/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
void SwWrtShell::Invalidate()
{ // to avoid making the slot volatile, invalidate it every time if something could have been changed // this is still much cheaper than asking for the state every 200 ms (and avoid background processing)
GetView().GetViewFrame().GetBindings().Invalidate( FN_STAT_SELMODE );
GetView().GetViewFrame().GetBindings().Update(FN_STAT_SELMODE); // make selection mode control icon update immediately
SwWordCountWrapper *pWrdCnt = static_cast<SwWordCountWrapper*>(GetView().GetViewFrame().GetChildWindow(SwWordCountWrapper::GetChildWindowId())); if (pWrdCnt)
pWrdCnt->UpdateCounts();
}
// the GoEnd() could have created a table selection, if so avoid ESA. if (bNeedsExtendedSelectAll && bIsCursorInTable)
{
bNeedsExtendedSelectAll = !HasWholeTabSelection();
}
if (bNeedsExtendedSelectAll)
{
ExtendedSelectAll(/*bFootnotes =*/ false);
}
if( oStartPos )
{
pTmpCursor = getShellCursor( false ); if( pTmpCursor )
{ // Some special handling for sections (e.g. TOC) at the beginning of the document body // to avoid the selection of the first section // if the last selection was behind the first section or // if the last selection was already the first section // In this both cases we select to the end of document if( ( *pTmpCursor->GetPoint() < *oEndPos ||
( *oStartPos == *pTmpCursor->GetMark() &&
*oEndPos == *pTmpCursor->GetPoint() ) ) && !bNeedsExtendedSelectAll)
SwCursorShell::SttEndDoc(false);
}
}
}
EndSelect();
LockView( bLockedView );
}
void SwWrtShell::PopMode()
{ if ( nullptr == m_pModeStack ) return;
if ( m_bExtMode && !m_pModeStack->bExt )
LeaveExtMode(); if ( m_bAddMode && !m_pModeStack->bAdd )
LeaveAddMode(); if ( m_bBlockMode && !m_pModeStack->bBlock )
LeaveBlockMode();
m_bIns = m_pModeStack->bIns;
m_pModeStack = std::move(m_pModeStack->pNext);
}
// Two methods for setting cursors: the first maps at the // eponymous methods in the CursorShell, the second removes // all selections at first.
tools::Long SwWrtShell::SetCursor(const Point *pPt, bool bTextOnly, ScrollSizeMode eScrollSizeMode)
{ // Remove a possibly present selection at the position // of the mouseclick
void SwWrtShell::UnSelectFrame()
{ // Remove Frame selection with guaranteed invalid position
Point aPt(LONG_MIN, LONG_MIN);
SelectObj(aPt);
SwTransferable::ClearSelection( *this );
}
// Remove of all selections
tools::Long SwWrtShell::ResetSelect(const Point *, bool, ScrollSizeMode)
{ if(IsSelFrameMode())
{
UnSelectFrame();
LeaveSelFrameMode();
} else
{ // SwActContext opens an Action - // to avoid problems in the basic process with the // shell switching, GetChgLnk().Call() may be called // after EndAction().
{
SwActContext aActContext(this);
m_bSelWrd = m_bSelLn = false;
KillPams();
ClearMark();
m_fnKillSel = &SwWrtShell::Ignore;
m_fnSetCursor = &SwWrtShell::SetCursor;
}
// After canceling of all selections an update of Attr-Controls // could be necessary.
GetChgLnk().Call(nullptr);
// Bug 66823: actual crsr has in additional mode no selection? // Then destroy the actual and go to prev, this will be expand if( !HasMark() && GoPrevCursor() )
{ bool bHasMark = HasMark(); // that's wrong!
GoNextCursor(); if( bHasMark )
{
DestroyCursor();
GoPrevCursor();
}
}
// check the direction of the selection with the new point bool bMoveCursor = true, bToTop = false;
SwCursorShell::SelectWord( &m_aStart ); // select the startword
SwCursorShell::Push(); // save the cursor
SwCursorShell::SetCursor( *pPt ); // and check the direction
// Bug 66823: actual crsr has in additional mode no selection? // Then destroy the actual and go to prev, this will be expand if( !HasMark() && GoPrevCursor() )
{ bool bHasMark = HasMark(); // that's wrong!
GoNextCursor(); if( bHasMark )
{
DestroyCursor();
GoPrevCursor();
}
}
// if applicable fit the selection to the "Mark" bool bToTop = !IsCursorPtAtEnd();
SwapPam();
// The "Mark" has to be at the end or the beginning of the line. if( bToTop ? !IsEndSentence() : !IsStartSentence() )
{ if( bToTop )
{ if( !IsEndPara() )
SwCursorShell::Right(1,SwCursorSkipMode::Chars);
SwCursorShell::GoEndSentence();
} else
SwCursorShell::GoStartSentence();
}
SwapPam();
if (bToTop)
SwCursorShell::GoStartSentence(); else
SwCursorShell::GoEndSentence();
}
// Back into the standard mode: no mode, no selections.
void SwWrtShell::EnterStdMode()
{ if(m_bAddMode)
LeaveAddMode(); if(m_bBlockMode)
LeaveBlockMode();
m_bBlockMode = false;
m_bExtMode = false;
m_bInSelect = false; if(IsSelFrameMode())
{
UnSelectFrame();
LeaveSelFrameMode();
} else
{ // SwActContext opens and action which has to be // closed prior to the call of // GetChgLnk().Call()
SwActContext aActContext(this);
m_bSelWrd = m_bSelLn = false; if( !IsRetainSelection() )
KillPams();
ClearMark();
m_fnSetCursor = &SwWrtShell::SetCursorKillSel;
m_fnKillSel = &SwWrtShell::ResetSelect;
}
Invalidate();
SwTransferable::ClearSelection( *this );
}
void SwWrtShell::AssureStdMode()
{ // deselect any drawing or frame and leave editing mode if (SdrView* pSdrView = GetDrawView())
{ if (pSdrView->IsTextEdit())
{ bool bLockView = IsViewLocked();
LockView(true);
EndTextEdit();
LockView(bLockView);
} // go out of the frame
Point aPt(LONG_MIN, LONG_MIN);
SelectObj(aPt, SW_LEAVE_FRAME);
} if (IsSelFrameMode() || GetSelectedObjCount())
{
UnSelectFrame();
LeaveSelFrameMode();
GetView().LeaveDrawCreate();
EnterStdMode();
DrawSelChanged();
GetView().StopShellTimer();
} else
EnterStdMode();
}
// equal call of BeginDrag in the SwFEShell
m_fnDrag = &SwWrtShell::BeginFrameDrag;
m_fnEndDrag = &SwWrtShell::UpdateLayoutFrame;
SwBaseShell::SetFrameMode( FLY_DRAG_START, this );
Invalidate();
}
// Description: Check if a word selection is present. // According to the rules for intelligent cut / paste // surrounding spaces are cut out. // Return: Delivers the type of the word selection.
int SwWrtShell::IntelligentCut(SelectionType nSelection, bool bCut)
{ // On multiple selection no intelligent drag and drop // there are multiple cursors, since a second was placed // already at the target position. if( IsAddMode() || !(nSelection & SelectionType::Text) ) return NO_WORD;
// For the preservation of the selection the cursor will be moved left // after SetMark(), so that the cursor is not moved by inserting text. // Because a present selection at the CORE page is cleared at the // current cursor position, the cursor will be pushed on the stack. // After moving, they will again resummarized.
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.