1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _MANIFEST_IMPORT_HXX
25 #define _MANIFEST_IMPORT_HXX
26 
27 #include <cppuhelper/implbase1.hxx> // helper for implementations
28 #ifndef _COM_SUN_STAR_XML_SAX_XDUCUMENTHANDLER_HPP_
29 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
30 #endif
31 #include "PackageConstants.hxx"
32 #include <vector>
33 
34 #include <com/sun/star/beans/PropertyValues.hpp>
35 #include <HashMaps.hxx>
36 
37 namespace com { namespace sun { namespace star {
38 	namespace xml { namespace sax { class XAttributeList; } }
39 	namespace beans { struct PropertyValue; }
40 } } }
41 
42 typedef ::std::hash_map< ::rtl::OUString, ::rtl::OUString, ::rtl::OUStringHash, eqFunc > StringHashMap;
43 
44 struct ManifestScopeEntry
45 {
46     ::rtl::OUString m_aConvertedName;
47     StringHashMap   m_aNamespaces;
48 
ManifestScopeEntryManifestScopeEntry49     ManifestScopeEntry( const ::rtl::OUString& aConvertedName, const StringHashMap& aNamespaces )
50     : m_aConvertedName( aConvertedName )
51     , m_aNamespaces( aNamespaces )
52     {}
53 
~ManifestScopeEntryManifestScopeEntry54     ~ManifestScopeEntry()
55     {}
56 };
57 
58 typedef ::std::vector< ManifestScopeEntry > ManifestStack;
59 
60 class ManifestImport : public cppu::WeakImplHelper1 < com::sun::star::xml::sax::XDocumentHandler >
61 {
62 protected:
63 	::com::sun::star::uno::Any maValues[ PKG_SIZE_ENCR_MNFST ];
64 
65 	::std::vector < ::com::sun::star::beans::PropertyValues > & rManVector;
66 	ManifestStack aStack;
67     sal_Int32 nDerivedKeySize;
68 	bool bIgnoreEncryptData;
69 
70 	const ::rtl::OUString sCdataAttribute;
71 	const ::rtl::OUString sMediaTypeAttribute;
72 	const ::rtl::OUString sVersionAttribute;
73 	const ::rtl::OUString sFullPathAttribute;
74 	const ::rtl::OUString sSizeAttribute;
75 	const ::rtl::OUString sSaltAttribute;
76 	const ::rtl::OUString sInitialisationVectorAttribute;
77 	const ::rtl::OUString sIterationCountAttribute;
78 	const ::rtl::OUString sKeySizeAttribute;
79 	const ::rtl::OUString sAlgorithmNameAttribute;
80 	const ::rtl::OUString sStartKeyAlgNameAttribute;
81 	const ::rtl::OUString sKeyDerivationNameAttribute;
82 	const ::rtl::OUString sChecksumAttribute;
83 	const ::rtl::OUString sChecksumTypeAttribute;
84 
85     ::rtl::OUString PushNameAndNamespaces( const ::rtl::OUString& aName,
86                                            const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttribs,
87                                            StringHashMap& o_aConvertedAttribs );
88     ::rtl::OUString ConvertNameWithNamespace( const ::rtl::OUString& aName, const StringHashMap& aNamespaces );
89     ::rtl::OUString ConvertName( const ::rtl::OUString& aName );
90 
91 public:
92 	ManifestImport( std::vector < ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue > > & rNewVector );
93 	~ManifestImport( void );
94     virtual void SAL_CALL startDocument(  )
95 		throw(::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
96     virtual void SAL_CALL endDocument(  )
97 		throw(::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
98     virtual void SAL_CALL startElement( const ::rtl::OUString& aName, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttribs )
99 		throw(::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
100     virtual void SAL_CALL endElement( const ::rtl::OUString& aName )
101 		throw(::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
102     virtual void SAL_CALL characters( const ::rtl::OUString& aChars )
103 		throw(::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
104     virtual void SAL_CALL ignorableWhitespace( const ::rtl::OUString& aWhitespaces )
105 		throw(::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
106     virtual void SAL_CALL processingInstruction( const ::rtl::OUString& aTarget, const ::rtl::OUString& aData )
107 		throw(::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
108     virtual void SAL_CALL setDocumentLocator( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator >& xLocator )
109 		throw(::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
110 };
111 #endif
112