diff options
author | Daniel Vogelheim <dvo@openoffice.org> | 2001-06-12 16:46:20 +0000 |
---|---|---|
committer | Daniel Vogelheim <dvo@openoffice.org> | 2001-06-12 16:46:20 +0000 |
commit | a98f6b275f40dc8166783ca6a0268e80e2e9e577 (patch) | |
tree | c2ba814b74f83a5073c3d8b9f35e20d8a6e1c764 /xmloff/source | |
parent | 6f412bfba04acc6fa76ca8e6bfbac402235ac878 (diff) |
#87851# sort algorithm for indices imported and exported
Diffstat (limited to 'xmloff/source')
-rw-r--r-- | xmloff/source/core/xmltoken.cxx | 6 | ||||
-rw-r--r-- | xmloff/source/text/XMLIndexBibliographyConfigurationContext.cxx | 85 | ||||
-rw-r--r-- | xmloff/source/text/XMLIndexSourceBaseContext.cxx | 36 | ||||
-rw-r--r-- | xmloff/source/text/XMLIndexSourceBaseContext.hxx | 18 | ||||
-rw-r--r-- | xmloff/source/text/XMLSectionExport.cxx | 59 | ||||
-rw-r--r-- | xmloff/source/text/XMLSectionExport.hxx | 6 |
6 files changed, 172 insertions, 38 deletions
diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx index 7d83ae28b40a..8cc45bdf3eb5 100644 --- a/xmloff/source/core/xmltoken.cxx +++ b/xmloff/source/core/xmltoken.cxx @@ -2,9 +2,9 @@ * * $RCSfile: xmltoken.cxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: bm $ $Date: 2001-06-05 16:05:43 $ + * last change: $Author: dvo $ $Date: 2001-06-12 17:46:20 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -1985,7 +1985,7 @@ namespace xmloff { namespace token { TOKEN( "use-regular-expressions" ), // XML_USE_REGULAR_EXPRESSIONS TOKEN( "data-source-has-labels" ), // XML_DATA_SOURCE_HAS_LABELS TOKEN( "link-data-style-to-source" ), // XML_LINK_DATA_STYLE_TO_SOURCE - + TOKEN( "sort-algorithm" ), // XML_SORT_ALGORITHM { 0, NULL, NULL } // XML_TOKEN_END }; diff --git a/xmloff/source/text/XMLIndexBibliographyConfigurationContext.cxx b/xmloff/source/text/XMLIndexBibliographyConfigurationContext.cxx index eb4f6f8d8987..bb8c0ebb03e2 100644 --- a/xmloff/source/text/XMLIndexBibliographyConfigurationContext.cxx +++ b/xmloff/source/text/XMLIndexBibliographyConfigurationContext.cxx @@ -2,9 +2,9 @@ * * $RCSfile: XMLIndexBibliographyConfigurationContext.cxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: sab $ $Date: 2001-03-21 10:52:49 $ + * last change: $Author: dvo $ $Date: 2001-06-12 17:46:20 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -92,6 +92,10 @@ #include "xmlkywd.hxx" #endif +#ifndef _XMLOFF_XMLTOKEN_HXX +#include "xmltoken.hxx" +#endif + #ifndef _XMLOFF_XMLUCONV_HXX #include "xmluconv.hxx" #endif @@ -114,6 +118,7 @@ using namespace ::com::sun::star::text; using namespace ::com::sun::star::uno; +using namespace ::xmloff::token; using ::rtl::OUString; using ::com::sun::star::xml::sax::XAttributeList; @@ -142,8 +147,12 @@ XMLIndexBibliographyConfigurationContext::XMLIndexBibliographyConfigurationConte sSortKeys(RTL_CONSTASCII_USTRINGPARAM("SortKeys")), sSortKey(RTL_CONSTASCII_USTRINGPARAM("SortKey")), sIsSortAscending(RTL_CONSTASCII_USTRINGPARAM("IsSortAscending")), + sSortAlgorithm(RTL_CONSTASCII_USTRINGPARAM("SortAlgorithm")), + sLocale(RTL_CONSTASCII_USTRINGPARAM("Locale")), sSuffix(), sPrefix(), + sAlgorithm(), + aLocale(), bNumberedEntries(sal_False), bSortByPosition(sal_True) { @@ -164,42 +173,57 @@ void XMLIndexBibliographyConfigurationContext::StartElement( GetKeyByAttrName( xAttrList->getNameByIndex(nAttr), &sLocalName ); - if (nPrefix == XML_NAMESPACE_TEXT) - { - ProcessAttribute(sLocalName, xAttrList->getValueByIndex(nAttr)); - } + ProcessAttribute(nPrefix, sLocalName, + xAttrList->getValueByIndex(nAttr)); // else: ignore } } void XMLIndexBibliographyConfigurationContext::ProcessAttribute( + sal_uInt16 nPrefix, OUString sLocalName, OUString sValue) { - if (sLocalName.equalsAsciiL(sXML_prefix, sizeof(sXML_prefix)-1)) - { - sPrefix = sValue; - } - else if (sLocalName.equalsAsciiL(sXML_suffix, sizeof(sXML_suffix)-1)) + if( XML_NAMESPACE_TEXT == nPrefix ) { - sSuffix = sValue; - } - else if (sLocalName.equalsAsciiL(sXML_numbered_entries, - sizeof(sXML_numbered_entries)-1)) - { - sal_Bool bTmp; - if (SvXMLUnitConverter::convertBool(bTmp, sValue)) + if( IsXMLToken(sLocalName, XML_PREFIX) ) + { + sPrefix = sValue; + } + else if( IsXMLToken(sLocalName, XML_SUFFIX) ) { - bNumberedEntries = bTmp; + sSuffix = sValue; + } + else if( IsXMLToken(sLocalName, XML_NUMBERED_ENTRIES) ) + { + sal_Bool bTmp; + if( SvXMLUnitConverter::convertBool(bTmp, sValue) ) + { + bNumberedEntries = bTmp; + } + } + else if( IsXMLToken(sLocalName, XML_SORT_BY_POSITION) ) + { + sal_Bool bTmp; + if (SvXMLUnitConverter::convertBool(bTmp, sValue)) + { + bSortByPosition = bTmp; + } + } + else if( IsXMLToken(sLocalName, XML_SORT_ALGORITHM) ) + { + sAlgorithm = sValue; } } - else if (sLocalName.equalsAsciiL(sXML_sort_by_position, - sizeof(sXML_sort_by_position)-1)) + else if( XML_NAMESPACE_FO == nPrefix ) { - sal_Bool bTmp; - if (SvXMLUnitConverter::convertBool(bTmp, sValue)) + if( IsXMLToken(sLocalName, XML_LANGUAGE) ) + { + aLocale.Language = sValue; + } + else if( IsXMLToken(sLocalName, XML_COUNTRY) ) { - bSortByPosition = bTmp; + aLocale.Country = sValue; } } } @@ -325,6 +349,19 @@ void XMLIndexBibliographyConfigurationContext::CreateAndInsert( aAny.setValue(&bSortByPosition, ::getBooleanCppuType()); xPropSet->setPropertyValue(sIsSortByPosition, aAny); + if( (aLocale.Language.getLength() > 0) && + (aLocale.Country.getLength() > 0) ) + { + aAny <<= aLocale; + xPropSet->setPropertyValue(sLocale, aAny); + } + + if( sAlgorithm.getLength() > 0 ) + { + aAny <<= sAlgorithm; + xPropSet->setPropertyValue(sSortAlgorithm, aAny); + } + sal_Int32 nCount = aSortKeys.size(); Sequence<Sequence<PropertyValue> > aKeysSeq(nCount); for(sal_Int32 i = 0; i < nCount; i++) diff --git a/xmloff/source/text/XMLIndexSourceBaseContext.cxx b/xmloff/source/text/XMLIndexSourceBaseContext.cxx index c57fc3f80b04..abb9690d87b8 100644 --- a/xmloff/source/text/XMLIndexSourceBaseContext.cxx +++ b/xmloff/source/text/XMLIndexSourceBaseContext.cxx @@ -2,9 +2,9 @@ * * $RCSfile: XMLIndexSourceBaseContext.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: dvo $ $Date: 2001-01-02 14:41:37 $ + * last change: $Author: dvo $ $Date: 2001-06-12 17:46:20 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -131,6 +131,8 @@ using ::com::sun::star::xml::sax::XAttributeList; const sal_Char sAPI_CreateFromChapter[] = "CreateFromChapter"; const sal_Char sAPI_IsRelativeTabstops[] = "IsRelativeTabstops"; +const sal_Char sAPI_SortAlgorithm[] = "SortAlgorithm"; +const sal_Char sAPI_Locale[] = "Locale"; static __FAR_DATA SvXMLTokenMapEntry aIndexSourceTokenMap[] = { @@ -218,6 +220,10 @@ static __FAR_DATA SvXMLTokenMapEntry aIndexSourceTokenMap[] = { XML_NAMESPACE_TEXT, sXML_use_index_source_styles, XML_TOK_INDEXSOURCE_USE_INDEX_SOURCE_STYLES }, + { XML_NAMESPACE_TEXT, sXML_sort_algorithm, + XML_TOK_INDEXSOURCE_SORT_ALGORITHM }, + { XML_NAMESPACE_FO, sXML_language, XML_TOK_INDEXSOURCE_LANGUAGE }, + { XML_NAMESPACE_FO, sXML_country, XML_TOK_INDEXSOURCE_COUNTRY }, XML_TOKEN_MAP_END }; @@ -236,7 +242,9 @@ XMLIndexSourceBaseContext::XMLIndexSourceBaseContext( bChapterIndex(sal_False), bRelativeTabs(sal_True), bUseLevelFormats(bLevelFormats), - sCreateFromChapter(RTL_CONSTASCII_USTRINGPARAM(sAPI_CreateFromChapter)), + sSortAlgorithm(RTL_CONSTASCII_USTRINGPARAM(sAPI_SortAlgorithm)), + sLocale(RTL_CONSTASCII_USTRINGPARAM(sAPI_Locale)), + sCreateFromChapter(RTL_CONSTASCII_USTRINGPARAM(sAPI_CreateFromChapter)), sIsRelativeTabstops(RTL_CONSTASCII_USTRINGPARAM(sAPI_IsRelativeTabstops)) { } @@ -288,6 +296,15 @@ void XMLIndexSourceBaseContext::ProcessAttribute( } break; } + case XML_TOK_INDEXSOURCE_SORT_ALGORITHM: + sAlgorithm = rValue; + break; + case XML_TOK_INDEXSOURCE_LANGUAGE: + aLocale.Language = rValue; + break; + case XML_TOK_INDEXSOURCE_COUNTRY: + aLocale.Country = rValue; + break; default: // unknown attribute -> ignore @@ -304,6 +321,19 @@ void XMLIndexSourceBaseContext::EndElement() aAny.setValue(&bChapterIndex, ::getBooleanCppuType()); rIndexPropertySet->setPropertyValue(sCreateFromChapter, aAny); + + if (sAlgorithm.getLength() > 0) + { + aAny <<= sAlgorithm; + rIndexPropertySet->setPropertyValue(sSortAlgorithm, aAny); + } + + if ( (aLocale.Language.getLength() > 0) && + (aLocale.Country.getLength() > 0) ) + { + aAny <<= aLocale; + rIndexPropertySet->setPropertyValue(sLocale, aAny); + } } SvXMLImportContext* XMLIndexSourceBaseContext::CreateChildContext( diff --git a/xmloff/source/text/XMLIndexSourceBaseContext.hxx b/xmloff/source/text/XMLIndexSourceBaseContext.hxx index 66e2e40c4029..4e116c6613eb 100644 --- a/xmloff/source/text/XMLIndexSourceBaseContext.hxx +++ b/xmloff/source/text/XMLIndexSourceBaseContext.hxx @@ -2,9 +2,9 @@ * * $RCSfile: XMLIndexSourceBaseContext.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: dvo $ $Date: 2000-11-21 11:53:19 $ + * last change: $Author: dvo $ $Date: 2001-06-12 17:46:20 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -74,6 +74,10 @@ #include <rtl/ustring.hxx> #endif +#ifndef _COM_SUN_STAR_LANG_LOCALE_HPP_ +#include <com/sun/star/lang/Locale.hpp> +#endif + namespace com { namespace sun { namespace star { namespace xml { namespace sax { class XAttributeList; } } @@ -109,7 +113,10 @@ enum IndexSourceParamEnum XML_TOK_INDEXSOURCE_SEQUENCE_NAME, XML_TOK_INDEXSOURCE_SEQUENCE_FORMAT, XML_TOK_INDEXSOURCE_COMMA_SEPARATED, - XML_TOK_INDEXSOURCE_USE_INDEX_SOURCE_STYLES + XML_TOK_INDEXSOURCE_USE_INDEX_SOURCE_STYLES, + XML_TOK_INDEXSOURCE_SORT_ALGORITHM, + XML_TOK_INDEXSOURCE_LANGUAGE, + XML_TOK_INDEXSOURCE_COUNTRY }; @@ -120,6 +127,11 @@ class XMLIndexSourceBaseContext : public SvXMLImportContext { const ::rtl::OUString sCreateFromChapter; const ::rtl::OUString sIsRelativeTabstops; + const ::rtl::OUString sSortAlgorithm; + const ::rtl::OUString sLocale; + + ::com::sun::star::lang::Locale aLocale; + ::rtl::OUString sAlgorithm; sal_Bool bUseLevelFormats; diff --git a/xmloff/source/text/XMLSectionExport.cxx b/xmloff/source/text/XMLSectionExport.cxx index 05ef1ed4f97b..04a02dc1d67f 100644 --- a/xmloff/source/text/XMLSectionExport.cxx +++ b/xmloff/source/text/XMLSectionExport.cxx @@ -2,9 +2,9 @@ * * $RCSfile: XMLSectionExport.cxx,v $ * - * $Revision: 1.19 $ + * $Revision: 1.20 $ * - * last change: $Author: dvo $ $Date: 2001-05-31 16:11:06 $ + * last change: $Author: dvo $ $Date: 2001-06-12 17:46:20 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -82,6 +82,10 @@ #include <com/sun/star/lang/XServiceInfo.hpp> #endif +#ifndef _COM_SUN_STAR_LANG_LOCALE_HPP_ +#include <com/sun/star/lang/Locale.hpp> +#endif + #ifndef _COM_SUN_STAR_CONTAINER_XINDEXREPLACE_HPP_ #include <com/sun/star/container/XIndexReplace.hpp> #endif @@ -142,6 +146,10 @@ #include "xmlkywd.hxx" #endif +#ifndef _XMLOFF_XMLTOKEN_HXX +#include "xmltoken.hxx" +#endif + #ifndef _XMLOFF_XMLNMSPE_HXX #include "xmlnmspe.hxx" #endif @@ -178,6 +186,7 @@ using namespace ::com::sun::star; using namespace ::com::sun::star::text; using namespace ::com::sun::star::uno; using namespace ::std; +using namespace ::xmloff::token; using ::rtl::OUString; using ::rtl::OUStringBuffer; @@ -189,6 +198,7 @@ using ::com::sun::star::container::XIndexReplace; using ::com::sun::star::container::XNameAccess; using ::com::sun::star::container::XNamed; using ::com::sun::star::lang::XServiceInfo; +using ::com::sun::star::lang::Locale; using ::com::sun::star::uno::XInterface; @@ -260,6 +270,8 @@ XMLSectionExport::XMLSectionExport( sTextSection(RTL_CONSTASCII_USTRINGPARAM("TextSection")), sIsGlobalDocumentSection(RTL_CONSTASCII_USTRINGPARAM("IsGlobalDocumentSection")), sProtectionKey(RTL_CONSTASCII_USTRINGPARAM("ProtectionKey")), + sSortAlgorithm(RTL_CONSTASCII_USTRINGPARAM("SortAlgorithm")), + sLocale(RTL_CONSTASCII_USTRINGPARAM("Locale")), sEmpty() { } @@ -951,6 +963,25 @@ void XMLSectionExport::ExportBaseIndexSource( sXML_relative_tab_stop_position, sXML_false); } + + // sort algorithm + aAny = rPropertySet->getPropertyValue(sSortAlgorithm); + OUString sAlgorithm; + aAny >>= sAlgorithm; + if (sAlgorithm.getLength() > 0) + { + GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_SORT_ALGORITHM, + sAlgorithm ); + } + + // locale + aAny = rPropertySet->getPropertyValue(sLocale); + Locale aLocale; + aAny >>= aLocale; + GetExport().AddAttribute(XML_NAMESPACE_FO, XML_LANGUAGE, + aLocale.Language); + GetExport().AddAttribute(XML_NAMESPACE_FO, XML_COUNTRY, + aLocale.Country); } // the index source element (all indices) @@ -1644,6 +1675,10 @@ void XMLSectionExport::ExportBibliographyConfiguration(SvXMLExport& rExport) RTL_CONSTASCII_USTRINGPARAM("IsSortByPosition")); const OUString sSortKeys( RTL_CONSTASCII_USTRINGPARAM("SortKeys")); + const OUString sSortAlgorithm( + RTL_CONSTASCII_USTRINGPARAM("SortAlgorithm")); + const OUString sLocale( + RTL_CONSTASCII_USTRINGPARAM("Locale")); OUString sTmp; @@ -1669,8 +1704,26 @@ void XMLSectionExport::ExportBibliographyConfiguration(SvXMLExport& rExport) sXML_sort_by_position, sXML_false); } - // configuration elementXML_CONSTASCII_ACTION( sXML_suffix, "suffix" ); + // sort algorithm + aAny = xPropSet->getPropertyValue(sSortAlgorithm); + OUString sAlgorithm; + aAny >>= sAlgorithm; + if( sAlgorithm.getLength() > 0 ) + { + rExport.AddAttribute( XML_NAMESPACE_TEXT, + XML_SORT_ALGORITHM, sAlgorithm ); + } + + // locale + aAny = xPropSet->getPropertyValue(sLocale); + Locale aLocale; + aAny >>= aLocale; + rExport.AddAttribute(XML_NAMESPACE_FO, XML_LANGUAGE, + aLocale.Language); + rExport.AddAttribute(XML_NAMESPACE_FO, XML_COUNTRY, + aLocale.Country); + // configuration element SvXMLElementExport aElement(rExport, XML_NAMESPACE_TEXT, sXML_bibliography_configuration, sal_True, sal_True); diff --git a/xmloff/source/text/XMLSectionExport.hxx b/xmloff/source/text/XMLSectionExport.hxx index 45658a38666b..95a1b3612b35 100644 --- a/xmloff/source/text/XMLSectionExport.hxx +++ b/xmloff/source/text/XMLSectionExport.hxx @@ -2,9 +2,9 @@ * * $RCSfile: XMLSectionExport.hxx,v $ * - * $Revision: 1.10 $ + * $Revision: 1.11 $ * - * last change: $Author: dvo $ $Date: 2001-05-02 15:04:56 $ + * last change: $Author: dvo $ $Date: 2001-06-12 17:46:20 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -184,6 +184,8 @@ class XMLSectionExport const ::rtl::OUString sTextSection; const ::rtl::OUString sIsGlobalDocumentSection; const ::rtl::OUString sProtectionKey; + const ::rtl::OUString sSortAlgorithm; + const ::rtl::OUString sLocale; const ::rtl::OUString sEmpty; |