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