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
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
|
/* -*- 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 <vcl/metaact.hxx>
#include <svx/svdedtv.hxx>
#include <svx/svdundo.hxx>
#include <svx/svdograf.hxx>
#include <svx/svdopath.hxx>
#include <svx/svdoole2.hxx>
#include <svx/svdopage.hxx>
#include <svx/svdoedge.hxx>
#include <svx/svdlayer.hxx>
#include <svx/svdpagv.hxx>
#include <svx/svdpage.hxx>
#include <svx/svdpoev.hxx>
#include "svx/svdstr.hrc"
#include "svdglob.hxx"
#include <svx/e3dsceneupdater.hxx>
#include <rtl/strbuf.hxx>
#include <svx/svdview.hxx>
#include <clonelist.hxx>
using namespace com::sun::star;
void SdrEditView::ImpResetPossibilityFlags()
{
bReadOnly =false;
bGroupPossible =false;
bUnGroupPossible =false;
bGrpEnterPossible =false;
bDeletePossible =false;
bToTopPossible =false;
bToBtmPossible =false;
bReverseOrderPossible =false;
bImportMtfPossible =false;
bCombinePossible =false;
bDismantlePossible =false;
bCombineNoPolyPolyPossible =false;
bDismantleMakeLinesPossible=false;
bOrthoDesiredOnMarked =false;
bMoreThanOneNotMovable =false;
bOneOrMoreMovable =false;
bMoreThanOneNoMovRot =false;
bContortionPossible =false;
bMoveAllowed =false;
bResizeFreeAllowed =false;
bResizePropAllowed =false;
bRotateFreeAllowed =false;
bRotate90Allowed =false;
bMirrorFreeAllowed =false;
bMirror45Allowed =false;
bMirror90Allowed =false;
bTransparenceAllowed =false;
bCropAllowed =false;
bGradientAllowed =false;
bShearAllowed =false;
bEdgeRadiusAllowed =false;
bCanConvToPath =false;
bCanConvToPoly =false;
bCanConvToContour =false;
bCanConvToPathLineToArea=false;
bCanConvToPolyLineToArea=false;
bMoveProtect =false;
bResizeProtect =false;
}
void SdrEditView::ImpClearVars()
{
ImpResetPossibilityFlags();
bPossibilitiesDirty=true; // << Purify didn't like this
bBundleVirtObj=false;
}
SdrEditView::SdrEditView(SdrModel* pModel1, OutputDevice* pOut):
SdrMarkView(pModel1,pOut)
{
ImpClearVars();
}
SdrEditView::~SdrEditView()
{
}
void SdrEditView::InsertNewLayer(const OUString& rName, sal_uInt16 nPos)
{
SdrLayerAdmin& rLA=mpModel->GetLayerAdmin();
sal_uInt16 nMax=rLA.GetLayerCount();
if (nPos>nMax) nPos=nMax;
rLA.NewLayer(rName,nPos);
if( GetModel()->IsUndoEnabled() )
AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewLayer(nPos,rLA,*mpModel));
mpModel->SetChanged();
}
#include <svx/svdogrp.hxx>
#include <svx/scene3d.hxx>
bool SdrEditView::ImpDelLayerCheck(SdrObjList* pOL, SdrLayerID nDelID) const
{
bool bDelAll(true);
for(size_t nObjNum = pOL->GetObjCount(); nObjNum > 0 && bDelAll;)
{
nObjNum--;
SdrObject* pObj = pOL->GetObj(nObjNum);
SdrObjList* pSubOL = pObj->GetSubList();
// explicitly test for group objects and 3d scenes
if(pSubOL && (dynamic_cast<const SdrObjGroup*>(pObj) != nullptr || dynamic_cast< const E3dScene* >(pObj) != nullptr))
{
if(!ImpDelLayerCheck(pSubOL, nDelID))
{
bDelAll = false;
}
}
else
{
if(pObj->GetLayer() != nDelID)
{
bDelAll = false;
}
}
}
return bDelAll;
}
void SdrEditView::ImpDelLayerDelObjs(SdrObjList* pOL, SdrLayerID nDelID)
{
const size_t nObjCount(pOL->GetObjCount());
// make sure OrdNums are correct
pOL->GetObj(0)->GetOrdNum();
const bool bUndo = GetModel()->IsUndoEnabled();
for(size_t nObjNum = nObjCount; nObjNum > 0;)
{
nObjNum--;
SdrObject* pObj = pOL->GetObj(nObjNum);
SdrObjList* pSubOL = pObj->GetSubList();
// explicitly test for group objects and 3d scenes
if(pSubOL && (dynamic_cast<const SdrObjGroup*>( pObj) != nullptr || dynamic_cast<const E3dScene* >(pObj) != nullptr))
{
if(ImpDelLayerCheck(pSubOL, nDelID))
{
if( bUndo )
AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj, true));
pOL->RemoveObject(nObjNum);
if( !bUndo )
SdrObject::Free( pObj );
}
else
{
ImpDelLayerDelObjs(pSubOL, nDelID);
}
}
else
{
if(pObj->GetLayer() == nDelID)
{
if( bUndo )
AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj, true));
pOL->RemoveObject(nObjNum);
if( !bUndo )
SdrObject::Free( pObj );
}
}
}
}
void SdrEditView::DeleteLayer(const OUString& rName)
{
SdrLayerAdmin& rLA = mpModel->GetLayerAdmin();
SdrLayer* pLayer = rLA.GetLayer(rName, true);
sal_uInt16 nLayerNum(rLA.GetLayerPos(pLayer));
if(SDRLAYER_NOTFOUND != nLayerNum)
{
SdrLayerID nDelID = pLayer->GetID();
const bool bUndo = IsUndoEnabled();
if( bUndo )
BegUndo(ImpGetResStr(STR_UndoDelLayer));
bool bMaPg(true);
for(sal_uInt16 nPageKind(0); nPageKind < 2; nPageKind++)
{
// MasterPages and DrawPages
sal_uInt16 nPgAnz(bMaPg ? mpModel->GetMasterPageCount() : mpModel->GetPageCount());
for(sal_uInt16 nPgNum(0); nPgNum < nPgAnz; nPgNum++)
{
// over all pages
SdrPage* pPage = (bMaPg) ? mpModel->GetMasterPage(nPgNum) : mpModel->GetPage(nPgNum);
const size_t nObjCount(pPage->GetObjCount());
// make sure OrdNums are correct
if(nObjCount)
pPage->GetObj(0)->GetOrdNum();
for(size_t nObjNum(nObjCount); nObjNum > 0;)
{
nObjNum--;
SdrObject* pObj = pPage->GetObj(nObjNum);
SdrObjList* pSubOL = pObj->GetSubList();
// explicitly test for group objects and 3d scenes
if(pSubOL && (dynamic_cast<const SdrObjGroup*>(pObj) != nullptr || dynamic_cast<const E3dScene* >(pObj) != nullptr))
{
if(ImpDelLayerCheck(pSubOL, nDelID))
{
if( bUndo )
AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj, true));
pPage->RemoveObject(nObjNum);
if( !bUndo )
SdrObject::Free(pObj);
}
else
{
ImpDelLayerDelObjs(pSubOL, nDelID);
}
}
else
{
if(pObj->GetLayer() == nDelID)
{
if( bUndo )
AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj, true));
pPage->RemoveObject(nObjNum);
if( !bUndo )
SdrObject::Free(pObj);
}
}
}
}
bMaPg = false;
}
if( bUndo )
{
AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoDeleteLayer(nLayerNum, rLA, *mpModel));
rLA.RemoveLayer(nLayerNum);
EndUndo();
}
else
{
delete rLA.RemoveLayer(nLayerNum);
}
mpModel->SetChanged();
}
}
void SdrEditView::EndUndo()
{
// #i13033#
// Comparison changed to 1L since EndUndo() is called later now
// and EndUndo WILL change count to count-1
if(1L == mpModel->GetUndoBracketLevel())
{
ImpBroadcastEdgesOfMarkedNodes();
}
// #i13033#
// moved to bottom to still have access to UNDOs inside of
// ImpBroadcastEdgesOfMarkedNodes()
mpModel->EndUndo();
}
void SdrEditView::ImpBroadcastEdgesOfMarkedNodes()
{
std::vector<SdrObject*>::const_iterator iterPos;
const std::vector<SdrObject*>& rAllMarkedObjects = GetTransitiveHullOfMarkedObjects();
// #i13033#
// New mechanism to search for necessary disconnections for
// changed connectors inside the transitive hull of all at
// the beginning of UNDO selected objects
for(size_t a(0); a < rAllMarkedObjects.size(); a++)
{
SdrEdgeObj* pEdge = dynamic_cast<SdrEdgeObj*>( rAllMarkedObjects[a] );
if(pEdge)
{
SdrObject* pObj1 = pEdge->GetConnectedNode(false);
SdrObject* pObj2 = pEdge->GetConnectedNode(true);
if(pObj1 && !pEdge->CheckNodeConnection(false))
{
iterPos = std::find(rAllMarkedObjects.begin(),rAllMarkedObjects.end(),pObj1);
if (iterPos == rAllMarkedObjects.end())
{
if( IsUndoEnabled() )
AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pEdge));
pEdge->DisconnectFromNode(false);
}
}
if(pObj2 && !pEdge->CheckNodeConnection(true))
{
iterPos = std::find(rAllMarkedObjects.begin(),rAllMarkedObjects.end(),pObj2);
if (iterPos == rAllMarkedObjects.end())
{
if( IsUndoEnabled() )
AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pEdge));
pEdge->DisconnectFromNode(true);
}
}
}
}
const size_t nMarkedEdgeAnz = GetMarkedEdgesOfMarkedNodes().GetMarkCount();
for (size_t i=0; i<nMarkedEdgeAnz; ++i) {
SdrMark* pEM = GetMarkedEdgesOfMarkedNodes().GetMark(i);
SdrObject* pEdgeTmp=pEM->GetMarkedSdrObj();
SdrEdgeObj* pEdge=dynamic_cast<SdrEdgeObj*>( pEdgeTmp );
if (pEdge!=nullptr) {
pEdge->SetEdgeTrackDirty();
}
}
}
// Possibilities
void SdrEditView::MarkListHasChanged()
{
SdrMarkView::MarkListHasChanged();
bPossibilitiesDirty=true;
}
void SdrEditView::ModelHasChanged()
{
SdrMarkView::ModelHasChanged();
bPossibilitiesDirty=true;
}
bool SdrEditView::IsResizeAllowed(bool bProp) const
{
ForcePossibilities();
if (bResizeProtect) return false;
if (bProp) return bResizePropAllowed;
return bResizeFreeAllowed;
}
bool SdrEditView::IsRotateAllowed(bool b90Deg) const
{
ForcePossibilities();
if (bMoveProtect) return false;
if (b90Deg) return bRotate90Allowed;
return bRotateFreeAllowed;
}
bool SdrEditView::IsMirrorAllowed(bool b45Deg, bool b90Deg) const
{
ForcePossibilities();
if (bMoveProtect) return false;
if (b90Deg) return bMirror90Allowed;
if (b45Deg) return bMirror45Allowed;
return bMirrorFreeAllowed && !bMoveProtect;
}
bool SdrEditView::IsTransparenceAllowed() const
{
ForcePossibilities();
return bTransparenceAllowed;
}
bool SdrEditView::IsCropAllowed() const
{
ForcePossibilities();
return bCropAllowed;
}
bool SdrEditView::IsGradientAllowed() const
{
ForcePossibilities();
return bGradientAllowed;
}
bool SdrEditView::IsShearAllowed() const
{
ForcePossibilities();
if (bResizeProtect) return false;
return bShearAllowed;
}
bool SdrEditView::IsEdgeRadiusAllowed() const
{
ForcePossibilities();
return bEdgeRadiusAllowed;
}
bool SdrEditView::IsCrookAllowed(bool bNoContortion) const
{
// CrookMode missing here (no rotations allowed when shearing ...)
ForcePossibilities();
if (bNoContortion) {
if (!bRotateFreeAllowed) return false;
return !bMoveProtect && bMoveAllowed;
} else {
return !bResizeProtect && bContortionPossible;
}
}
bool SdrEditView::IsDistortAllowed(bool bNoContortion) const
{
ForcePossibilities();
if (bNoContortion) {
return false;
} else {
return !bResizeProtect && bContortionPossible;
}
}
bool SdrEditView::IsCombinePossible(bool bNoPolyPoly) const
{
ForcePossibilities();
if (bNoPolyPoly) return bCombineNoPolyPolyPossible;
else return bCombinePossible;
}
bool SdrEditView::IsDismantlePossible(bool bMakeLines) const
{
ForcePossibilities();
if (bMakeLines) return bDismantleMakeLinesPossible;
else return bDismantlePossible;
}
void SdrEditView::CheckPossibilities()
{
if (mbSomeObjChgdFlag) bPossibilitiesDirty=true;
if(mbSomeObjChgdFlag)
{
// This call IS necessary to correct the MarkList, in which
// no longer to the model belonging objects still can reside.
// These ones need to be removed.
CheckMarked();
}
if (bPossibilitiesDirty) {
ImpResetPossibilityFlags();
SortMarkedObjects();
const size_t nMarkCount=GetMarkedObjectCount();
if (nMarkCount!=0) {
bReverseOrderPossible=nMarkCount>=2;
size_t nMovableCount=0;
bGroupPossible=nMarkCount>=2;
bCombinePossible=nMarkCount>=2;
if (nMarkCount==1) {
// check bCombinePossible more thoroughly
// still missing ...
const SdrObject* pObj=GetMarkedObjectByIndex(0);
//const SdrPathObj* pPath=dynamic_cast<SdrPathObj*>( pObj );
bool bGroup=pObj->GetSubList()!=nullptr;
bool bHasText=pObj->GetOutlinerParaObject()!=nullptr;
if (bGroup || bHasText) {
bCombinePossible=true;
}
}
bCombineNoPolyPolyPossible=bCombinePossible;
bDeletePossible=true;
// accept transformations for now
bMoveAllowed =true;
bResizeFreeAllowed=true;
bResizePropAllowed=true;
bRotateFreeAllowed=true;
bRotate90Allowed =true;
bMirrorFreeAllowed=true;
bMirror45Allowed =true;
bMirror90Allowed =true;
bShearAllowed =true;
bEdgeRadiusAllowed=false;
bContortionPossible=true;
bCanConvToContour = true;
// these ones are only allowed when single object is selected
bTransparenceAllowed = (nMarkCount == 1);
bGradientAllowed = (nMarkCount == 1);
bCropAllowed = (nMarkCount == 1);
if(bGradientAllowed)
{
// gradient depends on fill style
const SdrMark* pM = GetSdrMarkByIndex(0);
const SdrObject* pObj = pM->GetMarkedSdrObj();
// may be group object, so get merged ItemSet
const SfxItemSet& rSet = pObj->GetMergedItemSet();
SfxItemState eState = rSet.GetItemState(XATTR_FILLSTYLE, false);
if(SfxItemState::DONTCARE != eState)
{
// If state is not DONTCARE, test the item
drawing::FillStyle eFillStyle = static_cast<const XFillStyleItem&>(rSet.Get(XATTR_FILLSTYLE)).GetValue();
if(eFillStyle != drawing::FillStyle_GRADIENT)
{
bGradientAllowed = false;
}
}
}
bool bNoMovRotFound=false;
const SdrPageView* pPV0=nullptr;
for (size_t nm=0; nm<nMarkCount; ++nm) {
const SdrMark* pM=GetSdrMarkByIndex(nm);
const SdrObject* pObj=pM->GetMarkedSdrObj();
const SdrPageView* pPV=pM->GetPageView();
if (pPV!=pPV0) {
if (pPV->IsReadOnly()) bReadOnly=true;
pPV0=pPV;
}
SdrObjTransformInfoRec aInfo;
pObj->TakeObjInfo(aInfo);
bool bMovPrt=pObj->IsMoveProtect();
bool bSizPrt=pObj->IsResizeProtect();
if (!bMovPrt && aInfo.bMoveAllowed) nMovableCount++; // count MovableObjs
if (bMovPrt) bMoveProtect=true;
if (bSizPrt) bResizeProtect=true;
// not allowed when not allowed at one object
if(!aInfo.bTransparenceAllowed)
bTransparenceAllowed = false;
// If one of these can't do something, none can
if (!aInfo.bMoveAllowed ) bMoveAllowed =false;
if (!aInfo.bResizeFreeAllowed) bResizeFreeAllowed=false;
if (!aInfo.bResizePropAllowed) bResizePropAllowed=false;
if (!aInfo.bRotateFreeAllowed) bRotateFreeAllowed=false;
if (!aInfo.bRotate90Allowed ) bRotate90Allowed =false;
if (!aInfo.bMirrorFreeAllowed) bMirrorFreeAllowed=false;
if (!aInfo.bMirror45Allowed ) bMirror45Allowed =false;
if (!aInfo.bMirror90Allowed ) bMirror90Allowed =false;
if (!aInfo.bShearAllowed ) bShearAllowed =false;
if (aInfo.bEdgeRadiusAllowed) bEdgeRadiusAllowed=true;
if (aInfo.bNoContortion ) bContortionPossible=false;
// For Crook with Contortion: all objects have to be
// Movable and Rotatable, except for a maximum of 1 of them
if (!bMoreThanOneNoMovRot) {
if (!aInfo.bMoveAllowed || !aInfo.bResizeFreeAllowed) {
bMoreThanOneNoMovRot=bNoMovRotFound;
bNoMovRotFound=true;
}
}
// Must be resizeable to allow cropping
if (!aInfo.bResizeFreeAllowed && !aInfo.bResizePropAllowed)
bCropAllowed = false;
// if one member cannot be converted, no conversion is possible
if(!aInfo.bCanConvToContour)
bCanConvToContour = false;
// Ungroup
if (!bUnGroupPossible) bUnGroupPossible=pObj->GetSubList()!=nullptr;
// ConvertToCurve: If at least one can be converted, that is fine.
if (aInfo.bCanConvToPath ) bCanConvToPath =true;
if (aInfo.bCanConvToPoly ) bCanConvToPoly =true;
if (aInfo.bCanConvToPathLineToArea) bCanConvToPathLineToArea=true;
if (aInfo.bCanConvToPolyLineToArea) bCanConvToPolyLineToArea=true;
// Combine/Dismantle
if(bCombinePossible)
{
bCombinePossible = ImpCanConvertForCombine(pObj);
bCombineNoPolyPolyPossible = bCombinePossible;
}
if (!bDismantlePossible) bDismantlePossible = ImpCanDismantle(pObj, false);
if (!bDismantleMakeLinesPossible) bDismantleMakeLinesPossible = ImpCanDismantle(pObj, true);
// check OrthoDesiredOnMarked
if (!bOrthoDesiredOnMarked && !aInfo.bNoOrthoDesired) bOrthoDesiredOnMarked=true;
// check ImportMtf
if (!bImportMtfPossible)
{
const SdrGrafObj* pSdrGrafObj = dynamic_cast< const SdrGrafObj* >(pObj);
const SdrOle2Obj* pSdrOle2Obj = dynamic_cast< const SdrOle2Obj* >(pObj);
if(pSdrGrafObj && ((pSdrGrafObj->HasGDIMetaFile() && !pSdrGrafObj->IsEPS()) || pSdrGrafObj->isEmbeddedSvg()))
{
bImportMtfPossible = true;
}
if(pSdrOle2Obj)
{
bImportMtfPossible = pSdrOle2Obj->GetObjRef().is();
}
}
}
bMoreThanOneNotMovable=nMovableCount<nMarkCount-1;
bOneOrMoreMovable=nMovableCount!=0;
bGrpEnterPossible=bUnGroupPossible;
}
ImpCheckToTopBtmPossible();
static_cast<SdrPolyEditView*>(this)->ImpCheckPolyPossibilities();
bPossibilitiesDirty=false;
if (bReadOnly) {
bool bMerker1=bGrpEnterPossible;
ImpResetPossibilityFlags();
bReadOnly=true;
bGrpEnterPossible=bMerker1;
}
if (bMoveAllowed) {
// Don't allow moving glued connectors.
// Currently only implemented for single selection.
if (nMarkCount==1) {
SdrObject* pObj=GetMarkedObjectByIndex(0);
SdrEdgeObj* pEdge=dynamic_cast<SdrEdgeObj*>( pObj );
if (pEdge!=nullptr) {
SdrObject* pNode1=pEdge->GetConnectedNode(true);
SdrObject* pNode2=pEdge->GetConnectedNode(false);
if (pNode1!=nullptr || pNode2!=nullptr) bMoveAllowed=false;
}
}
}
}
}
void SdrEditView::ForceMarkedObjToAnotherPage()
{
bool bFlg=false;
for (size_t nm=0; nm<GetMarkedObjectCount(); ++nm) {
SdrMark* pM=GetSdrMarkByIndex(nm);
SdrObject* pObj=pM->GetMarkedSdrObj();
Rectangle aObjRect(pObj->GetCurrentBoundRect());
Rectangle aPgRect(pM->GetPageView()->GetPageRect());
if (!aObjRect.IsOver(aPgRect)) {
bool bFnd=false;
SdrPageView* pPV = GetSdrPageView();
if(pPV)
{
bFnd = aObjRect.IsOver(pPV->GetPageRect());
}
if(bFnd)
{
pM->GetPageView()->GetObjList()->RemoveObject(pObj->GetOrdNum());
SdrInsertReason aReason(SdrInsertReasonKind::ViewCall);
pPV->GetObjList()->InsertObject(pObj, SAL_MAX_SIZE, &aReason);
pM->SetPageView(pPV);
InvalidateAllWin(aObjRect);
bFlg=true;
}
}
}
if (bFlg) {
MarkListHasChanged();
}
}
void SdrEditView::DeleteMarkedList(const SdrMarkList& rMark)
{
if (rMark.GetMarkCount()!=0)
{
rMark.ForceSort();
const bool bUndo = IsUndoEnabled();
if( bUndo )
BegUndo();
const size_t nMarkCount(rMark.GetMarkCount());
if(nMarkCount)
{
std::vector< E3DModifySceneSnapRectUpdater* > aUpdaters;
if( bUndo )
{
for(size_t nm = nMarkCount; nm > 0;)
{
--nm;
SdrMark* pM = rMark.GetMark(nm);
SdrObject* pObj = pM->GetMarkedSdrObj();
// extra undo actions for changed connector which now may hold its laid out path (SJ)
std::vector< SdrUndoAction* > vConnectorUndoActions( CreateConnectorUndo( *pObj ) );
AddUndoActions( vConnectorUndoActions );
AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj));
}
}
// make sure, OrderNums are correct:
rMark.GetMark(0)->GetMarkedSdrObj()->GetOrdNum();
std::vector< SdrObject* > aRemoved3DObjects;
for(size_t nm = nMarkCount; nm > 0;)
{
--nm;
SdrMark* pM = rMark.GetMark(nm);
SdrObject* pObj = pM->GetMarkedSdrObj();
SdrObjList* pOL = pObj->GetObjList();
const size_t nOrdNum(pObj->GetOrdNumDirect());
bool bIs3D = dynamic_cast< E3dObject* >(pObj);
// set up a scene updater if object is a 3d object
if(bIs3D)
{
aUpdaters.push_back(new E3DModifySceneSnapRectUpdater(pObj));
}
pOL->RemoveObject(nOrdNum);
if( !bUndo )
{
if( bIs3D )
aRemoved3DObjects.push_back( pObj ); // may be needed later
else
SdrObject::Free(pObj);
}
}
// fire scene updaters
while(!aUpdaters.empty())
{
delete aUpdaters.back();
aUpdaters.pop_back();
}
if( !bUndo )
{
// now delete removed scene objects
while(!aRemoved3DObjects.empty())
{
SdrObject::Free( aRemoved3DObjects.back() );
aRemoved3DObjects.pop_back();
}
}
}
if( bUndo )
EndUndo();
}
}
void SdrEditView::DeleteMarkedObj()
{
// #i110981# return when nothing is to be done at all
if(!GetMarkedObjectCount())
{
return;
}
// moved breaking action and undo start outside loop
BrkAction();
BegUndo(ImpGetResStr(STR_EditDelete),GetDescriptionOfMarkedObjects(),SdrRepeatFunc::Delete);
// remove as long as something is selected. This allows to schedule objects for
// removal for a next run as needed
while(GetMarkedObjectCount())
{
// vector to remember the parents which may be empty after object removal
std::vector< SdrObject* > aParents;
{
const SdrMarkList& rMarkList = GetMarkedObjectList();
const size_t nCount(rMarkList.GetMarkCount());
for(size_t a = 0; a < nCount; ++a)
{
// in the first run, add all found parents, but only once
SdrMark* pMark = rMarkList.GetMark(a);
SdrObject* pObject = pMark->GetMarkedSdrObj();
SdrObject* pParent = pObject->GetObjList()->GetOwnerObj();
if(pParent)
{
if(!aParents.empty())
{
std::vector< SdrObject* >::iterator aFindResult =
std::find(aParents.begin(), aParents.end(), pParent);
if(aFindResult == aParents.end())
{
aParents.push_back(pParent);
}
}
else
{
aParents.push_back(pParent);
}
}
}
if(!aParents.empty())
{
// in a 2nd run, remove all objects which may already be scheduled for
// removal. I am not sure if this can happen, but theoretically
// a to-be-removed object may already be the group/3DScene itself
for(size_t a = 0; a < nCount; ++a)
{
SdrMark* pMark = rMarkList.GetMark(a);
SdrObject* pObject = pMark->GetMarkedSdrObj();
std::vector< SdrObject* >::iterator aFindResult =
std::find(aParents.begin(), aParents.end(), pObject);
if(aFindResult != aParents.end())
{
aParents.erase(aFindResult);
}
}
}
}
// original stuff: remove selected objects. Handle clear will
// do something only once
DeleteMarkedList(GetMarkedObjectList());
GetMarkedObjectListWriteAccess().Clear();
maHdlList.Clear();
while(aParents.size() && !GetMarkedObjectCount())
{
// iterate over remembered parents
SdrObject* pParent = aParents.back();
aParents.pop_back();
if(pParent->GetSubList() && 0 == pParent->GetSubList()->GetObjCount())
{
// we detected an empty parent, a candidate to leave group/3DScene
// if entered
if(GetSdrPageView()->GetAktGroup()
&& GetSdrPageView()->GetAktGroup() == pParent)
{
GetSdrPageView()->LeaveOneGroup();
}
// schedule empty parent for removal
GetMarkedObjectListWriteAccess().InsertEntry(
SdrMark(pParent, GetSdrPageView()));
}
}
}
// end undo and change messaging moved at the end
EndUndo();
MarkListHasChanged();
}
void SdrEditView::CopyMarkedObj()
{
SortMarkedObjects();
SdrMarkList aSourceObjectsForCopy(GetMarkedObjectList());
// The following loop is used instead of MarkList::Merge(), to be
// able to flag the MarkEntries.
const size_t nEdgeAnz = GetEdgesOfMarkedNodes().GetMarkCount();
for (size_t nEdgeNum=0; nEdgeNum<nEdgeAnz; ++nEdgeNum) {
SdrMark aM(*GetEdgesOfMarkedNodes().GetMark(nEdgeNum));
aM.SetUser(1);
aSourceObjectsForCopy.InsertEntry(aM);
}
aSourceObjectsForCopy.ForceSort();
// #i13033#
// New mechanism to re-create the connections of cloned connectors
CloneList aCloneList;
const bool bUndo = IsUndoEnabled();
GetMarkedObjectListWriteAccess().Clear();
size_t nCloneErrCnt=0;
const size_t nMarkCount=aSourceObjectsForCopy.GetMarkCount();
for (size_t nm=0; nm<nMarkCount; ++nm) {
SdrMark* pM=aSourceObjectsForCopy.GetMark(nm);
SdrObject* pO=pM->GetMarkedSdrObj()->Clone();
if (pO!=nullptr) {
SdrInsertReason aReason(SdrInsertReasonKind::ViewCall);
pM->GetPageView()->GetObjList()->InsertObject(pO, SAL_MAX_SIZE, &aReason);
if( bUndo )
AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoCopyObject(*pO));
SdrMark aME(*pM);
aME.SetMarkedSdrObj(pO);
aCloneList.AddPair(pM->GetMarkedSdrObj(), pO);
if (pM->GetUser()==0)
{
// otherwise it is only an Edge we have to copy as well
GetMarkedObjectListWriteAccess().InsertEntry(aME);
}
} else {
nCloneErrCnt++;
}
}
// #i13033#
// New mechanism to re-create the connections of cloned connectors
aCloneList.CopyConnections();
if(nCloneErrCnt)
{
#ifdef DBG_UTIL
OStringBuffer aStr("SdrEditView::CopyMarkedObj(): Error when cloning ");
if(nCloneErrCnt == 1)
{
aStr.append("a drawing object.");
}
else
{
aStr.append(static_cast<sal_Int32>(nCloneErrCnt));
aStr.append(" drawing objects.");
}
aStr.append(" This object's/These objects's connections will not be copied.");
OSL_FAIL(aStr.getStr());
#endif
}
MarkListHasChanged();
}
bool SdrEditView::InsertObjectAtView(SdrObject* pObj, SdrPageView& rPV, SdrInsertFlags nOptions)
{
if (nOptions & SdrInsertFlags::SETDEFLAYER) {
SdrLayerID nLayer=rPV.GetPage()->GetLayerAdmin().GetLayerID(maActualLayer,true);
if (nLayer==SDRLAYER_NOTFOUND) nLayer=0;
if (rPV.GetLockedLayers().IsSet(nLayer) || !rPV.GetVisibleLayers().IsSet(nLayer)) {
SdrObject::Free( pObj ); // Layer locked or invisible
return false;
}
pObj->NbcSetLayer(nLayer);
}
if (nOptions & SdrInsertFlags::SETDEFATTR) {
if (mpDefaultStyleSheet!=nullptr) pObj->NbcSetStyleSheet(mpDefaultStyleSheet, false);
pObj->SetMergedItemSet(maDefaultAttr);
}
if (!pObj->IsInserted()) {
SdrInsertReason aReason(SdrInsertReasonKind::ViewCall);
if (nOptions & SdrInsertFlags::NOBROADCAST) {
rPV.GetObjList()->NbcInsertObject(pObj, SAL_MAX_SIZE, &aReason);
} else {
rPV.GetObjList()->InsertObject(pObj, SAL_MAX_SIZE, &aReason);
}
}
if( IsUndoEnabled() )
AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pObj));
if (!(nOptions & SdrInsertFlags::DONTMARK)) {
if (!(nOptions & SdrInsertFlags::ADDMARK)) UnmarkAllObj();
MarkObj(pObj,&rPV);
}
return true;
}
void SdrEditView::ReplaceObjectAtView(SdrObject* pOldObj, SdrPageView& rPV, SdrObject* pNewObj, bool bMark)
{
if(IsTextEdit())
{
#ifdef DBG_UTIL
if(dynamic_cast< SdrTextObj* >(pOldObj) && static_cast< SdrTextObj* >(pOldObj)->IsTextEditActive())
{
OSL_ENSURE(false, "OldObject is in TextEdit mode, this has to be ended before replacing it usnig SdrEndTextEdit (!)");
}
if(dynamic_cast< SdrTextObj* >(pNewObj) && static_cast< SdrTextObj* >(pNewObj)->IsTextEditActive())
{
OSL_ENSURE(false, "NewObject is in TextEdit mode, this has to be ended before replacing it usnig SdrEndTextEdit (!)");
}
#endif
// #i123468# emergency repair situation, needs to cast up to a class derived from
// this one; (aw080 has a mechanism for that and the view hierarchy is secured to
// always be a SdrView)
SdrView *pSdrView = dynamic_cast<SdrView*>(this);
if (pSdrView)
pSdrView->SdrEndTextEdit();
}
SdrObjList* pOL=pOldObj->GetObjList();
const bool bUndo = IsUndoEnabled();
if( bUndo )
AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoReplaceObject(*pOldObj,*pNewObj));
if( IsObjMarked( pOldObj ) )
MarkObj( pOldObj, &rPV, true /*unmark!*/ );
pOL->ReplaceObject(pNewObj,pOldObj->GetOrdNum());
if( !bUndo )
SdrObject::Free( pOldObj );
if (bMark) MarkObj(pNewObj,&rPV);
}
bool SdrEditView::IsUndoEnabled() const
{
return mpModel->IsUndoEnabled();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|