bump product version to 4.1.6.2
[LibreOffice.git] / svx / source / svdraw / svdpagv.cxx
blobbbd94bf4bb4e24ef4faceaeded5ce0b4d7a68075
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <svx/svdpagv.hxx>
21 #include <com/sun/star/awt/XWindow.hpp>
22 #include <com/sun/star/awt/PosSize.hpp>
23 #include <comphelper/processfactory.hxx>
24 #include <svx/svdoutl.hxx>
25 #include <svx/xpoly.hxx>
26 #include <svx/svdouno.hxx>
27 #include <svx/svdpage.hxx>
28 #include <svx/svdview.hxx>
30 #include <svx/svdedxv.hxx>
31 #include <editeng/outliner.hxx>
32 #include <svx/svdetc.hxx>
33 #include <svx/svdobj.hxx>
34 #include "svx/svditer.hxx"
35 #include <svx/svdogrp.hxx>
36 #include <svx/svdtypes.hxx>
37 #include <svx/svdoole2.hxx>
39 #include <svx/sdr/contact/objectcontactofpageview.hxx>
40 #include <svx/sdr/contact/viewobjectcontactredirector.hxx>
41 #include <svx/fmview.hxx>
43 // for search on vector
44 #include <algorithm>
46 using namespace ::rtl;
47 using namespace ::com::sun::star;
48 #include <svx/sdrpagewindow.hxx>
49 #include <svx/sdrpaintwindow.hxx>
51 DBG_NAME(SdrPageView);
53 ////////////////////////////////////////////////////////////////////////////////////////////////////
54 // interface to SdrPageWindow
56 SdrPageWindow* SdrPageView::FindPageWindow(SdrPaintWindow& rPaintWindow) const
58 for(SdrPageWindowVector::const_iterator a = maPageWindows.begin(); a != maPageWindows.end(); ++a)
60 if(&((*a)->GetPaintWindow()) == &rPaintWindow)
62 return *a;
66 return 0L;
69 const SdrPageWindow* SdrPageView::FindPatchedPageWindow( const OutputDevice& _rOutDev ) const
71 for ( SdrPageWindowVector::const_iterator loop = maPageWindows.begin();
72 loop != maPageWindows.end();
73 ++loop
76 const SdrPageWindow& rPageWindow( *(*loop) );
77 const SdrPaintWindow& rPaintWindow( rPageWindow.GetOriginalPaintWindow() ? *rPageWindow.GetOriginalPaintWindow() : rPageWindow.GetPaintWindow() );
78 if ( &rPaintWindow.GetOutputDevice() == &_rOutDev )
80 return &rPageWindow;
84 return NULL;
87 SdrPageWindow* SdrPageView::FindPageWindow(const OutputDevice& rOutDev) const
89 for(SdrPageWindowVector::const_iterator a = maPageWindows.begin(); a != maPageWindows.end(); ++a)
91 if(&((*a)->GetPaintWindow().GetOutputDevice()) == &rOutDev)
93 return *a;
97 return 0L;
100 SdrPageWindow* SdrPageView::GetPageWindow(sal_uInt32 nIndex) const
102 if(nIndex < maPageWindows.size())
104 return maPageWindows[nIndex];
107 return 0L;
110 void SdrPageView::ClearPageWindows()
112 for(SdrPageWindowVector::const_iterator a = maPageWindows.begin(); a != maPageWindows.end(); ++a)
114 delete *a;
117 maPageWindows.clear();
120 void SdrPageView::AppendPageWindow(SdrPageWindow& rNew)
122 maPageWindows.push_back(&rNew);
125 SdrPageWindow* SdrPageView::RemovePageWindow(SdrPageWindow& rOld)
127 const SdrPageWindowVector::iterator aFindResult = ::std::find(maPageWindows.begin(), maPageWindows.end(), &rOld);
129 if(aFindResult != maPageWindows.end())
131 // remember return value
132 SdrPageWindow* pSdrPageWindow = *aFindResult;
133 maPageWindows.erase(aFindResult);
134 return pSdrPageWindow;
137 return 0L;
140 //////////////////////////////////////////////////////////////////////////////
142 SdrPageView::SdrPageView(SdrPage* pPage1, SdrView& rNewView)
143 : mrView(rNewView),
144 // col_auto color lets the view takes the default SvxColorConfig entry
145 maDocumentColor( COL_AUTO ),
146 maBackgroundColor(COL_AUTO ), // #i48367# also react on autocolor
147 mpPreparedPageWindow(0) // #i72752#
149 DBG_CTOR(SdrPageView,NULL);
150 mpPage = pPage1;
152 if(mpPage)
154 aPgOrg.X()=mpPage->GetLftBorder();
155 aPgOrg.Y()=mpPage->GetUppBorder();
157 mbHasMarked = sal_False;
158 aLayerVisi.SetAll();
159 aLayerPrn.SetAll();
161 mbVisible = sal_False;
162 pAktList = NULL;
163 pAktGroup = NULL;
164 SetAktGroupAndList(NULL, mpPage);
166 for(sal_uInt32 a(0L); a < rNewView.PaintWindowCount(); a++)
168 AddPaintWindowToPageView(*rNewView.GetPaintWindow(a));
172 SdrPageView::~SdrPageView()
174 DBG_DTOR(SdrPageView,NULL);
176 // cleanup window vector
177 ClearPageWindows();
180 SdrPageWindow& SdrPageView::CreateNewPageWindowEntry(SdrPaintWindow& rPaintWindow)
182 SdrPageWindow& rWindow = *(new SdrPageWindow(*this, rPaintWindow));
183 AppendPageWindow(rWindow);
185 return rWindow;
188 void SdrPageView::AddPaintWindowToPageView(SdrPaintWindow& rPaintWindow)
190 if(!FindPageWindow(rPaintWindow))
192 CreateNewPageWindowEntry(rPaintWindow);
196 void SdrPageView::RemovePaintWindowFromPageView(SdrPaintWindow& rPaintWindow)
198 SdrPageWindow* pCandidate = FindPageWindow(rPaintWindow);
200 if(pCandidate)
202 pCandidate = RemovePageWindow(*pCandidate);
204 if(pCandidate)
206 delete pCandidate;
211 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer > SdrPageView::GetControlContainer( const OutputDevice& _rDevice ) const
213 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer > xReturn;
214 const SdrPageWindow* pCandidate = FindPatchedPageWindow( _rDevice );
216 if ( pCandidate )
217 xReturn = pCandidate->GetControlContainer( true );
219 return xReturn;
222 void SdrPageView::ModelHasChanged()
224 if (GetAktGroup()!=NULL) CheckAktGroup();
227 sal_Bool SdrPageView::IsReadOnly() const
229 return (0L == GetPage() || GetView().GetModel()->IsReadOnly() || GetPage()->IsReadOnly() || GetObjList()->IsReadOnly());
232 void SdrPageView::Show()
234 if(!IsVisible())
236 mbVisible = sal_True;
237 InvalidateAllWin();
239 for(sal_uInt32 a(0L); a < GetView().PaintWindowCount(); a++)
241 AddPaintWindowToPageView(*GetView().GetPaintWindow(a));
246 void SdrPageView::Hide()
248 if(IsVisible())
250 InvalidateAllWin();
251 mbVisible = sal_False;
252 ClearPageWindows();
256 Rectangle SdrPageView::GetPageRect() const
258 if (GetPage()==NULL) return Rectangle();
259 return Rectangle(Point(),Size(GetPage()->GetWdt()+1,GetPage()->GetHgt()+1));
262 void SdrPageView::InvalidateAllWin()
264 if(IsVisible() && GetPage())
266 Rectangle aRect(Point(0,0),Size(GetPage()->GetWdt()+1,GetPage()->GetHgt()+1));
267 aRect.Union(GetPage()->GetAllObjBoundRect());
268 GetView().InvalidateAllWin(aRect);
272 ////////////////////////////////////////////////////////////////////////////////////////////////////
274 void SdrPageView::PrePaint()
276 const sal_uInt32 nCount(PageWindowCount());
278 for(sal_uInt32 a(0); a < nCount; a++)
280 SdrPageWindow* pCandidate = GetPageWindow(a);
282 if(pCandidate)
284 pCandidate->PrePaint();
289 void SdrPageView::CompleteRedraw(SdrPaintWindow& rPaintWindow, const Region& rReg, sdr::contact::ViewObjectContactRedirector* pRedirector) const
291 if(GetPage())
293 SdrPageWindow* pPageWindow = FindPageWindow(rPaintWindow);
294 bool bIsTempTarget(false);
296 if(!pPageWindow)
298 // create temp PageWindow
299 pPageWindow = new SdrPageWindow(*((SdrPageView*)this), rPaintWindow);
300 bIsTempTarget = true;
303 // do the redraw
304 pPageWindow->PrepareRedraw(rReg);
305 pPageWindow->RedrawAll(pRedirector);
307 // get rid of temp PageWindow
308 if(bIsTempTarget)
310 delete pPageWindow;
311 pPageWindow = 0L;
316 ////////////////////////////////////////////////////////////////////////////////////////////////////
317 // #i74769# use SdrPaintWindow directly
319 void SdrPageView::setPreparedPageWindow(SdrPageWindow* pKnownTarget)
321 // #i72752# remember prepared SdrPageWindow
322 mpPreparedPageWindow = pKnownTarget;
325 void SdrPageView::DrawLayer(SdrLayerID nID, OutputDevice* pGivenTarget, sdr::contact::ViewObjectContactRedirector* pRedirector, const Rectangle& rRect) const
327 if(GetPage())
329 if(pGivenTarget)
331 const SdrPageWindow* pKnownTarget = FindPageWindow(*pGivenTarget);
333 if(pKnownTarget)
335 // paint known target
336 pKnownTarget->RedrawLayer(&nID, pRedirector);
338 else
340 // #i72752# DrawLayer() uses a OutputDevice different from BeginDrawLayer. This happens
341 // e.g. when SW paints a single text line in text edit mode. Try to use it
342 SdrPageWindow* pPreparedTarget = mpPreparedPageWindow;
344 if(pPreparedTarget)
346 // if we have a prepared target, do not use a new SdrPageWindow since this
347 // works but is expensive. Just use a temporary PaintWindow
348 SdrPaintWindow aTemporaryPaintWindow(mrView, *pGivenTarget);
350 // Copy existing paint region to use the same as prepared in BeginDrawLayer
351 SdrPaintWindow& rExistingPaintWindow = pPreparedTarget->GetPaintWindow();
352 const Region& rExistingRegion = rExistingPaintWindow.GetRedrawRegion();
353 bool bUseRect(false);
354 if (!rRect.IsEmpty())
356 Region r(rExistingRegion);
357 r.Intersect(rRect);
358 // fdo#74435: FIXME: visibility check broken if empty
359 if (!r.IsEmpty())
360 bUseRect = true;
362 if (!bUseRect)
363 aTemporaryPaintWindow.SetRedrawRegion(rExistingRegion);
364 else
365 aTemporaryPaintWindow.SetRedrawRegion(Region(rRect));
367 // patch the ExistingPageWindow
368 pPreparedTarget->patchPaintWindow(aTemporaryPaintWindow);
370 // redraw the layer
371 pPreparedTarget->RedrawLayer(&nID, pRedirector);
373 // restore the ExistingPageWindow
374 pPreparedTarget->unpatchPaintWindow();
376 else
378 OSL_FAIL("SdrPageView::DrawLayer: Creating temporary SdrPageWindow (ObjectContact), this should never be needed (!)");
380 // None of the known OutputDevices is the target of this paint, use
381 // a temporary SdrPageWindow for this Redraw.
382 SdrPaintWindow aTemporaryPaintWindow(mrView, *pGivenTarget);
383 SdrPageWindow aTemporaryPageWindow(*((SdrPageView*)this), aTemporaryPaintWindow);
385 // #i72752#
386 // Copy existing paint region if other PageWindows exist, this was created by
387 // PrepareRedraw() from BeginDrawLayer(). Needs to be used e.g. when suddenly SW
388 // paints into an unknown device other than the view was created for (e.g. VirtualDevice)
389 if(PageWindowCount())
391 SdrPageWindow* pExistingPageWindow = GetPageWindow(0L);
392 SdrPaintWindow& rExistingPaintWindow = pExistingPageWindow->GetPaintWindow();
393 const Region& rExistingRegion = rExistingPaintWindow.GetRedrawRegion();
394 aTemporaryPaintWindow.SetRedrawRegion(rExistingRegion);
397 aTemporaryPageWindow.RedrawLayer(&nID, pRedirector);
401 else
403 // paint in all known windows
404 for(sal_uInt32 a(0L); a < PageWindowCount(); a++)
406 SdrPageWindow* pTarget = GetPageWindow(a);
407 pTarget->RedrawLayer(&nID, pRedirector);
413 void SdrPageView::SetDesignMode( bool _bDesignMode ) const
415 for ( sal_uInt32 i = 0L; i < PageWindowCount(); ++i )
417 const SdrPageWindow& rPageViewWindow = *GetPageWindow(i);
418 rPageViewWindow.SetDesignMode( _bDesignMode );
422 ////////////////////////////////////////////////////////////////////////////////////////////////////
424 void SdrPageView::DrawPageViewGrid(OutputDevice& rOut, const Rectangle& rRect, Color aColor)
426 if (GetPage()==NULL)
427 return;
429 long nx1=GetView().aGridBig.Width();
430 long nx2=GetView().aGridFin.Width();
431 long ny1=GetView().aGridBig.Height();
432 long ny2=GetView().aGridFin.Height();
434 if (nx1==0) nx1=nx2;
435 if (nx2==0) nx2=nx1;
436 if (ny1==0) ny1=ny2;
437 if (ny2==0) ny2=ny1;
438 if (nx1==0) { nx1=ny1; nx2=ny2; }
439 if (ny1==0) { ny1=nx1; ny2=nx2; }
440 if (nx1<0) nx1=-nx1;
441 if (nx2<0) nx2=-nx2;
442 if (ny1<0) ny1=-ny1;
443 if (ny2<0) ny2=-ny2;
445 if (nx1!=0)
447 // no more global output size, use window size instead to decide grid sizes
448 long nScreenWdt = rOut.GetOutputSizePixel().Width();
450 long nMinDotPix=2;
451 long nMinLinPix=4;
453 if (nScreenWdt>=1600)
455 nMinDotPix=4;
456 nMinLinPix=8;
458 else if (nScreenWdt>=1024)
460 nMinDotPix=3;
461 nMinLinPix=6;
463 else
464 { // e. g. 640x480
465 nMinDotPix=2;
466 nMinLinPix=4;
468 Size aMinDotDist(rOut.PixelToLogic(Size(nMinDotPix,nMinDotPix)));
469 Size aMinLinDist(rOut.PixelToLogic(Size(nMinLinPix,nMinLinPix)));
470 bool bHoriSolid=nx2<aMinDotDist.Width();
471 bool bVertSolid=ny2<aMinDotDist.Height();
472 // enlarge line offset (minimum 4 pixels)
473 // enlarge by: *2 *5 *10 *20 *50 *100 ...
474 int nTgl=0;
475 long nVal0=nx1;
476 while (nx1<aMinLinDist.Width())
478 long a=nx1;
480 if (nTgl==0) nx1*=2;
481 if (nTgl==1) nx1=nVal0*5; // => nx1*=2.5
482 if (nTgl==2) nx1*=2;
484 nVal0=a;
485 nTgl++; if (nTgl>=3) nTgl=0;
487 nTgl=0;
488 nVal0=ny1;
489 while (ny1<aMinLinDist.Height())
491 long a=ny1;
493 if (nTgl==0) ny1*=2;
494 if (nTgl==1) ny1=nVal0*5; // => ny1*=2.5
495 if (nTgl==2) ny1*=2;
497 nVal0=a;
498 nTgl++;
500 if (nTgl>=3) nTgl=0;
503 bool bHoriFine=nx2<nx1;
504 bool bVertFine=ny2<ny1;
505 bool bHoriLines=bHoriSolid || bHoriFine || !bVertFine;
506 bool bVertLines=bVertSolid || bVertFine;
508 Color aColorMerk( rOut.GetLineColor() );
509 rOut.SetLineColor( aColor );
511 bool bMap0=rOut.IsMapModeEnabled();
513 long nWrX=0;
514 long nWrY=0;
515 Point aOrg(aPgOrg);
516 long x1=GetPage()->GetLftBorder()+1+nWrX;
517 long x2=GetPage()->GetWdt()-GetPage()->GetRgtBorder()-1+nWrY;
518 long y1=GetPage()->GetUppBorder()+1+nWrX;
519 long y2=GetPage()->GetHgt()-GetPage()->GetLwrBorder()-1+nWrY;
520 const SdrPageGridFrameList* pFrames=GetPage()->GetGridFrameList(this,NULL);
522 sal_uInt16 nGridPaintAnz=1;
523 if (pFrames!=NULL) nGridPaintAnz=pFrames->GetCount();
524 for (sal_uInt16 nGridPaintNum=0; nGridPaintNum<nGridPaintAnz; nGridPaintNum++) {
525 if (pFrames!=NULL) {
526 const SdrPageGridFrame& rGF=(*pFrames)[nGridPaintNum];
527 nWrX=rGF.GetPaperRect().Left();
528 nWrY=rGF.GetPaperRect().Top();
529 x1=rGF.GetUserArea().Left();
530 x2=rGF.GetUserArea().Right();
531 y1=rGF.GetUserArea().Top();
532 y2=rGF.GetUserArea().Bottom();
533 aOrg=rGF.GetUserArea().TopLeft();
534 aOrg-=rGF.GetPaperRect().TopLeft();
536 if (!rRect.IsEmpty()) {
537 Size a1PixSiz(rOut.PixelToLogic(Size(1,1)));
538 long nX1Pix=a1PixSiz.Width(); // add 1 pixel of tolerance
539 long nY1Pix=a1PixSiz.Height();
540 if (x1<rRect.Left() -nX1Pix) x1=rRect.Left() -nX1Pix;
541 if (x2>rRect.Right() +nX1Pix) x2=rRect.Right() +nX1Pix;
542 if (y1<rRect.Top() -nY1Pix) y1=rRect.Top() -nY1Pix;
543 if (y2>rRect.Bottom()+nY1Pix) y2=rRect.Bottom()+nY1Pix;
546 long xBigOrg=aOrg.X()+nWrX;
547 while (xBigOrg>=x1) xBigOrg-=nx1;
548 while (xBigOrg<x1) xBigOrg+=nx1;
549 long xFinOrg=xBigOrg;
550 while (xFinOrg>=x1) xFinOrg-=nx2;
551 while (xFinOrg<x1) xFinOrg+=nx2;
553 long yBigOrg=aOrg.Y()+nWrY;
554 while (yBigOrg>=y1) yBigOrg-=ny1;
555 while (yBigOrg<y1) yBigOrg+=ny1;
556 long yFinOrg=yBigOrg;
557 while (yFinOrg>=y1) yFinOrg-=ny2;
558 while (yFinOrg<y1) yFinOrg+=ny2;
560 if( x1 <= x2 && y1 <= y2 )
562 if( bHoriLines )
564 sal_uIntPtr nGridFlags = ( bHoriSolid ? GRID_HORZLINES : GRID_DOTS );
565 sal_uInt16 nSteps = sal_uInt16(nx1 / nx2);
566 sal_uInt32 nRestPerStepMul1000 = nSteps ? ( ((nx1 * 1000L)/ nSteps) - (nx2 * 1000L) ) : 0;
567 sal_uInt32 nStepOffset = 0;
568 sal_uInt16 nPointOffset = 0;
570 for(sal_uInt16 a=0;a<nSteps;a++)
572 // draw
573 rOut.DrawGrid(
574 Rectangle( xFinOrg + (a * nx2) + nPointOffset, yBigOrg, x2, y2 ),
575 Size( nx1, ny1 ), nGridFlags );
577 // do a step
578 nStepOffset += nRestPerStepMul1000;
579 while(nStepOffset >= 1000)
581 nStepOffset -= 1000;
582 nPointOffset++;
587 if( bVertLines )
589 sal_uIntPtr nGridFlags = ( bVertSolid ? GRID_VERTLINES : GRID_DOTS );
590 sal_uInt16 nSteps = sal_uInt16(ny1 / ny2);
591 sal_uInt32 nRestPerStepMul1000 = nSteps ? ( ((ny1 * 1000L)/ nSteps) - (ny2 * 1000L) ) : 0;
592 sal_uInt32 nStepOffset = 0;
593 sal_uInt16 nPointOffset = 0;
595 for(sal_uInt16 a=0;a<nSteps;a++)
597 // draw
598 rOut.DrawGrid(
599 Rectangle( xBigOrg, yFinOrg + (a * ny2) + nPointOffset, x2, y2 ),
600 Size( nx1, ny1 ), nGridFlags );
602 // do a step
603 nStepOffset += nRestPerStepMul1000;
604 while(nStepOffset >= 1000)
606 nStepOffset -= 1000;
607 nPointOffset++;
614 rOut.EnableMapMode(bMap0);
615 rOut.SetLineColor(aColorMerk);
619 void SdrPageView::AdjHdl()
621 GetView().AdjustMarkHdl();
624 void SdrPageView::SetLayer(const XubString& rName, SetOfByte& rBS, sal_Bool bJa)
626 if(!GetPage())
627 return;
629 SdrLayerID nID = GetPage()->GetLayerAdmin().GetLayerID(rName, sal_True);
631 if(SDRLAYER_NOTFOUND != nID)
632 rBS.Set(nID, bJa);
635 sal_Bool SdrPageView::IsLayer(const XubString& rName, const SetOfByte& rBS) const
637 if(!GetPage())
638 return sal_False;
640 sal_Bool bRet(sal_False);
642 if(rName.Len())
644 SdrLayerID nId = GetPage()->GetLayerAdmin().GetLayerID(rName, sal_True);
646 if(SDRLAYER_NOTFOUND != nId)
648 bRet = rBS.IsSet(nId);
652 return bRet;
655 sal_Bool SdrPageView::IsObjMarkable(SdrObject* pObj) const
657 if(pObj)
659 // excluded from selection?
660 if(pObj->IsMarkProtect())
662 return sal_False;
665 // only visible are selectable
666 if( !pObj->IsVisible() )
668 return sal_False;
671 if(pObj->ISA(SdrObjGroup))
673 // If object is a Group object, visibility may depend on
674 // multiple layers. If one object is markable, Group is markable.
675 SdrObjList* pObjList = ((SdrObjGroup*)pObj)->GetSubList();
677 if(pObjList && pObjList->GetObjCount())
679 sal_Bool bGroupIsMarkable(sal_False);
681 for(sal_uInt32 a(0L); !bGroupIsMarkable && a < pObjList->GetObjCount(); a++)
683 SdrObject* pCandidate = pObjList->GetObj(a);
685 // call recursively
686 if(IsObjMarkable(pCandidate))
688 bGroupIsMarkable = sal_True;
692 return bGroupIsMarkable;
694 else
696 // #i43302#
697 // Allow empty groups to be selected to be able to delete them
698 return sal_True;
701 else
703 // the layer has to be visible and must not be locked
704 SdrLayerID nL = pObj->GetLayer();
705 return (aLayerVisi.IsSet(sal_uInt8(nL)) && !aLayerLock.IsSet(sal_uInt8(nL)));
709 return sal_False;
712 void SdrPageView::SetPageOrigin(const Point& rOrg)
714 if (rOrg!=aPgOrg) {
715 aPgOrg=rOrg;
716 if (GetView().IsGridVisible()) {
717 InvalidateAllWin();
722 void SdrPageView::ImpInvalidateHelpLineArea(sal_uInt16 nNum) const
724 if (GetView().IsHlplVisible() && nNum<aHelpLines.GetCount()) {
725 const SdrHelpLine& rHL=aHelpLines[nNum];
727 for(sal_uInt32 a(0L); a < GetView().PaintWindowCount(); a++)
729 SdrPaintWindow* pCandidate = GetView().GetPaintWindow(a);
731 if(pCandidate->OutputToWindow())
733 OutputDevice& rOutDev = pCandidate->GetOutputDevice();
734 Rectangle aR(rHL.GetBoundRect(rOutDev));
735 Size aSiz(rOutDev.PixelToLogic(Size(1,1)));
736 aR.Left() -= aSiz.Width();
737 aR.Right() += aSiz.Width();
738 aR.Top() -= aSiz.Height();
739 aR.Bottom() += aSiz.Height();
740 ((SdrView&)GetView()).InvalidateOneWin((Window&)rOutDev, aR);
746 void SdrPageView::SetHelpLines(const SdrHelpLineList& rHLL)
748 aHelpLines=rHLL;
749 InvalidateAllWin();
752 void SdrPageView::SetHelpLine(sal_uInt16 nNum, const SdrHelpLine& rNewHelpLine)
754 if (nNum<aHelpLines.GetCount() && aHelpLines[nNum]!=rNewHelpLine) {
755 bool bNeedRedraw = true;
756 if (aHelpLines[nNum].GetKind()==rNewHelpLine.GetKind()) {
757 switch (rNewHelpLine.GetKind()) {
758 case SDRHELPLINE_VERTICAL : if (aHelpLines[nNum].GetPos().X()==rNewHelpLine.GetPos().X()) bNeedRedraw = false; break;
759 case SDRHELPLINE_HORIZONTAL: if (aHelpLines[nNum].GetPos().Y()==rNewHelpLine.GetPos().Y()) bNeedRedraw = false; break;
760 default: break;
761 } // switch
763 if (bNeedRedraw) ImpInvalidateHelpLineArea(nNum);
764 aHelpLines[nNum]=rNewHelpLine;
765 if (bNeedRedraw) ImpInvalidateHelpLineArea(nNum);
769 void SdrPageView::DeleteHelpLine(sal_uInt16 nNum)
771 if (nNum<aHelpLines.GetCount()) {
772 ImpInvalidateHelpLineArea(nNum);
773 aHelpLines.Delete(nNum);
777 void SdrPageView::InsertHelpLine(const SdrHelpLine& rHL, sal_uInt16 nNum)
779 if (nNum > aHelpLines.GetCount())
780 nNum = aHelpLines.GetCount();
781 aHelpLines.Insert(rHL,nNum);
782 if (GetView().IsHlplVisible())
783 ImpInvalidateHelpLineArea(nNum);
786 // set current group and list
787 void SdrPageView::SetAktGroupAndList(SdrObject* pNewGroup, SdrObjList* pNewList)
789 if(pAktGroup != pNewGroup)
791 pAktGroup = pNewGroup;
793 if(pAktList != pNewList)
795 pAktList = pNewList;
799 sal_Bool SdrPageView::EnterGroup(SdrObject* pObj)
801 sal_Bool bRet(sal_False);
803 if(pObj && pObj->IsGroupObject())
805 sal_Bool bGlueInvalidate(GetView().ImpIsGlueVisible());
807 if(bGlueInvalidate)
809 GetView().GlueInvalidate();
812 // deselect all
813 GetView().UnmarkAll();
815 // set current group and list
816 SdrObjList* pNewObjList = pObj->GetSubList();
817 SetAktGroupAndList(pObj, pNewObjList);
819 // select contained object if only one object is contained,
820 // else select nothing and let the user decide what to do next
821 if(pNewObjList && pNewObjList->GetObjCount() == 1)
823 SdrObject* pFirstObject = pNewObjList->GetObj(0L);
825 if(GetView().GetSdrPageView())
827 GetView().MarkObj(pFirstObject, GetView().GetSdrPageView());
831 // build new handles
832 GetView().AdjustMarkHdl();
834 // invalidate only when view wants to visualize group entering
835 if(GetView().DoVisualizeEnteredGroup())
837 InvalidateAllWin();
840 if (bGlueInvalidate)
842 GetView().GlueInvalidate();
845 bRet = sal_True;
848 return bRet;
851 void SdrPageView::LeaveOneGroup()
853 if(GetAktGroup())
855 sal_Bool bGlueInvalidate = (GetView().ImpIsGlueVisible());
857 if(bGlueInvalidate)
858 GetView().GlueInvalidate();
860 SdrObject* pLastGroup = GetAktGroup();
861 SdrObject* pParentGroup = GetAktGroup()->GetUpGroup();
862 SdrObjList* pParentList = GetPage();
864 if(pParentGroup)
865 pParentList = pParentGroup->GetSubList();
867 // deselect everything
868 GetView().UnmarkAll();
870 // allocations, pAktGroup and pAktList need to be set
871 SetAktGroupAndList(pParentGroup, pParentList);
873 // select the group we just left
874 if(pLastGroup)
875 if(GetView().GetSdrPageView())
876 GetView().MarkObj(pLastGroup, GetView().GetSdrPageView());
878 GetView().AdjustMarkHdl();
880 // invalidate only if view wants to visualize group entering
881 if(GetView().DoVisualizeEnteredGroup())
882 InvalidateAllWin();
884 if(bGlueInvalidate)
885 GetView().GlueInvalidate();
889 void SdrPageView::LeaveAllGroup()
891 if(GetAktGroup())
893 sal_Bool bGlueInvalidate = (GetView().ImpIsGlueVisible());
895 if(bGlueInvalidate)
896 GetView().GlueInvalidate();
898 SdrObject* pLastGroup = GetAktGroup();
900 // deselect everything
901 GetView().UnmarkAll();
903 // allocations, pAktGroup and pAktList always need to be set
904 SetAktGroupAndList(NULL, GetPage());
906 // find and select uppermost group
907 if(pLastGroup)
909 while(pLastGroup->GetUpGroup())
910 pLastGroup = pLastGroup->GetUpGroup();
912 if(GetView().GetSdrPageView())
913 GetView().MarkObj(pLastGroup, GetView().GetSdrPageView());
916 GetView().AdjustMarkHdl();
918 // invalidate only when view wants to visualize group entering
919 if(GetView().DoVisualizeEnteredGroup())
920 InvalidateAllWin();
922 if(bGlueInvalidate)
923 GetView().GlueInvalidate();
927 sal_uInt16 SdrPageView::GetEnteredLevel() const
929 sal_uInt16 nAnz=0;
930 SdrObject* pGrp=GetAktGroup();
931 while (pGrp!=NULL) {
932 nAnz++;
933 pGrp=pGrp->GetUpGroup();
935 return nAnz;
938 void SdrPageView::CheckAktGroup()
940 SdrObject* pGrp=GetAktGroup();
941 while (pGrp!=NULL &&
942 (!pGrp->IsInserted() || pGrp->GetObjList()==NULL ||
943 pGrp->GetPage()==NULL || pGrp->GetModel()==NULL)) { // anything outside of the borders?
944 pGrp=pGrp->GetUpGroup();
946 if (pGrp!=GetAktGroup()) {
947 if (pGrp!=NULL) EnterGroup(pGrp);
948 else LeaveAllGroup();
952 // Set background color for svx at SdrPageViews
953 void SdrPageView::SetApplicationBackgroundColor(Color aBackgroundColor)
955 maBackgroundColor = aBackgroundColor;
958 Color SdrPageView::GetApplicationBackgroundColor() const
960 return maBackgroundColor;
963 // Set document color for svx at SdrPageViews
964 void SdrPageView::SetApplicationDocumentColor(Color aDocumentColor)
966 maDocumentColor = aDocumentColor;
969 Color SdrPageView::GetApplicationDocumentColor() const
971 return maDocumentColor;
975 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */