diff options
Diffstat (limited to 'editeng/source/editeng/impedit.hxx')
-rw-r--r-- | editeng/source/editeng/impedit.hxx | 1018 |
1 files changed, 518 insertions, 500 deletions
diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx index 7e22687aba7c..07f6af002358 100644 --- a/editeng/source/editeng/impedit.hxx +++ b/editeng/source/editeng/impedit.hxx @@ -70,7 +70,6 @@ class SvxLRSpaceItem; class TextRanger; class SvKeyValueIterator; class SvxForbiddenCharactersTable; -class SvtCTLOptions; namespace vcl { class Window; } class SvxNumberFormat; namespace com::sun::star::datatransfer::clipboard { @@ -91,63 +90,65 @@ namespace editeng { #define ATTRSPECIAL_WHOLEWORD 1 #define ATTRSPECIAL_EDGE 2 -enum class GetCursorFlags { - NONE = 0x0000, - TextOnly = 0x0001, - StartOfLine = 0x0002, - EndOfLine = 0x0004, - PreferPortionStart = 0x0008, +struct CursorFlags +{ + bool bTextOnly : 1 = false; + bool bStartOfLine : 1 = false; + bool bEndOfLine : 1 = false; + bool bPreferPortionStart : 1 = false; }; -namespace o3tl { - template<> struct typed_flags<GetCursorFlags> : is_typed_flags<GetCursorFlags, 0x0f> {}; -} - struct DragAndDropInfo { - tools::Rectangle aCurCursor; - tools::Rectangle aCurSavedCursor; - sal_uInt16 nSensibleRange; - sal_uInt16 nCursorWidth; - ESelection aBeginDragSel; - EditPaM aDropDest; - sal_Int32 nOutlinerDropDest; - ESelection aDropSel; - VclPtr<VirtualDevice> pBackground; - const SvxFieldItem* pField; - bool bVisCursor : 1; - bool bDroppedInMe : 1; - bool bStarterOfDD : 1; - bool bHasValidData : 1; - bool bUndoAction : 1; - bool bOutlinerMode : 1; - bool bDragAccepted : 1; - - DragAndDropInfo() - : nSensibleRange(0), nCursorWidth(0), nOutlinerDropDest(0), pBackground(nullptr), - pField(nullptr), bVisCursor(false), bDroppedInMe(false), bStarterOfDD(false), - bHasValidData(false), bUndoAction(false), bOutlinerMode(false), bDragAccepted(false) - { - } + tools::Rectangle aCurCursor; + tools::Rectangle aCurSavedCursor; + sal_uInt16 nSensibleRange = 0; + sal_uInt16 nCursorWidth = 0; + ESelection aBeginDragSel; + EditPaM aDropDest; + sal_Int32 nOutlinerDropDest = 0; + ESelection aDropSel; + VclPtr<VirtualDevice> pBackground = nullptr; + const SvxFieldItem* pField = nullptr; + bool bVisCursor : 1 = false; + bool bDroppedInMe : 1 = false; + bool bStarterOfDD : 1 = false; + bool bHasValidData : 1 = false; + bool bUndoAction : 1 = false; + bool bOutlinerMode : 1 = false; + bool bDragAccepted : 1 = false; + ~DragAndDropInfo() { - pBackground.disposeAndClear(); + pBackground.disposeAndClear(); } }; struct ImplIMEInfos { - OUString aOldTextAfterStartPos; + OUString aOldTextAfterStartPos; std::unique_ptr<ExtTextInputAttr[]> pAttribs; - EditPaM aPos; - sal_Int32 nLen; - bool bWasCursorOverwrite; + EditPaM aPos; + sal_Int32 nLen = 0; + bool bWasCursorOverwrite = false; - ImplIMEInfos( const EditPaM& rPos, const OUString& rOldTextAfterStartPos ); - ~ImplIMEInfos(); + ImplIMEInfos(const EditPaM& rPos, OUString _aOldTextAfterStartPos) + : aOldTextAfterStartPos(std::move(_aOldTextAfterStartPos)) + , aPos(rPos) + {} - void CopyAttribs( const ExtTextInputAttr* pA, sal_uInt16 nL ); - void DestroyAttribs(); + void CopyAttribs(const ExtTextInputAttr* pInputAttributes, sal_uInt16 nInputLength) + { + nLen = nInputLength; + pAttribs.reset(new ExtTextInputAttr[nInputLength]); + memcpy(pAttribs.get(), pInputAttributes, nInputLength * sizeof(ExtTextInputAttr)); + } + + void DestroyAttribs() + { + pAttribs.reset(); + nLen = 0; + } }; // #i18881# to be able to identify the positions of changed words @@ -156,56 +157,55 @@ typedef std::vector<EditSelection> SpellContentSelections; struct SpellInfo { - EditPaM aCurSentenceStart; - svx::SpellPortions aLastSpellPortions; - SpellContentSelections aLastSpellContentSelections; - EESpellState eState; - EPaM aSpellStart; - EPaM aSpellTo; - bool bSpellToEnd; - bool bMultipleDoc; - SpellInfo() : eState(EESpellState::Ok), bSpellToEnd(true), bMultipleDoc(false) - { } + EditPaM aCurSentenceStart; + svx::SpellPortions aLastSpellPortions; + SpellContentSelections aLastSpellContentSelections; + EESpellState eState = EESpellState::Ok; + EPaM aSpellStart; + EPaM aSpellTo; + bool bSpellToEnd : 1 = true; + bool bMultipleDoc : 1 = false; }; // used for text conversion struct ConvInfo { - EPaM aConvStart; - EPaM aConvTo; - EPaM aConvContinue; // position to start search for next text portion (word) with - bool bConvToEnd; - bool bMultipleDoc; - - ConvInfo() : bConvToEnd(true), bMultipleDoc(false) {} + EPaM aConvStart; + EPaM aConvTo; + EPaM aConvContinue; // position to start search for next text portion (word) with + bool bConvToEnd : 1 = true; + bool bMultipleDoc : 1 = false; }; struct FormatterFontMetric { - sal_uInt16 nMaxAscent; - sal_uInt16 nMaxDescent; + sal_uInt16 nMaxAscent = 0; + sal_uInt16 nMaxDescent = 0; - FormatterFontMetric() : nMaxAscent(0), nMaxDescent(0) { /* nMinLeading = 0xFFFF; */ } - sal_uInt16 GetHeight() const { return nMaxAscent+nMaxDescent; } + sal_uInt16 GetHeight() const + { + return nMaxAscent + nMaxDescent; + } }; class IdleFormattter : public Idle { private: - EditView* pView; - int nRestarts; + EditView* mpView = nullptr; + int mnRestarts = 0; public: - IdleFormattter(); - virtual ~IdleFormattter() override; + IdleFormattter(); + virtual ~IdleFormattter() override; - void DoIdleFormat( EditView* pV ); - void ForceTimeout(); - void ResetRestarts() { nRestarts = 0; } - EditView* GetView() { return pView; } + void DoIdleFormat(EditView* pView); + void ForceTimeout(); + void ResetRestarts() { mnRestarts = 0; } + EditView* GetView() { return mpView; } }; class ImpEditView; + /// This is meant just for Calc, where all positions in logical units (twips for LOK) are computed by /// doing independent pixel-alignment for each cell's size. LOKSpecialPositioning stores /// both 'output-area' and 'visible-doc-position' in pure logical unit (twips for LOK). @@ -234,6 +234,9 @@ public: Point GetWindowPos(const Point& rDocPos, MapUnit eDocPosUnit) const; tools::Rectangle GetWindowPos(const tools::Rectangle& rDocRect, MapUnit eDocRectUnit) const; + void SetFlags(LOKSpecialFlags eFlags) { meFlags = eFlags; } + bool IsLayoutRTL() { return bool(meFlags & LOKSpecialFlags::LayoutRTL); } + Point GetRefPoint() const; private: @@ -244,6 +247,7 @@ private: tools::Rectangle maOutArea; Point maVisDocStartPos; MapUnit meUnit; + LOKSpecialFlags meFlags; }; @@ -258,38 +262,37 @@ class ImpEditView : public vcl::unohelper::DragAndDropClient using vcl::unohelper::DragAndDropClient::dragOver; private: - EditView* pEditView; - std::unique_ptr<vcl::Cursor, o3tl::default_delete<vcl::Cursor>> pCursor; - std::optional<Color> mxBackgroundColor; + EditView* mpEditView; + std::unique_ptr<vcl::Cursor, o3tl::default_delete<vcl::Cursor>> mpCursor; + std::optional<Color> mxBackgroundColor; /// Containing view shell, if any. - OutlinerViewShell* mpViewShell; + OutlinerViewShell* mpViewShell; /// Another shell, just listening to our state, if any. - OutlinerViewShell* mpOtherShell; - EditEngine* pEditEngine; - VclPtr<vcl::Window> pOutWin; - EditView::OutWindowSet aOutWindowSet; - std::optional<PointerStyle> mxPointer; - std::unique_ptr<DragAndDropInfo> pDragAndDropInfo; - - css::uno::Reference< css::datatransfer::dnd::XDragSourceListener > mxDnDListener; - - - tools::Long nInvMore; - EVControlBits nControl; - sal_uInt32 nTravelXPos; - GetCursorFlags nExtraCursorFlags; - sal_uInt16 nCursorBidiLevel; - sal_uInt16 nScrollDiffX; - bool bReadOnly; - bool bClickedInSelection; - bool bActiveDragAndDropListener; - - Point aAnchorPoint; - tools::Rectangle aOutArea; - Point aVisDocStartPos; - EESelectionMode eSelectionMode; - EditSelection aEditSelection; - EEAnchorMode eAnchorMode; + OutlinerViewShell* mpOtherShell; + EditEngine* mpEditEngine; + VclPtr<vcl::Window> mpOutputWindow; + EditView::OutWindowSet maOutWindowSet; + std::optional<PointerStyle> mxPointer; + std::unique_ptr<DragAndDropInfo> mpDragAndDropInfo; + + css::uno::Reference<css::datatransfer::dnd::XDragSourceListener> mxDnDListener; + + tools::Long mnInvalidateMore; + EVControlBits mnControl; + sal_uInt32 mnTravelXPos; + CursorFlags maExtraCursorFlags; + sal_uInt16 mnCursorBidiLevel; + sal_uInt16 mnScrollDiffX; + bool mbReadOnly; + bool mbClickedInSelection; + bool mbActiveDragAndDropListener; + + Point maAnchorPoint; + tools::Rectangle maOutputArea; + Point maVisDocStartPos; + EESelectionMode meSelectionMode; + EditSelection maEditSelection; + EEAnchorMode meAnchorMode; /// mechanism to change from the classic refresh mode that simply // invalidates the area where text was changed. When set, the invalidate @@ -302,6 +305,7 @@ private: std::unique_ptr<LOKSpecialPositioning> mpLOKSpecialPositioning; bool mbBroadcastLOKViewCursor:1; bool mbSuppressLOKMessages:1; + bool mbNegativeX:1; EditViewCallbacks* getEditViewCallbacks() const { @@ -337,21 +341,24 @@ protected: void ShowDDCursor( const tools::Rectangle& rRect ); void HideDDCursor(); - void ImplDrawHighlightRect(OutputDevice& rTarget, const Point& rDocPosTopLeft, const Point& rDocPosBottomRight, tools::PolyPolygon* pPolyPoly); - tools::Rectangle ImplGetEditCursor(EditPaM& aPaM, GetCursorFlags nShowCursorFlags, - sal_Int32& nTextPortionStart, const ParaPortion* pParaPortion) const; + void ImplDrawHighlightRect(OutputDevice& rTarget, const Point& rDocPosTopLeft, const Point& rDocPosBottomRight, tools::PolyPolygon* pPolyPoly, bool bLOKCalcRTL); + tools::Rectangle ImplGetEditCursor(EditPaM& aPaM, CursorFlags aShowCursorFlags, sal_Int32& nTextPortionStart, ParaPortion const& rParaPortion) const; public: - ImpEditView( EditView* pView, EditEngine* pEng, vcl::Window* pWindow ); - virtual ~ImpEditView() override; + ImpEditView(EditView* pView, EditEngine* pEditEngine, vcl::Window* pWindow); + virtual ~ImpEditView() override; + + EditView* GetEditViewPtr() { return mpEditView; } - EditView* GetEditViewPtr() { return pEditView; } + EditEngine& getEditEngine() const { return *mpEditEngine; } + ImpEditEngine& getImpEditEngine() const { return getEditEngine().getImpl(); } - sal_uInt16 GetScrollDiffX() const { return nScrollDiffX; } - void SetScrollDiffX( sal_uInt16 n ) { nScrollDiffX = n; } - sal_uInt16 GetCursorBidiLevel() const { return nCursorBidiLevel; } - void SetCursorBidiLevel( sal_uInt16 n ) { nCursorBidiLevel = n; } + sal_uInt16 GetScrollDiffX() const { return mnScrollDiffX; } + void SetScrollDiffX(sal_uInt16 n) { mnScrollDiffX = n; } + + sal_uInt16 GetCursorBidiLevel() const { return mnCursorBidiLevel; } + void SetCursorBidiLevel(sal_uInt16 n) { mnCursorBidiLevel = n; } Point GetDocPos( const Point& rWindowPos ) const; Point GetWindowPos( const Point& rDocPos ) const; @@ -359,7 +366,7 @@ public: void SetOutputArea( const tools::Rectangle& rRect ); void ResetOutputArea( const tools::Rectangle& rRect ); - const tools::Rectangle& GetOutputArea() const { return aOutArea; } + const tools::Rectangle& GetOutputArea() const { return maOutputArea; } bool IsVertical() const; bool IsTopToBottom() const; @@ -373,22 +380,31 @@ public: bool Command(const CommandEvent& rCEvt); void CutCopy( css::uno::Reference< css::datatransfer::clipboard::XClipboard > const & rxClipboard, bool bCut ); - void Paste( css::uno::Reference< css::datatransfer::clipboard::XClipboard > const & rxClipboard, bool bUseSpecial = false ); + void Paste( css::uno::Reference< css::datatransfer::clipboard::XClipboard > const & rxClipboard, bool bUseSpecial = false, SotClipboardFormatId format = SotClipboardFormatId::NONE); - void SetVisDocStartPos( const Point& rPos ) { aVisDocStartPos = rPos; } + void SetVisDocStartPos(const Point& rPos) { maVisDocStartPos = rPos; } - tools::Long GetVisDocLeft() const { return aVisDocStartPos.X(); } - tools::Long GetVisDocTop() const { return aVisDocStartPos.Y(); } - tools::Long GetVisDocRight() const { return aVisDocStartPos.X() + ( !IsVertical() ? aOutArea.GetWidth() : aOutArea.GetHeight() ); } - tools::Long GetVisDocBottom() const { return aVisDocStartPos.Y() + ( !IsVertical() ? aOutArea.GetHeight() : aOutArea.GetWidth() ); } + tools::Long GetVisDocLeft() const { return maVisDocStartPos.X(); } + tools::Long GetVisDocTop() const { return maVisDocStartPos.Y(); } + tools::Long GetVisDocRight() const + { + return maVisDocStartPos.X() + ( !IsVertical() ? maOutputArea.GetWidth() : maOutputArea.GetHeight() ); + } + tools::Long GetVisDocBottom() const + { + return maVisDocStartPos.Y() + ( !IsVertical() ? maOutputArea.GetHeight() : maOutputArea.GetWidth() ); + } tools::Rectangle GetVisDocArea() const; - const EditSelection& GetEditSelection() const { return aEditSelection; } - void SetEditSelection( const EditSelection& rEditSelection ); - bool HasSelection() const { return aEditSelection.HasRange(); } + const EditSelection& GetEditSelection() const { return maEditSelection; } + void SetEditSelection(const EditSelection& rEditSelection); + bool HasSelection() const { return maEditSelection.HasRange(); } void SelectionChanged(); - void DrawSelectionXOR() { DrawSelectionXOR( aEditSelection ); } + void DrawSelectionXOR() + { + DrawSelectionXOR(maEditSelection); + } void DrawSelectionXOR( EditSelection, vcl::Region* pRegion = nullptr, OutputDevice* pTargetDevice = nullptr ); void GetSelectionRectangles(EditSelection aTmpSel, std::vector<tools::Rectangle>& rLogicRects); @@ -396,13 +412,36 @@ public: OutputDevice& GetOutputDevice() const; weld::Widget* GetPopupParent(tools::Rectangle& rRect) const; - vcl::Window* GetWindow() const { return pOutWin; } + vcl::Window* GetWindow() const { return mpOutputWindow; } void SetSelectionMode( EESelectionMode eMode ); - inline PointerStyle GetPointer(); + PointerStyle GetPointer() + { + if ( !mxPointer ) + { + mxPointer = IsVertical() ? PointerStyle::TextVertical : PointerStyle::Text; + return *mxPointer; + } + + if(PointerStyle::Text == *mxPointer && IsVertical()) + { + mxPointer = PointerStyle::TextVertical; + } + else if(PointerStyle::TextVertical == *mxPointer && !IsVertical()) + { + mxPointer = PointerStyle::Text; + } + + return *mxPointer; + } - inline vcl::Cursor* GetCursor(); + vcl::Cursor* GetCursor() + { + if (!mpCursor) + mpCursor.reset(new vcl::Cursor); + return mpCursor.get(); + } void AddDragAndDropListeners(); void RemoveDragAndDropListeners(); @@ -416,9 +455,11 @@ public: bool IsSelectionAtPoint( const Point& rPosPixel ); bool IsInSelection( const EditPaM& rPaM ); + bool IsSelectionFullPara() const; + bool IsSelectionInSinglePara() const; void SetAnchorMode( EEAnchorMode eMode ); - EEAnchorMode GetAnchorMode() const { return eAnchorMode; } + EEAnchorMode GetAnchorMode() const { return meAnchorMode; } void CalcAnchorPoint(); void RecalcOutputArea(); @@ -427,17 +468,17 @@ public: void ShowCursor( bool bGotoCursor, bool bForceVisCursor ); Pair Scroll( tools::Long ndX, tools::Long ndY, ScrollRangeCheck nRangeCheck = ScrollRangeCheck::NoNegative ); - void SetInsertMode( bool bInsert ); - bool IsInsertMode() const { return !( nControl & EVControlBits::OVERWRITE ); } + void SetInsertMode( bool bInsert ); + bool IsInsertMode() const { return !(mnControl & EVControlBits::OVERWRITE); } - bool IsPasteEnabled() const { return bool( nControl & EVControlBits::ENABLEPASTE ); } + bool IsPasteEnabled() const { return bool(mnControl & EVControlBits::ENABLEPASTE); } - bool DoSingleLinePaste() const { return bool( nControl & EVControlBits::SINGLELINEPASTE ); } - bool DoAutoScroll() const { return bool( nControl & EVControlBits::AUTOSCROLL ); } - bool DoAutoSize() const { return bool( nControl & EVControlBits::AUTOSIZE ); } - bool DoAutoWidth() const { return bool( nControl & EVControlBits::AUTOSIZEX); } - bool DoAutoHeight() const { return bool( nControl & EVControlBits::AUTOSIZEY); } - bool DoInvalidateMore() const { return bool( nControl & EVControlBits::INVONEMORE ); } + bool DoSingleLinePaste() const { return bool(mnControl & EVControlBits::SINGLELINEPASTE); } + bool DoAutoScroll() const { return bool(mnControl & EVControlBits::AUTOSCROLL); } + bool DoAutoSize() const { return bool(mnControl & EVControlBits::AUTOSIZE); } + bool DoAutoWidth() const { return bool(mnControl & EVControlBits::AUTOSIZEX); } + bool DoAutoHeight() const { return bool(mnControl & EVControlBits::AUTOSIZEY); } + bool DoInvalidateMore() const { return bool(mnControl & EVControlBits::INVONEMORE ); } void SetBackgroundColor( const Color& rColor ); const Color& GetBackgroundColor() const; @@ -455,8 +496,14 @@ public: void DeleteSelected(); // If possible invalidate more than OutputArea, for the DrawingEngine text frame - void SetInvalidateMore( sal_uInt16 nPixel ) { nInvMore = nPixel; } - sal_uInt16 GetInvalidateMore() const { return static_cast<sal_uInt16>(nInvMore); } + void SetInvalidateMore(sal_uInt16 nPixel) + { + mnInvalidateMore = nPixel; + } + sal_uInt16 GetInvalidateMore() const + { + return sal_uInt16(mnInvalidateMore); + } void InitLOKSpecialPositioning(MapUnit eUnit, const tools::Rectangle& rOutputArea, const Point& rVisDocStartPos); @@ -466,15 +513,20 @@ public: tools::Rectangle GetLOKSpecialVisArea() const; bool HasLOKSpecialPositioning() const; + void SetLOKSpecialFlags(LOKSpecialFlags eFlags); + void SuppressLOKMessages(bool bSet) { mbSuppressLOKMessages = bSet; } bool IsSuppressLOKMessages() const { return mbSuppressLOKMessages; } + + void SetNegativeX(bool bSet) { mbNegativeX = bSet; } + bool IsNegativeX() const { return mbNegativeX; } }; // ImpEditEngine -class ImpEditEngine : public SfxListener +class ImpEditEngine : public SfxListener, public svl::StyleSheetUser { friend class EditEngine; @@ -483,82 +535,77 @@ class ImpEditEngine : public SfxListener private: std::shared_ptr<editeng::SharedVclResources> pSharedVCL; - - // Data ... - - // Document Specific data ... - ParaPortionList aParaPortionList; // Formatting - Size aPaperSize; // Layout - Size aMinAutoPaperSize; // Layout ? - Size aMaxAutoPaperSize; // Layout ? + ParaPortionList maParaPortionList; // Formatting + Size maPaperSize; // Layout + Size maMinAutoPaperSize; // Layout ? + Size maMaxAutoPaperSize; // Layout ? tools::Long mnMinColumnWrapHeight = 0; // Corresponds to graphic object height - EditDoc aEditDoc; // Document content + EditDoc maEditDoc; // Document content // Engine Specific data ... - EditEngine* pEditEngine; - ViewsType aEditViews; - EditView* pActiveView; - std::unique_ptr<TextRanger> pTextRanger; + EditEngine* mpEditEngine; + ViewsType maEditViews; + EditView* mpActiveView; + std::unique_ptr<TextRanger> mpTextRanger; - SfxStyleSheetPool* pStylePool; - SfxItemPool* pTextObjectPool; + SfxStyleSheetPool* mpStylePool; + SfxItemPool* mpTextObjectPool; - VclPtr< VirtualDevice> pVirtDev; - VclPtr< OutputDevice > pRefDev; + VclPtr<VirtualDevice> mpVirtDev; + VclPtr<OutputDevice> mpRefDev; VclPtr<VirtualDevice> mpOwnDev; svtools::ColorConfig maColorConfig; - mutable std::unique_ptr<SvtCTLOptions> pCTLOptions; mutable std::unique_ptr<SfxItemSet> pEmptyItemSet; - EditUndoManager* pUndoManager; - std::unique_ptr<ESelection> pUndoMarkSelection; + EditUndoManager* mpUndoManager; + std::optional<ESelection> moUndoMarkSelection; std::unique_ptr<ImplIMEInfos> mpIMEInfos; - OUString aWordDelimiters; + OUString maWordDelimiters; - EditSelFunctionSet aSelFuncSet; - EditSelectionEngine aSelEngine; + EditSelFunctionSet maSelFuncSet; + EditSelectionEngine maSelEngine; Color maBackgroundColor; - sal_uInt16 nStretchX; - sal_uInt16 nStretchY; + ScalingParameters maCustomScalingParameters; + ScalingParameters maScalingParameters; + bool mbRoundToNearestPt; - CharCompressType nAsianCompressionMode; + CharCompressType mnAsianCompressionMode; - EEHorizontalTextDirection eDefaultHorizontalTextDirection; + EEHorizontalTextDirection meDefaultHorizontalTextDirection; - sal_Int32 nBigTextObjectStart; - css::uno::Reference< css::linguistic2::XSpellChecker1 > xSpeller; - css::uno::Reference< css::linguistic2::XHyphenator > xHyphenator; - std::unique_ptr<SpellInfo> pSpellInfo; - mutable css::uno::Reference < css::i18n::XBreakIterator > xBI; - mutable css::uno::Reference < css::i18n::XExtendedInputSequenceChecker > xISC; + sal_Int32 mnBigTextObjectStart; + css::uno::Reference<css::linguistic2::XSpellChecker1> mxSpeller; + css::uno::Reference<css::linguistic2::XHyphenator> mxHyphenator; + std::unique_ptr<SpellInfo> mpSpellInfo; + mutable css::uno::Reference <css::i18n::XBreakIterator> mxBI; + mutable css::uno::Reference <css::i18n::XExtendedInputSequenceChecker> mxISC; - std::unique_ptr<ConvInfo> pConvInfo; + std::unique_ptr<ConvInfo> mpConvInfo; - OUString aAutoCompleteText; + OUString maAutoCompleteText; - InternalEditStatus aStatus; + InternalEditStatus maStatus; - LanguageType eDefLanguage; + LanguageType meDefLanguage; - OnDemandLocaleDataWrapper xLocaleDataWrapper; - OnDemandTransliterationWrapper xTransliterationWrapper; + OnDemandLocaleDataWrapper mxLocaleDataWrapper; + OnDemandTransliterationWrapper mxTransliterationWrapper; // For Formatting / Update... - std::vector<std::unique_ptr<DeletedNodeInfo> > aDeletedNodes; - tools::Rectangle aInvalidRect; - tools::Long nCurTextHeight; - tools::Long nCurTextHeightNTP; // without trailing empty paragraphs - sal_uInt16 nOnePixelInRef; + std::vector<std::unique_ptr<DeletedNodeInfo>> maDeletedNodes; + tools::Rectangle maInvalidRect; + tools::Long mnCurTextHeight; + tools::Long mnCurTextHeightNTP; // without trailing empty paragraphs + sal_uInt16 mnOnePixelInRef; - IdleFormattter aIdleFormatter; - - Timer aOnlineSpellTimer; + IdleFormattter maIdleFormatter; + Timer maOnlineSpellTimer; // For Chaining sal_Int32 mnOverflowingPara = -1; @@ -570,51 +617,52 @@ private: // If it is detected at one point that the StatusHdl has to be called, but // this should not happen immediately (critical section): - Timer aStatusTimer; - Size aLOKSpecialPaperSize; - - Link<EditStatus&,void> aStatusHdlLink; - Link<EENotify&,void> aNotifyHdl; - Link<HtmlImportInfo&,void> aHtmlImportHdl; - Link<RtfImportInfo&,void> aRtfImportHdl; - Link<MoveParagraphsInfo&,void> aBeginMovingParagraphsHdl; - Link<MoveParagraphsInfo&,void> aEndMovingParagraphsHdl; - Link<PasteOrDropInfos&,void> aBeginPasteOrDropHdl; - Link<PasteOrDropInfos&,void> aEndPasteOrDropHdl; - Link<LinkParamNone*,void> aModifyHdl; + Timer maStatusTimer; + Size maLOKSpecialPaperSize; + + Link<EditStatus&,void> maStatusHdlLink; + Link<EENotify&,void> maNotifyHdl; + Link<HtmlImportInfo&,void> maHtmlImportHdl; + Link<RtfImportInfo&,void> maRtfImportHdl; + Link<MoveParagraphsInfo&,void> maBeginMovingParagraphsHdl; + Link<MoveParagraphsInfo&,void> maEndMovingParagraphsHdl; + Link<PasteOrDropInfos&,void> maBeginPasteOrDropHdl; + Link<PasteOrDropInfos&,void> maEndPasteOrDropHdl; + Link<LinkParamNone*,void> maModifyHdl; Link<EditView*,void> maBeginDropHdl; Link<EditView*,void> maEndDropHdl; - bool bKernAsianPunctuation:1; - bool bAddExtLeading:1; - bool bIsFormatting:1; - bool bFormatted:1; - bool bInSelection:1; - bool bIsInUndo:1; - bool bUpdateLayout:1; - bool bUndoEnabled:1; - bool bDowning:1; - bool bUseAutoColor:1; - bool bForceAutoColor:1; - bool bCallParaInsertedOrDeleted:1; - bool bFirstWordCapitalization:1; // specifies if auto-correction should capitalize the first word or not - bool mbLastTryMerge:1; - bool mbReplaceLeadingSingleQuotationMark:1; - - bool mbNbspRunNext; // can't be a bitfield as it is passed as bool& - + bool mbKernAsianPunctuation : 1; + bool mbAddExtLeading : 1; + bool mbIsFormatting : 1; + bool mbFormatted : 1; + bool mbInSelection : 1; + bool mbIsInUndo : 1; + bool mbUpdateLayout : 1; + bool mbUndoEnabled : 1; + bool mbDowning : 1; + bool mbUseAutoColor : 1; + bool mbForceAutoColor : 1; + bool mbCallParaInsertedOrDeleted : 1; + bool mbFirstWordCapitalization : 1; // specifies if auto-correction should capitalize the first word or not + bool mbLastTryMerge : 1; + bool mbReplaceLeadingSingleQuotationMark : 1; + bool mbSkipOutsideFormat : 1; + bool mbFuzzing : 1; + + bool mbNbspRunNext; // can't be a bitfield as it is passed as bool& // Methods... - void CursorMoved( const ContentNode* pPrevNode ); void ParaAttribsChanged( ContentNode const * pNode, bool bIgnoreUndoCheck = false ); void TextModified(); - void CalcHeight( ParaPortion* pPortion ); + void CalcHeight(ParaPortion& rParaPortion); + bool isInEmptyClusterAtTheEnd(ParaPortion& rParaPortion); void InsertUndo( std::unique_ptr<EditUndo> pUndo, bool bTryMerge = false ); void ResetUndoManager(); - bool HasUndoManager() const { return pUndoManager != nullptr; } + bool HasUndoManager() const { return mpUndoManager != nullptr; } std::unique_ptr<EditUndoSetAttribs> CreateAttribUndo( EditSelection aSel, const SfxItemSet& rSet ); @@ -623,10 +671,10 @@ private: std::tuple<const ParaPortion*, const EditLine*, tools::Long> GetPortionAndLine(Point aDocPos); EditPaM GetPaM( Point aDocPos, bool bSmart = true ); bool IsTextPos(const Point& rDocPos, sal_uInt16 nBorder); - tools::Long GetXPos(const ParaPortion* pParaPortion, const EditLine* pLine, sal_Int32 nIndex, bool bPreferPortionStart = false) const; - tools::Long GetPortionXOffset(const ParaPortion* pParaPortion, const EditLine* pLine, sal_Int32 nTextPortion) const; - sal_Int32 GetChar(const ParaPortion* pParaPortion, const EditLine* pLine, tools::Long nX, bool bSmart = true); - Range GetLineXPosStartEnd( const ParaPortion* pParaPortion, const EditLine* pLine ) const; + tools::Long GetXPos(ParaPortion const& rParaPortion, EditLine const& rLine, sal_Int32 nIndex, bool bPreferPortionStart = false) const; + tools::Long GetPortionXOffset(ParaPortion const& rParaPortion, EditLine const& rLine, sal_Int32 nTextPortion) const; + sal_Int32 GetChar(ParaPortion const& rParaPortion, EditLine const& rLine, tools::Long nX, bool bSmart = true); + Range GetLineXPosStartEnd(ParaPortion const& rParaPortion, EditLine const& rLine) const; void ParaAttribsToCharAttribs( ContentNode* pNode ); void GetCharAttribs( sal_Int32 nPara, std::vector<EECharAttrib>& rLst ) const; @@ -634,24 +682,28 @@ private: std::unique_ptr<EditTextObject> CreateTextObject(EditSelection aSelection, SfxItemPool*, bool bAllowBigObjects = false, sal_Int32 nBigObjStart = 0); EditSelection InsertTextObject( const EditTextObject&, EditPaM aPaM ); - EditSelection PasteText( css::uno::Reference< css::datatransfer::XTransferable > const & rxDataObj, const OUString& rBaseURL, const EditPaM& rPaM, bool bUseSpecial ); + EditSelection PasteText( css::uno::Reference< css::datatransfer::XTransferable > const & rxDataObj, const OUString& rBaseURL, const EditPaM& rPaM, bool bUseSpecial, SotClipboardFormatId format = SotClipboardFormatId::NONE); void CheckPageOverflow(); void Clear(); EditPaM RemoveText(); - bool CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY ); - void CreateAndInsertEmptyLine( ParaPortion* pParaPortion ); - bool FinishCreateLines( ParaPortion* pParaPortion ); - void CreateTextPortions( ParaPortion* pParaPortion, sal_Int32& rStartPos /*, sal_Bool bCreateBlockPortions */ ); - void RecalcTextPortion( ParaPortion* pParaPortion, sal_Int32 nStartPos, sal_Int32 nNewChars ); - sal_Int32 SplitTextPortion( ParaPortion* pParaPortion, sal_Int32 nPos, EditLine* pCurLine = nullptr ); + + bool createLinesForEmptyParagraph(ParaPortion& rParaPortion); + tools::Long calculateMaxLineWidth(tools::Long nStartX, SvxLRSpaceItem const& rLRItem); + bool CreateLines(sal_Int32 nPara, sal_uInt32 nStartPosY); + + void CreateAndInsertEmptyLine(ParaPortion& rParaPortion); + bool FinishCreateLines(ParaPortion& rParaPortion); + void CreateTextPortions(ParaPortion& rParaPortion, sal_Int32& rStartPos); + void RecalcTextPortion(ParaPortion& rParaPortion, sal_Int32 nStartPos, sal_Int32 nNewChars); + sal_Int32 SplitTextPortion(ParaPortion& rParaPortion, sal_Int32 nPos, EditLine* pCurLine = nullptr); void SeekCursor( ContentNode* pNode, sal_Int32 nPos, SvxFont& rFont, OutputDevice* pOut = nullptr ); void RecalcFormatterFontMetrics( FormatterFontMetric& rCurMetrics, SvxFont& rFont ); void CheckAutoPageSize(); - void ImpBreakLine( ParaPortion* pParaPortion, EditLine* pLine, TextPortion const * pPortion, sal_Int32 nPortionStart, tools::Long nRemainingWidth, bool bCanHyphenate ); - void ImpAdjustBlocks( ParaPortion* pParaPortion, EditLine* pLine, tools::Long nRemainingSpace ); + void ImpBreakLine(ParaPortion& rParaPortion, EditLine& rLine, TextPortion const * pPortion, sal_Int32 nPortionStart, tools::Long nRemainingWidth, bool bCanHyphenate); + void ImpAdjustBlocks(ParaPortion& rParaPortion, EditLine& rLine, tools::Long nRemainingSpace ); EditPaM ImpConnectParagraphs( ContentNode* pLeft, ContentNode* pRight, bool bBackward = false ); EditPaM ImpDeleteSelection(const EditSelection& rCurSel); EditPaM ImpInsertParaBreak( EditPaM& rPaM, bool bKeepEndingAttribs = true ); @@ -665,13 +717,11 @@ private: EditPaM ImpFastInsertText( EditPaM aPaM, const OUString& rStr ); EditPaM ImpFastInsertParagraph( sal_Int32 nPara ); - bool ImpCheckRefMapMode(); - bool ImplHasText() const; void ImpFindKashidas( ContentNode* pNode, sal_Int32 nStart, sal_Int32 nEnd, std::vector<sal_Int32>& rArray ); - void InsertContent( ContentNode* pNode, sal_Int32 nPos ); + void InsertContent(std::unique_ptr<ContentNode> pNode, sal_Int32 nPos); EditPaM SplitContent( sal_Int32 nNode, sal_Int32 nSepPos ); EditPaM ConnectContents( sal_Int32 nLeftNode, bool bBackward ); @@ -693,7 +743,7 @@ private: EditPaM WordRight( const EditPaM& rPaM, sal_Int16 nWordType = css::i18n::WordType::ANYWORD_IGNOREWHITESPACES ); EditPaM StartOfWord( const EditPaM& rPaM ); EditPaM EndOfWord( const EditPaM& rPaM ); - EditSelection SelectWord( const EditSelection& rCurSelection, sal_Int16 nWordType = css::i18n::WordType::ANYWORD_IGNOREWHITESPACES, bool bAcceptStartOfWord = true ); + EditSelection SelectWord( const EditSelection& rCurSelection, sal_Int16 nWordType = css::i18n::WordType::ANYWORD_IGNOREWHITESPACES, bool bAcceptStartOfWord = true, bool bAcceptEndOfWord = false ); EditSelection SelectSentence( const EditSelection& rCurSel ) const; EditPaM CursorVisualLeftRight( EditView const * pEditView, const EditPaM& rPaM, sal_uInt16 nCharacterIteratorMode, bool bToLeft ); EditPaM CursorVisualStartEnd( EditView const * pEditView, const EditPaM& rPaM, bool bStart ); @@ -707,11 +757,11 @@ private: bool ImplCalcAsianCompression( ContentNode* pNode, TextPortion* pTextPortion, sal_Int32 nStartPos, sal_Int32* pDXArray, sal_uInt16 n100thPercentFromMax, bool bManipulateDXArray ); - void ImplExpandCompressedPortions( EditLine* pLine, ParaPortion* pParaPortion, tools::Long nRemainingWidth ); + void ImplExpandCompressedPortions(EditLine& rLine, ParaPortion& rParaPortion, tools::Long nRemainingWidth); void ImplInitLayoutMode(OutputDevice& rOutDev, sal_Int32 nPara, sal_Int32 nIndex); - LanguageType ImplCalcDigitLang(LanguageType eCurLang) const; - void ImplInitDigitMode(OutputDevice& rOutDev, LanguageType eLang); + static LanguageType ImplCalcDigitLang(LanguageType eCurLang); + static void ImplInitDigitMode(OutputDevice& rOutDev, LanguageType eLang); static OUString convertDigits(std::u16string_view rString, sal_Int32 nStt, sal_Int32 nLen, LanguageType eDigitLang); EditPaM ReadText( SvStream& rInput, EditSelection aSel ); @@ -728,11 +778,40 @@ private: std::vector<std::unique_ptr<SvxFontItem>>& rFontTable, SvxColorList& rColorList ); sal_Int32 LogicToTwips( sal_Int32 n ); - inline short GetXValue( short nXValue ) const; - inline tools::Long GetXValue( tools::Long nXValue ) const; + double scaleXSpacingValue(tools::Long nXValue) const + { + if (!maStatus.DoStretch() || maScalingParameters.fSpacingX == 1.0) + return nXValue; + + return double(nXValue) * maScalingParameters.fSpacingX; + } + + double scaleYSpacingValue(sal_uInt16 nYValue) const + { + if (!maStatus.DoStretch() || maScalingParameters.fSpacingY == 1.0) + return nYValue; + + return double(nYValue) * maScalingParameters.fSpacingY; + } + + double scaleXFontValue(tools::Long nXValue) const + { + if (!maStatus.DoStretch() || (maScalingParameters.fFontX == 1.0)) + return nXValue; - inline short GetYValue( short nYValue ) const; - inline sal_uInt16 GetYValue( sal_uInt16 nYValue ) const; + return double(nXValue) * maScalingParameters.fFontX; + } + + double scaleYFontValue(sal_uInt16 nYValue) const + { + if (!maStatus.DoStretch() || (maScalingParameters.fFontY == 1.0)) + return nYValue; + + return double(nYValue) * maScalingParameters.fFontY; + } + + void setRoundToNearestPt(bool bRound) { mbRoundToNearestPt = bRound; } + double roundToNearestPt(double fInput) const; ContentNode* GetPrevVisNode( ContentNode const * pCurNode ); ContentNode* GetNextVisNode( ContentNode const * pCurNode ); @@ -746,13 +825,31 @@ private: tools::Long CalcVertLineSpacing(Point& rStartPos) const; Color GetAutoColor() const; - void EnableAutoColor( bool b ) { bUseAutoColor = b; } - bool IsAutoColorEnabled() const { return bUseAutoColor; } - void ForceAutoColor( bool b ) { bForceAutoColor = b; } - bool IsForceAutoColor() const { return bForceAutoColor; } + void EnableAutoColor( bool b ) { mbUseAutoColor = b; } + bool IsAutoColorEnabled() const { return mbUseAutoColor; } + void ForceAutoColor( bool b ) { mbForceAutoColor = b; } + bool IsForceAutoColor() const { return mbForceAutoColor; } + + VirtualDevice* GetVirtualDevice(const MapMode& rMapMode, DrawModeFlags nDrawMode) + { + if (!mpVirtDev) + mpVirtDev = VclPtr<VirtualDevice>::Create(); + + if ((mpVirtDev->GetMapMode().GetMapUnit() != rMapMode.GetMapUnit()) || + (mpVirtDev->GetMapMode().GetScaleX() != rMapMode.GetScaleX()) || + (mpVirtDev->GetMapMode().GetScaleY() != rMapMode.GetScaleY()) ) + { + MapMode aMapMode(rMapMode); + aMapMode.SetOrigin(Point(0, 0)); + mpVirtDev->SetMapMode(aMapMode); + } - inline VirtualDevice* GetVirtualDevice( const MapMode& rMapMode, DrawModeFlags nDrawMode ); - void EraseVirtualDevice() { pVirtDev.disposeAndClear(); } + mpVirtDev->SetDrawMode(nDrawMode); + + return mpVirtDev; + } + + void EraseVirtualDevice() { mpVirtDev.disposeAndClear(); } DECL_LINK( StatusTimerHdl, Timer *, void); DECL_LINK( IdleFormatHdl, Timer *, void); @@ -761,8 +858,19 @@ private: void CheckIdleFormatter(); - inline const ParaPortion& FindParaPortion( const ContentNode* pNode ) const; - inline ParaPortion& FindParaPortion( ContentNode const * pNode ); + const ParaPortion* FindParaPortion(const ContentNode* pNode) const + { + sal_Int32 nPos = maEditDoc.GetPos( pNode ); + DBG_ASSERT( nPos < GetParaPortions().Count(), "Portionloser Node?" ); + return GetParaPortions().SafeGetObject(nPos); + } + + ParaPortion* FindParaPortion(ContentNode const * pNode) + { + sal_Int32 nPos = maEditDoc.GetPos( pNode ); + DBG_ASSERT( nPos < GetParaPortions().Count(), "Portionloser Node?" ); + return GetParaPortions().SafeGetObject(nPos); + } css::uno::Reference< css::datatransfer::XTransferable > CreateTransferable( const EditSelection& rSelection ); @@ -780,15 +888,15 @@ private: ImpEditEngine(EditEngine* pEditEngine, SfxItemPool* pPool); void InitDoc(bool bKeepParaAttribs); - EditDoc& GetEditDoc() { return aEditDoc; } - const EditDoc& GetEditDoc() const { return aEditDoc; } + EditDoc& GetEditDoc() { return maEditDoc; } + const EditDoc& GetEditDoc() const { return maEditDoc; } - const ParaPortionList& GetParaPortions() const { return aParaPortionList; } - ParaPortionList& GetParaPortions() { return aParaPortionList; } + const ParaPortionList& GetParaPortions() const { return maParaPortionList; } + ParaPortionList& GetParaPortions() { return maParaPortionList; } tools::Long Calc1ColumnTextHeight(tools::Long* pHeightNTP); - void IdleFormatAndLayout(EditView* pCurView) { aIdleFormatter.DoIdleFormat(pCurView); } + void IdleFormatAndLayout(EditView* pCurView) { maIdleFormatter.DoIdleFormat(pCurView); } protected: virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; @@ -798,18 +906,44 @@ public: ImpEditEngine(const ImpEditEngine&) = delete; ImpEditEngine& operator=(const ImpEditEngine&) = delete; - inline EditUndoManager& GetUndoManager(); - inline SfxUndoManager* SetUndoManager(SfxUndoManager* pNew); + EditUndoManager& GetUndoManager() + { + if (!mpUndoManager) + { + mpUndoManager = new EditUndoManager(); + mpUndoManager->SetEditEngine(mpEditEngine); + } + return *mpUndoManager; + } + + EditUndoManager* SetUndoManager(EditUndoManager* pNew) + { + EditUndoManager* pRetval = mpUndoManager; + + if (mpUndoManager) + { + mpUndoManager->SetEditEngine(nullptr); + } + + mpUndoManager = pNew; + + if (mpUndoManager) + { + mpUndoManager->SetEditEngine(mpEditEngine); + } + + return pRetval; + } // @return the previous bUpdateLayout state bool SetUpdateLayout( bool bUpdate, EditView* pCurView = nullptr, bool bForceUpdate = false ); - bool IsUpdateLayout() const { return bUpdateLayout; } + bool IsUpdateLayout() const { return mbUpdateLayout; } - ViewsType& GetEditViews() { return aEditViews; } - const ViewsType& GetEditViews() const { return aEditViews; } + ViewsType& GetEditViews() { return maEditViews; } + const ViewsType& GetEditViews() const { return maEditViews; } - const Size& GetPaperSize() const { return aPaperSize; } - void SetPaperSize( const Size& rSz ) { aPaperSize = rSz; } + const Size& GetPaperSize() const { return maPaperSize; } + void SetPaperSize(const Size& rSize) { maPaperSize = rSize; } void SetVertical( bool bVertical); bool IsEffectivelyVertical() const { return GetEditDoc().IsEffectivelyVertical(); } @@ -825,8 +959,8 @@ public: void SetFixedCellHeight( bool bUseFixedCellHeight ); bool IsFixedCellHeight() const { return GetEditDoc().IsFixedCellHeight(); } - void SetDefaultHorizontalTextDirection( EEHorizontalTextDirection eHTextDir ) { eDefaultHorizontalTextDirection = eHTextDir; } - EEHorizontalTextDirection GetDefaultHorizontalTextDirection() const { return eDefaultHorizontalTextDirection; } + void SetDefaultHorizontalTextDirection( EEHorizontalTextDirection eHTextDir ) { meDefaultHorizontalTextDirection = eHTextDir; } + EEHorizontalTextDirection GetDefaultHorizontalTextDirection() const { return meDefaultHorizontalTextDirection; } void InitWritingDirections( sal_Int32 nPara ); @@ -835,18 +969,21 @@ public: bool HasDifferentRTLLevels( const ContentNode* pNode ); void SetTextRanger( std::unique_ptr<TextRanger> pRanger ); - TextRanger* GetTextRanger() const { return pTextRanger.get(); } + TextRanger* GetTextRanger() const { return mpTextRanger.get(); } - const Size& GetMinAutoPaperSize() const { return aMinAutoPaperSize; } - void SetMinAutoPaperSize( const Size& rSz ) { aMinAutoPaperSize = rSz; } + const Size& GetMinAutoPaperSize() const { return maMinAutoPaperSize; } + void SetMinAutoPaperSize(const Size& rSize) { maMinAutoPaperSize = rSize; } - const Size& GetMaxAutoPaperSize() const { return aMaxAutoPaperSize; } - void SetMaxAutoPaperSize( const Size& rSz ) { aMaxAutoPaperSize = rSz; } + const Size& GetMaxAutoPaperSize() const { return maMaxAutoPaperSize; } + void SetMaxAutoPaperSize(const Size& rSize) { maMaxAutoPaperSize = rSize; } void SetMinColumnWrapHeight(tools::Long nVal) { mnMinColumnWrapHeight = nVal; } - void FormatDoc(); - void FormatFullDoc(); + tools::Long FormatParagraphs(o3tl::sorted_vector<sal_Int32>& rRepaintParagraphs); + void ScaleContentToFitWindow(o3tl::sorted_vector<sal_Int32>& rRepaintParagraphs); + void FormatDoc(); + void FormatFullDoc(); + void UpdateViews( EditView* pCurView = nullptr ); void Paint( ImpEditView* pView, const tools::Rectangle& rRect, OutputDevice* pTargetDevice ); void Paint(OutputDevice& rOutDev, tools::Rectangle aClipRect, Point aStartPos, bool bStripOnly = false, Degree10 nOrientation = 0_deg10); @@ -857,7 +994,7 @@ public: bool MouseMove( const MouseEvent& rMouseEvent, EditView* pView ); bool Command(const CommandEvent& rCEvt, EditView* pView); - EditSelectionEngine& GetSelEngine() { return aSelEngine; } + EditSelectionEngine& GetSelEngine() { return maSelEngine; } OUString GetSelected( const EditSelection& rSel ) const; const SfxItemSet& GetEmptyItemSet() const; @@ -865,15 +1002,15 @@ public: void UpdateSelections(); void EnableUndo( bool bEnable ); - bool IsUndoEnabled() const { return bUndoEnabled; } - void SetUndoMode( bool b ) { bIsInUndo = b; } - bool IsInUndo() const { return bIsInUndo; } + bool IsUndoEnabled() const { return mbUndoEnabled; } + void SetUndoMode( bool b ) { mbIsInUndo = b; } + bool IsInUndo() const { return mbIsInUndo; } - void SetCallParaInsertedOrDeleted( bool b ) { bCallParaInsertedOrDeleted = b; } - bool IsCallParaInsertedOrDeleted() const { return bCallParaInsertedOrDeleted; } + void SetCallParaInsertedOrDeleted( bool b ) { mbCallParaInsertedOrDeleted = b; } + bool IsCallParaInsertedOrDeleted() const { return mbCallParaInsertedOrDeleted; } - bool IsFormatted() const { return bFormatted; } - bool IsFormatting() const { return bIsFormatting; } + bool IsFormatted() const { return mbFormatted; } + bool IsFormatting() const { return mbIsFormatting; } void SetText(const OUString& rText); EditPaM DeleteSelected(const EditSelection& rEditSelection); @@ -904,13 +1041,13 @@ public: sal_uInt32 GetTextHeightNTP() const; sal_uInt32 CalcTextWidth( bool bIgnoreExtraSpace); sal_uInt32 CalcParaWidth( sal_Int32 nParagraph, bool bIgnoreExtraSpace ); - sal_uInt32 CalcLineWidth( ParaPortion* pPortion, EditLine* pLine, bool bIgnoreExtraSpace); + sal_uInt32 CalcLineWidth(ParaPortion const& rPortion, EditLine const& rLine, bool bIgnoreExtraSpace); sal_Int32 GetLineCount( sal_Int32 nParagraph ) const; sal_Int32 GetLineLen( sal_Int32 nParagraph, sal_Int32 nLine ) const; void GetLineBoundaries( /*out*/sal_Int32& rStart, /*out*/sal_Int32& rEnd, sal_Int32 nParagraph, sal_Int32 nLine ) const; sal_Int32 GetLineNumberAtIndex( sal_Int32 nPara, sal_Int32 nIndex ) const; sal_uInt16 GetLineHeight( sal_Int32 nParagraph, sal_Int32 nLine ); - sal_uInt32 GetParaHeight( sal_Int32 nParagraph ); + sal_uInt32 GetParaHeight(sal_Int32 nParagraph) const; SfxItemSet GetAttribs( sal_Int32 nPara, sal_Int32 nStart, sal_Int32 nEnd, GetAttribsFlags nFlags = GetAttribsFlags::ALL ) const; SfxItemSet GetAttribs( EditSelection aSel, EditEngineAttribs nOnlyHardAttrib = EditEngineAttribs::All ); @@ -930,16 +1067,14 @@ public: return static_cast<const T&>(GetParaAttrib(nPara, sal_uInt16(nWhich))); } - tools::Rectangle PaMtoEditCursor( EditPaM aPaM, GetCursorFlags nFlags = GetCursorFlags::NONE ); - tools::Rectangle GetEditCursor(const ParaPortion* pPortion, const EditLine* pLine, - sal_Int32 nIndex, GetCursorFlags nFlags); + tools::Rectangle PaMtoEditCursor(EditPaM aPaM, CursorFlags aFlags = CursorFlags()); + tools::Rectangle GetEditCursor(ParaPortion const& rPortion, EditLine const& rLine, sal_Int32 nIndex, CursorFlags aFlags); - bool IsModified() const { return aEditDoc.IsModified(); } - void SetModifyFlag( bool b ) { aEditDoc.SetModified( b ); } - void SetModifyHdl( const Link<LinkParamNone*,void>& rLink ) { aModifyHdl = rLink; } - const Link<LinkParamNone*,void>& GetModifyHdl() const { return aModifyHdl; } + bool IsModified() const { return maEditDoc.IsModified(); } + void SetModifyFlag(bool b) { maEditDoc.SetModified( b ); } + void SetModifyHdl( const Link<LinkParamNone*,void>& rLink ) { maModifyHdl = rLink; } - bool IsInSelectionMode() const { return bInSelection; } + bool IsInSelectionMode() const { return mbInSelection; } // For Undo/Redo void Undo( EditView* pView ); @@ -950,26 +1085,61 @@ public: EditPaM InsertParagraph( sal_Int32 nPara ); std::optional<EditSelection> SelectParagraph( sal_Int32 nPara ); - void SetStatusEventHdl( const Link<EditStatus&, void>& rLink ) { aStatusHdlLink = rLink; } - const Link<EditStatus&,void>& GetStatusEventHdl() const { return aStatusHdlLink; } + void SetStatusEventHdl( const Link<EditStatus&, void>& rLink ) { maStatusHdlLink = rLink; } + const Link<EditStatus&,void>& GetStatusEventHdl() const { return maStatusHdlLink; } - void SetNotifyHdl( const Link<EENotify&,void>& rLink ) { aNotifyHdl = rLink; } - const Link<EENotify&,void>& GetNotifyHdl() const { return aNotifyHdl; } + void SetNotifyHdl( const Link<EENotify&,void>& rLink ) { maNotifyHdl = rLink; } + const Link<EENotify&,void>& GetNotifyHdl() const { return maNotifyHdl; } void FormatAndLayout( EditView* pCurView = nullptr, bool bCalledFromUndo = false ); const svtools::ColorConfig& GetColorConfig() const { return maColorConfig; } - bool IsVisualCursorTravelingEnabled(); - bool DoVisualCursorTraveling(); + static bool IsVisualCursorTravelingEnabled(); + static bool DoVisualCursorTraveling(); EditSelection ConvertSelection( sal_Int32 nStartPara, sal_Int32 nStartPos, sal_Int32 nEndPara, sal_Int32 nEndPos ); - inline EPaM CreateEPaM( const EditPaM& rPaM ) const; - inline EditPaM CreateEditPaM( const EPaM& rEPaM ); - inline ESelection CreateESel( const EditSelection& rSel ) const; - inline EditSelection CreateSel( const ESelection& rSel ); + + EPaM CreateEPaM( const EditPaM& rPaM ) const + { + const ContentNode* pNode = rPaM.GetNode(); + return EPaM(maEditDoc.GetPos(pNode), rPaM.GetIndex()); + } + + EditPaM CreateEditPaM( const EPaM& rEPaM ) + { + DBG_ASSERT( rEPaM.nPara < maEditDoc.Count(), "CreateEditPaM: invalid paragraph" ); + DBG_ASSERT(maEditDoc.GetObject(rEPaM.nPara)->Len() >= rEPaM.nIndex, "CreateEditPaM: invalid Index"); + return EditPaM(maEditDoc.GetObject(rEPaM.nPara), rEPaM.nIndex); + } + + ESelection CreateESel(const EditSelection& rSel) const + { + const ContentNode* pStartNode = rSel.Min().GetNode(); + const ContentNode* pEndNode = rSel.Max().GetNode(); + ESelection aESel; + aESel.nStartPara = maEditDoc.GetPos( pStartNode ); + aESel.nStartPos = rSel.Min().GetIndex(); + aESel.nEndPara = maEditDoc.GetPos( pEndNode ); + aESel.nEndPos = rSel.Max().GetIndex(); + return aESel; + } + + EditSelection CreateSel(const ESelection& rSel) + { + DBG_ASSERT( rSel.nStartPara < maEditDoc.Count(), "CreateSel: invalid start paragraph" ); + DBG_ASSERT( rSel.nEndPara < maEditDoc.Count(), "CreateSel: invalid end paragraph" ); + EditSelection aSel; + aSel.Min().SetNode(maEditDoc.GetObject(rSel.nStartPara)); + aSel.Min().SetIndex( rSel.nStartPos ); + aSel.Max().SetNode(maEditDoc.GetObject(rSel.nEndPara)); + aSel.Max().SetIndex( rSel.nEndPos ); + DBG_ASSERT( !aSel.DbgIsBuggy( maEditDoc ), "CreateSel: incorrect selection!" ); + return aSel; + + } void SetStyleSheetPool( SfxStyleSheetPool* pSPool ); - SfxStyleSheetPool* GetStyleSheetPool() const { return pStylePool; } + SfxStyleSheetPool* GetStyleSheetPool() const { return mpStylePool; } void SetStyleSheet( EditSelection aSel, SfxStyleSheet* pStyle ); void SetStyleSheet( sal_Int32 nPara, SfxStyleSheet* pStyle ); @@ -979,41 +1149,45 @@ public: void UpdateParagraphsWithStyleSheet( SfxStyleSheet* pStyle ); void RemoveStyleFromParagraphs( SfxStyleSheet const * pStyle ); - OutputDevice* GetRefDevice() const { return pRefDev.get(); } - void SetRefDevice( OutputDevice* pRefDef ); + bool isUsedByModel() const override { return true; } + + OutputDevice* GetRefDevice() const { return mpRefDev.get(); } + void SetRefDevice(OutputDevice* mpRefDef); + + const MapMode& GetRefMapMode() const { return mpRefDev->GetMapMode(); } + void SetRefMapMode(const MapMode& rMapMode); - const MapMode& GetRefMapMode() const { return pRefDev->GetMapMode(); } - void SetRefMapMode( const MapMode& rMapMode ); + InternalEditStatus& GetStatus() { return maStatus; } + InternalEditStatus const& GetStatus() const{ return maStatus; } - InternalEditStatus& GetStatus() { return aStatus; } void CallStatusHdl(); - void DelayedCallStatusHdl() { aStatusTimer.Start(); } + void DelayedCallStatusHdl() { maStatusTimer.Start(); } void UndoActionStart( sal_uInt16 nId ); void UndoActionStart( sal_uInt16 nId, const ESelection& rSel ); void UndoActionEnd(); - EditView* GetActiveView() const { return pActiveView; } + EditView* GetActiveView() const { return mpActiveView; } void SetActiveView( EditView* pView ); css::uno::Reference< css::linguistic2::XSpellChecker1 > const & GetSpeller(); void SetSpeller( css::uno::Reference< css::linguistic2::XSpellChecker1 > const &xSpl ) - { xSpeller = xSpl; } + { mxSpeller = xSpl; } const css::uno::Reference< css::linguistic2::XHyphenator >& - GetHyphenator() const { return xHyphenator; } + GetHyphenator() const { return mxHyphenator; } void SetHyphenator( css::uno::Reference< css::linguistic2::XHyphenator > const &xHyph ) - { xHyphenator = xHyph; } + { mxHyphenator = xHyph; } void GetAllMisspellRanges( std::vector<editeng::MisspellRanges>& rRanges ) const; void SetAllMisspellRanges( const std::vector<editeng::MisspellRanges>& rRanges ); - SpellInfo* GetSpellInfo() const { return pSpellInfo.get(); } + SpellInfo* GetSpellInfo() const { return mpSpellInfo.get(); } - void SetDefaultLanguage( LanguageType eLang ) { eDefLanguage = eLang; } - LanguageType GetDefaultLanguage() const { return eDefLanguage; } + void SetDefaultLanguage(LanguageType eLang) { meDefLanguage = eLang; } + LanguageType GetDefaultLanguage() const { return meDefLanguage; } - LanguageType GetLanguage( const EditPaM& rPaM, sal_Int32* pEndPos = nullptr ) const; + editeng::LanguageSpan GetLanguage( const EditPaM& rPaM, sal_Int32* pEndPos = nullptr ) const; css::lang::Locale GetLocale( const EditPaM& rPaM ) const; void DoOnlineSpelling( ContentNode* pThisNodeOnly = nullptr, bool bSpellAtCursorPos = false, bool bInterruptible = true ); @@ -1028,7 +1202,7 @@ public: void Convert(EditView* pEditView, weld::Widget* pDialogParent, LanguageType nSrcLang, LanguageType nDestLang, const vcl::Font *pDestFont, sal_Int32 nOptions, bool bIsInteractive, bool bMultipleDoc); void ImpConvert( OUString &rConvTxt, LanguageType &rConvTxtLang, EditView* pEditView, LanguageType nSrcLang, const ESelection &rConvRange, bool bAllowImplicitChangesForNotConvertibleText, LanguageType nTargetLang, const vcl::Font *pTargetFont ); - ConvInfo * GetConvInfo() const { return pConvInfo.get(); } + ConvInfo * GetConvInfo() const { return mpConvInfo.get(); } bool HasConvertibleTextPortion( LanguageType nLang ); void SetLanguageAndFont( const ESelection &rESel, LanguageType nLang, sal_uInt16 nLangWhichId, @@ -1064,8 +1238,8 @@ public: sal_Int32 StartSearchAndReplace( EditView* pEditView, const SvxSearchItem& rSearchItem ); bool HasText( const SvxSearchItem& rSearchItem ); - void SetEditTextObjectPool( SfxItemPool* pP ) { pTextObjectPool = pP; } - SfxItemPool* GetEditTextObjectPool() const { return pTextObjectPool; } + void SetEditTextObjectPool( SfxItemPool* pP ) { mpTextObjectPool = pP; } + SfxItemPool* GetEditTextObjectPool() const { return mpTextObjectPool; } const SvxNumberFormat * GetNumberFormat( const ContentNode* pNode ) const; sal_Int32 GetSpaceBeforeAndMinLabelWidth( const ContentNode *pNode, sal_Int32 *pnSpaceBefore = nullptr, sal_Int32 *pnMinLabelWidth = nullptr ) const; @@ -1075,27 +1249,36 @@ public: SvxCellJustifyMethod GetJustifyMethod( sal_Int32 nPara ) const; SvxCellVerJustify GetVerJustification( sal_Int32 nPara ) const; - void SetCharStretching( sal_uInt16 nX, sal_uInt16 nY ); - inline void GetCharStretching( sal_uInt16& rX, sal_uInt16& rY ) const; + void setScalingParameters(ScalingParameters const& rScalingParameters); + + void resetScalingParameters() + { + setScalingParameters(ScalingParameters()); + } + + ScalingParameters getScalingParameters() + { + return maScalingParameters; + } - sal_Int32 GetBigTextObjectStart() const { return nBigTextObjectStart; } + sal_Int32 GetBigTextObjectStart() const { return mnBigTextObjectStart; } - EditEngine* GetEditEnginePtr() const { return pEditEngine; } + EditEngine* GetEditEnginePtr() const { return mpEditEngine; } - void StartOnlineSpellTimer() { aOnlineSpellTimer.Start(); } - void StopOnlineSpellTimer() { aOnlineSpellTimer.Stop(); } + void StartOnlineSpellTimer() { maOnlineSpellTimer.Start(); } + void StopOnlineSpellTimer() { maOnlineSpellTimer.Stop(); } - const OUString& GetAutoCompleteText() const { return aAutoCompleteText; } + const OUString& GetAutoCompleteText() const { return maAutoCompleteText; } void SetAutoCompleteText(const OUString& rStr, bool bUpdateTipWindow); EditSelection TransliterateText( const EditSelection& rSelection, TransliterationFlags nTransliterationMode ); short ReplaceTextOnly( ContentNode* pNode, sal_Int32 nCurrentStart, std::u16string_view rText, const css::uno::Sequence< sal_Int32 >& rOffsets ); void SetAsianCompressionMode( CharCompressType n ); - CharCompressType GetAsianCompressionMode() const { return nAsianCompressionMode; } + CharCompressType GetAsianCompressionMode() const { return mnAsianCompressionMode; } void SetKernAsianPunctuation( bool b ); - bool IsKernAsianPunctuation() const { return bKernAsianPunctuation; } + bool IsKernAsianPunctuation() const { return mbKernAsianPunctuation; } sal_Int32 GetOverflowingParaNum() const { return mnOverflowingPara; } sal_Int32 GetOverflowingLineNum() const { return mnOverflowingLine; } @@ -1103,7 +1286,7 @@ public: void SetAddExtLeading( bool b ); - bool IsAddExtLeading() const { return bAddExtLeading; } + bool IsAddExtLeading() const { return mbAddExtLeading; } static std::shared_ptr<SvxForbiddenCharactersTable> const & GetForbiddenCharsTable(); static void SetForbiddenCharsTable( const std::shared_ptr<SvxForbiddenCharactersTable>& xForbiddenChars ); @@ -1117,8 +1300,8 @@ public: const Link<EditView*,void>& GetEndDropHdl() const { return maEndDropHdl; } /// specifies if auto-correction should capitalize the first word or not (default is on) - void SetFirstWordCapitalization( bool bCapitalize ) { bFirstWordCapitalization = bCapitalize; } - bool IsFirstWordCapitalization() const { return bFirstWordCapitalization; } + void SetFirstWordCapitalization( bool bCapitalize ) { mbFirstWordCapitalization = bCapitalize; } + bool IsFirstWordCapitalization() const { return mbFirstWordCapitalization; } /** specifies if auto-correction should replace a leading single quotation mark (apostrophe) or not (default is on) */ @@ -1128,9 +1311,11 @@ public: /** Whether last AutoCorrect inserted a NO-BREAK SPACE that may need to be removed again. */ bool IsNbspRunNext() const { return mbNbspRunNext; } + void EnableSkipOutsideFormat(bool set) { mbSkipOutsideFormat = set; } + void Dispose(); - void SetLOKSpecialPaperSize(const Size& rSize) { aLOKSpecialPaperSize = rSize; } - const Size& GetLOKSpecialPaperSize() const { return aLOKSpecialPaperSize; } + void SetLOKSpecialPaperSize(const Size& rSize) { maLOKSpecialPaperSize = rSize; } + const Size& GetLOKSpecialPaperSize() const { return maLOKSpecialPaperSize; } enum class CallbackResult { @@ -1175,176 +1360,9 @@ public: Size getTopLeftDocOffset(const tools::Rectangle& rect) const; }; -inline EPaM ImpEditEngine::CreateEPaM( const EditPaM& rPaM ) const -{ - const ContentNode* pNode = rPaM.GetNode(); - return EPaM( aEditDoc.GetPos( pNode ), rPaM.GetIndex() ); -} - -inline EditPaM ImpEditEngine::CreateEditPaM( const EPaM& rEPaM ) -{ - DBG_ASSERT( rEPaM.nPara < aEditDoc.Count(), "CreateEditPaM: invalid paragraph" ); - DBG_ASSERT( aEditDoc[ rEPaM.nPara ]->Len() >= rEPaM.nIndex, "CreateEditPaM: invalid Index" ); - return EditPaM( aEditDoc[ rEPaM.nPara], rEPaM.nIndex ); -} - -inline ESelection ImpEditEngine::CreateESel( const EditSelection& rSel ) const -{ - const ContentNode* pStartNode = rSel.Min().GetNode(); - const ContentNode* pEndNode = rSel.Max().GetNode(); - ESelection aESel; - aESel.nStartPara = aEditDoc.GetPos( pStartNode ); - aESel.nStartPos = rSel.Min().GetIndex(); - aESel.nEndPara = aEditDoc.GetPos( pEndNode ); - aESel.nEndPos = rSel.Max().GetIndex(); - return aESel; -} - -inline EditSelection ImpEditEngine::CreateSel( const ESelection& rSel ) -{ - DBG_ASSERT( rSel.nStartPara < aEditDoc.Count(), "CreateSel: invalid start paragraph" ); - DBG_ASSERT( rSel.nEndPara < aEditDoc.Count(), "CreateSel: invalid end paragraph" ); - EditSelection aSel; - aSel.Min().SetNode( aEditDoc[ rSel.nStartPara ] ); - aSel.Min().SetIndex( rSel.nStartPos ); - aSel.Max().SetNode( aEditDoc[ rSel.nEndPara ] ); - aSel.Max().SetIndex( rSel.nEndPos ); - DBG_ASSERT( !aSel.DbgIsBuggy( aEditDoc ), "CreateSel: incorrect selection!" ); - return aSel; -} - -inline VirtualDevice* ImpEditEngine::GetVirtualDevice( const MapMode& rMapMode, DrawModeFlags nDrawMode ) -{ - if ( !pVirtDev ) - pVirtDev = VclPtr<VirtualDevice>::Create(); - - if ( ( pVirtDev->GetMapMode().GetMapUnit() != rMapMode.GetMapUnit() ) || - ( pVirtDev->GetMapMode().GetScaleX() != rMapMode.GetScaleX() ) || - ( pVirtDev->GetMapMode().GetScaleY() != rMapMode.GetScaleY() ) ) - { - MapMode aMapMode( rMapMode ); - aMapMode.SetOrigin( Point( 0, 0 ) ); - pVirtDev->SetMapMode( aMapMode ); - } - - pVirtDev->SetDrawMode( nDrawMode ); - - return pVirtDev; -} - -inline EditUndoManager& ImpEditEngine::GetUndoManager() -{ - if ( !pUndoManager ) - { - pUndoManager = new EditUndoManager(); - pUndoManager->SetEditEngine(pEditEngine); - } - return *pUndoManager; -} - -inline SfxUndoManager* ImpEditEngine::SetUndoManager(SfxUndoManager* pNew) -{ - SfxUndoManager* pRetval = pUndoManager; - - if(pUndoManager) - { - pUndoManager->SetEditEngine(nullptr); - } - - pUndoManager = dynamic_cast< EditUndoManager* >(pNew); - - if(pUndoManager) - { - pUndoManager->SetEditEngine(pEditEngine); - } - - return pRetval; -} - -inline const ParaPortion& ImpEditEngine::FindParaPortion( const ContentNode* pNode ) const -{ - sal_Int32 nPos = aEditDoc.GetPos( pNode ); - DBG_ASSERT( nPos < GetParaPortions().Count(), "Portionloser Node?" ); - return GetParaPortions()[ nPos ]; -} - -inline ParaPortion& ImpEditEngine::FindParaPortion( ContentNode const * pNode ) -{ - sal_Int32 nPos = aEditDoc.GetPos( pNode ); - DBG_ASSERT( nPos < GetParaPortions().Count(), "Portionloser Node?" ); - return GetParaPortions()[ nPos ]; -} - -inline void ImpEditEngine::GetCharStretching( sal_uInt16& rX, sal_uInt16& rY ) const -{ - rX = nStretchX; - rY = nStretchY; -} - -inline short ImpEditEngine::GetXValue( short nXValue ) const -{ - if ( !aStatus.DoStretch() || ( nStretchX == 100 ) ) - return nXValue; - - return static_cast<short>(static_cast<tools::Long>(nXValue)*nStretchX/100); -} - - -inline tools::Long ImpEditEngine::GetXValue( tools::Long nXValue ) const -{ - if ( !aStatus.DoStretch() || ( nStretchX == 100 ) ) - return nXValue; - - return nXValue*nStretchX/100; -} - -inline short ImpEditEngine::GetYValue( short nYValue ) const -{ - if ( !aStatus.DoStretch() || ( nStretchY == 100 ) ) - return nYValue; - - return static_cast<short>(static_cast<tools::Long>(nYValue)*nStretchY/100); -} - -inline sal_uInt16 ImpEditEngine::GetYValue( sal_uInt16 nYValue ) const -{ - if ( !aStatus.DoStretch() || ( nStretchY == 100 ) ) - return nYValue; - - return static_cast<sal_uInt16>(static_cast<tools::Long>(nYValue)*nStretchY/100); -} - -inline PointerStyle ImpEditView::GetPointer() -{ - if ( !mxPointer ) - { - mxPointer = IsVertical() ? PointerStyle::TextVertical : PointerStyle::Text; - return *mxPointer; - } - - if(PointerStyle::Text == *mxPointer && IsVertical()) - { - mxPointer = PointerStyle::TextVertical; - } - else if(PointerStyle::TextVertical == *mxPointer && !IsVertical()) - { - mxPointer = PointerStyle::Text; - } - - return *mxPointer; -} - -inline vcl::Cursor* ImpEditView::GetCursor() -{ - if ( !pCursor ) - pCursor.reset( new vcl::Cursor ); - return pCursor.get(); -} - void ConvertItem( std::unique_ptr<SfxPoolItem>& rPoolItem, MapUnit eSourceUnit, MapUnit eDestUnit ); void ConvertAndPutItems( SfxItemSet& rDest, const SfxItemSet& rSource, const MapUnit* pSourceUnit = nullptr, const MapUnit* pDestUnit = nullptr ); AsianCompressionFlags GetCharTypeForCompression( sal_Unicode cChar ); -Point Rotate( const Point& rPoint, Degree10 nOrientation, const Point& rOrigin ); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |