1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: XMLIndexObjectSourceContext.cxx,v $
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(
74 const OUString
& rLocalName
,
75 Reference
<XPropertySet
> & rPropSet
) :
76 XMLIndexSourceBaseContext(rImport
, nPrfx
, rLocalName
,
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
)),
92 bUseOtherObjects(sal_False
)
96 XMLIndexObjectSourceContext::~XMLIndexObjectSourceContext()
100 void XMLIndexObjectSourceContext::ProcessAttribute(
101 enum IndexSourceParamEnum eParam
,
102 const OUString
& rValue
)
108 case XML_TOK_INDEXSOURCE_USE_OTHER_OBJECTS
:
109 if (SvXMLUnitConverter::convertBool(bTmp
, rValue
))
111 bUseOtherObjects
= bTmp
;
115 case XML_TOK_INDEXSOURCE_USE_SHEET
:
116 if (SvXMLUnitConverter::convertBool(bTmp
, rValue
))
122 case XML_TOK_INDEXSOURCE_USE_CHART
:
123 if (SvXMLUnitConverter::convertBool(bTmp
, rValue
))
129 case XML_TOK_INDEXSOURCE_USE_DRAW
:
130 if (SvXMLUnitConverter::convertBool(bTmp
, rValue
))
136 case XML_TOK_INDEXSOURCE_USE_MATH
:
137 if (SvXMLUnitConverter::convertBool(bTmp
, rValue
))
144 XMLIndexSourceBaseContext::ProcessAttribute(eParam
, rValue
);
149 void XMLIndexObjectSourceContext::EndElement()
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(
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
,
182 XML_TOKEN_INVALID
, // no outline-level attr
183 aLevelStylePropNameTableMap
,
184 aAllowedTokenTypesTable
);
188 return XMLIndexSourceBaseContext::CreateChildContext(nPrefix
,