bump product version to 5.0.4.1
[LibreOffice.git] / svx / source / svdraw / svdogrp.cxx
blob7fb0065160c8471ac4081c2e4f263a242a66a21d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 <sfx2/linkmgr.hxx>
22 #include <unotools/datetime.hxx>
24 #include <svx/svdogrp.hxx>
26 #include <sfx2/lnkbase.hxx>
28 #include <svl/urihelper.hxx>
30 #include <svx/xpool.hxx>
31 #include <svx/xpoly.hxx>
33 #include <svx/svdmodel.hxx>
34 #include <svx/svdpage.hxx>
35 #include "svx/svditer.hxx"
36 #include <svx/svdobj.hxx>
37 #include <svx/svdtrans.hxx>
38 #include <svx/svdetc.hxx>
39 #include <svx/svdoedge.hxx>
40 #include "svdglob.hxx"
41 #include "svx/svdstr.hrc"
43 #include <svx/svxids.hrc>
44 #include <svl/whiter.hxx>
45 #include <svx/svdpool.hxx>
46 #include <sdr/properties/groupproperties.hxx>
47 #include <sdr/contact/viewcontactofgroup.hxx>
48 #include <basegfx/range/b2drange.hxx>
49 #include <basegfx/polygon/b2dpolygontools.hxx>
50 #include <basegfx/polygon/b2dpolygon.hxx>
51 #include <libxml/xmlwriter.h>
54 // BaseProperties section
56 sdr::properties::BaseProperties* SdrObjGroup::CreateObjectSpecificProperties()
58 return new sdr::properties::GroupProperties(*this);
62 // DrawContact section
64 sdr::contact::ViewContact* SdrObjGroup::CreateObjectSpecificViewContact()
66 return new sdr::contact::ViewContactOfGroup(*this);
71 TYPEINIT1(SdrObjGroup,SdrObject);
73 SdrObjGroup::SdrObjGroup()
75 pSub=new SdrObjList(NULL,NULL);
76 pSub->SetOwnerObj(this);
77 pSub->SetListKind(SDROBJLIST_GROUPOBJ);
78 bRefPoint=false;
79 bClosedObj=false;
83 SdrObjGroup::~SdrObjGroup()
85 delete pSub;
88 void SdrObjGroup::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const
90 rInfo.bNoContortion=false;
91 SdrObjList* pOL=pSub;
92 const size_t nObjCount = pOL->GetObjCount();
93 for (size_t i=0; i<nObjCount; ++i) {
94 SdrObject* pObj=pOL->GetObj(i);
95 SdrObjTransformInfoRec aInfo;
96 pObj->TakeObjInfo(aInfo);
97 if (!aInfo.bMoveAllowed ) rInfo.bMoveAllowed =false;
98 if (!aInfo.bResizeFreeAllowed ) rInfo.bResizeFreeAllowed =false;
99 if (!aInfo.bResizePropAllowed ) rInfo.bResizePropAllowed =false;
100 if (!aInfo.bRotateFreeAllowed ) rInfo.bRotateFreeAllowed =false;
101 if (!aInfo.bRotate90Allowed ) rInfo.bRotate90Allowed =false;
102 if (!aInfo.bMirrorFreeAllowed ) rInfo.bMirrorFreeAllowed =false;
103 if (!aInfo.bMirror45Allowed ) rInfo.bMirror45Allowed =false;
104 if (!aInfo.bMirror90Allowed ) rInfo.bMirror90Allowed =false;
105 if (!aInfo.bShearAllowed ) rInfo.bShearAllowed =false;
106 if (!aInfo.bEdgeRadiusAllowed ) rInfo.bEdgeRadiusAllowed =false;
107 if (!aInfo.bNoOrthoDesired ) rInfo.bNoOrthoDesired =false;
108 if (aInfo.bNoContortion ) rInfo.bNoContortion =true;
109 if (!aInfo.bCanConvToPath ) rInfo.bCanConvToPath =false;
111 if(!aInfo.bCanConvToContour)
112 rInfo.bCanConvToContour = false;
114 if (!aInfo.bCanConvToPoly ) rInfo.bCanConvToPoly =false;
115 if (!aInfo.bCanConvToPathLineToArea) rInfo.bCanConvToPathLineToArea=false;
116 if (!aInfo.bCanConvToPolyLineToArea) rInfo.bCanConvToPolyLineToArea=false;
118 if (nObjCount==0) {
119 rInfo.bRotateFreeAllowed=false;
120 rInfo.bRotate90Allowed =false;
121 rInfo.bMirrorFreeAllowed=false;
122 rInfo.bMirror45Allowed =false;
123 rInfo.bMirror90Allowed =false;
124 rInfo.bTransparenceAllowed = false;
125 rInfo.bGradientAllowed = false;
126 rInfo.bShearAllowed =false;
127 rInfo.bEdgeRadiusAllowed=false;
128 rInfo.bNoContortion =true;
130 if(nObjCount != 1)
132 // only allowed if single object selected
133 rInfo.bTransparenceAllowed = false;
134 rInfo.bGradientAllowed = false;
139 void SdrObjGroup::SetBoundRectDirty()
141 // avoid resetting aOutRect which in case of this object is model data,
142 // not re-creatable view data
145 sal_uInt16 SdrObjGroup::GetObjIdentifier() const
147 return sal_uInt16(OBJ_GRUP);
151 SdrLayerID SdrObjGroup::GetLayer() const
153 bool b1st = true;
154 SdrLayerID nLay=SdrLayerID(SdrObject::GetLayer());
155 SdrObjList* pOL=pSub;
156 const size_t nObjCount = pOL->GetObjCount();
157 for (size_t i=0; i<nObjCount; ++i) {
158 SdrLayerID nLay1=pOL->GetObj(i)->GetLayer();
159 if (b1st) { nLay=nLay1; b1st = false; }
160 else if (nLay1!=nLay) return 0;
162 return nLay;
166 void SdrObjGroup::NbcSetLayer(SdrLayerID nLayer)
168 SdrObject::NbcSetLayer(nLayer);
169 SdrObjList* pOL=pSub;
170 const size_t nObjCount = pOL->GetObjCount();
171 for (size_t i=0; i<nObjCount; ++i) {
172 pOL->GetObj(i)->NbcSetLayer(nLayer);
177 void SdrObjGroup::SetObjList(SdrObjList* pNewObjList)
179 SdrObject::SetObjList(pNewObjList);
180 pSub->SetUpList(pNewObjList);
184 void SdrObjGroup::SetPage(SdrPage* pNewPage)
186 SdrObject::SetPage(pNewPage);
187 pSub->SetPage(pNewPage);
191 void SdrObjGroup::SetModel(SdrModel* pNewModel)
193 if(pNewModel!=pModel)
195 // #i30648#
196 // This method also needs to migrate the used ItemSet
197 // when the destination model uses a different pool
198 // than the current one. Else it is possible to create
199 // SdrObjGroups which reference the old pool which might
200 // be destroyed (as the bug shows).
201 SdrModel* pOldModel = pModel;
203 // test for correct pool in ItemSet; move to new pool if necessary
204 if(pNewModel && &GetObjectItemPool() != &pNewModel->GetItemPool())
206 MigrateItemPool(&GetObjectItemPool(), &pNewModel->GetItemPool(), pNewModel);
209 // call parent
210 SdrObject::SetModel(pNewModel);
212 // set new model at content
213 pSub->SetModel(pNewModel);
215 // modify properties
216 GetProperties().SetModel(pOldModel, pNewModel);
221 bool SdrObjGroup::HasRefPoint() const
223 return bRefPoint;
227 Point SdrObjGroup::GetRefPoint() const
229 return aRefPoint;
233 void SdrObjGroup::SetRefPoint(const Point& rPnt)
235 bRefPoint=true;
236 aRefPoint=rPnt;
240 SdrObjList* SdrObjGroup::GetSubList() const
242 return pSub;
245 const Rectangle& SdrObjGroup::GetCurrentBoundRect() const
247 // <aOutRect> has to contain the bounding rectangle
248 if ( pSub->GetObjCount()!=0 )
250 const_cast<SdrObjGroup*>(this)->aOutRect = pSub->GetAllObjBoundRect();
253 return aOutRect;
256 const Rectangle& SdrObjGroup::GetSnapRect() const
258 // <aOutRect> has to contain the bounding rectangle
259 if ( pSub->GetObjCount()!=0 )
261 return pSub->GetAllObjSnapRect();
263 else
265 return aOutRect;
269 SdrObjGroup* SdrObjGroup::Clone() const
271 return CloneHelper< SdrObjGroup >();
274 SdrObjGroup& SdrObjGroup::operator=(const SdrObjGroup& rObj)
276 if( this == &rObj )
277 return *this;
278 // copy SdrObject stuff
279 SdrObject::operator=(rObj);
281 // #i36404#
282 // copy SubList, init model and page first
283 SdrObjList& rSourceSubList = *rObj.GetSubList();
284 pSub->SetPage(rSourceSubList.GetPage());
285 pSub->SetModel(rSourceSubList.GetModel());
286 pSub->CopyObjects(*rObj.GetSubList());
288 // copy local parameters
289 aRefPoint = rObj.aRefPoint;
290 bRefPoint = rObj.bRefPoint;
291 return *this;
295 OUString SdrObjGroup::TakeObjNameSingul() const
297 OUStringBuffer sName;
299 if(!pSub->GetObjCount())
301 sName.append(ImpGetResStr(STR_ObjNameSingulGRUPEMPTY));
303 else
305 sName.append(ImpGetResStr(STR_ObjNameSingulGRUP));
308 const OUString aName(GetName());
310 if (!aName.isEmpty())
312 sName.append(' ');
313 sName.append('\'');
314 sName.append(aName);
315 sName.append('\'');
318 return sName.makeStringAndClear();
322 OUString SdrObjGroup::TakeObjNamePlural() const
324 if (pSub->GetObjCount()==0)
325 return ImpGetResStr(STR_ObjNamePluralGRUPEMPTY);
326 return ImpGetResStr(STR_ObjNamePluralGRUP);
330 void SdrObjGroup::RecalcSnapRect()
332 // TODO: unnecessary, because we use the Rects from the SubList
335 basegfx::B2DPolyPolygon SdrObjGroup::TakeXorPoly() const
337 basegfx::B2DPolyPolygon aRetval;
338 const size_t nObjCount(pSub->GetObjCount());
340 for(size_t a = 0; a < nObjCount; ++a)
342 SdrObject* pObj = pSub->GetObj(a);
343 aRetval.append(pObj->TakeXorPoly());
346 if(!aRetval.count())
348 const basegfx::B2DRange aRange(aOutRect.Left(), aOutRect.Top(), aOutRect.Right(), aOutRect.Bottom());
349 aRetval.append(basegfx::tools::createPolygonFromRect(aRange));
352 return aRetval;
355 bool SdrObjGroup::beginSpecialDrag(SdrDragStat& /*rDrag*/) const
357 return false;
361 bool SdrObjGroup::BegCreate(SdrDragStat& /*rStat*/)
363 return false;
367 long SdrObjGroup::GetRotateAngle() const
369 long nRetval(0);
371 if(pSub->GetObjCount())
373 SdrObject* pObj = pSub->GetObj(0);
375 nRetval = pObj->GetRotateAngle();
378 return nRetval;
382 long SdrObjGroup::GetShearAngle(bool /*bVertical*/) const
384 long nRetval(0);
386 if(pSub->GetObjCount())
388 SdrObject* pObj = pSub->GetObj(0);
390 nRetval = pObj->GetShearAngle();
393 return nRetval;
397 void SdrObjGroup::NbcSetSnapRect(const Rectangle& rRect)
399 Rectangle aOld(GetSnapRect());
400 long nMulX=rRect.Right()-rRect.Left();
401 long nDivX=aOld.Right()-aOld.Left();
402 long nMulY=rRect.Bottom()-rRect.Top();
403 long nDivY=aOld.Bottom()-aOld.Top();
404 if (nDivX==0) { nMulX=1; nDivX=1; }
405 if (nDivY==0) { nMulY=1; nDivY=1; }
406 if (nMulX!=nDivX || nMulY!=nDivY) {
407 Fraction aX(nMulX,nDivX);
408 Fraction aY(nMulY,nDivY);
409 NbcResize(aOld.TopLeft(),aX,aY);
411 if (rRect.Left()!=aOld.Left() || rRect.Top()!=aOld.Top()) {
412 NbcMove(Size(rRect.Left()-aOld.Left(),rRect.Top()-aOld.Top()));
417 void SdrObjGroup::NbcSetLogicRect(const Rectangle& rRect)
419 NbcSetSnapRect(rRect);
423 void SdrObjGroup::NbcMove(const Size& rSiz)
425 MovePoint(aRefPoint,rSiz);
426 if (pSub->GetObjCount()!=0) {
427 SdrObjList* pOL=pSub;
428 const size_t nObjCount = pOL->GetObjCount();
429 for (size_t i=0; i<nObjCount; ++i) {
430 SdrObject* pObj=pOL->GetObj(i);
431 pObj->NbcMove(rSiz);
433 } else {
434 MoveRect(aOutRect,rSiz);
435 SetRectsDirty();
440 void SdrObjGroup::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact)
442 bool bXMirr=(xFact.GetNumerator()<0) != (xFact.GetDenominator()<0);
443 bool bYMirr=(yFact.GetNumerator()<0) != (yFact.GetDenominator()<0);
444 if (bXMirr || bYMirr) {
445 Point aRef1(GetSnapRect().Center());
446 if (bXMirr) {
447 Point aRef2(aRef1);
448 aRef2.Y()++;
449 NbcMirrorGluePoints(aRef1,aRef2);
451 if (bYMirr) {
452 Point aRef2(aRef1);
453 aRef2.X()++;
454 NbcMirrorGluePoints(aRef1,aRef2);
457 ResizePoint(aRefPoint,rRef,xFact,yFact);
458 if (pSub->GetObjCount()!=0) {
459 SdrObjList* pOL=pSub;
460 const size_t nObjCount = pOL->GetObjCount();
461 for (size_t i=0; i<nObjCount; ++i) {
462 SdrObject* pObj=pOL->GetObj(i);
463 pObj->NbcResize(rRef,xFact,yFact);
465 } else {
466 ResizeRect(aOutRect,rRef,xFact,yFact);
467 SetRectsDirty();
472 void SdrObjGroup::NbcRotate(const Point& rRef, long nAngle, double sn, double cs)
474 SetGlueReallyAbsolute(true);
475 RotatePoint(aRefPoint,rRef,sn,cs);
476 SdrObjList* pOL=pSub;
477 const size_t nObjCount = pOL->GetObjCount();
478 for (size_t i=0; i<nObjCount; ++i) {
479 SdrObject* pObj=pOL->GetObj(i);
480 pObj->NbcRotate(rRef,nAngle,sn,cs);
482 NbcRotateGluePoints(rRef,nAngle,sn,cs);
483 SetGlueReallyAbsolute(false);
487 void SdrObjGroup::NbcMirror(const Point& rRef1, const Point& rRef2)
489 SetGlueReallyAbsolute(true);
490 MirrorPoint(aRefPoint,rRef1,rRef2); // implementation missing in SvdEtc!
491 SdrObjList* pOL=pSub;
492 const size_t nObjCount = pOL->GetObjCount();
493 for (size_t i=0; i<nObjCount; ++i) {
494 SdrObject* pObj=pOL->GetObj(i);
495 pObj->NbcMirror(rRef1,rRef2);
497 NbcMirrorGluePoints(rRef1,rRef2);
498 SetGlueReallyAbsolute(false);
502 void SdrObjGroup::NbcShear(const Point& rRef, long nAngle, double tn, bool bVShear)
504 SetGlueReallyAbsolute(true);
505 ShearPoint(aRefPoint,rRef,tn);
506 SdrObjList* pOL=pSub;
507 const size_t nObjCount = pOL->GetObjCount();
508 for (size_t i=0; i<nObjCount; ++i) {
509 SdrObject* pObj=pOL->GetObj(i);
510 pObj->NbcShear(rRef,nAngle,tn,bVShear);
512 NbcShearGluePoints(rRef,nAngle,tn,bVShear);
513 SetGlueReallyAbsolute(false);
517 void SdrObjGroup::NbcSetAnchorPos(const Point& rPnt)
519 aAnchor=rPnt;
520 Size aSiz(rPnt.X()-aAnchor.X(),rPnt.Y()-aAnchor.Y());
521 MovePoint(aRefPoint,aSiz);
522 SdrObjList* pOL=pSub;
523 const size_t nObjCount=pOL->GetObjCount();
524 for (size_t i=0; i<nObjCount; ++i) {
525 SdrObject* pObj=pOL->GetObj(i);
526 pObj->NbcSetAnchorPos(rPnt);
531 void SdrObjGroup::SetSnapRect(const Rectangle& rRect)
533 Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
534 Rectangle aOld(GetSnapRect());
535 long nMulX=rRect.Right()-rRect.Left();
536 long nDivX=aOld.Right()-aOld.Left();
537 long nMulY=rRect.Bottom()-rRect.Top();
538 long nDivY=aOld.Bottom()-aOld.Top();
539 if (nDivX==0) { nMulX=1; nDivX=1; }
540 if (nDivY==0) { nMulY=1; nDivY=1; }
541 if (nMulX!=nDivX || nMulY!=nDivY) {
542 Fraction aX(nMulX,nDivX);
543 Fraction aY(nMulY,nDivY);
544 Resize(aOld.TopLeft(),aX,aY);
546 if (rRect.Left()!=aOld.Left() || rRect.Top()!=aOld.Top()) {
547 Move(Size(rRect.Left()-aOld.Left(),rRect.Top()-aOld.Top()));
550 SetChanged();
551 BroadcastObjectChange();
552 SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
556 void SdrObjGroup::SetLogicRect(const Rectangle& rRect)
558 SetSnapRect(rRect);
562 void SdrObjGroup::Move(const Size& rSiz)
564 if (rSiz.Width()!=0 || rSiz.Height()!=0) {
565 Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
566 MovePoint(aRefPoint,rSiz);
567 if (pSub->GetObjCount()!=0) {
568 // first move the connectors, then everything else
569 SdrObjList* pOL=pSub;
570 const size_t nObjCount = pOL->GetObjCount();
571 for (size_t i=0; i<nObjCount; ++i) {
572 SdrObject* pObj=pOL->GetObj(i);
573 if (pObj->IsEdgeObj()) pObj->Move(rSiz);
575 for (size_t i=0; i<nObjCount; ++i) {
576 SdrObject* pObj=pOL->GetObj(i);
577 if (!pObj->IsEdgeObj()) pObj->Move(rSiz);
579 } else {
580 MoveRect(aOutRect,rSiz);
581 SetRectsDirty();
584 SetChanged();
585 BroadcastObjectChange();
586 SendUserCall(SDRUSERCALL_MOVEONLY,aBoundRect0);
591 void SdrObjGroup::Resize(const Point& rRef, const Fraction& xFact, const Fraction& yFact, bool bUnsetRelative)
593 if (xFact.GetNumerator()!=xFact.GetDenominator() || yFact.GetNumerator()!=yFact.GetDenominator()) {
594 bool bXMirr=(xFact.GetNumerator()<0) != (xFact.GetDenominator()<0);
595 bool bYMirr=(yFact.GetNumerator()<0) != (yFact.GetDenominator()<0);
596 if (bXMirr || bYMirr) {
597 Point aRef1(GetSnapRect().Center());
598 if (bXMirr) {
599 Point aRef2(aRef1);
600 aRef2.Y()++;
601 NbcMirrorGluePoints(aRef1,aRef2);
603 if (bYMirr) {
604 Point aRef2(aRef1);
605 aRef2.X()++;
606 NbcMirrorGluePoints(aRef1,aRef2);
609 Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
610 ResizePoint(aRefPoint,rRef,xFact,yFact);
611 if (pSub->GetObjCount()!=0) {
612 // move the connectors first, everything else afterwards
613 SdrObjList* pOL=pSub;
614 const size_t nObjCount = pOL->GetObjCount();
615 for (size_t i=0; i<nObjCount; ++i) {
616 SdrObject* pObj=pOL->GetObj(i);
617 if (pObj->IsEdgeObj()) pObj->Resize(rRef,xFact,yFact,bUnsetRelative);
619 for (size_t i=0; i<nObjCount; ++i) {
620 SdrObject* pObj=pOL->GetObj(i);
621 if (!pObj->IsEdgeObj()) pObj->Resize(rRef,xFact,yFact,bUnsetRelative);
623 } else {
624 ResizeRect(aOutRect,rRef,xFact,yFact);
625 SetRectsDirty();
628 SetChanged();
629 BroadcastObjectChange();
630 SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
635 void SdrObjGroup::Rotate(const Point& rRef, long nAngle, double sn, double cs)
637 if (nAngle!=0) {
638 SetGlueReallyAbsolute(true);
639 Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
640 RotatePoint(aRefPoint,rRef,sn,cs);
641 // move the connectors first, everything else afterwards
642 SdrObjList* pOL=pSub;
643 const size_t nObjCount = pOL->GetObjCount();
644 for (size_t i=0; i<nObjCount; ++i) {
645 SdrObject* pObj=pOL->GetObj(i);
646 if (pObj->IsEdgeObj()) pObj->Rotate(rRef,nAngle,sn,cs);
648 for (size_t i=0; i<nObjCount; ++i) {
649 SdrObject* pObj=pOL->GetObj(i);
650 if (!pObj->IsEdgeObj()) pObj->Rotate(rRef,nAngle,sn,cs);
652 NbcRotateGluePoints(rRef,nAngle,sn,cs);
653 SetGlueReallyAbsolute(false);
654 SetChanged();
655 BroadcastObjectChange();
656 SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
661 void SdrObjGroup::Mirror(const Point& rRef1, const Point& rRef2)
663 SetGlueReallyAbsolute(true);
664 Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
665 MirrorPoint(aRefPoint,rRef1,rRef2); // implementation missing in SvdEtc!
666 // move the connectors first, everything else afterwards
667 SdrObjList* pOL=pSub;
668 const size_t nObjCount = pOL->GetObjCount();
669 for (size_t i=0; i<nObjCount; ++i) {
670 SdrObject* pObj=pOL->GetObj(i);
671 if (pObj->IsEdgeObj()) pObj->Mirror(rRef1,rRef2);
673 for (size_t i=0; i<nObjCount; ++i) {
674 SdrObject* pObj=pOL->GetObj(i);
675 if (!pObj->IsEdgeObj()) pObj->Mirror(rRef1,rRef2);
677 NbcMirrorGluePoints(rRef1,rRef2);
678 SetGlueReallyAbsolute(false);
679 SetChanged();
680 BroadcastObjectChange();
681 SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
685 void SdrObjGroup::Shear(const Point& rRef, long nAngle, double tn, bool bVShear)
687 if (nAngle!=0) {
688 SetGlueReallyAbsolute(true);
689 Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
690 ShearPoint(aRefPoint,rRef,tn);
691 // move the connectors first, everything else afterwards
692 SdrObjList* pOL=pSub;
693 const size_t nObjCount = pOL->GetObjCount();
694 for (size_t i=0; i<nObjCount; ++i) {
695 SdrObject* pObj=pOL->GetObj(i);
696 if (pObj->IsEdgeObj()) pObj->Shear(rRef,nAngle,tn,bVShear);
698 for (size_t i=0; i<nObjCount; ++i) {
699 SdrObject* pObj=pOL->GetObj(i);
700 if (!pObj->IsEdgeObj()) pObj->Shear(rRef,nAngle,tn,bVShear);
702 NbcShearGluePoints(rRef,nAngle,tn,bVShear);
703 SetGlueReallyAbsolute(false);
704 SetChanged();
705 BroadcastObjectChange();
706 SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
711 void SdrObjGroup::SetAnchorPos(const Point& rPnt)
713 Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
714 bool bChg=aAnchor!=rPnt;
715 aAnchor=rPnt;
716 Size aSiz(rPnt.X()-aAnchor.X(),rPnt.Y()-aAnchor.Y());
717 MovePoint(aRefPoint,aSiz);
718 // move the connectors first, everything else afterwards
719 SdrObjList* pOL=pSub;
720 const size_t nObjCount = pOL->GetObjCount();
721 for (size_t i=0; i<nObjCount; ++i) {
722 SdrObject* pObj=pOL->GetObj(i);
723 if (pObj->IsEdgeObj()) pObj->SetAnchorPos(rPnt);
725 for (size_t i=0; i<nObjCount; ++i) {
726 SdrObject* pObj = pOL->GetObj(i);
727 if (!pObj->IsEdgeObj()) pObj->SetAnchorPos(rPnt);
729 if (bChg) {
730 SetChanged();
731 BroadcastObjectChange();
732 SendUserCall(SDRUSERCALL_MOVEONLY,aBoundRect0);
738 void SdrObjGroup::NbcSetRelativePos(const Point& rPnt)
740 Point aRelPos0(GetSnapRect().TopLeft()-aAnchor);
741 Size aSiz(rPnt.X()-aRelPos0.X(),rPnt.Y()-aRelPos0.Y());
742 NbcMove(aSiz); // this also calls SetRectsDirty()
745 void SdrObjGroup::SetRelativePos(const Point& rPnt)
747 Point aRelPos0(GetSnapRect().TopLeft()-aAnchor);
748 Size aSiz(rPnt.X()-aRelPos0.X(),rPnt.Y()-aRelPos0.Y());
749 if (aSiz.Width()!=0 || aSiz.Height()!=0) Move(aSiz); // this also calls SetRectsDirty() and Broadcast, ...
752 void SdrObjGroup::NbcReformatText()
754 pSub->NbcReformatAllTextObjects();
757 void SdrObjGroup::ReformatText()
759 pSub->ReformatAllTextObjects();
762 SdrObject* SdrObjGroup::DoConvertToPolyObj(bool bBezier, bool bAddText) const
764 SdrObject* pGroup = new SdrObjGroup;
765 pGroup->SetModel(GetModel());
767 for(size_t a=0; a<pSub->GetObjCount(); ++a)
769 SdrObject* pIterObj = pSub->GetObj(a);
770 SdrObject* pResult = pIterObj->DoConvertToPolyObj(bBezier, bAddText);
772 // pResult can be NULL e.g. for empty objects
773 if( pResult )
774 pGroup->GetSubList()->NbcInsertObject(pResult);
777 return pGroup;
780 void SdrObjGroup::dumpAsXml(xmlTextWriterPtr pWriter) const
782 xmlTextWriterStartElement(pWriter, BAD_CAST("sdrObjGroup"));
783 xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", this);
785 SdrObject::dumpAsXml(pWriter);
787 pSub->dumpAsXml(pWriter);
788 xmlTextWriterEndElement(pWriter);
791 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */