merge the formfield patch from ooo-build
[ooovba.git] / sw / inc / PostItMgr.hxx
blobf71c0f3e23e876b68c46409b0003fb60c86b3345
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: PostItMgr.hxx,v $
10 * $Revision: 1.8.84.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _POSTITMGR_HXX
32 #define _POSTITMGR_HXX
34 #include <svtools/lstner.hxx>
36 #include <list>
37 #include <vector>
38 #include <svx/outlobj.hxx>
39 #include <tools/string.hxx>
40 #include <tools/link.hxx>
41 #include <tools/debug.hxx>
42 #include <swrect.hxx>
43 #include <unotools/configitem.hxx>
44 #include <com/sun/star/util/SearchOptions.hpp>
45 #include <com/sun/star/uno/Any.hxx>
47 class SwWrtShell;
48 class SwDoc;
49 class SwView;
50 class SwPostItField;
51 class SwFmtFld;
52 class SwField;
53 class SfxBroadcaster;
54 class SfxHint;
55 class SwEditWin;
56 class Color;
57 class SvxSearchItem;
58 class SvxLanguageItem;
59 class SwPostIt;
60 class SwMarginWin;
61 class SwMarginItem;
63 #define SORT_POS 1
64 #define SORT_AUTHOR 2
65 #define SORT_DATE 3
67 #define COL_NOTES_SIDEPANE_ARROW_ENABLED RGB_COLORDATA(0,0,0)
68 #define COL_NOTES_SIDEPANE_ARROW_DISABLED RGB_COLORDATA(172,168,153)
70 typedef std::list<SwMarginItem*> SwMarginItem_list;
71 typedef std::list<SwMarginItem*>::iterator SwMarginItem_iterator;
73 using namespace ::com::sun::star;
74 using namespace ::com::sun::star::uno;
75 using ::rtl::OUString;
77 struct SwPostItPageItem
79 bool bScrollbar;
80 bool bMarginSide;
81 long lOffset;
82 SwRect mPageRect;
83 SwMarginItem_list* mList;
84 SwPostItPageItem(): bScrollbar(false),lOffset(0)
86 mList = new SwMarginItem_list;
88 ~SwPostItPageItem()
90 mList->clear();
91 delete mList;
96 struct FieldShadowState
98 const SwPostItField* mpShadowFld;
99 bool bCursor;
100 bool bMouse;
101 FieldShadowState(): mpShadowFld(0),bCursor(false),bMouse(false)
106 class SwNoteProps: public utl::ConfigItem
108 private:
109 bool bIsShowAnkor;
110 public:
111 SwNoteProps() : ConfigItem(::rtl::OUString::createFromAscii("Office.Writer/Notes")), bIsShowAnkor(false)
113 const Sequence<OUString>& rNames = GetPropertyNames();
114 Sequence<Any> aValues = GetProperties(rNames);
115 const Any* pValues = aValues.getConstArray();
116 DBG_ASSERT(aValues.getLength() == rNames.getLength(), "GetProperties failed");
117 if (aValues.getLength())
118 pValues[0]>>=bIsShowAnkor;
121 bool IsShowAnkor()
123 return bIsShowAnkor;
125 Sequence<OUString>& GetPropertyNames()
127 static Sequence<OUString> aNames;
128 if(!aNames.getLength())
130 static const char* aPropNames[] =
132 "ShowAnkor"
134 const int nCount = sizeof(aPropNames)/sizeof(const char*);
135 aNames.realloc(nCount);
136 OUString* pNames = aNames.getArray();
137 for(int i = 0; i < nCount; i++)
138 pNames[i] = OUString::createFromAscii(aPropNames[i]);
140 return aNames;
144 class SwPostItMgr: public SfxListener
146 private:
147 SwView* mpView;
148 SwWrtShell* mpWrtShell;
149 SwEditWin* mpEditWin;
150 std::list< SwMarginItem*> mvPostItFlds;
151 std::vector<SwPostItPageItem*> mPages;
152 ULONG mnEventId;
153 bool mbWaitingForCalcRects;
154 SwMarginWin* mpActivePostIt;
155 bool mbLayout;
156 long mbLayoutHeight;
157 long mbLayouting;
158 bool mbReadOnly;
159 bool mbDeleteNote;
160 FieldShadowState mShadowState;
161 OutlinerParaObject* mpAnswer;
162 bool mpIsShowAnkor;
164 typedef std::list<SwMarginWin*>::iterator SwMarginWin_iterator;
166 void AddPostIts(bool bCheckExistance = true,bool bFocus = true);
167 //void AddRedlineComments(bool bCheckExistance, bool bFocus);
168 void RemoveMarginWin();
169 void PreparePageContainer();
170 void Scroll(const long lScroll,const unsigned long aPage );
171 void AutoScroll(const SwMarginWin* pPostIt,const unsigned long aPage );
172 bool ScrollbarHit(const unsigned long aPage,const Point &aPoint);
173 bool LayoutByPage(std::list<SwMarginWin*> &aVisiblePostItList,const Rectangle aBorder,long lNeededHeight);
174 void CheckForRemovedPostIts();
175 bool ArrowEnabled(USHORT aDirection,unsigned long aPage) const;
176 bool BorderOverPageBorder(unsigned long aPage) const;
177 bool HasScrollbars() const;
178 void Focus(SfxBroadcaster& rBC);
180 sal_Int32 GetInitialAnchorDistance() const;
181 sal_Int32 GetScrollSize() const;
182 sal_Int32 GetSpaceBetween() const;
183 void SetReadOnlyState();
184 DECL_LINK( CalcHdl, void*);
185 protected:
187 public:
188 SwPostItMgr(SwView* aDoc);
189 ~SwPostItMgr();
191 typedef std::list< SwMarginItem* >::const_iterator const_iterator;
192 const_iterator begin() const { return mvPostItFlds.begin(); }
193 const_iterator end() const { return mvPostItFlds.end(); }
195 void InsertItem( SfxBroadcaster* pItem, bool bCheckExistance, bool bFocus);
196 void RemoveItem( SfxBroadcaster* pBroadcast );
197 void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
199 void LayoutPostIts();
200 bool CalcRects();
202 void MakeVisible(const SwMarginWin* pPostIt,long aPage = -1);
204 bool ShowScrollbar(const unsigned long aPage) const;
205 bool HasNotes() const ;
206 bool ShowNotes() const;
207 bool IsShowAnkor() { return mpIsShowAnkor;}
208 unsigned long GetSidebarWidth(bool bPx = false) const;
209 unsigned long GetSidebarBorderWidth(bool bPx = false) const;
210 unsigned long GetNoteWidth();
212 void PrepareView(bool bIgnoreCount = false);
214 void CorrectPositions();
216 void Sort(const short aType);
218 void SetLayout() { mbLayout = true; };
219 void Delete(String aAuthor);
220 void Delete();
222 void Hide( SwPostItField* pPostItField );
223 void Hide( const String& rAuthor );
224 void Hide();
225 void Show();
227 void Rescale();
229 Rectangle GetBottomScrollRect(const unsigned long aPage) const;
230 Rectangle GetTopScrollRect(const unsigned long aPage) const;
232 bool IsHit(const Point &aPointPixel);
233 Color GetArrowColor(USHORT aDirection,unsigned long aPage) const;
235 SwMarginWin* GetNextPostIt(USHORT aDirection, SwMarginWin* aPostIt);
236 long GetNextBorder();
237 SwMarginWin* GetActivePostIt() { return mpActivePostIt; }
238 void SetActivePostIt( SwMarginWin* p);
239 sal_Int32 GetMinimumSizeWithMeta() const;
240 sal_Int32 GetSidebarScrollerHeight() const;
242 SwMarginWin* GetPostIt(const SfxBroadcaster* pBroadcaster) const;
243 SwMarginWin* GetPostIt(SfxBroadcaster* pBroadcaster) const;
244 SwPostIt* GetPostIt(const SwPostItField* pFld) const;
245 SwPostIt* GetPostIt(SwPostItField* pFld) const;
247 void SetShadowState(const SwPostItField* pFld,bool bCursor = true);
249 void SetSpellChecking();
251 Color GetColorDark(sal_uInt16 aAuthorIndex);
252 Color GetColorLight(sal_uInt16 aAuthorIndex);
253 Color GetColorAnkor(sal_uInt16 aAuthorIndex);
255 bool ShowPreview(const SwField* pFld,SwFmtFld*& pFmtFld) const;
257 void RegisterAnswer(OutlinerParaObject* pAnswer) { mpAnswer = pAnswer;}
258 OutlinerParaObject* IsAnswer() {return mpAnswer;}
259 void CheckMetaText();
260 void StartSpelling();
262 sal_uInt16 Replace(SvxSearchItem* pItem);
263 sal_uInt16 SearchReplace(const SwFmtFld &pFld, const ::com::sun::star::util::SearchOptions& rSearchOptions,bool bSrchForward);
264 sal_uInt16 FinishSearchReplace(const ::com::sun::star::util::SearchOptions& rSearchOptions,bool bSrchForward);
266 void AssureStdModeAtShell();
269 #endif