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>
41#include <svx/strings.hrc>
48#include <com/sun/star/sdbc/XResultSet.hpp>
49#include <com/sun/star/ucb/XContentAccess.hpp>
56const std::pair<sal_uInt16, rtl::OUStringConstExpr>
aUnlocalized[] =
113 bool _bReadOnly,
bool _bNewFile,
114 sal_uInt32 _nId,
bool _bThemeNameFromResource ) :
117 bThemeNameFromResource ( _bThemeNameFromResource )
120 DBG_ASSERT(
aURL.GetProtocol() != INetProtocol::NotValid,
"invalid URL" );
122 if (bCreateUniqueURL)
162 if(
aName.isEmpty() )
195 if(
aName != rNewName )
233: bMultiPath ( false )
245 static Gallery *
const s_pGallery(
254 bool bIsReadOnlyDir {
false};
261 if( !bIsReadOnlyDir )
266 bool bIsRelURL {
true};
279 if( !bIsReadOnlyDir )
293 rbDirIsReadOnly =
false;
297 uno::Reference< ucb::XCommandEnvironment > xEnv;
300 uno::Sequence<OUString> aProps {
"Url" };
302 uno::Reference< sdbc::XResultSet > xResultSet( aCnt.
createCursor( aProps, ::ucbhelper::INCLUDE_DOCUMENTS_ONLY ) );
304#if defined(MACOSX) && HAVE_FEATURE_READONLY_INSTALLSET
307 const char *appBundle = [[[NSBundle mainBundle] bundlePath] UTF8String];
309 if( path.startsWith( Concat2View(OUString( appBundle, strlen( appBundle ), RTL_TEXTENCODING_UTF8 ) +
"/") ) )
310 rbDirIsReadOnly =
true;
318 aTestURL.
Append(
u"cdefghij.klm" );
323 pTestStm->WriteInt32( sal_Int32(1) );
325 if( pTestStm->GetError() )
326 rbDirIsReadOnly =
true;
332 rbDirIsReadOnly =
true;
334 catch(
const ucb::ContentCreationException& )
337 catch(
const uno::RuntimeException& )
340 catch(
const uno::Exception& )
344 if( xResultSet.is() )
346 uno::Reference< ucb::XContentAccess > xContentAccess( xResultSet, uno::UNO_QUERY );
348 if( xContentAccess.is() )
350 static constexpr OUStringLiteral s_sTitle =
u"Title";
351 static constexpr OUStringLiteral s_sIsReadOnly =
u"IsReadOnly";
353 while( xResultSet->next() )
355 INetURLObject aThmURL( xContentAccess->queryContentIdentifierString() );
373 catch(
const uno::RuntimeException& )
376 catch(
const uno::Exception& )
380 if( !aTitle.isEmpty() )
388 catch(
const uno::RuntimeException& )
391 catch(
const uno::Exception& )
401 catch(
const css::uno::RuntimeException& )
404 catch(
const css::uno::Exception& )
408 if( !aTitle.isEmpty() )
414 catch(
const uno::RuntimeException& )
417 catch(
const uno::Exception& )
429 catch(
const css::uno::RuntimeException& )
432 catch(
const css::uno::Exception& )
436 if( !aTitle.isEmpty() )
442 catch(
const uno::RuntimeException& )
445 catch(
const uno::Exception& )
457 catch(
const ucb::ContentCreationException& )
460 catch(
const uno::RuntimeException& )
463 catch(
const uno::Exception& )
471 catch(
const ucb::ContentCreationException& )
474 catch(
const uno::RuntimeException& )
477 catch(
const uno::Exception& )
484 if( !rThemeName.empty() )
501 if( nThemeId == pEntry->
GetId() )
513 aFallback =
SvxResId(RID_GALLERYSTR_THEME_3D);
516 aFallback =
SvxResId(RID_GALLERYSTR_THEME_BULLETS);
519 aFallback =
SvxResId(RID_GALLERYSTR_THEME_HOMEPAGE);
531 aFallback =
SvxResId(RID_GALLERYSTR_THEME_SOUNDS);
534 aFallback =
SvxResId(RID_GALLERYSTR_THEME_ARROWS);
537 aFallback =
SvxResId(RID_GALLERYSTR_THEME_COMPUTERS);
540 aFallback =
SvxResId(RID_GALLERYSTR_THEME_DIAGRAMS);
543 aFallback =
SvxResId(RID_GALLERYSTR_THEME_EDUCATION);
546 aFallback =
SvxResId(RID_GALLERYSTR_THEME_ENVIRONMENT);
549 aFallback =
SvxResId(RID_GALLERYSTR_THEME_FINANCE);
552 aFallback =
SvxResId(RID_GALLERYSTR_THEME_PEOPLE);
555 aFallback =
SvxResId(RID_GALLERYSTR_THEME_SYMBOLS);
558 aFallback =
SvxResId(RID_GALLERYSTR_THEME_TRANSPORT);
561 aFallback =
SvxResId(RID_GALLERYSTR_THEME_TXTSHAPES);
582 if( !
HasTheme( rThemeName ) && (
GetUserURL().GetProtocol() != INetProtocol::NotValid ) )
585 aURL.Append( rThemeName );
587 true,
aURL, rThemeName,
588 false,
true, 0,
false );
612 pThemeEntry->
SetName( rNewName );
627 if( pThemeEntry && !pThemeEntry->
IsReadOnly() )
641 [&pThemeEntry](
const std::unique_ptr<GalleryThemeEntry>& rpEntry) { return pThemeEntry == rpEntry.get(); });
655 std::unique_ptr<GalleryTheme> pNewTheme;
670 pTheme = (*it)->GetTheme();
674 std::unique_ptr<GalleryTheme> pNewTheme = pThemeEntry->
getCachedTheme(
this);
static GalleryThemeEntry * CreateThemeEntry(const INetURLObject &rURL, bool bReadOnly)
static void CreateUniqueURL(const INetURLObject &rBaseURL, INetURLObject &aURL)
const GalleryThemeEntry * mpThemeEntry
const GalleryThemeEntry * GetThemeEntry() const
GalleryTheme * GetTheme() const
GalleryThemeCacheEntry(const GalleryThemeEntry *pThemeEntry, std::unique_ptr< GalleryTheme > pTheme)
std::unique_ptr< GalleryTheme > mpTheme
const OUString & GetThemeName() const
std::unique_ptr< GalleryFileStorageEntry > mpGalleryStorageEngineEntry
GalleryThemeEntry(bool bCreateUniqueURL, const INetURLObject &rBaseURL, const OUString &rName, bool bReadOnly, bool bNewFile, sal_uInt32 nId, bool bThemeNameFromResource)
GalleryTheme * createGalleryTheme(Gallery *pGallery)
GalleryStorageLocations & getGalleryStorageLocations() const
void setStorageLocations(INetURLObject &rURL)
bool bThemeNameFromResource
void SetModified(bool bSet)
std::unique_ptr< GalleryTheme > getCachedTheme(Gallery *pGallery)
void SetId(sal_uInt32 nNewId, bool bResetThemeName)
void SetName(const OUString &rNewName)
std::unique_ptr< GalleryFileStorage > createGalleryStorageEngine(GalleryObjectCollection &mrGalleryObjectCollection)
SAL_DLLPRIVATE void ImplSetModified(bool bModified)
const OUString & GetName() const
static void InsertAllThemes(weld::ComboBox &rListBox)
std::unique_ptr< GalleryFileStorage > mpGalleryStorageEngine
SAL_DLLPRIVATE OUString GetThemeName(sal_uInt32 nThemeId) const
static Gallery * GetGalleryInstance()
SAL_DLLPRIVATE void ImplLoadSubDirs(const INetURLObject &rBaseURL, bool &rbIsReadOnly)
void ReleaseTheme(GalleryTheme *pTheme, SfxListener &rListener)
bool CreateTheme(const OUString &rThemeName)
SAL_DLLPRIVATE const INetURLObject & GetUserURL() const
bool HasTheme(std::u16string_view rThemeName)
void RenameTheme(const OUString &rOldName, const OUString &rNewName)
virtual ~Gallery() override
Gallery(Gallery const &)=delete
bool RemoveTheme(const OUString &rThemeName)
SAL_DLLPRIVATE void ImplLoad(std::u16string_view rMultiPath)
GalleryThemeEntry * ImplGetThemeEntry(std::u16string_view rThemeName)
SAL_DLLPRIVATE GalleryTheme * ImplGetCachedTheme(GalleryThemeEntry *pThemeEntry)
std::vector< std::unique_ptr< GalleryThemeEntry > > aThemeList
GalleryCacheThemeList aThemeCache
GalleryTheme * AcquireTheme(std::u16string_view rThemeName, SfxListener &rListener)
SAL_DLLPRIVATE void ImplDeleteCachedTheme(GalleryTheme const *pTheme)
void SetExtension(std::u16string_view rTheExtension)
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
OUString GetFileExtension() const
OUString GetURLPath(DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
INetProtocol GetProtocol() const
bool Append(std::u16string_view rTheSegment, EncodeMechanism eMechanism=EncodeMechanism::WasEncoded, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
bool HasListeners() const
void Broadcast(const SfxHint &rHint)
void StartListening(SfxBroadcaster &rBroadcaster, DuplicateHandling eDuplicateHanding=DuplicateHandling::Unexpected)
void EndListening(SfxBroadcaster &rBroadcaster, bool bRemoveAllDuplicates=false)
css::uno::Any getPropertyValue(const OUString &rPropertyName)
css::uno::Reference< css::sdbc::XResultSet > createCursor(const css::uno::Sequence< OUString > &rPropertyNames, ResultSetInclude eMode=INCLUDE_FOLDERS_AND_DOCUMENTS)
static std::unique_ptr< SvStream > CreateStream(const OUString &rFileName, StreamMode eOpenMode, css::uno::Reference< css::awt::XWindow > xParentWin=nullptr)
void append_text(const OUString &rStr)
#define DBG_ASSERT(sCon, aError)
OUString SvxResId(TranslateId aId)
const std::pair< sal_uInt16, TranslateId > aLocalized[]
const std::pair< sal_uInt16, rtl::OUStringConstExpr > aUnlocalized[]
#define RID_GALLERY_THEME_PRESENTATION
#define RID_GALLERY_THEME_BACKGROUNDS
#define GALLERY_THEME_FONTWORK
#define RID_GALLERY_THEME_CLIMA
#define RID_GALLERY_THEME_PEOPLE
#define GALLERY_THEME_DUMMY5
#define RID_GALLERY_THEME_COMMUNICATION
#define GALLERY_THEME_USERSOUNDS
#define GALLERY_THEME_FONTWORK_VERTICAL
#define GALLERY_THEME_MYTHEME
#define RID_GALLERY_THEME_TROUBLE
#define RID_GALLERY_THEME_CALENDAR
#define RID_GALLERY_THEME_INTERACTION
#define RID_GALLERY_THEME_MAPS
#define RID_GALLERY_THEME_3D
#define RID_GALLERY_THEME_FINANCE
#define RID_GALLERY_THEME_TRANSPORT
#define GALLERY_THEME_POWERPOINT
#define RID_GALLERY_THEME_DIAGRAMS
#define RID_GALLERY_THEME_BULLETS
#define RID_GALLERY_THEME_SYMBOLS
#define RID_GALLERY_THEME_COMPUTER
#define RID_GALLERY_THEME_SOUNDS
#define RID_GALLERY_THEME_ARROWS
#define RID_GALLERY_THEME_SURFACES
#define RID_GALLERY_THEME_ANIMATIONS
#define RID_GALLERY_THEME_FLOWCHARTS
#define GALLERY_THEME_BULLETS
#define RID_GALLERY_THEME_SCREENBEANS
#define RID_GALLERY_THEME_MYTHEME
#define RID_GALLERY_THEME_TXTSHAPES
#define RID_GALLERY_THEME_EMOTICONS
#define RID_GALLERY_THEME_BALLOONS
#define GALLERY_THEME_RULERS
#define RID_GALLERY_THEME_KEYBOARD
#define RID_GALLERY_THEME_FINANCES
#define RID_GALLERY_THEME_OFFICE
#define RID_GALLERY_THEME_TIME
#define RID_GALLERY_THEME_PHOTOS
#define RID_GALLERY_THEME_ENVIRONMENT
#define RID_GALLERY_THEME_HOMEPAGE
#define RID_GALLERY_THEME_FLAGS
#define RID_GALLERY_THEME_COMPUTERS
#define RID_GALLERY_THEME_EDUCATION
#define GALLERY_THEME_SOUNDS
#define GALLERY_THEME_HOMEPAGE
#define RID_GALLERY_THEME_NAVIGATION
bool KillFile(const INetURLObject &rURL)
#define SAL_N_ELEMENTS(arr)
Reference< XComponentContext > getProcessComponentContext()
constexpr OUStringLiteral first
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
constexpr OUStringLiteral RID_GALLERYSTR_THEME_RULERS
constexpr OUStringLiteral RID_GALLERYSTR_THEME_POWERPOINT
constexpr OUStringLiteral RID_GALLERYSTR_THEME_USERSOUNDS
constexpr OUStringLiteral RID_GALLERYSTR_THEME_HTMLBUTTONS
constexpr OUStringLiteral RID_GALLERYSTR_THEME_FONTWORK_VERTICAL
constexpr OUStringLiteral RID_GALLERYSTR_THEME_FONTWORK
constexpr OUStringLiteral RID_GALLERYSTR_THEME_DUMMY5