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