tdf#151091 Revert "tdf#148635 cache some chart stuff"

This reverts commit fd2ca9607431fc6ca49e37ab6fef228aa72da5f9,
since it causes a regression when copying a chart.

Change-Id: I5d40de6f46b4b3e68531257d27f9a81540a06da4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140427
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
diff --git a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx
index a9479cd..d5ede5c 100644
--- a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx
+++ b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx
@@ -1098,8 +1098,7 @@ public:

private: //member
    std::shared_ptr< Chart2ModelContact >   m_spChart2ModelContact;
    mutable Any                             m_aOuterValue;
    mutable bool                            m_bDetectedRangeSegmentation { false };
    mutable Any                                 m_aOuterValue;
};

}
@@ -1153,19 +1152,15 @@ Any WrappedDataRowSourceProperty::getPropertyValue( const Reference< beans::XPro
    bool bHasCategories = true;
    uno::Sequence< sal_Int32 > aSequenceMapping;

    if (!m_bDetectedRangeSegmentation)
    if( DataSourceHelper::detectRangeSegmentation(
            m_spChart2ModelContact->getDocumentModel(), aRangeString, aSequenceMapping, bUseColumns
            , bFirstCellAsLabel, bHasCategories ) )
    {
        if( DataSourceHelper::detectRangeSegmentation(
                m_spChart2ModelContact->getDocumentModel(), aRangeString, aSequenceMapping, bUseColumns
                , bFirstCellAsLabel, bHasCategories ) )
        {
            css::chart::ChartDataRowSource eChartDataRowSource = css::chart::ChartDataRowSource_ROWS;
            if(bUseColumns)
                eChartDataRowSource = css::chart::ChartDataRowSource_COLUMNS;
        css::chart::ChartDataRowSource eChartDataRowSource = css::chart::ChartDataRowSource_ROWS;
        if(bUseColumns)
            eChartDataRowSource = css::chart::ChartDataRowSource_COLUMNS;

            m_aOuterValue <<= eChartDataRowSource;
        }
        m_bDetectedRangeSegmentation = true;
        m_aOuterValue <<= eChartDataRowSource;
    }

    return m_aOuterValue;
diff --git a/sc/inc/chart2uno.hxx b/sc/inc/chart2uno.hxx
index 72a6374..a5e4f53 100644
--- a/sc/inc/chart2uno.hxx
+++ b/sc/inc/chart2uno.hxx
@@ -147,10 +147,6 @@ private:
    ScDocument*                 m_pDocument;
    SfxItemPropertySet          m_aPropSet;
    bool                        m_bIncludeHiddenCells;
    css::uno::Reference< css::chart2::data::XDataSource > mxCachedDataSource;
    css::uno::Sequence< css::beans::PropertyValue > maCachedArguments;
    css::uno::Sequence< css::beans::PropertyValue > maCreateDataSourceArguments;
    css::uno::Reference< css::chart2::data::XDataSource > mxCreatedDataSource;
};

// DataSource
diff --git a/sc/source/ui/unoobj/chart2uno.cxx b/sc/source/ui/unoobj/chart2uno.cxx
index 99476e1..7292497 100644
--- a/sc/source/ui/unoobj/chart2uno.cxx
+++ b/sc/source/ui/unoobj/chart2uno.cxx
@@ -1401,11 +1401,7 @@ ScChart2DataProvider::createDataSource(
    if ( ! m_pDocument )
        throw uno::RuntimeException();

    // This is expensive to compute and we get called more than once, so cache
    if (maCreateDataSourceArguments == aArguments)
        return mxCreatedDataSource;
    maCreateDataSourceArguments = aArguments;

    uno::Reference< chart2::data::XDataSource> xResult;
    bool bLabel = true;
    bool bCategories = false;
    bool bOrientCol = true;
@@ -1492,7 +1488,7 @@ ScChart2DataProvider::createDataSource(
    const Chart2PositionMap* pChartMap = aChPositioner.getPositionMap();
    if (!pChartMap)
        // No chart position map instance.  Bail out.
        return mxCreatedDataSource;
        return xResult;

    rtl::Reference<ScChart2DataSource> pDS;
    ::std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > aSeqs;
@@ -1570,8 +1566,8 @@ ScChart2DataProvider::createDataSource(
        }
    }

    mxCreatedDataSource.set(pDS);
    return mxCreatedDataSource;
    xResult.set( pDS );
    return xResult;
}

namespace
@@ -1763,10 +1759,6 @@ std::pair<OUString, OUString> constructKey(const uno::Reference< chart2::data::X
uno::Sequence< beans::PropertyValue > SAL_CALL ScChart2DataProvider::detectArguments(
    const uno::Reference< chart2::data::XDataSource >& xDataSource )
{
    // Cache these because this is expensive to compute and we get called more than once
    if (xDataSource == mxCachedDataSource)
        return maCachedArguments;

    ::std::vector< beans::PropertyValue > aResult;
    bool bRowSourceDetected = false;
    bool bFirstCellAsLabel = false;
@@ -2032,10 +2024,7 @@ uno::Sequence< beans::PropertyValue > SAL_CALL ScChart2DataProvider::detectArgum
        }
    }

    mxCachedDataSource = xDataSource;
    maCachedArguments = comphelper::containerToSequence( aResult );

    return maCachedArguments;
    return comphelper::containerToSequence( aResult );
}

sal_Bool SAL_CALL ScChart2DataProvider::createDataSequenceByRangeRepresentationPossible( const OUString& aRangeRepresentation )