LibreOffice Module svx (master)  1
galtheme.cxx
Go to the documentation of this file.
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 #include <config_features.h>
21 
22 #include <sal/config.h>
23 
24 #include <algorithm>
25 
26 #include <osl/file.hxx>
27 #include <osl/thread.hxx>
28 #include <tools/urlobj.hxx>
29 #include <tools/vcompat.hxx>
30 #include <tools/datetime.hxx>
31 #include <sot/storage.hxx>
32 #include <sot/formats.hxx>
33 #include <sot/filelist.hxx>
34 #include <vcl/virdev.hxx>
35 #include <avmedia/mediawindow.hxx>
36 #include <svx/svdograf.hxx>
37 #include <svx/fmmodel.hxx>
38 #include <svx/fmview.hxx>
39 #include <svx/galmisc.hxx>
40 #include <svx/galtheme.hxx>
41 #include <svx/svdpage.hxx>
44 #include <galobj.hxx>
45 #include <svx/gallery1.hxx>
46 #include "gallerydrawmodel.hxx"
47 #include <memory>
48 
49 using namespace ::com::sun::star;
50 
52  : pParent(pGallery)
53  , pThm(pThemeEntry)
54  , mnThemeLockCount(0)
55  , mnBroadcasterLockCount(0)
56  , nDragPos(0)
57  , bDragging(false)
58  , bAbortActualize(false)
59 {
61 }
62 
64 {
65  if(pThm->IsModified())
66  if(!mpGalleryStorageEngine->implWrite(*this, pThm))
67  ImplSetModified(false);
68 
69  for (auto & pEntry : maGalleryObjectCollection.getObjectList())
70  {
72  pEntry.reset();
73  }
75  mpGalleryStorageEngine->clearSotStorage();
76 }
77 
78 void GalleryTheme::SetDestDir(const OUString& rDestDir, bool bRelative)
79 {
80  mpGalleryStorageEngine->setDestDir(rDestDir, bRelative);
81 }
82 
83 void GalleryTheme::ImplBroadcast(sal_uInt32 nUpdatePos)
84 {
85  if( !IsBroadcasterLocked() )
86  {
87  if( GetObjectCount() && ( nUpdatePos >= GetObjectCount() ) )
88  nUpdatePos = GetObjectCount() - 1;
89 
90  Broadcast( GalleryHint( GalleryHintType::THEME_UPDATEVIEW, GetName(), reinterpret_cast<void*>(nUpdatePos) ) );
91  }
92 }
93 
95 {
96  DBG_ASSERT( mnThemeLockCount, "Theme is not locked" );
97 
98  bool bRet = false;
99 
100  if( mnThemeLockCount )
101  {
103  bRet = true;
104  }
105 
106  return bRet;
107 }
108 
110 {
111  DBG_ASSERT( mnBroadcasterLockCount, "Broadcaster is not locked" );
112 
114  ImplBroadcast( 0 );
115 }
116 
117 bool GalleryTheme::InsertObject(const SgaObject& rObj, sal_uInt32 nInsertPos)
118 {
119  if (!rObj.IsValid())
120  return false;
121 
122  GalleryObject* pFoundEntry = nullptr;
123  sal_uInt32 iFoundPos = 0;
124  for (sal_uInt32 n = maGalleryObjectCollection.size(); iFoundPos < n; ++iFoundPos)
125  {
126  if (maGalleryObjectCollection.get(iFoundPos)->getURL() == rObj.GetURL())
127  {
128  pFoundEntry = maGalleryObjectCollection.get(iFoundPos).get();
129  break;
130  }
131  }
132 
133  mpGalleryStorageEngine->insertObject(rObj, pFoundEntry, nInsertPos);
134 
135  ImplSetModified(true);
136  ImplBroadcast(pFoundEntry? iFoundPos: nInsertPos);
137 
138  return true;
139 }
140 
141 std::unique_ptr<SgaObject> GalleryTheme::AcquireObject(sal_uInt32 nPos)
142 {
143  return mpGalleryStorageEngine->implReadSgaObject(maGalleryObjectCollection.getForPosition(nPos));
144 }
145 
146 void GalleryTheme::GetPreviewBitmapExAndStrings(sal_uInt32 nPos, BitmapEx& rBitmapEx, Size& rSize, OUString& rTitle, OUString& rPath)
147 {
148  const GalleryObject* pGalleryObject = maGalleryObjectCollection.get(nPos).get();
149 
150  rBitmapEx = pGalleryObject->maPreviewBitmapEx;
151  rSize = pGalleryObject->maPreparedSize;
152  rTitle = pGalleryObject->maTitle;
153  rPath = pGalleryObject->maPath;
154 }
155 
156 void GalleryTheme::SetPreviewBitmapExAndStrings(sal_uInt32 nPos, const BitmapEx& rBitmapEx, const Size& rSize, const OUString& rTitle, const OUString& rPath)
157 {
158  GalleryObject* pGalleryObject = maGalleryObjectCollection.get(nPos).get();
159 
160  pGalleryObject->maPreviewBitmapEx = rBitmapEx;
161  pGalleryObject->maPreparedSize = rSize;
162  pGalleryObject->maTitle = rTitle;
163  pGalleryObject->maPath = rPath;
164 }
165 
166 void GalleryTheme::RemoveObject(sal_uInt32 nPos)
167 {
168  auto it = maGalleryObjectCollection.getObjectList().begin() + nPos;
169  std::unique_ptr<GalleryObject> pEntry = std::move(*it);
171 
172  mpGalleryStorageEngine->removeObject(pEntry);
173 
175  pEntry.reset();
176 
177  ImplSetModified( true );
178  ImplBroadcast( nPos );
179 }
180 
181 bool GalleryTheme::ChangeObjectPos(sal_uInt32 nOldPos, sal_uInt32 nNewPos)
182 {
183  if (nOldPos == nNewPos || nOldPos >= maGalleryObjectCollection.size())
184  return false;
185 
186  std::unique_ptr<GalleryObject> pEntry = std::move(maGalleryObjectCollection.get(nOldPos));
187 
188  maGalleryObjectCollection.getObjectList().insert(maGalleryObjectCollection.getObjectList().begin() + nNewPos, std::move(pEntry));
189 
190  if (nNewPos < nOldPos)
191  nOldPos++;
192 
193  auto it = maGalleryObjectCollection.getObjectList().begin() + nOldPos;
195 
196  ImplSetModified(true);
197  ImplBroadcast((nNewPos < nOldPos)? nNewPos: (nNewPos - 1));
198 
199  return true;
200 }
201 
203 {
204  if( IsReadOnly() )
205  return;
206 
207  Graphic aGraphic;
208  OUString aFormat;
209  const sal_uInt32 nCount = maGalleryObjectCollection.size();
210 
211  LockBroadcaster();
212  bAbortActualize = false;
213 
214  // reset delete flag
215  for (sal_uInt32 i = 0; i < nCount; i++)
216  maGalleryObjectCollection.get(i)->mbDelete = false;
217 
218  for (sal_uInt32 i = 0; ( i < nCount ) && !bAbortActualize; i++)
219  {
220  if( pProgress )
221  pProgress->Update( i, nCount - 1 );
222 
223  GalleryObject* pEntry = maGalleryObjectCollection.get(i).get();
224 
225  const INetURLObject aURL( pEntry->getURL());
226 
227  rActualizeLink.Call( aURL );
228 
229  // SvDraw objects will be updated later
230  if( pEntry->eObjKind != SgaObjKind::SvDraw )
231  {
232  // Still a function should be implemented,
233  // which assigns files to the relevant entry.
234  // insert graphics as graphic objects into the gallery
235  if( pEntry->eObjKind == SgaObjKind::Sound )
236  {
237  SgaObjectSound aObjSound( aURL );
238  if( !InsertObject( aObjSound ) )
239  pEntry->mbDelete = true;
240  }
241  else
242  {
243  aGraphic.Clear();
244 
245  if ( GalleryGraphicImport( aURL, aGraphic, aFormat ) != GalleryGraphicImportRet::IMPORT_NONE )
246  {
247  std::unique_ptr<SgaObject> pNewObj;
248 
249  if ( SgaObjKind::Inet == pEntry->eObjKind )
250  pNewObj.reset(new SgaObjectINet( aGraphic, aURL ));
251  else if ( aGraphic.IsAnimated() )
252  pNewObj.reset(new SgaObjectAnim( aGraphic, aURL ));
253  else
254  pNewObj.reset(new SgaObjectBmp( aGraphic, aURL ));
255 
256  if( !InsertObject( *pNewObj ) )
257  pEntry->mbDelete = true;
258  }
259  else
260  pEntry->mbDelete = true; // set delete flag
261  }
262  }
263  else
264  {
265  //update SvDraw object
266  if ( mpGalleryStorageEngine->GetSvDrawStorage().is() )
267  {
268  SgaObjectSvDraw aNewObj = mpGalleryStorageEngine->updateSvDrawObject(pEntry);
269  if (aNewObj.IsValid() && !InsertObject(aNewObj))
270  pEntry->mbDelete = true;
271  }
272  }
273  }
274 
275  // remove all entries with set flag
276  for ( auto it = maGalleryObjectCollection.getObjectList().begin(); it != maGalleryObjectCollection.getObjectList().end(); /* increment is in the body of loop */)
277  {
278  if( (*it)->mbDelete )
279  {
281  it = maGalleryObjectCollection.getObjectList().erase( it );
282  }
283  else
284  ++it;
285  }
286 
287  // update theme
288  mpGalleryStorageEngine->updateTheme();
289  ImplSetModified( true );
290  if (pThm->IsModified())
291  if (!mpGalleryStorageEngine->implWrite(*this, pThm))
292  ImplSetModified(false);
294 }
295 
296 bool GalleryTheme::GetThumb(sal_uInt32 nPos, BitmapEx& rBmp)
297 {
298  std::unique_ptr<SgaObject> pObj = AcquireObject( nPos );
299  bool bRet = false;
300 
301  if( pObj )
302  {
303  rBmp = pObj->GetThumbBmp();
304  bRet = true;
305  }
306 
307  return bRet;
308 }
309 
310 bool GalleryTheme::GetGraphic(sal_uInt32 nPos, Graphic& rGraphic)
311 {
313  bool bRet = false;
314 
315  if( pObject )
316  {
317  const INetURLObject aURL( ImplGetURL( pObject ) );
318 
319  switch( pObject->eObjKind )
320  {
321  case SgaObjKind::Bitmap:
323  case SgaObjKind::Inet:
324  {
325  OUString aFilterDummy;
326  bRet = ( GalleryGraphicImport( aURL, rGraphic, aFilterDummy ) != GalleryGraphicImportRet::IMPORT_NONE );
327  }
328  break;
329 
330  case SgaObjKind::SvDraw:
331  {
332  SvxGalleryDrawModel aModel;
333 
334  if( aModel.GetModel() )
335  {
336  if( GetModel( nPos, *aModel.GetModel() ) )
337  {
338  ImageMap aIMap;
339 
340  if( CreateIMapGraphic( *aModel.GetModel(), rGraphic, aIMap ) )
341  bRet = true;
342  else
343  {
345  pVDev->SetMapMode( MapMode( MapUnit::Map100thMM ) );
346  FmFormView aView(*aModel.GetModel(), pVDev);
347 
348  aView.hideMarkHandles();
349  aView.ShowSdrPage(aView.GetModel()->GetPage(0));
350  aView.MarkAll();
351  rGraphic = aView.GetAllMarkedGraphic();
352  bRet = true;
353  }
354  }
355  }
356  }
357  break;
358 
359  case SgaObjKind::Sound:
360  {
361  std::unique_ptr<SgaObject> pObj = AcquireObject( nPos );
362 
363  if( pObj )
364  {
365  rGraphic = pObj->GetThumbBmp();
366  //Bitmap aBmp( pObj->GetThumbBmp() );
367  //aBmp.Replace( COL_LIGHTMAGENTA, COL_WHITE );
368  //rGraphic = aBmp;
369  bRet = true;
370  }
371  }
372  break;
373 
374  default:
375  break;
376  }
377  }
378 
379  return bRet;
380 }
381 
382 bool GalleryTheme::InsertGraphic(const Graphic& rGraphic, sal_uInt32 nInsertPos)
383 {
384  bool bRet = false;
385 
386  if( rGraphic.GetType() != GraphicType::NONE )
387  {
388  ConvertDataFormat nExportFormat = ConvertDataFormat::Unknown;
389  const GfxLink aGfxLink( rGraphic.GetGfxLink() );
390 
391  if( aGfxLink.GetDataSize() )
392  {
393  switch( aGfxLink.GetType() )
394  {
395  case GfxLinkType::EpsBuffer: nExportFormat = ConvertDataFormat::SVM; break;
396  case GfxLinkType::NativeGif: nExportFormat = ConvertDataFormat::GIF; break;
397 
398  // #i15508# added BMP type
399  // could not find/trigger a call to this, but should do no harm
400  case GfxLinkType::NativeBmp: nExportFormat = ConvertDataFormat::BMP; break;
401 
402  case GfxLinkType::NativeJpg: nExportFormat = ConvertDataFormat::JPG; break;
403  case GfxLinkType::NativePng: nExportFormat = ConvertDataFormat::PNG; break;
404  case GfxLinkType::NativeTif: nExportFormat = ConvertDataFormat::TIF; break;
405  case GfxLinkType::NativeWmf: nExportFormat = ConvertDataFormat::WMF; break;
406  case GfxLinkType::NativeMet: nExportFormat = ConvertDataFormat::MET; break;
407  case GfxLinkType::NativePct: nExportFormat = ConvertDataFormat::PCT; break;
408  case GfxLinkType::NativeSvg: nExportFormat = ConvertDataFormat::SVG; break;
409  default:
410  break;
411  }
412  }
413  else
414  {
415  if( rGraphic.GetType() == GraphicType::Bitmap )
416  {
417  if( rGraphic.IsAnimated() )
418  nExportFormat = ConvertDataFormat::GIF;
419  else
420  nExportFormat = ConvertDataFormat::PNG;
421  }
422  else
423  nExportFormat = ConvertDataFormat::SVM;
424  }
425 
426  const SgaObjectBmp aObjBmp = mpGalleryStorageEngine->insertGraphic(rGraphic, aGfxLink, nExportFormat, GetParent()->GetUserURL());
427 
428  if (aObjBmp.IsValid())
429  bRet = InsertObject(aObjBmp, nInsertPos);
430  }
431 
432  return bRet;
433 }
434 
435 bool GalleryTheme::GetModel(sal_uInt32 nPos, SdrModel& rModel)
436 {
438  bool bRet = false;
439 
440  if( pObject && ( SgaObjKind::SvDraw == pObject->eObjKind ) )
441  {
442  bRet = mpGalleryStorageEngine->readModel(pObject, rModel);
443  }
444 
445  return bRet;
446 }
447 
448 bool GalleryTheme::InsertModel(const FmFormModel& rModel, sal_uInt32 nInsertPos)
449 {
450  bool bRet = false;
451  SgaObjectSvDraw aObjSvDraw = mpGalleryStorageEngine->insertModel(rModel, GetParent()->GetUserURL());
452  if(aObjSvDraw.IsValid())
453  bRet = InsertObject( aObjSvDraw, nInsertPos );
454  return bRet;
455 }
456 
457 bool GalleryTheme::GetModelStream(sal_uInt32 nPos, tools::SvRef<SotTempStream> const & rxModelStream)
458 {
460  bool bRet = false;
461 
462  if( pObject && ( SgaObjKind::SvDraw == pObject->eObjKind ) )
463  {
464  bRet = mpGalleryStorageEngine->readModelStream(pObject, rxModelStream);
465  }
466 
467  return bRet;
468 }
469 
470 bool GalleryTheme::InsertModelStream(const tools::SvRef<SotTempStream>& rxModelStream, sal_uInt32 nInsertPos)
471 {
472  bool bRet = false;
473 
474  const SgaObjectSvDraw aObjSvDraw = mpGalleryStorageEngine->insertModelStream(rxModelStream, GetParent()->GetUserURL());
475  if(aObjSvDraw.IsValid())
476  bRet = InsertObject( aObjSvDraw, nInsertPos );
477 
478  return bRet;
479 }
480 
481 bool GalleryTheme::GetURL(sal_uInt32 nPos, INetURLObject& rURL)
482 {
484  bool bRet = false;
485 
486  if( pObject )
487  {
488  rURL = ImplGetURL( pObject );
489  bRet = true;
490  }
491 
492  return bRet;
493 }
494 
495 bool GalleryTheme::InsertURL(const INetURLObject& rURL, sal_uInt32 nInsertPos)
496 {
497  Graphic aGraphic;
498  OUString aFormat;
499  std::unique_ptr<SgaObject> pNewObj;
500  const GalleryGraphicImportRet nImportRet = GalleryGraphicImport( rURL, aGraphic, aFormat );
501  bool bRet = false;
502 
503  if( nImportRet != GalleryGraphicImportRet::IMPORT_NONE )
504  {
505  if ( aGraphic.IsAnimated() )
506  pNewObj.reset(new SgaObjectAnim( aGraphic, rURL ));
507  else
508  pNewObj.reset(new SgaObjectBmp( aGraphic, rURL ));
509  }
510 #if HAVE_FEATURE_AVMEDIA
512  pNewObj.reset(new SgaObjectSound( rURL ));
513 #endif
514  if( pNewObj && InsertObject( *pNewObj, nInsertPos ) )
515  bRet = true;
516 
517  return bRet;
518 }
519 
520 bool GalleryTheme::InsertFileOrDirURL(const INetURLObject& rFileOrDirURL, sal_uInt32 nInsertPos)
521 {
522  bool bRet = false;
523  std::vector< INetURLObject > aURLVector;
524  GalleryBinaryEngine::insertFileOrDirURL(rFileOrDirURL, aURLVector);
525 
526  for( const auto& rURL : aURLVector )
527  bRet = bRet || InsertURL( rURL, nInsertPos );
528 
529  return bRet;
530 }
531 
532 bool GalleryTheme::InsertTransferable(const uno::Reference< datatransfer::XTransferable >& rxTransferable, sal_uInt32 nInsertPos)
533 {
534  bool bRet = false;
535 
536  if( rxTransferable.is() )
537  {
538  TransferableDataHelper aDataHelper( rxTransferable );
539  std::unique_ptr<Graphic> pGraphic;
540 
541  if( aDataHelper.HasFormat( SotClipboardFormatId::DRAWING ) )
542  {
543  tools::SvRef<SotTempStream> xModelStm;
544 
545  if( aDataHelper.GetSotStorageStream( SotClipboardFormatId::DRAWING, xModelStm ) )
546  bRet = InsertModelStream( xModelStm, nInsertPos );
547  }
548  else if( aDataHelper.HasFormat( SotClipboardFormatId::FILE_LIST ) ||
549  aDataHelper.HasFormat( SotClipboardFormatId::SIMPLE_FILE ) )
550  {
551  FileList aFileList;
552 
553  if( aDataHelper.HasFormat( SotClipboardFormatId::FILE_LIST ) )
554  aDataHelper.GetFileList( SotClipboardFormatId::FILE_LIST, aFileList );
555  else
556  {
557  OUString aFile;
558  if (aDataHelper.GetString(SotClipboardFormatId::SIMPLE_FILE, aFile) && !aFile.isEmpty())
559  aFileList.AppendFile( aFile );
560  }
561 
562  for( sal_uInt32 i = 0, nCount = aFileList.Count(); i < nCount; ++i )
563  {
564  const OUString aFile( aFileList.GetFile( i ) );
565  INetURLObject aURL( aFile );
566 
567  if( aURL.GetProtocol() == INetProtocol::NotValid )
568  {
569  OUString aLocalURL;
570 
571  if( osl::FileBase::getFileURLFromSystemPath( aFile, aLocalURL ) == osl::FileBase::E_None )
572  aURL = INetURLObject( aLocalURL );
573  }
574 
575  if( aURL.GetProtocol() != INetProtocol::NotValid )
576  bRet = InsertFileOrDirURL( aURL, nInsertPos );
577  }
578  }
579  else
580  {
581  Graphic aGraphic;
582  SotClipboardFormatId nFormat = SotClipboardFormatId::NONE;
583 
584  if( aDataHelper.HasFormat( SotClipboardFormatId::SVXB ) )
585  nFormat = SotClipboardFormatId::SVXB;
586  else if( aDataHelper.HasFormat( SotClipboardFormatId::GDIMETAFILE ) )
587  nFormat = SotClipboardFormatId::GDIMETAFILE;
588  else if( aDataHelper.HasFormat( SotClipboardFormatId::BITMAP ) )
589  nFormat = SotClipboardFormatId::BITMAP;
590 
591  if( nFormat != SotClipboardFormatId::NONE && aDataHelper.GetGraphic( nFormat, aGraphic ) )
592  pGraphic.reset(new Graphic( aGraphic ));
593  }
594 
595  if( pGraphic )
596  {
597  bRet = false;
598 
599  if( aDataHelper.HasFormat( SotClipboardFormatId::SVIM ) )
600  {
601 
602  ImageMap aImageMap;
603 
604  // according to KA we don't need a BaseURL here
605  if( aDataHelper.GetImageMap( SotClipboardFormatId::SVIM, aImageMap ) )
606  {
607  SvxGalleryDrawModel aModel;
608 
609  if( aModel.GetModel() )
610  {
611  SdrPage* pPage = aModel.GetModel()->GetPage(0);
612  SdrGrafObj* pGrafObj = new SdrGrafObj(*aModel.GetModel(), *pGraphic );
613 
614  pGrafObj->AppendUserData( std::unique_ptr<SdrObjUserData>(new SgaIMapInfo( aImageMap )) );
615  pPage->InsertObject( pGrafObj );
616  bRet = InsertModel( *aModel.GetModel(), nInsertPos );
617  }
618  }
619  }
620 
621  if( !bRet )
622  bRet = InsertGraphic( *pGraphic, nInsertPos );
623  }
624  }
625 
626  return bRet;
627 }
628 
629 void GalleryTheme::CopyToClipboard(sal_uInt32 nPos)
630 {
631  rtl::Reference<GalleryTransferable> pTransferable = new GalleryTransferable( this, nPos, false );
632  pTransferable->CopyToClipboard(GetSystemClipboard());
633 }
634 
636 {
637  return mpGalleryStorageEngine->getModificationDate();
638 }
639 
641 {
642  sal_uInt32 nCount;
643  sal_uInt16 nVersion;
644 
645  rIStm.ReadUInt16( nVersion );
647  rIStm.ReadUInt32( nCount );
648 
649  if( nVersion >= 0x0004 )
650  {
651  sal_uInt16 nTmp16;
652  rIStm.ReadUInt16( nTmp16 );
653  }
654 
655  if( nCount <= ( 1 << 14 ) )
656  {
657  INetURLObject aRelURL1( GetParent()->GetRelativeURL() );
658  INetURLObject aRelURL2( GetParent()->GetUserURL() );
659  sal_uInt32 nId1, nId2;
660  bool bRel;
661 
663  {
664  GalleryObject* pObj = i.get();
666  i.reset();
667  }
669 
670  for( sal_uInt32 i = 0; i < nCount; i++ )
671  {
672  std::unique_ptr<GalleryObject> pObj(new GalleryObject);
673 
674  OUString aFileName;
675  sal_uInt16 nTemp;
676 
677  rIStm.ReadCharAsBool( bRel );
678  OString aTempFileName = read_uInt16_lenPrefixed_uInt8s_ToOString(rIStm);
679  rIStm.ReadUInt32( pObj->nOffset );
680  rIStm.ReadUInt16( nTemp ); pObj->eObjKind = static_cast<SgaObjKind>(nTemp);
681 
682  aFileName = OStringToOUString(aTempFileName, osl_getThreadTextEncoding());
683 
684  pObj->m_pGalleryObjectStorage.reset();
685  pObj->m_pGalleryObjectStorage = std::make_unique<GalleryObjectBinaryStorage>();
686 
687  if( bRel )
688  {
689  aFileName = aFileName.replaceAll( "\\", "/" );
690  OUString aPath = aRelURL1.GetMainURL( INetURLObject::DecodeMechanism::NONE );
691 
692  if( aFileName[ 0 ] != '/' )
693  aPath += "/";
694 
695  aPath += aFileName;
696 
697  pObj->m_pGalleryObjectStorage->setURL(INetURLObject(aPath));
698 
699  if (!FileExists(pObj->getURL()))
700  {
702 
703  if( aFileName[0] != '/' )
704  aPath += "/";
705 
706  aPath += aFileName;
707 
708  // assign this URL, even in the case it is not valid (#94482)
709  pObj->m_pGalleryObjectStorage->setURL(INetURLObject(aPath));
710  }
711  }
712  else
713  {
714  if( SgaObjKind::SvDraw == pObj->eObjKind )
715  {
716  OUString aDummyURL = "gallery/svdraw/" + aFileName;
717  pObj->m_pGalleryObjectStorage->setURL(INetURLObject(aDummyURL, INetProtocol::PrivSoffice));
718  }
719  else
720  {
721  OUString aLocalURL;
722 
723  pObj->m_pGalleryObjectStorage->setURL(INetURLObject(aFileName));
724 
725  if( ( pObj->getURL().GetProtocol() == INetProtocol::NotValid ) &&
726  osl::FileBase::getFileURLFromSystemPath( aFileName, aLocalURL ) == osl::FileBase::E_None )
727  {
728  pObj->m_pGalleryObjectStorage->setURL(INetURLObject(aLocalURL));
729  }
730  }
731  }
732  maGalleryObjectCollection.getObjectList().push_back( std::move(pObj) );
733  }
734 
735  rIStm.ReadUInt32( nId1 ).ReadUInt32( nId2 );
736 
737  // In newer versions a 512 byte reserve buffer is located at the end,
738  // the data is located at the beginning of this buffer and are clamped
739  // by a VersionCompatRead.
740  if( !rIStm.eof() &&
741  nId1 == COMPAT_FORMAT( 'G', 'A', 'L', 'R' ) &&
742  nId2 == COMPAT_FORMAT( 'E', 'S', 'R', 'V' ) )
743  {
744  VersionCompatRead aCompat(rIStm);
745  sal_uInt32 nTemp32;
746  bool bThemeNameFromResource = false;
747 
748  rIStm.ReadUInt32( nTemp32 );
749 
750  if( aCompat.GetVersion() >= 2 )
751  {
752  rIStm.ReadCharAsBool( bThemeNameFromResource );
753  }
754 
755  SetId( nTemp32, bThemeNameFromResource );
756  }
757  }
758  else
759  rIStm.SetError( SVSTREAM_READ_ERROR );
760 
761  ImplSetModified( false );
762 
763  return rIStm;
764 }
765 
766 void GalleryTheme::ImplSetModified( bool bModified )
767 {
768  pThm->SetModified(bModified);
769 }
770 
771 sal_uInt32 GalleryTheme::GetId() const { return pThm->GetId(); }
772 void GalleryTheme::SetId( sal_uInt32 nNewId, bool bResetThemeName ) { pThm->SetId( nNewId, bResetThemeName ); }
773 bool GalleryTheme::IsReadOnly() const { return pThm->IsReadOnly(); }
774 bool GalleryTheme::IsDefault() const { return pThm->IsDefault(); }
775 
776 const OUString& GalleryTheme::GetName() const { return pThm->GetThemeName(); }
777 
778 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool GetGraphic(SotClipboardFormatId nFormat, Graphic &rGraphic)
URL aURL
std::unique_ptr< GalleryBinaryEngine > mpGalleryStorageEngine
Definition: galtheme.hxx:59
bool InsertObject(const SgaObject &rObj, sal_uInt32 nPos=SAL_MAX_UINT32)
Definition: galtheme.cxx:117
void Update(sal_Int32 nVal, sal_Int32 nMaxVal)
Definition: galmisc.cxx:352
bool GetSotStorageStream(SotClipboardFormatId nFormat, tools::SvRef< SotTempStream > &rStreamRef)
SAL_DLLPRIVATE bool InsertModelStream(const tools::SvRef< SotTempStream > &rModelStream, sal_uInt32 nInsertPos)
Definition: galtheme.cxx:470
bool IsModified() const
Definition: gallery1.hxx:71
bool IsDefault() const
Definition: galtheme.cxx:774
sal_uInt32 GetId() const
Definition: galtheme.cxx:771
bool InsertGraphic(const Graphic &rGraphic, sal_uInt32 nInsertPos)
Definition: galtheme.cxx:382
bool CreateIMapGraphic(const FmFormModel &rModel, Graphic &rGraphic, ImageMap &rImageMap)
Definition: galmisc.cxx:120
SvStream & ReadUInt16(sal_uInt16 &rUInt16)
sal_uInt32 mnBroadcasterLockCount
Definition: galtheme.hxx:64
SAL_DLLPRIVATE Gallery * GetParent() const
Definition: galtheme.hxx:117
sal_uInt32 mnThemeLockCount
Definition: galtheme.hxx:63
std::vector< std::unique_ptr< GalleryObject > > & getObjectList()
#define SVSTREAM_READ_ERROR
SvStream & ReadCharAsBool(bool &rBool)
sal_Int64 n
void RemoveObject(sal_uInt32 nPos)
Definition: galtheme.cxx:166
const INetURLObject & getURL() const
css::uno::Reference< css::datatransfer::clipboard::XClipboard > VCL_DLLPUBLIC GetSystemClipboard()
SAL_DLLPRIVATE void SetPreviewBitmapExAndStrings(sal_uInt32 nPos, const BitmapEx &rBitmapEx, const Size &rSize, const OUString &rTitle, const OUString &rPath)
Definition: galtheme.cxx:156
FmFormModel * GetModel() const
bool IsReadOnly() const
Definition: gallery1.hxx:66
virtual void InsertObject(SdrObject *pObj, size_t nPos=SAL_MAX_SIZE)
Definition: svdpage.cxx:338
EmbeddedObjectRef * pObject
bool HasFormat(SotClipboardFormatId nFormat) const
void Clear()
OString read_uInt16_lenPrefixed_uInt8s_ToOString(SvStream &rStrm)
SAL_DLLPRIVATE bool GetURL(sal_uInt32 nPos, INetURLObject &rURL)
Definition: galtheme.cxx:481
bool eof() const
INetURLObject ImplGetURL(const GalleryObject *pObject)
Definition: galmisc.cxx:556
int nCount
GalleryThemeEntry * pThm
Definition: galtheme.hxx:62
std::unique_ptr< GalleryObject > & get(sal_uInt32 nPos)
SAL_DLLPRIVATE SvStream & ReadData(SvStream &rIn)
Definition: galtheme.cxx:640
SotClipboardFormatId
virtual SAL_DLLPRIVATE ~GalleryTheme() override
Definition: galtheme.cxx:63
SAL_DLLPRIVATE void LockBroadcaster()
Definition: galtheme.hxx:104
bool IsAnimated() const
SvStream & ReadUInt32(sal_uInt32 &rUInt32)
SgaObjKind
Definition: galmisc.hxx:55
sal_uInt32 GetId() const
Definition: gallery1.hxx:77
GalleryTheme(GalleryTheme const &)=delete
SAL_DLLPRIVATE bool InsertFileOrDirURL(const INetURLObject &rFileOrDirURL, sal_uInt32 nInsertPos)
Definition: galtheme.cxx:520
#define DBG_ASSERT(sCon, aError)
int i
GalleryGraphicImportRet GalleryGraphicImport(const INetURLObject &rURL, Graphic &rGraphic, OUString &rFilterName)
Definition: galmisc.cxx:51
bool InsertURL(const INetURLObject &rURL, sal_uInt32 nInsertPos=SAL_MAX_UINT32)
Definition: galtheme.cxx:495
GraphicType GetType() const
static void insertFileOrDirURL(const INetURLObject &rFileOrDirURL, std::vector< INetURLObject > &rURLVector)
void SetModified(bool bSet)
Definition: gallery1.hxx:72
sal_uInt32 COMPAT_FORMAT(char char1, char char2, char char3, char char4)
void Actualize(const Link< const INetURLObject &, void > &rActualizeLink, GalleryProgress *pProgress=nullptr)
Definition: galtheme.cxx:202
bool GetString(SotClipboardFormatId nFormat, OUString &rStr)
ConvertDataFormat
void hideMarkHandles()
Definition: svdmrkv.cxx:570
SAL_DLLPRIVATE void GetPreviewBitmapExAndStrings(sal_uInt32 nPos, BitmapEx &rBitmapEx, Size &rSize, OUString &rTitle, OUString &rPath)
Definition: galtheme.cxx:146
bool ChangeObjectPos(sal_uInt32 nOldPos, sal_uInt32 nNewPos)
Definition: galtheme.cxx:181
const SdrPage * GetPage(sal_uInt16 nPgNum) const
Definition: svdmodel.cxx:1840
void SetDestDir(const OUString &rDestDir, bool bRelative)
Definition: galtheme.cxx:78
OUString GetFile(size_t nIndex) const
void SetError(ErrCode nErrorCode)
SAL_DLLPRIVATE bool InsertTransferable(const css::uno::Reference< css::datatransfer::XTransferable > &rxTransferable, sal_uInt32 nInsertPos)
Definition: galtheme.cxx:532
SAL_DLLPRIVATE sal_uInt32 GetObjectCount() const
Definition: galtheme.hxx:82
GalleryGraphicImportRet
Definition: galmisc.hxx:69
bool GetGraphic(sal_uInt32 nPos, Graphic &rGraphic)
Definition: galtheme.cxx:310
This class represents an embedded or linked bitmap graphic object.
Definition: svdograf.hxx:77
sal_Int16 nVersion
GfxLink GetGfxLink() const
size_t Count() const
void AppendFile(const OUString &rStr)
SAL_DLLPRIVATE bool IsBroadcasterLocked() const
Definition: galtheme.hxx:106
static bool isMediaURL(const OUString &rURL, const OUString &rReferer, bool bDeep=false, Size *pPreferredSizePixel=nullptr)
void UnlockBroadcaster()
Definition: galtheme.cxx:109
SAL_DLLPRIVATE void ImplBroadcast(sal_uInt32 nUpdatePos)
Definition: galtheme.cxx:83
void AppendUserData(std::unique_ptr< SdrObjUserData > pData)
Definition: svdobj.cxx:2684
bool GetImageMap(SotClipboardFormatId nFormat, ImageMap &rIMap)
GalleryObjectCollection maGalleryObjectCollection
Definition: galtheme.hxx:60
bool IsDefault() const
Definition: gallery1.cxx:718
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
DateTime getModificationDate() const
Definition: galtheme.cxx:635
bool GetModel(sal_uInt32 nPos, SdrModel &rModel)
Definition: galtheme.cxx:435
SAL_DLLPRIVATE void CopyToClipboard(sal_uInt32 nPos)
Definition: galtheme.cxx:629
static bool FileExists(const INetURLObject &rURL, const OUString &rExt)
void Broadcast(const SfxHint &rHint)
std::unique_ptr< GalleryBinaryEngine > createGalleryStorageEngine(GalleryObjectCollection &mrGalleryObjectCollection)
Definition: gallery1.cxx:175
SAL_DLLPRIVATE bool GetModelStream(sal_uInt32 nPos, tools::SvRef< SotTempStream > const &rModelStreamRef)
Definition: galtheme.cxx:457
const GalleryObject * getForPosition(sal_uInt32 nPos) const
void SetId(sal_uInt32 nNewId, bool bResetThemeName)
Definition: gallery1.cxx:199
SAL_DLLPRIVATE bool GetThumb(sal_uInt32 nPos, BitmapEx &rBmp)
Definition: galtheme.cxx:296
bool GetFileList(SotClipboardFormatId nFormat, FileList &rFileList)
bool bAbortActualize
Definition: galtheme.hxx:67
SAL_DLLPRIVATE void ImplSetModified(bool bModified)
Definition: galtheme.cxx:766
SAL_DLLPRIVATE void SetId(sal_uInt32 nNewId, bool bResetThemeName)
Definition: galtheme.cxx:772
const OUString & GetName() const
Definition: galtheme.cxx:776
A SdrPage contains exactly one SdrObjList and a description of the physical page dimensions (size / m...
Definition: svdpage.hxx:365
SAL_DLLPRIVATE bool UnlockTheme()
Definition: galtheme.cxx:94
bool IsReadOnly() const
Definition: galtheme.cxx:773
bool InsertModel(const FmFormModel &rModel, sal_uInt32 nInsertPos)
Definition: galtheme.cxx:448
const OUString & GetThemeName() const
Definition: gallery1.hxx:64
std::unique_ptr< SgaObject > AcquireObject(sal_uInt32 nPos)
Definition: galtheme.cxx:141