nss: upgrade to release 3.73
[LibreOffice.git] / xmloff / source / text / XMLIndexAlphabeticalSourceContext.cxx
blob3c1725887fcea27f0a68a6ed6c2e210fdb47b4cf
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 .
21 #include "XMLIndexAlphabeticalSourceContext.hxx"
23 #include <com/sun/star/beans/XPropertySet.hpp>
24 #include <com/sun/star/container/XNameContainer.hpp>
26 #include <sax/tools/converter.hxx>
28 #include "XMLIndexTemplateContext.hxx"
29 #include <xmloff/xmlictxt.hxx>
30 #include <xmloff/xmlimp.hxx>
31 #include <xmloff/txtimp.hxx>
32 #include <xmloff/xmlnamespace.hxx>
33 #include <xmloff/xmltoken.hxx>
34 #include <xmloff/xmluconv.hxx>
35 #include <rtl/ustring.hxx>
38 using ::com::sun::star::beans::XPropertySet;
39 using ::com::sun::star::uno::Reference;
40 using ::com::sun::star::uno::Any;
41 using ::com::sun::star::xml::sax::XAttributeList;
42 using ::xmloff::token::IsXMLToken;
43 using ::xmloff::token::XML_ALPHABETICAL_INDEX_ENTRY_TEMPLATE;
44 using ::xmloff::token::XML_OUTLINE_LEVEL;
46 XMLIndexAlphabeticalSourceContext::XMLIndexAlphabeticalSourceContext(
47 SvXMLImport& rImport,
48 sal_uInt16 nPrfx,
49 const OUString& rLocalName,
50 Reference<XPropertySet> & rPropSet)
51 : XMLIndexSourceBaseContext(rImport, nPrfx, rLocalName, rPropSet, false)
52 , bMainEntryStyleNameOK(false)
53 , bSeparators(false)
54 , bCombineEntries(true)
55 , bCaseSensitive(true)
56 , bEntry(false)
57 , bUpperCase(false)
58 , bCombineDash(false)
59 , bCombinePP(true)
60 , bCommaSeparated(false)
64 XMLIndexAlphabeticalSourceContext::~XMLIndexAlphabeticalSourceContext()
68 void XMLIndexAlphabeticalSourceContext::ProcessAttribute(
69 enum IndexSourceParamEnum eParam,
70 const OUString& rValue)
72 bool bTmp(false);
74 switch (eParam)
76 case XML_TOK_INDEXSOURCE_MAIN_ENTRY_STYLE:
78 sMainEntryStyleName = rValue;
79 OUString sDisplayStyleName = GetImport().GetStyleDisplayName(
80 XmlStyleFamily::TEXT_TEXT, sMainEntryStyleName );
81 const Reference < css::container::XNameContainer >&
82 rStyles = GetImport().GetTextImport()->GetTextStyles();
83 bMainEntryStyleNameOK = rStyles.is() && rStyles->hasByName( sDisplayStyleName );
85 break;
87 case XML_TOK_INDEXSOURCE_IGNORE_CASE:
88 if (::sax::Converter::convertBool(bTmp, rValue))
90 bCaseSensitive = !bTmp;
92 break;
94 case XML_TOK_INDEXSOURCE_SEPARATORS:
95 if (::sax::Converter::convertBool(bTmp, rValue))
97 bSeparators = bTmp;
99 break;
101 case XML_TOK_INDEXSOURCE_COMBINE_ENTRIES:
102 if (::sax::Converter::convertBool(bTmp, rValue))
104 bCombineEntries = bTmp;
106 break;
108 case XML_TOK_INDEXSOURCE_COMBINE_WITH_DASH:
109 if (::sax::Converter::convertBool(bTmp, rValue))
111 bCombineDash = bTmp;
113 break;
114 case XML_TOK_INDEXSOURCE_KEYS_AS_ENTRIES:
115 if (::sax::Converter::convertBool(bTmp, rValue))
117 bEntry = bTmp;
119 break;
121 case XML_TOK_INDEXSOURCE_COMBINE_WITH_PP:
122 if (::sax::Converter::convertBool(bTmp, rValue))
124 bCombinePP = bTmp;
126 break;
128 case XML_TOK_INDEXSOURCE_CAPITALIZE:
129 if (::sax::Converter::convertBool(bTmp, rValue))
131 bUpperCase = bTmp;
133 break;
135 case XML_TOK_INDEXSOURCE_COMMA_SEPARATED:
136 if (::sax::Converter::convertBool(bTmp, rValue))
138 bCommaSeparated = bTmp;
140 break;
142 case XML_TOK_INDEXSOURCE_SORT_ALGORITHM:
143 sAlgorithm = rValue;
144 break;
145 case XML_TOK_INDEXSOURCE_RFC_LANGUAGE_TAG:
146 maLanguageTagODF.maRfcLanguageTag = rValue;
147 break;
148 case XML_TOK_INDEXSOURCE_LANGUAGE:
149 maLanguageTagODF.maLanguage = rValue;
150 break;
151 case XML_TOK_INDEXSOURCE_SCRIPT:
152 maLanguageTagODF.maScript = rValue;
153 break;
154 case XML_TOK_INDEXSOURCE_COUNTRY:
155 maLanguageTagODF.maCountry = rValue;
156 break;
158 default:
159 XMLIndexSourceBaseContext::ProcessAttribute(eParam, rValue);
160 break;
164 void XMLIndexAlphabeticalSourceContext::endFastElement(sal_Int32 nElement)
167 Any aAny;
169 if (bMainEntryStyleNameOK)
171 aAny <<= GetImport().GetStyleDisplayName(
172 XmlStyleFamily::TEXT_TEXT, sMainEntryStyleName );
173 rIndexPropertySet->setPropertyValue("MainEntryCharacterStyleName",aAny);
176 rIndexPropertySet->setPropertyValue("UseAlphabeticalSeparators", css::uno::Any(bSeparators));
177 rIndexPropertySet->setPropertyValue("UseCombinedEntries", css::uno::Any(bCombineEntries));
178 rIndexPropertySet->setPropertyValue("IsCaseSensitive", css::uno::Any(bCaseSensitive));
179 rIndexPropertySet->setPropertyValue("UseKeyAsEntry", css::uno::Any(bEntry));
180 rIndexPropertySet->setPropertyValue("UseUpperCase", css::uno::Any(bUpperCase));
181 rIndexPropertySet->setPropertyValue("UseDash", css::uno::Any(bCombineDash));
182 rIndexPropertySet->setPropertyValue("UsePP", css::uno::Any(bCombinePP));
183 rIndexPropertySet->setPropertyValue("IsCommaSeparated", css::uno::Any(bCommaSeparated));
186 if (!sAlgorithm.isEmpty())
188 rIndexPropertySet->setPropertyValue("SortAlgorithm", css::uno::Any(sAlgorithm));
191 if ( !maLanguageTagODF.isEmpty() )
193 aAny <<= maLanguageTagODF.getLanguageTag().getLocale( false);
194 rIndexPropertySet->setPropertyValue("Locale", aAny);
197 XMLIndexSourceBaseContext::endFastElement(nElement);
200 SvXMLImportContextRef XMLIndexAlphabeticalSourceContext::CreateChildContext(
201 sal_uInt16 nPrefix,
202 const OUString& rLocalName,
203 const Reference<XAttributeList> & xAttrList )
205 if ( (XML_NAMESPACE_TEXT == nPrefix) &&
206 IsXMLToken( rLocalName, XML_ALPHABETICAL_INDEX_ENTRY_TEMPLATE ) )
208 return new XMLIndexTemplateContext(GetImport(), rIndexPropertySet,
209 nPrefix, rLocalName,
210 aLevelNameAlphaMap,
211 XML_OUTLINE_LEVEL,
212 aLevelStylePropNameAlphaMap,
213 aAllowedTokenTypesAlpha);
215 else
217 return XMLIndexSourceBaseContext::CreateChildContext(nPrefix,
218 rLocalName,
219 xAttrList);
223 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */