summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAditya <adityasahu1511@gmail.com>2020-07-20 17:13:13 +0530
committerTomaž Vajngerl <quikee@gmail.com>2020-07-30 07:30:05 +0200
commit104f7027ea3bea45849cb5d88a1893e69bf3606c (patch)
treefd81f655d3748852b2b4c279aabee32d7eff6ed3 /include
parent1486f96317aa6eac34ddb7ef4e1c64824bb269b4 (diff)
svx: GalleryObjectCollection shared class and related refactoring work
Add GalleryObjectCollection, a shared class primarily owned by GalleryTheme which contains object list to be used by GalleryTheme and GalleryBinaryEngine. Refactor ImplCreateUniqueURL, InsertGraphic() Implement comphelper::GraphicMimeTypeHelper::GetExtensionForConvertDataFormat() Refactor Actualize(), implement updateSvDrawObject(), updateTheme() Move ImplCreateSvDrawStorage into constructor instead of calling in directly. Change-Id: I6a8c552268628b4e192f45112ac9e8789c6e1609 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99035 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'include')
-rw-r--r--include/comphelper/graphicmimetype.hxx1
-rw-r--r--include/svx/gallerybinaryengine.hxx35
-rw-r--r--include/svx/gallerybinaryengineentry.hxx10
-rw-r--r--include/svx/galleryobjectcollection.hxx41
-rw-r--r--include/svx/galtheme.hxx23
5 files changed, 82 insertions, 28 deletions
diff --git a/include/comphelper/graphicmimetype.hxx b/include/comphelper/graphicmimetype.hxx
index 5380c43a4cb0..53ffd49888e4 100644
--- a/include/comphelper/graphicmimetype.hxx
+++ b/include/comphelper/graphicmimetype.hxx
@@ -36,6 +36,7 @@ public:
static OUString
GetMimeTypeForImageStream(const css::uno::Reference<css::io::XInputStream>& xInputStream);
static OUString GetMimeTypeForConvertDataFormat(ConvertDataFormat convertDataFormat);
+ static char const* GetExtensionForConvertDataFormat(ConvertDataFormat nFormat);
};
}
diff --git a/include/svx/gallerybinaryengine.hxx b/include/svx/gallerybinaryengine.hxx
index b40f9c2b11bb..b878200a12e5 100644
--- a/include/svx/gallerybinaryengine.hxx
+++ b/include/svx/gallerybinaryengine.hxx
@@ -20,19 +20,19 @@
#pragma once
#include <svx/galtheme.hxx>
-#include <svx/gallerybinaryengine.hxx>
-#include <svx/gallerystoragelocations.hxx>
+#include <svx/galmisc.hxx>
#include <svx/svxdllapi.h>
#include <svx/fmmodel.hxx>
+#include <svx/gallerystoragelocations.hxx>
#include <tools/urlobj.hxx>
#include <sot/storage.hxx>
-#include <cstdio>
#include <memory>
-#include <vector>
class GalleryStorageLocations;
+class GalleryObjectCollection;
class SgaObjectSvDraw;
+class SgaObjectBmp;
class SgaObject;
class SotStorage;
struct GalleryObject;
@@ -44,12 +44,17 @@ class SVXCORE_DLLPUBLIC GalleryBinaryEngine
private:
tools::SvRef<SotStorage> m_aSvDrawStorageRef;
const GalleryStorageLocations& maGalleryStorageLocations;
+ GalleryObjectCollection& mrGalleryObjectCollection;
+ bool mbReadOnly;
public:
- GalleryBinaryEngine(const GalleryStorageLocations& rGalleryStorageLocations);
+ GalleryBinaryEngine(const GalleryStorageLocations& rGalleryStorageLocations,
+ GalleryObjectCollection& rGalleryObjectCollection, bool bReadOnly);
+ SAL_DLLPRIVATE ~GalleryBinaryEngine();
+
void clearSotStorage();
- SAL_DLLPRIVATE void ImplCreateSvDrawStorage(bool bReadOnly);
+ SAL_DLLPRIVATE void ImplCreateSvDrawStorage();
SAL_DLLPRIVATE const tools::SvRef<SotStorage>& GetSvDrawStorage() const;
const INetURLObject& GetThmURL() const { return maGalleryStorageLocations.GetThmURL(); }
@@ -60,21 +65,29 @@ public:
SAL_DLLPRIVATE bool implWrite(const GalleryTheme& rTheme);
void insertObject(const SgaObject& rObj, GalleryObject* pFoundEntry, OUString& rDestDir,
- ::std::vector<std::unique_ptr<GalleryObject>>& rObjectList,
sal_uInt32& rInsertPos);
std::unique_ptr<SgaObject> implReadSgaObject(GalleryObject const* pEntry);
bool implWriteSgaObject(const SgaObject& rObj, sal_uInt32 nPos, GalleryObject* pExistentEntry,
- OUString& aDestDir,
- ::std::vector<std::unique_ptr<GalleryObject>>& aObjectList);
+ OUString& aDestDir);
bool readModel(const GalleryObject* pObject, SdrModel& rModel);
- bool insertModel(const FmFormModel& rModel, INetURLObject& rURL);
+ SgaObjectSvDraw insertModel(const FmFormModel& rModel, const INetURLObject& rUserURL);
bool readModelStream(const GalleryObject* pObject,
tools::SvRef<SotStorageStream> const& rxModelStream);
SgaObjectSvDraw insertModelStream(const tools::SvRef<SotStorageStream>& rxModelStream,
- INetURLObject& rURL);
+ const INetURLObject& rUserURL);
+
+ INetURLObject implCreateUniqueURL(SgaObjKind eObjKind, const INetURLObject& rUserURL,
+ ConvertDataFormat nFormat = ConvertDataFormat::Unknown);
+
+ SgaObjectBmp insertGraphic(const Graphic& rGraphic, const GfxLink& aGfxLink,
+ ConvertDataFormat& nExportFormat, const INetURLObject& rUserURL);
+
+ SgaObjectSvDraw updateSvDrawObject(GalleryObject* pEntry);
+
+ void updateTheme();
};
SvStream& WriteGalleryTheme(SvStream& rOut, const GalleryTheme& rTheme);
diff --git a/include/svx/gallerybinaryengineentry.hxx b/include/svx/gallerybinaryengineentry.hxx
index a310f085df03..15d75a922997 100644
--- a/include/svx/gallerybinaryengineentry.hxx
+++ b/include/svx/gallerybinaryengineentry.hxx
@@ -30,7 +30,7 @@ class GalleryStorageLocations;
class SVXCORE_DLLPUBLIC GalleryBinaryEngineEntry
{
private:
- GalleryStorageLocations& maGalleryStorageLocations;
+ GalleryStorageLocations& m_rGalleryStorageLocations;
public:
GalleryBinaryEngineEntry(GalleryStorageLocations& rGalleryStorageLocations);
@@ -38,10 +38,10 @@ public:
OUString ReadStrFromIni(const OUString& aKeyName);
- const INetURLObject& GetThmURL() const { return maGalleryStorageLocations.GetThmURL(); }
- const INetURLObject& GetSdgURL() const { return maGalleryStorageLocations.GetSdgURL(); }
- const INetURLObject& GetSdvURL() const { return maGalleryStorageLocations.GetSdvURL(); }
- const INetURLObject& GetStrURL() const { return maGalleryStorageLocations.GetStrURL(); }
+ const INetURLObject& GetThmURL() const { return m_rGalleryStorageLocations.GetThmURL(); }
+ const INetURLObject& GetSdgURL() const { return m_rGalleryStorageLocations.GetSdgURL(); }
+ const INetURLObject& GetSdvURL() const { return m_rGalleryStorageLocations.GetSdvURL(); }
+ const INetURLObject& GetStrURL() const { return m_rGalleryStorageLocations.GetStrURL(); }
SAL_DLLPRIVATE static GalleryThemeEntry* CreateThemeEntry(const INetURLObject& rURL,
bool bReadOnly);
diff --git a/include/svx/galleryobjectcollection.hxx b/include/svx/galleryobjectcollection.hxx
new file mode 100644
index 000000000000..266d263e8b14
--- /dev/null
+++ b/include/svx/galleryobjectcollection.hxx
@@ -0,0 +1,41 @@
+/* -*- 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 <memory>
+#include <vector>
+
+struct GalleryObject;
+
+class GalleryObjectCollection
+{
+private:
+ std::vector<std::unique_ptr<GalleryObject>> m_aObjectList;
+
+public:
+ std::vector<std::unique_ptr<GalleryObject>>& getObjectList() { return m_aObjectList; }
+ std::unique_ptr<GalleryObject>& get(sal_uInt32 nPos) { return m_aObjectList[nPos]; }
+ const std::unique_ptr<GalleryObject>& get(sal_uInt32 nPos) const { return m_aObjectList[nPos]; }
+ sal_uInt32 size() const { return m_aObjectList.size(); }
+
+ void clear();
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/svx/galtheme.hxx b/include/svx/galtheme.hxx
index 1da9eac44a7a..5c3f537c2107 100644
--- a/include/svx/galtheme.hxx
+++ b/include/svx/galtheme.hxx
@@ -21,6 +21,7 @@
#define INCLUDED_SVX_GALTHEME_HXX
#include <svx/svxdllapi.h>
+#include <svx/galleryobjectcollection.hxx>
#include <svx/gallerybinaryengine.hxx>
#include <tools/debug.hxx>
@@ -74,7 +75,7 @@ class SVXCORE_DLLPUBLIC GalleryTheme : public SfxBroadcaster
private:
std::unique_ptr<GalleryBinaryEngine> mpGalleryBinaryEngine;
- ::std::vector< std::unique_ptr<GalleryObject> > aObjectList;
+ GalleryObjectCollection maGalleryObjectCollection;
OUString m_aDestDir;
bool m_bDestDirRelative;
Gallery* pParent;
@@ -85,21 +86,21 @@ private:
bool bDragging;
bool bAbortActualize;
- std::unique_ptr<GalleryBinaryEngine> createGalleryBinaryEngine();
+ std::unique_ptr<GalleryBinaryEngine> createGalleryBinaryEngine(bool bReadOnly);
const std::unique_ptr<GalleryBinaryEngine>& getGalleryBinaryEngine() const { return mpGalleryBinaryEngine; }
SAL_DLLPRIVATE const GalleryObject* ImplGetGalleryObject(sal_uInt32 nPos) const
{
- if (nPos < aObjectList.size())
- return aObjectList[ nPos ].get();
+ if (nPos < maGalleryObjectCollection.size())
+ return maGalleryObjectCollection.get(nPos).get();
return nullptr;
}
- const GalleryObject* ImplGetGalleryObject( const INetURLObject& rURL );
+ const GalleryObject* ImplGetGalleryObject(const INetURLObject& rURL);
- SAL_DLLPRIVATE sal_uInt32 ImplGetGalleryObjectPos( const GalleryObject* pObj ) const
+ SAL_DLLPRIVATE sal_uInt32 ImplGetGalleryObjectPos( const GalleryObject* pObj )
{
- for (sal_uInt32 i = 0, n = aObjectList.size(); i < n; ++i)
- if ( pObj == aObjectList[ i ].get() )
+ for (sal_uInt32 i = 0, n = maGalleryObjectCollection.size(); i < n; ++i)
+ if ( pObj == maGalleryObjectCollection.get(i).get() )
return i;
return SAL_MAX_UINT32;
}
@@ -115,7 +116,7 @@ public:
SAL_DLLPRIVATE virtual ~GalleryTheme() override;
- SAL_DLLPRIVATE sal_uInt32 GetObjectCount() const { return aObjectList.size(); }
+ SAL_DLLPRIVATE sal_uInt32 GetObjectCount() const { return maGalleryObjectCollection.size(); }
std::unique_ptr<SgaObject> AcquireObject(sal_uInt32 nPos);
@@ -184,8 +185,6 @@ public:
SAL_DLLPRIVATE bool GetModelStream(sal_uInt32 nPos, tools::SvRef<SotStorageStream> const & rModelStreamRef);
SAL_DLLPRIVATE bool InsertModelStream(const tools::SvRef<SotStorageStream>& rModelStream, sal_uInt32 nInsertPos);
- INetURLObject implCreateUniqueURL(SgaObjKind eObjKind, ConvertDataFormat nFormat = ConvertDataFormat::Unknown);
-
SAL_DLLPRIVATE bool GetURL(sal_uInt32 nPos, INetURLObject& rURL);
bool InsertURL(const INetURLObject& rURL, sal_uInt32 nInsertPos = SAL_MAX_UINT32);
SAL_DLLPRIVATE bool InsertFileOrDirURL(const INetURLObject& rFileOrDirURL, sal_uInt32 nInsertPos);
@@ -201,7 +200,7 @@ public:
static void InsertAllThemes(weld::ComboBox& rListBox);
// for buffering PreviewBitmaps and strings for object and path
- SAL_DLLPRIVATE void GetPreviewBitmapExAndStrings(sal_uInt32 nPos, BitmapEx& rBitmapEx, Size& rSize, OUString& rTitle, OUString& rPath) const;
+ SAL_DLLPRIVATE void GetPreviewBitmapExAndStrings(sal_uInt32 nPos, BitmapEx& rBitmapEx, Size& rSize, OUString& rTitle, OUString& rPath);
SAL_DLLPRIVATE void SetPreviewBitmapExAndStrings(sal_uInt32 nPos, const BitmapEx& rBitmapEx, const Size& rSize, const OUString& rTitle, const OUString& rPath);
};