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