summaryrefslogtreecommitdiff
path: root/extensions/source/propctrlr/usercontrol.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'extensions/source/propctrlr/usercontrol.cxx')
-rw-r--r--extensions/source/propctrlr/usercontrol.cxx67
1 files changed, 39 insertions, 28 deletions
diff --git a/extensions/source/propctrlr/usercontrol.cxx b/extensions/source/propctrlr/usercontrol.cxx
index 005659f3576a..e168fd0da830 100644
--- a/extensions/source/propctrlr/usercontrol.cxx
+++ b/extensions/source/propctrlr/usercontrol.cxx
@@ -2,13 +2,10 @@
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
- * Copyright 2008 by Sun Microsystems, Inc.
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
- * $RCSfile: usercontrol.cxx,v $
- * $Revision: 1.12 $
- *
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
@@ -36,14 +33,15 @@
#include <com/sun/star/inspection/PropertyControlType.hpp>
#include <com/sun/star/inspection/PropertyControlType.hpp>
/** === end UNO includes === **/
-#include <svtools/numuno.hxx>
+#include <svl/numuno.hxx>
#include <rtl/math.hxx>
#include <tools/debug.hxx>
-#include <svtools/zformat.hxx>
+#include <svl/zformat.hxx>
#include <connectivity/dbconversion.hxx>
#include <com/sun/star/util/Time.hpp>
#include "modulepcr.hxx"
#include "propresid.hrc"
+
//............................................................................
namespace pcr
{
@@ -118,39 +116,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;
}
//------------------------------------------------------------------