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 <svx/svdpage.hxx>
22 #include <svx/svdview.hxx>
24 #include <svx/svdobj.hxx>
25 #include <svx/svdogrp.hxx>
26 #include <svx/svdtypes.hxx>
28 #include <svx/sdr/contact/viewobjectcontactredirector.hxx>
32 #include <svx/sdrpagewindow.hxx>
33 #include <svx/sdrpaintwindow.hxx>
34 #include <comphelper/lok.hxx>
35 #include <comphelper/scopeguard.hxx>
36 #include <basegfx/range/b2irectangle.hxx>
37 #include <osl/diagnose.h>
39 using namespace ::com::sun::star
;
41 // interface to SdrPageWindow
43 SdrPageWindow
* SdrPageView::FindPageWindow(const SdrPaintWindow
& rPaintWindow
) const
45 for(auto & a
: maPageWindows
)
47 if(&(a
->GetPaintWindow()) == &rPaintWindow
)
56 const SdrPageWindow
* SdrPageView::FindPatchedPageWindow( const OutputDevice
& _rOutDev
) const
58 for ( auto const & pPageWindow
: maPageWindows
)
60 const SdrPaintWindow
& rPaintWindow( pPageWindow
->GetOriginalPaintWindow() ? *pPageWindow
->GetOriginalPaintWindow() : pPageWindow
->GetPaintWindow() );
61 if ( &rPaintWindow
.GetOutputDevice() == &_rOutDev
)
63 return pPageWindow
.get();
70 SdrPageWindow
* SdrPageView::FindPageWindow(const OutputDevice
& rOutDev
) const
72 for ( auto const & pPageWindow
: maPageWindows
)
74 if(&(pPageWindow
->GetPaintWindow().GetOutputDevice()) == &rOutDev
)
76 return pPageWindow
.get();
83 SdrPageWindow
* SdrPageView::GetPageWindow(sal_uInt32 nIndex
) const
85 return maPageWindows
[nIndex
].get();
88 SdrPageView::SdrPageView(SdrPage
* pPage1
, SdrView
& rNewView
)
90 // col_auto color lets the view takes the default SvxColorConfig entry
91 maDocumentColor( COL_AUTO
),
92 maBackgroundColor( COL_AUTO
), // #i48367# also react on autocolor
93 mpPreparedPageWindow(nullptr) // #i72752#
99 maPageOrigin
.setX(mpPage
->GetLeftBorder() );
100 maPageOrigin
.setY(mpPage
->GetUpperBorder() );
102 // For example, in the case of charts, there is a LayerAdmin, but it has no valid values. Therefore
103 // a solution like pLayerAdmin->getVisibleLayersODF(aLayerVisi) is not possible. So use the
104 // generic SetAll() for now.
110 pCurrentList
= nullptr;
111 pCurrentGroup
= nullptr;
112 SetCurrentGroupAndList(nullptr, mpPage
);
114 for(sal_uInt32
a(0); a
< rNewView
.PaintWindowCount(); a
++)
116 AddPaintWindowToPageView(*rNewView
.GetPaintWindow(a
));
120 SdrPageView::~SdrPageView()
124 void SdrPageView::AddPaintWindowToPageView(SdrPaintWindow
& rPaintWindow
)
126 if(!FindPageWindow(rPaintWindow
))
128 maPageWindows
.emplace_back(new SdrPageWindow(*this, rPaintWindow
));
132 void SdrPageView::RemovePaintWindowFromPageView(SdrPaintWindow
& rPaintWindow
)
134 auto it
= std::find_if(maPageWindows
.begin(), maPageWindows
.end(),
135 [&rPaintWindow
](const std::unique_ptr
<SdrPageWindow
>& rpWindow
) {
136 return &(rpWindow
->GetPaintWindow()) == &rPaintWindow
;
138 if (it
!= maPageWindows
.end())
139 maPageWindows
.erase(it
);
142 css::uno::Reference
< css::awt::XControlContainer
> SdrPageView::GetControlContainer( const OutputDevice
& _rDevice
) const
144 css::uno::Reference
< css::awt::XControlContainer
> xReturn
;
145 const SdrPageWindow
* pCandidate
= FindPatchedPageWindow( _rDevice
);
148 xReturn
= pCandidate
->GetControlContainer();
153 void SdrPageView::ModelHasChanged()
155 if (GetCurrentGroup()!=nullptr) CheckCurrentGroup();
158 bool SdrPageView::IsReadOnly() const
160 return (nullptr == GetPage() || GetView().GetModel().IsReadOnly() || GetPage()->IsReadOnly() || GetObjList()->IsReadOnly());
163 void SdrPageView::Show()
169 for(sal_uInt32
a(0); a
< GetView().PaintWindowCount(); a
++)
171 AddPaintWindowToPageView(*GetView().GetPaintWindow(a
));
176 void SdrPageView::Hide()
180 if (!comphelper::LibreOfficeKit::isActive())
185 maPageWindows
.clear();
189 tools::Rectangle
SdrPageView::GetPageRect() const
191 if (GetPage()==nullptr) return tools::Rectangle();
192 return tools::Rectangle(Point(),Size(GetPage()->GetWidth()+1,GetPage()->GetHeight()+1));
195 void SdrPageView::InvalidateAllWin()
197 if(IsVisible() && GetPage())
199 tools::Rectangle
aRect(Point(0,0),Size(GetPage()->GetWidth()+1,GetPage()->GetHeight()+1));
200 aRect
.Union(GetPage()->GetAllObjBoundRect());
201 GetView().InvalidateAllWin(aRect
);
206 void SdrPageView::PrePaint()
208 const sal_uInt32
nCount(PageWindowCount());
210 for(sal_uInt32
a(0); a
< nCount
; a
++)
212 SdrPageWindow
* pCandidate
= GetPageWindow(a
);
216 pCandidate
->PrePaint();
221 void SdrPageView::CompleteRedraw(
222 SdrPaintWindow
& rPaintWindow
, const vcl::Region
& rReg
, sdr::contact::ViewObjectContactRedirector
* pRedirector
)
227 SdrPageWindow
* pPageWindow
= FindPageWindow(rPaintWindow
);
228 std::unique_ptr
<SdrPageWindow
> pTempPageWindow
;
232 // create temp PageWindow
233 pTempPageWindow
.reset(new SdrPageWindow(*this, rPaintWindow
));
234 pPageWindow
= pTempPageWindow
.get();
238 pPageWindow
->PrepareRedraw(rReg
);
239 pPageWindow
->RedrawAll(pRedirector
);
243 // #i74769# use SdrPaintWindow directly
245 void SdrPageView::setPreparedPageWindow(SdrPageWindow
* pKnownTarget
)
247 // #i72752# remember prepared SdrPageWindow
248 mpPreparedPageWindow
= pKnownTarget
;
251 void SdrPageView::DrawLayer(SdrLayerID nID
, OutputDevice
* pGivenTarget
,
252 sdr::contact::ViewObjectContactRedirector
* pRedirector
,
253 const tools::Rectangle
& rRect
, basegfx::B2IRectangle
const*const pPageFrame
)
260 SdrPageWindow
* pKnownTarget
= FindPageWindow(*pGivenTarget
);
264 // paint known target
265 pKnownTarget
->RedrawLayer(&nID
, pRedirector
, pPageFrame
);
269 // #i72752# DrawLayer() uses an OutputDevice different from BeginDrawLayer. This happens
270 // e.g. when SW paints a single text line in text edit mode. Try to use it
271 SdrPageWindow
* pPreparedTarget
= mpPreparedPageWindow
;
275 // if we have a prepared target, do not use a new SdrPageWindow since this
276 // works but is expensive. Just use a temporary PaintWindow
277 SdrPaintWindow
aTemporaryPaintWindow(mrView
, *pGivenTarget
);
279 // Copy existing paint region to use the same as prepared in BeginDrawLayer
280 SdrPaintWindow
& rExistingPaintWindow
= pPreparedTarget
->GetPaintWindow();
281 const vcl::Region
& rExistingRegion
= rExistingPaintWindow
.GetRedrawRegion();
282 bool bUseRect(false);
283 if (!rRect
.IsEmpty())
285 vcl::Region
r(rExistingRegion
);
287 // fdo#74435: FIXME: visibility check broken if empty
292 aTemporaryPaintWindow
.SetRedrawRegion(rExistingRegion
);
294 aTemporaryPaintWindow
.SetRedrawRegion(vcl::Region(rRect
));
296 // patch the ExistingPageWindow
297 auto pPreviousWindow
= pPreparedTarget
->patchPaintWindow(aTemporaryPaintWindow
);
298 // unpatch window when leaving the scope
299 const ::comphelper::ScopeGuard
aGuard(
300 [&pPreviousWindow
, &pPreparedTarget
]() { pPreparedTarget
->unpatchPaintWindow(pPreviousWindow
); } );
302 pPreparedTarget
->RedrawLayer(&nID
, pRedirector
, pPageFrame
);
306 OSL_FAIL("SdrPageView::DrawLayer: Creating temporary SdrPageWindow (ObjectContact), this should never be needed (!)");
308 // None of the known OutputDevices is the target of this paint, use
309 // a temporary SdrPageWindow for this Redraw.
310 SdrPaintWindow
aTemporaryPaintWindow(mrView
, *pGivenTarget
);
311 SdrPageWindow
aTemporaryPageWindow(*this, aTemporaryPaintWindow
);
314 // Copy existing paint region if other PageWindows exist, this was created by
315 // PrepareRedraw() from BeginDrawLayer(). Needs to be used e.g. when suddenly SW
316 // paints into an unknown device other than the view was created for (e.g. VirtualDevice)
317 if(PageWindowCount())
319 SdrPageWindow
* pExistingPageWindow
= GetPageWindow(0);
320 SdrPaintWindow
& rExistingPaintWindow
= pExistingPageWindow
->GetPaintWindow();
321 const vcl::Region
& rExistingRegion
= rExistingPaintWindow
.GetRedrawRegion();
322 aTemporaryPaintWindow
.SetRedrawRegion(rExistingRegion
);
325 aTemporaryPageWindow
.RedrawLayer(&nID
, pRedirector
, nullptr);
331 // paint in all known windows
332 for(sal_uInt32
a(0); a
< PageWindowCount(); a
++)
334 SdrPageWindow
* pTarget
= GetPageWindow(a
);
335 pTarget
->RedrawLayer(&nID
, pRedirector
, nullptr);
340 void SdrPageView::SetDesignMode( bool _bDesignMode
) const
342 for ( sal_uInt32 i
= 0; i
< PageWindowCount(); ++i
)
344 const SdrPageWindow
& rPageViewWindow
= *GetPageWindow(i
);
345 rPageViewWindow
.SetDesignMode( _bDesignMode
);
350 void SdrPageView::DrawPageViewGrid(OutputDevice
& rOut
, const tools::Rectangle
& rRect
, Color aColor
)
352 if (GetPage()==nullptr)
355 tools::Long nx1
=GetView().maGridBig
.Width();
356 tools::Long nx2
=GetView().maGridFin
.Width();
357 tools::Long ny1
=GetView().maGridBig
.Height();
358 tools::Long ny2
=GetView().maGridFin
.Height();
364 if (nx1
==0) { nx1
=ny1
; nx2
=ny2
; }
365 if (ny1
==0) { ny1
=nx1
; ny2
=nx2
; }
374 // no more global output size, use window size instead to decide grid sizes
375 tools::Long nScreenWdt
= rOut
.GetOutputSizePixel().Width();
377 tools::Long nMinDotPix
=2;
378 tools::Long nMinLinPix
=4;
380 if (nScreenWdt
>=1600)
385 else if (nScreenWdt
>=1024)
395 Size
aMinDotDist(rOut
.PixelToLogic(Size(nMinDotPix
,nMinDotPix
)));
396 Size
aMinLinDist(rOut
.PixelToLogic(Size(nMinLinPix
,nMinLinPix
)));
397 bool bHoriSolid
=nx2
<aMinDotDist
.Width();
398 bool bVertSolid
=ny2
<aMinDotDist
.Height();
399 // enlarge line offset (minimum 4 pixels)
400 // enlarge by: *2 *5 *10 *20 *50 *100 ...
402 tools::Long nVal0
=nx1
;
403 while (nx1
<aMinLinDist
.Width())
408 if (nTgl
==1) nx1
=nVal0
*5; // => nx1*=2.5
412 nTgl
++; if (nTgl
>=3) nTgl
=0;
416 while (ny1
<aMinLinDist
.Height())
421 if (nTgl
==1) ny1
=nVal0
*5; // => ny1*=2.5
430 bool bHoriFine
=nx2
<nx1
;
431 bool bVertFine
=ny2
<ny1
;
432 bool bHoriLines
=bHoriSolid
|| bHoriFine
|| !bVertFine
;
433 bool bVertLines
=bVertSolid
|| bVertFine
;
435 Color
aOriginalLineColor( rOut
.GetLineColor() );
436 rOut
.SetLineColor( aColor
);
438 bool bMap0
=rOut
.IsMapModeEnabled();
442 Point
aOrg(maPageOrigin
);
445 if (GetPage()->GetWidth() < 0) // ScDrawPage of RTL sheet
447 x1
= GetPage()->GetWidth() + GetPage()->GetLeftBorder() + 1;
448 x2
= - GetPage()->GetRightBorder() - 1;
452 x1
= GetPage()->GetLeftBorder() + 1;
453 x2
= GetPage()->GetWidth() - GetPage()->GetRightBorder() - 1;
455 tools::Long y1
= GetPage()->GetUpperBorder() + 1;
456 tools::Long y2
= GetPage()->GetHeight() - GetPage()->GetLowerBorder() - 1;
457 const SdrPageGridFrameList
* pFrames
=GetPage()->GetGridFrameList(this,nullptr);
459 sal_uInt16 nGridPaintCnt
=1;
460 if (pFrames
!=nullptr) nGridPaintCnt
=pFrames
->GetCount();
461 for (sal_uInt16 nGridPaintNum
=0; nGridPaintNum
<nGridPaintCnt
; nGridPaintNum
++) {
462 if (pFrames
!=nullptr) {
463 const SdrPageGridFrame
& rGF
=(*pFrames
)[nGridPaintNum
];
464 nWrX
=rGF
.GetPaperRect().Left();
465 nWrY
=rGF
.GetPaperRect().Top();
466 x1
=rGF
.GetUserArea().Left();
467 x2
=rGF
.GetUserArea().Right();
468 y1
=rGF
.GetUserArea().Top();
469 y2
=rGF
.GetUserArea().Bottom();
470 aOrg
=rGF
.GetUserArea().TopLeft();
471 aOrg
-=rGF
.GetPaperRect().TopLeft();
473 if (!rRect
.IsEmpty()) {
474 Size
a1PixSiz(rOut
.PixelToLogic(Size(1,1)));
475 tools::Long nX1Pix
=a1PixSiz
.Width(); // add 1 pixel of tolerance
476 tools::Long nY1Pix
=a1PixSiz
.Height();
477 if (x1
<rRect
.Left() -nX1Pix
) x1
=rRect
.Left() -nX1Pix
;
478 if (x2
>rRect
.Right() +nX1Pix
) x2
=rRect
.Right() +nX1Pix
;
479 if (y1
<rRect
.Top() -nY1Pix
) y1
=rRect
.Top() -nY1Pix
;
480 if (y2
>rRect
.Bottom()+nY1Pix
) y2
=rRect
.Bottom()+nY1Pix
;
483 tools::Long xBigOrg
=aOrg
.X()+nWrX
;
484 while (xBigOrg
>=x1
) xBigOrg
-=nx1
;
485 while (xBigOrg
<x1
) xBigOrg
+=nx1
;
486 tools::Long xFinOrg
=xBigOrg
;
487 while (xFinOrg
>=x1
) xFinOrg
-=nx2
;
488 while (xFinOrg
<x1
) xFinOrg
+=nx2
;
490 tools::Long yBigOrg
=aOrg
.Y()+nWrY
;
491 while (yBigOrg
>=y1
) yBigOrg
-=ny1
;
492 while (yBigOrg
<y1
) yBigOrg
+=ny1
;
493 tools::Long yFinOrg
=yBigOrg
;
494 while (yFinOrg
>=y1
) yFinOrg
-=ny2
;
495 while (yFinOrg
<y1
) yFinOrg
+=ny2
;
497 if( x1
<= x2
&& y1
<= y2
)
501 DrawGridFlags nGridFlags
= ( bHoriSolid
? DrawGridFlags::HorzLines
: DrawGridFlags::Dots
);
502 sal_uInt16 nSteps
= sal_uInt16(nx1
/ nx2
);
503 sal_uInt32 nRestPerStepMul1000
= nSteps
? ( ((nx1
* 1000)/ nSteps
) - (nx2
* 1000) ) : 0;
504 sal_uInt32 nStepOffset
= 0;
505 sal_uInt16 nPointOffset
= 0;
507 for(sal_uInt16 a
=0;a
<nSteps
;a
++)
511 tools::Rectangle( xFinOrg
+ (a
* nx2
) + nPointOffset
, yBigOrg
, x2
, y2
),
512 Size( nx1
, ny1
), nGridFlags
);
515 nStepOffset
+= nRestPerStepMul1000
;
516 while(nStepOffset
>= 1000)
526 DrawGridFlags nGridFlags
= ( bVertSolid
? DrawGridFlags::VertLines
: DrawGridFlags::Dots
);
527 sal_uInt16 nSteps
= sal_uInt16(ny1
/ ny2
);
528 sal_uInt32 nRestPerStepMul1000
= nSteps
? ( ((ny1
* 1000L)/ nSteps
) - (ny2
* 1000L) ) : 0;
529 sal_uInt32 nStepOffset
= 0;
530 sal_uInt16 nPointOffset
= 0;
532 for(sal_uInt16 a
=0;a
<nSteps
;a
++)
536 tools::Rectangle( xBigOrg
, yFinOrg
+ (a
* ny2
) + nPointOffset
, x2
, y2
),
537 Size( nx1
, ny1
), nGridFlags
);
540 nStepOffset
+= nRestPerStepMul1000
;
541 while(nStepOffset
>= 1000)
551 rOut
.EnableMapMode(bMap0
);
552 rOut
.SetLineColor(aOriginalLineColor
);
555 void SdrPageView::AdjHdl()
557 GetView().AdjustMarkHdl();
560 void SdrPageView::SetLayer(const OUString
& rName
, SdrLayerIDSet
& rBS
, bool bJa
)
565 SdrLayerID nID
= GetPage()->GetLayerAdmin().GetLayerID(rName
);
567 if(SDRLAYER_NOTFOUND
!= nID
)
571 bool SdrPageView::IsLayer(const OUString
& rName
, const SdrLayerIDSet
& rBS
) const
578 if (!rName
.isEmpty())
580 SdrLayerID nId
= GetPage()->GetLayerAdmin().GetLayerID(rName
);
582 if(SDRLAYER_NOTFOUND
!= nId
)
584 bRet
= rBS
.IsSet(nId
);
591 bool SdrPageView::IsObjMarkable(SdrObject
const * pObj
) const
595 if (pObj
->IsMarkProtect())
596 return false; // excluded from selection?
597 if (!pObj
->IsVisible())
598 return false; // only visible are selectable
599 if (!pObj
->IsInserted())
600 return false; // Obj deleted?
601 if (auto pObjGroup
= dynamic_cast<const SdrObjGroup
*>(pObj
))
603 // If object is a Group object, visibility may depend on
604 // multiple layers. If one object is markable, Group is markable.
605 SdrObjList
* pObjList
= pObjGroup
->GetSubList();
607 if (pObjList
&& pObjList
->GetObjCount())
609 for (size_t a
= 0; a
< pObjList
->GetObjCount(); ++a
)
611 SdrObject
* pCandidate
= pObjList
->GetObj(a
);
613 if (IsObjMarkable(pCandidate
))
621 // Allow empty groups to be selected to be able to delete them
625 if (!pObj
->Is3DObj() && pObj
->getSdrPageFromSdrObject() != GetPage())
627 // Obj suddenly in different Page
631 // the layer has to be visible and must not be locked
632 SdrLayerID nL
= pObj
->GetLayer();
633 if (!aLayerVisi
.IsSet(nL
))
635 if (aLayerLock
.IsSet(nL
))
640 void SdrPageView::SetPageOrigin(const Point
& rOrg
)
642 if (rOrg
!= maPageOrigin
)
645 if (GetView().IsGridVisible())
652 void SdrPageView::ImpInvalidateHelpLineArea(sal_uInt16 nNum
) const
654 if (!(GetView().IsHlplVisible() && nNum
<aHelpLines
.GetCount())) return;
656 const SdrHelpLine
& rHL
=aHelpLines
[nNum
];
658 for(sal_uInt32
a(0); a
< GetView().PaintWindowCount(); a
++)
660 SdrPaintWindow
* pCandidate
= GetView().GetPaintWindow(a
);
662 if(pCandidate
->OutputToWindow())
664 OutputDevice
& rOutDev
= pCandidate
->GetOutputDevice();
665 tools::Rectangle
aR(rHL
.GetBoundRect(rOutDev
));
666 Size
aSiz(rOutDev
.PixelToLogic(Size(1,1)));
667 aR
.AdjustLeft( -(aSiz
.Width()) );
668 aR
.AdjustRight(aSiz
.Width() );
669 aR
.AdjustTop( -(aSiz
.Height()) );
670 aR
.AdjustBottom(aSiz
.Height() );
671 const_cast<SdrView
&>(GetView()).InvalidateOneWin(rOutDev
, aR
);
676 void SdrPageView::SetHelpLines(const SdrHelpLineList
& rHLL
)
682 void SdrPageView::SetHelpLine(sal_uInt16 nNum
, const SdrHelpLine
& rNewHelpLine
)
684 if (nNum
>= aHelpLines
.GetCount() || aHelpLines
[nNum
] == rNewHelpLine
)
687 bool bNeedRedraw
= true;
688 if (aHelpLines
[nNum
].GetKind()==rNewHelpLine
.GetKind()) {
689 switch (rNewHelpLine
.GetKind()) {
690 case SdrHelpLineKind::Vertical
: if (aHelpLines
[nNum
].GetPos().X()==rNewHelpLine
.GetPos().X()) bNeedRedraw
= false; break;
691 case SdrHelpLineKind::Horizontal
: if (aHelpLines
[nNum
].GetPos().Y()==rNewHelpLine
.GetPos().Y()) bNeedRedraw
= false; break;
695 if (bNeedRedraw
) ImpInvalidateHelpLineArea(nNum
);
696 aHelpLines
[nNum
]=rNewHelpLine
;
697 if (bNeedRedraw
) ImpInvalidateHelpLineArea(nNum
);
700 void SdrPageView::DeleteHelpLine(sal_uInt16 nNum
)
702 if (nNum
<aHelpLines
.GetCount()) {
703 ImpInvalidateHelpLineArea(nNum
);
704 aHelpLines
.Delete(nNum
);
708 void SdrPageView::InsertHelpLine(const SdrHelpLine
& rHL
)
710 sal_uInt16 nNum
= aHelpLines
.GetCount();
711 aHelpLines
.Insert(rHL
,nNum
);
712 if (GetView().IsHlplVisible())
713 ImpInvalidateHelpLineArea(nNum
);
716 // set current group and list
717 void SdrPageView::SetCurrentGroupAndList(SdrObject
* pNewGroup
, SdrObjList
* pNewList
)
719 if(pCurrentGroup
!= pNewGroup
)
721 pCurrentGroup
= pNewGroup
;
723 if(pCurrentList
!= pNewList
)
725 pCurrentList
= pNewList
;
729 bool SdrPageView::EnterGroup(SdrObject
* pObj
)
731 if(!pObj
|| !pObj
->IsGroupObject())
734 // Don't allow enter Diagrams
735 if(nullptr != pObj
&& pObj
->isDiagram())
738 const bool bGlueInvalidate(GetView().ImpIsGlueVisible());
742 GetView().GlueInvalidate();
746 GetView().UnmarkAll();
748 // set current group and list
749 SdrObjList
* pNewObjList
= pObj
->GetSubList();
750 SetCurrentGroupAndList(pObj
, pNewObjList
);
752 // select contained object if only one object is contained,
753 // else select nothing and let the user decide what to do next
754 if(pNewObjList
&& pNewObjList
->GetObjCount() == 1)
756 SdrObject
* pFirstObject
= pNewObjList
->GetObj(0);
758 if(GetView().GetSdrPageView())
760 GetView().MarkObj(pFirstObject
, GetView().GetSdrPageView());
765 GetView().AdjustMarkHdl();
767 // invalidate only when view wants to visualize group entering
772 GetView().GlueInvalidate();
778 void SdrPageView::LeaveOneGroup()
780 SdrObject
* pLastGroup
= GetCurrentGroup();
784 bool bGlueInvalidate
= GetView().ImpIsGlueVisible();
787 GetView().GlueInvalidate();
789 SdrObject
* pParentGroup
= pLastGroup
->getParentSdrObjectFromSdrObject();
790 SdrObjList
* pParentList
= GetPage();
793 pParentList
= pParentGroup
->GetSubList();
795 // deselect everything
796 GetView().UnmarkAll();
798 // allocations, pCurrentGroup and pCurrentList need to be set
799 SetCurrentGroupAndList(pParentGroup
, pParentList
);
801 // select the group we just left
802 if (GetView().GetSdrPageView())
803 GetView().MarkObj(pLastGroup
, GetView().GetSdrPageView());
805 GetView().AdjustMarkHdl();
807 // invalidate only if view wants to visualize group entering
811 GetView().GlueInvalidate();
814 void SdrPageView::LeaveAllGroup()
816 SdrObject
* pLastGroup
= GetCurrentGroup();
820 bool bGlueInvalidate
= GetView().ImpIsGlueVisible();
823 GetView().GlueInvalidate();
825 // deselect everything
826 GetView().UnmarkAll();
828 // allocations, pCurrentGroup and pCurrentList always need to be set
829 SetCurrentGroupAndList(nullptr, GetPage());
831 // find and select uppermost group
832 while (pLastGroup
->getParentSdrObjectFromSdrObject())
833 pLastGroup
= pLastGroup
->getParentSdrObjectFromSdrObject();
835 if (GetView().GetSdrPageView())
836 GetView().MarkObj(pLastGroup
, GetView().GetSdrPageView());
838 GetView().AdjustMarkHdl();
840 // invalidate only when view wants to visualize group entering
844 GetView().GlueInvalidate();
847 sal_uInt16
SdrPageView::GetEnteredLevel() const
850 SdrObject
* pGrp
=GetCurrentGroup();
851 while (pGrp
!=nullptr) {
853 pGrp
=pGrp
->getParentSdrObjectFromSdrObject();
858 void SdrPageView::CheckCurrentGroup()
860 SdrObject
* pGrp(GetCurrentGroup());
862 while(nullptr != pGrp
&&
863 (!pGrp
->IsInserted() || nullptr == pGrp
->getParentSdrObjListFromSdrObject() || nullptr == pGrp
->getSdrPageFromSdrObject()))
865 // anything outside of the borders?
866 pGrp
= pGrp
->getParentSdrObjectFromSdrObject();
869 if(pGrp
!= GetCurrentGroup())
882 // Set background color for svx at SdrPageViews
883 void SdrPageView::SetApplicationBackgroundColor(Color aBackgroundColor
)
885 maBackgroundColor
= aBackgroundColor
;
889 // Set document color for svx at SdrPageViews
890 void SdrPageView::SetApplicationDocumentColor(Color aDocumentColor
)
892 maDocumentColor
= aDocumentColor
;
896 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */