LibreOffice Module package (master) 1
ZipPackageFolder.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19#ifndef INCLUDED_PACKAGE_INC_ZIPPACKAGEFOLDER_HXX
20#define INCLUDED_PACKAGE_INC_ZIPPACKAGEFOLDER_HXX
21
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"
28#include <rtl/ref.hxx>
29
30#include <string_view>
31#include <unordered_map>
32#include <vector>
33
34class ZipOutputStream;
35struct ZipEntry;
38
40{
42 bool bFolder;
43 union
44 {
47 };
48 ZipContentInfo( ZipPackageStream * pNewStream );
49 ZipContentInfo( ZipPackageFolder * pNewFolder );
54
56};
57
58typedef std::unordered_map < OUString,
60
61class ZipPackageFolder final : public cppu::ImplInheritanceHelper
62<
63 ZipPackageEntry,
64 css::container::XNameContainer,
65 css::container::XEnumerationAccess
66>
67{
68private:
70 OUString m_sVersion;
71
72public:
73
74 ZipPackageFolder( const css::uno::Reference < css::uno::XComponentContext >& xContext,
75 sal_Int32 nFormat,
76 bool bAllowRemoveOnInsert );
77 virtual ~ZipPackageFolder() override;
78
79 const OUString& GetVersion() const { return m_sVersion; }
80 void SetVersion( const OUString& aVersion ) { m_sVersion = aVersion; }
81
82 bool LookForUnexpectedODF12Streams( std::u16string_view aPath );
83
84 void setChildStreamsTypeByExtension( const css::beans::StringPair& aPair );
85
90 void doInsertByName ( ZipPackageEntry *pEntry, bool bSetParent );
91
92 ZipContentInfo& doGetByName( const OUString& aName );
93
94 void setPackageFormat_Impl( sal_Int32 nFormat ) { m_nFormat = nFormat; }
95 void setRemoveOnInsertMode_Impl( bool bRemove ) { mbAllowRemoveOnInsert = bRemove; }
96
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 sal_Int32 nPBKDF2IterationCount,
102 const rtlRandomPool &rRandomPool ) override;
103
104 // Recursive functions
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 sal_Int32 nPBKDF2IterationCount,
112 const rtlRandomPool & rRandomPool) const;
113
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;
117
118 // XEnumerationAccess
119 virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration( ) override;
120
121 // XElementAccess
122 virtual css::uno::Type SAL_CALL getElementType( ) override;
123 virtual sal_Bool SAL_CALL hasElements( ) override;
124
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;
129
130 // XNameReplace
131 virtual void SAL_CALL replaceByName( const OUString& aName, const css::uno::Any& aElement ) override;
132
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;
136
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;
141};
142#endif
143
144/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void * rtlRandomPool
std::unordered_map< OUString, ZipContentInfo > ContentHash
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override
void setChildStreamsTypeByExtension(const css::beans::StringPair &aPair)
virtual css::uno::Any SAL_CALL getByName(const OUString &aName) override
virtual void SAL_CALL insertByName(const OUString &aName, const css::uno::Any &aElement) override
void setRemoveOnInsertMode_Impl(bool bRemove)
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
virtual sal_Bool SAL_CALL hasByName(const OUString &aName) override
void setPackageFormat_Impl(sal_Int32 nFormat)
virtual void SAL_CALL replaceByName(const OUString &aName, const css::uno::Any &aElement) override
void doInsertByName(ZipPackageEntry *pEntry, bool bSetParent)
virtual void SAL_CALL removeByName(const OUString &Name) override
virtual ~ZipPackageFolder() override
virtual OUString SAL_CALL getImplementationName() override
virtual bool saveChild(const OUString &rPath, std::vector< css::uno::Sequence< css::beans::PropertyValue > > &rManList, ZipOutputStream &rZipOut, const css::uno::Sequence< sal_Int8 > &rEncryptionKey, sal_Int32 nPBKDF2IterationCount, const rtlRandomPool &rRandomPool) override
ZipContentInfo & doGetByName(const OUString &aName)
void saveContents(const OUString &rPath, std::vector< css::uno::Sequence< css::beans::PropertyValue > > &rManList, ZipOutputStream &rZipOut, const css::uno::Sequence< sal_Int8 > &rEncryptionKey, sal_Int32 nPBKDF2IterationCount, const rtlRandomPool &rRandomPool) const
bool LookForUnexpectedODF12Streams(std::u16string_view aPath)
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
ContentHash maContents
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual css::uno::Type SAL_CALL getElementType() override
ZipPackageFolder(const css::uno::Reference< css::uno::XComponentContext > &xContext, sal_Int32 nFormat, bool bAllowRemoveOnInsert)
void SetVersion(const OUString &aVersion)
const OUString & GetVersion() const
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual sal_Bool SAL_CALL hasElements() override
sal_uInt16 const m_nFormat
ZipPackageFolder * pFolder
ZipContentInfo(ZipContentInfo &&)
rtl::Reference< ZipPackageEntry > xPackageEntry
ZipContentInfo(const ZipContentInfo &)
ZipContentInfo & operator=(ZipContentInfo &&)
ZipContentInfo & operator=(const ZipContentInfo &)
ZipContentInfo(ZipPackageStream *pNewStream)
ZipPackageStream * pStream
unsigned char sal_Bool