1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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/customweld.hxx>
29 #include "postithelper.hxx"
31 #include "SidebarWindowsTypes.hxx"
35 class OutlinerParaObject
;
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
;
56 namespace sw::annotation
{
58 class SAL_DLLPUBLIC_RTTI SwAnnotationWin final
: public InterimItemWindow
61 SwAnnotationWin( SwEditWin
& rEditWin
,
63 SwSidebarItem
& rSidebarItem
,
64 SwFormatField
* aField
);
65 virtual ~SwAnnotationWin() override
;
66 virtual void dispose() override
;
72 const SwPostItField
* GetPostItField() const { return mpField
; }
73 void UpdateText(const OUString
& aText
);
75 OUString
GetAuthor() const;
77 tools::Time
GetTime() const;
79 sal_uInt32
MoveCaret();
81 /// Calculate parent postit id of current annotation window
82 sal_uInt32
CalcParent();
83 void InitAnswer(OutlinerParaObject
const & rText
);
85 bool IsReadOnlyOrProtected() const;
87 void SetSize( const Size
& rNewSize
);
88 void SetPosSizePixelRect( tools::Long nX
,
92 const SwRect
& aAnchorRect
,
93 const tools::Long PageBorder
);
95 void TranslateTopPosition(const tools::Long aAmount
);
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
; }
106 OutlinerView
* GetOutlinerView() { return mpOutlinerView
.get();}
107 Outliner
* GetOutliner() { return mpOutliner
.get();}
108 bool HasScrollbar() const;
109 bool IsScrollbarVisible() const;
110 ::sw::sidebarwindows::AnchorOverlayObject
* Anchor() { return mpAnchor
.get();}
111 ::sw::sidebarwindows::ShadowOverlayObject
* Shadow() { return mpShadow
.get();}
112 ::sw::overlay::OverlayRanges
* TextRange() { return mpTextRangeOverlay
.get();}
114 tools::Long
GetPostItTextHeight();
116 void SwitchToPostIt(sal_uInt16 aDirection
);
117 void SwitchToFieldPos();
119 void ExecuteCommand(sal_uInt16 nSlot
);
122 void ResizeIfNecessary(tools::Long aOldHeight
, tools::Long aNewHeight
);
124 void LockView(bool bLock
);
126 void SetVirtualPosSize( const Point
& aPoint
, const Size
& aSize
);
127 Point
VirtualPos() { return mPosSize
.TopLeft(); }
128 Size
VirtualSize() { return mPosSize
.GetSize(); }
130 void ShowAnchorOnly(const Point
&aPoint
);
134 void ResetAttributes();
136 void SetSidebarPosition(sw::sidebarwindows::SidebarPosition eSidebarPosition
);
137 void SetReadonly(bool bSet
);
138 bool IsReadOnly() const
143 void SetColor(Color aColorDark
,Color aColorLight
, Color aColorAnchor
);
144 const Color
& ColorDark() { return mColorDark
; }
145 const Color
& ColorLight() { return mColorLight
; }
148 void SetViewState(::sw::sidebarwindows::ViewState bViewState
);
150 bool IsFollow() const { return mbIsFollow
; }
151 void SetFollow( bool bIsFollow
) { mbIsFollow
= bIsFollow
; };
153 sal_Int32
GetMetaHeight() const;
154 sal_Int32
GetMinimumSizeWithMeta() const;
155 sal_Int32
GetMinimumSizeWithoutMeta() const;
156 int GetPrefScrollbarWidth() const;
157 sal_Int32
GetNumFields() const;
159 void SetSpellChecking();
161 void ToggleInsMode();
163 void ActivatePostIt();
164 void DeactivatePostIt();
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
; }
171 bool IsMouseOverSidebarWin() const { return mbMouseOver
; }
173 void SetLanguage(const SvxLanguageItem
& rNewItem
);
175 void ChangeSidebarItem( SwSidebarItem
const & rSidebarItem
);
176 virtual css::uno::Reference
< css::accessibility::XAccessible
> CreateAccessible() override
;
178 void DrawForPage(OutputDevice
* pDev
, const Point
& rPos
);
180 void PaintTile(vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& rRect
);
181 /// Is there a matching sub-widget inside this sidebar widget for rPointLogic?
182 bool IsHitWindow(const Point
& rPointLogic
);
183 /// Allows adjusting the point or mark of the selection to a document coordinate.
184 void SetCursorLogicPosition(const Point
& rPosition
, bool bPoint
, bool bClearMark
);
186 // Various access functions for 'resolved' status
187 void SetResolved(bool resolved
);
188 void ToggleResolved();
189 void ToggleResolvedForThread();
191 bool IsResolved() const;
192 bool IsThreadResolved();
194 // Get annotation paraId or generate one if it doesn't exist
195 sal_uInt32
GetParaId();
196 // Used to generate a unique paraId
197 static sal_uInt32
CreateUniqueParaId();
199 // Set this SwAnnotationWin as the currently active one
200 // return false if it was already active
201 bool SetActiveSidebarWin();
202 // Unset this SwAnnotationWin as the currently active one
203 void UnsetActiveSidebarWin();
205 /// Find the first annotation for the thread which this annotation is in.
206 /// This may be the same annotation as this one.
207 SwAnnotationWin
* GetTopReplyNote();
209 virtual FactoryFunction
GetUITestFactory() const override
;
213 virtual void LoseFocus() override
;
214 virtual void GetFocus() override
;
216 void SetSizePixel( const Size
& rNewSize
) override
;
217 SfxItemSet
DefaultItem();
219 DECL_DLLPRIVATE_LINK(ModifyHdl
, LinkParamNone
*, void);
220 DECL_DLLPRIVATE_LINK(ScrollHdl
, weld::ScrolledWindow
&, void);
221 DECL_DLLPRIVATE_LINK(DeleteHdl
, void*, void);
222 DECL_DLLPRIVATE_LINK(ToggleHdl
, weld::Toggleable
&, void);
223 DECL_DLLPRIVATE_LINK(SelectHdl
, const OUString
&, void);
224 DECL_DLLPRIVATE_LINK(KeyInputHdl
, const KeyEvent
&, bool);
225 DECL_DLLPRIVATE_LINK(MouseMoveHdl
, const MouseEvent
&, bool);
227 sal_uInt32
CountFollowing();
229 SvxLanguageItem
GetLanguage() const;
231 void SetMenuButtonColors();
236 ImplSVEvent
* mnDeleteEventId
;
238 std::unique_ptr
<OutlinerView
> mpOutlinerView
;
239 std::unique_ptr
<Outliner
> mpOutliner
;
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
;
250 std::unique_ptr
<sw::sidebarwindows::AnchorOverlayObject
> mpAnchor
;
251 std::unique_ptr
<sw::sidebarwindows::ShadowOverlayObject
> mpShadow
;
252 std::unique_ptr
<sw::overlay::OverlayRanges
> mpTextRangeOverlay
;
259 sw::sidebarwindows::SidebarPosition meSidebarPosition
;
261 tools::Rectangle mPosSize
;
263 tools::Long mPageBorder
;
264 bool mbAnchorRectChanged
;
266 bool mbResolvedStateUpdated
;
268 std::vector
<basegfx::B2DRange
> maAnnotationTextRanges
;
271 SwPostItHelper::SwLayoutStatus mLayoutStatus
;
276 SwSidebarItem
& mrSidebarItem
;
277 const SwFrame
* mpAnchorFrame
;
279 SwFormatField
* mpFormatField
;
280 SwPostItField
* mpField
;
282 rtl::Reference
<sw::sidebarwindows::SidebarWinAccessible
> mxSidebarWinAccessible
;
285 } // end of namespace sw::annotation
287 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */