LibreOffice Module sw (master)  1
AnnotationWin.hxx
Go to the documentation of this file.
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 #ifndef INCLUDED_SW_INC_ANNOTATIONWIN_HXX
21 #define INCLUDED_SW_INC_ANNOTATIONWIN_HXX
22 
24 #include <editeng/outlobj.hxx>
25 #include <tools/date.hxx>
26 #include <tools/time.hxx>
28 #include <vcl/customweld.hxx>
29 
30 #include "postithelper.hxx"
31 #include "swrect.hxx"
32 #include "SidebarWindowsTypes.hxx"
33 
34 class EditView;
35 class PopupMenu;
36 class OutlinerParaObject;
37 class SwPostItMgr;
38 class SwPostItField;
39 class OutlinerView;
40 class Outliner;
41 class ScrollBar;
42 class SwEditWin;
43 class SwView;
44 class FixedText;
45 class MenuButton;
46 class SwFrame;
47 class SvxLanguageItem;
48 namespace sw::overlay { class OverlayRanges; }
49 namespace sw::sidebarwindows {
50  class SidebarTextControl;
51  class AnchorOverlayObject;
52  class ShadowOverlayObject;
53  class SidebarWinAccessible;
54 }
55 
56 
57 namespace sw::annotation {
58 
59 class SAL_DLLPUBLIC_RTTI SwAnnotationWin final : public InterimItemWindow
60 {
61  public:
62  SwAnnotationWin( SwEditWin& rEditWin,
63  SwPostItMgr& aMgr,
64  SwSidebarItem& rSidebarItem,
65  SwFormatField* aField );
66  virtual ~SwAnnotationWin() override;
67  virtual void dispose() override;
68 
69  void UpdateData();
70  void SetPostItText();
71  void Delete();
72  void GotoPos();
73  const SwPostItField* GetPostItField() const { return mpField; }
74  void UpdateText(const OUString& aText);
75 
76  OUString GetAuthor() const;
77  Date GetDate() const;
78  tools::Time GetTime() const;
79 
80  sal_uInt32 MoveCaret();
81 
83  sal_uInt32 CalcParent();
84  void InitAnswer(OutlinerParaObject const & rText);
85 
86  bool IsProtected() const;
87 
88  void SetSize( const Size& rNewSize );
89  void SetPosSizePixelRect( tools::Long nX,
90  tools::Long nY,
91  tools::Long nWidth,
92  tools::Long nHeight,
93  const SwRect& aAnchorRect,
94  const tools::Long PageBorder);
95  void SetPosAndSize();
96  void TranslateTopPosition(const tools::Long aAmount);
97  void CheckMetaText();
98 
99  Point const & GetAnchorPos() { return mAnchorRect.Pos(); }
100  const SwRect& GetAnchorRect() const { return mAnchorRect; }
101  bool IsAnchorRectChanged() const { return mbAnchorRectChanged; }
102  void ResetAnchorRectChanged() { mbAnchorRectChanged = false; }
103  const std::vector<basegfx::B2DRange>& GetAnnotationTextRanges() const { return maAnnotationTextRanges; }
104  SwEditWin& EditWin();
105  SwSidebarItem& GetSidebarItem() { return mrSidebarItem; }
106 
107  OutlinerView* GetOutlinerView() { return mpOutlinerView.get();}
108  Outliner* GetOutliner() { return mpOutliner.get();}
109  bool HasScrollbar() const;
110  bool IsScrollbarVisible() const;
113  ::sw::overlay::OverlayRanges* TextRange() { return mpTextRangeOverlay.get();}
114 
115  tools::Long GetPostItTextHeight();
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  Point VirtualPos() { return mPosSize.TopLeft(); }
129  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  return mbReadonly;
142  }
143 
144  void SetColor(Color aColorDark,Color aColorLight, Color aColorAnchor);
145  const Color& ColorDark() { return mColorDark; }
146  const Color& ColorLight() { return mColorLight; }
147  void Rescale();
148 
149  void SetViewState(::sw::sidebarwindows::ViewState bViewState);
150 
151  bool IsFollow() const { return mbIsFollow; }
152  void SetFollow( bool bIsFollow) { mbIsFollow = bIsFollow; };
153 
154  sal_Int32 GetMetaHeight() const;
155  sal_Int32 GetMinimumSizeWithMeta() const;
156  sal_Int32 GetMinimumSizeWithoutMeta() const;
157  int GetPrefScrollbarWidth() const;
158  sal_Int32 GetNumFields() const;
159 
160  void SetSpellChecking();
161 
162  void ToggleInsMode();
163 
164  void ActivatePostIt();
165  void DeactivatePostIt();
166 
167  void SetChangeTracking( const SwPostItHelper::SwLayoutStatus aStatus,
168  const Color& aColor);
169  SwPostItHelper::SwLayoutStatus GetLayoutStatus() const { return mLayoutStatus; }
170  const Color& GetChangeColor() const { return mChangeColor; }
171 
172  bool IsMouseOverSidebarWin() const { return mbMouseOver; }
173 
174  void SetLanguage(const SvxLanguageItem& rNewItem);
175 
176  void ChangeSidebarItem( SwSidebarItem const & rSidebarItem );
177  virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override;
178 
179  void DrawForPage(OutputDevice* pDev, const Point& rPos);
180 
181  void PaintTile(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect);
183  bool IsHitWindow(const Point& rPointLogic);
185  void SetCursorLogicPosition(const Point& rPosition, bool bPoint, bool bClearMark);
186 
187  // Various access functions for 'resolved' status
188  void SetResolved(bool resolved);
189  void ToggleResolved();
190  void ToggleResolvedForThread();
191  void DeleteThread();
192  bool IsResolved() const;
193  bool IsThreadResolved();
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 
203  SwAnnotationWin* GetTopReplyNote();
204 
205  virtual FactoryFunction GetUITestFactory() const override;
206 
207  private:
208 
209  virtual void LoseFocus() override;
210  virtual void GetFocus() override;
211 
212  void SetSizePixel( const Size& rNewSize ) override;
213  SfxItemSet DefaultItem();
214 
215  DECL_LINK(ModifyHdl, LinkParamNone*, void);
216  DECL_LINK(ScrollHdl, weld::ScrolledWindow&, void);
217  DECL_LINK(DeleteHdl, void*, void);
218  DECL_LINK(ToggleHdl, weld::Toggleable&, void);
219  DECL_LINK(SelectHdl, const OString&, void);
220  DECL_LINK(KeyInputHdl, const KeyEvent&, bool);
221  DECL_LINK(MouseMoveHdl, const MouseEvent&, bool);
222 
223  sal_uInt32 CountFollowing();
224 
226 
227  void SetMenuButtonColors();
228 
231 
233 
234  std::unique_ptr<OutlinerView> mpOutlinerView;
235  std::unique_ptr<Outliner> mpOutliner;
236 
237  std::unique_ptr<weld::ScrolledWindow> mxVScrollbar;
238  std::unique_ptr<sw::sidebarwindows::SidebarTextControl> mxSidebarTextControl;
239  std::unique_ptr<weld::CustomWeld> mxSidebarTextControlWin;
241  std::unique_ptr<weld::Label> mxMetadataAuthor;
242  std::unique_ptr<weld::Label> mxMetadataDate;
243  std::unique_ptr<weld::Label> mxMetadataResolved;
244  std::unique_ptr<weld::MenuButton> mxMenuButton;
245 
246  std::unique_ptr<sw::sidebarwindows::AnchorOverlayObject> mpAnchor;
247  std::unique_ptr<sw::sidebarwindows::ShadowOverlayObject> mpShadow;
248  std::unique_ptr<sw::overlay::OverlayRanges> mpTextRangeOverlay;
249 
254 
256 
261 
263 
264  std::vector<basegfx::B2DRange> maAnnotationTextRanges;
265 
268 
271 
274 
277 
279 };
280 
281 } // end of namespace sw::annotation
282 
283 #endif
284 
285 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::unique_ptr< weld::Label > mxMetadataDate
Base class of the Writer layout elements.
Definition: frame.hxx:315
std::unique_ptr< weld::ScrolledWindow > mxVScrollbar
std::vector< basegfx::B2DRange > maAnnotationTextRanges
std::unique_ptr< weld::Label > mxMetadataResolved
SwPostItHelper::SwLayoutStatus GetLayoutStatus() const
const SwRect & GetAnchorRect() const
SwPostItHelper::SwLayoutStatus mLayoutStatus
::sw::overlay::OverlayRanges * TextRange()
long Long
LanguageType GetLanguage(SfxItemSet const &aSet, sal_uInt16 nLangWhichId)
Definition: langhelper.cxx:390
std::function< std::unique_ptr< UIObject >vcl::Window *)> FactoryFunction
Any GetTime(const OUString &val)
std::unique_ptr< sw::sidebarwindows::ShadowOverlayObject > mpShadow
Of course Writer needs its own rectangles.
Definition: swrect.hxx:34
const SwPostItField * GetPostItField() const
std::unique_ptr< weld::MenuButton > mxMenuButton
std::unique_ptr< sw::overlay::OverlayRanges > mpTextRangeOverlay
std::unique_ptr< Outliner > mpOutliner
std::unique_ptr< OutlinerView > mpOutlinerView
Window class for the Writer edit area, this is the one handling mouse and keyboard events and doing t...
Definition: edtwin.hxx:58
const Color & GetChangeColor() const
rtl::Reference< sw::sidebarwindows::SidebarWinAccessible > mxSidebarWinAccessible
::sw::sidebarwindows::AnchorOverlayObject * Anchor()
void SetFollow(bool bIsFollow)
std::unique_ptr< weld::CustomWeld > mxSidebarTextControlWin
sw::sidebarwindows::SidebarPosition meSidebarPosition
const std::vector< basegfx::B2DRange > & GetAnnotationTextRanges() const
std::unique_ptr< sw::sidebarwindows::AnchorOverlayObject > mpAnchor
::sw::sidebarwindows::ShadowOverlayObject * Shadow()
void SetLanguage(SwWrtShell &rWrtSh, std::u16string_view rLangText, bool bIsForSelection, SfxItemSet &rCoreSet)
Definition: langhelper.cxx:214
std::unique_ptr< sw::sidebarwindows::SidebarTextControl > mxSidebarTextControl
std::unique_ptr< weld::Label > mxMetadataAuthor
Definition: view.hxx:144