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 "HashMaps.hxx" 27 #include "ZipPackageEntry.hxx" 28 #include <cppuhelper/implbase.hxx> 29 30 #include <string_view> 31 #include <vector> 32 33 class ZipOutputStream; 34 struct ZipEntry; 35 36 class ZipPackageFolder : public cppu::ImplInheritanceHelper 37 < 38 ZipPackageEntry, 39 css::container::XNameContainer, 40 css::container::XEnumerationAccess 41 > 42 { 43 private: 44 ContentHash maContents; 45 OUString m_sVersion; 46 47 public: 48 49 ZipPackageFolder( const css::uno::Reference < css::uno::XComponentContext >& xContext, 50 sal_Int32 nFormat, 51 bool bAllowRemoveOnInsert ); 52 virtual ~ZipPackageFolder() override; 53 GetVersion() const54 const OUString& GetVersion() const { return m_sVersion; } SetVersion(const OUString & aVersion)55 void SetVersion( const OUString& aVersion ) { m_sVersion = aVersion; } 56 57 bool LookForUnexpectedODF12Streams( std::u16string_view aPath ); 58 59 void setChildStreamsTypeByExtension( const css::beans::StringPair& aPair ); 60 61 /// @throws css::lang::IllegalArgumentException 62 /// @throws css::container::ElementExistException 63 /// @throws css::lang::WrappedTargetException 64 /// @throws css::uno::RuntimeException 65 void doInsertByName ( ZipPackageEntry *pEntry, bool bSetParent ); 66 67 ZipContentInfo& doGetByName( const OUString& aName ); 68 69 static css::uno::Sequence < sal_Int8 > getUnoTunnelId(); 70 setPackageFormat_Impl(sal_Int32 nFormat)71 void setPackageFormat_Impl( sal_Int32 nFormat ) { m_nFormat = nFormat; } setRemoveOnInsertMode_Impl(bool bRemove)72 void setRemoveOnInsertMode_Impl( bool bRemove ) { mbAllowRemoveOnInsert = bRemove; } 73 74 virtual bool saveChild( const OUString &rPath, 75 std::vector < css::uno::Sequence < css::beans::PropertyValue > > &rManList, 76 ZipOutputStream & rZipOut, 77 const css::uno::Sequence < sal_Int8 >& rEncryptionKey, 78 sal_Int32 nPBKDF2IterationCount, 79 const rtlRandomPool &rRandomPool ) override; 80 81 // Recursive functions 82 /// @throws css::uno::RuntimeException 83 void saveContents( 84 const OUString &rPath, 85 std::vector < css::uno::Sequence < css::beans::PropertyValue > > &rManList, 86 ZipOutputStream & rZipOut, 87 const css::uno::Sequence< sal_Int8 > &rEncryptionKey, 88 sal_Int32 nPBKDF2IterationCount, 89 const rtlRandomPool & rRandomPool) const; 90 91 // XNameContainer 92 virtual void SAL_CALL insertByName( const OUString& aName, const css::uno::Any& aElement ) override; 93 virtual void SAL_CALL removeByName( const OUString& Name ) override; 94 95 // XEnumerationAccess 96 virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration( ) override; 97 98 // XElementAccess 99 virtual css::uno::Type SAL_CALL getElementType( ) override; 100 virtual sal_Bool SAL_CALL hasElements( ) override; 101 102 // XNameAccess 103 virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override; 104 virtual css::uno::Sequence< OUString > SAL_CALL getElementNames( ) override; 105 virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override; 106 107 // XNameReplace 108 virtual void SAL_CALL replaceByName( const OUString& aName, const css::uno::Any& aElement ) override; 109 110 // XPropertySet 111 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override; 112 virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override; 113 114 // XUnoTunnel 115 virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override; 116 117 // XServiceInfo 118 virtual OUString SAL_CALL getImplementationName( ) override; 119 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; 120 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override; 121 }; 122 #endif 123 124 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 125