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 #pragma once
21 
23 #include <editeng/outlobj.hxx>
24 #include <tools/date.hxx>
25 #include <tools/time.hxx>
27 #include <vcl/customweld.hxx>
28 
29 #include "postithelper.hxx"
30 #include "swrect.hxx"
31 #include "SidebarWindowsTypes.hxx"
32 
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;
52  class SidebarWinAccessible;
53 }
54 
55 
56 namespace sw::annotation {
57 
58 class SAL_DLLPUBLIC_RTTI SwAnnotationWin final : public InterimItemWindow
59 {
60  public:
61  SwAnnotationWin( SwEditWin& rEditWin,
62  SwPostItMgr& aMgr,
63  SwSidebarItem& rSidebarItem,
64  SwFormatField* aField );
65  virtual ~SwAnnotationWin() override;
66  virtual void dispose() override;
67 
68  void UpdateData();
69  void SetPostItText();
70  void Delete();
71  void GotoPos();
72  const SwPostItField* GetPostItField() const { return mpField; }
73  void UpdateText(const OUString& aText);
74 
75  OUString GetAuthor() const;
76  Date GetDate() const;
77  tools::Time GetTime() const;
78 
79  sal_uInt32 MoveCaret();
80 
82  sal_uInt32 CalcParent();
83  void InitAnswer(OutlinerParaObject const & rText);
84 
85  bool IsProtected() const;
86 
87  void SetSize( const Size& rNewSize );
88  void SetPosSizePixelRect( tools::Long nX,
89  tools::Long nY,
90  tools::Long nWidth,
91  tools::Long nHeight,
92  const SwRect& aAnchorRect,
93  const tools::Long PageBorder);
94  void SetPosAndSize();
95  void TranslateTopPosition(const tools::Long aAmount);
96  void CheckMetaText();
97 
98  Point const & GetAnchorPos() { return mAnchorRect.Pos(); }
99  const SwRect& GetAnchorRect() const { return mAnchorRect; }
100  bool IsAnchorRectChanged() const { return mbAnchorRectChanged; }
101  void ResetAnchorRectChanged() { mbAnchorRectChanged = false; }
102  const std::vector<basegfx::B2DRange>& GetAnnotationTextRanges() const { return maAnnotationTextRanges; }
103  SwEditWin& EditWin();
104  SwSidebarItem& GetSidebarItem() { return mrSidebarItem; }
105 
106  OutlinerView* GetOutlinerView() { return mpOutlinerView.get();}
107  Outliner* GetOutliner() { return mpOutliner.get();}
108  bool HasScrollbar() const;
109  bool IsScrollbarVisible() const;
112  ::sw::overlay::OverlayRanges* TextRange() { return mpTextRangeOverlay.get();}
113 
114  tools::Long GetPostItTextHeight();
115 
116  void SwitchToPostIt(sal_uInt16 aDirection);
117  void SwitchToFieldPos();
118 
119  void ExecuteCommand(sal_uInt16 nSlot);
120  void InitControls();
121  void DoResize();
122  void ResizeIfNecessary(tools::Long aOldHeight, tools::Long aNewHeight);
123  void SetScrollbar();
124  void LockView(bool bLock);
125 
126  void SetVirtualPosSize( const Point& aPoint, const Size& aSize);
127  Point VirtualPos() { return mPosSize.TopLeft(); }
128  Size VirtualSize() { return mPosSize.GetSize(); }
129 
130  void ShowAnchorOnly(const Point &aPoint);
131  void ShowNote();
132  void HideNote();
133 
134  void ResetAttributes();
135 
136  void SetSidebarPosition(sw::sidebarwindows::SidebarPosition eSidebarPosition);
137  void SetReadonly(bool bSet);
138  bool IsReadOnly() const
139  {
140  return mbReadonly;
141  }
142 
143  void SetColor(Color aColorDark,Color aColorLight, Color aColorAnchor);
144  const Color& ColorDark() { return mColorDark; }
145  const Color& ColorLight() { return mColorLight; }
146  void Rescale();
147 
148  void SetViewState(::sw::sidebarwindows::ViewState bViewState);
149 
150  bool IsFollow() const { return mbIsFollow; }
151  void SetFollow( bool bIsFollow) { mbIsFollow = bIsFollow; };
152 
153  sal_Int32 GetMetaHeight() const;
154  sal_Int32 GetMinimumSizeWithMeta() const;
155  sal_Int32 GetMinimumSizeWithoutMeta() const;
156  int GetPrefScrollbarWidth() const;
157  sal_Int32 GetNumFields() const;
158 
159  void SetSpellChecking();
160 
161  void ToggleInsMode();
162 
163  void ActivatePostIt();
164  void DeactivatePostIt();
165 
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; }
170 
171  bool IsMouseOverSidebarWin() const { return mbMouseOver; }
172 
173  void SetLanguage(const SvxLanguageItem& rNewItem);
174 
175  void ChangeSidebarItem( SwSidebarItem const & rSidebarItem );
176  virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override;
177 
178  void DrawForPage(OutputDevice* pDev, const Point& rPos);
179 
180  void PaintTile(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect);
182  bool IsHitWindow(const Point& rPointLogic);
184  void SetCursorLogicPosition(const Point& rPosition, bool bPoint, bool bClearMark);
185 
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();
193 
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();
199 
202  SwAnnotationWin* GetTopReplyNote();
203 
204  virtual FactoryFunction GetUITestFactory() const override;
205 
206  private:
207 
208  virtual void LoseFocus() override;
209  virtual void GetFocus() override;
210 
211  void SetSizePixel( const Size& rNewSize ) override;
212  SfxItemSet DefaultItem();
213 
214  DECL_DLLPRIVATE_LINK(ModifyHdl, LinkParamNone*, void);
215  DECL_DLLPRIVATE_LINK(ScrollHdl, weld::ScrolledWindow&, void);
216  DECL_DLLPRIVATE_LINK(DeleteHdl, void*, void);
217  DECL_DLLPRIVATE_LINK(ToggleHdl, weld::Toggleable&, void);
218  DECL_DLLPRIVATE_LINK(SelectHdl, const OString&, void);
219  DECL_DLLPRIVATE_LINK(KeyInputHdl, const KeyEvent&, bool);
220  DECL_DLLPRIVATE_LINK(MouseMoveHdl, const MouseEvent&, bool);
221 
222  sal_uInt32 CountFollowing();
223 
225 
226  void SetMenuButtonColors();
227 
230 
232 
233  std::unique_ptr<OutlinerView> mpOutlinerView;
234  std::unique_ptr<Outliner> mpOutliner;
235 
236  std::unique_ptr<weld::ScrolledWindow> mxVScrollbar;
237  std::unique_ptr<sw::sidebarwindows::SidebarTextControl> mxSidebarTextControl;
238  std::unique_ptr<weld::CustomWeld> mxSidebarTextControlWin;
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;
244 
245  std::unique_ptr<sw::sidebarwindows::AnchorOverlayObject> mpAnchor;
246  std::unique_ptr<sw::sidebarwindows::ShadowOverlayObject> mpShadow;
247  std::unique_ptr<sw::overlay::OverlayRanges> mpTextRangeOverlay;
248 
253 
255 
260 
262 
263  std::vector<basegfx::B2DRange> maAnnotationTextRanges;
264 
267 
270 
273 
276 
278 };
279 
280 } // end of namespace sw::annotation
281 
282 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::unique_ptr< weld::Label > mxMetadataDate
Base class of the Writer layout elements.
Definition: frame.hxx:314
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:59
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