summaryrefslogtreecommitdiff
path: root/extensions/source/propctrlr
diff options
context:
space:
mode:
authorFrank Schoenheit [fs] <frank.schoenheit@sun.com>2009-12-17 11:15:02 +0100
committerFrank Schoenheit [fs] <frank.schoenheit@sun.com>2009-12-17 11:15:02 +0100
commit738f9f2e8577984fa90f1376078e18c1f57bf64b (patch)
treee065d90f00ed4c2688e1a0577312bc4ac3e9b07c /extensions/source/propctrlr
parentd510bfeda9869a98f489b81ccda8c1740fd2a8c3 (diff)
dba33e: #i107611#: display a text sample for text formats, to better distinguish text formats from non-text formats
Diffstat (limited to 'extensions/source/propctrlr')
-rw-r--r--extensions/source/propctrlr/formcomponenthandler.cxx2
-rw-r--r--extensions/source/propctrlr/propres.src5
-rw-r--r--extensions/source/propctrlr/propresid.hrc3
-rw-r--r--extensions/source/propctrlr/usercontrol.cxx58
-rw-r--r--extensions/source/propctrlr/usercontrol.hxx3
5 files changed, 47 insertions, 24 deletions
diff --git a/extensions/source/propctrlr/formcomponenthandler.cxx b/extensions/source/propctrlr/formcomponenthandler.cxx
index f21e70a20f47..6f580ec2422e 100644
--- a/extensions/source/propctrlr/formcomponenthandler.cxx
+++ b/extensions/source/propctrlr/formcomponenthandler.cxx
@@ -2710,7 +2710,7 @@ namespace pcr
SvNumberFormatter* pFormatter = pSupplier->GetNumberFormatter();
double dPreviewVal = OFormatSampleControl::getPreviewValue(pFormatter,nFormatKey);
- SvxNumberInfoItem aFormatter( pFormatter, dPreviewVal, SID_ATTR_NUMBERFORMAT_INFO );
+ SvxNumberInfoItem aFormatter( pFormatter, dPreviewVal, String( PcrRes( RID_STR_TEXT_FORMAT ) ), SID_ATTR_NUMBERFORMAT_INFO );
aCoreSet.Put( aFormatter );
// a tab dialog with a single page
diff --git a/extensions/source/propctrlr/propres.src b/extensions/source/propctrlr/propres.src
index 7ce673f8136f..6d2729f12625 100644
--- a/extensions/source/propctrlr/propres.src
+++ b/extensions/source/propctrlr/propres.src
@@ -64,3 +64,8 @@ String RID_EMBED_IMAGE_PLACEHOLDER
{
Text [ en-US ] = "<Embedded-Image>";
};
+
+String RID_STR_TEXT_FORMAT
+{
+ Text [ en-US ] = "Text";
+};
diff --git a/extensions/source/propctrlr/propresid.hrc b/extensions/source/propctrlr/propresid.hrc
index 705638accf98..1f857616905c 100644
--- a/extensions/source/propctrlr/propresid.hrc
+++ b/extensions/source/propctrlr/propresid.hrc
@@ -45,6 +45,7 @@
#define RID_STR_PROPPAGE_DEFAULT ( RID_PROPCONTROLLER_START + 1 )
#define RID_STR_PROPPAGE_DATA ( RID_PROPCONTROLLER_START + 2 )
#define RID_STR_HELP_SECTION_LABEL ( RID_PROPCONTROLLER_START + 3 )
-#define RID_EMBED_IMAGE_PLACEHOLDER ( RID_PROPCONTROLLER_START + 5 )
+#define RID_EMBED_IMAGE_PLACEHOLDER ( RID_PROPCONTROLLER_START + 4 )
+#define RID_STR_TEXT_FORMAT ( RID_PROPCONTROLLER_START + 5 )
#endif // EXTENSIONS_PROPRESID_HRC
diff --git a/extensions/source/propctrlr/usercontrol.cxx b/extensions/source/propctrlr/usercontrol.cxx
index 005659f3576a..40dc288f64f4 100644
--- a/extensions/source/propctrlr/usercontrol.cxx
+++ b/extensions/source/propctrlr/usercontrol.cxx
@@ -44,6 +44,7 @@
#include <com/sun/star/util/Time.hpp>
#include "modulepcr.hxx"
#include "propresid.hrc"
+
//............................................................................
namespace pcr
{
@@ -118,39 +119,52 @@ namespace pcr
getTypedControlWindow()->SetFormatKey( nFormatKey );
SvNumberFormatter* pNF = getTypedControlWindow()->GetFormatter();
- getTypedControlWindow()->SetValue( getPreviewValue(pNF,getTypedControlWindow()->GetFormatKey()) );
+ const SvNumberformat* pEntry = pNF->GetEntry( nFormatKey );
+ OSL_ENSURE( pEntry, "OFormatSampleControl::setValue: invalid format entry!" );
+
+ const bool bIsTextFormat = ( pEntry && pEntry->IsTextFormat() );
+ if ( bIsTextFormat )
+ getTypedControlWindow()->SetText( String( PcrRes( RID_STR_TEXT_FORMAT ) ) );
+ else
+ getTypedControlWindow()->SetValue( pEntry ? getPreviewValue( *pEntry ) : 1234.56789 );
}
else
getTypedControlWindow()->SetText( String() );
}
//------------------------------------------------------------------
+ double OFormatSampleControl::getPreviewValue( const SvNumberformat& i_rEntry )
+ {
+ double nValue = 1234.56789;
+ switch ( i_rEntry.GetType() & ~NUMBERFORMAT_DEFINED )
+ {
+ case NUMBERFORMAT_DATE:
+ {
+ Date aCurrentDate;
+ static ::com::sun::star::util::Date STANDARD_DB_DATE(30,12,1899);
+ nValue = ::dbtools::DBTypeConversion::toDouble(::dbtools::DBTypeConversion::toDate(static_cast<sal_Int32>(aCurrentDate.GetDate())),STANDARD_DB_DATE);
+ }
+ break;
+ case NUMBERFORMAT_TIME:
+ case NUMBERFORMAT_DATETIME:
+ {
+ Time aCurrentTime;
+ nValue = ::dbtools::DBTypeConversion::toDouble(::dbtools::DBTypeConversion::toTime(aCurrentTime.GetTime()));
+ }
+ break;
+ default:
+ break;
+ }
+ return nValue;
+ }
+
+ //------------------------------------------------------------------
double OFormatSampleControl::getPreviewValue(SvNumberFormatter* _pNF,sal_Int32 _nFormatKey)
{
const SvNumberformat* pEntry = _pNF->GetEntry(_nFormatKey);
DBG_ASSERT( pEntry, "OFormattedNumericControl::SetFormatDescription: invalid format key!" );
double nValue = 1234.56789;
if ( pEntry )
- {
- switch (pEntry->GetType() & ~NUMBERFORMAT_DEFINED)
- {
- case NUMBERFORMAT_DATE:
- {
- Date aCurrentDate;
- static ::com::sun::star::util::Date STANDARD_DB_DATE(30,12,1899);
- nValue = ::dbtools::DBTypeConversion::toDouble(::dbtools::DBTypeConversion::toDate(static_cast<sal_Int32>(aCurrentDate.GetDate())),STANDARD_DB_DATE);
- }
- break;
- case NUMBERFORMAT_TIME:
- case NUMBERFORMAT_DATETIME:
- {
- Time aCurrentTime;
- nValue = ::dbtools::DBTypeConversion::toDouble(::dbtools::DBTypeConversion::toTime(aCurrentTime.GetTime()));
- }
- break;
- default:
- break;
- }
- }
+ nValue = getPreviewValue( *pEntry );
return nValue;
}
//------------------------------------------------------------------
diff --git a/extensions/source/propctrlr/usercontrol.hxx b/extensions/source/propctrlr/usercontrol.hxx
index 0d9a0e5a85d7..3fca7e12324f 100644
--- a/extensions/source/propctrlr/usercontrol.hxx
+++ b/extensions/source/propctrlr/usercontrol.hxx
@@ -90,6 +90,9 @@ namespace pcr
* \return current date or time or the value 1234.56789
*/
static double getPreviewValue(SvNumberFormatter* _pNF,sal_Int32 _nFormatKey);
+
+ private:
+ static double getPreviewValue( const SvNumberformat& i_rEntry );
};
//========================================================================