LibreOffice Module svx (master)  1
svdogrp.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/svdogrp.hxx>
21 
22 #include <svx/svdmodel.hxx>
23 #include <svx/svdpage.hxx>
24 #include <svx/svdobj.hxx>
25 #include <svx/svdtrans.hxx>
26 #include <svx/dialmgr.hxx>
27 #include <svx/strings.hrc>
28 
33 #include <libxml/xmlwriter.h>
34 #include <vcl/canvastools.hxx>
36 
37 const std::shared_ptr< svx::diagram::IDiagramHelper >& SdrObjGroup::getDiagramHelper() const
38 {
39  return mp_DiagramHelper;
40 }
41 
42 // BaseProperties section
43 std::unique_ptr<sdr::properties::BaseProperties> SdrObjGroup::CreateObjectSpecificProperties()
44 {
45  return std::make_unique<sdr::properties::GroupProperties>(*this);
46 }
47 
48 // DrawContact section
49 std::unique_ptr<sdr::contact::ViewContact> SdrObjGroup::CreateObjectSpecificViewContact()
50 {
51  return std::make_unique<sdr::contact::ViewContactOfGroup>(*this);
52 }
53 
55 : SdrObject(rSdrModel)
56 , SdrObjList()
57 , maRefPoint(0, 0)
58 , mp_DiagramHelper()
59 {
60  m_bClosedObj=false;
61 }
62 
63 SdrObjGroup::SdrObjGroup(SdrModel& rSdrModel, SdrObjGroup const & rSource)
64 : SdrObject(rSdrModel, rSource)
65 , SdrObjList()
66 , maRefPoint(0, 0)
67 , mp_DiagramHelper()
68 {
69  m_bClosedObj=false;
70 
71  // copy child SdrObjects
72  if(nullptr != rSource.GetSubList())
73  {
74  // #i36404# Copy SubList, init model and page first
75  const SdrObjList& rSourceSubList(*rSource.GetSubList());
76 
77  CopyObjects(rSourceSubList);
78 
79  // tdf#116979: needed here, we need bSnapRectDirty to be true
80  // which it is after using SdrObject::operator= (see above),
81  // but set to false again using CopyObjects
83  }
84 
85  // copy local parameters
86  maRefPoint = rSource.maRefPoint;
87 }
88 
90 {
91  // only for diagram, so do nothing for just groups
92  if(!isDiagram())
93  return;
94 
96 }
97 
99 {
100 }
101 
103 {
104  return getSdrPageFromSdrObject();
105 }
106 
108 {
109  return const_cast< SdrObjGroup* >(this);
110 }
111 
113 {
114  return const_cast< SdrObjGroup* >(this);
115 }
116 
118 {
119  rInfo.bNoContortion=false;
120  const size_t nObjCount(GetObjCount());
121  for (size_t i=0; i<nObjCount; ++i) {
122  SdrObject* pObj(GetObj(i));
124  pObj->TakeObjInfo(aInfo);
125  if (!aInfo.bMoveAllowed ) rInfo.bMoveAllowed =false;
126  if (!aInfo.bResizeFreeAllowed ) rInfo.bResizeFreeAllowed =false;
127  if (!aInfo.bResizePropAllowed ) rInfo.bResizePropAllowed =false;
128  if (!aInfo.bRotateFreeAllowed ) rInfo.bRotateFreeAllowed =false;
129  if (!aInfo.bRotate90Allowed ) rInfo.bRotate90Allowed =false;
130  if (!aInfo.bMirrorFreeAllowed ) rInfo.bMirrorFreeAllowed =false;
131  if (!aInfo.bMirror45Allowed ) rInfo.bMirror45Allowed =false;
132  if (!aInfo.bMirror90Allowed ) rInfo.bMirror90Allowed =false;
133  if (!aInfo.bShearAllowed ) rInfo.bShearAllowed =false;
134  if (!aInfo.bEdgeRadiusAllowed ) rInfo.bEdgeRadiusAllowed =false;
135  if (!aInfo.bNoOrthoDesired ) rInfo.bNoOrthoDesired =false;
136  if (aInfo.bNoContortion ) rInfo.bNoContortion =true;
137  if (!aInfo.bCanConvToPath ) rInfo.bCanConvToPath =false;
138 
139  if(!aInfo.bCanConvToContour)
140  rInfo.bCanConvToContour = false;
141 
142  if (!aInfo.bCanConvToPoly ) rInfo.bCanConvToPoly =false;
143  if (!aInfo.bCanConvToPathLineToArea) rInfo.bCanConvToPathLineToArea=false;
144  if (!aInfo.bCanConvToPolyLineToArea) rInfo.bCanConvToPolyLineToArea=false;
145  }
146  if (nObjCount==0) {
147  rInfo.bRotateFreeAllowed=false;
148  rInfo.bRotate90Allowed =false;
149  rInfo.bMirrorFreeAllowed=false;
150  rInfo.bMirror45Allowed =false;
151  rInfo.bMirror90Allowed =false;
152  rInfo.bTransparenceAllowed = false;
153  rInfo.bShearAllowed =false;
154  rInfo.bEdgeRadiusAllowed=false;
155  rInfo.bNoContortion =true;
156  }
157  if(nObjCount != 1)
158  {
159  // only allowed if single object selected
160  rInfo.bTransparenceAllowed = false;
161  }
162 }
163 
165 {
166  // avoid resetting aOutRect which in case of this object is model data,
167  // not re-creatable view data
168 }
169 
171 {
172  return SdrObjKind::Group;
173 }
174 
176 {
177  bool b1st = true;
179  const size_t nObjCount(GetObjCount());
180  for (size_t i=0; i<nObjCount; ++i) {
181  SdrLayerID nLay1(GetObj(i)->GetLayer());
182  if (b1st) { nLay=nLay1; b1st = false; }
183  else if (nLay1!=nLay) return SdrLayerID(0);
184  }
185  return nLay;
186 }
187 
189 {
190  SdrObject::NbcSetLayer(nLayer);
191  const size_t nObjCount(GetObjCount());
192  for (size_t i=0; i<nObjCount; ++i) {
193  GetObj(i)->NbcSetLayer(nLayer);
194  }
195 }
196 
198 {
199  // call parent
200  SdrObject::handlePageChange(pOldPage, pNewPage);
201 
202  for(size_t i(0); i < GetObjCount(); i++)
203  {
204  GetObj(i)->handlePageChange(pOldPage, pNewPage);
205  }
206 }
207 
209 {
210  return const_cast< SdrObjGroup* >(this);
211 }
212 
213 static bool containsOOXData(const css::uno::Any& rVal)
214 {
215  const css::uno::Sequence<css::beans::PropertyValue>& propList(rVal.get< css::uno::Sequence<css::beans::PropertyValue> >());
216  for (const auto& rProp : std::as_const(propList))
217  {
218  if(rProp.Name.startsWith("OOX"))
219  {
220  return true;
221  }
222  }
223 
224  return false;
225 }
226 
227 void SdrObjGroup::SetGrabBagItem(const css::uno::Any& rVal)
228 {
229  // detect if the intention is to disable Diagram functionality
230  if(isDiagram() && !containsOOXData(rVal))
231  {
232  css::uno::Any aOld;
233  GetGrabBagItem(aOld);
234 
235  if(containsOOXData(aOld))
236  {
237  mp_DiagramHelper.reset();
238  }
239  }
240 
241  // call parent
243 }
244 
246 {
247  // <aOutRect> has to contain the bounding rectangle
248  if(0 != GetObjCount())
249  {
251  }
252 
253  return m_aOutRect;
254 }
255 
257 {
258  // <aOutRect> has to contain the bounding rectangle
259  if(0 != GetObjCount())
260  {
261  return GetAllObjSnapRect();
262  }
263  else
264  {
265  return m_aOutRect;
266  }
267 }
268 
270 {
271  return new SdrObjGroup(rTargetModel, *this);
272 }
273 
275 {
276  OUString sName;
277 
278  if(0 == GetObjCount())
279  {
280  sName = SvxResId(STR_ObjNameSingulGRUPEMPTY);
281  }
282  else
283  {
284  if(isDiagram())
285  sName = SvxResId(STR_ObjNameSingulDIAGRAM);
286  else
287  sName = SvxResId(STR_ObjNameSingulGRUP);
288  }
289 
290  const OUString aName(GetName());
291 
292  if (!aName.isEmpty())
293  sName += " '" + aName + "'";
294 
295  return sName;
296 }
297 
298 
300 {
301  if(0 == GetObjCount())
302  return SvxResId(STR_ObjNamePluralGRUPEMPTY);
303  if(isDiagram())
304  return SvxResId(RID_GALLERYSTR_THEME_DIAGRAMS);
305  return SvxResId(STR_ObjNamePluralGRUP);
306 }
307 
308 
310 {
311  // TODO: unnecessary, because we use the Rects from the SubList
312 }
313 
315 {
316  basegfx::B2DPolyPolygon aRetval;
317  const size_t nObjCount(GetObjCount());
318 
319  for(size_t a = 0; a < nObjCount; ++a)
320  {
321  SdrObject* pObj(GetObj(a));
322  aRetval.append(pObj->TakeXorPoly());
323  }
324 
325  if(!aRetval.count())
326  {
329  }
330 
331  return aRetval;
332 }
333 
335 {
336  return false;
337 }
338 
339 
341 {
342  return false;
343 }
344 
345 
347 {
348  Degree100 nRetval(0);
349 
350  if(0 != GetObjCount())
351  {
352  SdrObject* pObj(GetObj(0));
353 
354  nRetval = pObj->GetRotateAngle();
355  }
356 
357  return nRetval;
358 }
359 
360 
361 Degree100 SdrObjGroup::GetShearAngle(bool /*bVertical*/) const
362 {
363  Degree100 nRetval(0);
364 
365  if(0 != GetObjCount())
366  {
367  SdrObject* pObj(GetObj(0));
368 
369  nRetval = pObj->GetShearAngle();
370  }
371 
372  return nRetval;
373 }
374 
375 
377 {
379  tools::Long nMulX=rRect.Right()-rRect.Left();
380  tools::Long nDivX=aOld.Right()-aOld.Left();
381  tools::Long nMulY=rRect.Bottom()-rRect.Top();
382  tools::Long nDivY=aOld.Bottom()-aOld.Top();
383  if (nDivX==0) { nMulX=1; nDivX=1; }
384  if (nDivY==0) { nMulY=1; nDivY=1; }
385  if (nMulX!=nDivX || nMulY!=nDivY) {
386  Fraction aX(nMulX,nDivX);
387  Fraction aY(nMulY,nDivY);
388  NbcResize(aOld.TopLeft(),aX,aY);
389  }
390  if (rRect.Left()!=aOld.Left() || rRect.Top()!=aOld.Top()) {
391  NbcMove(Size(rRect.Left()-aOld.Left(),rRect.Top()-aOld.Top()));
392  }
393 }
394 
395 
397 {
398  NbcSetSnapRect(rRect);
399 }
400 
401 
402 void SdrObjGroup::NbcMove(const Size& rSiz)
403 {
404  maRefPoint.Move(rSiz);
405  const size_t nObjCount(GetObjCount());
406 
407  if(0 != nObjCount)
408  {
409  for (size_t i=0; i<nObjCount; ++i)
410  {
411  SdrObject* pObj(GetObj(i));
412  pObj->NbcMove(rSiz);
413  }
414  }
415  else
416  {
417  m_aOutRect.Move(rSiz);
419  }
420 }
421 
422 
423 void SdrObjGroup::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact)
424 {
425  bool bXMirr=(xFact.GetNumerator()<0) != (xFact.GetDenominator()<0);
426  bool bYMirr=(yFact.GetNumerator()<0) != (yFact.GetDenominator()<0);
427  if (bXMirr || bYMirr) {
428  Point aRef1(GetSnapRect().Center());
429  if (bXMirr) {
430  Point aRef2(aRef1);
431  aRef2.AdjustY( 1 );
432  NbcMirrorGluePoints(aRef1,aRef2);
433  }
434  if (bYMirr) {
435  Point aRef2(aRef1);
436  aRef2.AdjustX( 1 );
437  NbcMirrorGluePoints(aRef1,aRef2);
438  }
439  }
440 
441  ResizePoint(maRefPoint, rRef, xFact, yFact);
442 
443  const size_t nObjCount(GetObjCount());
444  if(0 != nObjCount)
445  {
446  for (size_t i=0; i<nObjCount; ++i)
447  {
448  SdrObject* pObj(GetObj(i));
449  pObj->NbcResize(rRef,xFact,yFact);
450  }
451  }
452  else
453  {
454  ResizeRect(m_aOutRect,rRef,xFact,yFact);
456  }
457 }
458 
459 
460 void SdrObjGroup::NbcRotate(const Point& rRef, Degree100 nAngle, double sn, double cs)
461 {
462  SetGlueReallyAbsolute(true);
463  RotatePoint(maRefPoint, rRef, sn, cs);
464  const size_t nObjCount(GetObjCount());
465 
466  for (size_t i=0; i<nObjCount; ++i)
467  {
468  SdrObject* pObj(GetObj(i));
469  pObj->NbcRotate(rRef,nAngle,sn,cs);
470  }
471 
472  NbcRotateGluePoints(rRef,nAngle,sn,cs);
473  SetGlueReallyAbsolute(false);
474 }
475 
476 
477 void SdrObjGroup::NbcMirror(const Point& rRef1, const Point& rRef2)
478 {
479  SetGlueReallyAbsolute(true);
480  MirrorPoint(maRefPoint, rRef1, rRef2); // implementation missing in SvdEtc!
481  const size_t nObjCount(GetObjCount());
482 
483  for (size_t i=0; i<nObjCount; ++i)
484  {
485  SdrObject* pObj(GetObj(i));
486  pObj->NbcMirror(rRef1,rRef2);
487  }
488 
489  NbcMirrorGluePoints(rRef1,rRef2);
490  SetGlueReallyAbsolute(false);
491 }
492 
493 
494 void SdrObjGroup::NbcShear(const Point& rRef, Degree100 nAngle, double tn, bool bVShear)
495 {
496  SetGlueReallyAbsolute(true);
497  ShearPoint(maRefPoint, rRef, tn);
498  const size_t nObjCount(GetObjCount());
499 
500  for (size_t i=0; i<nObjCount; ++i)
501  {
502  SdrObject* pObj(GetObj(i));
503  pObj->NbcShear(rRef,nAngle,tn,bVShear);
504  }
505 
506  NbcShearGluePoints(rRef,tn,bVShear);
507  SetGlueReallyAbsolute(false);
508 }
509 
510 
511 void SdrObjGroup::NbcSetAnchorPos(const Point& rPnt)
512 {
513  m_aAnchor=rPnt;
514  Size aSiz(rPnt.X()-m_aAnchor.X(),rPnt.Y()-m_aAnchor.Y());
515  maRefPoint.Move(aSiz);
516  const size_t nObjCount(GetObjCount());
517 
518  for (size_t i=0; i<nObjCount; ++i)
519  {
520  SdrObject* pObj(GetObj(i));
521  pObj->NbcSetAnchorPos(rPnt);
522  }
523 }
524 
525 
527 {
528  tools::Rectangle aBoundRect0; if (m_pUserCall!=nullptr) aBoundRect0=GetLastBoundRect();
530  if (aOld.IsEmpty())
531  {
532  Fraction aX(1,1);
533  Fraction aY(1,1);
534  Resize(aOld.TopLeft(),aX,aY);
535  }
536  else
537  {
538  tools::Long nMulX=rRect.Right()-rRect.Left();
539  tools::Long nDivX=aOld.Right()-aOld.Left();
540  tools::Long nMulY=rRect.Bottom()-rRect.Top();
541  tools::Long nDivY=aOld.Bottom()-aOld.Top();
542  if (nDivX==0) { nMulX=1; nDivX=1; }
543  if (nDivY==0) { nMulY=1; nDivY=1; }
544  if (nMulX!=nDivX || nMulY!=nDivY) {
545  Fraction aX(nMulX,nDivX);
546  Fraction aY(nMulY,nDivY);
547  Resize(aOld.TopLeft(),aX,aY);
548  }
549  }
550  if (rRect.Left()!=aOld.Left() || rRect.Top()!=aOld.Top()) {
551  Move(Size(rRect.Left()-aOld.Left(),rRect.Top()-aOld.Top()));
552  }
553 
554  SetChanged();
557 }
558 
559 
561 {
562  SetSnapRect(rRect);
563 }
564 
565 
566 void SdrObjGroup::Move(const Size& rSiz)
567 {
568  if (rSiz.Width()==0 && rSiz.Height()==0)
569  return;
570 
571  tools::Rectangle aBoundRect0; if (m_pUserCall!=nullptr) aBoundRect0=GetLastBoundRect();
572  maRefPoint.Move(rSiz);
573  const size_t nObjCount(GetObjCount());
574 
575  if(0 != nObjCount)
576  {
577  // first move the connectors, then everything else
578  for (size_t i=0; i<nObjCount; ++i)
579  {
580  SdrObject* pObj(GetObj(i));
581  if (pObj->IsEdgeObj())
582  pObj->Move(rSiz);
583  }
584 
585  for (size_t i=0; i<nObjCount; ++i)
586  {
587  SdrObject* pObj(GetObj(i));
588  if (!pObj->IsEdgeObj())
589  pObj->Move(rSiz);
590  }
591  }
592  else
593  {
594  m_aOutRect.Move(rSiz);
596  }
597 
598  SetChanged();
601 }
602 
603 
604 void SdrObjGroup::Resize(const Point& rRef, const Fraction& xFact, const Fraction& yFact, bool bUnsetRelative)
605 {
606  if (xFact.GetNumerator()==xFact.GetDenominator() && yFact.GetNumerator()==yFact.GetDenominator())
607  return;
608 
609  bool bXMirr=(xFact.GetNumerator()<0) != (xFact.GetDenominator()<0);
610  bool bYMirr=(yFact.GetNumerator()<0) != (yFact.GetDenominator()<0);
611  if (bXMirr || bYMirr) {
612  Point aRef1(GetSnapRect().Center());
613  if (bXMirr) {
614  Point aRef2(aRef1);
615  aRef2.AdjustY( 1 );
616  NbcMirrorGluePoints(aRef1,aRef2);
617  }
618  if (bYMirr) {
619  Point aRef2(aRef1);
620  aRef2.AdjustX( 1 );
621  NbcMirrorGluePoints(aRef1,aRef2);
622  }
623  }
624  tools::Rectangle aBoundRect0; if (m_pUserCall!=nullptr) aBoundRect0=GetLastBoundRect();
625  ResizePoint(maRefPoint, rRef, xFact, yFact);
626  const size_t nObjCount(GetObjCount());
627 
628  if(0 != nObjCount)
629  {
630  // move the connectors first, everything else afterwards
631  for (size_t i=0; i<nObjCount; ++i)
632  {
633  SdrObject* pObj(GetObj(i));
634  if (pObj->IsEdgeObj())
635  pObj->Resize(rRef,xFact,yFact,bUnsetRelative);
636  }
637 
638  for (size_t i=0; i<nObjCount; ++i)
639  {
640  SdrObject* pObj(GetObj(i));
641  if (!pObj->IsEdgeObj())
642  pObj->Resize(rRef,xFact,yFact,bUnsetRelative);
643  }
644  }
645  else
646  {
647  ResizeRect(m_aOutRect,rRef,xFact,yFact);
649  }
650 
651  SetChanged();
654 }
655 
656 
657 void SdrObjGroup::Rotate(const Point& rRef, Degree100 nAngle, double sn, double cs)
658 {
659  if (nAngle==0_deg100)
660  return;
661 
662  SetGlueReallyAbsolute(true);
663  tools::Rectangle aBoundRect0; if (m_pUserCall!=nullptr) aBoundRect0=GetLastBoundRect();
664  RotatePoint(maRefPoint, rRef, sn, cs);
665  // move the connectors first, everything else afterwards
666  const size_t nObjCount(GetObjCount());
667 
668  for (size_t i=0; i<nObjCount; ++i)
669  {
670  SdrObject* pObj(GetObj(i));
671  if (pObj->IsEdgeObj())
672  pObj->Rotate(rRef,nAngle,sn,cs);
673  }
674 
675  for (size_t i=0; i<nObjCount; ++i)
676  {
677  SdrObject* pObj(GetObj(i));
678  if (!pObj->IsEdgeObj())
679  pObj->Rotate(rRef,nAngle,sn,cs);
680  }
681 
682  NbcRotateGluePoints(rRef,nAngle,sn,cs);
683  SetGlueReallyAbsolute(false);
684  SetChanged();
687 }
688 
689 
690 void SdrObjGroup::Mirror(const Point& rRef1, const Point& rRef2)
691 {
692  SetGlueReallyAbsolute(true);
693  tools::Rectangle aBoundRect0; if (m_pUserCall!=nullptr) aBoundRect0=GetLastBoundRect();
694  MirrorPoint(maRefPoint, rRef1, rRef2); // implementation missing in SvdEtc!
695  // move the connectors first, everything else afterwards
696  const size_t nObjCount(GetObjCount());
697 
698  for (size_t i=0; i<nObjCount; ++i)
699  {
700  SdrObject* pObj(GetObj(i));
701  if (pObj->IsEdgeObj())
702  pObj->Mirror(rRef1,rRef2);
703  }
704 
705  for (size_t i=0; i<nObjCount; ++i)
706  {
707  SdrObject* pObj(GetObj(i));
708  if (!pObj->IsEdgeObj())
709  pObj->Mirror(rRef1,rRef2);
710  }
711 
712  NbcMirrorGluePoints(rRef1,rRef2);
713  SetGlueReallyAbsolute(false);
714  SetChanged();
717 }
718 
719 
720 void SdrObjGroup::Shear(const Point& rRef, Degree100 nAngle, double tn, bool bVShear)
721 {
722  if (nAngle==0_deg100)
723  return;
724 
725  SetGlueReallyAbsolute(true);
726  tools::Rectangle aBoundRect0; if (m_pUserCall!=nullptr) aBoundRect0=GetLastBoundRect();
727  ShearPoint(maRefPoint, rRef, tn);
728  // move the connectors first, everything else afterwards
729  const size_t nObjCount(GetObjCount());
730 
731  for (size_t i=0; i<nObjCount; ++i)
732  {
733  SdrObject* pObj(GetObj(i));
734  if (pObj->IsEdgeObj())
735  pObj->Shear(rRef,nAngle,tn,bVShear);
736  }
737 
738  for (size_t i=0; i<nObjCount; ++i)
739  {
740  SdrObject* pObj(GetObj(i));
741  if (!pObj->IsEdgeObj())
742  pObj->Shear(rRef,nAngle,tn,bVShear);
743  }
744 
745  NbcShearGluePoints(rRef,tn,bVShear);
746  SetGlueReallyAbsolute(false);
747  SetChanged();
750 
751 }
752 
753 
754 void SdrObjGroup::SetAnchorPos(const Point& rPnt)
755 {
756  tools::Rectangle aBoundRect0; if (m_pUserCall!=nullptr) aBoundRect0=GetLastBoundRect();
757  bool bChg=m_aAnchor!=rPnt;
758  m_aAnchor=rPnt;
759  Size aSiz(rPnt.X()-m_aAnchor.X(),rPnt.Y()-m_aAnchor.Y());
760  maRefPoint.Move(aSiz);
761  // move the connectors first, everything else afterwards
762  const size_t nObjCount(GetObjCount());
763 
764  for (size_t i=0; i<nObjCount; ++i)
765  {
766  SdrObject* pObj(GetObj(i));
767  if (pObj->IsEdgeObj())
768  pObj->SetAnchorPos(rPnt);
769  }
770 
771  for (size_t i=0; i<nObjCount; ++i)
772  {
773  SdrObject* pObj(GetObj(i));
774  if (!pObj->IsEdgeObj())
775  pObj->SetAnchorPos(rPnt);
776  }
777 
778  if (bChg)
779  {
780  SetChanged();
783  }
784 }
785 
786 
787 void SdrObjGroup::NbcSetRelativePos(const Point& rPnt)
788 {
789  Point aRelPos0(GetSnapRect().TopLeft()-m_aAnchor);
790  Size aSiz(rPnt.X()-aRelPos0.X(),rPnt.Y()-aRelPos0.Y());
791  NbcMove(aSiz); // this also calls SetRectsDirty()
792 }
793 
794 void SdrObjGroup::SetRelativePos(const Point& rPnt)
795 {
796  Point aRelPos0(GetSnapRect().TopLeft()-m_aAnchor);
797  Size aSiz(rPnt.X()-aRelPos0.X(),rPnt.Y()-aRelPos0.Y());
798  if (aSiz.Width()!=0 || aSiz.Height()!=0) Move(aSiz); // this also calls SetRectsDirty() and Broadcast, ...
799 }
800 
802 {
804 }
805 
806 SdrObjectUniquePtr SdrObjGroup::DoConvertToPolyObj(bool bBezier, bool bAddText) const
807 {
809  const size_t nObjCount(GetObjCount());
810 
811  for(size_t a=0; a < nObjCount; ++a)
812  {
813  SdrObject* pIterObj(GetObj(a));
814  SdrObjectUniquePtr pResult(pIterObj->DoConvertToPolyObj(bBezier, bAddText));
815 
816  // pResult can be NULL e.g. for empty objects
817  if( pResult )
818  pGroup->GetSubList()->NbcInsertObject(pResult.release());
819  }
820 
821  return pGroup;
822 }
823 
825 {
826  (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SdrObjGroup"));
827  (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", this);
828 
829  SdrObject::dumpAsXml(pWriter);
830  SdrObjList::dumpAsXml(pWriter);
831 
832  (void)xmlTextWriterEndElement(pWriter);
833 }
834 
835 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void NbcSetAnchorPos(const Point &rPnt) override
Definition: svdogrp.cxx:511
virtual void Shear(const Point &rRef, Degree100 nAngle, double tn, bool bVShear)
Definition: svdobj.cxx:1599
virtual bool BegCreate(SdrDragStat &rStat) override
Every object must be able to create itself interactively.
Definition: svdogrp.cxx:340
static bool containsOOXData(const css::uno::Any &rVal)
Definition: svdogrp.cxx:213
virtual basegfx::B2DPolyPolygon TakeXorPoly() const
The Xor-Polygon is required by the View to drag the object.
Definition: svdobj.cxx:1124
virtual void TakeObjInfo(SdrObjTransformInfoRec &rInfo) const
Definition: svdobj.cxx:659
virtual void NbcShear(const Point &rRef, Degree100 nAngle, double tn, bool bVShear) override
Definition: svdogrp.cxx:494
void NbcReformatAllTextObjects()
reformat all text objects, e.g. when changing printer
Definition: svdpage.cxx:752
virtual SdrLayerID GetLayer() const override
Definition: svdogrp.cxx:175
virtual SdrObjectUniquePtr DoConvertToPolyObj(bool bBezier, bool bAddText) const override
Definition: svdogrp.cxx:806
virtual void Resize(const Point &rRef, const Fraction &xFact, const Fraction &yFact, bool bUnsetRelative=true)
Definition: svdobj.cxx:1551
void ShearPoint(Point &rPnt, const Point &rRef, double tn, bool bVShear=false)
Definition: svdtrans.hxx:109
struct _xmlTextWriter * xmlTextWriterPtr
virtual basegfx::B2DPolyPolygon TakeXorPoly() const override
The Xor-Polygon is required by the View to drag the object.
Definition: svdogrp.cxx:314
virtual void SetBoundRectDirty() override
Definition: svdogrp.cxx:164
virtual void handlePageChange(SdrPage *pOldPage, SdrPage *pNewPage)
Definition: svdobj.cxx:529
virtual void RecalcSnapRect() override
Snap is not done on the BoundRect but if possible on logic coordinates (i.e.
Definition: svdogrp.cxx:309
bool m_bClosedObj
Definition: svdobj.hxx:908
const tools::Rectangle & GetAllObjBoundRect() const
Definition: svdpage.cxx:737
virtual void NbcResize(const Point &rRef, const Fraction &xFact, const Fraction &yFact)
Definition: svdobj.cxx:1438
void ResizePoint(Point &rPnt, const Point &rRef, const Fraction &xFract, const Fraction &yFract)
Definition: svdtrans.hxx:93
static void AddAdditionalVisualization(const SdrObjGroup &rTarget, SdrHdlList &rHdlList)
constexpr tools::Long Left() const
virtual void NbcRotate(const Point &rRef, Degree100 nAngle, double sn, double cs)
Definition: svdobj.cxx:1468
bool IsEdgeObj() const
Definition: svdobj.hxx:747
long Long
virtual void NbcSetLayer(SdrLayerID nLayer) override
Definition: svdogrp.cxx:188
virtual SdrObjectUniquePtr DoConvertToPolyObj(bool bBezier, bool bAddText) const
Definition: svdobj.cxx:2643
virtual void NbcShear(const Point &rRef, Degree100 nAngle, double tn, bool bVShear)
Definition: svdobj.cxx:1527
SdrObject * GetObj(size_t nNum) const
Definition: svdpage.cxx:807
size_t GetObjCount() const
Definition: svdpage.cxx:801
void SetGlueReallyAbsolute(bool bOn)
Definition: svdobj.cxx:2331
void CopyObjects(const SdrObjList &rSrcList)
Definition: svdpage.cxx:129
tools::Rectangle m_aOutRect
Definition: svdobj.hxx:888
abstract object (SdrObject)
void NbcMirrorGluePoints(const Point &rRef1, const Point &rRef2)
Definition: svdobj.cxx:2351
Center
virtual void SetGrabBagItem(const css::uno::Any &rVal)
Definition: svdobj.cxx:922
virtual void NbcMirror(const Point &rRef1, const Point &rRef2) override
Definition: svdogrp.cxx:477
SdrObjKind
Definition: svdobjkind.hxx:24
constexpr tools::Long Width() const
Provides information about various ZObject properties.
Definition: svdobj.hxx:196
virtual Degree100 GetShearAngle(bool bVertical=false) const override
Definition: svdogrp.cxx:361
virtual bool beginSpecialDrag(SdrDragStat &rDrag) const override
Definition: svdogrp.cxx:334
SdrPage * getSdrPageFromSdrObject() const
Definition: svdobj.cxx:274
virtual void SetAnchorPos(const Point &rPnt)
Definition: svdobj.cxx:1645
virtual void NbcResize(const Point &rRef, const Fraction &xFact, const Fraction &yFact) override
Definition: svdogrp.cxx:423
OUString SvxResId(TranslateId aId)
Definition: dialmgr.cxx:24
SdrObjGroup(SdrModel &rSdrModel)
Definition: svdogrp.cxx:54
virtual void SetRelativePos(const Point &rPnt) override
Definition: svdogrp.cxx:794
Point maRefPoint
Definition: svdogrp.hxx:39
virtual void SetBoundAndSnapRectsDirty(bool bNotMyself=false, bool bRecursive=true)
Definition: svdobj.cxx:515
constexpr bool IsEmpty() const
virtual void Shear(const Point &rRef, Degree100 nAngle, double tn, bool bVShear) override
Definition: svdogrp.cxx:720
virtual Degree100 GetRotateAngle() const override
Definition: svdogrp.cxx:346
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override
Definition: svdogrp.cxx:824
void ResizeRect(tools::Rectangle &rRect, const Point &rRef, const Fraction &rxFact, const Fraction &ryFact)
Definition: svdtrans.cxx:38
virtual void NbcRotate(const Point &rRef, Degree100 nAngle, double sn, double cs) override
Definition: svdogrp.cxx:460
int i
uno_Any a
OUString sName
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: svdpage.cxx:1099
virtual void NbcMirror(const Point &rRef1, const Point &rRef2)
Definition: svdobj.cxx:1496
virtual SdrObjGroup * CloneSdrObject(SdrModel &rTargetModel) const override
Definition: svdogrp.cxx:269
void BroadcastObjectChange() const
Definition: svdobj.cxx:1006
B2DPolygon createPolygonFromRect(const B2DRectangle &rRect, double fRadiusX, double fRadiusY)
virtual const tools::Rectangle & GetSnapRect() const override
Definition: svdogrp.cxx:256
virtual Degree100 GetShearAngle(bool bVertical=false) const
Definition: svdobj.cxx:1713
void MirrorPoint(Point &rPnt, const Point &rRef1, const Point &rRef2)
Definition: svdtrans.cxx:105
constexpr tools::Long Right() const
void NbcShearGluePoints(const Point &rRef, double tn, bool bVShear)
Definition: svdobj.cxx:2361
SdrModel & getSdrModelFromSdrObject() const
Definition: svdobj.cxx:284
SdrObjUserCall * m_pUserCall
Definition: svdobj.hxx:890
virtual void NbcSetSnapRect(const tools::Rectangle &rRect) override
Definition: svdogrp.cxx:376
constexpr tools::Long Top() const
virtual ~SdrObjGroup() override
Definition: svdogrp.cxx:98
o3tl::strong_int< sal_Int16, struct SdrLayerIDTag > SdrLayerID
Definition: svdtypes.hxx:56
virtual SdrObjList * GetSubList() const override
Definition: svdogrp.cxx:208
virtual void Move(const Size &rSiz)
Definition: svdobj.cxx:1534
virtual void SetLogicRect(const tools::Rectangle &rRect) override
Definition: svdogrp.cxx:560
Abstract DrawObject.
Definition: svdobj.hxx:260
virtual void Mirror(const Point &rRef1, const Point &rRef2) override
Definition: svdogrp.cxx:690
virtual SdrObject * getSdrObjectFromSdrObjList() const override
Definition: svdogrp.cxx:107
virtual void Mirror(const Point &rRef1, const Point &rRef2)
Definition: svdobj.cxx:1590
virtual void handlePageChange(SdrPage *pOldPage, SdrPage *pNewPage) override
Definition: svdogrp.cxx:197
constexpr Point TopLeft() const
virtual void AddToHdlList(SdrHdlList &rHdlList) const override
Definition: svdogrp.cxx:89
virtual SdrLayerID GetLayer() const
Definition: svdobj.cxx:673
basegfx::B2DRange b2DRectangleFromRectangle(const ::tools::Rectangle &rRect)
virtual void Rotate(const Point &rRef, Degree100 nAngle, double sn, double cs) override
Definition: svdogrp.cxx:657
constexpr tools::Long Bottom() const
virtual SdrObjList * getChildrenOfSdrObject() const override
Definition: svdogrp.cxx:112
virtual OUString TakeObjNamePlural() const override
Definition: svdogrp.cxx:299
virtual void SetSnapRect(const tools::Rectangle &rRect) override
Definition: svdogrp.cxx:526
std::shared_ptr< svx::diagram::IDiagramHelper > mp_DiagramHelper
Definition: svdogrp.hxx:44
Point m_aAnchor
Definition: svdobj.hxx:889
virtual void NbcReformatText() override
Definition: svdogrp.cxx:801
void append(const B2DPolygon &rPolygon, sal_uInt32 nCount=1)
virtual const tools::Rectangle & GetLastBoundRect() const
Definition: svdobj.cxx:968
void RotatePoint(Point &rPnt, const Point &rRef, double sn, double cs)
Definition: svdtrans.hxx:101
virtual std::unique_ptr< sdr::contact::ViewContact > CreateObjectSpecificViewContact() override
Definition: svdogrp.cxx:49
virtual void NbcSetLogicRect(const tools::Rectangle &rRect) override
Definition: svdogrp.cxx:396
sal_uInt32 count() const
sal_Int32 GetDenominator() const
void GetGrabBagItem(css::uno::Any &rVal) const
Definition: svdobj.cxx:914
constexpr tools::Long Height() const
virtual void NbcSetRelativePos(const Point &rPnt) override
The relative position of a SdrObject is the distance of the upper left corner of the logic bounding r...
Definition: svdogrp.cxx:787
virtual void NbcMove(const Size &rSiz) override
The methods Move, Resize, Rotate, Mirror, Shear, SetSnapRect and SetLogicRect call the corresponding ...
Definition: svdogrp.cxx:402
virtual void SetAnchorPos(const Point &rPnt) override
Definition: svdogrp.cxx:754
virtual void NbcMove(const Size &rSiz)
The methods Move, Resize, Rotate, Mirror, Shear, SetSnapRect and SetLogicRect call the corresponding ...
Definition: svdobj.cxx:1432
OUString aName
virtual void SetGrabBagItem(const css::uno::Any &rVal) override
Definition: svdogrp.cxx:227
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: svdobj.cxx:1774
bool isDiagram() const
Definition: svdobj.hxx:265
virtual void Resize(const Point &rRef, const Fraction &xFact, const Fraction &yFact, bool bUnsetRelative=true) override
Definition: svdogrp.cxx:604
sal_Int32 GetNumerator() const
std::unique_ptr< SdrObject, SdrObjectFreeOp > SdrObjectUniquePtr
Definition: svdobj.hxx:98
virtual void Rotate(const Point &rRef, Degree100 nAngle, double sn, double cs)
Definition: svdobj.cxx:1579
virtual OUString TakeObjNameSingul() const override
Definition: svdogrp.cxx:274
void Move(tools::Long nHorzMoveDelta, tools::Long nVertMoveDelta)
virtual void NbcSetAnchorPos(const Point &rPnt)
Definition: svdobj.cxx:1638
virtual Degree100 GetRotateAngle() const
Definition: svdobj.cxx:1708
A SdrPage contains exactly one SdrObjList and a description of the physical page dimensions (size / m...
Definition: svdpage.hxx:373
virtual std::unique_ptr< sdr::properties::BaseProperties > CreateObjectSpecificProperties() override
Definition: svdogrp.cxx:43
virtual void TakeObjInfo(SdrObjTransformInfoRec &rInfo) const override
Definition: svdogrp.cxx:117
virtual const tools::Rectangle & GetCurrentBoundRect() const override
Definition: svdogrp.cxx:245
virtual void SetChanged()
Definition: svdobj.cxx:1030
const tools::Rectangle & GetAllObjSnapRect() const
Definition: svdpage.cxx:728
virtual const std::shared_ptr< svx::diagram::IDiagramHelper > & getDiagramHelper() const override
Definition: svdogrp.cxx:37
const OUString & GetName() const
Definition: svdobj.cxx:797
void SendUserCall(SdrUserCallType eUserCall, const tools::Rectangle &rBoundRect) const
Definition: svdobj.cxx:2767
virtual void Move(const Size &rSiz) override
Definition: svdogrp.cxx:566
virtual SdrObjKind GetObjIdentifier() const override
Definition: svdogrp.cxx:170
void NbcRotateGluePoints(const Point &rRef, Degree100 nAngle, double sn, double cs)
Definition: svdobj.cxx:2341
virtual void NbcSetLayer(SdrLayerID nLayer)
Definition: svdobj.cxx:690
virtual SdrPage * getSdrPageFromSdrObjList() const override
Definition: svdogrp.cxx:102
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo