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 "XMLIndexObjectSourceContext.hxx"
22 :
23 : #include <rtl/ustring.hxx>
24 :
25 : #include <com/sun/star/beans/XPropertySet.hpp>
26 : #include <com/sun/star/container/XIndexReplace.hpp>
27 :
28 : #include <sax/tools/converter.hxx>
29 :
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>
39 :
40 :
41 : using ::rtl::OUString;
42 : using ::com::sun::star::beans::XPropertySet;
43 : using ::com::sun::star::uno::Reference;
44 : using ::com::sun::star::uno::Any;
45 : using ::com::sun::star::xml::sax::XAttributeList;
46 : using ::xmloff::token::IsXMLToken;
47 : using ::xmloff::token::XML_OBJECT_INDEX_ENTRY_TEMPLATE;
48 : using ::xmloff::token::XML_TOKEN_INVALID;
49 :
50 : const sal_Char sAPI_CreateFromStarCalc[] = "CreateFromStarCalc";
51 : const sal_Char sAPI_CreateFromStarChart[] = "CreateFromStarChart";
52 : const sal_Char sAPI_CreateFromStarDraw[] = "CreateFromStarDraw";
53 : const sal_Char sAPI_CreateFromStarImage[] = "CreateFromStarImage";
54 : const sal_Char sAPI_CreateFromStarMath[] = "CreateFromStarMath";
55 : const sal_Char sAPI_CreateFromOtherEmbeddedObjects[] = "CreateFromOtherEmbeddedObjects";
56 :
57 :
58 0 : TYPEINIT1( XMLIndexObjectSourceContext, XMLIndexSourceBaseContext );
59 :
60 0 : XMLIndexObjectSourceContext::XMLIndexObjectSourceContext(
61 : SvXMLImport& rImport,
62 : sal_uInt16 nPrfx,
63 : const OUString& rLocalName,
64 : Reference<XPropertySet> & rPropSet) :
65 : XMLIndexSourceBaseContext(rImport, nPrfx, rLocalName,
66 : rPropSet, sal_False),
67 : sCreateFromStarCalc(RTL_CONSTASCII_USTRINGPARAM(
68 : sAPI_CreateFromStarCalc)),
69 : sCreateFromStarChart(RTL_CONSTASCII_USTRINGPARAM(
70 : sAPI_CreateFromStarChart)),
71 : sCreateFromStarDraw(RTL_CONSTASCII_USTRINGPARAM(
72 : sAPI_CreateFromStarDraw)),
73 : sCreateFromStarMath(RTL_CONSTASCII_USTRINGPARAM(
74 : sAPI_CreateFromStarMath)),
75 : sCreateFromOtherEmbeddedObjects(RTL_CONSTASCII_USTRINGPARAM(
76 : sAPI_CreateFromOtherEmbeddedObjects)),
77 : bUseCalc(sal_False),
78 : bUseChart(sal_False),
79 : bUseDraw(sal_False),
80 : bUseMath(sal_False),
81 0 : bUseOtherObjects(sal_False)
82 : {
83 0 : }
84 :
85 0 : XMLIndexObjectSourceContext::~XMLIndexObjectSourceContext()
86 : {
87 0 : }
88 :
89 0 : void XMLIndexObjectSourceContext::ProcessAttribute(
90 : enum IndexSourceParamEnum eParam,
91 : const OUString& rValue)
92 : {
93 0 : bool bTmp(false);
94 :
95 0 : switch (eParam)
96 : {
97 : case XML_TOK_INDEXSOURCE_USE_OTHER_OBJECTS:
98 0 : if (::sax::Converter::convertBool(bTmp, rValue))
99 : {
100 0 : bUseOtherObjects = bTmp;
101 : }
102 0 : break;
103 :
104 : case XML_TOK_INDEXSOURCE_USE_SHEET:
105 0 : if (::sax::Converter::convertBool(bTmp, rValue))
106 : {
107 0 : bUseCalc = bTmp;
108 : }
109 0 : break;
110 :
111 : case XML_TOK_INDEXSOURCE_USE_CHART:
112 0 : if (::sax::Converter::convertBool(bTmp, rValue))
113 : {
114 0 : bUseChart = bTmp;
115 : }
116 0 : break;
117 :
118 : case XML_TOK_INDEXSOURCE_USE_DRAW:
119 0 : if (::sax::Converter::convertBool(bTmp, rValue))
120 : {
121 0 : bUseDraw = bTmp;
122 : }
123 0 : break;
124 :
125 : case XML_TOK_INDEXSOURCE_USE_MATH:
126 0 : if (::sax::Converter::convertBool(bTmp, rValue))
127 : {
128 0 : bUseMath = bTmp;
129 : }
130 0 : break;
131 :
132 : default:
133 0 : XMLIndexSourceBaseContext::ProcessAttribute(eParam, rValue);
134 0 : break;
135 : }
136 0 : }
137 :
138 0 : void XMLIndexObjectSourceContext::EndElement()
139 : {
140 0 : Any aAny;
141 :
142 0 : aAny.setValue(&bUseCalc, ::getBooleanCppuType());
143 0 : rIndexPropertySet->setPropertyValue(sCreateFromStarCalc, aAny);
144 :
145 0 : aAny.setValue(&bUseChart, ::getBooleanCppuType());
146 0 : rIndexPropertySet->setPropertyValue(sCreateFromStarChart, aAny);
147 :
148 0 : aAny.setValue(&bUseDraw, ::getBooleanCppuType());
149 0 : rIndexPropertySet->setPropertyValue(sCreateFromStarDraw, aAny);
150 :
151 0 : aAny.setValue(&bUseMath, ::getBooleanCppuType());
152 0 : rIndexPropertySet->setPropertyValue(sCreateFromStarMath, aAny);
153 :
154 0 : aAny.setValue(&bUseOtherObjects, ::getBooleanCppuType());
155 0 : rIndexPropertySet->setPropertyValue(sCreateFromOtherEmbeddedObjects, aAny);
156 :
157 0 : XMLIndexSourceBaseContext::EndElement();
158 0 : }
159 :
160 0 : SvXMLImportContext* XMLIndexObjectSourceContext::CreateChildContext(
161 : sal_uInt16 nPrefix,
162 : const OUString& rLocalName,
163 : const Reference<XAttributeList> & xAttrList )
164 : {
165 0 : if ( (XML_NAMESPACE_TEXT == nPrefix) &&
166 0 : (IsXMLToken(rLocalName, XML_OBJECT_INDEX_ENTRY_TEMPLATE)) )
167 : {
168 0 : return new XMLIndexTemplateContext(GetImport(), rIndexPropertySet,
169 : nPrefix, rLocalName,
170 : aLevelNameTableMap,
171 : XML_TOKEN_INVALID, // no outline-level attr
172 : aLevelStylePropNameTableMap,
173 0 : aAllowedTokenTypesTable);
174 : }
175 : else
176 : {
177 : return XMLIndexSourceBaseContext::CreateChildContext(nPrefix,
178 : rLocalName,
179 0 : xAttrList);
180 : }
181 :
182 : }
183 :
184 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|