diff options
Diffstat (limited to 'chart2')
34 files changed, 417 insertions, 455 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" diff --git a/chart2/source/controller/inc/DataPointItemConverter.hxx b/chart2/source/controller/inc/DataPointItemConverter.hxx index d738cf8f6245..c5072e26f648 100644 --- a/chart2/source/controller/inc/DataPointItemConverter.hxx +++ b/chart2/source/controller/inc/DataPointItemConverter.hxx @@ -29,7 +29,7 @@ #include "ItemConverter.hxx" #include "GraphicPropertyItemConverter.hxx" -#include "chartview/NumberFormatterWrapper.hxx" +#include "NumberFormatterWrapper.hxx" #include <com/sun/star/chart2/XDataSeries.hpp> #include <com/sun/star/awt/Size.hpp> diff --git a/chart2/source/controller/inc/ErrorBarItemConverter.hxx b/chart2/source/controller/inc/ErrorBarItemConverter.hxx index 9dffde68cd5b..484458a63a84 100755 --- a/chart2/source/controller/inc/ErrorBarItemConverter.hxx +++ b/chart2/source/controller/inc/ErrorBarItemConverter.hxx @@ -29,7 +29,7 @@ #include "ItemConverter.hxx" #include "GraphicPropertyItemConverter.hxx" -#include "chartview/NumberFormatterWrapper.hxx" +#include "NumberFormatterWrapper.hxx" #include <com/sun/star/frame/XModel.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> diff --git a/chart2/source/controller/inc/HelpIds.hrc b/chart2/source/controller/inc/HelpIds.hrc index 7d14eebabd78..5e20b7980c8b 100644 --- a/chart2/source/controller/inc/HelpIds.hrc +++ b/chart2/source/controller/inc/HelpIds.hrc @@ -52,7 +52,6 @@ #define HID_SCH_TBI_DATA_SWAP_COL "CHART2_HID_SCH_TBI_DATA_SWAP_COL" #define HID_SCH_TBI_DATA_SWAP_ROW "CHART2_HID_SCH_TBI_DATA_SWAP_ROW" #define HID_SCH_TBI_DATA_INSERT_TEXT_COL "CHART2_HID_SCH_TBI_DATA_INSERT_TEXT_COL" -#define HID_SCH_TBI_DATA_TOGGLE_DATE_CATEGORIES "CHART2_HID_SCH_TBI_DATA_TOGGLE_DATE_CATEGORIES" #define HID_SCH_TBX_DATA "CHART2_HID_SCH_TBX_DATA" #define HID_SCH_ALIGNMENT_CTR_DIAL "CHART2_HID_SCH_ALIGNMENT_CTR_DIAL" diff --git a/chart2/source/controller/inc/StatisticsItemConverter.hxx b/chart2/source/controller/inc/StatisticsItemConverter.hxx index cb4227185093..cb706e92cc97 100644 --- a/chart2/source/controller/inc/StatisticsItemConverter.hxx +++ b/chart2/source/controller/inc/StatisticsItemConverter.hxx @@ -31,7 +31,7 @@ #include "ItemConverter.hxx" #include "GraphicPropertyItemConverter.hxx" -#include "chartview/NumberFormatterWrapper.hxx" +#include "NumberFormatterWrapper.hxx" #include <vector> diff --git a/chart2/source/controller/main/ChartController_Insert.cxx b/chart2/source/controller/main/ChartController_Insert.cxx index 0a7a4057ef9a..14a1421f913a 100644 --- a/chart2/source/controller/main/ChartController_Insert.cxx +++ b/chart2/source/controller/main/ChartController_Insert.cxx @@ -44,7 +44,7 @@ #include "DiagramHelper.hxx" #include "macros.hxx" #include "chartview/DrawModelWrapper.hxx" -#include "chartview/NumberFormatterWrapper.hxx" +#include "NumberFormatterWrapper.hxx" #include "ViewElementListProvider.hxx" #include "MultipleChartConverters.hxx" #include "ControllerLockGuard.hxx" diff --git a/chart2/source/inc/AxisHelper.hxx b/chart2/source/inc/AxisHelper.hxx index eaaee11abe10..33430807c3e2 100644 --- a/chart2/source/inc/AxisHelper.hxx +++ b/chart2/source/inc/AxisHelper.hxx @@ -34,6 +34,7 @@ #include <com/sun/star/chart2/XCoordinateSystem.hpp> #include <com/sun/star/chart2/XDiagram.hpp> #include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/util/XNumberFormatsSupplier.hpp> #include <vector> @@ -62,6 +63,12 @@ public: static void checkDateAxis( ::com::sun::star::chart2::ScaleData& rScale, ExplicitCategoriesProvider* pExplicitCategoriesProvider, bool bChartTypeAllowsDateAxis ); static ::com::sun::star::chart2::ScaleData getDateCheckedScale( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis >& xAxis, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xChartModel ); + static sal_Int32 getExplicitNumberFormatKeyForAxis( + const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis >& xAxis + , const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XCoordinateSystem >& xCorrespondingCoordinateSystem + , const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier >& xNumberFormatsSupplier + , bool bSearchForParallelAxisIfNothingIsFound ); + static ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis > createAxis( sal_Int32 nDimensionIndex, bool bMainAxis diff --git a/chart2/source/inc/DiagramHelper.hxx b/chart2/source/inc/DiagramHelper.hxx index 858454497db5..e4fc0ea2ecfc 100644 --- a/chart2/source/inc/DiagramHelper.hxx +++ b/chart2/source/inc/DiagramHelper.hxx @@ -38,6 +38,8 @@ #include <com/sun/star/chart2/XChartDocument.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/util/XNumberFormats.hpp> +#include <com/sun/star/util/XNumberFormatsSupplier.hpp> #include <utility> #include <vector> @@ -240,14 +242,6 @@ public: const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XCoordinateSystem > & xCooSys ); - static bool mayToggleDateCategories( - const ::com::sun::star::uno::Reference< - ::com::sun::star::chart2::XChartDocument > & xChartDoc ); - - static void toggleDateCategories( - const ::com::sun::star::uno::Reference< - ::com::sun::star::chart2::XChartDocument > & xChartDoc ); - static void switchToDateCategories( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument > & xChartDoc ); @@ -256,6 +250,13 @@ public: const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument > & xChartDoc ); + static bool isSupportingDateAxis( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram >& xDiagram ); + static bool isDateNumberFormat( sal_Int32 nNumberFormat, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormats >& xNumberFormats ); + static sal_Int32 getDateNumberFormat( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier >& xNumberFormatsSupplier ); + + static sal_Int32 getPercentNumberFormat( const ::com::sun::star::uno::Reference< + ::com::sun::star::util::XNumberFormatsSupplier >& xNumberFormatsSupplier ); + static ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartType > getChartTypeByIndex( const ::com::sun::star::uno::Reference< diff --git a/chart2/source/inc/ExplicitCategoriesProvider.hxx b/chart2/source/inc/ExplicitCategoriesProvider.hxx index dfa6379a42a1..f8d17c277036 100644 --- a/chart2/source/inc/ExplicitCategoriesProvider.hxx +++ b/chart2/source/inc/ExplicitCategoriesProvider.hxx @@ -104,6 +104,10 @@ public: static ::com::sun::star::uno::Sequence< ::rtl::OUString > getExplicitSimpleCategories( const SplitCategoriesProvider& rSplitCategoriesProvider ); + static void convertCategoryAnysToText( ::com::sun::star::uno::Sequence< rtl::OUString >& rOutTexts + , const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& rInAnys + , ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > xChartModel ); + bool hasComplexCategories() const; sal_Int32 getCategoryLevelCount() const; @@ -122,6 +126,7 @@ private: //member ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XLabeledDataSequence> m_xOriginalCategories; + bool m_bIsExplicitCategoriesInited; ::com::sun::star::uno::Sequence< ::rtl::OUString > m_aExplicitCategories; ::std::vector< ::std::vector< ComplexCategory > > m_aComplexCats; ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< diff --git a/chart2/source/inc/chartview/NumberFormatterWrapper.hxx b/chart2/source/inc/NumberFormatterWrapper.hxx index 5eb2160a8765..964fd3f79f06 100644..100755 --- a/chart2/source/inc/chartview/NumberFormatterWrapper.hxx +++ b/chart2/source/inc/NumberFormatterWrapper.hxx @@ -24,12 +24,12 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -#ifndef _CHART2_VIEW_NUMBERFORMATTERWRAPPER_HXX -#define _CHART2_VIEW_NUMBERFORMATTERWRAPPER_HXX +#ifndef _CHART2_TOOLS_NUMBERFORMATTERWRAPPER_HXX +#define _CHART2_TOOLS_NUMBERFORMATTERWRAPPER_HXX +#include "charttoolsdllapi.hxx" #include <svl/zforlist.hxx> #include <com/sun/star/util/XNumberFormatsSupplier.hpp> -#include "chartviewdllapi.hxx" //............................................................................. namespace chart @@ -41,7 +41,7 @@ namespace chart */ class FixedNumberFormatter; -class OOO_DLLPUBLIC_CHARTVIEW NumberFormatterWrapper +class OOO_DLLPUBLIC_CHARTTOOLS NumberFormatterWrapper { public: NumberFormatterWrapper( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier >& xSupplier ); diff --git a/chart2/source/inc/Strings.hrc b/chart2/source/inc/Strings.hrc index d263881a0905..fa7917ff7c5a 100644 --- a/chart2/source/inc/Strings.hrc +++ b/chart2/source/inc/Strings.hrc @@ -30,7 +30,7 @@ // this includes no link dependency #include <svl/solar.hrc> -//next free is 294 +//next free is 293 //#define RID_APP_START 30000 ////#define STR_NULL (RID_APP_START + 1) @@ -194,8 +194,6 @@ #define STR_DATA_SELECT_RANGE_FOR_POSITIVE_ERRORBARS (RID_APP_START + 21) #define STR_DATA_SELECT_RANGE_FOR_NEGATIVE_ERRORBARS (RID_APP_START + 267) -#define STR_DATA_DATE_CATEGORIES (RID_APP_START + 293) - //----------------------------------------------------------------------------- //chart objects //e.g. used as titles for insert dialogs and object properties dialog diff --git a/chart2/source/inc/chartview/ExplicitValueProvider.hxx b/chart2/source/inc/chartview/ExplicitValueProvider.hxx index 231b1acef6db..6e2fef8feb36 100644 --- a/chart2/source/inc/chartview/ExplicitValueProvider.hxx +++ b/chart2/source/inc/chartview/ExplicitValueProvider.hxx @@ -99,9 +99,6 @@ public: , const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XCoordinateSystem > & xCorrespondingCoordinateSystem , const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier >& xNumberFormatsSupplier ); - SAL_DLLPRIVATE static sal_Int32 getPercentNumberFormat( const ::com::sun::star::uno::Reference< - ::com::sun::star::util::XNumberFormatsSupplier >& xNumberFormatsSupplier ); - static sal_Int32 getExplicitNumberFormatKeyForDataLabel( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xSeriesOrPointProp , const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries >& xSeries diff --git a/chart2/source/tools/AxisHelper.cxx b/chart2/source/tools/AxisHelper.cxx index ec437cf7fd34..75bde77c801f 100644 --- a/chart2/source/tools/AxisHelper.cxx +++ b/chart2/source/tools/AxisHelper.cxx @@ -148,6 +148,148 @@ void AxisHelper::checkDateAxis( chart2::ScaleData& rScale, ExplicitCategoriesPro } } +sal_Int32 AxisHelper::getExplicitNumberFormatKeyForAxis( + const Reference< chart2::XAxis >& xAxis + , const Reference< chart2::XCoordinateSystem > & xCorrespondingCoordinateSystem + , const Reference< util::XNumberFormatsSupplier >& xNumberFormatsSupplier + , bool bSearchForParallelAxisIfNothingIsFound ) +{ + sal_Int32 nNumberFormatKey(0); + Reference< beans::XPropertySet > xProp( xAxis, uno::UNO_QUERY ); + if( xProp.is() && !( xProp->getPropertyValue( C2U( "NumberFormat" ) ) >>= nNumberFormatKey ) ) + { + bool bFormatSet = false; + //check wether we have a percent scale -> use percent format + if( xNumberFormatsSupplier.is() ) + { + ScaleData aData = AxisHelper::getDateCheckedScale( xAxis, Reference< frame::XModel >( xNumberFormatsSupplier, uno::UNO_QUERY ) ); + if( aData.AxisType==AxisType::PERCENT ) + { + sal_Int32 nPercentFormat = DiagramHelper::getPercentNumberFormat( xNumberFormatsSupplier ); + if( nPercentFormat != -1 ) + { + nNumberFormatKey = nPercentFormat; + bFormatSet = true; + } + } + else if( aData.AxisType==AxisType::DATE ) + { + if( aData.Categories.is() ) + { + Reference< data::XDataSequence > xSeq( aData.Categories->getValues()); + Reference< chart2::XChartDocument > xChartDoc( xNumberFormatsSupplier, uno::UNO_QUERY ); + if( xSeq.is() && !( xChartDoc.is() && xChartDoc->hasInternalDataProvider()) ) + nNumberFormatKey = xSeq->getNumberFormatKeyByIndex( -1 ); + else + nNumberFormatKey = DiagramHelper::getDateNumberFormat( xNumberFormatsSupplier ); + bFormatSet = true; + } + } + } + + if( !bFormatSet ) + { + typedef ::std::map< sal_Int32, sal_Int32 > tNumberformatFrequency; + tNumberformatFrequency aKeyMap; + + bool bNumberFormatKeyFoundViaAttachedData = false; + sal_Int32 nAxisIndex = 0; + sal_Int32 nDimensionIndex = 1; + + try + { + Reference< XChartTypeContainer > xCTCnt( xCorrespondingCoordinateSystem, uno::UNO_QUERY_THROW ); + if( xCTCnt.is() ) + { + AxisHelper::getIndicesForAxis( xAxis, xCorrespondingCoordinateSystem, nDimensionIndex, nAxisIndex ); + ::rtl::OUString aRoleToMatch; + if( nDimensionIndex == 0 ) + aRoleToMatch = C2U("values-x"); + Sequence< Reference< XChartType > > aChartTypes( xCTCnt->getChartTypes()); + for( sal_Int32 nCTIdx=0; nCTIdx<aChartTypes.getLength(); ++nCTIdx ) + { + if( nDimensionIndex != 0 ) + aRoleToMatch = ChartTypeHelper::getRoleOfSequenceForYAxisNumberFormatDetection( aChartTypes[nCTIdx] ); + Reference< XDataSeriesContainer > xDSCnt( aChartTypes[nCTIdx], uno::UNO_QUERY_THROW ); + Sequence< Reference< XDataSeries > > aDataSeriesSeq( xDSCnt->getDataSeries()); + for( sal_Int32 nSeriesIdx=0; nSeriesIdx<aDataSeriesSeq.getLength(); ++nSeriesIdx ) + { + Reference< chart2::XDataSeries > xDataSeries(aDataSeriesSeq[nSeriesIdx]); + Reference< data::XDataSource > xSource( xDataSeries, uno::UNO_QUERY_THROW ); + + if( nDimensionIndex == 1 ) + { + //only take those series into accoutn that are attached to this axis + sal_Int32 nAttachedAxisIndex = DataSeriesHelper::getAttachedAxisIndex(xDataSeries); + if( nAttachedAxisIndex != nAxisIndex ) + continue; + } + + Reference< data::XLabeledDataSequence > xLabeledSeq( + DataSeriesHelper::getDataSequenceByRole( xSource, aRoleToMatch ) ); + + if( !xLabeledSeq.is() && nDimensionIndex==0 ) + { + ScaleData aData = xAxis->getScaleData(); + xLabeledSeq = aData.Categories; + } + + if( xLabeledSeq.is() ) + { + Reference< data::XDataSequence > xSeq( xLabeledSeq->getValues()); + if( xSeq.is() ) + { + sal_Int32 nKey = xSeq->getNumberFormatKeyByIndex( -1 ); + // initialize the value + if( aKeyMap.find( nKey ) == aKeyMap.end()) + aKeyMap[ nKey ] = 0; + // increase frequency + aKeyMap[ nKey ] = (aKeyMap[ nKey ] + 1); + } + } + } + } + } + } + catch( const uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } + + if( ! aKeyMap.empty()) + { + sal_Int32 nMaxFreq = 0; + // find most frequent key + for( tNumberformatFrequency::const_iterator aIt = aKeyMap.begin(); + aIt != aKeyMap.end(); ++aIt ) + { + OSL_TRACE( "NumberFormatKey %d appears %d times", (*aIt).first, (*aIt).second ); + // all values must at least be 1 + if( (*aIt).second > nMaxFreq ) + { + nNumberFormatKey = (*aIt).first; + bNumberFormatKeyFoundViaAttachedData = true; + nMaxFreq = (*aIt).second; + } + } + } + + if( bSearchForParallelAxisIfNothingIsFound ) + { + //no format is set to this axis and no data is set to this axis + //--> try to obtain the format from the parallel y-axis + if( !bNumberFormatKeyFoundViaAttachedData && nDimensionIndex == 1 ) + { + sal_Int32 nParallelAxisIndex = (nAxisIndex==1) ?0 :1; + Reference< XAxis > xParallelAxis( AxisHelper::getAxis( 1, nParallelAxisIndex, xCorrespondingCoordinateSystem ) ); + nNumberFormatKey = AxisHelper::getExplicitNumberFormatKeyForAxis( xParallelAxis, xCorrespondingCoordinateSystem, xNumberFormatsSupplier, false ); + } + } + } + } + return nNumberFormatKey; +} + //static Reference< XAxis > AxisHelper::createAxis( sal_Int32 nDimensionIndex diff --git a/chart2/source/tools/DiagramHelper.cxx b/chart2/source/tools/DiagramHelper.cxx index e9f060248afe..772994bf2498 100644 --- a/chart2/source/tools/DiagramHelper.cxx +++ b/chart2/source/tools/DiagramHelper.cxx @@ -1045,26 +1045,6 @@ Sequence< rtl::OUString > DiagramHelper::getExplicitSimpleCategories( return aRet; } -bool DiagramHelper::mayToggleDateCategories( const Reference< XChartDocument >& xChartDoc ) -{ - Reference< frame::XModel > xChartModel( xChartDoc, uno::UNO_QUERY ); - if(xChartModel.is()) - { - Reference< chart2::XCoordinateSystem > xCooSys( ChartModelHelper::getFirstCoordinateSystem( xChartModel ) ); - if( xCooSys.is() ) - { - Reference< XAxis > xAxis( xCooSys->getAxisByDimension(0,0) ); - if( xAxis.is() ) - { - ScaleData aScale( xAxis->getScaleData() ); - if( aScale.AxisType == chart2::AxisType::DATE || aScale.AxisType == chart2::AxisType::CATEGORY ) - return true; - } - } - } - return false; -} - namespace { void lcl_switchToDateCategories( const Reference< XChartDocument >& xChartDoc, const Reference< XAxis >& xAxis ) @@ -1194,35 +1174,62 @@ void DiagramHelper::switchToTextCategories( const Reference< XChartDocument >& x } } -void DiagramHelper::toggleDateCategories( const Reference< XChartDocument >& xChartDoc ) +bool DiagramHelper::isSupportingDateAxis( const Reference< chart2::XDiagram >& xDiagram ) { - Reference< frame::XModel > xChartModel( xChartDoc, uno::UNO_QUERY ); - if(xChartModel.is()) + return ::chart::ChartTypeHelper::isSupportingDateAxis( + DiagramHelper::getChartTypeByIndex( xDiagram, 0 ), DiagramHelper::getDimension( xDiagram ), 0 ); +} + +bool DiagramHelper::isDateNumberFormat( sal_Int32 nNumberFormat, const Reference< util::XNumberFormats >& xNumberFormats ) +{ + bool bIsDate = false; + if( !xNumberFormats.is() ) + return bIsDate; + + Reference< beans::XPropertySet > xKeyProps = xNumberFormats->getByKey( nNumberFormat ); + if( xKeyProps.is() ) { - ControllerLockGuard aCtrlLockGuard( xChartModel ); + sal_Int32 nType = util::NumberFormat::UNDEFINED; + xKeyProps->getPropertyValue( C2U("Type") ) >>= nType; + bIsDate = nType & util::NumberFormat::DATE; + } + return bIsDate; +} - Reference< chart2::XCoordinateSystem > xCooSys( ChartModelHelper::getFirstCoordinateSystem( xChartModel ) ); - if( xCooSys.is() ) +sal_Int32 DiagramHelper::getDateNumberFormat( const Reference< util::XNumberFormatsSupplier >& xNumberFormatsSupplier ) +{ + sal_Int32 nRet=-1; + Reference< util::XNumberFormats > xNumberFormats( xNumberFormatsSupplier->getNumberFormats() ); + if( xNumberFormats.is() ) + { + sal_Bool bCreate = sal_True; + const LocaleDataWrapper& rLocaleDataWrapper = Application::GetSettings().GetLocaleDataWrapper(); + Sequence<sal_Int32> aKeySeq = xNumberFormats->queryKeys( util::NumberFormat::DATE, + rLocaleDataWrapper.getLocale(), bCreate ); + if( aKeySeq.getLength() ) { - Reference< XAxis > xAxis( xCooSys->getAxisByDimension(0,0) ); - if( xAxis.is() ) - { - ScaleData aScale( xAxis->getScaleData() ); - if( aScale.AxisType == chart2::AxisType::DATE ) - { - lcl_switchToTextCategories( xChartDoc, xAxis ); - } - else if( aScale.AxisType == chart2::AxisType::CATEGORY ) - { - lcl_switchToDateCategories( xChartDoc, xAxis ); - } - else - { - DBG_ERROR("Cannot toggle Date Categories for this axis type"); - } - } + nRet = aKeySeq[0]; + } + } + return nRet; +} + +sal_Int32 DiagramHelper::getPercentNumberFormat( const Reference< util::XNumberFormatsSupplier >& xNumberFormatsSupplier ) +{ + sal_Int32 nRet=-1; + Reference< util::XNumberFormats > xNumberFormats( xNumberFormatsSupplier->getNumberFormats() ); + if( xNumberFormats.is() ) + { + sal_Bool bCreate = sal_True; + const LocaleDataWrapper& rLocaleDataWrapper = Application::GetSettings().GetLocaleDataWrapper(); + Sequence<sal_Int32> aKeySeq = xNumberFormats->queryKeys( util::NumberFormat::PERCENT, + rLocaleDataWrapper.getLocale(), bCreate ); + if( aKeySeq.getLength() ) + { + nRet = aKeySeq[0]; } } + return nRet; } // static diff --git a/chart2/source/tools/ExplicitCategoriesProvider.cxx b/chart2/source/tools/ExplicitCategoriesProvider.cxx index 1c52a3c3e622..ef2d6ac22bf2 100644 --- a/chart2/source/tools/ExplicitCategoriesProvider.cxx +++ b/chart2/source/tools/ExplicitCategoriesProvider.cxx @@ -37,6 +37,7 @@ #include "ChartModelHelper.hxx" #include "ContainerHelper.hxx" #include "macros.hxx" +#include "NumberFormatterWrapper.hxx" #include <com/sun/star/chart2/AxisType.hpp> #include <com/sun/star/util/NumberFormat.hpp> @@ -61,6 +62,7 @@ ExplicitCategoriesProvider::ExplicitCategoriesProvider( const Reference< chart2: , m_xCooSysModel( xCooSysModel ) , m_xChartModel( xChartModel ) , m_xOriginalCategories() + , m_bIsExplicitCategoriesInited(false) , m_bIsDateAxis(false) , m_bIsAutoDate(false) { @@ -188,30 +190,52 @@ std::vector<sal_Int32> lcl_getLimitingBorders( const std::vector< ComplexCategor return aLimitingBorders; } -uno::Sequence< rtl::OUString > lcl_DataToStringSequence( const uno::Reference< data::XDataSequence >& xDataSequence ) +void ExplicitCategoriesProvider::convertCategoryAnysToText( uno::Sequence< rtl::OUString >& rOutTexts, const uno::Sequence< uno::Any >& rInAnys, Reference< frame::XModel > xChartModel ) { - uno::Sequence< rtl::OUString > aStrings; + sal_Int32 nCount = rInAnys.getLength(); + if(!nCount) + return; + rOutTexts.realloc(nCount); + Reference< util::XNumberFormatsSupplier > xNumberFormatsSupplier( xChartModel, uno::UNO_QUERY ); + Reference< util::XNumberFormats > xNumberFormats; + if( xNumberFormatsSupplier.is() ) + xNumberFormats = Reference< util::XNumberFormats >( xNumberFormatsSupplier->getNumberFormats() ); + + sal_Int32 nAxisNumberFormat = 0; + Reference< XCoordinateSystem > xCooSysModel( ChartModelHelper::getFirstCoordinateSystem( xChartModel ) ); + if( xCooSysModel.is() ) + { + Reference< chart2::XAxis > xAxis( xCooSysModel->getAxisByDimension(0,0) ); + nAxisNumberFormat = AxisHelper::getExplicitNumberFormatKeyForAxis( + xAxis, xCooSysModel, xNumberFormatsSupplier, false ); + } - OSL_ASSERT( xDataSequence.is()); - if( !xDataSequence.is() ) - return aStrings; + sal_Int32 nLabelColor; + bool bColorChanged = false; + NumberFormatterWrapper aNumberFormatterWrapper( xNumberFormatsSupplier ); + SvNumberFormatter* pSvNumberFormatter = aNumberFormatterWrapper.getSvNumberFormatter(); - uno::Reference< data::XTextualDataSequence > xTextualDataSequence( xDataSequence, uno::UNO_QUERY ); - if( xTextualDataSequence.is() ) + for(sal_Int32 nN=0;nN<nCount;nN++) { - aStrings = xTextualDataSequence->getTextualData(); - } - else - { - uno::Sequence< uno::Any > aValues = xDataSequence->getData(); - aStrings.realloc(aValues.getLength()); - - for(sal_Int32 nN=aValues.getLength();nN--;) - aValues[nN] >>= aStrings[nN]; + rtl::OUString aText; + uno::Any aAny = rInAnys[nN]; + if( aAny.hasValue() ) + { + double fDouble; + if( aAny>>=fDouble ) + { + if( !::rtl::math::isNan(fDouble) ) + aText = aNumberFormatterWrapper.getFormattedString( + nAxisNumberFormat, fDouble, nLabelColor, bColorChanged ); + } + else + { + aAny>>=aText; + } + } + rOutTexts[nN] = aText; } - - return aStrings; } SplitCategoriesProvider::~SplitCategoriesProvider() @@ -222,9 +246,13 @@ class SplitCategoriesProvider_ForLabeledDataSequences : public SplitCategoriesPr { public: - explicit SplitCategoriesProvider_ForLabeledDataSequences( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< - ::com::sun::star::chart2::data::XLabeledDataSequence> >& rSplitCategoriesList ) + explicit SplitCategoriesProvider_ForLabeledDataSequences( + const ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::data::XLabeledDataSequence> >& rSplitCategoriesList + , const Reference< frame::XModel >& xChartModel ) : m_rSplitCategoriesList( rSplitCategoriesList ) + , m_xChartModel( xChartModel ) {} virtual ~SplitCategoriesProvider_ForLabeledDataSequences() {} @@ -235,6 +263,8 @@ public: private: const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XLabeledDataSequence> >& m_rSplitCategoriesList; + + Reference< frame::XModel > m_xChartModel; }; sal_Int32 SplitCategoriesProvider_ForLabeledDataSequences::getLevelCount() const @@ -246,7 +276,11 @@ uno::Sequence< rtl::OUString > SplitCategoriesProvider_ForLabeledDataSequences:: uno::Sequence< rtl::OUString > aRet; Reference< data::XLabeledDataSequence > xLabeledDataSequence( m_rSplitCategoriesList[nLevel] ); if( xLabeledDataSequence.is() ) - aRet = lcl_DataToStringSequence( xLabeledDataSequence->getValues() ); + { + uno::Reference< data::XDataSequence > xDataSequence( xLabeledDataSequence->getValues() ); + if( xDataSequence.is() ) + ExplicitCategoriesProvider::convertCategoryAnysToText( aRet, xDataSequence->getData(), m_xChartModel ); + } return aRet; } @@ -393,22 +427,6 @@ struct DatePlusIndexComparator } }; -bool lcl_isDateFormat( sal_Int32 nNumberFormat, const Reference< util::XNumberFormats >& xNumberFormats ) -{ - bool bIsDate = false; - if( !xNumberFormats.is() ) - return bIsDate; - - Reference< beans::XPropertySet > xKeyProps = xNumberFormats->getByKey( nNumberFormat ); - if( xKeyProps.is() ) - { - sal_Int32 nType = util::NumberFormat::UNDEFINED; - xKeyProps->getPropertyValue( C2U("Type") ) >>= nType; - bIsDate = nType & util::NumberFormat::DATE; - } - return bIsDate; -} - bool lcl_fillDateCategories( const uno::Reference< data::XDataSequence >& xDataSequence, std::vector< DatePlusIndex >& rDateCategories, bool bIsAutoDate, Reference< util::XNumberFormatsSupplier > xNumberFormatsSupplier ) { bool bOnlyDatesFound = true; @@ -424,8 +442,8 @@ bool lcl_fillDateCategories( const uno::Reference< data::XDataSequence >& xDataS xNumberFormats = Reference< util::XNumberFormats >( xNumberFormatsSupplier->getNumberFormats() ); bool bOwnData = false; - bool bOwnDataAndDateFormat = false; - sal_Int32 nAxisNumberFormat = 0; + bool bOwnDataAnddAxisHasAnyFormat = false; + bool bOwnDataAnddAxisHasDateFormat = false; Reference< chart2::XChartDocument > xChartDoc( xNumberFormatsSupplier, uno::UNO_QUERY ); Reference< XCoordinateSystem > xCooSysModel( ChartModelHelper::getFirstCoordinateSystem( Reference< frame::XModel >( xChartDoc, uno::UNO_QUERY ) ) ); if( xChartDoc.is() && xCooSysModel.is() ) @@ -434,8 +452,12 @@ bool lcl_fillDateCategories( const uno::Reference< data::XDataSequence >& xDataS { bOwnData = true; Reference< beans::XPropertySet > xAxisProps( xCooSysModel->getAxisByDimension(0,0), uno::UNO_QUERY ); + sal_Int32 nAxisNumberFormat = 0; if( xAxisProps.is() && (xAxisProps->getPropertyValue( C2U("NumberFormat") ) >>= nAxisNumberFormat) ) - bOwnDataAndDateFormat = lcl_isDateFormat( nAxisNumberFormat, xNumberFormats ); + { + bOwnDataAnddAxisHasAnyFormat = true; + bOwnDataAnddAxisHasDateFormat = DiagramHelper::isDateNumberFormat( nAxisNumberFormat, xNumberFormats ); + } } } @@ -445,9 +467,9 @@ bool lcl_fillDateCategories( const uno::Reference< data::XDataSequence >& xDataS if( bIsAutoDate ) { if( bOwnData ) - bIsDate = bOwnDataAndDateFormat; + bIsDate = bOwnDataAnddAxisHasAnyFormat ? bOwnDataAnddAxisHasDateFormat : true; else - bIsDate = lcl_isDateFormat( xDataSequence->getNumberFormatKeyByIndex( nN ), xNumberFormats ); + bIsDate = DiagramHelper::isDateNumberFormat( xDataSequence->getNumberFormatKeyByIndex( nN ), xNumberFormats ); } else bIsDate = true; @@ -488,7 +510,6 @@ void ExplicitCategoriesProvider::init() { if( m_bDirty ) { - m_aExplicitCategories.realloc(0); m_aComplexCats.clear();//not one per index m_aDateCategories.clear(); @@ -496,7 +517,6 @@ void ExplicitCategoriesProvider::init() { if( !hasComplexCategories() ) { - m_aExplicitCategories = DataSequenceToStringSequence(m_xOriginalCategories->getValues()); if(m_bIsDateAxis) { if( ChartTypeHelper::isSupportingDateAxis( AxisHelper::getChartTypeByIndex( m_xCooSysModel, 0 ), 2, 0 ) ) @@ -507,15 +527,11 @@ void ExplicitCategoriesProvider::init() } else { - m_aExplicitCategories = lcl_getExplicitSimpleCategories( - SplitCategoriesProvider_ForLabeledDataSequences( m_aSplitCategoriesList ), m_aComplexCats ); m_bIsDateAxis = false; } } else m_bIsDateAxis=false; - if(!m_aExplicitCategories.getLength()) - m_aExplicitCategories = DiagramHelper::generateAutomaticCategoriesFromCooSys( m_xCooSysModel ); m_bDirty = false; } } @@ -523,7 +539,28 @@ void ExplicitCategoriesProvider::init() Sequence< ::rtl::OUString > ExplicitCategoriesProvider::getSimpleCategories() { - init(); + if( !m_bIsExplicitCategoriesInited ) + { + init(); + m_aExplicitCategories.realloc(0); + if( m_xOriginalCategories.is() ) + { + if( !hasComplexCategories() ) + { + uno::Reference< data::XDataSequence > xDataSequence( m_xOriginalCategories->getValues() ); + if( xDataSequence.is() ) + ExplicitCategoriesProvider::convertCategoryAnysToText( m_aExplicitCategories, xDataSequence->getData(), m_xChartModel ); + } + else + { + m_aExplicitCategories = lcl_getExplicitSimpleCategories( + SplitCategoriesProvider_ForLabeledDataSequences( m_aSplitCategoriesList, m_xChartModel ), m_aComplexCats ); + } + } + if(!m_aExplicitCategories.getLength()) + m_aExplicitCategories = DiagramHelper::generateAutomaticCategoriesFromCooSys( m_xCooSysModel ); + m_bIsExplicitCategoriesInited = true; + } return m_aExplicitCategories; } diff --git a/chart2/source/tools/InternalDataProvider.cxx b/chart2/source/tools/InternalDataProvider.cxx index b3f3058d6f05..88de8c94e977 100644 --- a/chart2/source/tools/InternalDataProvider.cxx +++ b/chart2/source/tools/InternalDataProvider.cxx @@ -375,17 +375,9 @@ InternalDataProvider::InternalDataProvider( const Reference< chart2::XChartDocum if( !xLDS.is() ) continue; Sequence< uno::Any > aDataSeq; - Reference< chart2::data::XTextualDataSequence > xTextSeq( xLDS->getValues(), uno::UNO_QUERY ); - if( !bIsDateAxis && xTextSeq.is() ) - { - aDataSeq = lcl_StringToAnySequence( xTextSeq->getTextualData() ); - } - else - { - Reference< chart2::data::XDataSequence > xSeq( xLDS->getValues() ); - if( xSeq.is() ) - aDataSeq = xSeq->getData(); - } + Reference< chart2::data::XDataSequence > xSeq( xLDS->getValues() ); + if( xSeq.is() ) + aDataSeq = xSeq->getData(); sal_Int32 nLength = aDataSeq.getLength(); if( static_cast< sal_Int32 >(aNewCategories.size()) < nLength ) aNewCategories.resize( nLength ); @@ -790,40 +782,14 @@ Sequence< uno::Any > SAL_CALL InternalDataProvider::getDataByRangeRepresentation } else if( aRange.equals( lcl_aCategoriesRangeName ) ) { - bool bReturnText = true; vector< vector< uno::Any > > aCategories( m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels()); sal_Int32 nLevelCount = lcl_getInnerLevelCount( aCategories ); if( nLevelCount == 1 ) { sal_Int32 nL=0; aResult = this->getDataByRangeRepresentation( lcl_aCategoriesLevelRangeNamePrefix + OUString::valueOf( nL ) ); - bool bOnlyDatesFound = true; - double fTest = 0.0; - OUString aTest; - for(sal_Int32 nN=aResult.getLength(); nN--;) - { - uno::Any aAny(aResult[nN]); - if( !( aAny >>= fTest) ) - { - if( aAny.hasValue() ) - { - if( (aAny>>=aTest) && !aTest.getLength() ) - { - //empty string does not count as non date value! - aResult[nN] = uno::Any(); - } - else - { - bOnlyDatesFound=false; - break; - } - } - } - } - if( bOnlyDatesFound ) - bReturnText = false; } - if( bReturnText ) + else { Sequence< OUString > aLabels = m_bDataInColumns ? this->getRowDescriptions() : this->getColumnDescriptions(); aResult.realloc( aLabels.getLength() ); diff --git a/chart2/source/view/main/NumberFormatterWrapper.cxx b/chart2/source/tools/NumberFormatterWrapper.cxx index de7dde79e789..829a64cc6617 100644..100755 --- a/chart2/source/view/main/NumberFormatterWrapper.cxx +++ b/chart2/source/tools/NumberFormatterWrapper.cxx @@ -27,7 +27,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_chart2.hxx" -#include "chartview/NumberFormatterWrapper.hxx" +#include "NumberFormatterWrapper.hxx" #include "macros.hxx" #include <comphelper/processfactory.hxx> // header for class SvNumberFormatsSupplierObj diff --git a/chart2/source/tools/makefile.mk b/chart2/source/tools/makefile.mk index fd92b894bfab..7554bd19cd38 100644 --- a/chart2/source/tools/makefile.mk +++ b/chart2/source/tools/makefile.mk @@ -70,6 +70,7 @@ SLOFILES= \ $(SLO)$/LinearRegressionCurveCalculator.obj \ $(SLO)$/LogarithmicRegressionCurveCalculator.obj \ $(SLO)$/MeanValueRegressionCurveCalculator.obj \ + $(SLO)$/NumberFormatterWrapper.obj \ $(SLO)$/OPropertySet.obj \ $(SLO)$/WrappedPropertySet.obj \ $(SLO)$/WrappedProperty.obj \ diff --git a/chart2/source/view/axes/VCartesianAxis.cxx b/chart2/source/view/axes/VCartesianAxis.cxx index 23d1d7985b90..a4cca736fe18 100644 --- a/chart2/source/view/axes/VCartesianAxis.cxx +++ b/chart2/source/view/axes/VCartesianAxis.cxx @@ -36,7 +36,7 @@ #include "macros.hxx" #include "ViewDefines.hxx" #include "PropertyMapper.hxx" -#include "chartview/NumberFormatterWrapper.hxx" +#include "NumberFormatterWrapper.hxx" #include "LabelPositionHelper.hxx" #include "TrueGuard.hxx" #include "BaseGFXHelper.hxx" diff --git a/chart2/source/view/axes/VPolarAngleAxis.cxx b/chart2/source/view/axes/VPolarAngleAxis.cxx index 0a10ee25e1c4..c23d6b95629d 100644 --- a/chart2/source/view/axes/VPolarAngleAxis.cxx +++ b/chart2/source/view/axes/VPolarAngleAxis.cxx @@ -33,7 +33,7 @@ #include "VPolarGrid.hxx" #include "ShapeFactory.hxx" #include "macros.hxx" -#include "chartview/NumberFormatterWrapper.hxx" +#include "NumberFormatterWrapper.hxx" #include "PolarLabelPositionHelper.hxx" #include <tools/color.hxx> diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx b/chart2/source/view/charttypes/VSeriesPlotter.cxx index dbafa59c0588..6b2f916b03ec 100644 --- a/chart2/source/view/charttypes/VSeriesPlotter.cxx +++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx @@ -43,7 +43,7 @@ #include "ChartTypeHelper.hxx" #include "Clipping.hxx" #include "servicenames_charttypes.hxx" -#include "chartview/NumberFormatterWrapper.hxx" +#include "NumberFormatterWrapper.hxx" #include "ContainerHelper.hxx" #include "DataSeriesHelper.hxx" #include "RegressionCurveHelper.hxx" @@ -53,6 +53,7 @@ #include "Strings.hrc" #include "RelativePositionHelper.hxx" #include "DateHelper.hxx" +#include "DiagramHelper.hxx" //only for creation: @todo remove if all plotter are uno components and instanciated via servicefactory #include "BarChart.hxx" @@ -395,7 +396,7 @@ OUString VSeriesPlotter::getLabelTextForValue( VDataSeries& rDataSeries nNumberFormatKey = rDataSeries.getExplicitNumberFormat(nPointIndex,bAsPercentage); else if( bAsPercentage ) { - sal_Int32 nPercentFormat = ExplicitValueProvider::getPercentNumberFormat( m_apNumberFormatterWrapper->getNumberFormatsSupplier() ); + sal_Int32 nPercentFormat = DiagramHelper::getPercentNumberFormat( m_apNumberFormatterWrapper->getNumberFormatsSupplier() ); if( nPercentFormat != -1 ) nNumberFormatKey = nPercentFormat; } diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx index cff3ab3d1c14..4f39cac39c9d 100644 --- a/chart2/source/view/main/ChartView.cxx +++ b/chart2/source/view/main/ChartView.cxx @@ -31,7 +31,7 @@ #include "ChartView.hxx" #include "chartview/DrawModelWrapper.hxx" -#include "chartview/NumberFormatterWrapper.hxx" +#include "NumberFormatterWrapper.hxx" #include "ViewDefines.hxx" #include "VDiagram.hxx" #include "VTitle.hxx" @@ -585,12 +585,14 @@ private: ::std::map< uno::Reference< XAxis >, AxisUsage > m_aAxisUsageList; sal_Int32 m_nMaxAxisIndex; bool m_bChartTypeUsesShiftedCategoryPositionPerDefault; + sal_Int32 m_nDefaultDateNumberFormat; }; SeriesPlotterContainer::SeriesPlotterContainer( std::vector< VCoordinateSystem* >& rVCooSysList ) : m_rVCooSysList( rVCooSysList ) , m_nMaxAxisIndex(0) , m_bChartTypeUsesShiftedCategoryPositionPerDefault(false) + , m_nDefaultDateNumberFormat(0) { } @@ -628,6 +630,10 @@ void SeriesPlotterContainer::initializeCooSysAndSeriesPlotter( return; uno::Reference< util::XNumberFormatsSupplier > xNumberFormatsSupplier( xChartModel, uno::UNO_QUERY ); + uno::Reference< chart2::XChartDocument > xChartDoc( xChartModel, uno::UNO_QUERY ); + if( xChartDoc.is() && xChartDoc->hasInternalDataProvider() + && DiagramHelper::isSupportingDateAxis( xDiagram ) ) + m_nDefaultDateNumberFormat=DiagramHelper::getDateNumberFormat( xNumberFormatsSupplier ); sal_Int32 nDimensionCount = DiagramHelper::getDimension( xDiagram ); if(!nDimensionCount) @@ -904,6 +910,11 @@ void SeriesPlotterContainer::setNumberFormatsFromAxes() { aAxesNumberFormats.setFormat( nNumberFormatKey, nDimensionIndex, nAxisIndex ); } + else if( nDimensionIndex==0 ) + { + //provide a default date format for date axis with own data + aAxesNumberFormats.setFormat( m_nDefaultDateNumberFormat, nDimensionIndex, nAxisIndex ); + } } } catch( lang::IndexOutOfBoundsException& e ) @@ -1828,195 +1839,16 @@ bool lcl_getPropertySwapXAndYAxis( const uno::Reference< XDiagram >& xDiagram ) } -sal_Int32 lcl_getDateNumberFormat( const Reference< util::XNumberFormatsSupplier >& xNumberFormatsSupplier ) -{ - sal_Int32 nRet=-1; - Reference< util::XNumberFormats > xNumberFormats( xNumberFormatsSupplier->getNumberFormats() ); - if( xNumberFormats.is() ) - { - sal_Bool bCreate = sal_True; - const LocaleDataWrapper& rLocaleDataWrapper = Application::GetSettings().GetLocaleDataWrapper(); - Sequence<sal_Int32> aKeySeq = xNumberFormats->queryKeys( util::NumberFormat::DATE, - rLocaleDataWrapper.getLocale(), bCreate ); - if( aKeySeq.getLength() ) - { - nRet = aKeySeq[0]; - } - } - return nRet; -} - -sal_Int32 lcl_getExplicitNumberFormatKeyForAxis( - const Reference< chart2::XAxis >& xAxis - , const Reference< chart2::XCoordinateSystem > & xCorrespondingCoordinateSystem - , const Reference< util::XNumberFormatsSupplier >& xNumberFormatsSupplier - , bool bSearchForParallelAxisIfNothingIsFound ) -{ - sal_Int32 nNumberFormatKey(0); - Reference< beans::XPropertySet > xProp( xAxis, uno::UNO_QUERY ); - if( xProp.is() && !( xProp->getPropertyValue( C2U( "NumberFormat" ) ) >>= nNumberFormatKey ) ) - { - bool bFormatSet = false; - //check wether we have a percent scale -> use percent format - if( xNumberFormatsSupplier.is() ) - { - ScaleData aData = AxisHelper::getDateCheckedScale( xAxis, Reference< frame::XModel >( xNumberFormatsSupplier, uno::UNO_QUERY ) ); - if( aData.AxisType==AxisType::PERCENT ) - { - sal_Int32 nPercentFormat = ExplicitValueProvider::getPercentNumberFormat( xNumberFormatsSupplier ); - if( nPercentFormat != -1 ) - { - nNumberFormatKey = nPercentFormat; - bFormatSet = true; - } - } - else if( aData.AxisType==AxisType::DATE ) - { - if( aData.Categories.is() ) - { - Reference< data::XDataSequence > xSeq( aData.Categories->getValues()); - if( xSeq.is() ) - nNumberFormatKey = xSeq->getNumberFormatKeyByIndex( -1 ); - else - nNumberFormatKey = lcl_getDateNumberFormat( xNumberFormatsSupplier ); - bFormatSet = true; - } - } - } - - if( !bFormatSet ) - { - typedef ::std::map< sal_Int32, sal_Int32 > tNumberformatFrequency; - tNumberformatFrequency aKeyMap; - - bool bNumberFormatKeyFoundViaAttachedData = false; - sal_Int32 nAxisIndex = 0; - sal_Int32 nDimensionIndex = 1; - - try - { - Reference< XChartTypeContainer > xCTCnt( xCorrespondingCoordinateSystem, uno::UNO_QUERY_THROW ); - if( xCTCnt.is() ) - { - AxisHelper::getIndicesForAxis( xAxis, xCorrespondingCoordinateSystem, nDimensionIndex, nAxisIndex ); - ::rtl::OUString aRoleToMatch; - if( nDimensionIndex == 0 ) - aRoleToMatch = C2U("values-x"); - Sequence< Reference< XChartType > > aChartTypes( xCTCnt->getChartTypes()); - for( sal_Int32 nCTIdx=0; nCTIdx<aChartTypes.getLength(); ++nCTIdx ) - { - if( nDimensionIndex != 0 ) - aRoleToMatch = ChartTypeHelper::getRoleOfSequenceForYAxisNumberFormatDetection( aChartTypes[nCTIdx] ); - Reference< XDataSeriesContainer > xDSCnt( aChartTypes[nCTIdx], uno::UNO_QUERY_THROW ); - Sequence< Reference< XDataSeries > > aDataSeriesSeq( xDSCnt->getDataSeries()); - for( sal_Int32 nSeriesIdx=0; nSeriesIdx<aDataSeriesSeq.getLength(); ++nSeriesIdx ) - { - Reference< chart2::XDataSeries > xDataSeries(aDataSeriesSeq[nSeriesIdx]); - Reference< data::XDataSource > xSource( xDataSeries, uno::UNO_QUERY_THROW ); - - if( nDimensionIndex == 1 ) - { - //only take those series into accoutn that are attached to this axis - sal_Int32 nAttachedAxisIndex = DataSeriesHelper::getAttachedAxisIndex(xDataSeries); - if( nAttachedAxisIndex != nAxisIndex ) - continue; - } - - Reference< data::XLabeledDataSequence > xLabeledSeq( - DataSeriesHelper::getDataSequenceByRole( xSource, aRoleToMatch ) ); - - if( !xLabeledSeq.is() && nDimensionIndex==0 ) - { - ScaleData aData = xAxis->getScaleData(); - if( aData.AxisType==AxisType::REALNUMBER ) - xLabeledSeq = aData.Categories; - } - - if( xLabeledSeq.is() ) - { - Reference< data::XDataSequence > xSeq( xLabeledSeq->getValues()); - if( xSeq.is() ) - { - sal_Int32 nKey = xSeq->getNumberFormatKeyByIndex( -1 ); - // initialize the value - if( aKeyMap.find( nKey ) == aKeyMap.end()) - aKeyMap[ nKey ] = 0; - // increase frequency - aKeyMap[ nKey ] = (aKeyMap[ nKey ] + 1); - } - } - } - } - } - } - catch( const uno::Exception & ex ) - { - ASSERT_EXCEPTION( ex ); - } - - if( ! aKeyMap.empty()) - { - sal_Int32 nMaxFreq = 0; - // find most frequent key - for( tNumberformatFrequency::const_iterator aIt = aKeyMap.begin(); - aIt != aKeyMap.end(); ++aIt ) - { - OSL_TRACE( "NumberFormatKey %d appears %d times", (*aIt).first, (*aIt).second ); - // all values must at least be 1 - if( (*aIt).second > nMaxFreq ) - { - nNumberFormatKey = (*aIt).first; - bNumberFormatKeyFoundViaAttachedData = true; - nMaxFreq = (*aIt).second; - } - } - } - - if( bSearchForParallelAxisIfNothingIsFound ) - { - //no format is set to this axis and no data is set to this axis - //--> try to obtain the format from the parallel y-axis - if( !bNumberFormatKeyFoundViaAttachedData && nDimensionIndex == 1 ) - { - sal_Int32 nParallelAxisIndex = (nAxisIndex==1) ?0 :1; - Reference< XAxis > xParallelAxis( AxisHelper::getAxis( 1, nParallelAxisIndex, xCorrespondingCoordinateSystem ) ); - nNumberFormatKey = lcl_getExplicitNumberFormatKeyForAxis( xParallelAxis, xCorrespondingCoordinateSystem, xNumberFormatsSupplier, false ); - } - } - } - } - return nNumberFormatKey; -} - //static sal_Int32 ExplicitValueProvider::getExplicitNumberFormatKeyForAxis( const Reference< chart2::XAxis >& xAxis , const Reference< chart2::XCoordinateSystem > & xCorrespondingCoordinateSystem , const Reference< util::XNumberFormatsSupplier >& xNumberFormatsSupplier ) { - return lcl_getExplicitNumberFormatKeyForAxis( xAxis, xCorrespondingCoordinateSystem, xNumberFormatsSupplier + return AxisHelper::getExplicitNumberFormatKeyForAxis( xAxis, xCorrespondingCoordinateSystem, xNumberFormatsSupplier , true /*bSearchForParallelAxisIfNothingIsFound*/ ); } -//static -sal_Int32 ExplicitValueProvider::getPercentNumberFormat( const Reference< util::XNumberFormatsSupplier >& xNumberFormatsSupplier ) -{ - sal_Int32 nRet=-1; - Reference< util::XNumberFormats > xNumberFormats( xNumberFormatsSupplier->getNumberFormats() ); - if( xNumberFormats.is() ) - { - sal_Bool bCreate = sal_True; - const LocaleDataWrapper& rLocaleDataWrapper = Application::GetSettings().GetLocaleDataWrapper(); - Sequence<sal_Int32> aKeySeq = xNumberFormats->queryKeys( util::NumberFormat::PERCENT, - rLocaleDataWrapper.getLocale(), bCreate ); - if( aKeySeq.getLength() ) - { - nRet = aKeySeq[0]; - } - } - return nRet; -} - sal_Int32 ExplicitValueProvider::getExplicitNumberFormatKeyForDataLabel( const uno::Reference< beans::XPropertySet >& xSeriesOrPointProp, const uno::Reference< XDataSeries >& xSeries, @@ -2069,7 +1901,7 @@ sal_Int32 ExplicitValueProvider::getExplicitPercentageNumberFormatKeyForDataLabe return nFormat; if( !(xSeriesOrPointProp->getPropertyValue(C2U( "PercentageNumberFormat" )) >>= nFormat) ) { - nFormat = ExplicitValueProvider::getPercentNumberFormat( xNumberFormatsSupplier ); + nFormat = DiagramHelper::getPercentNumberFormat( xNumberFormatsSupplier ); } if(nFormat<0) nFormat=0; diff --git a/chart2/source/view/main/makefile.mk b/chart2/source/view/main/makefile.mk index ec9c99f2a898..8675930aa107 100644 --- a/chart2/source/view/main/makefile.mk +++ b/chart2/source/view/main/makefile.mk @@ -43,7 +43,6 @@ ENABLE_EXCEPTIONS= TRUE SLOFILES = \ $(SLO)$/ChartItemPool.obj \ $(SLO)$/DrawModelWrapper.obj \ - $(SLO)$/NumberFormatterWrapper.obj \ $(SLO)$/PropertyMapper.obj \ $(SLO)$/Stripe.obj \ $(SLO)$/VLineProperties.obj \ |