diff options
author | Daniel Boelzle <dbo@openoffice.org> | 2001-09-19 08:42:28 +0000 |
---|---|---|
committer | Daniel Boelzle <dbo@openoffice.org> | 2001-09-19 08:42:28 +0000 |
commit | db8efafbdc093ca378fbe58c02a03e50c04ce262 (patch) | |
tree | f6e32cfe396abc385a8feecb5ae9099c74a80c46 /xmlscript | |
parent | 46f9e0ef119e2dab56f67fab40cb748bf606ad98 (diff) |
#92181# supporting formattedfield
Diffstat (limited to 'xmlscript')
-rw-r--r-- | xmlscript/dtd/dialog.dtd | 6 | ||||
-rw-r--r-- | xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx | 20 | ||||
-rw-r--r-- | xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx | 85 | ||||
-rw-r--r-- | xmlscript/test/test.xml | 2 |
4 files changed, 54 insertions, 59 deletions
diff --git a/xmlscript/dtd/dialog.dtd b/xmlscript/dtd/dialog.dtd index e7431af6d400..ccd782ad9743 100644 --- a/xmlscript/dtd/dialog.dtd +++ b/xmlscript/dtd/dialog.dtd @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- - $Id: dialog.dtd,v 1.18 2001-09-19 08:46:32 dbo Exp $ + $Id: dialog.dtd,v 1.19 2001-09-19 09:42:25 dbo Exp $ The Contents of this file are made available subject to the terms of either of the following licenses @@ -326,8 +326,8 @@ dlg:tabstop %boolean; #IMPLIED dlg:readonly %boolean; #IMPLIED dlg:align (left|center|right) #IMPLIED - dlg:format-code CDATA #REQUIRED - dlg:format-locale CDATA #REQUIRED + dlg:format-code CDATA #IMPLIED + dlg:format-locale CDATA #IMPLIED dlg:strict-format %boolean; #IMPLIED dlg:value-default CDATA #IMPLIED dlg:value-max %numeric; #IMPLIED diff --git a/xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx b/xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx index 93e244d6a91e..22e701a13696 100644 --- a/xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx +++ b/xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx @@ -2,9 +2,9 @@ * * $RCSfile: xmldlg_expmodels.cxx,v $ * - * $Revision: 1.15 $ + * $Revision: 1.16 $ * - * last change: $Author: dbo $ $Date: 2001-09-19 08:46:33 $ + * last change: $Author: dbo $ $Date: 2001-09-19 09:42:27 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -745,12 +745,16 @@ void ElementDescriptor::readFormattedFieldModel( StyleBag * all_styles ) // format spec sal_Int32 nKey; - Reference< util::XNumberFormatsSupplier > xSupplier; - OSL_VERIFY( _xProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("FormatKey") ) ) >>= nKey ); - OSL_VERIFY( _xProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("FormatsSupplier") ) ) >>= xSupplier ); - addNumberFormatAttr( - xSupplier->getNumberFormats()->getByKey( nKey ), - OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":value-min") ) ); + if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("FormatKey") ) ) >>= nKey) + { + Reference< util::XNumberFormatsSupplier > xSupplier; + if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("FormatsSupplier") ) ) >>= xSupplier) + { + addNumberFormatAttr( + xSupplier->getNumberFormats()->getByKey( nKey ), + OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":value-min") ) ); + } + } readEvents(); } diff --git a/xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx b/xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx index 773d114986fa..c4f4235cff32 100644 --- a/xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx +++ b/xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx @@ -2,9 +2,9 @@ * * $RCSfile: xmldlg_impmodels.cxx,v $ * - * $Revision: 1.21 $ + * $Revision: 1.22 $ * - * last change: $Author: dbo $ $Date: 2001-09-19 08:46:33 $ + * last change: $Author: dbo $ $Date: 2001-09-19 09:42:27 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -394,60 +394,57 @@ void FormattedFieldElement::endElement() } // format spec - try + OUString sFormat( _xAttributes->getValueByUidName( + XMLNS_DIALOGS_UID, + OUString( RTL_CONSTASCII_USTRINGPARAM("format-code") ) ) ); + if (sFormat.getLength()) { - OUString sFormat( _xAttributes->getValueByUidName( - XMLNS_DIALOGS_UID, - OUString( RTL_CONSTASCII_USTRINGPARAM("format-code") ) ) ); - if (! sFormat.getLength()) - { - throw xml::sax::SAXException( - OUString( RTL_CONSTASCII_USTRINGPARAM("missing format-code attribute!") ), - Reference< XInterface >(), Any() ); - } + lang::Locale locale; + OUString sLocale( _xAttributes->getValueByUidName( XMLNS_DIALOGS_UID, OUString( RTL_CONSTASCII_USTRINGPARAM("format-locale") ) ) ); - if (! sLocale.getLength()) + if (sLocale.getLength()) { - throw xml::sax::SAXException( - OUString( RTL_CONSTASCII_USTRINGPARAM("missing format-locale attribute!") ), - Reference< XInterface >(), Any() ); - } - - // split locale - lang::Locale locale; - sal_Int32 semi0 = sLocale.indexOf( ';' ); - if (semi0 < 0) // no semi at all, just try language - { - locale.Language = sLocale; - } - else - { - sal_Int32 semi1 = sLocale.indexOf( ';', semi0 +1 ); - if (semi1 > semi0) // language;country;variant + // split locale + sal_Int32 semi0 = sLocale.indexOf( ';' ); + if (semi0 < 0) // no semi at all, just try language { - locale.Language = sLocale.copy( 0, semi0 ); - locale.Country = sLocale.copy( semi0 +1, semi1 - semi0 -1 ); - locale.Variant = sLocale.copy( semi1 +1 ); + locale.Language = sLocale; } - else // try language;country + else { - locale.Language = sLocale.copy( 0, semi0 ); - locale.Country = sLocale.copy( semi0 +1 ); + sal_Int32 semi1 = sLocale.indexOf( ';', semi0 +1 ); + if (semi1 > semi0) // language;country;variant + { + locale.Language = sLocale.copy( 0, semi0 ); + locale.Country = sLocale.copy( semi0 +1, semi1 - semi0 -1 ); + locale.Variant = sLocale.copy( semi1 +1 ); + } + else // try language;country + { + locale.Language = sLocale.copy( 0, semi0 ); + locale.Country = sLocale.copy( semi0 +1 ); + } } } Reference< XComponentContext > xContext( _pImport->getComponentContext() ); -// Reference< util::XNumberFormatter > xFormatter( xContext->getServiceManager()->createInstanceWithContext( -// OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.util.NumberFormatter") ), xContext ), UNO_QUERY ); -// OSL_ASSERT( xFormatter.is() ); -// Reference< util::XNumberFormatsSupplier > xSupplier( xFormatter->getNumberFormatsSupplier() ); Reference< util::XNumberFormatsSupplier > xSupplier( xContext->getServiceManager()->createInstanceWithContext( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.util.NumberFormatsSupplier") ), xContext ), UNO_QUERY ); - Reference< util::XNumberFormats > xFormats( xSupplier->getNumberFormats() ); - sal_Int32 nKey = xFormats->addNew( sFormat, locale ); + + sal_Int32 nKey; + try + { + nKey = xFormats->addNew( sFormat, locale ); + } + catch (util::MalformedNumberFormatException & exc) + { + OSL_ENSURE( 0, "### util::MalformedNumberFormatException occured!" ); + // rethrow + throw xml::sax::SAXException( exc.Message, Reference< XInterface >(), Any() ); + } ctx.getControlModel()->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("FormatsSupplier") ), @@ -456,12 +453,6 @@ void FormattedFieldElement::endElement() OUString( RTL_CONSTASCII_USTRINGPARAM("FormatKey") ), makeAny( nKey ) ); } - catch (util::MalformedNumberFormatException & exc) - { - OSL_ENSURE( 0, "### util::MalformedNumberFormatException occured!" ); - // rethrow - throw xml::sax::SAXException( exc.Message, Reference< XInterface >(), Any() ); - } ctx.importEvents( _events ); } diff --git a/xmlscript/test/test.xml b/xmlscript/test/test.xml index 29bfd306cd6f..d4c94d4ccb6e 100644 --- a/xmlscript/test/test.xml +++ b/xmlscript/test/test.xml @@ -95,7 +95,7 @@ <scrollbar style-id="dialog" id="scrollbar1" left="300" top="660" width="80" height="20" align="horizontal" curpos="50" maxpos="200" increment="1" pageincrement="10"/> <formattedfield style-id="dialog" id="ffield0" left="20" top="110" width="80" height="20" align="center" text="first ffield" - dlg:format-code="[$$-409]#.##0,00;[ROT]-[$$-409]#.##0,00" dlg:format-locale="de" dlg:value-max="750" dlg:value-min="0" dlg:value="2" spin="true"/> + dlg:value-max="750" dlg:value-min="0" dlg:value="2" spin="true"/> <formattedfield style-id="dialog" id="ffield1" left="250" top="110" width="80" height="20" align="center" text="second ffield" dlg:format-code="[$$-409]#.##0,00;[ROT]-[$$-409]#.##0,00" dlg:format-locale="de;DE;WIN" dlg:value-max="750" dlg:value-min="0" dlg:value="4" spin="true"/> </dlg:bulletinboard> |