update credits
[LibreOffice.git] / sw / inc / PostItMgr.hxx
blobc8dc4323bc423228ab079fc96c946dbeb5f7e5fd
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 _POSTITMGR_HXX
21 #define _POSTITMGR_HXX
23 #include <list>
24 #include <vector>
25 #include <editeng/outlobj.hxx>
26 #include <tools/string.hxx>
27 #include <tools/link.hxx>
28 #include <swrect.hxx>
29 #include <unotools/configitem.hxx>
30 #include <unotools/options.hxx>
31 #include <com/sun/star/util/SearchOptions.hpp>
32 #include <com/sun/star/uno/Any.hxx>
33 #include <SidebarWindowsTypes.hxx>
34 #include <svl/lstner.hxx>
36 class SwWrtShell;
37 class SwDoc;
38 class SwView;
39 class SwPostItField;
40 class SwFmtFld;
41 class SwField;
42 class SfxBroadcaster;
43 class SfxHint;
44 class SwEditWin;
45 class Color;
46 class SvxSearchItem;
47 class SvxLanguageItem;
48 namespace sw { namespace annotation {
49 class SwAnnotationWin;
51 namespace sw { namespace sidebarwindows {
52 class SwSidebarWin;
53 class SwFrmSidebarWinContainer;
55 class SwSidebarItem;
56 class SwFrm;
57 class Window;
59 #define SORT_POS 1
60 #define SORT_AUTHOR 2
61 #define SORT_DATE 3
63 #define COL_NOTES_SIDEPANE_ARROW_ENABLED RGB_COLORDATA(0,0,0)
64 #define COL_NOTES_SIDEPANE_ARROW_DISABLED RGB_COLORDATA(172,168,153)
66 typedef std::list<SwSidebarItem*> SwSidebarItem_list;
67 typedef std::list<SwSidebarItem*>::iterator SwSidebarItem_iterator;
70 struct SwPostItPageItem
72 bool bScrollbar;
73 sw::sidebarwindows::SidebarPosition eSidebarPosition;
74 long lOffset;
75 SwRect mPageRect;
76 SwSidebarItem_list* mList;
77 SwPostItPageItem(): bScrollbar(false), eSidebarPosition( sw::sidebarwindows::SIDEBAR_LEFT ), lOffset(0)
79 mList = new SwSidebarItem_list;
81 ~SwPostItPageItem()
83 mList->clear();
84 delete mList;
89 struct FieldShadowState
91 const SwPostItField* mpShadowFld;
92 bool bCursor;
93 bool bMouse;
94 FieldShadowState(): mpShadowFld(0),bCursor(false),bMouse(false)
99 class SwNoteProps: public utl::ConfigItem
101 private:
102 bool bIsShowAnchor;
103 public:
104 SwNoteProps()
105 : ConfigItem(OUString("Office.Writer/Notes"))
106 , bIsShowAnchor(false)
108 const ::com::sun::star::uno::Sequence< OUString >& rNames = GetPropertyNames();
109 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > aValues = GetProperties(rNames);
110 const ::com::sun::star::uno::Any* pValues = aValues.getConstArray();
111 OSL_ENSURE(aValues.getLength() == rNames.getLength(), "GetProperties failed");
112 if (aValues.getLength())
113 pValues[0]>>=bIsShowAnchor;
116 bool IsShowAnchor()
118 return bIsShowAnchor;
120 ::com::sun::star::uno::Sequence< OUString >& GetPropertyNames()
122 static ::com::sun::star::uno::Sequence< OUString > aNames;
123 if(!aNames.getLength())
125 aNames.realloc(1);
126 OUString* pNames = aNames.getArray();
127 pNames[0] = OUString("ShowAnkor");
129 return aNames;
132 virtual void Commit();
133 virtual void Notify( const ::com::sun::star::uno::Sequence< OUString >& aPropertyNames );
136 class SwPostItMgr: public SfxListener
138 private:
139 SwView* mpView;
140 SwWrtShell* mpWrtShell;
141 SwEditWin* mpEditWin;
142 std::list< SwSidebarItem*> mvPostItFlds;
143 std::vector<SwPostItPageItem*> mPages;
144 sal_uLong mnEventId;
145 bool mbWaitingForCalcRects;
146 sw::sidebarwindows::SwSidebarWin* mpActivePostIt;
147 bool mbLayout;
148 long mbLayoutHeight;
149 long mbLayouting;
150 bool mbReadOnly;
151 bool mbDeleteNote;
152 FieldShadowState mShadowState;
153 OutlinerParaObject* mpAnswer;
154 bool mbIsShowAnchor;
156 // data structure to collect the <SwSidebarWin> instances for certain <SwFrm> instances.
157 sw::sidebarwindows::SwFrmSidebarWinContainer* mpFrmSidebarWinContainer;
159 typedef std::list<sw::sidebarwindows::SwSidebarWin*>::iterator SwSidebarWin_iterator;
161 void AddPostIts(bool bCheckExistance = true,bool bFocus = true);
162 void RemoveSidebarWin();
163 void PreparePageContainer();
164 void Scroll(const long lScroll,const unsigned long aPage );
165 void AutoScroll(const sw::sidebarwindows::SwSidebarWin* pPostIt,const unsigned long aPage );
166 bool ScrollbarHit(const unsigned long aPage,const Point &aPoint);
167 bool LayoutByPage( std::list<sw::sidebarwindows::SwSidebarWin*> &aVisiblePostItList,
168 const Rectangle aBorder,
169 long lNeededHeight);
170 void CheckForRemovedPostIts();
171 bool ArrowEnabled(sal_uInt16 aDirection,unsigned long aPage) const;
172 bool BorderOverPageBorder(unsigned long aPage) const;
173 bool HasScrollbars() const;
174 void Focus(SfxBroadcaster& rBC);
176 sal_Int32 GetInitialAnchorDistance() const;
177 sal_Int32 GetScrollSize() const;
178 sal_Int32 GetSpaceBetween() const;
179 void SetReadOnlyState();
180 DECL_LINK( CalcHdl, void*);
182 sw::sidebarwindows::SwSidebarWin* GetSidebarWin(const SfxBroadcaster* pBroadcaster) const;
184 void InsertItem( SfxBroadcaster* pItem, bool bCheckExistance, bool bFocus);
185 void RemoveItem( SfxBroadcaster* pBroadcast );
187 void Sort(const short aType);
189 public:
190 SwPostItMgr(SwView* aDoc);
191 ~SwPostItMgr();
193 typedef std::list< SwSidebarItem* >::const_iterator const_iterator;
194 const_iterator begin() const { return mvPostItFlds.begin(); }
195 const_iterator end() const { return mvPostItFlds.end(); }
197 void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
199 void LayoutPostIts();
200 bool CalcRects();
202 void MakeVisible( const sw::sidebarwindows::SwSidebarWin* pPostIt,
203 long aPage = -1);
205 bool ShowScrollbar(const unsigned long aPage) const;
206 bool HasNotes() const ;
207 bool ShowNotes() const;
208 bool IsShowAnchor() { return mbIsShowAnchor;}
209 unsigned long GetSidebarWidth(bool bPx = false) const;
210 unsigned long GetSidebarBorderWidth(bool bPx = false) const;
211 unsigned long GetNoteWidth();
213 void PrepareView(bool bIgnoreCount = false);
215 void CorrectPositions();
217 void SetLayout() { mbLayout = true; };
218 void Delete(String aAuthor);
219 void Delete();
221 void Hide( const String& rAuthor );
222 void Hide();
223 void Show();
225 void Rescale();
227 Rectangle GetBottomScrollRect(const unsigned long aPage) const;
228 Rectangle GetTopScrollRect(const unsigned long aPage) const;
230 bool IsHit(const Point &aPointPixel);
231 Color GetArrowColor(sal_uInt16 aDirection,unsigned long aPage) const;
233 sw::annotation::SwAnnotationWin* GetAnnotationWin(const SwPostItField* pFld) const;
235 sw::sidebarwindows::SwSidebarWin* GetNextPostIt( sal_uInt16 aDirection,
236 sw::sidebarwindows::SwSidebarWin* aPostIt);
237 long GetNextBorder();
239 sw::sidebarwindows::SwSidebarWin* GetActiveSidebarWin() { return mpActivePostIt; }
240 void SetActiveSidebarWin( sw::sidebarwindows::SwSidebarWin* p);
241 bool HasActiveSidebarWin() const;
242 bool HasActiveAnnotationWin() const;
243 void GrabFocusOnActiveSidebarWin();
244 void UpdateDataOnActiveSidebarWin();
245 void DeleteActiveSidebarWin();
246 void HideActiveSidebarWin();
247 void ToggleInsModeOnActiveSidebarWin();
249 sal_Int32 GetMinimumSizeWithMeta() const;
250 sal_Int32 GetSidebarScrollerHeight() const;
252 void SetShadowState(const SwPostItField* pFld,bool bCursor = true);
254 void SetSpellChecking();
256 static Color GetColorDark(sal_uInt16 aAuthorIndex);
257 static Color GetColorLight(sal_uInt16 aAuthorIndex);
258 static Color GetColorAnchor(sal_uInt16 aAuthorIndex);
261 void RegisterAnswer(OutlinerParaObject* pAnswer) { mpAnswer = pAnswer;}
262 OutlinerParaObject* IsAnswer() {return mpAnswer;}
263 void CheckMetaText();
264 void StartSpelling();
266 sal_uInt16 Replace(SvxSearchItem* pItem);
267 sal_uInt16 SearchReplace(const SwFmtFld &pFld, const ::com::sun::star::util::SearchOptions& rSearchOptions,bool bSrchForward);
268 sal_uInt16 FinishSearchReplace(const ::com::sun::star::util::SearchOptions& rSearchOptions,bool bSrchForward);
270 void AssureStdModeAtShell();
272 void ConnectSidebarWinToFrm( const SwFrm& rFrm,
273 const SwFmtFld& rFmtFld,
274 sw::sidebarwindows::SwSidebarWin& rSidebarWin );
275 void DisconnectSidebarWinFromFrm( const SwFrm& rFrm,
276 sw::sidebarwindows::SwSidebarWin& rSidebarWin );
277 bool HasFrmConnectedSidebarWins( const SwFrm& rFrm );
278 Window* GetSidebarWinForFrmByIndex( const SwFrm& rFrm,
279 const sal_Int32 nIndex );
280 void GetAllSidebarWinForFrm( const SwFrm& rFrm,
281 std::vector< Window* >* pChildren );
284 #endif
289 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */