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 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_xmloff.hxx" 26 #include <tools/debug.hxx> 27 #include "XMLTextPropertySetContext.hxx" 28 #include "XMLTextColumnsContext.hxx" 29 #include "XMLBackgroundImageContext.hxx" 30 #include "XMLSectionFootnoteConfigImport.hxx" 31 32 #ifndef _XMLOFF_TXTPRMAP_HXX 33 #include <xmloff/txtprmap.hxx> 34 #endif 35 #include "xmltabi.hxx" 36 #ifndef _XMLOFF_TXTDROPI_HXX 37 #include "txtdropi.hxx" 38 #endif 39 40 using ::rtl::OUString; 41 42 using namespace ::com::sun::star::uno; 43 using namespace ::com::sun::star; 44 45 XMLTextPropertySetContext::XMLTextPropertySetContext( 46 SvXMLImport& rImport, sal_uInt16 nPrfx, 47 const OUString& rLName, 48 const Reference< xml::sax::XAttributeList > & xAttrList, 49 sal_uInt32 nFamily, 50 ::std::vector< XMLPropertyState > &rProps, 51 const UniReference < SvXMLImportPropertyMapper > &rMap, 52 OUString& rDCTextStyleName ) : 53 SvXMLPropertySetContext( rImport, nPrfx, rLName, xAttrList, nFamily, 54 rProps, rMap ), 55 rDropCapTextStyleName( rDCTextStyleName ) 56 { 57 } 58 59 XMLTextPropertySetContext::~XMLTextPropertySetContext() 60 { 61 } 62 63 SvXMLImportContext *XMLTextPropertySetContext::CreateChildContext( 64 sal_uInt16 nPrefix, 65 const OUString& rLocalName, 66 const Reference< xml::sax::XAttributeList > & xAttrList, 67 ::std::vector< XMLPropertyState > &rProperties, 68 const XMLPropertyState& rProp ) 69 { 70 SvXMLImportContext *pContext = 0; 71 72 switch( mxMapper->getPropertySetMapper() 73 ->GetEntryContextId( rProp.mnIndex ) ) 74 { 75 case CTF_TABSTOP: 76 pContext = new SvxXMLTabStopImportContext( GetImport(), nPrefix, 77 rLocalName, rProp, 78 rProperties ); 79 break; 80 case CTF_TEXTCOLUMNS: 81 #ifndef SVX_LIGHT 82 pContext = new XMLTextColumnsContext( GetImport(), nPrefix, 83 rLocalName, xAttrList, rProp, 84 rProperties ); 85 #else 86 // create default context to skip content 87 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); 88 #endif // #ifndef SVX_LIGHT 89 break; 90 91 case CTF_DROPCAPFORMAT: 92 { 93 DBG_ASSERT( rProp.mnIndex >= 2 && 94 CTF_DROPCAPWHOLEWORD == mxMapper->getPropertySetMapper() 95 ->GetEntryContextId( rProp.mnIndex-2 ), 96 "invalid property map!"); 97 XMLTextDropCapImportContext *pDCContext = 98 new XMLTextDropCapImportContext( GetImport(), nPrefix, 99 rLocalName, xAttrList, 100 rProp, 101 rProp.mnIndex-2, 102 rProperties ); 103 rDropCapTextStyleName = pDCContext->GetStyleName(); 104 pContext = pDCContext; 105 } 106 break; 107 108 case CTF_BACKGROUND_URL: 109 { 110 DBG_ASSERT( rProp.mnIndex >= 2 && 111 CTF_BACKGROUND_POS == mxMapper->getPropertySetMapper() 112 ->GetEntryContextId( rProp.mnIndex-2 ) && 113 CTF_BACKGROUND_FILTER == mxMapper->getPropertySetMapper() 114 ->GetEntryContextId( rProp.mnIndex-1 ), 115 "invalid property map!"); 116 117 // #99657# Transparency might be there as well... but doesn't have 118 // to. Thus, this is checked with an if, rather than with an assertion. 119 sal_Int32 nTranspIndex = -1; 120 if( (rProp.mnIndex >= 3) && 121 ( CTF_BACKGROUND_TRANSPARENCY == 122 mxMapper->getPropertySetMapper()->GetEntryContextId( 123 rProp.mnIndex-3 ) ) ) 124 nTranspIndex = rProp.mnIndex-3; 125 126 pContext = 127 new XMLBackgroundImageContext( GetImport(), nPrefix, 128 rLocalName, xAttrList, 129 rProp, 130 rProp.mnIndex-2, 131 rProp.mnIndex-1, 132 nTranspIndex, 133 rProperties ); 134 } 135 break; 136 #ifndef SVX_LIGHT 137 case CTF_SECTION_FOOTNOTE_END: 138 case CTF_SECTION_ENDNOTE_END: 139 pContext = new XMLSectionFootnoteConfigImport( 140 GetImport(), nPrefix, rLocalName, rProperties, 141 mxMapper->getPropertySetMapper()); 142 break; 143 #endif // #ifndef SVX_LIGHT 144 } 145 146 if( !pContext ) 147 pContext = SvXMLPropertySetContext::CreateChildContext( nPrefix, rLocalName, 148 xAttrList, 149 rProperties, rProp ); 150 151 return pContext; 152 } 153 154 155