LibreOffice Module xmloff (master)  1
XMLTrackedChangesImportContext.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 <com/sun/star/uno/Reference.h>
23 #include <sax/tools/converter.hxx>
24 #include <xmloff/xmlimp.hxx>
25 #include <xmloff/xmlnamespace.hxx>
26 #include <xmloff/namespacemap.hxx>
27 #include <xmloff/xmltoken.hxx>
28 
29 
30 using ::com::sun::star::uno::Reference;
31 using ::com::sun::star::xml::sax::XAttributeList;
32 using namespace ::xmloff::token;
33 
34 
36  SvXMLImport& rImport,
37  sal_uInt16 nPrefix,
38  const OUString& rLocalName) :
39  SvXMLImportContext(rImport, nPrefix, rLocalName)
40 {
41 }
42 
44 {
45 }
46 
48  const Reference<XAttributeList> & xAttrList )
49 {
50  bool bTrackChanges = true;
51 
52  // scan for text:track-changes and text:protection-key attributes
53  sal_Int16 nLength = xAttrList->getLength();
54  for( sal_Int16 i = 0; i < nLength; i++ )
55  {
56  OUString sLocalName;
57  sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
58  GetKeyByAttrName( xAttrList->getNameByIndex(i), &sLocalName );
59 
60  if ( XML_NAMESPACE_TEXT == nPrefix )
61  {
62  if ( IsXMLToken( sLocalName, XML_TRACK_CHANGES ) )
63  {
64  bool bTmp(false);
66  bTmp, xAttrList->getValueByIndex(i)) )
67  {
68  bTrackChanges = bTmp;
69  }
70  }
71  }
72  }
73 
74  // set tracked changes
75  GetImport().GetTextImport()->SetRecordChanges( bTrackChanges );
76 }
77 
78 
80  sal_uInt16 nPrefix,
81  const OUString& rLocalName,
82  const Reference<XAttributeList> & /*xAttrList*/)
83 {
84  SvXMLImportContextRef xContext;
85 
86  if ( (XML_NAMESPACE_TEXT == nPrefix) &&
87  IsXMLToken( rLocalName, XML_CHANGED_REGION ) )
88  {
90  nPrefix, rLocalName);
91  }
92 
93  return xContext;
94 }
95 
96 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool IsXMLToken(const OUString &rString, enum XMLTokenEnum eToken)
compare eToken to the string
Definition: xmltoken.cxx:3434
static bool convertBool(bool &rBool, const OUString &rString)
SvXMLImport & GetImport()
Definition: xmlictxt.hxx:62
SvXMLNamespaceMap & GetNamespaceMap()
Definition: xmlimp.hxx:402
XMLTrackedChangesImportContext(SvXMLImport &rImport, sal_uInt16 nPrefix, const OUString &rLocalName)
rtl::Reference< XMLTextImportHelper > const & GetTextImport()
Definition: xmlimp.hxx:600
int i
constexpr sal_uInt16 XML_NAMESPACE_TEXT
Import elements contained in a element.
virtual SvXMLImportContextRef CreateChildContext(sal_uInt16 nPrefix, const OUString &rLocalName, const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList) override
Create a children element context.
This class deliberately does not support XWeak, to improve performance when loading large documents...
Definition: xmlictxt.hxx:44
Handling of tokens in XML:
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