Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 :
21 : #include <unotools/streamwrap.hxx>
22 : #include <unotools/ucbstreamhelper.hxx>
23 : #include <comphelper/processfactory.hxx>
24 : #include <comphelper/string.hxx>
25 : #include <ucbhelper/content.hxx>
26 : #include <tools/resmgr.hxx>
27 : #include <tools/urlobj.hxx>
28 : #include <svl/solar.hrc>
29 : #include <svl/urihelper.hxx>
30 : #include <vcl/graphicfilter.hxx>
31 : #include <svl/itempool.hxx>
32 : #include <sfx2/docfile.hxx>
33 : #include <avmedia/mediawindow.hxx>
34 : #include <vcl/svapp.hxx>
35 : #include <svx/svdpage.hxx>
36 : #include <svx/svdograf.hxx>
37 : #include <svx/fmmodel.hxx>
38 : #include <svx/fmview.hxx>
39 : #include <svx/unomodel.hxx>
40 : #include "codec.hxx"
41 : #include "gallery.hrc"
42 : #include "svx/gallery1.hxx"
43 : #include "svx/galtheme.hxx"
44 : #include "svx/galmisc.hxx"
45 : #include <com/sun/star/sdbc/XResultSet.hpp>
46 : #include <com/sun/star/ucb/XContentAccess.hpp>
47 : #include <com/sun/star/ucb/TransferInfo.hpp>
48 : #include <com/sun/star/ucb/NameClash.hpp>
49 :
50 : // --------------
51 : // - Namespaces -
52 : // --------------
53 :
54 : using namespace ::rtl;
55 : using namespace ::com::sun::star;
56 :
57 : // ----------
58 : // - ResMgr -
59 : // ----------
60 :
61 0 : ResMgr* GetGalleryResMgr()
62 : {
63 : static ResMgr* pGalleryResMgr = NULL;
64 :
65 0 : if( !pGalleryResMgr )
66 : {
67 : pGalleryResMgr = ResMgr::CreateResMgr(
68 0 : "gal", Application::GetSettings().GetUILanguageTag() );
69 : }
70 :
71 0 : return pGalleryResMgr;
72 : }
73 :
74 : // -------------------------
75 : // - GalleryResGetBitmapEx -
76 : // -------------------------
77 :
78 0 : BitmapEx GalleryResGetBitmapEx( sal_uInt32 nId )
79 : {
80 0 : BitmapEx aBmpEx( GAL_RES( nId ) );
81 :
82 0 : if( !aBmpEx.IsTransparent() )
83 0 : aBmpEx = BitmapEx( aBmpEx.GetBitmap(), COL_LIGHTMAGENTA );
84 :
85 0 : return aBmpEx;
86 : }
87 :
88 : // ----------------------
89 : // - SgaUserDataFactory -
90 : // ----------------------
91 :
92 0 : IMPL_LINK( SgaUserDataFactory, MakeUserData, SdrObjFactory*, pObjFactory )
93 : {
94 0 : if ( pObjFactory->nInventor == IV_IMAPINFO && pObjFactory->nIdentifier == ID_IMAPINFO )
95 0 : pObjFactory->pNewData = new SgaIMapInfo;
96 :
97 0 : return 0L;
98 : }
99 :
100 : // ------------------------
101 : // - GalleryGraphicImport -
102 : // ------------------------
103 :
104 503 : sal_uInt16 GalleryGraphicImport( const INetURLObject& rURL, Graphic& rGraphic,
105 : String& rFilterName, sal_Bool bShowProgress )
106 : {
107 503 : sal_uInt16 nRet = SGA_IMPORT_NONE;
108 503 : SfxMedium aMedium( rURL.GetMainURL( INetURLObject::NO_DECODE ), STREAM_READ );
109 :
110 503 : aMedium.DownLoad();
111 :
112 503 : SvStream* pIStm = aMedium.GetInStream();
113 :
114 503 : if( pIStm )
115 : {
116 503 : GraphicFilter& rGraphicFilter = GraphicFilter::GetGraphicFilter();
117 503 : GalleryProgress* pProgress = bShowProgress ? new GalleryProgress( &rGraphicFilter ) : NULL;
118 : sal_uInt16 nFormat;
119 :
120 503 : if( !rGraphicFilter.ImportGraphic( rGraphic, rURL.GetMainURL( INetURLObject::NO_DECODE ), *pIStm, GRFILTER_FORMAT_DONTKNOW, &nFormat ) )
121 : {
122 468 : rFilterName = rGraphicFilter.GetImportFormatName( nFormat );
123 468 : nRet = SGA_IMPORT_FILE;
124 : }
125 :
126 503 : delete pProgress;
127 : }
128 :
129 503 : return nRet;
130 : }
131 :
132 : // -----------------------
133 : // - GallerySvDrawImport -
134 : // -----------------------
135 :
136 0 : sal_Bool GallerySvDrawImport( SvStream& rIStm, SdrModel& rModel )
137 : {
138 : sal_uInt32 nVersion;
139 0 : sal_Bool bRet = sal_False;
140 :
141 0 : if( GalleryCodec::IsCoded( rIStm, nVersion ) )
142 : {
143 0 : SvMemoryStream aMemStm( 65535, 65535 );
144 0 : GalleryCodec aCodec( rIStm );
145 :
146 0 : aCodec.Read( aMemStm );
147 0 : aMemStm.Seek( 0UL );
148 :
149 0 : if( 1 == nVersion )
150 : {
151 : OSL_FAIL( "staroffice binary file formats are no longer supported inside the gallery!" );
152 0 : bRet = false;
153 : }
154 0 : else if( 2 == nVersion )
155 : {
156 : // recall to read as XML
157 0 : bRet = GallerySvDrawImport( aMemStm, rModel );
158 0 : }
159 : }
160 : else
161 : {
162 : // read as XML
163 0 : uno::Reference< io::XInputStream > xInputStream( new utl::OInputStreamWrapper( rIStm ) );
164 :
165 0 : rModel.GetItemPool().SetDefaultMetric( SFX_MAPUNIT_100TH_MM );
166 0 : uno::Reference< lang::XComponent > xComponent;
167 :
168 0 : bRet = SvxDrawingLayerImport( &rModel, xInputStream, xComponent, "com.sun.star.comp.Draw.XMLOasisImporter" );
169 0 : if( !bRet || (rModel.GetPageCount() == 0) )
170 : {
171 0 : rIStm.Seek(0);
172 0 : bRet = SvxDrawingLayerImport( &rModel, xInputStream, xComponent, "com.sun.star.comp.Draw.XMLImporter" );
173 0 : }
174 :
175 : }
176 :
177 0 : return bRet;
178 : }
179 :
180 : // ---------------------
181 : // - CreateIMapGraphic -
182 : // ---------------------
183 :
184 0 : sal_Bool CreateIMapGraphic( const FmFormModel& rModel, Graphic& rGraphic, ImageMap& rImageMap )
185 : {
186 0 : sal_Bool bRet = sal_False;
187 :
188 0 : if ( rModel.GetPageCount() )
189 : {
190 0 : const SdrPage* pPage = rModel.GetPage( 0 );
191 0 : const SdrObject* pObj = pPage->GetObj( 0 );
192 :
193 0 : if ( pPage->GetObjCount() == 1 && pObj->ISA( SdrGrafObj ) )
194 : {
195 0 : const sal_uInt16 nCount = pObj->GetUserDataCount();
196 :
197 : // gibt es in den User-Daten eine IMap-Information?
198 0 : for ( sal_uInt16 i = 0; i < nCount; i++ )
199 : {
200 0 : const SdrObjUserData* pUserData = pObj->GetUserData( i );
201 :
202 0 : if ( ( pUserData->GetInventor() == IV_IMAPINFO ) && ( pUserData->GetId() == ID_IMAPINFO ) )
203 : {
204 0 : rGraphic = ( (SdrGrafObj*) pObj )->GetGraphic();
205 0 : rImageMap = ( (SgaIMapInfo*) pUserData )->GetImageMap();
206 0 : bRet = sal_True;
207 0 : break;
208 : }
209 : }
210 : }
211 : }
212 :
213 0 : return bRet;
214 : }
215 :
216 : // --------------------
217 : // - GetReducedString -
218 : // --------------------
219 :
220 0 : String GetReducedString( const INetURLObject& rURL, sal_uIntPtr nMaxLen )
221 : {
222 0 : String aReduced( rURL.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS ) );
223 :
224 0 : aReduced = aReduced.GetToken( comphelper::string::getTokenCount(aReduced, '/') - 1, '/' );
225 :
226 0 : if( INET_PROT_PRIV_SOFFICE != rURL.GetProtocol() )
227 : {
228 : sal_Unicode aDelimiter;
229 0 : const String aPath( rURL.getFSysPath( INetURLObject::FSYS_DETECT, &aDelimiter ) );
230 0 : const String aName( aReduced );
231 :
232 0 : if( aPath.Len() > nMaxLen )
233 : {
234 0 : aReduced = aPath.Copy( 0, (sal_uInt16)( nMaxLen - aName.Len() - 4 ) );
235 0 : aReduced += String( RTL_CONSTASCII_USTRINGPARAM( "..." ) );
236 0 : aReduced += aDelimiter;
237 0 : aReduced += aName;
238 : }
239 : else
240 0 : aReduced = aPath;
241 : }
242 :
243 0 : return aReduced;
244 : }
245 :
246 : // -----------------------------------------------------------------------------
247 :
248 0 : String GetSvDrawStreamNameFromURL( const INetURLObject& rSvDrawObjURL )
249 : {
250 0 : String aRet;
251 :
252 0 : if( rSvDrawObjURL.GetProtocol() == INET_PROT_PRIV_SOFFICE &&
253 0 : comphelper::string::getTokenCount(rSvDrawObjURL.GetMainURL( INetURLObject::NO_DECODE ), '/') == 3 )
254 : {
255 0 : aRet = String(rSvDrawObjURL.GetMainURL( INetURLObject::NO_DECODE )).GetToken( 2, '/' );
256 : }
257 :
258 0 : return aRet;
259 : }
260 :
261 : // -----------------------------------------------------------------------------
262 :
263 635 : sal_Bool FileExists( const INetURLObject& rURL )
264 : {
265 635 : sal_Bool bRet = sal_False;
266 :
267 635 : if( rURL.GetProtocol() != INET_PROT_NOT_VALID )
268 : {
269 : try
270 : {
271 635 : ::ucbhelper::Content aCnt( rURL.GetMainURL( INetURLObject::NO_DECODE ), uno::Reference< ucb::XCommandEnvironment >(), comphelper::getProcessComponentContext() );
272 1270 : OUString aTitle;
273 :
274 723 : aCnt.getPropertyValue("Title") >>= aTitle;
275 1182 : bRet = ( !aTitle.isEmpty() );
276 : }
277 0 : catch( const ucb::ContentCreationException& )
278 : {
279 : }
280 0 : catch( const uno::RuntimeException& )
281 : {
282 : }
283 88 : catch( const uno::Exception& )
284 : {
285 : }
286 : }
287 :
288 635 : return bRet;
289 : }
290 :
291 : // -----------------------------------------------------------------------------
292 :
293 0 : sal_Bool CreateDir( const INetURLObject& rURL )
294 : {
295 0 : sal_Bool bRet = FileExists( rURL );
296 :
297 0 : if( !bRet )
298 : {
299 : try
300 : {
301 0 : uno::Reference< ucb::XCommandEnvironment > aCmdEnv;
302 0 : INetURLObject aNewFolderURL( rURL );
303 0 : INetURLObject aParentURL( aNewFolderURL ); aParentURL.removeSegment();
304 0 : ::ucbhelper::Content aParent( aParentURL.GetMainURL( INetURLObject::NO_DECODE ), aCmdEnv, comphelper::getProcessComponentContext() );
305 0 : uno::Sequence< OUString > aProps( 1 );
306 0 : uno::Sequence< uno::Any > aValues( 1 );
307 :
308 0 : aProps.getArray()[ 0 ] = OUString("Title");
309 0 : aValues.getArray()[ 0 ] = uno::makeAny( OUString( aNewFolderURL.GetName() ) );
310 :
311 0 : ::ucbhelper::Content aContent( aNewFolderURL.GetMainURL( INetURLObject::NO_DECODE ), aCmdEnv, comphelper::getProcessComponentContext() );
312 0 : bRet = aParent.insertNewContent( OUString("application/vnd.sun.staroffice.fsys-folder"), aProps, aValues, aContent );
313 : }
314 0 : catch( const ucb::ContentCreationException& )
315 : {
316 : }
317 0 : catch( const uno::RuntimeException& )
318 : {
319 : }
320 0 : catch( const uno::Exception& )
321 : {
322 : }
323 : }
324 :
325 0 : return bRet;
326 : }
327 :
328 : // -----------------------------------------------------------------------------
329 :
330 0 : sal_Bool CopyFile( const INetURLObject& rSrcURL, const INetURLObject& rDstURL )
331 : {
332 0 : sal_Bool bRet = sal_False;
333 :
334 : try
335 : {
336 0 : ::ucbhelper::Content aDestPath( rDstURL.GetMainURL( INetURLObject::NO_DECODE ), uno::Reference< ucb::XCommandEnvironment >(), comphelper::getProcessComponentContext() );
337 :
338 : aDestPath.executeCommand( OUString("transfer"),
339 : uno::makeAny( ucb::TransferInfo( sal_False, rSrcURL.GetMainURL( INetURLObject::NO_DECODE ),
340 0 : rDstURL.GetName(), ucb::NameClash::OVERWRITE ) ) );
341 0 : bRet = sal_True;
342 : }
343 0 : catch( const ucb::ContentCreationException& )
344 : {
345 : }
346 0 : catch( const uno::RuntimeException& )
347 : {
348 : }
349 0 : catch( const uno::Exception& )
350 : {
351 : }
352 :
353 0 : return bRet;
354 : }
355 :
356 : // -----------------------------------------------------------------------------
357 :
358 11 : sal_Bool KillFile( const INetURLObject& rURL )
359 : {
360 11 : sal_Bool bRet = FileExists( rURL );
361 :
362 11 : if( bRet )
363 : {
364 : try
365 : {
366 11 : ::ucbhelper::Content aCnt( rURL.GetMainURL( INetURLObject::NO_DECODE ), uno::Reference< ucb::XCommandEnvironment >(), comphelper::getProcessComponentContext() );
367 11 : aCnt.executeCommand( OUString("delete"), uno::makeAny( sal_Bool( sal_True ) ) );
368 : }
369 0 : catch( const ucb::ContentCreationException& )
370 : {
371 0 : bRet = sal_False;
372 : }
373 0 : catch( const uno::RuntimeException& )
374 : {
375 0 : bRet = sal_False;
376 : }
377 0 : catch( const uno::Exception& )
378 : {
379 0 : bRet = sal_False;
380 : }
381 : }
382 :
383 11 : return bRet;
384 : }
385 :
386 : // -------------------
387 : // - GalleryProgress -
388 : // -------------------
389 : DBG_NAME(GalleryProgress)
390 :
391 0 : GalleryProgress::GalleryProgress( GraphicFilter* pFilter ) :
392 0 : mpFilter( pFilter )
393 : {
394 : DBG_CTOR(GalleryProgress,NULL);
395 :
396 0 : uno::Reference< lang::XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() );
397 :
398 0 : uno::Reference< awt::XProgressMonitor > xMonitor( xMgr->createInstance(
399 0 : OUString("com.sun.star.awt.XProgressMonitor") ),
400 0 : uno::UNO_QUERY );
401 :
402 0 : if ( xMonitor.is() )
403 : {
404 0 : mxProgressBar = uno::Reference< awt::XProgressBar >( xMonitor, uno::UNO_QUERY );
405 :
406 0 : if( mxProgressBar.is() )
407 : {
408 0 : String aProgressText;
409 :
410 0 : if( mpFilter )
411 : {
412 0 : aProgressText = GAL_RESSTR(RID_SVXSTR_GALLERY_FILTER);
413 : // mpFilter->SetUpdatePercentHdl( LINK( this, GalleryProgress, Update ) ); // sj: progress wasn't working up from SO7 at all
414 : // // so I am removing this. The gallery progress should
415 : // // be changed to use the XStatusIndicator instead of XProgressMonitor
416 : }
417 : else
418 0 : aProgressText = String( RTL_CONSTASCII_USTRINGPARAM( "Gallery" ) );
419 :
420 0 : xMonitor->addText( String( RTL_CONSTASCII_USTRINGPARAM( "Gallery" ) ), aProgressText, sal_False ) ;
421 0 : mxProgressBar->setRange( 0, GALLERY_PROGRESS_RANGE );
422 : }
423 0 : }
424 0 : }
425 :
426 : // ------------------------------------------------------------------------
427 :
428 0 : GalleryProgress::~GalleryProgress()
429 : {
430 : DBG_DTOR(GalleryProgress,NULL);
431 0 : }
432 :
433 : // ------------------------------------------------------------------------
434 :
435 0 : void GalleryProgress::Update( sal_uIntPtr nVal, sal_uIntPtr nMaxVal )
436 : {
437 0 : if( mxProgressBar.is() && nMaxVal )
438 0 : mxProgressBar->setValue( std::min( (sal_uIntPtr)( (double) nVal / nMaxVal * GALLERY_PROGRESS_RANGE ), (sal_uIntPtr) GALLERY_PROGRESS_RANGE ) );
439 0 : }
440 :
441 : // -----------------------
442 : // - GalleryTransferable -
443 : // -----------------------
444 : DBG_NAME(GalleryTransferable)
445 :
446 0 : GalleryTransferable::GalleryTransferable( GalleryTheme* pTheme, sal_uIntPtr nObjectPos, bool bLazy ) :
447 : mpTheme( pTheme ),
448 0 : meObjectKind( mpTheme->GetObjectKind( nObjectPos ) ),
449 : mnObjectPos( nObjectPos ),
450 : mpGraphicObject( NULL ),
451 : mpImageMap( NULL ),
452 0 : mpURL( NULL )
453 : {
454 : DBG_CTOR(GalleryTransferable,NULL);
455 :
456 0 : InitData( bLazy );
457 0 : }
458 :
459 : // ------------------------------------------------------------------------
460 :
461 0 : GalleryTransferable::~GalleryTransferable()
462 : {
463 : DBG_DTOR(GalleryTransferable,NULL);
464 0 : }
465 :
466 : // ------------------------------------------------------------------------
467 :
468 0 : void GalleryTransferable::InitData( bool bLazy )
469 : {
470 0 : switch( meObjectKind )
471 : {
472 : case( SGA_OBJ_SVDRAW ):
473 : {
474 0 : if( !bLazy )
475 : {
476 0 : if( !mpGraphicObject )
477 : {
478 0 : Graphic aGraphic;
479 :
480 0 : if( mpTheme->GetGraphic( mnObjectPos, aGraphic ) )
481 0 : mpGraphicObject = new GraphicObject( aGraphic );
482 : }
483 :
484 0 : if( !mxModelStream.Is() )
485 : {
486 0 : mxModelStream = new SotStorageStream( String() );
487 0 : mxModelStream->SetBufferSize( 16348 );
488 :
489 0 : if( !mpTheme->GetModelStream( mnObjectPos, mxModelStream ) )
490 0 : mxModelStream.Clear();
491 : else
492 0 : mxModelStream->Seek( 0 );
493 : }
494 : }
495 : }
496 0 : break;
497 :
498 : case( SGA_OBJ_ANIM ):
499 : case( SGA_OBJ_BMP ):
500 : case( SGA_OBJ_INET ):
501 : case( SGA_OBJ_SOUND ):
502 : {
503 0 : if( !mpURL )
504 : {
505 0 : mpURL = new INetURLObject;
506 :
507 0 : if( !mpTheme->GetURL( mnObjectPos, *mpURL ) )
508 0 : delete mpURL, mpURL = NULL;
509 : }
510 :
511 0 : if( ( SGA_OBJ_SOUND != meObjectKind ) && !mpGraphicObject )
512 : {
513 0 : Graphic aGraphic;
514 :
515 0 : if( mpTheme->GetGraphic( mnObjectPos, aGraphic ) )
516 0 : mpGraphicObject = new GraphicObject( aGraphic );
517 : }
518 : }
519 0 : break;
520 :
521 : default:
522 : OSL_FAIL( "GalleryTransferable::GalleryTransferable: invalid object type" );
523 0 : break;
524 : }
525 0 : }
526 :
527 : // ------------------------------------------------------------------------
528 :
529 0 : void GalleryTransferable::AddSupportedFormats()
530 : {
531 0 : if( SGA_OBJ_SVDRAW == meObjectKind )
532 : {
533 0 : AddFormat( SOT_FORMATSTR_ID_DRAWING );
534 0 : AddFormat( SOT_FORMATSTR_ID_SVXB );
535 0 : AddFormat( FORMAT_GDIMETAFILE );
536 0 : AddFormat( FORMAT_BITMAP );
537 : }
538 : else
539 : {
540 0 : if( mpURL )
541 0 : AddFormat( FORMAT_FILE );
542 :
543 0 : if( mpGraphicObject )
544 : {
545 0 : AddFormat( SOT_FORMATSTR_ID_SVXB );
546 :
547 0 : if( mpGraphicObject->GetType() == GRAPHIC_GDIMETAFILE )
548 : {
549 0 : AddFormat( FORMAT_GDIMETAFILE );
550 0 : AddFormat( FORMAT_BITMAP );
551 : }
552 : else
553 : {
554 0 : AddFormat( FORMAT_BITMAP );
555 0 : AddFormat( FORMAT_GDIMETAFILE );
556 : }
557 : }
558 : }
559 0 : }
560 :
561 : // ------------------------------------------------------------------------
562 :
563 0 : sal_Bool GalleryTransferable::GetData( const datatransfer::DataFlavor& rFlavor )
564 : {
565 0 : sal_uInt32 nFormat = SotExchange::GetFormat( rFlavor );
566 0 : sal_Bool bRet = sal_False;
567 :
568 0 : InitData( false );
569 :
570 0 : if( ( SOT_FORMATSTR_ID_DRAWING == nFormat ) && ( SGA_OBJ_SVDRAW == meObjectKind ) )
571 : {
572 0 : bRet = ( mxModelStream.Is() && SetObject( &mxModelStream, 0, rFlavor ) );
573 : }
574 0 : else if( ( SOT_FORMATSTR_ID_SVIM == nFormat ) && mpImageMap )
575 : {
576 : // TODO/MBA: do we need a BaseURL here?!
577 0 : bRet = SetImageMap( *mpImageMap, rFlavor );
578 : }
579 0 : else if( ( FORMAT_FILE == nFormat ) && mpURL )
580 : {
581 0 : bRet = SetString( mpURL->GetMainURL( INetURLObject::NO_DECODE ), rFlavor );
582 : }
583 0 : else if( ( SOT_FORMATSTR_ID_SVXB == nFormat ) && mpGraphicObject )
584 : {
585 0 : bRet = SetGraphic( mpGraphicObject->GetGraphic(), rFlavor );
586 : }
587 0 : else if( ( FORMAT_GDIMETAFILE == nFormat ) && mpGraphicObject )
588 : {
589 0 : bRet = SetGDIMetaFile( mpGraphicObject->GetGraphic().GetGDIMetaFile(), rFlavor );
590 : }
591 0 : else if( ( FORMAT_BITMAP == nFormat ) && mpGraphicObject )
592 : {
593 0 : bRet = SetBitmapEx( mpGraphicObject->GetGraphic().GetBitmapEx(), rFlavor );
594 : }
595 :
596 0 : return bRet;
597 : }
598 :
599 : // ------------------------------------------------------------------------
600 :
601 0 : sal_Bool GalleryTransferable::WriteObject( SotStorageStreamRef& rxOStm, void* pUserObject,
602 : sal_uInt32, const datatransfer::DataFlavor& )
603 : {
604 0 : sal_Bool bRet = sal_False;
605 :
606 0 : if( pUserObject )
607 : {
608 0 : *rxOStm << *static_cast< SotStorageStream* >( pUserObject );
609 0 : bRet = ( rxOStm->GetError() == ERRCODE_NONE );
610 : }
611 :
612 0 : return bRet;
613 : }
614 :
615 : // ------------------------------------------------------------------------
616 :
617 0 : void GalleryTransferable::DragFinished( sal_Int8 nDropAction )
618 : {
619 0 : mpTheme->SetDragging( sal_False );
620 0 : mpTheme->SetDragPos( 0 );
621 0 : if ( nDropAction )
622 : {
623 0 : Window *pFocusWindow = Application::GetFocusWindow();
624 0 : if ( pFocusWindow )
625 0 : pFocusWindow->GrabFocusToDocument();
626 : }
627 0 : }
628 :
629 : // ------------------------------------------------------------------------
630 :
631 0 : void GalleryTransferable::ObjectReleased()
632 : {
633 0 : mxModelStream.Clear();
634 0 : delete mpGraphicObject, mpGraphicObject = NULL;
635 0 : delete mpImageMap, mpImageMap = NULL;
636 0 : delete mpURL, mpURL = NULL;
637 0 : }
638 :
639 : // ------------------------------------------------------------------------
640 :
641 0 : void GalleryTransferable::CopyToClipboard( Window* pWindow )
642 : {
643 0 : TransferableHelper::CopyToClipboard( pWindow );
644 0 : }
645 :
646 : // ------------------------------------------------------------------------
647 :
648 0 : void GalleryTransferable::StartDrag( Window* pWindow, sal_Int8 nDragSourceActions,
649 : sal_Int32 nDragPointer, sal_Int32 nDragImage )
650 : {
651 0 : INetURLObject aURL;
652 :
653 0 : if( mpTheme->GetURL( mnObjectPos, aURL ) && ( aURL.GetProtocol() != INET_PROT_NOT_VALID ) )
654 : {
655 0 : mpTheme->SetDragging( sal_True );
656 0 : mpTheme->SetDragPos( mnObjectPos );
657 0 : TransferableHelper::StartDrag( pWindow, nDragSourceActions, nDragPointer, nDragImage );
658 0 : }
659 258 : }
660 :
661 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|