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( OUString, PropertyMap );
52 :
53 0 : struct Node
54 : {
55 : 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();
65 : virtual ~TypeDetectionImporter( void );
66 :
67 : static void doImport( const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& rxContext, 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 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 OUString& aName )
76 : throw(::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
77 : virtual void SAL_CALL characters( const OUString& aChars )
78 : throw(::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
79 : virtual void SAL_CALL ignorableWhitespace( const OUString& aWhitespaces )
80 : throw(::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
81 : virtual void SAL_CALL processingInstruction( const OUString& aTarget, const 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 OUString& rType );
90 :
91 : std::stack< ImportState > maStack;
92 : PropertyMap maPropertyMap;
93 :
94 : NodeVector maFilterNodes;
95 : NodeVector maTypeNodes;
96 :
97 : OUString maValue;
98 : OUString maNodeName;
99 : OUString maPropertyName;
100 :
101 : const OUString sRootNode;
102 : const OUString sNode;
103 : const OUString sName;
104 : const OUString sProp;
105 : const OUString sValue;
106 : const OUString sUIName;
107 : const OUString sData;
108 : const OUString sFilters;
109 : const OUString sTypes;
110 : const OUString sFilterAdaptorService;
111 : const OUString sXSLTFilterService;
112 :
113 : const OUString sCdataAttribute;
114 : const OUString sWhiteSpace;
115 :
116 : };
117 : #endif
118 :
119 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|