/src/libreoffice/xmloff/source/text/XMLIndexUserSourceContext.cxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
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/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
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 . |
18 | | */ |
19 | | |
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> |
28 | | |
29 | | |
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; |
34 | | |
35 | | XMLIndexUserSourceContext::XMLIndexUserSourceContext( |
36 | | SvXMLImport& rImport, |
37 | | Reference<XPropertySet> & rPropSet) |
38 | 0 | : XMLIndexSourceBaseContext(rImport, rPropSet, UseStyles::Level), |
39 | 0 | bUseObjects(false), |
40 | 0 | bUseGraphic(false), |
41 | 0 | bUseMarks(false), |
42 | 0 | bUseTables(false), |
43 | 0 | bUseFrames(false), |
44 | 0 | bUseLevelFromSource(false), |
45 | 0 | bUseLevelParagraphStyles(false) |
46 | 0 | { |
47 | 0 | } |
48 | | |
49 | | XMLIndexUserSourceContext::~XMLIndexUserSourceContext() |
50 | 0 | { |
51 | 0 | } |
52 | | |
53 | | void XMLIndexUserSourceContext::ProcessAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter & aIter) |
54 | 0 | { |
55 | 0 | bool bTmp(false); |
56 | |
|
57 | 0 | switch (aIter.getToken()) |
58 | 0 | { |
59 | 0 | case XML_ELEMENT(TEXT, XML_USE_INDEX_MARKS): |
60 | 0 | if (::sax::Converter::convertBool(bTmp, aIter.toView())) |
61 | 0 | { |
62 | 0 | bUseMarks = bTmp; |
63 | 0 | } |
64 | 0 | break; |
65 | | |
66 | 0 | case XML_ELEMENT(TEXT, XML_USE_OBJECTS): |
67 | 0 | if (::sax::Converter::convertBool(bTmp, aIter.toView())) |
68 | 0 | { |
69 | 0 | bUseObjects = bTmp; |
70 | 0 | } |
71 | 0 | break; |
72 | | |
73 | 0 | case XML_ELEMENT(TEXT, XML_USE_GRAPHICS): |
74 | 0 | if (::sax::Converter::convertBool(bTmp, aIter.toView())) |
75 | 0 | { |
76 | 0 | bUseGraphic = bTmp; |
77 | 0 | } |
78 | 0 | break; |
79 | | |
80 | 0 | case XML_ELEMENT(TEXT, XML_USE_TABLES): |
81 | 0 | if (::sax::Converter::convertBool(bTmp, aIter.toView())) |
82 | 0 | { |
83 | 0 | bUseTables = bTmp; |
84 | 0 | } |
85 | 0 | break; |
86 | | |
87 | 0 | case XML_ELEMENT(TEXT, XML_USE_FLOATING_FRAMES): |
88 | 0 | if (::sax::Converter::convertBool(bTmp, aIter.toView())) |
89 | 0 | { |
90 | 0 | bUseFrames = bTmp; |
91 | 0 | } |
92 | 0 | break; |
93 | | |
94 | 0 | case XML_ELEMENT(TEXT, XML_COPY_OUTLINE_LEVELS): |
95 | 0 | if (::sax::Converter::convertBool(bTmp, aIter.toView())) |
96 | 0 | { |
97 | 0 | bUseLevelFromSource = bTmp; |
98 | 0 | } |
99 | 0 | break; |
100 | | |
101 | 0 | case XML_ELEMENT(TEXT, XML_USE_INDEX_SOURCE_STYLES): |
102 | 0 | if (::sax::Converter::convertBool(bTmp, aIter.toView())) |
103 | 0 | { |
104 | 0 | bUseLevelParagraphStyles = bTmp; |
105 | 0 | } |
106 | 0 | break; |
107 | | |
108 | 0 | case XML_ELEMENT(TEXT, XML_INDEX_NAME): |
109 | 0 | sIndexName = aIter.toString(); |
110 | 0 | break; |
111 | | |
112 | 0 | default: |
113 | 0 | XMLIndexSourceBaseContext::ProcessAttribute(aIter); |
114 | 0 | break; |
115 | 0 | } |
116 | 0 | } |
117 | | |
118 | | void XMLIndexUserSourceContext::endFastElement(sal_Int32 nElement) |
119 | 0 | { |
120 | 0 | rIndexPropertySet->setPropertyValue(u"CreateFromEmbeddedObjects"_ustr, css::uno::Any(bUseObjects)); |
121 | 0 | rIndexPropertySet->setPropertyValue(u"CreateFromGraphicObjects"_ustr, css::uno::Any(bUseGraphic)); |
122 | 0 | rIndexPropertySet->setPropertyValue(u"UseLevelFromSource"_ustr, css::uno::Any(bUseLevelFromSource)); |
123 | 0 | rIndexPropertySet->setPropertyValue(u"CreateFromMarks"_ustr, css::uno::Any(bUseMarks)); |
124 | 0 | rIndexPropertySet->setPropertyValue(u"CreateFromTables"_ustr, css::uno::Any(bUseTables)); |
125 | 0 | rIndexPropertySet->setPropertyValue(u"CreateFromTextFrames"_ustr, css::uno::Any(bUseFrames)); |
126 | 0 | rIndexPropertySet->setPropertyValue(u"CreateFromLevelParagraphStyles"_ustr, css::uno::Any(bUseLevelParagraphStyles)); |
127 | |
|
128 | 0 | if( !sIndexName.isEmpty() ) |
129 | 0 | { |
130 | 0 | rIndexPropertySet->setPropertyValue(u"UserIndexName"_ustr, css::uno::Any(sIndexName)); |
131 | 0 | } |
132 | |
|
133 | 0 | XMLIndexSourceBaseContext::endFastElement(nElement); |
134 | 0 | } |
135 | | |
136 | | css::uno::Reference< css::xml::sax::XFastContextHandler > XMLIndexUserSourceContext::createFastChildContext( |
137 | | sal_Int32 nElement, |
138 | | const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) |
139 | 0 | { |
140 | 0 | if ( nElement == XML_ELEMENT(TEXT, XML_USER_INDEX_ENTRY_TEMPLATE) ) |
141 | 0 | { |
142 | 0 | return new XMLIndexTemplateContext(GetImport(), rIndexPropertySet, |
143 | 0 | aSvLevelNameTOCMap, |
144 | 0 | XML_OUTLINE_LEVEL, |
145 | 0 | aLevelStylePropNameTOCMap, |
146 | 0 | aAllowedTokenTypesUser); |
147 | 0 | } |
148 | 0 | else |
149 | 0 | { |
150 | 0 | return XMLIndexSourceBaseContext::createFastChildContext(nElement, |
151 | 0 | xAttrList); |
152 | 0 | } |
153 | |
|
154 | 0 | } |
155 | | |
156 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |