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