xref: /AOO41X/main/svx/source/svdraw/svdxcgv.cxx (revision bb18ee55e6364eb9cc0432c4c06984f8fc66fe0c)
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 <vector>
28cdf0e10cSrcweir #include <editeng/editeng.hxx>
29cdf0e10cSrcweir #include "svx/xexch.hxx"
30cdf0e10cSrcweir #include <svx/xflclit.hxx>
31cdf0e10cSrcweir #include <svx/svdxcgv.hxx>
32cdf0e10cSrcweir #include <svx/svdoutl.hxx>
33cdf0e10cSrcweir #include "svx/svditext.hxx"
34cdf0e10cSrcweir #include <svx/svdetc.hxx>
35cdf0e10cSrcweir #include <svx/svdundo.hxx>
36cdf0e10cSrcweir #include <svx/svdograf.hxx>
37cdf0e10cSrcweir #include <svx/svdoole2.hxx> // fuer kein OLE im SdrClipboardFormat
38cdf0e10cSrcweir #include <svx/svdorect.hxx>
39cdf0e10cSrcweir #include <svx/svdoedge.hxx> // fuer Konnektoren uebers Clipboard
40cdf0e10cSrcweir #include <svx/svdopage.hxx> // fuer Konnektoren uebers Clipboard
41cdf0e10cSrcweir #include <svx/svdpage.hxx>
42cdf0e10cSrcweir #include <svx/svdpagv.hxx>
43cdf0e10cSrcweir #include <svx/svdtrans.hxx> // Fuer GetMapFactor zum umskalieren bei PasteModel
44cdf0e10cSrcweir #include "svx/svdstr.hrc"   // Namen aus der Resource
45cdf0e10cSrcweir #include "svx/svdglob.hxx"  // StringCache
46cdf0e10cSrcweir #include "svx/xoutbmp.hxx"
47cdf0e10cSrcweir #include <vcl/metaact.hxx>
48cdf0e10cSrcweir #include <svl/poolitem.hxx>
49cdf0e10cSrcweir #include <svl/itempool.hxx>
50cdf0e10cSrcweir #include <tools/bigint.hxx>
51cdf0e10cSrcweir #include <sot/formats.hxx>
52cdf0e10cSrcweir 
53cdf0e10cSrcweir // #i13033#
54cdf0e10cSrcweir #include <clonelist.hxx>
55cdf0e10cSrcweir #include <vcl/virdev.hxx>
56cdf0e10cSrcweir 
57cdf0e10cSrcweir // b4967543
58cdf0e10cSrcweir #include <svl/style.hxx>
59cdf0e10cSrcweir 
60cdf0e10cSrcweir // #i72535#
61cdf0e10cSrcweir #include "fmobj.hxx"
62cdf0e10cSrcweir 
63cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
64cdf0e10cSrcweir 
65cdf0e10cSrcweir SdrExchangeView::SdrExchangeView(SdrModel* pModel1, OutputDevice* pOut):
66cdf0e10cSrcweir 	SdrObjEditView(pModel1,pOut)
67cdf0e10cSrcweir {
68cdf0e10cSrcweir }
69cdf0e10cSrcweir 
70cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
71cdf0e10cSrcweir 
72cdf0e10cSrcweir Point SdrExchangeView::GetViewCenter(const OutputDevice* pOut) const
73cdf0e10cSrcweir {
74cdf0e10cSrcweir 	Point aCenter;
75cdf0e10cSrcweir 	if (pOut==NULL)
76cdf0e10cSrcweir 	{
77cdf0e10cSrcweir 		pOut = GetFirstOutputDevice();
78cdf0e10cSrcweir 	}
79cdf0e10cSrcweir 	if (pOut!=NULL) {
80cdf0e10cSrcweir 		Point aOfs=pOut->GetMapMode().GetOrigin();
81cdf0e10cSrcweir 		Size aOutSiz=pOut->GetOutputSize();
82cdf0e10cSrcweir 		aOutSiz.Width()/=2;
83cdf0e10cSrcweir 		aOutSiz.Height()/=2;
84cdf0e10cSrcweir 		aCenter.X()=aOutSiz.Width() -aOfs.X();
85cdf0e10cSrcweir 		aCenter.Y()=aOutSiz.Height()-aOfs.Y();
86cdf0e10cSrcweir 	}
87cdf0e10cSrcweir 	return aCenter;
88cdf0e10cSrcweir }
89cdf0e10cSrcweir 
90cdf0e10cSrcweir Point SdrExchangeView::GetPastePos(SdrObjList* pLst, OutputDevice* pOut)
91cdf0e10cSrcweir {
92cdf0e10cSrcweir 	Point aP(GetViewCenter(pOut));
93cdf0e10cSrcweir 	SdrPage* pPg=NULL;
94cdf0e10cSrcweir 	if (pLst!=NULL) pPg=pLst->GetPage();
95cdf0e10cSrcweir 	if (pPg!=NULL) {
96cdf0e10cSrcweir 		Size aSiz(pPg->GetSize());
97cdf0e10cSrcweir 		aP.X()=aSiz.Width()/2;
98cdf0e10cSrcweir 		aP.Y()=aSiz.Height()/2;
99cdf0e10cSrcweir 	}
100cdf0e10cSrcweir 	return aP;
101cdf0e10cSrcweir }
102cdf0e10cSrcweir 
103cdf0e10cSrcweir sal_Bool SdrExchangeView::ImpLimitToWorkArea(Point& rPt) const
104cdf0e10cSrcweir {
105cdf0e10cSrcweir 	sal_Bool bRet(sal_False);
106cdf0e10cSrcweir 
107cdf0e10cSrcweir 	if(!aMaxWorkArea.IsEmpty())
108cdf0e10cSrcweir 	{
109cdf0e10cSrcweir 		if(rPt.X()<aMaxWorkArea.Left())
110cdf0e10cSrcweir 		{
111cdf0e10cSrcweir 			rPt.X() = aMaxWorkArea.Left();
112cdf0e10cSrcweir 			bRet = sal_True;
113cdf0e10cSrcweir 		}
114cdf0e10cSrcweir 
115cdf0e10cSrcweir 		if(rPt.X()>aMaxWorkArea.Right())
116cdf0e10cSrcweir 		{
117cdf0e10cSrcweir 			rPt.X() = aMaxWorkArea.Right();
118cdf0e10cSrcweir 			bRet = sal_True;
119cdf0e10cSrcweir 		}
120cdf0e10cSrcweir 
121cdf0e10cSrcweir 		if(rPt.Y()<aMaxWorkArea.Top())
122cdf0e10cSrcweir 		{
123cdf0e10cSrcweir 			rPt.Y() = aMaxWorkArea.Top();
124cdf0e10cSrcweir 			bRet = sal_True;
125cdf0e10cSrcweir 		}
126cdf0e10cSrcweir 
127cdf0e10cSrcweir 		if(rPt.Y()>aMaxWorkArea.Bottom())
128cdf0e10cSrcweir 		{
129cdf0e10cSrcweir 			rPt.Y() = aMaxWorkArea.Bottom();
130cdf0e10cSrcweir 			bRet = sal_True;
131cdf0e10cSrcweir 		}
132cdf0e10cSrcweir 	}
133cdf0e10cSrcweir 	return bRet;
134cdf0e10cSrcweir }
135cdf0e10cSrcweir 
136cdf0e10cSrcweir void SdrExchangeView::ImpGetPasteObjList(Point& /*rPos*/, SdrObjList*& rpLst)
137cdf0e10cSrcweir {
138cdf0e10cSrcweir 	if (rpLst==NULL)
139cdf0e10cSrcweir 	{
140cdf0e10cSrcweir 		SdrPageView* pPV = GetSdrPageView();
141cdf0e10cSrcweir 
142cdf0e10cSrcweir 		if (pPV!=NULL) {
143cdf0e10cSrcweir 			rpLst=pPV->GetObjList();
144cdf0e10cSrcweir 		}
145cdf0e10cSrcweir 	}
146cdf0e10cSrcweir }
147cdf0e10cSrcweir 
148cdf0e10cSrcweir sal_Bool SdrExchangeView::ImpGetPasteLayer(const SdrObjList* pObjList, SdrLayerID& rLayer) const
149cdf0e10cSrcweir {
150cdf0e10cSrcweir 	sal_Bool bRet=sal_False;
151cdf0e10cSrcweir 	rLayer=0;
152cdf0e10cSrcweir 	if (pObjList!=NULL) {
153cdf0e10cSrcweir 		const SdrPage* pPg=pObjList->GetPage();
154cdf0e10cSrcweir 		if (pPg!=NULL) {
155cdf0e10cSrcweir 			rLayer=pPg->GetLayerAdmin().GetLayerID(aAktLayer,sal_True);
156cdf0e10cSrcweir 			if (rLayer==SDRLAYER_NOTFOUND) rLayer=0;
157cdf0e10cSrcweir 			SdrPageView* pPV = GetSdrPageView();
158cdf0e10cSrcweir 			if (pPV!=NULL) {
159cdf0e10cSrcweir 				bRet=!pPV->GetLockedLayers().IsSet(rLayer) && pPV->GetVisibleLayers().IsSet(rLayer);
160cdf0e10cSrcweir 			}
161cdf0e10cSrcweir 		}
162cdf0e10cSrcweir 	}
163cdf0e10cSrcweir 	return bRet;
164cdf0e10cSrcweir }
165cdf0e10cSrcweir 
166cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
167cdf0e10cSrcweir 
168cdf0e10cSrcweir sal_Bool SdrExchangeView::Paste(const GDIMetaFile& rMtf, const Point& rPos, SdrObjList* pLst, sal_uInt32 nOptions)
169cdf0e10cSrcweir {
170cdf0e10cSrcweir 	Point aPos(rPos);
171cdf0e10cSrcweir 	ImpGetPasteObjList(aPos,pLst);
172cdf0e10cSrcweir 	ImpLimitToWorkArea( aPos );
173cdf0e10cSrcweir 	if (pLst==NULL) return sal_False;
174cdf0e10cSrcweir 	SdrLayerID nLayer;
175cdf0e10cSrcweir 	if (!ImpGetPasteLayer(pLst,nLayer)) return sal_False;
176cdf0e10cSrcweir 	sal_Bool bUnmark=(nOptions&(SDRINSERT_DONTMARK|SDRINSERT_ADDMARK))==0 && !IsTextEdit();
177cdf0e10cSrcweir 	if (bUnmark) UnmarkAllObj();
178cdf0e10cSrcweir 	SdrGrafObj* pObj=new SdrGrafObj(Graphic(rMtf));
179cdf0e10cSrcweir 	pObj->SetLayer(nLayer);
180cdf0e10cSrcweir 	ImpPasteObject(pObj,*pLst,aPos,rMtf.GetPrefSize(),rMtf.GetPrefMapMode(),nOptions);
181cdf0e10cSrcweir 	return sal_True;
182cdf0e10cSrcweir }
183cdf0e10cSrcweir 
184cdf0e10cSrcweir sal_Bool SdrExchangeView::Paste(const Bitmap& rBmp, const Point& rPos, SdrObjList* pLst, sal_uInt32 nOptions)
185cdf0e10cSrcweir {
186cdf0e10cSrcweir 	Point aPos(rPos);
187cdf0e10cSrcweir 	ImpGetPasteObjList(aPos,pLst);
188cdf0e10cSrcweir 	ImpLimitToWorkArea( aPos );
189cdf0e10cSrcweir 	if (pLst==NULL) return sal_False;
190cdf0e10cSrcweir 	SdrLayerID nLayer;
191cdf0e10cSrcweir 	if (!ImpGetPasteLayer(pLst,nLayer)) return sal_False;
192cdf0e10cSrcweir 	sal_Bool bUnmark=(nOptions&(SDRINSERT_DONTMARK|SDRINSERT_ADDMARK))==0 && !IsTextEdit();
193cdf0e10cSrcweir 	if (bUnmark) UnmarkAllObj();
194cdf0e10cSrcweir 	SdrGrafObj* pObj=new SdrGrafObj(Graphic(rBmp));
195cdf0e10cSrcweir 	pObj->SetLayer(nLayer);
196cdf0e10cSrcweir 	ImpPasteObject(pObj,*pLst,aPos,rBmp.GetSizePixel(),MapMode(MAP_PIXEL),nOptions);
197cdf0e10cSrcweir 	return sal_True;
198cdf0e10cSrcweir }
199cdf0e10cSrcweir 
200cdf0e10cSrcweir sal_Bool SdrExchangeView::Paste(const XubString& rStr, const Point& rPos, SdrObjList* pLst, sal_uInt32 nOptions)
201cdf0e10cSrcweir {
202cdf0e10cSrcweir 	if(!rStr.Len())
203cdf0e10cSrcweir 		return sal_False;
204cdf0e10cSrcweir 
205cdf0e10cSrcweir 	Point aPos(rPos);
206cdf0e10cSrcweir 	ImpGetPasteObjList(aPos,pLst);
207cdf0e10cSrcweir 	ImpLimitToWorkArea( aPos );
208cdf0e10cSrcweir 	if (pLst==NULL) return sal_False;
209cdf0e10cSrcweir 	SdrLayerID nLayer;
210cdf0e10cSrcweir 	if (!ImpGetPasteLayer(pLst,nLayer)) return sal_False;
211cdf0e10cSrcweir 	sal_Bool bUnmark=(nOptions&(SDRINSERT_DONTMARK|SDRINSERT_ADDMARK))==0 && !IsTextEdit();
212cdf0e10cSrcweir 	if (bUnmark) UnmarkAllObj();
213cdf0e10cSrcweir 	Rectangle aTextRect(0,0,500,500);
214cdf0e10cSrcweir 	SdrPage* pPage=pLst->GetPage();
215cdf0e10cSrcweir 	if (pPage!=NULL) {
216cdf0e10cSrcweir 		aTextRect.SetSize(pPage->GetSize());
217cdf0e10cSrcweir 	}
218cdf0e10cSrcweir 	SdrRectObj* pObj=new SdrRectObj(OBJ_TEXT,aTextRect);
219cdf0e10cSrcweir 	pObj->SetModel(pMod);
220cdf0e10cSrcweir 	pObj->SetLayer(nLayer);
221cdf0e10cSrcweir 	pObj->NbcSetText(rStr); // #32424# SetText vor SetAttr, weil SetAttr sonst unwirksam!
222cdf0e10cSrcweir 	if (pDefaultStyleSheet!=NULL) pObj->NbcSetStyleSheet(pDefaultStyleSheet, sal_False);
223cdf0e10cSrcweir 
224cdf0e10cSrcweir 	pObj->SetMergedItemSet(aDefaultAttr);
225cdf0e10cSrcweir 
226cdf0e10cSrcweir 	SfxItemSet aTempAttr(pMod->GetItemPool());  // Keine Fuellung oder Linie
227cdf0e10cSrcweir 	aTempAttr.Put(XLineStyleItem(XLINE_NONE));
228cdf0e10cSrcweir 	aTempAttr.Put(XFillStyleItem(XFILL_NONE));
229cdf0e10cSrcweir 
230cdf0e10cSrcweir 	pObj->SetMergedItemSet(aTempAttr);
231cdf0e10cSrcweir 
232cdf0e10cSrcweir 	pObj->FitFrameToTextSize();
233cdf0e10cSrcweir 	Size aSiz(pObj->GetLogicRect().GetSize());
234cdf0e10cSrcweir 	MapUnit eMap=pMod->GetScaleUnit();
235cdf0e10cSrcweir 	Fraction aMap=pMod->GetScaleFraction();
236cdf0e10cSrcweir 	ImpPasteObject(pObj,*pLst,aPos,aSiz,MapMode(eMap,Point(0,0),aMap,aMap),nOptions);
237cdf0e10cSrcweir 	return sal_True;
238cdf0e10cSrcweir }
239cdf0e10cSrcweir 
240cdf0e10cSrcweir sal_Bool SdrExchangeView::Paste(SvStream& rInput, const String& rBaseURL, sal_uInt16 eFormat, const Point& rPos, SdrObjList* pLst, sal_uInt32 nOptions)
241cdf0e10cSrcweir {
242cdf0e10cSrcweir 	Point aPos(rPos);
243cdf0e10cSrcweir 	ImpGetPasteObjList(aPos,pLst);
244cdf0e10cSrcweir 	ImpLimitToWorkArea( aPos );
245cdf0e10cSrcweir 	if (pLst==NULL) return sal_False;
246cdf0e10cSrcweir 	SdrLayerID nLayer;
247cdf0e10cSrcweir 	if (!ImpGetPasteLayer(pLst,nLayer)) return sal_False;
248cdf0e10cSrcweir 	sal_Bool bUnmark=(nOptions&(SDRINSERT_DONTMARK|SDRINSERT_ADDMARK))==0 && !IsTextEdit();
249cdf0e10cSrcweir 	if (bUnmark) UnmarkAllObj();
250cdf0e10cSrcweir 	Rectangle aTextRect(0,0,500,500);
251cdf0e10cSrcweir 	SdrPage* pPage=pLst->GetPage();
252cdf0e10cSrcweir 	if (pPage!=NULL) {
253cdf0e10cSrcweir 		aTextRect.SetSize(pPage->GetSize());
254cdf0e10cSrcweir 	}
255cdf0e10cSrcweir 	SdrRectObj* pObj=new SdrRectObj(OBJ_TEXT,aTextRect);
256cdf0e10cSrcweir 	pObj->SetModel(pMod);
257cdf0e10cSrcweir 	pObj->SetLayer(nLayer);
258cdf0e10cSrcweir 	if (pDefaultStyleSheet!=NULL) pObj->NbcSetStyleSheet(pDefaultStyleSheet, sal_False);
259cdf0e10cSrcweir 
260cdf0e10cSrcweir 	pObj->SetMergedItemSet(aDefaultAttr);
261cdf0e10cSrcweir 
262cdf0e10cSrcweir 	SfxItemSet aTempAttr(pMod->GetItemPool());  // Keine Fuellung oder Linie
263cdf0e10cSrcweir 	aTempAttr.Put(XLineStyleItem(XLINE_NONE));
264cdf0e10cSrcweir 	aTempAttr.Put(XFillStyleItem(XFILL_NONE));
265cdf0e10cSrcweir 
266cdf0e10cSrcweir 	pObj->SetMergedItemSet(aTempAttr);
267cdf0e10cSrcweir 
268cdf0e10cSrcweir     pObj->NbcSetText(rInput,rBaseURL,eFormat);
269cdf0e10cSrcweir 	pObj->FitFrameToTextSize();
270cdf0e10cSrcweir 	Size aSiz(pObj->GetLogicRect().GetSize());
271cdf0e10cSrcweir 	MapUnit eMap=pMod->GetScaleUnit();
272cdf0e10cSrcweir 	Fraction aMap=pMod->GetScaleFraction();
273cdf0e10cSrcweir 	ImpPasteObject(pObj,*pLst,aPos,aSiz,MapMode(eMap,Point(0,0),aMap,aMap),nOptions);
274cdf0e10cSrcweir 
275cdf0e10cSrcweir 	// b4967543
276cdf0e10cSrcweir 	if(pObj && pObj->GetModel() && pObj->GetOutlinerParaObject())
277cdf0e10cSrcweir 	{
278cdf0e10cSrcweir 		SdrOutliner& rOutliner = pObj->GetModel()->GetHitTestOutliner();
279cdf0e10cSrcweir 		rOutliner.SetText(*pObj->GetOutlinerParaObject());
280cdf0e10cSrcweir 
281cdf0e10cSrcweir 		if(1L == rOutliner.GetParagraphCount())
282cdf0e10cSrcweir 		{
283cdf0e10cSrcweir 			SfxStyleSheet* pCandidate = rOutliner.GetStyleSheet(0L);
284cdf0e10cSrcweir 
285cdf0e10cSrcweir 			if(pCandidate)
286cdf0e10cSrcweir 			{
287cdf0e10cSrcweir 				if(pObj->GetModel()->GetStyleSheetPool() == &pCandidate->GetPool())
288cdf0e10cSrcweir 				{
289cdf0e10cSrcweir 					pObj->NbcSetStyleSheet(pCandidate, sal_True);
290cdf0e10cSrcweir 				}
291cdf0e10cSrcweir 			}
292cdf0e10cSrcweir 		}
293cdf0e10cSrcweir 	}
294cdf0e10cSrcweir 
295cdf0e10cSrcweir 	return sal_True;
296cdf0e10cSrcweir }
297cdf0e10cSrcweir 
298cdf0e10cSrcweir sal_Bool SdrExchangeView::Paste(const SdrModel& rMod, const Point& rPos, SdrObjList* pLst, sal_uInt32 nOptions)
299cdf0e10cSrcweir {
300cdf0e10cSrcweir 	const SdrModel* pSrcMod=&rMod;
301cdf0e10cSrcweir 	if (pSrcMod==pMod)
302cdf0e10cSrcweir 		return sal_False; // na so geht's ja nun nicht
303cdf0e10cSrcweir 
304cdf0e10cSrcweir 	const bool bUndo = IsUndoEnabled();
305cdf0e10cSrcweir 
306cdf0e10cSrcweir 	if( bUndo )
307cdf0e10cSrcweir 		BegUndo(ImpGetResStr(STR_ExchangePaste));
308cdf0e10cSrcweir 
309cdf0e10cSrcweir 	if( mxSelectionController.is() && mxSelectionController->PasteObjModel( rMod ) )
310cdf0e10cSrcweir 	{
311cdf0e10cSrcweir 		if( bUndo )
312cdf0e10cSrcweir 			EndUndo();
313cdf0e10cSrcweir 		return sal_True;
314cdf0e10cSrcweir 	}
315cdf0e10cSrcweir 
316cdf0e10cSrcweir 	Point aPos(rPos);
317cdf0e10cSrcweir 	ImpGetPasteObjList(aPos,pLst);
318cdf0e10cSrcweir 	SdrPageView* pMarkPV=NULL;
319cdf0e10cSrcweir 	SdrPageView* pPV = GetSdrPageView();
320cdf0e10cSrcweir 
321cdf0e10cSrcweir 	if(pPV)
322cdf0e10cSrcweir 	{
323cdf0e10cSrcweir 		if ( pPV->GetObjList() == pLst )
324cdf0e10cSrcweir 			pMarkPV=pPV;
325cdf0e10cSrcweir 	}
326cdf0e10cSrcweir 
327cdf0e10cSrcweir 	ImpLimitToWorkArea( aPos );
328cdf0e10cSrcweir 	if (pLst==NULL)
329cdf0e10cSrcweir 		return sal_False;
330cdf0e10cSrcweir 
331cdf0e10cSrcweir 	sal_Bool bUnmark=(nOptions&(SDRINSERT_DONTMARK|SDRINSERT_ADDMARK))==0 && !IsTextEdit();
332cdf0e10cSrcweir 	if (bUnmark)
333cdf0e10cSrcweir 		UnmarkAllObj();
334cdf0e10cSrcweir 
335cdf0e10cSrcweir 	// evtl. umskalieren bei unterschiedlicher MapUnit am Model
336cdf0e10cSrcweir 	// Dafuer erstmal die Faktoren berechnen
337cdf0e10cSrcweir 	MapUnit eSrcUnit=pSrcMod->GetScaleUnit();
338cdf0e10cSrcweir 	MapUnit eDstUnit=pMod->GetScaleUnit();
339cdf0e10cSrcweir 	sal_Bool bResize=eSrcUnit!=eDstUnit;
340cdf0e10cSrcweir 	Fraction xResize,yResize;
341cdf0e10cSrcweir 	Point aPt0;
342cdf0e10cSrcweir 	if (bResize)
343cdf0e10cSrcweir 	{
344cdf0e10cSrcweir 		FrPair aResize(GetMapFactor(eSrcUnit,eDstUnit));
345cdf0e10cSrcweir 		xResize=aResize.X();
346cdf0e10cSrcweir 		yResize=aResize.Y();
347cdf0e10cSrcweir 	}
348cdf0e10cSrcweir 	SdrObjList*  pDstLst=pLst;
349cdf0e10cSrcweir 	sal_uInt16 nPg,nPgAnz=pSrcMod->GetPageCount();
350cdf0e10cSrcweir 	for (nPg=0; nPg<nPgAnz; nPg++)
351cdf0e10cSrcweir 	{
352cdf0e10cSrcweir 		const SdrPage* pSrcPg=pSrcMod->GetPage(nPg);
353cdf0e10cSrcweir 
354cdf0e10cSrcweir 		// #104148# Use SnapRect, not BoundRect here
355cdf0e10cSrcweir 		Rectangle aR=pSrcPg->GetAllObjSnapRect();
356cdf0e10cSrcweir 
357cdf0e10cSrcweir 		if (bResize)
358cdf0e10cSrcweir 			ResizeRect(aR,aPt0,xResize,yResize);
359cdf0e10cSrcweir 		Point aDist(aPos-aR.Center());
360cdf0e10cSrcweir 		Size  aSiz(aDist.X(),aDist.Y());
361cdf0e10cSrcweir 		//sal_uIntPtr nDstObjAnz0=pDstLst->GetObjCount();
362cdf0e10cSrcweir 		sal_uIntPtr nCloneErrCnt=0;
363cdf0e10cSrcweir 		sal_uIntPtr nOb,nObAnz=pSrcPg->GetObjCount();
364cdf0e10cSrcweir 		sal_Bool bMark=pMarkPV!=NULL && !IsTextEdit() && (nOptions&SDRINSERT_DONTMARK)==0;
365cdf0e10cSrcweir 
366cdf0e10cSrcweir 		// #i13033#
367cdf0e10cSrcweir 		// New mechanism to re-create the connections of cloned connectors
368cdf0e10cSrcweir 		CloneList aCloneList;
369cdf0e10cSrcweir 
370cdf0e10cSrcweir 		for (nOb=0; nOb<nObAnz; nOb++)
371cdf0e10cSrcweir 		{
372cdf0e10cSrcweir 			const SdrObject* pSrcOb=pSrcPg->GetObj(nOb);
373cdf0e10cSrcweir 
374cdf0e10cSrcweir 			// #116235#
375cdf0e10cSrcweir 			SdrObject* pNeuObj = pSrcOb->Clone();
376cdf0e10cSrcweir 
377cdf0e10cSrcweir 			if (pNeuObj!=NULL)
378cdf0e10cSrcweir 			{
379cdf0e10cSrcweir 				if(bResize)
380cdf0e10cSrcweir 				{
381cdf0e10cSrcweir 					pNeuObj->GetModel()->SetPasteResize(sal_True); // #51139#
382cdf0e10cSrcweir 					pNeuObj->NbcResize(aPt0,xResize,yResize);
383cdf0e10cSrcweir 					pNeuObj->GetModel()->SetPasteResize(sal_False); // #51139#
384cdf0e10cSrcweir 				}
385cdf0e10cSrcweir 
386cdf0e10cSrcweir 				// #i39861#
387cdf0e10cSrcweir 				pNeuObj->SetModel(pDstLst->GetModel());
388cdf0e10cSrcweir 				pNeuObj->SetPage(pDstLst->GetPage());
389cdf0e10cSrcweir 
390cdf0e10cSrcweir 				pNeuObj->NbcMove(aSiz);
391cdf0e10cSrcweir 
392cdf0e10cSrcweir 				const SdrPage* pPg = pDstLst->GetPage();
393cdf0e10cSrcweir 
394cdf0e10cSrcweir 				if(pPg)
395cdf0e10cSrcweir 				{
396cdf0e10cSrcweir 					// #i72535#
397cdf0e10cSrcweir 					const SdrLayerAdmin& rAd = pPg->GetLayerAdmin();
398cdf0e10cSrcweir 					SdrLayerID nLayer(0);
399cdf0e10cSrcweir 
400cdf0e10cSrcweir 					if(pNeuObj->ISA(FmFormObj))
401cdf0e10cSrcweir 					{
402cdf0e10cSrcweir 						// for FormControls, force to form layer
403cdf0e10cSrcweir 						nLayer = rAd.GetLayerID(rAd.GetControlLayerName(), true);
404cdf0e10cSrcweir 					}
405cdf0e10cSrcweir 					else
406cdf0e10cSrcweir 					{
407cdf0e10cSrcweir 						nLayer = rAd.GetLayerID(aAktLayer, sal_True);
408cdf0e10cSrcweir 					}
409cdf0e10cSrcweir 
410cdf0e10cSrcweir 					if(SDRLAYER_NOTFOUND == nLayer)
411cdf0e10cSrcweir 					{
412cdf0e10cSrcweir 						nLayer = 0;
413cdf0e10cSrcweir 					}
414cdf0e10cSrcweir 
415cdf0e10cSrcweir 					pNeuObj->SetLayer(nLayer);
416cdf0e10cSrcweir 				}
417cdf0e10cSrcweir 
418cdf0e10cSrcweir 				SdrInsertReason aReason(SDRREASON_VIEWCALL);
419cdf0e10cSrcweir 				pDstLst->InsertObject(pNeuObj,CONTAINER_APPEND,&aReason);
420cdf0e10cSrcweir 
421cdf0e10cSrcweir 				if( bUndo )
422cdf0e10cSrcweir 					AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pNeuObj));
423cdf0e10cSrcweir 
424cdf0e10cSrcweir 				if (bMark) {
425cdf0e10cSrcweir 					// Markhandles noch nicht sofort setzen!
426cdf0e10cSrcweir 					// Das erledigt das ModelHasChanged der MarkView.
427cdf0e10cSrcweir 					MarkObj(pNeuObj,pMarkPV,sal_False,sal_True);
428cdf0e10cSrcweir 				}
429cdf0e10cSrcweir 
430cdf0e10cSrcweir 				// #i13033#
431cdf0e10cSrcweir 				aCloneList.AddPair(pSrcOb, pNeuObj);
432cdf0e10cSrcweir 			}
433cdf0e10cSrcweir 			else
434cdf0e10cSrcweir 			{
435cdf0e10cSrcweir 				nCloneErrCnt++;
436cdf0e10cSrcweir 			}
437cdf0e10cSrcweir 		}
438cdf0e10cSrcweir 
439cdf0e10cSrcweir 		// #i13033#
440cdf0e10cSrcweir 		// New mechanism to re-create the connections of cloned connectors
441cdf0e10cSrcweir 		aCloneList.CopyConnections();
442cdf0e10cSrcweir 
443cdf0e10cSrcweir 		if(0L != nCloneErrCnt)
444cdf0e10cSrcweir 		{
445cdf0e10cSrcweir #ifdef DBG_UTIL
446cdf0e10cSrcweir 			ByteString aStr("SdrExchangeView::Paste(): Fehler beim Clonen ");
447cdf0e10cSrcweir 
448cdf0e10cSrcweir 			if(nCloneErrCnt == 1)
449cdf0e10cSrcweir 			{
450cdf0e10cSrcweir 				aStr += "eines Zeichenobjekts.";
451cdf0e10cSrcweir 			}
452cdf0e10cSrcweir 			else
453cdf0e10cSrcweir 			{
454cdf0e10cSrcweir 				aStr += "von ";
455cdf0e10cSrcweir 				aStr += ByteString::CreateFromInt32( nCloneErrCnt );
456cdf0e10cSrcweir 				aStr += " Zeichenobjekten.";
457cdf0e10cSrcweir 			}
458cdf0e10cSrcweir 
459cdf0e10cSrcweir 			aStr += " Objektverbindungen werden nicht mitkopiert.";
460cdf0e10cSrcweir 
461cdf0e10cSrcweir 			DBG_ERROR(aStr.GetBuffer());
462cdf0e10cSrcweir #endif
463cdf0e10cSrcweir 		}
464cdf0e10cSrcweir 	}
465cdf0e10cSrcweir 
466cdf0e10cSrcweir 	if( bUndo )
467cdf0e10cSrcweir 		EndUndo();
468cdf0e10cSrcweir 
469cdf0e10cSrcweir 	return sal_True;
470cdf0e10cSrcweir }
471cdf0e10cSrcweir 
472cdf0e10cSrcweir sal_Bool SdrExchangeView::IsExchangeFormatSupported(sal_uIntPtr nFormat) const
473cdf0e10cSrcweir {
474cdf0e10cSrcweir     return( FORMAT_PRIVATE == nFormat ||
475cdf0e10cSrcweir 			FORMAT_GDIMETAFILE == nFormat ||
476cdf0e10cSrcweir 			FORMAT_BITMAP == nFormat ||
477cdf0e10cSrcweir 			FORMAT_RTF == nFormat ||
478cdf0e10cSrcweir 			FORMAT_STRING == nFormat ||
479cdf0e10cSrcweir 			SOT_FORMATSTR_ID_DRAWING == nFormat ||
480cdf0e10cSrcweir 			SOT_FORMATSTR_ID_EDITENGINE == nFormat );
481cdf0e10cSrcweir }
482cdf0e10cSrcweir 
483cdf0e10cSrcweir void SdrExchangeView::ImpPasteObject(SdrObject* pObj, SdrObjList& rLst, const Point& rCenter, const Size& rSiz, const MapMode& rMap, sal_uInt32 nOptions)
484cdf0e10cSrcweir {
485cdf0e10cSrcweir 	BigInt nSizX(rSiz.Width());
486cdf0e10cSrcweir 	BigInt nSizY(rSiz.Height());
487cdf0e10cSrcweir 	MapUnit eSrcMU=rMap.GetMapUnit();
488cdf0e10cSrcweir 	MapUnit eDstMU=pMod->GetScaleUnit();
489cdf0e10cSrcweir 	FrPair aMapFact(GetMapFactor(eSrcMU,eDstMU));
490cdf0e10cSrcweir 	Fraction aDstFr(pMod->GetScaleFraction());
491cdf0e10cSrcweir 	nSizX*=aMapFact.X().GetNumerator();
492cdf0e10cSrcweir 	nSizX*=rMap.GetScaleX().GetNumerator();
493cdf0e10cSrcweir 	nSizX*=aDstFr.GetDenominator();
494cdf0e10cSrcweir 	nSizX/=aMapFact.X().GetDenominator();
495cdf0e10cSrcweir 	nSizX/=rMap.GetScaleX().GetDenominator();
496cdf0e10cSrcweir 	nSizX/=aDstFr.GetNumerator();
497cdf0e10cSrcweir 	nSizY*=aMapFact.Y().GetNumerator();
498cdf0e10cSrcweir 	nSizY*=rMap.GetScaleY().GetNumerator();
499cdf0e10cSrcweir 	nSizX*=aDstFr.GetDenominator();
500cdf0e10cSrcweir 	nSizY/=aMapFact.Y().GetDenominator();
501cdf0e10cSrcweir 	nSizY/=rMap.GetScaleY().GetDenominator();
502cdf0e10cSrcweir 	nSizY/=aDstFr.GetNumerator();
503cdf0e10cSrcweir 	long xs=nSizX;
504cdf0e10cSrcweir 	long ys=nSizY;
505cdf0e10cSrcweir 	Point aPos(rCenter.X()-xs/2,rCenter.Y()-ys/2);
506cdf0e10cSrcweir 	Rectangle aR(aPos.X(),aPos.Y(),aPos.X()+xs,aPos.Y()+ys);
507cdf0e10cSrcweir 	pObj->SetLogicRect(aR);
508cdf0e10cSrcweir 	SdrInsertReason aReason(SDRREASON_VIEWCALL);
509cdf0e10cSrcweir 	rLst.InsertObject(pObj,CONTAINER_APPEND,&aReason);
510cdf0e10cSrcweir 
511cdf0e10cSrcweir 	if( IsUndoEnabled() )
512cdf0e10cSrcweir 		AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pObj));
513cdf0e10cSrcweir 
514cdf0e10cSrcweir 	SdrPageView* pMarkPV=NULL;
515cdf0e10cSrcweir 	SdrPageView* pPV = GetSdrPageView();
516cdf0e10cSrcweir 
517cdf0e10cSrcweir 	if(pPV)
518cdf0e10cSrcweir 	{
519cdf0e10cSrcweir 		if (pPV->GetObjList()==&rLst)
520cdf0e10cSrcweir 			pMarkPV=pPV;
521cdf0e10cSrcweir 	}
522cdf0e10cSrcweir 
523cdf0e10cSrcweir 	sal_Bool bMark=pMarkPV!=NULL && !IsTextEdit() && (nOptions&SDRINSERT_DONTMARK)==0;
524cdf0e10cSrcweir 	if (bMark)
525cdf0e10cSrcweir 	{ // Obj in der ersten gefundenen PageView markieren
526cdf0e10cSrcweir 		MarkObj(pObj,pMarkPV);
527cdf0e10cSrcweir 	}
528cdf0e10cSrcweir }
529cdf0e10cSrcweir 
530cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
531cdf0e10cSrcweir 
532*bb18ee55SArmin Le Grand BitmapEx SdrExchangeView::GetMarkedObjBitmapEx(bool bNoVDevIfOneBmpMarked) const
533cdf0e10cSrcweir {
534ddde725dSArmin Le Grand 	BitmapEx aBmp;
535cdf0e10cSrcweir 
536cdf0e10cSrcweir 	if( AreObjectsMarked() )
537cdf0e10cSrcweir 	{
538ddde725dSArmin Le Grand         if(1 == GetMarkedObjectCount())
539ddde725dSArmin Le Grand         {
540cdf0e10cSrcweir             if(bNoVDevIfOneBmpMarked)
541cdf0e10cSrcweir             {
542cdf0e10cSrcweir                 SdrObject*	pGrafObjTmp	= GetMarkedObjectByIndex( 0 );
543cdf0e10cSrcweir                 SdrGrafObj*	pGrafObj = ( GetMarkedObjectCount() == 1 ) ? PTR_CAST( SdrGrafObj, pGrafObjTmp ) : NULL;
544cdf0e10cSrcweir 
545cdf0e10cSrcweir                 if( pGrafObj && ( pGrafObj->GetGraphicType() == GRAPHIC_BITMAP ) )
546ddde725dSArmin Le Grand                 {
547ddde725dSArmin Le Grand                     aBmp = pGrafObj->GetTransformedGraphic().GetBitmapEx();
548ddde725dSArmin Le Grand                 }
549ddde725dSArmin Le Grand             }
550ddde725dSArmin Le Grand             else
551ddde725dSArmin Le Grand             {
552ddde725dSArmin Le Grand                 const SdrGrafObj* pSdrGrafObj = dynamic_cast< const SdrGrafObj* >(GetMarkedObjectByIndex(0));
553ddde725dSArmin Le Grand 
554ddde725dSArmin Le Grand                 if(pSdrGrafObj && pSdrGrafObj->isEmbeddedSvg())
555ddde725dSArmin Le Grand                 {
556ddde725dSArmin Le Grand                     aBmp = pSdrGrafObj->GetGraphic().getSvgData()->getReplacement();
557ddde725dSArmin Le Grand                 }
558ddde725dSArmin Le Grand             }
559cdf0e10cSrcweir         }
560cdf0e10cSrcweir 
561cdf0e10cSrcweir 		if( !aBmp )
562cdf0e10cSrcweir 		{
563cdf0e10cSrcweir 			const Graphic aGraphic(GetMarkedObjMetaFile(bNoVDevIfOneBmpMarked));
564cdf0e10cSrcweir 
565cdf0e10cSrcweir             // #i102089# support user's settings of AA and LineSnap when the MetaFile gets
566cdf0e10cSrcweir             // rasterconverted to a bitmap
567cdf0e10cSrcweir             const SvtOptionsDrawinglayer aDrawinglayerOpt;
568cdf0e10cSrcweir             const GraphicConversionParameters aParameters(
569cdf0e10cSrcweir                 Size(),
570cdf0e10cSrcweir                 false,
571cdf0e10cSrcweir                 aDrawinglayerOpt.IsAntiAliasing(),
572cdf0e10cSrcweir                 aDrawinglayerOpt.IsSnapHorVerLinesToDiscrete());
573cdf0e10cSrcweir 
574ddde725dSArmin Le Grand             aBmp = aGraphic.GetBitmapEx(aParameters);
575cdf0e10cSrcweir 		}
576cdf0e10cSrcweir 	}
577cdf0e10cSrcweir 
578cdf0e10cSrcweir 	return aBmp;
579cdf0e10cSrcweir }
580cdf0e10cSrcweir 
581cdf0e10cSrcweir // -----------------------------------------------------------------------------
582cdf0e10cSrcweir 
583*bb18ee55SArmin Le Grand GDIMetaFile SdrExchangeView::GetMarkedObjMetaFile(bool bNoVDevIfOneMtfMarked) const
584cdf0e10cSrcweir {
585cdf0e10cSrcweir     GDIMetaFile aMtf;
586cdf0e10cSrcweir 
587cdf0e10cSrcweir     if( AreObjectsMarked() )
588cdf0e10cSrcweir 	{
589cdf0e10cSrcweir 		Rectangle	aBound( GetMarkedObjBoundRect() );
590cdf0e10cSrcweir 		Size        aBoundSize( aBound.GetWidth(), aBound.GetHeight() );
591cdf0e10cSrcweir 		MapMode	    aMap( pMod->GetScaleUnit(), Point(), pMod->GetScaleFraction(), pMod->GetScaleFraction() );
592cdf0e10cSrcweir 
593cdf0e10cSrcweir 		if( bNoVDevIfOneMtfMarked )
594cdf0e10cSrcweir 		{
595cdf0e10cSrcweir 			SdrObject*	pGrafObjTmp = GetMarkedObjectByIndex( 0 );
596cdf0e10cSrcweir 			SdrGrafObj* pGrafObj = ( GetMarkedObjectCount() ==1 ) ? PTR_CAST( SdrGrafObj, pGrafObjTmp ) : NULL;
597cdf0e10cSrcweir 
598cdf0e10cSrcweir 			if( pGrafObj )
599cdf0e10cSrcweir             {
600cdf0e10cSrcweir                 Graphic aGraphic( pGrafObj->GetTransformedGraphic() );
601cdf0e10cSrcweir 
602cdf0e10cSrcweir                 if( aGraphic.GetType() == GRAPHIC_BITMAP )
603cdf0e10cSrcweir                 {
604cdf0e10cSrcweir                     const Point aPos;
605cdf0e10cSrcweir 
606cdf0e10cSrcweir                     aMtf.AddAction( new MetaBmpExScaleAction( aPos, aBoundSize, aGraphic.GetBitmapEx() ) );
607cdf0e10cSrcweir         		    aMtf.SetPrefMapMode( aMap );
608cdf0e10cSrcweir                 	aMtf.SetPrefSize( aBoundSize );
609cdf0e10cSrcweir                 }
610cdf0e10cSrcweir                 else
611cdf0e10cSrcweir                     aMtf = aGraphic.GetGDIMetaFile();
612cdf0e10cSrcweir             }
613cdf0e10cSrcweir 		}
614cdf0e10cSrcweir 
615cdf0e10cSrcweir 		if( !aMtf.GetActionCount() )
616cdf0e10cSrcweir 		{
617cdf0e10cSrcweir 			VirtualDevice   aOut;
618cdf0e10cSrcweir             Size            aDummySize( 2, 2 );
619cdf0e10cSrcweir 
620cdf0e10cSrcweir             aOut.SetOutputSizePixel( aDummySize );
621cdf0e10cSrcweir 			aOut.EnableOutput( sal_False );
622cdf0e10cSrcweir 			aOut.SetMapMode( aMap );
623cdf0e10cSrcweir 
624cdf0e10cSrcweir             aMtf.Clear();
625cdf0e10cSrcweir 			aMtf.Record( &aOut );
626cdf0e10cSrcweir 
627cdf0e10cSrcweir 			// Replace offset given formally to DrawMarkedObj and used at XOutDev with relative
628cdf0e10cSrcweir 			// MapMode (which was also used in XOutDev in that case). Goal is to paint the object
629cdf0e10cSrcweir 			// as if TopLeft point is (0,0)
630cdf0e10cSrcweir 			const Fraction aNeutralFraction(1, 1);
631cdf0e10cSrcweir 			const MapMode aRelativeMapMode(MAP_RELATIVE, Point(-aBound.Left(), -aBound.Top()), aNeutralFraction, aNeutralFraction);
632cdf0e10cSrcweir 			aOut.SetMapMode(aRelativeMapMode);
633cdf0e10cSrcweir 
634cdf0e10cSrcweir             DrawMarkedObj(aOut);
635cdf0e10cSrcweir 
636cdf0e10cSrcweir             aMtf.Stop();
637cdf0e10cSrcweir 			aMtf.WindStart();
638cdf0e10cSrcweir 		    aMtf.SetPrefMapMode( aMap );
639cdf0e10cSrcweir 
640cdf0e10cSrcweir 			// removed PrefSize extension. It is principially wrong to set a reduced size at
641cdf0e10cSrcweir 			// the created MetaFile. The mentioned errors occurr at output time since the integer
642cdf0e10cSrcweir 			// MapModes from VCL lead to errors. It is now corrected in the VCLRenderer for
643cdf0e10cSrcweir 			// primitives (and may later be done in breaking up a MetaFile to primitives)
644cdf0e10cSrcweir 			aMtf.SetPrefSize(aBoundSize);
645cdf0e10cSrcweir 		}
646cdf0e10cSrcweir 	}
647cdf0e10cSrcweir 
648cdf0e10cSrcweir 	return aMtf;
649cdf0e10cSrcweir }
650cdf0e10cSrcweir 
651cdf0e10cSrcweir // -----------------------------------------------------------------------------
652cdf0e10cSrcweir 
653cdf0e10cSrcweir Graphic SdrExchangeView::GetAllMarkedGraphic() const
654cdf0e10cSrcweir {
655cdf0e10cSrcweir     Graphic aRet;
656cdf0e10cSrcweir 
657cdf0e10cSrcweir     if( AreObjectsMarked() )
658cdf0e10cSrcweir     {
659cdf0e10cSrcweir         if( ( 1 == GetMarkedObjectCount() ) && GetSdrMarkByIndex( 0 ) )
660cdf0e10cSrcweir             aRet = SdrExchangeView::GetObjGraphic( pMod, GetMarkedObjectByIndex( 0 ) );
661cdf0e10cSrcweir         else
662*bb18ee55SArmin Le Grand             aRet = GetMarkedObjMetaFile(false);
663cdf0e10cSrcweir     }
664cdf0e10cSrcweir 
665cdf0e10cSrcweir     return aRet;
666cdf0e10cSrcweir }
667cdf0e10cSrcweir 
668cdf0e10cSrcweir // -----------------------------------------------------------------------------
669cdf0e10cSrcweir 
670cdf0e10cSrcweir Graphic SdrExchangeView::GetObjGraphic( const SdrModel* pModel, const SdrObject* pObj )
671cdf0e10cSrcweir {
672cdf0e10cSrcweir     Graphic aRet;
673cdf0e10cSrcweir 
674cdf0e10cSrcweir     if( pModel && pObj )
675cdf0e10cSrcweir     {
676cdf0e10cSrcweir         // try to get a graphic from the object first
677cdf0e10cSrcweir 		const SdrGrafObj* pSdrGrafObj = dynamic_cast< const SdrGrafObj* >(pObj);
678cdf0e10cSrcweir 		const SdrOle2Obj* pSdrOle2Obj = dynamic_cast< const SdrOle2Obj* >(pObj);
679cdf0e10cSrcweir 
680cdf0e10cSrcweir 		if(pSdrGrafObj)
681cdf0e10cSrcweir         {
682ddde725dSArmin Le Grand             if(pSdrGrafObj->isEmbeddedSvg())
683ddde725dSArmin Le Grand             {
684ddde725dSArmin Le Grand                 // get Metafile for Svg content
685ddde725dSArmin Le Grand                 aRet = pSdrGrafObj->getMetafileFromEmbeddedSvg();
686ddde725dSArmin Le Grand             }
687ddde725dSArmin Le Grand             else
688ddde725dSArmin Le Grand             {
689cdf0e10cSrcweir                 // #110981# Make behaviour coherent with metafile
690cdf0e10cSrcweir                 // recording below (which of course also takes
691cdf0e10cSrcweir                 // view-transformed objects)
692cdf0e10cSrcweir                 aRet = pSdrGrafObj->GetTransformedGraphic();
693cdf0e10cSrcweir             }
694ddde725dSArmin Le Grand         }
695cdf0e10cSrcweir         else if(pSdrOle2Obj)
696cdf0e10cSrcweir         {
697cdf0e10cSrcweir             if ( pSdrOle2Obj->GetGraphic() )
698cdf0e10cSrcweir                 aRet = *pSdrOle2Obj->GetGraphic();
699cdf0e10cSrcweir         }
700cdf0e10cSrcweir 
701cdf0e10cSrcweir         // if graphic could not be retrieved => go the hard way and create a MetaFile
702cdf0e10cSrcweir         if( ( GRAPHIC_NONE == aRet.GetType() ) || ( GRAPHIC_DEFAULT == aRet.GetType() ) )
703cdf0e10cSrcweir         {
704cdf0e10cSrcweir 			VirtualDevice	aOut;
705cdf0e10cSrcweir             GDIMetaFile     aMtf;
706cdf0e10cSrcweir 			const Rectangle	aBoundRect( pObj->GetCurrentBoundRect() );
707cdf0e10cSrcweir 			const MapMode	aMap( pModel->GetScaleUnit(),
708cdf0e10cSrcweir                                   Point(),
709cdf0e10cSrcweir 								  pModel->GetScaleFraction(),
710cdf0e10cSrcweir                                   pModel->GetScaleFraction() );
711cdf0e10cSrcweir 
712cdf0e10cSrcweir 			aOut.EnableOutput( sal_False );
713cdf0e10cSrcweir 			aOut.SetMapMode( aMap );
714cdf0e10cSrcweir 			aMtf.Record( &aOut );
715cdf0e10cSrcweir             pObj->SingleObjectPainter( aOut ); // #110094#-17
716cdf0e10cSrcweir             aMtf.Stop();
717cdf0e10cSrcweir 			aMtf.WindStart();
718cdf0e10cSrcweir 
719cdf0e10cSrcweir 			// #i99268# replace the original offset from using XOutDev's SetOffset
720cdf0e10cSrcweir 			// NOT (as tried with #i92760#) with another MapMode which gets recorded
721cdf0e10cSrcweir 			// by the Metafile itself (what always leads to problems), but by hardly
722cdf0e10cSrcweir 			// moving the result
723cdf0e10cSrcweir 			aMtf.Move(-aBoundRect.Left(), -aBoundRect.Top());
724cdf0e10cSrcweir 
725cdf0e10cSrcweir     		aMtf.SetPrefMapMode( aMap );
726cdf0e10cSrcweir 			aMtf.SetPrefSize( aBoundRect.GetSize() );
727cdf0e10cSrcweir 
728cdf0e10cSrcweir             if( aMtf.GetActionCount() )
729cdf0e10cSrcweir                 aRet = aMtf;
730cdf0e10cSrcweir         }
731cdf0e10cSrcweir      }
732cdf0e10cSrcweir 
733cdf0e10cSrcweir      return aRet;
734cdf0e10cSrcweir }
735cdf0e10cSrcweir 
736cdf0e10cSrcweir // -----------------------------------------------------------------------------
737cdf0e10cSrcweir 
738cdf0e10cSrcweir void SdrExchangeView::DrawMarkedObj(OutputDevice& rOut) const
739cdf0e10cSrcweir {
740cdf0e10cSrcweir 	SortMarkedObjects();
741cdf0e10cSrcweir 
742cdf0e10cSrcweir     ::std::vector< ::std::vector< SdrMark* > >  aObjVectors( 2 );
743cdf0e10cSrcweir     ::std::vector< SdrMark* >&                  rObjVector1 = aObjVectors[ 0 ];
744cdf0e10cSrcweir     ::std::vector< SdrMark* >&                  rObjVector2 = aObjVectors[ 1 ];
745cdf0e10cSrcweir     const SdrLayerAdmin&                        rLayerAdmin = pMod->GetLayerAdmin();
746cdf0e10cSrcweir     const sal_uInt32                            nControlLayerId = rLayerAdmin.GetLayerID( rLayerAdmin.GetControlLayerName(), sal_False );
747cdf0e10cSrcweir     sal_uInt32                                  n, nCount;
748cdf0e10cSrcweir 
749cdf0e10cSrcweir 	for( n = 0, nCount = GetMarkedObjectCount(); n < nCount; n++ )
750cdf0e10cSrcweir     {
751cdf0e10cSrcweir         SdrMark* pMark = GetSdrMarkByIndex( n );
752cdf0e10cSrcweir 
753cdf0e10cSrcweir         // paint objects on control layer on top of all otherobjects
754cdf0e10cSrcweir         if( nControlLayerId == pMark->GetMarkedSdrObj()->GetLayer() )
755cdf0e10cSrcweir             rObjVector2.push_back( pMark );
756cdf0e10cSrcweir         else
757cdf0e10cSrcweir             rObjVector1.push_back( pMark );
758cdf0e10cSrcweir     }
759cdf0e10cSrcweir 
760cdf0e10cSrcweir     for( n = 0, nCount = aObjVectors.size(); n < nCount; n++ )
761cdf0e10cSrcweir     {
762cdf0e10cSrcweir         ::std::vector< SdrMark* >& rObjVector = aObjVectors[ n ];
763cdf0e10cSrcweir 
764cdf0e10cSrcweir         for( sal_uInt32 i = 0; i < rObjVector.size(); i++ )
765cdf0e10cSrcweir         {
766cdf0e10cSrcweir     		SdrMark*    pMark = rObjVector[ i ];
767cdf0e10cSrcweir             pMark->GetMarkedSdrObj()->SingleObjectPainter( rOut ); // #110094#-17
768cdf0e10cSrcweir         }
769cdf0e10cSrcweir     }
770cdf0e10cSrcweir }
771cdf0e10cSrcweir 
772cdf0e10cSrcweir // -----------------------------------------------------------------------------
773cdf0e10cSrcweir 
774cdf0e10cSrcweir SdrModel* SdrExchangeView::GetMarkedObjModel() const
775cdf0e10cSrcweir {
776cdf0e10cSrcweir 	// Wenn das sortieren der MarkList mal stoeren sollte,
777cdf0e10cSrcweir 	// werde ich sie mir wohl kopieren muessen.
778cdf0e10cSrcweir 	SortMarkedObjects();
779cdf0e10cSrcweir 	SdrModel* pNeuMod=pMod->AllocModel();
780cdf0e10cSrcweir 	SdrPage* pNeuPag=pNeuMod->AllocPage(sal_False);
781cdf0e10cSrcweir 	pNeuMod->InsertPage(pNeuPag);
782cdf0e10cSrcweir 
783cdf0e10cSrcweir 	if( !mxSelectionController.is() || !mxSelectionController->GetMarkedObjModel( pNeuPag ) )
784cdf0e10cSrcweir 	{
785cdf0e10cSrcweir 		::std::vector< ::std::vector< SdrMark* > >  aObjVectors( 2 );
786cdf0e10cSrcweir 		::std::vector< SdrMark* >&                  rObjVector1 = aObjVectors[ 0 ];
787cdf0e10cSrcweir 		::std::vector< SdrMark* >&                  rObjVector2 = aObjVectors[ 1 ];
788cdf0e10cSrcweir 		const SdrLayerAdmin&                        rLayerAdmin = pMod->GetLayerAdmin();
789cdf0e10cSrcweir 		const sal_uInt32                            nControlLayerId = rLayerAdmin.GetLayerID( rLayerAdmin.GetControlLayerName(), sal_False );
790cdf0e10cSrcweir 		sal_uInt32                                  n, nCount, nCloneErrCnt = 0;
791cdf0e10cSrcweir 
792cdf0e10cSrcweir 		for( n = 0, nCount = GetMarkedObjectCount(); n < nCount; n++ )
793cdf0e10cSrcweir 		{
794cdf0e10cSrcweir 			SdrMark* pMark = GetSdrMarkByIndex( n );
795cdf0e10cSrcweir 
796cdf0e10cSrcweir 			// paint objects on control layer on top of all otherobjects
797cdf0e10cSrcweir 			if( nControlLayerId == pMark->GetMarkedSdrObj()->GetLayer() )
798cdf0e10cSrcweir 				rObjVector2.push_back( pMark );
799cdf0e10cSrcweir 			else
800cdf0e10cSrcweir 				rObjVector1.push_back( pMark );
801cdf0e10cSrcweir 		}
802cdf0e10cSrcweir 
803cdf0e10cSrcweir 		// #i13033#
804cdf0e10cSrcweir 		// New mechanism to re-create the connections of cloned connectors
805cdf0e10cSrcweir 		CloneList aCloneList;
806cdf0e10cSrcweir 
807cdf0e10cSrcweir 		for( n = 0, nCount = aObjVectors.size(); n < nCount; n++ )
808cdf0e10cSrcweir 		{
809cdf0e10cSrcweir 			::std::vector< SdrMark* >& rObjVector = aObjVectors[ n ];
810cdf0e10cSrcweir 
811cdf0e10cSrcweir 			for( sal_uInt32 i = 0; i < rObjVector.size(); i++ )
812cdf0e10cSrcweir 			{
813cdf0e10cSrcweir    				const SdrMark*      pMark = rObjVector[ i ];
814cdf0e10cSrcweir 				const SdrObject*    pObj = pMark->GetMarkedSdrObj();
815cdf0e10cSrcweir 				SdrObject*          pNeuObj;
816cdf0e10cSrcweir 
817cdf0e10cSrcweir 				if( pObj->ISA( SdrPageObj ) )
818cdf0e10cSrcweir 				{
819cdf0e10cSrcweir 					// convert SdrPageObj's to a graphic representation, because
820cdf0e10cSrcweir 					// virtual connection to referenced page gets lost in new model
821cdf0e10cSrcweir 					pNeuObj = new SdrGrafObj( GetObjGraphic( pMod, pObj ), pObj->GetLogicRect() );
822cdf0e10cSrcweir 					pNeuObj->SetPage( pNeuPag );
823cdf0e10cSrcweir 					pNeuObj->SetModel( pNeuMod );
824cdf0e10cSrcweir 				}
825cdf0e10cSrcweir 				else
826cdf0e10cSrcweir 				{
827cdf0e10cSrcweir 					// #116235#
828cdf0e10cSrcweir     				// pNeuObj = pObj->Clone( pNeuPag, pNeuMod );
829cdf0e10cSrcweir     				pNeuObj = pObj->Clone();
830cdf0e10cSrcweir 					pNeuObj->SetPage( pNeuPag );
831cdf0e10cSrcweir 					pNeuObj->SetModel( pNeuMod );
832cdf0e10cSrcweir 				}
833cdf0e10cSrcweir 
834cdf0e10cSrcweir 				if( pNeuObj )
835cdf0e10cSrcweir 				{
836cdf0e10cSrcweir 					SdrInsertReason aReason(SDRREASON_VIEWCALL);
837cdf0e10cSrcweir 					pNeuPag->InsertObject(pNeuObj,CONTAINER_APPEND,&aReason);
838cdf0e10cSrcweir 
839cdf0e10cSrcweir 					// #i13033#
840cdf0e10cSrcweir 					aCloneList.AddPair(pObj, pNeuObj);
841cdf0e10cSrcweir 				}
842cdf0e10cSrcweir 				else
843cdf0e10cSrcweir 					nCloneErrCnt++;
844cdf0e10cSrcweir 			}
845cdf0e10cSrcweir 		}
846cdf0e10cSrcweir 
847cdf0e10cSrcweir 		// #i13033#
848cdf0e10cSrcweir 		// New mechanism to re-create the connections of cloned connectors
849cdf0e10cSrcweir 		aCloneList.CopyConnections();
850cdf0e10cSrcweir 
851cdf0e10cSrcweir 		if(0L != nCloneErrCnt)
852cdf0e10cSrcweir 		{
853cdf0e10cSrcweir #ifdef DBG_UTIL
854cdf0e10cSrcweir 			ByteString aStr("SdrExchangeView::GetMarkedObjModel(): Fehler beim Clonen ");
855cdf0e10cSrcweir 
856cdf0e10cSrcweir 			if(nCloneErrCnt == 1)
857cdf0e10cSrcweir 			{
858cdf0e10cSrcweir 				aStr += "eines Zeichenobjekts.";
859cdf0e10cSrcweir 			}
860cdf0e10cSrcweir 			else
861cdf0e10cSrcweir 			{
862cdf0e10cSrcweir 				aStr += "von ";
863cdf0e10cSrcweir 				aStr += ByteString::CreateFromInt32( nCloneErrCnt );
864cdf0e10cSrcweir 				aStr += " Zeichenobjekten.";
865cdf0e10cSrcweir 			}
866cdf0e10cSrcweir 
867cdf0e10cSrcweir 			aStr += " Objektverbindungen werden nicht mitkopiert.";
868cdf0e10cSrcweir 
869cdf0e10cSrcweir 			DBG_ERROR(aStr.GetBuffer());
870cdf0e10cSrcweir #endif
871cdf0e10cSrcweir 		}
872cdf0e10cSrcweir 	}
873cdf0e10cSrcweir 	return pNeuMod;
874cdf0e10cSrcweir }
875cdf0e10cSrcweir 
876cdf0e10cSrcweir // -----------------------------------------------------------------------------
877cdf0e10cSrcweir 
878cdf0e10cSrcweir sal_Bool SdrExchangeView::Cut( sal_uIntPtr /*nFormat */)
879cdf0e10cSrcweir {
880cdf0e10cSrcweir     DBG_ERROR( "SdrExchangeView::Cut: Not supported anymore" );
881cdf0e10cSrcweir     return sal_False;
882cdf0e10cSrcweir }
883cdf0e10cSrcweir 
884cdf0e10cSrcweir // -----------------------------------------------------------------------------
885cdf0e10cSrcweir 
886cdf0e10cSrcweir void SdrExchangeView::CutMarked( sal_uIntPtr /*nFormat */)
887cdf0e10cSrcweir {
888cdf0e10cSrcweir     DBG_ERROR( "SdrExchangeView::CutMarked: Not supported anymore" );
889cdf0e10cSrcweir }
890cdf0e10cSrcweir 
891cdf0e10cSrcweir // -----------------------------------------------------------------------------
892cdf0e10cSrcweir 
893cdf0e10cSrcweir sal_Bool SdrExchangeView::Yank(sal_uIntPtr /*nFormat*/)
894cdf0e10cSrcweir {
895cdf0e10cSrcweir     DBG_ERROR( "SdrExchangeView::Yank: Not supported anymore" );
896cdf0e10cSrcweir     return sal_False;
897cdf0e10cSrcweir }
898cdf0e10cSrcweir 
899cdf0e10cSrcweir // -----------------------------------------------------------------------------
900cdf0e10cSrcweir 
901cdf0e10cSrcweir void SdrExchangeView::YankMarked(sal_uIntPtr /*nFormat*/)
902cdf0e10cSrcweir {
903cdf0e10cSrcweir     DBG_ERROR( "YankMarked: Not supported anymore" );
904cdf0e10cSrcweir }
905cdf0e10cSrcweir 
906cdf0e10cSrcweir // -----------------------------------------------------------------------------
907cdf0e10cSrcweir 
908cdf0e10cSrcweir sal_Bool SdrExchangeView::Paste(Window* /*pWin*/, sal_uIntPtr /*nFormat*/)
909cdf0e10cSrcweir {
910cdf0e10cSrcweir     DBG_ERROR( "SdrExchangeView::Paste: Not supported anymore" );
911cdf0e10cSrcweir     return sal_False;
912cdf0e10cSrcweir }
913