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 = 0;
443  tools::Long x2 = 0;
444  if (GetPage()->GetWidth() < 0) // ScDrawPage of RTL sheet
445  {
446  x1 = GetPage()->GetWidth() + GetPage()->GetLeftBorder() + 1;
447  x2 = - GetPage()->GetRightBorder() - 1;
448  }
449  else
450  {
451  x1 = GetPage()->GetLeftBorder() + 1;
452  x2 = GetPage()->GetWidth() - GetPage()->GetRightBorder() - 1;
453  }
454  tools::Long y1 = GetPage()->GetUpperBorder() + 1;
455  tools::Long y2 = GetPage()->GetHeight() - GetPage()->GetLowerBorder() - 1;
456  const SdrPageGridFrameList* pFrames=GetPage()->GetGridFrameList(this,nullptr);
457 
458  sal_uInt16 nGridPaintCnt=1;
459  if (pFrames!=nullptr) nGridPaintCnt=pFrames->GetCount();
460  for (sal_uInt16 nGridPaintNum=0; nGridPaintNum<nGridPaintCnt; nGridPaintNum++) {
461  if (pFrames!=nullptr) {
462  const SdrPageGridFrame& rGF=(*pFrames)[nGridPaintNum];
463  nWrX=rGF.GetPaperRect().Left();
464  nWrY=rGF.GetPaperRect().Top();
465  x1=rGF.GetUserArea().Left();
466  x2=rGF.GetUserArea().Right();
467  y1=rGF.GetUserArea().Top();
468  y2=rGF.GetUserArea().Bottom();
469  aOrg=rGF.GetUserArea().TopLeft();
470  aOrg-=rGF.GetPaperRect().TopLeft();
471  }
472  if (!rRect.IsEmpty()) {
473  Size a1PixSiz(rOut.PixelToLogic(Size(1,1)));
474  tools::Long nX1Pix=a1PixSiz.Width(); // add 1 pixel of tolerance
475  tools::Long nY1Pix=a1PixSiz.Height();
476  if (x1<rRect.Left() -nX1Pix) x1=rRect.Left() -nX1Pix;
477  if (x2>rRect.Right() +nX1Pix) x2=rRect.Right() +nX1Pix;
478  if (y1<rRect.Top() -nY1Pix) y1=rRect.Top() -nY1Pix;
479  if (y2>rRect.Bottom()+nY1Pix) y2=rRect.Bottom()+nY1Pix;
480  }
481 
482  tools::Long xBigOrg=aOrg.X()+nWrX;
483  while (xBigOrg>=x1) xBigOrg-=nx1;
484  while (xBigOrg<x1) xBigOrg+=nx1;
485  tools::Long xFinOrg=xBigOrg;
486  while (xFinOrg>=x1) xFinOrg-=nx2;
487  while (xFinOrg<x1) xFinOrg+=nx2;
488 
489  tools::Long yBigOrg=aOrg.Y()+nWrY;
490  while (yBigOrg>=y1) yBigOrg-=ny1;
491  while (yBigOrg<y1) yBigOrg+=ny1;
492  tools::Long yFinOrg=yBigOrg;
493  while (yFinOrg>=y1) yFinOrg-=ny2;
494  while (yFinOrg<y1) yFinOrg+=ny2;
495 
496  if( x1 <= x2 && y1 <= y2 )
497  {
498  if( bHoriLines )
499  {
500  DrawGridFlags nGridFlags = ( bHoriSolid ? DrawGridFlags::HorzLines : DrawGridFlags::Dots );
501  sal_uInt16 nSteps = sal_uInt16(nx1 / nx2);
502  sal_uInt32 nRestPerStepMul1000 = nSteps ? ( ((nx1 * 1000)/ nSteps) - (nx2 * 1000) ) : 0;
503  sal_uInt32 nStepOffset = 0;
504  sal_uInt16 nPointOffset = 0;
505 
506  for(sal_uInt16 a=0;a<nSteps;a++)
507  {
508  // draw
509  rOut.DrawGrid(
510  tools::Rectangle( xFinOrg + (a * nx2) + nPointOffset, yBigOrg, x2, y2 ),
511  Size( nx1, ny1 ), nGridFlags );
512 
513  // do a step
514  nStepOffset += nRestPerStepMul1000;
515  while(nStepOffset >= 1000)
516  {
517  nStepOffset -= 1000;
518  nPointOffset++;
519  }
520  }
521  }
522 
523  if( bVertLines )
524  {
525  DrawGridFlags nGridFlags = ( bVertSolid ? DrawGridFlags::VertLines : DrawGridFlags::Dots );
526  sal_uInt16 nSteps = sal_uInt16(ny1 / ny2);
527  sal_uInt32 nRestPerStepMul1000 = nSteps ? ( ((ny1 * 1000L)/ nSteps) - (ny2 * 1000L) ) : 0;
528  sal_uInt32 nStepOffset = 0;
529  sal_uInt16 nPointOffset = 0;
530 
531  for(sal_uInt16 a=0;a<nSteps;a++)
532  {
533  // draw
534  rOut.DrawGrid(
535  tools::Rectangle( xBigOrg, yFinOrg + (a * ny2) + nPointOffset, x2, y2 ),
536  Size( nx1, ny1 ), nGridFlags );
537 
538  // do a step
539  nStepOffset += nRestPerStepMul1000;
540  while(nStepOffset >= 1000)
541  {
542  nStepOffset -= 1000;
543  nPointOffset++;
544  }
545  }
546  }
547  }
548  }
549 
550  rOut.EnableMapMode(bMap0);
551  rOut.SetLineColor(aOriginalLineColor);
552 }
553 
555 {
557 }
558 
559 void SdrPageView::SetLayer(const OUString& rName, SdrLayerIDSet& rBS, bool bJa)
560 {
561  if(!GetPage())
562  return;
563 
564  SdrLayerID nID = GetPage()->GetLayerAdmin().GetLayerID(rName);
565 
566  if(SDRLAYER_NOTFOUND != nID)
567  rBS.Set(nID, bJa);
568 }
569 
570 bool SdrPageView::IsLayer(const OUString& rName, const SdrLayerIDSet& rBS) const
571 {
572  if(!GetPage())
573  return false;
574 
575  bool bRet(false);
576 
577  if (!rName.isEmpty())
578  {
580 
581  if(SDRLAYER_NOTFOUND != nId)
582  {
583  bRet = rBS.IsSet(nId);
584  }
585  }
586 
587  return bRet;
588 }
589 
590 bool SdrPageView::IsObjMarkable(SdrObject const * pObj) const
591 {
592  if (!pObj)
593  return false;
594  if (pObj->IsMarkProtect())
595  return false; // excluded from selection?
596  if (!pObj->IsVisible())
597  return false; // only visible are selectable
598  if (!pObj->IsInserted())
599  return false; // Obj deleted?
600  if (auto pObjGroup = dynamic_cast<const SdrObjGroup*>(pObj))
601  {
602  // If object is a Group object, visibility may depend on
603  // multiple layers. If one object is markable, Group is markable.
604  SdrObjList* pObjList = pObjGroup->GetSubList();
605 
606  if (pObjList && pObjList->GetObjCount())
607  {
608  for (size_t a = 0; a < pObjList->GetObjCount(); ++a)
609  {
610  SdrObject* pCandidate = pObjList->GetObj(a);
611  // call recursively
612  if (IsObjMarkable(pCandidate))
613  return true;
614  }
615  return false;
616  }
617  else
618  {
619  // #i43302#
620  // Allow empty groups to be selected to be able to delete them
621  return true;
622  }
623  }
624  if (!pObj->Is3DObj() && pObj->getSdrPageFromSdrObject() != GetPage())
625  {
626  // Obj suddenly in different Page
627  return false;
628  }
629 
630  // the layer has to be visible and must not be locked
631  SdrLayerID nL = pObj->GetLayer();
632  if (!aLayerVisi.IsSet(nL))
633  return false;
634  if (aLayerLock.IsSet(nL))
635  return false;
636  return true;
637 }
638 
639 void SdrPageView::SetPageOrigin(const Point& rOrg)
640 {
641  if (rOrg!=aPgOrg) {
642  aPgOrg=rOrg;
643  if (GetView().IsGridVisible()) {
645  }
646  }
647 }
648 
649 void SdrPageView::ImpInvalidateHelpLineArea(sal_uInt16 nNum) const
650 {
651  if (!(GetView().IsHlplVisible() && nNum<aHelpLines.GetCount())) return;
652 
653  const SdrHelpLine& rHL=aHelpLines[nNum];
654 
655  for(sal_uInt32 a(0); a < GetView().PaintWindowCount(); a++)
656  {
657  SdrPaintWindow* pCandidate = GetView().GetPaintWindow(a);
658 
659  if(pCandidate->OutputToWindow())
660  {
661  OutputDevice& rOutDev = pCandidate->GetOutputDevice();
662  tools::Rectangle aR(rHL.GetBoundRect(rOutDev));
663  Size aSiz(rOutDev.PixelToLogic(Size(1,1)));
664  aR.AdjustLeft( -(aSiz.Width()) );
665  aR.AdjustRight(aSiz.Width() );
666  aR.AdjustTop( -(aSiz.Height()) );
667  aR.AdjustBottom(aSiz.Height() );
668  const_cast<SdrView&>(GetView()).InvalidateOneWin(rOutDev, aR);
669  }
670  }
671 }
672 
674 {
675  aHelpLines=rHLL;
677 }
678 
679 void SdrPageView::SetHelpLine(sal_uInt16 nNum, const SdrHelpLine& rNewHelpLine)
680 {
681  if (nNum >= aHelpLines.GetCount() || aHelpLines[nNum] == rNewHelpLine)
682  return;
683 
684  bool bNeedRedraw = true;
685  if (aHelpLines[nNum].GetKind()==rNewHelpLine.GetKind()) {
686  switch (rNewHelpLine.GetKind()) {
687  case SdrHelpLineKind::Vertical : if (aHelpLines[nNum].GetPos().X()==rNewHelpLine.GetPos().X()) bNeedRedraw = false; break;
688  case SdrHelpLineKind::Horizontal: if (aHelpLines[nNum].GetPos().Y()==rNewHelpLine.GetPos().Y()) bNeedRedraw = false; break;
689  default: break;
690  } // switch
691  }
692  if (bNeedRedraw) ImpInvalidateHelpLineArea(nNum);
693  aHelpLines[nNum]=rNewHelpLine;
694  if (bNeedRedraw) ImpInvalidateHelpLineArea(nNum);
695 }
696 
697 void SdrPageView::DeleteHelpLine(sal_uInt16 nNum)
698 {
699  if (nNum<aHelpLines.GetCount()) {
701  aHelpLines.Delete(nNum);
702  }
703 }
704 
706 {
707  sal_uInt16 nNum = aHelpLines.GetCount();
708  aHelpLines.Insert(rHL,nNum);
709  if (GetView().IsHlplVisible())
711 }
712 
713 // set current group and list
715 {
716  if(pCurrentGroup != pNewGroup)
717  {
718  pCurrentGroup = pNewGroup;
719  }
720  if(pCurrentList != pNewList)
721  {
722  pCurrentList = pNewList;
723  }
724 }
725 
727 {
728  bool bRet(false);
729 
730  if(pObj && pObj->IsGroupObject())
731  {
732  bool bGlueInvalidate(GetView().ImpIsGlueVisible());
733 
734  if(bGlueInvalidate)
735  {
737  }
738 
739  // deselect all
740  GetView().UnmarkAll();
741 
742  // set current group and list
743  SdrObjList* pNewObjList = pObj->GetSubList();
744  SetCurrentGroupAndList(pObj, pNewObjList);
745 
746  // select contained object if only one object is contained,
747  // else select nothing and let the user decide what to do next
748  if(pNewObjList && pNewObjList->GetObjCount() == 1)
749  {
750  SdrObject* pFirstObject = pNewObjList->GetObj(0);
751 
752  if(GetView().GetSdrPageView())
753  {
754  GetView().MarkObj(pFirstObject, GetView().GetSdrPageView());
755  }
756  }
757 
758  // build new handles
760 
761  // invalidate only when view wants to visualize group entering
763 
764  if (bGlueInvalidate)
765  {
767  }
768 
769  bRet = true;
770  }
771 
772  return bRet;
773 }
774 
776 {
777  SdrObject* pLastGroup = GetCurrentGroup();
778  if (!pLastGroup)
779  return;
780 
781  bool bGlueInvalidate = GetView().ImpIsGlueVisible();
782 
783  if(bGlueInvalidate)
785 
786  SdrObject* pParentGroup = pLastGroup->getParentSdrObjectFromSdrObject();
787  SdrObjList* pParentList = GetPage();
788 
789  if(pParentGroup)
790  pParentList = pParentGroup->GetSubList();
791 
792  // deselect everything
793  GetView().UnmarkAll();
794 
795  // allocations, pCurrentGroup and pCurrentList need to be set
796  SetCurrentGroupAndList(pParentGroup, pParentList);
797 
798  // select the group we just left
799  if (GetView().GetSdrPageView())
800  GetView().MarkObj(pLastGroup, GetView().GetSdrPageView());
801 
803 
804  // invalidate only if view wants to visualize group entering
806 
807  if(bGlueInvalidate)
809 }
810 
812 {
813  SdrObject* pLastGroup = GetCurrentGroup();
814  if (!pLastGroup)
815  return;
816 
817  bool bGlueInvalidate = GetView().ImpIsGlueVisible();
818 
819  if(bGlueInvalidate)
821 
822  // deselect everything
823  GetView().UnmarkAll();
824 
825  // allocations, pCurrentGroup and pCurrentList always need to be set
826  SetCurrentGroupAndList(nullptr, GetPage());
827 
828  // find and select uppermost group
829  while (pLastGroup->getParentSdrObjectFromSdrObject())
830  pLastGroup = pLastGroup->getParentSdrObjectFromSdrObject();
831 
832  if (GetView().GetSdrPageView())
833  GetView().MarkObj(pLastGroup, GetView().GetSdrPageView());
834 
836 
837  // invalidate only when view wants to visualize group entering
839 
840  if(bGlueInvalidate)
842 }
843 
845 {
846  sal_uInt16 nCount=0;
847  SdrObject* pGrp=GetCurrentGroup();
848  while (pGrp!=nullptr) {
849  nCount++;
850  pGrp=pGrp->getParentSdrObjectFromSdrObject();
851  }
852  return nCount;
853 }
854 
856 {
857  SdrObject* pGrp(GetCurrentGroup());
858 
859  while(nullptr != pGrp &&
860  (!pGrp->IsInserted() || nullptr == pGrp->getParentSdrObjListFromSdrObject() || nullptr == pGrp->getSdrPageFromSdrObject()))
861  {
862  // anything outside of the borders?
863  pGrp = pGrp->getParentSdrObjectFromSdrObject();
864  }
865 
866  if(pGrp != GetCurrentGroup())
867  {
868  if(nullptr != pGrp)
869  {
870  EnterGroup(pGrp);
871  }
872  else
873  {
874  LeaveAllGroup();
875  }
876  }
877 }
878 
879 // Set background color for svx at SdrPageViews
881 {
882  maBackgroundColor = aBackgroundColor;
883 }
884 
885 
886 // Set document color for svx at SdrPageViews
888 {
889  maDocumentColor = aDocumentColor;
890 }
891 
892 
893 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void ImpInvalidateHelpLineArea(sal_uInt16 nNum) const
Definition: svdpagv.cxx:649
Point TopLeft() const
void AdjHdl()
Definition: svdpagv.cxx:554
void Set(SdrLayerID a)
Definition: svdsob.hxx:48
void InsertHelpLine(const SdrHelpLine &rHL)
Definition: svdpagv.cxx:705
const SdrPageWindow * FindPatchedPageWindow(const OutputDevice &rOutDev) const
Finds the page window whose PaintWindow belongs to the given output device In opposite to FindPageWin...
Definition: svdpagv.cxx:55
sal_Int32 GetHeight() const
Definition: svdpage.cxx:1392
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:880
long Long
void SetAll()
Definition: svdsob.hxx:71
void CheckCurrentGroup()
Let's see if the current Group (pCurrentGroup) is still inserted.
Definition: svdpagv.cxx:855
constexpr::Color COL_AUTO(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
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:1477
bool IsInserted() const
Definition: svdobj.hxx:744
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:570
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:887
SdrLayerIDSet aLayerVisi
Definition: svdpagv.hxx:72
const tools::Rectangle & GetPaperRect() const
Definition: svdpage.hxx:286
sal_Int32 GetLowerBorder() const
Definition: svdpage.cxx:1482
tools::Rectangle GetBoundRect(const OutputDevice &rOut) const
Definition: svdhlpln.cxx:55
SdrView & mrView
Definition: svdpagv.hxx:63
virtual SdrObjList * GetSubList() const
Definition: svdobj.cxx:718
sal_Int32 GetLeftBorder() const
Definition: svdpage.cxx:1467
bool IsVisible() const
Definition: svdobj.hxx:756
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
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:811
void SetHelpLines(const SdrHelpLineList &rHLL)
Definition: svdpagv.cxx:673
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:775
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:639
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:1618
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:1472
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:713
const SdrLayerAdmin & GetLayerAdmin() const
changing the layers does not set the modified-flag!
Definition: svdpage.cxx:1623
void Intersect(const tools::Rectangle &rRegion)
const vcl::Region & GetRedrawRegion() const
void DeleteHelpLine(sal_uInt16 nNum)
Definition: svdpagv.cxx:697
void Hide()
Definition: svdpagv.cxx: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:679
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:648
bool IsMarkProtect() const
Definition: svdobj.hxx:758
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:844
Color maBackgroundColor
tools::Rectangle & Union(const tools::Rectangle &rRect)
void SetLayer(const OUString &rName, SdrLayerIDSet &rBS, bool bJa)
Definition: svdpagv.cxx:559
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:714
void AdjustMarkHdl(SfxViewShell *pOtherShell=nullptr)
Definition: svdmrkv.cxx:2438
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:723
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:726
bool MarkObj(const Point &rPnt, short nTol=-2, bool bToggle=false, bool bDeep=false)
Definition: svdmrkv.cxx:1762
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:1366
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:747
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:590
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