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