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 : protected:
53 : ContentHash maContents;
54 : const ::com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory > m_xFactory;
55 : sal_Int32 m_nFormat;
56 : ::rtl::OUString m_sVersion;
57 :
58 : public:
59 :
60 : ZipPackageFolder( const ::com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory >& xFactory,
61 : sal_Int32 nFormat,
62 : sal_Bool bAllowRemoveOnInsert );
63 : virtual ~ZipPackageFolder();
64 :
65 74 : ::rtl::OUString& GetVersion() { return m_sVersion; }
66 239 : void SetVersion( const ::rtl::OUString& aVersion ) { m_sVersion = aVersion; }
67 :
68 : sal_Bool LookForUnexpectedODF12Streams( const ::rtl::OUString& aPath );
69 :
70 : void setChildStreamsTypeByExtension( const ::com::sun::star::beans::StringPair& aPair );
71 :
72 : void doInsertByName ( ZipPackageEntry *pEntry, sal_Bool bSetParent )
73 : throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::ElementExistException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
74 :
75 : com::sun::star::packages::ContentInfo & doGetByName( const ::rtl::OUString& aName )
76 : throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
77 :
78 : static void copyZipEntry( ZipEntry &rDest, const ZipEntry &rSource);
79 : static const ::com::sun::star::uno::Sequence < sal_Int8 >& static_getImplementationId();
80 :
81 378 : void setPackageFormat_Impl( sal_Int32 nFormat ) { m_nFormat = nFormat; }
82 1016 : void setRemoveOnInsertMode_Impl( sal_Bool bRemove ) { this->mbAllowRemoveOnInsert = bRemove; }
83 :
84 : bool saveChild(const rtl::OUString &rShortName, const com::sun::star::packages::ContentInfo &rInfo, rtl::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);
85 :
86 : // Recursive functions
87 : void saveContents(rtl::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)
88 : throw(::com::sun::star::uno::RuntimeException);
89 : void releaseUpwardRef();
90 :
91 : // XNameContainer
92 : virtual void SAL_CALL insertByName( const ::rtl::OUString& aName, const ::com::sun::star::uno::Any& aElement )
93 : throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::ElementExistException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
94 : virtual void SAL_CALL removeByName( const ::rtl::OUString& Name )
95 : throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
96 :
97 : // XEnumerationAccess
98 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createEnumeration( )
99 : throw(::com::sun::star::uno::RuntimeException);
100 :
101 : // XElementAccess
102 : virtual ::com::sun::star::uno::Type SAL_CALL getElementType( )
103 : throw(::com::sun::star::uno::RuntimeException);
104 : virtual sal_Bool SAL_CALL hasElements( )
105 : throw(::com::sun::star::uno::RuntimeException);
106 :
107 : // XNameAccess
108 : virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName )
109 : throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
110 : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames( )
111 : throw(::com::sun::star::uno::RuntimeException);
112 : virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName )
113 : throw(::com::sun::star::uno::RuntimeException);
114 :
115 : // XNameReplace
116 : virtual void SAL_CALL replaceByName( const ::rtl::OUString& aName, const ::com::sun::star::uno::Any& aElement )
117 : throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
118 :
119 : // XPropertySet
120 : virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue )
121 : 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);
122 : virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName )
123 : throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
124 :
125 : // XUnoTunnel
126 : virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier )
127 : throw(::com::sun::star::uno::RuntimeException);
128 :
129 : // XServiceInfo
130 : virtual ::rtl::OUString SAL_CALL getImplementationName( )
131 : throw (::com::sun::star::uno::RuntimeException);
132 : virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
133 : throw (::com::sun::star::uno::RuntimeException);
134 : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( )
135 : throw (::com::sun::star::uno::RuntimeException);
136 : };
137 : #endif
138 :
139 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|