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