1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <svx/svdogrp.hxx>
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>
29 #include <sdr/properties/groupproperties.hxx>
30 #include <sdr/contact/viewcontactofgroup.hxx>
31 #include <basegfx/range/b2drange.hxx>
32 #include <basegfx/polygon/b2dpolygontools.hxx>
33 #include <libxml/xmlwriter.h>
34 #include <vcl/canvastools.hxx>
35 #include <svx/diagram/IDiagramHelper.hxx>
37 const std::shared_ptr
< svx::diagram::IDiagramHelper
>& SdrObjGroup::getDiagramHelper() const
39 return mp_DiagramHelper
;
42 // BaseProperties section
43 std::unique_ptr
<sdr::properties::BaseProperties
> SdrObjGroup::CreateObjectSpecificProperties()
45 return std::make_unique
<sdr::properties::GroupProperties
>(*this);
48 // DrawContact section
49 std::unique_ptr
<sdr::contact::ViewContact
> SdrObjGroup::CreateObjectSpecificViewContact()
51 return std::make_unique
<sdr::contact::ViewContactOfGroup
>(*this);
54 SdrObjGroup::SdrObjGroup(SdrModel
& rSdrModel
)
55 : SdrObject(rSdrModel
)
63 SdrObjGroup::SdrObjGroup(SdrModel
& rSdrModel
, SdrObjGroup
const & rSource
)
64 : SdrObject(rSdrModel
, rSource
)
71 // copy child SdrObjects
72 if(nullptr != rSource
.GetSubList())
74 // #i36404# Copy SubList, init model and page first
75 const SdrObjList
& rSourceSubList(*rSource
.GetSubList());
77 CopyObjects(rSourceSubList
);
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
82 SetBoundAndSnapRectsDirty();
85 // copy local parameters
86 maRefPoint
= rSource
.maRefPoint
;
89 void SdrObjGroup::AddToHdlList(SdrHdlList
& rHdlList
) const
91 // only for diagram, so do nothing for just groups
95 svx::diagram::IDiagramHelper::AddAdditionalVisualization(*this, rHdlList
);
98 SdrObjGroup::~SdrObjGroup()
102 SdrPage
* SdrObjGroup::getSdrPageFromSdrObjList() const
104 return getSdrPageFromSdrObject();
107 SdrObject
* SdrObjGroup::getSdrObjectFromSdrObjList() const
109 return const_cast< SdrObjGroup
* >(this);
112 SdrObjList
* SdrObjGroup::getChildrenOfSdrObject() const
114 return const_cast< SdrObjGroup
* >(this);
117 void SdrObjGroup::TakeObjInfo(SdrObjTransformInfoRec
& rInfo
) const
119 rInfo
.bNoContortion
=false;
120 const size_t nObjCount(GetObjCount());
121 for (size_t i
=0; i
<nObjCount
; ++i
) {
122 SdrObject
* pObj(GetObj(i
));
123 SdrObjTransformInfoRec aInfo
;
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;
139 if(!aInfo
.bCanConvToContour
)
140 rInfo
.bCanConvToContour
= false;
142 if (!aInfo
.bCanConvToPoly
) rInfo
.bCanConvToPoly
=false;
143 if (!aInfo
.bCanConvToPathLineToArea
) rInfo
.bCanConvToPathLineToArea
=false;
144 if (!aInfo
.bCanConvToPolyLineToArea
) rInfo
.bCanConvToPolyLineToArea
=false;
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;
159 // only allowed if single object selected
160 rInfo
.bTransparenceAllowed
= false;
164 void SdrObjGroup::SetBoundRectDirty()
166 // avoid resetting aOutRect which in case of this object is model data,
167 // not re-creatable view data
170 SdrObjKind
SdrObjGroup::GetObjIdentifier() const
172 return SdrObjKind::Group
;
175 SdrLayerID
SdrObjGroup::GetLayer() const
178 SdrLayerID nLay
= SdrObject::GetLayer();
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);
188 void SdrObjGroup::NbcSetLayer(SdrLayerID nLayer
)
190 SdrObject::NbcSetLayer(nLayer
);
191 const size_t nObjCount(GetObjCount());
192 for (size_t i
=0; i
<nObjCount
; ++i
) {
193 GetObj(i
)->NbcSetLayer(nLayer
);
197 void SdrObjGroup::handlePageChange(SdrPage
* pOldPage
, SdrPage
* pNewPage
)
200 SdrObject::handlePageChange(pOldPage
, pNewPage
);
202 for(size_t i(0); i
< GetObjCount(); i
++)
204 GetObj(i
)->handlePageChange(pOldPage
, pNewPage
);
208 SdrObjList
* SdrObjGroup::GetSubList() const
210 return const_cast< SdrObjGroup
* >(this);
213 static bool containsOOXData(const css::uno::Any
& rVal
)
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
))
218 if(rProp
.Name
.startsWith("OOX"))
227 void SdrObjGroup::SetGrabBagItem(const css::uno::Any
& rVal
)
229 // detect if the intention is to disable Diagram functionality
230 if(isDiagram() && !containsOOXData(rVal
))
233 GetGrabBagItem(aOld
);
235 if(containsOOXData(aOld
))
237 mp_DiagramHelper
.reset();
242 SdrObject::SetGrabBagItem(rVal
);
245 const tools::Rectangle
& SdrObjGroup::GetCurrentBoundRect() const
247 // <aOutRect> has to contain the bounding rectangle
248 if(0 != GetObjCount())
250 setOutRectangleConst(GetAllObjBoundRect());
253 return getOutRectangle();
256 const tools::Rectangle
& SdrObjGroup::GetSnapRect() const
258 // <aOutRect> has to contain the bounding rectangle
259 if(0 != GetObjCount())
261 return GetAllObjSnapRect();
265 return getOutRectangle();
269 rtl::Reference
<SdrObject
> SdrObjGroup::CloneSdrObject(SdrModel
& rTargetModel
) const
271 return new SdrObjGroup(rTargetModel
, *this);
274 OUString
SdrObjGroup::TakeObjNameSingul() const
278 if(0 == GetObjCount())
280 sName
= SvxResId(STR_ObjNameSingulGRUPEMPTY
);
285 sName
= SvxResId(STR_ObjNameSingulDIAGRAM
);
287 sName
= SvxResId(STR_ObjNameSingulGRUP
);
290 const OUString
aName(GetName());
292 if (!aName
.isEmpty())
293 sName
+= " '" + aName
+ "'";
299 OUString
SdrObjGroup::TakeObjNamePlural() const
301 if(0 == GetObjCount())
302 return SvxResId(STR_ObjNamePluralGRUPEMPTY
);
304 return SvxResId(RID_GALLERYSTR_THEME_DIAGRAMS
);
305 return SvxResId(STR_ObjNamePluralGRUP
);
309 void SdrObjGroup::RecalcSnapRect()
311 // TODO: unnecessary, because we use the Rects from the SubList
314 basegfx::B2DPolyPolygon
SdrObjGroup::TakeXorPoly() const
316 basegfx::B2DPolyPolygon aRetval
;
317 const size_t nObjCount(GetObjCount());
319 for(size_t a
= 0; a
< nObjCount
; ++a
)
321 SdrObject
* pObj(GetObj(a
));
322 aRetval
.append(pObj
->TakeXorPoly());
327 const basegfx::B2DRange aRange
= vcl::unotools::b2DRectangleFromRectangle(getOutRectangle());
328 aRetval
.append(basegfx::utils::createPolygonFromRect(aRange
));
334 bool SdrObjGroup::beginSpecialDrag(SdrDragStat
& /*rDrag*/) const
340 bool SdrObjGroup::BegCreate(SdrDragStat
& /*rStat*/)
346 Degree100
SdrObjGroup::GetRotateAngle() const
348 Degree100
nRetval(0);
350 if(0 != GetObjCount())
352 SdrObject
* pObj(GetObj(0));
354 nRetval
= pObj
->GetRotateAngle();
361 Degree100
SdrObjGroup::GetShearAngle(bool /*bVertical*/) const
363 Degree100
nRetval(0);
365 if(0 != GetObjCount())
367 SdrObject
* pObj(GetObj(0));
369 nRetval
= pObj
->GetShearAngle();
376 void SdrObjGroup::NbcSetSnapRect(const tools::Rectangle
& rRect
)
378 tools::Rectangle
aOld(GetSnapRect());
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
);
390 if (rRect
.Left()!=aOld
.Left() || rRect
.Top()!=aOld
.Top()) {
391 NbcMove(Size(rRect
.Left()-aOld
.Left(),rRect
.Top()-aOld
.Top()));
396 void SdrObjGroup::NbcSetLogicRect(const tools::Rectangle
& rRect
)
398 NbcSetSnapRect(rRect
);
402 void SdrObjGroup::NbcMove(const Size
& rSize
)
404 maRefPoint
.Move(rSize
);
405 const size_t nObjCount(GetObjCount());
409 for (size_t i
=0; i
<nObjCount
; ++i
)
411 SdrObject
* pObj(GetObj(i
));
412 pObj
->NbcMove(rSize
);
417 moveOutRectangle(rSize
.Width(), rSize
.Height());
418 SetBoundAndSnapRectsDirty();
423 void SdrObjGroup::NbcResize(const Point
& rRef
, const Fraction
& xFact
, const Fraction
& yFact
)
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());
432 NbcMirrorGluePoints(aRef1
,aRef2
);
437 NbcMirrorGluePoints(aRef1
,aRef2
);
441 ResizePoint(maRefPoint
, rRef
, xFact
, yFact
);
443 const size_t nObjCount(GetObjCount());
446 for (size_t i
=0; i
<nObjCount
; ++i
)
448 SdrObject
* pObj(GetObj(i
));
449 pObj
->NbcResize(rRef
,xFact
,yFact
);
454 auto aRectangle
= getOutRectangle();
455 ResizeRect(aRectangle
, rRef
, xFact
, yFact
);
456 setOutRectangle(aRectangle
);
458 SetBoundAndSnapRectsDirty();
463 void SdrObjGroup::NbcRotate(const Point
& rRef
, Degree100 nAngle
, double sn
, double cs
)
465 SetGlueReallyAbsolute(true);
466 RotatePoint(maRefPoint
, rRef
, sn
, cs
);
467 const size_t nObjCount(GetObjCount());
469 for (size_t i
=0; i
<nObjCount
; ++i
)
471 SdrObject
* pObj(GetObj(i
));
472 pObj
->NbcRotate(rRef
,nAngle
,sn
,cs
);
475 NbcRotateGluePoints(rRef
,nAngle
,sn
,cs
);
476 SetGlueReallyAbsolute(false);
480 void SdrObjGroup::NbcMirror(const Point
& rRef1
, const Point
& rRef2
)
482 SetGlueReallyAbsolute(true);
483 MirrorPoint(maRefPoint
, rRef1
, rRef2
); // implementation missing in SvdEtc!
484 const size_t nObjCount(GetObjCount());
486 for (size_t i
=0; i
<nObjCount
; ++i
)
488 SdrObject
* pObj(GetObj(i
));
489 pObj
->NbcMirror(rRef1
,rRef2
);
492 NbcMirrorGluePoints(rRef1
,rRef2
);
493 SetGlueReallyAbsolute(false);
497 void SdrObjGroup::NbcShear(const Point
& rRef
, Degree100 nAngle
, double tn
, bool bVShear
)
499 SetGlueReallyAbsolute(true);
500 ShearPoint(maRefPoint
, rRef
, tn
);
501 const size_t nObjCount(GetObjCount());
503 for (size_t i
=0; i
<nObjCount
; ++i
)
505 SdrObject
* pObj(GetObj(i
));
506 pObj
->NbcShear(rRef
,nAngle
,tn
,bVShear
);
509 NbcShearGluePoints(rRef
,tn
,bVShear
);
510 SetGlueReallyAbsolute(false);
514 void SdrObjGroup::NbcSetAnchorPos(const Point
& rPnt
)
517 Size
aSiz(rPnt
.X()-m_aAnchor
.X(),rPnt
.Y()-m_aAnchor
.Y());
518 maRefPoint
.Move(aSiz
);
519 const size_t nObjCount(GetObjCount());
521 for (size_t i
=0; i
<nObjCount
; ++i
)
523 SdrObject
* pObj(GetObj(i
));
524 pObj
->NbcSetAnchorPos(rPnt
);
529 void SdrObjGroup::SetSnapRect(const tools::Rectangle
& rRect
)
531 tools::Rectangle aBoundRect0
; if (m_pUserCall
!=nullptr) aBoundRect0
=GetLastBoundRect();
532 tools::Rectangle
aOld(GetSnapRect());
537 Resize(aOld
.TopLeft(),aX
,aY
);
541 tools::Long nMulX
=rRect
.Right()-rRect
.Left();
542 tools::Long nDivX
=aOld
.Right()-aOld
.Left();
543 tools::Long nMulY
=rRect
.Bottom()-rRect
.Top();
544 tools::Long nDivY
=aOld
.Bottom()-aOld
.Top();
545 if (nDivX
==0) { nMulX
=1; nDivX
=1; }
546 if (nDivY
==0) { nMulY
=1; nDivY
=1; }
547 if (nMulX
!=nDivX
|| nMulY
!=nDivY
) {
548 Fraction
aX(nMulX
,nDivX
);
549 Fraction
aY(nMulY
,nDivY
);
550 Resize(aOld
.TopLeft(),aX
,aY
);
553 if (rRect
.Left()!=aOld
.Left() || rRect
.Top()!=aOld
.Top()) {
554 Move(Size(rRect
.Left()-aOld
.Left(),rRect
.Top()-aOld
.Top()));
558 BroadcastObjectChange();
559 SendUserCall(SdrUserCallType::Resize
,aBoundRect0
);
563 void SdrObjGroup::SetLogicRect(const tools::Rectangle
& rRect
)
569 void SdrObjGroup::Move(const Size
& rSiz
)
571 if (rSiz
.Width()==0 && rSiz
.Height()==0)
574 tools::Rectangle aBoundRect0
; if (m_pUserCall
!=nullptr) aBoundRect0
=GetLastBoundRect();
575 maRefPoint
.Move(rSiz
);
576 const size_t nObjCount(GetObjCount());
580 // first move the connectors, then everything else
581 for (size_t i
=0; i
<nObjCount
; ++i
)
583 SdrObject
* pObj(GetObj(i
));
584 if (pObj
->IsEdgeObj())
588 for (size_t i
=0; i
<nObjCount
; ++i
)
590 SdrObject
* pObj(GetObj(i
));
591 if (!pObj
->IsEdgeObj())
597 moveOutRectangle(rSiz
.Width(), rSiz
.Height());
598 SetBoundAndSnapRectsDirty();
602 BroadcastObjectChange();
603 SendUserCall(SdrUserCallType::MoveOnly
,aBoundRect0
);
607 void SdrObjGroup::Resize(const Point
& rRef
, const Fraction
& xFact
, const Fraction
& yFact
, bool bUnsetRelative
)
609 if (xFact
.GetNumerator()==xFact
.GetDenominator() && yFact
.GetNumerator()==yFact
.GetDenominator())
612 bool bXMirr
=(xFact
.GetNumerator()<0) != (xFact
.GetDenominator()<0);
613 bool bYMirr
=(yFact
.GetNumerator()<0) != (yFact
.GetDenominator()<0);
614 if (bXMirr
|| bYMirr
) {
615 Point
aRef1(GetSnapRect().Center());
619 NbcMirrorGluePoints(aRef1
,aRef2
);
624 NbcMirrorGluePoints(aRef1
,aRef2
);
627 tools::Rectangle aBoundRect0
; if (m_pUserCall
!=nullptr) aBoundRect0
=GetLastBoundRect();
628 ResizePoint(maRefPoint
, rRef
, xFact
, yFact
);
629 const size_t nObjCount(GetObjCount());
633 // move the connectors first, everything else afterwards
634 for (size_t i
=0; i
<nObjCount
; ++i
)
636 SdrObject
* pObj(GetObj(i
));
637 if (pObj
->IsEdgeObj())
638 pObj
->Resize(rRef
,xFact
,yFact
,bUnsetRelative
);
641 for (size_t i
=0; i
<nObjCount
; ++i
)
643 SdrObject
* pObj(GetObj(i
));
644 if (!pObj
->IsEdgeObj())
645 pObj
->Resize(rRef
,xFact
,yFact
,bUnsetRelative
);
650 auto aRectangle
= getOutRectangle();
651 ResizeRect(aRectangle
, rRef
, xFact
, yFact
);
652 setOutRectangle(aRectangle
);
654 SetBoundAndSnapRectsDirty();
658 BroadcastObjectChange();
659 SendUserCall(SdrUserCallType::Resize
,aBoundRect0
);
663 void SdrObjGroup::Rotate(const Point
& rRef
, Degree100 nAngle
, double sn
, double cs
)
665 if (nAngle
==0_deg100
)
668 SetGlueReallyAbsolute(true);
669 tools::Rectangle aBoundRect0
; if (m_pUserCall
!=nullptr) aBoundRect0
=GetLastBoundRect();
670 RotatePoint(maRefPoint
, rRef
, sn
, cs
);
671 // move the connectors first, everything else afterwards
672 const size_t nObjCount(GetObjCount());
674 for (size_t i
=0; i
<nObjCount
; ++i
)
676 SdrObject
* pObj(GetObj(i
));
677 if (pObj
->IsEdgeObj())
678 pObj
->Rotate(rRef
,nAngle
,sn
,cs
);
681 for (size_t i
=0; i
<nObjCount
; ++i
)
683 SdrObject
* pObj(GetObj(i
));
684 if (!pObj
->IsEdgeObj())
685 pObj
->Rotate(rRef
,nAngle
,sn
,cs
);
688 NbcRotateGluePoints(rRef
,nAngle
,sn
,cs
);
689 SetGlueReallyAbsolute(false);
691 BroadcastObjectChange();
692 SendUserCall(SdrUserCallType::Resize
,aBoundRect0
);
696 void SdrObjGroup::Mirror(const Point
& rRef1
, const Point
& rRef2
)
698 SetGlueReallyAbsolute(true);
699 tools::Rectangle aBoundRect0
; if (m_pUserCall
!=nullptr) aBoundRect0
=GetLastBoundRect();
700 MirrorPoint(maRefPoint
, rRef1
, rRef2
); // implementation missing in SvdEtc!
701 // move the connectors first, everything else afterwards
702 const size_t nObjCount(GetObjCount());
704 for (size_t i
=0; i
<nObjCount
; ++i
)
706 SdrObject
* pObj(GetObj(i
));
707 if (pObj
->IsEdgeObj())
708 pObj
->Mirror(rRef1
,rRef2
);
711 for (size_t i
=0; i
<nObjCount
; ++i
)
713 SdrObject
* pObj(GetObj(i
));
714 if (!pObj
->IsEdgeObj())
715 pObj
->Mirror(rRef1
,rRef2
);
718 NbcMirrorGluePoints(rRef1
,rRef2
);
719 SetGlueReallyAbsolute(false);
721 BroadcastObjectChange();
722 SendUserCall(SdrUserCallType::Resize
,aBoundRect0
);
726 void SdrObjGroup::Shear(const Point
& rRef
, Degree100 nAngle
, double tn
, bool bVShear
)
728 if (nAngle
==0_deg100
)
731 SetGlueReallyAbsolute(true);
732 tools::Rectangle aBoundRect0
; if (m_pUserCall
!=nullptr) aBoundRect0
=GetLastBoundRect();
733 ShearPoint(maRefPoint
, rRef
, tn
);
734 // move the connectors first, everything else afterwards
735 const size_t nObjCount(GetObjCount());
737 for (size_t i
=0; i
<nObjCount
; ++i
)
739 SdrObject
* pObj(GetObj(i
));
740 if (pObj
->IsEdgeObj())
741 pObj
->Shear(rRef
,nAngle
,tn
,bVShear
);
744 for (size_t i
=0; i
<nObjCount
; ++i
)
746 SdrObject
* pObj(GetObj(i
));
747 if (!pObj
->IsEdgeObj())
748 pObj
->Shear(rRef
,nAngle
,tn
,bVShear
);
751 NbcShearGluePoints(rRef
,tn
,bVShear
);
752 SetGlueReallyAbsolute(false);
754 BroadcastObjectChange();
755 SendUserCall(SdrUserCallType::Resize
,aBoundRect0
);
760 void SdrObjGroup::SetAnchorPos(const Point
& rPnt
)
762 tools::Rectangle aBoundRect0
; if (m_pUserCall
!=nullptr) aBoundRect0
=GetLastBoundRect();
763 bool bChg
=m_aAnchor
!=rPnt
;
765 Size
aSiz(rPnt
.X()-m_aAnchor
.X(),rPnt
.Y()-m_aAnchor
.Y());
766 maRefPoint
.Move(aSiz
);
767 // move the connectors first, everything else afterwards
768 const size_t nObjCount(GetObjCount());
770 for (size_t i
=0; i
<nObjCount
; ++i
)
772 SdrObject
* pObj(GetObj(i
));
773 if (pObj
->IsEdgeObj())
774 pObj
->SetAnchorPos(rPnt
);
777 for (size_t i
=0; i
<nObjCount
; ++i
)
779 SdrObject
* pObj(GetObj(i
));
780 if (!pObj
->IsEdgeObj())
781 pObj
->SetAnchorPos(rPnt
);
787 BroadcastObjectChange();
788 SendUserCall(SdrUserCallType::MoveOnly
,aBoundRect0
);
793 void SdrObjGroup::NbcSetRelativePos(const Point
& rPnt
)
795 Point
aRelPos0(GetSnapRect().TopLeft()-m_aAnchor
);
796 Size
aSiz(rPnt
.X()-aRelPos0
.X(),rPnt
.Y()-aRelPos0
.Y());
797 NbcMove(aSiz
); // this also calls SetRectsDirty()
800 void SdrObjGroup::SetRelativePos(const Point
& rPnt
)
802 Point
aRelPos0(GetSnapRect().TopLeft()-m_aAnchor
);
803 Size
aSiz(rPnt
.X()-aRelPos0
.X(),rPnt
.Y()-aRelPos0
.Y());
804 if (aSiz
.Width()!=0 || aSiz
.Height()!=0) Move(aSiz
); // this also calls SetRectsDirty() and Broadcast, ...
807 void SdrObjGroup::NbcReformatText()
809 NbcReformatAllTextObjects();
812 rtl::Reference
<SdrObject
> SdrObjGroup::DoConvertToPolyObj(bool bBezier
, bool bAddText
) const
814 rtl::Reference
<SdrObject
> pGroup( new SdrObjGroup(getSdrModelFromSdrObject()) );
815 const size_t nObjCount(GetObjCount());
817 for(size_t a
=0; a
< nObjCount
; ++a
)
819 SdrObject
* pIterObj(GetObj(a
));
820 rtl::Reference
<SdrObject
> pResult(pIterObj
->DoConvertToPolyObj(bBezier
, bAddText
));
822 // pResult can be NULL e.g. for empty objects
824 pGroup
->GetSubList()->NbcInsertObject(pResult
.get());
830 void SdrObjGroup::dumpAsXml(xmlTextWriterPtr pWriter
) const
832 (void)xmlTextWriterStartElement(pWriter
, BAD_CAST("SdrObjGroup"));
833 (void)xmlTextWriterWriteFormatAttribute(pWriter
, BAD_CAST("ptr"), "%p", this);
835 SdrObject::dumpAsXml(pWriter
);
836 SdrObjList::dumpAsXml(pWriter
);
838 (void)xmlTextWriterEndElement(pWriter
);
841 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */