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  case GfxLinkType::NativeWebp: nExportFormat = ConvertDataFormat::WEBP; break;
411  default:
412  break;
413  }
414  }
415  else
416  {
417  if( rGraphic.GetType() == GraphicType::Bitmap )
418  {
419  if( rGraphic.IsAnimated() )
420  nExportFormat = ConvertDataFormat::GIF;
421  else
422  nExportFormat = ConvertDataFormat::PNG;
423  }
424  else
425  nExportFormat = ConvertDataFormat::SVM;
426  }
427 
428  const SgaObjectBmp aObjBmp = mpGalleryStorageEngine->insertGraphic(rGraphic, aGfxLink, nExportFormat, GetParent()->GetUserURL());
429 
430  if (aObjBmp.IsValid())
431  bRet = InsertObject(aObjBmp, nInsertPos);
432  }
433 
434  return bRet;
435 }
436 
437 bool GalleryTheme::GetModel(sal_uInt32 nPos, SdrModel& rModel)
438 {
440  bool bRet = false;
441 
442  if( pObject && ( SgaObjKind::SvDraw == pObject->eObjKind ) )
443  {
444  bRet = mpGalleryStorageEngine->readModel(pObject, rModel);
445  }
446 
447  return bRet;
448 }
449 
450 bool GalleryTheme::InsertModel(const FmFormModel& rModel, sal_uInt32 nInsertPos)
451 {
452  bool bRet = false;
453  SgaObjectSvDraw aObjSvDraw = mpGalleryStorageEngine->insertModel(rModel, GetParent()->GetUserURL());
454  if(aObjSvDraw.IsValid())
455  bRet = InsertObject( aObjSvDraw, nInsertPos );
456  return bRet;
457 }
458 
459 bool GalleryTheme::GetModelStream(sal_uInt32 nPos, tools::SvRef<SotTempStream> const & rxModelStream)
460 {
462  bool bRet = false;
463 
464  if( pObject && ( SgaObjKind::SvDraw == pObject->eObjKind ) )
465  {
466  bRet = mpGalleryStorageEngine->readModelStream(pObject, rxModelStream);
467  }
468 
469  return bRet;
470 }
471 
472 bool GalleryTheme::InsertModelStream(const tools::SvRef<SotTempStream>& rxModelStream, sal_uInt32 nInsertPos)
473 {
474  bool bRet = false;
475 
476  const SgaObjectSvDraw aObjSvDraw = mpGalleryStorageEngine->insertModelStream(rxModelStream, GetParent()->GetUserURL());
477  if(aObjSvDraw.IsValid())
478  bRet = InsertObject( aObjSvDraw, nInsertPos );
479 
480  return bRet;
481 }
482 
483 bool GalleryTheme::GetURL(sal_uInt32 nPos, INetURLObject& rURL)
484 {
486  bool bRet = false;
487 
488  if( pObject )
489  {
490  rURL = ImplGetURL( pObject );
491  bRet = true;
492  }
493 
494  return bRet;
495 }
496 
497 bool GalleryTheme::InsertURL(const INetURLObject& rURL, sal_uInt32 nInsertPos)
498 {
499  Graphic aGraphic;
500  OUString aFormat;
501  std::unique_ptr<SgaObject> pNewObj;
502  const GalleryGraphicImportRet nImportRet = GalleryGraphicImport( rURL, aGraphic, aFormat );
503  bool bRet = false;
504 
505  if( nImportRet != GalleryGraphicImportRet::IMPORT_NONE )
506  {
507  if ( aGraphic.IsAnimated() )
508  pNewObj.reset(new SgaObjectAnim( aGraphic, rURL ));
509  else
510  pNewObj.reset(new SgaObjectBmp( aGraphic, rURL ));
511  }
512 #if HAVE_FEATURE_AVMEDIA
514  pNewObj.reset(new SgaObjectSound( rURL ));
515 #endif
516  if( pNewObj && InsertObject( *pNewObj, nInsertPos ) )
517  bRet = true;
518 
519  return bRet;
520 }
521 
522 bool GalleryTheme::InsertFileOrDirURL(const INetURLObject& rFileOrDirURL, sal_uInt32 nInsertPos)
523 {
524  bool bRet = false;
525  std::vector< INetURLObject > aURLVector;
526  GalleryBinaryEngine::insertFileOrDirURL(rFileOrDirURL, aURLVector);
527 
528  for( const auto& rURL : aURLVector )
529  bRet = bRet || InsertURL( rURL, nInsertPos );
530 
531  return bRet;
532 }
533 
534 bool GalleryTheme::InsertTransferable(const uno::Reference< datatransfer::XTransferable >& rxTransferable, sal_uInt32 nInsertPos)
535 {
536  bool bRet = false;
537 
538  if( rxTransferable.is() )
539  {
540  TransferableDataHelper aDataHelper( rxTransferable );
541  std::unique_ptr<Graphic> pGraphic;
542 
543  if( aDataHelper.HasFormat( SotClipboardFormatId::DRAWING ) )
544  {
545  tools::SvRef<SotTempStream> xModelStm;
546 
547  if( aDataHelper.GetSotStorageStream( SotClipboardFormatId::DRAWING, xModelStm ) )
548  bRet = InsertModelStream( xModelStm, nInsertPos );
549  }
550  else if( aDataHelper.HasFormat( SotClipboardFormatId::FILE_LIST ) ||
551  aDataHelper.HasFormat( SotClipboardFormatId::SIMPLE_FILE ) )
552  {
553  FileList aFileList;
554 
555  if( aDataHelper.HasFormat( SotClipboardFormatId::FILE_LIST ) )
556  aDataHelper.GetFileList( SotClipboardFormatId::FILE_LIST, aFileList );
557  else
558  {
559  OUString aFile;
560  if (aDataHelper.GetString(SotClipboardFormatId::SIMPLE_FILE, aFile) && !aFile.isEmpty())
561  aFileList.AppendFile( aFile );
562  }
563 
564  for( sal_uInt32 i = 0, nCount = aFileList.Count(); i < nCount; ++i )
565  {
566  const OUString aFile( aFileList.GetFile( i ) );
567  INetURLObject aURL( aFile );
568 
569  if( aURL.GetProtocol() == INetProtocol::NotValid )
570  {
571  OUString aLocalURL;
572 
573  if( osl::FileBase::getFileURLFromSystemPath( aFile, aLocalURL ) == osl::FileBase::E_None )
574  aURL = INetURLObject( aLocalURL );
575  }
576 
577  if( aURL.GetProtocol() != INetProtocol::NotValid )
578  bRet = InsertFileOrDirURL( aURL, nInsertPos );
579  }
580  }
581  else
582  {
583  Graphic aGraphic;
584  SotClipboardFormatId nFormat = SotClipboardFormatId::NONE;
585 
586  if( aDataHelper.HasFormat( SotClipboardFormatId::SVXB ) )
587  nFormat = SotClipboardFormatId::SVXB;
588  else if( aDataHelper.HasFormat( SotClipboardFormatId::GDIMETAFILE ) )
589  nFormat = SotClipboardFormatId::GDIMETAFILE;
590  else if( aDataHelper.HasFormat( SotClipboardFormatId::BITMAP ) )
591  nFormat = SotClipboardFormatId::BITMAP;
592 
593  if( nFormat != SotClipboardFormatId::NONE && aDataHelper.GetGraphic( nFormat, aGraphic ) )
594  pGraphic.reset(new Graphic( aGraphic ));
595  }
596 
597  if( pGraphic )
598  {
599  bRet = false;
600 
601  if( aDataHelper.HasFormat( SotClipboardFormatId::SVIM ) )
602  {
603 
604  ImageMap aImageMap;
605 
606  // according to KA we don't need a BaseURL here
607  if( aDataHelper.GetImageMap( SotClipboardFormatId::SVIM, aImageMap ) )
608  {
609  SvxGalleryDrawModel aModel;
610 
611  if( aModel.GetModel() )
612  {
613  SdrPage* pPage = aModel.GetModel()->GetPage(0);
614  SdrGrafObj* pGrafObj = new SdrGrafObj(*aModel.GetModel(), *pGraphic );
615 
616  pGrafObj->AppendUserData( std::unique_ptr<SdrObjUserData>(new SgaIMapInfo( aImageMap )) );
617  pPage->InsertObject( pGrafObj );
618  bRet = InsertModel( *aModel.GetModel(), nInsertPos );
619  }
620  }
621  }
622 
623  if( !bRet )
624  bRet = InsertGraphic( *pGraphic, nInsertPos );
625  }
626  }
627 
628  return bRet;
629 }
630 
631 void GalleryTheme::CopyToClipboard(const weld::Widget& rWidget, sal_uInt32 nPos)
632 {
633  rtl::Reference<GalleryTransferable> pTransferable = new GalleryTransferable( this, nPos, false );
634  pTransferable->CopyToClipboard(rWidget.get_clipboard());
635 }
636 
638 {
639  return mpGalleryStorageEngine->getModificationDate();
640 }
641 
643 {
644  sal_uInt32 nCount;
645  sal_uInt16 nVersion;
646 
647  rIStm.ReadUInt16( nVersion );
649  rIStm.ReadUInt32( nCount );
650 
651  if( nVersion >= 0x0004 )
652  {
653  sal_uInt16 nTmp16;
654  rIStm.ReadUInt16( nTmp16 );
655  }
656 
657  if( nCount <= ( 1 << 14 ) )
658  {
659  INetURLObject aRelURL1( GetParent()->GetRelativeURL() );
660  INetURLObject aRelURL2( GetParent()->GetUserURL() );
661  sal_uInt32 nId1, nId2;
662  bool bRel;
663 
665  {
666  GalleryObject* pObj = i.get();
668  i.reset();
669  }
671 
672  for( sal_uInt32 i = 0; i < nCount; i++ )
673  {
674  std::unique_ptr<GalleryObject> pObj(new GalleryObject);
675 
676  OUString aFileName;
677  sal_uInt16 nTemp;
678 
679  rIStm.ReadCharAsBool( bRel );
680  OString aTempFileName = read_uInt16_lenPrefixed_uInt8s_ToOString(rIStm);
681  rIStm.ReadUInt32( pObj->nOffset );
682  rIStm.ReadUInt16( nTemp ); pObj->eObjKind = static_cast<SgaObjKind>(nTemp);
683 
684  aFileName = OStringToOUString(aTempFileName, osl_getThreadTextEncoding());
685 
686  pObj->m_pGalleryObjectStorage.reset();
687  pObj->m_pGalleryObjectStorage = std::make_unique<GalleryObjectBinaryStorage>();
688 
689  if( bRel )
690  {
691  aFileName = aFileName.replaceAll( "\\", "/" );
692  OUString aPath = aRelURL1.GetMainURL( INetURLObject::DecodeMechanism::NONE );
693 
694  if( aFileName[ 0 ] != '/' )
695  aPath += "/";
696 
697  aPath += aFileName;
698 
699  pObj->m_pGalleryObjectStorage->setURL(INetURLObject(aPath));
700 
701  if (!FileExists(pObj->getURL()))
702  {
704 
705  if( aFileName[0] != '/' )
706  aPath += "/";
707 
708  aPath += aFileName;
709 
710  // assign this URL, even in the case it is not valid (#94482)
711  pObj->m_pGalleryObjectStorage->setURL(INetURLObject(aPath));
712  }
713  }
714  else
715  {
716  if( SgaObjKind::SvDraw == pObj->eObjKind )
717  {
718  OUString aDummyURL = "gallery/svdraw/" + aFileName;
719  pObj->m_pGalleryObjectStorage->setURL(INetURLObject(aDummyURL, INetProtocol::PrivSoffice));
720  }
721  else
722  {
723  OUString aLocalURL;
724 
725  pObj->m_pGalleryObjectStorage->setURL(INetURLObject(aFileName));
726 
727  if( ( pObj->getURL().GetProtocol() == INetProtocol::NotValid ) &&
728  osl::FileBase::getFileURLFromSystemPath( aFileName, aLocalURL ) == osl::FileBase::E_None )
729  {
730  pObj->m_pGalleryObjectStorage->setURL(INetURLObject(aLocalURL));
731  }
732  }
733  }
734  maGalleryObjectCollection.getObjectList().push_back( std::move(pObj) );
735  }
736 
737  rIStm.ReadUInt32( nId1 ).ReadUInt32( nId2 );
738 
739  // In newer versions a 512 byte reserve buffer is located at the end,
740  // the data is located at the beginning of this buffer and are clamped
741  // by a VersionCompatRead.
742  if( !rIStm.eof() &&
743  nId1 == COMPAT_FORMAT( 'G', 'A', 'L', 'R' ) &&
744  nId2 == COMPAT_FORMAT( 'E', 'S', 'R', 'V' ) )
745  {
746  VersionCompatRead aCompat(rIStm);
747  sal_uInt32 nTemp32;
748  bool bThemeNameFromResource = false;
749 
750  rIStm.ReadUInt32( nTemp32 );
751 
752  if( aCompat.GetVersion() >= 2 )
753  {
754  rIStm.ReadCharAsBool( bThemeNameFromResource );
755  }
756 
757  SetId( nTemp32, bThemeNameFromResource );
758  }
759  }
760  else
761  rIStm.SetError( SVSTREAM_READ_ERROR );
762 
763  ImplSetModified( false );
764 
765  return rIStm;
766 }
767 
768 void GalleryTheme::ImplSetModified( bool bModified )
769 {
770  pThm->SetModified(bModified);
771 }
772 
773 sal_uInt32 GalleryTheme::GetId() const { return pThm->GetId(); }
774 void GalleryTheme::SetId( sal_uInt32 nNewId, bool bResetThemeName ) { pThm->SetId( nNewId, bResetThemeName ); }
775 bool GalleryTheme::IsReadOnly() const { return pThm->IsReadOnly(); }
776 bool GalleryTheme::IsDefault() const { return pThm->IsDefault(); }
777 
778 const OUString& GalleryTheme::GetName() const { return pThm->GetThemeName(); }
779 
780 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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:349
SAL_DLLPRIVATE bool InsertModelStream(const tools::SvRef< SotTempStream > &rModelStream, sal_uInt32 nInsertPos)
Definition: galtheme.cxx:472
bool IsModified() const
Definition: gallery1.hxx:71
bool IsDefault() const
Definition: galtheme.cxx:776
sal_uInt32 GetId() const
Definition: galtheme.cxx:773
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:329
EmbeddedObjectRef * pObject
bool HasFormat(SotClipboardFormatId nFormat) const
static bool isMediaURL(std::u16string_view rURL, const OUString &rReferer, bool bDeep=false, rtl::Reference< PlayerListener > xPreferredPixelSizeListener=nullptr)
void Clear()
OString read_uInt16_lenPrefixed_uInt8s_ToOString(SvStream &rStrm)
SAL_DLLPRIVATE bool GetURL(sal_uInt32 nPos, INetURLObject &rURL)
Definition: galtheme.cxx:483
bool eof() const
INetURLObject ImplGetURL(const GalleryObject *pObject)
Definition: galmisc.cxx:553
int nCount
GalleryThemeEntry * pThm
Definition: galtheme.hxx:62
std::unique_ptr< GalleryObject > & get(sal_uInt32 nPos)
bool GetFileList(SotClipboardFormatId nFormat, FileList &rFileList) const
SAL_DLLPRIVATE SvStream & ReadData(SvStream &rIn)
Definition: galtheme.cxx:642
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:631
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:522
#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:497
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
ConvertDataFormat
void hideMarkHandles()
Definition: svdmrkv.cxx:584
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:1801
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:534
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
bool GetString(SotClipboardFormatId nFormat, OUString &rStr) const
void AppendFile(const OUString &rStr)
SAL_DLLPRIVATE bool IsBroadcasterLocked() const
Definition: galtheme.hxx:106
bool GetImageMap(SotClipboardFormatId nFormat, ImageMap &rIMap) const
void UnlockBroadcaster()
Definition: galtheme.cxx:110
bool GetGraphic(SotClipboardFormatId nFormat, Graphic &rGraphic) const
SAL_DLLPRIVATE void ImplBroadcast(sal_uInt32 nUpdatePos)
Definition: galtheme.cxx:84
void AppendUserData(std::unique_ptr< SdrObjUserData > pData)
Definition: svdobj.cxx:2728
GalleryObjectCollection maGalleryObjectCollection
Definition: galtheme.hxx:60
bool IsDefault() const
Definition: gallery1.cxx:719
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
DateTime getModificationDate() const
Definition: galtheme.cxx:637
bool GetModel(sal_uInt32 nPos, SdrModel &rModel)
Definition: galtheme.cxx:437
void Broadcast(const SfxHint &rHint)
bool GetSotStorageStream(SotClipboardFormatId nFormat, tools::SvRef< SotTempStream > &rStreamRef) const
std::unique_ptr< GalleryBinaryEngine > createGalleryStorageEngine(GalleryObjectCollection &mrGalleryObjectCollection)
Definition: gallery1.cxx:176
sal_uInt16 GetVersion() const
SAL_DLLPRIVATE bool GetModelStream(sal_uInt32 nPos, tools::SvRef< SotTempStream > const &rModelStreamRef)
Definition: galtheme.cxx:459
const GalleryObject * getForPosition(sal_uInt32 nPos) const
void SetId(sal_uInt32 nNewId, bool bResetThemeName)
Definition: gallery1.cxx:200
SAL_DLLPRIVATE bool GetThumb(sal_uInt32 nPos, BitmapEx &rBmp)
Definition: galtheme.cxx:297
bool bAbortActualize
Definition: galtheme.hxx:67
SAL_DLLPRIVATE void ImplSetModified(bool bModified)
Definition: galtheme.cxx:768
SAL_DLLPRIVATE void SetId(sal_uInt32 nNewId, bool bResetThemeName)
Definition: galtheme.cxx:774
const OUString & GetName() const
Definition: galtheme.cxx:778
A SdrPage contains exactly one SdrObjList and a description of the physical page dimensions (size / m...
Definition: svdpage.hxx:373
SAL_DLLPRIVATE bool UnlockTheme()
Definition: galtheme.cxx:95
bool IsReadOnly() const
Definition: galtheme.cxx:775
bool InsertModel(const FmFormModel &rModel, sal_uInt32 nInsertPos)
Definition: galtheme.cxx:450
const OUString & GetThemeName() const
Definition: gallery1.hxx:64
std::unique_ptr< SgaObject > AcquireObject(sal_uInt32 nPos)
Definition: galtheme.cxx:142
bool m_bDetectedRangeSegmentation false