chart2/source/view/axes/MinimumAndMaximumSupplier.cxx |   35 +++++----------
 chart2/source/view/axes/VCoordinateSystem.cxx         |   12 ++++-
 chart2/source/view/charttypes/PieChart.cxx            |    8 ---
 chart2/source/view/charttypes/PieChart.hxx            |    3 -
 chart2/source/view/charttypes/VSeriesPlotter.cxx      |   40 ++----------------
 chart2/source/view/inc/MinimumAndMaximumSupplier.hxx  |    6 --
 chart2/source/view/inc/VSeriesPlotter.hxx             |    3 -
 sc/inc/docuno.hxx                                     |    9 ++--
 sc/source/filter/xml/XMLTableSourceContext.cxx        |    3 -
 sc/source/filter/xml/xmlcoli.cxx                      |    5 +-
 sc/source/filter/xml/xmlrowi.cxx                      |    5 +-
 sc/source/filter/xml/xmlsubti.cxx                     |   29 ++++---------
 sc/source/filter/xml/xmlsubti.hxx                     |    5 +-
 sc/source/filter/xml/xmltabi.cxx                      |    3 -
 sc/source/ui/unoobj/docuno.cxx                        |   13 ++++-
 15 files changed, 71 insertions(+), 108 deletions(-)

New commits:
commit 2824c9ca4ba53f015f9b8f279b347585ee847818
Author:     Noel Grandin <[email protected]>
AuthorDate: Sat Apr 5 20:37:35 2025 +0200
Commit:     Noel Grandin <[email protected]>
CommitDate: Sun Apr 6 08:38:29 2025 +0200

    use more concrete UNO in sc
    
    as a prelude to doing some optimisation
    
    Change-Id: Ia92f4c2f7a440c39c3180b262cde4ef83db7622a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183749
    Reviewed-by: Noel Grandin <[email protected]>
    Tested-by: Jenkins

diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx
index 5586ee4f8963..c8dab9647d0c 100644
--- a/sc/inc/docuno.hxx
+++ b/sc/inc/docuno.hxx
@@ -71,6 +71,7 @@ class ScRangeList;
 class ScPrintUIOptions;
 class ScSheetSaveData;
 struct ScFormatSaveData;
+class ScTableSheetsObj;
 
 class SAL_DLLPUBLIC_RTTI ScModelObj : public SfxBaseModel,
                     public vcl::ITiledRenderable,
@@ -163,8 +164,9 @@ public:
     virtual void            Notify( SfxBroadcaster& rBC, const SfxHint& rHint 
) override;
 
                             /// XSpreadsheetDocument
-    virtual css::uno::Reference< css::sheet::XSpreadsheets > SAL_CALL
-                            getSheets() override;
+    SC_DLLPUBLIC virtual css::uno::Reference< css::sheet::XSpreadsheets > 
SAL_CALL
+                            getSheets() override final;
+    SC_DLLPUBLIC rtl::Reference< ScTableSheetsObj > getScSheets();
 
                             /// XDataProviderAccess
     virtual ::css::uno::Reference< css::chart2::data::XDataProvider > SAL_CALL
@@ -449,7 +451,6 @@ class ScTableSheetsObj final : public cppu::WeakImplHelper<
 private:
     ScDocShell*             pDocShell;
 
-    rtl::Reference<ScTableSheetObj> GetObjectByIndex_Impl(sal_Int32 nIndex) 
const;
     rtl::Reference<ScTableSheetObj> GetObjectByName_Impl(const OUString& 
aName) const;
 
 public:
@@ -511,6 +512,8 @@ public:
     virtual OUString SAL_CALL getImplementationName() override;
     virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) 
override;
     virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() 
override;
+
+    rtl::Reference<ScTableSheetObj> GetSheetByIndex(sal_Int32 nIndex) const;
 };
 
 class ScTableColumnsObj final : public cppu::WeakImplHelper<
diff --git a/sc/source/filter/xml/XMLTableSourceContext.cxx 
b/sc/source/filter/xml/XMLTableSourceContext.cxx
index 9f66f6f4a089..a6a95a1473ec 100644
--- a/sc/source/filter/xml/XMLTableSourceContext.cxx
+++ b/sc/source/filter/xml/XMLTableSourceContext.cxx
@@ -23,6 +23,7 @@
 #include <docsh.hxx>
 #include "xmlsubti.hxx"
 #include <tablink.hxx>
+#include <cellsuno.hxx>
 #include <xmloff/xmltoken.hxx>
 #include <xmloff/xmlnamespace.hxx>
 #include <sax/tools/converter.hxx>
@@ -79,7 +80,7 @@ void SAL_CALL ScXMLTableSourceContext::endFastElement( 
sal_Int32 /*nElement*/ )
     if (sLink.isEmpty())
         return;
 
-    uno::Reference <sheet::XSheetLinkable> xLinkable 
(GetScImport().GetTables().GetCurrentXSheet(), uno::UNO_QUERY);
+    rtl::Reference<ScTableSheetObj> xLinkable 
(GetScImport().GetTables().GetCurrentXSheet());
     ScDocument* pDoc(GetScImport().GetDocument());
     if (!(xLinkable.is() && pDoc))
         return;
diff --git a/sc/source/filter/xml/xmlcoli.cxx b/sc/source/filter/xml/xmlcoli.cxx
index 5114296d9760..7c0944b6bdc7 100644
--- a/sc/source/filter/xml/xmlcoli.cxx
+++ b/sc/source/filter/xml/xmlcoli.cxx
@@ -21,6 +21,7 @@
 #include "xmlimprt.hxx"
 #include "xmlstyli.hxx"
 #include <document.hxx>
+#include <cellsuno.hxx>
 #include <docuno.hxx>
 #include <olinetab.hxx>
 #include <sheetdata.hxx>
@@ -88,7 +89,7 @@ void SAL_CALL ScXMLTableColContext::endFastElement( sal_Int32 
/*nElement*/ )
     ScDocument* pDoc = rXMLImport.GetDocument();
     SCTAB nSheet = rXMLImport.GetTables().GetCurrentSheet();
     sal_Int32 nCurrentColumn = rXMLImport.GetTables().GetCurrentColCount();
