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>
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
50using 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
79void GalleryTheme::SetDestDir(const OUString& rDestDir, bool bRelative)
80{
81 mpGalleryStorageEngine->setDestDir(rDestDir, bRelative);
82}
83
84void 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
118bool 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)->m_oStorageUrl == 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
142std::unique_ptr<SgaObject> GalleryTheme::AcquireObject(sal_uInt32 nPos)
143{
145}
146
147void 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
157void 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
167void 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 );
180}
181
182bool 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
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
225
226 const INetURLObject aURL( *pEntry->m_oStorageUrl );
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
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
297bool 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
311bool GalleryTheme::GetGraphic(sal_uInt32 nPos, Graphic& rGraphic)
312{
314 bool bRet = false;
315
316 if( pObject )
317 {
319
320 switch( pObject->eObjKind )
321 {
324 case SgaObjKind::Inet:
325 {
326 OUString aFilterDummy;
327 bRet = ( GalleryGraphicImport( aURL, rGraphic, aFilterDummy ) != GalleryGraphicImportRet::IMPORT_NONE );
328 }
329 break;
330
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
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
383bool 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
437bool 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
450bool 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
459bool 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
472bool 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
483bool 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
497bool 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
522bool GalleryTheme::InsertFileOrDirURL(const INetURLObject& rFileOrDirURL, sal_uInt32 nInsertPos)
523{
524 bool bRet = false;
525 std::vector< INetURLObject > aURLVector;
526 GalleryFileStorage::insertFileOrDirURL(rFileOrDirURL, aURLVector);
527
528 for( const auto& rURL : aURLVector )
529 bRet = bRet || InsertURL( rURL, nInsertPos );
530
531 return bRet;
532}
533
534bool 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::optional<Graphic> oGraphic;
542
543 if( aDataHelper.HasFormat( SotClipboardFormatId::DRAWING ) )
544 {
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 oGraphic.emplace( aGraphic );
595 }
596
597 if( oGraphic )
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 rtl::Reference<SdrGrafObj> pGrafObj = new SdrGrafObj(*aModel.GetModel(), *oGraphic );
615
616 pGrafObj->AppendUserData( std::unique_ptr<SdrObjUserData>(new SgaIMapInfo( aImageMap )) );
617 pPage->InsertObject( pGrafObj.get() );
618 bRet = InsertModel( *aModel.GetModel(), nInsertPos );
619 }
620 }
621 }
622
623 if( !bRet )
624 bRet = InsertGraphic( *oGraphic, nInsertPos );
625 }
626 }
627
628 return bRet;
629}
630
631void 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_oStorageUrl.emplace();
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_oStorageUrl = INetURLObject(aPath);
699
700 if (!FileExists(*pObj->m_oStorageUrl))
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_oStorageUrl = INetURLObject(aPath);
711 }
712 }
713 else
714 {
715 if( SgaObjKind::SvDraw == pObj->eObjKind )
716 {
717 OUString aDummyURL = "gallery/svdraw/" + aFileName;
718 pObj->m_oStorageUrl = INetURLObject(aDummyURL, INetProtocol::PrivSoffice);
719 }
720 else
721 {
722 OUString aLocalURL;
723
724 pObj->m_oStorageUrl = INetURLObject(aFileName);
725
726 if( ( pObj->m_oStorageUrl->GetProtocol() == INetProtocol::NotValid ) &&
727 osl::FileBase::getFileURLFromSystemPath( aFileName, aLocalURL ) == osl::FileBase::E_None )
728 {
729 pObj->m_oStorageUrl = 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
761
762 ImplSetModified( false );
763
764 return rIStm;
765}
766
767void GalleryTheme::ImplSetModified( bool bModified )
768{
769 pThm->SetModified(bModified);
770}
771
772sal_uInt32 GalleryTheme::GetId() const { return pThm->GetId(); }
773void GalleryTheme::SetId( sal_uInt32 nNewId, bool bResetThemeName ) { pThm->SetId( nNewId, bResetThemeName ); }
774bool GalleryTheme::IsReadOnly() const { return pThm->IsReadOnly(); }
775bool GalleryTheme::IsDefault() const { return pThm->IsDefault(); }
776
777const OUString& GalleryTheme::GetName() const { return pThm->GetThemeName(); }
778const INetURLObject& GalleryTheme::getThemeURL() const { return mpGalleryStorageEngine->getThemeURL(); }
779
780/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
size_t Count() const
OUString GetFile(size_t nIndex) const
void AppendFile(const OUString &rStr)
virtual SdrPageView * ShowSdrPage(SdrPage *pPage) override
Definition: fmview.cxx:292
static void insertFileOrDirURL(const INetURLObject &rFileOrDirURL, std::vector< INetURLObject > &rURLVector)
const GalleryObject * getForPosition(sal_uInt32 nPos) const
std::unique_ptr< GalleryObject > & get(sal_uInt32 nPos)
std::vector< std::unique_ptr< GalleryObject > > & getObjectList()
void Update(sal_Int32 nVal, sal_Int32 nMaxVal)
Definition: galmisc.cxx:349
const OUString & GetThemeName() const
Definition: gallery1.hxx:64
bool IsReadOnly() const
Definition: gallery1.hxx:66
sal_uInt32 GetId() const
Definition: gallery1.hxx:77
bool IsDefault() const
Definition: gallery1.cxx:722
void SetModified(bool bSet)
Definition: gallery1.hxx:72
void SetId(sal_uInt32 nNewId, bool bResetThemeName)
Definition: gallery1.cxx:203
bool IsModified() const
Definition: gallery1.hxx:71
std::unique_ptr< GalleryFileStorage > createGalleryStorageEngine(GalleryObjectCollection &mrGalleryObjectCollection)
Definition: gallery1.cxx:179
SAL_DLLPRIVATE void LockBroadcaster()
Definition: galtheme.hxx:105
SAL_DLLPRIVATE void ImplSetModified(bool bModified)
Definition: galtheme.cxx:767
GalleryObjectCollection maGalleryObjectCollection
Definition: galtheme.hxx:61
const OUString & GetName() const
Definition: galtheme.cxx:777
GalleryTheme(GalleryTheme const &)=delete
bool bAbortActualize
Definition: galtheme.hxx:68
bool InsertURL(const INetURLObject &rURL, sal_uInt32 nInsertPos=SAL_MAX_UINT32)
Definition: galtheme.cxx:497
sal_uInt32 mnThemeLockCount
Definition: galtheme.hxx:64
SAL_DLLPRIVATE void SetId(sal_uInt32 nNewId, bool bResetThemeName)
Definition: galtheme.cxx:773
void Actualize(const Link< const INetURLObject &, void > &rActualizeLink, GalleryProgress *pProgress=nullptr)
Definition: galtheme.cxx:203
SAL_DLLPRIVATE void CopyToClipboard(const weld::Widget &rWidget, sal_uInt32 nPos)
Definition: galtheme.cxx:631
sal_uInt32 mnBroadcasterLockCount
Definition: galtheme.hxx:65
bool GetGraphic(sal_uInt32 nPos, Graphic &rGraphic)
Definition: galtheme.cxx:311
bool InsertObject(const SgaObject &rObj, sal_uInt32 nPos=SAL_MAX_UINT32)
Definition: galtheme.cxx:118
void SetDestDir(const OUString &rDestDir, bool bRelative)
Definition: galtheme.cxx:79
void UnlockBroadcaster()
Definition: galtheme.cxx:110
virtual SAL_DLLPRIVATE ~GalleryTheme() override
Definition: galtheme.cxx:64
bool ChangeObjectPos(sal_uInt32 nOldPos, sal_uInt32 nNewPos)
Definition: galtheme.cxx:182
sal_uInt32 GetId() const
Definition: galtheme.cxx:772
SAL_DLLPRIVATE bool InsertTransferable(const css::uno::Reference< css::datatransfer::XTransferable > &rxTransferable, sal_uInt32 nInsertPos)
Definition: galtheme.cxx:534
GalleryThemeEntry * pThm
Definition: galtheme.hxx:63
bool IsReadOnly() const
Definition: galtheme.cxx:774
SAL_DLLPRIVATE sal_uInt32 GetObjectCount() const
Definition: galtheme.hxx:83
SAL_DLLPRIVATE bool UnlockTheme()
Definition: galtheme.cxx:95
SAL_DLLPRIVATE bool GetThumb(sal_uInt32 nPos, BitmapEx &rBmp)
Definition: galtheme.cxx:297
SAL_DLLPRIVATE Gallery * GetParent() const
Definition: galtheme.hxx:118
SAL_DLLPRIVATE bool GetModelStream(sal_uInt32 nPos, tools::SvRef< SotTempStream > const &rModelStreamRef)
Definition: galtheme.cxx:459
std::unique_ptr< SgaObject > AcquireObject(sal_uInt32 nPos)
Definition: galtheme.cxx:142
std::unique_ptr< GalleryFileStorage > mpGalleryStorageEngine
Definition: galtheme.hxx:60
DateTime getModificationDate() const
Definition: galtheme.cxx:637
bool InsertGraphic(const Graphic &rGraphic, sal_uInt32 nInsertPos)
Definition: galtheme.cxx:383
bool GetModel(sal_uInt32 nPos, SdrModel &rModel)
Definition: galtheme.cxx:437
SAL_DLLPRIVATE bool IsBroadcasterLocked() const
Definition: galtheme.hxx:107
SAL_DLLPRIVATE bool InsertFileOrDirURL(const INetURLObject &rFileOrDirURL, sal_uInt32 nInsertPos)
Definition: galtheme.cxx:522
bool InsertModel(const FmFormModel &rModel, sal_uInt32 nInsertPos)
Definition: galtheme.cxx:450
void RemoveObject(sal_uInt32 nPos)
Definition: galtheme.cxx:167
SAL_DLLPRIVATE SvStream & ReadData(SvStream &rIn)
Definition: galtheme.cxx:642
SAL_DLLPRIVATE bool InsertModelStream(const tools::SvRef< SotTempStream > &rModelStream, sal_uInt32 nInsertPos)
Definition: galtheme.cxx:472
SAL_DLLPRIVATE void ImplBroadcast(sal_uInt32 nUpdatePos)
Definition: galtheme.cxx:84
SAL_DLLPRIVATE void SetPreviewBitmapExAndStrings(sal_uInt32 nPos, const BitmapEx &rBitmapEx, const Size &rSize, const OUString &rTitle, const OUString &rPath)
Definition: galtheme.cxx:157
const INetURLObject & getThemeURL() const
Definition: galtheme.cxx:778
bool IsDefault() const
Definition: galtheme.cxx:775
SAL_DLLPRIVATE bool GetURL(sal_uInt32 nPos, INetURLObject &rURL)
Definition: galtheme.cxx:483
SAL_DLLPRIVATE void GetPreviewBitmapExAndStrings(sal_uInt32 nPos, BitmapEx &rBitmapEx, Size &rSize, OUString &rTitle, OUString &rPath)
Definition: galtheme.cxx:147
GraphicType GetType() const
GfxLink GetGfxLink() const
bool IsAnimated() const
void Clear()
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
Graphic GetAllMarkedGraphic() const
Definition: svdxcgv.cxx:581
This class represents an embedded or linked bitmap graphic object.
Definition: svdograf.hxx:68
void hideMarkHandles()
Definition: svdmrkv.cxx:584
const SdrPage * GetPage(sal_uInt16 nPgNum) const
Definition: svdmodel.cxx:1860
virtual void InsertObject(SdrObject *pObj, size_t nPos=SAL_MAX_SIZE)
Definition: svdpage.cxx:295
A SdrPage contains exactly one SdrObjList and a description of the physical page dimensions (size / m...
Definition: svdpage.hxx:379
SdrModel & GetModel() const
Definition: svdpntv.hxx:282
void MarkAll()
Definition: svdview.cxx:1360
void Broadcast(const SfxHint &rHint)
SvStream & ReadCharAsBool(bool &rBool)
bool eof() const
SvStream & ReadUInt32(sal_uInt32 &rUInt32)
void SetError(ErrCode nErrorCode)
SvStream & ReadUInt16(sal_uInt16 &rUInt16)
FmFormModel * GetModel() const
bool GetString(SotClipboardFormatId nFormat, OUString &rStr) const
bool GetImageMap(SotClipboardFormatId nFormat, ImageMap &rIMap) const
bool GetFileList(SotClipboardFormatId nFormat, FileList &rFileList) const
bool GetSotStorageStream(SotClipboardFormatId nFormat, tools::SvRef< SotTempStream > &rStreamRef) const
bool HasFormat(SotClipboardFormatId nFormat) const
bool GetGraphic(SotClipboardFormatId nFormat, Graphic &rGraphic) const
sal_uInt16 GetVersion() const
static bool isMediaURL(std::u16string_view rURL, const OUString &rReferer, bool bDeep=false, rtl::Reference< PlayerListener > xPreferredPixelSizeListener=nullptr)
virtual css::uno::Reference< css::datatransfer::clipboard::XClipboard > get_clipboard() const=0
int nCount
#define DBG_ASSERT(sCon, aError)
URL aURL
EmbeddedObjectRef * pObject
#define SVSTREAM_READ_ERROR
sal_Int16 nVersion
SotClipboardFormatId
static bool FileExists(const INetURLObject &rURL, std::u16string_view rExt)
bool CreateIMapGraphic(const FmFormModel &rModel, Graphic &rGraphic, ImageMap &rImageMap)
Definition: galmisc.cxx:120
INetURLObject ImplGetURL(const GalleryObject *pObject)
Definition: galmisc.cxx:553
GalleryGraphicImportRet GalleryGraphicImport(const INetURLObject &rURL, Graphic &rGraphic, OUString &rFilterName)
Definition: galmisc.cxx:51
GalleryGraphicImportRet
Definition: galmisc.hxx:71
SgaObjKind
Definition: galmisc.hxx:57
sal_Int64 n
sal_uInt16 nPos
int i
ConvertDataFormat
OString read_uInt16_lenPrefixed_uInt8s_ToOString(SvStream &rStrm)
std::optional< INetURLObject > m_oStorageUrl
sal_uInt32 COMPAT_FORMAT(char char1, char char2, char char3, char char4)