Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include "XMLIndexObjectSourceContext.hxx"
31 : :
32 : : #include <rtl/ustring.hxx>
33 : :
34 : : #include <com/sun/star/beans/XPropertySet.hpp>
35 : : #include <com/sun/star/container/XIndexReplace.hpp>
36 : :
37 : : #include <sax/tools/converter.hxx>
38 : :
39 : : #include "XMLIndexTemplateContext.hxx"
40 : : #include "XMLIndexTitleTemplateContext.hxx"
41 : : #include "XMLIndexTOCStylesContext.hxx"
42 : : #include <xmloff/xmlictxt.hxx>
43 : : #include <xmloff/xmlimp.hxx>
44 : : #include <xmloff/txtimp.hxx>
45 : : #include "xmloff/xmlnmspe.hxx"
46 : : #include <xmloff/nmspmap.hxx>
47 : : #include <xmloff/xmltoken.hxx>
48 : :
49 : :
50 : : using ::rtl::OUString;
51 : : using ::com::sun::star::beans::XPropertySet;
52 : : using ::com::sun::star::uno::Reference;
53 : : using ::com::sun::star::uno::Any;
54 : : using ::com::sun::star::xml::sax::XAttributeList;
55 : : using ::xmloff::token::IsXMLToken;
56 : : using ::xmloff::token::XML_OBJECT_INDEX_ENTRY_TEMPLATE;
57 : : using ::xmloff::token::XML_TOKEN_INVALID;
58 : :
59 : : const sal_Char sAPI_CreateFromStarCalc[] = "CreateFromStarCalc";
60 : : const sal_Char sAPI_CreateFromStarChart[] = "CreateFromStarChart";
61 : : const sal_Char sAPI_CreateFromStarDraw[] = "CreateFromStarDraw";
62 : : const sal_Char sAPI_CreateFromStarImage[] = "CreateFromStarImage";
63 : : const sal_Char sAPI_CreateFromStarMath[] = "CreateFromStarMath";
64 : : const sal_Char sAPI_CreateFromOtherEmbeddedObjects[] = "CreateFromOtherEmbeddedObjects";
65 : :
66 : :
67 [ # # ][ # # ]: 0 : TYPEINIT1( XMLIndexObjectSourceContext, XMLIndexSourceBaseContext );
68 : :
69 : 4 : XMLIndexObjectSourceContext::XMLIndexObjectSourceContext(
70 : : SvXMLImport& rImport,
71 : : sal_uInt16 nPrfx,
72 : : const OUString& rLocalName,
73 : : Reference<XPropertySet> & rPropSet) :
74 : : XMLIndexSourceBaseContext(rImport, nPrfx, rLocalName,
75 : : rPropSet, sal_False),
76 : : sCreateFromStarCalc(RTL_CONSTASCII_USTRINGPARAM(
77 : : sAPI_CreateFromStarCalc)),
78 : : sCreateFromStarChart(RTL_CONSTASCII_USTRINGPARAM(
79 : : sAPI_CreateFromStarChart)),
80 : : sCreateFromStarDraw(RTL_CONSTASCII_USTRINGPARAM(
81 : : sAPI_CreateFromStarDraw)),
82 : : sCreateFromStarMath(RTL_CONSTASCII_USTRINGPARAM(
83 : : sAPI_CreateFromStarMath)),
84 : : sCreateFromOtherEmbeddedObjects(RTL_CONSTASCII_USTRINGPARAM(
85 : : sAPI_CreateFromOtherEmbeddedObjects)),
86 : : bUseCalc(sal_False),
87 : : bUseChart(sal_False),
88 : : bUseDraw(sal_False),
89 : : bUseMath(sal_False),
90 [ + - ][ + - ]: 4 : bUseOtherObjects(sal_False)
[ + - ][ + - ]
[ + - ]
91 : : {
92 : 4 : }
93 : :
94 : 4 : XMLIndexObjectSourceContext::~XMLIndexObjectSourceContext()
95 : : {
96 [ - + ]: 8 : }
97 : :
98 : 16 : void XMLIndexObjectSourceContext::ProcessAttribute(
99 : : enum IndexSourceParamEnum eParam,
100 : : const OUString& rValue)
101 : : {
102 : 16 : bool bTmp(false);
103 : :
104 [ - + + + : 16 : switch (eParam)
+ - ]
105 : : {
106 : : case XML_TOK_INDEXSOURCE_USE_OTHER_OBJECTS:
107 [ # # ][ # # ]: 0 : if (::sax::Converter::convertBool(bTmp, rValue))
108 : : {
109 : 0 : bUseOtherObjects = bTmp;
110 : : }
111 : 0 : break;
112 : :
113 : : case XML_TOK_INDEXSOURCE_USE_SHEET:
114 [ + - ][ + - ]: 4 : if (::sax::Converter::convertBool(bTmp, rValue))
115 : : {
116 : 4 : bUseCalc = bTmp;
117 : : }
118 : 4 : break;
119 : :
120 : : case XML_TOK_INDEXSOURCE_USE_CHART:
121 [ + - ][ + - ]: 4 : if (::sax::Converter::convertBool(bTmp, rValue))
122 : : {
123 : 4 : bUseChart = bTmp;
124 : : }
125 : 4 : break;
126 : :
127 : : case XML_TOK_INDEXSOURCE_USE_DRAW:
128 [ + - ][ + - ]: 4 : if (::sax::Converter::convertBool(bTmp, rValue))
129 : : {
130 : 4 : bUseDraw = bTmp;
131 : : }
132 : 4 : break;
133 : :
134 : : case XML_TOK_INDEXSOURCE_USE_MATH:
135 [ + - ][ + - ]: 4 : if (::sax::Converter::convertBool(bTmp, rValue))
136 : : {
137 : 4 : bUseMath = bTmp;
138 : : }
139 : 4 : break;
140 : :
141 : : default:
142 [ # # ]: 0 : XMLIndexSourceBaseContext::ProcessAttribute(eParam, rValue);
143 : 0 : break;
144 : : }
145 : 16 : }
146 : :
147 : 4 : void XMLIndexObjectSourceContext::EndElement()
148 : : {
149 : 4 : Any aAny;
150 : :
151 [ + - ]: 4 : aAny.setValue(&bUseCalc, ::getBooleanCppuType());
152 [ + - ][ + - ]: 4 : rIndexPropertySet->setPropertyValue(sCreateFromStarCalc, aAny);
153 : :
154 [ + - ]: 4 : aAny.setValue(&bUseChart, ::getBooleanCppuType());
155 [ + - ][ + - ]: 4 : rIndexPropertySet->setPropertyValue(sCreateFromStarChart, aAny);
156 : :
157 [ + - ]: 4 : aAny.setValue(&bUseDraw, ::getBooleanCppuType());
158 [ + - ][ + - ]: 4 : rIndexPropertySet->setPropertyValue(sCreateFromStarDraw, aAny);
159 : :
160 [ + - ]: 4 : aAny.setValue(&bUseMath, ::getBooleanCppuType());
161 [ + - ][ + - ]: 4 : rIndexPropertySet->setPropertyValue(sCreateFromStarMath, aAny);
162 : :
163 [ + - ]: 4 : aAny.setValue(&bUseOtherObjects, ::getBooleanCppuType());
164 [ + - ][ + - ]: 4 : rIndexPropertySet->setPropertyValue(sCreateFromOtherEmbeddedObjects, aAny);
165 : :
166 [ + - ]: 4 : XMLIndexSourceBaseContext::EndElement();
167 : 4 : }
168 : :
169 : 8 : SvXMLImportContext* XMLIndexObjectSourceContext::CreateChildContext(
170 : : sal_uInt16 nPrefix,
171 : : const OUString& rLocalName,
172 : : const Reference<XAttributeList> & xAttrList )
173 : : {
174 [ + - + + ]: 16 : if ( (XML_NAMESPACE_TEXT == nPrefix) &&
[ + + ]
175 : 8 : (IsXMLToken(rLocalName, XML_OBJECT_INDEX_ENTRY_TEMPLATE)) )
176 : : {
177 : 4 : return new XMLIndexTemplateContext(GetImport(), rIndexPropertySet,
178 : : nPrefix, rLocalName,
179 : : aLevelNameTableMap,
180 : : XML_TOKEN_INVALID, // no outline-level attr
181 : : aLevelStylePropNameTableMap,
182 [ + - ]: 4 : aAllowedTokenTypesTable);
183 : : }
184 : : else
185 : : {
186 : : return XMLIndexSourceBaseContext::CreateChildContext(nPrefix,
187 : : rLocalName,
188 : 8 : xAttrList);
189 : : }
190 : :
191 : : }
192 : :
193 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|