merge the formfield patch from ooo-build
[ooovba.git] / xmloff / source / transform / TransformerBase.hxx
blobb3fb3f629ae7ec18c92a0d551cdb657e5baf13ab
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: TransformerBase.hxx,v $
10 * $Revision: 1.9.56.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _XMLOFF_TRANSFORMER_BASE_HXX
32 #define _XMLOFF_TRANSFORMER_BASE_HXX
34 #include <com/sun/star/xml/sax/SAXParseException.hpp>
35 #include <com/sun/star/xml/sax/SAXException.hpp>
36 #include <com/sun/star/xml/sax/XAttributeList.hpp>
37 #include <com/sun/star/xml/sax/XLocator.hpp>
38 #include <com/sun/star/beans/XPropertySet.hpp>
39 #include <com/sun/star/frame/XModel.hpp>
40 #include <xmloff/xmltoken.hxx>
42 #ifndef _XMLOFF_TRANSFORMER_HXX_
43 #include "Transformer.hxx"
44 #endif
46 namespace rtl { class OUString; }
47 namespace com { namespace sun { namespace star {
48 namespace i18n { class XCharacterClassification; }
49 }}}
51 class SvXMLNamespaceMap;
52 class XMLTransformerContext;
53 class XMLTransformerContextVector;
54 class XMLTransformerActions;
55 struct XMLTransformerActionInit;
56 struct TransformerAction_Impl;
57 class XMLMutableAttributeList;
58 class XMLTransformerTokenMap;
60 const sal_uInt16 INVALID_ACTIONS = 0xffff;
62 class XMLTransformerBase : public XMLTransformer
64 friend class XMLTransformerContext;
66 ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator >
67 m_xLocator;
69 ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > m_xHandler; // the handlers
70 ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XExtendedDocumentHandler > m_xExtHandler;
71 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xPropSet;
72 ::com::sun::star::uno::Reference<
73 ::com::sun::star::i18n::XCharacterClassification > xCharClass;
75 ::rtl::OUString m_aExtPathPrefix;
76 ::rtl::OUString m_aClass;
78 SvXMLNamespaceMap *m_pNamespaceMap;
79 SvXMLNamespaceMap *m_pReplaceNamespaceMap;
80 XMLTransformerContextVector *m_pContexts;
81 XMLTransformerActions *m_pElemActions;
82 XMLTransformerTokenMap *m_pTokenMap;
84 protected:
85 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > mxModel;
87 // This method is called after the namespace map has been updated, but
88 // before a context for the current element has been pushed.
89 XMLTransformerContext *CreateContext( sal_uInt16 nPrefix,
90 const ::rtl::OUString& rLocalName,
91 const ::rtl::OUString& rQName );
93 // this method may return an empty reference when the transformer service
94 // was created outside the xmloff environment.
95 // It is strictly forbiden to use this as a write access to the model!
96 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& getModel() const { return mxModel; }
98 public:
99 XMLTransformerBase( XMLTransformerActionInit *pInit=0,
100 ::xmloff::token::XMLTokenEnum *pTKMapInit=0 ) throw();
101 virtual ~XMLTransformerBase() throw();
103 // ::com::sun::star::xml::sax::XDocumentHandler
104 virtual void SAL_CALL startDocument(void)
105 throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException );
106 virtual void SAL_CALL endDocument(void)
107 throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException );
108 virtual void SAL_CALL startElement(const ::rtl::OUString& aName,
109 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttribs)
110 throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException );
111 virtual void SAL_CALL endElement(const ::rtl::OUString& aName)
112 throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException );
113 virtual void SAL_CALL characters(const ::rtl::OUString& aChars)
114 throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException );
115 virtual void SAL_CALL ignorableWhitespace(const ::rtl::OUString& aWhitespaces)
116 throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException );
117 virtual void SAL_CALL processingInstruction(const ::rtl::OUString& aTarget,
118 const ::rtl::OUString& aData)
119 throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException );
120 virtual void SAL_CALL setDocumentLocator(const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator > & xLocator)
121 throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException );
123 // ::com::sun::star::xml::sax::XExtendedDocumentHandler
124 virtual void SAL_CALL startCDATA(void) throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException );
125 virtual void SAL_CALL endCDATA(void) throw( ::com::sun::star::uno::RuntimeException );
126 virtual void SAL_CALL comment(const ::rtl::OUString& sComment)
127 throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException );
128 virtual void SAL_CALL allowLineBreak(void)
129 throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException );
130 virtual void SAL_CALL unknown(const ::rtl::OUString& sString)
131 throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException );
133 // XInitialization
134 virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
136 // C++
137 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > & GetDocHandler() { return m_xHandler; }
139 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & GetPropertySet() { return m_xPropSet; }
142 SvXMLNamespaceMap& GetNamespaceMap() { return *m_pNamespaceMap; }
143 const SvXMLNamespaceMap& GetNamespaceMap() const { return *m_pNamespaceMap; }
144 SvXMLNamespaceMap& GetReplaceNamespaceMap() { return *m_pReplaceNamespaceMap; }
146 XMLTransformerActions& GetElemActions() { return *m_pElemActions; }
147 virtual XMLTransformerActions *GetUserDefinedActions( sal_uInt16 n );
148 virtual XMLTransformerContext *CreateUserDefinedContext(
149 const TransformerAction_Impl& rAction,
150 const ::rtl::OUString& rQName,
151 sal_Bool bPersistent=sal_False ) = 0;
152 virtual ::rtl::OUString GetEventName( const ::rtl::OUString& rName,
153 sal_Bool bForm = sal_False ) = 0;
156 XMLMutableAttributeList *ProcessAttrList( ::com::sun::star::uno::Reference<
157 ::com::sun::star::xml::sax::XAttributeList >& rAttrList,
158 sal_uInt16 nActionMap, sal_Bool bClone );
160 static sal_Bool ReplaceSingleInchWithIn( ::rtl::OUString& rValue );
161 static sal_Bool ReplaceSingleInWithInch( ::rtl::OUString& rValue );
162 static sal_Bool ReplaceInchWithIn( ::rtl::OUString& rValue );
163 static sal_Bool ReplaceInWithInch( ::rtl::OUString& rValue );
165 sal_Bool EncodeStyleName( ::rtl::OUString& rName ) const;
166 static sal_Bool DecodeStyleName( ::rtl::OUString& rName );
167 static sal_Bool NegPercent( ::rtl::OUString& rValue );
169 sal_Bool AddNamespacePrefix( ::rtl::OUString& rName,
170 sal_uInt16 nPrefix ) const;
171 sal_Bool RemoveNamespacePrefix( ::rtl::OUString& rName,
172 sal_uInt16 nPrefixOnly=0xffffU ) const;
174 sal_Bool ConvertURIToOASIS( ::rtl::OUString& rURI,
175 sal_Bool bSupportPackage=sal_False ) const;
176 sal_Bool ConvertURIToOOo( ::rtl::OUString& rURI,
177 sal_Bool bSupportPackage=sal_False ) const;
179 /** renames the given rOutAttributeValue if one of the parameters contains a
180 matching token in its lower 16 bits. The value is converted to the
181 token that is given in the upper 16 bits of the matching parameter.
183 sal_Bool RenameAttributeValue( ::rtl::OUString& rOutAttributeValue,
184 sal_Int32 nParam1,
185 sal_Int32 nParam2,
186 sal_Int32 nParam3 );
188 /** converts the '.' that separates fractions of seconds in a dateTime
189 string into a ',' that was used in the OOo format
191 @param rDateTime
192 A dateTime string that will be parsed and changed in case a match
193 was found.
194 @return <TRUE/> if the given string was changed
196 static bool ConvertRNGDateTimeToISO( ::rtl::OUString& rDateTime );
198 ::xmloff::token::XMLTokenEnum GetToken( const ::rtl::OUString& rStr ) const;
200 const XMLTransformerContext *GetCurrentContext() const;
201 const XMLTransformerContext *GetAncestorContext( sal_uInt32 i ) const;
203 // C++
204 inline void SetClass( const ::rtl::OUString& r ) { m_aClass = r; }
205 inline const ::rtl::OUString& GetClass() const { return m_aClass; }
207 bool isWriter() const;
211 #endif // _XMLOFF_TRANSFORMER_BASE_HXX