Kaydet (Commit) 8a3eab7b authored tarafından Michael Meeks's avatar Michael Meeks

gallery: fix hideous theme numbering / naming situation.

Change-Id: Ibe288e5b2e782da4dd5804a7e018d8ae85c156cc
üst 22ca7c45
...@@ -38,11 +38,10 @@ class GalleryThemeEntry ...@@ -38,11 +38,10 @@ class GalleryThemeEntry
{ {
private: private:
OUString aName; OUString aName;
INetURLObject aThmURL; INetURLObject aThmURL;
INetURLObject aSdgURL; INetURLObject aSdgURL;
INetURLObject aSdvURL; INetURLObject aSdvURL;
sal_uInt32 nFileNumber;
sal_uInt32 nId; sal_uInt32 nId;
sal_Bool bReadOnly; sal_Bool bReadOnly;
sal_Bool bModified; sal_Bool bModified;
...@@ -54,12 +53,11 @@ private: ...@@ -54,12 +53,11 @@ private:
public: public:
GalleryThemeEntry( const INetURLObject& rBaseURL, const String& rName, GalleryThemeEntry( const INetURLObject& rBaseURL, const String& rName,
sal_uInt32 nFileNumber, sal_Bool bReadOnly, sal_Bool bReadOnly, sal_Bool bNewFile,
sal_Bool bNewFile, sal_uInt32 nId, sal_Bool bThemeNameFromResource ); sal_uInt32 nId, sal_Bool bThemeNameFromResource );
~GalleryThemeEntry() {}; ~GalleryThemeEntry() {};
const OUString& GetThemeName() const { return aName; } const OUString& GetThemeName() const { return aName; }
sal_uInt32 GetFileNumber() const { return nFileNumber; }
const INetURLObject& GetThmURL() const { return aThmURL; } const INetURLObject& GetThmURL() const { return aThmURL; }
const INetURLObject& GetSdgURL() const { return aSdgURL; } const INetURLObject& GetSdgURL() const { return aSdgURL; }
...@@ -124,8 +122,7 @@ private: ...@@ -124,8 +122,7 @@ private:
INetURLObject aRelURL; INetURLObject aRelURL;
INetURLObject aUserURL; INetURLObject aUserURL;
rtl_TextEncoding nReadTextEncoding; rtl_TextEncoding nReadTextEncoding;
sal_uIntPtr nLastFileNumber; sal_Bool bMultiPath;
sal_Bool bMultiPath;
void ImplLoad( const OUString& rMultiPath ); void ImplLoad( const OUString& rMultiPath );
void ImplLoadSubDirs( const INetURLObject& rBaseURL, sal_Bool& rbIsReadOnly ); void ImplLoadSubDirs( const INetURLObject& rBaseURL, sal_Bool& rbIsReadOnly );
...@@ -151,7 +148,7 @@ public: ...@@ -151,7 +148,7 @@ public:
SVX_DLLPUBLIC sal_Bool HasTheme( const String& rThemeName ); SVX_DLLPUBLIC sal_Bool HasTheme( const String& rThemeName );
OUString GetThemeName( sal_uIntPtr nThemeId ) const; OUString GetThemeName( sal_uIntPtr nThemeId ) const;
SVX_DLLPUBLIC sal_Bool CreateTheme( const String& rThemeName, sal_uInt32 nNumFrom = 0 ); SVX_DLLPUBLIC sal_Bool CreateTheme( const String& rThemeName );
sal_Bool RenameTheme( const String& rOldName, const String& rNewName ); sal_Bool RenameTheme( const String& rOldName, const String& rNewName );
SVX_DLLPUBLIC sal_Bool RemoveTheme( const String& rThemeName ); SVX_DLLPUBLIC sal_Bool RemoveTheme( const String& rThemeName );
......
...@@ -46,24 +46,22 @@ using namespace ::com::sun::star; ...@@ -46,24 +46,22 @@ using namespace ::com::sun::star;
// --------------------- // ---------------------
GalleryThemeEntry::GalleryThemeEntry( const INetURLObject& rBaseURL, const String& rName, GalleryThemeEntry::GalleryThemeEntry( const INetURLObject& rBaseURL, const String& rName,
sal_uInt32 _nFileNumber, sal_Bool _bReadOnly, sal_Bool _bReadOnly, sal_Bool _bNewFile,
sal_Bool _bNewFile, sal_uInt32 _nId, sal_Bool _bThemeNameFromResource ) : sal_uInt32 _nId, sal_Bool _bThemeNameFromResource ) :
nFileNumber ( _nFileNumber ),
nId ( _nId ), nId ( _nId ),
bReadOnly ( _bReadOnly ), bReadOnly ( _bReadOnly ),
bThemeNameFromResource ( _bThemeNameFromResource ) bThemeNameFromResource ( _bThemeNameFromResource )
{ {
INetURLObject aURL( rBaseURL ); INetURLObject aURL( rBaseURL );
DBG_ASSERT( aURL.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" ); DBG_ASSERT( aURL.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" );
String aFileName( String( "sg" ) );
aURL.Append( ( aFileName += OUString::number( nFileNumber ) ) += String( RTL_CONSTASCII_USTRINGPARAM( ".thm" ) ) ); aURL.setExtension( "thm" );
aThmURL = ImplGetURLIgnoreCase( aURL ); aThmURL = ImplGetURLIgnoreCase( aURL );
aURL.setExtension( String( RTL_CONSTASCII_USTRINGPARAM( "sdg" ) ) ); aURL.setExtension( "sdg" );
aSdgURL = ImplGetURLIgnoreCase( aURL ); aSdgURL = ImplGetURLIgnoreCase( aURL );
aURL.setExtension( String( RTL_CONSTASCII_USTRINGPARAM( "sdv" ) ) ); aURL.setExtension( "sdv" );
aSdvURL = ImplGetURLIgnoreCase( aURL ); aSdvURL = ImplGetURLIgnoreCase( aURL );
SetModified( _bNewFile ); SetModified( _bNewFile );
...@@ -172,7 +170,6 @@ public: ...@@ -172,7 +170,6 @@ public:
Gallery::Gallery( const OUString& rMultiPath ) Gallery::Gallery( const OUString& rMultiPath )
: nReadTextEncoding ( osl_getThreadTextEncoding() ) : nReadTextEncoding ( osl_getThreadTextEncoding() )
, nLastFileNumber ( 0 )
, bMultiPath ( sal_False ) , bMultiPath ( sal_False )
{ {
ImplLoad( rMultiPath ); ImplLoad( rMultiPath );
...@@ -406,14 +403,7 @@ void Gallery::ImplLoadSubDirs( const INetURLObject& rBaseURL, sal_Bool& rbDirIsR ...@@ -406,14 +403,7 @@ void Gallery::ImplLoadSubDirs( const INetURLObject& rBaseURL, sal_Bool& rbDirIsR
GalleryThemeEntry* pEntry = GalleryTheme::CreateThemeEntry( aThmURL, rbDirIsReadOnly || bReadOnly ); GalleryThemeEntry* pEntry = GalleryTheme::CreateThemeEntry( aThmURL, rbDirIsReadOnly || bReadOnly );
if( pEntry ) if( pEntry )
{
const sal_uIntPtr nFileNumber = (sal_uIntPtr) String(aThmURL.GetBase()).Erase( 0, 2 ).Erase( 6 ).ToInt32();
aThemeList.push_back( pEntry ); aThemeList.push_back( pEntry );
if( nFileNumber > nLastFileNumber )
nLastFileNumber = nFileNumber;
}
} }
} }
catch( const ucb::ContentCreationException& ) catch( const ucb::ContentCreationException& )
...@@ -547,15 +537,15 @@ sal_Bool Gallery::HasTheme( const String& rThemeName ) ...@@ -547,15 +537,15 @@ sal_Bool Gallery::HasTheme( const String& rThemeName )
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
sal_Bool Gallery::CreateTheme( const String& rThemeName, sal_uInt32 nNumFrom ) sal_Bool Gallery::CreateTheme( const String& rThemeName )
{ {
sal_Bool bRet = sal_False; sal_Bool bRet = sal_False;
if( !HasTheme( rThemeName ) && ( GetUserURL().GetProtocol() != INET_PROT_NOT_VALID ) ) if( !HasTheme( rThemeName ) && ( GetUserURL().GetProtocol() != INET_PROT_NOT_VALID ) )
{ {
nLastFileNumber = nNumFrom > nLastFileNumber ? nNumFrom : nLastFileNumber + 1; INetURLObject aURL( GetUserURL() );
GalleryThemeEntry* pNewEntry = new GalleryThemeEntry( GetUserURL(), rThemeName, aURL.Append( rThemeName );
nLastFileNumber, GalleryThemeEntry* pNewEntry = new GalleryThemeEntry( aURL, rThemeName,
sal_False, sal_True, 0, sal_False ); sal_False, sal_True, 0, sal_False );
aThemeList.push_back( pNewEntry ); aThemeList.push_back( pNewEntry );
......
...@@ -751,11 +751,7 @@ GalleryThemeEntry* GalleryTheme::CreateThemeEntry( const INetURLObject& rURL, sa ...@@ -751,11 +751,7 @@ GalleryThemeEntry* GalleryTheme::CreateThemeEntry( const INetURLObject& rURL, sa
} }
INetURLObject aPathURL( rURL ); INetURLObject aPathURL( rURL );
aPathURL.removeSegment();
aPathURL.removeFinalSlash();
pRet = new GalleryThemeEntry( aPathURL, aThemeName, pRet = new GalleryThemeEntry( aPathURL, aThemeName,
String(rURL.GetBase()).Copy( 2, 6 ).ToInt32(),
bReadOnly, sal_False, nThemeId, bReadOnly, sal_False, nThemeId,
bThemeNameFromResource ); bThemeNameFromResource );
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment