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_XMLICTXT_HXX 25 #define _XMLOFF_XMLICTXT_HXX 26 27 #include "sal/config.h" 28 #include "xmloff/dllapi.h" 29 #include "sal/types.h" 30 #include <com/sun/star/xml/sax/XAttributeList.hpp> 31 #include <tools/solar.h> 32 #include <tools/ref.hxx> 33 #include <rtl/ustring.hxx> 34 #include <tools/rtti.hxx> 35 36 class SvXMLNamespaceMap; 37 class SvXMLImport; 38 39 class XMLOFF_DLLPUBLIC SvXMLImportContext : public SvRefBase 40 { 41 friend class SvXMLImport; 42 43 SvXMLImport& mrImport; 44 45 sal_uInt16 mnPrefix; 46 ::rtl::OUString maLocalName; 47 48 SvXMLNamespaceMap *mpRewindMap; 49 GetRewindMap() const50 SAL_DLLPRIVATE SvXMLNamespaceMap *GetRewindMap() const 51 { return mpRewindMap; } SetRewindMap(SvXMLNamespaceMap * p)52 SAL_DLLPRIVATE void SetRewindMap( SvXMLNamespaceMap *p ) { mpRewindMap = p; } 53 54 protected: 55 GetImport()56 SvXMLImport& GetImport() { return mrImport; } GetImport() const57 const SvXMLImport& GetImport() const { return mrImport; } 58 59 public: 60 TYPEINFO(); 61 GetPrefix() const62 sal_uInt16 GetPrefix() const { return mnPrefix; } GetLocalName() const63 const ::rtl::OUString& GetLocalName() const { return maLocalName; } 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 SvXMLImportContext( SvXMLImport& rImport, sal_uInt16 nPrfx, 70 const ::rtl::OUString& rLName ); 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 ~SvXMLImportContext(); 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 SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix, 81 const ::rtl::OUString& rLocalName, 82 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList ); 83 84 // StartElement is called after a context has been constructed and 85 // before a elements context is parsed. It may be used for actions that 86 // require virtual methods. The default is to do nothing. 87 virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList ); 88 89 // EndElement is called before a context will be destructed, but 90 // after a elements context has been parsed. It may be used for actions 91 // that require virtual methods. The default is to do nothing. 92 virtual void EndElement(); 93 94 // This method is called for all characters that are contained in the 95 // current element. The default is to ignore them. 96 virtual void Characters( const ::rtl::OUString& rChars ); 97 98 // #124143# allow to copy evtl. useful data from another temporary import context, e.g. used to 99 // support multiple images and to rescue evtl. GluePoints imported with one of the 100 // to be deprecated contents 101 virtual void onDemandRescueUsefulDataFromTemporary( const SvXMLImportContext& rCandidate ); 102 }; 103 104 SV_DECL_REF( SvXMLImportContext ) 105 SV_IMPL_REF( SvXMLImportContext ) 106 107 108 #endif // _XMLOFF_XMLICTXT_HXX 109 110