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 <tools/date.hxx>
25 #include <tools/time.hxx>
26 #include <vcl/builder.hxx>
27 #include <vcl/window.hxx>
28 
29 #include "postithelper.hxx"
30 #include "swrect.hxx"
31 #include "SidebarWindowsTypes.hxx"
32 
33 class PopupMenu;
34 class OutlinerParaObject;
35 class SwPostItMgr;
36 class SwPostItField;
37 class OutlinerView;
38 class Outliner;
39 class ScrollBar;
40 class SwEditWin;
41 class SwView;
42 class Edit;
43 class MenuButton;
44 class SwFrame;
45 class SvxLanguageItem;
46 namespace sw::overlay { class OverlayRanges; }
47 namespace sw::sidebarwindows {
48  class SidebarTextControl;
49  class AnchorOverlayObject;
50  class ShadowOverlayObject;
51 }
52 
53 
54 namespace sw::annotation {
55 
56 class SAL_DLLPUBLIC_RTTI SwAnnotationWin : public vcl::Window
57 {
58  public:
59  SwAnnotationWin( SwEditWin& rEditWin,
60  SwPostItMgr& aMgr,
61  SwSidebarItem& rSidebarItem,
62  SwFormatField* aField );
63  virtual ~SwAnnotationWin() override;
64  virtual void dispose() override;
65 
66  void UpdateData();
67  void SetPostItText();
68  void Delete();
69  void GotoPos();
70  const SwPostItField* GetPostItField() const { return mpField; }
71  void UpdateText(const OUString& aText);
72 
73  OUString GetAuthor() const;
74  Date GetDate() const;
75  tools::Time GetTime() const;
76 
77  sal_uInt32 MoveCaret();
78 
80  sal_uInt32 CalcParent();
81  void InitAnswer(OutlinerParaObject const * pText);
82 
83  bool IsProtected() const;
84 
85  void SetSize( const Size& rNewSize );
86  void SetPosSizePixelRect( long nX,
87  long nY,
88  long nWidth,
89  long nHeight,
90  const SwRect& aAnchorRect,
91  const long PageBorder);
92  void SetPosAndSize();
93  void TranslateTopPosition(const long aAmount);
94  void CheckMetaText();
95 
96  Point const & GetAnchorPos() { return mAnchorRect.Pos(); }
97  const SwRect& GetAnchorRect() const { return mAnchorRect; }
98  bool IsAnchorRectChanged() const { return mbAnchorRectChanged; }
99  void ResetAnchorRectChanged() { mbAnchorRectChanged = false; }
100  const std::vector<basegfx::B2DRange>& GetAnnotationTextRanges() const { return maAnnotationTextRanges; }
101  SwEditWin& EditWin();
102  SwSidebarItem& GetSidebarItem() { return mrSidebarItem; }
103 
104  OutlinerView* GetOutlinerView() { return mpOutlinerView.get();}
105  Outliner* GetOutliner() { return mpOutliner.get();}
106  bool HasScrollbar() const;
107  bool IsScrollbarVisible() const;
108  ScrollBar* Scrollbar() { return mpVScrollbar; }
111  ::sw::overlay::OverlayRanges* TextRange() { return mpTextRangeOverlay.get();}
112 
113  long GetPostItTextHeight();
114 
115  void SwitchToPostIt(sal_uInt16 aDirection);
116  void SwitchToFieldPos();
117 
118  void ExecuteCommand(sal_uInt16 nSlot);
119  void InitControls();
120  void DoResize();
121  void ResizeIfNecessary(long aOldHeight, long aNewHeight);
122  void SetScrollbar();
123 
124  void SetVirtualPosSize( const Point& aPoint, const Size& aSize);
125  Point VirtualPos() { return mPosSize.TopLeft(); }
126  Size VirtualSize() { return mPosSize.GetSize(); }
127 
128  void ShowAnchorOnly(const Point &aPoint);
129  void ShowNote();
130  void HideNote();
131  void InvalidateControl();
132 
133  void ResetAttributes();
134 
135  void SetSidebarPosition(sw::sidebarwindows::SidebarPosition eSidebarPosition);
136  void SetReadonly(bool bSet);
137  bool IsReadOnly() const
138  {
139  return mbReadonly;
140  }
141 
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();
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();
154  sal_Int32 GetMinimumSizeWithMeta() const;
155  sal_Int32 GetMinimumSizeWithoutMeta() const;
156  sal_Int32 GetMetaButtonAreaWidth() const;
157  sal_Int32 GetScrollbarWidth() const;
158  sal_Int32 GetNumFields();
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  DECL_LINK( WindowEventListener, VclWindowEvent&, void );
173  bool IsMouseOverSidebarWin() const { return mbMouseOver; }
174 
175  void SetLanguage(const SvxLanguageItem& rNewItem);
176 
177  void ChangeSidebarItem( SwSidebarItem const & rSidebarItem );
178  virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override;
179 
180  virtual void Draw(OutputDevice* pDev, const Point&, DrawFlags) override;
181  virtual void KeyInput(const KeyEvent& rKeyEvt) override;
182  virtual void MouseButtonDown(const MouseEvent& rMouseEvent) override;
183  virtual void MouseButtonUp(const MouseEvent& rMouseEvent) override;
184  virtual void MouseMove(const MouseEvent& rMouseEvent) override;
185  void PaintTile(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect);
187  bool IsHitWindow(const Point& rPointLogic);
189  void SetCursorLogicPosition(const Point& rPosition, bool bPoint, bool bClearMark);
190 
191  // Various access functions for 'resolved' status
192  void SetResolved(bool resolved);
193  void ToggleResolved();
194  void ToggleResolvedForThread();
195  bool IsResolved() const;
196  bool IsThreadResolved();
197 
200  SwAnnotationWin* GetTopReplyNote();
201 
202  virtual FactoryFunction GetUITestFactory() const override;
203 
204  private:
205  VclPtr<MenuButton> CreateMenuButton();
206  virtual void LoseFocus() override;
207  virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
208  virtual void GetFocus() override;
209 
210  void SetSizePixel( const Size& rNewSize ) override;
211  SfxItemSet DefaultItem();
212 
213  DECL_LINK(ModifyHdl, LinkParamNone*, void);
214  DECL_LINK(ScrollHdl, ScrollBar*, void);
215  DECL_LINK(DeleteHdl, void*, void);
216 
217  sal_uInt32 CountFollowing();
218 
220 
224 
226 
227  std::unique_ptr<OutlinerView> mpOutlinerView;
228  std::unique_ptr<Outliner> mpOutliner;
229 
236 
237  std::unique_ptr<sw::sidebarwindows::AnchorOverlayObject> mpAnchor;
238  std::unique_ptr<sw::sidebarwindows::ShadowOverlayObject> mpShadow;
239  std::unique_ptr<sw::overlay::OverlayRanges> mpTextRangeOverlay;
240 
245 
247 
252 
254 
255  std::vector<basegfx::B2DRange> maAnnotationTextRanges;
256 
259 
262 
265 
269 };
270 
271 } // end of namespace sw::annotation
272 
273 #endif
274 
275 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Base class of the Writer layout elements.
Definition: frame.hxx:297
std::vector< basegfx::B2DRange > maAnnotationTextRanges
VclPtr< MenuButton > mpMenuButton
SwPostItHelper::SwLayoutStatus GetLayoutStatus() const
const SwRect & GetAnchorRect() const
SwPostItHelper::SwLayoutStatus mLayoutStatus
::sw::overlay::OverlayRanges * TextRange()
LanguageType GetLanguage(SfxItemSet const &aSet, sal_uInt16 nLangWhichId)
Definition: langhelper.cxx:399
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:35
const SwPostItField * GetPostItField() const
std::unique_ptr< sw::overlay::OverlayRanges > mpTextRangeOverlay
std::unique_ptr< Outliner > mpOutliner
std::unique_ptr< OutlinerView > mpOutlinerView
DrawFlags
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
::sw::sidebarwindows::AnchorOverlayObject * Anchor()
void SetFollow(bool bIsFollow)
sw::sidebarwindows::SidebarPosition meSidebarPosition
const std::vector< basegfx::B2DRange > & GetAnnotationTextRanges() const
std::unique_ptr< sw::sidebarwindows::AnchorOverlayObject > mpAnchor
VclPtr< sw::sidebarwindows::SidebarTextControl > mpSidebarTextControl
void SetLanguage(SwWrtShell &rWrtSh, const OUString &rLangText, bool bIsForSelection, SfxItemSet &rCoreSet)
Definition: langhelper.cxx:220
VclPtr< ScrollBar > mpVScrollbar
::sw::sidebarwindows::ShadowOverlayObject * Shadow()
VclPtr< PopupMenu > mpButtonPopup
Definition: view.hxx:144