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 .
20 #ifndef INCLUDED_SW_INC_ANNOTATIONWIN_HXX
21 #define INCLUDED_SW_INC_ANNOTATIONWIN_HXX
23 #include <basegfx/range/b2drange.hxx>
24 #include <tools/date.hxx>
25 #include <tools/time.hxx>
26 #include <vcl/builder.hxx>
27 #include <vcl/window.hxx>
29 #include "postithelper.hxx"
31 #include "SidebarWindowsTypes.hxx"
34 class OutlinerParaObject
;
45 class SvxLanguageItem
;
46 namespace sw::overlay
{ class OverlayRanges
; }
47 namespace sw::sidebarwindows
{
48 class SidebarTextControl
;
49 class AnchorOverlayObject
;
50 class ShadowOverlayObject
;
54 namespace sw::annotation
{
56 class SAL_DLLPUBLIC_RTTI SwAnnotationWin
: public vcl::Window
59 SwAnnotationWin( SwEditWin
& rEditWin
,
61 SwSidebarItem
& rSidebarItem
,
62 SwFormatField
* aField
);
63 virtual ~SwAnnotationWin() override
;
64 virtual void dispose() override
;
70 const SwPostItField
* GetPostItField() const { return mpField
; }
71 void UpdateText(const OUString
& aText
);
73 OUString
GetAuthor() const;
75 tools::Time
GetTime() const;
77 sal_uInt32
MoveCaret();
79 /// Calculate parent postit id of current annotation window
80 sal_uInt32
CalcParent();
81 void InitAnswer(OutlinerParaObject
const * pText
);
83 bool IsProtected() const;
85 void SetSize( const Size
& rNewSize
);
86 void SetPosSizePixelRect( tools::Long nX
,
90 const SwRect
& aAnchorRect
,
91 const tools::Long PageBorder
);
93 void TranslateTopPosition(const tools::Long aAmount
);
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
; }
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
; }
109 ::sw::sidebarwindows::AnchorOverlayObject
* Anchor() { return mpAnchor
.get();}
110 ::sw::sidebarwindows::ShadowOverlayObject
* Shadow() { return mpShadow
.get();}
111 ::sw::overlay::OverlayRanges
* TextRange() { return mpTextRangeOverlay
.get();}
113 tools::Long
GetPostItTextHeight();
115 void SwitchToPostIt(sal_uInt16 aDirection
);
116 void SwitchToFieldPos();
118 void ExecuteCommand(sal_uInt16 nSlot
);
121 void ResizeIfNecessary(tools::Long aOldHeight
, tools::Long aNewHeight
);
124 void SetVirtualPosSize( const Point
& aPoint
, const Size
& aSize
);
125 Point
VirtualPos() { return mPosSize
.TopLeft(); }
126 Size
VirtualSize() { return mPosSize
.GetSize(); }
128 void ShowAnchorOnly(const Point
&aPoint
);
131 void InvalidateControl();
133 void ResetAttributes();
135 void SetSidebarPosition(sw::sidebarwindows::SidebarPosition eSidebarPosition
);
136 void SetReadonly(bool bSet
);
137 bool IsReadOnly() const
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
; }
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 sal_Int32
GetMetaButtonAreaWidth() const;
157 sal_Int32
GetScrollbarWidth() const;
158 sal_Int32
GetNumFields() const;
160 void SetSpellChecking();
162 void ToggleInsMode();
164 void ActivatePostIt();
165 void DeactivatePostIt();
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
; }
172 DECL_LINK( WindowEventListener
, VclWindowEvent
&, void );
173 bool IsMouseOverSidebarWin() const { return mbMouseOver
; }
175 void SetLanguage(const SvxLanguageItem
& rNewItem
);
177 void ChangeSidebarItem( SwSidebarItem
const & rSidebarItem
);
178 virtual css::uno::Reference
< css::accessibility::XAccessible
> CreateAccessible() override
;
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
);
186 /// Is there a matching sub-widget inside this sidebar widget for rPointLogic?
187 bool IsHitWindow(const Point
& rPointLogic
);
188 /// Allows adjusting the point or mark of the selection to a document coordinate.
189 void SetCursorLogicPosition(const Point
& rPosition
, bool bPoint
, bool bClearMark
);
191 // Various access functions for 'resolved' status
192 void SetResolved(bool resolved
);
193 void ToggleResolved();
194 void ToggleResolvedForThread();
196 bool IsResolved() const;
197 bool IsThreadResolved();
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
;
212 VclPtr
<MenuButton
> CreateMenuButton();
213 virtual void LoseFocus() override
;
214 virtual void Paint(vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& rRect
) override
;
215 virtual void GetFocus() override
;
217 void SetSizePixel( const Size
& rNewSize
) override
;
218 SfxItemSet
DefaultItem();
220 DECL_LINK(ModifyHdl
, LinkParamNone
*, void);
221 DECL_LINK(ScrollHdl
, ScrollBar
*, void);
222 DECL_LINK(DeleteHdl
, void*, void);
224 sal_uInt32
CountFollowing();
226 SvxLanguageItem
GetLanguage() const;
228 VclBuilder maBuilder
;
232 ImplSVEvent
* mnEventId
;
234 std::unique_ptr
<OutlinerView
> mpOutlinerView
;
235 std::unique_ptr
<Outliner
> mpOutliner
;
237 VclPtr
<sw::sidebarwindows::SidebarTextControl
> mpSidebarTextControl
;
238 VclPtr
<ScrollBar
> mpVScrollbar
;
239 VclPtr
<FixedText
> mpMetadataAuthor
;
240 VclPtr
<FixedText
> mpMetadataDate
;
241 VclPtr
<FixedText
> mpMetadataResolved
;
242 VclPtr
<MenuButton
> mpMenuButton
;
244 std::unique_ptr
<sw::sidebarwindows::AnchorOverlayObject
> mpAnchor
;
245 std::unique_ptr
<sw::sidebarwindows::ShadowOverlayObject
> mpShadow
;
246 std::unique_ptr
<sw::overlay::OverlayRanges
> mpTextRangeOverlay
;
253 sw::sidebarwindows::SidebarPosition meSidebarPosition
;
255 tools::Rectangle mPosSize
;
257 tools::Long mPageBorder
;
258 bool mbAnchorRectChanged
;
260 bool mbResolvedStateUpdated
;
262 std::vector
<basegfx::B2DRange
> maAnnotationTextRanges
;
265 SwPostItHelper::SwLayoutStatus mLayoutStatus
;
270 SwSidebarItem
& mrSidebarItem
;
271 const SwFrame
* mpAnchorFrame
;
273 SwFormatField
* mpFormatField
;
274 SwPostItField
* mpField
;
275 VclPtr
<PopupMenu
> mpButtonPopup
;
278 } // end of namespace sw::annotation
282 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */