1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include "fuinsert.hxx"
23 #include <comphelper/storagehelper.hxx>
24 #include <comphelper/processfactory.hxx>
25 #include <toolkit/helper/vclunohelper.hxx>
26 #include <svx/svxdlg.hxx>
27 #include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
28 #include <com/sun/star/embed/Aspects.hpp>
29 #include <com/sun/star/beans/XPropertySet.hpp>
30 #include <com/sun/star/chart2/XChartDocument.hpp>
31 #include <com/sun/star/drawing/FillStyle.hpp>
33 #include <tools/urlobj.hxx>
34 #include <svl/urihelper.hxx>
35 #include <sfx2/msgpool.hxx>
36 #include <svtools/sores.hxx>
37 #include <svtools/insdlg.hxx>
38 #include <sfx2/request.hxx>
39 #include <svl/globalnameitem.hxx>
40 #include <unotools/pathoptions.hxx>
41 #include <svtools/miscopt.hxx>
42 #include <svx/pfiledlg.hxx>
43 #include <svx/dialogs.hrc>
44 #include <sfx2/linkmgr.hxx>
45 #include <svx/linkwarn.hxx>
46 #include <svx/svdetc.hxx>
47 #include <avmedia/mediawindow.hxx>
48 #include <unotools/ucbstreamhelper.hxx>
49 #include <sfx2/printer.hxx>
50 #include <comphelper/classids.hxx>
51 #include <svtools/sfxecode.hxx>
52 #include <svtools/transfer.hxx>
53 #include <svl/urlbmk.hxx>
54 #include <svx/svdobj.hxx>
55 #include <svx/svdograf.hxx>
56 #include <svx/svdoole2.hxx>
57 #include <svx/svdomedia.hxx>
58 #include <editeng/editeng.hxx>
59 #include <sot/storage.hxx>
60 #include <sot/formats.hxx>
61 #include <svx/svdpagv.hxx>
62 #include <vcl/msgbox.hxx>
63 #include <sfx2/opengrf.hxx>
65 #include <sfx2/viewfrm.hxx>
68 #include "sdresid.hxx"
72 #include "drawview.hxx"
73 #include "DrawViewShell.hxx"
74 #include "DrawDocShell.hxx"
75 #include "GraphicDocShell.hxx"
76 #include "strings.hrc"
77 #include "drawdoc.hxx"
78 #include "sdgrffilter.hxx"
80 #include <vcl/svapp.hxx>
81 #include "undo/undoobjects.hxx"
84 using namespace com::sun::star
;
88 TYPEINIT1( FuInsertGraphic
, FuPoor
);
89 TYPEINIT1( FuInsertClipboard
, FuPoor
);
90 TYPEINIT1( FuInsertOLE
, FuPoor
);
91 TYPEINIT1( FuInsertAVMedia
, FuPoor
);
93 FuInsertGraphic::FuInsertGraphic (
99 : FuPoor(pViewSh
, pWin
, pView
, pDoc
, rReq
)
103 FunctionReference
FuInsertGraphic::Create( ViewShell
* pViewSh
, ::sd::Window
* pWin
, ::sd::View
* pView
, SdDrawDocument
* pDoc
, SfxRequest
& rReq
)
105 FunctionReference
xFunc( new FuInsertGraphic( pViewSh
, pWin
, pView
, pDoc
, rReq
) );
106 xFunc
->DoExecute(rReq
);
110 void FuInsertGraphic::DoExecute( SfxRequest
& )
112 SvxOpenGraphicDialog
aDlg(SdResId(STR_INSERTGRAPHIC
));
114 if( aDlg
.Execute() == GRFILTER_OK
)
117 int nError
= aDlg
.GetGraphic(aGraphic
);
118 if( nError
== GRFILTER_OK
)
120 if( mpViewShell
&& mpViewShell
->ISA(DrawViewShell
))
122 sal_Int8 nAction
= DND_ACTION_COPY
;
125 if( ( pPickObj
= mpView
->GetSelectedSingleObject( mpView
->GetPage() ) ) || ( pPickObj
= mpView
->GetEmptyPresentationObject( PRESOBJ_GRAPHIC
) ) )
126 nAction
= DND_ACTION_LINK
;
129 Rectangle
aRect(aPos
, mpWindow
->GetOutputSizePixel() );
130 aPos
= aRect
.Center();
131 aPos
= mpWindow
->PixelToLogic(aPos
);
132 SdrGrafObj
* pGrafObj
= mpView
->InsertGraphic(aGraphic
, nAction
, aPos
, pPickObj
, NULL
);
134 if(pGrafObj
&& aDlg
.IsAsLink())
136 // really store as link only?
137 if( SvtMiscOptions().ShowLinkWarningDialog() )
139 SvxLinkWarningDialog
aWarnDlg(mpWindow
,aDlg
.GetPath());
140 if( aWarnDlg
.Execute() != RET_OK
)
141 return; // don't store as link
145 String
aFltName(aDlg
.GetCurrentFilter());
146 String
aPath(aDlg
.GetPath());
147 pGrafObj
->SetGraphicLink(aPath
, aFltName
);
153 SdGRFFilter::HandleGraphicFilterError( (sal_uInt16
)nError
, GraphicFilter::GetGraphicFilter().GetLastError().nStreamError
);
159 FuInsertClipboard::FuInsertClipboard (
163 SdDrawDocument
* pDoc
,
165 : FuPoor(pViewSh
, pWin
, pView
, pDoc
, rReq
)
169 FunctionReference
FuInsertClipboard::Create( ViewShell
* pViewSh
, ::sd::Window
* pWin
, ::sd::View
* pView
, SdDrawDocument
* pDoc
, SfxRequest
& rReq
)
171 FunctionReference
xFunc( new FuInsertClipboard( pViewSh
, pWin
, pView
, pDoc
, rReq
) );
172 xFunc
->DoExecute(rReq
);
176 void FuInsertClipboard::DoExecute( SfxRequest
& )
178 TransferableDataHelper
aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( mpWindow
) );
181 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
182 SfxAbstractPasteDialog
* pDlg
= pFact
->CreatePasteDialog( mpViewShell
->GetActiveWindow() );
185 const String aEmptyString
;
186 ::com::sun::star::datatransfer::DataFlavor aFlavor
;
188 pDlg
->Insert( SOT_FORMATSTR_ID_EMBED_SOURCE
, aEmptyString
);
189 pDlg
->Insert( SOT_FORMATSTR_ID_LINK_SOURCE
, aEmptyString
);
190 pDlg
->Insert( SOT_FORMATSTR_ID_DRAWING
, aEmptyString
);
191 pDlg
->Insert( SOT_FORMATSTR_ID_SVXB
, aEmptyString
);
192 pDlg
->Insert( FORMAT_GDIMETAFILE
, aEmptyString
);
193 pDlg
->Insert( FORMAT_BITMAP
, aEmptyString
);
194 pDlg
->Insert( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK
, aEmptyString
);
195 pDlg
->Insert( FORMAT_STRING
, aEmptyString
);
196 pDlg
->Insert( SOT_FORMATSTR_ID_HTML
, aEmptyString
);
197 pDlg
->Insert( FORMAT_RTF
, aEmptyString
);
198 pDlg
->Insert( SOT_FORMATSTR_ID_EDITENGINE
, aEmptyString
);
201 nFormatId
= pDlg
->GetFormat( aDataHelper
);
202 if( nFormatId
&& aDataHelper
.GetTransferable().is() )
204 sal_Int8 nAction
= DND_ACTION_COPY
;
206 if( !mpView
->InsertData( aDataHelper
,
207 mpWindow
->PixelToLogic( Rectangle( Point(), mpWindow
->GetOutputSizePixel() ).Center() ),
208 nAction
, sal_False
, nFormatId
) &&
209 ( mpViewShell
&& mpViewShell
->ISA( DrawViewShell
) ) )
211 DrawViewShell
* pDrViewSh
= static_cast<DrawViewShell
*>(mpViewShell
);
212 INetBookmark
aINetBookmark( aEmptyStr
, aEmptyStr
);
214 if( ( aDataHelper
.HasFormat( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK
) &&
215 aDataHelper
.GetINetBookmark( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK
, aINetBookmark
) ) ||
216 ( aDataHelper
.HasFormat( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR
) &&
217 aDataHelper
.GetINetBookmark( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR
, aINetBookmark
) ) ||
218 ( aDataHelper
.HasFormat( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR
) &&
219 aDataHelper
.GetINetBookmark( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR
, aINetBookmark
) ) )
221 pDrViewSh
->InsertURLField( aINetBookmark
.GetURL(), aINetBookmark
.GetDescription(), aEmptyStr
, NULL
);
232 FuInsertOLE::FuInsertOLE (
236 SdDrawDocument
* pDoc
,
238 : FuPoor(pViewSh
, pWin
, pView
, pDoc
, rReq
)
242 FunctionReference
FuInsertOLE::Create( ViewShell
* pViewSh
, ::sd::Window
* pWin
, ::sd::View
* pView
, SdDrawDocument
* pDoc
, SfxRequest
& rReq
)
244 FunctionReference
xFunc( new FuInsertOLE( pViewSh
, pWin
, pView
, pDoc
, rReq
) );
245 xFunc
->DoExecute(rReq
);
249 void FuInsertOLE::DoExecute( SfxRequest
& rReq
)
251 if ( nSlotId
== SID_ATTR_TABLE
||
252 nSlotId
== SID_INSERT_DIAGRAM
||
253 nSlotId
== SID_INSERT_MATH
)
255 PresObjKind ePresObjKind
= (nSlotId
== SID_INSERT_DIAGRAM
) ? PRESOBJ_CHART
: PRESOBJ_OBJECT
;
257 SdrObject
* pPickObj
= mpView
->GetEmptyPresentationObject( ePresObjKind
);
259 // insert diagram or Calc table
262 if (nSlotId
== SID_INSERT_DIAGRAM
)
263 aName
= SvGlobalName( SO3_SCH_CLASSID
);
264 else if (nSlotId
== SID_ATTR_TABLE
)
265 aName
= SvGlobalName(SO3_SC_CLASSID
);
266 else if (nSlotId
== SID_INSERT_MATH
)
267 aName
= SvGlobalName(SO3_SM_CLASSID
);
269 uno::Reference
< embed::XEmbeddedObject
> xObj
= mpViewShell
->GetViewFrame()->GetObjectShell()->
270 GetEmbeddedObjectContainer().CreateEmbeddedObject( aName
.GetByteSequence(), aObjName
);
273 sal_Int64 nAspect
= embed::Aspects::MSOLE_CONTENT
;
275 MapUnit aUnit
= VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj
->getMapUnit( nAspect
) );
280 aRect
= pPickObj
->GetLogicRect();
283 aSz
.Width
= aRect
.GetWidth();
284 aSz
.Height
= aRect
.GetHeight();
285 xObj
->setVisualAreaSize( nAspect
, aSz
);
292 aSz
= xObj
->getVisualAreaSize( nAspect
);
294 catch ( embed::NoVisualAreaSizeException
& )
296 // the default size will be set later
299 Size
aSize( aSz
.Width
, aSz
.Height
);
301 if (aSize
.Height() == 0 || aSize
.Width() == 0)
303 // rectangle with balanced edge ratio
304 aSize
.Width() = 14100;
305 aSize
.Height() = 10000;
306 Size aTmp
= OutputDevice::LogicToLogic( aSize
, MAP_100TH_MM
, aUnit
);
307 aSz
.Width
= aTmp
.Width();
308 aSz
.Height
= aTmp
.Height();
309 xObj
->setVisualAreaSize( nAspect
, aSz
);
313 aSize
= OutputDevice::LogicToLogic(aSize
, aUnit
, MAP_100TH_MM
);
317 Rectangle
aWinRect(aPos
, mpWindow
->GetOutputSizePixel() );
318 aPos
= aWinRect
.Center();
319 aPos
= mpWindow
->PixelToLogic(aPos
);
320 aPos
.X() -= aSize
.Width() / 2;
321 aPos
.Y() -= aSize
.Height() / 2;
322 aRect
= Rectangle(aPos
, aSize
);
325 SdrOle2Obj
* pOleObj
= new SdrOle2Obj( svt::EmbeddedObjectRef( xObj
, nAspect
), aObjName
, aRect
);
326 SdrPageView
* pPV
= mpView
->GetSdrPageView();
328 // if we have a pick obj we need to make this new ole a pres obj replacing the current pick obj
331 SdPage
* pPage
= static_cast< SdPage
* >(pPickObj
->GetPage());
332 if(pPage
&& pPage
->IsPresObj(pPickObj
))
334 pPage
->InsertPresObj( pOleObj
, ePresObjKind
);
335 pOleObj
->SetUserCall(pPickObj
->GetUserCall());
341 mpView
->ReplaceObjectAtView(pPickObj
, *pPV
, pOleObj
, sal_True
);
343 bRet
= mpView
->InsertObjectAtView(pOleObj
, *pPV
, SDRINSERT_SETDEFLAYER
);
347 if (nSlotId
== SID_INSERT_DIAGRAM
)
349 pOleObj
->SetProgName( OUString( "StarChart" ));
351 else if (nSlotId
== SID_ATTR_TABLE
)
353 pOleObj
->SetProgName( OUString( "StarCalc" ) );
355 else if (nSlotId
== SID_INSERT_MATH
)
357 pOleObj
->SetProgName( OUString( "StarMath" ) );
360 pOleObj
->SetLogicRect(aRect
);
361 Size
aTmp( OutputDevice::LogicToLogic( aRect
.GetSize(), MAP_100TH_MM
, aUnit
) );
362 awt::Size aVisualSize
;
363 aVisualSize
.Width
= aTmp
.Width();
364 aVisualSize
.Height
= aTmp
.Height();
365 xObj
->setVisualAreaSize( nAspect
, aVisualSize
);
366 mpViewShell
->ActivateObject(pOleObj
, SVVERB_SHOW
);
368 if (nSlotId
== SID_INSERT_DIAGRAM
)
370 // note, that this call modified the chart model which
371 // results in a change notification. So call this after
372 // everything else is finished.
373 mpViewShell
->AdaptDefaultsForChart( xObj
);
379 ErrorHandler::HandleError(* new StringErrorInfo(ERRCODE_SFX_OLEGENERAL
,
386 sal_Int64 nAspect
= embed::Aspects::MSOLE_CONTENT
;
387 sal_Bool bCreateNew
= sal_False
;
388 uno::Reference
< embed::XEmbeddedObject
> xObj
;
389 uno::Reference
< embed::XStorage
> xStorage
= comphelper::OStorageHelper::GetTemporaryStorage();
390 SvObjectServerList aServerLst
;
393 OUString aIconMediaType
;
394 uno::Reference
< io::XInputStream
> xIconMetaFile
;
396 SFX_REQUEST_ARG( rReq
, pNameItem
, SfxGlobalNameItem
, SID_INSERT_OBJECT
, sal_False
);
397 if ( nSlotId
== SID_INSERT_OBJECT
&& pNameItem
)
399 SvGlobalName aClassName
= pNameItem
->GetValue();
400 xObj
= mpViewShell
->GetViewFrame()->GetObjectShell()->
401 GetEmbeddedObjectContainer().CreateEmbeddedObject( aClassName
.GetByteSequence(), aName
);
407 case SID_INSERT_OBJECT
:
409 aServerLst
.FillInsertObjects();
410 if (mpDoc
->GetDocumentType() == DOCUMENT_TYPE_DRAW
)
412 aServerLst
.Remove( GraphicDocShell::Factory().GetClassId() );
416 aServerLst
.Remove( DrawDocShell::Factory().GetClassId() );
419 // intentionally no break!
421 case SID_INSERT_PLUGIN
:
422 case SID_INSERT_FLOATINGFRAME
:
424 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
425 SfxAbstractInsertObjectDialog
* pDlg
=
426 pFact
->CreateInsertObjectDialog( mpViewShell
->GetActiveWindow(), SD_MOD()->GetSlotPool()->GetSlot(nSlotId
)->GetCommandString(),
427 xStorage
, &aServerLst
);
431 bCreateNew
= pDlg
->IsCreateNew();
432 xObj
= pDlg
->GetObject();
434 xIconMetaFile
= pDlg
->GetIconIfIconified( &aIconMediaType
);
435 if ( xIconMetaFile
.is() )
436 nAspect
= embed::Aspects::MSOLE_ICON
;
439 mpViewShell
->GetObjectShell()->GetEmbeddedObjectContainer().InsertEmbeddedObject( xObj
, aName
);
445 case SID_INSERT_SOUND
:
446 case SID_INSERT_VIDEO
:
448 // create special filedialog for plugins
449 SvxPluginFileDlg
aPluginFileDialog (mpWindow
, nSlotId
);
450 if( ERRCODE_NONE
== aPluginFileDialog
.Execute () )
453 String
aStrURL(aPluginFileDialog
.GetPath());
454 INetURLObject
aURL( aStrURL
, INET_PROT_FILE
);
455 if( aURL
.GetProtocol() != INET_PROT_NOT_VALID
)
457 // create a plugin object
458 xObj
= mpViewShell
->GetObjectShell()->GetEmbeddedObjectContainer().CreateEmbeddedObject( SvGlobalName( SO3_PLUGIN_CLASSID
).GetByteSequence(), aName
);
461 if ( xObj
.is() && svt::EmbeddedObjectRef::TryRunningState( xObj
) )
463 // set properties from dialog
464 uno::Reference
< embed::XComponentSupplier
> xSup( xObj
, uno::UNO_QUERY
);
467 uno::Reference
< beans::XPropertySet
> xSet( xSup
->getComponent(), uno::UNO_QUERY
);
470 xSet
->setPropertyValue("PluginURL",
471 uno::makeAny( OUString( aURL
.GetMainURL( INetURLObject::NO_DECODE
) ) ) );
477 // unable to create PlugIn
478 String
aStrErr( SdResId( STR_ERROR_OBJNOCREATE_PLUGIN
) );
480 aMask
+= sal_Unicode('%');
481 aStrErr
.SearchAndReplace( aMask
, aStrURL
);
482 ErrorBox( mpWindow
, WB_3DLOOK
| WB_OK
, aStrErr
).Execute();
493 //TODO/LATER: needs status for RESIZEONPRINTERCHANGE
494 //if( SVOBJ_MISCSTATUS_RESIZEONPRINTERCHANGE & xObj->getStatus( nAspect ) )
495 // aIPObj->OnDocumentPrinterChanged( mpDocSh->GetPrinter(sal_False) );
497 sal_Bool bInsertNewObject
= sal_True
;
500 MapUnit aMapUnit
= MAP_100TH_MM
;
501 if ( nAspect
!= embed::Aspects::MSOLE_ICON
)
506 aSz
= xObj
->getVisualAreaSize( nAspect
);
508 catch( embed::NoVisualAreaSizeException
& )
510 // the default size will be set later
513 aSize
=Size( aSz
.Width
, aSz
.Height
);
515 aMapUnit
= VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj
->getMapUnit( nAspect
) );
516 if (aSize
.Height() == 0 || aSize
.Width() == 0)
518 // rectangle with balanced edge ratio
519 aSize
.Width() = 14100;
520 aSize
.Height() = 10000;
521 Size aTmp
= OutputDevice::LogicToLogic( aSize
, MAP_100TH_MM
, aMapUnit
);
522 aSz
.Width
= aTmp
.Width();
523 aSz
.Height
= aTmp
.Height();
524 xObj
->setVisualAreaSize( nAspect
, aSz
);
528 aSize
= OutputDevice::LogicToLogic(aSize
, aMapUnit
, MAP_100TH_MM
);
532 if ( mpView
->AreObjectsMarked() )
534 // as an empty OLE object available?
535 const SdrMarkList
& rMarkList
= mpView
->GetMarkedObjectList();
537 if (rMarkList
.GetMarkCount() == 1)
539 SdrMark
* pMark
= rMarkList
.GetMark(0);
540 SdrObject
* pObj
= pMark
->GetMarkedSdrObj();
542 if (pObj
->GetObjInventor() == SdrInventor
&&
543 pObj
->GetObjIdentifier() == OBJ_OLE2
)
545 if ( !( (SdrOle2Obj
*) pObj
)->GetObjRef().is() )
547 // the empty OLE object gets a new IPObj
548 bInsertNewObject
= sal_False
;
549 pObj
->SetEmptyPresObj(sal_False
);
550 ( (SdrOle2Obj
*) pObj
)->SetOutlinerParaObject(NULL
);
551 ( (SdrOle2Obj
*) pObj
)->SetObjRef(xObj
);
552 ( (SdrOle2Obj
*) pObj
)->SetPersistName(aName
);
553 ( (SdrOle2Obj
*) pObj
)->SetName(aName
);
554 ( (SdrOle2Obj
*) pObj
)->SetAspect(nAspect
);
555 Rectangle aRect
= ( (SdrOle2Obj
*) pObj
)->GetLogicRect();
557 if ( nAspect
== embed::Aspects::MSOLE_ICON
)
559 if( xIconMetaFile
.is() )
560 ( (SdrOle2Obj
*) pObj
)->SetGraphicToObj( xIconMetaFile
, aIconMediaType
);
564 Size aTmp
= OutputDevice::LogicToLogic( aRect
.GetSize(), MAP_100TH_MM
, aMapUnit
);
565 awt::Size
aSz( aTmp
.Width(), aTmp
.Height() );
566 xObj
->setVisualAreaSize( nAspect
, aSz
);
573 if (bInsertNewObject
)
575 // we create a new OLE object
576 SdrPageView
* pPV
= mpView
->GetSdrPageView();
577 Size aPageSize
= pPV
->GetPage()->GetSize();
579 // get the size from the iconified object
580 ::svt::EmbeddedObjectRef
aObjRef( xObj
, nAspect
);
581 if ( nAspect
== embed::Aspects::MSOLE_ICON
)
583 aObjRef
.SetGraphicStream( xIconMetaFile
, aIconMediaType
);
584 MapMode
aMapMode( MAP_100TH_MM
);
585 aSize
= aObjRef
.GetSize( &aMapMode
);
588 Point
aPnt ((aPageSize
.Width() - aSize
.Width()) / 2,
589 (aPageSize
.Height() - aSize
.Height()) / 2);
590 Rectangle
aRect (aPnt
, aSize
);
592 SdrOle2Obj
* pObj
= new SdrOle2Obj( aObjRef
, aName
, aRect
);
594 if( mpView
->InsertObjectAtView(pObj
, *pPV
, SDRINSERT_SETDEFLAYER
) )
596 // Math objects change their object size during InsertObject.
597 // New size must be set in SdrObject, or a wrong scale will be set at
600 if ( nAspect
!= embed::Aspects::MSOLE_ICON
)
604 awt::Size aSz
= xObj
->getVisualAreaSize( nAspect
);
606 Size aNewSize
= Window::LogicToLogic( Size( aSz
.Width
, aSz
.Height
),
607 MapMode( aMapUnit
), MapMode( MAP_100TH_MM
) );
608 if ( aNewSize
!= aSize
)
610 aRect
.SetSize( aNewSize
);
611 pObj
->SetLogicRect( aRect
);
614 catch( embed::NoVisualAreaSizeException
& )
620 pObj
->SetLogicRect(aRect
);
622 if ( nAspect
!= embed::Aspects::MSOLE_ICON
)
624 Size aTmp
= OutputDevice::LogicToLogic( aRect
.GetSize(), MAP_100TH_MM
, aMapUnit
);
625 awt::Size
aSz( aTmp
.Width(), aTmp
.Height() );
626 xObj
->setVisualAreaSize( nAspect
, aSz
);
629 mpViewShell
->ActivateObject(pObj
, SVVERB_SHOW
);
632 Size aVisSizePixel
= mpWindow
->GetOutputSizePixel();
633 Rectangle aVisAreaWin
= mpWindow
->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel
) );
634 mpViewShell
->VisAreaChanged(aVisAreaWin
);
635 mpDocSh
->SetVisArea(aVisAreaWin
);
640 catch (uno::Exception
&)
642 // For some reason the object can not be inserted. For example
643 // because it is password protected and is not properly unlocked.
650 FuInsertAVMedia::FuInsertAVMedia(
654 SdDrawDocument
* pDoc
,
656 : FuPoor(pViewSh
, pWin
, pView
, pDoc
, rReq
)
660 FunctionReference
FuInsertAVMedia::Create( ViewShell
* pViewSh
, ::sd::Window
* pWin
, ::sd::View
* pView
, SdDrawDocument
* pDoc
, SfxRequest
& rReq
)
662 FunctionReference
xFunc( new FuInsertAVMedia( pViewSh
, pWin
, pView
, pDoc
, rReq
) );
663 xFunc
->DoExecute(rReq
);
667 void FuInsertAVMedia::DoExecute( SfxRequest
& rReq
)
670 const SfxItemSet
* pReqArgs
= rReq
.GetArgs();
675 const SfxStringItem
* pStringItem
= PTR_CAST( SfxStringItem
, &pReqArgs
->Get( rReq
.GetSlot() ) );
679 aURL
= pStringItem
->GetValue();
680 bAPI
= !aURL
.isEmpty();
686 ::avmedia::MediaWindow::executeMediaURLDialog(mpWindow
, aURL
, & bLink
))
691 mpWindow
->EnterWait();
693 if( !::avmedia::MediaWindow::isMediaURL( aURL
, true, &aPrefSize
) )
696 mpWindow
->LeaveWait();
699 ::avmedia::MediaWindow::executeFormatErrorBox( mpWindow
);
705 sal_Int8 nAction
= DND_ACTION_COPY
;
707 if( aPrefSize
.Width() && aPrefSize
.Height() )
710 aSize
= mpWindow
->PixelToLogic( aPrefSize
, MAP_100TH_MM
);
712 aSize
= Application::GetDefaultDevice()->PixelToLogic( aPrefSize
, MAP_100TH_MM
);
715 aSize
= Size( 5000, 5000 );
719 aPos
= mpWindow
->PixelToLogic( Rectangle( aPos
, mpWindow
->GetOutputSizePixel() ).Center() );
720 aPos
.X() -= aSize
.Width() >> 1;
721 aPos
.Y() -= aSize
.Height() >> 1;
724 mpView
->InsertMediaURL( aURL
, nAction
, aPos
, aSize
, bLink
) ;
727 mpWindow
->LeaveWait();
732 } // end of namespace sd
734 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */