bump product version to 5.0.4.1
[LibreOffice.git] / xmloff / source / text / XMLChangeElementImportContext.cxx
blob08420ec92e905c96afd006c67dfaef124319f419
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "XMLChangeElementImportContext.hxx"
21 #include "XMLChangedRegionImportContext.hxx"
22 #include "XMLChangeInfoContext.hxx"
23 #include <com/sun/star/uno/Reference.h>
24 #include <xmloff/xmlimp.hxx>
25 #include <xmloff/xmlnmspe.hxx>
26 #include <xmloff/xmltoken.hxx>
30 using ::com::sun::star::uno::Reference;
31 using ::com::sun::star::xml::sax::XAttributeList;
32 using ::xmloff::token::IsXMLToken;
33 using ::xmloff::token::XML_P;
34 using ::xmloff::token::XML_CHANGE_INFO;
36 TYPEINIT1( XMLChangeElementImportContext, SvXMLImportContext );
38 XMLChangeElementImportContext::XMLChangeElementImportContext(
39 SvXMLImport& rImport,
40 sal_uInt16 nPrefix,
41 const OUString& rLocalName,
42 bool bAccContent,
43 XMLChangedRegionImportContext& rParent) :
44 SvXMLImportContext(rImport, nPrefix, rLocalName),
45 bAcceptContent(bAccContent),
46 rChangedRegion(rParent)
50 SvXMLImportContext* XMLChangeElementImportContext::CreateChildContext(
51 sal_uInt16 nPrefix,
52 const OUString& rLocalName,
53 const Reference<XAttributeList> & xAttrList)
55 SvXMLImportContext* pContext = NULL;
57 if ( (XML_NAMESPACE_OFFICE == nPrefix) &&
58 IsXMLToken( rLocalName, XML_CHANGE_INFO) )
60 pContext = new XMLChangeInfoContext(GetImport(), nPrefix, rLocalName,
61 rChangedRegion, GetLocalName());
63 else
65 // import into redline -> create XText
66 rChangedRegion.UseRedlineText();
68 pContext = GetImport().GetTextImport()->CreateTextChildContext(
69 GetImport(), nPrefix, rLocalName, xAttrList,
70 XML_TEXT_TYPE_CHANGED_REGION);
72 if (NULL == pContext)
74 // no text element
75 // illegal element content! TODO: discard this redline!
76 // for the moment -> use default
77 pContext = SvXMLImportContext::CreateChildContext(
78 nPrefix, rLocalName, xAttrList);
82 return pContext;
85 // #107848#
86 void XMLChangeElementImportContext::StartElement( const Reference< XAttributeList >& )
88 if(bAcceptContent)
90 GetImport().GetTextImport()->SetInsideDeleteContext(true);
94 // #107848#
95 void XMLChangeElementImportContext::EndElement()
97 if(bAcceptContent)
99 GetImport().GetTextImport()->SetInsideDeleteContext(false);
103 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */