/* -*- 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 .
*/ #pragma once
class SfxItemSet; class SfxPoolItem; class SwCallLink; class SwContentFrame; class SwUnoCursor; class SwFormatField; class SwTextFormatColl; class SwTextINetFormat; class SwFormatINetFormat; class SwTextAttr; class SwTOXMark; class SwRangeRedline; class SwBlockCursor; class SwPostItField; class SwTextField; class SwTextFootnote; class SwTextContentControl; class SwMarkName;
namespace i18nutil { struct SearchOptions2;
} namespace com::sun::star::text { class XTextRange; } namespace com::sun::star::container { class XStringKeyMap; }
// enum and struct to get information via the Doc-Position
// return values of SetCursor (can be combined via ||) constint CRSR_POSOLD = 0x01, // cursor stays at old position
CRSR_POSCHG = 0x02; // position changed by the layout
struct VisibleCursorState
{
SwRect m_aCharRect; ///< Char-SRectangle on which the cursor is located
Point m_aCursorHeight; ///< height & offset from visible Cursor
SwShellCursor* m_pCurrentCursor; ///< currently active cursor
SwVisibleCursor *m_pVisibleCursor; ///< cursor displayed in view bool m_bSVCursorVis : 1; ///< SV-Cursor visible/invisible bool m_bOverwriteCursor : 1; ///< true -> show Overwrite Cursor
Point m_aOldRBPos; ///< Right/Bottom of last VisArea // (used in Invalidate by Cursor)
Link<const SwFlyFrameFormat*,void> m_aFlyMacroLnk; /**< Link will be called, if the Cursor is set
into a fly. A macro can then be called */
Link<LinkParamNone*,void> m_aChgLnk; /**< link will be called by every attribute/
format changes at cursor position.*/
Link<SwCursorShell&,void> m_aGrfArrivedLnk; ///< Link calls to UI if a graphic is arrived
SwShellCursor* m_pStackCursor; ///< stack for the cursor
SwBlockCursor *m_pBlockCursor; ///< interface of cursor for block (=rectangular) selection
SwShellTableCursor* m_pTableCursor; /**< table Cursor; only in tables when the
selection lays over 2 columns */
SwNodeIndex* m_pBoxIdx; ///< for recognizing of the changed
SwTableBox* m_pBoxPtr; ///< table row
tools::Long m_nUpDownX; /**< try to move the cursor on up/down always
in the same column */
tools::Long m_nLeftFramePos;
SwNodeOffset m_nCurrentNode; // save CursorPos at Start-Action
sal_Int32 m_nCurrentContent;
SwNodeType m_nCurrentNdTyp;
/* * Via the Method SttCursorMove and EndCursorMove this counter gets * incremented/decremented. As long as the counter is inequal to 0, the * current Cursor gets no update. This way, "complicated" cursor movements * (via Find()) can be realised.
*/
sal_uInt16 m_nCursorMove;
CursorMoveState m_eMvState; ///< Status for Cursor-Travelling - GetModelPositionForViewPoint
SwTable::SearchType m_eEnhancedTableSel; /// table rows or columns selected by not cell by cell
OUString m_sMarkedListId; int m_nMarkedListLevel;
bool m_bHasFocus : 1; ///< Shell is "active" in a window bool m_bChgCallFlag : 1; ///< attribute change inside Start- and EndAction bool m_bVisPortChgd : 1; ///< in VisPortChg-Call // (used in Invalidate by the Cursor)
bool m_bCallChgLnk : 1; ///< flag for derived classes // true -> call ChgLnk // access only via SwChgLinkFlag bool m_bAllProtect : 1; ///< Flag for areas // true -> everything protected / hidden bool m_bInCMvVisportChgd : 1; ///< Flag for CursorMoves // true -> view was moved bool m_bGCAttr : 1; // true -> non expanded attributes exist. bool m_bIgnoreReadonly : 1; // true -> make the cursor visible on next // EndAction in spite of Readonly bool m_bSelTableCells : 1; // true -> select cells over the InputWin bool m_bAutoUpdateCells : 1; // true -> autoformat cells bool m_bBasicHideCursor : 1; // true -> HideCursor from Basic bool m_bSetCursorInReadOnly : 1;// true -> Cursor is allowed in ReadOnly-Areas
// true -> send accessible events when cursor changes // (set to false when using internal-only helper cursor) bool m_bSendAccessibleCursorEvents : 1;
bool m_bMacroExecAllowed : 1;
// SwViewShell::LayoutIdle needs to be called on cursor update to repeat a spell check, // because previous attempt marked a word as pending, because the word had cursor bool m_bNeedLayoutOnCursorUpdate : 1 = false;
SwFrame* m_oldColFrame;
Idle m_aLayoutIdle; // An idle to schedule another SwViewShell::LayoutIdle call
/* * Compare-Method for the StackCursor and the current Cursor. * The Methods return -1, 0, 1 for lower, equal, greater.
*/ int CompareCursorStackMkCurrPt() const;
// create new cursor and append the old one virtual SwCursor & CreateNewShellCursor() override;
SW_DLLPUBLIC virtual SwCursor & GetCurrentShellCursor() override;
SW_DLLPUBLIC SwPaM * CreateCursor(); ///< delete the current cursor and make the following into the current
SW_DLLPUBLIC void DestroyCursor(); ///< transform TableCursor to normal cursor, nullify Tablemode void TableCursorToCursor(); ///< enter block mode, change normal cursor into block cursor void CursorToBlockCursor(); ///< leave block mode, change block cursor into normal cursor void BlockCursorToCursor();
// SelAll() selects the document body content // if ExtendedSelect() is called afterwards, the whole nodes array is selected // only for usage in special cases allowed! void ExtendedSelectAll(bool bFootnotes = true); /// If ExtendedSelectAll() was called and selection didn't change since then. typedef std::optional<std::pair<SwNode const*, std::vector<SwTableNode*>>> ExtendedSelection;
ExtendedSelection ExtendedSelectedAll() const; enumclass StartsWith { None, Table, HiddenPara, HiddenSection }; /// If document body starts with a table or starts/ends with hidden paragraph.
StartsWith StartsWith_();
SW_DLLPUBLIC SwCursor* GetCursor( bool bMakeTableCursor = true ) const; // return only the current cursor
SwShellCursor* GetCursor_() { return m_pCurrentCursor; } const SwShellCursor* GetCursor_() const { return m_pCurrentCursor; }
// show passed cursor - for UNO void SetSelection(const SwPaM& rCursor);
// remove all cursors from ContentNodes and set to 0 void ParkCursor( const SwNode &rIdx );
// return the current cursor stack // (required in EditShell when deleting contents) inline SwPaM* GetStackCursor() const;
// start parenthesing, hide SV-Cursor and selected areas
SW_DLLPUBLIC virtualvoid StartAction() override; // end parenthesing, show SV-Cursor and selected areas
SW_DLLPUBLIC virtualvoid EndAction(constbool bIdleEnd = false) override;
// Position the Cursor // return values: // CRSR_POSCHG: when cursor was corrected from SPoint by the layout // CRSR_POSOLD: when the cursor was not changed /** * @param bFieldInfo * false: Over the last half of the character, place cursor behind it. This is used when * the cursor is actually being moved by the user to the closest valid point. * true: Place the cursor at the start of the character/field. This is used when setting * the cursor is done in order to get at the properties under the mouse pointer.
*/
SW_DLLPUBLIC int SetCursor(const Point& rPt, bool bOnlyText = false, bool bBlock = true, bool bFieldInfo = false, ScrollSizeMode eScrollSizeMode = ScrollSizeMode::ScrollSizeDefault);
/* * Notification that the visible area was changed. m_aVisArea is reset, then * scrolling is done. The passed Rectangle lays on pixel borders to avoid * pixel errors.
*/ virtualvoid VisPortChgd( const SwRect & ) override;
/* * virtual paint method to make selection visible again after Paint
*/ void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle & rRect) override;
// Areas inlinevoid SetMark(); inlinebool HasMark() const;
SW_DLLPUBLIC void ClearMark();
/** Ensure point and mark of the current PaM are in a specific order.
@param bPointFirst true: If the point is behind the mark then swap the PaM. false: If the mark is behind the point then swap the PaM.
*/
SW_DLLPUBLIC void NormalizePam(bool bPointFirst = true);
/// store a copy of the current cursor on the cursor stack
SW_DLLPUBLIC void Push(); enumclass PopMode { DeleteCurrent, DeleteStack }; /* * Delete a cursor * - either from the top of the stack * - or delete the current one and replace it with the cursor from the * stack * @return <true> if there was one on the stack, <false> otherwise
*/ bool Pop(PopMode, ::std::optional<SwCallLink>& roLink);
SW_DLLPUBLIC bool Pop(PopMode); /* * Combine 2 Cursors. * Delete the topmost from the stack and move its Mark into the current.
*/ void Combine();
/* * When the focus is lost the selected ranges are not displayed anymore. * On the other hand, on receiving the focus all selected ranges are displayed again * (ranges must be recalculated!).
*/ bool HasShellFocus() const { return m_bHasFocus; } void ShellLoseFocus(); void ShellGetFocus();
// Methods for displaying or hiding the visible text cursor.
SW_DLLPUBLIC void ShowCursor();
SW_DLLPUBLIC void HideCursor(); // Methods for displaying or hiding the selected ranges with visible cursor. void ShowCursors( bool bCursorVis ); void HideCursors();
// Return current frame in which the cursor is placed.
SW_DLLPUBLIC SwContentFrame *GetCurrFrame( constbool bCalcFrame = true ) const;
//true if cursor is hidden because of readonly. //false if it is working despite readonly.
SW_DLLPUBLIC bool IsCursorReadonly() const;
// Cursor is placed in something that is protected or selection contains // something that is protected.
SW_DLLPUBLIC bool HasReadonlySel(bool isReplace = false) const; bool HasHiddenSections() const;
// Can the cursor be set to read only ranges? bool IsReadOnlyAvailable() const { return m_bSetCursorInReadOnly; } void SetReadOnlyAvailable( bool bFlag ); bool IsOverReadOnlyPos( const Point& rPt ) const;
//Call ChgLink. When within an action calling will be delayed. void CallChgLnk();
// Check if the current cursor contains a selection, i.e. // if Mark is set and SPoint and Mark are different.
SW_DLLPUBLIC bool HasSelection() const;
// Check if a selection exists, i.e. if the current cursor comprises a selection. inlinebool IsSelection() const; // returns if multiple cursors are available inlinebool IsMultiSelection() const;
// Check if a complete paragraph was selected. bool IsSelFullPara() const;
// Check if selection is within one paragraph.
//Should WaitPtr be activated for Clipboard. bool ShouldWait() const;
// Check if selection is within one paragraph. bool IsSelOnePara() const;
// Check if selection starts a paragraph. bool IsSelStartPara() const;
/* * Returns SRectangle, at which the cursor is located.
*/ const SwRect &GetCharRect() const { return m_aCharRect; } /* * Returns if cursor is wholly or partly within visible range.
*/ bool IsCursorVisible() const { return VisArea().Overlaps( GetCharRect() ); } /* * Returns SwRect, at which the character is located.
*/ void GetCharRectAt(SwRect& rRect, const SwPosition* pPos);
// Return current page number: // true: in which cursor is located. // false: which is visible at the upper margin.
SW_DLLPUBLIC void GetPageNum( sal_uInt16 &rnPhyNum, sal_uInt16 &rnVirtNum, bool bAtCursorPos = true, constbool bCalcFrame = true ); // Returns current page's sequential number (1-based),in which cursor is located, ignoring autoinserted empty pages. // Returns 0 on error
SW_DLLPUBLIC sal_uInt16 GetPageNumSeqNonEmpty(); // Determine how "empty pages" are handled // (used in PhyPage).
sal_uInt16 GetNextPrevPageNum( bool bNext = true );
// Move cursor at the beginning of page "nPage". bool GotoPage( sal_uInt16 nPage );
// update Cursr, i.e. reset it into content should only be called when the // cursor was set to a random position e.g. when deleting frames void UpdateCursorPos();
// get the selected text at the current cursor. It will be filled with // fields etc.
SW_DLLPUBLIC OUString GetSelText() const;
/// Check if Point of current cursor is placed within a table.
SW_DLLPUBLIC const SwTableNode* IsCursorInTable() const; bool MoveOutOfTable(); bool TrySelectOuterTable(); bool MoveStartText();
SW_DLLPUBLIC bool IsCursorInFootnote() const;
inline Point& GetCursorDocPos() const; // get cursor position relative to the page it is in
Point GetCursorPagePos() const; inlinebool IsCursorPtAtEnd() const;
bool IsTableComplexForChart(); // get current table selection as text
OUString GetBoxNms() const;
// set Cursor to the next/previous cell
SW_DLLPUBLIC bool GoNextCell( bool bAppendLine = true );
SW_DLLPUBLIC bool GoPrevCell(); // go to this box (if available and inside of table) bool GotoTable( const UIName& rName );
// select a table row, column or box (based on the current cursor) bool SelTableRow() { return SelTableRowOrCol( true ); } bool SelTableCol() { return SelTableRowOrCol( false ); } bool SelTableBox();
SW_DLLPUBLIC bool SelTable();
void GotoNextNum(); void GotoPrevNum();
bool GotoOutline( const OUString& rName ); // to the next/previous or the given OutlineNode void GotoOutline( SwOutlineNodes::size_type nIdx ); // find the "outline position" in the nodes array of the current chapter
SW_DLLPUBLIC SwOutlineNodes::size_type GetOutlinePos(sal_uInt8 nLevel = UCHAR_MAX, SwPaM* pPaM = nullptr); // select the given range of OutlineNodes. Optionally including the children // the sal_uInt16s are the positions in OutlineNodes-Array (EditShell) void MakeOutlineSel(SwOutlineNodes::size_type nSttPos, SwOutlineNodes::size_type nEndPos, bool bWithChildren, bool bKillPams = true, const SwOutlineNodesInline* pOutlNdsInline = nullptr);
bool GotoNextOutline(); bool GotoPrevOutline();
/** Delivers the current shell cursor
Some operations have to run on the current cursor ring, some on the m_pTableCursor (if exist) or the current cursor ring and some on the m_pTableCursor or m_pBlockCursor or the current cursor ring. This small function checks the existence and delivers the wished cursor.
@param bBlock [bool] if the block cursor is of interest or not
@return m_pTableCursor if exist, m_pBlockCursor if exist and of interest (param bBlock) otherwise m_pCurrentCursor
*/
SW_DLLPUBLIC SwShellCursor* getShellCursor( bool bBlock ); const SwShellCursor* getShellCursor( bool bBlock ) const
{ returnconst_cast<SwCursorShell*>(this)->getShellCursor( bBlock ); }
SW_DLLPUBLIC bool GotoFootnoteText(); ///< jump from content to footnote bool GotoFootnoteAnchor(); ///< jump from footnote to anchor
SW_DLLPUBLIC bool GotoPrevFootnoteAnchor();
SW_DLLPUBLIC bool GotoNextFootnoteAnchor();
void GotoFlyAnchor(); ///< jump from the frame to the anchor
SW_DLLPUBLIC bool GotoHeaderText(); ///< jump from the content to the header bool GotoFooterText(); ///< jump from the content to the footer // jump to the header/footer of the given or current PageDesc bool SetCursorInHdFt(size_t nDescNo, bool bInHeader, bool bEven = false, bool bFirst = false); // is point of cursor in header/footer. pbInHeader return true if it is // in a headerframe otherwise in a footerframe
SW_DLLPUBLIC bool IsInHeaderFooter( bool* pbInHeader = nullptr ) const;
bool GotoNextTOXBase( const UIName* = nullptr ); bool GotoPrevTOXBase( const UIName* = nullptr ); void GotoTOXMarkBase(); // jump to the next or previous index entry bool GotoNxtPrvTOXMark( bool bNext = true ); // jump to the next/previous index mark of this type
SW_DLLPUBLIC const SwTOXMark& GotoTOXMark( const SwTOXMark& rStart, SwTOXSearch eDir );
// jump to the next or previous table formula // optionally only to broken formulas bool GotoNxtPrvTableFormula( bool bNext = true, bool bOnlyErrors = false ); // jump to the next / previous hyperlink - inside text and also // on graphics bool SelectNxtPrvHyperlink( bool bNext );
// get the nth character from the start or end of the current selection
sal_Unicode GetChar( bool bEnd = true, tools::Long nOffset = 0 ); bool ExtendSelection( bool bEnd = true, sal_Int32 nCount = 1 );
// Place only the visible cursor at the given position in the document. // Return false if SPoint was corrected by layout. // (This is needed for displaying the Drag&Drop/Copy-Cursor.) bool SetVisibleCursor( const Point &rPt, ScrollSizeMode eScrollSizeMode = ScrollSizeMode::ScrollSizeDefault ); inlinevoid UnSetVisibleCursor();
SW_DLLPUBLIC SwVisibleCursor* GetVisibleCursor() const;
// jump to the next or previous field of the corresponding type bool MoveFieldType( const SwFieldType* pFieldType, constbool bNext, const SwFieldIds nResType = SwFieldIds::Unknown, constbool bAddSetExpressionFieldsToInputFields = true );
// Return number of cursors in ring (The flag indicates whether // only cursors containing selections are requested).
SW_DLLPUBLIC sal_uInt16 GetCursorCnt( bool bAll = true ) const;
// get position from current cursor bool IsStartWord( sal_Int16 nWordType = css::i18n::WordType::ANYWORD_IGNOREWHITESPACES )const; bool IsEndWord( sal_Int16 nWordType = css::i18n::WordType::ANYWORD_IGNOREWHITESPACES ) const; bool IsInWord( sal_Int16 nWordType = css::i18n::WordType::ANYWORD_IGNOREWHITESPACES ) const; bool IsStartSentence() const; bool IsEndSentence() const;
SW_DLLPUBLIC bool IsSttPara() const;
SW_DLLPUBLIC bool IsEndPara() const; bool IsEndOfTable() const; ///< at the very last SwPosition inside a table bool IsStartOfDoc() const;
SW_DLLPUBLIC bool IsEndOfDoc() const; bool IsInFrontOfLabel() const; bool IsAtLeftMargin() const { return IsAtLRMargin( true ); } bool IsAtRightMargin() const { return IsAtLRMargin( false, true/*bAPI*/ ); }
// delete all created cursors, set the table cursor and the last cursor to // its TextNode (or StartNode?) // They all get created on the next ::GetCursor again // Used for Drag&Drop/Clipboard-Paste in tables bool ParkTableCursor();
SvxFrameDirection GetTextDirection( const Point* pPt = nullptr ) const; // is cursor or the point in/over a vertical formatted text? bool IsInVerticalText( const Point* pPt = nullptr ) const; // is cursor or the point in/over a right to left formatted text? bool IsInRightToLeftText() const;
staticvoid FirePageChangeEvent(sal_uInt16 nOldPage, sal_uInt16 nNewPage); bool bColumnChange(); staticvoid FireSectionChangeEvent(sal_uInt16 nOldSection, sal_uInt16 nNewSection); staticvoid FireColumnChangeEvent(sal_uInt16 nOldColumn, sal_uInt16 nNewColumn); // If the current cursor position is inside a hidden range true is returned. If bSelect is // true, the hidden range is selected. If bSelect is false, the hidden range is not selected. bool IsInHiddenRange(constbool bSelect);
// remove all invalid cursors void ClearUpCursors();
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.