1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: svdxcgv.cxx,v $
10 * $Revision: 1.34.18.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
35 #include <svx/editeng.hxx>
37 #include <svx/xflclit.hxx>
38 #include <svx/svdxcgv.hxx>
39 #include <svx/svdoutl.hxx>
40 #include "svditext.hxx"
41 #include <svx/svdetc.hxx>
42 #include <svx/svdundo.hxx>
43 #include <svx/svdograf.hxx>
44 #include <svx/svdoole2.hxx> // fuer kein OLE im SdrClipboardFormat
45 #include <svx/svdorect.hxx>
46 #include <svx/svdoedge.hxx> // fuer Konnektoren uebers Clipboard
47 #include <svx/svdopage.hxx> // fuer Konnektoren uebers Clipboard
48 #include <svx/svdpage.hxx>
49 #include <svx/svdpagv.hxx>
50 #include <svx/svdtrans.hxx> // Fuer GetMapFactor zum umskalieren bei PasteModel
51 #include "svdstr.hrc" // Namen aus der Resource
52 #include "svdglob.hxx" // StringCache
53 #include "xoutbmp.hxx"
54 #include <vcl/metaact.hxx>
55 #include <svtools/poolitem.hxx>
56 #include <svtools/itempool.hxx>
57 #include <tools/bigint.hxx>
58 #include <sot/formats.hxx>
61 #include <clonelist.hxx>
62 #include <vcl/virdev.hxx>
65 #include <svtools/style.hxx>
70 ////////////////////////////////////////////////////////////////////////////////////////////////////
72 SdrExchangeView::SdrExchangeView(SdrModel
* pModel1
, OutputDevice
* pOut
):
73 SdrObjEditView(pModel1
,pOut
)
77 ////////////////////////////////////////////////////////////////////////////////////////////////////
79 Point
SdrExchangeView::GetViewCenter(const OutputDevice
* pOut
) const
84 pOut
= GetFirstOutputDevice();
87 Point aOfs
=pOut
->GetMapMode().GetOrigin();
88 Size aOutSiz
=pOut
->GetOutputSize();
91 aCenter
.X()=aOutSiz
.Width() -aOfs
.X();
92 aCenter
.Y()=aOutSiz
.Height()-aOfs
.Y();
97 Point
SdrExchangeView::GetPastePos(SdrObjList
* pLst
, OutputDevice
* pOut
)
99 Point
aP(GetViewCenter(pOut
));
101 if (pLst
!=NULL
) pPg
=pLst
->GetPage();
103 Size
aSiz(pPg
->GetSize());
104 aP
.X()=aSiz
.Width()/2;
105 aP
.Y()=aSiz
.Height()/2;
110 BOOL
SdrExchangeView::ImpLimitToWorkArea(Point
& rPt
) const
114 if(!aMaxWorkArea
.IsEmpty())
116 if(rPt
.X()<aMaxWorkArea
.Left())
118 rPt
.X() = aMaxWorkArea
.Left();
122 if(rPt
.X()>aMaxWorkArea
.Right())
124 rPt
.X() = aMaxWorkArea
.Right();
128 if(rPt
.Y()<aMaxWorkArea
.Top())
130 rPt
.Y() = aMaxWorkArea
.Top();
134 if(rPt
.Y()>aMaxWorkArea
.Bottom())
136 rPt
.Y() = aMaxWorkArea
.Bottom();
143 void SdrExchangeView::ImpGetPasteObjList(Point
& /*rPos*/, SdrObjList
*& rpLst
)
147 SdrPageView
* pPV
= GetSdrPageView();
150 rpLst
=pPV
->GetObjList();
155 BOOL
SdrExchangeView::ImpGetPasteLayer(const SdrObjList
* pObjList
, SdrLayerID
& rLayer
) const
159 if (pObjList
!=NULL
) {
160 const SdrPage
* pPg
=pObjList
->GetPage();
162 rLayer
=pPg
->GetLayerAdmin().GetLayerID(aAktLayer
,TRUE
);
163 if (rLayer
==SDRLAYER_NOTFOUND
) rLayer
=0;
164 SdrPageView
* pPV
= GetSdrPageView();
166 bRet
=!pPV
->GetLockedLayers().IsSet(rLayer
) && pPV
->GetVisibleLayers().IsSet(rLayer
);
173 ////////////////////////////////////////////////////////////////////////////////////////////////////
175 BOOL
SdrExchangeView::Paste(const GDIMetaFile
& rMtf
, const Point
& rPos
, SdrObjList
* pLst
, UINT32 nOptions
)
178 ImpGetPasteObjList(aPos
,pLst
);
179 ImpLimitToWorkArea( aPos
);
180 if (pLst
==NULL
) return FALSE
;
182 if (!ImpGetPasteLayer(pLst
,nLayer
)) return FALSE
;
183 BOOL bUnmark
=(nOptions
&(SDRINSERT_DONTMARK
|SDRINSERT_ADDMARK
))==0 && !IsTextEdit();
184 if (bUnmark
) UnmarkAllObj();
185 SdrGrafObj
* pObj
=new SdrGrafObj(Graphic(rMtf
));
186 pObj
->SetLayer(nLayer
);
187 ImpPasteObject(pObj
,*pLst
,aPos
,rMtf
.GetPrefSize(),rMtf
.GetPrefMapMode(),nOptions
);
191 BOOL
SdrExchangeView::Paste(const Bitmap
& rBmp
, const Point
& rPos
, SdrObjList
* pLst
, UINT32 nOptions
)
194 ImpGetPasteObjList(aPos
,pLst
);
195 ImpLimitToWorkArea( aPos
);
196 if (pLst
==NULL
) return FALSE
;
198 if (!ImpGetPasteLayer(pLst
,nLayer
)) return FALSE
;
199 BOOL bUnmark
=(nOptions
&(SDRINSERT_DONTMARK
|SDRINSERT_ADDMARK
))==0 && !IsTextEdit();
200 if (bUnmark
) UnmarkAllObj();
201 SdrGrafObj
* pObj
=new SdrGrafObj(Graphic(rBmp
));
202 pObj
->SetLayer(nLayer
);
203 ImpPasteObject(pObj
,*pLst
,aPos
,rBmp
.GetSizePixel(),MapMode(MAP_PIXEL
),nOptions
);
207 BOOL
SdrExchangeView::Paste(const XubString
& rStr
, const Point
& rPos
, SdrObjList
* pLst
, UINT32 nOptions
)
213 ImpGetPasteObjList(aPos
,pLst
);
214 ImpLimitToWorkArea( aPos
);
215 if (pLst
==NULL
) return FALSE
;
217 if (!ImpGetPasteLayer(pLst
,nLayer
)) return FALSE
;
218 BOOL bUnmark
=(nOptions
&(SDRINSERT_DONTMARK
|SDRINSERT_ADDMARK
))==0 && !IsTextEdit();
219 if (bUnmark
) UnmarkAllObj();
220 Rectangle
aTextRect(0,0,500,500);
221 SdrPage
* pPage
=pLst
->GetPage();
223 aTextRect
.SetSize(pPage
->GetSize());
225 SdrRectObj
* pObj
=new SdrRectObj(OBJ_TEXT
,aTextRect
);
226 pObj
->SetModel(pMod
);
227 pObj
->SetLayer(nLayer
);
228 pObj
->NbcSetText(rStr
); // #32424# SetText vor SetAttr, weil SetAttr sonst unwirksam!
229 if (pDefaultStyleSheet
!=NULL
) pObj
->NbcSetStyleSheet(pDefaultStyleSheet
, sal_False
);
231 pObj
->SetMergedItemSet(aDefaultAttr
);
233 SfxItemSet
aTempAttr(pMod
->GetItemPool()); // Keine Fuellung oder Linie
234 aTempAttr
.Put(XLineStyleItem(XLINE_NONE
));
235 aTempAttr
.Put(XFillStyleItem(XFILL_NONE
));
237 pObj
->SetMergedItemSet(aTempAttr
);
239 pObj
->FitFrameToTextSize();
240 Size
aSiz(pObj
->GetLogicRect().GetSize());
241 MapUnit eMap
=pMod
->GetScaleUnit();
242 Fraction aMap
=pMod
->GetScaleFraction();
243 ImpPasteObject(pObj
,*pLst
,aPos
,aSiz
,MapMode(eMap
,Point(0,0),aMap
,aMap
),nOptions
);
247 BOOL
SdrExchangeView::Paste(SvStream
& rInput
, const String
& rBaseURL
, USHORT eFormat
, const Point
& rPos
, SdrObjList
* pLst
, UINT32 nOptions
)
250 ImpGetPasteObjList(aPos
,pLst
);
251 ImpLimitToWorkArea( aPos
);
252 if (pLst
==NULL
) return FALSE
;
254 if (!ImpGetPasteLayer(pLst
,nLayer
)) return FALSE
;
255 BOOL bUnmark
=(nOptions
&(SDRINSERT_DONTMARK
|SDRINSERT_ADDMARK
))==0 && !IsTextEdit();
256 if (bUnmark
) UnmarkAllObj();
257 Rectangle
aTextRect(0,0,500,500);
258 SdrPage
* pPage
=pLst
->GetPage();
260 aTextRect
.SetSize(pPage
->GetSize());
262 SdrRectObj
* pObj
=new SdrRectObj(OBJ_TEXT
,aTextRect
);
263 pObj
->SetModel(pMod
);
264 pObj
->SetLayer(nLayer
);
265 if (pDefaultStyleSheet
!=NULL
) pObj
->NbcSetStyleSheet(pDefaultStyleSheet
, sal_False
);
267 pObj
->SetMergedItemSet(aDefaultAttr
);
269 SfxItemSet
aTempAttr(pMod
->GetItemPool()); // Keine Fuellung oder Linie
270 aTempAttr
.Put(XLineStyleItem(XLINE_NONE
));
271 aTempAttr
.Put(XFillStyleItem(XFILL_NONE
));
273 pObj
->SetMergedItemSet(aTempAttr
);
275 pObj
->NbcSetText(rInput
,rBaseURL
,eFormat
);
276 pObj
->FitFrameToTextSize();
277 Size
aSiz(pObj
->GetLogicRect().GetSize());
278 MapUnit eMap
=pMod
->GetScaleUnit();
279 Fraction aMap
=pMod
->GetScaleFraction();
280 ImpPasteObject(pObj
,*pLst
,aPos
,aSiz
,MapMode(eMap
,Point(0,0),aMap
,aMap
),nOptions
);
283 if(pObj
&& pObj
->GetModel() && pObj
->GetOutlinerParaObject())
285 SdrOutliner
& rOutliner
= pObj
->GetModel()->GetHitTestOutliner();
286 rOutliner
.SetText(*pObj
->GetOutlinerParaObject());
288 if(1L == rOutliner
.GetParagraphCount())
290 SfxStyleSheet
* pCandidate
= rOutliner
.GetStyleSheet(0L);
294 if(pObj
->GetModel()->GetStyleSheetPool() == &pCandidate
->GetPool())
296 pObj
->NbcSetStyleSheet(pCandidate
, sal_True
);
305 BOOL
SdrExchangeView::Paste(const SdrModel
& rMod
, const Point
& rPos
, SdrObjList
* pLst
, UINT32 nOptions
)
307 const SdrModel
* pSrcMod
=&rMod
;
309 return FALSE
; // na so geht's ja nun nicht
311 const bool bUndo
= IsUndoEnabled();
314 BegUndo(ImpGetResStr(STR_ExchangePaste
));
316 if( mxSelectionController
.is() && mxSelectionController
->PasteObjModel( rMod
) )
324 ImpGetPasteObjList(aPos
,pLst
);
325 SdrPageView
* pMarkPV
=NULL
;
326 SdrPageView
* pPV
= GetSdrPageView();
330 if ( pPV
->GetObjList() == pLst
)
334 ImpLimitToWorkArea( aPos
);
338 BOOL bUnmark
=(nOptions
&(SDRINSERT_DONTMARK
|SDRINSERT_ADDMARK
))==0 && !IsTextEdit();
342 // evtl. umskalieren bei unterschiedlicher MapUnit am Model
343 // Dafuer erstmal die Faktoren berechnen
344 MapUnit eSrcUnit
=pSrcMod
->GetScaleUnit();
345 MapUnit eDstUnit
=pMod
->GetScaleUnit();
346 BOOL bResize
=eSrcUnit
!=eDstUnit
;
347 Fraction xResize
,yResize
;
351 FrPair
aResize(GetMapFactor(eSrcUnit
,eDstUnit
));
355 SdrObjList
* pDstLst
=pLst
;
356 USHORT nPg
,nPgAnz
=pSrcMod
->GetPageCount();
357 for (nPg
=0; nPg
<nPgAnz
; nPg
++)
359 const SdrPage
* pSrcPg
=pSrcMod
->GetPage(nPg
);
361 // #104148# Use SnapRect, not BoundRect here
362 Rectangle aR
=pSrcPg
->GetAllObjSnapRect();
365 ResizeRect(aR
,aPt0
,xResize
,yResize
);
366 Point
aDist(aPos
-aR
.Center());
367 Size
aSiz(aDist
.X(),aDist
.Y());
368 //ULONG nDstObjAnz0=pDstLst->GetObjCount();
369 ULONG nCloneErrCnt
=0;
370 ULONG nOb
,nObAnz
=pSrcPg
->GetObjCount();
371 BOOL bMark
=pMarkPV
!=NULL
&& !IsTextEdit() && (nOptions
&SDRINSERT_DONTMARK
)==0;
374 // New mechanism to re-create the connections of cloned connectors
375 CloneList aCloneList
;
377 for (nOb
=0; nOb
<nObAnz
; nOb
++)
379 const SdrObject
* pSrcOb
=pSrcPg
->GetObj(nOb
);
382 SdrObject
* pNeuObj
= pSrcOb
->Clone();
388 pNeuObj
->GetModel()->SetPasteResize(TRUE
); // #51139#
389 pNeuObj
->NbcResize(aPt0
,xResize
,yResize
);
390 pNeuObj
->GetModel()->SetPasteResize(FALSE
); // #51139#
394 pNeuObj
->SetModel(pDstLst
->GetModel());
395 pNeuObj
->SetPage(pDstLst
->GetPage());
397 pNeuObj
->NbcMove(aSiz
);
399 const SdrPage
* pPg
= pDstLst
->GetPage();
404 const SdrLayerAdmin
& rAd
= pPg
->GetLayerAdmin();
405 SdrLayerID
nLayer(0);
407 if(pNeuObj
->ISA(FmFormObj
))
409 // for FormControls, force to form layer
410 nLayer
= rAd
.GetLayerID(rAd
.GetControlLayerName(), true);
414 nLayer
= rAd
.GetLayerID(aAktLayer
, TRUE
);
417 if(SDRLAYER_NOTFOUND
== nLayer
)
422 pNeuObj
->SetLayer(nLayer
);
425 SdrInsertReason
aReason(SDRREASON_VIEWCALL
);
426 pDstLst
->InsertObject(pNeuObj
,CONTAINER_APPEND
,&aReason
);
429 AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pNeuObj
));
432 // Markhandles noch nicht sofort setzen!
433 // Das erledigt das ModelHasChanged der MarkView.
434 MarkObj(pNeuObj
,pMarkPV
,FALSE
,TRUE
);
438 aCloneList
.AddPair(pSrcOb
, pNeuObj
);
447 // New mechanism to re-create the connections of cloned connectors
448 aCloneList
.CopyConnections();
450 if(0L != nCloneErrCnt
)
453 ByteString
aStr("SdrExchangeView::Paste(): Fehler beim Clonen ");
455 if(nCloneErrCnt
== 1)
457 aStr
+= "eines Zeichenobjekts.";
462 aStr
+= ByteString::CreateFromInt32( nCloneErrCnt
);
463 aStr
+= " Zeichenobjekten.";
466 aStr
+= " Objektverbindungen werden nicht mitkopiert.";
468 DBG_ERROR(aStr
.GetBuffer());
479 BOOL
SdrExchangeView::IsExchangeFormatSupported(ULONG nFormat
) const
481 return( FORMAT_PRIVATE
== nFormat
||
482 FORMAT_GDIMETAFILE
== nFormat
||
483 FORMAT_BITMAP
== nFormat
||
484 FORMAT_RTF
== nFormat
||
485 FORMAT_STRING
== nFormat
||
486 SOT_FORMATSTR_ID_DRAWING
== nFormat
||
487 SOT_FORMATSTR_ID_EDITENGINE
== nFormat
);
490 void SdrExchangeView::ImpPasteObject(SdrObject
* pObj
, SdrObjList
& rLst
, const Point
& rCenter
, const Size
& rSiz
, const MapMode
& rMap
, UINT32 nOptions
)
492 BigInt
nSizX(rSiz
.Width());
493 BigInt
nSizY(rSiz
.Height());
494 MapUnit eSrcMU
=rMap
.GetMapUnit();
495 MapUnit eDstMU
=pMod
->GetScaleUnit();
496 FrPair
aMapFact(GetMapFactor(eSrcMU
,eDstMU
));
497 Fraction
aDstFr(pMod
->GetScaleFraction());
498 nSizX
*=aMapFact
.X().GetNumerator();
499 nSizX
*=rMap
.GetScaleX().GetNumerator();
500 nSizX
*=aDstFr
.GetDenominator();
501 nSizX
/=aMapFact
.X().GetDenominator();
502 nSizX
/=rMap
.GetScaleX().GetDenominator();
503 nSizX
/=aDstFr
.GetNumerator();
504 nSizY
*=aMapFact
.Y().GetNumerator();
505 nSizY
*=rMap
.GetScaleY().GetNumerator();
506 nSizX
*=aDstFr
.GetDenominator();
507 nSizY
/=aMapFact
.Y().GetDenominator();
508 nSizY
/=rMap
.GetScaleY().GetDenominator();
509 nSizY
/=aDstFr
.GetNumerator();
512 Point
aPos(rCenter
.X()-xs
/2,rCenter
.Y()-ys
/2);
513 Rectangle
aR(aPos
.X(),aPos
.Y(),aPos
.X()+xs
,aPos
.Y()+ys
);
514 pObj
->SetLogicRect(aR
);
515 SdrInsertReason
aReason(SDRREASON_VIEWCALL
);
516 rLst
.InsertObject(pObj
,CONTAINER_APPEND
,&aReason
);
518 if( IsUndoEnabled() )
519 AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pObj
));
521 SdrPageView
* pMarkPV
=NULL
;
522 SdrPageView
* pPV
= GetSdrPageView();
526 if (pPV
->GetObjList()==&rLst
)
530 BOOL bMark
=pMarkPV
!=NULL
&& !IsTextEdit() && (nOptions
&SDRINSERT_DONTMARK
)==0;
532 { // Obj in der ersten gefundenen PageView markieren
533 MarkObj(pObj
,pMarkPV
);
537 ////////////////////////////////////////////////////////////////////////////////////////////////////
539 Bitmap
SdrExchangeView::GetMarkedObjBitmap( BOOL bNoVDevIfOneBmpMarked
) const
543 if( AreObjectsMarked() )
545 if( bNoVDevIfOneBmpMarked
)
547 SdrObject
* pGrafObjTmp
= GetMarkedObjectByIndex( 0 );
548 SdrGrafObj
* pGrafObj
= ( GetMarkedObjectCount() == 1 ) ? PTR_CAST( SdrGrafObj
, pGrafObjTmp
) : NULL
;
550 if( pGrafObj
&& ( pGrafObj
->GetGraphicType() == GRAPHIC_BITMAP
) )
551 aBmp
= pGrafObj
->GetTransformedGraphic().GetBitmap();
556 const Graphic
aGraphic( GetMarkedObjMetaFile( bNoVDevIfOneBmpMarked
) );
558 // #i102089# support user's settings of AA and LineSnap when the MetaFile gets
559 // rasterconverted to a bitmap
560 const SvtOptionsDrawinglayer aDrawinglayerOpt
;
561 const GraphicConversionParameters
aParameters(
564 aDrawinglayerOpt
.IsAntiAliasing(),
565 aDrawinglayerOpt
.IsSnapHorVerLinesToDiscrete());
567 aBmp
= aGraphic
.GetBitmap(aParameters
);
574 // -----------------------------------------------------------------------------
576 GDIMetaFile
SdrExchangeView::GetMarkedObjMetaFile( BOOL bNoVDevIfOneMtfMarked
) const
580 if( AreObjectsMarked() )
582 Rectangle
aBound( GetMarkedObjBoundRect() );
583 Size
aBoundSize( aBound
.GetWidth(), aBound
.GetHeight() );
584 MapMode
aMap( pMod
->GetScaleUnit(), Point(), pMod
->GetScaleFraction(), pMod
->GetScaleFraction() );
586 if( bNoVDevIfOneMtfMarked
)
588 SdrObject
* pGrafObjTmp
= GetMarkedObjectByIndex( 0 );
589 SdrGrafObj
* pGrafObj
= ( GetMarkedObjectCount() ==1 ) ? PTR_CAST( SdrGrafObj
, pGrafObjTmp
) : NULL
;
593 Graphic
aGraphic( pGrafObj
->GetTransformedGraphic() );
595 if( aGraphic
.GetType() == GRAPHIC_BITMAP
)
599 aMtf
.AddAction( new MetaBmpExScaleAction( aPos
, aBoundSize
, aGraphic
.GetBitmapEx() ) );
600 aMtf
.SetPrefMapMode( aMap
);
601 aMtf
.SetPrefSize( aBoundSize
);
604 aMtf
= aGraphic
.GetGDIMetaFile();
608 if( !aMtf
.GetActionCount() )
611 Size
aDummySize( 2, 2 );
613 aOut
.SetOutputSizePixel( aDummySize
);
614 aOut
.EnableOutput( FALSE
);
615 aOut
.SetMapMode( aMap
);
618 aMtf
.Record( &aOut
);
620 // Replace offset given formally to DrawMarkedObj and used at XOutDev with relative
621 // MapMode (which was also used in XOutDev in that case). Goal is to paint the object
622 // as if TopLeft point is (0,0)
623 const Fraction
aNeutralFraction(1, 1);
624 const MapMode
aRelativeMapMode(MAP_RELATIVE
, Point(-aBound
.Left(), -aBound
.Top()), aNeutralFraction
, aNeutralFraction
);
625 aOut
.SetMapMode(aRelativeMapMode
);
631 aMtf
.SetPrefMapMode( aMap
);
633 // removed PrefSize extension. It is principially wrong to set a reduced size at
634 // the created MetaFile. The mentioned errors occurr at output time since the integer
635 // MapModes from VCL lead to errors. It is now corrected in the VCLRenderer for
636 // primitives (and may later be done in breaking up a MetaFile to primitives)
637 aMtf
.SetPrefSize(aBoundSize
);
644 // -----------------------------------------------------------------------------
646 Graphic
SdrExchangeView::GetAllMarkedGraphic() const
650 if( AreObjectsMarked() )
652 if( ( 1 == GetMarkedObjectCount() ) && GetSdrMarkByIndex( 0 ) )
653 aRet
= SdrExchangeView::GetObjGraphic( pMod
, GetMarkedObjectByIndex( 0 ) );
655 aRet
= GetMarkedObjMetaFile( FALSE
);
661 // -----------------------------------------------------------------------------
663 Graphic
SdrExchangeView::GetObjGraphic( const SdrModel
* pModel
, const SdrObject
* pObj
)
669 // try to get a graphic from the object first
670 const SdrGrafObj
* pSdrGrafObj
= dynamic_cast< const SdrGrafObj
* >(pObj
);
671 const SdrOle2Obj
* pSdrOle2Obj
= dynamic_cast< const SdrOle2Obj
* >(pObj
);
675 // #110981# Make behaviour coherent with metafile
676 // recording below (which of course also takes
677 // view-transformed objects)
678 aRet
= pSdrGrafObj
->GetTransformedGraphic();
682 if ( pSdrOle2Obj
->GetGraphic() )
683 aRet
= *pSdrOle2Obj
->GetGraphic();
686 // if graphic could not be retrieved => go the hard way and create a MetaFile
687 if( ( GRAPHIC_NONE
== aRet
.GetType() ) || ( GRAPHIC_DEFAULT
== aRet
.GetType() ) )
691 const Rectangle
aBoundRect( pObj
->GetCurrentBoundRect() );
692 const MapMode
aMap( pModel
->GetScaleUnit(),
694 pModel
->GetScaleFraction(),
695 pModel
->GetScaleFraction() );
697 aOut
.EnableOutput( FALSE
);
698 aOut
.SetMapMode( aMap
);
699 aMtf
.Record( &aOut
);
700 pObj
->SingleObjectPainter( aOut
); // #110094#-17
704 // #i99268# replace the original offset from using XOutDev's SetOffset
705 // NOT (as tried with #i92760#) with another MapMode which gets recorded
706 // by the Metafile itself (what always leads to problems), but by hardly
708 aMtf
.Move(-aBoundRect
.Left(), -aBoundRect
.Top());
710 aMtf
.SetPrefMapMode( aMap
);
711 aMtf
.SetPrefSize( aBoundRect
.GetSize() );
713 if( aMtf
.GetActionCount() )
721 // -----------------------------------------------------------------------------
723 void SdrExchangeView::DrawMarkedObj(OutputDevice
& rOut
) const
727 ::std::vector
< ::std::vector
< SdrMark
* > > aObjVectors( 2 );
728 ::std::vector
< SdrMark
* >& rObjVector1
= aObjVectors
[ 0 ];
729 ::std::vector
< SdrMark
* >& rObjVector2
= aObjVectors
[ 1 ];
730 const SdrLayerAdmin
& rLayerAdmin
= pMod
->GetLayerAdmin();
731 const sal_uInt32 nControlLayerId
= rLayerAdmin
.GetLayerID( rLayerAdmin
.GetControlLayerName(), FALSE
);
732 sal_uInt32 n
, nCount
;
734 for( n
= 0, nCount
= GetMarkedObjectCount(); n
< nCount
; n
++ )
736 SdrMark
* pMark
= GetSdrMarkByIndex( n
);
738 // paint objects on control layer on top of all otherobjects
739 if( nControlLayerId
== pMark
->GetMarkedSdrObj()->GetLayer() )
740 rObjVector2
.push_back( pMark
);
742 rObjVector1
.push_back( pMark
);
745 for( n
= 0, nCount
= aObjVectors
.size(); n
< nCount
; n
++ )
747 ::std::vector
< SdrMark
* >& rObjVector
= aObjVectors
[ n
];
749 for( sal_uInt32 i
= 0; i
< rObjVector
.size(); i
++ )
751 SdrMark
* pMark
= rObjVector
[ i
];
752 pMark
->GetMarkedSdrObj()->SingleObjectPainter( rOut
); // #110094#-17
757 // -----------------------------------------------------------------------------
759 SdrModel
* SdrExchangeView::GetMarkedObjModel() const
761 // Wenn das sortieren der MarkList mal stoeren sollte,
762 // werde ich sie mir wohl kopieren muessen.
764 SdrModel
* pNeuMod
=pMod
->AllocModel();
765 SdrPage
* pNeuPag
=pNeuMod
->AllocPage(FALSE
);
766 pNeuMod
->InsertPage(pNeuPag
);
768 if( !mxSelectionController
.is() || !mxSelectionController
->GetMarkedObjModel( pNeuPag
) )
770 ::std::vector
< ::std::vector
< SdrMark
* > > aObjVectors( 2 );
771 ::std::vector
< SdrMark
* >& rObjVector1
= aObjVectors
[ 0 ];
772 ::std::vector
< SdrMark
* >& rObjVector2
= aObjVectors
[ 1 ];
773 const SdrLayerAdmin
& rLayerAdmin
= pMod
->GetLayerAdmin();
774 const sal_uInt32 nControlLayerId
= rLayerAdmin
.GetLayerID( rLayerAdmin
.GetControlLayerName(), FALSE
);
775 sal_uInt32 n
, nCount
, nCloneErrCnt
= 0;
777 for( n
= 0, nCount
= GetMarkedObjectCount(); n
< nCount
; n
++ )
779 SdrMark
* pMark
= GetSdrMarkByIndex( n
);
781 // paint objects on control layer on top of all otherobjects
782 if( nControlLayerId
== pMark
->GetMarkedSdrObj()->GetLayer() )
783 rObjVector2
.push_back( pMark
);
785 rObjVector1
.push_back( pMark
);
789 // New mechanism to re-create the connections of cloned connectors
790 CloneList aCloneList
;
792 for( n
= 0, nCount
= aObjVectors
.size(); n
< nCount
; n
++ )
794 ::std::vector
< SdrMark
* >& rObjVector
= aObjVectors
[ n
];
796 for( sal_uInt32 i
= 0; i
< rObjVector
.size(); i
++ )
798 const SdrMark
* pMark
= rObjVector
[ i
];
799 const SdrObject
* pObj
= pMark
->GetMarkedSdrObj();
802 if( pObj
->ISA( SdrPageObj
) )
804 // convert SdrPageObj's to a graphic representation, because
805 // virtual connection to referenced page gets lost in new model
806 pNeuObj
= new SdrGrafObj( GetObjGraphic( pMod
, pObj
), pObj
->GetLogicRect() );
807 pNeuObj
->SetPage( pNeuPag
);
808 pNeuObj
->SetModel( pNeuMod
);
813 // pNeuObj = pObj->Clone( pNeuPag, pNeuMod );
814 pNeuObj
= pObj
->Clone();
815 pNeuObj
->SetPage( pNeuPag
);
816 pNeuObj
->SetModel( pNeuMod
);
821 SdrInsertReason
aReason(SDRREASON_VIEWCALL
);
822 pNeuPag
->InsertObject(pNeuObj
,CONTAINER_APPEND
,&aReason
);
825 aCloneList
.AddPair(pObj
, pNeuObj
);
833 // New mechanism to re-create the connections of cloned connectors
834 aCloneList
.CopyConnections();
836 if(0L != nCloneErrCnt
)
839 ByteString
aStr("SdrExchangeView::GetMarkedObjModel(): Fehler beim Clonen ");
841 if(nCloneErrCnt
== 1)
843 aStr
+= "eines Zeichenobjekts.";
848 aStr
+= ByteString::CreateFromInt32( nCloneErrCnt
);
849 aStr
+= " Zeichenobjekten.";
852 aStr
+= " Objektverbindungen werden nicht mitkopiert.";
854 DBG_ERROR(aStr
.GetBuffer());
861 // -----------------------------------------------------------------------------
863 BOOL
SdrExchangeView::Cut( ULONG
/*nFormat */)
865 DBG_ERROR( "SdrExchangeView::Cut: Not supported anymore" );
869 // -----------------------------------------------------------------------------
871 void SdrExchangeView::CutMarked( ULONG
/*nFormat */)
873 DBG_ERROR( "SdrExchangeView::CutMarked: Not supported anymore" );
876 // -----------------------------------------------------------------------------
878 BOOL
SdrExchangeView::Yank(ULONG
/*nFormat*/)
880 DBG_ERROR( "SdrExchangeView::Yank: Not supported anymore" );
884 // -----------------------------------------------------------------------------
886 void SdrExchangeView::YankMarked(ULONG
/*nFormat*/)
888 DBG_ERROR( "YankMarked: Not supported anymore" );
891 // -----------------------------------------------------------------------------
893 BOOL
SdrExchangeView::Paste(Window
* /*pWin*/, ULONG
/*nFormat*/)
895 DBG_ERROR( "SdrExchangeView::Paste: Not supported anymore" );