diff options
Diffstat (limited to 'chart2/source/controller/dialogs/DataBrowser.cxx')
-rw-r--r-- | chart2/source/controller/dialogs/DataBrowser.cxx | 98 |
1 files changed, 72 insertions, 26 deletions
diff --git a/chart2/source/controller/dialogs/DataBrowser.cxx b/chart2/source/controller/dialogs/DataBrowser.cxx index 85bbc8c82fda..bebbf410a89c 100644 --- a/chart2/source/controller/dialogs/DataBrowser.cxx +++ b/chart2/source/controller/dialogs/DataBrowser.cxx @@ -48,7 +48,7 @@ #include "ChartModelHelper.hxx" #include "CommonConverters.hxx" #include "macros.hxx" -#include "chartview/NumberFormatterWrapper.hxx" +#include "NumberFormatterWrapper.hxx" #include "servicenames_charttypes.hxx" #include "ResId.hxx" #include "Bitmaps.hrc" @@ -64,6 +64,7 @@ #include <com/sun/star/chart2/XChartType.hpp> #include <com/sun/star/container/XIndexReplace.hpp> +#include <com/sun/star/util/XNumberFormats.hpp> #include <algorithm> #include <functional> @@ -102,7 +103,7 @@ sal_Int32 lcl_getRowInData( long nRow ) return static_cast< sal_Int32 >( nRow ); } -sal_Int32 lcl_getColumnInData( USHORT nCol ) +sal_Int32 lcl_getColumnInData( sal_uInt16 nCol ) { return static_cast< sal_Int32 >( nCol ) - 1; } @@ -237,7 +238,7 @@ SeriesHeader::SeriesHeader( Window * pParent ) : m_spSeriesName->EnableUpdateData( 4 * EDIT_UPDATEDATA_TIMEOUT ); // define is in vcl/edit.hxx m_spSeriesName->SetUpdateDataHdl( LINK( this, SeriesHeader, SeriesNameChanged )); m_spSeriesName->SetModifyHdl( LINK( this, SeriesHeader, SeriesNameEdited )); - m_spSeriesName->SetSmartHelpId( SmartId( HID_SCH_DATA_SERIES_LABEL )); + m_spSeriesName->SetHelpId( HID_SCH_DATA_SERIES_LABEL ); Show(); } @@ -471,13 +472,13 @@ bool lcl_SeriesHeaderHasFocus( } sal_Int32 lcl_getColumnInDataOrHeader( - USHORT nCol, const ::std::vector< ::boost::shared_ptr< ::chart::impl::SeriesHeader > > & rSeriesHeader ) + sal_uInt16 nCol, const ::std::vector< ::boost::shared_ptr< ::chart::impl::SeriesHeader > > & rSeriesHeader ) { sal_Int32 nColIdx = 0; bool bHeaderHasFocus( lcl_SeriesHeaderHasFocus( rSeriesHeader, &nColIdx )); if( bHeaderHasFocus ) - nColIdx = lcl_getColumnInData( static_cast< USHORT >( rSeriesHeader[nColIdx]->GetStartColumn())); + nColIdx = lcl_getColumnInData( static_cast< sal_uInt16 >( rSeriesHeader[nColIdx]->GetStartColumn())); else nColIdx = lcl_getColumnInData( nCol ); @@ -502,7 +503,7 @@ DataBrowser::DataBrowser( Window* pParent, const ResId& rId, bool bLiveUpdate ) double fNan; ::rtl::math::setNan( & fNan ); m_aNumberEditField.SetDefaultValue( fNan ); - m_aNumberEditField.TreatAsNumber( TRUE ); + m_aNumberEditField.TreatAsNumber( sal_True ); RenewTable(); SetClean(); } @@ -578,10 +579,10 @@ void DataBrowser::RenewTable() return; long nOldRow = GetCurRow(); - USHORT nOldColId = GetCurColumnId(); + sal_uInt16 nOldColId = GetCurColumnId(); - BOOL bLastUpdateMode = GetUpdateMode(); - SetUpdateMode( FALSE ); + sal_Bool bLastUpdateMode = GetUpdateMode(); + SetUpdateMode( sal_False ); if( IsModified() ) SaveModified(); @@ -609,7 +610,7 @@ void DataBrowser::RenewTable() RowInserted( 1, nRowCountLocal ); GoToRow( ::std::min( nOldRow, GetRowCount() - 1 )); - GoToColumnId( ::std::min( nOldColId, static_cast< USHORT >( ColCount() - 1 ))); + GoToColumnId( ::std::min( nOldColId, static_cast< sal_uInt16 >( ColCount() - 1 ))); Window * pWin = this->GetParent(); if( !pWin ) @@ -665,7 +666,7 @@ String DataBrowser::GetRowString( sal_Int32 nRow ) const return String::CreateFromInt32( nRow + 1 ); } -String DataBrowser::GetCellText( long nRow, USHORT nColumnId ) const +String DataBrowser::GetCellText( long nRow, sal_uInt16 nColumnId ) const { String aResult; @@ -690,6 +691,23 @@ String DataBrowser::GetCellText( long nRow, USHORT nColumnId ) const GetNumberFormatKey( nRow, nColumnId ), fData, nLabelColor, bColorChanged )); } + else if( m_apDataBrowserModel->getCellType( nColIndex, nRow ) == DataBrowserModel::TEXTORDATE ) + { + uno::Any aAny = m_apDataBrowserModel->getCellAny( nColIndex, nRow ); + OUString aText; + double fDouble=0.0; + if( aAny>>=aText ) + aResult = aText; + else if( aAny>>=fDouble ) + { + sal_Int32 nLabelColor; + bool bColorChanged = false; + sal_Int32 nDateNumberFormat = DiagramHelper::getDateNumberFormat( Reference< util::XNumberFormatsSupplier >( m_xChartDoc, uno::UNO_QUERY) ); + if( ! ::rtl::math::isNan( fDouble ) && m_spNumberFormatterWrapper.get() ) + aResult = String( m_spNumberFormatterWrapper->getFormattedString( + nDateNumberFormat, fDouble, nLabelColor, bColorChanged )); + } + } else { OSL_ASSERT( m_apDataBrowserModel->getCellType( nColIndex, nRow ) == DataBrowserModel::TEXT ); @@ -700,7 +718,7 @@ String DataBrowser::GetCellText( long nRow, USHORT nColumnId ) const return aResult; } -double DataBrowser::GetCellNumber( long nRow, USHORT nColumnId ) const +double DataBrowser::GetCellNumber( long nRow, sal_uInt16 nColumnId ) const { double fResult; ::rtl::math::setNan( & fResult ); @@ -717,8 +735,8 @@ double DataBrowser::GetCellNumber( long nRow, USHORT nColumnId ) const void DataBrowser::Resize() { - BOOL bLastUpdateMode = GetUpdateMode(); - SetUpdateMode( FALSE ); + sal_Bool bLastUpdateMode = GetUpdateMode(); + SetUpdateMode( sal_False ); ::svt::EditBrowseBox::Resize(); ImplAdjustHeaderControls(); @@ -848,6 +866,9 @@ void DataBrowser::SetDataFromModel( new NumberFormatterWrapper( Reference< util::XNumberFormatsSupplier >( m_xChartDoc, uno::UNO_QUERY ))); + if( m_spNumberFormatterWrapper.get() ) + m_aNumberEditField.SetFormatter( m_spNumberFormatterWrapper->getSvNumberFormatter() ); + RenewTable(); const sal_Int32 nColCnt = m_apDataBrowserModel->getColumnCount(); @@ -1115,6 +1136,22 @@ sal_uInt32 DataBrowser::GetNumberFormatKey( sal_Int32 nRow, sal_uInt16 nCol ) co return m_apDataBrowserModel->getNumberFormatKey( lcl_getColumnInData( nCol ), lcl_getRowInData( nRow )); } +bool DataBrowser::isDateString( rtl::OUString aInputString, double& fOutDateValue ) +{ + sal_uInt32 nNumberFormat=0; + SvNumberFormatter* pSvNumberFormatter = m_spNumberFormatterWrapper.get() ? m_spNumberFormatterWrapper->getSvNumberFormatter() : 0; + if( aInputString.getLength() > 0 && pSvNumberFormatter && pSvNumberFormatter->IsNumberFormat( aInputString, nNumberFormat, fOutDateValue ) ) + { + Reference< util::XNumberFormatsSupplier > xNumberFormatsSupplier( m_xChartDoc, uno::UNO_QUERY ); + Reference< util::XNumberFormats > xNumberFormats; + if( xNumberFormatsSupplier.is() ) + xNumberFormats = Reference< util::XNumberFormats >( xNumberFormatsSupplier->getNumberFormats() ); + if( DiagramHelper::isDateNumberFormat( nNumberFormat, xNumberFormats ) ) + return true; + } + return false; +} + sal_Bool DataBrowser::SaveModified() { if( ! IsModified() ) @@ -1127,6 +1164,7 @@ sal_Bool DataBrowser::SaveModified() DBG_ASSERT( nRow >= 0 || nCol >= 0, "This cell should not be modified!" ); + SvNumberFormatter* pSvNumberFormatter = m_spNumberFormatterWrapper.get() ? m_spNumberFormatterWrapper->getSvNumberFormatter() : 0; switch( m_apDataBrowserModel->getCellType( nCol, nRow )) { case DataBrowserModel::NUMBER: @@ -1136,11 +1174,8 @@ sal_Bool DataBrowser::SaveModified() String aText( m_aNumberEditField.GetText()); // an empty string is valid, if no numberformatter exists, all // values are treated as valid - if( aText.Len() > 0 && - m_spNumberFormatterWrapper.get() && - m_spNumberFormatterWrapper->getSvNumberFormatter() && - ! m_spNumberFormatterWrapper->getSvNumberFormatter()->IsNumberFormat( - aText, nDummy, fDummy )) + if( aText.Len() > 0 && pSvNumberFormatter && + ! pSvNumberFormatter->IsNumberFormat( aText, nDummy, fDummy ) ) { bChangeValid = sal_False; } @@ -1151,6 +1186,17 @@ sal_Bool DataBrowser::SaveModified() } } break; + case DataBrowserModel::TEXTORDATE: + { + OUString aText( m_aTextEditField.GetText() ); + double fDateValue=0.0; + bChangeValid = sal_False; + if( isDateString( aText, fDateValue ) ) + bChangeValid = m_apDataBrowserModel->setCellAny( nCol, nRow, uno::makeAny( fDateValue ) ); + if(!bChangeValid) + bChangeValid = m_apDataBrowserModel->setCellAny( nCol, nRow, uno::makeAny( aText ) ); + } + break; case DataBrowserModel::TEXT: { OUString aText( m_aTextEditField.GetText()); @@ -1191,10 +1237,10 @@ sal_Int16 DataBrowser::GetFirstVisibleColumNumber() const return GetFirstVisibleColNumber(); } -void DataBrowser::ColumnResized( USHORT nColId ) +void DataBrowser::ColumnResized( sal_uInt16 nColId ) { - BOOL bLastUpdateMode = GetUpdateMode(); - SetUpdateMode( FALSE ); + sal_Bool bLastUpdateMode = GetUpdateMode(); + SetUpdateMode( sal_False ); EditBrowseBox::ColumnResized( nColId ); ImplAdjustHeaderControls(); @@ -1203,8 +1249,8 @@ void DataBrowser::ColumnResized( USHORT nColId ) void DataBrowser::EndScroll() { - BOOL bLastUpdateMode = GetUpdateMode(); - SetUpdateMode( FALSE ); + sal_Bool bLastUpdateMode = GetUpdateMode(); + SetUpdateMode( sal_False ); EditBrowseBox::EndScroll(); RenewSeriesHeaders(); @@ -1331,8 +1377,8 @@ IMPL_LINK( DataBrowser, SeriesHeaderChanged, impl::SeriesHeaderEdit*, pEdit ) sal_Int32 DataBrowser::GetTotalWidth() const { - ULONG nWidth = 0; - for ( USHORT nCol = 0; nCol < ColCount(); ++nCol ) + sal_uLong nWidth = 0; + for ( sal_uInt16 nCol = 0; nCol < ColCount(); ++nCol ) nWidth += GetColumnWidth( nCol ); return static_cast< sal_Int32 >( nWidth ); } |