workaround segfault in compiler on macos-clang-intel
[LibreOffice.git] / package / inc / ZipPackageFolder.hxx
blob7598c25c304db3bda00bba37ec480149a27a8106
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 .
19 #ifndef INCLUDED_PACKAGE_INC_ZIPPACKAGEFOLDER_HXX
20 #define INCLUDED_PACKAGE_INC_ZIPPACKAGEFOLDER_HXX
22 #include <com/sun/star/container/XNameContainer.hpp>
23 #include <com/sun/star/container/XEnumerationAccess.hpp>
24 #include <com/sun/star/beans/StringPair.hpp>
25 #include <com/sun/star/uno/XComponentContext.hpp>
26 #include "ZipPackageEntry.hxx"
27 #include <cppuhelper/implbase.hxx>
28 #include <rtl/ref.hxx>
30 #include <string_view>
31 #include <unordered_map>
32 #include <vector>
34 class ZipOutputStream;
35 struct ZipEntry;
36 class ZipPackageFolder;
37 class ZipPackageStream;
39 struct ZipContentInfo
41 rtl::Reference < ZipPackageEntry > xPackageEntry;
42 bool bFolder;
43 union
45 ZipPackageFolder *pFolder;
46 ZipPackageStream *pStream;
48 ZipContentInfo( ZipPackageStream * pNewStream );
49 ZipContentInfo( ZipPackageFolder * pNewFolder );
50 ZipContentInfo( const ZipContentInfo& );
51 ZipContentInfo( ZipContentInfo&& );
52 ZipContentInfo& operator=( const ZipContentInfo& );
53 ZipContentInfo& operator=( ZipContentInfo&& );
55 ~ZipContentInfo();
58 typedef std::unordered_map < OUString,
59 ZipContentInfo > ContentHash;
61 class ZipPackageFolder final : public cppu::ImplInheritanceHelper
63 ZipPackageEntry,
64 css::container::XNameContainer,
65 css::container::XEnumerationAccess
68 private:
69 ContentHash maContents;
70 OUString m_sVersion;
72 public:
74 ZipPackageFolder( const css::uno::Reference < css::uno::XComponentContext >& xContext,
75 sal_Int32 nFormat,
76 bool bAllowRemoveOnInsert );
77 virtual ~ZipPackageFolder() override;
79 const OUString& GetVersion() const { return m_sVersion; }
80 void SetVersion( const OUString& aVersion ) { m_sVersion = aVersion; }
82 bool LookForUnexpectedODF12Streams(std::u16string_view aPath, bool isWholesomeEncryption);
84 void setChildStreamsTypeByExtension( const css::beans::StringPair& aPair );
86 /// @throws css::lang::IllegalArgumentException
87 /// @throws css::container::ElementExistException
88 /// @throws css::lang::WrappedTargetException
89 /// @throws css::uno::RuntimeException
90 void doInsertByName ( ZipPackageEntry *pEntry, bool bSetParent );
92 ZipContentInfo& doGetByName( const OUString& aName );
94 void setPackageFormat_Impl( sal_Int32 nFormat ) { m_nFormat = nFormat; }
95 void setRemoveOnInsertMode_Impl( bool bRemove ) { mbAllowRemoveOnInsert = bRemove; }
97 virtual bool saveChild( const OUString &rPath,
98 std::vector < css::uno::Sequence < css::beans::PropertyValue > > &rManList,
99 ZipOutputStream & rZipOut,
100 const css::uno::Sequence < sal_Int8 >& rEncryptionKey,
101 ::std::optional<sal_Int32> oPBKDF2IterationCount,
102 ::std::optional<::std::tuple<sal_Int32, sal_Int32, sal_Int32>> oArgon2Args) override;
104 // Recursive functions
105 /// @throws css::uno::RuntimeException
106 void saveContents(
107 const OUString &rPath,
108 std::vector < css::uno::Sequence < css::beans::PropertyValue > > &rManList,
109 ZipOutputStream & rZipOut,
110 const css::uno::Sequence< sal_Int8 > &rEncryptionKey,
111 ::std::optional<sal_Int32> oPBKDF2IterationCount,
112 ::std::optional<::std::tuple<sal_Int32, sal_Int32, sal_Int32>> oArgon2Args) const;
114 // XNameContainer
115 virtual void SAL_CALL insertByName( const OUString& aName, const css::uno::Any& aElement ) override;
116 virtual void SAL_CALL removeByName( const OUString& Name ) override;
118 // XEnumerationAccess
119 virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration( ) override;
121 // XElementAccess
122 virtual css::uno::Type SAL_CALL getElementType( ) override;
123 virtual sal_Bool SAL_CALL hasElements( ) override;
125 // XNameAccess
126 virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override;
127 virtual css::uno::Sequence< OUString > SAL_CALL getElementNames( ) override;
128 virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override;
130 // XNameReplace
131 virtual void SAL_CALL replaceByName( const OUString& aName, const css::uno::Any& aElement ) override;
133 // XPropertySet
134 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override;
135 virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override;
137 // XServiceInfo
138 virtual OUString SAL_CALL getImplementationName( ) override;
139 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
140 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
142 #endif
144 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */