Avoid potential negative array index access to cached text.
[LibreOffice.git] / svx / inc / galleryfilestorage.hxx
blobbafbc13c7badb8c24031e3b0cfc9ea9efeeb8c1b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #pragma once
22 #include <svx/galmisc.hxx>
23 #include <svx/svxdllapi.h>
24 #include <svx/fmmodel.hxx>
25 #include "gallerystoragelocations.hxx"
26 #include "galleryfilestorage.hxx"
27 #include <tools/urlobj.hxx>
28 #include <sot/storage.hxx>
29 #include <vcl/salctype.hxx>
31 #include <tools/datetime.hxx>
33 #include <memory>
35 class GalleryObjectCollection;
36 class SgaObjectSvDraw;
37 class SgaObjectBmp;
38 class SgaObject;
39 class SotStorage;
40 struct GalleryObject;
41 class FmFormModel;
42 class GalleryTheme;
43 class GalleryThemeEntry;
45 class SVXCORE_DLLPUBLIC GalleryFileStorage final
47 private:
48 tools::SvRef<SotStorage> m_aSvDrawStorageRef;
49 const GalleryStorageLocations& maGalleryStorageLocations;
50 GalleryObjectCollection& mrGalleryObjectCollection;
51 bool mbReadOnly;
52 OUString m_aDestDir;
53 bool m_bDestDirRelative;
55 const INetURLObject& GetSdgURL() const { return maGalleryStorageLocations.GetSdgURL(); }
56 const INetURLObject& GetSdvURL() const { return maGalleryStorageLocations.GetSdvURL(); }
57 const INetURLObject& GetThmURL() const { return maGalleryStorageLocations.GetThmURL(); }
59 public:
60 GalleryFileStorage(const GalleryStorageLocations& rGalleryStorageLocations,
61 GalleryObjectCollection& rGalleryObjectCollection, bool bReadOnly);
62 SAL_DLLPRIVATE ~GalleryFileStorage();
64 void clearSotStorage();
66 void setDestDir(const OUString& rDestDir, bool bRelative);
68 SAL_DLLPRIVATE void ImplCreateSvDrawStorage();
69 SAL_DLLPRIVATE const tools::SvRef<SotStorage>& GetSvDrawStorage() const;
71 const INetURLObject& getThemeURL() const { return maGalleryStorageLocations.getThemeURL(); }
73 SAL_DLLPRIVATE bool implWrite(const GalleryTheme& rTheme, const GalleryThemeEntry* pThm);
75 void insertObject(const SgaObject& rObj, GalleryObject* pFoundEntry, sal_uInt32 nInsertPos);
76 void removeObject(const std::unique_ptr<GalleryObject>& pEntry);
78 std::unique_ptr<SgaObject> implReadSgaObject(GalleryObject const* pEntry);
79 bool implWriteSgaObject(const SgaObject& rObj, sal_uInt32 nPos, GalleryObject* pExistentEntry);
81 bool readModel(const GalleryObject* pObject, SdrModel& rModel);
82 SgaObjectSvDraw insertModel(const FmFormModel& rModel, const INetURLObject& rUserURL);
84 bool readModelStream(const GalleryObject* pObject,
85 tools::SvRef<SotTempStream> const& rxModelStream);
86 SgaObjectSvDraw insertModelStream(const tools::SvRef<SotTempStream>& rxModelStream,
87 const INetURLObject& rUserURL);
89 INetURLObject implCreateUniqueURL(SgaObjKind eObjKind, const INetURLObject& rUserURL,
90 ConvertDataFormat nFormat = ConvertDataFormat::Unknown);
92 SgaObjectBmp insertGraphic(const Graphic& rGraphic, const GfxLink& aGfxLink,
93 const ConvertDataFormat& nExportFormat,
94 const INetURLObject& rUserURL);
96 SgaObjectSvDraw updateSvDrawObject(const GalleryObject* pEntry);
98 void updateTheme();
99 static void insertFileOrDirURL(const INetURLObject& rFileOrDirURL,
100 std::vector<INetURLObject>& rURLVector);
102 SvStream& writeGalleryTheme(SvStream& rOStm, const GalleryTheme& rTheme,
103 const GalleryThemeEntry* pThm);
105 DateTime getModificationDate() const;
108 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */