merge the formfield patch from ooo-build
[ooovba.git] / xmloff / source / text / XMLIndexObjectSourceContext.cxx
blobd72b41104fb1224effb235a6d127eeb661fd4c0c
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: XMLIndexObjectSourceContext.cxx,v $
10 * $Revision: 1.7 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_xmloff.hxx"
35 #include "XMLIndexObjectSourceContext.hxx"
36 #include <com/sun/star/beans/XPropertySet.hpp>
37 #include <com/sun/star/container/XIndexReplace.hpp>
38 #include "XMLIndexTemplateContext.hxx"
39 #include "XMLIndexTitleTemplateContext.hxx"
40 #include "XMLIndexTOCStylesContext.hxx"
41 #include <xmloff/xmlictxt.hxx>
42 #include <xmloff/xmlimp.hxx>
43 #include <xmloff/txtimp.hxx>
44 #include "xmlnmspe.hxx"
45 #include <xmloff/nmspmap.hxx>
46 #include <xmloff/xmltoken.hxx>
47 #include <xmloff/xmluconv.hxx>
48 #include <tools/debug.hxx>
49 #include <rtl/ustring.hxx>
52 using ::rtl::OUString;
53 using ::com::sun::star::beans::XPropertySet;
54 using ::com::sun::star::uno::Reference;
55 using ::com::sun::star::uno::Any;
56 using ::com::sun::star::xml::sax::XAttributeList;
57 using ::xmloff::token::IsXMLToken;
58 using ::xmloff::token::XML_OBJECT_INDEX_ENTRY_TEMPLATE;
59 using ::xmloff::token::XML_TOKEN_INVALID;
61 const sal_Char sAPI_CreateFromStarCalc[] = "CreateFromStarCalc";
62 const sal_Char sAPI_CreateFromStarChart[] = "CreateFromStarChart";
63 const sal_Char sAPI_CreateFromStarDraw[] = "CreateFromStarDraw";
64 const sal_Char sAPI_CreateFromStarImage[] = "CreateFromStarImage";
65 const sal_Char sAPI_CreateFromStarMath[] = "CreateFromStarMath";
66 const sal_Char sAPI_CreateFromOtherEmbeddedObjects[] = "CreateFromOtherEmbeddedObjects";
69 TYPEINIT1( XMLIndexObjectSourceContext, XMLIndexSourceBaseContext );
71 XMLIndexObjectSourceContext::XMLIndexObjectSourceContext(
72 SvXMLImport& rImport,
73 sal_uInt16 nPrfx,
74 const OUString& rLocalName,
75 Reference<XPropertySet> & rPropSet) :
76 XMLIndexSourceBaseContext(rImport, nPrfx, rLocalName,
77 rPropSet, sal_False),
78 sCreateFromStarCalc(RTL_CONSTASCII_USTRINGPARAM(
79 sAPI_CreateFromStarCalc)),
80 sCreateFromStarChart(RTL_CONSTASCII_USTRINGPARAM(
81 sAPI_CreateFromStarChart)),
82 sCreateFromStarDraw(RTL_CONSTASCII_USTRINGPARAM(
83 sAPI_CreateFromStarDraw)),
84 sCreateFromStarMath(RTL_CONSTASCII_USTRINGPARAM(
85 sAPI_CreateFromStarMath)),
86 sCreateFromOtherEmbeddedObjects(RTL_CONSTASCII_USTRINGPARAM(
87 sAPI_CreateFromOtherEmbeddedObjects)),
88 bUseCalc(sal_False),
89 bUseChart(sal_False),
90 bUseDraw(sal_False),
91 bUseMath(sal_False),
92 bUseOtherObjects(sal_False)
96 XMLIndexObjectSourceContext::~XMLIndexObjectSourceContext()
100 void XMLIndexObjectSourceContext::ProcessAttribute(
101 enum IndexSourceParamEnum eParam,
102 const OUString& rValue)
104 switch (eParam)
106 sal_Bool bTmp;
108 case XML_TOK_INDEXSOURCE_USE_OTHER_OBJECTS:
109 if (SvXMLUnitConverter::convertBool(bTmp, rValue))
111 bUseOtherObjects = bTmp;
113 break;
115 case XML_TOK_INDEXSOURCE_USE_SHEET:
116 if (SvXMLUnitConverter::convertBool(bTmp, rValue))
118 bUseCalc = bTmp;
120 break;
122 case XML_TOK_INDEXSOURCE_USE_CHART:
123 if (SvXMLUnitConverter::convertBool(bTmp, rValue))
125 bUseChart = bTmp;
127 break;
129 case XML_TOK_INDEXSOURCE_USE_DRAW:
130 if (SvXMLUnitConverter::convertBool(bTmp, rValue))
132 bUseDraw = bTmp;
134 break;
136 case XML_TOK_INDEXSOURCE_USE_MATH:
137 if (SvXMLUnitConverter::convertBool(bTmp, rValue))
139 bUseMath = bTmp;
141 break;
143 default:
144 XMLIndexSourceBaseContext::ProcessAttribute(eParam, rValue);
145 break;
149 void XMLIndexObjectSourceContext::EndElement()
151 Any aAny;
153 aAny.setValue(&bUseCalc, ::getBooleanCppuType());
154 rIndexPropertySet->setPropertyValue(sCreateFromStarCalc, aAny);
156 aAny.setValue(&bUseChart, ::getBooleanCppuType());
157 rIndexPropertySet->setPropertyValue(sCreateFromStarChart, aAny);
159 aAny.setValue(&bUseDraw, ::getBooleanCppuType());
160 rIndexPropertySet->setPropertyValue(sCreateFromStarDraw, aAny);
162 aAny.setValue(&bUseMath, ::getBooleanCppuType());
163 rIndexPropertySet->setPropertyValue(sCreateFromStarMath, aAny);
165 aAny.setValue(&bUseOtherObjects, ::getBooleanCppuType());
166 rIndexPropertySet->setPropertyValue(sCreateFromOtherEmbeddedObjects, aAny);
168 XMLIndexSourceBaseContext::EndElement();
171 SvXMLImportContext* XMLIndexObjectSourceContext::CreateChildContext(
172 sal_uInt16 nPrefix,
173 const OUString& rLocalName,
174 const Reference<XAttributeList> & xAttrList )
176 if ( (XML_NAMESPACE_TEXT == nPrefix) &&
177 (IsXMLToken(rLocalName, XML_OBJECT_INDEX_ENTRY_TEMPLATE)) )
179 return new XMLIndexTemplateContext(GetImport(), rIndexPropertySet,
180 nPrefix, rLocalName,
181 aLevelNameTableMap,
182 XML_TOKEN_INVALID, // no outline-level attr
183 aLevelStylePropNameTableMap,
184 aAllowedTokenTypesTable);
186 else
188 return XMLIndexSourceBaseContext::CreateChildContext(nPrefix,
189 rLocalName,
190 xAttrList);