Line data Source code
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 :
21 : #include "XMLLineNumberingSeparatorImportContext.hxx"
22 :
23 : #include <sax/tools/converter.hxx>
24 : #include "XMLLineNumberingImportContext.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;
34 : using ::rtl::OUString;
35 : using ::rtl::OUStringBuffer;
36 : using ::xmloff::token::IsXMLToken;
37 : using ::xmloff::token::XML_INCREMENT;
38 :
39 0 : TYPEINIT1( XMLLineNumberingSeparatorImportContext, SvXMLImportContext );
40 :
41 0 : XMLLineNumberingSeparatorImportContext::XMLLineNumberingSeparatorImportContext(
42 : SvXMLImport& rImport,
43 : sal_uInt16 nPrfx,
44 : const OUString& rLocalName,
45 : XMLLineNumberingImportContext& rLineNumbering) :
46 : SvXMLImportContext(rImport, nPrfx, rLocalName),
47 0 : rLineNumberingContext(rLineNumbering)
48 : {
49 0 : }
50 :
51 0 : XMLLineNumberingSeparatorImportContext::~XMLLineNumberingSeparatorImportContext()
52 : {
53 0 : }
54 :
55 0 : void XMLLineNumberingSeparatorImportContext::StartElement(
56 : const Reference<XAttributeList> & xAttrList)
57 : {
58 0 : sal_Int16 nLength = xAttrList->getLength();
59 0 : for(sal_Int16 i=0; i<nLength; i++)
60 : {
61 0 : OUString sLocalName;
62 0 : sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
63 0 : GetKeyByAttrName( xAttrList->getNameByIndex(i), &sLocalName );
64 :
65 0 : if ( (nPrefix == XML_NAMESPACE_TEXT) &&
66 0 : IsXMLToken(sLocalName, XML_INCREMENT) )
67 : {
68 : sal_Int32 nTmp;
69 0 : if (::sax::Converter::convertNumber(
70 0 : nTmp, xAttrList->getValueByIndex(i), 0))
71 : {
72 0 : rLineNumberingContext.SetSeparatorIncrement((sal_Int16)nTmp);
73 : }
74 : // else: invalid number -> ignore
75 : }
76 : // else: unknown attribute -> ignore
77 0 : }
78 0 : }
79 :
80 0 : void XMLLineNumberingSeparatorImportContext::Characters(
81 : const OUString& rChars )
82 : {
83 0 : sSeparatorBuf.append(rChars);
84 0 : }
85 :
86 0 : void XMLLineNumberingSeparatorImportContext::EndElement()
87 : {
88 0 : rLineNumberingContext.SetSeparatorText(sSeparatorBuf.makeStringAndClear());
89 0 : }
90 :
91 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|