tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / xmloff / source / text / XMLIndexUserSourceContext.cxx
blobf459ea9e996e5f411f63fe598e4a55da493dde57
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/xmlimp.hxx>
25 #include <xmloff/xmlnamespace.hxx>
26 #include <xmloff/xmltoken.hxx>
27 #include <rtl/ustring.hxx>
30 using ::com::sun::star::beans::XPropertySet;
31 using ::com::sun::star::uno::Reference;
32 using ::com::sun::star::uno::Any;
33 using namespace ::xmloff::token;
35 XMLIndexUserSourceContext::XMLIndexUserSourceContext(
36 SvXMLImport& rImport,
37 Reference<XPropertySet> & rPropSet)
38 : XMLIndexSourceBaseContext(rImport, rPropSet, UseStyles::Level),
39 bUseObjects(false),
40 bUseGraphic(false),
41 bUseMarks(false),
42 bUseTables(false),
43 bUseFrames(false),
44 bUseLevelFromSource(false),
45 bUseLevelParagraphStyles(false)
49 XMLIndexUserSourceContext::~XMLIndexUserSourceContext()
53 void XMLIndexUserSourceContext::ProcessAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter & aIter)
55 bool bTmp(false);
57 switch (aIter.getToken())
59 case XML_ELEMENT(TEXT, XML_USE_INDEX_MARKS):
60 if (::sax::Converter::convertBool(bTmp, aIter.toView()))
62 bUseMarks = bTmp;
64 break;
66 case XML_ELEMENT(TEXT, XML_USE_OBJECTS):
67 if (::sax::Converter::convertBool(bTmp, aIter.toView()))
69 bUseObjects = bTmp;
71 break;
73 case XML_ELEMENT(TEXT, XML_USE_GRAPHICS):
74 if (::sax::Converter::convertBool(bTmp, aIter.toView()))
76 bUseGraphic = bTmp;
78 break;
80 case XML_ELEMENT(TEXT, XML_USE_TABLES):
81 if (::sax::Converter::convertBool(bTmp, aIter.toView()))
83 bUseTables = bTmp;
85 break;
87 case XML_ELEMENT(TEXT, XML_USE_FLOATING_FRAMES):
88 if (::sax::Converter::convertBool(bTmp, aIter.toView()))
90 bUseFrames = bTmp;
92 break;
94 case XML_ELEMENT(TEXT, XML_COPY_OUTLINE_LEVELS):
95 if (::sax::Converter::convertBool(bTmp, aIter.toView()))
97 bUseLevelFromSource = bTmp;
99 break;
101 case XML_ELEMENT(TEXT, XML_USE_INDEX_SOURCE_STYLES):
102 if (::sax::Converter::convertBool(bTmp, aIter.toView()))
104 bUseLevelParagraphStyles = bTmp;
106 break;
108 case XML_ELEMENT(TEXT, XML_INDEX_NAME):
109 sIndexName = aIter.toString();
110 break;
112 default:
113 XMLIndexSourceBaseContext::ProcessAttribute(aIter);
114 break;
118 void XMLIndexUserSourceContext::endFastElement(sal_Int32 nElement)
120 rIndexPropertySet->setPropertyValue(u"CreateFromEmbeddedObjects"_ustr, css::uno::Any(bUseObjects));
121 rIndexPropertySet->setPropertyValue(u"CreateFromGraphicObjects"_ustr, css::uno::Any(bUseGraphic));
122 rIndexPropertySet->setPropertyValue(u"UseLevelFromSource"_ustr, css::uno::Any(bUseLevelFromSource));
123 rIndexPropertySet->setPropertyValue(u"CreateFromMarks"_ustr, css::uno::Any(bUseMarks));
124 rIndexPropertySet->setPropertyValue(u"CreateFromTables"_ustr, css::uno::Any(bUseTables));
125 rIndexPropertySet->setPropertyValue(u"CreateFromTextFrames"_ustr, css::uno::Any(bUseFrames));
126 rIndexPropertySet->setPropertyValue(u"CreateFromLevelParagraphStyles"_ustr, css::uno::Any(bUseLevelParagraphStyles));
128 if( !sIndexName.isEmpty() )
130 rIndexPropertySet->setPropertyValue(u"UserIndexName"_ustr, css::uno::Any(sIndexName));
133 XMLIndexSourceBaseContext::endFastElement(nElement);
136 css::uno::Reference< css::xml::sax::XFastContextHandler > XMLIndexUserSourceContext::createFastChildContext(
137 sal_Int32 nElement,
138 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
140 if ( nElement == XML_ELEMENT(TEXT, XML_USER_INDEX_ENTRY_TEMPLATE) )
142 return new XMLIndexTemplateContext(GetImport(), rIndexPropertySet,
143 aSvLevelNameTOCMap,
144 XML_OUTLINE_LEVEL,
145 aLevelStylePropNameTOCMap,
146 aAllowedTokenTypesUser);
148 else
150 return XMLIndexSourceBaseContext::createFastChildContext(nElement,
151 xAttrList);
156 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */