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 1447 : const OUString& GetVersion() const { return m_sVersion; }
53 2590 : 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 9100 : void setPackageFormat_Impl( sal_Int32 nFormat ) { m_nFormat = nFormat; }
69 15904 : 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 :
86 : // XNameContainer
87 : virtual void SAL_CALL insertByName( const OUString& aName, const ::com::sun::star::uno::Any& aElement )
88 : 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;
89 : virtual void SAL_CALL removeByName( const OUString& Name )
90 : throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
91 :
92 : // XEnumerationAccess
93 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createEnumeration( )
94 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
95 :
96 : // XElementAccess
97 : virtual ::com::sun::star::uno::Type SAL_CALL getElementType( )
98 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
99 : virtual sal_Bool SAL_CALL hasElements( )
100 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
101 :
102 : // XNameAccess
103 : virtual ::com::sun::star::uno::Any SAL_CALL getByName( const OUString& aName )
104 : throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
105 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getElementNames( )
106 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
107 : virtual sal_Bool SAL_CALL hasByName( const OUString& aName )
108 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
109 :
110 : // XNameReplace
111 : virtual void SAL_CALL replaceByName( const OUString& aName, const ::com::sun::star::uno::Any& aElement )
112 : 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;
113 :
114 : // XPropertySet
115 : virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue )
116 : 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;
117 : virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName )
118 : throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
119 :
120 : // XUnoTunnel
121 : virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier )
122 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
123 :
124 : // XServiceInfo
125 : virtual OUString SAL_CALL getImplementationName( )
126 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
127 : virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
128 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
129 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( )
130 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
131 : };
132 : #endif
133 :
134 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|