1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <svx/svdogrp.hxx>
#include <svx/svdmodel.hxx>
#include <svx/svdpage.hxx>
#include <svx/svdobj.hxx>
#include <svx/svdtrans.hxx>
#include <svx/dialmgr.hxx>
#include <svx/strings.hrc>
#include <sdr/properties/groupproperties.hxx>
#include <sdr/contact/viewcontactofgroup.hxx>
#include <basegfx/range/b2drange.hxx>
#include <basegfx/polygon/b2dpolygontools.hxx>
#include <basegfx/polygon/b2dpolygon.hxx>
#include <libxml/xmlwriter.h>
#include <rtl/ustrbuf.hxx>
#include <vcl/canvastools.hxx>
// BaseProperties section
std::unique_ptr<sdr::properties::BaseProperties> SdrObjGroup::CreateObjectSpecificProperties()
{
return std::make_unique<sdr::properties::GroupProperties>(*this);
}
// DrawContact section
std::unique_ptr<sdr::contact::ViewContact> SdrObjGroup::CreateObjectSpecificViewContact()
{
return std::make_unique<sdr::contact::ViewContactOfGroup>(*this);
}
SdrObjGroup::SdrObjGroup(SdrModel& rSdrModel)
: SdrObject(rSdrModel),
SdrObjList(),
aRefPoint(0, 0)
{
bClosedObj=false;
}
SdrObjGroup::~SdrObjGroup()
{
}
SdrPage* SdrObjGroup::getSdrPageFromSdrObjList() const
{
return getSdrPageFromSdrObject();
}
SdrObject* SdrObjGroup::getSdrObjectFromSdrObjList() const
{
return const_cast< SdrObjGroup* >(this);
}
SdrObjList* SdrObjGroup::getChildrenOfSdrObject() const
{
return const_cast< SdrObjGroup* >(this);
}
void SdrObjGroup::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const
{
rInfo.bNoContortion=false;
const size_t nObjCount(GetObjCount());
for (size_t i=0; i<nObjCount; ++i) {
SdrObject* pObj(GetObj(i));
SdrObjTransformInfoRec aInfo;
pObj->TakeObjInfo(aInfo);
if (!aInfo.bMoveAllowed ) rInfo.bMoveAllowed =false;
if (!aInfo.bResizeFreeAllowed ) rInfo.bResizeFreeAllowed =false;
if (!aInfo.bResizePropAllowed ) rInfo.bResizePropAllowed =false;
if (!aInfo.bRotateFreeAllowed ) rInfo.bRotateFreeAllowed =false;
if (!aInfo.bRotate90Allowed ) rInfo.bRotate90Allowed =false;
if (!aInfo.bMirrorFreeAllowed ) rInfo.bMirrorFreeAllowed =false;
if (!aInfo.bMirror45Allowed ) rInfo.bMirror45Allowed =false;
if (!aInfo.bMirror90Allowed ) rInfo.bMirror90Allowed =false;
if (!aInfo.bShearAllowed ) rInfo.bShearAllowed =false;
if (!aInfo.bEdgeRadiusAllowed ) rInfo.bEdgeRadiusAllowed =false;
if (!aInfo.bNoOrthoDesired ) rInfo.bNoOrthoDesired =false;
if (aInfo.bNoContortion ) rInfo.bNoContortion =true;
if (!aInfo.bCanConvToPath ) rInfo.bCanConvToPath =false;
if(!aInfo.bCanConvToContour)
rInfo.bCanConvToContour = false;
if (!aInfo.bCanConvToPoly ) rInfo.bCanConvToPoly =false;
if (!aInfo.bCanConvToPathLineToArea) rInfo.bCanConvToPathLineToArea=false;
if (!aInfo.bCanConvToPolyLineToArea) rInfo.bCanConvToPolyLineToArea=false;
}
if (nObjCount==0) {
rInfo.bRotateFreeAllowed=false;
rInfo.bRotate90Allowed =false;
rInfo.bMirrorFreeAllowed=false;
rInfo.bMirror45Allowed =false;
rInfo.bMirror90Allowed =false;
rInfo.bTransparenceAllowed = false;
rInfo.bShearAllowed =false;
rInfo.bEdgeRadiusAllowed=false;
rInfo.bNoContortion =true;
}
if(nObjCount != 1)
{
// only allowed if single object selected
rInfo.bTransparenceAllowed = false;
}
}
void SdrObjGroup::SetBoundRectDirty()
{
// avoid resetting aOutRect which in case of this object is model data,
// not re-creatable view data
}
sal_uInt16 SdrObjGroup::GetObjIdentifier() const
{
return sal_uInt16(OBJ_GRUP);
}
SdrLayerID SdrObjGroup::GetLayer() const
{
bool b1st = true;
SdrLayerID nLay = SdrObject::GetLayer();
const size_t nObjCount(GetObjCount());
for (size_t i=0; i<nObjCount; ++i) {
SdrLayerID nLay1(GetObj(i)->GetLayer());
if (b1st) { nLay=nLay1; b1st = false; }
else if (nLay1!=nLay) return SdrLayerID(0);
}
return nLay;
}
void SdrObjGroup::NbcSetLayer(SdrLayerID nLayer)
{
SdrObject::NbcSetLayer(nLayer);
const size_t nObjCount(GetObjCount());
for (size_t i=0; i<nObjCount; ++i) {
GetObj(i)->NbcSetLayer(nLayer);
}
}
void SdrObjGroup::handlePageChange(SdrPage* pOldPage, SdrPage* pNewPage)
{
// call parent
SdrObject::handlePageChange(pOldPage, pNewPage);
for(size_t i(0); i < GetObjCount(); i++)
{
GetObj(i)->handlePageChange(pOldPage, pNewPage);
}
}
SdrObjList* SdrObjGroup::GetSubList() const
{
return const_cast< SdrObjGroup* >(this);
}
const tools::Rectangle& SdrObjGroup::GetCurrentBoundRect() const
{
// <aOutRect> has to contain the bounding rectangle
if(0 != GetObjCount())
{
const_cast< SdrObjGroup* >(this)->aOutRect = GetAllObjBoundRect();
}
return aOutRect;
}
const tools::Rectangle& SdrObjGroup::GetSnapRect() const
{
// <aOutRect> has to contain the bounding rectangle
if(0 != GetObjCount())
{
return GetAllObjSnapRect();
}
else
{
return aOutRect;
}
}
SdrObjGroup* SdrObjGroup::CloneSdrObject(SdrModel& rTargetModel) const
{
return CloneHelper< SdrObjGroup >(rTargetModel);
}
SdrObjGroup& SdrObjGroup::operator=(const SdrObjGroup& rObj)
{
if( this == &rObj )
return *this;
// copy SdrObject stuff
SdrObject::operator=(rObj);
// copy child SdrObjects
if(nullptr != rObj.GetSubList())
{
// #i36404# Copy SubList, init model and page first
const SdrObjList& rSourceSubList(*rObj.GetSubList());
CopyObjects(rSourceSubList);
// tdf#116979: needed here, we need bSnapRectDirty to be true
// which it is after using SdrObject::operator= (see above),
// but set to false again using CopyObjects
SetRectsDirty();
}
// copy local parameters
aRefPoint = rObj.aRefPoint;
return *this;
}
OUString SdrObjGroup::TakeObjNameSingul() const
{
OUStringBuffer sName;
if(0 == GetObjCount())
{
sName.append(SvxResId(STR_ObjNameSingulGRUPEMPTY));
}
else
{
sName.append(SvxResId(STR_ObjNameSingulGRUP));
}
const OUString aName(GetName());
if (!aName.isEmpty())
{
sName.append(' ');
sName.append('\'');
sName.append(aName);
sName.append('\'');
}
return sName.makeStringAndClear();
}
OUString SdrObjGroup::TakeObjNamePlural() const
{
if(0 == GetObjCount())
return SvxResId(STR_ObjNamePluralGRUPEMPTY);
return SvxResId(STR_ObjNamePluralGRUP);
}
void SdrObjGroup::RecalcSnapRect()
{
// TODO: unnecessary, because we use the Rects from the SubList
}
basegfx::B2DPolyPolygon SdrObjGroup::TakeXorPoly() const
{
basegfx::B2DPolyPolygon aRetval;
const size_t nObjCount(GetObjCount());
for(size_t a = 0; a < nObjCount; ++a)
{
SdrObject* pObj(GetObj(a));
aRetval.append(pObj->TakeXorPoly());
}
if(!aRetval.count())
{
const basegfx::B2DRange aRange = vcl::unotools::b2DRectangleFromRectangle(aOutRect);
aRetval.append(basegfx::utils::createPolygonFromRect(aRange));
}
return aRetval;
}
bool SdrObjGroup::beginSpecialDrag(SdrDragStat& /*rDrag*/) const
{
return false;
}
bool SdrObjGroup::BegCreate(SdrDragStat& /*rStat*/)
{
return false;
}
long SdrObjGroup::GetRotateAngle() const
{
long nRetval(0);
if(0 != GetObjCount())
{
SdrObject* pObj(GetObj(0));
nRetval = pObj->GetRotateAngle();
}
return nRetval;
}
long SdrObjGroup::GetShearAngle(bool /*bVertical*/) const
{
long nRetval(0);
if(0 != GetObjCount())
{
SdrObject* pObj(GetObj(0));
nRetval = pObj->GetShearAngle();
}
return nRetval;
}
void SdrObjGroup::NbcSetSnapRect(const tools::Rectangle& rRect)
{
tools::Rectangle aOld(GetSnapRect());
long nMulX=rRect.Right()-rRect.Left();
long nDivX=aOld.Right()-aOld.Left();
long nMulY=rRect.Bottom()-rRect.Top();
long nDivY=aOld.Bottom()-aOld.Top();
if (nDivX==0) { nMulX=1; nDivX=1; }
if (nDivY==0) { nMulY=1; nDivY=1; }
if (nMulX!=nDivX || nMulY!=nDivY) {
Fraction aX(nMulX,nDivX);
Fraction aY(nMulY,nDivY);
NbcResize(aOld.TopLeft(),aX,aY);
}
if (rRect.Left()!=aOld.Left() || rRect.Top()!=aOld.Top()) {
NbcMove(Size(rRect.Left()-aOld.Left(),rRect.Top()-aOld.Top()));
}
}
void SdrObjGroup::NbcSetLogicRect(const tools::Rectangle& rRect)
{
NbcSetSnapRect(rRect);
}
void SdrObjGroup::NbcMove(const Size& rSiz)
{
aRefPoint.Move(rSiz);
const size_t nObjCount(GetObjCount());
if(0 != nObjCount)
{
for (size_t i=0; i<nObjCount; ++i)
{
SdrObject* pObj(GetObj(i));
pObj->NbcMove(rSiz);
}
}
else
{
aOutRect.Move(rSiz);
SetRectsDirty();
}
}
void SdrObjGroup::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact)
{
bool bXMirr=(xFact.GetNumerator()<0) != (xFact.GetDenominator()<0);
bool bYMirr=(yFact.GetNumerator()<0) != (yFact.GetDenominator()<0);
if (bXMirr || bYMirr) {
Point aRef1(GetSnapRect().Center());
if (bXMirr) {
Point aRef2(aRef1);
aRef2.AdjustY( 1 );
NbcMirrorGluePoints(aRef1,aRef2);
}
if (bYMirr) {
Point aRef2(aRef1);
aRef2.AdjustX( 1 );
NbcMirrorGluePoints(aRef1,aRef2);
}
}
ResizePoint(aRefPoint,rRef,xFact,yFact);
const size_t nObjCount(GetObjCount());
if(0 != nObjCount)
{
for (size_t i=0; i<nObjCount; ++i)
{
SdrObject* pObj(GetObj(i));
pObj->NbcResize(rRef,xFact,yFact);
}
}
else
{
ResizeRect(aOutRect,rRef,xFact,yFact);
SetRectsDirty();
}
}
void SdrObjGroup::NbcRotate(const Point& rRef, long nAngle, double sn, double cs)
{
SetGlueReallyAbsolute(true);
RotatePoint(aRefPoint,rRef,sn,cs);
const size_t nObjCount(GetObjCount());
for (size_t i=0; i<nObjCount; ++i)
{
SdrObject* pObj(GetObj(i));
pObj->NbcRotate(rRef,nAngle,sn,cs);
}
NbcRotateGluePoints(rRef,nAngle,sn,cs);
SetGlueReallyAbsolute(false);
}
void SdrObjGroup::NbcMirror(const Point& rRef1, const Point& rRef2)
{
SetGlueReallyAbsolute(true);
MirrorPoint(aRefPoint,rRef1,rRef2); // implementation missing in SvdEtc!
const size_t nObjCount(GetObjCount());
for (size_t i=0; i<nObjCount; ++i)
{
SdrObject* pObj(GetObj(i));
pObj->NbcMirror(rRef1,rRef2);
}
NbcMirrorGluePoints(rRef1,rRef2);
SetGlueReallyAbsolute(false);
}
void SdrObjGroup::NbcShear(const Point& rRef, long nAngle, double tn, bool bVShear)
{
SetGlueReallyAbsolute(true);
ShearPoint(aRefPoint,rRef,tn);
const size_t nObjCount(GetObjCount());
for (size_t i=0; i<nObjCount; ++i)
{
SdrObject* pObj(GetObj(i));
pObj->NbcShear(rRef,nAngle,tn,bVShear);
}
NbcShearGluePoints(rRef,tn,bVShear);
SetGlueReallyAbsolute(false);
}
void SdrObjGroup::NbcSetAnchorPos(const Point& rPnt)
{
aAnchor=rPnt;
Size aSiz(rPnt.X()-aAnchor.X(),rPnt.Y()-aAnchor.Y());
aRefPoint.Move(aSiz);
const size_t nObjCount(GetObjCount());
for (size_t i=0; i<nObjCount; ++i)
{
SdrObject* pObj(GetObj(i));
pObj->NbcSetAnchorPos(rPnt);
}
}
void SdrObjGroup::SetSnapRect(const tools::Rectangle& rRect)
{
tools::Rectangle aBoundRect0; if (pUserCall!=nullptr) aBoundRect0=GetLastBoundRect();
tools::Rectangle aOld(GetSnapRect());
if (aOld.IsEmpty())
{
Fraction aX(1,1);
Fraction aY(1,1);
Resize(aOld.TopLeft(),aX,aY);
}
else
{
long nMulX=rRect.Right()-rRect.Left();
long nDivX=aOld.Right()-aOld.Left();
long nMulY=rRect.Bottom()-rRect.Top();
long nDivY=aOld.Bottom()-aOld.Top();
if (nDivX==0) { nMulX=1; nDivX=1; }
if (nDivY==0) { nMulY=1; nDivY=1; }
if (nMulX!=nDivX || nMulY!=nDivY) {
Fraction aX(nMulX,nDivX);
Fraction aY(nMulY,nDivY);
Resize(aOld.TopLeft(),aX,aY);
}
}
if (rRect.Left()!=aOld.Left() || rRect.Top()!=aOld.Top()) {
Move(Size(rRect.Left()-aOld.Left(),rRect.Top()-aOld.Top()));
}
SetChanged();
BroadcastObjectChange();
SendUserCall(SdrUserCallType::Resize,aBoundRect0);
}
void SdrObjGroup::SetLogicRect(const tools::Rectangle& rRect)
{
SetSnapRect(rRect);
}
void SdrObjGroup::Move(const Size& rSiz)
{
if (rSiz.Width()!=0 || rSiz.Height()!=0) {
tools::Rectangle aBoundRect0; if (pUserCall!=nullptr) aBoundRect0=GetLastBoundRect();
aRefPoint.Move(rSiz);
const size_t nObjCount(GetObjCount());
if(0 != nObjCount)
{
// first move the connectors, then everything else
for (size_t i=0; i<nObjCount; ++i)
{
SdrObject* pObj(GetObj(i));
if (pObj->IsEdgeObj())
pObj->Move(rSiz);
}
for (size_t i=0; i<nObjCount; ++i)
{
SdrObject* pObj(GetObj(i));
if (!pObj->IsEdgeObj())
pObj->Move(rSiz);
}
}
else
{
aOutRect.Move(rSiz);
SetRectsDirty();
}
SetChanged();
BroadcastObjectChange();
SendUserCall(SdrUserCallType::MoveOnly,aBoundRect0);
}
}
void SdrObjGroup::Resize(const Point& rRef, const Fraction& xFact, const Fraction& yFact, bool bUnsetRelative)
{
if (xFact.GetNumerator()!=xFact.GetDenominator() || yFact.GetNumerator()!=yFact.GetDenominator()) {
bool bXMirr=(xFact.GetNumerator()<0) != (xFact.GetDenominator()<0);
bool bYMirr=(yFact.GetNumerator()<0) != (yFact.GetDenominator()<0);
if (bXMirr || bYMirr) {
Point aRef1(GetSnapRect().Center());
if (bXMirr) {
Point aRef2(aRef1);
aRef2.AdjustY( 1 );
NbcMirrorGluePoints(aRef1,aRef2);
}
if (bYMirr) {
Point aRef2(aRef1);
aRef2.AdjustX( 1 );
NbcMirrorGluePoints(aRef1,aRef2);
}
}
tools::Rectangle aBoundRect0; if (pUserCall!=nullptr) aBoundRect0=GetLastBoundRect();
ResizePoint(aRefPoint,rRef,xFact,yFact);
const size_t nObjCount(GetObjCount());
if(0 != nObjCount)
{
// move the connectors first, everything else afterwards
for (size_t i=0; i<nObjCount; ++i)
{
SdrObject* pObj(GetObj(i));
if (pObj->IsEdgeObj())
pObj->Resize(rRef,xFact,yFact,bUnsetRelative);
}
for (size_t i=0; i<nObjCount; ++i)
{
SdrObject* pObj(GetObj(i));
if (!pObj->IsEdgeObj())
pObj->Resize(rRef,xFact,yFact,bUnsetRelative);
}
}
else
{
ResizeRect(aOutRect,rRef,xFact,yFact);
SetRectsDirty();
}
SetChanged();
BroadcastObjectChange();
SendUserCall(SdrUserCallType::Resize,aBoundRect0);
}
}
void SdrObjGroup::Rotate(const Point& rRef, long nAngle, double sn, double cs)
{
if (nAngle==0)
return;
SetGlueReallyAbsolute(true);
tools::Rectangle aBoundRect0; if (pUserCall!=nullptr) aBoundRect0=GetLastBoundRect();
RotatePoint(aRefPoint,rRef,sn,cs);
// move the connectors first, everything else afterwards
const size_t nObjCount(GetObjCount());
for (size_t i=0; i<nObjCount; ++i)
{
SdrObject* pObj(GetObj(i));
if (pObj->IsEdgeObj())
pObj->Rotate(rRef,nAngle,sn,cs);
}
for (size_t i=0; i<nObjCount; ++i)
{
SdrObject* pObj(GetObj(i));
if (!pObj->IsEdgeObj())
pObj->Rotate(rRef,nAngle,sn,cs);
}
NbcRotateGluePoints(rRef,nAngle,sn,cs);
SetGlueReallyAbsolute(false);
SetChanged();
BroadcastObjectChange();
SendUserCall(SdrUserCallType::Resize,aBoundRect0);
}
void SdrObjGroup::Mirror(const Point& rRef1, const Point& rRef2)
{
SetGlueReallyAbsolute(true);
tools::Rectangle aBoundRect0; if (pUserCall!=nullptr) aBoundRect0=GetLastBoundRect();
MirrorPoint(aRefPoint,rRef1,rRef2); // implementation missing in SvdEtc!
// move the connectors first, everything else afterwards
const size_t nObjCount(GetObjCount());
for (size_t i=0; i<nObjCount; ++i)
{
SdrObject* pObj(GetObj(i));
if (pObj->IsEdgeObj())
pObj->Mirror(rRef1,rRef2);
}
for (size_t i=0; i<nObjCount; ++i)
{
SdrObject* pObj(GetObj(i));
if (!pObj->IsEdgeObj())
pObj->Mirror(rRef1,rRef2);
}
NbcMirrorGluePoints(rRef1,rRef2);
SetGlueReallyAbsolute(false);
SetChanged();
BroadcastObjectChange();
SendUserCall(SdrUserCallType::Resize,aBoundRect0);
}
void SdrObjGroup::Shear(const Point& rRef, long nAngle, double tn, bool bVShear)
{
if (nAngle==0)
return;
SetGlueReallyAbsolute(true);
tools::Rectangle aBoundRect0; if (pUserCall!=nullptr) aBoundRect0=GetLastBoundRect();
ShearPoint(aRefPoint,rRef,tn);
// move the connectors first, everything else afterwards
const size_t nObjCount(GetObjCount());
for (size_t i=0; i<nObjCount; ++i)
{
SdrObject* pObj(GetObj(i));
if (pObj->IsEdgeObj())
pObj->Shear(rRef,nAngle,tn,bVShear);
}
for (size_t i=0; i<nObjCount; ++i)
{
SdrObject* pObj(GetObj(i));
if (!pObj->IsEdgeObj())
pObj->Shear(rRef,nAngle,tn,bVShear);
}
NbcShearGluePoints(rRef,tn,bVShear);
SetGlueReallyAbsolute(false);
SetChanged();
BroadcastObjectChange();
SendUserCall(SdrUserCallType::Resize,aBoundRect0);
}
void SdrObjGroup::SetAnchorPos(const Point& rPnt)
{
tools::Rectangle aBoundRect0; if (pUserCall!=nullptr) aBoundRect0=GetLastBoundRect();
bool bChg=aAnchor!=rPnt;
aAnchor=rPnt;
Size aSiz(rPnt.X()-aAnchor.X(),rPnt.Y()-aAnchor.Y());
aRefPoint.Move(aSiz);
// move the connectors first, everything else afterwards
const size_t nObjCount(GetObjCount());
for (size_t i=0; i<nObjCount; ++i)
{
SdrObject* pObj(GetObj(i));
if (pObj->IsEdgeObj())
pObj->SetAnchorPos(rPnt);
}
for (size_t i=0; i<nObjCount; ++i)
{
SdrObject* pObj(GetObj(i));
if (!pObj->IsEdgeObj())
pObj->SetAnchorPos(rPnt);
}
if (bChg)
{
SetChanged();
BroadcastObjectChange();
SendUserCall(SdrUserCallType::MoveOnly,aBoundRect0);
}
}
void SdrObjGroup::NbcSetRelativePos(const Point& rPnt)
{
Point aRelPos0(GetSnapRect().TopLeft()-aAnchor);
Size aSiz(rPnt.X()-aRelPos0.X(),rPnt.Y()-aRelPos0.Y());
NbcMove(aSiz); // this also calls SetRectsDirty()
}
void SdrObjGroup::SetRelativePos(const Point& rPnt)
{
Point aRelPos0(GetSnapRect().TopLeft()-aAnchor);
Size aSiz(rPnt.X()-aRelPos0.X(),rPnt.Y()-aRelPos0.Y());
if (aSiz.Width()!=0 || aSiz.Height()!=0) Move(aSiz); // this also calls SetRectsDirty() and Broadcast, ...
}
void SdrObjGroup::NbcReformatText()
{
NbcReformatAllTextObjects();
}
SdrObjectUniquePtr SdrObjGroup::DoConvertToPolyObj(bool bBezier, bool bAddText) const
{
SdrObjectUniquePtr pGroup( new SdrObjGroup(getSdrModelFromSdrObject()) );
const size_t nObjCount(GetObjCount());
for(size_t a=0; a < nObjCount; ++a)
{
SdrObject* pIterObj(GetObj(a));
SdrObjectUniquePtr pResult(pIterObj->DoConvertToPolyObj(bBezier, bAddText));
// pResult can be NULL e.g. for empty objects
if( pResult )
pGroup->GetSubList()->NbcInsertObject(pResult.release());
}
return pGroup;
}
void SdrObjGroup::dumpAsXml(xmlTextWriterPtr pWriter) const
{
xmlTextWriterStartElement(pWriter, BAD_CAST("SdrObjGroup"));
xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", this);
SdrObject::dumpAsXml(pWriter);
SdrObjList::dumpAsXml(pWriter);
xmlTextWriterEndElement(pWriter);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|