Bump version to 6.4.7.2.M8
[LibreOffice.git] / svx / source / svdraw / svdpagv.cxx
blob950660669bad1a293063bf7fb87091d28157b342
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 <svx/svdoutl.hxx>
24 #include <svx/xpoly.hxx>
25 #include <svx/svdouno.hxx>
26 #include <svx/svdpage.hxx>
27 #include <svx/svdview.hxx>
29 #include <svx/svdedxv.hxx>
30 #include <editeng/outliner.hxx>
31 #include <svx/svdetc.hxx>
32 #include <svx/svdobj.hxx>
33 #include <svx/svditer.hxx>
34 #include <svx/svdogrp.hxx>
35 #include <svx/svdtypes.hxx>
36 #include <svx/svdoole2.hxx>
38 #include <svx/sdr/contact/objectcontactofpageview.hxx>
39 #include <svx/sdr/contact/viewobjectcontactredirector.hxx>
40 #include <svx/fmview.hxx>
42 #include <algorithm>
44 #include <svx/sdrpagewindow.hxx>
45 #include <svx/sdrpaintwindow.hxx>
46 #include <comphelper/lok.hxx>
47 #include <basegfx/range/b2irectangle.hxx>
49 using namespace ::com::sun::star;
51 // interface to SdrPageWindow
53 SdrPageWindow* SdrPageView::FindPageWindow(SdrPaintWindow& rPaintWindow) const
55 for(auto & a : maPageWindows)
57 if(&(a->GetPaintWindow()) == &rPaintWindow)
59 return a.get();
63 return nullptr;
66 const SdrPageWindow* SdrPageView::FindPatchedPageWindow( const OutputDevice& _rOutDev ) const
68 for ( auto const & pPageWindow : maPageWindows )
70 const SdrPaintWindow& rPaintWindow( pPageWindow->GetOriginalPaintWindow() ? *pPageWindow->GetOriginalPaintWindow() : pPageWindow->GetPaintWindow() );
71 if ( &rPaintWindow.GetOutputDevice() == &_rOutDev )
73 return pPageWindow.get();
77 return nullptr;
80 SdrPageWindow* SdrPageView::FindPageWindow(const OutputDevice& rOutDev) const
82 for ( auto const & pPageWindow : maPageWindows )
84 if(&(pPageWindow->GetPaintWindow().GetOutputDevice()) == &rOutDev)
86 return pPageWindow.get();
90 return nullptr;
93 SdrPageWindow* SdrPageView::GetPageWindow(sal_uInt32 nIndex) const
95 return maPageWindows[nIndex].get();
98 void SdrPageView::ClearPageWindows()
100 maPageWindows.clear();
103 SdrPageView::SdrPageView(SdrPage* pPage1, SdrView& rNewView)
104 : mrView(rNewView),
105 // col_auto color lets the view takes the default SvxColorConfig entry
106 maDocumentColor( COL_AUTO ),
107 maBackgroundColor( COL_AUTO ), // #i48367# also react on autocolor
108 mpPreparedPageWindow(nullptr) // #i72752#
110 mpPage = pPage1;
112 if(mpPage)
114 aPgOrg.setX(mpPage->GetLeftBorder() );
115 aPgOrg.setY(mpPage->GetUpperBorder() );
117 // For example, in the case of charts, there is a LayerAdmin, but it has no valid values. Therefore
118 // a solution like pLayerAdmin->getVisibleLayersODF(aLayerVisi) is not possible. So use the
119 // generic SetAll() for now.
120 aLayerVisi.SetAll();
121 aLayerPrn.SetAll();
123 mbHasMarked = false;
124 mbVisible = false;
125 pCurrentList = nullptr;
126 pCurrentGroup = nullptr;
127 SetCurrentGroupAndList(nullptr, mpPage);
129 for(sal_uInt32 a(0); a < rNewView.PaintWindowCount(); a++)
131 AddPaintWindowToPageView(*rNewView.GetPaintWindow(a));
135 SdrPageView::~SdrPageView()
139 void SdrPageView::AddPaintWindowToPageView(SdrPaintWindow& rPaintWindow)
141 if(!FindPageWindow(rPaintWindow))
143 maPageWindows.emplace_back(new SdrPageWindow(*this, rPaintWindow));
147 void SdrPageView::RemovePaintWindowFromPageView(SdrPaintWindow& rPaintWindow)
149 auto it = std::find_if(maPageWindows.begin(), maPageWindows.end(),
150 [&rPaintWindow](const std::unique_ptr<SdrPageWindow>& rpWindow) {
151 return &(rpWindow->GetPaintWindow()) == &rPaintWindow;
153 if (it != maPageWindows.end())
154 maPageWindows.erase(it);
157 css::uno::Reference< css::awt::XControlContainer > SdrPageView::GetControlContainer( const OutputDevice& _rDevice ) const
159 css::uno::Reference< css::awt::XControlContainer > xReturn;
160 const SdrPageWindow* pCandidate = FindPatchedPageWindow( _rDevice );
162 if ( pCandidate )
163 xReturn = pCandidate->GetControlContainer();
165 return xReturn;
168 void SdrPageView::ModelHasChanged()
170 if (GetCurrentGroup()!=nullptr) CheckCurrentGroup();
173 bool SdrPageView::IsReadOnly() const
175 return (nullptr == GetPage() || GetView().GetModel()->IsReadOnly() || GetPage()->IsReadOnly() || GetObjList()->IsReadOnly());
178 void SdrPageView::Show()
180 if(!IsVisible())
182 mbVisible = true;
184 for(sal_uInt32 a(0); a < GetView().PaintWindowCount(); a++)
186 AddPaintWindowToPageView(*GetView().GetPaintWindow(a));
191 void SdrPageView::Hide()
193 if(IsVisible())
195 if (!comphelper::LibreOfficeKit::isActive())
197 InvalidateAllWin();
199 mbVisible = false;
200 ClearPageWindows();
204 tools::Rectangle SdrPageView::GetPageRect() const
206 if (GetPage()==nullptr) return tools::Rectangle();
207 return tools::Rectangle(Point(),Size(GetPage()->GetWidth()+1,GetPage()->GetHeight()+1));
210 void SdrPageView::InvalidateAllWin()
212 if(IsVisible() && GetPage())
214 tools::Rectangle aRect(Point(0,0),Size(GetPage()->GetWidth()+1,GetPage()->GetHeight()+1));
215 aRect.Union(GetPage()->GetAllObjBoundRect());
216 GetView().InvalidateAllWin(aRect);
221 void SdrPageView::PrePaint()
223 const sal_uInt32 nCount(PageWindowCount());
225 for(sal_uInt32 a(0); a < nCount; a++)
227 SdrPageWindow* pCandidate = GetPageWindow(a);
229 if(pCandidate)
231 pCandidate->PrePaint();
236 void SdrPageView::CompleteRedraw(
237 SdrPaintWindow& rPaintWindow, const vcl::Region& rReg, sdr::contact::ViewObjectContactRedirector* pRedirector )
239 if(GetPage())
241 SdrPageWindow* pPageWindow = FindPageWindow(rPaintWindow);
242 std::unique_ptr<SdrPageWindow> pTempPageWindow;
244 if(!pPageWindow)
246 // create temp PageWindow
247 pTempPageWindow.reset(new SdrPageWindow(*this, rPaintWindow));
248 pPageWindow = pTempPageWindow.get();
251 // do the redraw
252 pPageWindow->PrepareRedraw(rReg);
253 pPageWindow->RedrawAll(pRedirector);
258 // #i74769# use SdrPaintWindow directly
260 void SdrPageView::setPreparedPageWindow(SdrPageWindow* pKnownTarget)
262 // #i72752# remember prepared SdrPageWindow
263 mpPreparedPageWindow = pKnownTarget;
266 void SdrPageView::DrawLayer(SdrLayerID nID, OutputDevice* pGivenTarget,
267 sdr::contact::ViewObjectContactRedirector* pRedirector,
268 const tools::Rectangle& rRect, basegfx::B2IRectangle const*const pPageFrame)
270 if(GetPage())
272 if(pGivenTarget)
274 SdrPageWindow* pKnownTarget = FindPageWindow(*pGivenTarget);
276 if(pKnownTarget)
278 // paint known target
279 pKnownTarget->RedrawLayer(&nID, pRedirector, nullptr);
281 else
283 // #i72752# DrawLayer() uses an OutputDevice different from BeginDrawLayer. This happens
284 // e.g. when SW paints a single text line in text edit mode. Try to use it
285 SdrPageWindow* pPreparedTarget = mpPreparedPageWindow;
287 if(pPreparedTarget)
289 // if we have a prepared target, do not use a new SdrPageWindow since this
290 // works but is expensive. Just use a temporary PaintWindow
291 SdrPaintWindow aTemporaryPaintWindow(mrView, *pGivenTarget);
293 // Copy existing paint region to use the same as prepared in BeginDrawLayer
294 SdrPaintWindow& rExistingPaintWindow = pPreparedTarget->GetPaintWindow();
295 const vcl::Region& rExistingRegion = rExistingPaintWindow.GetRedrawRegion();
296 bool bUseRect(false);
297 if (!rRect.IsEmpty())
299 vcl::Region r(rExistingRegion);
300 r.Intersect(rRect);
301 // fdo#74435: FIXME: visibility check broken if empty
302 if (!r.IsEmpty())
303 bUseRect = true;
305 if (!bUseRect)
306 aTemporaryPaintWindow.SetRedrawRegion(rExistingRegion);
307 else
308 aTemporaryPaintWindow.SetRedrawRegion(vcl::Region(rRect));
309 // patch the ExistingPageWindow
310 pPreparedTarget->patchPaintWindow(aTemporaryPaintWindow);
312 // redraw the layer
313 pPreparedTarget->RedrawLayer(&nID, pRedirector, pPageFrame);
315 // restore the ExistingPageWindow
316 pPreparedTarget->unpatchPaintWindow();
318 else
320 OSL_FAIL("SdrPageView::DrawLayer: Creating temporary SdrPageWindow (ObjectContact), this should never be needed (!)");
322 // None of the known OutputDevices is the target of this paint, use
323 // a temporary SdrPageWindow for this Redraw.
324 SdrPaintWindow aTemporaryPaintWindow(mrView, *pGivenTarget);
325 SdrPageWindow aTemporaryPageWindow(*this, aTemporaryPaintWindow);
327 // #i72752#
328 // Copy existing paint region if other PageWindows exist, this was created by
329 // PrepareRedraw() from BeginDrawLayer(). Needs to be used e.g. when suddenly SW
330 // paints into an unknown device other than the view was created for (e.g. VirtualDevice)
331 if(PageWindowCount())
333 SdrPageWindow* pExistingPageWindow = GetPageWindow(0);
334 SdrPaintWindow& rExistingPaintWindow = pExistingPageWindow->GetPaintWindow();
335 const vcl::Region& rExistingRegion = rExistingPaintWindow.GetRedrawRegion();
336 aTemporaryPaintWindow.SetRedrawRegion(rExistingRegion);
339 aTemporaryPageWindow.RedrawLayer(&nID, pRedirector, nullptr);
343 else
345 // paint in all known windows
346 for(sal_uInt32 a(0); a < PageWindowCount(); a++)
348 SdrPageWindow* pTarget = GetPageWindow(a);
349 pTarget->RedrawLayer(&nID, pRedirector, nullptr);
355 void SdrPageView::SetDesignMode( bool _bDesignMode ) const
357 for ( sal_uInt32 i = 0; i < PageWindowCount(); ++i )
359 const SdrPageWindow& rPageViewWindow = *GetPageWindow(i);
360 rPageViewWindow.SetDesignMode( _bDesignMode );
365 void SdrPageView::DrawPageViewGrid(OutputDevice& rOut, const tools::Rectangle& rRect, Color aColor)
367 if (GetPage()==nullptr)
368 return;
370 long nx1=GetView().maGridBig.Width();
371 long nx2=GetView().maGridFin.Width();
372 long ny1=GetView().maGridBig.Height();
373 long ny2=GetView().maGridFin.Height();
375 if (nx1==0) nx1=nx2;
376 if (nx2==0) nx2=nx1;
377 if (ny1==0) ny1=ny2;
378 if (ny2==0) ny2=ny1;
379 if (nx1==0) { nx1=ny1; nx2=ny2; }
380 if (ny1==0) { ny1=nx1; ny2=nx2; }
381 if (nx1<0) nx1=-nx1;
382 if (nx2<0) nx2=-nx2;
383 if (ny1<0) ny1=-ny1;
384 if (ny2<0) ny2=-ny2;
386 if (nx1==0)
387 return;
389 // no more global output size, use window size instead to decide grid sizes
390 long nScreenWdt = rOut.GetOutputSizePixel().Width();
392 long nMinDotPix=2;
393 long nMinLinPix=4;
395 if (nScreenWdt>=1600)
397 nMinDotPix=4;
398 nMinLinPix=8;
400 else if (nScreenWdt>=1024)
402 nMinDotPix=3;
403 nMinLinPix=6;
405 else
406 { // e. g. 640x480
407 nMinDotPix=2;
408 nMinLinPix=4;
410 Size aMinDotDist(rOut.PixelToLogic(Size(nMinDotPix,nMinDotPix)));
411 Size aMinLinDist(rOut.PixelToLogic(Size(nMinLinPix,nMinLinPix)));
412 bool bHoriSolid=nx2<aMinDotDist.Width();
413 bool bVertSolid=ny2<aMinDotDist.Height();
414 // enlarge line offset (minimum 4 pixels)
415 // enlarge by: *2 *5 *10 *20 *50 *100 ...
416 int nTgl=0;
417 long nVal0=nx1;
418 while (nx1<aMinLinDist.Width())
420 long a=nx1;
422 if (nTgl==0) nx1*=2;
423 if (nTgl==1) nx1=nVal0*5; // => nx1*=2.5
424 if (nTgl==2) nx1*=2;
426 nVal0=a;
427 nTgl++; if (nTgl>=3) nTgl=0;
429 nTgl=0;
430 nVal0=ny1;
431 while (ny1<aMinLinDist.Height())
433 long a=ny1;
435 if (nTgl==0) ny1*=2;
436 if (nTgl==1) ny1=nVal0*5; // => ny1*=2.5
437 if (nTgl==2) ny1*=2;
439 nVal0=a;
440 nTgl++;
442 if (nTgl>=3) nTgl=0;
445 bool bHoriFine=nx2<nx1;
446 bool bVertFine=ny2<ny1;
447 bool bHoriLines=bHoriSolid || bHoriFine || !bVertFine;
448 bool bVertLines=bVertSolid || bVertFine;
450 Color aOriginalLineColor( rOut.GetLineColor() );
451 rOut.SetLineColor( aColor );
453 bool bMap0=rOut.IsMapModeEnabled();
455 long nWrX=0;
456 long nWrY=0;
457 Point aOrg(aPgOrg);
458 long x1=GetPage()->GetLeftBorder()+1+nWrX;
459 long x2=GetPage()->GetWidth()-GetPage()->GetRightBorder()-1+nWrY;
460 long y1=GetPage()->GetUpperBorder()+1+nWrX;
461 long y2=GetPage()->GetHeight()-GetPage()->GetLowerBorder()-1+nWrY;
462 const SdrPageGridFrameList* pFrames=GetPage()->GetGridFrameList(this,nullptr);
464 sal_uInt16 nGridPaintCnt=1;
465 if (pFrames!=nullptr) nGridPaintCnt=pFrames->GetCount();
466 for (sal_uInt16 nGridPaintNum=0; nGridPaintNum<nGridPaintCnt; nGridPaintNum++) {
467 if (pFrames!=nullptr) {
468 const SdrPageGridFrame& rGF=(*pFrames)[nGridPaintNum];
469 nWrX=rGF.GetPaperRect().Left();
470 nWrY=rGF.GetPaperRect().Top();
471 x1=rGF.GetUserArea().Left();
472 x2=rGF.GetUserArea().Right();
473 y1=rGF.GetUserArea().Top();
474 y2=rGF.GetUserArea().Bottom();
475 aOrg=rGF.GetUserArea().TopLeft();
476 aOrg-=rGF.GetPaperRect().TopLeft();
478 if (!rRect.IsEmpty()) {
479 Size a1PixSiz(rOut.PixelToLogic(Size(1,1)));
480 long nX1Pix=a1PixSiz.Width(); // add 1 pixel of tolerance
481 long nY1Pix=a1PixSiz.Height();
482 if (x1<rRect.Left() -nX1Pix) x1=rRect.Left() -nX1Pix;
483 if (x2>rRect.Right() +nX1Pix) x2=rRect.Right() +nX1Pix;
484 if (y1<rRect.Top() -nY1Pix) y1=rRect.Top() -nY1Pix;
485 if (y2>rRect.Bottom()+nY1Pix) y2=rRect.Bottom()+nY1Pix;
488 long xBigOrg=aOrg.X()+nWrX;
489 while (xBigOrg>=x1) xBigOrg-=nx1;
490 while (xBigOrg<x1) xBigOrg+=nx1;
491 long xFinOrg=xBigOrg;
492 while (xFinOrg>=x1) xFinOrg-=nx2;
493 while (xFinOrg<x1) xFinOrg+=nx2;
495 long yBigOrg=aOrg.Y()+nWrY;
496 while (yBigOrg>=y1) yBigOrg-=ny1;
497 while (yBigOrg<y1) yBigOrg+=ny1;
498 long yFinOrg=yBigOrg;
499 while (yFinOrg>=y1) yFinOrg-=ny2;
500 while (yFinOrg<y1) yFinOrg+=ny2;
502 if( x1 <= x2 && y1 <= y2 )
504 if( bHoriLines )
506 DrawGridFlags nGridFlags = ( bHoriSolid ? DrawGridFlags::HorzLines : DrawGridFlags::Dots );
507 sal_uInt16 nSteps = sal_uInt16(nx1 / nx2);
508 sal_uInt32 nRestPerStepMul1000 = nSteps ? ( ((nx1 * 1000L)/ nSteps) - (nx2 * 1000L) ) : 0;
509 sal_uInt32 nStepOffset = 0;
510 sal_uInt16 nPointOffset = 0;
512 for(sal_uInt16 a=0;a<nSteps;a++)
514 // draw
515 rOut.DrawGrid(
516 tools::Rectangle( xFinOrg + (a * nx2) + nPointOffset, yBigOrg, x2, y2 ),
517 Size( nx1, ny1 ), nGridFlags );
519 // do a step
520 nStepOffset += nRestPerStepMul1000;
521 while(nStepOffset >= 1000)
523 nStepOffset -= 1000;
524 nPointOffset++;
529 if( bVertLines )
531 DrawGridFlags nGridFlags = ( bVertSolid ? DrawGridFlags::VertLines : DrawGridFlags::Dots );
532 sal_uInt16 nSteps = sal_uInt16(ny1 / ny2);
533 sal_uInt32 nRestPerStepMul1000 = nSteps ? ( ((ny1 * 1000L)/ nSteps) - (ny2 * 1000L) ) : 0;
534 sal_uInt32 nStepOffset = 0;
535 sal_uInt16 nPointOffset = 0;
537 for(sal_uInt16 a=0;a<nSteps;a++)
539 // draw
540 rOut.DrawGrid(
541 tools::Rectangle( xBigOrg, yFinOrg + (a * ny2) + nPointOffset, x2, y2 ),
542 Size( nx1, ny1 ), nGridFlags );
544 // do a step
545 nStepOffset += nRestPerStepMul1000;
546 while(nStepOffset >= 1000)
548 nStepOffset -= 1000;
549 nPointOffset++;
556 rOut.EnableMapMode(bMap0);
557 rOut.SetLineColor(aOriginalLineColor);
560 void SdrPageView::AdjHdl()
562 GetView().AdjustMarkHdl();
565 void SdrPageView::SetLayer(const OUString& rName, SdrLayerIDSet& rBS, bool bJa)
567 if(!GetPage())
568 return;
570 SdrLayerID nID = GetPage()->GetLayerAdmin().GetLayerID(rName);
572 if(SDRLAYER_NOTFOUND != nID)
573 rBS.Set(nID, bJa);
576 bool SdrPageView::IsLayer(const OUString& rName, const SdrLayerIDSet& rBS) const
578 if(!GetPage())
579 return false;
581 bool bRet(false);
583 if (!rName.isEmpty())
585 SdrLayerID nId = GetPage()->GetLayerAdmin().GetLayerID(rName);
587 if(SDRLAYER_NOTFOUND != nId)
589 bRet = rBS.IsSet(nId);
593 return bRet;
596 bool SdrPageView::IsObjMarkable(SdrObject const * pObj) const
598 if (!pObj)
599 return false;
600 if (pObj->IsMarkProtect())
601 return false; // excluded from selection?
602 if (!pObj->IsVisible())
603 return false; // only visible are selectable
604 if (!pObj->IsInserted())
605 return false; // Obj deleted?
606 if (auto pObjGroup = dynamic_cast<const SdrObjGroup*>(pObj))
608 // If object is a Group object, visibility may depend on
609 // multiple layers. If one object is markable, Group is markable.
610 SdrObjList* pObjList = pObjGroup->GetSubList();
612 if (pObjList && pObjList->GetObjCount())
614 for (size_t a = 0; a < pObjList->GetObjCount(); ++a)
616 SdrObject* pCandidate = pObjList->GetObj(a);
617 // call recursively
618 if (IsObjMarkable(pCandidate))
619 return true;
621 return false;
623 else
625 // #i43302#
626 // Allow empty groups to be selected to be able to delete them
627 return true;
630 if (!pObj->Is3DObj() && pObj->getSdrPageFromSdrObject() != GetPage())
632 // Obj suddenly in different Page
633 return false;
636 // the layer has to be visible and must not be locked
637 SdrLayerID nL = pObj->GetLayer();
638 if (!aLayerVisi.IsSet(nL))
639 return false;
640 if (aLayerLock.IsSet(nL))
641 return false;
642 return true;
645 void SdrPageView::SetPageOrigin(const Point& rOrg)
647 if (rOrg!=aPgOrg) {
648 aPgOrg=rOrg;
649 if (GetView().IsGridVisible()) {
650 InvalidateAllWin();
655 void SdrPageView::ImpInvalidateHelpLineArea(sal_uInt16 nNum) const
657 if (GetView().IsHlplVisible() && nNum<aHelpLines.GetCount()) {
658 const SdrHelpLine& rHL=aHelpLines[nNum];
660 for(sal_uInt32 a(0); a < GetView().PaintWindowCount(); a++)
662 SdrPaintWindow* pCandidate = GetView().GetPaintWindow(a);
664 if(pCandidate->OutputToWindow())
666 OutputDevice& rOutDev = pCandidate->GetOutputDevice();
667 tools::Rectangle aR(rHL.GetBoundRect(rOutDev));
668 Size aSiz(rOutDev.PixelToLogic(Size(1,1)));
669 aR.AdjustLeft( -(aSiz.Width()) );
670 aR.AdjustRight(aSiz.Width() );
671 aR.AdjustTop( -(aSiz.Height()) );
672 aR.AdjustBottom(aSiz.Height() );
673 const_cast<SdrView&>(GetView()).InvalidateOneWin(rOutDev, aR);
679 void SdrPageView::SetHelpLines(const SdrHelpLineList& rHLL)
681 aHelpLines=rHLL;
682 InvalidateAllWin();
685 void SdrPageView::SetHelpLine(sal_uInt16 nNum, const SdrHelpLine& rNewHelpLine)
687 if (nNum<aHelpLines.GetCount() && aHelpLines[nNum]!=rNewHelpLine) {
688 bool bNeedRedraw = true;
689 if (aHelpLines[nNum].GetKind()==rNewHelpLine.GetKind()) {
690 switch (rNewHelpLine.GetKind()) {
691 case SdrHelpLineKind::Vertical : if (aHelpLines[nNum].GetPos().X()==rNewHelpLine.GetPos().X()) bNeedRedraw = false; break;
692 case SdrHelpLineKind::Horizontal: if (aHelpLines[nNum].GetPos().Y()==rNewHelpLine.GetPos().Y()) bNeedRedraw = false; break;
693 default: break;
694 } // switch
696 if (bNeedRedraw) ImpInvalidateHelpLineArea(nNum);
697 aHelpLines[nNum]=rNewHelpLine;
698 if (bNeedRedraw) ImpInvalidateHelpLineArea(nNum);
702 void SdrPageView::DeleteHelpLine(sal_uInt16 nNum)
704 if (nNum<aHelpLines.GetCount()) {
705 ImpInvalidateHelpLineArea(nNum);
706 aHelpLines.Delete(nNum);
710 void SdrPageView::InsertHelpLine(const SdrHelpLine& rHL)
712 sal_uInt16 nNum = aHelpLines.GetCount();
713 aHelpLines.Insert(rHL,nNum);
714 if (GetView().IsHlplVisible())
715 ImpInvalidateHelpLineArea(nNum);
718 // set current group and list
719 void SdrPageView::SetCurrentGroupAndList(SdrObject* pNewGroup, SdrObjList* pNewList)
721 if(pCurrentGroup != pNewGroup)
723 pCurrentGroup = pNewGroup;
725 if(pCurrentList != pNewList)
727 pCurrentList = pNewList;
731 bool SdrPageView::EnterGroup(SdrObject* pObj)
733 bool bRet(false);
735 if(pObj && pObj->IsGroupObject())
737 bool bGlueInvalidate(GetView().ImpIsGlueVisible());
739 if(bGlueInvalidate)
741 GetView().GlueInvalidate();
744 // deselect all
745 GetView().UnmarkAll();
747 // set current group and list
748 SdrObjList* pNewObjList = pObj->GetSubList();
749 SetCurrentGroupAndList(pObj, pNewObjList);
751 // select contained object if only one object is contained,
752 // else select nothing and let the user decide what to do next
753 if(pNewObjList && pNewObjList->GetObjCount() == 1)
755 SdrObject* pFirstObject = pNewObjList->GetObj(0);
757 if(GetView().GetSdrPageView())
759 GetView().MarkObj(pFirstObject, GetView().GetSdrPageView());
763 // build new handles
764 GetView().AdjustMarkHdl();
766 // invalidate only when view wants to visualize group entering
767 InvalidateAllWin();
769 if (bGlueInvalidate)
771 GetView().GlueInvalidate();
774 bRet = true;
777 return bRet;
780 void SdrPageView::LeaveOneGroup()
782 SdrObject* pLastGroup = GetCurrentGroup();
783 if (!pLastGroup)
784 return;
786 bool bGlueInvalidate = GetView().ImpIsGlueVisible();
788 if(bGlueInvalidate)
789 GetView().GlueInvalidate();
791 SdrObject* pParentGroup = pLastGroup->getParentSdrObjectFromSdrObject();
792 SdrObjList* pParentList = GetPage();
794 if(pParentGroup)
795 pParentList = pParentGroup->GetSubList();
797 // deselect everything
798 GetView().UnmarkAll();
800 // allocations, pCurrentGroup and pCurrentList need to be set
801 SetCurrentGroupAndList(pParentGroup, pParentList);
803 // select the group we just left
804 if (GetView().GetSdrPageView())
805 GetView().MarkObj(pLastGroup, GetView().GetSdrPageView());
807 GetView().AdjustMarkHdl();
809 // invalidate only if view wants to visualize group entering
810 InvalidateAllWin();
812 if(bGlueInvalidate)
813 GetView().GlueInvalidate();
816 void SdrPageView::LeaveAllGroup()
818 if (SdrObject* pLastGroup = GetCurrentGroup())
820 bool bGlueInvalidate = GetView().ImpIsGlueVisible();
822 if(bGlueInvalidate)
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
841 InvalidateAllWin();
843 if(bGlueInvalidate)
844 GetView().GlueInvalidate();
848 sal_uInt16 SdrPageView::GetEnteredLevel() const
850 sal_uInt16 nCount=0;
851 SdrObject* pGrp=GetCurrentGroup();
852 while (pGrp!=nullptr) {
853 nCount++;
854 pGrp=pGrp->getParentSdrObjectFromSdrObject();
856 return nCount;
859 void SdrPageView::CheckCurrentGroup()
861 SdrObject* pGrp(GetCurrentGroup());
863 while(nullptr != pGrp &&
864 (!pGrp->IsInserted() || nullptr == pGrp->getParentSdrObjListFromSdrObject() || nullptr == pGrp->getSdrPageFromSdrObject()))
866 // anything outside of the borders?
867 pGrp = pGrp->getParentSdrObjectFromSdrObject();
870 if(pGrp != GetCurrentGroup())
872 if(nullptr != pGrp)
874 EnterGroup(pGrp);
876 else
878 LeaveAllGroup();
883 // Set background color for svx at SdrPageViews
884 void SdrPageView::SetApplicationBackgroundColor(Color aBackgroundColor)
886 maBackgroundColor = aBackgroundColor;
890 // Set document color for svx at SdrPageViews
891 void SdrPageView::SetApplicationDocumentColor(Color aDocumentColor)
893 maDocumentColor = aDocumentColor;
897 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */