diff options
author | Eike Rathke <erack@redhat.com> | 2013-07-09 15:48:10 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2013-07-09 15:52:21 +0200 |
commit | 4935422b410757bb4920b98a2d81da3c11b8e3d7 (patch) | |
tree | 8c6c5e217e76f77313b864ee1cd6b29b499eadb8 /include/xmloff | |
parent | cc7a301dad831f8113cc3d737e2f4d23061a65ac (diff) |
read/write ODF *:script* and *:rfc-language-tag*
This prepares to be able to read/write the attributes, it does not
enable proper handling of unknown language tags yet. An unknown tag
usually falls back to SYSTEM locale.
Change-Id: I4a78e8fd37deae188c69570157bc4589a712bc7a
Diffstat (limited to 'include/xmloff')
-rw-r--r-- | include/xmloff/languagetagodf.hxx | 35 | ||||
-rw-r--r-- | include/xmloff/xmlexp.hxx | 33 | ||||
-rw-r--r-- | include/xmloff/xmltoken.hxx | 2 | ||||
-rw-r--r-- | include/xmloff/xmltypes.hxx | 3 |
4 files changed, 73 insertions, 0 deletions
diff --git a/include/xmloff/languagetagodf.hxx b/include/xmloff/languagetagodf.hxx new file mode 100644 index 000000000000..9eef8e84af8b --- /dev/null +++ b/include/xmloff/languagetagodf.hxx @@ -0,0 +1,35 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <sal/config.h> +#include <rtl/ustring.hxx> +#include <i18nlangtag/languagetag.hxx> + +/** Helper to gather the single language tag relevant attributes during reading + ODF and form a resulting LanguageTag when done. + + For example fo:language, fo:script, fo:country, style:rfc-language-tag + */ +struct LanguageTagODF +{ + OUString maRfcLanguageTag; + OUString maLanguage; + OUString maScript; + OUString maCountry; + + bool isEmpty() const { return maRfcLanguageTag.isEmpty() && + maLanguage.isEmpty() && maScript.isEmpty() && maCountry.isEmpty(); } + + /** Best call this only once per instance, it recreates a LanguageTag + instance on every call. + */ + LanguageTag getLanguageTag() const { return LanguageTag( maRfcLanguageTag, maLanguage, maScript, maCountry); } +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/xmloff/xmlexp.hxx b/include/xmloff/xmlexp.hxx index 148f73692158..8a58cfd166b6 100644 --- a/include/xmloff/xmlexp.hxx +++ b/include/xmloff/xmlexp.hxx @@ -70,6 +70,7 @@ class XMLEventExport; class XMLSettingsExportHelper; class XMLImageMapExport; class XMLErrors; +class LanguageTag; // Shapes in Writer cannot be named via context menu (#i51726#) #include <unotools/moduleoptions.hxx> @@ -77,6 +78,7 @@ class XMLErrors; namespace com { namespace sun { namespace star { namespace frame { class XModel; } namespace container { class XIndexContainer; } + namespace lang { struct Locale; } } } } namespace comphelper { class UnoInterfaceToUniqueIdentifierMapper; } @@ -349,6 +351,37 @@ public: const OUString& rValue ); void AddAttribute( const OUString& rQName, enum ::xmloff::token::XMLTokenEnum eValue ); + + /** Add language tag attributes, deciding which are necessary. + + @param nPrefix + Namespace prefix for *:language, *:script and *:country + + @param nPrefixRfc + Namespace prefix for *:rfc-language-tag + + @param bWriteEmpty + Whether to write empty *:language and *:country attribute + values in case of an empty locale (denoting system). + + @param eClass + default, XML_LANGUAGE: XML_SCRIPT, XML_COUNTRY, XML_RFC_LANGUAGE_TAG + XML_LANGUAGE_ASIAN: XML_SCRIPT_ASIAN, XML_COUNTRY_ASIAN, XML_RFC_LANGUAGE_TAG_ASIAN + also switches nPrefix XML_NAMESPACE_FO to XML_NAMESPACE_STYLE + XML_LANGUAGE_COMPLEX: XML_SCRIPT_COMPLEX, XML_COUNTRY_COMPLEX, XML_RFC_LANGUAGE_TAG_COMPLEX + also switches nPrefix XML_NAMESPACE_FO to XML_NAMESPACE_STYLE + */ + void AddLanguageTagAttributes( sal_uInt16 nPrefix, sal_uInt16 nPrefixRfc, + const ::com::sun::star::lang::Locale& rLocale, bool bWriteEmpty, + enum ::xmloff::token::XMLTokenEnum eClass = ::xmloff::token::XML_LANGUAGE ); + + /** Same as AddLanguageTagAttributes() but with LanguageTag parameter + instead of Locale. + */ + void AddLanguageTagAttributes( sal_uInt16 nPrefix, sal_uInt16 nPrefixRfc, + const LanguageTag& rLanguageTag, bool bWriteEmpty, + enum ::xmloff::token::XMLTokenEnum eClass = ::xmloff::token::XML_LANGUAGE ); + // add several attributes to the common attribute list void AddAttributeList( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList ); diff --git a/include/xmloff/xmltoken.hxx b/include/xmloff/xmltoken.hxx index a47dedd9fc25..69282ce707d1 100644 --- a/include/xmloff/xmltoken.hxx +++ b/include/xmloff/xmltoken.hxx @@ -1547,6 +1547,8 @@ namespace xmloff { namespace token { XML_SCIENTIFIC_NUMBER, XML_SCORE_SPACES, XML_SCRIPT, + XML_SCRIPT_ASIAN, + XML_SCRIPT_COMPLEX, XML_SCROLL, XML_SDEV, XML_SEARCH_CRITERIA_MUST_APPLY_TO_WHOLE_CELL, diff --git a/include/xmloff/xmltypes.hxx b/include/xmloff/xmltypes.hxx index c20394fd934e..1953af47ee7d 100644 --- a/include/xmloff/xmltypes.hxx +++ b/include/xmloff/xmltypes.hxx @@ -274,6 +274,9 @@ #define XML_TYPE_BOOL_FALSE (XML_TEXT_TYPES_START + 114) #define XML_TYPE_FILLSTYLE (XML_TEXT_TYPES_START + 115) +#define XML_TYPE_CHAR_SCRIPT (XML_TEXT_TYPES_START + 116) +#define XML_TYPE_CHAR_RFC_LANGUAGE_TAG (XML_TEXT_TYPES_START + 117) + #define XML_SCH_TYPES_START (0x4 << XML_TYPE_APP_SHIFT) #define XML_PM_TYPES_START (0x5 << XML_TYPE_APP_SHIFT) // page master #define XML_DB_TYPES_START (0x6 << XML_TYPE_APP_SHIFT) |