1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_svx.hxx"
26 #include <svx/svdpagv.hxx>
27 #include <com/sun/star/awt/XWindow.hpp>
28 #include <com/sun/star/awt/PosSize.hpp>
29 #include <comphelper/processfactory.hxx>
30 #include <svx/svdoutl.hxx>
31 #include <svx/xpoly.hxx>
32 #include <svx/svdouno.hxx>
33 #include <svx/svdpage.hxx>
34 #include <svx/svdview.hxx>
35
36 #include <svx/svdedxv.hxx>
37 #include <svx/svdpagv.hxx>
38 #include <svx/svdoutl.hxx>
39 #include <svx/svdpagv.hxx>
40 #include <editeng/outliner.hxx>
41 #include <svx/svdetc.hxx>
42 #include <svx/svdobj.hxx>
43 #include <svx/svdouno.hxx>
44 #include <svx/svdpage.hxx>
45 #include <svx/svdview.hxx>
46 #include "svx/svditer.hxx"
47 #include <svx/svdogrp.hxx>
48 #include <svx/svdtypes.hxx>
49 #include <svx/svdoole2.hxx>
50
51 // #110094#
52 #include <svx/sdr/contact/objectcontactofpageview.hxx>
53 #include <svx/svdogrp.hxx>
54 #include <svx/sdr/contact/viewobjectcontactredirector.hxx>
55 #include <svx/fmview.hxx>
56
57 // for search on vector
58 #include <algorithm>
59
60 using namespace ::rtl;
61 using namespace ::com::sun::star;
62 #include <svx/sdrpagewindow.hxx>
63 #include <svx/sdrpaintwindow.hxx>
64
65 TYPEINIT1(SdrPageView, SfxListener);
66 DBG_NAME(SdrPageView);
67
68 ////////////////////////////////////////////////////////////////////////////////////////////////////
69 // interface to SdrPageWindow
70
FindPageWindow(SdrPaintWindow & rPaintWindow) const71 SdrPageWindow* SdrPageView::FindPageWindow(SdrPaintWindow& rPaintWindow) const
72 {
73 for(SdrPageWindowVector::const_iterator a = maPageWindows.begin(); a != maPageWindows.end(); a++)
74 {
75 if(&((*a)->GetPaintWindow()) == &rPaintWindow)
76 {
77 return *a;
78 }
79 }
80
81 return 0L;
82 }
83
FindPatchedPageWindow(const OutputDevice & _rOutDev) const84 const SdrPageWindow* SdrPageView::FindPatchedPageWindow( const OutputDevice& _rOutDev ) const
85 {
86 for ( SdrPageWindowVector::const_iterator loop = maPageWindows.begin();
87 loop != maPageWindows.end();
88 ++loop
89 )
90 {
91 const SdrPageWindow& rPageWindow( *(*loop) );
92 const SdrPaintWindow& rPaintWindow( rPageWindow.GetOriginalPaintWindow() ? *rPageWindow.GetOriginalPaintWindow() : rPageWindow.GetPaintWindow() );
93 if ( &rPaintWindow.GetOutputDevice() == &_rOutDev )
94 {
95 return &rPageWindow;
96 }
97 }
98
99 return NULL;
100 }
101
FindPageWindow(const OutputDevice & rOutDev) const102 SdrPageWindow* SdrPageView::FindPageWindow(const OutputDevice& rOutDev) const
103 {
104 for(SdrPageWindowVector::const_iterator a = maPageWindows.begin(); a != maPageWindows.end(); a++)
105 {
106 if(&((*a)->GetPaintWindow().GetOutputDevice()) == &rOutDev)
107 {
108 return *a;
109 }
110 }
111
112 return 0L;
113 }
114
GetPageWindow(sal_uInt32 nIndex) const115 SdrPageWindow* SdrPageView::GetPageWindow(sal_uInt32 nIndex) const
116 {
117 // #126416#
118 if(nIndex < maPageWindows.size())
119 {
120 return maPageWindows[nIndex];
121 }
122
123 return 0L;
124 }
125
ClearPageWindows()126 void SdrPageView::ClearPageWindows()
127 {
128 // #126416#
129 for(SdrPageWindowVector::const_iterator a = maPageWindows.begin(); a != maPageWindows.end(); a++)
130 {
131 delete *a;
132 }
133
134 maPageWindows.clear();
135 }
136
AppendPageWindow(SdrPageWindow & rNew)137 void SdrPageView::AppendPageWindow(SdrPageWindow& rNew)
138 {
139 maPageWindows.push_back(&rNew);
140 }
141
RemovePageWindow(sal_uInt32 nPos)142 SdrPageWindow* SdrPageView::RemovePageWindow(sal_uInt32 nPos)
143 {
144 if(nPos < maPageWindows.size())
145 {
146 SdrPageWindowVector::iterator aAccess = maPageWindows.begin() + nPos;
147 // #114376# remember return value
148 SdrPageWindow* pErasedSdrPageWindow = *aAccess;
149 maPageWindows.erase(aAccess);
150 return pErasedSdrPageWindow;
151 }
152
153 return 0L;
154 }
155
RemovePageWindow(SdrPageWindow & rOld)156 SdrPageWindow* SdrPageView::RemovePageWindow(SdrPageWindow& rOld)
157 {
158 const SdrPageWindowVector::iterator aFindResult = ::std::find(maPageWindows.begin(), maPageWindows.end(), &rOld);
159
160 if(aFindResult != maPageWindows.end())
161 {
162 // #114376# remember return value
163 SdrPageWindow* pSdrPageWindow = *aFindResult;
164 maPageWindows.erase(aFindResult);
165 return pSdrPageWindow;
166 }
167
168 return 0L;
169 }
170
171 //////////////////////////////////////////////////////////////////////////////
172
SdrPageView(SdrPage * pPage1,SdrView & rNewView)173 SdrPageView::SdrPageView(SdrPage* pPage1, SdrView& rNewView)
174 : mrView(rNewView),
175 // #103911# col_auto color lets the view takes the default SvxColorConfig entry
176 maDocumentColor( COL_AUTO ),
177 maBackgroundColor(COL_AUTO ), // #i48367# also react on autocolor
178 mpPreparedPageWindow(0) // #i72752#
179 {
180 DBG_CTOR(SdrPageView,NULL);
181 mpPage = pPage1;
182
183 if(mpPage)
184 {
185 aPgOrg.X()=mpPage->GetLftBorder();
186 aPgOrg.Y()=mpPage->GetUppBorder();
187 }
188 mbHasMarked = sal_False;
189 aLayerVisi.SetAll();
190 aLayerPrn.SetAll();
191
192 mbVisible = sal_False;
193 pAktList = NULL;
194 pAktGroup = NULL;
195 SetAktGroupAndList(NULL, mpPage);
196
197 StartListening(*rNewView.GetModel());
198
199 for(sal_uInt32 a(0L); a < rNewView.PaintWindowCount(); a++)
200 {
201 AddPaintWindowToPageView(*rNewView.GetPaintWindow(a));
202 }
203 }
204
~SdrPageView()205 SdrPageView::~SdrPageView()
206 {
207 DBG_DTOR(SdrPageView,NULL);
208
209 // cleanup window vector
210 ClearPageWindows();
211 }
212
CreateNewPageWindowEntry(SdrPaintWindow & rPaintWindow)213 SdrPageWindow& SdrPageView::CreateNewPageWindowEntry(SdrPaintWindow& rPaintWindow)
214 {
215 // MIB 3.7.08: Das WinRec muss sofort in die Liste eingetragen werden,
216 // weil sich das InsertControlContainer darauf verlaesst
217 //SdrPageViewWinRec* pRec = new SdrPageViewWinRec( *this, pOut );
218 //pWinList->Insert(pRec);
219 SdrPageWindow& rWindow = *(new SdrPageWindow(*this, rPaintWindow));
220 AppendPageWindow(rWindow);
221
222 return rWindow;
223 }
224
AddPaintWindowToPageView(SdrPaintWindow & rPaintWindow)225 void SdrPageView::AddPaintWindowToPageView(SdrPaintWindow& rPaintWindow)
226 {
227 if(!FindPageWindow(rPaintWindow))
228 {
229 CreateNewPageWindowEntry(rPaintWindow);
230 }
231 }
232
RemovePaintWindowFromPageView(SdrPaintWindow & rPaintWindow)233 void SdrPageView::RemovePaintWindowFromPageView(SdrPaintWindow& rPaintWindow)
234 {
235 SdrPageWindow* pCandidate = FindPageWindow(rPaintWindow);
236
237 if(pCandidate)
238 {
239 pCandidate = RemovePageWindow(*pCandidate);
240
241 if(pCandidate)
242 {
243 delete pCandidate;
244 }
245 }
246 }
247
GetControlContainer(const OutputDevice & _rDevice) const248 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer > SdrPageView::GetControlContainer( const OutputDevice& _rDevice ) const
249 {
250 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer > xReturn;
251 const SdrPageWindow* pCandidate = FindPatchedPageWindow( _rDevice );
252
253 if ( pCandidate )
254 xReturn = pCandidate->GetControlContainer( true );
255
256 return xReturn;
257 }
258
Notify(SfxBroadcaster &,const SfxHint &)259 void __EXPORT SdrPageView::Notify(SfxBroadcaster& /*rBC*/, const SfxHint& /*rHint*/)
260 {
261 // not really interested in
262 }
263
ModelHasChanged()264 void SdrPageView::ModelHasChanged()
265 {
266 if (GetAktGroup()!=NULL) CheckAktGroup();
267 }
268
IsReadOnly() const269 sal_Bool SdrPageView::IsReadOnly() const
270 {
271 return (0L == GetPage() || GetView().GetModel()->IsReadOnly() || GetPage()->IsReadOnly() || GetObjList()->IsReadOnly());
272 }
273
Show()274 void SdrPageView::Show()
275 {
276 if(!IsVisible())
277 {
278 mbVisible = sal_True;
279 InvalidateAllWin();
280
281 for(sal_uInt32 a(0L); a < GetView().PaintWindowCount(); a++)
282 {
283 AddPaintWindowToPageView(*GetView().GetPaintWindow(a));
284 }
285 }
286 }
287
Hide()288 void SdrPageView::Hide()
289 {
290 if(IsVisible())
291 {
292 InvalidateAllWin();
293 mbVisible = sal_False;
294 ClearPageWindows();
295 }
296 }
297
GetPageRect() const298 Rectangle SdrPageView::GetPageRect() const
299 {
300 if (GetPage()==NULL) return Rectangle();
301 return Rectangle(Point(),Size(GetPage()->GetWdt()+1,GetPage()->GetHgt()+1));
302 }
303
InvalidateAllWin()304 void SdrPageView::InvalidateAllWin()
305 {
306 if(IsVisible() && GetPage())
307 {
308 Rectangle aRect(Point(0,0),Size(GetPage()->GetWdt()+1,GetPage()->GetHgt()+1));
309 aRect.Union(GetPage()->GetAllObjBoundRect());
310 GetView().InvalidateAllWin(aRect);
311 }
312 }
313
InvalidateAllWin(const Rectangle & rRect,sal_Bool bPlus1Pix)314 void SdrPageView::InvalidateAllWin(const Rectangle& rRect, sal_Bool bPlus1Pix)
315 {
316 if(IsVisible())
317 {
318 GetView().InvalidateAllWin(rRect, bPlus1Pix);
319 }
320 }
321
322 ////////////////////////////////////////////////////////////////////////////////////////////////////
323
PrePaint()324 void SdrPageView::PrePaint()
325 {
326 const sal_uInt32 nCount(PageWindowCount());
327
328 for(sal_uInt32 a(0); a < nCount; a++)
329 {
330 SdrPageWindow* pCandidate = GetPageWindow(a);
331
332 if(pCandidate)
333 {
334 pCandidate->PrePaint();
335 }
336 }
337 }
338
PostPaint()339 void SdrPageView::PostPaint()
340 {
341 const sal_uInt32 nCount(PageWindowCount());
342
343 for(sal_uInt32 a(0); a < nCount; a++)
344 {
345 SdrPageWindow* pCandidate = GetPageWindow(a);
346
347 if(pCandidate)
348 {
349 pCandidate->PostPaint();
350 }
351 }
352 }
353
CompleteRedraw(SdrPaintWindow & rPaintWindow,const Region & rReg,sdr::contact::ViewObjectContactRedirector * pRedirector) const354 void SdrPageView::CompleteRedraw(SdrPaintWindow& rPaintWindow, const Region& rReg, sdr::contact::ViewObjectContactRedirector* pRedirector) const
355 {
356 if(GetPage())
357 {
358 SdrPageWindow* pPageWindow = FindPageWindow(rPaintWindow);
359 sal_Bool bIsTempTarget(sal_False);
360
361 if(!pPageWindow)
362 {
363 // create temp PageWindow
364 pPageWindow = new SdrPageWindow(*((SdrPageView*)this), rPaintWindow);
365 bIsTempTarget = sal_True;
366 }
367
368 // do the redraw
369 pPageWindow->PrepareRedraw(rReg);
370 pPageWindow->RedrawAll(pRedirector);
371
372 // get rid of temp PageWindow
373 if(bIsTempTarget)
374 {
375 delete pPageWindow;
376 pPageWindow = 0L;
377 }
378 }
379 }
380
381 ////////////////////////////////////////////////////////////////////////////////////////////////////
382 // #i74769# use SdrPaintWindow directly
383
setPreparedPageWindow(SdrPageWindow * pKnownTarget)384 void SdrPageView::setPreparedPageWindow(SdrPageWindow* pKnownTarget)
385 {
386 // #i72752# remember prepared SdrPageWindow
387 mpPreparedPageWindow = pKnownTarget;
388 }
389
DrawLayer(SdrLayerID nID,OutputDevice * pGivenTarget,sdr::contact::ViewObjectContactRedirector * pRedirector) const390 void SdrPageView::DrawLayer(SdrLayerID nID, OutputDevice* pGivenTarget, sdr::contact::ViewObjectContactRedirector* pRedirector) const
391 {
392 if(GetPage())
393 {
394 if(pGivenTarget)
395 {
396 const SdrPageWindow* pKnownTarget = FindPageWindow(*pGivenTarget);
397
398 if(pKnownTarget)
399 {
400 // paint known target
401 pKnownTarget->RedrawLayer(&nID, pRedirector);
402 }
403 else
404 {
405 // #i72752# DrawLayer() uses a OutputDevice different from BeginDrawLayer. This happens
406 // e.g. when SW paints a single text line in text edit mode. Try to use it
407 SdrPageWindow* pPreparedTarget = mpPreparedPageWindow;
408
409 if(pPreparedTarget)
410 {
411 // if we have a prepared target, do not use a new SdrPageWindow since this
412 // works but is expensive. Just use a temporary PaintWindow
413 SdrPaintWindow aTemporaryPaintWindow(mrView, *pGivenTarget);
414
415 // Copy existing paint region to use the same as prepared in BeginDrawLayer
416 SdrPaintWindow& rExistingPaintWindow = pPreparedTarget->GetPaintWindow();
417 const Region& rExistingRegion = rExistingPaintWindow.GetRedrawRegion();
418 aTemporaryPaintWindow.SetRedrawRegion(rExistingRegion);
419
420 // patch the ExistingPageWindow
421 pPreparedTarget->patchPaintWindow(aTemporaryPaintWindow);
422
423 // redraw the layer
424 pPreparedTarget->RedrawLayer(&nID, pRedirector);
425
426 // restore the ExistingPageWindow
427 pPreparedTarget->unpatchPaintWindow();
428 }
429 else
430 {
431 OSL_ENSURE(false, "SdrPageView::DrawLayer: Creating temporary SdrPageWindow (ObjectContact), this should never be needed (!)");
432
433 // None of the known OutputDevices is the target of this paint, use
434 // a temporary SdrPageWindow for this Redraw.
435 SdrPaintWindow aTemporaryPaintWindow(mrView, *pGivenTarget);
436 SdrPageWindow aTemporaryPageWindow(*((SdrPageView*)this), aTemporaryPaintWindow);
437
438 // #i72752#
439 // Copy existing paint region if other PageWindows exist, this was created by
440 // PrepareRedraw() from BeginDrawLayer(). Needs to be used e.g. when suddenly SW
441 // paints into an unknown device other than the view was created for (e.g. VirtualDevice)
442 if(PageWindowCount())
443 {
444 SdrPageWindow* pExistingPageWindow = GetPageWindow(0L);
445 SdrPaintWindow& rExistingPaintWindow = pExistingPageWindow->GetPaintWindow();
446 const Region& rExistingRegion = rExistingPaintWindow.GetRedrawRegion();
447 aTemporaryPaintWindow.SetRedrawRegion(rExistingRegion);
448 }
449
450 aTemporaryPageWindow.RedrawLayer(&nID, pRedirector);
451 }
452 }
453 }
454 else
455 {
456 // paint in all known windows
457 for(sal_uInt32 a(0L); a < PageWindowCount(); a++)
458 {
459 SdrPageWindow* pTarget = GetPageWindow(a);
460 pTarget->RedrawLayer(&nID, pRedirector);
461 }
462 }
463 }
464 }
465
SetDesignMode(bool _bDesignMode) const466 void SdrPageView::SetDesignMode( bool _bDesignMode ) const
467 {
468 for ( sal_uInt32 i = 0L; i < PageWindowCount(); ++i )
469 {
470 const SdrPageWindow& rPageViewWindow = *GetPageWindow(i);
471 rPageViewWindow.SetDesignMode( _bDesignMode );
472 }
473 }
474
475 ////////////////////////////////////////////////////////////////////////////////////////////////////
476
477 #ifdef OS2
478 #define RGBCOLOR(r,g,b) ((sal_uIntPtr)(((sal_uInt8)(b) | ((sal_uInt16)(g)<<8)) | (((sal_uIntPtr)(sal_uInt8)(r))<<16)))
479 #endif
480
DrawPageViewGrid(OutputDevice & rOut,const Rectangle & rRect,Color aColor)481 void SdrPageView::DrawPageViewGrid(OutputDevice& rOut, const Rectangle& rRect, Color aColor)
482 {
483 if (GetPage()==NULL)
484 return;
485
486 long nx1=GetView().aGridBig.Width();
487 long nx2=GetView().aGridFin.Width();
488 long ny1=GetView().aGridBig.Height();
489 long ny2=GetView().aGridFin.Height();
490
491 if (nx1==0) nx1=nx2;
492 if (nx2==0) nx2=nx1;
493 if (ny1==0) ny1=ny2;
494 if (ny2==0) ny2=ny1;
495 if (nx1==0) { nx1=ny1; nx2=ny2; }
496 if (ny1==0) { ny1=nx1; ny2=nx2; }
497 if (nx1<0) nx1=-nx1;
498 if (nx2<0) nx2=-nx2;
499 if (ny1<0) ny1=-ny1;
500 if (ny2<0) ny2=-ny2;
501
502 if (nx1!=0)
503 {
504 // no more global output size, use window size instead to decide grid sizes
505 long nScreenWdt = rOut.GetOutputSizePixel().Width();
506 // old: long nScreenWdt=System::GetDesktopRectPixel().GetWidth();
507
508 // Grid bei kleinen Zoomstufen etwas erweitern
509 //Size a1PixSiz(rOut.PixelToLogic(Size(1,1)));
510 long nMinDotPix=2;
511 long nMinLinPix=4;
512
513 if (nScreenWdt>=1600)
514 {
515 nMinDotPix=4;
516 nMinLinPix=8;
517 }
518 else if (nScreenWdt>=1024)
519 {
520 nMinDotPix=3;
521 nMinLinPix=6;
522 }
523 else
524 { // z.B. 640x480
525 nMinDotPix=2;
526 nMinLinPix=4;
527 }
528 Size aMinDotDist(rOut.PixelToLogic(Size(nMinDotPix,nMinDotPix)));
529 //Size a3PixSiz(rOut.PixelToLogic(Size(2,2)));
530 Size aMinLinDist(rOut.PixelToLogic(Size(nMinLinPix,nMinLinPix)));
531 FASTBOOL bHoriSolid=nx2<aMinDotDist.Width();
532 FASTBOOL bVertSolid=ny2<aMinDotDist.Height();
533 // Linienabstand vergroessern (mind. 4 Pixel)
534 // Vergroesserung: *2 *5 *10 *20 *50 *100 ...
535 int nTgl=0;
536 long nVal0=nx1;
537 while (nx1<aMinLinDist.Width())
538 {
539 long a=nx1;
540
541 if (nTgl==0) nx1*=2;
542 if (nTgl==1) nx1=nVal0*5; // => nx1*=2.5
543 if (nTgl==2) nx1*=2;
544
545 nVal0=a;
546 nTgl++; if (nTgl>=3) nTgl=0;
547 }
548 nTgl=0;
549 nVal0=ny1;
550 while (ny1<aMinLinDist.Height())
551 {
552 long a=ny1;
553
554 if (nTgl==0) ny1*=2;
555 if (nTgl==1) ny1=nVal0*5; // => ny1*=2.5
556 if (nTgl==2) ny1*=2;
557
558 nVal0=a;
559 nTgl++;
560
561 if (nTgl>=3) nTgl=0;
562 }
563 // Keine Zwischenpunkte, wenn...
564 //if (nx2<a2PixSiz.Width()) nx2=nx1;
565 //if (ny2<a2PixSiz.Height()) ny2=ny1;
566
567 FASTBOOL bHoriFine=nx2<nx1;
568 FASTBOOL bVertFine=ny2<ny1;
569 FASTBOOL bHoriLines=bHoriSolid || bHoriFine || !bVertFine;
570 FASTBOOL bVertLines=bVertSolid || bVertFine;
571
572 Color aColorMerk( rOut.GetLineColor() );
573 rOut.SetLineColor( aColor );
574
575 bool bMap0=rOut.IsMapModeEnabled();
576
577 long nWrX=0;//aWriterPageOffset.X();
578 long nWrY=0;//aWriterPageOffset.Y();
579 Point aOrg(aPgOrg);
580 long x1=GetPage()->GetLftBorder()+1+nWrX;
581 long x2=GetPage()->GetWdt()-GetPage()->GetRgtBorder()-1+nWrY;
582 long y1=GetPage()->GetUppBorder()+1+nWrX;
583 long y2=GetPage()->GetHgt()-GetPage()->GetLwrBorder()-1+nWrY;
584 const SdrPageGridFrameList* pFrames=GetPage()->GetGridFrameList(this,NULL);
585 //sal_uInt16 nBufSiz=1024; // 4k Buffer = max. 512 Punkte
586 // #90353# long* pBuf = NULL;
587 sal_uInt16 nGridPaintAnz=1;
588 if (pFrames!=NULL) nGridPaintAnz=pFrames->GetCount();
589 for (sal_uInt16 nGridPaintNum=0; nGridPaintNum<nGridPaintAnz; nGridPaintNum++) {
590 if (pFrames!=NULL) {
591 const SdrPageGridFrame& rGF=(*pFrames)[nGridPaintNum];
592 nWrX=rGF.GetPaperRect().Left();
593 nWrY=rGF.GetPaperRect().Top();
594 x1=rGF.GetUserArea().Left();
595 x2=rGF.GetUserArea().Right();
596 y1=rGF.GetUserArea().Top();
597 y2=rGF.GetUserArea().Bottom();
598 aOrg=rGF.GetUserArea().TopLeft();
599 aOrg-=rGF.GetPaperRect().TopLeft();
600 }
601 if (!rRect.IsEmpty()) {
602 Size a1PixSiz(rOut.PixelToLogic(Size(1,1)));
603 long nX1Pix=a1PixSiz.Width(); // 1 Pixel Toleranz drauf
604 long nY1Pix=a1PixSiz.Height();
605 if (x1<rRect.Left() -nX1Pix) x1=rRect.Left() -nX1Pix;
606 if (x2>rRect.Right() +nX1Pix) x2=rRect.Right() +nX1Pix;
607 if (y1<rRect.Top() -nY1Pix) y1=rRect.Top() -nY1Pix;
608 if (y2>rRect.Bottom()+nY1Pix) y2=rRect.Bottom()+nY1Pix;
609 }
610 Point aPnt;
611
612 long xBigOrg=aOrg.X()+nWrX;
613 while (xBigOrg>=x1) xBigOrg-=nx1;
614 while (xBigOrg<x1) xBigOrg+=nx1;
615 long xFinOrg=xBigOrg;
616 while (xFinOrg>=x1) xFinOrg-=nx2;
617 while (xFinOrg<x1) xFinOrg+=nx2;
618
619 long yBigOrg=aOrg.Y()+nWrY;
620 while (yBigOrg>=y1) yBigOrg-=ny1;
621 while (yBigOrg<y1) yBigOrg+=ny1;
622 long yFinOrg=yBigOrg;
623 while (yFinOrg>=y1) yFinOrg-=ny2;
624 while (yFinOrg<y1) yFinOrg+=ny2;
625
626 if( x1 <= x2 && y1 <= y2 )
627 {
628 if( bHoriLines )
629 {
630 sal_uIntPtr nGridFlags = ( bHoriSolid ? GRID_HORZLINES : GRID_DOTS );
631 sal_uInt16 nSteps = sal_uInt16(nx1 / nx2);
632 sal_uInt32 nRestPerStepMul1000 = nSteps ? ( ((nx1 * 1000L)/ nSteps) - (nx2 * 1000L) ) : 0;
633 sal_uInt32 nStepOffset = 0;
634 sal_uInt16 nPointOffset = 0;
635
636 for(sal_uInt16 a=0;a<nSteps;a++)
637 {
638 // Zeichnen
639 rOut.DrawGrid(
640 Rectangle( xFinOrg + (a * nx2) + nPointOffset, yBigOrg, x2, y2 ),
641 Size( nx1, ny1 ), nGridFlags );
642
643 // Schritt machen
644 nStepOffset += nRestPerStepMul1000;
645 while(nStepOffset >= 1000)
646 {
647 nStepOffset -= 1000;
648 nPointOffset++;
649 }
650 }
651 }
652
653 if( bVertLines )
654 {
655 sal_uIntPtr nGridFlags = ( bVertSolid ? GRID_VERTLINES : GRID_DOTS );
656 sal_uInt16 nSteps = sal_uInt16(ny1 / ny2);
657 sal_uInt32 nRestPerStepMul1000 = nSteps ? ( ((ny1 * 1000L)/ nSteps) - (ny2 * 1000L) ) : 0;
658 sal_uInt32 nStepOffset = 0;
659 sal_uInt16 nPointOffset = 0;
660
661 for(sal_uInt16 a=0;a<nSteps;a++)
662 {
663 // Zeichnen
664 rOut.DrawGrid(
665 Rectangle( xBigOrg, yFinOrg + (a * ny2) + nPointOffset, x2, y2 ),
666 Size( nx1, ny1 ), nGridFlags );
667
668 // Schritt machen
669 nStepOffset += nRestPerStepMul1000;
670 while(nStepOffset >= 1000)
671 {
672 nStepOffset -= 1000;
673 nPointOffset++;
674 }
675 }
676
677 // rOut.DrawGrid( Rectangle( xo + xBigOrg, yo + yFinOrg, x2, y2 ), Size( nx1, ny2 ), nGridFlags );
678 }
679 }
680 }
681
682 rOut.EnableMapMode(bMap0);
683 rOut.SetLineColor(aColorMerk);
684 }
685 }
686
AdjHdl()687 void SdrPageView::AdjHdl()
688 {
689 GetView().AdjustMarkHdl();
690 }
691
SetLayer(const XubString & rName,SetOfByte & rBS,sal_Bool bJa)692 void SdrPageView::SetLayer(const XubString& rName, SetOfByte& rBS, sal_Bool bJa)
693 {
694 if(!GetPage())
695 return;
696
697 SdrLayerID nID = GetPage()->GetLayerAdmin().GetLayerID(rName, sal_True);
698
699 if(SDRLAYER_NOTFOUND != nID)
700 rBS.Set(nID, bJa);
701 }
702
IsLayer(const XubString & rName,const SetOfByte & rBS) const703 sal_Bool SdrPageView::IsLayer(const XubString& rName, const SetOfByte& rBS) const
704 {
705 if(!GetPage())
706 return sal_False;
707
708 sal_Bool bRet(sal_False);
709
710 if(rName.Len())
711 {
712 SdrLayerID nId = GetPage()->GetLayerAdmin().GetLayerID(rName, sal_True);
713
714 if(SDRLAYER_NOTFOUND != nId)
715 {
716 bRet = rBS.IsSet(nId);
717 }
718 }
719
720 return bRet;
721 }
722
SetAllLayers(SetOfByte & rB,sal_Bool bJa)723 void SdrPageView::SetAllLayers(SetOfByte& rB, sal_Bool bJa)
724 {
725 if(bJa)
726 {
727 rB.SetAll();
728 rB.Clear(SDRLAYER_NOTFOUND);
729 }
730 else
731 {
732 rB.ClearAll();
733 }
734 }
735
IsObjMarkable(SdrObject * pObj) const736 sal_Bool SdrPageView::IsObjMarkable(SdrObject* pObj) const
737 {
738 if(pObj)
739 {
740 // Vom Markieren ausgeschlossen?
741 if(pObj->IsMarkProtect())
742 {
743 return sal_False;
744 }
745
746 // only visible are markable
747 if( !pObj->IsVisible() )
748 {
749 return sal_False;
750 }
751
752 // #112440#
753 if(pObj->ISA(SdrObjGroup))
754 {
755 // If object is a Group object, visibility depends evtl. on
756 // multiple layers. If one object is markable, Group is markable.
757 SdrObjList* pObjList = ((SdrObjGroup*)pObj)->GetSubList();
758
759 if(pObjList && pObjList->GetObjCount())
760 {
761 sal_Bool bGroupIsMarkable(sal_False);
762
763 for(sal_uInt32 a(0L); !bGroupIsMarkable && a < pObjList->GetObjCount(); a++)
764 {
765 SdrObject* pCandidate = pObjList->GetObj(a);
766
767 // call recursively
768 if(IsObjMarkable(pCandidate))
769 {
770 bGroupIsMarkable = sal_True;
771 }
772 }
773
774 return bGroupIsMarkable;
775 }
776 else
777 {
778 // #i43302#
779 // Allow empty groups to be selected to be able to delete them
780 return sal_True;
781 }
782 }
783 else
784 {
785 // Der Layer muss sichtbar und darf nicht gesperrt sein
786 SdrLayerID nL = pObj->GetLayer();
787 return (aLayerVisi.IsSet(sal_uInt8(nL)) && !aLayerLock.IsSet(sal_uInt8(nL)));
788 }
789 }
790
791 return sal_False;
792 }
793
SetPageOrigin(const Point & rOrg)794 void SdrPageView::SetPageOrigin(const Point& rOrg)
795 {
796 if (rOrg!=aPgOrg) {
797 aPgOrg=rOrg;
798 if (GetView().IsGridVisible()) {
799 InvalidateAllWin();
800 }
801 }
802 }
803
ImpInvalidateHelpLineArea(sal_uInt16 nNum) const804 void SdrPageView::ImpInvalidateHelpLineArea(sal_uInt16 nNum) const
805 {
806 if (GetView().IsHlplVisible() && nNum<aHelpLines.GetCount()) {
807 const SdrHelpLine& rHL=aHelpLines[nNum];
808
809 for(sal_uInt32 a(0L); a < GetView().PaintWindowCount(); a++)
810 {
811 SdrPaintWindow* pCandidate = GetView().GetPaintWindow(a);
812
813 if(pCandidate->OutputToWindow())
814 {
815 OutputDevice& rOutDev = pCandidate->GetOutputDevice();
816 Rectangle aR(rHL.GetBoundRect(rOutDev));
817 Size aSiz(rOutDev.PixelToLogic(Size(1,1)));
818 aR.Left() -= aSiz.Width();
819 aR.Right() += aSiz.Width();
820 aR.Top() -= aSiz.Height();
821 aR.Bottom() += aSiz.Height();
822 ((SdrView&)GetView()).InvalidateOneWin((Window&)rOutDev, aR);
823 }
824 }
825 }
826 }
827
SetHelpLines(const SdrHelpLineList & rHLL)828 void SdrPageView::SetHelpLines(const SdrHelpLineList& rHLL)
829 {
830 aHelpLines=rHLL;
831 InvalidateAllWin();
832 }
833
SetHelpLine(sal_uInt16 nNum,const SdrHelpLine & rNewHelpLine)834 void SdrPageView::SetHelpLine(sal_uInt16 nNum, const SdrHelpLine& rNewHelpLine)
835 {
836 if (nNum<aHelpLines.GetCount() && aHelpLines[nNum]!=rNewHelpLine) {
837 FASTBOOL bNeedRedraw=sal_True;
838 if (aHelpLines[nNum].GetKind()==rNewHelpLine.GetKind()) {
839 switch (rNewHelpLine.GetKind()) {
840 case SDRHELPLINE_VERTICAL : if (aHelpLines[nNum].GetPos().X()==rNewHelpLine.GetPos().X()) bNeedRedraw=sal_False; break;
841 case SDRHELPLINE_HORIZONTAL: if (aHelpLines[nNum].GetPos().Y()==rNewHelpLine.GetPos().Y()) bNeedRedraw=sal_False; break;
842 default: break;
843 } // switch
844 }
845 if (bNeedRedraw) ImpInvalidateHelpLineArea(nNum);
846 aHelpLines[nNum]=rNewHelpLine;
847 if (bNeedRedraw) ImpInvalidateHelpLineArea(nNum);
848 }
849 }
850
DeleteHelpLine(sal_uInt16 nNum)851 void SdrPageView::DeleteHelpLine(sal_uInt16 nNum)
852 {
853 if (nNum<aHelpLines.GetCount()) {
854 ImpInvalidateHelpLineArea(nNum);
855 aHelpLines.Delete(nNum);
856 }
857 }
858
InsertHelpLine(const SdrHelpLine & rHL,sal_uInt16 nNum)859 void SdrPageView::InsertHelpLine(const SdrHelpLine& rHL, sal_uInt16 nNum)
860 {
861 if (nNum>aHelpLines.GetCount()) nNum=aHelpLines.GetCount();
862 aHelpLines.Insert(rHL,nNum);
863 if (GetView().IsHlplVisible()) {
864 if (GetView().IsHlplFront()) {
865 // Hier optimieren ...
866 ImpInvalidateHelpLineArea(nNum);
867 } else {
868 ImpInvalidateHelpLineArea(nNum);
869 }
870 }
871 }
872
873 // Betretene Gruppe und Liste setzen
SetAktGroupAndList(SdrObject * pNewGroup,SdrObjList * pNewList)874 void SdrPageView::SetAktGroupAndList(SdrObject* pNewGroup, SdrObjList* pNewList)
875 {
876 if(pAktGroup != pNewGroup)
877 {
878 pAktGroup = pNewGroup;
879 }
880 if(pAktList != pNewList)
881 {
882 pAktList = pNewList;
883 }
884 }
885
EnterGroup(SdrObject * pObj)886 sal_Bool SdrPageView::EnterGroup(SdrObject* pObj)
887 {
888 sal_Bool bRet(sal_False);
889
890 if(pObj && pObj->IsGroupObject())
891 {
892 sal_Bool bGlueInvalidate(GetView().ImpIsGlueVisible());
893
894 if(bGlueInvalidate)
895 {
896 GetView().GlueInvalidate();
897 }
898
899 // deselect all
900 GetView().UnmarkAll();
901
902 // set current group and list
903 SdrObjList* pNewObjList = pObj->GetSubList();
904 SetAktGroupAndList(pObj, pNewObjList);
905
906 // select contained object if only one object is contained,
907 // else select nothing and let the user decide what to do next
908 if(pNewObjList && pNewObjList->GetObjCount() == 1)
909 {
910 SdrObject* pFirstObject = pNewObjList->GetObj(0L);
911
912 if(GetView().GetSdrPageView())
913 {
914 GetView().MarkObj(pFirstObject, GetView().GetSdrPageView());
915 }
916 }
917
918 // build new handles
919 GetView().AdjustMarkHdl();
920
921 // invalidate only when view wants to visualize group entering
922 if(GetView().DoVisualizeEnteredGroup())
923 {
924 InvalidateAllWin();
925 }
926
927 if (bGlueInvalidate)
928 {
929 GetView().GlueInvalidate();
930 }
931
932 bRet = sal_True;
933 }
934
935 return bRet;
936 }
937
LeaveOneGroup()938 void SdrPageView::LeaveOneGroup()
939 {
940 if(GetAktGroup())
941 {
942 sal_Bool bGlueInvalidate = (GetView().ImpIsGlueVisible());
943
944 if(bGlueInvalidate)
945 GetView().GlueInvalidate();
946
947 SdrObject* pLastGroup = GetAktGroup();
948 SdrObject* pParentGroup = GetAktGroup()->GetUpGroup();
949 SdrObjList* pParentList = GetPage();
950
951 if(pParentGroup)
952 pParentList = pParentGroup->GetSubList();
953
954 // Alles deselektieren
955 GetView().UnmarkAll();
956
957 // Zuweisungen, pAktGroup und pAktList muessen gesetzt sein
958 SetAktGroupAndList(pParentGroup, pParentList);
959
960 // gerade verlassene Gruppe selektieren
961 if(pLastGroup)
962 if(GetView().GetSdrPageView())
963 GetView().MarkObj(pLastGroup, GetView().GetSdrPageView());
964
965 GetView().AdjustMarkHdl();
966
967 // invalidate only when view wants to visualize group entering
968 if(GetView().DoVisualizeEnteredGroup())
969 InvalidateAllWin();
970
971 if(bGlueInvalidate)
972 GetView().GlueInvalidate();
973 }
974 }
975
LeaveAllGroup()976 void SdrPageView::LeaveAllGroup()
977 {
978 if(GetAktGroup())
979 {
980 sal_Bool bGlueInvalidate = (GetView().ImpIsGlueVisible());
981
982 if(bGlueInvalidate)
983 GetView().GlueInvalidate();
984
985 SdrObject* pLastGroup = GetAktGroup();
986
987 // Alles deselektieren
988 GetView().UnmarkAll();
989
990 // Zuweisungen, pAktGroup und pAktList muessen gesetzt sein
991 SetAktGroupAndList(NULL, GetPage());
992
993 // Oberste letzte Gruppe finden und selektieren
994 if(pLastGroup)
995 {
996 while(pLastGroup->GetUpGroup())
997 pLastGroup = pLastGroup->GetUpGroup();
998
999 if(GetView().GetSdrPageView())
1000 GetView().MarkObj(pLastGroup, GetView().GetSdrPageView());
1001 }
1002
1003 GetView().AdjustMarkHdl();
1004
1005 // invalidate only when view wants to visualize group entering
1006 if(GetView().DoVisualizeEnteredGroup())
1007 InvalidateAllWin();
1008
1009 if(bGlueInvalidate)
1010 GetView().GlueInvalidate();
1011 }
1012 }
1013
GetEnteredLevel() const1014 sal_uInt16 SdrPageView::GetEnteredLevel() const
1015 {
1016 sal_uInt16 nAnz=0;
1017 SdrObject* pGrp=GetAktGroup();
1018 while (pGrp!=NULL) {
1019 nAnz++;
1020 pGrp=pGrp->GetUpGroup();
1021 }
1022 return nAnz;
1023 }
1024
GetActualGroupName() const1025 XubString SdrPageView::GetActualGroupName() const
1026 {
1027 if(GetAktGroup())
1028 {
1029 XubString aStr(GetAktGroup()->GetName());
1030
1031 if(!aStr.Len())
1032 aStr += sal_Unicode('?');
1033
1034 return aStr;
1035 }
1036 else
1037 return String();
1038 }
1039
GetActualPathName(sal_Unicode cSep) const1040 XubString SdrPageView::GetActualPathName(sal_Unicode cSep) const
1041 {
1042 XubString aStr;
1043 sal_Bool bNamFnd(sal_False);
1044 SdrObject* pGrp = GetAktGroup();
1045
1046 while(pGrp)
1047 {
1048 XubString aStr1(pGrp->GetName());
1049
1050 if(!aStr1.Len())
1051 aStr1 += sal_Unicode('?');
1052 else
1053 bNamFnd = sal_True;
1054
1055 aStr += aStr1;
1056 pGrp = pGrp->GetUpGroup();
1057
1058 if(pGrp)
1059 aStr += cSep;
1060 }
1061
1062 if(!bNamFnd && GetAktGroup())
1063 {
1064 aStr = String();
1065 aStr += sal_Unicode('(');
1066 aStr += String::CreateFromInt32( GetEnteredLevel() );
1067 aStr += sal_Unicode(')');
1068 }
1069
1070 return aStr;
1071 }
1072
CheckAktGroup()1073 void SdrPageView::CheckAktGroup()
1074 {
1075 SdrObject* pGrp=GetAktGroup();
1076 while (pGrp!=NULL &&
1077 (!pGrp->IsInserted() || pGrp->GetObjList()==NULL ||
1078 pGrp->GetPage()==NULL || pGrp->GetModel()==NULL)) { // irgendwas daneben?
1079 pGrp=pGrp->GetUpGroup();
1080 }
1081 if (pGrp!=GetAktGroup()) {
1082 if (pGrp!=NULL) EnterGroup(pGrp);
1083 else LeaveAllGroup();
1084 }
1085 }
1086
1087 // #103834# Set background color for svx at SdrPageViews
SetApplicationBackgroundColor(Color aBackgroundColor)1088 void SdrPageView::SetApplicationBackgroundColor(Color aBackgroundColor)
1089 {
1090 maBackgroundColor = aBackgroundColor;
1091 }
1092
1093 // #109585#
GetApplicationBackgroundColor() const1094 Color SdrPageView::GetApplicationBackgroundColor() const
1095 {
1096 return maBackgroundColor;
1097 }
1098
1099 // #103911# Set document color for svx at SdrPageViews
SetApplicationDocumentColor(Color aDocumentColor)1100 void SdrPageView::SetApplicationDocumentColor(Color aDocumentColor)
1101 {
1102 maDocumentColor = aDocumentColor;
1103 }
1104
GetApplicationDocumentColor() const1105 Color SdrPageView::GetApplicationDocumentColor() const
1106 {
1107 return maDocumentColor;
1108 }
1109
1110 ////////////////////////////////////////////////////////////////////////////////////////////////////
1111 // eof
1112