Version 4.3.0.0.beta1, tag libreoffice-4.3.0.0.beta1
[LibreOffice.git] / svx / source / svdraw / svdpagv.cxx
blob39ffbaa5e02ae765f20e293e27cd4c7518cd2255
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 <sdr/contact/objectcontactofpageview.hxx>
40 #include <svx/sdr/contact/viewobjectcontactredirector.hxx>
41 #include <svx/fmview.hxx>
43 #include <algorithm>
45 using namespace ::rtl;
46 using namespace ::com::sun::star;
47 #include <svx/sdrpagewindow.hxx>
48 #include <svx/sdrpaintwindow.hxx>
52 // interface to SdrPageWindow
54 SdrPageWindow* SdrPageView::FindPageWindow(SdrPaintWindow& rPaintWindow) const
56 for(SdrPageWindowVector::const_iterator a = maPageWindows.begin(); a != maPageWindows.end(); ++a)
58 if(&((*a)->GetPaintWindow()) == &rPaintWindow)
60 return *a;
64 return 0L;
67 const SdrPageWindow* SdrPageView::FindPatchedPageWindow( const OutputDevice& _rOutDev ) const
69 for ( SdrPageWindowVector::const_iterator loop = maPageWindows.begin();
70 loop != maPageWindows.end();
71 ++loop
74 const SdrPageWindow& rPageWindow( *(*loop) );
75 const SdrPaintWindow& rPaintWindow( rPageWindow.GetOriginalPaintWindow() ? *rPageWindow.GetOriginalPaintWindow() : rPageWindow.GetPaintWindow() );
76 if ( &rPaintWindow.GetOutputDevice() == &_rOutDev )
78 return &rPageWindow;
82 return NULL;
85 SdrPageWindow* SdrPageView::FindPageWindow(const OutputDevice& rOutDev) const
87 for(SdrPageWindowVector::const_iterator a = maPageWindows.begin(); a != maPageWindows.end(); ++a)
89 if(&((*a)->GetPaintWindow().GetOutputDevice()) == &rOutDev)
91 return *a;
95 return 0L;
98 SdrPageWindow* SdrPageView::GetPageWindow(sal_uInt32 nIndex) const
100 if(nIndex < maPageWindows.size())
102 return maPageWindows[nIndex];
105 return 0L;
108 void SdrPageView::ClearPageWindows()
110 for(SdrPageWindowVector::const_iterator a = maPageWindows.begin(); a != maPageWindows.end(); ++a)
112 delete *a;
115 maPageWindows.clear();
118 void SdrPageView::AppendPageWindow(SdrPageWindow& rNew)
120 maPageWindows.push_back(&rNew);
123 SdrPageWindow* SdrPageView::RemovePageWindow(SdrPageWindow& rOld)
125 const SdrPageWindowVector::iterator aFindResult = ::std::find(maPageWindows.begin(), maPageWindows.end(), &rOld);
127 if(aFindResult != maPageWindows.end())
129 // remember return value
130 SdrPageWindow* pSdrPageWindow = *aFindResult;
131 maPageWindows.erase(aFindResult);
132 return pSdrPageWindow;
135 return 0L;
140 SdrPageView::SdrPageView(SdrPage* pPage1, SdrView& rNewView)
141 : mrView(rNewView),
142 // col_auto color lets the view takes the default SvxColorConfig entry
143 maDocumentColor( COL_AUTO ),
144 maBackgroundColor(COL_AUTO ), // #i48367# also react on autocolor
145 mpPreparedPageWindow(0) // #i72752#
147 mpPage = pPage1;
149 if(mpPage)
151 aPgOrg.X()=mpPage->GetLftBorder();
152 aPgOrg.Y()=mpPage->GetUppBorder();
154 mbHasMarked = false;
155 aLayerVisi.SetAll();
156 aLayerPrn.SetAll();
158 mbVisible = false;
159 pAktList = NULL;
160 pAktGroup = NULL;
161 SetAktGroupAndList(NULL, mpPage);
163 for(sal_uInt32 a(0L); a < rNewView.PaintWindowCount(); a++)
165 AddPaintWindowToPageView(*rNewView.GetPaintWindow(a));
169 SdrPageView::~SdrPageView()
172 // cleanup window vector
173 ClearPageWindows();
176 SdrPageWindow& SdrPageView::CreateNewPageWindowEntry(SdrPaintWindow& rPaintWindow)
178 SdrPageWindow& rWindow = *(new SdrPageWindow(*this, rPaintWindow));
179 AppendPageWindow(rWindow);
181 return rWindow;
184 void SdrPageView::AddPaintWindowToPageView(SdrPaintWindow& rPaintWindow)
186 if(!FindPageWindow(rPaintWindow))
188 CreateNewPageWindowEntry(rPaintWindow);
192 void SdrPageView::RemovePaintWindowFromPageView(SdrPaintWindow& rPaintWindow)
194 SdrPageWindow* pCandidate = FindPageWindow(rPaintWindow);
196 if(pCandidate)
198 pCandidate = RemovePageWindow(*pCandidate);
200 if(pCandidate)
202 delete pCandidate;
207 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer > SdrPageView::GetControlContainer( const OutputDevice& _rDevice ) const
209 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer > xReturn;
210 const SdrPageWindow* pCandidate = FindPatchedPageWindow( _rDevice );
212 if ( pCandidate )
213 xReturn = pCandidate->GetControlContainer( true );
215 return xReturn;
218 void SdrPageView::ModelHasChanged()
220 if (GetAktGroup()!=NULL) CheckAktGroup();
223 bool SdrPageView::IsReadOnly() const
225 return (0L == GetPage() || GetView().GetModel()->IsReadOnly() || GetPage()->IsReadOnly() || GetObjList()->IsReadOnly());
228 void SdrPageView::Show()
230 if(!IsVisible())
232 mbVisible = true;
233 InvalidateAllWin();
235 for(sal_uInt32 a(0L); a < GetView().PaintWindowCount(); a++)
237 AddPaintWindowToPageView(*GetView().GetPaintWindow(a));
242 void SdrPageView::Hide()
244 if(IsVisible())
246 InvalidateAllWin();
247 mbVisible = false;
248 ClearPageWindows();
252 Rectangle SdrPageView::GetPageRect() const
254 if (GetPage()==NULL) return Rectangle();
255 return Rectangle(Point(),Size(GetPage()->GetWdt()+1,GetPage()->GetHgt()+1));
258 void SdrPageView::InvalidateAllWin()
260 if(IsVisible() && GetPage())
262 Rectangle aRect(Point(0,0),Size(GetPage()->GetWdt()+1,GetPage()->GetHgt()+1));
263 aRect.Union(GetPage()->GetAllObjBoundRect());
264 GetView().InvalidateAllWin(aRect);
270 void SdrPageView::PrePaint()
272 const sal_uInt32 nCount(PageWindowCount());
274 for(sal_uInt32 a(0); a < nCount; a++)
276 SdrPageWindow* pCandidate = GetPageWindow(a);
278 if(pCandidate)
280 pCandidate->PrePaint();
285 void SdrPageView::CompleteRedraw(SdrPaintWindow& rPaintWindow, const Region& rReg, sdr::contact::ViewObjectContactRedirector* pRedirector) const
287 if(GetPage())
289 SdrPageWindow* pPageWindow = FindPageWindow(rPaintWindow);
290 bool bIsTempTarget(false);
292 if(!pPageWindow)
294 // create temp PageWindow
295 pPageWindow = new SdrPageWindow(*((SdrPageView*)this), rPaintWindow);
296 bIsTempTarget = true;
299 // do the redraw
300 pPageWindow->PrepareRedraw(rReg);
301 pPageWindow->RedrawAll(pRedirector);
303 // get rid of temp PageWindow
304 if(bIsTempTarget)
306 delete pPageWindow;
307 pPageWindow = 0L;
313 // #i74769# use SdrPaintWindow directly
315 void SdrPageView::setPreparedPageWindow(SdrPageWindow* pKnownTarget)
317 // #i72752# remember prepared SdrPageWindow
318 mpPreparedPageWindow = pKnownTarget;
321 void SdrPageView::DrawLayer(SdrLayerID nID, OutputDevice* pGivenTarget, sdr::contact::ViewObjectContactRedirector* pRedirector, const Rectangle& rRect) const
323 if(GetPage())
325 if(pGivenTarget)
327 const SdrPageWindow* pKnownTarget = FindPageWindow(*pGivenTarget);
329 if(pKnownTarget)
331 // paint known target
332 pKnownTarget->RedrawLayer(&nID, pRedirector);
334 else
336 // #i72752# DrawLayer() uses a OutputDevice different from BeginDrawLayer. This happens
337 // e.g. when SW paints a single text line in text edit mode. Try to use it
338 SdrPageWindow* pPreparedTarget = mpPreparedPageWindow;
340 if(pPreparedTarget)
342 // if we have a prepared target, do not use a new SdrPageWindow since this
343 // works but is expensive. Just use a temporary PaintWindow
344 SdrPaintWindow aTemporaryPaintWindow(mrView, *pGivenTarget);
346 // Copy existing paint region to use the same as prepared in BeginDrawLayer
347 SdrPaintWindow& rExistingPaintWindow = pPreparedTarget->GetPaintWindow();
348 const Region& rExistingRegion = rExistingPaintWindow.GetRedrawRegion();
349 bool bUseRect(false);
350 if (!rRect.IsEmpty())
352 Region r(rExistingRegion);
353 r.Intersect(rRect);
354 // fdo#74435: FIXME: visibility check broken if empty
355 if (!r.IsEmpty())
356 bUseRect = true;
358 if (!bUseRect)
359 aTemporaryPaintWindow.SetRedrawRegion(rExistingRegion);
360 else
361 aTemporaryPaintWindow.SetRedrawRegion(Region(rRect));
363 // patch the ExistingPageWindow
364 pPreparedTarget->patchPaintWindow(aTemporaryPaintWindow);
366 // redraw the layer
367 pPreparedTarget->RedrawLayer(&nID, pRedirector);
369 // restore the ExistingPageWindow
370 pPreparedTarget->unpatchPaintWindow();
372 else
374 OSL_FAIL("SdrPageView::DrawLayer: Creating temporary SdrPageWindow (ObjectContact), this should never be needed (!)");
376 // None of the known OutputDevices is the target of this paint, use
377 // a temporary SdrPageWindow for this Redraw.
378 SdrPaintWindow aTemporaryPaintWindow(mrView, *pGivenTarget);
379 SdrPageWindow aTemporaryPageWindow(*((SdrPageView*)this), aTemporaryPaintWindow);
381 // #i72752#
382 // Copy existing paint region if other PageWindows exist, this was created by
383 // PrepareRedraw() from BeginDrawLayer(). Needs to be used e.g. when suddenly SW
384 // paints into an unknown device other than the view was created for (e.g. VirtualDevice)
385 if(PageWindowCount())
387 SdrPageWindow* pExistingPageWindow = GetPageWindow(0L);
388 SdrPaintWindow& rExistingPaintWindow = pExistingPageWindow->GetPaintWindow();
389 const Region& rExistingRegion = rExistingPaintWindow.GetRedrawRegion();
390 aTemporaryPaintWindow.SetRedrawRegion(rExistingRegion);
393 aTemporaryPageWindow.RedrawLayer(&nID, pRedirector);
397 else
399 // paint in all known windows
400 for(sal_uInt32 a(0L); a < PageWindowCount(); a++)
402 SdrPageWindow* pTarget = GetPageWindow(a);
403 pTarget->RedrawLayer(&nID, pRedirector);
409 void SdrPageView::SetDesignMode( bool _bDesignMode ) const
411 for ( sal_uInt32 i = 0L; i < PageWindowCount(); ++i )
413 const SdrPageWindow& rPageViewWindow = *GetPageWindow(i);
414 rPageViewWindow.SetDesignMode( _bDesignMode );
420 void SdrPageView::DrawPageViewGrid(OutputDevice& rOut, const Rectangle& rRect, Color aColor)
422 if (GetPage()==NULL)
423 return;
425 long nx1=GetView().aGridBig.Width();
426 long nx2=GetView().aGridFin.Width();
427 long ny1=GetView().aGridBig.Height();
428 long ny2=GetView().aGridFin.Height();
430 if (nx1==0) nx1=nx2;
431 if (nx2==0) nx2=nx1;
432 if (ny1==0) ny1=ny2;
433 if (ny2==0) ny2=ny1;
434 if (nx1==0) { nx1=ny1; nx2=ny2; }
435 if (ny1==0) { ny1=nx1; ny2=nx2; }
436 if (nx1<0) nx1=-nx1;
437 if (nx2<0) nx2=-nx2;
438 if (ny1<0) ny1=-ny1;
439 if (ny2<0) ny2=-ny2;
441 if (nx1!=0)
443 // no more global output size, use window size instead to decide grid sizes
444 long nScreenWdt = rOut.GetOutputSizePixel().Width();
446 long nMinDotPix=2;
447 long nMinLinPix=4;
449 if (nScreenWdt>=1600)
451 nMinDotPix=4;
452 nMinLinPix=8;
454 else if (nScreenWdt>=1024)
456 nMinDotPix=3;
457 nMinLinPix=6;
459 else
460 { // e. g. 640x480
461 nMinDotPix=2;
462 nMinLinPix=4;
464 Size aMinDotDist(rOut.PixelToLogic(Size(nMinDotPix,nMinDotPix)));
465 Size aMinLinDist(rOut.PixelToLogic(Size(nMinLinPix,nMinLinPix)));
466 bool bHoriSolid=nx2<aMinDotDist.Width();
467 bool bVertSolid=ny2<aMinDotDist.Height();
468 // enlarge line offset (minimum 4 pixels)
469 // enlarge by: *2 *5 *10 *20 *50 *100 ...
470 int nTgl=0;
471 long nVal0=nx1;
472 while (nx1<aMinLinDist.Width())
474 long a=nx1;
476 if (nTgl==0) nx1*=2;
477 if (nTgl==1) nx1=nVal0*5; // => nx1*=2.5
478 if (nTgl==2) nx1*=2;
480 nVal0=a;
481 nTgl++; if (nTgl>=3) nTgl=0;
483 nTgl=0;
484 nVal0=ny1;
485 while (ny1<aMinLinDist.Height())
487 long a=ny1;
489 if (nTgl==0) ny1*=2;
490 if (nTgl==1) ny1=nVal0*5; // => ny1*=2.5
491 if (nTgl==2) ny1*=2;
493 nVal0=a;
494 nTgl++;
496 if (nTgl>=3) nTgl=0;
499 bool bHoriFine=nx2<nx1;
500 bool bVertFine=ny2<ny1;
501 bool bHoriLines=bHoriSolid || bHoriFine || !bVertFine;
502 bool bVertLines=bVertSolid || bVertFine;
504 Color aColorMerk( rOut.GetLineColor() );
505 rOut.SetLineColor( aColor );
507 bool bMap0=rOut.IsMapModeEnabled();
509 long nWrX=0;
510 long nWrY=0;
511 Point aOrg(aPgOrg);
512 long x1=GetPage()->GetLftBorder()+1+nWrX;
513 long x2=GetPage()->GetWdt()-GetPage()->GetRgtBorder()-1+nWrY;
514 long y1=GetPage()->GetUppBorder()+1+nWrX;
515 long y2=GetPage()->GetHgt()-GetPage()->GetLwrBorder()-1+nWrY;
516 const SdrPageGridFrameList* pFrames=GetPage()->GetGridFrameList(this,NULL);
518 sal_uInt16 nGridPaintAnz=1;
519 if (pFrames!=NULL) nGridPaintAnz=pFrames->GetCount();
520 for (sal_uInt16 nGridPaintNum=0; nGridPaintNum<nGridPaintAnz; nGridPaintNum++) {
521 if (pFrames!=NULL) {
522 const SdrPageGridFrame& rGF=(*pFrames)[nGridPaintNum];
523 nWrX=rGF.GetPaperRect().Left();
524 nWrY=rGF.GetPaperRect().Top();
525 x1=rGF.GetUserArea().Left();
526 x2=rGF.GetUserArea().Right();
527 y1=rGF.GetUserArea().Top();
528 y2=rGF.GetUserArea().Bottom();
529 aOrg=rGF.GetUserArea().TopLeft();
530 aOrg-=rGF.GetPaperRect().TopLeft();
532 if (!rRect.IsEmpty()) {
533 Size a1PixSiz(rOut.PixelToLogic(Size(1,1)));
534 long nX1Pix=a1PixSiz.Width(); // add 1 pixel of tolerance
535 long nY1Pix=a1PixSiz.Height();
536 if (x1<rRect.Left() -nX1Pix) x1=rRect.Left() -nX1Pix;
537 if (x2>rRect.Right() +nX1Pix) x2=rRect.Right() +nX1Pix;
538 if (y1<rRect.Top() -nY1Pix) y1=rRect.Top() -nY1Pix;
539 if (y2>rRect.Bottom()+nY1Pix) y2=rRect.Bottom()+nY1Pix;
542 long xBigOrg=aOrg.X()+nWrX;
543 while (xBigOrg>=x1) xBigOrg-=nx1;
544 while (xBigOrg<x1) xBigOrg+=nx1;
545 long xFinOrg=xBigOrg;
546 while (xFinOrg>=x1) xFinOrg-=nx2;
547 while (xFinOrg<x1) xFinOrg+=nx2;
549 long yBigOrg=aOrg.Y()+nWrY;
550 while (yBigOrg>=y1) yBigOrg-=ny1;
551 while (yBigOrg<y1) yBigOrg+=ny1;
552 long yFinOrg=yBigOrg;
553 while (yFinOrg>=y1) yFinOrg-=ny2;
554 while (yFinOrg<y1) yFinOrg+=ny2;
556 if( x1 <= x2 && y1 <= y2 )
558 if( bHoriLines )
560 sal_uIntPtr nGridFlags = ( bHoriSolid ? GRID_HORZLINES : GRID_DOTS );
561 sal_uInt16 nSteps = sal_uInt16(nx1 / nx2);
562 sal_uInt32 nRestPerStepMul1000 = nSteps ? ( ((nx1 * 1000L)/ nSteps) - (nx2 * 1000L) ) : 0;
563 sal_uInt32 nStepOffset = 0;
564 sal_uInt16 nPointOffset = 0;
566 for(sal_uInt16 a=0;a<nSteps;a++)
568 // draw
569 rOut.DrawGrid(
570 Rectangle( xFinOrg + (a * nx2) + nPointOffset, yBigOrg, x2, y2 ),
571 Size( nx1, ny1 ), nGridFlags );
573 // do a step
574 nStepOffset += nRestPerStepMul1000;
575 while(nStepOffset >= 1000)
577 nStepOffset -= 1000;
578 nPointOffset++;
583 if( bVertLines )
585 sal_uIntPtr nGridFlags = ( bVertSolid ? GRID_VERTLINES : GRID_DOTS );
586 sal_uInt16 nSteps = sal_uInt16(ny1 / ny2);
587 sal_uInt32 nRestPerStepMul1000 = nSteps ? ( ((ny1 * 1000L)/ nSteps) - (ny2 * 1000L) ) : 0;
588 sal_uInt32 nStepOffset = 0;
589 sal_uInt16 nPointOffset = 0;
591 for(sal_uInt16 a=0;a<nSteps;a++)
593 // draw
594 rOut.DrawGrid(
595 Rectangle( xBigOrg, yFinOrg + (a * ny2) + nPointOffset, x2, y2 ),
596 Size( nx1, ny1 ), nGridFlags );
598 // do a step
599 nStepOffset += nRestPerStepMul1000;
600 while(nStepOffset >= 1000)
602 nStepOffset -= 1000;
603 nPointOffset++;
610 rOut.EnableMapMode(bMap0);
611 rOut.SetLineColor(aColorMerk);
615 void SdrPageView::AdjHdl()
617 GetView().AdjustMarkHdl();
620 void SdrPageView::SetLayer(const OUString& rName, SetOfByte& rBS, bool bJa)
622 if(!GetPage())
623 return;
625 SdrLayerID nID = GetPage()->GetLayerAdmin().GetLayerID(rName, true);
627 if(SDRLAYER_NOTFOUND != nID)
628 rBS.Set(nID, bJa);
631 bool SdrPageView::IsLayer(const OUString& rName, const SetOfByte& rBS) const
633 if(!GetPage())
634 return false;
636 bool bRet(false);
638 if (!rName.isEmpty())
640 SdrLayerID nId = GetPage()->GetLayerAdmin().GetLayerID(rName, true);
642 if(SDRLAYER_NOTFOUND != nId)
644 bRet = rBS.IsSet(nId);
648 return bRet;
651 bool SdrPageView::IsObjMarkable(SdrObject* pObj) const
653 if(pObj)
655 // excluded from selection?
656 if(pObj->IsMarkProtect())
658 return false;
661 // only visible are selectable
662 if( !pObj->IsVisible() )
664 return false;
667 if(pObj->ISA(SdrObjGroup))
669 // If object is a Group object, visibility may depend on
670 // multiple layers. If one object is markable, Group is markable.
671 SdrObjList* pObjList = ((SdrObjGroup*)pObj)->GetSubList();
673 if(pObjList && pObjList->GetObjCount())
675 bool bGroupIsMarkable(false);
677 for(sal_uInt32 a(0L); !bGroupIsMarkable && a < pObjList->GetObjCount(); a++)
679 SdrObject* pCandidate = pObjList->GetObj(a);
681 // call recursively
682 if(IsObjMarkable(pCandidate))
684 bGroupIsMarkable = true;
688 return bGroupIsMarkable;
690 else
692 // #i43302#
693 // Allow empty groups to be selected to be able to delete them
694 return true;
697 else
699 // the layer has to be visible and must not be locked
700 SdrLayerID nL = pObj->GetLayer();
701 return (aLayerVisi.IsSet(sal_uInt8(nL)) && !aLayerLock.IsSet(sal_uInt8(nL)));
705 return false;
708 void SdrPageView::SetPageOrigin(const Point& rOrg)
710 if (rOrg!=aPgOrg) {
711 aPgOrg=rOrg;
712 if (GetView().IsGridVisible()) {
713 InvalidateAllWin();
718 void SdrPageView::ImpInvalidateHelpLineArea(sal_uInt16 nNum) const
720 if (GetView().IsHlplVisible() && nNum<aHelpLines.GetCount()) {
721 const SdrHelpLine& rHL=aHelpLines[nNum];
723 for(sal_uInt32 a(0L); a < GetView().PaintWindowCount(); a++)
725 SdrPaintWindow* pCandidate = GetView().GetPaintWindow(a);
727 if(pCandidate->OutputToWindow())
729 OutputDevice& rOutDev = pCandidate->GetOutputDevice();
730 Rectangle aR(rHL.GetBoundRect(rOutDev));
731 Size aSiz(rOutDev.PixelToLogic(Size(1,1)));
732 aR.Left() -= aSiz.Width();
733 aR.Right() += aSiz.Width();
734 aR.Top() -= aSiz.Height();
735 aR.Bottom() += aSiz.Height();
736 ((SdrView&)GetView()).InvalidateOneWin((Window&)rOutDev, aR);
742 void SdrPageView::SetHelpLines(const SdrHelpLineList& rHLL)
744 aHelpLines=rHLL;
745 InvalidateAllWin();
748 void SdrPageView::SetHelpLine(sal_uInt16 nNum, const SdrHelpLine& rNewHelpLine)
750 if (nNum<aHelpLines.GetCount() && aHelpLines[nNum]!=rNewHelpLine) {
751 bool bNeedRedraw = true;
752 if (aHelpLines[nNum].GetKind()==rNewHelpLine.GetKind()) {
753 switch (rNewHelpLine.GetKind()) {
754 case SDRHELPLINE_VERTICAL : if (aHelpLines[nNum].GetPos().X()==rNewHelpLine.GetPos().X()) bNeedRedraw = false; break;
755 case SDRHELPLINE_HORIZONTAL: if (aHelpLines[nNum].GetPos().Y()==rNewHelpLine.GetPos().Y()) bNeedRedraw = false; break;
756 default: break;
757 } // switch
759 if (bNeedRedraw) ImpInvalidateHelpLineArea(nNum);
760 aHelpLines[nNum]=rNewHelpLine;
761 if (bNeedRedraw) ImpInvalidateHelpLineArea(nNum);
765 void SdrPageView::DeleteHelpLine(sal_uInt16 nNum)
767 if (nNum<aHelpLines.GetCount()) {
768 ImpInvalidateHelpLineArea(nNum);
769 aHelpLines.Delete(nNum);
773 void SdrPageView::InsertHelpLine(const SdrHelpLine& rHL, sal_uInt16 nNum)
775 if (nNum > aHelpLines.GetCount())
776 nNum = aHelpLines.GetCount();
777 aHelpLines.Insert(rHL,nNum);
778 if (GetView().IsHlplVisible())
779 ImpInvalidateHelpLineArea(nNum);
782 // set current group and list
783 void SdrPageView::SetAktGroupAndList(SdrObject* pNewGroup, SdrObjList* pNewList)
785 if(pAktGroup != pNewGroup)
787 pAktGroup = pNewGroup;
789 if(pAktList != pNewList)
791 pAktList = pNewList;
795 bool SdrPageView::EnterGroup(SdrObject* pObj)
797 bool bRet(false);
799 if(pObj && pObj->IsGroupObject())
801 bool bGlueInvalidate(GetView().ImpIsGlueVisible());
803 if(bGlueInvalidate)
805 GetView().GlueInvalidate();
808 // deselect all
809 GetView().UnmarkAll();
811 // set current group and list
812 SdrObjList* pNewObjList = pObj->GetSubList();
813 SetAktGroupAndList(pObj, pNewObjList);
815 // select contained object if only one object is contained,
816 // else select nothing and let the user decide what to do next
817 if(pNewObjList && pNewObjList->GetObjCount() == 1)
819 SdrObject* pFirstObject = pNewObjList->GetObj(0L);
821 if(GetView().GetSdrPageView())
823 GetView().MarkObj(pFirstObject, GetView().GetSdrPageView());
827 // build new handles
828 GetView().AdjustMarkHdl();
830 // invalidate only when view wants to visualize group entering
831 if(GetView().DoVisualizeEnteredGroup())
833 InvalidateAllWin();
836 if (bGlueInvalidate)
838 GetView().GlueInvalidate();
841 bRet = true;
844 return bRet;
847 void SdrPageView::LeaveOneGroup()
849 if(GetAktGroup())
851 bool bGlueInvalidate = (GetView().ImpIsGlueVisible());
853 if(bGlueInvalidate)
854 GetView().GlueInvalidate();
856 SdrObject* pLastGroup = GetAktGroup();
857 SdrObject* pParentGroup = GetAktGroup()->GetUpGroup();
858 SdrObjList* pParentList = GetPage();
860 if(pParentGroup)
861 pParentList = pParentGroup->GetSubList();
863 // deselect everything
864 GetView().UnmarkAll();
866 // allocations, pAktGroup and pAktList need to be set
867 SetAktGroupAndList(pParentGroup, pParentList);
869 // select the group we just left
870 if(pLastGroup)
871 if(GetView().GetSdrPageView())
872 GetView().MarkObj(pLastGroup, GetView().GetSdrPageView());
874 GetView().AdjustMarkHdl();
876 // invalidate only if view wants to visualize group entering
877 if(GetView().DoVisualizeEnteredGroup())
878 InvalidateAllWin();
880 if(bGlueInvalidate)
881 GetView().GlueInvalidate();
885 void SdrPageView::LeaveAllGroup()
887 if(GetAktGroup())
889 bool bGlueInvalidate = (GetView().ImpIsGlueVisible());
891 if(bGlueInvalidate)
892 GetView().GlueInvalidate();
894 SdrObject* pLastGroup = GetAktGroup();
896 // deselect everything
897 GetView().UnmarkAll();
899 // allocations, pAktGroup and pAktList always need to be set
900 SetAktGroupAndList(NULL, GetPage());
902 // find and select uppermost group
903 if(pLastGroup)
905 while(pLastGroup->GetUpGroup())
906 pLastGroup = pLastGroup->GetUpGroup();
908 if(GetView().GetSdrPageView())
909 GetView().MarkObj(pLastGroup, GetView().GetSdrPageView());
912 GetView().AdjustMarkHdl();
914 // invalidate only when view wants to visualize group entering
915 if(GetView().DoVisualizeEnteredGroup())
916 InvalidateAllWin();
918 if(bGlueInvalidate)
919 GetView().GlueInvalidate();
923 sal_uInt16 SdrPageView::GetEnteredLevel() const
925 sal_uInt16 nAnz=0;
926 SdrObject* pGrp=GetAktGroup();
927 while (pGrp!=NULL) {
928 nAnz++;
929 pGrp=pGrp->GetUpGroup();
931 return nAnz;
934 void SdrPageView::CheckAktGroup()
936 SdrObject* pGrp=GetAktGroup();
937 while (pGrp!=NULL &&
938 (!pGrp->IsInserted() || pGrp->GetObjList()==NULL ||
939 pGrp->GetPage()==NULL || pGrp->GetModel()==NULL)) { // anything outside of the borders?
940 pGrp=pGrp->GetUpGroup();
942 if (pGrp!=GetAktGroup()) {
943 if (pGrp!=NULL) EnterGroup(pGrp);
944 else LeaveAllGroup();
948 // Set background color for svx at SdrPageViews
949 void SdrPageView::SetApplicationBackgroundColor(Color aBackgroundColor)
951 maBackgroundColor = aBackgroundColor;
954 Color SdrPageView::GetApplicationBackgroundColor() const
956 return maBackgroundColor;
959 // Set document color for svx at SdrPageViews
960 void SdrPageView::SetApplicationDocumentColor(Color aDocumentColor)
962 maDocumentColor = aDocumentColor;
965 Color SdrPageView::GetApplicationDocumentColor() const
967 return maDocumentColor;
971 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */