Avoid potential negative array index access to cached text.
[LibreOffice.git] / xmloff / source / text / XMLIndexObjectSourceContext.cxx
blob805ce796aaa836b4d5bcae811313dc1105939251
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 "XMLIndexObjectSourceContext.hxx"
23 #include <rtl/ustring.hxx>
25 #include <com/sun/star/beans/XPropertySet.hpp>
27 #include <sax/tools/converter.hxx>
29 #include "XMLIndexTemplateContext.hxx"
30 #include <xmloff/xmlictxt.hxx>
31 #include <xmloff/xmlimp.hxx>
32 #include <xmloff/xmlnamespace.hxx>
33 #include <xmloff/xmltoken.hxx>
36 using ::com::sun::star::beans::XPropertySet;
37 using ::com::sun::star::uno::Reference;
38 using ::com::sun::star::uno::Any;
39 using namespace ::xmloff::token;
42 XMLIndexObjectSourceContext::XMLIndexObjectSourceContext(
43 SvXMLImport& rImport,
44 Reference<XPropertySet> & rPropSet)
45 : XMLIndexSourceBaseContext(rImport, rPropSet, UseStyles::Single),
46 bUseCalc(false),
47 bUseChart(false),
48 bUseDraw(false),
49 bUseMath(false),
50 bUseOtherObjects(false)
54 XMLIndexObjectSourceContext::~XMLIndexObjectSourceContext()
58 void XMLIndexObjectSourceContext::ProcessAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter & aIter)
60 bool bTmp(false);
62 switch (aIter.getToken())
64 case XML_ELEMENT(TEXT, XML_USE_OTHER_OBJECTS):
65 if (::sax::Converter::convertBool(bTmp, aIter.toView()))
67 bUseOtherObjects = bTmp;
69 break;
71 case XML_ELEMENT(TEXT, XML_USE_SPREADSHEET_OBJECTS):
72 if (::sax::Converter::convertBool(bTmp, aIter.toView()))
74 bUseCalc = bTmp;
76 break;
78 case XML_ELEMENT(TEXT, XML_USE_CHART_OBJECTS):
79 if (::sax::Converter::convertBool(bTmp, aIter.toView()))
81 bUseChart = bTmp;
83 break;
85 case XML_ELEMENT(TEXT, XML_USE_DRAW_OBJECTS):
86 if (::sax::Converter::convertBool(bTmp, aIter.toView()))
88 bUseDraw = bTmp;
90 break;
92 case XML_ELEMENT(TEXT, XML_USE_MATH_OBJECTS):
93 if (::sax::Converter::convertBool(bTmp, aIter.toView()))
95 bUseMath = bTmp;
97 break;
99 default:
100 XMLIndexSourceBaseContext::ProcessAttribute(aIter);
101 break;
105 void XMLIndexObjectSourceContext::endFastElement(sal_Int32 nElement)
107 rIndexPropertySet->setPropertyValue("CreateFromStarCalc", css::uno::Any(bUseCalc));
108 rIndexPropertySet->setPropertyValue("CreateFromStarChart", css::uno::Any(bUseChart));
109 rIndexPropertySet->setPropertyValue("CreateFromStarDraw", css::uno::Any(bUseDraw));
110 rIndexPropertySet->setPropertyValue("CreateFromStarMath", css::uno::Any(bUseMath));
111 rIndexPropertySet->setPropertyValue("CreateFromOtherEmbeddedObjects", css::uno::Any(bUseOtherObjects));
113 XMLIndexSourceBaseContext::endFastElement(nElement);
116 css::uno::Reference< css::xml::sax::XFastContextHandler > XMLIndexObjectSourceContext::createFastChildContext(
117 sal_Int32 nElement,
118 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
120 if ( nElement == XML_ELEMENT(TEXT, XML_OBJECT_INDEX_ENTRY_TEMPLATE) )
122 return new XMLIndexTemplateContext(GetImport(), rIndexPropertySet,
123 aLevelNameTableMap,
124 XML_TOKEN_INVALID, // no outline-level attr
125 aLevelStylePropNameTableMap,
126 aAllowedTokenTypesTable);
128 else
130 return XMLIndexSourceBaseContext::createFastChildContext(nElement,
131 xAttrList);
136 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */