Branch data 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 : :
20 : : #ifndef _MANIFEST_IMPORT_HXX
21 : : #define _MANIFEST_IMPORT_HXX
22 : :
23 : : #include <cppuhelper/implbase1.hxx> // helper for implementations
24 : : #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
25 : : #include <comphelper/sequenceasvector.hxx>
26 : : #include <vector>
27 : :
28 : : #include <HashMaps.hxx>
29 : :
30 : : namespace com { namespace sun { namespace star {
31 : : namespace xml { namespace sax { class XAttributeList; } }
32 : : namespace beans { struct PropertyValue; }
33 : : } } }
34 : :
35 : : typedef ::boost::unordered_map< ::rtl::OUString, ::rtl::OUString, ::rtl::OUStringHash, eqFunc > StringHashMap;
36 : :
37 [ + - ]: 11443 : struct ManifestScopeEntry
38 : : {
39 : : ::rtl::OUString m_aConvertedName;
40 : : StringHashMap m_aNamespaces;
41 : : bool m_bValid;
42 : :
43 : 11443 : ManifestScopeEntry( const ::rtl::OUString& aConvertedName, const StringHashMap& aNamespaces )
44 : : : m_aConvertedName( aConvertedName )
45 : : , m_aNamespaces( aNamespaces )
46 [ + - ]: 11443 : , m_bValid( true )
47 : 11443 : {}
48 : :
49 : 22886 : ~ManifestScopeEntry()
50 [ + - ]: 22886 : {}
51 : : };
52 : :
53 : : typedef ::std::vector< ManifestScopeEntry > ManifestStack;
54 : :
55 : : class ManifestImport : public cppu::WeakImplHelper1 < com::sun::star::xml::sax::XDocumentHandler >
56 : : {
57 : : protected:
58 : : comphelper::SequenceAsVector< com::sun::star::beans::PropertyValue > aSequence;
59 : : ManifestStack aStack;
60 : : sal_Bool bIgnoreEncryptData;
61 : : sal_Int32 nDerivedKeySize;
62 : : ::std::vector < ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue > > & rManVector;
63 : :
64 : : const ::rtl::OUString sFileEntryElement;
65 : : const ::rtl::OUString sManifestElement;
66 : : const ::rtl::OUString sEncryptionDataElement;
67 : : const ::rtl::OUString sAlgorithmElement;
68 : : const ::rtl::OUString sStartKeyAlgElement;
69 : : const ::rtl::OUString sKeyDerivationElement;
70 : :
71 : : const ::rtl::OUString sCdataAttribute;
72 : : const ::rtl::OUString sMediaTypeAttribute;
73 : : const ::rtl::OUString sVersionAttribute;
74 : : const ::rtl::OUString sFullPathAttribute;
75 : : const ::rtl::OUString sSizeAttribute;
76 : : const ::rtl::OUString sSaltAttribute;
77 : : const ::rtl::OUString sInitialisationVectorAttribute;
78 : : const ::rtl::OUString sIterationCountAttribute;
79 : : const ::rtl::OUString sKeySizeAttribute;
80 : : const ::rtl::OUString sAlgorithmNameAttribute;
81 : : const ::rtl::OUString sStartKeyAlgNameAttribute;
82 : : const ::rtl::OUString sKeyDerivationNameAttribute;
83 : : const ::rtl::OUString sChecksumAttribute;
84 : : const ::rtl::OUString sChecksumTypeAttribute;
85 : :
86 : : const ::rtl::OUString sFullPathProperty;
87 : : const ::rtl::OUString sMediaTypeProperty;
88 : : const ::rtl::OUString sVersionProperty;
89 : : const ::rtl::OUString sIterationCountProperty;
90 : : const ::rtl::OUString sDerivedKeySizeProperty;
91 : : const ::rtl::OUString sSaltProperty;
92 : : const ::rtl::OUString sInitialisationVectorProperty;
93 : : const ::rtl::OUString sSizeProperty;
94 : : const ::rtl::OUString sDigestProperty;
95 : : const ::rtl::OUString sEncryptionAlgProperty;
96 : : const ::rtl::OUString sStartKeyAlgProperty;
97 : : const ::rtl::OUString sDigestAlgProperty;
98 : :
99 : : const ::rtl::OUString sWhiteSpace;
100 : :
101 : : const ::rtl::OUString sSHA256_URL;
102 : : const ::rtl::OUString sSHA1_Name;
103 : : const ::rtl::OUString sSHA1_URL;
104 : :
105 : : const ::rtl::OUString sSHA256_1k_URL;
106 : : const ::rtl::OUString sSHA1_1k_Name;
107 : : const ::rtl::OUString sSHA1_1k_URL;
108 : :
109 : : const ::rtl::OUString sBlowfish_Name;
110 : : const ::rtl::OUString sBlowfish_URL;
111 : : const ::rtl::OUString sAES128_URL;
112 : : const ::rtl::OUString sAES192_URL;
113 : : const ::rtl::OUString sAES256_URL;
114 : :
115 : : const ::rtl::OUString sPBKDF2_Name;
116 : : const ::rtl::OUString sPBKDF2_URL;
117 : :
118 : :
119 : : ::rtl::OUString PushNameAndNamespaces( const ::rtl::OUString& aName,
120 : : const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttribs,
121 : : StringHashMap& o_aConvertedAttribs );
122 : : ::rtl::OUString ConvertNameWithNamespace( const ::rtl::OUString& aName, const StringHashMap& aNamespaces );
123 : : ::rtl::OUString ConvertName( const ::rtl::OUString& aName );
124 : :
125 : : public:
126 : : ManifestImport( std::vector < ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue > > & rNewVector );
127 : : ~ManifestImport( void );
128 : : virtual void SAL_CALL startDocument( )
129 : : throw(::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
130 : : virtual void SAL_CALL endDocument( )
131 : : throw(::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
132 : : virtual void SAL_CALL startElement( const ::rtl::OUString& aName, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttribs )
133 : : throw(::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
134 : : virtual void SAL_CALL endElement( const ::rtl::OUString& aName )
135 : : throw(::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
136 : : virtual void SAL_CALL characters( const ::rtl::OUString& aChars )
137 : : throw(::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
138 : : virtual void SAL_CALL ignorableWhitespace( const ::rtl::OUString& aWhitespaces )
139 : : throw(::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
140 : : virtual void SAL_CALL processingInstruction( const ::rtl::OUString& aTarget, const ::rtl::OUString& aData )
141 : : throw(::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
142 : : virtual void SAL_CALL setDocumentLocator( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator >& xLocator )
143 : : throw(::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
144 : : private:
145 : : void doFileEntry(StringHashMap &rConvertedAttribs) throw(::com::sun::star::uno::RuntimeException);
146 : : void doEncryptionData(StringHashMap &rConvertedAttribs) throw(::com::sun::star::uno::RuntimeException);
147 : : void doAlgorithm(StringHashMap &rConvertedAttribs) throw(::com::sun::star::uno::RuntimeException);
148 : : void doKeyDerivation(StringHashMap &rConvertedAttribs) throw(::com::sun::star::uno::RuntimeException);
149 : : void doStartKeyAlg(StringHashMap &rConvertedAttribs) throw(::com::sun::star::uno::RuntimeException);
150 : : };
151 : : #endif
152 : :
153 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|