summaryrefslogtreecommitdiff
path: root/chart2/source/inc
diff options
context:
space:
mode:
Diffstat (limited to 'chart2/source/inc')
-rw-r--r--chart2/source/inc/DataBrowserModel.hxx170
-rw-r--r--chart2/source/inc/InternalDataProvider.hxx8
-rw-r--r--chart2/source/inc/RangeSelectionHelper.hxx73
-rw-r--r--chart2/source/inc/RangeSelectionListener.hxx79
-rw-r--r--chart2/source/inc/TimerTriggeredControllerLock.hxx60
5 files changed, 390 insertions, 0 deletions
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 <com/sun/star/uno/Reference.hxx>
+#include <rtl/ref.hxx>
+
+#include <memory>
+#include <utility>
+#include <vector>
+
+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 </sal_True> if the number could successfully be set at the given position
+ bool setCellNumber( sal_Int32 nAtColumn, sal_Int32 nAtRow, double fValue );
+ /// returns </sal_True> 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 <ChartModel.hxx>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/chart/XDateCategories.hpp>
@@ -30,6 +31,7 @@
#include <cppuhelper/implbase.hxx>
#include <cppuhelper/weakref.hxx>
#include <rtl/ref.hxx>
+#include <unotools/weakref.hxx>
#include <map>
@@ -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<ChartModel> 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 <com/sun/star/uno/Reference.h>
+#include <com/sun/star/uno/Sequence.h>
+#include <rtl/ustring.hxx>
+#include <rtl/ref.hxx>
+
+#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 <cppuhelper/implbase.hxx>
+#include <com/sun/star/sheet/XRangeSelectionListener.hpp>
+#include <rtl/ref.hxx>
+
+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<css::sheet::XRangeSelectionListener>
+{
+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 <vcl/timer.hxx>
+#include <rtl/ref.hxx>
+
+#include <memory>
+
+#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<ControllerLockGuardUNO> m_apControllerLockGuard;
+ AutoTimer m_aTimer;
+
+ DECL_LINK(TimerTimeout, Timer*, void);
+};
+
+} //namespace chart
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */