From 599365d293bb0c0fcc2b5b1183e50fa9b93a8e3f Mon Sep 17 00:00:00 2001 From: Attila Szűcs Date: Thu, 25 Jul 2024 06:21:35 +0200 Subject: SW: extract transform charts (using dialog code) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implemented chart data extraction, and transformation added insert/delete/modify row/column, and the ability to set resize data table setcolumndesc / setrowdesc .. for 1 descriptor, or with multiple descriptor to set set 1 cell value, or set the whole table cells values. it will resize the table, but you can still use partial arrays like "data": [ [ 1,2,3,4 ], [ 2,3,4,5 ], [ 3 ], [ 4,5,6,7 ], [ 2,2,1 ], [ 5,6,7,8 ] ], that means the 3. row 2,3,4th cell will not be overwritten. for insert column, it call codes from DataBrowserModel. (used by dialog code) added tests, fixed a contentcontrol date problem 2. commit (made by Caolan) squashed into 1. commit: WIP hack this to link move stuff from chartcontroller to chartcore and adjust visibility until it links at least Change-Id: I5529f4da33f046eef7e947d755e29486fa966274 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172849 Tested-by: Jenkins CollaboraOffice Reviewed-by: Caolán McNamara Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175121 Tested-by: Jenkins --- chart2/source/controller/dialogs/DataBrowser.cxx | 2 +- .../source/controller/dialogs/DataBrowserModel.cxx | 2 +- .../source/controller/dialogs/DataBrowserModel.hxx | 170 --------------------- chart2/source/controller/dialogs/DialogModel.hxx | 2 +- .../source/controller/inc/RangeSelectionHelper.hxx | 71 --------- .../controller/inc/RangeSelectionListener.hxx | 79 ---------- .../inc/TimerTriggeredControllerLock.hxx | 58 ------- .../source/controller/inc/dlg_CreationWizard.hxx | 2 +- chart2/source/controller/inc/res_ErrorBar.hxx | 2 +- chart2/source/inc/DataBrowserModel.hxx | 170 +++++++++++++++++++++ chart2/source/inc/InternalDataProvider.hxx | 8 + chart2/source/inc/RangeSelectionHelper.hxx | 73 +++++++++ chart2/source/inc/RangeSelectionListener.hxx | 79 ++++++++++ chart2/source/inc/TimerTriggeredControllerLock.hxx | 60 ++++++++ chart2/source/model/main/ChartModel.cxx | 3 + chart2/source/tools/InternalDataProvider.cxx | 15 ++ 16 files changed, 413 insertions(+), 383 deletions(-) delete mode 100644 chart2/source/controller/dialogs/DataBrowserModel.hxx delete mode 100644 chart2/source/controller/inc/RangeSelectionHelper.hxx delete mode 100644 chart2/source/controller/inc/RangeSelectionListener.hxx delete mode 100644 chart2/source/controller/inc/TimerTriggeredControllerLock.hxx create mode 100644 chart2/source/inc/DataBrowserModel.hxx create mode 100644 chart2/source/inc/RangeSelectionHelper.hxx create mode 100644 chart2/source/inc/RangeSelectionListener.hxx create mode 100644 chart2/source/inc/TimerTriggeredControllerLock.hxx (limited to 'chart2/source') diff --git a/chart2/source/controller/dialogs/DataBrowser.cxx b/chart2/source/controller/dialogs/DataBrowser.cxx index db25ada7c1ff..b80dcf2043e0 100644 --- a/chart2/source/controller/dialogs/DataBrowser.cxx +++ b/chart2/source/controller/dialogs/DataBrowser.cxx @@ -20,7 +20,7 @@ #include #include "DataBrowser.hxx" -#include "DataBrowserModel.hxx" +#include #include #include #include diff --git a/chart2/source/controller/dialogs/DataBrowserModel.cxx b/chart2/source/controller/dialogs/DataBrowserModel.cxx index 1db3abc60c9a..9f01c68f61fc 100644 --- a/chart2/source/controller/dialogs/DataBrowserModel.cxx +++ b/chart2/source/controller/dialogs/DataBrowserModel.cxx @@ -17,8 +17,8 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include "DataBrowserModel.hxx" #include "DialogModel.hxx" +#include #include #include #include diff --git a/chart2/source/controller/dialogs/DataBrowserModel.hxx b/chart2/source/controller/dialogs/DataBrowserModel.hxx deleted file mode 100644 index e3254851d002..000000000000 --- a/chart2/source/controller/dialogs/DataBrowserModel.hxx +++ /dev/null @@ -1,170 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ -#pragma once - -#include -#include - -#include -#include - -#include -#include -#include - -namespace com::sun::star::chart2 { class XChartDocument; } -namespace com::sun::star::uno { class XComponentContext; } - -namespace com::sun::star::chart2 { - class XDataSeries; - class XChartType; -} - -namespace chart -{ - -class DialogModel; -class ChartModel; -class ChartType; -class DataSeries; - -class DataBrowserModel final -{ -public: - explicit DataBrowserModel( - const rtl::Reference<::chart::ChartModel> & xChartDoc ); - ~DataBrowserModel(); - - /** Inserts a new data series after the data series to which the data column - with index nAfterColumnIndex belongs. - */ - void insertDataSeries( sal_Int32 nAfterColumnIndex ); - - /** Inserts a new text column for complex categories. - */ - void insertComplexCategoryLevel( sal_Int32 nAfterColumnIndex ); - - /** Removes a data series to which the data column with index nAtColumnIndex - belongs. - */ - void removeDataSeriesOrComplexCategoryLevel( sal_Int32 nAtColumnIndex ); - - /** Swaps the series to which the data column with index nFirstIndex belongs - with the next series (which starts at an index >= nFirstIndex + 1) - */ - void swapDataSeries( sal_Int32 nFirstIndex ); - void swapDataPointForAllSeries( sal_Int32 nFirstIndex ); - - void insertDataPointForAllSeries( sal_Int32 nAfterIndex ); - void removeDataPointForAllSeries( sal_Int32 nAtIndex ); - - enum eCellType - { - NUMBER, - TEXT, - TEXTORDATE - }; - - eCellType getCellType( sal_Int32 nAtColumn ) const; - /// If getCellType( nAtColumn, nAtRow ) returns TEXT, the result will be Nan - double getCellNumber( sal_Int32 nAtColumn, sal_Int32 nAtRow ); - OUString getCellText( sal_Int32 nAtColumn, sal_Int32 nAtRow ); - css::uno::Any getCellAny( sal_Int32 nAtColumn, sal_Int32 nAtRow ); - sal_uInt32 getNumberFormatKey( sal_Int32 nAtColumn ); - - /// returns if the number could successfully be set at the given position - bool setCellNumber( sal_Int32 nAtColumn, sal_Int32 nAtRow, double fValue ); - /// returns if the text could successfully be set at the given position - bool setCellText( sal_Int32 nAtColumn, sal_Int32 nAtRow, const OUString & rText ); - bool setCellAny( sal_Int32 nAtColumn, sal_Int32 nAtRow, const css::uno::Any & aValue ); - - sal_Int32 getColumnCount() const; - sal_Int32 getMaxRowCount() const; - - // returns the UI string of the corresponding role - OUString getRoleOfColumn( sal_Int32 nColumnIndex ) const; - bool isCategoriesColumn( sal_Int32 nColumnIndex ) const; - - struct tDataHeader - { - rtl::Reference< ::chart::DataSeries > m_xDataSeries; - rtl::Reference< ::chart::ChartType > m_xChartType; - bool m_bSwapXAndYAxis; - sal_Int32 m_nStartColumn; - sal_Int32 m_nEndColumn; - - // default CTOR - tDataHeader() : - m_bSwapXAndYAxis( false ), - m_nStartColumn( -1 ), - m_nEndColumn( -1 ) - {} - // "full" CTOR - tDataHeader( - rtl::Reference< ::chart::DataSeries > xDataSeries, - rtl::Reference< ::chart::ChartType > xChartType, - bool bSwapXAndYAxis, - sal_Int32 nStartColumn, - sal_Int32 nEndColumn ) : - m_xDataSeries(std::move( xDataSeries )), - m_xChartType(std::move( xChartType )), - m_bSwapXAndYAxis( bSwapXAndYAxis ), - m_nStartColumn( nStartColumn ), - m_nEndColumn( nEndColumn ) - {} - }; - - typedef std::vector< tDataHeader > tDataHeaderVector; - - const tDataHeaderVector& getDataHeaders() const { return m_aHeaders;} - - tDataHeader getHeaderForSeries( - const css::uno::Reference< css::chart2::XDataSeries > &xSeries ) const; - - rtl::Reference< ::chart::DataSeries > - getDataSeriesByColumn( sal_Int32 nColumn ) const; - -private: - void updateFromModel(); - - void removeComplexCategoryLevel( sal_Int32 nAtColumnIndex ); - - void addErrorBarRanges( - const rtl::Reference<::chart::DataSeries > & xDataSeries, - sal_Int32 nNumberFormatKey, - sal_Int32 & rInOutSequenceIndex, - sal_Int32 & rInOutHeaderEnd, bool bYError ); - - sal_Int32 getCategoryColumnCount(); - - rtl::Reference<::chart::ChartModel> m_xChartDocument; - std::unique_ptr< DialogModel > m_apDialogModel; - - struct tDataColumn; - struct implColumnLess; - - typedef std::vector< tDataColumn > tDataColumnVector; - - tDataColumnVector m_aColumns; - tDataHeaderVector m_aHeaders; -}; - -} // namespace chart - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/controller/dialogs/DialogModel.hxx b/chart2/source/controller/dialogs/DialogModel.hxx index 24b74d6fab3a..88a74c62d403 100644 --- a/chart2/source/controller/dialogs/DialogModel.hxx +++ b/chart2/source/controller/dialogs/DialogModel.hxx @@ -61,7 +61,7 @@ struct DialogModelTimeBasedInfo sal_Int32 nEnd; }; -class DialogModel +class OOO_DLLPUBLIC_CHARTTOOLS DialogModel { public: explicit DialogModel( rtl::Reference<::chart::ChartModel> xChartDocument ); diff --git a/chart2/source/controller/inc/RangeSelectionHelper.hxx b/chart2/source/controller/inc/RangeSelectionHelper.hxx deleted file mode 100644 index 36fe0db99cce..000000000000 --- a/chart2/source/controller/inc/RangeSelectionHelper.hxx +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ -#pragma once - -#include -#include -#include -#include - -namespace com::sun::star::beans { struct PropertyValue; } -namespace com::sun::star::chart2 { class XChartDocument; } - -namespace com::sun::star { - namespace sheet{ - class XRangeSelection; - class XRangeSelectionListener; - } -} - -namespace chart -{ -class ChartModel; -class RangeSelectionListenerParent; - -class RangeSelectionHelper -{ -public: - explicit RangeSelectionHelper( - rtl::Reference<::chart::ChartModel> xChartDocument ); - ~RangeSelectionHelper(); - - bool hasRangeSelection(); - css::uno::Reference< css::sheet::XRangeSelection > const & getRangeSelection(); - void raiseRangeSelectionDocument(); - bool chooseRange( - const OUString & aCurrentRange, - const OUString & aUIString, - RangeSelectionListenerParent & rListenerParent ); - void stopRangeListening( bool bRemoveListener = true ); - bool verifyCellRange( const OUString & rRangeStr ); - bool verifyArguments( const css::uno::Sequence< css::beans::PropertyValue >& rArguments ); - -private: - css::uno::Reference< css::sheet::XRangeSelection > - m_xRangeSelection; - - rtl::Reference<::chart::ChartModel> m_xChartDocument; - - css::uno::Reference< css::sheet::XRangeSelectionListener > - m_xRangeSelectionListener; -}; - -} // namespace chart - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/controller/inc/RangeSelectionListener.hxx b/chart2/source/controller/inc/RangeSelectionListener.hxx deleted file mode 100644 index 0ca4644a96ad..000000000000 --- a/chart2/source/controller/inc/RangeSelectionListener.hxx +++ /dev/null @@ -1,79 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ -#pragma once - -#include -#include -#include -#include - -namespace com::sun::star::frame -{ -class XModel; -} -namespace weld -{ -class DialogController; -} - -namespace chart -{ -class ChartModel; - -class RangeSelectionListenerParent -{ -public: - virtual void listeningFinished(const OUString& rNewRange) = 0; - virtual void disposingRangeSelection() = 0; - - void enableRangeChoosing(bool bEnable, weld::DialogController* pDialog); - -protected: - ~RangeSelectionListenerParent() {} - -private: - OUString m_sRestorePageIdent; -}; - -class RangeSelectionListener final - : public ::cppu::WeakImplHelper -{ -public: - explicit RangeSelectionListener( - RangeSelectionListenerParent& rParent, OUString aInitialRange, - const rtl::Reference<::chart::ChartModel>& xModelToLockController); - virtual ~RangeSelectionListener() override; - -protected: - // ____ XRangeSelectionListener ____ - virtual void SAL_CALL done(const css::sheet::RangeSelectionEvent& aEvent) override; - virtual void SAL_CALL aborted(const css::sheet::RangeSelectionEvent& aEvent) override; - - // ____ XEventListener ____ - virtual void SAL_CALL disposing(const css::lang::EventObject& Source) override; - -private: - RangeSelectionListenerParent& m_rParent; - OUString m_aRange; - ControllerLockGuardUNO m_aControllerLockGuard; -}; - -} // namespace chart - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/controller/inc/TimerTriggeredControllerLock.hxx b/chart2/source/controller/inc/TimerTriggeredControllerLock.hxx deleted file mode 100644 index 49541b1552d4..000000000000 --- a/chart2/source/controller/inc/TimerTriggeredControllerLock.hxx +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#pragma once - -#include -#include - -#include - -namespace com::sun::star::frame -{ -class XModel; -} -namespace chart -{ -class ControllerLockGuardUNO; -} - -namespace chart -{ -class ChartModel; - -class TimerTriggeredControllerLock final -{ -public: - TimerTriggeredControllerLock(rtl::Reference<::chart::ChartModel> xModel); - ~TimerTriggeredControllerLock(); - - void startTimer(); - -private: - rtl::Reference<::chart::ChartModel> m_xModel; - std::unique_ptr m_apControllerLockGuard; - AutoTimer m_aTimer; - - DECL_LINK(TimerTimeout, Timer*, void); -}; - -} //namespace chart - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/controller/inc/dlg_CreationWizard.hxx b/chart2/source/controller/inc/dlg_CreationWizard.hxx index 1b782632f4d3..556c1ca81bb3 100644 --- a/chart2/source/controller/inc/dlg_CreationWizard.hxx +++ b/chart2/source/controller/inc/dlg_CreationWizard.hxx @@ -19,7 +19,7 @@ #pragma once -#include "TimerTriggeredControllerLock.hxx" +#include #include "TabPageNotifiable.hxx" #include diff --git a/chart2/source/controller/inc/res_ErrorBar.hxx b/chart2/source/controller/inc/res_ErrorBar.hxx index c3521d5ba087..2a1f3645a775 100644 --- a/chart2/source/controller/inc/res_ErrorBar.hxx +++ b/chart2/source/controller/inc/res_ErrorBar.hxx @@ -22,7 +22,7 @@ #include #include #include -#include "RangeSelectionListener.hxx" +#include #include namespace com::sun::star::chart2 { class XChartDocument; } diff --git a/chart2/source/inc/DataBrowserModel.hxx b/chart2/source/inc/DataBrowserModel.hxx new file mode 100644 index 000000000000..16acb2de0b07 --- /dev/null +++ b/chart2/source/inc/DataBrowserModel.hxx @@ -0,0 +1,170 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include "DataSeries.hxx" +#include "ChartType.hxx" + +#include +#include + +#include +#include +#include + +namespace com::sun::star::chart2 { class XChartDocument; } +namespace com::sun::star::uno { class XComponentContext; } + +namespace com::sun::star::chart2 { + class XDataSeries; + class XChartType; +} + +namespace chart +{ + +class DialogModel; +class ChartModel; +class ChartType; +class DataSeries; + +class OOO_DLLPUBLIC_CHARTTOOLS DataBrowserModel final +{ +public: + explicit DataBrowserModel( + const rtl::Reference<::chart::ChartModel> & xChartDoc ); + ~DataBrowserModel(); + + /** Inserts a new data series after the data series to which the data column + with index nAfterColumnIndex belongs. + */ + void insertDataSeries( sal_Int32 nAfterColumnIndex ); + + /** Inserts a new text column for complex categories. + */ + void insertComplexCategoryLevel( sal_Int32 nAfterColumnIndex ); + + /** Removes a data series to which the data column with index nAtColumnIndex + belongs. + */ + void removeDataSeriesOrComplexCategoryLevel( sal_Int32 nAtColumnIndex ); + + /** Swaps the series to which the data column with index nFirstIndex belongs + with the next series (which starts at an index >= nFirstIndex + 1) + */ + void swapDataSeries( sal_Int32 nFirstIndex ); + void swapDataPointForAllSeries( sal_Int32 nFirstIndex ); + + void insertDataPointForAllSeries( sal_Int32 nAfterIndex ); + void removeDataPointForAllSeries( sal_Int32 nAtIndex ); + + enum eCellType + { + NUMBER, + TEXT, + TEXTORDATE + }; + + eCellType getCellType( sal_Int32 nAtColumn ) const; + /// If getCellType( nAtColumn, nAtRow ) returns TEXT, the result will be Nan + double getCellNumber( sal_Int32 nAtColumn, sal_Int32 nAtRow ); + OUString getCellText( sal_Int32 nAtColumn, sal_Int32 nAtRow ); + css::uno::Any getCellAny( sal_Int32 nAtColumn, sal_Int32 nAtRow ); + sal_uInt32 getNumberFormatKey( sal_Int32 nAtColumn ); + + /// returns if the number could successfully be set at the given position + bool setCellNumber( sal_Int32 nAtColumn, sal_Int32 nAtRow, double fValue ); + /// returns if the text could successfully be set at the given position + bool setCellText( sal_Int32 nAtColumn, sal_Int32 nAtRow, const OUString & rText ); + bool setCellAny( sal_Int32 nAtColumn, sal_Int32 nAtRow, const css::uno::Any & aValue ); + + sal_Int32 getColumnCount() const; + sal_Int32 getMaxRowCount() const; + + // returns the UI string of the corresponding role + OUString getRoleOfColumn( sal_Int32 nColumnIndex ) const; + bool isCategoriesColumn( sal_Int32 nColumnIndex ) const; + + struct tDataHeader + { + rtl::Reference< ::chart::DataSeries > m_xDataSeries; + rtl::Reference< ::chart::ChartType > m_xChartType; + bool m_bSwapXAndYAxis; + sal_Int32 m_nStartColumn; + sal_Int32 m_nEndColumn; + + // default CTOR + tDataHeader() : + m_bSwapXAndYAxis( false ), + m_nStartColumn( -1 ), + m_nEndColumn( -1 ) + {} + // "full" CTOR + tDataHeader( + rtl::Reference< ::chart::DataSeries > xDataSeries, + rtl::Reference< ::chart::ChartType > xChartType, + bool bSwapXAndYAxis, + sal_Int32 nStartColumn, + sal_Int32 nEndColumn ) : + m_xDataSeries(std::move( xDataSeries )), + m_xChartType(std::move( xChartType )), + m_bSwapXAndYAxis( bSwapXAndYAxis ), + m_nStartColumn( nStartColumn ), + m_nEndColumn( nEndColumn ) + {} + }; + + typedef std::vector< tDataHeader > tDataHeaderVector; + + const tDataHeaderVector& getDataHeaders() const { return m_aHeaders;} + + tDataHeader getHeaderForSeries( + const css::uno::Reference< css::chart2::XDataSeries > &xSeries ) const; + + rtl::Reference< ::chart::DataSeries > + getDataSeriesByColumn( sal_Int32 nColumn ) const; + +private: + void updateFromModel(); + + void removeComplexCategoryLevel( sal_Int32 nAtColumnIndex ); + + void addErrorBarRanges( + const rtl::Reference<::chart::DataSeries > & xDataSeries, + sal_Int32 nNumberFormatKey, + sal_Int32 & rInOutSequenceIndex, + sal_Int32 & rInOutHeaderEnd, bool bYError ); + + sal_Int32 getCategoryColumnCount(); + + rtl::Reference<::chart::ChartModel> m_xChartDocument; + std::unique_ptr< DialogModel > m_apDialogModel; + + struct tDataColumn; + struct implColumnLess; + + typedef std::vector< tDataColumn > tDataColumnVector; + + tDataColumnVector m_aColumns; + tDataHeaderVector m_aHeaders; +}; + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/InternalDataProvider.hxx b/chart2/source/inc/InternalDataProvider.hxx index a5032efcdab8..26a759c56865 100644 --- a/chart2/source/inc/InternalDataProvider.hxx +++ b/chart2/source/inc/InternalDataProvider.hxx @@ -19,6 +19,7 @@ #pragma once #include "InternalData.hxx" +#include #include #include @@ -30,6 +31,7 @@ #include #include #include +#include #include @@ -101,6 +103,7 @@ public: virtual void SAL_CALL swapDataPointWithNextOneForAllSequences( ::sal_Int32 nAtIndex ) override; virtual void SAL_CALL registerDataSequenceForChanges( const css::uno::Reference< css::chart2::data::XDataSequence >& xSeq ) override; + virtual void SAL_CALL insertDataSeries( ::sal_Int32 nAfterIndex ) override; // ____ XDataProvider (base of XInternalDataProvider) ____ virtual sal_Bool SAL_CALL createDataSourcePossible( @@ -175,6 +178,8 @@ public: // css::lang::XInitialization: virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > & aArguments) override; + void setChartModel(ChartModel* pChartModel); + private: void addDataSequenceToMap( const OUString & rRangeRepresentation, @@ -213,6 +218,9 @@ private: tSequenceMap m_aSequenceMap; InternalData m_aInternalData; bool m_bDataInColumns; + + // keep a weak reference to the owning m_xChartModel for insertDataSeries + unotools::WeakReference m_xChartModel; }; } // namespace chart diff --git a/chart2/source/inc/RangeSelectionHelper.hxx b/chart2/source/inc/RangeSelectionHelper.hxx new file mode 100644 index 000000000000..3afc7fcb511a --- /dev/null +++ b/chart2/source/inc/RangeSelectionHelper.hxx @@ -0,0 +1,73 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include +#include +#include +#include + +#include "charttoolsdllapi.hxx" + +namespace com::sun::star::beans { struct PropertyValue; } +namespace com::sun::star::chart2 { class XChartDocument; } + +namespace com::sun::star { + namespace sheet{ + class XRangeSelection; + class XRangeSelectionListener; + } +} + +namespace chart +{ +class ChartModel; +class RangeSelectionListenerParent; + +class OOO_DLLPUBLIC_CHARTTOOLS RangeSelectionHelper +{ +public: + explicit RangeSelectionHelper( + rtl::Reference<::chart::ChartModel> xChartDocument ); + ~RangeSelectionHelper(); + + bool hasRangeSelection(); + css::uno::Reference< css::sheet::XRangeSelection > const & getRangeSelection(); + void raiseRangeSelectionDocument(); + bool chooseRange( + const OUString & aCurrentRange, + const OUString & aUIString, + RangeSelectionListenerParent & rListenerParent ); + void stopRangeListening( bool bRemoveListener = true ); + bool verifyCellRange( const OUString & rRangeStr ); + bool verifyArguments( const css::uno::Sequence< css::beans::PropertyValue >& rArguments ); + +private: + css::uno::Reference< css::sheet::XRangeSelection > + m_xRangeSelection; + + rtl::Reference<::chart::ChartModel> m_xChartDocument; + + css::uno::Reference< css::sheet::XRangeSelectionListener > + m_xRangeSelectionListener; +}; + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/RangeSelectionListener.hxx b/chart2/source/inc/RangeSelectionListener.hxx new file mode 100644 index 000000000000..7902ff2263a4 --- /dev/null +++ b/chart2/source/inc/RangeSelectionListener.hxx @@ -0,0 +1,79 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include "ControllerLockGuard.hxx" +#include +#include +#include + +namespace com::sun::star::frame +{ +class XModel; +} +namespace weld +{ +class DialogController; +} + +namespace chart +{ +class ChartModel; + +class OOO_DLLPUBLIC_CHARTTOOLS RangeSelectionListenerParent +{ +public: + virtual void listeningFinished(const OUString& rNewRange) = 0; + virtual void disposingRangeSelection() = 0; + + void enableRangeChoosing(bool bEnable, weld::DialogController* pDialog); + +protected: + ~RangeSelectionListenerParent() {} + +private: + OUString m_sRestorePageIdent; +}; + +class RangeSelectionListener final + : public ::cppu::WeakImplHelper +{ +public: + explicit RangeSelectionListener( + RangeSelectionListenerParent& rParent, OUString aInitialRange, + const rtl::Reference<::chart::ChartModel>& xModelToLockController); + virtual ~RangeSelectionListener() override; + +protected: + // ____ XRangeSelectionListener ____ + virtual void SAL_CALL done(const css::sheet::RangeSelectionEvent& aEvent) override; + virtual void SAL_CALL aborted(const css::sheet::RangeSelectionEvent& aEvent) override; + + // ____ XEventListener ____ + virtual void SAL_CALL disposing(const css::lang::EventObject& Source) override; + +private: + RangeSelectionListenerParent& m_rParent; + OUString m_aRange; + ControllerLockGuardUNO m_aControllerLockGuard; +}; + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/TimerTriggeredControllerLock.hxx b/chart2/source/inc/TimerTriggeredControllerLock.hxx new file mode 100644 index 000000000000..7d56fd94369e --- /dev/null +++ b/chart2/source/inc/TimerTriggeredControllerLock.hxx @@ -0,0 +1,60 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include +#include + +#include + +#include "charttoolsdllapi.hxx" + +namespace com::sun::star::frame +{ +class XModel; +} +namespace chart +{ +class ControllerLockGuardUNO; +} + +namespace chart +{ +class ChartModel; + +class OOO_DLLPUBLIC_CHARTTOOLS TimerTriggeredControllerLock final +{ +public: + TimerTriggeredControllerLock(rtl::Reference<::chart::ChartModel> xModel); + ~TimerTriggeredControllerLock(); + + void startTimer(); + +private: + rtl::Reference<::chart::ChartModel> m_xModel; + std::unique_ptr m_apControllerLockGuard; + AutoTimer m_aTimer; + + DECL_LINK(TimerTimeout, Timer*, void); +}; + +} //namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/model/main/ChartModel.cxx b/chart2/source/model/main/ChartModel.cxx index 022446666c2b..bc718c89878d 100644 --- a/chart2/source/model/main/ChartModel.cxx +++ b/chart2/source/model/main/ChartModel.cxx @@ -742,7 +742,10 @@ void SAL_CALL ChartModel::createInternalDataProvider( sal_Bool bCloneExistingDat if( bCloneExistingData ) m_xInternalDataProvider = ChartModelHelper::createInternalDataProvider( this, true ); else + { m_xInternalDataProvider = ChartModelHelper::createInternalDataProvider( nullptr, true ); + m_xInternalDataProvider->setChartModel(this); + } m_xDataProvider.set( m_xInternalDataProvider ); } setModified( true ); diff --git a/chart2/source/tools/InternalDataProvider.cxx b/chart2/source/tools/InternalDataProvider.cxx index 22f3e84a5802..3e1f8372a7b2 100644 --- a/chart2/source/tools/InternalDataProvider.cxx +++ b/chart2/source/tools/InternalDataProvider.cxx @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -298,6 +299,7 @@ InternalDataProvider::InternalDataProvider( { if (!xModel.is()) return; + m_xChartModel = xModel.get(); try { rtl::Reference< Diagram > xDiagram( xModel->getFirstChartDiagram() ); @@ -393,6 +395,11 @@ InternalDataProvider::InternalDataProvider( const InternalDataProvider & rOther InternalDataProvider::~InternalDataProvider() {} +void InternalDataProvider::setChartModel(ChartModel* pChartModel) +{ + m_xChartModel = pChartModel; +} + void InternalDataProvider::addDataSequenceToMap( const OUString & rRangeRepresentation, const Reference< chart2::data::XDataSequence > & xSequence ) @@ -1137,6 +1144,14 @@ void SAL_CALL InternalDataProvider::registerDataSequenceForChanges( const Refere addDataSequenceToMap( xSeq->getSourceRangeRepresentation(), xSeq ); } +void SAL_CALL InternalDataProvider::insertDataSeries(::sal_Int32 nAfterIndex) +{ + // call the dialog insertion + rtl::Reference xChartModel(m_xChartModel); + DataBrowserModel* pDBM = new DataBrowserModel(xChartModel); + pDBM->insertDataSeries(nAfterIndex); +} + // ____ XRangeXMLConversion ____ OUString SAL_CALL InternalDataProvider::convertRangeToXML( const OUString& aRangeRepresentation ) { -- cgit