diff options
author | Ingrid Halama [iha] <Ingrid.Halama@oracle.com> | 2011-01-14 18:11:00 +0100 |
---|---|---|
committer | Ingrid Halama [iha] <Ingrid.Halama@oracle.com> | 2011-01-14 18:11:00 +0100 |
commit | dbf69a6612a5471d7ae23b1bf41afd1e9fec23a2 (patch) | |
tree | 9586af3b6af4e1d327004fa534a2dfbb2dd6cf2d /chart2/source/controller/dialogs | |
parent | bb15dfd763af19c547a27c40882d9cdf1477f375 (diff) |
chart46: #i25706# implement date axis - #i116467# change behaviour of own data table
Diffstat (limited to 'chart2/source/controller/dialogs')
12 files changed, 84 insertions, 114 deletions
diff --git a/chart2/source/controller/dialogs/DataBrowser.cxx b/chart2/source/controller/dialogs/DataBrowser.cxx index a05b3171ccbb..550aee7132d9 100644 --- a/chart2/source/controller/dialogs/DataBrowser.cxx +++ b/chart2/source/controller/dialogs/DataBrowser.cxx @@ -47,7 +47,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> @@ -517,19 +518,6 @@ DataBrowser::~DataBrowser() { } -bool DataBrowser::HasDateCategories() const -{ - if( m_apDataBrowserModel.get() ) - return m_apDataBrowserModel->hasDateCategories(); - return false; -} - -bool DataBrowser::MayToggleDateCategories() const -{ - return ! IsReadOnly() - && DiagramHelper::mayToggleDateCategories( m_xChartDoc ); -} - bool DataBrowser::MayInsertRow() const { return ! IsReadOnly() @@ -710,6 +698,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 ); @@ -1009,19 +1014,6 @@ void DataBrowser::SwapRow() } } -void DataBrowser::ToggleDateCategories() -{ - if( m_apDataBrowserModel.get() ) - { - // save changes made to edit-field - if( IsModified() ) - SaveModified(); - - m_apDataBrowserModel->toggleDateCategories(); - RenewTable(); - } -} - void DataBrowser::SetCursorMovedHdl( const Link& rLink ) { m_aCursorMovedHdlLink = rLink; @@ -1164,6 +1156,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() ) @@ -1176,6 +1184,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: @@ -1185,11 +1194,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; } @@ -1200,6 +1206,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()); diff --git a/chart2/source/controller/dialogs/DataBrowser.hxx b/chart2/source/controller/dialogs/DataBrowser.hxx index 7a7cd120fb5f..b5cd2a731f7b 100644 --- a/chart2/source/controller/dialogs/DataBrowser.hxx +++ b/chart2/source/controller/dialogs/DataBrowser.hxx @@ -93,6 +93,8 @@ public: */ double GetCellNumber( long nRow, USHORT nColumnId ) const; + bool isDateString( rtl::OUString aInputString, double& fOutDateValue ); + // Window virtual void Resize(); @@ -113,9 +115,6 @@ public: // predicates to determine what actions are possible at the current cursor // position. This depends on the implementation of the according mutators // below. (They are used for enabling toolbar icons) - bool HasDateCategories() const; - bool MayToggleDateCategories() const; - bool MayInsertRow() const; bool MayInsertColumn() const; bool MayDeleteRow() const; @@ -134,8 +133,6 @@ public: using BrowseBox::RemoveColumn; using BrowseBox::MouseButtonDown; - void ToggleDateCategories(); - void SwapRow(); void SwapColumn(); diff --git a/chart2/source/controller/dialogs/DataBrowserModel.cxx b/chart2/source/controller/dialogs/DataBrowserModel.cxx index a075f6c3a5c6..23fda0f472af 100644 --- a/chart2/source/controller/dialogs/DataBrowserModel.cxx +++ b/chart2/source/controller/dialogs/DataBrowserModel.cxx @@ -569,12 +569,6 @@ void DataBrowserModel::removeDataPointForAllSeries( sal_Int32 nAtIndex ) // unlockControllers } -void DataBrowserModel::toggleDateCategories() -{ - DiagramHelper::toggleDateCategories( Reference<chart2::XChartDocument>( m_apDialogModel->getChartModel(), uno::UNO_QUERY ) ); - updateFromModel(); -} - DataBrowserModel::tDataHeader DataBrowserModel::getHeaderForSeries( const Reference< chart2::XDataSeries > & xSeries ) const { @@ -626,6 +620,26 @@ double DataBrowserModel::getCellNumber( sal_Int32 nAtColumn, sal_Int32 nAtRow ) return fResult; } +uno::Any DataBrowserModel::getCellAny( sal_Int32 nAtColumn, sal_Int32 nAtRow ) +{ + uno::Any aResult; + + tDataColumnVector::size_type nIndex( nAtColumn ); + if( nIndex < m_aColumns.size() && + m_aColumns[ nIndex ].m_xLabeledDataSequence.is()) + { + Reference< chart2::data::XDataSequence > xData( + m_aColumns[ nIndex ].m_xLabeledDataSequence->getValues() ); + if( xData.is() ) + { + Sequence< uno::Any > aValues( xData->getData()); + if( nAtRow < aValues.getLength()) + aResult = aValues[nAtRow]; + } + } + return aResult; +} + OUString DataBrowserModel::getCellText( sal_Int32 nAtColumn, sal_Int32 nAtRow ) { OUString aResult; @@ -762,12 +776,6 @@ sal_Int32 DataBrowserModel::getCategoryColumnCount() } return nLastTextColumnIndex+1; } -bool DataBrowserModel::hasDateCategories() const -{ - if( NUMBER == getCellType( 0, 0 ) ) - return true; - return false; -} const DataBrowserModel::tDataHeaderVector& DataBrowserModel::getDataHeaders() const { @@ -784,10 +792,6 @@ void DataBrowserModel::updateFromModel() Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram( m_xChartDocument )); if( !xDiagram.is()) return; - Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( xDiagram, uno::UNO_QUERY ); - if( !xCooSysCnt.is()) - return; - Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq( xCooSysCnt->getCoordinateSystems()); // set template at DialogModel uno::Reference< lang::XMultiServiceFactory > xFact( m_xChartDocument->getChartTypeManager(), uno::UNO_QUERY ); @@ -801,22 +805,7 @@ void DataBrowserModel::updateFromModel() if( lcl_ShowCategories( xDiagram )) { Reference< frame::XModel > xChartModel( m_xChartDocument, uno::UNO_QUERY ); - Reference< chart2::XCoordinateSystem > xCooSys( ChartModelHelper::getFirstCoordinateSystem( xChartModel ) ); - ExplicitCategoriesProvider aExplicitCategoriesProvider( xCooSys, xChartModel ); - bool bIsDateAxis = false; - if( xCooSys.is() ) - { - Reference< chart2::XAxis > xAxis( xCooSys->getAxisByDimension(0,0) ); - if( xAxis.is() ) - { - chart2::ScaleData aScale( xAxis->getScaleData() ); - bIsDateAxis = (aScale.AxisType == chart2::AxisType::DATE); - } - } - - sal_Int32 nDateCategoriesNumberFormat = 0; - if( bIsDateAxis && aCooSysSeq.getLength() ) - nDateCategoriesNumberFormat = DataSeriesHelper::getNumberFormatKeyFromAxis( 0, aCooSysSeq[0], 0, 0 ); + ExplicitCategoriesProvider aExplicitCategoriesProvider( ChartModelHelper::getFirstCoordinateSystem(xChartModel), xChartModel ); const Sequence< Reference< chart2::data::XLabeledDataSequence> >& rSplitCategoriesList( aExplicitCategoriesProvider.getSplitCategoriesList() ); sal_Int32 nLevelCount = rSplitCategoriesList.getLength(); @@ -830,24 +819,18 @@ void DataBrowserModel::updateFromModel() aCategories.m_xLabeledDataSequence.set( xCategories ); if( lcl_ShowCategoriesAsDataLabel( xDiagram )) aCategories.m_aUIRoleName = DialogModel::GetRoleDataLabel(); - else if( bIsDateAxis ) - aCategories.m_aUIRoleName = DialogModel::GetRoleDates(); else aCategories.m_aUIRoleName = lcl_getUIRoleName( xCategories ); - if( bIsDateAxis ) - { - aCategories.m_eCellType = NUMBER; - aCategories.m_nNumberFormatKey = nDateCategoriesNumberFormat; - } - else - { - aCategories.m_eCellType = TEXT; - } + aCategories.m_eCellType = TEXTORDATE; m_aColumns.push_back( aCategories ); ++nHeaderStart; } } + Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( xDiagram, uno::UNO_QUERY ); + if( !xCooSysCnt.is()) + return; + Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq( xCooSysCnt->getCoordinateSystems()); for( sal_Int32 nCooSysIdx=0; nCooSysIdx<aCooSysSeq.getLength(); ++nCooSysIdx ) { Reference< chart2::XChartTypeContainer > xCTCnt( aCooSysSeq[nCooSysIdx], uno::UNO_QUERY_THROW ); diff --git a/chart2/source/controller/dialogs/DataBrowserModel.hxx b/chart2/source/controller/dialogs/DataBrowserModel.hxx index d6c82a2f15ea..bde29f1771e4 100644 --- a/chart2/source/controller/dialogs/DataBrowserModel.hxx +++ b/chart2/source/controller/dialogs/DataBrowserModel.hxx @@ -78,18 +78,18 @@ public: void insertDataPointForAllSeries( sal_Int32 nAfterIndex ); void removeDataPointForAllSeries( sal_Int32 nAtIndex ); - void toggleDateCategories(); - enum eCellType { NUMBER, - TEXT + TEXT, + TEXTORDATE }; eCellType getCellType( sal_Int32 nAtColumn, sal_Int32 nAtRow ) const; /// If getCellType( nAtColumn, nAtRow ) returns TEXT, the result will be Nan double getCellNumber( sal_Int32 nAtColumn, sal_Int32 nAtRow ); ::rtl::OUString getCellText( sal_Int32 nAtColumn, sal_Int32 nAtRow ); + ::com::sun::star::uno::Any getCellAny( sal_Int32 nAtColumn, sal_Int32 nAtRow ); sal_uInt32 getNumberFormatKey( sal_Int32 nAtColumn, sal_Int32 nAtRow ); /// returns </TRUE> if the number could successfully be set at the given position @@ -105,8 +105,6 @@ public: ::rtl::OUString getRoleOfColumn( sal_Int32 nColumnIndex ) const; bool isCategoriesColumn( sal_Int32 nColumnIndex ) const; - bool hasDateCategories() const; - struct tDataHeader { ::com::sun::star::uno::Reference< diff --git a/chart2/source/controller/dialogs/DialogModel.cxx b/chart2/source/controller/dialogs/DialogModel.cxx index 00b25fb701fb..49e28e304975 100644 --- a/chart2/source/controller/dialogs/DialogModel.cxx +++ b/chart2/source/controller/dialogs/DialogModel.cxx @@ -737,12 +737,6 @@ OUString DialogModel::GetRoleDataLabel() } // static -OUString DialogModel::GetRoleDates() -{ - return OUString( String( ::chart::SchResId( STR_DATA_DATE_CATEGORIES ))); -} - -// static sal_Int32 DialogModel::GetRoleIndexForSorting( const ::rtl::OUString & rInternalRoleString ) { diff --git a/chart2/source/controller/dialogs/DialogModel.hxx b/chart2/source/controller/dialogs/DialogModel.hxx index 25bbc2669a9b..dcca6c716b8d 100644 --- a/chart2/source/controller/dialogs/DialogModel.hxx +++ b/chart2/source/controller/dialogs/DialogModel.hxx @@ -152,7 +152,6 @@ public: static ::rtl::OUString ConvertRoleFromInternalToUI( const ::rtl::OUString & rRoleString ); static ::rtl::OUString GetRoleDataLabel(); - static ::rtl::OUString GetRoleDates(); // pass a role string (not translated) and get an index that serves for // relative ordering, to get e.g. x-values and y-values in the right order diff --git a/chart2/source/controller/dialogs/ObjectNameProvider.cxx b/chart2/source/controller/dialogs/ObjectNameProvider.cxx index 0836ab9ca93a..81ec9c6c2ca7 100644 --- a/chart2/source/controller/dialogs/ObjectNameProvider.cxx +++ b/chart2/source/controller/dialogs/ObjectNameProvider.cxx @@ -40,7 +40,7 @@ #include "AxisIndexDefines.hxx" #include "ExplicitCategoriesProvider.hxx" #include "CommonConverters.hxx" -#include "chartview/NumberFormatterWrapper.hxx" +#include "NumberFormatterWrapper.hxx" #include "RegressionCurveHelper.hxx" #include <rtl/math.hxx> #include <tools/debug.hxx> diff --git a/chart2/source/controller/dialogs/Strings.src b/chart2/source/controller/dialogs/Strings.src index b25c99454cef..4b4cec65426e 100644 --- a/chart2/source/controller/dialogs/Strings.src +++ b/chart2/source/controller/dialogs/Strings.src @@ -548,10 +548,6 @@ String STR_DATA_ROLE_CATEGORIES { Text [ en-US ] = "Categories"; }; -String STR_DATA_DATE_CATEGORIES -{ - Text [ en-US ] = "Dates"; -}; String STR_DATA_UNNAMED_SERIES { diff --git a/chart2/source/controller/dialogs/dlg_DataEditor.cxx b/chart2/source/controller/dialogs/dlg_DataEditor.cxx index 3f073136ef67..f1d441921a6a 100644 --- a/chart2/source/controller/dialogs/dlg_DataEditor.cxx +++ b/chart2/source/controller/dialogs/dlg_DataEditor.cxx @@ -160,9 +160,6 @@ IMPL_LINK( DataEditor, ToolboxHdl, void *, EMPTYARG ) case TBI_DATA_SWAP_ROW : m_apBrwData->SwapRow (); break; - case TBI_DATA_TOGGLE_DATE_CATEGORIES: - m_apBrwData->ToggleDateCategories (); - break; } return 0; @@ -178,15 +175,13 @@ IMPL_LINK( DataEditor, BrowserCursorMovedHdl, void *, EMPTYARG ) m_aTbxData.EnableItem( TBI_DATA_INSERT_ROW, bIsDataValid && m_apBrwData->MayInsertRow() ); m_aTbxData.EnableItem( TBI_DATA_INSERT_COL, bIsDataValid && m_apBrwData->MayInsertColumn() ); - m_aTbxData.EnableItem( TBI_DATA_INSERT_TEXT_COL, bIsDataValid && m_apBrwData->MayInsertColumn() && !m_apBrwData->HasDateCategories() ); + m_aTbxData.EnableItem( TBI_DATA_INSERT_TEXT_COL, bIsDataValid && m_apBrwData->MayInsertColumn() ); m_aTbxData.EnableItem( TBI_DATA_DELETE_ROW, m_apBrwData->MayDeleteRow() ); m_aTbxData.EnableItem( TBI_DATA_DELETE_COL, m_apBrwData->MayDeleteColumn() ); m_aTbxData.EnableItem( TBI_DATA_SWAP_COL, bIsDataValid && m_apBrwData->MaySwapColumns() ); m_aTbxData.EnableItem( TBI_DATA_SWAP_ROW, bIsDataValid && m_apBrwData->MaySwapRows() ); - m_aTbxData.EnableItem( TBI_DATA_TOGGLE_DATE_CATEGORIES, bIsDataValid && m_apBrwData->MayToggleDateCategories() ); - return 0; } @@ -203,7 +198,6 @@ void DataEditor::SetReadOnly( bool bReadOnly ) m_aTbxData.EnableItem( TBI_DATA_DELETE_COL, FALSE ); m_aTbxData.EnableItem( TBI_DATA_SWAP_COL, FALSE ); m_aTbxData.EnableItem( TBI_DATA_SWAP_ROW, FALSE ); - m_aTbxData.EnableItem( TBI_DATA_TOGGLE_DATE_CATEGORIES, FALSE ); } m_apBrwData->SetReadOnly( m_bReadOnly ); diff --git a/chart2/source/controller/dialogs/dlg_DataEditor.hrc b/chart2/source/controller/dialogs/dlg_DataEditor.hrc index 794beb40abd3..d2675c5bb29e 100644 --- a/chart2/source/controller/dialogs/dlg_DataEditor.hrc +++ b/chart2/source/controller/dialogs/dlg_DataEditor.hrc @@ -41,7 +41,6 @@ #define TBI_DATA_SWAP_COL 5 #define TBI_DATA_SWAP_ROW 6 #define TBI_DATA_INSERT_TEXT_COL 7 -#define TBI_DATA_TOGGLE_DATE_CATEGORIES 8 // image lists (normal and high-contrast) for toolbox #define IL_DIAGRAM_DATA 1 diff --git a/chart2/source/controller/dialogs/dlg_DataEditor.src b/chart2/source/controller/dialogs/dlg_DataEditor.src index a83666553155..02ccc98b7a82 100644 --- a/chart2/source/controller/dialogs/dlg_DataEditor.src +++ b/chart2/source/controller/dialogs/dlg_DataEditor.src @@ -116,12 +116,6 @@ ModalDialog DLG_DIAGRAM_DATA { Type = TOOLBOXITEM_SEPARATOR ; }; - ToolBoxItem - { - HelpID = HID_SCH_TBI_DATA_TOGGLE_DATE_CATEGORIES ; - Identifier = TBI_DATA_TOGGLE_DATE_CATEGORIES ; - Text [ en-US ] = "Categories: Date/Text" ; - }; }; }; @@ -135,9 +129,8 @@ ModalDialog DLG_DIAGRAM_DATA TBI_DATA_DELETE_COL; \ TBI_DATA_SWAP_COL; \ TBI_DATA_SWAP_ROW; \ - TBI_DATA_TOGGLE_DATE_CATEGORIES; \ }; \ - IdCount = { 8; } + IdCount = { 7; } ImageList IL_DIAGRAM_DATA { diff --git a/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx b/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx index 5b3b96c705b3..431616714c00 100644 --- a/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx +++ b/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx @@ -56,7 +56,7 @@ #include "ChartTypeHelper.hxx" #include "ObjectNameProvider.hxx" #include "DiagramHelper.hxx" -#include "chartview/NumberFormatterWrapper.hxx" +#include "NumberFormatterWrapper.hxx" #include "AxisIndexDefines.hxx" #include "AxisHelper.hxx" |