summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoros <os@openoffice.org>2009-10-12 10:27:34 +0200
committeros <os@openoffice.org>2009-10-12 10:27:34 +0200
commit542fd3d674db56a676df824b341655833096fc71 (patch)
tree39ae5621085c64018b2577356e3c8723e98f527e
parent37cafacf3e7bbdf5c77f2011bd32a953549b0a72 (diff)
#i105687# enable number format for custom date/datetime/time data
-rw-r--r--sfx2/inc/sfx2/dinfdlg.hxx4
-rw-r--r--sfx2/source/dialog/dinfdlg.cxx22
-rw-r--r--xmloff/inc/txtfldi.hxx5
-rw-r--r--xmloff/source/text/txtflde.cxx11
-rw-r--r--xmloff/source/text/txtfldi.cxx33
5 files changed, 70 insertions, 5 deletions
diff --git a/sfx2/inc/sfx2/dinfdlg.hxx b/sfx2/inc/sfx2/dinfdlg.hxx
index 01746d21527f..8228bb071e1a 100644
--- a/sfx2/inc/sfx2/dinfdlg.hxx
+++ b/sfx2/inc/sfx2/dinfdlg.hxx
@@ -424,6 +424,10 @@ struct CustomPropertyLine
CustomPropertiesYesNoButton m_aYesNoButton;
CustomPropertiesRemoveButton m_aRemoveButton;
+ Point m_aDatePos;
+ Point m_aTimePos;
+ Size m_aDateTimeSize;
+
bool m_bIsRemoved;
bool m_bTypeLostFocus;
diff --git a/sfx2/source/dialog/dinfdlg.cxx b/sfx2/source/dialog/dinfdlg.cxx
index 9d9b97d6667e..4d5417864004 100644
--- a/sfx2/source/dialog/dinfdlg.cxx
+++ b/sfx2/source/dialog/dinfdlg.cxx
@@ -1656,6 +1656,21 @@ IMPL_LINK( CustomPropertiesWindow, TypeHdl, CustomPropertiesTypeBox*, pBox )
pLine->m_aDateField.Show( (CUSTOM_TYPE_DATE == nType) || (CUSTOM_TYPE_DATETIME == nType) );
pLine->m_aTimeField.Show( (CUSTOM_TYPE_TIME == nType) || (CUSTOM_TYPE_DATETIME == nType) );
pLine->m_aYesNoButton.Show( CUSTOM_TYPE_BOOLEAN == nType );
+ //adjust positions of date and time controls
+ if( nType == CUSTOM_TYPE_DATE )
+ {
+ pLine->m_aDateField.SetPosSizePixel(pLine->m_aValueEdit.GetPosPixel(), pLine->m_aValueEdit.GetSizePixel());
+ }
+ else if( nType == CUSTOM_TYPE_DATETIME)
+ {
+ pLine->m_aDateField.SetPosSizePixel( pLine->m_aDatePos, pLine->m_aDateTimeSize );
+ pLine->m_aTimeField.SetPosSizePixel(pLine->m_aTimePos, pLine->m_aDateTimeSize );
+ }
+ else if( nType == CUSTOM_TYPE_TIME)
+ {
+ pLine->m_aTimeField.SetPosSizePixel(pLine->m_aValueEdit.GetPosPixel(), pLine->m_aValueEdit.GetSizePixel());
+ }
+
return 0;
}
@@ -1881,6 +1896,10 @@ void CustomPropertiesWindow::AddLine( const ::rtl::OUString& sName, Any& rAny )
pCurrent++;
pNewCurrent++;
}
+ //
+ pNewLine->m_aDatePos = pNewLine->m_aDateField.GetPosPixel();
+ pNewLine->m_aTimePos = pNewLine->m_aTimeField.GetPosPixel();
+ pNewLine->m_aDateTimeSize = pNewLine->m_aDateField.GetSizePixel();
double nTmpValue = 0;
bool bTmpValue = false;
@@ -1898,6 +1917,7 @@ void CustomPropertiesWindow::AddLine( const ::rtl::OUString& sName, Any& rAny )
{
sal_uInt32 nIndex = m_aNumberFormatter.GetFormatIndex( NF_NUMBER_SYSTEM );
m_aNumberFormatter.GetInputLineString( nTmpValue, nIndex, sValue );
+ pNewLine->m_aValueEdit.SetText( sValue );
nType = CUSTOM_TYPE_NUMBER;
}
else if ( rAny >>= bTmpValue )
@@ -1939,8 +1959,6 @@ void CustomPropertiesWindow::AddLine( const ::rtl::OUString& sName, Any& rAny )
else
pNewLine->m_aYesNoButton.CheckNo();
}
-// else
-// pNewLine->m_aValueEdit.SetText( sValue );
pNewLine->m_aTypeBox.SelectEntryPos( m_aTypeBox.GetEntryPos( (void*)nType ) );
}
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);