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>
42 #include <strings.hxx>
48 #include <com/sun/star/sdbc/XResultSet.hpp>
49 #include <com/sun/star/ucb/XContentAccess.hpp>
56 const std::pair<sal_uInt16, rtl::OUStringConstExpr>
aUnlocalized[] =
113 bool _bReadOnly,
bool _bNewFile,
114 sal_uInt32 _nId,
bool _bThemeNameFromResource ) :
117 bThemeNameFromResource ( _bThemeNameFromResource )
122 if (bCreateUniqueURL)
162 if(
aName.isEmpty() )
186 for (
size_t i = 0; i < SAL_N_ELEMENTS(
aLocalized); ++i)
192 if(
aName != rNewName )
222 mpThemeEntry( pThemeEntry ), mpTheme(
std::move(pTheme) ) {}
230 : bMultiPath (
false )
242 static Gallery *
const s_pGallery(
251 bool bIsReadOnlyDir {
false};
258 if( !bIsReadOnlyDir )
263 bool bIsRelURL {
true};
276 if( !bIsReadOnlyDir )
290 rbDirIsReadOnly =
false;
294 uno::Reference< ucb::XCommandEnvironment > xEnv;
297 uno::Sequence<OUString> aProps {
"Url" };
301 #if defined(MACOSX) && HAVE_FEATURE_READONLY_INSTALLSET
304 const char *appBundle = [[[NSBundle mainBundle] bundlePath] UTF8String];
306 if( path.startsWith( OUStringConcatenation(OUString( appBundle, strlen( appBundle ), RTL_TEXTENCODING_UTF8 ) +
"/") ) )
307 rbDirIsReadOnly =
true;
315 aTestURL.
Append(
u"cdefghij.klm" );
320 pTestStm->WriteInt32( sal_Int32(1) );
322 if( pTestStm->GetError() )
323 rbDirIsReadOnly =
true;
329 rbDirIsReadOnly =
true;
331 catch(
const ucb::ContentCreationException& )
334 catch(
const uno::RuntimeException& )
337 catch(
const uno::Exception& )
341 if( xResultSet.is() )
343 uno::Reference< ucb::XContentAccess > xContentAccess( xResultSet, uno::UNO_QUERY );
345 if( xContentAccess.is() )
347 static constexpr OUStringLiteral s_sTitle =
u"Title";
348 static constexpr OUStringLiteral s_sIsReadOnly =
u"IsReadOnly";
350 while( xResultSet->next() )
352 INetURLObject aThmURL( xContentAccess->queryContentIdentifierString() );
354 if (aThmURL.GetFileExtension().equalsIgnoreAsciiCase(
"thm"))
370 catch(
const uno::RuntimeException& )
373 catch(
const uno::Exception& )
377 if( !aTitle.isEmpty() )
383 aThmCnt.getPropertyValue( s_sIsReadOnly ) >>=
bReadOnly;
385 catch(
const uno::RuntimeException& )
388 catch(
const uno::Exception& )
396 aSdgCnt.getPropertyValue( s_sTitle ) >>= aTitle;
398 catch(
const css::uno::RuntimeException& )
401 catch(
const css::uno::Exception& )
405 if( !aTitle.isEmpty() )
409 aSdgCnt.getPropertyValue( s_sIsReadOnly ) >>=
bReadOnly;
411 catch(
const uno::RuntimeException& )
414 catch(
const uno::Exception& )
424 aSdvCnt.getPropertyValue( s_sTitle ) >>= aTitle;
426 catch(
const css::uno::RuntimeException& )
429 catch(
const css::uno::Exception& )
433 if( !aTitle.isEmpty() )
437 aSdvCnt.getPropertyValue( s_sIsReadOnly ) >>=
bReadOnly;
439 catch(
const uno::RuntimeException& )
442 catch(
const uno::Exception& )
454 catch(
const ucb::ContentCreationException& )
457 catch(
const uno::RuntimeException& )
460 catch(
const uno::Exception& )
468 catch(
const ucb::ContentCreationException& )
471 catch(
const uno::RuntimeException& )
474 catch(
const uno::Exception& )
481 if( !rThemeName.empty() )
498 if( nThemeId == pEntry->
GetId() )
510 aFallback =
SvxResId(RID_GALLERYSTR_THEME_3D);
513 aFallback =
SvxResId(RID_GALLERYSTR_THEME_BULLETS);
516 aFallback =
SvxResId(RID_GALLERYSTR_THEME_HOMEPAGE);
528 aFallback =
SvxResId(RID_GALLERYSTR_THEME_SOUNDS);
531 aFallback =
SvxResId(RID_GALLERYSTR_THEME_ARROWS);
534 aFallback =
SvxResId(RID_GALLERYSTR_THEME_COMPUTERS);
537 aFallback =
SvxResId(RID_GALLERYSTR_THEME_DIAGRAMS);
540 aFallback =
SvxResId(RID_GALLERYSTR_THEME_EDUCATION);
543 aFallback =
SvxResId(RID_GALLERYSTR_THEME_ENVIRONMENT);
546 aFallback =
SvxResId(RID_GALLERYSTR_THEME_FINANCE);
549 aFallback =
SvxResId(RID_GALLERYSTR_THEME_PEOPLE);
552 aFallback =
SvxResId(RID_GALLERYSTR_THEME_SYMBOLS);
555 aFallback =
SvxResId(RID_GALLERYSTR_THEME_TRANSPORT);
558 aFallback =
SvxResId(RID_GALLERYSTR_THEME_TXTSHAPES);
579 if( !
HasTheme( rThemeName ) && (
GetUserURL().GetProtocol() != INetProtocol::NotValid ) )
582 aURL.
Append( rThemeName );
584 true, aURL, rThemeName,
585 false,
true, 0,
false );
609 pThemeEntry->
SetName( rNewName );
624 if( pThemeEntry && !pThemeEntry->
IsReadOnly() )
638 [&pThemeEntry](
const std::unique_ptr<GalleryThemeEntry>& rpEntry) {
return pThemeEntry == rpEntry.get(); });
652 std::unique_ptr<GalleryTheme> pNewTheme;
667 pTheme = (*it)->GetTheme();
671 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_GALLERY_THEME_PEOPLE
OUString GetURLPath(DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
css::uno::Any getPropertyValue(const OUString &rPropertyName)
constexpr OUStringLiteral RID_GALLERYSTR_THEME_POWERPOINT
std::unique_ptr< GalleryTheme > mpTheme
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
#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)
void RenameTheme(const OUString &rOldName, const OUString &rNewName)
static Gallery * GetGalleryInstance()
OUString SvxResId(TranslateId aId)
constexpr OUStringLiteral RID_GALLERYSTR_THEME_HTMLBUTTONS
SAL_DLLPRIVATE void ImplLoadSubDirs(const INetURLObject &rBaseURL, bool &rbIsReadOnly)
const GalleryThemeEntry * mpThemeEntry
static GalleryThemeEntry * CreateThemeEntry(const INetURLObject &rURL, bool bReadOnly)
bool bThemeNameFromResource
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 SAL_N_ELEMENTS(arr)
#define RID_GALLERY_THEME_CLIMA
constexpr OUStringLiteral RID_GALLERYSTR_THEME_FONTWORK
GalleryTheme * GetTheme() const
#define RID_GALLERY_THEME_FLOWCHARTS
#define RID_GALLERY_THEME_COMPUTERS
constexpr OUStringLiteral RID_GALLERYSTR_THEME_USERSOUNDS
SAL_DLLPRIVATE const INetURLObject & GetUserURL() const
#define DBG_ASSERT(sCon, aError)
#define RID_GALLERY_THEME_PHOTOS
void SetModified(bool bSet)
#define RID_GALLERY_THEME_BALLOONS
#define RID_GALLERY_THEME_BULLETS
#define RID_GALLERY_THEME_FINANCE
constexpr OUStringLiteral RID_GALLERYSTR_THEME_FONTWORK_VERTICAL
#define RID_GALLERY_THEME_COMMUNICATION
constexpr OUStringLiteral RID_GALLERYSTR_THEME_RULERS
void StartListening(SfxBroadcaster &rBroadcaster, DuplicateHandling eDuplicateHanding=DuplicateHandling::Unexpected)
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)
std::unique_ptr< GalleryBinaryEngine > createGalleryStorageEngine(GalleryObjectCollection &mrGalleryObjectCollection)
GalleryThemeCacheEntry(const GalleryThemeEntry *pThemeEntry, std::unique_ptr< GalleryTheme > pTheme)
const std::pair< sal_uInt16, TranslateId > aLocalized[]
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_GALLERY_THEME_EDUCATION
Reference< XComponentContext > getProcessComponentContext()
#define RID_GALLERY_THEME_SOUNDS
bool Append(std::u16string_view rTheSegment, EncodeMechanism eMechanism=EncodeMechanism::WasEncoded, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
GalleryCacheThemeList aThemeCache
SAL_DLLPRIVATE void ImplLoad(std::u16string_view rMultiPath)
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 SetExtension(std::u16string_view rTheExtension)
void append_text(const OUString &rStr)
const OUString & GetName() const
GalleryThemeEntry * ImplGetThemeEntry(std::u16string_view rThemeName)
constexpr OUStringLiteral RID_GALLERYSTR_THEME_DUMMY5
#define GALLERY_THEME_FONTWORK_VERTICAL
const std::pair< sal_uInt16, rtl::OUStringConstExpr > aUnlocalized[]
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
bool m_bDetectedRangeSegmentation false
std::vector< std::unique_ptr< GalleryThemeEntry > > aThemeList