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