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 "View.hxx" 32*cdf0e10cSrcweir #include <unotools/localfilehelper.hxx> 33*cdf0e10cSrcweir #include <sfx2/request.hxx> 34*cdf0e10cSrcweir #include <sfx2/docfilt.hxx> 35*cdf0e10cSrcweir #include <sfx2/fcontnr.hxx> 36*cdf0e10cSrcweir #include <sfx2/docfile.hxx> 37*cdf0e10cSrcweir #include <vcl/msgbox.hxx> 38*cdf0e10cSrcweir #include <svl/urlbmk.hxx> 39*cdf0e10cSrcweir #include <svx/svdpagv.hxx> 40*cdf0e10cSrcweir #include <svx/xfillit.hxx> 41*cdf0e10cSrcweir #include <svx/svdundo.hxx> 42*cdf0e10cSrcweir #include <svx/xoutbmp.hxx> 43*cdf0e10cSrcweir #include <svx/svdograf.hxx> 44*cdf0e10cSrcweir #include <svx/svdomedia.hxx> 45*cdf0e10cSrcweir #include <svx/svdoole2.hxx> 46*cdf0e10cSrcweir #include <sot/storage.hxx> 47*cdf0e10cSrcweir #include <sfx2/app.hxx> 48*cdf0e10cSrcweir #include <avmedia/mediawindow.hxx> 49*cdf0e10cSrcweir #include <svtools/ehdl.hxx> 50*cdf0e10cSrcweir #include <svtools/sfxecode.hxx> 51*cdf0e10cSrcweir #include <svtools/filter.hxx> 52*cdf0e10cSrcweir #include "app.hrc" 53*cdf0e10cSrcweir #include "Window.hxx" 54*cdf0e10cSrcweir #include "DrawDocShell.hxx" 55*cdf0e10cSrcweir #include "DrawViewShell.hxx" 56*cdf0e10cSrcweir #include "fuinsfil.hxx" 57*cdf0e10cSrcweir #include "drawdoc.hxx" 58*cdf0e10cSrcweir #include "sdresid.hxx" 59*cdf0e10cSrcweir #include "strings.hrc" 60*cdf0e10cSrcweir #include "imapinfo.hxx" 61*cdf0e10cSrcweir #include "sdpage.hxx" 62*cdf0e10cSrcweir #include "view/SlideSorterView.hxx" 63*cdf0e10cSrcweir #include "undo/undoobjects.hxx" 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 66*cdf0e10cSrcweir #include <com/sun/star/embed/ElementModes.hpp> 67*cdf0e10cSrcweir #include <com/sun/star/embed/XEmbedPersist.hpp> 68*cdf0e10cSrcweir #include <com/sun/star/embed/Aspects.hpp> 69*cdf0e10cSrcweir #include <com/sun/star/embed/NoVisualAreaSizeException.hpp> 70*cdf0e10cSrcweir #include <svtools/soerr.hxx> 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir #include <sfx2/ipclient.hxx> 73*cdf0e10cSrcweir 74*cdf0e10cSrcweir using namespace com::sun::star; 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir namespace sd { 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir #ifdef _MSC_VER 79*cdf0e10cSrcweir #pragma optimize ( "", off ) 80*cdf0e10cSrcweir #endif 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir /************************************************************************* 83*cdf0e10cSrcweir |* 84*cdf0e10cSrcweir |* Graphik einfuegen 85*cdf0e10cSrcweir |* Wird ein leeres Graphikobjekt uebergeben, so wird dieses gefuellt. 86*cdf0e10cSrcweir |* Andernfalls wird ein an der gegebenen Position vorhandenes Objekt 87*cdf0e10cSrcweir |* gefuellt. Ist an der Position kein Objekt vorhanden, so wird ein neues 88*cdf0e10cSrcweir |* Objekt erzeugt und ein Pointer auf dieses Objekt zurueckgegeben. 89*cdf0e10cSrcweir |* 90*cdf0e10cSrcweir \************************************************************************/ 91*cdf0e10cSrcweir 92*cdf0e10cSrcweir SdrGrafObj* View::InsertGraphic( const Graphic& rGraphic, sal_Int8& rAction, 93*cdf0e10cSrcweir const Point& rPos, SdrObject* pObj, ImageMap* pImageMap ) 94*cdf0e10cSrcweir { 95*cdf0e10cSrcweir SdrEndTextEdit(); 96*cdf0e10cSrcweir mnAction = rAction; 97*cdf0e10cSrcweir 98*cdf0e10cSrcweir // Liegt ein Objekt an der Position rPos? 99*cdf0e10cSrcweir SdrGrafObj* pNewGrafObj = NULL; 100*cdf0e10cSrcweir SdrPageView* pPV = GetSdrPageView(); 101*cdf0e10cSrcweir SdrObject* pPickObj = pObj; 102*cdf0e10cSrcweir const bool bOnMaster = pPV && pPV->GetPage() && pPV->GetPage()->IsMasterPage(); 103*cdf0e10cSrcweir 104*cdf0e10cSrcweir if(pPV && this->ISA(::sd::slidesorter::view::SlideSorterView)) 105*cdf0e10cSrcweir { 106*cdf0e10cSrcweir if(!pPV->GetPageRect().IsInside(rPos)) 107*cdf0e10cSrcweir pPV = 0L; 108*cdf0e10cSrcweir } 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir if( !pPickObj && pPV ) 111*cdf0e10cSrcweir { 112*cdf0e10cSrcweir SdrPageView* pPageView = pPV; 113*cdf0e10cSrcweir PickObj(rPos, getHitTolLog(), pPickObj, pPageView); 114*cdf0e10cSrcweir } 115*cdf0e10cSrcweir 116*cdf0e10cSrcweir if( mnAction == DND_ACTION_LINK && pPickObj && pPV ) 117*cdf0e10cSrcweir { 118*cdf0e10cSrcweir const bool bIsGraphic = pPickObj->ISA( SdrGrafObj ); 119*cdf0e10cSrcweir if( bIsGraphic || (pObj->IsEmptyPresObj() && !bOnMaster) ) 120*cdf0e10cSrcweir { 121*cdf0e10cSrcweir if( IsUndoEnabled() ) 122*cdf0e10cSrcweir BegUndo(String(SdResId(STR_INSERTGRAPHIC))); 123*cdf0e10cSrcweir 124*cdf0e10cSrcweir SdPage* pPage = (SdPage*) pPickObj->GetPage(); 125*cdf0e10cSrcweir 126*cdf0e10cSrcweir if( bIsGraphic ) 127*cdf0e10cSrcweir { 128*cdf0e10cSrcweir // Das Objekt wird mit der Bitmap gefuellt 129*cdf0e10cSrcweir pNewGrafObj = (SdrGrafObj*) pPickObj->Clone(); 130*cdf0e10cSrcweir pNewGrafObj->SetGraphic(rGraphic); 131*cdf0e10cSrcweir } 132*cdf0e10cSrcweir else 133*cdf0e10cSrcweir { 134*cdf0e10cSrcweir pNewGrafObj = new SdrGrafObj( rGraphic, pPickObj->GetLogicRect() ); 135*cdf0e10cSrcweir pNewGrafObj->SetEmptyPresObj(sal_True); 136*cdf0e10cSrcweir } 137*cdf0e10cSrcweir 138*cdf0e10cSrcweir if ( pNewGrafObj->IsEmptyPresObj() ) 139*cdf0e10cSrcweir { 140*cdf0e10cSrcweir Rectangle aRect( pNewGrafObj->GetLogicRect() ); 141*cdf0e10cSrcweir pNewGrafObj->AdjustToMaxRect( aRect, sal_False ); 142*cdf0e10cSrcweir pNewGrafObj->SetOutlinerParaObject(NULL); 143*cdf0e10cSrcweir pNewGrafObj->SetEmptyPresObj(sal_False); 144*cdf0e10cSrcweir } 145*cdf0e10cSrcweir 146*cdf0e10cSrcweir if (pPage && pPage->IsPresObj(pPickObj)) 147*cdf0e10cSrcweir { 148*cdf0e10cSrcweir // Neues PresObj in die Liste eintragen 149*cdf0e10cSrcweir pPage->InsertPresObj( pNewGrafObj, PRESOBJ_GRAPHIC ); 150*cdf0e10cSrcweir pNewGrafObj->SetUserCall(pPickObj->GetUserCall()); 151*cdf0e10cSrcweir } 152*cdf0e10cSrcweir 153*cdf0e10cSrcweir if (pImageMap) 154*cdf0e10cSrcweir pNewGrafObj->InsertUserData(new SdIMapInfo(*pImageMap)); 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir ReplaceObjectAtView(pPickObj, *pPV, pNewGrafObj); // maybe ReplaceObjectAtView 157*cdf0e10cSrcweir 158*cdf0e10cSrcweir if( IsUndoEnabled() ) 159*cdf0e10cSrcweir EndUndo(); 160*cdf0e10cSrcweir } 161*cdf0e10cSrcweir else if (pPickObj->IsClosedObj() && !pPickObj->ISA(SdrOle2Obj)) 162*cdf0e10cSrcweir { 163*cdf0e10cSrcweir /****************************************************************** 164*cdf0e10cSrcweir * Das Objekt wird mit der Graphik gefuellt 165*cdf0e10cSrcweir ******************************************************************/ 166*cdf0e10cSrcweir if( IsUndoEnabled() ) 167*cdf0e10cSrcweir { 168*cdf0e10cSrcweir BegUndo(String(SdResId(STR_UNDO_DRAGDROP))); 169*cdf0e10cSrcweir AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*pPickObj)); 170*cdf0e10cSrcweir EndUndo(); 171*cdf0e10cSrcweir } 172*cdf0e10cSrcweir 173*cdf0e10cSrcweir XOBitmap aXOBitmap( rGraphic.GetBitmap() ); 174*cdf0e10cSrcweir SfxItemSet aSet(mpDocSh->GetPool(), XATTR_FILLSTYLE, XATTR_FILLBITMAP); 175*cdf0e10cSrcweir aSet.Put(XFillStyleItem(XFILL_BITMAP)); 176*cdf0e10cSrcweir aSet.Put(XFillBitmapItem(&mpDocSh->GetPool(), aXOBitmap)); 177*cdf0e10cSrcweir pPickObj->SetMergedItemSetAndBroadcast(aSet); 178*cdf0e10cSrcweir } 179*cdf0e10cSrcweir } 180*cdf0e10cSrcweir else if ( pPV ) 181*cdf0e10cSrcweir { 182*cdf0e10cSrcweir // create new object 183*cdf0e10cSrcweir Size aSize; 184*cdf0e10cSrcweir 185*cdf0e10cSrcweir if ( rGraphic.GetPrefMapMode().GetMapUnit() == MAP_PIXEL ) 186*cdf0e10cSrcweir { 187*cdf0e10cSrcweir ::OutputDevice* pOutDev = 0; 188*cdf0e10cSrcweir if( mpViewSh ) 189*cdf0e10cSrcweir pOutDev = mpViewSh->GetActiveWindow(); 190*cdf0e10cSrcweir 191*cdf0e10cSrcweir if( !pOutDev ) 192*cdf0e10cSrcweir pOutDev = Application::GetDefaultDevice(); 193*cdf0e10cSrcweir 194*cdf0e10cSrcweir if( pOutDev ) 195*cdf0e10cSrcweir aSize = pOutDev->PixelToLogic( rGraphic.GetPrefSize(), MAP_100TH_MM ); 196*cdf0e10cSrcweir } 197*cdf0e10cSrcweir else 198*cdf0e10cSrcweir { 199*cdf0e10cSrcweir aSize = OutputDevice::LogicToLogic( rGraphic.GetPrefSize(), 200*cdf0e10cSrcweir rGraphic.GetPrefMapMode(), 201*cdf0e10cSrcweir MapMode( MAP_100TH_MM ) ); 202*cdf0e10cSrcweir } 203*cdf0e10cSrcweir 204*cdf0e10cSrcweir pNewGrafObj = new SdrGrafObj( rGraphic, Rectangle( rPos, aSize ) ); 205*cdf0e10cSrcweir SdrPage* pPage = pPV->GetPage(); 206*cdf0e10cSrcweir Size aPageSize( pPage->GetSize() ); 207*cdf0e10cSrcweir aPageSize.Width() -= pPage->GetLftBorder() + pPage->GetRgtBorder(); 208*cdf0e10cSrcweir aPageSize.Height() -= pPage->GetUppBorder() + pPage->GetLwrBorder(); 209*cdf0e10cSrcweir pNewGrafObj->AdjustToMaxRect( Rectangle( Point(), aPageSize ), sal_True ); 210*cdf0e10cSrcweir // pNewGrafObj->AdjustToMaxRect( Rectangle( pPV->GetOffset(), aPageSize ), sal_True ); 211*cdf0e10cSrcweir 212*cdf0e10cSrcweir sal_uLong nOptions = SDRINSERT_SETDEFLAYER; 213*cdf0e10cSrcweir sal_Bool bIsPresTarget = sal_False; 214*cdf0e10cSrcweir 215*cdf0e10cSrcweir if ((mpViewSh 216*cdf0e10cSrcweir && mpViewSh->GetViewShell()!=NULL 217*cdf0e10cSrcweir && mpViewSh->GetViewShell()->GetIPClient() 218*cdf0e10cSrcweir && mpViewSh->GetViewShell()->GetIPClient()->IsObjectInPlaceActive()) 219*cdf0e10cSrcweir || this->ISA(::sd::slidesorter::view::SlideSorterView)) 220*cdf0e10cSrcweir nOptions |= SDRINSERT_DONTMARK; 221*cdf0e10cSrcweir 222*cdf0e10cSrcweir if( ( mnAction & DND_ACTION_MOVE ) && pPickObj && (pPickObj->IsEmptyPresObj() || pPickObj->GetUserCall()) ) 223*cdf0e10cSrcweir { 224*cdf0e10cSrcweir SdPage* pP = static_cast< SdPage* >( pPickObj->GetPage() ); 225*cdf0e10cSrcweir 226*cdf0e10cSrcweir if ( pP && pP->IsMasterPage() ) 227*cdf0e10cSrcweir bIsPresTarget = pP->IsPresObj(pPickObj); 228*cdf0e10cSrcweir } 229*cdf0e10cSrcweir 230*cdf0e10cSrcweir if( ( mnAction & DND_ACTION_MOVE ) && pPickObj && !bIsPresTarget ) 231*cdf0e10cSrcweir { 232*cdf0e10cSrcweir // replace object 233*cdf0e10cSrcweir if (pImageMap) 234*cdf0e10cSrcweir pNewGrafObj->InsertUserData(new SdIMapInfo(*pImageMap)); 235*cdf0e10cSrcweir 236*cdf0e10cSrcweir Rectangle aPickObjRect(pPickObj->GetCurrentBoundRect()); 237*cdf0e10cSrcweir Size aPickObjSize(aPickObjRect.GetSize()); 238*cdf0e10cSrcweir Rectangle aObjRect(pNewGrafObj->GetCurrentBoundRect()); 239*cdf0e10cSrcweir Size aObjSize(aObjRect.GetSize()); 240*cdf0e10cSrcweir 241*cdf0e10cSrcweir Fraction aScaleWidth(aPickObjSize.Width(), aObjSize.Width()); 242*cdf0e10cSrcweir Fraction aScaleHeight(aPickObjSize.Height(), aObjSize.Height()); 243*cdf0e10cSrcweir pNewGrafObj->NbcResize(aObjRect.TopLeft(), aScaleWidth, aScaleHeight); 244*cdf0e10cSrcweir 245*cdf0e10cSrcweir Point aVec = aPickObjRect.TopLeft() - aObjRect.TopLeft(); 246*cdf0e10cSrcweir pNewGrafObj->NbcMove(Size(aVec.X(), aVec.Y())); 247*cdf0e10cSrcweir 248*cdf0e10cSrcweir const bool bUndo = IsUndoEnabled(); 249*cdf0e10cSrcweir 250*cdf0e10cSrcweir if( bUndo ) 251*cdf0e10cSrcweir BegUndo(String(SdResId(STR_UNDO_DRAGDROP))); 252*cdf0e10cSrcweir pNewGrafObj->NbcSetLayer(pPickObj->GetLayer()); 253*cdf0e10cSrcweir SdrPage* pP = pPV->GetPage(); 254*cdf0e10cSrcweir pP->InsertObject(pNewGrafObj); 255*cdf0e10cSrcweir if( bUndo ) 256*cdf0e10cSrcweir { 257*cdf0e10cSrcweir AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoNewObject(*pNewGrafObj)); 258*cdf0e10cSrcweir AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoDeleteObject(*pPickObj)); 259*cdf0e10cSrcweir } 260*cdf0e10cSrcweir pP->RemoveObject(pPickObj->GetOrdNum()); 261*cdf0e10cSrcweir 262*cdf0e10cSrcweir if( bUndo ) 263*cdf0e10cSrcweir { 264*cdf0e10cSrcweir EndUndo(); 265*cdf0e10cSrcweir } 266*cdf0e10cSrcweir else 267*cdf0e10cSrcweir { 268*cdf0e10cSrcweir SdrObject::Free(pPickObj); 269*cdf0e10cSrcweir } 270*cdf0e10cSrcweir mnAction = DND_ACTION_COPY; 271*cdf0e10cSrcweir } 272*cdf0e10cSrcweir else 273*cdf0e10cSrcweir { 274*cdf0e10cSrcweir InsertObjectAtView(pNewGrafObj, *pPV, nOptions); 275*cdf0e10cSrcweir 276*cdf0e10cSrcweir if( pImageMap ) 277*cdf0e10cSrcweir pNewGrafObj->InsertUserData(new SdIMapInfo(*pImageMap)); 278*cdf0e10cSrcweir } 279*cdf0e10cSrcweir } 280*cdf0e10cSrcweir 281*cdf0e10cSrcweir rAction = mnAction; 282*cdf0e10cSrcweir 283*cdf0e10cSrcweir return pNewGrafObj; 284*cdf0e10cSrcweir } 285*cdf0e10cSrcweir 286*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 287*cdf0e10cSrcweir 288*cdf0e10cSrcweir SdrMediaObj* View::InsertMediaURL( const rtl::OUString& rMediaURL, sal_Int8& rAction, 289*cdf0e10cSrcweir const Point& rPos, const Size& rSize ) 290*cdf0e10cSrcweir { 291*cdf0e10cSrcweir SdrEndTextEdit(); 292*cdf0e10cSrcweir mnAction = rAction; 293*cdf0e10cSrcweir 294*cdf0e10cSrcweir SdrMediaObj* pNewMediaObj = NULL; 295*cdf0e10cSrcweir SdrPageView* pPV = GetSdrPageView(); 296*cdf0e10cSrcweir SdrObject* pPickObj = GetEmptyPresentationObject( PRESOBJ_MEDIA ); 297*cdf0e10cSrcweir 298*cdf0e10cSrcweir if(pPV && this->ISA(::sd::slidesorter::view::SlideSorterView )) 299*cdf0e10cSrcweir { 300*cdf0e10cSrcweir if(!pPV->GetPageRect().IsInside(rPos)) 301*cdf0e10cSrcweir pPV = 0L; 302*cdf0e10cSrcweir } 303*cdf0e10cSrcweir 304*cdf0e10cSrcweir if( !pPickObj && pPV ) 305*cdf0e10cSrcweir { 306*cdf0e10cSrcweir SdrPageView* pPageView = pPV; 307*cdf0e10cSrcweir PickObj(rPos, getHitTolLog(), pPickObj, pPageView); 308*cdf0e10cSrcweir } 309*cdf0e10cSrcweir 310*cdf0e10cSrcweir if( mnAction == DND_ACTION_LINK && pPickObj && pPV && pPickObj->ISA( SdrMediaObj ) ) 311*cdf0e10cSrcweir { 312*cdf0e10cSrcweir pNewMediaObj = static_cast< SdrMediaObj* >( pPickObj->Clone() ); 313*cdf0e10cSrcweir pNewMediaObj->setURL( rMediaURL ); 314*cdf0e10cSrcweir 315*cdf0e10cSrcweir BegUndo(String(SdResId(STR_UNDO_DRAGDROP))); 316*cdf0e10cSrcweir ReplaceObjectAtView(pPickObj, *pPV, pNewMediaObj); 317*cdf0e10cSrcweir EndUndo(); 318*cdf0e10cSrcweir } 319*cdf0e10cSrcweir else if( pPV ) 320*cdf0e10cSrcweir { 321*cdf0e10cSrcweir Rectangle aRect( rPos, rSize ); 322*cdf0e10cSrcweir if( pPickObj ) 323*cdf0e10cSrcweir aRect = pPickObj->GetLogicRect(); 324*cdf0e10cSrcweir 325*cdf0e10cSrcweir 326*cdf0e10cSrcweir pNewMediaObj = new SdrMediaObj( aRect ); 327*cdf0e10cSrcweir 328*cdf0e10cSrcweir bool bIsPres = false; 329*cdf0e10cSrcweir if( pPickObj ) 330*cdf0e10cSrcweir { 331*cdf0e10cSrcweir SdPage* pPage = static_cast< SdPage* >(pPickObj->GetPage()); 332*cdf0e10cSrcweir bIsPres = pPage && pPage->IsPresObj(pPickObj); 333*cdf0e10cSrcweir if( bIsPres ) 334*cdf0e10cSrcweir { 335*cdf0e10cSrcweir pPage->InsertPresObj( pNewMediaObj, PRESOBJ_MEDIA ); 336*cdf0e10cSrcweir } 337*cdf0e10cSrcweir } 338*cdf0e10cSrcweir 339*cdf0e10cSrcweir if( pPickObj ) 340*cdf0e10cSrcweir ReplaceObjectAtView(pPickObj, *pPV, pNewMediaObj); 341*cdf0e10cSrcweir else 342*cdf0e10cSrcweir InsertObjectAtView( pNewMediaObj, *pPV, SDRINSERT_SETDEFLAYER ); 343*cdf0e10cSrcweir 344*cdf0e10cSrcweir pNewMediaObj->setURL( rMediaURL ); 345*cdf0e10cSrcweir 346*cdf0e10cSrcweir if( pPickObj ) 347*cdf0e10cSrcweir { 348*cdf0e10cSrcweir pNewMediaObj->AdjustToMaxRect( pPickObj->GetLogicRect() ); 349*cdf0e10cSrcweir if( bIsPres ) 350*cdf0e10cSrcweir pNewMediaObj->SetUserCall(pPickObj->GetUserCall()); 351*cdf0e10cSrcweir } 352*cdf0e10cSrcweir } 353*cdf0e10cSrcweir 354*cdf0e10cSrcweir rAction = mnAction; 355*cdf0e10cSrcweir 356*cdf0e10cSrcweir return pNewMediaObj; 357*cdf0e10cSrcweir } 358*cdf0e10cSrcweir 359*cdf0e10cSrcweir /************************************************************************* 360*cdf0e10cSrcweir |* 361*cdf0e10cSrcweir |* Timer-Handler fuer InsertFile beim Drop() 362*cdf0e10cSrcweir |* 363*cdf0e10cSrcweir \************************************************************************/ 364*cdf0e10cSrcweir 365*cdf0e10cSrcweir IMPL_LINK( View, DropInsertFileHdl, Timer*, EMPTYARG ) 366*cdf0e10cSrcweir { 367*cdf0e10cSrcweir DBG_ASSERT( mpViewSh, "sd::View::DropInsertFileHdl(), I need a view shell to work!" ); 368*cdf0e10cSrcweir if( !mpViewSh ) 369*cdf0e10cSrcweir return 0; 370*cdf0e10cSrcweir 371*cdf0e10cSrcweir SfxErrorContext aEc( ERRCTX_ERROR, mpViewSh->GetActiveWindow(), RID_SO_ERRCTX ); 372*cdf0e10cSrcweir ErrCode nError = 0; 373*cdf0e10cSrcweir 374*cdf0e10cSrcweir ::std::vector< String >::const_iterator aIter( maDropFileVector.begin() ); 375*cdf0e10cSrcweir 376*cdf0e10cSrcweir while( (aIter != maDropFileVector.end()) && !nError ) 377*cdf0e10cSrcweir { 378*cdf0e10cSrcweir String aCurrentDropFile( *aIter ); 379*cdf0e10cSrcweir INetURLObject aURL( aCurrentDropFile ); 380*cdf0e10cSrcweir sal_Bool bOK = sal_False; 381*cdf0e10cSrcweir 382*cdf0e10cSrcweir if( aURL.GetProtocol() == INET_PROT_NOT_VALID ) 383*cdf0e10cSrcweir { 384*cdf0e10cSrcweir String aURLStr; 385*cdf0e10cSrcweir ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aCurrentDropFile, aURLStr ); 386*cdf0e10cSrcweir aURL = INetURLObject( aURLStr ); 387*cdf0e10cSrcweir } 388*cdf0e10cSrcweir 389*cdf0e10cSrcweir GraphicFilter* pGraphicFilter = GraphicFilter::GetGraphicFilter(); 390*cdf0e10cSrcweir Graphic aGraphic; 391*cdf0e10cSrcweir 392*cdf0e10cSrcweir aCurrentDropFile = aURL.GetMainURL( INetURLObject::NO_DECODE ); 393*cdf0e10cSrcweir 394*cdf0e10cSrcweir if( !::avmedia::MediaWindow::isMediaURL( aCurrentDropFile ) ) 395*cdf0e10cSrcweir { 396*cdf0e10cSrcweir if( !pGraphicFilter->ImportGraphic( aGraphic, aURL ) ) 397*cdf0e10cSrcweir { 398*cdf0e10cSrcweir sal_Int8 nTempAction = ( aIter == maDropFileVector.begin() ) ? mnAction : 0; 399*cdf0e10cSrcweir const bool bLink = ( ( nTempAction & DND_ACTION_LINK ) != 0 ); 400*cdf0e10cSrcweir SdrGrafObj* pGrafObj = InsertGraphic( aGraphic, nTempAction, maDropPos, NULL, NULL ); 401*cdf0e10cSrcweir 402*cdf0e10cSrcweir if( pGrafObj && bLink ) 403*cdf0e10cSrcweir pGrafObj->SetGraphicLink( aCurrentDropFile, String() ); 404*cdf0e10cSrcweir 405*cdf0e10cSrcweir // return action from first inserted graphic 406*cdf0e10cSrcweir if( aIter == maDropFileVector.begin() ) 407*cdf0e10cSrcweir mnAction = nTempAction; 408*cdf0e10cSrcweir 409*cdf0e10cSrcweir bOK = sal_True; 410*cdf0e10cSrcweir } 411*cdf0e10cSrcweir if( !bOK ) 412*cdf0e10cSrcweir { 413*cdf0e10cSrcweir const SfxFilter* pFoundFilter = NULL; 414*cdf0e10cSrcweir SfxMedium aSfxMedium( aCurrentDropFile, STREAM_READ | STREAM_SHARE_DENYNONE, sal_False ); 415*cdf0e10cSrcweir ErrCode nErr = SFX_APP()->GetFilterMatcher().GuessFilter( aSfxMedium, &pFoundFilter, SFX_FILTER_IMPORT, SFX_FILTER_NOTINSTALLED | SFX_FILTER_EXECUTABLE ); 416*cdf0e10cSrcweir 417*cdf0e10cSrcweir if( pFoundFilter && !nErr ) 418*cdf0e10cSrcweir { 419*cdf0e10cSrcweir ::std::vector< String > aFilterVector; 420*cdf0e10cSrcweir const String aFilterName( pFoundFilter->GetFilterName() ); 421*cdf0e10cSrcweir String aLowerAsciiFileName( aCurrentDropFile ); 422*cdf0e10cSrcweir aLowerAsciiFileName.ToLowerAscii(); 423*cdf0e10cSrcweir 424*cdf0e10cSrcweir FuInsertFile::GetSupportedFilterVector( aFilterVector ); 425*cdf0e10cSrcweir 426*cdf0e10cSrcweir if( ( ::std::find( aFilterVector.begin(), aFilterVector.end(), pFoundFilter->GetMimeType() ) != aFilterVector.end() ) || 427*cdf0e10cSrcweir aFilterName.SearchAscii( "Text" ) != STRING_NOTFOUND || 428*cdf0e10cSrcweir aFilterName.SearchAscii( "Rich" ) != STRING_NOTFOUND || 429*cdf0e10cSrcweir aFilterName.SearchAscii( "RTF" ) != STRING_NOTFOUND || 430*cdf0e10cSrcweir aFilterName.SearchAscii( "HTML" ) != STRING_NOTFOUND || 431*cdf0e10cSrcweir aLowerAsciiFileName.SearchAscii(".sdd") != STRING_NOTFOUND || 432*cdf0e10cSrcweir aLowerAsciiFileName.SearchAscii(".sda") != STRING_NOTFOUND || 433*cdf0e10cSrcweir aLowerAsciiFileName.SearchAscii(".sxd") != STRING_NOTFOUND || 434*cdf0e10cSrcweir aLowerAsciiFileName.SearchAscii(".sxi") != STRING_NOTFOUND || 435*cdf0e10cSrcweir aLowerAsciiFileName.SearchAscii(".std") != STRING_NOTFOUND || 436*cdf0e10cSrcweir aLowerAsciiFileName.SearchAscii(".sti") != STRING_NOTFOUND ) 437*cdf0e10cSrcweir { 438*cdf0e10cSrcweir ::sd::Window* pWin = mpViewSh->GetActiveWindow(); 439*cdf0e10cSrcweir SfxRequest aReq(SID_INSERTFILE, 0, mpDoc->GetItemPool()); 440*cdf0e10cSrcweir SfxStringItem aItem1( ID_VAL_DUMMY0, aCurrentDropFile ), aItem2( ID_VAL_DUMMY1, pFoundFilter->GetFilterName() ); 441*cdf0e10cSrcweir 442*cdf0e10cSrcweir aReq.AppendItem( aItem1 ); 443*cdf0e10cSrcweir aReq.AppendItem( aItem2 ); 444*cdf0e10cSrcweir FuInsertFile::Create( mpViewSh, pWin, this, mpDoc, aReq ); 445*cdf0e10cSrcweir bOK = sal_True; 446*cdf0e10cSrcweir } 447*cdf0e10cSrcweir } 448*cdf0e10cSrcweir } 449*cdf0e10cSrcweir } 450*cdf0e10cSrcweir 451*cdf0e10cSrcweir if( !bOK ) 452*cdf0e10cSrcweir { 453*cdf0e10cSrcweir Size aPrefSize; 454*cdf0e10cSrcweir 455*cdf0e10cSrcweir if( ::avmedia::MediaWindow::isMediaURL( aCurrentDropFile ) && 456*cdf0e10cSrcweir ::avmedia::MediaWindow::isMediaURL( aCurrentDropFile, true, &aPrefSize ) ) 457*cdf0e10cSrcweir { 458*cdf0e10cSrcweir if( aPrefSize.Width() && aPrefSize.Height() ) 459*cdf0e10cSrcweir { 460*cdf0e10cSrcweir ::sd::Window* pWin = mpViewSh->GetActiveWindow(); 461*cdf0e10cSrcweir 462*cdf0e10cSrcweir if( pWin ) 463*cdf0e10cSrcweir aPrefSize = pWin->PixelToLogic( aPrefSize, MAP_100TH_MM ); 464*cdf0e10cSrcweir else 465*cdf0e10cSrcweir aPrefSize = Application::GetDefaultDevice()->PixelToLogic( aPrefSize, MAP_100TH_MM ); 466*cdf0e10cSrcweir } 467*cdf0e10cSrcweir else 468*cdf0e10cSrcweir aPrefSize = Size( 5000, 5000 ); 469*cdf0e10cSrcweir 470*cdf0e10cSrcweir InsertMediaURL( aCurrentDropFile, mnAction, maDropPos, aPrefSize ) ; 471*cdf0e10cSrcweir } 472*cdf0e10cSrcweir else if( mnAction & DND_ACTION_LINK ) 473*cdf0e10cSrcweir static_cast< DrawViewShell* >( mpViewSh )->InsertURLButton( aCurrentDropFile, aCurrentDropFile, String(), &maDropPos ); 474*cdf0e10cSrcweir else 475*cdf0e10cSrcweir { 476*cdf0e10cSrcweir if( mpViewSh ) 477*cdf0e10cSrcweir { 478*cdf0e10cSrcweir try 479*cdf0e10cSrcweir { 480*cdf0e10cSrcweir //TODO/MBA: testing 481*cdf0e10cSrcweir ::rtl::OUString aName; 482*cdf0e10cSrcweir uno::Sequence < beans::PropertyValue > aMedium(1); 483*cdf0e10cSrcweir aMedium[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "URL" ) ); 484*cdf0e10cSrcweir aMedium[0].Value <<= ::rtl::OUString( aCurrentDropFile ); 485*cdf0e10cSrcweir 486*cdf0e10cSrcweir uno::Reference < embed::XEmbeddedObject > xObj = mpDocSh->GetEmbeddedObjectContainer(). 487*cdf0e10cSrcweir InsertEmbeddedObject( aMedium, aName ); 488*cdf0e10cSrcweir 489*cdf0e10cSrcweir uno::Reference < embed::XEmbedPersist > xPersist( xObj, uno::UNO_QUERY ); 490*cdf0e10cSrcweir if ( xPersist.is()) 491*cdf0e10cSrcweir { 492*cdf0e10cSrcweir // TODO/LEAN: VisualArea access can switch the object to running state 493*cdf0e10cSrcweir sal_Int64 nAspect = embed::Aspects::MSOLE_CONTENT; 494*cdf0e10cSrcweir 495*cdf0e10cSrcweir xPersist->storeOwn(); 496*cdf0e10cSrcweir 497*cdf0e10cSrcweir awt::Size aSz; 498*cdf0e10cSrcweir try 499*cdf0e10cSrcweir { 500*cdf0e10cSrcweir aSz = xObj->getVisualAreaSize( nAspect ); 501*cdf0e10cSrcweir } 502*cdf0e10cSrcweir catch( embed::NoVisualAreaSizeException& ) 503*cdf0e10cSrcweir { 504*cdf0e10cSrcweir // the default size will be set later 505*cdf0e10cSrcweir } 506*cdf0e10cSrcweir 507*cdf0e10cSrcweir Size aSize( aSz.Width, aSz.Height ); 508*cdf0e10cSrcweir Rectangle aRect; 509*cdf0e10cSrcweir 510*cdf0e10cSrcweir if (!aSize.Width() || !aSize.Height()) 511*cdf0e10cSrcweir { 512*cdf0e10cSrcweir aSize.Width() = 1410; 513*cdf0e10cSrcweir aSize.Height() = 1000; 514*cdf0e10cSrcweir } 515*cdf0e10cSrcweir 516*cdf0e10cSrcweir aRect = Rectangle( maDropPos, aSize ); 517*cdf0e10cSrcweir 518*cdf0e10cSrcweir SdrOle2Obj* pOleObj = new SdrOle2Obj( svt::EmbeddedObjectRef( xObj, nAspect ), aName, aRect ); 519*cdf0e10cSrcweir sal_uLong nOptions = SDRINSERT_SETDEFLAYER; 520*cdf0e10cSrcweir 521*cdf0e10cSrcweir if (mpViewSh != NULL) 522*cdf0e10cSrcweir { 523*cdf0e10cSrcweir OSL_ASSERT (mpViewSh->GetViewShell()!=NULL); 524*cdf0e10cSrcweir SfxInPlaceClient* pIpClient = 525*cdf0e10cSrcweir mpViewSh->GetViewShell()->GetIPClient(); 526*cdf0e10cSrcweir if (pIpClient!=NULL && pIpClient->IsObjectInPlaceActive()) 527*cdf0e10cSrcweir nOptions |= SDRINSERT_DONTMARK; 528*cdf0e10cSrcweir } 529*cdf0e10cSrcweir 530*cdf0e10cSrcweir InsertObjectAtView( pOleObj, *GetSdrPageView(), nOptions ); 531*cdf0e10cSrcweir pOleObj->SetLogicRect( aRect ); 532*cdf0e10cSrcweir aSz.Width = aRect.GetWidth(); 533*cdf0e10cSrcweir aSz.Height = aRect.GetHeight(); 534*cdf0e10cSrcweir xObj->setVisualAreaSize( nAspect,aSz ); 535*cdf0e10cSrcweir } 536*cdf0e10cSrcweir } 537*cdf0e10cSrcweir catch( uno::Exception& ) 538*cdf0e10cSrcweir { 539*cdf0e10cSrcweir nError = ERRCODE_IO_GENERAL; 540*cdf0e10cSrcweir // TODO/LATER: better error handling 541*cdf0e10cSrcweir } 542*cdf0e10cSrcweir } 543*cdf0e10cSrcweir } 544*cdf0e10cSrcweir } 545*cdf0e10cSrcweir 546*cdf0e10cSrcweir ++aIter; 547*cdf0e10cSrcweir } 548*cdf0e10cSrcweir 549*cdf0e10cSrcweir if( nError ) 550*cdf0e10cSrcweir ErrorHandler::HandleError( nError ); 551*cdf0e10cSrcweir 552*cdf0e10cSrcweir return nError; 553*cdf0e10cSrcweir } 554*cdf0e10cSrcweir 555*cdf0e10cSrcweir /************************************************************************* 556*cdf0e10cSrcweir |* 557*cdf0e10cSrcweir |* Timer-Handler fuer Errorhandling beim Drop() 558*cdf0e10cSrcweir |* 559*cdf0e10cSrcweir \************************************************************************/ 560*cdf0e10cSrcweir 561*cdf0e10cSrcweir IMPL_LINK( View, DropErrorHdl, Timer*, EMPTYARG ) 562*cdf0e10cSrcweir { 563*cdf0e10cSrcweir InfoBox( mpViewSh ? mpViewSh->GetActiveWindow() : 0, String(SdResId(STR_ACTION_NOTPOSSIBLE) ) ).Execute(); 564*cdf0e10cSrcweir return 0; 565*cdf0e10cSrcweir } 566*cdf0e10cSrcweir 567*cdf0e10cSrcweir #ifdef _MSC_VER 568*cdf0e10cSrcweir #pragma optimize ( "", on ) 569*cdf0e10cSrcweir #endif 570*cdf0e10cSrcweir 571*cdf0e10cSrcweir /************************************************************************* 572*cdf0e10cSrcweir |* 573*cdf0e10cSrcweir |* Redraw sperren oder erlauben 574*cdf0e10cSrcweir |* 575*cdf0e10cSrcweir \************************************************************************/ 576*cdf0e10cSrcweir 577*cdf0e10cSrcweir void View::LockRedraw(sal_Bool bLock) 578*cdf0e10cSrcweir { 579*cdf0e10cSrcweir if (bLock) 580*cdf0e10cSrcweir { 581*cdf0e10cSrcweir mnLockRedrawSmph++; 582*cdf0e10cSrcweir DBG_ASSERT(mnLockRedrawSmph, "Ueberlauf im LockRedraw"); 583*cdf0e10cSrcweir } 584*cdf0e10cSrcweir else 585*cdf0e10cSrcweir { 586*cdf0e10cSrcweir DBG_ASSERT(mnLockRedrawSmph, "Unterlauf im LockRedraw"); 587*cdf0e10cSrcweir mnLockRedrawSmph--; 588*cdf0e10cSrcweir 589*cdf0e10cSrcweir // alle gespeicherten Redraws ausfuehren 590*cdf0e10cSrcweir if (!mnLockRedrawSmph) 591*cdf0e10cSrcweir { 592*cdf0e10cSrcweir while (mpLockedRedraws && mpLockedRedraws->Count()) 593*cdf0e10cSrcweir { 594*cdf0e10cSrcweir SdViewRedrawRec* pRec = (SdViewRedrawRec*)mpLockedRedraws->First(); 595*cdf0e10cSrcweir OutputDevice* pCurrentOut = pRec->mpOut; 596*cdf0e10cSrcweir Rectangle aBoundRect(pRec->aRect); 597*cdf0e10cSrcweir mpLockedRedraws->Remove(pRec); 598*cdf0e10cSrcweir delete pRec; 599*cdf0e10cSrcweir 600*cdf0e10cSrcweir pRec = (SdViewRedrawRec*)mpLockedRedraws->First(); 601*cdf0e10cSrcweir while (pRec) 602*cdf0e10cSrcweir { 603*cdf0e10cSrcweir if (pRec->mpOut == pCurrentOut) 604*cdf0e10cSrcweir { 605*cdf0e10cSrcweir aBoundRect.Union(pRec->aRect); 606*cdf0e10cSrcweir mpLockedRedraws->Remove(pRec); 607*cdf0e10cSrcweir delete pRec; 608*cdf0e10cSrcweir pRec = (SdViewRedrawRec*)mpLockedRedraws->GetCurObject(); 609*cdf0e10cSrcweir } 610*cdf0e10cSrcweir else 611*cdf0e10cSrcweir { 612*cdf0e10cSrcweir pRec = (SdViewRedrawRec*)mpLockedRedraws->Next(); 613*cdf0e10cSrcweir } 614*cdf0e10cSrcweir } 615*cdf0e10cSrcweir 616*cdf0e10cSrcweir CompleteRedraw(pCurrentOut, Region(aBoundRect)); 617*cdf0e10cSrcweir } 618*cdf0e10cSrcweir delete mpLockedRedraws; 619*cdf0e10cSrcweir mpLockedRedraws = NULL; 620*cdf0e10cSrcweir } 621*cdf0e10cSrcweir } 622*cdf0e10cSrcweir } 623*cdf0e10cSrcweir 624*cdf0e10cSrcweir 625*cdf0e10cSrcweir 626*cdf0e10cSrcweir 627*cdf0e10cSrcweir /************************************************************************* 628*cdf0e10cSrcweir |* 629*cdf0e10cSrcweir |* StyleSheet aus der Sleketion besorgen 630*cdf0e10cSrcweir |* 631*cdf0e10cSrcweir \************************************************************************/ 632*cdf0e10cSrcweir 633*cdf0e10cSrcweir SfxStyleSheet* View::GetStyleSheet() const 634*cdf0e10cSrcweir { 635*cdf0e10cSrcweir return SdrView::GetStyleSheet(); 636*cdf0e10cSrcweir } 637*cdf0e10cSrcweir 638*cdf0e10cSrcweir } // end of namespace sd 639