include/svx/gallery1.hxx | 19 +++++------ include/svx/gallerybinaryengine.hxx | 45 ++++++++++++++++++++++++++ svx/Library_svxcore.mk | 1 svx/source/gallery2/gallery1.cxx | 16 ++------- svx/source/gallery2/gallerybinaryengine.cxx | 47 ++++++++++++++++++++++++++++ 5 files changed, 107 insertions(+), 21 deletions(-)
New commits: commit e0c9ed26b982813a3f26e350b25caec395d44653 Author: Aditya <adityasahu1...@gmail.com> AuthorDate: Wed Jun 10 14:52:20 2020 +0530 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Sat Jun 13 10:50:28 2020 +0200 svx: Gallery code refactoring Older classes like Gallery, GalleryTheme, GalleryThemeEntry have reading and writing data members and member functions included in the classes which makes the code unclear and less organized. Introduce new class Gallery Binary Engine that would deal with these member functions in such a way that older classes will have no knowledge about reading and writing. Only change the internal structure of the project and no change in behaviour of output must be there. Change-Id: Ia05eb3c692976b775a3d00e7d09fecc861bced2f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95922 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/include/svx/gallery1.hxx b/include/svx/gallery1.hxx index aa3e986f9e78..f25128955b5b 100644 --- a/include/svx/gallery1.hxx +++ b/include/svx/gallery1.hxx @@ -24,28 +24,25 @@ #include <svl/SfxBroadcaster.hxx> #include <svx/svxdllapi.h> #include <tools/urlobj.hxx> +#include <svx/gallerybinaryengine.hxx> #include <cstdio> #include <memory> #include <vector> +class GalleryBinaryEngine; class GalleryThemeEntry { private: + GalleryBinaryEngine maGalleryBinaryEngine; OUString aName; - INetURLObject aThmURL; - INetURLObject aSdgURL; - INetURLObject aSdvURL; - INetURLObject aStrURL; sal_uInt32 nId; bool bReadOnly; bool bModified; bool bThemeNameFromResource; - static INetURLObject ImplGetURLIgnoreCase( const INetURLObject& rURL ); - public: GalleryThemeEntry( bool bCreateUniqueURL, const INetURLObject& rBaseURL, @@ -53,12 +50,14 @@ 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 aThmURL; } - const INetURLObject& GetSdgURL() const { return aSdgURL; } - const INetURLObject& GetSdvURL() const { return aSdvURL; } - const INetURLObject& GetStrURL() const { return aStrURL; } + const INetURLObject& GetThmURL() const { return maGalleryBinaryEngine.GetThmURL(); } + const INetURLObject& GetSdgURL() const { return maGalleryBinaryEngine.GetSdgURL(); } + const INetURLObject& GetSdvURL() const { return maGalleryBinaryEngine.GetSdvURL(); } + const INetURLObject& GetStrURL() const { return maGalleryBinaryEngine.GetStrURL(); } OUString ReadStrFromIni(const OUString &aKeyName ); diff --git a/include/svx/gallerybinaryengine.hxx b/include/svx/gallerybinaryengine.hxx new file mode 100755 index 000000000000..7ce4ff471ecd --- /dev/null +++ b/include/svx/gallerybinaryengine.hxx @@ -0,0 +1,45 @@ +/* -*- 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 . + */ + +#pragma once + +#include <tools/urlobj.hxx> +#include <svx/svxdllapi.h> + +class SVXCORE_DLLPUBLIC GalleryBinaryEngine +{ +private: + INetURLObject aThmURL; + INetURLObject aSdgURL; + INetURLObject aSdvURL; + INetURLObject aStrURL; + +public: + void SetThmExtension(INetURLObject aURL); + void SetSdgExtension(INetURLObject aURL); + void SetSdvExtension(INetURLObject aURL); + void SetStrExtension(INetURLObject aURL); + + const INetURLObject& GetThmURL() const { return aThmURL; } + const INetURLObject& GetSdgURL() const { return aSdgURL; } + const INetURLObject& GetSdvURL() const { return aSdvURL; } + const INetURLObject& GetStrURL() const { return aStrURL; } +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/Library_svxcore.mk b/svx/Library_svxcore.mk index cf23b824ca3e..430b35e9299c 100644 --- a/svx/Library_svxcore.mk +++ b/svx/Library_svxcore.mk @@ -152,6 +152,7 @@ $(eval $(call gb_Library_add_exception_objects,svxcore,\ svx/source/gallery2/galobj \ svx/source/gallery2/galtheme \ svx/source/gallery2/GalleryControl \ + svx/source/gallery2/gallerybinaryengine \ svx/source/items/chrtitem \ svx/source/items/clipfmtitem \ svx/source/items/customshapeitem \ diff --git a/svx/source/gallery2/gallery1.cxx b/svx/source/gallery2/gallery1.cxx index 685f3d99df5e..7a5fd36761be 100644 --- a/svx/source/gallery2/gallery1.cxx +++ b/svx/source/gallery2/gallery1.cxx @@ -41,6 +41,7 @@ #include <svx/galmisc.hxx> #include <svx/galtheme.hxx> #include <svx/gallery1.hxx> +#include <svx/gallerybinaryengine.hxx> #include <vcl/weld.hxx> #include <com/sun/star/sdbc/XResultSet.hpp> #include <com/sun/star/ucb/XContentAccess.hpp> @@ -136,17 +137,10 @@ GalleryThemeEntry::GalleryThemeEntry( bool bCreateUniqueURL, } } - aURL.setExtension( "thm" ); - aThmURL = ImplGetURLIgnoreCase( aURL ); - - aURL.setExtension( "sdg" ); - aSdgURL = ImplGetURLIgnoreCase( aURL ); - - aURL.setExtension( "sdv" ); - aSdvURL = ImplGetURLIgnoreCase( aURL ); - - aURL.setExtension( "str" ); - aStrURL = ImplGetURLIgnoreCase( aURL ); + maGalleryBinaryEngine.SetThmExtension(aURL); + maGalleryBinaryEngine.SetSdgExtension(aURL); + maGalleryBinaryEngine.SetSdvExtension(aURL); + maGalleryBinaryEngine.SetStrExtension(aURL); SetModified( _bNewFile ); diff --git a/svx/source/gallery2/gallerybinaryengine.cxx b/svx/source/gallery2/gallerybinaryengine.cxx new file mode 100755 index 000000000000..201ed1209530 --- /dev/null +++ b/svx/source/gallery2/gallerybinaryengine.cxx @@ -0,0 +1,47 @@ +/* -*- 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/gallerybinaryengine.hxx> +#include <svx/gallery1.hxx> + +#include <tools/urlobj.hxx> + +void GalleryBinaryEngine::SetThmExtension(INetURLObject aURL) +{ + aURL.setExtension("thm"); + aThmURL = GalleryThemeEntry::ImplGetURLIgnoreCase(aURL); +} + +void GalleryBinaryEngine::SetSdgExtension(INetURLObject aURL) +{ + aURL.setExtension("sdg"); + aSdgURL = GalleryThemeEntry::ImplGetURLIgnoreCase(aURL); +} + +void GalleryBinaryEngine::SetSdvExtension(INetURLObject aURL) +{ + aURL.setExtension("sdv"); + aSdvURL = GalleryThemeEntry::ImplGetURLIgnoreCase(aURL); +} + +void GalleryBinaryEngine::SetStrExtension(INetURLObject aURL) +{ + aURL.setExtension("str"); + aStrURL = GalleryThemeEntry::ImplGetURLIgnoreCase(aURL); +} _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits