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 : :
30 : : #include "PostItMgr.hxx"
31 : : #include <postithelper.hxx>
32 : :
33 : : #include <SidebarWin.hxx>
34 : : #include <AnnotationWin.hxx>
35 : : #include <frmsidebarwincontainer.hxx>
36 : : #include <accmap.hxx>
37 : :
38 : : #include <SidebarWindowsConsts.hxx>
39 : : #include <AnchorOverlayObject.hxx>
40 : : #include <ShadowOverlayObject.hxx>
41 : :
42 : : #include <vcl/svapp.hxx>
43 : : #include <vcl/scrbar.hxx>
44 : : #include <vcl/outdev.hxx>
45 : :
46 : : #include <viewopt.hxx>
47 : :
48 : : #include <view.hxx>
49 : : #include <docsh.hxx>
50 : : #include <wrtsh.hxx>
51 : : #include <doc.hxx>
52 : : #include <fldbas.hxx>
53 : : #include <fmtfld.hxx>
54 : : #include <docufld.hxx>
55 : : #include <edtwin.hxx>
56 : : #include <txtfld.hxx>
57 : : #include <ndtxt.hxx>
58 : : #include <redline.hxx>
59 : : #include <docary.hxx>
60 : : #include <SwRewriter.hxx>
61 : : #include <tools/color.hxx>
62 : :
63 : : #include <swmodule.hxx>
64 : : #include <annotation.hrc>
65 : : #include "cmdid.h"
66 : :
67 : : #include <sfx2/request.hxx>
68 : : #include <sfx2/event.hxx>
69 : : #include <svl/srchitem.hxx>
70 : :
71 : :
72 : : #include <svl/languageoptions.hxx>
73 : : #include <svtools/langtab.hxx>
74 : : #include <svl/smplhint.hxx>
75 : :
76 : : #include <svx/svdview.hxx>
77 : : #include <editeng/eeitem.hxx>
78 : : #include <editeng/langitem.hxx>
79 : : #include <editeng/outliner.hxx>
80 : :
81 : : #include <i18npool/mslangid.hxx>
82 : : #include <i18npool/lang.h>
83 : :
84 : : #include "swevent.hxx"
85 : : #include "switerator.hxx"
86 : :
87 : : // distance between Anchor Y and initial note position
88 : : #define POSTIT_INITIAL_ANCHOR_DISTANCE 20
89 : : //distance between two postits
90 : : #define POSTIT_SPACE_BETWEEN 8
91 : : #define POSTIT_MINIMUMSIZE_WITH_META 60
92 : : #define POSTIT_SCROLL_SIDEBAR_HEIGHT 20
93 : :
94 : : // if we layout more often we stop, this should never happen
95 : : #define MAX_LOOP_COUNT 50
96 : :
97 : : using namespace sw::sidebarwindows;
98 : :
99 : 0 : bool comp_pos(const SwSidebarItem* a, const SwSidebarItem* b)
100 : : {
101 : : // sort by anchor position
102 [ # # ][ # # ]: 0 : return a->GetAnchorPosition() < b->GetAnchorPosition();
[ # # ]
103 : : }
104 : :
105 : 1318 : SwPostItMgr::SwPostItMgr(SwView* pView)
106 : : : mpView(pView)
107 [ + - ]: 1318 : , mpWrtShell(mpView->GetDocShell()->GetWrtShell())
108 : 1318 : , mpEditWin(&mpView->GetEditWin())
109 : : , mnEventId(0)
110 : : , mbWaitingForCalcRects(false)
111 : : , mpActivePostIt(0)
112 : : , mbLayout(false)
113 : : , mbLayoutHeight(0)
114 : : , mbLayouting(false)
115 [ + - ][ + - ]: 1318 : , mbReadOnly(mpView->GetDocShell()->IsReadOnly())
116 : : , mbDeleteNote(true)
117 : : , mpAnswer(0)
118 : : , mbIsShowAnchor( false )
119 [ + - ][ + - ]: 3954 : , mpFrmSidebarWinContainer( 0 )
120 : : {
121 [ + + ][ + - ]: 1318 : if(!mpView->GetDrawView() )
122 [ + - ]: 746 : mpView->GetWrtShell().MakeDrawView();
123 : :
124 [ + - ]: 1318 : SwNoteProps aProps;
125 : 1318 : mbIsShowAnchor = aProps.IsShowAnchor();
126 : :
127 : : //make sure we get the colour yellow always, even if not the first one of comments or redlining
128 [ + - ][ + - ]: 1318 : SW_MOD()->GetRedlineAuthor();
129 : :
130 : : // collect all PostIts and redline comments that exist after loading the document
131 : : // don't check for existance for any of them, don't focus them
132 [ + - ]: 1318 : AddPostIts(false,false);
133 : : /* this code can be used once we want redline comments in the Sidebar
134 : : AddRedlineComments(false,false);
135 : : */
136 : : // we want to receive stuff like SFX_HINT_DOCCHANGED
137 [ + - ][ + - ]: 1318 : StartListening(*mpView->GetDocShell());
138 [ + + ]: 1318 : if (!mvPostItFlds.empty())
139 : : {
140 : 18 : mbWaitingForCalcRects = true;
141 [ + - ][ + - ]: 18 : mnEventId = Application::PostUserEvent( LINK( this, SwPostItMgr, CalcHdl), 0 );
142 [ + - ]: 1318 : }
143 : 1318 : }
144 : :
145 : 1231 : SwPostItMgr::~SwPostItMgr()
146 : : {
147 [ - + ]: 1231 : if ( mnEventId )
148 [ # # ]: 0 : Application::RemoveUserEvent( mnEventId );
149 : : // forget about all our Sidebar windows
150 [ + - ]: 1231 : RemoveSidebarWin();
151 [ + - ][ + - ]: 1231 : EndListening( *mpView->GetDocShell() );
152 : :
153 [ + - ][ + + ]: 2541 : for(std::vector<SwPostItPageItem*>::iterator i = mPages.begin(); i!= mPages.end() ; ++i)
154 [ + - ]: 1310 : delete (*i);
155 : 1231 : mPages.clear();
156 : :
157 [ + - ][ + + ]: 1231 : delete mpFrmSidebarWinContainer;
158 : 1231 : mpFrmSidebarWinContainer = 0;
159 [ - + ]: 2462 : }
160 : :
161 : 0 : void SwPostItMgr::CheckForRemovedPostIts()
162 : : {
163 : 0 : bool bRemoved = false;
164 [ # # ]: 0 : for(std::list<SwSidebarItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end(); )
165 : : {
166 : 0 : std::list<SwSidebarItem*>::iterator it = i++;
167 [ # # ][ # # ]: 0 : if ( !(*it)->UseElement() )
168 : : {
169 : 0 : SwSidebarItem* p = (*it);
170 [ # # ]: 0 : mvPostItFlds.remove(*it);
171 [ # # ]: 0 : if (GetActiveSidebarWin() == p->pPostIt)
172 [ # # ]: 0 : SetActiveSidebarWin(0);
173 [ # # ]: 0 : if (p->pPostIt)
174 [ # # ][ # # ]: 0 : delete p->pPostIt;
175 [ # # ][ # # ]: 0 : delete p;
176 : 0 : bRemoved = true;
177 : : }
178 : : }
179 : :
180 [ # # ]: 0 : if ( bRemoved )
181 : : {
182 : : // make sure that no deleted items remain in page lists
183 : : // todo: only remove deleted ones?!
184 [ # # ]: 0 : if ( mvPostItFlds.empty() )
185 : : {
186 : 0 : PreparePageContainer();
187 : 0 : PrepareView();
188 : : }
189 : : else
190 : : // if postits are their make sure that page lists are not empty
191 : : // otherwise sudden paints can cause pain (in BorderOverPageBorder)
192 : 0 : CalcRects();
193 : : }
194 : 0 : }
195 : :
196 : 18 : void SwPostItMgr::InsertItem(SfxBroadcaster* pItem, bool bCheckExistance, bool bFocus)
197 : : {
198 [ - + ]: 18 : if (bCheckExistance)
199 : : {
200 [ # # ]: 0 : for(std::list<SwSidebarItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; ++i)
201 : : {
202 [ # # ][ # # ]: 0 : if ( (*i)->GetBroadCaster() == pItem )
203 : 18 : return;
204 : : }
205 : : }
206 : 18 : mbLayout = bFocus;
207 [ + - ]: 18 : if (pItem->ISA(SwFmtFld))
208 [ + - ][ + - ]: 18 : mvPostItFlds.push_back(new SwAnnotationItem(static_cast<SwFmtFld*>(pItem), true, bFocus) );
209 : : OSL_ENSURE(pItem->ISA(SwFmtFld),"Mgr::InsertItem: seems like new stuff was added");
210 : 18 : StartListening(*pItem);
211 : : }
212 : :
213 : 0 : void SwPostItMgr::RemoveItem( SfxBroadcaster* pBroadcast )
214 : : {
215 : 0 : EndListening(*pBroadcast);
216 [ # # ]: 0 : for(std::list<SwSidebarItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; ++i)
217 : : {
218 [ # # ][ # # ]: 0 : if ( (*i)->GetBroadCaster() == pBroadcast )
219 : : {
220 : 0 : SwSidebarItem* p = (*i);
221 [ # # ]: 0 : if (GetActiveSidebarWin() == p->pPostIt)
222 [ # # ]: 0 : SetActiveSidebarWin(0);
223 [ # # ]: 0 : mvPostItFlds.remove(*i);
224 [ # # ][ # # ]: 0 : delete p->pPostIt;
225 [ # # ][ # # ]: 0 : delete p;
226 : 0 : break;
227 : : }
228 : : }
229 : 0 : mbLayout = true;
230 : 0 : PrepareView();
231 : 0 : }
232 : :
233 : 45657 : void SwPostItMgr::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
234 : : {
235 [ + + ]: 45657 : if ( rHint.IsA(TYPE(SfxEventHint) ) )
236 : : {
237 : 11548 : sal_uInt32 nId = ((SfxEventHint&)rHint).GetEventId();
238 [ + + ]: 11548 : if ( nId == SW_EVENT_LAYOUT_FINISHED )
239 : : {
240 [ + - ][ + + ]: 1528 : if ( !mbWaitingForCalcRects && !mvPostItFlds.empty())
[ + + ]
241 : : {
242 : 3 : mbWaitingForCalcRects = true;
243 [ + - ]: 3 : mnEventId = Application::PostUserEvent( LINK( this, SwPostItMgr, CalcHdl), 0 );
244 : : }
245 : : }
246 : : }
247 [ + + ]: 34109 : else if ( rHint.IsA(TYPE(SfxSimpleHint) ) )
248 : : {
249 : 34091 : sal_uInt32 nId = ((SfxSimpleHint&)rHint).GetId();
250 [ + + - - : 34091 : switch ( nId )
+ ]
251 : : {
252 : : case SFX_HINT_MODECHANGED:
253 : : {
254 [ - + ]: 6 : if ( mbReadOnly != !!(mpView->GetDocShell()->IsReadOnly()) )
255 : : {
256 : 0 : mbReadOnly = !mbReadOnly;
257 : 0 : SetReadOnlyState();
258 : 0 : mbLayout = true;
259 : : }
260 : 6 : break;
261 : : }
262 : : case SFX_HINT_DOCCHANGED:
263 : : {
264 [ + - ]: 31066 : if ( mpView->GetDocShell() == &rBC )
265 : : {
266 [ + - ][ + + ]: 31066 : if ( !mbWaitingForCalcRects && !mvPostItFlds.empty())
[ + + ]
267 : : {
268 : 18 : mbWaitingForCalcRects = true;
269 [ + - ]: 18 : mnEventId = Application::PostUserEvent( LINK( this, SwPostItMgr, CalcHdl), 0 );
270 : : }
271 : : }
272 : 31066 : break;
273 : : }
274 : : case SFX_HINT_USER04:
275 : : {
276 : : // if we are in a SplitNode/Cut operation, do not delete note and then add again, as this will flicker
277 : 0 : mbDeleteNote = !mbDeleteNote;
278 : 0 : break;
279 : : }
280 : : case SFX_HINT_DYING:
281 : : {
282 [ # # ]: 0 : if ( mpView->GetDocShell() != &rBC )
283 : : {
284 : : // field to be removed is the broadcaster
285 : : OSL_FAIL("Notification for removed SwFmtFld was not sent!");
286 : 0 : RemoveItem(&rBC);
287 : : }
288 : 34091 : break;
289 : : }
290 : : }
291 : : }
292 [ + - ]: 18 : else if ( rHint.IsA(TYPE(SwFmtFldHint) ) )
293 : : {
294 : 18 : const SwFmtFldHint& rFmtHint = static_cast<const SwFmtFldHint&>(rHint);
295 : 18 : SwFmtFld* pFld = const_cast <SwFmtFld*>( rFmtHint.GetField() );
296 [ - - - - : 18 : switch ( rFmtHint.Which() )
+ - ]
297 : : {
298 : : case SWFMTFLD_INSERTED :
299 : : {
300 [ # # ]: 0 : if (!pFld)
301 : : {
302 : 0 : AddPostIts(true);
303 : 0 : break;
304 : : }
305 : : // get field to be inserted from hint
306 [ # # ]: 0 : if ( pFld->IsFldInDoc() )
307 : : {
308 : 0 : bool bEmpty = !HasNotes();
309 [ # # ]: 0 : InsertItem( pFld, true, false );
310 [ # # ][ # # ]: 0 : if (bEmpty && !mvPostItFlds.empty())
[ # # ]
311 : 0 : PrepareView(true);
312 : : }
313 : : else
314 : : {
315 : : OSL_FAIL("Inserted field not in document!" );
316 : : }
317 : 0 : break;
318 : : }
319 : : case SWFMTFLD_REMOVED:
320 : : {
321 [ # # ]: 0 : if (mbDeleteNote)
322 : : {
323 [ # # ]: 0 : if (!pFld)
324 : : {
325 : 0 : CheckForRemovedPostIts();
326 : 0 : break;
327 : : }
328 [ # # ]: 0 : RemoveItem(pFld);
329 : : }
330 : 0 : break;
331 : : }
332 : : case SWFMTFLD_FOCUS:
333 : : {
334 [ # # ]: 0 : if (rFmtHint.GetView()== mpView)
335 : 0 : Focus(rBC);
336 : 0 : break;
337 : : }
338 : : case SWFMTFLD_CHANGED:
339 : : {
340 [ # # ]: 0 : SwFmtFld* pFmtFld = dynamic_cast<SwFmtFld*>(&rBC);
341 [ # # ]: 0 : for(std::list<SwSidebarItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; ++i)
342 : : {
343 [ # # ][ # # ]: 0 : if ( pFmtFld == (*i)->GetBroadCaster() )
[ # # ]
344 : : {
345 [ # # ]: 0 : if ((*i)->pPostIt)
346 : : {
347 [ # # ]: 0 : (*i)->pPostIt->SetPostItText();
348 : 0 : mbLayout = true;
349 : : }
350 : 0 : break;
351 : : }
352 : : }
353 : 0 : break;
354 : : }
355 : : case SWFMTFLD_LANGUAGE:
356 : : {
357 [ - + ]: 18 : SwFmtFld* pFmtFld = dynamic_cast<SwFmtFld*>(&rBC);
358 [ + - ]: 18 : for(std::list<SwSidebarItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; ++i)
359 : : {
360 [ + - ][ + - ]: 18 : if ( pFmtFld == (*i)->GetBroadCaster() )
[ + - ]
361 : : {
362 [ - + ]: 18 : if ((*i)->pPostIt)
363 : : {
364 [ # # ][ # # ]: 0 : sal_uInt16 nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage( (*i)->GetFmtFld()->GetFld()->GetLanguage() );
365 : 0 : sal_uInt16 nLangWhichId = 0;
366 [ # # # # ]: 0 : switch (nScriptType)
367 : : {
368 : 0 : case SCRIPTTYPE_LATIN : nLangWhichId = EE_CHAR_LANGUAGE ; break;
369 : 0 : case SCRIPTTYPE_ASIAN : nLangWhichId = EE_CHAR_LANGUAGE_CJK; break;
370 : 0 : case SCRIPTTYPE_COMPLEX : nLangWhichId = EE_CHAR_LANGUAGE_CTL; break;
371 : : }
372 [ # # ]: 0 : (*i)->pPostIt->SetLanguage( SvxLanguageItem((*i)->GetFmtFld()->GetFld()->GetLanguage(),
373 [ # # ]: 0 : nLangWhichId) );
[ # # # # ]
374 : : }
375 : 18 : break;
376 : : }
377 : : }
378 : 18 : break;
379 : : }
380 : : }
381 : : }
382 : 45657 : }
383 : :
384 : 0 : void SwPostItMgr::Focus(SfxBroadcaster& rBC)
385 : : {
386 [ # # ]: 0 : if (!mpWrtShell->GetViewOptions()->IsPostIts())
387 : : {
388 [ # # ]: 0 : SfxRequest aRequest(mpView->GetViewFrame(),FN_VIEW_NOTES);
389 [ # # ][ # # ]: 0 : mpView->ExecViewOptions(aRequest);
390 : : }
391 : :
392 [ # # ]: 0 : for(std::list<SwSidebarItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; ++i)
393 : : {
394 : : // field to get the focus is the broadcaster
395 [ # # ][ # # ]: 0 : if ( &rBC == (*i)->GetBroadCaster() )
396 : : {
397 [ # # ]: 0 : if ((*i)->pPostIt)
398 : : {
399 [ # # ]: 0 : (*i)->pPostIt->GrabFocus();
400 [ # # ]: 0 : MakeVisible((*i)->pPostIt);
401 : : }
402 : : else
403 : : {
404 : : // when the layout algorithm starts, this postit is created and receives focus
405 : 0 : (*i)->bFocus = true;
406 : : }
407 : : }
408 : : }
409 : 0 : }
410 : :
411 : 5456 : bool SwPostItMgr::CalcRects()
412 : : {
413 [ + + ]: 5456 : if ( mnEventId )
414 : : {
415 : : // if CalcRects() was forced and an event is still pending: remove it
416 : : // it is superfluous and also may cause reentrance problems if triggered while layouting
417 : 36 : Application::RemoveUserEvent( mnEventId );
418 : 36 : mnEventId = 0;
419 : : }
420 : :
421 : 5456 : bool bChange = false;
422 : 5456 : bool bRepair = false;
423 : 5456 : PreparePageContainer();
424 [ + + ]: 5456 : if ( !mvPostItFlds.empty() )
425 : : {
426 [ + + ]: 198 : for(std::list<SwSidebarItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; ++i)
427 : : {
428 : 99 : SwSidebarItem* pItem = (*i);
429 [ - + ][ + - ]: 99 : if ( !pItem->UseElement() )
430 : : {
431 : : OSL_FAIL("PostIt is not in doc or other wrong use");
432 : 0 : bRepair = true;
433 : 0 : continue;
434 : : }
435 : :
436 : : //save old rect and visible state
437 : 99 : SwRect aOldRect(pItem->maLayoutInfo.mPosition);
438 : 99 : SwPostItHelper::SwLayoutStatus eOldStatus = pItem->mLayoutStatus;
439 [ + - ]: 99 : std::vector< SwLayoutInfo > aInfo;
440 : : {
441 [ + - ]: 99 : SwPosition aPosition = pItem->GetAnchorPosition();
442 [ + - ][ + - ]: 99 : pItem->mLayoutStatus = SwPostItHelper::getLayoutInfos( aInfo, aPosition );
443 : : }
444 [ + + ]: 99 : if( !aInfo.empty() )
445 : : {
446 : 81 : pItem->maLayoutInfo = aInfo[0];
447 : : }
448 : : bChange = bChange ||
449 : 99 : ( pItem->maLayoutInfo.mPosition != aOldRect ) ||
450 [ + - + + ]: 198 : ( eOldStatus != pItem->mLayoutStatus );
[ - + ]
451 : 99 : }
452 : :
453 : : // show notes in right order in navigator
454 : : //prevent Anchors during layout to overlap, e.g. when moving a frame
455 : 99 : Sort(SORT_POS);
456 : :
457 : : // sort the items into the right page vector, so layout can be done by page
458 [ + + ]: 198 : for(std::list<SwSidebarItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; ++i)
459 : : {
460 : 99 : SwSidebarItem* pItem = (*i);
461 [ + + ]: 99 : if( SwPostItHelper::INVISIBLE == pItem->mLayoutStatus )
462 : : {
463 [ - + ]: 18 : if (pItem->pPostIt)
464 [ # # ]: 0 : pItem->pPostIt->HideNote();
465 : 18 : continue;
466 : : }
467 : :
468 [ - + ]: 81 : if( SwPostItHelper::HIDDEN == pItem->mLayoutStatus )
469 : : {
470 [ # # ]: 0 : if (!mpWrtShell->GetViewOptions()->IsShowHiddenChar())
471 : : {
472 [ # # ]: 0 : if (pItem->pPostIt)
473 [ # # ]: 0 : pItem->pPostIt->HideNote();
474 : 0 : continue;
475 : : }
476 : : }
477 : :
478 : 81 : const unsigned long aPageNum = pItem->maLayoutInfo.mnPageNumber;
479 [ - + ]: 81 : if (aPageNum > mPages.size())
480 : : {
481 : 0 : const unsigned long nNumberOfPages = mPages.size();
482 [ # # ]: 0 : for (unsigned int j=0; j<aPageNum - nNumberOfPages; ++j)
483 [ # # ][ # # ]: 0 : mPages.push_back( new SwPostItPageItem());
[ # # ]
484 : : }
485 [ + - ]: 81 : mPages[aPageNum-1]->mList->push_back(pItem);
486 : 81 : mPages[aPageNum-1]->mPageRect = pItem->maLayoutInfo.mPageFrame;
487 : 99 : mPages[aPageNum-1]->eSidebarPosition = pItem->maLayoutInfo.meSidebarPosition;
488 : : }
489 : :
490 [ + + ][ - + ]: 99 : if (!bChange && mpWrtShell->getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE))
[ - + ]
491 : : {
492 : 0 : long nLayoutHeight = SwPostItHelper::getLayoutHeight( mpWrtShell->GetLayout() );
493 [ # # ]: 0 : if( nLayoutHeight > mbLayoutHeight )
494 : : {
495 [ # # ][ # # ]: 0 : if (mPages[0]->bScrollbar || HasScrollbars())
[ # # ]
496 : 0 : bChange = true;
497 : : }
498 [ # # ]: 0 : else if( nLayoutHeight < mbLayoutHeight )
499 : : {
500 [ # # ][ # # ]: 0 : if (mPages[0]->bScrollbar || !BorderOverPageBorder(1))
[ # # ]
501 : 0 : bChange = true;
502 : : }
503 : : }
504 : : }
505 : :
506 [ - + ]: 5456 : if ( bRepair )
507 : 0 : CheckForRemovedPostIts();
508 : :
509 : 5456 : mbLayoutHeight = SwPostItHelper::getLayoutHeight( mpWrtShell->GetLayout() );
510 : 5456 : mbWaitingForCalcRects = false;
511 : 5456 : return bChange;
512 : : }
513 : :
514 : 0 : bool SwPostItMgr::HasScrollbars() const
515 : : {
516 [ # # ]: 0 : for(std::list<SwSidebarItem*>::const_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; ++i)
517 : : {
518 [ # # ][ # # ]: 0 : if ((*i)->bShow && (*i)->pPostIt && (*i)->pPostIt->HasScrollbar())
[ # # ][ # # ]
[ # # ]
519 : 0 : return true;
520 : : }
521 : 0 : return false;
522 : : }
523 : :
524 : 6687 : void SwPostItMgr::PreparePageContainer()
525 : : {
526 : : // we do not just delete the SwPostItPageItem, so offset/scrollbar is not lost
527 : 6687 : long lPageSize = mpWrtShell->GetNumPages();
528 : 6687 : long lContainerSize = mPages.size();
529 : :
530 [ + + ]: 6687 : if (lContainerSize < lPageSize)
531 : : {
532 [ + + ]: 2760 : for (int i=0; i<lPageSize - lContainerSize;i++)
533 [ + - ][ + - ]: 1413 : mPages.push_back( new SwPostItPageItem());
534 : : }
535 : : else
536 [ + + ]: 5340 : if (lContainerSize > lPageSize)
537 : : {
538 [ + + ]: 18 : for (int i=mPages.size()-1; i >= lPageSize;--i)
539 : : {
540 [ + - ]: 10 : delete mPages[i];
541 : 10 : mPages.pop_back();
542 : : }
543 : : }
544 : : // only clear the list, DO NOT delete the objects itself
545 [ + - ][ + + ]: 14093 : for(std::vector<SwPostItPageItem*>::iterator i = mPages.begin(); i!= mPages.end() ; ++i)
546 : : {
547 : 7406 : (*i)->mList->clear();
548 [ + + ]: 7406 : if (mvPostItFlds.empty())
549 : 7307 : (*i)->bScrollbar = false;
550 : :
551 : : }
552 : 6687 : }
553 : :
554 : 5453 : void SwPostItMgr::LayoutPostIts()
555 : : {
556 [ + + ][ + - ]: 5453 : if ( !mvPostItFlds.empty() && !mbWaitingForCalcRects )
[ + + ]
557 : : {
558 : 96 : mbLayouting = true;
559 : :
560 : : //loop over all pages and do the layout
561 : : // - create SwPostIt if neccessary
562 : : // - place SwPostIts on their initial position
563 : : // - calculate neccessary height for all PostIts together
564 : 96 : bool bUpdate = false;
565 [ + + ]: 192 : for (unsigned long n=0;n<mPages.size();n++)
566 : : {
567 : : // only layout if there are notes on this page
568 [ + + ]: 96 : if (mPages[n]->mList->size()>0)
569 : : {
570 [ + - ]: 78 : std::list<SwSidebarWin*> aVisiblePostItList;
571 : 78 : unsigned long lNeededHeight = 0;
572 : 78 : long mlPageBorder = 0;
573 : 78 : long mlPageEnd = 0;
574 : :
575 [ + + ]: 156 : for(SwSidebarItem_iterator i = mPages[n]->mList->begin(); i!= mPages[n]->mList->end(); i++)
576 : : {
577 : 78 : SwSidebarItem* pItem = (*i);
578 : 78 : SwSidebarWin* pPostIt = pItem->pPostIt;
579 : :
580 [ - + ]: 78 : if (mPages[n]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_LEFT )
581 : : {
582 : : // x value for notes positioning
583 [ # # ][ # # ]: 0 : mlPageBorder = mpEditWin->LogicToPixel( Point( mPages[n]->mPageRect.Left(), 0)).X() - GetSidebarWidth(true);// - GetSidebarBorderWidth(true);
584 : : //bending point
585 : : mlPageEnd =
586 [ # # ][ # # ]: 0 : mpWrtShell->getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE)
587 : 0 : ? pItem->maLayoutInfo.mPagePrtArea.Left()
588 [ # # ]: 0 : : mPages[n]->mPageRect.Left() + 350;
589 : : }
590 [ + - ]: 78 : else if (mPages[n]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_RIGHT )
591 : : {
592 : : // x value for notes positioning
593 [ + - ][ + - ]: 78 : mlPageBorder = mpEditWin->LogicToPixel( Point(mPages[n]->mPageRect.Right(), 0)).X() + GetSidebarBorderWidth(true);
594 : : //bending point
595 : : mlPageEnd =
596 [ + - ][ + - ]: 78 : mpWrtShell->getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE)
597 : 0 : ? pItem->maLayoutInfo.mPagePrtArea.Right() :
598 [ - + ]: 78 : mPages[n]->mPageRect.Right() - 350;
599 : : }
600 : :
601 [ + - ]: 78 : if (pItem->bShow)
602 : : {
603 [ + - ]: 78 : long Y = mpEditWin->LogicToPixel( Point(0,pItem->maLayoutInfo.mPosition.Bottom())).Y();
604 : 78 : long aPostItHeight = 0;
605 [ + + ]: 78 : if (!pPostIt)
606 : : {
607 : 18 : pPostIt = (*i)->GetSidebarWindow( mpView->GetEditWin(),
608 : : WB_DIALOGCONTROL,
609 : : *this,
610 [ + - ]: 18 : 0 );
611 [ + - ]: 18 : pPostIt->InitControls();
612 [ + - ]: 18 : pPostIt->SetReadonly(mbReadOnly);
613 : 18 : pItem->pPostIt = pPostIt;
614 [ - + ]: 18 : if (mpAnswer)
615 : : {
616 [ # # ][ # # ]: 0 : if (pPostIt->CalcFollow()) //do we really have another note in front of this one
617 [ # # ]: 0 : static_cast<sw::annotation::SwAnnotationWin*>(pPostIt)->InitAnswer(mpAnswer);
618 [ # # ][ # # ]: 0 : delete mpAnswer;
619 : 0 : mpAnswer = 0;
620 : : }
621 : : }
622 : :
623 : : pPostIt->SetChangeTracking(
624 : : pItem->mLayoutStatus,
625 [ + - ][ + - ]: 78 : GetColorAnchor(pItem->maLayoutInfo.mRedlineAuthor));
626 [ + - ]: 78 : pPostIt->SetSidebarPosition(mPages[n]->eSidebarPosition);
627 [ + - ]: 78 : pPostIt->SetFollow(pPostIt->CalcFollow());
628 [ + - ][ + - ]: 78 : aPostItHeight = ( pPostIt->GetPostItTextHeight() < pPostIt->GetMinimumSizeWithoutMeta()
629 : 78 : ? pPostIt->GetMinimumSizeWithoutMeta()
630 : 0 : : pPostIt->GetPostItTextHeight() )
631 [ + - ][ + - ]: 78 : + pPostIt->GetMetaHeight();
[ # # ][ + - ]
632 : : pPostIt->SetPosSizePixelRect( mlPageBorder ,
633 : 78 : Y - GetInitialAnchorDistance(),
634 [ + - ]: 78 : GetNoteWidth() ,
635 : : aPostItHeight,
636 : : pItem->maLayoutInfo.mPosition,
637 [ + - ]: 78 : mlPageEnd );
638 [ + - ]: 78 : pPostIt->ChangeSidebarItem( *pItem );
639 : :
640 [ - + ]: 78 : if (pItem->bFocus)
641 : : {
642 : 0 : mbLayout = true;
643 [ # # ]: 0 : pPostIt->GrabFocus();
644 : 0 : pItem->bFocus = false;
645 : : }
646 : : // only the visible postits are used for the final layout
647 [ + - ]: 78 : aVisiblePostItList.push_back(pPostIt);
648 [ - + ]: 78 : lNeededHeight += pPostIt->IsFollow() ? aPostItHeight : aPostItHeight+GetSpaceBetween();
649 : : }
650 : : else // we don't want to see it
651 : : {
652 [ # # ]: 0 : if (pPostIt)
653 [ # # ]: 0 : pPostIt->HideNote();
654 : : }
655 : : }
656 : :
657 [ + - ][ + - ]: 78 : if ((!aVisiblePostItList.empty()) && ShowNotes())
[ + - ]
658 : : {
659 : 78 : bool bOldScrollbar = mPages[n]->bScrollbar;
660 [ + - ]: 78 : if (ShowNotes())
661 [ + - ][ + - ]: 78 : mPages[n]->bScrollbar = LayoutByPage(aVisiblePostItList, mPages[n]->mPageRect.SVRect(), lNeededHeight);
662 : : else
663 : 0 : mPages[n]->bScrollbar = false;
664 [ + - ]: 78 : if (!mPages[n]->bScrollbar)
665 : : {
666 : 78 : mPages[n]->lOffset = 0;
667 : : }
668 : : else
669 : : {
670 : : //when we changed our zoom level, the offset value can be to big, so lets check for the largest possible zoom value
671 [ # # ]: 0 : long aAvailableHeight = mpEditWin->LogicToPixel(Size(0,mPages[n]->mPageRect.Height())).Height() - 2 * GetSidebarScrollerHeight();
672 : 0 : long lOffset = -1 * GetScrollSize() * (aVisiblePostItList.size() - aAvailableHeight / GetScrollSize());
673 [ # # ]: 0 : if (mPages[n]->lOffset < lOffset)
674 : 0 : mPages[n]->lOffset = lOffset;
675 : : }
676 [ + - ][ - + ]: 78 : bUpdate = (bOldScrollbar != mPages[n]->bScrollbar) || bUpdate;
677 [ - + ][ # # ]: 78 : const long aSidebarheight = mPages[n]->bScrollbar ? mpEditWin->PixelToLogic(Size(0,GetSidebarScrollerHeight())).Height() : 0;
[ - + ][ - + ]
[ # # # # ]
678 : : /*
679 : : TODO
680 : : - enlarge all notes till GetNextBorder(), as we resized to average value before
681 : : */
682 : : //lets hide the ones which overlap the page
683 [ + + ]: 156 : for(SwSidebarWin_iterator i = aVisiblePostItList.begin(); i!= aVisiblePostItList.end() ; i++)
684 : : {
685 [ - + ]: 78 : if (mPages[n]->lOffset != 0)
686 [ # # ]: 0 : (*i)->TranslateTopPosition(mPages[n]->lOffset);
687 : :
688 [ + - ][ + - ]: 78 : bool bBottom = mpEditWin->PixelToLogic(Point(0,(*i)->VirtualPos().Y()+(*i)->VirtualSize().Height())).Y() <= (mPages[n]->mPageRect.Bottom()-aSidebarheight);
689 [ + - ]: 78 : bool bTop = mpEditWin->PixelToLogic(Point(0,(*i)->VirtualPos().Y())).Y() >= (mPages[n]->mPageRect.Top()+aSidebarheight);
690 [ + - ][ + - ]: 78 : if ( bBottom && bTop )
691 : : {
692 [ + - ]: 78 : (*i)->ShowNote();
693 : : }
694 : : else
695 : : {
696 [ # # ][ # # ]: 0 : if (mpEditWin->PixelToLogic(Point(0,(*i)->VirtualPos().Y())).Y() < (mPages[n]->mPageRect.Top()+aSidebarheight))
697 : : {
698 [ # # ]: 0 : if ( mPages[n]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_LEFT )
699 : 0 : (*i)->ShowAnchorOnly(Point( mPages[n]->mPageRect.Left(),
700 [ # # ]: 0 : mPages[n]->mPageRect.Top()));
701 [ # # ]: 0 : else if ( mPages[n]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_RIGHT )
702 : 0 : (*i)->ShowAnchorOnly(Point( mPages[n]->mPageRect.Right(),
703 [ # # ]: 0 : mPages[n]->mPageRect.Top()));
704 : : }
705 : : else
706 : : {
707 [ # # ]: 0 : if ( mPages[n]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_LEFT )
708 : 0 : (*i)->ShowAnchorOnly(Point(mPages[n]->mPageRect.Left(),
709 [ # # ]: 0 : mPages[n]->mPageRect.Bottom()));
710 [ # # ]: 0 : else if ( mPages[n]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_RIGHT )
711 : 0 : (*i)->ShowAnchorOnly(Point(mPages[n]->mPageRect.Right(),
712 [ # # ]: 0 : mPages[n]->mPageRect.Bottom()));
713 : : }
714 : : OSL_ENSURE(mPages[n]->bScrollbar,"SwPostItMgr::LayoutByPage(): note overlaps, but bScrollbar is not true");
715 : : }
716 : : }
717 : : }
718 : : else
719 : : {
720 [ # # ]: 0 : for(SwSidebarWin_iterator i = aVisiblePostItList.begin(); i!= aVisiblePostItList.end() ; i++)
721 [ # # ]: 0 : (*i)->SetPosAndSize();
722 : :
723 : 0 : bool bOldScrollbar = mPages[n]->bScrollbar;
724 : 0 : mPages[n]->bScrollbar = false;
725 [ # # ][ # # ]: 0 : bUpdate = (bOldScrollbar != mPages[n]->bScrollbar) || bUpdate;
726 : : }
727 : 78 : aVisiblePostItList.clear();
728 : : }
729 : : else
730 : : {
731 : 18 : bUpdate = true;
732 : 18 : mPages[n]->bScrollbar = false;
733 : : }
734 : : }
735 : :
736 [ - + ]: 96 : if (!ShowNotes())
737 : : { // we do not want to see the notes anymore -> Options-Writer-View-Notes
738 : 0 : bool bRepair = false;
739 [ # # ]: 0 : for(SwSidebarItem_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++)
740 : : {
741 : 0 : SwSidebarItem* pItem = (*i);
742 [ # # ][ # # ]: 0 : if ( !pItem->UseElement() )
743 : : {
744 : : OSL_FAIL("PostIt is not in doc!");
745 : 0 : bRepair = true;
746 : 0 : continue;
747 : : }
748 : :
749 [ # # ]: 0 : if ((*i)->pPostIt)
750 : : {
751 [ # # ]: 0 : (*i)->pPostIt->HideNote();
752 [ # # ][ # # ]: 0 : if ((*i)->pPostIt->HasChildPathFocus())
753 : : {
754 [ # # ]: 0 : SetActiveSidebarWin(0);
755 [ # # ]: 0 : (*i)->pPostIt->GrabFocusToDocument();
756 : : }
757 : : }
758 : : }
759 : :
760 [ # # ]: 0 : if ( bRepair )
761 : 0 : CheckForRemovedPostIts();
762 : : }
763 : :
764 : :
765 : : // notes scrollbar is otherwise not drawn correctly for some cases
766 : : // scrollbar area is enough
767 [ + + ]: 96 : if (bUpdate)
768 : 18 : mpEditWin->Invalidate();
769 : 96 : mbLayouting = false;
770 : : }
771 : 5453 : }
772 : :
773 : 0 : bool SwPostItMgr::BorderOverPageBorder(unsigned long aPage) const
774 : : {
775 [ # # ]: 0 : if ( mPages[aPage-1]->mList->empty() )
776 : : {
777 : : OSL_FAIL("Notes SidePane painted but no rects and page lists calculated!");
778 : 0 : return false;
779 : : }
780 : :
781 : 0 : SwSidebarItem_iterator aItem = mPages[aPage-1]->mList->end();
782 : 0 : --aItem;
783 : : OSL_ENSURE ((*aItem)->pPostIt,"BorderOverPageBorder: NULL postIt, should never happen");
784 [ # # ]: 0 : if ((*aItem)->pPostIt)
785 : : {
786 [ # # ][ # # ]: 0 : const long aSidebarheight = mPages[aPage-1]->bScrollbar ? mpEditWin->PixelToLogic(Size(0,GetSidebarScrollerHeight())).Height() : 0;
[ # # ][ # # ]
[ # # # # ]
787 [ # # ][ # # ]: 0 : const long aEndValue = mpEditWin->PixelToLogic(Point(0,(*aItem)->pPostIt->GetPosPixel().Y()+(*aItem)->pPostIt->GetSizePixel().Height())).Y();
[ # # ]
788 : 0 : return aEndValue <= mPages[aPage-1]->mPageRect.Bottom()-aSidebarheight;
789 : : }
790 : : else
791 : 0 : return false;
792 : : }
793 : :
794 : 0 : void SwPostItMgr::Scroll(const long lScroll,const unsigned long aPage)
795 : : {
796 : : OSL_ENSURE((lScroll % GetScrollSize() )==0,"SwPostItMgr::Scroll: scrolling by wrong value");
797 : : // do not scroll more than neccessary up or down
798 [ # # ][ # # ]: 0 : if ( ((mPages[aPage-1]->lOffset == 0) && (lScroll>0)) || ( BorderOverPageBorder(aPage) && (lScroll<0)) )
[ # # ][ # # ]
[ # # ]
799 : 0 : return;
800 : :
801 : 0 : const bool bOldUp = ArrowEnabled(KEY_PAGEUP,aPage);
802 : 0 : const bool bOldDown = ArrowEnabled(KEY_PAGEDOWN,aPage);
803 [ # # ]: 0 : const long aSidebarheight = mpEditWin->PixelToLogic(Size(0,GetSidebarScrollerHeight())).Height();
804 [ # # ]: 0 : for(SwSidebarItem_iterator i = mPages[aPage-1]->mList->begin(); i!= mPages[aPage-1]->mList->end(); i++)
805 : : {
806 : 0 : SwSidebarWin* pPostIt = (*i)->pPostIt;
807 : : // if this is an answer, we should take the normal position and not the real, slightly moved position
808 [ # # ][ # # ]: 0 : pPostIt->SetVirtualPosSize(pPostIt->GetPosPixel(),pPostIt->GetSizePixel());
[ # # ]
809 [ # # ]: 0 : pPostIt->TranslateTopPosition(lScroll);
810 : :
811 [ # # ]: 0 : if ((*i)->bShow)
812 : : {
813 [ # # ][ # # ]: 0 : bool bBottom = mpEditWin->PixelToLogic(Point(0,pPostIt->VirtualPos().Y()+pPostIt->VirtualSize().Height())).Y() <= (mPages[aPage-1]->mPageRect.Bottom()-aSidebarheight);
814 [ # # ]: 0 : bool bTop = mpEditWin->PixelToLogic(Point(0,pPostIt->VirtualPos().Y())).Y() >= (mPages[aPage-1]->mPageRect.Top()+aSidebarheight);
815 [ # # ][ # # ]: 0 : if ( bBottom && bTop)
816 : : {
817 [ # # ]: 0 : pPostIt->ShowNote();
818 : : }
819 : : else
820 : : {
821 [ # # ][ # # ]: 0 : if ( mpEditWin->PixelToLogic(Point(0,pPostIt->VirtualPos().Y())).Y() < (mPages[aPage-1]->mPageRect.Top()+aSidebarheight))
822 : : {
823 [ # # ]: 0 : if (mPages[aPage-1]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_LEFT)
824 [ # # ]: 0 : pPostIt->ShowAnchorOnly(Point(mPages[aPage-1]->mPageRect.Left(),mPages[aPage-1]->mPageRect.Top()));
825 [ # # ]: 0 : else if (mPages[aPage-1]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_RIGHT)
826 [ # # ]: 0 : pPostIt->ShowAnchorOnly(Point(mPages[aPage-1]->mPageRect.Right(),mPages[aPage-1]->mPageRect.Top()));
827 : : }
828 : : else
829 : : {
830 [ # # ]: 0 : if (mPages[aPage-1]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_LEFT)
831 [ # # ]: 0 : pPostIt->ShowAnchorOnly(Point(mPages[aPage-1]->mPageRect.Left(),mPages[aPage-1]->mPageRect.Bottom()));
832 [ # # ]: 0 : else if (mPages[aPage-1]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_RIGHT)
833 [ # # ]: 0 : pPostIt->ShowAnchorOnly(Point(mPages[aPage-1]->mPageRect.Right(),mPages[aPage-1]->mPageRect.Bottom()));
834 : : }
835 : : }
836 : : }
837 : : }
838 : 0 : mPages[aPage-1]->lOffset += lScroll;
839 [ # # ][ # # ]: 0 : if ( (bOldUp != ArrowEnabled(KEY_PAGEUP,aPage)) ||(bOldDown != ArrowEnabled(KEY_PAGEDOWN,aPage)) )
[ # # ]
840 : : {
841 [ # # ]: 0 : mpEditWin->Invalidate(GetBottomScrollRect(aPage));
842 [ # # ]: 0 : mpEditWin->Invalidate(GetTopScrollRect(aPage));
843 : : }
844 : : }
845 : :
846 : 0 : void SwPostItMgr::AutoScroll(const SwSidebarWin* pPostIt,const unsigned long aPage )
847 : : {
848 : : // otherwise all notes are visible
849 [ # # ]: 0 : if (mPages[aPage-1]->bScrollbar)
850 : : {
851 [ # # ]: 0 : const long aSidebarheight = mpEditWin->PixelToLogic(Size(0,GetSidebarScrollerHeight())).Height();
852 [ # # ][ # # ]: 0 : const bool bBottom = mpEditWin->PixelToLogic(Point(0,pPostIt->GetPosPixel().Y()+pPostIt->GetSizePixel().Height())).Y() <= (mPages[aPage-1]->mPageRect.Bottom()-aSidebarheight);
853 [ # # ]: 0 : const bool bTop = mpEditWin->PixelToLogic(Point(0,pPostIt->GetPosPixel().Y())).Y() >= (mPages[aPage-1]->mPageRect.Top()+aSidebarheight);
854 [ # # ][ # # ]: 0 : if ( !(bBottom && bTop))
855 : : {
856 [ # # ][ # # ]: 0 : const long aDiff = bBottom ? mpEditWin->LogicToPixel(Point(0,mPages[aPage-1]->mPageRect.Top() + aSidebarheight)).Y() - pPostIt->GetPosPixel().Y() :
[ # # ][ # # ]
[ # # ][ # #
# # # # ]
857 [ # # ][ # # ]: 0 : mpEditWin->LogicToPixel(Point(0,mPages[aPage-1]->mPageRect.Bottom() - aSidebarheight)).Y() - (pPostIt->GetPosPixel().Y()+pPostIt->GetSizePixel().Height());
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # # #
# # # # ]
858 : : // this just adds the missing value to get the next a* GetScrollSize() after aDiff
859 : : // e.g aDiff= 61 POSTIT_SCOLL=50 --> lScroll = 100
860 [ # # ]: 0 : const long lScroll = bBottom ? (aDiff + ( GetScrollSize() - (aDiff % GetScrollSize()))) : (aDiff - (GetScrollSize() + (aDiff % GetScrollSize())));
861 : 0 : Scroll(lScroll, aPage);
862 : : }
863 : : }
864 : 0 : }
865 : :
866 : 0 : void SwPostItMgr::MakeVisible(const SwSidebarWin* pPostIt,long aPage )
867 : : {
868 [ # # ]: 0 : if (aPage == -1)
869 : : {
870 : : // we dont know the page yet, lets find it ourselves
871 [ # # ]: 0 : for (unsigned long n=0;n<mPages.size();n++)
872 : : {
873 [ # # ]: 0 : if (mPages[n]->mList->size()>0)
874 : : {
875 [ # # ]: 0 : for(SwSidebarItem_iterator i = mPages[n]->mList->begin(); i!= mPages[n]->mList->end(); i++)
876 : : {
877 [ # # ]: 0 : if ((*i)->pPostIt==pPostIt)
878 : : {
879 : 0 : aPage = n+1;
880 : 0 : break;
881 : : }
882 : : }
883 : : }
884 : : }
885 : : }
886 [ # # ]: 0 : if (aPage!=-1)
887 [ # # ]: 0 : AutoScroll(pPostIt,aPage);
888 [ # # ][ # # ]: 0 : Rectangle aNoteRect (Point(pPostIt->GetPosPixel().X(),pPostIt->GetPosPixel().Y()-5),pPostIt->GetSizePixel());
[ # # ][ # # ]
889 [ # # ][ # # ]: 0 : if (!aNoteRect.IsEmpty())
890 [ # # ][ # # ]: 0 : mpWrtShell->MakeVisible(SwRect(mpEditWin->PixelToLogic(aNoteRect)));
[ # # ]
891 : 0 : }
892 : :
893 : 0 : bool SwPostItMgr::ArrowEnabled(sal_uInt16 aDirection,unsigned long aPage) const
894 : : {
895 [ # # # ]: 0 : switch (aDirection)
896 : : {
897 : : case KEY_PAGEUP:
898 : : {
899 : 0 : return (mPages[aPage-1]->lOffset != 0);
900 : : }
901 : : case KEY_PAGEDOWN:
902 : : {
903 : 0 : return (!BorderOverPageBorder(aPage));
904 : : }
905 : 0 : default: return false;
906 : : }
907 : : }
908 : :
909 : 0 : Color SwPostItMgr::GetArrowColor(sal_uInt16 aDirection,unsigned long aPage) const
910 : : {
911 [ # # ]: 0 : if (ArrowEnabled(aDirection,aPage))
912 : : {
913 [ # # ]: 0 : if (Application::GetSettings().GetStyleSettings().GetHighContrastMode())
914 : 0 : return Color(COL_WHITE);
915 : : else
916 : 0 : return COL_NOTES_SIDEPANE_ARROW_ENABLED;
917 : : }
918 : : else
919 : : {
920 : 0 : return COL_NOTES_SIDEPANE_ARROW_DISABLED;
921 : : }
922 : : }
923 : :
924 : 78 : bool SwPostItMgr::LayoutByPage(std::list<SwSidebarWin*> &aVisiblePostItList,const Rectangle aBorder, long lNeededHeight)
925 : : {
926 : : /*** General layout idea:***/
927 : : // - if we have space left, we always move the current one up,
928 : : // otherwise the next one down
929 : : // - first all notes are resized
930 : : // - then the real layout starts
931 : : /*************************************************************/
932 : :
933 : : //rBorder is the page rect
934 [ + - ]: 78 : const Rectangle rBorder = mpEditWin->LogicToPixel( aBorder);
935 : 78 : long lTopBorder = rBorder.Top() + 5;
936 : 78 : long lBottomBorder = rBorder.Bottom() - 5;
937 : 78 : const long lVisibleHeight = lBottomBorder - lTopBorder; //rBorder.GetHeight() ;
938 : 78 : long lSpaceUsed = 0;
939 : 78 : long lTranslatePos = 0;
940 : 78 : int loop = 0;
941 : 78 : bool bScrollbars = false;
942 : :
943 : : // do all neccessary resizings
944 [ - + ]: 78 : if (lVisibleHeight < lNeededHeight)
945 : : {
946 : : // ok, now we have to really resize and adding scrollbars
947 : 0 : const long lAverageHeight = (lVisibleHeight - aVisiblePostItList.size()*GetSpaceBetween()) / aVisiblePostItList.size();
948 [ # # ]: 0 : if (lAverageHeight<GetMinimumSizeWithMeta())
949 : : {
950 : 0 : bScrollbars = true;
951 : 0 : lTopBorder += GetSidebarScrollerHeight() + 10;
952 : 0 : lBottomBorder -= (GetSidebarScrollerHeight() + 10);
953 [ # # ]: 0 : for(SwSidebarWin_iterator i = aVisiblePostItList.begin(); i!= aVisiblePostItList.end() ; i++)
954 [ # # ][ # # ]: 0 : (*i)->SetSize(Size((*i)->VirtualSize().getWidth(),(*i)->GetMinimumSizeWithMeta()));
[ # # ]
955 : : }
956 : : else
957 : : {
958 [ # # ]: 0 : for(SwSidebarWin_iterator i = aVisiblePostItList.begin(); i!= aVisiblePostItList.end() ; i++)
959 : : {
960 [ # # ][ # # ]: 0 : if ( (*i)->VirtualSize().getHeight() > lAverageHeight)
961 [ # # ][ # # ]: 0 : (*i)->SetSize(Size((*i)->VirtualSize().getWidth(),lAverageHeight));
962 : : }
963 : : }
964 : : }
965 : :
966 : : //start the real layout so nothing overlaps anymore
967 [ - + ]: 78 : if (aVisiblePostItList.size()>1)
968 : : {
969 : 0 : bool bDone = false;
970 : : // if no window is moved anymore we are finished
971 [ # # ]: 0 : while (!bDone)
972 : : {
973 : 0 : loop++;
974 : 0 : bDone = true;
975 : 0 : lSpaceUsed = lTopBorder + GetSpaceBetween();
976 [ # # ]: 0 : for(SwSidebarWin_iterator i = aVisiblePostItList.begin(); i!= aVisiblePostItList.end() ; i++)
977 : : {
978 : 0 : SwSidebarWin_iterator aNextPostIt = i;
979 : 0 : ++aNextPostIt;
980 : :
981 [ # # ]: 0 : if (aNextPostIt !=aVisiblePostItList.end())
982 : : {
983 [ # # ]: 0 : lTranslatePos = ( (*i)->VirtualPos().Y() + (*i)->VirtualSize().Height()) - (*aNextPostIt)->VirtualPos().Y();
984 [ # # ]: 0 : if (lTranslatePos > 0) // note windows overlaps the next one
985 : : {
986 : : // we are not done yet, loop at least once more
987 : 0 : bDone = false;
988 : : // if there is space left, move the current note up
989 : : // it could also happen that there is no space left for the first note due to a scrollbar
990 : : // then we also jump into, so we move the current one up and the next one down
991 [ # # ][ # # ]: 0 : if ( (lSpaceUsed <= (*i)->VirtualPos().Y()) || (i==aVisiblePostItList.begin()))
[ # # ][ # # ]
[ # # ]
992 : : {
993 : : // we have space left, so let's move the current one up
994 [ # # ]: 0 : if ( ((*i)->VirtualPos().Y()- lTranslatePos - GetSpaceBetween()) > lTopBorder)
995 : : {
996 [ # # ]: 0 : if ((*aNextPostIt)->IsFollow())
997 [ # # ]: 0 : (*i)->TranslateTopPosition(-1*(lTranslatePos+ANCHORLINE_WIDTH));
998 : : else
999 [ # # ]: 0 : (*i)->TranslateTopPosition(-1*(lTranslatePos+GetSpaceBetween()));
1000 : : }
1001 : : else
1002 : : {
1003 : 0 : long lMoveUp = (*i)->VirtualPos().Y() - lTopBorder;
1004 [ # # ]: 0 : (*i)->TranslateTopPosition(-1* lMoveUp);
1005 [ # # ]: 0 : if ((*aNextPostIt)->IsFollow())
1006 [ # # ]: 0 : (*aNextPostIt)->TranslateTopPosition( (lTranslatePos+ANCHORLINE_WIDTH) - lMoveUp);
1007 : : else
1008 [ # # ]: 0 : (*aNextPostIt)->TranslateTopPosition( (lTranslatePos+GetSpaceBetween()) - lMoveUp);
1009 : : }
1010 : : }
1011 : : else
1012 : : {
1013 : : // no space left, left move the next one down
1014 [ # # ]: 0 : if ((*aNextPostIt)->IsFollow())
1015 [ # # ]: 0 : (*aNextPostIt)->TranslateTopPosition(lTranslatePos+ANCHORLINE_WIDTH);
1016 : : else
1017 [ # # ]: 0 : (*aNextPostIt)->TranslateTopPosition(lTranslatePos+GetSpaceBetween());
1018 : : }
1019 : : }
1020 : : else
1021 : : {
1022 : : // the first one could overlap the topborder instead of a second note
1023 [ # # ]: 0 : if (i==aVisiblePostItList.begin())
1024 : : {
1025 : 0 : long lMoveDown = lTopBorder - (*i)->VirtualPos().Y();
1026 [ # # ]: 0 : if (lMoveDown>0)
1027 : : {
1028 : 0 : bDone = false;
1029 [ # # ]: 0 : (*i)->TranslateTopPosition( lMoveDown);
1030 : : }
1031 : : }
1032 : : }
1033 [ # # ][ # # ]: 0 : if (aNextPostIt !=aVisiblePostItList.end() && (*aNextPostIt)->IsFollow())
[ # # ][ # # ]
1034 [ # # ]: 0 : lSpaceUsed += (*i)->VirtualSize().Height() + ANCHORLINE_WIDTH;
1035 : : else
1036 [ # # ]: 0 : lSpaceUsed += (*i)->VirtualSize().Height() + GetSpaceBetween();
1037 : : }
1038 : : else
1039 : : {
1040 : : //(*i) is the last visible item
1041 : 0 : SwSidebarWin_iterator aPrevPostIt = i;
1042 : 0 : --aPrevPostIt;
1043 [ # # ]: 0 : lTranslatePos = ( (*aPrevPostIt)->VirtualPos().Y() + (*aPrevPostIt)->VirtualSize().Height() ) - (*i)->VirtualPos().Y();
1044 [ # # ]: 0 : if (lTranslatePos > 0)
1045 : : {
1046 : 0 : bDone = false;
1047 [ # # ][ # # ]: 0 : if ( ((*i)->VirtualPos().Y()+ (*i)->VirtualSize().Height()+lTranslatePos) < lBottomBorder)
1048 : : {
1049 [ # # ]: 0 : if ( (*i)->IsFollow() )
1050 [ # # ]: 0 : (*i)->TranslateTopPosition(lTranslatePos+ANCHORLINE_WIDTH);
1051 : : else
1052 [ # # ]: 0 : (*i)->TranslateTopPosition(lTranslatePos+GetSpaceBetween());
1053 : : }
1054 : : else
1055 : : {
1056 [ # # ][ # # ]: 0 : (*i)->TranslateTopPosition(lBottomBorder - ((*i)->VirtualPos().Y()+ (*i)->VirtualSize().Height()) );
1057 : : }
1058 : : }
1059 : : else
1060 : : {
1061 : : // note does not overlap, but we might be over the lower border
1062 : : // only do this if there are no scrollbars, otherwise notes are supposed to overlap the border
1063 [ # # ][ # # ]: 0 : if (!bScrollbars && ((*i)->VirtualPos().Y()+ (*i)->VirtualSize().Height() > lBottomBorder) )
[ # # ][ # # ]
[ # # ][ # #
# # # # ]
1064 : : {
1065 : 0 : bDone = false;
1066 [ # # ][ # # ]: 0 : (*i)->TranslateTopPosition(lBottomBorder - ((*i)->VirtualPos().Y()+ (*i)->VirtualSize().Height()));
1067 : : }
1068 : : }
1069 : : }
1070 : : }
1071 : : // security check so we don't loop forever
1072 [ # # ]: 0 : if (loop>MAX_LOOP_COUNT)
1073 : : {
1074 : : OSL_FAIL("PostItMgr::Layout(): We are looping forever");
1075 : 0 : break;
1076 : : }
1077 : : }
1078 : : }
1079 : : else
1080 : : {
1081 : : // only one left, make sure it is not hidden at the top or bottom
1082 : 78 : SwSidebarWin_iterator i = aVisiblePostItList.begin();
1083 : 78 : lTranslatePos = lTopBorder - (*i)->VirtualPos().Y();
1084 [ - + ]: 78 : if (lTranslatePos>0)
1085 : : {
1086 [ # # ]: 0 : (*i)->TranslateTopPosition(lTranslatePos+GetSpaceBetween());
1087 : : }
1088 [ + - ]: 78 : lTranslatePos = lBottomBorder - ((*i)->VirtualPos().Y()+ (*i)->VirtualSize().Height());
1089 [ - + ]: 78 : if (lTranslatePos<0)
1090 : : {
1091 [ # # ]: 78 : (*i)->TranslateTopPosition(lTranslatePos);
1092 : : }
1093 : : }
1094 : 78 : return bScrollbars;
1095 : : }
1096 : :
1097 : 1318 : void SwPostItMgr::AddPostIts(bool bCheckExistance, bool bFocus)
1098 : : {
1099 : 1318 : bool bEmpty = mvPostItFlds.empty();
1100 [ + - ][ + - ]: 1318 : SwFieldType* pType = mpView->GetDocShell()->GetDoc()->GetFldType(RES_POSTITFLD, aEmptyStr,false);
1101 [ + - ]: 1318 : SwIterator<SwFmtFld,SwFieldType> aIter( *pType );
1102 [ + - ]: 1318 : SwFmtFld* pSwFmtFld = aIter.First();
1103 [ + + ]: 1336 : while(pSwFmtFld)
1104 : : {
1105 [ + - ]: 18 : if ( pSwFmtFld->GetTxtFld())
1106 : : {
1107 [ + - ][ + - ]: 18 : if ( pSwFmtFld->IsFldInDoc() )
1108 [ + - ][ + - ]: 18 : InsertItem(pSwFmtFld,bCheckExistance,bFocus);
1109 : : }
1110 [ + - ]: 18 : pSwFmtFld = aIter.Next();
1111 : : }
1112 : :
1113 : : // if we just added the first one we have to update the view for centering
1114 [ + - ][ + + ]: 1318 : if (bEmpty && !mvPostItFlds.empty())
[ + + ]
1115 [ + - ][ + - ]: 1318 : PrepareView(true);
1116 : 1318 : }
1117 : :
1118 : 1231 : void SwPostItMgr::RemoveSidebarWin()
1119 : : {
1120 [ + + ]: 1231 : if (!mvPostItFlds.empty())
1121 : : {
1122 [ + + ]: 30 : for(std::list<SwSidebarItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; ++i)
1123 : : {
1124 [ + - ][ + - ]: 15 : EndListening( *((*i)->GetBroadCaster()) );
1125 [ + - ]: 15 : if ((*i)->pPostIt)
1126 [ + - ][ + - ]: 15 : delete (*i)->pPostIt;
1127 [ + - ][ + - ]: 15 : delete (*i);
1128 : : }
1129 : 15 : mvPostItFlds.clear();
1130 : : }
1131 : :
1132 : : // all postits removed, no items should be left in pages
1133 : 1231 : PreparePageContainer();
1134 : 1231 : }
1135 : :
1136 : : // copy to new vector, otherwise RemoveItem would operate and delete stuff on mvPostItFlds as well
1137 : : // RemoveItem will clean up the core field and visible postit if neccessary
1138 : : // we cannot just delete everything as before, as postits could move into change tracking
1139 : 0 : void SwPostItMgr::Delete(String aAuthor)
1140 : : {
1141 [ # # ]: 0 : mpWrtShell->StartAllAction();
1142 [ # # ][ # # ]: 0 : if ( HasActiveSidebarWin() && (GetActiveSidebarWin()->GetAuthor()==aAuthor) )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # # # ]
1143 : : {
1144 [ # # ]: 0 : SetActiveSidebarWin(0);
1145 : : }
1146 [ # # ]: 0 : SwRewriter aRewriter;
1147 [ # # ]: 0 : String aUndoString = SW_RES(STR_DELETE_AUTHOR_NOTES);
1148 [ # # ]: 0 : aUndoString += aAuthor;
1149 [ # # ]: 0 : aRewriter.AddRule(UndoArg1, aUndoString);
1150 [ # # ]: 0 : mpWrtShell->StartUndo( UNDO_DELETE, &aRewriter );
1151 : :
1152 [ # # ]: 0 : std::vector<SwFmtFld*> aTmp;
1153 [ # # ]: 0 : aTmp.reserve( mvPostItFlds.size() );
1154 [ # # ]: 0 : for(std::list<SwSidebarItem*>::iterator pPostIt = mvPostItFlds.begin(); pPostIt!= mvPostItFlds.end() ; ++pPostIt)
1155 : : {
1156 [ # # ][ # # ]: 0 : if ((*pPostIt)->GetFmtFld() && ((*pPostIt)->pPostIt->GetAuthor() == aAuthor) )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
[ # # # # ]
1157 [ # # ][ # # ]: 0 : aTmp.push_back( (*pPostIt)->GetFmtFld() );
1158 : : }
1159 [ # # ][ # # ]: 0 : for(std::vector<SwFmtFld*>::iterator i = aTmp.begin(); i!= aTmp.end() ; ++i)
[ # # ]
1160 : : {
1161 [ # # ][ # # ]: 0 : mpWrtShell->GotoField( *(*i) );
1162 [ # # ]: 0 : mpWrtShell->DelRight();
1163 : : }
1164 [ # # ]: 0 : mpWrtShell->EndUndo();
1165 [ # # ]: 0 : PrepareView();
1166 [ # # ]: 0 : mpWrtShell->EndAllAction();
1167 : 0 : mbLayout = true;
1168 [ # # ]: 0 : CalcRects();
1169 [ # # ][ # # ]: 0 : LayoutPostIts();
[ # # ]
1170 : 0 : }
1171 : :
1172 : 0 : void SwPostItMgr::Delete()
1173 : : {
1174 [ # # ]: 0 : mpWrtShell->StartAllAction();
1175 [ # # ]: 0 : SetActiveSidebarWin(0);
1176 [ # # ]: 0 : SwRewriter aRewriter;
1177 [ # # ][ # # ]: 0 : aRewriter.AddRule(UndoArg1, SW_RES(STR_DELETE_ALL_NOTES) );
[ # # ]
1178 [ # # ]: 0 : mpWrtShell->StartUndo( UNDO_DELETE, &aRewriter );
1179 : :
1180 [ # # ]: 0 : std::vector<SwFmtFld*> aTmp;
1181 [ # # ]: 0 : aTmp.reserve( mvPostItFlds.size() );
1182 [ # # ]: 0 : for(std::list<SwSidebarItem*>::iterator pPostIt = mvPostItFlds.begin(); pPostIt!= mvPostItFlds.end() ; ++pPostIt)
1183 : : {
1184 [ # # ][ # # ]: 0 : if ((*pPostIt)->GetFmtFld())
1185 [ # # ][ # # ]: 0 : aTmp.push_back( (*pPostIt)->GetFmtFld() );
1186 : : }
1187 [ # # ][ # # ]: 0 : for(std::vector<SwFmtFld*>::iterator i = aTmp.begin(); i!= aTmp.end() ; ++i)
[ # # ]
1188 : : {
1189 [ # # ][ # # ]: 0 : mpWrtShell->GotoField( *(*i) );
1190 [ # # ]: 0 : mpWrtShell->DelRight();
1191 : : }
1192 : :
1193 [ # # ]: 0 : mpWrtShell->EndUndo();
1194 [ # # ]: 0 : PrepareView();
1195 [ # # ]: 0 : mpWrtShell->EndAllAction();
1196 : 0 : mbLayout = true;
1197 [ # # ]: 0 : CalcRects();
1198 [ # # ][ # # ]: 0 : LayoutPostIts();
1199 : 0 : }
1200 : 0 : void SwPostItMgr::Hide( const String& rAuthor )
1201 : : {
1202 [ # # ]: 0 : for(SwSidebarItem_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++)
1203 : : {
1204 [ # # ][ # # ]: 0 : if ( (*i)->pPostIt && ((*i)->pPostIt->GetAuthor() == rAuthor) )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # # # ]
1205 : : {
1206 : 0 : (*i)->bShow = false;
1207 [ # # ]: 0 : (*i)->pPostIt->HideNote();
1208 : : }
1209 : : }
1210 : :
1211 : 0 : LayoutPostIts();
1212 : 0 : }
1213 : :
1214 : 0 : void SwPostItMgr::Hide()
1215 : : {
1216 [ # # ]: 0 : for(SwSidebarItem_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++)
1217 : : {
1218 : 0 : (*i)->bShow = false;
1219 [ # # ]: 0 : (*i)->pPostIt->HideNote();
1220 : : }
1221 : 0 : }
1222 : :
1223 : :
1224 : 0 : void SwPostItMgr::Show()
1225 : : {
1226 [ # # ]: 0 : for(SwSidebarItem_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++)
1227 : : {
1228 : 0 : (*i)->bShow = true;
1229 : : }
1230 : 0 : LayoutPostIts();
1231 : 0 : }
1232 : :
1233 : 99 : void SwPostItMgr::Sort(const short aType)
1234 : : {
1235 [ - + ]: 99 : if (mvPostItFlds.size()>1 )
1236 : : {
1237 [ # # ]: 0 : switch (aType)
1238 : : {
1239 : : case SORT_POS:
1240 : 0 : mvPostItFlds.sort(comp_pos);
1241 : 0 : break;
1242 : : }
1243 : : }
1244 : 99 : }
1245 : :
1246 : 0 : SwSidebarWin* SwPostItMgr::GetSidebarWin( const SfxBroadcaster* pBroadcaster) const
1247 : : {
1248 [ # # ]: 0 : for(const_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; ++i)
1249 : : {
1250 [ # # ][ # # ]: 0 : if ( (*i)->GetBroadCaster() == pBroadcaster)
1251 : 0 : return (*i)->pPostIt;
1252 : : }
1253 : 0 : return NULL;
1254 : : }
1255 : :
1256 : 0 : sw::annotation::SwAnnotationWin* SwPostItMgr::GetAnnotationWin(const SwPostItField* pFld) const
1257 : : {
1258 [ # # ]: 0 : for(const_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; ++i)
1259 : : {
1260 [ # # ][ # # ]: 0 : if ( (*i)->GetFmtFld() && ((*i)->GetFmtFld()->GetFld() == pFld))
[ # # ][ # # ]
[ # # ]
1261 [ # # ]: 0 : return dynamic_cast<sw::annotation::SwAnnotationWin*>((*i)->pPostIt);
1262 : : }
1263 : 0 : return NULL;
1264 : : }
1265 : :
1266 : 0 : SwSidebarWin* SwPostItMgr::GetNextPostIt( sal_uInt16 aDirection,
1267 : : SwSidebarWin* aPostIt )
1268 : : {
1269 [ # # ]: 0 : if (mvPostItFlds.size()>1)
1270 : : {
1271 [ # # ]: 0 : for(SwSidebarItem_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++)
1272 : : {
1273 [ # # ]: 0 : if ( (*i)->pPostIt ==aPostIt)
1274 : : {
1275 : 0 : SwSidebarItem_iterator iNextPostIt = i;
1276 [ # # ]: 0 : if (aDirection==KEY_PAGEUP)
1277 : : {
1278 [ # # ]: 0 : if ( iNextPostIt==mvPostItFlds.begin() )
1279 : : {
1280 : 0 : return NULL;
1281 : : }
1282 : 0 : --iNextPostIt;
1283 : : }
1284 : : else
1285 : : {
1286 : 0 : iNextPostIt++;
1287 [ # # ]: 0 : if ( iNextPostIt==mvPostItFlds.end() )
1288 : : {
1289 : 0 : return NULL;
1290 : : }
1291 : : }
1292 : : // lets quit, we are back at the beginng
1293 [ # # ]: 0 : if ( (*iNextPostIt)->pPostIt==aPostIt)
1294 : 0 : return NULL;
1295 : 0 : return (*iNextPostIt)->pPostIt;
1296 : : }
1297 : : }
1298 : 0 : return NULL;
1299 : : }
1300 : : else
1301 : 0 : return NULL;
1302 : : }
1303 : :
1304 : 0 : long SwPostItMgr::GetNextBorder()
1305 : : {
1306 [ # # ]: 0 : for (unsigned long n=0;n<mPages.size();n++)
1307 : : {
1308 [ # # ]: 0 : for(SwSidebarItem_iterator b = mPages[n]->mList->begin(); b!= mPages[n]->mList->end(); b++)
1309 : : {
1310 [ # # ]: 0 : if ((*b)->pPostIt == mpActivePostIt)
1311 : : {
1312 : 0 : SwSidebarItem_iterator aNext = b;
1313 : 0 : aNext++;
1314 [ # # ]: 0 : bool bFollow = (aNext == mPages[n]->mList->end()) ? false : (*aNext)->pPostIt->IsFollow();
1315 [ # # ][ # # ]: 0 : if ( mPages[n]->bScrollbar || bFollow )
[ # # ]
1316 : : {
1317 : 0 : return -1;
1318 : : }
1319 : : else
1320 : : {
1321 : : //if this is the last item, return the bottom border otherwise the next item
1322 [ # # ]: 0 : if (aNext == mPages[n]->mList->end())
1323 [ # # ]: 0 : return mpEditWin->LogicToPixel(Point(0,mPages[n]->mPageRect.Bottom())).Y() - GetSpaceBetween();
1324 : : else
1325 [ # # ]: 0 : return (*aNext)->pPostIt->GetPosPixel().Y() - GetSpaceBetween();
1326 : : }
1327 : : }
1328 : : }
1329 : : }
1330 : :
1331 : : OSL_FAIL("SwPostItMgr::GetNextBorder(): We have to find a next border here");
1332 : 0 : return -1;
1333 : : }
1334 : :
1335 : 19573 : void SwPostItMgr::SetShadowState(const SwPostItField* pFld,bool bCursor)
1336 : : {
1337 [ - + ]: 19573 : if (pFld)
1338 : : {
1339 [ # # ]: 0 : if (pFld !=mShadowState.mpShadowFld)
1340 : : {
1341 [ # # ]: 0 : if (mShadowState.mpShadowFld)
1342 : : {
1343 : : // reset old one if still alive
1344 : : // TODO: does not work properly if mouse and cursor was set
1345 : : sw::annotation::SwAnnotationWin* pOldPostIt =
1346 : 0 : GetAnnotationWin(mShadowState.mpShadowFld);
1347 [ # # ][ # # ]: 0 : if (pOldPostIt && pOldPostIt->Shadow() && (pOldPostIt->Shadow()->GetShadowState() != SS_EDIT))
[ # # ][ # # ]
1348 : 0 : pOldPostIt->SetViewState(VS_NORMAL);
1349 : : }
1350 : : //set new one, if it is not currently edited
1351 : 0 : sw::annotation::SwAnnotationWin* pNewPostIt = GetAnnotationWin(pFld);
1352 [ # # ][ # # ]: 0 : if (pNewPostIt && pNewPostIt->Shadow() && (pNewPostIt->Shadow()->GetShadowState() != SS_EDIT))
[ # # ][ # # ]
1353 : : {
1354 : 0 : pNewPostIt->SetViewState(VS_VIEW);
1355 : : //remember our new field
1356 : 0 : mShadowState.mpShadowFld = pFld;
1357 : 0 : mShadowState.bCursor = false;
1358 : 0 : mShadowState.bMouse = false;
1359 : : }
1360 : : }
1361 [ # # ]: 0 : if (bCursor)
1362 : 0 : mShadowState.bCursor = true;
1363 : : else
1364 : 0 : mShadowState.bMouse = true;
1365 : : }
1366 : : else
1367 : : {
1368 [ - + ]: 19573 : if (mShadowState.mpShadowFld)
1369 : : {
1370 [ # # ]: 0 : if (bCursor)
1371 : 0 : mShadowState.bCursor = false;
1372 : : else
1373 : 0 : mShadowState.bMouse = false;
1374 [ # # ][ # # ]: 0 : if (!mShadowState.bCursor && !mShadowState.bMouse)
1375 : : {
1376 : : // reset old one if still alive
1377 : 0 : sw::annotation::SwAnnotationWin* pOldPostIt = GetAnnotationWin(mShadowState.mpShadowFld);
1378 [ # # ][ # # ]: 0 : if (pOldPostIt && pOldPostIt->Shadow() && (pOldPostIt->Shadow()->GetShadowState() != SS_EDIT))
[ # # ][ # # ]
1379 : : {
1380 : 0 : pOldPostIt->SetViewState(VS_NORMAL);
1381 : 0 : mShadowState.mpShadowFld = 0;
1382 : : }
1383 : : }
1384 : : }
1385 : : }
1386 : 19573 : }
1387 : :
1388 : 236 : void SwPostItMgr::PrepareView(bool bIgnoreCount)
1389 : : {
1390 [ + + ][ + - ]: 236 : if (!HasNotes() || bIgnoreCount)
[ + - ]
1391 : : {
1392 : 236 : mpWrtShell->StartAllAction();
1393 : 236 : SwRootFrm* pLayout = mpWrtShell->GetLayout();
1394 [ + - ]: 236 : if ( pLayout )
1395 : : SwPostItHelper::setSidebarChanged( pLayout,
1396 : 236 : mpWrtShell->getIDocumentSettingAccess()->get( IDocumentSettingAccess::BROWSE_MODE ) );
1397 : 236 : mpWrtShell->EndAllAction();
1398 : : }
1399 : 236 : }
1400 : :
1401 : 3 : bool SwPostItMgr::ShowScrollbar(const unsigned long aPage) const
1402 : : {
1403 [ + - ]: 3 : if (mPages.size() > aPage-1)
1404 [ - + ][ # # ]: 3 : return (mPages[aPage-1]->bScrollbar && !mbWaitingForCalcRects);
1405 : : else
1406 : 3 : return false;
1407 : : }
1408 : :
1409 : 0 : bool SwPostItMgr::IsHit(const Point &aPointPixel)
1410 : : {
1411 [ # # ][ # # ]: 0 : if (HasNotes() && ShowNotes())
[ # # ]
1412 : : {
1413 [ # # ]: 0 : const Point aPoint = mpEditWin->PixelToLogic(aPointPixel);
1414 [ # # ]: 0 : const SwRootFrm* pLayout = mpWrtShell->GetLayout();
1415 : 0 : SwRect aPageFrm;
1416 [ # # ]: 0 : const unsigned long nPageNum = SwPostItHelper::getPageInfo( aPageFrm, pLayout, aPoint );
1417 [ # # ]: 0 : if( nPageNum )
1418 : : {
1419 [ # # ]: 0 : Rectangle aRect;
1420 : : OSL_ENSURE(mPages.size()>nPageNum-1,"SwPostitMgr:: page container size wrong");
1421 : 0 : aRect = mPages[nPageNum-1]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_LEFT
1422 [ # # ]: 0 : ? Rectangle(Point(aPageFrm.Left()-GetSidebarWidth()-GetSidebarBorderWidth(),aPageFrm.Top()),Size(GetSidebarWidth(),aPageFrm.Height()))
[ # # # # ]
1423 [ # # ][ # # ]: 0 : : Rectangle( Point(aPageFrm.Right()+GetSidebarBorderWidth(),aPageFrm.Top()) , Size(GetSidebarWidth(),aPageFrm.Height()));
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # # #
# # # # #
# # # ]
[ # # ]
1424 [ # # ][ # # ]: 0 : if (aRect.IsInside(aPoint))
1425 : : {
1426 : : // we hit the note's sidebar
1427 : : // lets now test for the arrow area
1428 [ # # ]: 0 : if (mPages[nPageNum-1]->bScrollbar)
1429 [ # # ]: 0 : return ScrollbarHit(nPageNum,aPoint);
1430 : : else
1431 : 0 : return false;
1432 : : }
1433 : : }
1434 : : }
1435 : 0 : return false;
1436 : : }
1437 : 0 : Rectangle SwPostItMgr::GetBottomScrollRect(const unsigned long aPage) const
1438 : : {
1439 : 0 : SwRect aPageRect = mPages[aPage-1]->mPageRect;
1440 : 0 : Point aPointBottom = mPages[aPage-1]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_LEFT
1441 [ # # ][ # # ]: 0 : ? Point(aPageRect.Left() - GetSidebarWidth() - GetSidebarBorderWidth() + mpEditWin->PixelToLogic(Size(2,0)).Width(),aPageRect.Bottom()- mpEditWin->PixelToLogic(Size(0,2+GetSidebarScrollerHeight())).Height())
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # # #
# # # # ]
1442 [ # # ][ # # ]: 0 : : Point(aPageRect.Right() + GetSidebarBorderWidth() + mpEditWin->PixelToLogic(Size(2,0)).Width(),aPageRect.Bottom()- mpEditWin->PixelToLogic(Size(0,2+GetSidebarScrollerHeight())).Height());
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # #
# # # # #
# ][ # # ]
1443 [ # # ][ # # ]: 0 : Size aSize(GetSidebarWidth() - mpEditWin->PixelToLogic(Size(4,0)).Width(), mpEditWin->PixelToLogic(Size(0,GetSidebarScrollerHeight())).Height()) ;
[ # # ]
1444 [ # # ]: 0 : return Rectangle(aPointBottom,aSize);
1445 : :
1446 : : }
1447 : :
1448 : 0 : Rectangle SwPostItMgr::GetTopScrollRect(const unsigned long aPage) const
1449 : : {
1450 : 0 : SwRect aPageRect = mPages[aPage-1]->mPageRect;
1451 : 0 : Point aPointTop = mPages[aPage-1]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_LEFT
1452 [ # # ][ # # ]: 0 : ? Point(aPageRect.Left() - GetSidebarWidth() -GetSidebarBorderWidth()+ mpEditWin->PixelToLogic(Size(2,0)).Width(),aPageRect.Top() + mpEditWin->PixelToLogic(Size(0,2)).Height())
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # # #
# # # # ]
1453 [ # # ][ # # ]: 0 : : Point(aPageRect.Right() + GetSidebarBorderWidth() + mpEditWin->PixelToLogic(Size(2,0)).Width(),aPageRect.Top() + mpEditWin->PixelToLogic(Size(0,2)).Height());
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # #
# # # # #
# ][ # # ]
1454 [ # # ][ # # ]: 0 : Size aSize(GetSidebarWidth() - mpEditWin->PixelToLogic(Size(4,0)).Width(), mpEditWin->PixelToLogic(Size(0,GetSidebarScrollerHeight())).Height()) ;
[ # # ]
1455 [ # # ]: 0 : return Rectangle(aPointTop,aSize);
1456 : : }
1457 : :
1458 : :
1459 : : //IMPORTANT: if you change the rects here, also change SwPageFrm::PaintNotesSidebar()
1460 : 0 : bool SwPostItMgr::ScrollbarHit(const unsigned long aPage,const Point &aPoint)
1461 : : {
1462 : 0 : SwRect aPageRect = mPages[aPage-1]->mPageRect;
1463 : 0 : Point aPointBottom = mPages[aPage-1]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_LEFT
1464 [ # # ][ # # ]: 0 : ? Point(aPageRect.Left() - GetSidebarWidth()-GetSidebarBorderWidth() + mpEditWin->PixelToLogic(Size(2,0)).Width(),aPageRect.Bottom()- mpEditWin->PixelToLogic(Size(0,2+GetSidebarScrollerHeight())).Height())
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # # #
# # # # ]
1465 [ # # ][ # # ]: 0 : : Point(aPageRect.Right() + GetSidebarBorderWidth()+ mpEditWin->PixelToLogic(Size(2,0)).Width(),aPageRect.Bottom()- mpEditWin->PixelToLogic(Size(0,2+GetSidebarScrollerHeight())).Height());
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # #
# # # # #
# ][ # # ]
1466 : :
1467 : 0 : Point aPointTop = mPages[aPage-1]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_LEFT
1468 [ # # ][ # # ]: 0 : ? Point(aPageRect.Left() - GetSidebarWidth()-GetSidebarBorderWidth()+ mpEditWin->PixelToLogic(Size(2,0)).Width(),aPageRect.Top() + mpEditWin->PixelToLogic(Size(0,2)).Height())
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # # #
# # # # ]
1469 [ # # ][ # # ]: 0 : : Point(aPageRect.Right()+GetSidebarBorderWidth()+ mpEditWin->PixelToLogic(Size(2,0)).Width(),aPageRect.Top() + mpEditWin->PixelToLogic(Size(0,2)).Height());
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # #
# # # # #
# ][ # # ]
1470 : :
1471 [ # # ]: 0 : Rectangle aRectBottom(GetBottomScrollRect(aPage));
1472 [ # # ]: 0 : Rectangle aRectTop(GetTopScrollRect(aPage));
1473 : :
1474 [ # # ][ # # ]: 0 : if (aRectBottom.IsInside(aPoint))
1475 : : {
1476 [ # # ][ # # ]: 0 : if (aPoint.X() < long((aPointBottom.X() + GetSidebarWidth()/3)))
1477 [ # # ]: 0 : Scroll( GetScrollSize(),aPage);
1478 : : else
1479 [ # # ]: 0 : Scroll( -1*GetScrollSize(), aPage);
1480 : 0 : return true;
1481 : : }
1482 : : else
1483 [ # # ][ # # ]: 0 : if (aRectTop.IsInside(aPoint))
1484 : : {
1485 [ # # ][ # # ]: 0 : if (aPoint.X() < long((aPointTop.X() + GetSidebarWidth()/3*2)))
1486 [ # # ]: 0 : Scroll(GetScrollSize(), aPage);
1487 : : else
1488 [ # # ]: 0 : Scroll(-1*GetScrollSize(), aPage);
1489 : 0 : return true;
1490 : : }
1491 : 0 : return false;
1492 : : }
1493 : :
1494 : 42 : void SwPostItMgr::CorrectPositions()
1495 : : {
1496 [ + - ][ + - ]: 42 : if ( mbWaitingForCalcRects || mbLayouting || mvPostItFlds.empty() )
[ - + ][ - + ]
1497 : 0 : return;
1498 : :
1499 : : // find first valid note
1500 : 42 : SwSidebarWin *pFirstPostIt = 0;
1501 [ + + ]: 60 : for(SwSidebarItem_iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++)
1502 : : {
1503 : 42 : pFirstPostIt = (*i)->pPostIt;
1504 [ + + ]: 42 : if (pFirstPostIt)
1505 : 24 : break;
1506 : : }
1507 : :
1508 : : //if we have not found a valid note, forget about it and leave
1509 [ + + ]: 42 : if (!pFirstPostIt)
1510 : 18 : return;
1511 : :
1512 : : // yeah, I know, if this is a left page it could be wrong, but finding the page and the note is probably not even faster than just doing it
1513 : : // check, if anchor overlay object exists.
1514 : 24 : const long aAnchorX = pFirstPostIt->Anchor()
1515 [ + - ][ + - ]: 48 : ? mpEditWin->LogicToPixel( Point((long)(pFirstPostIt->Anchor()->GetSixthPosition().getX()),0)).X()
[ + - ]
[ # # # # ]
1516 [ + - ]: 48 : : 0;
1517 : 24 : const long aAnchorY = pFirstPostIt->Anchor()
1518 [ + - ][ + - ]: 48 : ? mpEditWin->LogicToPixel( Point(0,(long)(pFirstPostIt->Anchor()->GetSixthPosition().getY()))).Y() + 1
[ + - ]
[ # # # # ]
1519 [ + - ]: 48 : : 0;
1520 [ - + ]: 24 : if (Point(aAnchorX,aAnchorY) != pFirstPostIt->GetPosPixel())
1521 : : {
1522 : 0 : long aAnchorPosX = 0;
1523 : 0 : long aAnchorPosY = 0;
1524 [ # # ]: 42 : for (unsigned long n=0;n<mPages.size();n++)
1525 : : {
1526 [ # # ]: 0 : for(SwSidebarItem_iterator i = mPages[n]->mList->begin(); i!= mPages[n]->mList->end(); i++)
1527 : : {
1528 : : // check, if anchor overlay object exists.
1529 [ # # ][ # # ]: 0 : if ( (*i)->bShow && (*i)->pPostIt && (*i)->pPostIt->Anchor() )
[ # # ][ # # ]
1530 : : {
1531 : 0 : aAnchorPosX = mPages[n]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_LEFT
1532 [ # # ][ # # ]: 0 : ? mpEditWin->LogicToPixel( Point((long)((*i)->pPostIt->Anchor()->GetSeventhPosition().getX()),0)).X()
[ # # ]
[ # # # # ]
1533 [ # # ][ # # ]: 0 : : mpEditWin->LogicToPixel( Point((long)((*i)->pPostIt->Anchor()->GetSixthPosition().getX()),0)).X();
[ # # ]
[ # # # # ]
[ # # ]
1534 [ # # ]: 0 : aAnchorPosY = mpEditWin->LogicToPixel( Point(0,(long)((*i)->pPostIt->Anchor()->GetSixthPosition().getY()))).Y() + 1;
1535 [ # # ]: 0 : (*i)->pPostIt->SetPosPixel(Point(aAnchorPosX,aAnchorPosY));
1536 : : }
1537 : : }
1538 : : }
1539 : : }
1540 : : }
1541 : :
1542 : :
1543 : 48193 : bool SwPostItMgr::ShowNotes() const
1544 : : {
1545 : : // we only want to see notes if Options - Writer - View - Notes is ticked
1546 : 48193 : return mpWrtShell->GetViewOptions()->IsPostIts();
1547 : : }
1548 : :
1549 : 61034 : bool SwPostItMgr::HasNotes() const
1550 : : {
1551 : 61034 : return !mvPostItFlds.empty();
1552 : : }
1553 : :
1554 : 234 : unsigned long SwPostItMgr::GetSidebarWidth(bool bPx) const
1555 : : {
1556 : 234 : unsigned long aWidth = (unsigned long)(mpWrtShell->GetViewOptions()->GetZoom() * 1.8);
1557 [ + + ]: 234 : if (bPx)
1558 : 210 : return aWidth;
1559 : : else
1560 [ + - ]: 234 : return mpEditWin->PixelToLogic(Size( aWidth ,0)).Width();
1561 : : }
1562 : :
1563 : 237 : unsigned long SwPostItMgr::GetSidebarBorderWidth(bool bPx) const
1564 : : {
1565 [ + + ]: 237 : if (bPx)
1566 : 210 : return 2;
1567 : : else
1568 [ + - ]: 237 : return mpEditWin->PixelToLogic(Size(2,0)).Width();
1569 : : }
1570 : :
1571 : 78 : unsigned long SwPostItMgr::GetNoteWidth()
1572 : : {
1573 : 78 : return GetSidebarWidth(true);
1574 : : }
1575 : :
1576 : 18 : Color SwPostItMgr::GetColorDark(sal_uInt16 aAuthorIndex)
1577 : : {
1578 [ + - ]: 18 : if (!Application::GetSettings().GetStyleSettings().GetHighContrastMode())
1579 : : {
1580 : : static const Color aArrayNormal[] = {
1581 : : COL_AUTHOR1_NORMAL, COL_AUTHOR2_NORMAL, COL_AUTHOR3_NORMAL,
1582 : : COL_AUTHOR4_NORMAL, COL_AUTHOR5_NORMAL, COL_AUTHOR6_NORMAL,
1583 [ + + ][ + - ]: 18 : COL_AUTHOR7_NORMAL, COL_AUTHOR8_NORMAL, COL_AUTHOR9_NORMAL };
1584 : :
1585 : 18 : return Color( aArrayNormal[ aAuthorIndex % (sizeof( aArrayNormal )/ sizeof( aArrayNormal[0] ))]);
1586 : : }
1587 : : else
1588 : 18 : return Color(COL_WHITE);
1589 : : }
1590 : :
1591 : 21 : Color SwPostItMgr::GetColorLight(sal_uInt16 aAuthorIndex)
1592 : : {
1593 [ + - ]: 21 : if (!Application::GetSettings().GetStyleSettings().GetHighContrastMode())
1594 : : {
1595 : : static const Color aArrayLight[] = {
1596 : : COL_AUTHOR1_LIGHT, COL_AUTHOR2_LIGHT, COL_AUTHOR3_LIGHT,
1597 : : COL_AUTHOR4_LIGHT, COL_AUTHOR5_LIGHT, COL_AUTHOR6_LIGHT,
1598 [ + + ][ + - ]: 21 : COL_AUTHOR7_LIGHT, COL_AUTHOR8_LIGHT, COL_AUTHOR9_LIGHT };
1599 : :
1600 : 21 : return Color( aArrayLight[ aAuthorIndex % (sizeof( aArrayLight )/ sizeof( aArrayLight[0] ))]);
1601 : : }
1602 : : else
1603 : 21 : return Color(COL_WHITE);
1604 : : }
1605 : :
1606 : 99 : Color SwPostItMgr::GetColorAnchor(sal_uInt16 aAuthorIndex)
1607 : : {
1608 [ + - ]: 99 : if (!Application::GetSettings().GetStyleSettings().GetHighContrastMode())
1609 : : {
1610 : : static const Color aArrayAnchor[] = {
1611 : : COL_AUTHOR1_DARK, COL_AUTHOR2_DARK, COL_AUTHOR3_DARK,
1612 : : COL_AUTHOR4_DARK, COL_AUTHOR5_DARK, COL_AUTHOR6_DARK,
1613 [ + + ][ + - ]: 99 : COL_AUTHOR7_DARK, COL_AUTHOR8_DARK, COL_AUTHOR9_DARK };
1614 : :
1615 : 99 : return Color( aArrayAnchor[ aAuthorIndex % (sizeof( aArrayAnchor ) / sizeof( aArrayAnchor[0] ))]);
1616 : : }
1617 : : else
1618 : 99 : return Color(COL_WHITE);
1619 : : }
1620 : :
1621 : 0 : void SwPostItMgr::SetActiveSidebarWin( SwSidebarWin* p)
1622 : : {
1623 [ # # ]: 0 : if ( p != mpActivePostIt )
1624 : : {
1625 : : // we need the temp variable so we can set mpActivePostIt before we call DeactivatePostIt
1626 : : // therefore we get a new layout in DOCCHANGED when switching from postit to document,
1627 : : // otherwise, GetActivePostIt() would still hold our old postit
1628 : 0 : SwSidebarWin* pActive = mpActivePostIt;
1629 : 0 : mpActivePostIt = p;
1630 [ # # ]: 0 : if (pActive)
1631 : : {
1632 : 0 : pActive->DeactivatePostIt();
1633 : 0 : mShadowState.mpShadowFld = 0;
1634 : : }
1635 [ # # ]: 0 : if (mpActivePostIt)
1636 : : {
1637 : 0 : mpActivePostIt->GotoPos();
1638 : 0 : mpView->AttrChangedNotify(0);
1639 : 0 : mpActivePostIt->ActivatePostIt();
1640 : : }
1641 : : }
1642 : 0 : }
1643 : :
1644 : 3 : IMPL_LINK( SwPostItMgr, CalcHdl, void*, /* pVoid*/ )
1645 : : {
1646 : 3 : mnEventId = 0;
1647 [ - + ]: 3 : if ( mbLayouting )
1648 : : {
1649 : : OSL_FAIL("Reentrance problem in Layout Manager!");
1650 : 0 : mbWaitingForCalcRects = false;
1651 : 0 : return 0;
1652 : : }
1653 : :
1654 : : // do not change order, even if it would seem so in the first place, we need the calcrects always
1655 [ + - ][ - + ]: 3 : if (CalcRects() || mbLayout)
[ - + ]
1656 : : {
1657 : 0 : mbLayout = false;
1658 : 0 : LayoutPostIts();
1659 : : }
1660 : 3 : return 0;
1661 : : }
1662 : :
1663 : 2591 : void SwPostItMgr::Rescale()
1664 : : {
1665 [ + + ]: 2633 : for(std::list<SwSidebarItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; ++i)
1666 [ + + ]: 42 : if ( (*i)->pPostIt )
1667 [ + - ]: 24 : (*i)->pPostIt->Rescale();
1668 : 2591 : }
1669 : :
1670 : 78 : sal_Int32 SwPostItMgr::GetInitialAnchorDistance() const
1671 : : {
1672 : 78 : const Fraction& f( mpEditWin->GetMapMode().GetScaleY() );
1673 : 78 : return POSTIT_INITIAL_ANCHOR_DISTANCE * f.GetNumerator() / f.GetDenominator();
1674 : : }
1675 : :
1676 : 78 : sal_Int32 SwPostItMgr::GetSpaceBetween() const
1677 : : {
1678 : 78 : const Fraction& f( mpEditWin->GetMapMode().GetScaleY() );
1679 : 78 : return ( POSTIT_SPACE_BETWEEN ) * f.GetNumerator() / f.GetDenominator();
1680 : : }
1681 : :
1682 : 0 : sal_Int32 SwPostItMgr::GetScrollSize() const
1683 : : {
1684 : 0 : const Fraction& f( mpEditWin->GetMapMode().GetScaleY() );
1685 : 0 : return ( POSTIT_SPACE_BETWEEN + POSTIT_MINIMUMSIZE_WITH_META ) * f.GetNumerator() / f.GetDenominator();
1686 : : }
1687 : :
1688 : 0 : sal_Int32 SwPostItMgr::GetMinimumSizeWithMeta() const
1689 : : {
1690 : 0 : const Fraction& f( mpEditWin->GetMapMode().GetScaleY() );
1691 : 0 : return POSTIT_MINIMUMSIZE_WITH_META * f.GetNumerator() / f.GetDenominator();
1692 : : }
1693 : :
1694 : 3 : sal_Int32 SwPostItMgr::GetSidebarScrollerHeight() const
1695 : : {
1696 : 3 : const Fraction& f( mpEditWin->GetMapMode().GetScaleY() );
1697 : 3 : return POSTIT_SCROLL_SIDEBAR_HEIGHT * f.GetNumerator() / f.GetDenominator();
1698 : : }
1699 : :
1700 : 0 : void SwPostItMgr::SetSpellChecking()
1701 : : {
1702 [ # # ]: 0 : for(std::list<SwSidebarItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; ++i)
1703 [ # # ]: 0 : if ( (*i)->pPostIt )
1704 [ # # ]: 0 : (*i)->pPostIt->SetSpellChecking();
1705 : 0 : }
1706 : :
1707 : 0 : void SwPostItMgr::SetReadOnlyState()
1708 : : {
1709 [ # # ]: 0 : for(std::list<SwSidebarItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; ++i)
1710 [ # # ]: 0 : if ( (*i)->pPostIt )
1711 [ # # ]: 0 : (*i)->pPostIt->SetReadonly( mbReadOnly );
1712 : 0 : }
1713 : :
1714 : 0 : void SwPostItMgr::CheckMetaText()
1715 : : {
1716 [ # # ]: 0 : for(std::list<SwSidebarItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; ++i)
1717 [ # # ]: 0 : if ( (*i)->pPostIt )
1718 [ # # ]: 0 : (*i)->pPostIt->CheckMetaText();
1719 : :
1720 : 0 : }
1721 : :
1722 : 0 : sal_uInt16 SwPostItMgr::Replace(SvxSearchItem* pItem)
1723 : : {
1724 : 0 : SwSidebarWin* pWin = GetActiveSidebarWin();
1725 : 0 : sal_uInt16 aResult = pWin->GetOutlinerView()->StartSearchAndReplace( *pItem );
1726 [ # # ]: 0 : if (!aResult)
1727 : 0 : SetActiveSidebarWin(0);
1728 : 0 : return aResult;
1729 : : }
1730 : :
1731 : 0 : sal_uInt16 SwPostItMgr::FinishSearchReplace(const ::com::sun::star::util::SearchOptions& rSearchOptions, bool bSrchForward)
1732 : : {
1733 : 0 : SwSidebarWin* pWin = GetActiveSidebarWin();
1734 [ # # ]: 0 : SvxSearchItem aItem(SID_SEARCH_ITEM );
1735 : 0 : aItem.SetSearchOptions(rSearchOptions);
1736 : 0 : aItem.SetBackward(!bSrchForward);
1737 [ # # ]: 0 : sal_uInt16 aResult = pWin->GetOutlinerView()->StartSearchAndReplace( aItem );
1738 [ # # ]: 0 : if (!aResult)
1739 [ # # ]: 0 : SetActiveSidebarWin(0);
1740 [ # # ]: 0 : return aResult;
1741 : : }
1742 : :
1743 : 0 : sal_uInt16 SwPostItMgr::SearchReplace(const SwFmtFld &pFld, const ::com::sun::star::util::SearchOptions& rSearchOptions, bool bSrchForward)
1744 : : {
1745 : 0 : sal_uInt16 aResult = 0;
1746 : 0 : SwSidebarWin* pWin = GetSidebarWin(&pFld);
1747 [ # # ]: 0 : if (pWin)
1748 : : {
1749 [ # # ]: 0 : ESelection aOldSelection = pWin->GetOutlinerView()->GetSelection();
1750 [ # # ]: 0 : if (bSrchForward)
1751 [ # # ]: 0 : pWin->GetOutlinerView()->SetSelection(ESelection(0,0,0,0));
1752 : : else
1753 [ # # ]: 0 : pWin->GetOutlinerView()->SetSelection(ESelection(0xFFFF,0xFFFF,0xFFFF,0xFFFF));
1754 [ # # ]: 0 : SvxSearchItem aItem(SID_SEARCH_ITEM );
1755 : 0 : aItem.SetSearchOptions(rSearchOptions);
1756 : 0 : aItem.SetBackward(!bSrchForward);
1757 [ # # ]: 0 : aResult = pWin->GetOutlinerView()->StartSearchAndReplace( aItem );
1758 [ # # ]: 0 : if (!aResult)
1759 [ # # ]: 0 : pWin->GetOutlinerView()->SetSelection(aOldSelection);
1760 : : else
1761 : : {
1762 [ # # ]: 0 : SetActiveSidebarWin(pWin);
1763 [ # # ]: 0 : MakeVisible(pWin);
1764 [ # # ]: 0 : }
1765 : : }
1766 : 0 : return aResult;
1767 : : }
1768 : :
1769 : 0 : void SwPostItMgr::AssureStdModeAtShell()
1770 : : {
1771 : : // deselect any drawing or frame and leave editing mode
1772 : 0 : SdrView* pSdrView = mpWrtShell->GetDrawView();
1773 [ # # ][ # # ]: 0 : if ( pSdrView && pSdrView->IsTextEdit() )
[ # # ]
1774 : : {
1775 : 0 : sal_Bool bLockView = mpWrtShell->IsViewLocked();
1776 : 0 : mpWrtShell->LockView( sal_True );
1777 : 0 : mpWrtShell->EndTextEdit();
1778 : 0 : mpWrtShell->LockView( bLockView );
1779 : : }
1780 : :
1781 [ # # ][ # # ]: 0 : if( mpWrtShell->IsSelFrmMode() || mpWrtShell->IsObjSelected())
[ # # ]
1782 : : {
1783 : 0 : mpWrtShell->UnSelectFrm();
1784 : 0 : mpWrtShell->LeaveSelFrmMode();
1785 : 0 : mpWrtShell->GetView().LeaveDrawCreate();
1786 : 0 : mpWrtShell->EnterStdMode();
1787 : :
1788 : 0 : mpWrtShell->DrawSelChanged();
1789 : 0 : mpView->StopShellTimer();
1790 : : }
1791 : 0 : }
1792 : :
1793 : 26024 : bool SwPostItMgr::HasActiveSidebarWin() const
1794 : : {
1795 : 26024 : return mpActivePostIt != 0;
1796 : : }
1797 : :
1798 : 0 : bool SwPostItMgr::HasActiveAnnotationWin() const
1799 : : {
1800 : 0 : return HasActiveSidebarWin() &&
1801 [ # # ][ # # ]: 0 : dynamic_cast<sw::annotation::SwAnnotationWin*>(mpActivePostIt) != 0;
[ # # ]
1802 : : }
1803 : :
1804 : 0 : void SwPostItMgr::GrabFocusOnActiveSidebarWin()
1805 : : {
1806 [ # # ]: 0 : if ( HasActiveSidebarWin() )
1807 : : {
1808 : 0 : mpActivePostIt->GrabFocus();
1809 : : }
1810 : 0 : }
1811 : :
1812 : 0 : void SwPostItMgr::UpdateDataOnActiveSidebarWin()
1813 : : {
1814 [ # # ]: 0 : if ( HasActiveSidebarWin() )
1815 : : {
1816 : 0 : mpActivePostIt->UpdateData();
1817 : : }
1818 : 0 : }
1819 : :
1820 : 0 : void SwPostItMgr::DeleteActiveSidebarWin()
1821 : : {
1822 [ # # ]: 0 : if ( HasActiveSidebarWin() )
1823 : : {
1824 : 0 : mpActivePostIt->Delete();
1825 : : }
1826 : 0 : }
1827 : :
1828 : 0 : void SwPostItMgr::HideActiveSidebarWin()
1829 : : {
1830 [ # # ]: 0 : if ( HasActiveSidebarWin() )
1831 : : {
1832 : 0 : mpActivePostIt->Hide();
1833 : : }
1834 : 0 : }
1835 : :
1836 : 0 : void SwPostItMgr::ToggleInsModeOnActiveSidebarWin()
1837 : : {
1838 [ # # ]: 0 : if ( HasActiveSidebarWin() )
1839 : : {
1840 : 0 : mpActivePostIt->ToggleInsMode();
1841 : : }
1842 : 0 : }
1843 : :
1844 : 18 : void SwPostItMgr::ConnectSidebarWinToFrm( const SwFrm& rFrm,
1845 : : const SwFmtFld& rFmtFld,
1846 : : SwSidebarWin& rSidebarWin )
1847 : : {
1848 [ + - ]: 18 : if ( mpFrmSidebarWinContainer == 0 )
1849 : : {
1850 [ + - ]: 18 : mpFrmSidebarWinContainer = new SwFrmSidebarWinContainer();
1851 : : }
1852 : :
1853 : 18 : const bool bInserted = mpFrmSidebarWinContainer->insert( rFrm, rFmtFld, rSidebarWin );
1854 [ - + ]: 36 : if ( bInserted &&
[ + - - + ]
1855 : 18 : mpWrtShell->GetAccessibleMap() )
1856 : : {
1857 [ # # ][ # # ]: 0 : mpWrtShell->GetAccessibleMap()->InvalidatePosOrSize( 0, 0, &rSidebarWin, SwRect() );
1858 : : }
1859 : 18 : }
1860 : :
1861 : 15 : void SwPostItMgr::DisconnectSidebarWinFromFrm( const SwFrm& rFrm,
1862 : : SwSidebarWin& rSidebarWin )
1863 : : {
1864 [ + - ]: 15 : if ( mpFrmSidebarWinContainer != 0 )
1865 : : {
1866 : 15 : const bool bRemoved = mpFrmSidebarWinContainer->remove( rFrm, rSidebarWin );
1867 [ - + ]: 30 : if ( bRemoved &&
[ + - - + ]
1868 : 15 : mpWrtShell->GetAccessibleMap() )
1869 : : {
1870 : 0 : mpWrtShell->GetAccessibleMap()->Dispose( 0, 0, &rSidebarWin );
1871 : : }
1872 : : }
1873 : 15 : }
1874 : :
1875 : 0 : bool SwPostItMgr::HasFrmConnectedSidebarWins( const SwFrm& rFrm )
1876 : : {
1877 : 0 : bool bRet( false );
1878 : :
1879 [ # # ]: 0 : if ( mpFrmSidebarWinContainer != 0 )
1880 : : {
1881 : 0 : bRet = !mpFrmSidebarWinContainer->empty( rFrm );
1882 : : }
1883 : :
1884 : 0 : return bRet;
1885 : : }
1886 : :
1887 : 0 : Window* SwPostItMgr::GetSidebarWinForFrmByIndex( const SwFrm& rFrm,
1888 : : const sal_Int32 nIndex )
1889 : : {
1890 : 0 : Window* pSidebarWin( 0 );
1891 : :
1892 [ # # ]: 0 : if ( mpFrmSidebarWinContainer != 0 )
1893 : : {
1894 : 0 : pSidebarWin = mpFrmSidebarWinContainer->get( rFrm, nIndex );
1895 : : }
1896 : :
1897 : 0 : return pSidebarWin;
1898 : : }
1899 : :
1900 : 0 : void SwPostItMgr::GetAllSidebarWinForFrm( const SwFrm& rFrm,
1901 : : std::vector< Window* >* pChildren )
1902 : : {
1903 [ # # ]: 0 : if ( mpFrmSidebarWinContainer != 0 )
1904 : : {
1905 : 0 : mpFrmSidebarWinContainer->getAll( rFrm, pChildren );
1906 : : }
1907 : 0 : }
1908 : :
1909 : 0 : void SwNoteProps::Commit() {}
1910 : 0 : void SwNoteProps::Notify( const ::com::sun::star::uno::Sequence< rtl::OUString >& ) {}
1911 : :
1912 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|