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