chart2/source/controller/dialogs/DataBrowserModel.cxx | 122 ++++++++++-------- chart2/source/controller/dialogs/DataBrowserModel.hxx | 2 chart2/source/inc/DataSeriesHelper.hxx | 5 chart2/source/tools/DataSeriesHelper.cxx | 12 + include/svl/sharedstring.hxx | 16 +- svl/source/misc/sharedstring.cxx | 32 ++++ 6 files changed, 127 insertions(+), 62 deletions(-)
New commits: commit 8c717ff5d7eb105380f88533edd244ea2e807499 Author: Kohei Yoshida <kohei.yosh...@collabora.com> Date: Thu Jun 26 11:22:59 2014 -0400 Revert needless inlining of methods for publicly exposed class. Keep the method implementations unexposed please. Change-Id: Ic9b1f8654e6ebef428d4182782c1aa4962934c6a diff --git a/include/svl/sharedstring.hxx b/include/svl/sharedstring.hxx index aac16df..fe9e851 100644 --- a/include/svl/sharedstring.hxx +++ b/include/svl/sharedstring.hxx @@ -34,18 +34,18 @@ public: bool operator== ( const SharedString& r ) const; bool operator!= ( const SharedString& r ) const; - OUString getString() const { return mpData ? OUString(mpData) : OUString();} + OUString getString() const; - rtl_uString* getData() { return mpData;} - const rtl_uString* getData() const { return mpData;} + rtl_uString* getData(); + const rtl_uString* getData() const; - rtl_uString* getDataIgnoreCase() { return mpDataIgnoreCase;} - const rtl_uString* getDataIgnoreCase() const { return mpDataIgnoreCase;} + rtl_uString* getDataIgnoreCase(); + const rtl_uString* getDataIgnoreCase() const; - bool isValid() const { return mpData != NULL;} - bool isEmpty() const { return mpData == NULL || mpData->length == 0;} + bool isValid() const; + bool isEmpty() const; - sal_Int32 getLength() const { return mpData ? mpData->length : 0;} + sal_Int32 getLength() const; }; } diff --git a/svl/source/misc/sharedstring.cxx b/svl/source/misc/sharedstring.cxx index 850d8df..8137952 100644 --- a/svl/source/misc/sharedstring.cxx +++ b/svl/source/misc/sharedstring.cxx @@ -95,13 +95,45 @@ bool SharedString::operator!= ( const SharedString& r ) const return !operator== (r); } +OUString SharedString::getString() const +{ + return mpData ? OUString(mpData) : OUString(); +} +rtl_uString* SharedString::getData() +{ + return mpData; +} +const rtl_uString* SharedString::getData() const +{ + return mpData; +} +rtl_uString* SharedString::getDataIgnoreCase() +{ + return mpDataIgnoreCase; +} +const rtl_uString* SharedString::getDataIgnoreCase() const +{ + return mpDataIgnoreCase; +} +bool SharedString::isValid() const +{ + return mpData != NULL; +} +bool SharedString::isEmpty() const +{ + return mpData == NULL || mpData->length == 0; +} +sal_Int32 SharedString::getLength() const +{ + return mpData ? mpData->length : 0; +} } commit 8192df38879694db77228b9b046b149d53448c0e Author: Kohei Yoshida <kohei.yosh...@collabora.com> Date: Thu Jun 26 10:58:55 2014 -0400 Clarify the code a little more. Change-Id: Idc0ff4913695ade9543cd30511aff61d24e7c495 diff --git a/chart2/source/controller/dialogs/DataBrowserModel.cxx b/chart2/source/controller/dialogs/DataBrowserModel.cxx index 49dfec3..e2bff5b 100644 --- a/chart2/source/controller/dialogs/DataBrowserModel.cxx +++ b/chart2/source/controller/dialogs/DataBrowserModel.cxx @@ -186,9 +186,10 @@ struct lcl_RepresentationsOfLSeqMatch : public ::std::unary_function< Reference< {} bool operator() ( const Reference< chart2::data::XLabeledDataSequence > & xLSeq ) { - return (xLSeq.is() && - xLSeq->getValues().is() && - (xLSeq->getValues()->getSourceRangeRepresentation() == m_aValuesRep )); + if (!xLSeq.is() || !xLSeq->getValues().is()) + return false; + + return xLSeq->getValues()->getSourceRangeRepresentation() == m_aValuesRep; } private: OUString m_aValuesRep; @@ -475,42 +476,55 @@ void DataBrowserModel::removeDataSeriesOrComplexCategoryLevel( sal_Int32 nAtColu //delete sequences from internal data provider that are not used anymore //but do not delete sequences that are still in use by the remaining series + Reference< chart2::XInternalDataProvider > xDataProvider( m_apDialogModel->getDataProvider(), uno::UNO_QUERY ); - Reference< chart2::data::XDataSource > xSourceOfDeletedSeries( xSeries, uno::UNO_QUERY ); - if( xDataProvider.is() && xSourceOfDeletedSeries.is()) + Reference< chart2::data::XDataSource > xSourceOfDeleted( xSeries, uno::UNO_QUERY ); + if (!xDataProvider.is() || !xSourceOfDeleted.is()) { - ::std::vector< sal_Int32 > aSequenceIndexesToDelete; - Sequence< Reference< chart2::data::XLabeledDataSequence > > aSequencesOfDeletedSeries( xSourceOfDeletedSeries->getDataSequences() ); - Reference< chart2::XDataSeriesContainer > xSeriesCnt( getHeaderForSeries( xSeries ).m_xChartType, uno::UNO_QUERY ); - if( xSeriesCnt.is()) - { - Reference< chart2::data::XDataSource > xRemainingDataSource( DataSeriesHelper::getDataSource( xSeriesCnt->getDataSeries() ) ); - if( xRemainingDataSource.is() ) - { - ::std::vector< Reference< chart2::data::XLabeledDataSequence > > aRemainingSeq( ContainerHelper::SequenceToVector( xRemainingDataSource->getDataSequences() ) ); - for( sal_Int32 i=0; i<aSequencesOfDeletedSeries.getLength(); ++i ) - { - ::std::vector< Reference< chart2::data::XLabeledDataSequence > >::const_iterator aHitIt( - ::std::find_if( aRemainingSeq.begin(), aRemainingSeq.end(), - lcl_RepresentationsOfLSeqMatch( aSequencesOfDeletedSeries[i] ))); - // if not used by the remaining series this sequence can be deleted - if( aHitIt == aRemainingSeq.end() ) - aSequenceIndexesToDelete.push_back( lcl_getValuesRepresentationIndex( aSequencesOfDeletedSeries[i] ) ); - } - } - } + // Something went wrong. Bail out. + updateFromModel(); + return; + } - // delete unnecessary sequences of the internal data - // iterate using greatest index first, so that deletion does not - // shift other sequences that will be deleted later - ::std::sort( aSequenceIndexesToDelete.begin(), aSequenceIndexesToDelete.end()); - for( ::std::vector< sal_Int32 >::reverse_iterator aIt( - aSequenceIndexesToDelete.rbegin()); aIt != aSequenceIndexesToDelete.rend(); ++aIt ) - { - if( *aIt != -1 ) - xDataProvider->deleteSequence( *aIt ); - } + Reference<chart2::XDataSeriesContainer> xSeriesCnt( + getHeaderForSeries(xSeries).m_xChartType, uno::UNO_QUERY); + if (!xSeriesCnt.is()) + { + // Unexpected happened. Bail out. + updateFromModel(); + return; } + + // Collect all the remaining data sequences in the same chart type. The + // deleted data series is already gone by this point. + std::vector<Reference<chart2::data::XLabeledDataSequence> > aAllDataSeqs = + DataSeriesHelper::getAllDataSequences(xSeriesCnt->getDataSeries()); + + // Check if the sequences to be deleted are still referenced by any of + // the other data series. If not, mark them for deletion. + std::vector<sal_Int32> aSequenceIndexesToDelete; + Sequence<Reference<chart2::data::XLabeledDataSequence> > aSequencesOfDeleted = xSourceOfDeleted->getDataSequences(); + for (sal_Int32 i = 0; i < aSequencesOfDeleted.getLength(); ++i) + { + std::vector<Reference<chart2::data::XLabeledDataSequence> >::const_iterator aHitIt( + ::std::find_if( aAllDataSeqs.begin(), aAllDataSeqs.end(), + lcl_RepresentationsOfLSeqMatch( aSequencesOfDeleted[i] ))); + // if not used by the remaining series this sequence can be deleted + if( aHitIt == aAllDataSeqs.end() ) + aSequenceIndexesToDelete.push_back( lcl_getValuesRepresentationIndex( aSequencesOfDeleted[i] ) ); + } + + // delete unnecessary sequences of the internal data + // iterate using greatest index first, so that deletion does not + // shift other sequences that will be deleted later + ::std::sort( aSequenceIndexesToDelete.begin(), aSequenceIndexesToDelete.end()); + for( ::std::vector< sal_Int32 >::reverse_iterator aIt( + aSequenceIndexesToDelete.rbegin()); aIt != aSequenceIndexesToDelete.rend(); ++aIt ) + { + if( *aIt != -1 ) + xDataProvider->deleteSequence( *aIt ); + } + updateFromModel(); } diff --git a/chart2/source/inc/DataSeriesHelper.hxx b/chart2/source/inc/DataSeriesHelper.hxx index 9792b71..13ea4bc 100644 --- a/chart2/source/inc/DataSeriesHelper.hxx +++ b/chart2/source/inc/DataSeriesHelper.hxx @@ -75,6 +75,11 @@ OOO_DLLPUBLIC_CHARTTOOLS ::std::vector< const OUString& aRole, bool bMatchPrefix = false ); +OOO_DLLPUBLIC_CHARTTOOLS +std::vector<css::uno::Reference<css::chart2::data::XLabeledDataSequence> > +getAllDataSequences( + const css::uno::Sequence<css::uno::Reference<css::chart2::XDataSeries> >& aSeries ); + /** Retrieves all data sequences found in the given data series and puts them into a data source. The order of sequences will match the order of the data series. diff --git a/chart2/source/tools/DataSeriesHelper.cxx b/chart2/source/tools/DataSeriesHelper.cxx index a3b6cd5..3066402 100644 --- a/chart2/source/tools/DataSeriesHelper.cxx +++ b/chart2/source/tools/DataSeriesHelper.cxx @@ -237,8 +237,8 @@ Reference< chart2::data::XLabeledDataSequence > return aResultVec; } -Reference< chart2::data::XDataSource > - getDataSource( const Sequence< Reference< chart2::XDataSeries > > & aSeries ) +std::vector<Reference<css::chart2::data::XLabeledDataSequence> > +getAllDataSequences( const uno::Sequence<uno::Reference<chart2::XDataSeries> >& aSeries ) { ::std::vector< Reference< chart2::data::XLabeledDataSequence > > aSeqVec; @@ -253,8 +253,14 @@ Reference< chart2::data::XDataSource > } } + return aSeqVec; +} + +Reference< chart2::data::XDataSource > + getDataSource( const Sequence< Reference< chart2::XDataSeries > > & aSeries ) +{ return Reference< chart2::data::XDataSource >( - new DataSource( ContainerHelper::ContainerToSequence( aSeqVec ))); + new DataSource(ContainerHelper::ContainerToSequence(getAllDataSequences(aSeries)))); } namespace commit 60e94d8982e2b3d2e92a178a7179142fb7fcc631 Author: Kohei Yoshida <kohei.yosh...@collabora.com> Date: Thu Jun 26 10:10:29 2014 -0400 Move the category level removal code into its own method. Change-Id: I4f0cfb4b15bc145b7a5c3491a7acbff13999bf5d diff --git a/chart2/source/controller/dialogs/DataBrowserModel.cxx b/chart2/source/controller/dialogs/DataBrowserModel.cxx index 56d6b41..49dfec3 100644 --- a/chart2/source/controller/dialogs/DataBrowserModel.cxx +++ b/chart2/source/controller/dialogs/DataBrowserModel.cxx @@ -440,32 +440,38 @@ void DataBrowserModel::insertComplexCategoryLevel( sal_Int32 nAfterColumnIndex ) updateFromModel(); } -void DataBrowserModel::removeDataSeriesOrComplexCategoryLevel( sal_Int32 nAtColumnIndex ) +void DataBrowserModel::removeComplexCategoryLevel( sal_Int32 nAtColumnIndex ) { - OSL_ASSERT( m_apDialogModel.get()); - if (static_cast<size_t>(nAtColumnIndex) >= m_aColumns.size()) + //delete a category column if there is more than one level (in case of a single column we do not get here) + OSL_ENSURE(nAtColumnIndex>0, "wrong index for categories deletion" ); + + Reference< chart2::XInternalDataProvider > xDataProvider( m_apDialogModel->getDataProvider(), uno::UNO_QUERY ); + if (!xDataProvider.is()) return; - Reference< chart2::XDataSeries > xSeries( m_aColumns[nAtColumnIndex].m_xDataSeries ); - if (!xSeries.is()) - { - //delete a category column if there is more than one level (in case of a single column we do not get here) - OSL_ENSURE(nAtColumnIndex>0, "wrong index for categories deletion" ); + m_apDialogModel->startControllerLockTimer(); + ControllerLockGuardUNO aLockedControllers( Reference< frame::XModel >( m_xChartDocument, uno::UNO_QUERY ) ); + xDataProvider->deleteComplexCategoryLevel( nAtColumnIndex ); - Reference< chart2::XInternalDataProvider > xDataProvider( m_apDialogModel->getDataProvider(), uno::UNO_QUERY ); - if (!xDataProvider.is()) - return; + updateFromModel(); +} - m_apDialogModel->startControllerLockTimer(); - ControllerLockGuardUNO aLockedControllers( Reference< frame::XModel >( m_xChartDocument, uno::UNO_QUERY ) ); - xDataProvider->deleteComplexCategoryLevel( nAtColumnIndex ); - updateFromModel(); +void DataBrowserModel::removeDataSeriesOrComplexCategoryLevel( sal_Int32 nAtColumnIndex ) +{ + OSL_ASSERT( m_apDialogModel.get()); + if (nAtColumnIndex < 0 || static_cast<size_t>(nAtColumnIndex) >= m_aColumns.size()) + // Out of bound. + return; + if (isCategoriesColumn(nAtColumnIndex)) + { + removeComplexCategoryLevel(nAtColumnIndex); return; } - m_apDialogModel->deleteSeries( - xSeries, getHeaderForSeries( xSeries ).m_xChartType ); + const Reference<chart2::XDataSeries>& xSeries = m_aColumns[nAtColumnIndex].m_xDataSeries; + + m_apDialogModel->deleteSeries(xSeries, getHeaderForSeries(xSeries).m_xChartType); //delete sequences from internal data provider that are not used anymore //but do not delete sequences that are still in use by the remaining series diff --git a/chart2/source/controller/dialogs/DataBrowserModel.hxx b/chart2/source/controller/dialogs/DataBrowserModel.hxx index 57bd55f..ce1b5e1 100644 --- a/chart2/source/controller/dialogs/DataBrowserModel.hxx +++ b/chart2/source/controller/dialogs/DataBrowserModel.hxx @@ -143,6 +143,8 @@ public: private: void updateFromModel(); + void removeComplexCategoryLevel( sal_Int32 nAtColumnIndex ); + void addErrorBarRanges( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries > & xDataSeries, _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits