/src/libreoffice/sw/inc/AnnotationWin.hxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
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/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
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 . |
18 | | */ |
19 | | |
20 | | #pragma once |
21 | | |
22 | | #include <basegfx/range/b2drange.hxx> |
23 | | #include <editeng/outlobj.hxx> |
24 | | #include <tools/date.hxx> |
25 | | #include <tools/time.hxx> |
26 | | #include <vcl/InterimItemWindow.hxx> |
27 | | #include <vcl/weld/Label.hxx> |
28 | | #include <vcl/weld/MenuButton.hxx> |
29 | | #include <vcl/weld/ScrolledWindow.hxx> |
30 | | #include <vcl/weld/customweld.hxx> |
31 | | |
32 | | #include "postithelper.hxx" |
33 | | #include "swrect.hxx" |
34 | | #include "SidebarWindowsTypes.hxx" |
35 | | |
36 | | class OutlinerParaObject; |
37 | | class SwPostItMgr; |
38 | | class SwPostItField; |
39 | | class OutlinerView; |
40 | | class Outliner; |
41 | | class SwEditWin; |
42 | | class SwView; |
43 | | class SwFrame; |
44 | | namespace sw::overlay { class OverlayRanges; } |
45 | | namespace sw::sidebarwindows { |
46 | | class SidebarTextControl; |
47 | | class AnchorOverlayObject; |
48 | | class ShadowOverlayObject; |
49 | | class SidebarWinAccessible; |
50 | | } |
51 | | |
52 | | |
53 | | namespace sw::annotation { |
54 | | |
55 | | class SAL_DLLPUBLIC_RTTI SwAnnotationWin final : public InterimItemWindow |
56 | | { |
57 | | public: |
58 | | SwAnnotationWin( SwEditWin& rEditWin, |
59 | | SwPostItMgr& aMgr, |
60 | | SwAnnotationItem& rSidebarItem, |
61 | | SwFormatField* aField ); |
62 | | virtual ~SwAnnotationWin() override; |
63 | | virtual void dispose() override; |
64 | | |
65 | | void UpdateData(); |
66 | | void SetPostItText(); |
67 | | void Delete(); |
68 | | void GotoPos(); |
69 | 0 | const SwPostItField* GetPostItField() const { return mpField; } |
70 | 0 | SwFormatField* GetFormatField() const { return mpFormatField; } |
71 | | void UpdateText(const OUString& rText); |
72 | | void UpdateHTML(const OUString& rHtml); |
73 | | |
74 | | OUString GetAuthor() const; |
75 | | Date GetDate() const; |
76 | | tools::Time GetTime() const; |
77 | | OString GetSimpleHtml() const; |
78 | | void GeneratePostItName(); |
79 | | |
80 | | sal_uInt32 MoveCaret(); |
81 | | |
82 | | void InitAnswer(OutlinerParaObject const & rText); |
83 | | |
84 | | bool IsReadOnlyOrProtected() const; |
85 | | |
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 tools::Long PageBorder); |
92 | | void SetAnchorRect(const SwRect& aAnchorRect); |
93 | | void SetPosAndSize(); |
94 | | void TranslateTopPosition(const tools::Long aAmount); |
95 | | void CheckMetaText(); |
96 | | void UpdateColors(); |
97 | | |
98 | 0 | Point const & GetAnchorPos() { return mAnchorRect.Pos(); } |
99 | 0 | const SwRect& GetAnchorRect() const { return mAnchorRect; } |
100 | 0 | bool IsAnchorRectChanged() const { return mbAnchorRectChanged; } |
101 | 0 | void ResetAnchorRectChanged() { mbAnchorRectChanged = false; } |
102 | 0 | const std::vector<basegfx::B2DRange>& GetAnnotationTextRanges() const { return maAnnotationTextRanges; } |
103 | | SwEditWin& EditWin(); |
104 | 0 | SwAnnotationItem& GetSidebarItem() { return *mpSidebarItem; } |
105 | | |
106 | 0 | OutlinerView* GetOutlinerView() { return mpOutlinerView.get();} |
107 | 0 | const OutlinerView* GetOutlinerView() const { return mpOutlinerView.get();} |
108 | 0 | Outliner* GetOutliner() { return mpOutliner.get();} |
109 | | bool HasScrollbar() const; |
110 | | bool IsScrollbarVisible() const; |
111 | 0 | ::sw::sidebarwindows::AnchorOverlayObject* Anchor() { return mpAnchor.get();} |
112 | 0 | ::sw::sidebarwindows::ShadowOverlayObject* Shadow() { return mpShadow.get();} |
113 | 0 | ::sw::overlay::OverlayRanges* TextRange() { return mpTextRangeOverlay.get();} |
114 | | |
115 | | tools::Long GetPostItTextHeight(); |
116 | | tools::Long GuessTextHeightForWidth(tools::Long nWidth) const; |
117 | | |
118 | | void SwitchToPostIt(sal_uInt16 aDirection); |
119 | | void SwitchToFieldPos(); |
120 | | |
121 | | void ExecuteCommand(sal_uInt16 nSlot); |
122 | | void InitControls(); |
123 | | void DoResize(); |
124 | | void ResizeIfNecessary(tools::Long aOldHeight, tools::Long aNewHeight); |
125 | | void SetScrollbar(); |
126 | | void LockView(bool bLock); |
127 | | |
128 | | void SetVirtualPosSize( const Point& aPoint, const Size& aSize); |
129 | 0 | Point VirtualPos() { return mPosSize.TopLeft(); } |
130 | 0 | Size VirtualSize() { return mPosSize.GetSize(); } |
131 | | |
132 | | void ShowAnchorOnly(const Point &aPoint); |
133 | | void ShowNote(); |
134 | | void HideNote(); |
135 | | |
136 | | void ResetAttributes(); |
137 | | |
138 | | void SetSidebarPosition(sw::sidebarwindows::SidebarPosition eSidebarPosition); |
139 | | void SetReadonly(bool bSet); |
140 | | bool IsReadOnly() const; |
141 | | |
142 | | void SetColor(Color aColorDark,Color aColorLight, Color aColorAnchor); |
143 | 0 | const Color& ColorDark() { return mColorDark; } |
144 | 0 | const Color& ColorLight() { return mColorLight; } |
145 | | void Rescale(); |
146 | | |
147 | | void SetViewState(::sw::sidebarwindows::ViewState bViewState); |
148 | | |
149 | 0 | bool IsFollow() const { return mbIsFollow; } |
150 | 0 | void SetFollow( bool bIsFollow) { mbIsFollow = bIsFollow; }; |
151 | | |
152 | | sal_Int32 GetMetaHeight() const; |
153 | | sal_Int32 GetMinimumSizeWithMeta() const; |
154 | | sal_Int32 GetMinimumSizeWithoutMeta() const; |
155 | | int GetPrefScrollbarWidth() const; |
156 | | sal_Int32 GetNumFields() const; |
157 | | |
158 | | void SetSpellChecking(); |
159 | | |
160 | | void ToggleInsMode(); |
161 | | |
162 | | void ActivatePostIt(); |
163 | | void DeactivatePostIt(); |
164 | | |
165 | | void SetChangeTracking( const SwPostItHelper::SwLayoutStatus aStatus, |
166 | | const Color& aColor); |
167 | 0 | SwPostItHelper::SwLayoutStatus GetLayoutStatus() const { return mLayoutStatus; } |
168 | 0 | const Color& GetChangeColor() const { return mChangeColor; } |
169 | | |
170 | 0 | bool IsMouseOverSidebarWin() const { return mbMouseOver; } |
171 | | |
172 | | void ChangeSidebarItem( SwAnnotationItem & rSidebarItem ); |
173 | | virtual rtl::Reference<comphelper::OAccessible> CreateAccessible() override; |
174 | | |
175 | | void DrawForPage(OutputDevice* pDev, const Point& rPos); |
176 | | |
177 | | void PaintTile(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect); |
178 | | /// Is there a matching sub-widget inside this sidebar widget for rPointLogic? |
179 | | bool IsHitWindow(const Point& rPointLogic); |
180 | | /// Allows adjusting the point or mark of the selection to a document coordinate. |
181 | | void SetCursorLogicPosition(const Point& rPosition, bool bPoint, bool bClearMark); |
182 | | |
183 | | // Various access functions for 'resolved' status |
184 | | void SetResolved(bool resolved); |
185 | | void ToggleResolved(); |
186 | | void ToggleResolvedForThread(); |
187 | | void DeleteThread(); |
188 | | bool IsResolved() const; |
189 | | bool IsThreadResolved(); |
190 | | |
191 | | // Get annotation paraId or generate one if it doesn't exist |
192 | | sal_uInt32 GetParaId(); |
193 | | // Used to generate a unique paraId |
194 | | static sal_uInt32 CreateUniqueParaId(); |
195 | | |
196 | | // Set this SwAnnotationWin as the currently active one |
197 | | // return false if it was already active |
198 | | bool SetActiveSidebarWin(); |
199 | | // Unset this SwAnnotationWin as the currently active one |
200 | | void UnsetActiveSidebarWin(); |
201 | | |
202 | | /// Find the first annotation for the thread which this annotation is in. |
203 | | /// This may be the same annotation as this one. |
204 | | SwAnnotationWin* GetTopReplyNote(); |
205 | | |
206 | | virtual FactoryFunction GetUITestFactory() const override; |
207 | | |
208 | | bool IsRootNote() const; |
209 | | void SetAsRoot(); |
210 | | |
211 | | private: |
212 | | |
213 | | virtual void LoseFocus() override; |
214 | | virtual void GetFocus() override; |
215 | | virtual void StateChanged(StateChangedType nStateChange) override; |
216 | | |
217 | | virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override; |
218 | | void SetSizePixel( const Size& rNewSize ) override; |
219 | | |
220 | | void UpdateMenu(); |
221 | | |
222 | | DECL_DLLPRIVATE_LINK(ModifyHdl, LinkParamNone*, void); |
223 | | DECL_DLLPRIVATE_LINK(ScrollHdl, weld::ScrolledWindow&, void); |
224 | | DECL_DLLPRIVATE_LINK(DeleteHdl, void*, void); |
225 | | DECL_DLLPRIVATE_LINK(SelectHdl, const OUString&, void); |
226 | | DECL_DLLPRIVATE_LINK(KeyInputHdl, const KeyEvent&, bool); |
227 | | DECL_DLLPRIVATE_LINK(MouseMoveHdl, const MouseEvent&, bool); |
228 | | |
229 | | sal_uInt32 CountFollowing(); |
230 | | |
231 | | void SetMenuButtonColors(); |
232 | | |
233 | | SwPostItMgr& mrMgr; |
234 | | SwView& mrView; |
235 | | |
236 | | ImplSVEvent* mnDeleteEventId; |
237 | | |
238 | | std::unique_ptr<OutlinerView> mpOutlinerView; |
239 | | std::unique_ptr<Outliner> mpOutliner; |
240 | | |
241 | | std::unique_ptr<weld::ScrolledWindow> mxVScrollbar; |
242 | | std::unique_ptr<sw::sidebarwindows::SidebarTextControl> mxSidebarTextControl; |
243 | | std::unique_ptr<weld::CustomWeld> mxSidebarTextControlWin; |
244 | | vcl::Font maLabelFont; |
245 | | std::unique_ptr<weld::Label> mxMetadataAuthor; |
246 | | std::unique_ptr<weld::Label> mxMetadataDate; |
247 | | std::unique_ptr<weld::Label> mxMetadataResolved; |
248 | | std::unique_ptr<weld::MenuButton> mxMenuButton; |
249 | | |
250 | | std::unique_ptr<sw::sidebarwindows::AnchorOverlayObject> mpAnchor; |
251 | | std::unique_ptr<sw::sidebarwindows::ShadowOverlayObject> mpShadow; |
252 | | std::unique_ptr<sw::overlay::OverlayRanges> mpTextRangeOverlay; |
253 | | |
254 | | Color mColorAnchor; |
255 | | Color mColorDark; |
256 | | Color mColorLight; |
257 | | Color mChangeColor; |
258 | | |
259 | | sw::sidebarwindows::SidebarPosition meSidebarPosition; |
260 | | |
261 | | tools::Rectangle mPosSize; |
262 | | SwRect mAnchorRect; |
263 | | tools::Long mPageBorder; |
264 | | bool mbAnchorRectChanged; |
265 | | |
266 | | bool mbResolvedStateUpdated; |
267 | | |
268 | | std::vector<basegfx::B2DRange> maAnnotationTextRanges; |
269 | | |
270 | | bool mbMouseOver; |
271 | | SwPostItHelper::SwLayoutStatus mLayoutStatus; |
272 | | |
273 | | bool mbReadonly; |
274 | | bool mbIsFollow; |
275 | | |
276 | | SwAnnotationItem* mpSidebarItem; |
277 | | const SwFrame* mpAnchorFrame; |
278 | | |
279 | | SwFormatField* mpFormatField; |
280 | | SwPostItField* mpField; |
281 | | |
282 | | rtl::Reference<sw::sidebarwindows::SidebarWinAccessible> mxSidebarWinAccessible; |
283 | | }; |
284 | | |
285 | | } // end of namespace sw::annotation |
286 | | |
287 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |