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;
43 using namespace ::xmloff::token;
44 
46  SvXMLImport& rImport,
47  Reference<XPropertySet> & rPropSet)
48 : XMLIndexSourceBaseContext(rImport, rPropSet, false)
49 , bMainEntryStyleNameOK(false)
50 , bSeparators(false)
51 , bCombineEntries(true)
52 , bCaseSensitive(true)
53 , bEntry(false)
54 , bUpperCase(false)
55 , bCombineDash(false)
56 , bCombinePP(true)
57 , bCommaSeparated(false)
58 {
59 }
60 
62 {
63 }
64 
66 {
67  bool bTmp(false);
68 
69  switch (aIter.getToken())
70  {
72  {
73  sMainEntryStyleName = aIter.toString();
74  OUString sDisplayStyleName = GetImport().GetStyleDisplayName(
76  const Reference < css::container::XNameContainer >&
77  rStyles = GetImport().GetTextImport()->GetTextStyles();
78  bMainEntryStyleNameOK = rStyles.is() && rStyles->hasByName( sDisplayStyleName );
79  }
80  break;
81 
83  if (::sax::Converter::convertBool(bTmp, aIter.toView()))
84  {
85  bCaseSensitive = !bTmp;
86  }
87  break;
88 
90  if (::sax::Converter::convertBool(bTmp, aIter.toView()))
91  {
92  bSeparators = bTmp;
93  }
94  break;
95 
97  if (::sax::Converter::convertBool(bTmp, aIter.toView()))
98  {
99  bCombineEntries = bTmp;
100  }
101  break;
102 
104  if (::sax::Converter::convertBool(bTmp, aIter.toView()))
105  {
106  bCombineDash = bTmp;
107  }
108  break;
110  if (::sax::Converter::convertBool(bTmp, aIter.toView()))
111  {
112  bEntry = bTmp;
113  }
114  break;
115 
117  if (::sax::Converter::convertBool(bTmp, aIter.toView()))
118  {
119  bCombinePP = bTmp;
120  }
121  break;
122 
124  if (::sax::Converter::convertBool(bTmp, aIter.toView()))
125  {
126  bUpperCase = bTmp;
127  }
128  break;
129 
131  if (::sax::Converter::convertBool(bTmp, aIter.toView()))
132  {
133  bCommaSeparated = bTmp;
134  }
135  break;
136 
138  sAlgorithm = aIter.toString();
139  break;
142  break;
143  case XML_ELEMENT(FO, XML_LANGUAGE):
145  break;
146  case XML_ELEMENT(FO, XML_SCRIPT):
148  break;
149  case XML_ELEMENT(FO, XML_COUNTRY):
151  break;
152 
153  default:
155  break;
156  }
157 }
158 
160 {
161 
162  Any aAny;
163 
165  {
166  aAny <<= GetImport().GetStyleDisplayName(
168  rIndexPropertySet->setPropertyValue("MainEntryCharacterStyleName",aAny);
169  }
170 
171  rIndexPropertySet->setPropertyValue("UseAlphabeticalSeparators", css::uno::Any(bSeparators));
172  rIndexPropertySet->setPropertyValue("UseCombinedEntries", css::uno::Any(bCombineEntries));
173  rIndexPropertySet->setPropertyValue("IsCaseSensitive", css::uno::Any(bCaseSensitive));
174  rIndexPropertySet->setPropertyValue("UseKeyAsEntry", css::uno::Any(bEntry));
175  rIndexPropertySet->setPropertyValue("UseUpperCase", css::uno::Any(bUpperCase));
176  rIndexPropertySet->setPropertyValue("UseDash", css::uno::Any(bCombineDash));
177  rIndexPropertySet->setPropertyValue("UsePP", css::uno::Any(bCombinePP));
178  rIndexPropertySet->setPropertyValue("IsCommaSeparated", css::uno::Any(bCommaSeparated));
179 
180 
181  if (!sAlgorithm.isEmpty())
182  {
183  rIndexPropertySet->setPropertyValue("SortAlgorithm", css::uno::Any(sAlgorithm));
184  }
185 
186  if ( !maLanguageTagODF.isEmpty() )
187  {
188  aAny <<= maLanguageTagODF.getLanguageTag().getLocale( false);
189  rIndexPropertySet->setPropertyValue("Locale", aAny);
190  }
191 
193 }
194 
195 css::uno::Reference< css::xml::sax::XFastContextHandler > XMLIndexAlphabeticalSourceContext::createFastChildContext(
196  sal_Int32 nElement,
197  const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
198 {
200  {
206  }
207  else
208  {
210  xAttrList);
211  }
212 }
213 
214 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
XMLIndexAlphabeticalSourceContext(SvXMLImport &rImport, css::uno::Reference< css::beans::XPropertySet > &rPropSet)
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
const SvXMLEnumMapEntry< sal_uInt16 > aLevelNameAlphaMap[]
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 ...
SvXMLImport & GetImport()
Definition: xmlictxt.hxx:59
bool IsXMLToken(std::u16string_view rString, enum XMLTokenEnum eToken)
compare eToken to the string
Definition: xmltoken.cxx:3508
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
const char * aLevelStylePropNameAlphaMap[]
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 ...
virtual void ProcessAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter &aIter)
bool isEmpty() const
OUString maRfcLanguageTag
static bool convertBool(bool &rBool, std::u16string_view rString)
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:1406
Handling of tokens in XML:
#define XML_ELEMENT(prefix, name)
Definition: xmlimp.hxx:97
TEXT
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override