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
;
47 namespace sw
{ namespace overlay
{
51 namespace sw
{ namespace sidebarwindows
{
52 class SidebarTextControl
;
53 class AnchorOverlayObject
;
54 class ShadowOverlayObject
;
57 namespace sw
{ namespace annotation
{
59 class SAL_DLLPUBLIC_RTTI SwAnnotationWin
: public vcl::Window
62 SwAnnotationWin( SwEditWin
& rEditWin
,
64 SwSidebarItem
& rSidebarItem
,
65 SwFormatField
* aField
);
66 virtual ~SwAnnotationWin() override
;
67 virtual void dispose() override
;
73 const SwPostItField
* GetPostItField() const { return mpField
; }
74 void UpdateText(const OUString
& aText
);
76 OUString
GetAuthor() const;
78 tools::Time
GetTime() const;
80 sal_uInt32
MoveCaret();
82 /// Calculate parent postit id of current annotation window
83 sal_uInt32
CalcParent();
84 void InitAnswer(OutlinerParaObject
const * pText
);
86 bool IsProtected() const;
88 void SetSize( const Size
& rNewSize
);
89 void SetPosSizePixelRect( long nX
,
93 const SwRect
& aAnchorRect
,
94 const long PageBorder
);
96 void TranslateTopPosition(const long aAmount
);
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
; }
107 OutlinerView
* GetOutlinerView() { return mpOutlinerView
.get();}
108 bool HasScrollbar() const;
109 bool IsScrollbarVisible() const;
110 ScrollBar
* Scrollbar() { return mpVScrollbar
; }
111 ::sw::sidebarwindows::AnchorOverlayObject
* Anchor() { return mpAnchor
.get();}
112 ::sw::sidebarwindows::ShadowOverlayObject
* Shadow() { return mpShadow
.get();}
113 ::sw::overlay::OverlayRanges
* TextRange() { return mpTextRangeOverlay
.get();}
115 long GetPostItTextHeight();
117 void SwitchToPostIt(sal_uInt16 aDirection
);
118 void SwitchToFieldPos();
120 void ExecuteCommand(sal_uInt16 nSlot
);
123 void ResizeIfNecessary(long aOldHeight
, long aNewHeight
);
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
);
133 void InvalidateControl();
135 void ResetAttributes();
137 void SetSidebarPosition(sw::sidebarwindows::SidebarPosition eSidebarPosition
);
138 void SetReadonly(bool bSet
);
139 bool IsReadOnly() const
144 void SetColor(Color aColorDark
,Color aColorLight
, Color aColorAnchor
);
145 const Color
& ColorAnchor() { return mColorAnchor
; }
146 const Color
& ColorDark() { return mColorDark
; }
147 const Color
& ColorLight() { return mColorLight
; }
150 void SetViewState(::sw::sidebarwindows::ViewState bViewState
);
152 bool IsFollow() const { return mbIsFollow
; }
153 void SetFollow( bool bIsFollow
) { mbIsFollow
= bIsFollow
; };
155 sal_Int32
GetMetaHeight();
156 sal_Int32
GetMinimumSizeWithMeta() const;
157 sal_Int32
GetMinimumSizeWithoutMeta() const;
158 sal_Int32
GetMetaButtonAreaWidth() const;
159 sal_Int32
GetScrollbarWidth() const;
160 sal_Int32
GetNumFields();
162 void SetSpellChecking();
164 void ToggleInsMode();
166 void ActivatePostIt();
167 void DeactivatePostIt();
169 void SetChangeTracking( const SwPostItHelper::SwLayoutStatus aStatus
,
170 const Color
& aColor
);
171 SwPostItHelper::SwLayoutStatus
GetLayoutStatus() const { return mLayoutStatus
; }
172 const Color
& GetChangeColor() const { return mChangeColor
; }
174 DECL_LINK( WindowEventListener
, VclWindowEvent
&, void );
175 bool IsMouseOverSidebarWin() const { return mbMouseOver
; }
177 void SetLanguage(const SvxLanguageItem
& rNewItem
);
179 void ChangeSidebarItem( SwSidebarItem
const & rSidebarItem
);
180 virtual css::uno::Reference
< css::accessibility::XAccessible
> CreateAccessible() override
;
182 virtual void Draw(OutputDevice
* pDev
, const Point
&, const Size
&, DrawFlags
) override
;
183 virtual void KeyInput(const KeyEvent
& rKeyEvt
) override
;
184 virtual void MouseButtonDown(const MouseEvent
& rMouseEvent
) override
;
185 virtual void MouseButtonUp(const MouseEvent
& rMouseEvent
) override
;
186 virtual void MouseMove(const MouseEvent
& rMouseEvent
) override
;
187 void PaintTile(vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& rRect
);
188 /// Is there a matching sub-widget inside this sidebar widget for rPointLogic?
189 bool IsHitWindow(const Point
& rPointLogic
);
190 /// Allows adjusting the point or mark of the selection to a document coordinate.
191 void SetCursorLogicPosition(const Point
& rPosition
, bool bPoint
, bool bClearMark
);
193 // Various access functions for 'resolved' status
194 void SetResolved(bool resolved
);
195 void ToggleResolved();
196 void ToggleResolvedForThread();
198 bool IsResolved() const;
199 bool IsThreadResolved();
201 /// Find the first annotation for the thread which this annotation is in.
202 /// This may be the same annotation as this one.
203 SwAnnotationWin
* GetTopReplyNote();
206 VclPtr
<MenuButton
> CreateMenuButton();
207 virtual void LoseFocus() override
;
208 virtual void Paint(vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& rRect
) override
;
209 virtual void GetFocus() override
;
211 void SetSizePixel( const Size
& rNewSize
) override
;
212 SfxItemSet
DefaultItem();
214 DECL_LINK(ModifyHdl
, LinkParamNone
*, void);
215 DECL_LINK(ScrollHdl
, ScrollBar
*, void);
216 DECL_LINK(DeleteHdl
, void*, void);
218 sal_uInt32
CountFollowing();
220 SvxLanguageItem
GetLanguage() const;
222 VclBuilder maBuilder
;
226 ImplSVEvent
* mnEventId
;
228 std::unique_ptr
<OutlinerView
> mpOutlinerView
;
229 std::unique_ptr
<Outliner
> mpOutliner
;
231 VclPtr
<sw::sidebarwindows::SidebarTextControl
> mpSidebarTextControl
;
232 VclPtr
<ScrollBar
> mpVScrollbar
;
233 VclPtr
<Edit
> mpMetadataAuthor
;
234 VclPtr
<Edit
> mpMetadataDate
;
235 VclPtr
<Edit
> mpMetadataResolved
;
236 VclPtr
<MenuButton
> mpMenuButton
;
238 std::unique_ptr
<sw::sidebarwindows::AnchorOverlayObject
> mpAnchor
;
239 std::unique_ptr
<sw::sidebarwindows::ShadowOverlayObject
> mpShadow
;
240 std::unique_ptr
<sw::overlay::OverlayRanges
> mpTextRangeOverlay
;
247 sw::sidebarwindows::SidebarPosition meSidebarPosition
;
249 tools::Rectangle mPosSize
;
252 bool mbAnchorRectChanged
;
254 bool mbResolvedStateUpdated
;
256 std::vector
<basegfx::B2DRange
> maAnnotationTextRanges
;
259 SwPostItHelper::SwLayoutStatus mLayoutStatus
;
264 SwSidebarItem
& mrSidebarItem
;
265 const SwFrame
* mpAnchorFrame
;
267 SwFormatField
* mpFormatField
;
268 SwPostItField
* mpField
;
269 VclPtr
<PopupMenu
> mpButtonPopup
;
272 } } // end of namespace sw::annotation
275 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */