Bump version to 21.06.18.1
[LibreOffice.git] / sw / inc / AnnotationWin.hxx
bloba04068e758ea56697d7acae9a3f5d8e6a1d245ee
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_SW_INC_ANNOTATIONWIN_HXX
21 #define INCLUDED_SW_INC_ANNOTATIONWIN_HXX
23 #include <basegfx/range/b2drange.hxx>
24 #include <tools/date.hxx>
25 #include <tools/time.hxx>
26 #include <vcl/InterimItemWindow.hxx>
27 #include <vcl/customweld.hxx>
29 #include "postithelper.hxx"
30 #include "swrect.hxx"
31 #include "SidebarWindowsTypes.hxx"
33 class EditView;
34 class PopupMenu;
35 class OutlinerParaObject;
36 class SwPostItMgr;
37 class SwPostItField;
38 class OutlinerView;
39 class Outliner;
40 class ScrollBar;
41 class SwEditWin;
42 class SwView;
43 class FixedText;
44 class MenuButton;
45 class SwFrame;
46 class SvxLanguageItem;
47 namespace sw::overlay { class OverlayRanges; }
48 namespace sw::sidebarwindows {
49 class SidebarTextControl;
50 class AnchorOverlayObject;
51 class ShadowOverlayObject;
55 namespace sw::annotation {
57 class SAL_DLLPUBLIC_RTTI SwAnnotationWin : public InterimItemWindow
59 public:
60 SwAnnotationWin( SwEditWin& rEditWin,
61 SwPostItMgr& aMgr,
62 SwSidebarItem& rSidebarItem,
63 SwFormatField* aField );
64 virtual ~SwAnnotationWin() override;
65 virtual void dispose() override;
67 void UpdateData();
68 void SetPostItText();
69 void Delete();
70 void GotoPos();
71 const SwPostItField* GetPostItField() const { return mpField; }
72 void UpdateText(const OUString& aText);
74 OUString GetAuthor() const;
75 Date GetDate() const;
76 tools::Time GetTime() const;
78 sal_uInt32 MoveCaret();
80 /// Calculate parent postit id of current annotation window
81 sal_uInt32 CalcParent();
82 void InitAnswer(OutlinerParaObject const * pText);
84 bool IsProtected() const;
86 void SetSize( const Size& rNewSize );
87 void SetPosSizePixelRect( tools::Long nX,
88 tools::Long nY,
89 tools::Long nWidth,
90 tools::Long nHeight,
91 const SwRect& aAnchorRect,
92 const tools::Long PageBorder);
93 void SetPosAndSize();
94 void TranslateTopPosition(const tools::Long aAmount);
95 void CheckMetaText();
97 Point const & GetAnchorPos() { return mAnchorRect.Pos(); }
98 const SwRect& GetAnchorRect() const { return mAnchorRect; }
99 bool IsAnchorRectChanged() const { return mbAnchorRectChanged; }
100 void ResetAnchorRectChanged() { mbAnchorRectChanged = false; }
101 const std::vector<basegfx::B2DRange>& GetAnnotationTextRanges() const { return maAnnotationTextRanges; }
102 SwEditWin& EditWin();
103 SwSidebarItem& GetSidebarItem() { return mrSidebarItem; }
105 OutlinerView* GetOutlinerView() { return mpOutlinerView.get();}
106 Outliner* GetOutliner() { return mpOutliner.get();}
107 bool HasScrollbar() const;
108 bool IsScrollbarVisible() const;
109 weld::ScrolledWindow* Scrollbar() { return mxVScrollbar.get(); }
110 ::sw::sidebarwindows::AnchorOverlayObject* Anchor() { return mpAnchor.get();}
111 ::sw::sidebarwindows::ShadowOverlayObject* Shadow() { return mpShadow.get();}
112 ::sw::overlay::OverlayRanges* TextRange() { return mpTextRangeOverlay.get();}
114 tools::Long GetPostItTextHeight();
116 void SwitchToPostIt(sal_uInt16 aDirection);
117 void SwitchToFieldPos();
119 void ExecuteCommand(sal_uInt16 nSlot);
120 void InitControls();
121 void DoResize();
122 void ResizeIfNecessary(tools::Long aOldHeight, tools::Long aNewHeight);
123 void SetScrollbar();
125 void SetVirtualPosSize( const Point& aPoint, const Size& aSize);
126 Point VirtualPos() { return mPosSize.TopLeft(); }
127 Size VirtualSize() { return mPosSize.GetSize(); }
129 void ShowAnchorOnly(const Point &aPoint);
130 void ShowNote();
131 void HideNote();
133 void ResetAttributes();
135 void SetSidebarPosition(sw::sidebarwindows::SidebarPosition eSidebarPosition);
136 void SetReadonly(bool bSet);
137 bool IsReadOnly() const
139 return mbReadonly;
142 void SetColor(Color aColorDark,Color aColorLight, Color aColorAnchor);
143 const Color& ColorAnchor() { return mColorAnchor; }
144 const Color& ColorDark() { return mColorDark; }
145 const Color& ColorLight() { return mColorLight; }
146 void Rescale();
148 void SetViewState(::sw::sidebarwindows::ViewState bViewState);
150 bool IsFollow() const { return mbIsFollow; }
151 void SetFollow( bool bIsFollow) { mbIsFollow = bIsFollow; };
153 sal_Int32 GetMetaHeight() const;
154 sal_Int32 GetMinimumSizeWithMeta() const;
155 sal_Int32 GetMinimumSizeWithoutMeta() const;
156 int GetPrefScrollbarWidth() const;
157 sal_Int32 GetNumFields() const;
159 void SetSpellChecking();
161 void ToggleInsMode();
163 void ActivatePostIt();
164 void DeactivatePostIt();
166 void SetChangeTracking( const SwPostItHelper::SwLayoutStatus aStatus,
167 const Color& aColor);
168 SwPostItHelper::SwLayoutStatus GetLayoutStatus() const { return mLayoutStatus; }
169 const Color& GetChangeColor() const { return mChangeColor; }
171 bool IsMouseOverSidebarWin() const { return mbMouseOver; }
173 void SetLanguage(const SvxLanguageItem& rNewItem);
175 void ChangeSidebarItem( SwSidebarItem const & rSidebarItem );
176 virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override;
178 void DrawForPage(OutputDevice* pDev, const Point& rPos);
180 void PaintTile(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect);
181 /// Is there a matching sub-widget inside this sidebar widget for rPointLogic?
182 bool IsHitWindow(const Point& rPointLogic);
183 /// Allows adjusting the point or mark of the selection to a document coordinate.
184 void SetCursorLogicPosition(const Point& rPosition, bool bPoint, bool bClearMark);
186 // Various access functions for 'resolved' status
187 void SetResolved(bool resolved);
188 void ToggleResolved();
189 void ToggleResolvedForThread();
190 void DeleteThread();
191 bool IsResolved() const;
192 bool IsThreadResolved();
194 // Set this SwAnnotationWin as the currently active one
195 // return false if it was already active
196 bool SetActiveSidebarWin();
197 // Unset this SwAnnotationWin as the currently active one
198 void UnsetActiveSidebarWin();
200 /// Find the first annotation for the thread which this annotation is in.
201 /// This may be the same annotation as this one.
202 SwAnnotationWin* GetTopReplyNote();
204 virtual FactoryFunction GetUITestFactory() const override;
206 private:
208 virtual void LoseFocus() override;
209 virtual void GetFocus() override;
211 void SetSizePixel( const Size& rNewSize ) override;
212 SfxItemSet DefaultItem();
214 DECL_LINK(ModifyHdl, LinkParamNone*, void);
215 DECL_LINK(ScrollHdl, weld::ScrolledWindow&, void);
216 DECL_LINK(DeleteHdl, void*, void);
217 DECL_LINK(ToggleHdl, weld::ToggleButton&, void);
218 DECL_LINK(SelectHdl, const OString&, void);
219 DECL_LINK(KeyInputHdl, const KeyEvent&, bool);
220 DECL_LINK(MouseMoveHdl, const MouseEvent&, bool);
222 sal_uInt32 CountFollowing();
224 SvxLanguageItem GetLanguage() const;
226 void SetMenuButtonColors();
228 SwPostItMgr& mrMgr;
229 SwView& mrView;
231 ImplSVEvent * mnEventId;
233 std::unique_ptr<OutlinerView> mpOutlinerView;
234 std::unique_ptr<Outliner> mpOutliner;
236 std::unique_ptr<weld::ScrolledWindow> mxVScrollbar;
237 std::unique_ptr<sw::sidebarwindows::SidebarTextControl> mxSidebarTextControl;
238 std::unique_ptr<weld::CustomWeld> mxSidebarTextControlWin;
239 vcl::Font maLabelFont;
240 std::unique_ptr<weld::Label> mxMetadataAuthor;
241 std::unique_ptr<weld::Label> mxMetadataDate;
242 std::unique_ptr<weld::Label> mxMetadataResolved;
243 std::unique_ptr<weld::MenuButton> mxMenuButton;
245 std::unique_ptr<sw::sidebarwindows::AnchorOverlayObject> mpAnchor;
246 std::unique_ptr<sw::sidebarwindows::ShadowOverlayObject> mpShadow;
247 std::unique_ptr<sw::overlay::OverlayRanges> mpTextRangeOverlay;
249 Color mColorAnchor;
250 Color mColorDark;
251 Color mColorLight;
252 Color mChangeColor;
254 sw::sidebarwindows::SidebarPosition meSidebarPosition;
256 tools::Rectangle mPosSize;
257 SwRect mAnchorRect;
258 tools::Long mPageBorder;
259 bool mbAnchorRectChanged;
261 bool mbResolvedStateUpdated;
263 std::vector<basegfx::B2DRange> maAnnotationTextRanges;
265 bool mbMouseOver;
266 SwPostItHelper::SwLayoutStatus mLayoutStatus;
268 bool mbReadonly;
269 bool mbIsFollow;
271 SwSidebarItem& mrSidebarItem;
272 const SwFrame* mpAnchorFrame;
274 SwFormatField* mpFormatField;
275 SwPostItField* mpField;
278 } // end of namespace sw::annotation
280 #endif
282 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */