xref: /trunk/main/svx/source/svdraw/svdedtv2.cxx (revision cf6516809c57e1bb0a940545cca99cdad54d4ce2)
1f6e50924SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3f6e50924SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4f6e50924SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5f6e50924SAndrew Rist  * distributed with this work for additional information
6f6e50924SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7f6e50924SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8f6e50924SAndrew Rist  * "License"); you may not use this file except in compliance
9f6e50924SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11f6e50924SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13f6e50924SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14f6e50924SAndrew Rist  * software distributed under the License is distributed on an
15f6e50924SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16f6e50924SAndrew Rist  * KIND, either express or implied.  See the License for the
17f6e50924SAndrew Rist  * specific language governing permissions and limitations
18f6e50924SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20f6e50924SAndrew Rist  *************************************************************/
21f6e50924SAndrew Rist 
22f6e50924SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svx.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <svx/svdedtv.hxx>
28cdf0e10cSrcweir #include <editeng/outliner.hxx>
29cdf0e10cSrcweir #include <svx/svdundo.hxx>
30cdf0e10cSrcweir #include <svx/svdogrp.hxx>   // fuer's Gruppieren
31cdf0e10cSrcweir #include <svx/svdovirt.hxx>  // fuer VirtualObject-Bundling (Writer)
32cdf0e10cSrcweir #include <svx/svdopath.hxx>  // fuer CombineObjects
33cdf0e10cSrcweir #include <svx/svdpage.hxx>
34cdf0e10cSrcweir #include <svx/svdpagv.hxx>
35cdf0e10cSrcweir #include "svx/svditer.hxx"
36cdf0e10cSrcweir #include <svx/svdograf.hxx>  // fuer Possibilities
37cdf0e10cSrcweir #include <svx/svdoole2.hxx>  // und Mtf-Import
38cdf0e10cSrcweir #include "svx/svdstr.hrc"   // Namen aus der Resource
39cdf0e10cSrcweir #include "svx/svdglob.hxx"  // StringCache
40cdf0e10cSrcweir #include "svdfmtf.hxx"
41cdf0e10cSrcweir #include <svx/svdetc.hxx>
42cdf0e10cSrcweir #include <sfx2/basedlgs.hxx>
43cdf0e10cSrcweir #include <vcl/msgbox.hxx>
44cdf0e10cSrcweir #include <editeng/outlobj.hxx>
45cdf0e10cSrcweir #include <editeng/eeitem.hxx>
46cdf0e10cSrcweir #include <basegfx/polygon/b2dpolypolygon.hxx>
47cdf0e10cSrcweir #include <basegfx/polygon/b2dpolypolygontools.hxx>
48cdf0e10cSrcweir 
49cdf0e10cSrcweir #include <svx/svxdlg.hxx> //CHINA001
50cdf0e10cSrcweir #include <svx/dialogs.hrc> //CHINA001
51cdf0e10cSrcweir 
52cdf0e10cSrcweir // #i37011#
53cdf0e10cSrcweir #include <svx/svdoashp.hxx>
54cdf0e10cSrcweir #include <basegfx/polygon/b2dpolypolygoncutter.hxx>
55cdf0e10cSrcweir 
56cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
57cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
58cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
59cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
60cdf0e10cSrcweir //
61cdf0e10cSrcweir //  @@@@@ @@@@@  @@ @@@@@@  @@ @@ @@ @@@@@ @@   @@
62cdf0e10cSrcweir //  @@    @@  @@ @@   @@    @@ @@ @@ @@    @@   @@
63cdf0e10cSrcweir //  @@    @@  @@ @@   @@    @@ @@ @@ @@    @@ @ @@
64cdf0e10cSrcweir //  @@@@  @@  @@ @@   @@    @@@@@ @@ @@@@  @@@@@@@
65cdf0e10cSrcweir //  @@    @@  @@ @@   @@     @@@  @@ @@    @@@@@@@
66cdf0e10cSrcweir //  @@    @@  @@ @@   @@     @@@  @@ @@    @@@ @@@
67cdf0e10cSrcweir //  @@@@@ @@@@@  @@   @@      @   @@ @@@@@ @@   @@
68cdf0e10cSrcweir //
69cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
70cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
71cdf0e10cSrcweir 
ImpBundleVirtObjOfMarkList()72cdf0e10cSrcweir void SdrEditView::ImpBundleVirtObjOfMarkList()
73cdf0e10cSrcweir {
74cdf0e10cSrcweir   // ... fehlende Implementation
75cdf0e10cSrcweir }
76cdf0e10cSrcweir 
GetMaxToTopObj(SdrObject *) const77cdf0e10cSrcweir SdrObject* SdrEditView::GetMaxToTopObj(SdrObject* /*pObj*/) const
78cdf0e10cSrcweir {
79cdf0e10cSrcweir   return NULL;
80cdf0e10cSrcweir }
81cdf0e10cSrcweir 
GetMaxToBtmObj(SdrObject *) const82cdf0e10cSrcweir SdrObject* SdrEditView::GetMaxToBtmObj(SdrObject* /*pObj*/) const
83cdf0e10cSrcweir {
84cdf0e10cSrcweir   return NULL;
85cdf0e10cSrcweir }
86cdf0e10cSrcweir 
ObjOrderChanged(SdrObject *,sal_uIntPtr,sal_uIntPtr)87cdf0e10cSrcweir void SdrEditView::ObjOrderChanged(SdrObject* /*pObj*/, sal_uIntPtr /*nOldPos*/, sal_uIntPtr /*nNewPos*/)
88cdf0e10cSrcweir {
89cdf0e10cSrcweir }
90cdf0e10cSrcweir 
MovMarkedToTop()91cdf0e10cSrcweir void SdrEditView::MovMarkedToTop()
92cdf0e10cSrcweir {
93cdf0e10cSrcweir     sal_uIntPtr nAnz=GetMarkedObjectCount();
94cdf0e10cSrcweir     if (nAnz!=0)
95cdf0e10cSrcweir     {
96cdf0e10cSrcweir         const bool bUndo = IsUndoEnabled();
97cdf0e10cSrcweir 
98cdf0e10cSrcweir         if( bUndo )
99cdf0e10cSrcweir             BegUndo(ImpGetResStr(STR_EditMovToTop),GetDescriptionOfMarkedObjects(),SDRREPFUNC_OBJ_MOVTOTOP);
100cdf0e10cSrcweir 
101cdf0e10cSrcweir         SortMarkedObjects();
102cdf0e10cSrcweir         sal_uIntPtr nm;
103cdf0e10cSrcweir         for (nm=0; nm<nAnz; nm++)
104cdf0e10cSrcweir         { // Ordnums muessen alle stimmen!
105cdf0e10cSrcweir             GetMarkedObjectByIndex(nm)->GetOrdNum();
106cdf0e10cSrcweir         }
107cdf0e10cSrcweir         sal_Bool bChg=sal_False;
108cdf0e10cSrcweir         SdrObjList* pOL0=NULL;
109cdf0e10cSrcweir         sal_uIntPtr nNewPos=0;
110cdf0e10cSrcweir         for (nm=nAnz; nm>0;)
111cdf0e10cSrcweir         {
112cdf0e10cSrcweir             nm--;
113cdf0e10cSrcweir             SdrMark* pM=GetSdrMarkByIndex(nm);
114cdf0e10cSrcweir             SdrObject* pObj=pM->GetMarkedSdrObj();
115cdf0e10cSrcweir             SdrObjList* pOL=pObj->GetObjList();
116cdf0e10cSrcweir             if (pOL!=pOL0)
117cdf0e10cSrcweir             {
118cdf0e10cSrcweir                 nNewPos=sal_uIntPtr(pOL->GetObjCount()-1);
119cdf0e10cSrcweir                 pOL0=pOL;
120cdf0e10cSrcweir             }
121cdf0e10cSrcweir             sal_uIntPtr nNowPos=pObj->GetOrdNumDirect();
122cdf0e10cSrcweir             const Rectangle& rBR=pObj->GetCurrentBoundRect();
123cdf0e10cSrcweir             sal_uIntPtr nCmpPos=nNowPos+1;
124cdf0e10cSrcweir             SdrObject* pMaxObj=GetMaxToTopObj(pObj);
125cdf0e10cSrcweir             if (pMaxObj!=NULL)
126cdf0e10cSrcweir             {
127cdf0e10cSrcweir                 sal_uIntPtr nMaxPos=pMaxObj->GetOrdNum();
128cdf0e10cSrcweir                 if (nMaxPos!=0)
129cdf0e10cSrcweir                     nMaxPos--;
130cdf0e10cSrcweir                 if (nNewPos>nMaxPos)
131cdf0e10cSrcweir                     nNewPos=nMaxPos; // diesen nicht ueberholen.
132cdf0e10cSrcweir                 if (nNewPos<nNowPos)
133cdf0e10cSrcweir                     nNewPos=nNowPos; // aber dabei auch nicht in die falsche Richtung schieben
134cdf0e10cSrcweir             }
135cdf0e10cSrcweir             sal_Bool bEnd=sal_False;
136cdf0e10cSrcweir             while (nCmpPos<nNewPos && !bEnd)
137cdf0e10cSrcweir             {
138cdf0e10cSrcweir                 SdrObject* pCmpObj=pOL->GetObj(nCmpPos);
139cdf0e10cSrcweir                 if (pCmpObj==NULL)
140cdf0e10cSrcweir                 {
141cdf0e10cSrcweir                     DBG_ERROR("MovMarkedToTop(): Vergleichsobjekt nicht gefunden");
142cdf0e10cSrcweir                     bEnd=sal_True;
143cdf0e10cSrcweir                 }
144cdf0e10cSrcweir                 else if (pCmpObj==pMaxObj)
145cdf0e10cSrcweir                 {
146cdf0e10cSrcweir                     nNewPos=nCmpPos;
147cdf0e10cSrcweir                     nNewPos--;
148cdf0e10cSrcweir                     bEnd=sal_True;
149cdf0e10cSrcweir                 }
150cdf0e10cSrcweir                 else if (rBR.IsOver(pCmpObj->GetCurrentBoundRect()))
151cdf0e10cSrcweir                 {
152cdf0e10cSrcweir                     nNewPos=nCmpPos;
153cdf0e10cSrcweir                     bEnd=sal_True;
154cdf0e10cSrcweir                 }
155cdf0e10cSrcweir                 else
156cdf0e10cSrcweir                 {
157cdf0e10cSrcweir                     nCmpPos++;
158cdf0e10cSrcweir                 }
159cdf0e10cSrcweir             }
160cdf0e10cSrcweir             if (nNowPos!=nNewPos)
161cdf0e10cSrcweir             {
162cdf0e10cSrcweir                 bChg=sal_True;
163cdf0e10cSrcweir                 pOL->SetObjectOrdNum(nNowPos,nNewPos);
164cdf0e10cSrcweir                 if( bUndo )
165cdf0e10cSrcweir                     AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoObjectOrdNum(*pObj,nNowPos,nNewPos));
166cdf0e10cSrcweir                 ObjOrderChanged(pObj,nNowPos,nNewPos);
167cdf0e10cSrcweir             }
168cdf0e10cSrcweir             nNewPos--;
169cdf0e10cSrcweir         }
170cdf0e10cSrcweir 
171cdf0e10cSrcweir         if( bUndo )
172cdf0e10cSrcweir             EndUndo();
173cdf0e10cSrcweir 
174cdf0e10cSrcweir         if (bChg)
175cdf0e10cSrcweir             MarkListHasChanged();
176cdf0e10cSrcweir     }
177cdf0e10cSrcweir }
178cdf0e10cSrcweir 
MovMarkedToBtm()179cdf0e10cSrcweir void SdrEditView::MovMarkedToBtm()
180cdf0e10cSrcweir {
181cdf0e10cSrcweir     sal_uIntPtr nAnz=GetMarkedObjectCount();
182cdf0e10cSrcweir     if (nAnz!=0)
183cdf0e10cSrcweir     {
184cdf0e10cSrcweir         const bool bUndo = IsUndoEnabled();
185cdf0e10cSrcweir 
186cdf0e10cSrcweir         if( bUndo )
187cdf0e10cSrcweir             BegUndo(ImpGetResStr(STR_EditMovToBtm),GetDescriptionOfMarkedObjects(),SDRREPFUNC_OBJ_MOVTOBTM);
188cdf0e10cSrcweir 
189cdf0e10cSrcweir         SortMarkedObjects();
190cdf0e10cSrcweir         sal_uIntPtr nm;
191cdf0e10cSrcweir         for (nm=0; nm<nAnz; nm++)
192cdf0e10cSrcweir         { // Ordnums muessen alle stimmen!
193cdf0e10cSrcweir             GetMarkedObjectByIndex(nm)->GetOrdNum();
194cdf0e10cSrcweir         }
195cdf0e10cSrcweir 
196cdf0e10cSrcweir         sal_Bool bChg=sal_False;
197cdf0e10cSrcweir         SdrObjList* pOL0=NULL;
198cdf0e10cSrcweir         sal_uIntPtr nNewPos=0;
199cdf0e10cSrcweir         for (nm=0; nm<nAnz; nm++)
200cdf0e10cSrcweir         {
201cdf0e10cSrcweir             SdrMark* pM=GetSdrMarkByIndex(nm);
202cdf0e10cSrcweir             SdrObject* pObj=pM->GetMarkedSdrObj();
203cdf0e10cSrcweir             SdrObjList* pOL=pObj->GetObjList();
204cdf0e10cSrcweir             if (pOL!=pOL0)
205cdf0e10cSrcweir             {
206cdf0e10cSrcweir                 nNewPos=0;
207cdf0e10cSrcweir                 pOL0=pOL;
208cdf0e10cSrcweir             }
209cdf0e10cSrcweir             sal_uIntPtr nNowPos=pObj->GetOrdNumDirect();
210cdf0e10cSrcweir             const Rectangle& rBR=pObj->GetCurrentBoundRect();
211cdf0e10cSrcweir             sal_uIntPtr nCmpPos=nNowPos; if (nCmpPos>0) nCmpPos--;
212cdf0e10cSrcweir             SdrObject* pMaxObj=GetMaxToBtmObj(pObj);
213cdf0e10cSrcweir             if (pMaxObj!=NULL)
214cdf0e10cSrcweir             {
215cdf0e10cSrcweir                 sal_uIntPtr nMinPos=pMaxObj->GetOrdNum()+1;
216cdf0e10cSrcweir                 if (nNewPos<nMinPos)
217cdf0e10cSrcweir                     nNewPos=nMinPos; // diesen nicht ueberholen.
218cdf0e10cSrcweir                 if (nNewPos>nNowPos)
219cdf0e10cSrcweir                     nNewPos=nNowPos; // aber dabei auch nicht in die falsche Richtung schieben
220cdf0e10cSrcweir             }
221cdf0e10cSrcweir             sal_Bool bEnd=sal_False;
222cdf0e10cSrcweir             // nNewPos ist an dieser Stelle noch die maximale Position,
223cdf0e10cSrcweir             // an der das Obj hinruecken darf, ohne seinen Vorgaenger
224cdf0e10cSrcweir             // (Mehrfachselektion) zu ueberholen.
225cdf0e10cSrcweir             while (nCmpPos>nNewPos && !bEnd)
226cdf0e10cSrcweir             {
227cdf0e10cSrcweir                 SdrObject* pCmpObj=pOL->GetObj(nCmpPos);
228cdf0e10cSrcweir                 if (pCmpObj==NULL)
229cdf0e10cSrcweir                 {
230cdf0e10cSrcweir                     DBG_ERROR("MovMarkedToBtm(): Vergleichsobjekt nicht gefunden");
231cdf0e10cSrcweir                     bEnd=sal_True;
232cdf0e10cSrcweir                 }
233cdf0e10cSrcweir                 else if (pCmpObj==pMaxObj)
234cdf0e10cSrcweir                 {
235cdf0e10cSrcweir                     nNewPos=nCmpPos;
236cdf0e10cSrcweir                     nNewPos++;
237cdf0e10cSrcweir                     bEnd=sal_True;
238cdf0e10cSrcweir                 }
239cdf0e10cSrcweir                 else if (rBR.IsOver(pCmpObj->GetCurrentBoundRect()))
240cdf0e10cSrcweir                 {
241cdf0e10cSrcweir                     nNewPos=nCmpPos;
242cdf0e10cSrcweir                     bEnd=sal_True;
243cdf0e10cSrcweir                 }
244cdf0e10cSrcweir                 else
245cdf0e10cSrcweir                 {
246cdf0e10cSrcweir                     nCmpPos--;
247cdf0e10cSrcweir                 }
248cdf0e10cSrcweir             }
249cdf0e10cSrcweir             if (nNowPos!=nNewPos)
250cdf0e10cSrcweir             {
251cdf0e10cSrcweir                 bChg=sal_True;
252cdf0e10cSrcweir                 pOL->SetObjectOrdNum(nNowPos,nNewPos);
253cdf0e10cSrcweir                 if( bUndo )
254cdf0e10cSrcweir                     AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoObjectOrdNum(*pObj,nNowPos,nNewPos));
255cdf0e10cSrcweir                 ObjOrderChanged(pObj,nNowPos,nNewPos);
256cdf0e10cSrcweir             }
257cdf0e10cSrcweir             nNewPos++;
258cdf0e10cSrcweir         }
259cdf0e10cSrcweir 
260cdf0e10cSrcweir         if(bUndo)
261cdf0e10cSrcweir             EndUndo();
262cdf0e10cSrcweir 
263cdf0e10cSrcweir         if(bChg)
264cdf0e10cSrcweir             MarkListHasChanged();
265cdf0e10cSrcweir     }
266cdf0e10cSrcweir }
267cdf0e10cSrcweir 
PutMarkedToTop()268cdf0e10cSrcweir void SdrEditView::PutMarkedToTop()
269cdf0e10cSrcweir {
270cdf0e10cSrcweir     PutMarkedInFrontOfObj(NULL);
271cdf0e10cSrcweir }
272cdf0e10cSrcweir 
PutMarkedInFrontOfObj(const SdrObject * pRefObj)273cdf0e10cSrcweir void SdrEditView::PutMarkedInFrontOfObj(const SdrObject* pRefObj)
274cdf0e10cSrcweir {
275cdf0e10cSrcweir     sal_uIntPtr nAnz=GetMarkedObjectCount();
276cdf0e10cSrcweir     if (nAnz!=0)
277cdf0e10cSrcweir     {
278cdf0e10cSrcweir         const bool bUndo = IsUndoEnabled();
279cdf0e10cSrcweir         if( bUndo )
280cdf0e10cSrcweir             BegUndo(ImpGetResStr(STR_EditPutToTop),GetDescriptionOfMarkedObjects(),SDRREPFUNC_OBJ_PUTTOTOP);
281cdf0e10cSrcweir 
282cdf0e10cSrcweir         SortMarkedObjects();
283cdf0e10cSrcweir 
284cdf0e10cSrcweir         if (pRefObj!=NULL)
285cdf0e10cSrcweir         {
286cdf0e10cSrcweir             // Damit "Vor das Objekt" auch funktioniert wenn die
287cdf0e10cSrcweir             // markierten Objekte bereits vor dem Objekt stehen
288cdf0e10cSrcweir             sal_uIntPtr nRefMark=TryToFindMarkedObject(pRefObj);
289cdf0e10cSrcweir             SdrMark aRefMark;
290cdf0e10cSrcweir             if (nRefMark!=CONTAINER_ENTRY_NOTFOUND)
291cdf0e10cSrcweir             {
292cdf0e10cSrcweir                 aRefMark=*GetSdrMarkByIndex(nRefMark);
293cdf0e10cSrcweir                 GetMarkedObjectListWriteAccess().DeleteMark(nRefMark);
294cdf0e10cSrcweir             }
295cdf0e10cSrcweir             PutMarkedToBtm();
296cdf0e10cSrcweir             if (nRefMark!=CONTAINER_ENTRY_NOTFOUND)
297cdf0e10cSrcweir             {
298cdf0e10cSrcweir                 GetMarkedObjectListWriteAccess().InsertEntry(aRefMark);
299cdf0e10cSrcweir                 SortMarkedObjects();
300cdf0e10cSrcweir             }
301cdf0e10cSrcweir         }
302cdf0e10cSrcweir         sal_uIntPtr nm;
303cdf0e10cSrcweir         for (nm=0; nm<nAnz; nm++)
304cdf0e10cSrcweir         { // Ordnums muessen alle stimmen!
305cdf0e10cSrcweir             GetMarkedObjectByIndex(nm)->GetOrdNum();
306cdf0e10cSrcweir         }
307cdf0e10cSrcweir         sal_Bool bChg=sal_False;
308cdf0e10cSrcweir         SdrObjList* pOL0=NULL;
309cdf0e10cSrcweir         sal_uIntPtr nNewPos=0;
310cdf0e10cSrcweir         for (nm=nAnz; nm>0;)
311cdf0e10cSrcweir         {
312cdf0e10cSrcweir             nm--;
313cdf0e10cSrcweir             SdrMark* pM=GetSdrMarkByIndex(nm);
314cdf0e10cSrcweir             SdrObject* pObj=pM->GetMarkedSdrObj();
315cdf0e10cSrcweir             if (pObj!=pRefObj)
316cdf0e10cSrcweir             {
317cdf0e10cSrcweir                 SdrObjList* pOL=pObj->GetObjList();
318cdf0e10cSrcweir                 if (pOL!=pOL0)
319cdf0e10cSrcweir                 {
320cdf0e10cSrcweir                     nNewPos=sal_uIntPtr(pOL->GetObjCount()-1);
321cdf0e10cSrcweir                     pOL0=pOL;
322cdf0e10cSrcweir                 }
323cdf0e10cSrcweir                 sal_uIntPtr nNowPos=pObj->GetOrdNumDirect();
324cdf0e10cSrcweir                 SdrObject* pMaxObj=GetMaxToTopObj(pObj);
325cdf0e10cSrcweir                 if (pMaxObj!=NULL)
326cdf0e10cSrcweir                 {
327cdf0e10cSrcweir                     sal_uIntPtr nMaxOrd=pMaxObj->GetOrdNum(); // geht leider nicht anders
328cdf0e10cSrcweir                     if (nMaxOrd>0)
329cdf0e10cSrcweir                         nMaxOrd--;
330cdf0e10cSrcweir                     if (nNewPos>nMaxOrd)
331cdf0e10cSrcweir                         nNewPos=nMaxOrd; // nicht ueberholen.
332cdf0e10cSrcweir                     if (nNewPos<nNowPos)
333cdf0e10cSrcweir                         nNewPos=nNowPos; // aber dabei auch nicht in die falsche Richtung schieben
334cdf0e10cSrcweir                 }
335cdf0e10cSrcweir                 if (pRefObj!=NULL)
336cdf0e10cSrcweir                 {
337cdf0e10cSrcweir                     if (pRefObj->GetObjList()==pObj->GetObjList())
338cdf0e10cSrcweir                     {
339cdf0e10cSrcweir                         sal_uIntPtr nMaxOrd=pRefObj->GetOrdNum(); // geht leider nicht anders
340cdf0e10cSrcweir                         if (nNewPos>nMaxOrd)
341cdf0e10cSrcweir                             nNewPos=nMaxOrd; // nicht ueberholen.
342cdf0e10cSrcweir                         if (nNewPos<nNowPos)
343cdf0e10cSrcweir                             nNewPos=nNowPos; // aber dabei auch nicht in die falsche Richtung schieben
344cdf0e10cSrcweir                     }
345cdf0e10cSrcweir                     else
346cdf0e10cSrcweir                     {
347cdf0e10cSrcweir                         nNewPos=nNowPos; // andere PageView, also nicht veraendern
348cdf0e10cSrcweir                     }
349cdf0e10cSrcweir                 }
350cdf0e10cSrcweir                 if (nNowPos!=nNewPos)
351cdf0e10cSrcweir                 {
352cdf0e10cSrcweir                     bChg=sal_True;
353cdf0e10cSrcweir                     pOL->SetObjectOrdNum(nNowPos,nNewPos);
354cdf0e10cSrcweir                     if( bUndo )
355cdf0e10cSrcweir                         AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoObjectOrdNum(*pObj,nNowPos,nNewPos));
356cdf0e10cSrcweir                     ObjOrderChanged(pObj,nNowPos,nNewPos);
357cdf0e10cSrcweir                 }
358cdf0e10cSrcweir                 nNewPos--;
359cdf0e10cSrcweir             } // if (pObj!=pRefObj)
360cdf0e10cSrcweir         } // for-Schleife ueber alle Markierten Objekte
361cdf0e10cSrcweir 
362cdf0e10cSrcweir         if( bUndo )
363cdf0e10cSrcweir             EndUndo();
364cdf0e10cSrcweir 
365cdf0e10cSrcweir         if(bChg)
366cdf0e10cSrcweir             MarkListHasChanged();
367cdf0e10cSrcweir     }
368cdf0e10cSrcweir }
369cdf0e10cSrcweir 
PutMarkedToBtm()370cdf0e10cSrcweir void SdrEditView::PutMarkedToBtm()
371cdf0e10cSrcweir {
372cdf0e10cSrcweir     PutMarkedBehindObj(NULL);
373cdf0e10cSrcweir }
374cdf0e10cSrcweir 
PutMarkedBehindObj(const SdrObject * pRefObj)375cdf0e10cSrcweir void SdrEditView::PutMarkedBehindObj(const SdrObject* pRefObj)
376cdf0e10cSrcweir {
377cdf0e10cSrcweir     sal_uIntPtr nAnz=GetMarkedObjectCount();
378cdf0e10cSrcweir     if (nAnz!=0)
379cdf0e10cSrcweir     {
380cdf0e10cSrcweir         const bool bUndo = IsUndoEnabled();
381cdf0e10cSrcweir 
382cdf0e10cSrcweir         if( bUndo )
383cdf0e10cSrcweir             BegUndo(ImpGetResStr(STR_EditPutToBtm),GetDescriptionOfMarkedObjects(),SDRREPFUNC_OBJ_PUTTOBTM);
384cdf0e10cSrcweir 
385cdf0e10cSrcweir         SortMarkedObjects();
386cdf0e10cSrcweir         if (pRefObj!=NULL)
387cdf0e10cSrcweir         {
388cdf0e10cSrcweir             // Damit "Hinter das Objekt" auch funktioniert wenn die
389cdf0e10cSrcweir             // markierten Objekte bereits hinter dem Objekt stehen
390cdf0e10cSrcweir             sal_uIntPtr nRefMark=TryToFindMarkedObject(pRefObj);
391cdf0e10cSrcweir             SdrMark aRefMark;
392cdf0e10cSrcweir             if (nRefMark!=CONTAINER_ENTRY_NOTFOUND)
393cdf0e10cSrcweir             {
394cdf0e10cSrcweir                 aRefMark=*GetSdrMarkByIndex(nRefMark);
395cdf0e10cSrcweir                 GetMarkedObjectListWriteAccess().DeleteMark(nRefMark);
396cdf0e10cSrcweir             }
397cdf0e10cSrcweir             PutMarkedToTop();
398cdf0e10cSrcweir             if (nRefMark!=CONTAINER_ENTRY_NOTFOUND)
399cdf0e10cSrcweir             {
400cdf0e10cSrcweir                 GetMarkedObjectListWriteAccess().InsertEntry(aRefMark);
401cdf0e10cSrcweir                 SortMarkedObjects();
402cdf0e10cSrcweir             }
403cdf0e10cSrcweir         }
404cdf0e10cSrcweir         sal_uIntPtr nm;
405cdf0e10cSrcweir         for (nm=0; nm<nAnz; nm++) { // Ordnums muessen alle stimmen!
406cdf0e10cSrcweir             GetMarkedObjectByIndex(nm)->GetOrdNum();
407cdf0e10cSrcweir         }
408cdf0e10cSrcweir         sal_Bool bChg=sal_False;
409cdf0e10cSrcweir         SdrObjList* pOL0=NULL;
410cdf0e10cSrcweir         sal_uIntPtr nNewPos=0;
411cdf0e10cSrcweir         for (nm=0; nm<nAnz; nm++) {
412cdf0e10cSrcweir             SdrMark* pM=GetSdrMarkByIndex(nm);
413cdf0e10cSrcweir             SdrObject* pObj=pM->GetMarkedSdrObj();
414cdf0e10cSrcweir             if (pObj!=pRefObj) {
415cdf0e10cSrcweir                 SdrObjList* pOL=pObj->GetObjList();
416cdf0e10cSrcweir                 if (pOL!=pOL0) {
417cdf0e10cSrcweir                     nNewPos=0;
418cdf0e10cSrcweir                     pOL0=pOL;
419cdf0e10cSrcweir                 }
420cdf0e10cSrcweir                 sal_uIntPtr nNowPos=pObj->GetOrdNumDirect();
421cdf0e10cSrcweir                 SdrObject* pMinObj=GetMaxToBtmObj(pObj);
422cdf0e10cSrcweir                 if (pMinObj!=NULL) {
423cdf0e10cSrcweir                     sal_uIntPtr nMinOrd=pMinObj->GetOrdNum()+1; // geht leider nicht anders
424cdf0e10cSrcweir                     if (nNewPos<nMinOrd) nNewPos=nMinOrd; // nicht ueberholen.
425cdf0e10cSrcweir                     if (nNewPos>nNowPos) nNewPos=nNowPos; // aber dabei auch nicht in die falsche Richtung schieben
426cdf0e10cSrcweir                 }
427cdf0e10cSrcweir                 if (pRefObj!=NULL) {
428cdf0e10cSrcweir                     if (pRefObj->GetObjList()==pObj->GetObjList()) {
429cdf0e10cSrcweir                         sal_uIntPtr nMinOrd=pRefObj->GetOrdNum(); // geht leider nicht anders
430cdf0e10cSrcweir                         if (nNewPos<nMinOrd) nNewPos=nMinOrd; // nicht ueberholen.
431cdf0e10cSrcweir                         if (nNewPos>nNowPos) nNewPos=nNowPos; // aber dabei auch nicht in die falsche Richtung schieben
432cdf0e10cSrcweir                     } else {
433cdf0e10cSrcweir                         nNewPos=nNowPos; // andere PageView, also nicht veraendern
434cdf0e10cSrcweir                     }
435cdf0e10cSrcweir                 }
436cdf0e10cSrcweir                 if (nNowPos!=nNewPos) {
437cdf0e10cSrcweir                     bChg=sal_True;
438cdf0e10cSrcweir                     pOL->SetObjectOrdNum(nNowPos,nNewPos);
439cdf0e10cSrcweir                     if( bUndo )
440cdf0e10cSrcweir                         AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoObjectOrdNum(*pObj,nNowPos,nNewPos));
441cdf0e10cSrcweir                     ObjOrderChanged(pObj,nNowPos,nNewPos);
442cdf0e10cSrcweir                 }
443cdf0e10cSrcweir                 nNewPos++;
444cdf0e10cSrcweir             } // if (pObj!=pRefObj)
445cdf0e10cSrcweir         } // for-Schleife ueber alle markierten Objekte
446cdf0e10cSrcweir 
447cdf0e10cSrcweir         if(bUndo)
448cdf0e10cSrcweir             EndUndo();
449cdf0e10cSrcweir 
450cdf0e10cSrcweir         if(bChg)
451cdf0e10cSrcweir             MarkListHasChanged();
452cdf0e10cSrcweir     }
453cdf0e10cSrcweir }
454cdf0e10cSrcweir 
ReverseOrderOfMarked()455cdf0e10cSrcweir void SdrEditView::ReverseOrderOfMarked()
456cdf0e10cSrcweir {
457cdf0e10cSrcweir     SortMarkedObjects();
458cdf0e10cSrcweir     sal_uIntPtr nMarkAnz=GetMarkedObjectCount();
459cdf0e10cSrcweir     if (nMarkAnz>0)
460cdf0e10cSrcweir     {
461cdf0e10cSrcweir         //sal_Bool bNeedBundle=sal_False;
462cdf0e10cSrcweir         sal_Bool bChg=sal_False;
463cdf0e10cSrcweir 
464cdf0e10cSrcweir         bool bUndo = IsUndoEnabled();
465cdf0e10cSrcweir         if( bUndo )
466cdf0e10cSrcweir             BegUndo(ImpGetResStr(STR_EditRevOrder),GetDescriptionOfMarkedObjects(),SDRREPFUNC_OBJ_REVORDER);
467cdf0e10cSrcweir 
468cdf0e10cSrcweir         sal_uIntPtr a=0;
469cdf0e10cSrcweir         do {
470cdf0e10cSrcweir             // Markierung ueber mehrere PageViews berueksichtigen
471cdf0e10cSrcweir             sal_uIntPtr b=a+1;
472cdf0e10cSrcweir             while (b<nMarkAnz && GetSdrPageViewOfMarkedByIndex(b) == GetSdrPageViewOfMarkedByIndex(a)) b++;
473cdf0e10cSrcweir             b--;
474cdf0e10cSrcweir             SdrObjList* pOL=GetSdrPageViewOfMarkedByIndex(a)->GetObjList();
475cdf0e10cSrcweir             sal_uIntPtr c=b;
476cdf0e10cSrcweir             if (a<c) { // Sicherstellen, dass die OrdNums nicht Dirty sind
477cdf0e10cSrcweir                 GetMarkedObjectByIndex(a)->GetOrdNum();
478cdf0e10cSrcweir             }
479cdf0e10cSrcweir             while (a<c) {
480cdf0e10cSrcweir                 SdrObject* pObj1=GetMarkedObjectByIndex(a);
481cdf0e10cSrcweir                 SdrObject* pObj2=GetMarkedObjectByIndex(c);
482cdf0e10cSrcweir                 sal_uIntPtr nOrd1=pObj1->GetOrdNumDirect();
483cdf0e10cSrcweir                 sal_uIntPtr nOrd2=pObj2->GetOrdNumDirect();
484cdf0e10cSrcweir                 if( bUndo )
485cdf0e10cSrcweir                 {
486cdf0e10cSrcweir                     AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoObjectOrdNum(*pObj1,nOrd1,nOrd2));
487cdf0e10cSrcweir                     AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoObjectOrdNum(*pObj2,nOrd2-1,nOrd1));
488cdf0e10cSrcweir                 }
489cdf0e10cSrcweir                 pOL->SetObjectOrdNum(nOrd1,nOrd2);
490cdf0e10cSrcweir                 // Obj 2 ist um eine Position nach vorn gerutscht, deshalb nun nOrd2-1
491cdf0e10cSrcweir                 pOL->SetObjectOrdNum(nOrd2-1,nOrd1);
492cdf0e10cSrcweir                 // Verwendung von Replace statt SetOrdNum wg. Performance (Neuberechnung der Ordnums)
493cdf0e10cSrcweir                 a++; c--;
494cdf0e10cSrcweir                 bChg=sal_True;
495cdf0e10cSrcweir             }
496cdf0e10cSrcweir             a=b+1;
497cdf0e10cSrcweir         } while (a<nMarkAnz);
498cdf0e10cSrcweir 
499cdf0e10cSrcweir         if(bUndo)
500cdf0e10cSrcweir             EndUndo();
501cdf0e10cSrcweir 
502cdf0e10cSrcweir         if(bChg)
503cdf0e10cSrcweir             MarkListHasChanged();
504cdf0e10cSrcweir     }
505cdf0e10cSrcweir }
506cdf0e10cSrcweir 
ImpCheckToTopBtmPossible()507cdf0e10cSrcweir void SdrEditView::ImpCheckToTopBtmPossible()
508cdf0e10cSrcweir {
509cdf0e10cSrcweir     sal_uIntPtr nAnz=GetMarkedObjectCount();
510cdf0e10cSrcweir     if (nAnz==0)
511cdf0e10cSrcweir         return;
512cdf0e10cSrcweir     if (nAnz==1)
513cdf0e10cSrcweir     { // Sonderbehandlung fuer Einzelmarkierung
514cdf0e10cSrcweir         SdrObject* pObj=GetMarkedObjectByIndex(0);
515cdf0e10cSrcweir         SdrObjList* pOL=pObj->GetObjList();
516cdf0e10cSrcweir         sal_uIntPtr nMax=pOL->GetObjCount();
517cdf0e10cSrcweir         sal_uIntPtr nMin=0;
518cdf0e10cSrcweir         sal_uIntPtr nObjNum=pObj->GetOrdNum();
519cdf0e10cSrcweir         SdrObject* pRestrict=GetMaxToTopObj(pObj);
520cdf0e10cSrcweir         if (pRestrict!=NULL) {
521cdf0e10cSrcweir             sal_uIntPtr nRestrict=pRestrict->GetOrdNum();
522cdf0e10cSrcweir             if (nRestrict<nMax) nMax=nRestrict;
523cdf0e10cSrcweir         }
524cdf0e10cSrcweir         pRestrict=GetMaxToBtmObj(pObj);
525cdf0e10cSrcweir         if (pRestrict!=NULL) {
526cdf0e10cSrcweir             sal_uIntPtr nRestrict=pRestrict->GetOrdNum();
527cdf0e10cSrcweir             if (nRestrict>nMin) nMin=nRestrict;
528cdf0e10cSrcweir         }
529cdf0e10cSrcweir         bToTopPossible=nObjNum<sal_uIntPtr(nMax-1);
530cdf0e10cSrcweir         bToBtmPossible=nObjNum>nMin;
531cdf0e10cSrcweir     } else { // Mehrfachselektion
532cdf0e10cSrcweir         sal_uIntPtr nm=0;
533cdf0e10cSrcweir         SdrObjList* pOL0=NULL;
534cdf0e10cSrcweir         long nPos0=-1;
535cdf0e10cSrcweir         while (!bToBtmPossible && nm<nAnz) { // 'nach hinten' checken
536cdf0e10cSrcweir             SdrObject* pObj=GetMarkedObjectByIndex(nm);
537cdf0e10cSrcweir             SdrObjList* pOL=pObj->GetObjList();
538cdf0e10cSrcweir             if (pOL!=pOL0) {
539cdf0e10cSrcweir                 nPos0=-1;
540cdf0e10cSrcweir                 pOL0=pOL;
541cdf0e10cSrcweir             }
542cdf0e10cSrcweir             sal_uIntPtr nPos=pObj->GetOrdNum();
543cdf0e10cSrcweir             bToBtmPossible=nPos>sal_uIntPtr(nPos0+1);
544cdf0e10cSrcweir             nPos0=long(nPos);
545cdf0e10cSrcweir             nm++;
546cdf0e10cSrcweir         }
547cdf0e10cSrcweir         nm=nAnz;
548cdf0e10cSrcweir         pOL0=NULL;
549cdf0e10cSrcweir         nPos0=0x7FFFFFFF;
550cdf0e10cSrcweir         while (!bToTopPossible && nm>0) { // 'nach vorn' checken
551cdf0e10cSrcweir             nm--;
552cdf0e10cSrcweir             SdrObject* pObj=GetMarkedObjectByIndex(nm);
553cdf0e10cSrcweir             SdrObjList* pOL=pObj->GetObjList();
554cdf0e10cSrcweir             if (pOL!=pOL0) {
555cdf0e10cSrcweir                 nPos0=pOL->GetObjCount();
556cdf0e10cSrcweir                 pOL0=pOL;
557cdf0e10cSrcweir             }
558cdf0e10cSrcweir             sal_uIntPtr nPos=pObj->GetOrdNum();
559cdf0e10cSrcweir             bToTopPossible=nPos+1<sal_uIntPtr(nPos0);
560cdf0e10cSrcweir             nPos0=nPos;
561cdf0e10cSrcweir         }
562cdf0e10cSrcweir     }
563cdf0e10cSrcweir }
564cdf0e10cSrcweir 
565cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
566cdf0e10cSrcweir //
567cdf0e10cSrcweir //   @@@@    @@@@   @@   @@  @@@@@   @@  @@  @@  @@@@@
568cdf0e10cSrcweir //  @@  @@  @@  @@  @@@ @@@  @@  @@  @@  @@@ @@  @@
569cdf0e10cSrcweir //  @@      @@  @@  @@@@@@@  @@  @@  @@  @@@@@@  @@
570cdf0e10cSrcweir //  @@      @@  @@  @@@@@@@  @@@@@   @@  @@@@@@  @@@@
571cdf0e10cSrcweir //  @@      @@  @@  @@ @ @@  @@  @@  @@  @@ @@@  @@
572cdf0e10cSrcweir //  @@  @@  @@  @@  @@   @@  @@  @@  @@  @@  @@  @@
573cdf0e10cSrcweir //   @@@@    @@@@   @@   @@  @@@@@   @@  @@  @@  @@@@@
574cdf0e10cSrcweir //
575cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
576cdf0e10cSrcweir 
ImpCopyAttributes(const SdrObject * pSource,SdrObject * pDest) const577cdf0e10cSrcweir void SdrEditView::ImpCopyAttributes(const SdrObject* pSource, SdrObject* pDest) const
578cdf0e10cSrcweir {
579cdf0e10cSrcweir     if (pSource!=NULL) {
580cdf0e10cSrcweir         SdrObjList* pOL=pSource->GetSubList();
581cdf0e10cSrcweir         if (pOL!=NULL && !pSource->Is3DObj()) { // erstes Nichtgruppenobjekt aus der Gruppe holen
582cdf0e10cSrcweir             SdrObjListIter aIter(*pOL,IM_DEEPNOGROUPS);
583cdf0e10cSrcweir             pSource=aIter.Next();
584cdf0e10cSrcweir         }
585cdf0e10cSrcweir     }
586cdf0e10cSrcweir 
587cdf0e10cSrcweir     if(pSource && pDest)
588cdf0e10cSrcweir     {
589cdf0e10cSrcweir         SfxItemSet aSet(pMod->GetItemPool(),
590cdf0e10cSrcweir             SDRATTR_START,              SDRATTR_NOTPERSIST_FIRST-1,
591cdf0e10cSrcweir             SDRATTR_NOTPERSIST_LAST+1,  SDRATTR_END,
592cdf0e10cSrcweir             EE_ITEMS_START,             EE_ITEMS_END,
593cdf0e10cSrcweir             0, 0); // #52757#, #52762#
594cdf0e10cSrcweir 
595cdf0e10cSrcweir         aSet.Put(pSource->GetMergedItemSet());
596cdf0e10cSrcweir 
597cdf0e10cSrcweir         pDest->ClearMergedItem();
598cdf0e10cSrcweir         pDest->SetMergedItemSet(aSet);
599cdf0e10cSrcweir 
600cdf0e10cSrcweir         pDest->NbcSetLayer(pSource->GetLayer());
601cdf0e10cSrcweir         pDest->NbcSetStyleSheet(pSource->GetStyleSheet(), sal_True);
602cdf0e10cSrcweir     }
603cdf0e10cSrcweir }
604cdf0e10cSrcweir 
ImpCanConvertForCombine1(const SdrObject * pObj) const605cdf0e10cSrcweir sal_Bool SdrEditView::ImpCanConvertForCombine1(const SdrObject* pObj) const
606cdf0e10cSrcweir {
607cdf0e10cSrcweir     // #69711 : new condition IsLine() to be able to combine simple Lines
608cdf0e10cSrcweir     sal_Bool bIsLine(sal_False);
609cdf0e10cSrcweir 
610cdf0e10cSrcweir     const SdrPathObj* pPath = PTR_CAST(SdrPathObj,pObj);
611cdf0e10cSrcweir 
612cdf0e10cSrcweir     if(pPath)
613cdf0e10cSrcweir     {
614cdf0e10cSrcweir         bIsLine = pPath->IsLine();
615cdf0e10cSrcweir     }
616cdf0e10cSrcweir 
617cdf0e10cSrcweir     SdrObjTransformInfoRec aInfo;
618cdf0e10cSrcweir     pObj->TakeObjInfo(aInfo);
619cdf0e10cSrcweir 
620cdf0e10cSrcweir     return (aInfo.bCanConvToPath || aInfo.bCanConvToPoly || bIsLine);
621cdf0e10cSrcweir }
622cdf0e10cSrcweir 
ImpCanConvertForCombine(const SdrObject * pObj) const623cdf0e10cSrcweir sal_Bool SdrEditView::ImpCanConvertForCombine(const SdrObject* pObj) const
624cdf0e10cSrcweir {
625cdf0e10cSrcweir     SdrObjList* pOL = pObj->GetSubList();
626cdf0e10cSrcweir 
627cdf0e10cSrcweir     if(pOL && !pObj->Is3DObj())
628cdf0e10cSrcweir     {
629cdf0e10cSrcweir         SdrObjListIter aIter(*pOL, IM_DEEPNOGROUPS);
630cdf0e10cSrcweir 
631cdf0e10cSrcweir         while(aIter.IsMore())
632cdf0e10cSrcweir         {
633cdf0e10cSrcweir             SdrObject* pObj1 = aIter.Next();
634cdf0e10cSrcweir 
635cdf0e10cSrcweir             // Es muessen alle Member einer Gruppe konvertierbar sein
636cdf0e10cSrcweir             if(!ImpCanConvertForCombine1(pObj1))
637cdf0e10cSrcweir             {
638cdf0e10cSrcweir                 return sal_False;
639cdf0e10cSrcweir             }
640cdf0e10cSrcweir         }
641cdf0e10cSrcweir     }
642cdf0e10cSrcweir     else
643cdf0e10cSrcweir     {
644cdf0e10cSrcweir         if(!ImpCanConvertForCombine1(pObj))
645cdf0e10cSrcweir         {
646cdf0e10cSrcweir             return sal_False;
647cdf0e10cSrcweir         }
648cdf0e10cSrcweir     }
649cdf0e10cSrcweir 
650cdf0e10cSrcweir     return sal_True;
651cdf0e10cSrcweir }
652cdf0e10cSrcweir 
ImpGetPolyPolygon1(const SdrObject * pObj,sal_Bool bCombine) const653cdf0e10cSrcweir basegfx::B2DPolyPolygon SdrEditView::ImpGetPolyPolygon1(const SdrObject* pObj, sal_Bool bCombine) const
654cdf0e10cSrcweir {
655cdf0e10cSrcweir     basegfx::B2DPolyPolygon aRetval;
656cdf0e10cSrcweir     SdrPathObj* pPath = PTR_CAST(SdrPathObj, pObj);
657cdf0e10cSrcweir 
658cdf0e10cSrcweir     if(bCombine && pPath && !pObj->GetOutlinerParaObject())
659cdf0e10cSrcweir     {
660cdf0e10cSrcweir         aRetval = pPath->GetPathPoly();
661cdf0e10cSrcweir     }
662cdf0e10cSrcweir     else
663cdf0e10cSrcweir     {
664cdf0e10cSrcweir         SdrObject* pConvObj = pObj->ConvertToPolyObj(bCombine, sal_False);
665cdf0e10cSrcweir 
666cdf0e10cSrcweir         if(pConvObj)
667cdf0e10cSrcweir         {
668cdf0e10cSrcweir             SdrObjList* pOL = pConvObj->GetSubList();
669cdf0e10cSrcweir 
670cdf0e10cSrcweir             if(pOL)
671cdf0e10cSrcweir             {
672cdf0e10cSrcweir                 SdrObjListIter aIter(*pOL, IM_DEEPNOGROUPS);
673cdf0e10cSrcweir 
674cdf0e10cSrcweir                 while(aIter.IsMore())
675cdf0e10cSrcweir                 {
676cdf0e10cSrcweir                     SdrObject* pObj1 = aIter.Next();
677cdf0e10cSrcweir                     pPath = PTR_CAST(SdrPathObj, pObj1);
678cdf0e10cSrcweir 
679cdf0e10cSrcweir                     if(pPath)
680cdf0e10cSrcweir                     {
681cdf0e10cSrcweir                         aRetval.append(pPath->GetPathPoly());
682cdf0e10cSrcweir                     }
683cdf0e10cSrcweir                 }
684cdf0e10cSrcweir             }
685cdf0e10cSrcweir             else
686cdf0e10cSrcweir             {
687cdf0e10cSrcweir                 pPath = PTR_CAST(SdrPathObj, pConvObj);
688cdf0e10cSrcweir 
689cdf0e10cSrcweir                 if(pPath)
690cdf0e10cSrcweir                 {
691cdf0e10cSrcweir                     aRetval = pPath->GetPathPoly();
692cdf0e10cSrcweir                 }
693cdf0e10cSrcweir             }
694cdf0e10cSrcweir 
695cdf0e10cSrcweir             SdrObject::Free( pConvObj );
696cdf0e10cSrcweir         }
697cdf0e10cSrcweir     }
698cdf0e10cSrcweir 
699cdf0e10cSrcweir     return aRetval;
700cdf0e10cSrcweir }
701cdf0e10cSrcweir 
ImpGetPolyPolygon(const SdrObject * pObj,sal_Bool bCombine) const702cdf0e10cSrcweir basegfx::B2DPolyPolygon SdrEditView::ImpGetPolyPolygon(const SdrObject* pObj, sal_Bool bCombine) const
703cdf0e10cSrcweir {
704cdf0e10cSrcweir     SdrObjList* pOL = pObj->GetSubList();
705cdf0e10cSrcweir 
706cdf0e10cSrcweir     if(pOL && !pObj->Is3DObj())
707cdf0e10cSrcweir     {
708cdf0e10cSrcweir         basegfx::B2DPolyPolygon aRetval;
709cdf0e10cSrcweir         SdrObjListIter aIter(*pOL, IM_DEEPNOGROUPS);
710cdf0e10cSrcweir 
711cdf0e10cSrcweir         while(aIter.IsMore())
712cdf0e10cSrcweir         {
713cdf0e10cSrcweir             SdrObject* pObj1 = aIter.Next();
714cdf0e10cSrcweir             aRetval.append(ImpGetPolyPolygon1(pObj1, bCombine));
715cdf0e10cSrcweir         }
716cdf0e10cSrcweir 
717cdf0e10cSrcweir         return aRetval;
718cdf0e10cSrcweir     }
719cdf0e10cSrcweir     else
720cdf0e10cSrcweir     {
721cdf0e10cSrcweir         return ImpGetPolyPolygon1(pObj, bCombine);
722cdf0e10cSrcweir     }
723cdf0e10cSrcweir }
724cdf0e10cSrcweir 
ImpCombineToSinglePolygon(const basegfx::B2DPolyPolygon & rPolyPolygon) const725cdf0e10cSrcweir basegfx::B2DPolygon SdrEditView::ImpCombineToSinglePolygon(const basegfx::B2DPolyPolygon& rPolyPolygon) const
726cdf0e10cSrcweir {
727cdf0e10cSrcweir     const sal_uInt32 nPolyCount(rPolyPolygon.count());
728cdf0e10cSrcweir 
729cdf0e10cSrcweir     if(0L == nPolyCount)
730cdf0e10cSrcweir     {
731cdf0e10cSrcweir         return basegfx::B2DPolygon();
732cdf0e10cSrcweir     }
733cdf0e10cSrcweir     else if(1L == nPolyCount)
734cdf0e10cSrcweir     {
735cdf0e10cSrcweir         return rPolyPolygon.getB2DPolygon(0L);
736cdf0e10cSrcweir     }
737cdf0e10cSrcweir     else
738cdf0e10cSrcweir     {
739cdf0e10cSrcweir         basegfx::B2DPolygon aRetval(rPolyPolygon.getB2DPolygon(0L));
740cdf0e10cSrcweir 
741cdf0e10cSrcweir         for(sal_uInt32 a(1L); a < nPolyCount; a++)
742cdf0e10cSrcweir         {
743cdf0e10cSrcweir             basegfx::B2DPolygon aCandidate(rPolyPolygon.getB2DPolygon(a));
744cdf0e10cSrcweir 
745cdf0e10cSrcweir             if(aRetval.count())
746cdf0e10cSrcweir             {
747cdf0e10cSrcweir                 if(aCandidate.count())
748cdf0e10cSrcweir                 {
749cdf0e10cSrcweir                     const basegfx::B2DPoint aCA(aCandidate.getB2DPoint(0L));
750cdf0e10cSrcweir                     const basegfx::B2DPoint aCB(aCandidate.getB2DPoint(aCandidate.count() - 1L));
751cdf0e10cSrcweir                     const basegfx::B2DPoint aRA(aRetval.getB2DPoint(0L));
752cdf0e10cSrcweir                     const basegfx::B2DPoint aRB(aRetval.getB2DPoint(aRetval.count() - 1L));
753cdf0e10cSrcweir 
754cdf0e10cSrcweir                     const double fRACA(basegfx::B2DVector(aCA - aRA).getLength());
755cdf0e10cSrcweir                     const double fRACB(basegfx::B2DVector(aCB - aRA).getLength());
756cdf0e10cSrcweir                     const double fRBCA(basegfx::B2DVector(aCA - aRB).getLength());
757cdf0e10cSrcweir                     const double fRBCB(basegfx::B2DVector(aCB - aRB).getLength());
758cdf0e10cSrcweir 
759cdf0e10cSrcweir                     const double fSmallestRA(fRACA < fRACB ? fRACA : fRACB);
760cdf0e10cSrcweir                     const double fSmallestRB(fRBCA < fRBCB ? fRBCA : fRBCB);
761cdf0e10cSrcweir 
762cdf0e10cSrcweir                     if(fSmallestRA < fSmallestRB)
763cdf0e10cSrcweir                     {
764cdf0e10cSrcweir                         // flip result
765cdf0e10cSrcweir                         aRetval.flip();
766cdf0e10cSrcweir                     }
767cdf0e10cSrcweir 
768cdf0e10cSrcweir                     const double fSmallestCA(fRACA < fRBCA ? fRACA : fRBCA);
769cdf0e10cSrcweir                     const double fSmallestCB(fRACB < fRBCB ? fRACB : fRBCB);
770cdf0e10cSrcweir 
771cdf0e10cSrcweir                     if(fSmallestCB < fSmallestCA)
772cdf0e10cSrcweir                     {
773cdf0e10cSrcweir                         // flip candidate
774cdf0e10cSrcweir                         aCandidate.flip();
775cdf0e10cSrcweir                     }
776cdf0e10cSrcweir 
777cdf0e10cSrcweir                     // append candidate to retval
778cdf0e10cSrcweir                     aRetval.append(aCandidate);
779cdf0e10cSrcweir                 }
780cdf0e10cSrcweir             }
781cdf0e10cSrcweir             else
782cdf0e10cSrcweir             {
783cdf0e10cSrcweir                 aRetval = aCandidate;
784cdf0e10cSrcweir             }
785cdf0e10cSrcweir         }
786cdf0e10cSrcweir 
787cdf0e10cSrcweir         return aRetval;
788cdf0e10cSrcweir     }
789cdf0e10cSrcweir }
790cdf0e10cSrcweir 
791cdf0e10cSrcweir // for distribution dialog function
792cdf0e10cSrcweir struct ImpDistributeEntry
793cdf0e10cSrcweir {
794cdf0e10cSrcweir     SdrObject*                  mpObj;
795cdf0e10cSrcweir     sal_Int32                       mnPos;
796cdf0e10cSrcweir     sal_Int32                       mnLength;
797cdf0e10cSrcweir };
798cdf0e10cSrcweir 
DECLARE_LIST(ImpDistributeEntryList,ImpDistributeEntry *)799cdf0e10cSrcweir DECLARE_LIST(ImpDistributeEntryList, ImpDistributeEntry*)
800cdf0e10cSrcweir 
801cdf0e10cSrcweir void SdrEditView::DistributeMarkedObjects()
802cdf0e10cSrcweir {
803cdf0e10cSrcweir     sal_uInt32 nMark(GetMarkedObjectCount());
804cdf0e10cSrcweir 
805cdf0e10cSrcweir     if(nMark > 2)
806cdf0e10cSrcweir     {
807cdf0e10cSrcweir         SfxItemSet aNewAttr(pMod->GetItemPool());
808cdf0e10cSrcweir         //CHINA001 SvxDistributeDialog* pDlg = new SvxDistributeDialog(NULL, aNewAttr);
809cdf0e10cSrcweir         SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
810cdf0e10cSrcweir         if(pFact)
811cdf0e10cSrcweir         {
812cdf0e10cSrcweir             AbstractSvxDistributeDialog *pDlg = pFact->CreateSvxDistributeDialog(NULL, aNewAttr);
813cdf0e10cSrcweir             DBG_ASSERT(pDlg, "Dialogdiet fail!");//CHINA001
814cdf0e10cSrcweir 
815cdf0e10cSrcweir             sal_uInt16 nResult = pDlg->Execute();
816cdf0e10cSrcweir 
817cdf0e10cSrcweir             if(nResult == RET_OK)
818cdf0e10cSrcweir             {
819cdf0e10cSrcweir                 SvxDistributeHorizontal eHor = pDlg->GetDistributeHor();
820cdf0e10cSrcweir                 SvxDistributeVertical eVer = pDlg->GetDistributeVer();
821cdf0e10cSrcweir                 ImpDistributeEntryList aEntryList;
822cdf0e10cSrcweir                 sal_uInt32 a, nInsPos, nFullLength;
823cdf0e10cSrcweir 
824cdf0e10cSrcweir                 const bool bUndo = IsUndoEnabled();
825cdf0e10cSrcweir                 if( bUndo )
826cdf0e10cSrcweir                     BegUndo();
827cdf0e10cSrcweir 
828cdf0e10cSrcweir                 if(eHor != SvxDistributeHorizontalNone)
829cdf0e10cSrcweir                 {
830cdf0e10cSrcweir                     // build sorted entry list
831cdf0e10cSrcweir                     nFullLength = 0L;
832cdf0e10cSrcweir 
833cdf0e10cSrcweir                     for(a=0;a<nMark;a++)
834cdf0e10cSrcweir                     {
835cdf0e10cSrcweir                         SdrMark* pMark = GetSdrMarkByIndex(a);
836cdf0e10cSrcweir                         ImpDistributeEntry* pNew = new ImpDistributeEntry;
837cdf0e10cSrcweir 
838cdf0e10cSrcweir                         pNew->mpObj = pMark->GetMarkedSdrObj();
839cdf0e10cSrcweir                         nInsPos = 0;
840cdf0e10cSrcweir 
841cdf0e10cSrcweir                         switch(eHor)
842cdf0e10cSrcweir                         {
843cdf0e10cSrcweir                             case SvxDistributeHorizontalLeft:
844cdf0e10cSrcweir                             {
845cdf0e10cSrcweir                                 pNew->mnPos = pNew->mpObj->GetSnapRect().Left();
846cdf0e10cSrcweir                                 break;
847cdf0e10cSrcweir                             }
848cdf0e10cSrcweir                             case SvxDistributeHorizontalCenter:
849cdf0e10cSrcweir                             {
850cdf0e10cSrcweir                                 pNew->mnPos = (pNew->mpObj->GetSnapRect().Right() + pNew->mpObj->GetSnapRect().Left()) / 2;
851cdf0e10cSrcweir                                 break;
852cdf0e10cSrcweir                             }
853cdf0e10cSrcweir                             case SvxDistributeHorizontalDistance:
854cdf0e10cSrcweir                             {
855cdf0e10cSrcweir                                 pNew->mnLength = pNew->mpObj->GetSnapRect().GetWidth() + 1;
856cdf0e10cSrcweir                                 nFullLength += pNew->mnLength;
857cdf0e10cSrcweir                                 pNew->mnPos = (pNew->mpObj->GetSnapRect().Right() + pNew->mpObj->GetSnapRect().Left()) / 2;
858cdf0e10cSrcweir                                 break;
859cdf0e10cSrcweir                             }
860cdf0e10cSrcweir                             case SvxDistributeHorizontalRight:
861cdf0e10cSrcweir                             {
862cdf0e10cSrcweir                                 pNew->mnPos = pNew->mpObj->GetSnapRect().Right();
863cdf0e10cSrcweir                                 break;
864cdf0e10cSrcweir                             }
865cdf0e10cSrcweir                             default: break;
866cdf0e10cSrcweir                         }
867cdf0e10cSrcweir 
868cdf0e10cSrcweir                         while(nInsPos < aEntryList.Count() && aEntryList.GetObject(nInsPos)->mnPos < pNew->mnPos)
869cdf0e10cSrcweir                             nInsPos++;
870cdf0e10cSrcweir 
871cdf0e10cSrcweir                         aEntryList.Insert(pNew, nInsPos);
872cdf0e10cSrcweir                     }
873cdf0e10cSrcweir 
874cdf0e10cSrcweir                     if(eHor == SvxDistributeHorizontalDistance)
875cdf0e10cSrcweir                     {
876cdf0e10cSrcweir                         // calc room in-between
877cdf0e10cSrcweir                         sal_Int32 nWidth = GetAllMarkedBoundRect().GetWidth() + 1;
878cdf0e10cSrcweir                         double fStepWidth = ((double)nWidth - (double)nFullLength) / (double)(aEntryList.Count() - 1);
879cdf0e10cSrcweir                         double fStepStart = (double)aEntryList.GetObject(0)->mnPos;
880cdf0e10cSrcweir                         fStepStart += fStepWidth + (double)((aEntryList.GetObject(0)->mnLength + aEntryList.GetObject(1)->mnLength) / 2);
881cdf0e10cSrcweir 
882cdf0e10cSrcweir                         // move entries 1..n-1
883cdf0e10cSrcweir                         for(a=1;a<aEntryList.Count()-1;a++)
884cdf0e10cSrcweir                         {
885cdf0e10cSrcweir                             ImpDistributeEntry* pCurr = aEntryList.GetObject(a);
886cdf0e10cSrcweir                             ImpDistributeEntry* pNext = aEntryList.GetObject(a+1);
887cdf0e10cSrcweir                             sal_Int32 nDelta = (sal_Int32)(fStepStart + 0.5) - pCurr->mnPos;
888cdf0e10cSrcweir                             if( bUndo )
889cdf0e10cSrcweir                                 AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pCurr->mpObj));
890cdf0e10cSrcweir                             pCurr->mpObj->Move(Size(nDelta, 0));
891cdf0e10cSrcweir                             fStepStart += fStepWidth + (double)((pCurr->mnLength + pNext->mnLength) / 2);
892cdf0e10cSrcweir                         }
893cdf0e10cSrcweir                     }
894cdf0e10cSrcweir                     else
895cdf0e10cSrcweir                     {
896cdf0e10cSrcweir                         // calc distances
897cdf0e10cSrcweir                         sal_Int32 nWidth = aEntryList.GetObject(aEntryList.Count() - 1)->mnPos - aEntryList.GetObject(0)->mnPos;
898cdf0e10cSrcweir                         double fStepWidth = (double)nWidth / (double)(aEntryList.Count() - 1);
899cdf0e10cSrcweir                         double fStepStart = (double)aEntryList.GetObject(0)->mnPos;
900cdf0e10cSrcweir                         fStepStart += fStepWidth;
901cdf0e10cSrcweir 
902cdf0e10cSrcweir                         // move entries 1..n-1
903cdf0e10cSrcweir                         for(a=1;a<aEntryList.Count()-1;a++)
904cdf0e10cSrcweir                         {
905cdf0e10cSrcweir                             ImpDistributeEntry* pCurr = aEntryList.GetObject(a);
906cdf0e10cSrcweir                             sal_Int32 nDelta = (sal_Int32)(fStepStart + 0.5) - pCurr->mnPos;
907cdf0e10cSrcweir                             if( bUndo )
908cdf0e10cSrcweir                                 AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pCurr->mpObj));
909cdf0e10cSrcweir                             pCurr->mpObj->Move(Size(nDelta, 0));
910cdf0e10cSrcweir                             fStepStart += fStepWidth;
911cdf0e10cSrcweir                         }
912cdf0e10cSrcweir                     }
913cdf0e10cSrcweir 
914cdf0e10cSrcweir                     // clear list
915cdf0e10cSrcweir                     while(aEntryList.Count())
916cdf0e10cSrcweir                         delete aEntryList.Remove((sal_uIntPtr)0L);
917cdf0e10cSrcweir                 }
918cdf0e10cSrcweir 
919cdf0e10cSrcweir                 if(eVer != SvxDistributeVerticalNone)
920cdf0e10cSrcweir                 {
921cdf0e10cSrcweir                     // build sorted entry list
922cdf0e10cSrcweir                     nFullLength = 0L;
923cdf0e10cSrcweir 
924cdf0e10cSrcweir                     for(a=0;a<nMark;a++)
925cdf0e10cSrcweir                     {
926cdf0e10cSrcweir                         SdrMark* pMark = GetSdrMarkByIndex(a);
927cdf0e10cSrcweir                         ImpDistributeEntry* pNew = new ImpDistributeEntry;
928cdf0e10cSrcweir 
929cdf0e10cSrcweir                         pNew->mpObj = pMark->GetMarkedSdrObj();
930cdf0e10cSrcweir                         nInsPos = 0;
931cdf0e10cSrcweir 
932cdf0e10cSrcweir                         switch(eVer)
933cdf0e10cSrcweir                         {
934cdf0e10cSrcweir                             case SvxDistributeVerticalTop:
935cdf0e10cSrcweir                             {
936cdf0e10cSrcweir                                 pNew->mnPos = pNew->mpObj->GetSnapRect().Top();
937cdf0e10cSrcweir                                 break;
938cdf0e10cSrcweir                             }
939cdf0e10cSrcweir                             case SvxDistributeVerticalCenter:
940cdf0e10cSrcweir                             {
941cdf0e10cSrcweir                                 pNew->mnPos = (pNew->mpObj->GetSnapRect().Bottom() + pNew->mpObj->GetSnapRect().Top()) / 2;
942cdf0e10cSrcweir                                 break;
943cdf0e10cSrcweir                             }
944cdf0e10cSrcweir                             case SvxDistributeVerticalDistance:
945cdf0e10cSrcweir                             {
946cdf0e10cSrcweir                                 pNew->mnLength = pNew->mpObj->GetSnapRect().GetHeight() + 1;
947cdf0e10cSrcweir                                 nFullLength += pNew->mnLength;
948cdf0e10cSrcweir                                 pNew->mnPos = (pNew->mpObj->GetSnapRect().Bottom() + pNew->mpObj->GetSnapRect().Top()) / 2;
949cdf0e10cSrcweir                                 break;
950cdf0e10cSrcweir                             }
951cdf0e10cSrcweir                             case SvxDistributeVerticalBottom:
952cdf0e10cSrcweir                             {
953cdf0e10cSrcweir                                 pNew->mnPos = pNew->mpObj->GetSnapRect().Bottom();
954cdf0e10cSrcweir                                 break;
955cdf0e10cSrcweir                             }
956cdf0e10cSrcweir                             default: break;
957cdf0e10cSrcweir                         }
958cdf0e10cSrcweir 
959cdf0e10cSrcweir                         while(nInsPos < aEntryList.Count() && aEntryList.GetObject(nInsPos)->mnPos < pNew->mnPos)
960cdf0e10cSrcweir                             nInsPos++;
961cdf0e10cSrcweir 
962cdf0e10cSrcweir                         aEntryList.Insert(pNew, nInsPos);
963cdf0e10cSrcweir                     }
964cdf0e10cSrcweir 
965cdf0e10cSrcweir                     if(eVer == SvxDistributeVerticalDistance)
966cdf0e10cSrcweir                     {
967cdf0e10cSrcweir                         // calc room in-between
968cdf0e10cSrcweir                         sal_Int32 nHeight = GetAllMarkedBoundRect().GetHeight() + 1;
969cdf0e10cSrcweir                         double fStepWidth = ((double)nHeight - (double)nFullLength) / (double)(aEntryList.Count() - 1);
970cdf0e10cSrcweir                         double fStepStart = (double)aEntryList.GetObject(0)->mnPos;
971cdf0e10cSrcweir                         fStepStart += fStepWidth + (double)((aEntryList.GetObject(0)->mnLength + aEntryList.GetObject(1)->mnLength) / 2);
972cdf0e10cSrcweir 
973cdf0e10cSrcweir                         // move entries 1..n-1
974cdf0e10cSrcweir                         for(a=1;a<aEntryList.Count()-1;a++)
975cdf0e10cSrcweir                         {
976cdf0e10cSrcweir                             ImpDistributeEntry* pCurr = aEntryList.GetObject(a);
977cdf0e10cSrcweir                             ImpDistributeEntry* pNext = aEntryList.GetObject(a+1);
978cdf0e10cSrcweir                             sal_Int32 nDelta = (sal_Int32)(fStepStart + 0.5) - pCurr->mnPos;
979cdf0e10cSrcweir                             if( bUndo )
980cdf0e10cSrcweir                                 AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pCurr->mpObj));
981cdf0e10cSrcweir                             pCurr->mpObj->Move(Size(0, nDelta));
982cdf0e10cSrcweir                             fStepStart += fStepWidth + (double)((pCurr->mnLength + pNext->mnLength) / 2);
983cdf0e10cSrcweir                         }
984cdf0e10cSrcweir                     }
985cdf0e10cSrcweir                     else
986cdf0e10cSrcweir                     {
987cdf0e10cSrcweir                         // calc distances
988cdf0e10cSrcweir                         sal_Int32 nHeight = aEntryList.GetObject(aEntryList.Count() - 1)->mnPos - aEntryList.GetObject(0)->mnPos;
989cdf0e10cSrcweir                         double fStepWidth = (double)nHeight / (double)(aEntryList.Count() - 1);
990cdf0e10cSrcweir                         double fStepStart = (double)aEntryList.GetObject(0)->mnPos;
991cdf0e10cSrcweir                         fStepStart += fStepWidth;
992cdf0e10cSrcweir 
993cdf0e10cSrcweir                         // move entries 1..n-1
994cdf0e10cSrcweir                         for(a=1;a<aEntryList.Count()-1;a++)
995cdf0e10cSrcweir                         {
996cdf0e10cSrcweir                             ImpDistributeEntry* pCurr = aEntryList.GetObject(a);
997cdf0e10cSrcweir                             sal_Int32 nDelta = (sal_Int32)(fStepStart + 0.5) - pCurr->mnPos;
998cdf0e10cSrcweir                             if( bUndo )
999cdf0e10cSrcweir                                 AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pCurr->mpObj));
1000cdf0e10cSrcweir                             pCurr->mpObj->Move(Size(0, nDelta));
1001cdf0e10cSrcweir                             fStepStart += fStepWidth;
1002cdf0e10cSrcweir                         }
1003cdf0e10cSrcweir                     }
1004cdf0e10cSrcweir 
1005cdf0e10cSrcweir                     // clear list
1006cdf0e10cSrcweir                     while(aEntryList.Count())
1007cdf0e10cSrcweir                         delete aEntryList.Remove((sal_uIntPtr)0L);
1008cdf0e10cSrcweir                 }
1009cdf0e10cSrcweir 
1010cdf0e10cSrcweir                 // UNDO-Comment and end of UNDO
1011cdf0e10cSrcweir                 SetUndoComment(ImpGetResStr(STR_DistributeMarkedObjects));
1012cdf0e10cSrcweir 
1013cdf0e10cSrcweir                 if( bUndo )
1014cdf0e10cSrcweir                     EndUndo();
1015cdf0e10cSrcweir             }
1016cdf0e10cSrcweir 
1017cdf0e10cSrcweir             delete(pDlg);
1018cdf0e10cSrcweir         }
1019cdf0e10cSrcweir     }
1020cdf0e10cSrcweir }
1021cdf0e10cSrcweir 
MergeMarkedObjects(SdrMergeMode eMode)1022cdf0e10cSrcweir void SdrEditView::MergeMarkedObjects(SdrMergeMode eMode)
1023cdf0e10cSrcweir {
1024cdf0e10cSrcweir     // #i73441# check content
1025cdf0e10cSrcweir     if(AreObjectsMarked())
1026cdf0e10cSrcweir     {
1027cdf0e10cSrcweir         SdrMarkList aRemove;
1028cdf0e10cSrcweir         SortMarkedObjects();
1029cdf0e10cSrcweir 
1030cdf0e10cSrcweir         const bool bUndo = IsUndoEnabled();
1031cdf0e10cSrcweir 
1032cdf0e10cSrcweir         if( bUndo )
1033cdf0e10cSrcweir             BegUndo();
1034cdf0e10cSrcweir 
1035cdf0e10cSrcweir         sal_uInt32 nInsPos=0xFFFFFFFF;
1036cdf0e10cSrcweir         const SdrObject* pAttrObj = NULL;
1037cdf0e10cSrcweir         basegfx::B2DPolyPolygon aMergePolyPolygonA;
1038cdf0e10cSrcweir         basegfx::B2DPolyPolygon aMergePolyPolygonB;
1039cdf0e10cSrcweir 
1040cdf0e10cSrcweir         SdrObjList* pInsOL = NULL;
1041cdf0e10cSrcweir         SdrPageView* pInsPV = NULL;
1042cdf0e10cSrcweir         sal_Bool bFirstObjectComplete(sal_False);
1043cdf0e10cSrcweir 
1044cdf0e10cSrcweir         // make sure selected objects are contour objects
1045cdf0e10cSrcweir         // since now basegfx::tools::adaptiveSubdivide() is used, it is no longer
1046cdf0e10cSrcweir         // necessary to use ConvertMarkedToPolyObj which will subdivide curves using the old
1047cdf0e10cSrcweir         // mechanisms. In a next step the polygon clipper will even be able to clip curves...
1048cdf0e10cSrcweir         // ConvertMarkedToPolyObj(sal_True);
1049cdf0e10cSrcweir         ConvertMarkedToPathObj(sal_True);
1050cdf0e10cSrcweir         OSL_ENSURE(AreObjectsMarked(), "no more objects selected after preparations (!)");
1051cdf0e10cSrcweir 
1052cdf0e10cSrcweir         for(sal_uInt32 a=0;a<GetMarkedObjectCount();a++)
1053cdf0e10cSrcweir         {
1054cdf0e10cSrcweir             SdrMark* pM = GetSdrMarkByIndex(a);
1055cdf0e10cSrcweir             SdrObject* pObj = pM->GetMarkedSdrObj();
1056cdf0e10cSrcweir 
1057cdf0e10cSrcweir             if(ImpCanConvertForCombine(pObj))
1058cdf0e10cSrcweir             {
1059cdf0e10cSrcweir                 if(!pAttrObj)
1060cdf0e10cSrcweir                     pAttrObj = pObj;
1061cdf0e10cSrcweir 
1062cdf0e10cSrcweir                 nInsPos = pObj->GetOrdNum() + 1;
1063cdf0e10cSrcweir                 pInsPV = pM->GetPageView();
1064cdf0e10cSrcweir                 pInsOL = pObj->GetObjList();
1065cdf0e10cSrcweir 
1066*86e1cf34SPedro Giffuni                 // #i76891# use single iter from SJ here which works on SdrObjects and takes
1067cdf0e10cSrcweir                 // groups into account by itself
1068cdf0e10cSrcweir                 SdrObjListIter aIter(*pObj, IM_DEEPWITHGROUPS);
1069cdf0e10cSrcweir 
1070cdf0e10cSrcweir                 while(aIter.IsMore())
1071cdf0e10cSrcweir                 {
1072cdf0e10cSrcweir                     SdrObject* pCandidate = aIter.Next();
1073cdf0e10cSrcweir                     SdrPathObj* pPathObj = PTR_CAST(SdrPathObj, pCandidate);
1074cdf0e10cSrcweir                     if(pPathObj)
1075cdf0e10cSrcweir                     {
1076cdf0e10cSrcweir                         basegfx::B2DPolyPolygon aTmpPoly(pPathObj->GetPathPoly());
1077cdf0e10cSrcweir 
1078cdf0e10cSrcweir                         // #i76891# unfortunately ConvertMarkedToPathObj has converted all
1079cdf0e10cSrcweir                         // involved polygon data to curve segments, even if not necessary.
1080cdf0e10cSrcweir                         // It is better to try to reduce to more simple polygons.
1081cdf0e10cSrcweir                         aTmpPoly = basegfx::tools::simplifyCurveSegments(aTmpPoly);
1082cdf0e10cSrcweir 
1083cdf0e10cSrcweir                         // for each part polygon as preparation, remove self-intersections
1084cdf0e10cSrcweir                         // correct orientations and get rid of evtl. neutral polygons.
1085cdf0e10cSrcweir                         aTmpPoly = basegfx::tools::prepareForPolygonOperation(aTmpPoly);
1086cdf0e10cSrcweir 
1087cdf0e10cSrcweir                         if(!bFirstObjectComplete)
1088cdf0e10cSrcweir                         {
1089cdf0e10cSrcweir                             // #i111987# Also need to collect ORed source shape when more than
1090cdf0e10cSrcweir                             // a single polygon is involved
1091cdf0e10cSrcweir                             if(aMergePolyPolygonA.count())
1092cdf0e10cSrcweir                             {
1093cdf0e10cSrcweir                                 aMergePolyPolygonA = basegfx::tools::solvePolygonOperationOr(aMergePolyPolygonA, aTmpPoly);
1094cdf0e10cSrcweir                             }
1095cdf0e10cSrcweir                             else
1096cdf0e10cSrcweir                             {
1097cdf0e10cSrcweir                                 aMergePolyPolygonA = aTmpPoly;
1098cdf0e10cSrcweir                             }
1099cdf0e10cSrcweir                         }
1100cdf0e10cSrcweir                         else
1101cdf0e10cSrcweir                         {
1102cdf0e10cSrcweir                             if(aMergePolyPolygonB.count())
1103cdf0e10cSrcweir                             {
1104cdf0e10cSrcweir                                 // to topologically correctly collect the 2nd polygon
1105cdf0e10cSrcweir                                 // group it is necessary to OR the parts (each is seen as
1106cdf0e10cSrcweir                                 // XOR-FillRule polygon and they are drawn over each-other)
1107cdf0e10cSrcweir                                 aMergePolyPolygonB = basegfx::tools::solvePolygonOperationOr(aMergePolyPolygonB, aTmpPoly);
1108cdf0e10cSrcweir                             }
1109cdf0e10cSrcweir                             else
1110cdf0e10cSrcweir                             {
1111cdf0e10cSrcweir                                 aMergePolyPolygonB = aTmpPoly;
1112cdf0e10cSrcweir                             }
1113cdf0e10cSrcweir                         }
1114cdf0e10cSrcweir                     }
1115cdf0e10cSrcweir                 }
1116cdf0e10cSrcweir 
1117cdf0e10cSrcweir                 // was there something added to the first poly?
1118cdf0e10cSrcweir                 if(!bFirstObjectComplete && aMergePolyPolygonA.count())
1119cdf0e10cSrcweir                 {
1120cdf0e10cSrcweir                     bFirstObjectComplete = sal_True;
1121cdf0e10cSrcweir                 }
1122cdf0e10cSrcweir 
1123cdf0e10cSrcweir                 // move object to temporary delete list
1124cdf0e10cSrcweir                 aRemove.InsertEntry(SdrMark(pObj, pM->GetPageView()));
1125cdf0e10cSrcweir             }
1126cdf0e10cSrcweir         }
1127cdf0e10cSrcweir 
1128cdf0e10cSrcweir         switch(eMode)
1129cdf0e10cSrcweir         {
1130cdf0e10cSrcweir             case SDR_MERGE_MERGE:
1131cdf0e10cSrcweir             {
1132cdf0e10cSrcweir                 // merge all contained parts (OR)
1133cdf0e10cSrcweir                 static bool bTestXOR(false);
1134cdf0e10cSrcweir                 if(bTestXOR)
1135cdf0e10cSrcweir                 {
1136cdf0e10cSrcweir                     aMergePolyPolygonA = basegfx::tools::solvePolygonOperationXor(aMergePolyPolygonA, aMergePolyPolygonB);
1137cdf0e10cSrcweir                 }
1138cdf0e10cSrcweir                 else
1139cdf0e10cSrcweir                 {
1140cdf0e10cSrcweir                     aMergePolyPolygonA = basegfx::tools::solvePolygonOperationOr(aMergePolyPolygonA, aMergePolyPolygonB);
1141cdf0e10cSrcweir                 }
1142cdf0e10cSrcweir                 break;
1143cdf0e10cSrcweir             }
1144cdf0e10cSrcweir             case SDR_MERGE_SUBSTRACT:
1145cdf0e10cSrcweir             {
1146cdf0e10cSrcweir                 // Substract B from A
1147cdf0e10cSrcweir                 aMergePolyPolygonA = basegfx::tools::solvePolygonOperationDiff(aMergePolyPolygonA, aMergePolyPolygonB);
1148cdf0e10cSrcweir                 break;
1149cdf0e10cSrcweir             }
1150cdf0e10cSrcweir             case SDR_MERGE_INTERSECT:
1151cdf0e10cSrcweir             {
1152cdf0e10cSrcweir                 // AND B and A
1153cdf0e10cSrcweir                 aMergePolyPolygonA = basegfx::tools::solvePolygonOperationAnd(aMergePolyPolygonA, aMergePolyPolygonB);
1154cdf0e10cSrcweir                 break;
1155cdf0e10cSrcweir             }
1156cdf0e10cSrcweir         }
1157cdf0e10cSrcweir 
1158cdf0e10cSrcweir         // #i73441# check insert list before taking actions
1159cdf0e10cSrcweir         if(pInsOL)
1160cdf0e10cSrcweir         {
1161cdf0e10cSrcweir             SdrPathObj* pPath = new SdrPathObj(OBJ_PATHFILL, aMergePolyPolygonA);
1162cdf0e10cSrcweir             ImpCopyAttributes(pAttrObj, pPath);
1163cdf0e10cSrcweir             SdrInsertReason aReason(SDRREASON_VIEWCALL, pAttrObj);
1164cdf0e10cSrcweir             pInsOL->InsertObject(pPath, nInsPos, &aReason);
1165cdf0e10cSrcweir             if( bUndo )
1166cdf0e10cSrcweir                 AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pPath));
116778590b6cSArmin Le Grand 
116878590b6cSArmin Le Grand             // #124760# To have a correct selection with only the new object it is necessary to
116978590b6cSArmin Le Grand             // unmark all objects first. If not doing so, there may remain invalid pointers to objects
117078590b6cSArmin Le Grand             //TTTT:Not needed for aw080 (!)
117178590b6cSArmin Le Grand             UnmarkAllObj(pInsPV);
117278590b6cSArmin Le Grand 
1173cdf0e10cSrcweir             MarkObj(pPath, pInsPV, sal_False, sal_True);
1174cdf0e10cSrcweir         }
1175cdf0e10cSrcweir 
1176cdf0e10cSrcweir         aRemove.ForceSort();
1177cdf0e10cSrcweir         switch(eMode)
1178cdf0e10cSrcweir         {
1179cdf0e10cSrcweir             case SDR_MERGE_MERGE:
1180cdf0e10cSrcweir             {
1181cdf0e10cSrcweir                 SetUndoComment(
1182cdf0e10cSrcweir                     ImpGetResStr(STR_EditMergeMergePoly),
1183cdf0e10cSrcweir                     aRemove.GetMarkDescription());
1184cdf0e10cSrcweir                 break;
1185cdf0e10cSrcweir             }
1186cdf0e10cSrcweir             case SDR_MERGE_SUBSTRACT:
1187cdf0e10cSrcweir             {
1188cdf0e10cSrcweir                 SetUndoComment(
1189cdf0e10cSrcweir                     ImpGetResStr(STR_EditMergeSubstractPoly),
1190cdf0e10cSrcweir                     aRemove.GetMarkDescription());
1191cdf0e10cSrcweir                 break;
1192cdf0e10cSrcweir             }
1193cdf0e10cSrcweir             case SDR_MERGE_INTERSECT:
1194cdf0e10cSrcweir             {
1195cdf0e10cSrcweir                 SetUndoComment(
1196cdf0e10cSrcweir                     ImpGetResStr(STR_EditMergeIntersectPoly),
1197cdf0e10cSrcweir                     aRemove.GetMarkDescription());
1198cdf0e10cSrcweir                 break;
1199cdf0e10cSrcweir             }
1200cdf0e10cSrcweir         }
1201cdf0e10cSrcweir         DeleteMarkedList(aRemove);
1202cdf0e10cSrcweir 
1203cdf0e10cSrcweir         if( bUndo )
1204cdf0e10cSrcweir             EndUndo();
1205cdf0e10cSrcweir     }
1206cdf0e10cSrcweir }
1207cdf0e10cSrcweir 
CombineMarkedObjects(sal_Bool bNoPolyPoly)1208cdf0e10cSrcweir void SdrEditView::CombineMarkedObjects(sal_Bool bNoPolyPoly)
1209cdf0e10cSrcweir {
1210cdf0e10cSrcweir     // #105899# Start of Combine-Undo put to front, else ConvertMarkedToPolyObj would
1211cdf0e10cSrcweir     // create a 2nd Undo-action and Undo-Comment.
1212cdf0e10cSrcweir 
1213cdf0e10cSrcweir     bool bUndo = IsUndoEnabled();
1214cdf0e10cSrcweir 
1215cdf0e10cSrcweir     // Undo-String will be set later
1216cdf0e10cSrcweir     if( bUndo )
1217cdf0e10cSrcweir         BegUndo(String(), String(), bNoPolyPoly ? SDRREPFUNC_OBJ_COMBINE_ONEPOLY : SDRREPFUNC_OBJ_COMBINE_POLYPOLY);
1218cdf0e10cSrcweir 
1219cdf0e10cSrcweir     // #105899# First, guarantee that all objects are converted to polyobjects,
1220cdf0e10cSrcweir     // especially for SdrGrafObj with bitmap filling this is necessary to not
1221cdf0e10cSrcweir     // loose the bitmap filling.
1222cdf0e10cSrcweir 
1223cdf0e10cSrcweir     // #i12392#
1224cdf0e10cSrcweir     // ConvertMarkedToPolyObj was too strong here, it will loose quality and
1225cdf0e10cSrcweir     // information when curve objects are combined. This can be replaced by
1226cdf0e10cSrcweir     // using ConvertMarkedToPathObj without changing the previous fix.
1227cdf0e10cSrcweir 
1228cdf0e10cSrcweir     // #i21250#
1229cdf0e10cSrcweir     // Instead of simply passing sal_True as LineToArea, use bNoPolyPoly as info
1230cdf0e10cSrcweir     // if this command is a 'Combine' or a 'Connect' command. On Connect it's sal_True.
1231cdf0e10cSrcweir     // To not concert line segments with a set line width to polygons in that case,
1232cdf0e10cSrcweir     // use this info. Do not convert LineToArea on Connect commands.
1233cdf0e10cSrcweir     // ConvertMarkedToPathObj(!bNoPolyPoly);
1234cdf0e10cSrcweir 
1235cdf0e10cSrcweir     // #114310#
1236cdf0e10cSrcweir     // This is used for Combine and Connect. In no case it is necessary to force
1237cdf0e10cSrcweir     // the content to curve, but it is also not good to force to polygons. Thus,
1238*86e1cf34SPedro Giffuni     // curve is the less information losing one. Remember: This place is not
1239cdf0e10cSrcweir     // used for merge.
1240cdf0e10cSrcweir     // LineToArea is never necessary, both commands are able to take over the
1241cdf0e10cSrcweir     // set line style and to display it correctly. Thus, i will use a
1242cdf0e10cSrcweir     // ConvertMarkedToPathObj with a sal_False in any case. Only drawback is that
1243cdf0e10cSrcweir     // simple polygons will be changed to curves, but with no information loss.
1244cdf0e10cSrcweir     ConvertMarkedToPathObj(sal_False /* bLineToArea */);
1245cdf0e10cSrcweir 
1246cdf0e10cSrcweir     // continue as before
1247cdf0e10cSrcweir     basegfx::B2DPolyPolygon aPolyPolygon;
1248cdf0e10cSrcweir     SdrObjList* pAktOL = 0L;
1249cdf0e10cSrcweir     SdrMarkList aRemoveMerker;
1250cdf0e10cSrcweir 
1251cdf0e10cSrcweir     SortMarkedObjects();
1252cdf0e10cSrcweir     sal_uInt32 nInsPos(0xFFFFFFFF);
1253cdf0e10cSrcweir     SdrObjList* pInsOL = 0L;
1254cdf0e10cSrcweir     SdrPageView* pInsPV = 0L;
1255cdf0e10cSrcweir     const sal_uInt32 nAnz(GetMarkedObjectCount());
1256cdf0e10cSrcweir     const SdrObject* pAttrObj = 0L;
1257cdf0e10cSrcweir 
1258cdf0e10cSrcweir     for(sal_uInt32 a(nAnz); a > 0L; )
1259cdf0e10cSrcweir     {
1260cdf0e10cSrcweir         a--;
1261cdf0e10cSrcweir         SdrMark* pM = GetSdrMarkByIndex(a);
1262cdf0e10cSrcweir         SdrObject* pObj = pM->GetMarkedSdrObj();
1263cdf0e10cSrcweir         SdrObjList* pThisOL = pObj->GetObjList();
1264cdf0e10cSrcweir 
1265cdf0e10cSrcweir         if(pAktOL != pThisOL)
1266cdf0e10cSrcweir         {
1267cdf0e10cSrcweir             pAktOL = pThisOL;
1268cdf0e10cSrcweir         }
1269cdf0e10cSrcweir 
1270cdf0e10cSrcweir         if(ImpCanConvertForCombine(pObj))
1271cdf0e10cSrcweir         {
1272cdf0e10cSrcweir             // Obj merken fuer Attribute kopieren
1273cdf0e10cSrcweir             pAttrObj = pObj;
1274cdf0e10cSrcweir 
1275cdf0e10cSrcweir             // unfortunately ConvertMarkedToPathObj has converted all
1276cdf0e10cSrcweir             // involved polygon data to curve segments, even if not necessary.
1277cdf0e10cSrcweir             // It is better to try to reduce to more simple polygons.
1278cdf0e10cSrcweir             basegfx::B2DPolyPolygon aTmpPoly(basegfx::tools::simplifyCurveSegments(ImpGetPolyPolygon(pObj, sal_True)));
1279cdf0e10cSrcweir             aPolyPolygon.insert(0L, aTmpPoly);
1280cdf0e10cSrcweir 
1281cdf0e10cSrcweir             if(!pInsOL)
1282cdf0e10cSrcweir             {
1283cdf0e10cSrcweir                 nInsPos = pObj->GetOrdNum() + 1L;
1284cdf0e10cSrcweir                 pInsPV = pM->GetPageView();
1285cdf0e10cSrcweir                 pInsOL = pObj->GetObjList();
1286cdf0e10cSrcweir             }
1287cdf0e10cSrcweir 
1288cdf0e10cSrcweir             aRemoveMerker.InsertEntry(SdrMark(pObj, pM->GetPageView()));
1289cdf0e10cSrcweir         }
1290cdf0e10cSrcweir     }
1291cdf0e10cSrcweir 
1292cdf0e10cSrcweir     if(bNoPolyPoly)
1293cdf0e10cSrcweir     {
1294cdf0e10cSrcweir         basegfx::B2DPolygon aCombinedPolygon(ImpCombineToSinglePolygon(aPolyPolygon));
1295cdf0e10cSrcweir         aPolyPolygon.clear();
1296cdf0e10cSrcweir         aPolyPolygon.append(aCombinedPolygon);
1297cdf0e10cSrcweir     }
1298cdf0e10cSrcweir 
1299cdf0e10cSrcweir     const sal_uInt32 nPolyCount(aPolyPolygon.count());
1300cdf0e10cSrcweir 
1301cdf0e10cSrcweir     if(nPolyCount)
1302cdf0e10cSrcweir     {
1303cdf0e10cSrcweir         SdrObjKind eKind = OBJ_PATHFILL;
1304cdf0e10cSrcweir 
1305cdf0e10cSrcweir         if(nPolyCount > 1L)
1306cdf0e10cSrcweir         {
1307cdf0e10cSrcweir             aPolyPolygon.setClosed(true);
1308cdf0e10cSrcweir         }
1309cdf0e10cSrcweir         else
1310cdf0e10cSrcweir         {
1311cdf0e10cSrcweir             // auf Polyline Checken
1312cdf0e10cSrcweir             const basegfx::B2DPolygon aPolygon(aPolyPolygon.getB2DPolygon(0L));
1313cdf0e10cSrcweir             const sal_uInt32 nPointCount(aPolygon.count());
1314cdf0e10cSrcweir 
1315cdf0e10cSrcweir             if(nPointCount <= 2L)
1316cdf0e10cSrcweir             {
1317cdf0e10cSrcweir                 eKind = OBJ_PATHLINE;
1318cdf0e10cSrcweir             }
1319cdf0e10cSrcweir             else
1320cdf0e10cSrcweir             {
1321cdf0e10cSrcweir                 if(!aPolygon.isClosed())
1322cdf0e10cSrcweir                 {
1323cdf0e10cSrcweir                     const basegfx::B2DPoint aPointA(aPolygon.getB2DPoint(0L));
1324cdf0e10cSrcweir                     const basegfx::B2DPoint aPointB(aPolygon.getB2DPoint(nPointCount - 1L));
1325cdf0e10cSrcweir                     const double fDistance(basegfx::B2DVector(aPointB - aPointA).getLength());
1326cdf0e10cSrcweir                     const double fJoinTolerance(10.0);
1327cdf0e10cSrcweir 
1328cdf0e10cSrcweir                     if(fDistance < fJoinTolerance)
1329cdf0e10cSrcweir                     {
1330cdf0e10cSrcweir                         aPolyPolygon.setClosed(true);
1331cdf0e10cSrcweir                     }
1332cdf0e10cSrcweir                     else
1333cdf0e10cSrcweir                     {
1334cdf0e10cSrcweir                         eKind = OBJ_PATHLINE;
1335cdf0e10cSrcweir                     }
1336cdf0e10cSrcweir                 }
1337cdf0e10cSrcweir             }
1338cdf0e10cSrcweir         }
1339cdf0e10cSrcweir 
1340cdf0e10cSrcweir         SdrPathObj* pPath = new SdrPathObj(eKind,aPolyPolygon);
1341cdf0e10cSrcweir 
1342cdf0e10cSrcweir         // Attribute des untersten Objekts
1343cdf0e10cSrcweir         ImpCopyAttributes(pAttrObj, pPath);
1344cdf0e10cSrcweir 
1345cdf0e10cSrcweir         // #100408# If LineStyle of pAttrObj is XLINE_NONE force to XLINE_SOLID to make visible.
1346cdf0e10cSrcweir         const XLineStyle eLineStyle = ((const XLineStyleItem&)pAttrObj->GetMergedItem(XATTR_LINESTYLE)).GetValue();
1347cdf0e10cSrcweir         const XFillStyle eFillStyle = ((const XFillStyleItem&)pAttrObj->GetMergedItem(XATTR_FILLSTYLE)).GetValue();
1348cdf0e10cSrcweir 
1349cdf0e10cSrcweir         // #110635#
1350cdf0e10cSrcweir         // Take fill style/closed state of pAttrObj in account when deciding to change the line style
1351cdf0e10cSrcweir         sal_Bool bIsClosedPathObj(pAttrObj->ISA(SdrPathObj) && ((SdrPathObj*)pAttrObj)->IsClosed());
1352cdf0e10cSrcweir 
1353cdf0e10cSrcweir         if(XLINE_NONE == eLineStyle && (XFILL_NONE == eFillStyle || !bIsClosedPathObj))
1354cdf0e10cSrcweir         {
1355cdf0e10cSrcweir             pPath->SetMergedItem(XLineStyleItem(XLINE_SOLID));
1356cdf0e10cSrcweir         }
1357cdf0e10cSrcweir 
1358cdf0e10cSrcweir         SdrInsertReason aReason(SDRREASON_VIEWCALL,pAttrObj);
1359cdf0e10cSrcweir         pInsOL->InsertObject(pPath,nInsPos,&aReason);
1360cdf0e10cSrcweir         if( bUndo )
1361cdf0e10cSrcweir             AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pPath));
1362cdf0e10cSrcweir 
1363cdf0e10cSrcweir         // #111111#
1364cdf0e10cSrcweir         // Here was a severe error: Without UnmarkAllObj, the new object was marked
1365cdf0e10cSrcweir         // additionally to the two ones which are deleted below. As long as those are
1366cdf0e10cSrcweir         // in the UNDO there is no problem, but as soon as they get deleted, the
1367cdf0e10cSrcweir         // MarkList will contain deleted objects -> GPF.
1368cdf0e10cSrcweir         UnmarkAllObj(pInsPV);
1369cdf0e10cSrcweir         MarkObj(pPath, pInsPV, sal_False, sal_True);
1370cdf0e10cSrcweir     }
1371cdf0e10cSrcweir 
1372cdf0e10cSrcweir     // UndoComment aus den tatsaechlich verwendeten Objekten zusammenbauen
1373cdf0e10cSrcweir     aRemoveMerker.ForceSort(); // wichtig fuer Remove (s.u.)
1374cdf0e10cSrcweir     if( bUndo )
1375cdf0e10cSrcweir         SetUndoComment(ImpGetResStr(bNoPolyPoly?STR_EditCombine_OnePoly:STR_EditCombine_PolyPoly),aRemoveMerker.GetMarkDescription());
1376cdf0e10cSrcweir 
1377cdf0e10cSrcweir     // die tatsaechlich verwendeten Objekten aus der Liste entfernen
1378cdf0e10cSrcweir     DeleteMarkedList(aRemoveMerker);
1379cdf0e10cSrcweir     if( bUndo )
1380cdf0e10cSrcweir         EndUndo();
1381cdf0e10cSrcweir }
1382cdf0e10cSrcweir 
1383cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
1384cdf0e10cSrcweir //
1385cdf0e10cSrcweir //  @@@@@   @@   @@@@   @@   @@   @@@@   @@  @@  @@@@@@  @@     @@@@@
1386cdf0e10cSrcweir //  @@  @@  @@  @@  @@  @@@ @@@  @@  @@  @@@ @@    @@    @@     @@
1387cdf0e10cSrcweir //  @@  @@  @@  @@      @@@@@@@  @@  @@  @@@@@@    @@    @@     @@
1388cdf0e10cSrcweir //  @@  @@  @@   @@@@   @@@@@@@  @@@@@@  @@@@@@    @@    @@     @@@@
1389cdf0e10cSrcweir //  @@  @@  @@      @@  @@ @ @@  @@  @@  @@ @@@    @@    @@     @@
1390cdf0e10cSrcweir //  @@  @@  @@  @@  @@  @@   @@  @@  @@  @@  @@    @@    @@     @@
1391cdf0e10cSrcweir //  @@@@@   @@   @@@@   @@   @@  @@  @@  @@  @@    @@    @@@@@  @@@@@
1392cdf0e10cSrcweir //
1393cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
1394cdf0e10cSrcweir 
ImpCanDismantle(const basegfx::B2DPolyPolygon & rPpolyPolygon,sal_Bool bMakeLines) const1395cdf0e10cSrcweir sal_Bool SdrEditView::ImpCanDismantle(const basegfx::B2DPolyPolygon& rPpolyPolygon, sal_Bool bMakeLines) const
1396cdf0e10cSrcweir {
1397cdf0e10cSrcweir     sal_Bool bCan(sal_False);
1398cdf0e10cSrcweir     const sal_uInt32 nPolygonCount(rPpolyPolygon.count());
1399cdf0e10cSrcweir 
1400cdf0e10cSrcweir     if(nPolygonCount >= 2L)
1401cdf0e10cSrcweir     {
1402cdf0e10cSrcweir         // #i69172# dismantle makes sense with 2 or more polygons in a polyPolygon
1403cdf0e10cSrcweir         bCan = sal_True;
1404cdf0e10cSrcweir     }
1405cdf0e10cSrcweir     else if(bMakeLines && 1L == nPolygonCount)
1406cdf0e10cSrcweir     {
1407cdf0e10cSrcweir         // #i69172# ..or with at least 2 edges (curves or lines)
1408cdf0e10cSrcweir         const basegfx::B2DPolygon aPolygon(rPpolyPolygon.getB2DPolygon(0L));
1409cdf0e10cSrcweir         const sal_uInt32 nPointCount(aPolygon.count());
1410cdf0e10cSrcweir 
1411cdf0e10cSrcweir         if(nPointCount > 2L)
1412cdf0e10cSrcweir         {
1413cdf0e10cSrcweir             bCan = sal_True;
1414cdf0e10cSrcweir         }
1415cdf0e10cSrcweir     }
1416cdf0e10cSrcweir 
1417cdf0e10cSrcweir     return bCan;
1418cdf0e10cSrcweir }
1419cdf0e10cSrcweir 
ImpCanDismantle(const SdrObject * pObj,sal_Bool bMakeLines) const1420cdf0e10cSrcweir sal_Bool SdrEditView::ImpCanDismantle(const SdrObject* pObj, sal_Bool bMakeLines) const
1421cdf0e10cSrcweir {
1422cdf0e10cSrcweir     sal_Bool bOtherObjs(sal_False);    // sal_True=andere Objekte ausser PathObj's vorhanden
1423cdf0e10cSrcweir     sal_Bool bMin1PolyPoly(sal_False); // sal_True=mind. 1 PolyPolygon mit mehr als ein Polygon vorhanden
1424cdf0e10cSrcweir     SdrObjList* pOL = pObj->GetSubList();
1425cdf0e10cSrcweir 
1426cdf0e10cSrcweir     if(pOL)
1427cdf0e10cSrcweir     {
1428cdf0e10cSrcweir         // Aha, Gruppenobjekt. Also alle Member ansehen.
1429cdf0e10cSrcweir         // Alle muessen PathObjs sein !
1430cdf0e10cSrcweir         SdrObjListIter aIter(*pOL, IM_DEEPNOGROUPS);
1431cdf0e10cSrcweir 
1432cdf0e10cSrcweir         while(aIter.IsMore() && !bOtherObjs)
1433cdf0e10cSrcweir         {
1434cdf0e10cSrcweir             const SdrObject* pObj1 = aIter.Next();
1435cdf0e10cSrcweir             const SdrPathObj* pPath = PTR_CAST(SdrPathObj, pObj1);
1436cdf0e10cSrcweir 
1437cdf0e10cSrcweir             if(pPath)
1438cdf0e10cSrcweir             {
1439cdf0e10cSrcweir                 if(ImpCanDismantle(pPath->GetPathPoly(), bMakeLines))
1440cdf0e10cSrcweir                 {
1441cdf0e10cSrcweir                     bMin1PolyPoly = sal_True;
1442cdf0e10cSrcweir                 }
1443cdf0e10cSrcweir 
1444cdf0e10cSrcweir                 SdrObjTransformInfoRec aInfo;
1445cdf0e10cSrcweir                 pObj1->TakeObjInfo(aInfo);
1446cdf0e10cSrcweir 
1447cdf0e10cSrcweir                 if(!aInfo.bCanConvToPath)
1448cdf0e10cSrcweir                 {
1449cdf0e10cSrcweir                     // Passiert z.B. im Falle Fontwork (Joe, 28-11-95)
1450cdf0e10cSrcweir                     bOtherObjs = sal_True;
1451cdf0e10cSrcweir                 }
1452cdf0e10cSrcweir             }
1453cdf0e10cSrcweir             else
1454cdf0e10cSrcweir             {
1455cdf0e10cSrcweir                 bOtherObjs = sal_True;
1456cdf0e10cSrcweir             }
1457cdf0e10cSrcweir         }
1458cdf0e10cSrcweir     }
1459cdf0e10cSrcweir     else
1460cdf0e10cSrcweir     {
1461cdf0e10cSrcweir         const SdrPathObj* pPath = PTR_CAST(SdrPathObj, pObj);
1462cdf0e10cSrcweir         const SdrObjCustomShape* pCustomShape = PTR_CAST(SdrObjCustomShape, pObj);
1463cdf0e10cSrcweir 
1464cdf0e10cSrcweir         // #i37011#
1465cdf0e10cSrcweir         if(pPath)
1466cdf0e10cSrcweir         {
1467cdf0e10cSrcweir             if(ImpCanDismantle(pPath->GetPathPoly(),bMakeLines))
1468cdf0e10cSrcweir             {
1469cdf0e10cSrcweir                 bMin1PolyPoly = sal_True;
1470cdf0e10cSrcweir             }
1471cdf0e10cSrcweir 
1472cdf0e10cSrcweir             SdrObjTransformInfoRec aInfo;
1473cdf0e10cSrcweir             pObj->TakeObjInfo(aInfo);
1474cdf0e10cSrcweir 
1475cdf0e10cSrcweir             // #69711 : new condition IsLine() to be able to break simple Lines
1476cdf0e10cSrcweir             if(!(aInfo.bCanConvToPath || aInfo.bCanConvToPoly) && !pPath->IsLine())
1477cdf0e10cSrcweir             {
1478cdf0e10cSrcweir                 // Passiert z.B. im Falle Fontwork (Joe, 28-11-95)
1479cdf0e10cSrcweir                 bOtherObjs = sal_True;
1480cdf0e10cSrcweir             }
1481cdf0e10cSrcweir         }
1482cdf0e10cSrcweir         else if(pCustomShape)
1483cdf0e10cSrcweir         {
1484cdf0e10cSrcweir             if(bMakeLines)
1485cdf0e10cSrcweir             {
1486cdf0e10cSrcweir                 // allow break command
1487cdf0e10cSrcweir                 bMin1PolyPoly = sal_True;
1488cdf0e10cSrcweir             }
1489cdf0e10cSrcweir         }
1490cdf0e10cSrcweir         else
1491cdf0e10cSrcweir         {
1492cdf0e10cSrcweir             bOtherObjs = sal_True;
1493cdf0e10cSrcweir         }
1494cdf0e10cSrcweir     }
1495cdf0e10cSrcweir     return bMin1PolyPoly && !bOtherObjs;
1496cdf0e10cSrcweir }
1497cdf0e10cSrcweir 
ImpDismantleOneObject(const SdrObject * pObj,SdrObjList & rOL,sal_uIntPtr & rPos,SdrPageView * pPV,sal_Bool bMakeLines)1498cdf0e10cSrcweir void SdrEditView::ImpDismantleOneObject(const SdrObject* pObj, SdrObjList& rOL, sal_uIntPtr& rPos, SdrPageView* pPV, sal_Bool bMakeLines)
1499cdf0e10cSrcweir {
1500cdf0e10cSrcweir     const SdrPathObj* pSrcPath = PTR_CAST(SdrPathObj, pObj);
1501cdf0e10cSrcweir     const SdrObjCustomShape* pCustomShape = PTR_CAST(SdrObjCustomShape, pObj);
1502cdf0e10cSrcweir 
1503cdf0e10cSrcweir     const bool bUndo = IsUndoEnabled();
1504cdf0e10cSrcweir 
1505cdf0e10cSrcweir     if(pSrcPath)
1506cdf0e10cSrcweir     {
1507cdf0e10cSrcweir         // #i74631# redesigned due to XpolyPolygon removal and explicit constructors
1508cdf0e10cSrcweir         SdrObject* pLast = 0; // fuer die Zuweisung des OutlinerParaObject
1509cdf0e10cSrcweir         const basegfx::B2DPolyPolygon& rPolyPolygon(pSrcPath->GetPathPoly());
1510cdf0e10cSrcweir         const sal_uInt32 nPolyCount(rPolyPolygon.count());
1511cdf0e10cSrcweir 
1512cdf0e10cSrcweir         for(sal_uInt32 a(0); a < nPolyCount; a++)
1513cdf0e10cSrcweir         {
1514cdf0e10cSrcweir             const basegfx::B2DPolygon& rCandidate(rPolyPolygon.getB2DPolygon(a));
1515cdf0e10cSrcweir             const sal_uInt32 nPointCount(rCandidate.count());
1516cdf0e10cSrcweir 
1517cdf0e10cSrcweir             if(!bMakeLines || nPointCount < 2)
1518cdf0e10cSrcweir             {
1519cdf0e10cSrcweir                 SdrPathObj* pPath = new SdrPathObj((SdrObjKind)pSrcPath->GetObjIdentifier(), basegfx::B2DPolyPolygon(rCandidate));
1520cdf0e10cSrcweir                 ImpCopyAttributes(pSrcPath, pPath);
1521cdf0e10cSrcweir                 pLast = pPath;
1522cdf0e10cSrcweir                 SdrInsertReason aReason(SDRREASON_VIEWCALL, pSrcPath);
1523cdf0e10cSrcweir                 rOL.InsertObject(pPath, rPos, &aReason);
1524cdf0e10cSrcweir                 if( bUndo )
1525cdf0e10cSrcweir                     AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pPath, sal_True));
1526cdf0e10cSrcweir                 MarkObj(pPath, pPV, sal_False, sal_True);
1527cdf0e10cSrcweir                 rPos++;
1528cdf0e10cSrcweir             }
1529cdf0e10cSrcweir             else
1530cdf0e10cSrcweir             {
1531cdf0e10cSrcweir                 const sal_uInt32 nLoopCount(rCandidate.isClosed() ? nPointCount : nPointCount - 1);
1532cdf0e10cSrcweir 
1533cdf0e10cSrcweir                 for(sal_uInt32 b(0); b < nLoopCount; b++)
1534cdf0e10cSrcweir                 {
1535cdf0e10cSrcweir                     SdrObjKind eKind(OBJ_PLIN);
1536cdf0e10cSrcweir                     basegfx::B2DPolygon aNewPolygon;
1537cdf0e10cSrcweir                     const sal_uInt32 nNextIndex((b + 1) % nPointCount);
1538cdf0e10cSrcweir 
1539cdf0e10cSrcweir                     aNewPolygon.append(rCandidate.getB2DPoint(b));
1540cdf0e10cSrcweir 
1541cdf0e10cSrcweir                     if(rCandidate.areControlPointsUsed())
1542cdf0e10cSrcweir                     {
1543cdf0e10cSrcweir                         aNewPolygon.appendBezierSegment(
1544cdf0e10cSrcweir                             rCandidate.getNextControlPoint(b),
1545cdf0e10cSrcweir                             rCandidate.getPrevControlPoint(nNextIndex),
1546cdf0e10cSrcweir                             rCandidate.getB2DPoint(nNextIndex));
1547cdf0e10cSrcweir                         eKind = OBJ_PATHLINE;
1548cdf0e10cSrcweir                     }
1549cdf0e10cSrcweir                     else
1550cdf0e10cSrcweir                     {
1551cdf0e10cSrcweir                         aNewPolygon.append(rCandidate.getB2DPoint(nNextIndex));
1552cdf0e10cSrcweir                     }
1553cdf0e10cSrcweir 
1554cdf0e10cSrcweir                     SdrPathObj* pPath = new SdrPathObj(eKind, basegfx::B2DPolyPolygon(aNewPolygon));
1555cdf0e10cSrcweir                     ImpCopyAttributes(pSrcPath, pPath);
1556cdf0e10cSrcweir                     pLast = pPath;
1557cdf0e10cSrcweir                     SdrInsertReason aReason(SDRREASON_VIEWCALL, pSrcPath);
1558cdf0e10cSrcweir                     rOL.InsertObject(pPath, rPos, &aReason);
1559cdf0e10cSrcweir                     if( bUndo )
1560cdf0e10cSrcweir                         AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pPath, sal_True));
1561cdf0e10cSrcweir                     MarkObj(pPath, pPV, sal_False, sal_True);
1562cdf0e10cSrcweir                     rPos++;
1563cdf0e10cSrcweir                 }
1564cdf0e10cSrcweir             }
1565cdf0e10cSrcweir         }
1566cdf0e10cSrcweir 
1567cdf0e10cSrcweir         if(pLast && pSrcPath->GetOutlinerParaObject())
1568cdf0e10cSrcweir         {
1569cdf0e10cSrcweir             pLast->SetOutlinerParaObject(new OutlinerParaObject(*pSrcPath->GetOutlinerParaObject()));
1570cdf0e10cSrcweir         }
1571cdf0e10cSrcweir     }
1572cdf0e10cSrcweir     else if(pCustomShape)
1573cdf0e10cSrcweir     {
1574cdf0e10cSrcweir         if(bMakeLines)
1575cdf0e10cSrcweir         {
1576cdf0e10cSrcweir             // break up custom shape
1577cdf0e10cSrcweir             const SdrObject* pReplacement = pCustomShape->GetSdrObjectFromCustomShape();
1578cdf0e10cSrcweir 
1579cdf0e10cSrcweir             if(pReplacement)
1580cdf0e10cSrcweir             {
1581cdf0e10cSrcweir                 SdrObject* pCandidate = pReplacement->Clone();
1582cdf0e10cSrcweir                 DBG_ASSERT(pCandidate, "SdrEditView::ImpDismantleOneObject: Could not clone SdrObject (!)");
1583cdf0e10cSrcweir                 pCandidate->SetModel(pCustomShape->GetModel());
1584cdf0e10cSrcweir 
1585cdf0e10cSrcweir                 if(((SdrShadowItem&)pCustomShape->GetMergedItem(SDRATTR_SHADOW)).GetValue())
1586cdf0e10cSrcweir                 {
1587cdf0e10cSrcweir                     if(pReplacement->ISA(SdrObjGroup))
1588cdf0e10cSrcweir                     {
1589cdf0e10cSrcweir                         pCandidate->SetMergedItem(SdrShadowItem(sal_True));
1590cdf0e10cSrcweir                     }
1591cdf0e10cSrcweir                 }
1592cdf0e10cSrcweir 
1593cdf0e10cSrcweir                 SdrInsertReason aReason(SDRREASON_VIEWCALL, pCustomShape);
1594cdf0e10cSrcweir                 rOL.InsertObject(pCandidate, rPos, &aReason);
1595cdf0e10cSrcweir                 if( bUndo )
1596cdf0e10cSrcweir                     AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pCandidate, true));
1597cdf0e10cSrcweir                 MarkObj(pCandidate, pPV, sal_False, sal_True);
1598cdf0e10cSrcweir 
1599cdf0e10cSrcweir                 if(pCustomShape->HasText() && !pCustomShape->IsTextPath())
1600cdf0e10cSrcweir                 {
1601cdf0e10cSrcweir                     // #i37011# also create a text object and add at rPos + 1
1602cdf0e10cSrcweir                     SdrTextObj* pTextObj = (SdrTextObj*)SdrObjFactory::MakeNewObject(
1603cdf0e10cSrcweir                         pCustomShape->GetObjInventor(), OBJ_TEXT, 0L, pCustomShape->GetModel());
1604cdf0e10cSrcweir 
1605cdf0e10cSrcweir                     // Copy text content
1606cdf0e10cSrcweir                     OutlinerParaObject* pParaObj = pCustomShape->GetOutlinerParaObject();
1607cdf0e10cSrcweir                     if(pParaObj)
1608cdf0e10cSrcweir                     {
1609cdf0e10cSrcweir                         pTextObj->NbcSetOutlinerParaObject(new OutlinerParaObject(*pParaObj));
1610cdf0e10cSrcweir                     }
1611cdf0e10cSrcweir 
1612cdf0e10cSrcweir                     // copy all attributes
1613cdf0e10cSrcweir                     SfxItemSet aTargetItemSet(pCustomShape->GetMergedItemSet());
1614cdf0e10cSrcweir 
1615cdf0e10cSrcweir                     // clear fill and line style
1616cdf0e10cSrcweir                     aTargetItemSet.Put(XLineStyleItem(XLINE_NONE));
1617cdf0e10cSrcweir                     aTargetItemSet.Put(XFillStyleItem(XFILL_NONE));
1618cdf0e10cSrcweir 
1619cdf0e10cSrcweir                     // get the text bounds and set at text object
1620cdf0e10cSrcweir                     Rectangle aTextBounds = pCustomShape->GetSnapRect();
1621cdf0e10cSrcweir                     if(pCustomShape->GetTextBounds(aTextBounds))
1622cdf0e10cSrcweir                     {
1623cdf0e10cSrcweir                         pTextObj->SetSnapRect(aTextBounds);
1624cdf0e10cSrcweir                     }
1625cdf0e10cSrcweir 
1626cdf0e10cSrcweir                     // if rotated, copy GeoStat, too.
1627cdf0e10cSrcweir                     const GeoStat& rSourceGeo = pCustomShape->GetGeoStat();
1628cdf0e10cSrcweir                     if(rSourceGeo.nDrehWink)
1629cdf0e10cSrcweir                     {
1630cdf0e10cSrcweir                         pTextObj->NbcRotate(
1631cdf0e10cSrcweir                             pCustomShape->GetSnapRect().Center(), rSourceGeo.nDrehWink,
1632cdf0e10cSrcweir                             rSourceGeo.nSin, rSourceGeo.nCos);
1633cdf0e10cSrcweir                     }
1634cdf0e10cSrcweir 
1635cdf0e10cSrcweir                     // set modified ItemSet at text object
1636cdf0e10cSrcweir                     pTextObj->SetMergedItemSet(aTargetItemSet);
1637cdf0e10cSrcweir 
1638cdf0e10cSrcweir                     // insert object
1639cdf0e10cSrcweir                     rOL.InsertObject(pTextObj, rPos + 1, &aReason);
1640cdf0e10cSrcweir                     if( bUndo )
1641cdf0e10cSrcweir                         AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pTextObj, true));
1642cdf0e10cSrcweir                     MarkObj(pTextObj, pPV, sal_False, sal_True);
1643cdf0e10cSrcweir                 }
1644cdf0e10cSrcweir             }
1645cdf0e10cSrcweir         }
1646cdf0e10cSrcweir     }
1647cdf0e10cSrcweir }
1648cdf0e10cSrcweir 
DismantleMarkedObjects(sal_Bool bMakeLines)1649cdf0e10cSrcweir void SdrEditView::DismantleMarkedObjects(sal_Bool bMakeLines)
1650cdf0e10cSrcweir {
1651cdf0e10cSrcweir     //sal_uInt32 nCnt(0);
1652cdf0e10cSrcweir     // Temporaere Marklist
1653cdf0e10cSrcweir     SdrMarkList aRemoveMerker;
1654cdf0e10cSrcweir 
1655cdf0e10cSrcweir     SortMarkedObjects();
1656cdf0e10cSrcweir 
1657cdf0e10cSrcweir     const bool bUndo = IsUndoEnabled();
1658cdf0e10cSrcweir 
1659cdf0e10cSrcweir     if( bUndo )
1660cdf0e10cSrcweir     {
1661cdf0e10cSrcweir         // Der Comment wird spaeter zusammengebaut
1662cdf0e10cSrcweir         BegUndo(String(), String(),
1663cdf0e10cSrcweir             bMakeLines ? SDRREPFUNC_OBJ_DISMANTLE_LINES : SDRREPFUNC_OBJ_DISMANTLE_POLYS);
1664cdf0e10cSrcweir     }
1665cdf0e10cSrcweir 
1666cdf0e10cSrcweir     sal_uIntPtr nm;
1667cdf0e10cSrcweir     sal_uIntPtr nAnz=GetMarkedObjectCount();
1668cdf0e10cSrcweir     SdrObjList* pOL0=NULL;
1669cdf0e10cSrcweir     for (nm=nAnz; nm>0;) {
1670cdf0e10cSrcweir         nm--;
1671cdf0e10cSrcweir         SdrMark* pM=GetSdrMarkByIndex(nm);
1672cdf0e10cSrcweir         SdrObject* pObj=pM->GetMarkedSdrObj();
1673cdf0e10cSrcweir         SdrPageView* pPV=pM->GetPageView();
1674cdf0e10cSrcweir         SdrObjList* pOL=pObj->GetObjList();
1675cdf0e10cSrcweir         if (pOL!=pOL0) { pOL0=pOL; pObj->GetOrdNum(); } // sicherstellen, dass OrdNums stimmen!
1676cdf0e10cSrcweir         if (ImpCanDismantle(pObj,bMakeLines)) {
1677cdf0e10cSrcweir             aRemoveMerker.InsertEntry(SdrMark(pObj,pM->GetPageView()));
1678cdf0e10cSrcweir             sal_uIntPtr nPos0=pObj->GetOrdNumDirect();
1679cdf0e10cSrcweir             sal_uIntPtr nPos=nPos0+1;
1680cdf0e10cSrcweir             SdrObjList* pSubList=pObj->GetSubList();
1681cdf0e10cSrcweir             if (pSubList!=NULL && !pObj->Is3DObj()) {
1682cdf0e10cSrcweir                 SdrObjListIter aIter(*pSubList,IM_DEEPNOGROUPS);
1683cdf0e10cSrcweir                 while (aIter.IsMore()) {
1684cdf0e10cSrcweir                     const SdrObject* pObj1=aIter.Next();
1685cdf0e10cSrcweir                     ImpDismantleOneObject(pObj1,*pOL,nPos,pPV,bMakeLines);
1686cdf0e10cSrcweir                 }
1687cdf0e10cSrcweir             } else {
1688cdf0e10cSrcweir                 ImpDismantleOneObject(pObj,*pOL,nPos,pPV,bMakeLines);
1689cdf0e10cSrcweir             }
1690cdf0e10cSrcweir             if( bUndo )
1691cdf0e10cSrcweir                 AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj,sal_True));
1692cdf0e10cSrcweir             pOL->RemoveObject(nPos0);
1693cdf0e10cSrcweir 
1694cdf0e10cSrcweir             if( !bUndo )
1695cdf0e10cSrcweir                 SdrObject::Free(pObj);
1696cdf0e10cSrcweir         }
1697cdf0e10cSrcweir     }
1698cdf0e10cSrcweir 
1699cdf0e10cSrcweir     if( bUndo )
1700cdf0e10cSrcweir     {
1701cdf0e10cSrcweir         // UndoComment aus den tatsaechlich verwendeten Objekten zusammenbauen
1702cdf0e10cSrcweir         SetUndoComment(ImpGetResStr(bMakeLines?STR_EditDismantle_Lines:STR_EditDismantle_Polys),aRemoveMerker.GetMarkDescription());
1703cdf0e10cSrcweir         // die tatsaechlich verwendeten Objekten aus der Liste entfernen
1704cdf0e10cSrcweir         EndUndo();
1705cdf0e10cSrcweir     }
1706cdf0e10cSrcweir }
1707cdf0e10cSrcweir 
1708cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
1709cdf0e10cSrcweir //
1710cdf0e10cSrcweir //   #### ####   ###  #   # ####
1711cdf0e10cSrcweir //  #     #   # #   # #   # #   #
1712cdf0e10cSrcweir //  #  ## ####  #   # #   # ####
1713cdf0e10cSrcweir //  #   # #   # #   # #   # #
1714cdf0e10cSrcweir //   #### #   #  ###   ###  #
1715cdf0e10cSrcweir //
1716cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
1717cdf0e10cSrcweir 
GroupMarked(const SdrObject * pUserGrp)1718cdf0e10cSrcweir void SdrEditView::GroupMarked(const SdrObject* pUserGrp)
1719cdf0e10cSrcweir {
1720cdf0e10cSrcweir     if (AreObjectsMarked())
1721cdf0e10cSrcweir     {
1722cdf0e10cSrcweir         SortMarkedObjects();
1723cdf0e10cSrcweir 
1724cdf0e10cSrcweir         const bool bUndo = IsUndoEnabled();
1725cdf0e10cSrcweir         if( bUndo )
1726cdf0e10cSrcweir         {
1727cdf0e10cSrcweir             BegUndo(ImpGetResStr(STR_EditGroup),GetDescriptionOfMarkedObjects(),SDRREPFUNC_OBJ_GROUP);
1728cdf0e10cSrcweir 
1729cdf0e10cSrcweir             const sal_uIntPtr nAnz = GetMarkedObjectCount();
1730cdf0e10cSrcweir             for(sal_uIntPtr nm = nAnz; nm>0; )
1731cdf0e10cSrcweir             {
1732cdf0e10cSrcweir                 // UndoActions fuer alle betroffenen Objekte anlegen
1733cdf0e10cSrcweir                 nm--;
1734cdf0e10cSrcweir                 SdrMark* pM=GetSdrMarkByIndex(nm);
1735cdf0e10cSrcweir                 SdrObject* pObj = pM->GetMarkedSdrObj();
1736cdf0e10cSrcweir                     std::vector< SdrUndoAction* > vConnectorUndoActions( CreateConnectorUndo( *pObj ) );
1737cdf0e10cSrcweir                     AddUndoActions( vConnectorUndoActions );
1738cdf0e10cSrcweir                     AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoRemoveObject( *pObj ));
1739cdf0e10cSrcweir             }
1740cdf0e10cSrcweir         }
1741cdf0e10cSrcweir 
1742cdf0e10cSrcweir         SdrMarkList aNewMark;
1743cdf0e10cSrcweir         SdrPageView* pPV = GetSdrPageView();
1744cdf0e10cSrcweir 
1745cdf0e10cSrcweir         if(pPV)
1746cdf0e10cSrcweir         {
1747cdf0e10cSrcweir             SdrObjList* pAktLst=pPV->GetObjList();
1748cdf0e10cSrcweir             SdrObjList* pSrcLst=pAktLst;
1749cdf0e10cSrcweir             SdrObjList* pSrcLst0=pSrcLst;
1750cdf0e10cSrcweir             SdrPage*    pPage=pPV->GetPage();
1751cdf0e10cSrcweir             // sicherstellen, dass die OrdNums stimmen
1752cdf0e10cSrcweir             if (pSrcLst->IsObjOrdNumsDirty())
1753cdf0e10cSrcweir                 pSrcLst->RecalcObjOrdNums();
1754cdf0e10cSrcweir             SdrObject*  pGrp=NULL;
1755cdf0e10cSrcweir             SdrObject*  pRefObj=NULL; // Referenz fuer InsertReason (-> rumankern im Writer)
1756cdf0e10cSrcweir             SdrObject*  pRefObj1=NULL; // Referenz fuer InsertReason (-> rumankern im Writer)
1757cdf0e10cSrcweir             SdrObjList* pDstLst=NULL;
1758cdf0e10cSrcweir             // Falls alle markierten Objekte aus Fremden Obj-Listen
1759cdf0e10cSrcweir             // kommen, kommt das Gruppenobjekt an das Ende der Liste.
1760cdf0e10cSrcweir             sal_uIntPtr       nInsPos=pSrcLst->GetObjCount();
1761cdf0e10cSrcweir             sal_Bool    bNeedInsPos=sal_True;
1762cdf0e10cSrcweir             for (sal_uIntPtr nm=GetMarkedObjectCount(); nm>0;)
1763cdf0e10cSrcweir             {
1764cdf0e10cSrcweir                 nm--;
1765cdf0e10cSrcweir                 SdrMark* pM=GetSdrMarkByIndex(nm);
1766cdf0e10cSrcweir                 if (pM->GetPageView()==pPV)
1767cdf0e10cSrcweir                 {
1768cdf0e10cSrcweir                     if (pGrp==NULL)
1769cdf0e10cSrcweir                     {
1770cdf0e10cSrcweir                         if (pUserGrp!=NULL)
1771cdf0e10cSrcweir                             pGrp=pUserGrp->Clone();
1772cdf0e10cSrcweir                         if (pGrp==NULL)
1773cdf0e10cSrcweir                             pGrp=new SdrObjGroup;
1774cdf0e10cSrcweir                         pDstLst=pGrp->GetSubList();
1775cdf0e10cSrcweir                         DBG_ASSERT(pDstLst!=NULL,"Angebliches Gruppenobjekt liefert keine Objektliste");
1776cdf0e10cSrcweir                     }
1777cdf0e10cSrcweir                     SdrObject* pObj=pM->GetMarkedSdrObj();
1778cdf0e10cSrcweir                     pSrcLst=pObj->GetObjList();
1779cdf0e10cSrcweir                     if (pSrcLst!=pSrcLst0)
1780cdf0e10cSrcweir                     {
1781cdf0e10cSrcweir                         if (pSrcLst->IsObjOrdNumsDirty())
1782cdf0e10cSrcweir                             pSrcLst->RecalcObjOrdNums();
1783cdf0e10cSrcweir                     }
1784cdf0e10cSrcweir                     sal_Bool bForeignList=pSrcLst!=pAktLst;
1785cdf0e10cSrcweir                     sal_Bool bGrouped=pSrcLst!=pPage;
1786cdf0e10cSrcweir                     if (!bForeignList && bNeedInsPos)
1787cdf0e10cSrcweir                     {
1788cdf0e10cSrcweir                         nInsPos=pObj->GetOrdNum(); // ua, damit sind alle ObjOrdNum der Page gesetzt
1789cdf0e10cSrcweir                         nInsPos++;
1790cdf0e10cSrcweir                         bNeedInsPos=sal_False;
1791cdf0e10cSrcweir                     }
1792cdf0e10cSrcweir                     pSrcLst->RemoveObject(pObj->GetOrdNumDirect());
1793cdf0e10cSrcweir                     if (!bForeignList)
1794cdf0e10cSrcweir                         nInsPos--; // InsertPos korregieren
1795cdf0e10cSrcweir                     SdrInsertReason aReason(SDRREASON_VIEWCALL);
1796cdf0e10cSrcweir                     pDstLst->InsertObject(pObj,0,&aReason);
1797cdf0e10cSrcweir                     GetMarkedObjectListWriteAccess().DeleteMark(nm);
1798cdf0e10cSrcweir                     if (pRefObj1==NULL)
1799cdf0e10cSrcweir                         pRefObj1=pObj; // Das oberste sichtbare Objekt
1800cdf0e10cSrcweir                     if (!bGrouped)
1801cdf0e10cSrcweir                     {
1802cdf0e10cSrcweir                         if (pRefObj==NULL)
1803cdf0e10cSrcweir                             pRefObj=pObj; // Das oberste sichtbare nicht gruppierte Objekt
1804cdf0e10cSrcweir                     }
1805cdf0e10cSrcweir                     pSrcLst0=pSrcLst;
1806cdf0e10cSrcweir                 }
1807cdf0e10cSrcweir             }
1808cdf0e10cSrcweir             if (pRefObj==NULL)
1809cdf0e10cSrcweir                 pRefObj=pRefObj1;
1810cdf0e10cSrcweir             if (pGrp!=NULL)
1811cdf0e10cSrcweir             {
1812cdf0e10cSrcweir                 aNewMark.InsertEntry(SdrMark(pGrp,pPV));
1813cdf0e10cSrcweir                 sal_uIntPtr nAnz=pDstLst->GetObjCount();
1814cdf0e10cSrcweir                 SdrInsertReason aReason(SDRREASON_VIEWCALL,pRefObj);
1815cdf0e10cSrcweir                 pAktLst->InsertObject(pGrp,nInsPos,&aReason);
1816cdf0e10cSrcweir                 if( bUndo )
1817cdf0e10cSrcweir                 {
1818cdf0e10cSrcweir                     AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pGrp,true)); // Kein Recalc!
1819cdf0e10cSrcweir                     for (sal_uIntPtr no=0; no<nAnz; no++)
1820cdf0e10cSrcweir                     {
1821cdf0e10cSrcweir                         AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoInsertObject(*pDstLst->GetObj(no)));
1822cdf0e10cSrcweir                     }
1823cdf0e10cSrcweir                 }
1824cdf0e10cSrcweir             }
1825cdf0e10cSrcweir         }
1826cdf0e10cSrcweir         GetMarkedObjectListWriteAccess().Merge(aNewMark);
1827cdf0e10cSrcweir         MarkListHasChanged();
1828cdf0e10cSrcweir 
1829cdf0e10cSrcweir         if( bUndo )
1830cdf0e10cSrcweir             EndUndo();
1831cdf0e10cSrcweir     }
1832cdf0e10cSrcweir }
1833cdf0e10cSrcweir 
1834cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
1835cdf0e10cSrcweir //
1836cdf0e10cSrcweir //  #   # #   #  #### ####   ###  #   # ####
1837cdf0e10cSrcweir //  #   # ##  # #     #   # #   # #   # #   #
1838cdf0e10cSrcweir //  #   # # # # #  ## ####  #   # #   # ####
1839cdf0e10cSrcweir //  #   # #  ## #   # #   # #   # #   # #
1840cdf0e10cSrcweir //   ###  #   #  #### #   #  ###   ###  #
1841cdf0e10cSrcweir //
1842cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
1843cdf0e10cSrcweir 
UnGroupMarked()1844cdf0e10cSrcweir void SdrEditView::UnGroupMarked()
1845cdf0e10cSrcweir {
1846cdf0e10cSrcweir     SdrMarkList aNewMark;
1847cdf0e10cSrcweir 
1848cdf0e10cSrcweir     const bool bUndo = IsUndoEnabled();
1849cdf0e10cSrcweir     if( bUndo )
1850cdf0e10cSrcweir         BegUndo(String(), String(), SDRREPFUNC_OBJ_UNGROUP);
1851cdf0e10cSrcweir 
1852cdf0e10cSrcweir     sal_uIntPtr nCount=0;
1853cdf0e10cSrcweir     XubString aName1;
1854cdf0e10cSrcweir     XubString aName;
1855cdf0e10cSrcweir     sal_Bool bNameOk=sal_False;
1856cdf0e10cSrcweir     for (sal_uIntPtr nm=GetMarkedObjectCount(); nm>0;) {
1857cdf0e10cSrcweir         nm--;
1858cdf0e10cSrcweir         SdrMark* pM=GetSdrMarkByIndex(nm);
1859cdf0e10cSrcweir         SdrObject* pGrp=pM->GetMarkedSdrObj();
1860cdf0e10cSrcweir         SdrObjList* pSrcLst=pGrp->GetSubList();
1861cdf0e10cSrcweir         if (pSrcLst!=NULL) {
1862cdf0e10cSrcweir             nCount++;
1863cdf0e10cSrcweir             if (nCount==1) {
1864cdf0e10cSrcweir                 pGrp->TakeObjNameSingul(aName);  // Bezeichnung der Gruppe holen
1865cdf0e10cSrcweir                 pGrp->TakeObjNamePlural(aName1); // Bezeichnung der Gruppe holen
1866cdf0e10cSrcweir                 bNameOk=sal_True;
1867cdf0e10cSrcweir             } else {
1868cdf0e10cSrcweir                 if (nCount==2) aName=aName1; // Pluralname setzen
1869cdf0e10cSrcweir                 if (bNameOk) {
1870cdf0e10cSrcweir                     XubString aStr;
1871cdf0e10cSrcweir                     pGrp->TakeObjNamePlural(aStr); // Bezeichnung der Gruppe holen
1872cdf0e10cSrcweir 
1873cdf0e10cSrcweir                     if(!aStr.Equals(aName))
1874cdf0e10cSrcweir                         bNameOk = sal_False;
1875cdf0e10cSrcweir                 }
1876cdf0e10cSrcweir             }
1877cdf0e10cSrcweir             sal_uIntPtr nDstCnt=pGrp->GetOrdNum();
1878cdf0e10cSrcweir             SdrObjList* pDstLst=pM->GetPageView()->GetObjList();
1879cdf0e10cSrcweir 
1880cdf0e10cSrcweir             // FIRST move contained objects to parent of group, so that
1881cdf0e10cSrcweir             // the contained objects are NOT migrated to the UNDO-ItemPool
1882cdf0e10cSrcweir             // when AddUndo(new SdrUndoDelObj(*pGrp)) is called.
1883cdf0e10cSrcweir             sal_uIntPtr nAnz=pSrcLst->GetObjCount();
1884cdf0e10cSrcweir             sal_uIntPtr no;
1885cdf0e10cSrcweir 
1886cdf0e10cSrcweir             if( bUndo )
1887cdf0e10cSrcweir             {
1888cdf0e10cSrcweir                 for (no=nAnz; no>0;)
1889cdf0e10cSrcweir                 {
1890cdf0e10cSrcweir                     no--;
1891cdf0e10cSrcweir                     SdrObject* pObj=pSrcLst->GetObj(no);
1892cdf0e10cSrcweir                     AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoRemoveObject(*pObj));
1893cdf0e10cSrcweir                 }
1894cdf0e10cSrcweir             }
1895cdf0e10cSrcweir             for (no=0; no<nAnz; no++)
1896cdf0e10cSrcweir             {
1897cdf0e10cSrcweir                 SdrObject* pObj=pSrcLst->RemoveObject(0);
1898cdf0e10cSrcweir                 SdrInsertReason aReason(SDRREASON_VIEWCALL,pGrp);
1899cdf0e10cSrcweir                 pDstLst->InsertObject(pObj,nDstCnt,&aReason);
1900cdf0e10cSrcweir                 if( bUndo )
1901cdf0e10cSrcweir                     AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoInsertObject(*pObj,true));
1902cdf0e10cSrcweir                 nDstCnt++;
1903cdf0e10cSrcweir                 // Kein SortCheck beim einfuegen in die MarkList, denn das
1904cdf0e10cSrcweir                 // wuerde wg. pObj->GetOrdNum() jedesmal ein RecalcOrdNums()
1905cdf0e10cSrcweir                 // provozieren:
1906cdf0e10cSrcweir                 aNewMark.InsertEntry(SdrMark(pObj,pM->GetPageView()),sal_False);
1907cdf0e10cSrcweir             }
1908cdf0e10cSrcweir 
1909cdf0e10cSrcweir             if( bUndo )
1910cdf0e10cSrcweir             {
1911cdf0e10cSrcweir                 // Now it is safe to add the delete-UNDO which trigers the
1912cdf0e10cSrcweir                 // MigrateItemPool now only for itself, not for the subobjects.
1913cdf0e10cSrcweir                 // nDstCnt is right, because previous inserts move group
1914cdf0e10cSrcweir                 // object deeper and increase nDstCnt.
1915cdf0e10cSrcweir                 AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoDeleteObject(*pGrp));
1916cdf0e10cSrcweir             }
1917cdf0e10cSrcweir             pDstLst->RemoveObject(nDstCnt);
1918cdf0e10cSrcweir 
1919cdf0e10cSrcweir             if( !bUndo )
1920cdf0e10cSrcweir                 SdrObject::Free(pGrp);
1921cdf0e10cSrcweir 
1922cdf0e10cSrcweir             GetMarkedObjectListWriteAccess().DeleteMark(nm);
1923cdf0e10cSrcweir         }
1924cdf0e10cSrcweir     }
1925cdf0e10cSrcweir     if (nCount!=0)
1926cdf0e10cSrcweir     {
1927cdf0e10cSrcweir         if (!bNameOk)
1928cdf0e10cSrcweir             aName=ImpGetResStr(STR_ObjNamePluralGRUP); // Oberbegriff Gruppenobjekte verwenden, wenn verschiedene Objekte.
1929cdf0e10cSrcweir         SetUndoComment(ImpGetResStr(STR_EditUngroup),aName);
1930cdf0e10cSrcweir     }
1931cdf0e10cSrcweir 
1932cdf0e10cSrcweir     if( bUndo )
1933cdf0e10cSrcweir         EndUndo();
1934cdf0e10cSrcweir 
1935cdf0e10cSrcweir     if (nCount!=0)
1936cdf0e10cSrcweir     {
1937cdf0e10cSrcweir         GetMarkedObjectListWriteAccess().Merge(aNewMark,sal_True); // Durch das obige Einsortieren ist aNewMark genau verkehrtherum
1938cdf0e10cSrcweir         MarkListHasChanged();
1939cdf0e10cSrcweir     }
1940cdf0e10cSrcweir }
1941cdf0e10cSrcweir 
1942cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
1943cdf0e10cSrcweir //
1944cdf0e10cSrcweir //   ###   ###  #   # #   # ##### ####  #####   #####  ###    ####   ###  #  #   #
1945cdf0e10cSrcweir //  #   # #   # ##  # #   # #     #   #   #       #   #   #   #   # #   # #   # #
1946cdf0e10cSrcweir //  #     #   # # # # #   # ####  ####    #       #   #   #   ####  #   # #    #
1947cdf0e10cSrcweir //  #   # #   # #  ##  # #  #     #   #   #       #   #   #   #     #   # #    #
1948cdf0e10cSrcweir //   ###   ###  #   #   #   ##### #   #   #       #    ###    #      ###  #### #
1949cdf0e10cSrcweir //
1950cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
1951cdf0e10cSrcweir 
ImpConvertOneObj(SdrObject * pObj,sal_Bool bPath,sal_Bool bLineToArea)1952cdf0e10cSrcweir SdrObject* SdrEditView::ImpConvertOneObj(SdrObject* pObj, sal_Bool bPath, sal_Bool bLineToArea)
1953cdf0e10cSrcweir {
1954cdf0e10cSrcweir     SdrObject* pNewObj = pObj->ConvertToPolyObj(bPath, bLineToArea);
1955cdf0e10cSrcweir     if (pNewObj!=NULL)
1956cdf0e10cSrcweir     {
1957cdf0e10cSrcweir         SdrObjList* pOL=pObj->GetObjList();
1958cdf0e10cSrcweir         DBG_ASSERT(pOL!=NULL,"ConvertTo: Obj liefert keine ObjList");
1959cdf0e10cSrcweir         if (pOL!=NULL)
1960cdf0e10cSrcweir         {
1961cdf0e10cSrcweir             const bool bUndo = IsUndoEnabled();
1962cdf0e10cSrcweir             if( bUndo )
1963cdf0e10cSrcweir                 AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoReplaceObject(*pObj,*pNewObj));
1964cdf0e10cSrcweir 
1965cdf0e10cSrcweir             pOL->ReplaceObject(pNewObj,pObj->GetOrdNum());
1966cdf0e10cSrcweir 
1967cdf0e10cSrcweir             if( !bUndo )
1968cdf0e10cSrcweir                 SdrObject::Free(pObj);
1969cdf0e10cSrcweir         }
1970cdf0e10cSrcweir     }
1971cdf0e10cSrcweir     return pNewObj;
1972cdf0e10cSrcweir }
1973cdf0e10cSrcweir 
ImpConvertTo(sal_Bool bPath,sal_Bool bLineToArea)1974cdf0e10cSrcweir void SdrEditView::ImpConvertTo(sal_Bool bPath, sal_Bool bLineToArea)
1975cdf0e10cSrcweir {
1976cdf0e10cSrcweir     sal_Bool bMrkChg=sal_False;
1977cdf0e10cSrcweir     sal_Bool bModChg=sal_False;
1978cdf0e10cSrcweir     if (AreObjectsMarked()) {
1979cdf0e10cSrcweir         sal_uIntPtr nMarkAnz=GetMarkedObjectCount();
1980cdf0e10cSrcweir         sal_uInt16 nDscrID=0;
1981cdf0e10cSrcweir         if(bLineToArea)
1982cdf0e10cSrcweir         {
1983cdf0e10cSrcweir             if(nMarkAnz == 1)
1984cdf0e10cSrcweir                 nDscrID = STR_EditConvToContour;
1985cdf0e10cSrcweir             else
1986cdf0e10cSrcweir                 nDscrID = STR_EditConvToContours;
1987cdf0e10cSrcweir 
1988cdf0e10cSrcweir             BegUndo(ImpGetResStr(nDscrID), GetDescriptionOfMarkedObjects());
1989cdf0e10cSrcweir         }
1990cdf0e10cSrcweir         else
1991cdf0e10cSrcweir         {
1992cdf0e10cSrcweir             if (bPath) {
1993cdf0e10cSrcweir                 if (nMarkAnz==1) nDscrID=STR_EditConvToCurve;
1994cdf0e10cSrcweir                 else nDscrID=STR_EditConvToCurves;
1995cdf0e10cSrcweir                 BegUndo(ImpGetResStr(nDscrID),GetDescriptionOfMarkedObjects(),SDRREPFUNC_OBJ_CONVERTTOPATH);
1996cdf0e10cSrcweir             } else {
1997cdf0e10cSrcweir                 if (nMarkAnz==1) nDscrID=STR_EditConvToPoly;
1998cdf0e10cSrcweir                 else nDscrID=STR_EditConvToPolys;
1999cdf0e10cSrcweir                 BegUndo(ImpGetResStr(nDscrID),GetDescriptionOfMarkedObjects(),SDRREPFUNC_OBJ_CONVERTTOPOLY);
2000cdf0e10cSrcweir             }
2001cdf0e10cSrcweir         }
2002cdf0e10cSrcweir         for (sal_uIntPtr nm=nMarkAnz; nm>0;) {
2003cdf0e10cSrcweir             nm--;
2004cdf0e10cSrcweir             SdrMark* pM=GetSdrMarkByIndex(nm);
2005cdf0e10cSrcweir             SdrObject* pObj=pM->GetMarkedSdrObj();
2006cdf0e10cSrcweir             SdrPageView* pPV=pM->GetPageView();
2007cdf0e10cSrcweir             if (pObj->IsGroupObject() && !pObj->Is3DObj()) {
2008cdf0e10cSrcweir                 SdrObject* pGrp=pObj;
2009cdf0e10cSrcweir                 SdrObjListIter aIter(*pGrp,IM_DEEPNOGROUPS);
2010cdf0e10cSrcweir                 while (aIter.IsMore()) {
2011cdf0e10cSrcweir                     pObj=aIter.Next();
2012cdf0e10cSrcweir                     if (ImpConvertOneObj(pObj,bPath,bLineToArea)) bModChg=sal_True;
2013cdf0e10cSrcweir                 }
2014cdf0e10cSrcweir             } else {
2015cdf0e10cSrcweir                 SdrObject* pNewObj=ImpConvertOneObj(pObj,bPath,bLineToArea);
2016cdf0e10cSrcweir                 if (pNewObj!=NULL) {
2017cdf0e10cSrcweir                     bModChg=sal_True;
2018cdf0e10cSrcweir                     bMrkChg=sal_True;
2019cdf0e10cSrcweir                     GetMarkedObjectListWriteAccess().ReplaceMark(SdrMark(pNewObj,pPV),nm);
2020cdf0e10cSrcweir                 }
2021cdf0e10cSrcweir             }
2022cdf0e10cSrcweir         }
2023cdf0e10cSrcweir         EndUndo();
2024cdf0e10cSrcweir         if (bMrkChg) AdjustMarkHdl();
2025cdf0e10cSrcweir         if (bMrkChg) MarkListHasChanged();
2026cdf0e10cSrcweir     }
2027cdf0e10cSrcweir }
2028cdf0e10cSrcweir 
ConvertMarkedToPathObj(sal_Bool bLineToArea)2029cdf0e10cSrcweir void SdrEditView::ConvertMarkedToPathObj(sal_Bool bLineToArea)
2030cdf0e10cSrcweir {
2031cdf0e10cSrcweir     ImpConvertTo(sal_True, bLineToArea);
2032cdf0e10cSrcweir }
2033cdf0e10cSrcweir 
ConvertMarkedToPolyObj(sal_Bool bLineToArea)2034cdf0e10cSrcweir void SdrEditView::ConvertMarkedToPolyObj(sal_Bool bLineToArea)
2035cdf0e10cSrcweir {
2036cdf0e10cSrcweir     ImpConvertTo(sal_False, bLineToArea);
2037cdf0e10cSrcweir }
2038cdf0e10cSrcweir 
2039cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
2040cdf0e10cSrcweir //
2041cdf0e10cSrcweir //  #   # ##### #####  ###  ##### # #    #####      # #   # ####   ###  ####  #####
2042cdf0e10cSrcweir //  ## ## #       #   #   # #     # #    #          # ## ## #   # #   # #   #   #
2043cdf0e10cSrcweir //  # # # ####    #   ##### ###   # #    ####  ###  # # # # ####  #   # ####    #
2044cdf0e10cSrcweir //  #   # #       #   #   # #     # #    #          # #   # #     #   # #   #   #
2045cdf0e10cSrcweir //  #   # #####   #   #   # #     # #### #####      # #   # #      ###  #   #   #
2046cdf0e10cSrcweir //
2047cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
2048cdf0e10cSrcweir 
DoImportMarkedMtf(SvdProgressInfo * pProgrInfo)2049cdf0e10cSrcweir void SdrEditView::DoImportMarkedMtf(SvdProgressInfo *pProgrInfo)
2050cdf0e10cSrcweir {
2051cdf0e10cSrcweir     const bool bUndo = IsUndoEnabled();
2052cdf0e10cSrcweir 
2053cdf0e10cSrcweir     if( bUndo )
2054cdf0e10cSrcweir         BegUndo(String(), String(), SDRREPFUNC_OBJ_IMPORTMTF);
2055cdf0e10cSrcweir 
2056cdf0e10cSrcweir     SortMarkedObjects();
2057cdf0e10cSrcweir     SdrMarkList aForTheDescription;
2058cdf0e10cSrcweir     SdrMarkList aNewMarked;
2059cdf0e10cSrcweir     sal_uIntPtr nAnz=GetMarkedObjectCount();
2060cdf0e10cSrcweir 
2061cdf0e10cSrcweir     for (sal_uIntPtr nm=nAnz; nm>0;)
2062cdf0e10cSrcweir     { // Undo Objekte fuer alle neuen Objekte erzeugen
2063cdf0e10cSrcweir         // zwischen den Metafiles auf Abbruch testen
2064cdf0e10cSrcweir         if( pProgrInfo != NULL )
2065cdf0e10cSrcweir         {
2066cdf0e10cSrcweir             pProgrInfo->SetNextObject();
2067cdf0e10cSrcweir             if(!pProgrInfo->ReportActions(0))
2068cdf0e10cSrcweir                 break;
2069cdf0e10cSrcweir         }
2070cdf0e10cSrcweir 
2071cdf0e10cSrcweir         nm--;
2072cdf0e10cSrcweir         SdrMark*     pM=GetSdrMarkByIndex(nm);
2073cdf0e10cSrcweir         SdrObject*   pObj=pM->GetMarkedSdrObj();
2074cdf0e10cSrcweir         SdrPageView* pPV=pM->GetPageView();
2075cdf0e10cSrcweir         SdrObjList*  pOL=pObj->GetObjList();
2076cdf0e10cSrcweir         sal_uIntPtr        nInsPos=pObj->GetOrdNum()+1;
2077cdf0e10cSrcweir         SdrGrafObj*  pGraf=PTR_CAST(SdrGrafObj,pObj);
2078cdf0e10cSrcweir         SdrOle2Obj*  pOle2=PTR_CAST(SdrOle2Obj,pObj);
2079cdf0e10cSrcweir         sal_uIntPtr        nInsAnz=0;
2080dfe9de19SHerbert Dürr         Rectangle aLogicRect;
2081dfe9de19SHerbert Dürr 
2082ddde725dSArmin Le Grand         if(pGraf && (pGraf->HasGDIMetaFile() || pGraf->isEmbeddedSvg()))
2083ddde725dSArmin Le Grand         {
2084ddde725dSArmin Le Grand             GDIMetaFile aMetaFile;
2085ddde725dSArmin Le Grand 
2086ddde725dSArmin Le Grand             if(pGraf->HasGDIMetaFile())
2087ddde725dSArmin Le Grand             {
20888718d260SArmin Le Grand                 aMetaFile = pGraf->GetTransformedGraphic(SDRGRAFOBJ_TRANSFORMATTR_COLOR|SDRGRAFOBJ_TRANSFORMATTR_MIRROR).GetGDIMetaFile();
2089ddde725dSArmin Le Grand             }
2090ddde725dSArmin Le Grand             else if(pGraf->isEmbeddedSvg())
2091ddde725dSArmin Le Grand             {
2092ddde725dSArmin Le Grand                 aMetaFile = pGraf->getMetafileFromEmbeddedSvg();
2093ddde725dSArmin Le Grand             }
2094ddde725dSArmin Le Grand 
2095ddde725dSArmin Le Grand             if(aMetaFile.GetActionCount())
2096cdf0e10cSrcweir             {
2097dfe9de19SHerbert Dürr                 aLogicRect = pGraf->GetLogicRect();
20988718d260SArmin Le Grand                 ImpSdrGDIMetaFileImport aFilter(*pMod, pObj->GetLayer(), aLogicRect);
2099ddde725dSArmin Le Grand                 nInsAnz = aFilter.DoImport(aMetaFile, *pOL, nInsPos, pProgrInfo);
2100ddde725dSArmin Le Grand             }
2101cdf0e10cSrcweir         }
2102cdf0e10cSrcweir         if ( pOle2!=NULL && pOle2->GetGraphic() )
2103cdf0e10cSrcweir         {
2104dfe9de19SHerbert Dürr             aLogicRect = pOle2->GetLogicRect();
21058718d260SArmin Le Grand             ImpSdrGDIMetaFileImport aFilter(*pMod, pObj->GetLayer(), aLogicRect);
2106cdf0e10cSrcweir             nInsAnz = aFilter.DoImport(pOle2->GetGraphic()->GetGDIMetaFile(), *pOL, nInsPos, pProgrInfo);
2107cdf0e10cSrcweir         }
2108cdf0e10cSrcweir         if (nInsAnz!=0)
2109cdf0e10cSrcweir         {
2110dfe9de19SHerbert Dürr             // transformation
2111dfe9de19SHerbert Dürr             GeoStat aGeoStat(pGraf ? pGraf->GetGeoStat() : pOle2->GetGeoStat());
2112cdf0e10cSrcweir             sal_uIntPtr nObj=nInsPos;
2113dfe9de19SHerbert Dürr 
2114dfe9de19SHerbert Dürr             if(aGeoStat.nShearWink)
2115dfe9de19SHerbert Dürr             {
2116dfe9de19SHerbert Dürr                 aGeoStat.RecalcTan();
2117dfe9de19SHerbert Dürr             }
2118dfe9de19SHerbert Dürr 
2119dfe9de19SHerbert Dürr             if(aGeoStat.nDrehWink)
2120dfe9de19SHerbert Dürr             {
2121dfe9de19SHerbert Dürr                 aGeoStat.RecalcSinCos();
2122dfe9de19SHerbert Dürr             }
2123dfe9de19SHerbert Dürr 
2124cdf0e10cSrcweir             for (sal_uIntPtr i=0; i<nInsAnz; i++)
2125cdf0e10cSrcweir             {
2126cdf0e10cSrcweir                 if( bUndo )
2127cdf0e10cSrcweir                     AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pOL->GetObj(nObj)));
2128cdf0e10cSrcweir 
2129cdf0e10cSrcweir                 // Neue MarkList pflegen
2130dfe9de19SHerbert Dürr                 SdrObject* pCandidate = pOL->GetObj(nObj);
2131dfe9de19SHerbert Dürr 
2132dfe9de19SHerbert Dürr                 // apply original transformation
2133dfe9de19SHerbert Dürr                 if(aGeoStat.nShearWink)
2134dfe9de19SHerbert Dürr                 {
2135dfe9de19SHerbert Dürr                     pCandidate->NbcShear(aLogicRect.TopLeft(), aGeoStat.nShearWink, aGeoStat.nTan, false);
2136dfe9de19SHerbert Dürr                 }
2137dfe9de19SHerbert Dürr 
2138dfe9de19SHerbert Dürr                 if(aGeoStat.nDrehWink)
2139dfe9de19SHerbert Dürr                 {
2140dfe9de19SHerbert Dürr                     pCandidate->NbcRotate(aLogicRect.TopLeft(), aGeoStat.nDrehWink, aGeoStat.nSin, aGeoStat.nCos);
2141dfe9de19SHerbert Dürr                 }
2142dfe9de19SHerbert Dürr 
2143dfe9de19SHerbert Dürr                 SdrMark aNewMark(pCandidate, pPV);
2144cdf0e10cSrcweir                 aNewMarked.InsertEntry(aNewMark);
2145cdf0e10cSrcweir 
2146cdf0e10cSrcweir                 nObj++;
2147cdf0e10cSrcweir             }
2148cdf0e10cSrcweir             aForTheDescription.InsertEntry(*pM);
2149cdf0e10cSrcweir 
2150cdf0e10cSrcweir             if( bUndo )
2151cdf0e10cSrcweir                 AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj));
2152cdf0e10cSrcweir 
2153cdf0e10cSrcweir             // Objekt aus selektion loesen und loeschen
2154cdf0e10cSrcweir             GetMarkedObjectListWriteAccess().DeleteMark(TryToFindMarkedObject(pObj));
2155cdf0e10cSrcweir             pOL->RemoveObject(nInsPos-1);
2156cdf0e10cSrcweir 
2157cdf0e10cSrcweir             if( !bUndo )
2158cdf0e10cSrcweir                 SdrObject::Free(pObj);
2159cdf0e10cSrcweir         }
2160cdf0e10cSrcweir     }
2161cdf0e10cSrcweir 
2162cdf0e10cSrcweir     // MarkObj... fehlt... jetzt nicht mehr (AW)
2163cdf0e10cSrcweir     if(aNewMarked.GetMarkCount())
2164cdf0e10cSrcweir     {
2165cdf0e10cSrcweir         // Neue Selektion bilden
2166cdf0e10cSrcweir         for(sal_uIntPtr a(0); a < aNewMarked.GetMarkCount(); a++)
2167cdf0e10cSrcweir         {
2168cdf0e10cSrcweir             GetMarkedObjectListWriteAccess().InsertEntry(*aNewMarked.GetMark(a));
2169cdf0e10cSrcweir         }
2170cdf0e10cSrcweir 
2171cdf0e10cSrcweir         SortMarkedObjects();
2172cdf0e10cSrcweir     }
2173cdf0e10cSrcweir 
2174cdf0e10cSrcweir     if( bUndo )
2175cdf0e10cSrcweir     {
2176cdf0e10cSrcweir         SetUndoComment(ImpGetResStr(STR_EditImportMtf),aForTheDescription.GetMarkDescription());
2177cdf0e10cSrcweir         EndUndo();
2178cdf0e10cSrcweir     }
2179cdf0e10cSrcweir }
2180