diff options
author | os <os@openoffice.org> | 2009-10-12 10:27:34 +0200 |
---|---|---|
committer | os <os@openoffice.org> | 2009-10-12 10:27:34 +0200 |
commit | 542fd3d674db56a676df824b341655833096fc71 (patch) | |
tree | 39ae5621085c64018b2577356e3c8723e98f527e /xmloff | |
parent | 37cafacf3e7bbdf5c77f2011bd32a953549b0a72 (diff) |
#i105687# enable number format for custom date/datetime/time data
Diffstat (limited to 'xmloff')
-rw-r--r-- | xmloff/inc/txtfldi.hxx | 5 | ||||
-rw-r--r-- | xmloff/source/text/txtflde.cxx | 11 | ||||
-rw-r--r-- | xmloff/source/text/txtfldi.cxx | 33 |
3 files changed, 46 insertions, 3 deletions
diff --git a/xmloff/inc/txtfldi.hxx b/xmloff/inc/txtfldi.hxx index b361081a7ce2..96e7e7fee238 100644 --- a/xmloff/inc/txtfldi.hxx +++ b/xmloff/inc/txtfldi.hxx @@ -745,6 +745,11 @@ class XMLUserDocInfoImportContext : public XMLSimpleDocInfoImportContext { rtl::OUString aName; const ::rtl::OUString sPropertyName; + const ::rtl::OUString sPropertyNumberFormat; + const ::rtl::OUString sPropertyIsFixedLanguage; + sal_Int32 nFormat; + sal_Bool bFormatOK; + sal_Bool bIsDefaultLanguage; public: diff --git a/xmloff/source/text/txtflde.cxx b/xmloff/source/text/txtflde.cxx index 873a4a42f02c..5a3850fafe7f 100644 --- a/xmloff/source/text/txtflde.cxx +++ b/xmloff/source/text/txtflde.cxx @@ -681,6 +681,7 @@ sal_Bool XMLTextFieldExport::IsStringField( case FIELD_ID_PAGENUMBER: case FIELD_ID_REFPAGE_SET: case FIELD_ID_REFPAGE_GET: + case FIELD_ID_DOCINFO_CUSTOM: // always number return sal_False; @@ -701,7 +702,6 @@ sal_Bool XMLTextFieldExport::IsStringField( case FIELD_ID_HIDDEN_PARAGRAPH: case FIELD_ID_DOCINFO_CREATION_AUTHOR: case FIELD_ID_DOCINFO_DESCRIPTION: - case FIELD_ID_DOCINFO_CUSTOM: case FIELD_ID_DOCINFO_PRINT_AUTHOR: case FIELD_ID_DOCINFO_TITLE: case FIELD_ID_DOCINFO_SUBJECT: @@ -850,6 +850,7 @@ void XMLTextFieldExport::ExportFieldAutoStyle( case FIELD_ID_USER_GET: case FIELD_ID_EXPRESSION: case FIELD_ID_TABLE_FORMULA: + case FIELD_ID_DOCINFO_CUSTOM: // register number format, if this is a numeric field if (! IsStringField(nToken, xPropSet)) { @@ -913,7 +914,6 @@ void XMLTextFieldExport::ExportFieldAutoStyle( case FIELD_ID_HIDDEN_PARAGRAPH: case FIELD_ID_DOCINFO_CREATION_AUTHOR: case FIELD_ID_DOCINFO_DESCRIPTION: - case FIELD_ID_DOCINFO_CUSTOM: case FIELD_ID_DOCINFO_PRINT_AUTHOR: case FIELD_ID_DOCINFO_TITLE: case FIELD_ID_DOCINFO_SUBJECT: @@ -1473,6 +1473,13 @@ void XMLTextFieldExport::ExportFieldHelper( case FIELD_ID_DOCINFO_CUSTOM: { + ProcessValueAndType(sal_False, // doesn't happen for text + GetIntProperty(sPropertyNumberFormat,rPropSet), + sEmpty, sEmpty, 0.0, // not used + sal_False, sal_False, sal_True, + ! GetOptionalBoolProperty( + sPropertyIsFixedLanguage, + rPropSet, xPropSetInfo, sal_False )); uno::Any aAny = rPropSet->getPropertyValue( sPropertyName ); ::rtl::OUString sName; aAny >>= sName; diff --git a/xmloff/source/text/txtfldi.cxx b/xmloff/source/text/txtfldi.cxx index 632fba8ddddd..f6f768312a94 100644 --- a/xmloff/source/text/txtfldi.cxx +++ b/xmloff/source/text/txtfldi.cxx @@ -2048,6 +2048,11 @@ XMLUserDocInfoImportContext::XMLUserDocInfoImportContext( sLocalName, nToken, sal_False, sal_False) , sPropertyName(RTL_CONSTASCII_USTRINGPARAM(sAPI_name)) + , sPropertyNumberFormat(RTL_CONSTASCII_USTRINGPARAM(sAPI_number_format)) + , sPropertyIsFixedLanguage(RTL_CONSTASCII_USTRINGPARAM(sAPI_is_fixed_language)) + , nFormat(0) + , bFormatOK(sal_False) + , bIsDefaultLanguage( sal_True ) { bValid = sal_False; } @@ -2058,6 +2063,17 @@ void XMLUserDocInfoImportContext::ProcessAttribute( { switch (nAttrToken) { + case XML_TOK_TEXTFIELD_DATA_STYLE_NAME: + { + sal_Int32 nKey = GetImportHelper().GetDataStyleKey( + sAttrValue, &bIsDefaultLanguage); + if (-1 != nKey) + { + nFormat = nKey; + bFormatOK = sal_True; + } + break; + } case XML_TOK_TEXTFIELD_NAME: { if (!bValid) @@ -2080,12 +2096,27 @@ void XMLUserDocInfoImportContext::PrepareField( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> & xPropertySet) { + uno::Any aAny; if ( aName.getLength() ) { - uno::Any aAny; aAny <<= aName; xPropertySet->setPropertyValue(sPropertyName, aAny); } + Reference<XPropertySetInfo> xPropertySetInfo( + xPropertySet->getPropertySetInfo()); + if (bFormatOK && + xPropertySetInfo->hasPropertyByName(sPropertyNumberFormat)) + { + aAny <<= nFormat; + xPropertySet->setPropertyValue(sPropertyNumberFormat, aAny); + + if( xPropertySetInfo->hasPropertyByName( sPropertyIsFixedLanguage ) ) + { + sal_Bool bIsFixedLanguage = ! bIsDefaultLanguage; + aAny.setValue( &bIsFixedLanguage, ::getBooleanCppuType() ); + xPropertySet->setPropertyValue( sPropertyIsFixedLanguage, aAny ); + } + } // call superclass to handle "fixed" XMLSimpleDocInfoImportContext::PrepareField(xPropertySet); |