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 : : #include <com/sun/star/awt/XWindow.hpp>
30 : : #include <svx/svdpntv.hxx>
31 : : #include <vcl/msgbox.hxx>
32 : : #include <svx/sdrpaintwindow.hxx>
33 : : #include <svtools/grfmgr.hxx>
34 : : #include <svx/svdmodel.hxx>
35 : :
36 : : #ifdef DBG_UTIL
37 : : #include <svdibrow.hxx>
38 : : #endif
39 : : #include <svx/svdpage.hxx>
40 : : #include <svx/svdpagv.hxx>
41 : : #include <svl/smplhint.hxx>
42 : :
43 : : #include <editeng/editdata.hxx>
44 : : #include <svx/svdmrkv.hxx>
45 : : #include <svx/svdundo.hxx>
46 : : #include <svx/svdview.hxx>
47 : : #include <svx/svdglue.hxx>
48 : : #include <svx/svdobj.hxx>
49 : : #include <svx/svdograf.hxx>
50 : : #include <svx/svdattrx.hxx>
51 : : #include "svdibrow.hxx"
52 : : #include "svx/svditer.hxx"
53 : : #include <svx/svdouno.hxx>
54 : : #include <svx/sdr/overlay/overlayobjectlist.hxx>
55 : : #include <svx/sdr/overlay/overlayrollingrectangle.hxx>
56 : : #include <svx/sdr/overlay/overlaymanager.hxx>
57 : : #include <svx/sxlayitm.hxx>
58 : : #include <svl/itemiter.hxx>
59 : : #include <editeng/eeitem.hxx>
60 : : #include <svl/whiter.hxx>
61 : : #include <svl/style.hxx>
62 : : #include <svx/sdrpagewindow.hxx>
63 : : #include <vcl/svapp.hxx>
64 : : #include <com/sun/star/awt/PosSize.hpp>
65 : : #include <com/sun/star/awt/XControl.hpp>
66 : :
67 : : // #i38135#
68 : : #include <svx/sdr/contact/objectcontact.hxx>
69 : : #include <svx/sdr/animation/objectanimator.hxx>
70 : : #include <svx/sdr/contact/viewcontact.hxx>
71 : :
72 : : using namespace ::rtl;
73 : : using namespace ::com::sun::star;
74 : :
75 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
76 : : // interface to SdrPaintWindow
77 : :
78 : 49644 : SdrPaintWindow* SdrPaintView::FindPaintWindow(const OutputDevice& rOut) const
79 : : {
80 [ + - ][ + - ]: 49644 : for(SdrPaintWindowVector::const_iterator a = maPaintWindows.begin(); a != maPaintWindows.end(); ++a)
81 : : {
82 [ + - ]: 49644 : if(&((*a)->GetOutputDevice()) == &rOut)
83 : : {
84 : 49644 : return *a;
85 : : }
86 : : }
87 : :
88 : 49644 : return 0L;
89 : : }
90 : :
91 : 31894 : SdrPaintWindow* SdrPaintView::GetPaintWindow(sal_uInt32 nIndex) const
92 : : {
93 [ + - ]: 31894 : if(nIndex < maPaintWindows.size())
94 : : {
95 : 31894 : return maPaintWindows[nIndex];
96 : : }
97 : :
98 : 31894 : return 0L;
99 : : }
100 : :
101 : 2124 : void SdrPaintView::AppendPaintWindow(SdrPaintWindow& rNew)
102 : : {
103 [ + - ]: 2124 : maPaintWindows.push_back(&rNew);
104 : 2124 : }
105 : :
106 : 615 : SdrPaintWindow* SdrPaintView::RemovePaintWindow(SdrPaintWindow& rOld)
107 : : {
108 : 615 : SdrPaintWindow* pRetval = 0L;
109 [ + - ]: 615 : const SdrPaintWindowVector::iterator aFindResult = ::std::find(maPaintWindows.begin(), maPaintWindows.end(), &rOld);
110 : :
111 [ + - ][ + - ]: 615 : if(aFindResult != maPaintWindows.end())
112 : : {
113 : : // remember return value, aFindResult is no longer valid after deletion
114 : 615 : pRetval = *aFindResult;
115 [ + - ]: 615 : maPaintWindows.erase(aFindResult);
116 : : }
117 : :
118 : 615 : return pRetval;
119 : : }
120 : :
121 : 1173 : OutputDevice* SdrPaintView::GetFirstOutputDevice() const
122 : : {
123 [ + - ]: 1173 : if(PaintWindowCount())
124 : : {
125 : 1173 : return &(GetPaintWindow(0)->GetOutputDevice());
126 : : }
127 : :
128 : 1173 : return 0L;
129 : : }
130 : :
131 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
132 : :
133 [ # # ][ # # ]: 869983 : TYPEINIT1( SvxViewHint, SfxHint );
134 : :
135 : 4504 : SvxViewHint::SvxViewHint (HintType eHintType)
136 : 4504 : : meHintType(eHintType)
137 : : {
138 : 4504 : }
139 : :
140 : 0 : SvxViewHint::HintType SvxViewHint::GetHintType (void) const
141 : : {
142 : 0 : return meHintType;
143 : : }
144 : :
145 : :
146 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
147 : :
148 [ # # ][ # # ]: 0 : TYPEINIT2(SdrPaintView,SfxListener,SfxRepeatTarget);
[ # # ]
149 : :
150 : : DBG_NAME(SdrPaintView);
151 : :
152 : 4699 : void SdrPaintView::ImpClearVars()
153 : : {
154 : : #ifdef DBG_UTIL
155 : : pItemBrowser=NULL;
156 : : #endif
157 : 4699 : bPageVisible=sal_True;
158 : 4699 : bPageBorderVisible=sal_True;
159 : 4699 : bBordVisible=sal_True;
160 : 4699 : bGridVisible=sal_True;
161 : 4699 : bGridFront =sal_False;
162 : 4699 : bHlplVisible=sal_True;
163 : 4699 : bHlplFront =sal_True;
164 : 4699 : bGlueVisible=sal_False;
165 : 4699 : bGlueVisible2=sal_False;
166 : 4699 : bGlueVisible3=sal_False;
167 : 4699 : bGlueVisible4=sal_False;
168 : 4699 : bSwapAsynchron=sal_False;
169 : 4699 : bPrintPreview=sal_False;
170 : 4699 : mbPreviewRenderer=sal_False;
171 : :
172 : 4699 : eAnimationMode = SDR_ANIMATION_ANIMATE;
173 : 4699 : bAnimationPause = sal_False;
174 : :
175 : 4699 : nHitTolPix=2;
176 : 4699 : nMinMovPix=3;
177 : 4699 : nHitTolLog=0;
178 : 4699 : nMinMovLog=0;
179 : 4699 : pActualOutDev=NULL;
180 : 4699 : pDragWin=NULL;
181 : 4699 : bRestoreColors=sal_True;
182 : 4699 : pDefaultStyleSheet=NULL;
183 : 4699 : bSomeObjChgdFlag=sal_False;
184 : 4699 : nGraphicManagerDrawMode = GRFMGR_DRAW_STANDARD;
185 [ + - ]: 4699 : aComeBackTimer.SetTimeout(1);
186 [ + - ]: 4699 : aComeBackTimer.SetTimeoutHdl(LINK(this,SdrPaintView,ImpComeBackHdl));
187 [ + - ]: 4699 : String aNam; // System::GetUserName() just return an empty string
188 : :
189 [ + - ]: 4699 : if (pMod)
190 [ + - ]: 4699 : SetDefaultStyleSheet(pMod->GetDefaultStyleSheet(), sal_True);
191 : :
192 [ + - ]: 4699 : aNam.ToUpperAscii();
193 : :
194 [ + - ]: 4699 : maGridColor = Color( COL_BLACK );
195 : 4699 : }
196 : :
197 : 4699 : SdrPaintView::SdrPaintView(SdrModel* pModel1, OutputDevice* pOut)
198 : : : mpPageView(NULL),
199 : 4699 : aDefaultAttr(pModel1->GetItemPool()),
200 : : mbBufferedOutputAllowed(false),
201 : : mbBufferedOverlayAllowed(false),
202 : : mbPagePaintingAllowed(true),
203 : : mbHideOle(false),
204 : : mbHideChart(false),
205 : : mbHideDraw(false),
206 [ + - ][ + - ]: 9398 : mbHideFormControl(false)
[ + - ][ + - ]
[ + - ][ + - ]
[ + - + - ]
[ + - ][ + - ]
[ + - ]
207 : : {
208 : : DBG_CTOR(SdrPaintView,NULL);
209 : 4699 : pMod=pModel1;
210 [ + - ]: 4699 : ImpClearVars();
211 : :
212 [ + + ]: 4699 : if(pOut)
213 : : {
214 [ + - ]: 2124 : AddWindowToPaintView(pOut);
215 : : }
216 : :
217 : : // flag to visualize groups
218 : 4699 : bVisualizeEnteredGroup = sal_True;
219 : :
220 [ + - ]: 4699 : maColorConfig.AddListener(this);
221 [ + - ]: 4699 : onChangeColorConfig();
222 : 4699 : }
223 : :
224 [ + - ][ + - ]: 4508 : SdrPaintView::~SdrPaintView()
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
225 : : {
226 : : DBG_DTOR(SdrPaintView,NULL);
227 [ + + ]: 4508 : if (pDefaultStyleSheet)
228 [ + - ]: 1263 : EndListening(*pDefaultStyleSheet);
229 : :
230 [ + - ]: 4508 : maColorConfig.RemoveListener(this);
231 [ + - ]: 4508 : ClearPageView();
232 : :
233 : : #ifdef DBG_UTIL
234 : : if(pItemBrowser)
235 : : {
236 : : delete pItemBrowser;
237 : : }
238 : : #endif
239 : :
240 : : // delete existing SdrPaintWindows
241 [ + + ]: 5926 : while(!maPaintWindows.empty())
242 : : {
243 [ + - ][ + - ]: 1418 : delete maPaintWindows.back();
[ + - ]
244 [ + - ]: 1418 : maPaintWindows.pop_back();
245 : : }
246 [ - + ]: 4508 : }
247 : :
248 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
249 : :
250 : 304910 : void SdrPaintView::Notify(SfxBroadcaster& rBC, const SfxHint& rHint)
251 : : {
252 : : //If the stylesheet has been destroyed
253 [ + + ][ + + ]: 304910 : if (&rBC == pDefaultStyleSheet)
254 : : {
255 [ + - ][ - + ]: 1520 : if (rHint.ISA(SfxSimpleHint) && ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING)
[ - + ]
256 : 0 : pDefaultStyleSheet = NULL;
257 : 304910 : return;
258 : : }
259 : :
260 : 303390 : sal_Bool bObjChg=!bSomeObjChgdFlag; // if sal_True, evaluate for ComeBack timer
261 [ + + ]: 303390 : if (bObjChg) {
262 [ + - ][ + + ]: 148182 : SdrHint* pSdrHint=PTR_CAST(SdrHint,&rHint);
263 [ + + ]: 148182 : if (pSdrHint!=NULL) {
264 : 10349 : SdrHintKind eKind=pSdrHint->GetKind();
265 [ + + ][ + + ]: 10349 : if (eKind==HINT_OBJCHG || eKind==HINT_OBJINSERTED || eKind==HINT_OBJREMOVED) {
[ + + ]
266 [ + - ]: 5355 : if (bObjChg) {
267 : 5355 : bSomeObjChgdFlag=sal_True;
268 : 5355 : aComeBackTimer.Start();
269 : : }
270 : : }
271 [ + + ]: 10349 : if (eKind==HINT_PAGEORDERCHG) {
272 : 4263 : const SdrPage* pPg=pSdrHint->GetPage();
273 : :
274 [ + + ][ + + ]: 4263 : if(pPg && !pPg->IsInserted())
[ + - ]
275 : : {
276 [ + + ][ - + ]: 2235 : if(mpPageView && mpPageView->GetPage() == pPg)
[ - + ]
277 : : {
278 : 0 : HideSdrPage();
279 : : }
280 : : }
281 : : }
282 : : }
283 : : }
284 : : }
285 : :
286 : 144 : void SdrPaintView::ConfigurationChanged( ::utl::ConfigurationBroadcaster* , sal_uInt32 )
287 : : {
288 : 144 : onChangeColorConfig();
289 : 144 : InvalidateAllWin();
290 : 144 : }
291 : :
292 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
293 : :
294 : 4579 : IMPL_LINK_NOARG_INLINE_START(SdrPaintView, ImpComeBackHdl)
295 : : {
296 [ + - ]: 4579 : if (bSomeObjChgdFlag) {
297 : 4579 : bSomeObjChgdFlag=sal_False;
298 : 4579 : ModelHasChanged();
299 : : }
300 : 4579 : return 0;
301 : : }
302 : 4298 : IMPL_LINK_NOARG_INLINE_END(SdrPaintView,ImpComeBackHdl)
303 : :
304 : 281 : void SdrPaintView::FlushComeBackTimer() const
305 : : {
306 [ + - ]: 281 : if (bSomeObjChgdFlag) {
307 : : // casting to nonconst
308 : 281 : ((SdrPaintView*)this)->ImpComeBackHdl(&((SdrPaintView*)this)->aComeBackTimer);
309 : 281 : ((SdrPaintView*)this)->aComeBackTimer.Stop();
310 : : }
311 : 281 : }
312 : :
313 : 4384 : void SdrPaintView::ModelHasChanged()
314 : : {
315 : : // broadcast to all PageViews
316 [ + + ][ - + ]: 4384 : if(mpPageView && !mpPageView->GetPage()->IsInserted())
[ - + ]
317 : : {
318 : 0 : HideSdrPage();
319 : : }
320 : :
321 : : // test mpPageView here again, HideSdrPage() may have invalidated it.
322 [ + + ]: 4384 : if(mpPageView)
323 : : {
324 : 1276 : mpPageView->ModelHasChanged();
325 : : }
326 : :
327 : : #ifdef DBG_UTIL
328 : : if(pItemBrowser)
329 : : {
330 : : pItemBrowser->SetDirty();
331 : : }
332 : : #endif
333 : 4384 : }
334 : :
335 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
336 : :
337 : 2168 : sal_Bool SdrPaintView::IsAction() const
338 : : {
339 : 2168 : return false;
340 : : }
341 : :
342 : 0 : void SdrPaintView::MovAction(const Point&)
343 : : {
344 : 0 : }
345 : :
346 : 0 : void SdrPaintView::EndAction()
347 : : {
348 : 0 : }
349 : :
350 : 0 : void SdrPaintView::BckAction()
351 : : {
352 : 0 : }
353 : :
354 : 9385 : void SdrPaintView::BrkAction()
355 : : {
356 : 9385 : }
357 : :
358 : 0 : void SdrPaintView::TakeActionRect(Rectangle&) const
359 : : {
360 : 0 : }
361 : :
362 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
363 : : // info about TextEdit. Default is sal_False.
364 : 0 : bool SdrPaintView::IsTextEdit() const
365 : : {
366 : 0 : return false;
367 : : }
368 : :
369 : : // info about TextEditPageView. Default is 0L.
370 : 0 : SdrPageView* SdrPaintView::GetTextEditPageView() const
371 : : {
372 : 0 : return 0L;
373 : : }
374 : :
375 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
376 : :
377 : 0 : sal_uInt16 SdrPaintView::ImpGetMinMovLogic(short nMinMov, const OutputDevice* pOut) const
378 : : {
379 [ # # ]: 0 : if (nMinMov>=0) return sal_uInt16(nMinMov);
380 [ # # ]: 0 : if (pOut==NULL)
381 : : {
382 : 0 : pOut = GetFirstOutputDevice();
383 : : }
384 [ # # ]: 0 : if (pOut!=NULL) {
385 [ # # ]: 0 : return short(-pOut->PixelToLogic(Size(nMinMov,0)).Width());
386 : : } else {
387 : 0 : return 0;
388 : : }
389 : : }
390 : :
391 : 0 : sal_uInt16 SdrPaintView::ImpGetHitTolLogic(short nHitTol, const OutputDevice* pOut) const
392 : : {
393 [ # # ]: 0 : if (nHitTol>=0) return sal_uInt16(nHitTol);
394 [ # # ]: 0 : if (pOut==NULL)
395 : : {
396 : 0 : pOut = GetFirstOutputDevice();
397 : : }
398 [ # # ]: 0 : if (pOut!=NULL) {
399 [ # # ]: 0 : return short(-pOut->PixelToLogic(Size(nHitTol,0)).Width());
400 : : } else {
401 : 0 : return 0;
402 : : }
403 : : }
404 : :
405 : 7751 : void SdrPaintView::TheresNewMapMode()
406 : : {
407 [ + + ]: 7751 : if (pActualOutDev!=NULL) {
408 [ + - ]: 5176 : nHitTolLog=(sal_uInt16)((OutputDevice*)pActualOutDev)->PixelToLogic(Size(nHitTolPix,0)).Width();
409 [ + - ]: 5176 : nMinMovLog=(sal_uInt16)((OutputDevice*)pActualOutDev)->PixelToLogic(Size(nMinMovPix,0)).Width();
410 : : }
411 : 7751 : }
412 : :
413 : 4065 : void SdrPaintView::SetActualWin(const OutputDevice* pWin)
414 : : {
415 : 4065 : pActualOutDev=pWin;
416 : 4065 : TheresNewMapMode();
417 : 4065 : }
418 : :
419 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
420 : :
421 : 4508 : void SdrPaintView::ClearPageView()
422 : : {
423 : 4508 : BrkAction();
424 : :
425 [ + + ]: 4508 : if(mpPageView)
426 : : {
427 : 201 : InvalidateAllWin();
428 [ + - ]: 201 : delete mpPageView;
429 : 201 : mpPageView = 0L;
430 : : }
431 : 4508 : }
432 : :
433 : 3246 : SdrPageView* SdrPaintView::ShowSdrPage(SdrPage* pPage)
434 : : {
435 [ + - ][ - + ]: 3246 : if(pPage && (!mpPageView || mpPageView->GetPage() != pPage))
[ # # ][ + - ]
436 : : {
437 [ - + ]: 3246 : if(mpPageView)
438 : : {
439 : 0 : InvalidateAllWin();
440 [ # # ]: 0 : delete mpPageView;
441 : : }
442 : :
443 [ + - ]: 3246 : mpPageView = new SdrPageView(pPage, *((SdrView*)this));
444 : 3246 : mpPageView->Show();
445 : : }
446 : :
447 : 3246 : return mpPageView;
448 : : }
449 : :
450 : 3232 : void SdrPaintView::HideSdrPage()
451 : : {
452 [ + + ]: 3232 : if(mpPageView)
453 : : {
454 : 2954 : mpPageView->Hide();
455 [ + - ]: 2954 : delete mpPageView;
456 : 2954 : mpPageView = 0L;
457 : : }
458 : 3232 : }
459 : :
460 : 2124 : void SdrPaintView::AddWindowToPaintView(OutputDevice* pNewWin)
461 : : {
462 : : DBG_ASSERT(pNewWin, "SdrPaintView::AddWindowToPaintView: No OutputDevice(!)");
463 [ + - ]: 2124 : SdrPaintWindow* pNewPaintWindow = new SdrPaintWindow(*this, *pNewWin);
464 : 2124 : AppendPaintWindow(*pNewPaintWindow);
465 : :
466 [ - + ]: 2124 : if(mpPageView)
467 : : {
468 : 0 : mpPageView->AddPaintWindowToPageView(*pNewPaintWindow);
469 : : }
470 : :
471 : : #ifdef DBG_UTIL
472 : : if (pItemBrowser!=NULL)
473 : : pItemBrowser->ForceParent();
474 : : #endif
475 : 2124 : }
476 : :
477 : 615 : void SdrPaintView::DeleteWindowFromPaintView(OutputDevice* pOldWin)
478 : : {
479 : : DBG_ASSERT(pOldWin, "SdrPaintView::DeleteWindowFromPaintView: No OutputDevice(!)");
480 : 615 : SdrPaintWindow* pCandidate = FindPaintWindow(*pOldWin);
481 : :
482 [ + - ]: 615 : if(pCandidate)
483 : : {
484 [ + + ]: 615 : if(mpPageView)
485 : : {
486 : 363 : mpPageView->RemovePaintWindowFromPageView(*pCandidate);
487 : : }
488 : :
489 : 615 : RemovePaintWindow(*pCandidate);
490 [ + - ]: 615 : delete pCandidate;
491 : : }
492 : :
493 : : #ifdef DBG_UTIL
494 : : if (pItemBrowser!=NULL)
495 : : pItemBrowser->ForceParent();
496 : : #endif
497 : 615 : }
498 : :
499 : 536 : void SdrPaintView::SetLayerVisible(const XubString& rName, sal_Bool bShow)
500 : : {
501 [ + - ]: 536 : if(mpPageView)
502 : : {
503 : 536 : mpPageView->SetLayerVisible(rName,bShow);
504 : : }
505 : :
506 : 536 : InvalidateAllWin();
507 : 536 : }
508 : :
509 : 0 : bool SdrPaintView::IsLayerVisible(const XubString& rName) const
510 : : {
511 [ # # ]: 0 : if(mpPageView)
512 : : {
513 : 0 : return mpPageView->IsLayerVisible(rName);
514 : : }
515 : :
516 : 0 : return false;
517 : : }
518 : :
519 : 2680 : void SdrPaintView::SetLayerLocked(const XubString& rName, sal_Bool bLock)
520 : : {
521 [ + - ]: 2680 : if(mpPageView)
522 : : {
523 : 2680 : mpPageView->SetLayerLocked(rName,bLock);
524 : : }
525 : 2680 : }
526 : :
527 : 0 : bool SdrPaintView::IsLayerLocked(const XubString& rName) const
528 : : {
529 [ # # ]: 0 : if(mpPageView)
530 : : {
531 : 0 : return mpPageView->IsLayerLocked(rName);
532 : : }
533 : :
534 : 0 : return false;
535 : : }
536 : :
537 : 19 : void SdrPaintView::SetLayerPrintable(const XubString& rName, sal_Bool bPrn)
538 : : {
539 [ + - ]: 19 : if(mpPageView)
540 : : {
541 : 19 : mpPageView->SetLayerPrintable(rName,bPrn);
542 : : }
543 : 19 : }
544 : :
545 : 0 : bool SdrPaintView::IsLayerPrintable(const XubString& rName) const
546 : : {
547 [ # # ]: 0 : if(mpPageView)
548 : : {
549 : 0 : return mpPageView->IsLayerPrintable(rName);
550 : : }
551 : :
552 : 0 : return false;
553 : : }
554 : :
555 : 15562 : void SdrPaintView::PrePaint()
556 : : {
557 [ + + ]: 15562 : if(mpPageView)
558 : : {
559 : 15547 : mpPageView->PrePaint();
560 : : }
561 : 15562 : }
562 : :
563 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
564 : : // #define SVX_REPAINT_TIMER_TEST
565 : :
566 : 2248 : void SdrPaintView::CompleteRedraw(OutputDevice* pOut, const Region& rReg, sdr::contact::ViewObjectContactRedirector* pRedirector)
567 : : {
568 : : #ifdef SVX_REPAINT_TIMER_TEST
569 : : #define REMEMBERED_TIMES_COUNT (10)
570 : : static bool bDoTimerTest(false);
571 : : static bool bTimesInited(false);
572 : : static sal_uInt32 nRepeatCount(10L);
573 : : static double fLastTimes[REMEMBERED_TIMES_COUNT];
574 : : const sal_uInt32 nStartTime(Time::GetSystemTicks());
575 : : sal_uInt32 count(1L);
576 : : sal_uInt32 a;
577 : :
578 : : if(bDoTimerTest)
579 : : {
580 : : count = nRepeatCount;
581 : : }
582 : :
583 : : for(a = 0L; a < count; a++)
584 : : {
585 : : #endif // SVX_REPAINT_TIMER_TEST
586 : :
587 : : // #i74769# check if pOut is a win and has a ClipRegion. If Yes, the Region
588 : : // rReg may be made more granular (fine) with using it. Normally, rReg
589 : : // does come from Window::Paint() anyways and thus is based on a single
590 : : // rectangle which was derived from exactly that repaint region
591 [ + - ]: 2248 : Region aOptimizedRepaintRegion(rReg);
592 : :
593 [ + - ][ + + ]: 2248 : if(pOut && OUTDEV_WINDOW == pOut->GetOutDevType())
[ + + ]
594 : : {
595 : 1880 : Window* pWindow = (Window*)pOut;
596 : :
597 [ + - ][ + - ]: 1880 : if(pWindow->IsInPaint())
598 : : {
599 [ + - ][ + - ]: 1880 : if(!pWindow->GetPaintRegion().IsEmpty())
[ + - ][ + - ]
600 : : {
601 [ + - ][ + - ]: 1880 : aOptimizedRepaintRegion.Intersect(pWindow->GetPaintRegion());
[ + - ]
602 : :
603 : : #ifdef DBG_UTIL
604 : : // #i74769# test-paint repaint region
605 : : static bool bDoPaintForVisualControl(false);
606 : : if(bDoPaintForVisualControl)
607 : : {
608 : : RegionHandle aRegionHandle(aOptimizedRepaintRegion.BeginEnumRects());
609 : : Rectangle aRegionRectangle;
610 : :
611 : : while(aOptimizedRepaintRegion.GetEnumRects(aRegionHandle, aRegionRectangle))
612 : : {
613 : : pWindow->SetLineColor(COL_LIGHTGREEN);
614 : : pWindow->SetFillColor();
615 : : pWindow->DrawRect(aRegionRectangle);
616 : : }
617 : :
618 : : aOptimizedRepaintRegion.EndEnumRects(aRegionHandle);
619 : : }
620 : : #endif
621 : : }
622 : : }
623 : : }
624 : :
625 [ + - ]: 2248 : SdrPaintWindow* pPaintWindow = BeginCompleteRedraw(pOut);
626 : : OSL_ENSURE(pPaintWindow, "SdrPaintView::CompleteRedraw: No OutDev (!)");
627 : :
628 [ + - ]: 2248 : DoCompleteRedraw(*pPaintWindow, aOptimizedRepaintRegion, pRedirector);
629 [ + - ][ + - ]: 2248 : EndCompleteRedraw(*pPaintWindow, true);
630 : :
631 : : #ifdef SVX_REPAINT_TIMER_TEST
632 : : }
633 : :
634 : : if(bDoTimerTest)
635 : : {
636 : : const sal_uInt32 nStopTime(Time::GetSystemTicks());
637 : : const sal_uInt32 nNeededTime(nStopTime - nStartTime);
638 : : const double fTimePerPaint((double)nNeededTime / (double)nRepeatCount);
639 : :
640 : : if(!bTimesInited)
641 : : {
642 : : for(a = 0L; a < REMEMBERED_TIMES_COUNT; a++)
643 : : {
644 : : fLastTimes[a] = fTimePerPaint;
645 : : }
646 : :
647 : : bTimesInited = true;
648 : : }
649 : : else
650 : : {
651 : : for(a = 1L; a < REMEMBERED_TIMES_COUNT; a++)
652 : : {
653 : : fLastTimes[a - 1L] = fLastTimes[a];
654 : : }
655 : :
656 : : fLastTimes[REMEMBERED_TIMES_COUNT - 1L] = fTimePerPaint;
657 : : }
658 : :
659 : : double fAddedTimes(0.0);
660 : :
661 : : for(a = 0L; a < REMEMBERED_TIMES_COUNT; a++)
662 : : {
663 : : fAddedTimes += fLastTimes[a];
664 : : }
665 : :
666 : : const double fAverageTimePerPaint(fAddedTimes / (double)REMEMBERED_TIMES_COUNT);
667 : :
668 : : fprintf(stderr, "-----------(start result)----------\n");
669 : : fprintf(stderr, "StartTime : %u, StopTime: %u, NeededTime: %u, TimePerPaint: %f\n", nStartTime, nStopTime, nNeededTime, fTimePerPaint);
670 : : fprintf(stderr, "Remembered times: ");
671 : :
672 : : for(a = 0L; a < REMEMBERED_TIMES_COUNT; a++)
673 : : {
674 : : fprintf(stderr, "%d: %f ", a, fLastTimes[a]);
675 : : }
676 : :
677 : : fprintf(stderr, "\n");
678 : : fprintf(stderr, "AverageTimePerPaint: %f\n", fAverageTimePerPaint);
679 : : fprintf(stderr, "-----------(stop result)----------\n");
680 : : }
681 : : #endif // SVX_REPAINT_TIMER_TEST
682 : 2248 : }
683 : :
684 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
685 : : // #i72889#
686 : :
687 : 16025 : SdrPaintWindow* SdrPaintView::BeginCompleteRedraw(OutputDevice* pOut)
688 : : {
689 : : OSL_ENSURE(pOut, "SdrPaintView::BeginCompleteRedraw: No OutDev (!)");
690 : 16025 : SdrPaintWindow* pPaintWindow = FindPaintWindow(*pOut);
691 : :
692 [ + - ]: 16025 : if(pPaintWindow)
693 : : {
694 : : // draw preprocessing, only for known devices
695 : : // prepare PreRendering
696 : 16025 : pPaintWindow->PreparePreRenderDevice();
697 : : }
698 : : else
699 : : {
700 : : // None of the known OutputDevices is the target of this paint, use
701 : : // a temporary SdrPaintWindow for this Redraw.
702 [ # # ]: 0 : pPaintWindow = new SdrPaintWindow(*this, *pOut);
703 : 0 : pPaintWindow->setTemporaryTarget(true);
704 : : }
705 : :
706 : 16025 : return pPaintWindow;
707 : : }
708 : :
709 : 2248 : void SdrPaintView::DoCompleteRedraw(SdrPaintWindow& rPaintWindow, const Region& rReg, sdr::contact::ViewObjectContactRedirector* pRedirector)
710 : : {
711 : : // redraw all PageViews with the target. This may expand the RedrawRegion
712 : : // at the PaintWindow, plus taking care of FormLayer expansion
713 [ + + ]: 2248 : if(mpPageView)
714 : : {
715 : 2222 : mpPageView->CompleteRedraw(rPaintWindow, rReg, pRedirector);
716 : : }
717 : 2248 : }
718 : :
719 : 16025 : void SdrPaintView::EndCompleteRedraw(SdrPaintWindow& rPaintWindow, bool bPaintFormLayer)
720 : : {
721 [ - + ]: 16025 : if(rPaintWindow.getTemporaryTarget())
722 : : {
723 : : // get rid of temp target again
724 [ # # ]: 0 : delete (&rPaintWindow);
725 : : }
726 : : else
727 : : {
728 : : // draw postprocessing, only for known devices
729 : : // it is necessary to always paint FormLayer
730 [ + - ]: 16025 : if(bPaintFormLayer)
731 : : {
732 : 16025 : ImpFormLayerDrawing(rPaintWindow);
733 : : }
734 : :
735 : : // look for active TextEdit. As long as this cannot be painted to a VDev,
736 : : // it cannot get part of buffering. In that case, output evtl. prerender
737 : : // early and paint text edit to window.
738 [ - + ][ # # ]: 16025 : const bool bTextEditActive(IsTextEdit() && GetTextEditPageView());
739 : :
740 [ - + ]: 16025 : if(bTextEditActive)
741 : : {
742 : : // output PreRendering and destroy it so that it is not used for FormLayer
743 : : // or overlay
744 : 0 : rPaintWindow.OutputPreRenderDevice(rPaintWindow.GetRedrawRegion());
745 : :
746 : : // draw old text edit stuff before overlay to have it as part of the background
747 : : // ATM. This will be changed to have the text editing on the overlay, bit it
748 : : // is not an easy thing to do, see BegTextEdit and the OutlinerView stuff used...
749 [ # # ]: 0 : if(bTextEditActive)
750 : : {
751 : 0 : ImpTextEditDrawing(rPaintWindow);
752 : : }
753 : :
754 : : // draw Overlay directly to window. This will save the contents of the window
755 : : // in the RedrawRegion to the overlay background buffer, too.
756 : : // This may lead to problems when reading from the screen is slow from the
757 : : // graphics driver/graphiccard combination.
758 : 0 : rPaintWindow.DrawOverlay(rPaintWindow.GetRedrawRegion(), false);
759 : : }
760 : : else
761 : : {
762 : : // draw Overlay, also to PreRender device if exists
763 : 16025 : rPaintWindow.DrawOverlay(rPaintWindow.GetRedrawRegion(), true);
764 : :
765 : : // output PreRendering
766 : 16025 : rPaintWindow.OutputPreRenderDevice(rPaintWindow.GetRedrawRegion());
767 : : }
768 : : }
769 : 16025 : }
770 : :
771 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
772 : :
773 : 13777 : SdrPaintWindow* SdrPaintView::BeginDrawLayers(OutputDevice* pOut, const Region& rReg, bool bDisableIntersect)
774 : : {
775 : : // #i74769# use BeginCompleteRedraw() as common base
776 : 13777 : SdrPaintWindow* pPaintWindow = BeginCompleteRedraw(pOut);
777 : : OSL_ENSURE(pPaintWindow, "SdrPaintView::BeginDrawLayers: No SdrPaintWindow (!)");
778 : :
779 [ + - ]: 13777 : if(mpPageView)
780 : : {
781 : 13777 : SdrPageWindow* pKnownTarget = mpPageView->FindPageWindow(*pPaintWindow);
782 : :
783 [ + - ]: 13777 : if(pKnownTarget)
784 : : {
785 [ + - ]: 13777 : Region aOptimizedRepaintRegion = OptimizeDrawLayersRegion( pOut, rReg, bDisableIntersect );
786 : :
787 : : // prepare redraw
788 [ + - ]: 13777 : pKnownTarget->PrepareRedraw(aOptimizedRepaintRegion);
789 : :
790 : : // remember prepared SdrPageWindow
791 [ + - ][ + - ]: 13777 : mpPageView->setPreparedPageWindow(pKnownTarget);
792 : : }
793 : : }
794 : :
795 : 13777 : return pPaintWindow;
796 : : }
797 : :
798 : 13777 : void SdrPaintView::EndDrawLayers(SdrPaintWindow& rPaintWindow, bool bPaintFormLayer)
799 : : {
800 : : // #i74769# use EndCompleteRedraw() as common base
801 : 13777 : EndCompleteRedraw(rPaintWindow, bPaintFormLayer);
802 : :
803 [ + - ]: 13777 : if(mpPageView)
804 : : {
805 : : // forget prepared SdrPageWindow
806 : 13777 : mpPageView->setPreparedPageWindow(0);
807 : : }
808 : 13777 : }
809 : :
810 : 33004 : void SdrPaintView::UpdateDrawLayersRegion(OutputDevice* pOut, const Region& rReg, bool bDisableIntersect)
811 : : {
812 : 33004 : SdrPaintWindow* pPaintWindow = FindPaintWindow(*pOut);
813 : : OSL_ENSURE(pPaintWindow, "SdrPaintView::UpdateDrawLayersRegion: No SdrPaintWindow (!)");
814 : :
815 [ + - ]: 33004 : if(mpPageView)
816 : : {
817 : 33004 : SdrPageWindow* pKnownTarget = mpPageView->FindPageWindow(*pPaintWindow);
818 : :
819 [ + - ]: 33004 : if(pKnownTarget)
820 : : {
821 [ + - ]: 33004 : Region aOptimizedRepaintRegion = OptimizeDrawLayersRegion( pOut, rReg, bDisableIntersect );
822 [ + - ]: 33004 : pKnownTarget->GetPaintWindow().SetRedrawRegion(aOptimizedRepaintRegion);
823 [ + - ][ + - ]: 33004 : mpPageView->setPreparedPageWindow(pKnownTarget); // already set actually
824 : : }
825 : : }
826 : 33004 : }
827 : :
828 : 46781 : Region SdrPaintView::OptimizeDrawLayersRegion(OutputDevice* pOut, const Region& rReg, bool bDisableIntersect)
829 : : {
830 : : // #i74769# check if pOut is a win and has a ClipRegion. If Yes, the Region
831 : : // rReg may be made more granular (fine) with using it. Normally, rReg
832 : : // does come from Window::Paint() anyways and thus is based on a single
833 : : // rectangle which was derived from exactly that repaint region
834 : 46781 : Region aOptimizedRepaintRegion(rReg);
835 : :
836 : : // #i76114# Intersecting the region with the Window's paint region is disabled
837 : : // for print preview in Calc, because the intersection can be empty (if the paint
838 : : // region is outside of the table area of the page), and then no clip region
839 : : // would be set.
840 [ + + ][ + + ]: 46781 : if(pOut && OUTDEV_WINDOW == pOut->GetOutDevType() && !bDisableIntersect)
[ + + ][ + - ]
841 : : {
842 : 46695 : Window* pWindow = (Window*)pOut;
843 : :
844 [ + - ][ + + ]: 46695 : if(pWindow->IsInPaint())
845 : : {
846 [ + - ][ + - ]: 21742 : if(!pWindow->GetPaintRegion().IsEmpty())
[ + - ][ + - ]
847 : : {
848 [ + - ][ + - ]: 21742 : aOptimizedRepaintRegion.Intersect(pWindow->GetPaintRegion());
[ + - ]
849 : :
850 : : #ifdef DBG_UTIL
851 : : // #i74769# test-paint repaint region
852 : : static bool bDoPaintForVisualControl(false);
853 : : if(bDoPaintForVisualControl)
854 : : {
855 : : RegionHandle aRegionHandle(aOptimizedRepaintRegion.BeginEnumRects());
856 : : Rectangle aRegionRectangle;
857 : :
858 : : while(aOptimizedRepaintRegion.GetEnumRects(aRegionHandle, aRegionRectangle))
859 : : {
860 : : pWindow->SetLineColor(COL_LIGHTGREEN);
861 : : pWindow->SetFillColor();
862 : : pWindow->DrawRect(aRegionRectangle);
863 : : }
864 : :
865 : : aOptimizedRepaintRegion.EndEnumRects(aRegionHandle);
866 : : }
867 : : #endif
868 : : }
869 : : }
870 : : }
871 : 46781 : return aOptimizedRepaintRegion;
872 : : }
873 : :
874 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
875 : :
876 : 0 : void SdrPaintView::ImpTextEditDrawing(SdrPaintWindow& rPaintWindow) const
877 : : {
878 : : // draw old text edit stuff
879 [ # # ]: 0 : if(IsTextEdit())
880 : : {
881 : 0 : SdrPageView* pPageView = GetTextEditPageView();
882 : :
883 [ # # ]: 0 : if(pPageView)
884 : : {
885 : : // paint TextEdit directly to the destination OutDev
886 [ # # ]: 0 : const Region& rRedrawRegion = rPaintWindow.GetRedrawRegion();
887 [ # # ]: 0 : const Rectangle aCheckRect(rRedrawRegion.GetBoundRect());
888 [ # # ]: 0 : pPageView->PaintOutlinerView(&rPaintWindow.GetOutputDevice(), aCheckRect);
889 : : }
890 : : }
891 : 0 : }
892 : :
893 : 16025 : void SdrPaintView::ImpFormLayerDrawing(SdrPaintWindow& rPaintWindow) const
894 : : {
895 [ + + ]: 16025 : if(mpPageView)
896 : : {
897 : 15999 : SdrPageWindow* pKnownTarget = mpPageView->FindPageWindow(rPaintWindow);
898 : :
899 [ + - ]: 15999 : if(pKnownTarget)
900 : : {
901 : 15999 : const SdrModel& rModel = *(GetModel());
902 : 15999 : const SdrLayerAdmin& rLayerAdmin = rModel.GetLayerAdmin();
903 : 15999 : const SdrLayerID nControlLayerId = rLayerAdmin.GetLayerID(rLayerAdmin.GetControlLayerName(), sal_False);
904 : :
905 : : // BUFFERED use GetTargetOutputDevice() now, it may be targeted to VDevs, too
906 : : // need to set PreparedPageWindow to make DrawLayer use the correct ObjectContact
907 : 15999 : mpPageView->setPreparedPageWindow(pKnownTarget);
908 : 15999 : mpPageView->DrawLayer(nControlLayerId, &rPaintWindow.GetTargetOutputDevice());
909 : 15999 : mpPageView->setPreparedPageWindow(0);
910 : : }
911 : : }
912 : 16025 : }
913 : :
914 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
915 : :
916 : 0 : sal_Bool SdrPaintView::KeyInput(const KeyEvent& /*rKEvt*/, Window* /*pWin*/)
917 : : {
918 : 0 : return sal_False;
919 : : }
920 : :
921 : 0 : void SdrPaintView::GlueInvalidate() const
922 : : {
923 : 0 : const sal_uInt32 nWindowCount(PaintWindowCount());
924 : :
925 [ # # ]: 0 : for(sal_uInt32 nWinNum(0L); nWinNum < nWindowCount; nWinNum++)
926 : : {
927 : 0 : SdrPaintWindow* pPaintWindow = GetPaintWindow(nWinNum);
928 : :
929 [ # # ]: 0 : if(pPaintWindow->OutputToWindow())
930 : : {
931 : 0 : OutputDevice& rOutDev = pPaintWindow->GetOutputDevice();
932 : :
933 [ # # ]: 0 : if(mpPageView)
934 : : {
935 : 0 : const SdrObjList* pOL=mpPageView->GetObjList();
936 : 0 : sal_uIntPtr nObjAnz=pOL->GetObjCount();
937 [ # # ]: 0 : for (sal_uIntPtr nObjNum=0; nObjNum<nObjAnz; nObjNum++) {
938 : 0 : const SdrObject* pObj=pOL->GetObj(nObjNum);
939 : 0 : const SdrGluePointList* pGPL=pObj->GetGluePointList();
940 [ # # ][ # # ]: 0 : if (pGPL!=NULL && pGPL->GetCount()!=0) {
[ # # ]
941 : 0 : pGPL->Invalidate((Window&)rOutDev, pObj);
942 : : }
943 : : }
944 : : }
945 : : }
946 : : }
947 : 0 : }
948 : :
949 : 14085 : void SdrPaintView::InvalidateAllWin()
950 : : {
951 : 14085 : const sal_uInt32 nWindowCount(PaintWindowCount());
952 : :
953 [ + + ]: 23697 : for(sal_uInt32 a(0L); a < nWindowCount; a++)
954 : : {
955 : 9612 : SdrPaintWindow* pPaintWindow = GetPaintWindow(a);
956 : :
957 [ + + ]: 9612 : if(pPaintWindow->OutputToWindow())
958 : : {
959 : 8340 : InvalidateOneWin((Window&)pPaintWindow->GetOutputDevice());
960 : : }
961 : : }
962 : 14085 : }
963 : :
964 : 11033 : void SdrPaintView::InvalidateAllWin(const Rectangle& rRect, sal_Bool bPlus1Pix)
965 : : {
966 : 11033 : const sal_uInt32 nWindowCount(PaintWindowCount());
967 : :
968 [ + + ]: 21757 : for(sal_uInt32 a(0L); a < nWindowCount; a++)
969 : : {
970 : 10724 : SdrPaintWindow* pPaintWindow = GetPaintWindow(a);
971 : :
972 [ + + ]: 10724 : if(pPaintWindow->OutputToWindow())
973 : : {
974 : 9876 : OutputDevice& rOutDev = pPaintWindow->GetOutputDevice();
975 : 9876 : Rectangle aRect(rRect);
976 : :
977 [ - + ]: 9876 : if(bPlus1Pix)
978 : : {
979 : 0 : Size aPixSiz(1,1);
980 [ # # ]: 0 : Size aSiz(rOutDev.PixelToLogic(aPixSiz));
981 : 0 : aRect.Left ()-=aSiz.Width();
982 : 0 : aRect.Top ()-=aSiz.Height();
983 : 0 : aRect.Right ()+=aSiz.Width();
984 : 0 : aRect.Bottom()+=aSiz.Height();
985 : : }
986 : :
987 : 9876 : Point aOrg(rOutDev.GetMapMode().GetOrigin());
988 : 9876 : aOrg.X()=-aOrg.X(); aOrg.Y()=-aOrg.Y();
989 [ + - ][ + - ]: 9876 : Rectangle aOutRect(aOrg, rOutDev.GetOutputSize());
990 : :
991 [ + - ][ + + ]: 9876 : if (aRect.IsOver(aOutRect))
992 : : {
993 [ + - ]: 9876 : InvalidateOneWin((Window&)rOutDev, aRect);
994 : : }
995 : : }
996 : : }
997 : 11033 : }
998 : :
999 : 8340 : void SdrPaintView::InvalidateOneWin(Window& rWin)
1000 : : {
1001 : : // do not erase background, that causes flicker (!)
1002 : 8340 : rWin.Invalidate(INVALIDATE_NOERASE);
1003 : 8340 : }
1004 : :
1005 : 3089 : void SdrPaintView::InvalidateOneWin(Window& rWin, const Rectangle& rRect)
1006 : : {
1007 : : // do not erase background, that causes flicker (!)
1008 : 3089 : rWin.Invalidate(rRect, INVALIDATE_NOERASE);
1009 : 3089 : }
1010 : :
1011 : 0 : void SdrPaintView::LeaveOneGroup()
1012 : : {
1013 [ # # ]: 0 : if(mpPageView)
1014 : : {
1015 : 0 : mpPageView->LeaveOneGroup();
1016 : : }
1017 : 0 : }
1018 : :
1019 : 0 : void SdrPaintView::LeaveAllGroup()
1020 : : {
1021 [ # # ]: 0 : if(mpPageView)
1022 : : {
1023 : 0 : mpPageView->LeaveAllGroup();
1024 : : }
1025 : 0 : }
1026 : :
1027 : 6385 : bool SdrPaintView::IsGroupEntered() const
1028 : : {
1029 [ + - ]: 6385 : if(mpPageView)
1030 : : {
1031 : 6385 : return (mpPageView->GetEnteredLevel() != 0);
1032 : : }
1033 : :
1034 : 6385 : return false;
1035 : : }
1036 : :
1037 : 0 : void SdrPaintView::SetNotPersistDefaultAttr(const SfxItemSet& rAttr, sal_Bool /*bReplaceAll*/)
1038 : : {
1039 : : // bReplaceAll has no effect here at all.
1040 [ # # ][ # # ]: 0 : sal_Bool bMeasure=ISA(SdrView) && ((SdrView*)this)->IsMeasureTool();
[ # # ][ # # ]
[ # # ]
1041 : 0 : const SfxPoolItem *pPoolItem=NULL;
1042 [ # # ][ # # ]: 0 : if (rAttr.GetItemState(SDRATTR_LAYERID,sal_True,&pPoolItem)==SFX_ITEM_SET) {
1043 : 0 : SdrLayerID nLayerId=((const SdrLayerIdItem*)pPoolItem)->GetValue();
1044 [ # # ]: 0 : const SdrLayer* pLayer=pMod->GetLayerAdmin().GetLayerPerID(nLayerId);
1045 [ # # ]: 0 : if (pLayer!=NULL) {
1046 [ # # ][ # # ]: 0 : if (bMeasure) aMeasureLayer=pLayer->GetName();
1047 [ # # ]: 0 : else aAktLayer=pLayer->GetName();
1048 : : }
1049 : : }
1050 [ # # ][ # # ]: 0 : if (rAttr.GetItemState(SDRATTR_LAYERNAME,sal_True,&pPoolItem)==SFX_ITEM_SET) {
1051 [ # # ][ # # ]: 0 : if (bMeasure) aMeasureLayer=((const SdrLayerNameItem*)pPoolItem)->GetValue();
1052 [ # # ]: 0 : else aAktLayer=((const SdrLayerNameItem*)pPoolItem)->GetValue();
1053 : : }
1054 : 0 : }
1055 : :
1056 : 1215 : void SdrPaintView::MergeNotPersistDefaultAttr(SfxItemSet& rAttr, sal_Bool /*bOnlyHardAttr*/) const
1057 : : {
1058 : : // bOnlyHardAttr has no effect here at all.
1059 [ + - ][ - + ]: 1215 : sal_Bool bMeasure=ISA(SdrView) && ((SdrView*)this)->IsMeasureTool();
1060 [ - + ]: 1215 : const XubString& aNam=bMeasure?aMeasureLayer:aAktLayer;
1061 [ + - ]: 1215 : rAttr.Put(SdrLayerNameItem(aNam));
1062 : 1215 : SdrLayerID nLayer=pMod->GetLayerAdmin().GetLayerID(aNam,sal_True);
1063 [ + - ]: 1215 : if (nLayer!=SDRLAYER_NOTFOUND) {
1064 [ + - ]: 1215 : rAttr.Put(SdrLayerIdItem(nLayer));
1065 : : }
1066 : 1215 : }
1067 : :
1068 : 0 : void SdrPaintView::SetDefaultAttr(const SfxItemSet& rAttr, sal_Bool bReplaceAll)
1069 : : {
1070 : : #ifdef DBG_UTIL
1071 : : {
1072 : : sal_Bool bHasEEFeatureItems=sal_False;
1073 : : SfxItemIter aIter(rAttr);
1074 : : const SfxPoolItem* pItem=aIter.FirstItem();
1075 : : while (!bHasEEFeatureItems && pItem!=NULL) {
1076 : : if (!IsInvalidItem(pItem)) {
1077 : : sal_uInt16 nW=pItem->Which();
1078 : : if (nW>=EE_FEATURE_START && nW<=EE_FEATURE_END) bHasEEFeatureItems=sal_True;
1079 : : }
1080 : : pItem=aIter.NextItem();
1081 : : }
1082 : :
1083 : : if(bHasEEFeatureItems)
1084 : : {
1085 : : String aMessage;
1086 : : aMessage.AppendAscii("SdrPaintView::SetDefaultAttr(): Setting EE_FEATURE items at the SdrView does not make sense! It only leads to overhead and unreadable documents.");
1087 : : InfoBox(NULL, aMessage).Execute();
1088 : : }
1089 : : }
1090 : : #endif
1091 [ # # ]: 0 : if (bReplaceAll) aDefaultAttr.Set(rAttr);
1092 : 0 : else aDefaultAttr.Put(rAttr,sal_False); // if FALSE, regard InvalidItems as "holes," not as Default
1093 : 0 : SetNotPersistDefaultAttr(rAttr,bReplaceAll);
1094 : : #ifdef DBG_UTIL
1095 : : if (pItemBrowser!=NULL) pItemBrowser->SetDirty();
1096 : : #endif
1097 : 0 : }
1098 : :
1099 : 4699 : void SdrPaintView::SetDefaultStyleSheet(SfxStyleSheet* pStyleSheet, sal_Bool bDontRemoveHardAttr)
1100 : : {
1101 [ - + ]: 4699 : if (pDefaultStyleSheet)
1102 : 0 : EndListening(*pDefaultStyleSheet);
1103 : 4699 : pDefaultStyleSheet=pStyleSheet;
1104 [ + + ]: 4699 : if (pDefaultStyleSheet)
1105 : 1272 : StartListening(*pDefaultStyleSheet);
1106 : :
1107 [ + + ][ - + ]: 4699 : if (pStyleSheet!=NULL && !bDontRemoveHardAttr) {
1108 [ # # ][ # # ]: 0 : SfxWhichIter aIter(pStyleSheet->GetItemSet());
1109 [ # # ]: 0 : sal_uInt16 nWhich=aIter.FirstWhich();
1110 [ # # ]: 0 : while (nWhich!=0) {
1111 [ # # ][ # # ]: 0 : if (pStyleSheet->GetItemSet().GetItemState(nWhich,sal_True)==SFX_ITEM_SET) {
[ # # ]
1112 [ # # ]: 0 : aDefaultAttr.ClearItem(nWhich);
1113 : : }
1114 [ # # ]: 0 : nWhich=aIter.NextWhich();
1115 [ # # ]: 0 : }
1116 : : }
1117 : : #ifdef DBG_UTIL
1118 : : if (pItemBrowser!=NULL) pItemBrowser->SetDirty();
1119 : : #endif
1120 : 4699 : }
1121 : :
1122 : 1215 : sal_Bool SdrPaintView::GetAttributes(SfxItemSet& rTargetSet, sal_Bool bOnlyHardAttr) const
1123 : : {
1124 [ + - ][ - + ]: 1215 : if(bOnlyHardAttr || !pDefaultStyleSheet)
1125 : : {
1126 : 0 : rTargetSet.Put(aDefaultAttr, sal_False);
1127 : : }
1128 : : else
1129 : : {
1130 : : // else merge with DefStyleSheet
1131 : 1215 : rTargetSet.Put(pDefaultStyleSheet->GetItemSet(), sal_False);
1132 : 1215 : rTargetSet.Put(aDefaultAttr, sal_False);
1133 : : }
1134 : 1215 : MergeNotPersistDefaultAttr(rTargetSet, bOnlyHardAttr);
1135 : 1215 : return sal_True;
1136 : : }
1137 : :
1138 : 0 : sal_Bool SdrPaintView::SetAttributes(const SfxItemSet& rSet, sal_Bool bReplaceAll)
1139 : : {
1140 : 0 : SetDefaultAttr(rSet,bReplaceAll);
1141 : 0 : return sal_True;
1142 : : }
1143 : :
1144 : 4 : SfxStyleSheet* SdrPaintView::GetStyleSheet() const
1145 : : {
1146 : 4 : return GetDefaultStyleSheet();
1147 : : }
1148 : :
1149 : 0 : sal_Bool SdrPaintView::SetStyleSheet(SfxStyleSheet* pStyleSheet, sal_Bool bDontRemoveHardAttr)
1150 : : {
1151 : 0 : SetDefaultStyleSheet(pStyleSheet,bDontRemoveHardAttr);
1152 : 0 : return sal_True;
1153 : : }
1154 : :
1155 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
1156 : :
1157 : : #ifdef DBG_UTIL
1158 : : void SdrPaintView::ShowItemBrowser(sal_Bool bShow)
1159 : : {
1160 : : if (bShow) {
1161 : : if (pItemBrowser==NULL) {
1162 : : pItemBrowser=new SdrItemBrowser(*(SdrView*)this);
1163 : : pItemBrowser->SetFloatingMode(sal_True);
1164 : : }
1165 : : pItemBrowser->Show();
1166 : : pItemBrowser->GrabFocus();
1167 : : } else {
1168 : : if (pItemBrowser!=NULL) {
1169 : : pItemBrowser->Hide();
1170 : : delete pItemBrowser;
1171 : : pItemBrowser=NULL;
1172 : : }
1173 : : }
1174 : : }
1175 : : #endif
1176 : :
1177 : 0 : void SdrPaintView::MakeVisible(const Rectangle& rRect, Window& rWin)
1178 : : {
1179 [ # # ]: 0 : MapMode aMap(rWin.GetMapMode());
1180 [ # # ]: 0 : Size aActualSize(rWin.GetOutputSize());
1181 : :
1182 [ # # ][ # # ]: 0 : if( aActualSize.Height() > 0 && aActualSize.Width() > 0 )
[ # # ]
1183 : : {
1184 [ # # ]: 0 : Size aNewSize(rRect.GetSize());
1185 : 0 : sal_Bool bNewScale=sal_False;
1186 : 0 : sal_Bool bNeedMoreX=aNewSize.Width()>aActualSize.Width();
1187 : 0 : sal_Bool bNeedMoreY=aNewSize.Height()>aActualSize.Height();
1188 [ # # ][ # # ]: 0 : if (bNeedMoreX || bNeedMoreY)
1189 : : {
1190 : 0 : bNewScale=sal_True;
1191 : : // set new MapMode (Size+Org) and invalidate everything
1192 [ # # ]: 0 : Fraction aXFact(aNewSize.Width(),aActualSize.Width());
1193 [ # # ]: 0 : Fraction aYFact(aNewSize.Height(),aActualSize.Height());
1194 [ # # ][ # # ]: 0 : if (aYFact>aXFact) aXFact=aYFact;
[ # # ]
1195 [ # # ]: 0 : aXFact*=aMap.GetScaleX();
1196 [ # # ]: 0 : aXFact.ReduceInaccurate(10); // to avoid runovers and BigInt mapping
1197 [ # # ]: 0 : aMap.SetScaleX(aXFact);
1198 [ # # ]: 0 : aMap.SetScaleY(aYFact);
1199 [ # # ]: 0 : rWin.SetMapMode(aMap);
1200 [ # # ]: 0 : aActualSize=rWin.GetOutputSize();
1201 : : }
1202 : 0 : Point aOrg(aMap.GetOrigin());
1203 : 0 : long dx=0,dy=0;
1204 : 0 : long l=-aOrg.X();
1205 : 0 : long r=-aOrg.X()+aActualSize.Width()-1;
1206 : 0 : long o=-aOrg.Y();
1207 : 0 : long u=-aOrg.Y()+aActualSize.Height()-1;
1208 [ # # ]: 0 : if (l>rRect.Left()) dx=rRect.Left()-l;
1209 [ # # ]: 0 : else if (r<rRect.Right()) dx=rRect.Right()-r;
1210 [ # # ]: 0 : if (o>rRect.Top()) dy=rRect.Top()-o;
1211 [ # # ]: 0 : else if (u<rRect.Bottom()) dy=rRect.Bottom()-u;
1212 [ # # ]: 0 : aMap.SetOrigin(Point(aOrg.X()-dx,aOrg.Y()-dy));
1213 [ # # ]: 0 : if (!bNewScale) {
1214 [ # # ][ # # ]: 0 : if (dx!=0 || dy!=0) {
1215 [ # # ]: 0 : rWin.Scroll(-dx,-dy);
1216 [ # # ]: 0 : rWin.SetMapMode(aMap);
1217 [ # # ]: 0 : rWin.Update();
1218 : : }
1219 : : } else {
1220 [ # # ]: 0 : rWin.SetMapMode(aMap);
1221 [ # # ]: 0 : InvalidateOneWin(rWin);
1222 : : }
1223 [ # # ]: 0 : }
1224 : 0 : }
1225 : :
1226 : 0 : void SdrPaintView::DoConnect(SdrOle2Obj* /*pOleObj*/)
1227 : : {
1228 : 0 : }
1229 : :
1230 : 35918 : void SdrPaintView::SetAnimationEnabled( sal_Bool bEnable )
1231 : : {
1232 [ + + ]: 35918 : SetAnimationMode( bEnable ? SDR_ANIMATION_ANIMATE : SDR_ANIMATION_DISABLE );
1233 : 35918 : }
1234 : :
1235 : 0 : void SdrPaintView::SetAnimationPause( bool bSet )
1236 : : {
1237 [ # # ]: 0 : if((bool)bAnimationPause != bSet)
1238 : : {
1239 : 0 : bAnimationPause = bSet;
1240 : :
1241 [ # # ]: 0 : if(mpPageView)
1242 : : {
1243 [ # # ]: 0 : for(sal_uInt32 b(0L); b < mpPageView->PageWindowCount(); b++)
1244 : : {
1245 : 0 : const SdrPageWindow& rPageWindow = *(mpPageView->GetPageWindow(b));
1246 : 0 : sdr::contact::ObjectContact& rObjectContact = rPageWindow.GetObjectContact();
1247 : 0 : sdr::animation::primitiveAnimator& rAnimator = rObjectContact.getPrimitiveAnimator();
1248 : :
1249 [ # # ]: 0 : if(rAnimator.IsPaused() != bSet)
1250 : : {
1251 : 0 : rAnimator.SetPaused(bSet);
1252 : : }
1253 : : }
1254 : : }
1255 : : }
1256 : 0 : }
1257 : :
1258 : 35918 : void SdrPaintView::SetAnimationMode( const SdrAnimationMode eMode )
1259 : : {
1260 : 35918 : eAnimationMode = eMode;
1261 : 35918 : }
1262 : :
1263 : 4785 : void SdrPaintView::VisAreaChanged(const OutputDevice* pOut)
1264 : : {
1265 [ + + ]: 4785 : if(mpPageView)
1266 : : {
1267 [ + + ]: 4504 : if (pOut)
1268 : : {
1269 : 3668 : SdrPageWindow* pWindow = mpPageView->FindPageWindow(*((OutputDevice*)pOut));
1270 : :
1271 [ + - ]: 3668 : if(pWindow)
1272 : : {
1273 : 3668 : VisAreaChanged(*pWindow);
1274 : : }
1275 : : }
1276 : : else
1277 : : {
1278 [ + + ]: 1672 : for(sal_uInt32 a(0L); a < mpPageView->PageWindowCount(); a++)
1279 : : {
1280 : 836 : VisAreaChanged(*mpPageView->GetPageWindow(a));
1281 : : }
1282 : : }
1283 : : }
1284 : 4785 : }
1285 : :
1286 : 4504 : void SdrPaintView::VisAreaChanged(const SdrPageWindow& /*rWindow*/)
1287 : : {
1288 : : // notify SfxListener
1289 [ + - ]: 4504 : Broadcast(SvxViewHint(SvxViewHint::SVX_HINT_VIEWCHANGED));
1290 : 4504 : }
1291 : :
1292 : 4843 : void SdrPaintView::onChangeColorConfig()
1293 : : {
1294 [ + - ]: 4843 : SetGridColor( Color( maColorConfig.GetColorValue( svtools::DRAWGRID ).nColor ) );
1295 : 4843 : }
1296 : :
1297 : 4843 : void SdrPaintView::SetGridColor( Color aColor )
1298 : : {
1299 : 4843 : maGridColor = aColor;
1300 : 4843 : }
1301 : :
1302 : 1120 : Color SdrPaintView::GetGridColor() const
1303 : : {
1304 : 1120 : return maGridColor;
1305 : : }
1306 : :
1307 : : // Set background color for svx at SdrPageViews
1308 : 2150 : void SdrPaintView::SetApplicationBackgroundColor(Color aBackgroundColor)
1309 : : {
1310 [ + + ]: 2150 : if(mpPageView)
1311 : : {
1312 : 2124 : mpPageView->SetApplicationBackgroundColor(aBackgroundColor);
1313 : : }
1314 : 2150 : }
1315 : :
1316 : : // Set document color for svx at SdrPageViews
1317 : 0 : void SdrPaintView::SetApplicationDocumentColor(Color aDocumentColor)
1318 : : {
1319 [ # # ]: 0 : if(mpPageView)
1320 : : {
1321 : 0 : mpPageView->SetApplicationDocumentColor(aDocumentColor);
1322 : : }
1323 : 0 : }
1324 : :
1325 : 16025 : bool SdrPaintView::IsBufferedOutputAllowed() const
1326 : : {
1327 [ + + ][ + - ]: 16025 : return (mbBufferedOutputAllowed && maDrawinglayerOpt.IsPaintBuffer());
1328 : : }
1329 : :
1330 : 1990 : void SdrPaintView::SetBufferedOutputAllowed(bool bNew)
1331 : : {
1332 [ + - ]: 1990 : if(bNew != (bool)mbBufferedOutputAllowed)
1333 : : {
1334 : 1990 : mbBufferedOutputAllowed = bNew;
1335 : : }
1336 : 1990 : }
1337 : :
1338 : 2615 : bool SdrPaintView::IsBufferedOverlayAllowed() const
1339 : : {
1340 [ + + ][ + - ]: 2615 : return (mbBufferedOverlayAllowed && maDrawinglayerOpt.IsOverlayBuffer());
1341 : : }
1342 : :
1343 : 1992 : void SdrPaintView::SetBufferedOverlayAllowed(bool bNew)
1344 : : {
1345 [ + - ]: 1992 : if(bNew != (bool)mbBufferedOverlayAllowed)
1346 : : {
1347 : 1992 : mbBufferedOverlayAllowed = bNew;
1348 : : }
1349 : 1992 : }
1350 : :
1351 : 2222 : sal_Bool SdrPaintView::IsPagePaintingAllowed() const
1352 : : {
1353 : 2222 : return mbPagePaintingAllowed;
1354 : : }
1355 : :
1356 : 34 : void SdrPaintView::SetPagePaintingAllowed(bool bNew)
1357 : : {
1358 [ - + ]: 34 : if(bNew != (bool)mbPagePaintingAllowed)
1359 : : {
1360 : 0 : mbPagePaintingAllowed = bNew;
1361 : : }
1362 : 34 : }
1363 : :
1364 : : // #i38135# Sets the timer for Object animations and restarts.
1365 : 0 : void SdrPaintView::SetAnimationTimer(sal_uInt32 nTime)
1366 : : {
1367 [ # # ]: 0 : if(mpPageView)
1368 : : {
1369 : : // first, reset all timers at all windows to 0L
1370 [ # # ]: 0 : for(sal_uInt32 a(0L); a < mpPageView->PageWindowCount(); a++)
1371 : : {
1372 : 0 : const SdrPageWindow& rPageWindow = *mpPageView->GetPageWindow(a);
1373 : 0 : sdr::contact::ObjectContact& rObjectContact = rPageWindow.GetObjectContact();
1374 : 0 : sdr::animation::primitiveAnimator& rAnimator = rObjectContact.getPrimitiveAnimator();
1375 : 0 : rAnimator.SetTime(nTime);
1376 : : }
1377 : : }
1378 : 0 : }
1379 : :
1380 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|