tdf#154285 Check upper bound of arguments in SbRtl_Minute function
[LibreOffice.git] / xmloff / source / text / XMLIndexTableSourceContext.cxx
bloba72d898f9457faed3219788615ec46c8ccc359a5
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include "XMLIndexTableSourceContext.hxx"
23 #include <com/sun/star/beans/XPropertySet.hpp>
24 #include <com/sun/star/text/ReferenceFieldPart.hpp>
26 #include <sax/tools/converter.hxx>
28 #include "XMLIndexTemplateContext.hxx"
29 #include <xmloff/xmlimp.hxx>
30 #include <xmloff/xmlnamespace.hxx>
31 #include <xmloff/xmltoken.hxx>
32 #include <xmloff/xmluconv.hxx>
33 #include <xmloff/xmlement.hxx>
34 #include <rtl/ustring.hxx>
37 using namespace ::com::sun::star::text;
38 using namespace ::xmloff::token;
40 using ::com::sun::star::beans::XPropertySet;
41 using ::com::sun::star::uno::Reference;
42 using ::com::sun::star::uno::Any;
44 XMLIndexTableSourceContext::XMLIndexTableSourceContext(
45 SvXMLImport& rImport, Reference<XPropertySet> & rPropSet)
46 : XMLIndexSourceBaseContext(rImport, rPropSet, UseStyles::Single)
47 , nDisplayFormat(0)
48 , bSequenceOK(false)
49 , bDisplayFormatOK(false)
50 , bUseCaption(true)
54 XMLIndexTableSourceContext::~XMLIndexTableSourceContext()
58 SvXMLEnumMapEntry<sal_uInt16> const lcl_aReferenceTypeTokenMap[] =
61 { XML_TEXT, ReferenceFieldPart::TEXT },
62 { XML_CATEGORY_AND_VALUE, ReferenceFieldPart::CATEGORY_AND_NUMBER },
63 { XML_CAPTION, ReferenceFieldPart::ONLY_CAPTION },
65 // wrong values that previous versions wrote:
66 { XML_CHAPTER, ReferenceFieldPart::CATEGORY_AND_NUMBER },
67 { XML_PAGE, ReferenceFieldPart::ONLY_CAPTION },
69 { XML_TOKEN_INVALID, 0 }
72 void XMLIndexTableSourceContext::ProcessAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter & aIter)
74 bool bTmp(false);
76 switch (aIter.getToken())
78 case XML_ELEMENT(TEXT, XML_USE_CAPTION):
79 if (::sax::Converter::convertBool(bTmp, aIter.toView()))
81 bUseCaption = bTmp;
83 break;
85 case XML_ELEMENT(TEXT, XML_CAPTION_SEQUENCE_NAME):
86 sSequence = aIter.toString();
87 bSequenceOK = true;
88 break;
90 case XML_ELEMENT(TEXT, XML_CAPTION_SEQUENCE_FORMAT):
92 sal_uInt16 nTmp;
93 if (SvXMLUnitConverter::convertEnum(nTmp, aIter.toView(),
94 lcl_aReferenceTypeTokenMap))
96 nDisplayFormat = nTmp;
97 bDisplayFormatOK = true;
99 break;
102 default:
103 XMLIndexSourceBaseContext::ProcessAttribute(aIter);
104 break;
108 void XMLIndexTableSourceContext::endFastElement(sal_Int32 nElement)
110 rIndexPropertySet->setPropertyValue(u"CreateFromLabels"_ustr, css::uno::Any(bUseCaption));
112 if (bSequenceOK)
114 rIndexPropertySet->setPropertyValue(u"LabelCategory"_ustr, css::uno::Any(sSequence));
117 if (bDisplayFormatOK)
119 rIndexPropertySet->setPropertyValue(u"LabelDisplayType"_ustr, css::uno::Any(nDisplayFormat));
122 XMLIndexSourceBaseContext::endFastElement(nElement);
125 css::uno::Reference< css::xml::sax::XFastContextHandler > XMLIndexTableSourceContext::createFastChildContext(
126 sal_Int32 nElement,
127 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
129 if ( nElement == XML_ELEMENT(TEXT, XML_TABLE_INDEX_ENTRY_TEMPLATE) )
131 return new XMLIndexTemplateContext(GetImport(), rIndexPropertySet,
132 aLevelNameTableMap,
133 XML_TOKEN_INVALID, // no outline-level attr
134 aLevelStylePropNameTableMap,
135 aAllowedTokenTypesTable);
137 else
139 return XMLIndexSourceBaseContext::createFastChildContext(nElement,
140 xAttrList);
145 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */