[Libreoffice-commits] core.git: include/svx svx/source

Aditya (via logerrit) logerrit at kemper.freedesktop.org
Mon Jun 15 10:15:14 UTC 2020


 include/svx/gallery1.hxx                    |    4 --
 include/svx/gallerybinaryengine.hxx         |    6 +++
 svx/source/gallery2/galini.cxx              |    4 +-
 svx/source/gallery2/gallery1.cxx            |   39 +--------------------
 svx/source/gallery2/gallerybinaryengine.cxx |   50 +++++++++++++++++++++++++---
 5 files changed, 55 insertions(+), 48 deletions(-)

New commits:
commit d570062ff9899e78553bfbe412bdf88ff62a5396
Author:     Aditya <adityasahu1511 at gmail.com>
AuthorDate: Sat Jun 13 15:28:27 2020 +0530
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Mon Jun 15 12:14:38 2020 +0200

    svx:move functions from GalleryThemeEntry to GalleryBinaryEngine
    
    These functions deal with reading and writing of binary files. They need to be
     moved because code is being refactored. This change should not result in any
     change in the external behaviour.
    
    Change-Id: Ib21f8df8d1f038993af4f7142cac5a25f0eac87e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96253
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/include/svx/gallery1.hxx b/include/svx/gallery1.hxx
index f25128955b5b..0cb9700f5462 100644
--- a/include/svx/gallery1.hxx
+++ b/include/svx/gallery1.hxx
@@ -50,8 +50,6 @@ public:
                                                bool bReadOnly, bool bNewFile,
                                                sal_uInt32 nId, bool bThemeNameFromResource );
 
-    static INetURLObject    ImplGetURLIgnoreCase(const INetURLObject& rURL);
-
     const OUString&         GetThemeName() const { return aName; }
 
     const INetURLObject&    GetThmURL() const { return maGalleryBinaryEngine.GetThmURL(); }
@@ -59,8 +57,6 @@ public:
     const INetURLObject&    GetSdvURL() const { return maGalleryBinaryEngine.GetSdvURL(); }
     const INetURLObject&    GetStrURL() const { return maGalleryBinaryEngine.GetStrURL(); }
 
-    OUString                ReadStrFromIni(const OUString &aKeyName );
-
     bool                    IsReadOnly() const { return bReadOnly; }
     bool                    IsDefault() const;
 
diff --git a/include/svx/gallerybinaryengine.hxx b/include/svx/gallerybinaryengine.hxx
index 7ce4ff471ecd..15aa8957d510 100644
--- a/include/svx/gallerybinaryengine.hxx
+++ b/include/svx/gallerybinaryengine.hxx
@@ -30,7 +30,13 @@ private:
     INetURLObject aSdvURL;
     INetURLObject aStrURL;
 
+    static INetURLObject ImplGetURLIgnoreCase(const INetURLObject& rURL);
+
 public:
+    static void CreateUniqueURL(const INetURLObject& rBaseURL, INetURLObject& aURL);
+
+    OUString ReadStrFromIni(const OUString& aKeyName);
+
     void SetThmExtension(INetURLObject aURL);
     void SetSdgExtension(INetURLObject aURL);
     void SetSdvExtension(INetURLObject aURL);
diff --git a/svx/source/gallery2/galini.cxx b/svx/source/gallery2/galini.cxx
index 55c19161bca2..22f3aaff515c 100644
--- a/svx/source/gallery2/galini.cxx
+++ b/svx/source/gallery2/galini.cxx
@@ -17,13 +17,13 @@
 #include <sal/log.hxx>
 
 #include <unotools/ucbstreamhelper.hxx>
-#include <svx/gallery1.hxx>
+#include <svx/gallerybinaryengine.hxx>
 #include <i18nlangtag/languagetag.hxx>
 #include <vcl/svapp.hxx>
 #include <vcl/settings.hxx>
 #include <memory>
 
-OUString GalleryThemeEntry::ReadStrFromIni(const OUString &aKeyName )
+OUString GalleryBinaryEngine::ReadStrFromIni(const OUString &aKeyName )
 {
     std::unique_ptr<SvStream> pStrm(::utl::UcbStreamHelper::CreateStream(
                                 GetStrURL().GetMainURL( INetURLObject::DecodeMechanism::NONE ),
diff --git a/svx/source/gallery2/gallery1.cxx b/svx/source/gallery2/gallery1.cxx
index 7a5fd36761be..a7c86c3ef9a3 100644
--- a/svx/source/gallery2/gallery1.cxx
+++ b/svx/source/gallery2/gallery1.cxx
@@ -51,13 +51,6 @@
 using namespace ::com::sun::star;
 
 
-static bool FileExists( const INetURLObject &rURL, const OUString &rExt )
-{
-    INetURLObject aURL( rURL );
-    aURL.setExtension( rExt );
-    return FileExists( aURL );
-}
-
 const std::pair<sal_uInt16, const char*> aUnlocalized[] =
 {
     { GALLERY_THEME_HOMEPAGE, RID_GALLERYSTR_THEME_HTMLBUTTONS },
@@ -126,15 +119,7 @@ GalleryThemeEntry::GalleryThemeEntry( bool bCreateUniqueURL,
 
     if (bCreateUniqueURL)
     {
-        INetURLObject aBaseNoCase( ImplGetURLIgnoreCase( rBaseURL ) );
-        aURL = aBaseNoCase;
-        static sal_Int32 nIdx = 0;
-        while( FileExists( aURL, "thm" ) )
-        { // create new URLs
-            nIdx++;
-            aURL = aBaseNoCase;
-            aURL.setName( aURL.getName() + OUString::number(nIdx));
-        }
+        GalleryBinaryEngine::CreateUniqueURL(rBaseURL,aURL);
     }
 
     maGalleryBinaryEngine.SetThmExtension(aURL);
@@ -144,7 +129,7 @@ GalleryThemeEntry::GalleryThemeEntry( bool bCreateUniqueURL,
 
     SetModified( _bNewFile );
 
-    aName = ReadStrFromIni( "name" );
+    aName = maGalleryBinaryEngine.ReadStrFromIni( "name" );
 
     // This is awful - we shouldn't use these resources if we
     // possibly can avoid them
@@ -187,26 +172,6 @@ void GalleryTheme::InsertAllThemes(weld::ComboBox& rListBox)
         rListBox.append_text(SvxResId(aLocalized[i].second));
 }
 
-INetURLObject GalleryThemeEntry::ImplGetURLIgnoreCase( const INetURLObject& rURL )
-{
-    INetURLObject   aURL( rURL );
-
-    // check original file name
-    if( !FileExists( aURL ) )
-    {
-        // check upper case file name
-        aURL.setName( aURL.getName().toAsciiUpperCase() );
-
-        if(!FileExists( aURL ) )
-        {
-            // check lower case file name
-            aURL.setName( aURL.getName().toAsciiLowerCase() );
-        }
-    }
-
-    return aURL;
-}
-
 void GalleryThemeEntry::SetName( const OUString& rNewName )
 {
     if( aName != rNewName )
diff --git a/svx/source/gallery2/gallerybinaryengine.cxx b/svx/source/gallery2/gallerybinaryengine.cxx
index 201ed1209530..0e08359909c2 100644
--- a/svx/source/gallery2/gallerybinaryengine.cxx
+++ b/svx/source/gallery2/gallerybinaryengine.cxx
@@ -18,30 +18,70 @@
  */
 
 #include <svx/gallerybinaryengine.hxx>
-#include <svx/gallery1.hxx>
+#include <svx/galmisc.hxx>
 
 #include <tools/urlobj.hxx>
 
+static bool FileExists(const INetURLObject& rURL, const OUString& rExt)
+{
+    INetURLObject aURL(rURL);
+    aURL.setExtension(rExt);
+    return FileExists(aURL);
+}
+
+INetURLObject GalleryBinaryEngine::ImplGetURLIgnoreCase(const INetURLObject& rURL)
+{
+    INetURLObject aURL(rURL);
+
+    // check original file name
+    if (!FileExists(aURL))
+    {
+        // check upper case file name
+        aURL.setName(aURL.getName().toAsciiUpperCase());
+
+        if (!FileExists(aURL))
+        {
+            // check lower case file name
+            aURL.setName(aURL.getName().toAsciiLowerCase());
+        }
+    }
+
+    return aURL;
+}
+
+void GalleryBinaryEngine::CreateUniqueURL(const INetURLObject& rBaseURL, INetURLObject& aURL)
+{
+    INetURLObject aBaseNoCase(ImplGetURLIgnoreCase(rBaseURL));
+    aURL = aBaseNoCase;
+    static sal_Int32 nIdx = 0;
+    while (FileExists(aURL, "thm"))
+    { // create new URLs
+        nIdx++;
+        aURL = aBaseNoCase;
+        aURL.setName(aURL.getName() + OUString::number(nIdx));
+    }
+}
+
 void GalleryBinaryEngine::SetThmExtension(INetURLObject aURL)
 {
     aURL.setExtension("thm");
-    aThmURL = GalleryThemeEntry::ImplGetURLIgnoreCase(aURL);
+    aThmURL = ImplGetURLIgnoreCase(aURL);
 }
 
 void GalleryBinaryEngine::SetSdgExtension(INetURLObject aURL)
 {
     aURL.setExtension("sdg");
-    aSdgURL = GalleryThemeEntry::ImplGetURLIgnoreCase(aURL);
+    aSdgURL = ImplGetURLIgnoreCase(aURL);
 }
 
 void GalleryBinaryEngine::SetSdvExtension(INetURLObject aURL)
 {
     aURL.setExtension("sdv");
-    aSdvURL = GalleryThemeEntry::ImplGetURLIgnoreCase(aURL);
+    aSdvURL = ImplGetURLIgnoreCase(aURL);
 }
 
 void GalleryBinaryEngine::SetStrExtension(INetURLObject aURL)
 {
     aURL.setExtension("str");
-    aStrURL = GalleryThemeEntry::ImplGetURLIgnoreCase(aURL);
+    aStrURL = ImplGetURLIgnoreCase(aURL);
 }


More information about the Libreoffice-commits mailing list