LibreOffice Module xmloff (master)  1
XMLChangeImportContext.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 
21 #include <xmloff/xmlimp.hxx>
22 #include <xmloff/xmlnmspe.hxx>
23 #include <xmloff/nmspmap.hxx>
24 #include <xmloff/xmltoken.hxx>
25 
26 using ::com::sun::star::uno::Reference;
27 using ::com::sun::star::xml::sax::XAttributeList;
30 
31 
33  SvXMLImport& rImport,
34  sal_Int16 nPrefix,
35  const OUString& rLocalName,
36  Element const eElement,
37  bool bOutsideOfParagraph)
38  : SvXMLImportContext(rImport, nPrefix, rLocalName)
39  , m_Element(eElement)
40  , m_bIsOutsideOfParagraph(bOutsideOfParagraph)
41 {
42 }
43 
45 {
46 }
47 
49  const Reference<XAttributeList>& xAttrList)
50 {
51  sal_Int16 nLength = xAttrList->getLength();
52  for(sal_Int16 nAttr = 0; nAttr < nLength; nAttr++)
53  {
54  OUString sLocalName;
55  sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
56  GetKeyByAttrName( xAttrList->getNameByIndex(nAttr),
57  &sLocalName );
58  if ( (XML_NAMESPACE_TEXT == nPrefix) &&
59  IsXMLToken( sLocalName, XML_CHANGE_ID ) )
60  {
61  // Id found! Now call RedlineImportHelper
62 
63  // prepare parameters
66  OUString sID = xAttrList->getValueByIndex(nAttr);
67 
68  // <text:change> is both start and end
70  rHelper->RedlineSetCursor(sID, true, m_bIsOutsideOfParagraph);
72  rHelper->RedlineSetCursor(sID, false, m_bIsOutsideOfParagraph);
73 
74  // outside of paragraph and still open? set open redline ID
76  {
77  rHelper->SetOpenRedlineId(sID);
78  }
79  }
80  // else: ignore
81  }
82 }
83 
84 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual ~XMLChangeImportContext() override
bool IsXMLToken(const OUString &rString, enum XMLTokenEnum eToken)
compare eToken to the string
Definition: xmltoken.cxx:3422
SvXMLImport & GetImport()
Definition: xmlictxt.hxx:62
XMLChangeImportContext(SvXMLImport &rImport, sal_Int16 nPrefix, const OUString &rLocalName, Element eElement, bool bIsOutsideOfParagraph)
import a change mark (, , ) Note: a ma...
SvXMLNamespaceMap & GetNamespaceMap()
Definition: xmlimp.hxx:397
constexpr sal_uInt16 XML_NAMESPACE_TEXT
Definition: xmlnmspe.hxx:31
rtl::Reference< XMLTextImportHelper > const & GetTextImport()
Definition: xmlimp.hxx:594
This class deliberately does not support XWeak, to improve performance when loading large documents...
Definition: xmlictxt.hxx:44
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...
sal_Int32 nLength
Definition: xmltoken.cxx:36