summaryrefslogtreecommitdiff
path: root/svx/source/gallery2
diff options
context:
space:
mode:
authorAditya <adityasahu1511@gmail.com>2020-06-13 15:28:27 +0530
committerTomaž Vajngerl <quikee@gmail.com>2020-06-15 12:14:38 +0200
commitd570062ff9899e78553bfbe412bdf88ff62a5396 (patch)
tree10e959625106eb9c171a693f861cc4ed2d3d3f86 /svx/source/gallery2
parent749ec5a7914b7ad0ca716719168786b417883792 (diff)
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@gmail.com>
Diffstat (limited to 'svx/source/gallery2')
-rw-r--r--svx/source/gallery2/galini.cxx4
-rw-r--r--svx/source/gallery2/gallery1.cxx39
-rw-r--r--svx/source/gallery2/gallerybinaryengine.cxx50
3 files changed, 49 insertions, 44 deletions
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);
}