/src/libreoffice/svx/source/svdraw/svdedtv.cxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
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/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
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 . |
18 | | */ |
19 | | |
20 | | #include <svx/svdedtv.hxx> |
21 | | #include <svx/svdundo.hxx> |
22 | | #include <svx/svdograf.hxx> |
23 | | #include <svx/svdoole2.hxx> |
24 | | #include <svx/svdoedge.hxx> |
25 | | #include <svx/svdlayer.hxx> |
26 | | #include <svx/svdpagv.hxx> |
27 | | #include <svx/svdpage.hxx> |
28 | | #include <svx/svdpoev.hxx> |
29 | | #include <svx/strings.hrc> |
30 | | #include <svx/dialmgr.hxx> |
31 | | #include <svx/e3dsceneupdater.hxx> |
32 | | #include <rtl/strbuf.hxx> |
33 | | #include <svx/svdview.hxx> |
34 | | #include <clonelist.hxx> |
35 | | #include <svx/svdogrp.hxx> |
36 | | #include <svx/xfillit0.hxx> |
37 | | #include <osl/diagnose.h> |
38 | | #include <sfx2/viewsh.hxx> |
39 | | #include <comphelper/dispatchcommand.hxx> |
40 | | |
41 | | #include <com/sun/star/lang/XServiceInfo.hpp> |
42 | | |
43 | | using namespace com::sun::star; |
44 | | |
45 | | void SdrEditView::ImpResetPossibilityFlags() |
46 | 0 | { |
47 | 0 | m_bReadOnly =false; |
48 | |
|
49 | 0 | m_bGroupPossible =false; |
50 | 0 | m_bUnGroupPossible =false; |
51 | 0 | m_bGrpEnterPossible =false; |
52 | 0 | m_bToTopPossible =false; |
53 | 0 | m_bToBtmPossible =false; |
54 | 0 | m_bReverseOrderPossible =false; |
55 | |
|
56 | 0 | m_bImportMtfPossible =false; |
57 | 0 | m_bCombinePossible =false; |
58 | 0 | m_bDismantlePossible =false; |
59 | 0 | m_bCombineNoPolyPolyPossible =false; |
60 | 0 | m_bDismantleMakeLinesPossible=false; |
61 | 0 | m_bOrthoDesiredOnMarked =false; |
62 | |
|
63 | 0 | m_bOneOrMoreMovable =false; |
64 | 0 | m_bMoreThanOneNoMovRot =false; |
65 | 0 | m_bContortionPossible =false; |
66 | 0 | m_bMoveAllowed =false; |
67 | 0 | m_bResizeFreeAllowed =false; |
68 | 0 | m_bResizePropAllowed =false; |
69 | 0 | m_bRotateFreeAllowed =false; |
70 | 0 | m_bRotate90Allowed =false; |
71 | 0 | m_bMirrorFreeAllowed =false; |
72 | 0 | m_bMirror45Allowed =false; |
73 | 0 | m_bMirror90Allowed =false; |
74 | 0 | m_bTransparenceAllowed =false; |
75 | 0 | m_bCropAllowed =false; |
76 | 0 | m_bGradientAllowed =false; |
77 | 0 | m_bShearAllowed =false; |
78 | 0 | m_bEdgeRadiusAllowed =false; |
79 | 0 | m_bCanConvToPath =false; |
80 | 0 | m_bCanConvToPoly =false; |
81 | 0 | m_bCanConvToContour =false; |
82 | 0 | m_bMoveProtect =false; |
83 | 0 | m_bResizeProtect =false; |
84 | 0 | } |
85 | | |
86 | | SdrEditView::SdrEditView(SdrModel& rSdrModel, OutputDevice* pOut) |
87 | 326k | : SdrMarkView(rSdrModel, pOut) |
88 | 326k | , m_bPossibilitiesDirty(true) |
89 | 326k | , m_bReadOnly(false) |
90 | 326k | , m_bGroupPossible(false) |
91 | 326k | , m_bUnGroupPossible(false) |
92 | 326k | , m_bGrpEnterPossible(false) |
93 | 326k | , m_bToTopPossible(false) |
94 | 326k | , m_bToBtmPossible(false) |
95 | 326k | , m_bReverseOrderPossible(false) |
96 | 326k | , m_bImportMtfPossible(false) |
97 | 326k | , m_bCombinePossible(false) |
98 | 326k | , m_bDismantlePossible(false) |
99 | 326k | , m_bCombineNoPolyPolyPossible(false) |
100 | 326k | , m_bDismantleMakeLinesPossible(false) |
101 | 326k | , m_bOrthoDesiredOnMarked(false) |
102 | 326k | , m_bOneOrMoreMovable(false) |
103 | 326k | , m_bMoreThanOneNoMovRot(false) |
104 | 326k | , m_bContortionPossible(false) |
105 | 326k | , m_bMoveAllowed(false) |
106 | 326k | , m_bResizeFreeAllowed(false) |
107 | 326k | , m_bResizePropAllowed(false) |
108 | 326k | , m_bRotateFreeAllowed(false) |
109 | 326k | , m_bRotate90Allowed(false) |
110 | 326k | , m_bMirrorFreeAllowed(false) |
111 | 326k | , m_bMirror45Allowed(false) |
112 | 326k | , m_bMirror90Allowed(false) |
113 | 326k | , m_bShearAllowed(false) |
114 | 326k | , m_bEdgeRadiusAllowed(false) |
115 | 326k | , m_bTransparenceAllowed(false) |
116 | 326k | , m_bCropAllowed(false) |
117 | 326k | , m_bGradientAllowed(false) |
118 | 326k | , m_bCanConvToPath(false) |
119 | 326k | , m_bCanConvToPoly(false) |
120 | 326k | , m_bCanConvToContour(false) |
121 | 326k | , m_bMoveProtect(false) |
122 | 326k | , m_bResizeProtect(false) |
123 | 326k | { |
124 | 326k | } |
125 | | |
126 | | SdrEditView::~SdrEditView() |
127 | 326k | { |
128 | 326k | } |
129 | | |
130 | | void SdrEditView::InsertNewLayer(const OUString& rName, sal_uInt16 nPos) |
131 | 0 | { |
132 | 0 | SdrLayerAdmin& rLA = GetModel().GetLayerAdmin(); |
133 | 0 | sal_uInt16 nMax=rLA.GetLayerCount(); |
134 | 0 | if (nPos>nMax) nPos=nMax; |
135 | 0 | rLA.NewLayer(rName,nPos); |
136 | |
|
137 | 0 | if( GetModel().IsUndoEnabled() ) |
138 | 0 | AddUndo(GetModel().GetSdrUndoFactory().CreateUndoNewLayer(nPos,rLA, GetModel())); |
139 | |
|
140 | 0 | GetModel().SetChanged(); |
141 | 0 | } |
142 | | |
143 | | bool SdrEditView::ImpDelLayerCheck(SdrObjList const * pOL, SdrLayerID nDelID) const |
144 | 0 | { |
145 | 0 | bool bDelAll(true); |
146 | |
|
147 | 0 | for(size_t nObjNum = pOL->GetObjCount(); nObjNum > 0 && bDelAll;) |
148 | 0 | { |
149 | 0 | nObjNum--; |
150 | 0 | SdrObject* pObj = pOL->GetObj(nObjNum); |
151 | 0 | assert(pObj); |
152 | 0 | SdrObjList* pSubOL = pObj->GetSubList(); |
153 | | |
154 | | // explicitly test for group objects and 3d scenes |
155 | 0 | if(pSubOL && (dynamic_cast<const SdrObjGroup*>(pObj) != nullptr || DynCastE3dScene(pObj))) |
156 | 0 | { |
157 | 0 | if(!ImpDelLayerCheck(pSubOL, nDelID)) |
158 | 0 | { |
159 | 0 | bDelAll = false; |
160 | 0 | } |
161 | 0 | } |
162 | 0 | else |
163 | 0 | { |
164 | 0 | if(pObj->GetLayer() != nDelID) |
165 | 0 | { |
166 | 0 | bDelAll = false; |
167 | 0 | } |
168 | 0 | } |
169 | 0 | } |
170 | |
|
171 | 0 | return bDelAll; |
172 | 0 | } |
173 | | |
174 | | void SdrEditView::ImpDelLayerDelObjs(SdrObjList* pOL, SdrLayerID nDelID) |
175 | 0 | { |
176 | 0 | const size_t nObjCount(pOL->GetObjCount()); |
177 | | // make sure OrdNums are correct |
178 | 0 | pOL->GetObj(0)->GetOrdNum(); |
179 | |
|
180 | 0 | const bool bUndo = GetModel().IsUndoEnabled(); |
181 | |
|
182 | 0 | for(size_t nObjNum = nObjCount; nObjNum > 0;) |
183 | 0 | { |
184 | 0 | nObjNum--; |
185 | 0 | SdrObject* pObj = pOL->GetObj(nObjNum); |
186 | 0 | assert(pObj); |
187 | 0 | SdrObjList* pSubOL = pObj->GetSubList(); |
188 | | |
189 | | |
190 | | // explicitly test for group objects and 3d scenes |
191 | 0 | if(pSubOL && (dynamic_cast<const SdrObjGroup*>( pObj) != nullptr || DynCastE3dScene(pObj))) |
192 | 0 | { |
193 | 0 | if(ImpDelLayerCheck(pSubOL, nDelID)) |
194 | 0 | { |
195 | 0 | if( bUndo ) |
196 | 0 | AddUndo(GetModel().GetSdrUndoFactory().CreateUndoDeleteObject(*pObj, true)); |
197 | 0 | pOL->RemoveObject(nObjNum); |
198 | 0 | } |
199 | 0 | else |
200 | 0 | { |
201 | 0 | ImpDelLayerDelObjs(pSubOL, nDelID); |
202 | 0 | } |
203 | 0 | } |
204 | 0 | else |
205 | 0 | { |
206 | 0 | if(pObj->GetLayer() == nDelID) |
207 | 0 | { |
208 | 0 | if( bUndo ) |
209 | 0 | AddUndo(GetModel().GetSdrUndoFactory().CreateUndoDeleteObject(*pObj, true)); |
210 | 0 | pOL->RemoveObject(nObjNum); |
211 | 0 | } |
212 | 0 | } |
213 | 0 | } |
214 | 0 | } |
215 | | |
216 | | void SdrEditView::DeleteLayer(const OUString& rName) |
217 | 0 | { |
218 | 0 | SdrLayerAdmin& rLA = GetModel().GetLayerAdmin(); |
219 | 0 | SdrLayer* pLayer = rLA.GetLayer(rName); |
220 | |
|
221 | 0 | if(!pLayer) |
222 | 0 | return; |
223 | | |
224 | 0 | sal_uInt16 nLayerNum(rLA.GetLayerPos(pLayer)); |
225 | 0 | SdrLayerID nDelID = pLayer->GetID(); |
226 | |
|
227 | 0 | const bool bUndo = IsUndoEnabled(); |
228 | 0 | if( bUndo ) |
229 | 0 | BegUndo(SvxResId(STR_UndoDelLayer)); |
230 | |
|
231 | 0 | bool bMaPg(true); |
232 | |
|
233 | 0 | for(sal_uInt16 nPageKind(0); nPageKind < 2; nPageKind++) |
234 | 0 | { |
235 | | // MasterPages and DrawPages |
236 | 0 | sal_uInt16 nPgCount(bMaPg ? GetModel().GetMasterPageCount() : GetModel().GetPageCount()); |
237 | |
|
238 | 0 | for(sal_uInt16 nPgNum(0); nPgNum < nPgCount; nPgNum++) |
239 | 0 | { |
240 | | // over all pages |
241 | 0 | SdrPage* pPage = bMaPg ? GetModel().GetMasterPage(nPgNum) : GetModel().GetPage(nPgNum); |
242 | 0 | const size_t nObjCount(pPage->GetObjCount()); |
243 | | |
244 | | // make sure OrdNums are correct |
245 | 0 | if(nObjCount) |
246 | 0 | pPage->GetObj(0)->GetOrdNum(); |
247 | |
|
248 | 0 | for(size_t nObjNum(nObjCount); nObjNum > 0;) |
249 | 0 | { |
250 | 0 | nObjNum--; |
251 | 0 | SdrObject* pObj = pPage->GetObj(nObjNum); |
252 | 0 | assert(pObj); |
253 | 0 | SdrObjList* pSubOL = pObj->GetSubList(); |
254 | | |
255 | | // explicitly test for group objects and 3d scenes |
256 | 0 | if(pSubOL && (dynamic_cast<const SdrObjGroup*>(pObj) != nullptr || DynCastE3dScene(pObj))) |
257 | 0 | { |
258 | 0 | if(ImpDelLayerCheck(pSubOL, nDelID)) |
259 | 0 | { |
260 | 0 | if( bUndo ) |
261 | 0 | AddUndo(GetModel().GetSdrUndoFactory().CreateUndoDeleteObject(*pObj, true)); |
262 | 0 | pPage->RemoveObject(nObjNum); |
263 | 0 | } |
264 | 0 | else |
265 | 0 | { |
266 | 0 | ImpDelLayerDelObjs(pSubOL, nDelID); |
267 | 0 | } |
268 | 0 | } |
269 | 0 | else |
270 | 0 | { |
271 | 0 | if(pObj->GetLayer() == nDelID) |
272 | 0 | { |
273 | 0 | if( bUndo ) |
274 | 0 | AddUndo(GetModel().GetSdrUndoFactory().CreateUndoDeleteObject(*pObj, true)); |
275 | 0 | pPage->RemoveObject(nObjNum); |
276 | 0 | } |
277 | 0 | } |
278 | 0 | } |
279 | 0 | } |
280 | 0 | bMaPg = false; |
281 | 0 | } |
282 | |
|
283 | 0 | if( bUndo ) |
284 | 0 | { |
285 | 0 | AddUndo(GetModel().GetSdrUndoFactory().CreateUndoDeleteLayer(nLayerNum, rLA, GetModel())); |
286 | | // coverity[leaked_storage] - ownership transferred to UndoDeleteLayer |
287 | 0 | rLA.RemoveLayer(nLayerNum).release(); |
288 | 0 | EndUndo(); |
289 | 0 | } |
290 | 0 | else |
291 | 0 | { |
292 | 0 | rLA.RemoveLayer(nLayerNum); |
293 | 0 | } |
294 | |
|
295 | 0 | GetModel().SetChanged(); |
296 | 0 | } |
297 | | |
298 | | |
299 | | void SdrEditView::EndUndo() |
300 | 0 | { |
301 | | // #i13033# |
302 | | // Comparison changed to 1L since EndUndo() is called later now |
303 | | // and EndUndo WILL change count to count-1 |
304 | 0 | if(1 == GetModel().GetUndoBracketLevel()) |
305 | 0 | { |
306 | 0 | ImpBroadcastEdgesOfMarkedNodes(); |
307 | 0 | } |
308 | | |
309 | | // #i13033# |
310 | | // moved to bottom to still have access to UNDOs inside of |
311 | | // ImpBroadcastEdgesOfMarkedNodes() |
312 | 0 | GetModel().EndUndo(); |
313 | 0 | } |
314 | | |
315 | | void SdrEditView::ImpBroadcastEdgesOfMarkedNodes() |
316 | 0 | { |
317 | 0 | std::vector<SdrObject*>::const_iterator iterPos; |
318 | 0 | const std::vector<SdrObject*>& rAllMarkedObjects = GetTransitiveHullOfMarkedObjects(); |
319 | | |
320 | | // #i13033# |
321 | | // New mechanism to search for necessary disconnections for |
322 | | // changed connectors inside the transitive hull of all at |
323 | | // the beginning of UNDO selected objects |
324 | 0 | for(size_t a(0); a < rAllMarkedObjects.size(); a++) |
325 | 0 | { |
326 | 0 | SdrEdgeObj* pEdge = dynamic_cast<SdrEdgeObj*>( rAllMarkedObjects[a] ); |
327 | |
|
328 | 0 | if(pEdge) |
329 | 0 | { |
330 | 0 | SdrObject* pObj1 = pEdge->GetConnectedNode(false); |
331 | 0 | SdrObject* pObj2 = pEdge->GetConnectedNode(true); |
332 | |
|
333 | 0 | if(pObj1 && !pEdge->CheckNodeConnection(false)) |
334 | 0 | { |
335 | 0 | iterPos = std::find(rAllMarkedObjects.begin(),rAllMarkedObjects.end(),pObj1); |
336 | |
|
337 | 0 | if (iterPos == rAllMarkedObjects.end()) |
338 | 0 | { |
339 | 0 | if( IsUndoEnabled() ) |
340 | 0 | AddUndo(GetModel().GetSdrUndoFactory().CreateUndoGeoObject(*pEdge)); |
341 | 0 | pEdge->DisconnectFromNode(false); |
342 | 0 | } |
343 | 0 | } |
344 | |
|
345 | 0 | if(pObj2 && !pEdge->CheckNodeConnection(true)) |
346 | 0 | { |
347 | 0 | iterPos = std::find(rAllMarkedObjects.begin(),rAllMarkedObjects.end(),pObj2); |
348 | |
|
349 | 0 | if (iterPos == rAllMarkedObjects.end()) |
350 | 0 | { |
351 | 0 | if( IsUndoEnabled() ) |
352 | 0 | AddUndo(GetModel().GetSdrUndoFactory().CreateUndoGeoObject(*pEdge)); |
353 | 0 | pEdge->DisconnectFromNode(true); |
354 | 0 | } |
355 | 0 | } |
356 | 0 | } |
357 | 0 | } |
358 | |
|
359 | 0 | const size_t nMarkedEdgeCnt = GetMarkedEdgesOfMarkedNodes().GetMarkCount(); |
360 | |
|
361 | 0 | for (size_t i=0; i<nMarkedEdgeCnt; ++i) { |
362 | 0 | SdrMark* pEM = GetMarkedEdgesOfMarkedNodes().GetMark(i); |
363 | 0 | SdrObject* pEdgeTmp=pEM->GetMarkedSdrObj(); |
364 | 0 | SdrEdgeObj* pEdge=dynamic_cast<SdrEdgeObj*>( pEdgeTmp ); |
365 | 0 | if (pEdge!=nullptr) { |
366 | 0 | pEdge->SetEdgeTrackDirty(); |
367 | 0 | } |
368 | 0 | } |
369 | 0 | } |
370 | | |
371 | | |
372 | | // Possibilities |
373 | | |
374 | | |
375 | | void SdrEditView::MarkListHasChanged() |
376 | 68.2k | { |
377 | 68.2k | SdrMarkView::MarkListHasChanged(); |
378 | 68.2k | m_bPossibilitiesDirty=true; |
379 | 68.2k | } |
380 | | |
381 | | void SdrEditView::ModelHasChanged() |
382 | 0 | { |
383 | 0 | SdrMarkView::ModelHasChanged(); |
384 | 0 | m_bPossibilitiesDirty=true; |
385 | 0 | } |
386 | | |
387 | | bool SdrEditView::IsResizeAllowed(bool bProp) const |
388 | 0 | { |
389 | 0 | ForcePossibilities(); |
390 | 0 | if (m_bResizeProtect) return false; |
391 | 0 | if (bProp) return m_bResizePropAllowed; |
392 | 0 | return m_bResizeFreeAllowed; |
393 | 0 | } |
394 | | |
395 | | bool SdrEditView::IsRotateAllowed(bool b90Deg) const |
396 | 0 | { |
397 | 0 | ForcePossibilities(); |
398 | 0 | if (m_bMoveProtect) return false; |
399 | 0 | if (b90Deg) return m_bRotate90Allowed; |
400 | 0 | return m_bRotateFreeAllowed; |
401 | 0 | } |
402 | | |
403 | | bool SdrEditView::IsMirrorAllowed(bool b45Deg, bool b90Deg) const |
404 | 0 | { |
405 | 0 | ForcePossibilities(); |
406 | 0 | if (m_bMoveProtect) return false; |
407 | 0 | if (b90Deg) return m_bMirror90Allowed; |
408 | 0 | if (b45Deg) return m_bMirror45Allowed; |
409 | 0 | return m_bMirrorFreeAllowed; |
410 | 0 | } |
411 | | |
412 | | bool SdrEditView::IsTransparenceAllowed() const |
413 | 0 | { |
414 | 0 | ForcePossibilities(); |
415 | 0 | return m_bTransparenceAllowed; |
416 | 0 | } |
417 | | |
418 | | bool SdrEditView::IsCropAllowed() const |
419 | 0 | { |
420 | 0 | ForcePossibilities(); |
421 | 0 | return m_bCropAllowed; |
422 | 0 | } |
423 | | |
424 | | bool SdrEditView::IsGradientAllowed() const |
425 | 0 | { |
426 | 0 | ForcePossibilities(); |
427 | 0 | return m_bGradientAllowed; |
428 | 0 | } |
429 | | |
430 | | bool SdrEditView::IsShearAllowed() const |
431 | 0 | { |
432 | 0 | ForcePossibilities(); |
433 | 0 | if (m_bResizeProtect) return false; |
434 | 0 | return m_bShearAllowed; |
435 | 0 | } |
436 | | |
437 | | bool SdrEditView::IsEdgeRadiusAllowed() const |
438 | 0 | { |
439 | 0 | ForcePossibilities(); |
440 | 0 | return m_bEdgeRadiusAllowed; |
441 | 0 | } |
442 | | |
443 | | bool SdrEditView::IsCrookAllowed(bool bNoContortion) const |
444 | 0 | { |
445 | | // CrookMode missing here (no rotations allowed when shearing ...) |
446 | 0 | ForcePossibilities(); |
447 | 0 | if (bNoContortion) { |
448 | 0 | if (!m_bRotateFreeAllowed) return false; |
449 | 0 | return !m_bMoveProtect && m_bMoveAllowed; |
450 | 0 | } else { |
451 | 0 | return !m_bResizeProtect && m_bContortionPossible; |
452 | 0 | } |
453 | 0 | } |
454 | | |
455 | | bool SdrEditView::IsDistortAllowed(bool bNoContortion) const |
456 | 0 | { |
457 | 0 | ForcePossibilities(); |
458 | 0 | if (bNoContortion) { |
459 | 0 | return false; |
460 | 0 | } else { |
461 | 0 | return !m_bResizeProtect && m_bContortionPossible; |
462 | 0 | } |
463 | 0 | } |
464 | | |
465 | | bool SdrEditView::IsCombinePossible(bool bNoPolyPoly) const |
466 | 0 | { |
467 | 0 | ForcePossibilities(); |
468 | 0 | if (bNoPolyPoly) return m_bCombineNoPolyPolyPossible; |
469 | 0 | else return m_bCombinePossible; |
470 | 0 | } |
471 | | |
472 | | bool SdrEditView::IsDismantlePossible(bool bMakeLines) const |
473 | 0 | { |
474 | 0 | ForcePossibilities(); |
475 | 0 | if (bMakeLines) return m_bDismantleMakeLinesPossible; |
476 | 0 | else return m_bDismantlePossible; |
477 | 0 | } |
478 | | |
479 | | void SdrEditView::CheckPossibilities() |
480 | 0 | { |
481 | 0 | if (mbSomeObjChgdFlag) |
482 | 0 | { |
483 | 0 | m_bPossibilitiesDirty = true; |
484 | | |
485 | | // This call IS necessary to correct the MarkList, in which |
486 | | // no longer to the model belonging objects still can reside. |
487 | | // These ones need to be removed. |
488 | 0 | CheckMarked(); |
489 | 0 | } |
490 | |
|
491 | 0 | if (!m_bPossibilitiesDirty) |
492 | 0 | return; |
493 | | |
494 | 0 | const SdrMarkList& rMarkList = GetMarkedObjectList(); |
495 | 0 | ImpResetPossibilityFlags(); |
496 | 0 | rMarkList.ForceSort(); |
497 | 0 | const size_t nMarkCount = rMarkList.GetMarkCount(); |
498 | 0 | if (nMarkCount != 0) |
499 | 0 | { |
500 | 0 | m_bReverseOrderPossible = (nMarkCount >= 2); |
501 | |
|
502 | 0 | size_t nMovableCount=0; |
503 | 0 | m_bGroupPossible=nMarkCount>=2; |
504 | 0 | m_bCombinePossible=nMarkCount>=2; |
505 | 0 | if (nMarkCount==1) |
506 | 0 | { |
507 | | // check bCombinePossible more thoroughly |
508 | | // still missing ... |
509 | 0 | const SdrObject* pObj=rMarkList.GetMark(0)->GetMarkedSdrObj(); |
510 | | //const SdrPathObj* pPath=dynamic_cast<SdrPathObj*>( pObj ); |
511 | 0 | bool bGroup=pObj->GetSubList()!=nullptr; |
512 | 0 | bool bHasText=pObj->GetOutlinerParaObject()!=nullptr; |
513 | 0 | if (bGroup || bHasText) { |
514 | 0 | m_bCombinePossible=true; |
515 | 0 | } |
516 | 0 | } |
517 | 0 | m_bCombineNoPolyPolyPossible=m_bCombinePossible; |
518 | | // accept transformations for now |
519 | 0 | m_bMoveAllowed =true; |
520 | 0 | m_bResizeFreeAllowed=true; |
521 | 0 | m_bResizePropAllowed=true; |
522 | 0 | m_bRotateFreeAllowed=true; |
523 | 0 | m_bRotate90Allowed =true; |
524 | 0 | m_bMirrorFreeAllowed=true; |
525 | 0 | m_bMirror45Allowed =true; |
526 | 0 | m_bMirror90Allowed =true; |
527 | 0 | m_bShearAllowed =true; |
528 | 0 | m_bEdgeRadiusAllowed=false; |
529 | 0 | m_bContortionPossible=true; |
530 | 0 | m_bCanConvToContour = true; |
531 | | |
532 | | // these ones are only allowed when single object is selected |
533 | 0 | m_bTransparenceAllowed = (nMarkCount == 1); |
534 | 0 | m_bGradientAllowed = (nMarkCount == 1); |
535 | 0 | m_bCropAllowed = (nMarkCount == 1); |
536 | 0 | if(m_bGradientAllowed) |
537 | 0 | { |
538 | | // gradient depends on fill style |
539 | 0 | const SdrMark* pM = rMarkList.GetMark(0); |
540 | 0 | const SdrObject* pObj = pM->GetMarkedSdrObj(); |
541 | | |
542 | | // may be group object, so get merged ItemSet |
543 | 0 | const SfxItemSet& rSet = pObj->GetMergedItemSet(); |
544 | 0 | SfxItemState eState = rSet.GetItemState(XATTR_FILLSTYLE, false); |
545 | |
|
546 | 0 | if(SfxItemState::INVALID != eState) |
547 | 0 | { |
548 | | // If state is not DONTCARE, test the item |
549 | 0 | drawing::FillStyle eFillStyle = rSet.Get(XATTR_FILLSTYLE).GetValue(); |
550 | |
|
551 | 0 | if(eFillStyle != drawing::FillStyle_GRADIENT) |
552 | 0 | { |
553 | 0 | m_bGradientAllowed = false; |
554 | 0 | } |
555 | 0 | } |
556 | 0 | } |
557 | |
|
558 | 0 | bool bNoMovRotFound=false; |
559 | 0 | const SdrPageView* pPV0=nullptr; |
560 | |
|
561 | 0 | for (size_t nm=0; nm<nMarkCount; ++nm) { |
562 | 0 | const SdrMark* pM=rMarkList.GetMark(nm); |
563 | 0 | SdrObject* pObj=pM->GetMarkedSdrObj(); |
564 | | |
565 | | // try to get DiagramSubSelection |
566 | 0 | { |
567 | 0 | SdrObject* pSubSelection(pObj->getDiagramSubSelection()); |
568 | 0 | if(nullptr != pSubSelection && !pSubSelection->isDiagramBackgroundShape()) |
569 | 0 | pObj = pSubSelection; |
570 | 0 | } |
571 | |
|
572 | 0 | const SdrPageView* pPV=pM->GetPageView(); |
573 | 0 | if (pPV!=pPV0) { |
574 | 0 | if (pPV->IsReadOnly()) m_bReadOnly=true; |
575 | 0 | pPV0=pPV; |
576 | 0 | } |
577 | |
|
578 | 0 | SdrObjTransformInfoRec aInfo; |
579 | 0 | pObj->TakeObjInfo(aInfo); |
580 | 0 | bool bMovPrt=pObj->IsMoveProtect(); |
581 | 0 | bool bSizPrt=pObj->IsResizeProtect(); |
582 | 0 | if (!bMovPrt && aInfo.bMoveAllowed) nMovableCount++; // count MovableObjs |
583 | 0 | if (bMovPrt) m_bMoveProtect=true; |
584 | 0 | if (bSizPrt) m_bResizeProtect=true; |
585 | | |
586 | | // not allowed when not allowed at one object |
587 | 0 | if(!aInfo.bTransparenceAllowed) |
588 | 0 | m_bTransparenceAllowed = false; |
589 | | |
590 | | // If one of these can't do something, none can |
591 | 0 | if (!aInfo.bMoveAllowed ) m_bMoveAllowed =false; |
592 | 0 | if (!aInfo.bResizeFreeAllowed) m_bResizeFreeAllowed=false; |
593 | 0 | if (!aInfo.bResizePropAllowed) m_bResizePropAllowed=false; |
594 | 0 | if (!aInfo.bRotateFreeAllowed) m_bRotateFreeAllowed=false; |
595 | 0 | if (!aInfo.bRotate90Allowed ) m_bRotate90Allowed =false; |
596 | 0 | if (!aInfo.bMirrorFreeAllowed) m_bMirrorFreeAllowed=false; |
597 | 0 | if (!aInfo.bMirror45Allowed ) m_bMirror45Allowed =false; |
598 | 0 | if (!aInfo.bMirror90Allowed ) m_bMirror90Allowed =false; |
599 | 0 | if (!aInfo.bShearAllowed ) m_bShearAllowed =false; |
600 | 0 | if (aInfo.bEdgeRadiusAllowed) m_bEdgeRadiusAllowed=true; |
601 | 0 | if (aInfo.bNoContortion ) m_bContortionPossible=false; |
602 | | // For Crook with Contortion: all objects have to be |
603 | | // Movable and Rotatable, except for a maximum of 1 of them |
604 | 0 | if (!m_bMoreThanOneNoMovRot) { |
605 | 0 | if (!aInfo.bMoveAllowed || !aInfo.bResizeFreeAllowed) { |
606 | 0 | m_bMoreThanOneNoMovRot=bNoMovRotFound; |
607 | 0 | bNoMovRotFound=true; |
608 | 0 | } |
609 | 0 | } |
610 | | |
611 | | // Must be resizable to allow cropping |
612 | 0 | if (!aInfo.bResizeFreeAllowed && !aInfo.bResizePropAllowed) |
613 | 0 | m_bCropAllowed = false; |
614 | | |
615 | | // if one member cannot be converted, no conversion is possible |
616 | 0 | if(!aInfo.bCanConvToContour) |
617 | 0 | m_bCanConvToContour = false; |
618 | | |
619 | | // Ungroup |
620 | 0 | if (!m_bUnGroupPossible) m_bUnGroupPossible=pObj->GetSubList()!=nullptr; |
621 | | // ConvertToCurve: If at least one can be converted, that is fine. |
622 | 0 | if (aInfo.bCanConvToPath ) m_bCanConvToPath =true; |
623 | 0 | if (aInfo.bCanConvToPoly ) m_bCanConvToPoly =true; |
624 | | |
625 | | // Combine/Dismantle |
626 | 0 | if(m_bCombinePossible) |
627 | 0 | { |
628 | 0 | m_bCombinePossible = ImpCanConvertForCombine(pObj); |
629 | 0 | m_bCombineNoPolyPolyPossible = m_bCombinePossible; |
630 | 0 | } |
631 | |
|
632 | 0 | if (!m_bDismantlePossible) m_bDismantlePossible = ImpCanDismantle(pObj, false); |
633 | 0 | if (!m_bDismantleMakeLinesPossible) m_bDismantleMakeLinesPossible = ImpCanDismantle(pObj, true); |
634 | | // check OrthoDesiredOnMarked |
635 | 0 | if (!m_bOrthoDesiredOnMarked && !aInfo.bNoOrthoDesired) m_bOrthoDesiredOnMarked=true; |
636 | | // check ImportMtf |
637 | |
|
638 | 0 | if (!m_bImportMtfPossible) |
639 | 0 | { |
640 | 0 | const SdrGrafObj* pSdrGrafObj = dynamic_cast< const SdrGrafObj* >(pObj); |
641 | 0 | if (pSdrGrafObj != nullptr) |
642 | 0 | { |
643 | 0 | if ((pSdrGrafObj->HasGDIMetaFile() && !pSdrGrafObj->IsEPS()) || |
644 | 0 | pSdrGrafObj->isEmbeddedVectorGraphicData()) |
645 | 0 | { |
646 | 0 | m_bImportMtfPossible = true; |
647 | 0 | } |
648 | 0 | } |
649 | |
|
650 | 0 | const SdrOle2Obj* pSdrOle2Obj = dynamic_cast< const SdrOle2Obj* >(pObj); |
651 | 0 | if (pSdrOle2Obj) |
652 | 0 | { |
653 | 0 | m_bImportMtfPossible = pSdrOle2Obj->GetObjRef().is(); |
654 | 0 | } |
655 | 0 | } |
656 | 0 | } |
657 | |
|
658 | 0 | m_bOneOrMoreMovable=nMovableCount!=0; |
659 | 0 | m_bGrpEnterPossible=m_bUnGroupPossible; |
660 | 0 | } |
661 | 0 | ImpCheckToTopBtmPossible(); |
662 | 0 | static_cast<SdrPolyEditView*>(this)->ImpCheckPolyPossibilities(); |
663 | 0 | m_bPossibilitiesDirty=false; |
664 | |
|
665 | 0 | if (m_bReadOnly || SfxViewShell::IsCurrentLokViewReadOnly() ) { |
666 | 0 | bool bTemp=m_bGrpEnterPossible; |
667 | 0 | ImpResetPossibilityFlags(); |
668 | 0 | m_bReadOnly=true; |
669 | 0 | m_bGrpEnterPossible=bTemp; |
670 | 0 | } |
671 | 0 | if (!m_bMoveAllowed) return; |
672 | | |
673 | | // Don't allow moving glued connectors. |
674 | | // Currently only implemented for single selection. |
675 | 0 | if (nMarkCount==1) { |
676 | 0 | SdrObject* pObj=rMarkList.GetMark(0)->GetMarkedSdrObj(); |
677 | 0 | SdrEdgeObj* pEdge=dynamic_cast<SdrEdgeObj*>( pObj ); |
678 | 0 | if (pEdge!=nullptr) { |
679 | 0 | SdrObject* pNode1=pEdge->GetConnectedNode(true); |
680 | 0 | SdrObject* pNode2=pEdge->GetConnectedNode(false); |
681 | 0 | if (pNode1!=nullptr || pNode2!=nullptr) m_bMoveAllowed=false; |
682 | 0 | } |
683 | 0 | } |
684 | | |
685 | | // Don't allow enter Diagrams |
686 | 0 | if (1 == nMarkCount && m_bGrpEnterPossible) |
687 | 0 | { |
688 | 0 | SdrObject* pCandidate(rMarkList.GetMark(0)->GetMarkedSdrObj()); |
689 | |
|
690 | 0 | if(nullptr != pCandidate && pCandidate->isDiagram()) |
691 | 0 | m_bGrpEnterPossible = false; |
692 | 0 | } |
693 | 0 | } |
694 | | |
695 | | |
696 | | void SdrEditView::ForceMarkedObjToAnotherPage() |
697 | 0 | { |
698 | 0 | const SdrMarkList& rMarkList = GetMarkedObjectList(); |
699 | 0 | bool bFlg=false; |
700 | 0 | for (size_t nm=0; nm<rMarkList.GetMarkCount(); ++nm) { |
701 | 0 | SdrMark* pM=rMarkList.GetMark(nm); |
702 | 0 | SdrObject* pObj=pM->GetMarkedSdrObj(); |
703 | 0 | tools::Rectangle aObjRect(pObj->GetCurrentBoundRect()); |
704 | 0 | tools::Rectangle aPgRect(pM->GetPageView()->GetPageRect()); |
705 | 0 | if (!aObjRect.Overlaps(aPgRect)) { |
706 | 0 | bool bFnd=false; |
707 | 0 | SdrPageView* pPV = GetSdrPageView(); |
708 | |
|
709 | 0 | if(pPV) |
710 | 0 | { |
711 | 0 | bFnd = aObjRect.Overlaps(pPV->GetPageRect()); |
712 | 0 | } |
713 | |
|
714 | 0 | if(bFnd) |
715 | 0 | { |
716 | 0 | pM->GetPageView()->GetObjList()->RemoveObject(pObj->GetOrdNum()); |
717 | 0 | pPV->GetObjList()->InsertObject(pObj, SAL_MAX_SIZE); |
718 | 0 | pM->SetPageView(pPV); |
719 | 0 | InvalidateAllWin(aObjRect); |
720 | 0 | bFlg=true; |
721 | 0 | } |
722 | 0 | } |
723 | 0 | } |
724 | 0 | if (bFlg) { |
725 | 0 | MarkListHasChanged(); |
726 | 0 | } |
727 | 0 | } |
728 | | |
729 | | std::vector<rtl::Reference<SdrObject>> SdrEditView::DeleteMarkedList(SdrMarkList const& rMark) |
730 | 0 | { |
731 | 0 | std::vector<rtl::Reference<SdrObject>> ret; |
732 | 0 | if (rMark.GetMarkCount()!=0) |
733 | 0 | { |
734 | 0 | rMark.ForceSort(); |
735 | |
|
736 | 0 | const bool bUndo = IsUndoEnabled(); |
737 | 0 | if( bUndo ) |
738 | 0 | BegUndo(); |
739 | 0 | const size_t nMarkCount(rMark.GetMarkCount()); |
740 | |
|
741 | 0 | if(nMarkCount) |
742 | 0 | { |
743 | 0 | std::vector< E3DModifySceneSnapRectUpdater* > aUpdaters; |
744 | |
|
745 | 0 | if( bUndo ) |
746 | 0 | { |
747 | 0 | for(size_t nm = nMarkCount; nm > 0;) |
748 | 0 | { |
749 | 0 | --nm; |
750 | 0 | SdrMark* pM = rMark.GetMark(nm); |
751 | 0 | SdrObject* pObj = pM->GetMarkedSdrObj(); |
752 | | |
753 | | // extra undo actions for changed connector which now may hold its laid out path (SJ) |
754 | 0 | AddUndoActions(CreateConnectorUndo( *pObj )); |
755 | |
|
756 | 0 | AddUndo(GetModel().GetSdrUndoFactory().CreateUndoDeleteObject(*pObj)); |
757 | 0 | } |
758 | 0 | } |
759 | | |
760 | | // make sure, OrderNums are correct: |
761 | 0 | rMark.GetMark(0)->GetMarkedSdrObj()->GetOrdNum(); |
762 | |
|
763 | 0 | for(size_t nm = nMarkCount; nm > 0;) |
764 | 0 | { |
765 | 0 | --nm; |
766 | 0 | SdrMark* pM = rMark.GetMark(nm); |
767 | 0 | SdrObject* pObj = pM->GetMarkedSdrObj(); |
768 | 0 | SdrObjList* pOL = pObj->getParentSdrObjListFromSdrObject(); |
769 | 0 | const size_t nOrdNum(pObj->GetOrdNumDirect()); |
770 | |
|
771 | 0 | bool bIs3D = DynCastE3dObject(pObj); |
772 | | // set up a scene updater if object is a 3d object |
773 | 0 | if(bIs3D) |
774 | 0 | { |
775 | 0 | aUpdaters.push_back(new E3DModifySceneSnapRectUpdater(pObj)); |
776 | 0 | } |
777 | |
|
778 | 0 | if( !bUndo ) |
779 | 0 | { |
780 | | // tdf#108863 and tdf#108889 don't delete objects before EndUndo() |
781 | 0 | ret.push_back(pObj); |
782 | 0 | } |
783 | |
|
784 | 0 | pOL->RemoveObject(nOrdNum); |
785 | 0 | } |
786 | | |
787 | | // fire scene updaters |
788 | 0 | while(!aUpdaters.empty()) |
789 | 0 | { |
790 | 0 | delete aUpdaters.back(); |
791 | 0 | aUpdaters.pop_back(); |
792 | 0 | } |
793 | 0 | } |
794 | |
|
795 | 0 | if( bUndo ) |
796 | 0 | EndUndo(); |
797 | 0 | } |
798 | 0 | return ret; |
799 | 0 | } |
800 | | |
801 | | static void lcl_LazyDelete(std::vector<rtl::Reference<SdrObject>> & rLazyDelete) |
802 | 0 | { |
803 | | // now delete removed scene objects |
804 | 0 | while (!rLazyDelete.empty()) |
805 | 0 | rLazyDelete.pop_back(); |
806 | 0 | } |
807 | | |
808 | | void SdrEditView::DeleteMarkedObj() |
809 | 0 | { |
810 | 0 | const SdrMarkList& rMarkList = GetMarkedObjectList(); |
811 | 0 | const size_t nMarkCount(rMarkList.GetMarkCount()); |
812 | | |
813 | | // #i110981# return when nothing is to be done at all |
814 | 0 | if(0 == nMarkCount) |
815 | 0 | return; |
816 | | |
817 | | // moved breaking action and undo start outside loop |
818 | 0 | BrkAction(); |
819 | 0 | BegUndo(SvxResId(STR_EditDelete),rMarkList.GetMarkDescription(),SdrRepeatFunc::Delete); |
820 | 0 | bool bDone(false); |
821 | |
|
822 | 0 | if (1 == nMarkCount) |
823 | 0 | { |
824 | 0 | SdrObject* pObj(rMarkList.GetMark(0)->GetMarkedSdrObj()); |
825 | |
|
826 | 0 | if (nullptr != pObj) |
827 | 0 | { |
828 | 0 | SdrObject* pSubSelection(pObj->getDiagramSubSelection()); |
829 | |
|
830 | 0 | if (nullptr != pSubSelection && pSubSelection->isDiagramTextNode()) |
831 | 0 | { |
832 | 0 | if (pSubSelection->removeDiagramNode()) |
833 | 0 | { |
834 | 0 | comphelper::dispatchCommand(u".uno:RegenerateDiagram"_ustr, {}); |
835 | 0 | bDone = true; |
836 | 0 | } |
837 | 0 | } |
838 | 0 | } |
839 | 0 | } |
840 | | |
841 | | // remove as long as something is selected. This allows to schedule objects for |
842 | | // removal for a next run as needed |
843 | 0 | std::vector<rtl::Reference<SdrObject>> lazyDeleteObjects; |
844 | |
|
845 | 0 | while(!bDone && rMarkList.GetMarkCount()) |
846 | 0 | { |
847 | | // vector to remember the parents which may be empty after object removal |
848 | 0 | std::vector< SdrObject* > aParents; |
849 | |
|
850 | 0 | { |
851 | 0 | const size_t nCount(rMarkList.GetMarkCount()); |
852 | |
|
853 | 0 | for(size_t a = 0; a < nCount; ++a) |
854 | 0 | { |
855 | | // in the first run, add all found parents, but only once |
856 | 0 | SdrMark* pMark(rMarkList.GetMark(a)); |
857 | 0 | SdrObject* pObject(pMark->GetMarkedSdrObj()); |
858 | 0 | SdrObject* pParent(pObject->getParentSdrObjectFromSdrObject()); |
859 | |
|
860 | 0 | if(pParent) |
861 | 0 | { |
862 | 0 | if(!aParents.empty()) |
863 | 0 | { |
864 | 0 | std::vector< SdrObject* >::iterator aFindResult = |
865 | 0 | std::find(aParents.begin(), aParents.end(), pParent); |
866 | |
|
867 | 0 | if(aFindResult == aParents.end()) |
868 | 0 | { |
869 | 0 | aParents.push_back(pParent); |
870 | 0 | } |
871 | 0 | } |
872 | 0 | else |
873 | 0 | { |
874 | 0 | aParents.push_back(pParent); |
875 | 0 | } |
876 | 0 | } |
877 | 0 | } |
878 | |
|
879 | 0 | if(!aParents.empty()) |
880 | 0 | { |
881 | | // in a 2nd run, remove all objects which may already be scheduled for |
882 | | // removal. I am not sure if this can happen, but theoretically |
883 | | // a to-be-removed object may already be the group/3DScene itself |
884 | 0 | for(size_t a = 0; a < nCount; ++a) |
885 | 0 | { |
886 | 0 | SdrMark* pMark = rMarkList.GetMark(a); |
887 | 0 | SdrObject* pObject = pMark->GetMarkedSdrObj(); |
888 | |
|
889 | 0 | std::vector< SdrObject* >::iterator aFindResult = |
890 | 0 | std::find(aParents.begin(), aParents.end(), pObject); |
891 | |
|
892 | 0 | if(aFindResult != aParents.end()) |
893 | 0 | { |
894 | 0 | aParents.erase(aFindResult); |
895 | 0 | } |
896 | 0 | } |
897 | 0 | } |
898 | 0 | } |
899 | | |
900 | | // original stuff: remove selected objects. Handle clear will |
901 | | // do something only once |
902 | 0 | auto temp(DeleteMarkedList(rMarkList)); |
903 | 0 | lazyDeleteObjects.insert(lazyDeleteObjects.end(), temp.begin(), temp.end()); |
904 | 0 | GetMarkedObjectListWriteAccess().Clear(); |
905 | 0 | maHdlList.Clear(); |
906 | |
|
907 | 0 | while(!aParents.empty() && !rMarkList.GetMarkCount()) |
908 | 0 | { |
909 | | // iterate over remembered parents |
910 | 0 | SdrObject* pParent = aParents.back(); |
911 | 0 | aParents.pop_back(); |
912 | |
|
913 | 0 | if(pParent->GetSubList() && 0 == pParent->GetSubList()->GetObjCount()) |
914 | 0 | { |
915 | | // we detected an empty parent, a candidate to leave group/3DScene |
916 | | // if entered |
917 | 0 | if(GetSdrPageView()->GetCurrentGroup() |
918 | 0 | && GetSdrPageView()->GetCurrentGroup() == pParent) |
919 | 0 | { |
920 | 0 | GetSdrPageView()->LeaveOneGroup(); |
921 | 0 | } |
922 | | |
923 | | // schedule empty parent for removal |
924 | 0 | GetMarkedObjectListWriteAccess().InsertEntry( |
925 | 0 | SdrMark(pParent, GetSdrPageView())); |
926 | 0 | } |
927 | 0 | } |
928 | 0 | } |
929 | | |
930 | | // end undo and change messaging moved at the end |
931 | 0 | EndUndo(); |
932 | 0 | MarkListHasChanged(); |
933 | |
|
934 | 0 | lcl_LazyDelete(lazyDeleteObjects); |
935 | 0 | } |
936 | | |
937 | | void SdrEditView::CopyMarkedObj() |
938 | 0 | { |
939 | 0 | const SdrMarkList& rMarkList = GetMarkedObjectList(); |
940 | 0 | rMarkList.ForceSort(); |
941 | |
|
942 | 0 | SdrMarkList aSourceObjectsForCopy(rMarkList); |
943 | | // The following loop is used instead of MarkList::Merge(), to be |
944 | | // able to flag the MarkEntries. |
945 | 0 | const size_t nEdgeCnt = GetEdgesOfMarkedNodes().GetMarkCount(); |
946 | 0 | for (size_t nEdgeNum=0; nEdgeNum<nEdgeCnt; ++nEdgeNum) { |
947 | 0 | SdrMark aM(*GetEdgesOfMarkedNodes().GetMark(nEdgeNum)); |
948 | 0 | aM.SetUser(1); |
949 | 0 | aSourceObjectsForCopy.InsertEntry(aM); |
950 | 0 | } |
951 | 0 | aSourceObjectsForCopy.ForceSort(); |
952 | | |
953 | | // #i13033# |
954 | | // New mechanism to re-create the connections of cloned connectors |
955 | 0 | CloneList aCloneList; |
956 | |
|
957 | 0 | const bool bUndo = IsUndoEnabled(); |
958 | |
|
959 | 0 | GetMarkedObjectListWriteAccess().Clear(); |
960 | 0 | size_t nCloneErrCnt=0; |
961 | 0 | std::unordered_set<rtl::OUString> aNameSet; |
962 | 0 | const size_t nMarkCount=aSourceObjectsForCopy.GetMarkCount(); |
963 | 0 | for (size_t nm=0; nm<nMarkCount; ++nm) { |
964 | 0 | SdrMark* pM=aSourceObjectsForCopy.GetMark(nm); |
965 | 0 | SdrObject* pSource(pM->GetMarkedSdrObj()); |
966 | 0 | rtl::Reference<SdrObject> pO(pSource->CloneSdrObject(pSource->getSdrModelFromSdrObject())); |
967 | 0 | if (pO!=nullptr) { |
968 | 0 | pM->GetPageView()->GetObjList()->InsertObjectThenMakeNameUnique(pO.get(), aNameSet); |
969 | |
|
970 | 0 | if( bUndo ) |
971 | 0 | AddUndo(GetModel().GetSdrUndoFactory().CreateUndoCopyObject(*pO)); |
972 | |
|
973 | 0 | SdrMark aME(*pM); |
974 | 0 | aME.SetMarkedSdrObj(pO.get()); |
975 | 0 | aCloneList.AddPair(pM->GetMarkedSdrObj(), pO.get()); |
976 | |
|
977 | 0 | if (pM->GetUser()==0) |
978 | 0 | { |
979 | | // otherwise it is only an Edge we have to copy as well |
980 | 0 | GetMarkedObjectListWriteAccess().InsertEntry(aME); |
981 | 0 | } |
982 | 0 | } else { |
983 | 0 | nCloneErrCnt++; |
984 | 0 | } |
985 | 0 | } |
986 | | |
987 | | // #i13033# |
988 | | // New mechanism to re-create the connections of cloned connectors |
989 | 0 | aCloneList.CopyConnections(); |
990 | |
|
991 | 0 | if(nCloneErrCnt) |
992 | 0 | { |
993 | | #ifdef DBG_UTIL |
994 | | OStringBuffer aStr("SdrEditView::CopyMarkedObj(): Error when cloning "); |
995 | | |
996 | | if(nCloneErrCnt == 1) |
997 | | { |
998 | | aStr.append("a drawing object."); |
999 | | } |
1000 | | else |
1001 | | { |
1002 | | aStr.append(OString::number(static_cast<sal_Int32>(nCloneErrCnt)) |
1003 | | + " drawing objects."); |
1004 | | } |
1005 | | |
1006 | | aStr.append(" This object's/These objects's connections will not be copied."); |
1007 | | OSL_FAIL(aStr.getStr()); |
1008 | | #endif |
1009 | 0 | } |
1010 | 0 | MarkListHasChanged(); |
1011 | 0 | } |
1012 | | |
1013 | | |
1014 | | bool SdrEditView::InsertObjectAtView(SdrObject* pObj, SdrPageView& rPV, SdrInsertFlags nOptions) |
1015 | 0 | { |
1016 | 0 | if (nOptions & SdrInsertFlags::SETDEFLAYER) { |
1017 | 0 | SdrLayerID nLayer=rPV.GetPage()->GetLayerAdmin().GetLayerID(maActualLayer); |
1018 | 0 | if (nLayer==SDRLAYER_NOTFOUND) nLayer=SdrLayerID(0); |
1019 | 0 | if (rPV.GetLockedLayers().IsSet(nLayer) || !rPV.GetVisibleLayers().IsSet(nLayer)) { |
1020 | 0 | return false; |
1021 | 0 | } |
1022 | 0 | pObj->NbcSetLayer(nLayer); |
1023 | 0 | } |
1024 | 0 | if (nOptions & SdrInsertFlags::SETDEFATTR) { |
1025 | 0 | if (mpDefaultStyleSheet!=nullptr) pObj->NbcSetStyleSheet(mpDefaultStyleSheet, false); |
1026 | 0 | pObj->SetMergedItemSet(maDefaultAttr); |
1027 | 0 | } |
1028 | 0 | if (!pObj->IsInserted()) { |
1029 | 0 | rPV.GetObjList()->InsertObject(pObj, SAL_MAX_SIZE); |
1030 | 0 | } |
1031 | |
|
1032 | 0 | css::uno::Reference<lang::XServiceInfo> xServices(GetModel().getUnoModel(), |
1033 | 0 | css::uno::UNO_QUERY); |
1034 | 0 | if (xServices.is() && (xServices->supportsService(u"com.sun.star.sheet.SpreadsheetDocument"_ustr) || |
1035 | 0 | xServices->supportsService(u"com.sun.star.text.TextDocument"_ustr))) |
1036 | 0 | { |
1037 | 0 | const bool bUndo(IsUndoEnabled()); |
1038 | 0 | GetModel().EnableUndo(false); |
1039 | 0 | pObj->MakeNameUnique(); |
1040 | 0 | GetModel().EnableUndo(bUndo); |
1041 | 0 | } |
1042 | |
|
1043 | 0 | if( IsUndoEnabled()) |
1044 | 0 | { |
1045 | 0 | bool bDontDeleteReally = true; |
1046 | 0 | EndTextEditCurrentView(bDontDeleteReally); |
1047 | 0 | AddUndo(GetModel().GetSdrUndoFactory().CreateUndoNewObject(*pObj)); |
1048 | 0 | } |
1049 | |
|
1050 | 0 | if (!(nOptions & SdrInsertFlags::DONTMARK)) { |
1051 | 0 | if (!(nOptions & SdrInsertFlags::ADDMARK)) UnmarkAllObj(); |
1052 | 0 | MarkObj(pObj,&rPV); |
1053 | 0 | } |
1054 | 0 | return true; |
1055 | 0 | } |
1056 | | |
1057 | | void SdrEditView::ReplaceObjectAtView(SdrObject* pOldObj, SdrPageView& rPV, SdrObject* pNewObj, bool bMark) |
1058 | 0 | { |
1059 | 0 | if(IsTextEdit()) |
1060 | 0 | { |
1061 | | #ifdef DBG_UTIL |
1062 | | if(auto pTextObj = DynCastSdrTextObj(pOldObj)) |
1063 | | if (pTextObj->IsTextEditActive()) |
1064 | | OSL_ENSURE(false, "OldObject is in TextEdit mode, this has to be ended before replacing it using SdrEndTextEdit (!)"); |
1065 | | |
1066 | | if(auto pTextObj = DynCastSdrTextObj(pNewObj)) |
1067 | | if (pTextObj->IsTextEditActive()) |
1068 | | OSL_ENSURE(false, "NewObject is in TextEdit mode, this has to be ended before replacing it using SdrEndTextEdit (!)"); |
1069 | | #endif |
1070 | | |
1071 | | // #i123468# emergency repair situation, needs to cast up to a class derived from |
1072 | | // this one; (aw080 has a mechanism for that and the view hierarchy is secured to |
1073 | | // always be a SdrView) |
1074 | 0 | SdrView *pSdrView = dynamic_cast<SdrView*>(this); |
1075 | 0 | if (pSdrView) |
1076 | 0 | pSdrView->SdrEndTextEdit(); |
1077 | 0 | } |
1078 | |
|
1079 | 0 | SdrObjList* pOL=pOldObj->getParentSdrObjListFromSdrObject(); |
1080 | 0 | const bool bUndo = IsUndoEnabled(); |
1081 | 0 | if( bUndo ) |
1082 | 0 | AddUndo(GetModel().GetSdrUndoFactory().CreateUndoReplaceObject(*pOldObj,*pNewObj)); |
1083 | |
|
1084 | 0 | if( IsObjMarked( pOldObj ) ) |
1085 | 0 | MarkObj( pOldObj, &rPV, true /*unmark!*/ ); |
1086 | |
|
1087 | 0 | pOL->ReplaceObject(pNewObj,pOldObj->GetOrdNum()); |
1088 | |
|
1089 | 0 | if (bMark) MarkObj(pNewObj,&rPV); |
1090 | 0 | } |
1091 | | |
1092 | | |
1093 | | bool SdrEditView::IsUndoEnabled() const |
1094 | 0 | { |
1095 | 0 | return GetModel().IsUndoEnabled(); |
1096 | 0 | } |
1097 | | |
1098 | | void SdrEditView::EndTextEditAllViews() const |
1099 | 0 | { |
1100 | 0 | GetModel().ForAllListeners( |
1101 | 0 | [](SfxListener* pListener) |
1102 | 0 | { |
1103 | 0 | SdrObjEditView* pView = dynamic_cast<SdrObjEditView*>(pListener); |
1104 | 0 | if (pView && pView->IsTextEdit()) |
1105 | 0 | pView->SdrEndTextEdit(); |
1106 | 0 | return false; |
1107 | 0 | }); |
1108 | 0 | } |
1109 | | |
1110 | | void SdrEditView::EndTextEditCurrentView(bool bDontDeleteReally) |
1111 | 0 | { |
1112 | 0 | if (IsTextEdit()) |
1113 | 0 | { |
1114 | 0 | SdrView* pSdrView = dynamic_cast<SdrView*>(this); |
1115 | 0 | if (pSdrView) |
1116 | 0 | pSdrView->SdrEndTextEdit(bDontDeleteReally); |
1117 | 0 | } |
1118 | 0 | } |
1119 | | |
1120 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |