diff options
author | Ocke Janssen <oj@openoffice.org> | 2002-09-26 09:49:09 +0000 |
---|---|---|
committer | Ocke Janssen <oj@openoffice.org> | 2002-09-26 09:49:09 +0000 |
commit | fb162871bea92577e72437e59e1dfc1d2e6b3a93 (patch) | |
tree | e70dc0da82e5386371dea60808693005fbecc71c | |
parent | 25d65446f2a79720e69e591da1b3ab603e264d7c (diff) |
#102963# SetEvalDateFormat(NF_EVALDATEFORMAT_FORMAT) to use the format key at the number formatter
-rw-r--r-- | dbaccess/source/ui/control/FieldDescControl.cxx | 45 | ||||
-rw-r--r-- | dbaccess/source/ui/inc/UITools.hxx | 10 | ||||
-rw-r--r-- | dbaccess/source/ui/inc/WTypeSelect.hxx | 10 | ||||
-rw-r--r-- | dbaccess/source/ui/misc/UITools.cxx | 29 | ||||
-rw-r--r-- | dbaccess/source/ui/misc/WTypeSelect.cxx | 15 | ||||
-rw-r--r-- | dbaccess/source/ui/tabledesign/TableFieldControl.cxx | 11 | ||||
-rw-r--r-- | dbaccess/source/ui/tabledesign/TableFieldControl.hxx | 7 |
7 files changed, 102 insertions, 25 deletions
diff --git a/dbaccess/source/ui/control/FieldDescControl.cxx b/dbaccess/source/ui/control/FieldDescControl.cxx index 56725b48c70f..9701b03543e5 100644 --- a/dbaccess/source/ui/control/FieldDescControl.cxx +++ b/dbaccess/source/ui/control/FieldDescControl.cxx @@ -2,9 +2,9 @@ * * $RCSfile: FieldDescControl.cxx,v $ * - * $Revision: 1.23 $ + * $Revision: 1.24 $ * - * last change: $Author: oj $ $Date: 2002-09-24 13:55:52 $ + * last change: $Author: oj $ $Date: 2002-09-26 10:49:02 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -167,8 +167,12 @@ #include "UITools.hxx" #endif #include <memory> +#ifndef _DBHELPER_DBCONVERSION_HXX_ +#include <connectivity/dbconversion.hxx> +#endif using namespace dbaui; +using namespace dbtools; // using namespace comphelper; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::beans; @@ -195,6 +199,24 @@ using namespace ::com::sun::star::sdbc; #define HSCROLL_STEP 20 +namespace +{ + // ----------------------------------------------------------------------------- + double checkDoubleForDateFormat(double _nValue,sal_Int32 _nFormatKey,const Reference<XNumberFormatter>& _xNumberFormatter) + { + double nValue = _nValue; + sal_Int32 nNumberFormat = ::comphelper::getNumberFormatType(_xNumberFormatter,_nFormatKey); + if( (nNumberFormat & NumberFormat::DATE) == NumberFormat::DATE + || (nNumberFormat & NumberFormat::DATETIME) == NumberFormat::DATETIME ) + { + nValue = DBTypeConversion::toStandardDbDate(DBTypeConversion::getNULLDate(_xNumberFormatter->getNumberFormatsSupplier()),nValue); + } + + return nValue; + } + // ----------------------------------------------------------------------------- +} + //================================================================== // class OFieldDescControl //================================================================== @@ -316,6 +338,7 @@ OFieldDescControl::OFieldDescControl( Window* pParent, OTableDesignHelpBar* pHel m_pHorzScroll->SetPageSize(1); m_nOldVThumb = m_nOldHThumb = 0; + } //------------------------------------------------------------------------------ @@ -391,6 +414,7 @@ String OFieldDescControl::BoolStringUI(const String& rPersistentString) const //------------------------------------------------------------------------------ void OFieldDescControl::Init() { + ::dbaui::setEvalDateFormatForFormatter(GetFormatter()); } //------------------------------------------------------------------------------ @@ -1888,6 +1912,7 @@ void OFieldDescControl::SaveData( OFieldDescription* pFieldDescr ) try { double nValue = GetFormatter()->convertStringToNumber(nFormatKey,sDefault); + nValue = checkDoubleForDateFormat(nValue,nFormatKey,GetFormatter()); pFieldDescr->SetControlDefault(makeAny(nValue)); } catch(const Exception&) @@ -2083,17 +2108,26 @@ String OFieldDescControl::getControlDefault( const OFieldDescription* _pFieldDes if ( !bTextFormat ) { - Reference<XNumberFormatPreviewer> xPreViewer(GetFormatter(),UNO_QUERY); + Reference<XNumberFormatter> xNumberFormatter = GetFormatter(); + Reference<XNumberFormatPreviewer> xPreViewer(xNumberFormatter,UNO_QUERY); OSL_ENSURE(xPreViewer.is(),"XNumberFormatPreviewer is null!"); - Reference<XPropertySet> xFormSet = GetFormatter()->getNumberFormatsSupplier()->getNumberFormats()->getByKey(nFormatKey); + Reference<XPropertySet> xFormSet = xNumberFormatter->getNumberFormatsSupplier()->getNumberFormats()->getByKey(nFormatKey); OSL_ENSURE(xFormSet.is(),"XPropertySet is null!"); ::rtl::OUString sFormat; xFormSet->getPropertyValue(::rtl::OUString::createFromAscii("FormatString")) >>= sFormat; Locale aLocale; - ::comphelper::getNumberFormatProperty(GetFormatter(),nFormatKey,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Locale"))) >>= aLocale; + ::comphelper::getNumberFormatProperty(xNumberFormatter,nFormatKey,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Locale"))) >>= aLocale; + + sal_Int32 nNumberFormat = ::comphelper::getNumberFormatType(xNumberFormatter,nFormatKey); + if( (nNumberFormat & NumberFormat::DATE) == NumberFormat::DATE + || (nNumberFormat & NumberFormat::DATETIME) == NumberFormat::DATETIME ) + { + nValue = DBTypeConversion::toNullDate(DBTypeConversion::getNULLDate(xNumberFormatter->getNumberFormatsSupplier()),nValue); + } + sDefault = xPreViewer->convertNumberToPreviewString(sFormat,nValue,aLocale,sal_True); } } @@ -2111,4 +2145,3 @@ String OFieldDescControl::getControlDefault( const OFieldDescription* _pFieldDes - diff --git a/dbaccess/source/ui/inc/UITools.hxx b/dbaccess/source/ui/inc/UITools.hxx index 69ed06c852c1..8b62e2014df7 100644 --- a/dbaccess/source/ui/inc/UITools.hxx +++ b/dbaccess/source/ui/inc/UITools.hxx @@ -2,9 +2,9 @@ * * $RCSfile: UITools.hxx,v $ * - * $Revision: 1.16 $ + * $Revision: 1.17 $ * - * last change: $Author: oj $ $Date: 2002-09-24 09:48:22 $ + * last change: $Author: oj $ $Date: 2002-09-26 10:49:03 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -99,6 +99,7 @@ namespace com { namespace sun { namespace star { namespace util { struct URL; + class XNumberFormatter; } }}} @@ -312,6 +313,11 @@ namespace dbaui */ ::com::sun::star::util::URL createHelpAgentURL(const ::rtl::OUString& _sModuleName,const sal_Int32 _nHelpId); + /** set the evaluation flag at the number formatter + @param _rxFormatter + */ + void setEvalDateFormatForFormatter(::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& _rxFormatter); + // ......................................................................... } // ......................................................................... diff --git a/dbaccess/source/ui/inc/WTypeSelect.hxx b/dbaccess/source/ui/inc/WTypeSelect.hxx index 34c0fa1a055c..53ea48261f00 100644 --- a/dbaccess/source/ui/inc/WTypeSelect.hxx +++ b/dbaccess/source/ui/inc/WTypeSelect.hxx @@ -2,9 +2,9 @@ * * $RCSfile: WTypeSelect.hxx,v $ * - * $Revision: 1.8 $ + * $Revision: 1.9 $ * - * last change: $Author: oj $ $Date: 2002-09-24 09:18:57 $ + * last change: $Author: oj $ $Date: 2002-09-26 10:49:04 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -108,10 +108,8 @@ namespace dbaui virtual ::rtl::OUString getAutoIncrementValue() const; public: - OWizTypeSelectControl(Window* pParent, OTableDesignHelpBar* pHelpBar=NULL) - : OFieldDescControl(pParent,pHelpBar) { }; - OWizTypeSelectControl(Window* pParent, const ResId& rResId,OTableDesignHelpBar* pHelpBar=NULL) - : OFieldDescControl(pParent,rResId,pHelpBar) { }; + OWizTypeSelectControl(Window* pParent, OTableDesignHelpBar* pHelpBar=NULL); + OWizTypeSelectControl(Window* pParent, const ResId& rResId,OTableDesignHelpBar* pHelpBar=NULL); virtual ~OWizTypeSelectControl(); virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData> getMetaData(); diff --git a/dbaccess/source/ui/misc/UITools.cxx b/dbaccess/source/ui/misc/UITools.cxx index ec14636daa27..a3c7e0dd9790 100644 --- a/dbaccess/source/ui/misc/UITools.cxx +++ b/dbaccess/source/ui/misc/UITools.cxx @@ -2,9 +2,9 @@ * * $RCSfile: UITools.cxx,v $ * - * $Revision: 1.39 $ + * $Revision: 1.40 $ * - * last change: $Author: oj $ $Date: 2002-09-24 09:48:20 $ + * last change: $Author: oj $ $Date: 2002-09-26 10:49:05 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -201,6 +201,12 @@ #ifndef _COM_SUN_STAR_UTIL_XFLUSHABLE_HPP_ #include <com/sun/star/util/XFlushable.hpp> #endif +#ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATSSUPPLIER_HPP_ +#include <com/sun/star/util/XNumberFormatsSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATTER_HPP_ +#include <com/sun/star/util/XNumberFormatter.hpp> +#endif #ifndef _DBU_MISC_HRC_ #include "dbu_misc.hrc" #endif @@ -237,6 +243,10 @@ #ifndef _URLOBJ_HXX #include <tools/urlobj.hxx> #endif +#ifndef _NUMUNO_HXX +#include <svtools/numuno.hxx> +#endif + // ......................................................................... namespace dbaui { @@ -1266,6 +1276,21 @@ URL createHelpAgentURL(const ::rtl::OUString& _sModuleName,const sal_Int32 _nHel } return aURL; } +// ----------------------------------------------------------------------------- +void setEvalDateFormatForFormatter(Reference< XNumberFormatter >& _rxFormatter) +{ + Reference< XNumberFormatsSupplier > xSupplier = _rxFormatter->getNumberFormatsSupplier(); + + Reference< XUnoTunnel > xTunnel(xSupplier,UNO_QUERY); + SvNumberFormatsSupplierObj* pSupplierImpl = (SvNumberFormatsSupplierObj*)xTunnel->getSomething(SvNumberFormatsSupplierObj::getUnoTunnelId()); + OSL_ENSURE(pSupplierImpl,"No Supplier!"); + + if ( pSupplierImpl ) + { + SvNumberFormatter* pFormatter = pSupplierImpl->GetNumberFormatter(); + pFormatter->SetEvalDateFormat(NF_EVALDATEFORMAT_FORMAT); + } +} // ......................................................................... } // ......................................................................... diff --git a/dbaccess/source/ui/misc/WTypeSelect.cxx b/dbaccess/source/ui/misc/WTypeSelect.cxx index d3427fbb8e29..8bdde0e5d6ea 100644 --- a/dbaccess/source/ui/misc/WTypeSelect.cxx +++ b/dbaccess/source/ui/misc/WTypeSelect.cxx @@ -2,9 +2,9 @@ * * $RCSfile: WTypeSelect.cxx,v $ * - * $Revision: 1.14 $ + * $Revision: 1.15 $ * - * last change: $Author: oj $ $Date: 2002-09-24 09:18:59 $ + * last change: $Author: oj $ $Date: 2002-09-26 10:49:06 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -106,6 +106,16 @@ using namespace ::com::sun::star::sdbc; //======================================================================== // OWizTypeSelectControl //======================================================================== +OWizTypeSelectControl::OWizTypeSelectControl(Window* pParent, OTableDesignHelpBar* pHelpBar) + : OFieldDescControl(pParent,pHelpBar) +{ +} +// ----------------------------------------------------------------------------- +OWizTypeSelectControl::OWizTypeSelectControl(Window* pParent, const ResId& rResId,OTableDesignHelpBar* pHelpBar) + : OFieldDescControl(pParent,rResId,pHelpBar) +{ +} +// ----------------------------------------------------------------------------- OWizTypeSelectControl::~OWizTypeSelectControl() { } @@ -236,6 +246,7 @@ OWizTypeSelect::OWizTypeSelect( Window* pParent,SvStream* _pStream) m_imgPKey = aImageList.GetImage(IMG_PRIMARY_KEY); m_aTypeControl.Show(); + m_aTypeControl.Init(); m_etAuto.SetText(String::CreateFromAscii("10")); m_etAuto.SetDecimalDigits(0); m_pbAuto.SetClickHdl(LINK(this,OWizTypeSelect,ButtonClickHdl)); diff --git a/dbaccess/source/ui/tabledesign/TableFieldControl.cxx b/dbaccess/source/ui/tabledesign/TableFieldControl.cxx index 898cdf452531..232bc35f2617 100644 --- a/dbaccess/source/ui/tabledesign/TableFieldControl.cxx +++ b/dbaccess/source/ui/tabledesign/TableFieldControl.cxx @@ -2,9 +2,9 @@ * * $RCSfile: TableFieldControl.cxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: oj $ $Date: 2002-09-24 09:19:05 $ + * last change: $Author: oj $ $Date: 2002-09-26 10:49:08 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -85,6 +85,9 @@ #ifndef DBAUI_TYPEINFO_HXX #include "TypeInfo.hxx" #endif +#ifndef DBAUI_TOOLS_HXX +#include "UITools.hxx" +#endif using namespace ::com::sun::star::uno; using namespace ::com::sun::star::beans; @@ -92,7 +95,9 @@ using namespace ::com::sun::star::util; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::sdbc; using namespace dbaui; - +OTableFieldControl::OTableFieldControl( Window* pParent, OTableDesignHelpBar* pHelpBar) :OFieldDescControl(pParent,pHelpBar) +{ +} //------------------------------------------------------------------ void OTableFieldControl::CellModified(long nRow, sal_uInt16 nColId ) { diff --git a/dbaccess/source/ui/tabledesign/TableFieldControl.hxx b/dbaccess/source/ui/tabledesign/TableFieldControl.hxx index fea7bf81c8c2..45bd00bc4e09 100644 --- a/dbaccess/source/ui/tabledesign/TableFieldControl.hxx +++ b/dbaccess/source/ui/tabledesign/TableFieldControl.hxx @@ -2,9 +2,9 @@ * * $RCSfile: TableFieldControl.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: oj $ $Date: 2002-09-24 09:19:05 $ + * last change: $Author: oj $ $Date: 2002-09-26 10:49:09 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -92,8 +92,7 @@ namespace dbaui virtual ::rtl::OUString getAutoIncrementValue() const; public: - OTableFieldControl( Window* pParent, OTableDesignHelpBar* pHelpBar) :OFieldDescControl(pParent,pHelpBar) {}; - + OTableFieldControl( Window* pParent, OTableDesignHelpBar* pHelpBar); String BoolStringPersistent(const String& rUIString) const { return OFieldDescControl::BoolStringPersistent(rUIString); } String BoolStringUI(const String& rPersistentString) const { return OFieldDescControl::BoolStringUI(rPersistentString); } |