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 <svx/svdpagv.hxx>
30 : : #include <com/sun/star/awt/XWindow.hpp>
31 : : #include <com/sun/star/awt/PosSize.hpp>
32 : : #include <comphelper/processfactory.hxx>
33 : : #include <svx/svdoutl.hxx>
34 : : #include <svx/xpoly.hxx>
35 : : #include <svx/svdouno.hxx>
36 : : #include <svx/svdpage.hxx>
37 : : #include <svx/svdview.hxx>
38 : :
39 : : #include <svx/svdedxv.hxx>
40 : : #include <editeng/outliner.hxx>
41 : : #include <svx/svdetc.hxx>
42 : : #include <svx/svdobj.hxx>
43 : : #include "svx/svditer.hxx"
44 : : #include <svx/svdogrp.hxx>
45 : : #include <svx/svdtypes.hxx>
46 : :
47 : : #include <svx/svdotext.hxx> // for PaintOutlinerView
48 : : #include <svx/svdoole2.hxx>
49 : :
50 : : #include <svx/sdr/contact/objectcontactofpageview.hxx>
51 : : #include <svx/sdr/contact/viewobjectcontactredirector.hxx>
52 : : #include <svx/fmview.hxx>
53 : :
54 : : // for search on vector
55 : : #include <algorithm>
56 : :
57 : : using namespace ::rtl;
58 : : using namespace ::com::sun::star;
59 : : #include <svx/sdrpagewindow.hxx>
60 : : #include <svx/sdrpaintwindow.hxx>
61 : :
62 : : DBG_NAME(SdrPageView);
63 : :
64 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
65 : : // interface to SdrPageWindow
66 : :
67 : 71773 : SdrPageWindow* SdrPageView::FindPageWindow(SdrPaintWindow& rPaintWindow) const
68 : : {
69 [ + - ][ + + ]: 71773 : for(SdrPageWindowVector::const_iterator a = maPageWindows.begin(); a != maPageWindows.end(); ++a)
70 : : {
71 [ + - ]: 68569 : if(&((*a)->GetPaintWindow()) == &rPaintWindow)
72 : : {
73 : 68569 : return *a;
74 : : }
75 : : }
76 : :
77 : 71773 : return 0L;
78 : : }
79 : :
80 : 694 : const SdrPageWindow* SdrPageView::FindPatchedPageWindow( const OutputDevice& _rOutDev ) const
81 : : {
82 [ + - ][ + - ]: 1388 : for ( SdrPageWindowVector::const_iterator loop = maPageWindows.begin();
83 : 694 : loop != maPageWindows.end();
84 : : ++loop
85 : : )
86 : : {
87 : 694 : const SdrPageWindow& rPageWindow( *(*loop) );
88 [ + + ]: 694 : const SdrPaintWindow& rPaintWindow( rPageWindow.GetOriginalPaintWindow() ? *rPageWindow.GetOriginalPaintWindow() : rPageWindow.GetPaintWindow() );
89 [ + - ]: 694 : if ( &rPaintWindow.GetOutputDevice() == &_rOutDev )
90 : : {
91 : 694 : return &rPageWindow;
92 : : }
93 : : }
94 : :
95 : 694 : return NULL;
96 : : }
97 : :
98 : 50254 : SdrPageWindow* SdrPageView::FindPageWindow(const OutputDevice& rOutDev) const
99 : : {
100 [ + - ][ + + ]: 93073 : for(SdrPageWindowVector::const_iterator a = maPageWindows.begin(); a != maPageWindows.end(); ++a)
101 : : {
102 [ + + ]: 50254 : if(&((*a)->GetPaintWindow().GetOutputDevice()) == &rOutDev)
103 : : {
104 : 7435 : return *a;
105 : : }
106 : : }
107 : :
108 : 50254 : return 0L;
109 : : }
110 : :
111 : 23928 : SdrPageWindow* SdrPageView::GetPageWindow(sal_uInt32 nIndex) const
112 : : {
113 [ + - ]: 23928 : if(nIndex < maPageWindows.size())
114 : : {
115 : 23928 : return maPageWindows[nIndex];
116 : : }
117 : :
118 : 23928 : return 0L;
119 : : }
120 : :
121 : 6109 : void SdrPageView::ClearPageWindows()
122 : : {
123 [ + - ][ + - ]: 8859 : for(SdrPageWindowVector::const_iterator a = maPageWindows.begin(); a != maPageWindows.end(); ++a)
[ + + ]
124 : : {
125 [ + - ][ + - ]: 2750 : delete *a;
126 : : }
127 : :
128 : 6109 : maPageWindows.clear();
129 : 6109 : }
130 : :
131 : 3204 : void SdrPageView::AppendPageWindow(SdrPageWindow& rNew)
132 : : {
133 [ + - ]: 3204 : maPageWindows.push_back(&rNew);
134 : 3204 : }
135 : :
136 : 363 : SdrPageWindow* SdrPageView::RemovePageWindow(SdrPageWindow& rOld)
137 : : {
138 [ + - ]: 363 : const SdrPageWindowVector::iterator aFindResult = ::std::find(maPageWindows.begin(), maPageWindows.end(), &rOld);
139 : :
140 [ + - ][ + - ]: 363 : if(aFindResult != maPageWindows.end())
141 : : {
142 : : // remember return value
143 : 363 : SdrPageWindow* pSdrPageWindow = *aFindResult;
144 [ + - ]: 363 : maPageWindows.erase(aFindResult);
145 : 363 : return pSdrPageWindow;
146 : : }
147 : :
148 : 363 : return 0L;
149 : : }
150 : :
151 : : //////////////////////////////////////////////////////////////////////////////
152 : :
153 : 3246 : SdrPageView::SdrPageView(SdrPage* pPage1, SdrView& rNewView)
154 : : : mrView(rNewView),
155 : : // col_auto color lets the view takes the default SvxColorConfig entry
156 : : maDocumentColor( COL_AUTO ),
157 : : maBackgroundColor(COL_AUTO ), // #i48367# also react on autocolor
158 [ + - ]: 3246 : mpPreparedPageWindow(0) // #i72752#
159 : : {
160 : : DBG_CTOR(SdrPageView,NULL);
161 : 3246 : mpPage = pPage1;
162 : :
163 [ + - ]: 3246 : if(mpPage)
164 : : {
165 [ + - ]: 3246 : aPgOrg.X()=mpPage->GetLftBorder();
166 [ + - ]: 3246 : aPgOrg.Y()=mpPage->GetUppBorder();
167 : : }
168 : 3246 : mbHasMarked = sal_False;
169 : 3246 : aLayerVisi.SetAll();
170 : 3246 : aLayerPrn.SetAll();
171 : :
172 : 3246 : mbVisible = sal_False;
173 : 3246 : pAktList = NULL;
174 : 3246 : pAktGroup = NULL;
175 [ + - ]: 3246 : SetAktGroupAndList(NULL, mpPage);
176 : :
177 [ + + ]: 6450 : for(sal_uInt32 a(0L); a < rNewView.PaintWindowCount(); a++)
178 : : {
179 [ + - ][ + - ]: 3204 : AddPaintWindowToPageView(*rNewView.GetPaintWindow(a));
180 : : }
181 : 3246 : }
182 : :
183 : 3155 : SdrPageView::~SdrPageView()
184 : : {
185 : : DBG_DTOR(SdrPageView,NULL);
186 : :
187 : : // cleanup window vector
188 [ + - ]: 3155 : ClearPageWindows();
189 : 3155 : }
190 : :
191 : 3204 : SdrPageWindow& SdrPageView::CreateNewPageWindowEntry(SdrPaintWindow& rPaintWindow)
192 : : {
193 [ + - ]: 3204 : SdrPageWindow& rWindow = *(new SdrPageWindow(*this, rPaintWindow));
194 : 3204 : AppendPageWindow(rWindow);
195 : :
196 : 3204 : return rWindow;
197 : : }
198 : :
199 : 6408 : void SdrPageView::AddPaintWindowToPageView(SdrPaintWindow& rPaintWindow)
200 : : {
201 [ + + ]: 6408 : if(!FindPageWindow(rPaintWindow))
202 : : {
203 : 3204 : CreateNewPageWindowEntry(rPaintWindow);
204 : : }
205 : 6408 : }
206 : :
207 : 363 : void SdrPageView::RemovePaintWindowFromPageView(SdrPaintWindow& rPaintWindow)
208 : : {
209 : 363 : SdrPageWindow* pCandidate = FindPageWindow(rPaintWindow);
210 : :
211 [ + - ]: 363 : if(pCandidate)
212 : : {
213 : 363 : pCandidate = RemovePageWindow(*pCandidate);
214 : :
215 [ + - ]: 363 : if(pCandidate)
216 : : {
217 [ + - ]: 363 : delete pCandidate;
218 : : }
219 : : }
220 : 363 : }
221 : :
222 : 694 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer > SdrPageView::GetControlContainer( const OutputDevice& _rDevice ) const
223 : : {
224 : 694 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer > xReturn;
225 [ + - ]: 694 : const SdrPageWindow* pCandidate = FindPatchedPageWindow( _rDevice );
226 : :
227 [ + - ]: 694 : if ( pCandidate )
228 [ + - ][ + - ]: 694 : xReturn = pCandidate->GetControlContainer( true );
229 : :
230 : 694 : return xReturn;
231 : : }
232 : :
233 : 1276 : void SdrPageView::ModelHasChanged()
234 : : {
235 [ - + ]: 1276 : if (GetAktGroup()!=NULL) CheckAktGroup();
236 : 1276 : }
237 : :
238 : 2 : sal_Bool SdrPageView::IsReadOnly() const
239 : : {
240 [ + - ][ + - ]: 2 : return (0L == GetPage() || GetView().GetModel()->IsReadOnly() || GetPage()->IsReadOnly() || GetObjList()->IsReadOnly());
[ + - ][ - + ]
241 : : }
242 : :
243 : 3246 : void SdrPageView::Show()
244 : : {
245 [ + - ]: 3246 : if(!IsVisible())
246 : : {
247 : 3246 : mbVisible = sal_True;
248 : 3246 : InvalidateAllWin();
249 : :
250 [ + + ]: 6450 : for(sal_uInt32 a(0L); a < GetView().PaintWindowCount(); a++)
251 : : {
252 : 3204 : AddPaintWindowToPageView(*GetView().GetPaintWindow(a));
253 : : }
254 : : }
255 : 3246 : }
256 : :
257 : 2954 : void SdrPageView::Hide()
258 : : {
259 [ + - ]: 2954 : if(IsVisible())
260 : : {
261 : 2954 : InvalidateAllWin();
262 : 2954 : mbVisible = sal_False;
263 : 2954 : ClearPageWindows();
264 : : }
265 : 2954 : }
266 : :
267 : 0 : Rectangle SdrPageView::GetPageRect() const
268 : : {
269 [ # # ]: 0 : if (GetPage()==NULL) return Rectangle();
270 [ # # ]: 0 : return Rectangle(Point(),Size(GetPage()->GetWdt()+1,GetPage()->GetHgt()+1));
271 : : }
272 : :
273 : 11033 : void SdrPageView::InvalidateAllWin()
274 : : {
275 [ + - ][ + - ]: 11033 : if(IsVisible() && GetPage())
[ + - ]
276 : : {
277 [ + - ][ + - ]: 11033 : Rectangle aRect(Point(0,0),Size(GetPage()->GetWdt()+1,GetPage()->GetHgt()+1));
[ + - ]
278 [ + - ][ + - ]: 11033 : aRect.Union(GetPage()->GetAllObjBoundRect());
279 [ + - ]: 11033 : GetView().InvalidateAllWin(aRect);
280 : : }
281 : 11033 : }
282 : :
283 : 0 : void SdrPageView::PaintOutlinerView(OutputDevice* pOut, const Rectangle& rRect) const
284 : : {
285 [ # # ]: 0 : if (GetView().pTextEditOutliner==NULL) return;
286 : 0 : sal_uIntPtr nViewAnz=GetView().pTextEditOutliner->GetViewCount();
287 [ # # ]: 0 : for (sal_uIntPtr i=0; i<nViewAnz; i++) {
288 : 0 : OutlinerView* pOLV=GetView().pTextEditOutliner->GetView(i);
289 [ # # ]: 0 : if (pOLV->GetWindow()==pOut) {
290 : 0 : GetView().ImpPaintOutlinerView(*pOLV, rRect);
291 : 0 : return;
292 : : }
293 : : }
294 : : }
295 : :
296 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
297 : :
298 : 15547 : void SdrPageView::PrePaint()
299 : : {
300 : 15547 : const sal_uInt32 nCount(PageWindowCount());
301 : :
302 [ + + ]: 31094 : for(sal_uInt32 a(0); a < nCount; a++)
303 : : {
304 : 15547 : SdrPageWindow* pCandidate = GetPageWindow(a);
305 : :
306 [ + - ]: 15547 : if(pCandidate)
307 : : {
308 : 15547 : pCandidate->PrePaint();
309 : : }
310 : : }
311 : 15547 : }
312 : :
313 : 2222 : void SdrPageView::CompleteRedraw(SdrPaintWindow& rPaintWindow, const Region& rReg, sdr::contact::ViewObjectContactRedirector* pRedirector) const
314 : : {
315 [ + - ]: 2222 : if(GetPage())
316 : : {
317 : 2222 : SdrPageWindow* pPageWindow = FindPageWindow(rPaintWindow);
318 : 2222 : sal_Bool bIsTempTarget(sal_False);
319 : :
320 [ - + ]: 2222 : if(!pPageWindow)
321 : : {
322 : : // create temp PageWindow
323 [ # # ]: 0 : pPageWindow = new SdrPageWindow(*((SdrPageView*)this), rPaintWindow);
324 : 0 : bIsTempTarget = sal_True;
325 : : }
326 : :
327 : : // do the redraw
328 : 2222 : pPageWindow->PrepareRedraw(rReg);
329 : 2222 : pPageWindow->RedrawAll(pRedirector);
330 : :
331 : : // get rid of temp PageWindow
332 [ - + ]: 2222 : if(bIsTempTarget)
333 : : {
334 [ # # ]: 0 : delete pPageWindow;
335 : 0 : pPageWindow = 0L;
336 : : }
337 : : }
338 : 2222 : }
339 : :
340 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
341 : : // #i74769# use SdrPaintWindow directly
342 : :
343 : 92556 : void SdrPageView::setPreparedPageWindow(SdrPageWindow* pKnownTarget)
344 : : {
345 : : // #i72752# remember prepared SdrPageWindow
346 : 92556 : mpPreparedPageWindow = pKnownTarget;
347 : 92556 : }
348 : :
349 : 43512 : void SdrPageView::DrawLayer(SdrLayerID nID, OutputDevice* pGivenTarget, sdr::contact::ViewObjectContactRedirector* pRedirector) const
350 : : {
351 [ + - ]: 43512 : if(GetPage())
352 : : {
353 [ + - ]: 43512 : if(pGivenTarget)
354 : : {
355 : 43512 : const SdrPageWindow* pKnownTarget = FindPageWindow(*pGivenTarget);
356 : :
357 [ + + ]: 43512 : if(pKnownTarget)
358 : : {
359 : : // paint known target
360 : 693 : pKnownTarget->RedrawLayer(&nID, pRedirector);
361 : : }
362 : : else
363 : : {
364 : : // #i72752# DrawLayer() uses a OutputDevice different from BeginDrawLayer. This happens
365 : : // e.g. when SW paints a single text line in text edit mode. Try to use it
366 : 42819 : SdrPageWindow* pPreparedTarget = mpPreparedPageWindow;
367 : :
368 [ + - ]: 42819 : if(pPreparedTarget)
369 : : {
370 : : // if we have a prepared target, do not use a new SdrPageWindow since this
371 : : // works but is expensive. Just use a temporary PaintWindow
372 [ + - ]: 42819 : SdrPaintWindow aTemporaryPaintWindow(mrView, *pGivenTarget);
373 : :
374 : : // Copy existing paint region to use the same as prepared in BeginDrawLayer
375 : 42819 : SdrPaintWindow& rExistingPaintWindow = pPreparedTarget->GetPaintWindow();
376 [ + - ]: 42819 : const Region& rExistingRegion = rExistingPaintWindow.GetRedrawRegion();
377 [ + - ]: 42819 : aTemporaryPaintWindow.SetRedrawRegion(rExistingRegion);
378 : :
379 : : // patch the ExistingPageWindow
380 [ + - ]: 42819 : pPreparedTarget->patchPaintWindow(aTemporaryPaintWindow);
381 : :
382 : : // redraw the layer
383 [ + - ]: 42819 : pPreparedTarget->RedrawLayer(&nID, pRedirector);
384 : :
385 : : // restore the ExistingPageWindow
386 [ + - ][ + - ]: 42819 : pPreparedTarget->unpatchPaintWindow();
387 : : }
388 : : else
389 : : {
390 : : OSL_FAIL("SdrPageView::DrawLayer: Creating temporary SdrPageWindow (ObjectContact), this should never be needed (!)");
391 : :
392 : : // None of the known OutputDevices is the target of this paint, use
393 : : // a temporary SdrPageWindow for this Redraw.
394 [ # # ]: 0 : SdrPaintWindow aTemporaryPaintWindow(mrView, *pGivenTarget);
395 [ # # ]: 0 : SdrPageWindow aTemporaryPageWindow(*((SdrPageView*)this), aTemporaryPaintWindow);
396 : :
397 : : // #i72752#
398 : : // Copy existing paint region if other PageWindows exist, this was created by
399 : : // PrepareRedraw() from BeginDrawLayer(). Needs to be used e.g. when suddenly SW
400 : : // paints into an unknown device other than the view was created for (e.g. VirtualDevice)
401 [ # # ]: 0 : if(PageWindowCount())
402 : : {
403 [ # # ]: 0 : SdrPageWindow* pExistingPageWindow = GetPageWindow(0L);
404 : 0 : SdrPaintWindow& rExistingPaintWindow = pExistingPageWindow->GetPaintWindow();
405 [ # # ]: 0 : const Region& rExistingRegion = rExistingPaintWindow.GetRedrawRegion();
406 [ # # ]: 0 : aTemporaryPaintWindow.SetRedrawRegion(rExistingRegion);
407 : : }
408 : :
409 [ # # ][ # # ]: 0 : aTemporaryPageWindow.RedrawLayer(&nID, pRedirector);
[ # # ]
410 : : }
411 : : }
412 : : }
413 : : else
414 : : {
415 : : // paint in all known windows
416 [ # # ]: 0 : for(sal_uInt32 a(0L); a < PageWindowCount(); a++)
417 : : {
418 : 0 : SdrPageWindow* pTarget = GetPageWindow(a);
419 : 0 : pTarget->RedrawLayer(&nID, pRedirector);
420 : : }
421 : : }
422 : : }
423 : 43512 : }
424 : :
425 : 4 : void SdrPageView::SetDesignMode( bool _bDesignMode ) const
426 : : {
427 [ + + ]: 8 : for ( sal_uInt32 i = 0L; i < PageWindowCount(); ++i )
428 : : {
429 : 4 : const SdrPageWindow& rPageViewWindow = *GetPageWindow(i);
430 : 4 : rPageViewWindow.SetDesignMode( _bDesignMode );
431 : : }
432 : 4 : }
433 : :
434 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
435 : :
436 : 25 : void SdrPageView::DrawPageViewGrid(OutputDevice& rOut, const Rectangle& rRect, Color aColor)
437 : : {
438 [ - + ]: 25 : if (GetPage()==NULL)
439 : 25 : return;
440 : :
441 : 25 : long nx1=GetView().aGridBig.Width();
442 : 25 : long nx2=GetView().aGridFin.Width();
443 : 25 : long ny1=GetView().aGridBig.Height();
444 : 25 : long ny2=GetView().aGridFin.Height();
445 : :
446 [ - + ]: 25 : if (nx1==0) nx1=nx2;
447 [ - + ]: 25 : if (nx2==0) nx2=nx1;
448 [ - + ]: 25 : if (ny1==0) ny1=ny2;
449 [ - + ]: 25 : if (ny2==0) ny2=ny1;
450 [ - + ]: 25 : if (nx1==0) { nx1=ny1; nx2=ny2; }
451 [ - + ]: 25 : if (ny1==0) { ny1=nx1; ny2=nx2; }
452 [ - + ]: 25 : if (nx1<0) nx1=-nx1;
453 [ - + ]: 25 : if (nx2<0) nx2=-nx2;
454 [ - + ]: 25 : if (ny1<0) ny1=-ny1;
455 [ - + ]: 25 : if (ny2<0) ny2=-ny2;
456 : :
457 [ + - ]: 25 : if (nx1!=0)
458 : : {
459 : : // no more global output size, use window size instead to decide grid sizes
460 : 25 : long nScreenWdt = rOut.GetOutputSizePixel().Width();
461 : :
462 : 25 : long nMinDotPix=2;
463 : 25 : long nMinLinPix=4;
464 : :
465 [ - + ]: 25 : if (nScreenWdt>=1600)
466 : : {
467 : 0 : nMinDotPix=4;
468 : 0 : nMinLinPix=8;
469 : : }
470 [ - + ]: 25 : else if (nScreenWdt>=1024)
471 : : {
472 : 0 : nMinDotPix=3;
473 : 0 : nMinLinPix=6;
474 : : }
475 : : else
476 : : { // e. g. 640x480
477 : 25 : nMinDotPix=2;
478 : 25 : nMinLinPix=4;
479 : : }
480 [ + - ]: 25 : Size aMinDotDist(rOut.PixelToLogic(Size(nMinDotPix,nMinDotPix)));
481 [ + - ]: 25 : Size aMinLinDist(rOut.PixelToLogic(Size(nMinLinPix,nMinLinPix)));
482 : 25 : bool bHoriSolid=nx2<aMinDotDist.Width();
483 : 25 : bool bVertSolid=ny2<aMinDotDist.Height();
484 : : // enlarge line offset (minimum 4 pixels)
485 : : // enlarge by: *2 *5 *10 *20 *50 *100 ...
486 : 25 : int nTgl=0;
487 : 25 : long nVal0=nx1;
488 [ - + ]: 25 : while (nx1<aMinLinDist.Width())
489 : : {
490 : 0 : long a=nx1;
491 : :
492 [ # # ]: 0 : if (nTgl==0) nx1*=2;
493 [ # # ]: 0 : if (nTgl==1) nx1=nVal0*5; // => nx1*=2.5
494 [ # # ]: 0 : if (nTgl==2) nx1*=2;
495 : :
496 : 0 : nVal0=a;
497 [ # # ]: 0 : nTgl++; if (nTgl>=3) nTgl=0;
498 : : }
499 : 25 : nTgl=0;
500 : 25 : nVal0=ny1;
501 [ - + ]: 25 : while (ny1<aMinLinDist.Height())
502 : : {
503 : 0 : long a=ny1;
504 : :
505 [ # # ]: 0 : if (nTgl==0) ny1*=2;
506 [ # # ]: 0 : if (nTgl==1) ny1=nVal0*5; // => ny1*=2.5
507 [ # # ]: 0 : if (nTgl==2) ny1*=2;
508 : :
509 : 0 : nVal0=a;
510 : 0 : nTgl++;
511 : :
512 [ # # ]: 0 : if (nTgl>=3) nTgl=0;
513 : : }
514 : :
515 : 25 : bool bHoriFine=nx2<nx1;
516 : 25 : bool bVertFine=ny2<ny1;
517 [ + - ][ - + ]: 25 : bool bHoriLines=bHoriSolid || bHoriFine || !bVertFine;
[ # # ]
518 [ + - ][ + - ]: 25 : bool bVertLines=bVertSolid || bVertFine;
519 : :
520 : 25 : Color aColorMerk( rOut.GetLineColor() );
521 [ + - ]: 25 : rOut.SetLineColor( aColor );
522 : :
523 : 25 : bool bMap0=rOut.IsMapModeEnabled();
524 : :
525 : 25 : long nWrX=0;
526 : 25 : long nWrY=0;
527 : 25 : Point aOrg(aPgOrg);
528 [ + - ]: 25 : long x1=GetPage()->GetLftBorder()+1+nWrX;
529 [ + - ][ + - ]: 25 : long x2=GetPage()->GetWdt()-GetPage()->GetRgtBorder()-1+nWrY;
530 [ + - ]: 25 : long y1=GetPage()->GetUppBorder()+1+nWrX;
531 [ + - ][ + - ]: 25 : long y2=GetPage()->GetHgt()-GetPage()->GetLwrBorder()-1+nWrY;
532 [ + - ]: 25 : const SdrPageGridFrameList* pFrames=GetPage()->GetGridFrameList(this,NULL);
533 : :
534 : 25 : sal_uInt16 nGridPaintAnz=1;
535 [ + - ]: 25 : if (pFrames!=NULL) nGridPaintAnz=pFrames->GetCount();
536 [ + + ]: 50 : for (sal_uInt16 nGridPaintNum=0; nGridPaintNum<nGridPaintAnz; nGridPaintNum++) {
537 [ + - ]: 25 : if (pFrames!=NULL) {
538 [ + - ]: 25 : const SdrPageGridFrame& rGF=(*pFrames)[nGridPaintNum];
539 : 25 : nWrX=rGF.GetPaperRect().Left();
540 : 25 : nWrY=rGF.GetPaperRect().Top();
541 : 25 : x1=rGF.GetUserArea().Left();
542 : 25 : x2=rGF.GetUserArea().Right();
543 : 25 : y1=rGF.GetUserArea().Top();
544 : 25 : y2=rGF.GetUserArea().Bottom();
545 : 25 : aOrg=rGF.GetUserArea().TopLeft();
546 : 25 : aOrg-=rGF.GetPaperRect().TopLeft();
547 : : }
548 [ + - ][ + - ]: 25 : if (!rRect.IsEmpty()) {
549 [ + - ]: 25 : Size a1PixSiz(rOut.PixelToLogic(Size(1,1)));
550 : 25 : long nX1Pix=a1PixSiz.Width(); // add 1 pixel of tolerance
551 : 25 : long nY1Pix=a1PixSiz.Height();
552 [ - + ]: 25 : if (x1<rRect.Left() -nX1Pix) x1=rRect.Left() -nX1Pix;
553 [ - + ]: 25 : if (x2>rRect.Right() +nX1Pix) x2=rRect.Right() +nX1Pix;
554 [ - + ]: 25 : if (y1<rRect.Top() -nY1Pix) y1=rRect.Top() -nY1Pix;
555 [ - + ]: 25 : if (y2>rRect.Bottom()+nY1Pix) y2=rRect.Bottom()+nY1Pix;
556 : : }
557 : 25 : Point aPnt;
558 : :
559 : 25 : long xBigOrg=aOrg.X()+nWrX;
560 [ + + ]: 50 : while (xBigOrg>=x1) xBigOrg-=nx1;
561 [ + + ]: 50 : while (xBigOrg<x1) xBigOrg+=nx1;
562 : 25 : long xFinOrg=xBigOrg;
563 [ + + ]: 50 : while (xFinOrg>=x1) xFinOrg-=nx2;
564 [ + + ]: 50 : while (xFinOrg<x1) xFinOrg+=nx2;
565 : :
566 : 25 : long yBigOrg=aOrg.Y()+nWrY;
567 [ + + ]: 50 : while (yBigOrg>=y1) yBigOrg-=ny1;
568 [ + + ]: 50 : while (yBigOrg<y1) yBigOrg+=ny1;
569 : 25 : long yFinOrg=yBigOrg;
570 [ + + ]: 50 : while (yFinOrg>=y1) yFinOrg-=ny2;
571 [ + + ]: 50 : while (yFinOrg<y1) yFinOrg+=ny2;
572 : :
573 [ + - ][ + - ]: 25 : if( x1 <= x2 && y1 <= y2 )
574 : : {
575 [ + - ]: 25 : if( bHoriLines )
576 : : {
577 [ - + ]: 25 : sal_uIntPtr nGridFlags = ( bHoriSolid ? GRID_HORZLINES : GRID_DOTS );
578 : 25 : sal_uInt16 nSteps = sal_uInt16(nx1 / nx2);
579 [ + - ]: 25 : sal_uInt32 nRestPerStepMul1000 = nSteps ? ( ((nx1 * 1000L)/ nSteps) - (nx2 * 1000L) ) : 0;
580 : 25 : sal_uInt32 nStepOffset = 0;
581 : 25 : sal_uInt16 nPointOffset = 0;
582 : :
583 [ + + ]: 245 : for(sal_uInt16 a=0;a<nSteps;a++)
584 : : {
585 : : // draw
586 : : rOut.DrawGrid(
587 : : Rectangle( xFinOrg + (a * nx2) + nPointOffset, yBigOrg, x2, y2 ),
588 [ + - ][ + - ]: 220 : Size( nx1, ny1 ), nGridFlags );
589 : :
590 : : // do a step
591 : 220 : nStepOffset += nRestPerStepMul1000;
592 [ + + ]: 333 : while(nStepOffset >= 1000)
593 : : {
594 : 113 : nStepOffset -= 1000;
595 : 113 : nPointOffset++;
596 : : }
597 : : }
598 : : }
599 : :
600 [ + - ]: 25 : if( bVertLines )
601 : : {
602 [ - + ]: 25 : sal_uIntPtr nGridFlags = ( bVertSolid ? GRID_VERTLINES : GRID_DOTS );
603 : 25 : sal_uInt16 nSteps = sal_uInt16(ny1 / ny2);
604 [ + - ]: 25 : sal_uInt32 nRestPerStepMul1000 = nSteps ? ( ((ny1 * 1000L)/ nSteps) - (ny2 * 1000L) ) : 0;
605 : 25 : sal_uInt32 nStepOffset = 0;
606 : 25 : sal_uInt16 nPointOffset = 0;
607 : :
608 [ + + ]: 195 : for(sal_uInt16 a=0;a<nSteps;a++)
609 : : {
610 : : // draw
611 : : rOut.DrawGrid(
612 : : Rectangle( xBigOrg, yFinOrg + (a * ny2) + nPointOffset, x2, y2 ),
613 [ + - ][ + - ]: 170 : Size( nx1, ny1 ), nGridFlags );
614 : :
615 : : // do a step
616 : 170 : nStepOffset += nRestPerStepMul1000;
617 [ + + ]: 219 : while(nStepOffset >= 1000)
618 : : {
619 : 49 : nStepOffset -= 1000;
620 : 49 : nPointOffset++;
621 : : }
622 : : }
623 : : }
624 : : }
625 : : }
626 : :
627 [ + - ]: 25 : rOut.EnableMapMode(bMap0);
628 [ + - ]: 25 : rOut.SetLineColor(aColorMerk);
629 : : }
630 : : }
631 : :
632 : 5619 : void SdrPageView::AdjHdl()
633 : : {
634 : 5619 : GetView().AdjustMarkHdl();
635 : 5619 : }
636 : :
637 : 7246 : void SdrPageView::SetLayer(const XubString& rName, SetOfByte& rBS, sal_Bool bJa)
638 : : {
639 [ - + ]: 7246 : if(!GetPage())
640 : 7246 : return;
641 : :
642 : 7246 : SdrLayerID nID = GetPage()->GetLayerAdmin().GetLayerID(rName, sal_True);
643 : :
644 [ + - ]: 7246 : if(SDRLAYER_NOTFOUND != nID)
645 : 7246 : rBS.Set(nID, bJa);
646 : : }
647 : :
648 : 13480 : sal_Bool SdrPageView::IsLayer(const XubString& rName, const SetOfByte& rBS) const
649 : : {
650 [ - + ]: 13480 : if(!GetPage())
651 : 0 : return sal_False;
652 : :
653 : 13480 : sal_Bool bRet(sal_False);
654 : :
655 [ + - ]: 13480 : if(rName.Len())
656 : : {
657 : 13480 : SdrLayerID nId = GetPage()->GetLayerAdmin().GetLayerID(rName, sal_True);
658 : :
659 [ + - ]: 13480 : if(SDRLAYER_NOTFOUND != nId)
660 : : {
661 : 13480 : bRet = rBS.IsSet(nId);
662 : : }
663 : : }
664 : :
665 : 13480 : return bRet;
666 : : }
667 : :
668 : 1037 : sal_Bool SdrPageView::IsObjMarkable(SdrObject* pObj) const
669 : : {
670 [ + - ]: 1037 : if(pObj)
671 : : {
672 : : // excluded from selection?
673 [ - + ]: 1037 : if(pObj->IsMarkProtect())
674 : : {
675 : 0 : return sal_False;
676 : : }
677 : :
678 : : // only visible are selectable
679 [ - + ]: 1037 : if( !pObj->IsVisible() )
680 : : {
681 : 0 : return sal_False;
682 : : }
683 : :
684 [ + + ]: 1037 : if(pObj->ISA(SdrObjGroup))
685 : : {
686 : : // If object is a Group object, visibility may depend on
687 : : // multiple layers. If one object is markable, Group is markable.
688 : 9 : SdrObjList* pObjList = ((SdrObjGroup*)pObj)->GetSubList();
689 : :
690 [ + - ][ + - ]: 9 : if(pObjList && pObjList->GetObjCount())
[ + - ]
691 : : {
692 : 9 : sal_Bool bGroupIsMarkable(sal_False);
693 : :
694 [ + + ][ + - ]: 18 : for(sal_uInt32 a(0L); !bGroupIsMarkable && a < pObjList->GetObjCount(); a++)
[ + + ]
695 : : {
696 : 9 : SdrObject* pCandidate = pObjList->GetObj(a);
697 : :
698 : : // call recursively
699 [ + - ]: 9 : if(IsObjMarkable(pCandidate))
700 : : {
701 : 9 : bGroupIsMarkable = sal_True;
702 : : }
703 : : }
704 : :
705 : 9 : return bGroupIsMarkable;
706 : : }
707 : : else
708 : : {
709 : : // #i43302#
710 : : // Allow empty groups to be selected to be able to delete them
711 : 0 : return sal_True;
712 : : }
713 : : }
714 : : else
715 : : {
716 : : // the layer has to be visible and must not be locked
717 : 1028 : SdrLayerID nL = pObj->GetLayer();
718 [ + - ][ + + ]: 1028 : return (aLayerVisi.IsSet(sal_uInt8(nL)) && !aLayerLock.IsSet(sal_uInt8(nL)));
719 : : }
720 : : }
721 : :
722 : 1037 : return sal_False;
723 : : }
724 : :
725 : 0 : void SdrPageView::SetPageOrigin(const Point& rOrg)
726 : : {
727 [ # # ]: 0 : if (rOrg!=aPgOrg) {
728 : 0 : aPgOrg=rOrg;
729 [ # # ]: 0 : if (GetView().IsGridVisible()) {
730 : 0 : InvalidateAllWin();
731 : : }
732 : : }
733 : 0 : }
734 : :
735 : 0 : void SdrPageView::ImpInvalidateHelpLineArea(sal_uInt16 nNum) const
736 : : {
737 [ # # ][ # # ]: 0 : if (GetView().IsHlplVisible() && nNum<aHelpLines.GetCount()) {
[ # # ]
738 : 0 : const SdrHelpLine& rHL=aHelpLines[nNum];
739 : :
740 [ # # ]: 0 : for(sal_uInt32 a(0L); a < GetView().PaintWindowCount(); a++)
741 : : {
742 : 0 : SdrPaintWindow* pCandidate = GetView().GetPaintWindow(a);
743 : :
744 [ # # ]: 0 : if(pCandidate->OutputToWindow())
745 : : {
746 : 0 : OutputDevice& rOutDev = pCandidate->GetOutputDevice();
747 [ # # ]: 0 : Rectangle aR(rHL.GetBoundRect(rOutDev));
748 [ # # ]: 0 : Size aSiz(rOutDev.PixelToLogic(Size(1,1)));
749 : 0 : aR.Left() -= aSiz.Width();
750 : 0 : aR.Right() += aSiz.Width();
751 : 0 : aR.Top() -= aSiz.Height();
752 : 0 : aR.Bottom() += aSiz.Height();
753 [ # # ]: 0 : ((SdrView&)GetView()).InvalidateOneWin((Window&)rOutDev, aR);
754 : : }
755 : : }
756 : : }
757 : 0 : }
758 : :
759 : 143 : void SdrPageView::SetHelpLines(const SdrHelpLineList& rHLL)
760 : : {
761 : 143 : aHelpLines=rHLL;
762 : 143 : InvalidateAllWin();
763 : 143 : }
764 : :
765 : 0 : void SdrPageView::SetHelpLine(sal_uInt16 nNum, const SdrHelpLine& rNewHelpLine)
766 : : {
767 [ # # ][ # # ]: 0 : if (nNum<aHelpLines.GetCount() && aHelpLines[nNum]!=rNewHelpLine) {
[ # # ]
768 : 0 : bool bNeedRedraw = true;
769 [ # # ]: 0 : if (aHelpLines[nNum].GetKind()==rNewHelpLine.GetKind()) {
770 [ # # # ]: 0 : switch (rNewHelpLine.GetKind()) {
771 [ # # ]: 0 : case SDRHELPLINE_VERTICAL : if (aHelpLines[nNum].GetPos().X()==rNewHelpLine.GetPos().X()) bNeedRedraw = false; break;
772 [ # # ]: 0 : case SDRHELPLINE_HORIZONTAL: if (aHelpLines[nNum].GetPos().Y()==rNewHelpLine.GetPos().Y()) bNeedRedraw = false; break;
773 : 0 : default: break;
774 : : } // switch
775 : : }
776 [ # # ]: 0 : if (bNeedRedraw) ImpInvalidateHelpLineArea(nNum);
777 : 0 : aHelpLines[nNum]=rNewHelpLine;
778 [ # # ]: 0 : if (bNeedRedraw) ImpInvalidateHelpLineArea(nNum);
779 : : }
780 : 0 : }
781 : :
782 : 0 : void SdrPageView::DeleteHelpLine(sal_uInt16 nNum)
783 : : {
784 [ # # ]: 0 : if (nNum<aHelpLines.GetCount()) {
785 : 0 : ImpInvalidateHelpLineArea(nNum);
786 : 0 : aHelpLines.Delete(nNum);
787 : : }
788 : 0 : }
789 : :
790 : 0 : void SdrPageView::InsertHelpLine(const SdrHelpLine& rHL, sal_uInt16 nNum)
791 : : {
792 [ # # ]: 0 : if (nNum > aHelpLines.GetCount())
793 : 0 : nNum = aHelpLines.GetCount();
794 : 0 : aHelpLines.Insert(rHL,nNum);
795 [ # # ]: 0 : if (GetView().IsHlplVisible())
796 : 0 : ImpInvalidateHelpLineArea(nNum);
797 : 0 : }
798 : :
799 : : // set current group and list
800 : 3246 : void SdrPageView::SetAktGroupAndList(SdrObject* pNewGroup, SdrObjList* pNewList)
801 : : {
802 [ - + ]: 3246 : if(pAktGroup != pNewGroup)
803 : : {
804 : 0 : pAktGroup = pNewGroup;
805 : : }
806 [ + - ]: 3246 : if(pAktList != pNewList)
807 : : {
808 : 3246 : pAktList = pNewList;
809 : : }
810 : 3246 : }
811 : :
812 : 0 : sal_Bool SdrPageView::EnterGroup(SdrObject* pObj)
813 : : {
814 : 0 : sal_Bool bRet(sal_False);
815 : :
816 [ # # ][ # # ]: 0 : if(pObj && pObj->IsGroupObject())
[ # # ]
817 : : {
818 : 0 : sal_Bool bGlueInvalidate(GetView().ImpIsGlueVisible());
819 : :
820 [ # # ]: 0 : if(bGlueInvalidate)
821 : : {
822 : 0 : GetView().GlueInvalidate();
823 : : }
824 : :
825 : : // deselect all
826 : 0 : GetView().UnmarkAll();
827 : :
828 : : // set current group and list
829 : 0 : SdrObjList* pNewObjList = pObj->GetSubList();
830 : 0 : SetAktGroupAndList(pObj, pNewObjList);
831 : :
832 : : // select contained object if only one object is contained,
833 : : // else select nothing and let the user decide what to do next
834 [ # # ][ # # ]: 0 : if(pNewObjList && pNewObjList->GetObjCount() == 1)
[ # # ]
835 : : {
836 : 0 : SdrObject* pFirstObject = pNewObjList->GetObj(0L);
837 : :
838 [ # # ]: 0 : if(GetView().GetSdrPageView())
839 : : {
840 : 0 : GetView().MarkObj(pFirstObject, GetView().GetSdrPageView());
841 : : }
842 : : }
843 : :
844 : : // build new handles
845 : 0 : GetView().AdjustMarkHdl();
846 : :
847 : : // invalidate only when view wants to visualize group entering
848 [ # # ]: 0 : if(GetView().DoVisualizeEnteredGroup())
849 : : {
850 : 0 : InvalidateAllWin();
851 : : }
852 : :
853 [ # # ]: 0 : if (bGlueInvalidate)
854 : : {
855 : 0 : GetView().GlueInvalidate();
856 : : }
857 : :
858 : 0 : bRet = sal_True;
859 : : }
860 : :
861 : 0 : return bRet;
862 : : }
863 : :
864 : 0 : void SdrPageView::LeaveOneGroup()
865 : : {
866 [ # # ]: 0 : if(GetAktGroup())
867 : : {
868 : 0 : sal_Bool bGlueInvalidate = (GetView().ImpIsGlueVisible());
869 : :
870 [ # # ]: 0 : if(bGlueInvalidate)
871 : 0 : GetView().GlueInvalidate();
872 : :
873 : 0 : SdrObject* pLastGroup = GetAktGroup();
874 : 0 : SdrObject* pParentGroup = GetAktGroup()->GetUpGroup();
875 : 0 : SdrObjList* pParentList = GetPage();
876 : :
877 [ # # ]: 0 : if(pParentGroup)
878 : 0 : pParentList = pParentGroup->GetSubList();
879 : :
880 : : // deselect everything
881 : 0 : GetView().UnmarkAll();
882 : :
883 : : // allocations, pAktGroup and pAktList need to be set
884 : 0 : SetAktGroupAndList(pParentGroup, pParentList);
885 : :
886 : : // select the group we just left
887 [ # # ]: 0 : if(pLastGroup)
888 [ # # ]: 0 : if(GetView().GetSdrPageView())
889 : 0 : GetView().MarkObj(pLastGroup, GetView().GetSdrPageView());
890 : :
891 : 0 : GetView().AdjustMarkHdl();
892 : :
893 : : // invalidate only if view wants to visualize group entering
894 [ # # ]: 0 : if(GetView().DoVisualizeEnteredGroup())
895 : 0 : InvalidateAllWin();
896 : :
897 [ # # ]: 0 : if(bGlueInvalidate)
898 : 0 : GetView().GlueInvalidate();
899 : : }
900 : 0 : }
901 : :
902 : 0 : void SdrPageView::LeaveAllGroup()
903 : : {
904 [ # # ]: 0 : if(GetAktGroup())
905 : : {
906 : 0 : sal_Bool bGlueInvalidate = (GetView().ImpIsGlueVisible());
907 : :
908 [ # # ]: 0 : if(bGlueInvalidate)
909 : 0 : GetView().GlueInvalidate();
910 : :
911 : 0 : SdrObject* pLastGroup = GetAktGroup();
912 : :
913 : : // deselect everything
914 : 0 : GetView().UnmarkAll();
915 : :
916 : : // allocations, pAktGroup and pAktList always need to be set
917 : 0 : SetAktGroupAndList(NULL, GetPage());
918 : :
919 : : // find and select uppermost group
920 [ # # ]: 0 : if(pLastGroup)
921 : : {
922 [ # # ]: 0 : while(pLastGroup->GetUpGroup())
923 : 0 : pLastGroup = pLastGroup->GetUpGroup();
924 : :
925 [ # # ]: 0 : if(GetView().GetSdrPageView())
926 : 0 : GetView().MarkObj(pLastGroup, GetView().GetSdrPageView());
927 : : }
928 : :
929 : 0 : GetView().AdjustMarkHdl();
930 : :
931 : : // invalidate only when view wants to visualize group entering
932 [ # # ]: 0 : if(GetView().DoVisualizeEnteredGroup())
933 : 0 : InvalidateAllWin();
934 : :
935 [ # # ]: 0 : if(bGlueInvalidate)
936 : 0 : GetView().GlueInvalidate();
937 : : }
938 : 0 : }
939 : :
940 : 6385 : sal_uInt16 SdrPageView::GetEnteredLevel() const
941 : : {
942 : 6385 : sal_uInt16 nAnz=0;
943 : 6385 : SdrObject* pGrp=GetAktGroup();
944 [ - + ]: 6385 : while (pGrp!=NULL) {
945 : 0 : nAnz++;
946 : 0 : pGrp=pGrp->GetUpGroup();
947 : : }
948 : 6385 : return nAnz;
949 : : }
950 : :
951 : 0 : void SdrPageView::CheckAktGroup()
952 : : {
953 : 0 : SdrObject* pGrp=GetAktGroup();
954 [ # # # # : 0 : while (pGrp!=NULL &&
# # # # #
# ][ # # ]
955 : 0 : (!pGrp->IsInserted() || pGrp->GetObjList()==NULL ||
956 : 0 : pGrp->GetPage()==NULL || pGrp->GetModel()==NULL)) { // anything outside of the borders?
957 : 0 : pGrp=pGrp->GetUpGroup();
958 : : }
959 [ # # ]: 0 : if (pGrp!=GetAktGroup()) {
960 [ # # ]: 0 : if (pGrp!=NULL) EnterGroup(pGrp);
961 : 0 : else LeaveAllGroup();
962 : : }
963 : 0 : }
964 : :
965 : : // Set background color for svx at SdrPageViews
966 : 2394 : void SdrPageView::SetApplicationBackgroundColor(Color aBackgroundColor)
967 : : {
968 : 2394 : maBackgroundColor = aBackgroundColor;
969 : 2394 : }
970 : :
971 : 1338 : Color SdrPageView::GetApplicationBackgroundColor() const
972 : : {
973 : 1338 : return maBackgroundColor;
974 : : }
975 : :
976 : : // Set document color for svx at SdrPageViews
977 : 0 : void SdrPageView::SetApplicationDocumentColor(Color aDocumentColor)
978 : : {
979 : 0 : maDocumentColor = aDocumentColor;
980 : 0 : }
981 : :
982 : 4088 : Color SdrPageView::GetApplicationDocumentColor() const
983 : : {
984 : 4088 : return maDocumentColor;
985 : : }
986 : :
987 : :
988 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|