Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <sfx2/linkmgr.hxx>
30 : :
31 : : #include <ucbhelper/content.hxx>
32 : : #include <ucbhelper/contentbroker.hxx>
33 : : #include <unotools/datetime.hxx>
34 : :
35 : : #include <svx/svdogrp.hxx>
36 : :
37 : : #include <sfx2/lnkbase.hxx>
38 : :
39 : : #include <svl/urihelper.hxx>
40 : :
41 : : #include <svx/xpool.hxx>
42 : : #include <svx/xpoly.hxx>
43 : :
44 : : #include <svx/svdmodel.hxx>
45 : : #include <svx/svdpage.hxx>
46 : : #include "svx/svditer.hxx"
47 : : #include <svx/svdobj.hxx>
48 : : #include <svx/svdtrans.hxx>
49 : : #include <svx/svdetc.hxx>
50 : : #include <svx/svdattrx.hxx> // NotPersistItems
51 : : #include <svx/svdoedge.hxx> // broadcast connectors to Move
52 : : #include "svx/svdglob.hxx" // StringCache
53 : : #include "svx/svdstr.hrc" // the object's name
54 : :
55 : : #include <svx/svxids.hrc>
56 : : #include <svl/whiter.hxx>
57 : : #include <svx/svdpool.hxx>
58 : : #include <svx/sdr/properties/groupproperties.hxx>
59 : : #include <svx/sdr/contact/viewcontactofgroup.hxx>
60 : : #include <basegfx/range/b2drange.hxx>
61 : : #include <basegfx/polygon/b2dpolygontools.hxx>
62 : : #include <basegfx/polygon/b2dpolygon.hxx>
63 : :
64 : : //////////////////////////////////////////////////////////////////////////////
65 : : // BaseProperties section
66 : :
67 : 34814 : sdr::properties::BaseProperties* SdrObjGroup::CreateObjectSpecificProperties()
68 : : {
69 [ + - ]: 34814 : return new sdr::properties::GroupProperties(*this);
70 : : }
71 : :
72 : : //////////////////////////////////////////////////////////////////////////////
73 : : // DrawContact section
74 : :
75 : 34814 : sdr::contact::ViewContact* SdrObjGroup::CreateObjectSpecificViewContact()
76 : : {
77 [ + - ]: 34814 : return new sdr::contact::ViewContactOfGroup(*this);
78 : : }
79 : :
80 : : //////////////////////////////////////////////////////////////////////////////
81 : :
82 [ + + ][ - + ]: 3738946 : TYPEINIT1(SdrObjGroup,SdrObject);
83 : :
84 : 34814 : SdrObjGroup::SdrObjGroup()
85 : : {
86 [ + - ][ + - ]: 34814 : pSub=new SdrObjList(NULL,NULL);
87 : 34814 : pSub->SetOwnerObj(this);
88 : 34814 : pSub->SetListKind(SDROBJLIST_GROUPOBJ);
89 : 34814 : bRefPoint=sal_False;
90 : 34814 : nDrehWink=0;
91 : 34814 : nShearWink=0;
92 : 34814 : bClosedObj=sal_False;
93 : 34814 : }
94 : :
95 : :
96 : 34814 : SdrObjGroup::~SdrObjGroup()
97 : : {
98 [ + - ][ + - ]: 34814 : delete pSub;
99 [ - + ]: 69628 : }
100 : :
101 : 0 : void SdrObjGroup::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const
102 : : {
103 : 0 : rInfo.bNoContortion=sal_False;
104 : 0 : SdrObjList* pOL=pSub;
105 : 0 : sal_uIntPtr nObjAnz=pOL->GetObjCount();
106 [ # # ]: 0 : for (sal_uIntPtr i=0; i<nObjAnz; i++) {
107 [ # # ]: 0 : SdrObject* pObj=pOL->GetObj(i);
108 [ # # ]: 0 : SdrObjTransformInfoRec aInfo;
109 [ # # ]: 0 : pObj->TakeObjInfo(aInfo);
110 [ # # ]: 0 : if (!aInfo.bMoveAllowed ) rInfo.bMoveAllowed =sal_False;
111 [ # # ]: 0 : if (!aInfo.bResizeFreeAllowed ) rInfo.bResizeFreeAllowed =sal_False;
112 [ # # ]: 0 : if (!aInfo.bResizePropAllowed ) rInfo.bResizePropAllowed =sal_False;
113 [ # # ]: 0 : if (!aInfo.bRotateFreeAllowed ) rInfo.bRotateFreeAllowed =sal_False;
114 [ # # ]: 0 : if (!aInfo.bRotate90Allowed ) rInfo.bRotate90Allowed =sal_False;
115 [ # # ]: 0 : if (!aInfo.bMirrorFreeAllowed ) rInfo.bMirrorFreeAllowed =sal_False;
116 [ # # ]: 0 : if (!aInfo.bMirror45Allowed ) rInfo.bMirror45Allowed =sal_False;
117 [ # # ]: 0 : if (!aInfo.bMirror90Allowed ) rInfo.bMirror90Allowed =sal_False;
118 [ # # ]: 0 : if (!aInfo.bShearAllowed ) rInfo.bShearAllowed =sal_False;
119 [ # # ]: 0 : if (!aInfo.bEdgeRadiusAllowed ) rInfo.bEdgeRadiusAllowed =sal_False;
120 [ # # ]: 0 : if (!aInfo.bNoOrthoDesired ) rInfo.bNoOrthoDesired =sal_False;
121 [ # # ]: 0 : if (aInfo.bNoContortion ) rInfo.bNoContortion =sal_True;
122 [ # # ]: 0 : if (!aInfo.bCanConvToPath ) rInfo.bCanConvToPath =sal_False;
123 : :
124 [ # # ]: 0 : if(!aInfo.bCanConvToContour)
125 : 0 : rInfo.bCanConvToContour = sal_False;
126 : :
127 [ # # ]: 0 : if (!aInfo.bCanConvToPoly ) rInfo.bCanConvToPoly =sal_False;
128 [ # # ]: 0 : if (!aInfo.bCanConvToPathLineToArea) rInfo.bCanConvToPathLineToArea=sal_False;
129 [ # # ]: 0 : if (!aInfo.bCanConvToPolyLineToArea) rInfo.bCanConvToPolyLineToArea=sal_False;
130 : : }
131 [ # # ]: 0 : if (nObjAnz==0) {
132 : 0 : rInfo.bRotateFreeAllowed=sal_False;
133 : 0 : rInfo.bRotate90Allowed =sal_False;
134 : 0 : rInfo.bMirrorFreeAllowed=sal_False;
135 : 0 : rInfo.bMirror45Allowed =sal_False;
136 : 0 : rInfo.bMirror90Allowed =sal_False;
137 : 0 : rInfo.bTransparenceAllowed = sal_False;
138 : 0 : rInfo.bGradientAllowed = sal_False;
139 : 0 : rInfo.bShearAllowed =sal_False;
140 : 0 : rInfo.bEdgeRadiusAllowed=sal_False;
141 : 0 : rInfo.bNoContortion =sal_True;
142 : : }
143 [ # # ]: 0 : if(nObjAnz != 1)
144 : : {
145 : : // only allowed if single object selected
146 : 0 : rInfo.bTransparenceAllowed = sal_False;
147 : 0 : rInfo.bGradientAllowed = sal_False;
148 : : }
149 : 0 : }
150 : :
151 : :
152 : 65377 : void SdrObjGroup::SetBoundRectDirty()
153 : : {
154 : : // avoid resetting aOutRect which in case of this object is model data,
155 : : // not re-creatable view data
156 : 65377 : }
157 : :
158 : 321122 : sal_uInt16 SdrObjGroup::GetObjIdentifier() const
159 : : {
160 : 321122 : return sal_uInt16(OBJ_GRUP);
161 : : }
162 : :
163 : :
164 : 145510 : SdrLayerID SdrObjGroup::GetLayer() const
165 : : {
166 : 145510 : bool b1st = true;
167 : 145510 : SdrLayerID nLay=SdrLayerID(SdrObject::GetLayer());
168 : 145510 : SdrObjList* pOL=pSub;
169 : 145510 : sal_uIntPtr nObjAnz=pOL->GetObjCount();
170 [ + + ]: 510962 : for (sal_uIntPtr i=0; i<nObjAnz; i++) {
171 : 365452 : SdrLayerID nLay1=pOL->GetObj(i)->GetLayer();
172 [ + + ]: 365452 : if (b1st) { nLay=nLay1; b1st = false; }
173 [ - + ]: 220337 : else if (nLay1!=nLay) return 0;
174 : : }
175 : 145510 : return nLay;
176 : : }
177 : :
178 : :
179 : 45 : void SdrObjGroup::NbcSetLayer(SdrLayerID nLayer)
180 : : {
181 : 45 : SdrObject::NbcSetLayer(nLayer);
182 : 45 : SdrObjList* pOL=pSub;
183 : 45 : sal_uIntPtr nObjAnz=pOL->GetObjCount();
184 [ + + ]: 405 : for (sal_uIntPtr i=0; i<nObjAnz; i++) {
185 : 360 : pOL->GetObj(i)->NbcSetLayer(nLayer);
186 : : }
187 : 45 : }
188 : :
189 : :
190 : 44814 : void SdrObjGroup::SetObjList(SdrObjList* pNewObjList)
191 : : {
192 : 44814 : SdrObject::SetObjList(pNewObjList);
193 : 44814 : pSub->SetUpList(pNewObjList);
194 : 44814 : }
195 : :
196 : :
197 : 102841 : void SdrObjGroup::SetPage(SdrPage* pNewPage)
198 : : {
199 : 102841 : SdrObject::SetPage(pNewPage);
200 : 102841 : pSub->SetPage(pNewPage);
201 : 102841 : }
202 : :
203 : :
204 : 69512 : void SdrObjGroup::SetModel(SdrModel* pNewModel)
205 : : {
206 [ + + ]: 69512 : if(pNewModel!=pModel)
207 : : {
208 : : // #i30648#
209 : : // This method also needs to migrate the used ItemSet
210 : : // when the destination model uses a different pool
211 : : // than the current one. Else it is possible to create
212 : : // SdrObjGroups which reference the old pool which might
213 : : // be destroyed (as the bug shows).
214 : 34814 : SdrModel* pOldModel = pModel;
215 : :
216 : : // test for correct pool in ItemSet; move to new pool if necessary
217 [ + - ][ + - ]: 34814 : if(pNewModel && GetObjectItemPool() && GetObjectItemPool() != &pNewModel->GetItemPool())
[ + - ][ + - ]
218 : : {
219 : 34814 : MigrateItemPool(GetObjectItemPool(), &pNewModel->GetItemPool(), pNewModel);
220 : : }
221 : :
222 : : // call parent
223 : 34814 : SdrObject::SetModel(pNewModel);
224 : :
225 : : // set new model at content
226 : 34814 : pSub->SetModel(pNewModel);
227 : :
228 : : // modify properties
229 : 34814 : GetProperties().SetModel(pOldModel, pNewModel);
230 : : }
231 : 69512 : }
232 : :
233 : :
234 : 0 : bool SdrObjGroup::HasRefPoint() const
235 : : {
236 : 0 : return bRefPoint;
237 : : }
238 : :
239 : :
240 : 0 : Point SdrObjGroup::GetRefPoint() const
241 : : {
242 : 0 : return aRefPoint;
243 : : }
244 : :
245 : :
246 : 0 : void SdrObjGroup::SetRefPoint(const Point& rPnt)
247 : : {
248 : 0 : bRefPoint=sal_True;
249 : 0 : aRefPoint=rPnt;
250 : 0 : }
251 : :
252 : :
253 : 1170902 : SdrObjList* SdrObjGroup::GetSubList() const
254 : : {
255 : 1170902 : return pSub;
256 : : }
257 : :
258 : 61966 : const Rectangle& SdrObjGroup::GetCurrentBoundRect() const
259 : : {
260 : : // <aOutRect> has to contain the bounding rectangle
261 [ + + ]: 61966 : if ( pSub->GetObjCount()!=0 )
262 : : {
263 : 43251 : const_cast<SdrObjGroup*>(this)->aOutRect = pSub->GetAllObjBoundRect();
264 : : }
265 : :
266 : 61966 : return aOutRect;
267 : : }
268 : :
269 : 337476 : const Rectangle& SdrObjGroup::GetSnapRect() const
270 : : {
271 : : // <aOutRect> has to contain the bounding rectangle
272 [ + + ]: 337476 : if ( pSub->GetObjCount()!=0 )
273 : : {
274 : 53095 : return pSub->GetAllObjSnapRect();
275 : : }
276 : : else
277 : : {
278 : 337476 : return aOutRect;
279 : : }
280 : : }
281 : :
282 : 0 : SdrObjGroup* SdrObjGroup::Clone() const
283 : : {
284 : 0 : return CloneHelper< SdrObjGroup >();
285 : : }
286 : :
287 : 0 : SdrObjGroup& SdrObjGroup::operator=(const SdrObjGroup& rObj)
288 : : {
289 [ # # ]: 0 : if( this == &rObj )
290 : 0 : return *this;
291 : : // copy SdrObject stuff
292 : 0 : SdrObject::operator=(rObj);
293 : :
294 : : // #i36404#
295 : : // copy SubList, init model and page first
296 : 0 : SdrObjList& rSourceSubList = *rObj.GetSubList();
297 : 0 : pSub->SetPage(rSourceSubList.GetPage());
298 : 0 : pSub->SetModel(rSourceSubList.GetModel());
299 : 0 : pSub->CopyObjects(*rObj.GetSubList());
300 : :
301 : : // copy local parameters
302 : 0 : nDrehWink = rObj.nDrehWink;
303 : 0 : nShearWink = rObj.nShearWink;
304 : 0 : aRefPoint = rObj.aRefPoint;
305 : 0 : bRefPoint = rObj.bRefPoint;
306 : 0 : return *this;
307 : : }
308 : :
309 : :
310 : 89 : void SdrObjGroup::TakeObjNameSingul(XubString& rName) const
311 : : {
312 [ + - ][ + + ]: 89 : if(!pSub->GetObjCount())
313 : : {
314 [ + - ][ + - ]: 74 : rName = ImpGetResStr(STR_ObjNameSingulGRUPEMPTY);
[ + - ]
315 : : }
316 : : else
317 : : {
318 [ + - ][ + - ]: 15 : rName = ImpGetResStr(STR_ObjNameSingulGRUP);
[ + - ]
319 : : }
320 : :
321 [ + - ][ + - ]: 89 : const String aName(GetName());
322 : :
323 [ - + ]: 89 : if(aName.Len())
324 : : {
325 [ # # ]: 0 : rName += sal_Unicode(' ');
326 [ # # ]: 0 : rName += sal_Unicode('\'');
327 [ # # ]: 0 : rName += aName;
328 [ # # ]: 0 : rName += sal_Unicode('\'');
329 [ + - ]: 89 : }
330 : 89 : }
331 : :
332 : :
333 : 9 : void SdrObjGroup::TakeObjNamePlural(XubString& rName) const
334 : : {
335 [ - + ]: 9 : if (pSub->GetObjCount()==0) {
336 [ # # ]: 0 : rName=ImpGetResStr(STR_ObjNamePluralGRUPEMPTY);
337 : : } else {
338 [ + - ]: 9 : rName=ImpGetResStr(STR_ObjNamePluralGRUP);
339 : : }
340 : 9 : }
341 : :
342 : :
343 : 0 : void SdrObjGroup::RecalcSnapRect()
344 : : {
345 : : // TODO: unnecessary, because we use the Rects from the SubList
346 : 0 : }
347 : :
348 : 0 : basegfx::B2DPolyPolygon SdrObjGroup::TakeXorPoly() const
349 : : {
350 : 0 : basegfx::B2DPolyPolygon aRetval;
351 [ # # ]: 0 : const sal_uInt32 nObjCount(pSub->GetObjCount());
352 : :
353 [ # # ]: 0 : for(sal_uInt32 a(0L); a < nObjCount; a++)
354 : : {
355 [ # # ]: 0 : SdrObject* pObj = pSub->GetObj(a);
356 [ # # ][ # # ]: 0 : aRetval.append(pObj->TakeXorPoly());
[ # # ]
357 : : }
358 : :
359 [ # # ][ # # ]: 0 : if(!aRetval.count())
360 : : {
361 [ # # ]: 0 : const basegfx::B2DRange aRange(aOutRect.Left(), aOutRect.Top(), aOutRect.Right(), aOutRect.Bottom());
362 [ # # ][ # # ]: 0 : aRetval.append(basegfx::tools::createPolygonFromRect(aRange));
[ # # ]
363 : : }
364 : :
365 : 0 : return aRetval;
366 : : }
367 : :
368 : 0 : bool SdrObjGroup::beginSpecialDrag(SdrDragStat& /*rDrag*/) const
369 : : {
370 : 0 : return false;
371 : : }
372 : :
373 : :
374 : 0 : bool SdrObjGroup::BegCreate(SdrDragStat& /*rStat*/)
375 : : {
376 : 0 : return sal_False;
377 : : }
378 : :
379 : :
380 : 0 : long SdrObjGroup::GetRotateAngle() const
381 : : {
382 : 0 : return nDrehWink;
383 : : }
384 : :
385 : :
386 : 0 : long SdrObjGroup::GetShearAngle(bool /*bVertical*/) const
387 : : {
388 : 0 : return nShearWink;
389 : : }
390 : :
391 : :
392 : 0 : void SdrObjGroup::NbcSetSnapRect(const Rectangle& rRect)
393 : : {
394 [ # # ]: 0 : Rectangle aOld(GetSnapRect());
395 : 0 : long nMulX=rRect.Right()-rRect.Left();
396 : 0 : long nDivX=aOld.Right()-aOld.Left();
397 : 0 : long nMulY=rRect.Bottom()-rRect.Top();
398 : 0 : long nDivY=aOld.Bottom()-aOld.Top();
399 [ # # ]: 0 : if (nDivX==0) { nMulX=1; nDivX=1; }
400 [ # # ]: 0 : if (nDivY==0) { nMulY=1; nDivY=1; }
401 [ # # ][ # # ]: 0 : if (nMulX!=nDivX || nMulY!=nDivY) {
402 [ # # ]: 0 : Fraction aX(nMulX,nDivX);
403 [ # # ]: 0 : Fraction aY(nMulY,nDivY);
404 [ # # ]: 0 : NbcResize(aOld.TopLeft(),aX,aY);
405 : : }
406 [ # # ][ # # ]: 0 : if (rRect.Left()!=aOld.Left() || rRect.Top()!=aOld.Top()) {
[ # # ]
407 [ # # ]: 0 : NbcMove(Size(rRect.Left()-aOld.Left(),rRect.Top()-aOld.Top()));
408 : : }
409 : 0 : }
410 : :
411 : :
412 : 0 : void SdrObjGroup::NbcSetLogicRect(const Rectangle& rRect)
413 : : {
414 : 0 : NbcSetSnapRect(rRect);
415 : 0 : }
416 : :
417 : :
418 : 0 : void SdrObjGroup::NbcMove(const Size& rSiz)
419 : : {
420 : 0 : MovePoint(aRefPoint,rSiz);
421 [ # # ]: 0 : if (pSub->GetObjCount()!=0) {
422 : 0 : SdrObjList* pOL=pSub;
423 : 0 : sal_uIntPtr nObjAnz=pOL->GetObjCount();
424 [ # # ]: 0 : for (sal_uIntPtr i=0; i<nObjAnz; i++) {
425 : 0 : SdrObject* pObj=pOL->GetObj(i);
426 : 0 : pObj->NbcMove(rSiz);
427 : : }
428 : : } else {
429 : 0 : MoveRect(aOutRect,rSiz);
430 : 0 : SetRectsDirty();
431 : : }
432 : 0 : }
433 : :
434 : :
435 : 0 : void SdrObjGroup::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact)
436 : : {
437 : 0 : bool bXMirr=(xFact.GetNumerator()<0) != (xFact.GetDenominator()<0);
438 : 0 : bool bYMirr=(yFact.GetNumerator()<0) != (yFact.GetDenominator()<0);
439 [ # # ][ # # ]: 0 : if (bXMirr || bYMirr) {
440 [ # # ][ # # ]: 0 : Point aRef1(GetSnapRect().Center());
441 [ # # ]: 0 : if (bXMirr) {
442 : 0 : Point aRef2(aRef1);
443 : 0 : aRef2.Y()++;
444 [ # # ]: 0 : NbcMirrorGluePoints(aRef1,aRef2);
445 : : }
446 [ # # ]: 0 : if (bYMirr) {
447 : 0 : Point aRef2(aRef1);
448 : 0 : aRef2.X()++;
449 [ # # ]: 0 : NbcMirrorGluePoints(aRef1,aRef2);
450 : : }
451 : : }
452 [ # # ][ # # ]: 0 : ResizePoint(aRefPoint,rRef,xFact,yFact);
453 [ # # ]: 0 : if (pSub->GetObjCount()!=0) {
454 : 0 : SdrObjList* pOL=pSub;
455 : 0 : sal_uIntPtr nObjAnz=pOL->GetObjCount();
456 [ # # ]: 0 : for (sal_uIntPtr i=0; i<nObjAnz; i++) {
457 : 0 : SdrObject* pObj=pOL->GetObj(i);
458 : 0 : pObj->NbcResize(rRef,xFact,yFact);
459 : : }
460 : : } else {
461 : 0 : ResizeRect(aOutRect,rRef,xFact,yFact);
462 : 0 : SetRectsDirty();
463 : : }
464 : 0 : }
465 : :
466 : :
467 : 0 : void SdrObjGroup::NbcRotate(const Point& rRef, long nWink, double sn, double cs)
468 : : {
469 : 0 : SetGlueReallyAbsolute(sal_True);
470 : 0 : nDrehWink=NormAngle360(nDrehWink+nWink);
471 : 0 : RotatePoint(aRefPoint,rRef,sn,cs);
472 : 0 : SdrObjList* pOL=pSub;
473 : 0 : sal_uIntPtr nObjAnz=pOL->GetObjCount();
474 [ # # ]: 0 : for (sal_uIntPtr i=0; i<nObjAnz; i++) {
475 : 0 : SdrObject* pObj=pOL->GetObj(i);
476 : 0 : pObj->NbcRotate(rRef,nWink,sn,cs);
477 : : }
478 : 0 : NbcRotateGluePoints(rRef,nWink,sn,cs);
479 : 0 : SetGlueReallyAbsolute(sal_False);
480 : 0 : }
481 : :
482 : :
483 : 0 : void SdrObjGroup::NbcMirror(const Point& rRef1, const Point& rRef2)
484 : : {
485 : 0 : SetGlueReallyAbsolute(sal_True);
486 : 0 : MirrorPoint(aRefPoint,rRef1,rRef2); // implementation missing in SvdEtc!
487 : 0 : SdrObjList* pOL=pSub;
488 : 0 : sal_uIntPtr nObjAnz=pOL->GetObjCount();
489 [ # # ]: 0 : for (sal_uIntPtr i=0; i<nObjAnz; i++) {
490 : 0 : SdrObject* pObj=pOL->GetObj(i);
491 : 0 : pObj->NbcMirror(rRef1,rRef2);
492 : : }
493 : 0 : NbcMirrorGluePoints(rRef1,rRef2);
494 : 0 : SetGlueReallyAbsolute(sal_False);
495 : 0 : }
496 : :
497 : :
498 : 0 : void SdrObjGroup::NbcShear(const Point& rRef, long nWink, double tn, bool bVShear)
499 : : {
500 : 0 : SetGlueReallyAbsolute(sal_True);
501 : 0 : nShearWink+=nWink;
502 : 0 : ShearPoint(aRefPoint,rRef,tn);
503 : 0 : SdrObjList* pOL=pSub;
504 : 0 : sal_uIntPtr nObjAnz=pOL->GetObjCount();
505 [ # # ]: 0 : for (sal_uIntPtr i=0; i<nObjAnz; i++) {
506 : 0 : SdrObject* pObj=pOL->GetObj(i);
507 : 0 : pObj->NbcShear(rRef,nWink,tn,bVShear);
508 : : }
509 : 0 : NbcShearGluePoints(rRef,nWink,tn,bVShear);
510 : 0 : SetGlueReallyAbsolute(sal_False);
511 : 0 : }
512 : :
513 : :
514 : 0 : void SdrObjGroup::NbcSetAnchorPos(const Point& rPnt)
515 : : {
516 : 0 : aAnchor=rPnt;
517 : 0 : Size aSiz(rPnt.X()-aAnchor.X(),rPnt.Y()-aAnchor.Y());
518 : 0 : MovePoint(aRefPoint,aSiz);
519 : 0 : SdrObjList* pOL=pSub;
520 [ # # ]: 0 : sal_uIntPtr nObjAnz=pOL->GetObjCount();
521 [ # # ]: 0 : for (sal_uIntPtr i=0; i<nObjAnz; i++) {
522 [ # # ]: 0 : SdrObject* pObj=pOL->GetObj(i);
523 [ # # ]: 0 : pObj->NbcSetAnchorPos(rPnt);
524 : : }
525 : 0 : }
526 : :
527 : :
528 : 100146 : void SdrObjGroup::SetSnapRect(const Rectangle& rRect)
529 : : {
530 [ + - ][ + + ]: 100146 : Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
[ + - ]
531 [ + - ]: 100146 : Rectangle aOld(GetSnapRect());
532 : 100146 : long nMulX=rRect.Right()-rRect.Left();
533 : 100146 : long nDivX=aOld.Right()-aOld.Left();
534 : 100146 : long nMulY=rRect.Bottom()-rRect.Top();
535 : 100146 : long nDivY=aOld.Bottom()-aOld.Top();
536 [ - + ]: 100146 : if (nDivX==0) { nMulX=1; nDivX=1; }
537 [ - + ]: 100146 : if (nDivY==0) { nMulY=1; nDivY=1; }
538 [ + + ][ - + ]: 100146 : if (nMulX!=nDivX || nMulY!=nDivY) {
539 [ + - ]: 65386 : Fraction aX(nMulX,nDivX);
540 [ + - ]: 65386 : Fraction aY(nMulY,nDivY);
541 [ + - ]: 65386 : Resize(aOld.TopLeft(),aX,aY);
542 : : }
543 [ + - ][ + + ]: 100146 : if (rRect.Left()!=aOld.Left() || rRect.Top()!=aOld.Top()) {
[ + + ]
544 [ + - ]: 5 : Move(Size(rRect.Left()-aOld.Left(),rRect.Top()-aOld.Top()));
545 : : }
546 : :
547 [ + - ]: 100146 : SetChanged();
548 [ + - ]: 100146 : BroadcastObjectChange();
549 [ + - ]: 100146 : SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
550 : 100146 : }
551 : :
552 : :
553 : 6 : void SdrObjGroup::SetLogicRect(const Rectangle& rRect)
554 : : {
555 : 6 : SetSnapRect(rRect);
556 : 6 : }
557 : :
558 : :
559 : 48574 : void SdrObjGroup::Move(const Size& rSiz)
560 : : {
561 [ + + ][ + + ]: 48574 : if (rSiz.Width()!=0 || rSiz.Height()!=0) {
[ + + ]
562 [ + - ][ + + ]: 13784 : Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
[ + - ]
563 : 13784 : MovePoint(aRefPoint,rSiz);
564 [ + - ][ + - ]: 13784 : if (pSub->GetObjCount()!=0) {
565 : : // first move the connectors, then everything else
566 : 13784 : SdrObjList* pOL=pSub;
567 [ + - ]: 13784 : sal_uIntPtr nObjAnz=pOL->GetObjCount();
568 : : sal_uIntPtr i;
569 [ + + ]: 40402 : for (i=0; i<nObjAnz; i++) {
570 [ + - ]: 26618 : SdrObject* pObj=pOL->GetObj(i);
571 [ + - ][ - + ]: 26618 : if (pObj->IsEdgeObj()) pObj->Move(rSiz);
[ # # ]
572 : : }
573 [ + + ]: 40402 : for (i=0; i<nObjAnz; i++) {
574 [ + - ]: 26618 : SdrObject* pObj=pOL->GetObj(i);
575 [ + - ][ + - ]: 26618 : if (!pObj->IsEdgeObj()) pObj->Move(rSiz);
[ + - ]
576 : : }
577 : : } else {
578 [ # # ]: 0 : MoveRect(aOutRect,rSiz);
579 [ # # ]: 0 : SetRectsDirty();
580 : : }
581 : :
582 [ + - ]: 13784 : SetChanged();
583 [ + - ]: 13784 : BroadcastObjectChange();
584 [ + - ]: 13784 : SendUserCall(SDRUSERCALL_MOVEONLY,aBoundRect0);
585 : : }
586 : 48574 : }
587 : :
588 : :
589 : 65386 : void SdrObjGroup::Resize(const Point& rRef, const Fraction& xFact, const Fraction& yFact)
590 : : {
591 [ - + ][ # # ]: 65386 : if (xFact.GetNumerator()!=xFact.GetDenominator() || yFact.GetNumerator()!=yFact.GetDenominator()) {
[ + - ]
592 : 65386 : bool bXMirr=(xFact.GetNumerator()<0) != (xFact.GetDenominator()<0);
593 : 65386 : bool bYMirr=(yFact.GetNumerator()<0) != (yFact.GetDenominator()<0);
594 [ - + ][ + + ]: 65386 : if (bXMirr || bYMirr) {
595 [ + - ][ + - ]: 65362 : Point aRef1(GetSnapRect().Center());
596 [ + - ]: 65362 : if (bXMirr) {
597 : 65362 : Point aRef2(aRef1);
598 : 65362 : aRef2.Y()++;
599 [ + - ]: 65362 : NbcMirrorGluePoints(aRef1,aRef2);
600 : : }
601 [ + - ]: 65362 : if (bYMirr) {
602 : 65362 : Point aRef2(aRef1);
603 : 65362 : aRef2.X()++;
604 [ + - ]: 65362 : NbcMirrorGluePoints(aRef1,aRef2);
605 : : }
606 : : }
607 [ + - ][ + + ]: 65386 : Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
[ + - ]
608 [ + - ][ + - ]: 65386 : ResizePoint(aRefPoint,rRef,xFact,yFact);
[ + - ]
609 [ + - ][ + + ]: 65386 : if (pSub->GetObjCount()!=0) {
610 : : // move the connectors first, everything else afterwards
611 : 9 : SdrObjList* pOL=pSub;
612 [ + - ]: 9 : sal_uIntPtr nObjAnz=pOL->GetObjCount();
613 : : sal_uIntPtr i;
614 [ + + ]: 33 : for (i=0; i<nObjAnz; i++) {
615 [ + - ]: 24 : SdrObject* pObj=pOL->GetObj(i);
616 [ + - ][ - + ]: 24 : if (pObj->IsEdgeObj()) pObj->Resize(rRef,xFact,yFact);
[ # # ]
617 : : }
618 [ + + ]: 33 : for (i=0; i<nObjAnz; i++) {
619 [ + - ]: 24 : SdrObject* pObj=pOL->GetObj(i);
620 [ + - ][ + - ]: 24 : if (!pObj->IsEdgeObj()) pObj->Resize(rRef,xFact,yFact);
[ + - ]
621 : : }
622 : : } else {
623 [ + - ]: 65377 : ResizeRect(aOutRect,rRef,xFact,yFact);
624 [ + - ]: 65377 : SetRectsDirty();
625 : : }
626 : :
627 [ + - ]: 65386 : SetChanged();
628 [ + - ]: 65386 : BroadcastObjectChange();
629 [ + - ]: 65386 : SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
630 : : }
631 : 65386 : }
632 : :
633 : :
634 : 0 : void SdrObjGroup::Rotate(const Point& rRef, long nWink, double sn, double cs)
635 : : {
636 [ # # ]: 0 : if (nWink!=0) {
637 [ # # ]: 0 : SetGlueReallyAbsolute(sal_True);
638 [ # # ][ # # ]: 0 : Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
[ # # ]
639 [ # # ]: 0 : nDrehWink=NormAngle360(nDrehWink+nWink);
640 : 0 : RotatePoint(aRefPoint,rRef,sn,cs);
641 : : // move the connectors first, everything else afterwards
642 : 0 : SdrObjList* pOL=pSub;
643 [ # # ]: 0 : sal_uIntPtr nObjAnz=pOL->GetObjCount();
644 : : sal_uIntPtr i;
645 [ # # ]: 0 : for (i=0; i<nObjAnz; i++) {
646 [ # # ]: 0 : SdrObject* pObj=pOL->GetObj(i);
647 [ # # ][ # # ]: 0 : if (pObj->IsEdgeObj()) pObj->Rotate(rRef,nWink,sn,cs);
[ # # ]
648 : : }
649 [ # # ]: 0 : for (i=0; i<nObjAnz; i++) {
650 [ # # ]: 0 : SdrObject* pObj=pOL->GetObj(i);
651 [ # # ][ # # ]: 0 : if (!pObj->IsEdgeObj()) pObj->Rotate(rRef,nWink,sn,cs);
[ # # ]
652 : : }
653 [ # # ]: 0 : NbcRotateGluePoints(rRef,nWink,sn,cs);
654 [ # # ]: 0 : SetGlueReallyAbsolute(sal_False);
655 [ # # ]: 0 : SetChanged();
656 [ # # ]: 0 : BroadcastObjectChange();
657 [ # # ]: 0 : SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
658 : : }
659 : 0 : }
660 : :
661 : :
662 : 0 : void SdrObjGroup::Mirror(const Point& rRef1, const Point& rRef2)
663 : : {
664 [ # # ]: 0 : SetGlueReallyAbsolute(sal_True);
665 [ # # ][ # # ]: 0 : Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
[ # # ]
666 [ # # ]: 0 : MirrorPoint(aRefPoint,rRef1,rRef2); // implementation missing in SvdEtc!
667 : : // move the connectors first, everything else afterwards
668 : 0 : SdrObjList* pOL=pSub;
669 [ # # ]: 0 : sal_uIntPtr nObjAnz=pOL->GetObjCount();
670 : : sal_uIntPtr i;
671 [ # # ]: 0 : for (i=0; i<nObjAnz; i++) {
672 [ # # ]: 0 : SdrObject* pObj=pOL->GetObj(i);
673 [ # # ][ # # ]: 0 : if (pObj->IsEdgeObj()) pObj->Mirror(rRef1,rRef2);
[ # # ]
674 : : }
675 [ # # ]: 0 : for (i=0; i<nObjAnz; i++) {
676 [ # # ]: 0 : SdrObject* pObj=pOL->GetObj(i);
677 [ # # ][ # # ]: 0 : if (!pObj->IsEdgeObj()) pObj->Mirror(rRef1,rRef2);
[ # # ]
678 : : }
679 [ # # ]: 0 : NbcMirrorGluePoints(rRef1,rRef2);
680 [ # # ]: 0 : SetGlueReallyAbsolute(sal_False);
681 [ # # ]: 0 : SetChanged();
682 [ # # ]: 0 : BroadcastObjectChange();
683 [ # # ]: 0 : SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
684 : 0 : }
685 : :
686 : :
687 : 0 : void SdrObjGroup::Shear(const Point& rRef, long nWink, double tn, bool bVShear)
688 : : {
689 [ # # ]: 0 : if (nWink!=0) {
690 [ # # ]: 0 : SetGlueReallyAbsolute(sal_True);
691 [ # # ][ # # ]: 0 : Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
[ # # ]
692 : 0 : nShearWink+=nWink;
693 : 0 : ShearPoint(aRefPoint,rRef,tn);
694 : : // move the connectors first, everything else afterwards
695 : 0 : SdrObjList* pOL=pSub;
696 [ # # ]: 0 : sal_uIntPtr nObjAnz=pOL->GetObjCount();
697 : : sal_uIntPtr i;
698 [ # # ]: 0 : for (i=0; i<nObjAnz; i++) {
699 [ # # ]: 0 : SdrObject* pObj=pOL->GetObj(i);
700 [ # # ][ # # ]: 0 : if (pObj->IsEdgeObj()) pObj->Shear(rRef,nWink,tn,bVShear);
[ # # ]
701 : : }
702 [ # # ]: 0 : for (i=0; i<nObjAnz; i++) {
703 [ # # ]: 0 : SdrObject* pObj=pOL->GetObj(i);
704 [ # # ][ # # ]: 0 : if (!pObj->IsEdgeObj()) pObj->Shear(rRef,nWink,tn,bVShear);
[ # # ]
705 : : }
706 [ # # ]: 0 : NbcShearGluePoints(rRef,nWink,tn,bVShear);
707 [ # # ]: 0 : SetGlueReallyAbsolute(sal_False);
708 [ # # ]: 0 : SetChanged();
709 [ # # ]: 0 : BroadcastObjectChange();
710 [ # # ]: 0 : SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
711 : : }
712 : 0 : }
713 : :
714 : :
715 : 9 : void SdrObjGroup::SetAnchorPos(const Point& rPnt)
716 : : {
717 [ + - ][ + - ]: 9 : Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
[ + - ]
718 : 9 : bool bChg=aAnchor!=rPnt;
719 : 9 : aAnchor=rPnt;
720 : 9 : Size aSiz(rPnt.X()-aAnchor.X(),rPnt.Y()-aAnchor.Y());
721 : 9 : MovePoint(aRefPoint,aSiz);
722 : : // move the connectors first, everything else afterwards
723 : 9 : SdrObjList* pOL=pSub;
724 [ + - ]: 9 : sal_uIntPtr nObjAnz=pOL->GetObjCount();
725 : : sal_uIntPtr i;
726 [ + + ]: 45 : for (i=0; i<nObjAnz; i++) {
727 [ + - ]: 36 : SdrObject* pObj=pOL->GetObj(i);
728 [ + - ][ - + ]: 36 : if (pObj->IsEdgeObj()) pObj->SetAnchorPos(rPnt);
[ # # ]
729 : : }
730 [ + + ]: 45 : for (i=0; i<nObjAnz; i++) {
731 [ + - ]: 36 : SdrObject* pObj=pOL->GetObj(i);
732 [ + - ][ + - ]: 36 : if (!pObj->IsEdgeObj()) pObj->SetAnchorPos(rPnt);
[ + - ]
733 : : }
734 [ + + ]: 9 : if (bChg) {
735 [ + - ]: 6 : SetChanged();
736 [ + - ]: 6 : BroadcastObjectChange();
737 [ + - ]: 6 : SendUserCall(SDRUSERCALL_MOVEONLY,aBoundRect0);
738 : : }
739 : 9 : }
740 : :
741 : :
742 : :
743 : 0 : void SdrObjGroup::NbcSetRelativePos(const Point& rPnt)
744 : : {
745 [ # # ]: 0 : Point aRelPos0(GetSnapRect().TopLeft()-aAnchor);
746 : 0 : Size aSiz(rPnt.X()-aRelPos0.X(),rPnt.Y()-aRelPos0.Y());
747 [ # # ]: 0 : NbcMove(aSiz); // this also calls SetRectsDirty()
748 : 0 : }
749 : :
750 : 0 : void SdrObjGroup::SetRelativePos(const Point& rPnt)
751 : : {
752 [ # # ]: 0 : Point aRelPos0(GetSnapRect().TopLeft()-aAnchor);
753 : 0 : Size aSiz(rPnt.X()-aRelPos0.X(),rPnt.Y()-aRelPos0.Y());
754 [ # # ][ # # ]: 0 : if (aSiz.Width()!=0 || aSiz.Height()!=0) Move(aSiz); // this also calls SetRectsDirty() and Broadcast, ...
[ # # ][ # # ]
755 : 0 : }
756 : :
757 : 0 : void SdrObjGroup::NbcReformatText()
758 : : {
759 : 0 : pSub->NbcReformatAllTextObjects();
760 : 0 : }
761 : :
762 : 0 : void SdrObjGroup::ReformatText()
763 : : {
764 : 0 : pSub->ReformatAllTextObjects();
765 : 0 : }
766 : :
767 : 0 : SdrObject* SdrObjGroup::DoConvertToPolyObj(sal_Bool bBezier) const
768 : : {
769 [ # # ]: 0 : SdrObject* pGroup = new SdrObjGroup;
770 : 0 : pGroup->SetModel(GetModel());
771 : :
772 [ # # ]: 0 : for(sal_uInt32 a=0;a<pSub->GetObjCount();a++)
773 : : {
774 : 0 : SdrObject* pIterObj = pSub->GetObj(a);
775 : 0 : SdrObject* pResult = pIterObj->DoConvertToPolyObj(bBezier);
776 : :
777 : : // pResult can be NULL e.g. for empty objects
778 [ # # ]: 0 : if( pResult )
779 : 0 : pGroup->GetSubList()->NbcInsertObject(pResult);
780 : : }
781 : :
782 : 0 : return pGroup;
783 : : }
784 : :
785 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|