merged tag LIBREOFFICE_3_2_99_3
[LibreOffice.git] / scripting / source / storage / ScriptMetadataImporter.hxx
blob3c94bff75d26c0e0bb86a26933031c304f373677
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
28 #ifndef _SCRIPTING_STORAGE_SCRIPTMETADATAIMPORTER_HXX_
29 #define _SCRIPTING_STORAGE_SCRIPTMETADATAIMPORTER_HXX_
31 #include <vector>
33 #include <rtl/ustring.h>
34 #include <rtl/ustrbuf.hxx>
35 #include <osl/mutex.hxx>
36 #include <cppuhelper/implbase1.hxx> // helper for component factory
38 #include <com/sun/star/uno/XComponentContext.hpp>
39 #include <com/sun/star/lang/XServiceInfo.hpp>
40 #include <com/sun/star/lang/XInitialization.hpp>
41 #include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp>
42 #include <com/sun/star/io/XInputStream.hpp>
44 #include "ScriptData.hxx"
46 namespace scripting_impl
48 // for simplification
49 #define css ::com::sun::star
50 #define dcsssf ::drafts::com::sun::star::script::framework
52 typedef ::std::vector< ScriptData > InfoImpls_vec;
53 typedef ::std::pair< ::rtl::OUString, ::std::pair< ::rtl::OUString,
54 ::rtl::OUString > > strpair_pair;
56 /**
57 * Script Meta Data Importer
59 class ScriptMetadataImporter : public
60 ::cppu::WeakImplHelper1< css::xml::sax::XExtendedDocumentHandler >
62 public:
64 /**
65 * This function will begin the parser and parse the meta data
67 * @param xInput The XInputStream for the parser which contains the XML
68 * @param parcelURI The parcel's URI in the document or the application
70 * @see css::io::XInputStream
72 void parseMetaData( css::uno::Reference< css::io::XInputStream >
73 const & xInput, const ::rtl::OUString & parcelURI,
74 InfoImpls_vec & io_ScriptDatas )
75 throw ( css::xml::sax::SAXException, css::io::IOException,
76 css::uno::RuntimeException );
78 /**
79 * Constructor for the meta-data parser
81 * @param XComponentContext
83 explicit ScriptMetadataImporter(
84 const css::uno::Reference< css::uno::XComponentContext >& );
86 /**
87 * Destructor for the parser
89 virtual ~ScriptMetadataImporter() SAL_THROW( () );
91 // XExtendedDocumentHandler impl
92 /**
93 * Function to handle the start of CDATA in XML
95 * @see com::sun::star::xml::sax::XExtendedDocumentHandler
97 virtual void SAL_CALL startCDATA()
98 throw ( css::xml::sax::SAXException, css::uno::RuntimeException );
101 * Function to handle the end of CDATA in XML
103 * @see com::sun::star::xml::sax::XExtendedDocumentHandler
105 virtual void SAL_CALL endCDATA() throw ( css::uno::RuntimeException );
108 * Function to handle comments in XML
110 * @see com::sun::star::xml::sax::XExtendedDocumentHandler
112 virtual void SAL_CALL comment( const ::rtl::OUString & sComment )
113 throw ( css::xml::sax::SAXException, css::uno::RuntimeException );
116 * Function to handle line breaks in XML
118 * @see com::sun::star::xml::sax::XExtendedDocumentHandler
120 virtual void SAL_CALL allowLineBreak()
121 throw ( css::xml::sax::SAXException, css::uno::RuntimeException );
124 * Function to handle unknowns in XML
126 * @see com::sun::star::xml::sax::XExtendedDocumentHandler
128 virtual void SAL_CALL unknown( const ::rtl::OUString & sString )
129 throw ( css::xml::sax::SAXException, css::uno::RuntimeException );
132 * Function to handle the start of XML document
134 * @see com::sun::star::xml::sax::XExtendedDocumentHandler
136 // XDocumentHandler impl
137 virtual void SAL_CALL startDocument()
138 throw ( css::xml::sax::SAXException, css::uno::RuntimeException );
141 * Function to handle the end of the XML document
143 * @see com::sun::star::xml::sax::XDocumentHandler
145 virtual void SAL_CALL endDocument()
146 throw ( css::xml::sax::SAXException, css::uno::RuntimeException );
149 * Function to handle the start of an element
151 * @see com::sun::star::xml::sax::XDocumentHandler
153 virtual void SAL_CALL startElement( const ::rtl::OUString& aName,
154 const css::uno::Reference< css::xml::sax::XAttributeList > & xAttribs )
155 throw ( css::xml::sax::SAXException,
156 css::uno::RuntimeException );
159 * Function to handle the end of an element
161 * @see com::sun::star::xml::sax::XDocumentHandler
163 virtual void SAL_CALL endElement( const ::rtl::OUString & aName )
164 throw ( css::xml::sax::SAXException, css::uno::RuntimeException );
167 * Function to handle characters in elements
169 * @see com::sun::star::xml::sax::XDocumentHandler
171 virtual void SAL_CALL characters( const ::rtl::OUString & aChars )
172 throw ( css::xml::sax::SAXException, css::uno::RuntimeException );
175 * Function to handle whitespace
177 * @see com::sun::star::xml::sax::XDocumentHandler
179 virtual void SAL_CALL ignorableWhitespace( const ::rtl::OUString & aWhitespaces )
180 throw ( css::xml::sax::SAXException, css::uno::RuntimeException );
183 * Function to handle XML processing instructions
185 * @see com::sun::star::xml::sax::XDocumentHandler
187 virtual void SAL_CALL processingInstruction(
188 const ::rtl::OUString & aTarget, const ::rtl::OUString & aData )
189 throw ( css::xml::sax::SAXException, css::uno::RuntimeException );
192 * Function to set the document locator
194 * @see com::sun::star::xml::sax::XDocumentHandler
196 virtual void SAL_CALL setDocumentLocator(
197 const css::uno::Reference< css::xml::sax::XLocator >& xLocator )
198 throw ( css::xml::sax::SAXException, css::uno::RuntimeException );
202 private:
204 /** Vector contains the ScriptData structs */
205 InfoImpls_vec* mpv_ScriptDatas;
207 /** @internal */
208 osl::Mutex m_mutex;
210 /** @internal */
211 css::uno::Reference< css::uno::XComponentContext > m_xContext;
213 /** Placeholder for the parcel URI */
214 ::rtl::OUString ms_parcelURI;
216 /** States for state machine during parsing */
217 enum { PARCEL, SCRIPT, LOCALE, DISPLAYNAME, DESCRIPTION, FUNCTIONNAME,
218 LOGICALNAME, LANGUAGEDEPPROPS, LANGDEPPROPS, FILESET, FILESETPROPS,
219 FILES, FILEPROPS } m_state;
221 /** Build up the struct during parsing the meta data */
222 ScriptData m_ScriptData;
224 /** @internal */
225 ::rtl::OUString ms_localeLang;
226 ::rtl::OUString ms_localeDisName;
227 ::rtl::OUStringBuffer *ms_localeDesc;
229 props_vec mv_filesetprops;
231 ::rtl::OUString ms_filename;
232 ::rtl::OUString ms_filesetname;
234 props_vec mv_fileprops;
236 strpairvec_map mm_files;
238 InfoImpls_vec mv_ScriptDatas;
241 * Helper function to set the state
243 * @param tagName
244 * The current tag being processed
246 void setState(const ::rtl::OUString & tagName);
248 ; // class ScriptMetadataImporter
252 #endif
254 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */