15b190011SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
35b190011SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
45b190011SAndrew Rist * or more contributor license agreements. See the NOTICE file
55b190011SAndrew Rist * distributed with this work for additional information
65b190011SAndrew Rist * regarding copyright ownership. The ASF licenses this file
75b190011SAndrew Rist * to you under the Apache License, Version 2.0 (the
85b190011SAndrew Rist * "License"); you may not use this file except in compliance
95b190011SAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
115b190011SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
135b190011SAndrew Rist * Unless required by applicable law or agreed to in writing,
145b190011SAndrew Rist * software distributed under the License is distributed on an
155b190011SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
165b190011SAndrew Rist * KIND, either express or implied. See the License for the
175b190011SAndrew Rist * specific language governing permissions and limitations
185b190011SAndrew Rist * under the License.
19cdf0e10cSrcweir *
205b190011SAndrew Rist *************************************************************/
215b190011SAndrew Rist
225b190011SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sd.hxx"
26cdf0e10cSrcweir #include <com/sun/star/embed/XTransactedObject.hpp>
27cdf0e10cSrcweir #include <com/sun/star/embed/XEmbedPersist.hpp>
28cdf0e10cSrcweir #include <com/sun/star/embed/ElementModes.hpp>
29cdf0e10cSrcweir #include <com/sun/star/lang/XComponent.hpp>
30cdf0e10cSrcweir #include <vos/mutex.hxx>
31cdf0e10cSrcweir #include <unotools/ucbstreamhelper.hxx>
32cdf0e10cSrcweir #ifndef _UNTOOLS_TEMPFILE_HXX
33cdf0e10cSrcweir #include <unotools/tempfile.hxx>
34cdf0e10cSrcweir #endif
35cdf0e10cSrcweir #include <editeng/eeitem.hxx>
36cdf0e10cSrcweir #include <editeng/flditem.hxx>
37cdf0e10cSrcweir #include <svx/svdpagv.hxx>
38cdf0e10cSrcweir #include <sfx2/app.hxx>
39cdf0e10cSrcweir #include <vcl/msgbox.hxx>
40cdf0e10cSrcweir #include <svx/svdoole2.hxx>
41cdf0e10cSrcweir #include <svx/svdograf.hxx>
42cdf0e10cSrcweir #include <svx/svdotext.hxx>
43cdf0e10cSrcweir #include <editeng/outlobj.hxx>
44cdf0e10cSrcweir #include <sot/storage.hxx>
45cdf0e10cSrcweir #include <svl/itempool.hxx>
46cdf0e10cSrcweir #include <editeng/editobj.hxx>
47cdf0e10cSrcweir #include <svx/fmglob.hxx>
48cdf0e10cSrcweir #include <svx/svdouno.hxx>
49cdf0e10cSrcweir #include <tools/urlobj.hxx>
50cdf0e10cSrcweir #include <sot/formats.hxx>
51cdf0e10cSrcweir #include <svl/urlbmk.hxx>
52cdf0e10cSrcweir #include <editeng/outliner.hxx>
53cdf0e10cSrcweir
54cdf0e10cSrcweir //#ifndef _SVDETC_HXX //autogen
55cdf0e10cSrcweir //#include <svx/svdetc.hxx>
56cdf0e10cSrcweir //#endif
57cdf0e10cSrcweir #include <com/sun/star/form/FormButtonType.hpp>
58cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
59cdf0e10cSrcweir #include <unotools/streamwrap.hxx>
60cdf0e10cSrcweir
61cdf0e10cSrcweir #include <svx/svdotable.hxx>
62cdf0e10cSrcweir #include <svx/unomodel.hxx>
63cdf0e10cSrcweir #include <svx/svditer.hxx>
64cdf0e10cSrcweir #include <sfx2/docfile.hxx>
65cdf0e10cSrcweir #include <comphelper/storagehelper.hxx>
66cdf0e10cSrcweir #include <svtools/embedtransfer.hxx>
67cdf0e10cSrcweir #include "DrawDocShell.hxx"
68cdf0e10cSrcweir #include "View.hxx"
69cdf0e10cSrcweir #include "sdpage.hxx"
70cdf0e10cSrcweir #include "drawview.hxx"
71cdf0e10cSrcweir #include "drawdoc.hxx"
72cdf0e10cSrcweir #include "stlpool.hxx"
73cdf0e10cSrcweir #include "strings.hrc"
74cdf0e10cSrcweir #include "sdresid.hxx"
75cdf0e10cSrcweir #include "imapinfo.hxx"
76cdf0e10cSrcweir #include "sdxfer.hxx"
77cdf0e10cSrcweir #include "unomodel.hxx"
78cdf0e10cSrcweir #include <vcl/virdev.hxx>
79cdf0e10cSrcweir
80cdf0e10cSrcweir // --------------
81cdf0e10cSrcweir // - Namespaces -
82cdf0e10cSrcweir // --------------
83cdf0e10cSrcweir
84cdf0e10cSrcweir using namespace ::com::sun::star;
85cdf0e10cSrcweir using namespace ::com::sun::star::lang;
86cdf0e10cSrcweir using namespace ::com::sun::star::uno;
87cdf0e10cSrcweir using namespace ::com::sun::star::io;
88cdf0e10cSrcweir using namespace ::com::sun::star::datatransfer;
89cdf0e10cSrcweir using namespace ::com::sun::star::datatransfer::clipboard;
90cdf0e10cSrcweir
91cdf0e10cSrcweir // -----------
92cdf0e10cSrcweir // - Defines -
93cdf0e10cSrcweir // -----------
94cdf0e10cSrcweir
95cdf0e10cSrcweir #define SDTRANSFER_OBJECTTYPE_DRAWMODEL 0x00000001
96cdf0e10cSrcweir #define SDTRANSFER_OBJECTTYPE_DRAWOLE 0x00000002
97cdf0e10cSrcweir
98cdf0e10cSrcweir // ------------------
99cdf0e10cSrcweir // - SdTransferable -
100cdf0e10cSrcweir // ------------------
101cdf0e10cSrcweir
SdTransferable(SdDrawDocument * pSrcDoc,::sd::View * pWorkView,sal_Bool bInitOnGetData)102cdf0e10cSrcweir SdTransferable::SdTransferable( SdDrawDocument* pSrcDoc, ::sd::View* pWorkView, sal_Bool bInitOnGetData )
103cdf0e10cSrcweir : mpPageDocShell( NULL )
104cdf0e10cSrcweir , mpOLEDataHelper( NULL )
105cdf0e10cSrcweir , mpObjDesc( NULL )
106cdf0e10cSrcweir , mpSdView( pWorkView )
107cdf0e10cSrcweir , mpSdViewIntern( pWorkView )
108cdf0e10cSrcweir , mpSdDrawDocument( NULL )
109cdf0e10cSrcweir , mpSdDrawDocumentIntern( NULL )
110cdf0e10cSrcweir , mpSourceDoc( pSrcDoc )
111cdf0e10cSrcweir , mpVDev( NULL )
112cdf0e10cSrcweir , mpBookmark( NULL )
113cdf0e10cSrcweir , mpGraphic( NULL )
114cdf0e10cSrcweir , mpImageMap( NULL )
115cdf0e10cSrcweir , mbInternalMove( sal_False )
116cdf0e10cSrcweir , mbOwnDocument( sal_False )
117cdf0e10cSrcweir , mbOwnView( sal_False )
118cdf0e10cSrcweir , mbLateInit( bInitOnGetData )
119cdf0e10cSrcweir , mbPageTransferable( sal_False )
120cdf0e10cSrcweir , mbPageTransferablePersistent( sal_False )
121cdf0e10cSrcweir , mbIsUnoObj( false )
122cdf0e10cSrcweir , maUserData()
123cdf0e10cSrcweir {
124cdf0e10cSrcweir if( mpSourceDoc )
125cdf0e10cSrcweir StartListening( *mpSourceDoc );
126cdf0e10cSrcweir
127cdf0e10cSrcweir if( pWorkView )
128cdf0e10cSrcweir StartListening( *pWorkView );
129cdf0e10cSrcweir
130cdf0e10cSrcweir if( !mbLateInit )
131cdf0e10cSrcweir CreateData();
132cdf0e10cSrcweir }
133cdf0e10cSrcweir
134cdf0e10cSrcweir // -----------------------------------------------------------------------------
135cdf0e10cSrcweir
~SdTransferable()136cdf0e10cSrcweir SdTransferable::~SdTransferable()
137cdf0e10cSrcweir {
138cdf0e10cSrcweir if( mpSourceDoc )
139cdf0e10cSrcweir EndListening( *mpSourceDoc );
140cdf0e10cSrcweir
141cdf0e10cSrcweir if( mpSdView )
142cdf0e10cSrcweir EndListening( *const_cast< sd::View *>( mpSdView) );
143cdf0e10cSrcweir
144cdf0e10cSrcweir Application::GetSolarMutex().acquire();
145cdf0e10cSrcweir
146cdf0e10cSrcweir ObjectReleased();
147cdf0e10cSrcweir
148cdf0e10cSrcweir for( void* p = maPageBookmarks.First(); p; p = maPageBookmarks.Next() )
149cdf0e10cSrcweir delete static_cast< String* >( p );
150cdf0e10cSrcweir
151cdf0e10cSrcweir if( mbOwnView )
152cdf0e10cSrcweir delete mpSdViewIntern;
153cdf0e10cSrcweir
154cdf0e10cSrcweir delete mpOLEDataHelper;
155cdf0e10cSrcweir
156cdf0e10cSrcweir if( maDocShellRef.Is() )
157cdf0e10cSrcweir {
158cdf0e10cSrcweir SfxObjectShell* pObj = maDocShellRef;
159cdf0e10cSrcweir ::sd::DrawDocShell* pDocSh = static_cast< ::sd::DrawDocShell*>(pObj);
160cdf0e10cSrcweir pDocSh->DoClose();
161cdf0e10cSrcweir }
162cdf0e10cSrcweir
163cdf0e10cSrcweir maDocShellRef.Clear();
164cdf0e10cSrcweir
165cdf0e10cSrcweir if( mbOwnDocument )
166cdf0e10cSrcweir delete mpSdDrawDocumentIntern;
167cdf0e10cSrcweir
168cdf0e10cSrcweir delete mpGraphic;
169cdf0e10cSrcweir delete mpBookmark;
170cdf0e10cSrcweir delete mpImageMap;
171cdf0e10cSrcweir
172cdf0e10cSrcweir delete mpVDev;
173cdf0e10cSrcweir delete mpObjDesc;
174cdf0e10cSrcweir
175cdf0e10cSrcweir Application::GetSolarMutex().release();
176cdf0e10cSrcweir }
177cdf0e10cSrcweir
178cdf0e10cSrcweir // -----------------------------------------------------------------------------
179cdf0e10cSrcweir
CreateObjectReplacement(SdrObject * pObj)180cdf0e10cSrcweir void SdTransferable::CreateObjectReplacement( SdrObject* pObj )
181cdf0e10cSrcweir {
182cdf0e10cSrcweir if( pObj )
183cdf0e10cSrcweir {
184cdf0e10cSrcweir delete mpOLEDataHelper, mpOLEDataHelper = NULL;
185cdf0e10cSrcweir delete mpGraphic, mpGraphic = NULL;
186cdf0e10cSrcweir delete mpBookmark, mpBookmark = NULL;
187cdf0e10cSrcweir delete mpImageMap, mpImageMap = NULL;
188cdf0e10cSrcweir
189cdf0e10cSrcweir if( pObj->ISA( SdrOle2Obj ) )
190cdf0e10cSrcweir {
191cdf0e10cSrcweir try
192cdf0e10cSrcweir {
193cdf0e10cSrcweir uno::Reference < embed::XEmbeddedObject > xObj = static_cast< SdrOle2Obj* >( pObj )->GetObjRef();
194cdf0e10cSrcweir uno::Reference < embed::XEmbedPersist > xPersist( xObj, uno::UNO_QUERY );
195cdf0e10cSrcweir if( xObj.is() && xPersist.is() && xPersist->hasEntry() )
196cdf0e10cSrcweir {
197cdf0e10cSrcweir mpOLEDataHelper = new TransferableDataHelper( new SvEmbedTransferHelper( xObj, static_cast< SdrOle2Obj* >( pObj )->GetGraphic(), static_cast< SdrOle2Obj* >( pObj )->GetAspect() ) );
198cdf0e10cSrcweir
199cdf0e10cSrcweir // TODO/LATER: the standalone handling of the graphic should not be used any more in future
200cdf0e10cSrcweir // The EmbedDataHelper should bring the graphic in future
201cdf0e10cSrcweir Graphic* pObjGr = static_cast< SdrOle2Obj* >( pObj )->GetGraphic();
202cdf0e10cSrcweir if ( pObjGr )
203cdf0e10cSrcweir mpGraphic = new Graphic( *pObjGr );
204cdf0e10cSrcweir }
205cdf0e10cSrcweir }
206cdf0e10cSrcweir catch( uno::Exception& )
207cdf0e10cSrcweir {}
208cdf0e10cSrcweir }
209cdf0e10cSrcweir else if( pObj->ISA( SdrGrafObj ) && (mpSourceDoc && !mpSourceDoc->GetAnimationInfo( pObj )) )
210cdf0e10cSrcweir {
211cdf0e10cSrcweir mpGraphic = new Graphic( static_cast< SdrGrafObj* >( pObj )->GetTransformedGraphic() );
212cdf0e10cSrcweir }
213cdf0e10cSrcweir else if( pObj->IsUnoObj() && FmFormInventor == pObj->GetObjInventor() && ( pObj->GetObjIdentifier() == (sal_uInt16) OBJ_FM_BUTTON ) )
214cdf0e10cSrcweir {
215cdf0e10cSrcweir SdrUnoObj* pUnoCtrl = static_cast< SdrUnoObj* >( pObj );
216cdf0e10cSrcweir
217cdf0e10cSrcweir if (pUnoCtrl && FmFormInventor == pUnoCtrl->GetObjInventor())
218cdf0e10cSrcweir {
219cdf0e10cSrcweir Reference< ::com::sun::star::awt::XControlModel > xControlModel( pUnoCtrl->GetUnoControlModel() );
220cdf0e10cSrcweir
221cdf0e10cSrcweir if( !xControlModel.is() )
222cdf0e10cSrcweir return;
223cdf0e10cSrcweir
224cdf0e10cSrcweir Reference< ::com::sun::star::beans::XPropertySet > xPropSet( xControlModel, UNO_QUERY );
225cdf0e10cSrcweir
226cdf0e10cSrcweir if( !xPropSet.is() )
227cdf0e10cSrcweir return;
228cdf0e10cSrcweir
229cdf0e10cSrcweir ::com::sun::star::form::FormButtonType eButtonType;
230cdf0e10cSrcweir Any aTmp( xPropSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ButtonType" ) ) ) );
231cdf0e10cSrcweir
232cdf0e10cSrcweir if( aTmp >>= eButtonType )
233cdf0e10cSrcweir {
234cdf0e10cSrcweir ::rtl::OUString aLabel, aURL;
235cdf0e10cSrcweir
236cdf0e10cSrcweir xPropSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Label" ) ) ) >>= aLabel;
237cdf0e10cSrcweir xPropSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("TargetURL") ) ) >>= aURL;
238cdf0e10cSrcweir
239cdf0e10cSrcweir mpBookmark = new INetBookmark( String( aURL ), String( aLabel ) );
240cdf0e10cSrcweir }
241cdf0e10cSrcweir }
242cdf0e10cSrcweir }
243cdf0e10cSrcweir else if( pObj->ISA( SdrTextObj ) )
244cdf0e10cSrcweir {
245cdf0e10cSrcweir const OutlinerParaObject* pPara;
246cdf0e10cSrcweir
247cdf0e10cSrcweir if( (pPara = static_cast< SdrTextObj* >( pObj )->GetOutlinerParaObject()) != 0 )
248cdf0e10cSrcweir {
249cdf0e10cSrcweir const SvxFieldItem* pField;
250cdf0e10cSrcweir
251cdf0e10cSrcweir if( (pField = pPara->GetTextObject().GetField()) != 0 )
252cdf0e10cSrcweir {
253cdf0e10cSrcweir const SvxFieldData* pData = pField->GetField();
254cdf0e10cSrcweir
255cdf0e10cSrcweir if( pData && pData->ISA( SvxURLField ) )
256cdf0e10cSrcweir {
257cdf0e10cSrcweir const SvxURLField* pURL = (SvxURLField*) pData;
258cdf0e10cSrcweir
259728936deSArmin Le Grand // #63399# This special code identifies TextFrames which have just an URL
260728936deSArmin Le Grand // as content and directly add this to the clipboard, probably to avoid adding
261728936deSArmin Le Grand // an unnecessary DrawObject to the target where paste may take place. This is
262728936deSArmin Le Grand // wanted only for SdrObjects with no fill and no line, else it is necessary to
263728936deSArmin Le Grand // use the whole SdrObect. Test here for Line/FillStyle and take shortcut only
264728936deSArmin Le Grand // when both are unused
265728936deSArmin Le Grand if(!pObj->HasFillStyle() && !pObj->HasLineStyle())
266728936deSArmin Le Grand {
267cdf0e10cSrcweir mpBookmark = new INetBookmark( pURL->GetURL(), pURL->GetRepresentation() );
268cdf0e10cSrcweir }
269cdf0e10cSrcweir }
270cdf0e10cSrcweir }
271cdf0e10cSrcweir }
272728936deSArmin Le Grand }
273cdf0e10cSrcweir
274cdf0e10cSrcweir SdIMapInfo* pInfo = static_cast< SdDrawDocument* >( pObj->GetModel() )->GetIMapInfo( static_cast< SdrObject* >( pObj ) );
275cdf0e10cSrcweir
276cdf0e10cSrcweir if( pInfo )
277cdf0e10cSrcweir mpImageMap = new ImageMap( pInfo->GetImageMap() );
278cdf0e10cSrcweir
279cdf0e10cSrcweir mbIsUnoObj = pObj && pObj->IsUnoObj();
280cdf0e10cSrcweir }
281cdf0e10cSrcweir }
282cdf0e10cSrcweir
283cdf0e10cSrcweir // -----------------------------------------------------------------------------
284cdf0e10cSrcweir
CreateData()285cdf0e10cSrcweir void SdTransferable::CreateData()
286cdf0e10cSrcweir {
287cdf0e10cSrcweir if( mpSdDrawDocument && !mpSdViewIntern )
288cdf0e10cSrcweir {
289cdf0e10cSrcweir mbOwnView = sal_True;
290cdf0e10cSrcweir
291cdf0e10cSrcweir SdPage* pPage = mpSdDrawDocument->GetSdPage(0, PK_STANDARD);
292cdf0e10cSrcweir
293cdf0e10cSrcweir if( 1 == pPage->GetObjCount() )
294cdf0e10cSrcweir CreateObjectReplacement( pPage->GetObj( 0 ) );
295cdf0e10cSrcweir
296cdf0e10cSrcweir mpVDev = new VirtualDevice( *Application::GetDefaultDevice() );
297cdf0e10cSrcweir mpVDev->SetMapMode( MapMode( mpSdDrawDocumentIntern->GetScaleUnit(), Point(), mpSdDrawDocumentIntern->GetScaleFraction(), mpSdDrawDocumentIntern->GetScaleFraction() ) );
298cdf0e10cSrcweir mpSdViewIntern = new ::sd::View( mpSdDrawDocumentIntern, mpVDev );
299cdf0e10cSrcweir mpSdViewIntern->EndListening(*mpSdDrawDocumentIntern );
300cdf0e10cSrcweir mpSdViewIntern->hideMarkHandles();
301cdf0e10cSrcweir SdrPageView* pPageView = mpSdViewIntern->ShowSdrPage(pPage);
302cdf0e10cSrcweir ((SdrMarkView*)mpSdViewIntern)->MarkAllObj(pPageView);
303cdf0e10cSrcweir }
304cdf0e10cSrcweir else if( mpSdView && !mpSdDrawDocumentIntern )
305cdf0e10cSrcweir {
306cdf0e10cSrcweir const SdrMarkList& rMarkList = mpSdView->GetMarkedObjectList();
307cdf0e10cSrcweir
308cdf0e10cSrcweir if( rMarkList.GetMarkCount() == 1 )
309cdf0e10cSrcweir CreateObjectReplacement( rMarkList.GetMark( 0 )->GetMarkedSdrObj() );
310cdf0e10cSrcweir
311cdf0e10cSrcweir if( mpSourceDoc )
312cdf0e10cSrcweir mpSourceDoc->CreatingDataObj(this);
313cdf0e10cSrcweir mpSdDrawDocumentIntern = (SdDrawDocument*) mpSdView->GetAllMarkedModel();
314cdf0e10cSrcweir if( mpSourceDoc )
315cdf0e10cSrcweir mpSourceDoc->CreatingDataObj(0);
316cdf0e10cSrcweir
317cdf0e10cSrcweir if( !maDocShellRef.Is() && mpSdDrawDocumentIntern->GetDocSh() )
318cdf0e10cSrcweir maDocShellRef = mpSdDrawDocumentIntern->GetDocSh();
319cdf0e10cSrcweir
320cdf0e10cSrcweir if( !maDocShellRef.Is() )
321cdf0e10cSrcweir {
322cdf0e10cSrcweir DBG_ERROR( "SdTransferable::CreateData(), failed to create a model with persist, clipboard operation will fail for OLE objects!" );
323cdf0e10cSrcweir mbOwnDocument = sal_True;
324cdf0e10cSrcweir }
325cdf0e10cSrcweir
326cdf0e10cSrcweir // Groesse der Source-Seite uebernehmen
327cdf0e10cSrcweir SdrPageView* pPgView = mpSdView->GetSdrPageView();
328cdf0e10cSrcweir SdPage* pOldPage = (SdPage*) pPgView->GetPage();
329cdf0e10cSrcweir SdrModel* pOldModel = mpSdView->GetModel();
330cdf0e10cSrcweir SdStyleSheetPool* pOldStylePool = (SdStyleSheetPool*) pOldModel->GetStyleSheetPool();
331cdf0e10cSrcweir SdStyleSheetPool* pNewStylePool = (SdStyleSheetPool*) mpSdDrawDocumentIntern->GetStyleSheetPool();
332cdf0e10cSrcweir SdPage* pPage = mpSdDrawDocumentIntern->GetSdPage( 0, PK_STANDARD );
333cdf0e10cSrcweir String aOldLayoutName( pOldPage->GetLayoutName() );
334cdf0e10cSrcweir
335cdf0e10cSrcweir pPage->SetSize( pOldPage->GetSize() );
336cdf0e10cSrcweir pPage->SetLayoutName( aOldLayoutName );
337cdf0e10cSrcweir pNewStylePool->CopyGraphicSheets( *pOldStylePool );
338cdf0e10cSrcweir pNewStylePool->CopyCellSheets( *pOldStylePool );
339cdf0e10cSrcweir pNewStylePool->CopyTableStyles( *pOldStylePool );
340cdf0e10cSrcweir aOldLayoutName.Erase( aOldLayoutName.SearchAscii( SD_LT_SEPARATOR ) );
341cdf0e10cSrcweir SdStyleSheetVector aCreatedSheets;
342cdf0e10cSrcweir pNewStylePool->CopyLayoutSheets( aOldLayoutName, *pOldStylePool, aCreatedSheets );
343cdf0e10cSrcweir }
344cdf0e10cSrcweir
34586e1cf34SPedro Giffuni // set VisArea and adjust objects if necessary
346cdf0e10cSrcweir if( maVisArea.IsEmpty() &&
347cdf0e10cSrcweir mpSdDrawDocumentIntern && mpSdViewIntern &&
348cdf0e10cSrcweir mpSdDrawDocumentIntern->GetPageCount() )
349cdf0e10cSrcweir {
350cdf0e10cSrcweir SdPage* pPage = mpSdDrawDocumentIntern->GetSdPage( 0, PK_STANDARD );
351cdf0e10cSrcweir
352cdf0e10cSrcweir if( 1 == mpSdDrawDocumentIntern->GetPageCount() )
353cdf0e10cSrcweir {
354cdf0e10cSrcweir // #112978# need to use GetAllMarkedBoundRect instead of GetAllMarkedRect to get
355cdf0e10cSrcweir // fat lines correctly
356cdf0e10cSrcweir Point aOrigin( ( maVisArea = mpSdViewIntern->GetAllMarkedBoundRect() ).TopLeft() );
357cdf0e10cSrcweir Size aVector( -aOrigin.X(), -aOrigin.Y() );
358cdf0e10cSrcweir
359cdf0e10cSrcweir for( sal_uLong nObj = 0, nObjCount = pPage->GetObjCount(); nObj < nObjCount; nObj++ )
360cdf0e10cSrcweir {
361cdf0e10cSrcweir SdrObject* pObj = pPage->GetObj( nObj );
362cdf0e10cSrcweir pObj->NbcMove( aVector );
363cdf0e10cSrcweir }
364cdf0e10cSrcweir }
365cdf0e10cSrcweir else
366cdf0e10cSrcweir maVisArea.SetSize( pPage->GetSize() );
367cdf0e10cSrcweir
368cdf0e10cSrcweir // Die Ausgabe soll am Nullpunkt erfolgen
369cdf0e10cSrcweir maVisArea.SetPos( Point() );
370cdf0e10cSrcweir }
371cdf0e10cSrcweir }
372cdf0e10cSrcweir
373cdf0e10cSrcweir // -----------------------------------------------------------------------------
374cdf0e10cSrcweir
lcl_HasOnlyControls(SdrModel * pModel)375cdf0e10cSrcweir sal_Bool lcl_HasOnlyControls( SdrModel* pModel )
376cdf0e10cSrcweir {
377cdf0e10cSrcweir sal_Bool bOnlyControls = sal_False; // default if there are no objects
378cdf0e10cSrcweir
379cdf0e10cSrcweir if ( pModel )
380cdf0e10cSrcweir {
381cdf0e10cSrcweir SdrPage* pPage = pModel->GetPage(0);
382cdf0e10cSrcweir if (pPage)
383cdf0e10cSrcweir {
384cdf0e10cSrcweir SdrObjListIter aIter( *pPage, IM_DEEPNOGROUPS );
385cdf0e10cSrcweir SdrObject* pObj = aIter.Next();
386cdf0e10cSrcweir if ( pObj )
387cdf0e10cSrcweir {
388cdf0e10cSrcweir bOnlyControls = sal_True; // only set if there are any objects at all
389cdf0e10cSrcweir while ( pObj )
390cdf0e10cSrcweir {
391cdf0e10cSrcweir if (!pObj->ISA(SdrUnoObj))
392cdf0e10cSrcweir {
393cdf0e10cSrcweir bOnlyControls = sal_False;
394cdf0e10cSrcweir break;
395cdf0e10cSrcweir }
396cdf0e10cSrcweir pObj = aIter.Next();
397cdf0e10cSrcweir }
398cdf0e10cSrcweir }
399cdf0e10cSrcweir }
400cdf0e10cSrcweir }
401cdf0e10cSrcweir
402cdf0e10cSrcweir return bOnlyControls;
403cdf0e10cSrcweir }
404cdf0e10cSrcweir
405cdf0e10cSrcweir // -----------------------------------------------------------------------------
406cdf0e10cSrcweir
lcl_HasOnlyOneTable(SdrModel * pModel)407cdf0e10cSrcweir bool lcl_HasOnlyOneTable( SdrModel* pModel )
408cdf0e10cSrcweir {
409cdf0e10cSrcweir if ( pModel )
410cdf0e10cSrcweir {
411cdf0e10cSrcweir SdrPage* pPage = pModel->GetPage(0);
412cdf0e10cSrcweir if (pPage && pPage->GetObjCount() == 1 )
413cdf0e10cSrcweir {
414cdf0e10cSrcweir if( dynamic_cast< sdr::table::SdrTableObj* >( pPage->GetObj(0) ) != 0 )
415cdf0e10cSrcweir return true;
416cdf0e10cSrcweir }
417cdf0e10cSrcweir }
418cdf0e10cSrcweir return false;
419cdf0e10cSrcweir }
420cdf0e10cSrcweir
421cdf0e10cSrcweir // -----------------------------------------------------------------------------
422cdf0e10cSrcweir
AddSupportedFormats()423cdf0e10cSrcweir void SdTransferable::AddSupportedFormats()
424cdf0e10cSrcweir {
425cdf0e10cSrcweir if( !mbPageTransferable || mbPageTransferablePersistent )
426cdf0e10cSrcweir {
427cdf0e10cSrcweir if( !mbLateInit )
428cdf0e10cSrcweir CreateData();
429cdf0e10cSrcweir
430cdf0e10cSrcweir if( mpObjDesc )
431cdf0e10cSrcweir AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR );
432cdf0e10cSrcweir
433cdf0e10cSrcweir if( mpOLEDataHelper )
434cdf0e10cSrcweir {
435cdf0e10cSrcweir AddFormat( SOT_FORMATSTR_ID_EMBED_SOURCE );
436cdf0e10cSrcweir
437cdf0e10cSrcweir DataFlavorExVector aVector( mpOLEDataHelper->GetDataFlavorExVector() );
438cdf0e10cSrcweir DataFlavorExVector::iterator aIter( aVector.begin() ), aEnd( aVector.end() );
439cdf0e10cSrcweir
440cdf0e10cSrcweir while( aIter != aEnd )
441cdf0e10cSrcweir AddFormat( *aIter++ );
442cdf0e10cSrcweir }
443cdf0e10cSrcweir else if( mpGraphic )
444cdf0e10cSrcweir {
445cdf0e10cSrcweir // #i25616#
446cdf0e10cSrcweir AddFormat( SOT_FORMATSTR_ID_DRAWING );
447cdf0e10cSrcweir
448cdf0e10cSrcweir AddFormat( SOT_FORMATSTR_ID_SVXB );
449cdf0e10cSrcweir
450cdf0e10cSrcweir if( mpGraphic->GetType() == GRAPHIC_BITMAP )
451cdf0e10cSrcweir {
452a206ee71SArmin Le Grand AddFormat( SOT_FORMATSTR_ID_PNG );
453cdf0e10cSrcweir AddFormat( SOT_FORMAT_BITMAP );
454cdf0e10cSrcweir AddFormat( SOT_FORMAT_GDIMETAFILE );
455cdf0e10cSrcweir }
456cdf0e10cSrcweir else
457cdf0e10cSrcweir {
458cdf0e10cSrcweir AddFormat( SOT_FORMAT_GDIMETAFILE );
459a206ee71SArmin Le Grand AddFormat( SOT_FORMATSTR_ID_PNG );
460cdf0e10cSrcweir AddFormat( SOT_FORMAT_BITMAP );
461cdf0e10cSrcweir }
462cdf0e10cSrcweir }
463cdf0e10cSrcweir else if( mpBookmark )
464cdf0e10cSrcweir {
465cdf0e10cSrcweir AddFormat( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK );
466cdf0e10cSrcweir AddFormat( FORMAT_STRING );
467cdf0e10cSrcweir }
468cdf0e10cSrcweir else
469cdf0e10cSrcweir {
470cdf0e10cSrcweir AddFormat( SOT_FORMATSTR_ID_EMBED_SOURCE );
471cdf0e10cSrcweir AddFormat( SOT_FORMATSTR_ID_DRAWING );
472cdf0e10cSrcweir if( !mpSdDrawDocument || !lcl_HasOnlyControls( mpSdDrawDocument ) )
473cdf0e10cSrcweir {
474cdf0e10cSrcweir AddFormat( SOT_FORMAT_GDIMETAFILE );
475a206ee71SArmin Le Grand AddFormat( SOT_FORMATSTR_ID_PNG );
476cdf0e10cSrcweir AddFormat( SOT_FORMAT_BITMAP );
477cdf0e10cSrcweir }
478cdf0e10cSrcweir
479cdf0e10cSrcweir if( lcl_HasOnlyOneTable( mpSdDrawDocument ) )
480cdf0e10cSrcweir AddFormat( SOT_FORMAT_RTF );
481cdf0e10cSrcweir }
482cdf0e10cSrcweir
483cdf0e10cSrcweir if( mpImageMap )
484cdf0e10cSrcweir AddFormat( SOT_FORMATSTR_ID_SVIM );
485cdf0e10cSrcweir }
486cdf0e10cSrcweir }
487cdf0e10cSrcweir
488cdf0e10cSrcweir // -----------------------------------------------------------------------------
489cdf0e10cSrcweir
GetData(const DataFlavor & rFlavor)490cdf0e10cSrcweir sal_Bool SdTransferable::GetData( const DataFlavor& rFlavor )
491cdf0e10cSrcweir {
492cdf0e10cSrcweir if (SD_MOD()==NULL)
493cdf0e10cSrcweir return sal_False;
494cdf0e10cSrcweir
495cdf0e10cSrcweir sal_uInt32 nFormat = SotExchange::GetFormat( rFlavor );
496cdf0e10cSrcweir sal_Bool bOK = sal_False;
497cdf0e10cSrcweir
498cdf0e10cSrcweir CreateData();
499cdf0e10cSrcweir
500cdf0e10cSrcweir if( nFormat == SOT_FORMAT_RTF && lcl_HasOnlyOneTable( mpSdDrawDocument ) )
501cdf0e10cSrcweir {
502cdf0e10cSrcweir bOK = SetTableRTF( mpSdDrawDocument, rFlavor );
503cdf0e10cSrcweir }
504cdf0e10cSrcweir else if( mpOLEDataHelper && mpOLEDataHelper->HasFormat( rFlavor ) )
505cdf0e10cSrcweir {
506cdf0e10cSrcweir sal_uLong nOldSwapMode = 0;
507cdf0e10cSrcweir
508cdf0e10cSrcweir if( mpSdDrawDocumentIntern )
509cdf0e10cSrcweir {
510cdf0e10cSrcweir nOldSwapMode = mpSdDrawDocumentIntern->GetSwapGraphicsMode();
511cdf0e10cSrcweir mpSdDrawDocumentIntern->SetSwapGraphicsMode( SDR_SWAPGRAPHICSMODE_PURGE );
512cdf0e10cSrcweir }
513cdf0e10cSrcweir
514cdf0e10cSrcweir // TODO/LATER: support all the graphical formats, the embedded object scenario should not have separated handling
515cdf0e10cSrcweir if( nFormat == FORMAT_GDIMETAFILE && mpGraphic )
516cdf0e10cSrcweir bOK = SetGDIMetaFile( mpGraphic->GetGDIMetaFile(), rFlavor );
517cdf0e10cSrcweir else
518cdf0e10cSrcweir bOK = SetAny( mpOLEDataHelper->GetAny( rFlavor ), rFlavor );
519cdf0e10cSrcweir
520cdf0e10cSrcweir if( mpSdDrawDocumentIntern )
521cdf0e10cSrcweir mpSdDrawDocumentIntern->SetSwapGraphicsMode( nOldSwapMode );
522cdf0e10cSrcweir }
523cdf0e10cSrcweir else if( HasFormat( nFormat ) )
524cdf0e10cSrcweir {
525cdf0e10cSrcweir if( ( nFormat == SOT_FORMATSTR_ID_LINKSRCDESCRIPTOR || nFormat == SOT_FORMATSTR_ID_OBJECTDESCRIPTOR ) && mpObjDesc )
526cdf0e10cSrcweir {
527cdf0e10cSrcweir bOK = SetTransferableObjectDescriptor( *mpObjDesc, rFlavor );
528cdf0e10cSrcweir }
529cdf0e10cSrcweir else if( nFormat == SOT_FORMATSTR_ID_DRAWING )
530cdf0e10cSrcweir {
531cdf0e10cSrcweir SfxObjectShellRef aOldRef( maDocShellRef );
532cdf0e10cSrcweir
533cdf0e10cSrcweir maDocShellRef.Clear();
534cdf0e10cSrcweir
535cdf0e10cSrcweir if( mpSdViewIntern )
536cdf0e10cSrcweir {
537cdf0e10cSrcweir SdDrawDocument* pInternDoc = mpSdViewIntern->GetDoc();
538cdf0e10cSrcweir if( pInternDoc )
539cdf0e10cSrcweir pInternDoc->CreatingDataObj(this);
540cdf0e10cSrcweir SdDrawDocument* pDoc = dynamic_cast< SdDrawDocument* >( mpSdViewIntern->GetAllMarkedModel() );
541cdf0e10cSrcweir if( pInternDoc )
542cdf0e10cSrcweir pInternDoc->CreatingDataObj(0);
543cdf0e10cSrcweir
544cdf0e10cSrcweir bOK = SetObject( pDoc, SDTRANSFER_OBJECTTYPE_DRAWMODEL, rFlavor );
545cdf0e10cSrcweir
546cdf0e10cSrcweir if( maDocShellRef.Is() )
547cdf0e10cSrcweir {
548cdf0e10cSrcweir maDocShellRef->DoClose();
549cdf0e10cSrcweir }
550cdf0e10cSrcweir else
551cdf0e10cSrcweir {
552cdf0e10cSrcweir delete pDoc;
553cdf0e10cSrcweir }
554cdf0e10cSrcweir }
555cdf0e10cSrcweir
556cdf0e10cSrcweir maDocShellRef = aOldRef;
557cdf0e10cSrcweir }
558cdf0e10cSrcweir else if( nFormat == FORMAT_GDIMETAFILE )
559cdf0e10cSrcweir {
560cdf0e10cSrcweir if( mpSdViewIntern )
561bb18ee55SArmin Le Grand bOK = SetGDIMetaFile( mpSdViewIntern->GetMarkedObjMetaFile(true), rFlavor );
562cdf0e10cSrcweir }
56345fd3b9aSArmin Le Grand else if( FORMAT_BITMAP == nFormat || SOT_FORMATSTR_ID_PNG == nFormat )
564cdf0e10cSrcweir {
565cdf0e10cSrcweir if( mpSdViewIntern )
56645fd3b9aSArmin Le Grand bOK = SetBitmapEx( mpSdViewIntern->GetMarkedObjBitmapEx(true), rFlavor );
567cdf0e10cSrcweir }
568cdf0e10cSrcweir else if( ( nFormat == FORMAT_STRING ) && mpBookmark )
569cdf0e10cSrcweir {
570cdf0e10cSrcweir bOK = SetString( mpBookmark->GetURL(), rFlavor );
571cdf0e10cSrcweir }
572cdf0e10cSrcweir else if( ( nFormat == SOT_FORMATSTR_ID_SVXB ) && mpGraphic )
573cdf0e10cSrcweir {
574cdf0e10cSrcweir bOK = SetGraphic( *mpGraphic, rFlavor );
575cdf0e10cSrcweir }
576cdf0e10cSrcweir else if( ( nFormat == SOT_FORMATSTR_ID_SVIM ) && mpImageMap )
577cdf0e10cSrcweir {
578cdf0e10cSrcweir bOK = SetImageMap( *mpImageMap, rFlavor );
579cdf0e10cSrcweir }
580cdf0e10cSrcweir else if( mpBookmark )
581cdf0e10cSrcweir {
582cdf0e10cSrcweir bOK = SetINetBookmark( *mpBookmark, rFlavor );
583cdf0e10cSrcweir }
584cdf0e10cSrcweir else if( nFormat == SOT_FORMATSTR_ID_EMBED_SOURCE )
585cdf0e10cSrcweir {
586cdf0e10cSrcweir sal_uLong nOldSwapMode = 0;
587cdf0e10cSrcweir
588cdf0e10cSrcweir if( mpSdDrawDocumentIntern )
589cdf0e10cSrcweir {
590cdf0e10cSrcweir nOldSwapMode = mpSdDrawDocumentIntern->GetSwapGraphicsMode();
591cdf0e10cSrcweir mpSdDrawDocumentIntern->SetSwapGraphicsMode( SDR_SWAPGRAPHICSMODE_PURGE );
592cdf0e10cSrcweir }
593cdf0e10cSrcweir
594cdf0e10cSrcweir if( !maDocShellRef.Is() )
595cdf0e10cSrcweir {
596cdf0e10cSrcweir maDocShellRef = new ::sd::DrawDocShell(
597cdf0e10cSrcweir mpSdDrawDocumentIntern,
598cdf0e10cSrcweir SFX_CREATE_MODE_EMBEDDED,
599cdf0e10cSrcweir sal_True,
600cdf0e10cSrcweir mpSdDrawDocumentIntern->GetDocumentType());
601cdf0e10cSrcweir mbOwnDocument = sal_False;
602cdf0e10cSrcweir maDocShellRef->DoInitNew( NULL );
603cdf0e10cSrcweir }
604cdf0e10cSrcweir
605cdf0e10cSrcweir maDocShellRef->SetVisArea( maVisArea );
606cdf0e10cSrcweir bOK = SetObject( &maDocShellRef, SDTRANSFER_OBJECTTYPE_DRAWOLE, rFlavor );
607cdf0e10cSrcweir
608cdf0e10cSrcweir if( mpSdDrawDocumentIntern )
609cdf0e10cSrcweir mpSdDrawDocumentIntern->SetSwapGraphicsMode( nOldSwapMode );
610cdf0e10cSrcweir }
611cdf0e10cSrcweir }
612cdf0e10cSrcweir
613cdf0e10cSrcweir return bOK;
614cdf0e10cSrcweir }
615cdf0e10cSrcweir
616cdf0e10cSrcweir // -----------------------------------------------------------------------------
617cdf0e10cSrcweir
618cdf0e10cSrcweir /* testcode
619cdf0e10cSrcweir #include <sfx2/docfile.hxx>
620cdf0e10cSrcweir */
621cdf0e10cSrcweir
WriteObject(SotStorageStreamRef & rxOStm,void * pObject,sal_uInt32 nObjectType,const DataFlavor &)622cdf0e10cSrcweir sal_Bool SdTransferable::WriteObject( SotStorageStreamRef& rxOStm, void* pObject, sal_uInt32 nObjectType, const DataFlavor& )
623cdf0e10cSrcweir {
624cdf0e10cSrcweir sal_Bool bRet = sal_False;
625cdf0e10cSrcweir
626cdf0e10cSrcweir switch( nObjectType )
627cdf0e10cSrcweir {
628cdf0e10cSrcweir case( SDTRANSFER_OBJECTTYPE_DRAWMODEL ):
629cdf0e10cSrcweir {
630cdf0e10cSrcweir try
631cdf0e10cSrcweir {
632cdf0e10cSrcweir static const sal_Bool bDontBurnInStyleSheet = ( getenv( "AVOID_BURN_IN_FOR_GALLERY_THEME" ) != NULL );
633cdf0e10cSrcweir SdDrawDocument* pDoc = (SdDrawDocument*) pObject;
634cdf0e10cSrcweir if ( !bDontBurnInStyleSheet )
635cdf0e10cSrcweir pDoc->BurnInStyleSheetAttributes();
636cdf0e10cSrcweir rxOStm->SetBufferSize( 16348 );
637cdf0e10cSrcweir
638cdf0e10cSrcweir Reference< XComponent > xComponent( new SdXImpressDocument( pDoc, sal_True ) );
639cdf0e10cSrcweir pDoc->setUnoModel( Reference< XInterface >::query( xComponent ) );
640cdf0e10cSrcweir
641cdf0e10cSrcweir {
642cdf0e10cSrcweir com::sun::star::uno::Reference<com::sun::star::io::XOutputStream> xDocOut( new utl::OOutputStreamWrapper( *rxOStm ) );
643cdf0e10cSrcweir if( SvxDrawingLayerExport( pDoc, xDocOut, xComponent, (pDoc->GetDocumentType() == DOCUMENT_TYPE_IMPRESS) ? "com.sun.star.comp.Impress.XMLClipboardExporter" : "com.sun.star.comp.DrawingLayer.XMLExporter" ) )
644cdf0e10cSrcweir rxOStm->Commit();
645cdf0e10cSrcweir }
646cdf0e10cSrcweir
647cdf0e10cSrcweir /* testcode
648cdf0e10cSrcweir {
649cdf0e10cSrcweir const rtl::OUString aURL( RTL_CONSTASCII_USTRINGPARAM( "file:///e:/test.xml" ) );
650cdf0e10cSrcweir SfxMedium aMedium( aURL, STREAM_WRITE | STREAM_TRUNC, sal_True );
651cdf0e10cSrcweir aMedium.IsRemote();
652cdf0e10cSrcweir com::sun::star::uno::Reference<com::sun::star::io::XOutputStream> xDocOut( new utl::OOutputStreamWrapper( *aMedium.GetOutStream() ) );
653cdf0e10cSrcweir if( SvxDrawingLayerExport( pDoc, xDocOut, xComponent, (pDoc->GetDocumentType() == DOCUMENT_TYPE_IMPRESS) ? "com.sun.star.comp.Impress.XMLClipboardExporter" : "com.sun.star.comp.DrawingLayer.XMLExporter" ) )
654cdf0e10cSrcweir aMedium.Commit();
655cdf0e10cSrcweir }
656cdf0e10cSrcweir */
657cdf0e10cSrcweir
658cdf0e10cSrcweir xComponent->dispose();
659cdf0e10cSrcweir bRet = ( rxOStm->GetError() == ERRCODE_NONE );
660cdf0e10cSrcweir }
661cdf0e10cSrcweir catch( Exception& )
662cdf0e10cSrcweir {
663*2eda3cbfSmseidel DBG_ERROR( "sd::SdTransferable::WriteObject(), exception caught!" );
664cdf0e10cSrcweir bRet = sal_False;
665cdf0e10cSrcweir }
666cdf0e10cSrcweir }
667cdf0e10cSrcweir break;
668cdf0e10cSrcweir
669cdf0e10cSrcweir case( SDTRANSFER_OBJECTTYPE_DRAWOLE ):
670cdf0e10cSrcweir {
671cdf0e10cSrcweir SfxObjectShell* pEmbObj = (SfxObjectShell*) pObject;
672cdf0e10cSrcweir ::utl::TempFile aTempFile;
673cdf0e10cSrcweir aTempFile.EnableKillingFile();
674cdf0e10cSrcweir
675cdf0e10cSrcweir try
676cdf0e10cSrcweir {
677cdf0e10cSrcweir uno::Reference< embed::XStorage > xWorkStore =
678cdf0e10cSrcweir ::comphelper::OStorageHelper::GetStorageFromURL( aTempFile.GetURL(), embed::ElementModes::READWRITE );
679cdf0e10cSrcweir
680cdf0e10cSrcweir // write document storage
681cdf0e10cSrcweir pEmbObj->SetupStorage( xWorkStore, SOFFICE_FILEFORMAT_CURRENT, sal_False );
682cdf0e10cSrcweir // mba: no relative ULRs for clipboard!
683cdf0e10cSrcweir SfxMedium aMedium( xWorkStore, String() );
684cdf0e10cSrcweir bRet = pEmbObj->DoSaveObjectAs( aMedium, sal_False );
685cdf0e10cSrcweir pEmbObj->DoSaveCompleted();
686cdf0e10cSrcweir
687cdf0e10cSrcweir uno::Reference< embed::XTransactedObject > xTransact( xWorkStore, uno::UNO_QUERY );
688cdf0e10cSrcweir if ( xTransact.is() )
689cdf0e10cSrcweir xTransact->commit();
690cdf0e10cSrcweir
691cdf0e10cSrcweir SvStream* pSrcStm = ::utl::UcbStreamHelper::CreateStream( aTempFile.GetURL(), STREAM_READ );
692cdf0e10cSrcweir if( pSrcStm )
693cdf0e10cSrcweir {
694cdf0e10cSrcweir rxOStm->SetBufferSize( 0xff00 );
695cdf0e10cSrcweir *rxOStm << *pSrcStm;
696cdf0e10cSrcweir delete pSrcStm;
697cdf0e10cSrcweir }
698cdf0e10cSrcweir
699cdf0e10cSrcweir bRet = sal_True;
700cdf0e10cSrcweir rxOStm->Commit();
701cdf0e10cSrcweir }
702cdf0e10cSrcweir catch ( Exception& )
703cdf0e10cSrcweir {}
704cdf0e10cSrcweir }
705cdf0e10cSrcweir
706cdf0e10cSrcweir break;
707cdf0e10cSrcweir
708cdf0e10cSrcweir default:
709cdf0e10cSrcweir break;
710cdf0e10cSrcweir }
711cdf0e10cSrcweir
712cdf0e10cSrcweir return bRet;
713cdf0e10cSrcweir }
714cdf0e10cSrcweir
715cdf0e10cSrcweir // -----------------------------------------------------------------------------
716cdf0e10cSrcweir
DragFinished(sal_Int8 nDropAction)717cdf0e10cSrcweir void SdTransferable::DragFinished( sal_Int8 nDropAction )
718cdf0e10cSrcweir {
719cdf0e10cSrcweir if( mpSdView )
720cdf0e10cSrcweir ( (::sd::View*) mpSdView )->DragFinished( nDropAction );
721cdf0e10cSrcweir }
722cdf0e10cSrcweir
723cdf0e10cSrcweir // -----------------------------------------------------------------------------
724cdf0e10cSrcweir
ObjectReleased()725cdf0e10cSrcweir void SdTransferable::ObjectReleased()
726cdf0e10cSrcweir {
727cdf0e10cSrcweir if( this == SD_MOD()->pTransferClip )
728cdf0e10cSrcweir SD_MOD()->pTransferClip = NULL;
729cdf0e10cSrcweir
730cdf0e10cSrcweir if( this == SD_MOD()->pTransferDrag )
731cdf0e10cSrcweir SD_MOD()->pTransferDrag = NULL;
732cdf0e10cSrcweir
733cdf0e10cSrcweir if( this == SD_MOD()->pTransferSelection )
734cdf0e10cSrcweir SD_MOD()->pTransferSelection = NULL;
735cdf0e10cSrcweir }
736cdf0e10cSrcweir
737cdf0e10cSrcweir // -----------------------------------------------------------------------------
738cdf0e10cSrcweir
SetObjectDescriptor(const TransferableObjectDescriptor & rObjDesc)739cdf0e10cSrcweir void SdTransferable::SetObjectDescriptor( const TransferableObjectDescriptor& rObjDesc )
740cdf0e10cSrcweir {
741cdf0e10cSrcweir delete mpObjDesc;
742cdf0e10cSrcweir mpObjDesc = new TransferableObjectDescriptor( rObjDesc );
743cdf0e10cSrcweir PrepareOLE( rObjDesc );
744cdf0e10cSrcweir }
745cdf0e10cSrcweir
746cdf0e10cSrcweir // -----------------------------------------------------------------------------
747cdf0e10cSrcweir
SetPageBookmarks(const List & rPageBookmarks,sal_Bool bPersistent)748cdf0e10cSrcweir void SdTransferable::SetPageBookmarks( const List& rPageBookmarks, sal_Bool bPersistent )
749cdf0e10cSrcweir {
750cdf0e10cSrcweir if( mpSourceDoc )
751cdf0e10cSrcweir {
752cdf0e10cSrcweir if( mpSdViewIntern )
753cdf0e10cSrcweir mpSdViewIntern->HideSdrPage();
754cdf0e10cSrcweir
755cdf0e10cSrcweir // #116168#
756cdf0e10cSrcweir mpSdDrawDocument->ClearModel(sal_False);
757cdf0e10cSrcweir
758cdf0e10cSrcweir mpPageDocShell = NULL;
759cdf0e10cSrcweir
760cdf0e10cSrcweir for( void* p = maPageBookmarks.First(); p; p = maPageBookmarks.Next() )
761cdf0e10cSrcweir delete static_cast< String* >( p );
762cdf0e10cSrcweir
763cdf0e10cSrcweir if( bPersistent )
764cdf0e10cSrcweir {
765cdf0e10cSrcweir mpSdDrawDocument->CreateFirstPages(mpSourceDoc);
766cdf0e10cSrcweir mpSdDrawDocument->InsertBookmarkAsPage( const_cast< List* >( &rPageBookmarks ), NULL, sal_False, sal_True, 1, sal_True, mpSourceDoc->GetDocSh(), sal_True, sal_True, sal_False );
767cdf0e10cSrcweir }
768cdf0e10cSrcweir else
769cdf0e10cSrcweir {
770cdf0e10cSrcweir mpPageDocShell = mpSourceDoc->GetDocSh();
771cdf0e10cSrcweir
772cdf0e10cSrcweir for( sal_uLong i = 0; i < rPageBookmarks.Count(); i++ )
773cdf0e10cSrcweir maPageBookmarks.Insert( new String( *static_cast< String* >( rPageBookmarks.GetObject( i ) ) ), LIST_APPEND );
774cdf0e10cSrcweir }
775cdf0e10cSrcweir
776cdf0e10cSrcweir if( mpSdViewIntern && mpSdDrawDocument )
777cdf0e10cSrcweir {
778cdf0e10cSrcweir SdPage* pPage = mpSdDrawDocument->GetSdPage( 0, PK_STANDARD );
779cdf0e10cSrcweir
780cdf0e10cSrcweir if( pPage )
781cdf0e10cSrcweir {
782cdf0e10cSrcweir ( (SdrMarkView*) mpSdViewIntern )->MarkAllObj( (SdrPageView*) mpSdViewIntern->ShowSdrPage( pPage ) );
783cdf0e10cSrcweir }
784cdf0e10cSrcweir }
785cdf0e10cSrcweir
786cdf0e10cSrcweir // set flags for page transferable; if ( mbPageTransferablePersistent == sal_False ),
787*2eda3cbfSmseidel // don't offer any formats => it's just for internal purposes
788cdf0e10cSrcweir mbPageTransferable = sal_True;
789cdf0e10cSrcweir mbPageTransferablePersistent = bPersistent;
790cdf0e10cSrcweir }
791cdf0e10cSrcweir }
792cdf0e10cSrcweir
793cdf0e10cSrcweir // -----------------------------------------------------------------------------
794cdf0e10cSrcweir
getSomething(const::com::sun::star::uno::Sequence<sal_Int8> & rId)795cdf0e10cSrcweir sal_Int64 SAL_CALL SdTransferable::getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw( ::com::sun::star::uno::RuntimeException )
796cdf0e10cSrcweir {
797cdf0e10cSrcweir sal_Int64 nRet;
798cdf0e10cSrcweir
799cdf0e10cSrcweir if( ( rId.getLength() == 16 ) &&
800cdf0e10cSrcweir ( 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), rId.getConstArray(), 16 ) ) )
801cdf0e10cSrcweir {
802cdf0e10cSrcweir nRet = sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
803cdf0e10cSrcweir }
804cdf0e10cSrcweir else
805cdf0e10cSrcweir {
806cdf0e10cSrcweir nRet = 0;
807cdf0e10cSrcweir }
808cdf0e10cSrcweir
809cdf0e10cSrcweir return nRet;
810cdf0e10cSrcweir }
811cdf0e10cSrcweir
812cdf0e10cSrcweir
813cdf0e10cSrcweir
814cdf0e10cSrcweir
GetSourceDoc(void) const815cdf0e10cSrcweir SdDrawDocument* SdTransferable::GetSourceDoc (void) const
816cdf0e10cSrcweir {
817cdf0e10cSrcweir return mpSourceDoc;
818cdf0e10cSrcweir }
819cdf0e10cSrcweir
820cdf0e10cSrcweir
821cdf0e10cSrcweir
822cdf0e10cSrcweir
AddUserData(const::boost::shared_ptr<UserData> & rpData)823cdf0e10cSrcweir void SdTransferable::AddUserData (const ::boost::shared_ptr<UserData>& rpData)
824cdf0e10cSrcweir {
825cdf0e10cSrcweir maUserData.push_back(rpData);
826cdf0e10cSrcweir }
827cdf0e10cSrcweir
828cdf0e10cSrcweir
829cdf0e10cSrcweir
830cdf0e10cSrcweir
RemoveUserData(const::boost::shared_ptr<UserData> & rpData)831cdf0e10cSrcweir void SdTransferable::RemoveUserData (const ::boost::shared_ptr<UserData>& rpData)
832cdf0e10cSrcweir {
833cdf0e10cSrcweir maUserData.erase(::std::find(maUserData.begin(), maUserData.end(), rpData));
834cdf0e10cSrcweir }
835cdf0e10cSrcweir
836cdf0e10cSrcweir
837cdf0e10cSrcweir
838cdf0e10cSrcweir
GetUserDataCount(void) const839cdf0e10cSrcweir sal_Int32 SdTransferable::GetUserDataCount (void) const
840cdf0e10cSrcweir {
841cdf0e10cSrcweir return maUserData.size();
842cdf0e10cSrcweir }
843cdf0e10cSrcweir
844cdf0e10cSrcweir
845cdf0e10cSrcweir
846cdf0e10cSrcweir
GetUserData(const sal_Int32 nIndex) const847cdf0e10cSrcweir ::boost::shared_ptr<SdTransferable::UserData> SdTransferable::GetUserData (const sal_Int32 nIndex) const
848cdf0e10cSrcweir {
849cdf0e10cSrcweir if (nIndex>=0 && nIndex<sal_Int32(maUserData.size()))
850cdf0e10cSrcweir return maUserData[nIndex];
851cdf0e10cSrcweir else
852cdf0e10cSrcweir return ::boost::shared_ptr<UserData>();
853cdf0e10cSrcweir }
854cdf0e10cSrcweir
855cdf0e10cSrcweir
856cdf0e10cSrcweir
857cdf0e10cSrcweir
858cdf0e10cSrcweir // -----------------------------------------------------------------------------
859cdf0e10cSrcweir
getUnoTunnelId()860cdf0e10cSrcweir const ::com::sun::star::uno::Sequence< sal_Int8 >& SdTransferable::getUnoTunnelId()
861cdf0e10cSrcweir {
862cdf0e10cSrcweir static ::com::sun::star::uno::Sequence< sal_Int8 > aSeq;
863cdf0e10cSrcweir
864cdf0e10cSrcweir if( !aSeq.getLength() )
865cdf0e10cSrcweir {
866cdf0e10cSrcweir static osl::Mutex aCreateMutex;
867cdf0e10cSrcweir osl::MutexGuard aGuard( aCreateMutex );
868cdf0e10cSrcweir
869cdf0e10cSrcweir aSeq.realloc( 16 );
870cdf0e10cSrcweir rtl_createUuid( reinterpret_cast< sal_uInt8* >( aSeq.getArray() ), 0, sal_True );
871cdf0e10cSrcweir }
872cdf0e10cSrcweir
873cdf0e10cSrcweir return aSeq;
874cdf0e10cSrcweir }
875cdf0e10cSrcweir
876cdf0e10cSrcweir // -----------------------------------------------------------------------------
877cdf0e10cSrcweir
getImplementation(const Reference<XInterface> & rxData)878cdf0e10cSrcweir SdTransferable* SdTransferable::getImplementation( const Reference< XInterface >& rxData ) throw()
879cdf0e10cSrcweir {
880cdf0e10cSrcweir try
881cdf0e10cSrcweir {
882cdf0e10cSrcweir Reference< ::com::sun::star::lang::XUnoTunnel > xUnoTunnel( rxData, UNO_QUERY_THROW );
883cdf0e10cSrcweir return reinterpret_cast<SdTransferable*>(sal::static_int_cast<sal_uIntPtr>(xUnoTunnel->getSomething( SdTransferable::getUnoTunnelId()) ) );
884cdf0e10cSrcweir }
885cdf0e10cSrcweir catch( const ::com::sun::star::uno::Exception& )
886cdf0e10cSrcweir {
887cdf0e10cSrcweir }
888cdf0e10cSrcweir return NULL;
889cdf0e10cSrcweir }
890cdf0e10cSrcweir
891cdf0e10cSrcweir // -----------------------------------------------------------------------------
892cdf0e10cSrcweir
893cdf0e10cSrcweir // SfxListener
Notify(SfxBroadcaster & rBC,const SfxHint & rHint)894cdf0e10cSrcweir void SdTransferable::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
895cdf0e10cSrcweir {
896cdf0e10cSrcweir const SdrHint* pSdrHint = dynamic_cast< const SdrHint* >( &rHint );
897cdf0e10cSrcweir if( pSdrHint )
898cdf0e10cSrcweir {
899cdf0e10cSrcweir if( HINT_MODELCLEARED == pSdrHint->GetKind() )
900cdf0e10cSrcweir {
901cdf0e10cSrcweir EndListening(*mpSourceDoc);
902cdf0e10cSrcweir mpSourceDoc = 0;
903cdf0e10cSrcweir }
904cdf0e10cSrcweir }
905cdf0e10cSrcweir else
906cdf0e10cSrcweir {
907cdf0e10cSrcweir const SfxSimpleHint* pSimpleHint = dynamic_cast< const SfxSimpleHint * >(&rHint);
908cdf0e10cSrcweir if(pSimpleHint && (pSimpleHint->GetId() == SFX_HINT_DYING) )
909cdf0e10cSrcweir {
910cdf0e10cSrcweir if( &rBC == mpSourceDoc )
911cdf0e10cSrcweir mpSourceDoc = 0;
912cdf0e10cSrcweir if( &rBC == mpSdViewIntern )
913cdf0e10cSrcweir mpSdViewIntern = 0;
914cdf0e10cSrcweir if( &rBC == mpSdView )
915cdf0e10cSrcweir mpSdView = 0;
916cdf0e10cSrcweir }
917cdf0e10cSrcweir }
918cdf0e10cSrcweir }
919cdf0e10cSrcweir
SetTableRTF(SdDrawDocument * pModel,const DataFlavor & rFlavor)920cdf0e10cSrcweir sal_Bool SdTransferable::SetTableRTF( SdDrawDocument* pModel, const DataFlavor& rFlavor)
921cdf0e10cSrcweir {
922cdf0e10cSrcweir if ( pModel )
923cdf0e10cSrcweir {
924cdf0e10cSrcweir SdrPage* pPage = pModel->GetPage(0);
925cdf0e10cSrcweir if (pPage && pPage->GetObjCount() == 1 )
926cdf0e10cSrcweir {
927cdf0e10cSrcweir sdr::table::SdrTableObj* pTableObj = dynamic_cast< sdr::table::SdrTableObj* >( pPage->GetObj(0) );
928cdf0e10cSrcweir if( pTableObj )
929cdf0e10cSrcweir {
930cdf0e10cSrcweir SvMemoryStream aMemStm( 65535, 65535 );
931cdf0e10cSrcweir sdr::table::SdrTableObj::ExportAsRTF( aMemStm, *pTableObj );
932cdf0e10cSrcweir return SetAny( Any( Sequence< sal_Int8 >( reinterpret_cast< const sal_Int8* >( aMemStm.GetData() ), aMemStm.Seek( STREAM_SEEK_TO_END ) ) ), rFlavor );
933cdf0e10cSrcweir }
934cdf0e10cSrcweir }
935cdf0e10cSrcweir }
936cdf0e10cSrcweir
937cdf0e10cSrcweir return sal_False;
938cdf0e10cSrcweir }
939