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 
26 #include <sax/tools/converter.hxx>
27 
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>
36 
37 
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;
45 
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)
61 {
62 }
63 
65 {
66 }
67 
69  enum IndexSourceParamEnum eParam,
70  const OUString& rValue)
71 {
72  bool bTmp(false);
73 
74  switch (eParam)
75  {
77  {
79  OUString sDisplayStyleName = GetImport().GetStyleDisplayName(
81  const Reference < css::container::XNameContainer >&
82  rStyles = GetImport().GetTextImport()->GetTextStyles();
83  bMainEntryStyleNameOK = rStyles.is() && rStyles->hasByName( sDisplayStyleName );
84  }
85  break;
86 
88  if (::sax::Converter::convertBool(bTmp, rValue))
89  {
90  bCaseSensitive = !bTmp;
91  }
92  break;
93 
95  if (::sax::Converter::convertBool(bTmp, rValue))
96  {
97  bSeparators = bTmp;
98  }
99  break;
100 
102  if (::sax::Converter::convertBool(bTmp, rValue))
103  {
104  bCombineEntries = bTmp;
105  }
106  break;
107 
109  if (::sax::Converter::convertBool(bTmp, rValue))
110  {
111  bCombineDash = bTmp;
112  }
113  break;
115  if (::sax::Converter::convertBool(bTmp, rValue))
116  {
117  bEntry = bTmp;
118  }
119  break;
120 
122  if (::sax::Converter::convertBool(bTmp, rValue))
123  {
124  bCombinePP = bTmp;
125  }
126  break;
127 
129  if (::sax::Converter::convertBool(bTmp, rValue))
130  {
131  bUpperCase = bTmp;
132  }
133  break;
134 
136  if (::sax::Converter::convertBool(bTmp, rValue))
137  {
138  bCommaSeparated = bTmp;
139  }
140  break;
141 
143  sAlgorithm = rValue;
144  break;
147  break;
150  break;
153  break;
156  break;
157 
158  default:
160  break;
161  }
162 }
163 
165 {
166 
167  Any aAny;
168 
170  {
171  aAny <<= GetImport().GetStyleDisplayName(
173  rIndexPropertySet->setPropertyValue("MainEntryCharacterStyleName",aAny);
174  }
175 
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));
184 
185 
186  if (!sAlgorithm.isEmpty())
187  {
188  rIndexPropertySet->setPropertyValue("SortAlgorithm", css::uno::Any(sAlgorithm));
189  }
190 
191  if ( !maLanguageTagODF.isEmpty() )
192  {
193  aAny <<= maLanguageTagODF.getLanguageTag().getLocale( false);
194  rIndexPropertySet->setPropertyValue("Locale", aAny);
195  }
196 
198 }
199 
201  sal_uInt16 nPrefix,
202  const OUString& rLocalName,
203  const Reference<XAttributeList> & xAttrList )
204 {
205  if ( (XML_NAMESPACE_TEXT == nPrefix) &&
207  {
209  nPrefix, rLocalName,
214  }
215  else
216  {
218  rLocalName,
219  xAttrList);
220  }
221 }
222 
223 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool IsXMLToken(const OUString &rString, enum XMLTokenEnum eToken)
compare eToken to the string
Definition: xmltoken.cxx:3434
static bool convertBool(bool &rBool, const OUString &rString)
Superclass for index source elements.
const SvXMLEnumMapEntry< sal_uInt16 > aLevelNameAlphaMap[]
SvXMLImport & GetImport()
Definition: xmlictxt.hxx:62
LanguageTag getLanguageTag() const
Best call this only once per instance, it recreates a LanguageTag instance on every call...
rtl::Reference< XMLTextImportHelper > const & GetTextImport()
Definition: xmlimp.hxx:600
const bool aAllowedTokenTypesAlpha[]
const css::lang::Locale & getLocale(bool bResolveSystem=true) const
css::uno::Any const & rValue
Definition: ImageStyle.hxx:38
virtual void ProcessAttribute(enum IndexSourceParamEnum eParam, const OUString &rValue) override
const char * aLevelStylePropNameAlphaMap[]
virtual void EndElement() override
EndElement is called before a context will be destructed, but after an elements context has been pars...
virtual SvXMLImportContextRef CreateChildContext(sal_uInt16 nPrefix, const OUString &rLocalName, const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList) override
Create a children element context.
bool isEmpty() const
constexpr sal_uInt16 XML_NAMESPACE_TEXT
OUString maRfcLanguageTag
virtual void ProcessAttribute(enum IndexSourceParamEnum eParam, const OUString &rValue)
Import index entry templates.
css::uno::Reference< css::beans::XPropertySet > & rIndexPropertySet
tab stops relative to margin or indent?
OUString GetStyleDisplayName(XmlStyleFamily nFamily, const OUString &rName) const
Definition: xmlimp.cxx:1494
XMLIndexAlphabeticalSourceContext(SvXMLImport &rImport, sal_uInt16 nPrfx, const OUString &rLocalName, css::uno::Reference< css::beans::XPropertySet > &rPropSet)
virtual SvXMLImportContextRef CreateChildContext(sal_uInt16 nPrefix, const OUString &rLocalName, const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList) override
Create a children element context.
virtual void EndElement() override
EndElement is called before a context will be destructed, but after an elements context has been pars...