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 27cdf0e10cSrcweir #include "fuinsert.hxx" 28cdf0e10cSrcweir 29cdf0e10cSrcweir #include <comphelper/storagehelper.hxx> 30cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 31cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx> 32cdf0e10cSrcweir #include <svx/svxdlg.hxx> 33cdf0e10cSrcweir #include <com/sun/star/embed/NoVisualAreaSizeException.hpp> 34cdf0e10cSrcweir #include <com/sun/star/embed/Aspects.hpp> 35cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 36cdf0e10cSrcweir #include <com/sun/star/chart2/XChartDocument.hpp> 37cdf0e10cSrcweir #include <com/sun/star/drawing/FillStyle.hpp> 38cdf0e10cSrcweir 39cdf0e10cSrcweir #include <tools/urlobj.hxx> 40cdf0e10cSrcweir #include <svl/urihelper.hxx> 41cdf0e10cSrcweir #include <sfx2/msgpool.hxx> 42cdf0e10cSrcweir #include <svtools/sores.hxx> 43cdf0e10cSrcweir #include <svtools/insdlg.hxx> 44cdf0e10cSrcweir #include <sfx2/request.hxx> 45cdf0e10cSrcweir #include <svl/globalnameitem.hxx> 46cdf0e10cSrcweir #include <unotools/pathoptions.hxx> 47cdf0e10cSrcweir #include <svx/pfiledlg.hxx> 48cdf0e10cSrcweir #include <svx/dialogs.hrc> 49cdf0e10cSrcweir #include <sfx2/linkmgr.hxx> 50cdf0e10cSrcweir #include <svx/svdetc.hxx> 51cdf0e10cSrcweir #include <avmedia/mediawindow.hxx> 52cdf0e10cSrcweir #ifndef _UNOTOOLS_UCBSTREAMHELPER_HXX 53cdf0e10cSrcweir #include <unotools/ucbstreamhelper.hxx> 54cdf0e10cSrcweir #endif 55cdf0e10cSrcweir #include <sfx2/printer.hxx> 56cdf0e10cSrcweir #include <sot/clsids.hxx> 57cdf0e10cSrcweir #include <svtools/sfxecode.hxx> 58cdf0e10cSrcweir #include <svtools/transfer.hxx> 59cdf0e10cSrcweir #include <svl/urlbmk.hxx> 60cdf0e10cSrcweir #include <svx/svdobj.hxx> 61cdf0e10cSrcweir #include <svx/svdograf.hxx> 62cdf0e10cSrcweir #include <svx/svdoole2.hxx> 63cdf0e10cSrcweir #include <svx/svdomedia.hxx> 64cdf0e10cSrcweir #ifndef _EDITENG_HXX //autogen 65cdf0e10cSrcweir #include <editeng/editeng.hxx> 66cdf0e10cSrcweir #endif 67cdf0e10cSrcweir #include <sot/storage.hxx> 68cdf0e10cSrcweir #include <sot/formats.hxx> 69cdf0e10cSrcweir #include <svx/svdpagv.hxx> 70cdf0e10cSrcweir #ifndef _MSGBOX_HXX //autogen 71cdf0e10cSrcweir #include <vcl/msgbox.hxx> 72cdf0e10cSrcweir #endif 73cdf0e10cSrcweir #include <sfx2/opengrf.hxx> 74cdf0e10cSrcweir #include <sfx2/viewfrm.hxx> 756f0b96b4SArmin Le Grand #include <svx/charthelper.hxx> 76cdf0e10cSrcweir 77cdf0e10cSrcweir #include "app.hrc" 78cdf0e10cSrcweir #include "misc.hxx" 79cdf0e10cSrcweir #include "sdresid.hxx" 80cdf0e10cSrcweir #include "View.hxx" 81cdf0e10cSrcweir #include "app.hxx" 82cdf0e10cSrcweir #include "Window.hxx" 83cdf0e10cSrcweir #include "drawview.hxx" 84cdf0e10cSrcweir #include "DrawViewShell.hxx" 85cdf0e10cSrcweir #include "DrawDocShell.hxx" 86cdf0e10cSrcweir #include "GraphicDocShell.hxx" 87cdf0e10cSrcweir #include "strings.hrc" 88cdf0e10cSrcweir #include "drawdoc.hxx" 89cdf0e10cSrcweir #include "sdgrffilter.hxx" 90cdf0e10cSrcweir #include "sdxfer.hxx" 91cdf0e10cSrcweir #include <vcl/svapp.hxx> 92cdf0e10cSrcweir #include "undo/undoobjects.hxx" 934bf7a51aSArmin Le Grand #include "glob.hrc" 94cdf0e10cSrcweir 95cdf0e10cSrcweir using namespace com::sun::star; 96cdf0e10cSrcweir 97cdf0e10cSrcweir namespace sd { 98cdf0e10cSrcweir 99cdf0e10cSrcweir TYPEINIT1( FuInsertGraphic, FuPoor ); 100cdf0e10cSrcweir TYPEINIT1( FuInsertClipboard, FuPoor ); 101cdf0e10cSrcweir TYPEINIT1( FuInsertOLE, FuPoor ); 102cdf0e10cSrcweir TYPEINIT1( FuInsertAVMedia, FuPoor ); 103cdf0e10cSrcweir 104cdf0e10cSrcweir /************************************************************************* 105cdf0e10cSrcweir |* 106cdf0e10cSrcweir |* FuInsertGraphic::Konstruktor 107cdf0e10cSrcweir |* 108cdf0e10cSrcweir \************************************************************************/ 109cdf0e10cSrcweir 110cdf0e10cSrcweir FuInsertGraphic::FuInsertGraphic ( 111cdf0e10cSrcweir ViewShell* pViewSh, 112cdf0e10cSrcweir ::sd::Window* pWin, 113cdf0e10cSrcweir ::sd::View* pView, 114cdf0e10cSrcweir SdDrawDocument* pDoc, 115cdf0e10cSrcweir SfxRequest& rReq) 116cdf0e10cSrcweir : FuPoor(pViewSh, pWin, pView, pDoc, rReq) 117cdf0e10cSrcweir { 118cdf0e10cSrcweir } 119cdf0e10cSrcweir 120cdf0e10cSrcweir FunctionReference FuInsertGraphic::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq ) 121cdf0e10cSrcweir { 122cdf0e10cSrcweir FunctionReference xFunc( new FuInsertGraphic( pViewSh, pWin, pView, pDoc, rReq ) ); 123cdf0e10cSrcweir xFunc->DoExecute(rReq); 124cdf0e10cSrcweir return xFunc; 125cdf0e10cSrcweir } 126cdf0e10cSrcweir 127cdf0e10cSrcweir #ifdef _MSC_VER 128cdf0e10cSrcweir #pragma optimize ( "", off ) 129cdf0e10cSrcweir #endif 130cdf0e10cSrcweir 131cdf0e10cSrcweir void FuInsertGraphic::DoExecute( SfxRequest& ) 132cdf0e10cSrcweir { 133cdf0e10cSrcweir SvxOpenGraphicDialog aDlg(SdResId(STR_INSERTGRAPHIC)); 134cdf0e10cSrcweir 135cdf0e10cSrcweir if( aDlg.Execute() == GRFILTER_OK ) 136cdf0e10cSrcweir { 137cdf0e10cSrcweir Graphic aGraphic; 138cdf0e10cSrcweir int nError = aDlg.GetGraphic(aGraphic); 139cdf0e10cSrcweir if( nError == GRFILTER_OK ) 140cdf0e10cSrcweir { 141cdf0e10cSrcweir if( mpViewShell && mpViewShell->ISA(DrawViewShell)) 142cdf0e10cSrcweir { 143cdf0e10cSrcweir sal_Int8 nAction = DND_ACTION_COPY; 144cdf0e10cSrcweir SdrObject* pPickObj = mpView->GetEmptyPresentationObject( PRESOBJ_GRAPHIC ); 145*52f1c2eeSArmin Le Grand bool bSelectionReplaced(false); 146*52f1c2eeSArmin Le Grand 147cdf0e10cSrcweir if( pPickObj ) 148*52f1c2eeSArmin Le Grand { 149cdf0e10cSrcweir nAction = DND_ACTION_LINK; 150*52f1c2eeSArmin Le Grand } 151*52f1c2eeSArmin Le Grand else if(1 == mpView->GetMarkedObjectCount()) 152*52f1c2eeSArmin Le Grand { 153*52f1c2eeSArmin Le Grand pPickObj = mpView->GetMarkedObjectByIndex(0); 154*52f1c2eeSArmin Le Grand nAction = DND_ACTION_MOVE; 155*52f1c2eeSArmin Le Grand bSelectionReplaced = true; 156*52f1c2eeSArmin Le Grand } 157cdf0e10cSrcweir 158cdf0e10cSrcweir Point aPos; 159cdf0e10cSrcweir Rectangle aRect(aPos, mpWindow->GetOutputSizePixel() ); 160cdf0e10cSrcweir aPos = aRect.Center(); 161cdf0e10cSrcweir aPos = mpWindow->PixelToLogic(aPos); 162cdf0e10cSrcweir SdrGrafObj* pGrafObj = mpView->InsertGraphic(aGraphic, nAction, aPos, pPickObj, NULL); 163cdf0e10cSrcweir 164cdf0e10cSrcweir if(pGrafObj && aDlg.IsAsLink()) 165cdf0e10cSrcweir { 166cdf0e10cSrcweir // store link only? 167cdf0e10cSrcweir String aFltName(aDlg.GetCurrentFilter()); 168cdf0e10cSrcweir String aPath(aDlg.GetPath()); 169cdf0e10cSrcweir pGrafObj->SetGraphicLink(aPath, aFltName); 170cdf0e10cSrcweir } 171*52f1c2eeSArmin Le Grand 172*52f1c2eeSArmin Le Grand if(bSelectionReplaced && pGrafObj) 173*52f1c2eeSArmin Le Grand { 174*52f1c2eeSArmin Le Grand mpView->MarkObj(pGrafObj, mpView->GetSdrPageView()); 175*52f1c2eeSArmin Le Grand } 176cdf0e10cSrcweir } 177cdf0e10cSrcweir } 178cdf0e10cSrcweir else 179cdf0e10cSrcweir { 180cdf0e10cSrcweir SdGRFFilter::HandleGraphicFilterError( (sal_uInt16)nError, GraphicFilter::GetGraphicFilter()->GetLastError().nStreamError ); 181cdf0e10cSrcweir } 182cdf0e10cSrcweir } 183cdf0e10cSrcweir } 184cdf0e10cSrcweir 185cdf0e10cSrcweir #ifdef _MSC_VER 186cdf0e10cSrcweir #pragma optimize ( "", on ) 187cdf0e10cSrcweir #endif 188cdf0e10cSrcweir 189cdf0e10cSrcweir /************************************************************************* 190cdf0e10cSrcweir |* 191cdf0e10cSrcweir |* FuInsertClipboard::Konstruktor 192cdf0e10cSrcweir |* 193cdf0e10cSrcweir \************************************************************************/ 194cdf0e10cSrcweir 195cdf0e10cSrcweir FuInsertClipboard::FuInsertClipboard ( 196cdf0e10cSrcweir ViewShell* pViewSh, 197cdf0e10cSrcweir ::sd::Window* pWin, 198cdf0e10cSrcweir ::sd::View* pView, 199cdf0e10cSrcweir SdDrawDocument* pDoc, 200cdf0e10cSrcweir SfxRequest& rReq) 201cdf0e10cSrcweir : FuPoor(pViewSh, pWin, pView, pDoc, rReq) 202cdf0e10cSrcweir { 203cdf0e10cSrcweir } 204cdf0e10cSrcweir 205cdf0e10cSrcweir FunctionReference FuInsertClipboard::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq ) 206cdf0e10cSrcweir { 207cdf0e10cSrcweir FunctionReference xFunc( new FuInsertClipboard( pViewSh, pWin, pView, pDoc, rReq ) ); 208cdf0e10cSrcweir xFunc->DoExecute(rReq); 209cdf0e10cSrcweir return xFunc; 210cdf0e10cSrcweir } 211cdf0e10cSrcweir 212cdf0e10cSrcweir void FuInsertClipboard::DoExecute( SfxRequest& ) 213cdf0e10cSrcweir { 214cdf0e10cSrcweir TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( mpWindow ) ); 215cdf0e10cSrcweir sal_uLong nFormatId; 216cdf0e10cSrcweir 217cdf0e10cSrcweir SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); 218cdf0e10cSrcweir SfxAbstractPasteDialog* pDlg = pFact->CreatePasteDialog( mpViewShell->GetActiveWindow() ); 219cdf0e10cSrcweir if ( pDlg ) 220cdf0e10cSrcweir { 221cdf0e10cSrcweir const String aEmptyString; 222cdf0e10cSrcweir ::com::sun::star::datatransfer::DataFlavor aFlavor; 223cdf0e10cSrcweir 224cdf0e10cSrcweir pDlg->Insert( SOT_FORMATSTR_ID_EMBED_SOURCE, aEmptyString ); 225cdf0e10cSrcweir pDlg->Insert( SOT_FORMATSTR_ID_LINK_SOURCE, aEmptyString ); 226cdf0e10cSrcweir pDlg->Insert( SOT_FORMATSTR_ID_DRAWING, aEmptyString ); 227cdf0e10cSrcweir pDlg->Insert( SOT_FORMATSTR_ID_SVXB, aEmptyString ); 228cdf0e10cSrcweir pDlg->Insert( FORMAT_GDIMETAFILE, aEmptyString ); 229cdf0e10cSrcweir pDlg->Insert( FORMAT_BITMAP, aEmptyString ); 230cdf0e10cSrcweir pDlg->Insert( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK, aEmptyString ); 231cdf0e10cSrcweir pDlg->Insert( FORMAT_STRING, aEmptyString ); 232cdf0e10cSrcweir pDlg->Insert( SOT_FORMATSTR_ID_HTML, aEmptyString ); 233cdf0e10cSrcweir pDlg->Insert( FORMAT_RTF, aEmptyString ); 234cdf0e10cSrcweir pDlg->Insert( SOT_FORMATSTR_ID_EDITENGINE, aEmptyString ); 235cdf0e10cSrcweir 236cdf0e10cSrcweir //TODO/MBA: testing 237cdf0e10cSrcweir nFormatId = pDlg->GetFormat( aDataHelper ); 238cdf0e10cSrcweir if( nFormatId && aDataHelper.GetTransferable().is() ) 239cdf0e10cSrcweir { 240cdf0e10cSrcweir sal_Int8 nAction = DND_ACTION_COPY; 241cdf0e10cSrcweir 242cdf0e10cSrcweir if( !mpView->InsertData( aDataHelper, 243cdf0e10cSrcweir mpWindow->PixelToLogic( Rectangle( Point(), mpWindow->GetOutputSizePixel() ).Center() ), 244cdf0e10cSrcweir nAction, sal_False, nFormatId ) && 245cdf0e10cSrcweir ( mpViewShell && mpViewShell->ISA( DrawViewShell ) ) ) 246cdf0e10cSrcweir { 247cdf0e10cSrcweir DrawViewShell* pDrViewSh = static_cast<DrawViewShell*>(mpViewShell); 248cdf0e10cSrcweir INetBookmark aINetBookmark( aEmptyStr, aEmptyStr ); 249cdf0e10cSrcweir 250cdf0e10cSrcweir if( ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK ) && 251cdf0e10cSrcweir aDataHelper.GetINetBookmark( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK, aINetBookmark ) ) || 252cdf0e10cSrcweir ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR ) && 253cdf0e10cSrcweir aDataHelper.GetINetBookmark( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR, aINetBookmark ) ) || 254cdf0e10cSrcweir ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR ) && 255cdf0e10cSrcweir aDataHelper.GetINetBookmark( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR, aINetBookmark ) ) ) 256cdf0e10cSrcweir { 257cdf0e10cSrcweir pDrViewSh->InsertURLField( aINetBookmark.GetURL(), aINetBookmark.GetDescription(), aEmptyStr, NULL ); 258cdf0e10cSrcweir } 259cdf0e10cSrcweir } 260cdf0e10cSrcweir } 261cdf0e10cSrcweir 262cdf0e10cSrcweir delete pDlg; 263cdf0e10cSrcweir } 264cdf0e10cSrcweir } 265cdf0e10cSrcweir 266cdf0e10cSrcweir 267cdf0e10cSrcweir /************************************************************************* 268cdf0e10cSrcweir |* 269cdf0e10cSrcweir |* FuInsertOLE::Konstruktor 270cdf0e10cSrcweir |* 271cdf0e10cSrcweir \************************************************************************/ 272cdf0e10cSrcweir 273cdf0e10cSrcweir FuInsertOLE::FuInsertOLE ( 274cdf0e10cSrcweir ViewShell* pViewSh, 275cdf0e10cSrcweir ::sd::Window* pWin, 276cdf0e10cSrcweir ::sd::View* pView, 277cdf0e10cSrcweir SdDrawDocument* pDoc, 278cdf0e10cSrcweir SfxRequest& rReq) 279cdf0e10cSrcweir : FuPoor(pViewSh, pWin, pView, pDoc, rReq) 280cdf0e10cSrcweir { 281cdf0e10cSrcweir } 282cdf0e10cSrcweir 283cdf0e10cSrcweir FunctionReference FuInsertOLE::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq ) 284cdf0e10cSrcweir { 285cdf0e10cSrcweir FunctionReference xFunc( new FuInsertOLE( pViewSh, pWin, pView, pDoc, rReq ) ); 286cdf0e10cSrcweir xFunc->DoExecute(rReq); 287cdf0e10cSrcweir return xFunc; 288cdf0e10cSrcweir } 289cdf0e10cSrcweir 290cdf0e10cSrcweir void FuInsertOLE::DoExecute( SfxRequest& rReq ) 291cdf0e10cSrcweir { 292cdf0e10cSrcweir if ( nSlotId == SID_ATTR_TABLE || 293cdf0e10cSrcweir nSlotId == SID_INSERT_DIAGRAM || 294cdf0e10cSrcweir nSlotId == SID_INSERT_MATH ) 295cdf0e10cSrcweir { 296cdf0e10cSrcweir PresObjKind ePresObjKind = (nSlotId == SID_INSERT_DIAGRAM) ? PRESOBJ_CHART : PRESOBJ_OBJECT; 297cdf0e10cSrcweir 298cdf0e10cSrcweir SdrObject* pPickObj = mpView->GetEmptyPresentationObject( ePresObjKind ); 299cdf0e10cSrcweir 300cdf0e10cSrcweir /********************************************************************** 301cdf0e10cSrcweir * Diagramm oder StarCalc-Tabelle einfuegen 302cdf0e10cSrcweir **********************************************************************/ 303cdf0e10cSrcweir 304cdf0e10cSrcweir ::rtl::OUString aObjName; 305cdf0e10cSrcweir SvGlobalName aName; 306cdf0e10cSrcweir if (nSlotId == SID_INSERT_DIAGRAM) 307cdf0e10cSrcweir aName = SvGlobalName( SO3_SCH_CLASSID); 308cdf0e10cSrcweir else if (nSlotId == SID_ATTR_TABLE) 309cdf0e10cSrcweir aName = SvGlobalName(SO3_SC_CLASSID); 310cdf0e10cSrcweir else if (nSlotId == SID_INSERT_MATH) 311cdf0e10cSrcweir aName = SvGlobalName(SO3_SM_CLASSID); 312cdf0e10cSrcweir 313cdf0e10cSrcweir uno::Reference < embed::XEmbeddedObject > xObj = mpViewShell->GetViewFrame()->GetObjectShell()-> 314cdf0e10cSrcweir GetEmbeddedObjectContainer().CreateEmbeddedObject( aName.GetByteSequence(), aObjName ); 315cdf0e10cSrcweir if ( xObj.is() ) 316cdf0e10cSrcweir { 317cdf0e10cSrcweir sal_Int64 nAspect = embed::Aspects::MSOLE_CONTENT; 318cdf0e10cSrcweir 319cdf0e10cSrcweir MapUnit aUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( nAspect ) ); 320cdf0e10cSrcweir 321cdf0e10cSrcweir Rectangle aRect; 322cdf0e10cSrcweir if( pPickObj ) 323cdf0e10cSrcweir { 324cdf0e10cSrcweir aRect = pPickObj->GetLogicRect(); 325cdf0e10cSrcweir 326cdf0e10cSrcweir awt::Size aSz; 327cdf0e10cSrcweir aSz.Width = aRect.GetWidth(); 328cdf0e10cSrcweir aSz.Height = aRect.GetHeight(); 329cdf0e10cSrcweir xObj->setVisualAreaSize( nAspect, aSz ); 330cdf0e10cSrcweir } 331cdf0e10cSrcweir else 332cdf0e10cSrcweir { 333cdf0e10cSrcweir awt::Size aSz; 334cdf0e10cSrcweir try 335cdf0e10cSrcweir { 336cdf0e10cSrcweir aSz = xObj->getVisualAreaSize( nAspect ); 337cdf0e10cSrcweir } 338cdf0e10cSrcweir catch ( embed::NoVisualAreaSizeException& ) 339cdf0e10cSrcweir { 340cdf0e10cSrcweir // the default size will be set later 341cdf0e10cSrcweir } 342cdf0e10cSrcweir 343cdf0e10cSrcweir Size aSize( aSz.Width, aSz.Height ); 344cdf0e10cSrcweir 345cdf0e10cSrcweir if (aSize.Height() == 0 || aSize.Width() == 0) 346cdf0e10cSrcweir { 347cdf0e10cSrcweir // Rechteck mit ausgewogenem Kantenverhaeltnis 348cdf0e10cSrcweir aSize.Width() = 14100; 349cdf0e10cSrcweir aSize.Height() = 10000; 350cdf0e10cSrcweir Size aTmp = OutputDevice::LogicToLogic( aSize, MAP_100TH_MM, aUnit ); 351cdf0e10cSrcweir aSz.Width = aTmp.Width(); 352cdf0e10cSrcweir aSz.Height = aTmp.Height(); 353cdf0e10cSrcweir xObj->setVisualAreaSize( nAspect, aSz ); 354cdf0e10cSrcweir } 355cdf0e10cSrcweir else 356cdf0e10cSrcweir { 357cdf0e10cSrcweir aSize = OutputDevice::LogicToLogic(aSize, aUnit, MAP_100TH_MM); 358cdf0e10cSrcweir } 359cdf0e10cSrcweir 360cdf0e10cSrcweir Point aPos; 361cdf0e10cSrcweir Rectangle aWinRect(aPos, mpWindow->GetOutputSizePixel() ); 362cdf0e10cSrcweir aPos = aWinRect.Center(); 363cdf0e10cSrcweir aPos = mpWindow->PixelToLogic(aPos); 364cdf0e10cSrcweir aPos.X() -= aSize.Width() / 2; 365cdf0e10cSrcweir aPos.Y() -= aSize.Height() / 2; 366cdf0e10cSrcweir aRect = Rectangle(aPos, aSize); 367cdf0e10cSrcweir } 368cdf0e10cSrcweir 369cdf0e10cSrcweir SdrOle2Obj* pOleObj = new SdrOle2Obj( svt::EmbeddedObjectRef( xObj, nAspect ), aObjName, aRect ); 370cdf0e10cSrcweir SdrPageView* pPV = mpView->GetSdrPageView(); 371cdf0e10cSrcweir 372cdf0e10cSrcweir // if we have a pick obj we need to make this new ole a pres obj replacing the current pick obj 373cdf0e10cSrcweir if( pPickObj ) 374cdf0e10cSrcweir { 375cdf0e10cSrcweir SdPage* pPage = static_cast< SdPage* >(pPickObj->GetPage()); 376cdf0e10cSrcweir if(pPage && pPage->IsPresObj(pPickObj)) 377cdf0e10cSrcweir { 378cdf0e10cSrcweir pPage->InsertPresObj( pOleObj, ePresObjKind ); 379cdf0e10cSrcweir pOleObj->SetUserCall(pPickObj->GetUserCall()); 380cdf0e10cSrcweir } 381cdf0e10cSrcweir } 382cdf0e10cSrcweir 383cdf0e10cSrcweir bool bRet = true; 384cdf0e10cSrcweir if( pPickObj ) 385cdf0e10cSrcweir mpView->ReplaceObjectAtView(pPickObj, *pPV, pOleObj, sal_True ); 386cdf0e10cSrcweir else 387cdf0e10cSrcweir bRet = mpView->InsertObjectAtView(pOleObj, *pPV, SDRINSERT_SETDEFLAYER); 388cdf0e10cSrcweir 389cdf0e10cSrcweir if( bRet ) 390cdf0e10cSrcweir { 391cdf0e10cSrcweir if (nSlotId == SID_INSERT_DIAGRAM) 392cdf0e10cSrcweir { 393cdf0e10cSrcweir pOleObj->SetProgName( UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "StarChart" ) ) ); 394cdf0e10cSrcweir } 395cdf0e10cSrcweir else if (nSlotId == SID_ATTR_TABLE) 396cdf0e10cSrcweir { 397cdf0e10cSrcweir pOleObj->SetProgName( UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "StarCalc" ) ) ); 398cdf0e10cSrcweir } 399cdf0e10cSrcweir else if (nSlotId == SID_INSERT_MATH) 400cdf0e10cSrcweir { 401cdf0e10cSrcweir pOleObj->SetProgName( UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "StarMath" ) ) ); 402cdf0e10cSrcweir } 403cdf0e10cSrcweir 404cdf0e10cSrcweir //HMHmpView->HideMarkHdl(); 405cdf0e10cSrcweir pOleObj->SetLogicRect(aRect); 406cdf0e10cSrcweir Size aTmp( OutputDevice::LogicToLogic( aRect.GetSize(), MAP_100TH_MM, aUnit ) ); 407cdf0e10cSrcweir awt::Size aVisualSize; 408cdf0e10cSrcweir aVisualSize.Width = aTmp.Width(); 409cdf0e10cSrcweir aVisualSize.Height = aTmp.Height(); 410cdf0e10cSrcweir xObj->setVisualAreaSize( nAspect, aVisualSize ); 411cdf0e10cSrcweir mpViewShell->ActivateObject(pOleObj, SVVERB_SHOW); 4126f0b96b4SArmin Le Grand 4136f0b96b4SArmin Le Grand if (nSlotId == SID_INSERT_DIAGRAM) 4146f0b96b4SArmin Le Grand { 4156f0b96b4SArmin Le Grand // note, that this call modified the chart model which 4166f0b96b4SArmin Le Grand // results in a change notification. So call this after 4176f0b96b4SArmin Le Grand // everything else is finished. 4186f0b96b4SArmin Le Grand ChartHelper::AdaptDefaultsForChart( xObj ); 4196f0b96b4SArmin Le Grand } 420cdf0e10cSrcweir } 421cdf0e10cSrcweir } 422cdf0e10cSrcweir else 423cdf0e10cSrcweir { 424cdf0e10cSrcweir ErrorHandler::HandleError(* new StringErrorInfo(ERRCODE_SFX_OLEGENERAL, 425cdf0e10cSrcweir aEmptyStr ) ); 426cdf0e10cSrcweir } 427cdf0e10cSrcweir } 428cdf0e10cSrcweir else 429cdf0e10cSrcweir { 430cdf0e10cSrcweir /********************************************************************** 431cdf0e10cSrcweir * Objekt einfuegen 432cdf0e10cSrcweir **********************************************************************/ 433cdf0e10cSrcweir sal_Int64 nAspect = embed::Aspects::MSOLE_CONTENT; 434cdf0e10cSrcweir sal_Bool bCreateNew = sal_False; 435cdf0e10cSrcweir uno::Reference < embed::XEmbeddedObject > xObj; 436cdf0e10cSrcweir uno::Reference < embed::XStorage > xStorage = comphelper::OStorageHelper::GetTemporaryStorage(); 437cdf0e10cSrcweir SvObjectServerList aServerLst; 438cdf0e10cSrcweir ::rtl::OUString aName; 439cdf0e10cSrcweir 440cdf0e10cSrcweir ::rtl::OUString aIconMediaType; 441cdf0e10cSrcweir uno::Reference< io::XInputStream > xIconMetaFile; 442cdf0e10cSrcweir 443cdf0e10cSrcweir SFX_REQUEST_ARG( rReq, pNameItem, SfxGlobalNameItem, SID_INSERT_OBJECT, sal_False ); 444cdf0e10cSrcweir if ( nSlotId == SID_INSERT_OBJECT && pNameItem ) 445cdf0e10cSrcweir { 446cdf0e10cSrcweir SvGlobalName aClassName = pNameItem->GetValue(); 447cdf0e10cSrcweir xObj = mpViewShell->GetViewFrame()->GetObjectShell()-> 448cdf0e10cSrcweir GetEmbeddedObjectContainer().CreateEmbeddedObject( aClassName.GetByteSequence(), aName ); 449cdf0e10cSrcweir } 450cdf0e10cSrcweir else 451cdf0e10cSrcweir { 452cdf0e10cSrcweir switch ( nSlotId ) 453cdf0e10cSrcweir { 454cdf0e10cSrcweir case SID_INSERT_OBJECT : 455cdf0e10cSrcweir { 456cdf0e10cSrcweir aServerLst.FillInsertObjects(); 457cdf0e10cSrcweir if (mpDoc->GetDocumentType() == DOCUMENT_TYPE_DRAW) 458cdf0e10cSrcweir { 459cdf0e10cSrcweir aServerLst.Remove( GraphicDocShell::Factory().GetClassId() ); 460cdf0e10cSrcweir } 461cdf0e10cSrcweir else 462cdf0e10cSrcweir { 463cdf0e10cSrcweir aServerLst.Remove( DrawDocShell::Factory().GetClassId() ); 464cdf0e10cSrcweir } 465cdf0e10cSrcweir 466cdf0e10cSrcweir // intentionally no break! 467cdf0e10cSrcweir } 468cdf0e10cSrcweir case SID_INSERT_PLUGIN : 469cdf0e10cSrcweir case SID_INSERT_FLOATINGFRAME : 470cdf0e10cSrcweir { 471cdf0e10cSrcweir SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); 472cdf0e10cSrcweir SfxAbstractInsertObjectDialog* pDlg = 473cdf0e10cSrcweir pFact->CreateInsertObjectDialog( mpViewShell->GetActiveWindow(), SD_MOD()->GetSlotPool()->GetSlot(nSlotId)->GetCommandString(), 474cdf0e10cSrcweir xStorage, &aServerLst ); 475cdf0e10cSrcweir if ( pDlg ) 476cdf0e10cSrcweir { 477cdf0e10cSrcweir pDlg->Execute(); 478cdf0e10cSrcweir bCreateNew = pDlg->IsCreateNew(); 479cdf0e10cSrcweir xObj = pDlg->GetObject(); 480cdf0e10cSrcweir 481cdf0e10cSrcweir xIconMetaFile = pDlg->GetIconIfIconified( &aIconMediaType ); 482cdf0e10cSrcweir if ( xIconMetaFile.is() ) 483cdf0e10cSrcweir nAspect = embed::Aspects::MSOLE_ICON; 484cdf0e10cSrcweir 485cdf0e10cSrcweir if ( xObj.is() ) 486cdf0e10cSrcweir mpViewShell->GetObjectShell()->GetEmbeddedObjectContainer().InsertEmbeddedObject( xObj, aName ); 487cdf0e10cSrcweir DELETEZ( pDlg ); 488cdf0e10cSrcweir } 489cdf0e10cSrcweir 490cdf0e10cSrcweir break; 491cdf0e10cSrcweir } 492cdf0e10cSrcweir case SID_INSERT_SOUND : 493cdf0e10cSrcweir case SID_INSERT_VIDEO : 494cdf0e10cSrcweir { 495cdf0e10cSrcweir // create special filedialog for plugins 496cdf0e10cSrcweir SvxPluginFileDlg aPluginFileDialog (mpWindow, nSlotId); 497cdf0e10cSrcweir if( ERRCODE_NONE == aPluginFileDialog.Execute () ) 498cdf0e10cSrcweir { 499cdf0e10cSrcweir // get URL 500cdf0e10cSrcweir String aStrURL(aPluginFileDialog.GetPath()); 501cdf0e10cSrcweir INetURLObject aURL( aStrURL, INET_PROT_FILE ); 502cdf0e10cSrcweir if( aURL.GetProtocol() != INET_PROT_NOT_VALID ) 503cdf0e10cSrcweir { 504cdf0e10cSrcweir // create a plugin object 505cdf0e10cSrcweir xObj = mpViewShell->GetObjectShell()->GetEmbeddedObjectContainer().CreateEmbeddedObject( SvGlobalName( SO3_PLUGIN_CLASSID ).GetByteSequence(), aName ); 506cdf0e10cSrcweir } 507cdf0e10cSrcweir 508cdf0e10cSrcweir if ( xObj.is() && svt::EmbeddedObjectRef::TryRunningState( xObj ) ) 509cdf0e10cSrcweir { 510cdf0e10cSrcweir // set properties from dialog 511cdf0e10cSrcweir uno::Reference < embed::XComponentSupplier > xSup( xObj, uno::UNO_QUERY ); 512cdf0e10cSrcweir if ( xSup.is() ) 513cdf0e10cSrcweir { 514cdf0e10cSrcweir uno::Reference < beans::XPropertySet > xSet( xSup->getComponent(), uno::UNO_QUERY ); 515cdf0e10cSrcweir if ( xSet.is() ) 516cdf0e10cSrcweir { 517cdf0e10cSrcweir xSet->setPropertyValue( ::rtl::OUString::createFromAscii("PluginURL"), 518cdf0e10cSrcweir uno::makeAny( ::rtl::OUString( aURL.GetMainURL( INetURLObject::NO_DECODE ) ) ) ); 519cdf0e10cSrcweir } 520cdf0e10cSrcweir } 521cdf0e10cSrcweir } 522cdf0e10cSrcweir else 523cdf0e10cSrcweir { 524cdf0e10cSrcweir // PlugIn konnte nicht erzeugt werden 525cdf0e10cSrcweir String aStrErr( SdResId( STR_ERROR_OBJNOCREATE_PLUGIN ) ); 526cdf0e10cSrcweir String aMask; 527cdf0e10cSrcweir aMask += sal_Unicode('%'); 528cdf0e10cSrcweir aStrErr.SearchAndReplace( aMask, aStrURL ); 529cdf0e10cSrcweir ErrorBox( mpWindow, WB_3DLOOK | WB_OK, aStrErr ).Execute(); 530cdf0e10cSrcweir } 531cdf0e10cSrcweir } 532cdf0e10cSrcweir } 533cdf0e10cSrcweir } 534cdf0e10cSrcweir } 535cdf0e10cSrcweir 536cdf0e10cSrcweir try 537cdf0e10cSrcweir { 538cdf0e10cSrcweir if (xObj.is()) 539cdf0e10cSrcweir { 540cdf0e10cSrcweir //TODO/LATER: needs status for RESIZEONPRINTERCHANGE 541cdf0e10cSrcweir //if( SVOBJ_MISCSTATUS_RESIZEONPRINTERCHANGE & xObj->getStatus( nAspect ) ) 542cdf0e10cSrcweir // aIPObj->OnDocumentPrinterChanged( mpDocSh->GetPrinter(sal_False) ); 543cdf0e10cSrcweir 544cdf0e10cSrcweir sal_Bool bInsertNewObject = sal_True; 545cdf0e10cSrcweir 546cdf0e10cSrcweir Size aSize; 547cdf0e10cSrcweir MapUnit aMapUnit = MAP_100TH_MM; 548cdf0e10cSrcweir if ( nAspect != embed::Aspects::MSOLE_ICON ) 549cdf0e10cSrcweir { 550cdf0e10cSrcweir awt::Size aSz; 551cdf0e10cSrcweir try 552cdf0e10cSrcweir { 553cdf0e10cSrcweir aSz = xObj->getVisualAreaSize( nAspect ); 554cdf0e10cSrcweir } 555cdf0e10cSrcweir catch( embed::NoVisualAreaSizeException& ) 556cdf0e10cSrcweir { 557cdf0e10cSrcweir // the default size will be set later 558cdf0e10cSrcweir } 559cdf0e10cSrcweir 560cdf0e10cSrcweir aSize =Size( aSz.Width, aSz.Height ); 561cdf0e10cSrcweir 562cdf0e10cSrcweir aMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( nAspect ) ); 563cdf0e10cSrcweir if (aSize.Height() == 0 || aSize.Width() == 0) 564cdf0e10cSrcweir { 565cdf0e10cSrcweir // Rechteck mit ausgewogenem Kantenverhaeltnis 566cdf0e10cSrcweir aSize.Width() = 14100; 567cdf0e10cSrcweir aSize.Height() = 10000; 568cdf0e10cSrcweir Size aTmp = OutputDevice::LogicToLogic( aSize, MAP_100TH_MM, aMapUnit ); 569cdf0e10cSrcweir aSz.Width = aTmp.Width(); 570cdf0e10cSrcweir aSz.Height = aTmp.Height(); 571cdf0e10cSrcweir xObj->setVisualAreaSize( nAspect, aSz ); 572cdf0e10cSrcweir } 573cdf0e10cSrcweir else 574cdf0e10cSrcweir { 575cdf0e10cSrcweir aSize = OutputDevice::LogicToLogic(aSize, aMapUnit, MAP_100TH_MM); 576cdf0e10cSrcweir } 577cdf0e10cSrcweir } 578cdf0e10cSrcweir 579cdf0e10cSrcweir if ( mpView->AreObjectsMarked() ) 580cdf0e10cSrcweir { 581cdf0e10cSrcweir /********************************************************** 582cdf0e10cSrcweir * Ist ein leeres OLE-Objekt vorhanden? 583cdf0e10cSrcweir **********************************************************/ 584cdf0e10cSrcweir const SdrMarkList& rMarkList = mpView->GetMarkedObjectList(); 585cdf0e10cSrcweir 586cdf0e10cSrcweir if (rMarkList.GetMarkCount() == 1) 587cdf0e10cSrcweir { 588cdf0e10cSrcweir SdrMark* pMark = rMarkList.GetMark(0); 589cdf0e10cSrcweir SdrObject* pObj = pMark->GetMarkedSdrObj(); 590cdf0e10cSrcweir 591cdf0e10cSrcweir if (pObj->GetObjInventor() == SdrInventor && 592cdf0e10cSrcweir pObj->GetObjIdentifier() == OBJ_OLE2) 593cdf0e10cSrcweir { 594cdf0e10cSrcweir if ( !( (SdrOle2Obj*) pObj)->GetObjRef().is() ) 595cdf0e10cSrcweir { 596cdf0e10cSrcweir /************************************************** 597cdf0e10cSrcweir * Das leere OLE-Objekt bekommt ein neues IPObj 598cdf0e10cSrcweir **************************************************/ 599cdf0e10cSrcweir bInsertNewObject = sal_False; 600cdf0e10cSrcweir pObj->SetEmptyPresObj(sal_False); 601cdf0e10cSrcweir ( (SdrOle2Obj*) pObj)->SetOutlinerParaObject(NULL); 602cdf0e10cSrcweir ( (SdrOle2Obj*) pObj)->SetObjRef(xObj); 603cdf0e10cSrcweir ( (SdrOle2Obj*) pObj)->SetPersistName(aName); 604cdf0e10cSrcweir ( (SdrOle2Obj*) pObj)->SetName(aName); 605cdf0e10cSrcweir ( (SdrOle2Obj*) pObj)->SetAspect(nAspect); 606cdf0e10cSrcweir Rectangle aRect = ( (SdrOle2Obj*) pObj)->GetLogicRect(); 607cdf0e10cSrcweir 608cdf0e10cSrcweir //HMHmpView->HideMarkHdl(); 609cdf0e10cSrcweir 610cdf0e10cSrcweir if ( nAspect == embed::Aspects::MSOLE_ICON ) 611cdf0e10cSrcweir { 612cdf0e10cSrcweir if( xIconMetaFile.is() ) 613cdf0e10cSrcweir ( (SdrOle2Obj*) pObj)->SetGraphicToObj( xIconMetaFile, aIconMediaType ); 614cdf0e10cSrcweir } 615cdf0e10cSrcweir else 616cdf0e10cSrcweir { 617cdf0e10cSrcweir Size aTmp = OutputDevice::LogicToLogic( aRect.GetSize(), MAP_100TH_MM, aMapUnit ); 618cdf0e10cSrcweir awt::Size aSz( aTmp.Width(), aTmp.Height() ); 619cdf0e10cSrcweir xObj->setVisualAreaSize( nAspect, aSz ); 620cdf0e10cSrcweir } 621cdf0e10cSrcweir } 622cdf0e10cSrcweir } 623cdf0e10cSrcweir } 624cdf0e10cSrcweir } 625cdf0e10cSrcweir 626cdf0e10cSrcweir if (bInsertNewObject) 627cdf0e10cSrcweir { 628cdf0e10cSrcweir /************************************************************** 629cdf0e10cSrcweir * Ein neues OLE-Objekt wird erzeugt 630cdf0e10cSrcweir **************************************************************/ 631cdf0e10cSrcweir SdrPageView* pPV = mpView->GetSdrPageView(); 632cdf0e10cSrcweir Size aPageSize = pPV->GetPage()->GetSize(); 633cdf0e10cSrcweir 634cdf0e10cSrcweir // get the size from the iconified object 635cdf0e10cSrcweir ::svt::EmbeddedObjectRef aObjRef( xObj, nAspect ); 636cdf0e10cSrcweir if ( nAspect == embed::Aspects::MSOLE_ICON ) 637cdf0e10cSrcweir { 638cdf0e10cSrcweir aObjRef.SetGraphicStream( xIconMetaFile, aIconMediaType ); 639cdf0e10cSrcweir MapMode aMapMode( MAP_100TH_MM ); 640cdf0e10cSrcweir aSize = aObjRef.GetSize( &aMapMode ); 641cdf0e10cSrcweir } 642cdf0e10cSrcweir 643cdf0e10cSrcweir Point aPnt ((aPageSize.Width() - aSize.Width()) / 2, 644cdf0e10cSrcweir (aPageSize.Height() - aSize.Height()) / 2); 645cdf0e10cSrcweir Rectangle aRect (aPnt, aSize); 646cdf0e10cSrcweir 647cdf0e10cSrcweir SdrOle2Obj* pObj = new SdrOle2Obj( aObjRef, aName, aRect); 648cdf0e10cSrcweir 649cdf0e10cSrcweir if( mpView->InsertObjectAtView(pObj, *pPV, SDRINSERT_SETDEFLAYER) ) 650cdf0e10cSrcweir { 651cdf0e10cSrcweir // #73279# Math objects change their object size during InsertObject. 652cdf0e10cSrcweir // New size must be set in SdrObject, or a wrong scale will be set at 653cdf0e10cSrcweir // ActivateObject. 654cdf0e10cSrcweir 655cdf0e10cSrcweir if ( nAspect != embed::Aspects::MSOLE_ICON ) 656cdf0e10cSrcweir { 657cdf0e10cSrcweir try 658cdf0e10cSrcweir { 659cdf0e10cSrcweir awt::Size aSz = xObj->getVisualAreaSize( nAspect ); 660cdf0e10cSrcweir 661cdf0e10cSrcweir Size aNewSize = Window::LogicToLogic( Size( aSz.Width, aSz.Height ), 662cdf0e10cSrcweir MapMode( aMapUnit ), MapMode( MAP_100TH_MM ) ); 663cdf0e10cSrcweir if ( aNewSize != aSize ) 664cdf0e10cSrcweir { 665cdf0e10cSrcweir aRect.SetSize( aNewSize ); 666cdf0e10cSrcweir pObj->SetLogicRect( aRect ); 667cdf0e10cSrcweir } 668cdf0e10cSrcweir } 669cdf0e10cSrcweir catch( embed::NoVisualAreaSizeException& ) 670cdf0e10cSrcweir {} 671cdf0e10cSrcweir } 672cdf0e10cSrcweir 673cdf0e10cSrcweir if (bCreateNew) 674cdf0e10cSrcweir { 675cdf0e10cSrcweir //HMHmpView->HideMarkHdl(); 676cdf0e10cSrcweir pObj->SetLogicRect(aRect); 677cdf0e10cSrcweir 678cdf0e10cSrcweir if ( nAspect != embed::Aspects::MSOLE_ICON ) 679cdf0e10cSrcweir { 680cdf0e10cSrcweir Size aTmp = OutputDevice::LogicToLogic( aRect.GetSize(), MAP_100TH_MM, aMapUnit ); 681cdf0e10cSrcweir awt::Size aSz( aTmp.Width(), aTmp.Height() ); 682cdf0e10cSrcweir xObj->setVisualAreaSize( nAspect, aSz ); 683cdf0e10cSrcweir } 684cdf0e10cSrcweir 685cdf0e10cSrcweir mpViewShell->ActivateObject(pObj, SVVERB_SHOW); 686cdf0e10cSrcweir } 687cdf0e10cSrcweir 688cdf0e10cSrcweir Size aVisSizePixel = mpWindow->GetOutputSizePixel(); 689cdf0e10cSrcweir Rectangle aVisAreaWin = mpWindow->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel) ); 690cdf0e10cSrcweir mpViewShell->VisAreaChanged(aVisAreaWin); 691cdf0e10cSrcweir mpDocSh->SetVisArea(aVisAreaWin); 692cdf0e10cSrcweir } 693cdf0e10cSrcweir } 694cdf0e10cSrcweir } 695cdf0e10cSrcweir } 696cdf0e10cSrcweir catch (uno::Exception&) 697cdf0e10cSrcweir { 698cdf0e10cSrcweir // For some reason the object can not be inserted. For example 699cdf0e10cSrcweir // because it is password protected and is not properly unlocked. 700cdf0e10cSrcweir } 701cdf0e10cSrcweir } 702cdf0e10cSrcweir } 703cdf0e10cSrcweir 704cdf0e10cSrcweir 705cdf0e10cSrcweir /************************************************************************* 706cdf0e10cSrcweir |* 707cdf0e10cSrcweir |* FuInsertAVMedia::Konstruktor 708cdf0e10cSrcweir |* 709cdf0e10cSrcweir \************************************************************************/ 710cdf0e10cSrcweir 711cdf0e10cSrcweir FuInsertAVMedia::FuInsertAVMedia( 712cdf0e10cSrcweir ViewShell* pViewSh, 713cdf0e10cSrcweir ::sd::Window* pWin, 714cdf0e10cSrcweir ::sd::View* pView, 715cdf0e10cSrcweir SdDrawDocument* pDoc, 716cdf0e10cSrcweir SfxRequest& rReq) 717cdf0e10cSrcweir : FuPoor(pViewSh, pWin, pView, pDoc, rReq) 718cdf0e10cSrcweir { 719cdf0e10cSrcweir } 720cdf0e10cSrcweir 721cdf0e10cSrcweir FunctionReference FuInsertAVMedia::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq ) 722cdf0e10cSrcweir { 723cdf0e10cSrcweir FunctionReference xFunc( new FuInsertAVMedia( pViewSh, pWin, pView, pDoc, rReq ) ); 724cdf0e10cSrcweir xFunc->DoExecute(rReq); 725cdf0e10cSrcweir return xFunc; 726cdf0e10cSrcweir } 727cdf0e10cSrcweir 728cdf0e10cSrcweir void FuInsertAVMedia::DoExecute( SfxRequest& rReq ) 729cdf0e10cSrcweir { 730cdf0e10cSrcweir ::rtl::OUString aURL; 731cdf0e10cSrcweir const SfxItemSet* pReqArgs = rReq.GetArgs(); 732cdf0e10cSrcweir bool bAPI = false; 733cdf0e10cSrcweir 734cdf0e10cSrcweir if( pReqArgs ) 735cdf0e10cSrcweir { 736cdf0e10cSrcweir const SfxStringItem* pStringItem = PTR_CAST( SfxStringItem, &pReqArgs->Get( rReq.GetSlot() ) ); 737cdf0e10cSrcweir 738cdf0e10cSrcweir if( pStringItem ) 739cdf0e10cSrcweir { 740cdf0e10cSrcweir aURL = pStringItem->GetValue(); 741cdf0e10cSrcweir bAPI = aURL.getLength(); 742cdf0e10cSrcweir } 743cdf0e10cSrcweir } 744cdf0e10cSrcweir 745cdf0e10cSrcweir if( bAPI || ::avmedia::MediaWindow::executeMediaURLDialog( mpWindow, aURL ) ) 746cdf0e10cSrcweir { 747cdf0e10cSrcweir Size aPrefSize; 748cdf0e10cSrcweir 749cdf0e10cSrcweir if( mpWindow ) 750cdf0e10cSrcweir mpWindow->EnterWait(); 751cdf0e10cSrcweir 752cdf0e10cSrcweir if( !::avmedia::MediaWindow::isMediaURL( aURL, true, &aPrefSize ) ) 753cdf0e10cSrcweir { 754cdf0e10cSrcweir if( mpWindow ) 755cdf0e10cSrcweir mpWindow->LeaveWait(); 756cdf0e10cSrcweir 757cdf0e10cSrcweir if( !bAPI ) 758cdf0e10cSrcweir ::avmedia::MediaWindow::executeFormatErrorBox( mpWindow ); 759cdf0e10cSrcweir } 760cdf0e10cSrcweir else 761cdf0e10cSrcweir { 762cdf0e10cSrcweir Point aPos; 763cdf0e10cSrcweir Size aSize; 764cdf0e10cSrcweir sal_Int8 nAction = DND_ACTION_COPY; 765cdf0e10cSrcweir 766cdf0e10cSrcweir if( aPrefSize.Width() && aPrefSize.Height() ) 767cdf0e10cSrcweir { 768cdf0e10cSrcweir if( mpWindow ) 769cdf0e10cSrcweir aSize = mpWindow->PixelToLogic( aPrefSize, MAP_100TH_MM ); 770cdf0e10cSrcweir else 771cdf0e10cSrcweir aSize = Application::GetDefaultDevice()->PixelToLogic( aPrefSize, MAP_100TH_MM ); 772cdf0e10cSrcweir } 773cdf0e10cSrcweir else 774cdf0e10cSrcweir aSize = Size( 5000, 5000 ); 775cdf0e10cSrcweir 776cdf0e10cSrcweir if( mpWindow ) 777cdf0e10cSrcweir { 778cdf0e10cSrcweir aPos = mpWindow->PixelToLogic( Rectangle( aPos, mpWindow->GetOutputSizePixel() ).Center() ); 779cdf0e10cSrcweir aPos.X() -= aSize.Width() >> 1; 780cdf0e10cSrcweir aPos.Y() -= aSize.Height() >> 1; 781cdf0e10cSrcweir } 782cdf0e10cSrcweir 783cdf0e10cSrcweir mpView->InsertMediaURL( aURL, nAction, aPos, aSize ) ; 784cdf0e10cSrcweir 785cdf0e10cSrcweir if( mpWindow ) 786cdf0e10cSrcweir mpWindow->LeaveWait(); 787cdf0e10cSrcweir } 788cdf0e10cSrcweir } 789cdf0e10cSrcweir } 790cdf0e10cSrcweir 791cdf0e10cSrcweir } // end of namespace sd 792