Line data Source code
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 <list>
24 : #include <vector>
25 : #include <editeng/outlobj.hxx>
26 : #include <rtl/ustring.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>
35 :
36 : class OutputDevice;
37 : class SwWrtShell;
38 : class SwDoc;
39 : class SwView;
40 : class SwPostItField;
41 : class SwFmtFld;
42 : class SwField;
43 : class SfxBroadcaster;
44 : class SfxHint;
45 : class SwEditWin;
46 : class Color;
47 : class SfxItemPool;
48 : class SfxItemSet;
49 : class SvxSearchItem;
50 : class SvxLanguageItem;
51 : namespace sw { namespace annotation {
52 : class SwAnnotationWin;
53 : }}
54 : namespace sw { namespace sidebarwindows {
55 : class SwSidebarWin;
56 : class SwFrmSidebarWinContainer;
57 : }}
58 : class SwSidebarItem;
59 : class SwFrm;
60 : namespace vcl { class Window; }
61 : struct ImplSVEvent;
62 :
63 : #define COL_NOTES_SIDEPANE_ARROW_ENABLED RGB_COLORDATA(0,0,0)
64 : #define COL_NOTES_SIDEPANE_ARROW_DISABLED RGB_COLORDATA(172,168,153)
65 :
66 : typedef std::list<SwSidebarItem*> SwSidebarItem_list;
67 : typedef std::list<SwSidebarItem*>::iterator SwSidebarItem_iterator;
68 :
69 : struct SwPostItPageItem
70 : {
71 : bool bScrollbar;
72 : sw::sidebarwindows::SidebarPosition eSidebarPosition;
73 : long lOffset;
74 : SwRect mPageRect;
75 : SwSidebarItem_list* mList;
76 6856 : SwPostItPageItem(): bScrollbar(false), eSidebarPosition( sw::sidebarwindows::SIDEBAR_LEFT ), lOffset(0)
77 : {
78 6856 : mList = new SwSidebarItem_list;
79 6856 : }
80 6856 : ~SwPostItPageItem()
81 : {
82 6856 : mList->clear();
83 6856 : delete mList;
84 6856 : }
85 :
86 : };
87 :
88 : struct FieldShadowState
89 : {
90 : const SwPostItField* mpShadowFld;
91 : bool bCursor;
92 : bool bMouse;
93 4708 : FieldShadowState(): mpShadowFld(0),bCursor(false),bMouse(false)
94 : {
95 4708 : }
96 : };
97 :
98 4708 : class SwNoteProps: public utl::ConfigItem
99 : {
100 : private:
101 : bool bIsShowAnchor;
102 : public:
103 4708 : SwNoteProps()
104 : : ConfigItem(OUString("Office.Writer/Notes"))
105 4708 : , bIsShowAnchor(false)
106 : {
107 4708 : const ::com::sun::star::uno::Sequence< OUString >& rNames = GetPropertyNames();
108 4708 : ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > aValues = GetProperties(rNames);
109 4708 : const ::com::sun::star::uno::Any* pValues = aValues.getConstArray();
110 : SAL_WARN_IF(aValues.getLength() != rNames.getLength(), "sw", "GetProperties failed");
111 4708 : if (aValues.getLength())
112 4708 : pValues[0]>>=bIsShowAnchor;
113 4708 : }
114 :
115 4708 : bool IsShowAnchor()
116 : {
117 4708 : return bIsShowAnchor;
118 : }
119 4708 : ::com::sun::star::uno::Sequence< OUString >& GetPropertyNames()
120 : {
121 4708 : static ::com::sun::star::uno::Sequence< OUString > aNames;
122 4708 : if(!aNames.getLength())
123 : {
124 84 : aNames.realloc(1);
125 84 : OUString* pNames = aNames.getArray();
126 84 : pNames[0] = OUString("ShowAnkor");
127 : }
128 4708 : return aNames;
129 : }
130 :
131 : virtual void Commit() SAL_OVERRIDE;
132 : virtual void Notify( const ::com::sun::star::uno::Sequence< OUString >& aPropertyNames ) SAL_OVERRIDE;
133 : };
134 :
135 : class SwPostItMgr: public SfxListener
136 : {
137 : private:
138 : SwView* mpView;
139 : SwWrtShell* mpWrtShell;
140 : SwEditWin* mpEditWin;
141 : std::list< SwSidebarItem*> mvPostItFlds;
142 : std::vector<SwPostItPageItem*> mPages;
143 : ImplSVEvent * mnEventId;
144 : bool mbWaitingForCalcRects;
145 : sw::sidebarwindows::SwSidebarWin* mpActivePostIt;
146 : bool mbLayout;
147 : long mbLayoutHeight;
148 : bool mbLayouting;
149 : bool mbReadOnly;
150 : bool mbDeleteNote;
151 : FieldShadowState mShadowState;
152 : OutlinerParaObject* mpAnswer;
153 : bool mbIsShowAnchor;
154 :
155 : // data structure to collect the <SwSidebarWin> instances for certain <SwFrm> instances.
156 : sw::sidebarwindows::SwFrmSidebarWinContainer* mpFrmSidebarWinContainer;
157 :
158 : typedef std::list<sw::sidebarwindows::SwSidebarWin*>::iterator SwSidebarWin_iterator;
159 :
160 : void AddPostIts(bool bCheckExistance = true,bool bFocus = true);
161 : void RemoveSidebarWin();
162 : void PreparePageContainer();
163 : void Scroll(const long lScroll,const unsigned long aPage );
164 : void AutoScroll(const sw::sidebarwindows::SwSidebarWin* pPostIt,const unsigned long aPage );
165 : bool ScrollbarHit(const unsigned long aPage,const Point &aPoint);
166 : bool LayoutByPage( std::list<sw::sidebarwindows::SwSidebarWin*> &aVisiblePostItList,
167 : const Rectangle aBorder,
168 : long lNeededHeight);
169 : void CheckForRemovedPostIts();
170 : bool ArrowEnabled(sal_uInt16 aDirection,unsigned long aPage) const;
171 : bool BorderOverPageBorder(unsigned long aPage) const;
172 : bool HasScrollbars() const;
173 : void Focus(SfxBroadcaster& rBC);
174 :
175 : sal_Int32 GetInitialAnchorDistance() const;
176 : sal_Int32 GetScrollSize() const;
177 : sal_Int32 GetSpaceBetween() const;
178 : void SetReadOnlyState();
179 : DECL_LINK( CalcHdl, void*);
180 :
181 : sw::sidebarwindows::SwSidebarWin* GetSidebarWin(const SfxBroadcaster* pBroadcaster) const;
182 :
183 : void InsertItem( SfxBroadcaster* pItem, bool bCheckExistance, bool bFocus);
184 : void RemoveItem( SfxBroadcaster* pBroadcast );
185 :
186 : void Sort();
187 :
188 : public:
189 : SwPostItMgr(SwView* aDoc);
190 : virtual ~SwPostItMgr();
191 :
192 : typedef std::list< SwSidebarItem* >::const_iterator const_iterator;
193 162 : const_iterator begin() const { return mvPostItFlds.begin(); }
194 162 : const_iterator end() const { return mvPostItFlds.end(); }
195 :
196 : void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) SAL_OVERRIDE;
197 :
198 : void LayoutPostIts();
199 : bool CalcRects();
200 :
201 : void MakeVisible( const sw::sidebarwindows::SwSidebarWin* pPostIt,
202 : long aPage = -1);
203 :
204 : bool ShowScrollbar(const unsigned long aPage) const;
205 : bool HasNotes() const ;
206 : bool ShowNotes() const;
207 0 : bool IsShowAnchor() { return mbIsShowAnchor;}
208 : unsigned long GetSidebarWidth(bool bPx = false) const;
209 : unsigned long GetSidebarBorderWidth(bool bPx = false) const;
210 : unsigned long GetNoteWidth();
211 :
212 : void PrepareView(bool bIgnoreCount = false);
213 :
214 : void CorrectPositions();
215 :
216 0 : void SetLayout() { mbLayout = true; };
217 : void Delete(const OUString& aAuthor);
218 : void Delete();
219 :
220 : void ExecuteFormatAllDialog(SwView& rView);
221 : void FormatAll(const SfxItemSet &rNewAttr);
222 :
223 : void Hide( const OUString& rAuthor );
224 : void Hide();
225 : void Show();
226 :
227 : void Rescale();
228 :
229 : Rectangle GetBottomScrollRect(const unsigned long aPage) const;
230 : Rectangle GetTopScrollRect(const unsigned long aPage) const;
231 :
232 : bool IsHit(const Point &aPointPixel);
233 : Color GetArrowColor(sal_uInt16 aDirection,unsigned long aPage) const;
234 :
235 : sw::annotation::SwAnnotationWin* GetAnnotationWin(const SwPostItField* pFld) const;
236 :
237 : sw::sidebarwindows::SwSidebarWin* GetNextPostIt( sal_uInt16 aDirection,
238 : sw::sidebarwindows::SwSidebarWin* aPostIt);
239 : long GetNextBorder();
240 :
241 42 : sw::sidebarwindows::SwSidebarWin* GetActiveSidebarWin() { return mpActivePostIt; }
242 : void SetActiveSidebarWin( sw::sidebarwindows::SwSidebarWin* p);
243 : bool HasActiveSidebarWin() const;
244 : bool HasActiveAnnotationWin() const;
245 : void GrabFocusOnActiveSidebarWin();
246 : void UpdateDataOnActiveSidebarWin();
247 : void DeleteActiveSidebarWin();
248 : void HideActiveSidebarWin();
249 : void ToggleInsModeOnActiveSidebarWin();
250 :
251 : sal_Int32 GetMinimumSizeWithMeta() const;
252 : sal_Int32 GetSidebarScrollerHeight() const;
253 :
254 : void SetShadowState(const SwPostItField* pFld,bool bCursor = true);
255 :
256 : void SetSpellChecking();
257 :
258 : static Color GetColorDark(sal_uInt16 aAuthorIndex);
259 : static Color GetColorLight(sal_uInt16 aAuthorIndex);
260 : static Color GetColorAnchor(sal_uInt16 aAuthorIndex);
261 :
262 0 : void RegisterAnswer(OutlinerParaObject* pAnswer) { mpAnswer = pAnswer;}
263 0 : OutlinerParaObject* IsAnswer() {return mpAnswer;}
264 : void CheckMetaText();
265 : void StartSpelling();
266 :
267 : sal_uInt16 Replace(SvxSearchItem* pItem);
268 : sal_uInt16 SearchReplace(const SwFmtFld &pFld, const ::com::sun::star::util::SearchOptions& rSearchOptions,bool bSrchForward);
269 : sal_uInt16 FinishSearchReplace(const ::com::sun::star::util::SearchOptions& rSearchOptions,bool bSrchForward);
270 :
271 : // get the PostIt window by index
272 : sal_Int32 GetPostItCount() const {return mvPostItFlds.size();}
273 : void AssureStdModeAtShell();
274 :
275 : void ConnectSidebarWinToFrm( const SwFrm& rFrm,
276 : const SwFmtFld& rFmtFld,
277 : sw::sidebarwindows::SwSidebarWin& rSidebarWin );
278 : void DisconnectSidebarWinFromFrm( const SwFrm& rFrm,
279 : sw::sidebarwindows::SwSidebarWin& rSidebarWin );
280 : bool HasFrmConnectedSidebarWins( const SwFrm& rFrm );
281 : vcl::Window* GetSidebarWinForFrmByIndex( const SwFrm& rFrm,
282 : const sal_Int32 nIndex );
283 : void GetAllSidebarWinForFrm( const SwFrm& rFrm,
284 : std::vector< vcl::Window* >* pChildren );
285 :
286 : void DrawNotesForPage(OutputDevice *pOutDev, sal_uInt32 nPage);
287 : };
288 :
289 : #endif
290 :
291 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|