diff options
author | Aditya <adityasahu1511@gmail.com> | 2020-08-27 11:42:16 +0530 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2020-09-04 21:58:30 +0200 |
commit | 86099e6ec0a2ae72c560c5f2d8b2c3e482ce2e60 (patch) | |
tree | 59c60978c285beff235440277edd8322643a1937 /svx | |
parent | b1a8b0e5327d823da34050e382f7a2838c262881 (diff) |
svx: Introduce GalleryBinaryStorageLocations
Make GalleryStorageLocations abstract superclass of
GalleryBinaryStorageLocations and upcoming GalleryXMLStorageLocations.
Change-Id: Iccd53b723a4495e0d93ab5e3306f899ec41705f8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101434
Tested-by: Tomaž Vajngerl <quikee@gmail.com>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/Library_svxcore.mk | 1 | ||||
-rw-r--r-- | svx/source/gallery2/gallery1.cxx | 11 | ||||
-rw-r--r-- | svx/source/gallery2/gallerybinaryengine.cxx | 8 | ||||
-rw-r--r-- | svx/source/gallery2/gallerybinaryengineentry.cxx | 4 | ||||
-rw-r--r-- | svx/source/gallery2/gallerybinarystoragelocations.cxx | 75 | ||||
-rw-r--r-- | svx/source/gallery2/gallerystoragelocations.cxx | 53 | ||||
-rw-r--r-- | svx/source/gallery2/galtheme.cxx | 2 |
7 files changed, 93 insertions, 61 deletions
diff --git a/svx/Library_svxcore.mk b/svx/Library_svxcore.mk index c5a54708a70a..3d4590d216a1 100644 --- a/svx/Library_svxcore.mk +++ b/svx/Library_svxcore.mk @@ -155,6 +155,7 @@ $(eval $(call gb_Library_add_exception_objects,svxcore,\ svx/source/gallery2/gallerybinaryengine \ svx/source/gallery2/gallerybinaryengineentry \ svx/source/gallery2/gallerystoragelocations \ + svx/source/gallery2/gallerybinarystoragelocations \ svx/source/gallery2/galleryobjectcollection \ svx/source/gallery2/galleryfilestorage \ svx/source/gallery2/galleryfilestorageentry \ diff --git a/svx/source/gallery2/gallery1.cxx b/svx/source/gallery2/gallery1.cxx index 78f517f63868..aaa6b47ed918 100644 --- a/svx/source/gallery2/gallery1.cxx +++ b/svx/source/gallery2/gallery1.cxx @@ -122,8 +122,9 @@ GalleryThemeEntry::GalleryThemeEntry( bool bCreateUniqueURL, { GalleryBinaryEngineEntry::CreateUniqueURL(rBaseURL,aURL); } + mpGalleryStorageLocations = createGalleryStorageLocations(); mpGalleryStorageEngineEntry = createGalleryStorageEngineEntry(); - maGalleryStorageLocations.SetStorageLocations(aURL); + mpGalleryStorageLocations->SetStorageLocations(aURL); SetModified( _bNewFile ); @@ -163,10 +164,16 @@ GalleryThemeEntry::GalleryThemeEntry( bool bCreateUniqueURL, std::unique_ptr<GalleryBinaryEngineEntry> GalleryThemeEntry::createGalleryStorageEngineEntry() { - std::unique_ptr<GalleryBinaryEngineEntry> pGalleryBinaryEngineEntry = std::make_unique<GalleryBinaryEngineEntry>(maGalleryStorageLocations); + std::unique_ptr<GalleryBinaryEngineEntry> pGalleryBinaryEngineEntry = std::make_unique<GalleryBinaryEngineEntry>(dynamic_cast<GalleryBinaryStorageLocations&>(*mpGalleryStorageLocations)); return pGalleryBinaryEngineEntry; } +std::unique_ptr<GalleryStorageLocations> GalleryThemeEntry::createGalleryStorageLocations() +{ + std::unique_ptr<GalleryStorageLocations> pGalleryStorageLocations = std::make_unique<GalleryBinaryStorageLocations>(); + return pGalleryStorageLocations; +} + void GalleryTheme::InsertAllThemes(weld::ComboBox& rListBox) { for (size_t i = 0; i < SAL_N_ELEMENTS(aUnlocalized); ++i) diff --git a/svx/source/gallery2/gallerybinaryengine.cxx b/svx/source/gallery2/gallerybinaryengine.cxx index 298edd596001..eb740c5a0cff 100644 --- a/svx/source/gallery2/gallerybinaryengine.cxx +++ b/svx/source/gallery2/gallerybinaryengine.cxx @@ -50,10 +50,10 @@ using namespace ::com::sun::star; -GalleryBinaryEngine::GalleryBinaryEngine(const GalleryStorageLocations& rGalleryStorageLocations, - GalleryObjectCollection& rGalleryObjectCollection, - bool bReadOnly) - : maGalleryStorageLocations(rGalleryStorageLocations) +GalleryBinaryEngine::GalleryBinaryEngine( + const GalleryBinaryStorageLocations& rGalleryBinaryStorageLocations, + GalleryObjectCollection& rGalleryObjectCollection, bool bReadOnly) + : maGalleryStorageLocations(rGalleryBinaryStorageLocations) , mrGalleryObjectCollection(rGalleryObjectCollection) , mbReadOnly(bReadOnly) , m_bDestDirRelative(false) diff --git a/svx/source/gallery2/gallerybinaryengineentry.cxx b/svx/source/gallery2/gallerybinaryengineentry.cxx index 8255b2b8a276..1d669576dc98 100644 --- a/svx/source/gallery2/gallerybinaryengineentry.cxx +++ b/svx/source/gallery2/gallerybinaryengineentry.cxx @@ -42,14 +42,14 @@ static bool FileExists(const INetURLObject& rURL, const OUString& rExt) } GalleryBinaryEngineEntry::GalleryBinaryEngineEntry( - GalleryStorageLocations& rGalleryStorageLocations) + GalleryBinaryStorageLocations& rGalleryStorageLocations) : m_rGalleryStorageLocations(rGalleryStorageLocations) { } void GalleryBinaryEngineEntry::CreateUniqueURL(const INetURLObject& rBaseURL, INetURLObject& aURL) { - INetURLObject aBaseNoCase(GalleryStorageLocations::ImplGetURLIgnoreCase(rBaseURL)); + INetURLObject aBaseNoCase(GalleryBinaryStorageLocations::ImplGetURLIgnoreCase(rBaseURL)); aURL = aBaseNoCase; static sal_Int32 nIdx = 0; while (FileExists(aURL, "thm")) diff --git a/svx/source/gallery2/gallerybinarystoragelocations.cxx b/svx/source/gallery2/gallerybinarystoragelocations.cxx new file mode 100644 index 000000000000..cefb79d543a9 --- /dev/null +++ b/svx/source/gallery2/gallerybinarystoragelocations.cxx @@ -0,0 +1,75 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <svx/gallerybinarystoragelocations.hxx> +#include <svx/galmisc.hxx> + +INetURLObject GalleryBinaryStorageLocations::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 GalleryBinaryStorageLocations::SetThmExtension(INetURLObject& aURL) +{ + aURL.setExtension("thm"); + maThmURL = ImplGetURLIgnoreCase(aURL); +} + +void GalleryBinaryStorageLocations::SetSdgExtension(INetURLObject& aURL) +{ + aURL.setExtension("sdg"); + maSdgURL = ImplGetURLIgnoreCase(aURL); +} + +void GalleryBinaryStorageLocations::SetSdvExtension(INetURLObject& aURL) +{ + aURL.setExtension("sdv"); + maSdvURL = ImplGetURLIgnoreCase(aURL); +} + +void GalleryBinaryStorageLocations::SetStrExtension(INetURLObject& aURL) +{ + aURL.setExtension("str"); + maStrURL = ImplGetURLIgnoreCase(aURL); +} + +void GalleryBinaryStorageLocations::SetStorageLocations(INetURLObject& aURL) +{ + SetThmExtension(aURL); + SetSdgExtension(aURL); + SetSdvExtension(aURL); + SetStrExtension(aURL); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/gallery2/gallerystoragelocations.cxx b/svx/source/gallery2/gallerystoragelocations.cxx index cc427c8d16b4..d71ae452fd71 100644 --- a/svx/source/gallery2/gallerystoragelocations.cxx +++ b/svx/source/gallery2/gallerystoragelocations.cxx @@ -18,58 +18,7 @@ */ #include <svx/gallerystoragelocations.hxx> -#include <svx/galmisc.hxx> -INetURLObject GalleryStorageLocations::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 GalleryStorageLocations::SetThmExtension(INetURLObject& aURL) -{ - aURL.setExtension("thm"); - maThmURL = ImplGetURLIgnoreCase(aURL); -} - -void GalleryStorageLocations::SetSdgExtension(INetURLObject& aURL) -{ - aURL.setExtension("sdg"); - maSdgURL = ImplGetURLIgnoreCase(aURL); -} - -void GalleryStorageLocations::SetSdvExtension(INetURLObject& aURL) -{ - aURL.setExtension("sdv"); - maSdvURL = ImplGetURLIgnoreCase(aURL); -} - -void GalleryStorageLocations::SetStrExtension(INetURLObject& aURL) -{ - aURL.setExtension("str"); - maStrURL = ImplGetURLIgnoreCase(aURL); -} - -void GalleryStorageLocations::SetStorageLocations(INetURLObject& aURL) -{ - SetThmExtension(aURL); - SetSdgExtension(aURL); - SetSdvExtension(aURL); - SetStrExtension(aURL); -} +GalleryStorageLocations::~GalleryStorageLocations(){}; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/gallery2/galtheme.cxx b/svx/source/gallery2/galtheme.cxx index a25964afa1f3..c0fb25b430ce 100644 --- a/svx/source/gallery2/galtheme.cxx +++ b/svx/source/gallery2/galtheme.cxx @@ -96,7 +96,7 @@ void GalleryTheme::SetDestDir(const OUString& rDestDir, bool bRelative) std::unique_ptr<GalleryBinaryEngine> GalleryTheme::createGalleryStorageEngine(bool bReadOnly) { - std::unique_ptr<GalleryBinaryEngine> pGalleryBinaryEngine = std::make_unique<GalleryBinaryEngine>(pThm->getGalleryStorageLocations(), maGalleryObjectCollection, bReadOnly); + std::unique_ptr<GalleryBinaryEngine> pGalleryBinaryEngine = std::make_unique<GalleryBinaryEngine>(dynamic_cast<GalleryBinaryStorageLocations&>(*pThm->getGalleryStorageLocations()), maGalleryObjectCollection, bReadOnly); return pGalleryBinaryEngine; } |