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 "XMLChangeElementImportContext.hxx" 27 #include "XMLChangedRegionImportContext.hxx" 28 #include "XMLChangeInfoContext.hxx" 29 #include <com/sun/star/uno/Reference.h> 30 #include <xmloff/xmlimp.hxx> 31 #include "xmloff/xmlnmspe.hxx" 32 #include <xmloff/xmltoken.hxx> 33 34 35 36 using ::rtl::OUString; 37 using ::com::sun::star::uno::Reference; 38 using ::com::sun::star::xml::sax::XAttributeList; 39 using ::xmloff::token::IsXMLToken; 40 using ::xmloff::token::XML_P; 41 using ::xmloff::token::XML_CHANGE_INFO; 42 43 TYPEINIT1( XMLChangeElementImportContext, SvXMLImportContext ); 44 45 XMLChangeElementImportContext::XMLChangeElementImportContext( 46 SvXMLImport& rImport, 47 sal_uInt16 nPrefix, 48 const OUString& rLocalName, 49 sal_Bool bAccContent, 50 XMLChangedRegionImportContext& rParent) : 51 SvXMLImportContext(rImport, nPrefix, rLocalName), 52 bAcceptContent(bAccContent), 53 rChangedRegion(rParent) 54 { 55 } 56 57 SvXMLImportContext* XMLChangeElementImportContext::CreateChildContext( 58 sal_uInt16 nPrefix, 59 const OUString& rLocalName, 60 const Reference<XAttributeList> & xAttrList) 61 { 62 SvXMLImportContext* pContext = NULL; 63 64 if ( (XML_NAMESPACE_OFFICE == nPrefix) && 65 IsXMLToken( rLocalName, XML_CHANGE_INFO) ) 66 { 67 pContext = new XMLChangeInfoContext(GetImport(), nPrefix, rLocalName, 68 rChangedRegion, GetLocalName()); 69 } 70 else 71 { 72 // import into redline -> create XText 73 rChangedRegion.UseRedlineText(); 74 75 pContext = GetImport().GetTextImport()->CreateTextChildContext( 76 GetImport(), nPrefix, rLocalName, xAttrList, 77 XML_TEXT_TYPE_CHANGED_REGION); 78 79 if (NULL == pContext) 80 { 81 // no text element -> use default 82 pContext = SvXMLImportContext::CreateChildContext( 83 nPrefix, rLocalName, xAttrList); 84 85 // illegal element content! TODO: discard this redline! 86 } 87 } 88 89 90 return pContext; 91 } 92 93 // #107848# 94 void XMLChangeElementImportContext::StartElement( const Reference< XAttributeList >& ) 95 { 96 if(bAcceptContent) 97 { 98 GetImport().GetTextImport()->SetInsideDeleteContext(sal_True); 99 } 100 } 101 102 // #107848# 103 void XMLChangeElementImportContext::EndElement() 104 { 105 if(bAcceptContent) 106 { 107 GetImport().GetTextImport()->SetInsideDeleteContext(sal_False); 108 } 109 } 110