fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / xmloff / source / text / XMLIndexAlphabeticalSourceContext.cxx
blob28acc591322d219f53c569bb9ee13238ca4b85e9
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/XIndexReplace.hpp>
26 #include <sax/tools/converter.hxx>
28 #include "XMLIndexTemplateContext.hxx"
29 #include "XMLIndexTitleTemplateContext.hxx"
30 #include "XMLIndexTOCStylesContext.hxx"
31 #include <xmloff/xmlictxt.hxx>
32 #include <xmloff/xmlimp.hxx>
33 #include <xmloff/txtimp.hxx>
34 #include "xmloff/xmlnmspe.hxx"
35 #include <xmloff/nmspmap.hxx>
36 #include <xmloff/xmltoken.hxx>
37 #include <xmloff/xmluconv.hxx>
38 #include <rtl/ustring.hxx>
43 using ::com::sun::star::beans::XPropertySet;
44 using ::com::sun::star::uno::Reference;
45 using ::com::sun::star::uno::Any;
46 using ::com::sun::star::xml::sax::XAttributeList;
47 using ::xmloff::token::IsXMLToken;
48 using ::xmloff::token::XML_ALPHABETICAL_INDEX_ENTRY_TEMPLATE;
49 using ::xmloff::token::XML_OUTLINE_LEVEL;
51 const sal_Char sAPI_MainEntryCharacterStyleName[] = "MainEntryCharacterStyleName";
52 const sal_Char sAPI_UseAlphabeticalSeparators[] = "UseAlphabeticalSeparators";
53 const sal_Char sAPI_UseCombinedEntries[] = "UseCombinedEntries";
54 const sal_Char sAPI_IsCaseSensitive[] = "IsCaseSensitive";
55 const sal_Char sAPI_UseKeyAsEntry[] = "UseKeyAsEntry";
56 const sal_Char sAPI_UseUpperCase[] = "UseUpperCase";
57 const sal_Char sAPI_UseDash[] = "UseDash";
58 const sal_Char sAPI_UsePP[] = "UsePP";
59 const sal_Char sAPI_SortAlgorithm[] = "SortAlgorithm";
60 const sal_Char sAPI_Locale[] = "Locale";
63 TYPEINIT1( XMLIndexAlphabeticalSourceContext, XMLIndexSourceBaseContext );
65 XMLIndexAlphabeticalSourceContext::XMLIndexAlphabeticalSourceContext(
66 SvXMLImport& rImport,
67 sal_uInt16 nPrfx,
68 const OUString& rLocalName,
69 Reference<XPropertySet> & rPropSet)
70 : XMLIndexSourceBaseContext(rImport, nPrfx, rLocalName, rPropSet, sal_False)
71 , sMainEntryCharacterStyleName(sAPI_MainEntryCharacterStyleName)
72 , sUseAlphabeticalSeparators(sAPI_UseAlphabeticalSeparators)
73 , sUseCombinedEntries(sAPI_UseCombinedEntries)
74 , sIsCaseSensitive(sAPI_IsCaseSensitive)
75 , sUseKeyAsEntry(sAPI_UseKeyAsEntry)
76 , sUseUpperCase(sAPI_UseUpperCase)
77 , sUseDash(sAPI_UseDash)
78 , sUsePP(sAPI_UsePP)
79 , sIsCommaSeparated("IsCommaSeparated")
80 , sSortAlgorithm(sAPI_SortAlgorithm)
81 , sLocale(sAPI_Locale)
82 , bMainEntryStyleNameOK(sal_False)
83 , bSeparators(sal_False)
84 , bCombineEntries(sal_True)
85 , bCaseSensitive(sal_True)
86 , bEntry(sal_False)
87 , bUpperCase(sal_False)
88 , bCombineDash(sal_False)
89 , bCombinePP(sal_True)
90 , bCommaSeparated(sal_False)
94 XMLIndexAlphabeticalSourceContext::~XMLIndexAlphabeticalSourceContext()
98 void XMLIndexAlphabeticalSourceContext::ProcessAttribute(
99 enum IndexSourceParamEnum eParam,
100 const OUString& rValue)
102 bool bTmp(false);
104 switch (eParam)
106 case XML_TOK_INDEXSOURCE_MAIN_ENTRY_STYLE:
108 sMainEntryStyleName = rValue;
109 OUString sDisplayStyleName = GetImport().GetStyleDisplayName(
110 XML_STYLE_FAMILY_TEXT_TEXT, sMainEntryStyleName );
111 const Reference < ::com::sun::star::container::XNameContainer >&
112 rStyles = GetImport().GetTextImport()->GetTextStyles();
113 bMainEntryStyleNameOK = rStyles.is() && rStyles->hasByName( sDisplayStyleName );
115 break;
117 case XML_TOK_INDEXSOURCE_IGNORE_CASE:
118 if (::sax::Converter::convertBool(bTmp, rValue))
120 bCaseSensitive = !bTmp;
122 break;
124 case XML_TOK_INDEXSOURCE_SEPARATORS:
125 if (::sax::Converter::convertBool(bTmp, rValue))
127 bSeparators = bTmp;
129 break;
131 case XML_TOK_INDEXSOURCE_COMBINE_ENTRIES:
132 if (::sax::Converter::convertBool(bTmp, rValue))
134 bCombineEntries = bTmp;
136 break;
138 case XML_TOK_INDEXSOURCE_COMBINE_WITH_DASH:
139 if (::sax::Converter::convertBool(bTmp, rValue))
141 bCombineDash = bTmp;
143 break;
144 case XML_TOK_INDEXSOURCE_KEYS_AS_ENTRIES:
145 if (::sax::Converter::convertBool(bTmp, rValue))
147 bEntry = bTmp;
149 break;
151 case XML_TOK_INDEXSOURCE_COMBINE_WITH_PP:
152 if (::sax::Converter::convertBool(bTmp, rValue))
154 bCombinePP = bTmp;
156 break;
158 case XML_TOK_INDEXSOURCE_CAPITALIZE:
159 if (::sax::Converter::convertBool(bTmp, rValue))
161 bUpperCase = bTmp;
163 break;
165 case XML_TOK_INDEXSOURCE_COMMA_SEPARATED:
166 if (::sax::Converter::convertBool(bTmp, rValue))
168 bCommaSeparated = bTmp;
170 break;
172 case XML_TOK_INDEXSOURCE_SORT_ALGORITHM:
173 sAlgorithm = rValue;
174 break;
175 case XML_TOK_INDEXSOURCE_LANGUAGE:
176 aLocale.Language = rValue;
177 break;
178 case XML_TOK_INDEXSOURCE_COUNTRY:
179 aLocale.Country = rValue;
180 break;
182 default:
183 XMLIndexSourceBaseContext::ProcessAttribute(eParam, rValue);
184 break;
188 void XMLIndexAlphabeticalSourceContext::EndElement()
191 Any aAny;
193 if (bMainEntryStyleNameOK)
195 aAny <<= GetImport().GetStyleDisplayName(
196 XML_STYLE_FAMILY_TEXT_TEXT, sMainEntryStyleName );
197 rIndexPropertySet->setPropertyValue(sMainEntryCharacterStyleName,aAny);
200 aAny.setValue(&bSeparators, ::getBooleanCppuType());
201 rIndexPropertySet->setPropertyValue(sUseAlphabeticalSeparators, aAny);
203 aAny.setValue(&bCombineEntries, ::getBooleanCppuType());
204 rIndexPropertySet->setPropertyValue(sUseCombinedEntries, aAny);
206 aAny.setValue(&bCaseSensitive, ::getBooleanCppuType());
207 rIndexPropertySet->setPropertyValue(sIsCaseSensitive, aAny);
209 aAny.setValue(&bEntry, ::getBooleanCppuType());
210 rIndexPropertySet->setPropertyValue(sUseKeyAsEntry, aAny);
212 aAny.setValue(&bUpperCase, ::getBooleanCppuType());
213 rIndexPropertySet->setPropertyValue(sUseUpperCase, aAny);
215 aAny.setValue(&bCombineDash, ::getBooleanCppuType());
216 rIndexPropertySet->setPropertyValue(sUseDash, aAny);
218 aAny.setValue(&bCombinePP, ::getBooleanCppuType());
219 rIndexPropertySet->setPropertyValue(sUsePP, aAny);
221 aAny.setValue(&bCommaSeparated, ::getBooleanCppuType());
222 rIndexPropertySet->setPropertyValue(sIsCommaSeparated, aAny);
225 if (!sAlgorithm.isEmpty())
227 aAny <<= sAlgorithm;
228 rIndexPropertySet->setPropertyValue(sSortAlgorithm, aAny);
231 if ( !aLocale.Language.isEmpty() && !aLocale.Country.isEmpty() )
233 aAny <<= aLocale;
234 rIndexPropertySet->setPropertyValue(sLocale, aAny);
237 XMLIndexSourceBaseContext::EndElement();
240 SvXMLImportContext* XMLIndexAlphabeticalSourceContext::CreateChildContext(
241 sal_uInt16 nPrefix,
242 const OUString& rLocalName,
243 const Reference<XAttributeList> & xAttrList )
245 if ( (XML_NAMESPACE_TEXT == nPrefix) &&
246 IsXMLToken( rLocalName, XML_ALPHABETICAL_INDEX_ENTRY_TEMPLATE ) )
248 return new XMLIndexTemplateContext(GetImport(), rIndexPropertySet,
249 nPrefix, rLocalName,
250 aLevelNameAlphaMap,
251 XML_OUTLINE_LEVEL,
252 aLevelStylePropNameAlphaMap,
253 aAllowedTokenTypesAlpha);
255 else
257 return XMLIndexSourceBaseContext::CreateChildContext(nPrefix,
258 rLocalName,
259 xAttrList);
263 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */