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>
32 #include <osl/thread.h>
35 #include <com/sun/star/ucb/ContentCreationException.hpp>
42 #include <svx/strings.hrc>
43 #include <strings.hxx>
48 #include <com/sun/star/sdbc/XResultSet.hpp>
49 #include <com/sun/star/ucb/XContentAccess.hpp>
120 bool _bReadOnly,
bool _bNewFile,
121 sal_uInt32 _nId,
bool _bThemeNameFromResource ) :
124 bThemeNameFromResource ( _bThemeNameFromResource )
129 if (bCreateUniqueURL)
133 static sal_Int32 nIdx = 0;
186 if(
aName.isEmpty() )
195 for (
size_t i = 0; i < SAL_N_ELEMENTS(
aLocalized); ++i)
221 if(
aName != rNewName )
247 mpThemeEntry( pThemeEntry ), mpTheme(
std::move(pTheme) ) {}
255 : bMultiPath ( false )
267 static Gallery *
const s_pGallery(
276 bool bIsReadOnlyDir {
false};
283 if( !bIsReadOnlyDir )
288 bool bIsRelURL {
true};
301 if( !bIsReadOnlyDir )
315 rbDirIsReadOnly =
false;
319 uno::Reference< ucb::XCommandEnvironment > xEnv;
322 uno::Sequence<OUString> aProps {
"Url" };
326 #if defined(MACOSX) && HAVE_FEATURE_READONLY_INSTALLSET
329 const char *appBundle = [[[NSBundle mainBundle] bundlePath] UTF8String];
331 if( path.startsWith( OUString( appBundle, strlen( appBundle ), RTL_TEXTENCODING_UTF8 ) +
"/" ) )
332 rbDirIsReadOnly =
true;
340 aTestURL.
Append(
"cdefghij.klm" );
345 pTestStm->WriteInt32( sal_Int32(1) );
347 if( pTestStm->GetError() )
348 rbDirIsReadOnly =
true;
354 rbDirIsReadOnly =
true;
356 catch(
const ucb::ContentCreationException& )
359 catch(
const uno::RuntimeException& )
362 catch(
const uno::Exception& )
366 if( xResultSet.is() )
368 uno::Reference< ucb::XContentAccess > xContentAccess( xResultSet, uno::UNO_QUERY );
370 if( xContentAccess.is() )
372 static const char s_sTitle[] =
"Title";
373 static const char s_sIsReadOnly[] =
"IsReadOnly";
375 while( xResultSet->next() )
377 INetURLObject aThmURL( xContentAccess->queryContentIdentifierString() );
379 if (aThmURL.GetFileExtension().equalsIgnoreAsciiCase(
"thm"))
395 catch(
const uno::RuntimeException& )
398 catch(
const uno::Exception& )
402 if( !aTitle.isEmpty() )
408 aThmCnt.getPropertyValue( s_sIsReadOnly ) >>=
bReadOnly;
410 catch(
const uno::RuntimeException& )
413 catch(
const uno::Exception& )
421 aSdgCnt.getPropertyValue( s_sTitle ) >>= aTitle;
423 catch(
const css::uno::RuntimeException& )
426 catch(
const css::uno::Exception& )
430 if( !aTitle.isEmpty() )
434 aSdgCnt.getPropertyValue( s_sIsReadOnly ) >>=
bReadOnly;
436 catch(
const uno::RuntimeException& )
439 catch(
const uno::Exception& )
449 aSdvCnt.getPropertyValue( s_sTitle ) >>= aTitle;
451 catch(
const css::uno::RuntimeException& )
454 catch(
const css::uno::Exception& )
458 if( !aTitle.isEmpty() )
462 aSdvCnt.getPropertyValue( s_sIsReadOnly ) >>=
bReadOnly;
464 catch(
const uno::RuntimeException& )
467 catch(
const uno::Exception& )
479 catch(
const ucb::ContentCreationException& )
482 catch(
const uno::RuntimeException& )
485 catch(
const uno::Exception& )
493 catch(
const ucb::ContentCreationException& )
496 catch(
const uno::RuntimeException& )
499 catch(
const uno::Exception& )
506 if( !rThemeName.isEmpty() )
523 if( nThemeId == pEntry->
GetId() )
535 aFallback =
SvxResId(RID_GALLERYSTR_THEME_3D);
538 aFallback =
SvxResId(RID_GALLERYSTR_THEME_BULLETS);
541 aFallback =
SvxResId(RID_GALLERYSTR_THEME_HOMEPAGE);
553 aFallback =
SvxResId(RID_GALLERYSTR_THEME_SOUNDS);
556 aFallback =
SvxResId(RID_GALLERYSTR_THEME_ARROWS);
559 aFallback =
SvxResId(RID_GALLERYSTR_THEME_COMPUTERS);
562 aFallback =
SvxResId(RID_GALLERYSTR_THEME_DIAGRAMS);
565 aFallback =
SvxResId(RID_GALLERYSTR_THEME_EDUCATION);
568 aFallback =
SvxResId(RID_GALLERYSTR_THEME_ENVIRONMENT);
571 aFallback =
SvxResId(RID_GALLERYSTR_THEME_FINANCE);
574 aFallback =
SvxResId(RID_GALLERYSTR_THEME_PEOPLE);
577 aFallback =
SvxResId(RID_GALLERYSTR_THEME_SYMBOLS);
580 aFallback =
SvxResId(RID_GALLERYSTR_THEME_TRANSPORT);
583 aFallback =
SvxResId(RID_GALLERYSTR_THEME_TXTSHAPES);
604 if( !
HasTheme( rThemeName ) && (
GetUserURL().GetProtocol() != INetProtocol::NotValid ) )
607 aURL.
Append( rThemeName );
609 true, aURL, rThemeName,
610 false,
true, 0,
false );
633 pThemeEntry->
SetName( rNewName );
647 if( pThemeEntry && !pThemeEntry->
IsReadOnly() )
670 [&pThemeEntry](
const std::unique_ptr<GalleryThemeEntry>& rpEntry) {
return pThemeEntry == rpEntry.get(); });
691 pTheme = (*it)->GetTheme();
699 std::unique_ptr<GalleryTheme> pNewTheme;
708 pNewTheme.reset(
new GalleryTheme(
this, const_cast<GalleryThemeEntry*>(pThemeEntry) ) );
711 if( pIStm->GetError() )
714 catch (
const css::ucb::ContentCreationException&)
#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
GalleryTheme * AcquireTheme(const OUString &rThemeName, SfxListener &rListener)
#define GALLERY_THEME_BULLETS
#define RID_GALLERY_THEME_TRANSPORT
#define RID_GALLERY_THEME_INTERACTION
#define RID_GALLERYSTR_THEME_FONTWORK
static SAL_DLLPRIVATE GalleryThemeEntry * CreateThemeEntry(const INetURLObject &rURL, bool bReadOnly)
#define RID_GALLERY_THEME_PEOPLE
OUString GetURLPath(DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
const INetURLObject & GetSdgURL() 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
#define RID_GALLERY_THEME_SURFACES
#define RID_GALLERY_THEME_NAVIGATION
#define RID_GALLERY_THEME_PRESENTATION
#define GALLERY_THEME_RULERS
#define RID_GALLERY_THEME_ENVIRONMENT
#define RID_GALLERY_THEME_3D
SAL_DLLPRIVATE OUString GetThemeName(sal_uInt32 nThemeId) const
#define RID_GALLERY_THEME_COMPUTER
bool setName(OUString const &rTheName, EncodeMechanism eMechanism=EncodeMechanism::WasEncoded, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
GalleryThemeEntry * ImplGetThemeEntry(const OUString &rThemeName)
SvStream & ReadGalleryTheme(SvStream &rIn, GalleryTheme &rTheme)
#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)
bool setExtension(OUString const &rTheExtension, sal_Int32 nIndex=LAST_SEGMENT, bool bIgnoreFinalSlash=true, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
OUString SvxResId(const char *pId)
SAL_DLLPRIVATE 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)
bool bThemeNameFromResource
#define RID_GALLERYSTR_THEME_HTMLBUTTONS
bool RemoveTheme(const OUString &rThemeName)
SAL_DLLPRIVATE const INetURLObject & GetStrURL() const
#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
OUString getName(sal_Int32 nIndex=LAST_SEGMENT, bool bIgnoreFinalSlash=true, DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
const std::pair< sal_uInt16, const char * > aLocalized[]
SAL_DLLPRIVATE void ImplWrite()
#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
bool HasTheme(const OUString &rThemeName)
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
#define RID_GALLERY_THEME_ARROWS
void Broadcast(const SfxHint &rHint)
void ReleaseTheme(GalleryTheme *pTheme, SfxListener &rListener)
void SetName(const OUString &rNewName)
const std::pair< sal_uInt16, const char * > aUnlocalized[]
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
static INetURLObject ImplGetURLIgnoreCase(const INetURLObject &rURL)
SAL_DLLPRIVATE const INetURLObject & GetThmURL() const
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
void SAL_CALL first(const css::awt::SpinEvent &rEvent) override
OUString ReadStrFromIni(const OUString &aKeyName)
void append_text(const OUString &rStr)
const OUString & GetName() const
#define GALLERY_THEME_FONTWORK_VERTICAL
virtual ~Gallery() override
bool CreateTheme(const OUString &rThemeName)
#define RID_GALLERY_THEME_MYTHEME
#define RID_GALLERY_THEME_SCREENBEANS
#define GALLERY_THEME_MYTHEME
static bool FileExists(const INetURLObject &rURL, const OUString &rExt)
#define GALLERY_THEME_DUMMY5
#define GALLERY_THEME_HOMEPAGE
SAL_DLLPRIVATE GalleryTheme * ImplGetCachedTheme(const GalleryThemeEntry *pThemeEntry)
const OUString & GetThemeName() const
#define RID_GALLERY_THEME_FINANCES
SAL_DLLPRIVATE const INetURLObject & GetSdvURL() const
std::vector< std::unique_ptr< GalleryThemeEntry > > aThemeList
const INetURLObject & GetThmURL() const