merge the formfield patch from ooo-build
[ooovba.git] / xmloff / source / text / XMLIndexUserSourceContext.cxx
blob6713a049f466cd820615fe201c1374e9ff3949d5
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: XMLIndexUserSourceContext.cxx,v $
10 * $Revision: 1.8 $
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 "XMLIndexUserSourceContext.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_USER_INDEX_ENTRY_TEMPLATE;
59 using ::xmloff::token::XML_OUTLINE_LEVEL;
62 const sal_Char sAPI_CreateFromEmbeddedObjects[] = "CreateFromEmbeddedObjects";
63 const sal_Char sAPI_CreateFromGraphicObjects[] = "CreateFromGraphicObjects";
64 const sal_Char sAPI_CreateFromMarks[] = "CreateFromMarks";
65 const sal_Char sAPI_CreateFromTables[] = "CreateFromTables";
66 const sal_Char sAPI_CreateFromTextFrames[] = "CreateFromTextFrames";
67 const sal_Char sAPI_UseLevelFromSource[] = "UseLevelFromSource";
68 const sal_Char sAPI_CreateFromLevelParagraphStyles[] = "CreateFromLevelParagraphStyles";
69 const sal_Char sAPI_UserIndexName[] = "UserIndexName";
72 TYPEINIT1(XMLIndexUserSourceContext, XMLIndexSourceBaseContext);
75 XMLIndexUserSourceContext::XMLIndexUserSourceContext(
76 SvXMLImport& rImport,
77 sal_uInt16 nPrfx,
78 const OUString& rLocalName,
79 Reference<XPropertySet> & rPropSet) :
80 XMLIndexSourceBaseContext(rImport, nPrfx, rLocalName,
81 rPropSet, sal_True),
82 sCreateFromEmbeddedObjects(RTL_CONSTASCII_USTRINGPARAM(
83 sAPI_CreateFromEmbeddedObjects)),
84 sCreateFromGraphicObjects(RTL_CONSTASCII_USTRINGPARAM(
85 sAPI_CreateFromGraphicObjects)),
86 sCreateFromMarks(RTL_CONSTASCII_USTRINGPARAM(sAPI_CreateFromMarks)),
87 sCreateFromTables(RTL_CONSTASCII_USTRINGPARAM(sAPI_CreateFromTables)),
88 sCreateFromTextFrames(RTL_CONSTASCII_USTRINGPARAM(
89 sAPI_CreateFromTextFrames)),
90 sUseLevelFromSource(RTL_CONSTASCII_USTRINGPARAM(
91 sAPI_UseLevelFromSource)),
92 sCreateFromLevelParagraphStyles(RTL_CONSTASCII_USTRINGPARAM(
93 sAPI_CreateFromLevelParagraphStyles)),
94 sUserIndexName(RTL_CONSTASCII_USTRINGPARAM(sAPI_UserIndexName)),
95 bUseObjects(sal_False),
96 bUseGraphic(sal_False),
97 bUseMarks(sal_False),
98 bUseTables(sal_False),
99 bUseFrames(sal_False),
100 bUseLevelFromSource(sal_False),
101 bUseLevelParagraphStyles(sal_False)
105 XMLIndexUserSourceContext::~XMLIndexUserSourceContext()
109 void XMLIndexUserSourceContext::ProcessAttribute(
110 enum IndexSourceParamEnum eParam,
111 const OUString& rValue)
113 sal_Bool bTmp;
115 switch (eParam)
117 case XML_TOK_INDEXSOURCE_USE_INDEX_MARKS:
118 if (SvXMLUnitConverter::convertBool(bTmp, rValue))
120 bUseMarks = bTmp;
122 break;
124 case XML_TOK_INDEXSOURCE_USE_OBJECTS:
125 if (SvXMLUnitConverter::convertBool(bTmp, rValue))
127 bUseObjects = bTmp;
129 break;
131 case XML_TOK_INDEXSOURCE_USE_GRAPHICS:
132 if (SvXMLUnitConverter::convertBool(bTmp, rValue))
134 bUseGraphic = bTmp;
136 break;
138 case XML_TOK_INDEXSOURCE_USE_TABLES:
139 if (SvXMLUnitConverter::convertBool(bTmp, rValue))
141 bUseTables = bTmp;
143 break;
145 case XML_TOK_INDEXSOURCE_USE_FRAMES:
146 if (SvXMLUnitConverter::convertBool(bTmp, rValue))
148 bUseFrames = bTmp;
150 break;
152 case XML_TOK_INDEXSOURCE_COPY_OUTLINE_LEVELS:
153 if (SvXMLUnitConverter::convertBool(bTmp, rValue))
155 bUseLevelFromSource = bTmp;
157 break;
159 case XML_TOK_INDEXSOURCE_USE_INDEX_SOURCE_STYLES:
160 if (SvXMLUnitConverter::convertBool(bTmp, rValue))
162 bUseLevelParagraphStyles = bTmp;
164 break;
166 case XML_TOK_INDEXSOURCE_USER_INDEX_NAME:
167 sIndexName = rValue;
168 break;
170 default:
171 XMLIndexSourceBaseContext::ProcessAttribute(eParam, rValue);
172 break;
177 void XMLIndexUserSourceContext::EndElement()
179 Any aAny;
181 aAny.setValue(&bUseObjects, ::getBooleanCppuType());
182 rIndexPropertySet->setPropertyValue(sCreateFromEmbeddedObjects, aAny);
184 aAny.setValue(&bUseGraphic, ::getBooleanCppuType());
185 rIndexPropertySet->setPropertyValue(sCreateFromGraphicObjects, aAny);
187 aAny.setValue(&bUseLevelFromSource, ::getBooleanCppuType());
188 rIndexPropertySet->setPropertyValue(sUseLevelFromSource, aAny);
190 aAny.setValue(&bUseMarks, ::getBooleanCppuType());
191 rIndexPropertySet->setPropertyValue(sCreateFromMarks, aAny);
193 aAny.setValue(&bUseTables, ::getBooleanCppuType());
194 rIndexPropertySet->setPropertyValue(sCreateFromTables, aAny);
196 aAny.setValue(&bUseFrames, ::getBooleanCppuType());
197 rIndexPropertySet->setPropertyValue(sCreateFromTextFrames, aAny);
199 aAny.setValue(&bUseLevelParagraphStyles, ::getBooleanCppuType());
200 rIndexPropertySet->setPropertyValue(sCreateFromLevelParagraphStyles, aAny);
202 if( sIndexName.getLength() > 0 )
204 aAny <<= sIndexName;
205 rIndexPropertySet->setPropertyValue(sUserIndexName, aAny);
208 XMLIndexSourceBaseContext::EndElement();
212 SvXMLImportContext* XMLIndexUserSourceContext::CreateChildContext(
213 sal_uInt16 nPrefix,
214 const OUString& rLocalName,
215 const Reference<XAttributeList> & xAttrList )
217 if ( (XML_NAMESPACE_TEXT == nPrefix) &&
218 (IsXMLToken(rLocalName, XML_USER_INDEX_ENTRY_TEMPLATE)) )
220 return new XMLIndexTemplateContext(GetImport(), rIndexPropertySet,
221 nPrefix, rLocalName,
222 aLevelNameTOCMap,
223 XML_OUTLINE_LEVEL,
224 aLevelStylePropNameTOCMap,
225 aAllowedTokenTypesUser);
227 else
229 return XMLIndexSourceBaseContext::CreateChildContext(nPrefix,
230 rLocalName,
231 xAttrList);