LibreOffice Module xmloff (master)  1
XMLChangeElementImportContext.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
22 #include "XMLChangeInfoContext.hxx"
23 #include <com/sun/star/uno/Reference.h>
24 #include <xmloff/xmlimp.hxx>
25 #include <xmloff/xmlnamespace.hxx>
26 #include <xmloff/xmltoken.hxx>
27 
28 
29 using ::com::sun::star::uno::Reference;
30 using ::com::sun::star::xml::sax::XAttributeList;
33 
34 
36  SvXMLImport& rImport,
37  sal_uInt16 nPrefix,
38  const OUString& rLocalName,
39  bool bAccContent,
41  SvXMLImportContext(rImport, nPrefix, rLocalName),
42  bAcceptContent(bAccContent),
43  rChangedRegion(rParent)
44 {
45 }
46 
48  sal_uInt16 nPrefix,
49  const OUString& rLocalName,
50  const Reference<XAttributeList> & xAttrList)
51 {
52  SvXMLImportContextRef xContext;
53 
54  if ( (XML_NAMESPACE_OFFICE == nPrefix) &&
55  IsXMLToken( rLocalName, XML_CHANGE_INFO) )
56  {
57  xContext = new XMLChangeInfoContext(GetImport(), nPrefix, rLocalName,
59  }
60  else
61  {
62  // import into redline -> create XText
64 
65  xContext = GetImport().GetTextImport()->CreateTextChildContext(
66  GetImport(), nPrefix, rLocalName, xAttrList,
68 
69  if (!xContext)
70  {
71  // no text element
72  // illegal element content! TODO: discard this redline!
73  // for the moment -> use default
74  }
75  }
76 
77  return xContext;
78 }
79 
80 void XMLChangeElementImportContext::StartElement( const Reference< XAttributeList >& )
81 {
82  if(bAcceptContent)
83  {
84  GetImport().GetTextImport()->SetInsideDeleteContext(true);
85  }
86 }
87 
89 {
90  if(bAcceptContent)
91  {
92  GetImport().GetTextImport()->SetInsideDeleteContext(false);
93  }
94 }
95 
96 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Import elements as children of elements.
bool IsXMLToken(const OUString &rString, enum XMLTokenEnum eToken)
compare eToken to the string
Definition: xmltoken.cxx:3434
constexpr sal_uInt16 XML_NAMESPACE_OFFICE
virtual SvXMLImportContextRef CreateChildContext(sal_uInt16 nPrefix, const OUString &rLocalName, const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList) override
Create a children element context.
SvXMLImport & GetImport()
Definition: xmlictxt.hxx:62
rtl::Reference< XMLTextImportHelper > const & GetTextImport()
Definition: xmlimp.hxx:600
void UseRedlineText()
create redline XText/XTextCursor on demand and register with XMLTextImportHelper
bool bAcceptContent
accept text content (paragraphs) in element as redline content?
const OUString & GetLocalName() const
Definition: xmlictxt.hxx:69
XMLChangedRegionImportContext & rChangedRegion
context of enclosing element
Import elements contained in a element.
This class deliberately does not support XWeak, to improve performance when loading large documents...
Definition: xmlictxt.hxx:44
virtual void EndElement() override
EndElement is called before a context will be destructed, but after an elements context has been pars...
virtual void StartElement(const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList) override
StartElement is called after a context has been constructed and before an elements context is parsed...
XMLChangeElementImportContext(SvXMLImport &rImport, sal_uInt16 nPrefix, const OUString &rLocalName, bool bAcceptContent, XMLChangedRegionImportContext &rParent)