LibreOffice Module sw (master) 1
PostItMgr.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_POSTITMGR_HXX
21#define INCLUDED_SW_INC_POSTITMGR_HXX
22
23#include <sal/config.h>
24#include "swdllapi.h"
25
26#include <cstddef>
27#include <memory>
28#include <vector>
29#include <rtl/ustring.hxx>
30#include <sal/log.hxx>
31#include <tools/link.hxx>
32#include "swrect.hxx"
34#include <com/sun/star/uno/Any.hxx>
36#include <editeng/outlobj.hxx>
37#include <svl/lstner.hxx>
38#include <vcl/vclptr.hxx>
39
40class OutputDevice;
41class SwWrtShell;
42class SwView;
43class SwPostItField;
44class SwFormatField;
45class SfxBroadcaster;
46class SfxHint;
47class SwEditWin;
48class Color;
49class SfxItemSet;
50class SvxSearchItem;
51namespace sw::annotation { class SwAnnotationWin; }
52namespace sw::sidebarwindows { class SwFrameSidebarWinContainer; }
53class SwSidebarItem;
54class SwFrame;
55namespace vcl { class Window; }
56struct ImplSVEvent;
58namespace i18nutil { struct SearchOptions2; }
59
60#define COL_NOTES_SIDEPANE_ARROW_ENABLED Color(0,0,0)
61#define COL_NOTES_SIDEPANE_ARROW_DISABLED Color(172,168,153)
62
64{
69 std::vector<SwSidebarItem*> mvSidebarItems;
71 {
72 }
73};
74
76{
78 bool bCursor;
79 bool bMouse;
80 FieldShadowState(): mpShadowField(nullptr),bCursor(false),bMouse(false)
81 {
82 }
83};
84
85class SwNoteProps final : public utl::ConfigItem
86{
87 private:
89
90 virtual void ImplCommit() override;
91
92 public:
94 : ConfigItem("Office.Writer/Notes")
95 , m_bIsShowAnchor(false)
96 {
97 const css::uno::Sequence< OUString >& rNames = GetPropertyNames();
98 css::uno::Sequence< css::uno::Any > aValues = GetProperties(rNames);
99 const css::uno::Any* pValues = aValues.getConstArray();
100 SAL_WARN_IF(aValues.getLength() != rNames.getLength(), "sw", "GetProperties failed");
101 if (aValues.hasElements())
103 }
104
105 bool IsShowAnchor() const
106 {
107 return m_bIsShowAnchor;
108 }
109 static css::uno::Sequence< OUString >& GetPropertyNames()
110 {
111 static css::uno::Sequence< OUString > aNames;
112 if(!aNames.hasElements())
113 {
114 aNames.realloc(1);
115 OUString* pNames = aNames.getArray();
116 pNames[0] = "ShowAnkor";
117 }
118 return aNames;
119 }
120
121 virtual void Notify( const css::uno::Sequence< OUString >& aPropertyNames ) override;
122};
123
124class SAL_DLLPUBLIC_RTTI SwPostItMgr final : public SfxListener
125{
126 private:
130 std::vector<std::unique_ptr<SwSidebarItem>> mvPostItFields;
131 std::vector<std::unique_ptr<SwPostItPageItem>> mPages;
142 OUString maAnswerText;
144
145 // data structure to collect the <SwAnnotationWin> instances for certain <SwFrame> instances.
146 std::unique_ptr<sw::sidebarwindows::SwFrameSidebarWinContainer> mpFrameSidebarWinContainer;
147
148 void AddPostIts(bool bCheckExistence = true,bool bFocus = true);
149 void RemoveSidebarWin();
150 void PreparePageContainer();
151 void Scroll(const tools::Long lScroll,const tools::ULong aPage );
152 void AutoScroll(const sw::annotation::SwAnnotationWin* pPostIt,const tools::ULong aPage );
153 bool ScrollbarHit(const tools::ULong aPage,const Point &aPoint);
154 bool LayoutByPage( std::vector<sw::annotation::SwAnnotationWin*> &aVisiblePostItList,
155 const tools::Rectangle& rBorder,
156 tools::Long lNeededHeight);
157 // return true if a postit was found to have been removed
158 bool CheckForRemovedPostIts();
159 bool ArrowEnabled(sal_uInt16 aDirection,tools::ULong aPage) const;
160 bool BorderOverPageBorder(tools::ULong aPage) const;
161 bool HasScrollbars() const;
162 void Focus(const SfxBroadcaster& rBC);
163
164 sal_Int32 GetInitialAnchorDistance() const;
165 sal_Int32 GetScrollSize() const;
166 sal_Int32 GetSpaceBetween() const;
167 void SetReadOnlyState();
168 DECL_DLLPRIVATE_LINK( CalcHdl, void*, void);
169
170 sw::annotation::SwAnnotationWin* GetSidebarWin(const SfxBroadcaster* pBroadcaster) const;
171
172 SwSidebarItem* InsertItem( SfxBroadcaster* pItem, bool bCheckExistence, bool bFocus);
173 void RemoveItem( SfxBroadcaster* pBroadcast );
174
175 public:
176 SwPostItMgr(SwView* aDoc);
177 virtual ~SwPostItMgr() override;
178
179 typedef std::vector< std::unique_ptr<SwSidebarItem> >::const_iterator const_iterator;
180 const_iterator begin() const { return mvPostItFields.begin(); }
181 const_iterator end() const { return mvPostItFields.end(); }
182
183 void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
184
185 void LayoutPostIts();
186 bool CalcRects();
187
188 void MakeVisible( const sw::annotation::SwAnnotationWin* pPostIt);
189
190 bool ShowScrollbar(const tools::ULong aPage) const;
191 bool HasNotes() const ;
192 bool ShowNotes() const;
193 bool IsShowAnchor() const { return mbIsShowAnchor;}
194 tools::ULong GetSidebarWidth(bool bPx = false) const;
195 tools::ULong GetSidebarBorderWidth(bool bPx = false) const;
196
197 void PrepareView(bool bIgnoreCount = false);
198
199 void CorrectPositions();
200
201 void SetLayout() { mbLayout = true; };
202 void Delete(const OUString& aAuthor);
203 void Delete(sal_uInt32 nPostItId);
204 void Delete();
205 void DeleteCommentThread(sal_uInt32 nPostItId);
206 void ToggleResolved(sal_uInt32 nPostItId);
207 void ToggleResolvedForThread(sal_uInt32 nPostItId);
208
209 void ExecuteFormatAllDialog(SwView& rView);
210 void FormatAll(const SfxItemSet &rNewAttr);
211
212 void Hide( std::u16string_view rAuthor );
213 void Hide();
214 void Show();
215 void UpdateResolvedStatus(const sw::annotation::SwAnnotationWin* topNote);
216 void ShowHideResolvedNotes(bool visible);
217
218 void Rescale();
219
220 tools::Rectangle GetBottomScrollRect(const tools::ULong aPage) const;
221 tools::Rectangle GetTopScrollRect(const tools::ULong aPage) const;
222
223 bool IsHit(const Point &aPointPixel);
225 vcl::Window* IsHitSidebarWindow(const Point& rPointLogic);
226 Color GetArrowColor(sal_uInt16 aDirection, tools::ULong aPage) const;
227
228 sw::annotation::SwAnnotationWin* GetAnnotationWin(const SwPostItField* pField) const;
229 sw::annotation::SwAnnotationWin* GetAnnotationWin(const sal_uInt32 nPostItId) const;
230
231 sw::annotation::SwAnnotationWin* GetNextPostIt( sal_uInt16 aDirection,
233 SwPostItField* GetLatestPostItField();
234
235 tools::Long GetNextBorder();
236
238 void SetActiveSidebarWin( sw::annotation::SwAnnotationWin* p);
239 SW_DLLPUBLIC bool HasActiveSidebarWin() const;
240 bool HasActiveAnnotationWin() const;
241 void GrabFocusOnActiveSidebarWin();
242 SW_DLLPUBLIC void UpdateDataOnActiveSidebarWin();
243 void DeleteActiveSidebarWin();
244 void HideActiveSidebarWin();
245 void ToggleInsModeOnActiveSidebarWin();
246
247 sal_Int32 GetMinimumSizeWithMeta() const;
248 sal_Int32 GetSidebarScrollerHeight() const;
249
250 void SetShadowState(const SwPostItField* pField,bool bCursor = true);
251
252 void SetSpellChecking();
253
254 static Color GetColorDark(std::size_t aAuthorIndex);
255 static Color GetColorLight(std::size_t aAuthorIndex);
256 static Color GetColorAnchor(std::size_t aAuthorIndex);
257
258 void RegisterAnswer(const OutlinerParaObject* pAnswer) { if (pAnswer) mpAnswer =* pAnswer; else mpAnswer.reset(); }
259 OutlinerParaObject* IsAnswer() { return mpAnswer ? &*mpAnswer : nullptr; }
260 void RegisterAnswerText(const OUString& aAnswerText) { maAnswerText = aAnswerText; }
261 const OUString& GetAnswerText() const { return maAnswerText; }
262 void CheckMetaText();
263
264 sal_uInt16 Replace(SvxSearchItem const * pItem);
265 sal_uInt16 SearchReplace(const SwFormatField &pField, const i18nutil::SearchOptions2& rSearchOptions,bool bSrchForward);
266 sal_uInt16 FinishSearchReplace(const i18nutil::SearchOptions2& rSearchOptions,bool bSrchForward);
267
268 void AssureStdModeAtShell();
269
270 void ConnectSidebarWinToFrame( const SwFrame& rFrame,
271 const SwFormatField& rFormatField,
272 sw::annotation::SwAnnotationWin& rSidebarWin );
273 void DisconnectSidebarWinFromFrame( const SwFrame& rFrame,
274 sw::annotation::SwAnnotationWin& rSidebarWin );
275 bool HasFrameConnectedSidebarWins( const SwFrame& rFrame );
276 vcl::Window* GetSidebarWinForFrameByIndex( const SwFrame& rFrame,
277 const sal_Int32 nIndex );
278 void GetAllSidebarWinForFrame( const SwFrame& rFrame,
279 std::vector< vcl::Window* >* pChildren );
280
281 void DrawNotesForPage(OutputDevice *pOutDev, sal_uInt32 nPage);
282 void PaintTile(OutputDevice& rRenderContext);
283};
284
285#endif
286
287/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const PropertyValue * pValues
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint)
Window class for the Writer edit area, this is the one handling mouse and keyboard events and doing t...
Definition: edtwin.hxx:61
Base class of the Writer layout elements.
Definition: frame.hxx:315
virtual void Notify(const css::uno::Sequence< OUString > &aPropertyNames) override
Definition: PostItMgr.cxx:2522
bool m_bIsShowAnchor
Definition: PostItMgr.hxx:88
virtual void ImplCommit() override
Definition: PostItMgr.cxx:2521
static css::uno::Sequence< OUString > & GetPropertyNames()
Definition: PostItMgr.hxx:109
bool IsShowAnchor() const
Definition: PostItMgr.hxx:105
bool mbReadOnly
Definition: PostItMgr.hxx:138
std::vector< std::unique_ptr< SwPostItPageItem > > mPages
Definition: PostItMgr.hxx:131
bool mbDeleteNote
Definition: PostItMgr.hxx:139
SwView * mpView
Definition: PostItMgr.hxx:127
const_iterator begin() const
Definition: PostItMgr.hxx:180
std::vector< std::unique_ptr< SwSidebarItem > > mvPostItFields
Definition: PostItMgr.hxx:130
OUString maAnswerText
Definition: PostItMgr.hxx:142
void RegisterAnswerText(const OUString &aAnswerText)
Definition: PostItMgr.hxx:260
void SetLayout()
Definition: PostItMgr.hxx:201
void RegisterAnswer(const OutlinerParaObject *pAnswer)
Definition: PostItMgr.hxx:258
FieldShadowState mShadowState
Definition: PostItMgr.hxx:140
OutlinerParaObject * IsAnswer()
Definition: PostItMgr.hxx:259
std::unique_ptr< sw::sidebarwindows::SwFrameSidebarWinContainer > mpFrameSidebarWinContainer
Definition: PostItMgr.hxx:146
SwWrtShell * mpWrtShell
Definition: PostItMgr.hxx:128
VclPtr< SwEditWin > mpEditWin
Definition: PostItMgr.hxx:129
std::optional< OutlinerParaObject > mpAnswer
Definition: PostItMgr.hxx:141
VclPtr< sw::annotation::SwAnnotationWin > mpActivePostIt
Definition: PostItMgr.hxx:134
std::vector< std::unique_ptr< SwSidebarItem > >::const_iterator const_iterator
Definition: PostItMgr.hxx:179
bool IsShowAnchor() const
Definition: PostItMgr.hxx:193
const_iterator end() const
Definition: PostItMgr.hxx:181
bool mbIsShowAnchor
Definition: PostItMgr.hxx:143
ImplSVEvent * mnEventId
Definition: PostItMgr.hxx:132
tools::Long mbLayoutHeight
Definition: PostItMgr.hxx:136
bool mbLayouting
Definition: PostItMgr.hxx:137
const OUString & GetAnswerText() const
Definition: PostItMgr.hxx:261
bool mbWaitingForCalcRects
Definition: PostItMgr.hxx:133
DECL_DLLPRIVATE_LINK(CalcHdl, void *, void)
sw::annotation::SwAnnotationWin * GetActiveSidebarWin()
Definition: PostItMgr.hxx:237
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
Definition: view.hxx:146
Used by the UI to modify the document model.
Definition: wrtsh.hxx:97
ConfigItem(ConfigItem const &)=default
static css::uno::Sequence< css::uno::Any > GetProperties(css::uno::Reference< css::container::XHierarchicalNameAccess > const &xHierarchyAccess, const css::uno::Sequence< OUString > &rNames, bool bAllLocales)
#define SAL_WARN_IF(condition, area, stream)
const sal_uInt32 LEFT
Dialog to specify the properties of date form field.
unsigned long ULong
long Long
const SwPostItField * mpShadowField
Definition: PostItMgr.hxx:77
sw::sidebarwindows::SidebarPosition eSidebarPosition
Definition: PostItMgr.hxx:66
std::vector< SwSidebarItem * > mvSidebarItems
Definition: PostItMgr.hxx:69
tools::Long lOffset
Definition: PostItMgr.hxx:67
#define SW_DLLPUBLIC
Definition: swdllapi.h:28