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