summaryrefslogtreecommitdiff
path: root/svx/source/gallery2
diff options
context:
space:
mode:
Diffstat (limited to 'svx/source/gallery2')
-rw-r--r--svx/source/gallery2/galini.cxx4
-rw-r--r--svx/source/gallery2/gallery1.cxx8
-rw-r--r--svx/source/gallery2/gallerybinaryengineentry.cxx181
-rw-r--r--svx/source/gallery2/galleryfilestorageentry.cxx159
4 files changed, 164 insertions, 188 deletions
diff --git a/svx/source/gallery2/galini.cxx b/svx/source/gallery2/galini.cxx
index 4eaf301d8edc..c88a7f4f2f8d 100644
--- a/svx/source/gallery2/galini.cxx
+++ b/svx/source/gallery2/galini.cxx
@@ -17,14 +17,14 @@
#include <sal/log.hxx>
#include <unotools/ucbstreamhelper.hxx>
-#include <gallerybinaryengineentry.hxx>
+#include <galleryfilestorageentry.hxx>
#include <i18nlangtag/languagetag.hxx>
#include <vcl/svapp.hxx>
#include <vcl/settings.hxx>
#include <o3tl/string_view.hxx>
#include <memory>
-OUString GalleryBinaryEngineEntry::ReadStrFromIni(std::u16string_view aKeyName ) const
+OUString GalleryFileStorageEntry::ReadStrFromIni(std::u16string_view aKeyName ) const
{
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 52fd3dd9b8bd..fbdf46acd6fd 100644
--- a/svx/source/gallery2/gallery1.cxx
+++ b/svx/source/gallery2/gallery1.cxx
@@ -43,7 +43,7 @@
#include <svx/galmisc.hxx>
#include <svx/galtheme.hxx>
#include <svx/gallery1.hxx>
-#include <gallerybinaryengineentry.hxx>
+#include <galleryfilestorageentry.hxx>
#include <vcl/weld.hxx>
#include <com/sun/star/sdbc/XResultSet.hpp>
#include <com/sun/star/ucb/XContentAccess.hpp>
@@ -121,10 +121,10 @@ GalleryThemeEntry::GalleryThemeEntry( bool bCreateUniqueURL,
if (bCreateUniqueURL)
{
- GalleryBinaryEngineEntry::CreateUniqueURL(rBaseURL,aURL);
+ GalleryFileStorageEntry::CreateUniqueURL(rBaseURL,aURL);
}
- mpGalleryStorageEngineEntry = std::make_unique<GalleryBinaryEngineEntry>();
+ mpGalleryStorageEngineEntry = std::make_unique<GalleryFileStorageEntry>();
setStorageLocations(aURL);
SetModified( _bNewFile );
@@ -448,7 +448,7 @@ void Gallery::ImplLoadSubDirs( const INetURLObject& rBaseURL, bool& rbDirIsReadO
}
}
- GalleryThemeEntry* pEntry = GalleryBinaryEngineEntry::CreateThemeEntry( aThmURL, rbDirIsReadOnly || bReadOnly );
+ GalleryThemeEntry* pEntry = GalleryFileStorageEntry::CreateThemeEntry( aThmURL, rbDirIsReadOnly || bReadOnly );
if( pEntry )
aThemeList.emplace_back( pEntry );
diff --git a/svx/source/gallery2/gallerybinaryengineentry.cxx b/svx/source/gallery2/gallerybinaryengineentry.cxx
deleted file mode 100644
index 9c222b1c15fe..000000000000
--- a/svx/source/gallery2/gallerybinaryengineentry.cxx
+++ /dev/null
@@ -1,181 +0,0 @@
-/* -*- 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 <gallerybinaryengineentry.hxx>
-#include <gallerystoragelocations.hxx>
-#include <svx/galmisc.hxx>
-#include <svx/gallery1.hxx>
-
-#include <unotools/ucbstreamhelper.hxx>
-#include <tools/urlobj.hxx>
-#include <tools/vcompat.hxx>
-
-#include <com/sun/star/ucb/ContentCreationException.hpp>
-
-static bool FileExists(const INetURLObject& rURL, std::u16string_view rExt)
-{
- INetURLObject aURL(rURL);
- aURL.setExtension(rExt);
- return FileExists(aURL);
-}
-
-GalleryBinaryEngineEntry::GalleryBinaryEngineEntry()
-{
- mpGalleryStorageLocations = std::make_unique<GalleryStorageLocations>();
-}
-
-void GalleryBinaryEngineEntry::setStorageLocations(INetURLObject& rURL)
-{
- mpGalleryStorageLocations->SetStorageLocations(rURL);
-}
-
-std::unique_ptr<GalleryBinaryEngine> GalleryBinaryEngineEntry::createGalleryStorageEngine(
- GalleryObjectCollection& mrGalleryObjectCollection, bool& bReadOnly)
-{
- return std::make_unique<GalleryBinaryEngine>(*mpGalleryStorageLocations,
- mrGalleryObjectCollection, bReadOnly);
-}
-
-void GalleryBinaryEngineEntry::CreateUniqueURL(const INetURLObject& rBaseURL, INetURLObject& aURL)
-{
- INetURLObject aBaseNoCase(GalleryStorageLocations::ImplGetURLIgnoreCase(rBaseURL));
- aURL = aBaseNoCase;
- static sal_Int32 nIdx = 0;
- while (FileExists(aURL, u"thm"))
- { // create new URLs
- nIdx++;
- aURL = aBaseNoCase;
- aURL.setName(Concat2View(aURL.getName() + OUString::number(nIdx)));
- }
-}
-
-GalleryThemeEntry* GalleryBinaryEngineEntry::CreateThemeEntry(const INetURLObject& rURL,
- bool bReadOnly)
-{
- DBG_ASSERT(rURL.GetProtocol() != INetProtocol::NotValid, "invalid URL");
-
- GalleryThemeEntry* pRet = nullptr;
-
- if (FileExists(rURL))
- {
- std::unique_ptr<SvStream> pIStm(::utl::UcbStreamHelper::CreateStream(
- rURL.GetMainURL(INetURLObject::DecodeMechanism::NONE), StreamMode::READ));
-
- if (pIStm)
- {
- sal_uInt16 nVersion;
-
- pIStm->ReadUInt16(nVersion);
-
- if (nVersion <= 0x00ff)
- {
- bool bThemeNameFromResource = false;
- sal_uInt32 nThemeId = 0;
-
- OString aTmpStr = read_uInt16_lenPrefixed_uInt8s_ToOString(*pIStm);
- OUString aThemeName = OStringToOUString(aTmpStr, RTL_TEXTENCODING_UTF8);
-
- // execute a character conversion
- if (nVersion >= 0x0004)
- {
- sal_uInt32 nCount;
- sal_uInt16 nTemp16;
-
- pIStm->ReadUInt32(nCount).ReadUInt16(nTemp16);
- pIStm->Seek(STREAM_SEEK_TO_END);
-
- // check whether there is a newer version;
- // therefore jump back by 520Bytes (8 bytes ID + 512Bytes reserve buffer)
- // if this is at all possible.
- if (pIStm->Tell() >= 520)
- {
- sal_uInt32 nId1, nId2;
-
- pIStm->SeekRel(-520);
- pIStm->ReadUInt32(nId1).ReadUInt32(nId2);
-
- if (nId1 == COMPAT_FORMAT('G', 'A', 'L', 'R')
- && nId2 == COMPAT_FORMAT('E', 'S', 'R', 'V'))
- {
- VersionCompatRead aCompat(*pIStm);
-
- pIStm->ReadUInt32(nThemeId);
-
- if (aCompat.GetVersion() >= 2)
- {
- pIStm->ReadCharAsBool(bThemeNameFromResource);
- }
- }
- }
- }
-
- pRet = new GalleryThemeEntry(false, rURL, aThemeName, bReadOnly, false, nThemeId,
- bThemeNameFromResource);
- }
- }
- }
-
- return pRet;
-}
-
-void GalleryBinaryEngineEntry::removeTheme()
-{
- INetURLObject aThmURL(GetThmURL());
- INetURLObject aSdgURL(GetSdgURL());
- INetURLObject aSdvURL(GetSdvURL());
- INetURLObject aStrURL(GetStrURL());
-
- KillFile(aThmURL);
- KillFile(aSdgURL);
- KillFile(aSdvURL);
- KillFile(aStrURL);
-}
-
-std::unique_ptr<GalleryTheme>&
-GalleryBinaryEngineEntry::getCachedTheme(std::unique_ptr<GalleryTheme>& pNewTheme)
-{
- INetURLObject aURL = GetThmURL();
-
- DBG_ASSERT(aURL.GetProtocol() != INetProtocol::NotValid, "invalid URL");
-
- if (FileExists(aURL))
- {
- std::unique_ptr<SvStream> pIStm(::utl::UcbStreamHelper::CreateStream(
- aURL.GetMainURL(INetURLObject::DecodeMechanism::NONE), StreamMode::READ));
-
- if (pIStm)
- {
- try
- {
- ReadGalleryTheme(*pIStm, *pNewTheme);
-
- if (pIStm->GetError())
- pNewTheme.reset();
- }
- catch (const css::ucb::ContentCreationException&)
- {
- }
- }
- }
- return pNewTheme;
-}
-
-SvStream& ReadGalleryTheme(SvStream& rIn, GalleryTheme& rTheme) { return rTheme.ReadData(rIn); }
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/gallery2/galleryfilestorageentry.cxx b/svx/source/gallery2/galleryfilestorageentry.cxx
index c0642145b2d8..abbc6efcaea1 100644
--- a/svx/source/gallery2/galleryfilestorageentry.cxx
+++ b/svx/source/gallery2/galleryfilestorageentry.cxx
@@ -18,7 +18,164 @@
*/
#include <galleryfilestorageentry.hxx>
+#include <gallerystoragelocations.hxx>
+#include <svx/galmisc.hxx>
+#include <svx/gallery1.hxx>
-GalleryFileStorageEntry::~GalleryFileStorageEntry(){};
+#include <unotools/ucbstreamhelper.hxx>
+#include <tools/urlobj.hxx>
+#include <tools/vcompat.hxx>
+
+#include <com/sun/star/ucb/ContentCreationException.hpp>
+
+static bool FileExists(const INetURLObject& rURL, std::u16string_view rExt)
+{
+ INetURLObject aURL(rURL);
+ aURL.setExtension(rExt);
+ return FileExists(aURL);
+}
+
+GalleryFileStorageEntry::GalleryFileStorageEntry()
+{
+ mpGalleryStorageLocations = std::make_unique<GalleryStorageLocations>();
+}
+
+void GalleryFileStorageEntry::setStorageLocations(INetURLObject& rURL)
+{
+ mpGalleryStorageLocations->SetStorageLocations(rURL);
+}
+
+std::unique_ptr<GalleryBinaryEngine> GalleryFileStorageEntry::createGalleryStorageEngine(
+ GalleryObjectCollection& mrGalleryObjectCollection, bool& bReadOnly)
+{
+ return std::make_unique<GalleryBinaryEngine>(*mpGalleryStorageLocations,
+ mrGalleryObjectCollection, bReadOnly);
+}
+
+void GalleryFileStorageEntry::CreateUniqueURL(const INetURLObject& rBaseURL, INetURLObject& aURL)
+{
+ INetURLObject aBaseNoCase(GalleryStorageLocations::ImplGetURLIgnoreCase(rBaseURL));
+ aURL = aBaseNoCase;
+ static sal_Int32 nIdx = 0;
+ while (FileExists(aURL, u"thm"))
+ { // create new URLs
+ nIdx++;
+ aURL = aBaseNoCase;
+ aURL.setName(Concat2View(aURL.getName() + OUString::number(nIdx)));
+ }
+}
+
+GalleryThemeEntry* GalleryFileStorageEntry::CreateThemeEntry(const INetURLObject& rURL,
+ bool bReadOnly)
+{
+ DBG_ASSERT(rURL.GetProtocol() != INetProtocol::NotValid, "invalid URL");
+
+ GalleryThemeEntry* pRet = nullptr;
+
+ if (FileExists(rURL))
+ {
+ std::unique_ptr<SvStream> pIStm(::utl::UcbStreamHelper::CreateStream(
+ rURL.GetMainURL(INetURLObject::DecodeMechanism::NONE), StreamMode::READ));
+
+ if (pIStm)
+ {
+ sal_uInt16 nVersion;
+
+ pIStm->ReadUInt16(nVersion);
+
+ if (nVersion <= 0x00ff)
+ {
+ bool bThemeNameFromResource = false;
+ sal_uInt32 nThemeId = 0;
+
+ OString aTmpStr = read_uInt16_lenPrefixed_uInt8s_ToOString(*pIStm);
+ OUString aThemeName = OStringToOUString(aTmpStr, RTL_TEXTENCODING_UTF8);
+
+ // execute a character conversion
+ if (nVersion >= 0x0004)
+ {
+ sal_uInt32 nCount;
+ sal_uInt16 nTemp16;
+
+ pIStm->ReadUInt32(nCount).ReadUInt16(nTemp16);
+ pIStm->Seek(STREAM_SEEK_TO_END);
+
+ // check whether there is a newer version;
+ // therefore jump back by 520Bytes (8 bytes ID + 512Bytes reserve buffer)
+ // if this is at all possible.
+ if (pIStm->Tell() >= 520)
+ {
+ sal_uInt32 nId1, nId2;
+
+ pIStm->SeekRel(-520);
+ pIStm->ReadUInt32(nId1).ReadUInt32(nId2);
+
+ if (nId1 == COMPAT_FORMAT('G', 'A', 'L', 'R')
+ && nId2 == COMPAT_FORMAT('E', 'S', 'R', 'V'))
+ {
+ VersionCompatRead aCompat(*pIStm);
+
+ pIStm->ReadUInt32(nThemeId);
+
+ if (aCompat.GetVersion() >= 2)
+ {
+ pIStm->ReadCharAsBool(bThemeNameFromResource);
+ }
+ }
+ }
+ }
+
+ pRet = new GalleryThemeEntry(false, rURL, aThemeName, bReadOnly, false, nThemeId,
+ bThemeNameFromResource);
+ }
+ }
+ }
+
+ return pRet;
+}
+
+void GalleryFileStorageEntry::removeTheme()
+{
+ INetURLObject aThmURL(GetThmURL());
+ INetURLObject aSdgURL(GetSdgURL());
+ INetURLObject aSdvURL(GetSdvURL());
+ INetURLObject aStrURL(GetStrURL());
+
+ KillFile(aThmURL);
+ KillFile(aSdgURL);
+ KillFile(aSdvURL);
+ KillFile(aStrURL);
+}
+
+std::unique_ptr<GalleryTheme>&
+GalleryFileStorageEntry::getCachedTheme(std::unique_ptr<GalleryTheme>& pNewTheme)
+{
+ INetURLObject aURL = GetThmURL();
+
+ DBG_ASSERT(aURL.GetProtocol() != INetProtocol::NotValid, "invalid URL");
+
+ if (FileExists(aURL))
+ {
+ std::unique_ptr<SvStream> pIStm(::utl::UcbStreamHelper::CreateStream(
+ aURL.GetMainURL(INetURLObject::DecodeMechanism::NONE), StreamMode::READ));
+
+ if (pIStm)
+ {
+ try
+ {
+ ReadGalleryTheme(*pIStm, *pNewTheme);
+
+ if (pIStm->GetError())
+ pNewTheme.reset();
+ }
+ catch (const css::ucb::ContentCreationException&)
+ {
+ }
+ }
+ }
+ return pNewTheme;
+}
+
+SvStream& ReadGalleryTheme(SvStream& rIn, GalleryTheme& rTheme) { return rTheme.ReadData(rIn); }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */