LibreOffice Module xmloff (master) 1
XMLIndexAlphabeticalSourceContext.cxx
Go to the documentation of this file.
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
22
23#include <com/sun/star/beans/XPropertySet.hpp>
24#include <com/sun/star/container/XNameContainer.hpp>
25
27
29#include <xmloff/xmlictxt.hxx>
30#include <xmloff/xmlimp.hxx>
31#include <xmloff/txtimp.hxx>
33#include <xmloff/xmltoken.hxx>
34#include <xmloff/xmluconv.hxx>
35#include <rtl/ustring.hxx>
36
37
38using ::com::sun::star::beans::XPropertySet;
39using ::com::sun::star::uno::Reference;
40using ::com::sun::star::uno::Any;
41using namespace ::xmloff::token;
42
44 SvXMLImport& rImport,
45 Reference<XPropertySet> & rPropSet)
46: XMLIndexSourceBaseContext(rImport, rPropSet, UseStyles::None)
47, bMainEntryStyleNameOK(false)
48, bSeparators(false)
49, bCombineEntries(true)
50, bCaseSensitive(true)
51, bEntry(false)
52, bUpperCase(false)
53, bCombineDash(false)
54, bCombinePP(true)
55, bCommaSeparated(false)
56{
57}
58
60{
61}
62
64{
65 bool bTmp(false);
66
67 switch (aIter.getToken())
68 {
70 {
72 OUString sDisplayStyleName = GetImport().GetStyleDisplayName(
74 const Reference < css::container::XNameContainer >&
75 rStyles = GetImport().GetTextImport()->GetTextStyles();
76 bMainEntryStyleNameOK = rStyles.is() && rStyles->hasByName( sDisplayStyleName );
77 }
78 break;
79
81 if (::sax::Converter::convertBool(bTmp, aIter.toView()))
82 {
83 bCaseSensitive = !bTmp;
84 }
85 break;
86
88 if (::sax::Converter::convertBool(bTmp, aIter.toView()))
89 {
90 bSeparators = bTmp;
91 }
92 break;
93
95 if (::sax::Converter::convertBool(bTmp, aIter.toView()))
96 {
97 bCombineEntries = bTmp;
98 }
99 break;
100
102 if (::sax::Converter::convertBool(bTmp, aIter.toView()))
103 {
104 bCombineDash = bTmp;
105 }
106 break;
108 if (::sax::Converter::convertBool(bTmp, aIter.toView()))
109 {
110 bEntry = bTmp;
111 }
112 break;
113
115 if (::sax::Converter::convertBool(bTmp, aIter.toView()))
116 {
117 bCombinePP = bTmp;
118 }
119 break;
120
122 if (::sax::Converter::convertBool(bTmp, aIter.toView()))
123 {
124 bUpperCase = bTmp;
125 }
126 break;
127
129 if (::sax::Converter::convertBool(bTmp, aIter.toView()))
130 {
131 bCommaSeparated = bTmp;
132 }
133 break;
134
136 sAlgorithm = aIter.toString();
137 break;
140 break;
141 case XML_ELEMENT(FO, XML_LANGUAGE):
143 break;
144 case XML_ELEMENT(FO, XML_SCRIPT):
146 break;
147 case XML_ELEMENT(FO, XML_COUNTRY):
149 break;
150
151 default:
153 break;
154 }
155}
156
158{
159
160 Any aAny;
161
163 {
164 aAny <<= GetImport().GetStyleDisplayName(
166 rIndexPropertySet->setPropertyValue("MainEntryCharacterStyleName",aAny);
167 }
168
169 rIndexPropertySet->setPropertyValue("UseAlphabeticalSeparators", css::uno::Any(bSeparators));
170 rIndexPropertySet->setPropertyValue("UseCombinedEntries", css::uno::Any(bCombineEntries));
171 rIndexPropertySet->setPropertyValue("IsCaseSensitive", css::uno::Any(bCaseSensitive));
172 rIndexPropertySet->setPropertyValue("UseKeyAsEntry", css::uno::Any(bEntry));
173 rIndexPropertySet->setPropertyValue("UseUpperCase", css::uno::Any(bUpperCase));
174 rIndexPropertySet->setPropertyValue("UseDash", css::uno::Any(bCombineDash));
175 rIndexPropertySet->setPropertyValue("UsePP", css::uno::Any(bCombinePP));
176 rIndexPropertySet->setPropertyValue("IsCommaSeparated", css::uno::Any(bCommaSeparated));
177
178
179 if (!sAlgorithm.isEmpty())
180 {
181 rIndexPropertySet->setPropertyValue("SortAlgorithm", css::uno::Any(sAlgorithm));
182 }
183
184 if ( !maLanguageTagODF.isEmpty() )
185 {
186 aAny <<= maLanguageTagODF.getLanguageTag().getLocale( false);
187 rIndexPropertySet->setPropertyValue("Locale", aAny);
188 }
189
191}
192
193css::uno::Reference< css::xml::sax::XFastContextHandler > XMLIndexAlphabeticalSourceContext::createFastChildContext(
194 sal_Int32 nElement,
195 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
196{
198 {
204 }
205 else
206 {
208 xAttrList);
209 }
210}
211
212/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const bool aAllowedTokenTypesAlpha[]
const SvXMLEnumMapEntry< sal_uInt16 > aLevelNameAlphaMap[]
const char * aLevelStylePropNameAlphaMap[]
const css::lang::Locale & getLocale(bool bResolveSystem=true) const
SvXMLImport & GetImport()
Definition: xmlictxt.hxx:60
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
XMLIndexAlphabeticalSourceContext(SvXMLImport &rImport, css::uno::Reference< css::beans::XPropertySet > &rPropSet)
virtual void ProcessAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter &aIter) override
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
endFastElement is called before a context will be destructed, but after an elements context has been ...
Superclass for index source elements.
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
endFastElement is called before a context will be destructed, but after an elements context has been ...
css::uno::Reference< css::beans::XPropertySet > & rIndexPropertySet
tab stops relative to margin or indent?
virtual void ProcessAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter &aIter)
Import index entry templates.
static bool convertBool(bool &rBool, std::u16string_view rString)
None
Handling of tokens in XML:
@ XML_MAIN_ENTRY_STYLE_NAME
Definition: xmltoken.hxx:1242
@ XML_COMBINE_ENTRIES_WITH_PP
Definition: xmltoken.hxx:478
@ XML_USE_KEYS_AS_ENTRIES
Definition: xmltoken.hxx:2075
@ XML_ALPHABETICAL_INDEX_ENTRY_TEMPLATE
Definition: xmltoken.hxx:238
@ XML_CAPITALIZE_ENTRIES
Definition: xmltoken.hxx:392
@ XML_COMBINE_ENTRIES_WITH_DASH
Definition: xmltoken.hxx:477
@ XML_ALPHABETICAL_SEPARATORS
Definition: xmltoken.hxx:243
LanguageTag getLanguageTag() const
Best call this only once per instance, it recreates a LanguageTag instance on every call.
bool isEmpty() const
OUString maRfcLanguageTag
TEXT
#define XML_ELEMENT(prefix, name)
Definition: xmlimp.hxx:97