1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
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
)
67 const SdrPageWindow
* SdrPageView::FindPatchedPageWindow( const OutputDevice
& _rOutDev
) const
69 for ( SdrPageWindowVector::const_iterator loop
= maPageWindows
.begin();
70 loop
!= maPageWindows
.end();
74 const SdrPageWindow
& rPageWindow( *(*loop
) );
75 const SdrPaintWindow
& rPaintWindow( rPageWindow
.GetOriginalPaintWindow() ? *rPageWindow
.GetOriginalPaintWindow() : rPageWindow
.GetPaintWindow() );
76 if ( &rPaintWindow
.GetOutputDevice() == &_rOutDev
)
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
)
98 SdrPageWindow
* SdrPageView::GetPageWindow(sal_uInt32 nIndex
) const
100 if(nIndex
< maPageWindows
.size())
102 return maPageWindows
[nIndex
];
108 void SdrPageView::ClearPageWindows()
110 for(SdrPageWindowVector::const_iterator a
= maPageWindows
.begin(); a
!= maPageWindows
.end(); ++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
;
140 SdrPageView::SdrPageView(SdrPage
* pPage1
, SdrView
& 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#
151 aPgOrg
.X()=mpPage
->GetLftBorder();
152 aPgOrg
.Y()=mpPage
->GetUppBorder();
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
176 SdrPageWindow
& SdrPageView::CreateNewPageWindowEntry(SdrPaintWindow
& rPaintWindow
)
178 SdrPageWindow
& rWindow
= *(new SdrPageWindow(*this, rPaintWindow
));
179 AppendPageWindow(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
);
198 pCandidate
= RemovePageWindow(*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
);
213 xReturn
= pCandidate
->GetControlContainer( true );
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()
235 for(sal_uInt32
a(0L); a
< GetView().PaintWindowCount(); a
++)
237 AddPaintWindowToPageView(*GetView().GetPaintWindow(a
));
242 void SdrPageView::Hide()
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
);
280 pCandidate
->PrePaint();
285 void SdrPageView::CompleteRedraw(SdrPaintWindow
& rPaintWindow
, const Region
& rReg
, sdr::contact::ViewObjectContactRedirector
* pRedirector
) const
289 SdrPageWindow
* pPageWindow
= FindPageWindow(rPaintWindow
);
290 bool bIsTempTarget(false);
294 // create temp PageWindow
295 pPageWindow
= new SdrPageWindow(*((SdrPageView
*)this), rPaintWindow
);
296 bIsTempTarget
= true;
300 pPageWindow
->PrepareRedraw(rReg
);
301 pPageWindow
->RedrawAll(pRedirector
);
303 // get rid of temp PageWindow
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
327 const SdrPageWindow
* pKnownTarget
= FindPageWindow(*pGivenTarget
);
331 // paint known target
332 pKnownTarget
->RedrawLayer(&nID
, pRedirector
);
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
;
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
);
354 // fdo#74435: FIXME: visibility check broken if empty
359 aTemporaryPaintWindow
.SetRedrawRegion(rExistingRegion
);
361 aTemporaryPaintWindow
.SetRedrawRegion(Region(rRect
));
363 // patch the ExistingPageWindow
364 pPreparedTarget
->patchPaintWindow(aTemporaryPaintWindow
);
367 pPreparedTarget
->RedrawLayer(&nID
, pRedirector
);
369 // restore the ExistingPageWindow
370 pPreparedTarget
->unpatchPaintWindow();
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
);
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
);
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
)
425 long nx1
=GetView().aGridBig
.Width();
426 long nx2
=GetView().aGridFin
.Width();
427 long ny1
=GetView().aGridBig
.Height();
428 long ny2
=GetView().aGridFin
.Height();
434 if (nx1
==0) { nx1
=ny1
; nx2
=ny2
; }
435 if (ny1
==0) { ny1
=nx1
; ny2
=nx2
; }
443 // no more global output size, use window size instead to decide grid sizes
444 long nScreenWdt
= rOut
.GetOutputSizePixel().Width();
449 if (nScreenWdt
>=1600)
454 else if (nScreenWdt
>=1024)
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 ...
472 while (nx1
<aMinLinDist
.Width())
477 if (nTgl
==1) nx1
=nVal0
*5; // => nx1*=2.5
481 nTgl
++; if (nTgl
>=3) nTgl
=0;
485 while (ny1
<aMinLinDist
.Height())
490 if (nTgl
==1) ny1
=nVal0
*5; // => ny1*=2.5
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();
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
++) {
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
)
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
++)
570 Rectangle( xFinOrg
+ (a
* nx2
) + nPointOffset
, yBigOrg
, x2
, y2
),
571 Size( nx1
, ny1
), nGridFlags
);
574 nStepOffset
+= nRestPerStepMul1000
;
575 while(nStepOffset
>= 1000)
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
++)
595 Rectangle( xBigOrg
, yFinOrg
+ (a
* ny2
) + nPointOffset
, x2
, y2
),
596 Size( nx1
, ny1
), nGridFlags
);
599 nStepOffset
+= nRestPerStepMul1000
;
600 while(nStepOffset
>= 1000)
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
)
625 SdrLayerID nID
= GetPage()->GetLayerAdmin().GetLayerID(rName
, true);
627 if(SDRLAYER_NOTFOUND
!= nID
)
631 bool SdrPageView::IsLayer(const OUString
& rName
, const SetOfByte
& rBS
) const
638 if (!rName
.isEmpty())
640 SdrLayerID nId
= GetPage()->GetLayerAdmin().GetLayerID(rName
, true);
642 if(SDRLAYER_NOTFOUND
!= nId
)
644 bRet
= rBS
.IsSet(nId
);
651 bool SdrPageView::IsObjMarkable(SdrObject
* pObj
) const
655 // excluded from selection?
656 if(pObj
->IsMarkProtect())
661 // only visible are selectable
662 if( !pObj
->IsVisible() )
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
);
682 if(IsObjMarkable(pCandidate
))
684 bGroupIsMarkable
= true;
688 return bGroupIsMarkable
;
693 // Allow empty groups to be selected to be able to delete them
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
)));
708 void SdrPageView::SetPageOrigin(const Point
& rOrg
)
712 if (GetView().IsGridVisible()) {
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
)
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;
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
)
795 bool SdrPageView::EnterGroup(SdrObject
* pObj
)
799 if(pObj
&& pObj
->IsGroupObject())
801 bool bGlueInvalidate(GetView().ImpIsGlueVisible());
805 GetView().GlueInvalidate();
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());
828 GetView().AdjustMarkHdl();
830 // invalidate only when view wants to visualize group entering
831 if(GetView().DoVisualizeEnteredGroup())
838 GetView().GlueInvalidate();
847 void SdrPageView::LeaveOneGroup()
851 bool bGlueInvalidate
= (GetView().ImpIsGlueVisible());
854 GetView().GlueInvalidate();
856 SdrObject
* pLastGroup
= GetAktGroup();
857 SdrObject
* pParentGroup
= GetAktGroup()->GetUpGroup();
858 SdrObjList
* pParentList
= GetPage();
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
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())
881 GetView().GlueInvalidate();
885 void SdrPageView::LeaveAllGroup()
889 bool bGlueInvalidate
= (GetView().ImpIsGlueVisible());
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
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())
919 GetView().GlueInvalidate();
923 sal_uInt16
SdrPageView::GetEnteredLevel() const
926 SdrObject
* pGrp
=GetAktGroup();
929 pGrp
=pGrp
->GetUpGroup();
934 void SdrPageView::CheckAktGroup()
936 SdrObject
* pGrp
=GetAktGroup();
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: */