LibreOffice Module xmloff (master)  1
XMLLineNumberingSeparatorImportContext.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 
20 
22 
23 #include <sax/tools/converter.hxx>
25 #include <xmloff/xmlimp.hxx>
26 #include <xmloff/nmspmap.hxx>
27 #include <xmloff/xmlnmspe.hxx>
28 #include <xmloff/xmltoken.hxx>
29 
30 
31 using namespace ::com::sun::star::uno;
32 
33 using ::com::sun::star::xml::sax::XAttributeList;
36 
37 
39  SvXMLImport& rImport,
40  sal_uInt16 nPrfx,
41  const OUString& rLocalName,
42  XMLLineNumberingImportContext& rLineNumbering) :
43  SvXMLImportContext(rImport, nPrfx, rLocalName),
44  rLineNumberingContext(rLineNumbering)
45 {
46 }
47 
49 {
50 }
51 
53  const Reference<XAttributeList> & xAttrList)
54 {
55  sal_Int16 nLength = xAttrList->getLength();
56  for(sal_Int16 i=0; i<nLength; i++)
57  {
58  OUString sLocalName;
59  sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
60  GetKeyByAttrName( xAttrList->getNameByIndex(i), &sLocalName );
61 
62  if ( (nPrefix == XML_NAMESPACE_TEXT) &&
63  IsXMLToken(sLocalName, XML_INCREMENT) )
64  {
65  sal_Int32 nTmp;
67  nTmp, xAttrList->getValueByIndex(i), 0))
68  {
69  rLineNumberingContext.SetSeparatorIncrement(static_cast<sal_Int16>(nTmp));
70  }
71  // else: invalid number -> ignore
72  }
73  // else: unknown attribute -> ignore
74  }
75 }
76 
78  const OUString& rChars )
79 {
80  sSeparatorBuf.append(rChars);
81 }
82 
84 {
86 }
87 
88 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool IsXMLToken(const OUString &rString, enum XMLTokenEnum eToken)
compare eToken to the string
Definition: xmltoken.cxx:3422
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...
SvXMLImport & GetImport()
Definition: xmlictxt.hxx:62
SvXMLNamespaceMap & GetNamespaceMap()
Definition: xmlimp.hxx:397
constexpr sal_uInt16 XML_NAMESPACE_TEXT
Definition: xmlnmspe.hxx:31
virtual void Characters(const OUString &rChars) override
This method is called for all characters that are contained in the current element.
XMLLineNumberingSeparatorImportContext(SvXMLImport &rImport, sal_uInt16 nPrfx, const OUString &rLocalName, XMLLineNumberingImportContext &rLineNumbering)
int i
void SetSeparatorText(const OUString &sText)
virtual void EndElement() override
EndElement is called before a context will be destructed, but after an elements context has been pars...
This class deliberately does not support XWeak, to improve performance when loading large documents...
Definition: xmlictxt.hxx:44
sal_Int32 nLength
Definition: xmltoken.cxx:36
static bool convertNumber(sal_Int32 &rValue, std::u16string_view aString, sal_Int32 nMin=SAL_MIN_INT32, sal_Int32 nMax=SAL_MAX_INT32)