From bf6449230ad2b4dfb427a062663e5ff2b9ddf3b6 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Mon, 10 Apr 2017 14:12:30 +0200 Subject: loplugin:mergeclasses merge SwAnnotationWin and SwSidebarWin Change-Id: Idaf7d7e8e4da37e0ba423dca3e22dc6711ba806a Reviewed-on: https://gerrit.libreoffice.org/36380 Tested-by: Jenkins Reviewed-by: Noel Grandin --- sw/Library_sw.mk | 2 +- sw/inc/AnnotationWin.hxx | 221 ++- sw/inc/PostItMgr.hxx | 27 +- sw/inc/SidebarWin.hxx | 256 ---- sw/inc/pch/precompiled_sw.hxx | 1 - sw/inc/postithelper.hxx | 10 +- sw/qa/extras/uiwriter/uiwriter.cxx | 2 +- sw/source/core/fields/postithelper.cxx | 2 +- sw/source/uibase/docvw/AnnotationMenuButton.cxx | 8 +- sw/source/uibase/docvw/AnnotationMenuButton.hxx | 8 +- sw/source/uibase/docvw/AnnotationWin.cxx | 126 +- sw/source/uibase/docvw/AnnotationWin2.cxx | 1504 +++++++++++++++++++ sw/source/uibase/docvw/PostItMgr.cxx | 70 +- sw/source/uibase/docvw/SidebarScrollBar.cxx | 4 +- sw/source/uibase/docvw/SidebarScrollBar.hxx | 10 +- sw/source/uibase/docvw/SidebarTxtControl.cxx | 8 +- sw/source/uibase/docvw/SidebarTxtControl.hxx | 9 +- sw/source/uibase/docvw/SidebarWin.cxx | 1638 --------------------- sw/source/uibase/docvw/SidebarWinAcc.cxx | 8 +- sw/source/uibase/docvw/SidebarWinAcc.hxx | 9 +- sw/source/uibase/docvw/edtwin.cxx | 4 +- sw/source/uibase/docvw/frmsidebarwincontainer.cxx | 12 +- sw/source/uibase/docvw/frmsidebarwincontainer.hxx | 10 +- sw/source/uibase/shells/annotsh.cxx | 2 +- sw/source/uibase/shells/textfld.cxx | 1 - sw/source/uibase/uiview/viewmdi.cxx | 2 +- sw/source/uibase/uno/unotxdoc.cxx | 5 +- sw/source/uibase/utlui/content.cxx | 2 +- 28 files changed, 1938 insertions(+), 2023 deletions(-) delete mode 100644 sw/inc/SidebarWin.hxx create mode 100644 sw/source/uibase/docvw/AnnotationWin2.cxx delete mode 100644 sw/source/uibase/docvw/SidebarWin.cxx (limited to 'sw') diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk index 847d061af188..8e6aea178073 100644 --- a/sw/Library_sw.mk +++ b/sw/Library_sw.mk @@ -598,6 +598,7 @@ $(eval $(call gb_Library_add_exception_objects,sw,\ sw/source/uibase/docvw/AnchorOverlayObject \ sw/source/uibase/docvw/AnnotationMenuButton \ sw/source/uibase/docvw/AnnotationWin \ + sw/source/uibase/docvw/AnnotationWin2 \ sw/source/uibase/docvw/DashedLine \ sw/source/uibase/docvw/FrameControlsManager \ sw/source/uibase/docvw/PageBreakWin \ @@ -607,7 +608,6 @@ $(eval $(call gb_Library_add_exception_objects,sw,\ sw/source/uibase/docvw/SidebarScrollBar \ sw/source/uibase/docvw/SidebarTxtControl \ sw/source/uibase/docvw/SidebarTxtControlAcc \ - sw/source/uibase/docvw/SidebarWin \ sw/source/uibase/docvw/SidebarWinAcc \ sw/source/uibase/docvw/HeaderFooterWin \ sw/source/uibase/docvw/edtdd \ diff --git a/sw/inc/AnnotationWin.hxx b/sw/inc/AnnotationWin.hxx index 04122ce9f70b..256441bc9dfb 100644 --- a/sw/inc/AnnotationWin.hxx +++ b/sw/inc/AnnotationWin.hxx @@ -20,15 +20,44 @@ #ifndef INCLUDED_SW_INC_ANNOTATIONWIN_HXX #define INCLUDED_SW_INC_ANNOTATIONWIN_HXX +#include +#include +#include +#include +#include +#include + #include -#include +#include +#include +#include class PopupMenu; class OutlinerParaObject; +class SwPostItMgr; +class SwPostItField; +class OutlinerView; +class Outliner; +class ScrollBar; +class SwEditWin; +class SwView; +class Edit; +class MenuButton; +class SwFrame; + +namespace sw { namespace overlay { + class OverlayRanges; +}} + +namespace sw { namespace sidebarwindows { + class SidebarTextControl; + class AnchorOverlayObject; + class ShadowOverlayObject; +}} namespace sw { namespace annotation { -class SwAnnotationWin : public sw::sidebarwindows::SwSidebarWin +class SwAnnotationWin : public vcl::Window { public: SwAnnotationWin( SwEditWin& rEditWin, @@ -39,36 +68,194 @@ class SwAnnotationWin : public sw::sidebarwindows::SwSidebarWin virtual ~SwAnnotationWin() override; virtual void dispose() override; - virtual void UpdateData() override; - virtual void SetPostItText() override; - virtual void Delete() override; - virtual void GotoPos() override; + void UpdateData(); + void SetPostItText(); + void Delete(); + void GotoPos(); const SwPostItField* GetPostItField() { return mpField; } void UpdateText(const OUString& aText); - virtual OUString GetAuthor() override; - virtual Date GetDate() override; - virtual tools::Time GetTime() override; + OUString GetAuthor(); + Date GetDate(); + tools::Time GetTime(); - virtual sal_uInt32 MoveCaret() override; + sal_uInt32 MoveCaret(); /// Calculate parent postit id of current annotation window - virtual sal_uInt32 CalcParent() override; - void InitAnswer(OutlinerParaObject* pText); + sal_uInt32 CalcParent(); + void InitAnswer(OutlinerParaObject* pText); + + bool IsProtected(); + + void SetSize( const Size& rNewSize ); + void SetPosSizePixelRect( long nX, + long nY, + long nWidth, + long nHeight, + const SwRect& aAnchorRect, + const long PageBorder); + void SetPosAndSize(); + void TranslateTopPosition(const long aAmount); + void CheckMetaText(); + + Point GetAnchorPos() { return mAnchorRect.Pos(); } + const SwRect& GetAnchorRect() { return mAnchorRect; } + bool IsAnchorRectChanged() { return mbAnchorRectChanged; } + void ResetAnchorRectChanged() { mbAnchorRectChanged = false; } + const std::vector& GetAnnotationTextRanges() { return maAnnotationTextRanges; } + SwEditWin& EditWin(); + SwSidebarItem& GetSidebarItem() { return mrSidebarItem; } + + OutlinerView* GetOutlinerView() { return mpOutlinerView;} + bool HasScrollbar() const; + bool IsScrollbarVisible() const; + ScrollBar* Scrollbar() { return mpVScrollbar; } + ::sw::sidebarwindows::AnchorOverlayObject* Anchor() { return mpAnchor;} + ::sw::sidebarwindows::ShadowOverlayObject* Shadow() { return mpShadow;} + ::sw::overlay::OverlayRanges* TextRange() { return mpTextRangeOverlay;} + + long GetPostItTextHeight(); + + void SwitchToPostIt(sal_uInt16 aDirection); + void SwitchToFieldPos(); + + void ExecuteCommand(sal_uInt16 nSlot); + void InitControls(); + void DoResize(); + void ResizeIfNecessary(long aOldHeight, long aNewHeight); + void SetScrollbar(); + + void SetVirtualPosSize( const Point& aPoint, const Size& aSize); + const Point VirtualPos() { return mPosSize.TopLeft(); } + const Size VirtualSize() { return mPosSize.GetSize(); } + + void ShowAnchorOnly(const Point &aPoint); + void ShowNote(); + void HideNote(); + void InvalidateControl(); + + void ResetAttributes(); + + void SetSidebarPosition(sw::sidebarwindows::SidebarPosition eSidebarPosition); + void SetReadonly(bool bSet); + bool IsReadOnly() + { + return mbReadonly; + } + + void SetColor(Color aColorDark,Color aColorLight, Color aColorAnchor); + const Color& ColorAnchor() { return mColorAnchor; } + const Color& ColorDark() { return mColorDark; } + const Color& ColorLight() { return mColorLight; } + void Rescale(); + + void SetViewState(::sw::sidebarwindows::ViewState bViewState); + + bool IsFollow() { return mbIsFollow; } + void SetFollow( bool bIsFollow) { mbIsFollow = bIsFollow; }; + + sal_Int32 GetMetaHeight(); + sal_Int32 GetMinimumSizeWithMeta(); + sal_Int32 GetMinimumSizeWithoutMeta(); + sal_Int32 GetMetaButtonAreaWidth(); + sal_Int32 GetScrollbarWidth(); + + void SetSpellChecking(); + + void ToggleInsMode(); + + void ActivatePostIt(); + void DeactivatePostIt(); - virtual bool IsProtected() override; + void SetChangeTracking( const SwPostItHelper::SwLayoutStatus aStatus, + const Color& aColor); + SwPostItHelper::SwLayoutStatus GetLayoutStatus() { return mLayoutStatus; } + const Color& GetChangeColor() { return mChangeColor; } - protected: - virtual VclPtr CreateMenuButton() override; + DECL_LINK( WindowEventListener, VclWindowEvent&, void ); + bool IsMouseOverSidebarWin() const { return mbMouseOver; } + + void SetLanguage(const SvxLanguageItem& rNewItem); + + void ChangeSidebarItem( SwSidebarItem& rSidebarItem ); + virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override; + + virtual void Draw(OutputDevice* pDev, const Point&, const Size&, DrawFlags) override; + virtual void KeyInput(const KeyEvent& rKeyEvt) override; + virtual void MouseButtonDown(const MouseEvent& rMouseEvent) override; + virtual void MouseButtonUp(const MouseEvent& rMouseEvent) override; + virtual void MouseMove(const MouseEvent& rMouseEvent) override; + void PaintTile(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect); + /// Is there a matching sub-widget inside this sidebar widget for rPointLogic? + bool IsHitWindow(const Point& rPointLogic); + /// Allows adjusting the point or mark of the selection to a document coordinate. + void SetCursorLogicPosition(const Point& rPosition, bool bPoint, bool bClearMark); private: - virtual SvxLanguageItem GetLanguage() override; + VclPtr CreateMenuButton(); + virtual void LoseFocus() override; + virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override; + virtual void GetFocus() override; + + void SetSizePixel( const Size& rNewSize ) override; + SfxItemSet DefaultItem(); + + DECL_LINK(ModifyHdl, LinkParamNone*, void); + DECL_LINK(ScrollHdl, ScrollBar*, void); + DECL_LINK(DeleteHdl, void*, void); + + SwView& DocView() { return mrView;} + SwPostItMgr& Mgr() { return mrMgr; } + Outliner* Engine() { return mpOutliner;} + sal_uInt32 CountFollowing(); + SwAnnotationWin* GetTopReplyNote(); + SvxLanguageItem GetLanguage(); + + SwPostItMgr& mrMgr; + SwView& mrView; + + ImplSVEvent * mnEventId; + + OutlinerView* mpOutlinerView; + Outliner* mpOutliner; + + VclPtr mpSidebarTextControl; + VclPtr mpVScrollbar; + VclPtr mpMetadataAuthor; + VclPtr mpMetadataDate; + VclPtr mpMenuButton; + + sw::sidebarwindows::AnchorOverlayObject* mpAnchor; + sw::sidebarwindows::ShadowOverlayObject* mpShadow; + sw::overlay::OverlayRanges* mpTextRangeOverlay; + + Color mColorAnchor; + Color mColorDark; + Color mColorLight; + Color mChangeColor; + + sw::sidebarwindows::SidebarPosition meSidebarPosition; + + tools::Rectangle mPosSize; + SwRect mAnchorRect; + long mPageBorder; + bool mbAnchorRectChanged; + + std::vector maAnnotationTextRanges; + + bool mbMouseOver; + SwPostItHelper::SwLayoutStatus mLayoutStatus; + + bool mbReadonly; + bool mbIsFollow; + + SwSidebarItem& mrSidebarItem; + const SwFrame* mpAnchorFrame; SwFormatField* mpFormatField; SwPostItField* mpField; VclPtr mpButtonPopup; - }; } } // end of namespace sw::annotation diff --git a/sw/inc/PostItMgr.hxx b/sw/inc/PostItMgr.hxx index 137080292eb3..6f25c4cb72bd 100644 --- a/sw/inc/PostItMgr.hxx +++ b/sw/inc/PostItMgr.hxx @@ -57,7 +57,6 @@ namespace sw { namespace annotation { class SwAnnotationWin; }} namespace sw { namespace sidebarwindows { - class SwSidebarWin; class SwFrameSidebarWinContainer; }} class SwSidebarItem; @@ -151,7 +150,7 @@ class SwPostItMgr: public SfxListener std::vector mPages; ImplSVEvent * mnEventId; bool mbWaitingForCalcRects; - VclPtr mpActivePostIt; + VclPtr mpActivePostIt; bool mbLayout; long mbLayoutHeight; bool mbLayouting; @@ -162,18 +161,18 @@ class SwPostItMgr: public SfxListener OUString maAnswerText; bool mbIsShowAnchor; - // data structure to collect the instances for certain instances. + // data structure to collect the instances for certain instances. sw::sidebarwindows::SwFrameSidebarWinContainer* mpFrameSidebarWinContainer; - typedef std::list::iterator SwSidebarWin_iterator; + typedef std::list::iterator SwAnnotationWin_iterator; void AddPostIts(bool bCheckExistance = true,bool bFocus = true); void RemoveSidebarWin(); void PreparePageContainer(); void Scroll(const long lScroll,const unsigned long aPage ); - void AutoScroll(const sw::sidebarwindows::SwSidebarWin* pPostIt,const unsigned long aPage ); + void AutoScroll(const sw::annotation::SwAnnotationWin* pPostIt,const unsigned long aPage ); bool ScrollbarHit(const unsigned long aPage,const Point &aPoint); - bool LayoutByPage( std::list &aVisiblePostItList, + bool LayoutByPage( std::list &aVisiblePostItList, const tools::Rectangle& rBorder, long lNeededHeight); void CheckForRemovedPostIts(); @@ -188,7 +187,7 @@ class SwPostItMgr: public SfxListener void SetReadOnlyState(); DECL_LINK( CalcHdl, void*, void); - sw::sidebarwindows::SwSidebarWin* GetSidebarWin(const SfxBroadcaster* pBroadcaster) const; + sw::annotation::SwAnnotationWin* GetSidebarWin(const SfxBroadcaster* pBroadcaster) const; SwSidebarItem* InsertItem( SfxBroadcaster* pItem, bool bCheckExistance, bool bFocus); void RemoveItem( SfxBroadcaster* pBroadcast ); @@ -206,7 +205,7 @@ class SwPostItMgr: public SfxListener void LayoutPostIts(); bool CalcRects(); - void MakeVisible( const sw::sidebarwindows::SwSidebarWin* pPostIt); + void MakeVisible( const sw::annotation::SwAnnotationWin* pPostIt); bool ShowScrollbar(const unsigned long aPage) const; bool HasNotes() const ; @@ -244,12 +243,12 @@ class SwPostItMgr: public SfxListener sw::annotation::SwAnnotationWin* GetAnnotationWin(const SwPostItField* pField) const; sw::annotation::SwAnnotationWin* GetAnnotationWin(const sal_uInt32 nPostItId) const; - sw::sidebarwindows::SwSidebarWin* GetNextPostIt( sal_uInt16 aDirection, - sw::sidebarwindows::SwSidebarWin* aPostIt); + sw::annotation::SwAnnotationWin* GetNextPostIt( sal_uInt16 aDirection, + sw::annotation::SwAnnotationWin* aPostIt); long GetNextBorder(); - sw::sidebarwindows::SwSidebarWin* GetActiveSidebarWin() { return mpActivePostIt; } - void SetActiveSidebarWin( sw::sidebarwindows::SwSidebarWin* p); + sw::annotation::SwAnnotationWin* GetActiveSidebarWin() { return mpActivePostIt; } + void SetActiveSidebarWin( sw::annotation::SwAnnotationWin* p); bool HasActiveSidebarWin() const; bool HasActiveAnnotationWin() const; void GrabFocusOnActiveSidebarWin(); @@ -283,9 +282,9 @@ class SwPostItMgr: public SfxListener void ConnectSidebarWinToFrame( const SwFrame& rFrame, const SwFormatField& rFormatField, - sw::sidebarwindows::SwSidebarWin& rSidebarWin ); + sw::annotation::SwAnnotationWin& rSidebarWin ); void DisconnectSidebarWinFromFrame( const SwFrame& rFrame, - sw::sidebarwindows::SwSidebarWin& rSidebarWin ); + sw::annotation::SwAnnotationWin& rSidebarWin ); bool HasFrameConnectedSidebarWins( const SwFrame& rFrame ); vcl::Window* GetSidebarWinForFrameByIndex( const SwFrame& rFrame, const sal_Int32 nIndex ); diff --git a/sw/inc/SidebarWin.hxx b/sw/inc/SidebarWin.hxx deleted file mode 100644 index d4692890b153..000000000000 --- a/sw/inc/SidebarWin.hxx +++ /dev/null @@ -1,256 +0,0 @@ -/* -*- 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 . - */ - -#ifndef INCLUDED_SW_INC_SIDEBARWIN_HXX -#define INCLUDED_SW_INC_SIDEBARWIN_HXX - -#include -#include - -#include -#include - -#include - -#include -#include -#include -#include - -class SwPostItMgr; -class SwPostItField; -class OutlinerView; -class Outliner; -class ScrollBar; -class SwEditWin; -class SwView; -class Edit; -class MenuButton; -class SwFrame; - -namespace sw { namespace overlay { - class OverlayRanges; -}} - -namespace sw { namespace sidebarwindows { - -class SidebarTextControl; -class AnchorOverlayObject; -class ShadowOverlayObject; - -class SwSidebarWin : public vcl::Window -{ - public: - SwSidebarWin( SwEditWin& rEditWin, - WinBits nBits, - SwPostItMgr& aMgr, - SwSidebarItem& rSidebarItem ); - virtual ~SwSidebarWin() override; - virtual void dispose() override; - - void SetSize( const Size& rNewSize ); - void SetPosSizePixelRect( long nX, - long nY, - long nWidth, - long nHeight, - const SwRect& aAnchorRect, - const long PageBorder); - void SetPosAndSize(); - void TranslateTopPosition(const long aAmount); - void CheckMetaText(); - - Point GetAnchorPos() { return mAnchorRect.Pos(); } - const SwRect& GetAnchorRect() { return mAnchorRect; } - bool IsAnchorRectChanged() { return mbAnchorRectChanged; } - void ResetAnchorRectChanged() { mbAnchorRectChanged = false; } - const std::vector& GetAnnotationTextRanges() { return maAnnotationTextRanges; } - SwEditWin& EditWin(); - SwSidebarItem& GetSidebarItem() { return mrSidebarItem; } - - OutlinerView* GetOutlinerView() { return mpOutlinerView;} - bool HasScrollbar() const; - bool IsScrollbarVisible() const; - ScrollBar* Scrollbar() { return mpVScrollbar; } - ::sw::sidebarwindows::AnchorOverlayObject* Anchor() { return mpAnchor;} - ::sw::sidebarwindows::ShadowOverlayObject* Shadow() { return mpShadow;} - ::sw::overlay::OverlayRanges* TextRange() { return mpTextRangeOverlay;} - - long GetPostItTextHeight(); - - void SwitchToPostIt(sal_uInt16 aDirection); - void SwitchToFieldPos(); - - virtual sal_uInt32 MoveCaret() = 0; - - virtual void UpdateData() = 0; - virtual void SetPostItText() = 0; - virtual void Delete(); - virtual void GotoPos() = 0; - - virtual OUString GetAuthor() = 0; - virtual Date GetDate() = 0; - virtual tools::Time GetTime() = 0; - - void ExecuteCommand(sal_uInt16 nSlot); - void InitControls(); - void DoResize(); - void ResizeIfNecessary(long aOldHeight, long aNewHeight); - void SetScrollbar(); - - void SetVirtualPosSize( const Point& aPoint, const Size& aSize); - const Point VirtualPos() { return mPosSize.TopLeft(); } - const Size VirtualSize() { return mPosSize.GetSize(); } - - void ShowAnchorOnly(const Point &aPoint); - void ShowNote(); - void HideNote(); - void InvalidateControl(); - - void ResetAttributes(); - - void SetSidebarPosition(sw::sidebarwindows::SidebarPosition eSidebarPosition); - void SetReadonly(bool bSet); - bool IsReadOnly() - { - return mbReadonly; - } - - void SetColor(Color aColorDark,Color aColorLight, Color aColorAnchor); - const Color& ColorAnchor() { return mColorAnchor; } - const Color& ColorDark() { return mColorDark; } - const Color& ColorLight() { return mColorLight; } - void Rescale(); - - void SetViewState(::sw::sidebarwindows::ViewState bViewState); - - bool IsFollow() { return mbIsFollow; } - void SetFollow( bool bIsFollow) { mbIsFollow = bIsFollow; }; - virtual sal_uInt32 CalcParent() = 0; - - sal_Int32 GetMetaHeight(); - sal_Int32 GetMinimumSizeWithMeta(); - sal_Int32 GetMinimumSizeWithoutMeta(); - sal_Int32 GetMetaButtonAreaWidth(); - sal_Int32 GetScrollbarWidth(); - - void SetSpellChecking(); - - void ToggleInsMode(); - - void ActivatePostIt(); - void DeactivatePostIt(); - - void SetChangeTracking( const SwPostItHelper::SwLayoutStatus aStatus, - const Color& aColor); - SwPostItHelper::SwLayoutStatus GetLayoutStatus() { return mLayoutStatus; } - const Color& GetChangeColor() { return mChangeColor; } - - virtual bool IsProtected() - { - return mbReadonly; - } - - DECL_LINK( WindowEventListener, VclWindowEvent&, void ); - bool IsMouseOverSidebarWin() const { return mbMouseOver; } - - void SetLanguage(const SvxLanguageItem& rNewItem); - - void ChangeSidebarItem( SwSidebarItem& rSidebarItem ); - virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override; - - virtual void Draw(OutputDevice* pDev, const Point&, const Size&, DrawFlags) override; - virtual void KeyInput(const KeyEvent& rKeyEvt) override; - virtual void MouseButtonDown(const MouseEvent& rMouseEvent) override; - virtual void MouseButtonUp(const MouseEvent& rMouseEvent) override; - virtual void MouseMove(const MouseEvent& rMouseEvent) override; - void PaintTile(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect); - /// Is there a matching sub-widget inside this sidebar widget for rPointLogic? - bool IsHitWindow(const Point& rPointLogic); - /// Allows adjusting the point or mark of the selection to a document coordinate. - void SetCursorLogicPosition(const Point& rPosition, bool bPoint, bool bClearMark); - - protected: - virtual void LoseFocus() override; - virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override; - virtual void GetFocus() override; - virtual VclPtr CreateMenuButton() = 0; - - void SetSizePixel( const Size& rNewSize ) override; - SfxItemSet DefaultItem(); - - DECL_LINK(ModifyHdl, LinkParamNone*, void); - DECL_LINK(ScrollHdl, ScrollBar*, void); - DECL_LINK(DeleteHdl, void*, void); - - SwView& DocView() { return mrView;} - SwPostItMgr& Mgr() { return mrMgr; } - Outliner* Engine() { return mpOutliner;} - - private: - SwSidebarWin* GetTopReplyNote(); - - virtual SvxLanguageItem GetLanguage(); - - SwPostItMgr& mrMgr; - SwView& mrView; - - ImplSVEvent * mnEventId; - - OutlinerView* mpOutlinerView; - Outliner* mpOutliner; - - VclPtr mpSidebarTextControl; - VclPtr mpVScrollbar; - VclPtr mpMetadataAuthor; - VclPtr mpMetadataDate; - VclPtr mpMenuButton; - - sw::sidebarwindows::AnchorOverlayObject* mpAnchor; - sw::sidebarwindows::ShadowOverlayObject* mpShadow; - sw::overlay::OverlayRanges* mpTextRangeOverlay; - - Color mColorAnchor; - Color mColorDark; - Color mColorLight; - Color mChangeColor; - - sw::sidebarwindows::SidebarPosition meSidebarPosition; - - tools::Rectangle mPosSize; - SwRect mAnchorRect; - long mPageBorder; - bool mbAnchorRectChanged; - - std::vector maAnnotationTextRanges; - - bool mbMouseOver; - SwPostItHelper::SwLayoutStatus mLayoutStatus; - - bool mbReadonly; - bool mbIsFollow; - - SwSidebarItem& mrSidebarItem; - const SwFrame* mpAnchorFrame; -}; - -} } // eof namespace sw::sidebarwindows - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/inc/pch/precompiled_sw.hxx b/sw/inc/pch/precompiled_sw.hxx index 86738867aff1..fdd62fe29f30 100644 --- a/sw/inc/pch/precompiled_sw.hxx +++ b/sw/inc/pch/precompiled_sw.hxx @@ -146,7 +146,6 @@ #include #include #include -#include #include #include #include diff --git a/sw/inc/postithelper.hxx b/sw/inc/postithelper.hxx index 90cfaf3a5d7e..26eb10186233 100644 --- a/sw/inc/postithelper.hxx +++ b/sw/inc/postithelper.hxx @@ -32,8 +32,8 @@ class SwTextField; class SwRootFrame; class SwPostItMgr; class SwEditWin; -namespace sw { namespace sidebarwindows { - class SwSidebarWin; +namespace sw { namespace annotation { + class SwAnnotationWin; } } struct SwPosition; @@ -88,7 +88,7 @@ namespace SwPostItHelper class SwSidebarItem { public: - VclPtr pPostIt; + VclPtr pPostIt; bool bShow; bool bFocus; bool bPendingLayout; @@ -114,7 +114,7 @@ public: virtual bool UseElement() = 0; virtual const SwFormatField& GetFormatField() const = 0; virtual const SfxBroadcaster* GetBroadCaster() const = 0; - virtual VclPtr GetSidebarWindow( SwEditWin& rEditWin, + virtual VclPtr GetSidebarWindow( SwEditWin& rEditWin, SwPostItMgr& aMgr) = 0; }; @@ -139,7 +139,7 @@ public: { return dynamic_cast (&mrFormatField); } - virtual VclPtr GetSidebarWindow( + virtual VclPtr GetSidebarWindow( SwEditWin& rEditWin, SwPostItMgr& aMgr ) override; diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index 292d9dec34d2..7bb8a1dfb757 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -43,7 +43,7 @@ #include #include #include -#include +#include #include "com/sun/star/text/XDefaultNumberingProvider.hpp" #include "com/sun/star/awt/FontUnderline.hpp" diff --git a/sw/source/core/fields/postithelper.cxx b/sw/source/core/fields/postithelper.cxx index cd607e8b5f3d..cfe556c76e56 100644 --- a/sw/source/core/fields/postithelper.cxx +++ b/sw/source/core/fields/postithelper.cxx @@ -143,7 +143,7 @@ bool SwAnnotationItem::UseElement() return mrFormatField.IsFieldInDoc(); } -VclPtr SwAnnotationItem::GetSidebarWindow( +VclPtr SwAnnotationItem::GetSidebarWindow( SwEditWin& rEditWin, SwPostItMgr& aMgr) { diff --git a/sw/source/uibase/docvw/AnnotationMenuButton.cxx b/sw/source/uibase/docvw/AnnotationMenuButton.cxx index 0eff9dc8aa93..a7f56ffe650c 100644 --- a/sw/source/uibase/docvw/AnnotationMenuButton.cxx +++ b/sw/source/uibase/docvw/AnnotationMenuButton.cxx @@ -32,7 +32,7 @@ #include #include -#include +#include namespace sw { namespace annotation { @@ -43,11 +43,11 @@ Color ColorFromAlphaColor(const sal_uInt8 aTransparency, const Color& aFront, co sal_uInt8(aFront.GetBlue() * aTransparency / 255.0 + aBack.GetBlue() * (1 - aTransparency / 255.0))); } -AnnotationMenuButton::AnnotationMenuButton(sw::sidebarwindows::SwSidebarWin& rSidebarWin) +AnnotationMenuButton::AnnotationMenuButton(sw::annotation::SwAnnotationWin& rSidebarWin) : MenuButton(&rSidebarWin) , mrSidebarWin(rSidebarWin) { - AddEventListener(LINK(&mrSidebarWin, sw::sidebarwindows::SwSidebarWin, WindowEventListener)); + AddEventListener(LINK(&mrSidebarWin, sw::annotation::SwAnnotationWin, WindowEventListener)); SetAccessibleName(SW_RES(STR_ACCESS_ANNOTATION_BUTTON_NAME)); SetAccessibleDescription(SW_RES(STR_ACCESS_ANNOTATION_BUTTON_DESC)); @@ -61,7 +61,7 @@ AnnotationMenuButton::~AnnotationMenuButton() void AnnotationMenuButton::dispose() { - RemoveEventListener(LINK(&mrSidebarWin, sw::sidebarwindows::SwSidebarWin, WindowEventListener)); + RemoveEventListener(LINK(&mrSidebarWin, sw::annotation::SwAnnotationWin, WindowEventListener)); MenuButton::dispose(); } diff --git a/sw/source/uibase/docvw/AnnotationMenuButton.hxx b/sw/source/uibase/docvw/AnnotationMenuButton.hxx index 6a7694d4caae..74bbcc5a02ab 100644 --- a/sw/source/uibase/docvw/AnnotationMenuButton.hxx +++ b/sw/source/uibase/docvw/AnnotationMenuButton.hxx @@ -22,8 +22,8 @@ #include -namespace sw { namespace sidebarwindows { - class SwSidebarWin; +namespace sw { namespace annotation { + class SwAnnotationWin; } } namespace sw { namespace annotation { @@ -31,7 +31,7 @@ namespace sw { namespace annotation { class AnnotationMenuButton : public MenuButton { public: - AnnotationMenuButton( sw::sidebarwindows::SwSidebarWin& rSidebarWin ); + AnnotationMenuButton( sw::annotation::SwAnnotationWin& rSidebarWin ); virtual ~AnnotationMenuButton() override; virtual void dispose() override; @@ -44,7 +44,7 @@ class AnnotationMenuButton : public MenuButton virtual void KeyInput( const KeyEvent& rKeyEvt ) override; private: - sw::sidebarwindows::SwSidebarWin& mrSidebarWin; + sw::annotation::SwAnnotationWin& mrSidebarWin; }; } } // end of namespace sw::annotation diff --git a/sw/source/uibase/docvw/AnnotationWin.cxx b/sw/source/uibase/docvw/AnnotationWin.cxx index 7809c3bc18b3..9f70393f637e 100644 --- a/sw/source/uibase/docvw/AnnotationWin.cxx +++ b/sw/source/uibase/docvw/AnnotationWin.cxx @@ -51,6 +51,11 @@ #include #include #include +#include +#include +#include +#include +#include #include @@ -61,11 +66,49 @@ SwAnnotationWin::SwAnnotationWin( SwEditWin& rEditWin, SwPostItMgr& aMgr, SwSidebarItem& rSidebarItem, SwFormatField* aField ) - : SwSidebarWin( rEditWin, nBits, aMgr, rSidebarItem ) + : Window(&rEditWin, nBits) + , mrMgr(aMgr) + , mrView(rEditWin.GetView()) + , mnEventId(nullptr) + , mpOutlinerView(nullptr) + , mpOutliner(nullptr) + , mpSidebarTextControl(nullptr) + , mpVScrollbar(nullptr) + , mpMetadataAuthor(nullptr) + , mpMetadataDate(nullptr) + , mpMenuButton(nullptr) + , mpAnchor(nullptr) + , mpShadow(nullptr) + , mpTextRangeOverlay(nullptr) + , mColorAnchor() + , mColorDark() + , mColorLight() + , mChangeColor() + , meSidebarPosition(sw::sidebarwindows::SidebarPosition::NONE) + , mPosSize() + , mAnchorRect() + , mPageBorder(0) + , mbAnchorRectChanged(false) + , mbMouseOver(false) + , mLayoutStatus(SwPostItHelper::INVISIBLE) + , mbReadonly(false) + , mbIsFollow(false) + , mrSidebarItem(rSidebarItem) + , mpAnchorFrame(rSidebarItem.maLayoutInfo.mpAnchorFrame) , mpFormatField(aField) , mpField( static_cast(aField->GetField())) , mpButtonPopup(nullptr) { + mpShadow = sidebarwindows::ShadowOverlayObject::CreateShadowOverlayObject( mrView ); + if ( mpShadow ) + { + mpShadow->setVisible(false); + } + + mrMgr.ConnectSidebarWinToFrame( *(mrSidebarItem.maLayoutInfo.mpAnchorFrame), + mrSidebarItem.GetFormatField(), + *this ); + if (SupportsDoubleBuffering()) // When double-buffering, allow parents to paint on our area. That's // necessary when parents paint the complete buffer. @@ -80,7 +123,71 @@ SwAnnotationWin::~SwAnnotationWin() void SwAnnotationWin::dispose() { mpButtonPopup.disposeAndClear(); - sw::sidebarwindows::SwSidebarWin::dispose(); + + if (IsDisposed()) + return; + + mrMgr.DisconnectSidebarWinFromFrame( *(mrSidebarItem.maLayoutInfo.mpAnchorFrame), + *this ); + + Disable(); + + if ( mpSidebarTextControl ) + { + if ( mpOutlinerView ) + { + mpOutlinerView->SetWindow( nullptr ); + } + } + mpSidebarTextControl.disposeAndClear(); + + if ( mpOutlinerView ) + { + delete mpOutlinerView; + mpOutlinerView = nullptr; + } + + if (mpOutliner) + { + delete mpOutliner; + mpOutliner = nullptr; + } + + if (mpMetadataAuthor) + { + mpMetadataAuthor->RemoveEventListener( LINK( this, SwAnnotationWin, WindowEventListener ) ); + } + mpMetadataAuthor.disposeAndClear(); + + if (mpMetadataDate) + { + mpMetadataDate->RemoveEventListener( LINK( this, SwAnnotationWin, WindowEventListener ) ); + } + mpMetadataDate.disposeAndClear(); + + if (mpVScrollbar) + { + mpVScrollbar->RemoveEventListener( LINK( this, SwAnnotationWin, WindowEventListener ) ); + } + mpVScrollbar.disposeAndClear(); + + RemoveEventListener( LINK( this, SwAnnotationWin, WindowEventListener ) ); + + sidebarwindows::AnchorOverlayObject::DestroyAnchorOverlayObject( mpAnchor ); + mpAnchor = nullptr; + + sidebarwindows::ShadowOverlayObject::DestroyShadowOverlayObject( mpShadow ); + mpShadow = nullptr; + + delete mpTextRangeOverlay; + mpTextRangeOverlay = nullptr; + + mpMenuButton.disposeAndClear(); + + if (mnEventId) + Application::RemoveUserEvent( mnEventId ); + + vcl::Window::dispose(); } void SwAnnotationWin::SetPostItText() @@ -155,7 +262,16 @@ void SwAnnotationWin::Delete() { if (DocView().GetWrtShellPtr()->GotoField(*mpFormatField)) { - SwSidebarWin::Delete(); + if ( mrMgr.GetActiveSidebarWin() == this) + { + mrMgr.SetActiveSidebarWin(nullptr); + // if the note is empty, the previous line will send a delete event, but we are already there + if (mnEventId) + { + Application::RemoveUserEvent( mnEventId ); + mnEventId = nullptr; + } + } // we delete the field directly, the Mgr cleans up the PostIt by listening GrabFocusToDocument(); DocView().GetWrtShellPtr()->ClearMark(); @@ -245,7 +361,7 @@ void SwAnnotationWin::InitAnswer(OutlinerParaObject* pText) return; //collect our old meta data - SwSidebarWin* pWin = Mgr().GetNextPostIt(KEY_PAGEUP, this); + SwAnnotationWin* pWin = Mgr().GetNextPostIt(KEY_PAGEUP, this); const SvtSysLocale aSysLocale; const LocaleDataWrapper& rLocalData = aSysLocale.GetLocaleData(); SwRewriter aRewriter; @@ -323,7 +439,7 @@ SvxLanguageItem SwAnnotationWin::GetLanguage() bool SwAnnotationWin::IsProtected() { - return SwSidebarWin::IsProtected() || + return mbReadonly || GetLayoutStatus() == SwPostItHelper::DELETED || ( mpFormatField && mpFormatField->IsProtect() ); } diff --git a/sw/source/uibase/docvw/AnnotationWin2.cxx b/sw/source/uibase/docvw/AnnotationWin2.cxx new file mode 100644 index 000000000000..30d5648f652b --- /dev/null +++ b/sw/source/uibase/docvw/AnnotationWin2.cxx @@ -0,0 +1,1504 @@ +/* -*- 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 . + */ + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace sw::sidebarwindows; + +namespace +{ + +/// Translate absolute <-> relative twips: LOK wants absolute coordinates as output and gives absolute coordinates as input. +void lcl_translateTwips(vcl::Window& rParent, vcl::Window& rChild, MouseEvent* pMouseEvent) +{ + // Set map mode, so that callback payloads will contain absolute coordinates instead of relative ones. + Point aOffset(rChild.GetOutOffXPixel() - rParent.GetOutOffXPixel(), rChild.GetOutOffYPixel() - rParent.GetOutOffYPixel()); + if (!rChild.IsMapModeEnabled()) + { + MapMode aMapMode(rChild.GetMapMode()); + aMapMode.SetMapUnit(MapUnit::MapTwip); + aMapMode.SetScaleX(rParent.GetMapMode().GetScaleX()); + aMapMode.SetScaleY(rParent.GetMapMode().GetScaleY()); + rChild.SetMapMode(aMapMode); + rChild.EnableMapMode(); + } + aOffset = rChild.PixelToLogic(aOffset); + MapMode aMapMode(rChild.GetMapMode()); + aMapMode.SetOrigin(aOffset); + aMapMode.SetMapUnit(rParent.GetMapMode().GetMapUnit()); + rChild.SetMapMode(aMapMode); + rChild.EnableMapMode(false); + + if (pMouseEvent) + { + // Set event coordinates, so they contain relative coordinates instead of absolute ones. + Point aPos = pMouseEvent->GetPosPixel(); + aPos.Move(-aOffset.getX(), -aOffset.getY()); + MouseEvent aMouseEvent(aPos, pMouseEvent->GetClicks(), pMouseEvent->GetMode(), pMouseEvent->GetButtons(), pMouseEvent->GetModifier()); + *pMouseEvent = aMouseEvent; + } +} + +/// Decide which one from the children of rParent should get rMouseEvent. +vcl::Window* lcl_getHitWindow(sw::annotation::SwAnnotationWin& rParent, const MouseEvent& rMouseEvent) +{ + vcl::Window* pRet = nullptr; + + rParent.EditWin().Push(PushFlags::MAPMODE); + rParent.EditWin().EnableMapMode(); + for (sal_Int16 i = rParent.GetChildCount() - 1; i >= 0; --i) + { + vcl::Window* pChild = rParent.GetChild(i); + + Point aPosition(rParent.GetPosPixel()); + aPosition.Move(pChild->GetPosPixel().getX(), pChild->GetPosPixel().getY()); + Size aSize(rParent.GetSizePixel()); + tools::Rectangle aRectangleLogic(rParent.EditWin().PixelToLogic(aPosition), rParent.EditWin().PixelToLogic(aSize)); + if (aRectangleLogic.IsInside(rMouseEvent.GetPosPixel())) + { + pRet = pChild; + break; + } + } + rParent.EditWin().Pop(); + return pRet; +} + +} + +namespace sw { namespace annotation { + +#define METABUTTON_WIDTH 16 +#define METABUTTON_HEIGHT 18 +#define METABUTTON_AREA_WIDTH 30 +#define POSTIT_META_HEIGHT (sal_Int32) 30 +#define POSTIT_MINIMUMSIZE_WITHOUT_META 50 + + +void SwAnnotationWin::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) +{ + Window::Paint(rRenderContext, rRect); + + if (mpMetadataAuthor->IsVisible()) + { + //draw left over space + if (Application::GetSettings().GetStyleSettings().GetHighContrastMode()) + { + rRenderContext.SetFillColor(COL_BLACK); + } + else + { + rRenderContext.SetFillColor(mColorDark); + } + + rRenderContext.SetLineColor(); + tools::Rectangle aRectangle(Point(mpMetadataAuthor->GetPosPixel().X() + mpMetadataAuthor->GetSizePixel().Width(), + mpMetadataAuthor->GetPosPixel().Y()), + Size(GetMetaButtonAreaWidth(), + mpMetadataAuthor->GetSizePixel().Height() + mpMetadataDate->GetSizePixel().Height())); + + if (comphelper::LibreOfficeKit::isActive()) + aRectangle = rRect; + else + aRectangle = PixelToLogic(aRectangle); + rRenderContext.DrawRect(aRectangle); + } +} + +void SwAnnotationWin::PaintTile(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) +{ + Paint(rRenderContext, rRect); + + for (sal_uInt16 i = 0; i < GetChildCount(); ++i) + { + vcl::Window* pChild = GetChild(i); + + // No point in showing this button till click on it are not handled. + if (pChild == mpMenuButton.get()) + continue; + + if (!pChild->IsVisible()) + continue; + + rRenderContext.Push(PushFlags::MAPMODE); + Point aOffset(PixelToLogic(pChild->GetPosPixel())); + MapMode aMapMode(rRenderContext.GetMapMode()); + aMapMode.SetOrigin(aMapMode.GetOrigin() + aOffset); + rRenderContext.SetMapMode(aMapMode); + + bool bPopChild = false; + if (pChild->GetMapMode().GetMapUnit() != rRenderContext.GetMapMode().GetMapUnit()) + { + // This is needed for the scrollbar that has its map unit in pixels. + pChild->Push(PushFlags::MAPMODE); + bPopChild = true; + pChild->EnableMapMode(); + aMapMode = pChild->GetMapMode(); + aMapMode.SetMapUnit(rRenderContext.GetMapMode().GetMapUnit()); + aMapMode.SetScaleX(rRenderContext.GetMapMode().GetScaleX()); + aMapMode.SetScaleY(rRenderContext.GetMapMode().GetScaleY()); + pChild->SetMapMode(aMapMode); + } + + pChild->Paint(rRenderContext, rRect); + + if (bPopChild) + pChild->Pop(); + rRenderContext.Pop(); + } + + const drawinglayer::geometry::ViewInformation2D aViewInformation; + std::unique_ptr pProcessor(drawinglayer::processor2d::createBaseProcessor2DFromOutputDevice(rRenderContext, aViewInformation)); + + // drawinglayer sets the map mode to pixels, not needed here. + rRenderContext.Pop(); + // Work in document-global twips. + rRenderContext.Pop(); + if (mpAnchor) + pProcessor->process(mpAnchor->getOverlayObjectPrimitive2DSequence()); + if (mpTextRangeOverlay) + pProcessor->process(mpTextRangeOverlay->getOverlayObjectPrimitive2DSequence()); + + rRenderContext.Push(PushFlags::NONE); + pProcessor.reset(); + rRenderContext.Push(PushFlags::NONE); +} + +bool SwAnnotationWin::IsHitWindow(const Point& rPointLogic) +{ + tools::Rectangle aRectangleLogic(EditWin().PixelToLogic(GetPosPixel()), EditWin().PixelToLogic(GetSizePixel())); + return aRectangleLogic.IsInside(rPointLogic); +} + +void SwAnnotationWin::SetCursorLogicPosition(const Point& rPosition, bool bPoint, bool bClearMark) +{ + mpSidebarTextControl->Push(PushFlags::MAPMODE); + MouseEvent aMouseEvent(rPosition); + lcl_translateTwips(EditWin(), *mpSidebarTextControl, &aMouseEvent); + Point aPosition(aMouseEvent.GetPosPixel()); + + EditView& rEditView = GetOutlinerView()->GetEditView(); + rEditView.SetCursorLogicPosition(aPosition, bPoint, bClearMark); + + mpSidebarTextControl->Pop(); +} + +void SwAnnotationWin::Draw(OutputDevice* pDev, const Point& rPt, const Size& rSz, DrawFlags nInFlags) +{ + if (mpMetadataAuthor->IsVisible() ) + { + pDev->SetFillColor(mColorDark); + pDev->SetLineColor(); + pDev->DrawRect( tools::Rectangle( rPt, rSz ) ); + } + + if (mpMetadataAuthor->IsVisible()) + { + vcl::Font aOrigFont(mpMetadataAuthor->GetControlFont()); + Size aSize(PixelToLogic(mpMetadataAuthor->GetSizePixel())); + Point aPos(PixelToLogic(mpMetadataAuthor->GetPosPixel())); + aPos += rPt; + vcl::Font aFont( mpMetadataAuthor->GetSettings().GetStyleSettings().GetFieldFont() ); + mpMetadataAuthor->SetControlFont( aFont ); + mpMetadataAuthor->Draw(pDev, aPos, aSize, nInFlags); + mpMetadataAuthor->SetControlFont( aOrigFont ); + } + + if (mpMetadataDate->IsVisible()) + { + vcl::Font aOrigFont(mpMetadataDate->GetControlFont()); + Size aSize(PixelToLogic(mpMetadataDate->GetSizePixel())); + Point aPos(PixelToLogic(mpMetadataDate->GetPosPixel())); + aPos += rPt; + vcl::Font aFont( mpMetadataDate->GetSettings().GetStyleSettings().GetFieldFont() ); + mpMetadataDate->SetControlFont( aFont ); + mpMetadataDate->Draw(pDev, aPos, aSize, nInFlags); + mpMetadataDate->SetControlFont( aOrigFont ); + } + + mpSidebarTextControl->Draw(pDev, rPt, rSz, nInFlags); + + const drawinglayer::geometry::ViewInformation2D aNewViewInfos; + std::unique_ptr pProcessor( + drawinglayer::processor2d::createBaseProcessor2DFromOutputDevice( + *pDev, aNewViewInfos )); + + if (mpAnchor) + pProcessor->process(mpAnchor->getOverlayObjectPrimitive2DSequence()); + if (mpTextRangeOverlay) + pProcessor->process(mpTextRangeOverlay->getOverlayObjectPrimitive2DSequence()); + pProcessor.reset(); + + if (mpVScrollbar->IsVisible()) + { + vcl::Font aOrigFont(mpMetadataDate->GetControlFont()); + Color aOrigBg( mpMetadataDate->GetControlBackground() ); + OUString sOrigText(mpMetadataDate->GetText()); + + Size aSize(PixelToLogic(mpMenuButton->GetSizePixel())); + Point aPos(PixelToLogic(mpMenuButton->GetPosPixel())); + aPos += rPt; + + vcl::Font aFont( mpMetadataDate->GetSettings().GetStyleSettings().GetFieldFont() ); + mpMetadataDate->SetControlFont( aFont ); + mpMetadataDate->SetControlBackground( 0xFFFFFF ); + mpMetadataDate->SetText("..."); + mpMetadataDate->Draw(pDev, aPos, aSize, nInFlags); + + mpMetadataDate->SetText(sOrigText); + mpMetadataDate->SetControlFont( aOrigFont ); + mpMetadataDate->SetControlBackground( aOrigBg ); + } +} + +void SwAnnotationWin::KeyInput(const KeyEvent& rKeyEvent) +{ + if (mpSidebarTextControl) + { + mpSidebarTextControl->Push(PushFlags::MAPMODE); + lcl_translateTwips(EditWin(), *mpSidebarTextControl, nullptr); + + mpSidebarTextControl->KeyInput(rKeyEvent); + + mpSidebarTextControl->Pop(); + } +} + +void SwAnnotationWin::MouseMove(const MouseEvent& rMouseEvent) +{ + if (vcl::Window* pHit = lcl_getHitWindow(*this, rMouseEvent)) + { + pHit->Push(PushFlags::MAPMODE); + MouseEvent aMouseEvent(rMouseEvent); + lcl_translateTwips(EditWin(), *pHit, &aMouseEvent); + + pHit->MouseMove(aMouseEvent); + + pHit->Pop(); + } +} + +void SwAnnotationWin::MouseButtonDown(const MouseEvent& rMouseEvent) +{ + if (vcl::Window* pHit = lcl_getHitWindow(*this, rMouseEvent)) + { + pHit->Push(PushFlags::MAPMODE); + MouseEvent aMouseEvent(rMouseEvent); + lcl_translateTwips(EditWin(), *pHit, &aMouseEvent); + + pHit->MouseButtonDown(aMouseEvent); + + pHit->Pop(); + } +} + +void SwAnnotationWin::MouseButtonUp(const MouseEvent& rMouseEvent) +{ + if (vcl::Window* pHit = lcl_getHitWindow(*this, rMouseEvent)) + { + pHit->Push(PushFlags::MAPMODE); + MouseEvent aMouseEvent(rMouseEvent); + lcl_translateTwips(EditWin(), *pHit, &aMouseEvent); + + pHit->MouseButtonUp(aMouseEvent); + + pHit->Pop(); + } +} + +void SwAnnotationWin::SetPosSizePixelRect(long nX, long nY, long nWidth, long nHeight, + const SwRect& aAnchorRect, const long aPageBorder) +{ + mPosSize = tools::Rectangle(Point(nX,nY),Size(nWidth,nHeight)); + if (!mAnchorRect.IsEmpty() && mAnchorRect != aAnchorRect) + mbAnchorRectChanged = true; + mAnchorRect = aAnchorRect; + mPageBorder = aPageBorder; +} + +void SwAnnotationWin::SetSize( const Size& rNewSize ) +{ + mPosSize.SetSize(rNewSize); +} + +void SwAnnotationWin::SetVirtualPosSize( const Point& aPoint, const Size& aSize) +{ + mPosSize = tools::Rectangle(aPoint,aSize); +} + +void SwAnnotationWin::TranslateTopPosition(const long aAmount) +{ + mPosSize.Move(0,aAmount); +} + +void SwAnnotationWin::ShowAnchorOnly(const Point &aPoint) +{ + HideNote(); + SetPosAndSize(); + if (mpAnchor) + { + mpAnchor->SetSixthPosition(basegfx::B2DPoint(aPoint.X(),aPoint.Y())); + mpAnchor->SetSeventhPosition(basegfx::B2DPoint(aPoint.X(),aPoint.Y())); + mpAnchor->SetAnchorState(AnchorState::All); + mpAnchor->setVisible(true); + } + if (mpShadow) + mpShadow->setVisible(false); +} + +SfxItemSet SwAnnotationWin::DefaultItem() +{ + SfxItemSet aItem( mrView.GetDocShell()->GetPool() ); + aItem.Put(SvxFontHeightItem(200,100,EE_CHAR_FONTHEIGHT)); + return aItem; +} + +void SwAnnotationWin::InitControls() +{ + AddEventListener( LINK( this, SwAnnotationWin, WindowEventListener ) ); + + // actual window which holds the user text + mpSidebarTextControl = VclPtr::Create( *this, + WB_NODIALOGCONTROL, + mrView, mrMgr ); + mpSidebarTextControl->SetPointer(Pointer(PointerStyle::Text)); + + // window controls for author and date + mpMetadataAuthor = VclPtr::Create( this, 0 ); + mpMetadataAuthor->SetAccessibleName( SW_RES( STR_ACCESS_ANNOTATION_AUTHOR_NAME ) ); + mpMetadataAuthor->EnableRTL(AllSettings::GetLayoutRTL()); + mpMetadataAuthor->SetReadOnly(); + mpMetadataAuthor->AlwaysDisableInput(true); + mpMetadataAuthor->SetCallHandlersOnInputDisabled(true); + mpMetadataAuthor->AddEventListener( LINK( this, SwAnnotationWin, WindowEventListener ) ); + // we should leave this setting alone, but for this we need a better layout algo + // with variable meta size height + { + AllSettings aSettings = mpMetadataAuthor->GetSettings(); + StyleSettings aStyleSettings = aSettings.GetStyleSettings(); + vcl::Font aFont = aStyleSettings.GetFieldFont(); + aFont.SetFontHeight(8); + aStyleSettings.SetFieldFont(aFont); + aSettings.SetStyleSettings(aStyleSettings); + mpMetadataAuthor->SetSettings(aSettings); + } + + mpMetadataDate = VclPtr::Create( this, 0 ); + mpMetadataDate->SetAccessibleName( SW_RES( STR_ACCESS_ANNOTATION_DATE_NAME ) ); + mpMetadataDate->EnableRTL(AllSettings::GetLayoutRTL()); + mpMetadataDate->SetReadOnly(); + mpMetadataDate->AlwaysDisableInput(true); + mpMetadataDate->SetCallHandlersOnInputDisabled(true); + mpMetadataDate->AddEventListener( LINK( this, SwAnnotationWin, WindowEventListener ) ); + // we should leave this setting alone, but for this we need a better layout algo + // with variable meta size height + { + AllSettings aSettings = mpMetadataDate->GetSettings(); + StyleSettings aStyleSettings = aSettings.GetStyleSettings(); + vcl::Font aFont = aStyleSettings.GetFieldFont(); + aFont.SetFontHeight(8); + aStyleSettings.SetFieldFont(aFont); + aSettings.SetStyleSettings(aStyleSettings); + mpMetadataDate->SetSettings(aSettings); + } + + SwDocShell* aShell = mrView.GetDocShell(); + mpOutliner = new Outliner(&aShell->GetPool(),OutlinerMode::TextObject); + aShell->GetDoc()->SetCalcFieldValueHdl( mpOutliner ); + mpOutliner->SetUpdateMode( true ); + Rescale(); + + mpSidebarTextControl->EnableRTL( false ); + mpOutlinerView = new OutlinerView ( mpOutliner, mpSidebarTextControl ); + mpOutlinerView->SetBackgroundColor(COL_TRANSPARENT); + mpOutliner->InsertView(mpOutlinerView ); + mpOutlinerView->SetOutputArea( PixelToLogic( tools::Rectangle(0,0,1,1) ) ); + + mpOutlinerView->SetAttribs(DefaultItem()); + + if (comphelper::LibreOfficeKit::isActive()) + { + // If there is a callback already registered, inform the new outliner view about it. + mpOutlinerView->RegisterViewShell(&mrView); + } + + //create Scrollbars + mpVScrollbar = VclPtr::Create(*this, WB_3DLOOK |WB_VSCROLL|WB_DRAG, mrView); + mpVScrollbar->EnableNativeWidget(false); + mpVScrollbar->EnableRTL( false ); + mpVScrollbar->SetScrollHdl(LINK(this, SwAnnotationWin, ScrollHdl)); + mpVScrollbar->EnableDrag(); + mpVScrollbar->AddEventListener( LINK( this, SwAnnotationWin, WindowEventListener ) ); + + const SwViewOption* pVOpt = mrView.GetWrtShellPtr()->GetViewOptions(); + EEControlBits nCntrl = mpOutliner->GetControlWord(); + // TODO: crash when AUTOCOMPLETE enabled + nCntrl |= EEControlBits::MARKFIELDS | EEControlBits::PASTESPECIAL | EEControlBits::AUTOCORRECT | EEControlBits::USECHARATTRIBS; // | EEControlBits::AUTOCOMPLETE; + if (SwViewOption::IsFieldShadings()) + nCntrl |= EEControlBits::MARKFIELDS; + else + nCntrl &= ~EEControlBits::MARKFIELDS; + if (pVOpt->IsOnlineSpell()) + nCntrl |= EEControlBits::ONLINESPELLING; + else + nCntrl &= ~EEControlBits::ONLINESPELLING; + mpOutliner->SetControlWord(nCntrl); + + std::size_t aIndex = SW_MOD()->InsertRedlineAuthor(GetAuthor()); + SetColor( SwPostItMgr::GetColorDark(aIndex), + SwPostItMgr::GetColorLight(aIndex), + SwPostItMgr::GetColorAnchor(aIndex)); + + CheckMetaText(); + + mpMenuButton = CreateMenuButton(); + + SetLanguage(GetLanguage()); + GetOutlinerView()->StartSpeller(); + SetPostItText(); + Engine()->CompleteOnlineSpelling(); + + mpSidebarTextControl->Show(); + mpMetadataAuthor->Show(); + mpMetadataDate->Show(); + mpVScrollbar->Show(); +} + +void SwAnnotationWin::CheckMetaText() +{ + const SvtSysLocale aSysLocale; + const LocaleDataWrapper& rLocalData = aSysLocale.GetLocaleData(); + OUString sMeta = GetAuthor(); + if (sMeta.isEmpty()) + { + sMeta = SW_RESSTR(STR_NOAUTHOR); + } + else if (sMeta.getLength() > 23) + { + sMeta = sMeta.copy(0, 20) + "..."; + } + if ( mpMetadataAuthor->GetText() != sMeta ) + { + mpMetadataAuthor->SetText(sMeta); + } + + Date aDate = GetDate(); + if (aDate.IsValidAndGregorian() ) + { + sMeta = rLocalData.getDate(aDate); + } + else + { + sMeta = SW_RESSTR(STR_NODATE); + } + if (GetTime()!=0) + { + sMeta += " " + rLocalData.getTime( GetTime(),false ); + } + if ( mpMetadataDate->GetText() != sMeta ) + { + mpMetadataDate->SetText(sMeta); + } +} + +void SwAnnotationWin::Rescale() +{ + MapMode aMode = GetParent()->GetMapMode(); + aMode.SetOrigin( Point() ); + mpOutliner->SetRefMapMode( aMode ); + SetMapMode( aMode ); + mpSidebarTextControl->SetMapMode( aMode ); + const Fraction& rFraction = mrView.GetWrtShellPtr()->GetOut()->GetMapMode().GetScaleY(); + if ( mpMetadataAuthor ) + { + vcl::Font aFont( mpMetadataAuthor->GetSettings().GetStyleSettings().GetFieldFont() ); + sal_Int32 nHeight = aFont.GetFontHeight(); + nHeight = nHeight * rFraction.GetNumerator() / rFraction.GetDenominator(); + aFont.SetFontHeight( nHeight ); + mpMetadataAuthor->SetControlFont( aFont ); + } + if ( mpMetadataDate ) + { + vcl::Font aFont( mpMetadataDate->GetSettings().GetStyleSettings().GetFieldFont() ); + sal_Int32 nHeight = aFont.GetFontHeight(); + nHeight = nHeight * rFraction.GetNumerator() / rFraction.GetDenominator(); + aFont.SetFontHeight( nHeight ); + mpMetadataDate->SetControlFont( aFont ); + } +} + +void SwAnnotationWin::SetPosAndSize() +{ + bool bChange = false; + + if (GetSizePixel() != mPosSize.GetSize()) + { + bChange = true; + SetSizePixel(mPosSize.GetSize()); + + if (comphelper::LibreOfficeKit::isActive()) + { + // Position is not yet set at VCL level, but the map mode should + // contain the right origin to emit the correct cursor position. + mpSidebarTextControl->Push(PushFlags::MAPMODE); + Point aOffset(mPosSize.Left(), mPosSize.Top()); + aOffset = PixelToLogic(aOffset); + MapMode aMapMode(mpSidebarTextControl->GetMapMode()); + aMapMode.SetOrigin(aOffset); + mpSidebarTextControl->SetMapMode(aMapMode); + mpSidebarTextControl->EnableMapMode(false); + } + + DoResize(); + + if (comphelper::LibreOfficeKit::isActive()) + mpSidebarTextControl->Pop(); + } + + if (GetPosPixel().X() != mPosSize.TopLeft().X() || (std::abs(GetPosPixel().Y() - mPosSize.TopLeft().Y()) > 5) ) + { + bChange = true; + SetPosPixel(mPosSize.TopLeft()); + + Point aLineStart; + Point aLineEnd ; + switch ( meSidebarPosition ) + { + case sw::sidebarwindows::SidebarPosition::LEFT: + { + aLineStart = EditWin().PixelToLogic( Point(GetPosPixel().X()+GetSizePixel().Width(),GetPosPixel().Y()-1) ); + aLineEnd = EditWin().PixelToLogic( Point(GetPosPixel().X(),GetPosPixel().Y()-1) ); + } + break; + case sw::sidebarwindows::SidebarPosition::RIGHT: + { + aLineStart = EditWin().PixelToLogic( Point(GetPosPixel().X(),GetPosPixel().Y()-1) ); + aLineEnd = EditWin().PixelToLogic( Point(GetPosPixel().X()+GetSizePixel().Width(),GetPosPixel().Y()-1) ); + } + break; + default: + OSL_FAIL( " - unexpected position of sidebar" ); + break; + } + + // LOK has map mode disabled, and we still want to perform pixel -> + // twips conversion for the size of the line above the note. + if (comphelper::LibreOfficeKit::isActive() && !EditWin().IsMapModeEnabled()) + { + EditWin().EnableMapMode(); + Size aSize(aLineEnd.getX() - aLineStart.getX(), aLineEnd.getY() - aLineStart.getY()); + aSize = EditWin().PixelToLogic(aSize); + aLineEnd = aLineStart; + aLineEnd.Move(aSize.getWidth(), aSize.getHeight()); + EditWin().EnableMapMode(false); + } + + if (mpAnchor) + { + mpAnchor->SetAllPosition( basegfx::B2DPoint( mAnchorRect.Left() , mAnchorRect.Bottom() - 5* 15), + basegfx::B2DPoint( mAnchorRect.Left()-5*15 , mAnchorRect.Bottom()+5*15), + basegfx::B2DPoint( mAnchorRect.Left()+5*15 , mAnchorRect.Bottom()+5*15), + basegfx::B2DPoint( mAnchorRect.Left(), mAnchorRect.Bottom()+2*15), + basegfx::B2DPoint( mPageBorder ,mAnchorRect.Bottom()+2*15), + basegfx::B2DPoint( aLineStart.X(),aLineStart.Y()), + basegfx::B2DPoint( aLineEnd.X(),aLineEnd.Y())); + mpAnchor->SetHeight(mAnchorRect.Height()); + } + else + { + mpAnchor = AnchorOverlayObject::CreateAnchorOverlayObject( mrView, + mAnchorRect, + mPageBorder, + aLineStart, + aLineEnd, + mColorAnchor ); + if ( mpAnchor ) + { + mpAnchor->SetHeight(mAnchorRect.Height()); + mpAnchor->setVisible(true); + mpAnchor->SetAnchorState(AnchorState::Tri); + if (HasChildPathFocus()) + { + mpAnchor->setLineSolid(true); + } + } + } + } + else + { + if ( mpAnchor && + ( mpAnchor->getBasePosition() != basegfx::B2DPoint( mAnchorRect.Left() , mAnchorRect.Bottom()-5*15) ) ) + { + mpAnchor->SetTriPosition( basegfx::B2DPoint( mAnchorRect.Left() , mAnchorRect.Bottom() - 5* 15), + basegfx::B2DPoint( mAnchorRect.Left()-5*15 , mAnchorRect.Bottom()+5*15), + basegfx::B2DPoint( mAnchorRect.Left()+5*15 , mAnchorRect.Bottom()+5*15), + basegfx::B2DPoint( mAnchorRect.Left(), mAnchorRect.Bottom()+2*15), + basegfx::B2DPoint( mPageBorder , mAnchorRect.Bottom()+2*15)); + } + } + + if (bChange) + { + Point aStart = EditWin().PixelToLogic(GetPosPixel()+Point(0,GetSizePixel().Height())); + Point aEnd = EditWin().PixelToLogic(GetPosPixel()+Point(GetSizePixel().Width()-1,GetSizePixel().Height())); + mpShadow->SetPosition(basegfx::B2DPoint(aStart.X(),aStart.Y()), basegfx::B2DPoint(aEnd.X(),aEnd.Y())); + } + + if (mrMgr.ShowNotes()) + { + if (IsFollow() && !HasChildPathFocus()) + { + // #i111964# + if ( mpAnchor ) + { + mpAnchor->SetAnchorState(AnchorState::End); + } + } + else + { + // #i111964# + if ( mpAnchor ) + { + mpAnchor->SetAnchorState(AnchorState::All); + } + SwAnnotationWin* pWin = GetTopReplyNote(); + // #i111964# + if ( pWin && pWin->Anchor() ) + { + pWin->Anchor()->SetAnchorState(AnchorState::End); + } + } + } + + + // text range overlay + maAnnotationTextRanges.clear(); + if ( mrSidebarItem.maLayoutInfo.mnStartNodeIdx != 0 + && mrSidebarItem.maLayoutInfo.mnStartContent != -1 ) + { + const SwTextAnnotationField* pTextAnnotationField = + dynamic_cast< const SwTextAnnotationField* >( mrSidebarItem.GetFormatField().GetTextField() ); + SwTextNode* pTextNode = pTextAnnotationField ? pTextAnnotationField->GetpTextNode() : nullptr; + SwContentNode* pContentNd = nullptr; + if (pTextNode) + { + SwNodes& rNds = pTextNode->GetDoc()->GetNodes(); + pContentNd = rNds[mrSidebarItem.maLayoutInfo.mnStartNodeIdx]->GetContentNode(); + } + if (pContentNd) + { + SwPosition aStartPos( *pContentNd, mrSidebarItem.maLayoutInfo.mnStartContent ); + SwShellCursor* pTmpCursor = nullptr; + const bool bTableCursorNeeded = pTextNode->FindTableBoxStartNode() != pContentNd->FindTableBoxStartNode(); + if ( bTableCursorNeeded ) + { + SwShellTableCursor* pTableCursor = new SwShellTableCursor( DocView().GetWrtShell(), aStartPos ); + pTableCursor->SetMark(); + pTableCursor->GetMark()->nNode = *pTextNode; + pTableCursor->GetMark()->nContent.Assign( pTextNode, pTextAnnotationField->GetStart()+1 ); + pTableCursor->NewTableSelection(); + pTmpCursor = pTableCursor; + } + else + { + SwShellCursor* pCursor = new SwShellCursor( DocView().GetWrtShell(), aStartPos ); + pCursor->SetMark(); + pCursor->GetMark()->nNode = *pTextNode; + pCursor->GetMark()->nContent.Assign( pTextNode, pTextAnnotationField->GetStart()+1 ); + pTmpCursor = pCursor; + } + std::unique_ptr pTmpCursorForAnnotationTextRange( pTmpCursor ); + + // For annotation text range rectangles to be calculated correctly, + // we need the map mode disabled + bool bDisableMapMode = comphelper::LibreOfficeKit::isActive() && EditWin().IsMapModeEnabled(); + if (bDisableMapMode) + EditWin().EnableMapMode(false); + + pTmpCursorForAnnotationTextRange->FillRects(); + + if (bDisableMapMode) + EditWin().EnableMapMode(); + + SwRects* pRects(pTmpCursorForAnnotationTextRange.get()); + for(SwRect & rNextRect : *pRects) + { + const tools::Rectangle aPntRect(rNextRect.SVRect()); + maAnnotationTextRanges.push_back(basegfx::B2DRange( + aPntRect.Left(), aPntRect.Top(), + aPntRect.Right() + 1, aPntRect.Bottom() + 1)); + } + } + } + + if (mrMgr.ShowNotes() && !maAnnotationTextRanges.empty()) + { + if ( mpTextRangeOverlay != nullptr ) + { + mpTextRangeOverlay->setRanges( maAnnotationTextRanges ); + if ( mpAnchor != nullptr && mpAnchor->getLineSolid() ) + { + mpTextRangeOverlay->ShowSolidBorder(); + } + else + { + mpTextRangeOverlay->HideSolidBorder(); + } + } + else if (!IsFollow()) + { + // This window is not a reply, then draw its range overlay. + mpTextRangeOverlay = + sw::overlay::OverlayRanges::CreateOverlayRange( + DocView(), + mColorAnchor, + maAnnotationTextRanges, + mpAnchor && mpAnchor->getLineSolid() ); + } + } + else + { + delete mpTextRangeOverlay; + mpTextRangeOverlay = nullptr; + } +} + +void SwAnnotationWin::DoResize() +{ + long aTextHeight = LogicToPixel( mpOutliner->CalcTextSize()).Height(); + long aHeight = GetSizePixel().Height(); + unsigned long aWidth = GetSizePixel().Width(); + + aHeight -= GetMetaHeight(); + mpMetadataAuthor->Show(); + mpMetadataDate->Show(); + mpSidebarTextControl->SetQuickHelpText(OUString()); + + if (aTextHeight > aHeight) + { // we need vertical scrollbars and have to reduce the width + aWidth -= GetScrollbarWidth(); + mpVScrollbar->Show(); + } + else + { + mpVScrollbar->Hide(); + } + + { + const Size aSizeOfMetadataControls( GetSizePixel().Width() - GetMetaButtonAreaWidth(), + GetMetaHeight()/2 ); + mpMetadataAuthor->setPosSizePixel( 0, + aHeight, + aSizeOfMetadataControls.Width(), + aSizeOfMetadataControls.Height() ); + mpMetadataDate->setPosSizePixel( 0, + aHeight + aSizeOfMetadataControls.Height(), + aSizeOfMetadataControls.Width(), + aSizeOfMetadataControls.Height() ); + } + + mpOutliner->SetPaperSize( PixelToLogic( Size(aWidth,aHeight) ) ) ; + if (!mpVScrollbar->IsVisible()) + { // if we do not have a scrollbar anymore, we want to see the complete text + mpOutlinerView->SetVisArea( PixelToLogic( tools::Rectangle(0,0,aWidth,aHeight) ) ); + } + mpOutlinerView->SetOutputArea( PixelToLogic( tools::Rectangle(0,0,aWidth,aHeight) ) ); + + if (!AllSettings::GetLayoutRTL()) + { + mpSidebarTextControl->setPosSizePixel(0, 0, aWidth, aHeight); + mpVScrollbar->setPosSizePixel( aWidth, 0, GetScrollbarWidth(), aHeight); + } + else + { + mpSidebarTextControl->setPosSizePixel( ( aTextHeight > aHeight ? GetScrollbarWidth() : 0 ), 0, + aWidth, aHeight); + mpVScrollbar->setPosSizePixel( 0, 0, GetScrollbarWidth(), aHeight); + } + + mpVScrollbar->SetVisibleSize( PixelToLogic(Size(0,aHeight)).Height() ); + mpVScrollbar->SetPageSize( PixelToLogic(Size(0,aHeight)).Height() * 8 / 10 ); + mpVScrollbar->SetLineSize( mpOutliner->GetTextHeight() / 10 ); + SetScrollbar(); + mpVScrollbar->SetRange( Range(0, mpOutliner->GetTextHeight())); + + //calculate rects for meta- button + const Fraction& fx( GetMapMode().GetScaleX() ); + const Fraction& fy( GetMapMode().GetScaleY() ); + + const Point aPos( mpMetadataAuthor->GetPosPixel()); + mpMenuButton->setPosSizePixel( aPos.X()+GetSizePixel().Width()-(METABUTTON_WIDTH+10)*fx.GetNumerator()/fx.GetDenominator(), + aPos.Y()+5*fy.GetNumerator()/fy.GetDenominator(), + METABUTTON_WIDTH*fx.GetNumerator()/fx.GetDenominator(), + METABUTTON_HEIGHT*fy.GetNumerator()/fy.GetDenominator() ); +} + +void SwAnnotationWin::SetSizePixel( const Size& rNewSize ) +{ + Window::SetSizePixel(rNewSize); + + if (mpShadow) + { + Point aStart = EditWin().PixelToLogic(GetPosPixel()+Point(0,GetSizePixel().Height())); + Point aEnd = EditWin().PixelToLogic(GetPosPixel()+Point(GetSizePixel().Width()-1,GetSizePixel().Height())); + mpShadow->SetPosition(basegfx::B2DPoint(aStart.X(),aStart.Y()), basegfx::B2DPoint(aEnd.X(),aEnd.Y())); + } +} + +void SwAnnotationWin::SetScrollbar() +{ + mpVScrollbar->SetThumbPos(mpOutlinerView->GetVisArea().Top()); +} + +void SwAnnotationWin::ResizeIfNecessary(long aOldHeight, long aNewHeight) +{ + if (aOldHeight != aNewHeight) + { + //check for lower border or next note + long aBorder = mrMgr.GetNextBorder(); + if (aBorder != -1) + { + if (aNewHeight > GetMinimumSizeWithoutMeta()) + { + long aNewLowerValue = GetPosPixel().Y() + aNewHeight + GetMetaHeight(); + if (aNewLowerValue < aBorder) + SetSizePixel(Size(GetSizePixel().Width(),aNewHeight+GetMetaHeight())); + else + SetSizePixel(Size(GetSizePixel().Width(),aBorder - GetPosPixel().Y())); + DoResize(); + Invalidate(); + } + else + { + if (GetSizePixel().Height() != GetMinimumSizeWithoutMeta() + GetMetaHeight()) + SetSizePixel(Size(GetSizePixel().Width(),GetMinimumSizeWithoutMeta() + GetMetaHeight())); + DoResize(); + Invalidate(); + } + } + else + { + DoResize(); + Invalidate(); + } + } + else + { + SetScrollbar(); + } +} + +void SwAnnotationWin::SetColor(Color aColorDark,Color aColorLight, Color aColorAnchor) +{ + mColorDark = aColorDark; + mColorLight = aColorLight; + mColorAnchor = aColorAnchor; + + if ( !Application::GetSettings().GetStyleSettings().GetHighContrastMode() ) + { + { + mpMetadataAuthor->SetControlBackground(mColorDark); + AllSettings aSettings = mpMetadataAuthor->GetSettings(); + StyleSettings aStyleSettings = aSettings.GetStyleSettings(); + aStyleSettings.SetFieldTextColor(aColorAnchor); + aSettings.SetStyleSettings(aStyleSettings); + mpMetadataAuthor->SetSettings(aSettings); + } + + { + mpMetadataDate->SetControlBackground(mColorDark); + AllSettings aSettings = mpMetadataDate->GetSettings(); + StyleSettings aStyleSettings = aSettings.GetStyleSettings(); + aStyleSettings.SetFieldTextColor(aColorAnchor); + aSettings.SetStyleSettings(aStyleSettings); + mpMetadataDate->SetSettings(aSettings); + } + + AllSettings aSettings2 = mpVScrollbar->GetSettings(); + StyleSettings aStyleSettings2 = aSettings2.GetStyleSettings(); + aStyleSettings2.SetButtonTextColor(Color(0,0,0)); + aStyleSettings2.SetCheckedColor(mColorLight); // background + aStyleSettings2.SetShadowColor(mColorAnchor); + aStyleSettings2.SetFaceColor(mColorDark); + aSettings2.SetStyleSettings(aStyleSettings2); + mpVScrollbar->SetSettings(aSettings2); + } +} + +void SwAnnotationWin::SetSidebarPosition(sw::sidebarwindows::SidebarPosition eSidebarPosition) +{ + meSidebarPosition = eSidebarPosition; +} + +void SwAnnotationWin::SetReadonly(bool bSet) +{ + mbReadonly = bSet; + GetOutlinerView()->SetReadOnly(bSet); +} + +void SwAnnotationWin::SetLanguage(const SvxLanguageItem& rNewItem) +{ + Link aLink = Engine()->GetModifyHdl(); + Engine()->SetModifyHdl( Link() ); + ESelection aOld = GetOutlinerView()->GetSelection(); + + ESelection aNewSelection( 0, 0, Engine()->GetParagraphCount()-1, EE_TEXTPOS_ALL ); + GetOutlinerView()->SetSelection( aNewSelection ); + SfxItemSet aEditAttr(GetOutlinerView()->GetAttribs()); + aEditAttr.Put(rNewItem); + GetOutlinerView()->SetAttribs( aEditAttr ); + + GetOutlinerView()->SetSelection(aOld); + Engine()->SetModifyHdl( aLink ); + + const SwViewOption* pVOpt = mrView.GetWrtShellPtr()->GetViewOptions(); + EEControlBits nCntrl = Engine()->GetControlWord(); + // turn off + nCntrl &= ~EEControlBits::ONLINESPELLING; + Engine()->SetControlWord(nCntrl); + + //turn back on + if (pVOpt->IsOnlineSpell()) + nCntrl |= EEControlBits::ONLINESPELLING; + else + nCntrl &= ~EEControlBits::ONLINESPELLING; + Engine()->SetControlWord(nCntrl); + + Engine()->CompleteOnlineSpelling(); + Invalidate(); +} + +void SwAnnotationWin::GetFocus() +{ + if (mpSidebarTextControl) + mpSidebarTextControl->GrabFocus(); +} + +void SwAnnotationWin::LoseFocus() +{ +} + +void SwAnnotationWin::ShowNote() +{ + SetPosAndSize(); + if (!IsVisible()) + Window::Show(); + if (mpShadow && !mpShadow->isVisible()) + mpShadow->setVisible(true); + if (mpAnchor && !mpAnchor->isVisible()) + mpAnchor->setVisible(true); + + // Invalidate. + InvalidateControl(); +} + +void SwAnnotationWin::HideNote() +{ + if (IsVisible()) + Window::Hide(); + if (mpAnchor) + { + if (mrMgr.IsShowAnchor()) + mpAnchor->SetAnchorState(AnchorState::Tri); + else + mpAnchor->setVisible(false); + } + if (mpShadow && mpShadow->isVisible()) + mpShadow->setVisible(false); +} + +void SwAnnotationWin::InvalidateControl() +{ + // Invalidate. + mpSidebarTextControl->Push(PushFlags::MAPMODE); + lcl_translateTwips(EditWin(), *mpSidebarTextControl, nullptr); + mpSidebarTextControl->Invalidate(); + mpSidebarTextControl->Pop(); +} + +void SwAnnotationWin::ActivatePostIt() +{ + mrMgr.AssureStdModeAtShell(); + + mpOutliner->ClearModifyFlag(); + mpOutliner->GetUndoManager().Clear(); + + CheckMetaText(); + SetViewState(ViewState::EDIT); + GetOutlinerView()->ShowCursor(); + + mpOutlinerView->GetEditView().SetInsertMode(mrView.GetWrtShellPtr()->IsInsMode()); + + if ( !Application::GetSettings().GetStyleSettings().GetHighContrastMode() ) + GetOutlinerView()->SetBackgroundColor(mColorDark); +} + +void SwAnnotationWin::DeactivatePostIt() +{ + // remove selection, #i87073# + if (GetOutlinerView()->GetEditView().HasSelection()) + { + ESelection aSelection = GetOutlinerView()->GetEditView().GetSelection(); + aSelection.nEndPara = aSelection.nStartPara; + aSelection.nEndPos = aSelection.nStartPos; + GetOutlinerView()->GetEditView().SetSelection(aSelection); + } + + mpOutliner->CompleteOnlineSpelling(); + + SetViewState(ViewState::NORMAL); + // Make sure this view doesn't emit LOK callbacks during the update, as the + // sidebar window's SidebarTextControl doesn't have a valid twip offset + // (map mode origin) during that operation. + bool bTiledPainting = comphelper::LibreOfficeKit::isTiledPainting(); + comphelper::LibreOfficeKit::setTiledPainting(true); + // write the visible text back into the SwField + UpdateData(); + comphelper::LibreOfficeKit::setTiledPainting(bTiledPainting); + + if ( !Application::GetSettings().GetStyleSettings().GetHighContrastMode() ) + GetOutlinerView()->SetBackgroundColor(COL_TRANSPARENT); + + if ( !IsProtected() && Engine()->GetEditEngine().GetText().isEmpty() ) + { + mnEventId = Application::PostUserEvent( LINK( this, SwAnnotationWin, DeleteHdl), nullptr, true ); + } +} + +void SwAnnotationWin::ToggleInsMode() +{ + if (!mrView.GetWrtShell().IsRedlineOn()) + { + //change outliner + mpOutlinerView->GetEditView().SetInsertMode(!mpOutlinerView->GetEditView().IsInsertMode()); + //change document + mrView.GetWrtShell().ToggleInsMode(); + //update statusbar + SfxBindings &rBnd = mrView.GetViewFrame()->GetBindings(); + rBnd.Invalidate(SID_ATTR_INSERT); + rBnd.Update(SID_ATTR_INSERT); + } +} + +void SwAnnotationWin::ExecuteCommand(sal_uInt16 nSlot) +{ + mrMgr.AssureStdModeAtShell(); + + switch (nSlot) + { + case FN_POSTIT: + case FN_REPLY: + { + // if this note is empty, it will be deleted once losing the focus, so no reply, but only a new note + // will be created + if (!Engine()->GetEditEngine().GetText().isEmpty()) + { + OutlinerParaObject* pPara = new OutlinerParaObject(*GetOutlinerView()->GetEditView().CreateTextObject()); + mrMgr.RegisterAnswer(pPara); + } + if (mrMgr.HasActiveSidebarWin()) + mrMgr.SetActiveSidebarWin(nullptr); + SwitchToFieldPos(); + mrView.GetViewFrame()->GetDispatcher()->Execute(FN_POSTIT); + break; + } + case FN_DELETE_COMMENT: + + //Delete(); // do not kill the parent of our open popup menu + mnEventId = Application::PostUserEvent( LINK( this, SwAnnotationWin, DeleteHdl), nullptr, true ); + break; + case FN_FORMAT_ALL_NOTES: + case FN_DELETE_ALL_NOTES: + case FN_HIDE_ALL_NOTES: + // not possible as slot as this would require that "this" is the active postit + mrView.GetViewFrame()->GetBindings().Execute( nSlot, nullptr, SfxCallMode::ASYNCHRON ); + break; + case FN_DELETE_NOTE_AUTHOR: + case FN_HIDE_NOTE_AUTHOR: + { + // not possible as slot as this would require that "this" is the active postit + SfxStringItem aItem( nSlot, GetAuthor() ); + const SfxPoolItem* aItems[2]; + aItems[0] = &aItem; + aItems[1] = nullptr; + mrView.GetViewFrame()->GetBindings().Execute( nSlot, aItems, SfxCallMode::ASYNCHRON ); + } + break; + default: + mrView.GetViewFrame()->GetBindings().Execute( nSlot ); + break; + } +} + +SwEditWin& SwAnnotationWin::EditWin() +{ + return mrView.GetEditWin(); +} + +long SwAnnotationWin::GetPostItTextHeight() +{ + return mpOutliner ? LogicToPixel(mpOutliner->CalcTextSize()).Height() : 0; +} + +void SwAnnotationWin::SwitchToPostIt(sal_uInt16 aDirection) +{ + SwAnnotationWin* pPostIt = mrMgr.GetNextPostIt(aDirection, this); + if (pPostIt) + pPostIt->GrabFocus(); +} + +IMPL_LINK( SwAnnotationWin, WindowEventListener, VclWindowEvent&, rEvent, void ) +{ + if ( rEvent.GetId() == VclEventId::WindowMouseMove ) + { + MouseEvent* pMouseEvt = static_cast(rEvent.GetData()); + if ( pMouseEvt->IsEnterWindow() ) + { + mbMouseOver = true; + if ( !HasFocus() ) + { + SetViewState(ViewState::VIEW); + Invalidate(); + } + } + else if ( pMouseEvt->IsLeaveWindow()) + { + mbMouseOver = false; + if ( !HasFocus() ) + { + SetViewState(ViewState::NORMAL); + Invalidate(); + } + } + } + else if ( rEvent.GetId() == VclEventId::WindowActivate && + rEvent.GetWindow() == mpSidebarTextControl ) + { + const bool bLockView = mrView.GetWrtShell().IsViewLocked(); + mrView.GetWrtShell().LockView( true ); + mrMgr.SetActiveSidebarWin( this ); + mrView.GetWrtShell().LockView( bLockView ); + mrMgr.MakeVisible( this ); + } +} + +IMPL_LINK(SwAnnotationWin, ScrollHdl, ScrollBar*, pScroll, void) +{ + long nDiff = GetOutlinerView()->GetEditView().GetVisArea().Top() - pScroll->GetThumbPos(); + GetOutlinerView()->Scroll( 0, nDiff ); +} + +IMPL_LINK_NOARG(SwAnnotationWin, ModifyHdl, LinkParamNone*, void) +{ + mrView.GetDocShell()->SetModified(); +} + +IMPL_LINK_NOARG(SwAnnotationWin, DeleteHdl, void*, void) +{ + mnEventId = nullptr; + Delete(); +} + +void SwAnnotationWin::ResetAttributes() +{ + mpOutlinerView->RemoveAttribsKeepLanguages(true); + mpOutliner->RemoveFields(); + mpOutlinerView->SetAttribs(DefaultItem()); +} + +sal_Int32 SwAnnotationWin::GetScrollbarWidth() +{ + return mrView.GetWrtShell().GetViewOptions()->GetZoom() / 10; +} + +sal_Int32 SwAnnotationWin::GetMetaButtonAreaWidth() +{ + const Fraction& f( GetMapMode().GetScaleX() ); + return METABUTTON_AREA_WIDTH * f.GetNumerator() / f.GetDenominator(); +} + +sal_Int32 SwAnnotationWin::GetMetaHeight() +{ + const Fraction& f(mrView.GetWrtShellPtr()->GetOut()->GetMapMode().GetScaleY()); + return POSTIT_META_HEIGHT * f.GetNumerator() / f.GetDenominator(); +} + +sal_Int32 SwAnnotationWin::GetMinimumSizeWithMeta() +{ + return mrMgr.GetMinimumSizeWithMeta(); +} + +sal_Int32 SwAnnotationWin::GetMinimumSizeWithoutMeta() +{ + const Fraction& f(mrView.GetWrtShellPtr()->GetOut()->GetMapMode().GetScaleY()); + return POSTIT_MINIMUMSIZE_WITHOUT_META * f.GetNumerator() / f.GetDenominator(); +} + +void SwAnnotationWin::SetSpellChecking() +{ + const SwViewOption* pVOpt = mrView.GetWrtShellPtr()->GetViewOptions(); + EEControlBits nCntrl = mpOutliner->GetControlWord(); + if (pVOpt->IsOnlineSpell()) + nCntrl |= EEControlBits::ONLINESPELLING; + else + nCntrl &= ~EEControlBits::ONLINESPELLING; + mpOutliner->SetControlWord(nCntrl); + + mpOutliner->CompleteOnlineSpelling(); + Invalidate(); +} + +void SwAnnotationWin::SetViewState(ViewState bViewState) +{ + switch (bViewState) + { + case ViewState::EDIT: + { + if (mpAnchor) + { + mpAnchor->SetAnchorState(AnchorState::All); + SwAnnotationWin* pWin = GetTopReplyNote(); + // #i111964# + if ( pWin && pWin->Anchor() ) + { + pWin->Anchor()->SetAnchorState(AnchorState::End); + } + mpAnchor->setLineSolid(true); + if ( mpTextRangeOverlay != nullptr ) + { + mpTextRangeOverlay->ShowSolidBorder(); + } + } + if (mpShadow) + mpShadow->SetShadowState(SS_EDIT); + break; + } + case ViewState::VIEW: + { + if (mpAnchor) + { + mpAnchor->setLineSolid(true); + if ( mpTextRangeOverlay != nullptr ) + { + mpTextRangeOverlay->ShowSolidBorder(); + } + } + if (mpShadow) + mpShadow->SetShadowState(SS_VIEW); + break; + } + case ViewState::NORMAL: + { + if (mpAnchor) + { + if (IsFollow()) + { + // if there is no visible parent note, we want to see the complete anchor ?? + //if (IsAnyStackParentVisible()) + mpAnchor->SetAnchorState(AnchorState::End); + SwAnnotationWin* pTopWinSelf = GetTopReplyNote(); + SwAnnotationWin* pTopWinActive = mrMgr.HasActiveSidebarWin() + ? mrMgr.GetActiveSidebarWin()->GetTopReplyNote() + : nullptr; + // #i111964# + if ( pTopWinSelf && ( pTopWinSelf != pTopWinActive ) && + pTopWinSelf->Anchor() ) + { + if ( pTopWinSelf != mrMgr.GetActiveSidebarWin() ) + { + pTopWinSelf->Anchor()->setLineSolid(false); + if ( pTopWinSelf->TextRange() != nullptr ) + { + pTopWinSelf->TextRange()->HideSolidBorder(); + } + } + pTopWinSelf->Anchor()->SetAnchorState(AnchorState::All); + } + } + mpAnchor->setLineSolid(false); + if ( mpTextRangeOverlay != nullptr ) + { + mpTextRangeOverlay->HideSolidBorder(); + } + } + if ( mpShadow ) + { + mpShadow->SetShadowState(SS_NORMAL); + } + break; + } + } +} + +SwAnnotationWin* SwAnnotationWin::GetTopReplyNote() +{ + SwAnnotationWin* pTopNote = nullptr; + SwAnnotationWin* pSidebarWin = IsFollow() ? mrMgr.GetNextPostIt(KEY_PAGEUP, this) : nullptr; + while (pSidebarWin) + { + pTopNote = pSidebarWin; + pSidebarWin = pSidebarWin->IsFollow() ? mrMgr.GetNextPostIt(KEY_PAGEUP, pSidebarWin) : nullptr; + } + return pTopNote; +} + +void SwAnnotationWin::SwitchToFieldPos() +{ + if ( mrMgr.GetActiveSidebarWin() == this ) + mrMgr.SetActiveSidebarWin(nullptr); + GotoPos(); + sal_uInt32 aCount = MoveCaret(); + if (aCount) + mrView.GetDocShell()->GetWrtShell()->SwCursorShell::Right(aCount, 0); + GrabFocusToDocument(); +} + +void SwAnnotationWin::SetChangeTracking( const SwPostItHelper::SwLayoutStatus aLayoutStatus, + const Color& aChangeColor ) +{ + if ( (mLayoutStatus != aLayoutStatus) || + (mChangeColor != aChangeColor) ) + { + mLayoutStatus = aLayoutStatus; + mChangeColor = aChangeColor; + Invalidate(); + } +} + +bool SwAnnotationWin::HasScrollbar() const +{ + return mpVScrollbar != nullptr; +} + +bool SwAnnotationWin::IsScrollbarVisible() const +{ + return HasScrollbar() && mpVScrollbar->IsVisible(); +} + +void SwAnnotationWin::ChangeSidebarItem( SwSidebarItem& rSidebarItem ) +{ + const bool bAnchorChanged = mpAnchorFrame != rSidebarItem.maLayoutInfo.mpAnchorFrame; + if ( bAnchorChanged ) + { + mrMgr.DisconnectSidebarWinFromFrame( *(mpAnchorFrame), *this ); + } + + mrSidebarItem = rSidebarItem; + mpAnchorFrame = mrSidebarItem.maLayoutInfo.mpAnchorFrame; + + if ( GetWindowPeer() ) + { + SidebarWinAccessible* pAcc = + static_cast( GetWindowPeer() ); + OSL_ENSURE( dynamic_cast( GetWindowPeer() ), + " - unexpected type of window peer -> crash possible!" ); + pAcc->ChangeSidebarItem( mrSidebarItem ); + } + + if ( bAnchorChanged ) + { + mrMgr.ConnectSidebarWinToFrame( *(mrSidebarItem.maLayoutInfo.mpAnchorFrame), + mrSidebarItem.GetFormatField(), + *this ); + } +} + +css::uno::Reference< css::accessibility::XAccessible > SwAnnotationWin::CreateAccessible() +{ + SidebarWinAccessible* pAcc( new SidebarWinAccessible( *this, + mrView.GetWrtShell(), + mrSidebarItem ) ); + css::uno::Reference< css::awt::XWindowPeer > xWinPeer( pAcc ); + SetWindowPeer( xWinPeer, pAcc ); + + css::uno::Reference< css::accessibility::XAccessible > xAcc( xWinPeer, css::uno::UNO_QUERY ); + return xAcc; +} + +} } // eof of namespace sw::sidebarwindows + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/docvw/PostItMgr.cxx b/sw/source/uibase/docvw/PostItMgr.cxx index c5e3b99d5f1c..2e67fc07aa2e 100644 --- a/sw/source/uibase/docvw/PostItMgr.cxx +++ b/sw/source/uibase/docvw/PostItMgr.cxx @@ -23,7 +23,6 @@ #include #include -#include #include #include @@ -99,6 +98,7 @@ #define MAX_LOOP_COUNT 50 using namespace sw::sidebarwindows; +using namespace sw::annotation; namespace { @@ -149,7 +149,7 @@ namespace { aAnnotation.put("id", nPostItId); if (nType != CommentNotificationType::Remove && pItem != nullptr) { - sw::annotation::SwAnnotationWin* pWin = static_cast((pItem)->pPostIt.get()); + sw::annotation::SwAnnotationWin* pWin = pItem->pPostIt.get(); const SwPostItField* pField = pWin->GetPostItField(); const SwRect& aRect = pWin->GetAnchorRect(); @@ -696,7 +696,7 @@ void SwPostItMgr::LayoutPostIts() // only layout if there are notes on this page if (pPage->mList->size()>0) { - std::list aVisiblePostItList; + std::list aVisiblePostItList; unsigned long lNeededHeight = 0; long mlPageBorder = 0; long mlPageEnd = 0; @@ -704,7 +704,7 @@ void SwPostItMgr::LayoutPostIts() for(SwSidebarItem_iterator i = pPage->mList->begin(); i != pPage->mList->end(); ++i) { SwSidebarItem* pItem = (*i); - VclPtr pPostIt = pItem->pPostIt; + VclPtr pPostIt = pItem->pPostIt; if (pPage->eSidebarPosition == sw::sidebarwindows::SidebarPosition::LEFT ) { @@ -741,7 +741,7 @@ void SwPostItMgr::LayoutPostIts() if (mpAnswer) { if (static_cast(pPostIt->CalcParent())) //do we really have another note in front of this one - static_cast(pPostIt.get())->InitAnswer(mpAnswer); + pPostIt.get()->InitAnswer(mpAnswer); delete mpAnswer; mpAnswer = nullptr; } @@ -807,7 +807,7 @@ void SwPostItMgr::LayoutPostIts() - enlarge all notes till GetNextBorder(), as we resized to average value before */ //lets hide the ones which overlap the page - for(SwSidebarWin_iterator i = aVisiblePostItList.begin(); i != aVisiblePostItList.end() ; ++i) + for(SwAnnotationWin_iterator i = aVisiblePostItList.begin(); i != aVisiblePostItList.end() ; ++i) { if (pPage->lOffset != 0) (*i)->TranslateTopPosition(pPage->lOffset); @@ -857,7 +857,7 @@ void SwPostItMgr::LayoutPostIts() } else { - for(SwSidebarWin_iterator i = aVisiblePostItList.begin(); i != aVisiblePostItList.end() ; ++i) + for(SwAnnotationWin_iterator i = aVisiblePostItList.begin(); i != aVisiblePostItList.end() ; ++i) { (*i)->SetPosAndSize(); } @@ -867,7 +867,7 @@ void SwPostItMgr::LayoutPostIts() bUpdate = (bOldScrollbar != pPage->bScrollbar) || bUpdate; } - for(SwSidebarWin_iterator i = aVisiblePostItList.begin(); i != aVisiblePostItList.end() ; ++i) + for(SwAnnotationWin_iterator i = aVisiblePostItList.begin(); i != aVisiblePostItList.end() ; ++i) { if (comphelper::LibreOfficeKit::isActive() && !comphelper::LibreOfficeKit::isTiledAnnotations()) { @@ -962,7 +962,7 @@ void SwPostItMgr::DrawNotesForPage(OutputDevice *pOutDev, sal_uInt32 nPage) return; for(SwSidebarItem_iterator i = mPages[nPage]->mList->begin(); i != mPages[nPage]->mList->end(); ++i) { - SwSidebarWin* pPostIt = (*i)->pPostIt; + SwAnnotationWin* pPostIt = (*i)->pPostIt; if (!pPostIt) continue; Point aPoint(mpEditWin->PixelToLogic(pPostIt->GetPosPixel())); @@ -975,7 +975,7 @@ void SwPostItMgr::PaintTile(OutputDevice& rRenderContext, const tools::Rectangle { for (SwSidebarItem* pItem : mvPostItFields) { - SwSidebarWin* pPostIt = pItem->pPostIt; + SwAnnotationWin* pPostIt = pItem->pPostIt; if (!pPostIt) continue; @@ -1009,7 +1009,7 @@ void SwPostItMgr::Scroll(const long lScroll,const unsigned long aPage) const long aSidebarheight = mpEditWin->PixelToLogic(Size(0,GetSidebarScrollerHeight())).Height(); for(SwSidebarItem_iterator i = mPages[aPage-1]->mList->begin(); i != mPages[aPage-1]->mList->end(); ++i) { - SwSidebarWin* pPostIt = (*i)->pPostIt; + SwAnnotationWin* pPostIt = (*i)->pPostIt; // if this is an answer, we should take the normal position and not the real, slightly moved position pPostIt->SetVirtualPosSize(pPostIt->GetPosPixel(),pPostIt->GetSizePixel()); pPostIt->TranslateTopPosition(lScroll); @@ -1049,7 +1049,7 @@ void SwPostItMgr::Scroll(const long lScroll,const unsigned long aPage) } } -void SwPostItMgr::AutoScroll(const SwSidebarWin* pPostIt,const unsigned long aPage ) +void SwPostItMgr::AutoScroll(const SwAnnotationWin* pPostIt,const unsigned long aPage ) { // otherwise all notes are visible if (mPages[aPage-1]->bScrollbar) @@ -1069,7 +1069,7 @@ void SwPostItMgr::AutoScroll(const SwSidebarWin* pPostIt,const unsigned long aPa } } -void SwPostItMgr::MakeVisible(const SwSidebarWin* pPostIt ) +void SwPostItMgr::MakeVisible(const SwAnnotationWin* pPostIt ) { long aPage = -1; // we don't know the page yet, lets find it ourselves @@ -1125,7 +1125,7 @@ Color SwPostItMgr::GetArrowColor(sal_uInt16 aDirection,unsigned long aPage) cons } } -bool SwPostItMgr::LayoutByPage(std::list &aVisiblePostItList, const tools::Rectangle& rBorder, long lNeededHeight) +bool SwPostItMgr::LayoutByPage(std::list &aVisiblePostItList, const tools::Rectangle& rBorder, long lNeededHeight) { /*** General layout idea:***/ // - if we have space left, we always move the current one up, @@ -1152,12 +1152,12 @@ bool SwPostItMgr::LayoutByPage(std::list &aVisiblePostItList, con bScrollbars = true; lTopBorder += GetSidebarScrollerHeight() + 10; lBottomBorder -= (GetSidebarScrollerHeight() + 10); - for(SwSidebarWin_iterator i = aVisiblePostItList.begin(); i != aVisiblePostItList.end() ; ++i) + for(SwAnnotationWin_iterator i = aVisiblePostItList.begin(); i != aVisiblePostItList.end() ; ++i) (*i)->SetSize(Size((*i)->VirtualSize().getWidth(),(*i)->GetMinimumSizeWithMeta())); } else { - for(SwSidebarWin_iterator i = aVisiblePostItList.begin(); i != aVisiblePostItList.end() ; ++i) + for(SwAnnotationWin_iterator i = aVisiblePostItList.begin(); i != aVisiblePostItList.end() ; ++i) { if ( (*i)->VirtualSize().getHeight() > lAverageHeight) (*i)->SetSize(Size((*i)->VirtualSize().getWidth(),lAverageHeight)); @@ -1176,9 +1176,9 @@ bool SwPostItMgr::LayoutByPage(std::list &aVisiblePostItList, con loop++; bDone = true; long lSpaceUsed = lTopBorder + GetSpaceBetween(); - for(SwSidebarWin_iterator i = aVisiblePostItList.begin(); i != aVisiblePostItList.end() ; ++i) + for(SwAnnotationWin_iterator i = aVisiblePostItList.begin(); i != aVisiblePostItList.end() ; ++i) { - SwSidebarWin_iterator aNextPostIt = i; + SwAnnotationWin_iterator aNextPostIt = i; ++aNextPostIt; if (aNextPostIt != aVisiblePostItList.end()) @@ -1241,7 +1241,7 @@ bool SwPostItMgr::LayoutByPage(std::list &aVisiblePostItList, con else { //(*i) is the last visible item - SwSidebarWin_iterator aPrevPostIt = i; + SwAnnotationWin_iterator aPrevPostIt = i; --aPrevPostIt; lTranslatePos = ( (*aPrevPostIt)->VirtualPos().Y() + (*aPrevPostIt)->VirtualSize().Height() ) - (*i)->VirtualPos().Y(); if (lTranslatePos > 0) @@ -1282,7 +1282,7 @@ bool SwPostItMgr::LayoutByPage(std::list &aVisiblePostItList, con else { // only one left, make sure it is not hidden at the top or bottom - SwSidebarWin_iterator i = aVisiblePostItList.begin(); + SwAnnotationWin_iterator i = aVisiblePostItList.begin(); lTranslatePos = lTopBorder - (*i)->VirtualPos().Y(); if (lTranslatePos>0) { @@ -1513,7 +1513,7 @@ void SwPostItMgr::Delete(sal_uInt32 nPostItId) { mpWrtShell->StartAllAction(); if (HasActiveSidebarWin() && - static_cast(mpActivePostIt.get())->GetPostItField()->GetPostItId() == nPostItId) + mpActivePostIt.get()->GetPostItField()->GetPostItId() == nPostItId) { SetActiveSidebarWin(nullptr); } @@ -1563,8 +1563,8 @@ void SwPostItMgr::ExecuteFormatAllDialog(SwView& rView) { if (mvPostItFields.empty()) return; - sw::sidebarwindows::SwSidebarWin *pOrigActiveWin = GetActiveSidebarWin(); - sw::sidebarwindows::SwSidebarWin *pWin = pOrigActiveWin; + sw::annotation::SwAnnotationWin *pOrigActiveWin = GetActiveSidebarWin(); + sw::annotation::SwAnnotationWin *pWin = pOrigActiveWin; if (!pWin) { for (SwSidebarItem_iterator i = mvPostItFields.begin(); i != mvPostItFields.end(); ++i) @@ -1664,7 +1664,7 @@ void SwPostItMgr::Show() LayoutPostIts(); } -SwSidebarWin* SwPostItMgr::GetSidebarWin( const SfxBroadcaster* pBroadcaster) const +SwAnnotationWin* SwPostItMgr::GetSidebarWin( const SfxBroadcaster* pBroadcaster) const { for(const_iterator i = mvPostItFields.begin(); i != mvPostItFields.end() ; ++i) { @@ -1694,8 +1694,8 @@ sw::annotation::SwAnnotationWin* SwPostItMgr::GetAnnotationWin(const sal_uInt32 return nullptr; } -SwSidebarWin* SwPostItMgr::GetNextPostIt( sal_uInt16 aDirection, - SwSidebarWin* aPostIt ) +SwAnnotationWin* SwPostItMgr::GetNextPostIt( sal_uInt16 aDirection, + SwAnnotationWin* aPostIt ) { if (mvPostItFields.size()>1) { @@ -1878,7 +1878,7 @@ vcl::Window* SwPostItMgr::IsHitSidebarWindow(const Point& rPointLogic) for (SwSidebarItem* pItem : mvPostItFields) { - SwSidebarWin* pPostIt = pItem->pPostIt; + SwAnnotationWin* pPostIt = pItem->pPostIt; if (!pPostIt) continue; @@ -1956,7 +1956,7 @@ void SwPostItMgr::CorrectPositions() return; // find first valid note - SwSidebarWin *pFirstPostIt = nullptr; + SwAnnotationWin *pFirstPostIt = nullptr; for(SwSidebarItem_iterator i = mvPostItFields.begin(); i != mvPostItFields.end() ; ++i) { pFirstPostIt = (*i)->pPostIt; @@ -2088,14 +2088,14 @@ Color SwPostItMgr::GetColorAnchor(std::size_t aAuthorIndex) return Color(COL_WHITE); } -void SwPostItMgr::SetActiveSidebarWin( SwSidebarWin* p) +void SwPostItMgr::SetActiveSidebarWin( SwAnnotationWin* p) { if ( p != mpActivePostIt ) { // we need the temp variable so we can set mpActivePostIt before we call DeactivatePostIt // therefore we get a new layout in DOCCHANGED when switching from postit to document, // otherwise, GetActivePostIt() would still hold our old postit - SwSidebarWin* pActive = mpActivePostIt; + SwAnnotationWin* pActive = mpActivePostIt; mpActivePostIt = p; if (pActive) { @@ -2192,7 +2192,7 @@ void SwPostItMgr::CheckMetaText() sal_uInt16 SwPostItMgr::Replace(SvxSearchItem* pItem) { - SwSidebarWin* pWin = GetActiveSidebarWin(); + SwAnnotationWin* pWin = GetActiveSidebarWin(); sal_uInt16 aResult = pWin->GetOutlinerView()->StartSearchAndReplace( *pItem ); if (!aResult) SetActiveSidebarWin(nullptr); @@ -2201,7 +2201,7 @@ sal_uInt16 SwPostItMgr::Replace(SvxSearchItem* pItem) sal_uInt16 SwPostItMgr::FinishSearchReplace(const i18nutil::SearchOptions2& rSearchOptions, bool bSrchForward) { - SwSidebarWin* pWin = GetActiveSidebarWin(); + SwAnnotationWin* pWin = GetActiveSidebarWin(); SvxSearchItem aItem(SID_SEARCH_ITEM ); aItem.SetSearchOptions(rSearchOptions); aItem.SetBackward(!bSrchForward); @@ -2214,7 +2214,7 @@ sal_uInt16 SwPostItMgr::FinishSearchReplace(const i18nutil::SearchOptions2& rSea sal_uInt16 SwPostItMgr::SearchReplace(const SwFormatField &pField, const i18nutil::SearchOptions2& rSearchOptions, bool bSrchForward) { sal_uInt16 aResult = 0; - SwSidebarWin* pWin = GetSidebarWin(&pField); + SwAnnotationWin* pWin = GetSidebarWin(&pField); if (pWin) { ESelection aOldSelection = pWin->GetOutlinerView()->GetSelection(); @@ -2315,7 +2315,7 @@ void SwPostItMgr::ToggleInsModeOnActiveSidebarWin() void SwPostItMgr::ConnectSidebarWinToFrame( const SwFrame& rFrame, const SwFormatField& rFormatField, - SwSidebarWin& rSidebarWin ) + SwAnnotationWin& rSidebarWin ) { if ( mpFrameSidebarWinContainer == nullptr ) { @@ -2331,7 +2331,7 @@ void SwPostItMgr::ConnectSidebarWinToFrame( const SwFrame& rFrame, } void SwPostItMgr::DisconnectSidebarWinFromFrame( const SwFrame& rFrame, - SwSidebarWin& rSidebarWin ) + SwAnnotationWin& rSidebarWin ) { if ( mpFrameSidebarWinContainer != nullptr ) { diff --git a/sw/source/uibase/docvw/SidebarScrollBar.cxx b/sw/source/uibase/docvw/SidebarScrollBar.cxx index bb23abe47369..7ad03a6c5225 100644 --- a/sw/source/uibase/docvw/SidebarScrollBar.cxx +++ b/sw/source/uibase/docvw/SidebarScrollBar.cxx @@ -13,17 +13,17 @@ #include #include -#include #include #include #include +#include namespace sw { namespace sidebarwindows { -SidebarScrollBar::SidebarScrollBar(SwSidebarWin& rSidebarWin, WinBits nStyle, SwView& rView) +SidebarScrollBar::SidebarScrollBar(sw::annotation::SwAnnotationWin& rSidebarWin, WinBits nStyle, SwView& rView) : ScrollBar(&rSidebarWin, nStyle), m_rSidebarWin(rSidebarWin), m_rView(rView) diff --git a/sw/source/uibase/docvw/SidebarScrollBar.hxx b/sw/source/uibase/docvw/SidebarScrollBar.hxx index 19dae0a8b782..e85eaedf0798 100644 --- a/sw/source/uibase/docvw/SidebarScrollBar.hxx +++ b/sw/source/uibase/docvw/SidebarScrollBar.hxx @@ -14,17 +14,19 @@ class SwView; +namespace sw { namespace annotation { + class SwAnnotationWin; +} } + namespace sw { namespace sidebarwindows { -class SwSidebarWin; - /// Similar to the VCL scrollbar, but instrumented with Writer-specific details for LOK. class SidebarScrollBar : public ScrollBar { - SwSidebarWin& m_rSidebarWin; + sw::annotation::SwAnnotationWin& m_rSidebarWin; SwView& m_rView; protected: @@ -33,7 +35,7 @@ protected: void MouseMove(const MouseEvent& rMouseEvent) override; void MouseButtonUp(const MouseEvent& rMouseEvent) override; public: - SidebarScrollBar(SwSidebarWin& rSidebarWin, WinBits nStyle, SwView& rView); + SidebarScrollBar(sw::annotation::SwAnnotationWin& rSidebarWin, WinBits nStyle, SwView& rView); virtual ~SidebarScrollBar() override; }; diff --git a/sw/source/uibase/docvw/SidebarTxtControl.cxx b/sw/source/uibase/docvw/SidebarTxtControl.cxx index 32d43744524e..0d4cf9f0a41b 100644 --- a/sw/source/uibase/docvw/SidebarTxtControl.cxx +++ b/sw/source/uibase/docvw/SidebarTxtControl.cxx @@ -23,7 +23,6 @@ #include #include -#include #include #include @@ -56,11 +55,12 @@ #include #include #include +#include #include namespace sw { namespace sidebarwindows { -SidebarTextControl::SidebarTextControl( SwSidebarWin& rSidebarWin, +SidebarTextControl::SidebarTextControl( sw::annotation::SwAnnotationWin& rSidebarWin, WinBits nBits, SwView& rDocView, SwPostItMgr& rPostItMgr ) @@ -69,7 +69,7 @@ SidebarTextControl::SidebarTextControl( SwSidebarWin& rSidebarWin, , mrDocView( rDocView ) , mrPostItMgr( rPostItMgr ) { - AddEventListener( LINK( &mrSidebarWin, SwSidebarWin, WindowEventListener ) ); + AddEventListener( LINK( &mrSidebarWin, sw::annotation::SwAnnotationWin, WindowEventListener ) ); } SidebarTextControl::~SidebarTextControl() @@ -79,7 +79,7 @@ SidebarTextControl::~SidebarTextControl() void SidebarTextControl::dispose() { - RemoveEventListener( LINK( &mrSidebarWin, SwSidebarWin, WindowEventListener ) ); + RemoveEventListener( LINK( &mrSidebarWin, sw::annotation::SwAnnotationWin, WindowEventListener ) ); Control::dispose(); } diff --git a/sw/source/uibase/docvw/SidebarTxtControl.hxx b/sw/source/uibase/docvw/SidebarTxtControl.hxx index daf9ab54fba6..7c13e62d93ab 100644 --- a/sw/source/uibase/docvw/SidebarTxtControl.hxx +++ b/sw/source/uibase/docvw/SidebarTxtControl.hxx @@ -26,15 +26,16 @@ class OutlinerView; class SwView; class SwPostItMgr; struct SpellCallbackInfo; +namespace sw { namespace annotation { + class SwAnnotationWin; +} } namespace sw { namespace sidebarwindows { -class SwSidebarWin; - class SidebarTextControl : public Control { private: - SwSidebarWin& mrSidebarWin; + sw::annotation::SwAnnotationWin& mrSidebarWin; SwView& mrDocView; SwPostItMgr& mrPostItMgr; @@ -49,7 +50,7 @@ class SidebarTextControl : public Control virtual Selection GetSurroundingTextSelection() const override; public: - SidebarTextControl( SwSidebarWin& rSidebarWin, + SidebarTextControl( sw::annotation::SwAnnotationWin& rSidebarWin, WinBits nBits, SwView& rDocView, SwPostItMgr& rPostItMgr ); diff --git a/sw/source/uibase/docvw/SidebarWin.cxx b/sw/source/uibase/docvw/SidebarWin.cxx deleted file mode 100644 index 7c3d69c7d69e..000000000000 --- a/sw/source/uibase/docvw/SidebarWin.cxx +++ /dev/null @@ -1,1638 +0,0 @@ -/* -*- 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 . - */ - -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace -{ - -/// Translate absolute <-> relative twips: LOK wants absolute coordinates as output and gives absolute coordinates as input. -void lcl_translateTwips(vcl::Window& rParent, vcl::Window& rChild, MouseEvent* pMouseEvent) -{ - // Set map mode, so that callback payloads will contain absolute coordinates instead of relative ones. - Point aOffset(rChild.GetOutOffXPixel() - rParent.GetOutOffXPixel(), rChild.GetOutOffYPixel() - rParent.GetOutOffYPixel()); - if (!rChild.IsMapModeEnabled()) - { - MapMode aMapMode(rChild.GetMapMode()); - aMapMode.SetMapUnit(MapUnit::MapTwip); - aMapMode.SetScaleX(rParent.GetMapMode().GetScaleX()); - aMapMode.SetScaleY(rParent.GetMapMode().GetScaleY()); - rChild.SetMapMode(aMapMode); - rChild.EnableMapMode(); - } - aOffset = rChild.PixelToLogic(aOffset); - MapMode aMapMode(rChild.GetMapMode()); - aMapMode.SetOrigin(aOffset); - aMapMode.SetMapUnit(rParent.GetMapMode().GetMapUnit()); - rChild.SetMapMode(aMapMode); - rChild.EnableMapMode(false); - - if (pMouseEvent) - { - // Set event coordinates, so they contain relative coordinates instead of absolute ones. - Point aPos = pMouseEvent->GetPosPixel(); - aPos.Move(-aOffset.getX(), -aOffset.getY()); - MouseEvent aMouseEvent(aPos, pMouseEvent->GetClicks(), pMouseEvent->GetMode(), pMouseEvent->GetButtons(), pMouseEvent->GetModifier()); - *pMouseEvent = aMouseEvent; - } -} - -/// Decide which one from the children of rParent should get rMouseEvent. -vcl::Window* lcl_getHitWindow(sw::sidebarwindows::SwSidebarWin& rParent, const MouseEvent& rMouseEvent) -{ - vcl::Window* pRet = nullptr; - - rParent.EditWin().Push(PushFlags::MAPMODE); - rParent.EditWin().EnableMapMode(); - for (sal_Int16 i = rParent.GetChildCount() - 1; i >= 0; --i) - { - vcl::Window* pChild = rParent.GetChild(i); - - Point aPosition(rParent.GetPosPixel()); - aPosition.Move(pChild->GetPosPixel().getX(), pChild->GetPosPixel().getY()); - Size aSize(rParent.GetSizePixel()); - tools::Rectangle aRectangleLogic(rParent.EditWin().PixelToLogic(aPosition), rParent.EditWin().PixelToLogic(aSize)); - if (aRectangleLogic.IsInside(rMouseEvent.GetPosPixel())) - { - pRet = pChild; - break; - } - } - rParent.EditWin().Pop(); - return pRet; -} - -} - -namespace sw { namespace sidebarwindows { - -#define METABUTTON_WIDTH 16 -#define METABUTTON_HEIGHT 18 -#define METABUTTON_AREA_WIDTH 30 -#define POSTIT_META_HEIGHT (sal_Int32) 30 -#define POSTIT_MINIMUMSIZE_WITHOUT_META 50 - -SwSidebarWin::SwSidebarWin(SwEditWin& rEditWin, - WinBits nBits, - SwPostItMgr& aMgr, - SwSidebarItem& rSidebarItem) - : Window(&rEditWin, nBits) - , mrMgr(aMgr) - , mrView(rEditWin.GetView()) - , mnEventId(nullptr) - , mpOutlinerView(nullptr) - , mpOutliner(nullptr) - , mpSidebarTextControl(nullptr) - , mpVScrollbar(nullptr) - , mpMetadataAuthor(nullptr) - , mpMetadataDate(nullptr) - , mpMenuButton(nullptr) - , mpAnchor(nullptr) - , mpShadow(nullptr) - , mpTextRangeOverlay(nullptr) - , mColorAnchor() - , mColorDark() - , mColorLight() - , mChangeColor() - , meSidebarPosition(sw::sidebarwindows::SidebarPosition::NONE) - , mPosSize() - , mAnchorRect() - , mPageBorder(0) - , mbAnchorRectChanged(false) - , mbMouseOver(false) - , mLayoutStatus(SwPostItHelper::INVISIBLE) - , mbReadonly(false) - , mbIsFollow(false) - , mrSidebarItem(rSidebarItem) - , mpAnchorFrame(rSidebarItem.maLayoutInfo.mpAnchorFrame) -{ - mpShadow = ShadowOverlayObject::CreateShadowOverlayObject( mrView ); - if ( mpShadow ) - { - mpShadow->setVisible(false); - } - - mrMgr.ConnectSidebarWinToFrame( *(mrSidebarItem.maLayoutInfo.mpAnchorFrame), - mrSidebarItem.GetFormatField(), - *this ); -} - -SwSidebarWin::~SwSidebarWin() -{ - disposeOnce(); -} - -void SwSidebarWin::dispose() -{ - if (IsDisposed()) - return; - - mrMgr.DisconnectSidebarWinFromFrame( *(mrSidebarItem.maLayoutInfo.mpAnchorFrame), - *this ); - - Disable(); - - if ( mpSidebarTextControl ) - { - if ( mpOutlinerView ) - { - mpOutlinerView->SetWindow( nullptr ); - } - } - mpSidebarTextControl.disposeAndClear(); - - if ( mpOutlinerView ) - { - delete mpOutlinerView; - mpOutlinerView = nullptr; - } - - if (mpOutliner) - { - delete mpOutliner; - mpOutliner = nullptr; - } - - if (mpMetadataAuthor) - { - mpMetadataAuthor->RemoveEventListener( LINK( this, SwSidebarWin, WindowEventListener ) ); - } - mpMetadataAuthor.disposeAndClear(); - - if (mpMetadataDate) - { - mpMetadataDate->RemoveEventListener( LINK( this, SwSidebarWin, WindowEventListener ) ); - } - mpMetadataDate.disposeAndClear(); - - if (mpVScrollbar) - { - mpVScrollbar->RemoveEventListener( LINK( this, SwSidebarWin, WindowEventListener ) ); - } - mpVScrollbar.disposeAndClear(); - - RemoveEventListener( LINK( this, SwSidebarWin, WindowEventListener ) ); - - AnchorOverlayObject::DestroyAnchorOverlayObject( mpAnchor ); - mpAnchor = nullptr; - - ShadowOverlayObject::DestroyShadowOverlayObject( mpShadow ); - mpShadow = nullptr; - - delete mpTextRangeOverlay; - mpTextRangeOverlay = nullptr; - - mpMenuButton.disposeAndClear(); - - if (mnEventId) - Application::RemoveUserEvent( mnEventId ); - - vcl::Window::dispose(); -} - -void SwSidebarWin::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) -{ - Window::Paint(rRenderContext, rRect); - - if (mpMetadataAuthor->IsVisible()) - { - //draw left over space - if (Application::GetSettings().GetStyleSettings().GetHighContrastMode()) - { - rRenderContext.SetFillColor(COL_BLACK); - } - else - { - rRenderContext.SetFillColor(mColorDark); - } - - rRenderContext.SetLineColor(); - tools::Rectangle aRectangle(Point(mpMetadataAuthor->GetPosPixel().X() + mpMetadataAuthor->GetSizePixel().Width(), - mpMetadataAuthor->GetPosPixel().Y()), - Size(GetMetaButtonAreaWidth(), - mpMetadataAuthor->GetSizePixel().Height() + mpMetadataDate->GetSizePixel().Height())); - - if (comphelper::LibreOfficeKit::isActive()) - aRectangle = rRect; - else - aRectangle = PixelToLogic(aRectangle); - rRenderContext.DrawRect(aRectangle); - } -} - -void SwSidebarWin::PaintTile(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) -{ - Paint(rRenderContext, rRect); - - for (sal_uInt16 i = 0; i < GetChildCount(); ++i) - { - vcl::Window* pChild = GetChild(i); - - // No point in showing this button till click on it are not handled. - if (pChild == mpMenuButton.get()) - continue; - - if (!pChild->IsVisible()) - continue; - - rRenderContext.Push(PushFlags::MAPMODE); - Point aOffset(PixelToLogic(pChild->GetPosPixel())); - MapMode aMapMode(rRenderContext.GetMapMode()); - aMapMode.SetOrigin(aMapMode.GetOrigin() + aOffset); - rRenderContext.SetMapMode(aMapMode); - - bool bPopChild = false; - if (pChild->GetMapMode().GetMapUnit() != rRenderContext.GetMapMode().GetMapUnit()) - { - // This is needed for the scrollbar that has its map unit in pixels. - pChild->Push(PushFlags::MAPMODE); - bPopChild = true; - pChild->EnableMapMode(); - aMapMode = pChild->GetMapMode(); - aMapMode.SetMapUnit(rRenderContext.GetMapMode().GetMapUnit()); - aMapMode.SetScaleX(rRenderContext.GetMapMode().GetScaleX()); - aMapMode.SetScaleY(rRenderContext.GetMapMode().GetScaleY()); - pChild->SetMapMode(aMapMode); - } - - pChild->Paint(rRenderContext, rRect); - - if (bPopChild) - pChild->Pop(); - rRenderContext.Pop(); - } - - const drawinglayer::geometry::ViewInformation2D aViewInformation; - std::unique_ptr pProcessor(drawinglayer::processor2d::createBaseProcessor2DFromOutputDevice(rRenderContext, aViewInformation)); - - // drawinglayer sets the map mode to pixels, not needed here. - rRenderContext.Pop(); - // Work in document-global twips. - rRenderContext.Pop(); - if (mpAnchor) - pProcessor->process(mpAnchor->getOverlayObjectPrimitive2DSequence()); - if (mpTextRangeOverlay) - pProcessor->process(mpTextRangeOverlay->getOverlayObjectPrimitive2DSequence()); - - rRenderContext.Push(PushFlags::NONE); - pProcessor.reset(); - rRenderContext.Push(PushFlags::NONE); -} - -bool SwSidebarWin::IsHitWindow(const Point& rPointLogic) -{ - tools::Rectangle aRectangleLogic(EditWin().PixelToLogic(GetPosPixel()), EditWin().PixelToLogic(GetSizePixel())); - return aRectangleLogic.IsInside(rPointLogic); -} - -void SwSidebarWin::SetCursorLogicPosition(const Point& rPosition, bool bPoint, bool bClearMark) -{ - mpSidebarTextControl->Push(PushFlags::MAPMODE); - MouseEvent aMouseEvent(rPosition); - lcl_translateTwips(EditWin(), *mpSidebarTextControl, &aMouseEvent); - Point aPosition(aMouseEvent.GetPosPixel()); - - EditView& rEditView = GetOutlinerView()->GetEditView(); - rEditView.SetCursorLogicPosition(aPosition, bPoint, bClearMark); - - mpSidebarTextControl->Pop(); -} - -void SwSidebarWin::Draw(OutputDevice* pDev, const Point& rPt, const Size& rSz, DrawFlags nInFlags) -{ - if (mpMetadataAuthor->IsVisible() ) - { - pDev->SetFillColor(mColorDark); - pDev->SetLineColor(); - pDev->DrawRect( tools::Rectangle( rPt, rSz ) ); - } - - if (mpMetadataAuthor->IsVisible()) - { - vcl::Font aOrigFont(mpMetadataAuthor->GetControlFont()); - Size aSize(PixelToLogic(mpMetadataAuthor->GetSizePixel())); - Point aPos(PixelToLogic(mpMetadataAuthor->GetPosPixel())); - aPos += rPt; - vcl::Font aFont( mpMetadataAuthor->GetSettings().GetStyleSettings().GetFieldFont() ); - mpMetadataAuthor->SetControlFont( aFont ); - mpMetadataAuthor->Draw(pDev, aPos, aSize, nInFlags); - mpMetadataAuthor->SetControlFont( aOrigFont ); - } - - if (mpMetadataDate->IsVisible()) - { - vcl::Font aOrigFont(mpMetadataDate->GetControlFont()); - Size aSize(PixelToLogic(mpMetadataDate->GetSizePixel())); - Point aPos(PixelToLogic(mpMetadataDate->GetPosPixel())); - aPos += rPt; - vcl::Font aFont( mpMetadataDate->GetSettings().GetStyleSettings().GetFieldFont() ); - mpMetadataDate->SetControlFont( aFont ); - mpMetadataDate->Draw(pDev, aPos, aSize, nInFlags); - mpMetadataDate->SetControlFont( aOrigFont ); - } - - mpSidebarTextControl->Draw(pDev, rPt, rSz, nInFlags); - - const drawinglayer::geometry::ViewInformation2D aNewViewInfos; - std::unique_ptr pProcessor( - drawinglayer::processor2d::createBaseProcessor2DFromOutputDevice( - *pDev, aNewViewInfos )); - - if (mpAnchor) - pProcessor->process(mpAnchor->getOverlayObjectPrimitive2DSequence()); - if (mpTextRangeOverlay) - pProcessor->process(mpTextRangeOverlay->getOverlayObjectPrimitive2DSequence()); - pProcessor.reset(); - - if (mpVScrollbar->IsVisible()) - { - vcl::Font aOrigFont(mpMetadataDate->GetControlFont()); - Color aOrigBg( mpMetadataDate->GetControlBackground() ); - OUString sOrigText(mpMetadataDate->GetText()); - - Size aSize(PixelToLogic(mpMenuButton->GetSizePixel())); - Point aPos(PixelToLogic(mpMenuButton->GetPosPixel())); - aPos += rPt; - - vcl::Font aFont( mpMetadataDate->GetSettings().GetStyleSettings().GetFieldFont() ); - mpMetadataDate->SetControlFont( aFont ); - mpMetadataDate->SetControlBackground( 0xFFFFFF ); - mpMetadataDate->SetText("..."); - mpMetadataDate->Draw(pDev, aPos, aSize, nInFlags); - - mpMetadataDate->SetText(sOrigText); - mpMetadataDate->SetControlFont( aOrigFont ); - mpMetadataDate->SetControlBackground( aOrigBg ); - } -} - -void SwSidebarWin::KeyInput(const KeyEvent& rKeyEvent) -{ - if (mpSidebarTextControl) - { - mpSidebarTextControl->Push(PushFlags::MAPMODE); - lcl_translateTwips(EditWin(), *mpSidebarTextControl, nullptr); - - mpSidebarTextControl->KeyInput(rKeyEvent); - - mpSidebarTextControl->Pop(); - } -} - -void SwSidebarWin::MouseMove(const MouseEvent& rMouseEvent) -{ - if (vcl::Window* pHit = lcl_getHitWindow(*this, rMouseEvent)) - { - pHit->Push(PushFlags::MAPMODE); - MouseEvent aMouseEvent(rMouseEvent); - lcl_translateTwips(EditWin(), *pHit, &aMouseEvent); - - pHit->MouseMove(aMouseEvent); - - pHit->Pop(); - } -} - -void SwSidebarWin::MouseButtonDown(const MouseEvent& rMouseEvent) -{ - if (vcl::Window* pHit = lcl_getHitWindow(*this, rMouseEvent)) - { - pHit->Push(PushFlags::MAPMODE); - MouseEvent aMouseEvent(rMouseEvent); - lcl_translateTwips(EditWin(), *pHit, &aMouseEvent); - - pHit->MouseButtonDown(aMouseEvent); - - pHit->Pop(); - } -} - -void SwSidebarWin::MouseButtonUp(const MouseEvent& rMouseEvent) -{ - if (vcl::Window* pHit = lcl_getHitWindow(*this, rMouseEvent)) - { - pHit->Push(PushFlags::MAPMODE); - MouseEvent aMouseEvent(rMouseEvent); - lcl_translateTwips(EditWin(), *pHit, &aMouseEvent); - - pHit->MouseButtonUp(aMouseEvent); - - pHit->Pop(); - } -} - -void SwSidebarWin::SetPosSizePixelRect(long nX, long nY, long nWidth, long nHeight, - const SwRect& aAnchorRect, const long aPageBorder) -{ - mPosSize = tools::Rectangle(Point(nX,nY),Size(nWidth,nHeight)); - if (!mAnchorRect.IsEmpty() && mAnchorRect != aAnchorRect) - mbAnchorRectChanged = true; - mAnchorRect = aAnchorRect; - mPageBorder = aPageBorder; -} - -void SwSidebarWin::SetSize( const Size& rNewSize ) -{ - mPosSize.SetSize(rNewSize); -} - -void SwSidebarWin::SetVirtualPosSize( const Point& aPoint, const Size& aSize) -{ - mPosSize = tools::Rectangle(aPoint,aSize); -} - -void SwSidebarWin::TranslateTopPosition(const long aAmount) -{ - mPosSize.Move(0,aAmount); -} - -void SwSidebarWin::ShowAnchorOnly(const Point &aPoint) -{ - HideNote(); - SetPosAndSize(); - if (mpAnchor) - { - mpAnchor->SetSixthPosition(basegfx::B2DPoint(aPoint.X(),aPoint.Y())); - mpAnchor->SetSeventhPosition(basegfx::B2DPoint(aPoint.X(),aPoint.Y())); - mpAnchor->SetAnchorState(AnchorState::All); - mpAnchor->setVisible(true); - } - if (mpShadow) - mpShadow->setVisible(false); -} - -SfxItemSet SwSidebarWin::DefaultItem() -{ - SfxItemSet aItem( mrView.GetDocShell()->GetPool() ); - aItem.Put(SvxFontHeightItem(200,100,EE_CHAR_FONTHEIGHT)); - return aItem; -} - -void SwSidebarWin::InitControls() -{ - AddEventListener( LINK( this, SwSidebarWin, WindowEventListener ) ); - - // actual window which holds the user text - mpSidebarTextControl = VclPtr::Create( *this, - WB_NODIALOGCONTROL, - mrView, mrMgr ); - mpSidebarTextControl->SetPointer(Pointer(PointerStyle::Text)); - - // window controls for author and date - mpMetadataAuthor = VclPtr::Create( this, 0 ); - mpMetadataAuthor->SetAccessibleName( SW_RES( STR_ACCESS_ANNOTATION_AUTHOR_NAME ) ); - mpMetadataAuthor->EnableRTL(AllSettings::GetLayoutRTL()); - mpMetadataAuthor->SetReadOnly(); - mpMetadataAuthor->AlwaysDisableInput(true); - mpMetadataAuthor->SetCallHandlersOnInputDisabled(true); - mpMetadataAuthor->AddEventListener( LINK( this, SwSidebarWin, WindowEventListener ) ); - // we should leave this setting alone, but for this we need a better layout algo - // with variable meta size height - { - AllSettings aSettings = mpMetadataAuthor->GetSettings(); - StyleSettings aStyleSettings = aSettings.GetStyleSettings(); - vcl::Font aFont = aStyleSettings.GetFieldFont(); - aFont.SetFontHeight(8); - aStyleSettings.SetFieldFont(aFont); - aSettings.SetStyleSettings(aStyleSettings); - mpMetadataAuthor->SetSettings(aSettings); - } - - mpMetadataDate = VclPtr::Create( this, 0 ); - mpMetadataDate->SetAccessibleName( SW_RES( STR_ACCESS_ANNOTATION_DATE_NAME ) ); - mpMetadataDate->EnableRTL(AllSettings::GetLayoutRTL()); - mpMetadataDate->SetReadOnly(); - mpMetadataDate->AlwaysDisableInput(true); - mpMetadataDate->SetCallHandlersOnInputDisabled(true); - mpMetadataDate->AddEventListener( LINK( this, SwSidebarWin, WindowEventListener ) ); - // we should leave this setting alone, but for this we need a better layout algo - // with variable meta size height - { - AllSettings aSettings = mpMetadataDate->GetSettings(); - StyleSettings aStyleSettings = aSettings.GetStyleSettings(); - vcl::Font aFont = aStyleSettings.GetFieldFont(); - aFont.SetFontHeight(8); - aStyleSettings.SetFieldFont(aFont); - aSettings.SetStyleSettings(aStyleSettings); - mpMetadataDate->SetSettings(aSettings); - } - - SwDocShell* aShell = mrView.GetDocShell(); - mpOutliner = new Outliner(&aShell->GetPool(),OutlinerMode::TextObject); - aShell->GetDoc()->SetCalcFieldValueHdl( mpOutliner ); - mpOutliner->SetUpdateMode( true ); - Rescale(); - - mpSidebarTextControl->EnableRTL( false ); - mpOutlinerView = new OutlinerView ( mpOutliner, mpSidebarTextControl ); - mpOutlinerView->SetBackgroundColor(COL_TRANSPARENT); - mpOutliner->InsertView(mpOutlinerView ); - mpOutlinerView->SetOutputArea( PixelToLogic( tools::Rectangle(0,0,1,1) ) ); - - mpOutlinerView->SetAttribs(DefaultItem()); - - if (comphelper::LibreOfficeKit::isActive()) - { - // If there is a callback already registered, inform the new outliner view about it. - mpOutlinerView->RegisterViewShell(&mrView); - } - - //create Scrollbars - mpVScrollbar = VclPtr::Create(*this, WB_3DLOOK |WB_VSCROLL|WB_DRAG, mrView); - mpVScrollbar->EnableNativeWidget(false); - mpVScrollbar->EnableRTL( false ); - mpVScrollbar->SetScrollHdl(LINK(this, SwSidebarWin, ScrollHdl)); - mpVScrollbar->EnableDrag(); - mpVScrollbar->AddEventListener( LINK( this, SwSidebarWin, WindowEventListener ) ); - - const SwViewOption* pVOpt = mrView.GetWrtShellPtr()->GetViewOptions(); - EEControlBits nCntrl = mpOutliner->GetControlWord(); - // TODO: crash when AUTOCOMPLETE enabled - nCntrl |= EEControlBits::MARKFIELDS | EEControlBits::PASTESPECIAL | EEControlBits::AUTOCORRECT | EEControlBits::USECHARATTRIBS; // | EEControlBits::AUTOCOMPLETE; - if (SwViewOption::IsFieldShadings()) - nCntrl |= EEControlBits::MARKFIELDS; - else - nCntrl &= ~EEControlBits::MARKFIELDS; - if (pVOpt->IsOnlineSpell()) - nCntrl |= EEControlBits::ONLINESPELLING; - else - nCntrl &= ~EEControlBits::ONLINESPELLING; - mpOutliner->SetControlWord(nCntrl); - - std::size_t aIndex = SW_MOD()->InsertRedlineAuthor(GetAuthor()); - SetColor( SwPostItMgr::GetColorDark(aIndex), - SwPostItMgr::GetColorLight(aIndex), - SwPostItMgr::GetColorAnchor(aIndex)); - - CheckMetaText(); - - mpMenuButton = CreateMenuButton(); - - SetLanguage(GetLanguage()); - GetOutlinerView()->StartSpeller(); - SetPostItText(); - Engine()->CompleteOnlineSpelling(); - - mpSidebarTextControl->Show(); - mpMetadataAuthor->Show(); - mpMetadataDate->Show(); - mpVScrollbar->Show(); -} - -void SwSidebarWin::CheckMetaText() -{ - const SvtSysLocale aSysLocale; - const LocaleDataWrapper& rLocalData = aSysLocale.GetLocaleData(); - OUString sMeta = GetAuthor(); - if (sMeta.isEmpty()) - { - sMeta = SW_RESSTR(STR_NOAUTHOR); - } - else if (sMeta.getLength() > 23) - { - sMeta = sMeta.copy(0, 20) + "..."; - } - if ( mpMetadataAuthor->GetText() != sMeta ) - { - mpMetadataAuthor->SetText(sMeta); - } - - Date aDate = GetDate(); - if (aDate.IsValidAndGregorian() ) - { - sMeta = rLocalData.getDate(aDate); - } - else - { - sMeta = SW_RESSTR(STR_NODATE); - } - if (GetTime()!=0) - { - sMeta += " " + rLocalData.getTime( GetTime(),false ); - } - if ( mpMetadataDate->GetText() != sMeta ) - { - mpMetadataDate->SetText(sMeta); - } -} - -void SwSidebarWin::Rescale() -{ - MapMode aMode = GetParent()->GetMapMode(); - aMode.SetOrigin( Point() ); - mpOutliner->SetRefMapMode( aMode ); - SetMapMode( aMode ); - mpSidebarTextControl->SetMapMode( aMode ); - const Fraction& rFraction = mrView.GetWrtShellPtr()->GetOut()->GetMapMode().GetScaleY(); - if ( mpMetadataAuthor ) - { - vcl::Font aFont( mpMetadataAuthor->GetSettings().GetStyleSettings().GetFieldFont() ); - sal_Int32 nHeight = aFont.GetFontHeight(); - nHeight = nHeight * rFraction.GetNumerator() / rFraction.GetDenominator(); - aFont.SetFontHeight( nHeight ); - mpMetadataAuthor->SetControlFont( aFont ); - } - if ( mpMetadataDate ) - { - vcl::Font aFont( mpMetadataDate->GetSettings().GetStyleSettings().GetFieldFont() ); - sal_Int32 nHeight = aFont.GetFontHeight(); - nHeight = nHeight * rFraction.GetNumerator() / rFraction.GetDenominator(); - aFont.SetFontHeight( nHeight ); - mpMetadataDate->SetControlFont( aFont ); - } -} - -void SwSidebarWin::SetPosAndSize() -{ - bool bChange = false; - - if (GetSizePixel() != mPosSize.GetSize()) - { - bChange = true; - SetSizePixel(mPosSize.GetSize()); - - if (comphelper::LibreOfficeKit::isActive()) - { - // Position is not yet set at VCL level, but the map mode should - // contain the right origin to emit the correct cursor position. - mpSidebarTextControl->Push(PushFlags::MAPMODE); - Point aOffset(mPosSize.Left(), mPosSize.Top()); - aOffset = PixelToLogic(aOffset); - MapMode aMapMode(mpSidebarTextControl->GetMapMode()); - aMapMode.SetOrigin(aOffset); - mpSidebarTextControl->SetMapMode(aMapMode); - mpSidebarTextControl->EnableMapMode(false); - } - - DoResize(); - - if (comphelper::LibreOfficeKit::isActive()) - mpSidebarTextControl->Pop(); - } - - if (GetPosPixel().X() != mPosSize.TopLeft().X() || (std::abs(GetPosPixel().Y() - mPosSize.TopLeft().Y()) > 5) ) - { - bChange = true; - SetPosPixel(mPosSize.TopLeft()); - - Point aLineStart; - Point aLineEnd ; - switch ( meSidebarPosition ) - { - case sw::sidebarwindows::SidebarPosition::LEFT: - { - aLineStart = EditWin().PixelToLogic( Point(GetPosPixel().X()+GetSizePixel().Width(),GetPosPixel().Y()-1) ); - aLineEnd = EditWin().PixelToLogic( Point(GetPosPixel().X(),GetPosPixel().Y()-1) ); - } - break; - case sw::sidebarwindows::SidebarPosition::RIGHT: - { - aLineStart = EditWin().PixelToLogic( Point(GetPosPixel().X(),GetPosPixel().Y()-1) ); - aLineEnd = EditWin().PixelToLogic( Point(GetPosPixel().X()+GetSizePixel().Width(),GetPosPixel().Y()-1) ); - } - break; - default: - OSL_FAIL( " - unexpected position of sidebar" ); - break; - } - - // LOK has map mode disabled, and we still want to perform pixel -> - // twips conversion for the size of the line above the note. - if (comphelper::LibreOfficeKit::isActive() && !EditWin().IsMapModeEnabled()) - { - EditWin().EnableMapMode(); - Size aSize(aLineEnd.getX() - aLineStart.getX(), aLineEnd.getY() - aLineStart.getY()); - aSize = EditWin().PixelToLogic(aSize); - aLineEnd = aLineStart; - aLineEnd.Move(aSize.getWidth(), aSize.getHeight()); - EditWin().EnableMapMode(false); - } - - if (mpAnchor) - { - mpAnchor->SetAllPosition( basegfx::B2DPoint( mAnchorRect.Left() , mAnchorRect.Bottom() - 5* 15), - basegfx::B2DPoint( mAnchorRect.Left()-5*15 , mAnchorRect.Bottom()+5*15), - basegfx::B2DPoint( mAnchorRect.Left()+5*15 , mAnchorRect.Bottom()+5*15), - basegfx::B2DPoint( mAnchorRect.Left(), mAnchorRect.Bottom()+2*15), - basegfx::B2DPoint( mPageBorder ,mAnchorRect.Bottom()+2*15), - basegfx::B2DPoint( aLineStart.X(),aLineStart.Y()), - basegfx::B2DPoint( aLineEnd.X(),aLineEnd.Y())); - mpAnchor->SetHeight(mAnchorRect.Height()); - } - else - { - mpAnchor = AnchorOverlayObject::CreateAnchorOverlayObject( mrView, - mAnchorRect, - mPageBorder, - aLineStart, - aLineEnd, - mColorAnchor ); - if ( mpAnchor ) - { - mpAnchor->SetHeight(mAnchorRect.Height()); - mpAnchor->setVisible(true); - mpAnchor->SetAnchorState(AnchorState::Tri); - if (HasChildPathFocus()) - { - mpAnchor->setLineSolid(true); - } - } - } - } - else - { - if ( mpAnchor && - ( mpAnchor->getBasePosition() != basegfx::B2DPoint( mAnchorRect.Left() , mAnchorRect.Bottom()-5*15) ) ) - { - mpAnchor->SetTriPosition( basegfx::B2DPoint( mAnchorRect.Left() , mAnchorRect.Bottom() - 5* 15), - basegfx::B2DPoint( mAnchorRect.Left()-5*15 , mAnchorRect.Bottom()+5*15), - basegfx::B2DPoint( mAnchorRect.Left()+5*15 , mAnchorRect.Bottom()+5*15), - basegfx::B2DPoint( mAnchorRect.Left(), mAnchorRect.Bottom()+2*15), - basegfx::B2DPoint( mPageBorder , mAnchorRect.Bottom()+2*15)); - } - } - - if (bChange) - { - Point aStart = EditWin().PixelToLogic(GetPosPixel()+Point(0,GetSizePixel().Height())); - Point aEnd = EditWin().PixelToLogic(GetPosPixel()+Point(GetSizePixel().Width()-1,GetSizePixel().Height())); - mpShadow->SetPosition(basegfx::B2DPoint(aStart.X(),aStart.Y()), basegfx::B2DPoint(aEnd.X(),aEnd.Y())); - } - - if (mrMgr.ShowNotes()) - { - if (IsFollow() && !HasChildPathFocus()) - { - // #i111964# - if ( mpAnchor ) - { - mpAnchor->SetAnchorState(AnchorState::End); - } - } - else - { - // #i111964# - if ( mpAnchor ) - { - mpAnchor->SetAnchorState(AnchorState::All); - } - SwSidebarWin* pWin = GetTopReplyNote(); - // #i111964# - if ( pWin && pWin->Anchor() ) - { - pWin->Anchor()->SetAnchorState(AnchorState::End); - } - } - } - - - // text range overlay - maAnnotationTextRanges.clear(); - if ( mrSidebarItem.maLayoutInfo.mnStartNodeIdx != 0 - && mrSidebarItem.maLayoutInfo.mnStartContent != -1 ) - { - const SwTextAnnotationField* pTextAnnotationField = - dynamic_cast< const SwTextAnnotationField* >( mrSidebarItem.GetFormatField().GetTextField() ); - SwTextNode* pTextNode = pTextAnnotationField ? pTextAnnotationField->GetpTextNode() : nullptr; - SwContentNode* pContentNd = nullptr; - if (pTextNode) - { - SwNodes& rNds = pTextNode->GetDoc()->GetNodes(); - pContentNd = rNds[mrSidebarItem.maLayoutInfo.mnStartNodeIdx]->GetContentNode(); - } - if (pContentNd) - { - SwPosition aStartPos( *pContentNd, mrSidebarItem.maLayoutInfo.mnStartContent ); - SwShellCursor* pTmpCursor = nullptr; - const bool bTableCursorNeeded = pTextNode->FindTableBoxStartNode() != pContentNd->FindTableBoxStartNode(); - if ( bTableCursorNeeded ) - { - SwShellTableCursor* pTableCursor = new SwShellTableCursor( DocView().GetWrtShell(), aStartPos ); - pTableCursor->SetMark(); - pTableCursor->GetMark()->nNode = *pTextNode; - pTableCursor->GetMark()->nContent.Assign( pTextNode, pTextAnnotationField->GetStart()+1 ); - pTableCursor->NewTableSelection(); - pTmpCursor = pTableCursor; - } - else - { - SwShellCursor* pCursor = new SwShellCursor( DocView().GetWrtShell(), aStartPos ); - pCursor->SetMark(); - pCursor->GetMark()->nNode = *pTextNode; - pCursor->GetMark()->nContent.Assign( pTextNode, pTextAnnotationField->GetStart()+1 ); - pTmpCursor = pCursor; - } - std::unique_ptr pTmpCursorForAnnotationTextRange( pTmpCursor ); - - // For annotation text range rectangles to be calculated correctly, - // we need the map mode disabled - bool bDisableMapMode = comphelper::LibreOfficeKit::isActive() && EditWin().IsMapModeEnabled(); - if (bDisableMapMode) - EditWin().EnableMapMode(false); - - pTmpCursorForAnnotationTextRange->FillRects(); - - if (bDisableMapMode) - EditWin().EnableMapMode(); - - SwRects* pRects(pTmpCursorForAnnotationTextRange.get()); - for(SwRect & rNextRect : *pRects) - { - const tools::Rectangle aPntRect(rNextRect.SVRect()); - maAnnotationTextRanges.push_back(basegfx::B2DRange( - aPntRect.Left(), aPntRect.Top(), - aPntRect.Right() + 1, aPntRect.Bottom() + 1)); - } - } - } - - if (mrMgr.ShowNotes() && !maAnnotationTextRanges.empty()) - { - if ( mpTextRangeOverlay != nullptr ) - { - mpTextRangeOverlay->setRanges( maAnnotationTextRanges ); - if ( mpAnchor != nullptr && mpAnchor->getLineSolid() ) - { - mpTextRangeOverlay->ShowSolidBorder(); - } - else - { - mpTextRangeOverlay->HideSolidBorder(); - } - } - else if (!IsFollow()) - { - // This window is not a reply, then draw its range overlay. - mpTextRangeOverlay = - sw::overlay::OverlayRanges::CreateOverlayRange( - DocView(), - mColorAnchor, - maAnnotationTextRanges, - mpAnchor && mpAnchor->getLineSolid() ); - } - } - else - { - delete mpTextRangeOverlay; - mpTextRangeOverlay = nullptr; - } -} - -void SwSidebarWin::DoResize() -{ - long aTextHeight = LogicToPixel( mpOutliner->CalcTextSize()).Height(); - long aHeight = GetSizePixel().Height(); - unsigned long aWidth = GetSizePixel().Width(); - - aHeight -= GetMetaHeight(); - mpMetadataAuthor->Show(); - mpMetadataDate->Show(); - mpSidebarTextControl->SetQuickHelpText(OUString()); - - if (aTextHeight > aHeight) - { // we need vertical scrollbars and have to reduce the width - aWidth -= GetScrollbarWidth(); - mpVScrollbar->Show(); - } - else - { - mpVScrollbar->Hide(); - } - - { - const Size aSizeOfMetadataControls( GetSizePixel().Width() - GetMetaButtonAreaWidth(), - GetMetaHeight()/2 ); - mpMetadataAuthor->setPosSizePixel( 0, - aHeight, - aSizeOfMetadataControls.Width(), - aSizeOfMetadataControls.Height() ); - mpMetadataDate->setPosSizePixel( 0, - aHeight + aSizeOfMetadataControls.Height(), - aSizeOfMetadataControls.Width(), - aSizeOfMetadataControls.Height() ); - } - - mpOutliner->SetPaperSize( PixelToLogic( Size(aWidth,aHeight) ) ) ; - if (!mpVScrollbar->IsVisible()) - { // if we do not have a scrollbar anymore, we want to see the complete text - mpOutlinerView->SetVisArea( PixelToLogic( tools::Rectangle(0,0,aWidth,aHeight) ) ); - } - mpOutlinerView->SetOutputArea( PixelToLogic( tools::Rectangle(0,0,aWidth,aHeight) ) ); - - if (!AllSettings::GetLayoutRTL()) - { - mpSidebarTextControl->setPosSizePixel(0, 0, aWidth, aHeight); - mpVScrollbar->setPosSizePixel( aWidth, 0, GetScrollbarWidth(), aHeight); - } - else - { - mpSidebarTextControl->setPosSizePixel( ( aTextHeight > aHeight ? GetScrollbarWidth() : 0 ), 0, - aWidth, aHeight); - mpVScrollbar->setPosSizePixel( 0, 0, GetScrollbarWidth(), aHeight); - } - - mpVScrollbar->SetVisibleSize( PixelToLogic(Size(0,aHeight)).Height() ); - mpVScrollbar->SetPageSize( PixelToLogic(Size(0,aHeight)).Height() * 8 / 10 ); - mpVScrollbar->SetLineSize( mpOutliner->GetTextHeight() / 10 ); - SetScrollbar(); - mpVScrollbar->SetRange( Range(0, mpOutliner->GetTextHeight())); - - //calculate rects for meta- button - const Fraction& fx( GetMapMode().GetScaleX() ); - const Fraction& fy( GetMapMode().GetScaleY() ); - - const Point aPos( mpMetadataAuthor->GetPosPixel()); - mpMenuButton->setPosSizePixel( aPos.X()+GetSizePixel().Width()-(METABUTTON_WIDTH+10)*fx.GetNumerator()/fx.GetDenominator(), - aPos.Y()+5*fy.GetNumerator()/fy.GetDenominator(), - METABUTTON_WIDTH*fx.GetNumerator()/fx.GetDenominator(), - METABUTTON_HEIGHT*fy.GetNumerator()/fy.GetDenominator() ); -} - -void SwSidebarWin::SetSizePixel( const Size& rNewSize ) -{ - Window::SetSizePixel(rNewSize); - - if (mpShadow) - { - Point aStart = EditWin().PixelToLogic(GetPosPixel()+Point(0,GetSizePixel().Height())); - Point aEnd = EditWin().PixelToLogic(GetPosPixel()+Point(GetSizePixel().Width()-1,GetSizePixel().Height())); - mpShadow->SetPosition(basegfx::B2DPoint(aStart.X(),aStart.Y()), basegfx::B2DPoint(aEnd.X(),aEnd.Y())); - } -} - -void SwSidebarWin::SetScrollbar() -{ - mpVScrollbar->SetThumbPos(mpOutlinerView->GetVisArea().Top()); -} - -void SwSidebarWin::ResizeIfNecessary(long aOldHeight, long aNewHeight) -{ - if (aOldHeight != aNewHeight) - { - //check for lower border or next note - long aBorder = mrMgr.GetNextBorder(); - if (aBorder != -1) - { - if (aNewHeight > GetMinimumSizeWithoutMeta()) - { - long aNewLowerValue = GetPosPixel().Y() + aNewHeight + GetMetaHeight(); - if (aNewLowerValue < aBorder) - SetSizePixel(Size(GetSizePixel().Width(),aNewHeight+GetMetaHeight())); - else - SetSizePixel(Size(GetSizePixel().Width(),aBorder - GetPosPixel().Y())); - DoResize(); - Invalidate(); - } - else - { - if (GetSizePixel().Height() != GetMinimumSizeWithoutMeta() + GetMetaHeight()) - SetSizePixel(Size(GetSizePixel().Width(),GetMinimumSizeWithoutMeta() + GetMetaHeight())); - DoResize(); - Invalidate(); - } - } - else - { - DoResize(); - Invalidate(); - } - } - else - { - SetScrollbar(); - } -} - -void SwSidebarWin::SetColor(Color aColorDark,Color aColorLight, Color aColorAnchor) -{ - mColorDark = aColorDark; - mColorLight = aColorLight; - mColorAnchor = aColorAnchor; - - if ( !Application::GetSettings().GetStyleSettings().GetHighContrastMode() ) - { - { - mpMetadataAuthor->SetControlBackground(mColorDark); - AllSettings aSettings = mpMetadataAuthor->GetSettings(); - StyleSettings aStyleSettings = aSettings.GetStyleSettings(); - aStyleSettings.SetFieldTextColor(aColorAnchor); - aSettings.SetStyleSettings(aStyleSettings); - mpMetadataAuthor->SetSettings(aSettings); - } - - { - mpMetadataDate->SetControlBackground(mColorDark); - AllSettings aSettings = mpMetadataDate->GetSettings(); - StyleSettings aStyleSettings = aSettings.GetStyleSettings(); - aStyleSettings.SetFieldTextColor(aColorAnchor); - aSettings.SetStyleSettings(aStyleSettings); - mpMetadataDate->SetSettings(aSettings); - } - - AllSettings aSettings2 = mpVScrollbar->GetSettings(); - StyleSettings aStyleSettings2 = aSettings2.GetStyleSettings(); - aStyleSettings2.SetButtonTextColor(Color(0,0,0)); - aStyleSettings2.SetCheckedColor(mColorLight); // background - aStyleSettings2.SetShadowColor(mColorAnchor); - aStyleSettings2.SetFaceColor(mColorDark); - aSettings2.SetStyleSettings(aStyleSettings2); - mpVScrollbar->SetSettings(aSettings2); - } -} - -void SwSidebarWin::SetSidebarPosition(sw::sidebarwindows::SidebarPosition eSidebarPosition) -{ - meSidebarPosition = eSidebarPosition; -} - -void SwSidebarWin::SetReadonly(bool bSet) -{ - mbReadonly = bSet; - GetOutlinerView()->SetReadOnly(bSet); -} - -void SwSidebarWin::SetLanguage(const SvxLanguageItem& rNewItem) -{ - Link aLink = Engine()->GetModifyHdl(); - Engine()->SetModifyHdl( Link() ); - ESelection aOld = GetOutlinerView()->GetSelection(); - - ESelection aNewSelection( 0, 0, Engine()->GetParagraphCount()-1, EE_TEXTPOS_ALL ); - GetOutlinerView()->SetSelection( aNewSelection ); - SfxItemSet aEditAttr(GetOutlinerView()->GetAttribs()); - aEditAttr.Put(rNewItem); - GetOutlinerView()->SetAttribs( aEditAttr ); - - GetOutlinerView()->SetSelection(aOld); - Engine()->SetModifyHdl( aLink ); - - const SwViewOption* pVOpt = mrView.GetWrtShellPtr()->GetViewOptions(); - EEControlBits nCntrl = Engine()->GetControlWord(); - // turn off - nCntrl &= ~EEControlBits::ONLINESPELLING; - Engine()->SetControlWord(nCntrl); - - //turn back on - if (pVOpt->IsOnlineSpell()) - nCntrl |= EEControlBits::ONLINESPELLING; - else - nCntrl &= ~EEControlBits::ONLINESPELLING; - Engine()->SetControlWord(nCntrl); - - Engine()->CompleteOnlineSpelling(); - Invalidate(); -} - -void SwSidebarWin::GetFocus() -{ - if (mpSidebarTextControl) - mpSidebarTextControl->GrabFocus(); -} - -void SwSidebarWin::LoseFocus() -{ -} - -void SwSidebarWin::ShowNote() -{ - SetPosAndSize(); - if (!IsVisible()) - Window::Show(); - if (mpShadow && !mpShadow->isVisible()) - mpShadow->setVisible(true); - if (mpAnchor && !mpAnchor->isVisible()) - mpAnchor->setVisible(true); - - // Invalidate. - InvalidateControl(); -} - -void SwSidebarWin::HideNote() -{ - if (IsVisible()) - Window::Hide(); - if (mpAnchor) - { - if (mrMgr.IsShowAnchor()) - mpAnchor->SetAnchorState(AnchorState::Tri); - else - mpAnchor->setVisible(false); - } - if (mpShadow && mpShadow->isVisible()) - mpShadow->setVisible(false); -} - -void SwSidebarWin::InvalidateControl() -{ - // Invalidate. - mpSidebarTextControl->Push(PushFlags::MAPMODE); - lcl_translateTwips(EditWin(), *mpSidebarTextControl, nullptr); - mpSidebarTextControl->Invalidate(); - mpSidebarTextControl->Pop(); -} - -void SwSidebarWin::ActivatePostIt() -{ - mrMgr.AssureStdModeAtShell(); - - mpOutliner->ClearModifyFlag(); - mpOutliner->GetUndoManager().Clear(); - - CheckMetaText(); - SetViewState(ViewState::EDIT); - GetOutlinerView()->ShowCursor(); - - mpOutlinerView->GetEditView().SetInsertMode(mrView.GetWrtShellPtr()->IsInsMode()); - - if ( !Application::GetSettings().GetStyleSettings().GetHighContrastMode() ) - GetOutlinerView()->SetBackgroundColor(mColorDark); -} - -void SwSidebarWin::DeactivatePostIt() -{ - // remove selection, #i87073# - if (GetOutlinerView()->GetEditView().HasSelection()) - { - ESelection aSelection = GetOutlinerView()->GetEditView().GetSelection(); - aSelection.nEndPara = aSelection.nStartPara; - aSelection.nEndPos = aSelection.nStartPos; - GetOutlinerView()->GetEditView().SetSelection(aSelection); - } - - mpOutliner->CompleteOnlineSpelling(); - - SetViewState(ViewState::NORMAL); - // Make sure this view doesn't emit LOK callbacks during the update, as the - // sidebar window's SidebarTextControl doesn't have a valid twip offset - // (map mode origin) during that operation. - bool bTiledPainting = comphelper::LibreOfficeKit::isTiledPainting(); - comphelper::LibreOfficeKit::setTiledPainting(true); - // write the visible text back into the SwField - UpdateData(); - comphelper::LibreOfficeKit::setTiledPainting(bTiledPainting); - - if ( !Application::GetSettings().GetStyleSettings().GetHighContrastMode() ) - GetOutlinerView()->SetBackgroundColor(COL_TRANSPARENT); - - if ( !IsProtected() && Engine()->GetEditEngine().GetText().isEmpty() ) - { - mnEventId = Application::PostUserEvent( LINK( this, SwSidebarWin, DeleteHdl), nullptr, true ); - } -} - -void SwSidebarWin::ToggleInsMode() -{ - if (!mrView.GetWrtShell().IsRedlineOn()) - { - //change outliner - mpOutlinerView->GetEditView().SetInsertMode(!mpOutlinerView->GetEditView().IsInsertMode()); - //change document - mrView.GetWrtShell().ToggleInsMode(); - //update statusbar - SfxBindings &rBnd = mrView.GetViewFrame()->GetBindings(); - rBnd.Invalidate(SID_ATTR_INSERT); - rBnd.Update(SID_ATTR_INSERT); - } -} - -void SwSidebarWin::ExecuteCommand(sal_uInt16 nSlot) -{ - mrMgr.AssureStdModeAtShell(); - - switch (nSlot) - { - case FN_POSTIT: - case FN_REPLY: - { - // if this note is empty, it will be deleted once losing the focus, so no reply, but only a new note - // will be created - if (!Engine()->GetEditEngine().GetText().isEmpty()) - { - OutlinerParaObject* pPara = new OutlinerParaObject(*GetOutlinerView()->GetEditView().CreateTextObject()); - mrMgr.RegisterAnswer(pPara); - } - if (mrMgr.HasActiveSidebarWin()) - mrMgr.SetActiveSidebarWin(nullptr); - SwitchToFieldPos(); - mrView.GetViewFrame()->GetDispatcher()->Execute(FN_POSTIT); - break; - } - case FN_DELETE_COMMENT: - - //Delete(); // do not kill the parent of our open popup menu - mnEventId = Application::PostUserEvent( LINK( this, SwSidebarWin, DeleteHdl), nullptr, true ); - break; - case FN_FORMAT_ALL_NOTES: - case FN_DELETE_ALL_NOTES: - case FN_HIDE_ALL_NOTES: - // not possible as slot as this would require that "this" is the active postit - mrView.GetViewFrame()->GetBindings().Execute( nSlot, nullptr, SfxCallMode::ASYNCHRON ); - break; - case FN_DELETE_NOTE_AUTHOR: - case FN_HIDE_NOTE_AUTHOR: - { - // not possible as slot as this would require that "this" is the active postit - SfxStringItem aItem( nSlot, GetAuthor() ); - const SfxPoolItem* aItems[2]; - aItems[0] = &aItem; - aItems[1] = nullptr; - mrView.GetViewFrame()->GetBindings().Execute( nSlot, aItems, SfxCallMode::ASYNCHRON ); - } - break; - default: - mrView.GetViewFrame()->GetBindings().Execute( nSlot ); - break; - } -} - -SwEditWin& SwSidebarWin::EditWin() -{ - return mrView.GetEditWin(); -} - -long SwSidebarWin::GetPostItTextHeight() -{ - return mpOutliner ? LogicToPixel(mpOutliner->CalcTextSize()).Height() : 0; -} - -void SwSidebarWin::SwitchToPostIt(sal_uInt16 aDirection) -{ - SwSidebarWin* pPostIt = mrMgr.GetNextPostIt(aDirection, this); - if (pPostIt) - pPostIt->GrabFocus(); -} - -IMPL_LINK( SwSidebarWin, WindowEventListener, VclWindowEvent&, rEvent, void ) -{ - if ( rEvent.GetId() == VclEventId::WindowMouseMove ) - { - MouseEvent* pMouseEvt = static_cast(rEvent.GetData()); - if ( pMouseEvt->IsEnterWindow() ) - { - mbMouseOver = true; - if ( !HasFocus() ) - { - SetViewState(ViewState::VIEW); - Invalidate(); - } - } - else if ( pMouseEvt->IsLeaveWindow()) - { - mbMouseOver = false; - if ( !HasFocus() ) - { - SetViewState(ViewState::NORMAL); - Invalidate(); - } - } - } - else if ( rEvent.GetId() == VclEventId::WindowActivate && - rEvent.GetWindow() == mpSidebarTextControl ) - { - const bool bLockView = mrView.GetWrtShell().IsViewLocked(); - mrView.GetWrtShell().LockView( true ); - mrMgr.SetActiveSidebarWin( this ); - mrView.GetWrtShell().LockView( bLockView ); - mrMgr.MakeVisible( this ); - } -} - -void SwSidebarWin::Delete() -{ - if ( mrMgr.GetActiveSidebarWin() == this) - { - mrMgr.SetActiveSidebarWin(nullptr); - // if the note is empty, the previous line will send a delete event, but we are already there - if (mnEventId) - { - Application::RemoveUserEvent( mnEventId ); - mnEventId = nullptr; - } - } -} - -IMPL_LINK(SwSidebarWin, ScrollHdl, ScrollBar*, pScroll, void) -{ - long nDiff = GetOutlinerView()->GetEditView().GetVisArea().Top() - pScroll->GetThumbPos(); - GetOutlinerView()->Scroll( 0, nDiff ); -} - -IMPL_LINK_NOARG(SwSidebarWin, ModifyHdl, LinkParamNone*, void) -{ - mrView.GetDocShell()->SetModified(); -} - -IMPL_LINK_NOARG(SwSidebarWin, DeleteHdl, void*, void) -{ - mnEventId = nullptr; - Delete(); -} - -void SwSidebarWin::ResetAttributes() -{ - mpOutlinerView->RemoveAttribsKeepLanguages(true); - mpOutliner->RemoveFields(); - mpOutlinerView->SetAttribs(DefaultItem()); -} - -sal_Int32 SwSidebarWin::GetScrollbarWidth() -{ - return mrView.GetWrtShell().GetViewOptions()->GetZoom() / 10; -} - -sal_Int32 SwSidebarWin::GetMetaButtonAreaWidth() -{ - const Fraction& f( GetMapMode().GetScaleX() ); - return METABUTTON_AREA_WIDTH * f.GetNumerator() / f.GetDenominator(); -} - -sal_Int32 SwSidebarWin::GetMetaHeight() -{ - const Fraction& f(mrView.GetWrtShellPtr()->GetOut()->GetMapMode().GetScaleY()); - return POSTIT_META_HEIGHT * f.GetNumerator() / f.GetDenominator(); -} - -sal_Int32 SwSidebarWin::GetMinimumSizeWithMeta() -{ - return mrMgr.GetMinimumSizeWithMeta(); -} - -sal_Int32 SwSidebarWin::GetMinimumSizeWithoutMeta() -{ - const Fraction& f(mrView.GetWrtShellPtr()->GetOut()->GetMapMode().GetScaleY()); - return POSTIT_MINIMUMSIZE_WITHOUT_META * f.GetNumerator() / f.GetDenominator(); -} - -void SwSidebarWin::SetSpellChecking() -{ - const SwViewOption* pVOpt = mrView.GetWrtShellPtr()->GetViewOptions(); - EEControlBits nCntrl = mpOutliner->GetControlWord(); - if (pVOpt->IsOnlineSpell()) - nCntrl |= EEControlBits::ONLINESPELLING; - else - nCntrl &= ~EEControlBits::ONLINESPELLING; - mpOutliner->SetControlWord(nCntrl); - - mpOutliner->CompleteOnlineSpelling(); - Invalidate(); -} - -void SwSidebarWin::SetViewState(ViewState bViewState) -{ - switch (bViewState) - { - case ViewState::EDIT: - { - if (mpAnchor) - { - mpAnchor->SetAnchorState(AnchorState::All); - SwSidebarWin* pWin = GetTopReplyNote(); - // #i111964# - if ( pWin && pWin->Anchor() ) - { - pWin->Anchor()->SetAnchorState(AnchorState::End); - } - mpAnchor->setLineSolid(true); - if ( mpTextRangeOverlay != nullptr ) - { - mpTextRangeOverlay->ShowSolidBorder(); - } - } - if (mpShadow) - mpShadow->SetShadowState(SS_EDIT); - break; - } - case ViewState::VIEW: - { - if (mpAnchor) - { - mpAnchor->setLineSolid(true); - if ( mpTextRangeOverlay != nullptr ) - { - mpTextRangeOverlay->ShowSolidBorder(); - } - } - if (mpShadow) - mpShadow->SetShadowState(SS_VIEW); - break; - } - case ViewState::NORMAL: - { - if (mpAnchor) - { - if (IsFollow()) - { - // if there is no visible parent note, we want to see the complete anchor ?? - //if (IsAnyStackParentVisible()) - mpAnchor->SetAnchorState(AnchorState::End); - SwSidebarWin* pTopWinSelf = GetTopReplyNote(); - SwSidebarWin* pTopWinActive = mrMgr.HasActiveSidebarWin() - ? mrMgr.GetActiveSidebarWin()->GetTopReplyNote() - : nullptr; - // #i111964# - if ( pTopWinSelf && ( pTopWinSelf != pTopWinActive ) && - pTopWinSelf->Anchor() ) - { - if ( pTopWinSelf != mrMgr.GetActiveSidebarWin() ) - { - pTopWinSelf->Anchor()->setLineSolid(false); - if ( pTopWinSelf->TextRange() != nullptr ) - { - pTopWinSelf->TextRange()->HideSolidBorder(); - } - } - pTopWinSelf->Anchor()->SetAnchorState(AnchorState::All); - } - } - mpAnchor->setLineSolid(false); - if ( mpTextRangeOverlay != nullptr ) - { - mpTextRangeOverlay->HideSolidBorder(); - } - } - if ( mpShadow ) - { - mpShadow->SetShadowState(SS_NORMAL); - } - break; - } - } -} - -SwSidebarWin* SwSidebarWin::GetTopReplyNote() -{ - SwSidebarWin* pTopNote = nullptr; - SwSidebarWin* pSidebarWin = IsFollow() ? mrMgr.GetNextPostIt(KEY_PAGEUP, this) : nullptr; - while (pSidebarWin) - { - pTopNote = pSidebarWin; - pSidebarWin = pSidebarWin->IsFollow() ? mrMgr.GetNextPostIt(KEY_PAGEUP, pSidebarWin) : nullptr; - } - return pTopNote; -} - -void SwSidebarWin::SwitchToFieldPos() -{ - if ( mrMgr.GetActiveSidebarWin() == this ) - mrMgr.SetActiveSidebarWin(nullptr); - GotoPos(); - sal_uInt32 aCount = MoveCaret(); - if (aCount) - mrView.GetDocShell()->GetWrtShell()->SwCursorShell::Right(aCount, 0); - GrabFocusToDocument(); -} - -SvxLanguageItem SwSidebarWin::GetLanguage() -{ - return SvxLanguageItem(SwLangHelper::GetLanguage(mrView.GetWrtShell(),RES_CHRATR_LANGUAGE),RES_CHRATR_LANGUAGE); -} - -void SwSidebarWin::SetChangeTracking( const SwPostItHelper::SwLayoutStatus aLayoutStatus, - const Color& aChangeColor ) -{ - if ( (mLayoutStatus != aLayoutStatus) || - (mChangeColor != aChangeColor) ) - { - mLayoutStatus = aLayoutStatus; - mChangeColor = aChangeColor; - Invalidate(); - } -} - -bool SwSidebarWin::HasScrollbar() const -{ - return mpVScrollbar != nullptr; -} - -bool SwSidebarWin::IsScrollbarVisible() const -{ - return HasScrollbar() && mpVScrollbar->IsVisible(); -} - -void SwSidebarWin::ChangeSidebarItem( SwSidebarItem& rSidebarItem ) -{ - const bool bAnchorChanged = mpAnchorFrame != rSidebarItem.maLayoutInfo.mpAnchorFrame; - if ( bAnchorChanged ) - { - mrMgr.DisconnectSidebarWinFromFrame( *(mpAnchorFrame), *this ); - } - - mrSidebarItem = rSidebarItem; - mpAnchorFrame = mrSidebarItem.maLayoutInfo.mpAnchorFrame; - - if ( GetWindowPeer() ) - { - SidebarWinAccessible* pAcc = - static_cast( GetWindowPeer() ); - OSL_ENSURE( dynamic_cast( GetWindowPeer() ), - " - unexpected type of window peer -> crash possible!" ); - pAcc->ChangeSidebarItem( mrSidebarItem ); - } - - if ( bAnchorChanged ) - { - mrMgr.ConnectSidebarWinToFrame( *(mrSidebarItem.maLayoutInfo.mpAnchorFrame), - mrSidebarItem.GetFormatField(), - *this ); - } -} - -css::uno::Reference< css::accessibility::XAccessible > SwSidebarWin::CreateAccessible() -{ - SidebarWinAccessible* pAcc( new SidebarWinAccessible( *this, - mrView.GetWrtShell(), - mrSidebarItem ) ); - css::uno::Reference< css::awt::XWindowPeer > xWinPeer( pAcc ); - SetWindowPeer( xWinPeer, pAcc ); - - css::uno::Reference< css::accessibility::XAccessible > xAcc( xWinPeer, css::uno::UNO_QUERY ); - return xAcc; -} - -} } // eof of namespace sw::sidebarwindows - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/docvw/SidebarWinAcc.cxx b/sw/source/uibase/docvw/SidebarWinAcc.cxx index 1edda6d00bb2..ea1cb8de7b49 100644 --- a/sw/source/uibase/docvw/SidebarWinAcc.cxx +++ b/sw/source/uibase/docvw/SidebarWinAcc.cxx @@ -18,8 +18,8 @@ */ #include +#include -#include #include #include #include @@ -32,7 +32,7 @@ namespace sw { namespace sidebarwindows { class SidebarWinAccessibleContext : public VCLXAccessibleComponent { public: - explicit SidebarWinAccessibleContext( SwSidebarWin& rSidebarWin, + explicit SidebarWinAccessibleContext( sw::annotation::SwAnnotationWin& rSidebarWin, SwViewShell& rViewShell, const SwFrame* pAnchorFrame ) : VCLXAccessibleComponent( rSidebarWin.GetWindowPeer() ) @@ -89,8 +89,8 @@ class SidebarWinAccessibleContext : public VCLXAccessibleComponent ::osl::Mutex maMutex; }; -// implementation of accessible for instance -SidebarWinAccessible::SidebarWinAccessible( SwSidebarWin& rSidebarWin, +// implementation of accessible for instance +SidebarWinAccessible::SidebarWinAccessible( sw::annotation::SwAnnotationWin& rSidebarWin, SwViewShell& rViewShell, const SwSidebarItem& rSidebarItem ) : VCLXWindow() diff --git a/sw/source/uibase/docvw/SidebarWinAcc.hxx b/sw/source/uibase/docvw/SidebarWinAcc.hxx index 869d06be4426..4d3880aa1374 100644 --- a/sw/source/uibase/docvw/SidebarWinAcc.hxx +++ b/sw/source/uibase/docvw/SidebarWinAcc.hxx @@ -25,15 +25,16 @@ class SwViewShell; class SwSidebarItem; class SwFrame; +namespace sw { namespace annotation { + class SwAnnotationWin; +} } namespace sw { namespace sidebarwindows { -class SwSidebarWin; - class SidebarWinAccessible : public VCLXWindow { public: - explicit SidebarWinAccessible( SwSidebarWin& rSidebarWin, + explicit SidebarWinAccessible( sw::annotation::SwAnnotationWin& rSidebarWin, SwViewShell& rViewShell, const SwSidebarItem& rSidebarItem ); virtual ~SidebarWinAccessible() override; @@ -44,7 +45,7 @@ class SidebarWinAccessible : public VCLXWindow void ChangeSidebarItem( const SwSidebarItem& rSidebarItem ); private: - SwSidebarWin& mrSidebarWin; + sw::annotation::SwAnnotationWin& mrSidebarWin; SwViewShell& mrViewShell; const SwFrame* mpAnchorFrame; bool bAccContextCreated; diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx index b50bdd97b72e..ffede7f6c1a8 100644 --- a/sw/source/uibase/docvw/edtwin.cxx +++ b/sw/source/uibase/docvw/edtwin.cxx @@ -147,8 +147,8 @@ #include #include -#include #include +#include #include #include @@ -6408,7 +6408,7 @@ void SwEditWin::SetCursorTwipPosition(const Point& rPosition, bool bPoint, bool if (m_rView.GetPostItMgr()) { - if (sw::sidebarwindows::SwSidebarWin* pWin = m_rView.GetPostItMgr()->GetActiveSidebarWin()) + if (sw::annotation::SwAnnotationWin* pWin = m_rView.GetPostItMgr()->GetActiveSidebarWin()) { // Editing postit text. pWin->SetCursorLogicPosition(rPosition, bPoint, bClearMark); diff --git a/sw/source/uibase/docvw/frmsidebarwincontainer.cxx b/sw/source/uibase/docvw/frmsidebarwincontainer.cxx index 76e58c39609f..dc03b70ae055 100644 --- a/sw/source/uibase/docvw/frmsidebarwincontainer.cxx +++ b/sw/source/uibase/docvw/frmsidebarwincontainer.cxx @@ -22,7 +22,7 @@ #include #include #include -#include +#include namespace { struct SidebarWinKey @@ -39,7 +39,7 @@ namespace { } }; - typedef std::map < SidebarWinKey, VclPtr > SidebarWinContainer; + typedef std::map < SidebarWinKey, VclPtr > SidebarWinContainer; struct FrameKey { @@ -76,7 +76,7 @@ SwFrameSidebarWinContainer::~SwFrameSidebarWinContainer() bool SwFrameSidebarWinContainer::insert( const SwFrame& rFrame, const SwFormatField& rFormatField, - SwSidebarWin& rSidebarWin ) + sw::annotation::SwAnnotationWin& rSidebarWin ) { bool bInserted( false ); @@ -95,7 +95,7 @@ bool SwFrameSidebarWinContainer::insert( const SwFrame& rFrame, } bool SwFrameSidebarWinContainer::remove( const SwFrame& rFrame, - const SwSidebarWin& rSidebarWin ) + const sw::annotation::SwAnnotationWin & rSidebarWin ) { bool bRemoved( false ); @@ -134,10 +134,10 @@ bool SwFrameSidebarWinContainer::empty( const SwFrame& rFrame ) return bEmpty; } -SwSidebarWin* SwFrameSidebarWinContainer::get( const SwFrame& rFrame, +sw::annotation::SwAnnotationWin* SwFrameSidebarWinContainer::get( const SwFrame& rFrame, const sal_Int32 nIndex ) { - SwSidebarWin* pRet( nullptr ); + sw::annotation::SwAnnotationWin* pRet( nullptr ); FrameKey aFrameKey( &rFrame ); FrameSidebarWinContainer::iterator aFrameIter = mpFrameSidebarWinContainer->find( aFrameKey ); diff --git a/sw/source/uibase/docvw/frmsidebarwincontainer.hxx b/sw/source/uibase/docvw/frmsidebarwincontainer.hxx index 77594c969985..bfac1090cb12 100644 --- a/sw/source/uibase/docvw/frmsidebarwincontainer.hxx +++ b/sw/source/uibase/docvw/frmsidebarwincontainer.hxx @@ -25,10 +25,12 @@ class SwFrame; class SwFormatField; namespace vcl { class Window; } +namespace sw { namespace annotation { + class SwAnnotationWin; +} } namespace sw { namespace sidebarwindows { -class SwSidebarWin; class FrameSidebarWinContainer; class SwFrameSidebarWinContainer @@ -39,14 +41,14 @@ class SwFrameSidebarWinContainer bool insert( const SwFrame& rFrame, const SwFormatField& rFormatField, - SwSidebarWin& rSidebarWin ); + sw::annotation::SwAnnotationWin& rSidebarWin ); bool remove( const SwFrame& rFrame, - const SwSidebarWin& rSidebarWin ); + const sw::annotation::SwAnnotationWin& rSidebarWin ); bool empty( const SwFrame& rFrame ); - SwSidebarWin* get( const SwFrame& rFrame, + sw::annotation::SwAnnotationWin* get( const SwFrame& rFrame, const sal_Int32 nIndex ); void getAll( const SwFrame& rFrame, diff --git a/sw/source/uibase/shells/annotsh.cxx b/sw/source/uibase/shells/annotsh.cxx index 93a10ee30cac..b58ef60fea11 100644 --- a/sw/source/uibase/shells/annotsh.cxx +++ b/sw/source/uibase/shells/annotsh.cxx @@ -94,7 +94,7 @@ #include "annotsh.hxx" #include "view.hxx" #include -#include +#include #include "swtypes.hxx" diff --git a/sw/source/uibase/shells/textfld.cxx b/sw/source/uibase/shells/textfld.cxx index 8b769879ee07..9fcea1ed4e33 100644 --- a/sw/source/uibase/shells/textfld.cxx +++ b/sw/source/uibase/shells/textfld.cxx @@ -21,7 +21,6 @@ #include #include #include -#include #include #include #include diff --git a/sw/source/uibase/uiview/viewmdi.cxx b/sw/source/uibase/uiview/viewmdi.cxx index d2fe2fdc0f29..e8dd1a8ce4ea 100644 --- a/sw/source/uibase/uiview/viewmdi.cxx +++ b/sw/source/uibase/uiview/viewmdi.cxx @@ -417,7 +417,7 @@ IMPL_LINK( SwView, MoveNavigationHdl, void*, p, void ) case NID_POSTIT: { rSh.EnterStdMode(); - sw::sidebarwindows::SwSidebarWin* pPostIt = GetPostItMgr()->GetActiveSidebarWin(); + sw::annotation::SwAnnotationWin* pPostIt = GetPostItMgr()->GetActiveSidebarWin(); if (pPostIt) GetPostItMgr()->SetActiveSidebarWin(nullptr); SwFieldType* pFieldType = rSh.GetFieldType(0, SwFieldIds::Postit); diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx index 07530d82e1bc..33eef3dc62bb 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -148,7 +148,6 @@ #include #include #include -#include #include #include @@ -3238,7 +3237,7 @@ OUString SwXTextDocument::getPostIts() for (std::list::const_iterator i = pDocShell->GetView()->GetPostItMgr()->begin(); i != pDocShell->GetView()->GetPostItMgr()->end(); ++i ) { - sw::annotation::SwAnnotationWin* pWin = static_cast((*i)->pPostIt.get()); + sw::annotation::SwAnnotationWin* pWin = (*i)->pPostIt.get(); const SwPostItField* pField = pWin->GetPostItField(); const SwRect& aRect = pWin->GetAnchorRect(); @@ -3457,7 +3456,7 @@ OString SwXTextDocument::getTextSelection(const char* pMimeType, OString& rUsedM if (SwPostItMgr* pPostItMgr = pDocShell->GetView()->GetPostItMgr()) { - if (sw::sidebarwindows::SwSidebarWin* pWin = pPostItMgr->GetActiveSidebarWin()) + if (sw::annotation::SwAnnotationWin* pWin = pPostItMgr->GetActiveSidebarWin()) { // Editing postit text. EditView& rEditView = pWin->GetOutlinerView()->GetEditView(); diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx index cf178dbf3895..293d0b493687 100644 --- a/sw/source/uibase/utlui/content.cxx +++ b/sw/source/uibase/utlui/content.cxx @@ -91,7 +91,7 @@ #include #include "navmgr.hxx" -#include "SidebarWin.hxx" +#include "AnnotationWin.hxx" #include #define CTYPE_CNT 0 -- cgit