1*63bba73cSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*63bba73cSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*63bba73cSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*63bba73cSAndrew Rist * distributed with this work for additional information 6*63bba73cSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*63bba73cSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*63bba73cSAndrew Rist * "License"); you may not use this file except in compliance 9*63bba73cSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*63bba73cSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*63bba73cSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*63bba73cSAndrew Rist * software distributed under the License is distributed on an 15*63bba73cSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*63bba73cSAndrew Rist * KIND, either express or implied. See the License for the 17*63bba73cSAndrew Rist * specific language governing permissions and limitations 18*63bba73cSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*63bba73cSAndrew Rist *************************************************************/ 21*63bba73cSAndrew Rist 22*63bba73cSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_xmloff.hxx" 26cdf0e10cSrcweir #include "XMLSectionImportContext.hxx" 27cdf0e10cSrcweir #include "XMLSectionSourceImportContext.hxx" 28cdf0e10cSrcweir #include "XMLSectionSourceDDEImportContext.hxx" 29cdf0e10cSrcweir #include <xmloff/xmlictxt.hxx> 30cdf0e10cSrcweir #include <xmloff/xmlimp.hxx> 31cdf0e10cSrcweir #include <xmloff/txtimp.hxx> 32cdf0e10cSrcweir #include <xmloff/nmspmap.hxx> 33cdf0e10cSrcweir #include "xmloff/xmlnmspe.hxx" 34cdf0e10cSrcweir #include <xmloff/xmltoken.hxx> 35cdf0e10cSrcweir #include <xmloff/xmluconv.hxx> 36cdf0e10cSrcweir #include <xmloff/prstylei.hxx> 37cdf0e10cSrcweir #include <com/sun/star/container/XNamed.hpp> 38cdf0e10cSrcweir #include <com/sun/star/uno/Reference.h> 39cdf0e10cSrcweir #include <com/sun/star/text/XTextContent.hpp> 40cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 41cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp> 42cdf0e10cSrcweir #include <com/sun/star/text/ControlCharacter.hpp> 43cdf0e10cSrcweir 44cdf0e10cSrcweir 45cdf0e10cSrcweir using ::rtl::OUString; 46cdf0e10cSrcweir using ::com::sun::star::beans::XPropertySet; 47cdf0e10cSrcweir using ::com::sun::star::uno::Reference; 48cdf0e10cSrcweir using ::com::sun::star::xml::sax::XAttributeList; 49cdf0e10cSrcweir using ::com::sun::star::lang::XMultiServiceFactory; 50cdf0e10cSrcweir using ::com::sun::star::container::XNamed; 51cdf0e10cSrcweir 52cdf0e10cSrcweir using namespace ::com::sun::star::uno; 53cdf0e10cSrcweir using namespace ::com::sun::star::text; 54cdf0e10cSrcweir using namespace ::xmloff::token; 55cdf0e10cSrcweir 56cdf0e10cSrcweir 57cdf0e10cSrcweir TYPEINIT1( XMLSectionImportContext, SvXMLImportContext ); 58cdf0e10cSrcweir 59cdf0e10cSrcweir const sal_Char sAPI_TextSection[] = "com.sun.star.text.TextSection"; 60cdf0e10cSrcweir const sal_Char sAPI_IndexHeaderSection[] = "com.sun.star.text.IndexHeaderSection"; 61cdf0e10cSrcweir const sal_Char sAPI_IsProtected[] = "IsProtected"; 62cdf0e10cSrcweir const sal_Char sAPI_Condition[] = "Condition"; 63cdf0e10cSrcweir const sal_Char sAPI_IsVisible[] = "IsVisible"; 64cdf0e10cSrcweir const sal_Char sAPI_IsCurrentlyVisible[] = "IsCurrentlyVisible"; 65cdf0e10cSrcweir const sal_Char sAPI_ProtectionKey[] = "ProtectionKey"; 66cdf0e10cSrcweir 67cdf0e10cSrcweir enum XMLSectionToken 68cdf0e10cSrcweir { 69cdf0e10cSrcweir XML_TOK_SECTION_XMLID, 70cdf0e10cSrcweir XML_TOK_SECTION_STYLE_NAME, 71cdf0e10cSrcweir XML_TOK_SECTION_NAME, 72cdf0e10cSrcweir XML_TOK_SECTION_CONDITION, 73cdf0e10cSrcweir XML_TOK_SECTION_DISPLAY, 74cdf0e10cSrcweir XML_TOK_SECTION_PROTECT, 75cdf0e10cSrcweir XML_TOK_SECTION_PROTECTION_KEY, 76cdf0e10cSrcweir XML_TOK_SECTION_IS_HIDDEN 77cdf0e10cSrcweir }; 78cdf0e10cSrcweir 79cdf0e10cSrcweir static __FAR_DATA SvXMLTokenMapEntry aSectionTokenMap[] = 80cdf0e10cSrcweir { 81cdf0e10cSrcweir { XML_NAMESPACE_XML , XML_ID, XML_TOK_SECTION_XMLID }, 82cdf0e10cSrcweir { XML_NAMESPACE_TEXT, XML_STYLE_NAME, XML_TOK_SECTION_STYLE_NAME }, 83cdf0e10cSrcweir { XML_NAMESPACE_TEXT, XML_NAME, XML_TOK_SECTION_NAME }, 84cdf0e10cSrcweir { XML_NAMESPACE_TEXT, XML_CONDITION, XML_TOK_SECTION_CONDITION }, 85cdf0e10cSrcweir { XML_NAMESPACE_TEXT, XML_DISPLAY, XML_TOK_SECTION_DISPLAY }, 86cdf0e10cSrcweir { XML_NAMESPACE_TEXT, XML_PROTECTED, XML_TOK_SECTION_PROTECT }, 87cdf0e10cSrcweir { XML_NAMESPACE_TEXT, XML_PROTECTION_KEY, XML_TOK_SECTION_PROTECTION_KEY}, 88cdf0e10cSrcweir { XML_NAMESPACE_TEXT, XML_IS_HIDDEN, XML_TOK_SECTION_IS_HIDDEN }, 89cdf0e10cSrcweir // compatibility with SRC629 (or earlier) versions 90cdf0e10cSrcweir { XML_NAMESPACE_TEXT, XML_PROTECT, XML_TOK_SECTION_PROTECT }, 91cdf0e10cSrcweir XML_TOKEN_MAP_END 92cdf0e10cSrcweir }; 93cdf0e10cSrcweir 94cdf0e10cSrcweir 95cdf0e10cSrcweir // section import: This one is fairly tricky due to a variety of 96cdf0e10cSrcweir // limits of the core or the API. The main problem is that if you 97cdf0e10cSrcweir // insert a section within another section, you can't move the cursor 98cdf0e10cSrcweir // between the ends of the inner and the enclosing section. To avoid 99cdf0e10cSrcweir // these problems, additional markers are first inserted and later deleted. 100cdf0e10cSrcweir XMLSectionImportContext::XMLSectionImportContext( 101cdf0e10cSrcweir SvXMLImport& rImport, 102cdf0e10cSrcweir sal_uInt16 nPrfx, 103cdf0e10cSrcweir const OUString& rLocalName ) 104cdf0e10cSrcweir : SvXMLImportContext(rImport, nPrfx, rLocalName) 105cdf0e10cSrcweir , sTextSection(RTL_CONSTASCII_USTRINGPARAM(sAPI_TextSection)) 106cdf0e10cSrcweir , sIndexHeaderSection(RTL_CONSTASCII_USTRINGPARAM(sAPI_IndexHeaderSection)) 107cdf0e10cSrcweir , sCondition(RTL_CONSTASCII_USTRINGPARAM(sAPI_Condition)) 108cdf0e10cSrcweir , sIsVisible(RTL_CONSTASCII_USTRINGPARAM(sAPI_IsVisible)) 109cdf0e10cSrcweir , sProtectionKey(RTL_CONSTASCII_USTRINGPARAM(sAPI_ProtectionKey)) 110cdf0e10cSrcweir , sIsProtected(RTL_CONSTASCII_USTRINGPARAM(sAPI_IsProtected)) 111cdf0e10cSrcweir , sIsCurrentlyVisible(RTL_CONSTASCII_USTRINGPARAM(sAPI_IsCurrentlyVisible)) 112cdf0e10cSrcweir , bProtect(sal_False) 113cdf0e10cSrcweir , bCondOK(sal_False) 114cdf0e10cSrcweir , bIsVisible(sal_True) 115cdf0e10cSrcweir , bValid(sal_False) 116cdf0e10cSrcweir , bSequenceOK(sal_False) 117cdf0e10cSrcweir , bIsCurrentlyVisible(sal_True) 118cdf0e10cSrcweir , bIsCurrentlyVisibleOK(sal_False) 119cdf0e10cSrcweir , bHasContent(sal_False) 120cdf0e10cSrcweir { 121cdf0e10cSrcweir } 122cdf0e10cSrcweir 123cdf0e10cSrcweir XMLSectionImportContext::~XMLSectionImportContext() 124cdf0e10cSrcweir { 125cdf0e10cSrcweir } 126cdf0e10cSrcweir 127cdf0e10cSrcweir void XMLSectionImportContext::StartElement( 128cdf0e10cSrcweir const Reference<XAttributeList> & xAttrList) 129cdf0e10cSrcweir { 130cdf0e10cSrcweir // process attributes 131cdf0e10cSrcweir ProcessAttributes(xAttrList); 132cdf0e10cSrcweir 133cdf0e10cSrcweir // process index headers: 134cdf0e10cSrcweir sal_Bool bIsIndexHeader = IsXMLToken( GetLocalName(), XML_INDEX_TITLE ); 135cdf0e10cSrcweir if (bIsIndexHeader) 136cdf0e10cSrcweir { 137cdf0e10cSrcweir bValid = sal_True; 138cdf0e10cSrcweir } 139cdf0e10cSrcweir 140cdf0e10cSrcweir UniReference<XMLTextImportHelper> rHelper = GetImport().GetTextImport(); 141cdf0e10cSrcweir 142cdf0e10cSrcweir // valid? 143cdf0e10cSrcweir if (bValid) 144cdf0e10cSrcweir { 145cdf0e10cSrcweir // create text section (as XPropertySet) 146cdf0e10cSrcweir Reference<XMultiServiceFactory> xFactory( 147cdf0e10cSrcweir GetImport().GetModel(),UNO_QUERY); 148cdf0e10cSrcweir if (xFactory.is()) 149cdf0e10cSrcweir { 150cdf0e10cSrcweir Reference<XInterface> xIfc = 151cdf0e10cSrcweir xFactory->createInstance( bIsIndexHeader ? sIndexHeaderSection 152cdf0e10cSrcweir : sTextSection ); 153cdf0e10cSrcweir if (xIfc.is()) 154cdf0e10cSrcweir { 155cdf0e10cSrcweir Reference<XPropertySet> xPropSet(xIfc, UNO_QUERY); 156cdf0e10cSrcweir 157cdf0e10cSrcweir // save PropertySet (for CreateChildContext) 158cdf0e10cSrcweir xSectionPropertySet = xPropSet; 159cdf0e10cSrcweir 160cdf0e10cSrcweir // name 161cdf0e10cSrcweir Reference<XNamed> xNamed(xPropSet, UNO_QUERY); 162cdf0e10cSrcweir xNamed->setName(sName); 163cdf0e10cSrcweir 164cdf0e10cSrcweir // stylename? 165cdf0e10cSrcweir if (sStyleName.getLength() > 0) 166cdf0e10cSrcweir { 167cdf0e10cSrcweir XMLPropStyleContext* pStyle = rHelper-> 168cdf0e10cSrcweir FindSectionStyle(sStyleName); 169cdf0e10cSrcweir 170cdf0e10cSrcweir if (pStyle != NULL) 171cdf0e10cSrcweir { 172cdf0e10cSrcweir pStyle->FillPropertySet( xPropSet ); 173cdf0e10cSrcweir } 174cdf0e10cSrcweir } 175cdf0e10cSrcweir 176cdf0e10cSrcweir // IsVisible and condition (not for index headers) 177cdf0e10cSrcweir if (! bIsIndexHeader) 178cdf0e10cSrcweir { 179cdf0e10cSrcweir Any aAny; 180cdf0e10cSrcweir aAny.setValue( &bIsVisible, ::getBooleanCppuType() ); 181cdf0e10cSrcweir xPropSet->setPropertyValue( sIsVisible, aAny ); 182cdf0e10cSrcweir 183cdf0e10cSrcweir // #97450# hidden sections must be hidden on reload 184cdf0e10cSrcweir // For backwards compatibilty, set flag only if it is 185cdf0e10cSrcweir // present 186cdf0e10cSrcweir if( bIsCurrentlyVisibleOK ) 187cdf0e10cSrcweir { 188cdf0e10cSrcweir aAny.setValue( &bIsCurrentlyVisible, 189cdf0e10cSrcweir ::getBooleanCppuType() ); 190cdf0e10cSrcweir xPropSet->setPropertyValue( sIsCurrentlyVisible, aAny); 191cdf0e10cSrcweir } 192cdf0e10cSrcweir 193cdf0e10cSrcweir if (bCondOK) 194cdf0e10cSrcweir { 195cdf0e10cSrcweir aAny <<= sCond; 196cdf0e10cSrcweir xPropSet->setPropertyValue( sCondition, aAny ); 197cdf0e10cSrcweir } 198cdf0e10cSrcweir } 199cdf0e10cSrcweir 200cdf0e10cSrcweir // password (only for regular sections) 201cdf0e10cSrcweir if ( bSequenceOK && 202cdf0e10cSrcweir IsXMLToken(GetLocalName(), XML_SECTION) ) 203cdf0e10cSrcweir { 204cdf0e10cSrcweir Any aAny; 205cdf0e10cSrcweir aAny <<= aSequence; 206cdf0e10cSrcweir xPropSet->setPropertyValue(sProtectionKey, aAny); 207cdf0e10cSrcweir } 208cdf0e10cSrcweir 209cdf0e10cSrcweir // protection 210cdf0e10cSrcweir Any aAny; 211cdf0e10cSrcweir aAny.setValue( &bProtect, ::getBooleanCppuType() ); 212cdf0e10cSrcweir xPropSet->setPropertyValue( sIsProtected, aAny ); 213cdf0e10cSrcweir 214cdf0e10cSrcweir // insert marker, <paragraph>, marker; then insert 215cdf0e10cSrcweir // section over the first marker character, and delete the 216cdf0e10cSrcweir // last paragraph (and marker) when closing a section. 217cdf0e10cSrcweir Reference<XTextRange> xStart = 218cdf0e10cSrcweir rHelper->GetCursor()->getStart(); 219cdf0e10cSrcweir #ifndef DBG_UTIL 220cdf0e10cSrcweir static const sal_Char sMarker[] = " "; 221cdf0e10cSrcweir #else 222cdf0e10cSrcweir static const sal_Char sMarker[] = "X"; 223cdf0e10cSrcweir #endif 224cdf0e10cSrcweir OUString sMarkerString(RTL_CONSTASCII_USTRINGPARAM(sMarker)); 225cdf0e10cSrcweir rHelper->InsertString(sMarkerString); 226cdf0e10cSrcweir rHelper->InsertControlCharacter( 227cdf0e10cSrcweir ControlCharacter::APPEND_PARAGRAPH ); 228cdf0e10cSrcweir rHelper->InsertString(sMarkerString); 229cdf0e10cSrcweir 230cdf0e10cSrcweir // select first marker 231cdf0e10cSrcweir rHelper->GetCursor()->gotoRange(xStart, sal_False); 232cdf0e10cSrcweir rHelper->GetCursor()->goRight(1, sal_True); 233cdf0e10cSrcweir 234cdf0e10cSrcweir // convert section to XTextContent 235cdf0e10cSrcweir Reference<XTextContent> xTextContent(xSectionPropertySet, 236cdf0e10cSrcweir UNO_QUERY); 237cdf0e10cSrcweir 238cdf0e10cSrcweir // and insert (over marker) 239cdf0e10cSrcweir rHelper->GetText()->insertTextContent( 240cdf0e10cSrcweir rHelper->GetCursorAsRange(), xTextContent, sal_True ); 241cdf0e10cSrcweir 242cdf0e10cSrcweir // and delete first marker (in section) 243cdf0e10cSrcweir rHelper->GetText()->insertString( 244cdf0e10cSrcweir rHelper->GetCursorAsRange(), sEmpty, sal_True); 245cdf0e10cSrcweir 246cdf0e10cSrcweir // finally, check for redlines that should start at 247cdf0e10cSrcweir // the section start node 248cdf0e10cSrcweir rHelper->RedlineAdjustStartNodeCursor(sal_True); // start ??? 249cdf0e10cSrcweir 250cdf0e10cSrcweir // xml:id for RDF metadata 251cdf0e10cSrcweir GetImport().SetXmlId(xIfc, sXmlId); 252cdf0e10cSrcweir } 253cdf0e10cSrcweir } 254cdf0e10cSrcweir } 255cdf0e10cSrcweir } 256cdf0e10cSrcweir 257cdf0e10cSrcweir void XMLSectionImportContext::ProcessAttributes( 258cdf0e10cSrcweir const Reference<XAttributeList> & xAttrList ) 259cdf0e10cSrcweir { 260cdf0e10cSrcweir SvXMLTokenMap aTokenMap(aSectionTokenMap); 261cdf0e10cSrcweir 262cdf0e10cSrcweir sal_Int16 nLength = xAttrList->getLength(); 263cdf0e10cSrcweir for(sal_Int16 nAttr = 0; nAttr < nLength; nAttr++) 264cdf0e10cSrcweir { 265cdf0e10cSrcweir OUString sLocalName; 266cdf0e10cSrcweir sal_uInt16 nNamePrefix = GetImport().GetNamespaceMap(). 267cdf0e10cSrcweir GetKeyByAttrName( xAttrList->getNameByIndex(nAttr), 268cdf0e10cSrcweir &sLocalName ); 269cdf0e10cSrcweir OUString sAttr = xAttrList->getValueByIndex(nAttr); 270cdf0e10cSrcweir 271cdf0e10cSrcweir switch (aTokenMap.Get(nNamePrefix, sLocalName)) 272cdf0e10cSrcweir { 273cdf0e10cSrcweir case XML_TOK_SECTION_XMLID: 274cdf0e10cSrcweir sXmlId = sAttr; 275cdf0e10cSrcweir break; 276cdf0e10cSrcweir case XML_TOK_SECTION_STYLE_NAME: 277cdf0e10cSrcweir sStyleName = sAttr; 278cdf0e10cSrcweir break; 279cdf0e10cSrcweir case XML_TOK_SECTION_NAME: 280cdf0e10cSrcweir sName = sAttr; 281cdf0e10cSrcweir bValid = sal_True; 282cdf0e10cSrcweir break; 283cdf0e10cSrcweir case XML_TOK_SECTION_CONDITION: 284cdf0e10cSrcweir { 285cdf0e10cSrcweir OUString sTmp; 286cdf0e10cSrcweir sal_uInt16 nPrefix = GetImport().GetNamespaceMap(). 287cdf0e10cSrcweir _GetKeyByAttrName( sAttr, &sTmp, sal_False ); 288cdf0e10cSrcweir if( XML_NAMESPACE_OOOW == nPrefix ) 289cdf0e10cSrcweir { 290cdf0e10cSrcweir sCond = sTmp; 291cdf0e10cSrcweir bCondOK = sal_True; 292cdf0e10cSrcweir } 293cdf0e10cSrcweir else 294cdf0e10cSrcweir sCond = sAttr; 295cdf0e10cSrcweir } 296cdf0e10cSrcweir break; 297cdf0e10cSrcweir case XML_TOK_SECTION_DISPLAY: 298cdf0e10cSrcweir if (IsXMLToken(sAttr, XML_TRUE)) 299cdf0e10cSrcweir { 300cdf0e10cSrcweir bIsVisible = sal_True; 301cdf0e10cSrcweir } 302cdf0e10cSrcweir else if ( IsXMLToken(sAttr, XML_NONE) || 303cdf0e10cSrcweir IsXMLToken(sAttr, XML_CONDITION) ) 304cdf0e10cSrcweir { 305cdf0e10cSrcweir bIsVisible = sal_False; 306cdf0e10cSrcweir } 307cdf0e10cSrcweir // else: ignore 308cdf0e10cSrcweir break; 309cdf0e10cSrcweir case XML_TOK_SECTION_IS_HIDDEN: 310cdf0e10cSrcweir { 311cdf0e10cSrcweir sal_Bool bTmp; 312cdf0e10cSrcweir if (SvXMLUnitConverter::convertBool(bTmp, sAttr)) 313cdf0e10cSrcweir { 314cdf0e10cSrcweir bIsCurrentlyVisible = !bTmp; 315cdf0e10cSrcweir bIsCurrentlyVisibleOK = sal_True; 316cdf0e10cSrcweir } 317cdf0e10cSrcweir } 318cdf0e10cSrcweir break; 319cdf0e10cSrcweir case XML_TOK_SECTION_PROTECTION_KEY: 320cdf0e10cSrcweir SvXMLUnitConverter::decodeBase64(aSequence, sAttr); 321cdf0e10cSrcweir bSequenceOK = sal_True; 322cdf0e10cSrcweir break; 323cdf0e10cSrcweir case XML_TOK_SECTION_PROTECT: 324cdf0e10cSrcweir { 325cdf0e10cSrcweir sal_Bool bTmp; 326cdf0e10cSrcweir if (SvXMLUnitConverter::convertBool(bTmp, sAttr)) 327cdf0e10cSrcweir { 328cdf0e10cSrcweir bProtect = bTmp; 329cdf0e10cSrcweir } 330cdf0e10cSrcweir break; 331cdf0e10cSrcweir } 332cdf0e10cSrcweir default: 333cdf0e10cSrcweir ; // ignore 334cdf0e10cSrcweir break; 335cdf0e10cSrcweir } 336cdf0e10cSrcweir } 337cdf0e10cSrcweir } 338cdf0e10cSrcweir 339cdf0e10cSrcweir void XMLSectionImportContext::EndElement() 340cdf0e10cSrcweir { 341cdf0e10cSrcweir // get rid of last paragraph 342cdf0e10cSrcweir // (unless it's the only paragraph in the section) 343cdf0e10cSrcweir UniReference<XMLTextImportHelper> rHelper = GetImport().GetTextImport(); 344cdf0e10cSrcweir rHelper->GetCursor()->goRight(1, sal_False); 345cdf0e10cSrcweir if (bHasContent) 346cdf0e10cSrcweir { 347cdf0e10cSrcweir rHelper->GetCursor()->goLeft(1, sal_True); 348cdf0e10cSrcweir rHelper->GetText()->insertString(rHelper->GetCursorAsRange(), 349cdf0e10cSrcweir sEmpty, sal_True); 350cdf0e10cSrcweir } 351cdf0e10cSrcweir 352cdf0e10cSrcweir // and delete second marker 353cdf0e10cSrcweir rHelper->GetCursor()->goRight(1, sal_True); 354cdf0e10cSrcweir rHelper->GetText()->insertString(rHelper->GetCursorAsRange(), 355cdf0e10cSrcweir sEmpty, sal_True); 356cdf0e10cSrcweir 357cdf0e10cSrcweir // check for redlines to our endnode 358cdf0e10cSrcweir rHelper->RedlineAdjustStartNodeCursor(sal_False); 359cdf0e10cSrcweir } 360cdf0e10cSrcweir 361cdf0e10cSrcweir SvXMLImportContext* XMLSectionImportContext::CreateChildContext( 362cdf0e10cSrcweir sal_uInt16 nPrefix, 363cdf0e10cSrcweir const OUString& rLocalName, 364cdf0e10cSrcweir const Reference<XAttributeList> & xAttrList ) 365cdf0e10cSrcweir { 366cdf0e10cSrcweir SvXMLImportContext* pContext = NULL; 367cdf0e10cSrcweir 368cdf0e10cSrcweir // section-source (-dde) elements 369cdf0e10cSrcweir if ( (XML_NAMESPACE_TEXT == nPrefix) && 370cdf0e10cSrcweir IsXMLToken(rLocalName, XML_SECTION_SOURCE) ) 371cdf0e10cSrcweir { 372cdf0e10cSrcweir pContext = new XMLSectionSourceImportContext(GetImport(), 373cdf0e10cSrcweir nPrefix, rLocalName, 374cdf0e10cSrcweir xSectionPropertySet); 375cdf0e10cSrcweir } 376cdf0e10cSrcweir else if ( (XML_NAMESPACE_OFFICE == nPrefix) && 377cdf0e10cSrcweir IsXMLToken(rLocalName, XML_DDE_SOURCE) ) 378cdf0e10cSrcweir { 379cdf0e10cSrcweir pContext = new XMLSectionSourceDDEImportContext(GetImport(), 380cdf0e10cSrcweir nPrefix, rLocalName, 381cdf0e10cSrcweir xSectionPropertySet); 382cdf0e10cSrcweir } 383cdf0e10cSrcweir else 384cdf0e10cSrcweir { 385cdf0e10cSrcweir // otherwise: text context 386cdf0e10cSrcweir pContext = GetImport().GetTextImport()->CreateTextChildContext( 387cdf0e10cSrcweir GetImport(), nPrefix, rLocalName, xAttrList, 388cdf0e10cSrcweir XML_TEXT_TYPE_SECTION ); 389cdf0e10cSrcweir 390cdf0e10cSrcweir // if that fails, default context 391cdf0e10cSrcweir if (NULL == pContext) 392cdf0e10cSrcweir { 393cdf0e10cSrcweir pContext = new SvXMLImportContext( GetImport(), 394cdf0e10cSrcweir nPrefix, rLocalName ); 395cdf0e10cSrcweir } 396cdf0e10cSrcweir else 397cdf0e10cSrcweir bHasContent = sal_True; 398cdf0e10cSrcweir } 399cdf0e10cSrcweir 400cdf0e10cSrcweir return pContext; 401cdf0e10cSrcweir } 402cdf0e10cSrcweir 403