1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir #ifndef _MANIFEST_IMPORT_HXX 29*cdf0e10cSrcweir #define _MANIFEST_IMPORT_HXX 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx> // helper for implementations 32*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_XML_SAX_XDUCUMENTHANDLER_HPP_ 33*cdf0e10cSrcweir #include <com/sun/star/xml/sax/XDocumentHandler.hpp> 34*cdf0e10cSrcweir #endif 35*cdf0e10cSrcweir #include <vector> 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir #include <HashMaps.hxx> 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir namespace com { namespace sun { namespace star { 40*cdf0e10cSrcweir namespace xml { namespace sax { class XAttributeList; } } 41*cdf0e10cSrcweir namespace beans { struct PropertyValue; } 42*cdf0e10cSrcweir } } } 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir typedef ::std::hash_map< ::rtl::OUString, ::rtl::OUString, ::rtl::OUStringHash, eqFunc > StringHashMap; 45*cdf0e10cSrcweir 46*cdf0e10cSrcweir struct ManifestScopeEntry 47*cdf0e10cSrcweir { 48*cdf0e10cSrcweir ::rtl::OUString m_aConvertedName; 49*cdf0e10cSrcweir StringHashMap m_aNamespaces; 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir ManifestScopeEntry( const ::rtl::OUString& aConvertedName, const StringHashMap& aNamespaces ) 52*cdf0e10cSrcweir : m_aConvertedName( aConvertedName ) 53*cdf0e10cSrcweir , m_aNamespaces( aNamespaces ) 54*cdf0e10cSrcweir {} 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir ~ManifestScopeEntry() 57*cdf0e10cSrcweir {} 58*cdf0e10cSrcweir }; 59*cdf0e10cSrcweir 60*cdf0e10cSrcweir typedef ::std::vector< ManifestScopeEntry > ManifestStack; 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir class ManifestImport : public cppu::WeakImplHelper1 < com::sun::star::xml::sax::XDocumentHandler > 63*cdf0e10cSrcweir { 64*cdf0e10cSrcweir protected: 65*cdf0e10cSrcweir com::sun::star::uno::Sequence < com::sun::star::beans::PropertyValue > aSequence; 66*cdf0e10cSrcweir sal_Int16 nNumProperty; 67*cdf0e10cSrcweir ManifestStack aStack; 68*cdf0e10cSrcweir sal_Bool bIgnoreEncryptData; 69*cdf0e10cSrcweir sal_Int32 nDerivedKeySize; 70*cdf0e10cSrcweir ::std::vector < ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue > > & rManVector; 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir const ::rtl::OUString sFileEntryElement; 73*cdf0e10cSrcweir const ::rtl::OUString sManifestElement; 74*cdf0e10cSrcweir const ::rtl::OUString sEncryptionDataElement; 75*cdf0e10cSrcweir const ::rtl::OUString sAlgorithmElement; 76*cdf0e10cSrcweir const ::rtl::OUString sStartKeyAlgElement; 77*cdf0e10cSrcweir const ::rtl::OUString sKeyDerivationElement; 78*cdf0e10cSrcweir 79*cdf0e10cSrcweir const ::rtl::OUString sCdataAttribute; 80*cdf0e10cSrcweir const ::rtl::OUString sMediaTypeAttribute; 81*cdf0e10cSrcweir const ::rtl::OUString sVersionAttribute; 82*cdf0e10cSrcweir const ::rtl::OUString sFullPathAttribute; 83*cdf0e10cSrcweir const ::rtl::OUString sSizeAttribute; 84*cdf0e10cSrcweir const ::rtl::OUString sSaltAttribute; 85*cdf0e10cSrcweir const ::rtl::OUString sInitialisationVectorAttribute; 86*cdf0e10cSrcweir const ::rtl::OUString sIterationCountAttribute; 87*cdf0e10cSrcweir const ::rtl::OUString sKeySizeAttribute; 88*cdf0e10cSrcweir const ::rtl::OUString sAlgorithmNameAttribute; 89*cdf0e10cSrcweir const ::rtl::OUString sStartKeyAlgNameAttribute; 90*cdf0e10cSrcweir const ::rtl::OUString sKeyDerivationNameAttribute; 91*cdf0e10cSrcweir const ::rtl::OUString sChecksumAttribute; 92*cdf0e10cSrcweir const ::rtl::OUString sChecksumTypeAttribute; 93*cdf0e10cSrcweir 94*cdf0e10cSrcweir const ::rtl::OUString sFullPathProperty; 95*cdf0e10cSrcweir const ::rtl::OUString sMediaTypeProperty; 96*cdf0e10cSrcweir const ::rtl::OUString sVersionProperty; 97*cdf0e10cSrcweir const ::rtl::OUString sIterationCountProperty; 98*cdf0e10cSrcweir const ::rtl::OUString sDerivedKeySizeProperty; 99*cdf0e10cSrcweir const ::rtl::OUString sSaltProperty; 100*cdf0e10cSrcweir const ::rtl::OUString sInitialisationVectorProperty; 101*cdf0e10cSrcweir const ::rtl::OUString sSizeProperty; 102*cdf0e10cSrcweir const ::rtl::OUString sDigestProperty; 103*cdf0e10cSrcweir const ::rtl::OUString sEncryptionAlgProperty; 104*cdf0e10cSrcweir const ::rtl::OUString sStartKeyAlgProperty; 105*cdf0e10cSrcweir const ::rtl::OUString sDigestAlgProperty; 106*cdf0e10cSrcweir 107*cdf0e10cSrcweir const ::rtl::OUString sWhiteSpace; 108*cdf0e10cSrcweir 109*cdf0e10cSrcweir const ::rtl::OUString sSHA256_URL; 110*cdf0e10cSrcweir const ::rtl::OUString sSHA1_Name; 111*cdf0e10cSrcweir const ::rtl::OUString sSHA1_URL; 112*cdf0e10cSrcweir 113*cdf0e10cSrcweir const ::rtl::OUString sSHA256_1k_URL; 114*cdf0e10cSrcweir const ::rtl::OUString sSHA1_1k_Name; 115*cdf0e10cSrcweir const ::rtl::OUString sSHA1_1k_URL; 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir const ::rtl::OUString sBlowfish_Name; 118*cdf0e10cSrcweir const ::rtl::OUString sBlowfish_URL; 119*cdf0e10cSrcweir const ::rtl::OUString sAES128_URL; 120*cdf0e10cSrcweir const ::rtl::OUString sAES192_URL; 121*cdf0e10cSrcweir const ::rtl::OUString sAES256_URL; 122*cdf0e10cSrcweir 123*cdf0e10cSrcweir const ::rtl::OUString sPBKDF2_Name; 124*cdf0e10cSrcweir const ::rtl::OUString sPBKDF2_URL; 125*cdf0e10cSrcweir 126*cdf0e10cSrcweir 127*cdf0e10cSrcweir ::rtl::OUString PushNameAndNamespaces( const ::rtl::OUString& aName, 128*cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttribs, 129*cdf0e10cSrcweir StringHashMap& o_aConvertedAttribs ); 130*cdf0e10cSrcweir ::rtl::OUString ConvertNameWithNamespace( const ::rtl::OUString& aName, const StringHashMap& aNamespaces ); 131*cdf0e10cSrcweir ::rtl::OUString ConvertName( const ::rtl::OUString& aName ); 132*cdf0e10cSrcweir 133*cdf0e10cSrcweir public: 134*cdf0e10cSrcweir ManifestImport( std::vector < ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue > > & rNewVector ); 135*cdf0e10cSrcweir ~ManifestImport( void ); 136*cdf0e10cSrcweir virtual void SAL_CALL startDocument( ) 137*cdf0e10cSrcweir throw(::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); 138*cdf0e10cSrcweir virtual void SAL_CALL endDocument( ) 139*cdf0e10cSrcweir throw(::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); 140*cdf0e10cSrcweir virtual void SAL_CALL startElement( const ::rtl::OUString& aName, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttribs ) 141*cdf0e10cSrcweir throw(::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); 142*cdf0e10cSrcweir virtual void SAL_CALL endElement( const ::rtl::OUString& aName ) 143*cdf0e10cSrcweir throw(::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); 144*cdf0e10cSrcweir virtual void SAL_CALL characters( const ::rtl::OUString& aChars ) 145*cdf0e10cSrcweir throw(::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); 146*cdf0e10cSrcweir virtual void SAL_CALL ignorableWhitespace( const ::rtl::OUString& aWhitespaces ) 147*cdf0e10cSrcweir throw(::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); 148*cdf0e10cSrcweir virtual void SAL_CALL processingInstruction( const ::rtl::OUString& aTarget, const ::rtl::OUString& aData ) 149*cdf0e10cSrcweir throw(::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); 150*cdf0e10cSrcweir virtual void SAL_CALL setDocumentLocator( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator >& xLocator ) 151*cdf0e10cSrcweir throw(::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); 152*cdf0e10cSrcweir }; 153*cdf0e10cSrcweir #endif 154