Line data Source code
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 _ZIP_PACKAGE_FOLDER_HXX
20 : #define _ZIP_PACKAGE_FOLDER_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 <HashMaps.hxx>
26 : #include <ZipPackageEntry.hxx>
27 : #include <cppuhelper/implbase2.hxx>
28 : #include <vector>
29 :
30 : namespace com { namespace sun { namespace star {
31 : namespace beans
32 : {
33 : struct PropertyValue;
34 : }
35 : namespace packages
36 : {
37 : class ContentInfo;
38 : }
39 : } } }
40 :
41 : class ZipOutputStream;
42 : struct ZipEntry;
43 : typedef void* rtlRandomPool;
44 :
45 : class ZipPackageFolder : public cppu::ImplInheritanceHelper2
46 : <
47 : ZipPackageEntry,
48 : ::com::sun::star::container::XNameContainer,
49 : ::com::sun::star::container::XEnumerationAccess
50 : >
51 : {
52 : private:
53 : ContentHash maContents;
54 : sal_Int32 m_nFormat;
55 : OUString m_sVersion;
56 :
57 : public:
58 :
59 : ZipPackageFolder( sal_Int32 nFormat,
60 : sal_Bool bAllowRemoveOnInsert );
61 : virtual ~ZipPackageFolder();
62 :
63 0 : OUString& GetVersion() { return m_sVersion; }
64 0 : void SetVersion( const OUString& aVersion ) { m_sVersion = aVersion; }
65 :
66 : sal_Bool LookForUnexpectedODF12Streams( const OUString& aPath );
67 :
68 : void setChildStreamsTypeByExtension( const ::com::sun::star::beans::StringPair& aPair );
69 :
70 : void doInsertByName ( ZipPackageEntry *pEntry, sal_Bool bSetParent )
71 : throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::ElementExistException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
72 :
73 : com::sun::star::packages::ContentInfo & doGetByName( const OUString& aName )
74 : throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
75 :
76 : static void copyZipEntry( ZipEntry &rDest, const ZipEntry &rSource);
77 : static ::com::sun::star::uno::Sequence < sal_Int8 > static_getImplementationId();
78 :
79 0 : void setPackageFormat_Impl( sal_Int32 nFormat ) { m_nFormat = nFormat; }
80 0 : void setRemoveOnInsertMode_Impl( sal_Bool bRemove ) { this->mbAllowRemoveOnInsert = bRemove; }
81 :
82 : bool saveChild(const OUString &rShortName, const com::sun::star::packages::ContentInfo &rInfo, OUString &rPath, std::vector < com::sun::star::uno::Sequence < com::sun::star::beans::PropertyValue > > &rManList, ZipOutputStream & rZipOut, const com::sun::star::uno::Sequence < sal_Int8 >& rEncryptionKey, rtlRandomPool & rRandomPool);
83 :
84 : // Recursive functions
85 : void saveContents(OUString &rPath, std::vector < com::sun::star::uno::Sequence < com::sun::star::beans::PropertyValue > > &rManList, ZipOutputStream & rZipOut, const com::sun::star::uno::Sequence< sal_Int8 > &rEncryptionKey, rtlRandomPool & rRandomPool)
86 : throw(::com::sun::star::uno::RuntimeException);
87 : void releaseUpwardRef();
88 :
89 : // XNameContainer
90 : virtual void SAL_CALL insertByName( const OUString& aName, const ::com::sun::star::uno::Any& aElement )
91 : throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::ElementExistException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
92 : virtual void SAL_CALL removeByName( const OUString& Name )
93 : throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
94 :
95 : // XEnumerationAccess
96 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createEnumeration( )
97 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
98 :
99 : // XElementAccess
100 : virtual ::com::sun::star::uno::Type SAL_CALL getElementType( )
101 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
102 : virtual sal_Bool SAL_CALL hasElements( )
103 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
104 :
105 : // XNameAccess
106 : virtual ::com::sun::star::uno::Any SAL_CALL getByName( const OUString& aName )
107 : throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
108 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getElementNames( )
109 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
110 : virtual sal_Bool SAL_CALL hasByName( const OUString& aName )
111 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
112 :
113 : // XNameReplace
114 : virtual void SAL_CALL replaceByName( const OUString& aName, const ::com::sun::star::uno::Any& aElement )
115 : throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
116 :
117 : // XPropertySet
118 : virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue )
119 : throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
120 : virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName )
121 : throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
122 :
123 : // XUnoTunnel
124 : virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier )
125 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
126 :
127 : // XServiceInfo
128 : virtual OUString SAL_CALL getImplementationName( )
129 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
130 : virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
131 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
132 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( )
133 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
134 : };
135 : #endif
136 :
137 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|