20 #include <config_features.h>
22 #if defined(MACOSX) && HAVE_FEATURE_READONLY_INSTALLSET
23 #define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0
25 #include <Foundation/Foundation.h>
33 #include <com/sun/star/ucb/ContentCreationException.hpp>
40 #include <svx/strings.hrc>
41 #include <strings.hxx>
47 #include <com/sun/star/sdbc/XResultSet.hpp>
48 #include <com/sun/star/ucb/XContentAccess.hpp>
112 bool _bReadOnly,
bool _bNewFile,
113 sal_uInt32 _nId,
bool _bThemeNameFromResource ) :
116 bThemeNameFromResource ( _bThemeNameFromResource )
121 if (bCreateUniqueURL)
161 if(
aName.isEmpty() )
185 for (
size_t i = 0; i < SAL_N_ELEMENTS(
aLocalized); ++i)
191 if(
aName != rNewName )
221 mpThemeEntry( pThemeEntry ), mpTheme(
std::move(pTheme) ) {}
229 : bMultiPath ( false )
241 static Gallery *
const s_pGallery(
250 bool bIsReadOnlyDir {
false};
257 if( !bIsReadOnlyDir )
262 bool bIsRelURL {
true};
275 if( !bIsReadOnlyDir )
289 rbDirIsReadOnly =
false;
293 uno::Reference< ucb::XCommandEnvironment > xEnv;
296 uno::Sequence<OUString> aProps {
"Url" };
300 #if defined(MACOSX) && HAVE_FEATURE_READONLY_INSTALLSET
303 const char *appBundle = [[[NSBundle mainBundle] bundlePath] UTF8String];
305 if( path.startsWith( OUString(OUString( appBundle, strlen( appBundle ), RTL_TEXTENCODING_UTF8 ) +
"/") ) )
306 rbDirIsReadOnly =
true;
314 aTestURL.
Append(
"cdefghij.klm" );
319 pTestStm->WriteInt32( sal_Int32(1) );
321 if( pTestStm->GetError() )
322 rbDirIsReadOnly =
true;
328 rbDirIsReadOnly =
true;
330 catch(
const ucb::ContentCreationException& )
333 catch(
const uno::RuntimeException& )
336 catch(
const uno::Exception& )
340 if( xResultSet.is() )
342 uno::Reference< ucb::XContentAccess > xContentAccess( xResultSet, uno::UNO_QUERY );
344 if( xContentAccess.is() )
346 static constexpr OUStringLiteral s_sTitle =
u"Title";
347 static constexpr OUStringLiteral s_sIsReadOnly =
u"IsReadOnly";
349 while( xResultSet->next() )
351 INetURLObject aThmURL( xContentAccess->queryContentIdentifierString() );
353 if (aThmURL.GetFileExtension().equalsIgnoreAsciiCase(
"thm"))
369 catch(
const uno::RuntimeException& )
372 catch(
const uno::Exception& )
376 if( !aTitle.isEmpty() )
382 aThmCnt.getPropertyValue( s_sIsReadOnly ) >>=
bReadOnly;
384 catch(
const uno::RuntimeException& )
387 catch(
const uno::Exception& )
395 aSdgCnt.getPropertyValue( s_sTitle ) >>= aTitle;
397 catch(
const css::uno::RuntimeException& )
400 catch(
const css::uno::Exception& )
404 if( !aTitle.isEmpty() )
408 aSdgCnt.getPropertyValue( s_sIsReadOnly ) >>=
bReadOnly;
410 catch(
const uno::RuntimeException& )
413 catch(
const uno::Exception& )
423 aSdvCnt.getPropertyValue( s_sTitle ) >>= aTitle;
425 catch(
const css::uno::RuntimeException& )
428 catch(
const css::uno::Exception& )
432 if( !aTitle.isEmpty() )
436 aSdvCnt.getPropertyValue( s_sIsReadOnly ) >>=
bReadOnly;
438 catch(
const uno::RuntimeException& )
441 catch(
const uno::Exception& )
453 catch(
const ucb::ContentCreationException& )
456 catch(
const uno::RuntimeException& )
459 catch(
const uno::Exception& )
467 catch(
const ucb::ContentCreationException& )
470 catch(
const uno::RuntimeException& )
473 catch(
const uno::Exception& )
480 if( !rThemeName.empty() )
497 if( nThemeId == pEntry->
GetId() )
509 aFallback =
SvxResId(RID_GALLERYSTR_THEME_3D);
512 aFallback =
SvxResId(RID_GALLERYSTR_THEME_BULLETS);
515 aFallback =
SvxResId(RID_GALLERYSTR_THEME_HOMEPAGE);
527 aFallback =
SvxResId(RID_GALLERYSTR_THEME_SOUNDS);
530 aFallback =
SvxResId(RID_GALLERYSTR_THEME_ARROWS);
533 aFallback =
SvxResId(RID_GALLERYSTR_THEME_COMPUTERS);
536 aFallback =
SvxResId(RID_GALLERYSTR_THEME_DIAGRAMS);
539 aFallback =
SvxResId(RID_GALLERYSTR_THEME_EDUCATION);
542 aFallback =
SvxResId(RID_GALLERYSTR_THEME_ENVIRONMENT);
545 aFallback =
SvxResId(RID_GALLERYSTR_THEME_FINANCE);
548 aFallback =
SvxResId(RID_GALLERYSTR_THEME_PEOPLE);
551 aFallback =
SvxResId(RID_GALLERYSTR_THEME_SYMBOLS);
554 aFallback =
SvxResId(RID_GALLERYSTR_THEME_TRANSPORT);
557 aFallback =
SvxResId(RID_GALLERYSTR_THEME_TXTSHAPES);
578 if( !
HasTheme( rThemeName ) && (
GetUserURL().GetProtocol() != INetProtocol::NotValid ) )
581 aURL.
Append( rThemeName );
583 true, aURL, rThemeName,
584 false,
true, 0,
false );
608 pThemeEntry->
SetName( rNewName );
623 if( pThemeEntry && !pThemeEntry->
IsReadOnly() )
637 [&pThemeEntry](
const std::unique_ptr<GalleryThemeEntry>& rpEntry) {
return pThemeEntry == rpEntry.get(); });
651 std::unique_ptr<GalleryTheme> pNewTheme;
666 pTheme = (*it)->GetTheme();
670 std::unique_ptr<GalleryTheme> pNewTheme = pThemeEntry->
getCachedTheme(
this);
#define GALLERY_THEME_POWERPOINT
#define RID_GALLERY_THEME_TROUBLE
#define GALLERY_THEME_FONTWORK
const GalleryThemeEntry * GetThemeEntry() const
bool HasListeners() const
#define RID_GALLERY_THEME_FLAGS
std::unique_ptr< GalleryBinaryEngine > mpGalleryStorageEngine
#define GALLERY_THEME_BULLETS
#define RID_GALLERY_THEME_TRANSPORT
#define RID_GALLERY_THEME_INTERACTION
#define RID_GALLERYSTR_THEME_FONTWORK
#define RID_GALLERY_THEME_PEOPLE
OUString GetURLPath(DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
css::uno::Any getPropertyValue(const OUString &rPropertyName)
SAL_DLLPRIVATE void ImplLoad(const OUString &rMultiPath)
std::unique_ptr< GalleryTheme > mpTheme
#define RID_GALLERY_THEME_KEYBOARD
static void InsertAllThemes(weld::ComboBox &rListBox)
#define RID_GALLERY_THEME_BACKGROUNDS
#define GALLERY_THEME_SOUNDS
GalleryTheme * createGalleryTheme(Gallery *pGallery)
#define RID_GALLERY_THEME_SURFACES
#define RID_GALLERY_THEME_NAVIGATION
#define RID_GALLERY_THEME_PRESENTATION
#define GALLERY_THEME_RULERS
#define RID_GALLERY_THEME_ENVIRONMENT
std::unique_ptr< GalleryBinaryEngineEntry > mpGalleryStorageEngineEntry
SAL_DLLPRIVATE GalleryTheme * ImplGetCachedTheme(GalleryThemeEntry *pThemeEntry)
#define RID_GALLERY_THEME_3D
bool HasTheme(std::u16string_view rThemeName)
SAL_DLLPRIVATE OUString GetThemeName(sal_uInt32 nThemeId) const
std::unique_ptr< GalleryTheme > getCachedTheme(Gallery *pGallery)
#define RID_GALLERY_THEME_COMPUTER
#define RID_GALLERY_THEME_TXTSHAPES
#define RID_GALLERY_THEME_ANIMATIONS
static std::unique_ptr< SvStream > CreateStream(const OUString &rFileName, StreamMode eOpenMode, css::uno::Reference< css::awt::XWindow > xParentWin=nullptr)
OUString SvxResId(const char *pId)
void RenameTheme(const OUString &rOldName, const OUString &rNewName)
static Gallery * GetGalleryInstance()
#define RID_GALLERYSTR_THEME_DUMMY5
SAL_DLLPRIVATE void ImplLoadSubDirs(const INetURLObject &rBaseURL, bool &rbIsReadOnly)
const GalleryThemeEntry * mpThemeEntry
void SetExtension(OUString const &rTheExtension)
static GalleryThemeEntry * CreateThemeEntry(const INetURLObject &rURL, bool bReadOnly)
bool bThemeNameFromResource
#define RID_GALLERYSTR_THEME_HTMLBUTTONS
bool RemoveTheme(const OUString &rThemeName)
#define RID_GALLERY_THEME_MAPS
SAL_DLLPRIVATE void ImplDeleteCachedTheme(GalleryTheme const *pTheme)
#define RID_GALLERY_THEME_EMOTICONS
#define RID_GALLERY_THEME_HOMEPAGE
#define RID_GALLERY_THEME_TIME
#define RID_GALLERYSTR_THEME_FONTWORK_VERTICAL
#define SAL_N_ELEMENTS(arr)
#define RID_GALLERY_THEME_CLIMA
GalleryTheme * GetTheme() const
#define RID_GALLERY_THEME_FLOWCHARTS
#define RID_GALLERY_THEME_COMPUTERS
SAL_DLLPRIVATE const INetURLObject & GetUserURL() const
#define DBG_ASSERT(sCon, aError)
bool Append(OUString const &rTheSegment, EncodeMechanism eMechanism=EncodeMechanism::WasEncoded, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
#define RID_GALLERY_THEME_PHOTOS
void SetModified(bool bSet)
#define RID_GALLERY_THEME_BALLOONS
const std::pair< sal_uInt16, const char * > aLocalized[]
#define RID_GALLERY_THEME_BULLETS
#define RID_GALLERY_THEME_FINANCE
#define RID_GALLERY_THEME_COMMUNICATION
#define RID_GALLERYSTR_THEME_POWERPOINT
void StartListening(SfxBroadcaster &rBroadcaster, DuplicateHandling eDuplicateHanding=DuplicateHandling::Unexpected)
#define RID_GALLERYSTR_THEME_RULERS
bool KillFile(const INetURLObject &rURL)
#define RID_GALLERY_THEME_SYMBOLS
Gallery(Gallery const &)=delete
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
#define RID_GALLERY_THEME_ARROWS
void Broadcast(const SfxHint &rHint)
static void CreateUniqueURL(const INetURLObject &rBaseURL, INetURLObject &aURL)
void ReleaseTheme(GalleryTheme *pTheme, SfxListener &rListener)
void SetName(const OUString &rNewName)
const std::pair< sal_uInt16, const char * > aUnlocalized[]
std::unique_ptr< GalleryBinaryEngine > createGalleryStorageEngine(GalleryObjectCollection &mrGalleryObjectCollection)
GalleryThemeCacheEntry(const GalleryThemeEntry *pThemeEntry, std::unique_ptr< GalleryTheme > pTheme)
INetProtocol GetProtocol() const
#define RID_GALLERY_THEME_DIAGRAMS
void SetId(sal_uInt32 nNewId, bool bResetThemeName)
void EndListening(SfxBroadcaster &rBroadcaster, bool bRemoveAllDuplicates=false)
#define GALLERY_THEME_USERSOUNDS
#define RID_GALLERYSTR_THEME_USERSOUNDS
#define RID_GALLERY_THEME_EDUCATION
Reference< XComponentContext > getProcessComponentContext()
#define RID_GALLERY_THEME_SOUNDS
GalleryCacheThemeList aThemeCache
GalleryThemeEntry(bool bCreateUniqueURL, const INetURLObject &rBaseURL, const OUString &rName, bool bReadOnly, bool bNewFile, sal_uInt32 nId, bool bThemeNameFromResource)
#define RID_GALLERY_THEME_CALENDAR
#define RID_GALLERY_THEME_OFFICE
SAL_DLLPRIVATE void ImplSetModified(bool bModified)
void append_text(const OUString &rStr)
const OUString & GetName() const
GalleryThemeEntry * ImplGetThemeEntry(std::u16string_view rThemeName)
#define GALLERY_THEME_FONTWORK_VERTICAL
virtual ~Gallery() override
bool CreateTheme(const OUString &rThemeName)
#define RID_GALLERY_THEME_MYTHEME
constexpr OUStringLiteral first
#define RID_GALLERY_THEME_SCREENBEANS
#define GALLERY_THEME_MYTHEME
#define GALLERY_THEME_DUMMY5
void setStorageLocations(INetURLObject &rURL)
#define GALLERY_THEME_HOMEPAGE
GalleryTheme * AcquireTheme(std::u16string_view rThemeName, SfxListener &rListener)
const OUString & GetThemeName() const
#define RID_GALLERY_THEME_FINANCES
std::vector< std::unique_ptr< GalleryThemeEntry > > aThemeList