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 _XMLOFF_TRANSFORMERCONTEXT_HXX 25 #define _XMLOFF_TRANSFORMERCONTEXT_HXX 26 27 #include <com/sun/star/xml/sax/XAttributeList.hpp> 28 #include <tools/solar.h> 29 #include <salhelper/simplereferenceobject.hxx> 30 #include <rtl/ustring.hxx> 31 #include <tools/rtti.hxx> 32 #include <xmloff/xmltoken.hxx> 33 34 class SvXMLNamespaceMap; 35 class XMLTransformerBase; 36 37 class XMLTransformerContext : public ::salhelper::SimpleReferenceObject 38 { 39 friend class XMLTransformerBase; 40 41 XMLTransformerBase& m_rTransformer; 42 43 ::rtl::OUString m_aQName; 44 45 SvXMLNamespaceMap *m_pRewindMap; 46 GetRewindMap() const47 SvXMLNamespaceMap *GetRewindMap() const { return m_pRewindMap; } SetRewindMap(SvXMLNamespaceMap * p)48 void SetRewindMap( SvXMLNamespaceMap *p ) { m_pRewindMap = p; } 49 50 protected: 51 GetTransformer()52 XMLTransformerBase& GetTransformer() { return m_rTransformer; } GetTransformer() const53 const XMLTransformerBase& GetTransformer() const { return m_rTransformer; } 54 SetQName(const::rtl::OUString & rQName)55 void SetQName( const ::rtl::OUString& rQName ) { m_aQName = rQName; } 56 57 public: 58 TYPEINFO(); 59 GetQName() const60 const ::rtl::OUString& GetQName() const { return m_aQName; } 61 sal_Bool HasQName( sal_uInt16 nPrefix, 62 ::xmloff::token::XMLTokenEnum eToken ) const; 63 sal_Bool HasNamespace( sal_uInt16 nPrefix ) const; 64 65 // A contexts constructor does anything that is required if an element 66 // starts. Namespace processing has been done already. 67 // Note that virtual methods cannot be used inside constructors. Use 68 // StartElement instead if this is required. 69 XMLTransformerContext( XMLTransformerBase& rTransformer, 70 const ::rtl::OUString& rQName ); 71 72 // A contexts destructor does anything that is required if an element 73 // ends. By default, nothing is done. 74 // Note that virtual methods cannot be used inside destructors. Use 75 // EndElement instead if this is required. 76 virtual ~XMLTransformerContext(); 77 78 // Create a childs element context. By default, the import's 79 // CreateContext method is called to create a new default context. 80 virtual XMLTransformerContext *CreateChildContext( sal_uInt16 nPrefix, 81 const ::rtl::OUString& rLocalName, 82 const ::rtl::OUString& rQName, 83 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList ); 84 85 // StartElement is called after a context has been constructed and 86 // before a elements context is parsed. It may be used for actions that 87 // require virtual methods. The default is to do nothing. 88 virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList ); 89 90 // EndElement is called before a context will be destructed, but 91 // after a elements context has been parsed. It may be used for actions 92 // that require virtual methods. The default is to do nothing. 93 virtual void EndElement(); 94 95 // This method is called for all characters that are contained in the 96 // current element. The default is to ignore them. 97 virtual void Characters( const ::rtl::OUString& rChars ); 98 99 // Is the current context a persistent one (i.e. one that saves is content 100 // rather than exporting it directly? 101 virtual sal_Bool IsPersistent() const; 102 103 // Export the whole element. By default, nothing is done here 104 virtual void Export(); 105 106 // Export the element content. By default, nothing is done here 107 virtual void ExportContent(); 108 }; 109 110 111 #endif // _XMLOFF_TRANSFORMERCONTEXT_HXX 112 113