LibreOffice Module svx (master)  1
svdpagv.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
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>
28 
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>
37 
40 #include <svx/fmview.hxx>
41 
42 #include <algorithm>
43 
44 #include <svx/sdrpagewindow.hxx>
45 #include <svx/sdrpaintwindow.hxx>
46 #include <comphelper/lok.hxx>
48 
49 using namespace ::com::sun::star;
50 
51 // interface to SdrPageWindow
52 
54 {
55  for(auto & a : maPageWindows)
56  {
57  if(&(a->GetPaintWindow()) == &rPaintWindow)
58  {
59  return a.get();
60  }
61  }
62 
63  return nullptr;
64 }
65 
67 {
68  for ( auto const & pPageWindow : maPageWindows )
69  {
70  const SdrPaintWindow& rPaintWindow( pPageWindow->GetOriginalPaintWindow() ? *pPageWindow->GetOriginalPaintWindow() : pPageWindow->GetPaintWindow() );
71  if ( &rPaintWindow.GetOutputDevice() == &_rOutDev )
72  {
73  return pPageWindow.get();
74  }
75  }
76 
77  return nullptr;
78 }
79 
81 {
82  for ( auto const & pPageWindow : maPageWindows )
83  {
84  if(&(pPageWindow->GetPaintWindow().GetOutputDevice()) == &rOutDev)
85  {
86  return pPageWindow.get();
87  }
88  }
89 
90  return nullptr;
91 }
92 
93 SdrPageWindow* SdrPageView::GetPageWindow(sal_uInt32 nIndex) const
94 {
95  return maPageWindows[nIndex].get();
96 }
97 
99 : mrView(rNewView),
100  // col_auto color lets the view takes the default SvxColorConfig entry
101  maDocumentColor( COL_AUTO ),
102  maBackgroundColor( COL_AUTO ), // #i48367# also react on autocolor
103  mpPreparedPageWindow(nullptr) // #i72752#
104 {
105  mpPage = pPage1;
106 
107  if(mpPage)
108  {
111  }
112  // For example, in the case of charts, there is a LayerAdmin, but it has no valid values. Therefore
113  // a solution like pLayerAdmin->getVisibleLayersODF(aLayerVisi) is not possible. So use the
114  // generic SetAll() for now.
115  aLayerVisi.SetAll();
116  aLayerPrn.SetAll();
117 
118  mbHasMarked = false;
119  mbVisible = false;
120  pCurrentList = nullptr;
121  pCurrentGroup = nullptr;
122  SetCurrentGroupAndList(nullptr, mpPage);
123 
124  for(sal_uInt32 a(0); a < rNewView.PaintWindowCount(); a++)
125  {
127  }
128 }
129 
131 {
132 }
133 
135 {
136  if(!FindPageWindow(rPaintWindow))
137  {
138  maPageWindows.emplace_back(new SdrPageWindow(*this, rPaintWindow));
139  }
140 }
141 
143 {
144  auto it = std::find_if(maPageWindows.begin(), maPageWindows.end(),
145  [&rPaintWindow](const std::unique_ptr<SdrPageWindow>& rpWindow) {
146  return &(rpWindow->GetPaintWindow()) == &rPaintWindow;
147  });
148  if (it != maPageWindows.end())
149  maPageWindows.erase(it);
150 }
151 
152 css::uno::Reference< css::awt::XControlContainer > SdrPageView::GetControlContainer( const OutputDevice& _rDevice ) const
153 {
154  css::uno::Reference< css::awt::XControlContainer > xReturn;
155  const SdrPageWindow* pCandidate = FindPatchedPageWindow( _rDevice );
156 
157  if ( pCandidate )
158  xReturn = pCandidate->GetControlContainer();
159 
160  return xReturn;
161 }
162 
164 {
165  if (GetCurrentGroup()!=nullptr) CheckCurrentGroup();
166 }
167 
169 {
170  return (nullptr == GetPage() || GetView().GetModel()->IsReadOnly() || GetPage()->IsReadOnly() || GetObjList()->IsReadOnly());
171 }
172 
174 {
175  if(!IsVisible())
176  {
177  mbVisible = true;
178 
179  for(sal_uInt32 a(0); a < GetView().PaintWindowCount(); a++)
180  {
181  AddPaintWindowToPageView(*GetView().GetPaintWindow(a));
182  }
183  }
184 }
185 
187 {
188  if(IsVisible())
189  {
191  {
193  }
194  mbVisible = false;
195  maPageWindows.clear();
196  }
197 }
198 
200 {
201  if (GetPage()==nullptr) return tools::Rectangle();
202  return tools::Rectangle(Point(),Size(GetPage()->GetWidth()+1,GetPage()->GetHeight()+1));
203 }
204 
206 {
207  if(IsVisible() && GetPage())
208  {
209  tools::Rectangle aRect(Point(0,0),Size(GetPage()->GetWidth()+1,GetPage()->GetHeight()+1));
210  aRect.Union(GetPage()->GetAllObjBoundRect());
211  GetView().InvalidateAllWin(aRect);
212  }
213 }
214 
215 
217 {
218  const sal_uInt32 nCount(PageWindowCount());
219 
220  for(sal_uInt32 a(0); a < nCount; a++)
221  {
222  SdrPageWindow* pCandidate = GetPageWindow(a);
223 
224  if(pCandidate)
225  {
226  pCandidate->PrePaint();
227  }
228  }
229 }
230 
232  SdrPaintWindow& rPaintWindow, const vcl::Region& rReg, sdr::contact::ViewObjectContactRedirector* pRedirector )
233 {
234  if(GetPage())
235  {
236  SdrPageWindow* pPageWindow = FindPageWindow(rPaintWindow);
237  std::unique_ptr<SdrPageWindow> pTempPageWindow;
238 
239  if(!pPageWindow)
240  {
241  // create temp PageWindow
242  pTempPageWindow.reset(new SdrPageWindow(*this, rPaintWindow));
243  pPageWindow = pTempPageWindow.get();
244  }
245 
246  // do the redraw
247  pPageWindow->PrepareRedraw(rReg);
248  pPageWindow->RedrawAll(pRedirector);
249  }
250 }
251 
252 
253 // #i74769# use SdrPaintWindow directly
254 
256 {
257  // #i72752# remember prepared SdrPageWindow
258  mpPreparedPageWindow = pKnownTarget;
259 }
260 
263  const tools::Rectangle& rRect, basegfx::B2IRectangle const*const pPageFrame)
264 {
265  if(GetPage())
266  {
267  if(pGivenTarget)
268  {
269  SdrPageWindow* pKnownTarget = FindPageWindow(*pGivenTarget);
270 
271  if(pKnownTarget)
272  {
273  // paint known target
274  pKnownTarget->RedrawLayer(&nID, pRedirector, nullptr);
275  }
276  else
277  {
278  // #i72752# DrawLayer() uses an OutputDevice different from BeginDrawLayer. This happens
279  // e.g. when SW paints a single text line in text edit mode. Try to use it
280  SdrPageWindow* pPreparedTarget = mpPreparedPageWindow;
281 
282  if(pPreparedTarget)
283  {
284  // if we have a prepared target, do not use a new SdrPageWindow since this
285  // works but is expensive. Just use a temporary PaintWindow
286  SdrPaintWindow aTemporaryPaintWindow(mrView, *pGivenTarget);
287 
288  // Copy existing paint region to use the same as prepared in BeginDrawLayer
289  SdrPaintWindow& rExistingPaintWindow = pPreparedTarget->GetPaintWindow();
290  const vcl::Region& rExistingRegion = rExistingPaintWindow.GetRedrawRegion();
291  bool bUseRect(false);
292  if (!rRect.IsEmpty())
293  {
294  vcl::Region r(rExistingRegion);
295  r.Intersect(rRect);
296  // fdo#74435: FIXME: visibility check broken if empty
297  if (!r.IsEmpty())
298  bUseRect = true;
299  }
300  if (!bUseRect)
301  aTemporaryPaintWindow.SetRedrawRegion(rExistingRegion);
302  else
303  aTemporaryPaintWindow.SetRedrawRegion(vcl::Region(rRect));
304  // patch the ExistingPageWindow
305  pPreparedTarget->patchPaintWindow(aTemporaryPaintWindow);
306 
307  // redraw the layer
308  pPreparedTarget->RedrawLayer(&nID, pRedirector, pPageFrame);
309 
310  // restore the ExistingPageWindow
311  pPreparedTarget->unpatchPaintWindow();
312  }
313  else
314  {
315  OSL_FAIL("SdrPageView::DrawLayer: Creating temporary SdrPageWindow (ObjectContact), this should never be needed (!)");
316 
317  // None of the known OutputDevices is the target of this paint, use
318  // a temporary SdrPageWindow for this Redraw.
319  SdrPaintWindow aTemporaryPaintWindow(mrView, *pGivenTarget);
320  SdrPageWindow aTemporaryPageWindow(*this, aTemporaryPaintWindow);
321 
322  // #i72752#
323  // Copy existing paint region if other PageWindows exist, this was created by
324  // PrepareRedraw() from BeginDrawLayer(). Needs to be used e.g. when suddenly SW
325  // paints into an unknown device other than the view was created for (e.g. VirtualDevice)
326  if(PageWindowCount())
327  {
328  SdrPageWindow* pExistingPageWindow = GetPageWindow(0);
329  SdrPaintWindow& rExistingPaintWindow = pExistingPageWindow->GetPaintWindow();
330  const vcl::Region& rExistingRegion = rExistingPaintWindow.GetRedrawRegion();
331  aTemporaryPaintWindow.SetRedrawRegion(rExistingRegion);
332  }
333 
334  aTemporaryPageWindow.RedrawLayer(&nID, pRedirector, nullptr);
335  }
336  }
337  }
338  else
339  {
340  // paint in all known windows
341  for(sal_uInt32 a(0); a < PageWindowCount(); a++)
342  {
343  SdrPageWindow* pTarget = GetPageWindow(a);
344  pTarget->RedrawLayer(&nID, pRedirector, nullptr);
345  }
346  }
347  }
348 }
349 
350 void SdrPageView::SetDesignMode( bool _bDesignMode ) const
351 {
352  for ( sal_uInt32 i = 0; i < PageWindowCount(); ++i )
353  {
354  const SdrPageWindow& rPageViewWindow = *GetPageWindow(i);
355  rPageViewWindow.SetDesignMode( _bDesignMode );
356  }
357 }
358 
359 
361 {
362  if (GetPage()==nullptr)
363  return;
364 
365  long nx1=GetView().maGridBig.Width();
366  long nx2=GetView().maGridFin.Width();
367  long ny1=GetView().maGridBig.Height();
368  long ny2=GetView().maGridFin.Height();
369 
370  if (nx1==0) nx1=nx2;
371  if (nx2==0) nx2=nx1;
372  if (ny1==0) ny1=ny2;
373  if (ny2==0) ny2=ny1;
374  if (nx1==0) { nx1=ny1; nx2=ny2; }
375  if (ny1==0) { ny1=nx1; ny2=nx2; }
376  if (nx1<0) nx1=-nx1;
377  if (nx2<0) nx2=-nx2;
378  if (ny1<0) ny1=-ny1;
379  if (ny2<0) ny2=-ny2;
380 
381  if (nx1==0)
382  return;
383 
384  // no more global output size, use window size instead to decide grid sizes
385  long nScreenWdt = rOut.GetOutputSizePixel().Width();
386 
387  long nMinDotPix=2;
388  long nMinLinPix=4;
389 
390  if (nScreenWdt>=1600)
391  {
392  nMinDotPix=4;
393  nMinLinPix=8;
394  }
395  else if (nScreenWdt>=1024)
396  {
397  nMinDotPix=3;
398  nMinLinPix=6;
399  }
400  else
401  { // e. g. 640x480
402  nMinDotPix=2;
403  nMinLinPix=4;
404  }
405  Size aMinDotDist(rOut.PixelToLogic(Size(nMinDotPix,nMinDotPix)));
406  Size aMinLinDist(rOut.PixelToLogic(Size(nMinLinPix,nMinLinPix)));
407  bool bHoriSolid=nx2<aMinDotDist.Width();
408  bool bVertSolid=ny2<aMinDotDist.Height();
409  // enlarge line offset (minimum 4 pixels)
410  // enlarge by: *2 *5 *10 *20 *50 *100 ...
411  int nTgl=0;
412  long nVal0=nx1;
413  while (nx1<aMinLinDist.Width())
414  {
415  long a=nx1;
416 
417  if (nTgl==0) nx1*=2;
418  if (nTgl==1) nx1=nVal0*5; // => nx1*=2.5
419  if (nTgl==2) nx1*=2;
420 
421  nVal0=a;
422  nTgl++; if (nTgl>=3) nTgl=0;
423  }
424  nTgl=0;
425  nVal0=ny1;
426  while (ny1<aMinLinDist.Height())
427  {
428  long a=ny1;
429 
430  if (nTgl==0) ny1*=2;
431  if (nTgl==1) ny1=nVal0*5; // => ny1*=2.5
432  if (nTgl==2) ny1*=2;
433 
434  nVal0=a;
435  nTgl++;
436 
437  if (nTgl>=3) nTgl=0;
438  }
439 
440  bool bHoriFine=nx2<nx1;
441  bool bVertFine=ny2<ny1;
442  bool bHoriLines=bHoriSolid || bHoriFine || !bVertFine;
443  bool bVertLines=bVertSolid || bVertFine;
444 
445  Color aOriginalLineColor( rOut.GetLineColor() );
446  rOut.SetLineColor( aColor );
447 
448  bool bMap0=rOut.IsMapModeEnabled();
449 
450  long nWrX=0;
451  long nWrY=0;
452  Point aOrg(aPgOrg);
453  long x1=GetPage()->GetLeftBorder()+1+nWrX;
454  long x2=GetPage()->GetWidth()-GetPage()->GetRightBorder()-1+nWrY;
455  long y1=GetPage()->GetUpperBorder()+1+nWrX;
456  long y2=GetPage()->GetHeight()-GetPage()->GetLowerBorder()-1+nWrY;
457  const SdrPageGridFrameList* pFrames=GetPage()->GetGridFrameList(this,nullptr);
458 
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();
472  }
473  if (!rRect.IsEmpty()) {
474  Size a1PixSiz(rOut.PixelToLogic(Size(1,1)));
475  long nX1Pix=a1PixSiz.Width(); // add 1 pixel of tolerance
476  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;
481  }
482 
483  long xBigOrg=aOrg.X()+nWrX;
484  while (xBigOrg>=x1) xBigOrg-=nx1;
485  while (xBigOrg<x1) xBigOrg+=nx1;
486  long xFinOrg=xBigOrg;
487  while (xFinOrg>=x1) xFinOrg-=nx2;
488  while (xFinOrg<x1) xFinOrg+=nx2;
489 
490  long yBigOrg=aOrg.Y()+nWrY;
491  while (yBigOrg>=y1) yBigOrg-=ny1;
492  while (yBigOrg<y1) yBigOrg+=ny1;
493  long yFinOrg=yBigOrg;
494  while (yFinOrg>=y1) yFinOrg-=ny2;
495  while (yFinOrg<y1) yFinOrg+=ny2;
496 
497  if( x1 <= x2 && y1 <= y2 )
498  {
499  if( bHoriLines )
500  {
501  DrawGridFlags nGridFlags = ( bHoriSolid ? DrawGridFlags::HorzLines : DrawGridFlags::Dots );
502  sal_uInt16 nSteps = sal_uInt16(nx1 / nx2);
503  sal_uInt32 nRestPerStepMul1000 = nSteps ? ( ((nx1 * 1000L)/ nSteps) - (nx2 * 1000L) ) : 0;
504  sal_uInt32 nStepOffset = 0;
505  sal_uInt16 nPointOffset = 0;
506 
507  for(sal_uInt16 a=0;a<nSteps;a++)
508  {
509  // draw
510  rOut.DrawGrid(
511  tools::Rectangle( xFinOrg + (a * nx2) + nPointOffset, yBigOrg, x2, y2 ),
512  Size( nx1, ny1 ), nGridFlags );
513 
514  // do a step
515  nStepOffset += nRestPerStepMul1000;
516  while(nStepOffset >= 1000)
517  {
518  nStepOffset -= 1000;
519  nPointOffset++;
520  }
521  }
522  }
523 
524  if( bVertLines )
525  {
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;
531 
532  for(sal_uInt16 a=0;a<nSteps;a++)
533  {
534  // draw
535  rOut.DrawGrid(
536  tools::Rectangle( xBigOrg, yFinOrg + (a * ny2) + nPointOffset, x2, y2 ),
537  Size( nx1, ny1 ), nGridFlags );
538 
539  // do a step
540  nStepOffset += nRestPerStepMul1000;
541  while(nStepOffset >= 1000)
542  {
543  nStepOffset -= 1000;
544  nPointOffset++;
545  }
546  }
547  }
548  }
549  }
550 
551  rOut.EnableMapMode(bMap0);
552  rOut.SetLineColor(aOriginalLineColor);
553 }
554 
556 {
558 }
559 
560 void SdrPageView::SetLayer(const OUString& rName, SdrLayerIDSet& rBS, bool bJa)
561 {
562  if(!GetPage())
563  return;
564 
565  SdrLayerID nID = GetPage()->GetLayerAdmin().GetLayerID(rName);
566 
567  if(SDRLAYER_NOTFOUND != nID)
568  rBS.Set(nID, bJa);
569 }
570 
571 bool SdrPageView::IsLayer(const OUString& rName, const SdrLayerIDSet& rBS) const
572 {
573  if(!GetPage())
574  return false;
575 
576  bool bRet(false);
577 
578  if (!rName.isEmpty())
579  {
581 
582  if(SDRLAYER_NOTFOUND != nId)
583  {
584  bRet = rBS.IsSet(nId);
585  }
586  }
587 
588  return bRet;
589 }
590 
591 bool SdrPageView::IsObjMarkable(SdrObject const * pObj) const
592 {
593  if (!pObj)
594  return false;
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))
602  {
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();
606 
607  if (pObjList && pObjList->GetObjCount())
608  {
609  for (size_t a = 0; a < pObjList->GetObjCount(); ++a)
610  {
611  SdrObject* pCandidate = pObjList->GetObj(a);
612  // call recursively
613  if (IsObjMarkable(pCandidate))
614  return true;
615  }
616  return false;
617  }
618  else
619  {
620  // #i43302#
621  // Allow empty groups to be selected to be able to delete them
622  return true;
623  }
624  }
625  if (!pObj->Is3DObj() && pObj->getSdrPageFromSdrObject() != GetPage())
626  {
627  // Obj suddenly in different Page
628  return false;
629  }
630 
631  // the layer has to be visible and must not be locked
632  SdrLayerID nL = pObj->GetLayer();
633  if (!aLayerVisi.IsSet(nL))
634  return false;
635  if (aLayerLock.IsSet(nL))
636  return false;
637  return true;
638 }
639 
641 {
642  if (rOrg!=aPgOrg) {
643  aPgOrg=rOrg;
644  if (GetView().IsGridVisible()) {
646  }
647  }
648 }
649 
650 void SdrPageView::ImpInvalidateHelpLineArea(sal_uInt16 nNum) const
651 {
652  if (GetView().IsHlplVisible() && nNum<aHelpLines.GetCount()) {
653  const SdrHelpLine& rHL=aHelpLines[nNum];
654 
655  for(sal_uInt32 a(0); a < GetView().PaintWindowCount(); a++)
656  {
657  SdrPaintWindow* pCandidate = GetView().GetPaintWindow(a);
658 
659  if(pCandidate->OutputToWindow())
660  {
661  OutputDevice& rOutDev = pCandidate->GetOutputDevice();
662  tools::Rectangle aR(rHL.GetBoundRect(rOutDev));
663  Size aSiz(rOutDev.PixelToLogic(Size(1,1)));
664  aR.AdjustLeft( -(aSiz.Width()) );
665  aR.AdjustRight(aSiz.Width() );
666  aR.AdjustTop( -(aSiz.Height()) );
667  aR.AdjustBottom(aSiz.Height() );
668  const_cast<SdrView&>(GetView()).InvalidateOneWin(rOutDev, aR);
669  }
670  }
671  }
672 }
673 
675 {
676  aHelpLines=rHLL;
678 }
679 
680 void SdrPageView::SetHelpLine(sal_uInt16 nNum, const SdrHelpLine& rNewHelpLine)
681 {
682  if (nNum<aHelpLines.GetCount() && aHelpLines[nNum]!=rNewHelpLine) {
683  bool bNeedRedraw = true;
684  if (aHelpLines[nNum].GetKind()==rNewHelpLine.GetKind()) {
685  switch (rNewHelpLine.GetKind()) {
686  case SdrHelpLineKind::Vertical : if (aHelpLines[nNum].GetPos().X()==rNewHelpLine.GetPos().X()) bNeedRedraw = false; break;
687  case SdrHelpLineKind::Horizontal: if (aHelpLines[nNum].GetPos().Y()==rNewHelpLine.GetPos().Y()) bNeedRedraw = false; break;
688  default: break;
689  } // switch
690  }
691  if (bNeedRedraw) ImpInvalidateHelpLineArea(nNum);
692  aHelpLines[nNum]=rNewHelpLine;
693  if (bNeedRedraw) ImpInvalidateHelpLineArea(nNum);
694  }
695 }
696 
697 void SdrPageView::DeleteHelpLine(sal_uInt16 nNum)
698 {
699  if (nNum<aHelpLines.GetCount()) {
701  aHelpLines.Delete(nNum);
702  }
703 }
704 
706 {
707  sal_uInt16 nNum = aHelpLines.GetCount();
708  aHelpLines.Insert(rHL,nNum);
709  if (GetView().IsHlplVisible())
711 }
712 
713 // set current group and list
715 {
716  if(pCurrentGroup != pNewGroup)
717  {
718  pCurrentGroup = pNewGroup;
719  }
720  if(pCurrentList != pNewList)
721  {
722  pCurrentList = pNewList;
723  }
724 }
725 
727 {
728  bool bRet(false);
729 
730  if(pObj && pObj->IsGroupObject())
731  {
732  bool bGlueInvalidate(GetView().ImpIsGlueVisible());
733 
734  if(bGlueInvalidate)
735  {
737  }
738 
739  // deselect all
740  GetView().UnmarkAll();
741 
742  // set current group and list
743  SdrObjList* pNewObjList = pObj->GetSubList();
744  SetCurrentGroupAndList(pObj, pNewObjList);
745 
746  // select contained object if only one object is contained,
747  // else select nothing and let the user decide what to do next
748  if(pNewObjList && pNewObjList->GetObjCount() == 1)
749  {
750  SdrObject* pFirstObject = pNewObjList->GetObj(0);
751 
752  if(GetView().GetSdrPageView())
753  {
754  GetView().MarkObj(pFirstObject, GetView().GetSdrPageView());
755  }
756  }
757 
758  // build new handles
760 
761  // invalidate only when view wants to visualize group entering
763 
764  if (bGlueInvalidate)
765  {
767  }
768 
769  bRet = true;
770  }
771 
772  return bRet;
773 }
774 
776 {
777  SdrObject* pLastGroup = GetCurrentGroup();
778  if (!pLastGroup)
779  return;
780 
781  bool bGlueInvalidate = GetView().ImpIsGlueVisible();
782 
783  if(bGlueInvalidate)
785 
786  SdrObject* pParentGroup = pLastGroup->getParentSdrObjectFromSdrObject();
787  SdrObjList* pParentList = GetPage();
788 
789  if(pParentGroup)
790  pParentList = pParentGroup->GetSubList();
791 
792  // deselect everything
793  GetView().UnmarkAll();
794 
795  // allocations, pCurrentGroup and pCurrentList need to be set
796  SetCurrentGroupAndList(pParentGroup, pParentList);
797 
798  // select the group we just left
799  if (GetView().GetSdrPageView())
800  GetView().MarkObj(pLastGroup, GetView().GetSdrPageView());
801 
803 
804  // invalidate only if view wants to visualize group entering
806 
807  if(bGlueInvalidate)
809 }
810 
812 {
813  if (SdrObject* pLastGroup = GetCurrentGroup())
814  {
815  bool bGlueInvalidate = GetView().ImpIsGlueVisible();
816 
817  if(bGlueInvalidate)
819 
820  // deselect everything
821  GetView().UnmarkAll();
822 
823  // allocations, pCurrentGroup and pCurrentList always need to be set
824  SetCurrentGroupAndList(nullptr, GetPage());
825 
826  // find and select uppermost group
827  while (pLastGroup->getParentSdrObjectFromSdrObject())
828  pLastGroup = pLastGroup->getParentSdrObjectFromSdrObject();
829 
830  if (GetView().GetSdrPageView())
831  GetView().MarkObj(pLastGroup, GetView().GetSdrPageView());
832 
834 
835  // invalidate only when view wants to visualize group entering
837 
838  if(bGlueInvalidate)
840  }
841 }
842 
844 {
845  sal_uInt16 nCount=0;
846  SdrObject* pGrp=GetCurrentGroup();
847  while (pGrp!=nullptr) {
848  nCount++;
849  pGrp=pGrp->getParentSdrObjectFromSdrObject();
850  }
851  return nCount;
852 }
853 
855 {
856  SdrObject* pGrp(GetCurrentGroup());
857 
858  while(nullptr != pGrp &&
859  (!pGrp->IsInserted() || nullptr == pGrp->getParentSdrObjListFromSdrObject() || nullptr == pGrp->getSdrPageFromSdrObject()))
860  {
861  // anything outside of the borders?
862  pGrp = pGrp->getParentSdrObjectFromSdrObject();
863  }
864 
865  if(pGrp != GetCurrentGroup())
866  {
867  if(nullptr != pGrp)
868  {
869  EnterGroup(pGrp);
870  }
871  else
872  {
873  LeaveAllGroup();
874  }
875  }
876 }
877 
878 // Set background color for svx at SdrPageViews
880 {
881  maBackgroundColor = aBackgroundColor;
882 }
883 
884 
885 // Set document color for svx at SdrPageViews
887 {
888  maDocumentColor = aDocumentColor;
889 }
890 
891 
892 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void ImpInvalidateHelpLineArea(sal_uInt16 nNum) const
Definition: svdpagv.cxx:650
Point TopLeft() const
long Width() const
void AdjHdl()
Definition: svdpagv.cxx:555
void Set(SdrLayerID a)
Definition: svdsob.hxx:48
void InsertHelpLine(const SdrHelpLine &rHL)
Definition: svdpagv.cxx:705
const SdrPageWindow * FindPatchedPageWindow(const OutputDevice &rOutDev) const
Finds the page window whose PaintWindow belongs to the given output device In opposite to FindPageWin...
Definition: svdpagv.cxx:66
sal_Int32 GetHeight() const
Definition: svdpage.cxx:1417
for the snap-to-grid in Writer
Definition: svdpage.hxx:281
long Height() const
SdrView & GetView()
Definition: svdpagv.hxx:135
SdrObjList * pCurrentList
Definition: svdpagv.hxx:76
void RemovePaintWindowFromPageView(SdrPaintWindow &rPaintWindow)
Definition: svdpagv.cxx:142
void SetApplicationBackgroundColor(Color aBackgroundColor)
Definition: svdpagv.cxx:879
void SetAll()
Definition: svdsob.hxx:71
void unpatchPaintWindow()
void CheckCurrentGroup()
Let's see if the current Group (pCurrentGroup) is still inserted.
Definition: svdpagv.cxx:854
bool IsReadOnly() const
PV represents a RefPage or a SubList of a RefObj, or the Model is ReadOnly.
Definition: svdpagv.cxx:168
bool IsMapModeEnabled() const
SdrObject * GetObj(size_t nNum) const
Definition: svdpage.cxx:773
sal_Int32 GetRightBorder() const
Definition: svdpage.cxx:1502
bool IsInserted() const
Definition: svdobj.hxx:792
css::uno::Reference< css::awt::XControlContainer > const & GetControlContainer(bool _bCreateIfNecessary=true) const
tools::Rectangle GetPageRect() const
Definition: svdpagv.cxx:199
size_t GetObjCount() const
Definition: svdpage.cxx:767
void Insert(const SdrHelpLine &rHL)
Definition: svdhlpln.hxx:71
bool IsLayer(const OUString &rName, const SdrLayerIDSet &rBS) const
Definition: svdpagv.cxx:571
sal_Int16 nId
void GlueInvalidate() const
Definition: svdpntv.cxx:799
void Show()
Definition: svdpagv.cxx:173
const tools::Rectangle & GetUserArea() const
Definition: svdpage.hxx:288
void EnableMapMode(bool bEnable=true)
void SetApplicationDocumentColor(Color aDocumentColor)
Definition: svdpagv.cxx:886
SdrLayerIDSet aLayerVisi
Definition: svdpagv.hxx:72
const tools::Rectangle & GetPaperRect() const
Definition: svdpage.hxx:287
sal_Int32 GetLowerBorder() const
Definition: svdpage.cxx:1507
tools::Rectangle GetBoundRect(const OutputDevice &rOut) const
Definition: svdhlpln.cxx:58
SdrView & mrView
Definition: svdpagv.hxx:63
virtual SdrObjList * GetSubList() const
Definition: svdobj.cxx:674
sal_Int32 GetLeftBorder() const
Definition: svdpage.cxx:1492
bool IsVisible() const
Definition: svdobj.hxx:804
void CompleteRedraw(SdrPaintWindow &rPaintWindow, const vcl::Region &rReg, sdr::contact::ViewObjectContactRedirector *pRedirector)
Definition: svdpagv.cxx:231
void SetRedrawRegion(const vcl::Region &rNew)
bool IsEmpty() const
SdrPageWindow * FindPageWindow(SdrPaintWindow &rPaintWindow) const
Definition: svdpagv.cxx:53
constexpr::Color COL_AUTO(0xFF, 0xFF, 0xFF, 0xFF)
void RedrawLayer(const SdrLayerID *pId, sdr::contact::ViewObjectContactRedirector *pRedirector, basegfx::B2IRectangle const *)
SdrPageWindow * GetPageWindow(sal_uInt32 nIndex) const
Definition: svdpagv.cxx:93
long Right() const
void LeaveAllGroup()
Leave all object groups we entered previously.
Definition: svdpagv.cxx:811
void SetHelpLines(const SdrHelpLineList &rHLL)
Definition: svdpagv.cxx:674
SdrPage * getSdrPageFromSdrObject() const
Definition: svdobj.cxx:289
SdrHelpLineKind GetKind() const
Definition: svdhlpln.hxx:49
void setX(long nX)
void LeaveOneGroup()
Leave an object group we entered previously.
Definition: svdpagv.cxx:775
bool OutputToWindow() const
bool IsVisible() const
Definition: svdpagv.hxx:151
SdrPageView(SdrPage *pPage1, SdrView &rNewView)
Definition: svdpagv.cxx:98
int nCount
Color maBackgroundColor
Definition: svdpagv.hxx:85
void SetPageOrigin(const Point &rOrg)
Definition: svdpagv.cxx:640
long Top() const
constexpr SdrLayerID SDRLAYER_NOTFOUND(0xff)
const Point & GetPos() const
Definition: svdhlpln.hxx:51
void UnmarkAll()
Definition: svdview.cxx:1353
void setY(long nY)
sal_uInt32 PaintWindowCount() const
Definition: svdpntv.hxx:228
SdrObjList * GetObjList() const
Return current List.
Definition: svdpagv.hxx:174
void setPreparedPageWindow(SdrPageWindow *pKnownTarget)
Write access to mpPreparedPageWindow.
Definition: svdpagv.cxx:255
bool IsEmpty() const
Point aPgOrg
Definition: svdpagv.hxx:65
void SetLineColor()
virtual const SdrPageGridFrameList * GetGridFrameList(const SdrPageView *pPV, const tools::Rectangle *pRect) const
for snap-to-grid in Writer, also for AlignObjects if 1 object is marked if pRect != null...
Definition: svdpage.cxx:1643
void InvalidateAllWin()
Invalidates the Page's whole area.
Definition: svdpagv.cxx:205
uno_Any a
bool ImpIsGlueVisible()
Definition: svdpntv.hxx:250
sal_Int32 GetUpperBorder() const
Definition: svdpage.cxx:1497
int i
SdrObject * pCurrentGroup
Definition: svdpagv.hxx:77
const Color & GetLineColor() const
long Bottom() const
void AddPaintWindowToPageView(SdrPaintWindow &rPaintWindow)
Definition: svdpagv.cxx:134
bool IsGroupObject() const
Definition: svdobj.cxx:669
const SdrLayerAdmin & GetLayerAdmin() const
changing the layers does not set the modified-flag!
Definition: svdpage.cxx:1648
void Intersect(const tools::Rectangle &rRegion)
const vcl::Region & GetRedrawRegion() const
void DeleteHelpLine(sal_uInt16 nNum)
Definition: svdpagv.cxx:697
void Hide()
Definition: svdpagv.cxx:186
std::vector< std::unique_ptr< SdrPageWindow > > maPageWindows
Definition: svdpagv.hxx:87
Size GetOutputSizePixel() const
SdrPage * mpPage
Definition: svdpagv.hxx:64
Size maGridFin
Definition: svdpntv.hxx:146
Abstract DrawObject.
Definition: svdobj.hxx:312
DrawGridFlags
void RedrawAll(sdr::contact::ViewObjectContactRedirector *pRedirector)
void SetHelpLine(sal_uInt16 nNum, const SdrHelpLine &rNewHelpLine)
Definition: svdpagv.cxx:680
long X() const
void PrepareRedraw(const vcl::Region &rReg)
sal_uInt16 GetCount() const
Definition: svdhlpln.hxx:70
void patchPaintWindow(SdrPaintWindow &rPaintWindow)
sal_uInt16 GetCount() const
Definition: svdpage.hxx:303
virtual SdrLayerID GetLayer() const
Definition: svdobj.cxx:604
bool IsMarkProtect() const
Definition: svdobj.hxx:806
Point PixelToLogic(const Point &rDevicePt) const
void DrawPageViewGrid(OutputDevice &rOut, const tools::Rectangle &rRect, Color aColor=COL_BLACK)
Definition: svdpagv.cxx:360
bool IsSet(SdrLayerID a) const
Definition: svdsob.hxx:66
sal_uInt16 GetEnteredLevel() const
Determine, how deep we descended (0 = Root(Page))
Definition: svdpagv.cxx:843
Color maBackgroundColor
tools::Rectangle & Union(const tools::Rectangle &rRect)
void SetLayer(const OUString &rName, SdrLayerIDSet &rBS, bool bJa)
Definition: svdpagv.cxx:560
SdrPageWindow * mpPreparedPageWindow
Definition: svdpagv.hxx:91
SdrPage * GetPage() const
Definition: svdpagv.hxx:171
Size maGridBig
Definition: svdpntv.hxx:145
SlideSorterView & mrView
void InvalidateAllWin()
Definition: svdpntv.cxx:827
void SetCurrentGroupAndList(SdrObject *pNewGroup, SdrObjList *pNewList)
Set current Group and List.
Definition: svdpagv.cxx:714
void AdjustMarkHdl(SfxViewShell *pOtherShell=nullptr)
Definition: svdmrkv.cxx:2338
SdrLayerIDSet aLayerPrn
Definition: svdpagv.hxx:74
SdrPaintWindow & GetPaintWindow() const
void DrawGrid(const tools::Rectangle &rRect, const Size &rDist, DrawGridFlags nFlags)
SdrHelpLineList aHelpLines
Definition: svdpagv.hxx:79
void DrawLayer(SdrLayerID nID, OutputDevice *pGivenTarget, sdr::contact::ViewObjectContactRedirector *pRedirector=nullptr, const tools::Rectangle &rRect=tools::Rectangle(), basegfx::B2IRectangle const *pPageFrame=nullptr)
Definition: svdpagv.cxx:261
void ModelHasChanged()
Is called by PaintView, when modal changes have finished.
Definition: svdpagv.cxx:163
void SetDesignMode(bool _bDesignMode) const
Sets all elements in the view which support a design and an alive mode into the given mode...
Definition: svdpagv.cxx:350
void PrePaint()
PrePaint call forwarded from app windows.
Definition: svdpagv.cxx:216
long Left() const
SdrObject * getParentSdrObjectFromSdrObject() const
Definition: svdobj.cxx:679
css::uno::Reference< css::awt::XControlContainer > GetControlContainer(const OutputDevice &_rDevice) const
Looks up the control container belonging to given output device.
Definition: svdpagv.cxx:152
bool EnterGroup(SdrObject *pObj)
Entering (editing) an object group After that, we have direct access to all member objects of the gro...
Definition: svdpagv.cxx:726
bool MarkObj(const Point &rPnt, short nTol=-2, bool bToggle=false, bool bDeep=false)
Definition: svdmrkv.cxx:1668
SdrLayerIDSet aLayerLock
Definition: svdpagv.hxx:73
A SdrPage contains exactly one SdrObjList and a description of the physical page dimensions (size / m...
Definition: svdpage.hxx:366
void Delete(sal_uInt16 nPos)
Definition: svdhlpln.hxx:79
sal_Int32 GetWidth() const
Definition: svdpage.cxx:1391
SdrObjList * getParentSdrObjListFromSdrObject() const
Definition: svdobj.cxx:325
SdrLayerID GetLayerID(const OUString &rName) const
Definition: svdlayer.cxx:230
bool mbHasMarked
Definition: svdpagv.hxx:69
bool Is3DObj() const
Definition: svdobj.hxx:795
Color maDocumentColor
Definition: svdpagv.hxx:82
OutputDevice & GetOutputDevice() const
SdrPaintWindow * GetPaintWindow(sal_uInt32 nIndex) const
Definition: svdpntv.cxx:77
bool IsObjMarkable(SdrObject const *pObj) const
At least one member must be visible for the Group object and it must not be locked.
Definition: svdpagv.cxx:591
long Y() const
bool mbVisible
Definition: svdpagv.hxx:70
void SetDesignMode(bool _bDesignMode) const
sets all elements in the view which support a design and an alive mode into the given mode ...
SdrObject * GetCurrentGroup() const
Return current Group.
Definition: svdpagv.hxx:177
sal_uInt32 PageWindowCount() const
Definition: svdpagv.hxx:94