Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _POSTITMGR_HXX
30 : : #define _POSTITMGR_HXX
31 : :
32 : : #include <list>
33 : : #include <vector>
34 : : #include <editeng/outlobj.hxx>
35 : : #include <tools/string.hxx>
36 : : #include <tools/link.hxx>
37 : : #include <swrect.hxx>
38 : : #include <unotools/configitem.hxx>
39 : : #include <unotools/options.hxx>
40 : : #include <com/sun/star/util/SearchOptions.hpp>
41 : : #include <com/sun/star/uno/Any.hxx>
42 : : #include <SidebarWindowsTypes.hxx>
43 : : #include <svl/lstner.hxx>
44 : :
45 : : class SwWrtShell;
46 : : class SwDoc;
47 : : class SwView;
48 : : class SwPostItField;
49 : : class SwFmtFld;
50 : : class SwField;
51 : : class SfxBroadcaster;
52 : : class SfxHint;
53 : : class SwEditWin;
54 : : class Color;
55 : : class SvxSearchItem;
56 : : class SvxLanguageItem;
57 : : namespace sw { namespace annotation {
58 : : class SwAnnotationWin;
59 : : }}
60 : : namespace sw { namespace sidebarwindows {
61 : : class SwSidebarWin;
62 : : class SwFrmSidebarWinContainer;
63 : : }}
64 : : class SwSidebarItem;
65 : : class SwFrm;
66 : : class Window;
67 : :
68 : : #define SORT_POS 1
69 : : #define SORT_AUTHOR 2
70 : : #define SORT_DATE 3
71 : :
72 : : #define COL_NOTES_SIDEPANE_ARROW_ENABLED RGB_COLORDATA(0,0,0)
73 : : #define COL_NOTES_SIDEPANE_ARROW_DISABLED RGB_COLORDATA(172,168,153)
74 : :
75 : : typedef std::list<SwSidebarItem*> SwSidebarItem_list;
76 : : typedef std::list<SwSidebarItem*>::iterator SwSidebarItem_iterator;
77 : :
78 : :
79 : : struct SwPostItPageItem
80 : : {
81 : : bool bScrollbar;
82 : : sw::sidebarwindows::SidebarPosition eSidebarPosition;
83 : : long lOffset;
84 : : SwRect mPageRect;
85 : : SwSidebarItem_list* mList;
86 : 1413 : SwPostItPageItem(): bScrollbar(false), eSidebarPosition( sw::sidebarwindows::SIDEBAR_LEFT ), lOffset(0)
87 : : {
88 [ + - ]: 1413 : mList = new SwSidebarItem_list;
89 : 1413 : }
90 : 1320 : ~SwPostItPageItem()
91 : : {
92 : 1320 : mList->clear();
93 [ + - ]: 1320 : delete mList;
94 : 1320 : }
95 : :
96 : : };
97 : :
98 : : struct FieldShadowState
99 : : {
100 : : const SwPostItField* mpShadowFld;
101 : : bool bCursor;
102 : : bool bMouse;
103 : 1318 : FieldShadowState(): mpShadowFld(0),bCursor(false),bMouse(false)
104 : : {
105 : 1318 : }
106 : : };
107 : :
108 [ - + ]: 1318 : class SwNoteProps: public utl::ConfigItem
109 : : {
110 : : private:
111 : : bool bIsShowAnchor;
112 : : public:
113 : 1318 : SwNoteProps()
114 : : : ConfigItem(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Office.Writer/Notes")))
115 [ + - ]: 1318 : , bIsShowAnchor(false)
116 : : {
117 [ + - ]: 1318 : const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rNames = GetPropertyNames();
118 [ + - ]: 1318 : ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > aValues = GetProperties(rNames);
119 : 1318 : const ::com::sun::star::uno::Any* pValues = aValues.getConstArray();
120 : : OSL_ENSURE(aValues.getLength() == rNames.getLength(), "GetProperties failed");
121 [ + - ]: 1318 : if (aValues.getLength())
122 [ + - ]: 1318 : pValues[0]>>=bIsShowAnchor;
123 : 1318 : }
124 : :
125 : 1318 : bool IsShowAnchor()
126 : : {
127 : 1318 : return bIsShowAnchor;
128 : : }
129 : 1318 : ::com::sun::star::uno::Sequence< ::rtl::OUString >& GetPropertyNames()
130 : : {
131 [ + + ][ + - ]: 1318 : static ::com::sun::star::uno::Sequence< ::rtl::OUString > aNames;
[ + - ][ # # ]
132 [ + + ]: 1318 : if(!aNames.getLength())
133 : : {
134 : 67 : aNames.realloc(1);
135 : 67 : ::rtl::OUString* pNames = aNames.getArray();
136 : 67 : pNames[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShowAnkor"));
137 : : }
138 : 1318 : return aNames;
139 : : }
140 : :
141 : : virtual void Commit();
142 : : virtual void Notify( const ::com::sun::star::uno::Sequence< rtl::OUString >& aPropertyNames );
143 : : };
144 : :
145 : : class SwPostItMgr: public SfxListener
146 : : {
147 : : private:
148 : : SwView* mpView;
149 : : SwWrtShell* mpWrtShell;
150 : : SwEditWin* mpEditWin;
151 : : std::list< SwSidebarItem*> mvPostItFlds;
152 : : std::vector<SwPostItPageItem*> mPages;
153 : : sal_uLong mnEventId;
154 : : bool mbWaitingForCalcRects;
155 : : sw::sidebarwindows::SwSidebarWin* mpActivePostIt;
156 : : bool mbLayout;
157 : : long mbLayoutHeight;
158 : : long mbLayouting;
159 : : bool mbReadOnly;
160 : : bool mbDeleteNote;
161 : : FieldShadowState mShadowState;
162 : : OutlinerParaObject* mpAnswer;
163 : : bool mbIsShowAnchor;
164 : :
165 : : // data structure to collect the <SwSidebarWin> instances for certain <SwFrm> instances.
166 : : sw::sidebarwindows::SwFrmSidebarWinContainer* mpFrmSidebarWinContainer;
167 : :
168 : : typedef std::list<sw::sidebarwindows::SwSidebarWin*>::iterator SwSidebarWin_iterator;
169 : :
170 : : void AddPostIts(bool bCheckExistance = true,bool bFocus = true);
171 : : void RemoveSidebarWin();
172 : : void PreparePageContainer();
173 : : void Scroll(const long lScroll,const unsigned long aPage );
174 : : void AutoScroll(const sw::sidebarwindows::SwSidebarWin* pPostIt,const unsigned long aPage );
175 : : bool ScrollbarHit(const unsigned long aPage,const Point &aPoint);
176 : : bool LayoutByPage( std::list<sw::sidebarwindows::SwSidebarWin*> &aVisiblePostItList,
177 : : const Rectangle aBorder,
178 : : long lNeededHeight);
179 : : void CheckForRemovedPostIts();
180 : : bool ArrowEnabled(sal_uInt16 aDirection,unsigned long aPage) const;
181 : : bool BorderOverPageBorder(unsigned long aPage) const;
182 : : bool HasScrollbars() const;
183 : : void Focus(SfxBroadcaster& rBC);
184 : :
185 : : sal_Int32 GetInitialAnchorDistance() const;
186 : : sal_Int32 GetScrollSize() const;
187 : : sal_Int32 GetSpaceBetween() const;
188 : : void SetReadOnlyState();
189 : : DECL_LINK( CalcHdl, void*);
190 : :
191 : : sw::sidebarwindows::SwSidebarWin* GetSidebarWin(const SfxBroadcaster* pBroadcaster) const;
192 : :
193 : : void InsertItem( SfxBroadcaster* pItem, bool bCheckExistance, bool bFocus);
194 : : void RemoveItem( SfxBroadcaster* pBroadcast );
195 : :
196 : : void Sort(const short aType);
197 : :
198 : : public:
199 : : SwPostItMgr(SwView* aDoc);
200 : : ~SwPostItMgr();
201 : :
202 : : typedef std::list< SwSidebarItem* >::const_iterator const_iterator;
203 : 0 : const_iterator begin() const { return mvPostItFlds.begin(); }
204 : 0 : const_iterator end() const { return mvPostItFlds.end(); }
205 : :
206 : : void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
207 : :
208 : : void LayoutPostIts();
209 : : bool CalcRects();
210 : :
211 : : void MakeVisible( const sw::sidebarwindows::SwSidebarWin* pPostIt,
212 : : long aPage = -1);
213 : :
214 : : bool ShowScrollbar(const unsigned long aPage) const;
215 : : bool HasNotes() const ;
216 : : bool ShowNotes() const;
217 : 0 : bool IsShowAnchor() { return mbIsShowAnchor;}
218 : : unsigned long GetSidebarWidth(bool bPx = false) const;
219 : : unsigned long GetSidebarBorderWidth(bool bPx = false) const;
220 : : unsigned long GetNoteWidth();
221 : :
222 : : void PrepareView(bool bIgnoreCount = false);
223 : :
224 : : void CorrectPositions();
225 : :
226 : 0 : void SetLayout() { mbLayout = true; };
227 : : void Delete(String aAuthor);
228 : : void Delete();
229 : :
230 : : void Hide( const String& rAuthor );
231 : : void Hide();
232 : : void Show();
233 : :
234 : : void Rescale();
235 : :
236 : : Rectangle GetBottomScrollRect(const unsigned long aPage) const;
237 : : Rectangle GetTopScrollRect(const unsigned long aPage) const;
238 : :
239 : : bool IsHit(const Point &aPointPixel);
240 : : Color GetArrowColor(sal_uInt16 aDirection,unsigned long aPage) const;
241 : :
242 : : sw::annotation::SwAnnotationWin* GetAnnotationWin(const SwPostItField* pFld) const;
243 : :
244 : : sw::sidebarwindows::SwSidebarWin* GetNextPostIt( sal_uInt16 aDirection,
245 : : sw::sidebarwindows::SwSidebarWin* aPostIt);
246 : : long GetNextBorder();
247 : :
248 : 10 : sw::sidebarwindows::SwSidebarWin* GetActiveSidebarWin() { return mpActivePostIt; }
249 : : void SetActiveSidebarWin( sw::sidebarwindows::SwSidebarWin* p);
250 : : bool HasActiveSidebarWin() const;
251 : : bool HasActiveAnnotationWin() const;
252 : : void GrabFocusOnActiveSidebarWin();
253 : : void UpdateDataOnActiveSidebarWin();
254 : : void DeleteActiveSidebarWin();
255 : : void HideActiveSidebarWin();
256 : : void ToggleInsModeOnActiveSidebarWin();
257 : :
258 : : sal_Int32 GetMinimumSizeWithMeta() const;
259 : : sal_Int32 GetSidebarScrollerHeight() const;
260 : :
261 : : void SetShadowState(const SwPostItField* pFld,bool bCursor = true);
262 : :
263 : : void SetSpellChecking();
264 : :
265 : : static Color GetColorDark(sal_uInt16 aAuthorIndex);
266 : : static Color GetColorLight(sal_uInt16 aAuthorIndex);
267 : : static Color GetColorAnchor(sal_uInt16 aAuthorIndex);
268 : :
269 : :
270 : 0 : void RegisterAnswer(OutlinerParaObject* pAnswer) { mpAnswer = pAnswer;}
271 : 0 : OutlinerParaObject* IsAnswer() {return mpAnswer;}
272 : : void CheckMetaText();
273 : : void StartSpelling();
274 : :
275 : : sal_uInt16 Replace(SvxSearchItem* pItem);
276 : : sal_uInt16 SearchReplace(const SwFmtFld &pFld, const ::com::sun::star::util::SearchOptions& rSearchOptions,bool bSrchForward);
277 : : sal_uInt16 FinishSearchReplace(const ::com::sun::star::util::SearchOptions& rSearchOptions,bool bSrchForward);
278 : :
279 : : void AssureStdModeAtShell();
280 : :
281 : : void ConnectSidebarWinToFrm( const SwFrm& rFrm,
282 : : const SwFmtFld& rFmtFld,
283 : : sw::sidebarwindows::SwSidebarWin& rSidebarWin );
284 : : void DisconnectSidebarWinFromFrm( const SwFrm& rFrm,
285 : : sw::sidebarwindows::SwSidebarWin& rSidebarWin );
286 : : bool HasFrmConnectedSidebarWins( const SwFrm& rFrm );
287 : : Window* GetSidebarWinForFrmByIndex( const SwFrm& rFrm,
288 : : const sal_Int32 nIndex );
289 : : void GetAllSidebarWinForFrm( const SwFrm& rFrm,
290 : : std::vector< Window* >* pChildren );
291 : : };
292 : :
293 : : #endif
294 : :
295 : :
296 : :
297 : :
298 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|