-    uno::Reference<sheet::XSpreadsheet> 
xSheet(rXMLImport.GetTables().GetCurrentXSheet());
+    rtl::Reference<ScTableSheetObj> 
xSheet(rXMLImport.GetTables().GetCurrentXSheet());
     if(pDoc && xSheet.is())
     {
         sal_Int32 nLastColumn(nCurrentColumn + nColCount - 1);
@@ -207,7 +208,7 @@ void SAL_CALL ScXMLTableColsContext::endFastElement( 
sal_Int32 /*nElement*/ )
         nHeaderEndCol--;
         if (nHeaderStartCol <= nHeaderEndCol)
         {
-            uno::Reference <sheet::XPrintAreas> xPrintAreas 
(rXMLImport.GetTables().GetCurrentXSheet(), uno::UNO_QUERY);
+            rtl::Reference<ScTableSheetObj> xPrintAreas 
(rXMLImport.GetTables().GetCurrentXSheet());
             if (xPrintAreas.is())
             {
                 if (!xPrintAreas->getPrintTitleColumns())
diff --git a/sc/source/filter/xml/xmlrowi.cxx b/sc/source/filter/xml/xmlrowi.cxx
index a75b32ac60f6..a2ad7c33e703 100644
--- a/sc/source/filter/xml/xmlrowi.cxx
+++ b/sc/source/filter/xml/xmlrowi.cxx
@@ -23,6 +23,7 @@
 #include "xmlstyli.hxx"
 #include "xmlstyle.hxx"
 #include <document.hxx>
+#include <cellsuno.hxx>
 #include <docuno.hxx>
 #include <olinetab.hxx>
 #include <sheetdata.hxx>
@@ -153,7 +154,7 @@ void SAL_CALL 
ScXMLTableRowContext::endFastElement(sal_Int32 /*nElement*/)
     }
     SCTAB nSheet = rXMLImport.GetTables().GetCurrentSheet();
     sal_Int32 nCurrentRow(rXMLImport.GetTables().GetCurrentRow());
-    uno::Reference<sheet::XSpreadsheet> 
xSheet(rXMLImport.GetTables().GetCurrentXSheet());
+    rtl::Reference<ScTableSheetObj> 
xSheet(rXMLImport.GetTables().GetCurrentXSheet());
     if(!xSheet.is())
         return;
 
@@ -324,7 +325,7 @@ void SAL_CALL 
ScXMLTableRowsContext::endFastElement(sal_Int32 /*nElement*/)
         SCROW nHeaderEndRow = rXMLImport.GetTables().GetCurrentRow();
         if (nHeaderStartRow <= nHeaderEndRow)
         {
-            uno::Reference <sheet::XPrintAreas> xPrintAreas 
(rXMLImport.GetTables().GetCurrentXSheet(), uno::UNO_QUERY);
+            rtl::Reference<ScTableSheetObj> xPrintAreas 
(rXMLImport.GetTables().GetCurrentXSheet());
             if (xPrintAreas.is())
             {
                 if (!xPrintAreas->getPrintTitleRows())
diff --git a/sc/source/filter/xml/xmlsubti.cxx 
b/sc/source/filter/xml/xmlsubti.cxx
index 5d09b36456e9..89c2e8d9be17 100644
--- a/sc/source/filter/xml/xmlsubti.cxx
+++ b/sc/source/filter/xml/xmlsubti.cxx
@@ -22,6 +22,7 @@
 #include "xmlimprt.hxx"
 #include <document.hxx>
 #include "XMLConverter.hxx"
+#include <cellsuno.hxx>
 #include <docuno.hxx>
 #include "XMLStylesImportHelper.hxx"
 #include <sheetdata.hxx>
@@ -71,23 +72,18 @@ ScMyTables::~ScMyTables()
 
 namespace {
 
-uno::Reference<sheet::XSpreadsheet> getCurrentSheet(const 
uno::Reference<frame::XModel>& xModel, SCTAB nSheet)
+rtl::Reference<ScTableSheetObj> getCurrentSheet(const 
uno::Reference<frame::XModel>& xModel, SCTAB nSheet)
 {
-    uno::Reference<sheet::XSpreadsheet> xSheet;
-    uno::Reference<sheet::XSpreadsheetDocument> xSpreadDoc(xModel, 
uno::UNO_QUERY);
-    if (!xSpreadDoc.is())
+    rtl::Reference<ScTableSheetObj> xSheet;
+    ScModelObj* pSpreadDoc = dynamic_cast<ScModelObj*>(xModel.get());
+    if (!pSpreadDoc)
         return xSheet;
 
-    uno::Reference <sheet::XSpreadsheets> xSheets(xSpreadDoc->getSheets());
+    rtl::Reference<ScTableSheetsObj> xSheets(pSpreadDoc->getScSheets());
     if (!xSheets.is())
         return xSheet;
 
-    uno::Reference <container::XIndexAccess> xIndex(xSheets, uno::UNO_QUERY);
-    if (!xIndex.is())
-        return xSheet;
-
-    xSheet.set(xIndex->getByIndex(nSheet), uno::UNO_QUERY);
-    return xSheet;
+    return xSheets->GetSheetByIndex(nSheet);
 }
 
 }
@@ -142,10 +138,6 @@ void ScMyTables::SetTableStyle(const OUString& sStyleName)
     if ( !xCurrentSheet.is() )
         return;
 
-    uno::Reference <beans::XPropertySet> xProperties(xCurrentSheet, 
uno::UNO_QUERY);
-    if ( !xProperties.is() )
-        return;
-
     XMLTableStylesContext *pStyles = static_cast<XMLTableStylesContext 
*>(rImport.GetAutoStyles());
     if ( pStyles )
     {
@@ -153,7 +145,7 @@ void ScMyTables::SetTableStyle(const OUString& sStyleName)
                 XmlStyleFamily::TABLE_TABLE, sStyleName, true)));
         if ( pStyle )
         {
-            pStyle->FillPropertySet(xProperties);
+            pStyle->FillPropertySet(xCurrentSheet);
 
             ScSheetSaveData* pSheetData = 
rImport.GetScModel()->GetSheetSaveData();
             pSheetData->AddTableStyle( sStyleName, ScAddress( 0, 0, 
maCurrentCellPos.Tab() ) );
@@ -231,9 +223,8 @@ uno::Reference< drawing::XDrawPage > const & 
ScMyTables::GetCurrentXDrawPage()
 {
     if( (maCurrentCellPos.Tab() != nCurrentDrawPage) || !xDrawPage.is() )
     {
-        uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier( 
xCurrentSheet, uno::UNO_QUERY );
-        if( xDrawPageSupplier.is() )
-            xDrawPage.set(xDrawPageSupplier->getDrawPage());
+        if( xCurrentSheet.is() )
+            xDrawPage.set(xCurrentSheet->getDrawPage());
         nCurrentDrawPage = 
sal::static_int_cast<sal_Int16>(maCurrentCellPos.Tab());
     }
     return xDrawPage;
diff --git a/sc/source/filter/xml/xmlsubti.hxx 
b/sc/source/filter/xml/xmlsubti.hxx
index b5ccc4261600..5970ddade41b 100644
--- a/sc/source/filter/xml/xmlsubti.hxx
+++ b/sc/source/filter/xml/xmlsubti.hxx
@@ -29,6 +29,7 @@ namespace com::sun::star::table { class XCellRange; }
 namespace com::sun::star::drawing { class XShapes; }
 
 class ScXMLImport;
+class ScTableSheetObj;
 
 struct ScXMLTabProtectionData
 {
@@ -55,7 +56,7 @@ private:
 
     ScMyOLEFixer                        aFixupOLEs;
 
-    css::uno::Reference< css::sheet::XSpreadsheet > xCurrentSheet;
+    rtl::Reference< ScTableSheetObj >   xCurrentSheet;
     css::uno::Reference< css::drawing::XDrawPage > xDrawPage;
     css::uno::Reference < css::drawing::XShapes > xShapes;
     OUString                       sCurrentSheetName;
@@ -87,7 +88,7 @@ public:
     SCTAB                               GetCurrentSheet() const { return 
(maCurrentCellPos.Tab() >= 0) ? maCurrentCellPos.Tab() : 0; }
     SCCOL                               GetCurrentColCount() const;
     SCROW                               GetCurrentRow() const { return 
(maCurrentCellPos.Row() >= 0) ? maCurrentCellPos.Row() : 0; }
-    const css::uno::Reference< css::sheet::XSpreadsheet >&
+    const rtl::Reference< ScTableSheetObj >&
                                         GetCurrentXSheet() const { return 
xCurrentSheet; }
     css::uno::Reference< css::drawing::XDrawPage > const &
                                         GetCurrentXDrawPage();
diff --git a/sc/source/filter/xml/xmltabi.cxx b/sc/source/filter/xml/xmltabi.cxx
index 5010c70b5e11..48849bdd8be9 100644
--- a/sc/source/filter/xml/xmltabi.cxx
+++ b/sc/source/filter/xml/xmltabi.cxx
@@ -25,6 +25,7 @@
 #include "xmlexternaltabi.hxx"
 #include "xmlnexpi.hxx"
 #include <document.hxx>
+#include <cellsuno.hxx>
 #include <docuno.hxx>
 #include <olinetab.hxx>
 #include "XMLTableShapesContext.hxx"
@@ -305,7 +306,7 @@ uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
     case XML_ELEMENT(OFFICE_EXT, XML_EVENT_LISTENERS):
         {
             // use XEventsSupplier interface of the sheet
-            uno::Reference<document::XEventsSupplier> xSupplier( 
GetScImport().GetTables().GetCurrentXSheet(), uno::UNO_QUERY );
+            uno::Reference<document::XEventsSupplier> xSupplier( 
GetScImport().GetTables().GetCurrentXSheet() );
             pContext = new XMLEventsImportContext( GetImport(), xSupplier );
         }
         break;
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 4618f8ddbe7a..ef0ca28c0732 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -1529,6 +1529,11 @@ void ScModelObj::Notify( SfxBroadcaster& rBC, const 
SfxHint& rHint )
 // XSpreadsheetDocument
 
 uno::Reference<sheet::XSpreadsheets> SAL_CALL ScModelObj::getSheets()
+{
+    return getScSheets();
+}
+
+rtl::Reference<ScTableSheetsObj> ScModelObj::getScSheets()
 {
     SolarMutexGuard aGuard;
     if (pDocShell)
@@ -4176,7 +4181,7 @@ void ScTableSheetsObj::Notify( SfxBroadcaster&, const 
SfxHint& rHint )
 
 // XSpreadsheets
 
-rtl::Reference<ScTableSheetObj> 
ScTableSheetsObj::GetObjectByIndex_Impl(sal_Int32 nIndex) const
+rtl::Reference<ScTableSheetObj> ScTableSheetsObj::GetSheetByIndex(sal_Int32 
nIndex) const
 {
     if ( pDocShell && nIndex >= 0 && nIndex < 
pDocShell->GetDocument().GetTableCount() )
         return new ScTableSheetObj( pDocShell, static_cast<SCTAB>(nIndex) );
@@ -4395,7 +4400,7 @@ sal_Int32 ScTableSheetsObj::importSheet(
 uno::Reference< table::XCell > SAL_CALL ScTableSheetsObj::getCellByPosition( 
sal_Int32 nColumn, sal_Int32 nRow, sal_Int32 nSheet )
 {
     SolarMutexGuard aGuard;
-    rtl::Reference<ScTableSheetObj> xSheet = 
GetObjectByIndex_Impl(static_cast<sal_uInt16>(nSheet));
+    rtl::Reference<ScTableSheetObj> xSheet = 
GetSheetByIndex(static_cast<sal_uInt16>(nSheet));
     if (! xSheet.is())
         throw lang::IndexOutOfBoundsException();
 
@@ -4405,7 +4410,7 @@ uno::Reference< table::XCell > SAL_CALL 
ScTableSheetsObj::getCellByPosition( sal
 uno::Reference< table::XCellRange > SAL_CALL 
ScTableSheetsObj::getCellRangeByPosition( sal_Int32 nLeft, sal_Int32 nTop, 
sal_Int32 nRight, sal_Int32 nBottom, sal_Int32 nSheet )
 {
     SolarMutexGuard aGuard;
-    rtl::Reference<ScTableSheetObj> xSheet = 
GetObjectByIndex_Impl(static_cast<sal_uInt16>(nSheet));
+    rtl::Reference<ScTableSheetObj> xSheet = 
GetSheetByIndex(static_cast<sal_uInt16>(nSheet));
     if (! xSheet.is())
         throw lang::IndexOutOfBoundsException();
 
@@ -4458,7 +4463,7 @@ sal_Int32 SAL_CALL ScTableSheetsObj::getCount()
 uno::Any SAL_CALL ScTableSheetsObj::getByIndex( sal_Int32 nIndex )
 {
     SolarMutexGuard aGuard;
-    rtl::Reference<ScTableSheetObj> xSheet(GetObjectByIndex_Impl(nIndex));
+    rtl::Reference<ScTableSheetObj> xSheet(GetSheetByIndex(nIndex));
     if (!xSheet.is())
         throw lang::IndexOutOfBoundsException();
 
commit 6ed923f647aaae79f36039b735c53592a4864ecb
Author:     Noel Grandin <[email protected]>
AuthorDate: Sat Apr 5 19:58:24 2025 +0200
Commit:     Noel Grandin <[email protected]>
CommitDate: Sun Apr 6 08:38:19 2025 +0200

    tdf#151876 speedup editing large chart (2)
    
    reduce hang time when switching chart to edit mode by 50%.
    
    We were already calculating min/max in one pass, but we were
    calling it twice, once for min and then again for max.
    
    Change-Id: I80275cc32cf1514862b65bb1236057d2c872bdb1
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183748
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <[email protected]>

diff --git a/chart2/source/view/axes/MinimumAndMaximumSupplier.cxx 
b/chart2/source/view/axes/MinimumAndMaximumSupplier.cxx
index eaf5c4347379..ea58ec912e19 100644
--- a/chart2/source/view/axes/MinimumAndMaximumSupplier.cxx
+++ b/chart2/source/view/axes/MinimumAndMaximumSupplier.cxx
@@ -74,32 +74,23 @@ double MergedMinimumAndMaximumSupplier::getMaximumX()
     return fGlobalExtremum;
 }
 
-double MergedMinimumAndMaximumSupplier::getMinimumYInRange( double fMinimumX, 
double fMaximumX, sal_Int32 nAxisIndex )
+std::pair<double, double> 
MergedMinimumAndMaximumSupplier::getMinimumAndMaximumYInRange( double 
fMinimumX, double fMaximumX, sal_Int32 nAxisIndex )
 {
-    double fGlobalExtremum = std::numeric_limits<double>::infinity();
-    for (auto const& elem : m_aMinimumAndMaximumSupplierList)
-    {
-        double fLocalExtremum = elem->getMinimumYInRange( fMinimumX, 
fMaximumX, nAxisIndex );
-        if(fLocalExtremum<fGlobalExtremum)
-            fGlobalExtremum=fLocalExtremum;
-    }
-    if(std::isinf(fGlobalExtremum))
-        return std::numeric_limits<double>::quiet_NaN();
-    return fGlobalExtremum;
-}
-
-double MergedMinimumAndMaximumSupplier::getMaximumYInRange( double fMinimumX, 
double fMaximumX, sal_Int32 nAxisIndex )
-{
-    double fGlobalExtremum = -std::numeric_limits<double>::infinity();
+    double fGlobalExtremumMin = std::numeric_limits<double>::infinity();
+    double fGlobalExtremumMax = -std::numeric_limits<double>::infinity();
     for (auto const& elem : m_aMinimumAndMaximumSupplierList)
     {
-        double fLocalExtremum = elem->getMaximumYInRange( fMinimumX, 
fMaximumX, nAxisIndex );
-        if(fLocalExtremum>fGlobalExtremum)
-            fGlobalExtremum=fLocalExtremum;
+        std::pair<double, double> fLocalExtremum = 
elem->getMinimumAndMaximumYInRange( fMinimumX, fMaximumX, nAxisIndex );
+        if(fLocalExtremum.first<fGlobalExtremumMin)
+            fGlobalExtremumMin=fLocalExtremum.first;
+        if(fLocalExtremum.second>fGlobalExtremumMax)
+            fGlobalExtremumMax=fLocalExtremum.second;
     }
-    if(std::isinf(fGlobalExtremum))
-        return std::numeric_limits<double>::quiet_NaN();
-    return fGlobalExtremum;
+    if(std::isinf(fGlobalExtremumMin))
+        fGlobalExtremumMin = std::numeric_limits<double>::quiet_NaN();
+    if(std::isinf(fGlobalExtremumMax))
+        fGlobalExtremumMax = std::numeric_limits<double>::quiet_NaN();
+    return { fGlobalExtremumMin, fGlobalExtremumMax };
 }
 
 double MergedMinimumAndMaximumSupplier::getMinimumZ()
diff --git a/chart2/source/view/axes/VCoordinateSystem.cxx 
b/chart2/source/view/axes/VCoordinateSystem.cxx
index 80d1f7d81c8e..ff8b6dd0be13 100644
--- a/chart2/source/view/axes/VCoordinateSystem.cxx
+++ b/chart2/source/view/axes/VCoordinateSystem.cxx
@@ -356,9 +356,9 @@ void VCoordinateSystem::prepareAutomaticAxisScaling( 
ScaleAutomatism& rScaleAuto
     {
         // y dimension
         ExplicitScaleData aScale = getExplicitScale( 0, 0 );
-        double fMaximum = aScale.Maximum;
         if (!aScale.m_bShiftedCategoryPosition && aScale.AxisType == 
AxisType::DATE)
         {
+            double fMaximum = aScale.Maximum;
             // tdf#146066 Increase maximum date value by one month/year,
             //            because the automatic scaling of the Y axis was 
incorrect when the last Y value was the highest value.
             Date aMaxDate(aScale.NullDate);
@@ -373,9 +373,15 @@ void VCoordinateSystem::prepareAutomaticAxisScaling( 
ScaleAutomatism& rScaleAuto
                     break;
             }
             fMaximum = aMaxDate - aScale.NullDate;
+            fMin = 
m_aMergedMinMaxSupplier.getMinimumAndMaximumYInRange(aScale.Minimum, 
aScale.Maximum, nAxisIndex).first;
+            fMax = 
m_aMergedMinMaxSupplier.getMinimumAndMaximumYInRange(aScale.Minimum, fMaximum, 
nAxisIndex).second;
+        }
+        else
+        {
+            auto fTmp = 
m_aMergedMinMaxSupplier.getMinimumAndMaximumYInRange(aScale.Minimum, 
aScale.Maximum, nAxisIndex);
+            fMin = fTmp.first;
+            fMax = fTmp.second;
         }
-        fMin = 
m_aMergedMinMaxSupplier.getMinimumYInRange(aScale.Minimum,aScale.Maximum, 
nAxisIndex);
-        fMax = m_aMergedMinMaxSupplier.getMaximumYInRange(aScale.Minimum, 
fMaximum, nAxisIndex);
     }
     else if( nDimIndex == 2 )
     {
diff --git a/chart2/source/view/charttypes/PieChart.cxx 
b/chart2/source/view/charttypes/PieChart.cxx
index e801cb120dbf..3fc7968fa23f 100644
--- a/chart2/source/view/charttypes/PieChart.cxx
+++ b/chart2/source/view/charttypes/PieChart.cxx
@@ -867,14 +867,10 @@ double PieChart::getMaximumX()
         return m_aZSlots.front().size()+0.5+fMaxOffset;
     return 1.5+fMaxOffset;
 }
-double PieChart::getMinimumYInRange( double /* fMinimumX */, double /* 
fMaximumX */, sal_Int32 /* nAxisIndex */ )
-{
-    return 0.0;
-}
 
-double PieChart::getMaximumYInRange( double /* fMinimumX */, double /* 
fMaximumX */, sal_Int32 /* nAxisIndex */ )
+std::pair<double, double> PieChart::getMinimumAndMaximumYInRange( double /* 
fMinimumX */, double /* fMaximumX */, sal_Int32 /* nAxisIndex */ )
 {
-    return 1.0;
+    return { 0.0, 1.0 };
 }
 
 bool PieChart::isExpandBorderToIncrementRhythm( sal_Int32 /* nDimensionIndex 
*/ )
diff --git a/chart2/source/view/charttypes/PieChart.hxx 
b/chart2/source/view/charttypes/PieChart.hxx
index b2fa3b8982ec..a4d92f68fc52 100644
--- a/chart2/source/view/charttypes/PieChart.hxx
+++ b/chart2/source/view/charttypes/PieChart.hxx
@@ -149,8 +149,7 @@ public:
     //MinimumAndMaximumSupplier
     virtual double getMinimumX() override;
     virtual double getMaximumX() override;
-    virtual double getMinimumYInRange( double fMinimumX, double fMaximumX, 
sal_Int32 nAxisIndex ) override;
-    virtual double getMaximumYInRange( double fMinimumX, double fMaximumX, 
sal_Int32 nAxisIndex ) override;
+    virtual std::pair<double, double> getMinimumAndMaximumYInRange( double 
fMinimumX, double fMaximumX, sal_Int32 nAxisIndex ) override;
 
     virtual bool isExpandBorderToIncrementRhythm( sal_Int32 nDimensionIndex ) 
override;
     virtual bool isExpandIfValuesCloseToBorder( sal_Int32 nDimensionIndex ) 
override;
diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx 
b/chart2/source/view/charttypes/VSeriesPlotter.cxx
index bb85d35afffd..62760bf41cd5 100644
--- a/chart2/source/view/charttypes/VSeriesPlotter.cxx
+++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx
@@ -1675,13 +1675,13 @@ double VSeriesPlotter::getMaximumX()
     return fMaximum;
 }
 
-double VSeriesPlotter::getMinimumYInRange( double fMinimumX, double fMaximumX, 
sal_Int32 nAxisIndex )
+std::pair<double, double> VSeriesPlotter::getMinimumAndMaximumYInRange( double 
fMinimumX, double fMaximumX, sal_Int32 nAxisIndex )
 {
     if( !m_bCategoryXAxis || ( m_pExplicitCategoriesProvider && 
m_pExplicitCategoriesProvider->isDateAxis() ) )
     {
         double fMinY, fMaxY;
         getMinimumAndMaximumYInContinuousXRange( fMinY, fMaxY, fMinimumX, 
fMaximumX, nAxisIndex );
-        return fMinY;
+        return { fMinY, fMaxY };
     }
 
     double fMinimum = std::numeric_limits<double>::infinity();
@@ -1703,40 +1703,10 @@ double VSeriesPlotter::getMinimumYInRange( double 
fMinimumX, double fMaximumX, s
         }
     }
     if(std::isinf(fMinimum))
-        return std::numeric_limits<double>::quiet_NaN();
-    return fMinimum;
-}
-
-double VSeriesPlotter::getMaximumYInRange( double fMinimumX, double fMaximumX, 
sal_Int32 nAxisIndex )
-{
-    if( !m_bCategoryXAxis || ( m_pExplicitCategoriesProvider && 
m_pExplicitCategoriesProvider->isDateAxis() ) )
-    {
-        double fMinY, fMaxY;
-        getMinimumAndMaximumYInContinuousXRange( fMinY, fMaxY, fMinimumX, 
fMaximumX, nAxisIndex );
-        return fMaxY;
-    }
-
-    double fMinimum = std::numeric_limits<double>::infinity();
-    double fMaximum = -std::numeric_limits<double>::infinity();
-    for( std::vector< VDataSeriesGroup > & rXSlots : m_aZSlots)
-    {
-        for(VDataSeriesGroup & rXSlot : rXSlots)
-        {
-            double fLocalMinimum, fLocalMaximum;
-            rXSlot.calculateYMinAndMaxForCategoryRange(
-                                static_cast<sal_Int32>(fMinimumX-1.0) //first 
category (index 0) matches with real number 1.0
-                                , static_cast<sal_Int32>(fMaximumX-1.0) 
//first category (index 0) matches with real number 1.0
-                                , isSeparateStackingForDifferentSigns( 1 )
-                                , fLocalMinimum, fLocalMaximum, nAxisIndex );
-            if(fMaximum<fLocalMaximum)
-                fMaximum=fLocalMaximum;
-            if(fMinimum>fLocalMinimum)
-                fMinimum=fLocalMinimum;
-        }
-    }
+        fMinimum = std::numeric_limits<double>::quiet_NaN();
     if(std::isinf(fMaximum))
-        return std::numeric_limits<double>::quiet_NaN();
-    return fMaximum;
+        fMaximum = std::numeric_limits<double>::quiet_NaN();
+    return { fMinimum, fMaximum };
 }
 
 double VSeriesPlotter::getMinimumZ()
diff --git a/chart2/source/view/inc/MinimumAndMaximumSupplier.hxx 
b/chart2/source/view/inc/MinimumAndMaximumSupplier.hxx
index cbb5e55ba74a..c7ac06d2c149 100644
--- a/chart2/source/view/inc/MinimumAndMaximumSupplier.hxx
+++ b/chart2/source/view/inc/MinimumAndMaximumSupplier.hxx
@@ -34,8 +34,7 @@ public:
     virtual double getMaximumX() = 0;
 
     //problem y maybe not is always the second border to ask for
-    virtual double getMinimumYInRange( double fMinimumX, double fMaximumX, 
sal_Int32 nAxisIndex ) = 0;
-    virtual double getMaximumYInRange( double fMinimumX, double fMaximumX, 
sal_Int32 nAxisIndex ) = 0;
+    virtual std::pair<double, double> getMinimumAndMaximumYInRange( double 
fMinimumX, double fMaximumX, sal_Int32 nAxisIndex ) = 0;
 
     //problem: z maybe not independent in future
     virtual double getMinimumZ() = 0;
@@ -68,8 +67,7 @@ public:
     //--MinimumAndMaximumSupplier
     virtual double getMinimumX() override;
     virtual double getMaximumX() override;
-    virtual double getMinimumYInRange( double fMinimumX, double fMaximumX, 
sal_Int32 nAxisIndex ) override;
-    virtual double getMaximumYInRange( double fMinimumX, double fMaximumX, 
sal_Int32 nAxisIndex ) override;
+    virtual std::pair<double, double> getMinimumAndMaximumYInRange( double 
fMinimumX, double fMaximumX, sal_Int32 nAxisIndex ) override;
     virtual double getMinimumZ() override;
     virtual double getMaximumZ() override;
 
diff --git a/chart2/source/view/inc/VSeriesPlotter.hxx 
b/chart2/source/view/inc/VSeriesPlotter.hxx
index eaafaef8bfd4..25c37f1c0426 100644
--- a/chart2/source/view/inc/VSeriesPlotter.hxx
+++ b/chart2/source/view/inc/VSeriesPlotter.hxx
@@ -164,8 +164,7 @@ public:
     virtual double getMinimumX() override;
     virtual double getMaximumX() override;
 
-    virtual double getMinimumYInRange( double fMinimumX, double fMaximumX, 
sal_Int32 nAxisIndex ) override;
-    virtual double getMaximumYInRange( double fMinimumX, double fMaximumX, 
sal_Int32 nAxisIndex ) override;
+    virtual std::pair<double, double> getMinimumAndMaximumYInRange( double 
fMinimumX, double fMaximumX, sal_Int32 nAxisIndex ) override;
 
     virtual double getMinimumZ() override;
     virtual double getMaximumZ() override;

Reply via email to