bump product version to 5.0.4.1
[LibreOffice.git] / xmloff / source / text / XMLIndexObjectSourceContext.cxx
blob8b8eb5032f13221b97e9458c7d9d24676f8cbf22
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>
26 #include <com/sun/star/container/XIndexReplace.hpp>
28 #include <sax/tools/converter.hxx>
30 #include "XMLIndexTemplateContext.hxx"
31 #include "XMLIndexTitleTemplateContext.hxx"
32 #include "XMLIndexTOCStylesContext.hxx"
33 #include <xmloff/xmlictxt.hxx>
34 #include <xmloff/xmlimp.hxx>
35 #include <xmloff/txtimp.hxx>
36 #include <xmloff/xmlnmspe.hxx>
37 #include <xmloff/nmspmap.hxx>
38 #include <xmloff/xmltoken.hxx>
41 using ::com::sun::star::beans::XPropertySet;
42 using ::com::sun::star::uno::Reference;
43 using ::com::sun::star::uno::Any;
44 using ::com::sun::star::xml::sax::XAttributeList;
45 using ::xmloff::token::IsXMLToken;
46 using ::xmloff::token::XML_OBJECT_INDEX_ENTRY_TEMPLATE;
47 using ::xmloff::token::XML_TOKEN_INVALID;
49 const sal_Char sAPI_CreateFromStarCalc[] = "CreateFromStarCalc";
50 const sal_Char sAPI_CreateFromStarChart[] = "CreateFromStarChart";
51 const sal_Char sAPI_CreateFromStarDraw[] = "CreateFromStarDraw";
52 const sal_Char sAPI_CreateFromStarMath[] = "CreateFromStarMath";
53 const sal_Char sAPI_CreateFromOtherEmbeddedObjects[] = "CreateFromOtherEmbeddedObjects";
56 TYPEINIT1( XMLIndexObjectSourceContext, XMLIndexSourceBaseContext );
58 XMLIndexObjectSourceContext::XMLIndexObjectSourceContext(
59 SvXMLImport& rImport,
60 sal_uInt16 nPrfx,
61 const OUString& rLocalName,
62 Reference<XPropertySet> & rPropSet) :
63 XMLIndexSourceBaseContext(rImport, nPrfx, rLocalName,
64 rPropSet, false),
65 sCreateFromStarCalc(sAPI_CreateFromStarCalc),
66 sCreateFromStarChart(sAPI_CreateFromStarChart),
67 sCreateFromStarDraw(sAPI_CreateFromStarDraw),
68 sCreateFromStarMath(sAPI_CreateFromStarMath),
69 sCreateFromOtherEmbeddedObjects(sAPI_CreateFromOtherEmbeddedObjects),
70 bUseCalc(false),
71 bUseChart(false),
72 bUseDraw(false),
73 bUseMath(false),
74 bUseOtherObjects(false)
78 XMLIndexObjectSourceContext::~XMLIndexObjectSourceContext()
82 void XMLIndexObjectSourceContext::ProcessAttribute(
83 enum IndexSourceParamEnum eParam,
84 const OUString& rValue)
86 bool bTmp(false);
88 switch (eParam)
90 case XML_TOK_INDEXSOURCE_USE_OTHER_OBJECTS:
91 if (::sax::Converter::convertBool(bTmp, rValue))
93 bUseOtherObjects = bTmp;
95 break;
97 case XML_TOK_INDEXSOURCE_USE_SHEET:
98 if (::sax::Converter::convertBool(bTmp, rValue))
100 bUseCalc = bTmp;
102 break;
104 case XML_TOK_INDEXSOURCE_USE_CHART:
105 if (::sax::Converter::convertBool(bTmp, rValue))
107 bUseChart = bTmp;
109 break;
111 case XML_TOK_INDEXSOURCE_USE_DRAW:
112 if (::sax::Converter::convertBool(bTmp, rValue))
114 bUseDraw = bTmp;
116 break;
118 case XML_TOK_INDEXSOURCE_USE_MATH:
119 if (::sax::Converter::convertBool(bTmp, rValue))
121 bUseMath = bTmp;
123 break;
125 default:
126 XMLIndexSourceBaseContext::ProcessAttribute(eParam, rValue);
127 break;
131 void XMLIndexObjectSourceContext::EndElement()
133 Any aAny;
135 aAny.setValue(&bUseCalc, cppu::UnoType<bool>::get());
136 rIndexPropertySet->setPropertyValue(sCreateFromStarCalc, aAny);
138 aAny.setValue(&bUseChart, cppu::UnoType<bool>::get());
139 rIndexPropertySet->setPropertyValue(sCreateFromStarChart, aAny);
141 aAny.setValue(&bUseDraw, cppu::UnoType<bool>::get());
142 rIndexPropertySet->setPropertyValue(sCreateFromStarDraw, aAny);
144 aAny.setValue(&bUseMath, cppu::UnoType<bool>::get());
145 rIndexPropertySet->setPropertyValue(sCreateFromStarMath, aAny);
147 aAny.setValue(&bUseOtherObjects, cppu::UnoType<bool>::get());
148 rIndexPropertySet->setPropertyValue(sCreateFromOtherEmbeddedObjects, aAny);
150 XMLIndexSourceBaseContext::EndElement();
153 SvXMLImportContext* XMLIndexObjectSourceContext::CreateChildContext(
154 sal_uInt16 nPrefix,
155 const OUString& rLocalName,
156 const Reference<XAttributeList> & xAttrList )
158 if ( (XML_NAMESPACE_TEXT == nPrefix) &&
159 (IsXMLToken(rLocalName, XML_OBJECT_INDEX_ENTRY_TEMPLATE)) )
161 return new XMLIndexTemplateContext(GetImport(), rIndexPropertySet,
162 nPrefix, rLocalName,
163 aLevelNameTableMap,
164 XML_TOKEN_INVALID, // no outline-level attr
165 aLevelStylePropNameTableMap,
166 aAllowedTokenTypesTable);
168 else
170 return XMLIndexSourceBaseContext::CreateChildContext(nPrefix,
171 rLocalName,
172 xAttrList);
177 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */