nss: upgrade to release 3.73
[LibreOffice.git] / xmloff / source / text / XMLIndexUserSourceContext.cxx
blob3d388c4de4982eacfdf0b87d04a25944236bd498
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "XMLIndexUserSourceContext.hxx"
21 #include <com/sun/star/beans/XPropertySet.hpp>
22 #include <sax/tools/converter.hxx>
23 #include "XMLIndexTemplateContext.hxx"
24 #include <xmloff/xmlictxt.hxx>
25 #include <xmloff/xmlimp.hxx>
26 #include <xmloff/xmlnamespace.hxx>
27 #include <xmloff/xmltoken.hxx>
28 #include <rtl/ustring.hxx>
31 using ::com::sun::star::beans::XPropertySet;
32 using ::com::sun::star::uno::Reference;
33 using ::com::sun::star::uno::Any;
34 using ::com::sun::star::xml::sax::XAttributeList;
35 using ::xmloff::token::IsXMLToken;
36 using ::xmloff::token::XML_USER_INDEX_ENTRY_TEMPLATE;
37 using ::xmloff::token::XML_OUTLINE_LEVEL;
39 XMLIndexUserSourceContext::XMLIndexUserSourceContext(
40 SvXMLImport& rImport,
41 sal_uInt16 nPrfx,
42 const OUString& rLocalName,
43 Reference<XPropertySet> & rPropSet) :
44 XMLIndexSourceBaseContext(rImport, nPrfx, rLocalName,
45 rPropSet, true),
46 bUseObjects(false),
47 bUseGraphic(false),
48 bUseMarks(false),
49 bUseTables(false),
50 bUseFrames(false),
51 bUseLevelFromSource(false),
52 bUseLevelParagraphStyles(false)
56 XMLIndexUserSourceContext::~XMLIndexUserSourceContext()
60 void XMLIndexUserSourceContext::ProcessAttribute(
61 enum IndexSourceParamEnum eParam,
62 const OUString& rValue)
64 bool bTmp(false);
66 switch (eParam)
68 case XML_TOK_INDEXSOURCE_USE_INDEX_MARKS:
69 if (::sax::Converter::convertBool(bTmp, rValue))
71 bUseMarks = bTmp;
73 break;
75 case XML_TOK_INDEXSOURCE_USE_OBJECTS:
76 if (::sax::Converter::convertBool(bTmp, rValue))
78 bUseObjects = bTmp;
80 break;
82 case XML_TOK_INDEXSOURCE_USE_GRAPHICS:
83 if (::sax::Converter::convertBool(bTmp, rValue))
85 bUseGraphic = bTmp;
87 break;
89 case XML_TOK_INDEXSOURCE_USE_TABLES:
90 if (::sax::Converter::convertBool(bTmp, rValue))
92 bUseTables = bTmp;
94 break;
96 case XML_TOK_INDEXSOURCE_USE_FRAMES:
97 if (::sax::Converter::convertBool(bTmp, rValue))
99 bUseFrames = bTmp;
101 break;
103 case XML_TOK_INDEXSOURCE_COPY_OUTLINE_LEVELS:
104 if (::sax::Converter::convertBool(bTmp, rValue))
106 bUseLevelFromSource = bTmp;
108 break;
110 case XML_TOK_INDEXSOURCE_USE_INDEX_SOURCE_STYLES:
111 if (::sax::Converter::convertBool(bTmp, rValue))
113 bUseLevelParagraphStyles = bTmp;
115 break;
117 case XML_TOK_INDEXSOURCE_USER_INDEX_NAME:
118 sIndexName = rValue;
119 break;
121 default:
122 XMLIndexSourceBaseContext::ProcessAttribute(eParam, rValue);
123 break;
127 void XMLIndexUserSourceContext::endFastElement(sal_Int32 nElement)
129 rIndexPropertySet->setPropertyValue("CreateFromEmbeddedObjects", css::uno::Any(bUseObjects));
130 rIndexPropertySet->setPropertyValue("CreateFromGraphicObjects", css::uno::Any(bUseGraphic));
131 rIndexPropertySet->setPropertyValue("UseLevelFromSource", css::uno::Any(bUseLevelFromSource));
132 rIndexPropertySet->setPropertyValue("CreateFromMarks", css::uno::Any(bUseMarks));
133 rIndexPropertySet->setPropertyValue("CreateFromTables", css::uno::Any(bUseTables));
134 rIndexPropertySet->setPropertyValue("CreateFromTextFrames", css::uno::Any(bUseFrames));
135 rIndexPropertySet->setPropertyValue("CreateFromLevelParagraphStyles", css::uno::Any(bUseLevelParagraphStyles));
137 if( !sIndexName.isEmpty() )
139 rIndexPropertySet->setPropertyValue("UserIndexName", css::uno::Any(sIndexName));
142 XMLIndexSourceBaseContext::endFastElement(nElement);
145 SvXMLImportContextRef XMLIndexUserSourceContext::CreateChildContext(
146 sal_uInt16 nPrefix,
147 const OUString& rLocalName,
148 const Reference<XAttributeList> & xAttrList )
150 if ( (XML_NAMESPACE_TEXT == nPrefix) &&
151 (IsXMLToken(rLocalName, XML_USER_INDEX_ENTRY_TEMPLATE)) )
153 return new XMLIndexTemplateContext(GetImport(), rIndexPropertySet,
154 nPrefix, rLocalName,
155 aSvLevelNameTOCMap,
156 XML_OUTLINE_LEVEL,
157 aLevelStylePropNameTOCMap,
158 aAllowedTokenTypesUser);
160 else
162 return XMLIndexSourceBaseContext::CreateChildContext(nPrefix,
163 rLocalName,
164 xAttrList);
169 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */