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