xref: /AOO41X/main/filter/source/xsltdialog/typedetectionimport.hxx (revision 22e87013b212da8c80c93e291ad90de8f36964c2)
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 _TYPEDETECTION_IMPORT_HXX
25 #define _TYPEDETECTION_IMPORT_HXX
26 
27 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
28 #include <com/sun/star/io/XInputStream.hpp>
29 #include <cppuhelper/implbase1.hxx> // helper for implementations
30 #ifndef _COM_SUN_STAR_XML_SAX_XDUCUMENTHANDLER_HPP_
31 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
32 #endif
33 #include <comphelper/stl_types.hxx>
34 
35 #include "xmlfilterjar.hxx"
36 
37 #include <vector>
38 #include <stack>
39 
40 namespace com { namespace sun { namespace star {
41     namespace xml { namespace sax { class XAttributeList; } }
42     namespace beans { struct PropertyValue; }
43 } } }
44 
45 enum ImportState
46 {
47     e_Root,
48     e_Filters,
49     e_Types,
50     e_Filter,
51     e_Type,
52     e_Property,
53     e_Value,
54     e_Unknown
55 };
56 
57 DECLARE_STL_USTRINGACCESS_MAP( ::rtl::OUString, PropertyMap );
58 
59 struct Node
60 {
61     ::rtl::OUString maName;
62     PropertyMap maPropertyMap;
63 };
64 
65 typedef std::vector< Node* > NodeVector;
66 
67 class TypeDetectionImporter : public cppu::WeakImplHelper1 < com::sun::star::xml::sax::XDocumentHandler >
68 {
69 public:
70     TypeDetectionImporter( com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& xMSF );
71     virtual ~TypeDetectionImporter( void );
72 
73     static void doImport( com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& xMSF, com::sun::star::uno::Reference < com::sun::star::io::XInputStream > xOS, XMLFilterVector& rFilters );
74 
75     virtual void SAL_CALL startDocument(  )
76         throw(::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
77     virtual void SAL_CALL endDocument(  )
78         throw(::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
79     virtual void SAL_CALL startElement( const ::rtl::OUString& aName, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttribs )
80         throw(::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
81     virtual void SAL_CALL endElement( const ::rtl::OUString& aName )
82         throw(::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
83     virtual void SAL_CALL characters( const ::rtl::OUString& aChars )
84         throw(::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
85     virtual void SAL_CALL ignorableWhitespace( const ::rtl::OUString& aWhitespaces )
86         throw(::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
87     virtual void SAL_CALL processingInstruction( const ::rtl::OUString& aTarget, const ::rtl::OUString& aData )
88         throw(::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
89     virtual void SAL_CALL setDocumentLocator( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator >& xLocator )
90         throw(::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
91 
92 private:
93     void fillFilterVector(  XMLFilterVector& rFilters );
94     filter_info_impl* createFilterForNode( Node * pNode );
95     Node* findTypeNode( const ::rtl::OUString& rType );
96 
97     com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > mxMSF;
98 
99     std::stack< ImportState > maStack;
100     PropertyMap maPropertyMap;
101 
102     NodeVector maFilterNodes;
103     NodeVector maTypeNodes;
104 
105     ::rtl::OUString maValue;
106     ::rtl::OUString maNodeName;
107     ::rtl::OUString maPropertyName;
108 
109     const ::rtl::OUString sRootNode;
110     const ::rtl::OUString sNode;
111     const ::rtl::OUString sName;
112     const ::rtl::OUString sProp;
113     const ::rtl::OUString sValue;
114     const ::rtl::OUString sUIName;
115     const ::rtl::OUString sData;
116     const ::rtl::OUString sFilters;
117     const ::rtl::OUString sTypes;
118     const ::rtl::OUString sFilterAdaptorService;
119     const ::rtl::OUString sXSLTFilterService;
120 
121     const ::rtl::OUString sCdataAttribute;
122     const ::rtl::OUString sWhiteSpace;
123 
124 };
125 #endif
126