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