diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 05:54:39 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 05:54:39 +0000 |
commit | 267c6f2ac71f92999e969232431ba04678e7437e (patch) | |
tree | 358c9467650e1d0a1d7227a21dac2e3d08b622b2 /sc/inc | |
parent | Initial commit. (diff) | |
download | libreoffice-267c6f2ac71f92999e969232431ba04678e7437e.tar.xz libreoffice-267c6f2ac71f92999e969232431ba04678e7437e.zip |
Adding upstream version 4:24.2.0.upstream/4%24.2.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
281 files changed, 56628 insertions, 0 deletions
diff --git a/sc/inc/ChartTools.hxx b/sc/inc/ChartTools.hxx new file mode 100644 index 0000000000..4f1accb1bb --- /dev/null +++ b/sc/inc/ChartTools.hxx @@ -0,0 +1,54 @@ +/* -*- 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/. + * + */ + +#pragma once + +#include <string_view> +#include <memory> +#include <vector> + +#include <svx/svditer.hxx> +#include <tools/long.hxx> +#include "types.hxx" +#include <optional> + +class ScDocShell; +class SdrOle2Obj; + +namespace sc::tools { + +enum class ChartSourceType +{ + CELL_RANGE, + PIVOT_TABLE +}; + +class ChartIterator +{ +private: + std::optional<SdrObjListIter> m_oIterator; + ChartSourceType m_eChartSourceType; +public: + ChartIterator(ScDocShell* pDocShell, SCTAB nTab, ChartSourceType eChartSourceType); + SdrOle2Obj* next(); +}; + +SdrOle2Obj* findChartsByName(ScDocShell* pDocShell, SCTAB nTab, + std::u16string_view rName, + ChartSourceType eChartSourceType); + +SdrOle2Obj* getChartByIndex(ScDocShell* pDocShell, SCTAB nTab, + ::tools::Long nIndex, ChartSourceType eChartSourceType); + +std::vector<SdrOle2Obj*> getAllPivotChartsConnectedTo(std::u16string_view sPivotTableName, ScDocShell* pDocShell); + +} // end sc::tools + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/CommonProperties.hxx b/sc/inc/CommonProperties.hxx new file mode 100644 index 0000000000..4a2931753c --- /dev/null +++ b/sc/inc/CommonProperties.hxx @@ -0,0 +1,34 @@ +/* -*- 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/. + */ + +#pragma once + +#define CELL_BACKGROUND_COLOR_PROPERTIES \ + { SC_UNONAME_CELLBACK, ATTR_BACKGROUND, cppu::UnoType<sal_Int32>::get(), 0, MID_BACK_COLOR }, \ + { SC_UNONAME_CELL_BACKGROUND_COMPLEX_COLOR, ATTR_BACKGROUND, cppu::UnoType<css::util::XComplexColor>::get(), 0, MID_BACKGROUND_COMPLEX_COLOR }, \ + +#define CHAR_COLOR_PROPERTIES \ + { SC_UNONAME_CCOLOR, ATTR_FONT_COLOR, cppu::UnoType<sal_Int32>::get(), 0, MID_COLOR_RGB }, \ + { SC_UNONAME_CHAR_COMPLEX_COLOR, ATTR_FONT_COLOR, cppu::UnoType<css::util::XComplexColor>::get(), 0, MID_COMPLEX_COLOR }, \ + +#define CELL_BORDER_PROPERTIES \ + { SC_UNONAME_BOTTBORDER, ATTR_BORDER, cppu::UnoType<table::BorderLine>::get(), 0, BOTTOM_BORDER | CONVERT_TWIPS }, \ + { SC_UNONAME_BOTTBORDER2, ATTR_BORDER, cppu::UnoType<table::BorderLine2>::get(), 0, BOTTOM_BORDER | CONVERT_TWIPS }, \ + { SC_UNONAME_LEFTBORDER, ATTR_BORDER, cppu::UnoType<table::BorderLine>::get(), 0, LEFT_BORDER | CONVERT_TWIPS }, \ + { SC_UNONAME_LEFTBORDER2, ATTR_BORDER, cppu::UnoType<table::BorderLine2>::get(), 0, LEFT_BORDER | CONVERT_TWIPS }, \ + { SC_UNONAME_RIGHTBORDER, ATTR_BORDER, cppu::UnoType<table::BorderLine>::get(), 0, RIGHT_BORDER | CONVERT_TWIPS }, \ + { SC_UNONAME_RIGHTBORDER2, ATTR_BORDER, cppu::UnoType<table::BorderLine2>::get(), 0, RIGHT_BORDER | CONVERT_TWIPS }, \ + { SC_UNONAME_TOPBORDER, ATTR_BORDER, cppu::UnoType<table::BorderLine>::get(), 0, TOP_BORDER | CONVERT_TWIPS }, \ + { SC_UNONAME_TOPBORDER2, ATTR_BORDER, cppu::UnoType<table::BorderLine2>::get(), 0, TOP_BORDER | CONVERT_TWIPS }, \ + { SC_UNONAME_BOTTOM_BORDER_COMPLEX_COLOR, ATTR_BORDER, cppu::UnoType<util::XComplexColor>::get(), 0, MID_BORDER_BOTTOM_COLOR }, \ + { SC_UNONAME_LEFT_BORDER_COMPLEX_COLOR, ATTR_BORDER, cppu::UnoType<util::XComplexColor>::get(), 0, MID_BORDER_LEFT_COLOR }, \ + { SC_UNONAME_RIGHT_BORDER_COMPLEX_COLOR, ATTR_BORDER, cppu::UnoType<util::XComplexColor>::get(), 0, MID_BORDER_RIGHT_COLOR }, \ + { SC_UNONAME_TOP_BORDER_COMPLEX_COLOR, ATTR_BORDER, cppu::UnoType<util::XComplexColor>::get(), 0, MID_BORDER_TOP_COLOR }, \ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/NumberFormatControl.hxx b/sc/inc/NumberFormatControl.hxx new file mode 100644 index 0000000000..868a6ca002 --- /dev/null +++ b/sc/inc/NumberFormatControl.hxx @@ -0,0 +1,42 @@ +/* -*- 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 <sfx2/tbxctrl.hxx> + + +namespace sc { + +class ScNumberFormatControl final : public SfxToolBoxControl +{ +public: + SFX_DECL_TOOLBOX_CONTROL(); + + ScNumberFormatControl(sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox& rTbx); + virtual ~ScNumberFormatControl() override; + + virtual void StateChangedAtToolBoxControl(sal_uInt16 nSID, SfxItemState eState, + const SfxPoolItem* pState) override; + virtual VclPtr<InterimItemWindow> CreateItemWindow( vcl::Window *pParent ) override; +}; + +} // end of namespace sc + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/PivotTableDataProvider.hxx b/sc/inc/PivotTableDataProvider.hxx new file mode 100644 index 0000000000..a1df012cca --- /dev/null +++ b/sc/inc/PivotTableDataProvider.hxx @@ -0,0 +1,184 @@ +/* -*- 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/. + */ + +#pragma once + +#include <com/sun/star/chart2/data/XDataProvider.hpp> +#include <com/sun/star/chart2/data/XPivotTableDataProvider.hpp> +#include <com/sun/star/chart2/data/PivotTableFieldEntry.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/util/XModifyBroadcaster.hpp> + +#include <svl/lstner.hxx> +#include <cppuhelper/implbase.hxx> +#include <rtl/ustring.hxx> +#include <svl/itemprop.hxx> + +#include <vector> +#include <unordered_map> + +namespace com::sun::star::chart2::data { class XDataSequence; } +namespace com::sun::star::chart2::data { class XDataSource; } +namespace com::sun::star::chart2::data { class XLabeledDataSequence; } +namespace com::sun::star::uno { class XComponentContext; } + +class ScDocument; + +namespace sc +{ + +struct ValueAndFormat; + +typedef cppu::WeakImplHelper<css::chart2::data::XDataProvider, + css::chart2::data::XPivotTableDataProvider, + css::beans::XPropertySet, + css::lang::XServiceInfo, + css::util::XModifyBroadcaster> + PivotTableDataProvider_Base; + +class PivotTableDataProvider final : public PivotTableDataProvider_Base, public SfxListener +{ +public: + + explicit PivotTableDataProvider(ScDocument& rDoc); + virtual ~PivotTableDataProvider() override; + virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override; + + // XDataProvider + virtual sal_Bool SAL_CALL + createDataSourcePossible(const css::uno::Sequence<css::beans::PropertyValue>& aArguments) override; + + virtual css::uno::Reference<css::chart2::data::XDataSource> SAL_CALL + createDataSource(const css::uno::Sequence<css::beans::PropertyValue>& aArguments) override; + + virtual css::uno::Sequence<css::beans::PropertyValue> SAL_CALL + detectArguments(const css::uno::Reference<css::chart2::data::XDataSource>& xDataSource) override; + + virtual sal_Bool SAL_CALL + createDataSequenceByRangeRepresentationPossible(const OUString& aRangeRepresentation) override; + + virtual css::uno::Reference<css::chart2::data::XDataSequence> SAL_CALL + createDataSequenceByRangeRepresentation(const OUString& aRangeRepresentation) override; + + virtual css::uno::Reference<css::chart2::data::XDataSequence> SAL_CALL + createDataSequenceByValueArray(const OUString& aRole, const OUString& aRangeRepresentation, + const OUString& aRoleQualifier) override; + + virtual css::uno::Reference<css::sheet::XRangeSelection> SAL_CALL getRangeSelection() override; + + // XPivotTableDataProvider + virtual css::uno::Sequence<css::chart2::data::PivotTableFieldEntry> SAL_CALL + getColumnFields() override; + virtual css::uno::Sequence<css::chart2::data::PivotTableFieldEntry> SAL_CALL + getRowFields() override; + virtual css::uno::Sequence<css::chart2::data::PivotTableFieldEntry> SAL_CALL + getPageFields() override; + virtual css::uno::Sequence<css::chart2::data::PivotTableFieldEntry> SAL_CALL + getDataFields() override; + + virtual OUString SAL_CALL getPivotTableName() override; + + virtual void SAL_CALL setPivotTableName(const OUString& sPivotTableName) override; + + virtual sal_Bool SAL_CALL hasPivotTable() override; + + virtual css::uno::Reference<css::chart2::data::XDataSequence> SAL_CALL + createDataSequenceOfValuesByIndex(sal_Int32 nIndex) override; + virtual css::uno::Reference<css::chart2::data::XDataSequence> SAL_CALL + createDataSequenceOfLabelsByIndex(sal_Int32 nIndex) override; + virtual css::uno::Reference<css::chart2::data::XDataSequence> SAL_CALL + createDataSequenceOfCategories() override; + + virtual OUString SAL_CALL getFieldOutputDescription(sal_Int32 nPageFieldIndex) override; + + // XPropertySet + virtual css::uno::Reference<css::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() override; + + virtual void SAL_CALL + setPropertyValue(const OUString& rPropertyName, const css::uno::Any& rValue) override; + + virtual css::uno::Any SAL_CALL + getPropertyValue(const OUString& rPropertyName) override; + + virtual void SAL_CALL addPropertyChangeListener( + const OUString& rPropertyName, + const css::uno::Reference<css::beans::XPropertyChangeListener>& xListener) override; + + virtual void SAL_CALL removePropertyChangeListener( + const OUString& rPropertyName, + const css::uno::Reference<css::beans::XPropertyChangeListener>& rListener) override; + + virtual void SAL_CALL addVetoableChangeListener( + const OUString& rPropertyName, + const css::uno::Reference<css::beans::XVetoableChangeListener>& rListener) override; + + virtual void SAL_CALL removeVetoableChangeListener( + const OUString& rPropertyName, + const css::uno::Reference<css::beans::XVetoableChangeListener>& rListener) override; + + // XModifyBroadcaster + virtual void SAL_CALL + addModifyListener(const css::uno::Reference<css::util::XModifyListener>& aListener) override; + + virtual void SAL_CALL + removeModifyListener(const css::uno::Reference<css::util::XModifyListener>& aListener) override; + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + + virtual sal_Bool SAL_CALL supportsService(const OUString& rServiceName) override; + + virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; + +private: + + css::uno::Reference<css::chart2::data::XDataSource> + createValuesDataSource(); + + css::uno::Reference<css::chart2::data::XDataSource> + createCategoriesDataSource(bool bOrientationIsColumn); + + css::uno::Reference<css::chart2::data::XLabeledDataSequence> newLabeledDataSequence(); + + css::uno::Reference<css::chart2::data::XDataSequence> assignLabelsToDataSequence(size_t nIndex); + + css::uno::Reference<css::chart2::data::XDataSequence> assignValuesToDataSequence(size_t nIndex); + + css::uno::Reference<css::chart2::data::XDataSequence> assignFirstCategoriesToDataSequence(); + + void collectPivotTableData(); + + ScDocument* m_pDocument; + OUString m_sPivotTableName; + SfxItemPropertySet m_aPropSet; + bool m_bIncludeHiddenCells; + + std::vector<std::vector<ValueAndFormat>> m_aCategoriesColumnOrientation; + std::vector<std::vector<ValueAndFormat>> m_aCategoriesRowOrientation; + std::vector<std::vector<ValueAndFormat>> m_aLabels; + std::vector<std::vector<ValueAndFormat>> m_aDataRowVector; + + std::vector<css::chart2::data::PivotTableFieldEntry> m_aColumnFields; + std::vector<css::chart2::data::PivotTableFieldEntry> m_aRowFields; + std::vector<css::chart2::data::PivotTableFieldEntry> m_aPageFields; + std::vector<css::chart2::data::PivotTableFieldEntry> m_aDataFields; + + std::unordered_map<sal_Int32, OUString> m_aFieldOutputDescriptionMap; + + bool m_bNeedsUpdate; + + css::uno::Reference<css::uno::XComponentContext> m_xContext; + + std::vector<css::uno::Reference<css::util::XModifyListener>> m_aValueListeners; +}; + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/PivotTableDataSequence.hxx b/sc/inc/PivotTableDataSequence.hxx new file mode 100644 index 0000000000..b92d736545 --- /dev/null +++ b/sc/inc/PivotTableDataSequence.hxx @@ -0,0 +1,167 @@ +/* -*- 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/. + */ + +#pragma once + +#include <com/sun/star/chart2/data/XDataSequence.hpp> +#include <com/sun/star/chart2/data/XTextualDataSequence.hpp> +#include <com/sun/star/chart2/data/XNumericalDataSequence.hpp> +#include <com/sun/star/chart2/data/DataSequenceRole.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/util/XCloneable.hpp> +#include <com/sun/star/util/XModifyBroadcaster.hpp> + + +#include <svl/lstner.hxx> +#include <svl/itemprop.hxx> +#include <cppuhelper/implbase.hxx> + +#include <limits> +#include <utility> + +class ScDocument; + +namespace sc +{ + +enum class ValueType +{ + Empty, + String, + Numeric +}; + +struct ValueAndFormat +{ + double m_fValue; + OUString m_aString; + ValueType m_eType; + sal_uInt32 m_nNumberFormat; + + explicit ValueAndFormat() + : m_fValue(std::numeric_limits<double>::quiet_NaN()) + , m_aString() + , m_eType(ValueType::Empty) + , m_nNumberFormat(0) + { + } + + explicit ValueAndFormat(double fValue, sal_uInt32 nNumberFormat) + : m_fValue(fValue) + , m_aString() + , m_eType(ValueType::Numeric) + , m_nNumberFormat(nNumberFormat) + {} + + explicit ValueAndFormat(OUString aString) + : m_fValue(std::numeric_limits<double>::quiet_NaN()) + , m_aString(std::move(aString)) + , m_eType(ValueType::String) + , m_nNumberFormat(0) + { + } +}; + +typedef cppu::WeakImplHelper<css::chart2::data::XDataSequence, + css::chart2::data::XTextualDataSequence, + css::chart2::data::XNumericalDataSequence, + css::util::XCloneable, + css::util::XModifyBroadcaster, + css::beans::XPropertySet, + css::lang::XServiceInfo> + PivotTableDataSequence_Base; + +class PivotTableDataSequence final : public PivotTableDataSequence_Base, public SfxListener +{ +public: + explicit PivotTableDataSequence(ScDocument* pDocument, + OUString sID, std::vector<ValueAndFormat>&& rData); + + virtual ~PivotTableDataSequence() override; + PivotTableDataSequence(const PivotTableDataSequence&) = delete; + PivotTableDataSequence& operator=(const PivotTableDataSequence&) = delete; + + virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override; + + // XDataSequence + virtual css::uno::Sequence<css::uno::Any> SAL_CALL getData() override; + virtual OUString SAL_CALL getSourceRangeRepresentation() override; + virtual css::uno::Sequence<OUString> SAL_CALL + generateLabel(css::chart2::data::LabelOrigin nOrigin) override; + + virtual sal_Int32 SAL_CALL getNumberFormatKeyByIndex(sal_Int32 nIndex) override; + + // XNumericalDataSequence + virtual css::uno::Sequence<double> SAL_CALL getNumericalData() override; + + // XTextualDataSequence + virtual css::uno::Sequence<OUString> SAL_CALL getTextualData() override; + + // XPropertySet + virtual css::uno::Reference<css::beans::XPropertySetInfo> SAL_CALL + getPropertySetInfo() override; + + virtual void SAL_CALL setPropertyValue(const OUString& rPropertyName, + const css::uno::Any& rValue) override; + + virtual css::uno::Any SAL_CALL getPropertyValue(const OUString& rPropertyName) override; + + virtual void SAL_CALL addPropertyChangeListener( + const OUString& rPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener>& xListener) override; + + virtual void SAL_CALL removePropertyChangeListener( + const OUString& rPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener>& rListener) override; + + virtual void SAL_CALL addVetoableChangeListener( + const OUString& rPropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener>& rListener) override; + + virtual void SAL_CALL removeVetoableChangeListener( + const OUString& rPropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener>& rListener) override; + + // XCloneable + virtual css::uno::Reference<css::util::XCloneable> SAL_CALL createClone() override; + + // XModifyBroadcaster + virtual void SAL_CALL addModifyListener( + const css::uno::Reference<css::util::XModifyListener>& aListener) override; + + virtual void SAL_CALL removeModifyListener( + const css::uno::Reference<css::util::XModifyListener>& aListener) override; + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + + virtual sal_Bool SAL_CALL supportsService(const OUString& rServiceName) override; + + virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; + + // Other + + void setRole(css::chart2::data::DataSequenceRole const & aRole) + { + m_aRole = aRole; + } + +private: + ScDocument* m_pDocument; + OUString m_aID; + std::vector<ValueAndFormat> m_aData; + SfxItemPropertySet m_aPropSet; + css::chart2::data::DataSequenceRole m_aRole; + std::vector<css::uno::Reference<css::util::XModifyListener>> m_aValueListeners; +}; + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/PivotTableDataSource.hxx b/sc/inc/PivotTableDataSource.hxx new file mode 100644 index 0000000000..636746b79c --- /dev/null +++ b/sc/inc/PivotTableDataSource.hxx @@ -0,0 +1,53 @@ +/* -*- 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/. + */ + +#pragma once + +#include <com/sun/star/chart2/data/XDataSource.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> + +#include <svl/lstner.hxx> +#include <cppuhelper/implbase.hxx> +#include <vector> + +namespace com::sun::star::chart2::data { class XLabeledDataSequence; } + +namespace sc +{ + +typedef cppu::WeakImplHelper<css::chart2::data::XDataSource, + css::lang::XServiceInfo> + PivotTableDataSource_Base; + +class PivotTableDataSource final : public PivotTableDataSource_Base, public SfxListener +{ +public: + explicit PivotTableDataSource(std::vector<css::uno::Reference<css::chart2::data::XLabeledDataSequence>>&& xLabeledSequence); + virtual ~PivotTableDataSource() override; + virtual void Notify(SfxBroadcaster& rBroadcaster, const SfxHint& rHint) override; + + // XDataSource + virtual css::uno::Sequence<css::uno::Reference<css::chart2::data::XLabeledDataSequence>> SAL_CALL + getDataSequences() override; + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + + virtual sal_Bool SAL_CALL supportsService(const OUString& rServiceName) override; + + virtual css::uno::Sequence<OUString> SAL_CALL + getSupportedServiceNames() override; + +private: + std::vector<css::uno::Reference<css::chart2::data::XLabeledDataSequence>> m_xLabeledSequence; +}; + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/SolverSettings.hxx b/sc/inc/SolverSettings.hxx new file mode 100644 index 0000000000..ec1ef994a7 --- /dev/null +++ b/sc/inc/SolverSettings.hxx @@ -0,0 +1,209 @@ +/* -*- 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/. + * + */ + +#pragma once + +#include <memory> +#include <utility> +#include <variant> +#include <rtl/ustring.hxx> +#include <com/sun/star/beans/PropertyValue.hpp> + +class ScTable; +class ScDocShell; + +namespace sc +{ +// These values are MS compatible +enum ObjectiveType +{ + OT_MAXIMIZE = 1, + OT_MINIMIZE = 2, + OT_VALUE = 3 +}; + +enum SolverParameter +{ + SP_OBJ_CELL, // Objective cell + SP_OBJ_TYPE, // Objective type (max, min, value) + SP_OBJ_VAL, // Value (used when objective is of type "value") + SP_VAR_CELLS, // Variable cells + SP_CONSTR_COUNT, // Number of constraints (MSO only) + SP_LO_ENGINE, // Engine name used in LO + SP_MS_ENGINE, // Engine ID used in MSO + SP_INTEGER, // Assume all variables are integer (0: no, 1: yes) + SP_NON_NEGATIVE, // Assume non negativity (1: yes, 2: no) + SP_EPSILON_LEVEL, // Epsilon level + SP_LIMIT_BBDEPTH, // Branch and bound depth + SP_TIMEOUT, // Time limit to return a solution + SP_ALGORITHM // Algorithm used by the SwarmSolver (1, 2 or 3) +}; + +// Starts at 1 to maintain MS compatibility +enum ConstraintOperator +{ + CO_LESS_EQUAL = 1, + CO_EQUAL = 2, + CO_GREATER_EQUAL = 3, + CO_INTEGER = 4, + CO_BINARY = 5 +}; + +// Parts of a constraint +enum ConstraintPart +{ + CP_LEFT_HAND_SIDE, + CP_OPERATOR, + CP_RIGHT_HAND_SIDE +}; + +// Stores the information of a single constraint (condition) +struct ModelConstraint +{ + OUString aLeftStr; + ConstraintOperator nOperator; + OUString aRightStr; + + ModelConstraint() + : nOperator(CO_LESS_EQUAL) + { + } + bool IsDefault() const + { + return aLeftStr.isEmpty() && aRightStr.isEmpty() && nOperator == CO_LESS_EQUAL; + } +}; + +/* Class SolverSettings + * + * This class is used to load/save and manipulate solver settings in a Calc tab. + * + * During initialization, (see Initialize() method) all settings stored in the tab are loaded onto + * the object. Settings that are not defined use default values. + * + * Read/Write methods are private and are used internally to load/write solver settings from + * named ranges associated with the sheet. + * + * Get/Set methods are public methods used to change object properties (they do not save data + * to the file). + * + * The method SaveSolverSettings() is used to create the named ranges containing the current + * property values into the file. + * + */ + +class SolverSettings +{ +private: + ScTable& m_rTable; + ScDocument& m_rDoc; + ScDocShell* m_pDocShell; + + // Used to read/write the named ranges in the tab + ScRangeName* m_pRangeName; + + OUString m_sObjCell; + ObjectiveType m_eObjType; + OUString m_sObjVal; + OUString m_sVariableCells; + OUString m_sLOEngineName; + OUString m_sMSEngineId; + + // Solver engine options + OUString m_sInteger; + OUString m_sNonNegative; + OUString m_sEpsilonLevel; + OUString m_sLimitBBDepth; + OUString m_sTimeout; + OUString m_sAlgorithm; + css::uno::Sequence<css::beans::PropertyValue> m_aEngineOptions; + + std::vector<ModelConstraint> m_aConstraints; + + void Initialize(); + + // Used to create or read a single solver parameter based on its named range + bool ReadParamValue(SolverParameter eParam, OUString& rValue, bool bRemoveQuotes = false); + void WriteParamValue(SolverParameter eParam, OUString sValue, bool bQuoted = false); + + // Creates or reads all constraints stored in named ranges + void ReadConstraints(); + void WriteConstraints(); + + // Used to create or get a single constraint part + bool ReadConstraintPart(ConstraintPart ePart, tools::Long nIndex, OUString& rValue); + void WriteConstraintPart(ConstraintPart ePart, tools::Long nIndex, OUString sValue); + + // Creates or reads all named ranges associated with solver engine options + void ReadEngine(); + void WriteEngine(); + + void DeleteAllNamedRanges(); + + // Maps solver parameters to named ranges + std::map<SolverParameter, OUString> m_mNamedRanges + = { { SP_OBJ_CELL, "solver_opt" }, { SP_OBJ_TYPE, "solver_typ" }, + { SP_OBJ_VAL, "solver_val" }, { SP_VAR_CELLS, "solver_adj" }, + { SP_CONSTR_COUNT, "solver_num" }, { SP_LO_ENGINE, "solver_lo_eng" }, + { SP_MS_ENGINE, "solver_eng" }, { SP_INTEGER, "solver_int" }, + { SP_NON_NEGATIVE, "solver_neg" }, { SP_EPSILON_LEVEL, "solver_eps" }, + { SP_LIMIT_BBDEPTH, "solver_bbd" }, { SP_TIMEOUT, "solver_tim" }, + { SP_ALGORITHM, "solver_alg" } }; + + // Maps LO solver implementation names to MS engine codes + std::map<OUString, OUString> SolverNamesToExcelEngines = { + { "com.sun.star.comp.Calc.CoinMPSolver", "2" }, // Simplex LP + { "com.sun.star.comp.Calc.LpsolveSolver", "2" }, // Simplex LP + { "com.sun.star.comp.Calc.SwarmSolver", "1" } // GRG Nonlinear + }; + + // Maps MS solver engine codes to LO solver implementation names + std::map<OUString, OUString> SolverCodesToLOEngines = { + { "1", "com.sun.star.comp.Calc.SwarmSolver" }, // GRG Nonlinear + { "2", "com.sun.star.comp.Calc.CoinMPSolver" }, // Simplex LP + { "3", "com.sun.star.comp.Calc.SwarmSolver" } // Evolutionary + }; + + // Maps LO solver parameters to named ranges to be used + // NonNegative: for MS compatibility, use 1 for selected and 2 for not selected + typedef std::vector<std::variant<OUString, SolverParameter>> TParamInfo; + std::map<OUString, TParamInfo> SolverParamNames + = { { "Integer", { SP_INTEGER, "solver_int", "bool" } }, + { "NonNegative", { SP_NON_NEGATIVE, "solver_neg", "bool" } }, + { "EpsilonLevel", { SP_EPSILON_LEVEL, "solver_eps", "int" } }, + { "LimitBBDepth", { SP_LIMIT_BBDEPTH, "solver_bbd", "bool" } }, + { "Timeout", { SP_TIMEOUT, "solver_tim", "int" } }, + { "Algorithm", { SP_ALGORITHM, "solver_alg", "int" } } }; + + // Stores the roots used for named ranges of constraint parts + // Items here must be in the same order as in ConstraintPart enum + std::vector<OUString> m_aConstraintParts{ "solver_lhs", "solver_rel", "solver_rhs" }; + +public: + /* A SolverSettings object is linked to the ScTable where solver parameters + * are located and saved to */ + SolverSettings(ScTable& pTable); + + SC_DLLPUBLIC OUString GetParameter(SolverParameter eParam); + SC_DLLPUBLIC void SetParameter(SolverParameter eParam, OUString sValue); + SC_DLLPUBLIC ObjectiveType GetObjectiveType() { return m_eObjType; } + SC_DLLPUBLIC void SetObjectiveType(ObjectiveType eType); + SC_DLLPUBLIC void GetEngineOptions(css::uno::Sequence<css::beans::PropertyValue>& aOptions); + SC_DLLPUBLIC void SetEngineOptions(css::uno::Sequence<css::beans::PropertyValue>& aOptions); + SC_DLLPUBLIC std::vector<ModelConstraint> GetConstraints() { return m_aConstraints; } + SC_DLLPUBLIC void SetConstraints(std::vector<ModelConstraint> aConstraints); + + SC_DLLPUBLIC void SaveSolverSettings(); + SC_DLLPUBLIC void ResetToDefaults(); +}; + +} // namespace sc + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/Sparkline.hxx b/sc/inc/Sparkline.hxx new file mode 100644 index 0000000000..236c4dc365 --- /dev/null +++ b/sc/inc/Sparkline.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/. + * + */ + +#pragma once + +#include "scdllapi.h" +#include "rangelst.hxx" +#include <memory> +#include <utility> + +namespace sc +{ +class SparklineGroup; + +/** Sparkline data, used for rendering the content of a cell + * + * Contains the input range of the data that is being drawn and a reference + * to the SparklineGroup, which includes common properties of multiple + * sparklines. + */ +class SC_DLLPUBLIC Sparkline +{ + SCCOL m_nColumn; + SCROW m_nRow; + + ScRangeList m_aInputRange; + std::shared_ptr<SparklineGroup> m_pSparklineGroup; + +public: + Sparkline(SCCOL nColumn, SCROW nRow, std::shared_ptr<SparklineGroup> pSparklineGroup) + : m_nColumn(nColumn) + , m_nRow(nRow) + , m_pSparklineGroup(std::move(pSparklineGroup)) + { + } + + Sparkline(const Sparkline&) = delete; + Sparkline& operator=(const Sparkline&) = delete; + + void setInputRange(ScRangeList const& rInputRange) { m_aInputRange = rInputRange; } + + ScRangeList const& getInputRange() const { return m_aInputRange; } + + std::shared_ptr<SparklineGroup> const& getSparklineGroup() const { return m_pSparklineGroup; } + + SCCOL getColumn() const { return m_nColumn; } + + SCROW getRow() const { return m_nRow; } +}; + +} // end sc + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/SparklineAttributes.hxx b/sc/inc/SparklineAttributes.hxx new file mode 100644 index 0000000000..04a6c0abb6 --- /dev/null +++ b/sc/inc/SparklineAttributes.hxx @@ -0,0 +1,148 @@ +/* -*- 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/. + * + */ + +#pragma once + +#include "scdllapi.h" +#include <sal/types.h> +#include <tools/color.hxx> +#include <docmodel/color/ComplexColor.hxx> +#include <optional> +#include <o3tl/cow_wrapper.hxx> + +namespace sc +{ +/** Supported sparkline types */ +enum class SparklineType +{ + Line, + Column, + Stacked +}; + +/** The method of calculating the axis min or max value */ +enum class AxisType +{ + Individual, // calculate the min/max of a sparkline + Group, // calculate the min or max of the whole sparkline group + Custom // user defined +}; + +/** Determines how to display the empty cells */ +enum class DisplayEmptyCellsAs +{ + Span, + Gap, + Zero // empty cell equals zero +}; + +/** Common properties for a group of sparklines */ +class SC_DLLPUBLIC SparklineAttributes +{ +private: + class Implementation; + o3tl::cow_wrapper<Implementation> m_aImplementation; + +public: + SparklineAttributes(); + ~SparklineAttributes(); + SparklineAttributes(const SparklineAttributes& rOther); + SparklineAttributes(SparklineAttributes&& rOther); + SparklineAttributes& operator=(const SparklineAttributes& rOther); + SparklineAttributes& operator=(SparklineAttributes&& rOther); + + bool operator==(const SparklineAttributes& rOther) const; + bool operator!=(const SparklineAttributes& rOther) const + { + return !(SparklineAttributes::operator==(rOther)); + } + + void resetColors(); + + model::ComplexColor getColorSeries() const; + void setColorSeries(model::ComplexColor const& rColorSeries); + + model::ComplexColor getColorNegative() const; + void setColorNegative(model::ComplexColor const& rColorSeries); + + model::ComplexColor getColorAxis() const; + void setColorAxis(model::ComplexColor const& rColorSeries); + + model::ComplexColor getColorMarkers() const; + void setColorMarkers(model::ComplexColor const& rColorSeries); + + model::ComplexColor getColorFirst() const; + void setColorFirst(model::ComplexColor const& rColorSeries); + + model::ComplexColor getColorLast() const; + void setColorLast(model::ComplexColor const& rColorSeries); + + model::ComplexColor getColorHigh() const; + void setColorHigh(model::ComplexColor const& rColorSeries); + + model::ComplexColor getColorLow() const; + void setColorLow(model::ComplexColor const& rColorSeries); + + AxisType getMinAxisType() const; + void setMinAxisType(AxisType eAxisType); + + AxisType getMaxAxisType() const; + void setMaxAxisType(AxisType eAxisType); + + /** Line weight or width in points */ + double getLineWeight() const; + void setLineWeight(double nWeight); + + SparklineType getType() const; + void setType(SparklineType eType); + + bool isDateAxis() const; + void setDateAxis(bool bValue); + + DisplayEmptyCellsAs getDisplayEmptyCellsAs() const; + void setDisplayEmptyCellsAs(DisplayEmptyCellsAs eValue); + + bool isMarkers() const; + void setMarkers(bool bValue); + + bool isHigh() const; + void setHigh(bool bValue); + + bool isLow() const; + void setLow(bool bValue); + + bool isFirst() const; + void setFirst(bool bValue); + + bool isLast() const; + void setLast(bool bValue); + + bool isNegative() const; + void setNegative(bool bValue); + + bool shouldDisplayXAxis() const; + void setDisplayXAxis(bool bValue); + + bool shouldDisplayHidden() const; + void setDisplayHidden(bool bValue); + + bool isRightToLeft() const; + void setRightToLeft(bool bValue); + + std::optional<double> getManualMax() const; + void setManualMax(std::optional<double> aValue); + + std::optional<double> getManualMin() const; + void setManualMin(std::optional<double> aValue); +}; + +} // end sc + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/SparklineCell.hxx b/sc/inc/SparklineCell.hxx new file mode 100644 index 0000000000..28a7b42498 --- /dev/null +++ b/sc/inc/SparklineCell.hxx @@ -0,0 +1,49 @@ +/* -*- 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/. + * + */ + +#pragma once + +#include "scdllapi.h" +#include "Sparkline.hxx" +#include <memory> +#include <utility> + +namespace sc +{ +/** Holder of a sparkline, that is connected to a cell specific */ +class SC_DLLPUBLIC SparklineCell +{ +private: + std::shared_ptr<Sparkline> m_pSparkline; + +public: + SparklineCell(std::shared_ptr<Sparkline> pSparkline) + : m_pSparkline(std::move(pSparkline)) + { + } + + SparklineCell(const SparklineCell&) = delete; + SparklineCell& operator=(const SparklineCell&) = delete; + + void setInputRange(ScRangeList const& rInputRange) { m_pSparkline->setInputRange(rInputRange); } + + ScRangeList const& getInputRange() { return m_pSparkline->getInputRange(); } + + std::shared_ptr<SparklineGroup> const& getSparklineGroup() const + { + return m_pSparkline->getSparklineGroup(); + } + + std::shared_ptr<Sparkline> const& getSparkline() const { return m_pSparkline; } +}; + +} // end sc + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/SparklineData.hxx b/sc/inc/SparklineData.hxx new file mode 100644 index 0000000000..c004abbd73 --- /dev/null +++ b/sc/inc/SparklineData.hxx @@ -0,0 +1,44 @@ +/* -*- 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/. + * + */ + +#pragma once + +#include "address.hxx" +#include "scdllapi.h" + +namespace sc +{ +/** Data defining a sparkline - input data and output position */ +struct SC_DLLPUBLIC SparklineData +{ + ScAddress maPosition; + ScRange maData; + + SparklineData(ScAddress const& rPosition, ScRange const& rData) + : maPosition(rPosition) + , maData(rData) + { + } +}; + +enum class RangeOrientation +{ + Unknown, + Row, + Col +}; + +/** Determine the sparkline group orientation for the input data the output size */ +SC_DLLPUBLIC RangeOrientation calculateOrientation(sal_Int32 nOutputSize, + ScRange const& rInputRange); + +} // end sc + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/SparklineGroup.hxx b/sc/inc/SparklineGroup.hxx new file mode 100644 index 0000000000..c79067c125 --- /dev/null +++ b/sc/inc/SparklineGroup.hxx @@ -0,0 +1,47 @@ +/* -*- 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/. + * + */ + +#pragma once + +#include "scdllapi.h" +#include "SparklineAttributes.hxx" +#include <tools/color.hxx> +#include <tools/Guid.hxx> +#include <optional> + +namespace sc +{ +/** Common properties for a group of sparklines */ +class SC_DLLPUBLIC SparklineGroup +{ +private: + SparklineAttributes m_aAttributes; + tools::Guid m_aGUID; + +public: + SparklineAttributes& getAttributes() { return m_aAttributes; } + SparklineAttributes const& getAttributes() const { return m_aAttributes; } + + void setAttributes(SparklineAttributes const& rAttributes) { m_aAttributes = rAttributes; }; + + tools::Guid& getID() { return m_aGUID; } + + void setID(tools::Guid const& rGuid) { m_aGUID = rGuid; } + + SparklineGroup(); + SparklineGroup(SparklineGroup const& pOtherSparkline); + SparklineGroup(SparklineAttributes aSparklineAttributes); + + SparklineGroup& operator=(const SparklineGroup&) = delete; +}; + +} // end sc + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/SparklineList.hxx b/sc/inc/SparklineList.hxx new file mode 100644 index 0000000000..e9ca859123 --- /dev/null +++ b/sc/inc/SparklineList.hxx @@ -0,0 +1,49 @@ +/* -*- 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/. + * + */ + +#pragma once + +#include "scdllapi.h" +#include <memory> +#include <map> + +#include "Sparkline.hxx" +#include "SparklineGroup.hxx" + +namespace sc +{ +/** Tracks and gathers all created sparklines and sparkline groups. + * + * All the collections of sparkline groups and sparklines don't take + * the ownership of the pointers. + */ +class SC_DLLPUBLIC SparklineList +{ +private: + std::vector<std::weak_ptr<SparklineGroup>> m_aSparklineGroups; + std::map<std::weak_ptr<SparklineGroup>, std::vector<std::weak_ptr<Sparkline>>, + std::owner_less<>> + m_aSparklineGroupMap; + +public: + SparklineList(); + + void addSparkline(std::shared_ptr<Sparkline> const& pSparkline); + void removeSparkline(std::shared_ptr<Sparkline> const& pSparkline); + + std::vector<std::shared_ptr<SparklineGroup>> getSparklineGroups(); + + std::vector<std::shared_ptr<Sparkline>> + getSparklinesFor(std::shared_ptr<SparklineGroup> const& pSparklineGroup); +}; + +} // end sc + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/TablePivotChart.hxx b/sc/inc/TablePivotChart.hxx new file mode 100644 index 0000000000..0012ed1d98 --- /dev/null +++ b/sc/inc/TablePivotChart.hxx @@ -0,0 +1,69 @@ +/* -*- 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/. + */ + +#pragma once + +#include <com/sun/star/table/XTablePivotChart.hpp> +#include <com/sun/star/document/XEmbeddedObjectSupplier.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/container/XNamed.hpp> + +#include <svl/lstner.hxx> +#include <comphelper/compbase.hxx> + +#include "types.hxx" + +class ScDocShell; + +namespace sc +{ + +typedef comphelper::WeakComponentImplHelper<css::table::XTablePivotChart, + css::document::XEmbeddedObjectSupplier, + css::container::XNamed, + css::lang::XServiceInfo> + TablePivotChart_Base; + +class TablePivotChart final : public TablePivotChart_Base, + public SfxListener +{ +private: + ScDocShell* m_pDocShell; + SCTAB m_nTab; // Charts are per sheet + OUString m_aChartName; + +public: + TablePivotChart(ScDocShell* pDocShell, SCTAB nTab, OUString aName); + virtual ~TablePivotChart() override; + + virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override; + + // XComponent + using TablePivotChart_Base::disposing; + + // XEmbeddedObjectSupplier + virtual css::uno::Reference<css::lang::XComponent> SAL_CALL + getEmbeddedObject() override; + + // XNamed + virtual OUString SAL_CALL getName() override; + virtual void SAL_CALL setName(OUString const & aName) override; + + // XTablePivotChart + virtual OUString SAL_CALL getPivotTableName() override; + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName) override; + virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; +}; + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/TablePivotCharts.hxx b/sc/inc/TablePivotCharts.hxx new file mode 100644 index 0000000000..9660e36782 --- /dev/null +++ b/sc/inc/TablePivotCharts.hxx @@ -0,0 +1,70 @@ +/* -*- 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/. + */ + +#pragma once + +#include <com/sun/star/table/XTablePivotCharts.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/container/XIndexAccess.hpp> + +#include <svl/lstner.hxx> +#include <cppuhelper/implbase.hxx> + +#include "types.hxx" + +class ScDocShell; + +namespace sc +{ +typedef cppu::WeakImplHelper<css::table::XTablePivotCharts, + css::container::XIndexAccess, + css::lang::XServiceInfo> + TablePivotCharts_Base; + +class TablePivotCharts final : public TablePivotCharts_Base, public SfxListener +{ +private: + ScDocShell* m_pDocShell; + SCTAB m_nTab; + +public: + TablePivotCharts(ScDocShell* pDocShell, SCTAB nTab); + + virtual ~TablePivotCharts() override; + + virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override; + + // XTablePivotCharts + virtual void SAL_CALL addNewByName(OUString const & aName, + const css::awt::Rectangle& aRect, + OUString const & aDataPilotName) override; + virtual void SAL_CALL removeByName(OUString const & aName) override; + + // XNameAccess + virtual css::uno::Any SAL_CALL getByName(OUString const & aName) override; + virtual css::uno::Sequence<OUString> SAL_CALL getElementNames() override; + virtual sal_Bool SAL_CALL hasByName(OUString const & aName) override; + + // XIndexAccess + virtual sal_Int32 SAL_CALL getCount() override; + virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) override; + + // XElementAccess + virtual css::uno::Type SAL_CALL getElementType() override; + virtual sal_Bool SAL_CALL hasElements() override; + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName) override; + virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; +}; + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/ViewSettingsSequenceDefines.hxx b/sc/inc/ViewSettingsSequenceDefines.hxx new file mode 100644 index 0000000000..0c04aa594e --- /dev/null +++ b/sc/inc/ViewSettingsSequenceDefines.hxx @@ -0,0 +1,105 @@ +/* -*- 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 <rtl/ustring.hxx> + +// this are the defines for the position of the settings in the +// ViewSettingsSequence + +#define SC_VIEWSETTINGS_COUNT 26 + +#define SC_VIEW_ID 0 +#define SC_TABLE_VIEWSETTINGS 1 +#define SC_ACTIVE_TABLE 2 +#define SC_HORIZONTAL_SCROLL_BAR_WIDTH 3 +#define SC_ZOOM_TYPE 4 +#define SC_ZOOM_VALUE 5 +#define SC_PAGE_VIEW_ZOOM_VALUE 6 +#define SC_PAGE_BREAK_PREVIEW 7 +#define SC_SHOWZERO 8 +#define SC_SHOWNOTES 9 +#define SC_SHOWFORMULASMARKS 10 +#define SC_SHOWGRID 11 +#define SC_GRIDCOLOR 12 +#define SC_SHOWPAGEBR 13 +#define SC_COLROWHDR 14 +#define SC_SHEETTABS 15 +#define SC_OUTLSYMB 16 +#define SC_VALUE_HIGHLIGHTING 17 +#define SC_SNAPTORASTER 18 +#define SC_RASTERVIS 19 +#define SC_RASTERRESX 20 +#define SC_RASTERRESY 21 +#define SC_RASTERSUBX 22 +#define SC_RASTERSUBY 23 +#define SC_RASTERSYNC 24 +#define SC_FORMULA_BAR_HEIGHT 25 + +// this are the defines for the position of the settings in the +// TableViewSettingsSequence + +#define SC_TABLE_VIEWSETTINGS_COUNT 16 + +#define SC_CURSOR_X 0 +#define SC_CURSOR_Y 1 +#define SC_HORIZONTAL_SPLIT_MODE 2 +#define SC_VERTICAL_SPLIT_MODE 3 +#define SC_HORIZONTAL_SPLIT_POSITION 4 +#define SC_VERTICAL_SPLIT_POSITION 5 +#define SC_ACTIVE_SPLIT_RANGE 6 +#define SC_POSITION_LEFT 7 +#define SC_POSITION_RIGHT 8 +#define SC_POSITION_TOP 9 +#define SC_POSITION_BOTTOM 10 +#define SC_TABLE_ZOOM_TYPE 11 +#define SC_TABLE_ZOOM_VALUE 12 +#define SC_TABLE_PAGE_VIEW_ZOOM_VALUE 13 +#define SC_FORMULA_BAR_HEIGHT_VALUE 14 +#define SC_TABLE_SHOWGRID 15 + +inline constexpr OUString SC_CURSORPOSITIONX = u"CursorPositionX"_ustr; +inline constexpr OUString SC_CURSORPOSITIONY = u"CursorPositionY"_ustr; +inline constexpr OUString SC_HORIZONTALSPLITMODE = u"HorizontalSplitMode"_ustr; +inline constexpr OUString SC_VERTICALSPLITMODE = u"VerticalSplitMode"_ustr; +inline constexpr OUString SC_HORIZONTALSPLITPOSITION = u"HorizontalSplitPosition"_ustr; +inline constexpr OUString SC_VERTICALSPLITPOSITION = u"VerticalSplitPosition"_ustr; +#define SC_HORIZONTALSPLITPOSITION_TWIPS "HorizontalSplitPositionTwips" +#define SC_VERTICALSPLITPOSITION_TWIPS "VerticalSplitPositionTwips" +inline constexpr OUString SC_ACTIVESPLITRANGE = u"ActiveSplitRange"_ustr; +inline constexpr OUString SC_POSITIONLEFT = u"PositionLeft"_ustr; +inline constexpr OUString SC_POSITIONRIGHT = u"PositionRight"_ustr; +inline constexpr OUString SC_POSITIONTOP = u"PositionTop"_ustr; +inline constexpr OUString SC_POSITIONBOTTOM = u"PositionBottom"_ustr; +#define SC_TABLESELECTED "TableSelected" + +inline constexpr OUString SC_TABLES = u"Tables"_ustr; +inline constexpr OUString SC_ACTIVETABLE = u"ActiveTable"_ustr; +inline constexpr OUString SC_HORIZONTALSCROLLBARWIDTH = u"HorizontalScrollbarWidth"_ustr; +#define SC_RELHORIZONTALTABBARWIDTH "RelativeHorizontalTabbarWidth" +inline constexpr OUString SC_ZOOMTYPE = u"ZoomType"_ustr; +inline constexpr OUString SC_ZOOMVALUE = u"ZoomValue"_ustr; +inline constexpr OUString SC_PAGEVIEWZOOMVALUE = u"PageViewZoomValue"_ustr; +inline constexpr OUString SC_SHOWPAGEBREAKPREVIEW = u"ShowPageBreakPreview"_ustr; +inline constexpr OUString SC_FORMULABARHEIGHT = u"FormulaBarHeight"_ustr; +inline constexpr OUString SC_VIEWID = u"ViewId"_ustr; +#define SC_VIEW "view" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/addincfg.hxx b/sc/inc/addincfg.hxx new file mode 100644 index 0000000000..0c0e24c356 --- /dev/null +++ b/sc/inc/addincfg.hxx @@ -0,0 +1,41 @@ +/* -*- 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 <unotools/configitem.hxx> + +class ScAddInCfg final : public utl::ConfigItem +{ +private: + virtual void ImplCommit() override; + +public: + ScAddInCfg(); + + virtual void Notify( const css::uno::Sequence<OUString>& aPropertyNames ) override; + + css::uno::Sequence< css::uno::Any> + GetProperties(const css::uno::Sequence< OUString >& rNames) + { return ConfigItem::GetProperties( rNames ); } + + using ConfigItem::GetNodeNames; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/addincol.hxx b/sc/inc/addincol.hxx new file mode 100644 index 0000000000..67e24e2c16 --- /dev/null +++ b/sc/inc/addincol.hxx @@ -0,0 +1,243 @@ +/* -*- 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 <memory> +#include <com/sun/star/uno/Any.h> +#include <com/sun/star/uno/Reference.h> +#include <com/sun/star/uno/Sequence.h> +#include <formula/errorcodes.hxx> +#include <i18nlangtag/lang.h> +#include "scdllapi.h" +#include <rtl/ustring.hxx> +#include <tools/long.hxx> + +#include "types.hxx" + +#include <string_view> +#include <utility> +#include <vector> +#include <unordered_map> + +namespace com::sun::star::reflection { class XIdlMethod; } +namespace com::sun::star::sheet { class XVolatileResult; } +namespace com::sun::star::uno { class XInterface; } + +class SfxObjectShell; +class ScUnoAddInFuncData; +class ScFuncDesc; +class LanguageTag; +class ScDocument; + +typedef std::unordered_map< OUString, const ScUnoAddInFuncData* > ScAddInHashMap; + +enum ScAddInArgumentType +{ + SC_ADDINARG_NONE, ///< - + SC_ADDINARG_INTEGER, ///< long + SC_ADDINARG_DOUBLE, ///< double + SC_ADDINARG_STRING, ///< string + SC_ADDINARG_INTEGER_ARRAY, ///< sequence<sequence<long>> + SC_ADDINARG_DOUBLE_ARRAY, ///< sequence<sequence<double>> + SC_ADDINARG_STRING_ARRAY, ///< sequence<sequence<string>> + SC_ADDINARG_MIXED_ARRAY, ///< sequence<sequence<any>> + SC_ADDINARG_VALUE_OR_ARRAY, ///< any + SC_ADDINARG_CELLRANGE, ///< XCellRange + SC_ADDINARG_CALLER, ///< XPropertySet + SC_ADDINARG_VARARGS ///< sequence<any> +}; + +struct ScAddInArgDesc +{ + OUString aInternalName; ///< used to match configuration and reflection information + OUString aName; + OUString aDescription; + ScAddInArgumentType eType; + bool bOptional; +}; + +class ScUnoAddInFuncData +{ +public: + struct LocalizedName + { + OUString maLocale; + OUString maName; + + LocalizedName( OUString aLocale, OUString aName ) + : maLocale(std::move(aLocale)), maName(std::move(aName)) { } + }; +private: + OUString aOriginalName; ///< kept in formula + OUString aLocalName; ///< for display + OUString aUpperName; ///< for entering formulas + OUString aUpperLocal; ///< for entering formulas + OUString aUpperEnglish; ///< for Function Wizard and tooltips + OUString aDescription; + css::uno::Reference< css::reflection::XIdlMethod> xFunction; + css::uno::Any aObject; + tools::Long nArgCount; + std::unique_ptr<ScAddInArgDesc[]> + pArgDescs; + tools::Long nCallerPos; + sal_uInt16 nCategory; + OUString sHelpId; + mutable ::std::vector< LocalizedName > maCompNames; + mutable bool bCompInitialized; + +public: + ScUnoAddInFuncData( const OUString& rNam, const OUString& rLoc, + OUString aDesc, + sal_uInt16 nCat, OUString , + css::uno::Reference< css::reflection::XIdlMethod> aFunc, + css::uno::Any aO, + tools::Long nAC, const ScAddInArgDesc* pAD, + tools::Long nCP ); + ~ScUnoAddInFuncData(); + + const OUString& GetOriginalName() const { return aOriginalName; } + const OUString& GetLocalName() const { return aLocalName; } + const OUString& GetUpperName() const { return aUpperName; } + const OUString& GetUpperLocal() const { return aUpperLocal; } + const OUString& GetUpperEnglish() const { return aUpperEnglish; } + const css::uno::Reference< css::reflection::XIdlMethod>& GetFunction() const + { return xFunction; } + const css::uno::Any& GetObject() const { return aObject; } + tools::Long GetArgumentCount() const { return nArgCount; } + const ScAddInArgDesc* GetArguments() const { return pArgDescs.get(); } + tools::Long GetCallerPos() const { return nCallerPos; } + const OUString& GetDescription() const { return aDescription; } + sal_uInt16 GetCategory() const { return nCategory; } + const OUString& GetHelpId() const { return sHelpId; } + + const ::std::vector< LocalizedName >& GetCompNames() const; + bool GetExcelName( const LanguageTag& rDestLang, OUString& rRetExcelName, + bool bFallbackToAny = true ) const; + + void SetFunction( const css::uno::Reference< css::reflection::XIdlMethod>& rNewFunc, + const css::uno::Any& rNewObj ); + void SetArguments( tools::Long nNewCount, const ScAddInArgDesc* pNewDescs ); + void SetCallerPos( tools::Long nNewPos ); + void SetCompNames( ::std::vector< LocalizedName >&& rNew ); + + /// Takes care of handling an empty name *after* upper local name was set. + void SetEnglishName( const OUString& rEnglishName ); +}; + +class SC_DLLPUBLIC ScUnoAddInCollection +{ +private: + tools::Long nFuncCount; + std::unique_ptr<std::unique_ptr<ScUnoAddInFuncData>[]> ppFuncData; + std::unique_ptr<ScAddInHashMap> pExactHashMap; ///< exact internal name + std::unique_ptr<ScAddInHashMap> pNameHashMap; ///< internal name upper + std::unique_ptr<ScAddInHashMap> pLocalHashMap; ///< localized name upper + std::unique_ptr<ScAddInHashMap> pEnglishHashMap; ///< English name upper + bool bInitialized; + + void Initialize(); + void ReadConfiguration(); + void ReadFromAddIn( const css::uno::Reference< css::uno::XInterface>& xInterface ); + void UpdateFromAddIn( const css::uno::Reference< css::uno::XInterface>& xInterface, + std::u16string_view rServiceName ); + void LoadComponent( const ScUnoAddInFuncData& rFuncData ); + +public: + ScUnoAddInCollection(); + ~ScUnoAddInCollection(); + + /// User entered name. rUpperName MUST already be upper case! + OUString FindFunction( const OUString& rUpperName, bool bLocalFirst ); + + /** Only if bComplete is set, the function reference and argument types + are initialized (component may have to be loaded). + @param rName is the exact Name. */ + const ScUnoAddInFuncData* GetFuncData( const OUString& rName, bool bComplete = false ); + + /** For enumeration in ScCompiler::OpCodeMap::getAvailableMappings(). + @param nIndex + 0 <= nIndex < GetFuncCount() + */ + const ScUnoAddInFuncData* GetFuncData( tools::Long nIndex ); + + void Clear(); + + void LocalizeString( OUString& rName ); ///< modify rName - input: exact name + + tools::Long GetFuncCount(); + bool FillFunctionDesc( tools::Long nFunc, ScFuncDesc& rDesc, bool bEnglishFunctionNames ); + + static bool FillFunctionDescFromData( const ScUnoAddInFuncData& rFuncData, ScFuncDesc& rDesc, + bool bEnglishFunctionNames ); + /// leave rRetExcelName unchanged, if no matching name is found + bool GetExcelName( const OUString& rCalcName, LanguageType eDestLang, OUString& rRetExcelName ); + /// leave rRetCalcName unchanged, if no matching name is found + bool GetCalcName( const OUString& rExcelName, OUString& rRetCalcName ); +}; + +class ScUnoAddInCall +{ +private: + const ScUnoAddInFuncData* pFuncData; + css::uno::Sequence<css::uno::Any> aArgs; + css::uno::Sequence<css::uno::Any> aVarArg; + css::uno::Reference<css::uno::XInterface> xCaller; + ScDocument& mrDoc; + bool bValidCount; + // result: + FormulaError nErrCode; + bool bHasString; + double fValue; + OUString aString; + ScMatrixRef xMatrix; + css::uno::Reference<css::sheet::XVolatileResult> xVarRes; + + void ExecuteCallWithArgs(css::uno::Sequence<css::uno::Any>& rCallArgs); + +public: + // exact name + ScUnoAddInCall( ScDocument& rDoc, ScUnoAddInCollection& rColl, const OUString& rName, + tools::Long nParamCount ); + ~ScUnoAddInCall(); + + bool NeedsCaller() const; + void SetCaller( const css::uno::Reference<css::uno::XInterface>& rInterface ); + void SetCallerFromObjectShell( const SfxObjectShell* pSh ); + + bool ValidParamCount() { return bValidCount;} + ScAddInArgumentType GetArgType( tools::Long nPos ); + void SetParam( tools::Long nPos, const css::uno::Any& rValue ); + + void ExecuteCall(); + + void SetResult( const css::uno::Any& rNewRes ); + + FormulaError GetErrCode() const { return nErrCode; } + bool HasString() const { return bHasString; } + bool HasMatrix() const { return bool(xMatrix); } + bool HasVarRes() const { return xVarRes.is(); } + double GetValue() const { return fValue; } + const OUString& GetString() const { return aString; } + const ScMatrixRef& GetMatrix() const { return xMatrix;} + const css::uno::Reference<css::sheet::XVolatileResult>& + GetVarRes() const { return xVarRes; } +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/address.hxx b/sc/inc/address.hxx new file mode 100644 index 0000000000..03cfb1db79 --- /dev/null +++ b/sc/inc/address.hxx @@ -0,0 +1,978 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column:100 -*- */ +/* + * 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 <rtl/ustrbuf.hxx> +#include <rtl/strbuf.hxx> + +#include <array> +#include <limits> +#include <ostream> + +#include "scdllapi.h" +#include "types.hxx" +#include <formula/grammar.hxx> + +#include <o3tl/typed_flags_set.hxx> +#include <o3tl/underlyingenumvalue.hxx> + +namespace com::sun::star { + namespace sheet { + struct ExternalLinkInfo; + } +} + +namespace com::sun::star::uno { template <typename > class Sequence; } + +class ScDocument; + +/** size_t typedef to be able to find places where code was changed from USHORT + to size_t and is used to read/write from/to streams. */ +typedef size_t SCSIZE; + +// Maximum possible value of data type, NOT maximum row value. +// MSC confuses numeric_limit max() with macro max() if vcl/wintypes.hxx is +// included, we should not be using those stupid macros anyway. +#undef min +#undef max +const SCROW SCROW_MAX = ::std::numeric_limits<SCROW>::max(); +const SCCOL SCCOL_MAX = ::std::numeric_limits<SCCOL>::max(); +const SCTAB SCTAB_MAX = ::std::numeric_limits<SCTAB>::max(); +const SCCOLROW SCCOLROW_MAX = ::std::numeric_limits<SCCOLROW>::max(); +const SCSIZE SCSIZE_MAX = ::std::numeric_limits<SCSIZE>::max(); + +// Count values +const SCROW MAXROWCOUNT = 1048576; +const SCCOL MAXCOLCOUNT = 16384; +const SCCOL INITIALCOLCOUNT = 1; // initial number of columns we allocate memory for +/// limiting to 10000 for now, problem with 32 bit builds for now +const SCTAB MAXTABCOUNT = 10000; +// Maximum values +const SCROW MAXROW = MAXROWCOUNT - 1; +const SCCOL MAXCOL = MAXCOLCOUNT - 1; +const SCTAB MAXTAB = MAXTABCOUNT - 1; +const SCCOLROW MAXCOLROW = MAXROW; +const SCROW MAXROWCOUNT_JUMBO = 16 * 1024 * 1024; +const SCCOL MAXCOLCOUNT_JUMBO = 16384; +const SCROW MAXROW_JUMBO = MAXROWCOUNT_JUMBO - 1; +const SCCOL MAXCOL_JUMBO = MAXCOLCOUNT_JUMBO - 1; +// Maximum tiled rendering values +const SCROW MAXTILEDROW = MAXROW; +// Limit the initial tab count to prevent users to set the count too high, +// which could cause the memory usage of blank documents to exceed the +// available system memory. +const SCTAB MAXINITTAB = 1024; +const SCTAB MININITTAB = 1; + +inline constexpr OUString MAXROW_STRING(u"1048575"_ustr); +inline constexpr OUString MAXCOL_STRING(u"XFD"_ustr); +inline constexpr OUString MAXROW_JUMBO_STRING(u"16777215"_ustr); +inline constexpr OUString MAXCOL_JUMBO_STRING(u"XFD"_ustr); + +// Special values +const SCTAB SC_TAB_APPEND = SCTAB_MAX; +const SCTAB TABLEID_DOC = SCTAB_MAX; // entire document, e.g. protect +const SCROW SCROWS32K = 32000; // for fuzzing +const SCCOL SCCOL_REPEAT_NONE = SCCOL_MAX; +const SCROW SCROW_REPEAT_NONE = SCROW_MAX; +const SCCOL SC_TABSTART_NONE = SCCOL_MAX; + +const SCROW MAXROW_30 = 8191; + +[[nodiscard]] inline bool ValidCol( SCCOL nCol, SCCOL nMaxCol ) +{ + assert(nMaxCol == MAXCOL || nMaxCol == MAXCOL_JUMBO); // temporary to debug jumbo sheets work + return nCol >= 0 && nCol <= nMaxCol; +} + +[[nodiscard]] inline bool ValidRow( SCROW nRow, SCROW nMaxRow) +{ + assert(nMaxRow == MAXROW || nMaxRow == MAXROW_JUMBO); // temporary to debug jumbo sheets work + return nRow >= 0 && nRow <= nMaxRow; +} + +[[nodiscard]] inline bool ValidTab( SCTAB nTab ) +{ + return nTab >= 0 && nTab <= MAXTAB; +} + +[[nodiscard]] inline bool ValidTab( SCTAB nTab, SCTAB nMaxTab ) +{ + return nTab >= 0 && nTab <= nMaxTab; +} + +[[nodiscard]] inline bool ValidColRow( SCCOL nCol, SCROW nRow, SCCOL nMaxCol, SCROW nMaxRow ) +{ + assert(nMaxRow == MAXROW || nMaxRow == MAXROW_JUMBO); // temporary to debug jumbo sheets work + return ValidCol(nCol,nMaxCol) && ValidRow(nRow,nMaxRow); +} + +[[nodiscard]] inline bool ValidColRowTab( SCCOL nCol, SCROW nRow, SCTAB nTab, SCCOL nMaxCol, SCROW nMaxRow ) +{ + assert(nMaxRow == MAXROW || nMaxRow == MAXROW_JUMBO); // temporary to debug jumbo sheets work + return ValidCol(nCol,nMaxCol) && ValidRow(nRow,nMaxRow) && ValidTab( nTab); +} + +[[nodiscard]] inline SCCOL SanitizeCol( SCCOL nCol, SCCOL nMaxCol ) +{ + assert(nMaxCol == MAXCOL || nMaxCol == MAXCOL_JUMBO); // temporary to debug jumbo sheets work + return nCol < 0 ? 0 : (nCol > nMaxCol ? nMaxCol : nCol); +} + +[[nodiscard]] inline SCROW SanitizeRow( SCROW nRow, SCROW nMaxRow ) +{ + assert(nMaxRow == MAXROW || nMaxRow == MAXROW_JUMBO); // temporary to debug jumbo sheets work + return nRow < 0 ? 0 : (nRow > nMaxRow ? nMaxRow : nRow); +} + +[[nodiscard]] inline SCTAB SanitizeTab( SCTAB nTab ) +{ + return nTab < 0 ? 0 : (nTab > MAXTAB ? MAXTAB : nTab); +} + +template <typename T> inline void PutInOrder(T& nStart, T& nEnd) +{ + if (nEnd < nStart) + std::swap(nStart, nEnd); +} + +// The result of ConvertRef() is a bit group of the following: +enum class ScRefFlags : sal_uInt16 +{ + ZERO = 0x0000, + COL_ABS = 0x0001, + ROW_ABS = 0x0002, + TAB_ABS = 0x0004, + TAB_3D = 0x0008, + COL2_ABS = 0x0010, + ROW2_ABS = 0x0020, + TAB2_ABS = 0x0040, + TAB2_3D = 0x0080, + ROW_VALID = 0x0100, + COL_VALID = 0x0200, + TAB_VALID = 0x0400, + // BITS for convenience + BITS = COL_ABS | ROW_ABS | TAB_ABS | TAB_3D + | ROW_VALID | COL_VALID | TAB_VALID, + // somewhat cheesy kludge to force the display of the document name even for + // local references. Requires TAB_3D to be valid + FORCE_DOC = 0x0800, + ROW2_VALID = 0x1000, + COL2_VALID = 0x2000, + TAB2_VALID = 0x4000, + VALID = 0x8000, + + TAB_ABS_3D = TAB_ABS | TAB_3D, + + ADDR_ABS = VALID | COL_ABS | ROW_ABS | TAB_ABS, + + RANGE_ABS = ADDR_ABS | COL2_ABS | ROW2_ABS | TAB2_ABS, + + ADDR_ABS_3D = ADDR_ABS | TAB_3D, + RANGE_ABS_3D = RANGE_ABS | TAB_3D +}; + +namespace o3tl +{ + template<> struct typed_flags<ScRefFlags> : is_typed_flags<ScRefFlags, 0xffff> {}; +} +inline void applyStartToEndFlags(ScRefFlags &target,const ScRefFlags source) +{ + target |= ScRefFlags(o3tl::to_underlying(source) << 4); +} +inline void applyStartToEndFlags(ScRefFlags &target) +{ + target |= ScRefFlags(o3tl::to_underlying(target) << 4); +} + +// ScAddress +class SAL_WARN_UNUSED ScAddress +{ +private: + // Even if the fields are in the order "row, column, tab", in all (?) the ScAddress and + // ScDocument APIs that take separate row, column, and tab parameters, the parameters are in the + // order "column, row, tab", which matches the most common (A1) address syntax, if you ignore + // the sheet (tab). Don't let this confuse you, like it confused me for a while. + + SCROW nRow; + SCCOL nCol; + SCTAB nTab; + +public: + + enum Uninitialized { UNINITIALIZED }; + enum InitializeInvalid { INITIALIZE_INVALID }; + + struct Details + { + formula::FormulaGrammar::AddressConvention eConv; + SCROW nRow; + SCCOL nCol; + + Details( formula::FormulaGrammar::AddressConvention eConvP, SCROW nRowP, SCCOL nColP ) : + eConv(eConvP), nRow(nRowP), nCol(nColP) + {} + Details( formula::FormulaGrammar::AddressConvention eConvP, ScAddress const & rAddr ) : + eConv(eConvP), nRow(rAddr.Row()), nCol(rAddr.Col()) + {} + Details( formula::FormulaGrammar::AddressConvention eConvP) : + eConv(eConvP), nRow(0), nCol(0) + {} + /* Use the formula::FormulaGrammar::AddressConvention associated with rAddr::Tab() */ + Details( const ScDocument& rDoc, const ScAddress& rAddr ); + }; + SC_DLLPUBLIC static const Details detailsOOOa1; + + struct ExternalInfo + { + OUString maTabName; + sal_uInt16 mnFileId; + bool mbExternal; + + ExternalInfo() : + mnFileId(0), mbExternal(false) + {} + }; + + ScAddress() : + nRow(0), nCol(0), nTab(0) + {} + ScAddress( SCCOL nColP, SCROW nRowP, SCTAB nTabP ) : + nRow(nRowP), nCol(nColP), nTab(nTabP) + {} + /** coverity[uninit_member] - Yes, it is what it seems to be: Uninitialized. + May be used for performance reasons if it is initialized by other means. */ + ScAddress( Uninitialized ) + {} + ScAddress( InitializeInvalid ) : + nRow(-1), nCol(-1), nTab(-1) + {} + ScAddress( const ScAddress& rAddress ) : + nRow(rAddress.nRow), nCol(rAddress.nCol), nTab(rAddress.nTab) + {} + inline ScAddress& operator=( const ScAddress& rAddress ); + + inline void Set( SCCOL nCol, SCROW nRow, SCTAB nTab ); + + SCROW Row() const + { + return nRow; + } + + SCCOL Col() const + { + return nCol; + } + SCTAB Tab() const + { + return nTab; + } + void SetRow( SCROW nRowP ) + { + nRow = nRowP; + } + void SetCol( SCCOL nColP ) + { + nCol = nColP; + } + void SetTab( SCTAB nTabP ) + { + nTab = nTabP; + } + void SetInvalid() + { + nRow = -1; + nCol = -1; + nTab = -1; + } + bool IsValid() const + { + return (nRow >= 0) && (nCol >= 0) && (nTab >= 0); + } + + inline void PutInOrder( ScAddress& rAddress ); + + void IncRow( SCROW nDelta = 1 ) + { + nRow = sal::static_int_cast<SCROW>(nRow + nDelta); + } + void IncCol( SCCOL nDelta = 1 ) + { + nCol = sal::static_int_cast<SCCOL>(nCol + nDelta); + } + void IncTab( SCTAB nDelta = 1 ) + { + nTab = sal::static_int_cast<SCTAB>(nTab + nDelta); + } + void GetVars( SCCOL& nColP, SCROW& nRowP, SCTAB& nTabP ) const + { + nColP = nCol; + nRowP = nRow; + nTabP = nTab; + } + + /** + @param pSheetEndPos + If given and Parse() successfully parsed a sheet name it returns + the end position (exclusive) behind the sheet name AND a + following sheet name separator. This independent of whether the + resulting reference is fully valid or not. + */ + SC_DLLPUBLIC ScRefFlags Parse( + const OUString&, const ScDocument&, + const Details& rDetails = detailsOOOa1, + ExternalInfo* pExtInfo = nullptr, + const css::uno::Sequence<css::sheet::ExternalLinkInfo>* pExternalLinks = nullptr, + sal_Int32* pSheetEndPos = nullptr, + const OUString* pErrRef = nullptr ); + + SC_DLLPUBLIC void Format( OStringBuffer& r, ScRefFlags nFlags, + const ScDocument* pDocument = nullptr, + const Details& rDetails = detailsOOOa1) const; + + SC_DLLPUBLIC OUString Format( ScRefFlags nFlags, + const ScDocument* pDocument = nullptr, + const Details& rDetails = detailsOOOa1) const; + + /** + @param rErrorPos + If FALSE is returned, the positions contain <0 or >MAX... + values if shifted out of bounds. + @param pDocument + The document for the maximum defined sheet number. + */ + [[nodiscard]] SC_DLLPUBLIC bool Move( SCCOL nDeltaX, SCROW nDeltaY, SCTAB nDeltaZ, + ScAddress& rErrorPos, const ScDocument& rDoc ); + + inline bool operator==( const ScAddress& rAddress ) const; + inline bool operator!=( const ScAddress& rAddress ) const; + inline bool operator<( const ScAddress& rAddress ) const; + inline bool operator<=( const ScAddress& rAddress ) const; + inline bool lessThanByRow( const ScAddress& rAddress ) const; + + inline size_t hash() const; + + /** + * Create a human-readable string representation of the cell address. You + * cannot specify precise formatting with this method; use Format() if you + * need to specify how the address needs to be formatted. + * + * The address string does not display sheet name. + * + * @return human-readable string representation of the cell address. + */ + OUString GetColRowString() const; +}; + +// For use in SAL_DEBUG etc. Output format not guaranteed to be stable. +template<typename charT, typename traits> +inline std::basic_ostream<charT, traits> & operator <<(std::basic_ostream<charT, traits> & stream, const ScAddress& rAddress) +{ + stream << + rAddress.Tab()+1 << "!" + "R" << rAddress.Row()+1 << + "C" << rAddress.Col()+1; + + return stream; +} + +inline void ScAddress::PutInOrder( ScAddress& rAddress ) +{ + ::PutInOrder(nCol, rAddress.nCol); + ::PutInOrder(nRow, rAddress.nRow); + ::PutInOrder(nTab, rAddress.nTab); +} + +inline void ScAddress::Set( SCCOL nColP, SCROW nRowP, SCTAB nTabP ) +{ + nCol = nColP; + nRow = nRowP; + nTab = nTabP; +} + +inline ScAddress& ScAddress::operator=( const ScAddress& rAddress ) +{ + nCol = rAddress.nCol; + nRow = rAddress.nRow; + nTab = rAddress.nTab; + return *this; +} + +inline bool ScAddress::operator==( const ScAddress& rAddress ) const +{ + return nRow == rAddress.nRow && nCol == rAddress.nCol && nTab == rAddress.nTab; +} + +inline bool ScAddress::operator!=( const ScAddress& rAddress ) const +{ + return !operator==( rAddress ); +} + +/** Less than ordered by tab,col,row. */ +inline bool ScAddress::operator<( const ScAddress& rAddress ) const +{ + if (nTab == rAddress.nTab) + { + if (nCol == rAddress.nCol) + return nRow < rAddress.nRow; + else + return nCol < rAddress.nCol; + } + else + return nTab < rAddress.nTab; +} + +inline bool ScAddress::operator<=( const ScAddress& rAddress ) const +{ + return operator<( rAddress ) || operator==( rAddress ); +} + +/** Less than ordered by tab,row,col as needed by row-wise import/export */ +inline bool ScAddress::lessThanByRow( const ScAddress& rAddress ) const +{ + if (nTab == rAddress.nTab) + { + if (nRow == rAddress.nRow) + return nCol < rAddress.nCol; + else + return nRow < rAddress.nRow; + } + else + return nTab < rAddress.nTab; +} + +inline size_t ScAddress::hash() const +{ +#if SAL_TYPES_SIZEOFPOINTER == 8 + // 16 bits for the columns, and 20 bits for the rows + return (static_cast<size_t>(nTab) << 36) ^ + (static_cast<size_t>(nCol) << 20) ^ + static_cast<size_t>(nRow); +#else + // Assume that there are not that many addresses with row > 2^16 AND column + // > 2^8 AND sheet > 2^8 so we won't have too many collisions. + if (nRow <= 0xffff) + return (static_cast<size_t>(nTab) << 24) ^ + (static_cast<size_t>(nCol) << 16) ^ static_cast<size_t>(nRow); + else + return (static_cast<size_t>(nTab) << 28) ^ + (static_cast<size_t>(nCol) << 24) ^ static_cast<size_t>(nRow); +#endif +} + +struct ScAddressHashFunctor +{ + size_t operator()( const ScAddress & rAddress ) const + { + return rAddress.hash(); + } +}; + +[[nodiscard]] inline bool ValidAddress( const ScAddress& rAddress, SCCOL nMaxCol, SCROW nMaxRow ) +{ + return ValidCol(rAddress.Col(), nMaxCol) && ValidRow(rAddress.Row(), nMaxRow) && ValidTab(rAddress.Tab()); +} + +// ScRange +class SAL_WARN_UNUSED SC_DLLPUBLIC ScRange final +{ +public: + ScAddress aStart; + ScAddress aEnd; + + ScRange() : + aStart(), aEnd() + {} + + ScRange( ScAddress::Uninitialized eUninitialized ) : + aStart( eUninitialized ), aEnd( eUninitialized ) + {} + ScRange( ScAddress::InitializeInvalid eInvalid ) : + aStart( eInvalid ), aEnd( eInvalid ) + {} + ScRange( const ScAddress& aInputStart, const ScAddress& aInputEnd ) : + aStart( aInputStart ), aEnd( aInputEnd ) + { + PutInOrder(); + } + ScRange( const ScRange& rRange ) : + aStart( rRange.aStart ), aEnd( rRange.aEnd ) + {} + ScRange( const ScAddress& rRange ) : + aStart( rRange ), aEnd( rRange ) + {} + ScRange( SCCOL nCol, SCROW nRow, SCTAB nTab ) : + aStart( nCol, nRow, nTab ), aEnd( aStart ) + {} + ScRange( SCCOL nCol1, SCROW nRow1, SCTAB nTab1, SCCOL nCol2, SCROW nRow2, SCTAB nTab2 ) : + aStart( nCol1, nRow1, nTab1 ), aEnd( nCol2, nRow2, nTab2 ) + {} + + ScRange& operator=( const ScRange& rRange ) + { + aStart = rRange.aStart; + aEnd = rRange.aEnd; + return *this; + } + ScRange& operator=( const ScAddress& rPos ) + { + aStart = aEnd = rPos; + return *this; + } + void SetInvalid() + { + aStart.SetInvalid(); + aEnd.SetInvalid(); + } + bool IsValid() const + { + return aStart.IsValid() && aEnd.IsValid(); + } + inline bool Contains( const ScAddress& ) const; ///< is Address& fully in Range? + inline bool Contains( const ScRange& ) const; ///< is Range& fully in Range? + inline bool Intersects( const ScRange& rRange ) const; // do two ranges intersect? + + ScRefFlags Parse( const OUString&, const ScDocument&, + const ScAddress::Details& rDetails = ScAddress::detailsOOOa1, + ScAddress::ExternalInfo* pExtInfo = nullptr, + const css::uno::Sequence<css::sheet::ExternalLinkInfo>* pExternalLinks = nullptr, + const OUString* pErrRef = nullptr ); + + ScRefFlags ParseAny( const OUString&, const ScDocument&, + const ScAddress::Details& rDetails = ScAddress::detailsOOOa1 ); + ScRefFlags ParseCols( const ScDocument& rDoc, + const OUString&, + const ScAddress::Details& rDetails = ScAddress::detailsOOOa1 ); + void ParseRows( const ScDocument& rDoc, + const OUString&, + const ScAddress::Details& rDetails = ScAddress::detailsOOOa1 ); + + /** Parse an Excel style reference up to and including the sheet name + separator '!', including detection of external documents and sheet + names, and in case of MOOXML import the bracketed index is used to + determine the actual document name passed in pExternalLinks. For + internal references (resulting rExternDocName empty), aStart.nTab and + aEnd.nTab are set, or -1 if sheet name not found. + @param bOnlyAcceptSingle If <TRUE/>, a 3D reference (Sheet1:Sheet2) + encountered results in an error (NULL returned). + @param pExternalLinks pointer to ExternalLinkInfo sequence, may be + NULL for non-filter usage, in which case indices such as [1] are + not resolved. + @param pErrRef pointer to "#REF!" string if to be accepted. + @returns + Pointer to the position after '!' if successfully parsed, and + rExternDocName, rStartTabName and/or rEndTabName filled if + applicable. ScRefFlags::... flags set in nFlags. + Or if no valid document and/or sheet header could be parsed the start + position passed with pString. + Or NULL if a 3D sheet header could be parsed but + bOnlyAcceptSingle==true was given. + */ + const sal_Unicode* Parse_XL_Header( const sal_Unicode* pString, const ScDocument& rDocument, + OUString& rExternDocName, OUString& rStartTabName, + OUString& rEndTabName, ScRefFlags& nFlags, + bool bOnlyAcceptSingle, + const css::uno::Sequence<css::sheet::ExternalLinkInfo>* pExternalLinks = nullptr, + const OUString* pErrRef = nullptr ); + + /** Returns string with formatted cell range from aStart to aEnd, + according to provided address convention. + @param nFlags + Cell reference flags + @param rDocument + Reference to document which is used for example to get tab names. + @param rDetails + Provide information about required address convention. + Supported address conventions are: + CONV_OOO 'doc'#sheet.A1:sheet2.B2 + CONV_XL_A1, [doc]sheet:sheet2!A1:B2 + CONV_XL_OOX, [#]sheet:sheet2!A1:B2 + CONV_XL_R1C1, [doc]sheet:sheet2!R1C1:R2C2 + @param bFullAddressNotation + If TRUE, the full address notation will be used. + For example in case all columns are used, "A1:AMJ177" is full address notation + and "1:177" is shortened address notation. + @returns + String contains formatted cell range in address convention + */ + OUString Format( const ScDocument& rDocument, + ScRefFlags nFlags = ScRefFlags::ZERO, + const ScAddress::Details& rDetails = ScAddress::detailsOOOa1, + bool bFullAddressNotation = false ) const; + + inline void GetVars( SCCOL& nCol1, SCROW& nRow1, SCTAB& nTab1, + SCCOL& nCol2, SCROW& nRow2, SCTAB& nTab2 ) const; + void PutInOrder() { aStart.PutInOrder(aEnd); } + + /** + @param rErrorRange + If FALSE is returned, the positions contain <0 or >MAX... + values if shifted out of bounds. + @param pDocument + The document for the maximum defined sheet number. + */ + [[nodiscard]] bool Move( SCCOL aDeltaX, SCROW aDeltaY, SCTAB aDeltaZ, + ScRange& rErrorRange, const ScDocument& rDoc ); + + /** Same as Move() but with sticky end col/row anchors. */ + [[nodiscard]] bool MoveSticky( const ScDocument& rDoc, SCCOL aDeltaX, SCROW aDeltaY, SCTAB aDeltaZ, + ScRange& rErrorRange ); + + void IncColIfNotLessThan(const ScDocument& rDoc, SCCOL nStartCol, SCCOL nOffset); + void IncRowIfNotLessThan(const ScDocument& rDoc, SCROW nStartRow, SCROW nOffset); + + void ExtendTo( const ScRange& rRange ); + + ScRange Intersection( const ScRange& rOther ) const; + + /// If maximum end column should not be adapted during reference update. + bool IsEndColSticky( const ScDocument& rDoc ) const; + /// If maximum end row should not be adapted during reference update. + bool IsEndRowSticky( const ScDocument& rDoc ) const; + + /** Increment or decrement end column unless sticky or until it becomes + sticky. Checks if the range encompasses at least two columns so should + be called before adjusting the start column. */ + void IncEndColSticky( const ScDocument& rDoc, SCCOL nDelta ); + + /** Increment or decrement end row unless sticky or until it becomes + sticky. Checks if the range encompasses at least two rows so should + be called before adjusting the start row. */ + void IncEndRowSticky( const ScDocument& rDoc, SCROW nDelta ); + + inline bool operator==( const ScRange& rRange ) const; + inline bool operator!=( const ScRange& rRange ) const; + inline bool operator<( const ScRange& rRange ) const; + inline bool operator<=( const ScRange& rRange ) const; + + /// Hash 2D area ignoring table number. + inline size_t hashArea() const; + /// Hash start column and start and end rows. + inline size_t hashStartColumn() const; +}; + +// For use in SAL_DEBUG etc. Output format not guaranteed to be stable. +template<typename charT, typename traits> +inline std::basic_ostream<charT, traits> & operator <<(std::basic_ostream<charT, traits> & stream, const ScRange& rRange) +{ + stream << rRange.aStart; + if (rRange.aEnd != rRange.aStart) + { + stream << ":"; + if (rRange.aEnd.Tab() != rRange.aStart.Tab()) + stream << rRange.aEnd; + else + stream << + "R" << rRange.aEnd.Row()+1 << + "C" << rRange.aEnd.Col()+1; + } + + return stream; +} + +inline void ScRange::GetVars( SCCOL& nCol1, SCROW& nRow1, SCTAB& nTab1, + SCCOL& nCol2, SCROW& nRow2, SCTAB& nTab2 ) const +{ + aStart.GetVars( nCol1, nRow1, nTab1 ); + aEnd.GetVars( nCol2, nRow2, nTab2 ); +} + +inline bool ScRange::operator==( const ScRange& rRange ) const +{ + return ( (aStart == rRange.aStart) && (aEnd == rRange.aEnd) ); +} + +inline bool ScRange::operator!=( const ScRange& rRange ) const +{ + return !operator==( rRange ); +} + +/// Sort on upper left corner tab,col,row, if equal then use lower right too. +inline bool ScRange::operator<( const ScRange& r ) const +{ + return aStart < r.aStart || (aStart == r.aStart && aEnd < r.aEnd) ; +} + +inline bool ScRange::operator<=( const ScRange& rRange ) const +{ + return operator<( rRange ) || operator==( rRange ); +} + +inline bool ScRange::Contains( const ScAddress& rAddress ) const +{ + return + aStart.Col() <= rAddress.Col() && rAddress.Col() <= aEnd.Col() && + aStart.Row() <= rAddress.Row() && rAddress.Row() <= aEnd.Row() && + aStart.Tab() <= rAddress.Tab() && rAddress.Tab() <= aEnd.Tab(); +} + +inline bool ScRange::Contains( const ScRange& rRange ) const +{ + return + aStart.Col() <= rRange.aStart.Col() && rRange.aEnd.Col() <= aEnd.Col() && + aStart.Row() <= rRange.aStart.Row() && rRange.aEnd.Row() <= aEnd.Row() && + aStart.Tab() <= rRange.aStart.Tab() && rRange.aEnd.Tab() <= aEnd.Tab(); +} + +inline bool ScRange::Intersects( const ScRange& rRange ) const +{ + return + aStart.Col() <= rRange.aEnd.Col() && rRange.aStart.Col() <= aEnd.Col() && + aStart.Row() <= rRange.aEnd.Row() && rRange.aStart.Row() <= aEnd.Row() && + aStart.Tab() <= rRange.aEnd.Tab() && rRange.aStart.Tab() <= aEnd.Tab(); +} + +inline size_t ScRange::hashArea() const +{ +#if SAL_TYPES_SIZEOFPOINTER == 8 + // 12 bits for the columns and 20 bits for the rows + return + (static_cast<size_t>(aStart.Row()) << 44) ^ + (static_cast<size_t>(aStart.Col()) << 32) ^ + (static_cast<size_t>(aEnd.Col()) << 20) ^ + static_cast<size_t>(aEnd.Row()); +#else + // Assume that there are not that many ranges with identical corners so we + // won't have too many collisions. Also assume that more lower row and + // column numbers are used so that there are not too many conflicts with + // the columns hashed into the values, and that start row and column + // usually don't exceed certain values. High bits are not masked off and + // may overlap with lower bits of other values, e.g. if start column is + // greater than assumed. + return + (static_cast<size_t>(aStart.Row()) << 26) ^ // start row <= 2^6 + (static_cast<size_t>(aStart.Col()) << 21) ^ // start column <= 2^5 + (static_cast<size_t>(aEnd.Col()) << 15) ^ // end column <= 2^6 + static_cast<size_t>(aEnd.Row()); // end row <= 2^15 +#endif +} + +inline size_t ScRange::hashStartColumn() const +{ +#if SAL_TYPES_SIZEOFPOINTER == 8 + // 20 bits for the rows + return + (static_cast<size_t>(aStart.Col()) << 40) ^ + (static_cast<size_t>(aStart.Row()) << 20) ^ + static_cast<size_t>(aEnd.Row()); +#else + // Assume that for the start row more lower row numbers are used so that + // there are not too many conflicts with the column hashed into the higher + // values. + return + (static_cast<size_t>(aStart.Col()) << 24) ^ // start column <= 2^8 + (static_cast<size_t>(aStart.Row()) << 16) ^ // start row <= 2^8 + static_cast<size_t>(aEnd.Row()); +#endif +} + +[[nodiscard]] inline bool ValidRange( const ScRange& rRange, SCCOL nMaxCol, SCROW nMaxRow ) +{ + return ValidAddress(rRange.aStart, nMaxCol, nMaxRow) && ValidAddress(rRange.aEnd, nMaxCol, nMaxRow); +} + +// ScRangePair +class SAL_WARN_UNUSED ScRangePair final +{ +private: + std::array<ScRange,2> aRange; + +public: + ScRangePair( const ScRangePair& r ) + { + aRange[0] = r.aRange[0]; + aRange[1] = r.aRange[1]; + } + ScRangePair( const ScRange& rRange1, const ScRange& rRange2 ) + { + aRange[0] = rRange1; + aRange[1] = rRange2; + } + + inline ScRangePair& operator= ( const ScRangePair& rRange ); + const ScRange& GetRange( sal_uInt16 n ) const + { + return aRange[n]; + } + ScRange& GetRange( sal_uInt16 n ) + { + return aRange[n]; + } +}; + +inline ScRangePair& ScRangePair::operator= ( const ScRangePair& rRange ) +{ + aRange[0] = rRange.aRange[0]; + aRange[1] = rRange.aRange[1]; + return *this; +} + +// ScRefAddress +class SAL_WARN_UNUSED ScRefAddress +{ +private: + ScAddress aAdr; + bool bRelCol; + bool bRelRow; + bool bRelTab; +public: + ScRefAddress() : + bRelCol(false), bRelRow(false), bRelTab(false) + {} + ScRefAddress( SCCOL nCol, SCROW nRow, SCTAB nTab ) : + aAdr(nCol, nRow, nTab), + bRelCol(false), bRelRow(false), bRelTab(false) + {} + ScRefAddress( const ScRefAddress& rRef ) : + aAdr(rRef.aAdr), bRelCol(rRef.bRelCol), bRelRow(rRef.bRelRow), + bRelTab(rRef.bRelTab) + {} + + inline ScRefAddress& operator=( const ScRefAddress& ); + + bool IsRelCol() const + { + return bRelCol; + } + bool IsRelRow() const + { + return bRelRow; + } + bool IsRelTab() const + { + return bRelTab; + } + + void SetRelCol(bool bNewRelCol) + { + bRelCol = bNewRelCol; + } + void SetRelRow(bool bNewRelRow) + { + bRelRow = bNewRelRow; + } + void SetRelTab(bool bNewRelTab) + { + bRelTab = bNewRelTab; + } + + inline void Set( const ScAddress& rAdr, + bool bNewRelCol, bool bNewRelRow, bool bNewRelTab ); + inline void Set( SCCOL nNewCol, SCROW nNewRow, SCTAB nNewTab, + bool bNewRelCol, bool bNewRelRow, bool bNewRelTab ); + + const ScAddress& GetAddress() const + { + return aAdr; + } + + SCCOL Col() const + { + return aAdr.Col(); + } + SCROW Row() const + { + return aAdr.Row(); + } + SCTAB Tab() const + { + return aAdr.Tab(); + } + + inline bool operator == ( const ScRefAddress& r ) const; + + OUString GetRefString( const ScDocument& rDocument, SCTAB nActTab, + const ScAddress::Details& rDetails = ScAddress::detailsOOOa1) const; +}; + +inline ScRefAddress& ScRefAddress::operator=( const ScRefAddress& rRef ) +{ + aAdr = rRef.aAdr; + bRelCol = rRef.bRelCol; + bRelRow = rRef.bRelRow; + bRelTab = rRef.bRelTab; + return *this; +} + +inline void ScRefAddress::Set( const ScAddress& rAdr, + bool bNewRelCol, bool bNewRelRow, bool bNewRelTab ) +{ + aAdr = rAdr; + bRelCol = bNewRelCol; + bRelRow = bNewRelRow; + bRelTab = bNewRelTab; +} + +inline void ScRefAddress::Set( SCCOL nNewCol, SCROW nNewRow, SCTAB nNewTab, + bool bNewRelCol, bool bNewRelRow, bool bNewRelTab ) +{ + aAdr.Set( nNewCol, nNewRow, nNewTab); + bRelCol = bNewRelCol; + bRelRow = bNewRelRow; + bRelTab = bNewRelTab; +} + +inline bool ScRefAddress::operator==( const ScRefAddress& rRefAddress ) const +{ + return aAdr == rRefAddress.aAdr && + bRelCol == rRefAddress.bRelCol && + bRelRow == rRefAddress.bRelRow && + bRelTab == rRefAddress.bRelTab; +} + +// Global functions + +// Special values for cells always broadcasting or listening (ScRecalcMode::ALWAYS +// and the like). +#define BCA_BRDCST_ALWAYS ScAddress( 0, SCROW_MAX, 0 ) +#define BCA_LISTEN_ALWAYS ScRange( BCA_BRDCST_ALWAYS, BCA_BRDCST_ALWAYS ) + +bool ConvertSingleRef( const ScDocument& pDocument, const OUString& rRefString, + SCTAB nDefTab, ScRefAddress& rRefAddress, + const ScAddress::Details& rDetails, + ScAddress::ExternalInfo* pExtInfo = nullptr ); + +bool ConvertDoubleRef( const ScDocument& rDocument, const OUString& rRefString, + SCTAB nDefTab, ScRefAddress& rStartRefAddress, + ScRefAddress& rEndRefAddress, + const ScAddress::Details& rDetails, + ScAddress::ExternalInfo* pExtInfo = nullptr ); + +/// append alpha representation of column to buffer +SC_DLLPUBLIC void ScColToAlpha( OUStringBuffer& rBuffer, SCCOL nCol); + +inline void ScColToAlpha( OUString& rStr, SCCOL nCol) +{ + OUStringBuffer aBuf(4); + ScColToAlpha( aBuf, nCol); + rStr += aBuf; +} + +inline OUString ScColToAlpha( SCCOL nCol ) +{ + OUStringBuffer aBuf(4); + ScColToAlpha( aBuf, nCol); + return aBuf.makeStringAndClear(); +} + +/// get column number of A..IV... string +bool AlphaToCol(const ScDocument& rDoc, SCCOL& rCol, std::u16string_view rStr); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/addruno.hxx b/sc/inc/addruno.hxx new file mode 100644 index 0000000000..54c91ed6ff --- /dev/null +++ b/sc/inc/addruno.hxx @@ -0,0 +1,72 @@ +/* -*- 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/lang/XServiceInfo.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <cppuhelper/implbase.hxx> +#include <svl/lstner.hxx> +#include "address.hxx" + +#include <docsh.hxx> + +class ScAddressConversionObj final : public ::cppu::WeakImplHelper< + css::beans::XPropertySet, + css::lang::XServiceInfo >, + public SfxListener +{ +private: + ScDocShell* pDocShell; + ScRange aRange; + sal_Int32 nRefSheet; + bool bIsRange; + + bool ParseUIString( const OUString& rUIString, ::formula::FormulaGrammar::AddressConvention eConv = ::formula::FormulaGrammar::CONV_OOO ); + +public: + + ScAddressConversionObj(ScDocShell* pDocSh, bool bIsRange); + virtual ~ScAddressConversionObj() override; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + // XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > + SAL_CALL getPropertySetInfo() override; + virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, + const css::uno::Any& aValue ) override; + virtual css::uno::Any SAL_CALL getPropertyValue( + const OUString& PropertyName ) override; + virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override; + virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override; + virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + + // XServiceInfo + 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; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/afmtuno.hxx b/sc/inc/afmtuno.hxx new file mode 100644 index 0000000000..6434a5073c --- /dev/null +++ b/sc/inc/afmtuno.hxx @@ -0,0 +1,184 @@ +/* -*- 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 <rtl/ref.hxx> +#include <svl/itemprop.hxx> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/container/XIndexAccess.hpp> +#include <com/sun/star/container/XEnumerationAccess.hpp> +#include <com/sun/star/container/XNameContainer.hpp> +#include <com/sun/star/container/XNamed.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <comphelper/servicehelper.hxx> +#include <cppuhelper/implbase.hxx> + +#include <climits> + +class ScAutoFormatFieldObj; +class ScAutoFormatObj; + +#define SC_AFMTOBJ_INVALID USHRT_MAX + +class ScAutoFormatsObj final : public ::cppu::WeakImplHelper< + css::container::XNameContainer, + css::container::XEnumerationAccess, + css::container::XIndexAccess, + css::lang::XServiceInfo > +{ +private: + static rtl::Reference<ScAutoFormatObj> GetObjectByIndex_Impl(sal_uInt16 nIndex); + static rtl::Reference<ScAutoFormatObj> GetObjectByName_Impl(std::u16string_view aName); + +public: + ScAutoFormatsObj(); + virtual ~ScAutoFormatsObj() override; + + // XNameContainer + virtual void SAL_CALL insertByName( const OUString& aName, + const css::uno::Any& aElement ) override; + virtual void SAL_CALL removeByName( const OUString& Name ) override; + + // XNameReplace + virtual void SAL_CALL replaceByName( const OUString& aName, + const css::uno::Any& aElement ) override; + + // XNameAccess + virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override; + virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override; + + // XElementAccess + virtual css::uno::Type SAL_CALL getElementType() override; + virtual sal_Bool SAL_CALL hasElements() override; + + // XEnumerationAccess + virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL + createEnumeration() override; + + // XIndexAccess + virtual sal_Int32 SAL_CALL getCount() override; + virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override; + + // XServiceInfo + 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; +}; + +class ScAutoFormatObj final : public ::cppu::WeakImplHelper< + css::container::XIndexAccess, + css::container::XEnumerationAccess, + css::container::XNamed, + css::beans::XPropertySet, + css::lang::XServiceInfo > +{ +private: + SfxItemPropertySet aPropSet; + sal_uInt16 nFormatIndex; + + rtl::Reference<ScAutoFormatFieldObj> GetObjectByIndex_Impl(sal_uInt16 nIndex); + +public: + ScAutoFormatObj(sal_uInt16 nIndex); + virtual ~ScAutoFormatObj() override; + + // called via getImplementation: + bool IsInserted() const { return nFormatIndex != SC_AFMTOBJ_INVALID; } + void InitFormat( sal_uInt16 nNewIndex ); + + // XIndexAccess + virtual sal_Int32 SAL_CALL getCount() override; + virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override; + + // XElementAccess + virtual css::uno::Type SAL_CALL getElementType() override; + virtual sal_Bool SAL_CALL hasElements() override; + + // XEnumerationAccess + virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL + createEnumeration() override; + + // XNamed + virtual OUString SAL_CALL getName() override; + virtual void SAL_CALL setName( const OUString& aName ) override; + + // XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > + SAL_CALL getPropertySetInfo() override; + virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, + const css::uno::Any& aValue ) override; + virtual css::uno::Any SAL_CALL getPropertyValue( + const OUString& PropertyName ) override; + virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< + css::beans::XPropertyChangeListener >& xListener ) override; + virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< + css::beans::XPropertyChangeListener >& aListener ) override; + virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< + css::beans::XVetoableChangeListener >& aListener ) override; + virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< + css::beans::XVetoableChangeListener >& aListener ) override; + + // XServiceInfo + 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; +}; + +class ScAutoFormatFieldObj final : public ::cppu::WeakImplHelper< + css::beans::XPropertySet, + css::lang::XServiceInfo > +{ +private: + SfxItemPropertySet aPropSet; + sal_uInt16 nFormatIndex; + sal_uInt16 nFieldIndex; + +public: + ScAutoFormatFieldObj(sal_uInt16 nFormat, sal_uInt16 nField); + virtual ~ScAutoFormatFieldObj() override; + + // XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > + SAL_CALL getPropertySetInfo() override; + virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, + const css::uno::Any& aValue ) override; + virtual css::uno::Any SAL_CALL getPropertyValue( + const OUString& PropertyName ) override; + virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override; + virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override; + virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + + // XServiceInfo + 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; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/appluno.hxx b/sc/inc/appluno.hxx new file mode 100644 index 0000000000..c1dcc4b5fb --- /dev/null +++ b/sc/inc/appluno.hxx @@ -0,0 +1,226 @@ +/* -*- 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 <svl/itemprop.hxx> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/sheet/XRecentFunctions.hpp> +#include <com/sun/star/sheet/XFunctionDescriptions.hpp> +#include <com/sun/star/sheet/XGlobalSheetSettings.hpp> +#include <com/sun/star/container/XEnumerationAccess.hpp> +#include <com/sun/star/container/XNameAccess.hpp> +#include <cppuhelper/implbase.hxx> +#include <rtl/ustring.hxx> +#include <sfx2/sfxmodelfactory.hxx> + +namespace com::sun::star::lang { class XMultiServiceFactory; } + +css::uno::Reference<css::uno::XInterface> + ScSpreadsheetSettings_CreateInstance( + const css::uno::Reference< css::lang::XMultiServiceFactory>& rSMgr ); +css::uno::Reference<css::uno::XInterface> SAL_CALL + ScRecentFunctionsObj_CreateInstance( + const css::uno::Reference< css::lang::XMultiServiceFactory>& rSMgr ); +css::uno::Reference<css::uno::XInterface> SAL_CALL + ScFunctionListObj_CreateInstance( + const css::uno::Reference< css::lang::XMultiServiceFactory>& rSMgr ); + + +class ScSpreadsheetSettings final : public cppu::WeakImplHelper< + css::sheet::XGlobalSheetSettings, + css::beans::XPropertySet, + css::lang::XServiceInfo> +{ +private: + SfxItemPropertySet aPropSet; + + /// @throws css::uno::RuntimeException + bool getPropertyBool(const OUString& aPropertyName); + /// @throws css::uno::RuntimeException + sal_Int16 getPropertyInt16(const OUString& aPropertyName); + /// @throws css::uno::RuntimeException + void setProperty(const OUString& aPropertyName, bool p1) + { setPropertyValue( aPropertyName, css::uno::Any(p1) ); } + /// @throws css::uno::RuntimeException + void setProperty(const OUString& aPropertyName, sal_Int16 p1) + { setPropertyValue( aPropertyName, css::uno::Any(p1) ); } +public: + ScSpreadsheetSettings(); + virtual ~ScSpreadsheetSettings() override; + + // XGlobalSheetSettings + virtual sal_Bool SAL_CALL getMoveSelection() override + { return getPropertyBool("MoveSelection"); } + virtual void SAL_CALL setMoveSelection(sal_Bool p1) override + { setProperty("MoveSelection", static_cast<bool>(p1)); } + virtual sal_Int16 SAL_CALL getMoveDirection() override + { return getPropertyInt16("MoveDirection"); } + virtual void SAL_CALL setMoveDirection(sal_Int16 p1) override + { setProperty("MoveDirection", p1); } + virtual sal_Bool SAL_CALL getEnterEdit() override + { return getPropertyBool("EnterEdit"); } + virtual void SAL_CALL setEnterEdit(sal_Bool p1) override + { setProperty("EnterEdit", static_cast<bool>(p1)); } + virtual sal_Bool SAL_CALL getExtendFormat() override + { return getPropertyBool("ExtendFormat"); } + virtual void SAL_CALL setExtendFormat(sal_Bool p1) override + { setProperty("ExtendFormat", static_cast<bool>(p1)); } + virtual sal_Bool SAL_CALL getRangeFinder() override + { return getPropertyBool("RangeFinder"); } + virtual void SAL_CALL setRangeFinder(sal_Bool p1) override + { setProperty("RangeFinder", static_cast<bool>(p1)); } + virtual sal_Bool SAL_CALL getExpandReferences() override + { return getPropertyBool("ExpandReferences"); } + virtual void SAL_CALL setExpandReferences(sal_Bool p1) override + { setProperty("ExpandReferences", static_cast<bool>(p1)); } + virtual sal_Bool SAL_CALL getMarkHeader() override + { return getPropertyBool("MarkHeader"); } + virtual void SAL_CALL setMarkHeader(sal_Bool p1) override + { setProperty("MarkHeader", static_cast<bool>(p1)); } + virtual sal_Bool SAL_CALL getUseTabCol() override + { return getPropertyBool("UseTabCol"); } + virtual void SAL_CALL setUseTabCol(sal_Bool p1) override + { setProperty("UseTabCol", static_cast<bool>(p1)); } + virtual sal_Int16 SAL_CALL getMetric() override + { return getPropertyInt16("Metric"); } + virtual void SAL_CALL setMetric(sal_Int16 p1) override + { setProperty("Metric", p1); } + virtual sal_Int16 SAL_CALL getScale() override + { return getPropertyInt16("Scale"); } + virtual void SAL_CALL setScale(sal_Int16 p1) override + { setProperty("Scale", p1); } + virtual sal_Bool SAL_CALL getDoAutoComplete() override + { return getPropertyBool("DoAutoComplete"); } + virtual void SAL_CALL setDoAutoComplete(sal_Bool p1) override + { setProperty("DoAutoComplete", static_cast<bool>(p1)); } + virtual sal_Int16 SAL_CALL getStatusBarFunction() override + { return getPropertyInt16("StatusBarFunction"); } + virtual void SAL_CALL setStatusBarFunction(sal_Int16 p1) override + { setProperty("StatusBarFunction", p1); } + virtual css::uno::Sequence<OUString> SAL_CALL getUserLists() override + { + css::uno::Any any = getPropertyValue("UserLists"); + css::uno::Sequence<OUString> b; + any >>= b; + return b; + } + virtual void SAL_CALL setUserLists(const css::uno::Sequence<OUString>& p1) override + { setPropertyValue( "UserLists", css::uno::Any(p1) ); } + virtual sal_Int16 SAL_CALL getLinkUpdateMode() override + { return getPropertyInt16("LinkUpdateMode"); } + virtual void SAL_CALL setLinkUpdateMode(sal_Int16 p1) override + { setProperty("LinkUpdateMode", p1); } + virtual sal_Bool SAL_CALL getPrintAllSheets() override + { return getPropertyBool("PrintAllSheets"); } + virtual void SAL_CALL setPrintAllSheets(sal_Bool p1) override + { setProperty("PrintAllSheets", static_cast<bool>(p1)); } + virtual sal_Bool SAL_CALL getPrintEmptyPages() override + { return getPropertyBool("PrintEmptyPages"); } + virtual void SAL_CALL setPrintEmptyPages(sal_Bool p1) override + { setProperty("PrintEmptyPages", static_cast<bool>(p1)); } + virtual sal_Bool SAL_CALL getUsePrinterMetrics() override + { return getPropertyBool("UsePrinterMetrics"); } + virtual void SAL_CALL setUsePrinterMetrics(sal_Bool p1) override + { setProperty("UsePrinterMetrics", static_cast<bool>(p1)); } + virtual sal_Bool SAL_CALL getReplaceCellsWarning() override + { return getPropertyBool("ReplaceCellsWarning"); } + virtual void SAL_CALL setReplaceCellsWarning(sal_Bool p1) override + { setProperty("ReplaceCellsWarning", static_cast<bool>(p1)); } + + // XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > + SAL_CALL getPropertySetInfo() override; + virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, + const css::uno::Any& aValue ) override; + virtual css::uno::Any SAL_CALL getPropertyValue( + const OUString& PropertyName ) override; + virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override; + virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override; + virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + + // XServiceInfo + 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; +}; + +class ScRecentFunctionsObj final : public cppu::WeakImplHelper< + css::sheet::XRecentFunctions, + css::lang::XServiceInfo> +{ +public: + ScRecentFunctionsObj(); + virtual ~ScRecentFunctionsObj() override; + + // XRecentFunctions + virtual css::uno::Sequence< sal_Int32 > SAL_CALL getRecentFunctionIds() override; + virtual void SAL_CALL setRecentFunctionIds( const css::uno::Sequence< sal_Int32 >& aRecentFunctionIds ) override; + virtual sal_Int32 SAL_CALL getMaxRecentFunctions() override; + + // XServiceInfo + 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; +}; + +class ScFunctionListObj final : public cppu::WeakImplHelper< + css::sheet::XFunctionDescriptions, + css::container::XEnumerationAccess, + css::container::XNameAccess, + css::lang::XServiceInfo> +{ +public: + ScFunctionListObj(); + virtual ~ScFunctionListObj() override; + + // XFunctionDescriptions + virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL + getById( sal_Int32 nId ) override; + + // XNameAccess + virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override; + virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override; + + // XIndexAccess + virtual sal_Int32 SAL_CALL getCount() override; + virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override; + + // XEnumerationAccess + virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL + createEnumeration() override; + + // XElementAccess + virtual css::uno::Type SAL_CALL getElementType() override; + virtual sal_Bool SAL_CALL hasElements() override; + + // XServiceInfo + 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; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/appoptio.hxx b/sc/inc/appoptio.hxx new file mode 100644 index 0000000000..d9e22c9cba --- /dev/null +++ b/sc/inc/appoptio.hxx @@ -0,0 +1,162 @@ +/* -*- 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 <sfx2/zoomitem.hxx> +#include "scdllapi.h" +#include "global.hxx" +#include "optutil.hxx" +#include <tools/fldunit.hxx> +#include <tools/color.hxx> +#include <tools/link.hxx> + +class SC_DLLPUBLIC ScAppOptions +{ +public: + ScAppOptions(); + ScAppOptions( const ScAppOptions& rCpy ); + ~ScAppOptions(); + + void SetDefaults(); + + void SetAppMetric( FieldUnit eUnit ) { eMetric = eUnit; } + FieldUnit GetAppMetric() const { return eMetric; } + void SetZoom( sal_uInt16 nNew ) { nZoom = nNew; } + sal_uInt16 GetZoom() const { return nZoom; } + void SetZoomType( SvxZoomType eNew ) { eZoomType = eNew; } + SvxZoomType GetZoomType() const { return eZoomType; } + void SetSynchronizeZoom( bool bNew ) { bSynchronizeZoom = bNew; } + bool GetSynchronizeZoom() const { return bSynchronizeZoom; } + sal_uInt16 GetLRUFuncListCount() const { return nLRUFuncCount; } + sal_uInt16* GetLRUFuncList() const { return pLRUList.get(); } + void SetLRUFuncList( const sal_uInt16* pList, + const sal_uInt16 nCount ); + void SetStatusFunc( sal_uInt32 nNew ) { nStatusFunc = nNew; } + sal_uInt32 GetStatusFunc() const { return nStatusFunc; } + void SetAutoComplete( bool bNew ) { bAutoComplete = bNew; } + bool GetAutoComplete() const { return bAutoComplete; } + void SetDetectiveAuto( bool bNew ) { bDetectiveAuto = bNew; } + bool GetDetectiveAuto() const { return bDetectiveAuto; } + + void SetTrackContentColor(Color nNew) { nTrackContentColor = nNew; } + Color GetTrackContentColor() const { return nTrackContentColor; } + void SetTrackInsertColor(Color nNew) { nTrackInsertColor = nNew; } + Color GetTrackInsertColor() const { return nTrackInsertColor; } + void SetTrackDeleteColor(Color nNew) { nTrackDeleteColor = nNew; } + Color GetTrackDeleteColor() const { return nTrackDeleteColor; } + void SetTrackMoveColor(Color nNew) { nTrackMoveColor = nNew; } + Color GetTrackMoveColor() const { return nTrackMoveColor; } + + ScLkUpdMode GetLinkMode() const { return eLinkMode ;} + void SetLinkMode( ScLkUpdMode nSet ) { eLinkMode = nSet;} + + void SetDefaultObjectSizeWidth(sal_Int32 nNew) { nDefaultObjectSizeWidth = nNew; } + sal_Int32 GetDefaultObjectSizeWidth() const { return nDefaultObjectSizeWidth; } + void SetDefaultObjectSizeHeight(sal_Int32 nNew) { nDefaultObjectSizeHeight = nNew; } + sal_Int32 GetDefaultObjectSizeHeight() const { return nDefaultObjectSizeHeight; } + + void SetShowSharedDocumentWarning( bool bNew ) { mbShowSharedDocumentWarning = bNew; } + bool GetShowSharedDocumentWarning() const { return mbShowSharedDocumentWarning; } + ScOptionsUtil::KeyBindingType GetKeyBindingType() const { return meKeyBindingType; } + void SetKeyBindingType( ScOptionsUtil::KeyBindingType e ) { meKeyBindingType = e; } + + void SetLinksInsertedLikeMSExcel(bool bNew) { mbLinksInsertedLikeMSExcel = bNew; } + bool GetLinksInsertedLikeMSExcel() const { return mbLinksInsertedLikeMSExcel; } + + ScAppOptions& operator= ( const ScAppOptions& rOpt ); + +private: + FieldUnit eMetric; + sal_uInt16 nLRUFuncCount; + std::unique_ptr<sal_uInt16[]> + pLRUList; + SvxZoomType eZoomType; + sal_uInt16 nZoom; + bool bSynchronizeZoom; + sal_uInt32 nStatusFunc; + bool bAutoComplete; + bool bDetectiveAuto; + Color nTrackContentColor; + Color nTrackInsertColor; + Color nTrackDeleteColor; + Color nTrackMoveColor; + ScLkUpdMode eLinkMode; + sal_Int32 nDefaultObjectSizeWidth; + sal_Int32 nDefaultObjectSizeHeight; + bool mbShowSharedDocumentWarning; + ScOptionsUtil::KeyBindingType meKeyBindingType; + bool mbLinksInsertedLikeMSExcel; +}; + +// Config Item containing app options + +class ScAppCfg : private ScAppOptions +{ + // spread about 5 config paths + //! split ScAppOptions into different classes + + ScLinkConfigItem aLayoutItem; + ScLinkConfigItem aInputItem; + ScLinkConfigItem aRevisionItem; + ScLinkConfigItem aContentItem; + ScLinkConfigItem aSortListItem; + ScLinkConfigItem aMiscItem; + ScLinkConfigItem aCompatItem; + + void ReadLayoutCfg(); + void ReadInputCfg(); + void ReadRevisionCfg(); + void ReadContentCfg(); + void ReadSortListCfg(); + void ReadMiscCfg(); + void ReadCompatCfg(); + + DECL_LINK( LayoutCommitHdl, ScLinkConfigItem&, void ); + DECL_LINK( InputCommitHdl, ScLinkConfigItem&, void ); + DECL_LINK( RevisionCommitHdl, ScLinkConfigItem&, void ); + DECL_LINK( ContentCommitHdl, ScLinkConfigItem&, void ); + DECL_LINK( SortListCommitHdl, ScLinkConfigItem&, void ); + DECL_LINK( MiscCommitHdl, ScLinkConfigItem&, void ); + DECL_LINK( CompatCommitHdl, ScLinkConfigItem&, void ); + + DECL_LINK( LayoutNotifyHdl, ScLinkConfigItem&, void ); + DECL_LINK( InputNotifyHdl, ScLinkConfigItem&, void ); + DECL_LINK( RevisionNotifyHdl, ScLinkConfigItem&, void ); + DECL_LINK( ContentNotifyHdl, ScLinkConfigItem&, void ); + DECL_LINK( SortListNotifyHdl, ScLinkConfigItem&, void ); + DECL_LINK( MiscNotifyHdl, ScLinkConfigItem&, void ); + DECL_LINK( CompatNotifyHdl, ScLinkConfigItem&, void ); + + static css::uno::Sequence<OUString> GetLayoutPropertyNames(); + static css::uno::Sequence<OUString> GetInputPropertyNames(); + static css::uno::Sequence<OUString> GetRevisionPropertyNames(); + static css::uno::Sequence<OUString> GetContentPropertyNames(); + static css::uno::Sequence<OUString> GetSortListPropertyNames(); + static css::uno::Sequence<OUString> GetMiscPropertyNames(); + static css::uno::Sequence<OUString> GetCompatPropertyNames(); + +public: + ScAppCfg(); + + const ScAppOptions& GetOptions() const { return *this; } + void SetOptions( const ScAppOptions& rNew ); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/arealink.hxx b/sc/inc/arealink.hxx new file mode 100644 index 0000000000..5eff082b6b --- /dev/null +++ b/sc/inc/arealink.hxx @@ -0,0 +1,77 @@ +/* -*- 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 "refreshtimer.hxx" +#include "address.hxx" +#include <sfx2/lnkbase.hxx> +#include "scdllapi.h" + +class SfxObjectShell; +class ScDocShell; + +class SC_DLLPUBLIC ScAreaLink final : public ::sfx2::SvBaseLink, public ScRefreshTimer +{ +private: + ScDocShell* m_pDocSh; + OUString aFileName; + OUString aFilterName; + OUString aOptions; + OUString aSourceArea; + ScRange aDestArea; + bool bAddUndo; + bool bInCreate; + bool bDoInsert; // is set to FALSE for first update + static bool FindExtRange( ScRange& rRange, const ScDocument& rSrcDoc, const OUString& rAreaName ); + +public: + ScAreaLink( ScDocShell* pShell, OUString aFile, + OUString aFilter, OUString aOpt, + OUString aArea, const ScRange& rDest, sal_Int32 nRefreshDelaySeconds ); + virtual ~ScAreaLink() override; + + virtual void Closed() override; + virtual ::sfx2::SvBaseLink::UpdateResult DataChanged( + const OUString& rMimeType, const css::uno::Any & rValue ) override; + + virtual void Edit(weld::Window*, const Link<SvBaseLink&,void>& rEndEditHdl) override; + + bool Refresh( const OUString& rNewFile, const OUString& rNewFilter, + const OUString& rNewArea, sal_Int32 nRefreshDelaySeconds ); + + void SetInCreate(bool bSet) { bInCreate = bSet; } + void SetDoInsert(bool bSet) { bDoInsert = bSet; } + void SetDestArea(const ScRange& rNew); + void SetSource(const OUString& rDoc, const OUString& rFlt, const OUString& rOpt, + const OUString& rArea); + + bool IsEqual( std::u16string_view rFile, std::u16string_view rFilter, std::u16string_view rOpt, + std::u16string_view rSource, const ScRange& rDest ) const; + + const OUString& GetFile() const { return aFileName; } + const OUString& GetFilter() const { return aFilterName; } + const OUString& GetOptions() const { return aOptions; } + const OUString& GetSource() const { return aSourceArea; } + const ScRange& GetDestArea() const { return aDestArea; } + + DECL_DLLPRIVATE_LINK( RefreshHdl, Timer*, void ); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/arraysumfunctor.hxx b/sc/inc/arraysumfunctor.hxx new file mode 100644 index 0000000000..c1eabb220e --- /dev/null +++ b/sc/inc/arraysumfunctor.hxx @@ -0,0 +1,105 @@ +/* -*- 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/. + * + */ + +#pragma once + +#include <cmath> +#include "kahan.hxx" +#include <formula/errorcodes.hxx> + +namespace sc::op +{ +/** + * If no boosts available, Unrolled KahanSum. + */ +static inline KahanSum executeUnrolled(size_t& i, size_t nSize, const double* pCurrent) +{ + size_t nRealSize = nSize - i; + size_t nUnrolledSize = nRealSize - (nRealSize % 4); + + if (nUnrolledSize > 0) + { + KahanSum sum0 = 0.0; + KahanSum sum1 = 0.0; + KahanSum sum2 = 0.0; + KahanSum sum3 = 0.0; + + for (; i + 3 < nUnrolledSize; i += 4) + { + sum0 += *pCurrent++; + sum1 += *pCurrent++; + sum2 += *pCurrent++; + sum3 += *pCurrent++; + } + // We are using pairwise summation alongside Kahan + return (sum0 + sum1) + (sum2 + sum3); + } + return 0.0; +} + +/** + * This function task is to choose the fastest method available to perform the sum. + * @param i + * @param nSize + * @param pCurrent + */ +static inline KahanSum executeFast(size_t& i, size_t nSize, const double* pCurrent) +{ +#if SC_USE_SSE2 + return executeSSE2(i, nSize, pCurrent); +#else + return executeUnrolled(i, nSize, pCurrent); +#endif +} + +/** + * Performs the sum of an array. + * Note that align 16 will speed up the process. + * @param pArray + * @param nSize + */ +inline KahanSum sumArray(const double* pArray, size_t nSize) +{ + size_t i = 0; + const double* pCurrent = pArray; + KahanSum fSum = executeFast(i, nSize, pCurrent); + + // sum rest of the array + for (; i < nSize; ++i) + fSum += pArray[i]; + + // If the sum is a NaN, some of the terms were empty cells, probably. + // Re-calculate, carefully + double fVal = fSum.get(); + if (!std::isfinite(fVal)) + { + FormulaError nErr = GetDoubleErrorValue(fVal); + if (nErr == FormulaError::NoValue) + { + fSum = 0; + for (i = 0; i < nSize; i++) + { + if (!std::isfinite(pArray[i])) + { + nErr = GetDoubleErrorValue(pArray[i]); + if (nErr != FormulaError::NoValue) + fSum += pArray[i]; // Let errors encoded as NaNs propagate ??? + } + else + fSum += pArray[i]; + } + } + } + return fSum; +} + +} // end namespace sc::op + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/attarray.hxx b/sc/inc/attarray.hxx new file mode 100644 index 0000000000..a7e1c08a9f --- /dev/null +++ b/sc/inc/attarray.hxx @@ -0,0 +1,324 @@ +/* -*- 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 "global.hxx" +#include "attrib.hxx" +#include "document.hxx" +#include "patattr.hxx" + +#include <algorithm> +#include <memory> +#include <optional> + +#include <svl/itemset.hxx> + +class ScDocument; +class ScEditDataArray; +class ScMarkArray; +class ScStyleSheet; +class ScFlatBoolRowSegments; + +class ScItemPoolCache; +class SfxStyleSheetBase; +class SvxBoxItem; +class SvxBoxInfoItem; + +namespace editeng { class SvxBorderLine; } + +#define SC_LINE_EMPTY 0 +#define SC_LINE_SET 1 +#define SC_LINE_DONTCARE 2 + +#define SC_ATTRARRAY_DELTA 4 + +#define DEBUG_SC_TESTATTRARRAY 0 + +struct ScLineFlags +{ + sal_uInt8 nLeft; + sal_uInt8 nRight; + sal_uInt8 nTop; + sal_uInt8 nBottom; + sal_uInt8 nHori; + sal_uInt8 nVert; + + ScLineFlags() : nLeft(SC_LINE_EMPTY),nRight(SC_LINE_EMPTY),nTop(SC_LINE_EMPTY), + nBottom(SC_LINE_EMPTY),nHori(SC_LINE_EMPTY),nVert(SC_LINE_EMPTY) {} +}; + +struct ScMergePatternState +{ + std::optional<SfxItemSet> pItemSet; + const ScPatternAttr* pOld1; ///< existing objects, temporary + const ScPatternAttr* pOld2; + + bool mbValidPatternId; + sal_uInt64 mnPatternId; + + ScMergePatternState() : pOld1(nullptr), pOld2(nullptr), + mbValidPatternId(true), mnPatternId(0) {} +}; + +// we store an array of these where the pattern applies to all rows up till nEndRow +struct ScAttrEntry +{ + SCROW nEndRow; + const ScPatternAttr* pPattern; + bool operator==( const ScAttrEntry& other ) const + { + return nEndRow == other.nEndRow && SfxPoolItem::areSame(pPattern, other.pPattern); + } +}; + +class ScAttrArray +{ +private: + SCCOL nCol; + SCTAB nTab; + ScDocument& rDocument; + + std::vector<ScAttrEntry> mvData; + +friend class ScDocument; // for FillInfo +friend class ScDocumentIterator; +friend class ScAttrIterator; +friend class ScHorizontalAttrIterator; + + bool ApplyFrame( const SvxBoxItem& rLineOuter, const SvxBoxInfoItem* pLineInner, + SCROW nStartRow, SCROW nEndRow, + bool bLeft, SCCOL nDistRight, bool bTop, SCROW nDistBottom ); + + void RemoveCellCharAttribs( SCROW nStartRow, SCROW nEndRow, + const ScPatternAttr* pPattern, ScEditDataArray* pDataArray ); + void SetDefaultIfNotInit( SCSIZE nNeeded = 1 ); + bool HasAttrib_Impl(const ScPatternAttr* pPattern, HasAttrFlags nMask, SCROW nRow1, SCROW nRow2, SCSIZE i) const; + + ScAttrArray(const ScAttrArray&) = delete; + ScAttrArray& operator=(const ScAttrArray&) = delete; + +public: + ScAttrArray( SCCOL nNewCol, SCTAB nNewTab, ScDocument& rDoc, ScAttrArray* pNextColAttrArray ); + ~ScAttrArray(); + + ScDocument& GetDoc() { return rDocument; } + const ScDocument& GetDoc() const { return rDocument; } + void SetTab(SCTAB nNewTab) { nTab = nNewTab; } + void SetCol(SCCOL nNewCol) { nCol = nNewCol; } +#if DEBUG_SC_TESTATTRARRAY + void TestData() const; +#endif + void Reset( const ScPatternAttr* pPattern); + bool Concat(SCSIZE nPos); + + const ScPatternAttr* GetPattern( SCROW nRow ) const; + + /** Returns if you search for attributes at nRow the range from rStartRow + to rEndRow where that attribute combination (ScPatternAttr) is applied. + The next ScPatternAttr different from this one starts at rEndRow+1 + (if that is <= MAXROW). + */ + const ScPatternAttr* GetPatternRange( SCROW& rStartRow, SCROW& rEndRow, SCROW nRow ) const; + + void MergePatternArea( SCROW nStartRow, SCROW nEndRow, ScMergePatternState& rState, bool bDeep ) const; + + void MergeBlockFrame( SvxBoxItem* pLineOuter, SvxBoxInfoItem* pLineInner, ScLineFlags& rFlags, + SCROW nStartRow, SCROW nEndRow, bool bLeft, SCCOL nDistRight ) const; + void ApplyBlockFrame(const SvxBoxItem& rLineOuter, const SvxBoxInfoItem* pLineInner, + SCROW nStartRow, SCROW nEndRow, bool bLeft, SCCOL nDistRight); + + void SetPattern( SCROW nRow, const ScPatternAttr* pPattern, bool bPutToPool = false ) + { SetPatternAreaImpl(nRow, nRow, pPattern, bPutToPool, nullptr, /*bPassingOwnership*/false); } + const ScPatternAttr* SetPattern( SCROW nRow, std::unique_ptr<ScPatternAttr> pPattern, bool bPutToPool = false ) + { return SetPatternAreaImpl(nRow, nRow, pPattern.release(), bPutToPool, nullptr, /*bPassingOwnership*/true); } + void SetPatternArea( SCROW nStartRow, SCROW nEndRow, std::unique_ptr<ScPatternAttr> pPattern, + bool bPutToPool = false, ScEditDataArray* pDataArray = nullptr) + { SetPatternAreaImpl(nStartRow, nEndRow, pPattern.release(), bPutToPool, pDataArray, /*bPassingOwnership*/true); } + void SetPatternArea( SCROW nStartRow, SCROW nEndRow, const ScPatternAttr* pPattern, + bool bPutToPool = false, ScEditDataArray* pDataArray = nullptr) + { SetPatternAreaImpl(nStartRow, nEndRow, pPattern, bPutToPool, pDataArray, /*bPassingOwnership*/false); } + void ApplyStyleArea( SCROW nStartRow, SCROW nEndRow, const ScStyleSheet& rStyle ); + void ApplyCacheArea( SCROW nStartRow, SCROW nEndRow, ScItemPoolCache* pCache, + ScEditDataArray* pDataArray = nullptr, bool* const pIsChanged = nullptr ); + void SetAttrEntries(std::vector<ScAttrEntry> && vNewData); + void ApplyLineStyleArea( SCROW nStartRow, SCROW nEndRow, + const ::editeng::SvxBorderLine* pLine, bool bColorOnly ); + + void AddCondFormat( SCROW nStartRow, SCROW nEndRow, sal_uInt32 nIndex ); + /// if nIndex == 0, remove all conditional format data + void RemoveCondFormat( SCROW nStartRow, SCROW nEndRow, sal_uInt32 nIndex ); + + void ClearItems( SCROW nStartRow, SCROW nEndRow, const sal_uInt16* pWhich ); + void ChangeIndent( SCROW nStartRow, SCROW nEndRow, bool bIncrement ); + + /// Including current, may return -1 + SCROW GetNextUnprotected( SCROW nRow, bool bUp ) const; + + /// May return -1 if not found + SCROW SearchStyle( + SCROW nRow, const ScStyleSheet* pSearchStyle, bool bUp, + const ScMarkArray* pMarkArray = nullptr) const; + + bool SearchStyleRange( + SCROW& rRow, SCROW& rEndRow, const ScStyleSheet* pSearchStyle, bool bUp, + const ScMarkArray* pMarkArray = nullptr) const; + + bool ApplyFlags( SCROW nStartRow, SCROW nEndRow, ScMF nFlags ); + bool RemoveFlags( SCROW nStartRow, SCROW nEndRow, ScMF nFlags ); + + bool Search( SCROW nRow, SCSIZE& nIndex, std::optional<SCROW> nIndexHint = {} ) const; + + bool HasAttrib( SCROW nRow1, SCROW nRow2, HasAttrFlags nMask ) const; + bool HasAttrib( SCROW nRow, HasAttrFlags nMask, SCROW* nStartRow = nullptr, SCROW* nEndRow = nullptr ) const; + bool IsMerged( SCROW nRow ) const; + bool ExtendMerge( SCCOL nThisCol, SCROW nStartRow, SCROW nEndRow, + SCCOL& rPaintCol, SCROW& rPaintRow, + bool bRefresh ); + void RemoveAreaMerge( SCROW nStartRow, SCROW nEndRow ); + + void FindStyleSheet( const SfxStyleSheetBase* pStyleSheet, ScFlatBoolRowSegments& rUsedRows, bool bReset ); + bool IsStyleSheetUsed( const ScStyleSheet& rStyle ) const; + + void SetPatternAreaSafe( SCROW nStartRow, SCROW nEndRow, + const ScPatternAttr* pWantedPattern, bool bDefault ); + void CopyAreaSafe( SCROW nStartRow, SCROW nEndRow, tools::Long nDy, ScAttrArray& rAttrArray ); + + bool IsEmpty() const; + + bool GetFirstVisibleAttr( SCROW& rFirstRow ) const; + bool GetLastVisibleAttr( SCROW& rLastRow, SCROW nLastData, bool bSkipEmpty ) const; + bool HasVisibleAttrIn( SCROW nStartRow, SCROW nEndRow ) const; + bool IsVisibleEqual( const ScAttrArray& rOther, + SCROW nStartRow, SCROW nEndRow ) const; + bool IsAllEqual( const ScAttrArray& rOther, SCROW nStartRow, SCROW nEndRow ) const; + + bool TestInsertCol( SCROW nStartRow, SCROW nEndRow) const; + bool TestInsertRow( SCSIZE nSize ) const; + void InsertRow( SCROW nStartRow, SCSIZE nSize ); + void DeleteRow( SCROW nStartRow, SCSIZE nSize ); + void DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex ); + void DeleteArea( SCROW nStartRow, SCROW nEndRow ); + void MoveTo( SCROW nStartRow, SCROW nEndRow, ScAttrArray& rAttrArray ); + void CopyArea( + SCROW nStartRow, SCROW nEndRow, tools::Long nDy, ScAttrArray& rAttrArray, ScMF nStripFlags = ScMF::NONE) const; + + void DeleteHardAttr( SCROW nStartRow, SCROW nEndRow ); + + /* i123909: Pre-calculate needed memory, and pre-reserve enough memory */ + bool Reserve( SCSIZE nReserve ); + SCSIZE Count() const { return mvData.size(); } + SCSIZE Count( SCROW nRow1, SCROW nRow2 ) const; + +private: + const ScPatternAttr* SetPatternAreaImpl( SCROW nStartRow, SCROW nEndRow, const ScPatternAttr* pPattern, + bool bPutToPool = false, ScEditDataArray* pDataArray = nullptr, + bool bPassingPatternOwnership = false ); +}; + +// Iterator for attributes + +class ScAttrIterator +{ + const ScAttrArray* pArray; + const ScPatternAttr* pDefPattern; + SCSIZE nPos; + SCROW nRow; + SCROW nEndRow; +public: + inline ScAttrIterator( const ScAttrArray* pNewArray, SCROW nStart, SCROW nEnd, const ScPatternAttr* pDefaultPattern ); + inline const ScPatternAttr* Next( SCROW& rTop, SCROW& rBottom ); + inline const ScPatternAttr* Resync( SCROW nRow, SCROW& rTop, SCROW& rBottom ); + SCROW GetNextRow() const { return nRow; } +}; + +inline ScAttrIterator::ScAttrIterator( const ScAttrArray* pNewArray, SCROW nStart, SCROW nEnd, const ScPatternAttr* pDefaultPattern ) : + pArray( pNewArray ), + pDefPattern( pDefaultPattern ), + nRow( nStart ), + nEndRow( nEnd ) +{ + if ( pArray->Count() ) + { + if ( nStart > 0 ) + pArray->Search( nStart, nPos ); + else + nPos = 0; + } + else + nPos = 0; +} + +inline const ScPatternAttr* ScAttrIterator::Next( SCROW& rTop, SCROW& rBottom ) +{ + const ScPatternAttr* pRet; + if ( !pArray->Count() ) + { + if ( !nPos ) + { + ++nPos; + if ( nRow > pArray->GetDoc().MaxRow()) + return nullptr; + rTop = nRow; + rBottom = std::min( nEndRow, pArray->GetDoc().MaxRow()); + nRow = rBottom + 1; + return pDefPattern; + } + return nullptr; + } + + if ( nPos < pArray->Count() && nRow <= nEndRow ) + { + rTop = nRow; + rBottom = std::min( pArray->mvData[nPos].nEndRow, nEndRow ); + pRet = pArray->mvData[nPos].pPattern; + nRow = rBottom + 1; + ++nPos; + } + else + pRet = nullptr; + return pRet; +} + +inline const ScPatternAttr* ScAttrIterator::Resync( SCROW nRowP, SCROW& rTop, SCROW& rBottom ) +{ + nRow = nRowP; + if ( !pArray->Count() ) + { + nPos = 0; + return Next( rTop, rBottom ); + } + // Chances are high that the pattern changed on nRowP introduced a span + // starting right there. Assume that Next() was called so nPos already + // advanced. Another high chance is that the change extended a previous or + // next pattern. In all these cases we don't need to search. + if (3 <= nPos && nPos <= pArray->Count() && pArray->mvData[nPos-3].nEndRow < nRowP && + nRowP <= pArray->mvData[nPos-2].nEndRow) + nPos -= 2; + else if (2 <= nPos && nPos <= pArray->Count() && pArray->mvData[nPos-2].nEndRow < nRowP && + nRowP <= pArray->mvData[nPos-1].nEndRow) + --nPos; + else if (pArray->Count() > 0 && nRowP <= pArray->mvData[0].nEndRow) + nPos = 0; + else + pArray->Search( nRowP, nPos ); + return Next( rTop, rBottom); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/attrib.hxx b/sc/inc/attrib.hxx new file mode 100644 index 0000000000..ec004f37d8 --- /dev/null +++ b/sc/inc/attrib.hxx @@ -0,0 +1,365 @@ +/* -*- 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 <memory> +#include <svl/poolitem.hxx> +#include <svl/intitem.hxx> +#include <svl/eitem.hxx> +#include <svx/sdangitm.hxx> +#include <o3tl/sorted_vector.hxx> +#include <o3tl/typed_flags_set.hxx> +#include "scdllapi.h" +#include "global.hxx" + +// flags for cells hidden by merge +// and control for auto filter +enum class ScMF { + NONE = 0x0000, + Hor = 0x0001, + Ver = 0x0002, + Auto = 0x0004, /// autofilter arrow + Button = 0x0008, /// field button for datapilot + Scenario = 0x0010, + ButtonPopup = 0x0020, /// dp button with popup arrow + HiddenMember = 0x0040, /// dp field button with presence of hidden member + DpTable = 0x0080, /// dp table output + DpCollapse = 0x0100, /// dp compact layout collapse button + DpExpand = 0x0200, /// dp compact layout expand button + ButtonPopup2 = 0x0400, /// dp button with popup arrow for multiple fields + All = 0x07FF +}; +namespace o3tl { + template<> struct typed_flags<ScMF> : is_typed_flags<ScMF, 0x07ff> {}; +} + +class EditTextObject; +namespace editeng { class SvxBorderLine; } + +bool SC_DLLPUBLIC ScHasPriority( const ::editeng::SvxBorderLine* pThis, const ::editeng::SvxBorderLine* pOther ); + +class SC_DLLPUBLIC ScMergeAttr final : public SfxPoolItem +{ + SCCOL nColMerge; + SCROW nRowMerge; +public: + ScMergeAttr(); + ScMergeAttr( SCCOL nCol, SCROW nRow ); + ScMergeAttr( const ScMergeAttr& ); + virtual ~ScMergeAttr() override; + + virtual bool operator==( const SfxPoolItem& ) const override; + virtual ScMergeAttr* Clone( SfxItemPool *pPool = nullptr ) const override; + + SCCOL GetColMerge() const {return nColMerge; } + SCROW GetRowMerge() const {return nRowMerge; } + + bool IsMerged() const { return nColMerge>1 || nRowMerge>1; } + + ScMergeAttr& operator=(const ScMergeAttr& rMerge) + { + nColMerge = rMerge.nColMerge; + nRowMerge = rMerge.nRowMerge; + return *this; + } + + virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override; +}; + +class SC_DLLPUBLIC ScMergeFlagAttr final : public SfxInt16Item +{ +public: + ScMergeFlagAttr(); + ScMergeFlagAttr(ScMF nFlags); + virtual ~ScMergeFlagAttr() override; + + ScMergeFlagAttr(ScMergeFlagAttr const &) = default; + ScMergeFlagAttr(ScMergeFlagAttr &&) = default; + ScMergeFlagAttr & operator =(ScMergeFlagAttr const &) = delete; // due to SfxInt16Item + ScMergeFlagAttr & operator =(ScMergeFlagAttr &&) = delete; // due to SfxInt16Item + + ScMergeFlagAttr* Clone(SfxItemPool * pPool = nullptr) const override; + + ScMF GetValue() const { return static_cast<ScMF>(SfxInt16Item::GetValue()); } + + bool IsHorOverlapped() const { return bool( GetValue() & ScMF::Hor ); } + bool IsVerOverlapped() const { return bool( GetValue() & ScMF::Ver ); } + bool IsOverlapped() const { return bool( GetValue() & ( ScMF::Hor | ScMF::Ver ) ); } + + bool HasAutoFilter() const { return bool( GetValue() & ScMF::Auto ); } + + bool IsScenario() const { return bool( GetValue() & ScMF::Scenario ); } + + bool HasPivotButton() const; + bool HasPivotPopupButton() const; + bool HasPivotToggle() const; + bool HasPivotMultiFieldPopupButton() const; + + virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override; +}; + +class SC_DLLPUBLIC ScProtectionAttr final : public SfxPoolItem +{ + bool bProtection; ///< protect cell + bool bHideFormula; ///< hide formula + bool bHideCell; ///< hide cell + bool bHidePrint; ///< don't print cell +public: + static SfxPoolItem* CreateDefault(); + ScProtectionAttr(); + ScProtectionAttr( bool bProtect, + bool bHFormula = false, + bool bHCell = false, + bool bHPrint = false); + ScProtectionAttr( const ScProtectionAttr& ); + virtual ~ScProtectionAttr() override; + + OUString GetValueText() const; + virtual bool GetPresentation( + SfxItemPresentation ePres, + MapUnit eCoreMetric, + MapUnit ePresMetric, + OUString& rText, + const IntlWrapper& rIntl ) const override; + + virtual bool operator==( const SfxPoolItem& ) const override; + virtual ScProtectionAttr* Clone( SfxItemPool *pPool = nullptr ) const override; + + virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override; + virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override; + + bool GetProtection() const { return bProtection; } + void SetProtection( bool bProtect); + bool GetHideFormula() const { return bHideFormula; } + void SetHideFormula( bool bHFormula); + bool GetHideCell() const { return bHideCell; } + void SetHideCell( bool bHCell); + bool GetHidePrint() const { return bHidePrint; } + void SetHidePrint( bool bHPrint); + ScProtectionAttr& operator=(const ScProtectionAttr& rProtection) + { + bProtection = rProtection.bProtection; + bHideFormula = rProtection.bHideFormula; + bHideCell = rProtection.bHideCell; + bHidePrint = rProtection.bHidePrint; + return *this; + } + virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override; +}; + +// page format item: contents of header and footer + +#define SC_HF_LEFTAREA 1 +#define SC_HF_CENTERAREA 2 +#define SC_HF_RIGHTAREA 3 + +class SC_DLLPUBLIC ScPageHFItem final : public SfxPoolItem +{ + std::unique_ptr<EditTextObject> pLeftArea; + std::unique_ptr<EditTextObject> pCenterArea; + std::unique_ptr<EditTextObject> pRightArea; + +public: + ScPageHFItem( sal_uInt16 nWhich ); + ScPageHFItem( const ScPageHFItem& rItem ); + virtual ~ScPageHFItem() override; + + virtual bool operator==( const SfxPoolItem& ) const override; + virtual ScPageHFItem* Clone( SfxItemPool *pPool = nullptr ) const override; + + virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override; + virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override; + + const EditTextObject* GetLeftArea() const { return pLeftArea.get(); } + const EditTextObject* GetCenterArea() const { return pCenterArea.get(); } + const EditTextObject* GetRightArea() const { return pRightArea.get(); } + + void SetLeftArea( const EditTextObject& rNew ); + void SetCenterArea( const EditTextObject& rNew ); + void SetRightArea( const EditTextObject& rNew ); + virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override; +}; + +// page format item: contents of header and footer + +class SC_DLLPUBLIC ScViewObjectModeItem final : public SfxEnumItem<ScVObjMode> +{ +public: + ScViewObjectModeItem( sal_uInt16 nWhich ); + ScViewObjectModeItem( sal_uInt16 nWhich, ScVObjMode eMode ); + virtual ~ScViewObjectModeItem() override; + + ScViewObjectModeItem(ScViewObjectModeItem const &) = default; + ScViewObjectModeItem(ScViewObjectModeItem &&) = default; + ScViewObjectModeItem & operator =(ScViewObjectModeItem const &) = delete; // due to SfxEnumItem<ScVObjMode> + ScViewObjectModeItem & operator =(ScViewObjectModeItem &&) = delete; // due to SfxEnumItem<ScVObjMode> + + virtual sal_uInt16 GetValueCount() const override; + virtual ScViewObjectModeItem* Clone( SfxItemPool *pPool = nullptr ) const override; + virtual bool GetPresentation( SfxItemPresentation ePres, + MapUnit eCoreMetric, + MapUnit ePresMetric, + OUString& rText, + const IntlWrapper& rIntl ) const override; +}; + +/** Member ID for "page scale to width" value in QueryValue() and PutValue(). */ +const sal_uInt8 SC_MID_PAGE_SCALETO_WIDTH = 1; +/** Member ID for "page scale to height" value in QueryValue() and PutValue(). */ +const sal_uInt8 SC_MID_PAGE_SCALETO_HEIGHT = 2; + +/** Contains the "scale to width/height" attribute in page styles. */ +class SC_DLLPUBLIC ScPageScaleToItem final : public SfxPoolItem +{ +public: + /** Default c'tor sets the width and height to 0. */ + explicit ScPageScaleToItem(); + explicit ScPageScaleToItem( sal_uInt16 nWidth, sal_uInt16 nHeight ); + + virtual ~ScPageScaleToItem() override; + + ScPageScaleToItem(ScPageScaleToItem const &) = default; + ScPageScaleToItem(ScPageScaleToItem &&) = default; + ScPageScaleToItem & operator =(ScPageScaleToItem const &) = delete; // due to SfxPoolItem + ScPageScaleToItem & operator =(ScPageScaleToItem &&) = delete; // due to SfxPoolItem + + virtual ScPageScaleToItem* Clone( SfxItemPool* = nullptr ) const override; + + virtual bool operator==( const SfxPoolItem& rCmp ) const override; + + sal_uInt16 GetWidth() const { return mnWidth; } + sal_uInt16 GetHeight() const { return mnHeight; } + bool IsValid() const { return mnWidth || mnHeight; } + + void SetWidth( sal_uInt16 nWidth ) { mnWidth = nWidth; } + void SetHeight( sal_uInt16 nHeight ) { mnHeight = nHeight; } + void Set( sal_uInt16 nWidth, sal_uInt16 nHeight ) + { mnWidth = nWidth; mnHeight = nHeight; } + + virtual bool GetPresentation( SfxItemPresentation ePresentation, + MapUnit, MapUnit, + OUString& rText, + const IntlWrapper& ) const override; + + virtual bool QueryValue( css::uno::Any& rAny, sal_uInt8 nMemberId = 0 ) const override; + virtual bool PutValue( const css::uno::Any& rAny, sal_uInt8 nMemberId ) override; + virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override; + +private: + sal_uInt16 mnWidth; + sal_uInt16 mnHeight; +}; + +typedef o3tl::sorted_vector<sal_uInt32> ScCondFormatIndexes; + +class SAL_DLLPUBLIC_RTTI ScCondFormatItem final : public SfxPoolItem +{ +public: + explicit ScCondFormatItem(); + explicit ScCondFormatItem(sal_uInt32 nIndex); + explicit ScCondFormatItem(const ScCondFormatIndexes& ); + explicit ScCondFormatItem(ScCondFormatIndexes&&) noexcept; + + virtual ~ScCondFormatItem() override; + + virtual bool operator==(const SfxPoolItem& rCmp ) const override; + virtual ScCondFormatItem* Clone( SfxItemPool* = nullptr ) const override; + + const ScCondFormatIndexes& GetCondFormatData() const { return maIndex;} + + virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override; + +private: + ScCondFormatIndexes maIndex; +}; + +class SC_DLLPUBLIC ScRotateValueItem final : public SdrAngleItem +{ +public: + ScRotateValueItem(Degree100 nAngle); + virtual ScRotateValueItem* Clone(SfxItemPool* pPool=nullptr) const override; + + virtual bool GetPresentation( SfxItemPresentation ePresentation, + MapUnit, MapUnit, + OUString& rText, + const IntlWrapper& rIntl) const override; +}; + +class SC_DLLPUBLIC ScShrinkToFitCell final : public SfxBoolItem +{ +public: + ScShrinkToFitCell(bool bShrink = false); + virtual ScShrinkToFitCell* Clone(SfxItemPool *pPool = nullptr) const override; + virtual bool GetPresentation(SfxItemPresentation ePres, + MapUnit eCoreMetric, + MapUnit ePresMetric, + OUString &rText, + const IntlWrapper& rIntl) const override; +}; + +class SC_DLLPUBLIC ScVerticalStackCell final : public SfxBoolItem +{ +public: + ScVerticalStackCell(bool bStack = false); + virtual ScVerticalStackCell* Clone(SfxItemPool *pPool = nullptr) const override; + virtual bool GetPresentation(SfxItemPresentation ePres, + MapUnit eCoreMetric, + MapUnit ePresMetric, + OUString &rText, + const IntlWrapper& rIntl) const override; +}; + +class SC_DLLPUBLIC ScLineBreakCell final : public SfxBoolItem +{ +public: + ScLineBreakCell(bool bLineBreak = false); + virtual ScLineBreakCell* Clone(SfxItemPool *pPool = nullptr) const override; + virtual bool GetPresentation(SfxItemPresentation ePres, + MapUnit eCoreMetric, + MapUnit ePresMetric, + OUString &rText, + const IntlWrapper& rIntl) const override; +}; + +class ScHyphenateCell final : public SfxBoolItem +{ +public: + ScHyphenateCell(bool bHyphenate= false); + virtual ScHyphenateCell* Clone(SfxItemPool *pPool = nullptr) const override; + virtual bool GetPresentation(SfxItemPresentation ePres, + MapUnit eCoreMetric, + MapUnit ePresMetric, + OUString &rText, + const IntlWrapper& rIntl) const override; +}; + +class SC_DLLPUBLIC ScIndentItem final : public SfxUInt16Item +{ +public: + ScIndentItem(sal_uInt16 nIndent = 0); + virtual ScIndentItem* Clone(SfxItemPool* pPool=nullptr) const override; + + virtual bool GetPresentation( SfxItemPresentation ePresentation, + MapUnit, MapUnit, + OUString& rText, + const IntlWrapper& rIntl) const override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/autoform.hxx b/sc/inc/autoform.hxx new file mode 100644 index 0000000000..b6facd437e --- /dev/null +++ b/sc/inc/autoform.hxx @@ -0,0 +1,215 @@ +/* -*- 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 + +/************************************************************************* +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + + The structure of auto formatting should not be changed. It is used + by various code of Writer and Calc. If a change is necessary, the + source code of both applications must be changed! + +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +**************************************************************************/ + +#include <svl/poolitem.hxx> +#include <svx/autoformathelper.hxx> + +#include "scdllapi.h" +#include "zforauto.hxx" + +#include <array> +#include <memory> +#include <map> +#include <climits> + +class ScDocument; + +/** +A binary blob of writer-specific data. This data typically consists of types that are +unavailable to Calc (e.g. SwFmtVertOrient), or that Calc doesn't care about. + +@remarks Note that in autoformat versions prior to AUTOFORMAT_DATA_ID_31005, Calc +logic handled and stored several writer-specific items (such as ScAutoFormatDataField::aAdjust). +That logic was preserved. From _31005 onward, writer-specific data should be handled by +blobs to avoid needlessly complicating the Calc logic. +*/ +struct AutoFormatSwBlob +{ + std::unique_ptr<sal_uInt8[]> pData; + std::size_t size; + + AutoFormatSwBlob() : size(0) + { + } + AutoFormatSwBlob(const AutoFormatSwBlob&) = delete; + const AutoFormatSwBlob& operator=(const AutoFormatSwBlob&) = delete; + + void Reset() + { + pData.reset(); + size = 0; + } +}; + +/// Struct with version numbers of the Items +struct ScAfVersions : public AutoFormatVersions +{ +private: + AutoFormatSwBlob swVersions; + +public: + ScAfVersions(); + + void Load( SvStream& rStream, sal_uInt16 nVer ); + void Write(SvStream& rStream, sal_uInt16 fileVersion); +}; + +/// Contains all items for one cell of a table autoformat. +class ScAutoFormatDataField : public AutoFormatBase +{ +private: + AutoFormatSwBlob m_swFields; + + // number format + ScNumFormatAbbrev aNumFormat; + +public: + ScAutoFormatDataField(); + ScAutoFormatDataField( const ScAutoFormatDataField& rCopy ); + ~ScAutoFormatDataField(); + + // block assignment operator + ScAutoFormatDataField& operator=(const ScAutoFormatDataField& rRef) = delete; + + // number format + const ScNumFormatAbbrev& GetNumFormat() const { return aNumFormat; } + + // number format + void SetNumFormat( const ScNumFormatAbbrev& rNumFormat ) { aNumFormat = rNumFormat; } + + bool Load( SvStream& rStream, const ScAfVersions& rVersions, sal_uInt16 nVer ); + bool Save( SvStream& rStream, sal_uInt16 fileVersion ); +}; + +class SC_DLLPUBLIC ScAutoFormatData +{ +private: + OUString aName; + sal_uInt16 nStrResId; + // common flags of Calc and Writer + bool bIncludeFont : 1; + bool bIncludeJustify : 1; + bool bIncludeFrame : 1; + bool bIncludeBackground : 1; + + // Calc specific flags + bool bIncludeValueFormat : 1; + bool bIncludeWidthHeight : 1; + + // Writer-specific data + AutoFormatSwBlob m_swFields; + + std::array<std::unique_ptr<ScAutoFormatDataField>,16> ppDataField; + + SAL_DLLPRIVATE ScAutoFormatDataField& GetField( sal_uInt16 nIndex ); + SAL_DLLPRIVATE const ScAutoFormatDataField& GetField( sal_uInt16 nIndex ) const; + +public: + ScAutoFormatData(); + ScAutoFormatData( const ScAutoFormatData& rData ); + ~ScAutoFormatData(); + + void SetName( const OUString& rName ) { aName = rName; nStrResId = USHRT_MAX; } + const OUString& GetName() const { return aName; } + + bool GetIncludeValueFormat() const { return bIncludeValueFormat; } + bool GetIncludeFont() const { return bIncludeFont; } + bool GetIncludeJustify() const { return bIncludeJustify; } + bool GetIncludeFrame() const { return bIncludeFrame; } + bool GetIncludeBackground() const { return bIncludeBackground; } + bool GetIncludeWidthHeight() const { return bIncludeWidthHeight; } + + void SetIncludeValueFormat( bool bValueFormat ) { bIncludeValueFormat = bValueFormat; } + void SetIncludeFont( bool bFont ) { bIncludeFont = bFont; } + void SetIncludeJustify( bool bJustify ) { bIncludeJustify = bJustify; } + void SetIncludeFrame( bool bFrame ) { bIncludeFrame = bFrame; } + void SetIncludeBackground( bool bBackground ) { bIncludeBackground = bBackground; } + void SetIncludeWidthHeight( bool bWidthHeight ) { bIncludeWidthHeight = bWidthHeight; } + + const SfxPoolItem* GetItem( sal_uInt16 nIndex, sal_uInt16 nWhich ) const; + template<class T> const T* GetItem( sal_uInt16 nIndex, TypedWhichId<T> nWhich ) const + { + return static_cast<const T*>(GetItem(nIndex, sal_uInt16(nWhich))); + } + void PutItem( sal_uInt16 nIndex, const SfxPoolItem& rItem ); + void CopyItem( sal_uInt16 nToIndex, sal_uInt16 nFromIndex, sal_uInt16 nWhich ); + + const ScNumFormatAbbrev& GetNumFormat( sal_uInt16 nIndex ) const; + + bool HasSameData( sal_uInt16 nIndex1, sal_uInt16 nIndex2 ) const; + + void FillToItemSet( sal_uInt16 nIndex, SfxItemSet& rItemSet, const ScDocument& rDoc ) const; + void GetFromItemSet( sal_uInt16 nIndex, const SfxItemSet& rItemSet, const ScNumFormatAbbrev& rNumFormat ); + + bool Load( SvStream& rStream, const ScAfVersions& rVersions ); + bool Save( SvStream& rStream, sal_uInt16 fileVersion ); +}; + +struct DefaultFirstEntry { + bool operator() (const OUString& left, const OUString& right) const; +}; + +class SC_DLLPUBLIC ScAutoFormat +{ + typedef std::map<OUString, std::unique_ptr<ScAutoFormatData>, DefaultFirstEntry> MapType; + MapType m_Data; + bool mbSaveLater; + ScAfVersions m_aVersions; + + ScAutoFormat(const ScAutoFormat&) = delete; + const ScAutoFormat operator=(const ScAutoFormat&) = delete; + +public: + typedef MapType::const_iterator const_iterator; + typedef MapType::iterator iterator; + + ScAutoFormat(); + void Load(); + bool Save(); + + void SetSaveLater( bool bSet ); + bool IsSaveLater() const { return mbSaveLater; } + + const ScAutoFormatData* findByIndex(size_t nIndex) const; + ScAutoFormatData* findByIndex(size_t nIndex); + iterator find(const OUString& rName); + + iterator insert(std::unique_ptr<ScAutoFormatData> pNew); + void erase(const iterator& it); + + size_t size() const; + const_iterator begin() const; + const_iterator end() const; + iterator begin(); + iterator end(); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/autonamecache.hxx b/sc/inc/autonamecache.hxx new file mode 100644 index 0000000000..c014fa38fb --- /dev/null +++ b/sc/inc/autonamecache.hxx @@ -0,0 +1,44 @@ +/* -*- 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 <unordered_map> +#include <vector> +#include "address.hxx" + +typedef std::vector< ScAddress > ScAutoNameAddresses; +typedef std::unordered_map< OUString, ScAutoNameAddresses > ScAutoNameHashMap; + +/** Cache for faster lookup of automatic names during CompileXML + (during CompileXML, no document content is changed). */ +class SC_DLLPUBLIC ScAutoNameCache +{ + ScAutoNameHashMap aNames; + ScDocument& rDoc; + SCTAB nCurrentTab; + +public: + ScAutoNameCache( ScDocument& pD ); + ~ScAutoNameCache(); + + const ScAutoNameAddresses& GetNameOccurrences( const OUString& rName, SCTAB nTab ); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/bigrange.hxx b/sc/inc/bigrange.hxx new file mode 100644 index 0000000000..139c32c661 --- /dev/null +++ b/sc/inc/bigrange.hxx @@ -0,0 +1,178 @@ +/* -*- 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 "address.hxx" +#include "document.hxx" + +// This is used by change tracking. References there may be located also outside of the document +// (see ScRefUpdate::Update()), and so it needs bigger range than ScAddress/ScRange. + +class ScBigAddress +{ + sal_Int64 nRow; + sal_Int64 nCol; + sal_Int64 nTab; + +public: + ScBigAddress() : nRow(0), nCol(0), nTab(0) {} + ScBigAddress( sal_Int64 nColP, sal_Int64 nRowP, sal_Int64 nTabP ) + : nRow( nRowP ), nCol( nColP ), nTab( nTabP ) {} + ScBigAddress( const ScBigAddress& r ) + : nRow( r.nRow ), nCol( r.nCol ), nTab( r.nTab ) {} + ScBigAddress( ScBigAddress&& ) = default; + ScBigAddress( const ScAddress& r ) + : nRow( r.Row() ), nCol( r.Col() ), nTab( r.Tab() ) {} + + sal_Int64 Col() const { return nCol; } + sal_Int64 Row() const { return nRow; } + sal_Int64 Tab() const { return nTab; } + + void Set( sal_Int64 nColP, sal_Int64 nRowP, sal_Int64 nTabP ) + { nCol = nColP; nRow = nRowP; nTab = nTabP; } + void SetCol( sal_Int64 nColP ) { nCol = nColP; } + void SetRow( sal_Int64 nRowP ) { nRow = nRowP; } + void SetTab( sal_Int64 nTabP ) { nTab = nTabP; } + void IncCol( sal_Int64 n = 1 ) { nCol += n; } + void IncRow( sal_Int64 n = 1 ) { nRow += n; } + void IncTab( sal_Int64 n = 1 ) { nTab += n; } + + void GetVars( sal_Int64& nColP, sal_Int64& nRowP, sal_Int64& nTabP ) const + { nColP = nCol; nRowP = nRow; nTabP = nTab; } + + bool IsValid( const ScDocument& rDoc ) const; + inline ScAddress MakeAddress( const ScDocument& rDoc ) const; + + ScBigAddress& operator=( const ScBigAddress& r ) + { nCol = r.nCol; nRow = r.nRow; nTab = r.nTab; return *this; } + ScBigAddress& operator=( ScBigAddress&& ) = default; + ScBigAddress& operator=( const ScAddress& r ) + { nCol = r.Col(); nRow = r.Row(); nTab = r.Tab(); return *this; } + bool operator==( const ScBigAddress& r ) const + { return nCol == r.nCol && nRow == r.nRow && nTab == r.nTab; } + bool operator!=( const ScBigAddress& r ) const + { return !operator==( r ); } +}; + +inline ScAddress ScBigAddress::MakeAddress( const ScDocument& rDoc ) const +{ + SCCOL nColA; + SCROW nRowA; + SCTAB nTabA; + + if ( nCol < 0 ) + nColA = 0; + else if ( nCol > rDoc.MaxCol() ) + nColA = rDoc.MaxCol(); + else + nColA = static_cast<SCCOL>(nCol); + + if ( nRow < 0 ) + nRowA = 0; + else if ( nRow > rDoc.MaxRow() ) + nRowA = rDoc.MaxRow(); + else + nRowA = static_cast<SCROW>(nRow); + + if ( nTab < 0 ) + nTabA = 0; + else if ( nTab > MAXTAB ) + nTabA = MAXTAB; + else + nTabA = static_cast<SCTAB>(nTab); + + return ScAddress( nColA, nRowA, nTabA ); +} + +class ScBigRange +{ +public: + + ScBigAddress aStart; + ScBigAddress aEnd; + + ScBigRange() : aStart(), aEnd() {} + ScBigRange( const ScBigRange& r ) + : aStart( r.aStart ), aEnd( r.aEnd ) {} + ScBigRange( ScBigRange&& ) = default; + ScBigRange( const ScRange& r ) + : aStart( r.aStart ), aEnd( r.aEnd ) {} + ScBigRange( sal_Int64 nCol1, sal_Int64 nRow1, sal_Int64 nTab1, + sal_Int64 nCol2, sal_Int64 nRow2, sal_Int64 nTab2 ) + : aStart( nCol1, nRow1, nTab1 ), + aEnd( nCol2, nRow2, nTab2 ) {} + + void Set( sal_Int64 nCol1, sal_Int64 nRow1, sal_Int64 nTab1, + sal_Int64 nCol2, sal_Int64 nRow2, sal_Int64 nTab2 ) + { aStart.Set( nCol1, nRow1, nTab1 ); + aEnd.Set( nCol2, nRow2, nTab2 ); } + + void GetVars( sal_Int64& nCol1, sal_Int64& nRow1, sal_Int64& nTab1, + sal_Int64& nCol2, sal_Int64& nRow2, sal_Int64& nTab2 ) const + { aStart.GetVars( nCol1, nRow1, nTab1 ); + aEnd.GetVars( nCol2, nRow2, nTab2 ); } + + bool IsValid( const ScDocument& rDoc ) const + { return aStart.IsValid( rDoc ) && aEnd.IsValid( rDoc ); } + ScRange MakeRange( const ScDocument& rDoc ) const + { return ScRange( aStart.MakeAddress( rDoc ), aEnd.MakeAddress( rDoc ) ); } + + inline bool Contains( const ScBigAddress& ) const; ///< is Address& in range? + inline bool Contains( const ScBigRange& ) const; ///< is Range& in range? + inline bool Intersects( const ScBigRange& ) const; ///< do two ranges overlap? + + ScBigRange& operator=( const ScBigRange& r ) + { aStart = r.aStart; aEnd = r.aEnd; return *this; } + ScBigRange& operator=( ScBigRange&& ) = default; + bool operator==( const ScBigRange& r ) const + { return (aStart == r.aStart) && (aEnd == r.aEnd); } + bool operator!=( const ScBigRange& r ) const + { return !operator==( r ); } + + // These are used to define whole rows/cols/tabs. + constexpr static sal_Int64 nRangeMin = ::std::numeric_limits<sal_Int64>::min();; + constexpr static sal_Int64 nRangeMax = ::std::numeric_limits<sal_Int64>::max();; +}; + +inline bool ScBigRange::Contains( const ScBigAddress& rAddr ) const +{ + return + aStart.Col() <= rAddr.Col() && rAddr.Col() <= aEnd.Col() && + aStart.Row() <= rAddr.Row() && rAddr.Row() <= aEnd.Row() && + aStart.Tab() <= rAddr.Tab() && rAddr.Tab() <= aEnd.Tab(); +} + +inline bool ScBigRange::Contains( const ScBigRange& r ) const +{ + return + aStart.Col() <= r.aStart.Col() && r.aEnd.Col() <= aEnd.Col() && + aStart.Row() <= r.aStart.Row() && r.aEnd.Row() <= aEnd.Row() && + aStart.Tab() <= r.aStart.Tab() && r.aEnd.Tab() <= aEnd.Tab(); +} + +inline bool ScBigRange::Intersects( const ScBigRange& r ) const +{ + return + aStart.Col() <= r.aEnd.Col() && r.aStart.Col() <= aEnd.Col() && + aStart.Row() <= r.aEnd.Row() && r.aStart.Row() <= aEnd.Row() && + aStart.Tab() <= r.aEnd.Tab() && r.aStart.Tab() <= aEnd.Tab(); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/bitmaps.hlst b/sc/inc/bitmaps.hlst new file mode 100644 index 0000000000..540e44bd0b --- /dev/null +++ b/sc/inc/bitmaps.hlst @@ -0,0 +1,127 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * 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/. + */ + +#pragma once + +#include <rtl/ustring.hxx> + +inline constexpr OUString RID_BMP_LEVEL1 = u"sc/res/ou01.png"_ustr; +inline constexpr OUString RID_BMP_LEVEL2 = u"sc/res/ou02.png"_ustr; +inline constexpr OUString RID_BMP_LEVEL3 = u"sc/res/ou03.png"_ustr; +inline constexpr OUString RID_BMP_LEVEL4 = u"sc/res/ou04.png"_ustr; +inline constexpr OUString RID_BMP_LEVEL5 = u"sc/res/ou05.png"_ustr; +inline constexpr OUString RID_BMP_LEVEL6 = u"sc/res/ou06.png"_ustr; +inline constexpr OUString RID_BMP_LEVEL7 = u"sc/res/ou07.png"_ustr; +inline constexpr OUString RID_BMP_LEVEL8 = u"sc/res/ou08.png"_ustr; +inline constexpr OUString RID_BMP_PLUS = u"sc/res/ou09.png"_ustr; +inline constexpr OUString RID_BMP_MINUS = u"sc/res/ou010.png"_ustr; +inline constexpr OUString RID_BMP_NOTPRESSED = u"sc/res/ou011.png"_ustr; +inline constexpr OUString RID_BMP_PRESSED = u"sc/res/ou012.png"_ustr; + +inline constexpr OUString RID_BMP_CONTENT_TABLE = u"sc/res/nc01.png"_ustr; +inline constexpr OUString RID_BMP_CONTENT_RANGENAME = u"sc/res/nc02.png"_ustr; +inline constexpr OUString RID_BMP_CONTENT_DBAREA = u"sc/res/nc03.png"_ustr; +inline constexpr OUString RID_BMP_CONTENT_GRAPHIC = u"sc/res/nc04.png"_ustr; +inline constexpr OUString RID_BMP_CONTENT_OLEOBJECT = u"sc/res/nc05.png"_ustr; +inline constexpr OUString RID_BMP_CONTENT_NOTE = u"sc/res/nc06.png"_ustr; +inline constexpr OUString RID_BMP_CONTENT_AREALINK = u"sc/res/nc07.png"_ustr; +inline constexpr OUString RID_BMP_CONTENT_DRAWING = u"sc/res/nc08.png"_ustr; +inline constexpr OUString RID_BMP_DROP_URL = u"sc/res/dropurl.png"_ustr; +inline constexpr OUString RID_BMP_DROP_LINK = u"sc/res/droplink.png"_ustr; +inline constexpr OUString RID_BMP_DROP_COPY = u"sc/res/dropcopy.png"_ustr; +inline constexpr OUString RID_BMP_ELEMENT_DEFAULT = u"sc/res/xml_element.png"_ustr; +inline constexpr OUString RID_BMP_ELEMENT_REPEAT = u"sc/res/xml_element_repeat.png"_ustr; +inline constexpr OUString RID_BMP_ELEMENT_ATTRIBUTE = u"sc/res/xml_attribute.png"_ustr; + +inline constexpr OUString BMP_LEFTRIGHT = u"sc/res/lftrgt.png"_ustr; +inline constexpr OUString BMP_TOPDOWN = u"sc/res/topdown.png"_ustr; + +inline constexpr OUString RID_BMP_CELL_BORDER = u"sc/res/sidebar/CellBorder.png"_ustr; +inline constexpr OUString RID_BMP_LINE_STYLE1 = u"sc/res/sidebar/CellBorderLineStyle_005.png"_ustr; +inline constexpr OUString RID_BMP_LINE_STYLE2 = u"sc/res/sidebar/CellBorderLineStyle_250.png"_ustr; +inline constexpr OUString RID_BMP_LINE_STYLE3 = u"sc/res/sidebar/CellBorderLineStyle_400.png"_ustr; +inline constexpr OUString RID_BMP_LINE_STYLE4 = u"sc/res/sidebar/CellBorderLineStyle_500.png"_ustr; +inline constexpr OUString RID_BMP_LINE_STYLE5 = u"sc/res/sidebar/CellBorderLineStyle_110.png"_ustr; +inline constexpr OUString RID_BMP_LINE_STYLE6 = u"sc/res/sidebar/CellBorderLineStyle_260.png"_ustr; +inline constexpr OUString RID_BMP_LINE_STYLE7 = u"sc/res/sidebar/CellBorderLineStyle_450.png"_ustr; +inline constexpr OUString RID_BMP_LINE_STYLE8 = u"sc/res/sidebar/CellBorderLineStyle_505.png"_ustr; +inline constexpr OUString RID_BMP_LINE_STYLE9 = u"sc/res/sidebar/CellBorderLineStyle_750.png"_ustr; + +inline constexpr OUString RID_BMP_INPUT_FUNCTION = u"sc/res/sc26047.png"_ustr; +inline constexpr OUString RID_BMP_INPUT_SUM = u"sc/res/sc26048.png"_ustr; +inline constexpr OUString RID_BMP_INPUT_EQUAL = u"sc/res/sc26049.png"_ustr; +inline constexpr OUString RID_BMP_INPUT_CANCEL = u"sc/res/sc26050.png"_ustr; +inline constexpr OUString RID_BMP_INPUT_OK = u"sc/res/sc26051.png"_ustr; + +inline constexpr OUString BMP_STYLES_FAMILY_CELL = u"sc/res/sf01.png"_ustr; +inline constexpr OUString BMP_STYLES_FAMILY_PAGE = u"sc/res/sf02.png"_ustr; +inline constexpr OUString BMP_STYLES_FAMILY_GRAPHICS = u"sd/res/sf01.png"_ustr; + +inline constexpr OUString BMP_ICON_SET_CIRCLES1_GRAY = u"sc/res/icon-set-circles1-gray.png"_ustr; +inline constexpr OUString BMP_ICON_SET_CIRCLES1_GREEN = u"sc/res/icon-set-circles1-green.png"_ustr; +inline constexpr OUString BMP_ICON_SET_CIRCLES1_YELLOW = u"sc/res/icon-set-circles1-yellow.png"_ustr; +inline constexpr OUString BMP_ICON_SET_CIRCLES1_RED = u"sc/res/icon-set-circles1-red.png"_ustr; +inline constexpr OUString BMP_ICON_SET_BARS_EMPTY = u"sc/res/icon-set-bars-empty.png"_ustr; +inline constexpr OUString BMP_ICON_SET_BARS_ONE_QUARTER = u"sc/res/icon-set-bars-one-quarter.png"_ustr; +inline constexpr OUString BMP_ICON_SET_BARS_HALF = u"sc/res/icon-set-bars-half.png"_ustr; +inline constexpr OUString BMP_ICON_SET_BARS_THREE_QUARTER = u"sc/res/icon-set-bars-three-quarters.png"_ustr; +inline constexpr OUString BMP_ICON_SET_BARS_FULL = u"sc/res/icon-set-bars-full.png"_ustr; +inline constexpr OUString BMP_ICON_SET_CIRCLES2_DARK_GRAY = u"sc/res/icon-set-circles2-dark-gray.png"_ustr; +inline constexpr OUString BMP_ICON_SET_CIRCLES2_LIGHT_GRAY = u"sc/res/icon-set-circles2-light-gray.png"_ustr; +inline constexpr OUString BMP_ICON_SET_CIRCLES2_LIGHT_RED = u"sc/res/icon-set-circles2-light-red.png"_ustr; +inline constexpr OUString BMP_ICON_SET_CIRCLES2_DARK_RED = u"sc/res/icon-set-circles2-dark-red.png"_ustr; +inline constexpr OUString BMP_ICON_SET_COLORARROWS_DOWN = u"sc/res/icon-set-colorarrows-down.png"_ustr; +inline constexpr OUString BMP_ICON_SET_COLORARROWS_SLIGHTLY_DOWN = u"sc/res/icon-set-colorarrows-slightly-down.png"_ustr; +inline constexpr OUString BMP_ICON_SET_COLORARROWS_SAME = u"sc/res/icon-set-colorarrows-same.png"_ustr; +inline constexpr OUString BMP_ICON_SET_COLORARROWS_SLIGHTLY_UP = u"sc/res/icon-set-colorarrows-slightly-up.png"_ustr; +inline constexpr OUString BMP_ICON_SET_COLORARROWS_UP = u"sc/res/icon-set-colorarrows-up.png"_ustr; +inline constexpr OUString BMP_ICON_SET_FLAGS_RED = u"sc/res/icon-set-flags-red.png"_ustr; +inline constexpr OUString BMP_ICON_SET_FLAGS_YELLOW = u"sc/res/icon-set-flags-yellow.png"_ustr; +inline constexpr OUString BMP_ICON_SET_FLAGS_GREEN = u"sc/res/icon-set-flags-green.png"_ustr; +inline constexpr OUString BMP_ICON_SET_GRAYARROWS_DOWN = u"sc/res/icon-set-grayarrows-down.png"_ustr; +inline constexpr OUString BMP_ICON_SET_GRAYARROWS_SLIGHTLY_DOWN = u"sc/res/icon-set-grayarrows-slightly-down.png"_ustr; +inline constexpr OUString BMP_ICON_SET_GRAYARROWS_SAME = u"sc/res/icon-set-grayarrows-same.png"_ustr; +inline constexpr OUString BMP_ICON_SET_GRAYARROWS_SLIGHTLY_UP = u"sc/res/icon-set-grayarrows-slightly-up.png"_ustr; +inline constexpr OUString BMP_ICON_SET_GRAYARROWS_UP = u"sc/res/icon-set-grayarrows-up.png"_ustr; +inline constexpr OUString BMP_ICON_SET_PIES_EMPTY = u"sc/res/icon-set-pies-empty.png"_ustr; +inline constexpr OUString BMP_ICON_SET_PIES_ONE_QUARTER = u"sc/res/icon-set-pies-one-quarter.png"_ustr; +inline constexpr OUString BMP_ICON_SET_PIES_HALF = u"sc/res/icon-set-pies-half.png"_ustr; +inline constexpr OUString BMP_ICON_SET_PIES_THREE_QUARTER = u"sc/res/icon-set-pies-three-quarters.png"_ustr; +inline constexpr OUString BMP_ICON_SET_PIES_FULL = u"sc/res/icon-set-pies-full.png"_ustr; +inline constexpr OUString BMP_ICON_SET_SHAPES_CIRCLE = u"sc/res/icon-set-shapes-circle.png"_ustr; +inline constexpr OUString BMP_ICON_SET_SHAPES_TRIANGLE = u"sc/res/icon-set-shapes-triangle.png"_ustr; +inline constexpr OUString BMP_ICON_SET_SHAPES_DIAMOND = u"sc/res/icon-set-shapes-diamond.png"_ustr; +inline constexpr OUString BMP_ICON_SET_SQUARES_EMPTY = u"sc/res/icon-set-squares-empty.png"_ustr; +inline constexpr OUString BMP_ICON_SET_SQUARES_ONE_QUARTER = u"sc/res/icon-set-squares-one-quarter.png"_ustr; +inline constexpr OUString BMP_ICON_SET_SQUARES_HALF = u"sc/res/icon-set-squares-half.png"_ustr; +inline constexpr OUString BMP_ICON_SET_SQUARES_THREE_QUARTER = u"sc/res/icon-set-squares-three-quarters.png"_ustr; +inline constexpr OUString BMP_ICON_SET_SQUARES_FULL = u"sc/res/icon-set-squares-full.png"_ustr; +inline constexpr OUString BMP_ICON_SET_STARS_EMPTY = u"sc/res/icon-set-stars-empty.png"_ustr; +inline constexpr OUString BMP_ICON_SET_STARS_HALF = u"sc/res/icon-set-stars-half.png"_ustr; +inline constexpr OUString BMP_ICON_SET_STARS_FULL = u"sc/res/icon-set-stars-full.png"_ustr; +inline constexpr OUString BMP_ICON_SET_SYMBOLS1_CHECK = u"sc/res/icon-set-symbols1-check.png"_ustr; +inline constexpr OUString BMP_ICON_SET_SYMBOLS1_EXCLAMATION_MARK = u"sc/res/icon-set-symbols1-exclamation-mark.png"_ustr; +inline constexpr OUString BMP_ICON_SET_SYMBOLS1_CROSS = u"sc/res/icon-set-symbols1-cross.png"_ustr; +inline constexpr OUString BMP_ICON_SET_TRAFFICLIGHTS_RED = u"sc/res/icon-set-trafficlights-red.png"_ustr; +inline constexpr OUString BMP_ICON_SET_TRAFFICLIGHTS_YELLOW = u"sc/res/icon-set-trafficlights-yellow.png"_ustr; +inline constexpr OUString BMP_ICON_SET_TRAFFICLIGHTS_GREEN = u"sc/res/icon-set-trafficlights-green.png"_ustr; +inline constexpr OUString BMP_ICON_SET_TRIANGLES_DOWN = u"sc/res/icon-set-triangles-down.png"_ustr; +inline constexpr OUString BMP_ICON_SET_TRIANGLES_SAME = u"sc/res/icon-set-triangles-same.png"_ustr; +inline constexpr OUString BMP_ICON_SET_TRIANGLES_UP = u"sc/res/icon-set-triangles-up.png"_ustr; +inline constexpr OUString BMP_ICON_SET_POSITIVE_GREEN_SMILIE = u"sc/res/icon-set-positive-green-smilie.png"_ustr; +inline constexpr OUString BMP_ICON_SET_NEUTRAL_YELLOW_SMILIE = u"sc/res/icon-set-neutral-yellow-smilie.png"_ustr; +inline constexpr OUString BMP_ICON_SET_NEGATIVE_RED_SMILIE = u"sc/res/icon-set-negative-red-smilie.png"_ustr; +inline constexpr OUString BMP_ICON_SET_POSITIVE_YELLOW_SMILIE = u"sc/res/icon-set-positive-yellow-smilie.png"_ustr; +inline constexpr OUString BMP_ICON_SET_NEGATIVE_YELLOW_SMILIE = u"sc/res/icon-set-negative-yellow-smilie.png"_ustr; + +inline constexpr OUString RID_SVXBMP_SLIDERBUTTON = u"svx/res/slidezoombutton_10.png"_ustr; +inline constexpr OUString RID_SVXBMP_SLIDERDECREASE = u"svx/res/slidezoomout_10.png"_ustr; +inline constexpr OUString RID_SVXBMP_SLIDERINCREASE = u"svx/res/slidezoomin_10.png"_ustr; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/sc/inc/brdcst.hxx b/sc/inc/brdcst.hxx new file mode 100644 index 0000000000..8b87285734 --- /dev/null +++ b/sc/inc/brdcst.hxx @@ -0,0 +1,50 @@ +/* -*- 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 "address.hxx" +#include <svl/hint.hxx> + +class ScHint final : public SfxHint +{ + ScAddress aAddress; + SCROW nRowCount; + +public: + ScHint( SfxHintId n, const ScAddress& a, SCROW rowCount = 1 ) : SfxHint(n), aAddress(a), nRowCount( rowCount ) {} + const ScAddress& GetStartAddress() const { return aAddress; } + SCROW GetRowCount() const { return nRowCount; } + ScRange GetRange() const + { return ScRange(aAddress, ScAddress(aAddress.Col(), aAddress.Row() + nRowCount - 1, aAddress.Tab())); } + void SetAddressTab(SCTAB nTab) { aAddress.SetTab(nTab); } + void SetAddressCol(SCCOL nCol) { aAddress.SetCol(nCol); } + void SetAddressRow(SCROW nRow) { aAddress.SetRow(nRow); } +}; + +class ScAreaChangedHint final : public SfxHint +{ +private: + ScRange aNewRange; +public: + ScAreaChangedHint(const ScRange& rRange) + : SfxHint(SfxHintId::ScAreaChanged), aNewRange(rRange) {} + const ScRange& GetRange() const { return aNewRange; } +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/broadcast.hxx b/sc/inc/broadcast.hxx new file mode 100644 index 0000000000..55b1e64f0c --- /dev/null +++ b/sc/inc/broadcast.hxx @@ -0,0 +1,71 @@ +/* -*- 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/. + */ + +#pragma once + +#include "address.hxx" + +#include <map> +#include <variant> +#include <ostream> + +class ScFormulaCell; +class SvtListener; + +namespace sc +{ +class FormulaGroupAreaListener; + +struct BroadcasterState +{ + struct CellListener + { + using DataType = std::variant<const ScFormulaCell*, const SvtListener*>; + + DataType pData; + + CellListener(const ScFormulaCell* p); + CellListener(const SvtListener* p); + }; + + struct AreaListener + { + using DataType = std::variant<const ScFormulaCell*, const sc::FormulaGroupAreaListener*, + const SvtListener*>; + + DataType pData; + + AreaListener(const ScFormulaCell* p); + AreaListener(const sc::FormulaGroupAreaListener* p); + AreaListener(const SvtListener* p); + }; + + std::map<ScAddress, std::vector<CellListener>> aCellListenerStore; + std::map<ScRange, std::vector<AreaListener>> aAreaListenerStore; + + /** + * Check if a formula cell listens on a single cell. + */ + bool hasFormulaCellListener(const ScAddress& rBroadcasterPos, + const ScAddress& rFormulaPos) const; + + /** + * Check if a formula cell listens on a single range. + */ + bool hasFormulaCellListener(const ScRange& rBroadcasterRange, + const ScAddress& rFormulaPos) const; + + /** + * Dump all broadcaster state in YAML format. + */ + void dump(std::ostream& rStrm, const ScDocument* pDoc = nullptr) const; +}; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/bulkdatahint.hxx b/sc/inc/bulkdatahint.hxx new file mode 100644 index 0000000000..e77ef317ef --- /dev/null +++ b/sc/inc/bulkdatahint.hxx @@ -0,0 +1,40 @@ +/* -*- 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/. + */ + +#pragma once + +#include <svl/hint.hxx> + +class ScDocument; + +namespace sc +{ +class ColumnSpanSet; + +class BulkDataHint final : public SfxHint +{ + ScDocument& mrDoc; + const ColumnSpanSet* mpSpans; + +public: + BulkDataHint(ScDocument& rDoc, SfxHintId nHintId) + : SfxHint(nHintId) + , mrDoc(rDoc) + , mpSpans(nullptr) + { + } + + void setSpans(const ColumnSpanSet* pSpans) { mpSpans = pSpans; } + const ColumnSpanSet* getSpans() const { return mpSpans; } + + ScDocument& getDoc() { return mrDoc; } +}; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/calcconfig.hxx b/sc/inc/calcconfig.hxx new file mode 100644 index 0000000000..57f6d38866 --- /dev/null +++ b/sc/inc/calcconfig.hxx @@ -0,0 +1,86 @@ +/* -*- 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/. + */ + +#pragma once + +#include "scdllapi.h" + +#include <memory> +#include <string_view> + +#include <o3tl/sorted_vector.hxx> +#include <formula/grammar.hxx> +#include <formula/opcode.hxx> +#include <rtl/ustring.hxx> + +// have to match the registry values +enum ScRecalcOptions +{ + RECALC_ALWAYS = 0, + RECALC_NEVER, + RECALC_ASK, +}; + +// Env.var. SC_FORCE_CALCULATION can be used to force all calculation +// to be done using OpenCL or group threading (even for single cells). +enum ForceCalculationType +{ + ForceCalculationNone, // do not force anything + ForceCalculationCore, // "core", use only non-threaded normal code + ForceCalculationOpenCL, // "opencl", force OpenCL + ForceCalculationThreads // "threads", force threaded code +}; + +/** + * Configuration options for formula interpreter. + */ +struct SC_DLLPUBLIC ScCalcConfig +{ + // from most stringent to most relaxed + enum class StringConversion + { + ILLEGAL, ///< =1+"1" or =1+"x" give #VALUE! + ZERO, ///< =1+"1" or =1+"x" give 1 + UNAMBIGUOUS, ///< =1+"1" gives 2, but =1+"1.000" or =1+"x" give #VALUE! + LOCALE ///< =1+"1.000" may be 2 or 1001 ... =1+"x" gives #VALUE! + }; + formula::FormulaGrammar::AddressConvention meStringRefAddressSyntax; + StringConversion meStringConversion; + bool mbEmptyStringAsZero : 1; + bool mbHasStringRefSyntax : 1; + + static bool isOpenCLEnabled(); + static bool isThreadingEnabled(); + static ForceCalculationType getForceCalculationType(); + + bool mbOpenCLSubsetOnly : 1; + bool mbOpenCLAutoSelect : 1; + OUString maOpenCLDevice; + sal_Int32 mnOpenCLMinimumFormulaGroupSize; + + typedef std::shared_ptr<o3tl::sorted_vector<OpCode>> OpCodeSet; + + OpCodeSet mpOpenCLSubsetOpCodes; + + ScCalcConfig(); + + void setOpenCLConfigToDefault(); + + void reset(); + void MergeDocumentSpecific(const ScCalcConfig& r); + void SetStringRefSyntax(formula::FormulaGrammar::AddressConvention eConv); + + bool operator==(const ScCalcConfig& r) const; + bool operator!=(const ScCalcConfig& r) const; +}; + +OUString ScOpCodeSetToSymbolicString(const ScCalcConfig::OpCodeSet& rOpCodes); +ScCalcConfig::OpCodeSet ScStringToOpCodeSet(std::u16string_view rOpCodes); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/calcmacros.hxx b/sc/inc/calcmacros.hxx new file mode 100644 index 0000000000..ebe9665480 --- /dev/null +++ b/sc/inc/calcmacros.hxx @@ -0,0 +1,35 @@ +/* -*- 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/. + */ + +#pragma once + +#define DEBUG_COLUMN_STORAGE 0 +#define DEBUG_PIVOT_TABLE 0 +#define DEBUG_FORMULA_COMPILER 0 + +#define DUMP_COLUMN_STORAGE 0 +#define DUMP_PIVOT_TABLE 0 + +#ifdef DBG_UTIL +#undef DUMP_COLUMN_STORAGE +#define DUMP_COLUMN_STORAGE 1 +#undef DUMP_PIVOT_TABLE +#define DUMP_PIVOT_TABLE 1 +#endif + +#if DUMP_PIVOT_TABLE || DEBUG_PIVOT_TABLE || \ + DUMP_COLUMN_STORAGE || DEBUG_COLUMN_STORAGE || \ + DEBUG_FORMULA_COMPILER +#include <iostream> +using std::cout; +using std::cerr; +using std::endl; +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/callform.hxx b/sc/inc/callform.hxx new file mode 100644 index 0000000000..dd4c4f1529 --- /dev/null +++ b/sc/inc/callform.hxx @@ -0,0 +1,109 @@ +/* -*- 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 <rtl/ustring.hxx> + +#include <memory> +#include <map> + +#define MAXFUNCPARAM 16 +#define MAXARRSIZE 0xfffe + +#ifndef _WIN32 +#define CALLTYPE +#else +#define CALLTYPE __cdecl +#endif + +extern "C" { +typedef void (CALLTYPE* AdvData)( double& nHandle, void* pData ); +} + +enum class ParamType +{ + PTR_DOUBLE, + PTR_STRING, + PTR_DOUBLE_ARR, + PTR_STRING_ARR, + PTR_CELL_ARR, + NONE +}; + +class ModuleData; + +class LegacyFuncData +{ + friend class LegacyFuncCollection; + + const ModuleData* pModuleData; + OUString aInternalName; + OUString aFuncName; + sal_uInt16 nNumber; + sal_uInt16 nParamCount; + ParamType eAsyncType; + ParamType eParamType[MAXFUNCPARAM]; +public: + LegacyFuncData(const ModuleData*pModule, + OUString aIName, + OUString aFName, + sal_uInt16 nNo, + sal_uInt16 nCount, + const ParamType* peType, + ParamType eType); + LegacyFuncData(const LegacyFuncData& rData); + + const OUString& GetModuleName() const; + const OUString& GetInternalName() const { return aInternalName; } + sal_uInt16 GetParamCount() const { return nParamCount; } + ParamType GetParamType(sal_uInt16 nIndex) const { return eParamType[nIndex]; } + ParamType GetAsyncType() const { return eAsyncType; } + void Call(void** ppParam) const; + void Unadvice(double nHandle); + + /** name and description of parameter nParam. + nParam==0 => Desc := function description, + Name := n/a */ + void getParamDesc( OUString& aName, OUString& aDesc, sal_uInt16 nParam ) const; +}; + +class LegacyFuncCollection +{ + typedef std::map<OUString, std::unique_ptr<LegacyFuncData>> MapType; + MapType m_Data; + +public: + typedef MapType::const_iterator const_iterator; + + LegacyFuncCollection(); + LegacyFuncCollection(const LegacyFuncCollection& r); + + const LegacyFuncData* findByName(const OUString& rName) const; + LegacyFuncData* findByName(const OUString& rName); + void insert(LegacyFuncData* pNew); + + const_iterator begin() const; + const_iterator end() const; +}; + +bool InitExternalFunc(const OUString& rModuleName); +void ExitExternalFunc(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/cellform.hxx b/sc/inc/cellform.hxx new file mode 100644 index 0000000000..7fb072ee85 --- /dev/null +++ b/sc/inc/cellform.hxx @@ -0,0 +1,63 @@ +/* -*- 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 "scdllapi.h" +#include <rtl/ustring.hxx> +#include <svl/sharedstring.hxx> + +class SvNumberFormatter; +class Color; +class ScDocument; +class ScAddress; +struct ScRefCellValue; + +class SC_DLLPUBLIC ScCellFormat +{ +public: + + static OUString GetString( + const ScRefCellValue& rCell, sal_uInt32 nFormat, + const Color** ppColor, SvNumberFormatter& rFormatter, const ScDocument& rDoc, bool bNullVals = true, + bool bFormula = false, bool bUseStarFormat = false ); + + static OUString GetString( + ScDocument& rDoc, const ScAddress& rPos, sal_uInt32 nFormat, + const Color** ppColor, SvNumberFormatter& rFormatter, bool bNullVals = true, + bool bFormula = false ); + + // Note that if pShared is set and a value is returned that way, the returned OUString is empty. + static OUString GetInputString( + const ScRefCellValue& rCell, sal_uInt32 nFormat, SvNumberFormatter& rFormatter, + const ScDocument& rDoc, const svl::SharedString** pShared = nullptr, bool bFiltering = false, + bool bForceSystemLocale = false ); + + static OUString GetInputString( + const ScRefCellValue& rCell, sal_uInt32 nFormat, SvNumberFormatter& rFormatter, + const ScDocument& rDoc, bool bFiltering, bool bForceSystemLocale = false ) + { + return GetInputString( rCell, nFormat, rFormatter, rDoc, nullptr, bFiltering, bForceSystemLocale ); + } + + static OUString GetOutputString( + ScDocument& rDoc, const ScAddress& rPos, const ScRefCellValue& rCell ); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/cellsuno.hxx b/sc/inc/cellsuno.hxx new file mode 100644 index 0000000000..e64c1065d5 --- /dev/null +++ b/sc/inc/cellsuno.hxx @@ -0,0 +1,1217 @@ +/* -*- 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 <config_options.h> +#include "address.hxx" +#include "rangelst.hxx" + +#include <formula/grammar.hxx> +#include <rtl/ref.hxx> +#include <sal/types.h> +#include <tools/link.hxx> +#include <svl/itemset.hxx> +#include <svl/lstner.hxx> +#include <svl/listener.hxx> +#include <com/sun/star/table/XTableChartsSupplier.hpp> +#include <com/sun/star/table/XTablePivotChartsSupplier.hpp> +#include <com/sun/star/chart/XChartDataArray.hpp> +#include <com/sun/star/text/XTextFieldsSupplier.hpp> +#include <com/sun/star/drawing/XDrawPageSupplier.hpp> +#include <com/sun/star/sheet/XSheetCellRange.hpp> +#include <com/sun/star/sheet/XFormulaQuery.hpp> +#include <com/sun/star/sheet/XCellRangeAddressable.hpp> +#include <com/sun/star/sheet/XSheetOperation.hpp> +#include <com/sun/star/sheet/XSheetCellRangeContainer.hpp> +#include <com/sun/star/sheet/XCellFormatRangesSupplier.hpp> +#include <com/sun/star/sheet/XUniqueCellFormatRangesSupplier.hpp> +#include <com/sun/star/sheet/XCellRangesQuery.hpp> +#include <com/sun/star/sheet/XSheetFilterableEx.hpp> +#include <com/sun/star/sheet/XSpreadsheet.hpp> +#include <com/sun/star/sheet/XSheetPageBreak.hpp> +#include <com/sun/star/sheet/XCellRangeMovement.hpp> +#include <com/sun/star/text/XText.hpp> +#include <com/sun/star/sheet/XPrintAreas.hpp> +#include <com/sun/star/sheet/XSheetLinkable.hpp> +#include <com/sun/star/sheet/XSubTotalCalculatable.hpp> +#include <com/sun/star/sheet/XArrayFormulaRange.hpp> +#include <com/sun/star/sheet/XCellRangeData.hpp> +#include <com/sun/star/sheet/XCellRangeFormula.hpp> +#include <com/sun/star/sheet/XCellSeries.hpp> +#include <com/sun/star/sheet/XMultipleOperation.hpp> +#include <com/sun/star/sheet/XFormulaTokens.hpp> +#include <com/sun/star/sheet/XArrayFormulaTokens.hpp> +#include <com/sun/star/sheet/XCellAddressable.hpp> +#include <com/sun/star/util/XReplaceable.hpp> +#include <com/sun/star/util/XIndent.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/container/XNameContainer.hpp> +#include <com/sun/star/util/XMergeable.hpp> +#include <com/sun/star/table/XAutoFormattable.hpp> +#include <com/sun/star/util/XSortable.hpp> +#include <com/sun/star/util/XImportable.hpp> +#include <com/sun/star/table/XColumnRowRange.hpp> +#include <com/sun/star/table/XCell2.hpp> +#include <com/sun/star/sheet/XDataPilotTablesSupplier.hpp> +#include <com/sun/star/sheet/XSheetAnnotationAnchor.hpp> +#include <com/sun/star/sheet/XScenariosSupplier.hpp> +#include <com/sun/star/sheet/XSheetAnnotationsSupplier.hpp> +#include <com/sun/star/sheet/XSheetAuditing.hpp> +#include <com/sun/star/sheet/XSheetOutline.hpp> +#include <com/sun/star/util/XProtectable.hpp> +#include <com/sun/star/sheet/XScenario.hpp> +#include <com/sun/star/sheet/XScenarioEnhanced.hpp> +#include <com/sun/star/util/XModifyBroadcaster.hpp> +#include <com/sun/star/beans/XPropertyState.hpp> +#include <com/sun/star/beans/XMultiPropertySet.hpp> +#include <com/sun/star/document/XActionLockable.hpp> +#include <com/sun/star/beans/XTolerantMultiPropertySet.hpp> +#include <com/sun/star/sheet/XExternalSheetName.hpp> +#include <com/sun/star/document/XEventsSupplier.hpp> +#include <comphelper/servicehelper.hxx> +#include <cppuhelper/implbase.hxx> + +#include <memory> +#include <optional> +#include <vector> + +namespace com::sun::star::table { struct BorderLine2; } +namespace com::sun::star::table { struct BorderLine; } +namespace com::sun::star::table { struct TableBorder2; } +namespace com::sun::star::table { struct TableBorder; } + +class ScDocShell; +class ScMarkData; +class ScMemChart; +class ScPrintRangeSaver; +class ScAttrRectIterator; +class ScCellRangeObj; +class ScPatternAttr; +class SvxBoxItem; +class SvxBoxInfoItem; +class SvxItemPropertySet; +class SvxUnoText; +class ScDocument; +class SfxBroadcaster; +class SfxHint; +class SfxItemPropertyMap; +class SfxItemPropertySet; +struct SfxItemPropertyMapEntry; + +namespace editeng { class SvxBorderLine; } + +class ScLinkListener final : public SvtListener +{ + Link<const SfxHint&,void> aLink; +public: + ScLinkListener(const Link<const SfxHint&,void>& rL) : aLink(rL) {} + virtual ~ScLinkListener() override; + virtual void Notify( const SfxHint& rHint ) override; +}; + +typedef std::vector< css::uno::Reference< css::util::XModifyListener > > XModifyListenerArr_Impl; + +// ScCellRangesBase - base class for ScCellRangesObj (with access by index) +// and ScCellRangeObj (without access by index) + +// XServiceInfo is implemented in derived classes + +class ScHelperFunctions +{ +public: + static const ::editeng::SvxBorderLine* GetBorderLine( ::editeng::SvxBorderLine& rLine, const css::table::BorderLine& rStruct ); + static const ::editeng::SvxBorderLine* GetBorderLine( ::editeng::SvxBorderLine& rLine, const css::table::BorderLine2& rStruct ); + static void FillBoxItems( SvxBoxItem& rOuter, SvxBoxInfoItem& rInner, const css::table::TableBorder& rBorder ); + static void FillBoxItems( SvxBoxItem& rOuter, SvxBoxInfoItem& rInner, const css::table::TableBorder2& rBorder ); + static void FillBorderLine( css::table::BorderLine& rStruct, const ::editeng::SvxBorderLine* pLine ); + static void FillBorderLine( css::table::BorderLine2& rStruct, const ::editeng::SvxBorderLine* pLine ); + static void AssignTableBorderToAny( css::uno::Any& rAny, + const SvxBoxItem& rOuter, const SvxBoxInfoItem& rInner, bool bInvalidateHorVerDist = false ); + static void AssignTableBorder2ToAny( css::uno::Any& rAny, + const SvxBoxItem& rOuter, const SvxBoxInfoItem& rInner, bool bInvalidateHorVerDist = false ); + static void ApplyBorder( ScDocShell* pDocShell, const ScRangeList& rRanges, + const SvxBoxItem& rOuter, const SvxBoxInfoItem& rInner ); +}; + +namespace ooo::vba::excel { + class ScVbaCellRangeAccess; // Vba Helper class +} + +class SC_DLLPUBLIC SAL_LOPLUGIN_ANNOTATE("crosscast") ScCellRangesBase : + public cppu::WeakImplHelper< + css::beans::XPropertySet, + css::beans::XMultiPropertySet, + css::beans::XPropertyState, + css::sheet::XSheetOperation, + css::chart::XChartDataArray, + css::util::XIndent, + css::sheet::XCellRangesQuery, + css::sheet::XFormulaQuery, + css::util::XReplaceable, + css::util::XModifyBroadcaster, + css::lang::XServiceInfo, + css::beans::XTolerantMultiPropertySet>, + public SfxListener +{ + friend class ScTabViewObj; // for select() + friend class ScTableSheetObj; // for createCursorByRange() + friend class ooo::vba::excel::ScVbaCellRangeAccess; + +private: + const SfxItemPropertySet* pPropSet; + ScDocShell* pDocShell; + std::unique_ptr<ScLinkListener> pValueListener; + std::unique_ptr<ScPatternAttr> pCurrentFlat; + std::unique_ptr<ScPatternAttr> pCurrentDeep; + std::optional<SfxItemSet> moCurrentDataSet; + std::optional<SfxItemSet> moNoDfltCurrentDataSet; + std::unique_ptr<ScMarkData> pMarkData; + ScRangeList aRanges; + sal_Int64 nObjectId; + bool bChartColAsHdr; + bool bChartRowAsHdr; + bool bCursorOnly; + bool bGotDataChangedHint; + XModifyListenerArr_Impl aValueListeners; + + DECL_DLLPRIVATE_LINK( ValueListenerHdl, const SfxHint&, void ); + +private: + void PaintGridRanges_Impl(); + ScRangeListRef GetLimitedChartRanges_Impl( sal_Int32 nDataColumns, sal_Int32 nDataRows ) const; + void ForceChartListener_Impl(); + std::unique_ptr<ScMemChart> CreateMemChart_Impl() const; + + const ScPatternAttr* GetCurrentAttrsFlat(); + const ScPatternAttr* GetCurrentAttrsDeep(); + SfxItemSet* GetCurrentDataSet(bool bNoDflt = false); + void ForgetMarkData(); + void ForgetCurrentAttrs(); + + css::uno::Reference<css::sheet::XSheetCellRanges> + QueryDifferences_Impl(const css::table::CellAddress& aCompare, + bool bColumnDiff); + css::uno::Reference<css::uno::XInterface> + Find_Impl(const css::uno::Reference<css::util::XSearchDescriptor>& xDesc, + const ScAddress* pLastPos); + +protected: + const ScMarkData* GetMarkData(); + + // GetItemPropertyMap for derived classes must contain all entries, including base class + virtual const SfxItemPropertyMap& GetItemPropertyMap(); + css::beans::PropertyState GetOnePropertyState( + sal_uInt16 nItemWhich, const SfxItemPropertyMapEntry* pEntry ); + /// @throws css::uno::RuntimeException + virtual void GetOnePropertyValue( const SfxItemPropertyMapEntry* pEntry, + css::uno::Any& ); + /// @throws css::lang::IllegalArgumentException + /// @throws css::uno::RuntimeException + virtual void SetOnePropertyValue( const SfxItemPropertyMapEntry* pEntry, + const css::uno::Any& aValue ); + +public: + ScCellRangesBase(ScDocShell* pDocSh, const ScRange& rR); + ScCellRangesBase(ScDocShell* pDocSh, ScRangeList aR); + virtual ~ScCellRangesBase() override; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + virtual void RefChanged(); + + // from derived classes and by getImplementation + ScDocShell* GetDocShell() const { return pDocShell; } + ScDocument* GetDocument() const; + const ScRangeList& GetRangeList() const { return aRanges; } + void AddRange(const ScRange& rRange, const bool bMergeRanges); + + // arouse object created via service: + void InitInsertRange(ScDocShell* pDocSh, const ScRange& rR); + + void SetNewRange(const ScRange& rNew); // for cursor + void SetNewRanges(const ScRangeList& rNew); + + void SetCursorOnly(bool bSet); + bool IsCursorOnly() const { return bCursorOnly; } + + // XSheetOperation + virtual double SAL_CALL computeFunction( css::sheet::GeneralFunction nFunction ) override; + virtual void SAL_CALL clearContents( sal_Int32 nContentFlags ) override; + + // XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > + SAL_CALL getPropertySetInfo() override; + virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, + const css::uno::Any& aValue ) override; + virtual css::uno::Any SAL_CALL getPropertyValue( + const OUString& PropertyName ) override; + virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override; + virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override; + virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + + // XMultiPropertySet + virtual void SAL_CALL setPropertyValues( const css::uno::Sequence< OUString >& aPropertyNames, + const css::uno::Sequence< css::uno::Any >& aValues ) override; + virtual css::uno::Sequence< css::uno::Any > SAL_CALL + getPropertyValues( const css::uno::Sequence< OUString >& aPropertyNames ) override; + virtual void SAL_CALL addPropertiesChangeListener( const css::uno::Sequence< OUString >& aPropertyNames, + const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override; + virtual void SAL_CALL removePropertiesChangeListener( const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override; + virtual void SAL_CALL firePropertiesChangeEvent( const css::uno::Sequence< OUString >& aPropertyNames, + const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override; + + // XTolerantMultiPropertySet + virtual css::uno::Sequence< css::beans::SetPropertyTolerantFailed > SAL_CALL + setPropertyValuesTolerant( const css::uno::Sequence< OUString >& aPropertyNames, + const css::uno::Sequence< css::uno::Any >& aValues ) override; + virtual css::uno::Sequence< css::beans::GetPropertyTolerantResult > SAL_CALL + getPropertyValuesTolerant( const css::uno::Sequence< OUString >& aPropertyNames ) override; + virtual css::uno::Sequence< css::beans::GetDirectPropertyTolerantResult > SAL_CALL + getDirectPropertyValuesTolerant( const css::uno::Sequence< OUString >& aPropertyNames ) override; + + // XPropertyState + virtual css::beans::PropertyState SAL_CALL getPropertyState( + const OUString& PropertyName ) override; + virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL + getPropertyStates( const css::uno::Sequence< + OUString >& aPropertyName ) override; + virtual void SAL_CALL setPropertyToDefault( const OUString& PropertyName ) override; + virtual css::uno::Any SAL_CALL getPropertyDefault( + const OUString& aPropertyName ) override; + + // XIndent + virtual void SAL_CALL decrementIndent() override; + virtual void SAL_CALL incrementIndent() override; + + // XChartData + virtual void SAL_CALL addChartDataChangeEventListener( + const css::uno::Reference< css::chart::XChartDataChangeEventListener >& aListener ) override; + virtual void SAL_CALL removeChartDataChangeEventListener( const css::uno::Reference< + css::chart::XChartDataChangeEventListener >& aListener ) override; + virtual double SAL_CALL getNotANumber() override; + virtual sal_Bool SAL_CALL isNotANumber( double nNumber ) override; + + // XChartDataArray + virtual css::uno::Sequence< css::uno::Sequence< double > > SAL_CALL + getData() override; + virtual void SAL_CALL setData( const css::uno::Sequence< css::uno::Sequence< double > >& aData ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getRowDescriptions() override; + virtual void SAL_CALL setRowDescriptions( const css::uno::Sequence< OUString >& aRowDescriptions ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getColumnDescriptions() override; + virtual void SAL_CALL setColumnDescriptions( const css::uno::Sequence< OUString >& aColumnDescriptions ) override; + + // XCellRangesQuery + virtual css::uno::Reference< css::sheet::XSheetCellRanges > SAL_CALL + queryVisibleCells() override; + virtual css::uno::Reference< css::sheet::XSheetCellRanges > SAL_CALL + queryEmptyCells() override; + virtual css::uno::Reference< css::sheet::XSheetCellRanges > SAL_CALL + queryContentCells( sal_Int16 nContentFlags ) override; + virtual css::uno::Reference< css::sheet::XSheetCellRanges > SAL_CALL + queryFormulaCells( sal_Int32 nResultFlags ) override; + virtual css::uno::Reference< css::sheet::XSheetCellRanges > SAL_CALL + queryColumnDifferences( + const css::table::CellAddress& aCompare ) override; + virtual css::uno::Reference< css::sheet::XSheetCellRanges > SAL_CALL + queryRowDifferences( + const css::table::CellAddress& aCompare ) override; + virtual css::uno::Reference< css::sheet::XSheetCellRanges > SAL_CALL + queryIntersection( + const css::table::CellRangeAddress& aRange ) override; + + // XFormulaQuery + virtual css::uno::Reference< css::sheet::XSheetCellRanges > SAL_CALL + queryDependents( sal_Bool bRecursive ) override; + virtual css::uno::Reference< css::sheet::XSheetCellRanges > SAL_CALL + queryPrecedents( sal_Bool bRecursive ) override; + + // XSearchable + virtual css::uno::Reference< css::util::XSearchDescriptor > SAL_CALL + createSearchDescriptor() override; + virtual css::uno::Reference< css::container::XIndexAccess > SAL_CALL + findAll( const css::uno::Reference< css::util::XSearchDescriptor >& xDesc ) override; + virtual css::uno::Reference< css::uno::XInterface > SAL_CALL + findFirst( const css::uno::Reference< css::util::XSearchDescriptor >& xDesc ) override; + virtual css::uno::Reference< css::uno::XInterface > SAL_CALL + findNext( const css::uno::Reference< css::uno::XInterface >& xStartAt, + const css::uno::Reference< css::util::XSearchDescriptor >& xDesc ) override; + + // XReplaceable + virtual css::uno::Reference< css::util::XReplaceDescriptor > SAL_CALL + createReplaceDescriptor() override; + virtual sal_Int32 SAL_CALL replaceAll( const css::uno::Reference< css::util::XSearchDescriptor >& xDesc ) override; + + // XModifyBroadcaster + virtual void SAL_CALL addModifyListener( const css::uno::Reference< css::util::XModifyListener >& aListener ) override; + virtual void SAL_CALL removeModifyListener( const css::uno::Reference< css::util::XModifyListener >& aListener ) override; + + // XServiceInfo + 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; +}; + +class UNLESS_MERGELIBS(SC_DLLPUBLIC) ScCellRangesObj final : public ScCellRangesBase, + public css::sheet::XSheetCellRangeContainer, + public css::container::XNameContainer, + public css::container::XEnumerationAccess +{ +public: + struct ScNamedEntry + { + OUString aName; + ScRange aRange; + const OUString& GetName() const { return aName; } + const ScRange& GetRange() const { return aRange; } + }; +private: + std::vector<ScNamedEntry> m_aNamedEntries; + + rtl::Reference<ScCellRangeObj> GetObjectByIndex_Impl(sal_Int32 nIndex) const; + +public: + IF_MERGELIBS(SC_DLLPUBLIC) + ScCellRangesObj(ScDocShell* pDocSh, const ScRangeList& rR); + virtual ~ScCellRangesObj() override; + + virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; + IF_MERGELIBS(SC_DLLPUBLIC) + virtual void SAL_CALL acquire() noexcept override; + virtual void SAL_CALL release() noexcept override; + + virtual void RefChanged() override; + + // XSheetCellRanges + virtual css::uno::Reference< css::container::XEnumerationAccess > SAL_CALL + getCells() override; + virtual OUString SAL_CALL getRangeAddressesAsString() override; + virtual css::uno::Sequence< css::table::CellRangeAddress > SAL_CALL + getRangeAddresses() override; + + // XSheetCellRangeContainer + virtual void SAL_CALL addRangeAddress( const css::table::CellRangeAddress& rRange, + sal_Bool bMergeRanges ) override; + virtual void SAL_CALL removeRangeAddress( const css::table::CellRangeAddress& rRange ) override; + virtual void SAL_CALL addRangeAddresses( const css::uno::Sequence< + css::table::CellRangeAddress >& rRanges, + sal_Bool bMergeRanges ) override; + virtual void SAL_CALL removeRangeAddresses( const css::uno::Sequence< + css::table::CellRangeAddress >& rRanges ) override; + + // XNameContainer + virtual void SAL_CALL insertByName( const OUString& aName, + const css::uno::Any& aElement ) override; + virtual void SAL_CALL removeByName( const OUString& Name ) override; + + // XNameReplace + virtual void SAL_CALL replaceByName( const OUString& aName, + const css::uno::Any& aElement ) override; + + // XNameAccess + virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override; + virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override; + + // XIndexAccess + virtual sal_Int32 SAL_CALL getCount() override; + virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override; + + // XElementAccess + virtual css::uno::Type SAL_CALL getElementType() override; + virtual sal_Bool SAL_CALL hasElements() override; + + // XEnumerationAccess + virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL + createEnumeration() override; + + // XServiceInfo + 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; + + // XTypeProvider + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; + virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; +}; + +class SC_DLLPUBLIC ScCellRangeObj : public ScCellRangesBase, + public css::sheet::XCellRangeAddressable, + public css::sheet::XSheetCellRange, + public css::sheet::XArrayFormulaRange, + public css::sheet::XArrayFormulaTokens, + public css::sheet::XCellRangeData, + public css::sheet::XCellRangeFormula, + public css::sheet::XMultipleOperation, + public css::util::XMergeable, + public css::sheet::XCellSeries, + public css::table::XAutoFormattable, + public css::util::XSortable, + public css::sheet::XSheetFilterableEx, + public css::sheet::XSubTotalCalculatable, + public css::util::XImportable, + public css::sheet::XCellFormatRangesSupplier, + public css::sheet::XUniqueCellFormatRangesSupplier, + public css::table::XColumnRowRange +{ +private: + const SfxItemPropertySet* pRangePropSet; + ScRange aRange; + +protected: + const ScRange& GetRange() const { return aRange; } + virtual const SfxItemPropertyMap& GetItemPropertyMap() override; + virtual void GetOnePropertyValue( const SfxItemPropertyMapEntry* pEntry, + css::uno::Any& ) override; + virtual void SetOnePropertyValue( const SfxItemPropertyMapEntry* pEntry, + const css::uno::Any& aValue ) override; + + /// @throws css::lang::IndexOutOfBoundsException + /// @throws css::uno::RuntimeException + css::uno::Reference< css::table::XCell > + GetCellByPosition_Impl( sal_Int32 nColumn, sal_Int32 nRow ); + + /// @throws css::uno::RuntimeException + void SetArrayFormula_Impl( const OUString& rFormula, + const formula::FormulaGrammar::Grammar eGrammar ); + +public: + ScCellRangeObj(ScDocShell* pDocSh, const ScRange& rR); + virtual ~ScCellRangeObj() override; + + // uses ObjectShell from document, if set (returns NULL otherwise) + static css::uno::Reference<css::table::XCellRange> + CreateRangeFromDoc( const ScDocument& rDoc, const ScRange& rR ); + + virtual css::uno::Any SAL_CALL queryInterface( + const css::uno::Type & rType ) override; + virtual void SAL_CALL acquire() noexcept override; + virtual void SAL_CALL release() noexcept override; + + virtual void RefChanged() override; + + // XCellRangeAddressable + virtual css::table::CellRangeAddress SAL_CALL getRangeAddress() override; + + // XSheetCellRange + virtual css::uno::Reference< css::sheet::XSpreadsheet > SAL_CALL + getSpreadsheet() override; + + // XArrayFormulaRange + virtual OUString SAL_CALL getArrayFormula() override; + virtual void SAL_CALL setArrayFormula( const OUString& aFormula ) override; + + // XArrayFormulaTokens + virtual css::uno::Sequence< css::sheet::FormulaToken > SAL_CALL getArrayTokens() override; + virtual void SAL_CALL setArrayTokens( const css::uno::Sequence< + css::sheet::FormulaToken >& aTokens ) override; + + // XCellRangeData + virtual css::uno::Sequence< css::uno::Sequence< css::uno::Any > > SAL_CALL getDataArray() override; + virtual void SAL_CALL setDataArray( const css::uno::Sequence< css::uno::Sequence< css::uno::Any > >& aArray ) override; + + // XCellRangeFormula + virtual css::uno::Sequence< css::uno::Sequence< + OUString > > SAL_CALL getFormulaArray() override; + virtual void SAL_CALL setFormulaArray( const css::uno::Sequence< css::uno::Sequence< OUString > >& aArray ) override; + + // XMultipleOperation + virtual void SAL_CALL setTableOperation( + const css::table::CellRangeAddress& aFormulaRange, + css::sheet::TableOperationMode nMode, + const css::table::CellAddress& aColumnCell, + const css::table::CellAddress& aRowCell ) override; + + // XMergeable + virtual void SAL_CALL merge( sal_Bool bMerge ) override; + virtual sal_Bool SAL_CALL getIsMerged() override; + + // XCellSeries + virtual void SAL_CALL fillSeries( css::sheet::FillDirection nFillDirection, + css::sheet::FillMode nFillMode, + css::sheet::FillDateMode nFillDateMode, + double fStep, double fEndValue ) override; + virtual void SAL_CALL fillAuto( css::sheet::FillDirection nFillDirection, + sal_Int32 nSourceCount ) override; + + // XAutoFormattable + virtual void SAL_CALL autoFormat( const OUString& aName ) override; + + // XSortable + virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL + createSortDescriptor() override; + virtual void SAL_CALL sort( const css::uno::Sequence< + css::beans::PropertyValue >& xDescriptor ) override; + + // XSheetFilterableEx + virtual css::uno::Reference< css::sheet::XSheetFilterDescriptor > SAL_CALL + createFilterDescriptorByObject( const css::uno::Reference< + css::sheet::XSheetFilterable >& xObject ) override; + + // XSheetFilterable + virtual css::uno::Reference< css::sheet::XSheetFilterDescriptor > SAL_CALL + createFilterDescriptor( sal_Bool bEmpty ) override; + virtual void SAL_CALL filter( const css::uno::Reference< + css::sheet::XSheetFilterDescriptor >& xDescriptor ) override; + + // XSubTotalCalculatable + virtual css::uno::Reference< css::sheet::XSubTotalDescriptor > SAL_CALL + createSubTotalDescriptor( sal_Bool bEmpty ) override; + virtual void SAL_CALL applySubTotals(const css::uno::Reference< css::sheet::XSubTotalDescriptor >& xDescriptor, + sal_Bool bReplace) override; + virtual void SAL_CALL removeSubTotals() override; + + // XImportable + virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL + createImportDescriptor( sal_Bool bEmpty ) override; + virtual void SAL_CALL doImport( const css::uno::Sequence< css::beans::PropertyValue >& aDescriptor ) override; + + // XCellFormatRangesSupplier + virtual css::uno::Reference< css::container::XIndexAccess > SAL_CALL + getCellFormatRanges() override; + + // XUniqueCellFormatRangesSupplier + virtual css::uno::Reference< css::container::XIndexAccess > SAL_CALL + getUniqueCellFormatRanges() override; + + // XColumnRowRange + virtual css::uno::Reference< css::table::XTableColumns > SAL_CALL + getColumns() override; + virtual css::uno::Reference< css::table::XTableRows > SAL_CALL + getRows() override; + + // XCellRange + virtual css::uno::Reference< css::table::XCell > SAL_CALL + getCellByPosition( sal_Int32 nColumn, sal_Int32 nRow ) override; + virtual css::uno::Reference< css::table::XCellRange > SAL_CALL + getCellRangeByPosition( sal_Int32 nLeft, sal_Int32 nTop, + sal_Int32 nRight, sal_Int32 nBottom ) override; + virtual css::uno::Reference< css::table::XCellRange > SAL_CALL + getCellRangeByName( const OUString& aRange ) override; + /// @throws css::uno::RuntimeException + css::uno::Reference< css::table::XCellRange > + getCellRangeByName( const OUString& aRange, const ScAddress::Details& rDetails ); + + // XPropertySet override due to Range-Properties + virtual css::uno::Reference< css::beans::XPropertySetInfo > + SAL_CALL getPropertySetInfo() override; + + // XServiceInfo + 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; + + // XTypeProvider + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; + virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; +}; + +//! really derive cell from range? + +class SC_DLLPUBLIC ScCellObj final : public ScCellRangeObj, + public css::text::XText, + public css::container::XEnumerationAccess, + public css::table::XCell2, + public css::sheet::XFormulaTokens, + public css::sheet::XCellAddressable, + public css::sheet::XSheetAnnotationAnchor, + public css::text::XTextFieldsSupplier, + public css::document::XActionLockable +{ +private: + rtl::Reference<SvxUnoText> mxUnoText; + const SfxItemPropertySet* pCellPropSet; + ScAddress aCellPos; + sal_Int16 nActionLockCount; + +private: + OUString GetInputString_Impl(bool bEnglish) const; + OUString GetOutputString_Impl() const; + void SetString_Impl(const OUString& rString, bool bInterpret, bool bEnglish); + double GetValue_Impl() const; + void SetValue_Impl(double fValue); + css::table::CellContentType GetContentType_Impl(); + sal_Int32 GetResultType_Impl() const; + + virtual const SfxItemPropertyMap& GetItemPropertyMap() override; + virtual void GetOnePropertyValue( const SfxItemPropertyMapEntry* pEntry, + css::uno::Any& ) override; + virtual void SetOnePropertyValue( const SfxItemPropertyMapEntry* pEntry, + const css::uno::Any& aValue ) override; + +public: + static const SvxItemPropertySet* GetEditPropertySet(); + static const SfxItemPropertyMap& GetCellPropertyMap(); + + ScCellObj(ScDocShell* pDocSh, const ScAddress& rP); + virtual ~ScCellObj() override; + + virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; + virtual void SAL_CALL acquire() noexcept override; + virtual void SAL_CALL release() noexcept override; + + virtual void RefChanged() override; + + SvxUnoText& GetUnoText(); + + // XML import needs to set results at formula cells, + // not meant for any other purpose. + const ScAddress& GetPosition() const { return aCellPos; } + + void InputEnglishString( const OUString& rText ); + + // XText + virtual void SAL_CALL insertTextContent( const css::uno::Reference< css::text::XTextRange >& xRange, + const css::uno::Reference< css::text::XTextContent >& xContent, + sal_Bool bAbsorb ) override; + virtual void SAL_CALL removeTextContent( const css::uno::Reference< css::text::XTextContent >& xContent ) override; + + // XSimpleText + virtual css::uno::Reference< css::text::XTextCursor > SAL_CALL + createTextCursor() override; + virtual css::uno::Reference< css::text::XTextCursor > SAL_CALL + createTextCursorByRange( const css::uno::Reference< css::text::XTextRange >& aTextPosition ) override; + virtual void SAL_CALL insertString( const css::uno::Reference< css::text::XTextRange >& xRange, + const OUString& aString, sal_Bool bAbsorb ) override; + virtual void SAL_CALL insertControlCharacter( const css::uno::Reference< css::text::XTextRange >& xRange, + sal_Int16 nControlCharacter, sal_Bool bAbsorb ) override; + + // XTextRange + virtual css::uno::Reference< css::text::XText > SAL_CALL + getText() override; + virtual css::uno::Reference< css::text::XTextRange > SAL_CALL + getStart() override; + virtual css::uno::Reference< css::text::XTextRange > SAL_CALL + getEnd() override; + virtual OUString SAL_CALL getString() override; + virtual void SAL_CALL setString( const OUString& aString ) override; + + // XEnumerationAccess + virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL + createEnumeration() override; + + // XElementAccess + virtual css::uno::Type SAL_CALL getElementType() override; + virtual sal_Bool SAL_CALL hasElements() override; + + // XCell + virtual OUString SAL_CALL getFormula() override; + virtual void SAL_CALL setFormula( const OUString& aFormula ) override; + virtual void SAL_CALL setFormulaResult( double nValue ) override; + virtual void SAL_CALL setFormulaString( const OUString& aFormula ) override; + virtual double SAL_CALL getValue() override; + virtual void SAL_CALL setValue( double nValue ) override; + virtual css::table::CellContentType SAL_CALL getType() override; + virtual sal_Int32 SAL_CALL getError() override; + + // XFormulaTokens + virtual css::uno::Sequence< css::sheet::FormulaToken > SAL_CALL getTokens() override; + virtual void SAL_CALL setTokens( const css::uno::Sequence< css::sheet::FormulaToken >& aTokens ) override; + + // XCellAddressable + virtual css::table::CellAddress SAL_CALL getCellAddress() override; + + // XSheetAnnotationAnchor + virtual css::uno::Reference< css::sheet::XSheetAnnotation > SAL_CALL + getAnnotation() override; + + // XTextFieldsSupplier + virtual css::uno::Reference< css::container::XEnumerationAccess > SAL_CALL + getTextFields() override; + virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL + getTextFieldMasters() override; + + // XPropertySet override due to cell properties + virtual css::uno::Reference< css::beans::XPropertySetInfo > + SAL_CALL getPropertySetInfo() override; + + // XServiceInfo + 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; + + // XTypeProvider + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; + virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + + // XActionLockable + virtual sal_Bool SAL_CALL isActionLocked() override; + virtual void SAL_CALL addActionLock() override; + virtual void SAL_CALL removeActionLock() override; + virtual void SAL_CALL setActionLocks( sal_Int16 nLock ) override; + virtual sal_Int16 SAL_CALL resetActionLocks() override; +}; + +class SC_DLLPUBLIC ScTableSheetObj final : public ScCellRangeObj, + public css::sheet::XSpreadsheet, + public css::container::XNamed, + public css::sheet::XSheetPageBreak, + public css::sheet::XCellRangeMovement, + public css::table::XTableChartsSupplier, + public css::table::XTablePivotChartsSupplier, + public css::sheet::XDataPilotTablesSupplier, + public css::sheet::XScenariosSupplier, + public css::sheet::XSheetAnnotationsSupplier, + public css::drawing::XDrawPageSupplier, + public css::sheet::XPrintAreas, + public css::sheet::XSheetLinkable, + public css::sheet::XSheetAuditing, + public css::sheet::XSheetOutline, + public css::util::XProtectable, + public css::sheet::XScenario, + public css::sheet::XScenarioEnhanced, + public css::sheet::XExternalSheetName, + public css::document::XEventsSupplier +{ + friend class ScTableSheetsObj; // for insertByName() + +private: + const SfxItemPropertySet* pSheetPropSet; + + SCTAB GetTab_Impl() const; + void PrintAreaUndo_Impl( std::unique_ptr<ScPrintRangeSaver> pOldRanges ); + + virtual const SfxItemPropertyMap& GetItemPropertyMap() override; + virtual void GetOnePropertyValue( const SfxItemPropertyMapEntry* pEntry, + css::uno::Any& ) override; + virtual void SetOnePropertyValue( const SfxItemPropertyMapEntry* pEntry, + const css::uno::Any& aValue ) override; + +public: + ScTableSheetObj(ScDocShell* pDocSh, SCTAB nTab); + virtual ~ScTableSheetObj() override; + + void InitInsertSheet(ScDocShell* pDocSh, SCTAB nTab); + + virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; + virtual void SAL_CALL acquire() noexcept override; + virtual void SAL_CALL release() noexcept override; + + // XSpreadsheet + virtual css::uno::Reference< css::sheet::XSheetCellCursor > + SAL_CALL createCursor() override; + virtual css::uno::Reference< css::sheet::XSheetCellCursor > SAL_CALL + createCursorByRange( const css::uno::Reference< + css::sheet::XSheetCellRange >& aRange ) override; + + // XSheetCellRange + virtual css::uno::Reference< css::sheet::XSpreadsheet > SAL_CALL + getSpreadsheet() override; + + // XCellRange + virtual css::uno::Reference< css::table::XCell > SAL_CALL + getCellByPosition( sal_Int32 nColumn, sal_Int32 nRow ) override; + virtual css::uno::Reference< css::table::XCellRange > SAL_CALL + getCellRangeByPosition( sal_Int32 nLeft, sal_Int32 nTop, + sal_Int32 nRight, sal_Int32 nBottom ) override; + using ScCellRangeObj::getCellRangeByName; + virtual css::uno::Reference< css::table::XCellRange > SAL_CALL + getCellRangeByName( const OUString& aRange ) override; + + // XNamed + virtual OUString SAL_CALL getName() override; + virtual void SAL_CALL setName( const OUString& aName ) override; + + // XSheetPageBreak + virtual css::uno::Sequence< css::sheet::TablePageBreakData > SAL_CALL + getColumnPageBreaks() override; + virtual css::uno::Sequence< css::sheet::TablePageBreakData > SAL_CALL + getRowPageBreaks() override; + virtual void SAL_CALL removeAllManualPageBreaks() override; + + // XCellRangeMovement + virtual void SAL_CALL insertCells( const css::table::CellRangeAddress& aRange, + css::sheet::CellInsertMode nMode ) override; + virtual void SAL_CALL removeRange( const css::table::CellRangeAddress& aRange, + css::sheet::CellDeleteMode nMode ) override; + virtual void SAL_CALL moveRange( const css::table::CellAddress& aDestination, + const css::table::CellRangeAddress& aSource ) override; + virtual void SAL_CALL copyRange( const css::table::CellAddress& aDestination, + const css::table::CellRangeAddress& aSource ) override; + + // XTableChartsSupplier + virtual css::uno::Reference< css::table::XTableCharts > SAL_CALL + getCharts() override; + + // XTablePivotChartsSupplier + virtual css::uno::Reference<css::table::XTablePivotCharts> SAL_CALL + getPivotCharts() override; + + // XDataPilotTablesSupplier + virtual css::uno::Reference< css::sheet::XDataPilotTables > SAL_CALL + getDataPilotTables() override; + + // XScenariosSupplier + virtual css::uno::Reference< css::sheet::XScenarios > SAL_CALL + getScenarios() override; + + // XSheetAnnotationsSupplier + virtual css::uno::Reference< css::sheet::XSheetAnnotations > SAL_CALL + getAnnotations() override; + + // XDrawPageSupplier + virtual css::uno::Reference< css::drawing::XDrawPage > SAL_CALL + getDrawPage() override; + + // XPrintAreas + virtual css::uno::Sequence< css::table::CellRangeAddress > SAL_CALL + getPrintAreas() override; + virtual void SAL_CALL setPrintAreas( const css::uno::Sequence< + css::table::CellRangeAddress >& aPrintAreas ) override; + virtual sal_Bool SAL_CALL getPrintTitleColumns() override; + virtual void SAL_CALL setPrintTitleColumns( sal_Bool bPrintTitleColumns ) override; + virtual css::table::CellRangeAddress SAL_CALL getTitleColumns() override; + virtual void SAL_CALL setTitleColumns( + const css::table::CellRangeAddress& aTitleColumns ) override; + virtual sal_Bool SAL_CALL getPrintTitleRows() override; + virtual void SAL_CALL setPrintTitleRows( sal_Bool bPrintTitleRows ) override; + virtual css::table::CellRangeAddress SAL_CALL getTitleRows() override; + virtual void SAL_CALL setTitleRows( + const css::table::CellRangeAddress& aTitleRows ) override; + + // XSheetLinkable + virtual css::sheet::SheetLinkMode SAL_CALL getLinkMode() override; + virtual void SAL_CALL setLinkMode( css::sheet::SheetLinkMode nLinkMode ) override; + virtual OUString SAL_CALL getLinkUrl() override; + virtual void SAL_CALL setLinkUrl( const OUString& aLinkUrl ) override; + virtual OUString SAL_CALL getLinkSheetName() override; + virtual void SAL_CALL setLinkSheetName( const OUString& aLinkSheetName ) override; + virtual void SAL_CALL link( const OUString& aUrl, + const OUString& aSheetName, + const OUString& aFilterName, + const OUString& aFilterOptions, + css::sheet::SheetLinkMode nMode ) override; + + // XSheetAuditing + virtual sal_Bool SAL_CALL hideDependents( const css::table::CellAddress& aPosition ) override; + virtual sal_Bool SAL_CALL hidePrecedents( const css::table::CellAddress& aPosition ) override; + virtual sal_Bool SAL_CALL showDependents( const css::table::CellAddress& aPosition ) override; + virtual sal_Bool SAL_CALL showPrecedents( const css::table::CellAddress& aPosition ) override; + virtual sal_Bool SAL_CALL showErrors( const css::table::CellAddress& aPosition ) override; + virtual sal_Bool SAL_CALL showInvalid() override; + virtual void SAL_CALL clearArrows() override; + + // XSheetOutline + virtual void SAL_CALL group( const css::table::CellRangeAddress& aRange, + css::table::TableOrientation nOrientation ) override; + virtual void SAL_CALL ungroup( const css::table::CellRangeAddress& aRange, + css::table::TableOrientation nOrientation ) override; + virtual void SAL_CALL autoOutline( const css::table::CellRangeAddress& aRange ) override; + virtual void SAL_CALL clearOutline() override; + virtual void SAL_CALL hideDetail( const css::table::CellRangeAddress& aRange ) override; + virtual void SAL_CALL showDetail( const css::table::CellRangeAddress& aRange ) override; + virtual void SAL_CALL showLevel( sal_Int16 nLevel, + css::table::TableOrientation nOrientation ) override; + + // XProtectable + virtual void SAL_CALL protect( const OUString& aPassword ) override; + virtual void SAL_CALL unprotect( const OUString& aPassword ) override; + virtual sal_Bool SAL_CALL isProtected() override; + + // XScenario + virtual sal_Bool SAL_CALL getIsScenario() override; + virtual OUString SAL_CALL getScenarioComment() override; + virtual void SAL_CALL setScenarioComment( const OUString& aScenarioComment ) override; + virtual void SAL_CALL addRanges( const css::uno::Sequence< + css::table::CellRangeAddress >& aRanges ) override; + virtual void SAL_CALL apply() override; + // XScenarioEnhanced + virtual css::uno::Sequence< css::table::CellRangeAddress > SAL_CALL + getRanges( ) override; + + // XExternalSheetName + virtual void SAL_CALL setExternalName( const OUString& aUrl, const OUString& aSheetName ) override; + + // XEventsSupplier + virtual css::uno::Reference< css::container::XNameReplace > SAL_CALL getEvents() override; + + // XPropertySet override due to sheet properties + virtual css::uno::Reference< css::beans::XPropertySetInfo > + SAL_CALL getPropertySetInfo() override; + + // XServiceInfo + 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; + + // XTypeProvider + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; + virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; +}; + +class ScTableColumnObj final : public ScCellRangeObj, + public css::container::XNamed +{ +private: + const SfxItemPropertySet* pColPropSet; + + virtual const SfxItemPropertyMap& GetItemPropertyMap() override; + virtual void GetOnePropertyValue( const SfxItemPropertyMapEntry* pEntry, + css::uno::Any& ) override; + virtual void SetOnePropertyValue( const SfxItemPropertyMapEntry* pEntry, + const css::uno::Any& aValue ) override; + +public: + ScTableColumnObj(ScDocShell* pDocSh, SCCOL nCol, SCTAB nTab); + virtual ~ScTableColumnObj() override; + + virtual css::uno::Any SAL_CALL queryInterface( + const css::uno::Type & rType ) override; + virtual void SAL_CALL acquire() noexcept override; + virtual void SAL_CALL release() noexcept override; + + // XNamed + virtual OUString SAL_CALL getName() override; + virtual void SAL_CALL setName( const OUString& aName ) override; + + // XPropertySet override due to column properties + virtual css::uno::Reference< css::beans::XPropertySetInfo > + SAL_CALL getPropertySetInfo() override; + + // XServiceInfo + 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; + + // XTypeProvider + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; + virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; +}; + +class ScTableRowObj final : public ScCellRangeObj +{ +private: + const SfxItemPropertySet* pRowPropSet; + + virtual const SfxItemPropertyMap& GetItemPropertyMap() override; + virtual void GetOnePropertyValue( const SfxItemPropertyMapEntry* pEntry, + css::uno::Any& ) override; + virtual void SetOnePropertyValue( const SfxItemPropertyMapEntry* pEntry, + const css::uno::Any& aValue ) override; + +public: + ScTableRowObj(ScDocShell* pDocSh, SCROW nRow, SCTAB nTab); + virtual ~ScTableRowObj() override; + + // XPropertySet override due to row properties + virtual css::uno::Reference< css::beans::XPropertySetInfo > + SAL_CALL getPropertySetInfo() override; + + // XServiceInfo + 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; +}; + +class ScCellsObj final : public cppu::WeakImplHelper< + css::container::XEnumerationAccess, + css::lang::XServiceInfo >, + public SfxListener +{ +private: + ScDocShell* pDocShell; + ScRangeList aRanges; + +public: + ScCellsObj(ScDocShell* pDocSh, ScRangeList aR); + virtual ~ScCellsObj() override; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + // XEnumerationAccess + virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL + createEnumeration() override; + + // XElementAccess + virtual css::uno::Type SAL_CALL getElementType() override; + virtual sal_Bool SAL_CALL hasElements() override; + + // XServiceInfo + 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; +}; + +class ScCellsEnumeration final : public cppu::WeakImplHelper< + css::container::XEnumeration, + css::lang::XServiceInfo >, + public SfxListener +{ +private: + ScDocShell* pDocShell; + ScRangeList aRanges; + ScAddress aPos; + std::unique_ptr<ScMarkData> pMark; + bool bAtEnd; + +private: + void Advance_Impl(); + void CheckPos_Impl(); + +public: + ScCellsEnumeration(ScDocShell* pDocSh, ScRangeList aR); + virtual ~ScCellsEnumeration() override; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + // XEnumeration + virtual sal_Bool SAL_CALL hasMoreElements() override; + virtual css::uno::Any SAL_CALL nextElement() override; + + // XServiceInfo + 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; +}; + +class ScCellFormatsObj final : public cppu::WeakImplHelper< + css::container::XIndexAccess, + css::container::XEnumerationAccess, + css::lang::XServiceInfo >, + public SfxListener +{ +private: + ScDocShell* pDocShell; + ScRange aTotalRange; + +private: + rtl::Reference<ScCellRangeObj> GetObjectByIndex_Impl(tools::Long nIndex) const; + +public: + ScCellFormatsObj(ScDocShell* pDocSh, const ScRange& rR); + virtual ~ScCellFormatsObj() override; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + // XIndexAccess + virtual sal_Int32 SAL_CALL getCount() override; + virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override; + + // XEnumerationAccess + virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL + createEnumeration() override; + + // XElementAccess + virtual css::uno::Type SAL_CALL getElementType() override; + virtual sal_Bool SAL_CALL hasElements() override; + + // XServiceInfo + 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; +}; + +class ScCellFormatsEnumeration final : public cppu::WeakImplHelper< + css::container::XEnumeration, + css::lang::XServiceInfo >, + public SfxListener +{ +private: + ScDocShell* pDocShell; + SCTAB nTab; + std::unique_ptr<ScAttrRectIterator> pIter; + ScRange aNext; + bool bAtEnd; + bool bDirty; + +private: + void Advance_Impl(); + rtl::Reference<ScCellRangeObj> NextObject_Impl(); + +public: + ScCellFormatsEnumeration(ScDocShell* pDocSh, const ScRange& rR); + virtual ~ScCellFormatsEnumeration() override; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + // XEnumeration + virtual sal_Bool SAL_CALL hasMoreElements() override; + virtual css::uno::Any SAL_CALL nextElement() override; + + // XServiceInfo + 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; +}; + +class ScUniqueCellFormatsObj final : public cppu::WeakImplHelper< + css::container::XIndexAccess, + css::container::XEnumerationAccess, + css::lang::XServiceInfo >, + public SfxListener +{ +private: + ScDocShell* pDocShell; + std::vector<ScRangeList> aRangeLists; + +public: + ScUniqueCellFormatsObj(ScDocShell* pDocSh, const ScRange& rR); + virtual ~ScUniqueCellFormatsObj() override; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + // XIndexAccess + virtual sal_Int32 SAL_CALL getCount() override; + virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override; + + // XEnumerationAccess + virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL + createEnumeration() override; + + // XElementAccess + virtual css::uno::Type SAL_CALL getElementType() override; + virtual sal_Bool SAL_CALL hasElements() override; + + // XServiceInfo + 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; +}; + +class ScUniqueCellFormatsEnumeration final : public cppu::WeakImplHelper< + css::container::XEnumeration, + css::lang::XServiceInfo >, + public SfxListener +{ +private: + std::vector<ScRangeList> aRangeLists; + ScDocShell* pDocShell; + sal_Int32 nCurrentPosition; + +public: + ScUniqueCellFormatsEnumeration(ScDocShell* pDocShell, std::vector<ScRangeList>&& rRangeLists); + virtual ~ScUniqueCellFormatsEnumeration() override; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + // XEnumeration + virtual sal_Bool SAL_CALL hasMoreElements() override; + virtual css::uno::Any SAL_CALL nextElement() override; + + // XServiceInfo + 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; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/celltextattr.hxx b/sc/inc/celltextattr.hxx new file mode 100644 index 0000000000..e6a475700d --- /dev/null +++ b/sc/inc/celltextattr.hxx @@ -0,0 +1,26 @@ +/* -*- 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/. + */ + +#pragma once + +#include <sal/types.h> +#include <svl/languageoptions.hxx> + +namespace sc +{ +struct CellTextAttr +{ + sal_uInt16 mnTextWidth; + SvtScriptType mnScriptType; + + CellTextAttr(); +}; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/cellvalue.hxx b/sc/inc/cellvalue.hxx new file mode 100644 index 0000000000..6db9dee493 --- /dev/null +++ b/sc/inc/cellvalue.hxx @@ -0,0 +1,193 @@ +/* -*- 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/. + */ + +#pragma once + +#include "global.hxx" +#include <svl/sharedstring.hxx> +#include <variant> + +class ScDocument; +class ScFormulaCell; +class EditTextObject; +class ScColumn; +struct ScRefCellValue; + +namespace sc { +struct ColumnBlockPosition; +} + +/** + * Store arbitrary cell value of any kind. It only stores cell value and + * nothing else. It creates a copy of the original cell value, and manages + * the life cycle of the copied value. + */ +struct SC_DLLPUBLIC ScCellValue +{ +private: + /// std::monostate is there to indicate CellType::NONE + std::variant<std::monostate, double, svl::SharedString, EditTextObject*, ScFormulaCell*> maData; + + void reset_to_empty(); +public: + + ScCellValue(); + ScCellValue( const ScRefCellValue& rCell ); + ScCellValue( double fValue ); + ScCellValue( const svl::SharedString& rString ); + ScCellValue( std::unique_ptr<EditTextObject> ); + ScCellValue( const ScCellValue& r ); + ScCellValue(ScCellValue&& r) noexcept; + ~ScCellValue(); + + void clear() noexcept; + + void set( double fValue ); + void set( const svl::SharedString& rStr ); + void set( const EditTextObject& rEditText ); + void set( std::unique_ptr<EditTextObject> ); + void set( ScFormulaCell* pFormula ); + + CellType getType() const; + double getDouble() const { return std::get<double>(maData); } + ScFormulaCell* getFormula() const { return std::get<ScFormulaCell*>(maData); } + const svl::SharedString* getSharedString() const { return &std::get<svl::SharedString>(maData); } + EditTextObject* getEditText() const { return std::get<EditTextObject*>(maData); } + EditTextObject* releaseEditText() { auto p = getEditText(); maData = static_cast<EditTextObject*>(nullptr); return p; } + ScFormulaCell* releaseFormula() { auto p = getFormula(); maData = static_cast<ScFormulaCell*>(nullptr); return p; } + + /** + * Take cell value from specified position in specified document. + */ + void assign( const ScDocument& rDoc, const ScAddress& rPos ); + + void assign(const ScCellValue& rOther, ScDocument& rDestDoc, ScCloneFlags nCloneFlags = ScCloneFlags::Default); + + /** + * Set cell value at specified position in specified document. + */ + void commit( ScDocument& rDoc, const ScAddress& rPos ) const; + + void commit( ScColumn& rColumn, SCROW nRow ) const; + + /** + * Set cell value at specified position in specified document. But unlike + * commit(), this method sets the original value to the document without + * copying. After this call, the value gets cleared. + */ + void release( ScDocument& rDoc, const ScAddress& rPos ); + + void release( ScColumn& rColumn, SCROW nRow, sc::StartListeningType eListenType = sc::SingleCellListening ); + + OUString getString( const ScDocument& rDoc ) const; + + bool isEmpty() const; + + bool equalsWithoutFormat( const ScCellValue& r ) const; + + ScCellValue& operator= ( const ScCellValue& r ); + ScCellValue& operator=(ScCellValue&& r) noexcept; + ScCellValue& operator= ( const ScRefCellValue& r ); + + void swap( ScCellValue& r ); +}; + +/** + * This is very similar to ScCellValue, except that it references the + * original value instead of copying it. As such, don't hold an instance of + * this class any longer than necessary, and absolutely not after the + * original cell has been destroyed. + */ +struct SC_DLLPUBLIC ScRefCellValue +{ +private: + CellType meType; + union { + double mfValue; + const svl::SharedString* mpString; + const EditTextObject* mpEditText; + ScFormulaCell* mpFormula; + }; +public: + + ScRefCellValue(); + ScRefCellValue( double fValue ); + ScRefCellValue( const svl::SharedString* pString ); + ScRefCellValue( const EditTextObject* pEditText ); + ScRefCellValue( ScFormulaCell* pFormula ); + + /** + * Take cell value from specified position in specified document. + */ + ScRefCellValue( ScDocument& rDoc, const ScAddress& rPos ); + ScRefCellValue( ScDocument& rDoc, const ScAddress& rPos, sc::ColumnBlockPosition& rBlockPos ); + + void clear(); + + CellType getType() const { return meType; } + double getDouble() const { assert(meType == CELLTYPE_VALUE); return mfValue; } + const svl::SharedString* getSharedString() const { assert(meType == CELLTYPE_STRING); return mpString; } + const EditTextObject* getEditText() const { assert(meType == CELLTYPE_EDIT); return mpEditText; } + ScFormulaCell* getFormula() const { assert(meType == CELLTYPE_FORMULA); return mpFormula; } + + /** + * Take cell value from specified position in specified document. + */ + void assign( ScDocument& rDoc, const ScAddress& rPos ); + void assign( ScDocument& rDoc, const ScAddress& rPos, sc::ColumnBlockPosition& rBlockPos ); + + /** + * Set cell value at specified position in specified document. + */ + void commit( ScDocument& rDoc, const ScAddress& rPos ) const; + + bool hasString() const; + + bool hasNumeric() const; + + bool hasError() const; + + double getValue(); + + /** + * Retrieve a numeric value without modifying the states of any objects in + * the referenced document store. + */ + double getRawValue() const; + + /** + * Retrieve string value. + * + * Note that this method is NOT thread-safe. + * + * @param pDoc + * Needed to resolve EditCells' field contents, obtain a + * ScFieldEditEngine from that document. May be NULL if there is + * no ScDocument in the calling context but then the document + * specific fields can not be resolved. See + * ScEditUtil::GetString(). + */ + OUString getString( const ScDocument* pDoc ) const; + + /** + * Retrieve a string value without modifying the states of any objects in + * the referenced document store. + * + * This method is thread-safe. + */ + OUString getRawString( const ScDocument& rDoc ) const; + + bool isEmpty() const; + + bool hasEmptyValue(); + + bool equalsWithoutFormat( const ScRefCellValue& r ) const; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/cellvalues.hxx b/sc/inc/cellvalues.hxx new file mode 100644 index 0000000000..352a152ec8 --- /dev/null +++ b/sc/inc/cellvalues.hxx @@ -0,0 +1,120 @@ +/* -*- 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/. + */ + +#pragma once + +#include "address.hxx" +#include <memory> +#include <vector> + +class ScColumn; +class ScFormulaCell; +class EditTextObject; + +namespace svl +{ +class SharedString; +} + +namespace sc +{ +struct CellValuesImpl; + +struct CellValueSpan +{ + SCROW mnRow1; + SCROW mnRow2; + + CellValueSpan(SCROW nRow1, SCROW nRow2); +}; + +/** + * Think of this as a mini-ScColumn like storage that only stores cell + * values in a column. + */ +class CellValues +{ + std::unique_ptr<CellValuesImpl> mpImpl; + + CellValues(const CellValues&) = delete; + CellValues& operator=(const CellValues&) = delete; + +public: + CellValues(); + ~CellValues(); + + /** + * Transfer values from specified column. The transferred segment in the + * source column becomes empty after this call. + * + * @param rCol source column to transfer values from. + * @param nRow top row position in the source column. + * @param nLen length of the segment to transfer. + */ + void transferFrom(ScColumn& rCol, SCROW nRow, size_t nLen); + + void copyTo(ScColumn& rCol, SCROW nRow) const; + void swapNonEmpty(ScColumn& rCol); + + void assign(const std::vector<double>& rVals); + void assign(const std::vector<ScFormulaCell*>& rVals); + + size_t size() const; + + void reset(size_t nSize); + void setValue(size_t nRow, double fVal); + void setValue(size_t nRow, const svl::SharedString& rStr); + /// Takes ownership of pEditText. + void setValue(size_t nRow, std::unique_ptr<EditTextObject> pEditText); + + void swap(CellValues& r); + + std::vector<CellValueSpan> getNonEmptySpans() const; + +private: + void copyCellsTo(ScColumn& rCol, SCROW nRow) const; + void copyCellTextAttrsTo(ScColumn& rCol, SCROW nRow) const; +}; + +/** + * Stores cell values for multiple tables. + */ +class TableValues +{ + struct Impl; + + std::unique_ptr<Impl> mpImpl; + + TableValues(const TableValues&) = delete; + TableValues& operator=(const TableValues&) = delete; + +public: + TableValues(); + TableValues(const ScRange& rRange); + ~TableValues(); + + const ScRange& getRange() const; + + /** + * Swap the entire column. + */ + void swap(SCTAB nTab, SCCOL nCol, CellValues& rColValue); + + /** + * Swap non-empty blocks with the column storage. + */ + void swapNonEmpty(SCTAB nTab, SCCOL nCol, ScColumn& rCol); + + std::vector<CellValueSpan> getNonEmptySpans(SCTAB nTab, SCCOL nCol) const; + + void swap(TableValues& rOther); +}; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/chart2uno.hxx b/sc/inc/chart2uno.hxx new file mode 100644 index 0000000000..a8ac442246 --- /dev/null +++ b/sc/inc/chart2uno.hxx @@ -0,0 +1,395 @@ +/* -*- 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 "cellsuno.hxx" +#include "rangelst.hxx" +#include "externalrefmgr.hxx" +#include "types.hxx" +#include "chartlis.hxx" + +#include <svl/lstner.hxx> +#include <com/sun/star/chart2/data/XDataProvider.hpp> +#include <com/sun/star/chart2/data/XSheetDataProvider.hpp> +#include <com/sun/star/chart2/data/XRangeXMLConversion.hpp> +#include <com/sun/star/chart2/data/XDataSource.hpp> +#include <com/sun/star/chart2/data/XDataSequence.hpp> +#include <com/sun/star/chart2/data/XTextualDataSequence.hpp> +#include <com/sun/star/chart2/data/XNumericalDataSequence.hpp> +#include <com/sun/star/chart2/data/DataSequenceRole.hpp> +#include <com/sun/star/chart2/XTimeBased.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/util/XCloneable.hpp> +#include <com/sun/star/util/XModifyBroadcaster.hpp> +#include <cppuhelper/implbase.hxx> +#include <rtl/ustring.hxx> +#include <svl/itemprop.hxx> + +#include <memory> +#include <optional> +#include <unordered_set> +#include <vector> + +namespace com::sun::star::chart2::data { class XLabeledDataSequence; } + +class ScDocument; + +// DataProvider +class SC_DLLPUBLIC ScChart2DataProvider final : public + ::cppu::WeakImplHelper< + css::chart2::data::XDataProvider, + css::chart2::data::XSheetDataProvider, + css::chart2::data::XRangeXMLConversion, + css::beans::XPropertySet, + css::lang::XServiceInfo>, + public SfxListener +{ +public: + + explicit ScChart2DataProvider( ScDocument* pDoc ); + virtual ~ScChart2DataProvider() override; + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + // XDataProvider + virtual sal_Bool SAL_CALL createDataSourcePossible( + const css::uno::Sequence< css::beans::PropertyValue >& aArguments ) override; + + virtual css::uno::Reference< + css::chart2::data::XDataSource > SAL_CALL createDataSource( + const css::uno::Sequence< css::beans::PropertyValue >& aArguments ) override; + + virtual css::uno::Sequence< + css::beans::PropertyValue > SAL_CALL detectArguments( + const css::uno::Reference< css::chart2::data::XDataSource >& xDataSource ) override; + + virtual sal_Bool SAL_CALL createDataSequenceByRangeRepresentationPossible( + const OUString& aRangeRepresentation ) override; + + virtual css::uno::Reference< + css::chart2::data::XDataSequence > SAL_CALL createDataSequenceByRangeRepresentation( + const OUString& aRangeRepresentation ) override; + + virtual css::uno::Reference<css::chart2::data::XDataSequence> SAL_CALL + createDataSequenceByValueArray( const OUString& aRole, const OUString& aRangeRepresentation, + const OUString& aRoleQualifier ) override; + + virtual css::uno::Reference< css::sheet::XRangeSelection > SAL_CALL getRangeSelection() override; + + // XSheetDataProvider + virtual sal_Bool SAL_CALL createDataSequenceByFormulaTokensPossible( + const css::uno::Sequence< css::sheet::FormulaToken >& aTokens ) override; + + virtual css::uno::Reference< css::chart2::data::XDataSequence > + SAL_CALL createDataSequenceByFormulaTokens( + const css::uno::Sequence< css::sheet::FormulaToken >& aTokens ) override; + + // XRangeXMLConversion + virtual OUString SAL_CALL convertRangeToXML( const OUString& sRangeRepresentation ) override; + + virtual OUString SAL_CALL convertRangeFromXML( const OUString& sXMLRange ) override; + + // XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo> SAL_CALL + getPropertySetInfo() override; + + virtual void SAL_CALL setPropertyValue( + const OUString& rPropertyName, + const css::uno::Any& rValue) override; + + virtual css::uno::Any SAL_CALL getPropertyValue( + const OUString& rPropertyName) override; + + virtual void SAL_CALL addPropertyChangeListener( + const OUString& rPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener>& xListener) override; + + virtual void SAL_CALL removePropertyChangeListener( + const OUString& rPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener>& rListener) override; + + virtual void SAL_CALL addVetoableChangeListener( + const OUString& rPropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener>& rListener) override; + + virtual void SAL_CALL removeVetoableChangeListener( + const OUString& rPropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener>& rListener) override; + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + + virtual sal_Bool SAL_CALL supportsService( const OUString& + rServiceName) override; + + virtual css::uno::Sequence< OUString> SAL_CALL + getSupportedServiceNames() override; + +private: + + ScDocument* m_pDocument; + SfxItemPropertySet m_aPropSet; + bool m_bIncludeHiddenCells; +}; + +// DataSource +class ScChart2DataSource final : public + ::cppu::WeakImplHelper< + css::chart2::data::XDataSource, + css::lang::XServiceInfo>, + public SfxListener +{ +public: + + explicit ScChart2DataSource( ScDocument* pDoc); + virtual ~ScChart2DataSource() override; + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + // XDataSource + virtual css::uno::Sequence< css::uno::Reference< + css::chart2::data::XLabeledDataSequence > > SAL_CALL + getDataSequences() override; + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + + virtual sal_Bool SAL_CALL supportsService( const OUString& + rServiceName) override; + + virtual css::uno::Sequence< OUString> SAL_CALL + getSupportedServiceNames() override; + + // implementation + + void AddLabeledSequence(const css::uno::Reference < css::chart2::data::XLabeledDataSequence >& xNew); + +private: + + ScDocument* m_pDocument; + std::vector < css::uno::Reference< css::chart2::data::XLabeledDataSequence > > m_aLabeledSequences; + +}; + +// DataSequence +class ScChart2DataSequence final : public + ::cppu::WeakImplHelper< + css::chart2::data::XDataSequence, + css::chart2::data::XTextualDataSequence, + css::chart2::data::XNumericalDataSequence, + css::chart2::XTimeBased, + css::util::XCloneable, + css::util::XModifyBroadcaster, + css::beans::XPropertySet, + css::lang::XServiceInfo>, + public SfxListener +{ +public: + explicit ScChart2DataSequence( ScDocument* pDoc, + ::std::vector<ScTokenRef>&& rTokens, bool bIncludeHiddenCells ); + + virtual ~ScChart2DataSequence() override; + ScChart2DataSequence(ScDocument* pDoc, const ScChart2DataSequence&); + ScChart2DataSequence(const ScChart2DataSequence&) = delete; + ScChart2DataSequence& operator=(const ScChart2DataSequence&) = delete; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + // XDataSequence + virtual css::uno::Sequence< css::uno::Any > + SAL_CALL getData() override; + virtual OUString SAL_CALL getSourceRangeRepresentation() override; + virtual css::uno::Sequence< OUString > + SAL_CALL generateLabel(css::chart2::data::LabelOrigin nOrigin) override; + + /** Get the number format key for the n-th data entry + * If nIndex == -1, then you will get the number format key for the first non-empty entry + */ + virtual ::sal_Int32 SAL_CALL getNumberFormatKeyByIndex( ::sal_Int32 nIndex ) override; + + // XNumericalDataSequence + virtual css::uno::Sequence< double > + SAL_CALL getNumericalData() override; + + // XTextualDataSequence + virtual css::uno::Sequence< OUString > + SAL_CALL getTextualData() override; + + // XTimeBased + virtual sal_Bool SAL_CALL switchToNext(sal_Bool bWrap) override; + virtual sal_Bool SAL_CALL setToPointInTime(sal_Int32 nPoint) override; + + virtual void SAL_CALL setRange(sal_Int32 nStart, sal_Int32 nEnd) override; + + // XPropertySet + virtual css::uno::Reference< + css::beans::XPropertySetInfo> SAL_CALL + getPropertySetInfo() override; + + virtual void SAL_CALL setPropertyValue( + const OUString& rPropertyName, + const css::uno::Any& rValue) override; + + virtual css::uno::Any SAL_CALL getPropertyValue( + const OUString& rPropertyName) override; + + virtual void SAL_CALL addPropertyChangeListener( + const OUString& rPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener>& xListener) override; + + virtual void SAL_CALL removePropertyChangeListener( + const OUString& rPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener>& rListener) override; + + virtual void SAL_CALL addVetoableChangeListener( + const OUString& rPropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener>& rListener) override; + + virtual void SAL_CALL removeVetoableChangeListener( + const OUString& rPropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener>& rListener) override; + + // XCloneable + virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override; + + // XModifyBroadcaster + virtual void SAL_CALL addModifyListener( + const css::uno::Reference< css::util::XModifyListener >& aListener ) override; + virtual void SAL_CALL removeModifyListener( + const css::uno::Reference< css::util::XModifyListener >& aListener ) override; + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + + virtual sal_Bool SAL_CALL supportsService( const OUString& + rServiceName) override; + + virtual css::uno::Sequence< OUString> SAL_CALL + getSupportedServiceNames() override; + +private: + void setDataChangedHint(bool b); + + // Implementation + void RefChanged(); + DECL_LINK( ValueListenerHdl, const SfxHint&, void ); + +private: + class ExternalRefListener final : public ScExternalRefManager::LinkListener + { + public: + ExternalRefListener(ScChart2DataSequence& rParent, ScDocument* pDoc); + virtual ~ExternalRefListener() override; + ExternalRefListener(const ExternalRefListener&) = delete; + ExternalRefListener& operator=(const ExternalRefListener&) = delete; + + virtual void notify(sal_uInt16 nFileId, ScExternalRefManager::LinkUpdateType eType) override; + void addFileId(sal_uInt16 nFileId); + const std::unordered_set<sal_uInt16>& getAllFileIds() const { return maFileIds;} + + private: + ScChart2DataSequence& mrParent; + std::unordered_set<sal_uInt16> maFileIds; + ScDocument* mpDoc; + }; + + /** + * Build an internal data array to cache the data ranges, and other + * information such as hidden values. + */ + void BuildDataCache(); + + void RebuildDataCache(); + + sal_Int32 FillCacheFromExternalRef(const ScTokenRef& pToken); + + void UpdateTokensFromRanges(const ScRangeList& rRanges); + + ExternalRefListener* GetExtRefListener(); + + void StopListeningToAllExternalRefs(); + +private: + + // data array + struct Item + { + double mfValue; + OUString maString; + bool mbIsValue; + ScAddress mAddress; + Item(); + }; + + class HiddenRangeListener final : public ScChartHiddenRangeListener + { + public: + HiddenRangeListener(ScChart2DataSequence& rParent); + virtual ~HiddenRangeListener() override; + + virtual void notify() override; + + private: + ScChart2DataSequence& mrParent; + }; + + /** This vector contains the cached data which was calculated with BuildDataCache(). + We use a shared_ptr because chart likes to Clone this class, which is very + expensive when we have lots of data. */ + std::shared_ptr<std::vector<Item>> m_xDataArray; + + /** + * Cached data for getData. We may also need to cache data for the + * numerical and textural data series if they turn out to be bottlenecks + * under certain scenarios. + */ + css::uno::Sequence< css::uno::Any > m_aMixedDataCache; + + css::uno::Sequence<sal_Int32> m_aHiddenValues; + + // properties + css::chart2::data::DataSequenceRole m_aRole; + bool m_bIncludeHiddenCells; + + // internals + sal_Int64 m_nObjectId; + ScDocument* m_pDocument; + std::vector<ScTokenRef> m_aTokens; + std::optional<std::vector<sal_uInt32>> + m_oRangeIndices; + std::unique_ptr<ExternalRefListener> + m_pExtRefListener; + SfxItemPropertySet m_aPropSet; + + std::unique_ptr<HiddenRangeListener> m_pHiddenListener; + + std::unique_ptr<ScLinkListener> m_pValueListener; + XModifyListenerArr_Impl m_aValueListeners; + + bool m_bGotDataChangedHint; + bool m_bExtDataRebuildQueued; + + bool mbTimeBased; + SCTAB mnTimeBasedStart; + SCTAB mnTimeBasedEnd; + SCTAB mnCurrentTab; + +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/chartarr.hxx b/sc/inc/chartarr.hxx new file mode 100644 index 0000000000..3540ccb900 --- /dev/null +++ b/sc/inc/chartarr.hxx @@ -0,0 +1,82 @@ +/* -*- 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 "rangelst.hxx" +#include "chartpos.hxx" + +#include <memory> + +class ScDocument; + +// ScMemChart is a stripped-down SchMemChart from old chart, +// used only to transport a rectangular data array for the UNO API, +// contains only column/row header text and data values. + +class ScMemChart +{ + SCROW nRowCnt; + SCCOL nColCnt; + std::unique_ptr<double[]> pData; + std::unique_ptr<OUString[]> pColText; + std::unique_ptr<OUString[]> pRowText; + + ScMemChart(const ScMemChart& rMemChart) = delete; + +public: + ScMemChart(SCCOL nCols, SCROW nRows); + ~ScMemChart(); + + SCCOL GetColCount() const { return nColCnt; } + SCROW GetRowCount() const { return nRowCnt; } + const OUString& GetColText(SCCOL nCol) const { return pColText[nCol]; } + const OUString& GetRowText(SCROW nRow) const { return pRowText[nRow]; } + double GetData(SCCOL nCol, SCROW nRow) const { return pData[nCol * nRowCnt + nRow]; } + void SetData(SCCOL nCol, SCROW nRow, const double& rVal) + { + pData[nCol * nRowCnt + nRow] = rVal; + } + void SetColText(SCCOL nCol, const OUString& rText) { pColText[nCol] = rText; } + void SetRowText(SCROW nRow, const OUString& rText) { pRowText[nRow] = rText; } +}; + +class ScChartArray // only parameter-struct +{ + ScDocument& rDocument; + ScChartPositioner aPositioner; + +private: + std::unique_ptr<ScMemChart> CreateMemChartSingle(); + std::unique_ptr<ScMemChart> CreateMemChartMulti(); + +public: + ScChartArray(ScDocument& rDoc, const ScRangeListRef& rRangeList); + + const ScRangeListRef& GetRangeList() const { return aPositioner.GetRangeList(); } + const ScChartPositionMap* GetPositionMap() { return aPositioner.GetPositionMap(); } + + void SetHeaders(bool bCol, bool bRow) { aPositioner.SetHeaders(bCol, bRow); } + bool HasColHeaders() const { return aPositioner.HasColHeaders(); } + bool HasRowHeaders() const { return aPositioner.HasRowHeaders(); } + + std::unique_ptr<ScMemChart> CreateMemChart(); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/charthelper.hxx b/sc/inc/charthelper.hxx new file mode 100644 index 0000000000..69eb7f2372 --- /dev/null +++ b/sc/inc/charthelper.hxx @@ -0,0 +1,54 @@ +/* -*- 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 "rangelst.hxx" + +namespace com::sun::star::chart2 { class XChartDocument; } +namespace com::sun::star::uno { template <typename > class Sequence; } + +class SdrObject; +class SdrPage; +class ScModelObj; + +typedef ::std::vector< ScRangeList > ScRangeListVector; + +/** Use this to handle charts in a calc document +*/ +class ScChartHelper +{ +public: + static sal_uInt16 DoUpdateAllCharts( ScDocument& rDoc ); + static void AdjustRangesOfChartsOnDestinationPage( const ScDocument& rSrcDoc, ScDocument& rDestDoc, const SCTAB nSrcTab, const SCTAB nDestTab ); + static void UpdateChartsOnDestinationPage( ScDocument& rDestDoc, const SCTAB nDestTab ); + static css::uno::Reference< css::chart2::XChartDocument > GetChartFromSdrObject( const SdrObject* pObject ); + static void GetChartRanges( const css::uno::Reference< css::chart2::XChartDocument >& xChartDoc, + std::vector< OUString >& rRanges ); + static void SetChartRanges( const css::uno::Reference< css::chart2::XChartDocument >& xChartDoc, + const css::uno::Sequence< OUString >& rRanges ); + + static void AddRangesIfProtectedChart( ScRangeListVector& rRangesVector, const ScDocument& rDocument, SdrObject* pObject ); + static void FillProtectedChartRangesVector( ScRangeListVector& rRangesVector, const ScDocument& rDocument, const SdrPage* pPage ); + static void GetChartNames( ::std::vector< OUString >& rChartNames, const SdrPage* pPage ); + static void CreateProtectedChartListenersAndNotify( ScDocument& rDoc, const SdrPage* pPage, ScModelObj* pModelObj, SCTAB nTab, + const ScRangeListVector& rRangesVector, const ::std::vector< OUString >& rExcludedChartNames, bool bSameDoc = true ); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/chartlis.hxx b/sc/inc/chartlis.hxx new file mode 100644 index 0000000000..5617dc482a --- /dev/null +++ b/sc/inc/chartlis.hxx @@ -0,0 +1,211 @@ +/* -*- 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/idle.hxx> +#include <svl/listener.hxx> +#include "rangelst.hxx" +#include "externalrefmgr.hxx" + +#include <memory> +#include <map> +#include <string_view> +#include <unordered_map> +#include <unordered_set> +#include <vector> + +namespace com::sun::star::chart { class XChartData; } +namespace com::sun::star::chart { class XChartDataChangeEventListener; } + +class Timer; +class ScDocument; +class ScChartUnoData; + +class SC_DLLPUBLIC ScChartListener final : public SvtListener +{ +public: + class SAL_DLLPRIVATE ExternalRefListener final : public ScExternalRefManager::LinkListener + { + public: + ExternalRefListener(ScChartListener& rParent, ScDocument& rDoc); + virtual ~ExternalRefListener() override; + virtual void notify(sal_uInt16 nFileId, ScExternalRefManager::LinkUpdateType eType) override; + void addFileId(sal_uInt16 nFileId); + void removeFileId(sal_uInt16 nFileId); + std::unordered_set<sal_uInt16>& getAllFileIds() { return maFileIds;} + + private: + ExternalRefListener(const ExternalRefListener& r) = delete; + + ScChartListener& mrParent; + std::unordered_set<sal_uInt16> maFileIds; + ScDocument* m_pDoc; + }; + +private: + + std::unique_ptr<ExternalRefListener> mpExtRefListener; + std::vector<ScTokenRef> maTokens; + + OUString maName; + std::unique_ptr<ScChartUnoData> pUnoData; + ScDocument& mrDoc; + bool bUsed:1; // for ScChartListenerCollection::FreeUnused + bool bDirty:1; + + ScChartListener& operator=( const ScChartListener& ) = delete; + +public: + ScChartListener( OUString aName, ScDocument& rDoc, + const ScRangeListRef& rRangeListRef ); + ScChartListener( OUString aName, ScDocument& rDoc, + ::std::vector<ScTokenRef> aTokens ); + ScChartListener( const ScChartListener& ) = delete; + virtual ~ScChartListener() override; + + const OUString& GetName() const { return maName;} + + void SetUno( const css::uno::Reference< css::chart::XChartDataChangeEventListener >& rListener, + const css::uno::Reference< css::chart::XChartData >& rSource ); + css::uno::Reference< css::chart::XChartDataChangeEventListener > GetUnoListener() const; + css::uno::Reference< css::chart::XChartData > GetUnoSource() const; + + bool IsUno() const { return (pUnoData != nullptr); } + + virtual void Notify( const SfxHint& rHint ) override; + void StartListeningTo(); + void EndListeningTo(); + void ChangeListening( const ScRangeListRef& rRangeListRef, + bool bDirty ); + void Update(); + ScRangeListRef GetRangeList() const; + void SetRangeList( const ScRangeListRef& rNew ); + bool IsUsed() const { return bUsed; } + void SetUsed( bool bFlg ) { bUsed = bFlg; } + bool IsDirty() const { return bDirty; } + void SetDirty( bool bFlg ) { bDirty = bFlg; } + + void UpdateChartIntersecting( const ScRange& rRange ); + + ExternalRefListener* GetExtRefListener(); + void SetUpdateQueue(); + + bool operator==( const ScChartListener& ) const; + bool operator!=( const ScChartListener& r ) const; +}; + +class SC_DLLPUBLIC ScChartHiddenRangeListener +{ +public: + ScChartHiddenRangeListener(); + virtual ~ScChartHiddenRangeListener(); + virtual void notify() = 0; +}; + +class SC_DLLPUBLIC ScChartListenerCollection final +{ +public: + typedef std::map<OUString, std::unique_ptr<ScChartListener>> ListenersType; + typedef std::unordered_set<OUString> StringSetType; +private: + ListenersType m_Listeners; + enum UpdateStatus + { + SC_CLCUPDATE_NONE, + SC_CLCUPDATE_RUNNING, + SC_CLCUPDATE_MODIFIED + } meModifiedDuringUpdate; + + std::unordered_multimap<ScChartHiddenRangeListener*, ScRange> maHiddenListeners; + + StringSetType maNonOleObjectNames; + + Idle aIdle; + ScDocument& rDoc; + + DECL_DLLPRIVATE_LINK(TimerHdl, Timer *, void); + + ScChartListenerCollection& operator=( const ScChartListenerCollection& ) = delete; + + void Init(); + +public: + ScChartListenerCollection( ScDocument& rDoc ); + ScChartListenerCollection( const ScChartListenerCollection& ); + ~ScChartListenerCollection(); + + // only needed after copy-ctor, if newly added to doc + void StartAllListeners(); + + bool insert(ScChartListener* pListener); + ScChartListener* findByName(const OUString& rName); + const ScChartListener* findByName(const OUString& rName) const; + bool hasListeners() const; + + void removeByName(const OUString& rName); + + const ListenersType& getListeners() const { return m_Listeners; } + ListenersType& getListeners() { return m_Listeners; } + StringSetType& getNonOleObjectNames() { return maNonOleObjectNames;} + + /** + * Create a unique name that's not taken by any existing chart listener + * objects. The name consists of a prefix given followed by a number. + */ + OUString getUniqueName(std::u16string_view rPrefix) const; + + void ChangeListening( const OUString& rName, + const ScRangeListRef& rRangeListRef ); + // use FreeUnused only the way it's used in ScDocument::UpdateChartListenerCollection + void FreeUnused(); + void FreeUno( const css::uno::Reference< css::chart::XChartDataChangeEventListener >& rListener, + const css::uno::Reference< css::chart::XChartData >& rSource ); + void StartTimer(); + void UpdateDirtyCharts(); + void SetDirty(); + void SetDiffDirty( const ScChartListenerCollection&, + bool bSetChartRangeLists ); + + void SetRangeDirty( const ScRange& rRange ); // for example rows/columns + + void UpdateChartsContainingTab( SCTAB nTab ); + + bool operator==( const ScChartListenerCollection& r ) const; + + /** + * Start listening on hide/show change within specified cell range. A + * single listener may listen on multiple ranges when the caller passes + * the same pointer multiple times with different ranges. + * + * Note that the caller is responsible for managing the life-cycle of the + * listener instance. + */ + void StartListeningHiddenRange( const ScRange& rRange, + ScChartHiddenRangeListener* pListener ); + + /** + * Remove all ranges associated with passed listener instance from the + * list of hidden range listeners. This does not delete the passed + * listener instance. + */ + void EndListeningHiddenRange( ScChartHiddenRangeListener* pListener ); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/chartlock.hxx b/sc/inc/chartlock.hxx new file mode 100644 index 0000000000..bf66b7f5b7 --- /dev/null +++ b/sc/inc/chartlock.hxx @@ -0,0 +1,72 @@ +/* -*- 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 <cppuhelper/weakref.hxx> + +#include <memory> +#include <vector> + +namespace com::sun::star::frame { class XModel; } + +class ScDocument; + +/** All current charts in the calc will be locked in constructor and unlocked in destructor. +*/ +class ScChartLockGuard final +{ +public: + ScChartLockGuard( ScDocument* pDoc ); + ~ScChartLockGuard(); + + void AlsoLockThisChart( const css::uno::Reference< css::frame::XModel >& xModel ); + +private: + std::vector< css::uno::WeakReference< css::frame::XModel > > maChartModels; + + ScChartLockGuard( const ScChartLockGuard& ) = delete; +}; + +/** Use this to lock all charts in the calc for a little time. + They will unlock automatically unless you call StartOrContinueLocking() again. +*/ +class ScTemporaryChartLock final +{ +public: + ScTemporaryChartLock( ScDocument* pDoc ); + ~ScTemporaryChartLock(); + + void StartOrContinueLocking(); + void StopLocking(); + void AlsoLockThisChart( const css::uno::Reference< css::frame::XModel >& xModel ); + +private: + ScDocument* mpDoc; + Timer maTimer; + std::unique_ptr< ScChartLockGuard > mapScChartLockGuard; + + DECL_LINK(TimeoutHdl, Timer *, void); + + ScTemporaryChartLock( const ScTemporaryChartLock& ) = delete; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/chartpos.hxx b/sc/inc/chartpos.hxx new file mode 100644 index 0000000000..685a2d350c --- /dev/null +++ b/sc/inc/chartpos.hxx @@ -0,0 +1,139 @@ +/* -*- 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 "rangelst.hxx" +#include <tools/solar.h> +#include <memory> +#include <map> + +// map of row number to ScAddress* +typedef std::map<SCROW, std::unique_ptr<ScAddress>> RowMap; +// map of column number to RowMap +typedef std::map<SCCOL, RowMap> ColumnMap; + +class ScChartPositionMap +{ + friend class ScChartPositioner; + + std::unique_ptr<std::unique_ptr<ScAddress>[]> ppData; + std::unique_ptr<std::unique_ptr<ScAddress>[]> ppColHeader; + std::unique_ptr<std::unique_ptr<ScAddress>[]> ppRowHeader; + sal_uInt64 nCount; + SCCOL nColCount; + SCROW nRowCount; + + ScChartPositionMap( SCCOL nChartCols, SCROW nChartRows, + SCCOL nColAdd, // header columns + SCROW nRowAdd, // header rows + ColumnMap& rCols // table with col tables with address* + ); + + ScChartPositionMap( const ScChartPositionMap& ) = delete; + ScChartPositionMap& operator=( const ScChartPositionMap& ) = delete; + +public: + ~ScChartPositionMap(); //! deletes all ScAddress* + + SCCOL GetColCount() const { return nColCount; } + SCROW GetRowCount() const { return nRowCount; } + + bool IsValid( SCCOL nCol, SCROW nRow ) const + { return nCol < nColCount && nRow < nRowCount; } + // data column by column + sal_uInt64 GetIndex( SCCOL nCol, SCROW nRow ) const + { return static_cast<sal_uInt64>(nCol) * nRowCount + nRow; } + + const ScAddress* GetPosition( sal_uInt64 nIndex ) const + { + if ( nIndex < nCount ) + return ppData[ nIndex ].get(); + return nullptr; + } + + //! might be NULL indicating "no value" + const ScAddress* GetPosition( SCCOL nChartCol, SCROW nChartRow ) const + { + if ( IsValid( nChartCol, nChartRow ) ) + return ppData[ GetIndex( nChartCol, nChartRow ) ].get(); + return nullptr; + } + const ScAddress* GetColHeaderPosition( SCCOL nChartCol ) const + { + if ( nChartCol < nColCount ) + return ppColHeader[ nChartCol ].get(); + return nullptr; + } + const ScAddress* GetRowHeaderPosition( SCROW nChartRow ) const + { + if ( nChartRow < nRowCount ) + return ppRowHeader[ nChartRow ].get(); + return nullptr; + } +}; + +enum class ScChartGlue { + NA, + NONE, // old mimic + Cols, // old mimic + Rows, + Both +}; + +class ScDocument; + +class ScChartPositioner final // only parameter struct +{ + ScRangeListRef aRangeListRef; + ScDocument& rDocument; + std::unique_ptr<ScChartPositionMap> pPositionMap; + ScChartGlue eGlue; + SCCOL nStartCol; + SCROW nStartRow; + bool bColHeaders; + bool bRowHeaders; + bool bDummyUpperLeft; + + void CheckColRowHeaders(); + + void GlueState(); // summarised areas + void CreatePositionMap(); + +public: + ScChartPositioner( ScDocument& rDoc, SCTAB nTab, + SCCOL nStartColP, SCROW nStartRowP, + SCCOL nEndColP, SCROW nEndRowP ); + ScChartPositioner( ScDocument& rDoc, ScRangeListRef xRangeList ); + ScChartPositioner( const ScChartPositioner& rPositioner ); + + ~ScChartPositioner(); + + const ScRangeListRef& GetRangeList() const { return aRangeListRef; } + void SetRangeList( const ScRange& rNew ); + + void SetHeaders(bool bCol, bool bRow) { bColHeaders=bCol; bRowHeaders=bRow; } + bool HasColHeaders() const { return bColHeaders; } + bool HasRowHeaders() const { return bRowHeaders; } + + void InvalidateGlue(); + const ScChartPositionMap* GetPositionMap(); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/chartuno.hxx b/sc/inc/chartuno.hxx new file mode 100644 index 0000000000..8eba30e630 --- /dev/null +++ b/sc/inc/chartuno.hxx @@ -0,0 +1,165 @@ +/* -*- 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 "rangelst.hxx" +#include <rtl/ref.hxx> +#include <svl/lstner.hxx> +#include <comphelper/proparrhlp.hxx> +#include <comphelper/propertycontainer.hxx> + +#include <com/sun/star/table/XTableChart.hpp> +#include <com/sun/star/table/XTableCharts.hpp> +#include <com/sun/star/document/XEmbeddedObjectSupplier.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/container/XEnumerationAccess.hpp> +#include <com/sun/star/container/XIndexAccess.hpp> +#include <com/sun/star/container/XNamed.hpp> +#include <cppuhelper/basemutex.hxx> +#include <cppuhelper/compbase.hxx> +#include <cppuhelper/implbase.hxx> + +class ScDocShell; +class ScChartObj; + +class ScChartsObj final : public cppu::WeakImplHelper< + css::table::XTableCharts, + css::container::XEnumerationAccess, + css::container::XIndexAccess, + css::lang::XServiceInfo >, + public SfxListener +{ +private: + ScDocShell* pDocShell; + SCTAB nTab; // Charts are per sheet + + rtl::Reference<ScChartObj> GetObjectByIndex_Impl(tools::Long nIndex) const; + rtl::Reference<ScChartObj> GetObjectByName_Impl(const OUString& aName) const; + +public: + ScChartsObj(ScDocShell* pDocSh, SCTAB nT); + virtual ~ScChartsObj() override; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + // XTableCharts + virtual void SAL_CALL addNewByName( const OUString& aName, + const css::awt::Rectangle& aRect, + const css::uno::Sequence< css::table::CellRangeAddress >& aRanges, + sal_Bool bColumnHeaders, sal_Bool bRowHeaders ) override; + virtual void SAL_CALL removeByName( const OUString& aName ) override; + + // XNameAccess + virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override; + virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override; + + // XIndexAccess + virtual sal_Int32 SAL_CALL getCount() override; + virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override; + + // XEnumerationAccess + virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL + createEnumeration() override; + + // XElementAccess + virtual css::uno::Type SAL_CALL getElementType() override; + virtual sal_Bool SAL_CALL hasElements() override; + + // XServiceInfo + 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; +}; + +typedef ::cppu::WeakComponentImplHelper< + css::table::XTableChart, + css::document::XEmbeddedObjectSupplier, + css::container::XNamed, + css::lang::XServiceInfo > ScChartObj_Base; + +typedef ::comphelper::OPropertyContainer ScChartObj_PBase; +typedef ::comphelper::OPropertyArrayUsageHelper< ScChartObj > ScChartObj_PABase; + +class ScChartObj final : public ::cppu::BaseMutex + ,public ScChartObj_Base + ,public ScChartObj_PBase + ,public ScChartObj_PABase + ,public SfxListener +{ +private: + ScDocShell* pDocShell; + SCTAB nTab; // Charts are per sheet + OUString aChartName; + + void Update_Impl( const ScRangeListRef& rRanges, bool bColHeaders, bool bRowHeaders ); + void GetData_Impl( ScRangeListRef& rRanges, bool& rColHeaders, bool& rRowHeaders ) const; + + // ::comphelper::OPropertySetHelper + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const css::uno::Any& rValue ) override; + using ::cppu::OPropertySetHelper::getFastPropertyValue; + virtual void SAL_CALL getFastPropertyValue( css::uno::Any& rValue, sal_Int32 nHandle ) const override; + + // ::comphelper::OPropertyArrayUsageHelper + virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const override; + +public: + ScChartObj(ScDocShell* pDocSh, SCTAB nT, OUString aN); + virtual ~ScChartObj() override; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + // XInterface + DECLARE_XINTERFACE() + + // XTypeProvider + DECLARE_XTYPEPROVIDER() + + // XComponent + using ScChartObj_Base::disposing; + + // XTableChart + virtual sal_Bool SAL_CALL getHasColumnHeaders() override; + virtual void SAL_CALL setHasColumnHeaders( sal_Bool bHasColumnHeaders ) override; + virtual sal_Bool SAL_CALL getHasRowHeaders() override; + virtual void SAL_CALL setHasRowHeaders( sal_Bool bHasRowHeaders ) override; + virtual css::uno::Sequence< css::table::CellRangeAddress > SAL_CALL + getRanges( ) override; + virtual void SAL_CALL setRanges( const css::uno::Sequence< css::table::CellRangeAddress >& aRanges ) override; + + // XEmbeddedObjectSupplier + virtual css::uno::Reference< css::lang::XComponent > SAL_CALL + getEmbeddedObject() override; + + // XNamed + virtual OUString SAL_CALL getName() override; + virtual void SAL_CALL setName( const OUString& aName ) override; + + // XServiceInfo + 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; + + // XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/chgtrack.hxx b/sc/inc/chgtrack.hxx new file mode 100644 index 0000000000..9e3aed17aa --- /dev/null +++ b/sc/inc/chgtrack.hxx @@ -0,0 +1,1141 @@ +/* -*- 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 <map> +#include <memory> +#include <set> +#include <stack> +#include <vector> + +#include <com/sun/star/uno/Sequence.hxx> +#include <tools/color.hxx> +#include <tools/datetime.hxx> +#include <tools/link.hxx> +#include <tools/solar.h> +#include <unotools/options.hxx> +#include <optional> +#include "global.hxx" +#include "bigrange.hxx" +#include "scdllapi.h" +#include "cellvalue.hxx" + +class ScDocument; +class ScFormulaCell; +class ScChangeAction; +class ScChangeTrack; +class ScAppOptions; +namespace tools { class JsonWriter; } + +class ScActionColorChanger +{ +private: + const ScAppOptions& rOpt; + const std::set<OUString>& rUsers; + OUString aLastUserName; + sal_uInt16 nLastUserIndex; + Color nColor; + +public: + ScActionColorChanger( const ScChangeTrack& rTrack ); + void Update( const ScChangeAction& rAction ); + Color GetColor() const { return nColor; } +}; + +enum ScChangeActionType +{ + SC_CAT_NONE, + SC_CAT_INSERT_COLS, + SC_CAT_INSERT_ROWS, + SC_CAT_INSERT_TABS, + SC_CAT_DELETE_COLS, + SC_CAT_DELETE_ROWS, + SC_CAT_DELETE_TABS, + SC_CAT_MOVE, + SC_CAT_CONTENT, + SC_CAT_REJECT +}; + +enum ScChangeActionState +{ + SC_CAS_VIRGIN, + SC_CAS_ACCEPTED, + SC_CAS_REJECTED +}; + +enum ScChangeActionClipMode +{ + SC_CACM_NONE, + SC_CACM_CUT, + SC_CACM_PASTE +}; + +/** A link/connection/dependency between change actions. + + Upon construction inserts itself as the head of a chain / linked list, + respectively between existing link entries. + + Upon destruction removes itself from the list and connects the previous and + next entry, if it was the first entry automatically maintaining the head + pointer to the list. + + ppPrev == &previous->pNext or address of pointer to head of linked list, + *ppPrev == this + */ +class ScChangeActionLinkEntry +{ + ScChangeActionLinkEntry( const ScChangeActionLinkEntry& ) = delete; + ScChangeActionLinkEntry& operator=( const ScChangeActionLinkEntry& ) = delete; + + ScChangeActionLinkEntry* pNext; + ScChangeActionLinkEntry** ppPrev; + ScChangeAction* pAction; + ScChangeActionLinkEntry* pLink; + +public: + + ScChangeActionLinkEntry( + ScChangeActionLinkEntry** ppPrevP, + ScChangeAction* pActionP ) + : pNext( *ppPrevP ), + ppPrev( ppPrevP ), + pAction( pActionP ), + pLink( nullptr ) + { + if ( pNext ) + pNext->ppPrev = &pNext; + *ppPrevP = this; + } + + virtual ~ScChangeActionLinkEntry() + { + ScChangeActionLinkEntry* p = pLink; + UnLink(); + Remove(); + if ( p ) + delete p; + } + + void SetLink( ScChangeActionLinkEntry* pLinkP ) + { + UnLink(); + if ( pLinkP ) + { + pLink = pLinkP; + pLinkP->pLink = this; + } + } + + void UnLink() + { + if ( pLink ) + { + pLink->pLink = nullptr; + pLink = nullptr; + } + } + + void Remove() + { + if ( ppPrev ) + { + if ( ( *ppPrev = pNext ) != nullptr ) + pNext->ppPrev = ppPrev; + ppPrev = nullptr; // not inserted + } + } + + const ScChangeActionLinkEntry* GetNext() const { return pNext; } + ScChangeActionLinkEntry* GetNext() { return pNext; } + const ScChangeAction* GetAction() const { return pAction; } + ScChangeAction* GetAction() { return pAction; } +}; + +// ScChangeActionCellListEntry +// this is only for the XML Export in the hxx +class ScChangeActionContent; + +class SAL_DLLPUBLIC_RTTI ScChangeAction +{ + friend class ScChangeTrack; + friend class ScChangeActionIns; + friend class ScChangeActionDel; + friend class ScChangeActionMove; + friend class ScChangeActionContent; + + ScChangeAction( const ScChangeAction& ) = delete; + ScChangeAction& operator=( const ScChangeAction& ) = delete; + +protected: + + ScBigRange aBigRange; // Ins/Del/MoveTo/ContentPos + DateTime aDateTime; //! UTC + OUString aUser; // who? + OUString aComment; // user comment + ScChangeAction* pNext; // next in linked list + ScChangeAction* pPrev; // previous in linked list + ScChangeActionLinkEntry* pLinkAny; // arbitrary links + ScChangeActionLinkEntry* pLinkDeletedIn; // access to insert areas which were + // deleted or moved or rejected + ScChangeActionLinkEntry* pLinkDeleted; // links to deleted + ScChangeActionLinkEntry* pLinkDependent; // links to dependent + sal_uLong nAction; + sal_uLong nRejectAction; + ScChangeActionType eType; + ScChangeActionState eState; + + ScChangeAction( ScChangeActionType, const ScRange& ); + + // only to be used in the XML import + ScChangeAction( ScChangeActionType, + ScBigRange , + const sal_uLong nAction, + const sal_uLong nRejectAction, + const ScChangeActionState eState, + const DateTime& aDateTime, + OUString aUser, + OUString aComment ); + + // only to be used in the XML import + ScChangeAction( ScChangeActionType, ScBigRange , const sal_uLong nAction); + + OUString GetRefString( + const ScBigRange& rRange, const ScDocument& rDoc, bool bFlag3D = false) const; + + void SetActionNumber( sal_uLong n ) { nAction = n; } + void SetRejectAction( sal_uLong n ) { nRejectAction = n; } + void SetUser( const OUString& r ); + void SetType( ScChangeActionType e ) { eType = e; } + void SetState( ScChangeActionState e ) { eState = e; } + void SetRejected(); + + ScBigRange& GetBigRange() { return aBigRange; } + + void AddLink( ScChangeAction* p, ScChangeActionLinkEntry* pL ) + { + ScChangeActionLinkEntry* pLnk = + new ScChangeActionLinkEntry( + &pLinkAny, p ); + pLnk->SetLink( pL ); + } + + virtual ScChangeActionLinkEntry* GetDeletedIn() const + { return pLinkDeletedIn; } + virtual ScChangeActionLinkEntry** GetDeletedInAddress() + { return &pLinkDeletedIn; } + bool RemoveDeletedIn( const ScChangeAction* ); + void SetDeletedIn( ScChangeAction* ); + + ScChangeActionLinkEntry* AddDeleted( ScChangeAction* p ) + { + return new ScChangeActionLinkEntry(&pLinkDeleted, p); + } + + ScChangeActionLinkEntry* AddDependent( ScChangeAction* p ) + { + return new ScChangeActionLinkEntry(&pLinkDependent, p); + } + + void RemoveAllDependent(); + + void RemoveAllLinks(); + + virtual void AddContent( ScChangeActionContent* ) = 0; + virtual void DeleteCellEntries() = 0; + + virtual void UpdateReference( const ScChangeTrack*, + UpdateRefMode, const ScBigRange&, + sal_Int32 nDx, sal_Int32 nDy, sal_Int32 nDz ); + + void Accept(); + virtual bool Reject(ScDocument& rDoc) = 0; + void RejectRestoreContents( ScChangeTrack*, SCCOL nDx, SCROW nDy ); + + // used in Reject() instead of IsRejectable() + bool IsInternalRejectable() const; + + // Derived classes that hold a pointer to the + // ChangeTrack must return that. Otherwise NULL. + virtual const ScChangeTrack* GetChangeTrack() const = 0; + +public: + virtual ~ScChangeAction(); + + bool IsInsertType() const; + bool IsDeleteType() const; + bool IsVirgin() const; + SC_DLLPUBLIC bool IsAccepted() const; + bool IsRejected() const; + + // Action rejects another Action + bool IsRejecting() const; + + // if action is visible in the document + bool IsVisible() const; + + // if action if touchable + bool IsTouchable() const; + + // if action is an entry in dialog root + bool IsDialogRoot() const; + + // if an entry in a dialog shall be a drop down entry + bool IsDialogParent() const; + + // if action is a delete with subdeletes (aufgeklappt = open ?) + bool IsMasterDelete() const; + + // if action is acceptable/selectable/rejectable + bool IsClickable() const; + + // if action is rejectable + bool IsRejectable() const; + + const ScBigRange& GetBigRange() const { return aBigRange; } + SC_DLLPUBLIC DateTime GetDateTime() const; // local time + const DateTime& GetDateTimeUTC() const // UTC time + { return aDateTime; } + ScChangeActionType GetType() const { return eType; } + ScChangeActionState GetState() const { return eState; } + sal_uLong GetActionNumber() const { return nAction; } + sal_uLong GetRejectAction() const { return nRejectAction; } + + ScChangeAction* GetNext() const { return pNext; } + ScChangeAction* GetPrev() const { return pPrev; } + + bool IsDeletedIn() const; + bool IsDeletedIn( const ScChangeAction* ) const; + bool IsDeletedInDelType( ScChangeActionType ) const; + void RemoveAllDeletedIn(); + + const ScChangeActionLinkEntry* GetFirstDeletedEntry() const + { return pLinkDeleted; } + const ScChangeActionLinkEntry* GetFirstDependentEntry() const + { return pLinkDependent; } + bool HasDependent() const; + bool HasDeleted() const; + // description will be appended to string + // with bSplitRange only one column/row will be considered for delete + // (for a listing of entries) + virtual OUString GetDescription( + ScDocument& rDoc, bool bSplitRange = false, bool bWarning = true ) const; + + virtual OUString GetRefString( ScDocument& rDoc, bool bFlag3D = false ) const; + + // for DocumentMerge set old date of the other + // action, fetched by GetDateTimeUTC + void SetDateTimeUTC( const DateTime& rDT ) + { aDateTime = rDT; } + + const OUString& GetUser() const { return aUser;} + const OUString& GetComment() const { return aComment;} + + // set user comment + void SetComment( const OUString& rStr ); + + // only to be used in the XML import + void SetDeletedInThis( sal_uLong nActionNumber, + const ScChangeTrack* pTrack ); + // only to be used in the XML import + void AddDependent( sal_uLong nActionNumber, + const ScChangeTrack* pTrack ); +}; + +// ScChangeActionIns +class SAL_DLLPUBLIC_RTTI ScChangeActionIns final : public ScChangeAction +{ + friend class ScChangeTrack; + + bool mbEndOfList; /// whether or not a row was auto-inserted at the bottom. + + ScChangeActionIns( const ScDocument* pDoc, const ScRange& rRange, bool bEndOfList = false ); + + virtual void AddContent( ScChangeActionContent* ) override {} + virtual void DeleteCellEntries() override {} + + virtual bool Reject(ScDocument& rDoc) override; + + virtual const ScChangeTrack* GetChangeTrack() const override { return nullptr; } + +public: + virtual ~ScChangeActionIns() override; + ScChangeActionIns( + const sal_uLong nActionNumber, + const ScChangeActionState eState, + const sal_uLong nRejectingNumber, + const ScBigRange& aBigRange, + const OUString& aUser, + const DateTime& aDateTime, + const OUString &sComment, + const ScChangeActionType eType, + bool bEndOfList = false ); + + virtual OUString GetDescription( + ScDocument& rDoc, bool bSplitRange = false, bool bWarning = true) const override; + + SC_DLLPUBLIC bool IsEndOfList() const; +}; + +// ScChangeActionDel +class SAL_DLLPUBLIC_RTTI ScChangeActionMove; + +class ScChangeActionDelMoveEntry final : public ScChangeActionLinkEntry +{ + friend class ScChangeActionDel; + friend class ScChangeTrack; + + short nCutOffFrom; + short nCutOffTo; + + inline ScChangeActionDelMoveEntry( + ScChangeActionDelMoveEntry** ppPrevP, + ScChangeActionMove* pMove, + short nFrom, short nTo ); + + inline ScChangeActionMove* GetMove(); + +public: + const ScChangeActionDelMoveEntry* GetNext() const + { + return static_cast<const ScChangeActionDelMoveEntry*>( + ScChangeActionLinkEntry::GetNext()); + } + inline const ScChangeActionMove* GetMove() const; + short GetCutOffFrom() const { return nCutOffFrom; } + short GetCutOffTo() const { return nCutOffTo; } +}; + +class ScChangeActionDel final : public ScChangeAction +{ + friend class ScChangeTrack; + friend void ScChangeAction::Accept(); + + ScChangeTrack* pTrack; + std::vector<ScChangeActionContent*> mvCells; + ScChangeActionIns* pCutOff; // cut insert + short nCutOff; // +: start -: end + ScChangeActionDelMoveEntry* pLinkMove; + SCCOL nDx; + SCROW nDy; + + ScChangeActionDel( const ScDocument* pDoc, const ScRange& rRange, SCCOL nDx, SCROW nDy, ScChangeTrack* ); + + virtual void AddContent( ScChangeActionContent* ) override; + virtual void DeleteCellEntries() override; + + void UndoCutOffMoves(); + void UndoCutOffInsert(); + + virtual void UpdateReference( const ScChangeTrack*, + UpdateRefMode, const ScBigRange&, + sal_Int32 nDx, sal_Int32 nDy, sal_Int32 nDz ) override; + + virtual bool Reject(ScDocument& rDoc) override; + + virtual const ScChangeTrack* GetChangeTrack() const override { return pTrack; } + +public: + ScChangeActionDel( + const sal_uLong nActionNumber, const ScChangeActionState eState, + const sal_uLong nRejectingNumber, const ScBigRange& aBigRange, + const OUString& aUser, const DateTime& aDateTime, + const OUString &sComment, const ScChangeActionType eType, + const SCCOLROW nD, ScChangeTrack* pTrack); // only to use in the XML import + // which of nDx and nDy is set is dependent on the type + virtual ~ScChangeActionDel() override; + + // is the last in a row (or single) + bool IsBaseDelete() const; + + // is the first in a row (or single) + bool IsTopDelete() const; + + // is part of a row + bool IsMultiDelete() const; + + // is col, belonging to a TabDelete + bool IsTabDeleteCol() const; + + SCCOL GetDx() const { return nDx; } + SCROW GetDy() const { return nDy; } + ScBigRange GetOverAllRange() const; // BigRange + (nDx, nDy) + + const ScChangeActionDelMoveEntry* GetFirstMoveEntry() const + { return pLinkMove; } + const ScChangeActionIns* GetCutOffInsert() const { return pCutOff; } + short GetCutOffCount() const { return nCutOff; } + + virtual OUString GetDescription( + ScDocument& rDoc, bool bSplitRange = false, bool bWarning = true ) const override; + + void SetCutOffInsert( ScChangeActionIns* p, short n ) + { pCutOff = p; nCutOff = n; } // only to use in the XML import + // this should be protected, but for the XML import it is public + // only to use in the XML import + // this should be protected, but for the XML import it is public + ScChangeActionDelMoveEntry* AddCutOffMove( + ScChangeActionMove* pMove, short nFrom, short nTo ); +}; + +// ScChangeActionMove +class ScChangeActionMove final : public ScChangeAction +{ + friend class ScChangeTrack; + friend struct std::default_delete<ScChangeActionMove>; // for std::unique_ptr + friend class ScChangeActionDel; + + ScBigRange aFromRange; + ScChangeTrack* pTrack; + std::vector<ScChangeActionContent*> mvCells; + sal_uLong nStartLastCut; // for PasteCut undo + sal_uLong nEndLastCut; + + ScChangeActionMove( const ScRange& rFromRange, + const ScRange& rToRange, + ScChangeTrack* pTrackP ) + : ScChangeAction( SC_CAT_MOVE, rToRange ), + aFromRange( rFromRange ), + pTrack( pTrackP ), + nStartLastCut(0), + nEndLastCut(0) + {} + virtual ~ScChangeActionMove() override; + + virtual void AddContent( ScChangeActionContent* ) override; + virtual void DeleteCellEntries() override; + + ScBigRange& GetFromRange() { return aFromRange; } + + void SetStartLastCut( sal_uLong nVal ) { nStartLastCut = nVal; } + sal_uLong GetStartLastCut() const { return nStartLastCut; } + void SetEndLastCut( sal_uLong nVal ) { nEndLastCut = nVal; } + sal_uLong GetEndLastCut() const { return nEndLastCut; } + + virtual void UpdateReference( const ScChangeTrack*, + UpdateRefMode, const ScBigRange&, + sal_Int32 nDx, sal_Int32 nDy, sal_Int32 nDz ) override; + + virtual bool Reject(ScDocument& rDoc) override; + + virtual const ScChangeTrack* GetChangeTrack() const override { return pTrack; } + +protected: + using ScChangeAction::GetRefString; + +public: + ScChangeActionMove(const sal_uLong nActionNumber, + const ScChangeActionState eState, + const sal_uLong nRejectingNumber, + const ScBigRange& aToBigRange, + const OUString& aUser, + const DateTime& aDateTime, + const OUString &sComment, + ScBigRange aFromBigRange, + ScChangeTrack* pTrack); // only to use in the XML import + + const ScBigRange& GetFromRange() const { return aFromRange; } + SC_DLLPUBLIC void GetDelta( sal_Int32& nDx, sal_Int32& nDy, sal_Int32& nDz ) const; + + virtual OUString GetDescription( + ScDocument& rDoc, bool bSplitRange = false, bool bWarning = true ) const override; + + virtual OUString GetRefString( ScDocument& rDoc, bool bFlag3D = false ) const override; +}; + +ScChangeActionDelMoveEntry::ScChangeActionDelMoveEntry( + ScChangeActionDelMoveEntry** ppPrevP, + ScChangeActionMove* pMove, + short nFrom, short nTo ) + : ScChangeActionLinkEntry( + reinterpret_cast<ScChangeActionLinkEntry**>( + ppPrevP), + static_cast<ScChangeAction*>(pMove) ), + nCutOffFrom( nFrom ), + nCutOffTo( nTo ) +{} + +inline ScChangeActionMove* ScChangeActionDelMoveEntry::GetMove() + { + return static_cast<ScChangeActionMove*>( + ScChangeActionLinkEntry::GetAction()); + } + +inline const ScChangeActionMove* ScChangeActionDelMoveEntry::GetMove() const + { + return static_cast<const ScChangeActionMove*>( + ScChangeActionLinkEntry::GetAction()); + } +// ScChangeActionContent +enum ScChangeActionContentCellType +{ + SC_CACCT_NONE = 0, + SC_CACCT_NORMAL, + SC_CACCT_MATORG, + SC_CACCT_MATREF +}; + +class SAL_DLLPUBLIC_RTTI ScChangeActionContent final : public ScChangeAction +{ + friend class ScChangeTrack; + + ScCellValue maOldCell; + ScCellValue maNewCell; + + OUString maOldValue; + OUString maNewValue; + ScChangeActionContent* pNextContent; // at the same position + ScChangeActionContent* pPrevContent; + ScChangeActionContent* pNextInSlot; // in the same slot + ScChangeActionContent** ppPrevInSlot; + + void InsertInSlot( ScChangeActionContent** pp ) + { + if ( !ppPrevInSlot ) + { + ppPrevInSlot = pp; + if ( ( pNextInSlot = *pp ) != nullptr ) + pNextInSlot->ppPrevInSlot = &pNextInSlot; + *pp = this; + } + } + + void RemoveFromSlot() + { + if ( ppPrevInSlot ) + { + if ( ( *ppPrevInSlot = pNextInSlot ) != nullptr ) + pNextInSlot->ppPrevInSlot = ppPrevInSlot; + ppPrevInSlot = nullptr; // not inserted + } + } + + ScChangeActionContent* GetNextInSlot() { return pNextInSlot; } + + void ClearTrack(); + + static OUString GetStringOfCell( + const ScCellValue& rCell, const ScDocument* pDoc, const ScAddress& rPos ); + + static OUString GetStringOfCell( + const ScCellValue& rCell, const ScDocument* pDoc, sal_uLong nFormat ); + + static void SetValue( OUString& rStr, ScCellValue& rCell, const ScAddress& rPos, + const ScCellValue& rOrgCell, const ScDocument* pFromDoc, + ScDocument* pToDoc ); + + static void SetValue( OUString& rStr, ScCellValue& rCell, sal_uLong nFormat, + const ScCellValue& rOrgCell, const ScDocument* pFromDoc, + ScDocument* pToDoc ); + + static void SetCell( OUString& rStr, ScCellValue& rCell, sal_uLong nFormat, const ScDocument* pDoc ); + + static bool NeedsNumberFormat( const ScCellValue& rVal ); + + void SetValueString( OUString& rValue, ScCellValue& rCell, const OUString& rStr, ScDocument* pDoc ); + + OUString GetValueString( const OUString& rValue, const ScCellValue& rCell, + const ScDocument* pDoc ) const; + + OUString GetFormulaString( const ScFormulaCell* pCell ) const; + + virtual void AddContent( ScChangeActionContent* ) override {} + virtual void DeleteCellEntries() override {} + + virtual void UpdateReference( const ScChangeTrack*, + UpdateRefMode, const ScBigRange&, + sal_Int32 nDx, sal_Int32 nDy, sal_Int32 nDz ) override; + + virtual bool Reject(ScDocument& rDoc) override; + + virtual const ScChangeTrack* GetChangeTrack() const override { return nullptr; } + + // pRejectActions!=NULL: reject actions get + // stacked, no SetNewValue, no Append + bool Select( ScDocument&, ScChangeTrack*, + bool bOldest, ::std::stack<ScChangeActionContent*>* pRejectActions ); + + void PutValueToDoc( + const ScCellValue& rCell, const OUString& rValue, ScDocument* pDoc, SCCOL nDx, SCROW nDy ) const; + +protected: + using ScChangeAction::GetRefString; + +public: + ScChangeActionContent( const ScRange& rRange ); + + ScChangeActionContent( + const sal_uLong nActionNumber, const ScChangeActionState eState, + const sal_uLong nRejectingNumber, const ScBigRange& aBigRange, + const OUString& aUser, const DateTime& aDateTime, + const OUString &sComment, ScCellValue aOldCell, + const ScDocument* pDoc, const OUString& sOldValue ); // to use for XML Import + + ScChangeActionContent( + const sal_uLong nActionNumber, ScCellValue aNewCell, + const ScBigRange& aBigRange, const ScDocument* pDoc, + const OUString& sNewValue ); // to use for XML Import of Generated Actions + + virtual ~ScChangeActionContent() override; + + ScChangeActionContent* GetNextContent() const { return pNextContent; } + ScChangeActionContent* GetPrevContent() const { return pPrevContent; } + ScChangeActionContent* GetTopContent() const; + bool IsTopContent() const { return pNextContent == nullptr; } + + virtual ScChangeActionLinkEntry* GetDeletedIn() const override; + virtual ScChangeActionLinkEntry** GetDeletedInAddress() override; + + void PutOldValueToDoc( ScDocument*, + SCCOL nDx, SCROW nDy ) const; + void PutNewValueToDoc( ScDocument*, + SCCOL nDx, SCROW nDy ) const; + + void SetOldValue( const ScCellValue& rCell, const ScDocument* pFromDoc, ScDocument* pToDoc, sal_uLong nFormat ); + + void SetOldValue( const ScCellValue& rCell, const ScDocument* pFromDoc, ScDocument* pToDoc ); + + void SetNewValue( const ScCellValue& rCell, ScDocument* pDoc ); + + // Used in import filter AppendContentOnTheFly, + void SetOldNewCells( + const ScCellValue& rOldCell, sal_uLong nOldFormat, + const ScCellValue& rNewCell, sal_uLong nNewFormat, const ScDocument* pDoc ); + + // Use this only in the XML import, + // takes ownership of cell. + void SetNewCell( + const ScCellValue& rCell, const ScDocument* pDoc, const OUString& rFormatted ); + + // These functions should be protected but for + // the XML import they are public. + void SetNextContent( ScChangeActionContent* p ) + { pNextContent = p; } + void SetPrevContent( ScChangeActionContent* p ) + { pPrevContent = p; } + + // don't use: + // assigns string / creates formula cell + void SetOldValue( const OUString& rOld, ScDocument* pDoc ); + + OUString GetOldString( const ScDocument* pDoc ) const; + OUString GetNewString( const ScDocument* pDoc ) const; + const ScCellValue& GetOldCell() const { return maOldCell;} + const ScCellValue& GetNewCell() const { return maNewCell;} + virtual OUString GetDescription( + ScDocument& rDoc, bool bSplitRange = false, bool bWarning = true ) const override; + + virtual OUString GetRefString( ScDocument& rDoc, bool bFlag3D = false ) const override; + + static ScChangeActionContentCellType GetContentCellType( const ScCellValue& rCell ); + static ScChangeActionContentCellType GetContentCellType( const ScRefCellValue& rIter ); + + // NewCell + bool IsMatrixOrigin() const; + // OldCell + bool IsOldMatrixReference() const; +}; + +// ScChangeActionReject +class ScChangeActionReject final : public ScChangeAction +{ + friend class ScChangeTrack; + friend class ScChangeActionContent; + + virtual void AddContent( ScChangeActionContent* ) override {} + virtual void DeleteCellEntries() override {} + + virtual bool Reject(ScDocument& rDoc) override; + + virtual const ScChangeTrack* GetChangeTrack() const override { return nullptr; } + +public: + ScChangeActionReject(const sal_uLong nActionNumber, + const ScChangeActionState eState, + const sal_uLong nRejectingNumber, + const ScBigRange& aBigRange, + const OUString& aUser, + const DateTime& aDateTime, + const OUString &sComment); // only to use in the XML import +}; + +// ScChangeTrack +enum class ScChangeTrackMsgType +{ + NONE, + Append, // Actions appended + Remove, // Actions removed + Change, // Actions changed + Parent // became a parent (and wasn't before) +}; + +struct ScChangeTrackMsgInfo +{ + ScChangeTrackMsgType eMsgType; + sal_uLong nStartAction; + sal_uLong nEndAction; +}; + +// MsgQueue for notification via ModifiedLink +typedef std::vector<ScChangeTrackMsgInfo> ScChangeTrackMsgQueue; +typedef std::vector<ScChangeTrackMsgInfo> ScChangeTrackMsgStack; +typedef std::map<sal_uLong, ScChangeAction*> ScChangeActionMap; + +enum ScChangeTrackMergeState +{ + SC_CTMS_NONE, + SC_CTMS_PREPARE, + SC_CTMS_OWN, + SC_CTMS_UNDO, + SC_CTMS_OTHER +}; + +// Internally generated actions start at this value (nearly all bits set) +// and are decremented, to keep values in a table separated from "normal" actions. +#define SC_CHGTRACK_GENERATED_START (sal_uInt32(0xfffffff0)) + +class SAL_DLLPUBLIC_RTTI ScChangeTrack final : public utl::ConfigurationListener +{ + friend void ScChangeAction::RejectRestoreContents( ScChangeTrack*, SCCOL, SCROW ); + friend bool ScChangeActionDel::Reject( ScDocument& pDoc ); + friend void ScChangeActionDel::DeleteCellEntries(); + friend void ScChangeActionMove::DeleteCellEntries(); + friend bool ScChangeActionMove::Reject( ScDocument& pDoc ); + + SCROW mnContentRowsPerSlot; + SCSIZE mnContentSlots; + + css::uno::Sequence< sal_Int8 > aProtectPass; + ScChangeActionMap aMap; + ScChangeActionMap aGeneratedMap; + ScChangeActionMap aPasteCutMap; + ScChangeTrackMsgQueue aMsgQueue; + ScChangeTrackMsgStack aMsgStackTmp; + ScChangeTrackMsgStack aMsgStackFinal; + std::set<OUString> maUserCollection; + OUString maUser; + Link<ScChangeTrack&,void> aModifiedLink; + ScRange aInDeleteRange; + DateTime aFixDateTime; + ScChangeAction* pFirst; + ScChangeAction* pLast; + ScChangeActionContent* pFirstGeneratedDelContent; + std::unique_ptr<ScChangeActionContent*[]> ppContentSlots; + std::unique_ptr<ScChangeActionMove> pLastCutMove; + ScChangeActionLinkEntry* pLinkInsertCol; + ScChangeActionLinkEntry* pLinkInsertRow; + ScChangeActionLinkEntry* pLinkInsertTab; + ScChangeActionLinkEntry* pLinkMove; + std::optional<ScChangeTrackMsgInfo> xBlockModifyMsg; + ScDocument& rDoc; + sal_uLong nActionMax; + sal_uLong nGeneratedMin; + sal_uLong nMarkLastSaved; + sal_uLong nStartLastCut; + sal_uLong nEndLastCut; + sal_uLong nLastMerge; + ScChangeTrackMergeState eMergeState; + bool bInDelete:1; + bool bInDeleteUndo:1; + bool bInDeleteTop:1; + bool bInPasteCut:1; + bool bUseFixDateTime:1; + bool bTimeNanoSeconds:1; + + ScChangeTrack( const ScChangeTrack& ) = delete; + ScChangeTrack& operator=( const ScChangeTrack& ) = delete; + + SCROW InitContentRowsPerSlot(); + + // true if one is ScMatrixMode::Formula and the other is + // not, or if both are and range differs + static bool IsMatrixFormulaRangeDifferent( + const ScCellValue& rOldCell, const ScCellValue& rNewCell ); + + void Init(); + void DtorClear(); + void SetInDeleteRange( const ScRange& rRange ) + { aInDeleteRange = rRange; } + void SetInDelete( bool bVal ) + { bInDelete = bVal; } + void SetInDeleteTop( bool bVal ) + { bInDeleteTop = bVal; } + void SetInDeleteUndo( bool bVal ) + { bInDeleteUndo = bVal; } + void SetInPasteCut( bool bVal ) + { bInPasteCut = bVal; } + void SetMergeState( ScChangeTrackMergeState eState ) + { eMergeState = eState; } + ScChangeTrackMergeState GetMergeState() const { return eMergeState; } + void SetLastMerge( sal_uLong nVal ) { nLastMerge = nVal; } + sal_uLong GetLastMerge() const { return nLastMerge; } + + void SetLastCutMoveRange( const ScRange&, ScDocument* ); + + // create block of ModifyMsg + void StartBlockModify( ScChangeTrackMsgType, + sal_uLong nStartAction ); + void EndBlockModify( sal_uLong nEndAction ); + + void AddDependentWithNotify( ScChangeAction* pParent, + ScChangeAction* pDependent ); + + void Dependencies( ScChangeAction* ); + void UpdateReference( ScChangeAction*, bool bUndo ); + void UpdateReference( ScChangeAction** ppFirstAction, ScChangeAction* pAct, bool bUndo ); + void Append( ScChangeAction* pAppend, sal_uLong nAction ); + SC_DLLPUBLIC void AppendDeleteRange( const ScRange&, + ScDocument* pRefDoc, SCTAB nDz, + sal_uLong nRejectingInsert ); + void AppendOneDeleteRange( const ScRange& rOrgRange, + ScDocument* pRefDoc, + SCCOL nDx, SCROW nDy, SCTAB nDz, + sal_uLong nRejectingInsert ); + void LookUpContents( const ScRange& rOrgRange, + ScDocument* pRefDoc, + SCCOL nDx, SCROW nDy, SCTAB nDz ); + void Remove( ScChangeAction* ); + void MasterLinks( ScChangeAction* ); + + // Content on top at Position + ScChangeActionContent* SearchContentAt( const ScBigAddress&, + const ScChangeAction* pButNotThis ) const; + void DeleteGeneratedDelContent( + ScChangeActionContent* ); + + ScChangeActionContent* GenerateDelContent( + const ScAddress& rPos, const ScCellValue& rCell, const ScDocument* pFromDoc ); + + void DeleteCellEntries( + std::vector<ScChangeActionContent*>&, + const ScChangeAction* pDeletor ); + + // Reject action and all dependent actions, + // Table stems from previous GetDependents, + // only needed for Insert and Move (MasterType), + // is NULL otherwise. + // bRecursion == called from reject with table + bool Reject( ScChangeAction*, ScChangeActionMap*, bool bRecursion ); + + bool IsLastAction( sal_uLong nNum ) const; + + void ClearMsgQueue(); + virtual void ConfigurationChanged( utl::ConfigurationBroadcaster*, ConfigurationHints ) override; + +public: + + SCSIZE ComputeContentSlot( sal_Int32 nRow ) const; + + SC_DLLPUBLIC ScChangeTrack( ScDocument& ); + ScChangeTrack(ScDocument& rDocP, std::set<OUString>&& aTempUserCollection); // only to use in the XML import + SC_DLLPUBLIC virtual ~ScChangeTrack() override; + void Clear(); + + ScChangeActionContent* GetFirstGenerated() const { return pFirstGeneratedDelContent; } + ScChangeAction* GetFirst() const { return pFirst; } + ScChangeAction* GetLast() const { return pLast; } + sal_uLong GetActionMax() const { return nActionMax; } + bool IsGenerated( sal_uLong nAction ) const; + SC_DLLPUBLIC ScChangeAction* GetAction( sal_uLong nAction ) const; + ScChangeAction* GetGenerated( sal_uLong nGenerated ) const; + ScChangeAction* GetActionOrGenerated( sal_uLong nAction ) const; + sal_uLong GetLastSavedActionNumber() const; + void SetLastSavedActionNumber(sal_uLong nNew); + ScChangeAction* GetLastSaved() const; + ScChangeActionContent** GetContentSlots() const { return ppContentSlots.get(); } + + const ScRange& GetInDeleteRange() const + { return aInDeleteRange; } + bool IsInDelete() const { return bInDelete; } + bool IsInDeleteTop() const { return bInDeleteTop; } + bool IsInDeleteUndo() const { return bInDeleteUndo; } + bool IsInPasteCut() const { return bInPasteCut; } + void CreateAuthorName(); + SC_DLLPUBLIC void SetUser( const OUString& rUser ); + const OUString& GetUser() const { return maUser;} + const std::set<OUString>& GetUserCollection() const { return maUserCollection;} + ScDocument& GetDocument() const { return rDoc; } + // for import filter + const DateTime& GetFixDateTime() const { return aFixDateTime; } + + // set this if the date/time set with + // SetFixDateTime...() shall be applied to + // appended actions + void SetUseFixDateTime( bool bVal ) + { bUseFixDateTime = bVal; } + // for MergeDocument, apply original date/time as UTC + void SetFixDateTimeUTC( const DateTime& rDT ) + { aFixDateTime = rDT; } + // for import filter, apply original date/time as local time + void SetFixDateTimeLocal( const DateTime& rDT ) + { aFixDateTime = rDT; aFixDateTime.ConvertToUTC(); } + + void Append( ScChangeAction* ); + + // pRefDoc may be NULL => no lookup of contents + // => no generation of deleted contents + SC_DLLPUBLIC void AppendDeleteRange( const ScRange&, + ScDocument* pRefDoc, + sal_uLong& nStartAction, sal_uLong& nEndAction, + SCTAB nDz = 0 ); + // nDz: multi TabDel, LookUpContent must be searched + // with an offset of -nDz + + // after new value was set in the document, + // old value from RefDoc/UndoDoc + void AppendContent( const ScAddress& rPos, + const ScDocument* pRefDoc ); + // after new values were set in the document, + // old values from RefDoc/UndoDoc + void AppendContentRange( const ScRange& rRange, + ScDocument* pRefDoc, + sal_uLong& nStartAction, sal_uLong& nEndAction, + ScChangeActionClipMode eMode = SC_CACM_NONE ); + // after new value was set in the document, + // old value from pOldCell, nOldFormat, + // RefDoc==NULL => Doc + void AppendContent( const ScAddress& rPos, const ScCellValue& rOldCell, + sal_uLong nOldFormat, ScDocument* pRefDoc = nullptr ); + // after new value was set in the document, + // old value from pOldCell, format from Doc + SC_DLLPUBLIC void AppendContent( const ScAddress& rPos, const ScCellValue& rOldCell ); + // after new values were set in the document, + // old values from RefDoc/UndoDoc. + // All contents with a cell in RefDoc + void AppendContentsIfInRefDoc( ScDocument& rRefDoc, + sal_uLong& nStartAction, sal_uLong& nEndAction ); + + // Meant for import filter, creates and inserts + // an unconditional content action of the two + // cells without querying the document, not + // even for number formats (though the number + // formatter of the document may be used). + // The action is returned and may be used to + // set user name, description, date/time et al. + // Takes ownership of the cells! + SC_DLLPUBLIC ScChangeActionContent* AppendContentOnTheFly( + const ScAddress& rPos, const ScCellValue& rOldCell, const ScCellValue& rNewCell, + sal_uLong nOldFormat = 0, sal_uLong nNewFormat = 0 ); + + // Only use the following two if there is no different solution! (Assign + // string for NewValue or creation of a formula respectively) + + SC_DLLPUBLIC void AppendInsert( const ScRange& rRange, bool bEndOfList = false ); + + // pRefDoc may be NULL => no lookup of contents + // => no generation of deleted contents + SC_DLLPUBLIC void AppendMove( const ScRange& rFromRange, const ScRange& rToRange, + ScDocument* pRefDoc ); + + // Cut to Clipboard + void ResetLastCut() + { + nStartLastCut = nEndLastCut = 0; + pLastCutMove.reset(); + } + bool HasLastCut() const + { + return nEndLastCut > 0 && + nStartLastCut <= nEndLastCut && + pLastCutMove; + } + + SC_DLLPUBLIC void Undo( sal_uLong nStartAction, sal_uLong nEndAction, bool bMerge = false ); + + // adjust references for MergeDocument + //! may only be used in a temporary opened document. + //! the Track (?) is unclean afterwards + void MergePrepare( const ScChangeAction* pFirstMerge, bool bShared ); + void MergeOwn( ScChangeAction* pAct, sal_uLong nFirstMerge, bool bShared ); + static bool MergeIgnore( const ScChangeAction&, sal_uLong nFirstMerge ); + + // This comment was already really strange in German. + // Tried to structure it a little. Hope no information got lost... + // + // Insert dependents into table. + // ScChangeAction is + // - "Insert": really dependents + // - "Move": dependent contents in FromRange / + // deleted contents in ToRange + // OR inserts in FromRange or ToRange + // - "Delete": a list of deleted (what?) + // OR for content, different contents at the same position + // OR MatrixReferences belonging to MatrixOrigin + + // With bListMasterDelete (==TRUE ?) all Deletes of a row belonging + // to a MasterDelete are listed (possibly it is + // "all Deletes belonging...are listed in a row?) + + // With bAllFlat (==TRUE ?) all dependents of dependents + // will be inserted flatly. + + SC_DLLPUBLIC void GetDependents( + ScChangeAction*, ScChangeActionMap&, bool bListMasterDelete = false, bool bAllFlat = false ) const; + + // Reject visible action (and dependents) + bool Reject( ScChangeAction*, bool bShared = false ); + + // Accept visible action (and dependents) + SC_DLLPUBLIC bool Accept( ScChangeAction* ); + + void AcceptAll(); // all Virgins + bool RejectAll(); // all Virgins + + // Selects a content of several contents at the same + // position and accepts this one and + // the older ones, rejects the more recent ones. + // If bOldest==TRUE then the first OldValue + // of a Virgin-Content-List will be restored. + bool SelectContent( ScChangeAction*, bool bOldest = false ); + + // If ModifiedLink is set, changes go to + // ScChangeTrackMsgQueue + void SetModifiedLink( const Link<ScChangeTrack&,void>& r ) + { aModifiedLink = r; ClearMsgQueue(); } + ScChangeTrackMsgQueue& GetMsgQueue(); + + void NotifyModified( ScChangeTrackMsgType eMsgType, + sal_uLong nStartAction, sal_uLong nEndAction ); + + sal_uLong AddLoadedGenerated( const ScCellValue& rNewCell, + const ScBigRange& aBigRange, const OUString& sNewValue ); // only to use in the XML import + void AppendLoaded( std::unique_ptr<ScChangeAction> pAppend ); // this is only for the XML import public, it should be protected + void SetActionMax(sal_uLong nTempActionMax) + { nActionMax = nTempActionMax; } // only to use in the XML import + + void SetProtection( const css::uno::Sequence< sal_Int8 >& rPass ) + { aProtectPass = rPass; } + const css::uno::Sequence< sal_Int8 >& GetProtection() const + { return aProtectPass; } + bool IsProtected() const { return aProtectPass.hasElements(); } + + // If time stamps of actions of this + // ChangeTrack and a second one are to be + // compared including nanoseconds. + void SetTimeNanoSeconds( bool bVal ) { bTimeNanoSeconds = bVal; } + bool IsTimeNanoSeconds() const { return bTimeNanoSeconds; } + + void AppendCloned( ScChangeAction* pAppend ); + SC_DLLPUBLIC ScChangeTrack* Clone( ScDocument* pDocument ) const; + static void MergeActionState( ScChangeAction* pAct, const ScChangeAction* pOtherAct ); + /// Get info about all ScChangeAction elements. + void GetChangeTrackInfo(tools::JsonWriter&); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/chgviset.hxx b/sc/inc/chgviset.hxx new file mode 100644 index 0000000000..88f817b970 --- /dev/null +++ b/sc/inc/chgviset.hxx @@ -0,0 +1,129 @@ +/* -*- 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 <memory> +#include <tools/datetime.hxx> +#include <tools/solar.h> +#include <unotools/textsearch.hxx> +#include <svx/ctredlin.hxx> +#include "rangelst.hxx" +#include "scdllapi.h" + +class ScDocument; + +class SC_DLLPUBLIC ScChangeViewSettings +{ +private: + + std::unique_ptr<utl::TextSearch> + pCommentSearcher; + DateTime aFirstDateTime; + DateTime aLastDateTime; + OUString aAuthorToShow; + OUString aComment; + ScRangeList aRangeList; + SvxRedlinDateMode eDateMode; + bool bShowIt; + bool bIsDate; + bool bIsAuthor; + bool bIsComment; + bool bIsRange; + bool bShowAccepted; + bool bShowRejected; + bool mbIsActionRange; + sal_uLong mnFirstAction; + sal_uLong mnLastAction; + +public: + + ScChangeViewSettings() + : aFirstDateTime(DateTime::EMPTY) + , aLastDateTime(DateTime::EMPTY) + , eDateMode(SvxRedlinDateMode::BEFORE) + , bShowIt(false) + , bIsDate(false) + , bIsAuthor(false) + , bIsComment(false) + , bIsRange(false) + , bShowAccepted(false) + , bShowRejected(false) + , mbIsActionRange(false) + , mnFirstAction(0) + , mnLastAction(0) + { + } + + ScChangeViewSettings( const ScChangeViewSettings& r ); + + ~ScChangeViewSettings(); + + bool ShowChanges() const {return bShowIt;} + void SetShowChanges(bool bFlag) {bShowIt=bFlag;} + + bool HasDate() const {return bIsDate;} + void SetHasDate(bool bFlag) {bIsDate=bFlag;} + + void SetTheDateMode(SvxRedlinDateMode eDatMod){ eDateMode=eDatMod; } + SvxRedlinDateMode GetTheDateMode() const { return eDateMode; } + + void SetTheFirstDateTime(const DateTime& aDateTime) {aFirstDateTime=aDateTime;} + const DateTime& GetTheFirstDateTime()const {return aFirstDateTime;} + + void SetTheLastDateTime(const DateTime& aDateTime) {aLastDateTime=aDateTime;} + const DateTime& GetTheLastDateTime()const {return aLastDateTime;} + + bool HasAuthor() const {return bIsAuthor;} + void SetHasAuthor(bool bFlag) {bIsAuthor=bFlag;} + + const OUString& GetTheAuthorToShow()const {return aAuthorToShow;} + void SetTheAuthorToShow(const OUString& aString){aAuthorToShow=aString;} + + bool HasComment() const {return bIsComment;} + void SetHasComment(bool bFlag) {bIsComment=bFlag;} + + const OUString& GetTheComment()const {return aComment;} + void SetTheComment(const OUString& aString); + + bool IsValidComment(const OUString* pCommentStr) const; + + bool HasRange() const {return bIsRange;} + void SetHasRange(bool bFlag) {bIsRange=bFlag;} + + const ScRangeList& GetTheRangeList()const {return aRangeList;} + void SetTheRangeList(const ScRangeList& aRl){aRangeList=aRl;} + + bool IsShowAccepted() const { return bShowAccepted; } + void SetShowAccepted( bool bVal ) { bShowAccepted = bVal; } + + bool IsShowRejected() const { return bShowRejected; } + void SetShowRejected( bool bVal ) { bShowRejected = bVal; } + + ScChangeViewSettings& operator= ( const ScChangeViewSettings& r ); + + /// Adjust dates according to selected DateMode + void AdjustDateMode( const ScDocument& rDoc ); + + bool HasActionRange() const { return mbIsActionRange; } + void SetHasActionRange() { mbIsActionRange = true; } + void GetTheActionRange( sal_uLong& nFirst, sal_uLong& nLast ) const { nFirst = mnFirstAction; nLast = mnLastAction; } + void SetTheActionRange( sal_uLong nFirst, sal_uLong nLast ) { mnFirstAction = nFirst; mnLastAction = nLast; } +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/clipcontext.hxx b/sc/inc/clipcontext.hxx new file mode 100644 index 0000000000..b3ce874a6a --- /dev/null +++ b/sc/inc/clipcontext.hxx @@ -0,0 +1,193 @@ +/* -*- 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/. + */ + +#pragma once + +#include "address.hxx" +#include "cellvalue.hxx" +#include "celltextattr.hxx" +#include "columnspanset.hxx" +#include "Sparkline.hxx" + +#include <memory> +#include <vector> + +class ScDocument; +class ScColumn; +class ScPatternAttr; +class ScPostIt; +class ScConditionalFormatList; + +namespace sc { + +struct ColumnBlockPosition; +class ColumnBlockPositionSet; + +class ClipContextBase +{ + std::unique_ptr<ColumnBlockPositionSet> mpSet; + +public: + ClipContextBase() = delete; + ClipContextBase(const ClipContextBase&) = delete; + const ClipContextBase& operator=(const ClipContextBase&) = delete; + ClipContextBase(ScDocument& rDoc); + virtual ~ClipContextBase(); + + ColumnBlockPosition* getBlockPosition(SCTAB nTab, SCCOL nCol); + ColumnBlockPositionSet* getBlockPositionSet() { return mpSet.get(); } +}; + +class SC_DLLPUBLIC CopyFromClipContext final : public ClipContextBase +{ + /** Tracks modified formula group spans. */ + sc::ColumnSpanSet maListeningFormulaSpans; + + SCCOL mnDestCol1; + SCCOL mnDestCol2; + SCROW mnDestRow1; + SCROW mnDestRow2; + SCTAB mnTabStart; + SCTAB mnTabEnd; + ScDocument& mrDestDoc; + ScDocument* mpRefUndoDoc; + ScDocument* mpClipDoc; + InsertDeleteFlags mnInsertFlag; + InsertDeleteFlags mnDeleteFlag; + + std::vector<ScCellValue> maSingleCells; + std::vector<sc::CellTextAttr> maSingleCellAttrs; + std::vector<const ScPatternAttr*> maSinglePatterns; + std::vector<const ScPostIt*> maSingleNotes; + std::vector<std::shared_ptr<sc::Sparkline>> maSingleSparkline; + + ScConditionalFormatList* mpCondFormatList; + bool mbAsLink:1; + bool mbSkipEmptyCells:1; + bool mbTableProtected:1; + +public: + + struct Range + { + SCCOL mnCol1; + SCCOL mnCol2; + SCROW mnRow1; + SCROW mnRow2; + }; + + CopyFromClipContext() = delete; + CopyFromClipContext(ScDocument& rDoc, + ScDocument* pRefUndoDoc, ScDocument* pClipDoc, InsertDeleteFlags nInsertFlag, + bool bAsLink, bool bSkipAttrForEmptyCells); + + virtual ~CopyFromClipContext() override; + + void setTabRange(SCTAB nStart, SCTAB nEnd); + + SCTAB getTabStart() const; + SCTAB getTabEnd() const; + + void setDestRange( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ); + Range getDestRange() const; + + ScDocument* getUndoDoc(); + ScDocument* getClipDoc(); + ScDocument* getDestDoc() { return &mrDestDoc; } + InsertDeleteFlags getInsertFlag() const; + + void setDeleteFlag( InsertDeleteFlags nFlag ); + InsertDeleteFlags getDeleteFlag() const; + + /** + * Record a range of formula cells that need to start listening after the + * copy-from-clip is complete. + */ + void setListeningFormulaSpans( SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ); + + /** + * Have the formula cells in the recorded ranges start listening. + */ + void startListeningFormulas(); + + /** + * Set the column size of a "single cell" row, which is used when copying + * a single row of cells in a clip doc and pasting it into multiple + * rows by replicating it. + */ + void setSingleCellColumnSize( size_t nSize ); + + ScCellValue& getSingleCell( size_t nColOffset ); + sc::CellTextAttr& getSingleCellAttr( size_t nColOffset ); + + void setSingleCell( const ScAddress& rSrcPos, const ScColumn& rSrcCol ); + + + const ScPatternAttr* getSingleCellPattern( size_t nColOffset ) const; + void setSingleCellPattern( size_t nColOffset, const ScPatternAttr* pAttr ); + + const ScPostIt* getSingleCellNote( size_t nColOffset ) const; + void setSingleCellNote( size_t nColOffset, const ScPostIt* pNote ); + + std::shared_ptr<sc::Sparkline> const& getSingleSparkline(size_t nColOffset) const; + void setSingleSparkline(size_t nColOffset, std::shared_ptr<sc::Sparkline> const& pSparkline); + + void setCondFormatList( ScConditionalFormatList* pCondFormatList ); + ScConditionalFormatList* getCondFormatList(); + + void setTableProtected( bool b ); + bool isTableProtected() const; + + bool isAsLink() const; + + /** + * Get the flag that indicates whether the "skip empty cells" paste option + * is selected. When this option is selected, empty cells in the clipboard + * document will not overwrite the corresponding non-empty cells in the + * destination range. + */ + bool isSkipEmptyCells() const; + bool isCloneNotes() const; + bool isCloneSparklines() const; + bool isDateCell( const ScColumn& rCol, SCROW nRow ) const; +}; + +class CopyToClipContext final : public ClipContextBase +{ + bool mbKeepScenarioFlags:1; + +public: + CopyToClipContext(ScDocument& rDoc, bool bKeepScenarioFlags); + virtual ~CopyToClipContext() override; + + bool isKeepScenarioFlags() const; +}; + +class CopyToDocContext final : public ClipContextBase +{ + bool mbStartListening; + +public: + CopyToDocContext(ScDocument& rDoc); + virtual ~CopyToDocContext() override; + + void setStartListening( bool b ); + bool isStartListening() const; +}; + +class MixDocContext final : public ClipContextBase +{ +public: + MixDocContext(ScDocument& rDoc); + virtual ~MixDocContext() override; +}; + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/clipoptions.hxx b/sc/inc/clipoptions.hxx new file mode 100644 index 0000000000..bb00e4c04b --- /dev/null +++ b/sc/inc/clipoptions.hxx @@ -0,0 +1,28 @@ +/* -*- 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/. + */ + +#pragma once + +#include "scdllapi.h" +#include <com/sun/star/uno/Reference.h> + +namespace com::sun::star::document +{ +class XDocumentProperties; +} + +/// Stores options which are only relevant for clipboard documents. +class SC_DLLPUBLIC ScClipOptions +{ +public: + /// Document properties. + css::uno::Reference<css::document::XDocumentProperties> m_xDocumentProperties; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/clipparam.hxx b/sc/inc/clipparam.hxx new file mode 100644 index 0000000000..4487e77093 --- /dev/null +++ b/sc/inc/clipparam.hxx @@ -0,0 +1,81 @@ +/* -*- 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 "rangelst.hxx" +#include "charthelper.hxx" +#include "document.hxx" + +/** + * This struct stores general clipboard parameters associated with a + * ScDocument instance created in clipboard mode. + */ +struct SC_DLLPUBLIC ScClipParam +{ + enum Direction { Unspecified, Column, Row }; + + ScRangeList maRanges; + Direction meDirection; + bool mbCutMode; + sal_uInt32 mnSourceDocID; + ScRangeListVector maProtectedChartRangesVector; + /** Was this clip transposed? */ + bool mbTransposed = false; + + ScClipParam(); + ScClipParam(const ScRange& rRange, bool bCutMode); + + bool isMultiRange() const; + + /** + * Get the column size of a pasted range. Note that when the range is + * non-contiguous, we first compress all individual ranges into a single + * range, and the size of that compressed range is returned. + */ + SCCOL getPasteColSize(); + + /** + * Same as the above method, but returns the row size of the compressed + * range. + */ + SCROW getPasteRowSize(const ScDocument& rSrcDoc, bool bIncludeFiltered); + + /** + * Return a single range that encompasses all individual ranges. + */ + ScRange getWholeRange() const; + + /** + * Transpose the clip parameters. + * Filtered rows are removed from parameters. + */ + void transpose(const ScDocument& rSrcDoc, bool bIncludeFiltered, + bool bIsMultiRangeRowFilteredTranspose); + + sal_uInt32 getSourceDocID() const { return mnSourceDocID; } + void setSourceDocID( sal_uInt32 nVal ) { mnSourceDocID = nVal; } + + /** + * Was this clip transposed? + */ + bool isTransposed() const { return mbTransposed; } +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/colcontainer.hxx b/sc/inc/colcontainer.hxx new file mode 100644 index 0000000000..13455b5e2c --- /dev/null +++ b/sc/inc/colcontainer.hxx @@ -0,0 +1,80 @@ +/* -*- 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 "types.hxx" +#include "column.hxx" + +#include <memory> +#include <vector> + +class ScColContainer +{ +public: + typedef std::vector<std::unique_ptr<ScColumn, o3tl::default_delete<ScColumn>>> ScColumnVector; + + ScColContainer( ScSheetLimits const &, const size_t nSize ); + ~ScColContainer() COVERITY_NOEXCEPT_FALSE; + + const ScColumn& operator[] ( const size_t nIndex ) const + { + return *aCols[nIndex]; + } + + ScColumn& operator[] ( const size_t nIndex ) + { + return *aCols[nIndex]; + } + + SCCOL size() const + { + return static_cast<SCCOL>( aCols.size() ); + } + + bool empty() const + { + return aCols.empty(); + } + + void resize( ScSheetLimits const &, const size_t aNewSize ); + + void Clear(); + + const ScColumn& back() const + { + assert(aCols.size() > 0); + return *aCols.back(); + } + + ScColumn& back() + { + assert(aCols.size() > 0); + return *aCols.back(); + } + + ScColumnVector::const_iterator begin() const { return aCols.begin(); } + ScColumnVector::const_iterator end() const { return aCols.end(); } + +private: + ScColumnVector aCols; +}; + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/colorscale.hxx b/sc/inc/colorscale.hxx new file mode 100644 index 0000000000..6652e224fe --- /dev/null +++ b/sc/inc/colorscale.hxx @@ -0,0 +1,418 @@ +/* -*- 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/. + */ + +#pragma once + +#include <formula/grammar.hxx> +#include <tools/color.hxx> +#include "conditio.hxx" +#include "document.hxx" + +#include <memory> +#include <vector> +#include <optional> + +//TODO: merge this with conditio.hxx + +class ScFormulaCell; +class ScTokenArray; +struct ScDataBarInfo; +class BitmapEx; + +// don't change the order +// they are also used in the dialog to determine the position +// in the list box +enum ScColorScaleEntryType +{ + COLORSCALE_AUTO, + COLORSCALE_MIN, + COLORSCALE_MAX, + COLORSCALE_PERCENTILE, + COLORSCALE_VALUE, + COLORSCALE_PERCENT, + COLORSCALE_FORMULA, +}; + +class SC_DLLPUBLIC ScColorScaleEntry +{ +private: + double mnVal; + std::unique_ptr<ScFormulaCell> mpCell; + std::unique_ptr<ScFormulaListener> mpListener; + ScConditionalFormat* mpFormat; + Color maColor; + ScColorScaleEntryType meType; + + void setListener(); + +public: + ScColorScaleEntry(double nVal, const Color& rCol, ScColorScaleEntryType eType = COLORSCALE_VALUE); + ScColorScaleEntry(); + ScColorScaleEntry(const ScColorScaleEntry& rEntry); + ScColorScaleEntry(ScDocument* pDoc, const ScColorScaleEntry& rEntry); + ~ScColorScaleEntry() COVERITY_NOEXCEPT_FALSE; + + const Color& GetColor() const { return maColor;} + void SetColor(const Color&); + double GetValue() const; + void SetValue(double nValue); + void SetFormula(const OUString& rFormula, ScDocument& rDoc, const ScAddress& rAddr, + formula::FormulaGrammar::Grammar eGrammar = formula::FormulaGrammar::GRAM_DEFAULT); + + void UpdateReference( const sc::RefUpdateContext& rCxt ); + void UpdateInsertTab( const sc::RefUpdateInsertTabContext& rCxt ); + void UpdateDeleteTab( const sc::RefUpdateDeleteTabContext& rCxt ); + void UpdateMoveTab( const sc::RefUpdateMoveTabContext& rCxt ); + + const ScTokenArray* GetFormula() const; + OUString GetFormula( formula::FormulaGrammar::Grammar eGrammar ) const; + + ScColorScaleEntryType GetType() const { return meType;} + void SetType( ScColorScaleEntryType eType ); + + void SetRepaintCallback(ScConditionalFormat* pParent); + void SetRepaintCallback(const std::function<void()>& func); +}; + +namespace databar +{ + +enum ScAxisPosition +{ + NONE, + AUTOMATIC, + MIDDLE +}; + +} + +struct SC_DLLPUBLIC ScDataBarFormatData +{ + ScDataBarFormatData(): + maAxisColor(COL_BLACK), + mbGradient(true), + mbNeg(true), + meAxisPosition(databar::AUTOMATIC), + mnMinLength(0), + mnMaxLength(100), + mbOnlyBar(false), + mpUpperLimit(new ScColorScaleEntry()), + mpLowerLimit(new ScColorScaleEntry()) + {} + + ScDataBarFormatData(const ScDataBarFormatData& r): + maPositiveColor(r.maPositiveColor), + maAxisColor(r.maAxisColor), + mbGradient(r.mbGradient), + mbNeg(r.mbNeg), + meAxisPosition(r.meAxisPosition), + mnMinLength(r.mnMinLength), + mnMaxLength(r.mnMaxLength), + mbOnlyBar(r.mbOnlyBar) + { + mxNegativeColor = r.mxNegativeColor; + + if(r.mpLowerLimit) + mpLowerLimit.reset( new ScColorScaleEntry(*r.mpLowerLimit)); + else + mpLowerLimit.reset(new ScColorScaleEntry()); + if(r.mpUpperLimit) + mpUpperLimit.reset( new ScColorScaleEntry(*r.mpUpperLimit)); + else + mpUpperLimit.reset(new ScColorScaleEntry()); + } + + /** + * Color for all Positive Values and if mbNeg == false also for negative ones + */ + Color maPositiveColor; + /** + * Specifies the color for negative values. This is optional and depends on mbNeg. + * + * Default color is 0xFF0000, this value is not set + */ + std::optional<Color> mxNegativeColor; + /** + * Color of the axis if used + * Default color is black + */ + Color maAxisColor; + /** + * Paint the bars with gradient. If this is used the default is to draw with + * borders. + * + * Default is true + */ + bool mbGradient; + /** + * Use different color for negative values. Color is specified in + * mpNegativeColor and defaults to 0xFF0000 + * + * Default is true + */ + bool mbNeg; //differentiate between negative values + /** + * Paint negative values into the same direction as positive values + * If false we will set the mid point according to the upper and lower limit and negative + * values are painted to the left and positive to the right + * + * Default is false + */ + databar::ScAxisPosition meAxisPosition; + /** + * Minimal length of a databar in percent of cell length + * Value has to be in the range [0, 100) + */ + double mnMinLength; + /** + * Maximal length of a databar in percent of cell length + * Value has to be in the range (0, 100] + */ + double mnMaxLength; + + /** + * If TRUE we only show the bar and not the value + */ + bool mbOnlyBar; + + std::unique_ptr<ScColorScaleEntry, o3tl::default_delete<ScColorScaleEntry>> mpUpperLimit; + std::unique_ptr<ScColorScaleEntry, o3tl::default_delete<ScColorScaleEntry>> mpLowerLimit; +}; + +enum ScIconSetType +{ + IconSet_3Arrows, + IconSet_3ArrowsGray, + IconSet_3Flags, + IconSet_3TrafficLights1, + IconSet_3TrafficLights2, + IconSet_3Signs, + IconSet_3Symbols, + IconSet_3Symbols2, + IconSet_3Smilies, + IconSet_3Stars, + IconSet_3Triangles, + IconSet_3ColorSmilies, + IconSet_4Arrows, + IconSet_4ArrowsGray, + IconSet_4RedToBlack, + IconSet_4Rating, + IconSet_4TrafficLights, + IconSet_5Arrows, + IconSet_5ArrowsGray, + IconSet_5Ratings, + IconSet_5Quarters, + IconSet_5Boxes +}; + +struct ScIconSetMap { + const char* pName; + ScIconSetType eType; + sal_Int32 nElements; +}; + +class SC_DLLPUBLIC ScColorFormat : public ScFormatEntry +{ +public: + ScColorFormat(ScDocument* pDoc); + virtual ~ScColorFormat() override; + + const ScRangeList& GetRange() const; + void SetCache(const std::vector<double>& aValues); + std::vector<double> GetCache() const; + + virtual void SetParent(ScConditionalFormat* pParent) override; + + virtual void startRendering() override; + virtual void endRendering() override; + virtual void updateValues() override; + +protected: + std::vector<double>& getValues() const; + + double getMinValue() const; + double getMaxValue() const; + + ScConditionalFormat* mpParent; + +private: + + struct ScColorFormatCache + { + std::vector<double> maValues; + }; + mutable std::unique_ptr<ScColorFormatCache> mpCache; +}; + +typedef std::vector<std::unique_ptr<ScColorScaleEntry, o3tl::default_delete<ScColorScaleEntry>>> ScColorScaleEntries; + +class SC_DLLPUBLIC ScColorScaleFormat final : public ScColorFormat +{ +private: + ScColorScaleEntries maColorScales; + + double GetMinValue() const; + double GetMaxValue() const; + + void calcMinMax(double& nMin, double& nMax) const; + double CalcValue(double nMin, double nMax, const ScColorScaleEntries::const_iterator& rItr) const; +public: + ScColorScaleFormat(ScDocument* pDoc); + ScColorScaleFormat(ScDocument* pDoc, const ScColorScaleFormat& rFormat); + virtual ~ScColorScaleFormat() override; + virtual ScColorFormat* Clone(ScDocument* pDoc) const override; + + virtual void SetParent(ScConditionalFormat* pParent) override; + + std::optional<Color> GetColor(const ScAddress& rAddr) const; + void AddEntry(ScColorScaleEntry* pEntry); + + bool IsEqual(const ScFormatEntry& r, bool bIgnoreSrcPos) const override; + + virtual void UpdateReference( sc::RefUpdateContext& rCxt ) override; + virtual void UpdateInsertTab( sc::RefUpdateInsertTabContext& rCxt ) override; + virtual void UpdateDeleteTab( sc::RefUpdateDeleteTabContext& rCxt ) override; + virtual void UpdateMoveTab( sc::RefUpdateMoveTabContext& rCxt ) override; + + virtual Type GetType() const override; + ScColorScaleEntries::iterator begin(); + ScColorScaleEntries::const_iterator begin() const; + ScColorScaleEntries::iterator end(); + ScColorScaleEntries::const_iterator end() const; + + ScColorScaleEntry* GetEntry(size_t nPos); + const ScColorScaleEntry* GetEntry(size_t nPos) const; + + size_t size() const; + + /** + * Makes sure that the maColorScales contain at least 2 entries. + * Should be called when it is not sure that the format is valid. + */ + void EnsureSize(); +}; + +class SC_DLLPUBLIC ScDataBarFormat final : public ScColorFormat +{ +public: + ScDataBarFormat(ScDocument* pDoc); + ScDataBarFormat(ScDocument* pDoc, const ScDataBarFormat& rFormat); + virtual ScColorFormat* Clone(ScDocument* pDoc) const override; + + virtual void SetParent(ScConditionalFormat* pParent) override; + + std::unique_ptr<ScDataBarInfo> GetDataBarInfo(const ScAddress& rAddr) const; + + void SetDataBarData( ScDataBarFormatData* pData ); + const ScDataBarFormatData* GetDataBarData() const; + ScDataBarFormatData* GetDataBarData(); + + bool IsEqual(const ScFormatEntry& r, bool bIgnoreSrcPos) const override; + + virtual void UpdateReference( sc::RefUpdateContext& rCxt ) override; + virtual void UpdateInsertTab( sc::RefUpdateInsertTabContext& rCxt ) override; + virtual void UpdateDeleteTab( sc::RefUpdateDeleteTabContext& rCxt ) override; + virtual void UpdateMoveTab( sc::RefUpdateMoveTabContext& rCxt ) override; + + virtual Type GetType() const override; + + /** + * Makes sure that the mpFormatData does not contain valid entries. + * Should be called when it is not sure that the format is valid. + */ + void EnsureSize(); + +private: + double getMin(double nMin, double nMax) const; + double getMax(double nMin, double nMax) const; + + std::unique_ptr<ScDataBarFormatData> mpFormatData; +}; + +struct ScIconSetFormatData +{ + ScIconSetType eIconSetType; + bool mbShowValue; + /** + * Specifies whether the icons should be shown in reverse order + */ + bool mbReverse; + typedef std::vector<std::unique_ptr<ScColorScaleEntry, o3tl::default_delete<ScColorScaleEntry>>> Entries_t; + Entries_t m_Entries; + bool mbCustom; + // the std::pair points to exactly one image + // std..pair::second == -1 means no image + std::vector<std::pair<ScIconSetType, sal_Int32> > maCustomVector; + + ScIconSetFormatData(ScIconSetType eType = IconSet_3Arrows): + eIconSetType(eType), + mbShowValue(true), + mbReverse(false), + mbCustom(false) + {} + + ScIconSetFormatData(ScIconSetFormatData const&); + ScIconSetFormatData& operator=(ScIconSetFormatData const&) = delete; //TODO? +}; + +class SC_DLLPUBLIC ScIconSetFormat final : public ScColorFormat +{ +public: + ScIconSetFormat(ScDocument* pDoc); + ScIconSetFormat(ScDocument* pDoc, const ScIconSetFormat& rFormat); + + virtual ScColorFormat* Clone(ScDocument* pDoc) const override; + + virtual void SetParent(ScConditionalFormat* pParent) override; + + std::unique_ptr<ScIconSetInfo> GetIconSetInfo(const ScAddress& rAddr) const; + + void SetIconSetData( ScIconSetFormatData* pData ); + const ScIconSetFormatData* GetIconSetData() const; + ScIconSetFormatData* GetIconSetData(); + + virtual void UpdateReference( sc::RefUpdateContext& rCxt ) override; + virtual void UpdateInsertTab( sc::RefUpdateInsertTabContext& rCxt ) override; + virtual void UpdateDeleteTab( sc::RefUpdateDeleteTabContext& rCxt ) override; + virtual void UpdateMoveTab( sc::RefUpdateMoveTabContext& rCxt ) override; + + virtual Type GetType() const override; + + static const ScIconSetMap g_IconSetMap[]; + static const char* getIconSetName( ScIconSetType eType ); + static sal_Int32 getIconSetElements( ScIconSetType eType ); + static OUString getIconName(ScIconSetType eType, sal_Int32 nIndex); + static BitmapEx& getBitmap(sc::IconSetBitmapMap& rBitmapMap, ScIconSetType eType, sal_Int32 nIndex); + + typedef ScIconSetFormatData::Entries_t::iterator iterator; + typedef ScIconSetFormatData::Entries_t::const_iterator const_iterator; + + iterator begin(); + const_iterator begin() const; + iterator end(); + const_iterator end() const; + + size_t size() const; + + /** + * Makes sure that the mpFormatData does not contain valid entries. + * Should be called when it is not sure that the format is valid. + */ + void EnsureSize(); + +private: + + double GetMinValue() const; + double GetMaxValue() const; + double CalcValue(double nMin, double nMax, const ScIconSetFormat::const_iterator& itr) const; + + std::unique_ptr<ScIconSetFormatData> mpFormatData; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx new file mode 100644 index 0000000000..733923b0f5 --- /dev/null +++ b/sc/inc/column.hxx @@ -0,0 +1,1089 @@ +/* -*- 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 "global.hxx" +#include "address.hxx" +#include "cellvalue.hxx" +#include "columnspanset.hxx" +#include "rangelst.hxx" +#include "types.hxx" +#include "mtvelements.hxx" +#include <formula/types.hxx> +#include <svl/zforlist.hxx> +#include <svx/svdobj.hxx> +#include "attarray.hxx" + +#include <optional> +#include <set> +#include <vector> + +#include <mdds/flat_segment_tree.hpp> + +namespace editeng { class SvxBorderLine; } +namespace formula { struct VectorRefArray; } + +namespace sc { + +struct BroadcasterState; +struct FormulaGroupEntry; +class StartListeningContext; +class EndListeningContext; +class CopyFromClipContext; +class CopyToClipContext; +class CopyToDocContext; +class MixDocContext; +struct RefUpdateContext; +struct RefUpdateInsertTabContext; +struct RefUpdateDeleteTabContext; +struct RefUpdateMoveTabContext; +class EditTextIterator; +struct NoteEntry; +class DocumentStreamAccess; +class CellValues; +class TableValues; +struct RowSpan; +class RowHeightContext; +class CompileFormulaContext; +struct SetFormulaDirtyContext; +enum class MatrixEdge; +class ColumnIterator; +class Sparkline; + +} + +class Fraction; +class OutputDevice; +class ScItemPoolCache; +class SvtListener; +class SfxPoolItem; +class SfxStyleSheetBase; +class SvxBoxInfoItem; +class SvxBoxItem; + +class ScDocument; +class ScEditDataArray; +class ScFormulaCell; +class ScMarkData; +class ScPatternAttr; +class ScStyleSheet; +class SvtBroadcaster; +class ScTypedStrData; +class ScProgress; +class ScFunctionData; +class ScFlatBoolRowSegments; +struct ScSetStringParam; +struct ScColWidthParam; +struct ScRefCellValue; +struct ScCellValue; +class ScHint; +enum class ScMF; +struct ScFilterEntries; +struct ScInterpreterContext; + +struct ScNeededSizeOptions +{ + const ScPatternAttr* pPattern; + bool bFormula; + bool bSkipMerged; + bool bGetFont; + bool bTotalSize; + + ScNeededSizeOptions(); +}; + +// A shared implementation of some column code and data. +// This is used by ScColumn, but also by ScTable for the unallocated +// columns (one instance that is the default for all not-yet allocated columns). +class ScColumnData +{ +protected: + std::unique_ptr<ScAttrArray> pAttrArray; + + ScColumnData(const ScColumnData&) = delete; + ScColumnData& operator= (const ScColumnData&) = delete; + +public: + ScColumnData() = default; + void InitAttrArray(ScAttrArray* attrArray) { pAttrArray.reset(attrArray); } + + ScDocument& GetDoc() const { return pAttrArray->GetDoc(); } + + ScAttrArray& AttrArray() { return *pAttrArray; } + const ScAttrArray& AttrArray() const { return *pAttrArray; } + + const SfxPoolItem& GetAttr( SCROW nRow, sal_uInt16 nWhich ) const; + template<class T> const T& GetAttr( SCROW nRow, TypedWhichId<T> nWhich ) const + { + return static_cast<const T&>(GetAttr(nRow, sal_uInt16(nWhich))); + } + const SfxPoolItem& GetAttr( SCROW nRow, sal_uInt16 nWhich, SCROW& nStartRow, SCROW& nEndRow ) const; + template<class T> const T& GetAttr( SCROW nRow, TypedWhichId<T> nWhich, SCROW& nStartRow, SCROW& nEndRow ) const + { + return static_cast<const T&>(GetAttr(nRow, sal_uInt16(nWhich), nStartRow, nEndRow)); + } + + void SetAttrEntries(std::vector<ScAttrEntry> && vNewData); + + const ScPatternAttr* GetPattern( SCROW nRow ) const; + const ScPatternAttr* GetMostUsedPattern( SCROW nStartRow, SCROW nEndRow ) const; + void ApplySelectionStyle(const ScStyleSheet& rStyle, SCROW nTop, SCROW nBottom); + void ApplySelectionCache(ScItemPoolCache* pCache, SCROW nStartRow, SCROW nEndRow, + ScEditDataArray* pDataArray, bool* pIsChanged); + void ApplyPatternArea( SCROW nStartRow, SCROW nEndRow, const ScPatternAttr& rPatAttr, + ScEditDataArray* pDataArray = nullptr, + bool* const pIsChanged = nullptr); + void MergePatternArea( ScMergePatternState& rState, SCROW nRow1, SCROW nRow2, bool bDeep ) const; + + sal_uInt32 GetNumberFormat( const ScInterpreterContext& rContext, SCROW nRow ) const; + sal_uInt32 GetNumberFormat( SCROW nStartRow, SCROW nEndRow ) const; + + /// Including current, may return -1 + SCROW GetNextUnprotected( SCROW nRow, bool bUp ) const; + + const ScStyleSheet* GetStyle( SCROW nRow ) const; + void ApplyStyleArea( SCROW nStartRow, SCROW nEndRow, const ScStyleSheet& rStyle ); + + bool HasAttrib( SCROW nRow1, SCROW nRow2, HasAttrFlags nMask ) const; + bool HasAttrib( SCROW nRow, HasAttrFlags nMask, SCROW* nStartRow = nullptr, SCROW* nEndRow = nullptr ) const; + + std::unique_ptr<ScAttrIterator> CreateAttrIterator( SCROW nStartRow, SCROW nEndRow ) const; + + bool IsAllAttrEqual( const ScColumnData& rCol, SCROW nStartRow, SCROW nEndRow ) const; + + void ClearSelectionItems(const sal_uInt16* pWhich, SCROW nStartRow, SCROW nEndRow); + void ChangeSelectionIndent(bool bIncrement, SCROW nStartRow, SCROW nEndRow); + + bool TestInsertRow( SCSIZE nSize ) const; + void InsertRow( SCROW nStartRow, SCSIZE nSize ); + void DeleteRow( SCROW nStartRow, SCSIZE nSize ); + + // Applies a function to the selected ranges. + // The function looks like + // ApplyDataFunc(ScColumnData& applyTo, SCROW nTop, SCROW nBottom) + template <typename ApplyDataFunc> void Apply(const ScMarkData&, SCCOL, ApplyDataFunc); +}; + +// Use protected inheritance to prevent publishing some internal ScColumnData +// functions as part of ScColumn. If they should be public in ScColumn, +// use 'using' to make them public. +class ScColumn : protected ScColumnData +{ + // Empty values correspond with empty cells. All non-empty cell positions + // must have non-empty elements. For text width, the value should be + // either the real text width, or TEXTWIDTH_DIRTY in case it hasn't been + // calculated yet. For script type, it should be either the real script + // type value or SvtScriptType::UNKNOWN. + sc::CellTextAttrStoreType maCellTextAttrs; + + // Cell notes + sc::CellNoteStoreType maCellNotes; + + // Broadcasters for formula cells. + sc::BroadcasterStoreType maBroadcasters; + + // Cell values. + sc::CellStoreType maCells; + + // Sparklines + sc::SparklineStoreType maSparklines; + + size_t mnBlkCountFormula; + + SCCOL nCol; + SCTAB nTab; + + bool mbEmptyBroadcastersPending : 1; // a broadcaster not removed during EnableDelayDeletingBroadcasters() + +friend class ScDocument; // for FillInfo +friend class ScTable; +friend class ScValueIterator; +friend class ScHorizontalValueIterator; +friend class ScDBQueryDataIterator; +template< ScQueryCellIteratorAccess accessType, ScQueryCellIteratorType queryType > +friend class ScQueryCellIteratorBase; +template< ScQueryCellIteratorAccess accessType > +friend class ScQueryCellIteratorAccessSpecific; +friend class ScFormulaGroupIterator; +friend class ScCellIterator; +friend class ScHorizontalCellIterator; +friend class ScColumnTextWidthIterator; +friend class ScDocumentImport; +friend class sc::DocumentStreamAccess; +friend class sc::SingleColumnSpanSet; +friend class sc::ColumnSpanSet; +friend class sc::EditTextIterator; +friend class sc::CellValues; +friend class sc::TableValues; +friend class sc::CellStoreEvent; + + bool ParseString( + ScCellValue& rCell, + SCROW nRow, SCTAB nTab, const OUString& rString, formula::FormulaGrammar::AddressConvention eConv, + const ScSetStringParam* pParam ); + + void duplicateSparkline(sc::CopyFromClipContext& rContext, sc::ColumnBlockPosition* pBlockPos, + size_t nColOffset, size_t nDestSize, ScAddress aDestPosition); + +public: + + /** Broadcast mode for SetDirty(SCROW,SCROW,BroadcastMode). */ + enum BroadcastMode + { + BROADCAST_NONE, ///< no broadcasting + BROADCAST_DATA_POSITIONS, ///< broadcast existing cells with position => does AreaBroadcast + BROADCAST_BROADCASTERS ///< broadcast only existing cell broadcasters => no AreaBroadcast of range! + }; + + ScColumn(ScSheetLimits const &); + ~ScColumn() COVERITY_NOEXCEPT_FALSE; + + void Init(SCCOL nNewCol, SCTAB nNewTab, ScDocument& rDoc, bool bEmptyAttrArray); + + using ScColumnData::GetDoc; + SCTAB GetTab() const { return nTab; } + SCCOL GetCol() const { return nCol; } + sc::CellStoreType& GetCellStore() { return maCells; } + const sc::CellStoreType& GetCellStore() const { return maCells; } + sc::CellTextAttrStoreType& GetCellAttrStore() { return maCellTextAttrs; } + const sc::CellTextAttrStoreType& GetCellAttrStore() const { return maCellTextAttrs; } + sc::CellNoteStoreType& GetCellNoteStore() { return maCellNotes; } + const sc::CellNoteStoreType& GetCellNoteStore() const { return maCellNotes; } + sc::SparklineStoreType& GetSparklineStore() { return maSparklines; } + const sc::SparklineStoreType& GetSparklineStore() const { return maSparklines; } + + ScRefCellValue GetCellValue( SCROW nRow ) const; + ScRefCellValue GetCellValue( sc::ColumnBlockPosition& rBlockPos, SCROW nRow ); + ScRefCellValue GetCellValue( sc::ColumnBlockConstPosition& rBlockPos, SCROW nRow ) const; + static ScRefCellValue GetCellValue( const sc::CellStoreType::const_iterator& itPos, size_t nOffset ); + + const sc::CellTextAttr* GetCellTextAttr( SCROW nRow ) const; + const sc::CellTextAttr* GetCellTextAttr( sc::ColumnBlockConstPosition& rBlockPos, SCROW nRow ) const; + + void Delete( SCROW nRow ); + void DeleteContent( SCROW nRow, bool bBroadcast = true ); + void FreeAll(); + void FreeNotes(); + void Swap( ScColumn& rOther, SCROW nRow1, SCROW nRow2, bool bPattern ); + + bool HasAttribSelection( const ScMarkData& rMark, HasAttrFlags nMask ) const; + bool IsMerged( SCROW nRow ) const; + bool ExtendMerge( SCCOL nThisCol, SCROW nStartRow, SCROW nEndRow, + SCCOL& rPaintCol, SCROW& rPaintRow, + bool bRefresh ); + + bool IsEmptyData() const; + bool IsEmptyAttr() const; + + // data only: + bool IsEmptyData(SCROW nStartRow, SCROW nEndRow) const; + SCSIZE GetEmptyLinesInBlock( SCROW nStartRow, SCROW nEndRow, ScDirection eDir ) const; + bool HasDataAt( SCROW nRow, ScDataAreaExtras* pDataAreaExtras = nullptr ) const; + bool HasDataAt( sc::ColumnBlockConstPosition& rBlockPos, SCROW nRow, + ScDataAreaExtras* pDataAreaExtras = nullptr ) const; + bool HasDataAt( sc::ColumnBlockPosition& rBlockPos, SCROW nRow, + ScDataAreaExtras* pDataAreaExtras = nullptr ); + void GetDataExtrasAt( SCROW nRow, ScDataAreaExtras& rDataAreaExtras ) const; + bool HasVisibleDataAt(SCROW nRow) const; + SCROW GetFirstDataPos() const; + SCROW GetLastDataPos() const; + SCROW GetLastDataPos( SCROW nLastRow, ScDataAreaExtras* pDataAreaExtras = nullptr ) const; + bool GetPrevDataPos(SCROW& rRow) const; + bool GetNextDataPos(SCROW& rRow) const; + bool TrimEmptyBlocks(SCROW& rRowStart, SCROW& rRowEnd) const; + void FindDataAreaPos(SCROW& rRow, bool bDown) const; // (without Broadcaster) + void FindUsed( SCROW nStartRow, SCROW nEndRow, mdds::flat_segment_tree<SCROW, bool>& rUsed ) const; + + SCSIZE VisibleCount( SCROW nStartRow, SCROW nEndRow ) const; + sc::MatrixEdge GetBlockMatrixEdges(SCROW nRow1, SCROW nRow2, sc::MatrixEdge nMask, bool bNoMatrixAtAll ) const; + // Repeated calls to HasSelectionMatrixFragment() repeatedly call rMark.GetMarkedRanges(), + // which may be quite slow. For that reason first save the result of rMark.GetMarkedRanges() + // pass that to HasSelectionMatrixFragment() calls. + bool HasSelectionMatrixFragment(const ScMarkData& rMark, const ScRangeList& rRangeList) const; + + bool GetFirstVisibleAttr( SCROW& rFirstRow ) const; + bool GetLastVisibleAttr( SCROW& rLastRow, bool bSkipEmpty ) const; + bool HasVisibleAttrIn( SCROW nStartRow, SCROW nEndRow ) const; + bool IsVisibleAttrEqual( const ScColumn& rCol, SCROW nStartRow, SCROW nEndRow ) const; + + bool TestInsertCol( SCROW nStartRow, SCROW nEndRow) const; + bool TestInsertRow( SCROW nStartRow, SCSIZE nSize ) const; + void InsertRow( SCROW nStartRow, SCSIZE nSize ); + void GetUnprotectedCells(SCROW nStartRow, SCROW nEndRow, ScRangeList& rRangeList ) const; + + /** + * @param nStartRow top row position + * @param nSize size of the segment to delete. + * @param pGroupPos when non-NULL, stores the top position of formula + * group that's been merged as a result of row deletion. + */ + void DeleteRow( SCROW nStartRow, SCSIZE nSize, std::vector<ScAddress>* pGroupPos ); + + void DeleteArea( + SCROW nStartRow, SCROW nEndRow, InsertDeleteFlags nDelFlag, + bool bBroadcast = true, sc::ColumnSpanSet* pBroadcastSpans = nullptr ); + + void DeleteRanges( const std::vector<sc::RowSpan>& rRanges, InsertDeleteFlags nDelFlag ); + + void CopyToClip( + sc::CopyToClipContext& rCxt, SCROW nRow1, SCROW nRow2, ScColumn& rColumn ) const; + + void CopyStaticToDocument( + SCROW nRow1, SCROW nRow2, const SvNumberFormatterMergeMap& rMap, ScColumn& rDestCol ); + + void CopyCellToDocument( SCROW nSrcRow, SCROW nDestRow, ScColumn& rDestCol ); + void InitBlockPosition( sc::ColumnBlockPosition& rBlockPos ); + void InitBlockPosition( sc::ColumnBlockConstPosition& rBlockPos ) const; + + void DeleteBeforeCopyFromClip( + sc::CopyFromClipContext& rCxt, const ScColumn& rClipCol, sc::ColumnSpanSet& rBroadcastSpans ); + + void CopyOneCellFromClip( sc::CopyFromClipContext& rCxt, SCROW nRow1, SCROW nRow2, size_t nColOffset ); + + void CopyFromClip( + sc::CopyFromClipContext& rCxt, SCROW nRow1, SCROW nRow2, tools::Long nDy, ScColumn& rColumn ); + + void RemoveEditAttribs( sc::ColumnBlockPosition& rBlockPos, SCROW nStartRow, SCROW nEndRow ); + + // Selection (?) of this document + void MixMarked( + sc::MixDocContext& rCxt, const ScMarkData& rMark, ScPasteFunc nFunction, + bool bSkipEmpty, const ScColumn& rSrcCol ); + void MixData( + sc::MixDocContext& rCxt, SCROW nRow1, SCROW nRow2, ScPasteFunc nFunction, bool bSkipEmpty, + const ScColumn& rSrcCol ); + + void UpdateSelectionFunction( + const ScRangeList& rRanges, ScFunctionData& rData, const ScFlatBoolRowSegments& rHiddenRows ); + + void CopyToColumn( + sc::CopyToDocContext& rCxt, SCROW nRow1, SCROW nRow2, InsertDeleteFlags nFlags, bool bMarked, + ScColumn& rColumn, const ScMarkData* pMarkData = nullptr, bool bAsLink = false, + bool bGlobalNamesToLocal = false ) const; + + void UndoToColumn( + sc::CopyToDocContext& rCxt, SCROW nRow1, SCROW nRow2, InsertDeleteFlags nFlags, bool bMarked, + ScColumn& rColumn) const; + + void CopyScenarioFrom( const ScColumn& rSrcCol ); + void CopyScenarioTo( ScColumn& rDestCol ) const; + bool TestCopyScenarioTo( const ScColumn& rDestCol ) const; + void MarkScenarioIn( ScMarkData& rDestMark ) const; + + void CopyUpdated( const ScColumn* pPosCol, ScColumn& rDestCol ) const; + + void SwapCol(ScColumn& rCol); + void MoveTo(SCROW nStartRow, SCROW nEndRow, ScColumn& rCol); + + bool HasEditCells(SCROW nStartRow, SCROW nEndRow, SCROW& rFirst); + + bool SetString( + SCROW nRow, SCTAB nTab, const OUString& rString, formula::FormulaGrammar::AddressConvention eConv, + const ScSetStringParam* pParam = nullptr ); + + void SetEditText( SCROW nRow, std::unique_ptr<EditTextObject> pEditText ); + void SetEditText( sc::ColumnBlockPosition& rBlockPos, SCROW nRow, std::unique_ptr<EditTextObject> pEditText ); + void SetEditText( sc::ColumnBlockPosition& rBlockPos, SCROW nRow, const EditTextObject& rEditText ); + void SetEditText( SCROW nRow, const EditTextObject& rEditText, const SfxItemPool* pEditPool ); + void SetFormula( SCROW nRow, const ScTokenArray& rArray, formula::FormulaGrammar::Grammar eGram ); + void SetFormula( SCROW nRow, const OUString& rFormula, formula::FormulaGrammar::Grammar eGram ); + + /** + * Takes ownership of pCell + * + * @return pCell if it was successfully inserted, NULL otherwise. pCell + * is deleted automatically on failure to insert. + */ + ScFormulaCell* SetFormulaCell( + SCROW nRow, ScFormulaCell* pCell, + sc::StartListeningType eListenType = sc::SingleCellListening, + bool bInheritNumFormatIfNeeded = true); + void SetFormulaCell( + sc::ColumnBlockPosition& rBlockPos, SCROW nRow, ScFormulaCell* pCell, + sc::StartListeningType eListenType = sc::SingleCellListening, + bool bInheritNumFormatIfNeeded = true); + + bool SetFormulaCells( SCROW nRow, std::vector<ScFormulaCell*>& rCells ); + + bool HasFormulaCell() const; + bool HasFormulaCell( SCROW nRow1, SCROW nRow2 ) const; + + void CloneFormulaCell( + sc::ColumnBlockPosition& rBlockPos, + const ScFormulaCell& rSrc, const sc::CellTextAttr& rAttr, + const std::vector<sc::RowSpan>& rRanges ); + + void CloneFormulaCell( + const ScFormulaCell& rSrc, const sc::CellTextAttr& rAttr, + const std::vector<sc::RowSpan>& rRanges ); + + svl::SharedString GetSharedString( SCROW nRow ) const; + + void SetRawString( SCROW nRow, const OUString& rStr ); + void SetRawString( SCROW nRow, const svl::SharedString& rStr ); + void SetRawString( sc::ColumnBlockPosition& rBlockPos, SCROW nRow, const svl::SharedString& rStr, bool bBroadcast = true ); + void SetValue( SCROW nRow, double fVal ); + void SetValues( const SCROW nRow, const std::vector<double>& rVals ); + void SetValue( sc::ColumnBlockPosition& rBlockPos, SCROW nRow, double fVal, bool bBroadcast = true ); + void SetError( SCROW nRow, const FormulaError nError); + + OUString GetString( SCROW nRow, const ScInterpreterContext* pContext = nullptr ) const + { return GetString( GetCellValue( nRow ), nRow, pContext ); } + OUString GetString( sc::ColumnBlockConstPosition& rBlockPos, SCROW nRow, + const ScInterpreterContext* pContext = nullptr ) const + { return GetString( GetCellValue( rBlockPos, nRow ), nRow, pContext ); } + double* GetValueCell( SCROW nRow ); + // Note that if pShared is set and a value is returned that way, the returned OUString is empty. + OUString GetInputString( SCROW nRow, bool bForceSystemLocale = false ) const + { return GetInputString( GetCellValue( nRow ), nRow, bForceSystemLocale ); } + OUString GetInputString( sc::ColumnBlockConstPosition& rBlockPos, SCROW nRow, + bool bForceSystemLocale = false ) const + { return GetInputString( GetCellValue( rBlockPos, nRow ), nRow, bForceSystemLocale ); } + double GetValue( SCROW nRow ) const; + const EditTextObject* GetEditText( SCROW nRow ) const; + void RemoveEditTextCharAttribs( SCROW nRow, const ScPatternAttr& rAttr ); + OUString GetFormula( SCROW nRow ) const; + const ScFormulaCell* GetFormulaCell( SCROW nRow ) const; + ScFormulaCell* GetFormulaCell( SCROW nRow ); + ScFormulaCell * const * GetFormulaCellBlockAddress( SCROW nRow, size_t& rBlockSize ) const; + CellType GetCellType( SCROW nRow ) const; + SCSIZE GetCellCount() const; + sal_uInt64 GetWeightedCount() const; + sal_uInt64 GetWeightedCount(SCROW nStartRow, SCROW nEndRow) const; + sal_uInt64 GetCodeCount() const; // RPN-Code in formulas + FormulaError GetErrCode( SCROW nRow ) const; + + bool HasStringData( SCROW nRow ) const; + bool HasValueData( SCROW nRow ) const; + bool HasStringCells( SCROW nStartRow, SCROW nEndRow ) const; + + sc::MultiDataCellState::StateType HasDataCellsInRange( + SCROW nRow1, SCROW nRow2, SCROW* pRow1 ) const; + + bool IsFormulaDirty( SCROW nRow ) const; + + void CheckVectorizationState(); + void SetAllFormulasDirty( const sc::SetFormulaDirtyContext& rCxt ); + void SetDirtyFromClip( SCROW nRow1, SCROW nRow2, sc::ColumnSpanSet& rBroadcastSpans ); + void SetDirty( SCROW nRow1, SCROW nRow2, BroadcastMode ); + void SetDirtyVar(); + void SetDirtyAfterLoad(); + void SetTableOpDirty( const ScRange& ); + void CalcAll(); + void CalcAfterLoad( sc::CompileFormulaContext& rCxt, bool bStartListening ); + void CompileAll( sc::CompileFormulaContext& rCxt ); + void CompileXML( sc::CompileFormulaContext& rCxt, ScProgress& rProgress ); + + /** Broadcast single broadcasters in range, without explicitly setting + anything dirty, not doing area broadcasts. + @param rHint address is modified to adapt to the actual broadcasted + position on each iteration and upon return points to the last + position broadcasted. */ + bool BroadcastBroadcasters( SCROW nRow1, SCROW nRow2, SfxHintId nHint ); + + bool CompileErrorCells( sc::CompileFormulaContext& rCxt, FormulaError nErrCode ); + + void ResetChanged( SCROW nStartRow, SCROW nEndRow ); + + bool UpdateReferenceOnCopy( sc::RefUpdateContext& rCxt, ScDocument* pUndoDoc = nullptr ); + + /** + * Update reference addresses in formula cell in response to mass cell + * movement. + * + * @return true if reference of at least one formula cell has been + * updated, false otherwise. + */ + bool UpdateReference( sc::RefUpdateContext& rCxt, ScDocument* pUndoDoc ); + + void UpdateInsertTab( sc::RefUpdateInsertTabContext& rCxt ); + void UpdateInsertTabOnlyCells( sc::RefUpdateInsertTabContext& rCxt ); + void UpdateDeleteTab( sc::RefUpdateDeleteTabContext& rCxt ); + void UpdateMoveTab( sc::RefUpdateMoveTabContext& rCxt, SCTAB nTabNo ); + void UpdateCompile( bool bForceIfNameInUse = false ); + void UpdateTranspose( const ScRange& rSource, const ScAddress& rDest, + ScDocument* pUndoDoc ); + void UpdateGrow( const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY ); + + void SetTabNo(SCTAB nNewTab); + void FindRangeNamesInUse(SCROW nRow1, SCROW nRow2, sc::UpdatedRangeNames& rIndexes) const; + + void PreprocessRangeNameUpdate( + sc::EndListeningContext& rEndListenCxt, sc::CompileFormulaContext& rCompileCxt ); + + void CompileHybridFormula( + sc::StartListeningContext& rStartListenCxt, sc::CompileFormulaContext& rCompileCxt ); + + void PreprocessDBDataUpdate( + sc::EndListeningContext& rEndListenCxt, sc::CompileFormulaContext& rCompileCxt ); + + using ScColumnData::GetAttr; + using ScColumnData::GetPattern; + using ScColumnData::GetNumberFormat; + + void MergeSelectionPattern( ScMergePatternState& rState, const ScMarkData& rMark, bool bDeep ) const; + void MergeBlockFrame( SvxBoxItem* pLineOuter, SvxBoxInfoItem* pLineInner, + ScLineFlags& rFlags, + SCROW nStartRow, SCROW nEndRow, bool bLeft, SCCOL nDistRight ) const; + void ApplyBlockFrame(const SvxBoxItem& rLineOuter, const SvxBoxInfoItem* pLineInner, + SCROW nStartRow, SCROW nEndRow, bool bLeft, SCCOL nDistRight); + + void ApplyAttr( SCROW nRow, const SfxPoolItem& rAttr ); + void ApplyPattern( SCROW nRow, const ScPatternAttr& rPatAttr ); + const ScPatternAttr* SetPattern( SCROW nRow, std::unique_ptr<ScPatternAttr> ); + void SetPattern( SCROW nRow, const ScPatternAttr& ); + void SetPatternArea( SCROW nStartRow, SCROW nEndRow, const ScPatternAttr& ); + void ApplyPatternIfNumberformatIncompatible( const ScRange& rRange, + const ScPatternAttr& rPattern, SvNumFormatType nNewType ); + + void ApplyStyle( SCROW nRow, const ScStyleSheet* rStyle ); + void ApplySelectionLineStyle( const ScMarkData& rMark, + const ::editeng::SvxBorderLine* pLine, bool bColorOnly ); + void AddCondFormat(SCROW nStartRow, SCROW nEndRow, sal_uInt32 nIndex ); + void RemoveCondFormat(SCROW nStartRow, SCROW nEndRow, sal_uInt32 nIndex ); + + const ScStyleSheet* GetSelectionStyle( const ScMarkData& rMark, bool& rFound ) const; + const ScStyleSheet* GetAreaStyle( bool& rFound, SCROW nRow1, SCROW nRow2 ) const; + + void FindStyleSheet( const SfxStyleSheetBase* pStyleSheet, ScFlatBoolRowSegments& rUsedRows, bool bReset ); + bool IsStyleSheetUsed( const ScStyleSheet& rStyle ) const; + + /// May return -1 if not found + SCROW SearchStyle( + SCROW nRow, const ScStyleSheet* pSearchStyle, bool bUp, bool bInSelection, + const ScMarkData& rMark) const; + + bool SearchStyleRange( + SCROW& rRow, SCROW& rEndRow, const ScStyleSheet* pSearchStyle, bool bUp, + bool bInSelection, const ScMarkData& rMark) const; + + bool ApplyFlags( SCROW nStartRow, SCROW nEndRow, ScMF nFlags ); + bool RemoveFlags( SCROW nStartRow, SCROW nEndRow, ScMF nFlags ); + void ClearItems( SCROW nStartRow, SCROW nEndRow, const sal_uInt16* pWhich ); + + void RemoveProtected( SCROW nStartRow, SCROW nEndRow ); + + void DeleteSelection( InsertDeleteFlags nDelFlag, const ScMarkData& rMark, bool bBroadcast ); + + tools::Long GetNeededSize( + SCROW nRow, OutputDevice* pDev, double nPPTX, double nPPTY, + const Fraction& rZoomX, const Fraction& rZoomY, + bool bWidth, const ScNeededSizeOptions& rOptions, const ScPatternAttr** pPatternChange, + bool bInPrintTwips = false ) const; + + sal_uInt16 GetOptimalColWidth( + OutputDevice* pDev, double nPPTX, double nPPTY, + const Fraction& rZoomX, const Fraction& rZoomY, + bool bFormula, sal_uInt16 nOldWidth, const ScMarkData* pMarkData, const ScColWidthParam* pParam) const; + + void GetOptimalHeight( + sc::RowHeightContext& rCxt, SCROW nStartRow, SCROW nEndRow, sal_uInt16 nMinHeight, SCROW nMinStart ); + + void GetFilterEntries( + sc::ColumnBlockConstPosition& rBlockPos, SCROW nStartRow, SCROW nEndRow, + ScFilterEntries& rFilterEntries, bool bFiltering, bool bFilteredRow ); + + void GetBackColorFilterEntries(SCROW nRow1, SCROW nRow2, ScFilterEntries& rFilterEntries ); + + bool GetDataEntries( SCROW nRow, std::set<ScTypedStrData>& rStrings) const; + + void UpdateInsertTabAbs(SCTAB nNewPos); + bool TestTabRefAbs(SCTAB nTable) const; + bool GetNextSpellingCell(SCROW& nRow, bool bInSel, const ScMarkData& rData) const; + + void StartListeningFormulaCells( + sc::StartListeningContext& rStartCxt, sc::EndListeningContext& rEndCxt, SCROW nRow1, SCROW nRow2 ); + + void EndListeningFormulaCells( + sc::EndListeningContext& rCxt, SCROW nRow1, SCROW nRow2, + SCROW* pStartRow, SCROW* pEndRow ); + + void StartListening( SvtListener& rLst, SCROW nRow ); + void EndListening( SvtListener& rLst, SCROW nRow ); + void StartListening( sc::StartListeningContext& rCxt, const ScAddress& rAddress, SvtListener& rListener ); + void EndListening( sc::EndListeningContext& rCxt, const ScAddress& rAddress, SvtListener& rListener ); + void StartListeners( sc::StartListeningContext& rCxt, bool bAll ); + void SetDirtyIfPostponed(); + void BroadcastRecalcOnRefMove(); + void CollectListeners( std::vector<SvtListener*>& rListeners, SCROW nRow1, SCROW nRow2 ); + void CollectFormulaCells( std::vector<ScFormulaCell*>& rCells, SCROW nRow1, SCROW nRow2 ); + + void CompileDBFormula( sc::CompileFormulaContext& rCxt ); + void CompileColRowNameFormula( sc::CompileFormulaContext& rCxt ); + + sal_Int32 GetMaxStringLen( SCROW nRowStart, SCROW nRowEnd, rtl_TextEncoding eCharSet ) const; + sal_Int32 GetMaxNumberStringLen( sal_uInt16& nPrecision, + SCROW nRowStart, SCROW nRowEnd ) const; + + sal_uInt16 GetTextWidth(SCROW nRow) const; + void SetTextWidth(SCROW nRow, sal_uInt16 nWidth); + + SvtScriptType GetScriptType( SCROW nRow ) const; + + /** + * Get combined script types of the specified range. This method may + * update script types on demand if they have not been determined. + */ + SvtScriptType GetRangeScriptType( sc::CellTextAttrStoreType::iterator& itPos, SCROW nRow1, SCROW nRow2, + const sc::CellStoreType::iterator& itr); + + void SetScriptType( SCROW nRow, SvtScriptType nType ); + void UpdateScriptTypes( SCROW nRow1, SCROW nRow2 ); + + formula::FormulaTokenRef ResolveStaticReference( SCROW nRow ); + bool ResolveStaticReference( ScMatrix& rMat, SCCOL nMatCol, SCROW nRow1, SCROW nRow2 ); + void FillMatrix( ScMatrix& rMat, size_t nMatCol, SCROW nRow1, SCROW nRow2, svl::SharedStringPool* pPool ) const; + formula::VectorRefArray FetchVectorRefArray( SCROW nRow1, SCROW nRow2 ); + bool HandleRefArrayForParallelism( SCROW nRow1, SCROW nRow2, + const ScFormulaCellGroupRef& mxGroup, ScAddress* pDirtiedAddress ); +#ifdef DBG_UTIL + void AssertNoInterpretNeeded( SCROW nRow1, SCROW nRow2 ); +#endif + void SetFormulaResults( SCROW nRow, const double* pResults, size_t nLen ); + + void CalculateInThread( ScInterpreterContext& rContext, SCROW nRow, size_t nLen, size_t nOffset, + unsigned nThisThread, unsigned nThreadsTotal ); + void HandleStuffAfterParallelCalculation( SCROW nRow, size_t nLen, ScInterpreter* pInterpreter ); + + void SetNumberFormat( SCROW nRow, sal_uInt32 nNumberFormat ); + + SvtBroadcaster* GetBroadcaster( SCROW nRow ); + const SvtBroadcaster* GetBroadcaster( SCROW nRow ) const; + + void DeleteBroadcasters( sc::ColumnBlockPosition& rBlockPos, SCROW nRow1, SCROW nRow2 ); + void PrepareBroadcastersForDestruction(); + void DeleteEmptyBroadcasters(); + + void Broadcast( SCROW nRow ); + void BroadcastCells( const std::vector<SCROW>& rRows, SfxHintId nHint ); + void BroadcastRows( SCROW nStartRow, SCROW nEndRow, SfxHintId nHint ); + + // Spaklines + sc::SparklineCell* GetSparklineCell(SCROW nRow); + void CreateSparklineCell(SCROW nRow, std::shared_ptr<sc::Sparkline> const& pSparkline); + void DeleteSparklineCells(sc::ColumnBlockPosition& rBlockPos, SCROW nRow1, SCROW nRow2); + bool DeleteSparkline(SCROW nRow); + bool IsSparklinesEmptyBlock(SCROW nStartRow, SCROW nEndRow) const; + void CopyCellSparklinesToDocument(SCROW nRow1, SCROW nRow2, ScColumn& rDestCol, SCROW nRowOffsetDest = 0) const; + void DuplicateSparklines(SCROW nStartRow, size_t nDataSize, ScColumn& rDestCol, + sc::ColumnBlockPosition& rDestBlockPos, SCROW nRowOffsetDest = 0) const; + bool HasSparklines() const; + SCROW GetSparklinesMaxRow() const; + SCROW GetSparklinesMinRow() const; + + // cell notes + ScPostIt* GetCellNote( SCROW nRow ); + const ScPostIt* GetCellNote( SCROW nRow ) const; + ScPostIt* GetCellNote( sc::ColumnBlockConstPosition& rBlockPos, SCROW nRow ); + const ScPostIt* GetCellNote( sc::ColumnBlockConstPosition& rBlockPos, SCROW nRow ) const; + void DeleteCellNotes( sc::ColumnBlockPosition& rBlockPos, SCROW nRow1, SCROW nRow2, bool bForgetCaptionOwnership ); + bool HasCellNote(SCROW nStartRow, SCROW nEndRow) const; + bool HasCellNotes() const; + void SetCellNote( SCROW nRow, std::unique_ptr<ScPostIt> pNote); + bool IsNotesEmptyBlock(SCROW nStartRow, SCROW nEndRow) const; + + std::unique_ptr<ScPostIt> ReleaseNote( SCROW nRow ); + size_t GetNoteCount() const; + void CreateAllNoteCaptions(); + void ForgetNoteCaptions( SCROW nRow1, SCROW nRow2, bool bPreserveData ); + SCROW GetNotePosition( size_t nIndex ) const; + void GetAllNoteEntries( std::vector<sc::NoteEntry>& rNotes ) const; + void GetNotesInRange( SCROW nStartRow, SCROW nEndRow, std::vector<sc::NoteEntry>& rNotes ) const; + + SCROW GetCellNotesMaxRow() const; + SCROW GetCellNotesMinRow() const; + + void CopyCellNotesToDocument( + SCROW nRow1, SCROW nRow2, ScColumn& rDestCol, bool bCloneCaption = true, + SCROW nRowOffsetDest = 0) const; + + void DuplicateNotes(SCROW nStartRow, size_t nDataSize, ScColumn& rDestCol, + sc::ColumnBlockPosition& rDestBlockPos, bool bCloneCaption, SCROW nRowOffsetDest = 0) const; + + void UpdateNoteCaptions( SCROW nRow1, SCROW nRow2, bool bAddressChanged = true ); + void CommentNotifyAddressChange( SCROW nRow1, SCROW nRow2 ); + + void UpdateDrawObjects( std::vector<std::vector<SdrObject*>>& pObjects, SCROW nRowStart, SCROW nRowEnd ); + void UpdateDrawObjectsForRow( std::vector<SdrObject*>& pObjects, SCCOL nTargetCol, SCROW nTargetRow ); + bool IsDrawObjectsEmptyBlock(SCROW nStartRow, SCROW nEndRow) const; + + void InterpretDirtyCells( SCROW nRow1, SCROW nRow2 ); + bool InterpretCellsIfNeeded( SCROW nRow1, SCROW nRow2 ); + + static void JoinNewFormulaCell( const sc::CellStoreType::position_type& aPos, ScFormulaCell& rCell ); + + /** + * Detach a formula cell that's about to be deleted, or removed from + * document storage (if that ever happens). + * + * @param rNewSharedRows collects possible new shared row ranges (top and + * bottom of shared or remaining single twice) resulting from + * unsharing to reestablish listeners on. + */ + void DetachFormulaCell( const sc::CellStoreType::position_type& aPos, ScFormulaCell& rCell, + std::vector<SCROW>& rNewSharedRows ); + + /** Re-establish listeners on unshared formula groups */ + void StartListeningUnshared( const std::vector<SCROW>& rNewSharedRows ); + + void DetachFormulaCells( const sc::CellStoreType::position_type& aPos, size_t nLength, + std::vector<SCROW>* pNewSharedRows ); + + void AttachFormulaCells( sc::StartListeningContext& rCxt, SCROW nRow1, SCROW nRow2 ); + void DetachFormulaCells( sc::EndListeningContext& rCxt, SCROW nRow1, SCROW nRow2 ); + + /** + * Regroup formula cells for the entire column. + */ + void RegroupFormulaCells( std::vector<ScAddress>* pGroupPos = nullptr ); + + /** + * Reset column position of formula cells within specified row range. + * If bUpdateRefs==true then reference positions are also adjusted to + * reflect the new position so that the formula cells still reference the + * same cells or ranges after the position change. + * The position of a formula cell before the call is interpreted as the old + * position of that cell. + * + * Caller needs to ensure that no formula groups cross the top and bottom + * row boundaries. + * + * @param nRow1 top row boundary + * @param nRow2 bottom row boundary + * @param bUpdateRefs whether to adjust references + */ + void ResetFormulaCellPositions( SCROW nRow1, SCROW nRow2, bool bUpdateRefs ); + + void SplitFormulaGroupByRelativeRef( const ScRange& rBoundRange ); + + void TransferCellValuesTo( SCROW nRow, size_t nLen, sc::CellValues& rDest ); + void CopyCellValuesFrom( SCROW nRow, const sc::CellValues& rSrc ); + void ConvertFormulaToValue( + sc::EndListeningContext& rCxt, SCROW nRow1, SCROW nRow2, sc::TableValues* pUndo ); + + void SwapNonEmpty( + sc::TableValues& rValues, sc::StartListeningContext& rStartCxt, sc::EndListeningContext& rEndCxt ); + + std::optional<sc::ColumnIterator> GetColumnIterator( SCROW nRow1, SCROW nRow2 ) const; + + bool EnsureFormulaCellResults( SCROW nRow1, SCROW nRow2, bool bSkipRunning = false ); + + void StoreToCache(SvStream& rStrm) const; + void RestoreFromCache(SvStream& rStrm); + +#if DUMP_COLUMN_STORAGE + void DumpColumnStorage() const; +#endif + + SCSIZE GetPatternCount() const; + SCSIZE GetPatternCount( SCROW nRow1, SCROW nRow2 ) const; + bool ReservePatternCount( SCSIZE nReserve ); + + void CheckIntegrity() const; + +private: + + sc::CellStoreType::iterator GetPositionToInsert( SCROW nRow, std::vector<SCROW>& rNewSharedRows, + bool bInsertFormula ); + sc::CellStoreType::iterator GetPositionToInsert( const sc::CellStoreType::iterator& it, SCROW nRow, + std::vector<SCROW>& rNewSharedRows, bool bInsertFormula ); + + void AttachNewFormulaCell( + const sc::CellStoreType::iterator& itPos, SCROW nRow, ScFormulaCell& rCell, + const std::vector<SCROW>& rNewSharedRows, + bool bJoin = true, sc::StartListeningType eListenType = sc::SingleCellListening ); + + void AttachNewFormulaCell( + const sc::CellStoreType::position_type& aPos, ScFormulaCell& rCell, + const std::vector<SCROW>& rNewSharedRows, + bool bJoin = true, sc::StartListeningType eListenType = sc::SingleCellListening ); + +public: + void AttachNewFormulaCells(const sc::CellStoreType::position_type& aPos, size_t nLength, + std::vector<SCROW>& rNewSharedRows); + +private: + void BroadcastNewCell( SCROW nRow ); + bool UpdateScriptType( sc::CellTextAttr& rAttr, SCROW nRow, sc::CellStoreType::iterator& itr ); + + const ScFormulaCell* FetchFormulaCell( SCROW nRow ) const; + + SCROW FindNextVisibleRowWithContent( + sc::CellStoreType::const_iterator& itPos, SCROW nRow, bool bForward) const; + SCROW FindNextVisibleRow(SCROW nRow, bool bForward) const; + + OUString GetString( const ScRefCellValue& cell, SCROW nRow, const ScInterpreterContext* pContext = nullptr ) const; + OUString GetInputString( const ScRefCellValue& cell, SCROW nRow, bool bForceSystemLocale = false ) const; + + /** + * Called whenever the state of cell array gets modified i.e. new cell + * insertion, cell removal or relocation, cell value update and so on. + * + * Call this only from those methods where maCells is modified directly. + */ + void CellStorageModified(); + void CellNotesDeleting(SCROW nRow1, SCROW nRow2, bool bForgetCaptionOwnership ); + + void CopyCellTextAttrsToDocument(SCROW nRow1, SCROW nRow2, ScColumn& rDestCol) const; + + struct DeleteCellsResult + { + /** cell ranges that have been deleted. */ + sc::SingleColumnSpanSet aDeletedRows; + /** formula cell range that has stopped listening. */ + std::vector<std::pair<SCROW, SCROW>> aFormulaRanges; + + DeleteCellsResult( const ScDocument& rDoc ); + DeleteCellsResult( const DeleteCellsResult& ) = delete; + }; + + std::unique_ptr<DeleteCellsResult> DeleteCells( + sc::ColumnBlockPosition& rBlockPos, SCROW nRow1, SCROW nRow2, InsertDeleteFlags nDelFlag ); + + /** + * Get all non-grouped formula cells and formula cell groups in the whole + * column. + */ + std::vector<sc::FormulaGroupEntry> GetFormulaGroupEntries(); + + void EndListeningIntersectedGroup( + sc::EndListeningContext& rCxt, SCROW nRow, std::vector<ScAddress>* pGroupPos ); + + void EndListeningIntersectedGroups( + sc::EndListeningContext& rCxt, SCROW nRow1, SCROW nRow2, std::vector<ScAddress>* pGroupPos ); + + void EndListeningGroup( sc::EndListeningContext& rCxt, SCROW nRow ); + void SetNeedsListeningGroup( SCROW nRow ); + + void CollectBroadcasterState(sc::BroadcasterState& rState) const; +}; + +inline bool ScColumn::IsEmptyAttr() const +{ + return pAttrArray->IsEmpty(); +} + +inline bool ScColumnData::IsAllAttrEqual( const ScColumnData& rCol, SCROW nStartRow, SCROW nEndRow ) const +{ + return pAttrArray->IsAllEqual( *rCol.pAttrArray, nStartRow, nEndRow ); +} + +inline bool ScColumn::IsVisibleAttrEqual( const ScColumn& rCol, SCROW nStartRow, SCROW nEndRow ) const +{ + return pAttrArray->IsVisibleEqual( *rCol.pAttrArray, nStartRow, nEndRow ); +} + +inline bool ScColumn::GetFirstVisibleAttr( SCROW& rFirstRow ) const +{ + return pAttrArray->GetFirstVisibleAttr( rFirstRow ); +} + +inline bool ScColumn::GetLastVisibleAttr( SCROW& rLastRow, bool bSkipEmpty ) const +{ + // row of last cell is needed + SCROW nLastData = GetLastDataPos(); // always including notes, 0 if none + return pAttrArray->GetLastVisibleAttr( rLastRow, nLastData, bSkipEmpty ); +} + +inline bool ScColumn::HasVisibleAttrIn( SCROW nStartRow, SCROW nEndRow ) const +{ + return pAttrArray->HasVisibleAttrIn( nStartRow, nEndRow ); +} + +inline SCSIZE ScColumn::GetPatternCount() const +{ + return pAttrArray->Count(); +} + +inline SCSIZE ScColumn::GetPatternCount( SCROW nRow1, SCROW nRow2 ) const +{ + return pAttrArray->Count( nRow1, nRow2 ); +} + +inline bool ScColumn::ReservePatternCount( SCSIZE nReserve ) +{ + return pAttrArray && pAttrArray->Reserve( nReserve ); +} + +inline bool ScColumn::IsMerged( SCROW nRow ) const +{ + return pAttrArray->IsMerged(nRow); +} + +inline SCROW ScColumnData::GetNextUnprotected( SCROW nRow, bool bUp ) const +{ + return pAttrArray->GetNextUnprotected(nRow, bUp); +} + +inline bool ScColumnData::HasAttrib( SCROW nRow1, SCROW nRow2, HasAttrFlags nMask ) const +{ + return pAttrArray->HasAttrib( nRow1, nRow2, nMask ); +} + +inline bool ScColumnData::HasAttrib( SCROW nRow, HasAttrFlags nMask, SCROW* nStartRow, SCROW* nEndRow ) const +{ + return pAttrArray->HasAttrib( nRow, nMask, nStartRow, nEndRow ); +} + +inline bool ScColumn::ExtendMerge( SCCOL nThisCol, SCROW nStartRow, SCROW nEndRow, + SCCOL& rPaintCol, SCROW& rPaintRow, + bool bRefresh ) +{ + return pAttrArray->ExtendMerge( nThisCol, nStartRow, nEndRow, rPaintCol, rPaintRow, bRefresh ); +} + +inline void ScColumnData::MergePatternArea( ScMergePatternState& rState, SCROW nRow1, SCROW nRow2, bool bDeep ) const +{ + pAttrArray->MergePatternArea( nRow1, nRow2, rState, bDeep ); +} + +inline void ScColumn::MergeBlockFrame( SvxBoxItem* pLineOuter, SvxBoxInfoItem* pLineInner, + ScLineFlags& rFlags, + SCROW nStartRow, SCROW nEndRow, bool bLeft, SCCOL nDistRight ) const +{ + pAttrArray->MergeBlockFrame( pLineOuter, pLineInner, rFlags, nStartRow, nEndRow, bLeft, nDistRight ); +} + +inline void ScColumn::ApplyBlockFrame(const SvxBoxItem& rLineOuter, const SvxBoxInfoItem* pLineInner, + SCROW nStartRow, SCROW nEndRow, bool bLeft, SCCOL nDistRight) +{ + pAttrArray->ApplyBlockFrame(rLineOuter, pLineInner, nStartRow, nEndRow, bLeft, nDistRight); +} + +inline const ScPatternAttr* ScColumnData::GetPattern( SCROW nRow ) const +{ + return pAttrArray->GetPattern( nRow ); +} + +inline const SfxPoolItem& ScColumnData::GetAttr( SCROW nRow, sal_uInt16 nWhich ) const +{ + return pAttrArray->GetPattern( nRow )->GetItemSet().Get(nWhich); +} + +inline const SfxPoolItem& ScColumnData::GetAttr( SCROW nRow, sal_uInt16 nWhich, SCROW& nStartRow, SCROW& nEndRow ) const +{ + return pAttrArray->GetPatternRange( nStartRow, nEndRow, nRow )->GetItemSet().Get(nWhich); +} + +inline sal_uInt32 ScColumnData::GetNumberFormat( const ScInterpreterContext& rContext, SCROW nRow ) const +{ + return pAttrArray->GetPattern( nRow )->GetNumberFormat( rContext.GetFormatTable() ); +} + +inline void ScColumn::AddCondFormat( SCROW nStartRow, SCROW nEndRow, sal_uInt32 nIndex ) +{ + pAttrArray->AddCondFormat( nStartRow, nEndRow, nIndex ); +} + +inline void ScColumn::RemoveCondFormat( SCROW nStartRow, SCROW nEndRow, sal_uInt32 nIndex ) +{ + pAttrArray->RemoveCondFormat( nStartRow, nEndRow, nIndex ); +} + +inline void ScColumnData::ApplyStyleArea( SCROW nStartRow, SCROW nEndRow, const ScStyleSheet& rStyle ) +{ + pAttrArray->ApplyStyleArea(nStartRow, nEndRow, rStyle); +} + +inline const ScStyleSheet* ScColumnData::GetStyle( SCROW nRow ) const +{ + return pAttrArray->GetPattern( nRow )->GetStyleSheet(); +} + +inline void ScColumn::FindStyleSheet( const SfxStyleSheetBase* pStyleSheet, ScFlatBoolRowSegments& rUsedRows, bool bReset ) +{ + pAttrArray->FindStyleSheet( pStyleSheet, rUsedRows, bReset ); +} + +inline bool ScColumn::IsStyleSheetUsed( const ScStyleSheet& rStyle ) const +{ + return pAttrArray->IsStyleSheetUsed( rStyle ); +} + +inline bool ScColumn::ApplyFlags( SCROW nStartRow, SCROW nEndRow, ScMF nFlags ) +{ + return pAttrArray->ApplyFlags( nStartRow, nEndRow, nFlags ); +} + +inline bool ScColumn::RemoveFlags( SCROW nStartRow, SCROW nEndRow, ScMF nFlags ) +{ + return pAttrArray->RemoveFlags( nStartRow, nEndRow, nFlags ); +} + +inline void ScColumn::ClearItems( SCROW nStartRow, SCROW nEndRow, const sal_uInt16* pWhich ) +{ + pAttrArray->ClearItems( nStartRow, nEndRow, pWhich ); +} + +inline const ScPatternAttr* ScColumn::SetPattern( SCROW nRow, std::unique_ptr<ScPatternAttr> pPatAttr ) +{ + return pAttrArray->SetPattern( nRow, std::move(pPatAttr), true/*bPutToPool*/ ); +} + +inline void ScColumn::SetPattern( SCROW nRow, const ScPatternAttr& rPatAttr ) +{ + pAttrArray->SetPattern( nRow, &rPatAttr, true/*bPutToPool*/ ); +} + +inline void ScColumn::SetPatternArea( SCROW nStartRow, SCROW nEndRow, + const ScPatternAttr& rPatAttr ) +{ + pAttrArray->SetPatternArea( nStartRow, nEndRow, &rPatAttr, true/*bPutToPool*/ ); +} + +inline void ScColumnData::SetAttrEntries(std::vector<ScAttrEntry> && vNewData) +{ + pAttrArray->SetAttrEntries( std::move( vNewData )); +} + +inline bool ScColumnData::TestInsertRow( SCSIZE nSize ) const +{ + return pAttrArray->TestInsertRow( nSize ); +} + +inline void ScColumnData::InsertRow( SCROW nStartRow, SCSIZE nSize ) +{ + pAttrArray->InsertRow( nStartRow, nSize ); +} + +inline void ScColumnData::DeleteRow(SCROW nStartRow, SCSIZE nSize) +{ + pAttrArray->DeleteRow( nStartRow, nSize ); +} + +template <typename ApplyDataFunc> +void ScColumnData::Apply(const ScMarkData& rMark, SCCOL nCol, ApplyDataFunc apply) +{ + if (rMark.IsMultiMarked()) + { + ScMultiSelIter aMultiIter(rMark.GetMultiSelData(), nCol); + SCROW nTop, nBottom; + while (aMultiIter.Next(nTop, nBottom)) + apply(*this, nTop, nBottom); + } + else if (rMark.IsMarked()) + { + const ScRange& aRange = rMark.GetMarkArea(); + if (aRange.aStart.Col() <= nCol && nCol <= aRange.aEnd.Col()) + apply(*this, aRange.aStart.Row(), aRange.aEnd.Row()); + } +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/columniterator.hxx b/sc/inc/columniterator.hxx new file mode 100644 index 0000000000..260c13e035 --- /dev/null +++ b/sc/inc/columniterator.hxx @@ -0,0 +1,87 @@ +/* -*- 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/. + */ + +#pragma once + +#include <stddef.h> +#include "address.hxx" +#include <mdds/multi_type_vector/types.hpp> +#include "mtvelements.hxx" +#include <sal/types.h> +#include "types.hxx" +class ScColumn; +class ScDocument; +struct ScRefCellValue; + +class ScColumnTextWidthIterator +{ + const size_t mnEnd; + size_t mnCurPos; + sc::CellTextAttrStoreType::iterator miBlockCur; + sc::CellTextAttrStoreType::iterator miBlockEnd; + sc::celltextattr_block::iterator miDataCur; + sc::celltextattr_block::iterator miDataEnd; + +public: + ScColumnTextWidthIterator(const ScColumnTextWidthIterator&) = delete; + const ScColumnTextWidthIterator& operator=(const ScColumnTextWidthIterator&) = delete; + ScColumnTextWidthIterator(const ScDocument& rDoc, ScColumn& rCol, SCROW nStartRow, + SCROW nEndRow); + + /** + * @param rDoc document instance. + * @param rStartPos position of the first cell from which to start + * iteration. Note that the caller must ensure that this + * position is valid; the constructor does not check its + * validity. + * @param nEndRow end row position. + */ + ScColumnTextWidthIterator(const ScDocument& rDoc, const ScAddress& rStartPos, SCROW nEndRow); + + void next(); + bool hasCell() const; + SCROW getPos() const; + sal_uInt16 getValue() const; + void setValue(sal_uInt16 nVal); + +private: + void init(const ScDocument& rDoc, SCROW nStartRow, SCROW nEndRow); + void getDataIterators(size_t nOffsetInBlock); + void checkEndRow(); +}; + +namespace sc +{ +/** + * This iterator lets you iterate over cells over specified range in a + * single column. It does not modify the state of the cells, and therefore + * is thread safe. + */ +class ColumnIterator +{ + CellStoreType::const_position_type maPos; + CellStoreType::const_position_type maPosEnd; + bool mbComplete; + +public: + ColumnIterator(const CellStoreType& rCells, SCROW nRow1, SCROW nRow2); + + void next(); + + SCROW getRow() const; + + bool hasCell() const; + + mdds::mtv::element_t getType() const; + + ScRefCellValue getCell() const; +}; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/columnset.hxx b/sc/inc/columnset.hxx new file mode 100644 index 0000000000..2ae8ab0106 --- /dev/null +++ b/sc/inc/columnset.hxx @@ -0,0 +1,37 @@ +/* -*- 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/. + */ + +#pragma once + +#include "types.hxx" + +#include <unordered_set> +#include <unordered_map> +#include <vector> + +namespace sc +{ +/** + * Simple container to keep track of sheet - column pair. + */ +class ColumnSet +{ + typedef std::unordered_set<SCCOL> ColsType; + typedef std::unordered_map<SCTAB, ColsType> TabsType; + TabsType maTabs; + +public: + void set(SCTAB nTab, SCCOL nCol); + void getColumns(SCTAB nTab, std::vector<SCCOL>& rCols) const; + bool hasTab(SCTAB nTab) const; + bool empty() const; +}; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/columnspanset.hxx b/sc/inc/columnspanset.hxx new file mode 100644 index 0000000000..5a3dc7645a --- /dev/null +++ b/sc/inc/columnspanset.hxx @@ -0,0 +1,175 @@ +/* -*- 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/. + */ + +#pragma once + +#include "address.hxx" + +#include <optional> +#include <vector> +#include <mdds/flat_segment_tree.hpp> + +class ScDocument; +class ScColumn; +class ScMarkData; +class ScRangeList; +struct ScSheetLimits; + +namespace sc { + +struct ColumnBlockConstPosition; +class SingleColumnSpanSet; + +struct RowSpan +{ + SCROW mnRow1; + SCROW mnRow2; + + RowSpan(SCROW nRow1, SCROW nRow2); +}; + +struct SC_DLLPUBLIC ColRowSpan +{ + SCCOLROW mnStart; + SCCOLROW mnEnd; + + ColRowSpan(SCCOLROW nStart, SCCOLROW nEnd); +}; + +/** + * Structure that stores segments of boolean flags per column, and perform + * custom action on those segments. + */ +class ColumnSpanSet +{ +public: + typedef mdds::flat_segment_tree<SCROW, bool> ColumnSpansType; + +private: + struct ColumnType + { + ColumnSpansType maSpans; + ColumnSpansType::const_iterator miPos; + + ColumnType(SCROW nStart, SCROW nEnd, bool bInit); + ColumnType(const ColumnType& rOther); + }; + + typedef std::vector<std::optional<ColumnType>> TableType; + + std::vector<TableType> maTables; + + ColumnType& getColumn(const ScDocument& rDoc, SCTAB nTab, SCCOL nCol); + +public: + class Action + { + public: + virtual ~Action() = 0; + virtual void startColumn(SCTAB nTab, SCCOL nCol); + virtual void execute(const ScAddress& rPos, SCROW nLength, bool bVal) = 0; + }; + + class ColumnAction + { + public: + virtual ~ColumnAction() = 0; + virtual void startColumn(ScColumn* pCol) = 0; + virtual void execute(SCROW nRow1, SCROW nRow2, bool bVal) = 0; + }; + + ColumnSpanSet(); + ColumnSpanSet(const ColumnSpanSet&) = delete; + ColumnSpanSet& operator=(const ColumnSpanSet&) = delete; + ColumnSpanSet(ColumnSpanSet&&) = default; + ColumnSpanSet& operator=(ColumnSpanSet&&) = default; + ~ColumnSpanSet(); + + void set(const ScDocument& rDoc, SCTAB nTab, SCCOL nCol, SCROW nRow, bool bVal); + void set(const ScDocument& rDoc, SCTAB nTab, SCCOL nCol, SCROW nRow1, SCROW nRow2, bool bVal); + void set(const ScDocument& rDoc, const ScRange& rRange, bool bVal); + + void set(const ScDocument& rDoc, SCTAB nTab, SCCOL nCol, const SingleColumnSpanSet& rSingleSet, bool bVal ); + + /** + * Scan specified range in a specified sheet and mark all non-empty cells + * with specified boolean value. + */ + void scan(const ScDocument& rDoc, SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, bool bVal); + + void executeAction(ScDocument& rDoc, Action& ac) const; + void executeColumnAction(ScDocument& rDoc, ColumnAction& ac) const; +}; + +/** + * Keep track of spans in a single column only. + */ +class SingleColumnSpanSet +{ +public: + typedef mdds::flat_segment_tree<SCROW, bool> ColumnSpansType; + + typedef std::vector<RowSpan> SpansType; + + SingleColumnSpanSet(ScSheetLimits const &); + + /** + * Scan an entire column and tag all non-empty cell positions. + */ + void scan(const ScColumn& rColumn); + + /** + * Scan a column between specified range, and tag all non-empty cell + * positions. + */ + void scan(const ScColumn& rColumn, SCROW nStart, SCROW nEnd); + + void scan( + ColumnBlockConstPosition& rBlockPos, const ScColumn& rColumn, SCROW nStart, SCROW nEnd); + + /** + * Scan all marked data and tag all marked segments in specified column. + */ + void scan(const ScMarkData& rMark, SCTAB nTab, SCCOL nCol); + + void scan(const ScRangeList& rRanges, SCTAB nTab, SCCOL nCol); + + void set(SCROW nRow1, SCROW nRow2, bool bVal); + + void getRows(std::vector<SCROW> &rRows) const; + + void getSpans(SpansType& rSpans) const; + + void swap( SingleColumnSpanSet& r ); + + /** Whether there isn't any row tagged. */ + bool empty() const; + +private: + ScSheetLimits const & mrSheetLimits; + ColumnSpansType maSpans; +}; + +/** + * Optimized ColumnSpanSet version that operates on a single ScRange. + */ +class RangeColumnSpanSet +{ +public: + RangeColumnSpanSet( const ScRange& spanRange ) + : range( spanRange ) {} + void executeColumnAction(ScDocument& rDoc, sc::ColumnSpanSet::ColumnAction& ac) const; +private: + ScRange range; +}; + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/compare.hxx b/sc/inc/compare.hxx new file mode 100644 index 0000000000..bdfca81773 --- /dev/null +++ b/sc/inc/compare.hxx @@ -0,0 +1,81 @@ +/* -*- 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 "queryentry.hxx" + +#include <unotools/textsearch.hxx> +#include <svl/sharedstring.hxx> + +class ScDocument; + +namespace sc { + +struct Compare +{ + struct Cell + { + double mfValue; + svl::SharedString maStr; + bool mbValue; + bool mbEmpty; + + Cell(); + }; + + Cell maCells[2]; + + ScQueryOp meOp; + bool mbIgnoreCase; + + Compare(); +}; + +struct CompareOptions +{ + ScQueryEntry aQueryEntry; + utl::SearchParam::SearchType eSearchType; + bool bMatchWholeCell; + + CompareOptions( const ScDocument& rDoc, const ScQueryEntry& rEntry, utl::SearchParam::SearchType eSrchTyp ); +private: + CompareOptions( const CompareOptions & ) = delete; + CompareOptions& operator=( const CompareOptions & ) = delete; +}; + +/** @param pOptions + Used for comparing two strings, if given. + NULL means that for comparing two strings ScQueryOp rComp.meOp is + tested for SC_EQUAL and SC_NOT_EQUAL, else pOptions->aQueryEntry.eOp + Case sensitivity document option is always to be passed in + rComp.mbIgnoreCase. + */ +double CompareFunc( const Compare& rComp, CompareOptions* pOptions = nullptr ); +double CompareFunc( const Compare::Cell& rCell1, double fCell2, const CompareOptions* pOptions ); +double CompareFunc( double fCell1, double fCell2 ); + +/** + * Left cell is empty while the right cell is numeric. + */ +double CompareEmptyToNumericFunc( double fCell2 ); + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/compiler.hrc b/sc/inc/compiler.hrc new file mode 100644 index 0000000000..f7cb95d6d3 --- /dev/null +++ b/sc/inc/compiler.hrc @@ -0,0 +1,41 @@ +/* -*- 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 <unotools/resmgr.hxx> + +#define NC_(Context, String) TranslateId(Context, u8##String) + +const TranslateId RID_FUNCTION_CATEGORIES[] = +{ + NC_("RID_FUNCTION_CATEGORIES", "Database"), + NC_("RID_FUNCTION_CATEGORIES", "Date&Time"), + NC_("RID_FUNCTION_CATEGORIES", "Financial"), + NC_("RID_FUNCTION_CATEGORIES", "Information"), + NC_("RID_FUNCTION_CATEGORIES", "Logical"), + NC_("RID_FUNCTION_CATEGORIES", "Mathematical"), + NC_("RID_FUNCTION_CATEGORIES", "Array"), + NC_("RID_FUNCTION_CATEGORIES", "Statistical"), + NC_("RID_FUNCTION_CATEGORIES", "Spreadsheet"), + NC_("RID_FUNCTION_CATEGORIES", "Text"), + NC_("RID_FUNCTION_CATEGORIES", "Add-in") +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/compiler.hxx b/sc/inc/compiler.hxx new file mode 100644 index 0000000000..9cff881db6 --- /dev/null +++ b/sc/inc/compiler.hxx @@ -0,0 +1,553 @@ +/* -*- 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 <string.h> + +#include "scdllapi.h" +#include "global.hxx" +#include "refdata.hxx" +#include "token.hxx" +#include <formula/token.hxx> +#include <formula/grammar.hxx> +#include <rtl/ustrbuf.hxx> +#include <com/sun/star/sheet/ExternalLinkInfo.hpp> +#include <com/sun/star/i18n/ParseResult.hpp> +#include <queue> +#include <vector> +#include <memory> +#include <unordered_set> +#include <set> +#include <com/sun/star/uno/Sequence.hxx> +#include <o3tl/typed_flags_set.hxx> + +#include <formula/FormulaCompiler.hxx> + +struct ScSheetLimits; + +// constants and data types also for external modules (ScInterpreter et al) + +#define MAXSTRLEN 1024 /* maximum length of input string of one symbol */ + +// flag values of CharTable +enum class ScCharFlags : sal_uInt32 { + NONE = 0x00000000, + Illegal = 0x00000000, + Char = 0x00000001, + CharBool = 0x00000002, + CharWord = 0x00000004, + CharValue = 0x00000008, + CharString = 0x00000010, + CharDontCare = 0x00000020, + Bool = 0x00000040, + Word = 0x00000080, + WordSep = 0x00000100, + Value = 0x00000200, + ValueSep = 0x00000400, + ValueExp = 0x00000800, + ValueSign = 0x00001000, + ValueValue = 0x00002000, + StringSep = 0x00004000, + NameSep = 0x00008000, // there can be only one! '\'' + CharIdent = 0x00010000, // identifier (built-in function) or reference start + Ident = 0x00020000, // identifier or reference continuation + OdfLBracket = 0x00040000, // ODF '[' reference bracket + OdfRBracket = 0x00080000, // ODF ']' reference bracket + OdfLabelOp = 0x00100000, // ODF '!!' automatic intersection of labels + OdfNameMarker = 0x00200000, // ODF '$$' marker that starts a defined (range) name + CharName = 0x00400000, // start character of a defined name + Name = 0x00800000, // continuation character of a defined name + CharErrConst = 0x01000000, // start character of an error constant ('#') +}; +namespace o3tl { + template<> struct typed_flags<ScCharFlags> : is_typed_flags<ScCharFlags, 0x01ffffff> {}; +} + +#define SC_COMPILER_FILE_TAB_SEP '#' // 'Doc'#Tab + +class ScDocument; +class ScMatrix; +class ScRangeData; +class ScTokenArray; +struct ScInterpreterContext; +class CharClass; + +namespace sc { + +class CompileFormulaContext; + +} + +// constants and data types internal to compiler + +struct ScRawToken final +{ + friend class ScCompiler; + // Friends that use a temporary ScRawToken on the stack (and therefore need + // the private dtor) and know what they're doing... + friend class ScTokenArray; + OpCode eOp; + formula::StackVar eType; // type of data; this determines how the unions are used +public: + union { + double nValue; + struct { + sal_uInt8 nCount; + sal_Unicode cChar; + } whitespace; + struct { + sal_uInt8 cByte; + formula::ParamClass eInForceArray; + } sbyte; + ScComplexRefData aRef; + struct { + sal_uInt16 nFileId; + ScComplexRefData aRef; + } extref; + struct { + sal_uInt16 nFileId; + } extname; + struct { + sal_Int16 nSheet; + sal_uInt16 nIndex; + } name; + struct { + sal_uInt16 nIndex; + ScTableRefToken::Item eItem; + } table; + struct { + rtl_uString* mpData; + rtl_uString* mpDataIgnoreCase; + } sharedstring; + ScMatrix* pMat; + FormulaError nError; + short nJump[ FORMULA_MAXJUMPCOUNT + 1 ]; // If/Chose token + }; + OUString maExternalName; // depending on the opcode, this is either the external, or the external name, or the external table name + + // coverity[uninit_member] - members deliberately not initialized + ScRawToken() {} +private: + ~ScRawToken() {} //! only delete via Delete() +public: + formula::StackVar GetType() const { return eType; } + OpCode GetOpCode() const { return eOp; } + void NewOpCode( OpCode e ) { eOp = e; } + + // Use these methods only on tokens that are not part of a token array, + // since the reference count is cleared! + void SetOpCode( OpCode eCode ); + void SetString( rtl_uString* pData, rtl_uString* pDataIgnoreCase ); + void SetSingleReference( const ScSingleRefData& rRef ); + void SetDoubleReference( const ScComplexRefData& rRef ); + void SetDouble( double fVal ); + void SetErrorConstant( FormulaError nErr ); + + // These methods are ok to use, reference count not cleared. + void SetName(sal_Int16 nSheet, sal_uInt16 nIndex); + void SetExternalSingleRef( sal_uInt16 nFileId, const OUString& rTabName, const ScSingleRefData& rRef ); + void SetExternalDoubleRef( sal_uInt16 nFileId, const OUString& rTabName, const ScComplexRefData& rRef ); + void SetExternalName( sal_uInt16 nFileId, const OUString& rName ); + void SetExternal(const OUString& rStr); + + /** If the token is a non-external reference, determine if the reference is + valid. If the token is an external reference, return true. Else return + false. Used only in ScCompiler::NextNewToken() to preserve non-existing + sheet names in otherwise valid references. + */ + bool IsValidReference(const ScDocument& rDoc) const; + + formula::FormulaToken* CreateToken(ScSheetLimits& rLimits) const; // create typified token +}; + +class SC_DLLPUBLIC ScCompiler final : public formula::FormulaCompiler +{ +public: + + enum ExtendedErrorDetection + { + EXTENDED_ERROR_DETECTION_NONE = 0, // no error on unknown symbols, default (interpreter handles it) + EXTENDED_ERROR_DETECTION_NAME_BREAK, // name error on unknown symbols and break, pCode incomplete + EXTENDED_ERROR_DETECTION_NAME_NO_BREAK // name error on unknown symbols, don't break, continue + }; + + struct SAL_DLLPRIVATE Convention + { + const formula::FormulaGrammar::AddressConvention meConv; + + Convention( formula::FormulaGrammar::AddressConvention eConvP ); + virtual ~Convention(); + + virtual void makeRefStr( + ScSheetLimits& rLimits, + OUStringBuffer& rBuffer, + formula::FormulaGrammar::Grammar eGram, + const ScAddress& rPos, + const OUString& rErrRef, const std::vector<OUString>& rTabNames, + const ScComplexRefData& rRef, bool bSingleRef, bool bFromRangeName ) const = 0; + + virtual css::i18n::ParseResult + parseAnyToken( const OUString& rFormula, + sal_Int32 nSrcPos, + const CharClass* pCharClass, + bool bGroupSeparator) const = 0; + + /** + * Parse the symbol string and pick up the file name and the external + * range name. + * + * @return true on successful parse, or false otherwise. + */ + virtual bool parseExternalName( const OUString& rSymbol, OUString& rFile, OUString& rName, + const ScDocument& rDoc, + const css::uno::Sequence< css::sheet::ExternalLinkInfo>* pExternalLinks ) const = 0; + + virtual OUString makeExternalNameStr( sal_uInt16 nFileId, const OUString& rFile, + const OUString& rName ) const = 0; + + virtual void makeExternalRefStr( + ScSheetLimits& rLimits, + OUStringBuffer& rBuffer, const ScAddress& rPos, sal_uInt16 nFileId, const OUString& rFileName, + const OUString& rTabName, const ScSingleRefData& rRef ) const = 0; + + virtual void makeExternalRefStr( + ScSheetLimits& rLimits, + OUStringBuffer& rBuffer, const ScAddress& rPos, + sal_uInt16 nFileId, const OUString& rFileName, const std::vector<OUString>& rTabNames, + const OUString& rTabName, const ScComplexRefData& rRef ) const = 0; + + enum SpecialSymbolType + { + /** + * Character between sheet name and address. In OOO A1 this is + * '.', while XL A1 and XL R1C1 this is '!'. + */ + SHEET_SEPARATOR, + + /** + * In OOO A1, a sheet name may be prefixed with '$' to indicate an + * absolute sheet position. + */ + ABS_SHEET_PREFIX + }; + virtual sal_Unicode getSpecialSymbol( SpecialSymbolType eSymType ) const = 0; + + virtual ScCharFlags getCharTableFlags( sal_Unicode c, sal_Unicode cLast ) const = 0; + + protected: + std::unique_ptr<ScCharFlags[]> mpCharTable; + }; + friend struct Convention; + +private: + + static const CharClass *pCharClassEnglish; // character classification for en_US locale + static const CharClass *pCharClassLocalized; // character classification for UI locale + static const Convention *pConventions[ formula::FormulaGrammar::CONV_LAST ]; + + static const struct AddInMap + { + const char* pODFF; + const char* pEnglish; + const char* pOriginal; // programmatical name + const char* pUpper; // upper case programmatical name + } g_aAddInMap[]; + static size_t GetAddInMapCount(); + + ScDocument& rDoc; + ScAddress aPos; + + SvNumberFormatter* mpFormatter; + const ScInterpreterContext* mpInterpreterContext; + + SCTAB mnCurrentSheetTab; // indicates current sheet number parsed so far + sal_Int32 mnCurrentSheetEndPos; // position after current sheet name if parsed + + // For CONV_XL_OOX, may be set via API by MOOXML filter. + css::uno::Sequence<css::sheet::ExternalLinkInfo> maExternalLinks; + + sal_Unicode cSymbol[MAXSTRLEN+1]; // current Symbol + 0 + OUString aFormula; // formula source code + sal_Int32 nSrcPos; // tokenizer position (source code) + ScRawToken maRawToken; + + std::queue<OpCode> maPendingOpCodes; // additional opcodes generated from a single symbol + + const CharClass* pCharClass; // which character classification is used for parseAnyToken and upper/lower + bool mbCharClassesDiffer; // whether pCharClass and current system locale's CharClass differ + sal_uInt16 mnPredetectedReference; // reference when reading ODF, 0 (none), 1 (single) or 2 (double) + sal_Int32 mnRangeOpPosInSymbol; // if and where a range operator is in symbol + const Convention *pConv; + ExtendedErrorDetection meExtendedErrorDetection; + bool mbCloseBrackets; // whether to close open brackets automatically, default TRUE + bool mbRewind; // whether symbol is to be rewound to some step during lexical analysis + bool mbRefConventionChartOOXML; // whether to use special ooxml chart syntax in case of OOXML reference convention, + // when parsing a formula string. [0]!GlobalNamedRange, LocalSheet!LocalNamedRange + std::vector<sal_uInt16> maExternalFiles; + + std::vector<OUString> maTabNames; /// sheet names mangled for the current grammar for output + std::vector<OUString> &GetSetupTabNames() const; /// get or setup tab names for the current grammar + + struct TableRefEntry + { + boost::intrusive_ptr<ScTableRefToken> mxToken; + sal_uInt16 mnLevel; + TableRefEntry( ScTableRefToken* p ) : mxToken(p), mnLevel(0) {} + }; + std::vector<TableRefEntry> maTableRefs; /// "stack" of currently active ocTableRef tokens + + // Optimizing implicit intersection is done only at the end of code generation, because the usage context may + // be important. Store candidate parameters and the operation they are the argument for. + struct PendingImplicitIntersectionOptimization + { + PendingImplicitIntersectionOptimization(formula::FormulaToken** p, formula::FormulaToken* o) + : parameterLocation( p ), parameter( *p ), operation( o ) {} + formula::FormulaToken** parameterLocation; + formula::FormulaTokenRef parameter; + formula::FormulaTokenRef operation; + }; + std::vector< PendingImplicitIntersectionOptimization > mPendingImplicitIntersectionOptimizations; + std::unordered_set<formula::FormulaTokenRef> mUnhandledPossibleImplicitIntersections; +#ifdef DBG_UTIL + std::set<OpCode> mUnhandledPossibleImplicitIntersectionsOpCodes; +#endif + + bool NextNewToken(bool bInArray); + bool ToUpperAsciiOrI18nIsAscii( OUString& rUpper, const OUString& rOrg ) const; + + virtual void SetError(FormulaError nError) override; + + struct Whitespace final + { + sal_Int32 nCount; + sal_Unicode cChar; + + Whitespace() : nCount(0), cChar(0x20) {} + void reset( sal_Unicode c ) { nCount = 0; cChar = c; } + }; + + static void addWhitespace( std::vector<ScCompiler::Whitespace> & rvSpaces, + ScCompiler::Whitespace & rSpace, sal_Unicode c, sal_Int32 n = 1 ); + + std::vector<Whitespace> NextSymbol(bool bInArray); + + bool ParseValue( const OUString& ); + bool ParseOpCode( const OUString&, bool bInArray ); + bool ParseOpCode2( std::u16string_view ); + bool ParseString(); + bool ParseReference( const OUString& rSymbol, const OUString* pErrRef = nullptr ); + bool ParseSingleReference( const OUString& rSymbol, const OUString* pErrRef = nullptr ); + bool ParseDoubleReference( const OUString& rSymbol, const OUString* pErrRef = nullptr ); + bool ParsePredetectedReference( const OUString& rSymbol ); + bool ParsePredetectedErrRefReference( const OUString& rName, const OUString* pErrRef ); + bool ParseMacro( const OUString& ); + bool ParseNamedRange( const OUString&, bool onlyCheck = false ); + bool ParseExternalNamedRange( const OUString& rSymbol, bool& rbInvalidExternalNameRange ); + bool ParseDBRange( const OUString& ); + bool ParseColRowName( const OUString& ); + bool ParseBoolean( const OUString& ); + void AutoCorrectParsedSymbol(); + const ScRangeData* GetRangeData( SCTAB& rSheet, const OUString& rUpperName ) const; + + void AdjustSheetLocalNameRelReferences( SCTAB nDelta ); + void SetRelNameReference(); + + /** Obtain range data for ocName token, global or sheet local. + + Prerequisite: rToken is a FormulaIndexToken so IsGlobal() and + GetIndex() can be called on it. We don't check with RTTI. + */ + ScRangeData* GetRangeData( const formula::FormulaToken& pToken ) const; + + bool HasPossibleNamedRangeConflict(SCTAB nTab) const; + +public: + static const CharClass* GetCharClassLocalized(); + static const CharClass* GetCharClassEnglish(); + +public: + ScCompiler( sc::CompileFormulaContext& rCxt, const ScAddress& rPos, + bool bComputeII = false, bool bMatrixFlag = false, const ScInterpreterContext* pContext = nullptr ); + + /** If eGrammar == GRAM_UNSPECIFIED then the grammar of rDocument is used, + */ + ScCompiler( ScDocument& rDocument, const ScAddress&, + formula::FormulaGrammar::Grammar eGrammar = formula::FormulaGrammar::GRAM_UNSPECIFIED, + bool bComputeII = false, bool bMatrixFlag = false, const ScInterpreterContext* pContext = nullptr ); + + ScCompiler( sc::CompileFormulaContext& rCxt, const ScAddress& rPos, ScTokenArray& rArr, + bool bComputeII = false, bool bMatrixFlag = false, const ScInterpreterContext* pContext = nullptr ); + + /** If eGrammar == GRAM_UNSPECIFIED then the grammar of rDocument is used, + */ + ScCompiler( ScDocument& rDocument, const ScAddress&, ScTokenArray& rArr, + formula::FormulaGrammar::Grammar eGrammar = formula::FormulaGrammar::GRAM_UNSPECIFIED, + bool bComputeII = false, bool bMatrixFlag = false, const ScInterpreterContext* pContext = nullptr ); + + virtual ~ScCompiler() override; + +public: + static void DeInit(); /// all + + // for ScAddress::Format() + static void CheckTabQuotes( OUString& aTabName, + const formula::FormulaGrammar::AddressConvention eConv = formula::FormulaGrammar::CONV_OOO ); + + /** Analyzes a string for a 'Doc'#Tab construct, or 'Do''c'#Tab etc... + + @returns the position of the unquoted # hash mark in 'Doc'#Tab, or + -1 if none. */ + static sal_Int32 GetDocTabPos( const OUString& rString ); + + // Check if it is a valid english function name + static bool IsEnglishSymbol( const OUString& rName ); + + bool ParseErrorConstant( const OUString& ); + bool ParseTableRefItem( const OUString& ); + bool ParseTableRefColumn( const OUString& ); + + /** Calls GetToken() if PeekNextNoSpaces() is of given OpCode. */ + bool GetTokenIfOpCode( OpCode eOp ); + + /** + * When auto correction is set, the jump command reorder must be enabled. + */ + void SetAutoCorrection( bool bVal ); + void SetCloseBrackets( bool bVal ) { mbCloseBrackets = bVal; } + void SetRefConventionChartOOXML( bool bVal ) { mbRefConventionChartOOXML = bVal; } + void SetRefConvention( const Convention *pConvP ); + void SetRefConvention( const formula::FormulaGrammar::AddressConvention eConv ); + + static const Convention* GetRefConvention( formula::FormulaGrammar::AddressConvention eConv ); + + /** Overwrite FormulaCompiler::GetOpCodeMap() forwarding to + GetFinalOpCodeMap(). + */ + OpCodeMapPtr GetOpCodeMap( const sal_Int32 nLanguage ) const { return GetFinalOpCodeMap(nLanguage); } + + /// Set symbol map if not empty. + void SetFormulaLanguage( const OpCodeMapPtr & xMap ); + + void SetGrammar( const formula::FormulaGrammar::Grammar eGrammar ); + + void SetNumberFormatter( SvNumberFormatter* pFormatter ); + +private: + /** Set grammar and reference convention from within SetFormulaLanguage() + or SetGrammar(). + + @param eNewGrammar + The new grammar to be set and the associated reference convention. + + @param eOldGrammar + The previous grammar that was active before SetFormulaLanguage(). + */ + void SetGrammarAndRefConvention( + const formula::FormulaGrammar::Grammar eNewGrammar, + const formula::FormulaGrammar::Grammar eOldGrammar ); +public: + + /// Set external link info for ScAddress::CONV_XL_OOX. + void SetExternalLinks( + const css::uno::Sequence< + css::sheet::ExternalLinkInfo>& rLinks ) + { + maExternalLinks = rLinks; + } + + void CreateStringFromXMLTokenArray( OUString& rFormula, OUString& rFormulaNmsp ); + + void SetExtendedErrorDetection( ExtendedErrorDetection eVal ) { meExtendedErrorDetection = eVal; } + + bool IsCorrected() const { return bCorrected; } + const OUString& GetCorrectedFormula() const { return aCorrectedFormula; } + + /** + * Tokenize formula expression string into an array of tokens. + * + * @param rFormula formula expression to tokenize. + * + * @return heap allocated token array object. The caller <i>must</i> + * manage the life cycle of this object. + */ + std::unique_ptr<ScTokenArray> CompileString( const OUString& rFormula ); + std::unique_ptr<ScTokenArray> CompileString( const OUString& rFormula, const OUString& rFormulaNmsp ); + const ScAddress& GetPos() const { return aPos; } + + void MoveRelWrap(); + static void MoveRelWrap( const ScTokenArray& rArr, const ScDocument& rDoc, const ScAddress& rPos, + SCCOL nMaxCol, SCROW nMaxRow ); + + /** If the character is allowed as tested by nFlags (SC_COMPILER_C_... + bits) for all known address conventions. If more than one bit is given + in nFlags, all bits must match. */ + static bool IsCharFlagAllConventions( + OUString const & rStr, sal_Int32 nPos, ScCharFlags nFlags ); + + /** TODO : Move this to somewhere appropriate. */ + static bool DoubleRefToPosSingleRefScalarCase(const ScRange& rRange, ScAddress& rAdr, + const ScAddress& rFormulaPos); + + bool HasUnhandledPossibleImplicitIntersections() const { return !mUnhandledPossibleImplicitIntersections.empty(); } +#ifdef DBG_UTIL + const std::set<OpCode>& UnhandledPossibleImplicitIntersectionsOpCodes() { return mUnhandledPossibleImplicitIntersectionsOpCodes; } +#endif + +private: + // FormulaCompiler + virtual OUString FindAddInFunction( const OUString& rUpperName, bool bLocalFirst ) const override; + virtual void fillFromAddInCollectionUpperName( const NonConstOpCodeMapPtr& xMap ) const override; + virtual void fillFromAddInCollectionEnglishName( const NonConstOpCodeMapPtr& xMap ) const override; + virtual void fillFromAddInMap( const NonConstOpCodeMapPtr& xMap, formula::FormulaGrammar::Grammar _eGrammar ) const override; + virtual void fillAddInToken(::std::vector< css::sheet::FormulaOpCodeMapEntry >& _rVec,bool _bIsEnglish) const override; + + virtual bool HandleExternalReference(const formula::FormulaToken& _aToken) override; + virtual bool HandleRange() override; + virtual bool HandleColRowName() override; + virtual bool HandleDbData() override; + virtual bool HandleTableRef() override; + + virtual formula::FormulaTokenRef ExtendRangeReference( formula::FormulaToken & rTok1, formula::FormulaToken & rTok2 ) override; + virtual void CreateStringFromExternal( OUStringBuffer& rBuffer, const formula::FormulaToken* pToken ) const override; + virtual void CreateStringFromSingleRef( OUStringBuffer& rBuffer, const formula::FormulaToken* pToken ) const override; + virtual void CreateStringFromDoubleRef( OUStringBuffer& rBuffer, const formula::FormulaToken* pToken ) const override; + virtual void CreateStringFromMatrix( OUStringBuffer& rBuffer, const formula::FormulaToken* pToken ) const override; + virtual void CreateStringFromIndex( OUStringBuffer& rBuffer, const formula::FormulaToken* pToken ) const override; + virtual void LocalizeString( OUString& rName ) const override; // modify rName - input: exact name + + virtual formula::ParamClass GetForceArrayParameter( const formula::FormulaToken* pToken, sal_uInt16 nParam ) const override; + + /// Access the CharTable flags + ScCharFlags GetCharTableFlags( sal_Unicode c, sal_Unicode cLast ) + { return c < 128 ? pConv->getCharTableFlags(c, cLast) : ScCharFlags::NONE; } + + virtual void HandleIIOpCode(formula::FormulaToken* token, formula::FormulaToken*** pppToken, sal_uInt8 nNumParams) override; + bool HandleIIOpCodeInternal(formula::FormulaToken* token, formula::FormulaToken*** pppToken, sal_uInt8 nNumParams); + bool SkipImplicitIntersectionOptimization(const formula::FormulaToken* token) const; + virtual void PostProcessCode() override; + virtual void AnnotateOperands() override; + static bool ParameterMayBeImplicitIntersection(const formula::FormulaToken* token, int parameter); + void ReplaceDoubleRefII(formula::FormulaToken** ppDoubleRefTok); + bool AdjustSumRangeShape(const ScComplexRefData& rBaseRange, ScComplexRefData& rSumRange); + void CorrectSumRange(const ScComplexRefData& rBaseRange, ScComplexRefData& rSumRange, formula::FormulaToken** ppSumRangeToken); + void AnnotateTrimOnDoubleRefs(); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/compressedarray.hxx b/sc/inc/compressedarray.hxx new file mode 100644 index 0000000000..0287f24738 --- /dev/null +++ b/sc/inc/compressedarray.hxx @@ -0,0 +1,222 @@ +/* -*- 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 <cstddef> +#include <memory> + +#include "scdllapi.h" + +/** Compressed array of row (or column) entries, e.g. heights, flags, ... + + The array stores ranges of values such that equal consecutive values occupy only + one entry. Initially it consists of one DataEntry with an implied start + row/column of 0 and an end row/column of access type maximum value. + + typename A := access type, e.g. SCROW or SCCOL, must be a POD. + + typename D := data type, e.g. sal_uInt16 or sal_uInt8 or whatever, may also be a + struct or class. + + D::operator==() and D::operator=() must be implemented. Force template + instantiation for a specific type in source/core/data/compressedarray.cxx + + TODO: Currently the allocated memory never shrinks, must manually invoke + Resize() if needed. + */ + +template< typename A, typename D > class ScCompressedArray +{ +public: + class Iterator + { + friend ScCompressedArray; + const ScCompressedArray& mrArray; + size_t mnIndex = 0; + A mnRegion = 0; + Iterator(const ScCompressedArray& rArray) : mrArray(rArray) {} + Iterator(const ScCompressedArray& rArray, size_t nIndex, A nRegion) : mrArray(rArray), mnIndex(nIndex), mnRegion(nRegion) {} + public: + void operator++(); + Iterator operator+(size_t) const; + const D & operator*() const { return mrArray.pData[mnIndex].aValue; } + }; + struct DataEntry + { + A nEnd; // start is end of previous entry + 1 + D aValue; + }; + struct RangeData + { + A mnRow1, mnRow2; + D maValue; + }; + + /** Construct with nMaxAccess=MAXROW, for example. */ + ScCompressedArray( A nMaxAccess, + const D& rValue ); + void Reset( const D& rValue ); + void SetValue( A nPos, const D& rValue ); + void SetValue( A nStart, A nEnd, const D& rValue ); + [[nodiscard]] + const D& GetValue( A nPos ) const; + [[nodiscard]] + A GetLastPos() const { return pData[nCount-1].nEnd; } + + /** Get value for a row, and it's region end row */ + [[nodiscard]] + const D& GetValue( A nPos, size_t& nIndex, A& nEnd ) const; + + /** Get range data for a row, i.e. value and start and end rows with that value */ + [[nodiscard]] + RangeData GetRangeData( A nPos ) const; + + /** Get next value and it's region end row. If nIndex<nCount, nIndex is + incremented first. If the resulting nIndex>=nCount, the value of the + last entry is returned again. */ + [[nodiscard]] + const D& GetNextValue( size_t& nIndex, A& nEnd ) const; + + /** Insert rows before nStart and copy value for inserted rows from + nStart-1, return that value. */ + const D& Insert( A nStart, size_t nCount ); + void InsertPreservingSize( A nStart, size_t nCount, const D& rFillValue ); + + void Remove( A nStart, size_t nCount ); + void RemovePreservingSize( A nStart, size_t nCount, const D& rFillValue ); + + /** Copy rArray.nStart+nSourceDy to this.nStart */ + void CopyFrom( const ScCompressedArray& rArray, + A nStart, A nEnd ) + { CopyFrom(rArray, nStart, nEnd, nStart); } + void CopyFrom( const ScCompressedArray& rArray, + A nDestStart, A nDestEnd, A nSrcStart ); + + // methods public for the coupled array sum methods + /** Obtain index into entries for nPos */ + SC_DLLPUBLIC size_t Search( A nPos ) const; + + Iterator begin() const { return Iterator(*this); } + +protected: + size_t nCount; + size_t nLimit; + std::unique_ptr<DataEntry[]> pData; + A nMaxAccess; +}; + +template< typename A, typename D > +void ScCompressedArray<A,D>::Reset( const D& rValue ) +{ + // Create a temporary copy in case we got a reference passed that points to + // a part of the array to be reallocated. + D aTmpVal( rValue); + nCount = nLimit = 1; + pData.reset(new DataEntry[1]); + pData[0].aValue = aTmpVal; + pData[0].nEnd = nMaxAccess; +} + +template< typename A, typename D > +void ScCompressedArray<A,D>::SetValue( A nPos, const D& rValue ) +{ + SetValue( nPos, nPos, rValue); +} + +template< typename A, typename D > +const D& ScCompressedArray<A,D>::GetValue( A nPos ) const +{ + size_t nIndex = Search( nPos); + return pData[nIndex].aValue; +} + +template< typename A, typename D > +const D& ScCompressedArray<A,D>::GetValue( A nPos, size_t& nIndex, A& nEnd ) const +{ + nIndex = Search( nPos); + nEnd = pData[nIndex].nEnd; + return pData[nIndex].aValue; +} + +template< typename A, typename D > +typename ScCompressedArray<A,D>::RangeData ScCompressedArray<A,D>::GetRangeData( A nPos ) const +{ + size_t nIndex = Search( nPos); + RangeData aData; + aData.mnRow1 = nIndex == 0 ? 0 : pData[nIndex - 1].nEnd + 1; + aData.mnRow2 = pData[nIndex].nEnd; + aData.maValue = pData[nIndex].aValue; + return aData; +} + +template< typename A, typename D > +const D& ScCompressedArray<A,D>::GetNextValue( size_t& nIndex, A& nEnd ) const +{ + if (nIndex < nCount) + ++nIndex; + size_t nEntry = (nIndex < nCount ? nIndex : nCount-1); + nEnd = pData[nEntry].nEnd; + return pData[nEntry].aValue; +} + +// ScBitMaskCompressedArray +/** The data type represents bits, manageable by bitwise operations. + */ + +template< typename A, typename D > class ScBitMaskCompressedArray final : public ScCompressedArray<A,D> +{ +public: + ScBitMaskCompressedArray( A nMaxAccessP, + const D& rValue ) + : ScCompressedArray<A,D>( nMaxAccessP, rValue ) + {} + void AndValue( A nPos, const D& rValueToAnd ); + void OrValue( A nPos, const D& rValueToOr ); + void AndValue( A nStart, A nEnd, const D& rValueToAnd ); + void OrValue( A nStart, A nEnd, const D& rValueToOr ); + + /** Copy values from rArray and bitwise AND them with rValueToAnd. */ + void CopyFromAnded( + const ScBitMaskCompressedArray& rArray, + A nStart, A nEnd, const D& rValueToAnd ); + + /** Return the last row where an entry meets the condition: + ((aValue & rBitMask) != 0), start searching at 0. If no entry + meets this condition, ::std::numeric_limits<A>::max() is returned. */ + A GetLastAnyBitAccess( const D& rBitMask ) const; +}; + +template< typename A, typename D > +void ScBitMaskCompressedArray<A,D>::AndValue( A nPos, const D& rValueToAnd ) +{ + const D& rValue = this->GetValue( nPos); + if ((rValue & rValueToAnd) != rValue) + this->SetValue( nPos, rValue & rValueToAnd); +} + +template< typename A, typename D > +void ScBitMaskCompressedArray<A,D>::OrValue( A nPos, const D& rValueToOr ) +{ + const D& rValue = this->GetValue( nPos); + if ((rValue | rValueToOr) != rValue) + this->SetValue( nPos, rValue | rValueToOr); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/conditio.hxx b/sc/inc/conditio.hxx new file mode 100644 index 0000000000..c3ef00e5cf --- /dev/null +++ b/sc/inc/conditio.hxx @@ -0,0 +1,717 @@ +/* -*- 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 <tools/solar.h> +#include <tools/color.hxx> +#include "address.hxx" +#include <formula/grammar.hxx> +#include "scdllapi.h" +#include "rangelst.hxx" +#include "tokenarray.hxx" + +#include <svl/listener.hxx> + +#include <com/sun/star/sheet/ConditionOperator.hpp> + +#include <rtl/math.hxx> +#include <tools/date.hxx> +#include <tools/link.hxx> + +#include <optional> +#include <map> +#include <memory> +#include <set> + +class RepaintInIdle; +class ScFormulaCell; +class ScTokenArray; +struct ScRefCellValue; + +namespace sc { + +struct RefUpdateContext; +struct RefUpdateInsertTabContext; +struct RefUpdateDeleteTabContext; +struct RefUpdateMoveTabContext; + +} + +// nOptions Flags +#define SC_COND_NOBLANKS 1 + +enum class ScConditionMode +{ + Equal, + Less, + Greater, + EqLess, + EqGreater, + NotEqual, + Between, + NotBetween, + Duplicate, + NotDuplicate, + Direct, + Top10, + Bottom10, + TopPercent, + BottomPercent, + AboveAverage, + BelowAverage, + AboveEqualAverage, + BelowEqualAverage, + Error, + NoError, + BeginsWith, + EndsWith, + ContainsText, + NotContainsText, + NONE +}; + +// For use in SAL_DEBUG etc. Output format not guaranteed to be stable. +template<typename charT, typename traits> +inline std::basic_ostream<charT, traits> & operator <<(std::basic_ostream<charT, traits> & stream, const ScConditionMode& rMode) +{ + switch (rMode) + { + case ScConditionMode::Equal: + stream << "EQUAL"; + break; + case ScConditionMode::Less: + stream << "LESS"; + break; + case ScConditionMode::Greater: + stream << "GREATER"; + break; + case ScConditionMode::EqLess: + stream << "EQLESS"; + break; + case ScConditionMode::EqGreater: + stream << "EQGREATER"; + break; + case ScConditionMode::NotEqual: + stream << "NOTEQUAL"; + break; + case ScConditionMode::Between: + stream << "BETWEEN"; + break; + case ScConditionMode::NotBetween: + stream << "NOTBETWEEN"; + break; + case ScConditionMode::Duplicate: + stream << "DUPLICATE"; + break; + case ScConditionMode::NotDuplicate: + stream << "NOTDUPLICATE"; + break; + case ScConditionMode::Direct: + stream << "DIRECT"; + break; + case ScConditionMode::Top10: + stream << "TOP10"; + break; + case ScConditionMode::Bottom10: + stream << "BOTTOM10"; + break; + case ScConditionMode::TopPercent: + stream << "TOPPERCENT"; + break; + case ScConditionMode::BottomPercent: + stream << "BOTTOMPERCENT"; + break; + case ScConditionMode::AboveAverage: + stream << "ABOVEAVERAGE"; + break; + case ScConditionMode::BelowAverage: + stream << "BELOWAVERAGE"; + break; + case ScConditionMode::AboveEqualAverage: + stream << "ABOVEEQUALAVERAGE"; + break; + case ScConditionMode::BelowEqualAverage: + stream << "BELOWEQUALAVERAGE"; + break; + case ScConditionMode::Error: + stream << "ERROR"; + break; + case ScConditionMode::NoError: + stream << "NOERROR"; + break; + case ScConditionMode::BeginsWith: + stream << "BEGINSWITH"; + break; + case ScConditionMode::EndsWith: + stream << "ENDSWITH"; + break; + case ScConditionMode::ContainsText: + stream << "CONTAINSTEXT"; + break; + case ScConditionMode::NotContainsText: + stream << "NOTCONTAINSTEXT"; + break; + case ScConditionMode::NONE: + stream << "NONE"; + break; + default: + stream << "?(" << static_cast<int>(rMode) << ")"; + break; + } + + return stream; +} + +class ScFormulaListener final : public SvtListener +{ +private: + mutable bool mbDirty; + ScDocument& mrDoc; + std::function<void()> maCallbackFunction; + + void startListening(const ScTokenArray* pTokens, const ScRange& rPos); + void startListening(const ScRangeList& rPos); + +public: + explicit ScFormulaListener(ScFormulaCell* pCell); + explicit ScFormulaListener(ScDocument& rDoc); + explicit ScFormulaListener(ScDocument& rDoc, const ScRangeList& rRange); + virtual ~ScFormulaListener() override; + + void Notify( const SfxHint& rHint ) override; + + bool NeedsRepaint() const; + + void addTokenArray(const ScTokenArray* pTokens, const ScRange& rRange); + void stopListening(); + void setCallback(const std::function<void()>& aCallbackFunction); + +}; + +class ScConditionalFormat; +struct ScDataBarInfo; +struct ScIconSetInfo; + +struct SC_DLLPUBLIC ScCondFormatData +{ + ScCondFormatData(); + ScCondFormatData(ScCondFormatData&&); + ~ScCondFormatData(); + + std::optional<Color> mxColorScale; + std::unique_ptr<ScDataBarInfo> pDataBar; + std::unique_ptr<ScIconSetInfo> pIconSet; + OUString aStyleName; +}; + +class SC_DLLPUBLIC ScFormatEntry +{ +public: + ScFormatEntry(ScDocument* pDoc); + virtual ~ScFormatEntry() {} + + enum class Type + { + Condition, + ExtCondition, + Colorscale, + Databar, + Iconset, + Date + }; + + virtual Type GetType() const = 0; + virtual void UpdateReference( sc::RefUpdateContext& rCxt ) = 0; + virtual void UpdateInsertTab( sc::RefUpdateInsertTabContext& rCxt ) = 0; + virtual void UpdateDeleteTab( sc::RefUpdateDeleteTabContext& rCxt ) = 0; + virtual void UpdateMoveTab( sc::RefUpdateMoveTabContext& rCxt ) = 0; + + virtual ScFormatEntry* Clone( ScDocument* pDoc ) const = 0; + + virtual void SetParent( ScConditionalFormat* pNew ) = 0; + + bool operator==( const ScFormatEntry& ) const; + virtual bool IsEqual( const ScFormatEntry&, bool bIgnoreSrcPos ) const; + + virtual void startRendering(); + virtual void endRendering(); + virtual void updateValues(); +protected: + ScDocument* mpDoc; + +}; + +template<typename charT, typename traits> +inline std::basic_ostream<charT, traits> & operator <<(std::basic_ostream<charT, traits> & stream, const ScFormatEntry::Type& rType) +{ + switch (rType) + { + case ScFormatEntry::Type::Condition: + stream << "Condition"; + break; + case ScFormatEntry::Type::ExtCondition: + stream << "ExtCondition"; + break; + case ScFormatEntry::Type::Colorscale: + stream << "Colorscale"; + break; + case ScFormatEntry::Type::Databar: + stream << "Databar"; + break; + case ScFormatEntry::Type::Iconset: + stream << "Iconset"; + break; + case ScFormatEntry::Type::Date: + stream << "Date"; + break; + default: + stream << "?(" << static_cast<int>(rType) << ")"; + break; + } + return stream; +} + +class approx_less +{ +public: + bool operator() (double nVal1, double nVal2) const + { + if(nVal1 < nVal2 && !rtl::math::approxEqual(nVal1, nVal2)) + return true; + + return false; + } +}; + +class SC_DLLPUBLIC ScConditionEntry : public ScFormatEntry +{ + // stored data: + ScConditionMode eOp; + sal_uInt16 nOptions; + double nVal1; // input or calculated + double nVal2; + OUString aStrVal1; // input or calculated + OUString aStrVal2; + const OUString aStrNmsp1; // namespace to be used on (re)compilation, e.g. in XML import + const OUString aStrNmsp2; // namespace to be used on (re)compilation, e.g. in XML import + const formula::FormulaGrammar::Grammar eTempGrammar1; // grammar to be used on (re)compilation, e.g. in XML import + const formula::FormulaGrammar::Grammar eTempGrammar2; // grammar to be used on (re)compilation, e.g. in XML import + bool bIsStr1; // for recognition of empty strings + bool bIsStr2; + std::unique_ptr<ScTokenArray> pFormula1; // entered formula + std::unique_ptr<ScTokenArray> pFormula2; + ScAddress aSrcPos; // source position for formulas + // temporary data: + OUString aSrcString; // formula source position as text during XML import + std::unique_ptr<ScFormulaCell> pFCell1; + std::unique_ptr<ScFormulaCell> pFCell2; + bool bRelRef1; + bool bRelRef2; + bool bFirstRun; + std::unique_ptr<ScFormulaListener> mpListener; + Type eConditionType; //It can be Condition or ExtCondition + + static void SimplifyCompiledFormula( std::unique_ptr<ScTokenArray>& rFormula, + double& rVal, + bool& rIsStr, + OUString& rStrVal ); + + void MakeCells( const ScAddress& rPos ); + void Compile( const OUString& rExpr1, const OUString& rExpr2, + const OUString& rExprNmsp1, const OUString& rExprNmsp2, + formula::FormulaGrammar::Grammar eGrammar1, + formula::FormulaGrammar::Grammar eGrammar2, + bool bTextToReal ); + void Interpret( const ScAddress& rPos ); + + bool IsValid( double nArg, const ScAddress& rPos ) const; + bool IsValidStr( const OUString& rArg, const ScAddress& rPos ) const; + void StartListening(); + +public: + ScConditionEntry( ScConditionMode eOper, + const OUString& rExpr1, const OUString& rExpr2, + ScDocument& rDocument, const ScAddress& rPos, + const OUString& rExprNmsp1, const OUString& rExprNmsp2, + formula::FormulaGrammar::Grammar eGrammar1, + formula::FormulaGrammar::Grammar eGrammar2, + Type eType = Type::Condition ); + ScConditionEntry( ScConditionMode eOper, + const ScTokenArray* pArr1, const ScTokenArray* pArr2, + ScDocument& rDocument, const ScAddress& rPos ); + ScConditionEntry( const ScConditionEntry& r ); // flat copy of formulas + // true copy of formulas (for Ref-Undo): + ScConditionEntry( ScDocument& rDocument, const ScConditionEntry& r ); + virtual ~ScConditionEntry() override; + + bool IsEqual( const ScFormatEntry& r, bool bIgnoreSrcPos ) const override; + + virtual void SetParent( ScConditionalFormat* pNew ) override; + + bool IsCellValid( ScRefCellValue& rCell, const ScAddress& rPos ) const; + + ScConditionMode GetOperation() const { return eOp; } + void SetOperation(ScConditionMode eMode); + bool IsIgnoreBlank() const { return ( nOptions & SC_COND_NOBLANKS ) == 0; } + void SetIgnoreBlank(bool bSet); + const OUString& GetSrcString() const { return aSrcString; } + const ScAddress& GetSrcPos() const { return aSrcPos; } + + ScAddress GetValidSrcPos() const; // adjusted to allow textual representation of expressions + + void SetSrcString( const OUString& rNew ); // for XML import + + void SetFormula1( const ScTokenArray& rArray ); + void SetFormula2( const ScTokenArray& rArray ); + + OUString GetExpression( const ScAddress& rCursor, sal_uInt16 nPos, sal_uInt32 nNumFmt = 0, + const formula::FormulaGrammar::Grammar eGrammar = formula::FormulaGrammar::GRAM_DEFAULT ) const; + + /** Create a flat copy using ScTokenArray copy-ctor with + shared tokens. */ + std::unique_ptr<ScTokenArray> CreateFlatCopiedTokenArray( sal_uInt16 nPos ) const; + + void CompileAll(); + void CompileXML(); + virtual void UpdateReference( sc::RefUpdateContext& rCxt ) override; + virtual void UpdateInsertTab( sc::RefUpdateInsertTabContext& rCxt ) override; + virtual void UpdateDeleteTab( sc::RefUpdateDeleteTabContext& rCxt ) override; + virtual void UpdateMoveTab( sc::RefUpdateMoveTabContext& rCxt ) override; + + bool MarkUsedExternalReferences() const; + + virtual Type GetType() const override { return eConditionType; } + + virtual ScFormatEntry* Clone(ScDocument* pDoc) const override; + + static ScConditionMode GetModeFromApi(css::sheet::ConditionOperator nOperator); + + virtual void endRendering() override; + virtual void startRendering() override; + + bool NeedsRepaint() const; + void CalcAll(); + +protected: + virtual void DataChanged() const; + ScDocument* GetDocument() const { return mpDoc; } + ScConditionalFormat* pCondFormat; + +private: + + bool IsDuplicate(double nArg, const OUString& rStr) const; + bool IsTopNElement( double nArg ) const; + bool IsTopNPercent( double nArg ) const; + bool IsBottomNElement( double nArg ) const; + bool IsBottomNPercent( double nArg ) const; + bool IsAboveAverage( double nArg, bool bEqual ) const; + bool IsBelowAverage( double nArg, bool bEqual ) const; + + bool IsError( const ScAddress& rPos ) const; + + void FillCache() const; + + struct ScConditionEntryCache + { + typedef std::map<OUString, sal_Int32> StringCacheType; + StringCacheType maStrings; + typedef std::map<double, sal_Int32, approx_less> ValueCacheType; + ValueCacheType maValues; + + // cache them for easier access + size_t nValueItems; + + ScConditionEntryCache(): + nValueItems(0) {} + }; + + mutable std::unique_ptr<ScConditionEntryCache> mpCache; + + std::unique_ptr<RepaintInIdle> mpRepaintTask; +}; + +// single condition entry for conditional formatting +class SC_DLLPUBLIC ScCondFormatEntry final : public ScConditionEntry +{ + OUString aStyleName; + Type eCondFormatType = Type::Condition; + +public: + ScCondFormatEntry( ScConditionMode eOper, + const OUString& rExpr1, const OUString& rExpr2, + ScDocument& rDocument, const ScAddress& rPos, + OUString aStyle, + const OUString& rExprNmsp1 = OUString(), + const OUString& rExprNmsp2 = OUString(), + formula::FormulaGrammar::Grammar eGrammar1 = formula::FormulaGrammar::GRAM_DEFAULT, + formula::FormulaGrammar::Grammar eGrammar2 = formula::FormulaGrammar::GRAM_DEFAULT, + Type eType = Type::Condition); + ScCondFormatEntry( ScConditionMode eOper, + const ScTokenArray* pArr1, const ScTokenArray* pArr2, + ScDocument& rDocument, const ScAddress& rPos, + OUString aStyle ); + ScCondFormatEntry( const ScCondFormatEntry& r ); + ScCondFormatEntry( ScDocument& rDocument, const ScCondFormatEntry& r ); + virtual ~ScCondFormatEntry() override; + + bool IsEqual( const ScFormatEntry& r, bool bIgnoreSrcPos ) const override; + + const OUString& GetStyle() const { return aStyleName; } + void UpdateStyleName(const OUString& rNew) { aStyleName=rNew; } + virtual ScFormatEntry* Clone(ScDocument* pDoc) const override; + virtual Type GetType() const override { return eCondFormatType; } + +private: + virtual void DataChanged() const override; +}; + +namespace condformat { + +enum ScCondFormatDateType +{ + TODAY, + YESTERDAY, + TOMORROW, + LAST7DAYS, + THISWEEK, + LASTWEEK, + NEXTWEEK, + THISMONTH, + LASTMONTH, + NEXTMONTH, + THISYEAR, + LASTYEAR, + NEXTYEAR +}; + +} + +class SC_DLLPUBLIC ScCondDateFormatEntry final : public ScFormatEntry +{ +public: + ScCondDateFormatEntry(ScDocument* pDoc); + ScCondDateFormatEntry(ScDocument* pDoc, const ScCondDateFormatEntry& rEntry); + + bool IsValid( const ScAddress& rPos ) const; + + void SetDateType(condformat::ScCondFormatDateType eType); + condformat::ScCondFormatDateType GetDateType() const { return meType;} + + const OUString& GetStyleName() const { return maStyleName;} + void SetStyleName( const OUString& rStyleName ); + + virtual Type GetType() const override { return Type::Date; } + virtual void UpdateReference( sc::RefUpdateContext& ) override {} + virtual void UpdateInsertTab( sc::RefUpdateInsertTabContext& ) override {} + virtual void UpdateDeleteTab( sc::RefUpdateDeleteTabContext& ) override {} + virtual void UpdateMoveTab( sc::RefUpdateMoveTabContext& ) override {} + + virtual ScFormatEntry* Clone( ScDocument* pDoc ) const override; + + virtual void SetParent( ScConditionalFormat* ) override {} + + virtual void startRendering() override; + virtual void endRendering() override; + +private: + condformat::ScCondFormatDateType meType; + + mutable std::unique_ptr<Date> mpCache; + + OUString maStyleName; +}; + +// complete conditional formatting +class SC_DLLPUBLIC ScConditionalFormat +{ + ScDocument* pDoc; + sal_uInt32 nKey; // Index in attributes + + std::vector<std::unique_ptr<ScFormatEntry>> maEntries; + ScRangeList maRanges; // Ranges for conditional format + +public: + ScConditionalFormat(sal_uInt32 nNewKey, ScDocument* pDocument); + ~ScConditionalFormat(); + ScConditionalFormat(const ScConditionalFormat&) = delete; + const ScConditionalFormat& operator=(const ScConditionalFormat&) = delete; + + // true copy of formulas (for Ref-Undo / between documents) + std::unique_ptr<ScConditionalFormat> Clone(ScDocument* pNewDoc = nullptr) const; + + void AddEntry( ScFormatEntry* pNew ); + void RemoveEntry(size_t nIndex); + void SetRange( const ScRangeList& rRanges ); + const ScRangeList& GetRange() const { return maRanges; } + // don't use the same name as for the const version + ScRangeList& GetRangeList() { return maRanges; } + + bool IsEmpty() const; + size_t size() const; + + ScDocument* GetDocument(); + + void CompileAll(); + void CompileXML(); + void UpdateReference( sc::RefUpdateContext& rCxt, bool bCopyAsMove = false ); + void UpdateInsertTab( sc::RefUpdateInsertTabContext& rCxt ); + void UpdateDeleteTab( sc::RefUpdateDeleteTabContext& rCxt ); + void UpdateMoveTab( sc::RefUpdateMoveTabContext& rCxt ); + + void InsertRow(SCTAB nTab, SCCOL nColStart, SCCOL nColEnd, SCROW nRowStart, SCSIZE nSize); + void InsertCol(SCTAB nTab, SCROW nRowStart, SCROW nRowEnd, SCCOL nColStart, SCSIZE nSize); + + void DeleteArea( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ); + void RenameCellStyle( std::u16string_view rOld, const OUString& rNew ); + + const ScFormatEntry* GetEntry( sal_uInt16 nPos ) const; + + OUString GetCellStyle( ScRefCellValue& rCell, const ScAddress& rPos ) const; + + ScCondFormatData GetData( ScRefCellValue& rCell, const ScAddress& rPos ) const; + + bool EqualEntries( const ScConditionalFormat& r, bool bIgnoreSrcPos = false ) const; + + void DoRepaint(); + + sal_uInt32 GetKey() const { return nKey; } + void SetKey(sal_uInt32 nNew) { nKey = nNew; } // only if not inserted! + + bool MarkUsedExternalReferences() const; + + // sorted (via std::set) by Index + bool operator < ( const ScConditionalFormat& r ) const { return nKey < r.nKey; } + + void startRendering(); + void endRendering(); + + void updateValues(); + + // Forced recalculation for formulas + void CalcAll(); +}; + +class RepaintInIdle final : public Idle +{ + ScConditionalFormat* mpCondFormat; + +public: + RepaintInIdle(ScConditionalFormat* pCondFormat) + : Idle("Conditional Format Repaint Idle") + , mpCondFormat(pCondFormat) + {} + + void Invoke() override + { + if (mpCondFormat) + mpCondFormat->DoRepaint(); + } +}; + +struct CompareScConditionalFormat +{ + using is_transparent = void; + bool operator()(std::unique_ptr<ScConditionalFormat> const& lhs, + std::unique_ptr<ScConditionalFormat> const& rhs) const + { + return (*lhs) < (*rhs); + } + bool operator()(sal_uInt32 nKey, std::unique_ptr<ScConditionalFormat> const& rpFormat) const + { + return nKey < rpFormat->GetKey(); + } + bool operator()(std::unique_ptr<ScConditionalFormat> const& rpFormat, sal_uInt32 nKey) const + { + return rpFormat->GetKey() < nKey; + } +}; + +// List of all conditional formats in a sheet +class SC_DLLPUBLIC ScConditionalFormatList +{ +private: + typedef std::set<std::unique_ptr<ScConditionalFormat>, + CompareScConditionalFormat> ConditionalFormatContainer; + ConditionalFormatContainer m_ConditionalFormats; + + void operator =(ScConditionalFormatList const &) = delete; + +public: + ScConditionalFormatList() {} + ScConditionalFormatList(const ScConditionalFormatList& rList); + ScConditionalFormatList(ScDocument& rDoc, const ScConditionalFormatList& rList); + + void InsertNew( std::unique_ptr<ScConditionalFormat> pNew ); + + /** + * Checks that all cond formats have a non empty range. + * Deletes empty cond formats. Optionally call rLink + * on the empty format before deleting it. + * @return true if all cond formats were valid + */ + bool CheckAllEntries(const Link<ScConditionalFormat*,void>& rLink = Link<ScConditionalFormat*,void>()); + + ScConditionalFormat* GetFormat( sal_uInt32 nKey ); + const ScConditionalFormat* GetFormat( sal_uInt32 nKey ) const; + + void CompileAll(); + void CompileXML(); + void UpdateReference( sc::RefUpdateContext& rCxt ); + void UpdateInsertTab( sc::RefUpdateInsertTabContext& rCxt ); + void UpdateDeleteTab( sc::RefUpdateDeleteTabContext& rCxt ); + void UpdateMoveTab( sc::RefUpdateMoveTabContext& rCxt ); + + void InsertRow(SCTAB nTab, SCCOL nColStart, SCCOL nColEnd, SCROW nRowStart, SCSIZE nSize); + void InsertCol(SCTAB nTab, SCROW nRowStart, SCROW nRowEnd, SCCOL nColStart, SCSIZE nSize); + + void RenameCellStyle( std::u16string_view rOld, const OUString& rNew ); + void DeleteArea( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ); + + typedef ConditionalFormatContainer::iterator iterator; + typedef ConditionalFormatContainer::const_iterator const_iterator; + + ScRangeList GetCombinedRange() const; + + void RemoveFromDocument(ScDocument& rDoc) const; + void AddToDocument(ScDocument& rDoc) const; + + iterator begin(); + const_iterator begin() const; + iterator end(); + const_iterator end() const; + + size_t size() const; + bool empty() const; + + void erase(sal_uLong nIndex); + void clear(); + + void startRendering(); + void endRendering(); + + void updateValues(); + + sal_uInt32 getMaxKey() const; + + /// Forced recalculation of formulas + void CalcAll(); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/confuno.hxx b/sc/inc/confuno.hxx new file mode 100644 index 0000000000..4bec4dcf6c --- /dev/null +++ b/sc/inc/confuno.hxx @@ -0,0 +1,68 @@ +/* -*- 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 <svl/itemprop.hxx> +#include <svl/lstner.hxx> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <cppuhelper/implbase.hxx> + +class ScDocShell; + +class ScDocumentConfiguration final : public cppu::WeakImplHelper< + css::beans::XPropertySet, + css::lang::XServiceInfo>, + public SfxListener +{ +private: + ScDocShell* pDocShell; + SfxItemPropertySet aPropSet; + +public: + ScDocumentConfiguration(ScDocShell* pDocShell); + virtual ~ScDocumentConfiguration() override; + + // SfxListener + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + // XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > + SAL_CALL getPropertySetInfo() override; + virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, + const css::uno::Any& aValue ) override; + virtual css::uno::Any SAL_CALL getPropertyValue( + const OUString& PropertyName ) override; + virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override; + virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override; + virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + + // XServiceInfo + 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; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/consoli.hxx b/sc/inc/consoli.hxx new file mode 100644 index 0000000000..46b952a3e7 --- /dev/null +++ b/sc/inc/consoli.hxx @@ -0,0 +1,91 @@ +/* -*- 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 "global.hxx" +#include "address.hxx" +#include <vector> + +class ScDocument; +class ScFunctionData; + +// Sequence: +// 1) create ScConsData +// 2) Parameter (Size/Flags) +// 3) AddFields for all areas (only needed for bColByName or bRowByName) +// 4) DoneFields ( " " ) +// 5) AddData for all areas +// perhaps AddName after each area +// 6) OutputToDocument + +//! Use structure ScDocument if a certain size is exceeded? + +class ScConsData +{ +private: + struct ScReferenceEntry // without constructor ! + { + SCCOL nCol; + SCROW nRow; + SCTAB nTab; + }; + typedef std::vector<ScReferenceEntry> ScReferenceList; + ScSubTotalFunc eFunction; + bool bReference; + bool bColByName; + bool bRowByName; + SCSIZE nColCount; + SCSIZE nRowCount; + std::unique_ptr<std::unique_ptr<bool[]>[]> ppUsed; + std::unique_ptr<std::unique_ptr<ScFunctionData[]>[]> ppFunctionData; + std::unique_ptr<std::unique_ptr<ScReferenceList[]>[]> ppRefs; + ::std::vector<OUString> maColHeaders; + ::std::vector<OUString> maRowHeaders; + ::std::vector<OUString> maTitles; + SCSIZE nDataCount; + std::unique_ptr<std::unique_ptr<SCSIZE[]>[]> ppTitlePos; + bool bCornerUsed; + OUString aCornerText; // only for bColByName && bRowByName + +public: + ScConsData(); + ~ScConsData(); + + void SetSize( SCCOL nCols, SCROW nRows ); + void SetFlags( ScSubTotalFunc eFunc, bool bColName, bool bRowName, bool bRef ); + + void InitData(); + void DeleteData(); + + void AddFields( const ScDocument* pSrcDoc, SCTAB nTab, + SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ); + void DoneFields(); + + void AddData( ScDocument* pSrcDoc, SCTAB nTab, + SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ); + void AddName( const OUString& rName ); + + void OutputToDocument( ScDocument& rDestDoc, SCCOL nCol, SCROW nRow, SCTAB nTab ); + + void GetSize( SCCOL& rCols, SCROW& rRows ) const; + SCROW GetInsertCount() const; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/convuno.hxx b/sc/inc/convuno.hxx new file mode 100644 index 0000000000..1bae9f9543 --- /dev/null +++ b/sc/inc/convuno.hxx @@ -0,0 +1,116 @@ +/* -*- 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 <algorithm> +#include <i18nlangtag/lang.h> +#include <com/sun/star/table/CellAddress.hpp> +#include <com/sun/star/table/CellRangeAddress.hpp> +#include "address.hxx" + +namespace com::sun::star::lang { struct Locale; } + +class ScUnoConversion +{ +public: + static LanguageType GetLanguage( const css::lang::Locale& rLocale ); + static void FillLocale( css::lang::Locale& rLocale, LanguageType eLang ); + + // CellAddress -> ScAddress + static inline void FillScAddress( + ScAddress& rScAddress, + const css::table::CellAddress& rApiAddress ); + // ScAddress -> CellAddress + static inline void FillApiAddress( + css::table::CellAddress& rApiAddress, + const ScAddress& rScAddress ); + // CellRangeAddress -> ScRange + static inline void FillScRange( + ScRange& rScRange, + const css::table::CellRangeAddress& rApiRange ); + // ScRange -> CellRangeAddress + static inline void FillApiRange( + css::table::CellRangeAddress& rApiRange, + const ScRange& rScRange ); + + /** Returns true, if the passed ranges have at least one common cell. */ + static inline bool Intersects( + const css::table::CellRangeAddress& rApiARange1, + const css::table::CellRangeAddress& rApiARange2 ); + /** Returns true, if the passed range rApiInner is completely inside the passed range rApiOuter. */ + static inline bool Contains( + const css::table::CellRangeAddress& rApiOuter, + const css::table::CellRangeAddress& rApiInner ); +}; + +inline void ScUnoConversion::FillScAddress( + ScAddress& rScAddress, + const css::table::CellAddress& rApiAddress ) +{ + rScAddress.Set( static_cast<SCCOL>(rApiAddress.Column), static_cast<SCROW>(rApiAddress.Row), static_cast<SCTAB>(rApiAddress.Sheet) ); +} + +inline void ScUnoConversion::FillApiAddress( + css::table::CellAddress& rApiAddress, + const ScAddress& rScAddress ) +{ + rApiAddress.Column = rScAddress.Col(); + rApiAddress.Row = rScAddress.Row(); + rApiAddress.Sheet = rScAddress.Tab(); +} + +inline void ScUnoConversion::FillScRange( + ScRange& rScRange, + const css::table::CellRangeAddress& rApiRange ) +{ + rScRange.aStart.Set( static_cast<SCCOL>(rApiRange.StartColumn), static_cast<SCROW>(rApiRange.StartRow), static_cast<SCTAB>(rApiRange.Sheet) ); + rScRange.aEnd.Set( static_cast<SCCOL>(rApiRange.EndColumn), static_cast<SCROW>(rApiRange.EndRow), static_cast<SCTAB>(rApiRange.Sheet) ); +} + +inline void ScUnoConversion::FillApiRange( + css::table::CellRangeAddress& rApiRange, + const ScRange& rScRange ) +{ + rApiRange.StartColumn = rScRange.aStart.Col(); + rApiRange.StartRow = rScRange.aStart.Row(); + rApiRange.Sheet = rScRange.aStart.Tab(); + rApiRange.EndColumn = rScRange.aEnd.Col(); + rApiRange.EndRow = rScRange.aEnd.Row(); +} + +inline bool ScUnoConversion::Intersects( + const css::table::CellRangeAddress& rApiRange1, + const css::table::CellRangeAddress& rApiRange2 ) +{ + return (rApiRange1.Sheet == rApiRange2.Sheet) && + (::std::max( rApiRange1.StartColumn, rApiRange2.StartColumn ) <= ::std::min( rApiRange1.EndColumn, rApiRange2.EndColumn )) && + (::std::max( rApiRange1.StartRow, rApiRange2.StartRow ) <= ::std::min( rApiRange1.EndRow, rApiRange2.EndRow )); +} + +inline bool ScUnoConversion::Contains( + const css::table::CellRangeAddress& rApiOuter, + const css::table::CellRangeAddress& rApiInner ) +{ + return (rApiOuter.Sheet == rApiInner.Sheet) && + (rApiOuter.StartColumn <= rApiInner.StartColumn) && (rApiInner.EndColumn <= rApiOuter.EndColumn) && + (rApiOuter.StartRow <= rApiInner.StartRow) && (rApiInner.EndRow <= rApiOuter.EndRow); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/cursuno.hxx b/sc/inc/cursuno.hxx new file mode 100644 index 0000000000..5ba9403e82 --- /dev/null +++ b/sc/inc/cursuno.hxx @@ -0,0 +1,84 @@ +/* -*- 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 "cellsuno.hxx" +#include <com/sun/star/table/XCellCursor.hpp> +#include <com/sun/star/sheet/XSheetCellCursor.hpp> +#include <com/sun/star/sheet/XUsedAreaCursor.hpp> + +class ScCellCursorObj final : public ScCellRangeObj, + public css::sheet::XSheetCellCursor, + public css::sheet::XUsedAreaCursor, + public css::table::XCellCursor +{ +public: + ScCellCursorObj(ScDocShell* pDocSh, const ScRange& rR); + virtual ~ScCellCursorObj() override; + + virtual css::uno::Any SAL_CALL queryInterface( + const css::uno::Type & rType ) override; + virtual void SAL_CALL acquire() noexcept override; + virtual void SAL_CALL release() noexcept override; + + // XSheetCellCursor + virtual void SAL_CALL collapseToCurrentRegion() override; + virtual void SAL_CALL collapseToCurrentArray() override; + virtual void SAL_CALL collapseToMergedArea() override; + virtual void SAL_CALL expandToEntireColumns() override; + virtual void SAL_CALL expandToEntireRows() override; + virtual void SAL_CALL collapseToSize( sal_Int32 nColumns, sal_Int32 nRows ) override; + + // XUsedAreaCursor + virtual void SAL_CALL gotoStartOfUsedArea( sal_Bool bExpand ) override; + virtual void SAL_CALL gotoEndOfUsedArea( sal_Bool bExpand ) override; + + // XCellCursor + virtual void SAL_CALL gotoStart() override; + virtual void SAL_CALL gotoEnd() override; + virtual void SAL_CALL gotoNext() override; + virtual void SAL_CALL gotoPrevious() override; + virtual void SAL_CALL gotoOffset( sal_Int32 nColumnOffset, sal_Int32 nRowOffset ) override; + + // XSheetCellRange + virtual css::uno::Reference< css::sheet::XSpreadsheet > SAL_CALL + getSpreadsheet() override; + + // XCellRange + virtual css::uno::Reference< css::table::XCell > SAL_CALL + getCellByPosition( sal_Int32 nColumn, sal_Int32 nRow ) override; + virtual css::uno::Reference< css::table::XCellRange > SAL_CALL + getCellRangeByPosition( sal_Int32 nLeft, sal_Int32 nTop, + sal_Int32 nRight, sal_Int32 nBottom ) override; + using ScCellRangeObj::getCellRangeByName; + virtual css::uno::Reference< css::table::XCellRange > SAL_CALL + getCellRangeByName( const OUString& aRange ) override; + + // XServiceInfo + 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; + + // XTypeProvider + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; + virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/dapiuno.hxx b/sc/inc/dapiuno.hxx new file mode 100644 index 0000000000..88c24ce1a4 --- /dev/null +++ b/sc/inc/dapiuno.hxx @@ -0,0 +1,714 @@ +/* -*- 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 "cellsuno.hxx" +#include "dpglobal.hxx" + +#include <svl/lstner.hxx> +#include <svl/itemprop.hxx> + +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/container/XEnumerationAccess.hpp> +#include <com/sun/star/container/XNameContainer.hpp> +#include <com/sun/star/util/XModifyBroadcaster.hpp> + +#include <com/sun/star/sheet/DataPilotFieldGroupInfo.hpp> +#include <com/sun/star/sheet/DataPilotFieldOrientation.hpp> +#include <com/sun/star/sheet/XDataPilotDataLayoutFieldSupplier.hpp> +#include <com/sun/star/sheet/XDataPilotDescriptor.hpp> +#include <com/sun/star/sheet/XDataPilotField.hpp> +#include <com/sun/star/sheet/XDataPilotFieldGrouping.hpp> +#include <com/sun/star/sheet/XDataPilotTable2.hpp> +#include <com/sun/star/sheet/XDataPilotTables.hpp> + +#include <cppuhelper/implbase.hxx> + +#include <memory> +#include <utility> +#include <vector> + +namespace com::sun::star::sheet { struct DataPilotFieldAutoShowInfo; } +namespace com::sun::star::sheet { class XMembersAccess; } +namespace com::sun::star::sheet { struct DataPilotFieldLayoutInfo; } +namespace com::sun::star::sheet { struct DataPilotFieldReference; } +namespace com::sun::star::sheet { struct DataPilotFieldSortInfo; } + + +class ScDocShell; +class ScDPSaveDimension; +struct ScDPNumGroupInfo; + +class ScDataPilotTableObj; +class ScDataPilotFieldObj; +class ScDataPilotItemObj; +enum class ScGeneralFunction; +class ScDPObject; + +class ScDataPilotConversion +{ +public: + static ScGeneralFunction FirstFunc( PivotFunc nBits ); + static PivotFunc FunctionBit( sal_Int16 eFunc ); + + static void FillGroupInfo( + css::sheet::DataPilotFieldGroupInfo& rInfo, + const ScDPNumGroupInfo& rGroupInfo ); +}; + +/** DataPilotTables collection per sheet. */ +class ScDataPilotTablesObj final : public cppu::WeakImplHelper< + css::sheet::XDataPilotTables, + css::container::XEnumerationAccess, + css::container::XIndexAccess, + css::lang::XServiceInfo>, + public SfxListener +{ +private: + ScDocShell* pDocShell; + SCTAB nTab; + + rtl::Reference<ScDataPilotTableObj> GetObjectByIndex_Impl( sal_Int32 nIndex ); + rtl::Reference<ScDataPilotTableObj> GetObjectByName_Impl(const OUString& aName); + +public: + ScDataPilotTablesObj(ScDocShell& rDocSh, SCTAB nT); + virtual ~ScDataPilotTablesObj() override; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + // XDataPilotTables + virtual css::uno::Reference< css::sheet::XDataPilotDescriptor > SAL_CALL + createDataPilotDescriptor() override; + virtual void SAL_CALL insertNewByName( const OUString& aName, + const css::table::CellAddress& aOutputAddress, + const css::uno::Reference< css::sheet::XDataPilotDescriptor >& xDescriptor ) override; + virtual void SAL_CALL removeByName( const OUString& aName ) override; + + // XNameAccess + virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override; + virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override; + + // XIndexAccess + virtual sal_Int32 SAL_CALL getCount() override; + virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override; + + // XEnumerationAccess + virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL + createEnumeration() override; + + // XElementAccess + virtual css::uno::Type SAL_CALL getElementType() override; + virtual sal_Bool SAL_CALL hasElements() override; + + // XServiceInfo + 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; +}; + +// ScDataPilotDescriptorBase is never instantiated directly +class SC_DLLPUBLIC ScDataPilotDescriptorBase : public cppu::WeakImplHelper< + css::sheet::XDataPilotDescriptor, + css::beans::XPropertySet, + css::sheet::XDataPilotDataLayoutFieldSupplier, + css::lang::XServiceInfo>, + public SfxListener +{ +private: + SfxItemPropertySet maPropSet; + ScDocShell* pDocShell; + +public: + ScDataPilotDescriptorBase(ScDocShell& rDocSh); + virtual ~ScDataPilotDescriptorBase() override; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + ScDocShell* GetDocShell() const { return pDocShell; } + + // in the derivatives: + virtual ScDPObject* GetDPObject() const = 0; + virtual void SetDPObject(ScDPObject* pDPObj) = 0; + + // XDataPilotDescriptor + // getName, setName, getTag, setTag in derived classes + + virtual css::table::CellRangeAddress SAL_CALL getSourceRange() override; + virtual void SAL_CALL setSourceRange( const css::table::CellRangeAddress& aSourceRange ) override; + virtual css::uno::Reference< css::sheet::XSheetFilterDescriptor > SAL_CALL + getFilterDescriptor() override; + virtual css::uno::Reference< css::container::XIndexAccess > SAL_CALL + getDataPilotFields() override; + virtual css::uno::Reference< css::container::XIndexAccess > SAL_CALL + getColumnFields() override; + virtual css::uno::Reference< css::container::XIndexAccess > SAL_CALL + getRowFields() override; + virtual css::uno::Reference< css::container::XIndexAccess > SAL_CALL + getPageFields() override; + virtual css::uno::Reference< css::container::XIndexAccess > SAL_CALL + getDataFields() override; + virtual css::uno::Reference< css::container::XIndexAccess > SAL_CALL + getHiddenFields() override; + + // XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > + SAL_CALL getPropertySetInfo( ) override; + virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, + const css::uno::Any& aValue ) override; + virtual css::uno::Any SAL_CALL getPropertyValue( + const OUString& PropertyName ) override; + virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override; + virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override; + virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + + // XDataPilotDataLayoutFieldSupplier + virtual css::uno::Reference< css::sheet::XDataPilotField > + SAL_CALL getDataLayoutField() override; + + // XServiceInfo is in derived classes +}; + +class ScDataPilotDescriptor final : public ScDataPilotDescriptorBase +{ +private: + std::unique_ptr<ScDPObject> mpDPObject; + +public: + ScDataPilotDescriptor(ScDocShell& rDocSh); + virtual ~ScDataPilotDescriptor() override; + + virtual ScDPObject* GetDPObject() const override; + virtual void SetDPObject(ScDPObject* pDPObj) override; + + // rest of XDataPilotDescriptor (incl. XNamed) + virtual OUString SAL_CALL getName() override; + virtual void SAL_CALL setName( const OUString& aName ) override; + virtual OUString SAL_CALL getTag() override; + virtual void SAL_CALL setTag( const OUString& aTag ) override; + + // XServiceInfo + 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; +}; + +class ScDataPilotTableObj final : public ScDataPilotDescriptorBase, + public css::sheet::XDataPilotTable2, + public css::util::XModifyBroadcaster +{ +private: + SCTAB nTab; + OUString aName; + XModifyListenerArr_Impl aModifyListeners; + + void Refreshed_Impl(); + +public: + ScDataPilotTableObj(ScDocShell& rDocSh, SCTAB nT, OUString aN); + virtual ~ScDataPilotTableObj() override; + + virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; + virtual void SAL_CALL acquire() noexcept override; + virtual void SAL_CALL release() noexcept override; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + virtual ScDPObject* GetDPObject() const override; + virtual void SetDPObject(ScDPObject* pDPObj) override; + + // rest of XDataPilotDescriptor (incl. XNamed) + virtual OUString SAL_CALL getName() override; + virtual void SAL_CALL setName( const OUString& aName ) override; + virtual OUString SAL_CALL getTag() override; + virtual void SAL_CALL setTag( const OUString& aTag ) override; + + // XDataPilotTable + virtual css::table::CellRangeAddress SAL_CALL getOutputRange() override; + virtual void SAL_CALL refresh() override; + + // XDataPilotTable2 + virtual css::uno::Sequence< css::uno::Sequence< css::uno::Any > > + SAL_CALL getDrillDownData(const css::table::CellAddress& aAddr) override; + + virtual css::sheet::DataPilotTablePositionData + SAL_CALL getPositionData(const css::table::CellAddress& aAddr) override; + + virtual void SAL_CALL insertDrillDownSheet(const css::table::CellAddress& aAddr) override; + + virtual css::table::CellRangeAddress SAL_CALL getOutputRangeByType( sal_Int32 nType ) override; + + // XModifyBroadcaster + virtual void SAL_CALL addModifyListener( const css::uno::Reference< css::util::XModifyListener >& aListener ) override; + virtual void SAL_CALL removeModifyListener( const css::uno::Reference< css::util::XModifyListener >& aListener ) override; + + // XTypeProvider (override) + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; + virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + + // XServiceInfo + 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; +}; + +struct ScFieldIdentifier +{ + OUString maFieldName; /// Source field name. + sal_Int32 mnFieldIdx; /// Field index (if several fields with same name exist). + bool mbDataLayout; /// True = data layout field collecting all data fields as items. + + explicit ScFieldIdentifier() : + mnFieldIdx( 0 ), mbDataLayout( false ) {} + + explicit ScFieldIdentifier( OUString aFieldName, bool bDataLayout ) : + maFieldName(std::move( aFieldName )), mnFieldIdx( 0 ), mbDataLayout( bDataLayout ) {} +}; + +/** Base class of all implementation objects based on a DataPilot descriptor + or DataPilot table object. Wraps acquiring and releasing the parent. */ +class ScDataPilotChildObjBase +{ +protected: + explicit ScDataPilotChildObjBase( ScDataPilotDescriptorBase& rParent ); + explicit ScDataPilotChildObjBase( ScDataPilotDescriptorBase& rParent, ScFieldIdentifier aFieldId ); + virtual ~ScDataPilotChildObjBase(); + + /** Returns the wrapped DataPilot object (calls GetDPObject() at parent). */ + ScDPObject* GetDPObject() const; + /** Sets the passed DataPilot object (calls SetDPObject() at parent). */ + void SetDPObject( ScDPObject* pDPObject ); + + /** Returns the DataPilot dimension object related to the field described by maFieldId. */ + ScDPSaveDimension* GetDPDimension( ScDPObject** ppDPObject = nullptr ) const; + + /** Returns the number of members for the field described by maFieldId. */ + sal_Int32 GetMemberCount() const; + /** Returns the collection of members for the field described by maFieldId. */ + css::uno::Reference< css::sheet::XMembersAccess > GetMembers() const; + + ScDocShell* GetDocShell() const; +protected: + rtl::Reference<ScDataPilotDescriptorBase> mxParent; + ScFieldIdentifier maFieldId; + +private: + ScDataPilotChildObjBase& operator=( const ScDataPilotChildObjBase& ) = delete; +}; + +typedef ::cppu::WeakImplHelper +< + css::container::XEnumerationAccess, + css::container::XIndexAccess, + css::container::XNameAccess, + css::lang::XServiceInfo +> +ScDataPilotFieldsObjImpl; + +/** Collection of all DataPilot fields, or of all fields from a specific dimension. */ +class ScDataPilotFieldsObj final : public ScDataPilotChildObjBase, public ScDataPilotFieldsObjImpl +{ +public: + explicit ScDataPilotFieldsObj( + ScDataPilotDescriptorBase& rParent ); + + explicit ScDataPilotFieldsObj( + ScDataPilotDescriptorBase& rParent, + css::sheet::DataPilotFieldOrientation eOrient ); + + virtual ~ScDataPilotFieldsObj() override; + + // XNameAccess + virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override; + virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override; + + // XIndexAccess + virtual sal_Int32 SAL_CALL getCount() override; + virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override; + + // XEnumerationAccess + virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL + createEnumeration() override; + + // XElementAccess + virtual css::uno::Type SAL_CALL getElementType() override; + virtual sal_Bool SAL_CALL hasElements() override; + + // XServiceInfo + 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; + +private: + rtl::Reference<ScDataPilotFieldObj> GetObjectByIndex_Impl( sal_Int32 nIndex ) const; + rtl::Reference<ScDataPilotFieldObj> GetObjectByName_Impl( const OUString& rName ) const; + +private: + css::uno::Any maOrient; /// Field orientation, no value = all fields. +}; + +typedef ::cppu::WeakImplHelper +< + css::container::XNamed, + css::beans::XPropertySet, + css::sheet::XDataPilotField, + css::sheet::XDataPilotFieldGrouping, + css::lang::XServiceInfo +> +ScDataPilotFieldObjImpl; + +/** Implementation of a single DataPilot field. */ +class ScDataPilotFieldObj final : public ScDataPilotChildObjBase, public ScDataPilotFieldObjImpl +{ +public: + ScDataPilotFieldObj( + ScDataPilotDescriptorBase& rParent, + const ScFieldIdentifier& rIdent ); + + ScDataPilotFieldObj( + ScDataPilotDescriptorBase& rParent, + const ScFieldIdentifier& rIdent, + css::uno::Any aOrient ); + + virtual ~ScDataPilotFieldObj() override; + + // XNamed + virtual OUString SAL_CALL getName() override; + virtual void SAL_CALL setName(const OUString& aName) override; + + // XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > + SAL_CALL getPropertySetInfo( ) override; + virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, + const css::uno::Any& aValue ) override; + virtual css::uno::Any SAL_CALL getPropertyValue(const OUString& PropertyName ) override; + virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override; + virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override; + virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + + // XDatePilotField + virtual css::uno::Reference<css::container::XIndexAccess> SAL_CALL + getItems() override; + + // only called from property-functions: + css::sheet::DataPilotFieldOrientation getOrientation() const; + void setOrientation(css::sheet::DataPilotFieldOrientation Orientation); + sal_Int16 getFunction() const; + void setFunction(ScGeneralFunction Function); + css::uno::Sequence< sal_Int16 > getSubtotals() const; + void setSubtotals(const std::vector< ScGeneralFunction >& rFunctions); + void setCurrentPage(const OUString& sPage); + void setUseCurrentPage(bool bUse); + const css::sheet::DataPilotFieldAutoShowInfo* getAutoShowInfo() const; + void setAutoShowInfo(const css::sheet::DataPilotFieldAutoShowInfo* pInfo); + const css::sheet::DataPilotFieldLayoutInfo* getLayoutInfo() const; + void setLayoutInfo(const css::sheet::DataPilotFieldLayoutInfo* pInfo); + const css::sheet::DataPilotFieldReference* getReference() const; + void setReference(const css::sheet::DataPilotFieldReference* pInfo); + const css::sheet::DataPilotFieldSortInfo* getSortInfo() const; + void setSortInfo(const css::sheet::DataPilotFieldSortInfo* pInfo); + bool getShowEmpty() const; + void setShowEmpty(bool bShow); + bool getRepeatItemLabels() const; + void setRepeatItemLabels(bool bShow); + + bool hasGroupInfo() const; + css::sheet::DataPilotFieldGroupInfo getGroupInfo(); + void setGroupInfo(const css::sheet::DataPilotFieldGroupInfo* pInfo); + + // XDataPilotFieldGrouping + virtual css::uno::Reference < css::sheet::XDataPilotField > SAL_CALL + createNameGroup(const css::uno::Sequence< OUString >& aItems) override; + virtual css::uno::Reference < css::sheet::XDataPilotField > SAL_CALL + createDateGroup(const css::sheet::DataPilotFieldGroupInfo& rInfo) override; + + // XServiceInfo + 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; + +private: + css::uno::Reference< css::container::XIndexAccess > + mxItems; + SfxItemPropertySet maPropSet; + css::uno::Any maOrient; +}; + +typedef ::std::vector< OUString > ScFieldGroupMembers; + +struct ScFieldGroup +{ + OUString maName; + ScFieldGroupMembers maMembers; +}; + +typedef ::std::vector< ScFieldGroup > ScFieldGroups; + +typedef ::cppu::WeakImplHelper +< + css::container::XNameContainer, + css::container::XEnumerationAccess, + css::container::XIndexAccess, + css::lang::XServiceInfo +> +ScDataPilotFieldGroupsObjImpl; + +/** Implementation of all grouped items in a DataPilot field. + + This is a stand-alone object without any connection to the base DataPilot + field. Grouping info has to be written back with the GroupInfo property of + the DataPilot field after modifying this object. + */ +class ScDataPilotFieldGroupsObj final : public ScDataPilotFieldGroupsObjImpl +{ +public: + explicit ScDataPilotFieldGroupsObj( ScFieldGroups&& rGroups ); + virtual ~ScDataPilotFieldGroupsObj() override; + + // XNameAccess + virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override; + virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override; + + // XNameReplace + virtual void SAL_CALL replaceByName( const OUString& aName, + const css::uno::Any& aElement ) override; + + // XNameContainer + virtual void SAL_CALL insertByName( const OUString& aName, + const css::uno::Any& aElement ) override; + virtual void SAL_CALL removeByName( const OUString& Name ) override; + + // XIndexAccess + virtual sal_Int32 SAL_CALL getCount() override; + virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override; + + // XEnumerationAccess + virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL + createEnumeration() override; + + // XElementAccess + virtual css::uno::Type SAL_CALL getElementType() override; + virtual sal_Bool SAL_CALL hasElements() override; + + // XServiceInfo + 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; + + // implementation + /// @throws css::uno::RuntimeException + ScFieldGroup& getFieldGroup( const OUString& rName ); + /// @throws css::uno::RuntimeException + void renameFieldGroup( const OUString& rOldName, const OUString& rNewName ); + +private: + ScFieldGroups::iterator implFindByName( const OUString& rName ); + +private: + ScFieldGroups maGroups; +}; + +typedef ::cppu::WeakImplHelper +< + css::container::XNameContainer, + css::container::XEnumerationAccess, + css::container::XIndexAccess, + css::container::XNamed, + css::lang::XServiceInfo +> +ScDataPilotFieldGroupObjImpl; + +class ScDataPilotFieldGroupObj final : public ScDataPilotFieldGroupObjImpl +{ +public: + explicit ScDataPilotFieldGroupObj( ScDataPilotFieldGroupsObj& rParent, OUString aGroupName ); + virtual ~ScDataPilotFieldGroupObj() override; + + // XNameAccess + virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override; + virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override; + + // XNameReplace + virtual void SAL_CALL replaceByName( const OUString& aName, + const css::uno::Any& aElement ) override; + + // XNameContainer + virtual void SAL_CALL insertByName( const OUString& aName, + const css::uno::Any& aElement ) override; + virtual void SAL_CALL removeByName( const OUString& Name ) override; + + // XIndexAccess + virtual sal_Int32 SAL_CALL getCount() override; + virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override; + + // XEnumerationAccess + virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL + createEnumeration() override; + + // XElementAccess + virtual css::uno::Type SAL_CALL getElementType() override; + virtual sal_Bool SAL_CALL hasElements() override; + + // XNamed + virtual OUString SAL_CALL getName() override; + virtual void SAL_CALL setName( const OUString& aName ) override; + + // XServiceInfo + 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; + +private: + rtl::Reference<ScDataPilotFieldGroupsObj> mxParent; + OUString maGroupName; +}; + +typedef ::cppu::WeakImplHelper +< + css::container::XNamed, + css::lang::XServiceInfo +> +ScDataPilotFieldGroupItemObjImpl; + +class ScDataPilotFieldGroupItemObj final : public ScDataPilotFieldGroupItemObjImpl +{ +public: + explicit ScDataPilotFieldGroupItemObj( ScDataPilotFieldGroupObj& rParent, OUString aName ); + virtual ~ScDataPilotFieldGroupItemObj() override; + + // XNamed + virtual OUString SAL_CALL getName() override; + virtual void SAL_CALL setName( const OUString& aName ) override; + + // XServiceInfo + 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; + +private: + rtl::Reference<ScDataPilotFieldGroupObj> mxParent; + OUString maName; +}; + +typedef ::cppu::WeakImplHelper +< + css::container::XEnumerationAccess, + css::container::XIndexAccess, + css::container::XNameAccess, + css::lang::XServiceInfo +> +ScDataPilotItemsObjImpl; + +class ScDataPilotItemsObj final : public ScDataPilotChildObjBase, public ScDataPilotItemsObjImpl +{ +public: + explicit ScDataPilotItemsObj( ScDataPilotDescriptorBase& rParent, const ScFieldIdentifier& rFieldId ); + virtual ~ScDataPilotItemsObj() override; + + // XNameAccess + virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override; + virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override; + + // XIndexAccess + virtual sal_Int32 SAL_CALL getCount() override; + virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override; + + // XEnumerationAccess + virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL + createEnumeration() override; + + // XElementAccess + virtual css::uno::Type SAL_CALL getElementType() override; + virtual sal_Bool SAL_CALL hasElements() override; + + // XServiceInfo + 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; + +private: + ScDataPilotItemObj* GetObjectByIndex_Impl( sal_Int32 nIndex ) const; +}; + +typedef ::cppu::WeakImplHelper +< + css::container::XNamed, + css::beans::XPropertySet, + css::lang::XServiceInfo +> +ScDataPilotItemObjImpl; + +class ScDataPilotItemObj final : public ScDataPilotChildObjBase, public ScDataPilotItemObjImpl +{ +public: + explicit ScDataPilotItemObj( + ScDataPilotDescriptorBase& rParent, + const ScFieldIdentifier& rFieldId, + sal_Int32 nIndex ); + + virtual ~ScDataPilotItemObj() override; + + // XNamed + virtual OUString SAL_CALL getName() override; + virtual void SAL_CALL setName( const OUString& aName ) override; + + // XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > + SAL_CALL getPropertySetInfo( ) override; + virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, + const css::uno::Any& aValue ) override; + virtual css::uno::Any SAL_CALL getPropertyValue( + const OUString& PropertyName ) override; + virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override; + virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override; + virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + + // XServiceInfo + 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; + +private: + SfxItemPropertySet maPropSet; + sal_Int32 mnIndex; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/datamapper.hxx b/sc/inc/datamapper.hxx new file mode 100644 index 0000000000..984e6cc812 --- /dev/null +++ b/sc/inc/datamapper.hxx @@ -0,0 +1,114 @@ +/* -*- 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/. + */ + +#pragma once + +#include <vector> + +#include "scdllapi.h" + +#include <rtl/ustring.hxx> + +#include "orcusxml.hxx" + +class ScDocument; + +namespace sc +{ +class ScDBDataManager; +class DataProvider; +class DataTransformation; + +class SC_DLLPUBLIC ExternalDataSource +{ +private: + /** + * The URL for the external data provider. The URL + * will be passed to the data provider together with + * the ID. + * + * A data provider may decide to ignore the URL string. + */ + OUString maURL; + + /** + * The data provider is a unique identifier that will + * allow to identify and instantiate the required data + * provider. + * + * Examples for the internal data providers are: + * + * org.libreoffice.dataprovider.calc.csv + * org.libreoffice.dataprovider.calc.json + * + * Only internal data providers should use the: + * "org.libreoffice.dataprovider prefix". + */ + OUString maProvider; + + /** + * The ID allows the same data provider to support different + * data streams. + * + * A data provider may decide to ignore the ID string. + */ + OUString maID; + + ScOrcusImportXMLParam maParam; + + std::shared_ptr<DataProvider> mpDataProvider; + std::shared_ptr<ScDBDataManager> mpDBDataManager; + + std::vector<std::shared_ptr<sc::DataTransformation>> maDataTransformations; + + ScDocument* mpDoc; + +public: + ExternalDataSource(OUString aURL, OUString aProvider, ScDocument* pDoc); + + void setUpdateFrequency(double nUpdateFrequency); + + void setID(const OUString& rID); + void setURL(const OUString& rURL); + void setProvider(const OUString& rProvider); + void setXMLImportParam(const ScOrcusImportXMLParam& rParam); + + const OUString& getURL() const; + const OUString& getProvider() const; + const OUString& getID() const; + const ScOrcusImportXMLParam& getXMLImportParam() const; + static double getUpdateFrequency(); + OUString getDBName() const; + void setDBData(const OUString& rDBName); + ScDBDataManager* getDBManager(); + + void refresh(ScDocument* pDoc, bool bDeterministic = false); + + void AddDataTransformation(const std::shared_ptr<sc::DataTransformation>& mpDataTransformation); + const std::vector<std::shared_ptr<sc::DataTransformation>>& getDataTransformation() const; +}; + +class SC_DLLPUBLIC ExternalDataMapper +{ + //ScDocument& mrDoc; + std::vector<ExternalDataSource> maDataSources; + +public: + ExternalDataMapper(ScDocument& rDoc); + + ~ExternalDataMapper(); + + void insertDataSource(const ExternalDataSource& rSource); + + const std::vector<ExternalDataSource>& getDataSources() const; + std::vector<ExternalDataSource>& getDataSources(); +}; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/datastreamgettime.hxx b/sc/inc/datastreamgettime.hxx new file mode 100644 index 0000000000..38dbdff121 --- /dev/null +++ b/sc/inc/datastreamgettime.hxx @@ -0,0 +1,37 @@ +/* -*- 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 <sal/config.h> + +namespace sc +{ +enum class DebugTime +{ + Import, + Recalc, + Render, + LAST = Render +}; + +double datastream_get_time(DebugTime nIdx); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/datauno.hxx b/sc/inc/datauno.hxx new file mode 100644 index 0000000000..f2ee6b6741 --- /dev/null +++ b/sc/inc/datauno.hxx @@ -0,0 +1,542 @@ +/* -*- 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 "global.hxx" +#include "queryparam.hxx" +#include "subtotalparam.hxx" + +#include <com/sun/star/sheet/GeneralFunction.hpp> +#include <com/sun/star/sheet/XCellRangeReferrer.hpp> +#include <com/sun/star/sheet/XSheetFilterDescriptor.hpp> +#include <com/sun/star/sheet/XSheetFilterDescriptor2.hpp> +#include <com/sun/star/sheet/XSheetFilterDescriptor3.hpp> +#include <com/sun/star/sheet/XConsolidationDescriptor.hpp> +#include <com/sun/star/sheet/XDatabaseRanges.hpp> +#include <com/sun/star/sheet/XDatabaseRange.hpp> +#include <com/sun/star/sheet/XUnnamedDatabaseRanges.hpp> +#include <com/sun/star/sheet/XSubTotalDescriptor.hpp> +#include <com/sun/star/sheet/XSubTotalField.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/container/XEnumerationAccess.hpp> +#include <com/sun/star/container/XIndexAccess.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/container/XNamed.hpp> +#include <com/sun/star/util/XRefreshable.hpp> +#include <comphelper/servicehelper.hxx> +#include <cppuhelper/implbase.hxx> +#include <rtl/ref.hxx> +#include <svl/itemprop.hxx> +#include <svl/lstner.hxx> + +#include <vector> + +namespace com::sun::star::sheet { struct TableFilterField2; } +namespace com::sun::star::sheet { struct TableFilterField3; } +namespace com::sun::star::sheet { struct TableFilterField; } + +class ScDBData; +class ScDocShell; + +class ScSubTotalFieldObj; +class ScDatabaseRangeObj; +class ScDataPilotDescriptorBase; + +struct ScSortParam; + +class ScDataUnoConversion +{ +public: + static css::sheet::GeneralFunction SubTotalToGeneral( ScSubTotalFunc eSubTotal ); +}; + +// ImportDescriptor is not available as Uno-object any longer, only Property-Sequence + +class ScImportDescriptor +{ +public: + static void FillImportParam( + ScImportParam& rParam, + const css::uno::Sequence<css::beans::PropertyValue>& rSeq ); + static void FillProperties( + css::uno::Sequence<css::beans::PropertyValue>& rSeq, + const ScImportParam& rParam ); + static tools::Long GetPropertyCount() { return 4; } +}; + +// SortDescriptor is not available as Uno-object any longer, only Property-Sequence + +class ScSortDescriptor +{ +public: + static void FillSortParam( + ScSortParam& rParam, + const css::uno::Sequence<css::beans::PropertyValue>& rSeq ); + static void FillProperties( + css::uno::Sequence<css::beans::PropertyValue>& rSeq, + const ScSortParam& rParam ); + //! SortAscending needs to get out of the SheetSortDescriptor service description + static tools::Long GetPropertyCount() + { + return 9; // TableSortDescriptor and SheetSortDescriptor + } + +}; + +// ScSubTotalDescriptorBase - base class for SubTotalDescriptor stand alone and in DB area (context?) + +// to uno, both look the same + +class ScSubTotalDescriptorBase : public cppu::WeakImplHelper< + css::sheet::XSubTotalDescriptor, + css::container::XEnumerationAccess, + css::container::XIndexAccess, + css::beans::XPropertySet, + css::lang::XServiceInfo > +{ +private: + SfxItemPropertySet aPropSet; + + rtl::Reference<ScSubTotalFieldObj> GetObjectByIndex_Impl(sal_uInt16 nIndex); + +public: + ScSubTotalDescriptorBase(); + virtual ~ScSubTotalDescriptorBase() override; + + // in derived classes: + // (Fields are within the range) + virtual void GetData( ScSubTotalParam& rParam ) const = 0; + virtual void PutData( const ScSubTotalParam& rParam ) = 0; + + // XSubTotalDescriptor + virtual void SAL_CALL addNew( const css::uno::Sequence< css::sheet::SubTotalColumn >& aSubTotalColumns, + sal_Int32 nGroupColumn ) override; + virtual void SAL_CALL clear() override; + + // XIndexAccess + virtual sal_Int32 SAL_CALL getCount() override; + virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override; + + // XEnumerationAccess + virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL + createEnumeration() override; + + // XElementAccess + virtual css::uno::Type SAL_CALL getElementType() override; + virtual sal_Bool SAL_CALL hasElements() override; + + // XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > + SAL_CALL getPropertySetInfo() override; + virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, + const css::uno::Any& aValue ) override; + virtual css::uno::Any SAL_CALL getPropertyValue( + const OUString& PropertyName ) override; + virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override; + virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override; + virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + + // XServiceInfo + 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; +}; + +// ScSubTotalDescriptor - dummy container to use with XImportTarget + +class ScSubTotalDescriptor final : public ScSubTotalDescriptorBase +{ +private: + ScSubTotalParam aStoredParam; + +public: + ScSubTotalDescriptor(); + virtual ~ScSubTotalDescriptor() override; + + // from ScSubTotalDescriptorBase: + virtual void GetData( ScSubTotalParam& rParam ) const override; + virtual void PutData( const ScSubTotalParam& rParam ) override; + + // external access: + void SetParam( const ScSubTotalParam& rNew ); +}; + +// ScRangeSubTotalDescriptor - SubTotalDescriptor of a data base area + +class ScRangeSubTotalDescriptor final : public ScSubTotalDescriptorBase +{ +private: + rtl::Reference<ScDatabaseRangeObj> mxParent; + +public: + ScRangeSubTotalDescriptor(ScDatabaseRangeObj* pPar); + virtual ~ScRangeSubTotalDescriptor() override; + + // from ScSubTotalDescriptorBase: + virtual void GetData( ScSubTotalParam& rParam ) const override; + virtual void PutData( const ScSubTotalParam& rParam ) override; +}; + +class ScSubTotalFieldObj final : public cppu::WeakImplHelper< + css::sheet::XSubTotalField, + css::lang::XServiceInfo > +{ +private: + rtl::Reference<ScSubTotalDescriptorBase> xParent; + sal_uInt16 nPos; + +public: + ScSubTotalFieldObj( ScSubTotalDescriptorBase* pDesc, sal_uInt16 nP ); + virtual ~ScSubTotalFieldObj() override; + + // XSubTotalField + virtual sal_Int32 SAL_CALL getGroupColumn() override; + virtual void SAL_CALL setGroupColumn( sal_Int32 nGroupColumn ) override; + virtual css::uno::Sequence< css::sheet::SubTotalColumn > SAL_CALL + getSubTotalColumns() override; + virtual void SAL_CALL setSubTotalColumns( const css::uno::Sequence< + css::sheet::SubTotalColumn >& aSubTotalColumns ) override; + + // XServiceInfo + 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; +}; + +class ScConsolidationDescriptor final : public cppu::WeakImplHelper< + css::sheet::XConsolidationDescriptor, + css::lang::XServiceInfo > +{ +private: + ScConsolidateParam aParam; + +public: + ScConsolidationDescriptor(); + virtual ~ScConsolidationDescriptor() override; + + void SetParam( const ScConsolidateParam& rNew ); + const ScConsolidateParam& GetParam() const { return aParam; } + + // XConsolidationDescriptor + virtual css::sheet::GeneralFunction SAL_CALL getFunction() override; + virtual void SAL_CALL setFunction( css::sheet::GeneralFunction nFunction ) override; + virtual css::uno::Sequence< css::table::CellRangeAddress > SAL_CALL + getSources( ) override; + virtual void SAL_CALL setSources( const css::uno::Sequence< css::table::CellRangeAddress >& aSources ) override; + virtual css::table::CellAddress SAL_CALL getStartOutputPosition() override; + virtual void SAL_CALL setStartOutputPosition( + const css::table::CellAddress& aStartOutputPosition ) override; + virtual sal_Bool SAL_CALL getUseColumnHeaders() override; + virtual void SAL_CALL setUseColumnHeaders( sal_Bool bUseColumnHeaders ) override; + virtual sal_Bool SAL_CALL getUseRowHeaders() override; + virtual void SAL_CALL setUseRowHeaders( sal_Bool bUseRowHeaders ) override; + virtual sal_Bool SAL_CALL getInsertLinks() override; + virtual void SAL_CALL setInsertLinks( sal_Bool bInsertLinks ) override; + + // XServiceInfo + 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; +}; + +// ScFilterDescriptorBase - base class for FilterDescriptor +// stand alone, in a DB area (or context?) and in the DataPilot + +// to uno, all three look the same + +class ScFilterDescriptorBase : public cppu::WeakImplHelper< + css::sheet::XSheetFilterDescriptor, + css::sheet::XSheetFilterDescriptor2, + css::sheet::XSheetFilterDescriptor3, + css::beans::XPropertySet, + css::lang::XServiceInfo >, + public SfxListener +{ +private: + SfxItemPropertySet aPropSet; + ScDocShell* pDocSh; + +public: + ScFilterDescriptorBase(ScDocShell* pDocShell); + virtual ~ScFilterDescriptorBase() override; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + // in the derived classes(?): + // (nField[] here within the area) + virtual void GetData( ScQueryParam& rParam ) const = 0; + virtual void PutData( const ScQueryParam& rParam ) = 0; + + // XSheetFilterDescriptor + virtual css::uno::Sequence< css::sheet::TableFilterField > SAL_CALL + getFilterFields() override; + virtual void SAL_CALL setFilterFields( const css::uno::Sequence< + css::sheet::TableFilterField >& aFilterFields ) override; + + // XSheetFilterDescriptor2 + virtual css::uno::Sequence< css::sheet::TableFilterField2 > SAL_CALL + getFilterFields2() override; + virtual void SAL_CALL setFilterFields2( const css::uno::Sequence< + css::sheet::TableFilterField2 >& aFilterFields ) override; + + // XSheetFilterDescriptor3 + virtual css::uno::Sequence< css::sheet::TableFilterField3 > SAL_CALL + getFilterFields3() override; + virtual void SAL_CALL setFilterFields3( const css::uno::Sequence< + css::sheet::TableFilterField3 >& aFilterFields ) override; + + // XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > + SAL_CALL getPropertySetInfo() override; + virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, + const css::uno::Any& aValue ) override; + virtual css::uno::Any SAL_CALL getPropertyValue( + const OUString& PropertyName ) override; + virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< + css::beans::XPropertyChangeListener >& xListener ) override; + virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< + css::beans::XPropertyChangeListener >& aListener ) override; + virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< + css::beans::XVetoableChangeListener >& aListener ) override; + virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< + css::beans::XVetoableChangeListener >& aListener ) override; + + // XServiceInfo + 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; +}; + +// ScFilterDescriptor - dummy container to use with XFilterable + +class ScFilterDescriptor final : public ScFilterDescriptorBase +{ +private: + ScQueryParam aStoredParam; // nField[] here within the area + +public: + ScFilterDescriptor(ScDocShell* pDocSh); + virtual ~ScFilterDescriptor() override; + + // from ScFilterDescriptorBase: + virtual void GetData( ScQueryParam& rParam ) const override; + virtual void PutData( const ScQueryParam& rParam ) override; + + // external access: + void SetParam( const ScQueryParam& rNew ); + const ScQueryParam& GetParam() const { return aStoredParam; } +}; + +// ScRangeFilterDescriptor - FilterDescriptor of a data base area + +class ScRangeFilterDescriptor final : public ScFilterDescriptorBase +{ +private: + rtl::Reference<ScDatabaseRangeObj> mxParent; + +public: + ScRangeFilterDescriptor(ScDocShell* pDocSh, ScDatabaseRangeObj* pPar); + virtual ~ScRangeFilterDescriptor() override; + + // from ScFilterDescriptorBase: + virtual void GetData( ScQueryParam& rParam ) const override; + virtual void PutData( const ScQueryParam& rParam ) override; +}; + +// ScDataPilotFilterDescriptor - FilterDescriptor of a DataPilotDescriptors + +class ScDataPilotFilterDescriptor final : public ScFilterDescriptorBase +{ +private: + rtl::Reference<ScDataPilotDescriptorBase> mxParent; + +public: + ScDataPilotFilterDescriptor(ScDocShell* pDocSh, ScDataPilotDescriptorBase* pPar); + virtual ~ScDataPilotFilterDescriptor() override; + + // from ScFilterDescriptorBase: + virtual void GetData( ScQueryParam& rParam ) const override; + virtual void PutData( const ScQueryParam& rParam ) override; +}; + +class ScDatabaseRangeObj final : public cppu::WeakImplHelper< + css::sheet::XDatabaseRange, + css::util::XRefreshable, + css::container::XNamed, + css::sheet::XCellRangeReferrer, + css::beans::XPropertySet, + css::lang::XServiceInfo >, + public SfxListener +{ +private: + ScDocShell* pDocShell; + OUString aName; + SfxItemPropertySet aPropSet; + std::vector< css::uno::Reference< css::util::XRefreshListener > > + aRefreshListeners; + bool bIsUnnamed; + SCTAB aTab; + +private: + ScDBData* GetDBData_Impl() const; + void Refreshed_Impl(); + +public: + ScDatabaseRangeObj(ScDocShell* pDocSh, OUString aNm); + SC_DLLPUBLIC ScDatabaseRangeObj(ScDocShell* pDocSh, const SCTAB nTab); + virtual ~ScDatabaseRangeObj() override; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + // nField[] here within the area: + void GetQueryParam(ScQueryParam& rQueryParam) const; + void SetQueryParam(const ScQueryParam& rQueryParam); + void GetSubTotalParam(ScSubTotalParam& rSubTotalParam) const; + void SetSubTotalParam(const ScSubTotalParam& rSubTotalParam); + + // XNamed + virtual OUString SAL_CALL getName() override; + virtual void SAL_CALL setName( const OUString& aName ) override; + + // XDatabaseRange + virtual css::table::CellRangeAddress SAL_CALL getDataArea() override; + virtual void SAL_CALL setDataArea( const css::table::CellRangeAddress& aDataArea ) override; + virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL + getSortDescriptor() override; + virtual css::uno::Reference< css::sheet::XSheetFilterDescriptor > SAL_CALL + getFilterDescriptor() override; + virtual css::uno::Reference< css::sheet::XSubTotalDescriptor > SAL_CALL + getSubTotalDescriptor() override; + virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL + getImportDescriptor() override; + + // XRefreshable + virtual void SAL_CALL refresh() override; + virtual void SAL_CALL addRefreshListener( const css::uno::Reference< + css::util::XRefreshListener >& l ) override; + virtual void SAL_CALL removeRefreshListener( const css::uno::Reference< + css::util::XRefreshListener >& l ) override; + + // XCellRangeReferrer + virtual css::uno::Reference< css::table::XCellRange > SAL_CALL + getReferredCells() override; + + // XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > + SAL_CALL getPropertySetInfo() override; + virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, + const css::uno::Any& aValue ) override; + virtual css::uno::Any SAL_CALL getPropertyValue( + const OUString& PropertyName ) override; + virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< + css::beans::XPropertyChangeListener >& xListener ) override; + virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< + css::beans::XPropertyChangeListener >& aListener ) override; + virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< + css::beans::XVetoableChangeListener >& aListener ) override; + virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< + css::beans::XVetoableChangeListener >& aListener ) override; + + // XServiceInfo + 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; +}; + +class ScDatabaseRangesObj final : public cppu::WeakImplHelper< + css::sheet::XDatabaseRanges, + css::container::XEnumerationAccess, + css::container::XIndexAccess, + css::lang::XServiceInfo >, + public SfxListener +{ +private: + ScDocShell* pDocShell; + + rtl::Reference<ScDatabaseRangeObj> GetObjectByIndex_Impl(size_t nIndex); + rtl::Reference<ScDatabaseRangeObj> GetObjectByName_Impl(const OUString& aName); + +public: + ScDatabaseRangesObj(ScDocShell* pDocSh); + virtual ~ScDatabaseRangesObj() override; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + // XDatabaseRanges + virtual void SAL_CALL addNewByName( const OUString& aName, + const css::table::CellRangeAddress& aRange ) override; + virtual void SAL_CALL removeByName( const OUString& aName ) override; + + // XEnumerationAccess + virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL + createEnumeration() override; + + // XIndexAccess + virtual sal_Int32 SAL_CALL getCount() override; + virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override; + + // XElementAccess + virtual css::uno::Type SAL_CALL getElementType() override; + virtual sal_Bool SAL_CALL hasElements() override; + + // XNameAccess + virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override; + virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override; + + // XServiceInfo + 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; +}; + +class ScUnnamedDatabaseRangesObj final : public cppu::WeakImplHelper< + css::sheet::XUnnamedDatabaseRanges>, + public SfxListener +{ +private: + ScDocShell* pDocShell; + +public: + ScUnnamedDatabaseRangesObj(ScDocShell* pDocSh); + virtual ~ScUnnamedDatabaseRangesObj() override; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + // XUnnamedDatabaseRanges + virtual void SAL_CALL setByTable( const css::table::CellRangeAddress& aRange ) override; + virtual css::uno::Any SAL_CALL getByTable( sal_Int32 nTab ) override; + virtual sal_Bool SAL_CALL hasByTable( sal_Int32 nTab ) override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/dbdata.hxx b/sc/inc/dbdata.hxx new file mode 100644 index 0000000000..df235ec526 --- /dev/null +++ b/sc/inc/dbdata.hxx @@ -0,0 +1,356 @@ +/* -*- 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 "scdllapi.h" +#include "refreshtimer.hxx" +#include "address.hxx" +#include "global.hxx" +#include "rangelst.hxx" + +#include <svl/listener.hxx> + +#include <memory> +#include <set> +#include <vector> + +class ScDocument; +struct ScSortParam; +struct ScQueryParam; +struct ScSubTotalParam; + +/** Enum used to indicate which portion of the DBArea is to be considered. */ +enum class ScDBDataPortion +{ + TOP_LEFT, ///< top left cell of area + AREA ///< entire area +}; + +struct TableColumnAttributes +{ + std::optional<OUString> maTotalsFunction = std::nullopt; +}; + +/** Container base class to provide selected access for ScDBData. */ +class ScDBDataContainerBase +{ +public: + ScDBDataContainerBase( ScDocument& rDoc ) : mrDoc(rDoc) {} + virtual ~ScDBDataContainerBase() {} + ScDocument& GetDocument() const; + ScRangeList& GetDirtyTableColumnNames(); + +protected: + ScDocument& mrDoc; + ScRangeList maDirtyTableColumnNames; +}; + +class SAL_DLLPUBLIC_RTTI ScDBData final : public SvtListener, public ScRefreshTimer +{ +private: + std::unique_ptr<ScSortParam> mpSortParam; + std::unique_ptr<ScQueryParam> mpQueryParam; + std::unique_ptr<ScSubTotalParam> mpSubTotal; + std::unique_ptr<ScImportParam> mpImportParam; + + ScDBDataContainerBase* mpContainer; + + /// DBParam + const OUString aName; + OUString aUpper; + SCTAB nTable; + SCCOL nStartCol; + SCROW nStartRow; + SCCOL nEndCol; + SCROW nEndRow; + bool bByRow; + bool bHasHeader; + bool bHasTotals; + bool bDoSize; + bool bKeepFmt; + bool bStripData; + + /// QueryParam + bool bIsAdvanced; ///< true if created by advanced filter + ScRange aAdvSource; ///< source range + + bool bDBSelection; ///< not in Param: if selection, block update + + sal_uInt16 nIndex; ///< unique index formulas + bool bAutoFilter; ///< AutoFilter? (not saved) + bool bModified; ///< is set/cleared for/by(?) UpdateReference + + ::std::vector< OUString > maTableColumnNames; ///< names of table columns + ::std::vector< TableColumnAttributes > maTableColumnAttributes; ///< attributes of table columns + bool mbTableColumnNamesDirty; + SCSIZE nFilteredRowCount; + + using ScRefreshTimer::operator==; + +public: + struct less + { + bool operator() (const std::unique_ptr<ScDBData>& left, const std::unique_ptr<ScDBData>& right) const; + }; + + SC_DLLPUBLIC ScDBData(const OUString& rName, + SCTAB nTab, + SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, + bool bByR = true, bool bHasH = true, bool bTotals = false); + ScDBData(const ScDBData& rData); + ScDBData(const OUString& rName, const ScDBData& rData); + SC_DLLPUBLIC virtual ~ScDBData() override; + + virtual void Notify( const SfxHint& rHint ) override; + + ScDBData& operator= (const ScDBData& rData) ; + + bool operator== (const ScDBData& rData) const; + + const OUString& GetName() const { return aName; } + const OUString& GetUpperName() const { return aUpper; } + SCTAB GetTab() const { return nTable; } + void GetArea(SCTAB& rTab, SCCOL& rCol1, SCROW& rRow1, SCCOL& rCol2, SCROW& rRow2) const; + SC_DLLPUBLIC void GetArea(ScRange& rRange) const; + void SetArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2); + void MoveTo(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, + SCCOL nUpdateCol = -1); + void SetByRow(bool bByR) { bByRow = bByR; } + bool HasHeader() const { return bHasHeader; } + void SetHeader(bool bHasH) { bHasHeader = bHasH; } + bool HasTotals() const { return bHasTotals; } + void SetTotals(bool bTotals) { bHasTotals = bTotals; } + void SetIndex(sal_uInt16 nInd) { nIndex = nInd; } + sal_uInt16 GetIndex() const { return nIndex; } + bool IsDoSize() const { return bDoSize; } + void SetDoSize(bool bSet) { bDoSize = bSet; } + bool IsKeepFmt() const { return bKeepFmt; } + void SetKeepFmt(bool bSet) { bKeepFmt = bSet; } + bool IsStripData() const { return bStripData; } + void SetStripData(bool bSet) { bStripData = bSet; } + + void SetContainer( ScDBDataContainerBase* pContainer ) { mpContainer = pContainer; } + /** Returns header row range if has headers, else invalid range. */ + ScRange GetHeaderArea() const; + void StartTableColumnNamesListener(); + void EndTableColumnNamesListener(); + SC_DLLPUBLIC void SetTableColumnNames( ::std::vector< OUString >&& rNames ); + SC_DLLPUBLIC const ::std::vector< OUString >& GetTableColumnNames() const { return maTableColumnNames; } + SC_DLLPUBLIC void SetTableColumnAttributes( ::std::vector< TableColumnAttributes >&& rAttributes ); + SC_DLLPUBLIC const ::std::vector< TableColumnAttributes >& GetTableColumnAttributes() const { return maTableColumnAttributes; } + bool AreTableColumnNamesDirty() const { return mbTableColumnNamesDirty; } + + /** Refresh/update the column names with the header row's cell contents. */ + SC_DLLPUBLIC void RefreshTableColumnNames( ScDocument* pDoc ); + + /** Refresh/update the column names with the header row's cell contents + within the given range. */ + void RefreshTableColumnNames( ScDocument* pDoc, const ScRange& rRange ); + + /** Finds the column named rName and returns the corresponding offset + within the table. + @returns -1 if not found. + + XXX NOTE: there is no refresh of names or anything implemented yet, use + this only during document load time. + */ + sal_Int32 GetColumnNameOffset( const OUString& rName ) const; + + /** Returns table column name if nCol is within column range and name + is stored, else empty string. */ + OUString GetTableColumnName( SCCOL nCol ) const; + + OUString GetSourceString() const; + OUString GetOperations() const; + + SC_DLLPUBLIC void GetSortParam(ScSortParam& rSortParam) const; + SC_DLLPUBLIC void SetSortParam(const ScSortParam& rSortParam); + + /** Remember some more settings of ScSortParam, only to be called at + anonymous DB ranges as it at least overwrites bHasHeader. */ + void UpdateFromSortParam( const ScSortParam& rSortParam ); + + SC_DLLPUBLIC void GetQueryParam(ScQueryParam& rQueryParam) const; + SC_DLLPUBLIC void SetQueryParam(const ScQueryParam& rQueryParam); + SC_DLLPUBLIC bool GetAdvancedQuerySource(ScRange& rSource) const; + SC_DLLPUBLIC void SetAdvancedQuerySource(const ScRange* pSource); + + void GetSubTotalParam(ScSubTotalParam& rSubTotalParam) const; + void SetSubTotalParam(const ScSubTotalParam& rSubTotalParam); + + void GetImportParam(ScImportParam& rImportParam) const; + void SetImportParam(const ScImportParam& rImportParam); + + bool IsDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, ScDBDataPortion ePortion) const; + bool IsDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) const; + + bool HasImportParam() const; + SC_DLLPUBLIC bool HasQueryParam() const; + bool HasSortParam() const; + bool HasSubTotalParam() const; + + bool HasImportSelection() const { return bDBSelection; } + void SetImportSelection(bool bSet) { bDBSelection = bSet; } + + bool HasAutoFilter() const { return bAutoFilter; } + void SetAutoFilter(bool bSet) { bAutoFilter = bSet; } + + bool IsModified() const { return bModified; } + void SetModified(bool bMod) { bModified = bMod; } + + void UpdateMoveTab( SCTAB nOldPos, SCTAB nNewPos ); + bool UpdateReference(const ScDocument* pDoc, UpdateRefMode eUpdateRefMode, SCCOL nCol1, + SCROW nRow1, SCTAB nTab1, SCCOL nCol2, SCROW nRow2, SCTAB nTab2, + SCCOL nDx, SCROW nDy, SCTAB nDz); + + void ExtendDataArea(const ScDocument& rDoc); + void ExtendBackColorArea(const ScDocument& rDoc); + void CalcSaveFilteredCount(SCSIZE nNonFilteredRowCount); + void GetFilterSelCount(SCSIZE& nSelected, SCSIZE& nTotal); + +private: + + void AdjustTableColumnAttributes( UpdateRefMode eUpdateRefMode, SCCOL nDx, SCCOL nCol1, + SCCOL nOldCol1, SCCOL nOldCol2, SCCOL nNewCol1, SCCOL nNewCol2 ); + void InvalidateTableColumnNames( bool bSwapToEmptyNames ); +}; + +class SC_DLLPUBLIC ScDBCollection +{ +public: + enum RangeType { GlobalNamed, GlobalAnonymous, SheetAnonymous }; + + /** + * Stores global named database ranges. + */ + class SC_DLLPUBLIC NamedDBs final : public ScDBDataContainerBase + { + friend class ScDBCollection; + + typedef ::std::set<std::unique_ptr<ScDBData>, ScDBData::less> DBsType; + DBsType m_DBs; + ScDBCollection& mrParent; + NamedDBs(ScDBCollection& rParent, ScDocument& rDoc); + NamedDBs(const NamedDBs& r, ScDBCollection& rParent); + NamedDBs(const NamedDBs&) = delete; + virtual ~NamedDBs() override; + NamedDBs & operator=(NamedDBs const&) = delete; + void initInserted( ScDBData* p ); + + public: + typedef DBsType::iterator iterator; + typedef DBsType::const_iterator const_iterator; + + iterator begin(); + iterator end(); + const_iterator begin() const; + const_iterator end() const; + ScDBData* findByIndex(sal_uInt16 nIndex); + ScDBData* findByUpperName(const OUString& rName); + iterator findByUpperName2(const OUString& rName); + ScDBData* findByName(const OUString& rName); + + /** Takes ownership of p and attempts to insert it into the collection. + Deletes p if it could not be inserted, i.e. duplicate name. + @return <TRUE/> if inserted, else <FALSE/>. + */ + bool insert(std::unique_ptr<ScDBData> p); + + iterator erase(const iterator& itr); + bool empty() const; + size_t size() const; + bool operator== (const NamedDBs& r) const; + }; + + /** + * Stores global anonymous database ranges. + */ + class SAL_DLLPRIVATE AnonDBs + { + typedef ::std::vector<std::unique_ptr<ScDBData>> DBsType; + DBsType m_DBs; + + AnonDBs& operator=(AnonDBs const&) = delete; + + public: + AnonDBs(); + AnonDBs(AnonDBs const&); + + typedef DBsType::iterator iterator; + typedef DBsType::const_iterator const_iterator; + + iterator begin(); + iterator end(); + const_iterator begin() const; + const_iterator end() const; + const ScDBData* findAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, ScDBDataPortion ePortion) const; + const ScDBData* findByRange(const ScRange& rRange) const; + void deleteOnTab(SCTAB nTab); + ScDBData* getByRange(const ScRange& rRange); + void insert(ScDBData* p); + iterator erase(const iterator& itr); + bool empty() const; + bool has( const ScDBData* p ) const; + bool operator== (const AnonDBs& r) const; + }; + +private: + Link<Timer *, void> aRefreshHandler; + ScDocument& rDoc; + sal_uInt16 nEntryIndex; ///< counter for unique indices + NamedDBs maNamedDBs; + AnonDBs maAnonDBs; + +public: + ScDBCollection(ScDocument& rDocument); + ScDBCollection(const ScDBCollection& r); + + NamedDBs& getNamedDBs() { return maNamedDBs;} + const NamedDBs& getNamedDBs() const { return maNamedDBs;} + + AnonDBs& getAnonDBs() { return maAnonDBs;} + const AnonDBs& getAnonDBs() const { return maAnonDBs;} + + const ScDBData* GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, ScDBDataPortion ePortion) const; + ScDBData* GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, ScDBDataPortion ePortion); + const ScDBData* GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) const; + ScDBData* GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2); + ScDBData* GetDBNearCursor(SCCOL nCol, SCROW nRow, SCTAB nTab ); + std::vector<ScDBData*> GetAllDBsFromTab(SCTAB nTab); + + void RefreshDirtyTableColumnNames(); + + void DeleteOnTab( SCTAB nTab ); + void UpdateReference(UpdateRefMode eUpdateRefMode, + SCCOL nCol1, SCROW nRow1, SCTAB nTab1, + SCCOL nCol2, SCROW nRow2, SCTAB nTab2, + SCCOL nDx, SCROW nDy, SCTAB nDz); + void UpdateMoveTab( SCTAB nOldPos, SCTAB nNewPos ); + void CopyToTable(SCTAB nOldPos, SCTAB nNewPos); + + void SetRefreshHandler( const Link<Timer *, void>& rLink ) + { aRefreshHandler = rLink; } + const Link<Timer *, void>& GetRefreshHandler() const { return aRefreshHandler; } + + bool empty() const; + bool operator== (const ScDBCollection& r) const; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/dbdocutl.hxx b/sc/inc/dbdocutl.hxx new file mode 100644 index 0000000000..5fd1186d81 --- /dev/null +++ b/sc/inc/dbdocutl.hxx @@ -0,0 +1,49 @@ +/* -*- 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 "types.hxx" +#include <sal/types.h> +#include <tools/long.hxx> + +class ScDocument; +namespace com::sun::star::uno { template <typename > class Reference; } +namespace com::sun::star::sdbc { class XRow; } + +class ScDatabaseDocUtil +{ +public: + /** + * Detailed information on single string value. + */ + struct StrData + { + bool mbSimpleText; + sal_uInt32 mnStrLength; + + StrData(); + }; + static void PutData( ScDocument& rDoc, SCCOL nCol, SCROW nRow, SCTAB nTab, + const css::uno::Reference< css::sdbc::XRow>& xRow, + sal_Int32 nRowPos, + tools::Long nType, bool bCurrency, StrData* pStrData = nullptr ); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/defaultsoptions.hxx b/sc/inc/defaultsoptions.hxx new file mode 100644 index 0000000000..6b6ace9523 --- /dev/null +++ b/sc/inc/defaultsoptions.hxx @@ -0,0 +1,80 @@ +/* -*- 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/. + */ + +#pragma once + +#include <svl/poolitem.hxx> +#include <unotools/configitem.hxx> +#include <config_features.h> +#include "scdllapi.h" +#include "types.hxx" + +class SC_DLLPUBLIC ScDefaultsOptions +{ +private: + SCTAB nInitTabCount; // number of Tabs for new Spreadsheet doc + OUString aInitTabPrefix; // The Tab prefix name in new Spreadsheet doc + bool bJumboSheets; + +public: + ScDefaultsOptions(); + + void SetDefaults(); + + SCTAB GetInitTabCount() const { return nInitTabCount; } + void SetInitTabCount( SCTAB nTabs) { nInitTabCount = nTabs; } + void SetInitTabPrefix(const OUString& aPrefix) { aInitTabPrefix = aPrefix; } + const OUString& GetInitTabPrefix() const { return aInitTabPrefix; } + bool GetInitJumboSheets() const { return bJumboSheets; } +#if HAVE_FEATURE_JUMBO_SHEETS + void SetInitJumboSheets( bool b) { bJumboSheets = b; } +#endif + bool operator== ( const ScDefaultsOptions& rOpt ) const; + +}; + +// item for the dialog / options page + +class SC_DLLPUBLIC ScTpDefaultsItem final : public SfxPoolItem +{ +public: + ScTpDefaultsItem( ScDefaultsOptions aOpt ); + virtual ~ScTpDefaultsItem() override; + + ScTpDefaultsItem(ScTpDefaultsItem const &) = default; + ScTpDefaultsItem(ScTpDefaultsItem &&) = default; + ScTpDefaultsItem & operator =(ScTpDefaultsItem const &) = delete; // due to SfxPoolItem + ScTpDefaultsItem & operator =(ScTpDefaultsItem &&) = delete; // due to SfxPoolItem + + virtual bool operator==( const SfxPoolItem& ) const override; + virtual ScTpDefaultsItem* Clone( SfxItemPool *pPool = nullptr ) const override; + + const ScDefaultsOptions& GetDefaultsOptions() const { return theOptions; } + +private: + ScDefaultsOptions theOptions; +}; + +// config item + +class ScDefaultsCfg final : public ScDefaultsOptions, public utl::ConfigItem +{ +private: + static css::uno::Sequence<OUString> GetPropertyNames(); + virtual void ImplCommit() override; + +public: + ScDefaultsCfg(); + + void SetOptions( const ScDefaultsOptions& rNew ); + + virtual void Notify( const css::uno::Sequence< OUString >& aPropertyNames ) override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/defltuno.hxx b/sc/inc/defltuno.hxx new file mode 100644 index 0000000000..296a6d3edc --- /dev/null +++ b/sc/inc/defltuno.hxx @@ -0,0 +1,80 @@ +/* -*- 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 <svl/lstner.hxx> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/beans/XPropertyState.hpp> +#include <cppuhelper/implbase.hxx> +#include <svl/itemprop.hxx> + +class ScDocShell; + +class ScDocDefaultsObj final : public ::cppu::WeakImplHelper< + css::beans::XPropertySet, + css::beans::XPropertyState, + css::lang::XServiceInfo >, + public SfxListener +{ +private: + ScDocShell* pDocShell; + SfxItemPropertyMap aPropertyMap; + + void ItemsChanged(); + +public: + ScDocDefaultsObj(ScDocShell* pDocSh); + virtual ~ScDocDefaultsObj() override; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + // XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > + SAL_CALL getPropertySetInfo() override; + virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, + const css::uno::Any& aValue ) override; + virtual css::uno::Any SAL_CALL getPropertyValue( + const OUString& PropertyName ) override; + virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override; + virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override; + virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + + // XPropertyState + virtual css::beans::PropertyState SAL_CALL getPropertyState( + const OUString& PropertyName ) override; + virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL + getPropertyStates( const css::uno::Sequence< OUString >& aPropertyName ) override; + virtual void SAL_CALL setPropertyToDefault( const OUString& PropertyName ) override; + virtual css::uno::Any SAL_CALL getPropertyDefault( + const OUString& aPropertyName ) override; + + // XServiceInfo + 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; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/detdata.hxx b/sc/inc/detdata.hxx new file mode 100644 index 0000000000..d9eeea6ad9 --- /dev/null +++ b/sc/inc/detdata.hxx @@ -0,0 +1,81 @@ +/* -*- 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 "global.hxx" + +#include <vector> + +enum ScDetOpType +{ + SCDETOP_ADDSUCC, + SCDETOP_DELSUCC, + SCDETOP_ADDPRED, + SCDETOP_DELPRED, + SCDETOP_ADDERROR +}; + +class ScDetOpData +{ + ScAddress aPos; + ScDetOpType eOperation; + +public: + ScDetOpData( const ScAddress& rP, ScDetOpType eOp ) : + aPos(rP), eOperation(eOp) {} + + const ScAddress& GetPos() const { return aPos; } + ScDetOpType GetOperation() const { return eOperation; } + + // for UpdateRef: + void SetPos(const ScAddress& rNew) { aPos=rNew; } + + bool operator== ( const ScDetOpData& r ) const + { return eOperation == r.eOperation && aPos == r.aPos; } +}; + +// list of operators + +typedef std::vector<ScDetOpData> ScDetOpDataVector; + +class ScDetOpList +{ + bool bHasAddError; // updated in append + ScDetOpDataVector aDetOpDataVector; + +public: + ScDetOpList() : bHasAddError(false) {} + ScDetOpList(const ScDetOpList& rList); + + void DeleteOnTab( SCTAB nTab ); + void UpdateReference( const ScDocument* pDoc, UpdateRefMode eUpdateRefMode, + const ScRange& rRange, SCCOL nDx, SCROW nDy, SCTAB nDz ); + + bool operator==( const ScDetOpList& r ) const; // for ref-undo + + void Append( const ScDetOpData& ); + ScDetOpDataVector& GetDataVector() { return aDetOpDataVector; } + const ScDetOpData& GetObject( size_t nPos ) const; + + bool HasAddError() const { return bHasAddError; } + size_t Count() const { return aDetOpDataVector.size(); } +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/detfunc.hxx b/sc/inc/detfunc.hxx new file mode 100644 index 0000000000..cb5758fd3f --- /dev/null +++ b/sc/inc/detfunc.hxx @@ -0,0 +1,153 @@ +/* -*- 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 "address.hxx" +#include <tools/gen.hxx> +#include <tools/color.hxx> +#include "scdllapi.h" + +#include <vector> + +class SdrObject; + +class ScDetectiveData; +class ScDocument; + +#define SC_DET_MAXCIRCLE 1000 + +enum class ScDetectiveDelete { Detective, Circles, Arrows }; + +enum ScDetectiveObjType +{ + SC_DETOBJ_NONE, + SC_DETOBJ_ARROW, + SC_DETOBJ_FROMOTHERTAB, + SC_DETOBJ_TOOTHERTAB, + SC_DETOBJ_CIRCLE, + SC_DETOBJ_RECTANGLE +}; + +class SC_DLLPUBLIC ScDetectiveFunc +{ + static Color nArrowColor; + static Color nErrorColor; + static Color nCommentColor; + static bool bColorsInitialized; + + ScDocument& rDoc; + SCTAB nTab; + + enum class DrawPosMode + { + TopLeft, ///< Top-left edge of the cell. + BottomRight, ///< Bottom-right edge of the cell. + DetectiveArrow, ///< Position inside cell for detective arrows. + }; + + /** @return a drawing layer position for the passed cell address. */ + Point GetDrawPos( SCCOL nCol, SCROW nRow, DrawPosMode eMode ) const; + + /** @return the drawing layer rectangle for the passed cell range. */ + tools::Rectangle GetDrawRect( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ) const; + + /** @return the drawing layer rectangle for the passed cell address. */ + tools::Rectangle GetDrawRect( SCCOL nCol, SCROW nRow ) const; + + bool HasArrow( const ScAddress& rStart, + SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab ); + + void DeleteArrowsAt( SCCOL nCol, SCROW nRow, bool bDestPnt ); + void DeleteBox( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ); + + bool HasError( const ScRange& rRange, ScAddress& rErrPos ); + + /// called from DrawEntry/DrawAlienEntry and InsertObject + void InsertArrow( SCCOL nCol, SCROW nRow, + SCCOL nRefStartCol, SCROW nRefStartRow, + SCCOL nRefEndCol, SCROW nRefEndRow, + bool bFromOtherTab, bool bRed, + ScDetectiveData& rData ); + void InsertToOtherTab( SCCOL nStartCol, SCROW nStartRow, + SCCOL nEndCol, SCROW nEndRow, bool bRed, + ScDetectiveData& rData ); + + /// DrawEntry / DrawAlienEntry check for existing arrows and errors + bool DrawEntry( SCCOL nCol, SCROW nRow, const ScRange& rRef, + ScDetectiveData& rData ); + bool DrawAlienEntry( const ScRange& rRef, + ScDetectiveData& rData ); + + void DrawCircle( SCCOL nCol, SCROW nRow, ScDetectiveData& rData ); + + sal_uInt16 InsertPredLevel( SCCOL nCol, SCROW nRow, ScDetectiveData& rData, sal_uInt16 nLevel ); + sal_uInt16 InsertPredLevelArea( const ScRange& rRef, + ScDetectiveData& rData, sal_uInt16 nLevel ); + sal_uInt16 FindPredLevel( SCCOL nCol, SCROW nRow, sal_uInt16 nLevel, sal_uInt16 nDeleteLevel ); + sal_uInt16 FindPredLevelArea( const ScRange& rRef, + sal_uInt16 nLevel, sal_uInt16 nDeleteLevel ); + + sal_uInt16 InsertErrorLevel( SCCOL nCol, SCROW nRow, ScDetectiveData& rData, sal_uInt16 nLevel ); + + sal_uInt16 InsertSuccLevel( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, + ScDetectiveData& rData, sal_uInt16 nLevel ); + sal_uInt16 FindSuccLevel( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, + sal_uInt16 nLevel, sal_uInt16 nDeleteLevel ); + + void FindFrameForObject( const SdrObject* pObject, ScRange& rRange ); + + void Modified(); + +public: + ScDetectiveFunc(ScDocument& rDocument, SCTAB nTable) : rDoc(rDocument),nTab(nTable) {} + + bool ShowSucc( SCCOL nCol, SCROW nRow ); + bool ShowPred( SCCOL nCol, SCROW nRow ); + bool ShowError( SCCOL nCol, SCROW nRow ); + + bool DeleteSucc( SCCOL nCol, SCROW nRow ); + bool DeletePred( SCCOL nCol, SCROW nRow ); + bool DeleteAll( ScDetectiveDelete eWhat ); + bool DeleteCirclesAt( SCCOL nCol, SCROW nRow ); + + bool MarkInvalid(bool& rOverflow); + + void GetAllPreds(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ::std::vector<ScTokenRef>& rRefTokens); + void GetAllSuccs(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ::std::vector<ScTokenRef>& rRefTokens); + + static void UpdateAllComments( ScDocument& rDoc ); ///< on all tables + void UpdateAllArrowColors(); ///< on all tables + + static bool IsNonAlienArrow( const SdrObject* pObject ); + + ScDetectiveObjType GetDetectiveObjectType( SdrObject* pObject, SCTAB nObjTab, + ScAddress& rPosition, ScRange& rSource, bool& rRedLine ); + void InsertObject( ScDetectiveObjType eType, const ScAddress& rPosition, + const ScRange& rSource, bool bRedLine ); + + static Color GetArrowColor(); + static Color GetErrorColor(); + static Color GetCommentColor(); + static void InitializeColors(); + static bool IsColorsInitialized(); + static void AppendChangTrackNoteSeparator(OUString &str); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/dispuno.hxx b/sc/inc/dispuno.hxx new file mode 100644 index 0000000000..f8c5e0791a --- /dev/null +++ b/sc/inc/dispuno.hxx @@ -0,0 +1,110 @@ +/* -*- 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/frame/XDispatchProviderInterceptor.hpp> +#include <com/sun/star/view/XSelectionChangeListener.hpp> +#include <cppuhelper/implbase.hxx> +#include <svl/lstner.hxx> +#include "global.hxx" + +namespace com::sun::star::frame { class XDispatchProviderInterception; } +class ScTabViewShell; + +class ScDispatchProviderInterceptor final : public cppu::WeakImplHelper< + css::frame::XDispatchProviderInterceptor, + css::lang::XEventListener>, + public SfxListener +{ + ScTabViewShell* pViewShell; + + /// the component which's dispatches we're intercepting + css::uno::Reference< css::frame::XDispatchProviderInterception> m_xIntercepted; + + /// chaining + css::uno::Reference< css::frame::XDispatchProvider> m_xSlaveDispatcher; + css::uno::Reference< css::frame::XDispatchProvider> m_xMasterDispatcher; + + /// own dispatch + css::uno::Reference< css::frame::XDispatch> m_xMyDispatch; + +public: + + ScDispatchProviderInterceptor(ScTabViewShell* pViewSh); + virtual ~ScDispatchProviderInterceptor() override; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + /// XDispatchProvider + virtual css::uno::Reference< css::frame::XDispatch > SAL_CALL + queryDispatch( const css::util::URL& aURL, + const OUString& aTargetFrameName, + sal_Int32 nSearchFlags ) override; + virtual css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > SAL_CALL + queryDispatches( const css::uno::Sequence< css::frame::DispatchDescriptor >& aDescripts ) override; + + /// XDispatchProviderInterceptor + virtual css::uno::Reference< css::frame::XDispatchProvider > SAL_CALL + getSlaveDispatchProvider() override; + virtual void SAL_CALL setSlaveDispatchProvider( const css::uno::Reference< + css::frame::XDispatchProvider >& xNewDispatchProvider ) override; + virtual css::uno::Reference< css::frame::XDispatchProvider > SAL_CALL + getMasterDispatchProvider() override; + virtual void SAL_CALL setMasterDispatchProvider( const css::uno::Reference< + css::frame::XDispatchProvider >& xNewSupplier ) override; + + /// XEventListener + virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; +}; + +class ScDispatch final : public cppu::WeakImplHelper< + css::frame::XDispatch, + css::view::XSelectionChangeListener >, + public SfxListener +{ + ScTabViewShell* pViewShell; + std::vector< css::uno::Reference< css::frame::XStatusListener > > + aDataSourceListeners; + ScImportParam aLastImport; + bool bListeningToView; + +public: + + ScDispatch(ScTabViewShell* pViewSh); + virtual ~ScDispatch() override; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + /// XDispatch + virtual void SAL_CALL dispatch( const css::util::URL& aURL, + const css::uno::Sequence< css::beans::PropertyValue >& aArgs ) override; + virtual void SAL_CALL addStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xControl, + const css::util::URL& aURL ) override; + virtual void SAL_CALL removeStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xControl, + const css::util::URL& aURL ) override; + + /// XSelectionChangeListener + virtual void SAL_CALL selectionChanged( const css::lang::EventObject& aEvent ) override; + + /// XEventListener + virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/dociter.hxx b/sc/inc/dociter.hxx new file mode 100644 index 0000000000..6be5a77e5e --- /dev/null +++ b/sc/inc/dociter.hxx @@ -0,0 +1,473 @@ +/* -*- 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 "address.hxx" +#include "formulagroup.hxx" +#include "global.hxx" +#include "scdllapi.h" +#include "cellvalue.hxx" +#include "mtvelements.hxx" +#include "queryparam.hxx" +#include <vcl/outdev.hxx> +#include <vcl/vclptr.hxx> + +#include <memory> +#include <set> +#include <vector> + +class ScDocument; +class ScPatternAttr; +class ScAttrArray; +class ScAttrIterator; +class ScFlatBoolRowSegments; +class ScMatrix; +struct ScDBQueryParamBase; +struct ScQueryParam; +struct ScDBQueryParamInternal; +struct ScDBQueryParamMatrix; +class ScFormulaCell; +class OutputDevice; +struct ScInterpreterContext; +enum class SvNumFormatType : sal_Int16; + +class ScValueIterator // walk through all values in an area +{ + typedef sc::CellStoreType::const_position_type PositionType; + + const ScDocument& mrDoc; + ScInterpreterContext& mrContext; + const ScAttrArray* pAttrArray; + sal_uInt32 nNumFormat; // for CalcAsShown + sal_uInt32 nNumFmtIndex; + ScAddress maStartPos; + ScAddress maEndPos; + SCCOL mnCol; + SCTAB mnTab; + SCROW nAttrEndRow; + SubtotalFlags mnSubTotalFlags; + SvNumFormatType nNumFmtType; + bool bNumValid; + bool bCalcAsShown; + bool bTextAsZero; + + const sc::CellStoreType* mpCells; + PositionType maCurPos; + + SCROW GetRow() const; + void IncBlock(); + void IncPos(); + + /** + * See if the cell at the current position is a non-empty cell. If not, + * move to the next non-empty cell position. + */ + bool GetThis( double& rValue, FormulaError& rErr ); + +public: + + ScValueIterator(ScInterpreterContext& rContext, + const ScRange& rRange, SubtotalFlags nSubTotalFlags = SubtotalFlags::NONE, + bool bTextAsZero = false ); + + void GetCurNumFmtInfo( SvNumFormatType& nType, sal_uInt32& nIndex ); + + /// Does NOT reset rValue if no value found! + bool GetFirst( double& rValue, FormulaError& rErr ); + + /// Does NOT reset rValue if no value found! + bool GetNext( double& rValue, FormulaError& rErr ); +}; + +class ScDBQueryDataIterator +{ +public: + struct Value + { + OUString maString; + double mfValue; + FormulaError mnError; + bool mbIsNumber; + + Value(); + }; + +private: + static const sc::CellStoreType* GetColumnCellStore(ScDocument& rDoc, SCTAB nTab, SCCOL nCol); + static const ScAttrArray* GetAttrArrayByCol(ScDocument& rDoc, SCTAB nTab, SCCOL nCol); + static bool IsQueryValid(ScDocument& rDoc, const ScQueryParam& rParam, SCTAB nTab, SCROW nRow, const ScRefCellValue* pCell); + + class DataAccess + { + public: + DataAccess(); + virtual ~DataAccess() = 0; + virtual bool getCurrent(Value& rValue) = 0; + virtual bool getFirst(Value& rValue) = 0; + virtual bool getNext(Value& rValue) = 0; + }; + + class DataAccessInternal final : public DataAccess + { + typedef std::pair<sc::CellStoreType::const_iterator,size_t> PositionType; + public: + DataAccessInternal(ScDBQueryParamInternal* pParam, ScDocument& rDoc, const ScInterpreterContext& rContext); + virtual ~DataAccessInternal() override; + virtual bool getCurrent(Value& rValue) override; + virtual bool getFirst(Value& rValue) override; + virtual bool getNext(Value& rValue) override; + + private: + void incBlock(); + void incPos(); + + const sc::CellStoreType* mpCells; + PositionType maCurPos; + ScDBQueryParamInternal* mpParam; + ScDocument& mrDoc; + const ScInterpreterContext& mrContext; + const ScAttrArray* pAttrArray; + sal_uInt32 nNumFormat; // for CalcAsShown + sal_uInt32 nNumFmtIndex; + SCCOL nCol; + SCROW nRow; + SCROW nAttrEndRow; + SCTAB nTab; + SvNumFormatType nNumFmtType; + bool bCalcAsShown; + }; + + class DataAccessMatrix final : public DataAccess + { + public: + DataAccessMatrix(ScDBQueryParamMatrix* pParam); + virtual ~DataAccessMatrix() override; + virtual bool getCurrent(Value& rValue) override; + virtual bool getFirst(Value& rValue) override; + virtual bool getNext(Value& rValue) override; + + private: + bool isValidQuery(SCROW mnRow, const ScMatrix& rMat) const; + + ScDBQueryParamMatrix* mpParam; + SCROW mnCurRow; + SCROW mnRows; + }; + + ::std::unique_ptr<ScDBQueryParamBase> mpParam; + ::std::unique_ptr<DataAccess> mpData; + +public: + ScDBQueryDataIterator(ScDocument& rDocument, const ScInterpreterContext& rContext, std::unique_ptr<ScDBQueryParamBase> pParam); + /// Does NOT reset rValue if no value found! + bool GetFirst(Value& rValue); + /// Does NOT reset rValue if no value found! + bool GetNext(Value& rValue); +}; + +class ScFormulaGroupIterator +{ +private: + ScDocument& mrDoc; + SCTAB mnTab; + SCCOL mnCol; + bool mbNullCol; + size_t mnIndex; + std::vector<sc::FormulaGroupEntry> maEntries; + +public: + ScFormulaGroupIterator( ScDocument& rDoc ); + + sc::FormulaGroupEntry* first(); + sc::FormulaGroupEntry* next(); +}; + +/** + * Walk through all cells in an area. For SubTotal and Aggregate depending on mnSubTotalFlags. + **/ +class ScCellIterator +{ + typedef std::pair<sc::CellStoreType::const_iterator, size_t> PositionType; + + ScDocument& mrDoc; + ScAddress maStartPos; + ScAddress maEndPos; + ScAddress maCurPos; + + PositionType maCurColPos; + SubtotalFlags mnSubTotalFlags; + + ScRefCellValue maCurCell; + + void incBlock(); + void incPos(); + void setPos(size_t nPos); + + const ScColumn* getColumn() const; + + void init(); + bool getCurrent(); + +public: + ScCellIterator( ScDocument& rDoc, const ScRange& rRange, SubtotalFlags nSubTotalFlags = SubtotalFlags::NONE ); + + const ScAddress& GetPos() const { return maCurPos; } + + CellType getType() const { return maCurCell.getType();} + OUString getString() const; + const EditTextObject* getEditText() const { return maCurCell.getEditText();} + ScFormulaCell* getFormulaCell() { return maCurCell.getFormula();} + const ScFormulaCell* getFormulaCell() const { return maCurCell.getFormula();} + ScCellValue getCellValue() const; + const ScRefCellValue& getRefCellValue() const { return maCurCell;} + + bool hasString() const; + bool isEmpty() const; + bool equalsWithoutFormat( const ScAddress& rPos ) const; + + bool first(); + bool next(); +}; + +class ScDocAttrIterator // all attribute areas +{ +private: + ScDocument& rDoc; + SCTAB nTab; + SCCOL nEndCol; + SCROW nStartRow; + SCROW nEndRow; + SCCOL nCol; + std::unique_ptr<ScAttrIterator> + pColIter; + +public: + ScDocAttrIterator(ScDocument& rDocument, SCTAB nTable, + SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2); + ~ScDocAttrIterator(); + + const ScPatternAttr* GetNext( SCCOL& rCol, SCROW& rRow1, SCROW& rRow2 ); +}; + +class ScAttrRectIterator // all attribute areas, including areas stretching + // across more than one column +{ +private: + ScDocument& rDoc; + SCTAB nTab; + SCCOL nEndCol; + SCROW nStartRow; + SCROW nEndRow; + SCCOL nIterStartCol; + SCCOL nIterEndCol; + std::unique_ptr<ScAttrIterator> + pColIter; + +public: + ScAttrRectIterator(ScDocument& rDocument, SCTAB nTable, + SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2); + ~ScAttrRectIterator(); + + void DataChanged(); + const ScPatternAttr* GetNext( SCCOL& rCol1, SCCOL& rCol2, SCROW& rRow1, SCROW& rRow2 ); +}; + +class ScHorizontalCellIterator // walk through all non empty cells in an area +{ // row by row + struct ColParam + { + sc::CellStoreType::const_iterator maPos; + sc::CellStoreType::const_iterator maEnd; + SCCOL mnCol; + }; + + std::vector<ColParam>::iterator maColPos; + std::vector<ColParam> maColPositions; + + ScDocument& rDoc; + SCTAB mnTab; + SCCOL nStartCol; + SCCOL nEndCol; + SCROW nStartRow; + SCROW nEndRow; + SCCOL mnCol; + SCROW mnRow; + ScRefCellValue maCurCell; + bool mbMore; + +public: + ScHorizontalCellIterator(ScDocument& rDocument, SCTAB nTable, + SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2); + ~ScHorizontalCellIterator(); + + ScRefCellValue* GetNext( SCCOL& rCol, SCROW& rRow ); + bool GetPos( SCCOL& rCol, SCROW& rRow ); + /// Set a(nother) sheet and (re)init. + void SetTab( SCTAB nTab ); + +private: + void Advance(); + void SkipInvalid(); + bool SkipInvalidInRow(); + SCROW FindNextNonEmptyRow(); +}; + +/** Row-wise value iterator. */ +class ScHorizontalValueIterator +{ +private: + ScDocument& rDoc; + const ScAttrArray* pAttrArray; + std::unique_ptr<ScHorizontalCellIterator> + pCellIter; + sal_uInt32 nNumFormat; // for CalcAsShown + SCTAB nEndTab; + SCCOL nCurCol; + SCROW nCurRow; + SCTAB nCurTab; + SCROW nAttrEndRow; + bool bCalcAsShown; + +public: + + ScHorizontalValueIterator( ScDocument& rDocument, + const ScRange& rRange ); + ~ScHorizontalValueIterator(); + /// Does NOT reset rValue if no value found! + bool GetNext( double& rValue, FormulaError& rErr ); +}; + +class ScHorizontalAttrIterator +{ +private: + ScDocument& rDoc; + SCTAB nTab; + SCCOL nStartCol; + SCROW nStartRow; + SCCOL nEndCol; + SCROW nEndRow; + + std::unique_ptr<SCROW[]> pNextEnd; + std::unique_ptr<SCCOL[]> pHorizEnd; + std::unique_ptr<SCSIZE[]> pIndices; + std::unique_ptr<const ScPatternAttr*[]> + ppPatterns; + SCCOL nCol; + SCROW nRow; + SCROW nMinNextEnd; + + void InitForNextRow(bool bInitialization); + +public: + ScHorizontalAttrIterator( ScDocument& rDocument, SCTAB nTable, + SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ); + ~ScHorizontalAttrIterator(); + + const ScPatternAttr* GetNext( SCCOL& rCol1, SCCOL& rCol2, SCROW& rRow ); +}; + +// returns non-empty cells and areas with formatting (horizontal) + +class SC_DLLPUBLIC ScUsedAreaIterator +{ +private: + ScHorizontalCellIterator aCellIter; + ScHorizontalAttrIterator aAttrIter; + + SCCOL nNextCol; + SCROW nNextRow; + + SCCOL nCellCol; + SCROW nCellRow; + ScRefCellValue* pCell; + SCCOL nAttrCol1; + SCCOL nAttrCol2; + SCROW nAttrRow; + const ScPatternAttr* pPattern; + + SCCOL nFoundStartCol; // results after GetNext + SCCOL nFoundEndCol; + SCROW nFoundRow; + const ScPatternAttr* pFoundPattern; + + ScRefCellValue maFoundCell; + +public: + ScUsedAreaIterator( ScDocument& rDocument, SCTAB nTable, + SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ); + ~ScUsedAreaIterator(); + + bool GetNext(); + + SCCOL GetStartCol() const { return nFoundStartCol; } + SCCOL GetEndCol() const { return nFoundEndCol; } + SCROW GetRow() const { return nFoundRow; } + const ScPatternAttr* GetPattern() const { return pFoundPattern; } + const ScRefCellValue& GetCell() const { return maFoundCell;} +}; + +class ScRowBreakIterator +{ +public: + static constexpr SCROW NOT_FOUND = -1; + + explicit ScRowBreakIterator(::std::set<SCROW>& rBreaks); + SCROW first(); + SCROW next(); + +private: + ::std::set<SCROW>& mrBreaks; + ::std::set<SCROW>::const_iterator maItr; + ::std::set<SCROW>::const_iterator maEnd; +}; + +class ScDocRowHeightUpdater +{ +public: + struct TabRanges + { + SCTAB mnTab; + ScFlatBoolRowSegments maRanges; + + TabRanges(SCTAB nTab, SCROW nMaxRow); + }; + + /** + * Passing a NULL pointer to pTabRangesArray forces the heights of all + * rows in all tables to be updated. + */ + explicit ScDocRowHeightUpdater( + ScDocument& rDoc, OutputDevice* pOutDev, double fPPTX, double fPPTY, + const ::std::vector<TabRanges>* pTabRangesArray); + + void update(const bool bOnlyUsedRows = false); + +private: + void updateAll(const bool bOnlyUsedRows); + +private: + ScDocument& mrDoc; + VclPtr<OutputDevice> mpOutDev; + double mfPPTX; + double mfPPTY; + const ::std::vector<TabRanges>* mpTabRangesArray; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/docoptio.hxx b/sc/inc/docoptio.hxx new file mode 100644 index 0000000000..6e4d4f124c --- /dev/null +++ b/sc/inc/docoptio.hxx @@ -0,0 +1,175 @@ +/* -*- 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 <unotools/textsearch.hxx> +#include <svl/poolitem.hxx> +#include "scdllapi.h" +#include "optutil.hxx" + +class SC_DLLPUBLIC ScDocOptions +{ + double fIterEps; // epsilon value dazu + sal_uInt16 nIterCount; ///< number + sal_uInt16 nPrecStandardFormat; ///< precision for standard format + sal_uInt16 nDay; ///< Null date: + sal_uInt16 nMonth; + sal_uInt16 nYear; + sal_uInt16 nYear2000; ///< earlier 19YY is assumed, 20YY otherwise (if only YY of year is given) + sal_uInt16 nTabDistance; ///< distance of standard tabs + mutable utl::SearchParam::SearchType eFormulaSearchType; ///< wildcards or regular expressions or normal search + bool bIsIgnoreCase; ///< ignore case for comparisons? + bool bIsIter; ///< iterations for circular refs + bool bCalcAsShown; ///< calculate as shown (wrt precision) + bool bMatchWholeCell; ///< search criteria must match the whole cell + bool bDoAutoSpell; ///< auto-spelling + bool bLookUpColRowNames; ///< determine column-/row titles automagically + mutable bool bFormulaRegexEnabled; ///< regular expressions in formulas enabled, only when reading settings + mutable bool bFormulaWildcardsEnabled;///< wildcards in formulas enabled, only when reading settings + bool bWriteCalcConfig; ///< (subset of) Calc config will be written to user's profile + +public: + ScDocOptions(); + + bool IsLookUpColRowNames() const { return bLookUpColRowNames; } + void SetLookUpColRowNames( bool bVal ) { bLookUpColRowNames = bVal; } + bool IsAutoSpell() const { return bDoAutoSpell; } + void SetAutoSpell( bool bVal ) { bDoAutoSpell = bVal; } + bool IsMatchWholeCell() const { return bMatchWholeCell; } + void SetMatchWholeCell( bool bVal ) { bMatchWholeCell = bVal; } + bool IsIgnoreCase() const { return bIsIgnoreCase; } + void SetIgnoreCase( bool bVal ) { bIsIgnoreCase = bVal; } + bool IsIter() const { return bIsIter; } + void SetIter( bool bVal ) { bIsIter = bVal; } + sal_uInt16 GetIterCount() const { return nIterCount; } + void SetIterCount( sal_uInt16 nCount) { nIterCount = nCount; } + double GetIterEps() const { return fIterEps; } + void SetIterEps( double fEps ) { fIterEps = fEps; } + + void GetDate( sal_uInt16& rD, sal_uInt16& rM, sal_Int16& rY ) const + { rD = nDay; rM = nMonth; rY = nYear;} + void SetDate (sal_uInt16 nD, sal_uInt16 nM, sal_Int16 nY) + { nDay = nD; nMonth = nM; nYear = nY; } + sal_uInt16 GetTabDistance() const { return nTabDistance;} + void SetTabDistance( sal_uInt16 nTabDist ) {nTabDistance = nTabDist;} + + void ResetDocOptions(); + + inline bool operator==( const ScDocOptions& rOpt ) const; + inline bool operator!=( const ScDocOptions& rOpt ) const; + + sal_uInt16 GetStdPrecision() const { return nPrecStandardFormat; } + void SetStdPrecision( sal_uInt16 n ) { nPrecStandardFormat = n; } + + bool IsCalcAsShown() const { return bCalcAsShown; } + void SetCalcAsShown( bool bVal ) { bCalcAsShown = bVal; } + + void SetYear2000( sal_uInt16 nVal ) { nYear2000 = nVal; } + sal_uInt16 GetYear2000() const { return nYear2000; } + + utl::SearchParam::SearchType GetFormulaSearchType() const + { + if (eFormulaSearchType == utl::SearchParam::SearchType::Unknown || (bFormulaRegexEnabled && bFormulaWildcardsEnabled)) + eFormulaSearchType = utl::SearchParam::ConvertToSearchType( bFormulaWildcardsEnabled, bFormulaRegexEnabled); + return eFormulaSearchType; + } + + void SetFormulaRegexEnabled( bool bVal ); + bool IsFormulaRegexEnabled() const { return GetFormulaSearchType() == utl::SearchParam::SearchType::Regexp; } + + void SetFormulaWildcardsEnabled( bool bVal ); + bool IsFormulaWildcardsEnabled() const { return GetFormulaSearchType() == utl::SearchParam::SearchType::Wildcard; } + + void SetWriteCalcConfig( bool bVal ) { bWriteCalcConfig = bVal; } + bool IsWriteCalcConfig() const { return bWriteCalcConfig; } +}; + +inline bool ScDocOptions::operator==( const ScDocOptions& rOpt ) const +{ + return ( + rOpt.bIsIgnoreCase == bIsIgnoreCase + && rOpt.bIsIter == bIsIter + && rOpt.nIterCount == nIterCount + && rOpt.fIterEps == fIterEps + && rOpt.nPrecStandardFormat == nPrecStandardFormat + && rOpt.nDay == nDay + && rOpt.nMonth == nMonth + && rOpt.nYear == nYear + && rOpt.nYear2000 == nYear2000 + && rOpt.nTabDistance == nTabDistance + && rOpt.bCalcAsShown == bCalcAsShown + && rOpt.bMatchWholeCell == bMatchWholeCell + && rOpt.bDoAutoSpell == bDoAutoSpell + && rOpt.bLookUpColRowNames == bLookUpColRowNames + && rOpt.bFormulaRegexEnabled == bFormulaRegexEnabled + && rOpt.bFormulaWildcardsEnabled == bFormulaWildcardsEnabled + && rOpt.eFormulaSearchType == eFormulaSearchType + && rOpt.bWriteCalcConfig == bWriteCalcConfig + ); +} + +inline bool ScDocOptions::operator!=( const ScDocOptions& rOpt ) const +{ + return !(operator==(rOpt)); +} + +// Item for preferences dialog - calculation + +class SC_DLLPUBLIC ScTpCalcItem final : public SfxPoolItem +{ +public: + ScTpCalcItem( sal_uInt16 nWhich, + const ScDocOptions& rOpt ); + virtual ~ScTpCalcItem() override; + + ScTpCalcItem(ScTpCalcItem const &) = default; + ScTpCalcItem(ScTpCalcItem &&) = default; + ScTpCalcItem & operator =(ScTpCalcItem const &) = delete; // due to SfxPoolItem + ScTpCalcItem & operator =(ScTpCalcItem &&) = delete; // due to SfxPoolItem + + virtual bool operator==( const SfxPoolItem& ) const override; + virtual ScTpCalcItem* Clone( SfxItemPool *pPool = nullptr ) const override; + + const ScDocOptions& GetDocOptions() const { return theOptions; } + +private: + ScDocOptions theOptions; +}; + +// Config Item containing document options + +class ScDocCfg : public ScDocOptions +{ + ScLinkConfigItem aCalcItem; + ScLinkConfigItem aLayoutItem; + + DECL_LINK( CalcCommitHdl, ScLinkConfigItem&, void ); + DECL_LINK( LayoutCommitHdl, ScLinkConfigItem&, void ); + + static css::uno::Sequence<OUString> GetCalcPropertyNames(); + static css::uno::Sequence<OUString> GetLayoutPropertyNames(); + +public: + ScDocCfg(); + + void SetOptions( const ScDocOptions& rNew ); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/docparam.hxx b/sc/inc/docparam.hxx new file mode 100644 index 0000000000..76713bd6bd --- /dev/null +++ b/sc/inc/docparam.hxx @@ -0,0 +1,26 @@ +/* -*- 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/. + */ + +#pragma once + +#include <sal/types.h> // for sal_uInt32 +#include "types.hxx" // for SCROW + +// Let's put here misc structures that get passed to ScDocument's methods. + +struct ScColWidthParam +{ + SCROW mnMaxTextRow; + sal_uInt32 mnMaxTextLen; + bool mbSimpleText; + + ScColWidthParam(); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/docpool.hxx b/sc/inc/docpool.hxx new file mode 100644 index 0000000000..c73d034f2f --- /dev/null +++ b/sc/inc/docpool.hxx @@ -0,0 +1,54 @@ +/* -*- 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 <rtl/ustring.hxx> +#include <svl/itempool.hxx> +#include "scdllapi.h" + +class ScStyleSheet; +class ScDocument; + +class SC_DLLPUBLIC ScDocumentPool final : public SfxItemPool +{ + std::vector<SfxPoolItem*> mvPoolDefaults; + sal_uInt64 mnCurrentMaxKey; + +public: + ScDocumentPool(); +private: + virtual ~ScDocumentPool() override; +public: + + virtual rtl::Reference<SfxItemPool> Clone() const override; + virtual MapUnit GetMetric( sal_uInt16 nWhich ) const override; + + void StyleDeleted( const ScStyleSheet* pStyle ); // delete templates(?) in organizer + void CellStyleCreated( std::u16string_view rName, const ScDocument& rDoc ); + virtual bool GetPresentation( const SfxPoolItem& rItem, + MapUnit ePresentationMetric, + OUString& rText, + const IntlWrapper& rIntl ) const override; +private: + virtual void newItem_Callback(const SfxPoolItem& rItem) const override; + virtual bool newItem_UseDirect(const SfxPoolItem& rItem) const override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx new file mode 100644 index 0000000000..09747bb2c0 --- /dev/null +++ b/sc/inc/document.hxx @@ -0,0 +1,2816 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * 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/idle.hxx> +#include <comphelper/errcode.hxx> +#include <com/sun/star/uno/Reference.hxx> +#include <vcl/vclptr.hxx> +#include "patattr.hxx" +#include "scdllapi.h" +#include "interpretercontext.hxx" +#include "rangelst.hxx" +#include "rangenam.hxx" +#include "recursionhelper.hxx" +#include "tabopparams.hxx" +#include "types.hxx" +#include <formula/grammar.hxx> +#include <formula/types.hxx> +#include "typedstrdata.hxx" +#include "calcmacros.hxx" +#include "calcconfig.hxx" +#include "sheetlimits.hxx" +#include <o3tl/deleter.hxx> +#include <o3tl/sorted_vector.hxx> +#include <svl/hint.hxx> +#include <svl/typedwhich.hxx> +#include <svl/zforlist.hxx> +#include <tools/gen.hxx> +#include <tools/solar.h> + +#include <cassert> +#include <memory> +#include <map> +#include <shared_mutex> +#include <optional> +#include <set> +#include <unordered_map> +#include <vector> + +#include "markdata.hxx" +#include "drwlayer.hxx" + +namespace com::sun::star::chart2 { class XChartDocument; } + +class Timer; + +enum class SvtScriptType : sal_uInt8; +enum class ScMF; +enum class FormulaError : sal_uInt16; +enum class CharCompressType; +enum class EEHorizontalTextDirection; +namespace editeng { class SvxBorderLine; } +namespace formula { struct VectorRefArray; } +namespace svl { +class SharedString; +class SharedStringPool; +} + +namespace tools { class Guid; } + +namespace sc { + +struct BroadcasterState; +struct FormulaGroupContext; +class StartListeningContext; +class EndListeningContext; +class CopyFromClipContext; +class ColumnSpanSet; +class RangeColumnSpanSet; +struct ColumnBlockPosition; +struct RefUpdateContext; +class EditTextIterator; +struct NoteEntry; +class DocumentStreamAccess; +class DocumentLinkManager; +class CellValues; +class TableValues; +class RowHeightContext; +struct SetFormulaDirtyContext; +class RefMovedHint; +struct ReorderParam; +class FormulaGroupAreaListener; +class ColumnSet; +class UpdatedRangeNames; +class TableColumnBlockPositionSet; +class ColumnIterator; +class ExternalDataMapper; +class Sparkline; +class SparklineGroup; +class SparklineList; + +} + +class Fraction; + +class OutputDevice; +class SdrObject; +class SfxBroadcaster; +class SfxListener; +class SfxItemSet; +class SfxObjectShell; +class SfxBindings; +class SfxPoolItem; +class SfxItemPool; +class SfxPrinter; +class SfxStyleSheetBase; +class SvMemoryStream; +class SvxBoxInfoItem; +class SvxBoxItem; +class SvxForbiddenCharactersTable; +namespace sfx2 { + class LinkManager; + } +class SvxSearchItem; +class XColorList; + +class ScAutoFormatData; +class ScBroadcastAreaSlotMachine; +class ScChangeViewSettings; +class ScChartListenerCollection; +class ScClipOptions; +class ScColumn; +class ScConditionalFormat; +class ScConditionalFormatList; +class ScDBCollection; +class ScDBData; +class ScDetOpData; +class ScDetOpList; +class ScDocOptions; +class ScDocProtection; +class ScDocumentPool; +class ScDrawLayer; +class ScExtDocOptions; +class ScExternalRefManager; +class ScFormulaCell; +class ScMacroManager; +class ScOutlineTable; +class ScPrintRangeSaver; +class ScStyleSheet; +class ScStyleSheetPool; +class ScTable; +class ScTableProtection; +class ScTokenArray; +class ScValidationData; +class ScValidationDataList; +class ScViewOptions; +class ScChangeTrack; +class ScEditEngineDefaulter; +class ScFieldEditEngine; +class ScNoteEditEngine; +class ScDPObject; +class ScDPCollection; +class ScMatrix; +class ScScriptTypeData; +class ScPoolHelper; +struct ScSortParam; +class ScRefreshTimerControl; +class ScUnoListenerCalls; +class ScUnoRefList; +class ScRecursionHelper; +struct RowInfo; +struct ScTableInfo; +struct ScTabOpParam; +class VirtualDevice; +class ScAutoNameCache; +class ScTemporaryChartLock; +class ScLookupCache; +struct ScLookupCacheMap; +class ScSortedRangeCache; +struct ScSortedRangeCacheMap; +class ScUndoManager; +class ScFormulaParserPool; +struct ScClipParam; +class ScRowBreakIterator; +struct ScSetStringParam; +struct ScColWidthParam; +class ScSheetEvents; +class ScProgress; +class SvtListener; +class ScEditDataArray; +class EditTextObject; +struct ScRefCellValue; +class ScPostIt; +struct ScSubTotalParam; +struct ScQueryParam; +class ScHint; +class SvtBroadcaster; +enum class ScDBDataPortion; +enum class ScSheetEventId; +class BitmapEx; +class ScColumnsRange; +struct ScFilterEntries; +typedef o3tl::sorted_vector<sal_uInt32> ScCondFormatIndexes; +struct ScSheetLimits; +struct ScDataAreaExtras; +enum class ScConditionMode; + + +namespace sc { + +typedef std::map<OUString, BitmapEx> IconSetBitmapMap; + +} + +namespace com::sun::star { + namespace lang { + struct EventObject; + } + namespace i18n { + class XBreakIterator; + } + namespace util { + class XModifyListener; + } + namespace embed { + class XEmbeddedObject; + } + namespace script::vba { + class XVBAEventProcessor; + } + namespace sheet { + struct TablePageBreakData; + } +} + +namespace weld { + +class Window; + +} + +#define SC_DOC_NEW 0xFFFF + +#define SC_MACROCALL_ALLOWED 0 + +#define SC_ASIANKERNING_INVALID 0xff + +enum ScDocumentMode +{ + SCDOCMODE_DOCUMENT, + SCDOCMODE_CLIP, + SCDOCMODE_UNDO, + SCDOCMODE_FUNCTIONACCESS +}; + +enum CommentCaptionState +{ + ALLSHOWN, // All comments captions are shown + ALLHIDDEN, // All comments captions are hidden + MIXED // There are comments in shown and hidden. +}; + +enum RangeNameScope +{ + GLOBAL, // A range name can be defined + SHEET // with two scope on Manage Names dialog. +}; + +/// Represents the type of sheet geometry data. +enum class SheetGeomType +{ + SIZES, // Column widths or row heights. + HIDDEN, // Hidden columns/rows. + FILTERED, // Filtered columns/rows. + GROUPS // Grouping of columns/rows. +}; + +struct ScDocStat +{ + OUString aDocName; + SCTAB nTableCount; + sal_uInt64 nCellCount; + sal_uInt64 nFormulaCount; + sal_uInt16 nPageCount; + ScDocStat() + : nTableCount(0) + , nCellCount(0) + , nFormulaCount(0) + , nPageCount(0) + { + } +}; + +// DDE link modes +const sal_uInt8 SC_DDE_DEFAULT = 0; +const sal_uInt8 SC_DDE_ENGLISH = 1; +const sal_uInt8 SC_DDE_TEXT = 2; +const sal_uInt8 SC_DDE_IGNOREMODE = 255; /// For usage in FindDdeLink() only! + +// During threaded calculation fields being mutated are kept in this struct +struct ScDocumentThreadSpecific +{ + std::unique_ptr<ScRecursionHelper> xRecursionHelper; // information for recursive and iterative cell formulas + ScInterpreterContext* pContext = nullptr; // references the context passed around for easier access +}; + +/// Enumeration to determine which pieces of the code should not be mutated when set. +enum ScMutationGuardFlags +{ + // Bit mask bits + CORE = 0x0001, /// Core calc data structures should not be mutated +}; + +typedef std::unique_ptr<ScTable, o3tl::default_delete<ScTable>> ScTableUniquePtr; + +class ScDocument +{ +friend class ScValueIterator; +friend class ScHorizontalValueIterator; +friend class ScDBQueryDataIterator; +friend class ScCellIterator; +template< ScQueryCellIteratorAccess accessType, ScQueryCellIteratorType queryType > +friend class ScQueryCellIteratorBase; +template< ScQueryCellIteratorAccess accessType > +friend class ScQueryCellIteratorAccessSpecific; +friend class ScHorizontalCellIterator; +friend class ScHorizontalAttrIterator; +friend class ScDocAttrIterator; +friend class ScAttrRectIterator; +friend class ScDocShell; +friend class ScDocRowHeightUpdater; +friend class ScColumnTextWidthIterator; +friend class ScTable; +friend class ScColumn; +friend struct ScRefCellValue; +friend class ScDocumentImport; +friend class sc::EditTextIterator; +friend struct ScMutationGuard; +friend struct ScMutationDisable; + + typedef std::vector<ScTableUniquePtr> TableContainer; + +public: + enum class HardRecalcState + { + OFF, /// normal calculation of dependencies + TEMPORARY, /// CalcAll() without broadcast/notify but setting up new listeners + ETERNAL /// no new listeners are setup, no broadcast/notify + }; + +private: + rtl::Reference<ScPoolHelper> mxPoolHelper; + + std::shared_ptr<svl::SharedStringPool> mpCellStringPool; + std::unique_ptr<sc::DocumentLinkManager> mpDocLinkMgr; + + std::shared_ptr<sc::FormulaGroupContext> mpFormulaGroupCxt; + bool mbFormulaGroupCxtBlockDiscard; + + ScCalcConfig maCalcConfig; + + ScUndoManager* mpUndoManager; + std::unique_ptr<ScFieldEditEngine> mpEditEngine; // uses pEditPool from xPoolHelper + std::unique_ptr<ScNoteEditEngine> mpNoteEngine; // uses pEditPool from xPoolHelper + ScDocShell* mpShell; + VclPtr<SfxPrinter> mpPrinter; + VclPtr<VirtualDevice> mpVirtualDevice_100th_mm; + std::unique_ptr<ScDrawLayer> mpDrawLayer; // SdrModel + rtl::Reference<XColorList> pColorList; + std::unique_ptr<ScValidationDataList> pValidationList; // validity + SvNumberFormatterIndexTable* pFormatExchangeList; // for application of number formats + TableContainer maTabs; + rtl::Reference<ScSheetLimits> mxSheetLimits; + std::vector<OUString> maTabNames; // for undo document, we need the information tab name <-> index + mutable std::unique_ptr<ScRangeName> pRangeName; + std::unique_ptr<ScDBCollection> pDBCollection; + std::unique_ptr<ScDPCollection> pDPCollection; + std::unique_ptr< ScTemporaryChartLock > apTemporaryChartLock; + std::unique_ptr<ScPatternAttr> pSelectionAttr; // Attributes of a block + ScFormulaCell* pFormulaTree; // formula tree (start) + ScFormulaCell* pEOFormulaTree; // formula tree (end), last cell + ScFormulaCell* pFormulaTrack; // BroadcastTrack (start) + ScFormulaCell* pEOFormulaTrack; // BroadcastTrack (end), last cell + std::unique_ptr<ScBroadcastAreaSlotMachine> pBASM; // BroadcastAreas + std::unique_ptr<ScChartListenerCollection> pChartListenerCollection; + std::unique_ptr<SvMemoryStream> pClipData; + std::unique_ptr<ScDetOpList> pDetOpList; + std::unique_ptr<ScChangeTrack> pChangeTrack; + std::unique_ptr<SfxBroadcaster> pUnoBroadcaster; + std::unique_ptr<ScUnoListenerCalls> pUnoListenerCalls; + std::unique_ptr<ScUnoRefList> pUnoRefUndoList; + std::unique_ptr<ScChangeViewSettings> pChangeViewSettings; + std::unique_ptr<ScScriptTypeData> pScriptTypeData; + std::unique_ptr<ScRefreshTimerControl> pRefreshTimerControl; + std::shared_ptr<SvxForbiddenCharactersTable> xForbiddenCharacters; + std::unique_ptr<ScDBData> mpAnonymousDBData; + std::unique_ptr<sc::ExternalDataMapper> mpDataMapper; + + std::unique_ptr<ScFieldEditEngine> pCacheFieldEditEngine; + + std::unique_ptr<ScDocProtection> pDocProtection; + std::unique_ptr<ScClipParam> mpClipParam; + + std::unique_ptr<ScExternalRefManager> pExternalRefMgr; + std::unique_ptr<ScMacroManager> mpMacroMgr; + + // mutable for lazy construction + mutable std::unique_ptr< ScFormulaParserPool > + mxFormulaParserPool; /// Pool for all external formula parsers used by this document. + + OUString aDocName; // optional: name of document + OUString aDocCodeName; // optional: name of document (twice?) + OUString maFileURL; // file URL for copy & paste + ScRangePairListRef xColNameRanges; + ScRangePairListRef xRowNameRanges; + + std::unique_ptr<ScViewOptions> pViewOptions; // view options + std::unique_ptr<ScDocOptions> pDocOptions; // document options + std::unique_ptr<ScExtDocOptions> pExtDocOptions; // for import etc. + std::unique_ptr<ScClipOptions> mpClipOptions; // clipboard options + std::unique_ptr<ScConsolidateParam> pConsolidateDlgData; + std::unique_ptr<ScConditionMode> pConditionalFormatDialogMode; + + std::unique_ptr<ScAutoNameCache> pAutoNameCache; // for automatic name lookup during CompileXML + + std::unique_ptr<SfxItemSet> pPreviewFont; // convert to std::unique_ptr or whatever + ScStyleSheet* pPreviewCellStyle; + ScMarkData maPreviewSelection; + sal_Int64 nUnoObjectId; // counted up for UNO objects + + ErrCode nRangeOverflowType; // used in (xml) loading for overflow warnings + + ScRange aEmbedRange; + ScAddress aCurTextWidthCalcPos; + + Idle aTrackIdle; + + css::uno::Reference< css::script::vba::XVBAEventProcessor > + mxVbaEvents; +public: + /// list of ScInterpreterTableOpParams currently in use + std::vector<ScInterpreterTableOpParams*> m_TableOpList; + ScInterpreterTableOpParams aLastTableOpParams; // remember last params + +private: + + LanguageType eLanguage; // default language + LanguageType eCjkLanguage; // default language for asian text + LanguageType eCtlLanguage; // default language for complex text + rtl_TextEncoding eSrcSet; // during reading: source character set + + /** The compiler grammar used in document storage. GRAM_PODF for ODF 1.1 + documents, GRAM_ODFF for ODF 1.2 documents. */ + formula::FormulaGrammar::Grammar eStorageGrammar; + + sal_uInt64 nFormulaCodeInTree; // formula RPN in the formula tree + sal_uInt64 nXMLImportedFormulaCount; // progress count during XML import + sal_uInt16 nInterpretLevel; // >0 if in interpreter + sal_uInt16 nMacroInterpretLevel; // >0 if macro in interpreter + sal_uInt16 nInterpreterTableOpLevel; // >0 if in interpreter TableOp + + ScDocumentThreadSpecific maNonThreaded; + + // There can be only one ScDocument being calculated in a thread at a time, so we can use a + // plain thread_local static member. + thread_local static ScDocumentThreadSpecific maThreadSpecific; + + mutable ScInterpreterContext maInterpreterContext; + + std::shared_mutex mScLookupMutex; // protection for thread-unsafe parts of handling ScLookup + std::unique_ptr<ScSortedRangeCacheMap> mxScSortedRangeCache; // cache for unsorted lookups + + static const sal_uInt16 nSrcVer; // file version (load/save) + sal_uInt16 nFormulaTrackCount; + HardRecalcState eHardRecalcState; // off, temporary, eternal + SCTAB nVisibleTab; // for OLE etc., don't use inside ScDocument + SCCOL nPosLeft; // for OLE etc., don't use inside ScDocument + SCROW nPosTop; // for OLE etc., don't use inside ScDocument + + ScLkUpdMode eLinkMode; + + bool bAutoCalc; // calculate automatically + bool bAutoCalcShellDisabled; // in/from/for ScDocShell disabled + // are there ForcedFormulas which have to be calculated + // in interaction with ScDocShell SetDocumentModified, + // AutoCalcShellDisabled and TrackFormulas + bool bForcedFormulaPending; + bool bCalculatingFormulaTree; + bool bIsClip; + bool bIsUndo; + bool bIsFunctionAccess; + bool bIsVisible; // set from view ctor + + bool bIsEmbedded; // display/adjust Embedded area? + + // no broadcast, construct no listener during insert from a different + // Doc (per filter or the like ), not until CompileAll / CalcAfterLoad + bool bInsertingFromOtherDoc; + bool bLoadingMedium; + bool bImportingXML; // special handling of formula text + bool bCalcingAfterLoad; // in CalcAfterLoad TRUE + // don't construct/destruct listeners temporarily + bool bNoListening; + bool mbIdleEnabled; + bool bInLinkUpdate; // TableLink or AreaLink + bool bChartListenerCollectionNeedsUpdate; + // are/were there RC_FORCED formula cells in the document (if set once to TRUE then set forever) + bool bHasForcedFormulas; + // is the Doc being destroyed? (no Notify-Tracking etc. needed anymore) + bool bInDtorClear; + // expand reference if insert column/row takes place at the border + // of a reference + // is fetched in each UpdateReference from InputOptions, + // assigned, and restored at the end of UpdateReference + bool bExpandRefs; + // for detective update, is set for each change of a formula + bool bDetectiveDirty; + // If the pointer is set, formula cells will not be automatically grouped into shared formula groups, + // instead the range will be extended to contain all such cells. + std::unique_ptr< ScRange > pDelayedFormulaGrouping; + // If non-empty, ScColumn::StartListeningFormulaCells() calls may be delayed using this, + // avoiding repeated calling for the same cells in the given range. The function will be called once + // later for all the cells in the range. + std::unordered_map< ScColumn*, std::pair<SCROW, SCROW>> pDelayedStartListeningFormulaCells; + // Cells will not delete their broadcasters if delayed, avoiding possible extensive mdds vector changes. + bool bDelayedDeletingBroadcasters; + + bool bLinkFormulaNeedingCheck; // valid only after loading, for ocDde and ocWebservice + + CharCompressType nAsianCompression; + sal_uInt8 nAsianKerning; + + bool bPastingDrawFromOtherDoc; + + sal_uInt8 nInDdeLinkUpdate; // originating DDE links (stacked bool) + + bool bInUnoBroadcast; + bool bInUnoListenerCall; + sal_uInt32 nAdjustHeightLock; + formula::FormulaGrammar::Grammar eGrammar; + + mutable bool bStyleSheetUsageInvalid; + + bool mbUndoEnabled:1; + bool mbExecuteLinkEnabled:1; + bool mbChangeReadOnlyEnabled:1; // allow changes in read-only document (for API import filters) + bool mbStreamValidLocked:1; + bool mbUserInteractionEnabled:1; // whether or not to launch any kind of interactive dialogs. + + sal_Int16 mnNamedRangesLockCount; + + std::set<ScFormulaCell*> maSubTotalCells; + + + bool mbEmbedFonts : 1; + bool mbEmbedUsedFontsOnly : 1; + bool mbEmbedFontScriptLatin : 1; + bool mbEmbedFontScriptAsian : 1; + bool mbEmbedFontScriptComplex : 1; + + sal_Int32 mnImagePreferredDPI; + + std::unique_ptr<sc::IconSetBitmapMap> m_pIconSetBitmapMap; + + bool mbTrackFormulasPending : 1; + bool mbFinalTrackFormulas : 1; + // This indicates if a ScDocShell::DoRecalc() or ScDocShell::DoHardRecalc() is in progress. + bool mbDocShellRecalc : 1; + // This indicates if a ScOutputData::LayoutStrings() is in progress. + bool mbLayoutStrings : 1; + + size_t mnMutationGuardFlags; + +public: + bool IsCellInChangeTrack(const ScAddress &cell,Color *pColCellBorder); + void GetCellChangeTrackNote(const ScAddress &cell, OUString &strTrackText, bool &pbLeftEdge); + + bool IsEmbedFonts() const { return mbEmbedFonts; } + bool IsEmbedUsedFontsOnly() const { return mbEmbedUsedFontsOnly; } + bool IsEmbedFontScriptLatin() const { return mbEmbedFontScriptLatin; } + bool IsEmbedFontScriptAsian() const { return mbEmbedFontScriptAsian; } + bool IsEmbedFontScriptComplex() const { return mbEmbedFontScriptComplex; } + + void SetEmbedFonts(bool bUse) { mbEmbedFonts = bUse; } + void SetEmbedUsedFontsOnly(bool bUse) { mbEmbedUsedFontsOnly = bUse; } + void SetEmbedFontScriptLatin(bool bUse) { mbEmbedFontScriptLatin = bUse; } + void SetEmbedFontScriptAsian(bool bUse) { mbEmbedFontScriptAsian = bUse; } + void SetEmbedFontScriptComplex(bool bUse) { mbEmbedFontScriptComplex = bUse; } + + void SetImagePreferredDPI(sal_Int32 nValue) { mnImagePreferredDPI = nValue; } + sal_Int32 GetImagePreferredDPI() { return mnImagePreferredDPI; } + + SC_DLLPUBLIC sal_uInt64 GetCellCount() const; // all cells + SC_DLLPUBLIC sal_uInt64 GetFormulaGroupCount() const; // all cells + sal_uInt64 GetCodeCount() const; // RPN-Code in formulas + DECL_LINK( GetUserDefinedColor, sal_uInt16, Color* ); + // number formatter +public: + SC_DLLPUBLIC ScDocument( ScDocumentMode eMode = SCDOCMODE_DOCUMENT, + ScDocShell* pDocShell = nullptr ); + SC_DLLPUBLIC ~ScDocument(); + + void SetName( const OUString& r ) { aDocName = r; } + const OUString& GetCodeName() const { return aDocCodeName; } + void SetCodeName( const OUString& r ) { aDocCodeName = r; } + const OUString& GetFileURL() const { return maFileURL; } + + void GetDocStat( ScDocStat& rDocStat ); + + SC_DLLPUBLIC void InitDrawLayer( ScDocShell* pDocShell = nullptr ); + + ScInterpreterContext& GetNonThreadedContext() const + { + assert(!IsThreadedGroupCalcInProgress()); + return maInterpreterContext; + } + // Uses thread_local. + ScInterpreterContext& GetThreadedContext() const + { + return IsThreadedGroupCalcInProgress() ? *maThreadSpecific.pContext : GetNonThreadedContext(); + } + void SetupContextFromNonThreadedContext( ScInterpreterContext& threadedContext, int threadNumber ); + void MergeContextBackIntoNonThreadedContext( ScInterpreterContext& threadedContext, int threadNumber ); + void SetThreadedGroupCalcInProgress( bool set ) { (void)this; ScGlobal::bThreadedGroupCalcInProgress = set; } + bool IsThreadedGroupCalcInProgress() const { (void)this; return ScGlobal::bThreadedGroupCalcInProgress; } + + SC_DLLPUBLIC sfx2::LinkManager* GetLinkManager(); + SC_DLLPUBLIC const sfx2::LinkManager* GetLinkManager() const; + + sc::DocumentLinkManager& GetDocLinkManager(); + const sc::DocumentLinkManager& GetDocLinkManager() const; + + SC_DLLPUBLIC const ScDocOptions& GetDocOptions() const; + SC_DLLPUBLIC void SetDocOptions( const ScDocOptions& rOpt ); + SC_DLLPUBLIC const ScViewOptions& GetViewOptions() const; + SC_DLLPUBLIC void SetViewOptions( const ScViewOptions& rOpt ); + void SetPrintOptions(); + + ScExtDocOptions* GetExtDocOptions() { return pExtDocOptions.get(); } + SC_DLLPUBLIC void SetExtDocOptions( std::unique_ptr<ScExtDocOptions> pNewOptions ); + + ScClipOptions* GetClipOptions() { return mpClipOptions.get(); } + void SetClipOptions(std::unique_ptr<ScClipOptions> pClipOptions); + + SC_DLLPUBLIC void GetLanguage( LanguageType& rLatin, LanguageType& rCjk, LanguageType& rCtl ) const; + void SetLanguage( LanguageType eLatin, LanguageType eCjk, LanguageType eCtl ); + + void SetConsolidateDlgData( std::unique_ptr<ScConsolidateParam> pData ); + const ScConsolidateParam* GetConsolidateDlgData() const { return pConsolidateDlgData.get(); } + void SetEasyConditionalFormatDialogData(std::unique_ptr<ScConditionMode> pMode); + const ScConditionMode* GetEasyConditionalFormatDialogData() const { return pConditionalFormatDialogMode.get(); } + + void Clear( bool bFromDestructor = false ); + + std::unique_ptr<ScFieldEditEngine> CreateFieldEditEngine(); + void DisposeFieldEditEngine(std::unique_ptr<ScFieldEditEngine>& rpEditEngine); + + /** + * Get all range names that are local to each table. It only returns + * non-empty range name set. + */ + SC_DLLPUBLIC void GetAllTabRangeNames(ScRangeName::TabNameCopyMap& rRangeNames) const; + SC_DLLPUBLIC void SetAllRangeNames(const std::map<OUString, ScRangeName>& rRangeMap); + SC_DLLPUBLIC void GetRangeNameMap(std::map<OUString, ScRangeName*>& rRangeName); + SC_DLLPUBLIC ScRangeName* GetRangeName(SCTAB nTab) const; + SC_DLLPUBLIC ScRangeName* GetRangeName() const; + void SetRangeName(SCTAB nTab, std::unique_ptr<ScRangeName> pNew); + void SetRangeName( std::unique_ptr<ScRangeName> pNewRangeName ); + bool IsAddressInRangeName( RangeNameScope eScope, const ScAddress& rAddress); + + /** Find a named expression / range name in either global or a local scope. + @param nTab + If <0 search nIndex in global scope, if >=0 search nIndex in scope of nTab. + @param nIndex + Index of named expression / range name. + @return nullptr if indexed name not found. + */ + ScRangeData* FindRangeNameBySheetAndIndex( SCTAB nTab, sal_uInt16 nIndex ) const; + + /** Recursively find all named expressions that directly or indirectly + (nested) reference a given sheet, starting from a given named + expression nTokenTab/nTokenIndex. + + Used to collect all named expressions/ranges that will need to be + copied along when copying sheets. + + The different tab/sheets passed cater for the situation that a sheet is + copied and was already inserted and global names are already adjusted + but the sheet-local names of the shifted original sheet are not yet. If + no sheet was inserted and global and local names' references not + updated yet, then all 4 tab arguments would be identical. + + @param nTokenTab + Tab/sheet on which to find the name, -1 if global scope. + For example obtained from ocName token. + + @param nTokenIndex + Index of named expression. For example obtained from ocName token. + + @param nGlobalRefTab + Tab to check if used in global names. + + @param nLocalRefTab + Tab to check if used in sheet-local names. + + @param nOldTokenTab + The original tab of the copied sheet, used as sheet-local + base position for relative references. + + @param nOldTokenTabReplacement + The replacement to use for relative references if the name + encountered uses nOldTokenTab as base position. + + @param bSameDoc + FALSE if collecting names for a sheet to be copied to another + document. Then all names encountered are considered to be + referencing the sheet. Else TRUE if collecting names to be + copied into the same document. + + @param nRecursion + Recursion guard, initialize with 0. + */ + bool FindRangeNamesReferencingSheet( sc::UpdatedRangeNames& rIndexes, + SCTAB nTokenTab, const sal_uInt16 nTokenIndex, + SCTAB nGlobalRefTab, SCTAB nLocalRefTab, SCTAB nOldTokenTab, SCTAB nOldTokenTabReplacement, + bool bSameDoc, int nRecursion ) const; + + /** If necessary (name references sheet rOldPos.Tab()) copy and adjust + named expression/range from sheet-local to sheet-local, or global to + sheet-local if bGlobalNamesToLocal==true. + + Also copies nested names and adjusts the ocName tokens of the calling name. + + @param rSheet + On entry, the original sheet of the named expression/range, <0 global. + On return TRUE, the new sheet. Else unchanged. + + @param rIndex + On entry, the original index of the named expression/range. + On return TRUE, the new index, or 0 if a new copied name couldn't be inserted. Else unchanged. + + @param rpRangeData + On entry, the pointer to the original named expression/range. + On return TRUE, the pointer to the new copied name, or nullptr if hits happened. + + @param rNewPos + New position of formula cell if called for that, else new base + position of a to be created new name adjusted for Tab. + rNewPos.nTab MUST point to the new sheet copied to. + + @param rOldPos + Old position of formula cell if called for that, else base + position of the existing name adjusted for Tab. + rOldPos.nTab MUST point to the old sheet copied from. + + @param bGlobalNamesToLocal + If TRUE, affected global names are copied to sheet-local names. + If FALSE, global names are copied to global names in another document. + + @param bUsedByFormula + If TRUE, forces a global name to be affected/used. + If FALSE, a global name is only affected if it evaluates to be + referencing the sheet. + + @return TRUE if copied and caller may need to evaluate rpRangeData and rSheet and rIndex. + FALSE if nothing to be done. + */ + bool CopyAdjustRangeName( SCTAB& rSheet, sal_uInt16& rIndex, ScRangeData*& rpRangeData, ScDocument& rNewDoc, + const ScAddress& rNewPos, const ScAddress& rOldPos, const bool bGlobalNamesToLocal, + const bool bUsedByFormula ) const; + + /** + * Call this immediately before updating all named ranges. + */ + SC_DLLPUBLIC void PreprocessAllRangeNamesUpdate( const std::map<OUString, ScRangeName>& rRangeMap ); + SC_DLLPUBLIC void PreprocessRangeNameUpdate(); + SC_DLLPUBLIC void PreprocessDBDataUpdate(); + /** + * Call this immediately after updating named ranges. + */ + SC_DLLPUBLIC void CompileHybridFormula(); + + /** + * Insert a new named expression to the global scope. + * + * @param rName name for the expression. + * @param rPos base position. + * @param rExpr formula expression to be associated with the name. The + * current grammar is used to compile this expression. + * + * @return true if inserted successfully, false otherwise. + */ + bool InsertNewRangeName( const OUString& rName, const ScAddress& rPos, const OUString& rExpr ); + + /** + * Insert a new named expression to a sheet-local scope. + * + * @param nTab sheet for local scope. + * @param rName name for the expression. + * @param rPos base position. + * @param rExpr formula expression to be associated with the name. The + * current grammar is used to compile this expression. + * + * @return true if inserted successfully, false otherwise. + */ + bool InsertNewRangeName( SCTAB nTab, const OUString& rName, const ScAddress& rPos, const OUString& rExpr ); + + /** Obtain the sheet separator corresponding to the document's grammar. + + @return '.' for our own grammars, '!' for Excel grammars. + */ + SC_DLLPUBLIC sal_Unicode GetSheetSeparator() const; + + SCTAB GetMaxTableNumber() const { return static_cast<SCTAB>(maTabs.size()) - 1; } + + ScRangePairList* GetColNameRanges() { return xColNameRanges.get(); } + ScRangePairList* GetRowNameRanges() { return xRowNameRanges.get(); } + ScRangePairListRef& GetColNameRangesRef() { return xColNameRanges; } + ScRangePairListRef& GetRowNameRangesRef() { return xRowNameRanges; } + + SC_DLLPUBLIC SCCOL ClampToAllocatedColumns(SCTAB nTab, SCCOL nCol) const; + SC_DLLPUBLIC SCCOL GetAllocatedColumnsCount(SCTAB nTab) const; + + SC_DLLPUBLIC ScDBCollection* GetDBCollection() const { return pDBCollection.get();} + void SetDBCollection( std::unique_ptr<ScDBCollection> pNewDBCollection, + bool bRemoveAutoFilter = false ); + const ScDBData* GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, ScDBDataPortion ePortion) const; + ScDBData* GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, ScDBDataPortion ePortion); + SC_DLLPUBLIC const ScDBData* GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) const; + SC_DLLPUBLIC ScDBData* GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2); + void RefreshDirtyTableColumnNames(); + SC_DLLPUBLIC sc::ExternalDataMapper& GetExternalDataMapper(); + + SC_DLLPUBLIC const ScRangeData* GetRangeAtBlock( const ScRange& rBlock, OUString& rName, + bool* pSheetLocal = nullptr ) const; + + SC_DLLPUBLIC bool HasPivotTable() const; + SC_DLLPUBLIC ScDPCollection* GetDPCollection(); + SC_DLLPUBLIC const ScDPCollection* GetDPCollection() const; + SC_DLLPUBLIC ScDPObject* GetDPAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab) const; + SC_DLLPUBLIC ScDPObject* GetDPAtCursor(ScAddress const& rAddress) const + { + return GetDPAtCursor(rAddress.Col(), rAddress.Row(), rAddress.Tab()); + } + SC_DLLPUBLIC bool HasDataPilotAtPosition(ScAddress const& rAddress) const + { + return GetDPAtCursor(rAddress) != nullptr; + } + ScDPObject* GetDPAtBlock( const ScRange& rBlock ) const; + + void StopTemporaryChartLock(); + + void EnsureGraphicNames(); + + SdrObject* GetObjectAtPoint( SCTAB nTab, const Point& rPos ); + bool HasChartAtPoint( SCTAB nTab, const Point& rPos, OUString& rName ); + + css::uno::Reference< css::chart2::XChartDocument > GetChartByName( std::u16string_view rChartName ); + + SC_DLLPUBLIC void GetChartRanges( std::u16string_view rChartName, std::vector< ScRangeList >& rRanges, const ScDocument& rSheetNameDoc ); + void SetChartRanges( std::u16string_view rChartName, const std::vector< ScRangeList >& rRanges ); + + void UpdateChartArea( const OUString& rChartName, const ScRange& rNewArea, + bool bColHeaders, bool bRowHeaders, bool bAdd ); + void UpdateChartArea( const OUString& rChartName, + const ScRangeListRef& rNewList, + bool bColHeaders, bool bRowHeaders, bool bAdd ); + void GetOldChartParameters( std::u16string_view rName, + ScRangeList& rRanges, bool& rColHeaders, bool& rRowHeaders ); + css::uno::Reference< + css::embed::XEmbeddedObject > + FindOleObjectByName( std::u16string_view rName ); + + SC_DLLPUBLIC void MakeTable( SCTAB nTab,bool _bNeedsNameCheck = true ); + + SCTAB GetVisibleTab() const { return nVisibleTab; } + SC_DLLPUBLIC void SetVisibleTab(SCTAB nTab) { nVisibleTab = nTab; } + SCCOL GetPosLeft() const { return nPosLeft; } + SC_DLLPUBLIC void SetPosLeft(SCCOL nCol) { nPosLeft = nCol; } + SCROW GetPosTop() const { return nPosTop; } + SC_DLLPUBLIC void SetPosTop(SCROW nRow) { nPosTop = nRow; } + + SC_DLLPUBLIC bool HasTable( SCTAB nTab ) const; + SC_DLLPUBLIC bool GetHashCode( SCTAB nTab, sal_Int64& rHashCode) const; + SC_DLLPUBLIC bool GetName( SCTAB nTab, OUString& rName ) const; + SC_DLLPUBLIC bool GetCodeName( SCTAB nTab, OUString& rName ) const; + SC_DLLPUBLIC bool SetCodeName( SCTAB nTab, const OUString& rName ); + SC_DLLPUBLIC bool GetTable( const OUString& rName, SCTAB& rTab ) const; + SC_DLLPUBLIC SCCOL MaxCol() const { return mxSheetLimits->mnMaxCol; } + SC_DLLPUBLIC SCROW MaxRow() const { return mxSheetLimits->mnMaxRow; } + SC_DLLPUBLIC SCCOL GetMaxColCount() const { return mxSheetLimits->GetMaxColCount(); } + SC_DLLPUBLIC SCROW GetMaxRowCount() const { return mxSheetLimits->GetMaxRowCount(); } + SC_DLLPUBLIC OUString MaxRowAsString() const { return mxSheetLimits->MaxRowAsString(); } + SC_DLLPUBLIC OUString MaxColAsString() const { return mxSheetLimits->MaxColAsString(); } + ScSheetLimits& GetSheetLimits() const { return *mxSheetLimits; } + [[nodiscard]] bool ValidCol(SCCOL nCol) const { return ::ValidCol(nCol, mxSheetLimits->mnMaxCol); } + [[nodiscard]] bool ValidRow(SCROW nRow) const { return ::ValidRow(nRow, mxSheetLimits->mnMaxRow); } + [[nodiscard]] bool ValidColRow(SCCOL nCol, SCROW nRow) const { return ::ValidColRow(nCol, nRow, MaxCol(), MaxRow()); } + [[nodiscard]] bool ValidColRowTab(SCCOL nCol, SCROW nRow, SCTAB nTab) const { return ::ValidColRowTab(nCol, nRow, nTab, MaxCol(), MaxRow()); } + [[nodiscard]] bool ValidRange(const ScRange& rRange) const { return ::ValidRange(rRange, MaxCol(), MaxRow()); } + [[nodiscard]] bool ValidAddress(const ScAddress& rAddress) const { return ::ValidAddress(rAddress, MaxCol(), MaxRow()); } + [[nodiscard]] SCCOL SanitizeCol( SCCOL nCol ) const { return ::SanitizeCol(nCol, MaxCol()); } + [[nodiscard]] SCROW SanitizeRow( SCROW nRow ) const { return ::SanitizeRow(nRow, MaxRow()); } + + SC_DLLPUBLIC std::vector<OUString> GetAllTableNames() const; + + OUString GetCopyTabName(SCTAB nTab) const; + + SC_DLLPUBLIC void SetAnonymousDBData(SCTAB nTab, std::unique_ptr<ScDBData> pDBData); + SC_DLLPUBLIC ScDBData* GetAnonymousDBData(SCTAB nTab); + + /** One document global anonymous database range for temporary operations, + used if the corresponding sheet-local anonymous database range is + already used with AutoFilter and range differs. Not stored in document + files. */ + SC_DLLPUBLIC void SetAnonymousDBData(std::unique_ptr<ScDBData> pDBData); + SC_DLLPUBLIC ScDBData* GetAnonymousDBData(); + + SC_DLLPUBLIC SCTAB GetTableCount() const; + SvNumberFormatterIndexTable* GetFormatExchangeList() const { return pFormatExchangeList; } + + SC_DLLPUBLIC ScDocProtection* GetDocProtection() const; + SC_DLLPUBLIC void SetDocProtection(const ScDocProtection* pProtect); + SC_DLLPUBLIC bool IsDocProtected() const; + bool IsDocEditable() const; + SC_DLLPUBLIC bool IsTabProtected( SCTAB nTab ) const; + SC_DLLPUBLIC const ScTableProtection* GetTabProtection(SCTAB nTab) const; + SC_DLLPUBLIC void SetTabProtection(SCTAB nTab, const ScTableProtection* pProtect); + void CopyTabProtection(SCTAB nTabSrc, SCTAB nTabDest); + + void LockTable(SCTAB nTab); + void UnlockTable(SCTAB nTab); + + bool IsBlockEditable( SCTAB nTab, SCCOL nStartCol, SCROW nStartRow, + SCCOL nEndCol, SCROW nEndRow, + bool* pOnlyNotBecauseOfMatrix = nullptr, + bool bNoMatrixAtAll = false ) const; + bool IsSelectionEditable( const ScMarkData& rMark, + bool* pOnlyNotBecauseOfMatrix = nullptr ) const; + bool HasSelectedBlockMatrixFragment( SCCOL nStartCol, SCROW nStartRow, + SCCOL nEndCol, SCROW nEndRow, + const ScMarkData& rMark ) const; + + bool IsEditActionAllowed( sc::ColRowEditAction eAction, SCTAB nTab, SCCOLROW nStart, SCCOLROW nEnd ) const; + bool IsEditActionAllowed( sc::ColRowEditAction eAction, const ScMarkData& rMark, SCCOLROW nStart, SCCOLROW nEnd ) const; + + SC_DLLPUBLIC bool GetMatrixFormulaRange( const ScAddress& rCellPos, ScRange& rMatrix ); + + bool IsEmbedded() const { return bIsEmbedded;} + void GetEmbedded( ScRange& rRange ) const; + void SetEmbedded( const ScRange& rRange ); + void ResetEmbedded(); + tools::Rectangle GetEmbeddedRect() const; // 1/100 mm + void SetEmbedded( SCTAB nTab, const tools::Rectangle& rRect ); // from VisArea (1/100 mm) + + static SC_DLLPUBLIC bool ValidTabName( const OUString& rName ); + + SC_DLLPUBLIC bool ValidNewTabName( const OUString& rName ) const; + SC_DLLPUBLIC void CreateValidTabName(OUString& rName) const; + SC_DLLPUBLIC void CreateValidTabNames(std::vector<OUString>& aNames, SCTAB nCount) const; + + void AppendTabOnLoad(const OUString& rName); + void SetTabNameOnLoad(SCTAB nTab, const OUString& rName); + void InvalidateStreamOnSave(); + + SC_DLLPUBLIC bool InsertTab( SCTAB nPos, const OUString& rName, + bool bExternalDocument = false, bool bUndoDeleteTab = false ); + + SC_DLLPUBLIC bool InsertTabs( SCTAB nPos, const std::vector<OUString>& rNames, + bool bNamesValid = false ); + SC_DLLPUBLIC bool DeleteTabs( SCTAB nTab, SCTAB nSheets ); + SC_DLLPUBLIC bool DeleteTab( SCTAB nTab ); + SC_DLLPUBLIC bool RenameTab( SCTAB nTab, const OUString& rName, + bool bExternalDocument = false ); + bool MoveTab( SCTAB nOldPos, SCTAB nNewPos, ScProgress* pProgress = nullptr ); + SC_DLLPUBLIC bool CopyTab( SCTAB nOldPos, SCTAB nNewPos, + const ScMarkData* pOnlyMarked = nullptr ); + SC_DLLPUBLIC sal_uLong TransferTab(ScDocument& rSrcDoc, SCTAB nSrcPos, SCTAB nDestPos, + bool bInsertNew = true, + bool bResultsOnly = false ); + SC_DLLPUBLIC void TransferDrawPage(const ScDocument& rSrcDoc, SCTAB nSrcPos, SCTAB nDestPos); + SC_DLLPUBLIC void SetVisible( SCTAB nTab, bool bVisible ); + SC_DLLPUBLIC bool IsVisible( SCTAB nTab ) const; + bool IsStreamValid( SCTAB nTab ) const; + void SetStreamValid( SCTAB nTab, bool bSet, bool bIgnoreLock = false ); + void LockStreamValid( bool bLock ); + bool IsStreamValidLocked() const { return mbStreamValidLocked; } + bool IsPendingRowHeights( SCTAB nTab ) const; + void SetPendingRowHeights( SCTAB nTab, bool bSet ); + sal_uInt16 GetSheetOptimalMinRowHeight(SCTAB nTab) const; + SC_DLLPUBLIC void SetLayoutRTL( SCTAB nTab, bool bRTL, ScObjectHandling eObjectHandling = ScObjectHandling::RecalcPosMode); + SC_DLLPUBLIC bool IsLayoutRTL( SCTAB nTab ) const; + SC_DLLPUBLIC bool IsNegativePage( SCTAB nTab ) const; + SC_DLLPUBLIC void SetScenario( SCTAB nTab, bool bFlag ); + SC_DLLPUBLIC bool IsScenario( SCTAB nTab ) const; + SC_DLLPUBLIC void GetScenarioData(SCTAB nTab, OUString& rComment, + Color& rColor, ScScenarioFlags &rFlags) const; + SC_DLLPUBLIC void SetScenarioData(SCTAB nTab, const OUString& rComment, + const Color& rColor, ScScenarioFlags nFlags); + SC_DLLPUBLIC Color GetTabBgColor( SCTAB nTab ) const; + SC_DLLPUBLIC void SetTabBgColor( SCTAB nTab, const Color& rColor ); + SC_DLLPUBLIC bool IsDefaultTabBgColor( SCTAB nTab ) const; + void GetScenarioFlags(SCTAB nTab, ScScenarioFlags &rFlags) const; + SC_DLLPUBLIC bool IsActiveScenario( SCTAB nTab ) const; + SC_DLLPUBLIC void SetActiveScenario( SCTAB nTab, bool bActive ); // only for Undo etc. + SC_DLLPUBLIC formula::FormulaGrammar::AddressConvention GetAddressConvention() const; + SC_DLLPUBLIC formula::FormulaGrammar::Grammar GetGrammar() const { return eGrammar;} + SC_DLLPUBLIC void SetGrammar( formula::FormulaGrammar::Grammar eGram ); + SC_DLLPUBLIC ScLinkMode GetLinkMode( SCTAB nTab ) const; + bool IsLinked( SCTAB nTab ) const; + SC_DLLPUBLIC OUString GetLinkDoc( SCTAB nTab ) const; + OUString GetLinkFlt( SCTAB nTab ) const; + OUString GetLinkOpt( SCTAB nTab ) const; + SC_DLLPUBLIC OUString GetLinkTab( SCTAB nTab ) const; + sal_uLong GetLinkRefreshDelay( SCTAB nTab ) const; + void SetLink( SCTAB nTab, ScLinkMode nMode, const OUString& rDoc, + const OUString& rFilter, const OUString& rOptions, + const OUString& rTabName, sal_uLong nRefreshDelay ); + bool HasLink( std::u16string_view rDoc, + std::u16string_view rFilter, std::u16string_view rOptions ) const; + SC_DLLPUBLIC bool LinkExternalTab( SCTAB& nTab, const OUString& aDocTab, + const OUString& aFileName, + const OUString& aTabName ); + + bool HasExternalRefManager() const { return bool(pExternalRefMgr); } + SC_DLLPUBLIC ScExternalRefManager* GetExternalRefManager() const; + bool IsInExternalReferenceMarking() const; + void MarkUsedExternalReferences(); + bool MarkUsedExternalReferences( const ScTokenArray& rArr, const ScAddress& rPos ); + + /** Returns the pool containing external formula parsers. Creates the pool + on first call. */ + ScFormulaParserPool& GetFormulaParserPool() const; + + bool HasAreaLinks() const; + void UpdateExternalRefLinks(weld::Window* pWin); + void UpdateAreaLinks(); + + // originating DDE links + void IncInDdeLinkUpdate() { if ( nInDdeLinkUpdate < 255 ) ++nInDdeLinkUpdate; } + void DecInDdeLinkUpdate() { if ( nInDdeLinkUpdate ) --nInDdeLinkUpdate; } + bool IsInDdeLinkUpdate() const { return nInDdeLinkUpdate != 0; } + + SC_DLLPUBLIC void CopyDdeLinks( ScDocument& rDestDoc ) const; + + /** Tries to find a DDE link with the specified connection data. + @param rnDdePos (out-param) Returns the index of the DDE link (does not include other links from link manager). + @return true = DDE link found, rnDdePos valid. */ + SC_DLLPUBLIC bool FindDdeLink( std::u16string_view rAppl, std::u16string_view rTopic, + std::u16string_view rItem, sal_uInt8 nMode, size_t& rnDdePos ); + + /** Returns the connection data of the specified DDE link. + @param nDdePos Index of the DDE link (does not include other links from link manager). + @param rAppl (out-param) The application name. + @param rTopic (out-param) The DDE topic. + @param rItem (out-param) The DDE item. + @return true = DDE link found, out-parameters valid. */ + bool GetDdeLinkData( size_t nDdePos, OUString& rAppl, OUString& rTopic, OUString& rItem ) const; + /** Returns the link mode of the specified DDE link. + @param nDdePos Index of the DDE link (does not include other links from link manager). + @param rnMode (out-param) The link mode of the specified DDE link. + @return true = DDE link found, rnMode valid. */ + bool GetDdeLinkMode( size_t nDdePos, sal_uInt8& rnMode ) const; + /** Returns the result matrix of the specified DDE link. + @param nDdePos Index of the DDE link (does not include other links from link manager). + @return The result matrix, if the DDE link has been found, 0 otherwise. */ + SC_DLLPUBLIC const ScMatrix* GetDdeLinkResultMatrix( size_t nDdePos ) const; + + /** Tries to find a DDE link or creates a new, if not extant. + @param pResults If not 0, sets the matrix as DDE link result matrix (also for existing links). + @return true = DDE link found; false = Unpredictable error occurred, no DDE link created. */ + SC_DLLPUBLIC bool CreateDdeLink( const OUString& rAppl, const OUString& rTopic, const OUString& rItem, sal_uInt8 nMode, const ScMatrixRef& pResults ); + /** Sets a result matrix for the specified DDE link. + @param nDdePos Index of the DDE link (does not include other links from link manager). + @param pResults The array containing all results of the DDE link (intrusive-ref-counted, do not delete). + @return true = DDE link found and matrix set. */ + bool SetDdeLinkResultMatrix( size_t nDdePos, const ScMatrixRef& pResults ); + + SfxBindings* GetViewBindings(); + ScDocShell* GetDocumentShell() const { return mpShell; } + SC_DLLPUBLIC ScDrawLayer* GetDrawLayer() { return mpDrawLayer.get(); } + SC_DLLPUBLIC const ScDrawLayer* GetDrawLayer() const { return mpDrawLayer.get(); } + SfxBroadcaster* GetDrawBroadcaster(); // to avoid header + void BeginDrawUndo(); + + void BeginUnoRefUndo(); + bool HasUnoRefUndo() const { return ( pUnoRefUndoList != nullptr ); } + [[nodiscard]] + std::unique_ptr<ScUnoRefList> EndUnoRefUndo(); // must be deleted by caller! + sal_Int64 GetNewUnoId() { return ++nUnoObjectId; } + void AddUnoRefChange( sal_Int64 nId, const ScRangeList& rOldRanges ); + + static bool IsChart( const SdrObject* pObject ); + + void UpdateChartRef( UpdateRefMode eUpdateRefMode, + SCCOL nCol1, SCROW nRow1, SCTAB nTab1, + SCCOL nCol2, SCROW nRow2, SCTAB nTab2, + SCCOL nDx, SCROW nDy, SCTAB nDz ); + //! only assigns the new RangeList, no ChartListener or the like + void SetChartRangeList( std::u16string_view rChartName, + const ScRangeListRef& rNewRangeListRef ); + + void StartAnimations( SCTAB nTab ); + + bool HasBackgroundDraw( SCTAB nTab, const tools::Rectangle& rMMRect ) const; + bool HasAnyDraw( SCTAB nTab, const tools::Rectangle& rMMRect ) const; + + const ScSheetEvents* GetSheetEvents( SCTAB nTab ) const; + void SetSheetEvents( SCTAB nTab, std::unique_ptr<ScSheetEvents> pNew ); + bool HasSheetEventScript( SCTAB nTab, ScSheetEventId nEvent, bool bWithVbaEvents = false ) const; + bool HasAnySheetEventScript( ScSheetEventId nEvent, bool bWithVbaEvents = false ) const; // on any sheet + + bool HasAnyCalcNotification() const; + bool HasCalcNotification( SCTAB nTab ) const; + void SetCalcNotification( SCTAB nTab ); + void ResetCalcNotifications(); + + SC_DLLPUBLIC ScOutlineTable* GetOutlineTable( SCTAB nTab, bool bCreate = false ); + bool SetOutlineTable( SCTAB nTab, const ScOutlineTable* pNewOutline ); + + void DoAutoOutline( SCCOL nStartCol, SCROW nStartRow, + SCCOL nEndCol, SCROW nEndRow, SCTAB nTab ); + + bool DoSubTotals( SCTAB nTab, ScSubTotalParam& rParam ); + void RemoveSubTotals( SCTAB nTab, ScSubTotalParam& rParam ); + bool TestRemoveSubTotals( SCTAB nTab, const ScSubTotalParam& rParam ); + bool HasSubTotalCells( const ScRange& rRange ); + + SC_DLLPUBLIC void EnsureTable( SCTAB nTab ); + + // return TRUE = number format is set + SC_DLLPUBLIC bool SetString( SCCOL nCol, SCROW nRow, SCTAB nTab, const OUString& rString, + const ScSetStringParam * pParam = nullptr ); + SC_DLLPUBLIC bool SetString( const ScAddress& rPos, const OUString& rString, + const ScSetStringParam* pParam = nullptr ); + + /** + * This method manages the lifecycle of the passed edit text object. When + * the text is successfully inserted, the cell takes over the ownership of + * the text object. If not, the text object gets deleted. + * + * <p>The caller must ensure that the passed edit text object <i>uses the + * SfxItemPool instance returned from ScDocument::GetEditPool()</i>. + * This is very important.</p> + */ + SC_DLLPUBLIC bool SetEditText( const ScAddress& rPos, std::unique_ptr<EditTextObject> pEditText ); + void SetEditText( const ScAddress& rPos, const EditTextObject& rEditText, const SfxItemPool* pEditPool ); + SC_DLLPUBLIC void SetEditText( const ScAddress& rPos, const OUString& rStr ); + SC_DLLPUBLIC SCROW GetFirstEditTextRow( const ScRange& rRange ) const; + + /** + * Call this if you are not sure whether to put this as an edit text or a + * simple text. + */ + SC_DLLPUBLIC void SetTextCell( const ScAddress& rPos, const OUString& rStr ); + void SetEmptyCell( const ScAddress& rPos ); + SC_DLLPUBLIC void SetValue( SCCOL nCol, SCROW nRow, SCTAB nTab, const double& rVal ); + SC_DLLPUBLIC void SetValue( const ScAddress& rPos, double fVal ); + void SetValues( const ScAddress& rPos, const std::vector<double>& rVals ); + void SetError( SCCOL nCol, SCROW nRow, SCTAB nTab, const FormulaError nError); + SC_DLLPUBLIC void SetFormula( const ScAddress& rPos, const ScTokenArray& rArray ); + SC_DLLPUBLIC void SetFormula( const ScAddress& rPos, const OUString& rFormula, + formula::FormulaGrammar::Grammar eGram ); + + /** + * Set formula cell, and transfer its ownership to the document. This call + * attempts to group the passed formula cell with the adjacent cells or + * cell groups if appropriate. + * + * @return pCell if it was successfully inserted, NULL otherwise. pCell + * is deleted automatically on failure to insert. + */ + SC_DLLPUBLIC ScFormulaCell* SetFormulaCell( const ScAddress& rPos, ScFormulaCell* pCell ); + bool SetFormulaCells( const ScAddress& rPos, std::vector<ScFormulaCell*>& rCells ); + + /** + * Check if there is at least one formula cell in specified range. + */ + bool HasFormulaCell( const ScRange& rRange ) const; + SC_DLLPUBLIC void InsertMatrixFormula(SCCOL nCol1, SCROW nRow1, + SCCOL nCol2, SCROW nRow2, + const ScMarkData& rMark, + const OUString& rFormula, + const ScTokenArray* p = nullptr, + const formula::FormulaGrammar::Grammar = formula::FormulaGrammar::GRAM_DEFAULT ); + SC_DLLPUBLIC void InsertTableOp(const ScTabOpParam& rParam, // multi-operation + SCCOL nCol1, SCROW nRow1, + SCCOL nCol2, SCROW nRow2, const ScMarkData& rMark); + + SC_DLLPUBLIC OUString GetString( SCCOL nCol, SCROW nRow, SCTAB nTab, + const ScInterpreterContext* pContext = nullptr ) const; + SC_DLLPUBLIC OUString GetString( const ScAddress& rPos, + const ScInterpreterContext* pContext = nullptr ) const; + + /** + * Return a pointer to the double value stored in value cell. + * + * @param rPos cell position + * + * @return pointer to the double value stored in a numeric cell, or NULL + * if the cell at specified position is not a numeric cell. + */ + SC_DLLPUBLIC double* GetValueCell( const ScAddress& rPos ); + + SC_DLLPUBLIC svl::SharedStringPool& GetSharedStringPool(); + const svl::SharedStringPool& GetSharedStringPool() const; + + svl::SharedString GetSharedString( const ScAddress& rPos ) const; + + std::shared_ptr<sc::FormulaGroupContext>& GetFormulaGroupContext(); + void DiscardFormulaGroupContext(); + void BlockFormulaGroupContextDiscard( bool block ) + { mbFormulaGroupCxtBlockDiscard = block; } + + // Note that if pShared is set and a value is returned that way, the returned OUString is empty. + SC_DLLPUBLIC OUString GetInputString( SCCOL nCol, SCROW nRow, SCTAB nTab, bool bForceSystemLocale = false ) const; + FormulaError GetStringForFormula( const ScAddress& rPos, OUString& rString ); + SC_DLLPUBLIC double GetValue( const ScAddress& rPos ) const; + SC_DLLPUBLIC double GetValue( SCCOL nCol, SCROW nRow, SCTAB nTab ) const; + SC_DLLPUBLIC const EditTextObject* GetEditText( const ScAddress& rPos ) const; + void RemoveEditTextCharAttribs( const ScAddress& rPos, const ScPatternAttr& rAttr ); + SC_DLLPUBLIC double RoundValueAsShown( double fVal, sal_uInt32 nFormat, const ScInterpreterContext* pContext = nullptr ) const; + SC_DLLPUBLIC sal_uInt32 GetNumberFormat( SCCOL nCol, SCROW nRow, SCTAB nTab ) const; + sal_uInt32 GetNumberFormat( const ScRange& rRange ) const; + SC_DLLPUBLIC sal_uInt32 GetNumberFormat( const ScInterpreterContext& rContext, const ScAddress& ) const; + SC_DLLPUBLIC void SetNumberFormat( const ScAddress& rPos, sal_uInt32 nNumberFormat ); + + void GetNumberFormatInfo( const ScInterpreterContext& rContext, SvNumFormatType& nType, sal_uInt32& nIndex, const ScAddress& rPos ) const; + SC_DLLPUBLIC const ScFormulaCell* GetFormulaCell( const ScAddress& rPos ) const; + SC_DLLPUBLIC ScFormulaCell* GetFormulaCell( const ScAddress& rPos ); + SC_DLLPUBLIC OUString GetFormula( SCCOL nCol, SCROW nRow, SCTAB nTab ) const; + SC_DLLPUBLIC CellType GetCellType( SCCOL nCol, SCROW nRow, SCTAB nTab ) const; + SC_DLLPUBLIC CellType GetCellType( const ScAddress& rPos ) const; + + SC_DLLPUBLIC bool HasData( SCCOL nCol, SCROW nRow, SCTAB nTab ); + SC_DLLPUBLIC bool HasStringData( SCCOL nCol, SCROW nRow, SCTAB nTab ) const; + SC_DLLPUBLIC bool HasValueData( SCCOL nCol, SCROW nRow, SCTAB nTab ) const; + SC_DLLPUBLIC bool HasValueData( const ScAddress& rPos ) const; + bool HasStringCells( const ScRange& rRange ) const; + + /** Returns true, if there is any data to create a selection list for rPos. */ + bool HasSelectionData( SCCOL nCol, SCROW nRow, SCTAB nTab ) const; + bool HasValidationData( SCCOL nCol, SCROW nRow, SCTAB nTab ) const; + + /** + * Check if the specified range contains either: 1) one non-empty cell, 2) + * more than one non-empty cells, or 3) totally empty. In case the range + * contains at least one non-empty cell, specify the position of the first + * non-empty cell. + */ + sc::MultiDataCellState HasMultipleDataCells( const ScRange& rRange ) const; + + // Spaklines + /** Returns sparkline at the address if it exists */ + SC_DLLPUBLIC std::shared_ptr<sc::Sparkline> GetSparkline(ScAddress const & rPosition); + SC_DLLPUBLIC bool HasSparkline(ScAddress const & rPosition); + SC_DLLPUBLIC sc::Sparkline* CreateSparkline(ScAddress const & rPosition, std::shared_ptr<sc::SparklineGroup> const& pSparklineGroup); + SC_DLLPUBLIC sc::SparklineList* GetSparklineList(SCTAB nTab); + SC_DLLPUBLIC bool DeleteSparkline(ScAddress const& rPosition); + + /** + * Returns true if the whole range covers one and the same sparkline + * group and returns the group via out parameter + */ + SC_DLLPUBLIC bool GetSparklineGroupInRange(ScRange const& rRange, std::shared_ptr<sc::SparklineGroup>& rGroup); + SC_DLLPUBLIC bool HasOneSparklineGroup(ScRange const& rRange); + SC_DLLPUBLIC std::shared_ptr<sc::SparklineGroup> SearchSparklineGroup(tools::Guid const& rGuid); + + // Notes + SC_DLLPUBLIC ScPostIt* GetNote(const ScAddress& rPos); + SC_DLLPUBLIC ScPostIt* GetNote(SCCOL nCol, SCROW nRow, SCTAB nTab); + void SetNote(const ScAddress& rPos, std::unique_ptr<ScPostIt> pNote); + void SetNote(SCCOL nCol, SCROW nRow, SCTAB nTab, std::unique_ptr<ScPostIt> pNote); + SC_DLLPUBLIC bool HasNote(const ScAddress& rPos) const; + bool HasNote(SCCOL nCol, SCROW nRow, SCTAB nTab) const; + bool HasNote(SCTAB nTab, SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow) const; + SC_DLLPUBLIC bool HasColNotes(SCCOL nCol, SCTAB nTab) const; + SC_DLLPUBLIC bool HasTabNotes(SCTAB nTab) const; + bool HasNotes() const; + SC_DLLPUBLIC std::unique_ptr<ScPostIt> ReleaseNote(const ScAddress& rPos); + SC_DLLPUBLIC ScPostIt* GetOrCreateNote(const ScAddress& rPos); + SC_DLLPUBLIC ScPostIt* CreateNote(const ScAddress& rPos); + size_t GetNoteCount( SCTAB nTab, SCCOL nCol ) const; + + /** + * Ensure that all note objects have an associated sdr object. The export + * code uses sdr objects to export note data. + */ + void CreateAllNoteCaptions(); + void ForgetNoteCaptions( const ScRangeList& rRanges, bool bPreserveData ); + CommentCaptionState GetAllNoteCaptionsState( const ScRangeList& rRanges); + + ScAddress GetNotePosition( size_t nIndex ) const; + ScAddress GetNotePosition( size_t nIndex, SCTAB nTab ) const; + SCROW GetNotePosition( SCTAB nTab, SCCOL nCol, size_t nIndex ) const; + + SC_DLLPUBLIC void GetAllNoteEntries( std::vector<sc::NoteEntry>& rNotes ) const; + SC_DLLPUBLIC void GetAllNoteEntries( SCTAB nTab, std::vector<sc::NoteEntry>& rNotes ) const; + void GetNotesInRange( const ScRangeList& rRange, std::vector<sc::NoteEntry>& rNotes ) const; + + bool ContainsNotesInRange( const ScRangeList& rRange ) const; + + SC_DLLPUBLIC void SetDrawPageSize(SCTAB nTab); + + bool IsMerged( const ScAddress& rPos ) const; + + void ExtendMergeSel( SCCOL nStartCol, SCROW nStartRow, + SCCOL& rEndCol, SCROW& rEndRow, const ScMarkData& rMark, + bool bRefresh = false ); + SC_DLLPUBLIC bool ExtendMerge( SCCOL nStartCol, SCROW nStartRow, + SCCOL& rEndCol, SCROW& rEndRow, SCTAB nTab, + bool bRefresh = false ); + bool ExtendMerge( ScRange& rRange, bool bRefresh = false ); + SC_DLLPUBLIC void ExtendTotalMerge( ScRange& rRange ) const; + SC_DLLPUBLIC void ExtendOverlapped( SCCOL& rStartCol, SCROW& rStartRow, + SCCOL nEndCol, SCROW nEndRow, SCTAB nTab ) const; + SC_DLLPUBLIC void ExtendOverlapped( ScRange& rRange ) const; + + bool RefreshAutoFilter( SCCOL nStartCol, SCROW nStartRow, + SCCOL nEndCol, SCROW nEndRow, SCTAB nTab ); + + SC_DLLPUBLIC void DoMergeContents( SCCOL nStartCol, SCROW nStartRow, + SCCOL nEndCol, SCROW nEndRow, SCTAB nTab ); + SC_DLLPUBLIC void DoEmptyBlock( SCCOL nStartCol, SCROW nStartRow, + SCCOL nEndCol, SCROW nEndRow, SCTAB nTab ); + // without checking: + SC_DLLPUBLIC void DoMerge( SCCOL nStartCol, SCROW nStartRow, + SCCOL nEndCol, SCROW nEndRow, SCTAB nTab, bool bDeleteCaptions = true ); + void RemoveMerge( SCCOL nCol, SCROW nRow, SCTAB nTab ); + + // This also includes e.g. notes. Use IsEmptyData() for cell data only. + bool IsBlockEmpty( SCCOL nStartCol, SCROW nStartRow, + SCCOL nEndCol, SCROW nEndRow, SCTAB nTab ) const; + bool IsPrintEmpty( SCCOL nStartCol, SCROW nStartRow, + SCCOL nEndCol, SCROW nEndRow, SCTAB nTab, + bool bLeftIsEmpty = false, + ScRange* pLastRange = nullptr, + tools::Rectangle* pLastMM = nullptr ) const; + + void SkipOverlapped( SCCOL& rCol, SCROW& rRow, SCTAB nTab ) const; + bool IsHorOverlapped( SCCOL nCol, SCROW nRow, SCTAB nTab ) const; + bool IsVerOverlapped( SCCOL nCol, SCROW nRow, SCTAB nTab, + SCROW* nStartRow = nullptr, SCROW* nEndRow = nullptr ) const; + + SC_DLLPUBLIC bool HasAttrib( SCCOL nCol1, SCROW nRow1, SCTAB nTab1, + SCCOL nCol2, SCROW nRow2, SCTAB nTab2, HasAttrFlags nMask ) const; + SC_DLLPUBLIC bool HasAttrib( const ScRange& rRange, HasAttrFlags nMask ) const; + bool HasAttrib( SCCOL nCol, SCROW nRow, SCTAB nTab, HasAttrFlags nMask, + SCROW* nStartRow = nullptr, SCROW* nEndRow = nullptr ) const; + + SC_DLLPUBLIC void GetBorderLines( SCCOL nCol, SCROW nRow, SCTAB nTab, + const ::editeng::SvxBorderLine** ppLeft, + const ::editeng::SvxBorderLine** ppTop, + const ::editeng::SvxBorderLine** ppRight, + const ::editeng::SvxBorderLine** ppBottom ) const; + + void ResetChanged( const ScRange& rRange ); + + void CheckVectorizationState(); + void SetAllFormulasDirty( const sc::SetFormulaDirtyContext& rCxt ); + void SetDirty( const ScRange&, bool bIncludeEmptyCells ); + void SetTableOpDirty( const ScRange& ); // for Interpreter TableOp + void InterpretDirtyCells( const ScRangeList& rRanges ); + // Interprets cells that have NeedsInterpret(), i.e. the same like calling MaybeInterpret() on them. + // Returns false if some couldn't be interpreted (i.e. they still have NeedsInterpret()). + // Useful to ensure that the given cells will not need interpreting. + bool InterpretCellsIfNeeded( const ScRangeList& rRanges ); + SC_DLLPUBLIC void CalcAll(); + SC_DLLPUBLIC void CalcAfterLoad( bool bStartListening = true ); + void CompileAll(); + void CompileXML(); + + /** + * Re-compile formula cells with error. + * + * @param nErrCode specified error code to match. Only those cells with + * this error code will be re-compiled. If this value is + * 0, cells with any error values will be re-compiled. + * + * @return true if at least one cell is re-compiled, false if no cells are + * re-compiled. + */ + bool CompileErrorCells(FormulaError nErrCode); + + ScAutoNameCache* GetAutoNameCache() { return pAutoNameCache.get(); } + void SetPreviewFont( std::unique_ptr<SfxItemSet> pFontSet ); + SfxItemSet* GetPreviewFont() { return pPreviewFont.get(); } + SfxItemSet* GetPreviewFont( SCCOL nCol, SCROW nRow, SCTAB nTab ); + const ScMarkData& GetPreviewSelection() const { return maPreviewSelection; } + void SetPreviewSelection( const ScMarkData& rSel ); + ScStyleSheet* GetPreviewCellStyle() { return pPreviewCellStyle; } + ScStyleSheet* GetPreviewCellStyle( SCCOL nCol, SCROW nRow, SCTAB nTab ); + void SetPreviewCellStyle( ScStyleSheet* pStyle ) { pPreviewCellStyle = pStyle; } + SC_DLLPUBLIC void SetAutoNameCache( std::unique_ptr<ScAutoNameCache> pCache ); + + /** Creates a ScLookupCache cache for the range if it + doesn't already exist. */ + ScLookupCache & GetLookupCache( const ScRange & rRange, ScInterpreterContext* pContext ); + ScSortedRangeCache & GetSortedRangeCache( const ScRange & rRange, const ScQueryParam& param, + ScInterpreterContext* pContext ); + /** Only ScLookupCache dtor uses RemoveLookupCache(), do + not use elsewhere! */ + void RemoveLookupCache( ScLookupCache & rCache ); + void RemoveSortedRangeCache( ScSortedRangeCache & rCache ); + /** Zap all caches. */ + void ClearLookupCaches(); + + // calculate automatically + SC_DLLPUBLIC void SetAutoCalc( bool bNewAutoCalc ); + SC_DLLPUBLIC bool GetAutoCalc() const { return bAutoCalc; } + // calculate automatically in/from/for ScDocShell disabled + void SetAutoCalcShellDisabled( bool bNew ) { bAutoCalcShellDisabled = bNew; } + bool IsAutoCalcShellDisabled() const { return bAutoCalcShellDisabled; } + // ForcedFormulas are to be calculated + void SetForcedFormulaPending( bool bNew ) { bForcedFormulaPending = bNew; } + bool IsForcedFormulaPending() const { return bForcedFormulaPending; } + // if CalcFormulaTree() is currently running + bool IsCalculatingFormulaTree() const { return bCalculatingFormulaTree; } + /// If set, joining cells into shared formula groups will be delayed until reset again + /// (RegroupFormulaCells() will be called as needed). + void DelayFormulaGrouping( bool delay ); + bool IsDelayedFormulaGrouping() const { return bool(pDelayedFormulaGrouping); } + /// To be used only by SharedFormulaUtil::joinFormulaCells(). + void AddDelayedFormulaGroupingCell( const ScFormulaCell* cell ); + /// If set, ScColumn::StartListeningFormulaCells() calls may be delayed using + /// CanDelayStartListeningFormulaCells() until reset again, at which point the function will + /// be called as necessary. + void EnableDelayStartListeningFormulaCells( ScColumn* column, bool delay ); + bool IsEnabledDelayStartListeningFormulaCells( ScColumn* column ) const; + /// If true is returned, ScColumn::StartListeningFormulaCells() for the given cells will be performed + /// later. If false is returned, it needs to be done explicitly. + bool CanDelayStartListeningFormulaCells( ScColumn* column, SCROW row1, SCROW row2 ); + /// If set, cells will not delete their empty broadcasters, avoiding possible extensive mdds + /// vector changes. Disabling delay will collect and delete all empty broadcasters. + void EnableDelayDeletingBroadcasters(bool set); + bool IsDelayedDeletingBroadcasters() const { return bDelayedDeletingBroadcasters; } + + FormulaError GetErrCode( const ScAddress& ) const; + + /** Shrink a range to only include data area. + + This is not the actually used area within the + selection, but the bounds of the sheet's data area + instead. + + @returns TRUE if the area passed intersected the data + area, FALSE if not, in which case the values + obtained may be out of bounds, not in order or + unmodified. TRUE does not mean that there + actually is any data within the selection. + */ + bool ShrinkToDataArea( SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, SCROW& rEndRow ) const; + + /** Shrink a range to only include used data area. + + @param o_bShrunk + Out parameter, true if area was shrunk, false if not. + @param bColumnsOnly + If TRUE, shrink only by columns, not rows. + @param bStickyTopRow + If TRUE, do not adjust the top row. + @param bStickyLeftCol + If TRUE, do not adjust the left column. + @param pDataAreaExtras + Consider additional area attributes like cell + formatting, cell notes and draw objects. The + possibly larger area than the actual cell + content data area is returned within the + struct. + + @returns true if there is any data, false if not. + */ + bool ShrinkToUsedDataArea( bool& o_bShrunk, + SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow, + SCCOL& rEndCol, SCROW& rEndRow, bool bColumnsOnly, + bool bStickyTopRow = false, bool bStickyLeftCol = false, + ScDataAreaExtras* pDataAreaExtras = nullptr ) const; + + /** + * Return the last non-empty row position in given columns that's no + * greater than the initial last row position, or 0 if the columns are + * empty. A negative value is returned if the given sheet or column + * positions are invalid. + * + * <p>It starts from the specified last row position, and finds the first + * non-empty row position in the upward direction if the start row + * position is empty.</p> + */ + SC_DLLPUBLIC SCROW GetLastDataRow( SCTAB nTab, SCCOL nCol1, SCCOL nCol2, SCROW nLastRow ) const; + + /** + * Return the smallest area containing at least all contiguous cells + * having data. This area is a square containing also empty cells. It may + * shrink or extend the area given as input Flags as modifiers: + * + * @param bIncludeOld when true, ensure that the returned area contains at + * least the initial area even if the actual data area + * is smaller than the initial area. + * + * @param bOnlyDown when true, extend / shrink the data area only in a + * downward direction i.e. only modify the end row + * position. + */ + SC_DLLPUBLIC void GetDataArea( SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow, + SCCOL& rEndCol, SCROW& rEndRow, + bool bIncludeOld, bool bOnlyDown ) const; + + /** + * Return the extended area containing at least all contiguous cells + * having background color. + */ + SC_DLLPUBLIC void GetBackColorArea( SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow, + SCCOL& rEndCol, SCROW& rEndRow ) const; + + /** + * Returns true if there is a non-empty subrange in the range given as input. + * In that case it also modifies rRange to largest subrange that does not + * have empty col/row inrange-segments in the beginning/end. + * It returns false if rRange is completely empty and in this case rRange is + * left unmodified. + */ + bool GetDataAreaSubrange(ScRange& rRange) const; + + SC_DLLPUBLIC bool GetCellArea( SCTAB nTab, SCCOL& rEndCol, SCROW& rEndRow ) const; + SC_DLLPUBLIC bool GetTableArea( SCTAB nTab, SCCOL& rEndCol, SCROW& rEndRow, + bool bCalcHiddens = false) const; + SC_DLLPUBLIC bool GetPrintArea( SCTAB nTab, SCCOL& rEndCol, SCROW& rEndRow, + bool bNotes = true) const; + SC_DLLPUBLIC bool GetPrintAreaHor( SCTAB nTab, SCROW nStartRow, SCROW nEndRow, + SCCOL& rEndCol ) const; + SC_DLLPUBLIC bool GetPrintAreaVer( SCTAB nTab, SCCOL nStartCol, SCCOL nEndCol, + SCROW& rEndRow, bool bNotes ) const; + void InvalidateTableArea(); + + /// Return the number of columns / rows that should be visible for the tiled rendering. + SC_DLLPUBLIC void GetTiledRenderingArea(SCTAB nTab, SCCOL& rEndCol, SCROW& rEndRow) const; + + SC_DLLPUBLIC bool GetDataStart( SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow ) const; + + /** + * Find the maximum column position that contains printable data for the + * specified row range. The final column position must be equal or less + * than the initial value of rEndCol. + */ + void ExtendPrintArea( OutputDevice* pDev, SCTAB nTab, + SCCOL nStartCol, SCROW nStartRow, + SCCOL& rEndCol, SCROW nEndRow ) const; + SC_DLLPUBLIC bool IsEmptyData(SCCOL nStartCol, SCROW nStartRow, + SCCOL nEndCol, SCROW nEndRow, SCTAB nTab) const; + // I think this returns the number of empty cells starting from the given direction. + SC_DLLPUBLIC SCSIZE GetEmptyLinesInBlock( SCCOL nStartCol, SCROW nStartRow, SCTAB nStartTab, + SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab, + ScDirection eDir ); + + void FindAreaPos( SCCOL& rCol, SCROW& rRow, SCTAB nTab, ScMoveDirection eDirection ) const; + SC_DLLPUBLIC void GetNextPos( SCCOL& rCol, SCROW& rRow, SCTAB nTab, SCCOL nMovX, SCROW nMovY, + bool bMarked, bool bUnprotected, const ScMarkData& rMark, + SCCOL nTabStartCol = SC_TABSTART_NONE ) const; + + bool GetNextMarkedCell( SCCOL& rCol, SCROW& rRow, SCTAB nTab, + const ScMarkData& rMark ); + + void LimitChartArea( SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow, + SCCOL& rEndCol, SCROW& rEndRow ); + void LimitChartIfAll( ScRangeListRef& rRangeList ); + + bool InsertRow( SCCOL nStartCol, SCTAB nStartTab, + SCCOL nEndCol, SCTAB nEndTab, + SCROW nStartRow, SCSIZE nSize, ScDocument* pRefUndoDoc = nullptr, + const ScMarkData* pTabMark = nullptr ); + SC_DLLPUBLIC bool InsertRow( const ScRange& rRange ); + void DeleteRow( SCCOL nStartCol, SCTAB nStartTab, + SCCOL nEndCol, SCTAB nEndTab, + SCROW nStartRow, SCSIZE nSize, + ScDocument* pRefUndoDoc = nullptr, bool* pUndoOutline = nullptr, + const ScMarkData* pTabMark = nullptr ); + SC_DLLPUBLIC void DeleteRow( const ScRange& rRange ); + bool InsertCol( SCROW nStartRow, SCTAB nStartTab, + SCROW nEndRow, SCTAB nEndTab, + SCCOL nStartCol, SCSIZE nSize, ScDocument* pRefUndoDoc = nullptr, + const ScMarkData* pTabMark = nullptr ); + SC_DLLPUBLIC bool InsertCol( const ScRange& rRange ); + void DeleteCol( SCROW nStartRow, SCTAB nStartTab, + SCROW nEndRow, SCTAB nEndTab, + SCCOL nStartCol, SCSIZE nSize, + ScDocument* pRefUndoDoc = nullptr, bool* pUndoOutline = nullptr, + const ScMarkData* pTabMark = nullptr ); + void DeleteCol( const ScRange& rRange ); + + bool CanInsertRow( const ScRange& rRange ) const; + bool CanInsertCol( const ScRange& rRange ) const; + + void FitBlock( const ScRange& rOld, const ScRange& rNew, bool bClear = true ); + bool CanFitBlock( const ScRange& rOld, const ScRange& rNew ); + + bool IsClipOrUndo() const { return bIsClip || bIsUndo; } + bool IsUndo() const { return bIsUndo; } + bool IsClipboard() const { return bIsClip; } + bool IsUndoEnabled() const { return mbUndoEnabled; } + SC_DLLPUBLIC void EnableUndo( bool bVal ); + bool IsFunctionAccess() const { return bIsFunctionAccess; } + + bool IsAdjustHeightLocked() const { return nAdjustHeightLock != 0; } + void LockAdjustHeight() { ++nAdjustHeightLock; } + SC_DLLPUBLIC void UnlockAdjustHeight(); + bool IsExecuteLinkEnabled() const { return mbExecuteLinkEnabled; } + void EnableExecuteLink( bool bVal ) { mbExecuteLinkEnabled = bVal; } + bool IsChangeReadOnlyEnabled() const { return mbChangeReadOnlyEnabled; } + void EnableChangeReadOnly( bool bVal ) { mbChangeReadOnlyEnabled = bVal; } + SC_DLLPUBLIC bool IsUserInteractionEnabled() const { return mbUserInteractionEnabled;} + SC_DLLPUBLIC void EnableUserInteraction( bool bVal ); + SC_DLLPUBLIC sal_Int16 GetNamedRangesLockCount() const { return mnNamedRangesLockCount; } + void SetNamedRangesLockCount( sal_Int16 nCount ) { mnNamedRangesLockCount = nCount; } + SC_DLLPUBLIC void ResetClip( ScDocument* pSourceDoc, const ScMarkData* pMarks ); + SC_DLLPUBLIC void ResetClip( ScDocument* pSourceDoc, SCTAB nTab ); + void SetCutMode( bool bCut ); + bool IsCutMode(); + void SetClipArea( const ScRange& rArea, bool bCut = false ); + + SC_DLLPUBLIC bool IsDocVisible() const { return bIsVisible; } + SC_DLLPUBLIC void SetDocVisible( bool bSet ); + + bool HasOLEObjectsInArea( const ScRange& rRange, const ScMarkData* pTabMark = nullptr ); + + void DeleteObjectsInArea( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, + const ScMarkData& rMark, bool bAnchored = false ); + void DeleteObjectsInSelection( const ScMarkData& rMark ); + + SC_DLLPUBLIC void DeleteArea( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, const ScMarkData& rMark, + InsertDeleteFlags nDelFlag, bool bBroadcast = true, + sc::ColumnSpanSet* pBroadcastSpans = nullptr ); + + SC_DLLPUBLIC void DeleteAreaTab(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, + SCTAB nTab, InsertDeleteFlags nDelFlag); + void DeleteAreaTab(const ScRange& rRange, InsertDeleteFlags nDelFlag); + + SC_DLLPUBLIC void CopyToClip( const ScClipParam& rClipParam, ScDocument* pClipDoc, + const ScMarkData* pMarks, bool bKeepScenarioFlags, + bool bIncludeObjects ); + + /** + * Copy only raw cell values to another document. Formula cells are + * converted to raw cells. No formatting info are copied except for + * number formats. + * + * @param rSrcRange source range in the source document + * @param nDestTab table in the clip document to copy to. + * @param rDestDoc document to copy to + */ + SC_DLLPUBLIC void CopyStaticToDocument(const ScRange& rSrcRange, SCTAB nDestTab, ScDocument& rDestDoc); + + /** + * Copy only cell, nothing but cell to another document. + * + * @param rSrcPos source cell position + * @param rDestPos destination cell position + * @param rDestDoc destination document + */ + void CopyCellToDocument( const ScAddress& rSrcPos, const ScAddress& rDestPos, ScDocument& rDestDoc ); + + void CopyTabToClip( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, + SCTAB nTab, ScDocument* pClipDoc); + + SC_DLLPUBLIC bool InitColumnBlockPosition( sc::ColumnBlockPosition& rBlockPos, SCTAB nTab, SCCOL nCol ); + + void DeleteBeforeCopyFromClip( sc::CopyFromClipContext& rCxt, const ScMarkData& rMark, + sc::ColumnSpanSet& rBroadcastSpans ); + + SC_DLLPUBLIC bool CopyOneCellFromClip(sc::CopyFromClipContext& rCxt, SCCOL nCol1, SCROW nRow1, + SCCOL nCol2, SCROW nRow2 ); + void CopyBlockFromClip( sc::CopyFromClipContext& rCxt, SCCOL nCol1, SCROW nRow1, + SCCOL nCol2, SCROW nRow2, const ScMarkData& rMark, + SCCOL nDx, SCROW nDy ); + /** + * @return the number of non-filtered rows. + */ + SCROW CopyNonFilteredFromClip(sc::CopyFromClipContext& rCxt, SCCOL nCol1, SCROW nRow1, + SCCOL nCol2, SCROW nRow2, const ScMarkData& rMark, SCCOL nDx, + SCROW& rClipStartRow, SCROW nClipEndRow); + + void StartListeningFromClip( + sc::StartListeningContext& rStartCxt, sc::EndListeningContext& rEndCxt, + SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ); + void StartListeningFromClip( SCCOL nCol1, SCROW nRow1, + SCCOL nCol2, SCROW nRow2, + const ScMarkData& rMark, InsertDeleteFlags nInsFlag ); + + void SetDirtyFromClip( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, + const ScMarkData& rMark, InsertDeleteFlags nInsFlag, + sc::ColumnSpanSet& rBroadcastSpans ); + + /** + * Paste data from a clipboard document into this document. + * + * @param rDestRange destination range. + * @param pClipDoc pointer to the clipboard document to copy data from. + * @param bSkipEmptyCells if this flag is set, empty cells in the source + * range in the clipboard document will not overwrite + * the target destination cells. + * @param pDestRanges If pDestRanges is given it overrides rDestRange, where + * rDestRange becomes the overall encompassing range. + */ + SC_DLLPUBLIC void CopyFromClip( + const ScRange& rDestRange, const ScMarkData& rMark, InsertDeleteFlags nInsFlag, + ScDocument* pRefUndoDoc, ScDocument* pClipDoc, + bool bResetCut = true, bool bAsLink = false, + bool bIncludeFiltered = true, bool bSkipEmptyCells = false, + const ScRangeList* pDestRanges = nullptr ); + + void CopyMultiRangeFromClip(const ScAddress& rDestPos, const ScMarkData& rMark, + InsertDeleteFlags nInsFlag, ScDocument* pClipDoc, + bool bResetCut = true, bool bAsLink = false, + bool bIncludeFiltered = true, + bool bSkipAttrForEmpty = false); + + void GetClipArea(SCCOL& nClipX, SCROW& nClipY, bool bIncludeFiltered); + void GetClipStart(SCCOL& nClipX, SCROW& nClipY); + + bool HasClipFilteredRows(); + + bool IsClipboardSource() const; + + SC_DLLPUBLIC void TransposeClip(ScDocument* pTransClip, InsertDeleteFlags nFlags, bool bAsLink, + bool bIncludeFiltered); + + ScClipParam& GetClipParam(); + void SetClipParam(const ScClipParam& rParam); + + /** To be called at the clipboard document when closing a document that is + the current clipboard source to decouple things from the originating + document. Done in ScDocument dtor after determining + IsClipboardSource(). + */ + void ClosingClipboardSource(); + + void MixDocument( const ScRange& rRange, ScPasteFunc nFunction, bool bSkipEmpty, + ScDocument& rSrcDoc ); + + void FillTab( const ScRange& rSrcArea, const ScMarkData& rMark, + InsertDeleteFlags nFlags, ScPasteFunc nFunction, + bool bSkipEmpty, bool bAsLink ); + void FillTabMarked( SCTAB nSrcTab, const ScMarkData& rMark, + InsertDeleteFlags nFlags, ScPasteFunc nFunction, + bool bSkipEmpty, bool bAsLink ); + + void TransliterateText( const ScMarkData& rMultiMark, TransliterationFlags nType ); + + SC_DLLPUBLIC void InitUndo( const ScDocument& rSrcDoc, SCTAB nTab1, SCTAB nTab2, + bool bColInfo = false, bool bRowInfo = false ); + void AddUndoTab( SCTAB nTab1, SCTAB nTab2, + bool bColInfo = false, bool bRowInfo = false ); + SC_DLLPUBLIC void InitUndoSelected( const ScDocument& rSrcDoc, const ScMarkData& rTabSelection, + bool bColInfo = false, bool bRowInfo = false ); + + // don't use anymore: + void CopyToDocument(SCCOL nCol1, SCROW nRow1, SCTAB nTab1, + SCCOL nCol2, SCROW nRow2, SCTAB nTab2, + InsertDeleteFlags nFlags, bool bMarked, ScDocument& rDestDoc, + const ScMarkData* pMarks = nullptr, bool bColRowFlags = true); + void UndoToDocument(SCCOL nCol1, SCROW nRow1, SCTAB nTab1, + SCCOL nCol2, SCROW nRow2, SCTAB nTab2, + InsertDeleteFlags nFlags, bool bMarked, ScDocument& rDestDoc); + + SC_DLLPUBLIC void CopyToDocument(const ScRange& rRange, + InsertDeleteFlags nFlags, bool bMarked, ScDocument& rDestDoc, + const ScMarkData* pMarks = nullptr, bool bColRowFlags = true); + void UndoToDocument(const ScRange& rRange, + InsertDeleteFlags nFlags, bool bMarked, ScDocument& rDestDoc); + + void CopyScenario( SCTAB nSrcTab, SCTAB nDestTab, bool bNewScenario = false ); + bool TestCopyScenario( SCTAB nSrcTab, SCTAB nDestTab ) const; + void MarkScenario(SCTAB nSrcTab, SCTAB nDestTab, + ScMarkData& rDestMark, bool bResetMark = true, + ScScenarioFlags nNeededBits = ScScenarioFlags::NONE) const; + bool HasScenarioRange( SCTAB nTab, const ScRange& rRange ) const; + SC_DLLPUBLIC const ScRangeList* GetScenarioRanges( SCTAB nTab ) const; + + SC_DLLPUBLIC void CopyUpdated( ScDocument* pPosDoc, ScDocument* pDestDoc ); + + void UpdateReference( sc::RefUpdateContext& rCxt, ScDocument* + pUndoDoc = nullptr, bool bIncludeDraw = true, + bool bUpdateNoteCaptionPos = true ); + /** + * @param pClipDoc original clipboard doc, i.e. non-transposed + * This clip doc is used to check references pointing to cut cells. + */ + SC_DLLPUBLIC void UpdateTranspose( const ScAddress& rDestPos, ScDocument* pClipDoc, + const ScMarkData& rMark, ScDocument* pUndoDoc ); + + void UpdateGrow( const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY ); + + SC_DLLPUBLIC void Fill( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, + ScProgress* pProgress, const ScMarkData& rMark, + sal_uInt64 nFillCount, FillDir eFillDir = FILL_TO_BOTTOM, + FillCmd eFillCmd = FILL_LINEAR, FillDateCmd eFillDateCmd = FILL_DAY, + double nStepValue = 1.0, double nMaxValue = 1E307 ); + OUString GetAutoFillPreview( const ScRange& rSource, SCCOL nEndX, SCROW nEndY ); + + bool GetSelectionFunction( ScSubTotalFunc eFunc, + const ScAddress& rCursor, const ScMarkData& rMark, + double& rResult ); + + SC_DLLPUBLIC const SfxPoolItem* GetAttr( SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt16 nWhich ) const; + template<class T> const T* GetAttr( SCCOL nCol, SCROW nRow, SCTAB nTab, TypedWhichId<T> nWhich ) const + { + return static_cast<const T*>(GetAttr(nCol, nRow, nTab, sal_uInt16(nWhich))); + } + SC_DLLPUBLIC const SfxPoolItem* GetAttr( SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt16 nWhich, + SCROW& nStartRow, SCROW& nEndRow ) const; + template<class T> const T* GetAttr( SCCOL nCol, SCROW nRow, SCTAB nTab, TypedWhichId<T> nWhich, + SCROW& nStartRow, SCROW& nEndRow ) const + { + return static_cast<const T*>(GetAttr(nCol, nRow, nTab, sal_uInt16(nWhich), nStartRow, nEndRow)); + } + SC_DLLPUBLIC const SfxPoolItem* GetAttr( const ScAddress& rPos, sal_uInt16 nWhich ) const; + template<class T> const T* GetAttr( const ScAddress& rPos, TypedWhichId<T> nWhich ) const + { + return static_cast<const T*>(GetAttr(rPos, sal_uInt16(nWhich))); + } + SC_DLLPUBLIC const ScPatternAttr* GetPattern( SCCOL nCol, SCROW nRow, SCTAB nTab ) const; + SC_DLLPUBLIC const ScPatternAttr* GetPattern( const ScAddress& rPos ) const; + SC_DLLPUBLIC const ScPatternAttr* GetMostUsedPattern( SCCOL nCol, SCROW nStartRow, SCROW nEndRow, SCTAB nTab ) const; + const ScPatternAttr* GetSelectionPattern( const ScMarkData& rMark ); + std::unique_ptr<ScPatternAttr> CreateSelectionPattern( const ScMarkData& rMark, bool bDeep = true ); + SC_DLLPUBLIC void AddCondFormatData( const ScRangeList& rRange, SCTAB nTab, sal_uInt32 nIndex ); + void RemoveCondFormatData( const ScRangeList& rRange, SCTAB nTab, sal_uInt32 nIndex ); + + SC_DLLPUBLIC ScConditionalFormat* GetCondFormat( SCCOL nCol, SCROW nRow, SCTAB nTab ) const; + // pCell is an optimization, must point to rPos + SC_DLLPUBLIC const SfxItemSet* GetCondResult( SCCOL nCol, SCROW nRow, SCTAB nTab, + ScRefCellValue* pCell = nullptr ) const; + const SfxItemSet* GetCondResult( ScRefCellValue& rCell, const ScAddress& rPos, + const ScConditionalFormatList& rList, + const ScCondFormatIndexes& rIndex ) const; + const SfxPoolItem* GetEffItem( SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt16 nWhich ) const; + template<class T> const T* GetEffItem( SCCOL nCol, SCROW nRow, SCTAB nTab, TypedWhichId<T> nWhich ) const + { + return static_cast<const T*>(GetEffItem(nCol, nRow, nTab, sal_uInt16(nWhich))); + } + + SC_DLLPUBLIC const css::uno::Reference< css::i18n::XBreakIterator >& GetBreakIterator(); + bool HasStringWeakCharacters( const OUString& rString ); + SC_DLLPUBLIC SvtScriptType GetStringScriptType( const OUString& rString ); + // pCell is an optimization, must point to rPos + SC_DLLPUBLIC SvtScriptType GetCellScriptType( const ScAddress& rPos, sal_uInt32 nNumberFormat, + const ScRefCellValue* pCell = nullptr ); + // pCell is an optimization, must point to nCol,nRow,nTab + SC_DLLPUBLIC SvtScriptType GetScriptType( SCCOL nCol, SCROW nRow, SCTAB nTab, + const ScRefCellValue* pCell = nullptr ); + SvtScriptType GetRangeScriptType( sc::ColumnBlockPosition& rBlockPos, const ScAddress& rPos, SCROW nLength ); + SvtScriptType GetRangeScriptType( const ScRangeList& rRanges ); + + bool HasDetectiveOperations() const; + void AddDetectiveOperation( const ScDetOpData& rData ); + void ClearDetectiveOperations(); + ScDetOpList* GetDetOpList() const { return pDetOpList.get(); } + void SetDetOpList(std::unique_ptr<ScDetOpList> pNew); + + bool HasDetectiveObjects(SCTAB nTab) const; + + void GetSelectionFrame( const ScMarkData& rMark, + SvxBoxItem& rLineOuter, + SvxBoxInfoItem& rLineInner ); + void ApplySelectionFrame(const ScMarkData& rMark, + const SvxBoxItem& rLineOuter, + const SvxBoxInfoItem* pLineInner); + void ApplyFrameAreaTab(const ScRange& rRange, + const SvxBoxItem& rLineOuter, + const SvxBoxInfoItem& rLineInner); + + void ClearSelectionItems( const sal_uInt16* pWhich, const ScMarkData& rMark ); + void ChangeSelectionIndent( bool bIncrement, const ScMarkData& rMark ); + + SC_DLLPUBLIC sal_uLong AddCondFormat( std::unique_ptr<ScConditionalFormat> pNew, SCTAB nTab ); + void DeleteConditionalFormat( sal_uLong nIndex, SCTAB nTab ); + + void SetCondFormList( ScConditionalFormatList* pList, SCTAB nTab ); + SC_DLLPUBLIC sal_uLong AddValidationEntry( const ScValidationData& rNew ); + SC_DLLPUBLIC const ScValidationData* GetValidationEntry( sal_uInt32 nIndex ) const; + + SC_DLLPUBLIC ScConditionalFormatList* GetCondFormList( SCTAB nTab ) const; + + const ScValidationDataList* GetValidationList() const { return pValidationList.get();} + ScValidationDataList* GetValidationList() { return pValidationList.get();} + + SC_DLLPUBLIC void ApplyAttr( SCCOL nCol, SCROW nRow, SCTAB nTab, + const SfxPoolItem& rAttr ); + SC_DLLPUBLIC void ApplyPattern( SCCOL nCol, SCROW nRow, SCTAB nTab, + const ScPatternAttr& rAttr ); + SC_DLLPUBLIC void ApplyPatternArea( SCCOL nStartCol, SCROW nStartRow, + SCCOL nEndCol, SCROW nEndRow, + const ScMarkData& rMark, const ScPatternAttr& rAttr, + ScEditDataArray* pDataArray = nullptr, + bool* const pIsChanged = nullptr ); + SC_DLLPUBLIC void ApplyPatternAreaTab( SCCOL nStartCol, SCROW nStartRow, + SCCOL nEndCol, SCROW nEndRow, SCTAB nTab, + const ScPatternAttr& rAttr ); + + SC_DLLPUBLIC void ApplyPatternIfNumberformatIncompatible( const ScRange& rRange, + const ScMarkData& rMark, + const ScPatternAttr& rPattern, + SvNumFormatType nNewType ); + + void ApplyStyle( SCCOL nCol, SCROW nRow, SCTAB nTab, + const ScStyleSheet& rStyle); + void ApplyStyleArea( SCCOL nStartCol, SCROW nStartRow, + SCCOL nEndCol, SCROW nEndRow, + const ScMarkData& rMark, const ScStyleSheet& rStyle); + SC_DLLPUBLIC void ApplyStyleAreaTab( SCCOL nStartCol, SCROW nStartRow, + SCCOL nEndCol, SCROW nEndRow, SCTAB nTab, + const ScStyleSheet& rStyle); + + SC_DLLPUBLIC void ApplySelectionStyle( const ScStyleSheet& rStyle, const ScMarkData& rMark ); + void ApplySelectionLineStyle( const ScMarkData& rMark, + const ::editeng::SvxBorderLine* pLine, bool bColorOnly ); + + const ScStyleSheet* GetStyle( SCCOL nCol, SCROW nRow, SCTAB nTab ) const; + const ScStyleSheet* GetSelectionStyle( const ScMarkData& rMark ) const; + + void StyleSheetChanged( const SfxStyleSheetBase* pStyleSheet, bool bRemoved, + OutputDevice* pDev, + double nPPTX, double nPPTY, + const Fraction& rZoomX, const Fraction& rZoomY ); + + bool IsStyleSheetUsed( const ScStyleSheet& rStyle ) const; + + SC_DLLPUBLIC bool ApplyFlagsTab( SCCOL nStartCol, SCROW nStartRow, + SCCOL nEndCol, SCROW nEndRow, + SCTAB nTab, ScMF nFlags ); + SC_DLLPUBLIC bool RemoveFlagsTab( SCCOL nStartCol, SCROW nStartRow, + SCCOL nEndCol, SCROW nEndRow, + SCTAB nTab, ScMF nFlags ); + + SC_DLLPUBLIC void SetPattern( const ScAddress&, const ScPatternAttr& rAttr ); + SC_DLLPUBLIC const ScPatternAttr* SetPattern( SCCOL nCol, SCROW nRow, SCTAB nTab, std::unique_ptr<ScPatternAttr> pAttr ); + SC_DLLPUBLIC const ScPatternAttr* SetPattern( const ScAddress& rPos, std::unique_ptr<ScPatternAttr> pAttr ); + SC_DLLPUBLIC void SetPattern( SCCOL nCol, SCROW nRow, SCTAB nTab, const ScPatternAttr& rAttr ); + + void AutoFormat( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, + sal_uInt16 nFormatNo, const ScMarkData& rMark ); + void GetAutoFormatData( SCTAB nTab, SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, + ScAutoFormatData& rData ); + bool SearchAndReplace( const SvxSearchItem& rSearchItem, + SCCOL& rCol, SCROW& rRow, SCTAB& rTab, + const ScMarkData& rMark, ScRangeList& rMatchedRanges, + OUString& rUndoStr, ScDocument* pUndoDoc, bool& bMatchedRangesWereClamped ); + static bool IsEmptyCellSearch( const SvxSearchItem& rSearchItem ); + + // determine Col/Row of subsequent calls + // (e.g. not found from the beginning, or subsequent tables) + // meaning of explanation in "()" was already unclear in German + void GetSearchAndReplaceStart( const SvxSearchItem& rSearchItem, + SCCOL& rCol, SCROW& rRow ); + + bool Solver( SCCOL nFCol, SCROW nFRow, SCTAB nFTab, + SCCOL nVCol, SCROW nVRow, SCTAB nVTab, + const OUString& sValStr, double& nX); + + SC_DLLPUBLIC void ApplySelectionPattern( const ScPatternAttr& rAttr, const ScMarkData& rMark, + ScEditDataArray* pDataArray = nullptr, bool* pIsChanged = nullptr ); + SC_DLLPUBLIC void DeleteSelection( InsertDeleteFlags nDelFlag, const ScMarkData& rMark, bool bBroadcast = true ); + void DeleteSelectionTab( SCTAB nTab, InsertDeleteFlags nDelFlag, const ScMarkData& rMark ); + + SC_DLLPUBLIC void SetColWidth( SCCOL nCol, SCTAB nTab, sal_uInt16 nNewWidth ); + SC_DLLPUBLIC void SetColWidthOnly( SCCOL nCol, SCTAB nTab, sal_uInt16 nNewWidth ); + SC_DLLPUBLIC void SetRowHeight( SCROW nRow, SCTAB nTab, sal_uInt16 nNewHeight ); + SC_DLLPUBLIC void SetRowHeightRange( SCROW nStartRow, SCROW nEndRow, SCTAB nTab, + sal_uInt16 nNewHeight ); + + SC_DLLPUBLIC void SetRowHeightOnly( SCROW nStartRow, SCROW nEndRow, SCTAB nTab, + sal_uInt16 nNewHeight ); + SC_DLLPUBLIC void SetManualHeight( SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bManual ); + + SC_DLLPUBLIC sal_uInt16 GetColWidth( SCCOL nCol, SCTAB nTab, bool bHiddenAsZero = true ) const; + SC_DLLPUBLIC tools::Long GetColWidth( SCCOL nStartCol, SCCOL nEndCol, SCTAB nTab ) const; + SC_DLLPUBLIC sal_uInt16 GetRowHeight( SCROW nRow, SCTAB nTab, bool bHiddenAsZero = true ) const; + SC_DLLPUBLIC sal_uInt16 GetRowHeight( SCROW nRow, SCTAB nTab, SCROW* pStartRow, SCROW* pEndRow, bool bHiddenAsZero = true ) const; + SC_DLLPUBLIC tools::Long GetRowHeight( SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bHiddenAsZero = true ) const; + + /** + * Given the height i.e. total vertical distance from the top of the sheet + * grid, return the first visible row whose top position is below the + * specified height. + */ + SCROW GetRowForHeight( SCTAB nTab, tools::Long nHeight ) const; + tools::Long GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, SCTAB nTab, double fScale ) const; + SC_DLLPUBLIC tools::Long GetColOffset( SCCOL nCol, SCTAB nTab, bool bHiddenAsZero = true ) const; + SC_DLLPUBLIC tools::Long GetRowOffset( SCROW nRow, SCTAB nTab, bool bHiddenAsZero = true ) const; + + SC_DLLPUBLIC sal_uInt16 GetOriginalWidth( SCCOL nCol, SCTAB nTab ) const; + SC_DLLPUBLIC sal_uInt16 GetOriginalHeight( SCROW nRow, SCTAB nTab ) const; + + sal_uInt16 GetCommonWidth( SCCOL nEndCol, SCTAB nTab ) const; + + SCROW GetHiddenRowCount( SCROW nRow, SCTAB nTab ) const; + + sal_uInt16 GetOptimalColWidth( SCCOL nCol, SCTAB nTab, OutputDevice* pDev, + double nPPTX, double nPPTY, + const Fraction& rZoomX, const Fraction& rZoomY, + bool bFormula, + const ScMarkData* pMarkData = nullptr, + const ScColWidthParam* pParam = nullptr ); + + SC_DLLPUBLIC bool SetOptimalHeight( sc::RowHeightContext& rCxt, SCROW nStartRow, + SCROW nEndRow, SCTAB nTab, bool bApi ); + + void UpdateAllRowHeights( sc::RowHeightContext& rCxt, const ScMarkData* pTabMark ); + + tools::Long GetNeededSize( SCCOL nCol, SCROW nRow, SCTAB nTab, + OutputDevice* pDev, + double nPPTX, double nPPTY, + const Fraction& rZoomX, const Fraction& rZoomY, + bool bWidth, bool bTotalSize = false, + bool bInPrintTwips = false ); + + SC_DLLPUBLIC void ShowCol(SCCOL nCol, SCTAB nTab, bool bShow); + SC_DLLPUBLIC void ShowRow(SCROW nRow, SCTAB nTab, bool bShow); + SC_DLLPUBLIC void ShowRows(SCROW nRow1, SCROW nRow2, SCTAB nTab, bool bShow); + SC_DLLPUBLIC void SetRowFlags( SCROW nRow, SCTAB nTab, CRFlags nNewFlags ); + SC_DLLPUBLIC void SetRowFlags( SCROW nStartRow, SCROW nEndRow, SCTAB nTab, CRFlags nNewFlags ); + + SC_DLLPUBLIC CRFlags GetColFlags( SCCOL nCol, SCTAB nTab ) const; + SC_DLLPUBLIC CRFlags GetRowFlags( SCROW nRow, SCTAB nTab ) const; + + SC_DLLPUBLIC void GetAllRowBreaks(std::set<SCROW>& rBreaks, SCTAB nTab, bool bPage, bool bManual) const; + SC_DLLPUBLIC void GetAllColBreaks(std::set<SCCOL>& rBreaks, SCTAB nTab, bool bPage, bool bManual) const; + SC_DLLPUBLIC ScBreakType HasRowBreak(SCROW nRow, SCTAB nTab) const; + SC_DLLPUBLIC ScBreakType HasColBreak(SCCOL nCol, SCTAB nTab) const; + SC_DLLPUBLIC void SetRowBreak(SCROW nRow, SCTAB nTab, bool bPage, bool bManual); + SC_DLLPUBLIC void SetColBreak(SCCOL nCol, SCTAB nTab, bool bPage, bool bManual); + void RemoveRowBreak(SCROW nRow, SCTAB nTab, bool bPage, bool bManual); + void RemoveColBreak(SCCOL nCol, SCTAB nTab, bool bPage, bool bManual); + css::uno::Sequence< + css::sheet::TablePageBreakData> GetRowBreakData(SCTAB nTab) const; + + SC_DLLPUBLIC bool RowHidden(SCROW nRow, SCTAB nTab, SCROW* pFirstRow = nullptr, SCROW* pLastRow = nullptr) const; + SC_DLLPUBLIC bool HasHiddenRows(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const; + SC_DLLPUBLIC bool ColHidden(SCCOL nCol, SCTAB nTab, SCCOL* pFirstCol = nullptr, SCCOL* pLastCol = nullptr) const; + SC_DLLPUBLIC void SetRowHidden(SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bHidden); + SC_DLLPUBLIC void SetColHidden(SCCOL nStartCol, SCCOL nEndCol, SCTAB nTab, bool bHidden); + SC_DLLPUBLIC SCROW FirstVisibleRow(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const; + SC_DLLPUBLIC SCROW LastVisibleRow(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const; + SCROW CountVisibleRows(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const; + + SC_DLLPUBLIC bool RowFiltered(SCROW nRow, SCTAB nTab, SCROW* pFirstRow = nullptr, SCROW* pLastRow = nullptr) const; + bool HasFilteredRows(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const; + bool ColFiltered(SCCOL nCol, SCTAB nTab) const; + SC_DLLPUBLIC void SetRowFiltered(SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bFiltered); + SCROW FirstNonFilteredRow(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const; + SCROW LastNonFilteredRow(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const; + SCROW CountNonFilteredRows(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const; + + SC_DLLPUBLIC bool IsManualRowHeight(SCROW nRow, SCTAB nTab) const; + + bool HasUniformRowHeight( SCTAB nTab, SCROW nRow1, SCROW nRow2 ) const; + + /** + * Write all column row flags to table's flag data, because not all column + * row attributes are stored in the flag data members. This is necessary + * for ods export. + */ + void SyncColRowFlags(); + + /// @return the index of the last row with any set flags (auto-pagebreak is ignored). + SC_DLLPUBLIC SCROW GetLastFlaggedRow( SCTAB nTab ) const; + + /// @return the index of the last changed column (flags and column width, auto pagebreak is ignored). + SCCOL GetLastChangedColFlagsWidth( SCTAB nTab ) const; + /// @return the index of the last changed row (flags and row height, auto pagebreak is ignored). + SCROW GetLastChangedRowFlagsWidth( SCTAB nTab ) const; + + SCCOL GetNextDifferentChangedColFlagsWidth( SCTAB nTab, SCCOL nStart) const; + + SCROW GetNextDifferentChangedRowFlagsWidth( SCTAB nTab, SCROW nStart) const; + + // returns whether to export a Default style for this col or not + // nDefault is set to one position in the current row where the Default style is + void GetColDefault( SCTAB nTab, SCCOL nCol, SCROW nLastRow, SCROW& nDefault); + + bool UpdateOutlineCol( SCCOL nStartCol, SCCOL nEndCol, SCTAB nTab, bool bShow ); + bool UpdateOutlineRow( SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bShow ); + + void StripHidden( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2, SCTAB nTab ); + void ExtendHidden( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2, SCTAB nTab ); + + SC_DLLPUBLIC ScPatternAttr* GetDefPattern() const; + SC_DLLPUBLIC ScDocumentPool* GetPool(); + SC_DLLPUBLIC ScStyleSheetPool* GetStyleSheetPool() const; + void GetUnprotectedCells( ScRangeList& rRange, SCTAB nTab ) const; + + // PageStyle: + SC_DLLPUBLIC OUString GetPageStyle( SCTAB nTab ) const; + SC_DLLPUBLIC void SetPageStyle( SCTAB nTab, const OUString& rName ); + Size GetPageSize( SCTAB nTab ) const; + void SetPageSize( SCTAB nTab, const Size& rSize ); + void SetRepeatArea( SCTAB nTab, SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCROW nEndRow ); + void InvalidatePageBreaks(SCTAB nTab); + void UpdatePageBreaks( SCTAB nTab, const ScRange* pUserArea = nullptr ); + void RemoveManualBreaks( SCTAB nTab ); + bool HasManualBreaks( SCTAB nTab ) const; + + bool IsPageStyleInUse( std::u16string_view rStrPageStyle, SCTAB* pInTab ); + bool RemovePageStyleInUse( std::u16string_view rStrPageStyle ); + bool RenamePageStyleInUse( std::u16string_view rOld, const OUString& rNew ); + void ModifyStyleSheet( SfxStyleSheetBase& rPageStyle, + const SfxItemSet& rChanges ); + + void PageStyleModified( SCTAB nTab, const OUString& rNewName ); + + SC_DLLPUBLIC bool NeedPageResetAfterTab( SCTAB nTab ) const; + + // Was stored in PageStyle previously. Now it exists for every table: + SC_DLLPUBLIC bool HasPrintRange(); + SC_DLLPUBLIC sal_uInt16 GetPrintRangeCount( SCTAB nTab ); + SC_DLLPUBLIC const ScRange* GetPrintRange( SCTAB nTab, sal_uInt16 nPos ); + SC_DLLPUBLIC std::optional<ScRange> GetRepeatColRange( SCTAB nTab ); + SC_DLLPUBLIC std::optional<ScRange> GetRepeatRowRange( SCTAB nTab ); + /** Returns true, if the specified sheet is always printed. */ + bool IsPrintEntireSheet( SCTAB nTab ) const; + + /** Removes all print ranges. */ + SC_DLLPUBLIC void ClearPrintRanges( SCTAB nTab ); + /** Adds a new print ranges. */ + SC_DLLPUBLIC void AddPrintRange( SCTAB nTab, const ScRange& rNew ); + // Removes all named ranges used for print ranges in a given tab + SC_DLLPUBLIC void ClearPrintNamedRanges( SCTAB nTab ); + /** Marks the specified sheet to be printed completely. Deletes old print ranges on the sheet! */ + SC_DLLPUBLIC void SetPrintEntireSheet( SCTAB nTab ); + SC_DLLPUBLIC void SetRepeatColRange( SCTAB nTab, std::optional<ScRange> oNew ); + SC_DLLPUBLIC void SetRepeatRowRange( SCTAB nTab, std::optional<ScRange> oNew ); + std::unique_ptr<ScPrintRangeSaver> CreatePrintRangeSaver() const; + void RestorePrintRanges( const ScPrintRangeSaver& rSaver ); + + SC_DLLPUBLIC tools::Rectangle GetMMRect( SCCOL nStartCol, SCROW nStartRow, + SCCOL nEndCol, SCROW nEndRow, SCTAB nTab, bool bHiddenAsZero = true ) const; + SC_DLLPUBLIC ScRange GetRange( SCTAB nTab, const tools::Rectangle& rMMRect, bool bHiddenAsZero = true ) const; + + void UpdStlShtPtrsFrmNms(); + void StylesToNames(); + + SC_DLLPUBLIC void CopyStdStylesFrom( const ScDocument& rSrcDoc ); + + static sal_uInt16 GetSrcVersion() { return nSrcVer; } + + void SetSrcCharSet( rtl_TextEncoding eNew ) { eSrcSet = eNew; } + void UpdateFontCharSet(); + + void FillInfo( ScTableInfo& rTabInfo, SCCOL nCol1, SCROW nRow1, + SCCOL nCol2, SCROW nRow2, SCTAB nTab, double fColScale, + double fRowScale, bool bPageMode, bool bFormulaMode, + const ScMarkData* pMarkData = nullptr ); + + SC_DLLPUBLIC SvNumberFormatter* GetFormatTable() const; + + /** Sort a range of data. */ + void Sort( SCTAB nTab, const ScSortParam& rSortParam, + bool bKeepQuery, bool bUpdateRefs, + ScProgress* pProgress, sc::ReorderParam* pUndo ); + + void Reorder( const sc::ReorderParam& rParam ); + + void PrepareQuery( SCTAB nTab, ScQueryParam& rQueryParam ); + SCSIZE Query( SCTAB nTab, const ScQueryParam& rQueryParam, bool bKeepSub ); + SC_DLLPUBLIC bool CreateQueryParam( const ScRange& rRange, ScQueryParam& rQueryParam ); + OUString GetUpperCellString(SCCOL nCol, SCROW nRow, SCTAB nTab); + + /** + * Get a list of unique strings to use in filtering criteria. The string + * values are sorted, and there are no duplicate values in the list. The + * data range to use to populate the filter entries is inferred from the + * database range that contains the specified cell position. + */ + void GetFilterEntries( SCCOL nCol, SCROW nRow, + SCTAB nTab, ScFilterEntries& rFilterEntries ); + + SC_DLLPUBLIC void GetFilterEntriesArea( SCCOL nCol, SCROW nStartRow, SCROW nEndRow, + SCTAB nTab, bool bCaseSens, + ScFilterEntries& rFilterEntries ); + + void GetDataEntries( SCCOL nCol, SCROW nRow, SCTAB nTab, + std::vector<ScTypedStrData>& rStrings, bool bValidation = false ); + void GetFormulaEntries( ScTypedCaseStrSet& rStrings ); + + bool HasAutoFilter( SCCOL nCol, SCROW nRow, SCTAB nTab ); + void GetFilterSelCount( SCCOL nCol, SCROW nRow, SCTAB nTab, SCSIZE& nSelected, SCSIZE& nTotal ); + + SC_DLLPUBLIC bool HasColHeader( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, + SCTAB nTab ); + SC_DLLPUBLIC bool HasRowHeader( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, + SCTAB nTab ); + + SfxPrinter* GetPrinter( bool bCreateIfNotExist = true ); + void SetPrinter( VclPtr<SfxPrinter> const & pNewPrinter ); + VirtualDevice* GetVirtualDevice_100th_mm(); + SC_DLLPUBLIC OutputDevice* GetRefDevice(bool bForceVirtDev = false); // WYSIWYG: Printer, otherwise VirtualDevice... + + bool GetNextSpellingCell( SCCOL& nCol, SCROW& nRow, SCTAB nTab, + bool bInSel, const ScMarkData& rMark) const; + + void ReplaceStyle( const SvxSearchItem& rSearchItem, + SCCOL nCol, SCROW nRow, SCTAB nTab, + const ScMarkData& rMark); + + void InvalidateTextWidth( std::u16string_view rStyleName ); + void InvalidateTextWidth( SCTAB nTab ); + void InvalidateTextWidth( const ScAddress* pAdrFrom, const ScAddress* pAdrTo, bool bNumFormatChanged ); + + bool IdleCalcTextWidth(); + + void RepaintRange( const ScRange& rRange ); + void RepaintRange( const ScRangeList& rRange ); + + bool IsIdleEnabled() const { return mbIdleEnabled; } + void EnableIdle(bool bDo) { mbIdleEnabled = bDo; } + + bool IsDetectiveDirty() const { return bDetectiveDirty; } + void SetDetectiveDirty(bool bSet) { bDetectiveDirty = bSet; } + + bool HasLinkFormulaNeedingCheck() const { return bLinkFormulaNeedingCheck; } + void SetLinkFormulaNeedingCheck(bool bSet) { bLinkFormulaNeedingCheck = bSet; } + /** Check token array and set link check if ocDde/ocWebservice is contained. */ + SC_DLLPUBLIC void CheckLinkFormulaNeedingCheck( const ScTokenArray& rCode ); + + void SetRangeOverflowType(ErrCode nType) { nRangeOverflowType = nType; } + bool HasRangeOverflow() const { return nRangeOverflowType != ERRCODE_NONE; } + SC_DLLPUBLIC const ErrCode& GetRangeOverflowType() const { return nRangeOverflowType; } + + // for broadcasting/listening + void SetInsertingFromOtherDoc( bool bVal ) { bInsertingFromOtherDoc = bVal; } + bool IsInsertingFromOtherDoc() const { return bInsertingFromOtherDoc; } + void SetLoadingMedium( bool bVal ); + SC_DLLPUBLIC void SetImportingXML( bool bVal ); + bool IsImportingXML() const { return bImportingXML; } + bool IsCalcingAfterLoad() const { return bCalcingAfterLoad; } + void SetNoListening( bool bVal ) { bNoListening = bVal; } + bool GetNoListening() const { return bNoListening; } + ScBroadcastAreaSlotMachine* GetBASM() const { return pBASM.get(); } + + SC_DLLPUBLIC ScChartListenerCollection* GetChartListenerCollection() const { return pChartListenerCollection.get(); } + void SetChartListenerCollection( std::unique_ptr<ScChartListenerCollection>, + bool bSetChartRangeLists ); + void UpdateChart( const OUString& rName ); + void RestoreChartListener( const OUString& rName ); + SC_DLLPUBLIC void UpdateChartListenerCollection(); + bool IsChartListenerCollectionNeedsUpdate() const { return bChartListenerCollectionNeedsUpdate; } + void SetChartListenerCollectionNeedsUpdate( bool bFlg ) { bChartListenerCollectionNeedsUpdate = bFlg; } + void AddOLEObjectToCollection(const OUString& rName); + + ScChangeViewSettings* GetChangeViewSettings() const { return pChangeViewSettings.get(); } + SC_DLLPUBLIC void SetChangeViewSettings(const ScChangeViewSettings& rNew); + + const std::shared_ptr<SvxForbiddenCharactersTable>& GetForbiddenCharacters() const; + void SetForbiddenCharacters(const std::shared_ptr<SvxForbiddenCharactersTable>& rNew); + + CharCompressType GetAsianCompression() const; + bool IsValidAsianCompression() const; + void SetAsianCompression(CharCompressType nNew); + + bool GetAsianKerning() const; + bool IsValidAsianKerning() const; + void SetAsianKerning(bool bNew); + void ApplyAsianEditSettings(ScEditEngineDefaulter& rEngine); + + EEHorizontalTextDirection GetEditTextDirection(SCTAB nTab) const; // EEHorizontalTextDirection values + + SC_DLLPUBLIC ScLkUpdMode GetLinkMode() const { return eLinkMode ;} + void SetLinkMode( ScLkUpdMode nSet ) { eLinkMode = nSet;} + + SC_DLLPUBLIC ScMacroManager* GetMacroManager(); + + void FillMatrix( ScMatrix& rMat, SCTAB nTab, SCCOL nCol1, + SCROW nRow1, SCCOL nCol2, SCROW nRow2, + svl::SharedStringPool* pPool = nullptr) const; + + /** + * Set an array of numerical formula results to a group of contiguous + * formula cells. + * + * @param rTopPos position of the top formula cell of a group. + * @param pResults array of numeric results. + * @param nLen length of numeric results. + */ + void SC_DLLPUBLIC SetFormulaResults( const ScAddress& rTopPos, const double* pResults, size_t nLen ); + + void CalculateInColumnInThread( ScInterpreterContext& rContext, const ScRange& rCalcRange, unsigned nThisThread, unsigned nThreadsTotal); + void HandleStuffAfterParallelCalculation( SCCOL nColStart, SCCOL nColEnd, SCROW nRow, size_t nLen, SCTAB nTab, ScInterpreter* pInterpreter ); + + /** + * Transfer a series of contiguous cell values from specified position to + * the passed container. The specified segment will become empty after the + * transfer. + */ + void TransferCellValuesTo( const ScAddress& rTopPos, size_t nLen, sc::CellValues& rDest ); + void CopyCellValuesFrom( const ScAddress& rTopPos, const sc::CellValues& rSrc ); + + std::set<Color> GetDocColors(); + sc::IconSetBitmapMap& GetIconSetBitmapMap(); + + std::set<SCCOL> QueryColumnsWithFormulaCells( SCTAB nTab ) const; + + /** + * Check the integrity of the internal table state. Useful from testing + * code. It throws an exception upon first failure. + * + * Feel free to add more checks as needed. + */ + void CheckIntegrity( SCTAB nTab ) const; + +private: + ScDocument(const ScDocument& r) = delete; + + void FindMaxRotCol( SCTAB nTab, RowInfo* pRowInfo, SCSIZE nArrCount, + SCCOL nX1, SCCOL nX2 ) const; + + sal_uInt16 RowDifferences( SCROW nThisRow, SCTAB nThisTab, + ScDocument& rOtherDoc, + SCROW nOtherRow, SCTAB nOtherTab, + SCCOL nMaxCol, const SCCOLROW* pOtherCols ); + sal_uInt16 ColDifferences( SCCOL nThisCol, SCTAB nThisTab, + ScDocument& rOtherDoc, + SCCOL nOtherCol, SCTAB nOtherTab, + SCROW nMaxRow, const SCCOLROW* pOtherRows ); + void FindOrder( SCCOLROW* pOtherRows, SCCOLROW nThisEndRow, SCCOLROW nOtherEndRow, + bool bColumns, + ScDocument& rOtherDoc, SCTAB nThisTab, SCTAB nOtherTab, + SCCOLROW nEndCol, const SCCOLROW* pTranslate, + ScProgress* pProgress, sal_uInt64 nProAdd ); + + DECL_LINK(TrackTimeHdl, Timer *, void); + + /** Adjust a range to available sheets. + + Used to start and stop listening on a sane range. Both o_rRange and + o_bEntirelyOutOfBounds are set only if needed and don't have to be + initialized by the caller. + + @param o_bEntirelyOutOfBounds + <TRUE/> if both sheets in the range point outside the + available sheet range, in which case no adjustment is done and + o_rRange is not modified. + + @return <TRUE/> if any adjustment was done or o_bEntirelyOutOfBounds + was set <TRUE/>. + <FALSE/> if rRange was within the available sheets. + */ + bool LimitRangeToAvailableSheets( const ScRange& rRange, ScRange& o_rRange, + bool& o_bEntirelyOutOfBounds ) const; + +public: + void StartListeningArea( const ScRange& rRange, bool bGroupListening, SvtListener* pListener ); + + void EndListeningArea( const ScRange& rRange, bool bGroupListening, SvtListener* pListener ); + /** Broadcast wrapper, calls + rHint.GetCell()->Broadcast() and AreaBroadcast() + and TrackFormulas() + Preferred. + */ + void Broadcast( const ScHint& rHint ); + + void BroadcastCells( const ScRange& rRange, SfxHintId nHint, bool bBroadcastSingleBroadcasters = true ); + + /// only area, no cell broadcast + void AreaBroadcast( const ScHint& rHint ); + void DelBroadcastAreasInRange( const ScRange& rRange ); + void UpdateBroadcastAreas( UpdateRefMode eUpdateRefMode, + const ScRange& rRange, + SCCOL nDx, SCROW nDy, SCTAB nDz ); + + void StartListeningCell( const ScAddress& rAddress, + SvtListener* pListener ); + void EndListeningCell( const ScAddress& rAddress, + SvtListener* pListener ); + + void StartListeningCell( sc::StartListeningContext& rCxt, const ScAddress& rPos, SvtListener& rListener ); + void EndListeningCell( sc::EndListeningContext& rCxt, const ScAddress& rPos, SvtListener& rListener ); + + void EndListeningFormulaCells( std::vector<ScFormulaCell*>& rCells ); + + sc::BroadcasterState GetBroadcasterState() const; + + void PutInFormulaTree( ScFormulaCell* pCell ); + void RemoveFromFormulaTree( ScFormulaCell* pCell ); + +/** + * Calculate formula cells that are on the formula tree either partially, + * or in full. + * + * @param bOnlyForced when true, it only calculates those formula cells + * that are marked "recalc forced". + * @param bProgressBar whether or not to use progress bar. + * @param bSetAllDirty when true, it marks all formula cells currently on + * the formula tree dirty, which forces all of them to + * be recalculated. When false, only those cells + * that are marked dirty prior to this call get + * recalculated. + */ + SC_DLLPUBLIC void CalcFormulaTree( bool bOnlyForced = false, bool bProgressBar = true, bool bSetAllDirty = true ); + void ClearFormulaTree(); + void AppendToFormulaTrack( ScFormulaCell* pCell ); + void RemoveFromFormulaTrack( ScFormulaCell* pCell ); + void TrackFormulas( SfxHintId nHintId = SfxHintId::ScDataChanged ); + void SetTrackFormulasPending() { mbTrackFormulasPending = true; } + bool IsTrackFormulasPending() const { return mbTrackFormulasPending; } + void FinalTrackFormulas( SfxHintId nHintId ); + bool IsFinalTrackFormulas() const { return mbFinalTrackFormulas; } + inline bool IsInFormulaTree( const ScFormulaCell* pCell ) const; + inline bool IsInFormulaTrack( const ScFormulaCell* pCell ) const; + HardRecalcState GetHardRecalcState() const { return eHardRecalcState; } + void SetHardRecalcState( HardRecalcState eVal ) { eHardRecalcState = eVal; } + void StartAllListeners(); + void StartNeededListeners(); + void StartNeededListeners( const std::shared_ptr<const sc::ColumnSet>& rpColSet ); + SC_DLLPUBLIC void StartAllListeners( const ScRange& rRange ); + + void SetForcedFormulas( bool bVal ) { bHasForcedFormulas = bVal; } + sal_uInt64 GetFormulaCodeInTree() const { return nFormulaCodeInTree; } + + bool IsInInterpreter() const { return nInterpretLevel != 0; } + + void IncInterpretLevel() + { + assert(!IsThreadedGroupCalcInProgress()); + if ( nInterpretLevel < USHRT_MAX ) + nInterpretLevel++; + } + void DecInterpretLevel() + { + assert(!IsThreadedGroupCalcInProgress()); + if ( nInterpretLevel ) + nInterpretLevel--; + } + sal_uInt16 GetMacroInterpretLevel() const { return nMacroInterpretLevel; } + void IncMacroInterpretLevel() + { + assert(!IsThreadedGroupCalcInProgress()); + if ( nMacroInterpretLevel < USHRT_MAX ) + nMacroInterpretLevel++; + } + void DecMacroInterpretLevel() + { + assert(!IsThreadedGroupCalcInProgress()); + if ( nMacroInterpretLevel ) + nMacroInterpretLevel--; + } + bool IsInInterpreterTableOp() const { return nInterpreterTableOpLevel != 0; } + void IncInterpreterTableOpLevel() + { + if ( nInterpreterTableOpLevel < USHRT_MAX ) + nInterpreterTableOpLevel++; + } + void DecInterpreterTableOpLevel() + { + if ( nInterpreterTableOpLevel ) + nInterpreterTableOpLevel--; + } + + // add a formula to be remembered for TableOp broadcasts + void AddTableOpFormulaCell( ScFormulaCell* ); + void InvalidateLastTableOpParams() { aLastTableOpParams.bValid = false; } + ScRecursionHelper& GetRecursionHelper(); + bool IsInDtorClear() const { return bInDtorClear; } + void SetExpandRefs( bool bVal ); + bool IsExpandRefs() const { return bExpandRefs; } + + sal_uInt64 GetXMLImportedFormulaCount() const { return nXMLImportedFormulaCount; } + void IncXMLImportedFormulaCount( sal_uInt64 nVal ) + { + if ( nXMLImportedFormulaCount + nVal > nXMLImportedFormulaCount ) + nXMLImportedFormulaCount += nVal; + } + void DecXMLImportedFormulaCount( sal_uInt64 nVal ) + { + if ( nVal <= nXMLImportedFormulaCount ) + nXMLImportedFormulaCount -= nVal; + else + nXMLImportedFormulaCount = 0; + } + + void StartTrackTimer(); + + void CompileDBFormula(); + void CompileColRowNameFormula(); + + /** Maximum string length of a column, e.g. for dBase export. + @return String length in octets (!) of the destination encoding. In + case of non-octet encodings (e.g. UCS2) the length in code + points times sizeof(sal_Unicode) is returned. */ + sal_Int32 GetMaxStringLen( SCTAB nTab, SCCOL nCol, + SCROW nRowStart, SCROW nRowEnd, + rtl_TextEncoding eCharSet ) const; + /** Maximum string length of numerical cells of a column, e.g. for dBase export. + @return String length in characters (!) including the decimal + separator, and the decimal precision needed. */ + sal_Int32 GetMaxNumberStringLen( sal_uInt16& nPrecision, + SCTAB nTab, SCCOL nCol, + SCROW nRowStart, SCROW nRowEnd ) const; + + void KeyInput(); // TimerDelays etc. + + ScChangeTrack* GetChangeTrack() const { return pChangeTrack.get(); } + + //! only for import filter, deletes any existing ChangeTrack via + //! EndChangeTracking() and takes ownership of new ChangeTrack pTrack + SC_DLLPUBLIC void SetChangeTrack( std::unique_ptr<ScChangeTrack> pTrack ); + + void StartChangeTracking(); + void EndChangeTracking(); + + SC_DLLPUBLIC void CompareDocument( ScDocument& rOtherDoc ); + + void AddUnoObject( SfxListener& rObject ); + void RemoveUnoObject( SfxListener& rObject ); + void BroadcastUno( const SfxHint &rHint ); + void AddUnoListenerCall( const css::uno::Reference< + css::util::XModifyListener >& rListener, + const css::lang::EventObject& rEvent ); + + void SetInLinkUpdate(bool bSet); // TableLink or AreaLink + bool IsInLinkUpdate() const; // including DdeLink + + SC_DLLPUBLIC SfxItemPool* GetEditPool() const; + SC_DLLPUBLIC SfxItemPool* GetEnginePool() const; + SC_DLLPUBLIC ScFieldEditEngine& GetEditEngine(); + SC_DLLPUBLIC ScNoteEditEngine& GetNoteEngine(); + + std::unique_ptr<EditTextObject> CreateSharedStringTextObject( const svl::SharedString& rSS ); + + std::unique_ptr<ScRefreshTimerControl> const & GetRefreshTimerControlAddress() const + { return pRefreshTimerControl; } + + void SetPastingDrawFromOtherDoc( bool bVal ) + { bPastingDrawFromOtherDoc = bVal; } + bool PastingDrawFromOtherDoc() const + { return bPastingDrawFromOtherDoc; } + + /// an ID unique to each document instance + sal_uInt32 GetDocumentID() const; + + void InvalidateStyleSheetUsage() { bStyleSheetUsageInvalid = true; } + void SC_DLLPUBLIC GetSortParam( ScSortParam& rParam, SCTAB nTab ); + void SC_DLLPUBLIC SetSortParam( const ScSortParam& rParam, SCTAB nTab ); + + void SetVbaEventProcessor( const css::uno::Reference< css::script::vba::XVBAEventProcessor >& rxVbaEvents ) + { mxVbaEvents = rxVbaEvents; } + const css::uno::Reference< css::script::vba::XVBAEventProcessor >& GetVbaEventProcessor() const { return mxVbaEvents; } + + /** Should only be GRAM_PODF or GRAM_ODFF. */ + void SetStorageGrammar( formula::FormulaGrammar::Grammar eGrammar ); + formula::FormulaGrammar::Grammar GetStorageGrammar() const { return eStorageGrammar; } + + SC_DLLPUBLIC ScUndoManager* GetUndoManager(); + bool IsInVBAMode() const; + ScRowBreakIterator* GetRowBreakIterator(SCTAB nTab) const; + + void AddSubTotalCell(ScFormulaCell* pCell); + void RemoveSubTotalCell(ScFormulaCell* pCell); + void SetSubTotalCellsDirty(const ScRange& rDirtyRange); + + sal_uInt16 GetTextWidth( const ScAddress& rPos ) const; + + SvtScriptType GetScriptType( const ScAddress& rPos ) const; + void SetScriptType( const ScAddress& rPos, SvtScriptType nType ); + void UpdateScriptTypes( const ScAddress& rPos, SCCOL nColSize, SCROW nRowSize ); + + /** + * Make specified formula cells non-grouped. + * + * @param nTab sheet index + * @param nCol column index + * @param rRows list of row indices at which formula cells are to be + * unshared. This call sorts the passed row indices and + * removes duplicates, which is why the caller must pass it + * as reference. + */ + void UnshareFormulaCells( SCTAB nTab, SCCOL nCol, std::vector<SCROW>& rRows ); + void RegroupFormulaCells( SCTAB nTab, SCCOL nCol ); + SC_DLLPUBLIC void RegroupFormulaCells( const ScRange& range ); + + formula::FormulaTokenRef ResolveStaticReference( const ScAddress& rPos ); + formula::FormulaTokenRef ResolveStaticReference( const ScRange& rRange ); + + formula::VectorRefArray FetchVectorRefArray( const ScAddress& rPos, SCROW nLength ); + bool HandleRefArrayForParallelism( const ScAddress& rPos, SCROW nLength, + const ScFormulaCellGroupRef& mxGroup, ScAddress* pDirtiedAddress ); +#ifdef DBG_UTIL + void AssertNoInterpretNeeded( const ScAddress& rPos, SCROW nLength ); +#endif + + /** + * Call this before any operations that might trigger one or more formula + * cells to get calculated. + */ + void PrepareFormulaCalc(); + + /** + * Make sure all of the formula cells in the specified range have been + * fully calculated. This method only re-calculates those formula cells + * that have been flagged dirty. In case of formula-groups, this calculates + * only the dirty subspans along with the dependents in the same way + * recursively. + * + * @param rRange range in which to potentially calculate the formula + * cells. + * @param bSkipRunning flag to skip evaluation of formula-cells that are + * marked as already being evaluated. + * @return true if at least one formula-cell in the specified range was dirty + * else returns false. + */ + SC_DLLPUBLIC bool EnsureFormulaCellResults( const ScRange& rRange, bool bSkipRunning = false ); + + SvtBroadcaster* GetBroadcaster( const ScAddress& rPos ); + const SvtBroadcaster* GetBroadcaster( const ScAddress& rPos ) const; + void DeleteBroadcasters( sc::ColumnBlockPosition& rBlockPos, const ScAddress& rTopPos, SCROW nLength ); + + std::optional<sc::ColumnIterator> GetColumnIterator( SCTAB nTab, SCCOL nCol, SCROW nRow1, SCROW nRow2 ) const; + void CreateColumnIfNotExists( SCTAB nTab, SCCOL nCol ); + + SC_DLLPUBLIC void StoreTabToCache(SCTAB nTab, SvStream& rStrm) const; + SC_DLLPUBLIC void RestoreTabFromCache(SCTAB nTab, SvStream& rStream); + +#if DUMP_COLUMN_STORAGE + SC_DLLPUBLIC void DumpColumnStorage( SCTAB nTab, SCCOL nCol ) const; +#endif + + SC_DLLPUBLIC void SetCalcConfig( const ScCalcConfig& rConfig ); + const ScCalcConfig& GetCalcConfig() const { return maCalcConfig; } + void ConvertFormulaToValue( const ScRange& rRange, sc::TableValues* pUndo ); + void SwapNonEmpty( sc::TableValues& rValues ); + void finalizeOutlineImport(); + + // Returns the given column range, first allocating all the columns if necessary. + SC_DLLPUBLIC ScColumnsRange GetWritableColumnsRange(SCTAB nTab, SCCOL nColBegin, SCCOL nColEnd); + // Returns a column range, clamped to the allocated columns. + SC_DLLPUBLIC ScColumnsRange GetAllocatedColumnsRange(SCTAB nTab, SCCOL nColBegin, SCCOL nColEnd) const; + // Returns the given range, without any adjustments. One of the variants above may return + // a smaller range (better performance) if the use case is known. + SC_DLLPUBLIC ScColumnsRange GetColumnsRange(SCTAB nTab, SCCOL nColBegin, SCCOL nColEnd) const; + + bool IsInDocShellRecalc() const { return mbDocShellRecalc; } + void SetDocShellRecalc(bool bSet) { mbDocShellRecalc = bSet; } + + bool IsInLayoutStrings() const { return mbLayoutStrings; } + void SetLayoutStrings(bool bSet) { mbLayoutStrings = bSet; } + + /** + * Serializes the specified sheet's geometry data. + * + * @param nTab is the index of the sheet to operate on. + * @param bColumns - if true it dumps the data for columns, else it does for rows. + * @param eGeomType indicates the type of data to be dumped for rows/columns. + * @return the serialization of the specified sheet's geometry data as an OString. + */ + OString dumpSheetGeomData(SCTAB nTab, bool bColumns, SheetGeomType eGeomType); + + SCCOL GetLOKFreezeCol(SCTAB nTab) const; + SCROW GetLOKFreezeRow(SCTAB nTab) const; + bool SetLOKFreezeCol(SCCOL nFreezeCol, SCTAB nTab); + bool SetLOKFreezeRow(SCROW nFreezeRow, SCTAB nTab); + +private: + + /** + * Use this class as a locale variable to merge number formatter from + * another document, and set NULL pointer to pFormatExchangeList when + * done. + */ + class NumFmtMergeHandler + { + public: + explicit NumFmtMergeHandler(ScDocument& rDoc, const ScDocument& rSrcDoc); + ~NumFmtMergeHandler(); + + private: + ScDocument& mrDoc; + }; + + void MergeNumberFormatter(const ScDocument& rSrcDoc); + + void ImplCreateOptions(); // Suggestion: switch to on-demand? + void ImplDeleteOptions(); + + SC_DLLPUBLIC bool DrawGetPrintArea( ScRange& rRange, bool bSetHor, bool bSetVer ) const; + + void UpdateDrawPrinter(); + void UpdateDrawLanguages(); + SC_DLLPUBLIC void InitClipPtrs( ScDocument* pSourceDoc ); + + void LoadDdeLinks(SvStream& rStream); + void SaveDdeLinks(SvStream& rStream) const; + + void DeleteAreaLinksOnTab( SCTAB nTab ); + void UpdateRefAreaLinks( UpdateRefMode eUpdateRefMode, + const ScRange& r, SCCOL nDx, SCROW nDy, SCTAB nDz ); + + void CopyRangeNamesToClip(ScDocument* pClipDoc, const ScRange& rClipRange, const ScMarkData* pMarks); + + bool HasPartOfMerged( const ScRange& rRange ); + +public: + SC_DLLPUBLIC ScTable* FetchTable( SCTAB nTab ); + const ScTable* FetchTable( SCTAB nTab ) const; + + ScRefCellValue GetRefCellValue( const ScAddress& rPos ); +private: + ScRefCellValue GetRefCellValue( const ScAddress& rPos, sc::ColumnBlockPosition& rBlockPos ); + + std::map< SCTAB, ScSortParam > mSheetSortParams; + + SCSIZE GetPatternCount( SCTAB nTab, SCCOL nCol ) const; + SCSIZE GetPatternCount( SCTAB nTab, SCCOL nCol, SCROW nRow1, SCROW nRow2 ) const; + void ReservePatternCount( SCTAB nTab, SCCOL nCol, SCSIZE nReserve ); + + void SharePooledResources( const ScDocument* pSrcDoc ); + + void EndListeningIntersectedGroup( + sc::EndListeningContext& rCxt, const ScAddress& rPos, std::vector<ScAddress>* pGroupPos ); + + void EndListeningIntersectedGroups( + sc::EndListeningContext& rCxt, const ScRange& rRange, std::vector<ScAddress>* pGroupPos ); + + void EndListeningGroups( const std::vector<ScAddress>& rPosArray ); + void SetNeedsListeningGroups( const std::vector<ScAddress>& rPosArray ); + + bool BroadcastHintInternal( const ScHint &rHint ); +}; + +typedef std::unique_ptr<ScDocument, o3tl::default_delete<ScDocument>> ScDocumentUniquePtr; + +/** + * Instantiate this to ensure that subsequent modification of + * the document will cause an assertion failure while this is + * in-scope. + */ +struct ScMutationDisable +{ +#ifndef NDEBUG + ScMutationDisable(ScDocument& rDocument, ScMutationGuardFlags nFlags) + : mnFlagRestore(rDocument.mnMutationGuardFlags) + , mrDocument(rDocument) + { + assert((mnFlagRestore & nFlags) == 0); + mrDocument.mnMutationGuardFlags |= static_cast<size_t>(nFlags); + } + ~ScMutationDisable() + { + mrDocument.mnMutationGuardFlags = mnFlagRestore; + } + size_t mnFlagRestore; + ScDocument& mrDocument; +#else + ScMutationDisable(ScDocument& rDocument, ScMutationGuardFlags nFlags) + { + (void)rDocument; (void)nFlags; + } +#endif +}; + +/** + * A pretty assertion that checks that the relevant bits in + * the @nFlags are not set on the document at entry and exit. + * + * Its primary use is for debugging threading. As such, an + * @ScMutationDisable is created to forbid mutation, and this + * condition is then asserted on at prominent sites that + * mutate @nFlags. + */ +struct ScMutationGuard +{ +#ifndef NDEBUG + ScMutationGuard(ScDocument& rDocument, ScMutationGuardFlags nFlags) + : mnFlags(static_cast<size_t>(nFlags)) + , mrDocument(rDocument) + { + assert((mrDocument.mnMutationGuardFlags & mnFlags) == 0); + } + + ~ScMutationGuard() + { + assert((mrDocument.mnMutationGuardFlags & mnFlags) == 0); + } + size_t mnFlags; + ScDocument& mrDocument; +#else + ScMutationGuard(ScDocument& rDocument, ScMutationGuardFlags nFlags) + { + (void)rDocument; (void)nFlags; + } +#endif +}; + +class ScDocShellRecalcGuard +{ + ScDocument& mrDoc; + +public: + ScDocShellRecalcGuard(ScDocument& rDoc) + : mrDoc(rDoc) + { + assert(!mrDoc.IsInDocShellRecalc()); + mrDoc.SetDocShellRecalc(true); + } + + ~ScDocShellRecalcGuard() + { + mrDoc.SetDocShellRecalc(false); + } +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/documentimport.hxx b/sc/inc/documentimport.hxx new file mode 100644 index 0000000000..2ffc75d67b --- /dev/null +++ b/sc/inc/documentimport.hxx @@ -0,0 +1,152 @@ +/* -*- 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/. + */ + +#pragma once + +#include "scdllapi.h" +#include "address.hxx" +#include "attarray.hxx" + +#include <rtl/ustring.hxx> + +#include <memory> +#include <vector> + +class EditTextObject; +class ScDocument; +class ScColumn; +class ScPatternAttr; +class ScTokenArray; +class ScFormulaCell; +class ScStyleSheet; +struct ScSetStringParam; +struct ScTabOpParam; +struct ScDocumentImportImpl; +enum class SvtScriptType : sal_uInt8; + +/** + * Accessor class to ScDocument. Its purpose is to allow import filter to + * fill the document model and nothing but that. Filling the document via + * this class does not trigger any kind of broadcasting, drawing object + * position calculation, or anything else that requires expensive + * computation which are unnecessary and undesirable during import. + */ +class SC_DLLPUBLIC ScDocumentImport +{ + std::unique_ptr<ScDocumentImportImpl> mpImpl; + +public: + + struct SC_DLLPUBLIC Attrs + { + std::vector<ScAttrEntry> mvData; + + bool mbLatinNumFmtOnly; + + Attrs(); + ~Attrs(); + Attrs& operator=( Attrs const & ) = delete; // MSVC2015 workaround + Attrs( Attrs const & ) = delete; // MSVC2015 workaround + bool operator==(const Attrs& other) const + { + return mvData == other.mvData && mbLatinNumFmtOnly == other.mbLatinNumFmtOnly; + } + Attrs& operator=( Attrs&& attrs ) = default; + }; + + ScDocumentImport() = delete; + ScDocumentImport(ScDocument& rDoc); + ScDocumentImport(const ScDocumentImport&) = delete; + const ScDocumentImport& operator=(const ScDocumentImport&) = delete; + ~ScDocumentImport(); + + ScDocument& getDoc(); + const ScDocument& getDoc() const; + + /** + * Initialize the storage for all sheets after all the sheet instances + * have been created in the document. + */ + void initForSheets(); + + void setDefaultNumericScript(SvtScriptType nScript); + + /** + * Apply specified cell style to an entire sheet. + */ + void setCellStyleToSheet(SCTAB nTab, const ScStyleSheet& rStyle); + + /** + * @param rName sheet name. + * + * @return 0-based sheet index, or -1 in case no sheet is found by + * specified name. + */ + SCTAB getSheetIndex(const OUString& rName) const; + SCTAB getSheetCount() const; + bool appendSheet(const OUString& rName); + void setSheetName(SCTAB nTab, const OUString& rName); + + void setOriginDate(sal_uInt16 nYear, sal_uInt16 nMonth, sal_uInt16 nDay); + + void setAutoInput(const ScAddress& rPos, const OUString& rStr, + const ScSetStringParam* pStringParam = nullptr); + void setNumericCell(const ScAddress& rPos, double fVal); + void setStringCell(const ScAddress& rPos, const OUString& rStr); + void setEditCell(const ScAddress& rPos, std::unique_ptr<EditTextObject> pEditText); + + void setFormulaCell( + const ScAddress& rPos, const OUString& rFormula, formula::FormulaGrammar::Grammar eGrammar, + const double* pResult = nullptr ); + + void setFormulaCell( + const ScAddress& rPos, const OUString& rFormula, formula::FormulaGrammar::Grammar eGrammar, + const OUString& rResult ); + + void setFormulaCell(const ScAddress& rPos, std::unique_ptr<ScTokenArray> pArray); + void setFormulaCell(const ScAddress& rPos, ScFormulaCell* pCell); + + void setMatrixCells( + const ScRange& rRange, const ScTokenArray& rArray, formula::FormulaGrammar::Grammar eGrammar); + + void setTableOpCells(const ScRange& rRange, const ScTabOpParam& rParam); + + void fillDownCells(const ScAddress& rPos, SCROW nFillSize); + + /** + * Set an array of cell attributes to specified range of columns. This call + * transfers the ownership of the ScAttrEntry array from the caller to the + * column. + */ + void setAttrEntries( SCTAB nTab, SCCOL nColStart, SCCOL nColEnd, Attrs&& rAttrs ); + + void setRowsVisible(SCTAB nTab, SCROW nRowStart, SCROW nRowEnd, bool bVisible); + + void setMergedCells(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2); + + void invalidateBlockPositionSet(SCTAB nTab); + + void finalize(); + + /** Broadcast all formula cells that are marked with + FormulaTokenArray::IsRecalcModeMustAfterImport() for a subsequent + ScDocument::CalcFormulaTree(). + */ + void broadcastRecalcAfterImport(); + + /** small cache for hot call during import */ + bool isLatinScript(sal_uInt32 nFormat); + bool isLatinScript(const ScPatternAttr&); + +private: + void initColumn(ScColumn& rCol); + static void broadcastRecalcAfterImportColumn(ScColumn& rCol); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/documentlinkmgr.hxx b/sc/inc/documentlinkmgr.hxx new file mode 100644 index 0000000000..de36ec40fa --- /dev/null +++ b/sc/inc/documentlinkmgr.hxx @@ -0,0 +1,71 @@ +/* -*- 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/. + */ + +#pragma once + +#include <memory> +#include <string_view> + +class SfxObjectShell; +namespace weld { class Window; } + +namespace sfx2 { + +class LinkManager; + +} + +namespace sc { + +class DataStream; +struct DocumentLinkManagerImpl; + +class DocumentLinkManager +{ + std::unique_ptr<DocumentLinkManagerImpl> mpImpl; + +public: + DocumentLinkManager( SfxObjectShell* pShell ); + DocumentLinkManager(const DocumentLinkManager&) = delete; + const DocumentLinkManager& operator=(const DocumentLinkManager&) = delete; + ~DocumentLinkManager(); + + void setDataStream( DataStream* p ); + DataStream* getDataStream(); + const DataStream* getDataStream() const; + + /** + * @param bCreate if true, create a new link manager instance in case one + * does not exist. + * + * @return link manager instance. + */ + sfx2::LinkManager* getLinkManager( bool bCreate = true ); + + const sfx2::LinkManager* getExistingLinkManager() const; + + bool idleCheckLinks(); + + bool hasDdeLinks() const; + bool hasDdeOrOleOrWebServiceLinks() const; + bool hasExternalRefLinks() const; + + bool updateDdeOrOleOrWebServiceLinks(weld::Window* pWin); + + void updateDdeLink( std::u16string_view rAppl, std::u16string_view rTopic, std::u16string_view rItem ); + + size_t getDdeLinkCount() const; + +private: + bool hasDdeOrOleOrWebServiceLinks(bool bDde, bool bOle, bool bWebService) const; +}; + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/documentstreamaccess.hxx b/sc/inc/documentstreamaccess.hxx new file mode 100644 index 0000000000..d34ea15ac8 --- /dev/null +++ b/sc/inc/documentstreamaccess.hxx @@ -0,0 +1,58 @@ +/* -*- 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/. + */ + +#pragma once + +#include <rtl/ustring.hxx> +#include <memory> + +class ScDocument; +class ScAddress; +class ScRange; + +namespace sc +{ +struct DocumentStreamAccessImpl; + +/** + * Provides methods to allow direct shifting of document content without + * broadcasting or shifting of broadcaster positions. + */ +class DocumentStreamAccess +{ + std::unique_ptr<DocumentStreamAccessImpl> mpImpl; + +public: + DocumentStreamAccess(ScDocument& rDoc); + ~DocumentStreamAccess(); + + void setNumericCell(const ScAddress& rPos, double fVal); + void setStringCell(const ScAddress& rPos, const OUString& rStr); + + /** + * Clear its internal state, and more importantly all the block position + * hints currently held. + */ + void reset(); + + /** + * Pop the top row inside specified range, shift all the other rows up by + * one, then set the bottom row empty. + */ + void shiftRangeUp(const ScRange& rRange); + + /** + * Top the bottom row inside specified range, shift all the other rows + * above downward by one by inserting an empty row at the top. + */ + void shiftRangeDown(const ScRange& rRange); +}; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx new file mode 100644 index 0000000000..611b0c22d2 --- /dev/null +++ b/sc/inc/docuno.hxx @@ -0,0 +1,765 @@ +/* -*- 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 "address.hxx" + +#include <sal/types.h> +#include <sfx2/sfxbasemodel.hxx> +#include <svl/lstner.hxx> +#include <svx/fmdmod.hxx> +#include <com/sun/star/view/XRenderable.hpp> +#include <com/sun/star/style/XStyleFamiliesSupplier.hpp> +#include <com/sun/star/document/XActionLockable.hpp> +#include <com/sun/star/document/XLinkTargetSupplier.hpp> +#include <com/sun/star/drawing/XDrawPagesSupplier.hpp> +#include <com/sun/star/drawing/XDrawPages.hpp> +#include <com/sun/star/sheet/XGoalSeek.hpp> +#include <com/sun/star/sheet/XCalculatable.hpp> +#include <com/sun/star/sheet/XScenarios.hpp> +#include <com/sun/star/sheet/XConsolidatable.hpp> +#include <com/sun/star/sheet/XSpreadsheetDocument.hpp> +#include <com/sun/star/sheet/XSpreadsheets2.hpp> +#include <com/sun/star/sheet/XDocumentAuditing.hpp> +#include <com/sun/star/chart2/XDataProviderAccess.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/util/XProtectable.hpp> +#include <com/sun/star/container/XEnumerationAccess.hpp> +#include <com/sun/star/table/XTableColumns.hpp> +#include <com/sun/star/table/XTableRows.hpp> +#include <com/sun/star/sheet/XSheetAnnotations.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/sheet/XCellRangesAccess.hpp> +#include <com/sun/star/sheet/opencl/XOpenCLSelection.hpp> +#include <com/sun/star/util/XChangesNotifier.hpp> +#include <com/sun/star/uno/XAggregation.hpp> +#include <cppuhelper/implbase.hxx> +#include <comphelper/interfacecontainer3.hxx> +#include <svl/itemprop.hxx> +#include <vcl/ITiledRenderable.hxx> + +namespace com::sun::star::chart2::data { class XDataProvider; } +namespace com::sun::star::sheet::opencl { struct OpenCLPlatform; } + +class ScDocShell; +class ScAnnotationObj; +class ScMarkData; +class ScPrintFuncCache; +struct ScPrintState; +class ScPrintSelectionStatus; +class ScTableColumnObj; +class ScTableRowObj; +class ScTableSheetObj; +class ScRangeList; +class ScPrintUIOptions; +class ScSheetSaveData; +struct ScFormatSaveData; + +class SC_DLLPUBLIC ScModelObj : public SfxBaseModel, + public vcl::ITiledRenderable, + public css::sheet::XSpreadsheetDocument, + public css::document::XActionLockable, + public css::sheet::XCalculatable, + public css::util::XProtectable, + public css::drawing::XDrawPagesSupplier, + public css::sheet::XGoalSeek, + public css::sheet::XConsolidatable, + public css::sheet::XDocumentAuditing, + public css::style::XStyleFamiliesSupplier, + public css::view::XRenderable, + public css::document::XLinkTargetSupplier, + public css::beans::XPropertySet, + public SvxFmMSFactory, ///< derived from XMultiServiceFactory + public css::lang::XServiceInfo, + public css::util::XChangesNotifier, + public css::chart2::XDataProviderAccess, + public css::sheet::opencl::XOpenCLSelection +{ +private: + SfxItemPropertySet aPropSet; + ScDocShell* pDocShell; + std::unique_ptr<ScPrintFuncCache> pPrintFuncCache; + std::unique_ptr<ScPrintUIOptions> pPrinterOptions; + std::unique_ptr<ScPrintState> m_pPrintState; + css::uno::Reference<css::uno::XAggregation> xNumberAgg; + css::uno::Reference<css::uno::XInterface> xDrawGradTab; + css::uno::Reference<css::uno::XInterface> xDrawHatchTab; + css::uno::Reference<css::uno::XInterface> xDrawBitmapTab; + css::uno::Reference<css::uno::XInterface> xDrawTrGradTab; + css::uno::Reference<css::uno::XInterface> xDrawMarkerTab; + css::uno::Reference<css::uno::XInterface> xDrawDashTab; + css::uno::Reference<css::uno::XInterface> xChartDataProv; + css::uno::Reference<css::uno::XInterface> xObjProvider; + + ::comphelper::OInterfaceContainerHelper3<css::util::XChangesListener> maChangesListeners; + + bool FillRenderMarkData( const css::uno::Any& aSelection, + const css::uno::Sequence< css::beans::PropertyValue >& rOptions, + ScMarkData& rMark, ScPrintSelectionStatus& rStatus, OUString& rPagesStr, + bool& rbRenderToGraphic ) const; + css::uno::Reference<css::uno::XAggregation> const & GetFormatter(); + void HandleCalculateEvents(); + + css::uno::Reference<css::uno::XInterface> create( + OUString const & aServiceSpecifier, + css::uno::Sequence<css::uno::Any> const * arguments); + + static bool IsOnEvenPage( sal_Int32 nPage ) { return nPage % 2 == 0; }; + + OUString maBuildId; + std::vector<sal_Int32> maValidPages; +protected: + const SfxItemPropertySet& GetPropertySet() const { return aPropSet; } + + /** abstract SdrModel provider */ + virtual SdrModel& getSdrModelFromUnoModel() const override; + +public: + ScModelObj(ScDocShell* pDocSh); + virtual ~ScModelObj() override; + + /// create ScModelObj and set at pDocSh (SetBaseModel) + static void CreateAndSet(ScDocShell* pDocSh); + + ScDocument* GetDocument() const; + SfxObjectShell* GetEmbeddedObject() const; + + void UpdateAllRowHeights(); + + void BeforeXMLLoading(); + void AfterXMLLoading(); + ScSheetSaveData* GetSheetSaveData(); + ScFormatSaveData* GetFormatSaveData(); + + void RepaintRange( const ScRange& rRange ); + void RepaintRange( const ScRangeList& rRange ); + + bool HasChangesListeners() const; + + void NotifyChanges( const OUString& rOperation, const ScRangeList& rRanges, + const css::uno::Sequence< css::beans::PropertyValue >& rProperties ); + + virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; + virtual void SAL_CALL acquire() noexcept override; + virtual void SAL_CALL release() noexcept override; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + /// XSpreadsheetDocument + virtual css::uno::Reference< css::sheet::XSpreadsheets > SAL_CALL + getSheets() override; + + /// XDataProviderAccess + virtual ::css::uno::Reference< css::chart2::data::XDataProvider > SAL_CALL + createDataProvider() override; + + /// XStyleFamiliesSupplier + virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL + getStyleFamilies() override; + + /// XRenderable + virtual sal_Int32 SAL_CALL getRendererCount( const css::uno::Any& aSelection, + const css::uno::Sequence< css::beans::PropertyValue >& xOptions ) override; + virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL + getRenderer( sal_Int32 nRenderer, const css::uno::Any& aSelection, + const css::uno::Sequence< css::beans::PropertyValue >& xOptions ) override; + virtual void SAL_CALL render( sal_Int32 nRenderer, const css::uno::Any& aSelection, + const css::uno::Sequence< css::beans::PropertyValue >& xOptions ) override; + + /// XLinkTargetSupplier + virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL + getLinks() override; + + /// XActionLockable + virtual sal_Bool SAL_CALL isActionLocked() override; + virtual void SAL_CALL addActionLock() override; + virtual void SAL_CALL removeActionLock() override; + virtual void SAL_CALL setActionLocks( sal_Int16 nLock ) override; + virtual sal_Int16 SAL_CALL resetActionLocks() override; + + virtual void SAL_CALL lockControllers() override; + virtual void SAL_CALL unlockControllers() override; + + /// XCalculatable + virtual void SAL_CALL calculate() override; + virtual void SAL_CALL calculateAll() override; + virtual sal_Bool SAL_CALL isAutomaticCalculationEnabled() override; + virtual void SAL_CALL enableAutomaticCalculation( sal_Bool bEnabled ) override; + + /// XProtectable + virtual void SAL_CALL protect( const OUString& aPassword ) override; + virtual void SAL_CALL unprotect( const OUString& aPassword ) override; + virtual sal_Bool SAL_CALL isProtected() override; + + /// XDrawPagesSupplier + virtual css::uno::Reference< css::drawing::XDrawPages > SAL_CALL + getDrawPages() override; + + /// XGoalSeek + virtual css::sheet::GoalResult SAL_CALL seekGoal( + const css::table::CellAddress& aFormulaPosition, + const css::table::CellAddress& aVariablePosition, + const OUString& aGoalValue ) override; + + /// XConsolidatable + virtual css::uno::Reference< css::sheet::XConsolidationDescriptor > + SAL_CALL createConsolidationDescriptor( sal_Bool bEmpty ) override; + virtual void SAL_CALL consolidate( const css::uno::Reference< css::sheet::XConsolidationDescriptor >& xDescriptor ) override; + + /// XDocumentAuditing + virtual void SAL_CALL refreshArrows() override; + + /// XViewDataSupplier + virtual css::uno::Reference< css::container::XIndexAccess > SAL_CALL getViewData( ) override; + + /// XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > + SAL_CALL getPropertySetInfo() override; + virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, + const css::uno::Any& aValue ) override; + virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override; + virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override; + virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override; + virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + + /// XMultiServiceFactory + virtual css::uno::Reference< css::uno::XInterface > SAL_CALL + createInstance( const OUString& aServiceSpecifier ) override; + virtual css::uno::Reference< css::uno::XInterface > SAL_CALL + createInstanceWithArguments( const OUString& ServiceSpecifier, + const css::uno::Sequence< css::uno::Any >& Arguments ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getAvailableServiceNames() override; + + /// XServiceInfo + 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; + + /// XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override; + + static const css::uno::Sequence<sal_Int8>& getUnoTunnelId(); + + /// XTypeProvider + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; + virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + + /// XChangesNotifier + virtual void SAL_CALL addChangesListener( const css::uno::Reference< css::util::XChangesListener >& aListener ) override; + virtual void SAL_CALL removeChangesListener( const css::uno::Reference< css::util::XChangesListener >& aListener ) override; + + // XOpenCLSelection + virtual sal_Bool SAL_CALL isOpenCLEnabled() override; + + virtual void SAL_CALL enableOpenCL(sal_Bool bEnable) override; + + virtual void SAL_CALL enableAutomaticDeviceSelection(sal_Bool bForce) override; + + virtual void SAL_CALL disableAutomaticDeviceSelection() override; + + virtual void SAL_CALL selectOpenCLDevice( sal_Int32 platform, sal_Int32 device ) override; + + virtual sal_Int32 SAL_CALL getPlatformID() override; + + virtual sal_Int32 SAL_CALL getDeviceID() override; + + virtual css::uno::Sequence< css::sheet::opencl::OpenCLPlatform > + SAL_CALL getOpenCLPlatforms() override; + + virtual void SAL_CALL enableOpcodeSubsetTest() override; + + virtual void SAL_CALL disableOpcodeSubsetTest() override; + + virtual sal_Bool SAL_CALL isOpcodeSubsetTested() override; + + virtual void SAL_CALL setFormulaCellNumberLimit( sal_Int32 number ) override; + + virtual sal_Int32 SAL_CALL getFormulaCellNumberLimit() override; + + /// @see vcl::ITiledRenderable::paintTile(). + virtual void paintTile( VirtualDevice& rDevice, + int nOutputWidth, + int nOutputHeight, + int nTilePosX, + int nTilePosY, + tools::Long nTileWidth, + tools::Long nTileHeight ) override; + + /// @see vcl::ITiledRenderable::getDocumentSize(). + virtual Size getDocumentSize() final override; + + /// @see vcl::ITiledRenderable::getDataArea(). + virtual Size getDataArea(long nPart) override; + + /// @see vcl::ITiledRenderable::setPart(). + virtual void setPart(int nPart, bool bAllowChangeFocus = true) override; + + /// @see vcl::ITiledRenderable::getPart(). + virtual int getPart() override; + + /// @see vcl::ITiledRenderable::getParts(). + virtual int getParts() override; + + /// @see vcl::ITiledRenderable::getPartInfo(). + virtual OUString getPartInfo( int nPart ) override; + + /// @see vcl::ITiledRenderable::getPartName(). + virtual OUString getPartName(int nPart) override; + + /// @see vcl::ITiledRenderable::getPartHash(). + virtual OUString getPartHash( int nPart ) override; + + /// @see vcl::ITiledRenderable::getDocWindow(). + virtual VclPtr<vcl::Window> getDocWindow() override; + + /// @see vcl::ITiledRenderable::initializeForTiledRendering(). + virtual void initializeForTiledRendering(const css::uno::Sequence<css::beans::PropertyValue>& rArguments) override; + + /// @see vcl::ITiledRenderable::postKeyEvent(). + virtual void postKeyEvent(int nType, int nCharCode, int nKeyCode) override; + + /// @see vcl::ITiledRenderable::postMouseEvent(). + virtual void postMouseEvent(int nType, int nX, int nY, int nCount, int nButtons, int nModifier) override; + + /// @see vcl::ITiledRenderable::setTextSelection(). + virtual void setTextSelection(int nType, int nX, int nY) override; + + /// @see vcl::ITiledRenderable::getSelection(). + virtual css::uno::Reference<css::datatransfer::XTransferable> getSelection() override; + + /// @see vcl::ITiledRenderable::setGraphicSelection(). + virtual void setGraphicSelection(int nType, int nX, int nY) override; + + /// @see lok::Document::resetSelection(). + virtual void resetSelection() override; + + /// @see vcl::ITiledRenderable::setClipboard(). + virtual void setClipboard(const css::uno::Reference<css::datatransfer::clipboard::XClipboard>& xClipboard) override; + + /// @see vcl::ITiledRenderable::isMimeTypeSupported(). + virtual bool isMimeTypeSupported() override; + + /// @see vcl::ITiledRenderable::setClientZoom(). + virtual void setClientZoom(int nTilePixelWidth, int nTilePixelHeight, int nTileTwipWidth, int nTileTwipHeight) override; + + /// @see vcl::ITiledRenderable::setOutlineState(). + virtual void setOutlineState(bool bColumn, int nLevel, int nIndex, bool bHidden) override; + + /// @see vcl::ITiledRenderable::getRowColumnHeaders(). + virtual void getRowColumnHeaders(const tools::Rectangle& rRectangle, tools::JsonWriter& rJsonWriter) override; + + /// @see vcl::ITiledRenderable::getSheetGeometryData(). + virtual OString getSheetGeometryData(bool bColumns, bool bRows, bool bSizes, bool bHidden, + bool bFiltered, bool bGroups) override; + + /// @see vcl::ITiledRenderable::getCellCursor(). + virtual void getCellCursor(tools::JsonWriter& rJsonWriter) override; + + /// @see vcl::ITiledRenderable::getPointer(). + virtual PointerStyle getPointer() override; + + /// @see vcl::ITiledRenderable::getTrackedChanges(). + void getTrackedChanges(tools::JsonWriter&) override; + + /// @see vcl::ITiledRenderable::setClientVisibleArea(). + virtual void setClientVisibleArea(const tools::Rectangle& rRectangle) override; + + /// @see vcl::ITiledRenderable::getPostIts(). + void getPostIts(tools::JsonWriter& rJsonWriter) override; + + /// @see vcl::ITiledRenderable::getPostItsPos(). + void getPostItsPos(tools::JsonWriter& rJsonWriter) override; + + /// @see vcl::ITiledRenderable::completeFunction(). + virtual void completeFunction(const OUString& rFunctionName) override; + + /// @see vcl::ITiledRenderable::getViewRenderState(). + OString getViewRenderState(SfxViewShell* pViewShell = nullptr) override; + +private: + Size getDocumentSize(SCCOL& rnTiledRenderingAreaEndCol, SCROW& rnTiledRenderingAreaEndRow ); +}; + +class ScDrawPagesObj final : public cppu::WeakImplHelper< + css::drawing::XDrawPages, + css::lang::XServiceInfo>, + public SfxListener +{ +private: + ScDocShell* pDocShell; + +css::uno::Reference< css::drawing::XDrawPage > + GetObjectByIndex_Impl(sal_Int32 nIndex) const; + +public: + ScDrawPagesObj(ScDocShell* pDocSh); + virtual ~ScDrawPagesObj() override; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + /// XDrawPages + virtual css::uno::Reference< css::drawing::XDrawPage > SAL_CALL + insertNewByIndex( sal_Int32 nIndex ) override; + virtual void SAL_CALL remove( const css::uno::Reference< css::drawing::XDrawPage >& xPage ) override; + + /// XIndexAccess + virtual sal_Int32 SAL_CALL getCount() override; + virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override; + + /// XElementAccess + virtual css::uno::Type SAL_CALL getElementType() override; + virtual sal_Bool SAL_CALL hasElements() override; + + /// XServiceInfo + 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; +}; + +class ScTableSheetsObj final : public cppu::WeakImplHelper< + css::sheet::XSpreadsheets2, + css::sheet::XCellRangesAccess, + css::container::XEnumerationAccess, + css::container::XIndexAccess, + css::lang::XServiceInfo>, + public SfxListener +{ +private: + ScDocShell* pDocShell; + + rtl::Reference<ScTableSheetObj> GetObjectByIndex_Impl(sal_Int32 nIndex) const; + rtl::Reference<ScTableSheetObj> GetObjectByName_Impl(const OUString& aName) const; + +public: + ScTableSheetsObj(ScDocShell* pDocSh); + virtual ~ScTableSheetsObj() override; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + /// XSpreadsheets + virtual void SAL_CALL insertNewByName( const OUString& aName, sal_Int16 nPosition ) override; + virtual void SAL_CALL moveByName( const OUString& aName, sal_Int16 nDestination ) override; + virtual void SAL_CALL copyByName( const OUString& aName, + const OUString& aCopy, sal_Int16 nDestination ) override; + + /// XSpreadsheets2 + virtual sal_Int32 SAL_CALL importSheet( + const css::uno::Reference< css::sheet::XSpreadsheetDocument > & xDocSrc, + const OUString& srcName, + sal_Int32 nDestPosition) override; + + /// XCellRangesAccess + + virtual css::uno::Reference< css::table::XCell > + SAL_CALL getCellByPosition( sal_Int32 nColumn, sal_Int32 nRow, sal_Int32 nSheet ) override; + + virtual css::uno::Reference< css::table::XCellRange > + SAL_CALL getCellRangeByPosition( sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom, sal_Int32 nSheet ) override; + + virtual css::uno::Sequence < css::uno::Reference< css::table::XCellRange > > + SAL_CALL getCellRangesByName( const OUString& aRange ) override; + + /// XNameContainer + virtual void SAL_CALL insertByName( const OUString& aName, + const css::uno::Any& aElement ) override; + virtual void SAL_CALL removeByName( const OUString& Name ) override; + + /// XNameReplace + virtual void SAL_CALL replaceByName( const OUString& aName, + const css::uno::Any& aElement ) override; + + /// XEnumerationAccess + virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL + createEnumeration() override; + + /// XElementAccess + virtual css::uno::Type SAL_CALL getElementType() override; + virtual sal_Bool SAL_CALL hasElements() override; + + /// XIndexAccess + virtual sal_Int32 SAL_CALL getCount() override; + virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override; + + /// XNameAccess + virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override; + virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override; + + /// XServiceInfo + 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; +}; + +class ScTableColumnsObj final : public cppu::WeakImplHelper< + css::table::XTableColumns, + css::container::XEnumerationAccess, + css::container::XNameAccess, + css::beans::XPropertySet, + css::lang::XServiceInfo>, + public SfxListener +{ +private: + ScDocShell* pDocShell; + SCTAB nTab; + SCCOL nStartCol; + SCCOL nEndCol; + + rtl::Reference<ScTableColumnObj> GetObjectByIndex_Impl(sal_Int32 nIndex) const; + rtl::Reference<ScTableColumnObj> GetObjectByName_Impl(std::u16string_view aName) const; + +public: + ScTableColumnsObj(ScDocShell* pDocSh, SCTAB nT, + SCCOL nSC, SCCOL nEC); + virtual ~ScTableColumnsObj() override; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + /// XTableColumns + virtual void SAL_CALL insertByIndex( sal_Int32 nIndex, sal_Int32 nCount ) override; + virtual void SAL_CALL removeByIndex( sal_Int32 nIndex, sal_Int32 nCount ) override; + + /// XNameAccess + virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override; + virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override; + + /// XIndexAccess + virtual sal_Int32 SAL_CALL getCount() override; + virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override; + + /// XEnumerationAccess + virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL + createEnumeration() override; + + /// XElementAccess + virtual css::uno::Type SAL_CALL getElementType() override; + virtual sal_Bool SAL_CALL hasElements() override; + + /// XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > + SAL_CALL getPropertySetInfo() override; + virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, + const css::uno::Any& aValue ) override; + virtual css::uno::Any SAL_CALL getPropertyValue( + const OUString& PropertyName ) override; + virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override; + virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override; + virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + + /// XServiceInfo + 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; +}; + +class ScTableRowsObj final : public cppu::WeakImplHelper< + css::table::XTableRows, + css::container::XEnumerationAccess, + css::beans::XPropertySet, + css::lang::XServiceInfo>, + public SfxListener +{ +private: + ScDocShell* pDocShell; + SCTAB nTab; + SCROW nStartRow; + SCROW nEndRow; + + rtl::Reference<ScTableRowObj> GetObjectByIndex_Impl(sal_Int32 nIndex) const; + +public: + ScTableRowsObj(ScDocShell* pDocSh, SCTAB nT, + SCROW nSR, SCROW nER); + virtual ~ScTableRowsObj() override; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + /// XTableRows + virtual void SAL_CALL insertByIndex( sal_Int32 nIndex, sal_Int32 nCount ) override; + virtual void SAL_CALL removeByIndex( sal_Int32 nIndex, sal_Int32 nCount ) override; + + /// XIndexAccess + virtual sal_Int32 SAL_CALL getCount() override; + virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override; + + /// XEnumerationAccess + virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL + createEnumeration() override; + + /// XElementAccess + virtual css::uno::Type SAL_CALL getElementType() override; + virtual sal_Bool SAL_CALL hasElements() override; + + /// XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > + SAL_CALL getPropertySetInfo() override; + virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, + const css::uno::Any& aValue ) override; + virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override; + virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override; + virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override; + virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + + /// XServiceInfo + 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; +}; + +class ScSpreadsheetSettingsObj final : public cppu::WeakImplHelper< + css::beans::XPropertySet, + css::lang::XServiceInfo>, + public SfxListener +{ +public: + virtual ~ScSpreadsheetSettingsObj() override; + + /// XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > + SAL_CALL getPropertySetInfo() override; + virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, + const css::uno::Any& aValue ) override; + virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override; + virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override; + virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override; + virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + + /// XServiceInfo + 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; +}; + +class SAL_DLLPUBLIC_RTTI ScAnnotationsObj final : public cppu::WeakImplHelper< + css::sheet::XSheetAnnotations, + css::container::XEnumerationAccess, + css::lang::XServiceInfo>, + public SfxListener +{ +private: + ScDocShell* pDocShell; + SCTAB nTab; ///< Collection belongs to the sheet + + bool GetAddressByIndex_Impl( sal_Int32 nIndex, ScAddress& rPos ) const; + rtl::Reference<ScAnnotationObj> GetObjectByIndex_Impl( sal_Int32 nIndex ) const; + +public: + ScAnnotationsObj(ScDocShell* pDocSh, SCTAB nT); + virtual ~ScAnnotationsObj() override; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + ScDocShell* GetDocShell() const { return pDocShell; } + + /// XSheetAnnotations + virtual void SAL_CALL insertNew( const css::table::CellAddress& aPosition, + const OUString& aText ) override; + virtual void SAL_CALL removeByIndex( sal_Int32 nIndex ) override; + + /// XIndexAccess + virtual sal_Int32 SAL_CALL getCount() override; + virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override; + + /// XEnumerationAccess + virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL + createEnumeration() override; + + /// XElementAccess + virtual css::uno::Type SAL_CALL getElementType() override; + virtual sal_Bool SAL_CALL hasElements() override; + + /// XServiceInfo + 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; +}; + +class ScScenariosObj final : public cppu::WeakImplHelper< + css::sheet::XScenarios, + css::container::XEnumerationAccess, + css::container::XIndexAccess, + css::lang::XServiceInfo>, + public SfxListener +{ +private: + ScDocShell* pDocShell; + SCTAB nTab; + + bool GetScenarioIndex_Impl( std::u16string_view rName, SCTAB& rIndex ); + rtl::Reference<ScTableSheetObj> GetObjectByIndex_Impl(sal_Int32 nIndex); + rtl::Reference<ScTableSheetObj> GetObjectByName_Impl(std::u16string_view aName); + +public: + ScScenariosObj(ScDocShell* pDocSh, SCTAB nT); + virtual ~ScScenariosObj() override; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + /// XScenarios + virtual void SAL_CALL addNewByName( const OUString& aName, + const css::uno::Sequence< css::table::CellRangeAddress >& aRanges, + const OUString& aComment ) override; + virtual void SAL_CALL removeByName( const OUString& aName ) override; + + /// XNameAccess + virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override; + virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override; + + /// XIndexAccess + virtual sal_Int32 SAL_CALL getCount() override; + virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override; + + /// XEnumerationAccess + virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL + createEnumeration() override; + + /// XElementAccess + virtual css::uno::Type SAL_CALL getElementType() override; + virtual sal_Bool SAL_CALL hasElements() override; + + /// XServiceInfo + 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; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/dpcache.hxx b/sc/inc/dpcache.hxx new file mode 100644 index 0000000000..e46e38f66a --- /dev/null +++ b/sc/inc/dpcache.hxx @@ -0,0 +1,215 @@ +/* -*- 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 "address.hxx" +#include "calcmacros.hxx" +#include "dpitemdata.hxx" +#include "dpnumgroupinfo.hxx" +#include "scdllapi.h" +#include "types.hxx" + +#include <mdds/flat_segment_tree.hpp> +#include <tools/long.hxx> +#include <o3tl/sorted_vector.hxx> + +#include <memory> +#include <unordered_set> +#include <vector> + +struct ScQueryParam; +class ScDPObject; +class ScDocument; +class SvNumberFormatter; + +enum class SvNumFormatType : sal_Int16; + +/** + * This class represents the cached data part of the datapilot cache table + * implementation. + */ +class SC_DLLPUBLIC ScDPCache +{ +public: + typedef std::unordered_set<OUString> StringSetType; + typedef mdds::flat_segment_tree<SCROW, bool> EmptyRowsType; + typedef std::vector<ScDPItemData> ScDPItemDataVec; + typedef o3tl::sorted_vector<ScDPObject*> ScDPObjectSet; + typedef std::vector<SCROW> IndexArrayType; + + struct SAL_DLLPRIVATE GroupItems + { + ScDPItemDataVec maItems; + ScDPNumGroupInfo maInfo; + sal_Int32 mnGroupType; + + GroupItems(); + GroupItems(const GroupItems&) = delete; + const GroupItems& operator=(const GroupItems&) = delete; + GroupItems(const ScDPNumGroupInfo& rInfo, sal_Int32 nGroupType); + }; + + struct SAL_DLLPRIVATE Field + { + /** + * Optional items for grouped field. + */ + std::unique_ptr<GroupItems> mpGroup; + + /** + * Unique values in the field, stored in ascending order. + */ + ScDPItemDataVec maItems; + + /** + * Original source data represented as indices to the unique value + * list. The order of the data is as they appear in the original + * data source. + */ + IndexArrayType maData; + + sal_uInt32 mnNumFormat; + + Field(); + Field(const Field&) = delete; + const Field& operator=(const Field&) = delete; + }; + + /** + * Interface for connecting to database source. Column index is 0-based. + */ + class DBConnector + { + public: + virtual tools::Long getColumnCount() const = 0; + virtual OUString getColumnLabel(tools::Long nCol) const = 0; + virtual bool first() = 0; + virtual bool next() = 0; + virtual void finish() = 0; + virtual void getValue(tools::Long nCol, ScDPItemData& rData, SvNumFormatType& rNumType) const = 0; + virtual ~DBConnector() {} + }; + +private: + + ScDocument& mrDoc; + SCCOL mnColumnCount; + + /** + * All pivot table objects that references this cache. + */ + mutable ScDPObjectSet maRefObjects; + + typedef std::vector< std::unique_ptr<Field> > FieldsType; + typedef std::vector< std::unique_ptr<GroupItems> > GroupFieldsType; + + FieldsType maFields; + GroupFieldsType maGroupFields; + std::vector<StringSetType> maStringPools; // one for each field. + + std::vector<OUString> maLabelNames; // Stores dimension names and the data layout dimension name at position 0. + EmptyRowsType maEmptyRows; + SCROW mnDataSize; + SCROW mnRowCount; + + bool mbDisposing; + +public: + rtl_uString* InternString( size_t nDim, const OUString& rStr ); + void AddReference(ScDPObject* pObj) const; + void RemoveReference(ScDPObject* pObj) const; + const ScDPObjectSet& GetAllReferences() const; + + SCROW GetIdByItemData(tools::Long nDim, const ScDPItemData& rItem) const; + + static sal_uInt32 GetLocaleIndependentFormat( SvNumberFormatter& rFormatter, sal_uInt32 nNumFormat ); + static OUString GetLocaleIndependentFormattedNumberString( double fValue ); + static OUString GetLocaleIndependentFormattedString( double fValue, SvNumberFormatter& rFormatter, sal_uInt32 nNumFormat ); + OUString GetFormattedString(tools::Long nDim, const ScDPItemData& rItem, bool bLocaleIndependent) const; + SvNumberFormatter* GetNumberFormatter() const; + + tools::Long AppendGroupField(); + void ResetGroupItems(tools::Long nDim, const ScDPNumGroupInfo& rNumInfo, sal_Int32 nGroupType); + SCROW SetGroupItem(tools::Long nDim, const ScDPItemData& rData); + void GetGroupDimMemberIds(tools::Long nDim, std::vector<SCROW>& rIds) const; + void ClearGroupFields(); + void ClearAllFields(); + const ScDPNumGroupInfo* GetNumGroupInfo(tools::Long nDim) const; + + /** + * Return a group type identifier. The values correspond with + * css::sheet::DataPilotFieldGroupBy constant values. + * + * @param nDim 0-based dimension index. + * + * @return group type identifier, or 0 on failure. + */ + sal_Int32 GetGroupType(tools::Long nDim) const; + + SCCOL GetDimensionIndex(std::u16string_view sName) const; + sal_uInt32 GetNumberFormat( tools::Long nDim ) const; + bool IsDateDimension( tools::Long nDim ) const ; + tools::Long GetDimMemberCount(tools::Long nDim) const; + + const IndexArrayType* GetFieldIndexArray( size_t nDim ) const; + const ScDPItemDataVec& GetDimMemberValues( SCCOL nDim ) const; + void InitFromDoc(ScDocument& rDoc, const ScRange& rRange); + bool InitFromDataBase(DBConnector& rDB); + + /** + * Row count is the number of records plus any trailing empty rows in case + * the source data is sheet and contains trailing empty rows. + */ + SCROW GetRowCount() const; + + /** + * Data size is the number of records without any trailing empty rows for + * sheet source data. For any other source type, this should equal the + * row count. + */ + SCROW GetDataSize() const; + SCROW GetItemDataId( sal_uInt16 nDim, SCROW nRow, bool bRepeatIfEmpty ) const; + OUString GetDimensionName(std::vector<OUString>::size_type nDim) const; + bool IsRowEmpty(SCROW nRow) const; + bool ValidQuery(SCROW nRow, const ScQueryParam& rQueryParam) const; + + ScDocument& GetDoc() const; + tools::Long GetColumnCount() const; + + const ScDPItemData* GetItemDataById( tools::Long nDim, SCROW nId ) const; + + size_t GetFieldCount() const; + size_t GetGroupFieldCount() const; + + ScDPCache(const ScDPCache&) = delete; + const ScDPCache& operator=(const ScDPCache&) = delete; + ScDPCache(ScDocument& rDoc); + ~ScDPCache(); + +#if DUMP_PIVOT_TABLE + void Dump() const; +#endif + +private: + void PostInit(); + void Clear(); + const GroupItems* GetGroupItems(tools::Long nDim) const; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/dpdimsave.hxx b/sc/inc/dpdimsave.hxx new file mode 100644 index 0000000000..400d532609 --- /dev/null +++ b/sc/inc/dpdimsave.hxx @@ -0,0 +1,218 @@ +/* -*- 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 <tools/long.hxx> + +#include <vector> +#include <map> +#include <string_view> + +#include "dpitemdata.hxx" +#include "dpnumgroupinfo.hxx" +#include "scdllapi.h" +#include "dptypes.hxx" + +class ScDPGroupTableData; +class ScDPGroupDimension; +class ScDPObject; +class ScDPCache; +class SvNumberFormatter; + +class ScDPSaveGroupDimension; + +/** + * Classes to save Data Pilot settings that create new dimensions (fields). + * These have to be applied before the other ScDPSaveData settings. + */ + +class SC_DLLPUBLIC ScDPSaveGroupItem +{ + OUString aGroupName; ///< name of group + std::vector<OUString> aElements; ///< names of items in original dimension + mutable std::vector<ScDPItemData> maItems; ///< items converted from the strings. + +public: + ScDPSaveGroupItem( OUString aName ); + ~ScDPSaveGroupItem(); + + ScDPSaveGroupItem(ScDPSaveGroupItem const &) = default; + ScDPSaveGroupItem(ScDPSaveGroupItem &&) = default; + ScDPSaveGroupItem & operator =(ScDPSaveGroupItem const &) = default; + ScDPSaveGroupItem & operator =(ScDPSaveGroupItem &&) = default; + + void AddToData(ScDPGroupDimension& rDataDim) const; + + void AddElement( const OUString& rName ); + void AddElementsFromGroup( const ScDPSaveGroupItem& rGroup ); + const OUString& GetGroupName() const { return aGroupName; } + + /// @return true if found (removed) + bool RemoveElement( const OUString& rName ); + + bool IsEmpty() const; + size_t GetElementCount() const; + const OUString* GetElementByIndex(size_t nIndex) const; + + void Rename( const OUString& rNewName ); + + /** remove this group's elements from their groups in rDimension + (rDimension must be a different dimension from the one which contains this)*/ + void RemoveElementsFromGroups( ScDPSaveGroupDimension& rDimension ) const; + + void ConvertElementsToItems(SvNumberFormatter* pFormatter) const; + bool HasInGroup(const ScDPItemData& rItem) const; +}; + +typedef ::std::vector<ScDPSaveGroupItem> ScDPSaveGroupItemVec; + +/** + * Represents a new group dimension whose dimension ID is higher than the + * highest source dimension ID. + */ +class SC_DLLPUBLIC ScDPSaveGroupDimension +{ + OUString aSourceDim; ///< always the real source from the original data + OUString aGroupDimName; + ScDPSaveGroupItemVec aGroups; + mutable ScDPNumGroupInfo aDateInfo; + sal_Int32 nDatePart; + +public: + ScDPSaveGroupDimension( OUString aSource, OUString aName ); + ScDPSaveGroupDimension( OUString aSource, OUString aName, const ScDPNumGroupInfo& rDateInfo, sal_Int32 nPart ); + + void AddToData( ScDPGroupTableData& rData ) const; + void AddToCache(ScDPCache& rCache) const; + void SetDateInfo( const ScDPNumGroupInfo& rInfo, sal_Int32 nPart ); + + void AddGroupItem( const ScDPSaveGroupItem& rItem ); + const OUString& GetGroupDimName() const { return aGroupDimName; } + const OUString& GetSourceDimName() const { return aSourceDim; } + + sal_Int32 GetDatePart() const { return nDatePart; } + const ScDPNumGroupInfo& GetDateInfo() const { return aDateInfo; } + + OUString CreateGroupName( std::u16string_view rPrefix ); + const ScDPSaveGroupItem* GetNamedGroup( const OUString& rGroupName ) const; + ScDPSaveGroupItem* GetNamedGroupAcc( const OUString& rGroupName ); + void RemoveFromGroups( const OUString& rItemName ); + void RemoveGroup(const OUString& rGroupName); + bool IsEmpty() const; + bool HasOnlyHidden(const ScDPUniqueStringSet& rVisible); + + tools::Long GetGroupCount() const; + const ScDPSaveGroupItem& GetGroupByIndex( tools::Long nIndex ) const; + + void Rename( const OUString& rNewName ); + +private: + bool IsInGroup(const ScDPItemData& rItem) const; +}; + +/** + * Represents a group dimension that introduces a new hierarchy for an + * existing dimension. Unlike the ScDPSaveGroupDimension counterpart, it + * re-uses the source dimension name and ID. + */ +class SC_DLLPUBLIC ScDPSaveNumGroupDimension +{ + OUString aDimensionName; + mutable ScDPNumGroupInfo aGroupInfo; + mutable ScDPNumGroupInfo aDateInfo; + sal_Int32 nDatePart; + +public: + ScDPSaveNumGroupDimension( OUString aName, const ScDPNumGroupInfo& rInfo ); + ScDPSaveNumGroupDimension( OUString aName, const ScDPNumGroupInfo& rDateInfo, sal_Int32 nPart ); + + void AddToData( ScDPGroupTableData& rData ) const; + void AddToCache(ScDPCache& rCache) const; + + const OUString& GetDimensionName() const { return aDimensionName; } + const ScDPNumGroupInfo& GetInfo() const { return aGroupInfo; } + + sal_Int32 GetDatePart() const { return nDatePart; } + const ScDPNumGroupInfo& GetDateInfo() const { return aDateInfo; } + + void SetGroupInfo( const ScDPNumGroupInfo& rNew ); + void SetDateInfo( const ScDPNumGroupInfo& rInfo, sal_Int32 nPart ); +}; + +/** + * This class has to do with handling exclusively grouped dimensions? TODO: + * Find out what this class does and document it here. + */ +class SC_DLLPUBLIC ScDPDimensionSaveData +{ +public: + ScDPDimensionSaveData(); + ScDPDimensionSaveData(ScDPDimensionSaveData const &) = default; + + bool operator==( const ScDPDimensionSaveData& r ) const; + + void WriteToData( ScDPGroupTableData& rData ) const; + + void WriteToCache(ScDPCache& rCache) const; + + OUString CreateGroupDimName( + const OUString& rSourceName, const ScDPObject& rObject, bool bAllowSource, + const ::std::vector<OUString>* pDeletedNames ); + + OUString CreateDateGroupDimName( + sal_Int32 nDatePart, const ScDPObject& rObject, bool bAllowSource, + const ::std::vector<OUString>* pDeletedNames ); + + void AddGroupDimension( const ScDPSaveGroupDimension& rGroupDim ); + void ReplaceGroupDimension( const ScDPSaveGroupDimension& rGroupDim ); + void RemoveGroupDimension( const OUString& rGroupDimName ); + + void AddNumGroupDimension( const ScDPSaveNumGroupDimension& rGroupDim ); + void ReplaceNumGroupDimension( const ScDPSaveNumGroupDimension& rGroupDim ); + void RemoveNumGroupDimension( const OUString& rGroupDimName ); + + const ScDPSaveGroupDimension* GetGroupDimForBase( const OUString& rBaseDimName ) const; + const ScDPSaveGroupDimension* GetNamedGroupDim( const OUString& rGroupDimName ) const; + const ScDPSaveGroupDimension* GetFirstNamedGroupDim( const OUString& rBaseDimName ) const; + const ScDPSaveGroupDimension* GetNextNamedGroupDim( const OUString& rGroupDimName ) const; + const ScDPSaveNumGroupDimension* GetNumGroupDim( const OUString& rGroupDimName ) const; + + ScDPSaveGroupDimension* GetGroupDimAccForBase( const OUString& rBaseDimName ); + ScDPSaveGroupDimension* GetNamedGroupDimAcc( const OUString& rGroupDimName ); + ScDPSaveGroupDimension* GetFirstNamedGroupDimAcc( const OUString& rBaseDimName ); + ScDPSaveGroupDimension* GetNextNamedGroupDimAcc( const OUString& rGroupDimName ); + + ScDPSaveNumGroupDimension* GetNumGroupDimAcc( const OUString& rGroupDimName ); + + bool HasGroupDimensions() const; + + sal_Int32 CollectDateParts( const OUString& rBaseDimName ) const; + +private: + typedef ::std::vector< ScDPSaveGroupDimension > ScDPSaveGroupDimVec; + typedef ::std::map<OUString, ScDPSaveNumGroupDimension> ScDPSaveNumGroupDimMap; + + ScDPDimensionSaveData& operator=( const ScDPDimensionSaveData& ) = delete; + + ScDPSaveGroupDimVec maGroupDims; + ScDPSaveNumGroupDimMap maNumGroupDims; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/dpfilteredcache.hxx b/sc/inc/dpfilteredcache.hxx new file mode 100644 index 0000000000..e7737141db --- /dev/null +++ b/sc/inc/dpfilteredcache.hxx @@ -0,0 +1,175 @@ +/* -*- 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 <sal/types.h> +#include "dpitemdata.hxx" +#include "calcmacros.hxx" +#include "types.hxx" + +#include <unordered_set> +#include <vector> + +#include <mdds/flat_segment_tree.hpp> + +namespace com::sun::star::uno +{ +class Any; +} +namespace com::sun::star::uno +{ +template <typename> class Sequence; +} + +class ScDPCache; +struct ScDPValue; +struct ScQueryParam; + +/** + * This class is only a wrapper to the actual cache, to provide filtering on + * the raw data based on the query filter and/or page field filters. + */ +class ScDPFilteredCache +{ + typedef mdds::flat_segment_tree<SCROW, bool> RowFlagType; + +public: + /** interface class used for filtering of rows. */ + class FilterBase + { + public: + virtual ~FilterBase() {} + /** returns true if the matching condition is met for a single cell + value, or false otherwise. */ + virtual bool match(const ScDPItemData& rCellData) const = 0; + + virtual std::vector<ScDPItemData> getMatchValues() const = 0; + }; + + /** ordinary single-item filter. */ + class SingleFilter final : public FilterBase + { + public: + explicit SingleFilter(const ScDPItemData& rItem); + + virtual bool match(const ScDPItemData& rCellData) const override; + virtual std::vector<ScDPItemData> getMatchValues() const override; + + private: + ScDPItemData maItem; + }; + + /** multi-item (group) filter. */ + class GroupFilter final : public FilterBase + { + public: + GroupFilter(); + virtual bool match(const ScDPItemData& rCellData) const override; + virtual std::vector<ScDPItemData> getMatchValues() const override; + void addMatchItem(const ScDPItemData& rItem); + size_t getMatchItemCount() const; + + private: + ::std::vector<ScDPItemData> maItems; + }; + + /** single filtering criterion. */ + struct Criterion + { + sal_Int32 mnFieldIndex; + std::shared_ptr<FilterBase> mpFilter; + + Criterion(); + }; + + ScDPFilteredCache(const ScDPCache& rCache); + ~ScDPFilteredCache(); + + sal_Int32 getRowSize() const; + sal_Int32 getColSize() const; + + const ScDPCache& getCache() const { return mrCache; } + + void fillTable(const ScQueryParam& rQuery, bool bIgnoreEmptyRows, bool bRepeatIfEmpty); + + void fillTable(); + + /** Check whether a specified row is active or not. When a row is active, + it is used in calculation of the results data. A row becomes inactive + when it is filtered out by page field. */ + bool isRowActive(sal_Int32 nRow, sal_Int32* pLastRow = nullptr) const; + + /** Set filter on/off flag to each row to control visibility. The caller + must ensure that the table is filled before calling this function. */ + void filterByPageDimension(const std::vector<Criterion>& rCriteria, + const std::unordered_set<sal_Int32>& rRepeatIfEmptyDims); + + /** Get the cell instance at specified location within the data grid. Note + that the data grid doesn't include the header row. Don't delete the + returned object! */ + const ScDPItemData* getCell(SCCOL nCol, SCROW nRow, bool bRepeatIfEmpty) const; + void getValue(ScDPValue& rVal, SCCOL nCol, SCROW nRow) const; + OUString getFieldName(SCCOL nIndex) const; + + /** Get the unique entries for a field specified by index. The caller must + make sure that the table is filled before calling function, or it will + get an empty collection. */ + const ::std::vector<SCROW>& getFieldEntries(sal_Int32 nColumn) const; + + /** Filter the table based on the specified criteria, and copy the + result to rTabData. This method is used, for example, to generate + a drill-down data table. */ + void filterTable(const std::vector<Criterion>& rCriteria, + css::uno::Sequence<css::uno::Sequence<css::uno::Any>>& rTabData, + const std::unordered_set<sal_Int32>& rRepeatIfEmptyDims); + + void clear(); + bool empty() const; + +#if DUMP_PIVOT_TABLE + static void dumpRowFlag(const RowFlagType& rFlag); + void dump() const; +#endif + +private: + ScDPFilteredCache(const ScDPFilteredCache&) = delete; + + /** + * Check if a given row meets all specified criteria. + * + * @param nRow index of row to be tested. + * @param rCriteria a list of criteria + */ + bool isRowQualified(sal_Int32 nRow, const ::std::vector<Criterion>& rCriteria, + const std::unordered_set<sal_Int32>& rRepeatIfEmptyDims) const; + +private: + /** unique field entries for each field (column). */ + ::std::vector<::std::vector<SCROW>> maFieldEntries; + + /** Rows visible by standard filter query. */ + RowFlagType maShowByFilter; + /** Rows visible by page dimension filtering. */ + RowFlagType maShowByPage; + + const ScDPCache& mrCache; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/dpglobal.hxx b/sc/inc/dpglobal.hxx new file mode 100644 index 0000000000..f311addbf8 --- /dev/null +++ b/sc/inc/dpglobal.hxx @@ -0,0 +1,56 @@ +/* -*- 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 <o3tl/typed_flags_set.hxx> + +enum class PivotFunc { + NONE = 0x0000, + Sum = 0x0001, + Count = 0x0002, + Average = 0x0004, + Median = 0x0008, + Max = 0x0010, + Min = 0x0020, + Product = 0x0040, + CountNum = 0x0080, + StdDev = 0x0100, + StdDevP = 0x0200, + StdVar = 0x0400, + StdVarP = 0x0800, + Auto = 0x1000 +}; +namespace o3tl { + template<> struct typed_flags<PivotFunc> : is_typed_flags<PivotFunc, 0x1fff> {}; +} + +struct ScDPValue +{ + enum Type { Empty = 0, Value, String, Error }; + + double mfValue; + Type meType; + + ScDPValue(); + + void Set( double fV, Type eT ); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/dpgroup.hxx b/sc/inc/dpgroup.hxx new file mode 100644 index 0000000000..4f4efdda39 --- /dev/null +++ b/sc/inc/dpgroup.hxx @@ -0,0 +1,180 @@ +/* -*- 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 <memory> +#include <unordered_set> +#include <vector> + +#include "dptabdat.hxx" +#include "scdllapi.h" +#include "dpitemdata.hxx" +#include "dpnumgroupinfo.hxx" + +class ScDocument; + +typedef ::std::vector<ScDPItemData> ScDPItemDataVec; + +class ScDPGroupItem +{ + ScDPItemData aGroupName; // name of group item + ScDPItemDataVec aElements; // names of items in original dimension + +public: + ScDPGroupItem( const ScDPItemData& rName ); + + void AddElement( const ScDPItemData& rName ); + + const ScDPItemData& GetName() const { return aGroupName; } + bool HasElement( const ScDPItemData& rData ) const; + bool HasCommonElement( const ScDPGroupItem& rOther ) const; + + void FillGroupFilter( ScDPFilteredCache::GroupFilter& rFilter ) const; +}; + +class ScDPGroupDimension +{ + tools::Long nSourceDim; + tools::Long nGroupDim; + OUString aGroupName; + std::vector<ScDPGroupItem> aItems; + mutable std::vector<SCROW> maMemberEntries; + bool mbDateDimension; +public: + ScDPGroupDimension( tools::Long nSource, OUString aNewName ); + ScDPGroupDimension( const ScDPGroupDimension& rOther ); + ~ScDPGroupDimension(); + + ScDPGroupDimension& operator=( const ScDPGroupDimension& rOther ); + + void AddItem( const ScDPGroupItem& rItem ); + void SetGroupDim( tools::Long nDim ); // called from AddGroupDimension + + tools::Long GetSourceDim() const { return nSourceDim; } + tools::Long GetGroupDim() const { return nGroupDim; } + const OUString& GetName() const { return aGroupName; } + + const std::vector< SCROW >& GetColumnEntries( const ScDPFilteredCache& rCacheTable ) const; + const ScDPGroupItem* GetGroupForData( const ScDPItemData& rData ) const; // rData = entry in original dim. + const ScDPGroupItem* GetGroupForName( const ScDPItemData& rName ) const; // rName = entry in group dim. + const ScDPGroupItem* GetGroupByIndex( size_t nIndex ) const; + + void DisposeData(); + + size_t GetItemCount() const { return aItems.size(); } + + void SetDateDimension(); + bool IsDateDimension() const { return mbDateDimension;} +}; + +class SC_DLLPUBLIC ScDPNumGroupDimension +{ + mutable ScDPNumGroupInfo aGroupInfo; // settings + mutable std::vector<SCROW> maMemberEntries; + bool mbDateDimension; + +public: + ScDPNumGroupDimension(); + ScDPNumGroupDimension( const ScDPNumGroupInfo& rInfo ); + ScDPNumGroupDimension( const ScDPNumGroupDimension& rOther ); + ~ScDPNumGroupDimension(); + + ScDPNumGroupDimension& operator=( const ScDPNumGroupDimension& rOther ); + + const ScDPNumGroupInfo& GetInfo() const { return aGroupInfo; } + + const std::vector<SCROW>& GetNumEntries(SCCOL nSourceDim, const ScDPCache* pCache) const; + + void SetDateDimension(); + + void DisposeData(); + + bool IsDateDimension() const { return mbDateDimension;} +}; + +// proxy implementation of ScDPTableData to add grouped items + +class ScDPGroupTableData final : public ScDPTableData +{ + std::shared_ptr<ScDPTableData> pSourceData; + sal_Int32 nSourceCount; + std::vector<ScDPGroupDimension> + aGroups; + std::unique_ptr<ScDPNumGroupDimension[]> + pNumGroups; // array[nSourceCount] + ScDocument* pDoc; + + void FillGroupValues(std::vector<SCROW>& rItems, const std::vector<sal_Int32>& rDims); + virtual sal_Int32 GetSourceDim( sal_Int32 nDim ) override; + + bool IsNumGroupDimension( tools::Long nDimension ) const; + void GetNumGroupInfo(tools::Long nDimension, ScDPNumGroupInfo& rInfo); + + void ModifyFilterCriteria(::std::vector<ScDPFilteredCache::Criterion>& rCriteria); + +public: + // takes ownership of pSource + ScDPGroupTableData( const std::shared_ptr<ScDPTableData>& pSource, ScDocument* pDocument ); + virtual ~ScDPGroupTableData() override; + + const std::shared_ptr<ScDPTableData>& GetSourceTableData() const { return pSourceData;} + + void AddGroupDimension( const ScDPGroupDimension& rGroup ); + void SetNumGroupDimension( sal_Int32 nIndex, const ScDPNumGroupDimension& rGroup ); + sal_Int32 GetDimensionIndex( std::u16string_view rName ); + + virtual sal_Int32 GetColumnCount() override; + virtual sal_Int32 GetMembersCount( sal_Int32 nDim ) override; + virtual const std::vector< SCROW >& GetColumnEntries( sal_Int32 nColumn ) override ; + virtual const ScDPItemData* GetMemberById( sal_Int32 nDim, sal_Int32 nId) override; + virtual sal_Int32 Compare( sal_Int32 nDim, sal_Int32 nDataId1, sal_Int32 nDataId2) override; + + virtual OUString getDimensionName(sal_Int32 nColumn) override; + virtual bool getIsDataLayoutDimension(sal_Int32 nColumn) override; + virtual bool IsDateDimension(sal_Int32 nDim) override; + virtual sal_uInt32 GetNumberFormat(sal_Int32 nDim) override; + virtual void DisposeData() override; + virtual void SetEmptyFlags( bool bIgnoreEmptyRows, bool bRepeatIfEmpty ) override; + + virtual bool IsRepeatIfEmpty() override; + + virtual void CreateCacheTable() override; + virtual void FilterCacheTable(std::vector<ScDPFilteredCache::Criterion>&& rCriteria, std::unordered_set<sal_Int32>&& rDataDims) override; + virtual void GetDrillDownData(std::vector<ScDPFilteredCache::Criterion>&& rCriteria, + std::unordered_set<sal_Int32>&& rCatDims, + css::uno::Sequence< css::uno::Sequence< css::uno::Any > >& rData) override; + virtual void CalcResults(CalcInfo& rInfo, bool bAutoShow) override; + virtual const ScDPFilteredCache& GetCacheTable() const override; + virtual void ReloadCacheTable() override; + + virtual bool IsBaseForGroup(sal_Int32 nDim) const override; + virtual sal_Int32 GetGroupBase(sal_Int32 nGroupDim) const override; + virtual bool IsNumOrDateGroup(sal_Int32 nDim) const override; + virtual bool IsInGroup( const ScDPItemData& rGroupData, sal_Int32 nGroupIndex, + const ScDPItemData& rBaseData, sal_Int32 nBaseIndex ) const override; + virtual bool HasCommonElement( const ScDPItemData& rFirstData, sal_Int32 nFirstIndex, + const ScDPItemData& rSecondData, sal_Int32 nSecondIndex ) const override; + +#if DUMP_PIVOT_TABLE + virtual void Dump() const override; +#endif +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/dpitemdata.hxx b/sc/inc/dpitemdata.hxx new file mode 100644 index 0000000000..8f76264438 --- /dev/null +++ b/sc/inc/dpitemdata.hxx @@ -0,0 +1,98 @@ +/* -*- 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/. + */ + +#pragma once + +#include "scdllapi.h" + +#include <sal/types.h> +#include <rtl/ustring.h> +#include <rtl/ustring.hxx> +#include "calcmacros.hxx" +#include "dpglobal.hxx" + +/** + * When assigning a string value, you can also assign an interned string + * whose life-cycle is managed by the pivot cache that it belongs to. Those + * methods that take a string pointer assume that the string is interned. + * + * <p>Do make sure that an item with an interned string won't persist after + * the pivot cache has been destroyed or reloaded.</p> + */ +class SC_DLLPUBLIC ScDPItemData +{ + friend class ScDPCache; + +public: + enum Type { GroupValue = 0, RangeStart = 1, Value = 2, String = 3, Error = 4, Empty = 5 }; + + static const sal_Int32 DateFirst; + static const sal_Int32 DateLast; + + struct GroupValueAttr + { + sal_Int32 mnGroupType; + sal_Int32 mnValue; + }; + +private: + + union { + rtl_uString* mpString; + GroupValueAttr maGroupValue; + double mfValue; + }; + + sal_uInt8 meType:3; + bool mbStringInterned:1; + + void DisposeString(); + +public: + // case insensitive equality + static sal_Int32 Compare(const ScDPItemData& rA, const ScDPItemData& rB); + + ScDPItemData(); + ScDPItemData(const ScDPItemData& r); + ScDPItemData(const OUString& rStr); + ScDPItemData(sal_Int32 nGroupType, sal_Int32 nValue); + ~ScDPItemData(); + + Type GetType() const { return static_cast<Type>(meType); } + void SetEmpty(); + void SetString(const OUString& rS); + void SetStringInterned( rtl_uString* pS ); + void SetValue(double fVal); + void SetRangeStart(double fVal); + void SetRangeFirst(); + void SetRangeLast(); + void SetErrorStringInterned( rtl_uString* pS ); + bool IsCaseInsEqual(const ScDPItemData& r) const; + + // exact equality + bool operator==(const ScDPItemData& r) const; + bool operator< (const ScDPItemData& r) const; + + ScDPItemData& operator= (const ScDPItemData& r); + + bool IsEmpty() const; + bool IsValue() const; + OUString GetString() const; + double GetValue() const; + GroupValueAttr GetGroupValue() const; + bool HasStringData() const ; + + ScDPValue::Type GetCellType() const; + +#if DEBUG_PIVOT_TABLE + void Dump(const char* msg) const; +#endif +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/dpnumgroupinfo.hxx b/sc/inc/dpnumgroupinfo.hxx new file mode 100644 index 0000000000..170c099de2 --- /dev/null +++ b/sc/inc/dpnumgroupinfo.hxx @@ -0,0 +1,33 @@ +/* -*- 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/. + */ + +#pragma once + +#include "scdllapi.h" +#include "calcmacros.hxx" + +struct ScDPNumGroupInfo +{ + bool mbEnable:1; + bool mbDateValues:1; + bool mbAutoStart:1; + bool mbAutoEnd:1; + bool mbIntegerOnly:1; + double mfStart; + double mfEnd; + double mfStep; + + SC_DLLPUBLIC ScDPNumGroupInfo(); + +#if DUMP_PIVOT_TABLE + void Dump() const; +#endif +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/dpobject.hxx b/sc/inc/dpobject.hxx new file mode 100644 index 0000000000..0e4cf882b5 --- /dev/null +++ b/sc/inc/dpobject.hxx @@ -0,0 +1,457 @@ +/* -*- 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 "scdllapi.h" +#include "global.hxx" +#include "address.hxx" +#include "dpcache.hxx" +#include "dptypes.hxx" +#include "pivot.hxx" +#include "calcmacros.hxx" + +#include <com/sun/star/sheet/DataPilotFieldOrientation.hpp> +#include <o3tl/sorted_vector.hxx> +#include <unotools/resmgr.hxx> + +#include <memory> +#include <vector> +#include <map> + +namespace com::sun::star { + + namespace container { + class XIndexAccess; + class XNameAccess; + } + + namespace sdbc { + class XRowSet; + } + + namespace sheet { + class XMembersAccess; + class XDimensionsSupplier; + struct DataPilotTablePositionData; + struct DataPilotTableHeaderData; + struct DataPilotFieldFilter; + } +} + +namespace tools { class Rectangle; } +class ScDPSaveData; +class ScDPOutput; +struct ScImportSourceDesc; +class ScSheetSourceDesc; +class ScDPTableData; +class ScDPDimensionSaveData; +class ScRangeList; +class ScDPCache; +class ScDocument; + +struct ScDPServiceDesc +{ + OUString aServiceName; + OUString aParSource; + OUString aParName; + OUString aParUser; + OUString aParPass; + + ScDPServiceDesc( OUString aServ, OUString aSrc, OUString aNam, + OUString aUser, OUString aPass ); + + bool operator== ( const ScDPServiceDesc& rOther ) const; +}; + +class SC_DLLPUBLIC ScDPObject +{ +private: + ScDocument* pDoc; + // settings + std::unique_ptr<ScDPSaveData> pSaveData; + OUString aTableName; + OUString aTableTag; + ScRange aOutRange; + std::unique_ptr<ScSheetSourceDesc> pSheetDesc; // for sheet data + std::unique_ptr<ScImportSourceDesc> pImpDesc; // for database data + std::unique_ptr<ScDPServiceDesc> pServDesc; // for external service + std::shared_ptr<ScDPTableData> mpTableData; + // cached data + css::uno::Reference<css::sheet::XDimensionsSupplier> xSource; + std::unique_ptr<ScDPOutput> pOutput; + + // name -> sequence of sequences of css::xml::FastAttribute or css::xml::Attribute + // see PivotTable::putToInteropGrabBag in sc/source/filter/oox/pivottablebuffer.cxx for details + std::map<OUString, css::uno::Any> maInteropGrabBag; + + sal_Int32 nHeaderRows; // page fields plus filter button + bool mbHeaderLayout:1; // true : grid, false : standard + bool bAllowMove:1; + bool bSettingsChanged:1; + bool mbEnableGetPivotData:1; + + SAL_DLLPRIVATE ScDPTableData* GetTableData(); + SAL_DLLPRIVATE void CreateObjects(); + SAL_DLLPRIVATE void CreateOutput(); + SAL_DLLPRIVATE void ClearSource(); + SAL_DLLPRIVATE void FillLabelDataForDimension( + const css::uno::Reference< css::container::XIndexAccess>& xDims, + sal_Int32 nDim, ScDPLabelData& rLabelData); + +public: + ScDPObject(ScDocument* pD); + ScDPObject(const ScDPObject& r); + ~ScDPObject(); + + ScDPObject& operator= (const ScDPObject& r); + + void EnableGetPivotData(bool b); + + void SetAllowMove(bool bSet); + + void InvalidateData(); + void Clear(); + void ClearTableData(); + void ReloadGroupTableData(); + + void Output( const ScAddress& rPos ); + ScRange GetNewOutputRange( bool& rOverflow ); + + ScRange GetOutputRangeByType( sal_Int32 nType ); + ScRange GetOutputRangeByType( sal_Int32 nType ) const; + + void SetSaveData(const ScDPSaveData& rData); + ScDPSaveData* GetSaveData() const { return pSaveData.get(); } + + void SetOutRange(const ScRange& rRange); + const ScRange& GetOutRange() const; + + void SetHeaderLayout(bool bUseGrid); + bool GetHeaderLayout() const { return mbHeaderLayout;} + + void SetSheetDesc(const ScSheetSourceDesc& rDesc); + void SetImportDesc(const ScImportSourceDesc& rDesc); + void SetServiceData(const ScDPServiceDesc& rDesc); + + void WriteSourceDataTo( ScDPObject& rDest ) const; + void WriteTempDataTo( ScDPObject& rDest ) const; + + const ScSheetSourceDesc* GetSheetDesc() const { return pSheetDesc.get(); } + const ScImportSourceDesc* GetImportSourceDesc() const { return pImpDesc.get(); } + const ScDPServiceDesc* GetDPServiceDesc() const { return pServDesc.get(); } + + css::uno::Reference<css::sheet::XDimensionsSupplier> const & GetSource(); + + bool IsSheetData() const; + bool IsImportData() const { return(pImpDesc != nullptr); } + bool IsServiceData() const { return(pServDesc != nullptr); } + + void SetName(const OUString& rNew); + const OUString& GetName() const { return aTableName; } + void SetTag(const OUString& rNew); + const OUString& GetTag() const { return aTableTag; } + + /** + * Data description cell displays the description of a data dimension if + * and only if there is only one data dimension. It's usually located at + * the upper-left corner of the table output. + */ + bool IsDataDescriptionCell(const ScAddress& rPos); + + bool IsDimNameInUse(std::u16string_view rName) const; + OUString GetDimName( tools::Long nDim, bool& rIsDataLayout, sal_Int32* pFlags = nullptr ); + bool IsDuplicated( tools::Long nDim ); + tools::Long GetDimCount(); + void GetHeaderPositionData(const ScAddress& rPos, css::sheet::DataPilotTableHeaderData& rData); + tools::Long GetHeaderDim( const ScAddress& rPos, css::sheet::DataPilotFieldOrientation& rOrient ); + bool GetHeaderDrag( const ScAddress& rPos, bool bMouseLeft, bool bMouseTop, + tools::Long nDragDim, + tools::Rectangle& rPosRect, css::sheet::DataPilotFieldOrientation& rOrient, tools::Long& rDimPos ); + bool IsFilterButton( const ScAddress& rPos ); + + OUString GetFormattedString( std::u16string_view rDimName, const double fValue ); + + double GetPivotData( + const OUString& rDataFieldName, + std::vector<css::sheet::DataPilotFieldFilter>& rFilters); + + bool ParseFilters( + OUString& rDataFieldName, + std::vector<css::sheet::DataPilotFieldFilter>& rFilters, + std::vector<sal_Int16>& rFilterFuncs, + std::u16string_view rFilterList ); + + void GetMemberResultNames(ScDPUniqueStringSet& rNames, tools::Long nDimension); + + void ToggleDetails(const css::sheet::DataPilotTableHeaderData& rElemDesc, ScDPObject* pDestObj); + + void FillOldParam(ScPivotParam& rParam) const; + void FillLabelData(sal_Int32 nDim, ScDPLabelData& Labels); + void FillLabelData(ScPivotParam& rParam); + + void GetFieldIdsNames(css::sheet::DataPilotFieldOrientation nOrient, std::vector<tools::Long>& rIndices, + std::vector<OUString>& rNames); + + bool GetHierarchiesNA( sal_Int32 nDim, css::uno::Reference< css::container::XNameAccess >& xHiers ); + void GetHierarchies( sal_Int32 nDim, css::uno::Sequence< OUString >& rHiers ); + + sal_Int32 GetUsedHierarchy( sal_Int32 nDim ); + + bool GetMembersNA( sal_Int32 nDim, css::uno::Reference< css::sheet::XMembersAccess >& xMembers ); + bool GetMembersNA( sal_Int32 nDim, sal_Int32 nHier, css::uno::Reference< css::sheet::XMembersAccess >& xMembers ); + + bool GetMemberNames( sal_Int32 nDim, css::uno::Sequence< OUString >& rNames ); + bool GetMembers( sal_Int32 nDim, sal_Int32 nHier, ::std::vector<ScDPLabelData::Member>& rMembers ); + + void UpdateReference( UpdateRefMode eUpdateRefMode, + const ScRange& r, SCCOL nDx, SCROW nDy, SCTAB nDz ); + bool RefsEqual( const ScDPObject& r ) const; + void WriteRefsTo( ScDPObject& r ) const; + + void GetPositionData(const ScAddress& rPos, css::sheet::DataPilotTablePositionData& rPosData); + + bool GetDataFieldPositionData(const ScAddress& rPos, + css::uno::Sequence< + css::sheet::DataPilotFieldFilter >& rFilters); + + void GetDrillDownData(const ScAddress& rPos, + css::uno::Sequence< css::uno::Sequence< css::uno::Any > >& rTableData); + + // apply drop-down attribute, initialize nHeaderRows, without accessing the source + // (button attribute must be present) + void RefreshAfterLoad(); + + void BuildAllDimensionMembers(); + + /** + * Remove in the save data entries for members that don't exist anymore. + * This is called during pivot table refresh. + */ + bool SyncAllDimensionMembers(); + + static bool HasRegisteredSources(); + static std::vector<OUString> GetRegisteredSources(); + static css::uno::Reference<css::sheet::XDimensionsSupplier> + CreateSource( const ScDPServiceDesc& rDesc ); + + static void ConvertOrientation( + ScDPSaveData& rSaveData, + const ScPivotFieldVector& rFields, css::sheet::DataPilotFieldOrientation nOrient, + const css::uno::Reference< css::sheet::XDimensionsSupplier>& xSource, + const ScDPLabelDataVector& rLabels, + const ScPivotFieldVector* pRefColFields = nullptr, + const ScPivotFieldVector* pRefRowFields = nullptr, + const ScPivotFieldVector* pRefPageFields = nullptr ); + + static bool IsOrientationAllowed( css::sheet::DataPilotFieldOrientation nOrient, sal_Int32 nDimFlags ); + + void PutInteropGrabBag(std::map<OUString, css::uno::Any>&& val) + { + maInteropGrabBag = std::move(val); + } + std::pair<bool, css::uno::Any> GetInteropGrabBagValue(const OUString& sName) const + { + if (const auto it = maInteropGrabBag.find(sName); it != maInteropGrabBag.end()) + return { true, it->second }; + + return { false, css::uno::Any() }; + } + +#if DUMP_PIVOT_TABLE + void Dump() const; + void DumpCache() const; +#endif +}; + +class ScDPCollection +{ + friend class ScDPCache; +public: + + /** + * Stores and manages all caches from internal sheets. + */ + class SheetCaches + { + friend class ScDPCollection; + typedef std::map<size_t, std::unique_ptr<ScDPCache>> CachesType; + typedef std::vector<ScRange> RangeIndexType; + CachesType m_Caches; + RangeIndexType maRanges; + ScDocument& mrDoc; + public: + SheetCaches(ScDocument& rDoc); + bool hasCache(const ScRange& rRange) const; + const ScDPCache* getCache(const ScRange& rRange, const ScDPDimensionSaveData* pDimData); + SC_DLLPUBLIC size_t size() const; + + void updateReference( + UpdateRefMode eMode, const ScRange& r, SCCOL nDx, SCROW nDy, SCTAB nDz); + + SC_DLLPUBLIC ScDPCache* getExistingCache(const ScRange& rRange); + SC_DLLPUBLIC const ScDPCache* getExistingCache(const ScRange& rRange) const; + + void updateCache(const ScRange& rRange, o3tl::sorted_vector<ScDPObject*>& rRefs); + bool remove(const ScDPCache* p); + + SC_DLLPUBLIC const std::vector<ScRange>& getAllRanges() const; + }; + + /** + * Data caches for range name based source data. + */ + class NameCaches + { + friend class ScDPCollection; + typedef ::std::map<OUString, std::unique_ptr<ScDPCache>> CachesType; + CachesType m_Caches; + ScDocument& mrDoc; + public: + NameCaches(ScDocument& rDoc); + bool hasCache(const OUString& rName) const; + const ScDPCache* getCache( + const OUString& rName, const ScRange& rRange, const ScDPDimensionSaveData* pDimData); + size_t size() const; + private: + ScDPCache* getExistingCache(const OUString& rName); + + void updateCache( + const OUString& rName, const ScRange& rRange, o3tl::sorted_vector<ScDPObject*>& rRefs); + bool remove(const ScDPCache* p); + }; + + /** + * Defines connection type to external data source. Used as a key to look + * up database cache. + */ + struct DBType + { + sal_Int32 mnSdbType; + OUString maDBName; + OUString maCommand; + DBType(sal_Int32 nSdbType, OUString aDBName, OUString aCommand); + + struct less + { + bool operator() (const DBType& left, const DBType& right) const; + }; + }; + + /** + * Data caches for external database sources. + */ + class DBCaches + { + friend class ScDPCollection; + typedef ::std::map<DBType, std::unique_ptr<ScDPCache>, DBType::less> CachesType; + CachesType m_Caches; + ScDocument& mrDoc; + public: + DBCaches(ScDocument& rDoc); + bool hasCache(sal_Int32 nSdbType, const OUString& rDBName, const OUString& rCommand) const; + const ScDPCache* getCache( + sal_Int32 nSdbType, const OUString& rDBName, const OUString& rCommand, + const ScDPDimensionSaveData* pDimData); + + private: + ScDPCache* getExistingCache( + sal_Int32 nSdbType, const OUString& rDBName, const OUString& rCommand); + + static css::uno::Reference<css::sdbc::XRowSet> createRowSet( + sal_Int32 nSdbType, const OUString& rDBName, const OUString& rCommand); + + void updateCache( + sal_Int32 nSdbType, const OUString& rDBName, const OUString& rCommand, + o3tl::sorted_vector<ScDPObject*>& rRefs); + bool remove(const ScDPCache* p); + }; + + ScDPCollection(ScDocument& rDocument); + ScDPCollection(const ScDPCollection& r); + ~ScDPCollection(); + + TranslateId ReloadCache(const ScDPObject* pDPObj, o3tl::sorted_vector<ScDPObject*>& rRefs); + bool ReloadGroupsInCache(const ScDPObject* pDPObj, o3tl::sorted_vector<ScDPObject*>& rRefs); + SC_DLLPUBLIC bool GetReferenceGroups(const ScDPObject& rDPObj, const ScDPDimensionSaveData** pGroups) const; + + SC_DLLPUBLIC size_t GetCount() const; + SC_DLLPUBLIC ScDPObject& operator[](size_t nIndex); + SC_DLLPUBLIC const ScDPObject& operator[](size_t nIndex) const; + + ScDPObject* GetByName(std::u16string_view rName) const; + + void DeleteOnTab( SCTAB nTab ); + void UpdateReference( UpdateRefMode eUpdateRefMode, + const ScRange& r, SCCOL nDx, SCROW nDy, SCTAB nDz ); + void CopyToTab( SCTAB nOld, SCTAB nNew ); + bool RefsEqual( const ScDPCollection& r ) const; + void WriteRefsTo( ScDPCollection& r ) const; + + /** + * Create a new name that's not yet used by any existing data pilot + * objects. All data pilot names are 'DataPilot' + <num> + * + * @return new name for data pilot object. + */ + OUString CreateNewName() const; + + void FreeTable(const ScDPObject* pDPObj); + SC_DLLPUBLIC ScDPObject* InsertNewTable(std::unique_ptr<ScDPObject> pDPObj); + SC_DLLPUBLIC bool HasTable(const ScDPObject* pDPObj) const; + + SC_DLLPUBLIC SheetCaches& GetSheetCaches(); + SC_DLLPUBLIC const SheetCaches& GetSheetCaches() const; + NameCaches& GetNameCaches(); + SC_DLLPUBLIC const NameCaches& GetNameCaches() const; + DBCaches& GetDBCaches(); + SC_DLLPUBLIC const DBCaches& GetDBCaches() const; + + ScRangeList GetAllTableRanges( SCTAB nTab ) const; + bool IntersectsTableByColumns( SCCOL nCol1, SCCOL nCol2, SCROW nRow, SCTAB nTab ) const; + bool IntersectsTableByRows( SCCOL nCol, SCROW nRow1, SCROW nRow2, SCTAB nTab ) const; + bool HasTable( const ScRange& rRange ) const; + +#if DEBUG_PIVOT_TABLE + void DumpTables() const; +#endif + +private: + /** Only to be called from ScDPCache::RemoveReference(). */ + void RemoveCache(const ScDPCache* pCache); + + void GetAllTables(const ScRange& rSrcRange, o3tl::sorted_vector<ScDPObject*>& rRefs) const; + void GetAllTables(std::u16string_view rSrcName, o3tl::sorted_vector<ScDPObject*>& rRefs) const; + void GetAllTables( + sal_Int32 nSdbType, std::u16string_view rDBName, std::u16string_view rCommand, + o3tl::sorted_vector<ScDPObject*>& rRefs) const; + +private: + typedef std::vector< std::unique_ptr<ScDPObject> > TablesType; + + ScDocument& mrDoc; + TablesType maTables; + SheetCaches maSheetCaches; + NameCaches maNameCaches; + DBCaches maDBCaches; +}; + +bool operator<(const ScDPCollection::DBType& left, const ScDPCollection::DBType& right); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/dpoutput.hxx b/sc/inc/dpoutput.hxx new file mode 100644 index 0000000000..94decfa444 --- /dev/null +++ b/sc/inc/dpoutput.hxx @@ -0,0 +1,146 @@ +/* -*- 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/sheet/DataPilotOutputRangeType.hpp> +#include <com/sun/star/sheet/DataPilotFieldOrientation.hpp> +#include <com/sun/star/uno/Sequence.hxx> + +#include <tools/long.hxx> + +#include "address.hxx" + +#include "dptypes.hxx" + +#include <memory> +#include <vector> + +namespace com::sun::star::sheet { + struct DataPilotFieldFilter; + struct DataPilotTablePositionData; + struct DataResult; + struct MemberResult; + class XDimensionsSupplier; +} +namespace tools { class Rectangle; } +class ScDocument; +struct ScDPOutLevelData; + +class ScDPOutput +{ +private: + ScDocument* pDoc; + css::uno::Reference< css::sheet::XDimensionsSupplier> xSource; + ScAddress aStartPos; + std::vector<ScDPOutLevelData> pColFields; + std::vector<ScDPOutLevelData> pRowFields; + std::vector<ScDPOutLevelData> pPageFields; + css::uno::Sequence< css::uno::Sequence< css::sheet::DataResult> > aData; + OUString aDataDescription; + + // Number format related parameters + std::unique_ptr<sal_uInt32[]> + pColNumFmt; + std::unique_ptr<sal_uInt32[]> + pRowNumFmt; + std::vector<bool> aRowCompactFlags; + sal_Int32 nColFmtCount; + sal_Int32 nRowFmtCount; + sal_uInt32 nSingleNumFmt; + size_t nRowDims; // Including empty ones. + + // Output geometry related parameters + sal_Int32 nColCount; + sal_Int32 nRowCount; + sal_Int32 nHeaderSize; + SCCOL nTabStartCol; + SCROW nTabStartRow; + SCCOL nMemberStartCol; + SCROW nMemberStartRow; + SCCOL nDataStartCol; + SCROW nDataStartRow; + SCCOL nTabEndCol; + SCROW nTabEndRow; + bool bDoFilter:1; + bool bResultsError:1; + bool bSizesValid:1; + bool bSizeOverflow:1; + bool mbHeaderLayout:1; // true : grid, false : standard + bool mbHasCompactRowField:1; // true: at least one of the row fields has compact layout. + bool mbExpandCollapse:1; // true: show expand/collapse buttons + + void DataCell( SCCOL nCol, SCROW nRow, SCTAB nTab, + const css::sheet::DataResult& rData ); + void HeaderCell( SCCOL nCol, SCROW nRow, SCTAB nTab, + const css::sheet::MemberResult& rData, + bool bColHeader, tools::Long nLevel ); + + void FieldCell(SCCOL nCol, SCROW nRow, SCTAB nTab, const ScDPOutLevelData& rData, bool bInTable); + void MultiFieldCell(SCCOL nCol, SCROW nRow, SCTAB nTab, bool bRowField); + + /// Computes number of columns needed to write row fields. + SCCOL GetColumnsForRowFields() const; + void CalcSizes(); + + /** Query which sub-area of the table the cell is in. See + css.sheet.DataPilotTablePositionType for the interpretation of the + return value. */ + sal_Int32 GetPositionType(const ScAddress& rPos); + /// Returns the range of row fields that are contained by table's row fields column nCol. + void GetRowFieldRange(SCCOL nCol, sal_Int32& nRowFieldStart, sal_Int32& nRowFieldEnd) const; + /// Find row field index from row position in case of compact layout. + sal_Int32 GetRowFieldCompact(SCCOL nColQuery, SCROW nRowQuery) const; + +public: + ScDPOutput( ScDocument* pD, + css::uno::Reference< css::sheet::XDimensionsSupplier> xSrc, + const ScAddress& rPos, bool bFilter, bool bExpandCollapse ); + ~ScDPOutput(); + + void SetPosition( const ScAddress& rPos ); + + void Output(); //! Refresh? + ScRange GetOutputRange( sal_Int32 nRegionType = css::sheet::DataPilotOutputRangeType::WHOLE ); + sal_Int32 GetHeaderRows() const; + bool HasError(); // range overflow or exception from source + + void GetPositionData(const ScAddress& rPos, css::sheet::DataPilotTablePositionData& rPosData); + + /** Get filtering criteria based on the position of the cell within data + field region. */ + bool GetDataResultPositionData(::std::vector< css::sheet::DataPilotFieldFilter >& rFilters, const ScAddress& rPos); + + tools::Long GetHeaderDim( const ScAddress& rPos, css::sheet::DataPilotFieldOrientation& rOrient ); + bool GetHeaderDrag( + const ScAddress& rPos, bool bMouseLeft, bool bMouseTop, tools::Long nDragDim, + tools::Rectangle& rPosRect, css::sheet::DataPilotFieldOrientation& rOrient, tools::Long& rDimPos ); + bool IsFilterButton( const ScAddress& rPos ); + + void GetMemberResultNames(ScDPUniqueStringSet& rNames, tools::Long nDimension); + + void SetHeaderLayout(bool bUseGrid); + bool GetHeaderLayout() const { return mbHeaderLayout;} + + static void GetDataDimensionNames( + OUString& rSourceName, OUString& rGivenName, + const css::uno::Reference< css::uno::XInterface>& xDim ); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/dpoutputgeometry.hxx b/sc/inc/dpoutputgeometry.hxx new file mode 100644 index 0000000000..bf6c4377a3 --- /dev/null +++ b/sc/inc/dpoutputgeometry.hxx @@ -0,0 +1,67 @@ +/* -*- 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 "address.hxx" +#include <vector> + +class SC_DLLPUBLIC ScDPOutputGeometry +{ +public: + enum FieldType { Column = 0, Row, Page, Data, None }; + + ScDPOutputGeometry() = delete; + ScDPOutputGeometry(const ScRange& rOutRange, bool bShowFilter); + + /** + * @param nCount number of row fields. + */ + void setRowFieldCount(sal_uInt32 nCount); + void setColumnFieldCount(sal_uInt32 nCount); + void setPageFieldCount(sal_uInt32 nCount); + void setDataFieldCount(sal_uInt32 nCount); + void setDataLayoutType(FieldType eType); + void setHeaderLayout(bool bHeaderLayout); + void setCompactMode(bool bCompactMode); + + void getColumnFieldPositions(::std::vector<ScAddress>& rAddrs) const; + void getRowFieldPositions(::std::vector<ScAddress>& rAddrs) const; + void getPageFieldPositions(::std::vector<ScAddress>& rAddrs) const; + + SCROW getRowFieldHeaderRow() const; + + std::pair<FieldType, size_t> getFieldButtonType(const ScAddress& rPos) const; + +private: + void adjustFieldsForDataLayout(sal_uInt32& rColumnFields, sal_uInt32& rRowFields) const; + +private: + ScRange maOutRange; + sal_uInt32 mnRowFields; /// number of row fields + sal_uInt32 mnColumnFields; + sal_uInt32 mnPageFields; + sal_uInt32 mnDataFields; + FieldType meDataLayoutType; + bool mbShowFilter; + bool mbHeaderLayout; + bool mbCompactMode; // MSO only setting +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/dpresfilter.hxx b/sc/inc/dpresfilter.hxx new file mode 100644 index 0000000000..ff8d28de93 --- /dev/null +++ b/sc/inc/dpresfilter.hxx @@ -0,0 +1,140 @@ +/* -*- 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/. + */ + +#pragma once + +#include <rtl/ustring.hxx> +#include "calcmacros.hxx" + +#include <memory> +#include <map> +#include <vector> +#include <unordered_map> + +namespace com::sun::star::uno +{ +template <typename> class Sequence; +} +namespace com::sun::star::sheet +{ +struct DataPilotFieldFilter; +} + +struct ScDPResultFilter +{ + OUString maDimName; + OUString maValueName; + OUString maValue; + + bool mbHasValue : 1; + bool mbDataLayout : 1; + + ScDPResultFilter(OUString aDimName, bool bDataLayout); +}; + +/** + * This class maintains pivot table calculation result in a tree structure + * which represents the logical structure of pivot table result layout as + * presented in the sheet. + * + * <p>The root node has two child nodes if the pivot table consists of both + * column and row dimensions. The first child stores the result tree that is + * first filtered by row dimensions then by column dimensions. The second + * child stores the result tree that is filtered by column dimensions only + * (for column grand totals).</p> + * + * <p>If the pivot table layout only consists of either column or row + * dimensions, the root node only has one child node.</p> + */ +class ScDPResultTree +{ +public: + typedef std::vector<double> ValuesType; + +private: + struct MemberNode; + typedef std::map<OUString, std::shared_ptr<MemberNode>> MembersType; + + struct DimensionNode + { + MembersType maChildMembersValueNames; + MembersType maChildMembersValues; + +#if DEBUG_PIVOT_TABLE + void dump(int nLevel) const; +#endif + }; + + struct MemberNode + { + ValuesType maValues; + std::map<OUString, DimensionNode> maChildDimensions; + + MemberNode(); + MemberNode(const MemberNode&) = delete; + const MemberNode& operator=(const MemberNode&) = delete; + ~MemberNode(); + +#if DEBUG_PIVOT_TABLE + void dump(int nLevel) const; +#endif + }; + + typedef std::pair<OUString, OUString> NamePairType; + + struct NamePairHash + { + size_t operator()(const NamePairType& rPair) const; + }; + typedef std::unordered_map<NamePairType, double, NamePairHash> LeafValuesType; + LeafValuesType maLeafValues; + + OUString maPrimaryDimName; + std::unique_ptr<MemberNode> mpRoot; + +public: + ScDPResultTree(); + ScDPResultTree(const ScDPResultTree&) = delete; + const ScDPResultTree& operator=(const ScDPResultTree&) = delete; + ~ScDPResultTree(); + /** + * Add a single value filter path. The filters are expected to be sorted + * by row dimension order then by column dimension order. + * + * @param rFilter set of filters. + * @param fVal result value, as displayed in the table output. + */ + void add(const std::vector<ScDPResultFilter>& rFilter, double fVal); + + void swap(ScDPResultTree& rOther); + + bool empty() const; + void clear(); + + const ValuesType* + getResults(const css::uno::Sequence<css::sheet::DataPilotFieldFilter>& rFilters) const; + + double getLeafResult(const css::sheet::DataPilotFieldFilter& rFilter) const; + +#if DEBUG_PIVOT_TABLE + void dump() const; +#endif +}; + +struct ScDPResultFilterContext +{ + ScDPResultTree maFilterSet; + std::vector<ScDPResultFilter> maFilters; + sal_Int32 mnCol; + sal_Int32 mnRow; + + ScDPResultFilterContext(); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/dpsave.hxx b/sc/inc/dpsave.hxx new file mode 100644 index 0000000000..f5d50db97d --- /dev/null +++ b/sc/inc/dpsave.hxx @@ -0,0 +1,394 @@ +/* -*- 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 <memory> +#include <vector> + +#include <com/sun/star/sheet/DataPilotFieldOrientation.hpp> +#include <rtl/ustring.hxx> +#include <sal/types.h> +#include <tools/long.hxx> + +#include "scdllapi.h" +#include "calcmacros.hxx" + +#include <unordered_map> +#include <unordered_set> +#include <optional> + +namespace com::sun::star::sheet { + class XDimensionsSupplier; + struct DataPilotFieldReference; + struct DataPilotFieldSortInfo; + struct DataPilotFieldAutoShowInfo; + struct DataPilotFieldLayoutInfo; +} + +class ScDPDimensionSaveData; +class ScDPTableData; +enum class ScGeneralFunction; + +// classes to save Data Pilot settings + +class ScDPSaveMember +{ +private: + OUString aName; + std::optional<OUString> mpLayoutName; // custom name to be displayed in the table. + sal_uInt16 nVisibleMode; + sal_uInt16 nShowDetailsMode; + +public: + ScDPSaveMember(OUString aName); + ScDPSaveMember(const ScDPSaveMember& r); + ~ScDPSaveMember(); + + bool operator== ( const ScDPSaveMember& r ) const; + + const OUString& GetName() const + { return aName; } + + SC_DLLPUBLIC bool HasIsVisible() const; + SC_DLLPUBLIC void SetIsVisible(bool bSet); + bool GetIsVisible() const + { return bool(nVisibleMode); } + + SC_DLLPUBLIC bool HasShowDetails() const; + SC_DLLPUBLIC void SetShowDetails(bool bSet); + bool GetShowDetails() const + { return bool(nShowDetailsMode); } + + void SetName( const OUString& rNew ); // used if the source member was renamed (groups) + + SC_DLLPUBLIC void SetLayoutName( const OUString& rName ); + SC_DLLPUBLIC const std::optional<OUString> & GetLayoutName() const; + void RemoveLayoutName(); + + void WriteToSource( const css::uno::Reference<css::uno::XInterface>& xMember, + sal_Int32 nPosition ); + +#if DUMP_PIVOT_TABLE + void Dump(int nIndent = 0) const; +#endif +}; + +class SC_DLLPUBLIC ScDPSaveDimension +{ +private: + OUString aName; + std::optional<OUString> mpLayoutName; + std::optional<OUString> mpSubtotalName; + bool bIsDataLayout; + bool bDupFlag; + css::sheet::DataPilotFieldOrientation nOrientation; + ScGeneralFunction nFunction; // for data dimensions + tools::Long nUsedHierarchy; + sal_uInt16 nShowEmptyMode; //! at level + bool bRepeatItemLabels; //! at level + bool bSubTotalDefault; //! at level + std::vector<ScGeneralFunction> maSubTotalFuncs; + std::unique_ptr<css::sheet::DataPilotFieldReference> pReferenceValue; + std::unique_ptr<css::sheet::DataPilotFieldSortInfo> pSortInfo; // (level) + std::unique_ptr<css::sheet::DataPilotFieldAutoShowInfo> pAutoShowInfo; // (level) + std::unique_ptr<css::sheet::DataPilotFieldLayoutInfo> pLayoutInfo; // (level) + +public: + typedef std::unordered_set<OUString> MemberSetType; + typedef std::vector<ScDPSaveMember*> MemberList; + +private: + std::unordered_map<OUString, std::unique_ptr<ScDPSaveMember>> maMemberHash; + MemberList maMemberList; + +public: + ScDPSaveDimension(OUString aName, bool bDataLayout); + ScDPSaveDimension(const ScDPSaveDimension& r); + ~ScDPSaveDimension(); + + bool operator== ( const ScDPSaveDimension& r ) const; + + const MemberList& GetMembers() const + { return maMemberList; } + + void AddMember(std::unique_ptr<ScDPSaveMember> pMember); + + void SetDupFlag(bool bSet) + { bDupFlag = bSet; } + + bool GetDupFlag() const + { return bDupFlag; } + + const OUString& GetName() const + { return aName; } + + bool IsDataLayout() const + { return bIsDataLayout; } + + void SetName( const OUString& rNew ); // used if the source dim was renamed (groups) + + void SetOrientation(css::sheet::DataPilotFieldOrientation nNew); + void SetSubTotals(std::vector<ScGeneralFunction> && rFuncs); + tools::Long GetSubTotalsCount() const + { return maSubTotalFuncs.size(); } + + ScGeneralFunction GetSubTotalFunc(tools::Long nIndex) const + { return maSubTotalFuncs[nIndex]; } + + bool HasShowEmpty() const; + void SetShowEmpty(bool bSet); + bool GetShowEmpty() const + { return bool(nShowEmptyMode); } + + void SetRepeatItemLabels(bool bSet); + bool GetRepeatItemLabels() const + { return bRepeatItemLabels; } + + void SetFunction(ScGeneralFunction nNew); + ScGeneralFunction GetFunction() const + { return nFunction; } + + void SetUsedHierarchy(tools::Long nNew); + tools::Long GetUsedHierarchy() const + { return nUsedHierarchy; } + + void SetLayoutName(const OUString& rName); + const std::optional<OUString> & GetLayoutName() const; + void RemoveLayoutName(); + void SetSubtotalName(const OUString& rName); + const std::optional<OUString> & GetSubtotalName() const; + void RemoveSubtotalName(); + + bool IsMemberNameInUse(const OUString& rName) const; + + const css::sheet::DataPilotFieldReference* GetReferenceValue() const + { return pReferenceValue.get(); } + + void SetReferenceValue(const css::sheet::DataPilotFieldReference* pNew); + + const css::sheet::DataPilotFieldSortInfo* GetSortInfo() const + { return pSortInfo.get(); } + + void SetSortInfo(const css::sheet::DataPilotFieldSortInfo* pNew); + const css::sheet::DataPilotFieldAutoShowInfo* GetAutoShowInfo() const + { return pAutoShowInfo.get(); } + + void SetAutoShowInfo(const css::sheet::DataPilotFieldAutoShowInfo* pNew); + const css::sheet::DataPilotFieldLayoutInfo* GetLayoutInfo() const + { return pLayoutInfo.get(); } + + void SetLayoutInfo(const css::sheet::DataPilotFieldLayoutInfo* pNew); + + void SetCurrentPage( const OUString* pPage ); // NULL = no selection (all) + OUString GetCurrentPage() const; // only for ODF compatibility + + css::sheet::DataPilotFieldOrientation GetOrientation() const + { return nOrientation; } + + ScDPSaveMember* GetExistingMemberByName(const OUString& rName); + + /** + * Get a member object by its name. If one doesn't exist, create a new + * object and return it. This class manages the life cycle of all member + * objects belonging to it, so <i>don't delete the returned instance.</i> + * + * @param rName member name + * + * @return pointer to the member object. + */ + ScDPSaveMember* GetMemberByName(const OUString& rName); + + void SetMemberPosition( const OUString& rName, sal_Int32 nNewPos ); + + void WriteToSource( const css::uno::Reference<css::uno::XInterface>& xDim ); + + void UpdateMemberVisibility(const std::unordered_map< OUString, bool>& rData); + + bool HasInvisibleMember() const; + + void RemoveObsoleteMembers(const MemberSetType& rMembers); + +#if DUMP_PIVOT_TABLE + void Dump(int nIndent = 0) const; +#endif +}; + +class ScDPSaveData +{ + typedef std::unordered_map<OUString, size_t> DupNameCountType; +public: + typedef std::unordered_map<OUString, size_t> DimOrderType; + typedef std::vector<std::unique_ptr<ScDPSaveDimension>> DimsType; + +private: + DimsType m_DimList; + DupNameCountType maDupNameCounts; /// keep track of number of duplicates in each name. + std::unique_ptr<ScDPDimensionSaveData> pDimensionData; // settings that create new dimensions + sal_uInt16 nColumnGrandMode; + sal_uInt16 nRowGrandMode; + sal_uInt16 nIgnoreEmptyMode; + sal_uInt16 nRepeatEmptyMode; + bool bFilterButton; // not passed to DataPilotSource + bool bDrillDown; // not passed to DataPilotSource + bool bExpandCollapse; // not passed to DataPilotSource + + /** if true, all dimensions already have all of their member instances + * created. */ + bool mbDimensionMembersBuilt; + + std::optional<OUString> mpGrandTotalName; + mutable std::unique_ptr<DimOrderType> mpDimOrder; // dimension order for row and column dimensions, to traverse result tree. + +public: + SC_DLLPUBLIC ScDPSaveData(); + ScDPSaveData(const ScDPSaveData& r); + SC_DLLPUBLIC ~ScDPSaveData(); + + ScDPSaveData& operator= ( const ScDPSaveData& r ); + + bool operator== ( const ScDPSaveData& r ) const; + + SC_DLLPUBLIC void SetGrandTotalName(const OUString& rName); + SC_DLLPUBLIC const std::optional<OUString> & GetGrandTotalName() const; + + const DimsType& GetDimensions() const { return m_DimList; } + + /** + * Get sort order map to sort row and column dimensions in order of + * appearance. Row dimensions get sorted before column dimensions. This + * is used to traverse result tree, which is structured following this + * order. + */ + const DimOrderType& GetDimensionSortOrder() const; + + /** + * Get all dimensions in a given orientation. The order represents the + * actual order of occurrence. The returned list also includes data + * layout dimension. + * + * @param eOrientation orientation + * @param rDims (out) list of dimensions for specified orientation + */ + SC_DLLPUBLIC void GetAllDimensionsByOrientation( + css::sheet::DataPilotFieldOrientation eOrientation, + std::vector<const ScDPSaveDimension*>& rDims) const; + + void AddDimension(ScDPSaveDimension* pDim); + + /** + * Get a dimension object by its name. <i>If one doesn't exist for the + * given name, it creates a new one.</i> + * + * @param rName dimension name + * + * @return pointer to the dimension object. The ScDPSaveData instance + * manages its life cycle; hence the caller must + * <i>not</i> delete this object. + */ + SC_DLLPUBLIC ScDPSaveDimension* GetDimensionByName(const OUString& rName); + SC_DLLPUBLIC ScDPSaveDimension* GetDataLayoutDimension(); + SC_DLLPUBLIC ScDPSaveDimension* GetExistingDataLayoutDimension() const; + + ScDPSaveDimension* DuplicateDimension(std::u16string_view rName); + SC_DLLPUBLIC ScDPSaveDimension& DuplicateDimension(const ScDPSaveDimension& rDim); + + SC_DLLPUBLIC ScDPSaveDimension* GetExistingDimensionByName(std::u16string_view rName) const; + SC_DLLPUBLIC ScDPSaveDimension* GetNewDimensionByName(const OUString& rName); + + void RemoveDimensionByName(const OUString& rName); + + ScDPSaveDimension* GetInnermostDimension(css::sheet::DataPilotFieldOrientation nOrientation); + ScDPSaveDimension* GetFirstDimension(css::sheet::DataPilotFieldOrientation eOrientation); + SC_DLLPUBLIC tools::Long GetDataDimensionCount() const; + + void SetPosition( ScDPSaveDimension* pDim, tools::Long nNew ); + SC_DLLPUBLIC void SetColumnGrand( bool bSet ); + bool GetColumnGrand() const + { return bool(nColumnGrandMode); } + + SC_DLLPUBLIC void SetRowGrand( bool bSet ); + bool GetRowGrand() const + { return bool(nRowGrandMode); } + + SC_DLLPUBLIC void SetIgnoreEmptyRows( bool bSet ); + bool GetIgnoreEmptyRows() const + { return bool(nIgnoreEmptyMode); } + + SC_DLLPUBLIC void SetRepeatIfEmpty( bool bSet ); + bool GetRepeatIfEmpty() const + { return bool(nRepeatEmptyMode); } + + SC_DLLPUBLIC void SetFilterButton( bool bSet ); + bool GetFilterButton() const + { return bFilterButton; } + + SC_DLLPUBLIC void SetDrillDown( bool bSet ); + bool GetDrillDown() const + { return bDrillDown; } + + SC_DLLPUBLIC void SetExpandCollapse( bool bSet ); + bool GetExpandCollapse() const + { return bExpandCollapse; } + + void WriteToSource( const css::uno::Reference<css::sheet::XDimensionsSupplier>& xSource ); + bool IsEmpty() const; + + const ScDPDimensionSaveData* GetExistingDimensionData() const + { return pDimensionData.get(); } + + void RemoveAllGroupDimensions( const OUString& rSrcDimName, std::vector<OUString>* pDeletedNames = nullptr ); + + SC_DLLPUBLIC ScDPDimensionSaveData* GetDimensionData(); // create if not there + SC_DLLPUBLIC void SetDimensionData( const ScDPDimensionSaveData* pNew ); // copied + void BuildAllDimensionMembers(ScDPTableData* pData); + void SyncAllDimensionMembers(ScDPTableData* pData); + + /** + * Check whether a dimension has one or more invisible members. + * + * @param rDimName dimension name + */ + SC_DLLPUBLIC bool HasInvisibleMember(std::u16string_view rDimName) const; + +#if DUMP_PIVOT_TABLE + void Dump() const; +#endif + +private: + void CheckDuplicateName(ScDPSaveDimension& rDim); + void RemoveDuplicateNameCount(const OUString& rName); + + /** + * Append a new original dimension. Not to be called to insert a duplicate + * dimension. + * + * @param rName Dimension name. The name must be the original dimension + * name; not a duplicate dimension name. + * @param bDataLayout true if this is a data layout dimension, false + * otherwise. + * + * @return pointer to the new dimension just inserted. + */ + ScDPSaveDimension* AppendNewDimension(const OUString& rName, bool bDataLayout); + + void DimensionsChanged(); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/dpsdbtab.hxx b/sc/inc/dpsdbtab.hxx new file mode 100644 index 0000000000..599e832e1b --- /dev/null +++ b/sc/inc/dpsdbtab.hxx @@ -0,0 +1,86 @@ +/* -*- 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 "dptabdat.hxx" + +#include <com/sun/star/sheet/DataImportMode.hpp> + +#include <unordered_set> +#include <vector> + +class ScDocument; +class ScDPCache; +class ScDPDimensionSaveData; + +struct ScImportSourceDesc +{ + OUString aDBName; + OUString aObject; + css::sheet::DataImportMode nType; + bool bNative; + ScDocument* mpDoc; + + ScImportSourceDesc(ScDocument* pDoc) : nType(css::sheet::DataImportMode_NONE), bNative(false), mpDoc(pDoc) {} + + bool operator== ( const ScImportSourceDesc& rOther ) const + { return aDBName == rOther.aDBName && + aObject == rOther.aObject && + nType == rOther.nType && + bNative == rOther.bNative && + mpDoc == rOther.mpDoc; } + + sal_Int32 GetCommandType() const; + const ScDPCache* CreateCache(const ScDPDimensionSaveData* pDimData) const; +}; + +/** + * This class represents source data from database source. + */ +class ScDatabaseDPData final : public ScDPTableData +{ +private: + ScDPFilteredCache aCacheTable; +public: + ScDatabaseDPData(const ScDocument* pDoc, const ScDPCache& rCache); + virtual ~ScDatabaseDPData() override; + + virtual sal_Int32 GetColumnCount() override; + virtual OUString getDimensionName(sal_Int32 nColumn) override; + virtual bool getIsDataLayoutDimension(sal_Int32 nColumn) override; + virtual bool IsDateDimension(sal_Int32 nDim) override; + virtual void DisposeData() override; + virtual void SetEmptyFlags( bool bIgnoreEmptyRows, bool bRepeatIfEmpty ) override; + + virtual void CreateCacheTable() override; + virtual void FilterCacheTable(std::vector<ScDPFilteredCache::Criterion>&& rCriteria, std::unordered_set<sal_Int32>&& rDataDims) override; + virtual void GetDrillDownData(std::vector<ScDPFilteredCache::Criterion>&& rCriteria, + std::unordered_set<sal_Int32>&& rCatDims, + css::uno::Sequence< css::uno::Sequence< css::uno::Any > >& rData) override; + virtual void CalcResults(CalcInfo& rInfo, bool bAutoShow) override; + virtual const ScDPFilteredCache& GetCacheTable() const override; + virtual void ReloadCacheTable() override; + +#if DUMP_PIVOT_TABLE + virtual void Dump() const override; +#endif +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/dpshttab.hxx b/sc/inc/dpshttab.hxx new file mode 100644 index 0000000000..3299771b42 --- /dev/null +++ b/sc/inc/dpshttab.hxx @@ -0,0 +1,123 @@ +/* -*- 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 "dptabdat.hxx" +#include "address.hxx" +#include "scdllapi.h" +#include "queryparam.hxx" +#include <unotools/resmgr.hxx> + +#include <unordered_set> +#include <vector> + +class ScDPDimensionSaveData; + +/** + * This class contains authoritative information on the internal reference + * used as the data source for datapilot table. <i>The range name takes + * precedence over the source range when it's non-empty.</i> When the range + * name is empty, the source range gets used. + */ +class ScSheetSourceDesc +{ +public: + ScSheetSourceDesc() = delete; + + SC_DLLPUBLIC ScSheetSourceDesc(ScDocument* pDoc); + + SC_DLLPUBLIC void SetSourceRange(const ScRange& rRange); + + /** + * Get the range that contains the source data. In case the source data + * is referred to via a range name, it returns the range that the range + * name points to. + * + * <i>Note that currently only a single range is supported; if the + * range name contains multiple ranges, only the first range is used.</i> + * + * @return source range. + */ + SC_DLLPUBLIC const ScRange& GetSourceRange() const; + SC_DLLPUBLIC void SetRangeName(const OUString& rName); + const OUString& GetRangeName() const { return maRangeName;} + bool HasRangeName() const; + void SetQueryParam(const ScQueryParam& rParam); + const ScQueryParam& GetQueryParam() const { return maQueryParam;} + + bool operator== ( const ScSheetSourceDesc& rOther ) const; + SC_DLLPUBLIC const ScDPCache* CreateCache(const ScDPDimensionSaveData* pDimData) const; + + /** + * Check the sanity of the data source range. + * + * @return nullptr if the source range is sane, otherwise an error message ID is + * returned. + */ + TranslateId CheckSourceRange() const; + +private: + mutable ScRange maSourceRange; + OUString maRangeName; + ScQueryParam maQueryParam; + ScDocument* mpDoc; +}; + +/** + * Implementation of ScDPTableData with sheet data. + */ +class SC_DLLPUBLIC ScSheetDPData final : public ScDPTableData +{ +private: + ScQueryParam aQuery; + bool bIgnoreEmptyRows; + bool bRepeatIfEmpty; + + ScDPFilteredCache aCacheTable; + +public: + ScSheetDPData(const ScDocument* pD, const ScSheetSourceDesc& rDesc, const ScDPCache& rCache); + virtual ~ScSheetDPData() override; + + virtual sal_Int32 GetColumnCount() override; + virtual OUString getDimensionName(sal_Int32 nColumn) override; + virtual bool getIsDataLayoutDimension(sal_Int32 nColumn) override; + virtual bool IsDateDimension(sal_Int32 nDim) override; + virtual sal_uInt32 GetNumberFormat(sal_Int32 nDim) override; + virtual void DisposeData() override; + virtual void SetEmptyFlags( bool bIgnoreEmptyRows, bool bRepeatIfEmpty ) override; + + virtual bool IsRepeatIfEmpty() override; + + virtual void CreateCacheTable() override; + virtual void FilterCacheTable(std::vector<ScDPFilteredCache::Criterion>&& rCriteria, std::unordered_set<sal_Int32>&& rCatDims) override; + virtual void GetDrillDownData(std::vector<ScDPFilteredCache::Criterion>&& rCriteria, + std::unordered_set<sal_Int32>&& rCatDims, + css::uno::Sequence< css::uno::Sequence< css::uno::Any > >& rData) override; + virtual void CalcResults(CalcInfo& rInfo, bool bAutoShow) override; + virtual const ScDPFilteredCache& GetCacheTable() const override; + virtual void ReloadCacheTable() override; + +#if DUMP_PIVOT_TABLE + virtual void Dump() const override; +#endif +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/dptabdat.hxx b/sc/inc/dptabdat.hxx new file mode 100644 index 0000000000..4f1a463795 --- /dev/null +++ b/sc/inc/dptabdat.hxx @@ -0,0 +1,159 @@ +/* -*- 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 "dpfilteredcache.hxx" +#include "calcmacros.hxx" + +#include <svl/zforlist.hxx> +#include <tools/long.hxx> + +#include <unordered_set> +#include <vector> + +#define SC_DAPI_HIERARCHY_FLAT 0 +#define SC_DAPI_HIERARCHY_QUARTER 1 +#define SC_DAPI_HIERARCHY_WEEK 2 + +#define SC_DAPI_FLAT_LEVELS 1 // single level for flat dates +#define SC_DAPI_QUARTER_LEVELS 4 // levels in year/quarter/month/day hierarchy +#define SC_DAPI_WEEK_LEVELS 3 // levels in year/week/day hierarchy + +#define SC_DAPI_LEVEL_YEAR 0 +#define SC_DAPI_LEVEL_QUARTER 1 +#define SC_DAPI_LEVEL_MONTH 2 +#define SC_DAPI_LEVEL_DAY 3 +#define SC_DAPI_LEVEL_WEEK 4 +#define SC_DAPI_LEVEL_WEEKDAY 5 + +class ScDPResultMember; +class ScDPDimension; +class ScDPLevel; +class ScDPInitState; +class ScDocument; + +/** + * Base class that abstracts different data source types of a datapilot + * table. + */ +class SC_DLLPUBLIC ScDPTableData +{ + // cached data for GetDatePart + tools::Long nLastDateVal; + tools::Long nLastHier; + tools::Long nLastLevel; + tools::Long nLastRet; + const ScDocument* mpDoc; +public: + + /** This structure stores dimension information used when calculating + results. These data are read only during result calculation, so it + should be passed as a const instance. */ + struct SAL_DLLPRIVATE CalcInfo + { + ::std::vector<sal_Int32> aColLevelDims; + ::std::vector<ScDPDimension*> aColDims; + ::std::vector<ScDPLevel*> aColLevels; + ::std::vector<sal_Int32> aRowLevelDims; + ::std::vector<ScDPDimension*> aRowDims; + ::std::vector<ScDPLevel*> aRowLevels; + ::std::vector<sal_Int32> aPageDims; + ::std::vector<sal_Int32> aDataSrcCols; + + ScDPInitState* pInitState; + ScDPResultMember* pColRoot; + ScDPResultMember* pRowRoot; + + CalcInfo(); + }; + + ScDPTableData(const ScDPTableData&) = delete; + const ScDPTableData& operator=(const ScDPTableData&) = delete; + ScDPTableData(const ScDocument* pDoc); + virtual ~ScDPTableData(); + + OUString GetFormattedString(sal_Int32 nDim, const ScDPItemData& rItem, bool bLocaleIndependent) const; + + tools::Long GetDatePart( tools::Long nDateVal, tools::Long nHierarchy, tools::Long nLevel ); + + //! use (new) typed collection instead of ScStrCollection + //! or separate Str and ValueCollection + + virtual sal_Int32 GetColumnCount() = 0; + virtual const std::vector< SCROW >& GetColumnEntries( sal_Int32 nColumn ) ; + virtual OUString getDimensionName(sal_Int32 nColumn) = 0; + virtual bool getIsDataLayoutDimension(sal_Int32 nColumn) = 0; + virtual bool IsDateDimension(sal_Int32 nDim) = 0; + virtual sal_uInt32 GetNumberFormat(sal_Int32 nDim); + sal_uInt32 GetNumberFormatByIdx( NfIndexTableOffset ); + virtual void DisposeData() = 0; + virtual void SetEmptyFlags( bool bIgnoreEmptyRows, bool bRepeatIfEmpty ) = 0; + + virtual bool IsRepeatIfEmpty(); + + virtual void CreateCacheTable() = 0; + virtual void FilterCacheTable(std::vector<ScDPFilteredCache::Criterion>&& rCriteria, std::unordered_set<sal_Int32>&& rDataDims) = 0; + virtual void GetDrillDownData(std::vector<ScDPFilteredCache::Criterion>&& rCriteria, + std::unordered_set<sal_Int32>&& rCatDims, + css::uno::Sequence< css::uno::Sequence< css::uno::Any > >& rData) = 0; + virtual void CalcResults(CalcInfo& rInfo, bool bAutoShow) = 0; + virtual const ScDPFilteredCache& GetCacheTable() const = 0; + virtual void ReloadCacheTable() = 0; + + // override in ScDPGroupTableData: + virtual bool IsBaseForGroup(sal_Int32 nDim) const; + virtual sal_Int32 GetGroupBase(sal_Int32 nGroupDim) const; + virtual bool IsNumOrDateGroup(sal_Int32 nDim) const; + virtual bool IsInGroup( const ScDPItemData& rGroupData, sal_Int32 nGroupIndex, + const ScDPItemData& rBaseData, sal_Int32 nBaseIndex ) const; + virtual bool HasCommonElement( const ScDPItemData& rFirstData, sal_Int32 nFirstIndex, + const ScDPItemData& rSecondData, sal_Int32 nSecondIndex ) const; + + virtual sal_Int32 GetMembersCount( sal_Int32 nDim ); + const ScDPItemData* GetMemberByIndex( sal_Int32 nDim, sal_Int32 nIndex ); + virtual const ScDPItemData* GetMemberById( sal_Int32 nDim, sal_Int32 nId); + virtual sal_Int32 GetSourceDim( sal_Int32 nDim ); + virtual sal_Int32 Compare( sal_Int32 nDim, sal_Int32 nDataId1, sal_Int32 nDataId2); + +#if DUMP_PIVOT_TABLE + virtual void Dump() const; +#endif + +protected: + /** This structure stores vector arrays that hold intermediate data for + each row during cache table iteration. */ + struct CalcRowData + { + ::std::vector< SCROW > aColData; + ::std::vector< SCROW > aRowData; + ::std::vector< SCROW > aPageData; + ::std::vector<ScDPValue> aValues; + }; + + void FillRowDataFromCacheTable(sal_Int32 nRow, const ScDPFilteredCache& rCacheTable, const CalcInfo& rInfo, CalcRowData& rData); + static void ProcessRowData(CalcInfo& rInfo, const CalcRowData& rData, bool bAutoShow); + void CalcResultsFromCacheTable(const ScDPFilteredCache& rCacheTable, CalcInfo& rInfo, bool bAutoShow); + +private: + void GetItemData(const ScDPFilteredCache& rCacheTable, sal_Int32 nRow, + const ::std::vector<sal_Int32>& rDims, ::std::vector< SCROW >& rItemData); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/dptabres.hxx b/sc/inc/dptabres.hxx new file mode 100644 index 0000000000..3c92fa3887 --- /dev/null +++ b/sc/inc/dptabres.hxx @@ -0,0 +1,669 @@ +/* -*- 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 "global.hxx" +#include "dpfilteredcache.hxx" +#include "calcmacros.hxx" +#include "dpitemdata.hxx" +#include "subtotal.hxx" + +#include <com/sun/star/sheet/DataPilotFieldOrientation.hpp> +#include <com/sun/star/sheet/DataPilotFieldReference.hpp> + +#include <map> +#include <unordered_map> +#include <unordered_set> +#include <memory> +#include <vector> + +namespace com::sun::star::sheet { struct DataResult; } +namespace com::sun::star::sheet { struct MemberResult; } +namespace com::sun::star::uno { template <typename > class Sequence; } + +class ScDPSource; +class ScDPDimension; +class ScDPLevel; +class ScDPMember; +class ScDPResultMember; +class ScDPResultVisibilityData; + +struct ScDPValue; +struct ScDPResultFilterContext; + +/** + * Member names that are being processed for InitFrom/LateInitFrom (needed + * for initialization of grouped items). + */ +class ScDPInitState +{ +public: + struct Member + { + tools::Long mnSrcIndex; + SCROW mnNameIndex; + + Member(tools::Long nSrcIndex, SCROW nNameIndex); + }; + + void AddMember(tools::Long nSourceIndex, SCROW nMember); + void RemoveMember(); + + const std::vector<Member>& GetMembers() const { return maMembers; } + +private: + std::vector<Member> maMembers; +}; + +typedef ::std::vector<sal_Int32> ScMemberSortOrder; + +/** + * Select subtotal information, passed down the dimensions. + */ +struct ScDPSubTotalState +{ + ScSubTotalFunc eColForce; + ScSubTotalFunc eRowForce; + tools::Long nColSubTotalFunc; + tools::Long nRowSubTotalFunc; + + ScDPSubTotalState() : + eColForce( SUBTOTAL_FUNC_NONE ), + eRowForce( SUBTOTAL_FUNC_NONE ), + nColSubTotalFunc( -1 ), + nRowSubTotalFunc( -1 ) + {} +}; + +/** + * indexes when calculating running totals + * + * Col/RowVisible: simple counts from 0 - without sort order applied + * - visible index (only used for running total / relative index) + * + * Col/RowSorted: with sort order applied - member index (used otherwise - + * so other members' children can be accessed). + */ +class ScDPRunningTotalState +{ +public: + typedef std::vector<sal_Int32> IndexArray; /// array of sal_Int32 terminated by -1. + + ScDPRunningTotalState( ScDPResultMember* pColRoot, ScDPResultMember* pRowRoot ); + + ScDPResultMember* GetColResRoot() const { return pColResRoot; } + ScDPResultMember* GetRowResRoot() const { return pRowResRoot; } + + const IndexArray& GetColVisible() const { return maColVisible;} + const IndexArray& GetColSorted() const { return maColSorted;} + const IndexArray& GetRowVisible() const { return maRowVisible;} + const IndexArray& GetRowSorted() const { return maRowSorted;} + + void AddColIndex( sal_Int32 nVisible, tools::Long nSorted ); + void AddRowIndex( sal_Int32 nVisible, tools::Long nSorted ); + void RemoveColIndex(); + void RemoveRowIndex(); + +private: + ScDPResultMember* pColResRoot; + ScDPResultMember* pRowResRoot; + + mutable IndexArray maColVisible; + mutable IndexArray maColSorted; + mutable IndexArray maRowVisible; + mutable IndexArray maRowSorted; +}; + +struct ScDPRelativePos +{ + tools::Long nBasePos; // simple count, without sort order applied + tools::Long nDirection; + + ScDPRelativePos( tools::Long nBase, tools::Long nDir ); +}; + +// aggregated data +//! separate header file? + +// Possible values for the nCount member: +// (greater than 0 counts the collected values) +const sal_Int64 SC_DPAGG_EMPTY = 0; // empty during data collection +const sal_Int64 SC_DPAGG_DATA_ERROR = -1; // error during data collection +const sal_Int64 SC_DPAGG_RESULT_EMPTY = -2; // empty result calculated +const sal_Int64 SC_DPAGG_RESULT_VALID = -3; // valid result calculated +const sal_Int64 SC_DPAGG_RESULT_ERROR = -4; // error in calculated result + +class ScDPAggData +{ +private: + WelfordRunner maWelford; + double fVal; + double fAux; + sal_Int64 nCount; + std::unique_ptr<ScDPAggData> pChild; + std::vector<double> mSortedValues; + +public: + ScDPAggData() : fVal(0.0), fAux(0.0), nCount(SC_DPAGG_EMPTY) {} + + void Update( const ScDPValue& rNext, ScSubTotalFunc eFunc, const ScDPSubTotalState& rSubState ); + void Calculate( ScSubTotalFunc eFunc, const ScDPSubTotalState& rSubState ); + bool IsCalculated() const; + + double GetResult() const; + bool HasError() const; + bool HasData() const; + + void SetResult( double fNew ); + void SetEmpty( bool bSet ); + void SetError(); + + double GetAuxiliary() const; + void SetAuxiliary( double fNew ); + + void Reset(); // also deletes children + + const ScDPAggData* GetExistingChild() const { return pChild.get(); } + ScDPAggData* GetChild(); + +#if DUMP_PIVOT_TABLE + void Dump(int nIndent) const; +#endif +}; + +// Row and grand total state, passed down (column total is at result member) + +class ScDPRowTotals +{ + ScDPAggData aRowTotal; + ScDPAggData aGrandTotal; + bool bIsInColRoot; + +public: + ScDPRowTotals(); + ~ScDPRowTotals(); + + ScDPAggData* GetRowTotal( tools::Long nMeasure ); + ScDPAggData* GetGrandTotal( tools::Long nMeasure ); + + bool IsInColRoot() const { return bIsInColRoot; } + void SetInColRoot(bool bSet) { bIsInColRoot = bSet; } +}; + +// results for a hierarchy dimension + +class ScDPResultDimension; +class ScDPDataDimension; +class ScDPDataMember; + +#define SC_DPMEASURE_ALL -1 +#define SC_DPMEASURE_ANY -2 + +struct ScDPParentDimData +{ + const SCROW mnOrder; //! Ref + const ScDPDimension* mpParentDim; //! Ref + const ScDPLevel* mpParentLevel; //! Ref + const ScDPMember* mpMemberDesc; //! Ref + + ScDPParentDimData(); + ScDPParentDimData(SCROW nIndex, const ScDPDimension* pDim, const ScDPLevel* pLev, const ScDPMember* pMember); +}; + +class ResultMembers final +{ + std::unordered_map<SCROW, ScDPParentDimData> maMemberHash; + bool mbHasHideDetailsMember; +public: + const ScDPParentDimData* FindMember( SCROW nIndex ) const; + void InsertMember( ScDPParentDimData const & rNew ); + bool IsHasHideDetailsMembers() const { return mbHasHideDetailsMember; } + void SetHasHideDetailsMembers( bool b ) { mbHasHideDetailsMember = b; } + ResultMembers(); + ~ResultMembers(); +}; + +class LateInitParams +{ +private: + const ::std::vector<ScDPDimension*>& mppDim; + const ::std::vector<ScDPLevel*>& mppLev; + + bool mbRow:1; + bool mbInitChild:1; + bool mbAllChildren:1; +public: + LateInitParams( const ::std::vector<ScDPDimension*>& ppDim, const ::std::vector<ScDPLevel*>& ppLev, + bool bRow); + + void SetInitChild( bool b ) { mbInitChild = b; } + void SetInitAllChildren( bool b ) { mbAllChildren = b; } + + ScDPDimension* GetDim( size_t nPos ) const { return mppDim[nPos];} + ScDPLevel* GetLevel( size_t nPos ) const { return mppLev[nPos];} + + bool GetInitChild() const {return mbInitChild; } + bool GetInitAllChild() const { return mbAllChildren; } + bool IsRow() const { return mbRow; } + bool IsEnd( size_t nPos ) const ; +}; + +/** + * The term 'measure' here roughly equals "data dimension" ? + */ +class ScDPResultData +{ + ScDPSource& mrSource; + //! keep things like measure lists here + + std::vector<ScSubTotalFunc> maMeasureFuncs; + std::vector<css::sheet::DataPilotFieldReference> maMeasureRefs; + std::vector<css::sheet::DataPilotFieldOrientation> maMeasureRefOrients; + std::vector<OUString> maMeasureNames; + + bool bLateInit:1; + bool bDataAtCol:1; + bool bDataAtRow:1; + + //! add "displayed values" settings + mutable std::vector<std::unique_ptr<ResultMembers>> maDimMembers; +public: + ScDPResultData( ScDPSource& rSrc ); + ~ScDPResultData(); + + void SetMeasureData( + std::vector<ScSubTotalFunc>& rFunctions, + std::vector<css::sheet::DataPilotFieldReference>& rRefs, + std::vector<css::sheet::DataPilotFieldOrientation>& rRefOrient, + std::vector<OUString>& rNames ); + + void SetDataLayoutOrientation( css::sheet::DataPilotFieldOrientation nOrient ); + void SetLateInit( bool bSet ); + + tools::Long GetMeasureCount() const { return maMeasureFuncs.size(); } + ScSubTotalFunc GetMeasureFunction(tools::Long nMeasure) const; + OUString GetMeasureString(tools::Long nMeasure, bool bForce, ScSubTotalFunc eForceFunc, bool& rbTotalResult) const; + OUString GetMeasureDimensionName(tools::Long nMeasure) const; + const css::sheet::DataPilotFieldReference& GetMeasureRefVal(tools::Long nMeasure) const; + css::sheet::DataPilotFieldOrientation GetMeasureRefOrient(tools::Long nMeasure) const; + + bool IsLateInit() const { return bLateInit; } + + tools::Long GetColStartMeasure() const; + tools::Long GetRowStartMeasure() const; + + tools::Long GetCountForMeasure( tools::Long nMeas ) const { return (nMeas == SC_DPMEASURE_ALL) ? maMeasureFuncs.size() : 1; } + + bool IsBaseForGroup( tools::Long nDim ) const; // any group + tools::Long GetGroupBase( tools::Long nGroupDim ) const; + bool IsNumOrDateGroup( tools::Long nDim ) const; + bool IsInGroup( SCROW nGroupDataId, tools::Long nGroupIndex, + const ScDPItemData& rBaseData, tools::Long nBaseIndex ) const; + bool HasCommonElement( SCROW nFirstDataId, tools::Long nFirstIndex, + const ScDPItemData& rSecondData, tools::Long nSecondIndex ) const; + + ResultMembers& GetDimResultMembers(tools::Long nDim, const ScDPDimension* pDim, ScDPLevel* pLevel) const; + + const ScDPSource& GetSource() const { return mrSource;} +}; + +class ScDPResultMember +{ +private: + const ScDPResultData* pResultData; + ScDPParentDimData aParentDimData; + std::unique_ptr<ScDPResultDimension> pChildDimension; + std::unique_ptr<ScDPDataMember> pDataRoot; + bool bHasElements:1; + bool bForceSubTotal:1; + bool bHasHiddenDetails:1; + bool bInitialized:1; + bool bAutoHidden:1; + ScDPAggData aColTotal; // to store column totals + + sal_uInt16 nMemberStep; // step to show details +public: + ScDPResultMember( + const ScDPResultData* pData, const ScDPParentDimData& rParentDimData ); //! Ref + ScDPResultMember( const ScDPResultData* pData, bool bForceSub ); + ~ScDPResultMember(); + + void InitFrom( const ::std::vector<ScDPDimension*>& ppDim, + const ::std::vector<ScDPLevel*>& ppLev, + size_t nPos, + ScDPInitState& rInitState, + bool bInitChild = true ); + void LateInitFrom( + LateInitParams& rParams, + const ::std::vector< SCROW >& pItemData, + size_t nPos, + ScDPInitState& rInitState); + void CheckShowEmpty( bool bShow = false ); + OUString GetName() const; + OUString GetDisplayName( bool bLocaleIndependent ) const; + + ScDPItemData FillItemData() const; + bool IsValid() const; + bool IsVisible() const; + tools::Long GetSize(tools::Long nMeasure) const; + // bHasHiddenDetails is set only if the "show details" flag is off, + // and there was a child dimension to skip + bool HasHiddenDetails() const { return bHasHiddenDetails; } + bool IsSubTotalInTitle(tools::Long nMeasure) const; + + tools::Long GetSubTotalCount( tools::Long* pUserSubStart = nullptr ) const; + + bool IsNamedItem( SCROW nIndex ) const; + bool IsValidEntry( const ::std::vector< SCROW >& aMembers ) const; + + void SetHasElements() { bHasElements = true; } + void SetAutoHidden() { bAutoHidden = true; } + + void ProcessData( const ::std::vector<SCROW>& aChildMembers, + const ScDPResultDimension* pDataDim, + const ::std::vector<SCROW>& aDataMembers, + const ::std::vector<ScDPValue>& aValues ); + void FillMemberResults( + css::uno::Sequence< css::sheet::MemberResult>* pSequences, + tools::Long& rPos, tools::Long nMeasure, bool bRoot, const OUString* pMemberName, const OUString* pMemberCaption ); + + void FillDataResults( + const ScDPResultMember* pRefMember, + ScDPResultFilterContext& rFilterCxt, + css::uno::Sequence< css::uno::Sequence< css::sheet::DataResult> >& rSequence, + tools::Long nMeasure) const; + + void UpdateDataResults( const ScDPResultMember* pRefMember, tools::Long nMeasure ) const; + void UpdateRunningTotals( const ScDPResultMember* pRefMember, tools::Long nMeasure, + ScDPRunningTotalState& rRunning, ScDPRowTotals& rTotals ) const; + + void SortMembers( ScDPResultMember* pRefMember ); + void DoAutoShow( ScDPResultMember* pRefMember ); + + void ResetResults(); + +#if DUMP_PIVOT_TABLE + void DumpState( const ScDPResultMember* pRefMember, ScDocument* pDoc, ScAddress& rPos ) const; + + void Dump(int nIndent) const; +#endif + + //! this will be removed! + const ScDPResultDimension* GetChildDimension() const { return pChildDimension.get(); } + ScDPResultDimension* GetChildDimension() { return pChildDimension.get(); } + + ScDPDataMember* GetDataRoot() const { return pDataRoot.get(); } + + const ScDPDimension* GetParentDim() const { return aParentDimData.mpParentDim; } //! Ref + const ScDPLevel* GetParentLevel() const { return aParentDimData.mpParentLevel; } //! Ref + const ScDPMember* GetDPMember()const { return aParentDimData.mpMemberDesc; } //! Ref + SCROW GetOrder() const { return aParentDimData.mnOrder; } //! Ref + bool IsRoot() const { return GetParentLevel() == nullptr; } + SCROW GetDataId( ) const ; + ScDPAggData* GetColTotal( tools::Long nMeasure ) const; + + void FillVisibilityData(ScDPResultVisibilityData& rData) const; +}; + +class ScDPDataMember +{ +private: + const ScDPResultData* pResultData; + const ScDPResultMember* pResultMember; //! Ref? + std::unique_ptr<ScDPDataDimension> + pChildDimension; + ScDPAggData aAggregate; + + void UpdateValues( const ::std::vector<ScDPValue>& aValues, const ScDPSubTotalState& rSubState ); + +public: + ScDPDataMember( const ScDPResultData* pData, const ScDPResultMember* pRes ); + ~ScDPDataMember(); + + void InitFrom( const ScDPResultDimension* pDim ); + + OUString GetName() const; + bool IsVisible() const; + bool HasData( tools::Long nMeasure, const ScDPSubTotalState& rSubState ) const; + + bool IsNamedItem( SCROW nRow ) const; + bool HasHiddenDetails() const; + + void ProcessData( const ::std::vector< SCROW >& aChildMembers, const ::std::vector<ScDPValue>& aValues, + const ScDPSubTotalState& rSubState ); + bool HasError( tools::Long nMeasure, const ScDPSubTotalState& rSubState ) const; + double GetAggregate( tools::Long nMeasure, const ScDPSubTotalState& rSubState ) const; + const ScDPAggData* GetConstAggData( tools::Long nMeasure, const ScDPSubTotalState& rSubState ) const; + ScDPAggData* GetAggData( tools::Long nMeasure, const ScDPSubTotalState& rSubState ); + + void FillDataRow( + const ScDPResultMember* pRefMember, + ScDPResultFilterContext& rFilterCxt, + css::uno::Sequence<css::sheet::DataResult>& rSequence, + tools::Long nMeasure, bool bIsSubTotalRow, + const ScDPSubTotalState& rSubState) const; + + void UpdateDataRow( const ScDPResultMember* pRefMember, tools::Long nMeasure, bool bIsSubTotalRow, + const ScDPSubTotalState& rSubState ); + void UpdateRunningTotals( const ScDPResultMember* pRefMember, tools::Long nMeasure, bool bIsSubTotalRow, + const ScDPSubTotalState& rSubState, ScDPRunningTotalState& rRunning, + ScDPRowTotals& rTotals, const ScDPResultMember& rRowParent ); + + void SortMembers( ScDPResultMember* pRefMember ); + void DoAutoShow( ScDPResultMember* pRefMember ); + + void ResetResults(); + +#if DUMP_PIVOT_TABLE + void DumpState( const ScDPResultMember* pRefMember, ScDocument* pDoc, ScAddress& rPos ) const; + void Dump(int nIndent) const; +#endif + + //! this will be removed! + const ScDPDataDimension* GetChildDimension() const { return pChildDimension.get(); } + ScDPDataDimension* GetChildDimension() { return pChildDimension.get(); } +}; + +// result dimension contains only members + +class ScDPResultDimension +{ +public: + typedef std::vector<std::unique_ptr<ScDPResultMember>> MemberArray; + typedef std::map<SCROW, ScDPResultMember*> MemberHash; +private: + const ScDPResultData* pResultData; + MemberArray maMemberArray; + MemberHash maMemberHash; + OUString aDimensionName; //! or ptr to IntDimension? + tools::Long nSortMeasure; + ScMemberSortOrder aMemberOrder; // used when sorted by measure + bool bIsDataLayout:1; //! or ptr to IntDimension? + bool bSortByData:1; + bool bSortAscending:1; + bool bAutoShow:1; + bool bAutoTopItems:1; + bool bInitialized:1; + tools::Long nAutoMeasure; + tools::Long nAutoCount; + + ScDPResultMember* FindMember( SCROW iData ) const; + ScDPResultMember* AddMember( const ScDPParentDimData& aData ); + ScDPResultMember* InsertMember( const ScDPParentDimData* pMemberData ); + void InitWithMembers( LateInitParams& rParams, + const ::std::vector< SCROW >& pItemData, + size_t nPos, + ScDPInitState& rInitState ); +public: + ScDPResultDimension( const ScDPResultData* pData ); + ~ScDPResultDimension(); + + // allocates new members + void InitFrom( + const ::std::vector<ScDPDimension*>& ppDim, const ::std::vector<ScDPLevel*>& ppLev, + size_t nPos, ScDPInitState& rInitState, bool bInitChild = true ); + void LateInitFrom( LateInitParams& rParams, + const ::std::vector< SCROW >& pItemData, + size_t nPos, + ScDPInitState& rInitState ); + void CheckShowEmpty( bool bShow = false ); + + tools::Long GetSize(tools::Long nMeasure) const; + + bool IsValidEntry( const ::std::vector<SCROW>& aMembers ) const; + + // modifies existing members, allocates data dimensions + void ProcessData( const ::std::vector<SCROW>& aMembers, + const ScDPResultDimension* pDataDim, + const ::std::vector<SCROW>& aDataMembers, + const ::std::vector<ScDPValue>& aValues ) const; //! Test + void FillMemberResults( css::uno::Sequence< + css::sheet::MemberResult>* pSequences, + tools::Long nStart, tools::Long nMeasure ); + + void FillDataResults( + const ScDPResultMember* pRefMember, + ScDPResultFilterContext& rFilterCxt, + css::uno::Sequence< + css::uno::Sequence< + css::sheet::DataResult> >& rSequence, + tools::Long nMeasure) const; + + void UpdateDataResults( const ScDPResultMember* pRefMember, tools::Long nMeasure ) const; + void UpdateRunningTotals( const ScDPResultMember* pRefMember, tools::Long nMeasure, + ScDPRunningTotalState& rRunning, ScDPRowTotals& rTotals ) const; + + void SortMembers( ScDPResultMember* pRefMember ); + tools::Long GetSortedIndex( tools::Long nUnsorted ) const; + + void DoAutoShow( ScDPResultMember* pRefMember ); + + void ResetResults(); + + // called for the reference dimension + ScDPDataMember* GetRowReferenceMember( + const ScDPRelativePos* pMemberPos, const OUString* pName, + const sal_Int32* pRowIndexes, const sal_Int32* pColIndexes ) const; + + // uses row root member from ScDPRunningTotalState + static ScDPDataMember* GetColReferenceMember( + const ScDPRelativePos* pMemberPos, const OUString* pName, + sal_Int32 nRefDimPos, const ScDPRunningTotalState& rRunning ); + +#if DUMP_PIVOT_TABLE + void DumpState( const ScDPResultMember* pRefMember, ScDocument* pDoc, ScAddress& rPos ) const; + void Dump(int nIndent) const; +#endif + + // for ScDPDataDimension::InitFrom + tools::Long GetMemberCount() const; + const ScDPResultMember* GetMember(tools::Long n) const; + ScDPResultMember* GetMember(tools::Long n); + + const ScMemberSortOrder& GetMemberOrder() const { return aMemberOrder; } + ScMemberSortOrder& GetMemberOrder() { return aMemberOrder; } + + bool IsDataLayout() const { return bIsDataLayout; } + const OUString& GetName() const { return aDimensionName; } + + bool IsSortByData() const { return bSortByData; } + bool IsSortAscending() const { return bSortAscending; } + tools::Long GetSortMeasure() const { return nSortMeasure; } + + bool IsAutoShow() const { return bAutoShow; } + bool IsAutoTopItems() const { return bAutoTopItems; } + tools::Long GetAutoMeasure() const { return nAutoMeasure; } + tools::Long GetAutoCount() const { return nAutoCount; } + + ScDPResultDimension* GetFirstChildDimension() const; + + void FillVisibilityData(ScDPResultVisibilityData& rData) const; +}; + +class ScDPDataDimension +{ +private: + const ScDPResultData* pResultData; + const ScDPResultDimension* pResultDimension; // column + std::vector<std::unique_ptr<ScDPDataMember>> maMembers; + bool bIsDataLayout; //! or ptr to IntDimension? + +public: + ScDPDataDimension( const ScDPResultData* pData ); + ~ScDPDataDimension(); + + void InitFrom( const ScDPResultDimension* pDim ); // recursive + void ProcessData( const ::std::vector< SCROW >& aDataMembers, const ::std::vector<ScDPValue>& aValues, + const ScDPSubTotalState& rSubState ); + void FillDataRow( + const ScDPResultDimension* pRefDim, + ScDPResultFilterContext& rFilterCxt, + css::uno::Sequence<css::sheet::DataResult>& rSequence, + tools::Long nMeasure, bool bIsSubTotalRow, const ScDPSubTotalState& rSubState) const; + + void UpdateDataRow( const ScDPResultDimension* pRefDim, tools::Long nMeasure, bool bIsSubTotalRow, + const ScDPSubTotalState& rSubState ) const; + void UpdateRunningTotals( const ScDPResultDimension* pRefDim, tools::Long nMeasure, bool bIsSubTotalRow, + const ScDPSubTotalState& rSubState, ScDPRunningTotalState& rRunning, + ScDPRowTotals& rTotals, const ScDPResultMember& rRowParent ) const; + + void SortMembers( ScDPResultDimension* pRefDim ); + tools::Long GetSortedIndex( tools::Long nUnsorted ) const; + + void DoAutoShow( ScDPResultDimension* pRefDim ); + + void ResetResults(); + +#if DUMP_PIVOT_TABLE + void DumpState( const ScDPResultDimension* pRefDim, ScDocument* pDoc, ScAddress& rPos ) const; + void Dump(int nIndent) const; +#endif + + tools::Long GetMemberCount() const; + const ScDPDataMember* GetMember(tools::Long n) const; + ScDPDataMember* GetMember(tools::Long n); +}; + +/** + * This class collects visible members of each dimension and uses that + * information to create filtering criteria (e.g. for drill-down data). + */ +class ScDPResultVisibilityData +{ +public: + ScDPResultVisibilityData( ScDPSource* pSource); + ~ScDPResultVisibilityData(); + + void addVisibleMember(const OUString& rDimName, const ScDPItemData& rMemberItem); + void fillFieldFilters(::std::vector<ScDPFilteredCache::Criterion>& rFilters) const; + +private: + struct MemberHash + { + size_t operator()(const ScDPItemData& r) const; + }; + typedef std::unordered_set<ScDPItemData, MemberHash> VisibleMemberType; + typedef std::unordered_map<OUString, VisibleMemberType> DimMemberType; + DimMemberType maDimensions; + + ScDPSource* mpSource; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/dptabsrc.hxx b/sc/inc/dptabsrc.hxx new file mode 100644 index 0000000000..4476966f21 --- /dev/null +++ b/sc/inc/dptabsrc.hxx @@ -0,0 +1,660 @@ +/* -*- 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/sheet/XDimensionsSupplier.hpp> +#include <com/sun/star/sheet/XHierarchiesSupplier.hpp> +#include <com/sun/star/sheet/XLevelsSupplier.hpp> +#include <com/sun/star/sheet/XMembersSupplier.hpp> +#include <com/sun/star/sheet/XDataPilotResults.hpp> +#include <com/sun/star/sheet/XDataPilotMemberResults.hpp> +#include <com/sun/star/sheet/DataPilotFieldAutoShowInfo.hpp> +#include <com/sun/star/sheet/DataPilotFieldLayoutInfo.hpp> +#include <com/sun/star/sheet/DataPilotFieldLayoutMode.hpp> +#include <com/sun/star/sheet/DataPilotFieldReference.hpp> +#include <com/sun/star/sheet/DataPilotFieldSortInfo.hpp> +#include <com/sun/star/sheet/DataPilotFieldOrientation.hpp> +#include <com/sun/star/util/XRefreshable.hpp> +#include <com/sun/star/sheet/XDrillDownDataSupplier.hpp> +#include <com/sun/star/util/XCloneable.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/container/XNamed.hpp> +#include <cppuhelper/implbase.hxx> +#include <rtl/ref.hxx> + +#include "dptabdat.hxx" +#include "dpresfilter.hxx" + +#include <memory> +#include <unordered_map> +#include <unordered_set> +#include <vector> +#include <optional> + +namespace com::sun::star { + namespace sheet { + struct DataPilotFieldFilter; + struct MemberResult; + } +} + +class ScDPResultMember; +class ScDPResultData; +class ScDPItemData; +class ScDPDimensions; +class ScDPDimension; +class ScDPHierarchies; +class ScDPHierarchy; +class ScDPLevels; +class ScDPLevel; +class ScDPMembers; +class ScDPMember; +enum class ScGeneralFunction; + +// implementation of DataPilotSource using ScDPTableData + +class ScDPSource final : public cppu::WeakImplHelper< + css::sheet::XDimensionsSupplier, + css::sheet::XDataPilotResults, + css::util::XRefreshable, + css::sheet::XDrillDownDataSupplier, + css::beans::XPropertySet, + css::lang::XServiceInfo > +{ +private: + ScDPTableData* pData; // data source (ScDPObject manages its life time) + rtl::Reference<ScDPDimensions> pDimensions; // api objects + // settings: + + std::vector<sal_Int32> maColDims; + std::vector<sal_Int32> maRowDims; + std::vector<sal_Int32> maDataDims; + std::vector<sal_Int32> maPageDims; + ScDPResultTree maResFilterSet; + + bool bColumnGrand; + bool bRowGrand; + bool bIgnoreEmptyRows; + bool bRepeatIfEmpty; + + sal_Int32 nDupCount; + + // results: + std::unique_ptr<ScDPResultData> pResData; // keep the rest in this! + std::unique_ptr<ScDPResultMember> pColResRoot; + std::unique_ptr<ScDPResultMember> pRowResRoot; + std::unique_ptr<css::uno::Sequence<css::sheet::MemberResult>[]> pColResults; + std::unique_ptr<css::uno::Sequence<css::sheet::MemberResult>[]> pRowResults; + std::vector<ScDPLevel*> aColLevelList; + std::vector<ScDPLevel*> aRowLevelList; + bool bResultOverflow; + bool bPageFiltered; // set if page field filters have been applied to cache table + + std::optional<OUString> mpGrandTotalName; + + void CreateRes_Impl(); + void FillMemberResults(); + void FillLevelList( css::sheet::DataPilotFieldOrientation nOrientation, std::vector<ScDPLevel*> &rList ); + void FillCalcInfo(bool bIsRow, ScDPTableData::CalcInfo& rInfo, bool &bHasAutoShow); + + /** + * Compile a list of dimension indices that are either, column, row or + * page dimensions (i.e. all but data dimensions). + */ + void GetCategoryDimensionIndices(std::unordered_set<sal_Int32>& rCatDims); + + /** + * Set visibilities of individual rows in the cache table based on the + * page field data. + */ + void FilterCacheByPageDimensions(); + + void SetDupCount( tools::Long nNew ); + + OUString getDataDescription(); //! ??? + + void setIgnoreEmptyRows(bool bSet); + void setRepeatIfEmpty(bool bSet); + + void disposeData(); + +public: + ScDPSource( ScDPTableData* pD ); + virtual ~ScDPSource() override; + + ScDPTableData* GetData() { return pData; } + const ScDPTableData* GetData() const { return pData; } + + const std::optional<OUString> & + GetGrandTotalName() const; + + css::sheet::DataPilotFieldOrientation + GetOrientation(sal_Int32 nColumn); + void SetOrientation(sal_Int32 nColumn, css::sheet::DataPilotFieldOrientation nNew); + sal_Int32 GetPosition(sal_Int32 nColumn); + + sal_Int32 GetDataDimensionCount() const; + ScDPDimension* GetDataDimension(sal_Int32 nIndex); + OUString GetDataDimName(sal_Int32 nIndex); + const ScDPCache* GetCache(); + const ScDPItemData* GetItemDataById( sal_Int32 nDim, sal_Int32 nId ); + bool IsDataLayoutDimension(sal_Int32 nDim); + css::sheet::DataPilotFieldOrientation + GetDataLayoutOrientation(); + + bool IsDateDimension(sal_Int32 nDim); + + bool SubTotalAllowed(sal_Int32 nColumn); //! move to ScDPResultData + + ScDPDimension* AddDuplicated(std::u16string_view rNewName); + sal_Int32 GetDupCount() const { return nDupCount; } + + sal_Int32 GetSourceDim(sal_Int32 nDim); + + const css::uno::Sequence<css::sheet::MemberResult>* + GetMemberResults( const ScDPLevel* pLevel ); + + ScDPDimensions* GetDimensionsObject(); + + // XDimensionsSupplier + virtual css::uno::Reference< css::container::XNameAccess > + SAL_CALL getDimensions( ) override; + + // XDataPilotResults + virtual css::uno::Sequence< css::uno::Sequence< css::sheet::DataResult > > SAL_CALL getResults( ) override; + + virtual css::uno::Sequence<double> SAL_CALL + getFilteredResults( + const css::uno::Sequence<css::sheet::DataPilotFieldFilter>& aFilters ) override; + + // XRefreshable + virtual void SAL_CALL refresh() override; + virtual void SAL_CALL addRefreshListener( const css::uno::Reference< css::util::XRefreshListener >& l ) override; + virtual void SAL_CALL removeRefreshListener( const css::uno::Reference< css::util::XRefreshListener >& l ) override; + + // XDrillDownDataSupplier + virtual css::uno::Sequence< css::uno::Sequence< css::uno::Any > > + SAL_CALL getDrillDownData(const css::uno::Sequence< + css::sheet::DataPilotFieldFilter >& aFilters ) override; + + // XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > + SAL_CALL getPropertySetInfo( ) override; + virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, + const css::uno::Any& aValue ) override; + virtual css::uno::Any SAL_CALL getPropertyValue( + const OUString& PropertyName ) override; + virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override; + virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override; + virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + + // XServiceInfo + 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; + +#if DUMP_PIVOT_TABLE + void DumpResults() const; +#endif +}; + +class ScDPDimensions final : public cppu::WeakImplHelper< + css::container::XNameAccess, + css::lang::XServiceInfo > +{ +private: + ScDPSource* pSource; + sal_Int32 nDimCount; + std::unique_ptr<rtl::Reference<ScDPDimension>[]> + ppDims; + +public: + ScDPDimensions( ScDPSource* pSrc ); + virtual ~ScDPDimensions() override; + + void CountChanged(); + + // XNameAccess + virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override; + virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override; + + // XElementAccess + virtual css::uno::Type SAL_CALL getElementType() override; + virtual sal_Bool SAL_CALL hasElements() override; + + // XServiceInfo + 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; + + tools::Long getCount() const; + ScDPDimension* getByIndex(tools::Long nIndex) const; +}; + +class ScDPDimension final : public cppu::WeakImplHelper< + css::sheet::XHierarchiesSupplier, + css::container::XNamed, + css::util::XCloneable, + css::beans::XPropertySet, + css::lang::XServiceInfo > +{ + ScDPSource* pSource; + sal_Int32 nDim; // dimension index (== column ID) + rtl::Reference<ScDPHierarchies> mxHierarchies; + ScGeneralFunction nFunction; + OUString aName; // if empty, take from source + std::optional<OUString> mpLayoutName; + std::optional<OUString> mpSubtotalName; + sal_Int32 nSourceDim; // >=0 if dup'ed + css::sheet::DataPilotFieldReference + aReferenceValue; // settings for "show data as" / "displayed value" + bool bHasSelectedPage; + OUString aSelectedPage; + std::unique_ptr<ScDPItemData> + pSelectedData; // internal, temporary, created from aSelectedPage + bool mbHasHiddenMember; + +public: + ScDPDimension( ScDPSource* pSrc, tools::Long nD ); + virtual ~ScDPDimension() override; + ScDPDimension(const ScDPDimension&) = delete; + ScDPDimension& operator=(const ScDPDimension&) = delete; + + sal_Int32 GetDimension() const { return nDim; } // dimension index in source + sal_Int32 GetSourceDim() const { return nSourceDim; } // >=0 if dup'ed + + ScDPDimension* CreateCloneObject(); + ScDPHierarchies* GetHierarchiesObject(); + + const std::optional<OUString> & GetLayoutName() const; + const std::optional<OUString> & GetSubtotalName() const; + + // XNamed + virtual OUString SAL_CALL getName() override; + virtual void SAL_CALL setName( const OUString& aName ) override; + + // XHierarchiesSupplier + virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL + getHierarchies() override; + + // XCloneable + virtual css::uno::Reference< css::util::XCloneable > SAL_CALL + createClone() override; + + // XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > + SAL_CALL getPropertySetInfo( ) override; + virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, + const css::uno::Any& aValue ) override; + virtual css::uno::Any SAL_CALL getPropertyValue( + const OUString& PropertyName ) override; + virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< + css::beans::XPropertyChangeListener >& xListener ) override; + virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override; + virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + + // XServiceInfo + 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; + + css::sheet::DataPilotFieldOrientation getOrientation() const; + bool getIsDataLayoutDimension() const; + ScGeneralFunction getFunction() const { return nFunction;} + void setFunction(ScGeneralFunction nNew); // for data dimension + static tools::Long getUsedHierarchy() { return 0;} + + bool HasSelectedPage() const { return bHasSelectedPage; } + const ScDPItemData& GetSelectedData(); + + const css::sheet::DataPilotFieldReference& GetReferenceValue() const { return aReferenceValue;} +}; + +class ScDPHierarchies final : public cppu::WeakImplHelper< + css::container::XNameAccess, + css::lang::XServiceInfo > +{ +private: + ScDPSource* pSource; + sal_Int32 nDim; + // date columns have 3 hierarchies (flat/quarter/week), other columns only one + // #i52547# don't offer the incomplete date hierarchy implementation + static const tools::Long nHierCount = 1; + std::unique_ptr<rtl::Reference<ScDPHierarchy>[]> + ppHiers; + +public: + ScDPHierarchies( ScDPSource* pSrc, tools::Long nD ); + virtual ~ScDPHierarchies() override; + + // XNameAccess + virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override; + virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override; + + // XElementAccess + virtual css::uno::Type SAL_CALL getElementType() override; + virtual sal_Bool SAL_CALL hasElements() override; + + // XServiceInfo + 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; + + static sal_Int32 getCount(); + ScDPHierarchy* getByIndex(tools::Long nIndex) const; +}; + +class ScDPHierarchy final : public cppu::WeakImplHelper< + css::sheet::XLevelsSupplier, + css::container::XNamed, + css::lang::XServiceInfo > +{ +private: + ScDPSource* pSource; + sal_Int32 nDim; + sal_Int32 nHier; + rtl::Reference<ScDPLevels> mxLevels; + +public: + ScDPHierarchy( ScDPSource* pSrc, sal_Int32 nDim, sal_Int32 nHier ); + virtual ~ScDPHierarchy() override; + + ScDPLevels* GetLevelsObject(); + + // XNamed + virtual OUString SAL_CALL getName() override; + virtual void SAL_CALL setName( const OUString& aName ) override; + + // XLevelsSupplier + virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL + getLevels() override; + + // XServiceInfo + 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; +}; + +class ScDPLevels final : public cppu::WeakImplHelper< + css::container::XNameAccess, + css::lang::XServiceInfo > +{ +private: + ScDPSource* pSource; + sal_Int32 nDim; + sal_Int32 nHier; + sal_Int32 nLevCount; + std::unique_ptr<rtl::Reference<ScDPLevel>[]> + ppLevs; + +public: + ScDPLevels( ScDPSource* pSrc, sal_Int32 nDim, sal_Int32 nHier ); + virtual ~ScDPLevels() override; + + // XNameAccess + virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override; + virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override; + + // XElementAccess + virtual css::uno::Type SAL_CALL getElementType() override; + virtual sal_Bool SAL_CALL hasElements() override; + + // XServiceInfo + 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; + + sal_Int32 getCount() const; + ScDPLevel* getByIndex(sal_Int32 nIndex) const; +}; + +class ScDPLevel final : public cppu::WeakImplHelper< + css::sheet::XMembersSupplier, + css::container::XNamed, + css::sheet::XDataPilotMemberResults, + css::beans::XPropertySet, + css::lang::XServiceInfo > +{ +private: + ScDPSource* pSource; + sal_Int32 nDim; + sal_Int32 nHier; + sal_Int32 nLev; + rtl::Reference<ScDPMembers> mxMembers; + css::uno::Sequence<sal_Int16> aSubTotals; + css::sheet::DataPilotFieldSortInfo aSortInfo; // stored user settings + css::sheet::DataPilotFieldAutoShowInfo aAutoShowInfo; // stored user settings + css::sheet::DataPilotFieldLayoutInfo aLayoutInfo; // stored user settings + // valid only from result calculation: + ::std::vector<sal_Int32> aGlobalOrder; // result of sorting by name or position + sal_Int32 nSortMeasure; // measure (index of data dimension) to sort by + sal_Int32 nAutoMeasure; // measure (index of data dimension) for AutoShow + bool bShowEmpty:1; + bool bEnableLayout:1; // enabled only for row fields, not for the innermost one + bool bRepeatItemLabels:1; + +public: + ScDPLevel( ScDPSource* pSrc, sal_Int32 nDim, sal_Int32 nHier, sal_Int32 nLevel ); + virtual ~ScDPLevel() override; + + ScDPMembers* GetMembersObject(); + + // XNamed + virtual OUString SAL_CALL getName() override; + virtual void SAL_CALL setName( const OUString& aName ) override; + + // XMembersSupplier + virtual css::uno::Reference< css::sheet::XMembersAccess > SAL_CALL + getMembers() override; + + // XDataPilotMemberResults + virtual css::uno::Sequence< css::sheet::MemberResult > SAL_CALL + getResults() override; + + // XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > + SAL_CALL getPropertySetInfo( ) override; + virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, + const css::uno::Any& aValue ) override; + virtual css::uno::Any SAL_CALL getPropertyValue( + const OUString& PropertyName ) override; + virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override; + virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override; + virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + + // XServiceInfo + 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; + + css::uno::Sequence<sal_Int16> getSubTotals() const; + bool getShowEmpty() const { return bShowEmpty;} + bool getRepeatItemLabels() const { return bRepeatItemLabels; } + + const css::sheet::DataPilotFieldSortInfo& GetSortInfo() const { return aSortInfo; } + const css::sheet::DataPilotFieldAutoShowInfo& GetAutoShow() const { return aAutoShowInfo; } + + void EvaluateSortOrder(); + void SetEnableLayout(bool bSet); + + const ::std::vector<sal_Int32>& GetGlobalOrder() const { return aGlobalOrder; } + ::std::vector<sal_Int32>& GetGlobalOrder() { return aGlobalOrder; } + sal_Int32 GetSortMeasure() const { return nSortMeasure; } + sal_Int32 GetAutoMeasure() const { return nAutoMeasure; } + + bool IsOutlineLayout() const + { + return bEnableLayout && + aLayoutInfo.LayoutMode != + css::sheet::DataPilotFieldLayoutMode::TABULAR_LAYOUT; + } + + bool IsSubtotalsAtTop() const + { + return bEnableLayout && + (aLayoutInfo.LayoutMode == + css::sheet::DataPilotFieldLayoutMode::OUTLINE_SUBTOTALS_TOP || + aLayoutInfo.LayoutMode == + css::sheet::DataPilotFieldLayoutMode::COMPACT_LAYOUT); + } + + bool IsAddEmpty() const + { + return bEnableLayout && aLayoutInfo.AddEmptyLines; + } + + //! number format (for data fields and date fields) +}; + +// hash map from name to index in the member array, for fast name access +typedef std::unordered_map< OUString, sal_Int32 > ScDPMembersHashMap; + +class ScDPMembers final : public cppu::WeakImplHelper< + css::sheet::XMembersAccess, + css::lang::XServiceInfo > +{ +private: + typedef std::vector<rtl::Reference<ScDPMember> > MembersType; + ScDPSource* pSource; + sal_Int32 nDim; + sal_Int32 nHier; + sal_Int32 nLev; + sal_Int32 nMbrCount; + mutable MembersType maMembers; + mutable ScDPMembersHashMap aHashMap; + +public: + ScDPMembers( ScDPSource* pSrc, sal_Int32 nDim, sal_Int32 nHier, sal_Int32 nLev ); + virtual ~ScDPMembers() override; + + // XMembersAccess + virtual css::uno::Sequence< OUString > SAL_CALL getLocaleIndependentElementNames() override; + + // XNameAccess + virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override; + virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override; + + // XElementAccess + virtual css::uno::Type SAL_CALL getElementType() override; + virtual sal_Bool SAL_CALL hasElements() override; + + // XServiceInfo + 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; + + sal_Int32 getCount() const { return nMbrCount;} + ScDPMember* getByIndex(sal_Int32 nIndex) const; + + sal_Int32 getMinMembers() const; + + sal_Int32 GetIndexFromName( const OUString& rName ) const; // <0 if not found + const ScDPItemData* GetSrcItemDataByIndex( SCROW nIndex); + +private: + /// @throws css::uno::RuntimeException + css::uno::Sequence< OUString > getElementNames( bool bLocaleIndependent ) const; +}; + +class ScDPMember final : public cppu::WeakImplHelper< + css::container::XNamed, + css::beans::XPropertySet, + css::lang::XServiceInfo > +{ +private: + ScDPSource* pSource; + sal_Int32 nDim; + sal_Int32 nHier; + sal_Int32 nLev; + + SCROW mnDataId; + std::optional<OUString> mpLayoutName; + + sal_Int32 nPosition; // manual sorting + bool bVisible; + bool bShowDet; + +public: + ScDPMember(ScDPSource* pSrc, sal_Int32 nDim, sal_Int32 nHier, sal_Int32 nLev, SCROW nIndex); + virtual ~ScDPMember() override; + ScDPMember(const ScDPMember&) = delete; + ScDPMember& operator=(const ScDPMember&) = delete; + + OUString GetNameStr( bool bLocaleIndependent ) const; + ScDPItemData FillItemData() const; + const ScDPItemData* GetItemData() const; + SCROW GetItemDataId() const { return mnDataId; } + bool IsNamedItem(SCROW nIndex) const; + + const std::optional<OUString> & GetLayoutName() const; + tools::Long GetDim() const { return nDim;} + + sal_Int32 Compare( const ScDPMember& rOther ) const; // visible order + + // XNamed + virtual OUString SAL_CALL getName() override; + virtual void SAL_CALL setName( const OUString& aName ) override; + + // XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > + SAL_CALL getPropertySetInfo( ) override; + virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, + const css::uno::Any& aValue ) override; + virtual css::uno::Any SAL_CALL getPropertyValue( + const OUString& PropertyName ) override; + virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override; + virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override; + virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + + // XServiceInfo + 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; + + bool isVisible() const { return bVisible;} + bool getShowDetails() const { return bShowDet;} +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/dptypes.hxx b/sc/inc/dptypes.hxx new file mode 100644 index 0000000000..b96fc0434e --- /dev/null +++ b/sc/inc/dptypes.hxx @@ -0,0 +1,18 @@ +/* -*- 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/. + */ + +#pragma once + +#include <rtl/ustring.hxx> + +#include <unordered_set> + +typedef std::unordered_set<OUString> ScDPUniqueStringSet; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/dputil.hxx b/sc/inc/dputil.hxx new file mode 100644 index 0000000000..5081c758ab --- /dev/null +++ b/sc/inc/dputil.hxx @@ -0,0 +1,58 @@ +/* -*- 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/. + */ + +#pragma once + +#include <sal/config.h> + +#include <string_view> + +#include <rtl/ustring.hxx> +#include "scdllapi.h" +#include "global.hxx" + +class SvNumberFormatter; +struct ScDPNumGroupInfo; +enum class ScGeneralFunction; + +class ScDPUtil +{ +public: + static bool isDuplicateDimension(std::u16string_view rName); + + SC_DLLPUBLIC static OUString getSourceDimensionName(std::u16string_view rName); + + /** + * Get a duplicate index in case the dimension is a duplicate. It returns + * 0 in case it's an original dimension. + */ + sal_uInt8 static getDuplicateIndex(const OUString& rName); + + SC_DLLPUBLIC static OUString createDuplicateDimensionName(const OUString& rOriginal, size_t nDupCount); + + SC_DLLPUBLIC static OUString getDateGroupName( + sal_Int32 nDatePart, sal_Int32 nValue, SvNumberFormatter* pFormatter, + double fStart, double fEnd); + + static double getNumGroupStartValue(double fValue, const ScDPNumGroupInfo& rInfo); + + static OUString getNumGroupName( + double fValue, const ScDPNumGroupInfo& rInfo, sal_Unicode cDecSep, + SvNumberFormatter* pFormatter); + + static sal_Int32 getDatePartValue( + double fValue, const ScDPNumGroupInfo* pInfo, sal_Int32 nDatePart, + const SvNumberFormatter* pFormatter); + + SC_DLLPUBLIC static OUString getDisplayedMeasureName(const OUString& rName, ScSubTotalFunc eFunc); + + SC_DLLPUBLIC static ScSubTotalFunc toSubTotalFunc(ScGeneralFunction eGenFunc); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/dragdata.hxx b/sc/inc/dragdata.hxx new file mode 100644 index 0000000000..f8cab8592e --- /dev/null +++ b/sc/inc/dragdata.hxx @@ -0,0 +1,38 @@ +/* -*- 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/. + */ + +#pragma once + +#include <rtl/ustring.hxx> + +class ScTransferObj; +class ScDrawTransferObj; +class ScDocument; + +struct ScDragData +{ + ScTransferObj* pCellTransfer; + ScDrawTransferObj* pDrawTransfer; + ScDocument* pJumpLocalDoc; + + OUString aLinkDoc; + OUString aLinkTable; + OUString aLinkArea; + OUString aJumpTarget; + OUString aJumpText; + + ScDragData() : + pCellTransfer(nullptr), + pDrawTransfer(nullptr), + pJumpLocalDoc(nullptr) + { + } +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/drawpage.hxx b/sc/inc/drawpage.hxx new file mode 100644 index 0000000000..772b3c5753 --- /dev/null +++ b/sc/inc/drawpage.hxx @@ -0,0 +1,40 @@ +/* -*- 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 <svx/fmpage.hxx> + +class ScDrawLayer; + +class ScDrawPage final : public FmFormPage +{ + ScDrawPage& operator=(const ScDrawPage&) = delete; + ScDrawPage(const ScDrawPage&) = delete; + +public: + explicit ScDrawPage(ScDrawLayer& rNewModel, bool bMasterPage); + virtual ~ScDrawPage() override; + + virtual rtl::Reference<SdrPage> CloneSdrPage(SdrModel& rTargetModel) const override; + + virtual css::uno::Reference<css::uno::XInterface> createUnoPage() override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/drdefuno.hxx b/sc/inc/drdefuno.hxx new file mode 100644 index 0000000000..8ccbdf06e2 --- /dev/null +++ b/sc/inc/drdefuno.hxx @@ -0,0 +1,42 @@ +/* -*- 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 <svx/unopool.hxx> +#include <svl/lstner.hxx> + +class ScDocShell; + +class ScDrawDefaultsObj final : public SvxUnoDrawPool, public SfxListener +{ +private: + ScDocShell* pDocShell; + +public: + ScDrawDefaultsObj(ScDocShell* pDocSh); + virtual ~ScDrawDefaultsObj() noexcept override; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + // from SvxUnoDrawPool + virtual SfxItemPool* getModelPool( bool bReadOnly ) noexcept override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/drwlayer.hxx b/sc/inc/drwlayer.hxx new file mode 100644 index 0000000000..6f1322b4b9 --- /dev/null +++ b/sc/inc/drwlayer.hxx @@ -0,0 +1,235 @@ +/* -*- 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 <svx/fmmodel.hxx> +#include <svx/svdundo.hxx> +#include "global.hxx" + +class ScDocument; +class SfxObjectShell; +class ScDrawObjData; +class ScMacroInfo; +class ScMarkData; +enum class SdrObjKind : sal_uInt16; + +class ScTabDeletedHint final : public SfxHint +{ +private: + SCTAB nTab; +public: + ScTabDeletedHint( SCTAB nTabNo ); + virtual ~ScTabDeletedHint() override; + + SCTAB GetTab() const { return nTab; } +}; + +class ScTabSizeChangedHint final : public SfxHint +{ +private: + SCTAB nTab; +public: + ScTabSizeChangedHint( SCTAB nTabNo ); + virtual ~ScTabSizeChangedHint() override; + + SCTAB GetTab() const { return nTab; } +}; + +// Adjusting of detective UserData and draw undo's both have to be in SdrUndoGroup; +// therefore derived from SdrUndoAction + +class ScUndoObjData final : public SdrUndoObj +{ +private: + ScAddress aOldStt; + ScAddress aOldEnd; + ScAddress aNewStt; + ScAddress aNewEnd; +public: + ScUndoObjData( SdrObject* pObj, const ScAddress& rOS, const ScAddress& rOE, + const ScAddress& rNS, const ScAddress& rNE ); + virtual ~ScUndoObjData() override; + + virtual void Undo() override; + virtual void Redo() override; +}; + +class ScUndoAnchorData final : public SdrUndoObj +{ +private: + bool mbWasCellAnchored; + bool mbWasResizeWithCell; + ScDocument* mpDoc; + SCTAB mnTab; +public: + ScUndoAnchorData( SdrObject* pObj, ScDocument* pDoc, SCTAB nTab ); + virtual ~ScUndoAnchorData() override; + + virtual void Undo() override; + virtual void Redo() override; +}; + +// for ScDrawLayer::SetPageSize +enum class ScObjectHandling +{ + RecalcPosMode, // used for row height or col width changes + MoveRTLMode, // used for switch to RTL during import of right-to-left sheet + MirrorRTLMode // used for switch between RTL and LTR by .uno:SheetRightToLeft +}; + +class SC_DLLPUBLIC ScDrawLayer final : public FmFormModel +{ +private: + OUString aName; + ScDocument* pDoc; + std::unique_ptr<SdrUndoGroup> pUndoGroup; + bool bRecording; + bool bAdjustEnabled; + bool bHyphenatorSet; + +private: + void MoveCells( SCTAB nTab, SCCOL nCol1,SCROW nRow1, SCCOL nCol2,SCROW nRow2, + SCCOL nDx,SCROW nDy, bool bUpdateNoteCaptionPos ); + + void ResizeLastRectFromAnchor( const SdrObject* pObj, ScDrawObjData& rData, bool bNegativePage, bool bCanResize ); + +public: + ScDrawLayer( ScDocument* pDocument, OUString aName ); + virtual ~ScDrawLayer() override; + + virtual rtl::Reference<SdrPage> AllocPage(bool bMasterPage) override; + virtual SdrModel* AllocModel() const override; + virtual void SetChanged( bool bFlg = true ) override; + + void CreateDefaultStyles(); + bool HasObjects() const; + + bool ScAddPage( SCTAB nTab ); + void ScRemovePage( SCTAB nTab ); + void ScRenamePage( SCTAB nTab, const OUString& rNewName ); + void ScMovePage( sal_uInt16 nOldPos, sal_uInt16 nNewPos ); + void ScCopyPage( sal_uInt16 nOldPos, sal_uInt16 nNewPos ); + void ResetTab( SCTAB nStart, SCTAB nEnd ); + + ScDocument* GetDocument() const { return pDoc; } + + void UseHyphenator(); + + bool GetPrintArea( ScRange& rRange, bool bSetHor, bool bSetVer ) const; + + // automatic adjustments + + void EnableAdjust( bool bSet ) { bAdjustEnabled = bSet; } + + void BeginCalcUndo(bool bDisableTextEditUsesCommonUndoManager); + std::unique_ptr<SdrUndoGroup> GetCalcUndo(); + bool IsRecording() const { return bRecording; } + void AddCalcUndo( std::unique_ptr<SdrUndoAction> pUndo ); + + void MoveArea( SCTAB nTab, SCCOL nCol1,SCROW nRow1, SCCOL nCol2,SCROW nRow2, + SCCOL nDx,SCROW nDy, bool bInsDel, bool bUpdateNoteCaptionPos ); + void InitializeCellAnchoredObj(SdrObject* pObj, ScDrawObjData& rData); + void RecalcPos( SdrObject* pObj, ScDrawObjData& rData, bool bNegativePage, bool bUpdateNoteCaptionPos ); + + bool HasObjectsInRows( SCTAB nTab, SCROW nStartRow, SCROW nEndRow ); + + void DeleteObjectsInArea( SCTAB nTab, SCCOL nCol1,SCROW nRow1, + SCCOL nCol2,SCROW nRow2, bool bAnchored = false ); + void DeleteObjectsInSelection( const ScMarkData& rMark ); + + void CopyToClip( ScDocument* pClipDoc, SCTAB nTab, const tools::Rectangle& rRange ); + void CopyFromClip( ScDrawLayer* pClipModel, + SCTAB nSourceTab, const ScRange& rSourceRange, + const ScAddress& rDestPos, const ScRange& rDestRange, + bool bTransposing = false); + + void SetPageSize(sal_uInt16 nPageNo, const Size& rSize, bool bUpdateNoteCaptionPos, + const ScObjectHandling eObjectHandling = ScObjectHandling::RecalcPosMode); + + // mirror or move between positive and negative positions for RTL + void MirrorRTL( SdrObject* pObj ); + void MoveRTL(SdrObject* pObj); + static void MirrorRectRTL( tools::Rectangle& rRect ); // for bounding rectangles etc. + + /** Returns the rectangle for the passed cell address in 1/100 mm. + @param bMergedCell True = regards merged cells. False = use single column/row size. */ + static tools::Rectangle GetCellRect( const ScDocument& rDoc, const ScAddress& rPos, bool bMergedCell ); + + // GetVisibleName: name for navigator etc: GetPersistName or GetName + // (ChartListenerCollection etc. must use GetPersistName directly) + static OUString GetVisibleName( const SdrObject* pObj ); + + SdrObject* GetNamedObject( std::u16string_view rName, SdrObjKind nId, SCTAB& rFoundTab ) const; + // if pnCounter != NULL, the search for a name starts with this index + 1, + // and the index really used is returned. + OUString GetNewGraphicName( tools::Long* pnCounter = nullptr ) const; + void EnsureGraphicNames(); + + static bool IsCellAnchored( const SdrObject& rObj ); + static bool IsResizeWithCell( const SdrObject& rObj ); + static void SetPageAnchored( SdrObject& ); + static void SetCellAnchored( SdrObject&, const ScDrawObjData &rAnchor ); + static void SetNonRotatedAnchor( SdrObject&, const ScDrawObjData &rAnchor ); + + // Updates rAnchor based on position of rObj + static void GetCellAnchorFromPosition( + const tools::Rectangle &rRectangle, + ScDrawObjData &rAnchor, + const ScDocument &rDoc, + SCTAB nTab, + bool bHiddenAsZero = true); + + static void SetCellAnchoredFromPosition( SdrObject &rObj, const ScDocument &rDoc, SCTAB nTab, bool bResizeWithCell ); + static void UpdateCellAnchorFromPositionEnd( const SdrObject &rObj, ScDrawObjData &rAnchor, const ScDocument &rDoc, SCTAB nTab, bool bUseLogicRect = true ); + static ScAnchorType GetAnchorType( const SdrObject& ); + std::vector<SdrObject*> GetObjectsAnchoredToRows(SCTAB nTab, SCROW nStartRow, SCROW nEndRow); + std::map<SCROW, std::vector<SdrObject*>> GetObjectsAnchoredToRange(SCTAB nTab, SCCOL nCol, SCROW nStartRow, SCROW nEndRow); + bool HasObjectsAnchoredInRange(const ScRange& rRange); + std::vector<SdrObject*> GetObjectsAnchoredToCols(SCTAB nTab, SCCOL nStartCol, SCCOL nEndCol); + void MoveObject(SdrObject* pObj, const ScAddress& rNewPosition); + + // positions for detective lines + static ScDrawObjData* GetObjData( SdrObject* pObj, bool bCreate=false ); + static ScDrawObjData* GetNonRotatedObjData( SdrObject* pObj, bool bCreate=false ); + + // The sheet information in ScDrawObjData isn't updated when sheets are inserted/deleted. + // Use this method to get an object with positions on the specified sheet (should be the + // sheet on which the object is inserted). + static ScDrawObjData* GetObjDataTab( SdrObject* pObj, SCTAB nTab ); + + /** Returns true, if the passed object is the caption of a cell note. */ + static bool IsNoteCaption( SdrObject* pObj ); + + /** Returns the object data, if the passed object is a cell note caption. */ + static ScDrawObjData* GetNoteCaptionData( SdrObject* pObj, SCTAB nTab ); + + static ScMacroInfo* GetMacroInfo( SdrObject* pObj, bool bCreate = false ); + +private: + static SfxObjectShell* pGlobalDrawPersist; // for AllocModel +public: + static void SetGlobalDrawPersist(SfxObjectShell* pPersist); +private: + virtual css::uno::Reference< css::frame::XModel > createUnoModel() override; +}; + +extern bool bDrawIsInUndo; // somewhere as member! + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/editdataarray.hxx b/sc/inc/editdataarray.hxx new file mode 100644 index 0000000000..4e2e30b2c1 --- /dev/null +++ b/sc/inc/editdataarray.hxx @@ -0,0 +1,72 @@ +/* -*- 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 <editeng/editobj.hxx> +#include "types.hxx" + +#include <memory> +#include <vector> + +class EditTextObject; + +class ScEditDataArray +{ +public: + class Item + { + public: + Item() = delete; + explicit Item(SCTAB nTab, SCCOL nCol, SCROW nRow, + std::unique_ptr<EditTextObject> pOldData, std::unique_ptr<EditTextObject> pNewData); + Item(Item const &) = delete; // due to mpOldData + Item(Item&&) = default; + ~Item(); + + const EditTextObject* GetOldData() const; + const EditTextObject* GetNewData() const; + SCTAB GetTab() const { return mnTab;} + SCCOL GetCol() const { return mnCol;} + SCROW GetRow() const { return mnRow;} + + private: + std::unique_ptr<EditTextObject> mpOldData; + std::unique_ptr<EditTextObject> mpNewData; + SCTAB mnTab; + SCCOL mnCol; + SCROW mnRow; + + }; + + ScEditDataArray(); + ~ScEditDataArray(); + + void AddItem(SCTAB nTab, SCCOL nCol, SCROW nRow, + std::unique_ptr<EditTextObject> pOldData, std::unique_ptr<EditTextObject> pNewData); + + const Item* First(); + const Item* Next(); + +private: + ::std::vector<Item>::const_iterator maIter; + ::std::vector<Item> maArray; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/editsrc.hxx b/sc/inc/editsrc.hxx new file mode 100644 index 0000000000..166a18a289 --- /dev/null +++ b/sc/inc/editsrc.hxx @@ -0,0 +1,149 @@ +/* -*- 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 "address.hxx" +#include <editeng/unoedsrc.hxx> +#include <svl/lstner.hxx> + +#include <memory> + +class ScEditEngineDefaulter; +class SvxEditEngineForwarder; + +class ScDocShell; +class ScCellTextData; +class ScHeaderFooterTextData; +class ScAccessibleTextData; +class SdrObject; + +class ScEditSource : public SvxEditSource +{ +public: + virtual ScEditEngineDefaulter* GetEditEngine() = 0; +}; + +/** + * ScHeaderFooterTextObj keeps the authoritative copy of + * ScHeaderFooterTextData that this class holds reference to. It's a + * reference instead of a copy to avoid broadcasting changes to the + * authoritative copy. + */ +class ScHeaderFooterEditSource final : public ScEditSource +{ +private: + ScHeaderFooterTextData& mrTextData; + +public: + ScHeaderFooterEditSource(ScHeaderFooterTextData& rData); + virtual ~ScHeaderFooterEditSource() override; + + // GetEditEngine is needed because the forwarder doesn't have field functions + virtual ScEditEngineDefaulter* GetEditEngine() override; + + virtual std::unique_ptr<SvxEditSource> Clone() const override; + virtual SvxTextForwarder* GetTextForwarder() override; + virtual void UpdateData() override; +}; + +/** + * Data (incl. EditEngine) for cell EditSource is now shared in + * ScCellTextData. + * + * ScCellEditSource with local copy of ScCellTextData is used by + * ScCellFieldsObj, ScCellFieldObj. + */ +class ScCellEditSource final : public ScEditSource +{ +private: + std::unique_ptr<ScCellTextData> pCellTextData; + +public: + ScCellEditSource(ScDocShell* pDocSh, const ScAddress& rP); + virtual ~ScCellEditSource() override; + + // GetEditEngine is needed because the forwarder doesn't have field functions + virtual ScEditEngineDefaulter* GetEditEngine() override; + + virtual std::unique_ptr<SvxEditSource> Clone() const override; + virtual SvxTextForwarder* GetTextForwarder() override; + + virtual void UpdateData() override; + + void SetDoUpdateData(bool bValue); + bool IsDirty() const; +}; + +class ScAnnotationEditSource final : public SvxEditSource, public SfxListener +{ +private: + ScDocShell* pDocShell; + ScAddress aCellPos; + std::unique_ptr<ScEditEngineDefaulter> pEditEngine; + std::unique_ptr<SvxEditEngineForwarder> pForwarder; + bool bDataValid; + + SdrObject* GetCaptionObj(); +public: + ScAnnotationEditSource(ScDocShell* pDocSh, const ScAddress& rP); + virtual ~ScAnnotationEditSource() override; + + virtual std::unique_ptr<SvxEditSource> Clone() const override ; + virtual SvxTextForwarder* GetTextForwarder() override; + virtual void UpdateData() override; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; +}; + +// EditSource with a shared forwarder for all children of one text object + +class ScSimpleEditSource final : public SvxEditSource +{ +private: + SvxTextForwarder* pForwarder; + +public: + ScSimpleEditSource( SvxTextForwarder* pForw ); + virtual ~ScSimpleEditSource() override; + + virtual std::unique_ptr<SvxEditSource> Clone() const override ; + virtual SvxTextForwarder* GetTextForwarder() override; + virtual void UpdateData() override; + +}; + +class ScAccessibilityEditSource final : public SvxEditSource +{ +private: + ::std::unique_ptr < ScAccessibleTextData > mpAccessibleTextData; + +public: + ScAccessibilityEditSource( ::std::unique_ptr < ScAccessibleTextData > && pAccessibleCellTextData ); + virtual ~ScAccessibilityEditSource() override; + + virtual std::unique_ptr<SvxEditSource> Clone() const override; + virtual SvxTextForwarder* GetTextForwarder() override; + virtual SvxViewForwarder* GetViewForwarder() override; + virtual SvxEditViewForwarder* GetEditViewForwarder( bool bCreate = false ) override; + virtual void UpdateData() override; + virtual SfxBroadcaster& GetBroadcaster() const override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/edittextiterator.hxx b/sc/inc/edittextiterator.hxx new file mode 100644 index 0000000000..8bcbc1f7b3 --- /dev/null +++ b/sc/inc/edittextiterator.hxx @@ -0,0 +1,55 @@ +/* -*- 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/. + */ + +#pragma once + +#include "types.hxx" +#include "mtvelements.hxx" + +class ScTable; +class ScDocument; +class EditTextObject; + +namespace sc +{ +/** + * Iterate through all edit text cells in a given sheet. The caller must + * check the validity of the sheet index passed to its constructor. + * + * It iterates from top to bottom, and then left to right order. + */ +class EditTextIterator +{ + const ScTable& mrTable; + SCCOL mnCol; + const CellStoreType* mpCells; + CellStoreType::const_position_type maPos; + CellStoreType::const_iterator miEnd; + + /** + * Move to the next edit text cell position if the current position is not + * an edit text. + */ + const EditTextObject* seek(); + + void incBlock(); + /** + * Initialize members w.r.t the dynamic column container in the given table. + */ + void init(); + +public: + EditTextIterator(const ScDocument& rDoc, SCTAB nTab); + + const EditTextObject* first(); + const EditTextObject* next(); +}; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/editutil.hxx b/sc/inc/editutil.hxx new file mode 100644 index 0000000000..ce102885ae --- /dev/null +++ b/sc/inc/editutil.hxx @@ -0,0 +1,238 @@ +/* -*- 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 <memory> +#include "scdllapi.h" +#include "types.hxx" +#include <editeng/editeng.hxx> +#include <svx/pageitem.hxx> +#include <tools/datetime.hxx> +#include <tools/gen.hxx> +#include <tools/fract.hxx> +#include <vcl/outdev.hxx> + +class ScDocument; +class ScPatternAttr; +class ScEditEngineDefaulter; + +class ScEditUtil +{ + ScDocument* pDoc; + SCCOL nCol; + SCROW nRow; + SCTAB nTab; + Point aCellPos; + VclPtr<OutputDevice> pDev; // MapMode has to be set + double nPPTX; + double nPPTY; + Fraction aZoomX; + Fraction aZoomY; + bool bInPrintTwips; + +public: + static OUString ModifyDelimiters( const OUString& rOld ); + + /// Retrieves string with paragraphs delimited by spaces + static OUString GetSpaceDelimitedString( const EditEngine& rEngine ); + + /// Retrieves string with paragraphs delimited by new lines ('\n'). + static OUString GetMultilineString( const EditEngine& rEngine ); + static OUString GetMultilineString( const EditTextObject& rEdit ); + + /** Retrieves string with paragraphs delimited by new lines ('\n'). + + @param pDoc + If not NULL, use pDoc->GetEditEngine() to retrieve field content. + If NULL, a static mutex-guarded ScFieldEditEngine is used that + is not capable of resolving document specific fields; avoid. + */ + SC_DLLPUBLIC static OUString GetString( const EditTextObject& rEditText, const ScDocument* pDoc ); + + static std::unique_ptr<EditTextObject> CreateURLObjectFromURL( + ScDocument& rDoc, const OUString& rURL, const OUString& rText ); + + static void RemoveCharAttribs( EditTextObject& rEditText, const ScPatternAttr& rAttr ); + + static std::unique_ptr<EditTextObject> Clone( const EditTextObject& rSrc, ScDocument& rDestDoc ); + + static OUString GetCellFieldValue( + const SvxFieldData& rFieldData, const ScDocument* pDoc, std::optional<Color>* ppTextColor, std::optional<FontLineStyle>* ppFldLineStyle ); + +public: + ScEditUtil( ScDocument* pDocument, SCCOL nX, SCROW nY, SCTAB nZ, + const Point& rCellPos, + OutputDevice* pDevice, double nScaleX, double nScaleY, + const Fraction& rX, const Fraction& rY, bool bPrintTwips = false ); + + tools::Rectangle GetEditArea( const ScPatternAttr* pPattern, bool bForceToTop ); + tools::Long GetIndent(const ScPatternAttr* pPattern) const; + void GetMargins(const ScPatternAttr* pPattern, tools::Long& nLeftMargin, tools::Long& nTopMargin, + tools::Long& nRightMargin, tools::Long& BottomMargin) const; + +}; + +class ScEditAttrTester +{ + std::unique_ptr<SfxItemSet> pEditAttrs; + bool bNeedsObject; + bool bNeedsCellAttr; + +public: + ScEditAttrTester( ScEditEngineDefaulter* pEng ); + ~ScEditAttrTester(); + + bool NeedsObject() const { return bNeedsObject; } + bool NeedsCellAttr() const { return bNeedsCellAttr; } + const SfxItemSet& GetAttribs() const { return *pEditAttrs; } +}; + +// construct pool before constructing EditEngine, destroy pool after EditEngine +class ScEnginePoolHelper +{ +protected: + rtl::Reference<SfxItemPool> pEnginePool; + SfxItemSet* pDefaults; + bool bDeleteEnginePool; + bool bDeleteDefaults; + + ScEnginePoolHelper( SfxItemPool* pEnginePool, bool bDeleteEnginePool ); + ScEnginePoolHelper( const ScEnginePoolHelper& rOrg ); + virtual ~ScEnginePoolHelper(); +}; + +class SC_DLLPUBLIC ScEditEngineDefaulter : public ScEnginePoolHelper, public EditEngine +{ +public: + using EditEngine::SetText; + /// bDeleteEnginePool: Engine becomes the owner of the pool + /// and deletes it on destruction + ScEditEngineDefaulter( SfxItemPool* pEnginePool, + bool bDeleteEnginePool = false ); + /// If rOrg.bDeleteEnginePool: pool gets cloned and will be + /// deleted on destruction. Defaults are not set. + ScEditEngineDefaulter( const ScEditEngineDefaulter& rOrg ); + virtual ~ScEditEngineDefaulter() override; + + /// Creates a copy of SfxItemSet if bRememberCopy set + void SetDefaults( const SfxItemSet& rDefaults, bool bRememberCopy = true ); + + /// Becomes the owner of the SfxItemSet + void SetDefaults( std::unique_ptr<SfxItemSet> pDefaults ); + + /// Set the item in the default ItemSet which is created + /// if it doesn't exist yet. + /// The default ItemSet is then applied to each paragraph. + void SetDefaultItem( const SfxPoolItem& rItem ); + + /// Returns the stored defaults, used to find non-default character attributes + const SfxItemSet& GetDefaults(); + + /// SetText and apply defaults already set + void SetTextCurrentDefaults( const EditTextObject& rTextObject ); + /// Current defaults are not applied, new defaults are applied + void SetTextNewDefaults( const EditTextObject& rTextObject, + const SfxItemSet& rDefaults, bool bRememberCopy = true ); + + /// SetText and apply defaults already set + void SetTextCurrentDefaults( const OUString& rText ); + /// Current defaults are not applied, new defaults are applied + void SetTextNewDefaults( const OUString& rText, + const SfxItemSet& rDefaults ); + + /// Paragraph attributes that are not defaults are copied to + /// character attributes and all paragraph attributes reset + void RemoveParaAttribs(); + + /// Re-apply existing defaults if set, same as in SetText, + /// but without EnableUndo/SetUpdateMode. + void RepeatDefaults(); +}; + +// for field commands (or just fields?) in a table +class SC_DLLPUBLIC ScFieldEditEngine : public ScEditEngineDefaulter +{ +private: + ScDocument* mpDoc; + bool bExecuteURL; + +public: + ScFieldEditEngine( + ScDocument* pDoc, SfxItemPool* pEnginePool, SfxItemPool* pTextObjectPool = nullptr, + bool bDeleteEnginePool = false); + + void SetExecuteURL(bool bSet) { bExecuteURL = bSet; } + + virtual bool FieldClicked( const SvxFieldItem& rField ) override; + virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, std::optional<Color>& rTxtColor, std::optional<Color>& rFldColor, std::optional<FontLineStyle>& rFldLineStyle ) override; +}; + +// 1/100 mm +class SC_DLLPUBLIC ScTabEditEngine final : public ScFieldEditEngine +{ +private: + void Init(const ScPatternAttr& rPattern); +public: + ScTabEditEngine( ScDocument* pDoc ); // Default + ScTabEditEngine(const ScPatternAttr& rPattern, + SfxItemPool *pEngineItemPool, ScDocument *pDoc, + SfxItemPool* pTextObjectPool = nullptr ); +}; + +struct ScHeaderFieldData +{ + OUString aTitle; // title or file name (if no title) + OUString aLongDocName; // path and file name + OUString aShortDocName; // pure file name + OUString aTabName; + DateTime aDateTime; + tools::Long nPageNo; + tools::Long nTotalPages; + SvxNumType eNumType; + + ScHeaderFieldData(); +}; + +// for headers/footers with fields +class SC_DLLPUBLIC ScHeaderEditEngine final : public ScEditEngineDefaulter +{ +private: + ScHeaderFieldData aData; + +public: + ScHeaderEditEngine( SfxItemPool* pEnginePool ); + virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, std::optional<Color>& rTxtColor, std::optional<Color>& rFldColor, std::optional<FontLineStyle>& rFldLineStyle ) override; + + void SetNumType(SvxNumType eNew) { aData.eNumType = eNew; } + void SetData(const ScHeaderFieldData& rNew) { aData = rNew; } +}; + +// for Note text objects. +class ScNoteEditEngine final : public ScEditEngineDefaulter +{ + +public: + ScNoteEditEngine( SfxItemPool* pEnginePool, SfxItemPool* pTextObjectPool ); + +}; + +// SvxFieldData derivations were moved to Svx (comment can be deleted?) + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/eventuno.hxx b/sc/inc/eventuno.hxx new file mode 100644 index 0000000000..f3ba5954a2 --- /dev/null +++ b/sc/inc/eventuno.hxx @@ -0,0 +1,65 @@ +/* -*- 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/lang/XServiceInfo.hpp> +#include <com/sun/star/container/XNameReplace.hpp> +#include <cppuhelper/implbase.hxx> +#include <svl/lstner.hxx> + +#include "types.hxx" + +class ScDocShell; + +class ScSheetEventsObj final : public cppu::WeakImplHelper< + css::container::XNameReplace, + css::lang::XServiceInfo>, + public SfxListener +{ +private: + ScDocShell* mpDocShell; + SCTAB mnTab; + +public: + ScSheetEventsObj(ScDocShell* pDocSh, SCTAB nT); + virtual ~ScSheetEventsObj() override; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + // XNameReplace + virtual void SAL_CALL replaceByName( const OUString& aName, + const css::uno::Any& aElement ) override; + + // XNameAccess + virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override; + virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override; + + // XElementAccess + virtual css::uno::Type SAL_CALL getElementType() override; + virtual sal_Bool SAL_CALL hasElements() override; + + // XServiceInfo + 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; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/externalrefmgr.hxx b/sc/inc/externalrefmgr.hxx new file mode 100644 index 0000000000..238c4a1d0f --- /dev/null +++ b/sc/inc/externalrefmgr.hxx @@ -0,0 +1,871 @@ +/* -*- 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 "address.hxx" +#include "document.hxx" +#include <sfx2/objsh.hxx> +#include <sfx2/lnkbase.hxx> +#include <tools/time.hxx> +#include <vcl/timer.hxx> +#include <svl/zforlist.hxx> +#include <svl/lstner.hxx> +#include "types.hxx" +#include "rangelst.hxx" +#include <osl/mutex.hxx> +#include <formula/types.hxx> +#include <tools/solar.h> + +#include <memory> +#include <mutex> +#include <unordered_map> +#include <unordered_set> +#include <vector> +#include <set> +#include <o3tl/sorted_vector.hxx> +#include <formula/ExternalReferenceHelper.hxx> + +class ScTokenArray; +namespace weld { class Window; } + +class ScFormulaCell; + +namespace sc { + +class ColumnSpanSet; + +} + +class ScExternalRefLink final : public ::sfx2::SvBaseLink +{ +public: + ScExternalRefLink(ScDocument& rDoc, sal_uInt16 nFileId); + virtual ~ScExternalRefLink() override; + + virtual void Closed() override; + virtual ::sfx2::SvBaseLink::UpdateResult DataChanged( + const OUString& rMimeType, const css::uno::Any & rValue) override; + virtual void Edit(weld::Window* pParent, const Link<SvBaseLink&,void>& rEndEditHdl) override; + + void SetDoRefresh(bool b); + +private: + ScExternalRefLink() = delete; + ScExternalRefLink(const ScExternalRefLink&) = delete; + + sal_uInt16 mnFileId; + ScDocument& mrDoc; + bool mbDoRefresh; +}; + +/** + * Cache table for external reference data. + */ +class ScExternalRefCache +{ +public: + typedef ::formula::FormulaTokenRef TokenRef; + typedef std::shared_ptr<ScTokenArray> TokenArrayRef; + + struct TableName + { + OUString maUpperName; + OUString maRealName; + + explicit TableName(OUString aUpper, OUString aReal); + }; + + struct CellFormat + { + bool mbIsSet; + SvNumFormatType mnType; + sal_uLong mnIndex; + + explicit CellFormat(); + }; + +private: + /** individual cell within cached external ref table. */ + struct Cell + { + TokenRef mxToken; + sal_uLong mnFmtIndex; + }; + typedef std::unordered_map<SCCOL, Cell> RowDataType; + typedef std::unordered_map<SCROW, RowDataType> RowsDataType; + +public: + /** + * Represents a single cached table in an external document. It only + * stores non-empty cells; empty cells should never be stored in the data + * cache. Instead, cached ranges should be used to determine whether or + * not a cell is empty or needs fetching from the source document. If a + * cell's value is not stored but its address is within the cached ranges, + * that cell is already queried in the source document and we know it's + * empty. + */ + class Table + { + public: + + Table(); + ~Table(); + + void clear(); + + /** + * Add cell value to the cache. + * + * @param bSetCacheRange if true, mark this cell 'cached'. This is + * false _only when_ adding a range of cell + * values, for performance reasons. + */ + SC_DLLPUBLIC void setCell(SCCOL nCol, SCROW nRow, TokenRef const & pToken, sal_uLong nFmtIndex = 0, bool bSetCacheRange = true); + SC_DLLPUBLIC TokenRef getCell(SCCOL nCol, SCROW nRow, sal_uInt32* pnFmtIndex = nullptr) const; + bool hasRow( SCROW nRow ) const; + /** Set/clear referenced status flag only if current status is not + REFERENCED_PERMANENT. */ + void setReferenced( bool bReferenced ); + bool isReferenced() const; + /// Obtain a sorted vector of rows. + void getAllRows(::std::vector<SCROW>& rRows, SCROW nLow, SCROW nHigh) const; + void getAllRows(::std::vector<SCROW>& rRows) const; + /// Returns the half-open range of used rows in this table. Returns [0,0) if table is empty. + SC_DLLPUBLIC ::std::pair< SCROW, SCROW > getRowRange() const; + /// Obtain a sorted vector of columns. + void getAllCols(SCROW nRow, ::std::vector<SCCOL>& rCols, SCCOL nLow, SCCOL nHigh) const; + void getAllCols(SCROW nRow, ::std::vector<SCCOL>& rCols) const; + /// Returns the half-open range of used columns in the specified row. Returns [0,0) if row is empty. + SC_DLLPUBLIC ::std::pair< SCCOL, SCCOL > getColRange( SCROW nRow ) const; + void getAllNumberFormats(::std::vector<sal_uInt32>& rNumFmts) const; + bool isRangeCached(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) const; + + void setCachedCell(SCCOL nCol, SCROW nRow); + void setCachedCellRange(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2); + + /** + * Call this to mark the entire table "cached". This will prevent all + * future attempts to access the source document even when non-cached + * cells are queried. In such case, non-cached cells are treated as + * empty cells. Useful when loading a document with own external data + * cache. + */ + SC_DLLPUBLIC void setWholeTableCached(); + private: + bool isInCachedRanges(SCCOL nCol, SCROW nRow) const; + TokenRef getEmptyOrNullToken(SCCOL nCol, SCROW nRow) const; + template< typename P > + void getAllRows(::std::vector<SCROW>& rRows, P predicate) const; + template< typename P > + void getAllCols(SCROW nRow, ::std::vector<SCCOL>& rCols, P predicate) const; + + private: + /** Data cache */ + RowsDataType maRows; + /** Collection of individual cached ranges. The table ranges are + * not used & always zero. */ + ScRangeList maCachedRanges; + bool mbReferenced; + }; + + typedef std::shared_ptr<Table> TableTypeRef; + typedef std::unordered_map< OUString, size_t> + TableNameIndexMap; + + ScExternalRefCache(const ScDocument& rDoc); + ~ScExternalRefCache(); + + const OUString* getRealTableName(sal_uInt16 nFileId, const OUString& rTabName) const; + const OUString* getRealRangeName(sal_uInt16 nFileId, const OUString& rRangeName) const; + + /** + * Get a cached cell data at specified cell location. + * + * @param nFileId file ID of an external document + * @param rTabName sheet name + * @param nCol + * @param nRow + * + * @return pointer to the token instance in the cache. + */ + ScExternalRefCache::TokenRef getCellData( + sal_uInt16 nFileId, const OUString& rTabName, SCCOL nCol, SCROW nRow, sal_uInt32* pnFmtIndex); + + /** + * Get a cached cell range data. + * + * @return a new token array instance. Note that <i>the caller must + * manage the life cycle of the returned instance</i>, which is + * guaranteed if the TokenArrayRef is properly used... + */ + ScExternalRefCache::TokenArrayRef getCellRangeData( + sal_uInt16 nFileId, const OUString& rTabName, const ScRange& rRange); + + ScExternalRefCache::TokenArrayRef getRangeNameTokens(sal_uInt16 nFileId, const OUString& rName); + void setRangeNameTokens(sal_uInt16 nFileId, const OUString& rName, TokenArrayRef pArray); + bool isValidRangeName(sal_uInt16 nFileId, const OUString& rName) const; + void setRangeName(sal_uInt16 nFileId, const OUString& rName); + + void setCellData(sal_uInt16 nFileId, const OUString& rTabName, + SCCOL nCol, SCROW nRow, TokenRef const & pToken, sal_uLong nFmtIndex); + + struct SingleRangeData + { + /** This name must be in upper-case. */ + OUString maTableName; + ScMatrixRef mpRangeData; + }; + void setCellRangeData(sal_uInt16 nFileId, const ScRange& rRange, const ::std::vector<SingleRangeData>& rData, + const TokenArrayRef& pArray); + + bool isDocInitialized(sal_uInt16 nFileId); + void initializeDoc(sal_uInt16 nFileId, const ::std::vector<OUString>& rTabNames, const OUString& rBaseName); + OUString getTableName(sal_uInt16 nFileId, size_t nCacheId) const; + void getAllTableNames(sal_uInt16 nFileId, ::std::vector<OUString>& rTabNames) const; + SCTAB getTabSpan( sal_uInt16 nFileId, const OUString& rStartTabName, const OUString& rEndTabName ) const; + void getAllNumberFormats(::std::vector<sal_uInt32>& rNumFmts) const; + + /** + * Set all tables of a document as referenced, used only during + * store-to-file. + * @returns <TRUE/> if ALL tables of ALL documents are marked. + */ + bool setCacheDocReferenced( sal_uInt16 nFileId ); + + /** + * Set a table as referenced, used only during store-to-file. + * @returns <TRUE/> if ALL tables of ALL documents are marked. + */ + bool setCacheTableReferenced( sal_uInt16 nFileId, const OUString& rTabName, size_t nSheets ); + void setAllCacheTableReferencedStati( bool bReferenced ); + bool areAllCacheTablesReferenced() const { return maReferenced.mbAllReferenced;} + + /** + * Collect all cached non-empty cell positions, inferred directly from the + * cached data, not the cached range metadata stored separately in the + * Table. + */ + void getAllCachedDataSpans( const ScDocument& rSrcDoc, sal_uInt16 nFileId, sc::ColumnSpanSet& rSet ) const; + + bool getSrcDocTable( const ScDocument& rSrcDoc, const OUString& rTabName, SCTAB& rTab, sal_uInt16 nFileId ) const; + +private: + struct ReferencedStatus + { + struct DocReferenced + { + ::std::vector<bool> maTables; + bool mbAllTablesReferenced; + // Initially, documents have no tables but all referenced. + DocReferenced() : mbAllTablesReferenced(true) {} + }; + typedef ::std::vector<DocReferenced> DocReferencedVec; + + DocReferencedVec maDocs; + bool mbAllReferenced; + + ReferencedStatus(); + void reset( size_t nDocs ); + void checkAllDocs(); + + } maReferenced; + void addCacheTableToReferenced( sal_uInt16 nFileId, size_t nIndex ); + void addCacheDocToReferenced( sal_uInt16 nFileId ); +public: + + ScExternalRefCache::TableTypeRef getCacheTable(sal_uInt16 nFileId, size_t nTabIndex) const; + ScExternalRefCache::TableTypeRef getCacheTable(sal_uInt16 nFileId, const OUString& rTabName, bool bCreateNew, + size_t* pnIndex, const OUString* pExtUrl); + + /** + * Clear all caches including the cache tables. + */ + void clearCache(sal_uInt16 nFileId); + + /** + * Clear all caches but keep the tables. All cache tables will be empty + * after the call, but the tables will not be removed. + */ + void clearCacheTables(sal_uInt16 nFileId); + + // Get the doc used to pass to methods that need an ScDocument in order to do row/col validation + const ScDocument& getDoc() const { return mrDoc; } + +private: + struct RangeHash + { + size_t operator()(const ScRange& rRange) const + { + const ScAddress& s = rRange.aStart; + const ScAddress& e = rRange.aEnd; + size_t hash = 17; + hash = hash * 37 + s.Tab(); + hash = hash * 37 + s.Col(); + hash = hash * 37 + s.Row(); + hash = hash * 37 + e.Tab(); + hash = hash * 37 + e.Col(); + hash = hash * 37 + e.Row(); + return hash; + } + }; + + typedef std::unordered_map<OUString, TokenArrayRef> RangeNameMap; + typedef std::unordered_map<ScRange, TokenArrayRef, RangeHash> RangeArrayMap; + typedef std::unordered_map<OUString, OUString> NamePairMap; + + /** Represents data cached for a single external document. */ + struct DocItem + { + /** The raw cache tables. */ + ::std::vector<TableTypeRef> maTables; + /** Table name list in correct order, in both upper- and real-case. */ + ::std::vector<TableName> maTableNames; + /** Table name to index map. The names must be stored upper-case. */ + TableNameIndexMap maTableNameIndex; + /** Range name cache. */ + RangeNameMap maRangeNames; + /** Token array cache for cell ranges. */ + RangeArrayMap maRangeArrays; + /** Upper- to real-case mapping for range names. */ + NamePairMap maRealRangeNameMap; + + /** Either the base name that was stored as sheet name for CSV files if + sheet name is Sheet1, or Sheet1 name if sheet name is base name. + */ + OUString maSingleTableNameAlias; + + bool mbInitFromSource; + + DocItem() : mbInitFromSource(false) {} + + TableNameIndexMap::const_iterator findTableNameIndex( const OUString& rTabName ) const; + bool getTableDataIndex( const OUString& rTabName, size_t& rIndex ) const; + bool getSingleTableNameAlternative( OUString& rTabName ) const; + }; + typedef std::unordered_map<sal_uInt16, DocItem> DocDataType; + DocItem* getDocItem(sal_uInt16 nFileId) const; + DocItem* getDocItem(std::unique_lock<std::mutex>& rGuard, sal_uInt16 nFileId) const; + +private: + mutable std::mutex maMtxDocs; + mutable DocDataType maDocs; + const ScDocument& mrDoc; +}; + +class SC_DLLPUBLIC ScExternalRefManager final : public formula::ExternalReferenceHelper, public SfxListener +{ +public: + + typedef std::set<ScFormulaCell*> RefCellSet; + typedef std::unordered_map<sal_uInt16, RefCellSet> RefCellMap; + + enum LinkUpdateType { LINK_MODIFIED, LINK_BROKEN, OH_NO_WE_ARE_GOING_TO_DIE }; + + /** + * Base class for objects that need to listen to link updates. When a + * link to a certain external file is updated, the notify() method gets + * called. + */ + class SAL_DLLPRIVATE LinkListener + { + public: + LinkListener(); + virtual ~LinkListener() COVERITY_NOEXCEPT_FALSE = 0; + virtual void notify(sal_uInt16 nFileId, LinkUpdateType eType) = 0; + }; + + /** + * Use this guard when performing something from the API that might query + * values from external references. Interpreting formula strings is one + * such example. + */ + class SC_DLLPUBLIC ApiGuard + { + public: + ApiGuard(const ScDocument& rDoc); + ~ApiGuard(); + private: + ScExternalRefManager* mpMgr; + bool mbOldInteractionEnabled; + }; + +private: + /** Shell instance for a source document. */ + struct SrcShell + { + SfxObjectShellRef maShell; + tools::Time maLastAccess; + + SrcShell() : maLastAccess( tools::Time::SYSTEM ) {} + }; + + typedef std::unordered_map<sal_uInt16, SrcShell> DocShellMap; + typedef std::unordered_map<sal_uInt16, bool> LinkedDocMap; + + typedef std::unordered_map<sal_uInt16, SvNumberFormatterMergeMap> NumFmtMap; + + typedef o3tl::sorted_vector<LinkListener*> LinkListeners; + typedef std::unordered_map<sal_uInt16, LinkListeners> LinkListenerMap; + +public: + /** Source document meta-data container. */ + struct SAL_DLLPRIVATE SrcFileData + { + OUString maFileName; /// original file name as loaded from the file. + OUString maRealFileName; /// file name created from the relative name. + OUString maRelativeName; + OUString maFilterName; + OUString maFilterOptions; + + void maybeCreateRealFileName(std::u16string_view rOwnDocName); + }; + +public: + explicit ScExternalRefManager(ScDocument& rDoc); + virtual ~ScExternalRefManager() override; + + virtual OUString getCacheTableName(sal_uInt16 nFileId, size_t nTabIndex) const override; + + /** + * Get a cache table instance for specified table and table index. Unlike + * the other method that takes a table name, this method does not create a + * new table when a table is not available for specified index. + * + * @param nFileId file ID + * @param nTabIndex cache table index + * + * @return shared_ptr to the cache table instance + */ + ScExternalRefCache::TableTypeRef getCacheTable(sal_uInt16 nFileId, size_t nTabIndex) const; + + /** + * Get a cache table instance for specified file and table name. If the + * table instance is not already present, it'll instantiate a new one and + * append it to the end of the table array. <I>It's important to be + * aware of this fact especially for multi-table ranges for which + * table orders are critical.</I> + * + * Excel filter calls this method to populate the cache table from the + * XCT/CRN records. ODF import calls it for cached tables for external + * references. + * + * @param nFileId file ID + * @param rTabName table name + * @param bCreateNew if true, create a new table instance if it's not + * already present. If false, it returns NULL if the + * specified table's cache doesn't exist. + * @param pnIndex if non-NULL pointer is passed, it stores the internal + * index of a cache table instance. + * @param pExtUrl if non-NULL and bCreateNew==true, the base name will be + * propagated as an alias for the first table (and removed + * later if further tables are created). + * + * @return shared_ptr to the cache table instance + */ + ScExternalRefCache::TableTypeRef getCacheTable(sal_uInt16 nFileId, const OUString& rTabName, bool bCreateNew, + size_t* pnIndex = nullptr, const OUString* pExtUrl = nullptr); + + /** Returns a vector containing all (real) table names and cache tables of + the specified file. + + The index in the returned vector corresponds to the table index used to + access the cache table, e.g. in getCacheTable(). + */ + void getAllCachedTableNames(sal_uInt16 nFileId, ::std::vector<OUString>& rTabNames) const; + + /** + * Get the span (distance+sign(distance)) of two sheets of a specified + * file. + * + * @param nFileId file ID + * @param rStartTabName name of first sheet (sheet1) + * @param rEndTabName name of second sheet (sheet2) + * + * @return span + * 1 if sheet2 == sheet1 + * > 1 if sheet2 > sheet1 + * < -1 if sheet2 < sheet1 + * -1 if nFileId or rStartTabName not found + * 0 if rEndTabName not found + */ + SCTAB getCachedTabSpan( + sal_uInt16 nFileId, const OUString& rStartTabName, const OUString& rEndTabName) const; + + /** + * Get all unique number format indices that are used in the cache tables. + * The retrieved indices are sorted in ascending order. + * + * @param rNumFmts (reference) all unique number format indices. + */ + void getAllCachedNumberFormats(::std::vector<sal_uInt32>& rNumFmts) const; + + sal_uInt16 getExternalFileCount() const; + + /** + * Mark all tables as referenced that are used by any LinkListener, used + * only during store-to-file. + */ + void markUsedByLinkListeners(); + + void markUsedExternalRefCells(); + + /** + * Set a table as referenced, used only during store-to-file. + * @returns <TRUE/> if ALL tables of ALL external documents are marked. + */ + bool setCacheTableReferenced( sal_uInt16 nFileId, const OUString& rTabName, size_t nSheets ); + void setAllCacheTableReferencedStati( bool bReferenced ); + + /** + * @returns <TRUE/> if setAllCacheTableReferencedStati(false) was called, + * <FALSE/> if setAllCacheTableReferencedStati(true) was called. + */ + bool isInReferenceMarking() const { return mbInReferenceMarking; } + + void storeRangeNameTokens(sal_uInt16 nFileId, const OUString& rName, const ScTokenArray& rArray); + + ScExternalRefCache::TokenRef getSingleRefToken( + sal_uInt16 nFileId, const OUString& rTabName, const ScAddress& rCell, + const ScAddress* pCurPos, SCTAB* pTab, ScExternalRefCache::CellFormat* pFmt = nullptr); + + /** + * Get an array of tokens that consist of the specified external cell + * range. + * + * @param nFileId file ID for an external document + * @param rTabName referenced sheet name + * @param rRange referenced cell range + * @param pCurPos current cursor position to keep track of cells that + * reference an external data. + * + * @return shared_ptr to a token array instance. <i>The caller must not + * delete the instance returned by this method.</i> + */ + ScExternalRefCache::TokenArrayRef getDoubleRefTokens( + sal_uInt16 nFileId, const OUString& rTabName, const ScRange& rRange, const ScAddress* pCurPos); + + /** + * Get an array of tokens corresponding with a specified name in a + * specified file. + * + * @param pCurPos current cell address where this name token is used. + * This is purely to keep track of all cells containing + * external names for refreshing purposes. If this is + * NULL, then the cell will not be added to the list. + * + * @return shared_ptr to array of tokens composing the name + */ + ScExternalRefCache::TokenArrayRef getRangeNameTokens( + sal_uInt16 nFileId, const OUString& rName, const ScAddress* pCurPos = nullptr); + + bool isValidRangeName(sal_uInt16 nFileId, const OUString& rName); + + OUString getOwnDocumentName() const; + bool isOwnDocument(std::u16string_view rFile) const; + + /** + * Takes a flat file name, and convert it to an absolute URL path. An + * absolute URL path begins with 'file:///. + * + * @param rFile file name to convert + */ + void convertToAbsName(OUString& rFile) const; + sal_uInt16 getExternalFileId(const OUString& rFile); + + /** + * It returns a pointer to the name of the URI associated with a given + * external file ID. In case the original document has moved, it returns + * a URI adjusted for the relocation. + * + * @param nFileId file ID for an external document + * @param bForceOriginal If true, it always returns the original document + * URI even if the referring document has relocated. + * If false, it returns a URI adjusted for + * relocated document. + * + * @return const OUString* external document URI. + */ + const OUString* getExternalFileName(sal_uInt16 nFileId, bool bForceOriginal = false); + + /** + * Reindex external file references to skip unused files, if skipping is enabled. + */ + sal_uInt16 convertFileIdToUsedFileId(sal_uInt16 nFileId); + void setSkipUnusedFileIds(std::vector<sal_uInt16>& pExternFileIds); + void disableSkipUnusedFileIds(); + + /** + * Get all cached external file names as an array. Array indices of the + * returned name array correspond with external file ID's. + */ + std::vector<OUString> getAllCachedExternalFileNames() const; + + bool hasExternalFile(sal_uInt16 nFileId) const; + bool hasExternalFile(const OUString& rFile) const; + const SrcFileData* getExternalFileData(sal_uInt16 nFileId) const; + + const OUString* getRealTableName(sal_uInt16 nFileId, const OUString& rTabName) const; + const OUString* getRealRangeName(sal_uInt16 nFileId, const OUString& rRangeName) const; + void clearCache(sal_uInt16 nFileId); + bool refreshSrcDocument(sal_uInt16 nFileId); + void breakLink(sal_uInt16 nFileId); + void switchSrcFile(sal_uInt16 nFileId, const OUString& rNewFile, const OUString& rNewFilter); + + /** + * Set a relative file path for the specified file ID. Note that the + * caller must ensure that the passed URL is a valid relative URL. + * + * @param nFileId file ID for an external document + * @param rRelUrl relative URL + */ + void setRelativeFileName(sal_uInt16 nFileId, const OUString& rRelUrl); + + /** + * Set the filter name and options if any for a given source document. + * These values get reset when the source document ever gets reloaded. + * + * @param nFileId + * @param rFilterName + * @param rOptions + */ + void setFilterData(sal_uInt16 nFileId, const OUString& rFilterName, const OUString& rOptions); + + void clear(); + + bool hasExternalData() const; + + /** + * Re-generates relative names for all stored source files. This is + * necessary when exporting to an ods document, to ensure that all source + * files have their respective relative names for xlink:href export. + * + * @param rBaseFileUrl Absolute URL of the content.xml fragment of the + * document being exported. + */ + void resetSrcFileData(const OUString& rBaseFileUrl); + + /** + * Replace the original URL with the real URL that was generated from the relative URL. + */ + void updateAbsAfterLoad(); + + /** + * Stop tracking a specific formula cell. + * + * @param pCell pointer to cell that formerly contained external + * reference. + */ + void removeRefCell(ScFormulaCell* pCell); + + /** + * Register a new link listener to a specified external document. Note + * that the caller is responsible for managing the life cycle of the + * listener object. + */ + void addLinkListener(sal_uInt16 nFileId, LinkListener* pListener); + + /** + * Remove an existing link listener. Note that removing a listener + * pointer here does not delete the listener object instance. + */ + void removeLinkListener(sal_uInt16 nFileId, LinkListener* pListener); + + void removeLinkListener(LinkListener* pListener); + + /** + * Notify all listeners that are listening to a specified external + * document. + * + * @param nFileId file ID for an external document. + */ + void notifyAllLinkListeners(sal_uInt16 nFileId, LinkUpdateType eType); + + /** + * Check if the file specified by the path is a legitimate file that + * exists & can be loaded. + */ + bool isFileLoadable(const OUString& rFile) const; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + /** + * If we still contain unsaved files we should warn the user before saving + * + * @return true if the document still contains references to an unsaved file + */ + bool containsUnsavedReferences() const { return !maUnsavedDocShells.empty(); } + + void insertRefCell(sal_uInt16 nFileId, const ScAddress& rCell); + /** + * Add a cell to reference the same files as the template cell. + */ + void insertRefCellFromTemplate( ScFormulaCell* pTemplateCell, ScFormulaCell* pCell ); + + bool hasCellExternalReference(const ScAddress& rCell); + + void enableDocTimer( bool bEnable ); + + /** Add all known external files to the LinkManager. */ + void addFilesToLinkManager(); + +private: + ScExternalRefManager(const ScExternalRefManager&) = delete; + + void refreshAllRefCells(sal_uInt16 nFileId); + + void fillCellFormat(sal_uLong nFmtIndex, ScExternalRefCache::CellFormat* pFmt) const; + + bool getSrcDocTable( const ScDocument& rSrcDoc, const OUString& rTabName, SCTAB& rTab, sal_uInt16 nFileId ) const; + + ScExternalRefCache::TokenRef getSingleRefTokenFromSrcDoc( + sal_uInt16 nFileId, ScDocument& rSrcDoc, const ScAddress& rPos, + ScExternalRefCache::CellFormat* pFmt); + + /** + * Retrieve a range token array from a source document instance. + * + * @param rSrcDoc reference to the source document instance. + * @param rTabName name of the first table. + * @param rRange range specified. Upon successful retrieval, this range + * gets modified to contain the correct table IDs, and in + * case the range is larger than the data area of the source + * document, it gets reduced to the data area. + * @param rCacheData an array of structs, with each struct containing the + * table name and the data in the specified range. + * + * @return range token array + */ + ScExternalRefCache::TokenArrayRef getDoubleRefTokensFromSrcDoc( + const ScDocument& rSrcDoc, const OUString& rTabName, ScRange& rRange, + ::std::vector<ScExternalRefCache::SingleRangeData>& rCacheData); + + /** + * Retrieve range name token array from a source document instance. + * + * @param nFileId file ID of the source document. + * @param rSrcDoc reference to the source document instance + * @param rName range name to retrieve. Note that the range name lookup + * is case <i>in</i>-sensitive, and upon successful retrieval + * of the range name array, this name gets updated to the + * actual range name with the correct casing. + * + * @return range name token array + */ + static ScExternalRefCache::TokenArrayRef getRangeNameTokensFromSrcDoc( + sal_uInt16 nFileId, const ScDocument& rSrcDoc, OUString& rName); + + ScDocument* getInMemorySrcDocument(sal_uInt16 nFileId); + ScDocument* getSrcDocument(sal_uInt16 nFileId); + SfxObjectShellRef loadSrcDocument(sal_uInt16 nFileId, OUString& rFilter); + + /** + * Caller must ensure that the passed shell is not already stored. + */ + ScDocument& cacheNewDocShell( sal_uInt16 nFileId, SrcShell& rSrcShell ); + + void maybeLinkExternalFile( sal_uInt16 nFileId, bool bDeferFilterDetection = false ); + + /** + * Try to create a "real" file name from the relative path. The original + * file name may not point to the real document when the referencing and + * referenced documents have been moved. + * + * For the real file name to be created, the relative name should not be + * empty before calling this method, or the real file name will not be + * created. + * + * @param nFileId file ID for an external document + */ + void maybeCreateRealFileName(sal_uInt16 nFileId); + + /** + * Purge those source document instances that have not been accessed for + * the specified duration. + * + * @param nTimeOut time out value in 100th of a second + */ + void purgeStaleSrcDocument(sal_Int32 nTimeOut); + + sal_uInt32 getMappedNumberFormat(sal_uInt16 nFileId, sal_uInt32 nNumFmt, const ScDocument& rSrcDoc); + + /** + * If in maUnsavedDocShells move it to maDocShells and create a correct + * external reference entry + * + * @param Pointer to the newly saved DocumentShell + */ + void transformUnsavedRefToSavedRef( SfxObjectShell* pShell ); + +private: + ScDocument& mrDoc; + + /** cache of referenced ranges and names from source documents. */ + ScExternalRefCache maRefCache; + + /** + * Source document cache. This stores the original source document shell + * instances. They get purged after a certain period of time. + */ + DocShellMap maDocShells; + + /** + * DocShells to unsaved but referenced documents. If not empty ask before saving! + * Move to maDocShells if document referenced here is saved + */ + DocShellMap maUnsavedDocShells; + + /** list of source documents that are managed by the link manager. */ + LinkedDocMap maLinkedDocs; + + /** + * List of referencing cells that may contain external names. There is + * one list per source document. + */ + RefCellMap maRefCells; + + LinkListenerMap maLinkListeners; + + NumFmtMap maNumFormatMap; + + /** + * List of external source document meta-data, used to keep track of + * external document identifiers. + */ + std::vector<SrcFileData> maSrcFiles; + + /** Status whether in reference marking state. See isInReferenceMarking(). */ + bool mbInReferenceMarking:1; + + /** + * Controls whether or not to allow user interaction. We don't want any + * user interaction when calling from the API. + */ + bool mbUserInteractionEnabled:1; + + bool mbSkipUnusedFileIds = false; + std::vector<sal_uInt16> maConvertFileIdToUsedFileId; + + bool mbDocTimerEnabled:1; + + AutoTimer maSrcDocTimer; + DECL_DLLPRIVATE_LINK(TimeOutHdl, Timer*, void); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/fielduno.hxx b/sc/inc/fielduno.hxx new file mode 100644 index 0000000000..82c9a04ebb --- /dev/null +++ b/sc/inc/fielduno.hxx @@ -0,0 +1,243 @@ +/* -*- 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 "address.hxx" + +#include <svl/lstner.hxx> +#include <editeng/editdata.hxx> +#include <com/sun/star/text/XTextField.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/container/XContainer.hpp> +#include <com/sun/star/container/XEnumerationAccess.hpp> +#include <com/sun/star/container/XIndexAccess.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/util/XRefreshable.hpp> +#include <com/sun/star/util/DateTime.hpp> +#include <comphelper/interfacecontainer4.hxx> +#include <comphelper/servicehelper.hxx> +#include <cppuhelper/implbase.hxx> +#include <comphelper/compbase.hxx> +#include <osl/mutex.hxx> + +#include <memory> + +class ScEditSource; +class SvxFieldItem; +class SvxFieldData; +class ScDocShell; +class ScHeaderFooterTextData; +class SfxItemPropertySet; + +class ScCellFieldsObj final : public cppu::WeakImplHelper< + css::container::XEnumerationAccess, + css::container::XIndexAccess, + css::container::XContainer, + css::util::XRefreshable, + css::lang::XServiceInfo >, + public SfxListener +{ +private: + css::uno::Reference<css::text::XTextRange> mxContent; + ScDocShell* pDocShell; + ScAddress aCellPos; + std::unique_ptr<ScEditSource> mpEditSource; + /// List of refresh listeners. + comphelper::OInterfaceContainerHelper4<css::util::XRefreshListener> maRefreshListeners; + /// mutex to lock the InterfaceContainerHelper + std::mutex aMutex; + + css::uno::Reference<css::text::XTextField> + GetObjectByIndex_Impl(sal_Int32 Index) const; + +public: + ScCellFieldsObj( + css::uno::Reference<css::text::XTextRange> xContent, + ScDocShell* pDocSh, const ScAddress& rPos); + virtual ~ScCellFieldsObj() override; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + // XIndexAccess + virtual sal_Int32 SAL_CALL getCount() override; + virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override; + + // XEnumerationAccess + virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL + createEnumeration() override; + + // XElementAccess + virtual css::uno::Type SAL_CALL getElementType() override; + virtual sal_Bool SAL_CALL hasElements() override; + + // XContainer + virtual void SAL_CALL addContainerListener( const css::uno::Reference< css::container::XContainerListener >& xListener ) override; + virtual void SAL_CALL removeContainerListener( const css::uno::Reference< css::container::XContainerListener >& xListener ) override; + + // XRefreshable + virtual void SAL_CALL refresh( ) override; + virtual void SAL_CALL addRefreshListener( const css::uno::Reference< css::util::XRefreshListener >& l ) override; + virtual void SAL_CALL removeRefreshListener( const css::uno::Reference< css::util::XRefreshListener >& l ) override; + + // XServiceInfo + 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; +}; + +class ScHeaderFieldsObj final : public cppu::WeakImplHelper< + css::container::XEnumerationAccess, + css::container::XIndexAccess, + css::container::XContainer, + css::util::XRefreshable, + css::lang::XServiceInfo > +{ +private: + ScHeaderFooterTextData& mrData; + std::unique_ptr<ScEditSource> mpEditSource; + + /// List of refresh listeners. + comphelper::OInterfaceContainerHelper4<css::util::XRefreshListener> maRefreshListeners; + /// mutex to lock the InterfaceContainerHelper + std::mutex aMutex; + + css::uno::Reference< css::text::XTextField> + GetObjectByIndex_Impl(sal_Int32 Index) const; + +public: + ScHeaderFieldsObj(ScHeaderFooterTextData& rData); + virtual ~ScHeaderFieldsObj() override; + + // XIndexAccess + virtual sal_Int32 SAL_CALL getCount() override; + virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override; + + // XEnumerationAccess + virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL + createEnumeration() override; + + // XElementAccess + virtual css::uno::Type SAL_CALL getElementType() override; + virtual sal_Bool SAL_CALL hasElements() override; + + // XContainer + virtual void SAL_CALL addContainerListener( const css::uno::Reference< css::container::XContainerListener >& xListener ) override; + virtual void SAL_CALL removeContainerListener( const css::uno::Reference< css::container::XContainerListener >& xListener ) override; + + // XRefreshable + virtual void SAL_CALL refresh( ) override; + virtual void SAL_CALL addRefreshListener( const css::uno::Reference< css::util::XRefreshListener >& l ) override; + virtual void SAL_CALL removeRefreshListener( const css::uno::Reference< css::util::XRefreshListener >& l ) override; + + // XServiceInfo + 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; +}; + +/** + * Generic UNO wrapper for edit engine's field item in cells, headers, and + * footers. + */ +typedef comphelper::WeakComponentImplHelper< + css::text::XTextField, + css::beans::XPropertySet, + css::lang::XServiceInfo> ScEditFieldObj_Base; +class ScEditFieldObj final : public ScEditFieldObj_Base +{ + ScEditFieldObj() = delete; + ScEditFieldObj(const ScEditFieldObj&) = delete; + const ScEditFieldObj& operator=(const ScEditFieldObj&) = delete; + + const SfxItemPropertySet* pPropSet; + std::unique_ptr<ScEditSource> mpEditSource; + ESelection aSelection; + + sal_Int32 meType; + std::unique_ptr<SvxFieldData> mpData; + css::uno::Reference<css::text::XTextRange> mpContent; + + css::util::DateTime maDateTime; + sal_Int32 mnNumFormat; + bool mbIsDate:1; + bool mbIsFixed:1; + +private: + SvxFieldData& getData(); + + void setPropertyValueURL(const OUString& rName, const css::uno::Any& rVal); + css::uno::Any getPropertyValueURL(const OUString& rName); + + void setPropertyValueFile(const OUString& rName, const css::uno::Any& rVal); + css::uno::Any getPropertyValueFile(const OUString& rName); + + void setPropertyValueDateTime(const OUString& rName, const css::uno::Any& rVal); + css::uno::Any getPropertyValueDateTime(const OUString& rName); + + void setPropertyValueSheet(const OUString& rName, const css::uno::Any& rVal); + +public: + ScEditFieldObj( + css::uno::Reference<css::text::XTextRange> xContent, + std::unique_ptr<ScEditSource> pEditSrc, sal_Int32 eType, const ESelection& rSel); + virtual ~ScEditFieldObj() override; + + sal_Int32 GetFieldType() const { return meType;} + void DeleteField(); + bool IsInserted() const; + SvxFieldItem CreateFieldItem(); + void InitDoc( + const css::uno::Reference<css::text::XTextRange>& rContent, + std::unique_ptr<ScEditSource> pEditSrc, const ESelection& rSel); + + // XTextField + virtual OUString SAL_CALL getPresentation( sal_Bool bShowCommand ) override; + + // XTextContent + virtual void SAL_CALL attach( const css::uno::Reference< css::text::XTextRange >& xTextRange ) override; + virtual css::uno::Reference< css::text::XTextRange > SAL_CALL + getAnchor() override; + + // XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > + SAL_CALL getPropertySetInfo() override; + virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, + const css::uno::Any& aValue ) override; + virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override; + virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override; + virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override; + virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + + // XServiceInfo + 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; + + // XTypeProvider + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; + virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/fillinfo.hxx b/sc/inc/fillinfo.hxx new file mode 100644 index 0000000000..81086ed358 --- /dev/null +++ b/sc/inc/fillinfo.hxx @@ -0,0 +1,291 @@ +/* -*- 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 <sal/config.h> + +#include <memory> + +#include <svx/framelinkarray.hxx> +#include "colorscale.hxx" +#include "cellvalue.hxx" +#include <o3tl/typed_flags_set.hxx> +#include <optional> + +class SfxItemSet; +class SvxBrushItem; +class SvxBoxItem; +class SvxLineItem; +class SvxShadowItem; + +class ScPatternAttr; + +enum class ScRotateDir : sal_uInt8 { + NONE, Standard, Left, Right, Center +}; + +enum class ScClipMark : sal_uInt8 { + NONE = 0x00, Left = 0x01, Right = 0x02, Bottom = 0x03, Top = 0x04 +}; +namespace o3tl { + template<> struct typed_flags<ScClipMark> : is_typed_flags<ScClipMark, 0x07> {}; +} + +const sal_uInt8 SC_CLIPMARK_SIZE = 64; + +enum ScShadowPart +{ + SC_SHADOW_HSTART, + SC_SHADOW_VSTART, + SC_SHADOW_HORIZ, + SC_SHADOW_VERT, + SC_SHADOW_CORNER +}; + +struct ScDataBarInfo +{ + double mnZero; // 0 to 100 + Color maColor; + double mnLength; // -100 to 100 + bool mbGradient; + bool mbShowValue; + Color maAxisColor; + + bool operator==(const ScDataBarInfo& r) const + { + if( mnZero != r.mnZero ) + return false; + if( maColor != r.maColor ) + return false; + if(mnLength != r.mnLength) + return false; + if (mbGradient != r.mbGradient) + return false; + + return true; + } + + bool operator!=(const ScDataBarInfo& r) const + { + return !(*this == r); + } +}; + +struct ScIconSetInfo +{ + sal_Int32 nIconIndex; + ScIconSetType eIconSetType; + tools::Long mnHeight = 0; + bool mbShowValue; +}; + +// FillInfo() computes some info for all cells starting from column 0, +// but most of the info is needed only for cells in the given columns. +// Keeping all the info in ScCellInfo could lead to allocation and initialization +// of MiB's of memory, so split the info needed for all cells to a smaller structure. +struct ScBasicCellInfo +{ + ScBasicCellInfo() + : nWidth(0) + , bEmptyCellText(true) + , bEditEngine(false) // view-internal + {} + sal_uInt16 nWidth; + bool bEmptyCellText : 1; + bool bEditEngine : 1; // output-internal +}; + +struct ScCellInfo +{ + ScCellInfo() + : pPatternAttr(nullptr) + , pConditionSet(nullptr) + , pDataBar(nullptr) + , pIconSet(nullptr) + , pBackground(nullptr) // TODO: omit? + , pLinesAttr(nullptr) + , mpTLBRLine(nullptr) + , mpBLTRLine(nullptr) + , pShadowAttr(nullptr) + , pHShadowOrigin(nullptr) + , pVShadowOrigin(nullptr) + , eHShadowPart(SC_SHADOW_HSTART) + , eVShadowPart(SC_SHADOW_HSTART) + , nClipMark(ScClipMark::NONE) + , nRotateDir(ScRotateDir::NONE) + , bMerged(false) + , bHOverlapped(false) + , bVOverlapped(false) + , bAutoFilter(false) + , bPivotButton(false) + , bPivotPopupButton(false) + , bFilterActive(false) + , bPrinted(false) // view-internal + , bHideGrid(false) // view-internal + , bPivotCollapseButton(false) + , bPivotExpandButton(false) + , bPivotPopupButtonMulti(false) + { + } + + ScCellInfo(const ScCellInfo&) = delete; + const ScCellInfo& operator=(const ScCellInfo&) = delete; + + ScRefCellValue maCell; + + const ScPatternAttr* pPatternAttr; + const SfxItemSet* pConditionSet; + std::optional<Color> mxColorScale; + const ScDataBarInfo* pDataBar; + const ScIconSetInfo* pIconSet; + + const SvxBrushItem* pBackground; + + const SvxBoxItem* pLinesAttr; /// original item from document. + const SvxLineItem* mpTLBRLine; /// original item from document. + const SvxLineItem* mpBLTRLine; /// original item from document. + + const SvxShadowItem* pShadowAttr; // original item (internal) + + const SvxShadowItem* pHShadowOrigin; + const SvxShadowItem* pVShadowOrigin; + + ScShadowPart eHShadowPart : 4; // shadow effective for drawing + ScShadowPart eVShadowPart : 4; + ScClipMark nClipMark; + ScRotateDir nRotateDir; + + bool bMerged : 1; + bool bHOverlapped : 1; + bool bVOverlapped : 1; + bool bAutoFilter : 1; + bool bPivotButton:1; + bool bPivotPopupButton:1; + bool bFilterActive:1; + bool bPrinted : 1; // when required (pagebreak mode) + bool bHideGrid : 1; // output-internal + bool bPivotCollapseButton : 1; // dp compact layout collapse button + bool bPivotExpandButton : 1; // dp compact layout expand button + bool bPivotPopupButtonMulti : 1; // dp button with popup arrow for multiple fields +}; + +const SCCOL SC_ROTMAX_NONE = SCCOL_MAX; + +struct RowInfo +{ + RowInfo() = default; + RowInfo(const RowInfo&) = delete; + const RowInfo& operator=(const RowInfo&) = delete; + + ScCellInfo& cellInfo(SCCOL nCol) + { + assert( nCol >= nStartCol - 1 ); +#ifdef DBG_UTIL + assert( nCol <= nEndCol + 1 ); +#endif + return pCellInfo[ nCol - nStartCol + 1 ]; + } + const ScCellInfo& cellInfo(SCCOL nCol) const + { + return const_cast<RowInfo*>(this)->cellInfo(nCol); + } + + ScBasicCellInfo& basicCellInfo(SCCOL nCol) + { + assert( nCol >= -1 ); +#ifdef DBG_UTIL + assert( nCol <= nEndCol + 1 ); +#endif + return pBasicCellInfo[ nCol + 1 ]; + } + const ScBasicCellInfo& basicCellInfo(SCCOL nCol) const + { + return const_cast<RowInfo*>(this)->basicCellInfo(nCol); + } + + void allocCellInfo(SCCOL startCol, SCCOL endCol) + { + nStartCol = startCol; +#ifdef DBG_UTIL + nEndCol = endCol; +#endif + pCellInfo = new ScCellInfo[ endCol - nStartCol + 1 + 2 ]; + pBasicCellInfo = new ScBasicCellInfo[ endCol + 1 + 2 ]; + } + void freeCellInfo() + { + delete[] pCellInfo; + delete[] pBasicCellInfo; + } + + sal_uInt16 nHeight; + SCROW nRowNo; + SCCOL nRotMaxCol; // SC_ROTMAX_NONE, if nothing + + bool bEmptyBack:1; + bool bAutoFilter:1; + bool bPivotButton:1; + bool bChanged:1; // TRUE, if not tested + bool bPivotToggle:1; + +private: + // This class allocates ScCellInfo with also one item extra before and after. + // To make handling easier, this is private and access functions take care of adjusting + // the array indexes and error-checking. ScCellInfo is allocated only for a given + // range of columns plus one on each side, ScBasicCellInfo is allocated for columns + // starting from column 0 until the last column given, again plus one on each side. + ScCellInfo* pCellInfo; + ScBasicCellInfo* pBasicCellInfo; + SCCOL nStartCol; +#ifdef DBG_UTIL + SCCOL nEndCol; +#endif +}; + +struct ScTableInfo +{ + svx::frame::Array maArray; + std::unique_ptr<RowInfo[]> + mpRowInfo; + SCSIZE mnArrCount; + SCSIZE mnArrCapacity; + bool mbPageMode; + + explicit ScTableInfo(const SCSIZE capacity = 1024); + ~ScTableInfo(); + ScTableInfo(const ScTableInfo&) = delete; + const ScTableInfo& operator=(const ScTableInfo&) = delete; + + void addDataBarInfo(std::unique_ptr<const ScDataBarInfo> info) + { + mDataBarInfos.push_back(std::move(info)); + } + void addIconSetInfo(std::unique_ptr<const ScIconSetInfo> info) + { + mIconSetInfos.push_back(std::move(info)); + } +private: + // These are owned here and not in ScCellInfo to avoid freeing + // memory for every pointer in ScCellInfo, most of which are nullptr. + std::vector<std::unique_ptr<const ScDataBarInfo>> mDataBarInfos; + std::vector<std::unique_ptr<const ScIconSetInfo>> mIconSetInfos; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/filter.hxx b/sc/inc/filter.hxx new file mode 100644 index 0000000000..6bceb74b69 --- /dev/null +++ b/sc/inc/filter.hxx @@ -0,0 +1,107 @@ +/* -*- 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 <rtl/textenc.h> +#include <rtl/ustring.hxx> +#include <comphelper/errcode.hxx> + +#include "scdllapi.h" +#include <memory> + +class SfxMedium; +class SvStream; + +class ScAddress; +class ScDocument; +class ScRange; +class SvNumberFormatter; +class ScOrcusFilters; + +// for import +enum EXCIMPFORMAT { EIF_AUTO, EIF_BIFF5, EIF_BIFF8, EIF_BIFF_LE4 }; + +// for export +enum ExportFormatExcel { ExpBiff5, ExpBiff8 }; + +// These are implemented inside the scfilt library and lazy loaded + +class ScEEAbsImport { + public: + virtual ~ScEEAbsImport() {} + virtual ErrCode Read( SvStream& rStream, const OUString& rBaseURL ) = 0; + virtual ScRange GetRange() = 0; + virtual void WriteToDocument( + bool bSizeColsRows = false, double nOutputFactor = 1.0, + SvNumberFormatter* pFormatter = nullptr, bool bConvertDate = true, + bool bConvertScientific = true ) = 0; +}; + +class SAL_DLLPUBLIC_RTTI ScFormatFilterPlugin { + public: + // various import filters + virtual ErrCode ScImportLotus123( SfxMedium&, ScDocument&, rtl_TextEncoding eSrc ) = 0; + virtual ErrCode ScImportQuattroPro(SvStream* pStream, ScDocument& rDoc) = 0; + virtual ErrCode ScImportExcel( SfxMedium&, ScDocument*, const EXCIMPFORMAT ) = 0; + // eFormat == EIF_AUTO -> matching filter is used automatically + // eFormat == EIF_BIFF5 -> only Biff5 stream is read successfully (in an Excel97 doc, too) + // eFormat == EIF_BIFF8 -> only Biff8 stream is read successfully (only in Excel97 docs) + // eFormat == EIF_BIFF_LE4 -> only non storage files _might_ be read successfully + virtual ErrCode ScImportDif( SvStream&, ScDocument*, const ScAddress& rInsPos, + const rtl_TextEncoding eSrc ) = 0; + virtual ErrCode ScImportRTF( SvStream&, const OUString& rBaseURL, ScDocument*, ScRange& rRange ) = 0; + virtual ErrCode ScImportHTML( SvStream&, const OUString& rBaseURL, ScDocument*, ScRange& rRange, double nOutputFactor, + bool bCalcWidthHeight, SvNumberFormatter* pFormatter, bool bConvertDate, + bool bConvertScientific ) = 0; + + // various import helpers + virtual std::unique_ptr<ScEEAbsImport> CreateRTFImport( ScDocument* pDoc, const ScRange& rRange ) = 0; + virtual std::unique_ptr<ScEEAbsImport> CreateHTMLImport( ScDocument* pDocP, const OUString& rBaseURL, const ScRange& rRange ) = 0; + virtual OUString GetHTMLRangeNameList( ScDocument& rDoc, const OUString& rOrigName ) = 0; + + // various export filters + virtual ErrCode ScExportExcel5( SfxMedium&, ScDocument*, ExportFormatExcel eFormat, rtl_TextEncoding eDest ) = 0; + virtual void ScExportDif( SvStream&, ScDocument*, const ScAddress& rOutPos, const rtl_TextEncoding eDest ) = 0; + virtual void ScExportDif( SvStream&, ScDocument*, const ScRange& rRange, const rtl_TextEncoding eDest ) = 0; + virtual void ScExportHTML( SvStream&, const OUString& rBaseURL, ScDocument*, const ScRange& rRange, const rtl_TextEncoding eDest, bool bAll, + const OUString& rStreamPath, OUString& rNonConvertibleChars, const OUString& rFilterOptions ) = 0; + virtual void ScExportRTF( SvStream&, ScDocument*, const ScRange& rRange, const rtl_TextEncoding eDest ) = 0; + + virtual ScOrcusFilters* GetOrcusFilters() = 0; + +protected: + ~ScFormatFilterPlugin() {} +}; + +// scfilt plugin symbol +extern "C" { + SAL_DLLPUBLIC_EXPORT ScFormatFilterPlugin * ScFilterCreate(); +} + +class ScFormatFilter { + public: + SC_DLLPUBLIC static ScFormatFilterPlugin &Get(); +}; + +struct LotusContext; + +ErrCode ScImportLotus123old(LotusContext& rContext, SvStream&, rtl_TextEncoding eSrc); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/filterentries.hxx b/sc/inc/filterentries.hxx new file mode 100644 index 0000000000..02110c879b --- /dev/null +++ b/sc/inc/filterentries.hxx @@ -0,0 +1,46 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * 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/. + */ + +#pragma once + +#include <sal/config.h> +#include "typedstrdata.hxx" +#include <vector> +#include <tools/color.hxx> + +struct ScFilterEntries +{ + std::vector<ScTypedStrData> maStrData; + bool mbHasDates; + bool mbHasEmpties; + std::set<Color> maTextColors; + std::set<Color> maBackgroundColors; + + ScFilterEntries() : mbHasDates(false), mbHasEmpties(false) {} + + std::vector<ScTypedStrData>::iterator begin() { return maStrData.begin(); } + std::vector<ScTypedStrData>::iterator end() { return maStrData.end(); } + std::vector<ScTypedStrData>::const_iterator begin() const { return maStrData.begin(); } + std::vector<ScTypedStrData>::const_iterator end() const { return maStrData.end(); } + std::vector<ScTypedStrData>::size_type size() const { return maStrData.size(); } + ScTypedStrData& front() { return maStrData.front(); } + const ScTypedStrData& front() const { return maStrData.front(); } + bool empty() const { return maStrData.empty(); } + void push_back( const ScTypedStrData& r ) { maStrData.push_back(r); } + void push_back( ScTypedStrData&& r ) { maStrData.push_back(r); } + std::set<Color>& getTextColors() { return maTextColors; }; + void addTextColor(const Color& aTextColor) { maTextColors.emplace(aTextColor); } + std::set<Color>& getBackgroundColors() { return maBackgroundColors; }; + void addBackgroundColor(const Color& aBackgroundColor) + { + maBackgroundColors.emplace(aBackgroundColor); + } +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/sc/inc/filtopt.hxx b/sc/inc/filtopt.hxx new file mode 100644 index 0000000000..50dfdfbbf3 --- /dev/null +++ b/sc/inc/filtopt.hxx @@ -0,0 +1,42 @@ +/* -*- 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 <unotools/configitem.hxx> +#include "scdllapi.h" + +// filter options + +class SC_DLLPUBLIC ScFilterOptions final : public utl::ConfigItem +{ +private: + bool bWK3Flag; + + virtual void ImplCommit() override; + +public: + ScFilterOptions(); + + virtual void Notify( const css::uno::Sequence<OUString>& aPropertyNames ) override; + + bool GetWK3Flag() const { return bWK3Flag; } +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/filtuno.hxx b/sc/inc/filtuno.hxx new file mode 100644 index 0000000000..100fdeb001 --- /dev/null +++ b/sc/inc/filtuno.hxx @@ -0,0 +1,78 @@ +/* -*- 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/beans/XPropertyAccess.hpp> +#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> +#include <com/sun/star/document/XImporter.hpp> +#include <com/sun/star/document/XExporter.hpp> +#include <com/sun/star/lang/XInitialization.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <cppuhelper/implbase.hxx> + +namespace com::sun::star::io { class XInputStream; } +namespace com::sun::star::awt { class XWindow; } + +class ScFilterOptionsObj final : public ::cppu::WeakImplHelper< + css::beans::XPropertyAccess, + css::ui::dialogs::XExecutableDialog, + css::document::XImporter, + css::document::XExporter, + css::lang::XInitialization, + css::lang::XServiceInfo > +{ +private: + OUString aFileName; + OUString aFilterName; + OUString aFilterOptions; + css::uno::Reference< css::io::XInputStream > xInputStream; + css::uno::Reference< css::awt::XWindow > xDialogParent; + bool bExport; + +public: + ScFilterOptionsObj(); + virtual ~ScFilterOptionsObj() override; + + // XPropertyAccess + virtual css::uno::Sequence< css::beans::PropertyValue > + SAL_CALL getPropertyValues() override; + virtual void SAL_CALL setPropertyValues( const css::uno::Sequence< + css::beans::PropertyValue >& aProps ) override; + + // XExecutableDialog + virtual void SAL_CALL setTitle( const OUString& aTitle ) override; + virtual sal_Int16 SAL_CALL execute() override; + + // XImporter + virtual void SAL_CALL setTargetDocument( const css::uno::Reference< css::lang::XComponent >& xDoc ) override; + + // XExporter + virtual void SAL_CALL setSourceDocument( const css::uno::Reference< css::lang::XComponent >& xDoc ) override; + + // XInitialization + virtual void SAL_CALL initialize(const css::uno::Sequence<css::uno::Any>& rArguments) override; + + // XServiceInfo + 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; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/fmtuno.hxx b/sc/inc/fmtuno.hxx new file mode 100644 index 0000000000..548ca3ec93 --- /dev/null +++ b/sc/inc/fmtuno.hxx @@ -0,0 +1,234 @@ +/* -*- 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 <vector> + +#include <formula/grammar.hxx> +#include <rtl/ref.hxx> +#include <svl/itemprop.hxx> +#include <com/sun/star/sheet/XSheetConditionalEntries.hpp> +#include <com/sun/star/sheet/XSheetCondition2.hpp> +#include <com/sun/star/sheet/XSheetConditionalEntry.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/container/XNameAccess.hpp> +#include <com/sun/star/container/XEnumerationAccess.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> + +#include <com/sun/star/sheet/XMultiFormulaTokens.hpp> +#include <com/sun/star/sheet/FormulaToken.hpp> +#include <comphelper/servicehelper.hxx> +#include <cppuhelper/implbase.hxx> + +#include "address.hxx" +#include "conditio.hxx" + +class ScDocument; +class ScTableConditionalEntry; +class ScValidationData; + +struct ScCondFormatEntryItem +{ + css::uno::Sequence< css::sheet::FormulaToken > maTokens1; + css::uno::Sequence< css::sheet::FormulaToken > maTokens2; + OUString maExpr1; + OUString maExpr2; + OUString maExprNmsp1; + OUString maExprNmsp2; + OUString maPosStr; // formula position as text + OUString maStyle; // display name as stored in ScStyleSheet + ScAddress maPos; + formula::FormulaGrammar::Grammar meGrammar1; // grammar used with maExpr1 + formula::FormulaGrammar::Grammar meGrammar2; // grammar used with maExpr2 + ScConditionMode meMode; + + // Make sure the grammar is initialized for API calls. + ScCondFormatEntryItem(); +}; + +class ScTableConditionalFormat final : public cppu::WeakImplHelper< + css::sheet::XSheetConditionalEntries, + css::container::XNameAccess, + css::container::XEnumerationAccess, + css::lang::XServiceInfo > +{ +private: + std::vector<rtl::Reference<ScTableConditionalEntry>> maEntries; + + ScTableConditionalEntry* GetObjectByIndex_Impl(sal_uInt16 nIndex) const; + void AddEntry_Impl(const ScCondFormatEntryItem& aEntry); +public: + ScTableConditionalFormat() = delete; + ScTableConditionalFormat(const ScDocument* pDoc, sal_uLong nKey, + SCTAB nTab, formula::FormulaGrammar::Grammar eGrammar); + virtual ~ScTableConditionalFormat() override; + + void FillFormat( ScConditionalFormat& rFormat, ScDocument& rDoc, + formula::FormulaGrammar::Grammar eGrammar) const; + + // XSheetConditionalEntries + virtual void SAL_CALL addNew( const css::uno::Sequence< css::beans::PropertyValue >& aConditionalEntry ) override; + virtual void SAL_CALL removeByIndex( sal_Int32 nIndex ) override; + virtual void SAL_CALL clear() override; + + // XIndexAccess + virtual sal_Int32 SAL_CALL getCount() override; + virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override; + + // XNameAccess + virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override; + virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override; + + // XEnumerationAccess + virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL + createEnumeration() override; + + // XElementAccess + virtual css::uno::Type SAL_CALL getElementType() override; + virtual sal_Bool SAL_CALL hasElements() override; + + // XServiceInfo + 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; +}; + +class ScTableConditionalEntry final : public cppu::WeakImplHelper< + css::sheet::XSheetCondition2, + css::sheet::XSheetConditionalEntry, + css::lang::XServiceInfo > +{ +private: + ScCondFormatEntryItem aData; + +public: + ScTableConditionalEntry() = delete; + ScTableConditionalEntry(ScCondFormatEntryItem aItem); + virtual ~ScTableConditionalEntry() override; + + void GetData(ScCondFormatEntryItem& rData) const; + + // XSheetCondition + virtual css::sheet::ConditionOperator SAL_CALL getOperator() override; + virtual sal_Int32 SAL_CALL getConditionOperator() override; + virtual void SAL_CALL setOperator( css::sheet::ConditionOperator nOperator ) override; + virtual void SAL_CALL setConditionOperator( sal_Int32 nOperator ) override; + virtual OUString SAL_CALL getFormula1() override; + virtual void SAL_CALL setFormula1( const OUString& aFormula1 ) override; + virtual OUString SAL_CALL getFormula2() override; + virtual void SAL_CALL setFormula2( const OUString& aFormula2 ) override; + virtual css::table::CellAddress SAL_CALL getSourcePosition() override; + virtual void SAL_CALL setSourcePosition( const css::table::CellAddress& aSourcePosition ) override; + + // XSheetConditionalEntry + virtual OUString SAL_CALL getStyleName() override; + virtual void SAL_CALL setStyleName( const OUString& aStyleName ) override; + + // XServiceInfo + 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; +}; + +class ScTableValidationObj final : public cppu::WeakImplHelper< + css::sheet::XSheetCondition2, + css::sheet::XMultiFormulaTokens, + css::beans::XPropertySet, + css::lang::XServiceInfo > +{ +private: + SfxItemPropertySet aPropSet; + ScConditionMode nMode; + OUString aExpr1; + OUString aExpr2; + OUString maExprNmsp1; + OUString maExprNmsp2; + formula::FormulaGrammar::Grammar meGrammar1; // grammar used with aExpr1 and aExpr2 + formula::FormulaGrammar::Grammar meGrammar2; // grammar used with aExpr1 and aExpr2 + css::uno::Sequence< css::sheet::FormulaToken > aTokens1; + css::uno::Sequence< css::sheet::FormulaToken > aTokens2; + ScAddress aSrcPos; + OUString aPosString; // formula position as text + sal_uInt16 nValMode; // enum ScValidationMode + bool bIgnoreBlank; + sal_Int16 nShowList; + bool bShowInput; + OUString aInputTitle; + OUString aInputMessage; + bool bShowError; + sal_uInt16 nErrorStyle; // enum ScValidErrorStyle + OUString aErrorTitle; + OUString aErrorMessage; + + void ClearData_Impl(); + +public: + + ScTableValidationObj() = delete; + ScTableValidationObj(const ScDocument& rDoc, sal_uInt32 nKey, + const formula::FormulaGrammar::Grammar eGrammar); + virtual ~ScTableValidationObj() override; + + ScValidationData* CreateValidationData( ScDocument& rDoc, + formula::FormulaGrammar::Grammar eGrammar ) const; + + // XSheetCondition + virtual css::sheet::ConditionOperator SAL_CALL getOperator() override; + virtual sal_Int32 SAL_CALL getConditionOperator() override; + virtual void SAL_CALL setOperator( css::sheet::ConditionOperator nOperator ) override; + virtual void SAL_CALL setConditionOperator( sal_Int32 nOperator ) override; + virtual OUString SAL_CALL getFormula1() override; + virtual void SAL_CALL setFormula1( const OUString& aFormula1 ) override; + virtual OUString SAL_CALL getFormula2() override; + virtual void SAL_CALL setFormula2( const OUString& aFormula2 ) override; + virtual css::table::CellAddress SAL_CALL getSourcePosition() override; + virtual void SAL_CALL setSourcePosition( const css::table::CellAddress& aSourcePosition ) override; + + // XMultiFormulaTokens + virtual css::uno::Sequence< css::sheet::FormulaToken > + SAL_CALL getTokens( sal_Int32 nIndex ) override; + virtual void SAL_CALL setTokens( sal_Int32 nIndex, + const css::uno::Sequence< css::sheet::FormulaToken >& aTokens ) override; + virtual sal_Int32 SAL_CALL getCount() override; + + // XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > + SAL_CALL getPropertySetInfo() override; + virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, + const css::uno::Any& aValue ) override; + virtual css::uno::Any SAL_CALL getPropertyValue( + const OUString& PropertyName ) override; + virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override; + virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override; + virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + + // XServiceInfo + 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; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/fonthelper.hxx b/sc/inc/fonthelper.hxx new file mode 100644 index 0000000000..1cf36baaf2 --- /dev/null +++ b/sc/inc/fonthelper.hxx @@ -0,0 +1,48 @@ +/* -*- 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/. + */ + +#pragma once + +#include "scdllapi.h" +#include <optional> +#include <tools/fontenum.hxx> +#include <tools/color.hxx> +#include <vcl/fntstyle.hxx> +#include <i18nlangtag/lang.h> + +class SvxFontItem; + +struct SC_DLLPUBLIC ScDxfFont +{ + std::optional<const SvxFontItem*> pFontAttr; + std::optional<sal_uInt32> nFontHeight; + std::optional<FontWeight> eWeight; + std::optional<FontItalic> eItalic; + std::optional<FontLineStyle> eUnder; + std::optional<FontLineStyle> eOver; + std::optional<bool> bWordLine; + std::optional<FontStrikeout> eStrike; + std::optional<bool> bOutline; + std::optional<bool> bShadow; + std::optional<FontEmphasisMark> eEmphasis; + std::optional<FontRelief> eRelief; + std::optional<Color> aColor; + std::optional<LanguageType> eLang; + + bool isEmpty() const + { + return !(pFontAttr.has_value() || nFontHeight.has_value() || + eWeight.has_value() || eItalic.has_value() || eUnder.has_value() || + eOver.has_value() || bWordLine.has_value() || eStrike.has_value() || + bOutline.has_value() || bShadow.has_value() || eEmphasis.has_value() || + eRelief.has_value() || aColor.has_value() || eLang.has_value()); + } +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/forbiuno.hxx b/sc/inc/forbiuno.hxx new file mode 100644 index 0000000000..b6440f4eb7 --- /dev/null +++ b/sc/inc/forbiuno.hxx @@ -0,0 +1,42 @@ +/* -*- 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 <editeng/UnoForbiddenCharsTable.hxx> +#include <svl/lstner.hxx> + +class ScDocShell; + +// object to set forbidden characters to document + +class ScForbiddenCharsObj final : public SvxUnoForbiddenCharsTable, public SfxListener +{ + ScDocShell* pDocShell; + + virtual void onChange() override; + +public: + ScForbiddenCharsObj( ScDocShell* pDocSh ); + virtual ~ScForbiddenCharsObj() override; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx new file mode 100644 index 0000000000..70f113d507 --- /dev/null +++ b/sc/inc/formulacell.hxx @@ -0,0 +1,520 @@ +/* -*- 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 <map> +#include <memory> +#include <optional> + +#include <formula/tokenarray.hxx> +#include <formula/errorcodes.hxx> +#include <svl/listener.hxx> + +#include "types.hxx" +#include "interpretercontext.hxx" +#include "document.hxx" +#include "docoptio.hxx" +#include "formulalogger.hxx" +#include "formularesult.hxx" +#include "tokenarray.hxx" +#include "grouparealistener.hxx" + +namespace sc { + +class StartListeningContext; +class EndListeningContext; +struct RefUpdateContext; +struct RefUpdateInsertTabContext; +struct RefUpdateDeleteTabContext; +struct RefUpdateMoveTabContext; +class CompileFormulaContext; +class UpdatedRangeNames; + +} + +class ScFormulaCell; +class ScProgress; +enum class SvNumFormatType : sal_Int16; + +struct AreaListenerKey +{ + ScRange maRange; + bool mbStartFixed; + bool mbEndFixed; + + AreaListenerKey( const ScRange& rRange, bool bStartFixed, bool bEndFixed ) : + maRange(rRange), mbStartFixed(bStartFixed), mbEndFixed(bEndFixed) {} + + bool operator < ( const AreaListenerKey& r ) const; +}; + +typedef std::map<AreaListenerKey, sc::FormulaGroupAreaListener> AreaListenersType; + +struct SC_DLLPUBLIC ScFormulaCellGroup +{ + AreaListenersType m_AreaListeners; +public: + + mutable size_t mnRefCount; + + std::optional<ScTokenArray> mpCode; + ScFormulaCell *mpTopCell; + SCROW mnLength; // How many of these do we have ? + sal_Int32 mnWeight; + SvNumFormatType mnFormatType; + bool mbInvariant:1; + bool mbSubTotal:1; + bool mbPartOfCycle:1; // To flag FG's part of a cycle + + sal_uInt8 meCalcState; + + ScFormulaCellGroup(); + ScFormulaCellGroup(const ScFormulaCellGroup&) = delete; + const ScFormulaCellGroup& operator=(const ScFormulaCellGroup&) = delete; + ~ScFormulaCellGroup(); + + void setCode( const ScTokenArray& rCode ); + void compileCode( + ScDocument& rDoc, const ScAddress& rPos, formula::FormulaGrammar::Grammar eGram ); + + sc::FormulaGroupAreaListener* getAreaListener( + ScFormulaCell** ppTopCell, const ScRange& rRange, bool bStartFixed, bool bEndFixed ); + + void endAllGroupListening( ScDocument& rDoc ); +}; + +inline void intrusive_ptr_add_ref(const ScFormulaCellGroup *p) +{ + p->mnRefCount++; +} + +inline void intrusive_ptr_release(const ScFormulaCellGroup *p) +{ + if( --p->mnRefCount == 0 ) + delete p; +} + +enum class ScMatrixMode : sal_uInt8 { + NONE = 0, // No matrix formula + Formula = 1, // Upper left matrix formula cell + Reference = 2 // Remaining cells, via ocMatRef reference token +}; + +class SC_DLLPUBLIC ScFormulaCell final : public SvtListener +{ +private: + ScFormulaCellGroupRef mxGroup; // Group of formulae we're part of + bool bDirty : 1; // Must be (re)calculated + bool bTableOpDirty : 1; // Dirty flag for TableOp + bool bChanged : 1; // Whether something changed regarding display/representation + bool bRunning : 1; // Already interpreting right now + bool bCompile : 1; // Must be (re)compiled + bool bSubTotal : 1; // Cell is part of or contains a SubTotal + bool bIsIterCell : 1; // Cell is part of a circular reference + bool bInChangeTrack : 1; // Cell is in ChangeTrack + bool bNeedListening : 1; // Listeners need to be re-established after UpdateReference + bool mbNeedsNumberFormat : 1; // set the calculated number format as hard number format + bool mbAllowNumberFormatChange : 1; /* allow setting further calculated + number formats as hard number format */ + bool mbPostponedDirty : 1; // if cell needs to be set dirty later + bool mbIsExtRef : 1; // has references in ScExternalRefManager; never cleared after set + bool mbSeenInPath : 1; // For detecting cycle involving formula groups and singleton formulacells + bool mbFreeFlying : 1; // Cell is out of sheets interpreted, like in conditional format + ScMatrixMode cMatrixFlag : 8; + sal_uInt16 nSeenInIteration : 16; // Iteration cycle in which the cell was last encountered + SvNumFormatType nFormatType : 16; + ScFormulaResult aResult; + formula::FormulaGrammar::Grammar eTempGrammar; // used between string (creation) and (re)compilation + // If this cell is in a cell group (mxGroup!=nullptr), then this pCode is a not-owning pointer + // to the mxGroup's mpCode, which owns the array. If the cell is not in a group, this is an owning pointer. + ScTokenArray* pCode; // The token array + ScDocument& rDocument; + ScFormulaCell* pPrevious; + ScFormulaCell* pNext; + ScFormulaCell* pPreviousTrack; + ScFormulaCell* pNextTrack; + + /** + * Update reference in response to cell copy-n-paste. + */ + bool UpdateReferenceOnCopy( + const sc::RefUpdateContext& rCxt, ScDocument* pUndoDoc, const ScAddress* pUndoCellPos ); + + ScFormulaCell( const ScFormulaCell& ) = delete; + + bool CheckComputeDependencies(sc::FormulaLogger::GroupScope& rScope, bool fromFirstRow, + SCROW nStartOffset, SCROW nEndOffset, bool bCalcDependencyOnly = false, + ScRangeList* pSuccessfulDependencies = nullptr, + ScAddress* pFailedAndDirtiedAddress = nullptr); + bool InterpretFormulaGroupThreading(sc::FormulaLogger::GroupScope& aScope, + bool& bDependencyComputed, + bool& bDependencyCheckFailed, + SCROW nStartOffset, SCROW nEndOffset); + bool InterpretFormulaGroupOpenCL(sc::FormulaLogger::GroupScope& aScope, + bool& bDependencyComputed, + bool& bDependencyCheckFailed); + bool InterpretInvariantFormulaGroup(); + +public: + + + enum ScInterpretTailParameter + { + SCITP_NORMAL, + SCITP_FROM_ITERATION, + SCITP_CLOSE_ITERATION_CIRCLE + }; + void InterpretTail( ScInterpreterContext&, ScInterpretTailParameter ); + + void HandleStuffAfterParallelCalculation(ScInterpreter* pInterpreter); + + enum CompareState { NotEqual = 0, EqualInvariant, EqualRelativeRef }; + + ScAddress aPos; + + virtual ~ScFormulaCell() override; + + ScFormulaCell* Clone() const; + ScFormulaCell* Clone( const ScAddress& rPos ) const; + + ScFormulaCell( ScDocument& rDoc, const ScAddress& rPos ); + + /** + * Transfer the ownership of the passed token array instance to the + * formula cell being constructed. The caller <i>must not</i> pass a NULL + * token array pointer. + */ + ScFormulaCell( ScDocument& rDoc, const ScAddress& rPos, std::unique_ptr<ScTokenArray> pArray, + const formula::FormulaGrammar::Grammar eGrammar = formula::FormulaGrammar::GRAM_DEFAULT, + ScMatrixMode cMatInd = ScMatrixMode::NONE ); + + ScFormulaCell( ScDocument& rDoc, const ScAddress& rPos, const ScTokenArray& rArray, + const formula::FormulaGrammar::Grammar eGrammar = formula::FormulaGrammar::GRAM_DEFAULT, + ScMatrixMode cMatInd = ScMatrixMode::NONE ); + + ScFormulaCell( ScDocument& rDoc, const ScAddress& rPos, const ScFormulaCellGroupRef& xGroup, + const formula::FormulaGrammar::Grammar = formula::FormulaGrammar::GRAM_DEFAULT, + ScMatrixMode = ScMatrixMode::NONE ); + + /** With formula string and grammar to compile with. + formula::FormulaGrammar::GRAM_DEFAULT effectively isformula::FormulaGrammar::GRAM_NATIVE_UI that + also includes formula::FormulaGrammar::CONV_UNSPECIFIED, therefore uses the address + convention associated with rPos::nTab by default. */ + ScFormulaCell( ScDocument& rDoc, const ScAddress& rPos, + const OUString& rFormula, + const formula::FormulaGrammar::Grammar = formula::FormulaGrammar::GRAM_DEFAULT, + ScMatrixMode cMatInd = ScMatrixMode::NONE ); + + ScFormulaCell(const ScFormulaCell& rCell, ScDocument& rDoc, const ScAddress& rPos, ScCloneFlags nCloneFlags = ScCloneFlags::Default); + + void SetFreeFlying( bool b ) { mbFreeFlying = b; } + + size_t GetHash() const; + + OUString GetFormula( const formula::FormulaGrammar::Grammar = formula::FormulaGrammar::GRAM_DEFAULT, + const ScInterpreterContext* pContext = nullptr ) const; + OUString GetFormula( sc::CompileFormulaContext& rCxt, const ScInterpreterContext* pContext = nullptr ) const; + + void SetDirty( bool bDirtyFlag=true ); + void SetDirtyVar(); + // If setting entire document dirty after load, no broadcasts but still append to FormulaTree. + void SetDirtyAfterLoad(); + void ResetTableOpDirtyVar(); + void SetTableOpDirty(); + + bool IsDirtyOrInTableOpDirty() const + { + return bDirty || (bTableOpDirty && rDocument.IsInInterpreterTableOp()); + } + + bool GetDirty() const { return bDirty; } + void ResetDirty(); + bool NeedsListening() const { return bNeedListening; } + void SetNeedsListening( bool bVar ); + void SetNeedsDirty( bool bVar ); + void SetNeedNumberFormat( bool bVal ); + bool NeedsNumberFormat() const { return mbNeedsNumberFormat;} + SvNumFormatType GetFormatType() const { return nFormatType; } + void Compile(const OUString& rFormula, + bool bNoListening, + const formula::FormulaGrammar::Grammar ); + void Compile( + sc::CompileFormulaContext& rCxt, const OUString& rFormula, bool bNoListening = false ); + + void CompileTokenArray( bool bNoListening = false ); + void CompileTokenArray( sc::CompileFormulaContext& rCxt, bool bNoListening = false ); + void CompileXML( sc::CompileFormulaContext& rCxt, ScProgress& rProgress ); // compile temporary string tokens + void CalcAfterLoad( sc::CompileFormulaContext& rCxt, bool bStartListening ); + bool MarkUsedExternalReferences(); + // Returns true if the cell was interpreted as part of the formula group. + // The parameters may limit which subset of the formula group should be interpreted, if possible. + bool Interpret(SCROW nStartOffset = -1, SCROW nEndOffset = -1); + bool IsIterCell() const { return bIsIterCell; } + sal_uInt16 GetSeenInIteration() const { return nSeenInIteration; } + + bool HasOneReference( ScRange& r ) const; + /* Checks if the formula contains reference list that can be + expressed by one reference (like A1;A2;A3:A5 -> A1:A5). The + reference list is not required to be sorted (i.e. A3;A1;A2 is + still recognized as A1:A3), but no overlapping is allowed. + If one reference is recognized, the rRange is filled. + + It is similar to HasOneReference(), but more general. + */ + bool HasRefListExpressibleAsOneReference(ScRange& rRange) const; + + enum class RelNameRef + { + NONE, ///< no relative reference from named expression + SINGLE, ///< only single cell relative reference + DOUBLE ///< at least one range relative reference from named expression + }; + RelNameRef HasRelNameReference() const; + + bool UpdateReference( + const sc::RefUpdateContext& rCxt, ScDocument* pUndoDoc = nullptr, const ScAddress* pUndoCellPos = nullptr ); + + /** + * Shift the position of formula cell as part of reference update. + * + * @return true if the position has shifted, false otherwise. + */ + bool UpdatePosOnShift( const sc::RefUpdateContext& rCxt ); + + /** + * Update reference in response to cell insertion or deletion. + */ + bool UpdateReferenceOnShift( + const sc::RefUpdateContext& rCxt, ScDocument* pUndoDoc, const ScAddress* pUndoCellPos ); + + /** + * Update reference in response to cell move. + */ + bool UpdateReferenceOnMove( + const sc::RefUpdateContext& rCxt, ScDocument* pUndoDoc, const ScAddress* pUndoCellPos ); + + void TransposeReference(); + void UpdateTranspose( const ScRange& rSource, const ScAddress& rDest, + ScDocument* pUndoDoc ); + + void UpdateGrow( const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY ); + + void UpdateInsertTab( const sc::RefUpdateInsertTabContext& rCxt ); + void UpdateInsertTabAbs(SCTAB nTable); + void UpdateDeleteTab( const sc::RefUpdateDeleteTabContext& rCxt ); + void UpdateMoveTab( const sc::RefUpdateMoveTabContext& rCxt, SCTAB nTabNo ); + bool TestTabRefAbs(SCTAB nTable); + void UpdateCompile( bool bForceIfNameInUse ); + void FindRangeNamesInUse(sc::UpdatedRangeNames& rIndexes) const; + bool IsSubTotal() const { return bSubTotal;} + bool IsChanged() const { return bChanged;} + void SetChanged(bool b); + bool IsEmpty(); // formula::svEmptyCell result + // display as empty string if formula::svEmptyCell result + bool IsEmptyDisplayedAsString(); + bool IsValue(); // also true if formula::svEmptyCell + bool IsValueNoError(); + bool IsValueNoError() const; + double GetValue(); + const svl::SharedString & GetString(); + + /** + * Get a numeric value without potentially triggering re-calculation. + */ + double GetRawValue() const; + + /** + * Get a string value without potentially triggering re-calculation. + */ + const svl::SharedString & GetRawString() const; + const ScMatrix* GetMatrix(); + bool GetMatrixOrigin( const ScDocument& rDoc, ScAddress& rPos ) const; + void GetResultDimensions( SCSIZE& rCols, SCSIZE& rRows ); + sc::MatrixEdge GetMatrixEdge( const ScDocument& rDoc, ScAddress& rOrgPos ) const; + FormulaError GetErrCode(); // interpret first if necessary + FormulaError GetRawError() const; // don't interpret, just return code or result error + bool GetErrorOrValue( FormulaError& rErr, double& rVal ); + sc::FormulaResultValue GetResult(); + sc::FormulaResultValue GetResult() const; + ScMatrixMode GetMatrixFlag() const { return cMatrixFlag;} + ScTokenArray* GetCode() { return pCode;} + const ScTokenArray* GetCode() const { return pCode;} + + void SetCode( std::unique_ptr<ScTokenArray> pNew ); + + bool IsRunning() const { return bRunning;} + void SetRunning( bool bVal ); + void CompileDBFormula( sc::CompileFormulaContext& rCxt ); + void CompileColRowNameFormula( sc::CompileFormulaContext& rCxt ); + ScFormulaCell* GetPrevious() const { return pPrevious; } + ScFormulaCell* GetNext() const { return pNext; } + void SetPrevious( ScFormulaCell* pF ); + void SetNext( ScFormulaCell* pF ); + ScFormulaCell* GetPreviousTrack() const { return pPreviousTrack; } + ScFormulaCell* GetNextTrack() const { return pNextTrack; } + void SetPreviousTrack( ScFormulaCell* pF ); + void SetNextTrack( ScFormulaCell* pF ); + + virtual void Notify( const SfxHint& rHint ) override; + virtual void Query( SvtListener::QueryBase& rQuery ) const override; + + void SetCompile( bool bVal ); + ScDocument& GetDocument() const { return rDocument;} + void SetMatColsRows( SCCOL nCols, SCROW nRows ); + void GetMatColsRows( SCCOL& nCols, SCROW& nRows ) const; + + // cell belongs to ChangeTrack and not to the real document + void SetInChangeTrack( bool bVal ); + bool IsInChangeTrack() const { return bInChangeTrack;} + + // For import filters! + void AddRecalcMode( ScRecalcMode ); + /** For import only: set a double result. */ + void SetHybridDouble( double n ); + /** For import only: set a string result. + If for whatever reason you have to use both, SetHybridDouble() and + SetHybridString() or SetHybridFormula(), use SetHybridDouble() first + for performance reasons.*/ + void SetHybridString( const svl::SharedString& r ); + /** For import only: set an empty cell result to be displayed as empty string. + If for whatever reason you have to use both, SetHybridDouble() and + SetHybridEmptyDisplayedAsString() or SetHybridFormula(), use + SetHybridDouble() first for performance reasons and use + SetHybridEmptyDisplayedAsString() last because SetHybridDouble() and + SetHybridString() will override it.*/ + void SetHybridEmptyDisplayedAsString(); + /** For import only: set a temporary formula string to be compiled later. + If for whatever reason you have to use both, SetHybridDouble() and + SetHybridString() or SetHybridFormula(), use SetHybridDouble() first + for performance reasons.*/ + void SetHybridFormula( + const OUString& r, const formula::FormulaGrammar::Grammar eGrammar ); + + OUString GetHybridFormula() const; + + void SetResultMatrix( SCCOL nCols, SCROW nRows, const ScConstMatrixRef& pMat, const formula::FormulaToken* pUL ); + + /** For import only: set a double result. + Use this instead of SetHybridDouble() if there is no (temporary) + formula string because the formula is present as a token array, as it + is the case for binary Excel import. + */ + void SetResultDouble( double n ); + + void SetResultToken( const formula::FormulaToken* pToken ); + + const svl::SharedString & GetResultString() const; + + bool HasHybridStringResult() const; + + /* Sets the shared code array to error state in addition to the cell result */ + void SetErrCode( FormulaError n ); + + /* Sets just the result to error */ + void SetResultError( FormulaError n ); + + bool IsHyperLinkCell() const; + std::unique_ptr<EditTextObject> CreateURLObject(); + void GetURLResult( OUString& rURL, OUString& rCellText ); + + /** Determines whether or not the result string contains more than one paragraph */ + bool IsMultilineResult(); + + bool NeedsInterpret() const + { + if (bIsIterCell) + // Shortcut to force return of current value and not enter Interpret() + // as we're looping over all iteration cells. + return false; + + if (!IsDirtyOrInTableOpDirty()) + return false; + + return rDocument.GetAutoCalc() || (cMatrixFlag != ScMatrixMode::NONE) + || (pCode->IsRecalcModeMustAfterImport() && !pCode->IsRecalcModeAlways()); + } + + void MaybeInterpret() + { + if (NeedsInterpret()) + { + if (bRunning && !rDocument.GetDocOptions().IsIter() && rDocument.IsThreadedGroupCalcInProgress()) + { + // This is actually copied from Interpret()'s if(bRunning) + // block that once caught this circular reference but now is + // prepended with various threaded group calc things which the + // assert() below is supposed to fail on when entering again. + // Nevertheless, we need some state here the caller can obtain. + aResult.SetResultError( FormulaError::CircularReference ); + } + else + { + assert(!rDocument.IsThreadedGroupCalcInProgress()); + Interpret(); + } + } + } + + /** + * Turn a non-grouped cell into the top of a grouped cell. + */ + ScFormulaCellGroupRef CreateCellGroup( SCROW nLen, bool bInvariant ); + const ScFormulaCellGroupRef& GetCellGroup() const { return mxGroup;} + void SetCellGroup( const ScFormulaCellGroupRef &xRef ); + + CompareState CompareByTokenArray( const ScFormulaCell& rOther ) const; + + bool InterpretFormulaGroup(SCROW nStartOffset = -1, SCROW nEndOffset = -1); + + // nOnlyNames may be one or more of SC_LISTENING_NAMES_* + void StartListeningTo( ScDocument& rDoc ); + void StartListeningTo( sc::StartListeningContext& rCxt ); + void EndListeningTo( + ScDocument& rDoc, ScTokenArray* pArr = nullptr, ScAddress aPos = ScAddress() ); + void EndListeningTo( sc::EndListeningContext& rCxt ); + + bool IsShared() const; + bool IsSharedTop() const; + SCROW GetSharedTopRow() const; + SCROW GetSharedLength() const; + + // An estimate of the number of cells referenced by the formula + sal_Int32 GetWeight() const; + + ScTokenArray* GetSharedCode(); + const ScTokenArray* GetSharedCode() const; + + void SyncSharedCode(); + + bool IsPostponedDirty() const { return mbPostponedDirty;} + + void SetIsExtRef() { mbIsExtRef = true; } + bool GetSeenInPath() const { return mbSeenInPath; } + void SetSeenInPath(bool bSet) { mbSeenInPath = bSet; } + +#if DUMP_COLUMN_STORAGE + void Dump() const; +#endif +}; + +inline bool ScDocument::IsInFormulaTree( const ScFormulaCell* pCell ) const { return pCell->GetPrevious() || pFormulaTree == pCell; } +inline bool ScDocument::IsInFormulaTrack( const ScFormulaCell* pCell ) const { return pCell->GetPreviousTrack() || pFormulaTrack == pCell; } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/formulagroup.hxx b/sc/inc/formulagroup.hxx new file mode 100644 index 0000000000..95b354f794 --- /dev/null +++ b/sc/inc/formulagroup.hxx @@ -0,0 +1,150 @@ +/* -*- 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/. + */ + +#pragma once + +#include <config_feature_opencl.h> + +#include "address.hxx" +#include "calcconfig.hxx" +#include "types.hxx" +#include "stlalgorithm.hxx" + +#if HAVE_FEATURE_OPENCL +#include <opencl/platforminfo.hxx> +#endif + +#include <memory> +#include <unordered_map> +#include <vector> + +class ScDocument; +class ScTokenArray; +class ScFormulaCell; + +namespace sc { + +struct FormulaGroupEntry +{ + union + { + ScFormulaCell* mpCell; // non-shared formula cell + ScFormulaCell** mpCells; // pointer to the top formula cell in a shared group. + }; + + size_t mnRow; + size_t mnLength; + bool mbShared; + + FormulaGroupEntry( ScFormulaCell** pCells, size_t nRow, size_t nLength ); + + FormulaGroupEntry( ScFormulaCell* pCell, size_t nRow ); +}; + +// Despite the name, this is actually a cache of cell values, used by OpenCL +// code ... I think. And obviously it's not really a struct either. +struct FormulaGroupContext +{ + typedef AlignedAllocator<double,256> DoubleAllocType; + typedef std::vector<double, DoubleAllocType> NumArrayType; + typedef std::vector<rtl_uString*> StrArrayType; + typedef std::vector<std::unique_ptr<NumArrayType>> NumArrayStoreType; + typedef std::vector<std::unique_ptr<StrArrayType>> StrArrayStoreType; + + struct ColKey + { + SCTAB mnTab; + SCCOL mnCol; + + struct Hash + { + size_t operator() ( const ColKey& rKey ) const; + }; + + ColKey( SCTAB nTab, SCCOL nCol ); + + bool operator== ( const ColKey& r ) const; + }; + + struct ColArray + { + NumArrayType* mpNumArray; + StrArrayType* mpStrArray; + size_t mnSize; + + ColArray( NumArrayType* pNumArray, StrArrayType* pStrArray ); + }; + + typedef std::unordered_map<ColKey, ColArray, ColKey::Hash> ColArraysType; + + NumArrayStoreType m_NumArrays; /// manage life cycle of numeric arrays. + StrArrayStoreType m_StrArrays; /// manage life cycle of string arrays. + + ColArraysType maColArrays; /// keep track of longest array for each column. + + ColArray* getCachedColArray( SCTAB nTab, SCCOL nCol, size_t nSize ); + + ColArray* setCachedColArray( + SCTAB nTab, SCCOL nCol, NumArrayType* pNumArray, StrArrayType* pStrArray ); + + void discardCachedColArray(SCTAB nTab, SCCOL nCol); + + void ensureStrArray( ColArray& rColArray, size_t nArrayLen ); + void ensureNumArray( ColArray& rColArray, size_t nArrayLen ); + + FormulaGroupContext(); + FormulaGroupContext(const FormulaGroupContext&) = delete; + const FormulaGroupContext& operator=(const FormulaGroupContext&) = delete; + ~FormulaGroupContext(); +}; + +/** + * Abstract base class for a "compiled" formula + */ +class CompiledFormula +{ +public: + CompiledFormula(); + virtual ~CompiledFormula(); +}; + +/** + * Abstract base class for vectorised formula group interpreters, + * plus a global instance factory. + */ +class SC_DLLPUBLIC FormulaGroupInterpreter +{ + static FormulaGroupInterpreter *msInstance; + +protected: + ScCalcConfig maCalcConfig; + + FormulaGroupInterpreter() {} + virtual ~FormulaGroupInterpreter() {} + + /// Merge global and document specific settings. + void MergeCalcConfig(const ScDocument& rDoc); + +public: + static FormulaGroupInterpreter *getStatic(); +#if HAVE_FEATURE_OPENCL + static void fillOpenCLInfo(std::vector<OpenCLPlatformInfo>& rPlatforms); + static bool switchOpenCLDevice(std::u16string_view rDeviceId, bool bAutoSelect, bool bForceEvaluation = false); + // This is intended to be called from opencl-test.cxx only + static void enableOpenCL_UnitTestsOnly(); + static void disableOpenCL_UnitTestsOnly(); + static void getOpenCLDeviceInfo(sal_Int32& rDeviceId, sal_Int32& rPlatformId); +#endif + virtual ScMatrixRef inverseMatrix(const ScMatrix& rMat) = 0; + virtual bool interpret(ScDocument& rDoc, const ScAddress& rTopPos, ScFormulaCellGroupRef& xGroup, ScTokenArray& rCode) = 0; +}; + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/formulaiter.hxx b/sc/inc/formulaiter.hxx new file mode 100644 index 0000000000..69f0bb3f5f --- /dev/null +++ b/sc/inc/formulaiter.hxx @@ -0,0 +1,44 @@ +/* -*- 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 <formula/tokenarray.hxx> + +#include "address.hxx" + +class ScFormulaCell; + +/** + * Iterator for references in a formula cell. + */ +class ScDetectiveRefIter +{ +private: + const ScDocument& mrDoc; + formula::FormulaTokenArrayPlainIterator maIter; + ScAddress aPos; + +public: + ScDetectiveRefIter(const ScDocument& rDoc, ScFormulaCell* pCell); + bool GetNextRef(ScRange& rRange); + formula::FormulaToken* GetNextRefToken(); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/formulalogger.hxx b/sc/inc/formulalogger.hxx new file mode 100644 index 0000000000..9e8da1f681 --- /dev/null +++ b/sc/inc/formulalogger.hxx @@ -0,0 +1,188 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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/. + */ + +#pragma once + +#include <rtl/ustring.hxx> + +#include <memory> +#include <string_view> +#include <vector> + +#include <config_options_calc.h> + +class ScFormulaCell; +class ScDocument; +class ScAddress; +struct ScFormulaCellGroup; + +namespace formula { + +class FormulaToken; +struct VectorRefArray; + +} + +namespace osl { class File; } + +namespace sc { + +#if ENABLE_FORMULA_LOGGER + +/** + * Outputs formula calculation log outputs to specified file. + */ +class FormulaLogger +{ + std::unique_ptr<osl::File> mpLogFile; + + sal_Int32 mnNestLevel = 0; + const ScFormulaCellGroup* mpLastGroup = nullptr; + + void writeAscii( const char* s ); + void writeAscii( const char* s, size_t n ); + void write( std::u16string_view ou ); + void write( sal_Int32 n ); + + void sync(); + + void writeNestLevel(); + +public: + + static FormulaLogger& get(); + + /** + * This class is only moveable. + */ + class GroupScope + { + friend class FormulaLogger; + + struct Impl; + std::unique_ptr<Impl> mpImpl; + + public: + GroupScope() = delete; + GroupScope( const GroupScope& ) = delete; + GroupScope& operator= ( const GroupScope& ) = delete; + + private: + GroupScope( + FormulaLogger& rLogger, const OUString& rPrefix, + const ScDocument& rDoc, const ScFormulaCell& rCell, + bool bOutputEnabled ); + + public: + GroupScope(GroupScope&& r) noexcept; + ~GroupScope(); + + /** + * Add an arbitrary message to dump to the log. + */ + void addMessage( const OUString& rMsg ); + + /** + * Add to the log a vector reference information for a single + * reference. + */ + void addRefMessage( + const ScAddress& rCellPos, const ScAddress& rRefPos, size_t nLen, + const formula::VectorRefArray& rArray ); + + /** + * Add to the log a vector reference information for a range + * reference. + */ + void addRefMessage( + const ScAddress& rCellPos, const ScAddress& rRefPos, size_t nLen, + const std::vector<formula::VectorRefArray>& rArrays ); + + /** + * Add to the log a single cell reference information. + */ + void addRefMessage( + const ScAddress& rCellPos, const ScAddress& rRefPos, + const formula::FormulaToken& rToken ); + + void addGroupSizeThresholdMessage( const ScFormulaCell& rCell ); + + /** + * Call this when the group calculation has finished successfully. + */ + void setCalcComplete(); + }; + + FormulaLogger( const FormulaLogger& ) = delete; + FormulaLogger& operator= ( const FormulaLogger& ) = delete; + + FormulaLogger(); + ~FormulaLogger(); + + GroupScope enterGroup( const ScDocument& rDoc, const ScFormulaCell& rCell ); +}; + +#else + +/** + * Dummy class with all empty inline methods. + */ +class FormulaLogger +{ +public: + + static FormulaLogger get() + { + return FormulaLogger(); + } + + class GroupScope + { + public: + void addMessage( [[maybe_unused]] const OUString& /*rMsg*/ ) { (void) this; /* loplugin:staticmethods */ } + + void addRefMessage( + const ScAddress& /*rCellPos*/, const ScAddress& /*rRefPos*/, size_t /*nLen*/, + const formula::VectorRefArray& /*rArray*/ ) + { + (void) this; /* loplugin:staticmethods */ + } + + void addRefMessage( + const ScAddress& /*rCellPos*/, const ScAddress& /*rRefPos*/, size_t /*nLen*/, + const std::vector<formula::VectorRefArray>& /*rArrays*/ ) + { + (void) this; /* loplugin:staticmethods */ + } + + void addRefMessage( + const ScAddress& /*rCellPos*/, const ScAddress& /*rRefPos*/, + const formula::FormulaToken& /*rToken*/ ) + { + (void) this; /* loplugin:staticmethods */ + } + + void addGroupSizeThresholdMessage( const ScFormulaCell& /*rCell*/ ) + { + (void) this; /* loplugin:staticmethods */ + } + + void setCalcComplete() { (void) this; /* loplugin:staticmethods */ } + }; + + GroupScope enterGroup( const ScDocument& /*rDoc*/, const ScFormulaCell& /*rCell*/ ) + { + (void) this; /* loplugin:staticmethods */ + return GroupScope(); + } +}; + +#endif // ENABLE_FORMULA_LOGGER + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/formulaopt.hxx b/sc/inc/formulaopt.hxx new file mode 100644 index 0000000000..de46b52643 --- /dev/null +++ b/sc/inc/formulaopt.hxx @@ -0,0 +1,116 @@ +/* -*- 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/. + */ + +#pragma once + +#include <map> +#include <svl/poolitem.hxx> +#include <unotools/configitem.hxx> +#include <formula/grammar.hxx> +#include "scdllapi.h" +#include "calcconfig.hxx" + +class SC_DLLPUBLIC ScFormulaOptions +{ +private: + bool bUseEnglishFuncName; // use English function name even if the locale is not English. + formula::FormulaGrammar::Grammar eFormulaGrammar; // formula grammar used to switch different formula syntax + ScCalcConfig aCalcConfig; + bool mbWriteCalcConfig; + + OUString aFormulaSepArg; + OUString aFormulaSepArrayRow; + OUString aFormulaSepArrayCol; + + ScRecalcOptions meOOXMLRecalc; + ScRecalcOptions meODFRecalc; + +public: + ScFormulaOptions(); + + void SetDefaults(); + + void SetFormulaSyntax( ::formula::FormulaGrammar::Grammar eGram ) { eFormulaGrammar = eGram; } + ::formula::FormulaGrammar::Grammar GetFormulaSyntax() const { return eFormulaGrammar; } + + ScCalcConfig& GetCalcConfig() { return aCalcConfig; } + const ScCalcConfig& GetCalcConfig() const { return aCalcConfig; } + void SetCalcConfig(const ScCalcConfig& rConfig) { aCalcConfig = rConfig; } + + void SetUseEnglishFuncName( bool bVal ) { bUseEnglishFuncName = bVal; } + bool GetUseEnglishFuncName() const { return bUseEnglishFuncName; } + + void SetWriteCalcConfig( bool bVal ) { mbWriteCalcConfig = bVal; } + bool GetWriteCalcConfig() const { return mbWriteCalcConfig; } + + void SetFormulaSepArg(const OUString& rSep) { aFormulaSepArg = rSep; } + const OUString& GetFormulaSepArg() const { return aFormulaSepArg; } + + void SetFormulaSepArrayRow(const OUString& rSep) { aFormulaSepArrayRow = rSep; } + const OUString& GetFormulaSepArrayRow() const { return aFormulaSepArrayRow; } + + void SetFormulaSepArrayCol(const OUString& rSep) { aFormulaSepArrayCol = rSep; } + const OUString& GetFormulaSepArrayCol() const { return aFormulaSepArrayCol; } + + void SetOOXMLRecalcOptions( ScRecalcOptions eOpt ) { meOOXMLRecalc = eOpt; } + ScRecalcOptions GetOOXMLRecalcOptions() const { return meOOXMLRecalc; } + + void SetODFRecalcOptions( ScRecalcOptions eOpt ) { meODFRecalc = eOpt; } + ScRecalcOptions GetODFRecalcOptions() const { return meODFRecalc; } + + void ResetFormulaSeparators(); + + static void GetDefaultFormulaSeparators(OUString& rSepArg, OUString& rSepArrayCol, OUString& rSepArrayRow); + + bool operator== ( const ScFormulaOptions& rOpt ) const; + bool operator!= ( const ScFormulaOptions& rOpt ) const; +}; + +// item for the dialog / options page + +class SC_DLLPUBLIC ScTpFormulaItem final : public SfxPoolItem +{ +public: + ScTpFormulaItem( ScFormulaOptions aOpt ); + virtual ~ScTpFormulaItem() override; + + ScTpFormulaItem(ScTpFormulaItem const &) = default; + ScTpFormulaItem(ScTpFormulaItem &&) = default; + ScTpFormulaItem & operator =(ScTpFormulaItem const &) = delete; // due to SfxPoolItem + ScTpFormulaItem & operator =(ScTpFormulaItem &&) = delete; // due to SfxPoolItem + + virtual bool operator==( const SfxPoolItem& ) const override; + virtual ScTpFormulaItem* Clone( SfxItemPool *pPool = nullptr ) const override; + + const ScFormulaOptions& GetFormulaOptions() const { return theOptions; } + +private: + ScFormulaOptions theOptions; +}; + +// config item + +class ScFormulaCfg final : public ScFormulaOptions, public utl::ConfigItem +{ + typedef std::map<OUString,sal_uInt16> PropsToIds; + static css::uno::Sequence<OUString> GetPropertyNames(); + static ScFormulaCfg::PropsToIds GetPropNamesToId(); + void UpdateFromProperties( const css::uno::Sequence<OUString>& rNames ); + + virtual void ImplCommit() override; + +public: + ScFormulaCfg(); + + void SetOptions( const ScFormulaOptions& rNew ); + + virtual void Notify( const css::uno::Sequence< OUString >& aPropertyNames ) override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/formulaparserpool.hxx b/sc/inc/formulaparserpool.hxx new file mode 100644 index 0000000000..d5b51e0437 --- /dev/null +++ b/sc/inc/formulaparserpool.hxx @@ -0,0 +1,51 @@ +/* -*- 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 <unordered_map> +#include <com/sun/star/sheet/XFormulaParser.hpp> + +class ScDocument; + +/** Stores the used instances of the FilterFormulaParser service + implementations, mapped by the formula namespace they support. */ +class ScFormulaParserPool +{ +public: + explicit ScFormulaParserPool( const ScDocument& rDoc ); + ~ScFormulaParserPool(); + + /** Returns true, if a formula parser is registered for the passed namespace. */ + bool hasFormulaParser( const OUString& rNamespace ); + + /** Returns the formula parser that is registered for the passed namespace. */ + css::uno::Reference< css::sheet::XFormulaParser > + getFormulaParser( const OUString& rNamespace ); + +private: + typedef std::unordered_map< + OUString, + css::uno::Reference< css::sheet::XFormulaParser > > ParserMap; + + const ScDocument& mrDoc; + ParserMap maParsers; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/formularesult.hxx b/sc/inc/formularesult.hxx new file mode 100644 index 0000000000..581d9a4bba --- /dev/null +++ b/sc/inc/formularesult.hxx @@ -0,0 +1,213 @@ +/* -*- 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 "global.hxx" +#include "calcmacros.hxx" +#include <svl/sharedstring.hxx> +#include <formula/token.hxx> +#include <formula/types.hxx> + +class ScMatrixFormulaCellToken; + +namespace sc { + +struct FormulaResultValue +{ + enum Type : sal_uInt8 { Invalid, Value, String, Error }; + + double mfValue; + svl::SharedString maString; + bool mbMultiLine = false; + Type meType; + FormulaError mnError; + + FormulaResultValue(); + FormulaResultValue( double fValue ); + FormulaResultValue( svl::SharedString aStr, bool bMultiLine ); + FormulaResultValue( FormulaError nErr ); +}; + +} + +/** Store a variable formula cell result, balancing between runtime performance + and memory consumption. */ +class ScFormulaResult +{ + typedef unsigned char Multiline; + static const Multiline MULTILINE_UNKNOWN = 0; + static const Multiline MULTILINE_FALSE = 1; + static const Multiline MULTILINE_TRUE = 2; + + union + { + double mfValue; // double result direct for performance and memory consumption + const formula::FormulaToken* mpToken; // if not, result token obtained from interpreter + }; + bool mbToken :1; // whether content of union is a token + bool mbEmpty :1; // empty cell result + bool mbEmptyDisplayedAsString :1; // only if mbEmpty + // If set it implies that the result is a simple double (in mfValue) and no error + bool mbValueCached :1; + Multiline meMultiline :2; // result is multiline + FormulaError mnError; // error code + + /** Reset mnError, mbEmpty and mbEmptyDisplayedAsString to their defaults + prior to assigning other types */ + void ResetToDefaults(); + + /** If token is of formula::svError set error code and decrement RefCount. + If token is of formula::svEmptyCell set mbEmpty and mbEmptyAsString and + decrement RefCount. + If token is of formula::svDouble set mfValue and decrement RefCount. + Else assign token to mpToken. NULL is valid => svUnknown. + Other member variables are set accordingly. + @precondition: Token MUST had been IncRef'ed prior to this call! + @precondition: An already existing different mpToken MUST had been + DecRef'ed prior to this call, p will be assigned to mpToken if not + resolved. + ATTENTION! Token may get deleted in this call! */ + void ResolveToken( const formula::FormulaToken * p ); + +public: + /** Effectively type svUnknown. */ + ScFormulaResult(); + + ScFormulaResult( const ScFormulaResult & r ); + + /** Same comments as for SetToken() apply! */ + explicit ScFormulaResult( const formula::FormulaToken* p ); + + ~ScFormulaResult(); + + /** Well, guess what ... */ + ScFormulaResult& operator=( const ScFormulaResult & r ); + + /** Assignment as in operator=() but without return */ + void Assign( const ScFormulaResult & r ); + + /** Sets a direct double if token type is formula::svDouble, or mbEmpty if + formula::svEmptyCell, else token. If p is NULL, that is set as well, effectively + resulting in GetType()==svUnknown. If the already existing result is + ScMatrixFormulaCellToken, the upper left is set to token. + + ATTENTION! formula::FormulaToken had to be allocated using 'new' and if of type + formula::svDouble and no RefCount was set may not be used after this call + because it was deleted after decrement! */ + void SetToken( const formula::FormulaToken* p ); + + /** May be NULL if SetToken() did so, also if type formula::svDouble or formula::svError! */ + formula::FormulaConstTokenRef GetToken() const; + + /** Return upper left token if formula::svMatrixCell, else return GetToken(). + May be NULL if SetToken() did so, also if type formula::svDouble or formula::svError! */ + formula::FormulaConstTokenRef GetCellResultToken() const; + + /** Return type of result, including formula::svError, formula::svEmptyCell, formula::svDouble and + formula::svMatrixCell. */ + formula::StackVar GetType() const; + + /** If type is formula::svMatrixCell return the type of upper left element, else + GetType() */ + formula::StackVar GetCellResultType() const; + + /** If type is formula::svEmptyCell (including matrix upper left) and should be + displayed as empty string */ + bool IsEmptyDisplayedAsString() const; + + /** Test for cell result type formula::svDouble, including upper left if + formula::svMatrixCell. Also included is formula::svError for legacy, because previously + an error result was treated like a numeric value at some places in + ScFormulaCell. Also included is formula::svEmptyCell as a reference to an empty + cell usually is treated as numeric 0. Use GetCellResultType() for + details instead. */ + bool IsValue() const; + + bool IsValueNoError() const; + + /** Determines whether or not the result is a string containing more than + one paragraph */ + bool IsMultiline() const; + + bool GetErrorOrDouble( FormulaError& rErr, double& rVal ) const; + sc::FormulaResultValue GetResult() const; + + /** Get error code if set or GetCellResultType() is formula::svError or svUnknown, + else 0. */ + FormulaError GetResultError() const; + + /** Set error code, don't touch token or double. */ + void SetResultError( FormulaError nErr ); + + /** Set direct double. Shouldn't be used externally except in + ScFormulaCell for rounded CalcAsShown or SetErrCode() or + SetResultDouble(), see there for condition. If + ScMatrixFormulaCellToken the token isn't replaced but upper + left result is modified instead, but only if it was of type + formula::svDouble before or not set at all. + */ + void SetDouble( double f ); + + /** Return value if type formula::svDouble or formula::svHybridCell or formula::svMatrixCell and upper + left formula::svDouble, else 0.0 */ + double GetDouble() const; + + /** Return string if type formula::svString or formula::svHybridCell or formula::svMatrixCell and + upper left formula::svString, else empty string. */ + const svl::SharedString & GetString() const; + + /** Return matrix if type formula::svMatrixCell and ScMatrix present, else NULL. */ + ScConstMatrixRef GetMatrix() const; + + /** Return formula string if type formula::svHybridCell, else empty string. */ + OUString GetHybridFormula() const; + + /** Should only be used by import filters, best in the order + SetHybridDouble(), SetHybridString(), or only SetHybridFormula() for + formula string to be compiled later. */ + void SetHybridDouble( double f ); + + /** Should only be used by import filters, best in the order + SetHybridDouble(), SetHybridString()/SetHybridFormula(), or only + SetHybridFormula() for formula string to be compiled later. */ + void SetHybridString( const svl::SharedString & rStr ); + + /** Should only be used by import filters, best in the order + SetHybridDouble(), SetHybridFormula(), + SetHybridEmptyDisplayedAsString() must be last. */ + void SetHybridEmptyDisplayedAsString(); + + /** Should only be used by import filters, best in the order + SetHybridDouble(), SetHybridString()/SetHybridFormula(), or only + SetHybridFormula() for formula string to be compiled later. */ + void SetHybridFormula( const OUString & rFormula ); + + void SetMatrix( SCCOL nCols, SCROW nRows, const ScConstMatrixRef& pMat, const formula::FormulaToken* pUL ); + + /** Get the const ScMatrixFormulaCellToken* if token is of that type, else + NULL. */ + const ScMatrixFormulaCellToken* GetMatrixFormulaCellToken() const; + + /** Get the ScMatrixFormulaCellToken* if token is of that type, else NULL. + Shouldn't be used externally except by ScFormulaCell::SetMatColsRows(). */ + ScMatrixFormulaCellToken* GetMatrixFormulaCellTokenNonConst(); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/fstalgorithm.hxx b/sc/inc/fstalgorithm.hxx new file mode 100644 index 0000000000..f3f1891843 --- /dev/null +++ b/sc/inc/fstalgorithm.hxx @@ -0,0 +1,131 @@ +/* -*- 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/. + */ + +#pragma once + +#include <mdds/flat_segment_tree.hpp> +#include <vector> + +namespace sc { + +template<typename Key, typename Span> +void buildSpan( + std::vector<Span>& rSpans, + typename mdds::flat_segment_tree<Key,bool>::const_iterator it, + typename mdds::flat_segment_tree<Key,bool>::const_iterator itEnd, const Key* pStart ) +{ + Key nLastPos = it->first; + bool bLastVal = it->second; + for (++it; it != itEnd; ++it) + { + Key nThisPos = it->first; + bool bThisVal = it->second; + + if (bLastVal) + { + Key nIndex1 = nLastPos; + Key nIndex2 = nThisPos-1; + + if (!pStart || *pStart < nIndex1) + rSpans.push_back(Span(nIndex1, nIndex2)); + else if (*pStart <= nIndex2) + rSpans.push_back(Span(*pStart, nIndex2)); + } + + nLastPos = nThisPos; + bLastVal = bThisVal; + } +} + +template<typename Key, typename Val, typename Span> +void buildSpanWithValue( + std::vector<Span>& rSpans, + typename mdds::flat_segment_tree<Key,Val>::const_iterator it, + typename mdds::flat_segment_tree<Key,Val>::const_iterator itEnd ) +{ + Key nLastPos = it->first; + Val nLastVal = it->second; + for (++it; it != itEnd; ++it) + { + Key nThisPos = it->first; + Val nThisVal = it->second; + + if (nLastVal) + { + Key nIndex1 = nLastPos; + Key nIndex2 = nThisPos-1; + rSpans.push_back(Span(nIndex1, nIndex2, nLastVal)); + } + + nLastPos = nThisPos; + nLastVal = nThisVal; + } +} + +/** + * Convert a flat_segment_tree structure whose value type is boolean, into + * an array of ranges that corresponds with the segments that have a 'true' + * value. + */ +template<typename Key, typename Span> +std::vector<Span> toSpanArray( const mdds::flat_segment_tree<Key,bool>& rTree ) +{ + typedef mdds::flat_segment_tree<Key,bool> FstType; + + std::vector<Span> aSpans; + + typename FstType::const_iterator it = rTree.begin(), itEnd = rTree.end(); + buildSpan<Key,Span>(aSpans, it, itEnd, nullptr); + return aSpans; +} + +/** + * Convert a flat_segment_tree structure into an array of ranges with + * values. Only those ranges whose value is evaluated to be true will be + * included. The value type must be something that supports bool operator. + * The span type must support a constructor that takes a start key, an end + * key and a value in this order. + */ +template<typename Key, typename Val, typename Span> +std::vector<Span> toSpanArrayWithValue( const mdds::flat_segment_tree<Key,Val>& rTree ) +{ + typedef mdds::flat_segment_tree<Key,Val> FstType; + + std::vector<Span> aSpans; + + typename FstType::const_iterator it = rTree.begin(), itEnd = rTree.end(); + buildSpanWithValue<Key,Val,Span>(aSpans, it, itEnd); + return aSpans; +} + +template<typename Key, typename Span> +std::vector<Span> toSpanArray( const mdds::flat_segment_tree<Key,bool>& rTree, Key nStartPos ) +{ + typedef mdds::flat_segment_tree<Key,bool> FstType; + + std::vector<Span> aSpans; + if (!rTree.is_tree_valid()) + return aSpans; + + bool bThisVal = false; + std::pair<typename FstType::const_iterator, bool> r = + rTree.search_tree(nStartPos, bThisVal); + + if (!r.second) + // Tree search failed. + return aSpans; + + typename FstType::const_iterator it = r.first, itEnd = rTree.end(); + buildSpan<Key,Span>(aSpans, it, itEnd, &nStartPos); + return aSpans; +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/funcdesc.hxx b/sc/inc/funcdesc.hxx new file mode 100644 index 0000000000..49b718dbd1 --- /dev/null +++ b/sc/inc/funcdesc.hxx @@ -0,0 +1,406 @@ +/* -*- 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 + +/* Function descriptions for function wizard / autopilot */ + +#include "scfuncs.hxx" + +#include <formula/IFunctionDescription.hxx> +#include <sal/types.h> +#include <rtl/ustring.hxx> +#include <optional> +#include <map> +#include <memory> + +#define MAX_FUNCCAT 12 /* maximum number of categories for functions */ +#define LRU_MAX 10 /* maximal number of last recently used functions */ + +/** + Stores and generates human readable descriptions for spreadsheet-functions, + e.g.\ functions used in formulas in calc +*/ +class ScFuncDesc final : public formula::IFunctionDescription +{ +public: + ScFuncDesc(); + virtual ~ScFuncDesc(); + + /** + Clears the object + + Deletes all objects referenced by the pointers in the class, + sets pointers to NULL, and all numerical variables to 0 + */ + void Clear(); + + /** + Fills a mapping with indexes for non-suppressed arguments + + Fills mapping from visible arguments to real arguments, e.g. if of 4 + parameters the second one is suppressed {0,2,3}. For VAR_ARGS + parameters only one element is added to the end of the sequence. + + @param _rArguments + Vector, which the indices are written to + */ + virtual void fillVisibleArgumentMapping(::std::vector<sal_uInt16>& _rArguments) const override ; + + /** + Returns the category of the function + + @return the category of the function + */ + virtual const formula::IFunctionCategory* getCategory() const override ; + + /** + Returns the description of the function + + @return the description of the function, or an empty OUString if there is no description + */ + virtual OUString getDescription() const override ; + + /** + Returns the function signature with parameters from the passed string array. + + @return function signature with parameters + */ + virtual OUString getFormula(const ::std::vector< OUString >& _aArguments) const override ; + + /** + Returns the name of the function + + @return the name of the function, or an empty OUString if there is no name + */ + virtual OUString getFunctionName() const override ; + + /** + Returns the help id of the function + + @return help id of the function + */ + virtual OUString getHelpId() const override ; + + /** Returns whether function is hidden and not offered in the Function + Wizard unless used in an expression. + + @return flag whether function is hidden + */ + virtual bool isHidden() const override; + + /** + Returns number of arguments + + @return number of arguments + */ + virtual sal_uInt32 getParameterCount() const override ; + + /** + Returns start of variable arguments + + @return start of variable arguments + */ + virtual sal_uInt32 getVarArgsStart() const override ; + + /** + Returns maximum number of (variable) arguments + + @return maximum number of arguments, or 0 if there is no specific limit other than the general limit + */ + virtual sal_uInt32 getVarArgsLimit() const override ; + + /** + Returns description of parameter at given position + + @param _nPos + Position of the parameter + + @return OUString description of the parameter + */ + virtual OUString getParameterDescription(sal_uInt32 _nPos) const override ; + + /** + Returns name of parameter at given position + + @param _nPos + Position of the parameter + + @return OUString name of the parameter + */ + virtual OUString getParameterName(sal_uInt32 _nPos) const override ; + + /** + Returns list of all parameter names + + @return OUString containing separated list of all parameter names + */ + OUString GetParamList() const; + + /** + Returns the full function signature + + @return OUString of the form "FUNCTIONNAME( parameter list )" + */ + virtual OUString getSignature() const override ; + + /** + Returns the number of non-suppressed arguments + + In case there are variable arguments the number of fixed non-suppressed + arguments plus VAR_ARGS, same as for nArgCount (variable arguments can't + be suppressed). The two functions are equal apart from return type and + name. + + @return number of non-suppressed arguments + */ + sal_uInt16 GetSuppressedArgCount() const; + virtual sal_Int32 getSuppressedArgumentCount() const override ; + + /** + Requests function data from AddInCollection + + Logs error message on failure for debugging purposes + */ + virtual void initArgumentInfo() const override; + + /** + Returns true if parameter at given position is optional + + @param _nPos + Position of the parameter + + @return true if optional, false if not optional + */ + virtual bool isParameterOptional(sal_uInt32 _nPos) const override ; + + /** + Compares functions by name, respecting special characters + + @param a + pointer to first function descriptor + + @param b + pointer to second function descriptor + + @return "(a < b)" + */ + static bool compareByName(const ScFuncDesc* a, const ScFuncDesc* b); + + /** + Stores whether a parameter is optional or suppressed + */ + struct ParameterFlags + { + bool bOptional :1; /**< Parameter is optional */ + + ParameterFlags() : bOptional(false) {} + }; + + std::optional<OUString> mxFuncName; /**< Function name */ + std::optional<OUString> mxFuncDesc; /**< Description of function */ + std::vector<OUString> maDefArgNames; /**< Parameter name(s) */ + std::vector<OUString> maDefArgDescs; /**< Description(s) of parameter(s) */ + ParameterFlags *pDefArgFlags; /**< Flags for each parameter */ + sal_uInt16 nFIndex; /**< Unique function index */ + sal_uInt16 nCategory; /**< Function category */ + sal_uInt16 nArgCount; /**< All parameter count, suppressed and unsuppressed */ + sal_uInt16 nVarArgsStart; /**< Start of variable arguments, for numbering */ + sal_uInt16 nVarArgsLimit; /**< Limit maximum of (variable) arguments, for numbering */ + OUString sHelpId; /**< HelpId of function */ + bool bIncomplete :1; /**< Incomplete argument info (set for add-in info from configuration) */ + bool mbHidden :1; /**< Whether function is hidden */ +}; + +/** + List of spreadsheet functions. + Generated by retrieving functions from resources, AddIns and StarOne AddIns, + and storing these in one linked list. Functions can be retrieved by index and + by iterating through the list, starting at the First element, and retrieving + the Next elements one by one. + + The length of the longest function name can be retrieved for easier + processing (i.e printing a function list). +*/ +class ScFunctionList +{ +public: + explicit ScFunctionList( bool bEnglishFunctionNames ); + ~ScFunctionList(); + + sal_uInt32 GetCount() const + { return aFunctionList.size(); } + + const ScFuncDesc* First(); + + const ScFuncDesc* Next(); + + const ScFuncDesc* GetFunction( sal_uInt32 nIndex ) const; + + bool IsEnglishFunctionNames() const { return mbEnglishFunctionNames; } + +private: + ::std::vector<const ScFuncDesc*> aFunctionList; /**< List of functions */ + ::std::vector<const ScFuncDesc*>::iterator aFunctionListIter; /**< position in function list */ + bool mbEnglishFunctionNames; +}; + +/** + Category of spreadsheet functions. + + Contains the name, index and function manager of a category, + as well as a list of functions in the category +*/ +class ScFunctionCategory final : public formula::IFunctionCategory +{ +public: + ScFunctionCategory(const ::std::vector<const ScFuncDesc*>& _rCategory,sal_uInt32 _nCategory) + : m_rCategory(_rCategory),m_nCategory(_nCategory){} + virtual ~ScFunctionCategory(){} + + /** + @return count of functions in this category + */ + virtual sal_uInt32 getCount() const override; + + /** + Gives the _nPos'th function in this category. + + @param _nPos + position of function in this category. + + @return function at the _nPos position in this category, null if _nPos out of bounds. + */ + virtual const formula::IFunctionDescription* getFunction(sal_uInt32 _nPos) const override; + + /** + @return index number of this category. + */ + virtual sal_uInt32 getNumber() const override; + virtual OUString getName() const override; + +private: + const ::std::vector<const ScFuncDesc*>& m_rCategory; /**< list of functions in this category */ + mutable OUString m_sName; /**< name of this category */ + sal_uInt32 m_nCategory; /**< index number of this category */ +}; + +#define SC_FUNCGROUP_COUNT ID_FUNCTION_GRP_ADDINS +/** + Stores spreadsheet functions in categories, including a cumulative ('All') category and makes them accessible. +*/ +class ScFunctionMgr final : public formula::IFunctionManager +{ +public: + /** + Retrieves all calc functions, generates cumulative ('All') category, and the categories. + + The function lists of the categories are sorted by (case insensitive) function name + */ + ScFunctionMgr(); + virtual ~ScFunctionMgr(); + + /** + Returns name of category. + + @param _nCategoryNumber + index of category + + @return name of the category specified by _nCategoryNumber, empty string if _nCategoryNumber out of bounds + */ + static OUString GetCategoryName(sal_uInt32 _nCategoryNumber ); + + /** + Returns function by index. + + Searches for a function with the function index nFIndex. + + @param nFIndex + index of the function + + @return pointer to function with the index nFIndex, null if no such function was found. + */ + const ScFuncDesc* Get( sal_uInt16 nFIndex ) const; + + /** + Returns the first function in category nCategory. + + Selects nCategory as current category and returns first element of this. + + @param nCategory + index of requested category + + @return pointer to first element in current category, null if nCategory out of bounds + */ + const ScFuncDesc* First( sal_uInt16 nCategory = 0 ) const; + + /** + Returns the next function of the current category. + + @return pointer to the next function in current category, null if current category not set. + */ + const ScFuncDesc* Next() const; + + /** + @return number of categories, not counting the cumulative category ('All') + */ + virtual sal_uInt32 getCount() const override; + + /** + Returns a category. + + Returns an IFunctionCategory object for a category specified by nPos. + + @param nPos + the index of the category, note that 0 maps to the first category not the cumulative ('All') category. + + @return pointer to an IFunctionCategory object, null if nPos out of bounds. + */ + virtual const formula::IFunctionCategory* getCategory(sal_uInt32 nPos) const override; + + /** + Appends the last recently used functions. + + Takes the last recently used functions, but maximal LRU_MAX, and appends them to the given vector _rLastRUFunctions. + + @param _rLastRUFunctions + a vector of pointer to IFunctionDescription, by reference. + */ + virtual void fillLastRecentlyUsedFunctions(::std::vector< const formula::IFunctionDescription*>& _rLastRUFunctions) const override; + + /** + Maps Etoken to character + + Used for retrieving characters for parentheses and separators. + + @param _eToken + token for which, the corresponding character is retrieved + + @return character + */ + virtual sal_Unicode getSingleToken(const formula::IFunctionManager::EToken _eToken) const override; + +private: + std::vector<const ScFuncDesc*> aCatLists[MAX_FUNCCAT]; /**< array of all categories, 0 is the cumulative ('All') category */ + mutable std::map< sal_uInt32, std::shared_ptr<ScFunctionCategory> > m_aCategories; /**< map of category pos to IFunctionCategory */ + mutable std::vector<const ScFuncDesc*>::const_iterator pCurCatListIter; /**< position in current category */ + mutable std::vector<const ScFuncDesc*>::const_iterator pCurCatListEnd; /**< end of current category */ +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/funcuno.hxx b/sc/inc/funcuno.hxx new file mode 100644 index 0000000000..3d62ecaded --- /dev/null +++ b/sc/inc/funcuno.hxx @@ -0,0 +1,100 @@ +/* -*- 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 <memory> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/sheet/XFunctionAccess.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <cppuhelper/implbase.hxx> +#include <svl/lstner.hxx> +#include "document.hxx" +#include <svl/itemprop.hxx> + +class ScDocOptions; + +css::uno::Reference< css::uno::XInterface > SAL_CALL + ScFunctionAccess_CreateInstance( + const css::uno::Reference< css::lang::XMultiServiceFactory >& ); + +class ScTempDocCache +{ +private: + ScDocumentUniquePtr xDoc; + bool bInUse; + +public: + ScTempDocCache(); + + ScDocument* GetDocument() const { return xDoc.get(); } + bool IsInUse() const { return bInUse; } + void SetInUse( bool bSet ) { bInUse = bSet; } + + void SetDocument( ScDocument* pNew ); + void Clear(); +}; + +class ScFunctionAccess final : public cppu::WeakImplHelper< + css::sheet::XFunctionAccess, + css::beans::XPropertySet, + css::lang::XServiceInfo>, + public SfxListener +{ +private: + ScTempDocCache aDocCache; + std::unique_ptr<ScDocOptions> pOptions; + SfxItemPropertyMap aPropertyMap; + bool mbArray; + bool mbValid; + +public: + ScFunctionAccess(); + virtual ~ScFunctionAccess() override; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + // XFunctionAccess + virtual css::uno::Any SAL_CALL callFunction( + const OUString& aName, + const css::uno::Sequence< css::uno::Any >& aArguments ) override; + + // XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > + SAL_CALL getPropertySetInfo() override; + virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, + const css::uno::Any& aValue ) override; + virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override; + virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override; + virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override; + virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + + // XServiceInfo + 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; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/generalfunction.hxx b/sc/inc/generalfunction.hxx new file mode 100644 index 0000000000..083fc57ca0 --- /dev/null +++ b/sc/inc/generalfunction.hxx @@ -0,0 +1,89 @@ +/* -*- 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/sheet/GeneralFunction.hpp> +#include <com/sun/star/sheet/GeneralFunction2.hpp> + +/** + * the css::sheet::GeneralFunction enum is extended by constants in GeneralFunction2, which causes some type-safety issues. + * So abstract them behind the facade of this enum. + */ +enum class ScGeneralFunction +{ + /** nothing is calculated. + */ + NONE = int(css::sheet::GeneralFunction_NONE), + + /** function is determined automatically. + + <p>If the values are all numerical, SUM is used, otherwise COUNT.</p> + */ + AUTO = int(css::sheet::GeneralFunction_AUTO), + + /** sum of all numerical values is calculated. + */ + SUM = int(css::sheet::GeneralFunction_SUM), + + /** all values, including non-numerical values, are counted. + */ + COUNT = int(css::sheet::GeneralFunction_COUNT), + + /** average of all numerical values is calculated. + */ + AVERAGE = int(css::sheet::GeneralFunction_AVERAGE), + + /** maximum value of all numerical values is calculated. + */ + MAX = int(css::sheet::GeneralFunction_MAX), + + /** minimum value of all numerical values is calculated. + */ + MIN = int(css::sheet::GeneralFunction_MIN), + + /** product of all numerical values is calculated. + */ + PRODUCT = int(css::sheet::GeneralFunction_PRODUCT), + + /** numerical values are counted. + */ + COUNTNUMS = int(css::sheet::GeneralFunction_COUNTNUMS), + + /** standard deviation is calculated based on a sample. + */ + STDEV = int(css::sheet::GeneralFunction_STDEV), + + /** standard deviation is calculated based on the entire population. + */ + STDEVP = int(css::sheet::GeneralFunction_STDEVP), + + /** variance is calculated based on a sample. + */ + VAR = int(css::sheet::GeneralFunction_VAR), + + /** variance is calculated based on the entire population. + */ + VARP = int(css::sheet::GeneralFunction_VARP), + + /** + * median of all numerical values is calculated. + * @since LibreOffice 5.3 + */ + MEDIAN = css::sheet::GeneralFunction2::MEDIAN +}; diff --git a/sc/inc/global.hxx b/sc/inc/global.hxx new file mode 100644 index 0000000000..089611e5ee --- /dev/null +++ b/sc/inc/global.hxx @@ -0,0 +1,929 @@ +/* -*- 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 "address.hxx" +#include "typedstrdata.hxx" +#include <i18nlangtag/lang.h> +#include <svx/svdtypes.hxx> +#include <tools/ref.hxx> +#include <sal/types.h> +#include <com/sun/star/i18n/CollatorOptions.hpp> +#include "scdllapi.h" +#include <rtl/ustring.hxx> +#include <tools/long.hxx> +#include <o3tl/unit_conversion.hxx> + +#include <atomic> +// HACK: <atomic> includes <stdbool.h>, which in some Clang versions does '#define bool bool', +// which confuses clang plugins. +#undef bool + +#include <memory> +#include <optional> +#include <string_view> + +namespace com::sun::star::uno { template <typename > class Reference; } + +class SfxItemSet; +class SfxViewShell; +struct ScCalcConfig; +enum class SvtScriptType : sal_uInt8; +enum class FormulaError : sal_uInt16; +enum class SvNumFormatType : sal_Int16; + +#define SC_COLLATOR_IGNORES css::i18n::CollatorOptions::CollatorOptions_IGNORE_CASE + +// Calc has lots of names... +// Clipboard names are in so3/soapp.hxx now +// STRING_SCAPP was "scalc3", "scalc4", now just "scalc" + +inline constexpr OUString STRING_SCAPP = u"scalc"_ustr; + +inline constexpr OUString STRING_STANDARD = u"Standard"_ustr; + +// Have the dreaded programmatic filter name defined in one place. +inline constexpr OUString SC_TEXT_CSV_FILTER_NAME = u"Text - txt - csv (StarCalc)"_ustr; + +// characters + +const sal_Unicode CHAR_NBSP = 0x00A0; +const sal_Unicode CHAR_SHY = 0x00AD; +const sal_Unicode CHAR_ZWSP = 0x200B; +const sal_Unicode CHAR_LRM = 0x200E; +const sal_Unicode CHAR_RLM = 0x200F; +const sal_Unicode CHAR_NBHY = 0x2011; +const sal_Unicode CHAR_WJ = 0x2060; +const sal_Unicode CHAR_NNBSP = 0x202F; //NARROW NO-BREAK SPACE + +#define MINDOUBLE 1.7e-307 +#define MAXDOUBLE 1.7e307 + +const sal_uInt16 MINZOOM = 20; +const sal_uInt16 MAXZOOM = 400; + +const SCSIZE MAXSUBTOTAL = 3; + +// ~105.88 twip, i.e. about 2 times narrower than o3tl::Length::ch, which is 210 twip +constexpr auto TWIPS_PER_CHAR = o3tl::toTwips(1 / 13.6, o3tl::Length::in); + +constexpr sal_Int32 STD_COL_WIDTH = o3tl::convert(64, o3tl::Length::pt, o3tl::Length::twip); +constexpr sal_Int32 STD_EXTRA_WIDTH = o3tl::convert(2, o3tl::Length::mm, o3tl::Length::twip); + +constexpr sal_Int32 MAX_EXTRA_WIDTH = o3tl::convert(42, o3tl::Length::cm, o3tl::Length::twip); +constexpr sal_Int32 MAX_EXTRA_HEIGHT = o3tl::convert(42, o3tl::Length::cm, o3tl::Length::twip); +constexpr sal_Int32 MAX_COL_WIDTH = o3tl::convert(1, o3tl::Length::m, o3tl::Length::twip); +constexpr sal_Int32 MAX_ROW_HEIGHT = o3tl::convert(1, o3tl::Length::m, o3tl::Length::twip); + + /* standard row height: text + margin - STD_ROWHEIGHT_DIFF */ +#define STD_ROWHEIGHT_DIFF 23 + +namespace sc +{ + constexpr ::tools::Long TwipsToEvenHMM( ::tools::Long nTwips ) { return o3tl::convert(nTwips, 127, 144) * 2; } +} + + // standard size as OLE server (cells) +#define OLE_STD_CELLS_X 4 +#define OLE_STD_CELLS_Y 5 + + + // repaint flags (for messages) +enum class PaintPartFlags { + NONE = 0x00, + Grid = 0x01, + Top = 0x02, + Left = 0x04, + Extras = 0x08, + Marks = 0x10, + Objects = 0x20, + Size = 0x40, + All = Grid | Top | Left | Extras | Objects | Size, +}; +namespace o3tl { + template<> struct typed_flags<PaintPartFlags> : is_typed_flags<PaintPartFlags, 0x07f> {}; +} + + // flags for columns / rows +enum class CRFlags : sal_uInt8 { + // Filtered always together with Hidden + // Filtered and ManualSize only valid for rows + NONE = 0x00, + Hidden = 0x01, + ManualBreak = 0x02, + Filtered = 0x04, + ManualSize = 0x08, + All = Hidden | ManualBreak | Filtered | ManualSize +}; +namespace o3tl { + template<> struct typed_flags<CRFlags> : is_typed_flags<CRFlags, 0x0f> {}; +} + +enum class ScBreakType { + NONE = 0x00, + Page = 0x01, + Manual = 0x02 +}; +namespace o3tl { + template<> struct typed_flags<ScBreakType> : is_typed_flags<ScBreakType, 0x03> {}; +} + +enum class InsertDeleteFlags : sal_uInt16 +{ + NONE = 0x0000, + VALUE = 0x0001, /// Numeric values (and numeric results if InsertDeleteFlags::FORMULA is not set). + DATETIME = 0x0002, /// Dates, times, datetime values. + STRING = 0x0004, /// Strings (and string results if InsertDeleteFlags::FORMULA is not set). + NOTE = 0x0008, /// Cell notes. + FORMULA = 0x0010, /// Formula cells. + HARDATTR = 0x0020, /// Hard cell attributes. + STYLES = 0x0040, /// Cell styles. + OBJECTS = 0x0080, /// Drawing objects. + EDITATTR = 0x0100, /// Rich-text attributes. + OUTLINE = 0x0800, /// Sheet / outlining (grouping) information + SPARKLINES = 0x4000, /// Sparklines in a cell. + NOCAPTIONS = 0x0200, /// Internal use only (undo etc.): do not copy/delete caption objects of cell notes. + ADDNOTES = 0x0400, /// Internal use only (copy from clip): do not delete existing cell contents when pasting notes. + SPECIAL_BOOLEAN = 0x1000, + FORGETCAPTIONS = 0x2000, /// Internal use only (d&d undo): do not delete caption objects of cell notes. + ATTRIB = HARDATTR | STYLES, + CONTENTS = VALUE | DATETIME | STRING | NOTE | FORMULA | OUTLINE | SPARKLINES, + // tdf#116127 - add EDITATTR to ALL flags in order to check for valid function inputs + ALL = CONTENTS | ATTRIB | OBJECTS | SPARKLINES | EDITATTR, + /// Copy flags for auto/series fill functions: do not touch notes and drawing objects. + AUTOFILL = ALL & ~(NOTE | OBJECTS) +}; +namespace o3tl +{ + template<> struct typed_flags<InsertDeleteFlags> : is_typed_flags<InsertDeleteFlags, 0x7fff> {}; +} +// This doesn't work at the moment, perhaps when we have constexpr we can modify InsertDeleteFlags to make it work. +//static_assert((InsertDeleteFlags::ATTRIB & InsertDeleteFlags::CONTENTS) == InsertDeleteFlags::NONE, "these must match"); + + +enum class ScPasteFunc { + NONE, ADD, SUB, MUL, DIV +}; + // bits for HasAttr +enum class HasAttrFlags { + NONE = 0x0000, + Lines = 0x0001, + Merged = 0x0002, + Overlapped = 0x0004, + Protected = 0x0008, + Shadow = 0x0010, + NeedHeight = 0x0020, + ShadowRight = 0x0040, + ShadowDown = 0x0080, + AutoFilter = 0x0100, + Conditional = 0x0200, + Rotate = 0x0400, + NotOverlapped = 0x0800, + RightOrCenter = 0x1000, // right or centered logical alignment +}; +namespace o3tl { + template<> struct typed_flags<HasAttrFlags> : is_typed_flags<HasAttrFlags, 0x1fff> {}; +} + + +// Layer id's for drawing. +// These are both id's and positions. +constexpr SdrLayerID SC_LAYER_FRONT (0); +constexpr SdrLayerID SC_LAYER_BACK (1); +constexpr SdrLayerID SC_LAYER_INTERN (2); +constexpr SdrLayerID SC_LAYER_CONTROLS(3); +constexpr SdrLayerID SC_LAYER_HIDDEN (4); + +// link tables +enum class ScLinkMode { + NONE, NORMAL, VALUE +}; + // input +enum class ScEnterMode { + NORMAL, BLOCK, MATRIX +}; + + // step = 10pt, max. indention = 100 steps +#define SC_INDENT_STEP 200 + +enum class ScScenarioFlags{ // scenario flags + NONE = 0, + CopyAll = 1, + ShowFrame = 2, + PrintFrame = 4, + TwoWay = 8, + Attrib = 16, + Value = 32, + Protected = 64 +}; +namespace o3tl { + template<> struct typed_flags<ScScenarioFlags> : is_typed_flags<ScScenarioFlags, 127> {}; +} + +enum class SubtotalFlags { + NONE = 0x00, + IgnoreNestedStAg = 0x08, + IgnoreErrVal = 0x04, + IgnoreHidden = 0x02, + IgnoreFiltered = 0x01 +}; +namespace o3tl { + template<> struct typed_flags<SubtotalFlags> : is_typed_flags<SubtotalFlags, 0x0f> {}; +} + +enum class ScCloneFlags{ +/** Default cell clone flags: do not start listening, do not adjust 3D refs to + old position, clone note captions of cell notes. */ + Default = 0x0000, + +/** If set, cloned formula cells will start to listen to the document. */ + StartListening = 0x0001, + +/** If set, absolute refs will not transformed to external references */ + NoMakeAbsExternal = 0x0002, + +/** If set, global named expressions will be converted to sheet-local named + expressions. */ + NamesToLocal = 0x0004 +}; +namespace o3tl +{ + template<> struct typed_flags<ScCloneFlags> : is_typed_flags<ScCloneFlags, 0x0007> {}; +} + +enum CellType + { + CELLTYPE_NONE, + CELLTYPE_VALUE, + CELLTYPE_STRING, + CELLTYPE_FORMULA, + CELLTYPE_EDIT, + }; + +enum class DelCellCmd + { + CellsUp, + CellsLeft, + Rows, + Cols, + NONE + }; + +enum InsCellCmd + { + INS_CELLSDOWN, + INS_CELLSRIGHT, + INS_INSROWS_BEFORE, + INS_INSCOLS_BEFORE, + INS_NONE, + INS_INSROWS_AFTER, + INS_INSCOLS_AFTER + }; + +enum UpdateRefMode + { + URM_INSDEL, + URM_COPY, + URM_MOVE, + URM_REORDER + }; + +enum FillDir + { + FILL_TO_BOTTOM, + FILL_TO_RIGHT, + FILL_TO_TOP, + FILL_TO_LEFT + }; + +enum FillCmd + { + FILL_SIMPLE, + FILL_LINEAR, + FILL_GROWTH, + FILL_DATE, + FILL_AUTO + }; + +enum ScMoveDirection +{ + SC_MOVE_RIGHT, + SC_MOVE_LEFT, + SC_MOVE_UP, + SC_MOVE_DOWN +}; + +enum FillDateCmd + { + FILL_DAY, + FILL_WEEKDAY, + FILL_MONTH, + FILL_END_OF_MONTH, + FILL_YEAR + }; + +enum ScDirection + { + DIR_BOTTOM, + DIR_RIGHT, + DIR_TOP, + DIR_LEFT + }; + +enum ScSizeMode + { + SC_SIZE_DIRECT, // set size or hide if value is 0 + SC_SIZE_OPTIMAL, // set optimal size for everything + SC_SIZE_SHOW, // show with original size + SC_SIZE_VISOPT, // set optimal size only if visible + SC_SIZE_ORIGINAL // only set size, don't change visible flag + }; + +enum ScInputMode + { + SC_INPUT_NONE, + SC_INPUT_TYPE, // input, while not in inplace mode + SC_INPUT_TABLE, // text cursor in the table + SC_INPUT_TOP // text cursor in the input line + }; + +enum ScVObjMode // output modes of objects on a page +{ + VOBJ_MODE_SHOW, + VOBJ_MODE_HIDE +}; + +enum ScAnchorType // anchor of a character object +{ + SCA_CELL, // anchor to cell, move with cell + SCA_CELL_RESIZE, // anchor to cell, move and resize with cell + SCA_PAGE, // anchor to page, independent of any cells + SCA_DONTKNOW // for multi selection +}; + +enum ScGetDBMode +{ + SC_DB_MAKE, ///< create "untitled" (if necessary) + SC_DB_AUTOFILTER, ///< force use of sheet-local instead of document global anonymous range + SC_DB_IMPORT, ///< create "Importx" (if necessary) + SC_DB_OLD ///< don't create +}; + +/// For ScDBFunc::GetDBData() +enum class ScGetDBSelection +{ + /** Keep selection as is, expand to used data area if no selection. */ + Keep, + + /** Shrink selection to actually used data area within the selection. */ + ShrinkToUsedData, + + /** If only one row or portion thereof is selected, shrink row to used data + columns and select further rows down until end of data. If an area is + selected, shrink rows to actually used columns. Else, no selection, + expand to used data area. */ + RowDown, + + /** Behave as if the range corresponding to a ScDBData area was selected, + for API use. */ + ForceMark +}; + +enum ScLkUpdMode // modes for updating links +{ + LM_ALWAYS, + LM_NEVER, + LM_ON_DEMAND, + LM_UNKNOWN +}; + +// enum with values equal to old DBObject enum from sdb +enum ScDBObject +{ + ScDbTable, + ScDbQuery +}; + +namespace sc { + +enum class ColRowEditAction +{ + Unknown, + InsertColumnsBefore, + InsertColumnsAfter, + InsertRowsBefore, + InsertRowsAfter, + DeleteColumns, + DeleteRows +}; + +} + +struct ScImportParam +{ + SCCOL nCol1; + SCROW nRow1; + SCCOL nCol2; + SCROW nRow2; + bool bImport; + OUString aDBName; // alias of data base + OUString aStatement; + bool bNative; + bool bSql; // statement or name? + sal_uInt8 nType; // enum DBObject + + ScImportParam(); + ScImportParam( const ScImportParam& r ); + ~ScImportParam(); + + ScImportParam& operator= ( const ScImportParam& r ); + bool operator== ( const ScImportParam& r ) const; +}; + +// Formula data replacement character for a pair of parentheses at end of +// function name, to force sorting parentheses before all other characters. +// Collation may treat parentheses differently. +constexpr sal_Unicode cParenthesesReplacement = 0x0001; +struct InputHandlerFunctionNames +{ + ScTypedCaseStrSet maFunctionData; + ScTypedCaseStrSet maFunctionDataPara; + std::set<sal_Unicode> maFunctionChar; +}; + +class ScDocShell; +class SvxSearchItem; +class ScAutoFormat; +class LegacyFuncCollection; +class ScUnoAddInCollection; +class ScUserList; +class SvxBrushItem; +class ScFunctionList; +class ScFunctionMgr; +class SfxItemPool; +class EditTextObject; +class SfxObjectShell; +class SvNumberFormatter; +class ScUnitConverter; +class CharClass; +class LocaleDataWrapper; +class SvtSysLocale; +class CalendarWrapper; +class CollatorWrapper; +class IntlWrapper; +class ScFieldEditEngine; + +namespace com::sun::star { + namespace lang { + struct Locale; + } + namespace i18n { + class XOrdinalSuffix; + } +} +namespace utl { + class TransliterationWrapper; +} + +namespace sc { + class SharedStringPoolPurge; +} + +class ScGlobal +{ + static std::unique_ptr<SvxSearchItem> xSearchItem; + static std::unique_ptr<ScAutoFormat> xAutoFormat; + static std::atomic<LegacyFuncCollection*> pLegacyFuncCollection; + static std::atomic<ScUnoAddInCollection*> pAddInCollection; + static std::unique_ptr<ScUserList> xUserList; + static OUString aStrClipDocName; + static std::unique_ptr<SvxBrushItem> xEmptyBrushItem; + static std::unique_ptr<SvxBrushItem> xButtonBrushItem; + + static std::unique_ptr<ScFunctionList> xStarCalcFunctionList; + static std::unique_ptr<ScFunctionMgr> xStarCalcFunctionMgr; + + static std::atomic<ScUnitConverter*> pUnitConverter; + + static std::unique_ptr<SvNumberFormatter> xEnglishFormatter; // for UNO / XML export + + static css::uno::Reference< css::i18n::XOrdinalSuffix> xOrdinalSuffix; + static std::optional<CalendarWrapper> oCalendar; + static std::atomic<CollatorWrapper*> pCaseCollator; + static std::atomic<CollatorWrapper*> pCollator; + static std::atomic<::utl::TransliterationWrapper*> pTransliteration; + static std::atomic<::utl::TransliterationWrapper*> pCaseTransliteration; + static std::atomic<css::lang::Locale*> pLocale; + + static std::unique_ptr<ScFieldEditEngine> xFieldEditEngine; + + static std::atomic<sc::SharedStringPoolPurge*> pSharedStringPoolPurge; + + static InputHandlerFunctionNames maInputHandlerFunctionNames; + + static void InitPPT(); + +public: + static std::optional<SvtSysLocale> oSysLocale; + SC_DLLPUBLIC static const LocaleDataWrapper& getLocaleData(); + SC_DLLPUBLIC static const CharClass& getCharClass(); + + static CalendarWrapper& GetCalendar(); + /// case-insensitive collator + SC_DLLPUBLIC static CollatorWrapper& GetCollator(); + /// case-sensitive collator + static CollatorWrapper& GetCaseCollator(); + static CollatorWrapper& GetCollator(bool bCaseSensitive); + static css::lang::Locale& GetLocale(); + + SC_DLLPUBLIC static ::utl::TransliterationWrapper& GetTransliteration(); + static ::utl::TransliterationWrapper& GetCaseTransliteration(); + static ::utl::TransliterationWrapper& GetTransliteration(bool bCaseSensitive); + + SC_DLLPUBLIC static LanguageType eLnge; + static constexpr sal_Unicode cListDelimiter = ','; + + static const OUString& GetClipDocName(); + static void SetClipDocName( const OUString& rNew ); + SC_DLLPUBLIC static const SvxSearchItem& GetSearchItem(); + SC_DLLPUBLIC static void SetSearchItem( const SvxSearchItem& rNew ); + SC_DLLPUBLIC static ScAutoFormat* GetAutoFormat(); + SC_DLLPUBLIC static ScAutoFormat* GetOrCreateAutoFormat(); + static void ClearAutoFormat(); //BugId 54209 + static LegacyFuncCollection* GetLegacyFuncCollection(); + SC_DLLPUBLIC static ScUnoAddInCollection* GetAddInCollection(); + SC_DLLPUBLIC static ScUserList* GetUserList(); + static void SetUserList( const ScUserList* pNewList ); + /** + * Open the specified URL. + * @param bIgnoreSettings - If true, ignore security settings (Ctrl-Click) and just open the URL. + */ + static void OpenURL(const OUString& rURL, const OUString& rTarget, bool bIgnoreSettings = false); + /// Whether the URL can be opened according to current security options (Click/Ctrl-Click) + static bool ShouldOpenURL(); + SC_DLLPUBLIC static OUString GetAbsDocName( const OUString& rFileName, + const SfxObjectShell* pShell ); + SC_DLLPUBLIC static OUString GetDocTabName( std::u16string_view rFileName, + std::u16string_view rTabName ); + SC_DLLPUBLIC static sal_uInt32 GetStandardFormat( SvNumberFormatter&, sal_uInt32 nFormat, SvNumFormatType nType ); + + SC_DLLPUBLIC static sal_uInt16 GetStandardRowHeight(); + /// Horizontal pixel per twips factor. + SC_DLLPUBLIC static double nScreenPPTX; + /// Vertical pixel per twips factor. + SC_DLLPUBLIC static double nScreenPPTY; + + static tools::SvRef<ScDocShell> xDrawClipDocShellRef; + + static sal_uInt16 nDefFontHeight; + SC_DLLPUBLIC static sal_uInt16 nStdRowHeight; + + SC_DLLPUBLIC static ::tools::Long nLastRowHeightExtra; + static ::tools::Long nLastColWidthExtra; + + SC_DLLPUBLIC static void Init(); // during start up + static void InitAddIns(); + SC_DLLPUBLIC static void Clear(); // at the end of the program + + static void InitTextHeight(const SfxItemPool* pPool); + static SvxBrushItem* GetEmptyBrushItem() { return xEmptyBrushItem.get(); } + static SvxBrushItem* GetButtonBrushItem(); + + static bool HasStarCalcFunctionList(); + static ScFunctionList* GetStarCalcFunctionList(); + static ScFunctionMgr* GetStarCalcFunctionMgr(); + static void ResetFunctionList(); + static const InputHandlerFunctionNames& GetInputHandlerFunctionNames(); + + static OUString GetErrorString(FormulaError nErrNumber); + static OUString GetLongErrorString(FormulaError nErrNumber); + static bool EETextObjEqual( const EditTextObject* pObj1, + const EditTextObject* pObj2 ); + static bool CheckWidthInvalidate( bool& bNumFormatChanged, + const SfxItemSet& rNewAttrs, + const SfxItemSet& rOldAttrs ); + static bool HasAttrChanged( const SfxItemSet& rNewAttrs, + const SfxItemSet& rOldAttrs, + const sal_uInt16 nWhich ); + + static ScUnitConverter* GetUnitConverter(); + + /// strchr() functionality on unicode, as long as we need it for FormulaToken etc. + static const sal_Unicode* UnicodeStrChr( const sal_Unicode* pStr, sal_Unicode c ); + + static sal_Unicode ToUpperAlpha( sal_Unicode c ) + { return ( c >= 'a' && c <= 'z' ) ? ( c-'a'+'A' ) : c; } + + /** Adds the string rToken to rTokenList, using a list separator character. + @param rTokenList The string list where the token will be appended to. + @param rToken The token string to append to the token list. + @param cSep The character to separate the tokens. + @param nSepCount Specifies how often cSep is inserted between two tokens. + @param bForceSep true = Always insert separator; false = Only, if not at begin or end. */ + SC_DLLPUBLIC static OUString addToken( + std::u16string_view rTokenList, std::u16string_view rToken, + sal_Unicode cSep, sal_Int32 nSepCount = 1, + bool bForceSep = false ); + + /** Returns true, if the first and last character of the string is cQuote. */ + SC_DLLPUBLIC static bool IsQuoted( std::u16string_view rString, sal_Unicode cQuote ); + + /** Inserts the character cQuote at beginning and end of rString. + @param bEscapeEmbedded If <TRUE/>, embedded quote characters are + escaped by doubling them. + */ + SC_DLLPUBLIC static void AddQuotes( OUString& rString, sal_Unicode cQuote, bool bEscapeEmbedded = true ); + + /** Erases the character cQuote from rString, if it exists at beginning AND end. + @param bUnescapeEmbedded If <TRUE/>, embedded doubled quote characters + are unescaped by replacing them with a + single instance. + */ + SC_DLLPUBLIC static void EraseQuotes( OUString& rString, sal_Unicode cQuote, bool bUnescapeEmbedded = true ); + + /** Finds an unquoted instance of cChar in rString, starting at + offset nStart. Unquoted instances may occur when concatenating two + quoted strings with a separator, for example, 's1':'s2'. Embedded + quotes have to be escaped by being doubled. Caller must ensure that + nStart points into an unquoted range or the opening quote. Specialty: + if cChar=='\'' the first quote character from nStart on is found. + @returns offset if found, else -1 + */ + SC_DLLPUBLIC static sal_Int32 FindUnquoted( const OUString& rString, sal_Unicode cChar, sal_Int32 nStart = 0 ); + + /** Finds an unquoted instance of cChar in null-terminated pString. Same + semantics as FindUnquoted( const String&, ...) + @returns: pointer to cChar if found, else NULL + */ + SC_DLLPUBLIC static const sal_Unicode* FindUnquoted( const sal_Unicode* pString, sal_Unicode cChar ); + + static rtl_TextEncoding GetCharsetValue( std::u16string_view rCharSet ); + static OUString GetCharsetString( rtl_TextEncoding eVal ); + + /// a "ReadOnly" formatter for UNO/XML export + static SvNumberFormatter* GetEnglishFormatter(); + + static bool IsSystemRTL(); // depending on system language + static LanguageType GetEditDefaultLanguage(); // for EditEngine::SetDefaultLanguage + SC_DLLPUBLIC static SvtScriptType GetDefaultScriptType(); // for all WEAK characters + /** Map ATTR_((CJK|CTL)_)?FONT_... to proper WhichIDs. + If more than one SvtScriptType::... values are or'ed together, prefers + first COMPLEX, then ASIAN */ + SC_DLLPUBLIC static sal_uInt16 GetScriptedWhichID( SvtScriptType nScriptType, sal_uInt16 nWhich ); + + /** Adds a language item to the item set, if the number format item contains + a language that differs from its parent's language. */ + SC_DLLPUBLIC static void AddLanguage( SfxItemSet& rSet, const SvNumberFormatter& rFormatter ); + + /** Obtain the ordinal suffix for a number according to the system locale */ + static OUString GetOrdinalSuffix( sal_Int32 nNumber); + + /** A static instance of ScFieldEditEngine not capable of resolving + document specific fields, to be used only by ScEditUtil::GetString(). */ + static ScFieldEditEngine& GetStaticFieldEditEngine(); + + static sc::SharedStringPoolPurge& GetSharedStringPoolPurge(); + + /** Replaces the first occurrence of rPlaceholder in rString with + rReplacement, or if rPlaceholder is not found appends one space if + rString does not end in a space and appends rReplacement. + + Meant to be used with resource strings ala "Column %1" where a + translation may have omitted the %1 placeholder and a simple + replacement would end up with nothing replaced so no column indicator + in the result string. + */ + SC_DLLPUBLIC static OUString ReplaceOrAppend( const OUString& rString, + std::u16string_view rPlaceholder, + const OUString& rReplacement ); + + + /** Convert string content to numeric value. + + In any case, if rError is set 0.0 is returned. + + If nStringNoValueError is FormulaError::CellNoValue, that is unconditionally + assigned to rError and 0.0 is returned. The caller is expected to + handle this situation. Used by the interpreter. + + Usually FormulaError::NoValue is passed as nStringNoValueError. + + Otherwise, depending on the string conversion configuration different + approaches are taken: + + + For ScCalcConfig::StringConversion::ILLEGAL + The error value passed in nStringNoValueError is assigned to rError + (and 0.0 returned). + + + For ScCalcConfig::StringConversion::ZERO + A zero value is returned and no error assigned. + + + For ScCalcConfig::StringConversion::LOCALE + + If the string is empty or consists only of spaces, if "treat empty + string as zero" is set 0.0 is returned, else nStringNoValueError + assigned to rError (and 0.0 returned). + + Else a non-empty string is passed to the number formatter's scanner to + be parsed locale dependent. If that does not detect a numeric value + nStringNoValueError is assigned to rError (and 0.0 returned). + + If no number formatter was passed, the conversion falls back to + UNAMBIGUOUS. + + + For ScCalcConfig::StringConversion::UNAMBIGUOUS + + If the string is empty or consists only of spaces, if "treat empty + string as zero" is set 0.0 is returned, else nStringNoValueError + assigned to rError (and 0.0 returned). + + If the string is not empty the following conversion rules are applied: + + Converted are only integer numbers including exponent, and ISO 8601 dates + and times in their extended formats with separators. Anything else, + especially fractional numeric values with decimal separators or dates other + than ISO 8601 would be locale dependent and is a no-no. Leading and + trailing blanks are ignored. + + The following ISO 8601 formats are converted: + + CCYY-MM-DD + CCYY-MM-DDThh:mm + CCYY-MM-DDThh:mm:ss + CCYY-MM-DDThh:mm:ss,s + CCYY-MM-DDThh:mm:ss.s + hh:mm + hh:mm:ss + hh:mm:ss,s + hh:mm:ss.s + + The century CC may not be omitted and the two-digit year setting is not + taken into account. Instead of the T date and time separator exactly one + blank may be used. + + If a date is given, it must be a valid Gregorian calendar date. In this + case the optional time must be in the range 00:00 to 23:59:59.99999... + If only time is given, it may have any value for hours, taking elapsed time + into account; minutes and seconds are limited to the value 59 as well. + + If the string can not be converted to a numeric value, the error value + passed in nStringNoValueError is assigned to rError. + + + @param rStr + The string to be converted. + + @param rConfig + The calculation configuration. + + @param rError + Contains the error on return, if any. If an error was set before + and the conversion did not result in an error, still 0.0 is + returned. + + @param nStringNoValueError + The error value to be assigned to rError if string could not be + converted to number. + + @param pFormatter + The number formatter to use in case of + ScCalcConfig::StringConversion::LOCALE. Can but should not be + nullptr in which case conversion falls back to + ScCalcConfig::StringConversion::UNAMBIGUOUS and if a date is + detected the null date is assumed to be the standard 1899-12-30 + instead of the configured null date. + + @param rCurFmtType + Can be assigned a format type in case a date or time or date+time + string was converted, e.g. SvNumFormatType::DATE or + SvNumFormatType::TIME or a combination thereof. + + */ + static double ConvertStringToValue( const OUString& rStr, const ScCalcConfig& rConfig, + FormulaError & rError, FormulaError nStringNoValueError, + SvNumberFormatter* pFormatter, SvNumFormatType & rCurFmtType ); + + /// Calc's threaded group calculation is in progress. + SC_DLLPUBLIC static bool bThreadedGroupCalcInProgress; +}; + +// maybe move to dbdata.hxx (?): + +enum ScQueryOp + { + SC_EQUAL, + SC_LESS, + SC_GREATER, + SC_LESS_EQUAL, + SC_GREATER_EQUAL, + SC_NOT_EQUAL, + SC_TOPVAL, + SC_BOTVAL, + SC_TOPPERC, + SC_BOTPERC, + SC_CONTAINS, + SC_DOES_NOT_CONTAIN, + SC_BEGINS_WITH, + SC_DOES_NOT_BEGIN_WITH, + SC_ENDS_WITH, + SC_DOES_NOT_END_WITH + }; + +enum ScQueryConnect + { + SC_AND, + SC_OR + }; + +enum ScSubTotalFunc + { + SUBTOTAL_FUNC_NONE = 0, + SUBTOTAL_FUNC_AVE = 1, + SUBTOTAL_FUNC_CNT = 2, + SUBTOTAL_FUNC_CNT2 = 3, + SUBTOTAL_FUNC_MAX = 4, + SUBTOTAL_FUNC_MIN = 5, + SUBTOTAL_FUNC_PROD = 6, + SUBTOTAL_FUNC_STD = 7, + SUBTOTAL_FUNC_STDP = 8, + SUBTOTAL_FUNC_SUM = 9, + SUBTOTAL_FUNC_VAR = 10, + SUBTOTAL_FUNC_VARP = 11, + SUBTOTAL_FUNC_MED = 12, + SUBTOTAL_FUNC_SELECTION_COUNT = 13 + }; + +enum ScAggregateFunc + { + AGGREGATE_FUNC_AVE = 1, + AGGREGATE_FUNC_CNT = 2, + AGGREGATE_FUNC_CNT2 = 3, + AGGREGATE_FUNC_MAX = 4, + AGGREGATE_FUNC_MIN = 5, + AGGREGATE_FUNC_PROD = 6, + AGGREGATE_FUNC_STD = 7, + AGGREGATE_FUNC_STDP = 8, + AGGREGATE_FUNC_SUM = 9, + AGGREGATE_FUNC_VAR = 10, + AGGREGATE_FUNC_VARP = 11, + AGGREGATE_FUNC_MEDIAN = 12, + AGGREGATE_FUNC_MODSNGL = 13, + AGGREGATE_FUNC_LARGE = 14, + AGGREGATE_FUNC_SMALL = 15, + AGGREGATE_FUNC_PERCINC = 16, + AGGREGATE_FUNC_QRTINC = 17, + AGGREGATE_FUNC_PERCEXC = 18, + AGGREGATE_FUNC_QRTEXC = 19 + }; + +class ScArea; + +struct ScConsolidateParam +{ + SCCOL nCol; // cursor position / + SCROW nRow; // or start of destination area respectively + SCTAB nTab; + ScSubTotalFunc eFunction; + sal_uInt16 nDataAreaCount; // number of data areas + std::unique_ptr<ScArea[]> pDataAreas; // array of pointers into data areas + bool bByCol; + bool bByRow; + bool bReferenceData; // reference source data + + ScConsolidateParam(); + ScConsolidateParam( const ScConsolidateParam& r ); + ~ScConsolidateParam(); + + ScConsolidateParam& operator= ( const ScConsolidateParam& r ); + bool operator== ( const ScConsolidateParam& r ) const; + void Clear (); // = ClearDataAreas()+Members + void ClearDataAreas (); + void SetAreas ( std::unique_ptr<ScArea[]> pAreas, sal_uInt16 nCount ); +}; + +extern SfxViewShell* pScActiveViewShell; +extern sal_uInt16 nScClickMouseModifier; +extern sal_uInt16 nScFillModeMouseModifier; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/globalnames.hxx b/sc/inc/globalnames.hxx new file mode 100644 index 0000000000..d336e25495 --- /dev/null +++ b/sc/inc/globalnames.hxx @@ -0,0 +1,27 @@ +/* -*- 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/. + */ + +#pragma once + +#include <rtl/ustring.hxx> + +inline constexpr OUString STR_DB_LOCAL_NONAME = u"__Anonymous_Sheet_DB__"_ustr; +inline constexpr OUString STR_DB_GLOBAL_NONAME = u"__Anonymous_DB__"_ustr; + +inline constexpr OUString STR_GLOBAL_RANGE_NAME = u"__Global_Range_Name__"_ustr; + +#define TEXTWIDTH_DIRTY 0xffff + +#define DATE_TIME_FACTOR 86400.0 + +// Device name used to represent the software group interpreter for OpenCL +// mode. This string gets stored in use configuration as the device name. +#define OPENCL_SOFTWARE_DEVICE_CONFIG_NAME "Software" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/globstr.hrc b/sc/inc/globstr.hrc new file mode 100644 index 0000000000..8b07dc508e --- /dev/null +++ b/sc/inc/globstr.hrc @@ -0,0 +1,573 @@ +/* -*- 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 . + */ + +#ifndef SC_GLOBSTR_HRC +#define SC_GLOBSTR_HRC + +#define NC_(Context, String) TranslateId(Context, u8##String) +#define NNC_(Context, StringSingular, StringPlural) TranslateNId(Context, reinterpret_cast<char const *>(u8##StringSingular), reinterpret_cast<char const *>(u8##StringPlural)) + +/* + * This file is reserved for string IDs of permanently loaded resident string + * resources for faster access in core and filter code (and some UI like + * Undo/Redo or strings displayed in the status bar), they reside in resource + * RID_GLOBSTR and are meant to be accessed via ScGlobal::GetRscString(). All + * other string IDs of strings used in message boxes and elsewhere go into + * sc/inc/strings.hrc + */ + +#define STR_UNDO_INSERTCELLS NC_("STR_UNDO_INSERTCELLS", "Insert") +#define STR_UNDO_DELETECELLS NC_("STR_UNDO_DELETECELLS", "Delete") +#define STR_UNDO_CUT NC_("STR_UNDO_CUT", "Cut") +#define STR_UNDO_PASTE NC_("STR_UNDO_PASTE", "Insert") +#define STR_UNDO_DRAGDROP NC_("STR_UNDO_DRAGDROP", "Drag and Drop") +#define STR_UNDO_MOVE NC_("STR_UNDO_MOVE", "Move") +#define STR_UNDO_COPY NC_("STR_UNDO_COPY", "Copy") +#define STR_UNDO_DELETECONTENTS NC_("STR_UNDO_DELETECONTENTS", "Delete") +#define STR_UNDO_SELATTR NC_("STR_UNDO_SELATTR", "Attributes") +#define STR_UNDO_SELATTRLINES NC_("STR_UNDO_SELATTRLINES", "Attributes/Lines") +#define STR_UNDO_COLWIDTH NC_("STR_UNDO_COLWIDTH", "Column Width") +#define STR_UNDO_OPTCOLWIDTH NC_("STR_UNDO_OPTCOLWIDTH", "Optimal Column Width") +#define STR_UNDO_ROWHEIGHT NC_("STR_UNDO_ROWHEIGHT", "Row height") +#define STR_UNDO_OPTROWHEIGHT NC_("STR_UNDO_OPTROWHEIGHT", "Optimal Row Height") +#define STR_UNDO_AUTOFILL NC_("STR_UNDO_AUTOFILL", "Fill") +#define STR_UNDO_MERGE NC_("STR_UNDO_MERGE", "Merge") +#define STR_UNDO_REMERGE NC_("STR_UNDO_REMERGE", "Split") +#define STR_UNDO_AUTOFORMAT NC_("STR_UNDO_AUTOFORMAT", "AutoFormat") +#define STR_UNDO_REPLACE NC_("STR_UNDO_REPLACE", "Replace") +#define STR_UNDO_CURSORATTR NC_("STR_UNDO_CURSORATTR", "Attributes") +#define STR_UNDO_ENTERDATA NC_("STR_UNDO_ENTERDATA", "Input") +#define STR_UNDO_INSCOLBREAK NC_("STR_UNDO_INSCOLBREAK", "Insert Column Break") +#define STR_UNDO_DELCOLBREAK NC_("STR_UNDO_DELCOLBREAK", "Delete column break") +#define STR_UNDO_INSROWBREAK NC_("STR_UNDO_INSROWBREAK", "Insert Row Break") +#define STR_UNDO_DELROWBREAK NC_("STR_UNDO_DELROWBREAK", "Delete row break") +#define STR_UNDO_DOOUTLINE NC_("STR_UNDO_DOOUTLINE", "View Details") +#define STR_UNDO_REDOOUTLINE NC_("STR_UNDO_REDOOUTLINE", "Hide details") +#define STR_UNDO_MAKEOUTLINE NC_("STR_UNDO_MAKEOUTLINE", "Group") +#define STR_UNDO_REMAKEOUTLINE NC_("STR_UNDO_REMAKEOUTLINE", "Ungroup") +#define STR_UNDO_OUTLINELEVEL NC_("STR_UNDO_OUTLINELEVEL", "Select outline level") +#define STR_UNDO_DOOUTLINEBLK NC_("STR_UNDO_DOOUTLINEBLK", "View Details") +#define STR_UNDO_REDOOUTLINEBLK NC_("STR_UNDO_REDOOUTLINEBLK", "Hide details") +#define STR_UNDO_REMOVEALLOTLNS NC_("STR_UNDO_REMOVEALLOTLNS", "Clear Outline") +#define STR_UNDO_AUTOOUTLINE NC_("STR_UNDO_AUTOOUTLINE", "AutoOutline") +#define STR_UNDO_SUBTOTALS NC_("STR_UNDO_SUBTOTALS", "Subtotals") +#define STR_UNDO_SORT NC_("STR_UNDO_SORT", "Sort") +#define STR_UNDO_QUERY NC_("STR_UNDO_QUERY", "Filter") +#define STR_UNDO_DBDATA NC_("STR_UNDO_DBDATA", "Change Database Range") +#define STR_UNDO_IMPORTDATA NC_("STR_UNDO_IMPORTDATA", "Importing") +#define STR_UNDO_REPEATDB NC_("STR_UNDO_REPEATDB", "Refresh range") +#define STR_UNDO_LISTNAMES NC_("STR_UNDO_LISTNAMES", "List names") +#define STR_UNDO_PIVOT_NEW NC_("STR_UNDO_PIVOT_NEW", "Create pivot table") +#define STR_UNDO_PIVOT_MODIFY NC_("STR_UNDO_PIVOT_MODIFY", "Edit pivot table") +#define STR_UNDO_PIVOT_DELETE NC_("STR_UNDO_PIVOT_DELETE", "Delete pivot table") +#define STR_UNDO_CONSOLIDATE NC_("STR_UNDO_CONSOLIDATE", "Consolidate") +#define STR_UNDO_USESCENARIO NC_("STR_UNDO_USESCENARIO", "Use scenario") +#define STR_UNDO_MAKESCENARIO NC_("STR_UNDO_MAKESCENARIO", "Create scenario") +#define STR_UNDO_EDITSCENARIO NC_("STR_UNDO_EDITSCENARIO", "Edit scenario") +#define STR_UNDO_APPLYCELLSTYLE NC_("STR_UNDO_APPLYCELLSTYLE", "Apply Cell Style") +#define STR_UNDO_EDITCELLSTYLE NC_("STR_UNDO_EDITCELLSTYLE", "Edit Cell Style") +#define STR_UNDO_APPLYPAGESTYLE NC_("STR_UNDO_APPLYPAGESTYLE", "Apply Page Style") +#define STR_UNDO_EDITPAGESTYLE NC_("STR_UNDO_EDITPAGESTYLE", "Edit Page Style") +#define STR_UNDO_EDITGRAPHICSTYLE NC_("STR_UNDO_EDITGRAPHICSTYLE", "Edit Drawing Style") +#define STR_UNDO_DETADDPRED NC_("STR_UNDO_DETADDPRED", "Trace Precedents") +#define STR_UNDO_DETDELPRED NC_("STR_UNDO_DETDELPRED", "Remove Precedent") +#define STR_UNDO_DETADDSUCC NC_("STR_UNDO_DETADDSUCC", "Trace Dependents") +#define STR_UNDO_DETDELSUCC NC_("STR_UNDO_DETDELSUCC", "Remove Dependent") +#define STR_UNDO_DETADDERROR NC_("STR_UNDO_DETADDERROR", "Trace Error") +#define STR_UNDO_DETDELALL NC_("STR_UNDO_DETDELALL", "Remove all Traces") +#define STR_UNDO_DETINVALID NC_("STR_UNDO_DETINVALID", "Mark invalid data") +#define STR_UNDO_DETREFRESH NC_("STR_UNDO_DETREFRESH", "Refresh Traces") +#define STR_UNDO_CHARTDATA NC_("STR_UNDO_CHARTDATA", "Modify chart data range") +#define STR_UNDO_ORIGINALSIZE NC_("STR_UNDO_ORIGINALSIZE", "Original Size") +#define STR_UNDO_FITCELLSIZE NC_("STR_UNDO_FITCELLSIZE", "Fit to Cell Size") +#define STR_UNDO_UPDATELINK NC_("STR_UNDO_UPDATELINK", "Update Link") +#define STR_UNDO_REMOVELINK NC_("STR_UNDO_REMOVELINK", "Unlink") +#define STR_UNDO_INSERTAREALINK NC_("STR_UNDO_INSERTAREALINK", "Insert Link") +#define STR_UNDO_ENTERMATRIX NC_("STR_UNDO_ENTERMATRIX", "Insert Array Formula") +#define STR_UNDO_INSERTNOTE NC_("STR_UNDO_INSERTNOTE", "Insert Comment") +#define STR_UNDO_DELETENOTE NC_("STR_UNDO_DELETENOTE", "Delete Comment") +#define STR_UNDO_SHOWNOTE NC_("STR_UNDO_SHOWNOTE", "Show Comment") +#define STR_UNDO_HIDENOTE NC_("STR_UNDO_HIDENOTE", "Hide Comment") +#define STR_UNDO_SHOWALLNOTES NC_("STR_UNDO_SHOWALLNOTES", "Show All Comments") +#define STR_UNDO_HIDEALLNOTES NC_("STR_UNDO_HIDEALLNOTES", "Hide All Comments") +#define STR_UNDO_EDITNOTE NC_("STR_UNDO_EDITNOTE", "Edit Comment") +#define STR_UNDO_DEC_INDENT NC_("STR_UNDO_DEC_INDENT", "Decrease Indent") +#define STR_UNDO_INC_INDENT NC_("STR_UNDO_INC_INDENT", "Increase Indent") +#define STR_UNDO_PROTECT_TAB NC_("STR_UNDO_PROTECT_TAB", "Protect sheet") +#define STR_UNDO_UNPROTECT_TAB NC_("STR_UNDO_UNPROTECT_TAB", "Unprotect sheet") +#define STR_UNDO_PROTECT_DOC NC_("STR_UNDO_PROTECT_DOC", "Protect document") +#define STR_UNDO_UNPROTECT_DOC NC_("STR_UNDO_UNPROTECT_DOC", "Unprotect document") +#define STR_UNDO_PRINTRANGES NC_("STR_UNDO_PRINTRANGES", "Print range") +#define STR_UNDO_REMOVEBREAKS NC_("STR_UNDO_REMOVEBREAKS", "Delete Page Breaks") +#define STR_UNDO_PRINTSCALE NC_("STR_UNDO_PRINTSCALE", "Change Scale") +#define STR_UNDO_DRAG_BREAK NC_("STR_UNDO_DRAG_BREAK", "Move Page Break") +#define STR_UNDO_RANGENAMES NC_("STR_UNDO_RANGENAMES", "Edit range names") +#define STR_UNDO_TRANSLITERATE NC_("STR_UNDO_TRANSLITERATE", "Change Case") +#define STR_DBNAME_IMPORT NC_("STR_DBNAME_IMPORT", "Import") +#define STR_MSSG_DOSUBTOTALS_0 NC_("STR_MSSG_DOSUBTOTALS_0", "%PRODUCTNAME Calc") +#define STR_MSSG_DOSUBTOTALS_1 NC_("STR_MSSG_DOSUBTOTALS_1", "Delete data?") +#define STR_MSSG_DOSUBTOTALS_2 NC_("STR_MSSG_DOSUBTOTALS_2", "Unable to insert rows") +#define STR_MSSG_REPEATDB_0 NC_("STR_MSSG_REPEATDB_0", "No operations to execute") +#define STR_MSSG_MAKEAUTOFILTER_0 NC_("STR_MSSG_MAKEAUTOFILTER_0", "The range does not contain column headers.\nDo you want the first line to be used as column header?") +#define STR_MSSG_IMPORTDATA_0 NC_("STR_MSSG_IMPORTDATA_0", "Error while importing data!") +#define STR_MSSG_MAKEOUTLINE_0 NC_("STR_MSSG_MAKEOUTLINE_0", "Grouping not possible") +#define STR_MSSG_REMOVEOUTLINE_0 NC_("STR_MSSG_REMOVEOUTLINE_0", "Ungrouping not possible") +#define STR_MSSG_PASTEFROMCLIP_0 NC_("STR_MSSG_PASTEFROMCLIP_0", "Insert into multiple selection not possible") +#define STR_MSSG_MOVEBLOCKTO_0 NC_("STR_MSSG_MOVEBLOCKTO_0", "Cell merge not possible if cells already merged!") +#define STR_MSSG_INSERTCELLS_0 NC_("STR_MSSG_INSERTCELLS_0", "Inserting into merged ranges not possible") +#define STR_MSSG_DELETECELLS_0 NC_("STR_MSSG_DELETECELLS_0", "Deleting in merged ranges not possible") +#define STR_MSSG_MERGECELLS_0 NC_("STR_MSSG_MERGECELLS_0", "Cell merge not possible if cells already merged") +#define STR_SORT_ERR_MERGED NC_("STR_SORT_ERR_MERGED", "Ranges containing merged cells can only be sorted without formats.") +#define STR_MSSG_SOLVE_0 NC_("STR_MSSG_SOLVE_0", "Goal Seek succeeded. Result: ") +#define STR_MSSG_SOLVE_1 NC_("STR_MSSG_SOLVE_1", "\n\nInsert the result into the variable cell?") +#define STR_MSSG_SOLVE_2 NC_("STR_MSSG_SOLVE_2", "Goal Seek failed.\n\n") +#define STR_MSSG_SOLVE_3 NC_("STR_MSSG_SOLVE_3", "Insert the closest value (") +#define STR_MSSG_SOLVE_4 NC_("STR_MSSG_SOLVE_4", ") into the variable cell anyway?") +#define STR_TABLE_ERGEBNIS NC_("STR_TABLE_ERGEBNIS", "Result") +#define STR_UNDO_SPELLING NC_("STR_UNDO_SPELLING", "Spellcheck") +#define STR_TABLE_AND NC_("STR_TABLE_AND", "AND") +#define STR_TABLE_OR NC_("STR_TABLE_OR", "OR") +#define STR_TABLE_DEF NC_("STR_TABLE_DEF", "Sheet") +#define STR_MOVE_TO_END NC_("STR_MOVE_TO_END", "- move to end position -") +#define STR_NO_REF_TABLE NC_("STR_NO_REF_TABLE", "#REF!") +#define STR_PIVOT_NODATA NC_("STR_PIVOT_NODATA", "The pivot table must contain at least one entry.") +#define STR_PIVOT_MOVENOTALLOWED NC_("STR_PIVOT_MOVENOTALLOWED", "The data range can not be deleted.") +#define STR_PIVOT_ERROR NC_("STR_PIVOT_ERROR", "Error creating the pivot table.") +#define STR_PIVOT_NOTEMPTY NC_("STR_PIVOT_NOTEMPTY", "The destination range is not empty. Overwrite existing contents?") +#define STR_PIVOT_REMOVE_PIVOTCHART NC_("STR_PIVOT_REMOVE_PIVOTCHART", "Deleting the pivot table will also remove any associated pivot charts.\nDo you want to proceed?") +#define STR_DATAPILOT_SUBTOTAL NC_("STR_DATAPILOT_SUBTOTAL", "The source range contains subtotals which may distort the results. Use it anyway?") +#define STR_PIVOT_TOTAL NC_("STR_PIVOT_TOTAL", "Total") +#define STR_PIVOT_DATA NC_("STR_PIVOT_DATA", "Data") +#define STR_PIVOT_GROUP NC_("STR_PIVOT_GROUP", "Group") +#define STR_PIVOT_ROW_LABELS NC_("STR_PIVOT_ROW_LABELS", "Row Labels") +#define STR_PIVOT_COL_LABELS NC_("STR_PIVOT_COL_LABELS", "Column Labels") +/* %1 will be replaced by STR_SELCOUNT_ROWARG, and %2 by STR_SELCOUNT_COLARG + e.g. Selected: 1 row, 2 columns */ +#define STR_SELCOUNT NC_("STR_SELCOUNT", "Selected: %1, %2") +// STR_SELCOUNT_ROWARG is %1 of STR_SELCOUNT. %d of STR_SELCOUNT_ROWARG is number of rows +#define STR_SELCOUNT_ROWARG NNC_("STR_SELCOUNT_ROWARG", "%d row", "%d rows") +// STR_SELCOUNT_COLARG is %2 of STR_SELCOUNT. %d of STR_SELCOUNT_ROWARG is number of columns +#define STR_SELCOUNT_COLARG NNC_("STR_SELCOUNT_COLARG", "%d column", "%d columns") +#define STR_FILTER_SELCOUNT NC_("STR_FILTER_SELCOUNT", "%1 of %2 records found") +#define STR_COLUMN NC_("STR_COLUMN", "Column") +#define STR_ROW NC_("STR_ROW", "Row") +#define STR_PAGE NC_("STR_PAGE", "Page") +#define STR_PGNUM NC_("STR_PGNUM", "Page %1") +#define STR_LOAD_DOC NC_("STR_LOAD_DOC", "Load document") +#define STR_SAVE_DOC NC_("STR_SAVE_DOC", "Save document") +#define STR_AREA_ALREADY_INSERTED NC_("STR_AREA_ALREADY_INSERTED", "This range has already been inserted.") +#define STR_INVALID_TABREF NC_("STR_INVALID_TABREF", "Invalid sheet reference.") +#define STR_INVALID_QUERYAREA NC_("STR_INVALID_QUERYAREA", "This range does not contain a valid query.") +#define STR_REIMPORT_EMPTY NC_("STR_REIMPORT_EMPTY", "This range does not contain imported data.") +#define STR_NOMULTISELECT NC_("STR_NOMULTISELECT", "This function cannot be used with multiple selections.") +#define STR_FILL_SERIES_PROGRESS NC_("STR_FILL_SERIES_PROGRESS", "Fill Row...") +#define STR_UNDO_THESAURUS NC_("STR_UNDO_THESAURUS", "Thesaurus") +#define STR_FILL_TAB NC_("STR_FILL_TAB", "Fill Sheets") +#define STR_UPDATE_SCENARIO NC_("STR_UPDATE_SCENARIO", "Add selected ranges to current scenario?") +#define STR_ERR_NEWSCENARIO NC_("STR_ERR_NEWSCENARIO", "The scenario ranges must be selected in order to be able to create a new scenario.") +#define STR_NOAREASELECTED NC_("STR_NOAREASELECTED", "A range has not been selected.") +#define STR_NEWTABNAMENOTUNIQUE NC_("STR_NEWTABNAMENOTUNIQUE", "This name already exists.") +#define STR_INVALIDTABNAME NC_("STR_INVALIDTABNAME", "Invalid sheet name.\n\nThe sheet name must not:\n• be empty\n• already exist\n• contain [ ] * ? : / \\ \n• use ' (apostrophe) as first or last character.") +#define STR_SCENARIO NC_("STR_SCENARIO", "Scenario") +#define STR_PIVOT_TABLE NC_("STR_PIVOT_TABLE", "Pivot Table") + // Text strings for captions of subtotal functions. +#define STR_FUN_TEXT_SUM NC_("STR_FUN_TEXT_SUM", "Sum") +#define STR_FUN_TEXT_SELECTION_COUNT NC_("STR_FUN_TEXT_SELECTION_COUNT", "Selection count") +#define STR_FUN_TEXT_COUNT NC_("STR_FUN_TEXT_COUNT", "Count") +#define STR_FUN_TEXT_COUNT2 NC_("STR_FUN_TEXT_COUNT2", "CountA") +#define STR_FUN_TEXT_AVG NC_("STR_FUN_TEXT_AVG", "Average") +#define STR_FUN_TEXT_MEDIAN NC_("STR_FUN_TEXT_MEDIAN", "Median") +#define STR_FUN_TEXT_MAX NC_("STR_FUN_TEXT_MAX", "Max") +#define STR_FUN_TEXT_MIN NC_("STR_FUN_TEXT_MIN", "Min") +#define STR_FUN_TEXT_PRODUCT NC_("STR_FUN_TEXT_PRODUCT", "Product") +#define STR_FUN_TEXT_STDDEV NC_("STR_FUN_TEXT_STDDEV", "StDev") +#define STR_FUN_TEXT_VAR NC_("STR_FUN_TEXT_VAR", "Var") +#define STR_TABLE_GRAND_AVG NC_("STR_TABLE_GRAND_AVG", "Grand Average") +#define STR_TABLE_GRAND_COUNT NC_("STR_TABLE_GRAND_COUNT", "Grand Count") +#define STR_TABLE_GRAND_MAX NC_("STR_TABLE_GRAND_MAX", "Grand Max") +#define STR_TABLE_GRAND_MIN NC_("STR_TABLE_GRAND_MIN", "Grand Min") +#define STR_TABLE_GRAND_PRODUCT NC_("STR_TABLE_GRAND_PRODUCT", "Grand Product") +#define STR_TABLE_GRAND_STDDEV NC_("STR_TABLE_GRAND_STDDEV", "Grand StdDev") +#define STR_TABLE_GRAND_SUM NC_("STR_TABLE_GRAND_SUM", "Grand Sum") +#define STR_TABLE_GRAND_VAR NC_("STR_TABLE_GRAND_VAR", "Grand Var") +#define STR_NOCHARTATCURSOR NC_("STR_NOCHARTATCURSOR", "No chart found at this position.") +#define STR_PIVOT_NOTFOUND NC_("STR_PIVOT_NOTFOUND", "No pivot table found at this position.") +#define STR_EMPTYDATA NC_("STR_EMPTYDATA", "(empty)") +#define STR_PRINT_INVALID_AREA NC_("STR_PRINT_INVALID_AREA", "Invalid print range") +#define STR_PAGESTYLE NC_("STR_PAGESTYLE", "Page Style") +#define STR_HEADER NC_("STR_HEADER", "Header") +#define STR_FOOTER NC_("STR_FOOTER", "Footer") +#define STR_TEXTATTRS NC_("STR_TEXTATTRS", "Text Attributes") +#define STR_PROTECTIONERR NC_("STR_PROTECTIONERR", "Protected cells can not be modified.") +#define STR_READONLYERR NC_("STR_READONLYERR", "Document opened in read-only mode.") +#define STR_MATRIXFRAGMENTERR NC_("STR_MATRIXFRAGMENTERR", "You cannot change only part of an array.") +#define STR_PAGEHEADER NC_("STR_PAGEHEADER", "Header") +#define STR_PAGEFOOTER NC_("STR_PAGEFOOTER", "Footer") + +/* BEGIN error constants and error strings. */ +#define STR_ERROR_STR NC_("STR_ERROR_STR", "Err:") +/* BEGIN defined ERROR.TYPE() values. */ +/* ERROR.TYPE( #DIV/0! ) == 2 */ +#define STR_LONG_ERR_DIV_ZERO NC_("STR_LONG_ERR_DIV_ZERO", "Error: Division by zero") +/* ERROR.TYPE( #VALUE! ) == 3 */ +#define STR_LONG_ERR_NO_VALUE NC_("STR_LONG_ERR_NO_VALUE", "Error: No value") +/* ERROR.TYPE( #REF! ) == 4 */ +#define STR_LONG_ERR_NO_REF NC_("STR_LONG_ERR_NO_REF", "Error: Not a valid reference") +/* ERROR.TYPE( #NAME! ) == 5 */ +#define STR_LONG_ERR_NO_NAME NC_("STR_LONG_ERR_NO_NAME", "Error: Invalid name") +/* ERROR.TYPE( #NUM! ) == 6 */ +#define STR_LONG_ERR_ILL_FPO NC_("STR_LONG_ERR_ILL_FPO", "Error: Invalid numeric value") +/* ERROR.TYPE( #N/A ) == 7 */ +#define STR_LONG_ERR_NV NC_("STR_LONG_ERR_NV", "Error: Value not available") +/* END defined ERROR.TYPE() values. */ +#define STR_NO_ADDIN NC_("STR_NO_ADDIN", "#ADDIN?") +#define STR_LONG_ERR_NO_ADDIN NC_("STR_LONG_ERR_NO_ADDIN", "Error: Add-in not found") +#define STR_NO_MACRO NC_("STR_NO_MACRO", "#MACRO?") +#define STR_LONG_ERR_NO_MACRO NC_("STR_LONG_ERR_NO_MACRO", "Error: Macro not found") +#define STR_LONG_ERR_SYNTAX NC_("STR_LONG_ERR_SYNTAX", "Internal syntactical error") +#define STR_LONG_ERR_NO_CODE NC_("STR_LONG_ERR_NO_CODE", "Error: No code or intersection") +#define STR_LONG_ERR_ILL_ARG NC_("STR_LONG_ERR_ILL_ARG", "Error: Invalid argument") +#define STR_LONG_ERR_ILL_PAR NC_("STR_LONG_ERR_ILL_PAR", "Error in parameter list") +#define STR_LONG_ERR_ILL_CHAR NC_("STR_LONG_ERR_ILL_CHAR", "Error: Invalid character") +#define STR_LONG_ERR_PAIR NC_("STR_LONG_ERR_PAIR", "Error: in bracketing") +#define STR_LONG_ERR_OP_EXP NC_("STR_LONG_ERR_OP_EXP", "Error: Operator missing") +#define STR_LONG_ERR_VAR_EXP NC_("STR_LONG_ERR_VAR_EXP", "Error: Variable missing") +#define STR_LONG_ERR_CODE_OVF NC_("STR_LONG_ERR_CODE_OVF", "Error: Formula overflow") +#define STR_LONG_ERR_STR_OVF NC_("STR_LONG_ERR_STR_OVF", "Error: String overflow") +#define STR_LONG_ERR_STACK_OVF NC_("STR_LONG_ERR_STACK_OVF", "Error: Internal overflow") +#define STR_LONG_ERR_MATRIX_SIZE NC_("STR_LONG_ERR_MATRIX_SIZE", "Error: Array or matrix size") +#define STR_LONG_ERR_CIRC_REF NC_("STR_LONG_ERR_CIRC_REF", "Error: Circular reference") +#define STR_LONG_ERR_NO_CONV NC_("STR_LONG_ERR_NO_CONV", "Error: Calculation does not converge") +/* END error constants and error strings. */ + +#define STR_CELL_FILTER NC_("STR_CELL_FILTER", "Filter") +#define STR_TARGETNOTFOUND NC_("STR_TARGETNOTFOUND", "The target database range does not exist.") +#define STR_INVALID_EPS NC_("STR_INVALID_EPS", "Invalid increment") +#define STR_UNDO_TABOP NC_("STR_UNDO_TABOP", "Multiple operations") +#define STR_INVALID_AFNAME NC_("STR_INVALID_AFNAME", "You have entered an invalid name.\nAutoFormat could not be created. \nTry again using a different name.") +#define STR_AREA NC_("STR_AREA", "Range") +#define STR_YES NC_("STR_YES", "Yes") +#define STR_NO NC_("STR_NO", "No") +#define STR_PROTECTION NC_("STR_PROTECTION", "Protection") +#define STR_FORMULAS NC_("STR_FORMULAS", "Formulas") +#define STR_HIDE NC_("STR_HIDE", "Hide") +#define STR_PRINT NC_("STR_PRINT", "Print") +#define STR_INVALID_AFAREA NC_("STR_INVALID_AFAREA", "To apply an AutoFormat,\na table range of at least\n3 × 3 cells must be selected.") +#define STR_OPTIONAL NC_("STR_OPTIONAL", "(optional)") +#define STR_REQUIRED NC_("STR_REQUIRED", "(required)") +#define STR_NOTES NC_("STR_NOTES", "Comments") +/* %d will be replaced by the number of selected sheets + e.g. Are you sure you want to delete the 3 selected sheets? */ +#define STR_QUERY_DELTAB NNC_("STR_QUERY_DELTAB", "Are you sure you want to delete the selected sheet?", "Are you sure you want to delete the %d selected sheets?") +#define STR_QUERY_DELSCENARIO NC_("STR_QUERY_DELSCENARIO", "Are you sure you want to delete the selected scenario?") +#define STR_EXPORT_ASCII NC_("STR_EXPORT_ASCII", "Export Text File") +#define STR_IMPORT_LOTUS NC_("STR_IMPORT_LOTUS", "Import Lotus files") +#define STR_IMPORT_DBF NC_("STR_IMPORT_DBF", "Import dBASE files") +#define STR_EXPORT_DBF NC_("STR_EXPORT_DBF", "dBASE export") +#define STR_EXPORT_DIF NC_("STR_EXPORT_DIF", "Dif Export") +#define STR_IMPORT_DIF NC_("STR_IMPORT_DIF", "Dif Import") +#define STR_STYLENAME_STANDARD NC_("STR_STYLENAME_STANDARD", "Default") +#define STR_STYLENAME_HEADING NC_("STR_STYLENAME_HEADING", "Heading") +#define STR_STYLENAME_HEADING_1 NC_("STR_STYLENAME_HEADING_1", "Heading 1") +#define STR_STYLENAME_HEADING_2 NC_("STR_STYLENAME_HEADING_2", "Heading 2") +#define STR_STYLENAME_TEXT NC_("STR_STYLENAME_TEXT", "Text") +#define STR_STYLENAME_NOTE NC_("STR_STYLENAME_NOTE", "Note") +#define STR_STYLENAME_FOOTNOTE NC_("STR_STYLENAME_FOOTNOTE", "Footnote") +#define STR_STYLENAME_HYPERLINK NC_("STR_STYLENAME_HYPERLINK", "Hyperlink") +#define STR_STYLENAME_STATUS NC_("STR_STYLENAME_STATUS", "Status") +#define STR_STYLENAME_GOOD NC_("STR_STYLENAME_GOOD", "Good") +#define STR_STYLENAME_NEUTRAL NC_("STR_STYLENAME_NEUTRAL", "Neutral") +#define STR_STYLENAME_BAD NC_("STR_STYLENAME_BAD", "Bad") +#define STR_STYLENAME_WARNING NC_("STR_STYLENAME_WARNING", "Warning") +#define STR_STYLENAME_ERROR NC_("STR_STYLENAME_ERROR", "Error") +#define STR_STYLENAME_ACCENT NC_("STR_STYLENAME_ACCENT", "Accent") +#define STR_STYLENAME_ACCENT_1 NC_("STR_STYLENAME_ACCENT_1", "Accent 1") +#define STR_STYLENAME_ACCENT_2 NC_("STR_STYLENAME_ACCENT_2", "Accent 2") +#define STR_STYLENAME_ACCENT_3 NC_("STR_STYLENAME_ACCENT_3", "Accent 3") +#define STR_STYLENAME_RESULT NC_("STR_STYLENAME_RESULT", "Result") +#define STR_STYLENAME_RESULT1 NC_("STR_STYLENAME_RESULT1", "Result2") +#define STR_STYLENAME_REPORT NC_("STR_STYLENAME_REPORT", "Report") +#define STR_THESAURUS_NO_STRING NC_("STR_THESAURUS_NO_STRING", "Thesaurus can only be used in text cells!") +#define STR_SPELLING_BEGIN_TAB NC_("STR_SPELLING_BEGIN_TAB", "Should the spellcheck be continued at the beginning of the current sheet?") +#define STR_SPELLING_NO_LANG NC_("STR_SPELLING_NO_LANG", "is not available for the thesaurus.\nPlease check your installation and install \nthe desired language if necessary") +#define STR_SPELLING_STOP_OK NC_("STR_SPELLING_STOP_OK", "The spellcheck of this sheet has been completed.") +#define STR_UNDO_INSERT_TAB NC_("STR_UNDO_INSERT_TAB", "Insert Sheet") +#define STR_UNDO_DELETE_TAB NC_("STR_UNDO_DELETE_TAB", "Delete Sheets") +#define STR_UNDO_RENAME_TAB NC_("STR_UNDO_RENAME_TAB", "Rename Sheet") +#define STR_UNDO_SET_TAB_BG_COLOR NC_("STR_UNDO_SET_TAB_BG_COLOR", "Color Tab") +#define STR_UNDO_SET_MULTI_TAB_BG_COLOR NC_("STR_UNDO_SET_MULTI_TAB_BG_COLOR", "Color Tabs") +#define STR_UNDO_MOVE_TAB NC_("STR_UNDO_MOVE_TAB", "Move Sheets") +#define STR_UNDO_COPY_TAB NC_("STR_UNDO_COPY_TAB", "Copy Sheet") +#define STR_UNDO_APPEND_TAB NC_("STR_UNDO_APPEND_TAB", "Append sheet") +#define STR_UNDO_SHOWTAB NC_("STR_UNDO_SHOWTAB", "Show Sheet") +#define STR_UNDO_SHOWTABS NC_("STR_UNDO_SHOWTABS", "Show Sheets") +#define STR_UNDO_HIDETAB NC_("STR_UNDO_HIDETAB", "Hide sheet") +#define STR_UNDO_HIDETABS NC_("STR_UNDO_HIDETABS", "Hide sheets") +#define STR_UNDO_TAB_RTL NC_("STR_UNDO_TAB_RTL", "Flip sheet") +#define STR_ABSREFLOST NC_("STR_ABSREFLOST", "The new table contains absolute references to other tables which may be incorrect!") +#define STR_NAMECONFLICT NC_("STR_NAMECONFLICT", "Due to identical names, an existing range name in the destination document has been altered!") +#define STR_ERR_AUTOFILTER NC_("STR_ERR_AUTOFILTER", "AutoFilter not possible") +#define STR_CREATENAME_REPLACE NC_("STR_CREATENAME_REPLACE", "Replace existing definition of #?") +#define STR_CREATENAME_MARKERR NC_("STR_CREATENAME_MARKERR", "Invalid selection for range names") +#define STR_CONSOLIDATE_ERR1 NC_("STR_CONSOLIDATE_ERR1", "References can not be inserted above the source data.") +#define STR_SCENARIO_NOTFOUND NC_("STR_SCENARIO_NOTFOUND", "Scenario not found") +#define STR_QUERY_DELENTRY NC_("STR_QUERY_DELENTRY", "Do you really want to delete the entry #?") +#define STR_VOBJ_OBJECT NC_("STR_VOBJ_OBJECT", "Objects/Images") +#define STR_VOBJ_CHART NC_("STR_VOBJ_CHART", "Charts") +#define STR_VOBJ_DRAWINGS NC_("STR_VOBJ_DRAWINGS", "Drawing Objects") +#define STR_VOBJ_MODE_SHOW NC_("STR_VOBJ_MODE_SHOW", "Show") +#define STR_VOBJ_MODE_HIDE NC_("STR_VOBJ_MODE_HIDE", "Hide") +#define STR_SCATTR_PAGE_TOPDOWN NC_("STR_SCATTR_PAGE_TOPDOWN", "Top to bottom") +#define STR_SCATTR_PAGE_LEFTRIGHT NC_("STR_SCATTR_PAGE_LEFTRIGHT", "Left-to-right") +#define STR_SCATTR_PAGE_NOTES NC_("STR_SCATTR_PAGE_NOTES", "Comments") +#define STR_SCATTR_PAGE_GRID NC_("STR_SCATTR_PAGE_GRID", "Grid") +#define STR_SCATTR_PAGE_HEADERS NC_("STR_SCATTR_PAGE_HEADERS", "Row & Column Headers") +#define STR_SCATTR_PAGE_FORMULAS NC_("STR_SCATTR_PAGE_FORMULAS", "Formulas") +#define STR_SCATTR_PAGE_NULLVALS NC_("STR_SCATTR_PAGE_NULLVALS", "Zero Values") +#define STR_SCATTR_PAGE_PRINTDIR NC_("STR_SCATTR_PAGE_PRINTDIR", "Print direction") +#define STR_SCATTR_PAGE_FIRSTPAGENO NC_("STR_SCATTR_PAGE_FIRSTPAGENO", "First page number") +#define STR_SCATTR_PAGE_SCALE NC_("STR_SCATTR_PAGE_SCALE", "Reduce/enlarge printout") +#define STR_SCATTR_PAGE_SCALETOPAGES NC_("STR_SCATTR_PAGE_SCALETOPAGES", "Shrink print range(s) on number of pages") +#define STR_SCATTR_PAGE_SCALETO NC_("STR_SCATTR_PAGE_SCALETO", "Shrink print range(s) to width/height") +#define STR_SCATTR_PAGE_SCALE_WIDTH NC_("STR_SCATTR_PAGE_SCALE_WIDTH", "Width") +#define STR_SCATTR_PAGE_SCALE_HEIGHT NC_("STR_SCATTR_PAGE_SCALE_HEIGHT", "Height") +#define STR_SCATTR_PAGE_SCALE_PAGES NNC_("STR_SCATTR_PAGE_SCALE_PAGES", "One page", "%1 pages") +#define STR_SCATTR_PAGE_SCALE_AUTO NC_("STR_SCATTR_PAGE_SCALE_AUTO", "automatic") +#define STR_DOC_STAT NC_("STR_DOC_STAT", "Statistics") +#define STR_LINKERROR NC_("STR_LINKERROR", "The link could not be updated.") +#define STR_LINKERRORFILE NC_("STR_LINKERRORFILE", "File:") +#define STR_LINKERRORTAB NC_("STR_LINKERRORTAB", "Sheet:") +#define STR_OVERVIEW NC_("STR_OVERVIEW", "Overview") +#define STR_DOC_INFO NC_("STR_DOC_INFO", "Doc.Information") +#define STR_DOC_PRINTED NC_("STR_DOC_PRINTED", "Printed") +#define STR_BY NC_("STR_BY", "by") +#define STR_ON NC_("STR_ON", "on") +#define STR_RELOAD_TABLES NC_("STR_RELOAD_TABLES", "Automatic update of external links has been disabled.") +#define STR_TRUST_DOCUMENT_WARNING NC_("STR_TRUST_DOCUMENT_WARNING", "Are you sure you trust this document?") +#define STR_WEBSERVICE_WITH_LINKS_WARNING NC_("STR_WEBSERVICE_WITH_LINKS_WARNING", "Links to remote locations can be constructed that transmit local data to the remote server.") +#define STR_REIMPORT_AFTER_LOAD NC_("STR_REIMPORT_AFTER_LOAD", "This file contains queries. The results of these queries were not saved.\nDo you want these queries to be repeated?") +#define STR_INSERT_FULL NC_("STR_INSERT_FULL", "Filled cells cannot be shifted\nbeyond the sheet.") +#define STR_TABINSERT_ERROR NC_("STR_TABINSERT_ERROR", "The table could not be inserted.") +#define STR_TABREMOVE_ERROR NC_("STR_TABREMOVE_ERROR", "The sheets could not be deleted.") +#define STR_PASTE_ERROR NC_("STR_PASTE_ERROR", "The contents of the clipboard could not be pasted.") +#define STR_PASTE_FULL NC_("STR_PASTE_FULL", "There is not enough space on the sheet to insert here.") +#define STR_PASTE_BIGGER NC_("STR_PASTE_BIGGER", "The content of the clipboard is bigger than the range selected.\nDo you want to insert it anyway?") +#define STR_ERR_NOREF NC_("STR_ERR_NOREF", "No cell references are found in the selected cells.") +#define STR_GRAPHICNAME NC_("STR_GRAPHICNAME", "Image") +#define STR_INVALIDNAME NC_("STR_INVALIDNAME", "Invalid name.") +#define STR_VALID_MACRONOTFOUND NC_("STR_VALID_MACRONOTFOUND", "Selected macro not found.") +#define STR_VALID_DEFERROR NC_("STR_VALID_DEFERROR", "Invalid value.") +#define STR_PROGRESS_CALCULATING NC_("STR_PROGRESS_CALCULATING", "calculating") +#define STR_PROGRESS_SORTING NC_("STR_PROGRESS_SORTING", "sorting") +#define STR_PROGRESS_HEIGHTING NC_("STR_PROGRESS_HEIGHTING", "Adapt row height") +#define STR_PROGRESS_COMPARING NC_("STR_PROGRESS_COMPARING", "Compare #") +#define STR_DETINVALID_OVERFLOW NC_("STR_DETINVALID_OVERFLOW", "The maximum number of invalid cells has been exceeded.\nNot all invalid cells have been marked.") +#define STR_QUICKHELP_DELETE NC_("STR_QUICKHELP_DELETE", "Delete contents") +#define STR_QUICKHELP_REF NC_("STR_QUICKHELP_REF", "%1 R × %2 C") +#define STR_FUNCTIONLIST_MORE NC_("STR_FUNCTIONLIST_MORE", "More...") +#define STR_ERR_INVALID_AREA NC_("STR_ERR_INVALID_AREA", "Invalid range") +#define STR_CHARTTITLE NC_("STR_CHARTTITLE", "Chart Title") +#define STR_AXISTITLE NC_("STR_AXISTITLE", "Axis Title") +// Templates for data pilot tables. +#define STR_PIVOT_STYLENAME_INNER NC_("STR_PIVOT_STYLE_INNER", "Pivot Table Value") +#define STR_PIVOT_STYLENAME_RESULT NC_("STR_PIVOT_STYLE_RESULT", "Pivot Table Result") +#define STR_PIVOT_STYLENAME_CATEGORY NC_("STR_PIVOT_STYLE_CATEGORY", "Pivot Table Category") +#define STR_PIVOT_STYLENAME_TITLE NC_("STR_PIVOT_STYLE_TITLE", "Pivot Table Title") +#define STR_PIVOT_STYLENAME_FIELDNAME NC_("STR_PIVOT_STYLE_FIELDNAME", "Pivot Table Field") +#define STR_PIVOT_STYLENAME_TOP NC_("STR_PIVOT_STYLE_TOP", "Pivot Table Corner") +#define STR_OPERATION_FILTER NC_("STR_OPERATION_FILTER", "Filter") +#define STR_OPERATION_SORT NC_("STR_OPERATION_SORT", "Sort") +#define STR_OPERATION_SUBTOTAL NC_("STR_OPERATION_SUBTOTAL", "Subtotals") +#define STR_OPERATION_NONE NC_("STR_OPERATION_NONE", "None") +#define STR_IMPORT_REPLACE NC_("STR_IMPORT_REPLACE", "Do you want to replace the contents of #?") +#define STR_TIP_WIDTH NC_("STR_TIP_WIDTH", "Width:") +#define STR_TIP_HEIGHT NC_("STR_TIP_HEIGHT", "Height:") +#define STR_TIP_HIDE NC_("STR_TIP_HIDE", "Hide") +#define STR_CHANGED_BLANK NC_("STR_CHANGED_BLANK", "<empty>") +#define STR_CHANGED_CELL NC_("STR_CHANGED_CELL", "Cell #1 changed from '#2' to '#3'") +#define STR_CHANGED_INSERT NC_("STR_CHANGED_INSERT", "#1 inserted") +#define STR_CHANGED_DELETE NC_("STR_CHANGED_DELETE", "#1 deleted") +#define STR_CHANGED_MOVE NC_("STR_CHANGED_MOVE", "Range moved from #1 to #2") +#define STR_END_REDLINING NC_("STR_END_REDLINING", "This action will exit the change recording mode.\nAny information about changes will be lost.\n\nExit change recording mode?\n\n") +#define STR_CLOSE_ERROR_LINK NC_("STR_CLOSE_ERROR_LINK", "The document can not be closed while a link is being updated.") +#define STR_UNDO_RESIZEMATRIX NC_("STR_UNDO_RESIZEMATRIX", "Adapt array area") +#define STR_TIP_RESIZEMATRIX NC_("STR_TIP_RESIZEMATRIX", "Array formula %1 R × %2 C") +#define STR_UNDO_HANGULHANJA NC_("STR_UNDO_HANGULHANJA", "Hangul/Hanja Conversion") +#define STR_NAME_INPUT_CELL NC_("STR_NAME_INPUT_CELL", "Select Cell") +#define STR_NAME_INPUT_RANGE NC_("STR_NAME_INPUT_RANGE", "Select Range") +#define STR_NAME_INPUT_DBRANGE NC_("STR_NAME_INPUT_DBRANGE", "Select Database Range") +#define STR_NAME_INPUT_ROW NC_("STR_NAME_INPUT_ROW", "Go To Row") +#define STR_NAME_INPUT_SHEET NC_("STR_NAME_INPUT_SHEET", "Go To Sheet") +#define STR_NAME_INPUT_DEFINE NC_("STR_NAME_INPUT_DEFINE", "Define Name for Range") +#define STR_NAME_ERROR_SELECTION NC_("STR_NAME_ERROR_SELECTION", "The selection needs to be rectangular in order to name it.") +#define STR_NAME_ERROR_NAME NC_("STR_NAME_ERROR_NAME", "You must enter a valid reference or type a valid name for the selected range.") +#define STR_CHANGED_MOVE_REJECTION_WARNING NC_("STR_CHANGED_MOVE_REJECTION_WARNING", "WARNING: This action may have resulted in unintended changes to cell references in formulas.") +#define STR_CHANGED_DELETE_REJECTION_WARNING NC_("STR_CHANGED_DELETE_REJECTION_WARNING", "WARNING: This action may have resulted in references to the deleted area not being restored.") +#define STR_UNDO_CHINESE_TRANSLATION NC_("STR_UNDO_CHINESE_TRANSLATION", "Chinese conversion") +#define STR_ERR_DATAPILOT_INPUT NC_("STR_ERR_DATAPILOT_INPUT", "You cannot change this part of the pivot table.") +#define STR_RECALC_MANUAL NC_("STR_RECALC_MANUAL", "Manual") +#define STR_RECALC_AUTO NC_("STR_RECALC_AUTO", "Automatic") +#define STR_ERR_LONG_NESTED_ARRAY NC_("STR_ERR_LONG_NESTED_ARRAY", "Nested arrays are not supported.") +#define STR_ERR_LONG_BAD_ARRAY_CONTENT NC_("STR_ERR_LONG_BAD_ARRAY_CONTENT", "Unsupported inline array content.") +#define STR_UNDO_TEXTTOCOLUMNS NC_("STR_UNDO_TEXTTOCOLUMNS", "Text to Columns") +#define STR_DOC_UPDATED NC_("STR_DOC_UPDATED", "Your spreadsheet has been updated with changes saved by other users.") +#define STR_DOC_WILLBESAVED NC_("STR_DOC_WILLBESAVED", "The spreadsheet must be saved now to activate sharing mode.\n\nDo you want to continue?") +#define STR_DOC_WILLNOTBESAVED NC_("STR_DOC_WILLNOTBESAVED", "Already resolved merge conflicts will be lost and your changes to the shared spreadsheet will not be saved.\n\nDo you want to continue?") +#define STR_DOC_DISABLESHARED NC_("STR_DOC_DISABLESHARED", "Disabling shared mode of a spreadsheet hinders all other users of the shared spreadsheet to merge back their work.\n\nDo you want to continue?") +#define STR_DOC_NOLONGERSHARED NC_("STR_DOC_NOLONGERSHARED", "This spreadsheet is no longer in shared mode.\n\nSave your spreadsheet to a separate file and merge your changes to the shared spreadsheet manually.") +#define STR_FILE_LOCKED_TRY_LATER NC_("STR_FILE_LOCKED_TRY_LATER", "The shared spreadsheet file is locked due to a merge in progress by user: '%1'\n\nSharing mode of a locked file cannot be disabled. Try again later.") +#define STR_FILE_LOCKED_SAVE_LATER NC_("STR_FILE_LOCKED_SAVE_LATER", "The shared spreadsheet file is locked due to a merge in progress by user: '%1'\n\nTry again later to save your changes.") +#define STR_UNKNOWN_USER NC_("STR_UNKNOWN_USER", "Unknown User") +#define STR_SHAPE_AUTOSHAPE NC_("STR_SHAPE_AUTOSHAPE", "AutoShape") +#define STR_SHAPE_RECTANGLE NC_("STR_SHAPE_RECTANGLE", "Rectangle") +#define STR_SHAPE_LINE NC_("STR_SHAPE_LINE", "Line") +#define STR_SHAPE_OVAL NC_("STR_SHAPE_OVAL", "Oval") +#define STR_FORM_BUTTON NC_("STR_FORM_BUTTON", "Button") +#define STR_FORM_CHECKBOX NC_("STR_FORM_CHECKBOX", "Check Box") +#define STR_FORM_OPTIONBUTTON NC_("STR_FORM_OPTIONBUTTON", "Option Button") +#define STR_FORM_LABEL NC_("STR_FORM_LABEL", "Label") +#define STR_FORM_LISTBOX NC_("STR_FORM_LISTBOX", "List Box") +#define STR_FORM_GROUPBOX NC_("STR_FORM_GROUPBOX", "Group Box") +#define STR_FORM_DROPDOWN NC_("STR_FORM_DROPDOWN", "Drop Down") +#define STR_FORM_SPINNER NC_("STR_FORM_SPINNER", "Spinner") +#define STR_FORM_SCROLLBAR NC_("STR_FORM_SCROLLBAR", "Scroll Bar") +#define STR_STYLE_FAMILY_CELL NC_("STR_STYLE_FAMILY_CELL", "Cell Styles") +#define STR_STYLE_FAMILY_PAGE NC_("STR_STYLE_FAMILY_PAGE", "Page Styles") +#define STR_STYLE_FAMILY_GRAPHICS NC_("STR_STYLE_FAMILY_GRAPHICS", "Drawing Styles") +#define STR_ERR_DATAPILOTSOURCE NC_("STR_ERR_DATAPILOTSOURCE", "Pivot table source data is invalid.") +#define STR_OPTIONS_WARN_SEPARATORS NC_("STR_OPTIONS_WARN_SEPARATORS", "Because the current formula separator settings conflict with the locale, the formula separators have been reset to their default values.") +#define STR_UNDO_INSERT_CURRENT_DATE NC_("STR_UNDO_INSERT_CURRENT_DATE", "Insert Current Date") +#define STR_UNDO_INSERT_CURRENT_TIME NC_("STR_UNDO_INSERT_CURRENT_TIME", "Insert Current Time") +#define STR_MANAGE_NAMES NC_("STR_MANAGE_NAMES", "Manage Names...") +#define STR_HEADER_NAME NC_("STR_HEADER_NAME", "Name") +#define STR_HEADER_SCOPE NC_("STR_HEADER_SCOPE", "Scope") +#define STR_MULTI_SELECT NC_("STR_MULTI_SELECT", "(multiple)") +#define STR_GLOBAL_SCOPE NC_("STR_GLOBAL_SCOPE", "Document (Global)") +#define STR_ERR_NAME_EXISTS NC_("STR_ERR_NAME_EXISTS", "Invalid name. Already in use for the selected scope.") +#define STR_ERR_NAME_INVALID NC_("STR_ERR_NAME_INVALID", "Invalid name. Start with a letter, use only letters, numbers and underscore.") +#define STR_UNSAVED_EXT_REF NC_("STR_UNSAVED_EXT_REF", "This Document contains external references to unsaved documents.\n\nDo you want to continue?") +#define STR_CLOSE_WITH_UNSAVED_REFS NC_("STR_CLOSE_WITH_UNSAVED_REFS", "This Document is referenced by another document and not yet saved. Closing it without saving will result in data loss.") +#define STR_COND_CONDITION NC_("STR_COND_CONDITION", "Cell value") +#define STR_COND_COLORSCALE NC_("STR_COND_COLORSCALE", "ColorScale") +#define STR_COND_DATABAR NC_("STR_COND_DATABAR", "DataBar") +#define STR_COND_ICONSET NC_("STR_COND_ICONSET", "IconSet") +#define STR_COND_BETWEEN NC_("STR_COND_BETWEEN", "is between") +#define STR_COND_NOTBETWEEN NC_("STR_COND_NOTBETWEEN", "is not between") +#define STR_COND_UNIQUE NC_("STR_COND_UNIQUE", "is unique") +#define STR_COND_DUPLICATE NC_("STR_COND_DUPLICATE", "is duplicate") +#define STR_COND_FORMULA NC_("STR_COND_FORMULA", "Formula is") +#define STR_COND_TOP10 NC_("STR_COND_TOP10", "is in top elements") +#define STR_COND_BOTTOM10 NC_("STR_COND_BOTTOM10", "is in bottom elements") +#define STR_COND_TOP_PERCENT NC_("STR_COND_TOP_PERCENT", "is in top percent") +#define STR_COND_DATE NC_("STR_COND_DATE", "Date is") +#define STR_COND_BOTTOM_PERCENT NC_("STR_COND_BOTTOM_PERCENT", "is in bottom percent") +#define STR_COND_ABOVE_AVERAGE NC_("STR_COND_ABOVE_AVERAGE", "is above average") +#define STR_COND_BELOW_AVERAGE NC_("STR_COND_BELOW_AVERAGE", "is below average") +#define STR_COND_ABOVE_EQUAL_AVERAGE NC_("STR_COND_ABOVE_EQUAL_AVERAGE", "is above or equal average") +#define STR_COND_BELOW_EQUAL_AVERAGE NC_("STR_COND_BELOW_EQUAL_AVERAGE", "is below or equal average") +#define STR_COND_ERROR NC_("STR_COND_ERROR", "is an error code") +#define STR_COND_NOERROR NC_("STR_COND_NOERROR", "is not an error code") +#define STR_COND_BEGINS_WITH NC_("STR_COND_BEGINS_WITH", "begins with") +#define STR_COND_ENDS_WITH NC_("STR_COND_ENDS_WITH", "ends with") +#define STR_COND_CONTAINS NC_("STR_COND_CONTAINS", "contains") +#define STR_COND_NOT_CONTAINS NC_("STR_COND_NOT_CONTAINS", "does not contain") +#define STR_COND_TODAY NC_("STR_COND_TODAY", "today") +#define STR_COND_YESTERDAY NC_("STR_COND_YESTERDAY", "yesterday") +#define STR_COND_TOMORROW NC_("STR_COND_TOMORROW", "tomorrow") +#define STR_COND_LAST7DAYS NC_("STR_COND_LAST7DAYS", "in the last 7 days") +#define STR_COND_THISWEEK NC_("STR_COND_THISWEEK", "this week") +#define STR_COND_LASTWEEK NC_("STR_COND_LASTWEEK", "last week") +#define STR_COND_NEXTWEEK NC_("STR_COND_NEXTWEEK", "next week") +#define STR_COND_THISMONTH NC_("STR_COND_THISMONTH", "this month") +#define STR_COND_LASTMONTH NC_("STR_COND_LASTMONTH", "last month") +#define STR_COND_NEXTMONTH NC_("STR_COND_NEXTMONTH", "next month") +#define STR_COND_THISYEAR NC_("STR_COND_THISYEAR", "this year") +#define STR_COND_LASTYEAR NC_("STR_COND_LASTYEAR", "last year") +#define STR_COND_NEXTYEAR NC_("STR_COND_NEXTYEAR", "next year") +#define STR_COND_AND NC_("STR_COND_AND", "and") +#define STR_ERR_CONDFORMAT_PROTECTED NC_("STR_ERR_CONDFORMAT_PROTECTED", "Conditional Formats can not be created, deleted or changed in protected sheets.") +#define STR_EDIT_EXISTING_COND_FORMATS NC_("STR_EDIT_EXISTING_COND_FORMATS", "The selected cell already contains conditional formatting. You can either edit the existing conditional format or you define a new overlapping conditional format.\n\n Do you want to edit the existing conditional format?") +#define STR_QUERY_FORMULA_RECALC_ONLOAD_ODS NC_("STR_QUERY_FORMULA_RECALC_ONLOAD_ODS", "This document was last saved by an application other than %PRODUCTNAME. Some formula cells may produce different results when recalculated.\n\nDo you want to recalculate all formula cells in this document now?") +#define STR_QUERY_FORMULA_RECALC_ONLOAD_XLS NC_("STR_QUERY_FORMULA_RECALC_ONLOAD_XLS", "This document was saved in Excel file format (.xlsx). Some formula cells may produce different results when recalculated. \n\nDo you want to recalculate all formula cells now?") +#define STR_NO_INSERT_DELETE_OVER_PIVOT_TABLE NC_("STR_NO_INSERT_DELETE_OVER_PIVOT_TABLE", "You cannot insert or delete cells when the affected range intersects with pivot table.") +#define STR_DPFIELD_GROUP_BY_SECONDS NC_("STR_DPFIELD_GROUP_BY_SECONDS", "Seconds") +#define STR_DPFIELD_GROUP_BY_MINUTES NC_("STR_DPFIELD_GROUP_BY_MINUTES", "Minutes") +#define STR_DPFIELD_GROUP_BY_HOURS NC_("STR_DPFIELD_GROUP_BY_HOURS", "Hours") +#define STR_DPFIELD_GROUP_BY_DAYS NC_("STR_DPFIELD_GROUP_BY_DAYS", "Days") +#define STR_DPFIELD_GROUP_BY_MONTHS NC_("STR_DPFIELD_GROUP_BY_MONTHS", "Months") +#define STR_DPFIELD_GROUP_BY_QUARTERS NC_("STR_DPFIELD_GROUP_BY_QUARTERS", "Quarters") +#define STR_DPFIELD_GROUP_BY_YEARS NC_("STR_DPFIELD_GROUP_BY_YEARS", "Years") +#define STR_INVALIDVAL NC_("STR_INVALIDVAL", "Invalid target value.") +#define STR_INVALIDVAR NC_("STR_INVALIDVAR", "Undefined name for variable cell.") +#define STR_INVALIDFORM NC_("STR_INVALIDFORM", "Undefined name as formula cell.") +#define STR_NOFORMULA NC_("STR_NOFORMULA", "Formula cell must contain a formula.") +#define STR_INVALIDINPUT NC_("STR_INVALIDINPUT", "Invalid input.") +#define STR_INVALIDCONDITION NC_("STR_INVALIDCONDITION", "Invalid condition.") +#define STR_QUERYREMOVE NC_("STR_QUERYREMOVE", "Should the entry\n#\nbe deleted?") +#define STR_COPYLIST NC_("STR_COPYLIST", "Copy List") +#define STR_COPYFROM NC_("STR_COPYFROM", "List from") +#define STR_COPYERR NC_("STR_COPYERR", "Cells without text have been ignored.") +#define STR_PRINT_PREVIEW_NODATA NC_("STR_PRINT_PREVIEW_NODATA", "No Data") +#define STR_PRINT_PREVIEW_EMPTY_RANGE NC_("STR_PRINT_PREVIEW_EMPTY_RANGE", "Print Range Empty") +#define STR_UNDO_CONDFORMAT NC_("STR_UNDO_CONDFORMAT", "Conditional Format") +#define STR_UNDO_CONDFORMAT_LIST NC_("STR_UNDO_CONDFORMAT_LIST", "Conditional Formats") +#define STR_UNDO_FORMULA_TO_VALUE NC_("STR_UNDO_FORMULA_TO_VALUE", "Convert Formula To Value") +#define STR_UNQUOTED_STRING NC_("STR_UNQUOTED_STRING", "Strings without quotes are interpreted as defined names or references or column/row labels.") +#define STR_ENTER_VALUE NC_("STR_ENTER_VALUE", "Enter a value!") +#define STR_TABLE_COUNT NC_("STR_TABLE_COUNT", "Sheet %1 of %2") +#define STR_FUNCTIONS_FOUND NC_("STR_FUNCTIONS_FOUND", "%1 and %2 more") +#define STR_GENERAL NC_("STR_GENERAL", "General") +#define STR_NUMBER NC_("STR_NUMBER", "Number") +#define STR_PERCENT NC_("STR_PERCENT", "Percent") +#define STR_CURRENCY NC_("STR_CURRENCY", "Currency") +#define STR_DATE NC_("STR_DATE", "Date") +#define STR_TIME NC_("STR_TIME", "Time") +#define STR_SCIENTIFIC NC_("STR_SCIENTIFIC", "Scientific") +#define STR_FRACTION NC_("STR_FRACTION", "Fraction") +#define STR_BOOLEAN_VALUE NC_("STR_BOOLEAN_VALUE", "Boolean Value") +#define STR_TEXT NC_("STR_TEXT", "Text") +/* %d will be replaced by the number of selected sheets + e.g. The 3 selected sheets contain source data of related pivot tables that will be lost. */ +#define STR_QUERY_PIVOTTABLE_DELTAB NNC_("STR_QUERY_PIVOTTABLE_DELTAB", "The selected sheet contains source data of related pivot tables that will be lost.", "The %d selected sheets contain source data of related pivot tables that will be lost.") +#define STR_ERR_NAME_INVALID_CELL_REF NC_("STR_ERR_NAME_INVALID_CELL_REF", "Invalid name. Reference to a cell, or a range of cells not allowed.") +#define STR_ERR_LONG_LINK_FORMULA_NEEDING_CHECK NC_("STR_ERR_LONG_LINK_FORMULA_NEEDING_CHECK", "External content disabled.") +#define STR_TEXTORIENTANGLE NC_("STR_TEXTORIENTANGLE", "Text orientation angle") +#define STR_SHRINKTOFITCELL_ON NC_("STR_SHRINKTOFITCELL_ON", "Shrink to fit cell: On") +#define STR_SHRINKTOFITCELL_OFF NC_("STR_SHRINKTOFITCELL_OFF", "Shrink to fit cell: Off") +#define STR_VERTICALSTACKCELL_ON NC_("STR_VERTICALSTACKCELL_ON", "Vertically stacked: On") +#define STR_VERTICALSTACKCELL_OFF NC_("STR_VERTICALSTACKCELL_OFF", "Vertically stacked: Off") +#define STR_LINEBREAKCELL_ON NC_("STR_LINEBREAKCELL_ON", "Wrap text automatically: On") +#define STR_LINEBREAKCELL_OFF NC_("STR_LINEBREAKCELL_OFF", "Wrap text automatically: Off") +#define STR_HYPHENATECELL_ON NC_("STR_HYPHENATECELL_ON", "Hyphenate: On") +#define STR_HYPHENATECELL_OFF NC_("STR_HYPHENATECELL_OFF", "Hyphenate: Off") +#define STR_INDENTCELL NC_("STR_INDENTCELL", "Indent: ") +#define STR_UNDO_INSERT_SPARKLINE_GROUP NC_("STR_UNDO_INSERT_SPARKLINE", "Insert Sparkline Group") +#define STR_UNDO_DELETE_SPARKLINE NC_("STR_UNDO_DELETE_SPARKLINE", "Delete Sparkline") +#define STR_UNDO_DELETE_SPARKLINE_GROUP NC_("STR_UNDO_DELETE_SPARKLINE_GROUP", "Delete Sparkline Group") +#define STR_UNDO_EDIT_SPARKLINE_GROUP NC_("STR_UNDO_EDIT_SPARKLINE_GROUP", "Edit Sparkline Group") +#define STR_UNDO_GROUP_SPARKLINES NC_("STR_UNDO_GROUP_SPARKLINES", "Group Sparklines") +#define STR_UNDO_UNGROUP_SPARKLINES NC_("STR_UNDO_UNGROUP_SPARKLINES", "Ungroup Sparklines") +#define STR_UNDO_EDIT_SPARKLINE NC_("STR_UNDO_EDIT_SPARKLINE", "Edit Sparkline") +#define STR_UNDO_THEME_CHANGE NC_("STR_UNDO_THEME_CHANGE", "Theme Change") +#define STR_UNDO_THEME_COLOR_CHANGE NC_("STR_UNDO_THEME_COLOR_CHANGE", "Theme Color Change") +#define STR_ERR_INSERT_CELLS NC_("STR_ERR_INSERT_CELLS", "Failed to insert cells") + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/grouparealistener.hxx b/sc/inc/grouparealistener.hxx new file mode 100644 index 0000000000..a52dc2fb8a --- /dev/null +++ b/sc/inc/grouparealistener.hxx @@ -0,0 +1,72 @@ +/* -*- 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/. + */ + +#pragma once + +#include "address.hxx" + +#include <svl/listener.hxx> + +#include <vector> + +class ScFormulaCell; +class ScDocument; +class ScColumn; + +namespace sc { + +class BulkDataHint; + +class FormulaGroupAreaListener final : public SvtListener +{ + ScRange maRange; + const ScDocument& mrDocument; + const ScColumn* mpColumn; + SCROW mnTopCellRow; + SCROW mnGroupLen; + bool mbStartFixed; + bool mbEndFixed; + +public: + + FormulaGroupAreaListener() = delete; + FormulaGroupAreaListener( const ScRange& rRange, const ScDocument& rDocument, + const ScAddress& rTopCellPos, SCROW nGroupLen, bool bStartFixed, bool bEndFixed ); + + virtual ~FormulaGroupAreaListener() override; + + ScRange getListeningRange() const; + + virtual void Notify( const SfxHint& rHint ) override; + virtual void Query( QueryBase& rQuery ) const override; + + /** + * Given the row span of changed cells within a single column, collect all + * formula cells that need to be notified of the change. + * + * @param nTab sheet position of the changed cell span. + * @param nCol column position of the changed cell span. + * @param nRow1 top row position of the changed cell span. + * @param nRow2 bottom row position of the changed cell span. + * @param rCells all formula cells that need to be notified are put into + * this container. + */ + void collectFormulaCells( SCTAB nTab, SCCOL nCol, SCROW nRow1, SCROW nRow2, std::vector<ScFormulaCell*>& rCells ) const; + void collectFormulaCells( SCROW nRow1, SCROW nRow2, std::vector<ScFormulaCell*>& rCells ) const; + + const ScFormulaCell* getTopCell() const; + +private: + void notifyCellChange( const SfxHint& rHint, const ScAddress& rPos, SCROW nNumRows ); + void notifyBulkChange( const BulkDataHint& rHint ); +}; + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/helpids.h b/sc/inc/helpids.h new file mode 100644 index 0000000000..eb3f590beb --- /dev/null +++ b/sc/inc/helpids.h @@ -0,0 +1,597 @@ +/* -*- 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 <rtl/ustring.hxx> + +inline constexpr OUString HID_INSWIN_POS = u"SC_HID_INSWIN_POS"_ustr; +inline constexpr OUString HID_INSWIN_CALC = u"SC_HID_INSWIN_CALC"_ustr; +inline constexpr OUString HID_INSWIN_CANCEL = u"SC_HID_INSWIN_CANCEL"_ustr; +inline constexpr OUString HID_INSWIN_OK = u"SC_HID_INSWIN_OK"_ustr; +inline constexpr OUString HID_INSWIN_SUMME = u"SC_HID_INSWIN_SUMME"_ustr; +inline constexpr OUString HID_INSWIN_FUNC = u"SC_HID_INSWIN_FUNC"_ustr; +inline constexpr OUString HID_INSWIN_INPUT = u"SC_HID_INSWIN_INPUT"_ustr; + +// Help IDs for document window ---------------------------------------------- +inline constexpr OUString HID_SC_WIN_GRIDWIN = u"SC_HID_SC_WIN_GRIDWIN"_ustr; +inline constexpr OUString HID_SC_WIN_PREVIEW = u"SC_HID_SC_WIN_PREVIEW"_ustr; + +inline constexpr OUString HID_SC_HEADER_EDIT = u"SC_HID_SC_HEADER_EDIT"_ustr; +inline constexpr OUString HID_SC_FOOTER_EDIT = u"SC_HID_SC_FOOTER_EDIT"_ustr; + +inline constexpr OUString HID_SC_SCENWIN_TOP = u"SC_HID_SC_SCENWIN_TOP"_ustr; +inline constexpr OUString HID_SC_SCENWIN_BOTTOM = u"SC_HID_SC_SCENWIN_BOTTOM"_ustr; + +inline constexpr OUString HID_SC_INPUTWIN = u"SC_HID_SC_INPUTWIN"_ustr; + +inline constexpr OUString HID_SC_RENAME_NAME = u"SC_HID_SC_RENAME_NAME"_ustr; +inline constexpr OUString HID_SC_APPEND_NAME = u"SC_HID_SC_APPEND_NAME"_ustr; + +inline constexpr OUString HID_SC_ADD_AUTOFMT = u"SC_HID_SC_ADD_AUTOFMT"_ustr; +inline constexpr OUString HID_SC_AUTOFMT_NAME = u"SC_HID_SC_AUTOFMT_NAME"_ustr; + +// wrong group - HID_SC_DLG_START is full +inline constexpr OUString HID_SC_REN_AFMT_NAME = u"SC_HID_SC_REN_AFMT_NAME"_ustr; + +inline constexpr OUString HID_CHG_PROTECT = u"SC_HID_CHG_PROTECT"_ustr; + + +inline constexpr OUString HID_SC_REN_AFMT_DLG = u"SC_HID_SC_REN_AFMT_DLG"_ustr; + +// Help IDs for Submenus (max.50) -------------------------------------------- +inline constexpr OUString HID_PASSWD_TABLE = u"SC_HID_PASSWD_TABLE"_ustr; +inline constexpr OUString HID_PASSWD_DOC = u"SC_HID_PASSWD_DOC"_ustr; +inline constexpr OUString HID_PASSWD_DOC_CONFIRM = u"SC_HID_PASSWD_DOC_CONFIRM"_ustr; + + +// Other help IDs (max.70) --------------------------------------------------- +inline constexpr OUString HID_SELECTTABLES = u"SC_HID_SELECTTABLES"_ustr; +inline constexpr OUString HID_GOTOTABLE = u"SC_HID_GOTOTABLE"_ustr; +inline constexpr OUString HID_GOTOTABLEMASK = u"SC_HID_GOTOTABLEMASK"_ustr; + + +// Analysis Addin Functions (max.120) ---------------------------------------- +inline constexpr OUString HID_AAI_FUNC_WORKDAY = u"SC_HID_AAI_FUNC_WORKDAY"_ustr; +inline constexpr OUString HID_AAI_FUNC_YEARFRAC = u"SC_HID_AAI_FUNC_YEARFRAC"_ustr; +inline constexpr OUString HID_AAI_FUNC_EDATE = u"SC_HID_AAI_FUNC_EDATE"_ustr; +inline constexpr OUString HID_AAI_FUNC_WEEKNUM = u"SC_HID_AAI_FUNC_WEEKNUM"_ustr; +inline constexpr OUString HID_AAI_FUNC_EOMONTH = u"SC_HID_AAI_FUNC_EOMONTH"_ustr; +inline constexpr OUString HID_AAI_FUNC_NETWORKDAYS = u"SC_HID_AAI_FUNC_NETWORKDAYS"_ustr; +inline constexpr OUString HID_AAI_FUNC_AMORDEGRC = u"SC_HID_AAI_FUNC_AMORDEGRC"_ustr; +inline constexpr OUString HID_AAI_FUNC_AMORLINC = u"SC_HID_AAI_FUNC_AMORLINC"_ustr; +inline constexpr OUString HID_AAI_FUNC_ACCRINT = u"SC_HID_AAI_FUNC_ACCRINT"_ustr; +inline constexpr OUString HID_AAI_FUNC_ACCRINTM = u"SC_HID_AAI_FUNC_ACCRINTM"_ustr; +inline constexpr OUString HID_AAI_FUNC_RECEIVED = u"SC_HID_AAI_FUNC_RECEIVED"_ustr; +inline constexpr OUString HID_AAI_FUNC_DISC = u"SC_HID_AAI_FUNC_DISC"_ustr; +inline constexpr OUString HID_AAI_FUNC_DURATION = u"SC_HID_AAI_FUNC_DURATION"_ustr; +inline constexpr OUString HID_AAI_FUNC_EFFECT = u"SC_HID_AAI_FUNC_EFFECT"_ustr; +inline constexpr OUString HID_AAI_FUNC_CUMPRINC = u"SC_HID_AAI_FUNC_CUMPRINC"_ustr; +inline constexpr OUString HID_AAI_FUNC_CUMIPMT = u"SC_HID_AAI_FUNC_CUMIPMT"_ustr; +inline constexpr OUString HID_AAI_FUNC_PRICE = u"SC_HID_AAI_FUNC_PRICE"_ustr; +inline constexpr OUString HID_AAI_FUNC_PRICEDISC = u"SC_HID_AAI_FUNC_PRICEDISC"_ustr; +inline constexpr OUString HID_AAI_FUNC_PRICEMAT = u"SC_HID_AAI_FUNC_PRICEMAT"_ustr; +inline constexpr OUString HID_AAI_FUNC_MDURATION = u"SC_HID_AAI_FUNC_MDURATION"_ustr; +inline constexpr OUString HID_AAI_FUNC_NOMINAL = u"SC_HID_AAI_FUNC_NOMINAL"_ustr; +inline constexpr OUString HID_AAI_FUNC_DOLLARFR = u"SC_HID_AAI_FUNC_DOLLARFR"_ustr; +inline constexpr OUString HID_AAI_FUNC_DOLLARDE = u"SC_HID_AAI_FUNC_DOLLARDE"_ustr; +inline constexpr OUString HID_AAI_FUNC_YIELD = u"SC_HID_AAI_FUNC_YIELD"_ustr; +inline constexpr OUString HID_AAI_FUNC_YIELDDISC = u"SC_HID_AAI_FUNC_YIELDDISC"_ustr; +inline constexpr OUString HID_AAI_FUNC_YIELDMAT = u"SC_HID_AAI_FUNC_YIELDMAT"_ustr; +inline constexpr OUString HID_AAI_FUNC_TBILLEQ = u"SC_HID_AAI_FUNC_TBILLEQ"_ustr; +inline constexpr OUString HID_AAI_FUNC_TBILLPRICE = u"SC_HID_AAI_FUNC_TBILLPRICE"_ustr; +inline constexpr OUString HID_AAI_FUNC_TBILLYIELD = u"SC_HID_AAI_FUNC_TBILLYIELD"_ustr; +inline constexpr OUString HID_AAI_FUNC_ODDFPRICE = u"SC_HID_AAI_FUNC_ODDFPRICE"_ustr; +inline constexpr OUString HID_AAI_FUNC_ODDFYIELD = u"SC_HID_AAI_FUNC_ODDFYIELD"_ustr; +inline constexpr OUString HID_AAI_FUNC_ODDLPRICE = u"SC_HID_AAI_FUNC_ODDLPRICE"_ustr; +inline constexpr OUString HID_AAI_FUNC_ODDLYIELD = u"SC_HID_AAI_FUNC_ODDLYIELD"_ustr; +inline constexpr OUString HID_AAI_FUNC_XIRR = u"SC_HID_AAI_FUNC_XIRR"_ustr; +inline constexpr OUString HID_AAI_FUNC_XNPV = u"SC_HID_AAI_FUNC_XNPV"_ustr; +inline constexpr OUString HID_AAI_FUNC_INTRATE = u"SC_HID_AAI_FUNC_INTRATE"_ustr; +inline constexpr OUString HID_AAI_FUNC_COUPNCD = u"SC_HID_AAI_FUNC_COUPNCD"_ustr; +inline constexpr OUString HID_AAI_FUNC_COUPDAYS = u"SC_HID_AAI_FUNC_COUPDAYS"_ustr; +inline constexpr OUString HID_AAI_FUNC_COUPDAYSNC = u"SC_HID_AAI_FUNC_COUPDAYSNC"_ustr; +inline constexpr OUString HID_AAI_FUNC_COUPDAYBS = u"SC_HID_AAI_FUNC_COUPDAYBS"_ustr; +inline constexpr OUString HID_AAI_FUNC_COUPPCD = u"SC_HID_AAI_FUNC_COUPPCD"_ustr; +inline constexpr OUString HID_AAI_FUNC_COUPNUM = u"SC_HID_AAI_FUNC_COUPNUM"_ustr; +inline constexpr OUString HID_AAI_FUNC_FVSCHEDULE = u"SC_HID_AAI_FUNC_FVSCHEDULE"_ustr; +inline constexpr OUString HID_AAI_FUNC_ISEVEN = u"SC_HID_AAI_FUNC_ISEVEN"_ustr; +inline constexpr OUString HID_AAI_FUNC_ISODD = u"SC_HID_AAI_FUNC_ISODD"_ustr; +inline constexpr OUString HID_AAI_FUNC_GCD = u"SC_HID_AAI_FUNC_GCD"_ustr; +inline constexpr OUString HID_AAI_FUNC_LCM = u"SC_HID_AAI_FUNC_LCM"_ustr; +inline constexpr OUString HID_AAI_FUNC_MULTINOMIAL = u"SC_HID_AAI_FUNC_MULTINOMIAL"_ustr; +inline constexpr OUString HID_AAI_FUNC_SERIESSUM = u"SC_HID_AAI_FUNC_SERIESSUM"_ustr; +inline constexpr OUString HID_AAI_FUNC_QUOTIENT = u"SC_HID_AAI_FUNC_QUOTIENT"_ustr; +inline constexpr OUString HID_AAI_FUNC_MROUND = u"SC_HID_AAI_FUNC_MROUND"_ustr; +inline constexpr OUString HID_AAI_FUNC_SQRTPI = u"SC_HID_AAI_FUNC_SQRTPI"_ustr; +inline constexpr OUString HID_AAI_FUNC_RANDBETWEEN = u"SC_HID_AAI_FUNC_RANDBETWEEN"_ustr; +inline constexpr OUString HID_AAI_FUNC_BESSELI = u"SC_HID_AAI_FUNC_BESSELI"_ustr; +inline constexpr OUString HID_AAI_FUNC_BESSELJ = u"SC_HID_AAI_FUNC_BESSELJ"_ustr; +inline constexpr OUString HID_AAI_FUNC_BESSELK = u"SC_HID_AAI_FUNC_BESSELK"_ustr; +inline constexpr OUString HID_AAI_FUNC_BESSELY = u"SC_HID_AAI_FUNC_BESSELY"_ustr; +inline constexpr OUString HID_AAI_FUNC_BIN2DEC = u"SC_HID_AAI_FUNC_BIN2DEC"_ustr; +inline constexpr OUString HID_AAI_FUNC_BIN2HEX = u"SC_HID_AAI_FUNC_BIN2HEX"_ustr; +inline constexpr OUString HID_AAI_FUNC_BIN2OCT = u"SC_HID_AAI_FUNC_BIN2OCT"_ustr; +inline constexpr OUString HID_AAI_FUNC_DELTA = u"SC_HID_AAI_FUNC_DELTA"_ustr; +inline constexpr OUString HID_AAI_FUNC_DEC2BIN = u"SC_HID_AAI_FUNC_DEC2BIN"_ustr; +inline constexpr OUString HID_AAI_FUNC_DEC2HEX = u"SC_HID_AAI_FUNC_DEC2HEX"_ustr; +inline constexpr OUString HID_AAI_FUNC_DEC2OCT = u"SC_HID_AAI_FUNC_DEC2OCT"_ustr; +inline constexpr OUString HID_AAI_FUNC_ERF = u"SC_HID_AAI_FUNC_ERF"_ustr; +inline constexpr OUString HID_AAI_FUNC_ERFC = u"SC_HID_AAI_FUNC_ERFC"_ustr; +inline constexpr OUString HID_AAI_FUNC_GESTEP = u"SC_HID_AAI_FUNC_GESTEP"_ustr; +inline constexpr OUString HID_AAI_FUNC_HEX2BIN = u"SC_HID_AAI_FUNC_HEX2BIN"_ustr; +inline constexpr OUString HID_AAI_FUNC_HEX2DEC = u"SC_HID_AAI_FUNC_HEX2DEC"_ustr; +inline constexpr OUString HID_AAI_FUNC_HEX2OCT = u"SC_HID_AAI_FUNC_HEX2OCT"_ustr; +inline constexpr OUString HID_AAI_FUNC_IMABS = u"SC_HID_AAI_FUNC_IMABS"_ustr; +inline constexpr OUString HID_AAI_FUNC_IMAGINARY = u"SC_HID_AAI_FUNC_IMAGINARY"_ustr; +inline constexpr OUString HID_AAI_FUNC_IMPOWER = u"SC_HID_AAI_FUNC_IMPOWER"_ustr; +inline constexpr OUString HID_AAI_FUNC_IMARGUMENT = u"SC_HID_AAI_FUNC_IMARGUMENT"_ustr; +inline constexpr OUString HID_AAI_FUNC_IMCOS = u"SC_HID_AAI_FUNC_IMCOS"_ustr; +inline constexpr OUString HID_AAI_FUNC_IMDIV = u"SC_HID_AAI_FUNC_IMDIV"_ustr; +inline constexpr OUString HID_AAI_FUNC_IMEXP = u"SC_HID_AAI_FUNC_IMEXP"_ustr; +inline constexpr OUString HID_AAI_FUNC_IMCONJUGATE = u"SC_HID_AAI_FUNC_IMCONJUGATE"_ustr; +inline constexpr OUString HID_AAI_FUNC_IMLN = u"SC_HID_AAI_FUNC_IMLN"_ustr; +inline constexpr OUString HID_AAI_FUNC_IMLOG10 = u"SC_HID_AAI_FUNC_IMLOG10"_ustr; +inline constexpr OUString HID_AAI_FUNC_IMLOG2 = u"SC_HID_AAI_FUNC_IMLOG2"_ustr; +inline constexpr OUString HID_AAI_FUNC_IMPRODUCT = u"SC_HID_AAI_FUNC_IMPRODUCT"_ustr; +inline constexpr OUString HID_AAI_FUNC_IMREAL = u"SC_HID_AAI_FUNC_IMREAL"_ustr; +inline constexpr OUString HID_AAI_FUNC_IMSIN = u"SC_HID_AAI_FUNC_IMSIN"_ustr; +inline constexpr OUString HID_AAI_FUNC_IMSUB = u"SC_HID_AAI_FUNC_IMSUB"_ustr; +inline constexpr OUString HID_AAI_FUNC_IMSUM = u"SC_HID_AAI_FUNC_IMSUM"_ustr; +inline constexpr OUString HID_AAI_FUNC_IMSQRT = u"SC_HID_AAI_FUNC_IMSQRT"_ustr; +inline constexpr OUString HID_AAI_FUNC_COMPLEX = u"SC_HID_AAI_FUNC_COMPLEX"_ustr; +inline constexpr OUString HID_AAI_FUNC_OCT2BIN = u"SC_HID_AAI_FUNC_OCT2BIN"_ustr; +inline constexpr OUString HID_AAI_FUNC_OCT2DEZ = u"SC_HID_AAI_FUNC_OCT2DEZ"_ustr; +inline constexpr OUString HID_AAI_FUNC_OCT2HEX = u"SC_HID_AAI_FUNC_OCT2HEX"_ustr; +inline constexpr OUString HID_AAI_FUNC_CONVERT = u"SC_HID_AAI_FUNC_CONVERT"_ustr; +inline constexpr OUString HID_AAI_FUNC_FACTDOUBLE = u"SC_HID_AAI_FUNC_FACTDOUBLE"_ustr; +inline constexpr OUString HID_AAI_FUNC_IMTAN = u"SC_HID_AAI_FUNC_IMTAN"_ustr; +inline constexpr OUString HID_AAI_FUNC_IMSEC = u"SC_HID_AAI_FUNC_IMSEC"_ustr; +inline constexpr OUString HID_AAI_FUNC_IMCSC = u"SC_HID_AAI_FUNC_IMCSC"_ustr; +inline constexpr OUString HID_AAI_FUNC_IMCOT = u"SC_HID_AAI_FUNC_IMCOT"_ustr; +inline constexpr OUString HID_AAI_FUNC_IMSINH = u"SC_HID_AAI_FUNC_IMSINH"_ustr; +inline constexpr OUString HID_AAI_FUNC_IMCOSH = u"SC_HID_AAI_FUNC_IMCOSH"_ustr; +inline constexpr OUString HID_AAI_FUNC_IMSECH = u"SC_HID_AAI_FUNC_IMSECH"_ustr; +inline constexpr OUString HID_AAI_FUNC_IMCSCH = u"SC_HID_AAI_FUNC_IMCSCH"_ustr; + +inline constexpr OUString HID_UPDATE_LINK_WARNING = u"cui/ui/baselinksdialog/UPDATE_NOW"_ustr; + +// DateFunc Addin Functions (max.20) ----------------------------------------- +inline constexpr OUString HID_DAI_FUNC_DAYSINMONTH = u"SC_HID_DAI_FUNC_DAYSINMONTH"_ustr; +inline constexpr OUString HID_DAI_FUNC_DAYSINYEAR = u"SC_HID_DAI_FUNC_DAYSINYEAR"_ustr; +inline constexpr OUString HID_DAI_FUNC_WEEKSINYEAR = u"SC_HID_DAI_FUNC_WEEKSINYEAR"_ustr; +inline constexpr OUString HID_DAI_FUNC_DIFFMONTHS = u"SC_HID_DAI_FUNC_DIFFMONTHS"_ustr; +inline constexpr OUString HID_DAI_FUNC_DIFFWEEKS = u"SC_HID_DAI_FUNC_DIFFWEEKS"_ustr; +inline constexpr OUString HID_DAI_FUNC_DIFFYEARS = u"SC_HID_DAI_FUNC_DIFFYEARS"_ustr; +inline constexpr OUString HID_DAI_FUNC_ROT13 = u"SC_HID_DAI_FUNC_ROT13"_ustr; + +// PricingFunc Addin Functions ----------------------------------------- + +inline constexpr OUString HID_PAI_FUNC_OPT_BARRIER = u"SC_HID_PAI_FUNC_OPT_BARRIER"_ustr; +inline constexpr OUString HID_PAI_FUNC_OPT_TOUCH = u"SC_HID_PAI_FUNC_OPT_TOUCH"_ustr; +inline constexpr OUString HID_PAI_FUNC_OPT_PROB_HIT = u"SC_HID_PAI_FUNC_OPT_PROB_HIT"_ustr; +inline constexpr OUString HID_PAI_FUNC_OPT_PROB_INMONEY = u"SC_HID_PAI_FUNC_OPT_PROB_INMONEY"_ustr; + +// End help IDs ------------------------------------------------------------ + +inline constexpr OUString HID_FUNC_DBANZAHL = u"SC_HID_FUNC_DBANZAHL"_ustr; +inline constexpr OUString HID_FUNC_DBANZAHL2 = u"SC_HID_FUNC_DBANZAHL2"_ustr; +inline constexpr OUString HID_FUNC_DBMITTELWERT = u"SC_HID_FUNC_DBMITTELWERT"_ustr; +inline constexpr OUString HID_FUNC_DBAUSZUG = u"SC_HID_FUNC_DBAUSZUG"_ustr; +inline constexpr OUString HID_FUNC_DBMAX = u"SC_HID_FUNC_DBMAX"_ustr; +inline constexpr OUString HID_FUNC_DBMIN = u"SC_HID_FUNC_DBMIN"_ustr; +inline constexpr OUString HID_FUNC_DBPRODUKT = u"SC_HID_FUNC_DBPRODUKT"_ustr; +inline constexpr OUString HID_FUNC_DBSTDABW = u"SC_HID_FUNC_DBSTDABW"_ustr; +inline constexpr OUString HID_FUNC_DBSTDABWN = u"SC_HID_FUNC_DBSTDABWN"_ustr; +inline constexpr OUString HID_FUNC_DBSUMME = u"SC_HID_FUNC_DBSUMME"_ustr; +inline constexpr OUString HID_FUNC_DBVARIANZ = u"SC_HID_FUNC_DBVARIANZ"_ustr; +inline constexpr OUString HID_FUNC_DBVARIANZEN = u"SC_HID_FUNC_DBVARIANZEN"_ustr; + +inline constexpr OUString HID_FUNC_DATUM = u"SC_HID_FUNC_DATUM"_ustr; +inline constexpr OUString HID_FUNC_DATWERT = u"SC_HID_FUNC_DATWERT"_ustr; +inline constexpr OUString HID_FUNC_TAG = u"SC_HID_FUNC_TAG"_ustr; +inline constexpr OUString HID_FUNC_TAGE360 = u"SC_HID_FUNC_TAGE360"_ustr; +inline constexpr OUString HID_FUNC_STUNDE = u"SC_HID_FUNC_STUNDE"_ustr; +inline constexpr OUString HID_FUNC_MINUTE = u"SC_HID_FUNC_MINUTE"_ustr; +inline constexpr OUString HID_FUNC_MONAT = u"SC_HID_FUNC_MONAT"_ustr; +inline constexpr OUString HID_FUNC_JETZT = u"SC_HID_FUNC_JETZT"_ustr; +inline constexpr OUString HID_FUNC_SEKUNDE = u"SC_HID_FUNC_SEKUNDE"_ustr; +inline constexpr OUString HID_FUNC_ZEIT = u"SC_HID_FUNC_ZEIT"_ustr; +inline constexpr OUString HID_FUNC_ZEITWERT = u"SC_HID_FUNC_ZEITWERT"_ustr; +inline constexpr OUString HID_FUNC_HEUTE = u"SC_HID_FUNC_HEUTE"_ustr; +inline constexpr OUString HID_FUNC_WOCHENTAG = u"SC_HID_FUNC_WOCHENTAG"_ustr; +inline constexpr OUString HID_FUNC_JAHR = u"SC_HID_FUNC_JAHR"_ustr; +inline constexpr OUString HID_FUNC_TAGE = u"SC_HID_FUNC_TAGE"_ustr; +inline constexpr OUString HID_FUNC_DATEDIF = u"SC_HID_FUNC_DATEDIF"_ustr; +inline constexpr OUString HID_FUNC_KALENDERWOCHE = u"SC_HID_FUNC_KALENDERWOCHE"_ustr; +inline constexpr OUString HID_FUNC_OSTERSONNTAG = u"SC_HID_FUNC_OSTERSONNTAG"_ustr; +inline constexpr OUString HID_FUNC_ISOWEEKNUM = u"SC_HID_FUNC_ISOWEEKNUM"_ustr; + +inline constexpr OUString HID_FUNC_BW = u"SC_HID_FUNC_BW"_ustr; +inline constexpr OUString HID_FUNC_ZW = u"SC_HID_FUNC_ZW"_ustr; +inline constexpr OUString HID_FUNC_ZZR = u"SC_HID_FUNC_ZZR"_ustr; +inline constexpr OUString HID_FUNC_RMZ = u"SC_HID_FUNC_RMZ"_ustr; +inline constexpr OUString HID_FUNC_ZINS = u"SC_HID_FUNC_ZINS"_ustr; +inline constexpr OUString HID_FUNC_ZINSZ = u"SC_HID_FUNC_ZINSZ"_ustr; +inline constexpr OUString HID_FUNC_KAPZ = u"SC_HID_FUNC_KAPZ"_ustr; +inline constexpr OUString HID_FUNC_KUMKAPITAL = u"SC_HID_FUNC_KUMKAPITAL"_ustr; +inline constexpr OUString HID_FUNC_KUMZINSZ = u"SC_HID_FUNC_KUMZINSZ"_ustr; +inline constexpr OUString HID_FUNC_DIA = u"SC_HID_FUNC_DIA"_ustr; +inline constexpr OUString HID_FUNC_LIA = u"SC_HID_FUNC_LIA"_ustr; +inline constexpr OUString HID_FUNC_GDA = u"SC_HID_FUNC_GDA"_ustr; +inline constexpr OUString HID_FUNC_GDA2 = u"SC_HID_FUNC_GDA2"_ustr; +inline constexpr OUString HID_FUNC_VDB = u"SC_HID_FUNC_VDB"_ustr; +inline constexpr OUString HID_FUNC_EFFEKTIV = u"SC_HID_FUNC_EFFEKTIV"_ustr; +inline constexpr OUString HID_FUNC_NOMINAL = u"SC_HID_FUNC_NOMINAL"_ustr; +inline constexpr OUString HID_FUNC_NBW = u"SC_HID_FUNC_NBW"_ustr; +inline constexpr OUString HID_FUNC_IKV = u"SC_HID_FUNC_IKV"_ustr; +inline constexpr OUString HID_FUNC_LAUFZEIT = u"SC_HID_FUNC_LAUFZEIT"_ustr; +inline constexpr OUString HID_FUNC_ZGZ = u"SC_HID_FUNC_ZGZ"_ustr; +inline constexpr OUString HID_FUNC_QIKV = u"SC_HID_FUNC_QIKV"_ustr; +inline constexpr OUString HID_FUNC_ISPMT = u"SC_HID_FUNC_ISPMT"_ustr; + +inline constexpr OUString HID_FUNC_ISTBEZUG = u"SC_HID_FUNC_ISTBEZUG"_ustr; +inline constexpr OUString HID_FUNC_ISTFEHL = u"SC_HID_FUNC_ISTFEHL"_ustr; +inline constexpr OUString HID_FUNC_ISTFEHLER = u"SC_HID_FUNC_ISTFEHLER"_ustr; +inline constexpr OUString HID_FUNC_ISTLEER = u"SC_HID_FUNC_ISTLEER"_ustr; +inline constexpr OUString HID_FUNC_ISTLOG = u"SC_HID_FUNC_ISTLOG"_ustr; +inline constexpr OUString HID_FUNC_ISTNV = u"SC_HID_FUNC_ISTNV"_ustr; +inline constexpr OUString HID_FUNC_ISTKTEXT = u"SC_HID_FUNC_ISTKTEXT"_ustr; +inline constexpr OUString HID_FUNC_ISTTEXT = u"SC_HID_FUNC_ISTTEXT"_ustr; +inline constexpr OUString HID_FUNC_ISTZAHL = u"SC_HID_FUNC_ISTZAHL"_ustr; +inline constexpr OUString HID_FUNC_ISTFORMEL = u"SC_HID_FUNC_ISTFORMEL"_ustr; +inline constexpr OUString HID_FUNC_N = u"SC_HID_FUNC_N"_ustr; +inline constexpr OUString HID_FUNC_NV = u"SC_HID_FUNC_NV"_ustr; +inline constexpr OUString HID_FUNC_TYP = u"SC_HID_FUNC_TYP"_ustr; +inline constexpr OUString HID_FUNC_AKTUELL = u"SC_HID_FUNC_AKTUELL"_ustr; +inline constexpr OUString HID_FUNC_FORMEL = u"SC_HID_FUNC_FORMEL"_ustr; +inline constexpr OUString HID_FUNC_ZELLE = u"SC_HID_FUNC_ZELLE"_ustr; +inline constexpr OUString HID_FUNC_INFO = u"SC_HID_FUNC_INFO"_ustr; + +inline constexpr OUString HID_FUNC_FALSCH = u"SC_HID_FUNC_FALSCH"_ustr; +inline constexpr OUString HID_FUNC_NICHT = u"SC_HID_FUNC_NICHT"_ustr; +inline constexpr OUString HID_FUNC_WAHR = u"SC_HID_FUNC_WAHR"_ustr; +inline constexpr OUString HID_FUNC_WENN = u"SC_HID_FUNC_WENN"_ustr; +inline constexpr OUString HID_FUNC_IFERROR = u"SC_HID_FUNC_IFERROR"_ustr; +inline constexpr OUString HID_FUNC_IFNA = u"SC_HID_FUNC_IFNA"_ustr; +inline constexpr OUString HID_FUNC_ODER = u"SC_HID_FUNC_ODER"_ustr; +inline constexpr OUString HID_FUNC_UND = u"SC_HID_FUNC_UND"_ustr; +inline constexpr OUString HID_FUNC_XOR = u"SC_HID_FUNC_XOR"_ustr; + +inline constexpr OUString HID_FUNC_ABS = u"SC_HID_FUNC_ABS"_ustr; +inline constexpr OUString HID_FUNC_POTENZ = u"SC_HID_FUNC_POTENZ"_ustr; +inline constexpr OUString HID_FUNC_ANZAHLLEEREZELLEN = u"SC_HID_FUNC_ANZAHLLEEREZELLEN"_ustr; +inline constexpr OUString HID_FUNC_PI = u"SC_HID_FUNC_PI"_ustr; +inline constexpr OUString HID_FUNC_SUMME = u"SC_HID_FUNC_SUMME"_ustr; +inline constexpr OUString HID_FUNC_QUADRATESUMME = u"SC_HID_FUNC_QUADRATESUMME"_ustr; +inline constexpr OUString HID_FUNC_PRODUKT = u"SC_HID_FUNC_PRODUKT"_ustr; +inline constexpr OUString HID_FUNC_SUMMEWENN = u"SC_HID_FUNC_SUMMEWENN"_ustr; +inline constexpr OUString HID_FUNC_AVERAGEIF = u"SC_HID_FUNC_AVERAGEIF"_ustr; +inline constexpr OUString HID_FUNC_SUMIFS = u"SC_HID_FUNC_SUMIFS"_ustr; +inline constexpr OUString HID_FUNC_AVERAGEIFS = u"SC_HID_FUNC_AVERAGEIFS"_ustr; +inline constexpr OUString HID_FUNC_COUNTIFS = u"SC_HID_FUNC_COUNTIFS"_ustr; +inline constexpr OUString HID_FUNC_ZAEHLENWENN = u"SC_HID_FUNC_ZAEHLENWENN"_ustr; +inline constexpr OUString HID_FUNC_WURZEL = u"SC_HID_FUNC_WURZEL"_ustr; +inline constexpr OUString HID_FUNC_ZUFALLSZAHL = u"SC_HID_FUNC_ZUFALLSZAHL"_ustr; +inline constexpr OUString HID_FUNC_ISTGERADE = u"SC_HID_FUNC_ISTGERADE"_ustr; +inline constexpr OUString HID_FUNC_ISTUNGERADE = u"SC_HID_FUNC_ISTUNGERADE"_ustr; +inline constexpr OUString HID_FUNC_KOMBINATIONEN = u"SC_HID_FUNC_KOMBINATIONEN"_ustr; +inline constexpr OUString HID_FUNC_KOMBINATIONEN2 = u"SC_HID_FUNC_KOMBINATIONEN2"_ustr; +inline constexpr OUString HID_FUNC_ARCCOS = u"SC_HID_FUNC_ARCCOS"_ustr; +inline constexpr OUString HID_FUNC_ARCSIN = u"SC_HID_FUNC_ARCSIN"_ustr; +inline constexpr OUString HID_FUNC_ARCOSHYP = u"SC_HID_FUNC_ARCOSHYP"_ustr; +inline constexpr OUString HID_FUNC_ARSINHYP = u"SC_HID_FUNC_ARSINHYP"_ustr; +inline constexpr OUString HID_FUNC_ARCCOT = u"SC_HID_FUNC_ARCCOT"_ustr; +inline constexpr OUString HID_FUNC_ARCTAN = u"SC_HID_FUNC_ARCTAN"_ustr; +inline constexpr OUString HID_FUNC_ARCOTHYP = u"SC_HID_FUNC_ARCOTHYP"_ustr; +inline constexpr OUString HID_FUNC_ARTANHYP = u"SC_HID_FUNC_ARTANHYP"_ustr; +inline constexpr OUString HID_FUNC_COS = u"SC_HID_FUNC_COS"_ustr; +inline constexpr OUString HID_FUNC_SIN = u"SC_HID_FUNC_SIN"_ustr; +inline constexpr OUString HID_FUNC_COT = u"SC_HID_FUNC_COT"_ustr; +inline constexpr OUString HID_FUNC_TAN = u"SC_HID_FUNC_TAN"_ustr; +inline constexpr OUString HID_FUNC_COSHYP = u"SC_HID_FUNC_COSHYP"_ustr; +inline constexpr OUString HID_FUNC_SINHYP = u"SC_HID_FUNC_SINHYP"_ustr; +inline constexpr OUString HID_FUNC_COTHYP = u"SC_HID_FUNC_COTHYP"_ustr; +inline constexpr OUString HID_FUNC_TANHYP = u"SC_HID_FUNC_TANHYP"_ustr; +inline constexpr OUString HID_FUNC_ARCTAN2 = u"SC_HID_FUNC_ARCTAN2"_ustr; +inline constexpr OUString HID_FUNC_COSECANT = u"SC_HID_FUNC_COSECANT"_ustr; +inline constexpr OUString HID_FUNC_SECANT = u"SC_HID_FUNC_SECANT"_ustr; +inline constexpr OUString HID_FUNC_SECANTHYP = u"SC_HID_FUNC_SECANTHYP"_ustr; +inline constexpr OUString HID_FUNC_COSECANTHYP = u"SC_HID_FUNC_COSECANTHYP"_ustr; +inline constexpr OUString HID_FUNC_DEG = u"SC_HID_FUNC_DEG"_ustr; +inline constexpr OUString HID_FUNC_RAD = u"SC_HID_FUNC_RAD"_ustr; +inline constexpr OUString HID_FUNC_EXP = u"SC_HID_FUNC_EXP"_ustr; +inline constexpr OUString HID_FUNC_LOG = u"SC_HID_FUNC_LOG"_ustr; +inline constexpr OUString HID_FUNC_LN = u"SC_HID_FUNC_LN"_ustr; +inline constexpr OUString HID_FUNC_LOG10 = u"SC_HID_FUNC_LOG10"_ustr; +inline constexpr OUString HID_FUNC_FAKULTAET = u"SC_HID_FUNC_FAKULTAET"_ustr; +inline constexpr OUString HID_FUNC_REST = u"SC_HID_FUNC_REST"_ustr; +inline constexpr OUString HID_FUNC_VORZEICHEN = u"SC_HID_FUNC_VORZEICHEN"_ustr; +inline constexpr OUString HID_FUNC_TEILERGEBNIS = u"SC_HID_FUNC_TEILERGEBNIS"_ustr; +inline constexpr OUString HID_FUNC_GANZZAHL = u"SC_HID_FUNC_GANZZAHL"_ustr; +inline constexpr OUString HID_FUNC_KUERZEN = u"SC_HID_FUNC_KUERZEN"_ustr; +inline constexpr OUString HID_FUNC_RUNDEN = u"SC_HID_FUNC_RUNDEN"_ustr; +inline constexpr OUString HID_FUNC_AUFRUNDEN = u"SC_HID_FUNC_AUFRUNDEN"_ustr; +inline constexpr OUString HID_FUNC_ABRUNDEN = u"SC_HID_FUNC_ABRUNDEN"_ustr; +inline constexpr OUString HID_FUNC_GERADE = u"SC_HID_FUNC_GERADE"_ustr; +inline constexpr OUString HID_FUNC_UNGERADE = u"SC_HID_FUNC_UNGERADE"_ustr; +inline constexpr OUString HID_FUNC_OBERGRENZE = u"SC_HID_FUNC_OBERGRENZE"_ustr; +inline constexpr OUString HID_FUNC_UNTERGRENZE = u"SC_HID_FUNC_UNTERGRENZE"_ustr; +inline constexpr OUString HID_FUNC_GGT = u"SC_HID_FUNC_GGT"_ustr; +inline constexpr OUString HID_FUNC_KGV = u"SC_HID_FUNC_KGV"_ustr; +inline constexpr OUString HID_FUNC_UMRECHNEN = u"SC_HID_FUNC_UMRECHNEN"_ustr; +inline constexpr OUString HID_FUNC_EUROCONVERT = u"SC_HID_FUNC_EUROCONVERT"_ustr; + +inline constexpr OUString HID_FUNC_MTRANS = u"SC_HID_FUNC_MTRANS"_ustr; +inline constexpr OUString HID_FUNC_MMULT = u"SC_HID_FUNC_MMULT"_ustr; +inline constexpr OUString HID_FUNC_MDET = u"SC_HID_FUNC_MDET"_ustr; +inline constexpr OUString HID_FUNC_MINV = u"SC_HID_FUNC_MINV"_ustr; +inline constexpr OUString HID_FUNC_EINHEITSMATRIX = u"SC_HID_FUNC_EINHEITSMATRIX"_ustr; +inline constexpr OUString HID_FUNC_SUMMENPRODUKT = u"SC_HID_FUNC_SUMMENPRODUKT"_ustr; +inline constexpr OUString HID_FUNC_SUMMEX2MY2 = u"SC_HID_FUNC_SUMMEX2MY2"_ustr; +inline constexpr OUString HID_FUNC_SUMMEX2PY2 = u"SC_HID_FUNC_SUMMEX2PY2"_ustr; +inline constexpr OUString HID_FUNC_SUMMEXMY2 = u"SC_HID_FUNC_SUMMEXMY2"_ustr; +inline constexpr OUString HID_FUNC_HAEUFIGKEIT = u"SC_HID_FUNC_HAEUFIGKEIT"_ustr; +inline constexpr OUString HID_FUNC_RGP = u"SC_HID_FUNC_RGP"_ustr; +inline constexpr OUString HID_FUNC_RKP = u"SC_HID_FUNC_RKP"_ustr; +inline constexpr OUString HID_FUNC_TREND = u"SC_HID_FUNC_TREND"_ustr; +inline constexpr OUString HID_FUNC_VARIATION = u"SC_HID_FUNC_VARIATION"_ustr; + +inline constexpr OUString HID_FUNC_ANZAHL = u"SC_HID_FUNC_ANZAHL"_ustr; +inline constexpr OUString HID_FUNC_ANZAHL2 = u"SC_HID_FUNC_ANZAHL2"_ustr; +inline constexpr OUString HID_FUNC_MAX = u"SC_HID_FUNC_MAX"_ustr; +inline constexpr OUString HID_FUNC_MIN = u"SC_HID_FUNC_MIN"_ustr; +inline constexpr OUString HID_FUNC_VARIANZ = u"SC_HID_FUNC_VARIANZ"_ustr; +inline constexpr OUString HID_FUNC_VARIANZEN = u"SC_HID_FUNC_VARIANZEN"_ustr; +inline constexpr OUString HID_FUNC_STABW = u"SC_HID_FUNC_STABW"_ustr; +inline constexpr OUString HID_FUNC_STABWN = u"SC_HID_FUNC_STABWN"_ustr; +inline constexpr OUString HID_FUNC_MITTELWERT = u"SC_HID_FUNC_MITTELWERT"_ustr; +inline constexpr OUString HID_FUNC_SUMQUADABW = u"SC_HID_FUNC_SUMQUADABW"_ustr; +inline constexpr OUString HID_FUNC_MITTELABW = u"SC_HID_FUNC_MITTELABW"_ustr; +inline constexpr OUString HID_FUNC_SCHIEFE = u"SC_HID_FUNC_SCHIEFE"_ustr; +inline constexpr OUString HID_FUNC_SKEWP = u"SC_HID_FUNC_SKEWP"_ustr; +inline constexpr OUString HID_FUNC_KURT = u"SC_HID_FUNC_KURT"_ustr; +inline constexpr OUString HID_FUNC_GEOMITTEL = u"SC_HID_FUNC_GEOMITTEL"_ustr; +inline constexpr OUString HID_FUNC_HARMITTEL = u"SC_HID_FUNC_HARMITTEL"_ustr; +inline constexpr OUString HID_FUNC_MODALWERT = u"SC_HID_FUNC_MODALWERT"_ustr; +inline constexpr OUString HID_FUNC_MEDIAN = u"SC_HID_FUNC_MEDIAN"_ustr; +inline constexpr OUString HID_FUNC_QUANTIL = u"SC_HID_FUNC_QUANTIL"_ustr; +inline constexpr OUString HID_FUNC_QUARTILE = u"SC_HID_FUNC_QUARTILE"_ustr; +inline constexpr OUString HID_FUNC_KGROESSTE = u"SC_HID_FUNC_KGROESSTE"_ustr; +inline constexpr OUString HID_FUNC_KKLEINSTE = u"SC_HID_FUNC_KKLEINSTE"_ustr; +inline constexpr OUString HID_FUNC_QUANTILSRANG = u"SC_HID_FUNC_QUANTILSRANG"_ustr; +inline constexpr OUString HID_FUNC_RANG = u"SC_HID_FUNC_RANG"_ustr; +inline constexpr OUString HID_FUNC_GESTUTZTMITTEL = u"SC_HID_FUNC_GESTUTZTMITTEL"_ustr; +inline constexpr OUString HID_FUNC_WAHRSCHBEREICH = u"SC_HID_FUNC_WAHRSCHBEREICH"_ustr; +inline constexpr OUString HID_FUNC_B = u"SC_HID_FUNC_B"_ustr; +inline constexpr OUString HID_FUNC_PHI = u"SC_HID_FUNC_PHI"_ustr; +inline constexpr OUString HID_FUNC_GAUSS = u"SC_HID_FUNC_GAUSS"_ustr; +inline constexpr OUString HID_FUNC_FISHER = u"SC_HID_FUNC_FISHER"_ustr; +inline constexpr OUString HID_FUNC_FISHERINV = u"SC_HID_FUNC_FISHERINV"_ustr; +inline constexpr OUString HID_FUNC_BINOMVERT = u"SC_HID_FUNC_BINOMVERT"_ustr; +inline constexpr OUString HID_FUNC_NEGBINOMVERT = u"SC_HID_FUNC_NEGBINOMVERT"_ustr; +inline constexpr OUString HID_FUNC_KRITBINOM = u"SC_HID_FUNC_KRITBINOM"_ustr; +inline constexpr OUString HID_FUNC_POISSON = u"SC_HID_FUNC_POISSON"_ustr; +inline constexpr OUString HID_FUNC_NORMVERT = u"SC_HID_FUNC_NORMVERT"_ustr; +inline constexpr OUString HID_FUNC_NORMINV = u"SC_HID_FUNC_NORMINV"_ustr; +inline constexpr OUString HID_FUNC_STANDNORMVERT = u"SC_HID_FUNC_STANDNORMVERT"_ustr; +inline constexpr OUString HID_FUNC_STANDNORMINV = u"SC_HID_FUNC_STANDNORMINV"_ustr; +inline constexpr OUString HID_FUNC_LOGNORMVERT = u"SC_HID_FUNC_LOGNORMVERT"_ustr; +inline constexpr OUString HID_FUNC_LOGINV = u"SC_HID_FUNC_LOGINV"_ustr; +inline constexpr OUString HID_FUNC_EXPONVERT = u"SC_HID_FUNC_EXPONVERT"_ustr; +inline constexpr OUString HID_FUNC_GAMMAVERT = u"SC_HID_FUNC_GAMMAVERT"_ustr; +inline constexpr OUString HID_FUNC_GAMMAINV = u"SC_HID_FUNC_GAMMAINV"_ustr; +inline constexpr OUString HID_FUNC_GAMMALN = u"SC_HID_FUNC_GAMMALN"_ustr; +inline constexpr OUString HID_FUNC_BETAVERT = u"SC_HID_FUNC_BETAVERT"_ustr; +inline constexpr OUString HID_FUNC_BETAINV = u"SC_HID_FUNC_BETAINV"_ustr; +inline constexpr OUString HID_FUNC_WEIBULL = u"SC_HID_FUNC_WEIBULL"_ustr; +inline constexpr OUString HID_FUNC_HYPGEOMVERT = u"SC_HID_FUNC_HYPGEOMVERT"_ustr; +inline constexpr OUString HID_FUNC_TVERT = u"SC_HID_FUNC_TVERT"_ustr; +inline constexpr OUString HID_FUNC_TINV = u"SC_HID_FUNC_TINV"_ustr; +inline constexpr OUString HID_FUNC_FVERT = u"SC_HID_FUNC_FVERT"_ustr; +inline constexpr OUString HID_FUNC_FINV = u"SC_HID_FUNC_FINV"_ustr; +inline constexpr OUString HID_FUNC_CHIVERT = u"SC_HID_FUNC_CHIVERT"_ustr; +inline constexpr OUString HID_FUNC_CHIINV = u"SC_HID_FUNC_CHIINV"_ustr; +inline constexpr OUString HID_FUNC_STANDARDISIERUNG = u"SC_HID_FUNC_STANDARDISIERUNG"_ustr; +inline constexpr OUString HID_FUNC_VARIATIONEN = u"SC_HID_FUNC_VARIATIONEN"_ustr; +inline constexpr OUString HID_FUNC_VARIATIONEN2 = u"SC_HID_FUNC_VARIATIONEN2"_ustr; +inline constexpr OUString HID_FUNC_KONFIDENZ = u"SC_HID_FUNC_KONFIDENZ"_ustr; +inline constexpr OUString HID_FUNC_GTEST = u"SC_HID_FUNC_GTEST"_ustr; +inline constexpr OUString HID_FUNC_CHITEST = u"SC_HID_FUNC_CHITEST"_ustr; +inline constexpr OUString HID_FUNC_FTEST = u"SC_HID_FUNC_FTEST"_ustr; +inline constexpr OUString HID_FUNC_TTEST = u"SC_HID_FUNC_TTEST"_ustr; +inline constexpr OUString HID_FUNC_BESTIMMTHEITSMASS = u"SC_HID_FUNC_BESTIMMTHEITSMASS"_ustr; +inline constexpr OUString HID_FUNC_ACHSENABSCHNITT = u"SC_HID_FUNC_ACHSENABSCHNITT"_ustr; +inline constexpr OUString HID_FUNC_STEIGUNG = u"SC_HID_FUNC_STEIGUNG"_ustr; +inline constexpr OUString HID_FUNC_STFEHLERYX = u"SC_HID_FUNC_STFEHLERYX"_ustr; +inline constexpr OUString HID_FUNC_PEARSON = u"SC_HID_FUNC_PEARSON"_ustr; +inline constexpr OUString HID_FUNC_KORREL = u"SC_HID_FUNC_KORREL"_ustr; +inline constexpr OUString HID_FUNC_KOVAR = u"SC_HID_FUNC_KOVAR"_ustr; +inline constexpr OUString HID_FUNC_SCHAETZER = u"SC_HID_FUNC_SCHAETZER"_ustr; +inline constexpr OUString HID_FUNC_MINA = u"SC_HID_FUNC_MINA"_ustr; +inline constexpr OUString HID_FUNC_MAXA = u"SC_HID_FUNC_MAXA"_ustr; +inline constexpr OUString HID_FUNC_MITTELWERTA = u"SC_HID_FUNC_MITTELWERTA"_ustr; +inline constexpr OUString HID_FUNC_STABWA = u"SC_HID_FUNC_STABWA"_ustr; +inline constexpr OUString HID_FUNC_STABWNA = u"SC_HID_FUNC_STABWNA"_ustr; +inline constexpr OUString HID_FUNC_VARIANZA = u"SC_HID_FUNC_VARIANZA"_ustr; +inline constexpr OUString HID_FUNC_VARIANZENA = u"SC_HID_FUNC_VARIANZENA"_ustr; +inline constexpr OUString HID_FUNC_CHISQDIST = u"SC_HID_FUNC_CHISQDIST"_ustr; +inline constexpr OUString HID_FUNC_CHISQINV = u"SC_HID_FUNC_CHISQINV"_ustr; +inline constexpr OUString HID_FUNC_GAMMA = u"SC_HID_FUNC_GAMMA"_ustr; + +inline constexpr OUString HID_FUNC_ADRESSE = u"SC_HID_FUNC_ADRESSE"_ustr; +inline constexpr OUString HID_FUNC_BEREICHE = u"SC_HID_FUNC_BEREICHE"_ustr; +inline constexpr OUString HID_FUNC_WAHL = u"SC_HID_FUNC_WAHL"_ustr; +inline constexpr OUString HID_FUNC_SPALTE = u"SC_HID_FUNC_SPALTE"_ustr; +inline constexpr OUString HID_FUNC_ZEILE = u"SC_HID_FUNC_ZEILE"_ustr; +inline constexpr OUString HID_FUNC_SPALTEN = u"SC_HID_FUNC_SPALTEN"_ustr; +inline constexpr OUString HID_FUNC_ZEILEN = u"SC_HID_FUNC_ZEILEN"_ustr; +inline constexpr OUString HID_FUNC_WVERWEIS = u"SC_HID_FUNC_WVERWEIS"_ustr; +inline constexpr OUString HID_FUNC_SVERWEIS = u"SC_HID_FUNC_SVERWEIS"_ustr; +inline constexpr OUString HID_FUNC_INDEX = u"SC_HID_FUNC_INDEX"_ustr; +inline constexpr OUString HID_FUNC_INDIREKT = u"SC_HID_FUNC_INDIREKT"_ustr; +inline constexpr OUString HID_FUNC_VERWEIS = u"SC_HID_FUNC_VERWEIS"_ustr; +inline constexpr OUString HID_FUNC_VERGLEICH = u"SC_HID_FUNC_VERGLEICH"_ustr; +inline constexpr OUString HID_FUNC_VERSCHIEBUNG = u"SC_HID_FUNC_VERSCHIEBUNG"_ustr; +inline constexpr OUString HID_FUNC_FEHLERTYP = u"SC_HID_FUNC_FEHLERTYP"_ustr; +inline constexpr OUString HID_FUNC_VORLAGE = u"SC_HID_FUNC_VORLAGE"_ustr; +inline constexpr OUString HID_FUNC_DDE = u"SC_HID_FUNC_DDE"_ustr; +inline constexpr OUString HID_FUNC_TABELLE = u"SC_HID_FUNC_TABELLE"_ustr; +inline constexpr OUString HID_FUNC_TABELLEN = u"SC_HID_FUNC_TABELLEN"_ustr; +inline constexpr OUString HID_FUNC_HYPERLINK = u"SC_HID_FUNC_HYPERLINK"_ustr; +inline constexpr OUString HID_FUNC_GETPIVOTDATA = u"SC_HID_FUNC_GETPIVOTDATA"_ustr; + +inline constexpr OUString HID_FUNC_CODE = u"SC_HID_FUNC_CODE"_ustr; +inline constexpr OUString HID_FUNC_DM = u"SC_HID_FUNC_DM"_ustr; +inline constexpr OUString HID_FUNC_ZEICHEN = u"SC_HID_FUNC_ZEICHEN"_ustr; +inline constexpr OUString HID_FUNC_SAEUBERN = u"SC_HID_FUNC_SAEUBERN"_ustr; +inline constexpr OUString HID_FUNC_VERKETTEN = u"SC_HID_FUNC_VERKETTEN"_ustr; +inline constexpr OUString HID_FUNC_IDENTISCH = u"SC_HID_FUNC_IDENTISCH"_ustr; +inline constexpr OUString HID_FUNC_FINDEN = u"SC_HID_FUNC_FINDEN"_ustr; +inline constexpr OUString HID_FUNC_SUCHEN = u"SC_HID_FUNC_SUCHEN"_ustr; +inline constexpr OUString HID_FUNC_GLAETTEN = u"SC_HID_FUNC_GLAETTEN"_ustr; +inline constexpr OUString HID_FUNC_GROSS2 = u"SC_HID_FUNC_GROSS2"_ustr; +inline constexpr OUString HID_FUNC_GROSS = u"SC_HID_FUNC_GROSS"_ustr; +inline constexpr OUString HID_FUNC_KLEIN = u"SC_HID_FUNC_KLEIN"_ustr; +inline constexpr OUString HID_FUNC_WERT = u"SC_HID_FUNC_WERT"_ustr; +inline constexpr OUString HID_FUNC_TEXT = u"SC_HID_FUNC_TEXT"_ustr; +inline constexpr OUString HID_FUNC_T = u"SC_HID_FUNC_T"_ustr; +inline constexpr OUString HID_FUNC_ERSETZEN = u"SC_HID_FUNC_ERSETZEN"_ustr; +inline constexpr OUString HID_FUNC_FEST = u"SC_HID_FUNC_FEST"_ustr; +inline constexpr OUString HID_FUNC_LAENGE = u"SC_HID_FUNC_LAENGE"_ustr; +inline constexpr OUString HID_FUNC_LINKS = u"SC_HID_FUNC_LINKS"_ustr; +inline constexpr OUString HID_FUNC_RECHTS = u"SC_HID_FUNC_RECHTS"_ustr; +inline constexpr OUString HID_FUNC_TEIL = u"SC_HID_FUNC_TEIL"_ustr; +inline constexpr OUString HID_FUNC_LENB = u"SC_HID_FUNC_LENB"_ustr; +inline constexpr OUString HID_FUNC_RIGHTB = u"SC_HID_FUNC_RIGHTB"_ustr; +inline constexpr OUString HID_FUNC_LEFTB = u"SC_HID_FUNC_LEFTB"_ustr; +inline constexpr OUString HID_FUNC_MIDB = u"SC_HID_FUNC_MIDB"_ustr; +inline constexpr OUString HID_FUNC_WIEDERHOLEN = u"SC_HID_FUNC_WIEDERHOLEN"_ustr; +inline constexpr OUString HID_FUNC_WECHSELN = u"SC_HID_FUNC_WECHSELN"_ustr; +inline constexpr OUString HID_FUNC_BASIS = u"SC_HID_FUNC_BASIS"_ustr; +inline constexpr OUString HID_FUNC_DEZIMAL = u"SC_HID_FUNC_DEZIMAL"_ustr; +inline constexpr OUString HID_FUNC_ROEMISCH = u"SC_HID_FUNC_ROEMISCH"_ustr; +inline constexpr OUString HID_FUNC_ARABISCH = u"SC_HID_FUNC_ARABISCH"_ustr; +inline constexpr OUString HID_FUNC_BAHTTEXT = u"SC_HID_FUNC_BAHTTEXT"_ustr; +inline constexpr OUString HID_FUNC_JIS = u"SC_HID_FUNC_JIS"_ustr; +inline constexpr OUString HID_FUNC_ASC = u"SC_HID_FUNC_ASC"_ustr; +inline constexpr OUString HID_FUNC_UNICODE = u"SC_HID_FUNC_UNICODE"_ustr; +inline constexpr OUString HID_FUNC_UNICHAR = u"SC_HID_FUNC_UNICHAR"_ustr; +inline constexpr OUString HID_FUNC_NUMBERVALUE = u"SC_HID_FUNC_NUMBERVALUE"_ustr; +inline constexpr OUString HID_FUNC_BITAND = u"SC_HID_FUNC_BITAND"_ustr; +inline constexpr OUString HID_FUNC_BITOR = u"SC_HID_FUNC_BITOR"_ustr; +inline constexpr OUString HID_FUNC_BITXOR = u"SC_HID_FUNC_BITXOR"_ustr; +inline constexpr OUString HID_FUNC_BITLSHIFT = u"SC_HID_FUNC_BITLSHIFT"_ustr; +inline constexpr OUString HID_FUNC_BITRSHIFT = u"SC_HID_FUNC_BITRSHIFT"_ustr; +inline constexpr OUString HID_FUNC_FILTERXML = u"SC_HID_FUNC_FILTERXML"_ustr; +inline constexpr OUString HID_FUNC_WEBSERVICE = u"SC_HID_FUNC_WEBSERVICE"_ustr; +inline constexpr OUString HID_FUNC_ENCODEURL = u"SC_HID_FUNC_ENCODEURL"_ustr; +inline constexpr OUString HID_FUNC_COLOR = u"SC_HID_FUNC_COLOR"_ustr; +inline constexpr OUString HID_FUNC_COVARIANCE_P = u"SC_HID_FUNC_COVARIANCE_P"_ustr; +inline constexpr OUString HID_FUNC_COVARIANCE_S = u"SC_HID_FUNC_COVARIANCE_S"_ustr; +inline constexpr OUString HID_FUNC_ST_DEV_P_MS = u"SC_HID_FUNC_ST_DEV_P_MS"_ustr; +inline constexpr OUString HID_FUNC_ST_DEV_S = u"SC_HID_FUNC_ST_DEV_S"_ustr; +inline constexpr OUString HID_FUNC_VAR_P_MS = u"SC_HID_FUNC_VAR_P_MS"_ustr; +inline constexpr OUString HID_FUNC_VAR_S = u"SC_HID_FUNC_VAR_S"_ustr; +inline constexpr OUString HID_FUNC_BETADIST_MS = u"SC_HID_FUNC_BETADIST_MS"_ustr; +inline constexpr OUString HID_FUNC_BETAINV_MS = u"SC_HID_FUNC_BETAINV_MS"_ustr; +inline constexpr OUString HID_FUNC_BINOM_DIST_MS = u"SC_HID_FUNC_BINOM_DIST_MS"_ustr; +inline constexpr OUString HID_FUNC_BINOM_INV_MS = u"SC_HID_FUNC_BINOM_INV_MS"_ustr; +inline constexpr OUString HID_FUNC_CHIINV_MS = u"SC_HID_FUNC_CHIINV_MS"_ustr; +inline constexpr OUString HID_FUNC_CHIVERT_MS = u"SC_HID_FUNC_CHIVERT_MS"_ustr; +inline constexpr OUString HID_FUNC_CHITEST_MS = u"SC_HID_FUNC_CHITEST_MS"_ustr; +inline constexpr OUString HID_FUNC_CHISQDIST_MS = u"SC_HID_FUNC_CHISQDIST_MS"_ustr; +inline constexpr OUString HID_FUNC_CHISQINV_MS = u"SC_HID_FUNC_CHISQINV_MS"_ustr; +inline constexpr OUString HID_FUNC_CONFIDENCE_N = u"SC_HID_FUNC_CONFIDENCE_N"_ustr; +inline constexpr OUString HID_FUNC_CONFIDENCE_T = u"SC_HID_FUNC_CONFIDENCE_T"_ustr; +inline constexpr OUString HID_FUNC_F_DIST_LT = u"SC_HID_FUNC_F_DIST_LT"_ustr; +inline constexpr OUString HID_FUNC_F_DIST_RT = u"SC_HID_FUNC_F_DIST_RT"_ustr; +inline constexpr OUString HID_FUNC_F_INV_LT = u"SC_HID_FUNC_F_INV_LT"_ustr; +inline constexpr OUString HID_FUNC_F_INV_RT = u"SC_HID_FUNC_F_INV_RT"_ustr; +inline constexpr OUString HID_FUNC_F_TEST_MS = u"SC_HID_FUNC_F_TEST_MS"_ustr; +inline constexpr OUString HID_FUNC_EXP_DIST_MS = u"SC_HID_FUNC_EXP_DIST_MS"_ustr; +inline constexpr OUString HID_FUNC_HYP_GEOM_DIST_MS = u"SC_HID_FUNC_HYP_GEOM_DIST_MS"_ustr; +inline constexpr OUString HID_FUNC_POISSON_DIST_MS = u"SC_HID_FUNC_POISSON_DIST_MS"_ustr; +inline constexpr OUString HID_FUNC_WEIBULL_DIST_MS = u"SC_HID_FUNC_WEIBULL_DIST_MS"_ustr; +inline constexpr OUString HID_FUNC_GAMMADIST_MS = u"SC_HID_FUNC_GAMMADIST_MS"_ustr; +inline constexpr OUString HID_FUNC_GAMMAINV_MS = u"SC_HID_FUNC_GAMMAINV_MS"_ustr; +inline constexpr OUString HID_FUNC_GAMMALN_MS = u"SC_HID_FUNC_GAMMALN_MS"_ustr; +inline constexpr OUString HID_FUNC_LOGNORMDIST_MS = u"SC_HID_FUNC_LOGNORMDIST_MS"_ustr; +inline constexpr OUString HID_FUNC_NORMDIST_MS = u"SC_HID_FUNC_NORMDIST_MS"_ustr; +inline constexpr OUString HID_FUNC_NORMINV_MS = u"SC_HID_FUNC_NORMINV_MS"_ustr; +inline constexpr OUString HID_FUNC_STD_NORMDIST_MS = u"SC_HID_FUNC_STD_NORMDIST_MS"_ustr; +inline constexpr OUString HID_FUNC_STD_NORMINV_MS = u"SC_HID_FUNC_STD_NORMINV_MS"_ustr; +inline constexpr OUString HID_FUNC_TDIST_2T = u"SC_HID_FUNC_TDIST_2T"_ustr; +inline constexpr OUString HID_FUNC_TDIST_MS = u"SC_HID_FUNC_TDIST_MS"_ustr; +inline constexpr OUString HID_FUNC_TDIST_RT = u"SC_HID_FUNC_TDIST_RT"_ustr; +inline constexpr OUString HID_FUNC_TINV_2T = u"SC_HID_FUNC_TINV_2T"_ustr; +inline constexpr OUString HID_FUNC_TINV_MS = u"SC_HID_FUNC_TINV_MS"_ustr; +inline constexpr OUString HID_FUNC_TTEST_MS = u"SC_HID_FUNC_TTEST_MS"_ustr; +inline constexpr OUString HID_FUNC_PERCENTILE_EXC = u"SC_HID_FUNC_PERCENTILE_EXC"_ustr; +inline constexpr OUString HID_FUNC_PERCENTILE_INC = u"SC_HID_FUNC_PERCENTILE_INC"_ustr; +inline constexpr OUString HID_FUNC_PERCENTRANK_EXC = u"SC_HID_FUNC_PERCENTRANK_EXC"_ustr; +inline constexpr OUString HID_FUNC_PERCENTRANK_INC = u"SC_HID_FUNC_PERCENTRANK_INC"_ustr; +inline constexpr OUString HID_FUNC_QUARTILE_INC = u"SC_HID_FUNC_QUARTILE_INC"_ustr; +inline constexpr OUString HID_FUNC_QUARTILE_EXC = u"SC_HID_FUNC_QUARTILE_EXC"_ustr; +inline constexpr OUString HID_FUNC_RANK_EQ = u"SC_HID_FUNC_RANK_EQ"_ustr; +inline constexpr OUString HID_FUNC_RANK_AVG = u"SC_HID_FUNC_RANK_AVG"_ustr; +inline constexpr OUString HID_FUNC_MODAL_VALUE_MS = u"SC_HID_FUNC_MODAL_VALUE_MS"_ustr; +inline constexpr OUString HID_FUNC_MODAL_VALUE_MULTI = u"SC_HID_FUNC_MODAL_VALUE_MULTI"_ustr; +inline constexpr OUString HID_FUNC_NEGBINOMDIST_MS = u"SC_HID_FUNC_NEGBINOMDIST_MS"_ustr; +inline constexpr OUString HID_FUNC_Z_TEST_MS = u"SC_HID_FUNC_Z_TEST_MS"_ustr; +inline constexpr OUString HID_FUNC_CEIL_MS = u"SC_HID_FUNC_CEIL_MS"_ustr; +inline constexpr OUString HID_FUNC_CEIL_PRECISE = u"SC_HID_FUNC_CEIL_PRECISE"_ustr; +inline constexpr OUString HID_FUNC_CEIL_ISO = u"SC_HID_FUNC_CEIL_ISO"_ustr; +inline constexpr OUString HID_FUNC_FLOOR_MS = u"SC_HID_FUNC_FLOOR_MS"_ustr; +inline constexpr OUString HID_FUNC_NETWORKDAYS = u"SC_HID_FUNC_NETWORKDAYS"_ustr; +inline constexpr OUString HID_FUNC_NETWORKDAYS_MS = u"SC_HID_FUNC_NETWORKDAYS_MS"_ustr; +inline constexpr OUString HID_FUNC_WORKDAY_MS = u"SC_HID_FUNC_WORKDAY_MS"_ustr; +inline constexpr OUString HID_FUNC_ERF_MS = u"SC_HID_FUNC_ERF_MS"_ustr; +inline constexpr OUString HID_FUNC_ERFC_MS = u"SC_HID_FUNC_ERFC_MS"_ustr; +inline constexpr OUString HID_FUNC_AGGREGATE = u"SC_HID_FUNC_AGGREGATE"_ustr; +inline constexpr OUString HID_FUNC_ERROR_TYPE_ODF = u"SC_HID_FUNC_ERROR_TYPE_ODF"_ustr; +inline constexpr OUString HID_FUNC_CEIL_MATH = u"SC_HID_FUNC_CEIL_MATH"_ustr; +inline constexpr OUString HID_FUNC_FLOOR_MATH = u"SC_HID_FUNC_FLOOR_MATH"_ustr; +inline constexpr OUString HID_FUNC_FLOOR_PRECISE = u"SC_HID_FUNC_FLOOR_PRECISE"_ustr; +inline constexpr OUString HID_FUNC_RAWSUBTRACT = u"SC_HID_FUNC_RAWSUBTRACT"_ustr; +inline constexpr OUString HID_FUNC_WEEKNUM_OOO = u"SC_HID_FUNC_WEEKNUM_OOO"_ustr; +inline constexpr OUString HID_FUNC_FORECAST_ETS_ADD = u"SC_HID_FUNC_FORECAST_ETS_ADD"_ustr; +inline constexpr OUString HID_FUNC_FORECAST_ETS_MUL = u"SC_HID_FUNC_FORECAST_ETS_MUL"_ustr; +inline constexpr OUString HID_FUNC_FORECAST_ETS_PIA = u"SC_HID_FUNC_FORECAST_ETS_PIA"_ustr; +inline constexpr OUString HID_FUNC_FORECAST_ETS_PIM = u"SC_HID_FUNC_FORECAST_ETS_PIM"_ustr; +inline constexpr OUString HID_FUNC_FORECAST_ETS_SEA = u"SC_HID_FUNC_FORECAST_ETS_SEA"_ustr; +inline constexpr OUString HID_FUNC_FORECAST_ETS_STA = u"SC_HID_FUNC_FORECAST_ETS_STA"_ustr; +inline constexpr OUString HID_FUNC_FORECAST_ETS_STM = u"SC_HID_FUNC_FORECAST_ETS_STM"_ustr; +inline constexpr OUString HID_FUNC_FORECAST_LIN = u"SC_HID_FUNC_FORECAST_LIN"_ustr; +inline constexpr OUString HID_FUNC_CONCAT_MS = u"SC_HID_FUNC_CONCAT_MS"_ustr; +inline constexpr OUString HID_FUNC_TEXTJOIN_MS = u"SC_HID_FUNC_TEXTJOIN_MS"_ustr; +inline constexpr OUString HID_FUNC_IFS_MS = u"SC_HID_FUNC_IFS_MS"_ustr; +inline constexpr OUString HID_FUNC_SWITCH_MS = u"SC_HID_FUNC_SWITCH_MS"_ustr; +inline constexpr OUString HID_FUNC_MINIFS_MS = u"SC_HID_FUNC_MINIFS_MS"_ustr; +inline constexpr OUString HID_FUNC_MAXIFS_MS = u"SC_HID_FUNC_MAXIFS_MS"_ustr; +inline constexpr OUString HID_FUNC_ROUNDSIG = u"SC_HID_FUNC_ROUNDSIG"_ustr; +inline constexpr OUString HID_FUNC_REPLACEB = u"SC_HID_FUNC_REPLACEB"_ustr; +inline constexpr OUString HID_FUNC_FINDB = u"SC_HID_FUNC_FINDB"_ustr; +inline constexpr OUString HID_FUNC_SEARCHB = u"SC_HID_FUNC_SEARCHB"_ustr; +inline constexpr OUString HID_FUNC_REGEX = u"SC_HID_FUNC_REGEX"_ustr; +inline constexpr OUString HID_FUNC_FOURIER = u"SC_HID_FUNC_FOURIER"_ustr; +inline constexpr OUString HID_FUNC_RAND_NV = u"SC_HID_FUNC_RAND_NV"_ustr; +inline constexpr OUString HID_FUNC_RANDBETWEEN_NV = u"SC_HID_FUNC_RANDBETWEEN_NV"_ustr; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/hints.hxx b/sc/inc/hints.hxx new file mode 100644 index 0000000000..d890072c1f --- /dev/null +++ b/sc/inc/hints.hxx @@ -0,0 +1,139 @@ +/* -*- 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 "global.hxx" +#include "address.hxx" +#include <tools/solar.h> +#include <svl/hint.hxx> + +class SC_DLLPUBLIC ScPaintHint final : public SfxHint +{ + ScRange aRange; + PaintPartFlags nParts; + +public: + ScPaintHint() = delete; + ScPaintHint( const ScRange& rRng, PaintPartFlags nPaint ); + virtual ~ScPaintHint() override; + + SCCOL GetStartCol() const { return aRange.aStart.Col(); } + SCROW GetStartRow() const { return aRange.aStart.Row(); } + SCTAB GetStartTab() const { return aRange.aStart.Tab(); } + SCCOL GetEndCol() const { return aRange.aEnd.Col(); } + SCROW GetEndRow() const { return aRange.aEnd.Row(); } + SCTAB GetEndTab() const { return aRange.aEnd.Tab(); } + PaintPartFlags GetParts() const { return nParts; } +}; + +class ScUpdateRefHint final : public SfxHint +{ + UpdateRefMode eUpdateRefMode; + ScRange aRange; + SCCOL nDx; + SCROW nDy; + SCTAB nDz; + +public: + ScUpdateRefHint( UpdateRefMode eMode, const ScRange& rR, + SCCOL nX, SCROW nY, SCTAB nZ ); + virtual ~ScUpdateRefHint() override; + + UpdateRefMode GetMode() const { return eUpdateRefMode; } + const ScRange& GetRange() const { return aRange; } + SCCOL GetDx() const { return nDx; } + SCROW GetDy() const { return nDy; } + SCTAB GetDz() const { return nDz; } +}; + +//! move ScLinkRefreshedHint to a different file? +enum class ScLinkRefType { + NONE, SHEET, AREA, DDE +}; + +class ScLinkRefreshedHint final : public SfxHint +{ + ScLinkRefType nLinkType; + OUString aUrl; // used for sheet links + OUString aDdeAppl; // used for dde links: + OUString aDdeTopic; + OUString aDdeItem; + ScAddress aDestPos; // used to identify area links + //! also use source data for area links? + +public: + ScLinkRefreshedHint(); + virtual ~ScLinkRefreshedHint() override; + + void SetSheetLink( const OUString& rSourceUrl ); + void SetDdeLink( const OUString& rA, const OUString& rT, const OUString& rI ); + void SetAreaLink( const ScAddress& rPos ); + + ScLinkRefType GetLinkType() const { return nLinkType; } + const OUString& GetUrl() const { return aUrl; } + const OUString& GetDdeAppl() const { return aDdeAppl; } + const OUString& GetDdeTopic() const { return aDdeTopic; } + const OUString& GetDdeItem() const { return aDdeItem; } + const ScAddress& GetDestPos() const { return aDestPos; } +}; + +//! move ScAutoStyleHint to a different file? + +class ScAutoStyleHint final : public SfxHint +{ + ScRange aRange; + OUString aStyle1; + OUString aStyle2; + sal_uLong nTimeout; + +public: + ScAutoStyleHint( const ScRange& rR, OUString aSt1, + sal_uLong nT, OUString aSt2 ); + virtual ~ScAutoStyleHint() override; + + const ScRange& GetRange() const { return aRange; } + const OUString& GetStyle1() const { return aStyle1; } + sal_uInt32 GetTimeout() const { return nTimeout; } + const OUString& GetStyle2() const { return aStyle2; } +}; + +class ScDBRangeRefreshedHint final : public SfxHint +{ + ScImportParam aParam; + +public: + ScDBRangeRefreshedHint( const ScImportParam& rP ); + virtual ~ScDBRangeRefreshedHint() override; + + const ScImportParam& GetImportParam() const { return aParam; } +}; + +class ScDataPilotModifiedHint final : public SfxHint +{ + OUString maName; + +public: + ScDataPilotModifiedHint( OUString aName ); + virtual ~ScDataPilotModifiedHint() override; + + const OUString& GetName() const { return maName; } +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/importfilterdata.hxx b/sc/inc/importfilterdata.hxx new file mode 100644 index 0000000000..fb054c7ccd --- /dev/null +++ b/sc/inc/importfilterdata.hxx @@ -0,0 +1,48 @@ +/* -*- 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/. + */ + +#pragma once + +#include "address.hxx" + +#include <memory> + +namespace sc { + +/** + * Stores data imported from the file that need to be processed at the end + * of the import process. + */ +struct ImportPostProcessData +{ + ImportPostProcessData() = default; + ImportPostProcessData(const ImportPostProcessData&) = delete; + const ImportPostProcessData& operator=(const ImportPostProcessData&) = delete; + /** + * Data stream data needs to be post-processed because it requires + * ScDocShell instance which is not available in the filter code. + */ + struct DataStream + { + enum InsertPos { InsertTop, InsertBottom }; + + OUString maURL; + ScRange maRange; + bool mbRefreshOnEmpty; + InsertPos meInsertPos; + + DataStream(); + }; + + std::unique_ptr<DataStream> mpDataStream; +}; + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/inputopt.hxx b/sc/inc/inputopt.hxx new file mode 100644 index 0000000000..05e59aad57 --- /dev/null +++ b/sc/inc/inputopt.hxx @@ -0,0 +1,90 @@ +/* -*- 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 <unotools/configitem.hxx> + +class ScInputOptions +{ +private: + sal_uInt16 nMoveDir; // enum ScDirection + bool bMoveSelection; + bool bEnterEdit; + bool bExtendFormat; + bool bRangeFinder; + bool bExpandRefs; + bool mbSortRefUpdate; + bool bMarkHeader; + bool bUseTabCol; + bool bTextWysiwyg; + bool bReplCellsWarn; + bool bLegacyCellSelection; + bool bEnterPasteMode; + +public: + ScInputOptions(); + + void SetMoveDir(sal_uInt16 nNew) { nMoveDir = nNew; } + sal_uInt16 GetMoveDir() const { return nMoveDir; } + void SetMoveSelection(bool bSet) { bMoveSelection = bSet; } + bool GetMoveSelection() const { return bMoveSelection; } + void SetEnterEdit(bool bSet) { bEnterEdit = bSet; } + bool GetEnterEdit() const { return bEnterEdit; } + void SetExtendFormat(bool bSet) { bExtendFormat = bSet; } + bool GetExtendFormat() const { return bExtendFormat; } + void SetRangeFinder(bool bSet) { bRangeFinder = bSet; } + bool GetRangeFinder() const { return bRangeFinder; } + void SetExpandRefs(bool bSet) { bExpandRefs = bSet; } + bool GetExpandRefs() const { return bExpandRefs; } + void SetSortRefUpdate(bool bSet) { mbSortRefUpdate = bSet; } + bool GetSortRefUpdate() const { return mbSortRefUpdate; } + void SetMarkHeader(bool bSet) { bMarkHeader = bSet; } + bool GetMarkHeader() const { return bMarkHeader; } + void SetUseTabCol(bool bSet) { bUseTabCol = bSet; } + bool GetUseTabCol() const { return bUseTabCol; } + void SetTextWysiwyg(bool bSet) { bTextWysiwyg = bSet; } + bool GetTextWysiwyg() const { return bTextWysiwyg; } + void SetReplaceCellsWarn(bool bSet) { bReplCellsWarn = bSet; } + bool GetReplaceCellsWarn() const { return bReplCellsWarn; } + void SetLegacyCellSelection(bool bSet) { bLegacyCellSelection = bSet; } + bool GetLegacyCellSelection() const { return bLegacyCellSelection; } + void SetEnterPasteMode(bool bSet) { bEnterPasteMode = bSet; } + bool GetEnterPasteMode() const { return bEnterPasteMode; } +}; + +// CfgItem for input options + +class ScInputCfg final : private ScInputOptions, + public utl::ConfigItem +{ + static css::uno::Sequence<OUString> GetPropertyNames(); + void ReadCfg(); + virtual void ImplCommit() override; + +public: + ScInputCfg(); + + const ScInputOptions& GetOptions() const { return *this; } + void SetOptions( const ScInputOptions& rNew ); + + virtual void Notify( const css::uno::Sequence<OUString>& aPropertyNames ) override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/interpretercontext.hxx b/sc/inc/interpretercontext.hxx new file mode 100644 index 0000000000..39d528cb6c --- /dev/null +++ b/sc/inc/interpretercontext.hxx @@ -0,0 +1,169 @@ +/* -*- 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/. + */ + +#pragma once + +#include <vector> +#include <memory> +#include "types.hxx" + +namespace formula +{ +class FormulaToken; +} + +#define TOKEN_CACHE_SIZE 8 + +class ScDocument; +class SvNumberFormatter; +struct ScLookupCacheMap; +class ScInterpreter; +enum class SvNumFormatType : sal_Int16; + +// SetNumberFormat() is not thread-safe, so calls to it need to be delayed to the main thread. +struct DelayedSetNumberFormat +{ + SCCOL mCol; + SCROW mRow; + sal_uInt32 mnNumberFormat; +}; + +struct NFIndexAndFmtType +{ + sal_uInt32 nIndex; + SvNumFormatType eType : 16; + bool bIsValid : 1; + + NFIndexAndFmtType() + : nIndex(0) + , eType(static_cast<SvNumFormatType>(0)) + , bIsValid(false) + { + } +}; + +class ScInterpreterContextPool; + +struct ScInterpreterContext +{ + const ScDocument* mpDoc; + size_t mnTokenCachePos; + std::vector<formula::FormulaToken*> maTokens; + std::vector<DelayedSetNumberFormat> maDelayedSetNumberFormat; + std::unique_ptr<ScLookupCacheMap> mxScLookupCache; // cache for lookups like VLOOKUP and MATCH + // Allocation cache for "aConditions" array in ScInterpreter::IterateParameterIfs() + // This is populated/used only when formula-group threading is enabled. + std::vector<sal_uInt8> maConditions; + ScInterpreter* pInterpreter; + + ScInterpreterContext(const ScDocument& rDoc, SvNumberFormatter* pFormatter); + + ScInterpreterContext() = delete; + + ~ScInterpreterContext(); + + SvNumberFormatter* GetFormatTable() const + { + if (mpFormatter == nullptr) + const_cast<ScInterpreterContext*>(this)->initFormatTable(); + return mpFormatter; + } + + SvNumFormatType GetNumberFormatType(sal_uInt32 nFIndex) const; + +private: + friend class ScInterpreterContextPool; + void ResetTokens(); + void SetDocAndFormatter(const ScDocument& rDoc, SvNumberFormatter* pFormatter); + void Cleanup(); + void ClearLookupCache(const ScDocument* pDoc); + void initFormatTable(); + SvNumberFormatter* mpFormatter; + mutable NFIndexAndFmtType maNFTypeCache; +}; + +class ScThreadedInterpreterContextGetterGuard; +class ScInterpreterContextGetterGuard; + +class ScInterpreterContextPool +{ + friend class ScThreadedInterpreterContextGetterGuard; + friend class ScInterpreterContextGetterGuard; + + std::vector<std::unique_ptr<ScInterpreterContext>> maPool; + size_t mnNextFree; + bool mbThreaded; + + ScInterpreterContextPool(bool bThreaded) + : mnNextFree(0) + , mbThreaded(bThreaded) + { + } + + ~ScInterpreterContextPool() {} + + static ScInterpreterContextPool aThreadedInterpreterPool; + static ScInterpreterContextPool aNonThreadedInterpreterPool; + + // API for threaded case + + // Ensures nNumThreads elements in pool. + void Init(size_t nNumThreads, const ScDocument& rDoc, SvNumberFormatter* pFormatter); + + // Returns ScInterpreterContext* for thread index nThreadIdx + ScInterpreterContext* GetInterpreterContextForThreadIdx(size_t nThreadIdx) const; + + // API for non-threaded + + // Ensures there is one unused element in the pool. + void Init(const ScDocument& rDoc, SvNumberFormatter* pFormatter); + + // Returns ScInterpreterContext* for non-threaded use. + ScInterpreterContext* GetInterpreterContext() const; + + // Common API for threaded/non-threaded + + // Cleans up the contexts prepared by call to immediately previous Init() and + // marks them all as unused. + void ReturnToPool(); + +public: + // Only to be used to clear lookup cache in all pool elements + static void ClearLookupCaches(const ScDocument* pDoc); +}; + +class ScThreadedInterpreterContextGetterGuard +{ + ScInterpreterContextPool& rPool; + +public: + ScThreadedInterpreterContextGetterGuard(size_t nNumThreads, const ScDocument& rDoc, + SvNumberFormatter* pFormatter); + ~ScThreadedInterpreterContextGetterGuard(); + + // Returns ScInterpreterContext* for thread index nThreadIdx + ScInterpreterContext* GetInterpreterContextForThreadIdx(size_t nThreadIdx) const; +}; + +class ScInterpreterContextGetterGuard +{ + ScInterpreterContextPool& rPool; +#if !defined NDEBUG + size_t nContextIdx; +#endif + +public: + ScInterpreterContextGetterGuard(const ScDocument& rDoc, SvNumberFormatter* pFormatter); + ~ScInterpreterContextGetterGuard(); + + // Returns ScInterpreterContext* for non-threaded use. + ScInterpreterContext* GetInterpreterContext() const; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/sc/inc/kahan.hxx b/sc/inc/kahan.hxx new file mode 100644 index 0000000000..c2560635fb --- /dev/null +++ b/sc/inc/kahan.hxx @@ -0,0 +1,276 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * 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/. + */ + +#pragma once + +#include <rtl/math.hxx> +#include <cmath> + +class KahanSum; +namespace sc::op +{ +// Checkout available optimization options. +// Note that it turned out to be problematic to support CPU-specific code +// that's not guaranteed to be available on that specific platform (see +// git commit 2d36e7f5186ba5215f2b228b98c24520bd4f2882). SSE2 is guaranteed on +// x86_64 and it is our baseline requirement for x86 on Windows, so SSE2 use is +// hardcoded on those platforms. +// Whenever we raise baseline to e.g. AVX, this may get +// replaced with AVX code (get it from mentioned git commit). +// Do it similarly with other platforms. +#if defined(X86_64) || (defined(INTEL) && defined(_WIN32)) +#define SC_USE_SSE2 1 +KahanSum executeSSE2(size_t& i, size_t nSize, const double* pCurrent); +#else +#define SC_USE_SSE2 0 +#endif +} + +/** + * This class provides LO with Kahan summation algorithm + * About this algorithm: https://en.wikipedia.org/wiki/Kahan_summation_algorithm + * For general purpose software we assume first order error is enough. + * + * Additionally queue and remember the last recent non-zero value and add it + * similar to approxAdd() when obtaining the final result to further eliminate + * accuracy errors. (e.g. for the dreaded 0.1 + 0.2 - 0.3 != 0.0) + */ + +class KahanSum +{ +public: + constexpr KahanSum() = default; + + constexpr KahanSum(double x_0) + : m_fSum(x_0) + { + } + + constexpr KahanSum(double x_0, double err_0) + : m_fSum(x_0) + , m_fError(err_0) + { + } + + constexpr KahanSum(const KahanSum& fSum) = default; + +public: + /** + * Performs one step of the Neumaier sum of doubles. + * Overwrites the summand and error. + * T could be double or long double. + */ + template <typename T> static inline void sumNeumaierNormal(T& sum, T& err, const double& value) + { + T t = sum + value; + if (std::abs(sum) >= std::abs(value)) + err += (sum - t) + value; + else + err += (value - t) + sum; + sum = t; + } + + /** + * Adds a value to the sum using Kahan summation. + * @param x_i + */ + void add(double x_i) + { + if (x_i == 0.0) + return; + + if (!m_fMem) + { + m_fMem = x_i; + return; + } + + sumNeumaierNormal(m_fSum, m_fError, m_fMem); + m_fMem = x_i; + } + + /** + * Adds a value to the sum using Kahan summation. + * @param fSum + */ + inline void add(const KahanSum& fSum) + { +#if SC_USE_SSE2 + add(fSum.m_fSum + fSum.m_fError); + add(fSum.m_fMem); +#else + // Without SSE2 the sum+compensation value fails badly. Continue + // keeping the old though slightly off (see tdf#156985) explicit + // addition of the compensation value. + double sum = fSum.m_fSum; + double err = fSum.m_fError; + if (fSum.m_fMem != 0.0) + sumNeumaierNormal(sum, err, fSum.m_fMem); + add(sum); + add(err); +#endif + } + + /** + * Substracts a value to the sum using Kahan summation. + * @param fSum + */ + inline void subtract(const KahanSum& fSum) { add(-fSum); } + +public: + constexpr KahanSum operator-() const + { + KahanSum fKahanSum; + fKahanSum.m_fSum = -m_fSum; + fKahanSum.m_fError = -m_fError; + fKahanSum.m_fMem = -m_fMem; + return fKahanSum; + } + + constexpr KahanSum& operator=(double fSum) + { + m_fSum = fSum; + m_fError = 0; + m_fMem = 0; + return *this; + } + + constexpr KahanSum& operator=(const KahanSum& fSum) = default; + + inline void operator+=(const KahanSum& fSum) { add(fSum); } + + inline void operator+=(double fSum) { add(fSum); } + + inline void operator-=(const KahanSum& fSum) { subtract(fSum); } + + inline void operator-=(double fSum) { add(-fSum); } + + inline KahanSum operator+(double fSum) const + { + KahanSum fNSum(*this); + fNSum.add(fSum); + return fNSum; + } + + inline KahanSum operator+(const KahanSum& fSum) const + { + KahanSum fNSum(*this); + fNSum += fSum; + return fNSum; + } + + inline KahanSum operator-(double fSum) const + { + KahanSum fNSum(*this); + fNSum.add(-fSum); + return fNSum; + } + + inline KahanSum operator-(const KahanSum& fSum) const + { + KahanSum fNSum(*this); + fNSum -= fSum; + return fNSum; + } + + /** + * In some parts of the code of interpr_.cxx this may be used for + * product instead of sum. This operator shall be used for that task. + */ + constexpr void operator*=(double fTimes) + { + if (m_fMem) + { + m_fSum = get() * fTimes; + m_fMem = 0.0; + } + else + { + m_fSum = (m_fSum + m_fError) * fTimes; + } + m_fError = 0.0; + } + + constexpr void operator/=(double fDivides) + { + if (m_fMem) + { + m_fSum = get() / fDivides; + m_fMem = 0.0; + } + else + { + m_fSum = (m_fSum + m_fError) / fDivides; + } + m_fError = 0.0; + } + + inline KahanSum operator*(const KahanSum& fTimes) const { return get() * fTimes.get(); } + + inline KahanSum operator*(double fTimes) const { return get() * fTimes; } + + inline KahanSum operator/(const KahanSum& fDivides) const { return get() / fDivides.get(); } + + inline KahanSum operator/(double fDivides) const { return get() / fDivides; } + + inline bool operator<(const KahanSum& fSum) const { return get() < fSum.get(); } + + inline bool operator<(double fSum) const { return get() < fSum; } + + inline bool operator>(const KahanSum& fSum) const { return get() > fSum.get(); } + + inline bool operator>(double fSum) const { return get() > fSum; } + + inline bool operator<=(const KahanSum& fSum) const { return get() <= fSum.get(); } + + inline bool operator<=(double fSum) const { return get() <= fSum; } + + inline bool operator>=(const KahanSum& fSum) const { return get() >= fSum.get(); } + + inline bool operator>=(double fSum) const { return get() >= fSum; } + + inline bool operator==(const KahanSum& fSum) const { return get() == fSum.get(); } + + inline bool operator!=(const KahanSum& fSum) const { return get() != fSum.get(); } + +public: + /** + * Returns the final sum. + * @return final sum + */ + double get() const + { + const double fTotal = m_fSum + m_fError; + if (!m_fMem) + return fTotal; + + // Check the same condition as rtl::math::approxAdd() and if true + // return 0.0, if false use another Kahan summation adding m_fMem. + if (((m_fMem < 0.0 && fTotal > 0.0) || (fTotal < 0.0 && m_fMem > 0.0)) + && rtl::math::approxEqual(m_fMem, -fTotal)) + { + /* TODO: should we reset all values to zero here for further + * summation, or is it better to keep them as they are? */ + return 0.0; + } + + // The actual argument passed to add() here does not matter as long as + // it is not 0, m_fMem is not 0 and will be added anyway, see add(). + const_cast<KahanSum*>(this)->add(m_fMem); + const_cast<KahanSum*>(this)->m_fMem = 0.0; + return m_fSum + m_fError; + } + +private: + double m_fSum = 0; + double m_fError = 0; + double m_fMem = 0; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/sc/inc/linkuno.hxx b/sc/inc/linkuno.hxx new file mode 100644 index 0000000000..855bb22843 --- /dev/null +++ b/sc/inc/linkuno.hxx @@ -0,0 +1,465 @@ +/* -*- 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 <svl/lstner.hxx> +#include <svl/itemprop.hxx> +#include <com/sun/star/sheet/XDDELink.hpp> +#include <com/sun/star/sheet/XDDELinkResults.hpp> +#include <com/sun/star/sheet/XDDELinks.hpp> +#include <com/sun/star/sheet/XExternalDocLink.hpp> +#include <com/sun/star/sheet/XExternalDocLinks.hpp> +#include <com/sun/star/sheet/XExternalSheetCache.hpp> +#include <com/sun/star/sheet/XAreaLink.hpp> +#include <com/sun/star/sheet/XAreaLinks.hpp> +#include <com/sun/star/util/XRefreshable.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/container/XEnumerationAccess.hpp> +#include <com/sun/star/container/XNameAccess.hpp> +#include <com/sun/star/container/XIndexAccess.hpp> +#include <com/sun/star/container/XNamed.hpp> +#include <cppuhelper/implbase.hxx> + +#include "externalrefmgr.hxx" + +#include <vector> + +class ScDocShell; +class ScTableLink; + +typedef std::vector< css::uno::Reference< css::util::XRefreshListener > > XRefreshListenerArr_Impl; + +class ScSheetLinkObj final : public cppu::WeakImplHelper< + css::container::XNamed, + css::util::XRefreshable, + css::beans::XPropertySet, + css::lang::XServiceInfo >, + public SfxListener +{ +private: + SfxItemPropertySet aPropSet; + ScDocShell* pDocShell; + OUString aFileName; + XRefreshListenerArr_Impl aRefreshListeners; + + ScTableLink* GetLink_Impl() const; + void Refreshed_Impl(); + void ModifyRefreshDelay_Impl( sal_Int32 nRefresh ); + +public: + ScSheetLinkObj(ScDocShell* pDocSh, OUString aName); + virtual ~ScSheetLinkObj() override; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + // XNamed + virtual OUString SAL_CALL getName() override; + virtual void SAL_CALL setName( const OUString& aName ) override; + + // XRefreshable + virtual void SAL_CALL refresh() override; + virtual void SAL_CALL addRefreshListener( const css::uno::Reference< css::util::XRefreshListener >& l ) override; + virtual void SAL_CALL removeRefreshListener( const css::uno::Reference< css::util::XRefreshListener >& l ) override; + + // XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > + SAL_CALL getPropertySetInfo( ) override; + virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, + const css::uno::Any& aValue ) override; + virtual css::uno::Any SAL_CALL getPropertyValue( + const OUString& PropertyName ) override; + virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override; + virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override; + virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + + // called from get/setPropertyValue: + OUString getFileName() const; + void setFileName(const OUString& FileName); + OUString getFilter() const; + void setFilter(const OUString& Filter); + OUString getFilterOptions() const; + void setFilterOptions(const OUString& FilterOptions); + sal_Int32 getRefreshDelay() const; + void setRefreshDelay(sal_Int32 nRefreshDelay); + + // XServiceInfo + 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; +}; + +class ScSheetLinksObj final : public cppu::WeakImplHelper< + css::container::XNameAccess, + css::container::XEnumerationAccess, + css::container::XIndexAccess, + css::lang::XServiceInfo >, + public SfxListener +{ +private: + ScDocShell* pDocShell; + + rtl::Reference<ScSheetLinkObj> GetObjectByIndex_Impl(sal_Int32 nIndex); + rtl::Reference<ScSheetLinkObj> GetObjectByName_Impl(const OUString& aName); + +public: + ScSheetLinksObj(ScDocShell* pDocSh); + virtual ~ScSheetLinksObj() override; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + // XNameAccess + virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override; + virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override; + + // XIndexAccess + virtual sal_Int32 SAL_CALL getCount() override; + virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override; + + // XEnumerationAccess + virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL + createEnumeration() override; + + // XElementAccess + virtual css::uno::Type SAL_CALL getElementType() override; + virtual sal_Bool SAL_CALL hasElements() override; + + // XServiceInfo + 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; +}; + +class ScAreaLinkObj final : public cppu::WeakImplHelper< + css::sheet::XAreaLink, + css::util::XRefreshable, + css::beans::XPropertySet, + css::lang::XServiceInfo >, + public SfxListener +{ +private: + SfxItemPropertySet aPropSet; + ScDocShell* pDocShell; + size_t nPos; + XRefreshListenerArr_Impl aRefreshListeners; + + void Modify_Impl( const OUString* pNewFile, const OUString* pNewFilter, + const OUString* pNewOptions, const OUString* pNewSource, + const css::table::CellRangeAddress* pNewDest ); + void ModifyRefreshDelay_Impl( sal_Int32 nRefresh ); + void Refreshed_Impl(); + +public: + ScAreaLinkObj(ScDocShell* pDocSh, size_t nP); + virtual ~ScAreaLinkObj() override; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + // XRefreshable + virtual void SAL_CALL refresh() override; + virtual void SAL_CALL addRefreshListener( const css::uno::Reference< css::util::XRefreshListener >& l ) override; + virtual void SAL_CALL removeRefreshListener( const css::uno::Reference< css::util::XRefreshListener >& l ) override; + + // XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > + SAL_CALL getPropertySetInfo( ) override; + virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, + const css::uno::Any& aValue ) override; + virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override; + virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override; + virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override; + virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + + // called from get/setPropertyValue: + OUString getFileName() const; + void setFileName(const OUString& FileName); + OUString getFilter() const; + void setFilter(const OUString& Filter); + OUString getFilterOptions() const; + void setFilterOptions(const OUString& FilterOptions); + sal_Int32 getRefreshDelay() const; + void setRefreshDelay(sal_Int32 nRefreshDelay); + + // XAreaLink + virtual OUString SAL_CALL getSourceArea() override; + virtual void SAL_CALL setSourceArea( const OUString& aSourceArea ) override; + virtual css::table::CellRangeAddress SAL_CALL getDestArea() override; + virtual void SAL_CALL setDestArea( const css::table::CellRangeAddress& aDestArea ) override; + + // XServiceInfo + 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; +}; + +class ScAreaLinksObj final : public cppu::WeakImplHelper< + css::sheet::XAreaLinks, + css::container::XEnumerationAccess, + css::lang::XServiceInfo >, + public SfxListener +{ +private: + ScDocShell* pDocShell; + + rtl::Reference<ScAreaLinkObj> GetObjectByIndex_Impl(sal_Int32 nIndex); + +public: + ScAreaLinksObj(ScDocShell* pDocSh); + virtual ~ScAreaLinksObj() override; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + // XAreaLinks + virtual void SAL_CALL insertAtPosition( const css::table::CellAddress& aDestPos, + const OUString& aFileName, + const OUString& aSourceArea, + const OUString& aFilter, + const OUString& aFilterOptions ) override; + virtual void SAL_CALL removeByIndex( sal_Int32 nIndex ) override; + + // XIndexAccess + virtual sal_Int32 SAL_CALL getCount() override; + virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override; + + // XEnumerationAccess + virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL + createEnumeration() override; + + // XElementAccess + virtual css::uno::Type SAL_CALL getElementType() override; + virtual sal_Bool SAL_CALL hasElements() override; + + // XServiceInfo + 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; +}; + +//! order of XNamed and DDELink changed to avoid "duplicate comdat" symbols + +class ScDDELinkObj final : public cppu::WeakImplHelper< + css::sheet::XDDELink, + css::container::XNamed, + css::util::XRefreshable, + css::sheet::XDDELinkResults, + css::lang::XServiceInfo >, + public SfxListener +{ +private: + ScDocShell* pDocShell; + OUString aAppl; + OUString aTopic; + OUString aItem; + XRefreshListenerArr_Impl aRefreshListeners; + + void Refreshed_Impl(); + +public: + ScDDELinkObj(ScDocShell* pDocSh, OUString aA, + OUString aT, OUString aI); + virtual ~ScDDELinkObj() override; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + // XNamed + virtual OUString SAL_CALL getName() override; + virtual void SAL_CALL setName( const OUString& aName ) override; + + // XDDELink + virtual OUString SAL_CALL getApplication() override; + virtual OUString SAL_CALL getTopic() override; + virtual OUString SAL_CALL getItem() override; + + // XRefreshable + virtual void SAL_CALL refresh() override; + virtual void SAL_CALL addRefreshListener( const css::uno::Reference< css::util::XRefreshListener >& l ) override; + virtual void SAL_CALL removeRefreshListener( const css::uno::Reference< css::util::XRefreshListener >& l ) override; + + // XDDELinkResults + virtual css::uno::Sequence< css::uno::Sequence< css::uno::Any > > + SAL_CALL getResults( ) override; + virtual void SAL_CALL setResults( + const css::uno::Sequence< css::uno::Sequence< css::uno::Any > >& aResults ) override; + + // XServiceInfo + 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; +}; + +class ScDDELinksObj final : public cppu::WeakImplHelper< + css::container::XEnumerationAccess, + css::container::XIndexAccess, + css::sheet::XDDELinks, + css::lang::XServiceInfo >, + public SfxListener +{ +private: + ScDocShell* pDocShell; + + rtl::Reference<ScDDELinkObj> GetObjectByIndex_Impl(sal_Int32 nIndex); + rtl::Reference<ScDDELinkObj> GetObjectByName_Impl(std::u16string_view aName); + +public: + ScDDELinksObj(ScDocShell* pDocSh); + virtual ~ScDDELinksObj() override; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + // XNameAccess + virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override; + virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override; + + // XIndexAccess + virtual sal_Int32 SAL_CALL getCount() override; + virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override; + + // XEnumerationAccess + virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL + createEnumeration() override; + + // XElementAccess + virtual css::uno::Type SAL_CALL getElementType() override; + virtual sal_Bool SAL_CALL hasElements() override; + + // XDDELinks + virtual css::uno::Reference< css::sheet::XDDELink > SAL_CALL addDDELink( + const OUString& aApplication, const OUString& aTopic, + const OUString& aItem, css::sheet::DDELinkMode nMode ) override; + + // XServiceInfo + 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; +}; + +class ScExternalSheetCacheObj final : public cppu::WeakImplHelper< css::sheet::XExternalSheetCache > +{ +public: + explicit ScExternalSheetCacheObj(ScDocShell* pDocShell, ScExternalRefCache::TableTypeRef pTable, size_t nIndex); + virtual ~ScExternalSheetCacheObj() override; + + // XExternalSheetCache + virtual void SAL_CALL setCellValue( + sal_Int32 nCol, sal_Int32 nRow, const css::uno::Any& rAny) override; + + virtual css::uno::Any SAL_CALL getCellValue(sal_Int32 nCol, sal_Int32 nRow) override; + + virtual css::uno::Sequence< sal_Int32 > SAL_CALL getAllRows() override; + + virtual css::uno::Sequence< sal_Int32 > SAL_CALL getAllColumns(sal_Int32 nRow) override; + + // Attributes + virtual sal_Int32 SAL_CALL getTokenIndex() override; + +private: + ScExternalSheetCacheObj(const ScExternalSheetCacheObj&) = delete; + +private: + ScDocShell* mpDocShell; + ScExternalRefCache::TableTypeRef mpTable; + size_t mnIndex; +}; + +class ScExternalDocLinkObj final : public cppu::WeakImplHelper< css::sheet::XExternalDocLink > +{ +public: + ScExternalDocLinkObj(ScDocShell* pDocShell, ScExternalRefManager* pRefMgr, sal_uInt16 nFileId); + virtual ~ScExternalDocLinkObj() override; + + // XExternalDocLink + virtual css::uno::Reference< css::sheet::XExternalSheetCache > + SAL_CALL addSheetCache( const OUString& aSheetName, sal_Bool bDynamicCache ) override; + + // XNameAccess + virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override; + virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override; + + // XIndexAccess + virtual sal_Int32 SAL_CALL getCount() override; + virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 nIndex ) override; + + // XEnumerationAccess + virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL + createEnumeration() override; + + // XElementAccess + virtual css::uno::Type SAL_CALL getElementType() override; + virtual sal_Bool SAL_CALL hasElements() override; + + // Attributes + virtual sal_Int32 SAL_CALL getTokenIndex() override; + +private: + ScDocShell* mpDocShell; + ScExternalRefManager* mpRefMgr; + sal_uInt16 mnFileId; +}; + +/** This is the UNO API equivalent of ScExternalRefManager. */ +class ScExternalDocLinksObj final : public cppu::WeakImplHelper< css::sheet::XExternalDocLinks > +{ +public: + ScExternalDocLinksObj(ScDocShell* pDocShell); + virtual ~ScExternalDocLinksObj() override; + + // XExternalDocLinks + virtual css::uno::Reference< css::sheet::XExternalDocLink > + SAL_CALL addDocLink( const OUString& aDocName ) override; + + // XNameAccess + virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override; + virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override; + + // XIndexAccess + virtual sal_Int32 SAL_CALL getCount() override; + virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 nIndex ) override; + + // XEnumerationAccess + virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL + createEnumeration() override; + + // XElementAccess + virtual css::uno::Type SAL_CALL getElementType() override; + virtual sal_Bool SAL_CALL hasElements() override; + +private: + ScExternalDocLinksObj(const ScExternalDocLinksObj&) = delete; + +private: + ScDocShell* mpDocShell; + ScExternalRefManager* mpRefMgr; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/listenercalls.hxx b/sc/inc/listenercalls.hxx new file mode 100644 index 0000000000..70bc9e1487 --- /dev/null +++ b/sc/inc/listenercalls.hxx @@ -0,0 +1,65 @@ +/* -*- 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 <list> +#include <utility> +#include <com/sun/star/uno/Reference.hxx> +#include <com/sun/star/lang/EventObject.hpp> + +namespace com::sun::star { + namespace util { + class XModifyListener; + } +} + +struct ScUnoListenerEntry +{ + css::uno::Reference< + css::util::XModifyListener > xListener; + css::lang::EventObject aEvent; + + ScUnoListenerEntry( css::uno::Reference< css::util::XModifyListener > xL, + css::lang::EventObject aE ) : + xListener(std::move( xL )), + aEvent(std::move( aE )) + {} +}; + +/** ScUnoListenerCalls stores notifications to XModifyListener that can't be processed + during BroadcastUno and calls them together at the end. +*/ +class ScUnoListenerCalls +{ +private: + // Must be list, not vector, to not invalidate iterators, see + // ExecuteAndClear() implementation. + ::std::list<ScUnoListenerEntry> aEntries; + +public: + ScUnoListenerCalls(); + ~ScUnoListenerCalls(); + + void Add( const css::uno::Reference< css::util::XModifyListener >& rListener, + const css::lang::EventObject& rEvent ); + void ExecuteAndClear(); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/listenercontext.hxx b/sc/inc/listenercontext.hxx new file mode 100644 index 0000000000..964f62a5c1 --- /dev/null +++ b/sc/inc/listenercontext.hxx @@ -0,0 +1,85 @@ +/* -*- 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/. + */ + +#pragma once + +#include "address.hxx" +#include "columnspanset.hxx" +#include "mtvelements.hxx" + +#include <memory> + +class ScDocument; +class ScTokenArray; + +namespace sc +{ +class ColumnSet; + +class StartListeningContext +{ + ScDocument& mrDoc; + std::shared_ptr<ColumnBlockPositionSet> mpSet; + std::shared_ptr<const ColumnSet> mpColSet; + +public: + StartListeningContext(const StartListeningContext&) = delete; + const StartListeningContext& operator=(const StartListeningContext&) = delete; + StartListeningContext(ScDocument& rDoc); + StartListeningContext(ScDocument& rDoc, std::shared_ptr<ColumnBlockPositionSet> pSet); + void setColumnSet(const std::shared_ptr<const ColumnSet>& pColSet); + const std::shared_ptr<const ColumnSet>& getColumnSet() const; + ScDocument& getDoc() { return mrDoc; } + + ColumnBlockPosition* getBlockPosition(SCTAB nTab, SCCOL nCol); +}; + +class EndListeningContext +{ + ScDocument& mrDoc; + ColumnSpanSet maSet; + std::shared_ptr<ColumnBlockPositionSet> mpPosSet; + ScTokenArray* mpOldCode; + ScAddress maPosDelta; // Add this to get the old position prior to the move. + +public: + EndListeningContext(const EndListeningContext&) = delete; + const EndListeningContext& operator=(const EndListeningContext&) = delete; + EndListeningContext(ScDocument& rDoc, ScTokenArray* pOldCode = nullptr); + EndListeningContext(ScDocument& rDoc, std::shared_ptr<ColumnBlockPositionSet> pSet, + ScTokenArray* pOldCode = nullptr); + + void setPositionDelta(const ScAddress& rDelta); + + ScDocument& getDoc() { return mrDoc; } + ScTokenArray* getOldCode() { return mpOldCode; } + ScAddress getOldPosition(const ScAddress& rPos) const; + + ColumnBlockPosition* getBlockPosition(SCTAB nTab, SCCOL nCol); + + void addEmptyBroadcasterPosition(SCTAB nTab, SCCOL nCol, SCROW nRow); + void purgeEmptyBroadcasters(); +}; + +class PurgeListenerAction final : public ColumnSpanSet::Action +{ + ScDocument& mrDoc; + std::unique_ptr<ColumnBlockPosition> mpBlockPos; + +public: + PurgeListenerAction(const PurgeListenerAction&) = delete; + const PurgeListenerAction& operator=(const PurgeListenerAction&) = delete; + PurgeListenerAction(ScDocument& rDoc); + + virtual void startColumn(SCTAB nTab, SCCOL nCol) override; + virtual void execute(const ScAddress& rPos, SCROW nLength, bool bVal) override; +}; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/listenerquery.hxx b/sc/inc/listenerquery.hxx new file mode 100644 index 0000000000..095e65f762 --- /dev/null +++ b/sc/inc/listenerquery.hxx @@ -0,0 +1,69 @@ +/* -*- 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/. + */ + +#ifndef SC_LISTENERQUERY_HXX +#define SC_LISTENERQUERY_HXX + +#include "address.hxx" +#include "rangelst.hxx" +#include <svl/listener.hxx> + +#include <unordered_map> +#include <vector> + +namespace sc +{ +/** + * Used to collect positions of formula cells that belong to a formula + * group. + */ +class RefQueryFormulaGroup final : public SvtListener::QueryBase +{ +public: + typedef std::vector<SCROW> ColType; + typedef std::unordered_map<SCCOL, ColType> ColsType; + typedef std::unordered_map<SCTAB, ColsType> TabsType; + + RefQueryFormulaGroup(); + virtual ~RefQueryFormulaGroup() override; + + void setSkipRange(const ScRange& rRange); + void add(const ScAddress& rPos); + + /** + * Row positions in each column may contain duplicates. Caller must + * remove duplicates if necessary. + */ + const TabsType& getAllPositions() const; + +private: + ScRange maSkipRange; + TabsType maTabs; +}; + +class QueryRange final : public SvtListener::QueryBase +{ + ScRangeList maRanges; + + QueryRange(const QueryRange&) = delete; + QueryRange& operator=(const QueryRange&) = delete; + +public: + QueryRange(); + virtual ~QueryRange() override; + + void add(const ScRange& rRange); + + void swapRanges(ScRangeList& rRanges); +}; +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/listenerqueryids.hxx b/sc/inc/listenerqueryids.hxx new file mode 100644 index 0000000000..ce8a0e2529 --- /dev/null +++ b/sc/inc/listenerqueryids.hxx @@ -0,0 +1,18 @@ +/* -*- 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/. + */ + +#ifndef SC_LISTENERQUERYIDS_HXX +#define SC_LISTENERQUERYIDS_HXX + +#define SC_LISTENER_QUERY_FORMULA_GROUP_POS 0 +#define SC_LISTENER_QUERY_FORMULA_GROUP_RANGE 1 + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/lookupcache.hxx b/sc/inc/lookupcache.hxx new file mode 100644 index 0000000000..ca1d333880 --- /dev/null +++ b/sc/inc/lookupcache.hxx @@ -0,0 +1,209 @@ +/* -*- 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 "address.hxx" +#include <svl/listener.hxx> + +#include <memory> +#include <unordered_map> + +class ScDocument; +struct ScLookupCacheMap; +struct ScQueryEntry; + +/** Lookup cache for one range used with interpreter functions such as VLOOKUP + and MATCH. Caches query for a specific row and the resulting address looked + up, in case other lookups of the same query in the same row are to be + performed, which usually occur to obtain a different offset column of the + same query. + */ + +class ScLookupCache final : public SvtListener +{ +public: + + enum Result + { + NOT_CACHED, /// Query not found in cache. + CRITERIA_DIFFERENT, /// Different criteria for same query position exists. + NOT_AVAILABLE, /// Criteria not available in lookup range. + FOUND /// Criteria found. + }; + + enum QueryOp + { + UNKNOWN, + EQUAL, + LESS_EQUAL, + GREATER_EQUAL + }; + + class QueryCriteria + { + union + { + double mfVal; + const OUString *mpStr; + }; + bool mbAlloc; + bool mbString; + QueryOp meOp; + + void deleteString() + { + if (mbAlloc && mbString) + delete mpStr; + } + + QueryCriteria & operator=( const QueryCriteria & r ) = delete; + + public: + + explicit QueryCriteria( const ScQueryEntry & rEntry ); + QueryCriteria( const QueryCriteria & r ); + ~QueryCriteria(); + + QueryOp getQueryOp() const { return meOp; } + + void setDouble( double fVal ) + { + deleteString(); + mbAlloc = mbString = false; + mfVal = fVal; + } + + void setString( const OUString & rStr ) + { + deleteString(); + mbAlloc = mbString = true; + mpStr = new OUString( rStr); + } + + bool operator==( const QueryCriteria & r ) const + { + return meOp == r.meOp && mbString == r.mbString && + (mbString ? (*mpStr == *r.mpStr) : (mfVal == r.mfVal)); + } + + bool isEmptyStringQuery() const + { + return (getQueryOp() == QueryOp::EQUAL) && mbString && mpStr && mpStr->isEmpty(); + } + }; + + /// MUST be new'd because Notify() deletes. + ScLookupCache( ScDocument * pDoc, const ScRange & rRange, ScLookupCacheMap & cacheMap ) + : maRange( rRange), mpDoc( pDoc), mCacheMap(cacheMap) {} + /// Remove from document structure and delete (!) cache on modify hint. + virtual void Notify( const SfxHint& rHint ) override; + + /// @returns document address in o_rResultAddress if Result==FOUND + Result lookup( ScAddress & o_rResultAddress, + const QueryCriteria & rCriteria, + const ScAddress & rQueryAddress ) const; + + SCROW lookup( const QueryCriteria & rCriteria ) const; + + /** Insert query and result. + @param bAvailable + Pass sal_False if the search didn't deliver a result. A subsequent + lookup() then will return Result::NOT_AVAILABLE. + @returns successful insertion. + */ + bool insert( const ScAddress & rResultAddress, + const QueryCriteria & rCriteria, + const ScAddress & rQueryAddress, + const bool bAvailable ); + + const ScRange& getRange() const { return maRange; } + + ScLookupCacheMap & getCacheMap() const { return mCacheMap; } + + struct Hash + { + size_t operator()( const ScRange & rRange ) const + { + // Lookups are performed on the first column. + return rRange.hashStartColumn(); + } + }; + +private: + + struct QueryKey + { + SCROW mnRow; + SCTAB mnTab; + QueryOp meOp; + + QueryKey( const ScAddress & rAddress, const QueryOp eOp ) : + mnRow( rAddress.Row()), + mnTab( rAddress.Tab()), + meOp( eOp) + { + } + + bool operator==( const QueryKey & r ) const + { + return mnRow == r.mnRow && mnTab == r.mnTab && meOp == r.meOp && meOp != UNKNOWN; + } + + struct Hash + { + size_t operator()( const QueryKey & r ) const + { + return (static_cast<size_t>(r.mnTab) << 24) ^ + (static_cast<size_t>(r.meOp) << 22) ^ + static_cast<size_t>(r.mnRow); + } + }; + }; + + struct QueryCriteriaAndResult + { + QueryCriteria maCriteria; + ScAddress maAddress; + + QueryCriteriaAndResult( const QueryCriteria & rCriteria, const ScAddress & rAddress ) : + maCriteria( rCriteria), + maAddress( rAddress) + { + } + }; + + std::unordered_map< QueryKey, QueryCriteriaAndResult, QueryKey::Hash > maQueryMap; + ScRange maRange; + ScDocument * mpDoc; + ScLookupCacheMap & mCacheMap; + + ScLookupCache( const ScLookupCache & ) = delete; + ScLookupCache & operator=( const ScLookupCache & ) = delete; + +}; + +// Struct because including lookupcache.hxx in document.hxx isn't wanted. +struct ScLookupCacheMap +{ + std::unordered_map< ScRange, std::unique_ptr<ScLookupCache>, ScLookupCache::Hash > aCacheMap; +}; + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/macromgr.hxx b/sc/inc/macromgr.hxx new file mode 100644 index 0000000000..d7930eaa30 --- /dev/null +++ b/sc/inc/macromgr.hxx @@ -0,0 +1,47 @@ +/* -*- 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/. + */ + +#pragma once + +#include <com/sun/star/container/XContainerListener.hpp> + +#include <rtl/ustring.hxx> +#include "scdllapi.h" + +#include <memory> +#include <unordered_map> + +class ScDocument; +class ScFormulaCell; +class ScUserMacroDepTracker; + +class ScMacroManager +{ +public: + explicit ScMacroManager(ScDocument& rDoc); + ~ScMacroManager(); + + SC_DLLPUBLIC void InitUserFuncData(); + SC_DLLPUBLIC void SetUserFuncVolatile(const OUString& sName, bool isVolatile); + SC_DLLPUBLIC bool GetUserFuncVolatile(const OUString& sName); + + void AddDependentCell(const OUString& aModuleName, ScFormulaCell* pCell); + void RemoveDependentCell(const ScFormulaCell* pCell); + void BroadcastModuleUpdate(const OUString& aModuleName); + +private: + typedef std::unordered_map<OUString, bool> NameBoolMap; + NameBoolMap mhFuncToVolatile; + css::uno::Reference<css::container::XContainerListener> mxContainerListener; + + ::std::unique_ptr<ScUserMacroDepTracker> mpDepTracker; + ScDocument& mrDoc; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/markarr.hxx b/sc/inc/markarr.hxx new file mode 100644 index 0000000000..03e94b7d30 --- /dev/null +++ b/sc/inc/markarr.hxx @@ -0,0 +1,89 @@ +/* -*- 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 "address.hxx" +#include <tools/long.hxx> +#include <vector> + +class ScRangeList; +struct ScSheetLimits; + +struct ScMarkEntry +{ + SCROW nRow : 30; // 30 because 31 causes compiler problems with VisualStudio + bool bMarked : 1; + + bool operator==(const ScMarkEntry& rOther) const + { return nRow == rOther.nRow && bMarked == rOther.bMarked; } +}; + +/** + This is a rather odd datastructure. We store alternating marked/not-marked entries, + and for each entry the range is defined as : + [previousEntry.nRow+1, currentEntry.nRow] +*/ +class SC_DLLPUBLIC ScMarkArray +{ + const ScSheetLimits & mrSheetLimits; + std::vector<ScMarkEntry> mvData; + +friend class ScMarkArrayIter; +friend class ScDocument; // for FillInfo + +public: + ScMarkArray( const ScSheetLimits& rLimits ); + ScMarkArray( ScMarkArray&& rArray ) noexcept; + ScMarkArray( const ScMarkArray& rArray ); + void Reset( bool bMarked = false, SCSIZE nNeeded = 1 ); + bool GetMark( SCROW nRow ) const; + void SetMarkArea( SCROW nStartRow, SCROW nEndRow, bool bMarked ); + void Set( std::vector<ScMarkEntry> && ); + bool IsAllMarked( SCROW nStartRow, SCROW nEndRow ) const; + bool HasOneMark( SCROW& rStartRow, SCROW& rEndRow ) const; + + bool HasMarks() const { return mvData.size() > 1 || ( mvData.size() == 1 && mvData[0].bMarked ); } + + ScMarkArray& operator=( ScMarkArray const & rSource ); + ScMarkArray& operator=(ScMarkArray&& rSource) noexcept; + bool operator==(ScMarkArray const & rOther ) const; + + bool Search( SCROW nRow, SCSIZE& nIndex ) const; + + /// Including current row, may return -1 if bUp and not found + SCROW GetNextMarked( SCROW nRow, bool bUp ) const; + SCROW GetMarkEnd( SCROW nRow, bool bUp ) const; + + void Shift( SCROW nStartRow, tools::Long nOffset ); + void Intersect( const ScMarkArray& rOther ); +}; + +class SC_DLLPUBLIC ScMarkArrayIter // iterate over selected range +{ + const ScMarkArray* pArray; + SCSIZE nPos; +public: + ScMarkArrayIter( const ScMarkArray* pNewArray ); + + bool Next( SCROW& rTop, SCROW& rBottom ); + void reset( const ScMarkArray* pNewArray ); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/markdata.hxx b/sc/inc/markdata.hxx new file mode 100644 index 0000000000..80d683f168 --- /dev/null +++ b/sc/inc/markdata.hxx @@ -0,0 +1,168 @@ +/* -*- 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 "address.hxx" +#include "rangelst.hxx" +#include "markmulti.hxx" +#include "scdllapi.h" + +#include <set> +#include <vector> + +namespace sc { + +struct ColRowSpan; + +} + +class ScMarkArray; + +//! todo: +//! It should be possible to have MarkArrays for each table, in order to +//! enable "search all" across more than one table again! + +class SC_DLLPUBLIC ScMarkData +{ +public: + typedef std::set<SCTAB> MarkedTabsType; +private: + MarkedTabsType maTabMarked; + + ScRange aMarkRange; // area + ScRange aMultiRange; // maximum area altogether + ScMultiSel aMultiSel; // multi selection + ScRangeList aTopEnvelope; // list of ranges in the top envelope of the multi selection + ScRangeList aBottomEnvelope; // list of ranges in the bottom envelope of the multi selection + ScRangeList aLeftEnvelope; // list of ranges in the left envelope of the multi selection + ScRangeList aRightEnvelope; // list of ranges in the right envelope of the multi selection + const ScSheetLimits& mrSheetLimits; + bool bMarked:1; // rectangle marked + bool bMultiMarked:1; + + bool bMarking:1; // area is being marked -> no MarkToMulti + bool bMarkIsNeg:1; // cancel if multi selection + +public: + ScMarkData(const ScSheetLimits& rSheetLimits); + ScMarkData(const ScSheetLimits& rSheetLimits, const ScRangeList& rList); + ScMarkData(const ScMarkData& rData) = default; + ScMarkData(ScMarkData&& rData) = default; + ScMarkData& operator=(const ScMarkData& rData); + ScMarkData& operator=(ScMarkData&& rData); + + void ResetMark(); + void SetMarkArea( const ScRange& rRange ); + + // bSetupMulti must be set to true only for recursive calls to SetMultiMarkArea + void SetMultiMarkArea( const ScRange& rRange, bool bMark = true, bool bSetupMulti = false ); + + void MarkToMulti(); + void MarkToSimple(); + + bool IsMarked() const { return bMarked; } + bool IsMultiMarked() const { return bMultiMarked; } + + const ScRange& GetMarkArea() const { return aMarkRange; } + const ScRange& GetMultiMarkArea() const { return aMultiRange; } + const ScRange& GetArea() const { return bMultiMarked ? aMultiRange : aMarkRange; } + + void SetAreaTab( SCTAB nTab ); + + void SelectTable( SCTAB nTab, bool bNew ); + bool GetTableSelect( SCTAB nTab ) const; + + void SelectOneTable( SCTAB nTab ); + SCTAB GetSelectCount() const; + SCTAB GetFirstSelected() const; + SCTAB GetLastSelected() const; + + const MarkedTabsType& GetSelectedTabs() const { return maTabMarked;} + void SetSelectedTabs(const MarkedTabsType& rTabs); + + void SetMarkNegative( bool bFlag ) { bMarkIsNeg = bFlag; } + bool IsMarkNegative() const { return bMarkIsNeg; } + void SetMarking( bool bFlag ) { bMarking = bFlag; } + bool GetMarkingFlag() const { return bMarking; } + + // for FillInfo / Document etc. + const ScMultiSel& GetMultiSelData() const { return aMultiSel; } + ScMarkArray GetMarkArray( SCCOL nCol ) const { return aMultiSel.GetMarkArray( nCol ); } + + bool IsCellMarked( SCCOL nCol, SCROW nRow, bool bNoSimple = false ) const; + + /** Create a range list of marks. + @param nForTab + If -1, use start-sheet-tab of the multi-area in ranges. + If >= 0, use given sheet-tab in ranges. + */ + void FillRangeListWithMarks( ScRangeList* pList, bool bClear, SCTAB nForTab = -1 ) const; + void ExtendRangeListTables( ScRangeList* pList ) const; + + ScRangeList GetMarkedRanges() const; + /** Get marked ranges with sheet-tab set to nTab. + Marks are stored for the currently active sheet respectively the + multi-area start-sheet-tab, update ranges with the sheet for which this + is called. */ + ScRangeList GetMarkedRangesForTab( SCTAB nTab ) const; + + void MarkFromRangeList( const ScRangeList& rList, bool bReset ); + + std::vector<sc::ColRowSpan> GetMarkedRowSpans() const; + std::vector<sc::ColRowSpan> GetMarkedColSpans() const; + + bool IsColumnMarked( SCCOL nCol ) const; + bool IsRowMarked( SCROW nRow ) const; + bool IsAllMarked( const ScRange& rRange ) const; // Multi + + // Returns the first column of the range [column,nLastCol] for which + // all those columns have equal marks. Value returned is not less than nMinCol. + SCCOL GetStartOfEqualColumns( SCCOL nLastCol, SCCOL nMinCol = 0 ) const; + + /// May return -1 + SCROW GetNextMarked( SCCOL nCol, SCROW nRow, bool bUp ) const; + bool HasMultiMarks( SCCOL nCol ) const; + bool HasAnyMultiMarks() const; + + // adjust table marking: + void InsertTab( SCTAB nTab ); + void DeleteTab( SCTAB nTab ); + + void ShiftCols(const ScDocument& rDoc, SCCOL nStartCol, sal_Int32 nColOffset); + void ShiftRows(const ScDocument& rDoc, SCROW nStartRow, sal_Int32 nRowOffset); + + // Generate envelopes if multimarked and fills the passed ScRange object with + // the smallest range that includes the marked area plus its envelopes. + void GetSelectionCover( ScRange& rRange ); + // Get top, bottom, left and right envelopes + const ScRangeList& GetTopEnvelope() const { return aTopEnvelope; } + const ScRangeList& GetBottomEnvelope() const { return aBottomEnvelope; } + const ScRangeList& GetLeftEnvelope() const { return aLeftEnvelope; } + const ScRangeList& GetRightEnvelope() const { return aRightEnvelope; } + + // iterators for table access + typedef std::set<SCTAB>::const_iterator const_iterator; + typedef std::set<SCTAB>::const_reverse_iterator const_reverse_iterator; + const_iterator begin() const { return maTabMarked.begin(); } + const_iterator end() const { return maTabMarked.end(); } + const_reverse_iterator rbegin() const { return maTabMarked.rbegin(); } +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/markmulti.hxx b/sc/inc/markmulti.hxx new file mode 100644 index 0000000000..9861342dc4 --- /dev/null +++ b/sc/inc/markmulti.hxx @@ -0,0 +1,92 @@ +/* -*- 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 "segmenttree.hxx" +#include "markarr.hxx" + +#include <vector> + +class ScRangeList; +struct ScSheetLimits; + +class SC_DLLPUBLIC ScMultiSel +{ + +private: + std::vector<ScMarkArray> aMultiSelContainer; + ScMarkArray aRowSel; + const ScSheetLimits& mrSheetLimits; + +friend class ScMultiSelIter; + +public: + ScMultiSel(ScSheetLimits const &); + ScMultiSel(const ScMultiSel& rMultiSel) = default; + ScMultiSel(ScMultiSel&& rMultiSel) = default; + + ScMultiSel& operator=(const ScMultiSel& rMultiSel); + ScMultiSel& operator=(ScMultiSel&& rMultiSel); + + SCCOL GetMultiSelectionCount() const; + bool HasMarks( SCCOL nCol ) const; + bool HasOneMark( SCCOL nCol, SCROW& rStartRow, SCROW& rEndRow ) const; + bool GetMark( SCCOL nCol, SCROW nRow ) const; + bool IsAllMarked( SCCOL nCol, SCROW nStartRow, SCROW nEndRow ) const; + bool HasEqualRowsMarked( SCCOL nCol1, SCCOL nCol2 ) const; + SCROW GetNextMarked( SCCOL nCol, SCROW nRow, bool bUp ) const; + // Returns the first column of the range [column,nLastCol] for which + // all those columns have equal marks. Value returned is not less than nMinCol. + SCCOL GetStartOfEqualColumns( SCCOL nLastCol, SCCOL nMinCol = 0 ) const; + void SetMarkArea( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCROW nEndRow, bool bMark ); + void Set( ScRangeList const & ); + bool IsRowMarked( SCROW nRow ) const; + bool IsRowRangeMarked( SCROW nStartRow, SCROW nEndRow ) const; + bool IsEmpty() const { return ( aMultiSelContainer.empty() && !aRowSel.HasMarks() ); } + ScMarkArray GetMarkArray( SCCOL nCol ) const; + void Clear(); + void MarkAllCols( SCROW nStartRow, SCROW nEndRow ); + bool HasAnyMarks() const; + void ShiftCols(SCCOL nStartCol, sal_Int32 nColOffset); + void ShiftRows(SCROW nStartRow, sal_Int32 nRowOffset); + + // For faster access from within ScMarkData, instead of creating + // ScMultiSelIter with ScFlatBoolRowSegments bottleneck. + const ScMarkArray& GetRowSelArray() const { return aRowSel; } + const ScMarkArray* GetMultiSelArray( SCCOL nCol ) const; +}; + +class ScMultiSelIter +{ + +private: + std::unique_ptr<ScFlatBoolRowSegments> pRowSegs; + ScMarkArrayIter aMarkArrayIter; + SCROW nNextSegmentStart; +public: + ScMultiSelIter( const ScMultiSel& rMultiSel, SCCOL nCol ); + + bool Next( SCROW& rTop, SCROW& rBottom ); + /** Only to be used by ScMultiSel::IsAllMarked() or otherwise sure that a + segment tree is actually used. */ + bool GetRangeData( SCROW nRow, ScFlatBoolRowSegments::RangeData& rRowRange ) const; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/math.hxx b/sc/inc/math.hxx new file mode 100644 index 0000000000..492e5d9144 --- /dev/null +++ b/sc/inc/math.hxx @@ -0,0 +1,70 @@ +/* -*- 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 <formula/errorcodes.hxx> + +namespace sc { + +/** Return fNumerator/fDenominator if fDenominator!=0 else #DIV/0! error coded + into double. + */ +inline double div( const double& fNumerator, const double& fDenominator ) +{ + return (fDenominator != 0.0) ? (fNumerator / fDenominator) : + CreateDoubleError( FormulaError::DivisionByZero); +} + +/** Return fNumerator/fDenominator if fDenominator!=0 else +-Infinity if + fNumerator!=0 or NaN if fNumerator==0. + + This allows to build/run with -fsanitize=float-divide-by-zero and have a + defined behavior for the otherwise undefined division by zero case ("If the + second operand of / or % is zero the behavior is undefined." + ([expr.mul]/4)). + + The Calc interpreter gracefully handles Infinity or NaN double values + encountered as interim or final results, using this function we can ensure + defined behavior where desired. + + Use where the double coded error creating div() is not wanted. + */ +inline double divide( const double& fNumerator, const double& fDenominator ) +{ + if (fDenominator == 0.0) + { + if (std::isfinite( fNumerator) && fNumerator != 0.0) + return std::signbit(fNumerator) ? -std::numeric_limits<double>::infinity() + : std::numeric_limits<double>::infinity(); + return std::numeric_limits<double>::quiet_NaN(); + } + return fNumerator / fDenominator; +} + +/** Return pow(fVal1,fVal2) with error handling. + + If an error was detected, a coded double error of + FormulaError::IllegalFPOperation is returned. + */ +double power( const double& fVal1, const double& fVal2 ); + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/matrixoperators.hxx b/sc/inc/matrixoperators.hxx new file mode 100644 index 0000000000..cd0295bb20 --- /dev/null +++ b/sc/inc/matrixoperators.hxx @@ -0,0 +1,68 @@ +/* -*- 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/. + */ + +#pragma once + + +#include <functional> +#include <utility> +#include <vector> +#include "kahan.hxx" + +namespace sc::op { + + +template<typename T, typename tRes> +struct Op_ +{ + const double mInitVal; + const T maOp; + Op_(double InitVal, T aOp): + mInitVal(InitVal), maOp(std::move(aOp)) + { + } + void operator()(tRes& rAccum, double fVal) const + { + maOp(rAccum, fVal); + } +}; + +using Op = Op_<std::function<void(double&, double)>, double>; +using kOp = Op_<std::function<void(KahanSum&, double)>, KahanSum>; + +void fkOpSum(KahanSum& rAccum, double fVal); +void fkOpSumSquare(KahanSum& rAccum, double fVal); + +extern kOp kOpSum; +extern kOp kOpSumSquare; +extern std::vector<kOp> kOpSumAndSumSquare; + +struct Sum +{ + static const double InitVal; + void operator()(KahanSum& rAccum, double fVal) const; +}; + +struct SumSquare +{ + static const double InitVal; + void operator()(KahanSum& rAccum, double fVal) const; +}; + +struct Product +{ + static const double InitVal; + void operator()(double& rAccum, double fVal) const; +}; + +} + + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/mid.h b/sc/inc/mid.h new file mode 100644 index 0000000000..614bcf91ee --- /dev/null +++ b/sc/inc/mid.h @@ -0,0 +1,30 @@ +/* -*- 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 . + */ + +#ifndef SC_MID_H +#define SC_MID_H + +#define MID_1 1 +#define MID_2 2 +#define MID_3 3 +#define MID_4 4 + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/miscuno.hxx b/sc/inc/miscuno.hxx new file mode 100644 index 0000000000..23289affbd --- /dev/null +++ b/sc/inc/miscuno.hxx @@ -0,0 +1,193 @@ +/* -*- 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 <vector> + +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/container/XNameAccess.hpp> +#include <com/sun/star/container/XEnumeration.hpp> +#include <com/sun/star/container/XIndexAccess.hpp> +#include <cppuhelper/implbase.hxx> +#include <cppuhelper/supportsservice.hxx> +#include <osl/diagnose.h> +#include "scdllapi.h" + +#define SC_SIMPLE_SERVICE_INFO_IMPL( ClassName, ClassNameAscii ) \ +OUString SAL_CALL ClassName::getImplementationName() \ +{ \ + return ClassNameAscii; \ +} \ +sal_Bool SAL_CALL ClassName::supportsService( const OUString& ServiceName ) \ +{ \ + return cppu::supportsService(this, ServiceName); \ +} + +#define SC_SIMPLE_SERVICE_INFO_NAME( ClassName, ServiceAscii ) \ +css::uno::Sequence< OUString > \ + SAL_CALL ClassName::getSupportedServiceNames() \ +{ \ + css::uno::Sequence< OUString > aRet { ServiceAscii }; \ + return aRet; \ +} + +// Place the old mistyped variant as first element so existing code can +// continue to ask aRet[0] if it doesn't iterate; new code can iterate over the +// sequence. This mostly should be used by supportsService() iterating anyway. +#define SC_SIMPLE_SERVICE_INFO_TYPO( ClassName, ServiceAscii, ServiceAsciiMistyped ) \ +css::uno::Sequence< OUString > \ + SAL_CALL ClassName::getSupportedServiceNames() \ +{ \ + css::uno::Sequence< OUString > aRet { ServiceAsciiMistyped, ServiceAscii }; \ + return aRet; \ +} + +#define SC_SIMPLE_SERVICE_INFO( ClassName, ClassNameAscii, ServiceAscii ) \ + SC_SIMPLE_SERVICE_INFO_IMPL( ClassName, ClassNameAscii ) \ + SC_SIMPLE_SERVICE_INFO_NAME( ClassName, ServiceAscii ) + +#define SC_SIMPLE_SERVICE_INFO_COMPAT( ClassName, ClassNameAscii, ServiceAscii, ServiceAsciiMistyped ) \ + SC_SIMPLE_SERVICE_INFO_IMPL( ClassName, ClassNameAscii ) \ + SC_SIMPLE_SERVICE_INFO_TYPO( ClassName, ServiceAscii, ServiceAsciiMistyped ) + + +#define SC_IMPL_DUMMY_PROPERTY_LISTENER( ClassName ) \ + void SAL_CALL ClassName::addPropertyChangeListener( const OUString&, \ + const uno::Reference<beans::XPropertyChangeListener>&) \ + { OSL_FAIL("not implemented"); } \ + void SAL_CALL ClassName::removePropertyChangeListener( const OUString&, \ + const uno::Reference<beans::XPropertyChangeListener>&) \ + { OSL_FAIL("not implemented"); } \ + void SAL_CALL ClassName::addVetoableChangeListener( const OUString&, \ + const uno::Reference<beans::XVetoableChangeListener>&) \ + { OSL_FAIL("not implemented"); } \ + void SAL_CALL ClassName::removeVetoableChangeListener( const OUString&, \ + const uno::Reference<beans::XVetoableChangeListener>&) \ + { OSL_FAIL("not implemented"); } + + +class ScIndexEnumeration final : public cppu::WeakImplHelper< + css::container::XEnumeration, + css::lang::XServiceInfo > +{ +private: + css::uno::Reference<css::container::XIndexAccess> xIndex; + OUString sServiceName; + sal_Int32 nPos; + +public: + ScIndexEnumeration(css::uno::Reference< + css::container::XIndexAccess> xInd, OUString aServiceName); + virtual ~ScIndexEnumeration() override; + + // XEnumeration + virtual sal_Bool SAL_CALL hasMoreElements() override; + virtual css::uno::Any SAL_CALL nextElement() override; + + // XServiceInfo + 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; +}; + +// new (uno 3) variant +class ScNameToIndexAccess final : public cppu::WeakImplHelper< + css::container::XIndexAccess, + css::lang::XServiceInfo > +{ +private: + css::uno::Reference<css::container::XNameAccess> xNameAccess; + css::uno::Sequence<OUString> aNames; + +public: + ScNameToIndexAccess( + css::uno::Reference< css::container::XNameAccess> xNameObj ); + virtual ~ScNameToIndexAccess() override; + + // XIndexAccess + virtual sal_Int32 SAL_CALL getCount( ) override; + virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override; + + // XElementAccess + virtual css::uno::Type SAL_CALL getElementType( ) override; + virtual sal_Bool SAL_CALL hasElements( ) override; + + // XServiceInfo + 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; +}; + +class SC_DLLPUBLIC ScUnoHelpFunctions +{ +public: + static bool GetBoolProperty( const css::uno::Reference< css::beans::XPropertySet>& xProp, + const OUString& rName, bool bDefault = false ); + static sal_Int16 GetShortProperty( const css::uno::Reference< css::beans::XPropertySet>& xProp, + const OUString& rName, sal_Int16 nDefault ); + static sal_Int32 GetLongProperty( const css::uno::Reference< css::beans::XPropertySet>& xProp, + const OUString& rName ); + template<typename EnumT> + static EnumT GetEnumProperty( const css::uno::Reference< css::beans::XPropertySet>& xProp, + const OUString& rName, EnumT nDefault ) + { return static_cast<EnumT>(GetEnumPropertyImpl(xProp, rName, static_cast<sal_Int32>(nDefault))); } + + static OUString GetStringProperty( + const css::uno::Reference<css::beans::XPropertySet>& xProp, + const OUString& rName, const OUString& rDefault ); + + static bool GetBoolFromAny( const css::uno::Any& aAny ); + static sal_Int16 GetInt16FromAny( const css::uno::Any& aAny ); + static sal_Int32 GetInt32FromAny( const css::uno::Any& aAny ); + static sal_Int32 GetEnumFromAny( const css::uno::Any& aAny ); + + static void SetOptionalPropertyValue( + const css::uno::Reference< css::beans::XPropertySet >& rPropSet, + const char* pPropName, const css::uno::Any& rVal ); + static void SetOptionalPropertyValue( + const css::uno::Reference< css::beans::XPropertySet >& rPropSet, + const OUString& rPropName, const css::uno::Any& rVal ); + + template<typename ValueType> + static void SetOptionalPropertyValue( + const css::uno::Reference< css::beans::XPropertySet >& rPropSet, + const char* pPropName, const ValueType& rVal ) + { + css::uno::Any any; + any <<= rVal; + SetOptionalPropertyValue(rPropSet, pPropName, any); + } + template<typename ValueType> + static void SetOptionalPropertyValue( + const css::uno::Reference< css::beans::XPropertySet >& rPropSet, + const OUString& rPropName, const ValueType& rVal ) + { + css::uno::Any any; + any <<= rVal; + SetOptionalPropertyValue(rPropSet, rPropName, any); + } + +private: + static sal_Int32 GetEnumPropertyImpl( const css::uno::Reference< css::beans::XPropertySet>& xProp, + const OUString& rName, sal_Int32 nDefault ); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/mtvcellfunc.hxx b/sc/inc/mtvcellfunc.hxx new file mode 100644 index 0000000000..89e41fb915 --- /dev/null +++ b/sc/inc/mtvcellfunc.hxx @@ -0,0 +1,191 @@ +/* -*- 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/. + */ + +#pragma once + +#include "mtvelements.hxx" +#include "mtvfunctions.hxx" + +class ScFormulaCell; + +namespace sc { + +template<typename Func> +void ProcessFormula(CellStoreType& rStore, Func& rFunc) +{ + FuncElseNoOp<size_t> aElse; + ProcessElements1<CellStoreType, formula_block, Func, FuncElseNoOp<size_t> >(rStore, rFunc, aElse); +} + +template<typename FuncElem> +typename CellStoreType::iterator +ProcessFormula( + const CellStoreType::iterator& it, CellStoreType& rStore, SCROW nRow1, SCROW nRow2, FuncElem& rFuncElem) +{ + FuncElseNoOp<size_t> aElse; + return ProcessElements1< + CellStoreType, formula_block, FuncElem, FuncElseNoOp<size_t> >(it, rStore, nRow1, nRow2, rFuncElem, aElse); +} + +/** + * Process formula cells found within specified row range. This function + * allows modifications of the states of the formula function objects. + */ +CellStoreType::iterator ProcessFormula( + const CellStoreType::iterator& it, CellStoreType& rStore, SCROW nRow1, SCROW nRow2, + std::function<void(size_t,ScFormulaCell*)> aFuncElem ); + +template<typename FuncElem, typename FuncElse> +typename CellStoreType::iterator +ProcessFormula( + const CellStoreType::iterator& it, CellStoreType& rStore, SCROW nRow1, SCROW nRow2, FuncElem& rFuncElem, FuncElse& rFuncElse) +{ + return ProcessElements1< + CellStoreType, formula_block, FuncElem, FuncElse>(it, rStore, nRow1, nRow2, rFuncElem, rFuncElse); +} + +template<typename Func> +CellStoreType::iterator +ProcessEditText(const CellStoreType::iterator& itPos, CellStoreType& rStore, SCROW nRow1, SCROW nRow2, Func& rFunc) +{ + FuncElseNoOp<size_t> aElse; + return ProcessElements1<CellStoreType, edittext_block, Func, FuncElseNoOp<size_t> >( + itPos, rStore, nRow1, nRow2, rFunc, aElse); +} + +template<typename Func> +void ParseFormula( + const CellStoreType& rStore, Func& rFunc) +{ + FuncElseNoOp<size_t> aElse; + ParseElements1<CellStoreType, formula_block, Func, FuncElseNoOp<size_t> >(rStore, rFunc, aElse); +} + +template<typename Func> +typename CellStoreType::const_iterator +ParseFormula( + const CellStoreType::const_iterator& itPos, const CellStoreType& rStore, + SCROW nStart, SCROW nEnd, Func& rFunc) +{ + FuncElseNoOp<size_t> aElse; + return ParseElements1<CellStoreType, formula_block, Func, FuncElseNoOp<size_t> >( + itPos, rStore, nStart, nEnd, rFunc, aElse); +} + +template<typename FuncElem, typename FuncElse> +typename CellStoreType::const_iterator +ParseAll( + const typename CellStoreType::const_iterator& itPos, const CellStoreType& rCells, + SCROW nRow1, SCROW nRow2, FuncElem& rFuncElem, FuncElse& rFuncElse) +{ + return ParseElements4<CellStoreType, + numeric_block, string_block, edittext_block, formula_block, + FuncElem, FuncElse>( + itPos, rCells, nRow1, nRow2, rFuncElem, rFuncElse); +} + +template<typename Func> +typename CellStoreType::const_iterator +ParseAllNonEmpty( + const typename CellStoreType::const_iterator& itPos, const CellStoreType& rCells, + SCROW nRow1, SCROW nRow2, Func& rFunc) +{ + FuncElseNoOp<size_t> aElse; + return ParseElements4<CellStoreType, + numeric_block, string_block, edittext_block, formula_block, + Func, FuncElseNoOp<size_t> >( + itPos, rCells, nRow1, nRow2, rFunc, aElse); +} + +template<typename Func> +typename CellStoreType::const_iterator +ParseFormulaNumeric( + const CellStoreType::const_iterator& itPos, const CellStoreType& rCells, + SCROW nRow1, SCROW nRow2, Func& rFunc) +{ + FuncElseNoOp<size_t> aElse; + return ParseElements2<CellStoreType, + numeric_block, formula_block, Func, FuncElseNoOp<size_t> >( + itPos, rCells, nRow1, nRow2, rFunc, aElse); +} + +template<typename Func> +void ProcessFormulaEditText(CellStoreType& rStore, Func& rFunc) +{ + // Walk backwards through the data - this helps when the FuncElem will be deleting + // stuff, so we don't continually move block data around. + FuncElseNoOp<size_t> aElse; + ProcessElements2Reverse<CellStoreType, edittext_block, formula_block, Func, FuncElseNoOp<size_t> >(rStore, rFunc, aElse); +} + +template<typename Func> +std::pair<CellStoreType::const_iterator, size_t> +FindFormula(const CellStoreType& rStore, SCROW nRow1, SCROW nRow2, Func& rFunc) +{ + typedef std::pair<size_t,bool> ElseRetType; + FuncElseNoOp<size_t, ElseRetType> aElse; + return FindElement1<CellStoreType, formula_block, Func, FuncElseNoOp<size_t, ElseRetType> >(rStore, nRow1, nRow2, rFunc, aElse); +} + +template<typename Func> +std::pair<CellStoreType::const_iterator, size_t> +FindFormulaEditText(const CellStoreType& rStore, SCROW nRow1, SCROW nRow2, Func& rFunc) +{ + return FindElement2<CellStoreType, edittext_block, formula_block, Func, Func>(rStore, nRow1, nRow2, rFunc, rFunc); +} + +template<typename Func> +void ProcessNote(CellNoteStoreType& rStore, Func& rFunc) +{ + FuncElseNoOp<size_t> aElse; + ProcessElements1<CellNoteStoreType, cellnote_block, Func, FuncElseNoOp<size_t> >(rStore, rFunc, aElse); +} + +template<typename Func> +typename CellNoteStoreType::const_iterator +ParseNote( + const CellNoteStoreType::const_iterator& itPos, const CellNoteStoreType& rStore, + SCROW nStart, SCROW nEnd, Func& rFunc) +{ + FuncElseNoOp<size_t> aElse; + return ParseElements1<CellNoteStoreType, cellnote_block, Func, FuncElseNoOp<size_t> >( + itPos, rStore, nStart, nEnd, rFunc, aElse); +} + +template<typename FuncElem> +typename CellNoteStoreType::iterator +ProcessNote( + const CellNoteStoreType::iterator& it, CellNoteStoreType& rStore, SCROW nRow1, SCROW nRow2, FuncElem& rFuncElem) +{ + FuncElseNoOp<size_t> aElse; + return ProcessElements1< + CellNoteStoreType, cellnote_block, FuncElem, FuncElseNoOp<size_t> >(it, rStore, nRow1, nRow2, rFuncElem, aElse); +} + +template<typename FuncElem> +typename BroadcasterStoreType::iterator +ProcessBroadcaster( + const BroadcasterStoreType::iterator& it, BroadcasterStoreType& rStore, SCROW nRow1, SCROW nRow2, FuncElem& rFuncElem) +{ + FuncElseNoOp<size_t> aElse; + return ProcessElements1< + BroadcasterStoreType, broadcaster_block, FuncElem, FuncElseNoOp<size_t> >(it, rStore, nRow1, nRow2, rFuncElem, aElse); +} + +template<typename Functor> +typename SparklineStoreType::const_iterator +ParseSparkline(const SparklineStoreType::const_iterator& itPos, const SparklineStoreType& rStore, SCROW nStart, SCROW nEnd, Functor& rFunctor) +{ + FuncElseNoOp<size_t> aElse; + return ParseElements1<SparklineStoreType, sparkline_block, Functor, FuncElseNoOp<size_t> >(itPos, rStore, nStart, nEnd, rFunctor, aElse); +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/mtvelements.hxx b/sc/inc/mtvelements.hxx new file mode 100644 index 0000000000..156346a945 --- /dev/null +++ b/sc/inc/mtvelements.hxx @@ -0,0 +1,216 @@ +/* -*- 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/. + */ + +#pragma once + +#include "formulacell.hxx" +#include <svl/broadcast.hxx> +#include <svl/sharedstring.hxx> +#include <editeng/editobj.hxx> +#include "calcmacros.hxx" +#include "postit.hxx" +#include "SparklineCell.hxx" +#include "celltextattr.hxx" + +#if DEBUG_COLUMN_STORAGE +#ifdef NDEBUG +#undef NDEBUG +#endif +#define MDDS_MULTI_TYPE_VECTOR_DEBUG 1 +#endif + +#include <mdds/multi_type_vector/macro.hpp> +#include <mdds/multi_type_vector/soa/main.hpp> +#include <mdds/multi_type_vector/block_funcs.hpp> + +#include <unordered_map> +#include <memory> +#include <mutex> + +class ScDocument; +class ScColumn; +struct ScRefCellValue; + +namespace sc { + +/// Custom element type IDs for multi_type_vector. + +const mdds::mtv::element_t element_type_broadcaster = mdds::mtv::element_type_user_start; +const mdds::mtv::element_t element_type_celltextattr = mdds::mtv::element_type_user_start + 1; + +const mdds::mtv::element_t element_type_string = mdds::mtv::element_type_user_start + 2; +const mdds::mtv::element_t element_type_edittext = mdds::mtv::element_type_user_start + 3; +const mdds::mtv::element_t element_type_formula = mdds::mtv::element_type_user_start + 4; + +const mdds::mtv::element_t element_type_cellnote = mdds::mtv::element_type_user_start + 5; +const mdds::mtv::element_t element_type_sparkline = mdds::mtv::element_type_user_start + 6; + +/// Mapped standard element types (for convenience). +const mdds::mtv::element_t element_type_numeric = mdds::mtv::element_type_double; +const mdds::mtv::element_t element_type_empty = mdds::mtv::element_type_empty; +const mdds::mtv::element_t element_type_uint16 = mdds::mtv::element_type_uint16; + +/// Custom element blocks. + +typedef mdds::mtv::noncopyable_managed_element_block<element_type_sparkline, sc::SparklineCell> sparkline_block; +typedef mdds::mtv::noncopyable_managed_element_block<element_type_cellnote, ScPostIt> cellnote_block; +typedef mdds::mtv::noncopyable_managed_element_block<element_type_broadcaster, SvtBroadcaster> broadcaster_block; +typedef mdds::mtv::default_element_block<element_type_celltextattr, CellTextAttr> celltextattr_block; +typedef mdds::mtv::default_element_block<element_type_string, svl::SharedString> string_block; +typedef mdds::mtv::noncopyable_managed_element_block<element_type_edittext, EditTextObject> edittext_block; +typedef mdds::mtv::noncopyable_managed_element_block<element_type_formula, ScFormulaCell> formula_block; + +/// Mapped standard element blocks (for convenience). +typedef mdds::mtv::double_element_block numeric_block; +typedef mdds::mtv::uint16_element_block uint16_block; + +} // end sc namespace + +/// CAUTION! The following defines must be in the same namespace as the respective type. +/// For example sc types like sc::CellTextAttr, ScFormulaCell in global namespace. +namespace sc { +MDDS_MTV_DEFINE_ELEMENT_CALLBACKS(CellTextAttr, element_type_celltextattr, CellTextAttr(), celltextattr_block) +MDDS_MTV_DEFINE_ELEMENT_CALLBACKS_PTR(SparklineCell, sc::element_type_sparkline, nullptr, sc::sparkline_block) +} + +/// These need to be in global namespace just like their respective types are. +MDDS_MTV_DEFINE_ELEMENT_CALLBACKS_PTR(ScPostIt, sc::element_type_cellnote, nullptr, sc::cellnote_block) +MDDS_MTV_DEFINE_ELEMENT_CALLBACKS_PTR(SvtBroadcaster, sc::element_type_broadcaster, nullptr, sc::broadcaster_block) +MDDS_MTV_DEFINE_ELEMENT_CALLBACKS_PTR(ScFormulaCell, sc::element_type_formula, nullptr, sc::formula_block) +MDDS_MTV_DEFINE_ELEMENT_CALLBACKS_PTR(EditTextObject, sc::element_type_edittext, nullptr, sc::edittext_block) + +namespace svl { +MDDS_MTV_DEFINE_ELEMENT_CALLBACKS(SharedString, sc::element_type_string, SharedString(), sc::string_block) +} + +namespace sc { + +class CellStoreEvent +{ + ScColumn* mpCol; +public: + CellStoreEvent(); + CellStoreEvent(ScColumn* pCol); + + void element_block_acquired(const mdds::mtv::base_element_block* block); + void element_block_released(const mdds::mtv::base_element_block* block); + + /** Stop processing events. */ + void stop(); + + void swap(CellStoreEvent& other); + + const ScColumn* getColumn() const; +}; + +struct SparklineTraits : public mdds::mtv::default_traits +{ + using block_funcs = mdds::mtv::element_block_funcs<sc::sparkline_block>; +}; + +struct CellNodeTraits : public mdds::mtv::default_traits +{ + using block_funcs = mdds::mtv::element_block_funcs<sc::cellnote_block>; +}; + +struct BroadcasterTraits : public mdds::mtv::default_traits +{ + using block_funcs = mdds::mtv::element_block_funcs<sc::broadcaster_block>; +}; + +struct CellTextAttrTraits : public mdds::mtv::default_traits +{ + using block_funcs = mdds::mtv::element_block_funcs<sc::celltextattr_block>; +}; + +struct CellStoreTraits : public mdds::mtv::default_traits +{ + using event_func = CellStoreEvent; + using block_funcs = mdds::mtv::element_block_funcs< + numeric_block, sc::string_block, sc::edittext_block, sc::formula_block>; +}; + +/// Sparkline container +typedef mdds::mtv::soa::multi_type_vector<SparklineTraits> SparklineStoreType; + +/// Cell note container +typedef mdds::mtv::soa::multi_type_vector<CellNodeTraits> CellNoteStoreType; + +/// Broadcaster storage container +typedef mdds::mtv::soa::multi_type_vector<BroadcasterTraits> BroadcasterStoreType; + +/// Cell text attribute container. +typedef mdds::mtv::soa::multi_type_vector<CellTextAttrTraits> CellTextAttrStoreType; + +/// Cell container +typedef mdds::mtv::soa::multi_type_vector<CellStoreTraits> CellStoreType; + +/** + * Store position data for column array storage. + */ +struct ColumnBlockPosition +{ + CellNoteStoreType::iterator miCellNotePos; + SparklineStoreType::iterator miSparklinePos; + BroadcasterStoreType::iterator miBroadcasterPos; + CellTextAttrStoreType::iterator miCellTextAttrPos; + CellStoreType::iterator miCellPos; + + ColumnBlockPosition(): miCellPos() {} +}; + +struct ColumnBlockConstPosition +{ + CellNoteStoreType::const_iterator miCellNotePos; + SparklineStoreType::const_iterator miSparklinePos; + CellTextAttrStoreType::const_iterator miCellTextAttrPos; + CellStoreType::const_iterator miCellPos; + + ColumnBlockConstPosition(): miCellPos() {} +}; + +class ColumnBlockPositionSet +{ + typedef std::unordered_map<SCCOL, ColumnBlockPosition> ColumnsType; + typedef std::unordered_map<SCTAB, ColumnsType> TablesType; + + ScDocument& mrDoc; + TablesType maTables; + std::mutex maMtxTables; + +public: + ColumnBlockPositionSet(ScDocument& rDoc); + + ColumnBlockPosition* getBlockPosition(SCTAB nTab, SCCOL nCol); + + void clear(); +}; + +/** + * Set of column block positions only for one table. + */ +class TableColumnBlockPositionSet +{ + struct Impl; + std::unique_ptr<Impl> mpImpl; + +public: + TableColumnBlockPositionSet( ScDocument& rDoc, SCTAB nTab ); + TableColumnBlockPositionSet(TableColumnBlockPositionSet&& rOther) noexcept; + ~TableColumnBlockPositionSet(); + + ColumnBlockPosition* getBlockPosition( SCCOL nCol ); + void invalidate(); // discards cached positions +}; + +ScRefCellValue toRefCell( const sc::CellStoreType::const_iterator& itPos, size_t nOffset ); + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/mtvfunctions.hxx b/sc/inc/mtvfunctions.hxx new file mode 100644 index 0000000000..9fe394faff --- /dev/null +++ b/sc/inc/mtvfunctions.hxx @@ -0,0 +1,557 @@ +/* -*- 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/. + */ + +#pragma once + +#include <cstdlib> +#include <mdds/multi_type_vector/types.hpp> + +namespace sc { + +template<typename SizeT, typename Ret = bool> +struct FuncElseNoOp +{ + Ret operator() (mdds::mtv::element_t, SizeT, SizeT) const + { + return Ret(); + } +}; + +template<typename FuncElem, typename Elem> +struct FuncNotElem +{ + FuncElem& func; + FuncNotElem(FuncElem& f) : func(f) {} + bool operator() (size_t s, Elem elem) const + { + return !func(s, elem); + } +}; + +/** + * Generic algorithm to parse blocks of multi_type_vector either partially + * or fully. + */ +template<typename StoreT, typename Func> +typename StoreT::const_iterator +ParseBlock( + const typename StoreT::const_iterator& itPos, const StoreT& rStore, Func& rFunc, + typename StoreT::size_type nStart, typename StoreT::size_type nEnd) +{ + typedef std::pair<typename StoreT::const_iterator, typename StoreT::size_type> PositionType; + + PositionType aPos = rStore.position(itPos, nStart); + typename StoreT::const_iterator it = aPos.first; + typename StoreT::size_type nOffset = aPos.second; + typename StoreT::size_type nDataSize = 0; + typename StoreT::size_type nTopRow = nStart; + + for (; it != rStore.end() && nTopRow <= nEnd; ++it, nOffset = 0, nTopRow += nDataSize) + { + bool bLastBlock = false; + nDataSize = it->size - nOffset; + if (nTopRow + nDataSize - 1 > nEnd) + { + // Truncate the block. + nDataSize = nEnd - nTopRow + 1; + bLastBlock = true; + } + + rFunc(*it, nOffset, nDataSize); + + if (bLastBlock) + break; + } + + return it; +} + +/** + * Non-const variant of the above function. TODO: Find a way to merge these + * two in an elegant way. + */ +template<typename StoreT, typename Func> +typename StoreT::iterator +ProcessBlock(const typename StoreT::iterator& itPos, StoreT& rStore, Func& rFunc, typename StoreT::size_type nStart, typename StoreT::size_type nEnd) +{ + typedef std::pair<typename StoreT::iterator, typename StoreT::size_type> PositionType; + + PositionType aPos = rStore.position(itPos, nStart); + typename StoreT::iterator it = aPos.first; + typename StoreT::size_type nOffset = aPos.second; + typename StoreT::size_type nDataSize = 0; + typename StoreT::size_type nCurRow = nStart; + + for (; it != rStore.end() && nCurRow <= nEnd; ++it, nOffset = 0, nCurRow += nDataSize) + { + bool bLastBlock = false; + nDataSize = it->size - nOffset; + if (nCurRow + nDataSize - 1 > nEnd) + { + // Truncate the block. + nDataSize = nEnd - nCurRow + 1; + bLastBlock = true; + } + + rFunc(*it, nOffset, nDataSize); + + if (bLastBlock) + break; + } + + return it; +} + +template<typename BlkT, typename ItrT, typename NodeT, typename FuncElem> +void EachElem(NodeT& rNode, size_t nOffset, size_t nDataSize, FuncElem& rFuncElem) +{ + ItrT it = BlkT::begin(*rNode.data); + std::advance(it, nOffset); + ItrT itEnd = it; + std::advance(itEnd, nDataSize); + size_t nRow = rNode.position + nOffset; + for (; it != itEnd; ++it, ++nRow) + rFuncElem(nRow, *it); +} + +template<typename BlkT, typename ItrT, typename NodeT, typename FuncElem> +void EachElem(NodeT& rNode, FuncElem& rFuncElem) +{ + auto it = BlkT::begin(*rNode.data); + auto itEnd = BlkT::end(*rNode.data); + size_t nRow = rNode.position; + for (; it != itEnd; ++it, ++nRow) + rFuncElem(nRow, *it); +} + +template<typename BlkT, typename ItrT, typename NodeT, typename FuncElem> +void EachElemReverse(NodeT& rNode, FuncElem& rFuncElem) +{ + auto it = BlkT::rbegin(*rNode.data); + auto itEnd = BlkT::rend(*rNode.data); + size_t nRow = rNode.position; + for (; it != itEnd; ++it, ++nRow) + rFuncElem(nRow, *it); +} + +template<typename BlkT, typename StoreT, typename FuncElem> +std::pair<typename StoreT::const_iterator, size_t> +CheckElem( + const StoreT& rStore, const typename StoreT::const_iterator& it, size_t nOffset, size_t nDataSize, + FuncElem& rFuncElem) +{ + typedef std::pair<typename StoreT::const_iterator, size_t> PositionType; + + typename BlkT::const_iterator itData = BlkT::begin(*it->data); + std::advance(itData, nOffset); + typename BlkT::const_iterator itDataEnd = itData; + std::advance(itDataEnd, nDataSize); + size_t nTopRow = it->position + nOffset; + size_t nRow = nTopRow; + for (; itData != itDataEnd; ++itData, ++nRow) + { + if (rFuncElem(nRow, *itData)) + return PositionType(it, nRow - it->position); + } + + return PositionType(rStore.end(), 0); +} + +template<typename StoreT, typename BlkT, typename FuncElem, typename FuncElse> +void ParseElements1(const StoreT& rStore, FuncElem& rFuncElem, FuncElse& rFuncElse) +{ + typename StoreT::size_type nTopRow = 0, nDataSize = 0; + typename StoreT::const_iterator it = rStore.begin(), itEnd = rStore.end(); + for (; it != itEnd; ++it, nTopRow += nDataSize) + { + nDataSize = it->size; + if (it->type != BlkT::block_type) + { + rFuncElse(it->type, nTopRow, nDataSize); + continue; + } + + EachElem<BlkT, typename BlkT::const_iterator>(*it, rFuncElem); + } +} + +template<typename StoreT, typename BlkT, typename FuncElem, typename FuncElse> +typename StoreT::const_iterator +ParseElements1( + const typename StoreT::const_iterator& itPos, const StoreT& rStore, + typename StoreT::size_type nStart, typename StoreT::size_type nEnd, + FuncElem& rFuncElem, FuncElse& rFuncElse) +{ + typedef std::pair<typename StoreT::const_iterator, typename StoreT::size_type> PositionType; + + PositionType aPos = rStore.position(itPos, nStart); + typename StoreT::const_iterator it = aPos.first; + typename StoreT::size_type nOffset = aPos.second; + typename StoreT::size_type nDataSize = 0; + typename StoreT::size_type nTopRow = nStart; + + for (; it != rStore.end() && nTopRow <= nEnd; ++it, nOffset = 0, nTopRow += nDataSize) + { + bool bLastBlock = false; + nDataSize = it->size - nOffset; + if (nTopRow + nDataSize - 1 > nEnd) + { + // Truncate the block. + nDataSize = nEnd - nTopRow + 1; + bLastBlock = true; + } + + if (it->type == BlkT::block_type) + EachElem<BlkT, typename BlkT::const_iterator>(*it, nOffset, nDataSize, rFuncElem); + else + rFuncElse(it->type, nTopRow, nDataSize); + + if (bLastBlock) + break; + } + + return it; +}; + +template<typename StoreT, typename Blk1, typename Blk2, typename FuncElem, typename FuncElse> +typename StoreT::const_iterator +ParseElements2( + const typename StoreT::const_iterator& itPos, const StoreT& rStore, typename StoreT::size_type nStart, typename StoreT::size_type nEnd, + FuncElem& rFuncElem, FuncElse& rFuncElse) +{ + typedef std::pair<typename StoreT::const_iterator, typename StoreT::size_type> PositionType; + + PositionType aPos = rStore.position(itPos, nStart); + typename StoreT::const_iterator it = aPos.first; + typename StoreT::size_type nOffset = aPos.second; + typename StoreT::size_type nDataSize = 0; + typename StoreT::size_type nTopRow = nStart; + + for (; it != rStore.end() && nTopRow <= nEnd; ++it, nOffset = 0, nTopRow += nDataSize) + { + bool bLastBlock = false; + nDataSize = it->size - nOffset; + if (nTopRow + nDataSize - 1 > nEnd) + { + // Truncate the block. + nDataSize = nEnd - nTopRow + 1; + bLastBlock = true; + } + + switch (it->type) + { + case Blk1::block_type: + EachElem<Blk1, typename Blk1::const_iterator>(*it, nOffset, nDataSize, rFuncElem); + break; + case Blk2::block_type: + EachElem<Blk2, typename Blk2::const_iterator>(*it, nOffset, nDataSize, rFuncElem); + break; + default: + rFuncElse(it->type, nTopRow, nDataSize); + } + + if (bLastBlock) + break; + } + + return it; +} + +template<typename StoreT, typename Blk1, typename Blk2, typename Blk3, typename Blk4, typename FuncElem, typename FuncElse> +typename StoreT::const_iterator +ParseElements4( + const typename StoreT::const_iterator& itPos, const StoreT& rStore, typename StoreT::size_type nStart, typename StoreT::size_type nEnd, + FuncElem& rFuncElem, FuncElse& rFuncElse) +{ + typedef std::pair<typename StoreT::const_iterator, typename StoreT::size_type> PositionType; + + PositionType aPos = rStore.position(itPos, nStart); + typename StoreT::const_iterator it = aPos.first; + typename StoreT::size_type nOffset = aPos.second; + typename StoreT::size_type nDataSize = 0; + typename StoreT::size_type nTopRow = nStart; + + for (; it != rStore.end() && nTopRow <= nEnd; ++it, nOffset = 0, nTopRow += nDataSize) + { + bool bLastBlock = false; + nDataSize = it->size - nOffset; + if (nTopRow + nDataSize - 1 > nEnd) + { + // Truncate the block. + nDataSize = nEnd - nTopRow + 1; + bLastBlock = true; + } + + switch (it->type) + { + case Blk1::block_type: + EachElem<Blk1, typename Blk1::const_iterator>(*it, nOffset, nDataSize, rFuncElem); + break; + case Blk2::block_type: + EachElem<Blk2, typename Blk2::const_iterator>(*it, nOffset, nDataSize, rFuncElem); + break; + case Blk3::block_type: + EachElem<Blk3, typename Blk3::const_iterator>(*it, nOffset, nDataSize, rFuncElem); + break; + case Blk4::block_type: + EachElem<Blk4, typename Blk4::const_iterator>(*it, nOffset, nDataSize, rFuncElem); + break; + default: + rFuncElse(it->type, nTopRow, nDataSize); + } + + if (bLastBlock) + break; + } + + return it; +} + +template<typename StoreT, typename BlkT, typename FuncElem, typename FuncElse> +void ProcessElements1(StoreT& rStore, FuncElem& rFuncElem, FuncElse& rFuncElse) +{ + typename StoreT::size_type nTopRow = 0, nDataSize = 0; + typename StoreT::iterator it = rStore.begin(), itEnd = rStore.end(); + for (; it != itEnd; ++it, nTopRow += nDataSize) + { + nDataSize = it->size; + if (it->type != BlkT::block_type) + { + rFuncElse(it->type, nTopRow, nDataSize); + continue; + } + + EachElem<BlkT, typename BlkT::iterator>(*it, rFuncElem); + } +} + +/** + * This variant specifies start and end positions. + */ +template<typename StoreT, typename BlkT, typename FuncElem, typename FuncElse> +typename StoreT::iterator +ProcessElements1( + const typename StoreT::iterator& itPos, StoreT& rStore, + typename StoreT::size_type nStart, typename StoreT::size_type nEnd, + FuncElem& rFuncElem, FuncElse& rFuncElse) +{ + typedef std::pair<typename StoreT::iterator, typename StoreT::size_type> PositionType; + + PositionType aPos = rStore.position(itPos, nStart); + typename StoreT::iterator it = aPos.first; + typename StoreT::size_type nOffset = aPos.second; + typename StoreT::size_type nDataSize = 0; + typename StoreT::size_type nTopRow = nStart; + + for (; it != rStore.end() && nTopRow <= nEnd; ++it, nOffset = 0, nTopRow += nDataSize) + { + bool bLastBlock = false; + nDataSize = it->size - nOffset; + if (nTopRow + nDataSize - 1 > nEnd) + { + // Truncate the block. + nDataSize = nEnd - nTopRow + 1; + bLastBlock = true; + } + + if (it->type == BlkT::block_type) + EachElem<BlkT, typename BlkT::iterator>(*it, nOffset, nDataSize, rFuncElem); + else + rFuncElse(it->type, nTopRow, nDataSize); + + if (bLastBlock) + break; + } + + return it; +}; + +template<typename StoreT, typename Blk1, typename Blk2, typename FuncElem, typename FuncElse> +void ProcessElements2(StoreT& rStore, FuncElem& rFuncElem, FuncElse& rFuncElse) +{ + typename StoreT::size_type nTopRow = 0, nDataSize = 0; + typename StoreT::iterator it = rStore.begin(), itEnd = rStore.end(); + for (; it != itEnd; ++it, nTopRow += nDataSize) + { + nDataSize = it->size; + switch (it->type) + { + case Blk1::block_type: + EachElem<Blk1, typename Blk1::iterator>(*it, rFuncElem); + break; + case Blk2::block_type: + EachElem<Blk2, typename Blk2::iterator>(*it, rFuncElem); + break; + default: + rFuncElse(it->type, nTopRow, nDataSize); + } + } +} + +template<typename StoreT, typename Blk1, typename Blk2, typename FuncElem, typename FuncElse> +void ProcessElements2Reverse(StoreT& rStore, FuncElem& rFuncElem, FuncElse& rFuncElse) +{ + typename StoreT::size_type nTopRow = 0, nDataSize = 0; + typename StoreT::iterator it = rStore.begin(), itEnd = rStore.end(); + for (; it != itEnd; ++it, nTopRow += nDataSize) + { + nDataSize = it->size; + switch (it->type) + { + case Blk1::block_type: + EachElemReverse<Blk1, typename Blk1::iterator>(*it, rFuncElem); + break; + case Blk2::block_type: + EachElemReverse<Blk2, typename Blk2::iterator>(*it, rFuncElem); + break; + default: + rFuncElse(it->type, nTopRow, nDataSize); + } + } +} + +template<typename StoreT, typename Blk1, typename FuncElem, typename FuncElse> +std::pair<typename StoreT::const_iterator, typename StoreT::size_type> +FindElement1( + const StoreT& rStore, typename StoreT::size_type nStart, typename StoreT::size_type nEnd, + FuncElem& rFuncElem, FuncElse& rFuncElse) +{ + typedef std::pair<typename StoreT::const_iterator, typename StoreT::size_type> PositionType; + typedef std::pair<typename StoreT::size_type, bool> ElseRetType; + + PositionType aPos = rStore.position(nStart); + typename StoreT::const_iterator it = aPos.first; + typename StoreT::size_type nOffset = aPos.second; + typename StoreT::size_type nDataSize = 0; + typename StoreT::size_type nTopRow = nStart; + + for (; it != rStore.end() && nTopRow <= nEnd; ++it, nOffset = 0, nTopRow += nDataSize) + { + bool bLastBlock = false; + nDataSize = it->size - nOffset; + if (nTopRow + nDataSize - 1 > nEnd) + { + // Truncate the block. + nDataSize = nEnd - nTopRow + 1; + bLastBlock = true; + } + + switch (it->type) + { + case Blk1::block_type: + { + PositionType aRet = CheckElem<Blk1>(rStore, it, nOffset, nDataSize, rFuncElem); + if (aRet.first != rStore.end()) + return aRet; + } + break; + default: + { + ElseRetType aRet = rFuncElse(it->type, nTopRow, nDataSize); + if (aRet.second) + return PositionType(it, aRet.first); + } + } + + if (bLastBlock) + break; + } + + return PositionType(rStore.end(), 0); +} + +template<typename StoreT, typename Blk1, typename Blk2, typename FuncElem, typename FuncElse> +std::pair<typename StoreT::const_iterator, typename StoreT::size_type> +FindElement2( + const StoreT& rStore, typename StoreT::size_type nStart, typename StoreT::size_type nEnd, + FuncElem& rFuncElem, FuncElse& rFuncElse) +{ + typedef std::pair<typename StoreT::const_iterator, typename StoreT::size_type> PositionType; + typedef std::pair<typename StoreT::size_type, bool> ElseRetType; + + PositionType aPos = rStore.position(nStart); + typename StoreT::const_iterator it = aPos.first; + typename StoreT::size_type nOffset = aPos.second; + typename StoreT::size_type nDataSize = 0; + typename StoreT::size_type nTopRow = nStart; + + for (; it != rStore.end() && nTopRow <= nEnd; ++it, nOffset = 0, nTopRow += nDataSize) + { + bool bLastBlock = false; + nDataSize = it->size - nOffset; + if (nTopRow + nDataSize - 1 > nEnd) + { + // Truncate the block. + nDataSize = nEnd - nTopRow + 1; + bLastBlock = true; + } + + switch (it->type) + { + case Blk1::block_type: + { + PositionType aRet = CheckElem<Blk1>(rStore, it, nOffset, nDataSize, rFuncElem); + if (aRet.first != rStore.end()) + return aRet; + } + break; + case Blk2::block_type: + { + PositionType aRet = CheckElem<Blk2>(rStore, it, nOffset, nDataSize, rFuncElem); + if (aRet.first != rStore.end()) + return aRet; + } + break; + default: + { + ElseRetType aRet = rFuncElse(*it, nOffset, nDataSize); + if (aRet.second) + return PositionType(it, aRet.first); + } + } + + if (bLastBlock) + break; + } + + return PositionType(rStore.end(), 0); +} + +// Efficiently set all elements for which the predicate returns true as empty. +template<typename Blk1, typename StoreT, typename FuncElem> +void SetElementsToEmpty1( + StoreT& rStore, FuncElem& rFuncElem) +{ + typedef std::pair<typename StoreT::const_iterator, typename StoreT::size_type> PositionType; + + for (typename StoreT::iterator it = rStore.begin(); it != rStore.end(); ++it) + { + if (it->type == Blk1::block_type) + { + PositionType firstToEmpty = CheckElem<Blk1>(rStore, it, 0, it->size, rFuncElem); + if (firstToEmpty.first != rStore.end()) + { + typename StoreT::size_type nFirstOffset = firstToEmpty.second; + typename StoreT::size_type nRemainingDataSize = it->size - nFirstOffset; + FuncNotElem<FuncElem, typename Blk1::value_type> notFuncElem(rFuncElem); + PositionType lastToEmpty = CheckElem<Blk1>(rStore, it, nFirstOffset, nRemainingDataSize, + notFuncElem); + typename StoreT::size_type nLastOffset = lastToEmpty.first != rStore.end() + ? lastToEmpty.second - 1 : it->size - 1; + it = rStore.set_empty(it, it->position + nFirstOffset, it->position + nLastOffset); + // The returned iterator points to the empty elements block. + assert(it->type == sc::element_type_empty); + } + } + } +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/nameuno.hxx b/sc/inc/nameuno.hxx new file mode 100644 index 0000000000..ee37dc365d --- /dev/null +++ b/sc/inc/nameuno.hxx @@ -0,0 +1,314 @@ +/* -*- 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 <svl/lstner.hxx> +#include "address.hxx" +#include "rangenam.hxx" +#include <formula/grammar.hxx> +#include <com/sun/star/sheet/XLabelRange.hpp> +#include <com/sun/star/sheet/XLabelRanges.hpp> +#include <com/sun/star/sheet/XCellRangeReferrer.hpp> +#include <com/sun/star/sheet/XNamedRange.hpp> +#include <com/sun/star/sheet/XFormulaTokens.hpp> +#include <com/sun/star/sheet/XNamedRanges.hpp> +#include <com/sun/star/container/XEnumerationAccess.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/document/XActionLockable.hpp> +#include <cppuhelper/implbase.hxx> +#include <rtl/ref.hxx> + +namespace com::sun::star::container { class XNamed; } + +class ScDocShell; +class ScNamedRangesObj; + +class SC_DLLPUBLIC ScNamedRangeObj final : public ::cppu::WeakImplHelper< + css::sheet::XNamedRange, + css::sheet::XFormulaTokens, + css::sheet::XCellRangeReferrer, + css::beans::XPropertySet, + css::lang::XServiceInfo >, + public SfxListener +{ +private: + rtl::Reference< ScNamedRangesObj > mxParent; + ScDocShell* pDocShell; + OUString aName; + css::uno::Reference< css::container::XNamed > mxSheet; + +private: +friend class ScVbaName; + ScRangeData* GetRangeData_Impl(); + void Modify_Impl( const OUString* pNewName, + const ScTokenArray* pNewTokens, const OUString* pNewContent, + const ScAddress* pNewPos, const ScRangeData::Type* pNewType, + const formula::FormulaGrammar::Grammar eGrammar ); + SCTAB GetTab_Impl(); + +public: + ScNamedRangeObj( rtl::Reference< ScNamedRangesObj > xParent, ScDocShell* pDocSh, OUString aNm, + css::uno::Reference< css::container::XNamed > const & xSheet = css::uno::Reference< css::container::XNamed > ()); + virtual ~ScNamedRangeObj() override; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + /// XNamedRange + virtual OUString SAL_CALL getContent() override; + virtual void SAL_CALL setContent( const OUString& aContent ) override; + virtual css::table::CellAddress SAL_CALL getReferencePosition() override; + virtual void SAL_CALL setReferencePosition( + const css::table::CellAddress& aReferencePosition ) override; + virtual sal_Int32 SAL_CALL getType() override; + virtual void SAL_CALL setType( sal_Int32 nType ) override; + + /// XFormulaTokens + virtual css::uno::Sequence< css::sheet::FormulaToken > SAL_CALL getTokens() override; + virtual void SAL_CALL setTokens( const css::uno::Sequence< css::sheet::FormulaToken >& aTokens ) override; + + /// XNamed + virtual OUString SAL_CALL getName() override; + virtual void SAL_CALL setName( const OUString& aName ) override; + + /// XCellRangeReferrer + virtual css::uno::Reference< css::table::XCellRange > SAL_CALL + getReferredCells() override; + + /// XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > + SAL_CALL getPropertySetInfo() override; + virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, + const css::uno::Any& aValue ) override; + virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override; + virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override; + virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override; + virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + + /// XServiceInfo + 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; +}; + +class ScNamedRangesObj : public ::cppu::WeakImplHelper< + css::sheet::XNamedRanges, + css::container::XEnumerationAccess, + css::container::XIndexAccess, + css::beans::XPropertySet, + css::document::XActionLockable, + css::lang::XServiceInfo >, + public SfxListener +{ +private: + + /** if true, adding new name or modifying existing one will set the + document 'modified' and broadcast the change. We turn this off during + import. */ + bool mbModifyAndBroadcast; + + virtual rtl::Reference<ScNamedRangeObj> GetObjectByIndex_Impl(sal_uInt16 nIndex) = 0; + virtual rtl::Reference<ScNamedRangeObj> GetObjectByName_Impl(const OUString& aName) = 0; + + virtual ScRangeName* GetRangeName_Impl() = 0; + virtual SCTAB GetTab_Impl() = 0; + +protected: + + ScDocShell* pDocShell; + /** called from the XActionLockable interface methods on initial locking */ + void lock(); + + /** called from the XActionLockable interface methods on final unlock */ + void unlock(); + +public: + ScNamedRangesObj(ScDocShell* pDocSh); + virtual ~ScNamedRangesObj() override; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + bool IsModifyAndBroadcast() const { return mbModifyAndBroadcast;} + + /// XNamedRanges + virtual void SAL_CALL addNewByName( const OUString& aName, const OUString& aContent, + const css::table::CellAddress& aPosition, sal_Int32 nType ) override; + virtual void SAL_CALL addNewFromTitles( const css::table::CellRangeAddress& aSource, + css::sheet::Border aBorder ) override; + virtual void SAL_CALL removeByName( const OUString& aName ) override; + virtual void SAL_CALL outputList( const css::table::CellAddress& aOutputPosition ) override; + + /// XNameAccess + virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override; + virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override; + + /// XIndexAccess + virtual sal_Int32 SAL_CALL getCount() override; + virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override; + + /// XEnumerationAccess + virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL + createEnumeration() override; + + /// XElementAccess + virtual css::uno::Type SAL_CALL getElementType() override; + virtual sal_Bool SAL_CALL hasElements() override; + + /// XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > + SAL_CALL getPropertySetInfo() override; + virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, + const css::uno::Any& aValue ) override; + virtual css::uno::Any SAL_CALL getPropertyValue( + const OUString& PropertyName ) override; + virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< + css::beans::XPropertyChangeListener >& xListener ) override; + virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override; + virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + + /// XActionLockable + virtual sal_Bool SAL_CALL isActionLocked() override; + virtual void SAL_CALL addActionLock() override; + virtual void SAL_CALL removeActionLock() override; + virtual void SAL_CALL setActionLocks( sal_Int16 nLock ) override; + virtual sal_Int16 SAL_CALL resetActionLocks() override; + + /// XServiceInfo + 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; +}; + +class ScGlobalNamedRangesObj final : public ScNamedRangesObj +{ +private: + + virtual rtl::Reference<ScNamedRangeObj> GetObjectByIndex_Impl(sal_uInt16 nIndex) override; + virtual rtl::Reference<ScNamedRangeObj> GetObjectByName_Impl(const OUString& aName) override; + + virtual ScRangeName* GetRangeName_Impl() override; + virtual SCTAB GetTab_Impl() override; + +public: + ScGlobalNamedRangesObj(ScDocShell* pDocSh); + virtual ~ScGlobalNamedRangesObj() override; +}; + +class ScLocalNamedRangesObj final : public ScNamedRangesObj +{ +private: + + virtual rtl::Reference<ScNamedRangeObj> GetObjectByIndex_Impl(sal_uInt16 nIndex) override; + virtual rtl::Reference<ScNamedRangeObj> GetObjectByName_Impl(const OUString& aName) override; + + virtual ScRangeName* GetRangeName_Impl() override; + virtual SCTAB GetTab_Impl() override; + + css::uno::Reference< css::container::XNamed > mxSheet; +public: + ScLocalNamedRangesObj(ScDocShell* pDocSh, css::uno::Reference< css::container::XNamed > xNamed ); + virtual ~ScLocalNamedRangesObj() override; +}; + +class ScLabelRangeObj final : public ::cppu::WeakImplHelper< + css::sheet::XLabelRange, + css::lang::XServiceInfo >, + public SfxListener +{ +private: + ScDocShell* pDocShell; + bool bColumn; + ScRange aRange; ///< criterion to find range + +private: + ScRangePair* GetData_Impl(); + void Modify_Impl( const ScRange* pLabel, const ScRange* pData ); + +public: + ScLabelRangeObj(ScDocShell* pDocSh, bool bCol, const ScRange& rR); + virtual ~ScLabelRangeObj() override; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + /// XLabelRange + virtual css::table::CellRangeAddress SAL_CALL getLabelArea() override; + virtual void SAL_CALL setLabelArea( const css::table::CellRangeAddress& aLabelArea ) override; + virtual css::table::CellRangeAddress SAL_CALL getDataArea() override; + virtual void SAL_CALL setDataArea( const css::table::CellRangeAddress& aDataArea ) override; + + /// XServiceInfo + 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; +}; + +class ScLabelRangesObj final : public ::cppu::WeakImplHelper< + css::sheet::XLabelRanges, + css::container::XEnumerationAccess, + css::lang::XServiceInfo >, + public SfxListener +{ +private: + ScDocShell* pDocShell; + bool bColumn; + + rtl::Reference<ScLabelRangeObj> GetObjectByIndex_Impl(size_t nIndex); + +public: + ScLabelRangesObj(ScDocShell* pDocSh, bool bCol); + virtual ~ScLabelRangesObj() override; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + /// XLabelRanges + virtual void SAL_CALL addNew( const css::table::CellRangeAddress& aLabelArea, + const css::table::CellRangeAddress& aDataArea ) override; + virtual void SAL_CALL removeByIndex( sal_Int32 nIndex ) override; + + /// XIndexAccess + virtual sal_Int32 SAL_CALL getCount() override; + virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override; + + /// XEnumerationAccess + virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL + createEnumeration() override; + + /// XElementAccess + virtual css::uno::Type SAL_CALL getElementType() override; + virtual sal_Bool SAL_CALL hasElements() override; + + /// XServiceInfo + 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; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/navicfg.hxx b/sc/inc/navicfg.hxx new file mode 100644 index 0000000000..cd8afb030e --- /dev/null +++ b/sc/inc/navicfg.hxx @@ -0,0 +1,46 @@ +/* -*- 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 <sal/types.h> + +enum class ScContentId; + +// CfgItem for navigator-state + +class ScNavipiCfg +{ +private: + sal_uInt16 nListMode; + sal_uInt16 nDragMode; + ScContentId nRootType; + +public: + ScNavipiCfg(); + + void SetListMode(sal_uInt16 nNew); + sal_uInt16 GetListMode() const { return nListMode; } + void SetDragMode(sal_uInt16 nNew); + sal_uInt16 GetDragMode() const { return nDragMode; } + void SetRootType(ScContentId nNew); + ScContentId GetRootType() const { return nRootType; } +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/notesuno.hxx b/sc/inc/notesuno.hxx new file mode 100644 index 0000000000..30bfcaf1c8 --- /dev/null +++ b/sc/inc/notesuno.hxx @@ -0,0 +1,104 @@ +/* -*- 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/sheet/XSheetAnnotation.hpp> +#include <com/sun/star/sheet/XSheetAnnotationShapeSupplier.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/container/XChild.hpp> +#include <com/sun/star/text/XSimpleText.hpp> +#include <cppuhelper/implbase.hxx> +#include <svl/lstner.hxx> +#include <rtl/ref.hxx> +#include "address.hxx" + +class ScDocShell; +class SvxUnoText; +class ScPostIt; + +class ScAnnotationObj final : public cppu::WeakImplHelper< + css::container::XChild, + css::text::XSimpleText, + css::sheet::XSheetAnnotation, + css::sheet::XSheetAnnotationShapeSupplier, + css::lang::XServiceInfo >, + public SfxListener +{ +public: + ScAnnotationObj(ScDocShell* pDocSh, const ScAddress& rPos); + virtual ~ScAnnotationObj() override; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + /// XChild + virtual css::uno::Reference< css::uno::XInterface > SAL_CALL + getParent() override; + virtual void SAL_CALL setParent( const css::uno::Reference< + css::uno::XInterface >& Parent ) override; + + /// XSimpleText + virtual css::uno::Reference< css::text::XTextCursor > SAL_CALL + createTextCursor() override; + virtual css::uno::Reference< css::text::XTextCursor > SAL_CALL + createTextCursorByRange( const css::uno::Reference< css::text::XTextRange >& aTextPosition ) override; + virtual void SAL_CALL insertString( const css::uno::Reference< + css::text::XTextRange >& xRange, + const OUString& aString, sal_Bool bAbsorb ) override; + virtual void SAL_CALL insertControlCharacter( const css::uno::Reference< css::text::XTextRange >& xRange, + sal_Int16 nControlCharacter, sal_Bool bAbsorb ) override; + + /// XTextRange + virtual css::uno::Reference< css::text::XText > SAL_CALL + getText() override; + virtual css::uno::Reference< css::text::XTextRange > SAL_CALL + getStart() override; + virtual css::uno::Reference< css::text::XTextRange > SAL_CALL + getEnd() override; + virtual OUString SAL_CALL getString() override; + virtual void SAL_CALL setString( const OUString& aString ) override; + + /// XSheetAnnotation + virtual css::table::CellAddress SAL_CALL getPosition() override; + virtual OUString SAL_CALL getAuthor() override; + virtual OUString SAL_CALL getDate() override; + virtual sal_Bool SAL_CALL getIsVisible() override; + virtual void SAL_CALL setIsVisible( sal_Bool bIsVisible ) override; + + /// XSheetAnnotationShapeSupplier + virtual css::uno::Reference < css::drawing::XShape > SAL_CALL + getAnnotationShape() override; + + /// XServiceInfo + 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; + +private: + SvxUnoText& GetUnoText(); + + const ScPostIt* ImplGetNote() const; + +private: + ScDocShell* pDocShell; + ScAddress aCellPos; + rtl::Reference<SvxUnoText> pUnoText; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/numformat.hxx b/sc/inc/numformat.hxx new file mode 100644 index 0000000000..cfd3653861 --- /dev/null +++ b/sc/inc/numformat.hxx @@ -0,0 +1,34 @@ +/* -*- 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/. + */ + +#pragma once + +#include "scdllapi.h" + +#include <tools/solar.h> + +class ScPatternAttr; +class ScDocument; + +namespace sc +{ +class SC_DLLPUBLIC NumFmtUtil +{ +public: + /** + * Check if the attribute pattern has a number format that only produces + * latin script output. + */ + static bool isLatinScript(const ScPatternAttr& rPat, ScDocument& rDoc); + + static bool isLatinScript(sal_uLong nFormat, ScDocument& rDoc); +}; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/olinetab.hxx b/sc/inc/olinetab.hxx new file mode 100644 index 0000000000..45c4a65a6b --- /dev/null +++ b/sc/inc/olinetab.hxx @@ -0,0 +1,191 @@ +/* -*- 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 "scdllapi.h" +#include "address.hxx" + +#include <map> + +#define SC_OL_MAXDEPTH 7 + +class ScTable; + +class ScOutlineEntry +{ + SCCOLROW nStart; + SCSIZE nSize; + bool bHidden; + bool bVisible; + +public: + ScOutlineEntry( SCCOLROW nNewStart, SCCOLROW nNewSize, bool bNewHidden ); + ScOutlineEntry( const ScOutlineEntry& rEntry ); + + SC_DLLPUBLIC SCCOLROW GetStart() const { return nStart;} + SCSIZE GetSize() const { return nSize;} + SC_DLLPUBLIC SCCOLROW GetEnd() const; + + /** + * @return true is the group is hidden, false otherwise. + */ + SC_DLLPUBLIC bool IsHidden() const { return bHidden;} + + /** + * @return true if the control is visible, false otherwise. + */ + SC_DLLPUBLIC bool IsVisible() const { return bVisible;} + + void Move( SCCOLROW nDelta ); + void SetSize( SCSIZE nNewSize ); + void SetPosSize( SCCOLROW nNewPos, SCSIZE nNewSize ); + void SetHidden( bool bNewHidden ); + void SetVisible( bool bNewVisible ); + + OString dumpAsString() const; +}; + +class ScOutlineCollection +{ + typedef std::map<SCCOLROW, ScOutlineEntry> MapType; + MapType m_Entries; + +public: + typedef MapType::iterator iterator; + typedef MapType::const_iterator const_iterator; + + ScOutlineCollection(); + + size_t size() const; + void clear(); + void insert(ScOutlineEntry const& rEntry); + iterator begin(); + iterator end(); + const_iterator begin() const; + const_iterator end() const; + iterator erase(const iterator& pos); + bool empty() const; + + iterator FindStart(SCCOLROW nMinStart); + + OString dumpAsString() const; +}; + +class SC_DLLPUBLIC ScOutlineArray +{ +friend class ScSubOutlineIterator; + +private: + size_t nDepth; + ScOutlineCollection aCollections[SC_OL_MAXDEPTH]; + + bool DecDepth(); + void FindEntry( + SCCOLROW nSearchPos, size_t& rFindLevel, size_t& rFindIndex, + size_t nMaxLevel = SC_OL_MAXDEPTH); + + void PromoteSub(SCCOLROW nStartPos, SCCOLROW nEndPos, size_t nStartLevel); + +public: + ScOutlineArray(); + ScOutlineArray( const ScOutlineArray& rArray ); + + size_t GetDepth() const { return nDepth;} + + bool FindTouchedLevel( + SCCOLROW nBlockStart, SCCOLROW nBlockEnd, size_t& rFindLevel) const; + + bool Insert( SCCOLROW nStartPos, SCCOLROW nEndPos, bool& rSizeChanged, + bool bHidden = false ); + bool Remove( SCCOLROW nBlockStart, SCCOLROW nBlockEnd, bool& rSizeChanged ); + + ScOutlineEntry* GetEntry(size_t nLevel, size_t nIndex); + const ScOutlineEntry* GetEntry(size_t nLevel, size_t nIndex) const; + size_t GetCount(size_t nLevel) const; + const ScOutlineEntry* GetEntryByPos(size_t nLevel, SCCOLROW nPos) const; + + bool GetEntryIndex(size_t nLevel, SCCOLROW nPos, size_t& rnIndex) const; + bool GetEntryIndexInRange( + size_t nLevel, SCCOLROW nBlockStart, SCCOLROW nBlockEnd, size_t& rnIndex) const; + + void SetVisibleBelow( + size_t nLevel, size_t nEntry, bool bValue, bool bSkipHidden = false); + + void GetRange(SCCOLROW& rStart, SCCOLROW& rEnd) const; + void ExtendBlock(size_t nLevel, SCCOLROW& rBlkStart, SCCOLROW& rBlkEnd); + + bool TestInsertSpace(SCSIZE nSize, SCCOLROW nMaxVal) const; + void InsertSpace(SCCOLROW nStartPos, SCSIZE nSize); + bool DeleteSpace(SCCOLROW nStartPos, SCSIZE nSize); + + bool ManualAction( + SCCOLROW nStartPos, SCCOLROW nEndPos, bool bShow, const ScTable& rTable, bool bCol); + + void finalizeImport(const ScTable& rTable); + + void RemoveAll(); + + OString dumpAsString() const; +}; + +class ScOutlineTable +{ +private: + ScOutlineArray aColOutline; + ScOutlineArray aRowOutline; + +public: + ScOutlineTable(); + ScOutlineTable( const ScOutlineTable& rOutline ); + + const ScOutlineArray& GetColArray() const { return aColOutline; } + ScOutlineArray& GetColArray() { return aColOutline; } + const ScOutlineArray& GetRowArray() const { return aRowOutline; } + ScOutlineArray& GetRowArray() { return aRowOutline; } + + bool TestInsertCol( SCSIZE nSize ); + void InsertCol( SCCOL nStartCol, SCSIZE nSize ); + bool DeleteCol( SCCOL nStartCol, SCSIZE nSize ); // TRUE: Undo only using original + bool TestInsertRow( SCSIZE nSize ); + void InsertRow( SCROW nStartRow, SCSIZE nSize ); + bool DeleteRow( SCROW nStartRow, SCSIZE nSize ); +}; + +class ScSubOutlineIterator +{ +private: + ScOutlineArray* pArray; + SCCOLROW nStart; + SCCOLROW nEnd; + size_t nSubLevel; + size_t nSubEntry; + size_t nDepth; + +public: + ScSubOutlineIterator( ScOutlineArray* pOutlineArray ); + ScSubOutlineIterator( ScOutlineArray* pOutlineArray, size_t nLevel, size_t nEntry ); + + ScOutlineEntry* GetNext(); + size_t LastLevel() const { return nSubLevel;} + size_t LastEntry() const; + void DeleteLast(); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/optuno.hxx b/sc/inc/optuno.hxx new file mode 100644 index 0000000000..72050044e3 --- /dev/null +++ b/sc/inc/optuno.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 "docuno.hxx" +#include "docoptio.hxx" + +#define PROP_UNO_CALCASSHOWN 1 +#define PROP_UNO_DEFTABSTOP 2 +#define PROP_UNO_IGNORECASE 3 +#define PROP_UNO_ITERENABLED 4 +#define PROP_UNO_ITERCOUNT 5 +#define PROP_UNO_ITEREPSILON 6 +#define PROP_UNO_LOOKUPLABELS 7 +#define PROP_UNO_MATCHWHOLE 8 +#define PROP_UNO_NULLDATE 9 +#define PROP_UNO_SPELLONLINE 10 +#define PROP_UNO_STANDARDDEC 11 +#define PROP_UNO_REGEXENABLED 12 +#define PROP_UNO_WILDCARDSENABLED 13 + +class ScDocOptionsHelper +{ +public: + static std::span<const SfxItemPropertyMapEntry> GetPropertyMap(); + + static bool setPropertyValue( ScDocOptions& rOptions, + const SfxItemPropertyMap& rPropMap, + std::u16string_view aPropertyName, + const css::uno::Any& aValue ); + static css::uno::Any getPropertyValue( + const ScDocOptions& rOptions, + const SfxItemPropertyMap& rPropMap, + std::u16string_view PropertyName ); +}; + +// empty doc object to supply only doc options + +class ScDocOptionsObj final : public ScModelObj +{ +private: + ScDocOptions aOptions; + +public: + ScDocOptionsObj( const ScDocOptions& rOpt ); + virtual ~ScDocOptionsObj() override; + + // get/setPropertyValue override to used stored options instead of document + + virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, + const css::uno::Any& aValue ) override; + virtual css::uno::Any SAL_CALL getPropertyValue( + const OUString& PropertyName ) override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/optutil.hxx b/sc/inc/optutil.hxx new file mode 100644 index 0000000000..8f31df9051 --- /dev/null +++ b/sc/inc/optutil.hxx @@ -0,0 +1,64 @@ +/* -*- 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 <unotools/configitem.hxx> +#include <tools/link.hxx> +#include "scdllapi.h" + +class ScOptionsUtil +{ +public: + // values must correspond with integer values stored in the configuration + enum KeyBindingType { KEY_DEFAULT = 0, KEY_OOO_LEGACY = 1 }; + + static bool IsMetricSystem(); +}; + +// ConfigItem for classes that use items from several sub trees + +class SC_DLLPUBLIC ScLinkConfigItem final : public utl::ConfigItem +{ + Link<ScLinkConfigItem&,void> aCommitLink; + Link<ScLinkConfigItem&,void> aNotifyLink; + +public: + ScLinkConfigItem( const OUString& rSubTree ); + ScLinkConfigItem( const OUString& rSubTree, ConfigItemMode nMode ); + void SetCommitLink( const Link<ScLinkConfigItem&,void>& rLink ); + void SetNotifyLink( const Link<ScLinkConfigItem&,void>& rLink ); + + virtual void Notify( const css::uno::Sequence<OUString>& aPropertyNames ) override; + virtual void ImplCommit() override; + + using ConfigItem::SetModified; + css::uno::Sequence< css::uno::Any> + GetProperties(const css::uno::Sequence< OUString >& rNames) + { return ConfigItem::GetProperties( rNames ); } + void PutProperties( const css::uno::Sequence< OUString >& rNames, + const css::uno::Sequence< css::uno::Any>& rValues) + { ConfigItem::PutProperties( rNames, rValues ); } + + using ConfigItem::EnableNotification; + using ConfigItem::GetNodeNames; + +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/orcusfilters.hxx b/sc/inc/orcusfilters.hxx new file mode 100644 index 0000000000..f13f5cc630 --- /dev/null +++ b/sc/inc/orcusfilters.hxx @@ -0,0 +1,68 @@ +/* -*- 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/. + */ + +#pragma once + +#include <rtl/ustring.hxx> +#include <memory> + +class ScDocument; +struct ScOrcusXMLTreeParam; +struct ScOrcusImportXMLParam; +class ScOrcusXMLContext; +class SfxMedium; +namespace weld { class TreeView; } + +/** + * Collection of orcus filter wrappers. + */ +class ScOrcusFilters +{ +public: + enum class ImportResult + { + NotSupported, + Success, + Failure + }; + + virtual ~ScOrcusFilters() {} + + virtual ImportResult importByName( + ScDocument& rDoc, SfxMedium& rMedium, const OUString& rFilterName) const = 0; + + /** + * Used to import just the styles from an xml file. + */ + + virtual bool importODS_Styles(ScDocument& rDoc, OUString& aFileName) const = 0; + + /** + * Create a context for XML file. The context object stores session + * information for each unique XML file. You must create a new context + * for each XML file, and never to re-use the same context for multiple + * XML files. + * + * The caller is responsible for deleting the instance returned from this + * method when it's done. + */ + virtual std::unique_ptr<ScOrcusXMLContext> createXMLContext(ScDocument& rDoc, const OUString& rPath) const = 0; +}; + +class ScOrcusXMLContext +{ +public: + virtual ~ScOrcusXMLContext() {} + + virtual void loadXMLStructure(weld::TreeView& rTreeCtrl, ScOrcusXMLTreeParam& rParam) = 0; + + virtual void importXML(const ScOrcusImportXMLParam& rParam) = 0; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/orcusxml.hxx b/sc/inc/orcusxml.hxx new file mode 100644 index 0000000000..c59bf100b3 --- /dev/null +++ b/sc/inc/orcusxml.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/. + */ + +#pragma once + +#include "scdllapi.h" +#include "address.hxx" + +#include <vector> +#include <memory> + +namespace weld { + class TreeIter; + class TreeView; +} + +/** + * Parameter used during call to ScOrcusFilters::loadXMLStructure(). + */ +struct ScOrcusXMLTreeParam +{ + enum EntryType { ElementDefault, ElementRepeat, Attribute }; + + /** Custom data stored with each tree item. */ + struct EntryData + { + size_t mnNamespaceID; /// numerical ID for xml namespace + EntryType meType; + ScAddress maLinkedPos; /// linked cell position (invalid if unlinked) + bool mbRangeParent:1; + bool mbLeafNode:1; /// Leaf if it has no child elements. Child Attributes don't count. + + SC_DLLPUBLIC EntryData(EntryType eType); + }; + + typedef std::vector<std::unique_ptr<EntryData>> UserDataStoreType; + + OUString maImgElementDefault; + OUString maImgElementRepeat; + OUString maImgAttribute; + + /** + * Store all custom data instances since the tree control doesn't manage + * the life cycle of user data. + */ + UserDataStoreType m_UserDataStore; + + static EntryData* getUserData(const weld::TreeView& rControl, const weld::TreeIter& rEntry); +}; + +struct ScOrcusImportXMLParam +{ + struct CellLink + { + ScAddress maPos; + OString maPath; + + CellLink(const ScAddress& rPos, OString aPath); + }; + + struct RangeLink + { + ScAddress maPos; + std::vector<OString> maFieldPaths; + std::vector<OString> maRowGroups; + }; + + std::vector<size_t> maNamespaces; + std::vector<CellLink> maCellLinks; + std::vector<RangeLink> maRangeLinks; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/pagepar.hxx b/sc/inc/pagepar.hxx new file mode 100644 index 0000000000..7961d5d367 --- /dev/null +++ b/sc/inc/pagepar.hxx @@ -0,0 +1,66 @@ +/* -*- 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 "address.hxx" + +struct ScPageTableParam +{ + bool bCellContent; + bool bNotes; + bool bGrid; + bool bHeaders; + bool bCharts; + bool bObjects; + bool bDrawings; + bool bFormulas; + bool bNullVals; + bool bTopDown; + bool bLeftRight; + bool bSkipEmpty; + bool bScaleNone; + bool bScaleAll; + bool bScaleTo; + bool bScalePageNum; + bool bForceBreaks; + sal_uInt16 nScaleAll; + sal_uInt16 nScaleWidth; + sal_uInt16 nScaleHeight; + sal_uInt16 nScalePageNum; + sal_uInt16 nFirstPageNo; + + ScPageTableParam(); + + void Reset (); +}; + +struct ScPageAreaParam +{ + bool bPrintArea; + bool bRepeatRow; + bool bRepeatCol; + ScRange aPrintArea; + + ScPageAreaParam(); + + void Reset (); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/pageuno.hxx b/sc/inc/pageuno.hxx new file mode 100644 index 0000000000..1956ba2462 --- /dev/null +++ b/sc/inc/pageuno.hxx @@ -0,0 +1,40 @@ +/* -*- 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 <svx/unopage.hxx> + +// SvxDrawPage subclass to create ScShapeObj for shapes + +class ScPageObj final : public SvxDrawPage +{ +public: + ScPageObj(SdrPage* pPage); + virtual ~ScPageObj() noexcept override; + + virtual css::uno::Reference<css::drawing::XShape> CreateShape(SdrObject* pObj) const override; + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + virtual sal_Bool SAL_CALL supportsService(const OUString& rServiceName) override; + virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/paramisc.hxx b/sc/inc/paramisc.hxx new file mode 100644 index 0000000000..59608cae15 --- /dev/null +++ b/sc/inc/paramisc.hxx @@ -0,0 +1,65 @@ +/* -*- 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 "address.hxx" +#include <optional> + +struct ScSolveParam +{ + ScAddress aRefFormulaCell; + ScAddress aRefVariableCell; + std::optional<OUString> pStrTargetVal; + + ScSolveParam(); + ScSolveParam( const ScSolveParam& r ); + ScSolveParam( const ScAddress& rFormulaCell, + const ScAddress& rVariableCell, + const OUString& rTargetValStr ); + ~ScSolveParam(); + + ScSolveParam& operator= ( const ScSolveParam& r ); + bool operator== ( const ScSolveParam& r ) const; +}; + +/** + * Parameter for data table aka multiple operations. + */ +struct SC_DLLPUBLIC ScTabOpParam +{ + enum Mode { Column = 0, Row = 1, Both = 2 }; + + ScRefAddress aRefFormulaCell; + ScRefAddress aRefFormulaEnd; + ScRefAddress aRefRowCell; + ScRefAddress aRefColCell; + Mode meMode; + + ScTabOpParam(); + ScTabOpParam( const ScTabOpParam& r ); + ScTabOpParam( + const ScRefAddress& rFormulaCell, const ScRefAddress& rFormulaEnd, + const ScRefAddress& rRowCell, const ScRefAddress& rColCell, Mode eMode ); + + ScTabOpParam& operator= ( const ScTabOpParam& r ); + bool operator== ( const ScTabOpParam& r ) const; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/patattr.hxx b/sc/inc/patattr.hxx new file mode 100644 index 0000000000..d6536551f9 --- /dev/null +++ b/sc/inc/patattr.hxx @@ -0,0 +1,193 @@ +/* -*- 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 <optional> + +#include <svl/setitem.hxx> +#include <svl/itemset.hxx> +#include <svl/languageoptions.hxx> +#include <tools/degree.hxx> +#include <editeng/svxenum.hxx> +#include "scdllapi.h" +#include "fonthelper.hxx" + +namespace vcl { class Font; } +namespace model { class ComplexColor; } +class OutputDevice; +class Fraction; +class ScStyleSheet; +class SvNumberFormatter; +class ScDocument; +enum class ScRotateDir : sal_uInt8; + +/// how to treat COL_AUTO in GetFont: + +enum class ScAutoFontColorMode +{ + Raw, ///< COL_AUTO is returned + Print, ///< black or white, depending on background + Display, ///< from style settings, or black/white if needed + IgnoreFont, ///< like DISPLAY, but ignore stored font color (assume COL_AUTO) + IgnoreBack, ///< like DISPLAY, but ignore stored background color (use configured color) + IgnoreAll ///< like DISPLAY, but ignore stored font and background colors +}; + +class SC_DLLPUBLIC ScPatternAttr final : public SfxSetItem +{ + std::optional<OUString> pName; + mutable std::optional<bool> mxVisible; + ScStyleSheet* pStyle; + sal_uInt64 mnPAKey; +public: + ScPatternAttr(SfxItemSet&& pItemSet, const OUString& rStyleName); + ScPatternAttr(SfxItemSet&& pItemSet); + ScPatternAttr(SfxItemPool* pItemPool); + ScPatternAttr(const ScPatternAttr& rPatternAttr); + + virtual ScPatternAttr* Clone( SfxItemPool *pPool = nullptr ) const override; + + virtual bool operator==(const SfxPoolItem& rCmp) const override; + + const SfxPoolItem& GetItem( sal_uInt16 nWhichP ) const + { return GetItemSet().Get(nWhichP); } + template<class T> const T& GetItem( TypedWhichId<T> nWhich ) const + { return static_cast<const T&>(GetItem(sal_uInt16(nWhich))); } + + static const SfxPoolItem& GetItem( sal_uInt16 nWhich, const SfxItemSet& rItemSet, const SfxItemSet* pCondSet ); + template<class T> static const T& GetItem( TypedWhichId<T> nWhich, const SfxItemSet& rItemSet, const SfxItemSet* pCondSet ) + { return static_cast<const T&>(GetItem(sal_uInt16(nWhich), rItemSet, pCondSet)); } + + const SfxPoolItem& GetItem( sal_uInt16 nWhich, const SfxItemSet* pCondSet ) const; + template<class T> const T& GetItem( TypedWhichId<T> nWhich, const SfxItemSet* pCondSet ) const + { return static_cast<const T&>(GetItem(sal_uInt16(nWhich), pCondSet)); } + + /// @param pWhich are no ranges, but single IDs, 0-terminated + bool HasItemsSet( const sal_uInt16* pWhich ) const; + void ClearItems( const sal_uInt16* pWhich ); + + void DeleteUnchanged( const ScPatternAttr* pOldAttrs ); + + static SvxCellOrientation GetCellOrientation( const SfxItemSet& rItemSet, const SfxItemSet* pCondSet ); + SvxCellOrientation GetCellOrientation( const SfxItemSet* pCondSet = nullptr ) const; + + /** Static helper function to fill a font object from the passed item set. */ + static void fillFontOnly(vcl::Font& rFont, const SfxItemSet& rItemSet, + const OutputDevice* pOutDev = nullptr, + const Fraction* pScale = nullptr, + const SfxItemSet* pCondSet = nullptr, + SvtScriptType nScript = SvtScriptType::NONE); + + static void fillFont( vcl::Font& rFont, const SfxItemSet& rItemSet, + ScAutoFontColorMode eAutoMode, + const OutputDevice* pOutDev = nullptr, + const Fraction* pScale = nullptr, + const SfxItemSet* pCondSet = nullptr, + SvtScriptType nScript = SvtScriptType::NONE, const Color* pBackConfigColor = nullptr, + const Color* pTextConfigColor = nullptr); + + static void fillColor(model::ComplexColor& rComplexColor, + const SfxItemSet& rItemSet, + ScAutoFontColorMode eAutoMode, + const SfxItemSet* pCondSet = nullptr, + const Color* pBackConfigColor = nullptr, + const Color* pTextConfigColor = nullptr); + + + static ScDxfFont GetDxfFont(const SfxItemSet& rSet, SvtScriptType nScript); + + void fillColor(model::ComplexColor& rComplexColor, + ScAutoFontColorMode eAutoMode, + const SfxItemSet* pCondSet = nullptr, + const Color* pBackConfigColor = nullptr, + const Color* pTextConfigColor = nullptr) const + { + fillColor(rComplexColor, GetItemSet(), eAutoMode, pCondSet, pBackConfigColor, pTextConfigColor); + } + + void fillFontOnly(vcl::Font& rFont, + const OutputDevice* pOutDev = nullptr, + const Fraction* pScale = nullptr, + const SfxItemSet* pCondSet = nullptr, + SvtScriptType nScript = SvtScriptType::NONE) const + { + fillFontOnly(rFont, GetItemSet(), pOutDev, pScale, pCondSet, nScript); + } + + /** Fills a font object from the own item set. */ + void fillFont(vcl::Font& rFont, ScAutoFontColorMode eAutoMode, + const OutputDevice* pOutDev = nullptr, + const Fraction* pScale = nullptr, + const SfxItemSet* pCondSet = nullptr, + SvtScriptType nScript = SvtScriptType::NONE, + const Color* pBackConfigColor = nullptr, + const Color* pTextConfigColor = nullptr) const + { + fillFont(rFont, GetItemSet(), eAutoMode, pOutDev, pScale, pCondSet, nScript, pBackConfigColor, pTextConfigColor); + } + + /** Converts all Calc items contained in rSrcSet to edit engine items and puts them into rEditSet. */ + static void FillToEditItemSet( SfxItemSet& rEditSet, const SfxItemSet& rSrcSet, const SfxItemSet* pCondSet = nullptr ); + /** Converts all Calc items contained in the own item set to edit engine items and puts them into pEditSet. */ + void FillEditItemSet( SfxItemSet* pEditSet, const SfxItemSet* pCondSet = nullptr ) const; + + /** Converts all edit engine items contained in rEditSet to Calc items and puts them into rDestSet. */ + static void GetFromEditItemSet( SfxItemSet& rDestSet, const SfxItemSet& rEditSet ); + /** Converts all edit engine items contained in pEditSet to Calc items and puts them into the own item set. */ + void GetFromEditItemSet( const SfxItemSet* pEditSet ); + + void FillEditParaItems( SfxItemSet* pSet ) const; + + ScPatternAttr* PutInPool( ScDocument* pDestDoc, ScDocument* pSrcDoc ) const; + + void SetStyleSheet(ScStyleSheet* pNewStyle, bool bClearDirectFormat = true); + const ScStyleSheet* GetStyleSheet() const { return pStyle; } + const OUString* GetStyleName() const; + void UpdateStyleSheet(const ScDocument& rDoc); + void StyleToName(); + + bool IsVisible() const; + bool IsVisibleEqual( const ScPatternAttr& rOther ) const; + + /** If font is an old symbol font StarBats/StarMath + with text encoding RTL_TEXTENC_SYMBOL */ + bool IsSymbolFont() const; + + sal_uInt32 GetNumberFormat( SvNumberFormatter* ) const; + sal_uInt32 GetNumberFormat( SvNumberFormatter* pFormatter, + const SfxItemSet* pCondSet ) const; + + Degree100 GetRotateVal( const SfxItemSet* pCondSet ) const; + ScRotateDir GetRotateDir( const SfxItemSet* pCondSet ) const; + + void SetPAKey(sal_uInt64 nKey); + sal_uInt64 GetPAKey() const; + + // TODO: tdf#135215: This is a band-aid to detect changes and invalidate the hash, + // a proper way would be probably to override SfxItemSet::Changed(), but 6cb400f41df0dd10 + // hardcoded SfxSetItem to contain SfxItemSet. + SfxItemSet& GetItemSet() { mxVisible.reset(); return SfxSetItem::GetItemSet(); } + using SfxSetItem::GetItemSet; + +private: + bool CalcVisible() const; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/pch/precompiled_sc.cxx b/sc/inc/pch/precompiled_sc.cxx new file mode 100644 index 0000000000..11e95b09da --- /dev/null +++ b/sc/inc/pch/precompiled_sc.cxx @@ -0,0 +1,12 @@ +/* -*- 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/. + */ + +#include "precompiled_sc.hxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/pch/precompiled_sc.hxx b/sc/inc/pch/precompiled_sc.hxx new file mode 100644 index 0000000000..0bd47079ec --- /dev/null +++ b/sc/inc/pch/precompiled_sc.hxx @@ -0,0 +1,613 @@ +/* -*- 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 has been autogenerated by update_pch.sh. It is possible to edit it + manually (such as when an include file has been moved/renamed/removed). All such + manual changes will be rewritten by the next run of update_pch.sh (which presumably + also fixes all possible problems, so it's usually better to use it). + + Generated on 2022-08-13 18:01:14 using: + ./bin/update_pch sc sc --cutoff=12 --exclude:system --include:module --include:local + + If after updating build fails, use the following command to locate conflicting headers: + ./bin/update_pch_bisect ./sc/inc/pch/precompiled_sc.hxx "make sc.build" --find-conflicts +*/ + +#include <sal/config.h> +#if PCH_LEVEL >= 1 +#include <algorithm> +#include <array> +#include <atomic> +#include <cassert> +#include <chrono> +#include <cmath> +#include <cstddef> +#include <cstdlib> +#include <cstring> +#include <deque> +#include <float.h> +#include <functional> +#include <initializer_list> +#include <iomanip> +#include <iterator> +#include <limits.h> +#include <limits> +#include <map> +#include <math.h> +#include <memory> +#include <mutex> +#include <new> +#include <optional> +#include <ostream> +#include <set> +#include <span> +#include <sstream> +#include <stddef.h> +#include <stdexcept> +#include <string.h> +#include <string> +#include <string_view> +#include <type_traits> +#include <unordered_map> +#include <unordered_set> +#include <utility> +#include <vector> +#include <boost/functional/hash.hpp> +#include <boost/intrusive_ptr.hpp> +#include <boost/property_tree/json_parser.hpp> +#include <boost/property_tree/ptree.hpp> +#include <boost/property_tree/ptree_fwd.hpp> +#endif // PCH_LEVEL >= 1 +#if PCH_LEVEL >= 2 +#include <osl/conditn.hxx> +#include <osl/diagnose.h> +#include <osl/diagnose.hxx> +#include <osl/doublecheckedlocking.h> +#include <osl/endian.h> +#include <osl/file.hxx> +#include <osl/getglobalmutex.hxx> +#include <osl/interlck.h> +#include <osl/module.hxx> +#include <osl/mutex.h> +#include <osl/mutex.hxx> +#include <osl/process.h> +#include <osl/security.hxx> +#include <osl/thread.h> +#include <rtl/alloc.h> +#include <rtl/bootstrap.hxx> +#include <rtl/character.hxx> +#include <rtl/crc.h> +#include <rtl/digest.h> +#include <rtl/instance.hxx> +#include <rtl/math.h> +#include <rtl/math.hxx> +#include <rtl/ref.hxx> +#include <rtl/strbuf.h> +#include <rtl/strbuf.hxx> +#include <rtl/string.h> +#include <rtl/string.hxx> +#include <rtl/stringconcat.hxx> +#include <rtl/stringutils.hxx> +#include <rtl/tencinfo.h> +#include <rtl/textcvt.h> +#include <rtl/textenc.h> +#include <rtl/ustrbuf.h> +#include <rtl/ustrbuf.hxx> +#include <rtl/ustring.h> +#include <rtl/ustring.hxx> +#include <sal/backtrace.hxx> +#include <sal/detail/log.h> +#include <sal/log.hxx> +#include <sal/macros.h> +#include <sal/mathconf.h> +#include <sal/saldllapi.h> +#include <sal/types.h> +#include <sal/typesizes.h> +#include <vcl/BinaryDataContainer.hxx> +#include <vcl/EnumContext.hxx> +#include <vcl/GraphicAttributes.hxx> +#include <vcl/GraphicExternalLink.hxx> +#include <vcl/GraphicObject.hxx> +#include <vcl/IDialogRenderable.hxx> +#include <vcl/InterimItemWindow.hxx> +#include <vcl/Scanline.hxx> +#include <vcl/WindowPosSize.hxx> +#include <vcl/alpha.hxx> +#include <vcl/animate/Animation.hxx> +#include <vcl/animate/AnimationFrame.hxx> +#include <vcl/bitmap.hxx> +#include <vcl/bitmap/BitmapTypes.hxx> +#include <vcl/bitmapex.hxx> +#include <vcl/checksum.hxx> +#include <vcl/commandevent.hxx> +#include <vcl/ctrl.hxx> +#include <vcl/customweld.hxx> +#include <vcl/dllapi.h> +#include <comphelper/errcode.hxx> +#include <vcl/event.hxx> +#include <vcl/fntstyle.hxx> +#include <vcl/font.hxx> +#include <vcl/gfxlink.hxx> +#include <vcl/graph.hxx> +#include <vcl/idle.hxx> +#include <vcl/image.hxx> +#include <vcl/keycod.hxx> +#include <vcl/keycodes.hxx> +#include <vcl/mapmod.hxx> +#include <vcl/outdev.hxx> +#include <vcl/region.hxx> +#include <vcl/settings.hxx> +#include <vcl/svapp.hxx> +#include <vcl/syswin.hxx> +#include <vcl/task.hxx> +#include <vcl/timer.hxx> +#include <vcl/toolboxid.hxx> +#include <vcl/transfer.hxx> +#include <vcl/uitest/factory.hxx> +#include <vcl/vclenum.hxx> +#include <vcl/vclptr.hxx> +#include <vcl/vectorgraphicdata.hxx> +#include <vcl/virdev.hxx> +#include <vcl/weld.hxx> +#include <vcl/window.hxx> +#include <vcl/windowstate.hxx> +#include <vcl/wintypes.hxx> +#endif // PCH_LEVEL >= 2 +#if PCH_LEVEL >= 3 +#include <basegfx/basegfxdllapi.h> +#include <basegfx/color/bcolor.hxx> +#include <basegfx/matrix/b2dhommatrix.hxx> +#include <basegfx/numeric/ftools.hxx> +#include <basegfx/point/b2dpoint.hxx> +#include <basegfx/point/b2ipoint.hxx> +#include <basegfx/polygon/b2dpolygon.hxx> +#include <basegfx/polygon/b2dpolypolygon.hxx> +#include <basegfx/range/Range2D.hxx> +#include <basegfx/range/b2drange.hxx> +#include <basegfx/range/b2drectangle.hxx> +#include <basegfx/range/basicrange.hxx> +#include <basegfx/tuple/Tuple2D.hxx> +#include <basegfx/tuple/Tuple3D.hxx> +#include <basegfx/tuple/b2dtuple.hxx> +#include <basegfx/tuple/b2ituple.hxx> +#include <basegfx/tuple/b3dtuple.hxx> +#include <basegfx/utils/common.hxx> +#include <basegfx/vector/b2dsize.hxx> +#include <basegfx/vector/b2dvector.hxx> +#include <basegfx/vector/b2enums.hxx> +#include <basegfx/vector/b2ivector.hxx> +#include <basic/basicdllapi.h> +#include <basic/sbxdef.hxx> +#include <com/sun/star/accessibility/AccessibleStateType.hpp> +#include <com/sun/star/accessibility/XAccessible.hpp> +#include <com/sun/star/accessibility/XAccessibleComponent.hpp> +#include <com/sun/star/accessibility/XAccessibleContext.hpp> +#include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp> +#include <com/sun/star/accessibility/XAccessibleSelection.hpp> +#include <com/sun/star/awt/Gradient.hpp> +#include <com/sun/star/awt/GradientStyle.hpp> +#include <com/sun/star/awt/Key.hpp> +#include <com/sun/star/awt/KeyGroup.hpp> +#include <com/sun/star/beans/Property.hpp> +#include <com/sun/star/beans/PropertyAttribute.hpp> +#include <com/sun/star/beans/PropertyState.hpp> +#include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/beans/XFastPropertySet.hpp> +#include <com/sun/star/beans/XMultiPropertySet.hpp> +#include <com/sun/star/beans/XPropertiesChangeListener.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/beans/XPropertySetInfo.hpp> +#include <com/sun/star/beans/XPropertySetOption.hpp> +#include <com/sun/star/beans/XPropertyState.hpp> +#include <com/sun/star/beans/XVetoableChangeListener.hpp> +#include <com/sun/star/container/XEnumerationAccess.hpp> +#include <com/sun/star/container/XNameContainer.hpp> +#include <com/sun/star/datatransfer/DataFlavor.hpp> +#include <com/sun/star/datatransfer/XTransferable2.hpp> +#include <com/sun/star/datatransfer/clipboard/XClipboard.hpp> +#include <com/sun/star/datatransfer/clipboard/XClipboardOwner.hpp> +#include <com/sun/star/datatransfer/dnd/DNDConstants.hpp> +#include <com/sun/star/datatransfer/dnd/DropTargetDragEvent.hpp> +#include <com/sun/star/datatransfer/dnd/DropTargetDropEvent.hpp> +#include <com/sun/star/datatransfer/dnd/XDragGestureListener.hpp> +#include <com/sun/star/datatransfer/dnd/XDragSourceListener.hpp> +#include <com/sun/star/datatransfer/dnd/XDropTargetListener.hpp> +#include <com/sun/star/drawing/DashStyle.hpp> +#include <com/sun/star/drawing/HatchStyle.hpp> +#include <com/sun/star/drawing/TextFitToSizeType.hpp> +#include <com/sun/star/embed/Aspects.hpp> +#include <com/sun/star/embed/XEmbeddedObject.hpp> +#include <com/sun/star/embed/XStorage.hpp> +#include <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/frame/XModel.hpp> +#include <com/sun/star/frame/XStatusListener.hpp> +#include <com/sun/star/frame/XTerminateListener.hpp> +#include <com/sun/star/frame/XToolbarController.hpp> +#include <com/sun/star/graphic/XPrimitive2D.hpp> +#include <com/sun/star/i18n/ForbiddenCharacters.hpp> +#include <com/sun/star/lang/DisposedException.hpp> +#include <com/sun/star/lang/EventObject.hpp> +#include <com/sun/star/lang/IndexOutOfBoundsException.hpp> +#include <com/sun/star/lang/Locale.hpp> +#include <com/sun/star/lang/XComponent.hpp> +#include <com/sun/star/lang/XInitialization.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/lang/XTypeProvider.hpp> +#include <com/sun/star/lang/XUnoTunnel.hpp> +#include <com/sun/star/sheet/DataPilotFieldOrientation.hpp> +#include <com/sun/star/style/NumberingType.hpp> +#include <com/sun/star/style/XStyle.hpp> +#include <com/sun/star/uno/Any.h> +#include <com/sun/star/uno/Any.hxx> +#include <com/sun/star/uno/Reference.h> +#include <com/sun/star/uno/Reference.hxx> +#include <com/sun/star/uno/RuntimeException.hpp> +#include <com/sun/star/uno/Sequence.h> +#include <com/sun/star/uno/Sequence.hxx> +#include <com/sun/star/uno/Type.h> +#include <com/sun/star/uno/Type.hxx> +#include <com/sun/star/uno/TypeClass.hdl> +#include <com/sun/star/uno/XAggregation.hpp> +#include <com/sun/star/uno/XInterface.hpp> +#include <com/sun/star/uno/XWeak.hpp> +#include <com/sun/star/uno/genfunc.h> +#include <com/sun/star/uno/genfunc.hxx> +#include <com/sun/star/util/Date.hpp> +#include <com/sun/star/util/DateTime.hpp> +#include <com/sun/star/util/Time.hpp> +#include <com/sun/star/util/XAccounting.hpp> +#include <com/sun/star/util/XUpdatable.hpp> +#include <com/sun/star/xml/sax/XFastContextHandler.hpp> +#include <comphelper/broadcasthelper.hxx> +#include <comphelper/compbase.hxx> +#include <comphelper/comphelperdllapi.h> +#include <comphelper/interfacecontainer2.hxx> +#include <comphelper/interfacecontainer4.hxx> +#include <comphelper/lok.hxx> +#include <comphelper/multicontainer2.hxx> +#include <comphelper/processfactory.hxx> +#include <comphelper/propagg.hxx> +#include <comphelper/proparrhlp.hxx> +#include <comphelper/propertycontainer.hxx> +#include <comphelper/propertycontainerhelper.hxx> +#include <comphelper/propertysequence.hxx> +#include <comphelper/propertysetinfo.hxx> +#include <comphelper/propstate.hxx> +#include <comphelper/sequence.hxx> +#include <comphelper/servicehelper.hxx> +#include <comphelper/string.hxx> +#include <comphelper/uno3.hxx> +#include <cppu/cppudllapi.h> +#include <cppu/unotype.hxx> +#include <cppuhelper/basemutex.hxx> +#include <cppuhelper/compbase5.hxx> +#include <cppuhelper/compbase_ex.hxx> +#include <cppuhelper/cppuhelperdllapi.h> +#include <cppuhelper/implbase.hxx> +#include <cppuhelper/implbase1.hxx> +#include <cppuhelper/implbase2.hxx> +#include <cppuhelper/implbase5.hxx> +#include <cppuhelper/implbase_ex.hxx> +#include <cppuhelper/implbase_ex_post.hxx> +#include <cppuhelper/implbase_ex_pre.hxx> +#include <cppuhelper/interfacecontainer.h> +#include <cppuhelper/propshlp.hxx> +#include <cppuhelper/queryinterface.hxx> +#include <cppuhelper/supportsservice.hxx> +#include <cppuhelper/weak.hxx> +#include <cppuhelper/weakagg.hxx> +#include <cppuhelper/weakref.hxx> +#include <drawinglayer/drawinglayerdllapi.h> +#include <drawinglayer/geometry/viewinformation2d.hxx> +#include <drawinglayer/primitive2d/CommonTypes.hxx> +#include <drawinglayer/primitive2d/Primitive2DContainer.hxx> +#include <drawinglayer/primitive2d/Primitive2DVisitor.hxx> +#include <drawinglayer/primitive2d/baseprimitive2d.hxx> +#include <editeng/adjustitem.hxx> +#include <editeng/borderline.hxx> +#include <editeng/boxitem.hxx> +#include <editeng/brushitem.hxx> +#include <editeng/colritem.hxx> +#include <editeng/editdata.hxx> +#include <editeng/editeng.hxx> +#include <editeng/editengdllapi.h> +#include <editeng/editobj.hxx> +#include <editeng/editstat.hxx> +#include <editeng/editview.hxx> +#include <editeng/eedata.hxx> +#include <editeng/eeitem.hxx> +#include <editeng/fhgtitem.hxx> +#include <editeng/flditem.hxx> +#include <editeng/fontitem.hxx> +#include <editeng/forbiddencharacterstable.hxx> +#include <editeng/justifyitem.hxx> +#include <editeng/langitem.hxx> +#include <editeng/lineitem.hxx> +#include <editeng/outliner.hxx> +#include <editeng/outlobj.hxx> +#include <editeng/overflowingtxt.hxx> +#include <editeng/paragraphdata.hxx> +#include <editeng/postitem.hxx> +#include <editeng/svxenum.hxx> +#include <editeng/svxfont.hxx> +#include <editeng/wghtitem.hxx> +#include <i18nlangtag/lang.h> +#include <o3tl/cow_wrapper.hxx> +#include <o3tl/deleter.hxx> +#include <o3tl/enumarray.hxx> +#include <o3tl/safeint.hxx> +#include <o3tl/sorted_vector.hxx> +#include <o3tl/string_view.hxx> +#include <o3tl/strong_int.hxx> +#include <o3tl/typed_flags_set.hxx> +#include <o3tl/underlyingenumvalue.hxx> +#include <o3tl/unit_conversion.hxx> +#include <officecfg/Office/Common.hxx> +#include <salhelper/salhelperdllapi.h> +#include <salhelper/simplereferenceobject.hxx> +#include <salhelper/thread.hxx> +#include <sax/tools/converter.hxx> +#include <sfx2/app.hxx> +#include <sfx2/basedlgs.hxx> +#include <sfx2/bindings.hxx> +#include <sfx2/chalign.hxx> +#include <sfx2/childwin.hxx> +#include <sfx2/dispatch.hxx> +#include <sfx2/dllapi.h> +#include <sfx2/docfile.hxx> +#include <sfx2/linkmgr.hxx> +#include <sfx2/lokhelper.hxx> +#include <sfx2/objface.hxx> +#include <sfx2/objsh.hxx> +#include <sfx2/printer.hxx> +#include <sfx2/request.hxx> +#include <sfx2/shell.hxx> +#include <sfx2/viewfrm.hxx> +#include <sot/exchange.hxx> +#include <sot/formats.hxx> +#include <sot/sotdllapi.h> +#include <svl/SfxBroadcaster.hxx> +#include <svl/cenumitm.hxx> +#include <svl/eitem.hxx> +#include <svl/hint.hxx> +#include <svl/intitem.hxx> +#include <svl/itempool.hxx> +#include <svl/itemprop.hxx> +#include <svl/itemset.hxx> +#include <svl/languageoptions.hxx> +#include <svl/lstner.hxx> +#include <svl/numformat.hxx> +#include <svl/poolitem.hxx> +#include <svl/sharedstring.hxx> +#include <svl/sharedstringpool.hxx> +#include <svl/stritem.hxx> +#include <svl/style.hxx> +#include <svl/stylesheetuser.hxx> +#include <svl/svldllapi.h> +#include <svl/typedwhich.hxx> +#include <svl/undo.hxx> +#include <svl/whichranges.hxx> +#include <svl/whiter.hxx> +#include <svl/zforlist.hxx> +#include <svl/zformat.hxx> +#include <svtools/colorcfg.hxx> +#include <svtools/svtdllapi.h> +#include <svtools/toolboxcontroller.hxx> +#include <svx/XPropertyEntry.hxx> +#include <svx/algitem.hxx> +#include <svx/itextprovider.hxx> +#include <svx/sdr/animation/scheduler.hxx> +#include <svx/sdr/overlay/overlayobject.hxx> +#include <svx/sdr/overlay/overlayobjectlist.hxx> +#include <svx/sdr/properties/defaultproperties.hxx> +#include <svx/sdr/properties/properties.hxx> +#include <svx/sdrobjectuser.hxx> +#include <svx/sdtaditm.hxx> +#include <svx/sdtaitm.hxx> +#include <svx/sdtakitm.hxx> +#include <svx/svddef.hxx> +#include <svx/svddrag.hxx> +#include <svx/svdglue.hxx> +#include <svx/svdhdl.hxx> +#include <svx/svdhlpln.hxx> +#include <svx/svditer.hxx> +#include <svx/svdlayer.hxx> +#include <svx/svdmark.hxx> +#include <svx/svdmodel.hxx> +#include <svx/svdmrkv.hxx> +#include <svx/svdoattr.hxx> +#include <svx/svdobj.hxx> +#include <svx/svdocapt.hxx> +#include <svx/svdoedge.hxx> +#include <svx/svdoole2.hxx> +#include <svx/svdotext.hxx> +#include <svx/svdouno.hxx> +#include <svx/svdpage.hxx> +#include <svx/svdpagv.hxx> +#include <svx/svdpntv.hxx> +#include <svx/svdsnpv.hxx> +#include <svx/svdsob.hxx> +#include <svx/svdtext.hxx> +#include <svx/svdtrans.hxx> +#include <svx/svdtypes.hxx> +#include <svx/svdundo.hxx> +#include <svx/svxdlg.hxx> +#include <svx/svxdllapi.h> +#include <svx/xdash.hxx> +#include <svx/xdef.hxx> +#include <svx/xhatch.hxx> +#include <svx/xit.hxx> +#include <svx/xpoly.hxx> +#include <svx/xtable.hxx> +#include <tools/color.hxx> +#include <tools/date.hxx> +#include <tools/datetime.hxx> +#include <tools/degree.hxx> +#include <comphelper/diagnose_ex.hxx> +#include <tools/fldunit.hxx> +#include <tools/fontenum.hxx> +#include <tools/fract.hxx> +#include <tools/gen.hxx> +#include <tools/globname.hxx> +#include <tools/helpers.hxx> +#include <tools/lineend.hxx> +#include <tools/link.hxx> +#include <tools/long.hxx> +#include <tools/mapunit.hxx> +#include <tools/poly.hxx> +#include <tools/ref.hxx> +#include <tools/solar.h> +#include <tools/stream.hxx> +#include <tools/time.hxx> +#include <tools/toolsdllapi.h> +#include <tools/urlobj.hxx> +#include <tools/weakbase.h> +#include <tools/weakbase.hxx> +#include <typelib/typeclass.h> +#include <typelib/typedescription.h> +#include <typelib/uik.h> +#include <uno/any2.h> +#include <uno/data.h> +#include <uno/sequence2.h> +#include <unotools/charclass.hxx> +#include <unotools/collatorwrapper.hxx> +#include <unotools/configitem.hxx> +#include <unotools/configmgr.hxx> +#include <unotools/options.hxx> +#include <unotools/resmgr.hxx> +#include <unotools/syslocale.hxx> +#include <unotools/transliterationwrapper.hxx> +#include <unotools/unotoolsdllapi.h> +#include <xmloff/dllapi.h> +#include <xmloff/namespacemap.hxx> +#include <xmloff/xmlictxt.hxx> +#include <xmloff/xmlnamespace.hxx> +#include <xmloff/xmltoken.hxx> +#endif // PCH_LEVEL >= 3 +#if PCH_LEVEL >= 4 +#include <AccessibleContextBase.hxx> +#include <IAnyRefDialog.hxx> +#include <Sparkline.hxx> +#include <SparklineGroup.hxx> +#include <TableFillingAndNavigationTools.hxx> +#include <address.hxx> +#include <anyrefdg.hxx> +#include <appoptio.hxx> +#include <attrib.hxx> +#include <brdcst.hxx> +#include <calcmacros.hxx> +#include <cellform.hxx> +#include <cellsuno.hxx> +#include <cellvalue.hxx> +#include <chartlis.hxx> +#include <chgtrack.hxx> +#include <clipparam.hxx> +#include <colorscale.hxx> +#include <column.hxx> +#include <columnspanset.hxx> +#include <compiler.hxx> +#include <conditio.hxx> +#include <convuno.hxx> +#include <datamapper.hxx> +#include <dbdata.hxx> +#include <dbdocfun.hxx> +#include <dbfunc.hxx> +#include <docfunc.hxx> +#include <dociter.hxx> +#include <docoptio.hxx> +#include <docpool.hxx> +#include <docsh.hxx> +#include <document.hxx> +#include <documentlinkmgr.hxx> +#include <docuno.hxx> +#include <dpobject.hxx> +#include <dpsave.hxx> +#include <dpshttab.hxx> +#include <dputil.hxx> +#include <drawview.hxx> +#include <drwlayer.hxx> +#include <editable.hxx> +#include <editsrc.hxx> +#include <editutil.hxx> +#include <externalrefmgr.hxx> +#include <fillinfo.hxx> +#include <formula/IControlReferenceHandler.hxx> +#include <formula/compiler.hxx> +#include <formula/errorcodes.hxx> +#include <formula/formuladllapi.h> +#include <formula/funcutl.hxx> +#include <formula/opcode.hxx> +#include <formula/token.hxx> +#include <formula/vectortoken.hxx> +#include <formulacell.hxx> +#include <funcdesc.hxx> +#include <global.hxx> +#include <globalnames.hxx> +#include <gridwin.hxx> +#include <hints.hxx> +#include <inputhdl.hxx> +#include <inputopt.hxx> +#include <inputwin.hxx> +#include <interpre.hxx> +#include <listenercontext.hxx> +#include <markdata.hxx> +#include <miscuno.hxx> +#include <mtvelements.hxx> +#include <olinetab.hxx> +#include <output.hxx> +#include <patattr.hxx> +#include <postit.hxx> +#include <prevwsh.hxx> +#include <printfun.hxx> +#include <queryentry.hxx> +#include <queryparam.hxx> +#include <rangelst.hxx> +#include <rangenam.hxx> +#include <rangeutl.hxx> +#include <refdata.hxx> +#include <reffact.hxx> +#include <refundo.hxx> +#include <refupdat.hxx> +#include <refupdatecontext.hxx> +#include <rowheightcontext.hxx> +#include <scabstdlg.hxx> +#include <scdllapi.h> +#include <scitems.hxx> +#include <scmatrix.hxx> +#include <scmod.hxx> +#include <scopetools.hxx> +#include <scresid.hxx> +#include <segmenttree.hxx> +#include <sheetdata.hxx> +#include <sheetevents.hxx> +#include <shellids.hxx> +#include <stlpool.hxx> +#include <stlsheet.hxx> +#include <stringutil.hxx> +#include <table.hxx> +#include <tablink.hxx> +#include <tabprotection.hxx> +#include <tabvwsh.hxx> +#include <tokenarray.hxx> +#include <tokenstringcontext.hxx> +#include <transobj.hxx> +#include <types.hxx> +#include <uiitems.hxx> +#include <undobase.hxx> +#include <undoblk.hxx> +#include <unonames.hxx> +#include <userdat.hxx> +#include <validat.hxx> +#include <viewdata.hxx> +#include <xlconst.hxx> +#include <xlroot.hxx> +#endif // PCH_LEVEL >= 4 + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/pch/precompiled_scfilt.cxx b/sc/inc/pch/precompiled_scfilt.cxx new file mode 100644 index 0000000000..ab6d9c7989 --- /dev/null +++ b/sc/inc/pch/precompiled_scfilt.cxx @@ -0,0 +1,12 @@ +/* -*- 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/. + */ + +#include "precompiled_scfilt.hxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/pch/precompiled_scfilt.hxx b/sc/inc/pch/precompiled_scfilt.hxx new file mode 100644 index 0000000000..c44c422833 --- /dev/null +++ b/sc/inc/pch/precompiled_scfilt.hxx @@ -0,0 +1,414 @@ +/* -*- 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 has been autogenerated by update_pch.sh. It is possible to edit it + manually (such as when an include file has been moved/renamed/removed). All such + manual changes will be rewritten by the next run of update_pch.sh (which presumably + also fixes all possible problems, so it's usually better to use it). + + Generated on 2021-03-08 13:15:21 using: + ./bin/update_pch sc scfilt --cutoff=4 --exclude:system --exclude:module --include:local + + If after updating build fails, use the following command to locate conflicting headers: + ./bin/update_pch_bisect ./sc/inc/pch/precompiled_scfilt.hxx "make sc.build" --find-conflicts +*/ + +#include <sal/config.h> +#if PCH_LEVEL >= 1 +#include <algorithm> +#include <cassert> +#include <cstddef> +#include <cstdlib> +#include <cstring> +#include <functional> +#include <iomanip> +#include <limits.h> +#include <limits> +#include <map> +#include <math.h> +#include <memory> +#include <new> +#include <optional> +#include <ostream> +#include <set> +#include <stack> +#include <stdexcept> +#include <stdio.h> +#include <string.h> +#include <string_view> +#include <type_traits> +#include <unordered_map> +#include <unordered_set> +#include <utility> +#include <vector> +#include <boost/property_tree/ptree_fwd.hpp> +#endif // PCH_LEVEL >= 1 +#if PCH_LEVEL >= 2 +#include <osl/diagnose.h> +#include <osl/endian.h> +#include <osl/file.hxx> +#include <osl/interlck.h> +#include <osl/mutex.h> +#include <osl/mutex.hxx> +#include <osl/thread.h> +#include <osl/thread.hxx> +#include <rtl/alloc.h> +#include <rtl/character.hxx> +#include <rtl/instance.hxx> +#include <rtl/math.h> +#include <rtl/math.hxx> +#include <rtl/random.h> +#include <rtl/ref.hxx> +#include <rtl/strbuf.hxx> +#include <rtl/string.h> +#include <rtl/string.hxx> +#include <rtl/stringconcat.hxx> +#include <rtl/stringutils.hxx> +#include <rtl/tencinfo.h> +#include <rtl/textenc.h> +#include <rtl/ustrbuf.hxx> +#include <rtl/ustring.h> +#include <rtl/ustring.hxx> +#include <rtl/uuid.h> +#include <sal/log.hxx> +#include <sal/macros.h> +#include <sal/mathconf.h> +#include <sal/saldllapi.h> +#include <sal/types.h> +#include <vcl/GraphicExternalLink.hxx> +#include <vcl/GraphicObject.hxx> +#include <vcl/animate/Animation.hxx> +#include <vcl/bitmapex.hxx> +#include <vcl/checksum.hxx> +#include <vcl/dllapi.h> +#include <comphelper/errcode.hxx> +#include <vcl/font.hxx> +#include <vcl/gfxlink.hxx> +#include <vcl/graph.hxx> +#include <vcl/mapmod.hxx> +#include <vcl/outdev.hxx> +#include <vcl/svapp.hxx> +#include <vcl/vclptr.hxx> +#include <vcl/vectorgraphicdata.hxx> +#endif // PCH_LEVEL >= 2 +#if PCH_LEVEL >= 3 +#include <basegfx/basegfxdllapi.h> +#include <basegfx/color/bcolor.hxx> +#include <basegfx/vector/b2dsize.hxx> +#include <com/sun/star/awt/DeviceInfo.hpp> +#include <com/sun/star/awt/Point.hpp> +#include <com/sun/star/awt/Rectangle.hpp> +#include <com/sun/star/awt/Size.hpp> +#include <com/sun/star/beans/Pair.hpp> +#include <com/sun/star/beans/PropertyState.hpp> +#include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/chart/XChartDocument.hpp> +#include <com/sun/star/chart2/XChartDocument.hpp> +#include <com/sun/star/container/XIndexAccess.hpp> +#include <com/sun/star/container/XIndexContainer.hpp> +#include <com/sun/star/container/XNameContainer.hpp> +#include <com/sun/star/document/XDocumentProperties.hpp> +#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> +#include <com/sun/star/drawing/BitmapMode.hpp> +#include <com/sun/star/drawing/Hatch.hpp> +#include <com/sun/star/drawing/TextFitToSizeType.hpp> +#include <com/sun/star/frame/XModel.hpp> +#include <com/sun/star/graphic/XGraphicMapper.hpp> +#include <com/sun/star/graphic/XGraphicProvider2.hpp> +#include <com/sun/star/i18n/ScriptType.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/lang/XTypeProvider.hpp> +#include <com/sun/star/lang/XUnoTunnel.hpp> +#include <com/sun/star/sheet/ConditionOperator.hpp> +#include <com/sun/star/sheet/DataPilotFieldGroupBy.hpp> +#include <com/sun/star/sheet/DataPilotFieldOrientation.hpp> +#include <com/sun/star/sheet/DataPilotFieldReferenceItemType.hpp> +#include <com/sun/star/sheet/FormulaLanguage.hpp> +#include <com/sun/star/sheet/FormulaToken.hpp> +#include <com/sun/star/sheet/XSpreadsheet.hpp> +#include <com/sun/star/sheet/XSpreadsheetDocument.hpp> +#include <com/sun/star/style/NumberingType.hpp> +#include <com/sun/star/table/CellAddress.hpp> +#include <com/sun/star/uno/Any.h> +#include <com/sun/star/uno/Any.hxx> +#include <com/sun/star/uno/Reference.h> +#include <com/sun/star/uno/Reference.hxx> +#include <com/sun/star/uno/Sequence.h> +#include <com/sun/star/uno/Sequence.hxx> +#include <com/sun/star/uno/Type.h> +#include <com/sun/star/uno/genfunc.hxx> +#include <com/sun/star/util/DateTime.hpp> +#include <com/sun/star/xml/sax/XFastAttributeList.hpp> +#include <com/sun/star/xml/sax/XFastContextHandler.hpp> +#include <comphelper/comphelperdllapi.h> +#include <comphelper/processfactory.hxx> +#include <comphelper/servicehelper.hxx> +#include <comphelper/string.hxx> +#include <cppu/unotype.hxx> +#include <cppuhelper/implbase.hxx> +#include <cppuhelper/implbase_ex.hxx> +#include <cppuhelper/weak.hxx> +#include <cppuhelper/weakref.hxx> +#include <drawinglayer/primitive2d/Primitive2DContainer.hxx> +#include <editeng/borderline.hxx> +#include <editeng/boxitem.hxx> +#include <editeng/brushitem.hxx> +#include <editeng/colritem.hxx> +#include <editeng/crossedoutitem.hxx> +#include <editeng/editdata.hxx> +#include <editeng/editengdllapi.h> +#include <editeng/editobj.hxx> +#include <editeng/eeitem.hxx> +#include <editeng/escapementitem.hxx> +#include <editeng/fhgtitem.hxx> +#include <editeng/flditem.hxx> +#include <editeng/fontitem.hxx> +#include <editeng/justifyitem.hxx> +#include <editeng/lineitem.hxx> +#include <editeng/postitem.hxx> +#include <editeng/svxenum.hxx> +#include <editeng/udlnitem.hxx> +#include <editeng/wghtitem.hxx> +#include <filter/msfilter/msfilterdllapi.h> +#include <filter/msfilter/msocximex.hxx> +#include <i18nlangtag/lang.h> +#include <o3tl/cow_wrapper.hxx> +#include <o3tl/safeint.hxx> +#include <o3tl/sorted_vector.hxx> +#include <o3tl/strong_int.hxx> +#include <o3tl/typed_flags_set.hxx> +#include <o3tl/underlyingenumvalue.hxx> +#include <o3tl/unit_conversion.hxx> +#include <oox/core/contexthandler.hxx> +#include <oox/core/contexthandler2.hxx> +#include <oox/core/filterbase.hxx> +#include <oox/core/fragmenthandler2.hxx> +#include <oox/core/relations.hxx> +#include <oox/dllapi.h> +#include <oox/drawingml/drawingmltypes.hxx> +#include <oox/export/utils.hxx> +#include <oox/helper/attributelist.hxx> +#include <oox/helper/binaryinputstream.hxx> +#include <oox/helper/binarystreambase.hxx> +#include <oox/helper/containerhelper.hxx> +#include <oox/helper/graphichelper.hxx> +#include <oox/helper/helper.hxx> +#include <oox/helper/progressbar.hxx> +#include <oox/helper/propertyset.hxx> +#include <oox/helper/refmap.hxx> +#include <oox/helper/refvector.hxx> +#include <oox/helper/storagebase.hxx> +#include <oox/ole/olehelper.hxx> +#include <oox/token/namespaces.hxx> +#include <oox/token/properties.hxx> +#include <oox/token/relationship.hxx> +#include <oox/token/tokens.hxx> +#include <salhelper/simplereferenceobject.hxx> +#include <sax/fastattribs.hxx> +#include <sax/fshelper.hxx> +#include <sax/saxdllapi.h> +#include <sax/tools/converter.hxx> +#include <sfx2/dllapi.h> +#include <sfx2/docfile.hxx> +#include <sfx2/frame.hxx> +#include <sfx2/objsh.hxx> +#include <sot/storage.hxx> +#include <svl/cenumitm.hxx> +#include <svl/eitem.hxx> +#include <svl/hint.hxx> +#include <svl/intitem.hxx> +#include <svl/itemset.hxx> +#include <svl/listener.hxx> +#include <svl/lstner.hxx> +#include <svl/poolitem.hxx> +#include <svl/sharedstring.hxx> +#include <svl/sharedstringpool.hxx> +#include <svl/stritem.hxx> +#include <svl/style.hxx> +#include <svl/svldllapi.h> +#include <svl/typedwhich.hxx> +#include <svl/zforlist.hxx> +#include <svtools/svtdllapi.h> +#include <svx/itextprovider.hxx> +#include <svx/msdffdef.hxx> +#include <svx/sdtaditm.hxx> +#include <svx/sdtaitm.hxx> +#include <svx/sdtakitm.hxx> +#include <svx/svddef.hxx> +#include <svx/svdoattr.hxx> +#include <svx/svdoole2.hxx> +#include <svx/svdorect.hxx> +#include <svx/svdotext.hxx> +#include <svx/svdpage.hxx> +#include <svx/svdtext.hxx> +#include <svx/svdtrans.hxx> +#include <svx/svdtypes.hxx> +#include <svx/svxdllapi.h> +#include <svx/unoapi.hxx> +#include <svx/xit.hxx> +#include <tools/UnitConversion.hxx> +#include <tools/color.hxx> +#include <tools/date.hxx> +#include <tools/datetime.hxx> +#include <tools/degree.hxx> +#include <comphelper/diagnose_ex.hxx> +#include <tools/fract.hxx> +#include <tools/gen.hxx> +#include <tools/link.hxx> +#include <tools/long.hxx> +#include <tools/mapunit.hxx> +#include <tools/ref.hxx> +#include <tools/solar.h> +#include <tools/stream.hxx> +#include <tools/time.hxx> +#include <tools/toolsdllapi.h> +#include <tools/urlobj.hxx> +#include <typelib/typedescription.h> +#include <uno/data.h> +#include <unotools/charclass.hxx> +#include <unotools/configitem.hxx> +#include <unotools/configmgr.hxx> +#include <unotools/fltrcfg.hxx> +#include <unotools/options.hxx> +#include <unotools/textsearch.hxx> +#include <unotools/unotoolsdllapi.h> +#endif // PCH_LEVEL >= 3 +#if PCH_LEVEL >= 4 +#include <address.hxx> +#include <addressconverter.hxx> +#include <attrib.hxx> +#include <autofilterbuffer.hxx> +#include <biffhelper.hxx> +#include <calcmacros.hxx> +#include <cellvalue.hxx> +#include <colrowst.hxx> +#include <compiler.hxx> +#include <condformatbuffer.hxx> +#include <conditio.hxx> +#include <connectionsbuffer.hxx> +#include <convuno.hxx> +#include <dbdata.hxx> +#include <defnamesbuffer.hxx> +#include <docoptio.hxx> +#include <docpool.hxx> +#include <docsh.hxx> +#include <document.hxx> +#include <documentimport.hxx> +#include <docuno.hxx> +#include <dpdimsave.hxx> +#include <dpglobal.hxx> +#include <dpobject.hxx> +#include <dpsave.hxx> +#include <drawingfragment.hxx> +#include <drwlayer.hxx> +#include <editutil.hxx> +#include <excelhandlers.hxx> +#include <excform.hxx> +#include <excimp8.hxx> +#include <excrecds.hxx> +#include <externallinkbuffer.hxx> +#include <externalrefmgr.hxx> +#include <extlstcontext.hxx> +#include <fapihelper.hxx> +#include <filter.hxx> +#include <formel.hxx> +#include <formula/errorcodes.hxx> +#include <formula/formuladllapi.h> +#include <formula/grammar.hxx> +#include <formula/opcode.hxx> +#include <formulabase.hxx> +#include <formulabuffer.hxx> +#include <formulacell.hxx> +#include <formulaparser.hxx> +#include <fprogressbar.hxx> +#include <ftools.hxx> +#include <global.hxx> +#include <imp_op.hxx> +#include <namebuff.hxx> +#include <pagesettings.hxx> +#include <patattr.hxx> +#include <pivotcachebuffer.hxx> +#include <postit.hxx> +#include <queryparam.hxx> +#include <rangelst.hxx> +#include <rangenam.hxx> +#include <refdata.hxx> +#include <richstring.hxx> +#include <richstringcontext.hxx> +#include <root.hxx> +#include <scdllapi.h> +#include <scerrors.hxx> +#include <scextopt.hxx> +#include <scitems.hxx> +#include <scmatrix.hxx> +#include <scresid.hxx> +#include <sharedstringsbuffer.hxx> +#include <sheetdatabuffer.hxx> +#include <stlpool.hxx> +#include <stlsheet.hxx> +#include <stringutil.hxx> +#include <stylesbuffer.hxx> +#include <stylesfragment.hxx> +#include <tablebuffer.hxx> +#include <tabprotection.hxx> +#include <themebuffer.hxx> +#include <tokenarray.hxx> +#include <tokenuno.hxx> +#include <tokstack.hxx> +#include <tool.h> +#include <types.hxx> +#include <unitconverter.hxx> +#include <unonames.hxx> +#include <userdat.hxx> +#include <viewsettings.hxx> +#include <workbookhelper.hxx> +#include <workbooksettings.hxx> +#include <worksheetbuffer.hxx> +#include <worksheethelper.hxx> +#include <worksheetsettings.hxx> +#include <xcl97rec.hxx> +#include <xecontent.hxx> +#include <xeescher.hxx> +#include <xeformula.hxx> +#include <xehelper.hxx> +#include <xelink.hxx> +#include <xename.hxx> +#include <xerecord.hxx> +#include <xeroot.hxx> +#include <xestream.hxx> +#include <xestring.hxx> +#include <xestyle.hxx> +#include <xicontent.hxx> +#include <xiescher.hxx> +#include <xiformula.hxx> +#include <xihelper.hxx> +#include <xilink.hxx> +#include <xiname.hxx> +#include <xipage.hxx> +#include <xiroot.hxx> +#include <xistream.hxx> +#include <xistyle.hxx> +#include <xiview.hxx> +#include <xladdress.hxx> +#include <xlconst.hxx> +#include <xlcontent.hxx> +#include <xlformula.hxx> +#include <xllink.hxx> +#include <xlname.hxx> +#include <xlroot.hxx> +#include <xlstream.hxx> +#include <xlstyle.hxx> +#include <xltools.hxx> +#include <xltracer.hxx> +#endif // PCH_LEVEL >= 4 + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/pch/precompiled_scui.cxx b/sc/inc/pch/precompiled_scui.cxx new file mode 100644 index 0000000000..ccd24c0700 --- /dev/null +++ b/sc/inc/pch/precompiled_scui.cxx @@ -0,0 +1,12 @@ +/* -*- 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/. + */ + +#include "precompiled_scui.hxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/pch/precompiled_scui.hxx b/sc/inc/pch/precompiled_scui.hxx new file mode 100644 index 0000000000..478adc2ddc --- /dev/null +++ b/sc/inc/pch/precompiled_scui.hxx @@ -0,0 +1,210 @@ +/* -*- 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 has been autogenerated by update_pch.sh. It is possible to edit it + manually (such as when an include file has been moved/renamed/removed). All such + manual changes will be rewritten by the next run of update_pch.sh (which presumably + also fixes all possible problems, so it's usually better to use it). + + Generated on 2021-03-08 13:14:26 using: + ./bin/update_pch sc scui --cutoff=1 --exclude:system --exclude:module --include:local + + If after updating build fails, use the following command to locate conflicting headers: + ./bin/update_pch_bisect ./sc/inc/pch/precompiled_scui.hxx "make sc.build" --find-conflicts +*/ + +#include <sal/config.h> +#if PCH_LEVEL >= 1 +#include <memory> +#include <utility> +#include <vector> +#endif // PCH_LEVEL >= 1 +#if PCH_LEVEL >= 2 +#include <osl/diagnose.h> +#include <osl/thread.h> +#include <osl/time.h> +#include <rtl/math.hxx> +#include <rtl/tencinfo.h> +#include <sal/types.h> +#include <vcl/event.hxx> +#include <vcl/settings.hxx> +#include <vcl/svapp.hxx> +#include <vcl/virdev.hxx> +#include <vcl/weld.hxx> +#endif // PCH_LEVEL >= 2 +#if PCH_LEVEL >= 3 +#include <com/sun/star/sdb/DatabaseContext.hpp> +#include <com/sun/star/sdb/XCompletedConnection.hpp> +#include <com/sun/star/sdb/XQueriesSupplier.hpp> +#include <com/sun/star/sdbcx/XTablesSupplier.hpp> +#include <com/sun/star/sheet/DataImportMode.hpp> +#include <com/sun/star/sheet/DataPilotFieldGroupBy.hpp> +#include <com/sun/star/sheet/DataPilotFieldLayoutMode.hpp> +#include <com/sun/star/sheet/DataPilotFieldReferenceItemType.hpp> +#include <com/sun/star/sheet/DataPilotFieldReferenceType.hpp> +#include <com/sun/star/sheet/DataPilotFieldShowItemsMode.hpp> +#include <com/sun/star/sheet/DataPilotFieldSortMode.hpp> +#include <com/sun/star/task/InteractionHandler.hpp> +#include <com/sun/star/uno/Any.hxx> +#include <com/sun/star/uno/Sequence.hxx> +#include <comphelper/lok.hxx> +#include <comphelper/processfactory.hxx> +#include <comphelper/string.hxx> +#include <editeng/editobj.hxx> +#include <editeng/eeitem.hxx> +#include <editeng/flditem.hxx> +#include <editeng/flstitem.hxx> +#include <i18nlangtag/languagetag.hxx> +#include <officecfg/Office/Calc.hxx> +#include <officecfg/Office/Common.hxx> +#include <sfx2/basedlgs.hxx> +#include <sfx2/docfile.hxx> +#include <sfx2/docfilt.hxx> +#include <sfx2/docinsert.hxx> +#include <sfx2/fcontnr.hxx> +#include <sfx2/filedlghelper.hxx> +#include <sfx2/objsh.hxx> +#include <sfx2/sfxdlg.hxx> +#include <sfx2/sfxresid.hxx> +#include <sfx2/tabdlg.hxx> +#include <svl/cjkoptions.hxx> +#include <svl/eitem.hxx> +#include <svl/intitem.hxx> +#include <svl/sharedstringpool.hxx> +#include <svl/style.hxx> +#include <svl/typedwhich.hxx> +#include <svl/zforlist.hxx> +#include <svtools/collatorres.hxx> +#include <svtools/ctrlbox.hxx> +#include <svtools/ehdl.hxx> +#include <svtools/inettbc.hxx> +#include <svtools/restartdialog.hxx> +#include <svtools/sfxecode.hxx> +#include <svtools/unitconv.hxx> +#include <svx/colorbox.hxx> +#include <svx/flagsdef.hxx> +#include <svx/langbox.hxx> +#include <svx/numinf.hxx> +#include <svx/pageitem.hxx> +#include <svx/txencbox.hxx> +#include <tools/color.hxx> +#include <comphelper/diagnose_ex.hxx> +#include <tools/fldunit.hxx> +#include <tools/lineend.hxx> +#include <unicode/ucsdet.h> +#include <unotools/collatorwrapper.hxx> +#include <unotools/localedatawrapper.hxx> +#include <unotools/transliterationwrapper.hxx> +#include <unotools/useroptions.hxx> +#endif // PCH_LEVEL >= 3 +#if PCH_LEVEL >= 4 +#include <appoptio.hxx> +#include <attrdlg.hxx> +#include <attrib.hxx> +#include <autoform.hxx> +#include <calcconfig.hxx> +#include <compiler.hxx> +#include <condformatdlg.hxx> +#include <condformathelper.hxx> +#include <condformatmgr.hxx> +#include <conditio.hxx> +#include <corodlg.hxx> +#include <crdlg.hxx> +#include <csvtablebox.hxx> +#include <dapidata.hxx> +#include <dapitype.hxx> +#include <datafdlg.hxx> +#include <dbdata.hxx> +#include <defaultsoptions.hxx> +#include <delcldlg.hxx> +#include <delcodlg.hxx> +#include <docoptio.hxx> +#include <docsh.hxx> +#include <document.hxx> +#include <dpgroupdlg.hxx> +#include <dpobject.hxx> +#include <dpsave.hxx> +#include <dpsdbtab.hxx> +#include <dputil.hxx> +#include <editfield.hxx> +#include <editutil.hxx> +#include <filldlg.hxx> +#include <filterentries.hxx> +#include <formula/grammar.hxx> +#include <formulaopt.hxx> +#include <global.hxx> +#include <globalnames.hxx> +#include <gototabdlg.hxx> +#include <groupdlg.hxx> +#include <helpids.h> +#include <hfedtdlg.hxx> +#include <imoptdlg.hxx> +#include <impex.hxx> +#include <inscldlg.hxx> +#include <inscodlg.hxx> +#include <instbdlg.hxx> +#include <lbseldlg.hxx> +#include <linkarea.hxx> +#include <miscuno.hxx> +#include <mtrindlg.hxx> +#include <mvtabdlg.hxx> +#include <namecrea.hxx> +#include <namepast.hxx> +#include <opredlin.hxx> +#include <optutil.hxx> +#include <patattr.hxx> +#include <pfiltdlg.hxx> +#include <printopt.hxx> +#include <pvfundlg.hxx> +#include <queryentry.hxx> +#include <rangenam.hxx> +#include <rangeutl.hxx> +#include <scabstdlg.hxx> +#include <scendlg.hxx> +#include <scitems.hxx> +#include <scmod.hxx> +#include <scresid.hxx> +#include <scui_def.hxx> +#include <scuiasciiopt.hxx> +#include <scuiautofmt.hxx> +#include <scuiimoptdlg.hxx> +#include <scuitphfedit.hxx> +#include <shtabdlg.hxx> +#include <sortdlg.hxx> +#include <sortkeydlg.hxx> +#include <strindlg.hxx> +#include <strings.hxx> +#include <styledlg.hxx> +#include <subtdlg.hxx> +#include <tabbgcolordlg.hxx> +#include <tablink.hxx> +#include <tabpages.hxx> +#include <tabvwsh.hxx> +#include <textdlgs.hxx> +#include <textimportoptions.hxx> +#include <tpcalc.hxx> +#include <tpcompatibility.hxx> +#include <tpdefaults.hxx> +#include <tpformula.hxx> +#include <tphf.hxx> +#include <tpprint.hxx> +#include <tpsort.hxx> +#include <tpstat.hxx> +#include <tpsubt.hxx> +#include <tptable.hxx> +#include <tpusrlst.hxx> +#include <tpview.hxx> +#include <uiitems.hxx> +#include <userlist.hxx> +#include <viewdata.hxx> +#include <viewopti.hxx> +#endif // PCH_LEVEL >= 4 + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/pch/precompiled_vbaobj.cxx b/sc/inc/pch/precompiled_vbaobj.cxx new file mode 100644 index 0000000000..2f8e7fea0d --- /dev/null +++ b/sc/inc/pch/precompiled_vbaobj.cxx @@ -0,0 +1,12 @@ +/* -*- 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/. + */ + +#include "precompiled_vbaobj.hxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/pch/precompiled_vbaobj.hxx b/sc/inc/pch/precompiled_vbaobj.hxx new file mode 100644 index 0000000000..64f8ed7357 --- /dev/null +++ b/sc/inc/pch/precompiled_vbaobj.hxx @@ -0,0 +1,350 @@ +/* -*- 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 has been autogenerated by update_pch.sh. It is possible to edit it + manually (such as when an include file has been moved/renamed/removed). All such + manual changes will be rewritten by the next run of update_pch.sh (which presumably + also fixes all possible problems, so it's usually better to use it). + + Generated on 2021-03-08 13:17:35 using: + ./bin/update_pch sc vbaobj --cutoff=1 --exclude:system --exclude:module --include:local + + If after updating build fails, use the following command to locate conflicting headers: + ./bin/update_pch_bisect ./sc/inc/pch/precompiled_vbaobj.hxx "make sc.build" --find-conflicts +*/ + +#include <sal/config.h> +#if PCH_LEVEL >= 1 +#include <algorithm> +#include <list> +#include <map> +#include <memory> +#include <string_view> +#include <unordered_map> +#include <vector> +#endif // PCH_LEVEL >= 1 +#if PCH_LEVEL >= 2 +#include <osl/file.hxx> +#include <rtl/instance.hxx> +#include <rtl/math.hxx> +#include <rtl/ref.hxx> +#include <sal/log.hxx> +#include <sal/macros.h> +#include <vcl/event.hxx> +#include <vcl/svapp.hxx> +#include <vcl/window.hxx> +#include <vcl/wrkwin.hxx> +#endif // PCH_LEVEL >= 2 +#if PCH_LEVEL >= 3 +#include <basic/basmgr.hxx> +#include <basic/sberrors.hxx> +#include <basic/sbmeth.hxx> +#include <basic/sbstar.hxx> +#include <basic/sbuno.hxx> +#include <basic/sbx.hxx> +#include <basic/sbxobj.hxx> +#include <com/sun/star/awt/FontUnderline.hpp> +#include <com/sun/star/awt/TextAlign.hpp> +#include <com/sun/star/awt/XControlModel.hpp> +#include <com/sun/star/awt/XTopWindow.hpp> +#include <com/sun/star/awt/XTopWindowListener.hpp> +#include <com/sun/star/awt/XWindowListener.hpp> +#include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/beans/XIntrospectionAccess.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/bridge/oleautomation/Date.hpp> +#include <com/sun/star/chart/ChartDataRowSource.hpp> +#include <com/sun/star/chart/ChartSolidType.hpp> +#include <com/sun/star/chart/ChartSymbolType.hpp> +#include <com/sun/star/chart/XAxisXSupplier.hpp> +#include <com/sun/star/chart/XAxisYSupplier.hpp> +#include <com/sun/star/chart/XAxisZSupplier.hpp> +#include <com/sun/star/chart/XChartDataArray.hpp> +#include <com/sun/star/chart/XTwoAxisXSupplier.hpp> +#include <com/sun/star/chart/XTwoAxisYSupplier.hpp> +#include <com/sun/star/container/XChild.hpp> +#include <com/sun/star/container/XEnumerationAccess.hpp> +#include <com/sun/star/container/XIndexAccess.hpp> +#include <com/sun/star/container/XIndexContainer.hpp> +#include <com/sun/star/container/XNameAccess.hpp> +#include <com/sun/star/container/XNamed.hpp> +#include <com/sun/star/document/XEmbeddedObjectSupplier.hpp> +#include <com/sun/star/document/XTypeDetection.hpp> +#include <com/sun/star/drawing/XControlShape.hpp> +#include <com/sun/star/drawing/XDrawPageSupplier.hpp> +#include <com/sun/star/drawing/XShape.hpp> +#include <com/sun/star/drawing/XShapes.hpp> +#include <com/sun/star/form/FormComponentType.hpp> +#include <com/sun/star/form/XForm.hpp> +#include <com/sun/star/form/XFormComponent.hpp> +#include <com/sun/star/form/XFormsSupplier.hpp> +#include <com/sun/star/frame/Desktop.hpp> +#include <com/sun/star/frame/XBorderResizeListener.hpp> +#include <com/sun/star/frame/XControllerBorder.hpp> +#include <com/sun/star/frame/XDesktop.hpp> +#include <com/sun/star/frame/XModel.hpp> +#include <com/sun/star/frame/XStorable.hpp> +#include <com/sun/star/lang/IndexOutOfBoundsException.hpp> +#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp> +#include <com/sun/star/lang/XMultiComponentFactory.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/script/ArrayWrapper.hpp> +#include <com/sun/star/script/BasicErrorException.hpp> +#include <com/sun/star/script/ModuleInfo.hpp> +#include <com/sun/star/script/ModuleType.hpp> +#include <com/sun/star/script/ScriptEventDescriptor.hpp> +#include <com/sun/star/script/XEventAttacherManager.hpp> +#include <com/sun/star/script/XTypeConverter.hpp> +#include <com/sun/star/script/vba/VBAEventId.hpp> +#include <com/sun/star/script/vba/XVBACompatibility.hpp> +#include <com/sun/star/script/vba/XVBAEventProcessor.hpp> +#include <com/sun/star/script/vba/XVBAModuleInfo.hpp> +#include <com/sun/star/sheet/CellFlags.hpp> +#include <com/sun/star/sheet/FilterConnection.hpp> +#include <com/sun/star/sheet/FilterOperator2.hpp> +#include <com/sun/star/sheet/FormulaResult.hpp> +#include <com/sun/star/sheet/GeneralFunction.hpp> +#include <com/sun/star/sheet/GlobalSheetSettings.hpp> +#include <com/sun/star/sheet/TableFilterField2.hpp> +#include <com/sun/star/sheet/ValidationAlertStyle.hpp> +#include <com/sun/star/sheet/ValidationType.hpp> +#include <com/sun/star/sheet/XArrayFormulaRange.hpp> +#include <com/sun/star/sheet/XCalculatable.hpp> +#include <com/sun/star/sheet/XCellAddressable.hpp> +#include <com/sun/star/sheet/XCellRangeAddressable.hpp> +#include <com/sun/star/sheet/XCellRangeMovement.hpp> +#include <com/sun/star/sheet/XCellRangeReferrer.hpp> +#include <com/sun/star/sheet/XCellRangesQuery.hpp> +#include <com/sun/star/sheet/XCellSeries.hpp> +#include <com/sun/star/sheet/XDataPilotTable.hpp> +#include <com/sun/star/sheet/XDataPilotTablesSupplier.hpp> +#include <com/sun/star/sheet/XDatabaseRange.hpp> +#include <com/sun/star/sheet/XFunctionAccess.hpp> +#include <com/sun/star/sheet/XGoalSeek.hpp> +#include <com/sun/star/sheet/XHeaderFooterContent.hpp> +#include <com/sun/star/sheet/XNamedRange.hpp> +#include <com/sun/star/sheet/XNamedRanges.hpp> +#include <com/sun/star/sheet/XPrintAreas.hpp> +#include <com/sun/star/sheet/XSheetAnnotation.hpp> +#include <com/sun/star/sheet/XSheetAnnotationAnchor.hpp> +#include <com/sun/star/sheet/XSheetAnnotationShapeSupplier.hpp> +#include <com/sun/star/sheet/XSheetAnnotations.hpp> +#include <com/sun/star/sheet/XSheetAnnotationsSupplier.hpp> +#include <com/sun/star/sheet/XSheetCellCursor.hpp> +#include <com/sun/star/sheet/XSheetCellRange.hpp> +#include <com/sun/star/sheet/XSheetCellRangeContainer.hpp> +#include <com/sun/star/sheet/XSheetCondition.hpp> +#include <com/sun/star/sheet/XSheetConditionalEntry.hpp> +#include <com/sun/star/sheet/XSheetFilterDescriptor2.hpp> +#include <com/sun/star/sheet/XSheetOperation.hpp> +#include <com/sun/star/sheet/XSheetOutline.hpp> +#include <com/sun/star/sheet/XSheetPageBreak.hpp> +#include <com/sun/star/sheet/XSpreadsheet.hpp> +#include <com/sun/star/sheet/XSpreadsheetDocument.hpp> +#include <com/sun/star/sheet/XSpreadsheetView.hpp> +#include <com/sun/star/sheet/XSpreadsheets.hpp> +#include <com/sun/star/sheet/XSubTotalCalculatable.hpp> +#include <com/sun/star/sheet/XSubTotalDescriptor.hpp> +#include <com/sun/star/sheet/XUnnamedDatabaseRanges.hpp> +#include <com/sun/star/sheet/XUsedAreaCursor.hpp> +#include <com/sun/star/sheet/XViewFreezable.hpp> +#include <com/sun/star/sheet/XViewSplitable.hpp> +#include <com/sun/star/style/VerticalAlignment.hpp> +#include <com/sun/star/style/XStyleFamiliesSupplier.hpp> +#include <com/sun/star/table/CellAddress.hpp> +#include <com/sun/star/table/CellContentType.hpp> +#include <com/sun/star/table/CellHoriJustify.hpp> +#include <com/sun/star/table/CellOrientation.hpp> +#include <com/sun/star/table/CellRangeAddress.hpp> +#include <com/sun/star/table/CellVertJustify2.hpp> +#include <com/sun/star/table/TableBorder.hpp> +#include <com/sun/star/table/TableSortField.hpp> +#include <com/sun/star/table/XCell.hpp> +#include <com/sun/star/table/XCellRange.hpp> +#include <com/sun/star/table/XColumnRowRange.hpp> +#include <com/sun/star/table/XTableChart.hpp> +#include <com/sun/star/table/XTableChartsSupplier.hpp> +#include <com/sun/star/table/XTableColumns.hpp> +#include <com/sun/star/table/XTableRows.hpp> +#include <com/sun/star/task/XStatusIndicator.hpp> +#include <com/sun/star/task/XStatusIndicatorSupplier.hpp> +#include <com/sun/star/text/WritingMode.hpp> +#include <com/sun/star/text/XSimpleText.hpp> +#include <com/sun/star/text/XText.hpp> +#include <com/sun/star/text/XTextCursor.hpp> +#include <com/sun/star/text/XTextFieldsSupplier.hpp> +#include <com/sun/star/text/XTextRange.hpp> +#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp> +#include <com/sun/star/ui/dialogs/FilePicker.hpp> +#include <com/sun/star/ui/dialogs/FolderPicker.hpp> +#include <com/sun/star/ui/dialogs/TemplateDescription.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/util/CellProtection.hpp> +#include <com/sun/star/util/NumberFormat.hpp> +#include <com/sun/star/util/PathSettings.hpp> +#include <com/sun/star/util/TriState.hpp> +#include <com/sun/star/util/XChangesListener.hpp> +#include <com/sun/star/util/XChangesNotifier.hpp> +#include <com/sun/star/util/XMergeable.hpp> +#include <com/sun/star/util/XNumberFormatTypes.hpp> +#include <com/sun/star/util/XNumberFormats.hpp> +#include <com/sun/star/util/XNumberFormatsSupplier.hpp> +#include <com/sun/star/util/XProtectable.hpp> +#include <com/sun/star/util/XReplaceable.hpp> +#include <com/sun/star/util/XSortable.hpp> +#include <com/sun/star/view/DocumentZoomType.hpp> +#include <com/sun/star/view/XSelectionSupplier.hpp> +#include <com/sun/star/xml/AttributeData.hpp> +#include <comphelper/documentinfo.hxx> +#include <comphelper/processfactory.hxx> +#include <comphelper/sequence.hxx> +#include <comphelper/servicehelper.hxx> +#include <comphelper/types.hxx> +#include <cppuhelper/exc_hlp.hxx> +#include <cppuhelper/implbase.hxx> +#include <filter/msfilter/msvbahelper.hxx> +#include <filter/msfilter/util.hxx> +#include <o3tl/any.hxx> +#include <o3tl/safeint.hxx> +#include <o3tl/unit_conversion.hxx> +#include <ooo/vba/XCommandBarControls.hpp> +#include <ooo/vba/XCommandBars.hpp> +#include <ooo/vba/XControlProvider.hpp> +#include <ooo/vba/excel/Constants.hpp> +#include <ooo/vba/excel/XApplication.hpp> +#include <ooo/vba/excel/XApplicationOutgoing.hpp> +#include <ooo/vba/excel/XAxis.hpp> +#include <ooo/vba/excel/XDialog.hpp> +#include <ooo/vba/excel/XFont.hpp> +#include <ooo/vba/excel/XFormatCondition.hpp> +#include <ooo/vba/excel/XOLEObject.hpp> +#include <ooo/vba/excel/XPivotTable.hpp> +#include <ooo/vba/excel/XRange.hpp> +#include <ooo/vba/excel/XStyle.hpp> +#include <ooo/vba/excel/XWorksheet.hpp> +#include <ooo/vba/excel/XlAutoFillType.hpp> +#include <ooo/vba/excel/XlAutoFilterOperator.hpp> +#include <ooo/vba/excel/XlAxisCrosses.hpp> +#include <ooo/vba/excel/XlAxisGroup.hpp> +#include <ooo/vba/excel/XlAxisType.hpp> +#include <ooo/vba/excel/XlBorderWeight.hpp> +#include <ooo/vba/excel/XlBordersIndex.hpp> +#include <ooo/vba/excel/XlCalculation.hpp> +#include <ooo/vba/excel/XlCellType.hpp> +#include <ooo/vba/excel/XlChartType.hpp> +#include <ooo/vba/excel/XlColorIndex.hpp> +#include <ooo/vba/excel/XlConsolidationFunction.hpp> +#include <ooo/vba/excel/XlDVAlertStyle.hpp> +#include <ooo/vba/excel/XlDVType.hpp> +#include <ooo/vba/excel/XlDeleteShiftDirection.hpp> +#include <ooo/vba/excel/XlDirection.hpp> +#include <ooo/vba/excel/XlEnableSelection.hpp> +#include <ooo/vba/excel/XlFileFormat.hpp> +#include <ooo/vba/excel/XlFindLookIn.hpp> +#include <ooo/vba/excel/XlFormatConditionOperator.hpp> +#include <ooo/vba/excel/XlFormatConditionType.hpp> +#include <ooo/vba/excel/XlHAlign.hpp> +#include <ooo/vba/excel/XlInsertShiftDirection.hpp> +#include <ooo/vba/excel/XlLineStyle.hpp> +#include <ooo/vba/excel/XlLookAt.hpp> +#include <ooo/vba/excel/XlMousePointer.hpp> +#include <ooo/vba/excel/XlOrder.hpp> +#include <ooo/vba/excel/XlOrientation.hpp> +#include <ooo/vba/excel/XlPageBreak.hpp> +#include <ooo/vba/excel/XlPageOrientation.hpp> +#include <ooo/vba/excel/XlPaperSize.hpp> +#include <ooo/vba/excel/XlPasteSpecialOperation.hpp> +#include <ooo/vba/excel/XlPasteType.hpp> +#include <ooo/vba/excel/XlPattern.hpp> +#include <ooo/vba/excel/XlPlacement.hpp> +#include <ooo/vba/excel/XlReferenceStyle.hpp> +#include <ooo/vba/excel/XlRowCol.hpp> +#include <ooo/vba/excel/XlScaleType.hpp> +#include <ooo/vba/excel/XlSearchDirection.hpp> +#include <ooo/vba/excel/XlSearchOrder.hpp> +#include <ooo/vba/excel/XlSheetType.hpp> +#include <ooo/vba/excel/XlSheetVisibility.hpp> +#include <ooo/vba/excel/XlSortDataOption.hpp> +#include <ooo/vba/excel/XlSortMethod.hpp> +#include <ooo/vba/excel/XlSortOrder.hpp> +#include <ooo/vba/excel/XlSortOrientation.hpp> +#include <ooo/vba/excel/XlSpecialCellsValue.hpp> +#include <ooo/vba/excel/XlUnderlineStyle.hpp> +#include <ooo/vba/excel/XlVAlign.hpp> +#include <ooo/vba/excel/XlWindowState.hpp> +#include <ooo/vba/excel/XlWindowView.hpp> +#include <ooo/vba/excel/XlYesNoGuess.hpp> +#include <ooo/vba/msforms/XShape.hpp> +#include <ooo/vba/office/MsoAnimationType.hpp> +#include <ooo/vba/office/MsoAutoShapeType.hpp> +#include <ooo/vba/office/MsoControlType.hpp> +#include <ooo/vba/office/MsoFileDialogType.hpp> +#include <ooo/vba/office/MsoHyperlinkType.hpp> +#include <ooo/vba/office/MsoShapeType.hpp> +#include <sfx2/app.hxx> +#include <sfx2/bindings.hxx> +#include <sfx2/dispatch.hxx> +#include <sfx2/objsh.hxx> +#include <sfx2/request.hxx> +#include <sfx2/viewfrm.hxx> +#include <svl/itemset.hxx> +#include <svl/srchitem.hxx> +#include <toolkit/helper/vclunohelper.hxx> +#include <comphelper/diagnose_ex.hxx> +#include <tools/urlobj.hxx> +#include <unotools/eventcfg.hxx> +#include <vbahelper/vbaaccesshelper.hxx> +#include <vbahelper/vbacollectionimpl.hxx> +#include <vbahelper/vbahelper.hxx> +#include <vbahelper/vbashape.hxx> +#include <vbahelper/vbashapes.hxx> +#endif // PCH_LEVEL >= 3 +#if PCH_LEVEL >= 4 +#include <attrib.hxx> +#include <cellsuno.hxx> +#include <columnspanset.hxx> +#include <compiler.hxx> +#include <convuno.hxx> +#include <dbdata.hxx> +#include <docfunc.hxx> +#include <docoptio.hxx> +#include <docsh.hxx> +#include <document.hxx> +#include <docuno.hxx> +#include <global.hxx> +#include <gridwin.hxx> +#include <macromgr.hxx> +#include <markdata.hxx> +#include <nameuno.hxx> +#include <olinetab.hxx> +#include <patattr.hxx> +#include <preview.hxx> +#include <prevwsh.hxx> +#include <queryentry.hxx> +#include <queryparam.hxx> +#include <rangelst.hxx> +#include <rangenam.hxx> +#include <scabstdlg.hxx> +#include <scdll.hxx> +#include <scitems.hxx> +#include <scmod.hxx> +#include <sortparam.hxx> +#include <tabprotection.hxx> +#include <tabvwsh.hxx> +#include <tokenarray.hxx> +#include <tokenuno.hxx> +#include <transobj.hxx> +#include <unonames.hxx> +#include <viewdata.hxx> +#include <viewutil.hxx> +#endif // PCH_LEVEL >= 4 + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/pivot.hxx b/sc/inc/pivot.hxx new file mode 100644 index 0000000000..10f3f71614 --- /dev/null +++ b/sc/inc/pivot.hxx @@ -0,0 +1,174 @@ +/* -*- 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 . + */ + +/* + IMPORTANT: + Strictly adhere to the following sequence when creating a pivot table: + + pPivot->SetColFields(aColArr, aColCount) + pPivot->SetRowFields(aRowArr, aRowCount) + pPivot->SetDataFields(aDataArr, aDataCount) + if (pPivot->CreateData()) + { + pPivotDrawData(); + pPivotReleaseData(); + } + + Make sure that either ColArr or RowArr contains a PivotDataField entry. +*/ + +#pragma once + +#include <rtl/ustring.hxx> +#include <tools/long.hxx> +#include "types.hxx" +#include "scdllapi.h" +#include "dpglobal.hxx" +#include "calcmacros.hxx" + +#include <vector> +#include <memory> + +#include <com/sun/star/uno/Sequence.hxx> +#include <com/sun/star/sheet/DataPilotFieldReference.hpp> +#include <com/sun/star/sheet/DataPilotFieldSortInfo.hpp> +#include <com/sun/star/sheet/DataPilotFieldLayoutInfo.hpp> +#include <com/sun/star/sheet/DataPilotFieldAutoShowInfo.hpp> + +#define PIVOT_DATA_FIELD (SCCOL(-1)) + +struct SC_DLLPUBLIC ScDPName +{ + OUString maName; ///< Original name of the dimension. + OUString maLayoutName; ///< Layout name (display name) + sal_uInt8 mnDupCount; + + ScDPName(); + explicit ScDPName(OUString aName, OUString aLayoutName, sal_uInt8 nDupCount); +}; + +struct ScDPLabelData +{ + OUString maName; ///< Original name of the dimension. + OUString maLayoutName; ///< Layout name (display name) + OUString maSubtotalName; + SCCOL mnCol; ///< 0-based field index (not the source column index) + tools::Long mnOriginalDim; ///< original dimension index (>= 0 for duplicated dimension) + PivotFunc mnFuncMask; ///< Page/Column/Row subtotal function. + sal_Int32 mnUsedHier; ///< Used hierarchy. + sal_Int32 mnFlags; ///< Flags from the DataPilotSource dimension + sal_uInt8 mnDupCount; + bool mbShowAll:1; ///< true = Show all (also empty) results. + bool mbIsValue:1; ///< true = Sum or count in data field. + bool mbDataLayout:1; + bool mbRepeatItemLabels:1; + + struct Member + { + OUString maName; + OUString maLayoutName; + bool mbVisible; + bool mbShowDetails; + + Member(); + + /** + * @return the name that should be displayed in the dp dialogs i.e. + * when the layout name is present, use it, or else use the original + * name. + */ + SC_DLLPUBLIC OUString const & getDisplayName() const; + }; + std::vector<Member> maMembers; + css::uno::Sequence<OUString> maHiers; ///< Hierarchies. + css::sheet::DataPilotFieldSortInfo maSortInfo; ///< Sorting info. + css::sheet::DataPilotFieldLayoutInfo maLayoutInfo; ///< Layout info. + css::sheet::DataPilotFieldAutoShowInfo maShowInfo; ///< AutoShow info. + + ScDPLabelData(); + + /** + * @return the name that should be displayed in the dp dialogs i.e. when + * the layout name is present, use it, or else use the original name. + */ + SC_DLLPUBLIC OUString const & getDisplayName() const; +}; + +typedef std::vector< std::unique_ptr<ScDPLabelData> > ScDPLabelDataVector; + +struct ScPivotField +{ + css::sheet::DataPilotFieldReference maFieldRef; + + tools::Long mnOriginalDim; ///< >= 0 for duplicated field. + PivotFunc nFuncMask; + SCCOL nCol; ///< 0-based dimension index (not source column index) + sal_uInt8 mnDupCount; + + explicit ScPivotField( SCCOL nNewCol = 0 ); + + tools::Long getOriginalDim() const; +}; + +typedef std::vector< ScPivotField > ScPivotFieldVector; + +struct ScPivotParam +{ + SCCOL nCol; ///< Cursor Position / + SCROW nRow; ///< or start of destination area + SCTAB nTab; + + ScDPLabelDataVector maLabelArray; + ScPivotFieldVector maPageFields; + ScPivotFieldVector maColFields; + ScPivotFieldVector maRowFields; + ScPivotFieldVector maDataFields; + + bool bIgnoreEmptyRows; + bool bDetectCategories; + bool bMakeTotalCol; + bool bMakeTotalRow; + + ScPivotParam(); + ScPivotParam( const ScPivotParam& r ); + ~ScPivotParam(); + + ScPivotParam& operator= ( const ScPivotParam& r ); + void SetLabelData(const ScDPLabelDataVector& r); +}; + +struct ScPivotFuncData +{ + css::sheet::DataPilotFieldReference maFieldRef; + + tools::Long mnOriginalDim; + PivotFunc mnFuncMask; + SCCOL mnCol; + sal_uInt8 mnDupCount; + + explicit ScPivotFuncData( SCCOL nCol, PivotFunc nFuncMask ); + +#if DEBUG_PIVOT_TABLE + void Dump() const; +#endif +}; + +typedef std::vector<ScDPName> ScDPNameVec; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/poolcach.hxx b/sc/inc/poolcach.hxx new file mode 100644 index 0000000000..6e3c3deda9 --- /dev/null +++ b/sc/inc/poolcach.hxx @@ -0,0 +1,53 @@ +/* -*- 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 "scdllapi.h" +#include <vector> + +class SfxItemPool; +class SfxItemSet; +class SfxPoolItem; +class ScPatternAttr; + +class ScItemPoolCache +{ + struct SfxItemModifyImpl + { + const ScPatternAttr *pOrigItem; + ScPatternAttr *pPoolItem; + }; + + SfxItemPool *pPool; + std::vector<SfxItemModifyImpl> + m_aCache; + const SfxItemSet *pSetToPut; + const SfxPoolItem *pItemToPut; + +public: + ScItemPoolCache( SfxItemPool *pPool, + const SfxPoolItem *pPutItem ); + ScItemPoolCache( SfxItemPool *pPool, + const SfxItemSet *pPutSet ); + ~ScItemPoolCache(); + + const ScPatternAttr& ApplyTo( const ScPatternAttr& rSetItem ); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/postit.hxx b/sc/inc/postit.hxx new file mode 100644 index 0000000000..5e7f6f81d1 --- /dev/null +++ b/sc/inc/postit.hxx @@ -0,0 +1,295 @@ +/* -*- 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 <rtl/ustring.hxx> +#include <svl/itemset.hxx> +#include <rtl/ref.hxx> +#include "address.hxx" +#include "scdllapi.h" + +#include <memory> +#include <string_view> + +class EditTextObject; +class OutlinerParaObject; +class SdrCaptionObj; +class SdrPage; + +class ScDocument; +namespace tools { class Rectangle; } +struct ScCaptionInitData; + +/** Internal data for a cell annotation. */ +struct ScNoteData +{ + typedef std::shared_ptr< ScCaptionInitData > ScCaptionInitDataRef; + + OUString maDate; /// Creation date of the note. + OUString maAuthor; /// Author of the note. + ScCaptionInitDataRef mxInitData; /// Initial data for invisible notes without SdrObject. + rtl::Reference<SdrCaptionObj> mxCaption; /// Drawing object representing the cell note. + bool mbShown; /// True = note is visible. + + explicit ScNoteData( bool bShown = false ); +}; + +/** + * Additional class containing cell annotation data. + */ +class SC_DLLPUBLIC ScPostIt +{ +public: + static sal_uInt32 mnLastPostItId; + + /** Creates an empty note and its caption object and places it according to + the passed cell position. */ + explicit ScPostIt( ScDocument& rDoc, const ScAddress& rPos, sal_uInt32 nPostItId = 0 ); + + /** Copy constructor. Clones the note and its caption to a new document. */ + explicit ScPostIt( ScDocument& rDoc, const ScAddress& rPos, const ScPostIt& rNote, sal_uInt32 nPostItId = 0 ); + + /** Creates a note from the passed note data with existing caption object. + + @param bAlwaysCreateCaption Instead of a pointer to an existing + caption object, the passed note data structure may contain a + reference to an ScCaptionInitData structure containing information + about how to construct a missing caption object. If sal_True is passed, + the caption drawing object will be created immediately from that + data. If sal_False is passed and the note is not visible, it will + continue to cache that data until the caption object is requested. + */ + explicit ScPostIt( + ScDocument& rDoc, const ScAddress& rPos, + ScNoteData aNoteData, bool bAlwaysCreateCaption, sal_uInt32 nPostItId = 0 ); + + /** Removes the caption object from drawing layer, if this note is its owner. */ + ~ScPostIt(); + + /** Clones this note and its caption object, if specified. + + @param bCloneCaption If sal_True is passed, clones the caption object and + inserts it into the drawing layer of the destination document. If + sal_False is passed, the cloned note will refer to the old caption + object (used e.g. in Undo documents to restore the pointer to the + existing caption object). + */ + std::unique_ptr<ScPostIt> Clone( + const ScAddress& rOwnPos, + ScDocument& rDestDoc, const ScAddress& rDestPos, + bool bCloneCaption ) const; + + /** Returns the note id. */ + sal_uInt32 GetId() const { return mnPostItId; } + + /** Returns the data struct containing all note settings. */ + const ScNoteData& GetNoteData() const { return maNoteData;} + + /** Returns the creation date of this note. */ + const OUString& GetDate() const { return maNoteData.maDate;} + /** Sets a new creation date for this note. */ + void SetDate( const OUString& rDate ); + + /** Returns the author date of this note. */ + const OUString& GetAuthor() const { return maNoteData.maAuthor;} + /** Sets a new author date for this note. */ + void SetAuthor( const OUString& rAuthor ); + + /** Sets date and author from system settings. */ + void AutoStamp(); + + /** Returns the pointer to the current outliner object, or null. */ + const OutlinerParaObject* GetOutlinerObject() const; + /** Returns the pointer to the current edit text object, or null. */ + const EditTextObject* GetEditTextObject() const; + + /** Returns the caption text of this note. */ + OUString GetText() const; + /** Changes the caption text of this note. All text formatting will be lost. */ + void SetText( const ScAddress& rPos, const OUString& rText ); + + /** Returns an existing note caption object. returns null, if the note + contains initial caption data needed to construct a caption object. + The SdrCaptionObj* returned is still managed by the underlying + ScNoteData::ScCaptionPtr and must not be stored elsewhere. */ + SdrCaptionObj* GetCaption() const { return maNoteData.mxCaption.get();} + /** Returns the caption object of this note. Creates the caption object, if + the note contains initial caption data instead of the caption. + The SdrCaptionObj* returned is still managed by the underlying + ScNoteData::ScCaptionPtr and must not be stored elsewhere. */ + SdrCaptionObj* GetOrCreateCaption( const ScAddress& rPos ) const; + + /** Forgets the pointer to the note caption object. + + @param bPreserveData + If true then the note text is remembered in maNoteData to be able + to later reconstruct a caption from it. + */ + void ForgetCaption( bool bPreserveData = false ); + + /** Shows or hides the note caption object. */ + void ShowCaption( const ScAddress& rPos, bool bShow ); + /** Returns true, if the caption object is visible. */ + bool IsCaptionShown() const { return maNoteData.mbShown;} + + /** Shows or hides the caption temporarily (does not change internal visibility state). */ + void ShowCaptionTemp( const ScAddress& rPos, bool bShow = true ); + + /** Updates caption position according to position of the passed cell. */ + void UpdateCaptionPos( const ScAddress& rPos ); + + static OString NoteRangeToJsonString(const ScDocument& rDoc, const ScAddress& rPos); + +private: + ScPostIt( const ScPostIt& ) = delete; + ScPostIt& operator=( const ScPostIt& ) = delete; + + /** Creates the caption object from initial caption data if existing. */ + void CreateCaptionFromInitData( const ScAddress& rPos ) const; + /** Creates a new caption object at the passed cell position, clones passed existing caption. */ + void CreateCaption( const ScAddress& rPos, const SdrCaptionObj* pCaption = nullptr ); + /** Removes the caption object from the drawing layer, if this note is its owner. */ + void RemoveCaption(); + +private: + ScDocument& mrDoc; /// Parent document containing the note. + mutable ScNoteData maNoteData; /// Note data with pointer to caption object. + sal_uInt32 mnPostItId; +}; + +class GenerateNoteCaption +{ +public: + virtual void Generate(SdrCaptionObj& rCaptionObj) = 0; + virtual OUString GetSimpleText() const = 0; + virtual ~GenerateNoteCaption() {}; +}; + +class SC_DLLPUBLIC ScNoteUtil +{ + static ScPostIt* InsertNote(ScDocument& rDoc, const ScAddress& rPos, ScNoteData&& rNoteData, + bool bAlwaysCreateCaption, sal_uInt32 nPostItId); + + static ScNoteData CreateNoteData(ScDocument& rDoc, const ScAddress& rPos, + const tools::Rectangle& rCaptionRect, bool bShown); +public: + + /** Creates and returns a caption object for a temporary caption. */ + static rtl::Reference<SdrCaptionObj> CreateTempCaption( ScDocument& rDoc, const ScAddress& rPos, + SdrPage& rDrawPage, std::u16string_view rUserText, + const tools::Rectangle& rVisRect, bool bTailFront ); + + /** Creates a cell note using the passed caption drawing object. + + This function is used in import filters to reuse the imported drawing + object as note caption object. + + @param pCaption The drawing object for the cell note. This object MUST + be inserted into the document at the correct drawing page already. + The underlying ScPostIt::ScNoteData::ScCaptionPtr takes managing + ownership of the pointer. + + @param bHasStyle Is there a drawing style set for the note. + + @return Pointer to the new cell note object if insertion was + successful (i.e. the passed cell position was valid), null + otherwise. The Calc document is the owner of the note object. The + passed item set and outliner object are deleted automatically if + creation of the note was not successful. + */ + static ScPostIt* CreateNoteFromCaption( + ScDocument& rDoc, const ScAddress& rPos, + SdrCaptionObj* pCaption, bool bHasStyle ); + + /** Creates a cell note based on the passed caption object data. + + This function is used in import filters to use an existing imported + item set and outliner object to create a note caption object. For + performance reasons, it is possible to specify that the caption drawing + object for the cell note is not created yet but the note caches the + passed data needed to create the caption object on demand (see + parameter bAlwaysCreateCaption). + + @param pItemSet Pointer to an item set on heap memory containing all + formatting attributes of the caption object. This function takes + ownership of the passed item set. + + @param rStyleName Drawing style associated with the caption object. + + @param rOutlinerObj An outliner object containing (formatted) text + for the caption object. + + @param rCaptionRect The absolute position and size of the caption + object. The rectangle may be empty, in this case the default + position and size is used. + + @return Pointer to the new cell note object if insertion was + successful (i.e. the passed cell position was valid), null + otherwise. The Calc document is the owner of the note object. + */ + static ScPostIt* CreateNoteFromObjectData( + ScDocument& rDoc, const ScAddress& rPos, + const SfxItemSet& rItemSet, const OUString& rStyleName, + const OutlinerParaObject& rOutlinerObj, + const tools::Rectangle& rCaptionRect, bool bShown ); + + // similar to above, except xGenerator is a functor to apply import + // properties to the caption object to finalize it on demand + static ScPostIt* CreateNoteFromGenerator( + ScDocument& rDoc, const ScAddress& rPos, + std::unique_ptr<GenerateNoteCaption> xGenerator, + const tools::Rectangle& rCaptionRect, bool bShown ); + + /** Creates a cell note based on the passed string and inserts it into the + document. + + @param rNoteText The text used to create the note caption object. Must + not be empty. + + @param bAlwaysCreateCaption If sal_True is passed, the caption drawing + object will be created immediately. If sal_False is passed, the caption + drawing object will not be created if the note is not visible + (bShown = sal_False), but the cell note will cache the passed data. + MUST be set to sal_False outside of import filter implementations! + + @return Pointer to the new cell note object if insertion was + successful (i.e. the passed cell position was valid), null + otherwise. The Calc document is the owner of the note object. + */ + static ScPostIt* CreateNoteFromString( + ScDocument& rDoc, const ScAddress& rPos, + const OUString& rNoteText, bool bShown, + bool bAlwaysCreateCaption, sal_uInt32 nPostItId = 0 ); + +}; + +namespace sc { + +struct NoteEntry +{ + ScAddress maPos; + const ScPostIt* mpNote; + + NoteEntry( const ScAddress& rPos, const ScPostIt* pNote ); +}; + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/printopt.hxx b/sc/inc/printopt.hxx new file mode 100644 index 0000000000..f646a35482 --- /dev/null +++ b/sc/inc/printopt.hxx @@ -0,0 +1,88 @@ +/* -*- 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 <svl/poolitem.hxx> +#include <unotools/configitem.hxx> +#include "scdllapi.h" + +class SC_DLLPUBLIC ScPrintOptions +{ +private: + bool bSkipEmpty; + bool bAllSheets; + bool bForceBreaks; + +public: + ScPrintOptions(); + + bool GetSkipEmpty() const { return bSkipEmpty; } + void SetSkipEmpty( bool bVal ) { bSkipEmpty = bVal; } + bool GetAllSheets() const { return bAllSheets; } + void SetAllSheets( bool bVal ) { bAllSheets = bVal; } + bool GetForceBreaks() const { return bForceBreaks; } + void SetForceBreaks( bool bVal ) { bForceBreaks = bVal; } + + void SetDefaults(); + + bool operator== ( const ScPrintOptions& rOpt ) const; +}; + +// item for the dialog / options page + +class SC_DLLPUBLIC ScTpPrintItem final : public SfxPoolItem +{ +public: + ScTpPrintItem( const ScPrintOptions& rOpt ); + virtual ~ScTpPrintItem() override; + + ScTpPrintItem(ScTpPrintItem const &) = default; + ScTpPrintItem(ScTpPrintItem &&) = default; + ScTpPrintItem & operator =(ScTpPrintItem const &) = delete; // due to SfxPoolItem + ScTpPrintItem & operator =(ScTpPrintItem &&) = delete; // due to SfxPoolItem + + virtual bool operator==( const SfxPoolItem& ) const override; + virtual ScTpPrintItem* Clone( SfxItemPool *pPool = nullptr ) const override; + + const ScPrintOptions& GetPrintOptions() const { return theOptions; } + +private: + ScPrintOptions theOptions; +}; + +// config item + +class ScPrintCfg final : private ScPrintOptions, public utl::ConfigItem +{ +private: + static css::uno::Sequence<OUString> GetPropertyNames(); + void ReadCfg(); + virtual void ImplCommit() override; + +public: + ScPrintCfg(); + + const ScPrintOptions& GetOptions() const { return *this; } + void SetOptions( const ScPrintOptions& rNew ); + + virtual void Notify( const css::uno::Sequence< OUString >& aPropertyNames ) override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/prnsave.hxx b/sc/inc/prnsave.hxx new file mode 100644 index 0000000000..9d10b430d4 --- /dev/null +++ b/sc/inc/prnsave.hxx @@ -0,0 +1,70 @@ +/* -*- 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 "address.hxx" +#include <optional> +#include <memory> +#include <vector> + +namespace tools { class JsonWriter; } + +class ScPrintSaverTab +{ + typedef ::std::vector< ScRange > ScRangeVec; + + ScRangeVec maPrintRanges; ///< Array + std::optional<ScRange> moRepeatCol; ///< single + std::optional<ScRange> moRepeatRow; ///< single + bool mbEntireSheet; + +public: + ScPrintSaverTab(); + ~ScPrintSaverTab(); + + void SetAreas( ScRangeVec&& rRanges, bool bEntireSheet ); + void SetRepeat( std::optional<ScRange> oCol, std::optional<ScRange> oRow ); + + const ScRangeVec& GetPrintRanges() const { return maPrintRanges; } + bool IsEntireSheet() const { return mbEntireSheet; } + const std::optional<ScRange>& GetRepeatCol() const { return moRepeatCol; } + const std::optional<ScRange>& GetRepeatRow() const { return moRepeatRow; } + + bool operator==( const ScPrintSaverTab& rCmp ) const; +}; + +class ScPrintRangeSaver +{ + SCTAB nTabCount; + std::unique_ptr<ScPrintSaverTab[]> pData; + +public: + ScPrintRangeSaver( SCTAB nCount ); + ~ScPrintRangeSaver(); + + SCTAB GetTabCount() const { return nTabCount; } + ScPrintSaverTab& GetTabData(SCTAB nTab); + const ScPrintSaverTab& GetTabData(SCTAB nTab) const; + void GetPrintRangesInfo(tools::JsonWriter& rPrintRanges) const; + + bool operator==( const ScPrintRangeSaver& rCmp ) const; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/progress.hxx b/sc/inc/progress.hxx new file mode 100644 index 0000000000..80d01df3c8 --- /dev/null +++ b/sc/inc/progress.hxx @@ -0,0 +1,120 @@ +/* -*- 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 <rtl/ustring.hxx> +#include <sfx2/progress.hxx> +#include <tools/solar.h> +#include "scdllapi.h" + +class ScDocument; + +/* + * #i102566 + * Drawing a progress bar update is not cheap, so if we draw it on every + * percentage change of 200 calculations we get one progress draw per 2 + * calculations which is slower than doing the calculations themselves. So as a + * rough guide only do an update per MIN_NO_CODES_PER_PROGRESS_UPDATE + * calculations + */ +#define MIN_NO_CODES_PER_PROGRESS_UPDATE 100 + +class SC_DLLPUBLIC ScProgress +{ +private: + static SfxProgress* pGlobalProgress; + static sal_uInt64 nGlobalRange; + static sal_uInt64 nGlobalPercent; + static ScProgress* pInterpretProgress; + static sal_uInt64 nInterpretProgress; + static ScDocument* pInterpretDoc; + static bool bIdleWasEnabled; + bool bEnabled; + + std::unique_ptr<SfxProgress> pProgress; + + ScProgress( const ScProgress& ) = delete; + ScProgress& operator=( const ScProgress& ) = delete; + + static void CalcGlobalPercent( sal_uInt64 nVal ) + { + nGlobalPercent = nGlobalRange ? + nVal * 100 / nGlobalRange : 0; + } + +public: + static void CreateInterpretProgress( ScDocument* pDoc, + bool bWait = true ); + static ScProgress* GetInterpretProgress() { return pInterpretProgress; } + static void DeleteInterpretProgress(); + + ScProgress( SfxObjectShell* pObjSh, + const OUString& rText, + sal_uInt64 nRange, + bool bWait ); + ~ScProgress(); + +#ifdef SC_PROGRESS_CXX + /// for DummyInterpret only, never use otherwise!!! + ScProgress(); +#endif + void SetState( sal_uInt64 nVal, sal_uInt64 nNewRange = 0 ) + { + if ( pProgress ) + { + if ( nNewRange ) + nGlobalRange = nNewRange; + CalcGlobalPercent( nVal ); + pProgress->SetState( nVal, nNewRange ); + } + } + void SetStateCountDown( sal_uInt64 nVal ) + { + if ( pProgress ) + { + CalcGlobalPercent( nGlobalRange - nVal ); + pProgress->SetState( nGlobalRange - nVal ); + } + } + void SetStateOnPercent( sal_uInt64 nVal ) + { /// only if percentage increased + if ( nGlobalRange && (nVal * 100 / + nGlobalRange) > nGlobalPercent ) + SetState( nVal ); + } + void SetStateCountDownOnPercent( sal_uInt64 nVal ) + { /// only if percentage increased + if ( nGlobalRange && + ((nGlobalRange - nVal) * 100 / + nGlobalRange) > nGlobalPercent ) + SetStateCountDown( nVal ); + } + sal_uInt64 GetState() const + { + if ( pProgress ) + return pProgress->GetState(); + return 0; + } + bool Enabled() const { return bEnabled; } + void Disable() { bEnabled = false; } + void Enable() { bEnabled = true; } +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/pvfundlg.hrc b/sc/inc/pvfundlg.hrc new file mode 100644 index 0000000000..510c5ad05c --- /dev/null +++ b/sc/inc/pvfundlg.hrc @@ -0,0 +1,42 @@ +/* -*- 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 <unotools/resmgr.hxx> + +#define NC_(Context, String) TranslateId(Context, u8##String) + +const TranslateId SCSTR_DPFUNCLISTBOX[] = +{ + NC_("SCSTR_DPFUNCLISTBOX", "Sum"), + NC_("SCSTR_DPFUNCLISTBOX", "Count"), + NC_("SCSTR_DPFUNCLISTBOX", "Average"), + NC_("SCSTR_DPFUNCLISTBOX", "Median"), + NC_("SCSTR_DPFUNCLISTBOX", "Max"), + NC_("SCSTR_DPFUNCLISTBOX", "Min"), + NC_("SCSTR_DPFUNCLISTBOX", "Product"), + NC_("SCSTR_DPFUNCLISTBOX", "Count (Numbers only)"), + NC_("SCSTR_DPFUNCLISTBOX", "StDev (Sample)"), + NC_("SCSTR_DPFUNCLISTBOX", "StDevP (Population)"), + NC_("SCSTR_DPFUNCLISTBOX", "Var (Sample)"), + NC_("SCSTR_DPFUNCLISTBOX", "VarP (Population)") +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/queryentry.hxx b/sc/inc/queryentry.hxx new file mode 100644 index 0000000000..9798b83df7 --- /dev/null +++ b/sc/inc/queryentry.hxx @@ -0,0 +1,102 @@ +/* -*- 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 "global.hxx" +#include <svl/sharedstring.hxx> +#include <unotools/textsearch.hxx> +#include <tools/color.hxx> + +#include <memory> +#include <vector> + +/** + * Each instance of this struct represents a single filtering criteria. + */ +struct SC_DLLPUBLIC ScQueryEntry final +{ + enum QueryType + { + ByValue, + ByString, + ByDate, + ByEmpty, + ByTextColor, + ByBackgroundColor, + }; + + struct SAL_DLLPRIVATE Item + { + QueryType meType; + double mfVal; + svl::SharedString maString; + Color maColor; + bool mbMatchEmpty; + bool mbRoundForFilter; + + Item() : meType(ByValue), mfVal(0.0), mbMatchEmpty(false), mbRoundForFilter(false) {} + + bool operator== (const Item& r) const; + }; + typedef std::vector<Item> QueryItemsType; + + bool bDoQuery; + SCCOLROW nField; + ScQueryOp eOp; + ScQueryConnect eConnect; + mutable std::unique_ptr<utl::SearchParam> pSearchParam; ///< if Wildcard or RegExp, not saved + mutable std::unique_ptr<utl::TextSearch> pSearchText; ///< if Wildcard or RegExp, not saved + + ScQueryEntry(); + ScQueryEntry(const ScQueryEntry& r); + ~ScQueryEntry(); + + /// creates pSearchParam and pSearchText if necessary + utl::TextSearch* GetSearchTextPtr( utl::SearchParam::SearchType eSearchType, bool bCaseSens, + bool bWildMatchSel ) const; + + QueryItemsType& GetQueryItems() { return maQueryItems;} + const QueryItemsType& GetQueryItems() const { return maQueryItems;} + void SetQueryByEmpty(); + bool IsQueryByEmpty() const; + void SetQueryByNonEmpty(); + bool IsQueryByNonEmpty() const; + void SetQueryByTextColor(Color color); + bool IsQueryByTextColor() const; + void SetQueryByBackgroundColor(Color color); + bool IsQueryByBackgroundColor() const; + const Item& GetQueryItem() const { return GetQueryItemImpl(); } + Item& GetQueryItem() { return GetQueryItemImpl(); } + void Clear(); + ScQueryEntry& operator=( const ScQueryEntry& r ); + bool operator==( const ScQueryEntry& r ) const; + +private: + Item& GetQueryItemImpl() const; + + /** + * Stores all query items. It must contain at least one item at all times + * (for single equality match queries or comparative queries). It may + * contain multiple items for multi-equality match queries. + */ + mutable QueryItemsType maQueryItems; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/queryevaluator.hxx b/sc/inc/queryevaluator.hxx new file mode 100644 index 0000000000..f572408344 --- /dev/null +++ b/sc/inc/queryevaluator.hxx @@ -0,0 +1,126 @@ +/* -*- 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 <memory> +#include <vector> +#include <unordered_map> + +#include "queryentry.hxx" + +class ScDocument; +class ScTable; +struct ScQueryParam; +class CollatorWrapper; +struct ScRefCellValue; +struct ScInterpreterContext; + +namespace sc +{ +class TableColumnBlockPositionSet; +} +namespace svl +{ +class SharedStringPool; +} +namespace utl +{ +class TransliterationWrapper; +} + +class ScQueryEvaluator +{ + ScDocument& mrDoc; + svl::SharedStringPool& mrStrPool; + const ScTable& mrTab; + const ScQueryParam& mrParam; + bool* mpTestEqualCondition; + utl::TransliterationWrapper* mpTransliteration; + CollatorWrapper* mpCollator; + const bool mbMatchWholeCell; + const bool mbCaseSensitive; + const ScInterpreterContext* mpContext; + + const SCSIZE mnEntryCount; + bool* mpPasst; + bool* mpTest; + static constexpr SCSIZE nFixedBools = 32; + bool maBool[nFixedBools]; + bool maTest[nFixedBools]; + std::unique_ptr<bool[]> mpBoolDynamic; + std::unique_ptr<bool[]> mpTestDynamic; + + std::unordered_map<FormulaError, svl::SharedString> mCachedSharedErrorStrings; + // The "outside" index in these two is the index of ScQueryEntry in ScQueryParam. + std::vector<std::vector<double>> mCachedSortedItemValues; + std::vector<std::vector<const rtl_uString*>> mCachedSortedItemStrings; + + static bool isPartialTextMatchOp(ScQueryOp eOp); + static bool isTextMatchOp(ScQueryOp eOp); + static bool isMatchWholeCellHelper(bool docMatchWholeCell, ScQueryOp eOp); + bool isMatchWholeCell(ScQueryOp eOp) const; + void setupTransliteratorIfNeeded(); + void setupCollatorIfNeeded(); + + bool isRealWildOrRegExp(const ScQueryEntry& rEntry) const; + bool isTestWildOrRegExp(const ScQueryEntry& rEntry) const; + static bool isQueryByValueForCell(const ScRefCellValue& rCell); + + sal_uInt32 getNumFmt(SCCOL nCol, SCROW nRow); + + std::pair<bool, bool> compareByValue(const ScRefCellValue& rCell, SCCOL nCol, SCROW nRow, + const ScQueryEntry& rEntry, + const ScQueryEntry::Item& rItem); + + bool isFastCompareByString(const ScQueryEntry& rEntry) const; + template <bool bFast = false> + std::pair<bool, bool> + compareByString(const ScQueryEntry& rEntry, const ScQueryEntry::Item& rItem, + const svl::SharedString* pValueSource1, const OUString* pValueSource2); + std::pair<bool, bool> compareByTextColor(SCCOL nCol, SCROW nRow, + const ScQueryEntry::Item& rItem); + std::pair<bool, bool> compareByBackgroundColor(SCCOL nCol, SCROW nRow, + const ScQueryEntry::Item& rItem); + + static std::pair<bool, bool> compareByRangeLookup(const ScRefCellValue& rCell, + const ScQueryEntry& rEntry, + const ScQueryEntry::Item& rItem); + + std::pair<bool, bool> processEntry(SCROW nRow, SCCOL nCol, ScRefCellValue& aCell, + const ScQueryEntry& rEntry, size_t nEntryIndex); + +public: + ScQueryEvaluator(ScDocument& rDoc, const ScTable& rTab, const ScQueryParam& rParam, + const ScInterpreterContext* pContext = nullptr, + bool* pTestEqualCondition = nullptr); + + bool ValidQuery(SCROW nRow, const ScRefCellValue* pCell = nullptr, + sc::TableColumnBlockPositionSet* pBlockPos = nullptr); + + static bool isQueryByValue(ScQueryOp eOp, ScQueryEntry::QueryType eType, + const ScRefCellValue& rCell); + static bool isQueryByString(ScQueryOp eOp, ScQueryEntry::QueryType eType, + const ScRefCellValue& rCell); + OUString getCellString(const ScRefCellValue& rCell, SCROW nRow, SCCOL nCol, + const svl::SharedString** sharedString); + static bool isMatchWholeCell(const ScDocument& rDoc, ScQueryOp eOp); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/queryiter.hxx b/sc/inc/queryiter.hxx new file mode 100644 index 0000000000..1d0066de7f --- /dev/null +++ b/sc/inc/queryiter.hxx @@ -0,0 +1,381 @@ +/* -*- 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 "address.hxx" +#include "global.hxx" +#include "scdllapi.h" +#include "queryparam.hxx" +#include "mtvelements.hxx" +#include "types.hxx" + +struct ScComplexRefData; +class ScSortedRangeCache; + +/* +Query-related iterators. There is one template class ScQueryCellIteratorBase +that implements most of the shared functionality, specific parts are done +by specializing the templates and then subclassing as the actual class to use. +A template is used for maximum performance, as that allows fast code specializing, +inlining, etc. +There are two template arguments: +* ScQueryCellIteratorAccess specifies how cells are accessed: + + Direct - direct access to cells using mdds. + + SortedCache - for accessing unsorted cells in a sorted way using ScSortedRangeCache. +* ScQueryCellIteratorType specifies the type of the query operation: + + Generic - the generic lookup, used e.g. by VLOOKUP. + + CountIf - faster implementation for COUNTIF(S). + +Specific data should be in specific templated base classes, otherwise adding data +members would mean specializing the entire ScQueryCellIteratorBase. Some specific +functionality may also be implemented in the base classes or depending on the template +parameter. +*/ + +// Data and functionality for accessing cells in a specific way. +// Needs specialization, see ScQueryCellIteratorAccess::Direct for what is needed. +template< ScQueryCellIteratorAccess accessType > +class ScQueryCellIteratorAccessSpecific +{ +}; + +// The implementation using linear direct mdds access. +template<> +class ScQueryCellIteratorAccessSpecific< ScQueryCellIteratorAccess::Direct > +{ +protected: + ScQueryCellIteratorAccessSpecific( ScDocument& rDocument, ScInterpreterContext& rContext, + const ScQueryParam& rParam ); + // Initialize position for new column. + void InitPos(); + // Increase position (next row). + void IncPos(); + // Next mdds block. If access is not direct/linear, then + // should call IncPos(). + void IncBlock(); + + // These members needs to be available already in the base class. + typedef sc::CellStoreType::const_position_type PositionType; + PositionType maCurPos; + ScQueryParam maParam; + ScDocument& rDoc; + ScInterpreterContext& mrContext; + SCTAB nTab; + SCCOL nCol; + SCROW nRow; + + class NonEmptyCellIndexer; + typedef std::pair<ScRefCellValue, SCROW> BinarySearchCellType; + static NonEmptyCellIndexer MakeBinarySearchIndexer(const sc::CellStoreType& rCells, + SCROW nStartRow, SCROW nEndRow); +}; + +// The implementation using ScSortedRangeCache, which allows sorted iteration +// of unsorted cells. +template<> +class ScQueryCellIteratorAccessSpecific< ScQueryCellIteratorAccess::SortedCache > +{ +public: + void SetSortedRangeCache( const ScSortedRangeCache& cache ); + template<bool fast> + bool IncPosImpl(); +protected: + ScQueryCellIteratorAccessSpecific( ScDocument& rDocument, ScInterpreterContext& rContext, + const ScQueryParam& rParam ); + void InitPosStart(); + void InitPosFinish( SCROW beforeRow, SCROW lastRow ); + void IncPos() { IncPosImpl<false>(); } + bool IncPosFast() { return IncPosImpl<true>(); } + void IncBlock() { IncPos(); } // Cannot skip entire block, not linear. + + // These members needs to be available already in the base class. + typedef sc::CellStoreType::const_position_type PositionType; + PositionType maCurPos; + ScQueryParam maParam; + ScDocument& rDoc; + ScInterpreterContext& mrContext; + SCTAB nTab; + SCCOL nCol; + SCROW nRow; + const ScColumn* pColumn; // matching nCol, set by InitPos() + + const ScSortedRangeCache* sortedCache; + size_t sortedCachePos; + size_t sortedCachePosLast; + + class SortedCacheIndexer; + typedef std::pair<ScRefCellValue, SCROW> BinarySearchCellType; + SortedCacheIndexer MakeBinarySearchIndexer(const sc::CellStoreType& rCells, + SCROW nStartRow, SCROW nEndRow); +}; + +// Data and functionality for specific types of query. +template< ScQueryCellIteratorType iteratorType > +class ScQueryCellIteratorTypeSpecific +{ +protected: + bool HandleItemFound(); // not implemented, needs specialization +}; + +// Shared code for query-based iterators. The main class. +template< ScQueryCellIteratorAccess accessType, ScQueryCellIteratorType queryType > +class ScQueryCellIteratorBase + : public ScQueryCellIteratorAccessSpecific< accessType > + , public ScQueryCellIteratorTypeSpecific< queryType > +{ + typedef ScQueryCellIteratorAccessSpecific< accessType > AccessBase; + typedef ScQueryCellIteratorTypeSpecific< queryType > TypeBase; +protected: + enum StopOnMismatchBits + { + nStopOnMismatchDisabled = 0x00, + nStopOnMismatchEnabled = 0x01, + nStopOnMismatchOccurred = 0x02, + nStopOnMismatchExecuted = nStopOnMismatchEnabled | nStopOnMismatchOccurred + }; + + enum TestEqualConditionBits + { + nTestEqualConditionDisabled = 0x00, + nTestEqualConditionEnabled = 0x01, + nTestEqualConditionMatched = 0x02, + nTestEqualConditionFulfilled = nTestEqualConditionEnabled | nTestEqualConditionMatched + }; + + sal_uInt8 nStopOnMismatch; + sal_uInt8 nTestEqualCondition; + bool bAdvanceQuery; + bool bIgnoreMismatchOnLeadingStrings; + + // Make base members directly visible here (templated bases need 'this->'). + using AccessBase::maCurPos; + using AccessBase::maParam; + using AccessBase::rDoc; + using AccessBase::mrContext; + using AccessBase::nTab; + using AccessBase::nCol; + using AccessBase::nRow; + using AccessBase::IncPos; + using AccessBase::IncBlock; + using typename AccessBase::BinarySearchCellType; + using AccessBase::MakeBinarySearchIndexer; + using TypeBase::HandleItemFound; + + void InitPos(); + + // The actual query function. It will call HandleItemFound() for any matching type + // and return if HandleItemFound() returns true. + void PerformQuery(); + + /* Only works if no regular expression is involved, only searches for rows in one column, + and only the first query entry is considered with simple conditions SC_LESS,SC_LESS_EQUAL, + SC_EQUAL (sorted ascending) or SC_GREATER,SC_GREATER_EQUAL (sorted descending). It + delivers a starting point set to nRow, i.e. the last row that either matches the searched + for value, or the last row that matches the condition. Continue with e.g. GetThis() and + GetNext() afterwards. Returns false if the searched for value is not in the search range + or if the range is not properly sorted, with nRow in that case set to the first row or after + the last row. In that case use GetFirst(). + */ + bool BinarySearch( SCCOL col, bool forEqual = false ); + + /** If set, iterator stops on first non-matching cell + content. May be used in SC_LESS_EQUAL queries where a + cell range is assumed to be sorted; stops on first + value being greater than the queried value and + GetFirst()/GetNext() return NULL. StoppedOnMismatch() + returns true then. + However, the iterator's conditions are not set to end + all queries, GetCol() and GetRow() return values for + the non-matching cell, further GetNext() calls may be + executed. */ + void SetStopOnMismatch( bool bVal ) + { + nStopOnMismatch = sal::static_int_cast<sal_uInt8>(bVal ? nStopOnMismatchEnabled : + nStopOnMismatchDisabled); + } + bool StoppedOnMismatch() const + { return nStopOnMismatch == nStopOnMismatchExecuted; } + + /** If set, an additional test for SC_EQUAL condition is + executed in ScTable::ValidQuery() if SC_LESS_EQUAL or + SC_GREATER_EQUAL conditions are to be tested. May be + used where a cell range is assumed to be sorted to stop + if an equal match is found. */ + void SetTestEqualCondition( bool bVal ) + { + nTestEqualCondition = sal::static_int_cast<sal_uInt8>(bVal ? + nTestEqualConditionEnabled : + nTestEqualConditionDisabled); + } + bool IsEqualConditionFulfilled() const + { return nTestEqualCondition == nTestEqualConditionFulfilled; } + +public: + ScQueryCellIteratorBase(ScDocument& rDocument, ScInterpreterContext& rContext, SCTAB nTable, + const ScQueryParam& aParam, bool bMod); + // when !bMod, the QueryParam has to be filled + // (bIsString) + + // increments all Entry.nField, if column + // changes, for ScInterpreter ScHLookup() + void SetAdvanceQueryParamEntryField( bool bVal ) + { bAdvanceQuery = bVal; } + void AdvanceQueryParamEntryField(); +}; + + +template<> +class ScQueryCellIteratorTypeSpecific< ScQueryCellIteratorType::Generic > +{ +protected: + bool HandleItemFound(); + bool getThisResult; +}; + +// The generic query iterator, used e.g. by VLOOKUP. +template< ScQueryCellIteratorAccess accessType > +class ScQueryCellIterator + : public ScQueryCellIteratorBase< accessType, ScQueryCellIteratorType::Generic > +{ + typedef ScQueryCellIteratorBase< accessType, ScQueryCellIteratorType::Generic > Base; + // Make base members directly visible here (templated bases need 'this->'). + using Base::maParam; + using Base::rDoc; + using Base::mrContext; + using Base::nTab; + using Base::nCol; + using Base::nRow; + using Base::InitPos; + using Base::IncPos; + using Base::bIgnoreMismatchOnLeadingStrings; + using Base::SetStopOnMismatch; + using Base::SetTestEqualCondition; + using Base::BinarySearch; + using typename Base::PositionType; + using Base::maCurPos; + using Base::IsEqualConditionFulfilled; + using Base::bAdvanceQuery; + using Base::StoppedOnMismatch; + using Base::nStopOnMismatch; + using Base::nStopOnMismatchEnabled; + using Base::nTestEqualCondition; + using Base::nTestEqualConditionEnabled; + using Base::PerformQuery; + using Base::getThisResult; + + bool GetThis(); + +public: + ScQueryCellIterator(ScDocument& rDocument, ScInterpreterContext& rContext, SCTAB nTable, + const ScQueryParam& aParam, bool bMod) + : Base( rDocument, rContext, nTable, aParam, bMod ) {} + bool GetFirst(); + bool GetNext(); + SCCOL GetCol() const { return nCol; } + SCROW GetRow() const { return nRow; } + + /** In a range assumed to be sorted find either the last of + a sequence of equal entries or the last being less than + (or greater than) the queried value. Used by the + interpreter for [HV]?LOOKUP() and MATCH(). Column and + row position of the found entry are returned, otherwise + invalid. + + The search does not stop when encountering a string and does not + assume that no values follow anymore. + If querying for a string a mismatch on the first + entry, e.g. column header, is ignored. + + @ATTENTION! StopOnMismatch, TestEqualCondition and + the internal IgnoreMismatchOnLeadingStrings and query + params are in an undefined state upon return! The + iterator is not usable anymore except for obtaining the + number format! + */ + bool FindEqualOrSortedLastInRange( SCCOL& nFoundCol, SCROW& nFoundRow ); +}; + +typedef ScQueryCellIterator< ScQueryCellIteratorAccess::Direct > ScQueryCellIteratorDirect; + +class ScQueryCellIteratorSortedCache + : public ScQueryCellIterator< ScQueryCellIteratorAccess::SortedCache > +{ + typedef ScQueryCellIterator< ScQueryCellIteratorAccess::SortedCache > Base; +public: + ScQueryCellIteratorSortedCache(ScDocument& rDocument, ScInterpreterContext& rContext, + SCTAB nTable, const ScQueryParam& aParam, bool bMod) + : Base( rDocument, rContext, nTable, aParam, bMod ) {} + // Returns true if this iterator can be used for the given query. + static bool CanBeUsed(ScDocument& rDoc, const ScQueryParam& aParam, + SCTAB nTab, const ScFormulaCell* cell, const ScComplexRefData* refData, + ScInterpreterContext& context); +}; + + +template<> +class ScQueryCellIteratorTypeSpecific< ScQueryCellIteratorType::CountIf > +{ +protected: + bool HandleItemFound(); + sal_uInt64 countIfCount; +}; + +// Used by ScInterpreter::ScCountIf. +template< ScQueryCellIteratorAccess accessType > +class ScCountIfCellIterator + : public ScQueryCellIteratorBase< accessType, ScQueryCellIteratorType::CountIf > +{ +protected: + typedef ScQueryCellIteratorBase< accessType, ScQueryCellIteratorType::CountIf > Base; + // Make base members directly visible here (templated bases need 'this->'). + using Base::maParam; + using Base::rDoc; + using Base::nTab; + using Base::nCol; + using Base::nRow; + using Base::InitPos; + using Base::PerformQuery; + using Base::SetAdvanceQueryParamEntryField; + using Base::countIfCount; + +public: + ScCountIfCellIterator(ScDocument& rDocument, ScInterpreterContext& rContext, SCTAB nTable, + const ScQueryParam& aParam, bool bMod) + : Base( rDocument, rContext, nTable, aParam, bMod ) {} + sal_uInt64 GetCount(); +}; + +typedef ScCountIfCellIterator< ScQueryCellIteratorAccess::Direct > ScCountIfCellIteratorDirect; + +class ScCountIfCellIteratorSortedCache + : public ScCountIfCellIterator< ScQueryCellIteratorAccess::SortedCache > +{ + typedef ScCountIfCellIterator< ScQueryCellIteratorAccess::SortedCache > Base; +public: + ScCountIfCellIteratorSortedCache(ScDocument& rDocument, ScInterpreterContext& rContext, + SCTAB nTable, const ScQueryParam& aParam, bool bMod) + : Base( rDocument, rContext, nTable, aParam, bMod ) {} + // Returns true if this iterator can be used for the given query. + static bool CanBeUsed(ScDocument& rDoc, const ScQueryParam& aParam, + SCTAB nTab, const ScFormulaCell* cell, const ScComplexRefData* refData, + ScInterpreterContext& context); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/queryparam.hxx b/sc/inc/queryparam.hxx new file mode 100644 index 0000000000..e80cb864fd --- /dev/null +++ b/sc/inc/queryparam.hxx @@ -0,0 +1,205 @@ +/* -*- 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 <unotools/textsearch.hxx> +#include "address.hxx" +#include "queryentry.hxx" +#include "types.hxx" + +#include <vector> +#include <ostream> + +class SvNumberFormatter; + +struct ScDBQueryParamInternal; +struct ScQueryEntry; + +namespace svl { + +class SharedStringPool; + +} + +struct SAL_DLLPUBLIC_RTTI ScQueryParamBase +{ + utl::SearchParam::SearchType eSearchType; + bool bHasHeader; + bool bByRow; + bool bInplace; + bool bCaseSens; + bool bDuplicate; + bool mbRangeLookup; ///< for spreadsheet functions like MATCH, LOOKUP, HLOOKUP, VLOOKUP + + virtual ~ScQueryParamBase(); + + virtual bool IsValidFieldIndex() const; + + SC_DLLPUBLIC SCSIZE GetEntryCount() const; + SC_DLLPUBLIC const ScQueryEntry& GetEntry(SCSIZE n) const; + SC_DLLPUBLIC ScQueryEntry& GetEntry(SCSIZE n); + SC_DLLPUBLIC ScQueryEntry& AppendEntry(); + ScQueryEntry* FindEntryByField(SCCOLROW nField, bool bNew); + std::vector<ScQueryEntry*> FindAllEntriesByField(SCCOLROW nField); + SC_DLLPUBLIC bool RemoveEntryByField(SCCOLROW nField); + SC_DLLPUBLIC void RemoveAllEntriesByField(SCCOLROW nField); + void Resize(size_t nNew); + void FillInExcelSyntax( svl::SharedStringPool& rPool, const OUString& aCellStr, SCSIZE nIndex, + SvNumberFormatter* pFormatter ); + +protected: + typedef std::vector<ScQueryEntry> EntriesType; + +public: + typedef EntriesType::const_iterator const_iterator; + + const_iterator begin() const; + const_iterator end() const; + +protected: + ScQueryParamBase(); + ScQueryParamBase(const ScQueryParamBase& r); + ScQueryParamBase& operator=(const ScQueryParamBase& r); + + EntriesType m_Entries; +}; + +// For use in SAL_DEBUG etc. Output format not guaranteed to be stable. +template<typename charT, typename traits> +inline std::basic_ostream<charT, traits> & operator <<(std::basic_ostream<charT, traits> & stream, const ScQueryParamBase& rParam) +{ + stream << "{" << + "searchType=" << rParam.eSearchType << + ",hasHeader=" << (rParam.bHasHeader?"YES":"NO") << + ",byRow=" << (rParam.bByRow?"YES":"NO") << + ",inplace=" << (rParam.bInplace?"YES":"NO") << + ",caseSens=" << (rParam.bCaseSens?"YES":"NO") << + ",duplicate=" << (rParam.bDuplicate?"YES":"NO") << + ",rangeLookup=" << (rParam.mbRangeLookup?"YES":"NO") << + "}"; + + return stream; +} + +struct SAL_DLLPUBLIC_RTTI ScQueryParamTable +{ + SCCOL nCol1; + SCROW nRow1; + SCCOL nCol2; + SCROW nRow2; + SCTAB nTab; + + ScQueryParamTable(); + virtual ~ScQueryParamTable(); + + ScQueryParamTable(ScQueryParamTable const &) = default; + ScQueryParamTable(ScQueryParamTable &&) = default; + ScQueryParamTable & operator =(ScQueryParamTable const &) = default; + ScQueryParamTable & operator =(ScQueryParamTable &&) = default; +}; + +// For use in SAL_DEBUG etc. Output format not guaranteed to be stable. +template<typename charT, typename traits> +inline std::basic_ostream<charT, traits> & operator <<(std::basic_ostream<charT, traits> & stream, const ScQueryParamTable& rParam) +{ + stream << "{" << + "col1=" << rParam.nCol1 << + ",row1=" << rParam.nRow1 << + ",col2=" << rParam.nCol2 << + ",row2=" << rParam.nRow2 << + ",tab=" << rParam.nTab << + "}"; + + return stream; +} + +struct SC_DLLPUBLIC ScQueryParam final : public ScQueryParamBase, public ScQueryParamTable +{ + bool bDestPers; // not saved + SCTAB nDestTab; + SCCOL nDestCol; + SCROW nDestRow; + + ScQueryParam(); + ScQueryParam( const ScQueryParam& ); + ScQueryParam( const ScDBQueryParamInternal& r ); + virtual ~ScQueryParam() override; + + ScQueryParam& operator= ( const ScQueryParam& ); + bool operator== ( const ScQueryParam& rOther ) const; + void Clear(); + void ClearDestParams(); + void MoveToDest(); +}; + +// For use in SAL_DEBUG etc. Output format not guaranteed to be stable. +template<typename charT, typename traits> +inline std::basic_ostream<charT, traits> & operator <<(std::basic_ostream<charT, traits> & stream, const ScQueryParam& rParam) +{ + stream << "{" << + "base=" << *static_cast<const ScQueryParamBase*>(&rParam) << + ",table=" << *static_cast<const ScQueryParamTable*>(&rParam) << + ",destPers=" << (rParam.bDestPers?"YES":"NO") << + ",destTab=" << rParam.nDestTab << + ",destCol=" << rParam.nDestCol << + ",destRow=" << rParam.nDestRow << + "}"; + + return stream; +} + +struct ScDBQueryParamBase : public ScQueryParamBase +{ + enum DataType { INTERNAL, MATRIX }; + + SCCOL mnField; /// the field in which the values are processed during iteration. + bool mbSkipString; + + DataType GetType() const { return meType;} + + ScDBQueryParamBase() = delete; + virtual ~ScDBQueryParamBase() override; + +protected: + ScDBQueryParamBase(DataType eType); + +private: + DataType meType; +}; + +struct ScDBQueryParamInternal final : public ScDBQueryParamBase, public ScQueryParamTable +{ + ScDBQueryParamInternal(); + virtual ~ScDBQueryParamInternal() override; + + virtual bool IsValidFieldIndex() const override; +}; + +struct ScDBQueryParamMatrix final : public ScDBQueryParamBase +{ + ScMatrixRef mpMatrix; + + ScDBQueryParamMatrix(); + virtual ~ScDBQueryParamMatrix() override; + + virtual bool IsValidFieldIndex() const override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/rangecache.hxx b/sc/inc/rangecache.hxx new file mode 100644 index 0000000000..c65e8653a4 --- /dev/null +++ b/sc/inc/rangecache.hxx @@ -0,0 +1,126 @@ +/* -*- 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 "address.hxx" +#include "queryentry.hxx" +#include <o3tl/hash_combine.hxx> +#include <svl/listener.hxx> + +#include <memory> +#include <unordered_map> + +class ScDocument; +struct ScInterpreterContext; +struct ScQueryParam; +struct ScSortedRangeCacheMap; + +/** Sorted cache for one range used with interpreter functions such as VLOOKUP + and MATCH. Caches sorted order for cells in the given range, which must + be one column. This allows faster lookups when cells are not sorted. + + The class has a vector of SCROW items, which is sorted according to values + of those cells. Therefore e.g. binary search of those cells can be done + by doing binary search of the vector while mapping the indexes to rows. + */ + +class ScSortedRangeCache final : public SvtListener +{ +public: + /// MUST be new'd because Notify() deletes. + ScSortedRangeCache(ScDocument* pDoc, const ScRange& rRange, const ScQueryParam& param, + ScInterpreterContext* context, bool invalid = false); + + /// Returns if the cache is usable. + bool isValid() const { return mValid; } + + /// Remove from document structure and delete (!) cache on modify hint. + virtual void Notify(const SfxHint& rHint) override; + + const ScRange& getRange() const { return maRange; } + + enum class ValueType + { + Values, + StringsCaseSensitive, + StringsCaseInsensitive + }; + struct HashKey + { + ScRange range; + ValueType valueType; + ScQueryOp queryOp; + ScQueryEntry::QueryType queryType; + bool operator==(const HashKey& other) const + { + return range == other.range && valueType == other.valueType && queryOp == other.queryOp + && queryType == other.queryType; + } + }; + HashKey getHashKey() const { return { maRange, mValueType, mQueryOp, mQueryType }; } + static HashKey makeHashKey(const ScRange& range, const ScQueryParam& param); + + struct Hash + { + size_t operator()(const HashKey& key) const + { + // Range should be just one column. + size_t hash = key.range.hashStartColumn(); + o3tl::hash_combine(hash, key.valueType); + o3tl::hash_combine(hash, key.queryOp); + o3tl::hash_combine(hash, key.queryType); + return hash; + } + }; + + const std::vector<SCROW>& sortedRows() const { return mSortedRows; } + size_t size() const { return mSortedRows.size(); } + size_t indexForRow(SCROW row) const + { + assert(row >= maRange.aStart.Row() && row <= maRange.aEnd.Row()); + assert(mRowToIndex[row - maRange.aStart.Row()] != mSortedRows.max_size()); + return mRowToIndex[row - maRange.aStart.Row()]; + } + SCROW rowForIndex(size_t index) const { return mSortedRows[index]; } + +private: + // Rows sorted by their value. + std::vector<SCROW> mSortedRows; + std::vector<size_t> mRowToIndex; // indexed by 'SCROW - maRange.aStart.Row()' + ScRange maRange; + ScDocument* mpDoc; + bool mValid; + ValueType mValueType; + ScQueryOp mQueryOp; + ScQueryEntry::QueryType mQueryType; + + ScSortedRangeCache(const ScSortedRangeCache&) = delete; + ScSortedRangeCache& operator=(const ScSortedRangeCache&) = delete; +}; + +// Struct because including lookupcache.hxx in document.hxx isn't wanted. +struct ScSortedRangeCacheMap +{ + std::unordered_map<ScSortedRangeCache::HashKey, std::unique_ptr<ScSortedRangeCache>, + ScSortedRangeCache::Hash> + aCacheMap; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/rangelst.hxx b/sc/inc/rangelst.hxx new file mode 100644 index 0000000000..efbc697b4c --- /dev/null +++ b/sc/inc/rangelst.hxx @@ -0,0 +1,165 @@ +/* -*- 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 "global.hxx" +#include "address.hxx" +#include <ostream> +#include <vector> +#include <sal/types.h> + +class ScDocument; + + +class SAL_WARN_UNUSED SC_DLLPUBLIC ScRangeList final : public SvRefBase +{ +public: + ScRangeList(); + ScRangeList( const ScRangeList& rList ); + ScRangeList(ScRangeList&& rList) noexcept; + ScRangeList( const ScRange& rRange ); + virtual ~ScRangeList() override; + + ScRangeList& operator=(const ScRangeList& rList); + ScRangeList& operator=(ScRangeList&& rList) noexcept; + + ScRefFlags Parse( std::u16string_view, const ScDocument&, + formula::FormulaGrammar::AddressConvention eConv = formula::FormulaGrammar::CONV_OOO, + SCTAB nDefaultTab = 0, sal_Unicode cDelimiter = 0 ); + + void Format( OUString&, ScRefFlags nFlags, const ScDocument&, + formula::FormulaGrammar::AddressConvention eConv = formula::FormulaGrammar::CONV_OOO, + sal_Unicode cDelimiter = 0, bool bFullAddressNotation = false ) const; + + void Join( const ScRange&, bool bIsInList = false ); + + bool UpdateReference( UpdateRefMode, const ScDocument*, + const ScRange& rWhere, + SCCOL nDx, + SCROW nDy, + SCTAB nDz + ); + + void InsertRow( SCTAB nTab, SCCOL nColStart, SCCOL nColEnd, SCROW nRowPos, SCSIZE nSize ); + void InsertCol( SCTAB nTab, SCROW nRowStart, SCROW nRowEnd, SCCOL nColPos, SCSIZE nSize ); + void InsertCol( SCTAB nTab, SCCOL nColPos ); + + /** For now this method assumes that nTab1 == nTab2 + * The algorithm will be much more complicated if nTab1 != nTab2 + */ + bool DeleteArea( SCCOL nCol1, SCROW nRow1, SCTAB nTab1, SCCOL nCol2, + SCROW nRow2, SCTAB nTab2 ); + + const ScRange* Find( const ScAddress& ) const; + ScRange* Find( const ScAddress& ); + bool operator==( const ScRangeList& ) const; + bool operator!=( const ScRangeList& r ) const; + bool Intersects( const ScRange& ) const; + bool Contains( const ScRange& ) const; + sal_uInt64 GetCellCount() const; + ScAddress GetTopLeftCorner() const; + + ScRangeList GetIntersectedRange(const ScRange& rRange) const; + + void Remove(size_t nPos); + void RemoveAll(); + + ScRange Combine() const; + // Add new range, and do a partial combine up till one row back + void AddAndPartialCombine(const ScRange&); + + bool empty() const { return maRanges.empty(); } + size_t size() const { return maRanges.size(); } + ScRange& operator[](size_t idx) { return maRanges[idx]; } + const ScRange& operator[](size_t idx) const { return maRanges[idx]; } + ScRange& front() { return maRanges.front(); } + const ScRange& front() const { return maRanges.front(); } + ScRange& back() { return maRanges.back(); } + const ScRange& back() const { return maRanges.back(); } + void push_back(const ScRange & rRange); + ::std::vector<ScRange>::const_iterator begin() const { return maRanges.begin(); } + ::std::vector<ScRange>::const_iterator end() const { return maRanges.end(); } + ::std::vector<ScRange>::iterator begin() { return maRanges.begin(); } + ::std::vector<ScRange>::iterator end() { return maRanges.end(); } + void insert(std::vector<ScRange>::iterator aPos, std::vector<ScRange>::const_iterator aSourceBegin, std::vector<ScRange>::const_iterator aSourceEnd) + { maRanges.insert(aPos, aSourceBegin, aSourceEnd); } + + void swap( ScRangeList& r ); + +private: + ::std::vector<ScRange> maRanges; + SCROW mnMaxRowUsed; +}; +typedef tools::SvRef<ScRangeList> ScRangeListRef; + +// For use in SAL_DEBUG etc. Output format not guaranteed to be stable. +template<typename charT, typename traits> +inline std::basic_ostream<charT, traits> & operator <<(std::basic_ostream<charT, traits> & stream, const ScRangeList& rRangeList) +{ + stream << "("; + for (size_t i = 0; i < rRangeList.size(); ++i) + { + if (i > 0) + stream << ","; + stream << rRangeList[i]; + } + stream << ")"; + + return stream; +} + +// RangePairList: +// aRange[0]: actual range, +// aRange[1]: data for that range, e.g. Rows belonging to a ColName +class SC_DLLPUBLIC ScRangePairList final : public SvRefBase +{ +public: + virtual ~ScRangePairList() override; + ScRangePairList* Clone() const; + void Append( const ScRangePair& rRangePair ) + { + maPairs.push_back( rRangePair ); + } + void Join( const ScRangePair&, bool bIsInList = false ); + void UpdateReference( UpdateRefMode, const ScDocument*, + const ScRange& rWhere, + SCCOL nDx, SCROW nDy, SCTAB nDz ); + void DeleteOnTab( SCTAB nTab ); + ScRangePair* Find( const ScAddress& ); + ScRangePair* Find( const ScRange& ); + std::vector<const ScRangePair*> + CreateNameSortedArray( ScDocument& ) const; + + void Remove(size_t nPos); + void Remove(const ScRangePair & rAdr); + + size_t size() const; + ScRangePair& operator[](size_t idx); + const ScRangePair& operator[](size_t idx) const; + +private: + ::std::vector< ScRangePair > maPairs; +}; +typedef tools::SvRef<ScRangePairList> ScRangePairListRef; + +extern "C" +int ScRangePairList_QsortNameCompare( const void*, const void* ); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/rangenam.hxx b/sc/inc/rangenam.hxx new file mode 100644 index 0000000000..881a2e876b --- /dev/null +++ b/sc/inc/rangenam.hxx @@ -0,0 +1,287 @@ +/* -*- 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 "global.hxx" +#include "address.hxx" +#include <formula/grammar.hxx> +#include "scdllapi.h" +#include "calcmacros.hxx" + +#include <memory> +#include <map> +#include <vector> + +class ScDocument; +class ScTokenArray; + +namespace sc { + +struct RefUpdateContext; +struct RefUpdateInsertTabContext; +struct RefUpdateDeleteTabContext; +struct RefUpdateMoveTabContext; +class CompileFormulaContext; + +} + +class ScRangeData +{ +public: + enum class Type //specialization to typed_flags outside of class + { + Name = 0x0000, + Database = 0x0001, + Criteria = 0x0002, + PrintArea = 0x0004, + ColHeader = 0x0008, + RowHeader = 0x0010, + AbsArea = 0x0020, + RefArea = 0x0040, + AbsPos = 0x0080, + Hidden = 0x0100 + }; + + enum class IsNameValidType + { + NAME_VALID, + NAME_INVALID_CELL_REF, + NAME_INVALID_BAD_STRING + }; + +private: + OUString aName; + OUString aUpperName; // #i62977# for faster searching (aName is never modified after ctor) + OUString maNewName; ///< used for formulas after changing names in the dialog + std::unique_ptr<ScTokenArray> + pCode; + ScAddress aPos; + Type eType; + ScDocument& rDoc; + formula::FormulaGrammar::Grammar eTempGrammar; // needed for unresolved XML compiles + sal_uInt16 nIndex; + bool bModified; // is set/cleared by UpdateReference + + void CompileRangeData( const OUString& rSymbol, bool bSetError ); + void InitCode(); +public: + + SC_DLLPUBLIC ScRangeData( ScDocument& rDoc, + const OUString& rName, + const OUString& rSymbol, + const ScAddress& rAdr = ScAddress(), + Type nType = Type::Name, + const formula::FormulaGrammar::Grammar eGrammar = formula::FormulaGrammar::GRAM_DEFAULT ); + SC_DLLPUBLIC ScRangeData( ScDocument& rDoc, + const OUString& rName, + const ScTokenArray& rArr, + const ScAddress& rAdr = ScAddress(), + Type nType = Type::Name ); + SC_DLLPUBLIC ScRangeData( ScDocument& rDoc, + const OUString& rName, + const ScAddress& rTarget ); + // rTarget is ABSPOS jump label + + /* Exact copy, not recompiled, no other index (!), nothing... except if + * pDocument or pPos are passed, those values are assigned instead of the + * copies. */ + ScRangeData( const ScRangeData& rScRangeData, ScDocument* pDocument = nullptr, const ScAddress* pPos = nullptr ); + + SC_DLLPUBLIC ~ScRangeData(); + + bool operator== (const ScRangeData& rData) const; + + void GetName( OUString& rName ) const { rName = maNewName.isEmpty() ? aName : maNewName; } + const OUString& GetName() const { return maNewName.isEmpty() ? aName : maNewName; } + const OUString& GetUpperName() const { return aUpperName; } + const ScAddress& GetPos() const { return aPos; } + // The index has to be unique. If index=0 a new index value is assigned. + void SetIndex( sal_uInt16 nInd ) { nIndex = nInd; } + sal_uInt16 GetIndex() const { return nIndex; } + /// Does not change the name, but sets maNewName for formula update after dialog. + void SetNewName( const OUString& rNewName ) { maNewName = rNewName; } + ScTokenArray* GetCode() { return pCode.get(); } + SC_DLLPUBLIC void SetCode( const ScTokenArray& ); + const ScTokenArray* GetCode() const { return pCode.get(); } + SC_DLLPUBLIC FormulaError GetErrCode() const; + bool HasReferences() const; + void AddType( Type nType ); + Type GetType() const { return eType; } + bool HasType( Type nType ) const; + SC_DLLPUBLIC sal_uInt32 GetUnoType() const; + SC_DLLPUBLIC OUString GetSymbol( const formula::FormulaGrammar::Grammar eGrammar = formula::FormulaGrammar::GRAM_DEFAULT ) const; + SC_DLLPUBLIC OUString GetSymbol( const ScAddress& rPos, const formula::FormulaGrammar::Grammar eGrammar = formula::FormulaGrammar::GRAM_DEFAULT ) const; + void UpdateSymbol( OUStringBuffer& rBuffer, const ScAddress& ); + + /** + * @param nLocalTab sheet index where this name belongs, or -1 for global + * name. + */ + void UpdateReference( sc::RefUpdateContext& rCxt, SCTAB nLocalTab ); + bool IsModified() const { return bModified; } + + SC_DLLPUBLIC void GuessPosition(); + + void UpdateTranspose( const ScRange& rSource, const ScAddress& rDest ); + void UpdateGrow( const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY ); + + SC_DLLPUBLIC bool IsReference( ScRange& rRef ) const; + bool IsReference( ScRange& rRef, const ScAddress& rPos ) const; + SC_DLLPUBLIC bool IsValidReference( ScRange& rRef ) const; + bool IsRangeAtBlock( const ScRange& ) const; + + void UpdateInsertTab( sc::RefUpdateInsertTabContext& rCxt, SCTAB nLocalTab ); + void UpdateDeleteTab( sc::RefUpdateDeleteTabContext& rCxt, SCTAB nLocalTab ); + void UpdateMoveTab( sc::RefUpdateMoveTabContext& rCxt, SCTAB nLocalTab ); + + void ValidateTabRefs(); + + static void MakeValidName( const ScDocument& rDoc, OUString& rName ); + + SC_DLLPUBLIC static IsNameValidType IsNameValid( const OUString& rName, const ScDocument& rDoc ); + + bool HasPossibleAddressConflict() const; + + void CompileUnresolvedXML( sc::CompileFormulaContext& rCxt ); + +#if DEBUG_FORMULA_COMPILER + void Dump() const; +#endif +}; +namespace o3tl +{ + template<> struct typed_flags<ScRangeData::Type> : is_typed_flags<ScRangeData::Type, 0x1ff> {}; +} + + +inline void ScRangeData::AddType( Type nType ) +{ + eType = eType|nType; +} + +inline bool ScRangeData::HasType( Type nType ) const +{ + return ( ( eType & nType ) == nType ); +} + +extern "C" int ScRangeData_QsortNameCompare( const void*, const void* ); + +class ScRangeName +{ +private: + typedef std::vector<ScRangeData*> IndexDataType; + typedef ::std::map<OUString, std::unique_ptr<ScRangeData>> DataType; + DataType m_Data; + IndexDataType maIndexToData; + // Use for optimization, true if any of the contained names resolves + // as a valid cell address (e.g. 'day1' with 16k columns). + mutable bool mHasPossibleAddressConflict : 1; + mutable bool mHasPossibleAddressConflictDirty : 1; + + void checkHasPossibleAddressConflict() const; + +public: + /// Map that stores non-managed pointers to ScRangeName instances. + typedef ::std::map<SCTAB, const ScRangeName*> TabNameCopyMap; + + typedef DataType::const_iterator const_iterator; + typedef DataType::iterator iterator; + + ScRangeName(); + SC_DLLPUBLIC ScRangeName(const ScRangeName& r); + + SC_DLLPUBLIC const ScRangeData* findByRange(const ScRange& rRange) const; + SC_DLLPUBLIC ScRangeData* findByUpperName(const OUString& rName); + SC_DLLPUBLIC const ScRangeData* findByUpperName(const OUString& rName) const; + SC_DLLPUBLIC ScRangeData* findByIndex(sal_uInt16 i) const; + void UpdateReference( sc::RefUpdateContext& rCxt, SCTAB nLocalTab = -1 ); + void UpdateInsertTab( sc::RefUpdateInsertTabContext& rCxt, SCTAB nLocalTab = -1 ); + void UpdateDeleteTab( sc::RefUpdateDeleteTabContext& rCxt, SCTAB nLocalTab = -1 ); + void UpdateMoveTab( sc::RefUpdateMoveTabContext& rCxt, SCTAB nLocalTab = -1 ); + void UpdateTranspose(const ScRange& rSource, const ScAddress& rDest); + void UpdateGrow(const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY); + + /** Compile those names that couldn't be resolved during loading and + inserting because they may have referred a name that was inserted later. + */ + void CompileUnresolvedXML( sc::CompileFormulaContext& rCxt ); + + /** Copy names while copying a sheet if they reference the sheet to be copied. + + Assumes that new sheet was already inserted, global names have been + updated/adjusted, but sheet-local names on nOldTab are not, as is the + case in ScDocument::CopyTab() + + @param nLocalTab + -1 when operating on global names, else sheet/tab of + sheet-local name scope. The already adjusted tab on which to + find the name. + + @param nOldTab + The original unadjusted tab position. + + @param nNewTab + The new tab position. + */ + void CopyUsedNames( const SCTAB nLocalTab, const SCTAB nOldTab, const SCTAB nNewTab, + const ScDocument& rOldDoc, ScDocument& rNewDoc, const bool bGlobalNamesToLocal ) const; + + SC_DLLPUBLIC const_iterator begin() const { return m_Data.begin(); } + SC_DLLPUBLIC const_iterator end() const { return m_Data.end(); } + SC_DLLPUBLIC size_t size() const { return m_Data.size(); } + SC_DLLPUBLIC size_t index_size() const { return maIndexToData.size(); } + bool empty() const { return m_Data.empty(); } + + /** Insert object into set. + @ATTENTION: The underlying ::std::map<std::unique_ptr>::insert(p) takes + ownership of p and if it can't insert it deletes the object! So, if + this insert here returns false the object where p pointed to is gone! + + @param bReuseFreeIndex + If the ScRangeData p points to has an index value of 0: + If `TRUE` then reuse a free index slot if available. + If `FALSE` then assign a new index slot. The Manage Names + dialog uses this so that deleting and adding ranges in the same + run is guaranteed to not reuse previously assigned indexes. + */ + SC_DLLPUBLIC bool insert( ScRangeData* p, bool bReuseFreeIndex = true ); + + void erase(const ScRangeData& r); + void erase(const OUString& rName); + + /** + * Erase by iterator position. Note that this method doesn't check for + * iterator's validity. The caller must make sure that the iterator is + * valid. + */ + void erase(const_iterator itr); + + void clear(); + bool operator== (const ScRangeName& r) const; + + bool hasPossibleAddressConflict() const + { + if( mHasPossibleAddressConflictDirty ) + checkHasPossibleAddressConflict(); + return mHasPossibleAddressConflict; + } +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/rangeseq.hxx b/sc/inc/rangeseq.hxx new file mode 100644 index 0000000000..9f424d0f38 --- /dev/null +++ b/sc/inc/rangeseq.hxx @@ -0,0 +1,102 @@ +/* -*- 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 "types.hxx" +#include <com/sun/star/uno/TypeClass.hpp> + +namespace com::sun::star::uno { class Any; } + +class SvNumberFormatter; +class ScDocument; +class ScMatrix; +class ScRange; + +class ScRangeToSequence +{ +public: + static bool FillLongArray( css::uno::Any& rAny, + ScDocument& rDoc, const ScRange& rRange ); + static bool FillLongArray( css::uno::Any& rAny, + const ScMatrix* pMatrix ); + static bool FillDoubleArray( css::uno::Any& rAny, + ScDocument& rDoc, const ScRange& rRange ); + static bool FillDoubleArray( css::uno::Any& rAny, + const ScMatrix* pMatrix ); + static bool FillStringArray( css::uno::Any& rAny, + ScDocument& rDoc, const ScRange& rRange ); + static bool FillStringArray( css::uno::Any& rAny, + const ScMatrix* pMatrix, SvNumberFormatter* pFormatter ); + static bool FillMixedArray( css::uno::Any& rAny, + ScDocument& rDoc, const ScRange& rRange, + bool bAllowNV = false ); + + /** @param bDataTypes + Additionally to the differentiation between string and double allow + differentiation between other types such as boolean. Needed for + implementation of XFormulaParser. If <FALSE/>, boolean values are + treated as ordinary double values 1 (true) and 0 (false). + */ + static bool FillMixedArray( css::uno::Any& rAny, + const ScMatrix* pMatrix, bool bDataTypes = false ); +}; + +class ScApiTypeConversion +{ +public: + + /** Convert a uno::Any to double if possible, including integer types. + @param o_fVal + Out: the double value on successful conversion. + @param o_eClass + Out: the uno::TypeClass of rAny. + @returns <TRUE/> if successfully converted. + */ + static bool ConvertAnyToDouble( + double & o_fVal, + css::uno::TypeClass & o_eClass, + const css::uno::Any & rAny ); + +}; + +class ScSequenceToMatrix +{ +public: + + /** Convert a sequence of mixed elements to ScMatrix. + + Precondition: rAny.getValueType().equals( cppu::UnoType< uno::Sequence< uno::Sequence< uno::Any > > >::get() ) + + @returns a new'd ScMatrix as ScMatrixRef, NULL if rAny couldn't be read + as type Sequence<Sequence<Any>> + */ + static ScMatrixRef CreateMixedMatrix( const css::uno::Any & rAny ); + +}; + +class ScByteSequenceToString +{ +public: + // rAny must contain either OUString or Sequence<sal_Int8> (thread encoding assumed), + // may or may not contain 0-bytes at the end + static bool GetString( OUString& rString, const css::uno::Any& rAny ); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/rangeutl.hxx b/sc/inc/rangeutl.hxx new file mode 100644 index 0000000000..852c82b11b --- /dev/null +++ b/sc/inc/rangeutl.hxx @@ -0,0 +1,291 @@ +/* -*- 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 "address.hxx" +#include "rangenam.hxx" +#include "dbdata.hxx" +#include "scdllapi.h" + +namespace com::sun::star::table { struct CellAddress; } +namespace com::sun::star::table { struct CellRangeAddress; } +namespace com::sun::star::uno { template <typename > class Sequence; } + +class ScArea; +class ScDocument; +class ScRangeList; + +enum RutlNameScope +{ + RUTL_NONE = 0, + RUTL_NAMES, + RUTL_NAMES_LOCAL, + RUTL_NAMES_GLOBAL, + RUTL_DBASE +}; + +class SC_DLLPUBLIC ScRangeUtil +{ +public: + ScRangeUtil() = delete; + + static bool MakeArea ( const OUString& rAreaStr, + ScArea& rArea, + const ScDocument& rDoc, + SCTAB nTab, + ScAddress::Details const & rDetails ); + + static void CutPosString ( const OUString& theAreaStr, + OUString& thePosStr ); + + static bool IsAbsTabArea ( const OUString& rAreaStr, + const ScDocument* pDoc, + std::unique_ptr<ScArea[]>* ppAreas, + sal_uInt16* pAreaCount, + bool bAcceptCellRef = false, + ScAddress::Details const & rDetails = ScAddress::detailsOOOa1 ); + + static bool IsAbsArea ( const OUString& rAreaStr, + const ScDocument& rDoc, + SCTAB nTab, + OUString* pCompleteStr, + ScRefAddress* pStartPos = nullptr, + ScRefAddress* pEndPos = nullptr, + ScAddress::Details const & rDetails = ScAddress::detailsOOOa1 ); + + static bool IsAbsPos ( const OUString& rPosStr, + const ScDocument& rDoc, + SCTAB nTab, + OUString* pCompleteStr, + ScRefAddress* pPosTripel = nullptr, + ScAddress::Details const & rDetails = ScAddress::detailsOOOa1 ); + + static bool MakeRangeFromName( const OUString& rName, + const ScDocument& rDoc, + SCTAB nCurTab, + ScRange& rRange, + RutlNameScope eScope=RUTL_NAMES, + ScAddress::Details const & rDetails = ScAddress::detailsOOOa1, + bool bUseDetailsPos = false ); +}; + +class SC_DLLPUBLIC ScRangeStringConverter +{ +public: + +/// helper methods + static void AssignString( + OUString& rString, + const OUString& rNewStr, + bool bAppendStr, + sal_Unicode cSeparator = ' '); + + static sal_Int32 IndexOf( + std::u16string_view rString, + sal_Unicode cSearchChar, + sal_Int32 nOffset, + sal_Unicode cQuote = '\''); + + static sal_Int32 IndexOfDifferent( + std::u16string_view rString, + sal_Unicode cSearchChar, + sal_Int32 nOffset ); + + static sal_Int32 GetTokenCount( + std::u16string_view rString, + sal_Unicode cSeparator = ' '); + + static void GetTokenByOffset( + OUString& rToken, + std::u16string_view rString, + sal_Int32& nOffset, + sal_Unicode cSeparator = ' ', + sal_Unicode cQuote = '\''); + + static void AppendTableName( + OUStringBuffer& rBuf, + const OUString& rTabName); + +/// String to Range core + static bool GetAddressFromString( + ScAddress& rAddress, + std::u16string_view rAddressStr, + const ScDocument& rDocument, + formula::FormulaGrammar::AddressConvention eConv, + sal_Int32& nOffset, + sal_Unicode cSeparator = ' ', + sal_Unicode cQuote = '\''); + static bool GetRangeFromString( + ScRange& rRange, + std::u16string_view rRangeStr, + const ScDocument& rDocument, + formula::FormulaGrammar::AddressConvention eConv, + sal_Int32& nOffset, + sal_Unicode cSeparator = ' ', + sal_Unicode cQuote = '\''); + static bool GetRangeListFromString( + ScRangeList& rRangeList, + std::u16string_view rRangeListStr, + const ScDocument& rDocument, + formula::FormulaGrammar::AddressConvention eConv, + sal_Unicode cSeparator = ' ', + sal_Unicode cQuote = '\''); + + static bool GetAreaFromString( + ScArea& rArea, + std::u16string_view rRangeStr, + const ScDocument& rDocument, + formula::FormulaGrammar::AddressConvention eConv, + sal_Int32& nOffset, + sal_Unicode cSeparator = ' '); + +/// String to Range API + static bool GetRangeFromString( + css::table::CellRangeAddress& rRange, + std::u16string_view rRangeStr, + const ScDocument& rDocument, + formula::FormulaGrammar::AddressConvention eConv, + sal_Int32& nOffset, + sal_Unicode cSeparator = ' '); + +/// Range to String core + static void GetStringFromAddress( + OUString& rString, + const ScAddress& rAddress, + const ScDocument* pDocument, + formula::FormulaGrammar::AddressConvention eConv, + sal_Unicode cSeparator = ' ', + bool bAppendStr = false, + ScRefFlags nFormatFlags = ScRefFlags::VALID | ScRefFlags::TAB_3D ); + static void GetStringFromRange( + OUString& rString, + const ScRange& rRange, + const ScDocument* pDocument, + formula::FormulaGrammar::AddressConvention eConv, + sal_Unicode cSeparator = ' ', + bool bAppendStr = false, + ScRefFlags nFormatFlags = ScRefFlags::VALID | ScRefFlags::TAB_3D ); + static void GetStringFromRangeList( + OUString& rString, + const ScRangeList* pRangeList, + const ScDocument* pDocument, + formula::FormulaGrammar::AddressConvention eConv, + sal_Unicode cSeparator = ' '); + + static void GetStringFromArea( + OUString& rString, + const ScArea& rArea, + const ScDocument* pDocument, + formula::FormulaGrammar::AddressConvention eConv, + sal_Unicode cSeparator, + bool bAppendStr = false, + ScRefFlags nFormatFlags = ScRefFlags::VALID | ScRefFlags::TAB_3D ); + +/// Range to String API + static void GetStringFromAddress( + OUString& rString, + const css::table::CellAddress& rAddress, + const ScDocument* pDocument, + formula::FormulaGrammar::AddressConvention eConv, + sal_Unicode cSeparator = ' ', + bool bAppendStr = false ); + static void GetStringFromRange( + OUString& rString, + const css::table::CellRangeAddress& rRange, + const ScDocument* pDocument, + formula::FormulaGrammar::AddressConvention eConv, + sal_Unicode cSeparator = ' ', + bool bAppendStr = false, + ScRefFlags nFormatFlags = ScRefFlags::VALID | ScRefFlags::TAB_3D ); + static void GetStringFromRangeList( + OUString& rString, + const css::uno::Sequence< css::table::CellRangeAddress >& rRangeSeq, + const ScDocument* pDocument, + formula::FormulaGrammar::AddressConvention eConv, + sal_Unicode cSeparator = ' ' ); + +/// XML Range to Calc Range + static void GetStringFromXMLRangeString( + OUString& rString, + std::u16string_view rXMLRange, + const ScDocument& rDoc ); + +/// String to RangeData core + static ScRangeData* GetRangeDataFromString( const OUString& rString, const SCTAB nTab, + const ScDocument& rDoc, formula::FormulaGrammar::AddressConvention eConv ); +}; + +class ScArea +{ +public: + ScArea( SCTAB tab = 0, + SCCOL colStart = 0, + SCROW rowStart = 0, + SCCOL colEnd = 0, + SCROW rowEnd = 0 ); + + bool operator== ( const ScArea& r ) const; + +public: + SCTAB nTab; + SCCOL nColStart; + SCROW nRowStart; + SCCOL nColEnd; + SCROW nRowEnd; +}; + +/// @return areas with reference and all db-areas + +class SC_DLLPUBLIC ScAreaNameIterator +{ +private: + ScRangeName* pRangeName; + ScDBCollection* pDBCollection; + ScRangeName::const_iterator maRNPos; + ScRangeName::const_iterator maRNEnd; + ScDBCollection::NamedDBs::const_iterator maDBPos; + ScDBCollection::NamedDBs::const_iterator maDBEnd; + bool bFirstPass; + +public: + ScAreaNameIterator( const ScDocument& rDoc ); + + bool Next( OUString& rName, ScRange& rRange ); + bool WasDBName() const { return !bFirstPass; } +}; + +struct SC_DLLPUBLIC ScRangeUpdater +{ + ScRangeUpdater() = delete; + + static void UpdateInsertTab(ScAddress& rAddr, const sc::RefUpdateInsertTabContext& rCxt); + + /** This is for the base-cell-address of a defined name or conditional + format, not for references. A sheet position on or after the start of + the deleted range is moved towards the beginning by the amount of + deleted sheets, within the deleted range to the front of that or set to + 0 (as there is always at least one sheet in a document) if the position + would result in a negative value, e.g. if position was 0 and (only) + sheet 0 is deleted it would had become -1. + */ + static void UpdateDeleteTab(ScAddress& rAddr, const sc::RefUpdateDeleteTabContext& rCxt); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/rechead.hxx b/sc/inc/rechead.hxx new file mode 100644 index 0000000000..aa3d272835 --- /dev/null +++ b/sc/inc/rechead.hxx @@ -0,0 +1,85 @@ +/* -*- 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 <tools/stream.hxx> +#include <memory> + +// ID's for files: + +#define SCID_SIZES 0x4200 + + +#define SC_31_EXPORT_VER 0x0012 // version for 3.1-export +// since 4.0 +#define SC_FONTCHARSET 0x0101 // Font-CharSets have to be right + +// since 5.0 +#define SC_MATRIX_DOUBLEREF 0x0202 // DoubleRef implicit intersection +// since 5.2 +#define SC_CURRENT_VERSION 0x0205 + +// all above SC_31_EXPORT_VER has to be queried during saving, +// because 3.1-export writes this version number. + +// btw: 10 following 09 is not a counting error but an intentional gap, +// because it was not clear, how long the RelRefs development would take. :) + + // Header with size specification for multiple objects + +class ScMultipleReadHeader +{ +private: + SvStream& rStream; + std::unique_ptr<sal_uInt8[]> + pBuf; + std::unique_ptr<SvMemoryStream> + pMemStream; + sal_uInt64 nEndPos; + sal_uInt64 nEntryEnd; + sal_uInt64 nTotalEnd; + +public: + ScMultipleReadHeader(SvStream& rNewStream); + ~ScMultipleReadHeader(); + + void StartEntry(); + void EndEntry(); + sal_uInt64 BytesLeft() const; +}; + +class ScMultipleWriteHeader +{ +private: + SvStream& rStream; + SvMemoryStream aMemStream; + sal_uInt64 nDataPos; + sal_uInt32 nDataSize; + sal_uInt64 nEntryStart; + +public: + ScMultipleWriteHeader(SvStream& rNewStream); + ~ScMultipleWriteHeader(); + + void StartEntry(); + void EndEntry(); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/recursionhelper.hxx b/sc/inc/recursionhelper.hxx new file mode 100644 index 0000000000..6c48509058 --- /dev/null +++ b/sc/inc/recursionhelper.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 "formularesult.hxx" + +#include <list> +#include <vector> +#include <stack> +#include <o3tl/sorted_vector.hxx> + +class ScFormulaCell; + +struct ScFormulaRecursionEntry +{ + ScFormulaCell* pCell; + bool bOldRunning; + ScFormulaResult aPreviousResult; + ScFormulaRecursionEntry( + ScFormulaCell* p, bool bR, const ScFormulaResult & rRes ) : + pCell(p), bOldRunning(bR), aPreviousResult( rRes) + { + } +}; + +typedef ::std::list< ScFormulaRecursionEntry > ScFormulaRecursionList; + +class ScRecursionHelper +{ + typedef ::std::stack< ScFormulaCell* > ScRecursionInIterationStack; + ScFormulaRecursionList aRecursionFormulas; + ScFormulaRecursionList::iterator aInsertPos; + ScFormulaRecursionList::iterator aLastIterationStart; + ScRecursionInIterationStack aRecursionInIterationStack; + std::vector< ScFormulaCell* > aFGList; + // Flag list corresponding to aFGList to indicate whether each formula-group + // is in a dependency evaluation mode or not. + std::vector< bool > aInDependencyEvalMode; + sal_uInt16 nRecursionCount; + sal_uInt16 nIteration; + // Count of ScFormulaCell::CheckComputeDependencies in current call-stack. + sal_uInt16 nDependencyComputationLevel; + bool bInRecursionReturn; + bool bDoingRecursion; + bool bInIterationReturn; + bool bConverging; + bool bGroupsIndependent; + bool bAbortingDependencyComputation; + std::vector< ScFormulaCell* > aTemporaryGroupCells; + o3tl::sorted_vector< ScFormulaCellGroup* >* pFGSet; + + void Init(); + void ResetIteration(); + +public: + + ScRecursionHelper(); + sal_uInt16 GetRecursionCount() const { return nRecursionCount; } + void IncRecursionCount() { ++nRecursionCount; } + void DecRecursionCount() { --nRecursionCount; } + sal_uInt16 GetDepComputeLevel() const { return nDependencyComputationLevel; } + void IncDepComputeLevel(); + void DecDepComputeLevel(); + /// A pure recursion return, no iteration. + bool IsInRecursionReturn() const { return bInRecursionReturn && + !bInIterationReturn; } + void SetInRecursionReturn( bool b ); + bool IsDoingRecursion() const { return bDoingRecursion; } + void SetDoingRecursion( bool b ) { bDoingRecursion = b; } + + void Insert( ScFormulaCell* p, bool bOldRunning, const ScFormulaResult & rRes ); + + bool IsInIterationReturn() const { return bInIterationReturn; } + void SetInIterationReturn( bool b ); + bool IsDoingIteration() const { return nIteration > 0; } + sal_uInt16 GetIteration() const { return nIteration; } + bool & GetConvergingReference() { return bConverging; } + void StartIteration(); + void ResumeIteration(); + void IncIteration(); + void EndIteration(); + + const ScFormulaRecursionList::iterator& GetLastIterationStart() const { return aLastIterationStart; } + ScFormulaRecursionList::iterator GetIterationStart(); + ScFormulaRecursionList::iterator GetIterationEnd(); + /** Any return, recursion or iteration, iteration is always coupled with + recursion. */ + bool IsInReturn() const { return bInRecursionReturn; } + const ScFormulaRecursionList& GetList() const { return aRecursionFormulas; } + ScFormulaRecursionList& GetList() { return aRecursionFormulas; } + ScRecursionInIterationStack& GetRecursionInIterationStack() { return aRecursionInIterationStack; } + + void Clear(); + + /** Detects a simple cycle involving formula-groups and singleton formula-cells. */ + bool PushFormulaGroup(ScFormulaCell* pCell); + void PopFormulaGroup(); + bool AnyCycleMemberInDependencyEvalMode(const ScFormulaCell* pCell); + bool AnyParentFGInCycle(); + void SetFormulaGroupDepEvalMode(bool bSet); + // When dependency computation detects a cycle, it may not compute proper cell values. + // This sets a flag that ScFormulaCell will use to avoid setting those new values + // and resetting the dirty flag, until the dependency computation bails out. + void AbortDependencyComputation(); + bool IsAbortingDependencyComputation() const { return bAbortingDependencyComputation; } + + void AddTemporaryGroupCell(ScFormulaCell* cell); + void CleanTemporaryGroupCells(); + + void SetFormulaGroupSet(o3tl::sorted_vector<ScFormulaCellGroup*>* pSet) { pFGSet = pSet; } + bool HasFormulaGroupSet() const { return pFGSet != nullptr; } + bool CheckFGIndependence(ScFormulaCellGroup* pFG); + void SetGroupsIndependent(bool bSet) { bGroupsIndependent = bSet; } + bool AreGroupsIndependent() { return bGroupsIndependent; } +}; + +/** A class to wrap ScRecursionHelper::PushFormulaGroup(), + ScRecursionHelper::PopFormulaGroup() and make these calls + exception safe. */ +class ScFormulaGroupCycleCheckGuard +{ + ScRecursionHelper& mrRecHelper; + bool mbShouldPop; +public: + ScFormulaGroupCycleCheckGuard() = delete; + ScFormulaGroupCycleCheckGuard(ScRecursionHelper& rRecursionHelper, ScFormulaCell* pCell); + ~ScFormulaGroupCycleCheckGuard(); + +}; + +class ScFormulaGroupDependencyComputeGuard +{ + ScRecursionHelper& mrRecHelper; +public: + ScFormulaGroupDependencyComputeGuard() = delete; + ScFormulaGroupDependencyComputeGuard(ScRecursionHelper& rRecursionHelper); + ~ScFormulaGroupDependencyComputeGuard(); +}; + +class ScCheckIndependentFGGuard +{ + ScRecursionHelper& mrRecHelper; + bool mbUsedFGSet; +public: + ScCheckIndependentFGGuard() = delete; + ScCheckIndependentFGGuard(ScRecursionHelper& rRecursionHelper, + o3tl::sorted_vector<ScFormulaCellGroup*>* pSet); + ~ScCheckIndependentFGGuard(); + + bool AreGroupsIndependent(); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/refdata.hxx b/sc/inc/refdata.hxx new file mode 100644 index 0000000000..d893248ba0 --- /dev/null +++ b/sc/inc/refdata.hxx @@ -0,0 +1,201 @@ +/* -*- 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 "address.hxx" +#include "scdllapi.h" +#include "calcmacros.hxx" + +struct ScSheetLimits; + +/// Single reference (one address) into the sheet +struct SC_DLLPUBLIC ScSingleRefData +{ +private: + SCCOL mnCol; + SCROW mnRow; + SCTAB mnTab; + + union + { + sal_uInt8 mnFlagValue; + struct + { + bool bColRel :1; + bool bColDeleted :1; + bool bRowRel :1; + bool bRowDeleted :1; + bool bTabRel :1; + bool bTabDeleted :1; + bool bFlag3D :1; ///< 3D-Ref + bool bRelName :1; ///< Reference derived from RangeName with relative values + } Flags; + }; + +public: + /// No default ctor, because used in ScRawToken union, set InitFlags! + void InitFlags() { mnFlagValue = 0; } ///< all FALSE + /// InitAddress: InitFlags and set address + void InitAddress( const ScAddress& rAdr ); + void InitAddress( SCCOL nCol, SCROW nRow, SCTAB nTab ); + /// InitAddressRel: InitFlags and set address, everything relative to rPos + void InitAddressRel( const ScDocument& rDoc, const ScAddress& rAdr, const ScAddress& rPos ); + /// InitFlags and set address, relative to rPos if rRef says so. + void InitFromRefAddress( const ScDocument& rDoc, const ScRefAddress& rRef, const ScAddress& rPos ); + sal_uInt8 FlagValue() const { return mnFlagValue;} + + void SetColRel( bool bVal ) { Flags.bColRel = bVal; } + bool IsColRel() const { return Flags.bColRel; } + void SetRowRel( bool bVal ) { Flags.bRowRel = bVal; } + bool IsRowRel() const { return Flags.bRowRel; } + void SetTabRel( bool bVal ) { Flags.bTabRel = bVal; } + bool IsTabRel() const { return Flags.bTabRel; } + + void SetAbsCol( SCCOL nVal ); + void SetRelCol( SCCOL nVal ); + void IncCol( SCCOL nInc ); + void SetAbsRow( SCROW nVal ); + void SetRelRow( SCROW nVal ); + void IncRow( SCROW nInc ); + void SetAbsTab( SCTAB nVal ); + void SetRelTab( SCTAB nVal ); + void IncTab( SCTAB nInc ); + + void SetColDeleted( bool bVal ); + bool IsColDeleted() const { return Flags.bColDeleted;} + void SetRowDeleted( bool bVal ); + bool IsRowDeleted() const { return Flags.bRowDeleted;} + void SetTabDeleted( bool bVal ); + bool IsTabDeleted() const { return Flags.bTabDeleted;} + bool IsDeleted() const; + + void SetFlag3D( bool bVal ) { Flags.bFlag3D = bVal; } + bool IsFlag3D() const { return Flags.bFlag3D; } + void SetRelName( bool bVal ) { Flags.bRelName = bVal; } + bool IsRelName() const { return Flags.bRelName; } + + bool Valid(const ScDocument& rDoc) const; + bool ColValid(const ScDocument& rDoc) const; + bool RowValid(const ScDocument& rDoc) const; + bool TabValid(const ScDocument& rDoc) const; + /** In external references nTab is -1 if the external document was not + loaded but the sheet was cached, or >=0 if the external document was + loaded. */ + bool ValidExternal(const ScDocument& rDoc) const; + + ScAddress toAbs( const ScSheetLimits& rLimits, const ScAddress& rPos ) const; + ScAddress toAbs( const ScDocument& rDoc, const ScAddress& rPos ) const; + void SetAddress( const ScSheetLimits& rLimits, const ScAddress& rAddr, const ScAddress& rPos ); + SCROW Row() const; + SCCOL Col() const; + SCTAB Tab() const; + + /** Adjust ordering (front-top-left/rear-bottom-right) to a new position. */ + static void PutInOrder( ScSingleRefData& rRef1, ScSingleRefData& rRef2, const ScAddress& rPos ); + + bool operator==( const ScSingleRefData& ) const; + bool operator!=( const ScSingleRefData& ) const; + +#if DEBUG_FORMULA_COMPILER + void Dump( int nIndent = 0 ) const; +#endif +}; + +/// Complex reference (a range) into the sheet +struct ScComplexRefData +{ + ScSingleRefData Ref1; + ScSingleRefData Ref2; + bool bTrimToData = false; + + void InitFlags() + { Ref1.InitFlags(); Ref2.InitFlags(); } + void InitRange( const ScRange& rRange ) + { + Ref1.InitAddress( rRange.aStart ); + Ref2.InitAddress( rRange.aEnd ); + } + void InitRangeRel( const ScDocument& rDoc, const ScRange& rRange, const ScAddress& rPos ) + { + Ref1.InitAddressRel( rDoc, rRange.aStart, rPos ); + Ref2.InitAddressRel( rDoc, rRange.aEnd, rPos ); + } + void InitRange( SCCOL nCol1, SCROW nRow1, SCTAB nTab1, + SCCOL nCol2, SCROW nRow2, SCTAB nTab2 ) + { + Ref1.InitAddress( nCol1, nRow1, nTab1 ); + Ref2.InitAddress( nCol2, nRow2, nTab2 ); + } + + /// InitFlags and set range, relative to rPos if rRef1 and rRef2 say so. + void InitFromRefAddresses( const ScDocument& rDoc, const ScRefAddress& rRef1, const ScRefAddress& rRef2, const ScAddress& rPos ); + + bool Valid(const ScDocument& rDoc) const; + + /** In external references nTab is -1 for the start tab and -1 for the end + tab if one sheet and the external document was not loaded but sheet was + cached, or >=0 also if more than one sheets. */ + bool ValidExternal(const ScDocument& rDoc) const; + + /** Whether this references entire columns, A:A */ + bool IsEntireCol( const ScSheetLimits& rLimits ) const; + + /** Whether this references entire rows, 1:1 */ + bool IsEntireRow( const ScSheetLimits& rLimits ) const; + + SC_DLLPUBLIC ScRange toAbs( const ScSheetLimits& rLimits, const ScAddress& rPos ) const; + SC_DLLPUBLIC ScRange toAbs( const ScDocument& rDoc, const ScAddress& rPos ) const; + + /** Set a new range, assuming that the ordering of the range matches the + ordering of the reference data flags already set. */ + void SetRange( const ScSheetLimits& rLimits, const ScRange& rRange, const ScAddress& rPos ); + + /** Adjust ordering (front-top-left/rear-bottom-right) to a new position. */ + void PutInOrder( const ScAddress& rPos ); + + bool operator==( const ScComplexRefData& r ) const + { return Ref1 == r.Ref1 && Ref2 == r.Ref2; } + /** Enlarge range if reference passed is not within existing range. + ScAddress position is used to calculate absolute references from + relative references. */ + ScComplexRefData& Extend( const ScSheetLimits& rLimits, const ScSingleRefData & rRef, const ScAddress & rPos ); + ScComplexRefData& Extend( const ScSheetLimits& rLimits, const ScComplexRefData & rRef, const ScAddress & rPos ); + + /** Increment or decrement end column unless or until sticky. + @see ScRange::IncEndColSticky() + @return TRUE if changed. */ + bool IncEndColSticky( const ScDocument& rDoc, SCCOL nDelta, const ScAddress& rPos ); + + /** Increment or decrement end row unless or until sticky. + @see ScRange::IncEndRowSticky() + @return TRUE if changed. */ + bool IncEndRowSticky( const ScDocument& rDoc, SCROW nDelta, const ScAddress& rPos ); + + bool IsDeleted() const; + + bool IsTrimToData() const { return bTrimToData; } + void SetTrimToData(bool bSet) { bTrimToData = bSet; } + +#if DEBUG_FORMULA_COMPILER + void Dump( int nIndent = 0 ) const; +#endif +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/reffind.hxx b/sc/inc/reffind.hxx new file mode 100644 index 0000000000..419bf56a69 --- /dev/null +++ b/sc/inc/reffind.hxx @@ -0,0 +1,50 @@ +/* -*- 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 "address.hxx" + +class ScDocument; + +class ScRefFinder +{ + OUString maFormula; + formula::FormulaGrammar::AddressConvention meConv; + ScDocument& mrDoc; + ScAddress maPos; + sal_Int32 mnFound; + sal_Int32 mnSelStart; + sal_Int32 mnSelEnd; + +public: + ScRefFinder(OUString aFormula, const ScAddress& rPos, ScDocument& rDoc, + formula::FormulaGrammar::AddressConvention eConvP + = formula::FormulaGrammar::CONV_OOO); + ~ScRefFinder(); + + const OUString& GetText() const { return maFormula; } + sal_Int32 GetFound() const { return mnFound; } + sal_Int32 GetSelStart() const { return mnSelStart; } + sal_Int32 GetSelEnd() const { return mnSelEnd; } + + void ToggleRel(sal_Int32 nStartPos, sal_Int32 nEndPos); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/refhint.hxx b/sc/inc/refhint.hxx new file mode 100644 index 0000000000..ad13287ede --- /dev/null +++ b/sc/inc/refhint.hxx @@ -0,0 +1,110 @@ +/* -*- 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/. + */ + +#pragma once + +#include "types.hxx" +#include <svl/hint.hxx> + +namespace sc { + +struct RefUpdateContext; +class ColRowReorderMapType; + +class RefHint : public SfxHint +{ +public: + enum Type { + ColumnReordered, + RowReordered, + StartListening, + StopListening + }; + +private: + Type meType; + +protected: + RefHint( Type eType ); + +public: + RefHint() = delete; + virtual ~RefHint() override = 0; + + RefHint(RefHint const &) = default; + RefHint(RefHint &&) = default; + RefHint & operator =(RefHint const &) = delete; + RefHint & operator =(RefHint &&) = delete; + + Type getType() const; +}; + +class RefColReorderHint final : public RefHint +{ + const sc::ColRowReorderMapType& mrColMap; + SCTAB mnTab; + SCROW mnRow1; + SCROW mnRow2; + +public: + RefColReorderHint( const sc::ColRowReorderMapType& rColMap, SCTAB nTab, SCROW nRow1, SCROW nRow2 ); + virtual ~RefColReorderHint() override; + + RefColReorderHint(RefColReorderHint const &) = default; + RefColReorderHint(RefColReorderHint &&) = default; + RefColReorderHint & operator =(RefColReorderHint const &) = delete; // due to mrColMap + RefColReorderHint & operator =(RefColReorderHint &&) = delete; // due to mrColMap + + const sc::ColRowReorderMapType& getColMap() const; + + SCTAB getTab() const; + SCROW getStartRow() const; + SCROW getEndRow() const; +}; + +class RefRowReorderHint final : public RefHint +{ + const sc::ColRowReorderMapType& mrRowMap; + SCTAB mnTab; + SCCOL mnCol1; + SCCOL mnCol2; + +public: + RefRowReorderHint( const sc::ColRowReorderMapType& rRowMap, SCTAB nTab, SCCOL nCol1, SCCOL nCol2 ); + virtual ~RefRowReorderHint() override; + + RefRowReorderHint(RefRowReorderHint const &) = default; + RefRowReorderHint(RefRowReorderHint &&) = default; + RefRowReorderHint & operator =(RefRowReorderHint const &) = delete; // due to mrRowMap + RefRowReorderHint & operator =(RefRowReorderHint &&) = delete; // due to mrRowMap + + const sc::ColRowReorderMapType& getRowMap() const; + + SCTAB getTab() const; + SCCOL getStartColumn() const; + SCCOL getEndColumn() const; +}; + +class RefStartListeningHint final : public RefHint +{ +public: + RefStartListeningHint(); + virtual ~RefStartListeningHint() override; +}; + +class RefStopListeningHint final : public RefHint +{ +public: + RefStopListeningHint(); + virtual ~RefStopListeningHint() override; +}; + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/refreshtimer.hxx b/sc/inc/refreshtimer.hxx new file mode 100644 index 0000000000..16ae0c7201 --- /dev/null +++ b/sc/inc/refreshtimer.hxx @@ -0,0 +1,67 @@ +/* -*- 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 <sal/config.h> + +#include <vcl/timer.hxx> +#include "scdllapi.h" +#include <memory> +#include <mutex> + +class ScRefreshTimerControl +{ + std::recursive_mutex aMutex; + sal_uInt16 nBlockRefresh; + +public: + ScRefreshTimerControl() : nBlockRefresh(0) {} + void SetAllowRefresh( bool b ); + bool IsRefreshAllowed() const { return !nBlockRefresh; } + std::recursive_mutex& GetMutex() { return aMutex; } +}; + +class ScRefreshTimer : public AutoTimer +{ + std::unique_ptr<ScRefreshTimerControl> const * ppControl; + +public: + ScRefreshTimer(); + ScRefreshTimer( sal_Int32 nSeconds ); + ScRefreshTimer( const ScRefreshTimer& r ); + virtual ~ScRefreshTimer() override; + + ScRefreshTimer& operator=( const ScRefreshTimer& r ); + bool operator==( const ScRefreshTimer& r ) const; + bool operator!=( const ScRefreshTimer& r ) const; + + void SetRefreshControl( std::unique_ptr<ScRefreshTimerControl> const * pp ); + void SetRefreshHandler( const Link<Timer *, void>& rLink ); + sal_Int32 GetRefreshDelaySeconds() const; + void StopRefreshTimer(); + + void SetRefreshDelay( sal_Int32 nSeconds ); + SC_DLLPUBLIC virtual void Invoke() override; + +private: + void Launch(); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/refreshtimerprotector.hxx b/sc/inc/refreshtimerprotector.hxx new file mode 100644 index 0000000000..fa89858eb9 --- /dev/null +++ b/sc/inc/refreshtimerprotector.hxx @@ -0,0 +1,27 @@ +/* -*- 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/. + */ + +#pragma once + +#include <sal/config.h> +#include "scdllapi.h" +#include <memory> + +class ScRefreshTimerControl; + +class SC_DLLPUBLIC ScRefreshTimerProtector +{ + std::unique_ptr<ScRefreshTimerControl> const& m_rpControl; + +public: + ScRefreshTimerProtector(std::unique_ptr<ScRefreshTimerControl> const& rp); + ~ScRefreshTimerProtector(); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/reftokenhelper.hxx b/sc/inc/reftokenhelper.hxx new file mode 100644 index 0000000000..e0e3e0f68c --- /dev/null +++ b/sc/inc/reftokenhelper.hxx @@ -0,0 +1,67 @@ +/* -*- 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 "address.hxx" +#include "types.hxx" +#include "scdllapi.h" + +#include <vector> + +class ScDocument; +class ScRangeList; +struct ScComplexRefData; + +namespace ScRefTokenHelper +{ + /** + * Compile an array of reference tokens from a data source range string. + * The source range may consist of multiple ranges separated by ';'s. + */ + void compileRangeRepresentation( + ::std::vector<ScTokenRef>& rRefTokens, const OUString& rRangeStr, ScDocument& rDoc, + const sal_Unicode cSep, ::formula::FormulaGrammar::Grammar eGrammar, bool bOnly3DRef = false); + + bool getRangeFromToken(const ScDocument* pDoc, ScRange& rRange, const ScTokenRef& pToken, const ScAddress& rPos, bool bExternal = false); + + void getRangeListFromTokens(const ScDocument* pDoc, ScRangeList& rRangeList, const ::std::vector<ScTokenRef>& pTokens, const ScAddress& rPos); + + /** + * Create a double reference token from a range object. + */ + void getTokenFromRange(const ScDocument* pDoc, ScTokenRef& pToken, const ScRange& rRange); + + void getTokensFromRangeList(const ScDocument* pDoc, ::std::vector<ScTokenRef>& pTokens, const ScRangeList& rRanges); + + bool SC_DLLPUBLIC isRef(const ScTokenRef& pToken); + bool SC_DLLPUBLIC isExternalRef(const ScTokenRef& pToken); + + bool SC_DLLPUBLIC intersects(const ScDocument* pDoc, + const ::std::vector<ScTokenRef>& rTokens, const ScTokenRef& pToken, const ScAddress& rPos); + + void SC_DLLPUBLIC join(const ScDocument* pDoc, ::std::vector<ScTokenRef>& rTokens, const ScTokenRef& pToken, const ScAddress& rPos); + + bool getDoubleRefDataFromToken(ScComplexRefData& rData, const ScTokenRef& pToken); + + ScTokenRef createRefToken(const ScDocument& rDoc, const ScAddress& rAddr); + ScTokenRef createRefToken(const ScDocument& rDoc, const ScRange& rRange); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/refupdatecontext.hxx b/sc/inc/refupdatecontext.hxx new file mode 100644 index 0000000000..7789dfdc3a --- /dev/null +++ b/sc/inc/refupdatecontext.hxx @@ -0,0 +1,168 @@ +/* -*- 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/. + */ + +#pragma once + +#include "global.hxx" +#include "address.hxx" +#include "columnset.hxx" + +#include <unordered_map> +#include <unordered_set> + +class ScDocument; + +namespace sc +{ +struct ColumnBlockPosition; +class ColumnBlockPositionSet; + +/** + * Keep track of all named expressions that have been updated during + * reference update. + * + * Can also be used to collect any set of named expressions / ranges. + */ +class UpdatedRangeNames +{ +public: + typedef std::unordered_set<sal_uInt16> NameIndicesType; + + void setUpdatedName(SCTAB nTab, sal_uInt16 nIndex); + bool isNameUpdated(SCTAB nTab, sal_uInt16 nIndex) const; + NameIndicesType getUpdatedNames(SCTAB nTab) const; + bool isEmpty(SCTAB nTab) const; + +private: + typedef std::unordered_map<SCTAB, NameIndicesType> UpdatedNamesType; + + UpdatedNamesType maUpdatedNames; +}; + +/** + * Context for reference update during shifting, moving or copying of cell + * ranges. + */ +struct RefUpdateContext +{ + ScDocument& mrDoc; + + /** + * update mode - insert/delete, copy, or move. The reorder mode (which + * corresponds with the reordering of sheets) is not used with this + * context. + */ + UpdateRefMode meMode; + + /** + * Range of cells that are about to be moved for insert/delete/move modes. + * For copy mode, it's the destination range of cells that are about to be + * pasted. When moving a range of cells, it's the destination range, not + * the source range. + */ + ScRange maRange; + + /** Are the data transposed? */ + bool mbTransposed; + + /** Amount and direction of movement in the column direction. */ + SCCOL mnColDelta; + /** Amount and direction of movement in the row direction. */ + SCROW mnRowDelta; + /** Amount and direction of movement in the sheet direction. */ + SCTAB mnTabDelta; + + UpdatedRangeNames maUpdatedNames; + ColumnSet maRegroupCols; + + ColumnBlockPositionSet* mpBlockPos; // not owning + + RefUpdateContext(ScDocument& rDoc, ScDocument* pClipdoc = nullptr); + + bool isInserted() const; + bool isDeleted() const; + + void setBlockPositionReference(ColumnBlockPositionSet* blockPos); + ColumnBlockPosition* getBlockPosition(SCTAB nTab, SCCOL nCol); +}; + +struct RefUpdateResult +{ + /** + * When this flag is true, the result of the formula needs to be + * re-calculated either because it contains a reference that's been + * deleted, or the size of a range reference has changed. + */ + bool mbValueChanged; + + /** + * This flag indicates whether any reference in the token array has been + * modified. + */ + bool mbReferenceModified; + + /** + * When this flag is true, it indicates that the token array contains a + * range name that's been updated. + */ + bool mbNameModified; + + SCTAB mnTab; + + RefUpdateResult(); +}; + +struct SC_DLLPUBLIC RefUpdateInsertTabContext +{ + ScDocument& mrDoc; + SCTAB mnInsertPos; + SCTAB mnSheets; + UpdatedRangeNames maUpdatedNames; + + RefUpdateInsertTabContext(ScDocument& rDoc, SCTAB nInsertPos, SCTAB nSheets); +}; + +struct SC_DLLPUBLIC RefUpdateDeleteTabContext +{ + ScDocument& mrDoc; + SCTAB mnDeletePos; + SCTAB mnSheets; + UpdatedRangeNames maUpdatedNames; + + RefUpdateDeleteTabContext(ScDocument& rDoc, SCTAB nInsertPos, SCTAB nSheets); +}; + +struct RefUpdateMoveTabContext +{ + ScDocument& mrDoc; + SCTAB mnOldPos; + SCTAB mnNewPos; + UpdatedRangeNames maUpdatedNames; + + RefUpdateMoveTabContext(ScDocument& rDoc, SCTAB nOldPos, SCTAB nNewPos); + + SCTAB getNewTab(SCTAB nOldTab) const; +}; + +struct SetFormulaDirtyContext +{ + SCTAB mnTabDeletedStart; + SCTAB mnTabDeletedEnd; + + /** + * When true, go through all reference tokens and clears "sheet deleted" + * flag if its corresponding index falls within specified sheet range. + */ + bool mbClearTabDeletedFlag; + + SetFormulaDirtyContext(); +}; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/reordermap.hxx b/sc/inc/reordermap.hxx new file mode 100644 index 0000000000..4eca9bcbcd --- /dev/null +++ b/sc/inc/reordermap.hxx @@ -0,0 +1,36 @@ +/* -*- 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/. + */ + +#pragma once + +#include "types.hxx" +#include <unordered_map> + +namespace sc { + +class ColRowReorderMapType +{ + typedef std::unordered_map<SCCOLROW,SCCOLROW> DataType; + DataType maData; +public: + typedef DataType::value_type value_type; + typedef DataType::const_iterator const_iterator; + typedef DataType::iterator iterator; + + const_iterator end() const { return maData.end(); } + + template<class... Args> + std::pair<iterator,bool> emplace(Args&&... args) { return maData.emplace(std::forward<Args>(args)...); } + + const_iterator find( DataType::key_type key ) const { return maData.find(key); } +}; + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/rowheightcontext.hxx b/sc/inc/rowheightcontext.hxx new file mode 100644 index 0000000000..699ef4d3e7 --- /dev/null +++ b/sc/inc/rowheightcontext.hxx @@ -0,0 +1,63 @@ +/* -*- 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/. + */ + +#pragma once + +#include "scdllapi.h" + +#include <tools/fract.hxx> +#include <vcl/vclptr.hxx> +#include <vcl/outdev.hxx> + +#include "compressedarray.hxx" +#include "types.hxx" + +using RowHeightsArray = ScCompressedArray<SCROW, sal_uInt16>; + +namespace sc { + +class SC_DLLPUBLIC RowHeightContext +{ + RowHeightsArray maHeights; + + double mfPPTX; + double mfPPTY; + Fraction maZoomX; + Fraction maZoomY; + VclPtr<OutputDevice> mpOutDev; + + sal_uInt16 mnExtraHeight; + bool mbForceAutoSize; /// whether to set height to optimal even when the manual height flag is set. + +public: + RowHeightContext( + SCROW nMaxRow, double fPPTX, double fPPTY, const Fraction& rZoomX, const Fraction& rZoomY, + OutputDevice* pOutDev ); + + ~RowHeightContext(); + + double getPPTX() const { return mfPPTX;} + double getPPTY() const { return mfPPTY;} + const Fraction& getZoomX() const { return maZoomX;} + const Fraction& getZoomY() const { return maZoomY;} + + OutputDevice* getOutputDevice() { return mpOutDev;} + + void setExtraHeight( sal_uInt16 nH ); + sal_uInt16 getExtraHeight() const { return mnExtraHeight;} + + void setForceAutoSize( bool b ); + bool isForceAutoSize() const { return mbForceAutoSize;} + + RowHeightsArray& getHeightArray() { return maHeights; } +}; + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/sc.hrc b/sc/inc/sc.hrc new file mode 100644 index 0000000000..f6f445fc5a --- /dev/null +++ b/sc/inc/sc.hrc @@ -0,0 +1,654 @@ +/* -*- 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 . + */ + +#ifndef SC_SC_HRC +#define SC_SC_HRC + +#include <svx/svxids.hrc> + +class ScTpPrintItem; +class SvxZoomSliderItem; + +// areas + +#ifndef SC_VIEW_START // duplicated in sfx2/sfxsids.hrc +#define SC_VIEW_START (SID_SC_START) +#endif +// SC_VIEW_END (SID_SC_START + 99) +#define SC_MESSAGE_START (SID_SC_START + 100) +// SC_MESSAGE_END (SID_SC_START + 199) +#ifndef SC_FUNCTION_START // duplicated in sfx2/sfxsids.hrc +#define SC_FUNCTION_START (SID_SC_START + 200) +#endif +// SC_FUNCTION_END (SID_SC_START + 299) +#define SC_PARAM_START (SID_SC_START + 300) +// SC_PARAM_END (SID_SC_START + 399) +#define SC_SIDEBAR_PROPERTY_BEGIN (SID_SC_START + 400) +// SC_SIDEBAR_PROPERTY_END (SID_SC_START + 499) + +// stay compatible to the past +#define SC_RESOURCE_START (RID_APP_START+5000) + +// help IDs - +// calc has a range of 2000 IDs +// the functions need 11*90 = 990 IDs + +#define HID_SC_SHEET_START (HID_SC_START + 1010) +#define HID_SC_SHELL_START (HID_SC_START + 1030) + +// help IDs for templates +#define HID_SC_SHEET_CELL_STD (HID_SC_SHEET_START +0 ) +#define HID_SC_SHEET_CELL_ERG1 (HID_SC_SHEET_START +2 ) +#define HID_SC_SHEET_PAGE_STD (HID_SC_SHEET_START +10 ) +#define HID_SC_SHEET_PAGE_REP (HID_SC_SHEET_START +11 ) + +// view-functions (max. 100) +#define FID_SCALESTATUS (SC_VIEW_START + 10) +#define SID_UPDATECHART (SC_VIEW_START + 13) + +// TabPage entry - Legacy selection +#define SID_SC_INPUT_LEGACY_CELL_SELECTION TypedWhichId<SfxBoolItem>(SC_VIEW_START + 15) +#define SID_SC_OPT_SORT_REF_UPDATE TypedWhichId<SfxBoolItem>(SC_VIEW_START + 16) + +// Format options +#define SID_SCFORMULAOPTIONS TypedWhichId<ScTpFormulaItem>(SC_VIEW_START + 20) +#define SID_SCDEFAULTSOPTIONS TypedWhichId<ScTpDefaultsItem>(SC_VIEW_START + 21) + + +#define SID_DATA_PROVIDER (SC_VIEW_START + 31) +#define SID_DATA_PROVIDER_REFRESH (SC_VIEW_START + 32) +#define SID_DATA_STREAMS_PLAY (SC_VIEW_START + 33) +#define SID_DATA_STREAMS_STOP (SC_VIEW_START + 34) +#define SID_DATA_STREAMS (SC_VIEW_START + 35) + +// slot-IDs for attributes +#define SID_SCATTR_PROTECTION (SC_VIEW_START + 36) // protection-page + +// other slot-IDs: +#define SID_SCUSERLISTS (SC_VIEW_START + 37) // user defined lists +#define RES_TBX_DUMMY (SC_VIEW_START + 38) // dummy-item +#define SID_SCVIEWOPTIONS TypedWhichId<ScTpViewItem>(SC_VIEW_START + 39) +#define SID_SCDOCOPTIONS TypedWhichId<ScTpCalcItem>(SC_VIEW_START + 40) + +// cursor movements as properties: +#define SID_CURRENTCELL TypedWhichId<SfxStringItem>(SC_VIEW_START + 41) +#define SID_CURRENTTAB TypedWhichId<SfxUInt16Item>(SC_VIEW_START + 42) +#define SID_CURRENTDOC TypedWhichId<SfxStringItem>(SC_VIEW_START + 43) +#define SID_CURRENTOBJECT TypedWhichId<SfxStringItem>(SC_VIEW_START + 44) + +// slot-IDs for special toolbox functions: +#define SID_NUMBER_CURRENCY (SC_VIEW_START + 45) +#define SID_NUMBER_PERCENT (SC_VIEW_START + 46) + +// "slot" IDs for input images: +// 47..51 are used for toolbox ids + +#define SID_NUMBER_STANDARD (SC_VIEW_START + 52) +#define SID_NUMBER_DATE (SC_VIEW_START + 53) +#define SID_NUMBER_TWODEC (SC_VIEW_START + 54) +#define SID_NUMBER_SCIENTIFIC (SC_VIEW_START + 55) +#define SID_NUMBER_TIME (SC_VIEW_START + 56) +#define SID_NUMBER_INCDEC (SC_VIEW_START + 57) +#define SID_NUMBER_DECDEC (SC_VIEW_START + 58) +#define SID_NUMBER_THOUSANDS (SC_VIEW_START + 59) + +// misc: +#define SID_LINKS (SC_VIEW_START + 60) +#define SID_INSERT_SMATH (SC_VIEW_START + 63) +// Put this here since all available slots for "SC_INPUT" are taken +#define SID_SC_INPUT_ENTER_PASTE_MODE TypedWhichId<SfxBoolItem>(SC_VIEW_START + 64) +#define SID_MIRROR_VERTICAL (SC_VIEW_START + 65) +#define SID_MIRROR_HORIZONTAL (SC_VIEW_START + 66) +#define SID_CELL_FORMAT_RESET (SC_VIEW_START + 67) +#define SID_SCPRINTOPTIONS TypedWhichId<ScTpPrintItem>(SC_VIEW_START + 68) +#define SID_WINDOW_SPLIT (SC_VIEW_START + 69) +#define SID_WINDOW_FIX (SC_VIEW_START + 70) +#define SID_DRAW_CHART (SC_VIEW_START + 71) +#define SID_UPDATETABLINKS (SC_VIEW_START + 72) + +// TabPage entry +#define SID_SC_INPUT_SELECTION TypedWhichId<SfxBoolItem>(SC_VIEW_START + 73) +#define SID_SC_INPUT_SELECTIONPOS TypedWhichId<SfxUInt16Item>(SC_VIEW_START + 74) +#define SID_SC_INPUT_EDITMODE TypedWhichId<SfxBoolItem>(SC_VIEW_START + 75) +#define SID_SC_INPUT_FMT_EXPAND TypedWhichId<SfxBoolItem>(SC_VIEW_START + 76) +#define SID_SC_INPUT_RANGEFINDER TypedWhichId<SfxBoolItem>(SC_VIEW_START + 77) +#define SID_SC_INPUT_REF_EXPAND TypedWhichId<SfxBoolItem>(SC_VIEW_START + 78) +#define SID_SC_INPUT_MARK_HEADER TypedWhichId<SfxBoolItem>(SC_VIEW_START + 79) + +#define SID_REIMPORT_AFTER_LOAD (SC_VIEW_START + 80) +#define SID_DRAW_NOTEEDIT (SC_VIEW_START + 81) + +#define SID_CHOOSE_DESIGN (SC_VIEW_START + 82) +#define SID_EURO_CONVERTER (SC_VIEW_START + 83) +//See include/sfx2/sfxsids.hrc for reserved usage of (SC_VIEW_START + 84) +#define SID_EXTERNAL_SOURCE (SC_VIEW_START + 85) + +#define SID_SC_INPUT_TEXTWYSIWYG TypedWhichId<SfxBoolItem>(SC_VIEW_START + 86) + +#define SID_ENABLE_HYPHENATION (SC_VIEW_START + 87) + +#define SID_RENAME_OBJECT (SC_VIEW_START + 88) +#define SID_FOCUS_INPUTLINE (SC_VIEW_START + 89) +#define SID_SELECT_TABLES TypedWhichId<SfxIntegerListItem>(SC_VIEW_START + 90) + +// new entry "Filter..." in DP popup menu +#define SID_DP_FILTER (SC_VIEW_START + 91) + +// replace cell contents warning +#define SID_SC_INPUT_REPLCELLSWARN TypedWhichId<SfxBoolItem>(SC_VIEW_START + 92) + +// additional IDs for list/range validity +#define FID_VALID_LISTTYPE TypedWhichId<SfxInt16Item>(SC_VIEW_START + 93) + +// #i68101# ID for changing title & description of an object +#define SID_TITLE_DESCRIPTION_OBJECT (SC_VIEW_START + 94) + +// #i59082# assign macro to shape +#define SID_ASSIGNMACRO (SC_VIEW_START + 95) + +// "Zoom / Synchronize sheets" in options dialog +#define SID_SC_OPT_SYNCZOOM TypedWhichId<SfxBoolItem>(SC_VIEW_START + 98) + +#define SID_SC_OPT_KEY_BINDING_COMPAT TypedWhichId<SfxUInt16Item>(SC_VIEW_START + 99) + +// NOTE: last valid ID is (SC_VIEW_START + 99) + +// messages + +#define FID_INPUTLINE_STATUS (SC_MESSAGE_START) +#define FID_INPUTLINE_ENTER (SC_MESSAGE_START + 1) +#define FID_REPAINT (SC_MESSAGE_START + 2) +#define SID_SOLVE (SC_MESSAGE_START + 6) +#define FID_FILTER_OK (SC_MESSAGE_START + 8) +#define FID_INPUTLINE_MATRIX (SC_MESSAGE_START + 11) +#define SID_DLG_RETOK (SC_MESSAGE_START + 12) +#define SID_STATUS_DOCPOS TypedWhichId<SfxStringItem>(SC_MESSAGE_START + 14) +#define SID_STATUS_PAGESTYLE TypedWhichId<SfxStringItem>(SC_MESSAGE_START + 15) +#define SID_STATUS_SELMODE TypedWhichId<SfxUInt16Item>(SC_MESSAGE_START + 16) +#define SID_DLG_MATRIX (SC_MESSAGE_START + 18) + +#define SID_STATUS_SELMODE_ERG (SC_MESSAGE_START + 22) +#define SID_STATUS_SELMODE_ERW (SC_MESSAGE_START + 23) +#define SID_STATUS_SELMODE_NORM (SC_MESSAGE_START + 24) + +#define SID_CHART_SOURCE TypedWhichId<SfxStringItem>(SC_MESSAGE_START + 25) +#define SID_CHART_NAME TypedWhichId<SfxStringItem>(SC_MESSAGE_START + 26) +#define SID_CHART_ADDSOURCE (SC_MESSAGE_START + 27) + +#define SID_AUTO_STYLE (SC_MESSAGE_START + 28) + +#define FID_INPUTLINE_BLOCK (SC_MESSAGE_START + 29) + +#define SID_STATUS_SUM TypedWhichId<SfxStringItem>(SC_MESSAGE_START + 30) + +#define SID_ENTER_STRING TypedWhichId<SfxStringItem>(SC_MESSAGE_START + 37) +#define SID_ROWCOL_SELCOUNT (SC_MESSAGE_START + 38) +#define SID_AUTO_SUM (SC_MESSAGE_START + 39) + +// messages for opening dialogs: +#define SID_OPENDLG_CONSOLIDATE (SC_MESSAGE_START + 50) +#define SID_OPENDLG_PIVOTTABLE (SC_MESSAGE_START + 51) +#define SID_OPENDLG_FUNCTION (SC_MESSAGE_START + 52) +#define SID_OPENDLG_SOLVE (SC_MESSAGE_START + 53) +#define SID_OPENDLG_TABOP (SC_MESSAGE_START + 54) +#define SID_OPENDLG_CURRENTCONDFRMT (SC_MESSAGE_START + 58) +#define SID_OPENDLG_CONDFRMT (SC_MESSAGE_START + 59) +#define SID_OPENDLG_OPTSOLVER (SC_MESSAGE_START + 60) +#define SID_VALIDITY_REFERENCE (SC_MESSAGE_START + 61) +#define SID_OPENDLG_CONDFRMT_MANAGER (SC_MESSAGE_START + 62) +#define SID_POPUP_CONDFRMT (SC_MESSAGE_START + 63) +#define SID_OPENDLG_CURRENTCONDFRMT_MANAGER (SC_MESSAGE_START + 64) +#define SID_OPENDLG_COLORSCALE (SC_MESSAGE_START + 66) +#define SID_OPENDLG_DATABAR (SC_MESSAGE_START + 67) +#define SID_OPENDLG_ICONSET (SC_MESSAGE_START + 68) +#define SID_OPENDLG_CONDDATE (SC_MESSAGE_START + 69) + +#define SID_RANDOM_NUMBER_GENERATOR_DIALOG (SC_MESSAGE_START + 70) +#define SID_SAMPLING_DIALOG (SC_MESSAGE_START + 71) +#define SID_DESCRIPTIVE_STATISTICS_DIALOG (SC_MESSAGE_START + 72) +#define SID_ANALYSIS_OF_VARIANCE_DIALOG (SC_MESSAGE_START + 73) +#define SID_CORRELATION_DIALOG (SC_MESSAGE_START + 74) +#define SID_COVARIANCE_DIALOG (SC_MESSAGE_START + 75) +#define SID_EXPONENTIAL_SMOOTHING_DIALOG (SC_MESSAGE_START + 76) +#define SID_MOVING_AVERAGE_DIALOG (SC_MESSAGE_START + 77) +#define SID_REGRESSION_DIALOG (SC_MESSAGE_START + 78) +#define SID_TTEST_DIALOG (SC_MESSAGE_START + 79) +#define SID_FTEST_DIALOG (SC_MESSAGE_START + 80) +#define SID_ZTEST_DIALOG (SC_MESSAGE_START + 81) +#define SID_CHI_SQUARE_TEST_DIALOG (SC_MESSAGE_START + 82) +#define SID_SEARCH_RESULTS_DIALOG (SC_MESSAGE_START + 83) +#define SID_WINDOW_FIX_ROW TypedWhichId<SfxInt32Item>(SC_MESSAGE_START + 84) +#define SID_WINDOW_FIX_COL TypedWhichId<SfxInt32Item>(SC_MESSAGE_START + 85) +#define SID_COLUMN_OPERATIONS (SC_MESSAGE_START + 86) +#define SID_ROW_OPERATIONS (SC_MESSAGE_START + 87) +#define SID_FOURIER_ANALYSIS_DIALOG (SC_MESSAGE_START + 88) +#define SID_SPARKLINE_DIALOG (SC_MESSAGE_START + 89) +#define SID_SPARKLINE_DATA_RANGE_DIALOG (SC_MESSAGE_START + 90) +#define SID_POPUP_EASY_CONDITIONAL_FORMAT (SC_MESSAGE_START + 91) +#define SID_EASY_CONDITIONAL_FORMAT_DIALOG (SC_MESSAGE_START + 92) + +// functions + +#define SID_OPEN_CALC (SC_FUNCTION_START + 4) +#define SID_CONVERT_FORMULA_TO_VALUE (SC_FUNCTION_START + 5) +#ifndef FILE_MENU_END // duplicated in sfx2/sfxsids.hrc +#define FILE_MENU_END (SC_FUNCTION_START + 20) +#endif + +#ifndef EDIT_MENU_START // duplicated in sfx2/sfxsids.hrc +#define EDIT_MENU_START (FILE_MENU_END) +#endif +#define FID_DELETE_CELL TypedWhichId<SfxStringItem>(EDIT_MENU_START + 2) +#define FID_DELETE_TABLE (EDIT_MENU_START + 3) +#define FID_FILL_TO_BOTTOM (EDIT_MENU_START + 4) +#define FID_FILL_TO_RIGHT (EDIT_MENU_START + 5) +#define FID_FILL_TO_TOP (EDIT_MENU_START + 6) +#define FID_FILL_TO_LEFT (EDIT_MENU_START + 7) +#define FID_FILL_TAB TypedWhichId<SfxStringItem>(EDIT_MENU_START + 8) +#define FID_FILL_SERIES TypedWhichId<SfxStringItem>(EDIT_MENU_START + 9) +#define FID_FILL_SINGLE_EDIT (EDIT_MENU_START + 10) +#define SID_HFEDIT (EDIT_MENU_START + 15) + +#define SID_DEL_ROWS (EDIT_MENU_START + 16)//JN +#define SID_DEL_COLS (EDIT_MENU_START + 17)//JN +// EDIT_MENU_START + 18 is defined in include/sfx2/sfxsids.hrc +#define FID_CHG_SHOW (EDIT_MENU_START + 19) + +#define EDIT_MENU_END (EDIT_MENU_START + 20) +#define VIEW_MENU_START (EDIT_MENU_END) + +#define FID_TOGGLEINPUTLINE TypedWhichId<SfxBoolItem>(VIEW_MENU_START + 1) +#define FID_TOGGLEHEADERS (VIEW_MENU_START + 2) +#define FID_SCALE TypedWhichId<SvxZoomItem>(VIEW_MENU_START + 4) +#define FID_TOGGLESYNTAX (VIEW_MENU_START + 5) +#define FID_TOGGLECOLROWHIGHLIGHTING (VIEW_MENU_START + 6) +#define FID_PAGEBREAKMODE (VIEW_MENU_START + 7) +#define FID_FUNCTION_BOX (VIEW_MENU_START + 8) +#define FID_NORMALVIEWMODE (VIEW_MENU_START + 9) +#define FID_TOGGLEFORMULA (VIEW_MENU_START + 10) + +#define FID_CHG_ACCEPT (VIEW_MENU_START + 18)// DANGER DIRTY ID +#define FID_CHG_COMMENT (VIEW_MENU_START + 19)// DANGER DIRTY ID +#define VIEW_MENU_END (VIEW_MENU_START + 20) + +#define INSERT_MENU_START (VIEW_MENU_END) +#define FID_INS_ROWBRK (INSERT_MENU_START + 1) +#define FID_INS_COLBRK (INSERT_MENU_START + 2) +#define FID_DEL_ROWBRK (INSERT_MENU_START + 3) +#define FID_DEL_COLBRK (INSERT_MENU_START + 4) +#define FID_INS_CELL_CONTENTS TypedWhichId<SfxStringItem>(INSERT_MENU_START + 5) +#define FID_INS_CELL TypedWhichId<SfxStringItem>(INSERT_MENU_START + 6) +#define FID_INS_ROW (INSERT_MENU_START + 7) +#define FID_INS_COLUMN (INSERT_MENU_START + 8) +#define FID_INS_TABLE TypedWhichId<SfxStringItem>(INSERT_MENU_START + 9) +#define SID_INS_FUNCTION (INSERT_MENU_START + 10) +#define FID_DEFINE_NAME (INSERT_MENU_START + 11) +#define FID_INSERT_NAME (INSERT_MENU_START + 12) +#define FID_USE_NAME (INSERT_MENU_START + 13) +#define FID_APPLY_NAME (INSERT_MENU_START + 14) +#define FID_INS_TABLE_EXT (INSERT_MENU_START + 15) +#define FID_ADD_NAME (INSERT_MENU_START + 16) +#define FID_INS_CELLSDOWN (INSERT_MENU_START + 18) +#define FID_INS_CELLSRIGHT (INSERT_MENU_START + 19) +#define FID_INS_ROWS_AFTER (INSERT_MENU_START + 20) +#define FID_INS_COLUMNS_AFTER (INSERT_MENU_START + 21) +#define FID_INS_ROWS_BEFORE (INSERT_MENU_START + 22) +#define FID_INS_COLUMNS_BEFORE (INSERT_MENU_START + 23) +#define FID_DEFINE_CURRENT_NAME (INSERT_MENU_START + 24) +#define INSERT_MENU_END (INSERT_MENU_START + 25) + +#define FORMAT_MENU_START (INSERT_MENU_END) +#define FID_CELL_FORMAT (FORMAT_MENU_START) +#define FID_ROW_HEIGHT TypedWhichId<SfxUInt16Item>(FORMAT_MENU_START + 1) +#define FID_ROW_OPT_HEIGHT TypedWhichId<SfxUInt16Item>(FORMAT_MENU_START + 2) +#define FID_ROW_HIDE (FORMAT_MENU_START + 3) +#define FID_ROW_SHOW (FORMAT_MENU_START + 4) +#define FID_COL_WIDTH TypedWhichId<SfxUInt16Item>(FORMAT_MENU_START + 5) +#define FID_COL_OPT_WIDTH TypedWhichId<SfxUInt16Item>(FORMAT_MENU_START + 6) +#define FID_COL_HIDE (FORMAT_MENU_START + 7) +#define FID_COL_SHOW (FORMAT_MENU_START + 8) +#define FID_TABLE_HIDE (FORMAT_MENU_START + 9) +#define FID_TABLE_SHOW TypedWhichId<SfxStringItem>(FORMAT_MENU_START + 10) +#define FID_MERGE_ON (FORMAT_MENU_START + 15) +#define FID_MERGE_OFF (FORMAT_MENU_START + 16) +#define SID_FORMATPAGE (FORMAT_MENU_START + 17) +#define SID_TEXT_STANDARD (FORMAT_MENU_START + 18) +#define SID_DRAWTEXT_ATTR_DLG (FORMAT_MENU_START + 19) +#define FID_TABLE_VISIBLE (FORMAT_MENU_START + 20) +#define FID_COL_OPT_DIRECT (FORMAT_MENU_START + 21) +#define FID_TOGGLEHIDDENCOLROW (FORMAT_MENU_START + 22) +#define FORMAT_MENU_END (FORMAT_MENU_START + 23) + +#define EXTRA_MENU_START (FORMAT_MENU_END) +#define FID_AUTO_CALC (EXTRA_MENU_START + 3) +#define FID_RECALC (EXTRA_MENU_START + 4) +#define FID_PROTECT_TABLE (EXTRA_MENU_START + 6) +#define FID_PROTECT_DOC (EXTRA_MENU_START + 7) +#define SID_SHARE_DOC (EXTRA_MENU_START + 11) +#define SID_SCENARIOS TypedWhichId<SfxStringItem>(EXTRA_MENU_START + 12) +#define SID_PIVOT_RECALC (EXTRA_MENU_START + 14) +#define SID_PIVOT_KILL (EXTRA_MENU_START + 15) + +#define FID_HARD_RECALC (EXTRA_MENU_START + 18) +#define FID_AUTOCOMPLETE (EXTRA_MENU_START + 19) + +#define EXTRA_MENU_END (EXTRA_MENU_START + 20) + +#define DATA_MENU_START (EXTRA_MENU_END) +#define SID_DEFINE_DBNAME (DATA_MENU_START) +#define SID_SELECT_DB TypedWhichId<SfxStringItem>(DATA_MENU_START + 1) +#define SID_SORT (DATA_MENU_START + 2) +#define SID_FILTER (DATA_MENU_START + 3) +#define SID_SPECIAL_FILTER (DATA_MENU_START + 4) +#define SID_AUTO_FILTER (DATA_MENU_START + 5) +#define SID_UNFILTER (DATA_MENU_START + 6) +#define SID_QUERY (DATA_MENU_START + 7) +#define SID_MANAGE_XML_SOURCE (DATA_MENU_START + 8) +#define SID_SUBTOTALS (DATA_MENU_START + 13) +#define SID_AUTO_OUTLINE (DATA_MENU_START + 14) +#define SID_REIMPORT_DATA (DATA_MENU_START + 16) +#define SID_PIVOT_TABLE (DATA_MENU_START + 17) +#define SID_TABOP (DATA_MENU_START + 18) +#define SID_TEXT_TO_COLUMNS (DATA_MENU_START + 19) +#define SID_CONSOLIDATE (DATA_MENU_START + 20) +#define SID_AUTOFILTER_HIDE (DATA_MENU_START + 21) +#define SID_SBA_IMPORT (DATA_MENU_START + 22) +#define SID_SORT_DESCENDING (DATA_MENU_START + 23) +#define SID_SORT_ASCENDING (DATA_MENU_START + 24) +#define SID_OUTLINE_HIDE (DATA_MENU_START + 25) +#define SID_OUTLINE_SHOW (DATA_MENU_START + 26) +#define SID_OUTLINE_MAKE TypedWhichId<SfxStringItem>(DATA_MENU_START + 27) +#define SID_OUTLINE_REMOVE TypedWhichId<SfxStringItem>(DATA_MENU_START + 28) + +#define DATA_MENU_END (DATA_MENU_START + 29) + +#define TAB_POPUP_START (DATA_MENU_END) +#define FID_TAB_MENU_RENAME (TAB_POPUP_START) +#define FID_TAB_RENAME TypedWhichId<SfxStringItem>(TAB_POPUP_START+1) +#define FID_TAB_MOVE TypedWhichId<SfxStringItem>(TAB_POPUP_START+2) +#define FID_TAB_SELECTALL (TAB_POPUP_START+3) +#define FID_TAB_APPEND (TAB_POPUP_START+4) +#define FID_TAB_INDEX (TAB_POPUP_START+5) +#define FID_TAB_RTL (TAB_POPUP_START+6) +#define FID_TAB_DESELECTALL (TAB_POPUP_START+7) +#define FID_TAB_MENU_SET_TAB_BG_COLOR (TAB_POPUP_START + 8) +#define FID_TAB_SET_TAB_BG_COLOR (TAB_POPUP_START + 9) +#define FID_TAB_EVENTS (TAB_POPUP_START+10) +#define FID_TAB_DUPLICATE (TAB_POPUP_START+11) + +#define TAB_POPUP_END (TAB_POPUP_START + 20) + +#define OBJBAR_FORMAT_START (TAB_POPUP_END) +#define SID_ALIGNLEFT (OBJBAR_FORMAT_START+6) +#define SID_ALIGNRIGHT (OBJBAR_FORMAT_START+7) +#define SID_ALIGNCENTERHOR (OBJBAR_FORMAT_START+8) +#define SID_ALIGNBLOCK (OBJBAR_FORMAT_START+9) +#define SID_ALIGNTOP (OBJBAR_FORMAT_START+10) +#define SID_ALIGNBOTTOM (OBJBAR_FORMAT_START+11) +#define SID_ALIGNCENTERVER (OBJBAR_FORMAT_START+12) +#define SID_SELECT_SCENARIO TypedWhichId<SfxStringItem>(OBJBAR_FORMAT_START+13) + +#define SID_V_ALIGNCELL (OBJBAR_FORMAT_START+14) +#define SID_H_ALIGNCELL (OBJBAR_FORMAT_START+15) + +#define OBJBAR_FORMAT_END (OBJBAR_FORMAT_START+20) + +#define RID_INPUTBAR_START (OBJBAR_FORMAT_END) +#define RID_INPUTBAR_END (RID_INPUTBAR_START+1) + +#define DRAW_BAR_START (RID_INPUTBAR_END) +#define SID_ANCHOR_PAGE (DRAW_BAR_START+24) +#define SID_ANCHOR_CELL (DRAW_BAR_START+25) +#define SID_ANCHOR_CELL_RESIZE (DRAW_BAR_START+26) +#define SID_ANCHOR_TOGGLE (DRAW_BAR_START+27) +#define SID_ORIGINALSIZE (DRAW_BAR_START+28) +#define SID_FITCELLSIZE (DRAW_BAR_START+29) + +#define DRAW_BAR_END (DRAW_BAR_START+50) + +#define DRAWTEXTBAR_START (DRAW_BAR_END) +#define DRAWTEXTBAR_END (DRAWTEXTBAR_START+20) + +#define DETECTIVE_START (DRAWTEXTBAR_END) +#define SID_DETECTIVE_ADD_PRED (DETECTIVE_START) +#define SID_DETECTIVE_DEL_PRED (DETECTIVE_START+1) +#define SID_DETECTIVE_ADD_SUCC (DETECTIVE_START+2) +#define SID_DETECTIVE_DEL_SUCC (DETECTIVE_START+3) +#define SID_DETECTIVE_ADD_ERR (DETECTIVE_START+4) +#define SID_DETECTIVE_DEL_ALL (DETECTIVE_START+5) + +#define SID_DETECTIVE_FILLMODE (DETECTIVE_START+6) +#define SID_FILL_ADD_PRED (DETECTIVE_START+7) +#define SID_FILL_DEL_PRED (DETECTIVE_START+8) +#define SID_FILL_ADD_SUCC (DETECTIVE_START+9) +#define SID_FILL_DEL_SUCC (DETECTIVE_START+10) +#define SID_FILL_NONE (DETECTIVE_START+11) +#define SID_FILL_SELECT (DETECTIVE_START+12) + +#define SID_DETECTIVE_INVALID (DETECTIVE_START+13) + +#define SID_DETECTIVE_REFRESH (DETECTIVE_START+14) +#define SID_DETECTIVE_AUTO (DETECTIVE_START+15) + +#define SID_DETECTIVE_MARK_PRED (DETECTIVE_START+16) +#define SID_DETECTIVE_MARK_SUCC (DETECTIVE_START+17) + +#define DETECTIVE_END (DETECTIVE_START+20) + +#define SID_API_SLOTS (DETECTIVE_END) +#define SID_INSERT_MATRIX (SID_API_SLOTS+1) + +#define SID_DELETE_NOTE (SID_API_SLOTS+2) + +#define SID_PREVIEW_START (SID_API_SLOTS+20) +#define SID_PREVIEW_NEXT (SID_PREVIEW_START) +#define SID_PREVIEW_PREVIOUS (SID_PREVIEW_START+1) +#define SID_PREVIEW_FIRST (SID_PREVIEW_START+2) +#define SID_PREVIEW_LAST (SID_PREVIEW_START+3) +#define SID_PREVIEW_CLOSE (SID_PREVIEW_START+7) +#define SID_PREVIEW_MARGIN (SID_PREVIEW_START+8) +#define SID_PREVIEW_SCALINGFACTOR TypedWhichId<SvxZoomSliderItem>(SID_PREVIEW_START+9) +#define SID_PREVIEW_END (SID_PREVIEW_START+10) + +// with SID_KEYFUNC_START defined in include/sfx2/sfxsids.hrc there is a risk of +// adding entries that cause an overlap here +static_assert(SID_PREVIEW_END < SID_KEYFUNC_START, "calc slots ids trampling info keyfunc slot range"); + +//from sfx: #define SID_KEYFUNC_START (SID_PREVIEW_END+5) +// from SID_KEYFUNC_START + 0 to SID_KEYFUNC_START + 13 are defined in include/sfx2/sfxsids.hrc +#define SID_CURSORPAGELEFT_ (SID_KEYFUNC_START + 6) +#define SID_CURSORPAGERIGHT_ (SID_KEYFUNC_START + 8) +#define SID_CURSORBLKUP (SID_KEYFUNC_START + 14) +#define SID_CURSORBLKDOWN (SID_KEYFUNC_START + 15) +#define SID_CURSORBLKLEFT (SID_KEYFUNC_START + 16) +#define SID_CURSORBLKRIGHT (SID_KEYFUNC_START + 17) +#define SID_CURSORBLKUP_SEL (SID_KEYFUNC_START + 18) +#define SID_CURSORBLKDOWN_SEL (SID_KEYFUNC_START + 19) +#define SID_CURSORBLKLEFT_SEL (SID_KEYFUNC_START + 20) +#define SID_CURSORBLKRIGHT_SEL (SID_KEYFUNC_START + 21) + +#define SID_NEXT_TABLE (SID_KEYFUNC_START + 22) +#define SID_PREV_TABLE (SID_KEYFUNC_START + 23) + +#define SID_NEXT_UNPROTECT (SID_KEYFUNC_START + 24) +#define SID_PREV_UNPROTECT (SID_KEYFUNC_START + 25) + +#define SID_SELECT_COL (SID_KEYFUNC_START + 26) +#define SID_SELECT_ROW (SID_KEYFUNC_START + 27) +#define SID_SELECT_NONE (SID_KEYFUNC_START + 28) +#define SID_ALIGNCURSOR (SID_KEYFUNC_START + 29) +#define SID_MARKDATAAREA (SID_KEYFUNC_START + 30) +#define SID_SETINPUTMODE (SID_KEYFUNC_START + 31) +#define SID_DELETE_CONTENTS (SID_KEYFUNC_START + 32) + +#define SID_MARKAREA (SID_KEYFUNC_START + 33) + +#define FID_FILL_AUTO TypedWhichId<SfxStringItem>(SID_KEYFUNC_START + 35) +#define SID_CANCEL (SID_KEYFUNC_START + 36) + +#define SID_CURSORENTERUP (SID_KEYFUNC_START + 37) +#define SID_CURSORENTERDOWN (SID_KEYFUNC_START + 38) + +#define SID_MARKARRAYFORMULA (SID_KEYFUNC_START + 39) + +#define SID_NEXT_TABLE_SEL (SID_KEYFUNC_START + 40) +#define SID_PREV_TABLE_SEL (SID_KEYFUNC_START + 41) + +#define SID_ACCEPT_FORMULA (SID_KEYFUNC_START + 42) +#define SID_START_FORMULA (SID_KEYFUNC_START + 43) + +#define SID_KEYFUNC_END (SID_KEYFUNC_START + 50) + +#define SID_NEW_SLOTS (SID_KEYFUNC_END) + +#define SID_NEW_TABLENAME TypedWhichId<SfxStringItem>(SID_NEW_SLOTS+1) +#define SID_EXPORT_AS_GRAPHIC (SID_NEW_SLOTS+2) + +#define FID_MERGE_TOGGLE (SID_NEW_SLOTS+10) + +#define SID_RANGE_ROW TypedWhichId<SfxInt32Item>(SID_NEW_SLOTS+20) +#define SID_RANGE_COL TypedWhichId<SfxInt16Item>(SID_NEW_SLOTS+21) +#define SID_RANGE_TABLE TypedWhichId<SfxInt16Item>(SID_NEW_SLOTS+22) +// empty, was SID_RANGE_VALUE +#define SID_RANGE_FORMULA TypedWhichId<SfxStringItem>(SID_NEW_SLOTS+24) +#define SID_RANGE_TEXTVALUE TypedWhichId<SfxStringItem>(SID_NEW_SLOTS+26) +#define SID_TABLE_ACTIVATE (SID_NEW_SLOTS+27) + +#define SID_DEFINE_PRINTAREA (SID_NEW_SLOTS+31) +#define SID_DELETE_PRINTAREA (SID_NEW_SLOTS+32) +#define SID_CHANGE_PRINTAREA TypedWhichId<SfxStringItem>(SID_NEW_SLOTS+33) +#define SID_OPENDLG_EDIT_PRINTAREA (SID_NEW_SLOTS+34) + +#define SID_OLE_ACTIVATE (SID_NEW_SLOTS+36) +#define SID_OLE_DEACTIVATE (SID_NEW_SLOTS+37) + +#define SID_TOGGLE_REL (SID_NEW_SLOTS+38) +#define SID_DATA_SELECT (SID_NEW_SLOTS+39) + +// search & replace +#define FID_SEARCH (SID_NEW_SLOTS+40) +#define FID_REPEAT_SEARCH (SID_NEW_SLOTS+41) +#define FID_REPLACE (SID_NEW_SLOTS+42) +#define FID_SEARCH_ALL (SID_NEW_SLOTS+43) +#define FID_REPLACE_ALL (SID_NEW_SLOTS+44) +#define FID_SEARCH_COUNT (SID_NEW_SLOTS+45) + +#define SID_SC_SETTEXT (SID_NEW_SLOTS+46) +#define SID_RANGE_ADDRESS TypedWhichId<SfxStringItem>(SID_NEW_SLOTS+47) +#define SID_NUMBER_FORMAT TypedWhichId<SfxStringItem>(SID_NEW_SLOTS+49) + +#define SID_OLE_SELECT (SID_NEW_SLOTS+50) + +#define FID_CURRENTVALIDATION (SID_NEW_SLOTS+51) +#define SID_RANGE_NOTETEXT TypedWhichId<SfxStringItem>(SID_NEW_SLOTS+52) +#define FID_INSERT_FILE (SID_NEW_SLOTS+53) + +#define FID_VALIDATION (SID_NEW_SLOTS+54) + +// slots for toolbox controller in toolbar +#define SID_TBXCTL_INSERT (SID_NEW_SLOTS+55) +#define SID_TBXCTL_INSCELLS (SID_NEW_SLOTS+56) + +#define SID_DEFINE_COLROWNAMERANGES (SID_NEW_SLOTS+58) + +#define FID_NOTE_VISIBLE (SID_NEW_SLOTS+59) + +// items for validation +#define FID_VALID_MODE TypedWhichId<SfxUInt16Item>(SID_NEW_SLOTS+60) +#define FID_VALID_CONDMODE TypedWhichId<SfxUInt16Item>(SID_NEW_SLOTS+61) +#define FID_VALID_VALUE1 TypedWhichId<SfxStringItem>(SID_NEW_SLOTS+62) +#define FID_VALID_VALUE2 TypedWhichId<SfxStringItem>(SID_NEW_SLOTS+63) +#define FID_VALID_BLANK TypedWhichId<SfxBoolItem>(SID_NEW_SLOTS+64) +#define FID_VALID_SHOWHELP TypedWhichId<SfxBoolItem>(SID_NEW_SLOTS+65) +#define FID_VALID_HELPTITLE TypedWhichId<SfxStringItem>(SID_NEW_SLOTS+66) +#define FID_VALID_HELPTEXT TypedWhichId<SfxStringItem>(SID_NEW_SLOTS+67) +#define FID_VALID_SHOWERR TypedWhichId<SfxBoolItem>(SID_NEW_SLOTS+68) +#define FID_VALID_ERRSTYLE TypedWhichId<SfxUInt16Item>(SID_NEW_SLOTS+69) +#define FID_VALID_ERRTITLE TypedWhichId<SfxStringItem>(SID_NEW_SLOTS+70) +#define FID_VALID_ERRTEXT TypedWhichId<SfxStringItem>(SID_NEW_SLOTS+71) + +#define SID_REFRESH_DBAREA (SID_NEW_SLOTS+72) + +#define FID_FOCUS_POSWND (SID_NEW_SLOTS+74) + +#define FID_DEL_MANUALBREAKS (SID_NEW_SLOTS+79) +#define SID_ADD_PRINTAREA (SID_NEW_SLOTS+80) +#define FID_ADJUST_PRINTZOOM (SID_NEW_SLOTS+81) +#define FID_RESET_PRINTZOOM (SID_NEW_SLOTS+82) + +#define SID_TABLES_COUNT (SID_NEW_SLOTS+83) +#define SID_ACTIVE_OBJ_NAME TypedWhichId<SfxStringItem>(SID_NEW_SLOTS+84) +#define SID_OBJECT_LEFT (SID_NEW_SLOTS+85) +#define SID_OBJECT_TOP (SID_NEW_SLOTS+86) +#define SID_OBJECT_WIDTH (SID_NEW_SLOTS+87) +#define SID_OBJECT_HEIGHT (SID_NEW_SLOTS+88) + +#define SID_DELETE_SCENARIO (SID_NEW_SLOTS+95) +#define SID_EDIT_SCENARIO (SID_NEW_SLOTS+96) +#define SID_INSERT_FIELD_SHEET (SID_NEW_SLOTS+97) +#define SID_INSERT_FIELD_TITLE (SID_NEW_SLOTS+98) +#define SID_INSERT_FIELD_DATE_VAR (SID_NEW_SLOTS+99) + +#define FID_SHOW_NOTE (SID_NEW_SLOTS+100) +#define FID_HIDE_NOTE (SID_NEW_SLOTS+101) +#define FID_SHOW_ALL_NOTES (SID_NEW_SLOTS+102) +#define FID_HIDE_ALL_NOTES (SID_NEW_SLOTS+103) +#define FID_DELETE_ALL_NOTES (SID_NEW_SLOTS+104) +#define SID_SCATTR_CELLPROTECTION (SID_NEW_SLOTS+105) +#define SID_SELECT_UNPROTECTED_CELLS (SID_NEW_SLOTS+106) +#define SID_SELECT_VISIBLE_ROWS (SID_NEW_SLOTS+107) +#define SID_SELECT_VISIBLE_COLUMNS (SID_NEW_SLOTS+108) +#define SID_CURRENT_FORMULA_RANGE (SID_NEW_SLOTS+109) + +#define SID_INSERT_SPARKLINE (SID_NEW_SLOTS+110) +#define SID_DELETE_SPARKLINE (SID_NEW_SLOTS+111) +#define SID_EDIT_SPARKLINE_GROUP (SID_NEW_SLOTS+112) +#define SID_DELETE_SPARKLINE_GROUP (SID_NEW_SLOTS+113) +#define SID_GROUP_SPARKLINES (SID_NEW_SLOTS+114) +#define SID_UNGROUP_SPARKLINES (SID_NEW_SLOTS+115) +#define SID_EDIT_SPARKLINE (SID_NEW_SLOTS+116) +#define SID_SC_OPT_LINKS TypedWhichId<SfxBoolItem>(SID_NEW_SLOTS + 117) + +// idl parameter + +#define SID_SORT_BYROW TypedWhichId<SfxBoolItem>(SC_PARAM_START) +#define SID_SORT_HASHEADER TypedWhichId<SfxBoolItem>(SC_PARAM_START+1) +#define SID_SORT_CASESENS TypedWhichId<SfxBoolItem>(SC_PARAM_START+2) +#define SID_SORT_ATTRIBS TypedWhichId<SfxBoolItem>(SC_PARAM_START+3) +#define SID_SORT_USERDEF TypedWhichId<SfxUInt16Item>(SC_PARAM_START+4) +#define SID_SORT_NATURALSORT TypedWhichId<SfxBoolItem>(SC_PARAM_START+5) +#define SID_SORT_INCCOMMENTS TypedWhichId<SfxBoolItem>(SC_PARAM_START+6) +#define SID_SORT_INCIMAGES TypedWhichId<SfxBoolItem>(SC_PARAM_START+7) + +// Sidebar ------------------------------------------------------------- + +#define SID_PROPERTY_PANEL_CELLTEXT_DLG (SC_SIDEBAR_PROPERTY_BEGIN+0) +#define SID_NUMBER_TYPE_FORMAT TypedWhichId<SfxUInt16Item>(SC_SIDEBAR_PROPERTY_BEGIN+1) + +// resources + +#define SID_DATA_FORM (SC_RESOURCE_START+15) // menu (in Data menu) +#define SID_INSERT_CURRENT_DATE (SC_RESOURCE_START+16) +#define SID_INSERT_CURRENT_TIME (SC_RESOURCE_START+17) +#define FID_TAB_TOGGLE_GRID (SC_RESOURCE_START+18) // toggle sheet grid +#define WID_SIMPLE_REF (SC_RESOURCE_START+20) + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/scabstdlg.hxx b/sc/inc/scabstdlg.hxx new file mode 100644 index 0000000000..7a94af5f6f --- /dev/null +++ b/sc/inc/scabstdlg.hxx @@ -0,0 +1,578 @@ +/* -*- 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/sheet/DataPilotFieldOrientation.hpp> +#include <sfx2/tabdlg.hxx> +#include <tools/fldunit.hxx> +#include <vcl/abstdlg.hxx> +#include "global.hxx" +#include "pivot.hxx" +#include <i18nlangtag/lang.h> +#include <asciiopt.hxx> + +class ScAutoFormat; +class ScAutoFormatData; +class ScDocument; +struct ScImportSourceDesc; +class ScViewData; +class ScQueryItem; +class ScImportOptions; +class SfxStyleSheetBase; +class SfxAbstractTabDialog; +class ScDPObject; +struct ScDPNumGroupInfo; +class ScTabViewShell; +class ScConditionalFormat; +class ScConditionalFormatList; +class Date; +class SdrView; +enum class CreateNameFlags; +enum class CellShiftDisabledFlags; + +namespace com::sun::star::sheet { struct DataPilotFieldReference; } + +class ScAsyncTabController +{ +public: + virtual ~ScAsyncTabController() = default; + virtual bool StartExecuteAsync(VclAbstractDialog::AsyncContext &rCtx) = 0; + virtual const SfxItemSet* GetOutputItemSet() const = 0; + virtual void SetCurPageId( const OUString &rName ) = 0; +}; + +class AbstractScImportAsciiDlg : public VclAbstractDialog +{ +protected: + virtual ~AbstractScImportAsciiDlg() override = default; +public: + virtual void GetOptions( ScAsciiOptions& rOpt ) = 0; + virtual void SaveParameters() = 0; +}; + +class AbstractScAutoFormatDlg : public VclAbstractDialog +{ +protected: + virtual ~AbstractScAutoFormatDlg() override = default; +public: + virtual sal_uInt16 GetIndex() const = 0 ; + virtual OUString GetCurrFormatName() = 0; +}; + +class AbstractScColRowLabelDlg : public VclAbstractDialog +{ +protected: + virtual ~AbstractScColRowLabelDlg() override = default; +public: + virtual bool IsCol() = 0; + virtual bool IsRow() = 0; +}; + +class AbstractScCondFormatManagerDlg : public VclAbstractDialog +{ +protected: + virtual ~AbstractScCondFormatManagerDlg() override = default; +public: + virtual std::unique_ptr<ScConditionalFormatList> GetConditionalFormatList() = 0; + + virtual bool CondFormatsChanged() const = 0; + + virtual void SetModified() = 0; + + virtual ScConditionalFormat* GetCondFormatSelected() = 0; +}; + +class AbstractScDataPilotDatabaseDlg :public VclAbstractDialog +{ +protected: + virtual ~AbstractScDataPilotDatabaseDlg() override = default; +public: + virtual void GetValues( ScImportSourceDesc& rDesc ) = 0; +}; + +class AbstractScDataPilotSourceTypeDlg : public VclAbstractDialog +{ +protected: + virtual ~AbstractScDataPilotSourceTypeDlg() override = default; +public: + virtual bool IsDatabase() const = 0; + virtual bool IsExternal() const = 0; + virtual bool IsNamedRange() const = 0; + virtual OUString GetSelectedNamedRange() const = 0; + virtual void AppendNamedRange(const OUString& rName) = 0; +}; + +class AbstractScDataPilotServiceDlg : public VclAbstractDialog +{ +protected: + virtual ~AbstractScDataPilotServiceDlg() override = default; +public: + virtual OUString GetServiceName() const = 0; + virtual OUString GetParSource() const = 0 ; + virtual OUString GetParName() const = 0 ; + virtual OUString GetParUser() const = 0; + virtual OUString GetParPass() const = 0; +}; + +class AbstractScDeleteCellDlg : public VclAbstractDialog +{ +protected: + virtual ~AbstractScDeleteCellDlg() override = default; +public: + virtual DelCellCmd GetDelCellCmd() const = 0; +}; + +//for dataform +class AbstractScDataFormDlg : public VclAbstractDialog +{ +protected: + virtual ~AbstractScDataFormDlg() override = default; +}; + +class AbstractScDeleteContentsDlg: public VclAbstractDialog +{ +protected: + virtual ~AbstractScDeleteContentsDlg() override = default; +public: + virtual void DisableObjects() = 0 ; + virtual InsertDeleteFlags GetDelContentsCmdBits() const = 0; +}; + +class AbstractScFillSeriesDlg: public VclAbstractDialog +{ +protected: + virtual ~AbstractScFillSeriesDlg() override = default; +public: + virtual FillDir GetFillDir() const = 0; + virtual FillCmd GetFillCmd() const = 0; + virtual FillDateCmd GetFillDateCmd() const = 0; + virtual double GetStart() const = 0; + virtual double GetStep() const = 0; + virtual double GetMax() const = 0; + virtual OUString GetStartStr() const = 0; + virtual void SetEdStartValEnabled(bool bFlag) = 0; +}; + +class AbstractScGroupDlg : public VclAbstractDialog +{ +protected: + virtual ~AbstractScGroupDlg() override = default; +public: + virtual bool GetColsChecked() const = 0; +}; + +class AbstractScInsertCellDlg : public VclAbstractDialog +{ +protected: + virtual ~AbstractScInsertCellDlg() override = default; +public: + virtual InsCellCmd GetInsCellCmd() const = 0; +}; + +class AbstractScInsertContentsDlg : public VclAbstractDialog +{ +protected: + virtual ~AbstractScInsertContentsDlg() override = default; +public: + virtual InsertDeleteFlags GetInsContentsCmdBits() const = 0; + virtual ScPasteFunc GetFormulaCmdBits() const = 0 ; + virtual bool IsSkipEmptyCells() const = 0; + virtual bool IsLink() const = 0; + virtual void SetFillMode( bool bSet ) = 0; + virtual void SetOtherDoc( bool bSet ) = 0; + virtual bool IsTranspose() const = 0; + virtual void SetChangeTrack( bool bSet ) = 0; + virtual void SetCellShiftDisabled( CellShiftDisabledFlags nDisable ) = 0; + virtual InsCellCmd GetMoveMode() = 0; +}; + +class AbstractScInsertTableDlg : public VclAbstractDialog +{ +protected: + virtual ~AbstractScInsertTableDlg() override = default; +public: + virtual bool GetTablesFromFile() = 0; + virtual bool GetTablesAsLink() = 0; + virtual const OUString* GetFirstTable( sal_uInt16* pN = nullptr ) = 0; + virtual ScDocShell* GetDocShellTables() = 0; + virtual bool IsTableBefore() = 0; + virtual sal_uInt16 GetTableCount() = 0; + virtual const OUString* GetNextTable( sal_uInt16* pN ) = 0; + +}; + +class AbstractScSelEntryDlg : public VclAbstractDialog +{ +protected: + virtual ~AbstractScSelEntryDlg() override = default; +public: + virtual OUString GetSelectedEntry() const = 0; +}; + +class AbstractScLinkedAreaDlg : public VclAbstractDialog +{ +protected: + virtual ~AbstractScLinkedAreaDlg() override = default; +public: + virtual void InitFromOldLink( const OUString& rFile, const OUString& rFilter, + const OUString& rOptions, const OUString& rSource, + sal_Int32 nRefreshDelaySeconds ) = 0; + virtual OUString GetURL() = 0; + virtual OUString GetFilter() = 0; // may be empty + virtual OUString GetOptions() = 0; // filter options + virtual OUString GetSource() = 0; // separated by ";" + virtual sal_Int32 GetRefreshDelaySeconds() = 0; // 0 if disabled +}; + +class AbstractScMetricInputDlg : public VclAbstractDialog +{ +protected: + virtual ~AbstractScMetricInputDlg() override = default; +public: + virtual int GetInputValue() const = 0; +}; + +class AbstractScMoveTableDlg : public VclAbstractDialog +{ +protected: + virtual ~AbstractScMoveTableDlg() override = default; +public: + virtual sal_uInt16 GetSelectedDocument () const = 0; + virtual sal_uInt16 GetSelectedTable () const = 0; + virtual bool GetCopyTable () const = 0; + virtual bool GetRenameTable () const = 0; + virtual void GetTabNameString( OUString& rString ) const = 0; + virtual void SetForceCopyTable () = 0; + virtual void EnableRenameTable (bool bFlag) = 0; +}; + +class AbstractScNameCreateDlg : public VclAbstractDialog // Manage Name Dialog +{ +protected: + virtual ~AbstractScNameCreateDlg() override = default; +public: + virtual CreateNameFlags GetFlags() const = 0; +}; + +class AbstractScNamePasteDlg : public VclAbstractDialog +{ +protected: + virtual ~AbstractScNamePasteDlg() override = default; +public: + virtual std::vector<OUString> GetSelectedNames() const = 0; +}; + +class AbstractScPivotFilterDlg : public VclAbstractDialog +{ +protected: + virtual ~AbstractScPivotFilterDlg() override = default; +public: + virtual const ScQueryItem& GetOutputItem() = 0; +}; + +class AbstractScDPFunctionDlg : public VclAbstractDialog +{ +protected: + virtual ~AbstractScDPFunctionDlg() override = default; +public: + virtual PivotFunc GetFuncMask() const = 0; + virtual css::sheet::DataPilotFieldReference GetFieldRef() const = 0; + virtual void Response(int nResponse) = 0; +}; + +class AbstractScDPSubtotalDlg : public VclAbstractDialog +{ +protected: + virtual ~AbstractScDPSubtotalDlg() override = default; +public: + virtual PivotFunc GetFuncMask() const = 0; + virtual void FillLabelData( ScDPLabelData& rLabelData ) const = 0; + virtual void Response(int nResponse) = 0; +}; + +class AbstractScDPNumGroupDlg : public VclAbstractDialog +{ +protected: + virtual ~AbstractScDPNumGroupDlg() override = default; +public: + virtual ScDPNumGroupInfo GetGroupInfo() const = 0; +}; + +class AbstractScDPDateGroupDlg : public VclAbstractDialog +{ +protected: + virtual ~AbstractScDPDateGroupDlg() override = default; +public: + virtual ScDPNumGroupInfo GetGroupInfo() const = 0; + virtual sal_Int32 GetDatePart() const = 0; +}; + +class AbstractScDPShowDetailDlg : public VclAbstractDialog +{ +protected: + virtual ~AbstractScDPShowDetailDlg() override = default; +public: + virtual OUString GetDimensionName() const = 0; +}; + +class AbstractScNewScenarioDlg : public VclAbstractDialog +{ +protected: + virtual ~AbstractScNewScenarioDlg() override = default; +public: + + virtual void SetScenarioData( const OUString& rName, const OUString& rComment, + const Color& rColor, ScScenarioFlags nFlags ) = 0; + + virtual void GetScenarioData( OUString& rName, OUString& rComment, + Color& rColor, ScScenarioFlags& rFlags ) const = 0; +}; + +class AbstractScShowTabDlg : public VclAbstractDialog +{ +protected: + virtual ~AbstractScShowTabDlg() override = default; +public: + virtual void Insert( const OUString& rString, bool bSelected ) = 0; + virtual void SetDescription(const OUString& rTitle, const OUString& rFixedText, const OUString& nDlgHelpId, const OUString& nLbHelpId ) = 0; + virtual std::vector<sal_Int32> GetSelectedRows() const = 0; + virtual OUString GetEntry(sal_Int32 nPos) const = 0; +}; + +class AbstractScSortWarningDlg : public VclAbstractDialog +{ +protected: + virtual ~AbstractScSortWarningDlg() override = default; +}; + +class AbstractScStringInputDlg : public VclAbstractDialog +{ +protected: + virtual ~AbstractScStringInputDlg() override = default; +public: + virtual OUString GetInputString() const = 0; +}; + +class AbstractScTabBgColorDlg : public VclAbstractDialog +{ +protected: + virtual ~AbstractScTabBgColorDlg() override = default; +public: + virtual void GetSelectedColor( Color& rColor ) const = 0; +}; + +class AbstractScImportOptionsDlg : public VclAbstractDialog +{ +protected: + virtual ~AbstractScImportOptionsDlg() override = default; +public: + virtual void GetImportOptions( ScImportOptions& rOptions ) const = 0; + virtual void SaveImportOptions() const = 0; +}; + +class AbstractScTextImportOptionsDlg : public VclAbstractDialog +{ +protected: + virtual ~AbstractScTextImportOptionsDlg() override = default; +public: + virtual LanguageType GetLanguageType() const = 0; + virtual bool IsDateConversionSet() const = 0; + virtual bool IsScientificConversionSet() const = 0; + virtual bool IsKeepAskingSet() const = 0; +}; + +class AbstractScGoToTabDlg : public VclAbstractDialog +{ +protected: + virtual ~AbstractScGoToTabDlg() override = default; +public: + virtual void Insert( const OUString& rString, bool bSelected ) = 0; + virtual void SetDescription(const OUString& rTitle, const OUString& rEntryLabel, const OUString& rListLabel, + const OUString& rDlgHelpId, const OUString& rEnHelpId, const OUString& rLbHelpId) = 0; + virtual OUString GetSelectedEntry() const = 0; +}; + +class ScAbstractDialogFactory +{ +public: + SC_DLLPUBLIC static ScAbstractDialogFactory* Create(); + + virtual VclPtr<AbstractScImportAsciiDlg> CreateScImportAsciiDlg(weld::Window* pParent, + const OUString& aDatName, + SvStream* pInStream, + ScImportAsciiCall eCall) = 0; + + virtual VclPtr<AbstractScTextImportOptionsDlg> CreateScTextImportOptionsDlg(weld::Window* pParent) = 0; + + virtual VclPtr<AbstractScAutoFormatDlg> CreateScAutoFormatDlg(weld::Window* pParent, + ScAutoFormat* pAutoFormat, + const ScAutoFormatData* pSelFormatData, + ScViewData& rViewData) = 0; + virtual VclPtr<AbstractScColRowLabelDlg> CreateScColRowLabelDlg (weld::Window* pParent, + bool bCol, + bool bRow) = 0; + + virtual VclPtr<AbstractScSortWarningDlg> CreateScSortWarningDlg(weld::Window* pParent, const OUString& rExtendText, const OUString& rCurrentText ) = 0; + + virtual VclPtr<AbstractScCondFormatManagerDlg> CreateScCondFormatMgrDlg(weld::Window* pParent, ScDocument& rDoc, const ScConditionalFormatList* pFormatList ) = 0; + + virtual VclPtr<AbstractScDataPilotDatabaseDlg> CreateScDataPilotDatabaseDlg(weld::Window* pParent) = 0; + + virtual VclPtr<AbstractScDataPilotSourceTypeDlg> CreateScDataPilotSourceTypeDlg(weld::Window* pParent, + bool bEnableExternal) = 0; + + virtual VclPtr<AbstractScDataPilotServiceDlg> CreateScDataPilotServiceDlg(weld::Window* pParent, + const std::vector<OUString>& rServices) = 0; + + virtual VclPtr<AbstractScDeleteCellDlg> CreateScDeleteCellDlg(weld::Window* pParent, bool bDisallowCellMove) = 0 ; + + //for dataform + virtual VclPtr<AbstractScDataFormDlg> CreateScDataFormDlg(weld::Window* pParent, ScTabViewShell* pTabViewShell) = 0; + + virtual VclPtr<AbstractScDeleteContentsDlg> CreateScDeleteContentsDlg(weld::Window* pParent) = 0; + virtual VclPtr<AbstractScFillSeriesDlg> CreateScFillSeriesDlg(weld::Window* pParent, + ScDocument& rDocument, + FillDir eFillDir, + FillCmd eFillCmd, + FillDateCmd eFillDateCmd, + const OUString& aStartStr, + double fStep, + double fMax, + SCSIZE nSelectHeight, + SCSIZE nSelectWidth, + sal_uInt16 nPossDir) = 0; + + virtual VclPtr<AbstractScGroupDlg> CreateAbstractScGroupDlg(weld::Window* pParent, bool bUnGroup = false) = 0; + + virtual VclPtr<AbstractScInsertCellDlg> CreateScInsertCellDlg(weld::Window* pParent, + bool bDisallowCellMove) = 0; + + virtual VclPtr<AbstractScInsertContentsDlg> CreateScInsertContentsDlg(weld::Window* pParent, + const OUString* pStrTitle = nullptr) = 0; + + virtual VclPtr<AbstractScInsertTableDlg> CreateScInsertTableDlg(weld::Window* pParent, ScViewData& rViewData, + SCTAB nTabCount, bool bFromFile) = 0; + + virtual VclPtr<AbstractScSelEntryDlg > CreateScSelEntryDlg(weld::Window* pParent, const std::vector<OUString> &rEntryList) = 0; + virtual VclPtr<AbstractScLinkedAreaDlg> CreateScLinkedAreaDlg(weld::Widget* pParent) = 0; + + virtual VclPtr<AbstractScMetricInputDlg> CreateScMetricInputDlg(weld::Window* pParent, + const OUString& sDialogName, + tools::Long nCurrent, + tools::Long nDefault, + FieldUnit eFUnit, + sal_uInt16 nDecimals, + tools::Long nMaximum, + tools::Long nMinimum = 0 ) = 0; + + virtual VclPtr<AbstractScMoveTableDlg> CreateScMoveTableDlg(weld::Window * pParent, + const OUString& rDefault) = 0; + + virtual VclPtr<AbstractScNameCreateDlg> CreateScNameCreateDlg(weld::Window * pParent, + CreateNameFlags nFlags) = 0; + + virtual VclPtr<AbstractScNamePasteDlg> CreateScNamePasteDlg(weld::Window * pParent, ScDocShell* pShell) = 0; + + virtual VclPtr<AbstractScPivotFilterDlg> CreateScPivotFilterDlg(weld::Window* pParent, + const SfxItemSet& rArgSet, + sal_uInt16 nSourceTab) = 0; + + virtual VclPtr<AbstractScDPFunctionDlg> CreateScDPFunctionDlg(weld::Widget* pParent, + const ScDPLabelDataVector& rLabelVec, + const ScDPLabelData& rLabelData, + const ScPivotFuncData& rFuncData ) = 0; + + virtual VclPtr<AbstractScDPSubtotalDlg> CreateScDPSubtotalDlg(weld::Widget* pParent, + ScDPObject& rDPObj, + const ScDPLabelData& rLabelData, + const ScPivotFuncData& rFuncData, + const ScDPNameVec& rDataFields) = 0; + + virtual VclPtr<AbstractScDPNumGroupDlg> CreateScDPNumGroupDlg(weld::Window* pParent, + const ScDPNumGroupInfo& rInfo) = 0; + + virtual VclPtr<AbstractScDPDateGroupDlg> CreateScDPDateGroupDlg(weld::Window* pParent, + const ScDPNumGroupInfo& rInfo, + sal_Int32 nDatePart, + const Date& rNullDate ) = 0; + + virtual VclPtr<AbstractScDPShowDetailDlg> CreateScDPShowDetailDlg(weld::Window* pParent, + ScDPObject& rDPObj, + css::sheet::DataPilotFieldOrientation nOrient ) = 0; + + virtual VclPtr<AbstractScNewScenarioDlg> CreateScNewScenarioDlg(weld::Window* pParent, const OUString& rName, + bool bEdit, bool bSheetProtected) = 0; + virtual VclPtr<AbstractScShowTabDlg> CreateScShowTabDlg(weld::Window* pParent) = 0; + + virtual VclPtr<AbstractScStringInputDlg> CreateScStringInputDlg(weld::Window* pParent, + const OUString& rTitle, + const OUString& rEditTitle, + const OUString& rDefault, + const OUString& rHelpId, + const OUString& rEditHelpId) = 0; + + virtual VclPtr<AbstractScTabBgColorDlg> CreateScTabBgColorDlg(weld::Window* pParent, + const OUString& rTitle, //Dialog Title + const OUString& rTabBgColorNoColorText, //Label for no tab color + const Color& rDefaultColor) = 0; //Currently selected Color + + virtual VclPtr<AbstractScImportOptionsDlg> CreateScImportOptionsDlg(weld::Window* pParent, bool bAscii, + const ScImportOptions* pOptions, + const OUString* pStrTitle, + bool bOnlyDbtoolsEncodings, + bool bImport = true ) = 0; + + virtual VclPtr<AbstractScGoToTabDlg> CreateScGoToTabDlg(weld::Window* pParent) = 0; + + virtual VclPtr<SfxAbstractTabDialog> CreateScAttrDlg(weld::Window* pParent, + const SfxItemSet* pCellAttrs) = 0; + + virtual VclPtr<SfxAbstractTabDialog> CreateScHFEditDlg(weld::Window* pParent, + const SfxItemSet& rCoreSet, + const OUString& rPageStyle, + sal_uInt16 nResId ) = 0; + + virtual VclPtr<SfxAbstractTabDialog> CreateScStyleDlg(weld::Window* pParent, + SfxStyleSheetBase& rStyleBase, + bool bPage /*true : page, false: para*/) = 0; + + virtual VclPtr<SfxAbstractTabDialog> CreateScDrawStyleDlg(weld::Window* pParent, + SfxStyleSheetBase& rStyleBase, + SdrView* pView) = 0; + + virtual VclPtr<SfxAbstractTabDialog> CreateScSubTotalDlg(weld::Window* pParent, + const SfxItemSet& rArgSet) = 0; + + virtual VclPtr<SfxAbstractTabDialog> CreateScCharDlg(weld::Window* pParent, + const SfxItemSet* pAttr, const SfxObjectShell* pDocShell, bool bDrawText) = 0; + + virtual VclPtr<SfxAbstractTabDialog> CreateScParagraphDlg(weld::Window* pParent, + const SfxItemSet* pAttr) = 0; + + virtual std::shared_ptr<ScAsyncTabController> CreateScSortDlg(weld::Window* pParent, const SfxItemSet* pArgSet) = 0; + + // for tabpage + virtual CreateTabPage GetTabPageCreatorFunc( sal_uInt16 nId ) = 0; + +protected: + ~ScAbstractDialogFactory() {} +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/scdll.hxx b/sc/inc/scdll.hxx new file mode 100644 index 0000000000..16d30dfcc3 --- /dev/null +++ b/sc/inc/scdll.hxx @@ -0,0 +1,42 @@ +/* -*- 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 "scdllapi.h" + +/** + * This class is a wrapper for a Load-On-Demand-DLL. One instance per + * SfxApplication will be created for the runtime of + * SfxApplication-subclass::Main(). + * + * Remember: Do export this class! It is used by the application. + */ +class ScDLL +{ +public: + /// Ctor/Dtor must be linked to the application + ScDLL(); + ~ScDLL(); + + /// DLL-init/exit-code must be linked to the DLL only + static SC_DLLPUBLIC void Init(); ///< called directly after loading the DLL +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/scdllapi.h b/sc/inc/scdllapi.h new file mode 100644 index 0000000000..b69a95e454 --- /dev/null +++ b/sc/inc/scdllapi.h @@ -0,0 +1,30 @@ +/* -*- 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 <sal/types.h> + +#if defined(SC_DLLIMPLEMENTATION) +#define SC_DLLPUBLIC SAL_DLLPUBLIC_EXPORT +#else +#define SC_DLLPUBLIC SAL_DLLPUBLIC_IMPORT +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/scerrors.hrc b/sc/inc/scerrors.hrc new file mode 100644 index 0000000000..88b099f691 --- /dev/null +++ b/sc/inc/scerrors.hrc @@ -0,0 +1,109 @@ +/* -*- 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 + +#define NC_(Context, String) TranslateId(Context, u8##String) + +#include <svtools/ehdl.hxx> +#include "scerrors.hxx" + +const ErrMsgCode RID_ERRHDLSC[] = +{ + // ERRORS ----------------------------------------------------- + { NC_("RID_ERRHDLSC", "Impossible to connect to the file.") , + SCERR_IMPORT_CONNECT }, + { NC_("RID_ERRHDLSC", "File could not be opened.") , + SCERR_IMPORT_OPEN }, + { NC_("RID_ERRHDLSC", "An unknown error has occurred.") , + SCERR_IMPORT_UNKNOWN }, + { NC_("RID_ERRHDLSC", "Not enough memory while importing.") , + SCERR_IMPORT_OUTOFMEM }, + { NC_("RID_ERRHDLSC", "Unknown Lotus1-2-3 file format.") , + SCERR_IMPORT_UNKNOWN_WK }, + { NC_("RID_ERRHDLSC", "Error in file structure while importing.") , + SCERR_IMPORT_FORMAT }, + { NC_("RID_ERRHDLSC", "There is no filter available for this file type.") , + SCERR_IMPORT_NI }, + { NC_("RID_ERRHDLSC", "Unknown or unsupported Excel file format.") , + SCERR_IMPORT_UNKNOWN_BIFF }, + { NC_("RID_ERRHDLSC", "Excel file format not yet implemented.") , + SCERR_IMPORT_NI_BIFF }, + { NC_("RID_ERRHDLSC", "This file is password-protected.") , + SCERR_IMPORT_FILEPASSWD }, + { NC_("RID_ERRHDLSC", "Internal import error.") , + SCERR_IMPORT_INTERNAL }, + { NC_("RID_ERRHDLSC", "The file contains data after row 8192 and therefore can not be read.") , + SCERR_IMPORT_8K_LIMIT }, + { NC_("RID_ERRHDLSC", "Format error discovered in the file in sub-document $(ARG1) at $(ARG2)(row,col)."), + SCERR_IMPORT_FILE_ROWCOL }, + { NC_("RID_ERRHDLSC", "File format error found at $(ARG1)(row,col).") , + SCERR_IMPORT_FORMAT_ROWCOL }, + + // Export ---------------------------------------------------- + { NC_("RID_ERRHDLSC", "Connection to the file could not be established.") , + SCERR_EXPORT_CONNECT }, + { NC_("RID_ERRHDLSC", "Data could not be written.") , + SCERR_EXPORT_DATA }, + { NC_("RID_ERRHDLSC", "$(ARG1)") , + SCERR_EXPORT_SQLEXCEPTION }, + { NC_("RID_ERRHDLSC", "Cell $(ARG1) contains characters that are not representable in the selected target character set \"$(ARG2)\".") , + SCERR_EXPORT_ENCODING }, + { NC_("RID_ERRHDLSC", "Cell $(ARG1) contains a string that is longer in the selected target character set \"$(ARG2)\" than the given field width.") , + SCERR_EXPORT_FIELDWIDTH }, + + // WARNINGS --------------------------------------------------- + { NC_("RID_ERRHDLSC", "Only the active sheet was saved.") , + SCWARN_EXPORT_ASCII }, + { NC_("RID_ERRHDLSC", "The maximum number of rows has been exceeded. Excess rows were not imported!") , + SCWARN_IMPORT_RANGE_OVERFLOW }, + { NC_("RID_ERRHDLSC", "The data could not be loaded completely because the maximum number of rows per sheet was exceeded.") , + SCWARN_IMPORT_ROW_OVERFLOW }, + { NC_("RID_ERRHDLSC", "The data could not be loaded completely because the maximum number of columns per sheet was exceeded.") , + SCWARN_IMPORT_COLUMN_OVERFLOW }, + { NC_("RID_ERRHDLSC", "Not all sheets have been loaded because the maximum number of sheets was exceeded.\n\nPlease be warned that re-saving this document will permanently delete those sheets that have not been loaded!") , + SCWARN_IMPORT_SHEET_OVERFLOW }, + { NC_("RID_ERRHDLSC", "The data could not be loaded completely because the maximum number of characters per cell was exceeded.") , + SCWARN_IMPORT_CELL_OVERFLOW }, + { NC_("RID_ERRHDLSC", "Corresponding FM3-File could not be opened.") , + SCWARN_IMPORT_OPEN_FM3 }, + { NC_("RID_ERRHDLSC", "Error in file structure of corresponding FM3-File.") , + SCWARN_IMPORT_WRONG_FM3 }, + { NC_("RID_ERRHDLSC", "Document too complex for automatic calculation. Press F9 to recalculate.") , + SCWARN_CORE_HARD_RECALC }, + { NC_("RID_ERRHDLSC", "The document contains more rows than supported in the selected format.\nAdditional rows were not saved.") , + SCWARN_EXPORT_MAXROW }, + { NC_("RID_ERRHDLSC", "The document contains more columns than supported in the selected format.\nAdditional columns were not saved.") , + SCWARN_EXPORT_MAXCOL }, + { NC_("RID_ERRHDLSC", "The document contains more sheets than supported in the selected format.\nAdditional sheets were not saved.") , + SCWARN_EXPORT_MAXTAB }, + { NC_("RID_ERRHDLSC", "The document contains information not recognized by this program version.\nResaving the document will delete this information!") , + SCWARN_IMPORT_INFOLOST }, + { NC_("RID_ERRHDLSC", "Not all cell contents could be saved in the specified format.") , + SCWARN_EXPORT_DATALOST }, + { NC_("RID_ERRHDLSC", "The following characters could not be converted to the selected character set\nand were written as Ӓ surrogates:\n\n$(ARG1)"), + SCWARN_EXPORT_NONCONVERTIBLE_CHARS }, + { NC_("RID_ERRHDLSC", "Format error discovered in the file in sub-document $(ARG1) at $(ARG2)(row,col)."), + SCWARN_IMPORT_FILE_ROWCOL }, + { NC_("RID_ERRHDLSC", "Not all attributes could be read.") , + SCWARN_IMPORT_FEATURES_LOST }, + { {}, ERRCODE_NONE } +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/scerrors.hxx b/sc/inc/scerrors.hxx new file mode 100644 index 0000000000..dcb734502e --- /dev/null +++ b/sc/inc/scerrors.hxx @@ -0,0 +1,80 @@ +/* -*- 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 <comphelper/errcode.hxx> + +// ErrCodeClass::Read - file related, displays "Read-Error" in MsgBox +#define SCERR_IMPORT_CONNECT ErrCode( ErrCodeArea::Sc, ErrCodeClass::Read, 1 ) +#define SCERR_IMPORT_OPEN ErrCode( ErrCodeArea::Sc, ErrCodeClass::Read, 2 ) +#define SCERR_IMPORT_UNKNOWN ErrCode( ErrCodeArea::Sc, ErrCodeClass::Read, 3 ) + // out of memory +#define SCERR_IMPORT_OUTOFMEM ErrCode( ErrCodeArea::Sc, ErrCodeClass::Read, 4 ) + // unknown WK? format (Lotus 1-2-3) +#define SCERR_IMPORT_UNKNOWN_WK ErrCode( ErrCodeArea::Sc, ErrCodeClass::Read, 5 ) + // format error during reading (no formula error!) +#define SCERR_IMPORT_FORMAT ErrCode( ErrCodeArea::Sc, ErrCodeClass::Read, 6 ) + // filter not implemented +#define SCERR_IMPORT_NI ErrCode( ErrCodeArea::Sc, ErrCodeClass::Read, 7 ) + // unknown BIFF format (Excel) +#define SCERR_IMPORT_UNKNOWN_BIFF ErrCode( ErrCodeArea::Sc, ErrCodeClass::Read, 8 ) +#define SCERR_IMPORT_NI_BIFF ErrCode( ErrCodeArea::Sc, ErrCodeClass::Read, 9 ) + // file password protected +#define SCERR_IMPORT_FILEPASSWD ErrCode( ErrCodeArea::Sc, ErrCodeClass::Read, 10 ) + // internal error +#define SCERR_IMPORT_INTERNAL ErrCode( ErrCodeArea::Sc, ErrCodeClass::Read, 11 ) +#define SCERR_IMPORT_8K_LIMIT ErrCode( ErrCodeArea::Sc, ErrCodeClass::Read, 12 ) +#define SCWARN_IMPORT_OPEN_FM3 ErrCode( WarningFlag::Yes, ErrCodeArea::Sc, ErrCodeClass::Read, 13 ) +#define SCWARN_IMPORT_WRONG_FM3 ErrCode( WarningFlag::Yes, ErrCodeArea::Sc, ErrCodeClass::Read, 14 ) +#define SCWARN_IMPORT_INFOLOST ErrCode( WarningFlag::Yes, ErrCodeArea::Sc, ErrCodeClass::Read, 15 ) +#define SCERR_IMPORT_FILE_ROWCOL ErrCode( ErrCodeArea::Sc, ErrCodeClass::Read, 16 ) +#define SCERR_IMPORT_FORMAT_ROWCOL ErrCode( ErrCodeArea::Sc, ErrCodeClass::Read, 17 ) +#define SCWARN_IMPORT_FILE_ROWCOL ErrCode( WarningFlag::Yes, ErrCodeArea::Sc, ErrCodeClass::Read, 18 ) + +// ErrCodeClass::Write - file related, displays "Write-Error" in MsgBox +#define SCERR_EXPORT_CONNECT ErrCode( ErrCodeArea::Sc, ErrCodeClass::Write, 1 ) +#define SCERR_EXPORT_DATA ErrCode( ErrCodeArea::Sc, ErrCodeClass::Write, 2 ) +#define SCERR_EXPORT_ENCODING ErrCode( ErrCodeArea::Sc, ErrCodeClass::Write, 3 ) +#define SCERR_EXPORT_FIELDWIDTH ErrCode( ErrCodeArea::Sc, ErrCodeClass::Write, 4 ) +#define SCERR_EXPORT_SQLEXCEPTION ErrCode( ErrCodeArea::Sc, ErrCodeClass::Write, 5 ) + +// ErrCodeClass::Import - does not display "Read-Error" in MsgBox + // overflow of cell coordinates + // table restricted to valid area (?) +#define SCWARN_IMPORT_RANGE_OVERFLOW ErrCode( WarningFlag::Yes, ErrCodeArea::Sc, ErrCodeClass::Import, 1 ) +#define SCWARN_IMPORT_ROW_OVERFLOW ErrCode( WarningFlag::Yes, ErrCodeArea::Sc, ErrCodeClass::Import, 2 ) +#define SCWARN_IMPORT_COLUMN_OVERFLOW ErrCode( WarningFlag::Yes, ErrCodeArea::Sc, ErrCodeClass::Import, 3 ) +#define SCWARN_IMPORT_SHEET_OVERFLOW ErrCode( WarningFlag::Yes, ErrCodeArea::Sc, ErrCodeClass::Import, 4 ) +#define SCWARN_IMPORT_CELL_OVERFLOW ErrCode( WarningFlag::Yes, ErrCodeArea::Sc, ErrCodeClass::Import, 5 ) +#define SCWARN_IMPORT_FEATURES_LOST ErrCode( WarningFlag::Yes, ErrCodeArea::Sc, ErrCodeClass::Import, 6 ) + +// ErrCodeClass::Export - does not display "Write-Error" in MsgBox +#define SCWARN_EXPORT_NONCONVERTIBLE_CHARS \ + ErrCode( WarningFlag::Yes, ErrCodeArea::Sc, ErrCodeClass::Export, 1 ) +#define SCWARN_EXPORT_ASCII ErrCode( WarningFlag::Yes, ErrCodeArea::Sc, ErrCodeClass::Export, 2 ) +#define SCWARN_EXPORT_MAXROW ErrCode( WarningFlag::Yes, ErrCodeArea::Sc, ErrCodeClass::Export, 3 ) +#define SCWARN_EXPORT_MAXCOL ErrCode( WarningFlag::Yes, ErrCodeArea::Sc, ErrCodeClass::Export, 4 ) +#define SCWARN_EXPORT_MAXTAB ErrCode( WarningFlag::Yes, ErrCodeArea::Sc, ErrCodeClass::Export, 5 ) +#define SCWARN_EXPORT_DATALOST ErrCode( WarningFlag::Yes, ErrCodeArea::Sc, ErrCodeClass::Export, 6 ) + +// ErrCodeClass::General +#define SCWARN_CORE_HARD_RECALC ErrCode( WarningFlag::Yes, ErrCodeArea::Sc, ErrCodeClass::General, 1 ) + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/scextopt.hxx b/sc/inc/scextopt.hxx new file mode 100644 index 0000000000..843dfa6eba --- /dev/null +++ b/sc/inc/scextopt.hxx @@ -0,0 +1,118 @@ +/* -*- 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 <memory> +#include <tools/gen.hxx> +#include <tools/color.hxx> +#include "rangelst.hxx" + +/** Extended settings for the document, used in import/export filters. */ +struct ScExtDocSettings +{ + OUString maGlobCodeName; ///< Global codename (VBA module name). + double mfTabBarWidth; ///< Width of the tabbar, relative to frame window width (0.0 ... 1.0). + sal_uInt32 mnLinkCnt; ///< Recursive counter for loading external documents. + SCTAB mnDisplTab; ///< Index of displayed sheet. + + explicit ScExtDocSettings(); +}; + +/** Enumerates possible positions of panes in split sheets. */ +enum ScExtPanePos +{ + SCEXT_PANE_TOPLEFT, ///< Single, top, left, or top-left pane. + SCEXT_PANE_TOPRIGHT, ///< Right, or top-right pane. + SCEXT_PANE_BOTTOMLEFT, ///< Bottom, or bottom-left pane. + SCEXT_PANE_BOTTOMRIGHT ///< Bottom-right pane. +}; + +/** Extended settings for a sheet, used in import/export filters. */ +struct ScExtTabSettings +{ + ScRange maUsedArea; ///< Used area in the sheet (columns/rows only). + ScRangeList maSelection; ///< Selected cell ranges (columns/rows only). + ScAddress maCursor; ///< The cursor position (column/row only). + ScAddress maFirstVis; ///< Top-left visible cell (column/row only). + ScAddress maSecondVis; ///< Top-left visible cell in add. panes (column/row only). + ScAddress maFreezePos; ///< Position of frozen panes (column/row only). + Point maSplitPos; ///< Position of split. + ScExtPanePos meActivePane; ///< Active (focused) pane. + Color maGridColor; ///< Grid color. + tools::Long mnNormalZoom; ///< Zoom in percent for normal view. + tools::Long mnPageZoom; ///< Zoom in percent for pagebreak preview. + bool mbSelected; ///< true = Sheet is selected. + bool mbFrozenPanes; ///< true = Frozen panes; false = Normal splits. + bool mbPageMode; ///< true = Pagebreak mode; false = Normal view mode. + bool mbShowGrid; ///< Whether or not to display gridlines. + + explicit ScExtTabSettings(); +}; + +struct ScExtDocOptionsImpl; + +/** Extended options held by an ScDocument containing additional settings for filters. + + This object is owned by a Calc document. It contains global document settings + (struct ScExtDocSettings), settings for all sheets in the document + (struct ScExtTabSettings), and a list of codenames used for VBA import/export. + */ +class SC_DLLPUBLIC ScExtDocOptions +{ +public: + explicit ScExtDocOptions(); + ScExtDocOptions( const ScExtDocOptions& rSrc ); + ~ScExtDocOptions(); + + ScExtDocOptions& operator=( const ScExtDocOptions& rSrc ); + + /** @return true, if the data needs to be copied to the view data after import. */ + bool IsChanged() const; + /** If set to true, the data will be copied to the view data after import. */ + void SetChanged( bool bChanged ); + + /** @return read access to the global document settings. */ + const ScExtDocSettings& GetDocSettings() const; + /** @return read/write access to the global document settings. */ + ScExtDocSettings& GetDocSettings(); + + /** @return read access to the settings of a sheet, if extant; otherwise 0. */ + const ScExtTabSettings* GetTabSettings( SCTAB nTab ) const; + + /** + * @return index of the last sheet that has settings, or -1 if no tab + * settings are present. + */ + SCTAB GetLastTab() const; + + /** @return read/write access to the settings of a sheet, may create a new struct. */ + ScExtTabSettings& GetOrCreateTabSettings( SCTAB nTab ); + + /** @return the number of sheet codenames. */ + SCTAB GetCodeNameCount() const; + /** @return the specified codename (empty string = no codename). */ + OUString GetCodeName( SCTAB nTab ) const; + /** Appends a codename for a sheet. */ + void SetCodeName( SCTAB nTab, const OUString& rCodeName ); + +private: + ::std::unique_ptr< ScExtDocOptionsImpl > mxImpl; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/scfuncs.hrc b/sc/inc/scfuncs.hrc new file mode 100644 index 0000000000..8fb9f59e90 --- /dev/null +++ b/sc/inc/scfuncs.hrc @@ -0,0 +1,4154 @@ +/* -*- 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 <unotools/resmgr.hxx> + +#define NC_(Context, String) TranslateId(Context, u8##String) + +/* Resource file for the function wizard / autopilot. + * + * For every function there is a StringArray with a resource id (offset by + * RID_SC_FUNC_DESCRIPTIONS_START) with the OpCode of the function + * + * In this stringarray, the description of the function is given as the first + * entry, followed by two entries for each parameter, first the type or name + * of the parameter, second a description of the parameter. + */ + +// -=*# Resource for function DCOUNT #*=- +const TranslateId SC_OPCODE_DB_COUNT_ARY[] = +{ + NC_("SC_OPCODE_DB_COUNT", "Counts the cells of a data range whose contents match the search criteria."), + NC_("SC_OPCODE_DB_COUNT", "Database"), + NC_("SC_OPCODE_DB_COUNT", "The range of cells containing data."), + NC_("SC_OPCODE_DB_COUNT", "Database field"), + NC_("SC_OPCODE_DB_COUNT", "Indicates which database field (column) is to be used for the search criteria."), + NC_("SC_OPCODE_DB_COUNT", "Search criteria"), + NC_("SC_OPCODE_DB_COUNT", "Defines the cell range containing the search criteria.") +}; + +// -=*# Resource for function DCOUNTA #*=- +const TranslateId SC_OPCODE_DB_COUNT_2_ARY[] = +{ + NC_("SC_OPCODE_DB_COUNT_2", "Counts all non-blank cells of a data range where the content corresponds to the search criteria."), + NC_("SC_OPCODE_DB_COUNT_2", "Database"), + NC_("SC_OPCODE_DB_COUNT_2", "The range of cells containing data."), + NC_("SC_OPCODE_DB_COUNT_2", "Database field"), + NC_("SC_OPCODE_DB_COUNT_2", "Indicates which database field (column) is to be used for the search criteria."), + NC_("SC_OPCODE_DB_COUNT_2", "Search criteria"), + NC_("SC_OPCODE_DB_COUNT_2", "Defines the cell range containing the search criteria.") +}; + +// -=*# Resource for function DAVERAGE #*=- +const TranslateId SC_OPCODE_DB_AVERAGE_ARY[] = +{ + NC_("SC_OPCODE_DB_AVERAGE", "Returns the average value of all the cells of a data range whose contents match the search criteria."), + NC_("SC_OPCODE_DB_AVERAGE", "Database"), + NC_("SC_OPCODE_DB_AVERAGE", "The range of cells containing data."), + NC_("SC_OPCODE_DB_AVERAGE", "Database field"), + NC_("SC_OPCODE_DB_AVERAGE", "Indicates which database field (column) is to be used for the search criteria."), + NC_("SC_OPCODE_DB_AVERAGE", "Search criteria"), + NC_("SC_OPCODE_DB_AVERAGE", "Defines the cell range containing the search criteria.") +}; + +// -=*# Resource for function DGET #*=- +const TranslateId SC_OPCODE_DB_GET_ARY[] = +{ + NC_("SC_OPCODE_DB_GET", "Defines the contents of the cell of a data range which matches the search criteria."), + NC_("SC_OPCODE_DB_GET", "Database"), + NC_("SC_OPCODE_DB_GET", "The range of cells containing data."), + NC_("SC_OPCODE_DB_GET", "Database field"), + NC_("SC_OPCODE_DB_GET", "Indicates which database field (column) is to be used for the search criteria."), + NC_("SC_OPCODE_DB_GET", "Search criteria"), + NC_("SC_OPCODE_DB_GET", "Defines the cell range containing the search criteria.") +}; + +// -=*# Resource for function DMAX #*=- +const TranslateId SC_OPCODE_DB_MAX_ARY[] = +{ + NC_("SC_OPCODE_DB_MAX", "Returns the maximum value from all of the cells of a data range which correspond to the search criteria."), + NC_("SC_OPCODE_DB_MAX", "Database"), + NC_("SC_OPCODE_DB_MAX", "The range of cells containing data."), + NC_("SC_OPCODE_DB_MAX", "Database field"), + NC_("SC_OPCODE_DB_MAX", "Indicates which database field (column) is to be used for the search criteria."), + NC_("SC_OPCODE_DB_MAX", "Search criteria"), + NC_("SC_OPCODE_DB_MAX", "Defines the cell range containing the search criteria.") +}; + +// -=*# Resource for function DMIN #*=- +const TranslateId SC_OPCODE_DB_MIN_ARY[] = +{ + NC_("SC_OPCODE_DB_MIN", "Returns the minimum of all cells of a data range where the contents correspond to the search criteria."), + NC_("SC_OPCODE_DB_MIN", "Database"), + NC_("SC_OPCODE_DB_MIN", "The range of cells containing data."), + NC_("SC_OPCODE_DB_MIN", "Database field"), + NC_("SC_OPCODE_DB_MIN", "Indicates which database field (column) is to be used for the search criteria."), + NC_("SC_OPCODE_DB_MIN", "Search criteria"), + NC_("SC_OPCODE_DB_MIN", "Defines the cell range containing the search criteria.") +}; + +// -=*# Resource for function DPRODUCT #*=- +const TranslateId SC_OPCODE_DB_PRODUCT_ARY[] = +{ + NC_("SC_OPCODE_DB_PRODUCT", "Multiplies all cells of a data range where the contents match the search criteria."), + NC_("SC_OPCODE_DB_PRODUCT", "Database"), + NC_("SC_OPCODE_DB_PRODUCT", "The range of cells containing data."), + NC_("SC_OPCODE_DB_PRODUCT", "Database field"), + NC_("SC_OPCODE_DB_PRODUCT", "Indicates which database field (column) is to be used for the search criteria."), + NC_("SC_OPCODE_DB_PRODUCT", "Search criteria"), + NC_("SC_OPCODE_DB_PRODUCT", "Defines the cell range containing the search criteria.") +}; + +// -=*# Resource for function DSTDEV #*=- +const TranslateId SC_OPCODE_DB_STD_DEV_ARY[] = +{ + NC_("SC_OPCODE_DB_STD_DEV", "Calculates the standard deviation of all cells in a data range whose contents match the search criteria."), + NC_("SC_OPCODE_DB_STD_DEV", "Database"), + NC_("SC_OPCODE_DB_STD_DEV", "The range of cells containing data."), + NC_("SC_OPCODE_DB_STD_DEV", "Database field"), + NC_("SC_OPCODE_DB_STD_DEV", "Indicates which database field (column) is to be used for the search criteria."), + NC_("SC_OPCODE_DB_STD_DEV", "Search criteria"), + NC_("SC_OPCODE_DB_STD_DEV", "Defines the cell range containing the search criteria.") +}; + +// -=*# Resource for function DSTDEVP #*=- +const TranslateId SC_OPCODE_DB_STD_DEV_P_ARY[] = +{ + NC_("SC_OPCODE_DB_STD_DEV_P", "Returns the standard deviation with regards to the population of all cells of a data range matching the search criteria."), + NC_("SC_OPCODE_DB_STD_DEV_P", "Database"), + NC_("SC_OPCODE_DB_STD_DEV_P", "The range of cells containing data."), + NC_("SC_OPCODE_DB_STD_DEV_P", "Database field"), + NC_("SC_OPCODE_DB_STD_DEV_P", "Indicates which database field (column) is to be used for the search criteria."), + NC_("SC_OPCODE_DB_STD_DEV_P", "Search criteria"), + NC_("SC_OPCODE_DB_STD_DEV_P", "Defines the cell range containing the search criteria.") +}; + +// -=*# Resource for function DSUM #*=- +const TranslateId SC_OPCODE_DB_SUM_ARY[] = +{ + NC_("SC_OPCODE_DB_SUM", "Adds all the cells of a data range where the contents match the search criteria."), + NC_("SC_OPCODE_DB_SUM", "Database"), + NC_("SC_OPCODE_DB_SUM", "The range of cells containing data."), + NC_("SC_OPCODE_DB_SUM", "Database field"), + NC_("SC_OPCODE_DB_SUM", "Indicates which database field (column) is to be used for the search criteria."), + NC_("SC_OPCODE_DB_SUM", "Search criteria"), + NC_("SC_OPCODE_DB_SUM", "Defines the cell range containing the search criteria.") +}; + +// -=*# Resource for function DVAR #*=- +const TranslateId SC_OPCODE_DB_VAR_ARY[] = +{ + NC_("SC_OPCODE_DB_VAR", "Determines the variance of all the cells in a data range where the contents match the search criteria."), + NC_("SC_OPCODE_DB_VAR", "Database"), + NC_("SC_OPCODE_DB_VAR", "The range of cells containing data."), + NC_("SC_OPCODE_DB_VAR", "Database field"), + NC_("SC_OPCODE_DB_VAR", "Indicates which database field (column) is to be used for the search criteria."), + NC_("SC_OPCODE_DB_VAR", "Search criteria"), + NC_("SC_OPCODE_DB_VAR", "Defines the cell range containing the search criteria.") +}; + +// -=*# Resource for function DVARP #*=- +const TranslateId SC_OPCODE_DB_VAR_P_ARY[] = +{ + NC_("SC_OPCODE_DB_VAR_P", "Determines variance of a population based on all cells in a data range where contents match the search criteria."), + NC_("SC_OPCODE_DB_VAR_P", "Database"), + NC_("SC_OPCODE_DB_VAR_P", "The range of cells containing data."), + NC_("SC_OPCODE_DB_VAR_P", "Database field"), + NC_("SC_OPCODE_DB_VAR_P", "Indicates which database field (column) is to be used for the search criteria."), + NC_("SC_OPCODE_DB_VAR_P", "Search criteria"), + NC_("SC_OPCODE_DB_VAR_P", "Defines the cell range containing the search criteria.") +}; + +// -=*# Resource for function DATE #*=- +const TranslateId SC_OPCODE_GET_DATE_ARY[] = +{ + NC_("SC_OPCODE_GET_DATE", "Provides an internal number for the date given."), + NC_("SC_OPCODE_GET_DATE", "Year"), + NC_("SC_OPCODE_GET_DATE", "An integer between 1583 and 9956 or 0 and 99 (19xx or 20xx depending on the defined option)."), + NC_("SC_OPCODE_GET_DATE", "Month"), + NC_("SC_OPCODE_GET_DATE", "An integer between 1 and 12 representing the month."), + NC_("SC_OPCODE_GET_DATE", "Day"), + NC_("SC_OPCODE_GET_DATE", "An integer between 1 and 31 representing the day of the month.") +}; + +// -=*# Resource for function DATE_VALUE #*=- +const TranslateId SC_OPCODE_GET_DATE_VALUE_ARY[] = +{ + NC_("SC_OPCODE_GET_DATE_VALUE", "Returns an internal number for a text having a possible date format."), + NC_("SC_OPCODE_GET_DATE_VALUE", "Text"), + NC_("SC_OPCODE_GET_DATE_VALUE", "A text enclosed in quotation marks which returns a date in a %PRODUCTNAME date format.") +}; + +// -=*# Resource for function DAY #*=- +const TranslateId SC_OPCODE_GET_DAY_ARY[] = +{ + NC_("SC_OPCODE_GET_DAY", "Returns the sequential date of the month as an integer (1-31) in relation to the date value."), + NC_("SC_OPCODE_GET_DAY", "Number"), + NC_("SC_OPCODE_GET_DAY", "The internal number for the date.") +}; + +// -=*# Resource for function DAYS360 #*=- +const TranslateId SC_OPCODE_GET_DIFF_DATE_360_ARY[] = +{ + NC_("SC_OPCODE_GET_DIFF_DATE_360", "Calculates the number of days between two dates based on a 360-day year."), + NC_("SC_OPCODE_GET_DIFF_DATE_360", "Date 1"), + NC_("SC_OPCODE_GET_DIFF_DATE_360", "The start date for calculating the difference in days."), + NC_("SC_OPCODE_GET_DIFF_DATE_360", "Date 2"), + NC_("SC_OPCODE_GET_DIFF_DATE_360", "The end date for calculating the difference in days."), + NC_("SC_OPCODE_GET_DIFF_DATE_360", "Type"), + NC_("SC_OPCODE_GET_DIFF_DATE_360", "Method used to form differences: Type = 0 denotes US method (NASD), Type = 1 denotes the European method.") +}; + +// -=*# Resource for function NETWORKDAYS #*=- +const TranslateId SC_OPCODE_NETWORKDAYS_ARY[] = +{ + NC_("SC_OPCODE_NETWORKDAYS", "Returns the number of workdays between two dates using arguments to indicate weekenddays and holidays."), + NC_("SC_OPCODE_NETWORKDAYS", "Start date"), + NC_("SC_OPCODE_NETWORKDAYS", "Start date for calculation."), + NC_("SC_OPCODE_NETWORKDAYS", "End date"), + NC_("SC_OPCODE_NETWORKDAYS", "End date for calculation."), + NC_("SC_OPCODE_NETWORKDAYS", "List of dates"), + NC_("SC_OPCODE_NETWORKDAYS", "Optional set of one or more dates to be considered as holiday."), + NC_("SC_OPCODE_NETWORKDAYS", "Array"), + NC_("SC_OPCODE_NETWORKDAYS", "Optional list of numbers to indicate working (0) and weekend (non-zero) days. When omitted, weekend is Saturday and Sunday.") +}; + +// -=*# Resource for function NETWORKDAYS.INTL #*=- +const TranslateId SC_OPCODE_NETWORKDAYS_MS_ARY[] = +{ + NC_("SC_OPCODE_NETWORKDAYS_MS", "Returns the number of workdays between two dates using arguments to indicate weekend days and holidays."), + NC_("SC_OPCODE_NETWORKDAYS_MS", "Start date"), + NC_("SC_OPCODE_NETWORKDAYS_MS", "Start date for calculation."), + NC_("SC_OPCODE_NETWORKDAYS_MS", "End date"), + NC_("SC_OPCODE_NETWORKDAYS_MS", "End date for calculation."), + NC_("SC_OPCODE_NETWORKDAYS_MS", "Number or string"), + NC_("SC_OPCODE_NETWORKDAYS_MS", "Optional number or string to indicate when weekends occur. When omitted, weekend is Saturday and Sunday."), + NC_("SC_OPCODE_NETWORKDAYS_MS", "Array"), + NC_("SC_OPCODE_NETWORKDAYS_MS", "Optional set of one or more dates to be considered as holiday.") +}; + +// -=*# Resource for function WORKDAY.INTL #*=- +const TranslateId SC_OPCODE_WORKDAY_MS_ARY[] = +{ + NC_("SC_OPCODE_WORKDAY_MS", "Returns the serial number of the date before or after a number of workdays using arguments to indicate weekend days and holidays."), + NC_("SC_OPCODE_WORKDAY_MS", "Start date"), + NC_("SC_OPCODE_WORKDAY_MS", "Start date for calculation."), + NC_("SC_OPCODE_WORKDAY_MS", "Days"), + NC_("SC_OPCODE_WORKDAY_MS", "The number of workdays before or after start date."), + NC_("SC_OPCODE_WORKDAY_MS", "Number or string"), + NC_("SC_OPCODE_WORKDAY_MS", "Optional number or string to indicate when weekends occur. When omitted, weekend is Saturday and Sunday."), + NC_("SC_OPCODE_WORKDAY_MS", "Array"), + NC_("SC_OPCODE_WORKDAY_MS", "Optional set of one or more dates to be considered as holiday.") +}; + +// -=*# Resource for function HOUR #*=- +const TranslateId SC_OPCODE_GET_HOUR_ARY[] = +{ + NC_("SC_OPCODE_GET_HOUR", "Determines the sequential number of the hour of the day (0-23) for the time value."), + NC_("SC_OPCODE_GET_HOUR", "Number"), + NC_("SC_OPCODE_GET_HOUR", "Internal time value") +}; + +// -=*# Resource for function MINUTE #*=- +const TranslateId SC_OPCODE_GET_MIN_ARY[] = +{ + NC_("SC_OPCODE_GET_MIN", "Determines the sequential number for the minute of the hour (0-59) for the time value."), + NC_("SC_OPCODE_GET_MIN", "Number"), + NC_("SC_OPCODE_GET_MIN", "Internal time value.") +}; + +// -=*# Resource for function MONTH #*=- +const TranslateId SC_OPCODE_GET_MONTH_ARY[] = +{ + NC_("SC_OPCODE_GET_MONTH", "Determines the sequential number of a month of the year (1-12) for the date value."), + NC_("SC_OPCODE_GET_MONTH", "Number"), + NC_("SC_OPCODE_GET_MONTH", "The internal number of the date.") +}; + +// -=*# Resource for function NOW #*=- +const TranslateId SC_OPCODE_GET_ACT_TIME_ARY[] = +{ + NC_("SC_OPCODE_GET_ACT_TIME", "Determines the current time of the computer.") +}; + +// -=*# Resource for function SECOND #*=- +const TranslateId SC_OPCODE_GET_SEC_ARY[] = +{ + NC_("SC_OPCODE_GET_SEC", "Determines the sequential number of the second of a minute (0-59) for the time value."), + NC_("SC_OPCODE_GET_SEC", "Number"), + NC_("SC_OPCODE_GET_SEC", "The internal time value.") +}; + +// -=*# Resource for function TIME #*=- +const TranslateId SC_OPCODE_GET_TIME_ARY[] = +{ + NC_("SC_OPCODE_GET_TIME", "Determines a time value from the details for hour, minute and second."), + NC_("SC_OPCODE_GET_TIME", "Hour"), + NC_("SC_OPCODE_GET_TIME", "The integer for the hour."), + NC_("SC_OPCODE_GET_TIME", "Minute"), + NC_("SC_OPCODE_GET_TIME", "The integer for the minute."), + NC_("SC_OPCODE_GET_TIME", "Second"), + NC_("SC_OPCODE_GET_TIME", "The integer for the second.") +}; + +// -=*# Resource for function TIMEVALUE #*=- +const TranslateId SC_OPCODE_GET_TIME_VALUE_ARY[] = +{ + NC_("SC_OPCODE_GET_TIME_VALUE", "Returns a sequential number for a text shown in a possible time entry format."), + NC_("SC_OPCODE_GET_TIME_VALUE", "Text"), + NC_("SC_OPCODE_GET_TIME_VALUE", "A text enclosed in quotation marks which returns a time in a %PRODUCTNAME time format.") +}; + +// -=*# Resource for function TODAY #*=- +const TranslateId SC_OPCODE_GET_ACT_DATE_ARY[] = +{ + NC_("SC_OPCODE_GET_ACT_DATE", "Determines the current date of the computer.") +}; + +// -=*# Resource for function WEEKDAY #*=- +const TranslateId SC_OPCODE_GET_DAY_OF_WEEK_ARY[] = +{ + NC_("SC_OPCODE_GET_DAY_OF_WEEK", "Returns the day of the week for the date value as an integer."), + NC_("SC_OPCODE_GET_DAY_OF_WEEK", "Number"), + NC_("SC_OPCODE_GET_DAY_OF_WEEK", "The internal number for the date."), + NC_("SC_OPCODE_GET_DAY_OF_WEEK", "Type"), + NC_("SC_OPCODE_GET_DAY_OF_WEEK", "Fixes the beginning of the week and the type of calculation to be used.") +}; + +// -=*# Resource for function YEAR #*=- +const TranslateId SC_OPCODE_GET_YEAR_ARY[] = +{ + NC_("SC_OPCODE_GET_YEAR", "Returns the year of a date value as an integer."), + NC_("SC_OPCODE_GET_YEAR", "Number"), + NC_("SC_OPCODE_GET_YEAR", "Internal number of the date.") +}; + +// -=*# Resource for function DAYS #*=- +const TranslateId SC_OPCODE_GET_DIFF_DATE_ARY[] = +{ + NC_("SC_OPCODE_GET_DIFF_DATE", "Calculates the number of days between two dates."), + NC_("SC_OPCODE_GET_DIFF_DATE", "Date 2"), + NC_("SC_OPCODE_GET_DIFF_DATE", "The end date for calculating the difference in days."), + NC_("SC_OPCODE_GET_DIFF_DATE", "Date 1"), + NC_("SC_OPCODE_GET_DIFF_DATE", "The start date for calculating the difference in days.") +}; + +// -=*# Resource for function DATEDIF #*=- +const TranslateId SC_OPCODE_GET_DATEDIF_ARY[] = +{ + NC_("SC_OPCODE_GET_DATEDIF", "Returns the number of whole days, months or years between 'start date' and 'end date'."), + NC_("SC_OPCODE_GET_DATEDIF", "Start date"), + NC_("SC_OPCODE_GET_DATEDIF", "The start date."), + NC_("SC_OPCODE_GET_DATEDIF", "End date"), + NC_("SC_OPCODE_GET_DATEDIF", "The end date."), + NC_("SC_OPCODE_GET_DATEDIF", "Interval"), + NC_("SC_OPCODE_GET_DATEDIF", "Interval to be calculated. Can be \"d\", \"m\", \"y\", \"ym\", \"md\" or \"yd\".") +}; + +// -=*# Resource for function WEEKNUM #*=- +const TranslateId SC_OPCODE_WEEK_ARY[] = +{ + NC_("SC_OPCODE_WEEK", "Calculates the calendar week corresponding to the given date."), + NC_("SC_OPCODE_WEEK", "Number"), + NC_("SC_OPCODE_WEEK", "The internal number of the date."), + NC_("SC_OPCODE_WEEK", "Mode"), + NC_("SC_OPCODE_WEEK", "Indicates the first day of the week and when week 1 starts.") +}; + +// -=*# Resource for function ISOWEEKNUM #*=- +const TranslateId SC_OPCODE_ISOWEEKNUM_ARY[] = +{ + NC_("SC_OPCODE_ISOWEEKNUM", "Calculates the ISO 8601 calendar week for the given date."), + NC_("SC_OPCODE_ISOWEEKNUM", "Number"), + NC_("SC_OPCODE_ISOWEEKNUM", "The internal number of the date.") +}; + +const TranslateId SC_OPCODE_WEEKNUM_OOO_ARY[] = +{ + NC_("SC_OPCODE_WEEKNUM_OOO", "Calculates the calendar week corresponding to the given date.\nThis function only provides interoperability with %PRODUCTNAME 5.0 and earlier and OpenOffice.org."), + NC_("SC_OPCODE_WEEKNUM_OOO", "Number"), + NC_("SC_OPCODE_WEEKNUM_OOO", "The internal number of the date."), + NC_("SC_OPCODE_WEEKNUM_OOO", "Mode"), + NC_("SC_OPCODE_WEEKNUM_OOO", "Indicates the first day of the week (1 = Sunday, other values = Monday).") +}; + +// -=*# Resource for function EASTERSUNDAY #*=- +const TranslateId SC_OPCODE_EASTERSUNDAY_ARY[] = +{ + NC_("SC_OPCODE_EASTERSUNDAY", "Calculates the date of Easter Sunday in a given year."), + NC_("SC_OPCODE_EASTERSUNDAY", "Year"), + NC_("SC_OPCODE_EASTERSUNDAY", "An integer between 1583 and 9956, or 0 and 99 (19xx or 20xx depending on the option set).") +}; + +// -=*# Resource for function PV #*=- +const TranslateId SC_OPCODE_PV_ARY[] = +{ + NC_("SC_OPCODE_PV", "Present value. Calculates the present value of an investment."), + NC_("SC_OPCODE_PV", "Rate"), + NC_("SC_OPCODE_PV", "The rate of interest for the period given."), + NC_("SC_OPCODE_PV", "NPER"), + NC_("SC_OPCODE_PV", "The payment period. The total number of periods in which the annuity is paid."), + NC_("SC_OPCODE_PV", "PMT"), + NC_("SC_OPCODE_PV", "Regular payments. The constant amount of annuity that is paid in each period."), + NC_("SC_OPCODE_PV", "FV"), + NC_("SC_OPCODE_PV", "Future value. The value (final value) to be attained after the last payment."), + NC_("SC_OPCODE_PV", "Type"), + NC_("SC_OPCODE_PV", "Type = 1 denotes due at the beginning of the period, = 0 at the end.") +}; + +// -=*# Resource for function FV #*=- +const TranslateId SC_OPCODE_FV_ARY[] = +{ + NC_("SC_OPCODE_FV", "Future value. Returns the future value of an investment based on regular payments and a constant interest rate."), + NC_("SC_OPCODE_FV", "Rate"), + NC_("SC_OPCODE_FV", "The rate of interest per period."), + NC_("SC_OPCODE_FV", "NPER"), + NC_("SC_OPCODE_FV", "Payment period. The total number of periods in which the annuity (pension) is paid."), + NC_("SC_OPCODE_FV", "PMT"), + NC_("SC_OPCODE_FV", "Regular payments. The constant annuity to be paid in each period."), + NC_("SC_OPCODE_FV", "PV"), + NC_("SC_OPCODE_FV", "Present value. The current value of a series of payments"), + NC_("SC_OPCODE_FV", "Type"), + NC_("SC_OPCODE_FV", "Type = 1 denotes due at the beginning of the period, = 0 at the end.") +}; + +// -=*# Resource for function NPER #*=- +const TranslateId SC_OPCODE_NPER_ARY[] = +{ + NC_("SC_OPCODE_NPER", "Payment period. Calculates the number of payment periods for an investment based on regular payments and a constant interest rate."), + NC_("SC_OPCODE_NPER", "Rate"), + NC_("SC_OPCODE_NPER", "The rate of interest per period."), + NC_("SC_OPCODE_NPER", "PMT"), + NC_("SC_OPCODE_NPER", "Regular payments. The constant annuity to be paid in each period."), + NC_("SC_OPCODE_NPER", "PV"), + NC_("SC_OPCODE_NPER", "Present value. The current value of a series of payments"), + NC_("SC_OPCODE_NPER", "FV"), + NC_("SC_OPCODE_NPER", "Future value. The value (end value) to be attained after the final payment."), + NC_("SC_OPCODE_NPER", "Type"), + NC_("SC_OPCODE_NPER", "Type = 1 denotes due at the beginning of the period, = 0 at the end.") +}; + +// -=*# Resource for function PMT #*=- +const TranslateId SC_OPCODE_PMT_ARY[] = +{ + NC_("SC_OPCODE_PMT", "Regular payments. Returns the periodic payment of an annuity, based on regular payments and a fixed periodic interest rate."), + NC_("SC_OPCODE_PMT", "Rate"), + NC_("SC_OPCODE_PMT", "The rate of interest per period."), + NC_("SC_OPCODE_PMT", "NPER"), + NC_("SC_OPCODE_PMT", "Payment period. The total number of periods in which the annuity (pension) is paid."), + NC_("SC_OPCODE_PMT", "PV"), + NC_("SC_OPCODE_PMT", "Present value. The current value of a series of payments"), + NC_("SC_OPCODE_PMT", "FV"), + NC_("SC_OPCODE_PMT", "Future value. The value (end value) to be attained after the final payment."), + NC_("SC_OPCODE_PMT", "Type"), + NC_("SC_OPCODE_PMT", "Type = 1 denotes due at the beginning of the period, = 0 at the end.") +}; + +// -=*# Resource for function RATE #*=- +const TranslateId SC_OPCODE_RATE_ARY[] = +{ + NC_("SC_OPCODE_RATE", "Calculates the constant interest rate of an investment with regular payments."), + NC_("SC_OPCODE_RATE", "NPER"), + NC_("SC_OPCODE_RATE", "Payment period. The total number of periods in which the annuity (pension) is paid."), + NC_("SC_OPCODE_RATE", "PMT"), + NC_("SC_OPCODE_RATE", "Regular payments. The constant annuity to be paid in each period."), + NC_("SC_OPCODE_RATE", "PV"), + NC_("SC_OPCODE_RATE", "Present value. The current value of a series of payments"), + NC_("SC_OPCODE_RATE", "FV"), + NC_("SC_OPCODE_RATE", "Future value. The value (end value) to be attained after the final payment."), + NC_("SC_OPCODE_RATE", "Type"), + NC_("SC_OPCODE_RATE", "Type = 1 denotes due at the beginning of the period, = 0 at the end."), + NC_("SC_OPCODE_RATE", "Guess"), + NC_("SC_OPCODE_RATE", "Guess. The estimate of the interest rate for the iterative calculating method.") +}; + +// -=*# Resource for function IPMT #*=- +const TranslateId SC_OPCODE_IPMT_ARY[] = +{ + NC_("SC_OPCODE_IPMT", "Compounded interest. Calculates the interest payment on the principal for an investment with regular payments and a constant interest rate for a given period."), + NC_("SC_OPCODE_IPMT", "Rate"), + NC_("SC_OPCODE_IPMT", "The rate of interest per period."), + NC_("SC_OPCODE_IPMT", "Period"), + NC_("SC_OPCODE_IPMT", "Periods. The periods for which the compounded interest is to be calculated. P = 1 denotes for the first period, P = NPER for the last one."), + NC_("SC_OPCODE_IPMT", "NPER"), + NC_("SC_OPCODE_IPMT", "Payment period. The total number of periods in which the annuity (pension) is paid."), + NC_("SC_OPCODE_IPMT", "PV"), + NC_("SC_OPCODE_IPMT", "Present value. The current value of a series of payments"), + NC_("SC_OPCODE_IPMT", "FV"), + NC_("SC_OPCODE_IPMT", "Future value. The value (end value) to be attained after the final payment."), + NC_("SC_OPCODE_IPMT", "Type"), + NC_("SC_OPCODE_IPMT", "Type = 1 denotes due at the beginning of the period, = 0 at the end.") +}; + +// -=*# Resource for function PPMT #*=- +const TranslateId SC_OPCODE_PPMT_ARY[] = +{ + NC_("SC_OPCODE_PPMT", "Repayment. Calculates the repayment amount for a period for an investment whereby the payments are at regular intervals and the interest rate constant."), + NC_("SC_OPCODE_PPMT", "Rate"), + NC_("SC_OPCODE_PPMT", "The interest rate per period."), + NC_("SC_OPCODE_PPMT", "Period"), + NC_("SC_OPCODE_PPMT", "Period. The period for which the repayments are to be calculated. Per = 1 denotes for the first period, P = NPER for the last"), + NC_("SC_OPCODE_PPMT", "NPER"), + NC_("SC_OPCODE_PPMT", "The payment period. The total number of periods in which the annuity (pension) is paid."), + NC_("SC_OPCODE_PPMT", "PV"), + NC_("SC_OPCODE_PPMT", "The present value. The present value or the amount the annuity is currently worth."), + NC_("SC_OPCODE_PPMT", "FV"), + NC_("SC_OPCODE_PPMT", "Future value. The value (end value) attained after the last payment has been made."), + NC_("SC_OPCODE_PPMT", "Type"), + NC_("SC_OPCODE_PPMT", "Type = 1 denotes due at the beginning of the period, = 0 at the end.") +}; + +// -=*# Resource for function CUMPRINC #*=- +const TranslateId SC_OPCODE_CUM_PRINC_ARY[] = +{ + NC_("SC_OPCODE_CUM_PRINC", "Cumulative capital. Calculates the total amount of the repayment share in a period for an investment with constant interest rate."), + NC_("SC_OPCODE_CUM_PRINC", "Rate"), + NC_("SC_OPCODE_CUM_PRINC", "The rate of interest per period."), + NC_("SC_OPCODE_CUM_PRINC", "NPER"), + NC_("SC_OPCODE_CUM_PRINC", "Payment period. The total number of periods in which the annuity (pension) is paid."), + NC_("SC_OPCODE_CUM_PRINC", "PV"), + NC_("SC_OPCODE_CUM_PRINC", "The present value. The present value or the amount the annuity is currently worth."), + NC_("SC_OPCODE_CUM_PRINC", "S"), + NC_("SC_OPCODE_CUM_PRINC", "The start period. The first period to be taken into account. S = 1 denotes the very first period."), + NC_("SC_OPCODE_CUM_PRINC", "E"), + NC_("SC_OPCODE_CUM_PRINC", "End period. The last period to be taken into account."), + NC_("SC_OPCODE_CUM_PRINC", "Type"), + NC_("SC_OPCODE_CUM_PRINC", "Type = 1 denotes due at the beginning of the period, = 0 at the end.") +}; + +// -=*# Resource for function CUMIPMT #*=- +const TranslateId SC_OPCODE_CUM_IPMT_ARY[] = +{ + NC_("SC_OPCODE_CUM_IPMT", "Cumulative compounded interest. Calculates the total amount of the interest share in a period for an investment with a constant interest rate."), + NC_("SC_OPCODE_CUM_IPMT", "Rate"), + NC_("SC_OPCODE_CUM_IPMT", "The rate of interest per period."), + NC_("SC_OPCODE_CUM_IPMT", "NPER"), + NC_("SC_OPCODE_CUM_IPMT", "Payment period. The total number of periods in which the annuity (pension) is paid."), + NC_("SC_OPCODE_CUM_IPMT", "PV"), + NC_("SC_OPCODE_CUM_IPMT", "The present value. The present value or the amount the annuity is currently worth."), + NC_("SC_OPCODE_CUM_IPMT", "S"), + NC_("SC_OPCODE_CUM_IPMT", "The start period. The first period to be taken into account. S = 1 denotes the very first period."), + NC_("SC_OPCODE_CUM_IPMT", "E"), + NC_("SC_OPCODE_CUM_IPMT", "The end period. The last period to be taken into account."), + NC_("SC_OPCODE_CUM_IPMT", "Type"), + NC_("SC_OPCODE_CUM_IPMT", "Type = 1 denotes due at the beginning of the period, = 0 at the end.") +}; + +// -=*# Resource for function SYD #*=- +const TranslateId SC_OPCODE_SYD_ARY[] = +{ + NC_("SC_OPCODE_SYD", "Calculates the arithmetically declining value of an asset (depreciation) for a specified period."), + NC_("SC_OPCODE_SYD", "Cost"), + NC_("SC_OPCODE_SYD", "Acquisition costs. The initial cost of the asset."), + NC_("SC_OPCODE_SYD", "Salvage"), + NC_("SC_OPCODE_SYD", "Salvage: The remaining value of the asset at the end of its life."), + NC_("SC_OPCODE_SYD", "Life"), + NC_("SC_OPCODE_SYD", "Useful life. The number of periods in the useful life of the asset."), + NC_("SC_OPCODE_SYD", "Period"), + NC_("SC_OPCODE_SYD", "Period. The depreciation period which must have the same time unit as average useful life.") +}; + +// -=*# Resource for function SLN #*=- +const TranslateId SC_OPCODE_SLN_ARY[] = +{ + NC_("SC_OPCODE_SLN", "Calculates the linear depreciation per period."), + NC_("SC_OPCODE_SLN", "Cost"), + NC_("SC_OPCODE_SLN", "Acquisition cost. The initial cost of an asset."), + NC_("SC_OPCODE_SLN", "Salvage"), + NC_("SC_OPCODE_SLN", "Salvage: The remaining value of the asset at the end of its life."), + NC_("SC_OPCODE_SLN", "Life"), + NC_("SC_OPCODE_SLN", "Useful life. The number of periods in the useful life of the asset.") +}; + +// -=*# Resource for function DDB #*=- +const TranslateId SC_OPCODE_DDB_ARY[] = +{ + NC_("SC_OPCODE_DDB", "Calculates the depreciation of an asset for a specific period using the double-declining balance method or declining balance factor."), + NC_("SC_OPCODE_DDB", "Cost"), + NC_("SC_OPCODE_DDB", "Acquisition costs. The initial cost of the asset."), + NC_("SC_OPCODE_DDB", "Salvage"), + NC_("SC_OPCODE_DDB", "Salvage: The remaining value of the asset at the end of its life."), + NC_("SC_OPCODE_DDB", "Life"), + NC_("SC_OPCODE_DDB", "Useful life. The number of periods in the useful life of the asset."), + NC_("SC_OPCODE_DDB", "Period"), + NC_("SC_OPCODE_DDB", "Period. The depreciation period in the same time unit as the average useful life entry."), + NC_("SC_OPCODE_DDB", "Factor"), + NC_("SC_OPCODE_DDB", "Factor. The factor for balance decline. F = 2 means a double declining balance factor") +}; + +// -=*# Resource for function DB #*=- +const TranslateId SC_OPCODE_DB_ARY[] = +{ + NC_("SC_OPCODE_DB", "Returns the real depreciation of an asset for a specified period using the fixed-declining balance method."), + NC_("SC_OPCODE_DB", "Cost"), + NC_("SC_OPCODE_DB", "Acquisition costs: The initial cost of the asset."), + NC_("SC_OPCODE_DB", "Salvage"), + NC_("SC_OPCODE_DB", "Salvage: The remaining value of the asset at the end of its life."), + NC_("SC_OPCODE_DB", "Life"), + NC_("SC_OPCODE_DB", "Useful life. The number of periods in the useful life of the asset."), + NC_("SC_OPCODE_DB", "Period"), + NC_("SC_OPCODE_DB", "Periods: The period for which the depreciation is calculated. The time unit used for period must be the same as that for the useful life."), + NC_("SC_OPCODE_DB", "Month"), + NC_("SC_OPCODE_DB", "Months: The number of months in the first year of depreciation.") +}; + +// -=*# Resource for function VDB #*=- +const TranslateId SC_OPCODE_VBD_ARY[] = +{ + NC_("SC_OPCODE_VBD", "Variable declining balance. Returns the declining balance depreciation for a particular period."), + NC_("SC_OPCODE_VBD", "Cost"), + NC_("SC_OPCODE_VBD", "Cost. The initial cost of the asset."), + NC_("SC_OPCODE_VBD", "Salvage"), + NC_("SC_OPCODE_VBD", "Salvage. The salvage value of an asset at the end of its useful life."), + NC_("SC_OPCODE_VBD", "Life"), + NC_("SC_OPCODE_VBD", "Useful life. The number of periods in the useful life of the asset."), + NC_("SC_OPCODE_VBD", "Start"), + NC_("SC_OPCODE_VBD", "Start. The first period for depreciation in the same time unit as the useful life."), + NC_("SC_OPCODE_VBD", "End"), + NC_("SC_OPCODE_VBD", "End. The last period of the depreciation using the same time unit as for the useful life."), + NC_("SC_OPCODE_VBD", "Factor"), + NC_("SC_OPCODE_VBD", "Factor. The factor for the reduction of the depreciation. Factor = 2 denotes double rate depreciation."), + NC_("SC_OPCODE_VBD", "NoSwitch"), + NC_("SC_OPCODE_VBD", "NoSwitch = 0 denotes switch to linear depreciation, NoSwitch = 1 do not switch.") +}; + +// -=*# Resource for function EFFECT #*=- +const TranslateId SC_OPCODE_EFFECT_ARY[] = +{ + NC_("SC_OPCODE_EFFECT", "Calculates the annual net interest rate for a nominal interest rate."), + NC_("SC_OPCODE_EFFECT", "NOM"), + NC_("SC_OPCODE_EFFECT", "Nominal interest"), + NC_("SC_OPCODE_EFFECT", "P"), + NC_("SC_OPCODE_EFFECT", "Periods. The number of interest payments per year.") +}; + +// -=*# Resource for function NOMINAL #*=- +const TranslateId SC_OPCODE_NOMINAL_ARY[] = +{ + NC_("SC_OPCODE_NOMINAL", "Calculates the yearly nominal interest rate as an effective interest rate."), + NC_("SC_OPCODE_NOMINAL", "Effective rate"), + NC_("SC_OPCODE_NOMINAL", "The effective interest rate"), + NC_("SC_OPCODE_NOMINAL", "NPER"), + NC_("SC_OPCODE_NOMINAL", "Periods. The number of interest payment per year.") +}; + +// -=*# Resource for function NPV #*=- +const TranslateId SC_OPCODE_NPV_ARY[] = +{ + NC_("SC_OPCODE_NPV", "Net present value. Calculates the net present value of an investment based on a series of periodic payments and a discount rate."), + NC_("SC_OPCODE_NPV", "Rate"), + NC_("SC_OPCODE_NPV", "The rate of discount for one period."), + NC_("SC_OPCODE_NPV", "Value "), + NC_("SC_OPCODE_NPV", "Value 1, value 2,... are arguments representing payments and income.") +}; + +// -=*# Resource for function IRR #*=- +const TranslateId SC_OPCODE_IRR_ARY[] = +{ + NC_("SC_OPCODE_IRR", "Returns the actuarial rate of interest of an investment excluding costs or profits."), + NC_("SC_OPCODE_IRR", "Values"), + NC_("SC_OPCODE_IRR", "An array or reference to cells whose contents correspond to the payments."), + NC_("SC_OPCODE_IRR", "Guess"), + NC_("SC_OPCODE_IRR", "Guess. An estimated value of the rate of return to be used for the iteration calculation.") +}; + +// -=*# Resource for function MIRR #*=- +const TranslateId SC_OPCODE_MIRR_ARY[] = +{ + NC_("SC_OPCODE_MIRR", "Returns the modified internal rate of return for a series of investments."), + NC_("SC_OPCODE_MIRR", "Values"), + NC_("SC_OPCODE_MIRR", "An array or reference to cells whose contents correspond to the payments."), + NC_("SC_OPCODE_MIRR", "Investment"), + NC_("SC_OPCODE_MIRR", "Interest rate for investments (the negative values in the array)."), + NC_("SC_OPCODE_MIRR", "Reinvest rate"), + NC_("SC_OPCODE_MIRR", "Interest rate for reinvestments (the positive values in the array).") +}; + +// -=*# Resource for function ISPMT #*=- +const TranslateId SC_OPCODE_ISPMT_ARY[] = +{ + NC_("SC_OPCODE_ISPMT", "Returns the amount of interest for constant amortization rates."), + NC_("SC_OPCODE_ISPMT", "Rate"), + NC_("SC_OPCODE_ISPMT", "Interest rate for a single amortization rate."), + NC_("SC_OPCODE_ISPMT", "Period"), + NC_("SC_OPCODE_ISPMT", "Number of amortization periods for the calculation of the interest."), + NC_("SC_OPCODE_ISPMT", "Total periods"), + NC_("SC_OPCODE_ISPMT", "Sum total of amortization periods."), + NC_("SC_OPCODE_ISPMT", "Investment"), + NC_("SC_OPCODE_ISPMT", "Amount of the investment.") +}; + +// -=*# Resource for function PDURATION #*=- +const TranslateId SC_OPCODE_PDURATION_ARY[] = +{ + NC_("SC_OPCODE_PDURATION", "Duration. Calculates the number of periods required by an investment to attain the desired value."), + NC_("SC_OPCODE_PDURATION", "Rate"), + NC_("SC_OPCODE_PDURATION", "The constant rate of interest."), + NC_("SC_OPCODE_PDURATION", "PV"), + NC_("SC_OPCODE_PDURATION", "The present value. The current value of the investment."), + NC_("SC_OPCODE_PDURATION", "FV"), + NC_("SC_OPCODE_PDURATION", "The future value of the investment.") +}; + +// -=*# Resource for function RRI #*=- +const TranslateId SC_OPCODE_RRI_ARY[] = +{ + NC_("SC_OPCODE_RRI", "Interest. Calculates the interest rate which represents the rate of return from an investment."), + NC_("SC_OPCODE_RRI", "Periods"), + NC_("SC_OPCODE_RRI", "The number of periods used in the calculation."), + NC_("SC_OPCODE_RRI", "PV"), + NC_("SC_OPCODE_RRI", "Present value. The current value of the investment."), + NC_("SC_OPCODE_RRI", "FV"), + NC_("SC_OPCODE_RRI", "The future value of the investment.") +}; + +// -=*# Resource for function ISREF #*=- +const TranslateId SC_OPCODE_IS_REF_ARY[] = +{ + NC_("SC_OPCODE_IS_REF", "Returns TRUE if value is a reference."), + NC_("SC_OPCODE_IS_REF", "Value"), + NC_("SC_OPCODE_IS_REF", "The value to be tested.") +}; + +// -=*# Resource for function ISERR #*=- +const TranslateId SC_OPCODE_IS_ERR_ARY[] = +{ + NC_("SC_OPCODE_IS_ERR", "Returns TRUE if the value is an error value not equal to #N/A."), + NC_("SC_OPCODE_IS_ERR", "Value"), + NC_("SC_OPCODE_IS_ERR", "The value to be tested.") +}; + +// -=*# Resource for function ISERROR #*=- +const TranslateId SC_OPCODE_IS_ERROR_ARY[] = +{ + NC_("SC_OPCODE_IS_ERROR", "Returns TRUE if the value is an error value."), + NC_("SC_OPCODE_IS_ERROR", "Value"), + NC_("SC_OPCODE_IS_ERROR", "The value to be tested.") +}; + +// -=*# Resource for function ISBLANK #*=- +const TranslateId SC_OPCODE_IS_EMPTY_ARY[] = +{ + NC_("SC_OPCODE_IS_EMPTY", "Returns TRUE if value refers to an empty cell."), + NC_("SC_OPCODE_IS_EMPTY", "Value"), + NC_("SC_OPCODE_IS_EMPTY", "The value to be tested.") +}; + +// -=*# Resource for function ISLOGICAL #*=- +const TranslateId SC_OPCODE_IS_LOGICAL_ARY[] = +{ + NC_("SC_OPCODE_IS_LOGICAL", "Returns TRUE if the value carries a logical number format."), + NC_("SC_OPCODE_IS_LOGICAL", "Value"), + NC_("SC_OPCODE_IS_LOGICAL", "The value to be tested.") +}; + +// -=*# Resource for function ISNA #*=- +const TranslateId SC_OPCODE_IS_NV_ARY[] = +{ + NC_("SC_OPCODE_IS_NV", "Returns TRUE if value equals #N/A."), + NC_("SC_OPCODE_IS_NV", "Value"), + NC_("SC_OPCODE_IS_NV", "The value to be tested.") +}; + +// -=*# Resource for function ISNONTEXT #*=- +const TranslateId SC_OPCODE_IS_NON_STRING_ARY[] = +{ + NC_("SC_OPCODE_IS_NON_STRING", "Returns TRUE if the value is not text."), + NC_("SC_OPCODE_IS_NON_STRING", "Value"), + NC_("SC_OPCODE_IS_NON_STRING", "The value to be tested.") +}; + +// -=*# Resource for function ISTEXT #*=- +const TranslateId SC_OPCODE_IS_STRING_ARY[] = +{ + NC_("SC_OPCODE_IS_STRING", "Returns TRUE if value is text."), + NC_("SC_OPCODE_IS_STRING", "Value"), + NC_("SC_OPCODE_IS_STRING", "The value to be tested.") +}; + +// -=*# Resource for function ISNUMBER #*=- +const TranslateId SC_OPCODE_IS_VALUE_ARY[] = +{ + NC_("SC_OPCODE_IS_VALUE", "Returns TRUE if value is a number."), + NC_("SC_OPCODE_IS_VALUE", "Value"), + NC_("SC_OPCODE_IS_VALUE", "The value to be tested.") +}; + +// -=*# Resource for function ISFORMULA #*=- +const TranslateId SC_OPCODE_IS_FORMULA_ARY[] = +{ + NC_("SC_OPCODE_IS_FORMULA", "Returns TRUE if the cell is a formula cell."), + NC_("SC_OPCODE_IS_FORMULA", "Reference"), + NC_("SC_OPCODE_IS_FORMULA", "The cell to be tested.") +}; + +// -=*# Resource for function FORMULA #*=- +const TranslateId SC_OPCODE_FORMULA_ARY[] = +{ + NC_("SC_OPCODE_FORMULA", "Returns the formula of a formula cell."), + NC_("SC_OPCODE_FORMULA", "Reference"), + NC_("SC_OPCODE_FORMULA", "The formula cell.") +}; + +// -=*# Resource for function N #*=- +const TranslateId SC_OPCODE_N_ARY[] = +{ + NC_("SC_OPCODE_N", "Converts a value to a number."), + NC_("SC_OPCODE_N", "Value"), + NC_("SC_OPCODE_N", "The value to be interpreted as a number.") +}; + +// -=*# Resource for function NA #*=- +const TranslateId SC_OPCODE_NO_VALUE_ARY[] = +{ + NC_("SC_OPCODE_NO_VALUE", "Not available. Returns the error value #N/A.") +}; + +// -=*# Resource for function TYPE #*=- +const TranslateId SC_OPCODE_TYPE_ARY[] = +{ + NC_("SC_OPCODE_TYPE", "Returns the data type of a value (1 = number, 2 = text, 4 = Boolean value, 8 = formula, 16 = error value, 64 = array)."), + NC_("SC_OPCODE_TYPE", "Value"), + NC_("SC_OPCODE_TYPE", "The value for which the data type is to be determined.") +}; + +// -=*# Resource for function CELL #*=- +const TranslateId SC_OPCODE_CELL_ARY[] = +{ + NC_("SC_OPCODE_CELL", "Determines information about address, formatting or contents of a cell."), + NC_("SC_OPCODE_CELL", "Info type"), + NC_("SC_OPCODE_CELL", "String that specifies the type of information."), + NC_("SC_OPCODE_CELL", "Reference"), + NC_("SC_OPCODE_CELL", "The position of the cell you want to examine.") +}; + +// -=*# Resource for function CURRENT #*=- +const TranslateId SC_OPCODE_CURRENT_ARY[] = +{ + NC_("SC_OPCODE_CURRENT", "Calculates the current value of the formula at the present location.") +}; + +// -=*# Resource for function FALSE #*=- +const TranslateId SC_OPCODE_FALSE_ARY[] = +{ + NC_("SC_OPCODE_FALSE", "Defines the logical value as FALSE.") +}; + +// -=*# Resource for function NOT #*=- +const TranslateId SC_OPCODE_NOT_ARY[] = +{ + NC_("SC_OPCODE_NOT", "Reverses the value of the argument."), + NC_("SC_OPCODE_NOT", "Logical value"), + NC_("SC_OPCODE_NOT", "An expression that can be either TRUE or FALSE.") +}; + +// -=*# Resource for function TRUE #*=- +const TranslateId SC_OPCODE_TRUE_ARY[] = +{ + NC_("SC_OPCODE_TRUE", "Returns the logical value TRUE.") +}; + +// -=*# Resource for function IF #*=- +const TranslateId SC_OPCODE_IF_ARY[] = +{ + NC_("SC_OPCODE_IF", "Specifies a logical test to be performed."), + NC_("SC_OPCODE_IF", "Test"), + NC_("SC_OPCODE_IF", "Any value or expression which can be either TRUE or FALSE."), + NC_("SC_OPCODE_IF", "Then value"), + NC_("SC_OPCODE_IF", "The result of the function if the logical test returns a TRUE."), + NC_("SC_OPCODE_IF", "Otherwise value"), + NC_("SC_OPCODE_IF", "The result of the function if the logical test returns FALSE.") +}; + +// -=*# Resource for function IFERROR #*=- +const TranslateId SC_OPCODE_IF_ERROR_ARY[] = +{ + NC_("SC_OPCODE_IF_ERROR", "Returns value if not an error value, else alternative."), + NC_("SC_OPCODE_IF_ERROR", "Value"), + NC_("SC_OPCODE_IF_ERROR", "The value to be calculated."), + NC_("SC_OPCODE_IF_ERROR", "Alternative value"), + NC_("SC_OPCODE_IF_ERROR", "The alternative to be returned, should value be an error value.") +}; + +// -=*# Resource for function IFNA #*=- +const TranslateId SC_OPCODE_IF_NA_ARY[] = +{ + NC_("SC_OPCODE_IF_NA", "Returns value if not a #N/A error, else alternative."), + NC_("SC_OPCODE_IF_NA", "Value"), + NC_("SC_OPCODE_IF_NA", "The value to be calculated."), + NC_("SC_OPCODE_IF_NA", "Alternative value"), + NC_("SC_OPCODE_IF_NA", "The alternative to be returned, should value be a #N/A error.") +}; + +// -=*# Resource for function OR #*=- +const TranslateId SC_OPCODE_OR_ARY[] = +{ + NC_("SC_OPCODE_OR", "Returns TRUE if an argument is TRUE."), + NC_("SC_OPCODE_OR", "Logical value "), + NC_("SC_OPCODE_OR", "Logical value 1, logical value 2,... are conditions to be tested and which return either TRUE or FALSE.") +}; + +// -=*# Resource for function XOR #*=- +const TranslateId SC_OPCODE_XOR_ARY[] = +{ + NC_("SC_OPCODE_XOR", "Returns TRUE if an odd number of arguments evaluates to TRUE."), + NC_("SC_OPCODE_XOR", "Logical value "), + NC_("SC_OPCODE_XOR", "Logical value 1, logical value 2, ... are conditions to be tested and which return either TRUE or FALSE.") +}; + +// -=*# Resource for function AND #*=- +const TranslateId SC_OPCODE_AND_ARY[] = +{ + NC_("SC_OPCODE_AND", "Returns TRUE if all arguments are TRUE."), + NC_("SC_OPCODE_AND", "Logical value "), + NC_("SC_OPCODE_AND", "Logical value 1, logical value 2;...are conditions to be tested and each returns either TRUE or FALSE.") +}; + +// -=*# Resource for function ABS #*=- +const TranslateId SC_OPCODE_ABS_ARY[] = +{ + NC_("SC_OPCODE_ABS", "Absolute value of a number."), + NC_("SC_OPCODE_ABS", "Number"), + NC_("SC_OPCODE_ABS", "The number whose absolute value is to be returned.") +}; + +// -=*# Resource for function POWER #*=- +const TranslateId SC_OPCODE_POWER_ARY[] = +{ + NC_("SC_OPCODE_POWER", "Returns a^b, base a raised to the power of exponent b."), + NC_("SC_OPCODE_POWER", "Base"), + NC_("SC_OPCODE_POWER", "The base a of the power a^b."), + NC_("SC_OPCODE_POWER", "Exponent"), + NC_("SC_OPCODE_POWER", "The exponent b of the power a^b.") +}; + +// -=*# Resource for function COUNTBLANK #*=- +const TranslateId SC_OPCODE_COUNT_EMPTY_CELLS_ARY[] = +{ + NC_("SC_OPCODE_COUNT_EMPTY_CELLS", "Counts the blank cells in a specified range."), + NC_("SC_OPCODE_COUNT_EMPTY_CELLS", "Range"), + NC_("SC_OPCODE_COUNT_EMPTY_CELLS", "The range in which empty cells are to be counted.") +}; + +// -=*# Resource for function PI #*=- +const TranslateId SC_OPCODE_PI_ARY[] = +{ + NC_("SC_OPCODE_PI", "Returns the value of the number Pi.") +}; + +// -=*# Resource for function SUM #*=- +const TranslateId SC_OPCODE_SUM_ARY[] = +{ + NC_("SC_OPCODE_SUM", "Returns the sum of all arguments."), + NC_("SC_OPCODE_SUM", "Number "), + NC_("SC_OPCODE_SUM", "Number 1, number 2, ... are arguments whose total is to be calculated.") +}; + +// -=*# Resource for function SUMSQ #*=- +const TranslateId SC_OPCODE_SUM_SQ_ARY[] = +{ + NC_("SC_OPCODE_SUM_SQ", "Returns the sum of the squares of the arguments."), + NC_("SC_OPCODE_SUM_SQ", "Number "), + NC_("SC_OPCODE_SUM_SQ", "Number 1, number 2,... are arguments for which the sum of the squares is to be calculated.") +}; + +// -=*# Resource for function PRODUCT #*=- +const TranslateId SC_OPCODE_PRODUCT_ARY[] = +{ + NC_("SC_OPCODE_PRODUCT", "Multiplies the arguments."), + NC_("SC_OPCODE_PRODUCT", "Number "), + NC_("SC_OPCODE_PRODUCT", "Number 1, number 2, ... are arguments to be multiplied and a result returned.") +}; + +// -=*# Resource for function SUMIF #*=- +const TranslateId SC_OPCODE_SUM_IF_ARY[] = +{ + NC_("SC_OPCODE_SUM_IF", "Totals the arguments that meet the condition."), + NC_("SC_OPCODE_SUM_IF", "Range"), + NC_("SC_OPCODE_SUM_IF", "The range to be evaluated by the criteria given."), + NC_("SC_OPCODE_SUM_IF", "Criteria"), + NC_("SC_OPCODE_SUM_IF", "The criteria to be applied to the range."), + NC_("SC_OPCODE_SUM_IF", "Sum range"), + NC_("SC_OPCODE_SUM_IF", "The range from which the values are to be totalled.") +}; + +// -=*# Resource for function AVERAGEIF #*=- +const TranslateId SC_OPCODE_AVERAGE_IF_ARY[] = +{ + NC_("SC_OPCODE_AVERAGE_IF", "Averages the arguments that meet the conditions."), + NC_("SC_OPCODE_AVERAGE_IF", "Range"), + NC_("SC_OPCODE_AVERAGE_IF", "The range to be evaluated by the criteria given."), + NC_("SC_OPCODE_AVERAGE_IF", "Criteria"), + NC_("SC_OPCODE_AVERAGE_IF", "The criteria to be applied to the range."), + NC_("SC_OPCODE_AVERAGE_IF", "Average range"), + NC_("SC_OPCODE_AVERAGE_IF", "The range from which the values are to be averaged.") +}; + +const TranslateId SC_OPCODE_SUM_IFS_ARY[] = +{ + NC_("SC_OPCODE_SUM_IFS", "Totals the values of cells in a range that meet multiple criteria in multiple ranges."), + NC_("SC_OPCODE_SUM_IFS", "Sum range"), + NC_("SC_OPCODE_SUM_IFS", "The range from which the values are to be totalled."), + NC_("SC_OPCODE_SUM_IFS", "Range "), + NC_("SC_OPCODE_SUM_IFS", "Range 1, range 2,... are the ranges to be evaluated by the criteria given."), + NC_("SC_OPCODE_SUM_IFS", "Criteria "), + NC_("SC_OPCODE_SUM_IFS", "Criteria 1, criteria 2,... are the criteria to be applied to the ranges given.") +}; + +// -=*# Resource for function AVERAGEIFS #*=- +const TranslateId SC_OPCODE_AVERAGE_IFS_ARY[] = +{ + NC_("SC_OPCODE_AVERAGE_IFS", "Averages the value of the cells that meet multiple criteria in multiple ranges."), + NC_("SC_OPCODE_AVERAGE_IFS", "Average range"), + NC_("SC_OPCODE_AVERAGE_IFS", "The range from which the values are to be averaged."), + NC_("SC_OPCODE_AVERAGE_IFS", "Range "), + NC_("SC_OPCODE_AVERAGE_IFS", "Range 1, range 2,... are the ranges to be evaluated by the criteria given."), + NC_("SC_OPCODE_AVERAGE_IFS", "Criteria "), + NC_("SC_OPCODE_AVERAGE_IFS", "Criteria 1, criteria 2,... are the criteria to be applied to the ranges given.") +}; + +// -=*# Resource for function COUNTIFS #*=- +const TranslateId SC_OPCODE_COUNT_IFS_ARY[] = +{ + NC_("SC_OPCODE_COUNT_IFS", "Counts the cells that meet multiple criteria in multiple ranges."), + NC_("SC_OPCODE_COUNT_IFS", "Range "), + NC_("SC_OPCODE_COUNT_IFS", "Range 1, range 2,... are the ranges to be evaluated by the criteria given."), + NC_("SC_OPCODE_COUNT_IFS", "Criteria "), + NC_("SC_OPCODE_COUNT_IFS", "Criteria 1, criteria 2,... are the criteria to be applied to the ranges given.") +}; + +// -=*# Resource for function COUNTIF #*=- +const TranslateId SC_OPCODE_COUNT_IF_ARY[] = +{ + NC_("SC_OPCODE_COUNT_IF", "Counts the arguments which meet the set conditions."), + NC_("SC_OPCODE_COUNT_IF", "Range"), + NC_("SC_OPCODE_COUNT_IF", "The range of cells to be evaluated by the criteria given."), + NC_("SC_OPCODE_COUNT_IF", "Criteria"), + NC_("SC_OPCODE_COUNT_IF", "The criteria to be applied to the range.") +}; + +// -=*# Resource for function SQRT #*=- +const TranslateId SC_OPCODE_SQRT_ARY[] = +{ + NC_("SC_OPCODE_SQRT", "Returns the square root of a number."), + NC_("SC_OPCODE_SQRT", "Number"), + NC_("SC_OPCODE_SQRT", "A positive value for which the square root is to be calculated.") +}; + +// -=*# Resource for function RAND #*=- +const TranslateId SC_OPCODE_RANDOM_ARY[] = +{ + NC_("SC_OPCODE_RANDOM", "Returns a random number between 0 and 1.") +}; + +// -=*# Resource for function ISEVEN #*=- +const TranslateId SC_OPCODE_IS_EVEN_ARY[] = +{ + NC_("SC_OPCODE_IS_EVEN", "Returns TRUE if the value truncated to integer is even."), + NC_("SC_OPCODE_IS_EVEN", "Value"), + NC_("SC_OPCODE_IS_EVEN", "The value to be tested.") +}; + +// -=*# Resource for function ISODD #*=- +const TranslateId SC_OPCODE_IS_ODD_ARY[] = +{ + NC_("SC_OPCODE_IS_ODD", "Returns TRUE if the value truncated to integer is odd."), + NC_("SC_OPCODE_IS_ODD", "Value"), + NC_("SC_OPCODE_IS_ODD", "The value to be tested.") +}; + +// -=*# Resource for function COMBIN #*=- +const TranslateId SC_OPCODE_COMBIN_ARY[] = +{ + NC_("SC_OPCODE_COMBIN", "Calculates the number of combinations for elements without repetition."), + NC_("SC_OPCODE_COMBIN", "Number 1"), + NC_("SC_OPCODE_COMBIN", "The total number of elements."), + NC_("SC_OPCODE_COMBIN", "Number 2"), + NC_("SC_OPCODE_COMBIN", "The number of elements selected.") +}; + +// -=*# Resource for function COMBINA #*=- +const TranslateId SC_OPCODE_COMBIN_A_ARY[] = +{ + NC_("SC_OPCODE_COMBIN_A", "Calculates the number of combinations of elements including repetition."), + NC_("SC_OPCODE_COMBIN_A", "Number 1"), + NC_("SC_OPCODE_COMBIN_A", "The total number of elements."), + NC_("SC_OPCODE_COMBIN_A", "Number 2"), + NC_("SC_OPCODE_COMBIN_A", "The number of elements selected.") +}; + +// -=*# Resource for function ARCCOS #*=- +const TranslateId SC_OPCODE_ARC_COS_ARY[] = +{ + NC_("SC_OPCODE_ARC_COS", "Returns the arccosine of a number."), + NC_("SC_OPCODE_ARC_COS", "Number"), + NC_("SC_OPCODE_ARC_COS", "A value between -1 and 1 for which the arccosine is to be returned.") +}; + +// -=*# Resource for function ARCSIN #*=- +const TranslateId SC_OPCODE_ARC_SIN_ARY[] = +{ + NC_("SC_OPCODE_ARC_SIN", "Returns the arcsine of a number."), + NC_("SC_OPCODE_ARC_SIN", "Number"), + NC_("SC_OPCODE_ARC_SIN", "A value between -1 and 1 for which the arcsine is to be returned.") +}; + +// -=*# Resource for function ARCCOSHYP #*=- +const TranslateId SC_OPCODE_ARC_COS_HYP_ARY[] = +{ + NC_("SC_OPCODE_ARC_COS_HYP", "Returns the inverse hyperbolic cosine of a number."), + NC_("SC_OPCODE_ARC_COS_HYP", "Number"), + NC_("SC_OPCODE_ARC_COS_HYP", "A value greater than or equal to 1 for which the inverse hyperbolic cosine is to be returned.") +}; + +// -=*# Resource for function ARCSINHYP #*=- +const TranslateId SC_OPCODE_ARC_SIN_HYP_ARY[] = +{ + NC_("SC_OPCODE_ARC_SIN_HYP", "Returns the inverse hyperbolic sine of a number."), + NC_("SC_OPCODE_ARC_SIN_HYP", "Number"), + NC_("SC_OPCODE_ARC_SIN_HYP", "The value for which the inverse hyperbolic sine is to be returned.") +}; + +// -=*# Resource for function ARCCOT #*=- +const TranslateId SC_OPCODE_ARC_COT_ARY[] = +{ + NC_("SC_OPCODE_ARC_COT", "Returns the inverse cotangent of a number."), + NC_("SC_OPCODE_ARC_COT", "Number"), + NC_("SC_OPCODE_ARC_COT", "The value for which the inverse cotangent is to be returned.") +}; + +// -=*# Resource for function ARCTAN #*=- +const TranslateId SC_OPCODE_ARC_TAN_ARY[] = +{ + NC_("SC_OPCODE_ARC_TAN", "Returns the arctangent of a number."), + NC_("SC_OPCODE_ARC_TAN", "Number"), + NC_("SC_OPCODE_ARC_TAN", "The value for which the arctangent is to be returned.") +}; + +// -=*# Resource for function ARCCOTHYP #*=- +const TranslateId SC_OPCODE_ARC_COT_HYP_ARY[] = +{ + NC_("SC_OPCODE_ARC_COT_HYP", "Returns the inverse hyperbolic cotangent of a number."), + NC_("SC_OPCODE_ARC_COT_HYP", "Number"), + NC_("SC_OPCODE_ARC_COT_HYP", "A value smaller than -1 or greater than 1 for which the inverse hyperbolic cotangent is to be returned.") +}; + +// -=*# Resource for function ARCTANHYP #*=- +const TranslateId SC_OPCODE_ARC_TAN_HYP_ARY[] = +{ + NC_("SC_OPCODE_ARC_TAN_HYP", "Returns the inverse hyperbolic tangent of a number."), + NC_("SC_OPCODE_ARC_TAN_HYP", "Number"), + NC_("SC_OPCODE_ARC_TAN_HYP", "A value between -1 and 1 for which the inverse hyperbolic tangent is to be returned.") +}; + +// -=*# Resource for function COS #*=- +const TranslateId SC_OPCODE_COS_ARY[] = +{ + NC_("SC_OPCODE_COS", "Returns the cosine of a number."), + NC_("SC_OPCODE_COS", "Number"), + NC_("SC_OPCODE_COS", "The angle in the radians for which the cosine is to be returned.") +}; + +// -=*# Resource for function SIN #*=- +const TranslateId SC_OPCODE_SIN_ARY[] = +{ + NC_("SC_OPCODE_SIN", "Returns the sine of a number."), + NC_("SC_OPCODE_SIN", "Number"), + NC_("SC_OPCODE_SIN", "The angle in radians for which the sine is to be calculated.") +}; + +// -=*# Resource for function COT #*=- +const TranslateId SC_OPCODE_COT_ARY[] = +{ + NC_("SC_OPCODE_COT", "Returns the cotangent of a number."), + NC_("SC_OPCODE_COT", "Number"), + NC_("SC_OPCODE_COT", "The angle in radians whose cotangent value is to be returned.") +}; + +// -=*# Resource for function TAN #*=- +const TranslateId SC_OPCODE_TAN_ARY[] = +{ + NC_("SC_OPCODE_TAN", "Returns the tangent of a number."), + NC_("SC_OPCODE_TAN", "Number"), + NC_("SC_OPCODE_TAN", "The angle in radians for which the tangent is to be calculated.") +}; + +// -=*# Resource for function COSHYP #*=- +const TranslateId SC_OPCODE_COS_HYP_ARY[] = +{ + NC_("SC_OPCODE_COS_HYP", "Returns the hyperbolic cosine of a number."), + NC_("SC_OPCODE_COS_HYP", "Number"), + NC_("SC_OPCODE_COS_HYP", "The value for which the hyperbolic cosine is to be returned.") +}; + +// -=*# Resource for function SINHYP #*=- +const TranslateId SC_OPCODE_SIN_HYP_ARY[] = +{ + NC_("SC_OPCODE_SIN_HYP", "Returns the hyperbolic sine of a number."), + NC_("SC_OPCODE_SIN_HYP", "Number"), + NC_("SC_OPCODE_SIN_HYP", "The value for which the hyperbolic sine is to be calculated.") +}; + +// -=*# Resource for function COTHYP #*=- +const TranslateId SC_OPCODE_COT_HYP_ARY[] = +{ + NC_("SC_OPCODE_COT_HYP", "Returns the hyperbolic cotangent of a number."), + NC_("SC_OPCODE_COT_HYP", "Number"), + NC_("SC_OPCODE_COT_HYP", "A value not equal to 0 for which the hyperbolic cotangent is to be returned.") +}; + +// -=*# Resource for function TANHYP #*=- +const TranslateId SC_OPCODE_TAN_HYP_ARY[] = +{ + NC_("SC_OPCODE_TAN_HYP", "Returns the hyperbolic tangent of a number."), + NC_("SC_OPCODE_TAN_HYP", "Number"), + NC_("SC_OPCODE_TAN_HYP", "The value for which the hyperbolic tangent is to be calculated.") +}; + +// -=*# Resource for function ARCTAN2 #*=- +const TranslateId SC_OPCODE_ARC_TAN_2_ARY[] = +{ + NC_("SC_OPCODE_ARC_TAN_2", "Returns the arctangent for the specified coordinates."), + NC_("SC_OPCODE_ARC_TAN_2", "Number X"), + NC_("SC_OPCODE_ARC_TAN_2", "The value for the X coordinate."), + NC_("SC_OPCODE_ARC_TAN_2", "Number Y"), + NC_("SC_OPCODE_ARC_TAN_2", "The value for the Y coordinate.") +}; + +// -=*# Resource for function CSC #*=- +const TranslateId SC_OPCODE_COSECANT_ARY[] = +{ + NC_("SC_OPCODE_COSECANT", "Return the cosecant of an angle. CSC(x)=1/SIN(x)"), + NC_("SC_OPCODE_COSECANT", "Angle"), + NC_("SC_OPCODE_COSECANT", "The angle in radians for which the cosecant is to be calculated.") +}; + +// -=*# Resource for function SEC #*=- +const TranslateId SC_OPCODE_SECANT_ARY[] = +{ + NC_("SC_OPCODE_SECANT", "Return the secant of an angle. SEC(x)=1/COS(x)"), + NC_("SC_OPCODE_SECANT", "Angle"), + NC_("SC_OPCODE_SECANT", "The angle in radians for which the secant is to be calculated.") +}; + +// -=*# Resource for function CSCH #*=- +const TranslateId SC_OPCODE_COSECANT_HYP_ARY[] = +{ + NC_("SC_OPCODE_COSECANT_HYP", "Return the hyperbolic cosecant of a hyperbolic angle. CSCH(x)=1/SINH(x)"), + NC_("SC_OPCODE_COSECANT_HYP", "Angle"), + NC_("SC_OPCODE_COSECANT_HYP", "The hyperbolic angle in radians for which the hyperbolic cosecant is to be calculated.") +}; + +// -=*# Resource for function SECH #*=- +const TranslateId SC_OPCODE_SECANT_HYP_ARY[] = +{ + NC_("SC_OPCODE_SECANT_HYP", "Return the hyperbolic secant of a hyperbolic angle. SECH(x)=1/COSH(x)"), + NC_("SC_OPCODE_SECANT_HYP", "Angle"), + NC_("SC_OPCODE_SECANT_HYP", "The hyperbolic angle in radians for which the hyperbolic secant is to be calculated.") +}; + +// -=*# Resource for function DEG #*=- +const TranslateId SC_OPCODE_DEG_ARY[] = +{ + NC_("SC_OPCODE_DEG", "Converts a radian to degrees"), + NC_("SC_OPCODE_DEG", "Number"), + NC_("SC_OPCODE_DEG", "The angle in a radian") +}; + +// -=*# Resource for function RAD #*=- +const TranslateId SC_OPCODE_RAD_ARY[] = +{ + NC_("SC_OPCODE_RAD", "Converts degrees to radians"), + NC_("SC_OPCODE_RAD", "Number"), + NC_("SC_OPCODE_RAD", "The angle in degrees.") +}; + +// -=*# Resource for function EXP #*=- +const TranslateId SC_OPCODE_EXP_ARY[] = +{ + NC_("SC_OPCODE_EXP", "Calculates the exponent for basis e."), + NC_("SC_OPCODE_EXP", "Number"), + NC_("SC_OPCODE_EXP", "The exponent applied to base e.") +}; + +// -=*# Resource for function LOG #*=- +const TranslateId SC_OPCODE_LOG_ARY[] = +{ + NC_("SC_OPCODE_LOG", "Calculates the logarithm to any specified base."), + NC_("SC_OPCODE_LOG", "Number"), + NC_("SC_OPCODE_LOG", "A value greater than 0 for which the logarithm is to be calculated."), + NC_("SC_OPCODE_LOG", "Base"), + NC_("SC_OPCODE_LOG", "The base of the logarithm. If omitted, the base is regarded as 10.") +}; + +// -=*# Resource for function LN #*=- +const TranslateId SC_OPCODE_LN_ARY[] = +{ + NC_("SC_OPCODE_LN", "Calculates the natural logarithm of a number."), + NC_("SC_OPCODE_LN", "Number"), + NC_("SC_OPCODE_LN", "A value greater than 0 for which the natural logarithm is to be calculated.") +}; + +// -=*# Resource for function LOG10 #*=- +const TranslateId SC_OPCODE_LOG10_ARY[] = +{ + NC_("SC_OPCODE_LOG10", "Calculates the base-10 logarithm of a number."), + NC_("SC_OPCODE_LOG10", "Number"), + NC_("SC_OPCODE_LOG10", "A value greater than 0 for which the logarithm is to be calculated.") +}; + +// -=*# Resource for function FACT #*=- +const TranslateId SC_OPCODE_FACT_ARY[] = +{ + NC_("SC_OPCODE_FACT", "Calculates the factorial of a number."), + NC_("SC_OPCODE_FACT", "Number"), + NC_("SC_OPCODE_FACT", "The number for which the factorial is to be calculated.") +}; + +// -=*# Resource for function MOD #*=- +const TranslateId SC_OPCODE_MOD_ARY[] = +{ + NC_("SC_OPCODE_MOD", "Calculates the remainder of a division."), + NC_("SC_OPCODE_MOD", "Dividend"), + NC_("SC_OPCODE_MOD", "The number to be divided."), + NC_("SC_OPCODE_MOD", "Divisor"), + NC_("SC_OPCODE_MOD", "The number by which the dividend is divided.") +}; + +// -=*# Resource for function SIGN #*=- +const TranslateId SC_OPCODE_PLUS_MINUS_ARY[] = +{ + NC_("SC_OPCODE_PLUS_MINUS", "Returns the algebraic sign of a number."), + NC_("SC_OPCODE_PLUS_MINUS", "Number"), + NC_("SC_OPCODE_PLUS_MINUS", "The number for which the algebraic sign is to be determined.") +}; + +// -=*# Resource for function SUBTOTAL #*=- +const TranslateId SC_OPCODE_SUB_TOTAL_ARY[] = +{ + NC_("SC_OPCODE_SUB_TOTAL", "Calculates subtotals in a spreadsheet."), + NC_("SC_OPCODE_SUB_TOTAL", "Function"), + NC_("SC_OPCODE_SUB_TOTAL", "Function index. Is an index of the possible functions Total, Max, ..."), + NC_("SC_OPCODE_SUB_TOTAL", "Range"), + NC_("SC_OPCODE_SUB_TOTAL", "The cells of the range which are to be taken into account.") +}; + +// -=*# Resource for function AGGREGATE #*=- +const TranslateId SC_OPCODE_AGGREGATE_ARY[] = +{ + NC_("SC_OPCODE_AGGREGATE", "Calculates an aggregate in a spreadsheet."), + NC_("SC_OPCODE_AGGREGATE", "Function"), + NC_("SC_OPCODE_AGGREGATE", "Function index. Is an index of the possible functions Total, Max, ..."), + NC_("SC_OPCODE_AGGREGATE", "Options"), + NC_("SC_OPCODE_AGGREGATE", "Option index. Is an index of the possible ignore options."), + NC_("SC_OPCODE_AGGREGATE", "Reference 1 or array"), + NC_("SC_OPCODE_AGGREGATE", "The cell(s) of the range which are to be taken into account."), + NC_("SC_OPCODE_AGGREGATE", "Reference 2..n or k "), + NC_("SC_OPCODE_AGGREGATE", "The cells of the range which are to be taken into account or mandatory 2nd argument for certain functions.") +}; + +// -=*# Resource for function INT #*=- +const TranslateId SC_OPCODE_INT_ARY[] = +{ + NC_("SC_OPCODE_INT", "Rounds a number down to the nearest integer."), + NC_("SC_OPCODE_INT", "Number"), + NC_("SC_OPCODE_INT", "The number to be rounded down.") +}; + +// -=*# Resource for function TRUNC #*=- +const TranslateId SC_OPCODE_TRUNC_ARY[] = +{ + NC_("SC_OPCODE_TRUNC", "Truncates the decimal places of a number."), + NC_("SC_OPCODE_TRUNC", "Number"), + NC_("SC_OPCODE_TRUNC", "The number to be truncated."), + NC_("SC_OPCODE_TRUNC", "Count"), + NC_("SC_OPCODE_TRUNC", "The number of places after the decimal point that are not to be truncated.") +}; + +// -=*# Resource for function ROUND #*=- +const TranslateId SC_OPCODE_ROUND_ARY[] = +{ + NC_("SC_OPCODE_ROUND", "Rounds a number to a predefined accuracy."), + NC_("SC_OPCODE_ROUND", "Number"), + NC_("SC_OPCODE_ROUND", "The number to be rounded."), + NC_("SC_OPCODE_ROUND", "Count"), + NC_("SC_OPCODE_ROUND", "The number of places to which a number is to be rounded.") +}; + +// -=*# Resource for function ROUNDUP #*=- +const TranslateId SC_OPCODE_ROUND_UP_ARY[] = +{ + NC_("SC_OPCODE_ROUND_UP", "Rounds a number up to the predefined accuracy."), + NC_("SC_OPCODE_ROUND_UP", "Number"), + NC_("SC_OPCODE_ROUND_UP", "The number to be rounded up."), + NC_("SC_OPCODE_ROUND_UP", "Count"), + NC_("SC_OPCODE_ROUND_UP", "The number of places to which a number is to be rounded.") +}; + +// -=*# Resource for function ROUNDDOWN #*=- +const TranslateId SC_OPCODE_ROUND_DOWN_ARY[] = +{ + NC_("SC_OPCODE_ROUND_DOWN", "Rounds a number down to a predefined accuracy."), + NC_("SC_OPCODE_ROUND_DOWN", "Number"), + NC_("SC_OPCODE_ROUND_DOWN", "The number to be rounded down."), + NC_("SC_OPCODE_ROUND_DOWN", "Count"), + NC_("SC_OPCODE_ROUND_DOWN", "The number of places down to which a number is to be rounded.") +}; + +// -=*# Resource for function EVEN #*=- +const TranslateId SC_OPCODE_EVEN_ARY[] = +{ + NC_("SC_OPCODE_EVEN", "Rounds a positive number up and negative number down to the nearest even integer."), + NC_("SC_OPCODE_EVEN", "Number"), + NC_("SC_OPCODE_EVEN", "The number to be rounded up.") +}; + +// -=*# Resource for function ODD #*=- +const TranslateId SC_OPCODE_ODD_ARY[] = +{ + NC_("SC_OPCODE_ODD", "Rounds a positive number up and negative number down to the nearest odd integer."), + NC_("SC_OPCODE_ODD", "Number"), + NC_("SC_OPCODE_ODD", "The number to be rounded up.") +}; + +// -=*# Resource for function CEILING.XCL #*=- +const TranslateId SC_OPCODE_CEIL_MS_ARY[] = +{ + NC_("SC_OPCODE_CEIL_MS", "Rounds a number away from zero to the nearest multiple of significance.\nThis function exists for interoperability with Microsoft Excel 2007 or older versions."), + NC_("SC_OPCODE_CEIL_MS", "Number"), + NC_("SC_OPCODE_CEIL_MS", "The number to be rounded up."), + NC_("SC_OPCODE_CEIL_MS", "Significance"), + NC_("SC_OPCODE_CEIL_MS", "The number to whose multiple the value is rounded.") +}; + +// -=*# Resource for function CEILING.PRECISE #*=- +const TranslateId SC_OPCODE_CEIL_PRECISE_ARY[] = +{ + NC_("SC_OPCODE_CEIL_PRECISE", "Rounds a number up to the nearest multiple of significance, regardless of sign of significance."), + NC_("SC_OPCODE_CEIL_PRECISE", "Number"), + NC_("SC_OPCODE_CEIL_PRECISE", "The number to be rounded up."), + NC_("SC_OPCODE_CEIL_PRECISE", "Significance"), + NC_("SC_OPCODE_CEIL_PRECISE", "The number to whose multiple the value is rounded.") +}; + +// -=*# Resource for function ISO.CEILING #*=- +const TranslateId SC_OPCODE_CEIL_ISO_ARY[] = +{ + NC_("SC_OPCODE_CEIL_ISO", "Rounds a number up to the nearest multiple of significance, regardless of sign of significance."), + NC_("SC_OPCODE_CEIL_ISO", "Number"), + NC_("SC_OPCODE_CEIL_ISO", "The number to be rounded up."), + NC_("SC_OPCODE_CEIL_ISO", "Significance"), + NC_("SC_OPCODE_CEIL_ISO", "The number to whose multiple the value is rounded.") +}; + +// -=*# Resource for function CEILING #*=- +const TranslateId SC_OPCODE_CEIL_ARY[] = +{ + NC_("SC_OPCODE_CEIL", "Rounds a number up to the nearest multiple of significance."), + NC_("SC_OPCODE_CEIL", "Number"), + NC_("SC_OPCODE_CEIL", "The number to be rounded up."), + NC_("SC_OPCODE_CEIL", "Significance"), + NC_("SC_OPCODE_CEIL", "If given the number to whose multiple the value is rounded, else -1 or 1 depending on sign of Number."), + NC_("SC_OPCODE_CEIL", "Mode"), + NC_("SC_OPCODE_CEIL", "If given and not equal to zero then rounded up according to amount when a negative number and significance.") +}; + +// -=*# Resource for function CEILING.MATH #*=- +const TranslateId SC_OPCODE_CEIL_MATH_ARY[] = +{ + NC_("SC_OPCODE_CEIL_MATH", "Rounds a number up to the nearest multiple of significance."), + NC_("SC_OPCODE_CEIL_MATH", "Number"), + NC_("SC_OPCODE_CEIL_MATH", "The number to be rounded up."), + NC_("SC_OPCODE_CEIL_MATH", "Significance"), + NC_("SC_OPCODE_CEIL_MATH", "If given the number to whose multiple the value is rounded, else 1."), + NC_("SC_OPCODE_CEIL_MATH", "Mode"), + NC_("SC_OPCODE_CEIL_MATH", "For negative numbers; if given and not equal to zero then rounds away from zero, else rounds towards zero.") +}; + +// -=*# Resource for function FLOOR #*=- +const TranslateId SC_OPCODE_FLOOR_ARY[] = +{ + NC_("SC_OPCODE_FLOOR", "Rounds number down to the nearest multiple of significance."), + NC_("SC_OPCODE_FLOOR", "Number"), + NC_("SC_OPCODE_FLOOR", "The number to be rounded down."), + NC_("SC_OPCODE_FLOOR", "Significance"), + NC_("SC_OPCODE_FLOOR", "The number to whose multiple the value is to be rounded down."), + NC_("SC_OPCODE_FLOOR", "Mode"), + NC_("SC_OPCODE_FLOOR", "If given and not equal to zero then rounded towards zero with negative number and significance.") +}; + +// -=*# Resource for function FLOOR.XCL #*=- +const TranslateId SC_OPCODE_FLOOR_MS_ARY[] = +{ + NC_("SC_OPCODE_FLOOR_MS", "Rounds number towards zero to the nearest multiple of absolute value of significance.\nThis function exists for interoperability with Microsoft Excel 2007 or older versions."), + NC_("SC_OPCODE_FLOOR_MS", "Number"), + NC_("SC_OPCODE_FLOOR_MS", "The number to be rounded down."), + NC_("SC_OPCODE_FLOOR_MS", "Significance"), + NC_("SC_OPCODE_FLOOR_MS", "The number to whose multiple the value is to be rounded down.") +}; + +// -=*# Resource for function FLOOR.MATH #*=- +const TranslateId SC_OPCODE_FLOOR_MATH_ARY[] = +{ + NC_("SC_OPCODE_FLOOR_MATH", "Rounds number down to the nearest multiple of significance, regardless of sign of significance."), + NC_("SC_OPCODE_FLOOR_MATH", "Number"), + NC_("SC_OPCODE_FLOOR_MATH", "The number to be rounded down."), + NC_("SC_OPCODE_FLOOR_MATH", "Significance"), + NC_("SC_OPCODE_FLOOR_MATH", "The number to whose multiple the value is to be rounded down."), + NC_("SC_OPCODE_FLOOR_MATH", "Mode"), + NC_("SC_OPCODE_FLOOR_MATH", "For negative numbers; if given and not equal to or less than zero rounds towards zero.") +}; + +// -=*# Resource for function FLOOR.PRECISE #*=- +const TranslateId SC_OPCODE_FLOOR_PRECISE_ARY[] = +{ + NC_("SC_OPCODE_FLOOR_PRECISE", "Rounds number down (towards -∞) to the nearest multiple of significance."), + NC_("SC_OPCODE_FLOOR_PRECISE", "Number"), + NC_("SC_OPCODE_FLOOR_PRECISE", "The number to be rounded down."), + NC_("SC_OPCODE_FLOOR_PRECISE", "Significance"), + NC_("SC_OPCODE_FLOOR_PRECISE", "The number to whose multiple the value is to be rounded down. Sign has no meaning.") +}; + +// -=*# Resource for function GCD #*=- +const TranslateId SC_OPCODE_GCD_ARY[] = +{ + NC_("SC_OPCODE_GCD", "Greatest Common Divisor"), + NC_("SC_OPCODE_GCD", "Integer "), + NC_("SC_OPCODE_GCD", "Integer 1; integer 2,... are integers for which the greatest common divisor is to be calculated.") +}; + +// -=*# Resource for function LCM #*=- +const TranslateId SC_OPCODE_LCM_ARY[] = +{ + NC_("SC_OPCODE_LCM", "Lowest common multiple"), + NC_("SC_OPCODE_LCM", "Integer "), + NC_("SC_OPCODE_LCM", "Integer 1; integer 2,... are integers whose smallest common multiple is to be calculated.") +}; + +// -=*# Resource for function TRANSPOSE #*=- +const TranslateId SC_OPCODE_MAT_TRANS_ARY[] = +{ + NC_("SC_OPCODE_MAT_TRANS", "Array transposition. Exchanges the rows and columns of an array."), + NC_("SC_OPCODE_MAT_TRANS", "Array"), + NC_("SC_OPCODE_MAT_TRANS", "The array in which the rows and columns have been transposed.") +}; + +// -=*# Resource for function MMULT #*=- +const TranslateId SC_OPCODE_MAT_MULT_ARY[] = +{ + NC_("SC_OPCODE_MAT_MULT", "Array multiplication. Returns the product of two arrays."), + NC_("SC_OPCODE_MAT_MULT", "Array 1"), + NC_("SC_OPCODE_MAT_MULT", "The first array for the array product."), + NC_("SC_OPCODE_MAT_MULT", "Array 2"), + NC_("SC_OPCODE_MAT_MULT", "The second array having the same number of rows as the first array has columns.") +}; + +// -=*# Resource for function MDETERM #*=- +const TranslateId SC_OPCODE_MAT_DET_ARY[] = +{ + NC_("SC_OPCODE_MAT_DET", "Returns the array determinant."), + NC_("SC_OPCODE_MAT_DET", "Array"), + NC_("SC_OPCODE_MAT_DET", "The array for which the determinant is to be determined.") +}; + +// -=*# Resource for function MINVERSE #*=- +const TranslateId SC_OPCODE_MAT_INV_ARY[] = +{ + NC_("SC_OPCODE_MAT_INV", "Returns the inverse of an array."), + NC_("SC_OPCODE_MAT_INV", "Array"), + NC_("SC_OPCODE_MAT_INV", "The array to be inverted.") +}; + +// -=*# Resource for function MUNIT #*=- +const TranslateId SC_OPCODE_MATRIX_UNIT_ARY[] = +{ + NC_("SC_OPCODE_MATRIX_UNIT", "Returns the unitary square array of a certain size."), + NC_("SC_OPCODE_MATRIX_UNIT", "Dimensions"), + NC_("SC_OPCODE_MATRIX_UNIT", "The size of the unitary array.") +}; + +// -=*# Resource for function SUMPRODUCT #*=- +const TranslateId SC_OPCODE_SUM_PRODUCT_ARY[] = +{ + NC_("SC_OPCODE_SUM_PRODUCT", "(Inner products) Returns the sum of the products of array arguments."), + NC_("SC_OPCODE_SUM_PRODUCT", "Array "), + NC_("SC_OPCODE_SUM_PRODUCT", "Array 1, array 2, ... are arrays whose arguments are to be multiplied.") +}; + +// -=*# Resource for function SUMX2MY2 #*=- +const TranslateId SC_OPCODE_SUM_X2MY2_ARY[] = +{ + NC_("SC_OPCODE_SUM_X2MY2", "Returns the sum of the difference of squares of two arrays."), + NC_("SC_OPCODE_SUM_X2MY2", "Array X"), + NC_("SC_OPCODE_SUM_X2MY2", "First array where the square of the arguments are totalled."), + NC_("SC_OPCODE_SUM_X2MY2", "Array Y"), + NC_("SC_OPCODE_SUM_X2MY2", "Second array where the square of the arguments is to be subtracted.") +}; + +// -=*# Resource for function SUMX2PY2 #*=- +const TranslateId SC_OPCODE_SUM_X2DY2_ARY[] = +{ + NC_("SC_OPCODE_SUM_X2DY2", "Returns the total of the square sum of two arrays."), + NC_("SC_OPCODE_SUM_X2DY2", "Array X"), + NC_("SC_OPCODE_SUM_X2DY2", "First array where the square of the arguments are totalled."), + NC_("SC_OPCODE_SUM_X2DY2", "Array Y"), + NC_("SC_OPCODE_SUM_X2DY2", "Second array where the square of the arguments is to be totalled.") +}; + +// -=*# Resource for function SUMXMY2 #*=- +const TranslateId SC_OPCODE_SUM_XMY2_ARY[] = +{ + NC_("SC_OPCODE_SUM_XMY2", "Returns the sum of squares of differences of two arrays."), + NC_("SC_OPCODE_SUM_XMY2", "Array X"), + NC_("SC_OPCODE_SUM_XMY2", "First array for forming argument differences."), + NC_("SC_OPCODE_SUM_XMY2", "Array Y"), + NC_("SC_OPCODE_SUM_XMY2", "Second array for forming the argument differences.") +}; + +// -=*# Resource for function FREQUENCY #*=- +const TranslateId SC_OPCODE_FREQUENCY_ARY[] = +{ + NC_("SC_OPCODE_FREQUENCY", "Returns a frequency distribution as a vertical array."), + NC_("SC_OPCODE_FREQUENCY", "Data"), + NC_("SC_OPCODE_FREQUENCY", "The array of the data."), + NC_("SC_OPCODE_FREQUENCY", "Classes"), + NC_("SC_OPCODE_FREQUENCY", "The array for forming classes.") +}; + +// -=*# Resource for function LINEST #*=- +const TranslateId SC_OPCODE_LINEST_ARY[] = +{ + NC_("SC_OPCODE_LINEST", "Calculates parameters of the linear regression as an array."), + NC_("SC_OPCODE_LINEST", "Data Y"), + NC_("SC_OPCODE_LINEST", "The Y data array."), + NC_("SC_OPCODE_LINEST", "Data X"), + NC_("SC_OPCODE_LINEST", "The X data array."), + NC_("SC_OPCODE_LINEST", "Linear type"), + NC_("SC_OPCODE_LINEST", "If type = 0 the linears will be calculated through the zero point, or else moved linears."), + NC_("SC_OPCODE_LINEST", "Stats"), + NC_("SC_OPCODE_LINEST", "If parameter = 0 then only the regression coefficient will be calculated, otherwise other values as well.") +}; + +// -=*# Resource for function LOGEST #*=- +const TranslateId SC_OPCODE_LOGEST_ARY[] = +{ + NC_("SC_OPCODE_LOGEST", "Calculates the parameters of the exponential regression curve as an array."), + NC_("SC_OPCODE_LOGEST", "Data Y"), + NC_("SC_OPCODE_LOGEST", "The Y data array."), + NC_("SC_OPCODE_LOGEST", "Data X"), + NC_("SC_OPCODE_LOGEST", "The X data array."), + NC_("SC_OPCODE_LOGEST", "Function type"), + NC_("SC_OPCODE_LOGEST", "If type = 0 then the functions will be calculated in the form of y=m^x, or also functions y=b*m^x."), + NC_("SC_OPCODE_LOGEST", "Stats"), + NC_("SC_OPCODE_LOGEST", "If parameter = 0 then only the regression coefficient will be calculated, otherwise other values as well.") +}; + +// -=*# Resource for function TREND #*=- +const TranslateId SC_OPCODE_TREND_ARY[] = +{ + NC_("SC_OPCODE_TREND", "Calculates points along a regression line."), + NC_("SC_OPCODE_TREND", "Data Y"), + NC_("SC_OPCODE_TREND", "The Y data array."), + NC_("SC_OPCODE_TREND", "Data X"), + NC_("SC_OPCODE_TREND", "The X data array as the basis for the regression."), + NC_("SC_OPCODE_TREND", "New data X"), + NC_("SC_OPCODE_TREND", "The array of X data for recalculating the values."), + NC_("SC_OPCODE_TREND", "Linear type"), + NC_("SC_OPCODE_TREND", "If type = 0 the linears will be calculated through the zero point, or else moved linears.") +}; + +// -=*# Resource for function GROWTH #*=- +const TranslateId SC_OPCODE_GROWTH_ARY[] = +{ + NC_("SC_OPCODE_GROWTH", "Calculates points on the exponential regression function."), + NC_("SC_OPCODE_GROWTH", "Data Y"), + NC_("SC_OPCODE_GROWTH", "The Y data array."), + NC_("SC_OPCODE_GROWTH", "Data X"), + NC_("SC_OPCODE_GROWTH", "The X data array as the basis for the regression."), + NC_("SC_OPCODE_GROWTH", "New data X"), + NC_("SC_OPCODE_GROWTH", "The array of X data for recalculating the values."), + NC_("SC_OPCODE_GROWTH", "Function type"), + NC_("SC_OPCODE_GROWTH", "If type = 0 then the functions will be calculated in the form of y=m^x, or also functions y=b*m^x.") +}; + +// -=*# Resource for function COUNT #*=- +const TranslateId SC_OPCODE_COUNT_ARY[] = +{ + NC_("SC_OPCODE_COUNT", "Counts how many numbers are in the list of arguments."), + NC_("SC_OPCODE_COUNT", "Value "), + NC_("SC_OPCODE_COUNT", "Value 1, value 2, ... are arguments containing different data types but where only numbers are counted.") +}; + +// -=*# Resource for function COUNTA #*=- +const TranslateId SC_OPCODE_COUNT_2_ARY[] = +{ + NC_("SC_OPCODE_COUNT_2", "Counts how many values are in the list of arguments."), + NC_("SC_OPCODE_COUNT_2", "Value "), + NC_("SC_OPCODE_COUNT_2", "Value 1, value 2, ... are arguments representing the values to be counted.") +}; + +// -=*# Resource for function MAX #*=- +const TranslateId SC_OPCODE_MAX_ARY[] = +{ + NC_("SC_OPCODE_MAX", "Returns the maximum value in a list of arguments."), + NC_("SC_OPCODE_MAX", "Number "), + NC_("SC_OPCODE_MAX", "Number 1, number 2, ... are numerical arguments for which the largest number is to be determined.") +}; + +// -=*# Resource for function MAXA #*=- +const TranslateId SC_OPCODE_MAX_A_ARY[] = +{ + NC_("SC_OPCODE_MAX_A", "Returns the maximum value in a list of arguments. Text is evaluated as Zero."), + NC_("SC_OPCODE_MAX_A", "Value "), + NC_("SC_OPCODE_MAX_A", "Value 1, value 2, are arguments whose largest value is to be determined.") +}; + +// -=*# Resource for function MIN #*=- +const TranslateId SC_OPCODE_MIN_ARY[] = +{ + NC_("SC_OPCODE_MIN", "Returns the minimum value in a list of arguments."), + NC_("SC_OPCODE_MIN", "Number "), + NC_("SC_OPCODE_MIN", "Number 1, number 2, ... are numerical arguments for which the smallest number is to be determined.") +}; + +// -=*# Resource for function MINA #*=- +const TranslateId SC_OPCODE_MIN_A_ARY[] = +{ + NC_("SC_OPCODE_MIN_A", "Returns the smallest value in a list of arguments. Text is evaluated as zero."), + NC_("SC_OPCODE_MIN_A", "Value "), + NC_("SC_OPCODE_MIN_A", "Value 1; value 2;... are arguments whose smallest number is to be determined.") +}; + +// -=*# Resource for function VAR #*=- +const TranslateId SC_OPCODE_VAR_ARY[] = +{ + NC_("SC_OPCODE_VAR", "Calculates the variance based on a sample."), + NC_("SC_OPCODE_VAR", "Number "), + NC_("SC_OPCODE_VAR", "Number 1, number 2, ... are numerical arguments which portray a sample of a population.") +}; + +// -=*# Resource for function VAR.S #*=- +const TranslateId SC_OPCODE_VAR_S_ARY[] = +{ + NC_("SC_OPCODE_VAR_S", "Calculates the variance based on a sample."), + NC_("SC_OPCODE_VAR_S", "Number "), + NC_("SC_OPCODE_VAR_S", "Number 1, number 2, ... are numerical arguments which portray a sample of a population.") +}; + +// -=*# Resource for function VARA #*=- +const TranslateId SC_OPCODE_VAR_A_ARY[] = +{ + NC_("SC_OPCODE_VAR_A", "Returns the variance based on a sample. Text is evaluated as zero."), + NC_("SC_OPCODE_VAR_A", "Value "), + NC_("SC_OPCODE_VAR_A", "Value 1; value 2; ... are arguments representing a sample taken from a basic total population.") +}; + +// -=*# Resource for function VARP #*=- +const TranslateId SC_OPCODE_VAR_P_ARY[] = +{ + NC_("SC_OPCODE_VAR_P", "Calculates variance based on the entire population."), + NC_("SC_OPCODE_VAR_P", "Number "), + NC_("SC_OPCODE_VAR_P", "Number 1, number 2, ... are numerical arguments which represent a population.") +}; + +// -=*# Resource for function VAR.P #*=- +const TranslateId SC_OPCODE_VAR_P_MS_ARY[] = +{ + NC_("SC_OPCODE_VAR_P_MS", "Calculates variance based on the entire population."), + NC_("SC_OPCODE_VAR_P_MS", "Number "), + NC_("SC_OPCODE_VAR_P_MS", "Number 1, number 2, ... are numerical arguments which represent a population.") +}; + +// -=*# Resource for function VARPA #*=- +const TranslateId SC_OPCODE_VAR_P_A_ARY[] = +{ + NC_("SC_OPCODE_VAR_P_A", "Returns the variance based on the entire population. Text is evaluated as zero."), + NC_("SC_OPCODE_VAR_P_A", "Value "), + NC_("SC_OPCODE_VAR_P_A", "Value 1; value 2;... are arguments representing a population.") +}; + +// -=*# Resource for function STDEV #*=- +const TranslateId SC_OPCODE_ST_DEV_ARY[] = +{ + NC_("SC_OPCODE_ST_DEV", "Calculates the standard deviation based on a sample."), + NC_("SC_OPCODE_ST_DEV", "Number "), + NC_("SC_OPCODE_ST_DEV", "Number 1, number 2, ... are numerical arguments which portray a sample of a population.") +}; + +// -=*# Resource for function STDEV.S #*=- +const TranslateId SC_OPCODE_ST_DEV_S_ARY[] = +{ + NC_("SC_OPCODE_ST_DEV_S", "Calculates the standard deviation based on a sample."), + NC_("SC_OPCODE_ST_DEV_S", "Number "), + NC_("SC_OPCODE_ST_DEV_S", "Number 1, number 2, ... are numerical arguments which portray a sample of a population.") +}; + +// -=*# Resource for function STDEVA #*=- +const TranslateId SC_OPCODE_ST_DEV_A_ARY[] = +{ + NC_("SC_OPCODE_ST_DEV_A", "Returns the standard deviation based on a sample. Text is evaluated as zero."), + NC_("SC_OPCODE_ST_DEV_A", "Value "), + NC_("SC_OPCODE_ST_DEV_A", "Value 1; value 2; ... are arguments representing a sample taken from a basic total population.") +}; + +// -=*# Resource for function STDEVP #*=- +const TranslateId SC_OPCODE_ST_DEV_P_ARY[] = +{ + NC_("SC_OPCODE_ST_DEV_P", "Calculates the standard deviation based on the entire population."), + NC_("SC_OPCODE_ST_DEV_P", "Number "), + NC_("SC_OPCODE_ST_DEV_P", "Number 1, number 2, ... are numerical arguments which portray a population.") +}; + +// -=*# Resource for function STDEV.P #*=- +const TranslateId SC_OPCODE_ST_DEV_P_MS_ARY[] = +{ + NC_("SC_OPCODE_ST_DEV_P_MS", "Calculates the standard deviation based on the entire population."), + NC_("SC_OPCODE_ST_DEV_P_MS", "Number "), + NC_("SC_OPCODE_ST_DEV_P_MS", "Number 1, number 2, ... are numerical arguments which portray a population.") +}; + +// -=*# Resource for function STDEVPA #*=- +const TranslateId SC_OPCODE_ST_DEV_P_A_ARY[] = +{ + NC_("SC_OPCODE_ST_DEV_P_A", "Returns the standard deviation based on the entire population. Text is evaluated as zero."), + NC_("SC_OPCODE_ST_DEV_P_A", "Value "), + NC_("SC_OPCODE_ST_DEV_P_A", "Value 1; value 2;... are arguments corresponding to a population.") +}; + +// -=*# Resource for function AVERAGE #*=- +const TranslateId SC_OPCODE_AVERAGE_ARY[] = +{ + NC_("SC_OPCODE_AVERAGE", "Returns the average of a sample."), + NC_("SC_OPCODE_AVERAGE", "Number "), + NC_("SC_OPCODE_AVERAGE", "Number 1, number 2;...are numeric arguments representing a population sample.") +}; + +// -=*# Resource for function AVERAGEA #*=- +const TranslateId SC_OPCODE_AVERAGE_A_ARY[] = +{ + NC_("SC_OPCODE_AVERAGE_A", "Returns the average value for a sample. Text is evaluated as zero."), + NC_("SC_OPCODE_AVERAGE_A", "Value "), + NC_("SC_OPCODE_AVERAGE_A", "Value 1; value 2; ... are arguments representing a sample taken from a basic total population.") +}; + +// -=*# Resource for function DEVSQ #*=- +const TranslateId SC_OPCODE_DEV_SQ_ARY[] = +{ + NC_("SC_OPCODE_DEV_SQ", "Returns the sum of squares of deviations from the sample mean value"), + NC_("SC_OPCODE_DEV_SQ", "Number "), + NC_("SC_OPCODE_DEV_SQ", "Number 1, number 2, ... are numerical arguments which portray a sample.") +}; + +// -=*# Resource for function AVEDEV #*=- +const TranslateId SC_OPCODE_AVE_DEV_ARY[] = +{ + NC_("SC_OPCODE_AVE_DEV", "Returns the average of the absolute deviations of a sample from the mean."), + NC_("SC_OPCODE_AVE_DEV", "Number "), + NC_("SC_OPCODE_AVE_DEV", "Number 1, number 2;...are numerical arguments representing a sample.") +}; + +// -=*# Resource for function SKEW #*=- +const TranslateId SC_OPCODE_SKEW_ARY[] = +{ + NC_("SC_OPCODE_SKEW", "Returns the skewness of a distribution."), + NC_("SC_OPCODE_SKEW", "Number "), + NC_("SC_OPCODE_SKEW", "Number 1, number 2, ... are numerical arguments portraying a sample of the distribution.") +}; + +// -=*# Resource for function SKEWP #*=- +const TranslateId SC_OPCODE_SKEWP_ARY[] = +{ + NC_("SC_OPCODE_SKEWP", "Returns the skewness of a distribution using the population of a random variable."), + NC_("SC_OPCODE_SKEWP", "Number "), + NC_("SC_OPCODE_SKEWP", "Number 1, number 2, ... are numerical arguments portraying the population.") +}; + +// -=*# Resource for function KURT #*=- +const TranslateId SC_OPCODE_KURT_ARY[] = +{ + NC_("SC_OPCODE_KURT", "Returns the kurtosis of a distribution."), + NC_("SC_OPCODE_KURT", "Number "), + NC_("SC_OPCODE_KURT", "Number 1, number 2, ... are numerical arguments, representing a sample of the distribution.") +}; + +// -=*# Resource for function GEOMEAN #*=- +const TranslateId SC_OPCODE_GEO_MEAN_ARY[] = +{ + NC_("SC_OPCODE_GEO_MEAN", "Returns the geometric mean of a sample."), + NC_("SC_OPCODE_GEO_MEAN", "Number "), + NC_("SC_OPCODE_GEO_MEAN", "Number 1, number 2, ... are numerical arguments which portray a sample.") +}; + +// -=*# Resource for function HARMEAN #*=- +const TranslateId SC_OPCODE_HAR_MEAN_ARY[] = +{ + NC_("SC_OPCODE_HAR_MEAN", "Returns the harmonic mean of a sample."), + NC_("SC_OPCODE_HAR_MEAN", "Number "), + NC_("SC_OPCODE_HAR_MEAN", "Number 1, number 2, ... are numerical arguments which portray a sample.") +}; + +// -=*# Resource for function MODE #*=- +const TranslateId SC_OPCODE_MODAL_VALUE_ARY[] = +{ + NC_("SC_OPCODE_MODAL_VALUE", "Returns the most common value in a sample."), + NC_("SC_OPCODE_MODAL_VALUE", "Number "), + NC_("SC_OPCODE_MODAL_VALUE", "Number 1, number 2, ... are numerical arguments which portray a sample.") +}; + +// -=*# Resource for function MODE.SNGL #*=- +const TranslateId SC_OPCODE_MODAL_VALUE_MS_ARY[] = +{ + NC_("SC_OPCODE_MODAL_VALUE_MS", "Returns the most common value in a sample."), + NC_("SC_OPCODE_MODAL_VALUE_MS", "Number "), + NC_("SC_OPCODE_MODAL_VALUE_MS", "Number 1, number 2, ... are numerical arguments which portray a sample.") +}; + +// -=*# Resource for function MODE.MULT #*=- +const TranslateId SC_OPCODE_MODAL_VALUE_MULTI_ARY[] = +{ + NC_("SC_OPCODE_MODAL_VALUE_MULTI", "Returns the most common value in a sample."), + NC_("SC_OPCODE_MODAL_VALUE_MULTI", "Number "), + NC_("SC_OPCODE_MODAL_VALUE_MULTI", "Number 1, number 2, ... are 1 to 254 numerical arguments which portray a sample.") +}; + +// -=*# Resource for function MEDIAN #*=- +const TranslateId SC_OPCODE_MEDIAN_ARY[] = +{ + NC_("SC_OPCODE_MEDIAN", "Returns the median of a given sample."), + NC_("SC_OPCODE_MEDIAN", "Number "), + NC_("SC_OPCODE_MEDIAN", "Number 1, number 2, ... are numerical arguments which portray a sample.") +}; + +// -=*# Resource for function PERCENTILE #*=- +const TranslateId SC_OPCODE_PERCENTILE_ARY[] = +{ + NC_("SC_OPCODE_PERCENTILE", "Returns the alpha percentile of a sample."), + NC_("SC_OPCODE_PERCENTILE", "Data"), + NC_("SC_OPCODE_PERCENTILE", "The array of the data in the sample."), + NC_("SC_OPCODE_PERCENTILE", "Alpha"), + NC_("SC_OPCODE_PERCENTILE", "The percentile value between 0 and 1, inclusive.") +}; + +// -=*# Resource for function PERCENTILE.EXC #*=- +const TranslateId SC_OPCODE_PERCENTILE_EXC_ARY[] = +{ + NC_("SC_OPCODE_PERCENTILE_EXC", "Returns the alpha percentile of a sample."), + NC_("SC_OPCODE_PERCENTILE_EXC", "Data"), + NC_("SC_OPCODE_PERCENTILE_EXC", "The array of the data in the sample."), + NC_("SC_OPCODE_PERCENTILE_EXC", "Alpha"), + NC_("SC_OPCODE_PERCENTILE_EXC", "The percentile value, range 0...1, exclusive.") +}; + +// -=*# Resource for function PERCENTILE.INC #*=- +const TranslateId SC_OPCODE_PERCENTILE_INC_ARY[] = +{ + NC_("SC_OPCODE_PERCENTILE_INC", "Returns the alpha percentile of a sample."), + NC_("SC_OPCODE_PERCENTILE_INC", "Data"), + NC_("SC_OPCODE_PERCENTILE_INC", "The array of the data in the sample."), + NC_("SC_OPCODE_PERCENTILE_INC", "Alpha"), + NC_("SC_OPCODE_PERCENTILE_INC", "The percentile value, range 0...1, inclusive.") +}; + +// -=*# Resource for function QUARTILE #*=- +const TranslateId SC_OPCODE_QUARTILE_ARY[] = +{ + NC_("SC_OPCODE_QUARTILE", "Returns the quartile of a sample."), + NC_("SC_OPCODE_QUARTILE", "Data"), + NC_("SC_OPCODE_QUARTILE", "The array of the data in the sample."), + NC_("SC_OPCODE_QUARTILE", "Type"), + NC_("SC_OPCODE_QUARTILE", "The type of the quartile (0 = MIN, 1 = 25%, 2 = 50%, 3 = 75%, 4 = MAX).") +}; + +// -=*# Resource for function QUARTILE.EXC #*=- +const TranslateId SC_OPCODE_QUARTILE_EXC_ARY[] = +{ + NC_("SC_OPCODE_QUARTILE_EXC", "Returns the quartile of a sample."), + NC_("SC_OPCODE_QUARTILE_EXC", "Data"), + NC_("SC_OPCODE_QUARTILE_EXC", "The array of the data in the sample."), + NC_("SC_OPCODE_QUARTILE_EXC", "Type"), + NC_("SC_OPCODE_QUARTILE_EXC", "The type of the quartile (1 = 25%, 2 = 50%, 3 = 75%).") +}; + +// -=*# Resource for function QUARTILE.INC #*=- +const TranslateId SC_OPCODE_QUARTILE_INC_ARY[] = +{ + NC_("SC_OPCODE_QUARTILE_INC", "Returns the quartile of a sample."), + NC_("SC_OPCODE_QUARTILE_INC", "Data"), + NC_("SC_OPCODE_QUARTILE_INC", "The array of the data in the sample."), + NC_("SC_OPCODE_QUARTILE_INC", "Type"), + NC_("SC_OPCODE_QUARTILE_INC", "The type of the quartile (0 = MIN, 1 = 25%, 2 = 50%, 3 = 75%, 4 = MAX).") +}; + +// -=*# Resource for function LARGE #*=- +const TranslateId SC_OPCODE_LARGE_ARY[] = +{ + NC_("SC_OPCODE_LARGE", "Returns the k-th largest value of a sample."), + NC_("SC_OPCODE_LARGE", "Data"), + NC_("SC_OPCODE_LARGE", "The array of the data in the sample."), + NC_("SC_OPCODE_LARGE", "Rank c"), + NC_("SC_OPCODE_LARGE", "The ranking of the value.") +}; + +// -=*# Resource for function SMALL #*=- +const TranslateId SC_OPCODE_SMALL_ARY[] = +{ + NC_("SC_OPCODE_SMALL", "Returns the k-th smallest value of a sample."), + NC_("SC_OPCODE_SMALL", "Data"), + NC_("SC_OPCODE_SMALL", "The array of the data in the sample."), + NC_("SC_OPCODE_SMALL", "Rank c"), + NC_("SC_OPCODE_SMALL", "The ranking of the value.") +}; + +// -=*# Resource for function PERCENTRANK #*=- +const TranslateId SC_OPCODE_PERCENT_RANK_ARY[] = +{ + NC_("SC_OPCODE_PERCENT_RANK", "Returns the percentage rank of a value in a sample."), + NC_("SC_OPCODE_PERCENT_RANK", "Data"), + NC_("SC_OPCODE_PERCENT_RANK", "The array of the data in the sample."), + NC_("SC_OPCODE_PERCENT_RANK", "Value"), + NC_("SC_OPCODE_PERCENT_RANK", "The value for which percentage ranking is to be determined."), + NC_("SC_OPCODE_PERCENT_RANK", "Significance"), + NC_("SC_OPCODE_PERCENT_RANK", "The number of significant digits for the returned percentage: if omitted, a value of 3 is used.") +}; + +// -=*# Resource for function PERCENTRANK.EXC #*=- +const TranslateId SC_OPCODE_PERCENT_RANK_EXC_ARY[] = +{ + NC_("SC_OPCODE_PERCENT_RANK_EXC", "Returns the percentage rank (0..1, exclusive) of a value in a sample."), + NC_("SC_OPCODE_PERCENT_RANK_EXC", "Data"), + NC_("SC_OPCODE_PERCENT_RANK_EXC", "The array of the data in the sample."), + NC_("SC_OPCODE_PERCENT_RANK_EXC", "Value"), + NC_("SC_OPCODE_PERCENT_RANK_EXC", "The value for which percentage ranking is to be determined."), + NC_("SC_OPCODE_PERCENT_RANK_EXC", "Significance"), + NC_("SC_OPCODE_PERCENT_RANK_EXC", "The number of significant digits for the returned percentage: if omitted, a value of 3 is used.") +}; + +// -=*# Resource for function PERCENTRANK.INC #*=- +const TranslateId SC_OPCODE_PERCENT_RANK_INC_ARY[] = +{ + NC_("SC_OPCODE_PERCENT_RANK_INC", "Returns the percentage rank (0..1, inclusive) of a value in a sample."), + NC_("SC_OPCODE_PERCENT_RANK_INC", "Data"), + NC_("SC_OPCODE_PERCENT_RANK_INC", "The array of the data in the sample."), + NC_("SC_OPCODE_PERCENT_RANK_INC", "Value"), + NC_("SC_OPCODE_PERCENT_RANK_INC", "The value for which percentage ranking is to be determined."), + NC_("SC_OPCODE_PERCENT_RANK_INC", "Significance"), + NC_("SC_OPCODE_PERCENT_RANK_INC", "The number of significant digits for the returned percentage: if omitted, a value of 3 is used.") +}; + +// -=*# Resource for function RANK #*=- +const TranslateId SC_OPCODE_RANK_ARY[] = +{ + NC_("SC_OPCODE_RANK", "Returns the ranking of a value in a sample."), + NC_("SC_OPCODE_RANK", "Value"), + NC_("SC_OPCODE_RANK", "The value for which the rank is to be determined."), + NC_("SC_OPCODE_RANK", "Data"), + NC_("SC_OPCODE_RANK", "The array of the data in the sample."), + NC_("SC_OPCODE_RANK", "Type"), + NC_("SC_OPCODE_RANK", "Sequence order: 0 or omitted means descending, any other value than 0 means ascending.") +}; + +// -=*# Resource for function RANK.EQ #*=- +const TranslateId SC_OPCODE_RANK_EQ_ARY[] = +{ + NC_("SC_OPCODE_RANK_EQ", "Returns the ranking of a value in a sample; if more than one value has the same rank, the top rank of that set of values is returned."), + NC_("SC_OPCODE_RANK_EQ", "Value"), + NC_("SC_OPCODE_RANK_EQ", "The value for which the rank is to be determined."), + NC_("SC_OPCODE_RANK_EQ", "Data"), + NC_("SC_OPCODE_RANK_EQ", "The array of the data in the sample."), + NC_("SC_OPCODE_RANK_EQ", "Type"), + NC_("SC_OPCODE_RANK_EQ", "Sequence order: 0 or omitted means descending, any other value than 0 means ascending.") +}; + +// -=*# Resource for function RANK.AVG #*=- +const TranslateId SC_OPCODE_RANK_AVG_ARY[] = +{ + NC_("SC_OPCODE_RANK_AVG", "Returns the ranking of a value in a sample; if more than one value has the same rank, the average rank is returned."), + NC_("SC_OPCODE_RANK_AVG", "Value"), + NC_("SC_OPCODE_RANK_AVG", "The value for which the rank is to be determined."), + NC_("SC_OPCODE_RANK_AVG", "Data"), + NC_("SC_OPCODE_RANK_AVG", "The array of the data in the sample."), + NC_("SC_OPCODE_RANK_AVG", "Type"), + NC_("SC_OPCODE_RANK_AVG", "Sequence order: 0 or omitted means descending, any other value than 0 means ascending.") +}; + +// -=*# Resource for function TRIMMEAN #*=- +const TranslateId SC_OPCODE_TRIM_MEAN_ARY[] = +{ + NC_("SC_OPCODE_TRIM_MEAN", "Returns the mean of a sample without including the marginal values."), + NC_("SC_OPCODE_TRIM_MEAN", "Data"), + NC_("SC_OPCODE_TRIM_MEAN", "The array of the data in the sample."), + NC_("SC_OPCODE_TRIM_MEAN", "Alpha"), + NC_("SC_OPCODE_TRIM_MEAN", "The percentage of marginal data that is not to be taken into account.") +}; + +// -=*# Resource for function PROB #*=- +const TranslateId SC_OPCODE_PROB_ARY[] = +{ + NC_("SC_OPCODE_PROB", "Returns the discrete probability of an interval."), + NC_("SC_OPCODE_PROB", "Data"), + NC_("SC_OPCODE_PROB", "The sample data array."), + NC_("SC_OPCODE_PROB", "Probability"), + NC_("SC_OPCODE_PROB", "The array of the associated probabilities."), + NC_("SC_OPCODE_PROB", "Start"), + NC_("SC_OPCODE_PROB", "The start of the value interval whose probabilities is to be totalled."), + NC_("SC_OPCODE_PROB", "End"), + NC_("SC_OPCODE_PROB", "The end of the value interval where the probabilities are to be totalled.") +}; + +// -=*# Resource for function B #*=- +const TranslateId SC_OPCODE_B_ARY[] = +{ + NC_("SC_OPCODE_B", "Returns the probability of a trial result using binomial distribution."), + NC_("SC_OPCODE_B", "Trials"), + NC_("SC_OPCODE_B", "The number of trials."), + NC_("SC_OPCODE_B", "SP"), + NC_("SC_OPCODE_B", "The individual probability of a trial result."), + NC_("SC_OPCODE_B", "T 1"), + NC_("SC_OPCODE_B", "Lower limit for the number of trials."), + NC_("SC_OPCODE_B", "T 2"), + NC_("SC_OPCODE_B", "Upper limit for the number of trials.") +}; + +// -=*# Resource for function PHI #*=- +const TranslateId SC_OPCODE_PHI_ARY[] = +{ + NC_("SC_OPCODE_PHI", "Values of the distribution function for a standard normal distribution."), + NC_("SC_OPCODE_PHI", "Number"), + NC_("SC_OPCODE_PHI", "The value for which the standard normal distribution is to be calculated.") +}; + +// -=*# Resource for function GAUSS #*=- +const TranslateId SC_OPCODE_GAUSS_ARY[] = +{ + NC_("SC_OPCODE_GAUSS", "Returns the integral values of the standard normal cumulative distribution."), + NC_("SC_OPCODE_GAUSS", "Number"), + NC_("SC_OPCODE_GAUSS", "The value for which the integral value of the standard normal distribution is to be calculated.") +}; + +// -=*# Resource for function FISHER #*=- +const TranslateId SC_OPCODE_FISHER_ARY[] = +{ + NC_("SC_OPCODE_FISHER", "Returns the Fisher transformation."), + NC_("SC_OPCODE_FISHER", "Number"), + NC_("SC_OPCODE_FISHER", "The value to be transformed (-1 < VALUE < 1).") +}; + +// -=*# Resource for function FISHERINV #*=- +const TranslateId SC_OPCODE_FISHER_INV_ARY[] = +{ + NC_("SC_OPCODE_FISHER_INV", "Returns the inverse of the Fisher transformation."), + NC_("SC_OPCODE_FISHER_INV", "Number"), + NC_("SC_OPCODE_FISHER_INV", "The value that is to be transformed back.") +}; + +// -=*# Resource for function BINOMDIST #*=- +const TranslateId SC_OPCODE_BINOM_DIST_ARY[] = +{ + NC_("SC_OPCODE_BINOM_DIST", "Values of the binomial distribution."), + NC_("SC_OPCODE_BINOM_DIST", "X"), + NC_("SC_OPCODE_BINOM_DIST", "The number of successes in a series of trials."), + NC_("SC_OPCODE_BINOM_DIST", "Trials"), + NC_("SC_OPCODE_BINOM_DIST", "The total number of trials."), + NC_("SC_OPCODE_BINOM_DIST", "SP"), + NC_("SC_OPCODE_BINOM_DIST", "The success probability of a trial."), + NC_("SC_OPCODE_BINOM_DIST", "C"), + NC_("SC_OPCODE_BINOM_DIST", "Cumulated. C=0 calculates the individual probability, C=1 the cumulated probability.") +}; + +// -=*# Resource for function BINOM.DIST #*=- +const TranslateId SC_OPCODE_BINOM_DIST_MS_ARY[] = +{ + NC_("SC_OPCODE_BINOM_DIST_MS", "Values of the binomial distribution."), + NC_("SC_OPCODE_BINOM_DIST_MS", "X"), + NC_("SC_OPCODE_BINOM_DIST_MS", "The number of successes in a series of trials."), + NC_("SC_OPCODE_BINOM_DIST_MS", "Trials"), + NC_("SC_OPCODE_BINOM_DIST_MS", "The total number of trials."), + NC_("SC_OPCODE_BINOM_DIST_MS", "SP"), + NC_("SC_OPCODE_BINOM_DIST_MS", "The success probability of a trial."), + NC_("SC_OPCODE_BINOM_DIST_MS", "C"), + NC_("SC_OPCODE_BINOM_DIST_MS", "Cumulated. C=0 calculates the individual probability, C=1 the cumulated probability.") +}; + +// -=*# Resource for function NEGBINOMDIST #*=- +const TranslateId SC_OPCODE_NEG_BINOM_VERT_ARY[] = +{ + NC_("SC_OPCODE_NEG_BINOM_VERT", "Values of the negative binomial distribution."), + NC_("SC_OPCODE_NEG_BINOM_VERT", "X"), + NC_("SC_OPCODE_NEG_BINOM_VERT", "The number of failures in the trial range."), + NC_("SC_OPCODE_NEG_BINOM_VERT", "R"), + NC_("SC_OPCODE_NEG_BINOM_VERT", "The number of successes in the trial sequence."), + NC_("SC_OPCODE_NEG_BINOM_VERT", "SP"), + NC_("SC_OPCODE_NEG_BINOM_VERT", "The success probability of a trial.") +}; + +// -=*# Resource for function NEGBINOM.DIST #*=- +const TranslateId SC_OPCODE_NEG_BINOM_DIST_MS_ARY[] = +{ + NC_("SC_OPCODE_NEG_BINOM_DIST_MS", "Values of the negative binomial distribution."), + NC_("SC_OPCODE_NEG_BINOM_DIST_MS", "X"), + NC_("SC_OPCODE_NEG_BINOM_DIST_MS", "The number of failures in the trial range."), + NC_("SC_OPCODE_NEG_BINOM_DIST_MS", "R"), + NC_("SC_OPCODE_NEG_BINOM_DIST_MS", "The number of successes in the trial sequence."), + NC_("SC_OPCODE_NEG_BINOM_DIST_MS", "SP"), + NC_("SC_OPCODE_NEG_BINOM_DIST_MS", "The success probability of a trial."), + NC_("SC_OPCODE_NEG_BINOM_DIST_MS", "Cumulative"), + NC_("SC_OPCODE_NEG_BINOM_DIST_MS", "0 or FALSE calculates the probability density function. Any other value or TRUE calculates the cumulative distribution function.") +}; + +// -=*# Resource for function CRITBINOM #*=- +const TranslateId SC_OPCODE_CRIT_BINOM_ARY[] = +{ + NC_("SC_OPCODE_CRIT_BINOM", "Returns the smallest value for which the cumulative binomial distribution is greater than or equal to a criterion value."), + NC_("SC_OPCODE_CRIT_BINOM", "Trials"), + NC_("SC_OPCODE_CRIT_BINOM", "The total number of trials."), + NC_("SC_OPCODE_CRIT_BINOM", "SP"), + NC_("SC_OPCODE_CRIT_BINOM", "The success probability of a trial."), + NC_("SC_OPCODE_CRIT_BINOM", "Alpha"), + NC_("SC_OPCODE_CRIT_BINOM", "The border probability that is attained or exceeded.") +}; + +// -=*# Resource for function BINOM.INV #*=- +const TranslateId SC_OPCODE_BINOM_INV_ARY[] = +{ + NC_("SC_OPCODE_BINOM_INV", "Returns the smallest value for which the cumulative binomial distribution is greater than or equal to a criterion value."), + NC_("SC_OPCODE_BINOM_INV", "Trials"), + NC_("SC_OPCODE_BINOM_INV", "The total number of trials."), + NC_("SC_OPCODE_BINOM_INV", "SP"), + NC_("SC_OPCODE_BINOM_INV", "The success probability of a trial."), + NC_("SC_OPCODE_BINOM_INV", "Alpha"), + NC_("SC_OPCODE_BINOM_INV", "The border probability that is attained or exceeded.") +}; + +// -=*# Resource for function POISSON #*=- +const TranslateId SC_OPCODE_POISSON_DIST_ARY[] = +{ + NC_("SC_OPCODE_POISSON_DIST", "Returns the Poisson distribution."), + NC_("SC_OPCODE_POISSON_DIST", "Number"), + NC_("SC_OPCODE_POISSON_DIST", "The value for which the Poisson distribution is to be calculated."), + NC_("SC_OPCODE_POISSON_DIST", "Mean"), + NC_("SC_OPCODE_POISSON_DIST", "Mean. The mean value of the Poisson distribution."), + NC_("SC_OPCODE_POISSON_DIST", "Cumulative"), + NC_("SC_OPCODE_POISSON_DIST", "0 or FALSE calculates the probability density function. Any other value or TRUE or omitted calculates the cumulative distribution function.") +}; + +// -=*# Resource for function POISSON.DIST #*=- +const TranslateId SC_OPCODE_POISSON_DIST_MS_ARY[] = +{ + NC_("SC_OPCODE_POISSON_DIST_MS", "Returns the Poisson distribution."), + NC_("SC_OPCODE_POISSON_DIST_MS", "Number"), + NC_("SC_OPCODE_POISSON_DIST_MS", "The value for which the Poisson distribution is to be calculated."), + NC_("SC_OPCODE_POISSON_DIST_MS", "Mean"), + NC_("SC_OPCODE_POISSON_DIST_MS", "Mean. The mean value of the Poisson distribution."), + NC_("SC_OPCODE_POISSON_DIST_MS", "Cumulative"), + NC_("SC_OPCODE_POISSON_DIST_MS", "0 or FALSE calculates the probability density function. Any other value or TRUE or omitted calculates the cumulative distribution function.") +}; + +// -=*# Resource for function NORMDIST #*=- +const TranslateId SC_OPCODE_NORM_DIST_ARY[] = +{ + NC_("SC_OPCODE_NORM_DIST", "Values of the normal distribution."), + NC_("SC_OPCODE_NORM_DIST", "Number"), + NC_("SC_OPCODE_NORM_DIST", "The value for which the normal distribution is to be calculated."), + NC_("SC_OPCODE_NORM_DIST", "Mean"), + NC_("SC_OPCODE_NORM_DIST", "The mean value. The mean value of the normal distribution."), + NC_("SC_OPCODE_NORM_DIST", "STDEV"), + NC_("SC_OPCODE_NORM_DIST", "Standard deviation. The standard deviation of the normal distribution."), + NC_("SC_OPCODE_NORM_DIST", "C"), + NC_("SC_OPCODE_NORM_DIST", "0 or FALSE calculates the probability density function. Any other value or TRUE or omitted calculates the cumulative distribution function.") +}; + +// -=*# Resource for function NORM.DIST #*=- +const TranslateId SC_OPCODE_NORM_DIST_MS_ARY[] = +{ + NC_("SC_OPCODE_NORM_DIST_MS", "Values of the normal distribution."), + NC_("SC_OPCODE_NORM_DIST_MS", "Number"), + NC_("SC_OPCODE_NORM_DIST_MS", "The value for which the normal distribution is to be calculated."), + NC_("SC_OPCODE_NORM_DIST_MS", "Mean"), + NC_("SC_OPCODE_NORM_DIST_MS", "The mean value. The mean value of the normal distribution."), + NC_("SC_OPCODE_NORM_DIST_MS", "STDEV"), + NC_("SC_OPCODE_NORM_DIST_MS", "Standard deviation. The standard deviation of the normal distribution."), + NC_("SC_OPCODE_NORM_DIST_MS", "C"), + NC_("SC_OPCODE_NORM_DIST_MS", "0 or FALSE calculates the probability density function. Any other value or TRUE calculates the cumulative distribution function.") +}; + +// -=*# Resource for function NORMINV #*=- +const TranslateId SC_OPCODE_NORM_INV_ARY[] = +{ + NC_("SC_OPCODE_NORM_INV", "Values of the inverse normal distribution."), + NC_("SC_OPCODE_NORM_INV", "Number"), + NC_("SC_OPCODE_NORM_INV", "The probability value for which the inverse normal distribution is to be calculated."), + NC_("SC_OPCODE_NORM_INV", "Mean"), + NC_("SC_OPCODE_NORM_INV", "The mean value. The mean value of the normal distribution."), + NC_("SC_OPCODE_NORM_INV", "STDEV"), + NC_("SC_OPCODE_NORM_INV", "Standard deviation. The standard deviation of the normal distribution.") +}; + +// -=*# Resource for function NORM.INV #*=- +const TranslateId SC_OPCODE_NORM_INV_MS_ARY[] = +{ + NC_("SC_OPCODE_NORM_INV_MS", "Values of the inverse normal distribution."), + NC_("SC_OPCODE_NORM_INV_MS", "Number"), + NC_("SC_OPCODE_NORM_INV_MS", "The probability value for which the inverse normal distribution is to be calculated."), + NC_("SC_OPCODE_NORM_INV_MS", "Mean"), + NC_("SC_OPCODE_NORM_INV_MS", "The mean value. The mean value of the normal distribution."), + NC_("SC_OPCODE_NORM_INV_MS", "STDEV"), + NC_("SC_OPCODE_NORM_INV_MS", "Standard deviation. The standard deviation of the normal distribution.") +}; + +// -=*# Resource for function NORMSDIST #*=- +const TranslateId SC_OPCODE_STD_NORM_DIST_ARY[] = +{ + NC_("SC_OPCODE_STD_NORM_DIST", "The values of the standard normal cumulative distribution."), + NC_("SC_OPCODE_STD_NORM_DIST", "Number"), + NC_("SC_OPCODE_STD_NORM_DIST", "The value for which the standard normal distribution is to be calculated.") +}; + +// -=*# Resource for function NORM.S.DIST #*=- +const TranslateId SC_OPCODE_STD_NORM_DIST_MS_ARY[] = +{ + NC_("SC_OPCODE_STD_NORM_DIST_MS", "The values of the standard normal distribution."), + NC_("SC_OPCODE_STD_NORM_DIST_MS", "Number"), + NC_("SC_OPCODE_STD_NORM_DIST_MS", "The value for which the standard normal distribution is to be calculated."), + NC_("SC_OPCODE_STD_NORM_DIST_MS", "Cumulative"), + NC_("SC_OPCODE_STD_NORM_DIST_MS", "0 or FALSE calculates the probability density function. Any other value or TRUE calculates the cumulative distribution function.") +}; + +// -=*# Resource for function NORMSINV #*=- +const TranslateId SC_OPCODE_S_NORM_INV_ARY[] = +{ + NC_("SC_OPCODE_S_NORM_INV", "Values of the inverse standard normal distribution."), + NC_("SC_OPCODE_S_NORM_INV", "Number"), + NC_("SC_OPCODE_S_NORM_INV", "The probability value for which the inverse standard normal distribution is to be calculated.") +}; + +// -=*# Resource for function NORM.S.INV #*=- +const TranslateId SC_OPCODE_S_NORM_INV_MS_ARY[] = +{ + NC_("SC_OPCODE_S_NORM_INV_MS", "Values of the inverse standard normal distribution."), + NC_("SC_OPCODE_S_NORM_INV_MS", "Number"), + NC_("SC_OPCODE_S_NORM_INV_MS", "The probability value for which the inverse standard normal distribution is to be calculated.") +}; + +// -=*# Resource for function LOGNORMDIST #*=- +const TranslateId SC_OPCODE_LOG_NORM_DIST_ARY[] = +{ + NC_("SC_OPCODE_LOG_NORM_DIST", "Values of the log normal distribution."), + NC_("SC_OPCODE_LOG_NORM_DIST", "Number"), + NC_("SC_OPCODE_LOG_NORM_DIST", "The value for which the log normal distribution is to be calculated."), + NC_("SC_OPCODE_LOG_NORM_DIST", "Mean"), + NC_("SC_OPCODE_LOG_NORM_DIST", "The mean value of the log normal distribution. It is set to 0 if omitted."), + NC_("SC_OPCODE_LOG_NORM_DIST", "STDEV"), + NC_("SC_OPCODE_LOG_NORM_DIST", "The standard deviation of the log normal distribution. It is set to 1 if omitted."), + NC_("SC_OPCODE_LOG_NORM_DIST", "Cumulative"), + NC_("SC_OPCODE_LOG_NORM_DIST", "0 or FALSE calculates the probability density function. Any other value or TRUE or omitted calculates the cumulative distribution function.") +}; + +// -=*# Resource for function LOGNORM.DIST #*=- +const TranslateId SC_OPCODE_LOG_NORM_DIST_MS_ARY[] = +{ + NC_("SC_OPCODE_LOG_NORM_DIST_MS", "Values of the log normal distribution."), + NC_("SC_OPCODE_LOG_NORM_DIST_MS", "Number"), + NC_("SC_OPCODE_LOG_NORM_DIST_MS", "The value for which the log normal distribution is to be calculated."), + NC_("SC_OPCODE_LOG_NORM_DIST_MS", "Mean"), + NC_("SC_OPCODE_LOG_NORM_DIST_MS", "The mean value of the log normal distribution."), + NC_("SC_OPCODE_LOG_NORM_DIST_MS", "STDEV"), + NC_("SC_OPCODE_LOG_NORM_DIST_MS", "The standard deviation of the log normal distribution."), + NC_("SC_OPCODE_LOG_NORM_DIST_MS", "Cumulative"), + NC_("SC_OPCODE_LOG_NORM_DIST_MS", "0 or FALSE calculates the probability density function. Any other value or TRUE calculates the cumulative distribution function.") +}; + +// -=*# Resource for function LOGINV #*=- +const TranslateId SC_OPCODE_LOG_INV_ARY[] = +{ + NC_("SC_OPCODE_LOG_INV", "Values of the inverse of the lognormal distribution."), + NC_("SC_OPCODE_LOG_INV", "Number"), + NC_("SC_OPCODE_LOG_INV", "The probability value for which the inverse log normal distribution is to be calculated."), + NC_("SC_OPCODE_LOG_INV", "Mean"), + NC_("SC_OPCODE_LOG_INV", "Mean value. The mean value of the log normal distribution."), + NC_("SC_OPCODE_LOG_INV", "STDEV"), + NC_("SC_OPCODE_LOG_INV", "Standard deviation. The standard deviation of the log normal distribution.") +}; + +// -=*# Resource for function LOGNORM.INV #*=- +const TranslateId SC_OPCODE_LOG_INV_MS_ARY[] = +{ + NC_("SC_OPCODE_LOG_INV_MS", "Values of the inverse of the lognormal distribution."), + NC_("SC_OPCODE_LOG_INV_MS", "Number"), + NC_("SC_OPCODE_LOG_INV_MS", "The probability value for which the inverse log normal distribution is to be calculated."), + NC_("SC_OPCODE_LOG_INV_MS", "Mean"), + NC_("SC_OPCODE_LOG_INV_MS", "Mean value. The mean value of the log normal distribution."), + NC_("SC_OPCODE_LOG_INV_MS", "STDEV"), + NC_("SC_OPCODE_LOG_INV_MS", "Standard deviation. The standard deviation of the log normal distribution.") +}; + +// -=*# Resource for function EXPONDIST #*=- +const TranslateId SC_OPCODE_EXP_DIST_ARY[] = +{ + NC_("SC_OPCODE_EXP_DIST", "Values of the exponential distribution."), + NC_("SC_OPCODE_EXP_DIST", "Number"), + NC_("SC_OPCODE_EXP_DIST", "The value to which the exponential distribution is to be calculated."), + NC_("SC_OPCODE_EXP_DIST", "Lambda"), + NC_("SC_OPCODE_EXP_DIST", "The parameters of the exponential distribution."), + NC_("SC_OPCODE_EXP_DIST", "C"), + NC_("SC_OPCODE_EXP_DIST", "Cumulated. C=0 calculates the density function, C=1 the distribution.") +}; + +// -=*# Resource for function EXPON.DIST #*=- +const TranslateId SC_OPCODE_EXP_DIST_MS_ARY[] = +{ + NC_("SC_OPCODE_EXP_DIST_MS", "Values of the exponential distribution."), + NC_("SC_OPCODE_EXP_DIST_MS", "Number"), + NC_("SC_OPCODE_EXP_DIST_MS", "The value to which the exponential distribution is to be calculated."), + NC_("SC_OPCODE_EXP_DIST_MS", "Lambda"), + NC_("SC_OPCODE_EXP_DIST_MS", "The parameters of the exponential distribution."), + NC_("SC_OPCODE_EXP_DIST_MS", "C"), + NC_("SC_OPCODE_EXP_DIST_MS", "Cumulated. C=0 calculates the density function, C=1 the distribution.") +}; + +// -=*# Resource for function GAMMADIST #*=- +const TranslateId SC_OPCODE_GAMMA_DIST_ARY[] = +{ + NC_("SC_OPCODE_GAMMA_DIST", "Returns the value of the probability density function or the cumulative distribution function for the Gamma distribution."), + NC_("SC_OPCODE_GAMMA_DIST", "Number"), + NC_("SC_OPCODE_GAMMA_DIST", "The value for which the gamma distribution is to be calculated."), + NC_("SC_OPCODE_GAMMA_DIST", "Alpha"), + NC_("SC_OPCODE_GAMMA_DIST", "The Alpha parameter of the Gamma distribution."), + NC_("SC_OPCODE_GAMMA_DIST", "Beta"), + NC_("SC_OPCODE_GAMMA_DIST", "The Beta parameter of the Gamma distribution."), + NC_("SC_OPCODE_GAMMA_DIST", "Cumulative"), + NC_("SC_OPCODE_GAMMA_DIST", "0 or FALSE calculates the probability density function. Any other value or TRUE or omitted calculates the cumulative distribution function.") +}; + +// -=*# Resource for function GAMMA.DIST #*=- +const TranslateId SC_OPCODE_GAMMA_DIST_MS_ARY[] = +{ + NC_("SC_OPCODE_GAMMA_DIST_MS", "Returns the value of the probability density function or the cumulative distribution function for the Gamma distribution."), + NC_("SC_OPCODE_GAMMA_DIST_MS", "Number"), + NC_("SC_OPCODE_GAMMA_DIST_MS", "The value for which the gamma distribution is to be calculated."), + NC_("SC_OPCODE_GAMMA_DIST_MS", "Alpha"), + NC_("SC_OPCODE_GAMMA_DIST_MS", "The Alpha parameter of the Gamma distribution."), + NC_("SC_OPCODE_GAMMA_DIST_MS", "Beta"), + NC_("SC_OPCODE_GAMMA_DIST_MS", "The Beta parameter of the Gamma distribution."), + NC_("SC_OPCODE_GAMMA_DIST_MS", "Cumulative"), + NC_("SC_OPCODE_GAMMA_DIST_MS", "0 or FALSE calculates the probability density function. Any other value or TRUE calculates the cumulative distribution function.") +}; + +// -=*# Resource for function GAMMAINV #*=- +const TranslateId SC_OPCODE_GAMMA_INV_ARY[] = +{ + NC_("SC_OPCODE_GAMMA_INV", "Values of the inverse gamma distribution."), + NC_("SC_OPCODE_GAMMA_INV", "Number"), + NC_("SC_OPCODE_GAMMA_INV", "The probability value for which the inverse gamma distribution is to be calculated."), + NC_("SC_OPCODE_GAMMA_INV", "Alpha"), + NC_("SC_OPCODE_GAMMA_INV", "The Alpha (shape) parameter of the Gamma distribution."), + NC_("SC_OPCODE_GAMMA_INV", "Beta"), + NC_("SC_OPCODE_GAMMA_INV", "The Beta (scale) parameter of the Gamma distribution.") +}; + +// -=*# Resource for function GAMMA.INV #*=- +const TranslateId SC_OPCODE_GAMMA_INV_MS_ARY[] = +{ + NC_("SC_OPCODE_GAMMA_INV_MS", "Values of the inverse gamma distribution."), + NC_("SC_OPCODE_GAMMA_INV_MS", "Number"), + NC_("SC_OPCODE_GAMMA_INV_MS", "The probability value for which the inverse gamma distribution is to be calculated."), + NC_("SC_OPCODE_GAMMA_INV_MS", "Alpha"), + NC_("SC_OPCODE_GAMMA_INV_MS", "The Alpha (shape) parameter of the Gamma distribution."), + NC_("SC_OPCODE_GAMMA_INV_MS", "Beta"), + NC_("SC_OPCODE_GAMMA_INV_MS", "The Beta (scale) parameter of the Gamma distribution.") +}; + +// -=*# Resource for function GAMMALN #*=- +const TranslateId SC_OPCODE_GAMMA_LN_ARY[] = +{ + NC_("SC_OPCODE_GAMMA_LN", "Returns the natural logarithm of the gamma function."), + NC_("SC_OPCODE_GAMMA_LN", "Number"), + NC_("SC_OPCODE_GAMMA_LN", "The value for which the natural logarithm of the gamma function is to be calculated.") +}; + +// -=*# Resource for function GAMMALN.PRECISE #*=- +const TranslateId SC_OPCODE_GAMMA_LN_MS_ARY[] = +{ + NC_("SC_OPCODE_GAMMA_LN_MS", "Returns the natural logarithm of the gamma function."), + NC_("SC_OPCODE_GAMMA_LN_MS", "Number"), + NC_("SC_OPCODE_GAMMA_LN_MS", "The value for which the natural logarithm of the gamma function is to be calculated.") +}; + + +// -=*# Resource for function GAMMA #*=- +const TranslateId SC_OPCODE_GAMMA_ARY[] = +{ + NC_("SC_OPCODE_GAMMA", "Returns the value of the Gamma function."), + NC_("SC_OPCODE_GAMMA", "Number"), + NC_("SC_OPCODE_GAMMA", "The value for which the Gamma function is to be calculated.") +}; + + +// -=*# Resource for function BETADIST #*=- +const TranslateId SC_OPCODE_BETA_DIST_ARY[] = +{ + NC_("SC_OPCODE_BETA_DIST", "Values of the beta distribution."), + NC_("SC_OPCODE_BETA_DIST", "Number"), + NC_("SC_OPCODE_BETA_DIST", "The value for which the beta distribution is to be calculated."), + NC_("SC_OPCODE_BETA_DIST", "Alpha"), + NC_("SC_OPCODE_BETA_DIST", "The Alpha parameter of the Beta distribution."), + NC_("SC_OPCODE_BETA_DIST", "Beta"), + NC_("SC_OPCODE_BETA_DIST", "The Beta parameter of the Beta distribution."), + NC_("SC_OPCODE_BETA_DIST", "Start"), + NC_("SC_OPCODE_BETA_DIST", "The starting value for the value interval of the distribution."), + NC_("SC_OPCODE_BETA_DIST", "End"), + NC_("SC_OPCODE_BETA_DIST", "The final value for the value interval of the distribution."), + NC_("SC_OPCODE_BETA_DIST", "Cumulative"), + NC_("SC_OPCODE_BETA_DIST", "0 or FALSE for probability density function, any other value or TRUE or omitted for cumulative distribution function.") +}; + +// -=*# Resource for function BETAINV #*=- +const TranslateId SC_OPCODE_BETA_INV_ARY[] = +{ + NC_("SC_OPCODE_BETA_INV", "Values of the inverse beta distribution."), + NC_("SC_OPCODE_BETA_INV", "Number"), + NC_("SC_OPCODE_BETA_INV", "The probability value for which the inverse beta distribution is to be calculated."), + NC_("SC_OPCODE_BETA_INV", "Alpha"), + NC_("SC_OPCODE_BETA_INV", "The Alpha parameter of the Beta distribution."), + NC_("SC_OPCODE_BETA_INV", "Beta"), + NC_("SC_OPCODE_BETA_INV", "The Beta parameter of the Beta distribution."), + NC_("SC_OPCODE_BETA_INV", "Start"), + NC_("SC_OPCODE_BETA_INV", "The starting value for the value interval of the distribution."), + NC_("SC_OPCODE_BETA_INV", "End"), + NC_("SC_OPCODE_BETA_INV", "The final value for the value interval of the distribution.") +}; + +// -=*# Resource for function BETA.DIST #*=- +const TranslateId SC_OPCODE_BETA_DIST_MS_ARY[] = +{ + NC_("SC_OPCODE_BETA_DIST_MS", "Values of the beta distribution."), + NC_("SC_OPCODE_BETA_DIST_MS", "Number"), + NC_("SC_OPCODE_BETA_DIST_MS", "The value for which the beta distribution is to be calculated."), + NC_("SC_OPCODE_BETA_DIST_MS", "Alpha"), + NC_("SC_OPCODE_BETA_DIST_MS", "The Alpha parameter of the Beta distribution."), + NC_("SC_OPCODE_BETA_DIST_MS", "Beta"), + NC_("SC_OPCODE_BETA_DIST_MS", "The Beta parameter of the Beta distribution."), + NC_("SC_OPCODE_BETA_DIST_MS", "Cumulative"), + NC_("SC_OPCODE_BETA_DIST_MS", "0 or FALSE for probability density function, any other value or TRUE or omitted for cumulative distribution function."), + NC_("SC_OPCODE_BETA_DIST_MS", "Start"), + NC_("SC_OPCODE_BETA_DIST_MS", "The starting value for the value interval of the distribution."), + NC_("SC_OPCODE_BETA_DIST_MS", "End"), + NC_("SC_OPCODE_BETA_DIST_MS", "The final value for the value interval of the distribution.") +}; + +// -=*# Resource for function BETA.INV #*=- +const TranslateId SC_OPCODE_BETA_INV_MS_ARY[] = +{ + NC_("SC_OPCODE_BETA_INV_MS", "Values of the inverse beta distribution."), + NC_("SC_OPCODE_BETA_INV_MS", "Number"), + NC_("SC_OPCODE_BETA_INV_MS", "The probability value for which the inverse beta distribution is to be calculated."), + NC_("SC_OPCODE_BETA_INV_MS", "Alpha"), + NC_("SC_OPCODE_BETA_INV_MS", "The Alpha parameter of the Beta distribution."), + NC_("SC_OPCODE_BETA_INV_MS", "Beta"), + NC_("SC_OPCODE_BETA_INV_MS", "The Beta parameter of the Beta distribution."), + NC_("SC_OPCODE_BETA_INV_MS", "Start"), + NC_("SC_OPCODE_BETA_INV_MS", "The starting value for the value interval of the distribution."), + NC_("SC_OPCODE_BETA_INV_MS", "End"), + NC_("SC_OPCODE_BETA_INV_MS", "The final value for the value interval of the distribution.") +}; + +// -=*# Resource for function WEIBULL #*=- +const TranslateId SC_OPCODE_WEIBULL_ARY[] = +{ + NC_("SC_OPCODE_WEIBULL", "Returns the values of the Weibull distribution."), + NC_("SC_OPCODE_WEIBULL", "Number"), + NC_("SC_OPCODE_WEIBULL", "The value for which the Weibull distribution is to be calculated."), + NC_("SC_OPCODE_WEIBULL", "Alpha"), + NC_("SC_OPCODE_WEIBULL", "The Alpha parameter of the Weibull distribution."), + NC_("SC_OPCODE_WEIBULL", "Beta"), + NC_("SC_OPCODE_WEIBULL", "The Beta parameter of the Weibull distribution."), + NC_("SC_OPCODE_WEIBULL", "C"), + NC_("SC_OPCODE_WEIBULL", "Cumulated. C=0 calculates the density function, C=1 the distribution.") +}; + +// -=*# Resource for function WEIBULL.DIST #*=- +const TranslateId SC_OPCODE_WEIBULL_MS_ARY[] = +{ + NC_("SC_OPCODE_WEIBULL_MS", "Returns the values of the Weibull distribution."), + NC_("SC_OPCODE_WEIBULL_MS", "Number"), + NC_("SC_OPCODE_WEIBULL_MS", "The value for which the Weibull distribution is to be calculated."), + NC_("SC_OPCODE_WEIBULL_MS", "Alpha"), + NC_("SC_OPCODE_WEIBULL_MS", "The Alpha parameter of the Weibull distribution."), + NC_("SC_OPCODE_WEIBULL_MS", "Beta"), + NC_("SC_OPCODE_WEIBULL_MS", "The Beta parameter of the Weibull distribution."), + NC_("SC_OPCODE_WEIBULL_MS", "C"), + NC_("SC_OPCODE_WEIBULL_MS", "Cumulated. C=0 calculates the density function, C=1 the distribution.") +}; + +// -=*# Resource for function HYPGEOMDIST #*=- +const TranslateId SC_OPCODE_HYP_GEOM_DIST_ARY[] = +{ + NC_("SC_OPCODE_HYP_GEOM_DIST", "Values of the hypergeometric distribution."), + NC_("SC_OPCODE_HYP_GEOM_DIST", "X"), + NC_("SC_OPCODE_HYP_GEOM_DIST", "The number of successes in the sample."), + NC_("SC_OPCODE_HYP_GEOM_DIST", "N sample"), + NC_("SC_OPCODE_HYP_GEOM_DIST", "The size of the sample."), + NC_("SC_OPCODE_HYP_GEOM_DIST", "Successes"), + NC_("SC_OPCODE_HYP_GEOM_DIST", "The number of successes in the population."), + NC_("SC_OPCODE_HYP_GEOM_DIST", "N population"), + NC_("SC_OPCODE_HYP_GEOM_DIST", "The population size."), + NC_("SC_OPCODE_HYP_GEOM_DIST", "Cumulative"), + NC_("SC_OPCODE_HYP_GEOM_DIST", "Cumulated. TRUE calculates the cumulative distribution function, FALSE the probability mass function.") +}; + +// -=*# Resource for function HYPGEOM.DIST #*=- +const TranslateId SC_OPCODE_HYP_GEOM_DIST_MS_ARY[] = +{ + NC_("SC_OPCODE_HYP_GEOM_DIST_MS", "Values of the hypergeometric distribution."), + NC_("SC_OPCODE_HYP_GEOM_DIST_MS", "X"), + NC_("SC_OPCODE_HYP_GEOM_DIST_MS", "The number of successes in the sample."), + NC_("SC_OPCODE_HYP_GEOM_DIST_MS", "N sample"), + NC_("SC_OPCODE_HYP_GEOM_DIST_MS", "The size of the sample."), + NC_("SC_OPCODE_HYP_GEOM_DIST_MS", "Successes"), + NC_("SC_OPCODE_HYP_GEOM_DIST_MS", "The number of successes in the population."), + NC_("SC_OPCODE_HYP_GEOM_DIST_MS", "N population"), + NC_("SC_OPCODE_HYP_GEOM_DIST_MS", "The population size."), + NC_("SC_OPCODE_HYP_GEOM_DIST_MS", "Cumulative"), + NC_("SC_OPCODE_HYP_GEOM_DIST_MS", "Cumulated. TRUE calculates the cumulative distribution function, FALSE the probability mass function.") +}; + +// -=*# Resource for function TDIST #*=- +const TranslateId SC_OPCODE_T_DIST_ARY[] = +{ + NC_("SC_OPCODE_T_DIST", "Returns the t-distribution."), + NC_("SC_OPCODE_T_DIST", "Number"), + NC_("SC_OPCODE_T_DIST", "The value for which the T distribution is to be calculated."), + NC_("SC_OPCODE_T_DIST", "Degrees freedom"), + NC_("SC_OPCODE_T_DIST", "The degrees of freedom of the T distribution."), + NC_("SC_OPCODE_T_DIST", "Mode"), + NC_("SC_OPCODE_T_DIST", "Mode = 1 calculates the one-tailed test, 2 = two-tailed distribution.") +}; + +// -=*# Resource for function T.DIST.2T #*=- +const TranslateId SC_OPCODE_T_DIST_2T_ARY[] = +{ + NC_("SC_OPCODE_T_DIST_2T", "Returns the two-tailed t-distribution."), + NC_("SC_OPCODE_T_DIST_2T", "Number"), + NC_("SC_OPCODE_T_DIST_2T", "The value for which the T distribution is to be calculated."), + NC_("SC_OPCODE_T_DIST_2T", "Degrees freedom"), + NC_("SC_OPCODE_T_DIST_2T", "The degrees of freedom of the T distribution.") +}; + +// -=*# Resource for function T.DIST #*=- +const TranslateId SC_OPCODE_T_DIST_MS_ARY[] = +{ + NC_("SC_OPCODE_T_DIST_MS", "Returns the t-distribution."), + NC_("SC_OPCODE_T_DIST_MS", "Number"), + NC_("SC_OPCODE_T_DIST_MS", "The value for which the T distribution is to be calculated."), + NC_("SC_OPCODE_T_DIST_MS", "Degrees freedom"), + NC_("SC_OPCODE_T_DIST_MS", "The degrees of freedom of the T distribution."), + NC_("SC_OPCODE_T_DIST_MS", "Cumulative"), + NC_("SC_OPCODE_T_DIST_MS", "True calculates the cumulative distribution function, false the probability density function.") +}; + +// -=*# Resource for function T.DIST.RT #*=- +const TranslateId SC_OPCODE_T_DIST_RT_ARY[] = +{ + NC_("SC_OPCODE_T_DIST_RT", "Returns the right-tailed t-distribution."), + NC_("SC_OPCODE_T_DIST_RT", "Number"), + NC_("SC_OPCODE_T_DIST_RT", "The value for which the T distribution is to be calculated."), + NC_("SC_OPCODE_T_DIST_RT", "Degrees freedom"), + NC_("SC_OPCODE_T_DIST_RT", "The degrees of freedom of the T distribution.") +}; + +// -=*# Resource for function TINV #*=- +const TranslateId SC_OPCODE_T_INV_ARY[] = +{ + NC_("SC_OPCODE_T_INV", "Values of the inverse t-distribution."), + NC_("SC_OPCODE_T_INV", "Number"), + NC_("SC_OPCODE_T_INV", "The probability value for which the inverse T distribution is to be calculated."), + NC_("SC_OPCODE_T_INV", "Degrees freedom"), + NC_("SC_OPCODE_T_INV", "The degrees of freedom of the T distribution.") +}; + +// -=*# Resource for function T.INV #*=- +const TranslateId SC_OPCODE_T_INV_MS_ARY[] = +{ + NC_("SC_OPCODE_T_INV_MS", "Values of the left-tailed inverse t-distribution."), + NC_("SC_OPCODE_T_INV_MS", "Number"), + NC_("SC_OPCODE_T_INV_MS", "The probability value for which the inverse T distribution is to be calculated."), + NC_("SC_OPCODE_T_INV_MS", "Degrees freedom"), + NC_("SC_OPCODE_T_INV_MS", "The degrees of freedom of the T distribution.") +}; + +// -=*# Resource for function T.INV.2T #*=- +const TranslateId SC_OPCODE_T_INV_2T_ARY[] = +{ + NC_("SC_OPCODE_T_INV_2T", "Values of the two-tailed inverse t-distribution."), + NC_("SC_OPCODE_T_INV_2T", "Number"), + NC_("SC_OPCODE_T_INV_2T", "The probability value for which the inverse T distribution is to be calculated."), + NC_("SC_OPCODE_T_INV_2T", "Degrees freedom"), + NC_("SC_OPCODE_T_INV_2T", "The degrees of freedom of the T distribution.") +}; + +// -=*# Resource for function FDIST #*=- +const TranslateId SC_OPCODE_F_DIST_ARY[] = +{ + NC_("SC_OPCODE_F_DIST", "Values of the F probability distribution."), + NC_("SC_OPCODE_F_DIST", "Number"), + NC_("SC_OPCODE_F_DIST", "The value for which the F distribution is to be calculated."), + NC_("SC_OPCODE_F_DIST", "Degrees freedom 1"), + NC_("SC_OPCODE_F_DIST", "The degrees of freedom in the numerator of the F distribution."), + NC_("SC_OPCODE_F_DIST", "Degrees freedom 2"), + NC_("SC_OPCODE_F_DIST", "The degrees of freedom in the denominator of the F distribution.") +}; + +// -=*# Resource for function F.DIST #*=- +const TranslateId SC_OPCODE_F_DIST_LT_ARY[] = +{ + NC_("SC_OPCODE_F_DIST_LT", "Values of the left tail F probability distribution."), + NC_("SC_OPCODE_F_DIST_LT", "Number"), + NC_("SC_OPCODE_F_DIST_LT", "The value for which the F distribution is to be calculated."), + NC_("SC_OPCODE_F_DIST_LT", "Degrees freedom 1"), + NC_("SC_OPCODE_F_DIST_LT", "The degrees of freedom in the numerator of the F distribution."), + NC_("SC_OPCODE_F_DIST_LT", "Degrees freedom 2"), + NC_("SC_OPCODE_F_DIST_LT", "The degrees of freedom in the denominator of the F distribution."), + NC_("SC_OPCODE_F_DIST_LT", "Cumulative"), + NC_("SC_OPCODE_F_DIST_LT", "Cumulative distribution function (TRUE) or probability density function (FALSE).") +}; + +// -=*# Resource for function F.DIST.RT #*=- +const TranslateId SC_OPCODE_F_DIST_RT_ARY[] = +{ + NC_("SC_OPCODE_F_DIST_RT", "Values of the right tail F probability distribution."), + NC_("SC_OPCODE_F_DIST_RT", "Number"), + NC_("SC_OPCODE_F_DIST_RT", "The value for which the F distribution is to be calculated."), + NC_("SC_OPCODE_F_DIST_RT", "Degrees freedom 1"), + NC_("SC_OPCODE_F_DIST_RT", "The degrees of freedom in the numerator of the F distribution."), + NC_("SC_OPCODE_F_DIST_RT", "Degrees freedom 2"), + NC_("SC_OPCODE_F_DIST_RT", "The degrees of freedom in the denominator of the F distribution.") +}; + +// -=*# Resource for function FINV #*=- +const TranslateId SC_OPCODE_F_INV_ARY[] = +{ + NC_("SC_OPCODE_F_INV", "Values of the inverse F distribution."), + NC_("SC_OPCODE_F_INV", "Number"), + NC_("SC_OPCODE_F_INV", "The probability value for which the inverse F distribution is to be calculated."), + NC_("SC_OPCODE_F_INV", "Degrees freedom 1"), + NC_("SC_OPCODE_F_INV", "The degrees of freedom in the numerator of the F distribution."), + NC_("SC_OPCODE_F_INV", "Degrees freedom 2"), + NC_("SC_OPCODE_F_INV", "The degrees of freedom in the denominator of the F distribution.") +}; + +// -=*# Resource for function F.INV #*=- +const TranslateId SC_OPCODE_F_INV_LT_ARY[] = +{ + NC_("SC_OPCODE_F_INV_LT", "Values of the inverse left tail F distribution."), + NC_("SC_OPCODE_F_INV_LT", "Number"), + NC_("SC_OPCODE_F_INV_LT", "The probability value for which the inverse F distribution is to be calculated."), + NC_("SC_OPCODE_F_INV_LT", "Degrees freedom 1"), + NC_("SC_OPCODE_F_INV_LT", "The degrees of freedom in the numerator of the F distribution."), + NC_("SC_OPCODE_F_INV_LT", "Degrees freedom 2"), + NC_("SC_OPCODE_F_INV_LT", "The degrees of freedom in the denominator of the F distribution.") +}; + +// -=*# Resource for function F.INV.RT #*=- +const TranslateId SC_OPCODE_F_INV_RT_ARY[] = +{ + NC_("SC_OPCODE_F_INV_RT", "Values of the inverse right tail F distribution."), + NC_("SC_OPCODE_F_INV_RT", "Number"), + NC_("SC_OPCODE_F_INV_RT", "The probability value for which the inverse F distribution is to be calculated."), + NC_("SC_OPCODE_F_INV_RT", "Degrees freedom 1"), + NC_("SC_OPCODE_F_INV_RT", "The degrees of freedom in the numerator of the F distribution."), + NC_("SC_OPCODE_F_INV_RT", "Degrees freedom 2"), + NC_("SC_OPCODE_F_INV_RT", "The degrees of freedom in the denominator of the F distribution.") +}; + +// -=*# Resource for function CHIDIST #*=- +const TranslateId SC_OPCODE_CHI_DIST_ARY[] = +{ + NC_("SC_OPCODE_CHI_DIST", "Returns the right-tail probability of the chi-square distribution."), + NC_("SC_OPCODE_CHI_DIST", "Number"), + NC_("SC_OPCODE_CHI_DIST", "The value for which the chi square distribution is to be calculated."), + NC_("SC_OPCODE_CHI_DIST", "Degrees freedom"), + NC_("SC_OPCODE_CHI_DIST", "The degrees of freedom of the chi square distribution.") +}; + +// -=*# Resource for function CHISQ.DIST.RT #*=- +const TranslateId SC_OPCODE_CHI_DIST_MS_ARY[] = +{ + NC_("SC_OPCODE_CHI_DIST_MS", "Returns the right-tail probability of the chi-square distribution."), + NC_("SC_OPCODE_CHI_DIST_MS", "Number"), + NC_("SC_OPCODE_CHI_DIST_MS", "The value for which the chi square distribution is to be calculated."), + NC_("SC_OPCODE_CHI_DIST_MS", "Degrees freedom"), + NC_("SC_OPCODE_CHI_DIST_MS", "The degrees of freedom of the chi square distribution.") +}; + + +// -=*# Resource for function CHISQDIST #*=- +const TranslateId SC_OPCODE_CHISQ_DIST_ARY[] = +{ + NC_("SC_OPCODE_CHISQ_DIST", "Returns left-tail probability of the cumulative distribution function or values of the probability density function of the chi-square distribution."), + NC_("SC_OPCODE_CHISQ_DIST", "Number"), + NC_("SC_OPCODE_CHISQ_DIST", "The value for which the probability density function or cumulative distribution function is to be calculated."), + NC_("SC_OPCODE_CHISQ_DIST", "Degrees of Freedom"), + NC_("SC_OPCODE_CHISQ_DIST", "The degrees of freedom of the chi-square distribution."), + NC_("SC_OPCODE_CHISQ_DIST", "Cumulative"), + NC_("SC_OPCODE_CHISQ_DIST", "0 or FALSE calculates the probability density function. Any other value or TRUE or omitted calculates the cumulative distribution function.") +}; + + +// -=*# Resource for function CHISQ.DIST #*=- +const TranslateId SC_OPCODE_CHISQ_DIST_MS_ARY[] = +{ + NC_("SC_OPCODE_CHISQ_DIST_MS", "Returns left-tail probability of the cumulative distribution function or values of the probability density function of the chi-square distribution."), + NC_("SC_OPCODE_CHISQ_DIST_MS", "Number"), + NC_("SC_OPCODE_CHISQ_DIST_MS", "The value for which the probability density function or cumulative distribution function is to be calculated."), + NC_("SC_OPCODE_CHISQ_DIST_MS", "Degrees of Freedom"), + NC_("SC_OPCODE_CHISQ_DIST_MS", "The degrees of freedom of the chi-square distribution."), + NC_("SC_OPCODE_CHISQ_DIST_MS", "Cumulative"), + NC_("SC_OPCODE_CHISQ_DIST_MS", "0 or FALSE calculates the probability density function. Any other value or TRUE calculates the cumulative distribution function.") +}; + + +// -=*# Resource for function CHIINV #*=- +const TranslateId SC_OPCODE_CHI_INV_ARY[] = +{ + NC_("SC_OPCODE_CHI_INV", "Values of the inverse of CHIDIST(x; DegreesOfFreedom)."), + NC_("SC_OPCODE_CHI_INV", "Number"), + NC_("SC_OPCODE_CHI_INV", "The probability value for which the inverse chi square distribution is to be calculated."), + NC_("SC_OPCODE_CHI_INV", "Degrees freedom"), + NC_("SC_OPCODE_CHI_INV", "The degrees of freedom of the chi square distribution.") +}; + + +// -=*# Resource for function CHISQ.INV.RT #*=- +const TranslateId SC_OPCODE_CHI_INV_MS_ARY[] = +{ + NC_("SC_OPCODE_CHI_INV_MS", "Values of the inverse of CHIDIST(x; DegreesOfFreedom)."), + NC_("SC_OPCODE_CHI_INV_MS", "Number"), + NC_("SC_OPCODE_CHI_INV_MS", "The probability value for which the inverse chi square distribution is to be calculated."), + NC_("SC_OPCODE_CHI_INV_MS", "Degrees freedom"), + NC_("SC_OPCODE_CHI_INV_MS", "The degrees of freedom of the chi square distribution.") +}; + + +// -=*# Resource for function CHISQINV #*=- +const TranslateId SC_OPCODE_CHISQ_INV_ARY[] = +{ + NC_("SC_OPCODE_CHISQ_INV", "Values of the inverse of CHISQDIST(x;DegreesOfFreedom;TRUE())."), + NC_("SC_OPCODE_CHISQ_INV", "Probability"), + NC_("SC_OPCODE_CHISQ_INV", "The probability value for which the inverse of the chi square distribution is to be calculated."), + NC_("SC_OPCODE_CHISQ_INV", "Degrees of Freedom"), + NC_("SC_OPCODE_CHISQ_INV", "The degrees of freedom of the chi square distribution.") +}; + + +// -=*# Resource for function CHISQ.INV #*=- +const TranslateId SC_OPCODE_CHISQ_INV_MS_ARY[] = +{ + NC_("SC_OPCODE_CHISQ_INV_MS", "Values of the inverse of CHISQ.DIST(x;DegreesOfFreedom;TRUE())."), + NC_("SC_OPCODE_CHISQ_INV_MS", "Probability"), + NC_("SC_OPCODE_CHISQ_INV_MS", "The probability value for which the inverse of the chi square distribution is to be calculated."), + NC_("SC_OPCODE_CHISQ_INV_MS", "Degrees of Freedom"), + NC_("SC_OPCODE_CHISQ_INV_MS", "The degrees of freedom of the chi square distribution.") +}; + + +// -=*# Resource for function STANDARDIZE #*=- +const TranslateId SC_OPCODE_STANDARD_ARY[] = +{ + NC_("SC_OPCODE_STANDARD", "Converts a random variable to a normalized value."), + NC_("SC_OPCODE_STANDARD", "Number"), + NC_("SC_OPCODE_STANDARD", "The value to be standardized."), + NC_("SC_OPCODE_STANDARD", "Mean"), + NC_("SC_OPCODE_STANDARD", "The mean value used for moving."), + NC_("SC_OPCODE_STANDARD", "STDEV"), + NC_("SC_OPCODE_STANDARD", "The standard deviation used for scaling.") +}; + +// -=*# Resource for function PERMUT #*=- +const TranslateId SC_OPCODE_PERMUT_ARY[] = +{ + NC_("SC_OPCODE_PERMUT", "Returns the number of permutations for a given number of elements without repetition."), + NC_("SC_OPCODE_PERMUT", "Count 1"), + NC_("SC_OPCODE_PERMUT", "The total number of elements."), + NC_("SC_OPCODE_PERMUT", "Count 2"), + NC_("SC_OPCODE_PERMUT", "The selection number taken from the elements.") +}; + +// -=*# Resource for function PERMUTATIONA #*=- +const TranslateId SC_OPCODE_PERMUTATION_A_ARY[] = +{ + NC_("SC_OPCODE_PERMUTATION_A", "Returns the number of permutations for a given number of objects (repetition allowed)."), + NC_("SC_OPCODE_PERMUTATION_A", "Count 1"), + NC_("SC_OPCODE_PERMUTATION_A", "The total number of elements."), + NC_("SC_OPCODE_PERMUTATION_A", "Count 2"), + NC_("SC_OPCODE_PERMUTATION_A", "The selection number taken from the elements.") +}; + +// -=*# Resource for function CONFIDENCE #*=- +const TranslateId SC_OPCODE_CONFIDENCE_ARY[] = +{ + NC_("SC_OPCODE_CONFIDENCE", "Returns a (1-alpha) confidence interval for a normal distribution."), + NC_("SC_OPCODE_CONFIDENCE", "Alpha"), + NC_("SC_OPCODE_CONFIDENCE", "The level of the confidence interval."), + NC_("SC_OPCODE_CONFIDENCE", "STDEV"), + NC_("SC_OPCODE_CONFIDENCE", "The standard deviation of the population."), + NC_("SC_OPCODE_CONFIDENCE", "Size"), + NC_("SC_OPCODE_CONFIDENCE", "The size of the population.") +}; + +// -=*# Resource for function CONFIDENCE.NORM #*=- +const TranslateId SC_OPCODE_CONFIDENCE_N_ARY[] = +{ + NC_("SC_OPCODE_CONFIDENCE_N", "Returns a (1-alpha) confidence interval for a normal distribution."), + NC_("SC_OPCODE_CONFIDENCE_N", "Alpha"), + NC_("SC_OPCODE_CONFIDENCE_N", "The level of the confidence interval."), + NC_("SC_OPCODE_CONFIDENCE_N", "STDEV"), + NC_("SC_OPCODE_CONFIDENCE_N", "The standard deviation of the population."), + NC_("SC_OPCODE_CONFIDENCE_N", "Size"), + NC_("SC_OPCODE_CONFIDENCE_N", "The size of the population.") +}; + +// -=*# Resource for function CONFIDENCE.T #*=- +const TranslateId SC_OPCODE_CONFIDENCE_T_ARY[] = +{ + NC_("SC_OPCODE_CONFIDENCE_T", "Returns a (1-alpha) confidence interval for a Student's t distribution."), + NC_("SC_OPCODE_CONFIDENCE_T", "Alpha"), + NC_("SC_OPCODE_CONFIDENCE_T", "The level of the confidence interval."), + NC_("SC_OPCODE_CONFIDENCE_T", "STDEV"), + NC_("SC_OPCODE_CONFIDENCE_T", "The standard deviation of the population."), + NC_("SC_OPCODE_CONFIDENCE_T", "Size"), + NC_("SC_OPCODE_CONFIDENCE_T", "The size of the population.") +}; + +// -=*# Resource for function ZTEST #*=- +const TranslateId SC_OPCODE_Z_TEST_ARY[] = +{ + NC_("SC_OPCODE_Z_TEST", "Calculates the probability of observing a z-statistic greater than the one computed based on a sample."), + NC_("SC_OPCODE_Z_TEST", "Data"), + NC_("SC_OPCODE_Z_TEST", "The given sample, drawn from a normally distributed population."), + NC_("SC_OPCODE_Z_TEST", "mu"), + NC_("SC_OPCODE_Z_TEST", "The known mean of the population."), + NC_("SC_OPCODE_Z_TEST", "sigma"), + NC_("SC_OPCODE_Z_TEST", "The known standard deviation of the population. If omitted, the standard deviation of the given sample is used.") +}; + +// -=*# Resource for function Z.TEST #*=- +const TranslateId SC_OPCODE_Z_TEST_MS_ARY[] = +{ + NC_("SC_OPCODE_Z_TEST_MS", "Calculates the probability of observing a z-statistic greater than the one computed based on a sample."), + NC_("SC_OPCODE_Z_TEST_MS", "Data"), + NC_("SC_OPCODE_Z_TEST_MS", "The given sample, drawn from a normally distributed population."), + NC_("SC_OPCODE_Z_TEST_MS", "mu"), + NC_("SC_OPCODE_Z_TEST_MS", "The known mean of the population."), + NC_("SC_OPCODE_Z_TEST_MS", "sigma"), + NC_("SC_OPCODE_Z_TEST_MS", "The known standard deviation of the population. If omitted, the standard deviation of the given sample is used.") +}; + +// -=*# Resource for function CHITEST #*=- +const TranslateId SC_OPCODE_CHI_TEST_ARY[] = +{ + NC_("SC_OPCODE_CHI_TEST", "Returns the chi square independence test."), + NC_("SC_OPCODE_CHI_TEST", "Data B"), + NC_("SC_OPCODE_CHI_TEST", "The observed data array."), + NC_("SC_OPCODE_CHI_TEST", "Data E"), + NC_("SC_OPCODE_CHI_TEST", "The expected data array.") +}; + +// -=*# Resource for function CHISQ.TEST #*=- +const TranslateId SC_OPCODE_CHI_TEST_MS_ARY[] = +{ + NC_("SC_OPCODE_CHI_TEST_MS", "Returns the chi square independence test."), + NC_("SC_OPCODE_CHI_TEST_MS", "Data B"), + NC_("SC_OPCODE_CHI_TEST_MS", "The observed data array."), + NC_("SC_OPCODE_CHI_TEST_MS", "Data E"), + NC_("SC_OPCODE_CHI_TEST_MS", "The expected data array.") +}; + +// -=*# Resource for function FTEST #*=- +const TranslateId SC_OPCODE_F_TEST_ARY[] = +{ + NC_("SC_OPCODE_F_TEST", "Calculates the F test."), + NC_("SC_OPCODE_F_TEST", "Data 1"), + NC_("SC_OPCODE_F_TEST", "The first record array."), + NC_("SC_OPCODE_F_TEST", "Data 2"), + NC_("SC_OPCODE_F_TEST", "The second record array.") +}; + +// -=*# Resource for function F.TEST #*=- +const TranslateId SC_OPCODE_F_TEST_MS_ARY[] = +{ + NC_("SC_OPCODE_F_TEST_MS", "Calculates the F test."), + NC_("SC_OPCODE_F_TEST_MS", "Data 1"), + NC_("SC_OPCODE_F_TEST_MS", "The first record array."), + NC_("SC_OPCODE_F_TEST_MS", "Data 2"), + NC_("SC_OPCODE_F_TEST_MS", "The second record array.") +}; + +// -=*# Resource for function TTEST #*=- +const TranslateId SC_OPCODE_T_TEST_ARY[] = +{ + NC_("SC_OPCODE_T_TEST", "Calculates the t-test."), + NC_("SC_OPCODE_T_TEST", "Data 1"), + NC_("SC_OPCODE_T_TEST", "The first record array."), + NC_("SC_OPCODE_T_TEST", "Data 2"), + NC_("SC_OPCODE_T_TEST", "The second record array."), + NC_("SC_OPCODE_T_TEST", "Mode"), + NC_("SC_OPCODE_T_TEST", "Mode specifies the number of distribution tails to return. 1 = one-tailed, 2 = two-tailed distribution"), + NC_("SC_OPCODE_T_TEST", "Type"), + NC_("SC_OPCODE_T_TEST", "The type of the t-test.") +}; + +// -=*# Resource for function T.TEST #*=- +const TranslateId SC_OPCODE_T_TEST_MS_ARY[] = +{ + NC_("SC_OPCODE_T_TEST_MS", "Calculates the t-test."), + NC_("SC_OPCODE_T_TEST_MS", "Data 1"), + NC_("SC_OPCODE_T_TEST_MS", "The first record array."), + NC_("SC_OPCODE_T_TEST_MS", "Data 2"), + NC_("SC_OPCODE_T_TEST_MS", "The second record array."), + NC_("SC_OPCODE_T_TEST_MS", "Mode"), + NC_("SC_OPCODE_T_TEST_MS", "Mode specifies the number of distribution tails to return. 1 = one-tailed, 2 = two-tailed distribution"), + NC_("SC_OPCODE_T_TEST_MS", "Type"), + NC_("SC_OPCODE_T_TEST_MS", "The type of the t-test.") +}; + +// -=*# Resource for function RSQ #*=- +const TranslateId SC_OPCODE_RSQ_ARY[] = +{ + NC_("SC_OPCODE_RSQ", "Returns the square of the Pearson product moment correlation coefficient."), + NC_("SC_OPCODE_RSQ", "Data Y"), + NC_("SC_OPCODE_RSQ", "The Y data array."), + NC_("SC_OPCODE_RSQ", "Data X"), + NC_("SC_OPCODE_RSQ", "The X data array.") +}; + +// -=*# Resource for function INTERCEPT #*=- +const TranslateId SC_OPCODE_INTERCEPT_ARY[] = +{ + NC_("SC_OPCODE_INTERCEPT", "Returns the intercept of the linear regression line and the Y axis."), + NC_("SC_OPCODE_INTERCEPT", "Data Y"), + NC_("SC_OPCODE_INTERCEPT", "The Y data array."), + NC_("SC_OPCODE_INTERCEPT", "Data X"), + NC_("SC_OPCODE_INTERCEPT", "The X data array.") +}; + +// -=*# Resource for function SLOPE #*=- +const TranslateId SC_OPCODE_SLOPE_ARY[] = +{ + NC_("SC_OPCODE_SLOPE", "Returns the slope of the linear regression line."), + NC_("SC_OPCODE_SLOPE", "Data Y"), + NC_("SC_OPCODE_SLOPE", "The Y data array."), + NC_("SC_OPCODE_SLOPE", "Data X"), + NC_("SC_OPCODE_SLOPE", "The X data array.") +}; + +// -=*# Resource for function STEYX #*=- +const TranslateId SC_OPCODE_STEYX_ARY[] = +{ + NC_("SC_OPCODE_STEYX", "Returns the standard error of the linear regression."), + NC_("SC_OPCODE_STEYX", "Data Y"), + NC_("SC_OPCODE_STEYX", "The Y data array."), + NC_("SC_OPCODE_STEYX", "Data X"), + NC_("SC_OPCODE_STEYX", "The X data array.") +}; + +// -=*# Resource for function PEARSON #*=- +const TranslateId SC_OPCODE_PEARSON_ARY[] = +{ + NC_("SC_OPCODE_PEARSON", "Returns the Pearson product moment correlation coefficient."), + NC_("SC_OPCODE_PEARSON", "Data 1"), + NC_("SC_OPCODE_PEARSON", "The first record array."), + NC_("SC_OPCODE_PEARSON", "Data 2"), + NC_("SC_OPCODE_PEARSON", "The second record array.") +}; + +// -=*# Resource for function CORREL #*=- +const TranslateId SC_OPCODE_CORREL_ARY[] = +{ + NC_("SC_OPCODE_CORREL", "Returns the correlation coefficient."), + NC_("SC_OPCODE_CORREL", "Data 1"), + NC_("SC_OPCODE_CORREL", "The first record array."), + NC_("SC_OPCODE_CORREL", "Data 2"), + NC_("SC_OPCODE_CORREL", "The second record array.") +}; + +// -=*# Resource for function COVAR #*=- +const TranslateId SC_OPCODE_COVAR_ARY[] = +{ + NC_("SC_OPCODE_COVAR", "Calculates the population covariance."), + NC_("SC_OPCODE_COVAR", "Data 1"), + NC_("SC_OPCODE_COVAR", "The first record array."), + NC_("SC_OPCODE_COVAR", "Data 2"), + NC_("SC_OPCODE_COVAR", "The second record array.") +}; + +// -=*# Resource for function COVARIANCE.P #*=- +const TranslateId SC_OPCODE_COVARIANCE_P_ARY[] = +{ + NC_("SC_OPCODE_COVARIANCE_P", "Calculates the population covariance."), + NC_("SC_OPCODE_COVARIANCE_P", "Data 1"), + NC_("SC_OPCODE_COVARIANCE_P", "The first record array."), + NC_("SC_OPCODE_COVARIANCE_P", "Data 2"), + NC_("SC_OPCODE_COVARIANCE_P", "The second record array.") +}; + +// -=*# Resource for function COVARIANCE.S #*=- +const TranslateId SC_OPCODE_COVARIANCE_S_ARY[] = +{ + NC_("SC_OPCODE_COVARIANCE_S", "Calculates the sample covariance."), + NC_("SC_OPCODE_COVARIANCE_S", "Data 1"), + NC_("SC_OPCODE_COVARIANCE_S", "The first record array."), + NC_("SC_OPCODE_COVARIANCE_S", "Data 2"), + NC_("SC_OPCODE_COVARIANCE_S", "The second record array.") +}; + +// -=*# Resource for function FORECAST #*=- +const TranslateId SC_OPCODE_FORECAST_ARY[] = +{ + NC_("SC_OPCODE_FORECAST", "Returns a value along a linear regression"), + NC_("SC_OPCODE_FORECAST", "Value"), + NC_("SC_OPCODE_FORECAST", "The X value for which the Y value on the regression linear is to be calculated."), + NC_("SC_OPCODE_FORECAST", "Data Y"), + NC_("SC_OPCODE_FORECAST", "The Y data array."), + NC_("SC_OPCODE_FORECAST", "Data X"), + NC_("SC_OPCODE_FORECAST", "The X data array.") +}; + +// -=*# Resource for function FORECAST.ETS #*=- +const TranslateId SC_OPCODE_FORECAST_ETS_ADD_ARY[] = +{ + NC_("SC_OPCODE_FORECAST_ETS_ADD", "Calculates future value(s) using additive Exponential Smoothing algorithm."), + NC_("SC_OPCODE_FORECAST_ETS_ADD", "Target"), + NC_("SC_OPCODE_FORECAST_ETS_ADD", "The date (array) for which you want to predict a value."), + NC_("SC_OPCODE_FORECAST_ETS_ADD", "Values"), + NC_("SC_OPCODE_FORECAST_ETS_ADD", "The data array from which you want to forecast."), + NC_("SC_OPCODE_FORECAST_ETS_ADD", "Timeline"), + NC_("SC_OPCODE_FORECAST_ETS_ADD", "The date or numeric array; a consistent step between values is needed."), + NC_("SC_OPCODE_FORECAST_ETS_ADD", "Period length"), + NC_("SC_OPCODE_FORECAST_ETS_ADD", "Number of Samples in Period (default 1); length of the seasonal pattern."), + NC_("SC_OPCODE_FORECAST_ETS_ADD", "Data completion"), + NC_("SC_OPCODE_FORECAST_ETS_ADD", "Data completion (default 1); 0 treats missing points as zero, 1 interpolates."), + NC_("SC_OPCODE_FORECAST_ETS_ADD", "Aggregation"), + NC_("SC_OPCODE_FORECAST_ETS_ADD", "Aggregation (default 1 = AVERAGE); method to be used to aggregate identical (time) values.") +}; + +// -=*# Resource for function FORECAST.ETS.MULT #*=- +const TranslateId SC_OPCODE_FORECAST_ETS_MUL_ARY[] = +{ + NC_("SC_OPCODE_FORECAST_ETS_MUL", "Calculates future value(s) using multiplicative Exponential Smoothing algorithm."), + NC_("SC_OPCODE_FORECAST_ETS_MUL", "Target"), + NC_("SC_OPCODE_FORECAST_ETS_MUL", "The date (array) for which you want to predict a value."), + NC_("SC_OPCODE_FORECAST_ETS_MUL", "Values"), + NC_("SC_OPCODE_FORECAST_ETS_MUL", "The data array from which you want to forecast."), + NC_("SC_OPCODE_FORECAST_ETS_MUL", "Timeline"), + NC_("SC_OPCODE_FORECAST_ETS_MUL", "The date or numeric array; a consistent step between values is needed."), + NC_("SC_OPCODE_FORECAST_ETS_MUL", "Period length"), + NC_("SC_OPCODE_FORECAST_ETS_MUL", "Number of Samples in Period (default 1); length of the seasonal pattern."), + NC_("SC_OPCODE_FORECAST_ETS_MUL", "Data completion"), + NC_("SC_OPCODE_FORECAST_ETS_MUL", "Data completion (default 1); 0 treats missing points as zero, 1 interpolates."), + NC_("SC_OPCODE_FORECAST_ETS_MUL", "Aggregation"), + NC_("SC_OPCODE_FORECAST_ETS_MUL", "Aggregation (default 1 = AVERAGE); method to be used to aggregate identical (time) values.") +}; + +// -=*# Resource for function FORECAST.ETS.CONFINT #*=- +const TranslateId SC_OPCODE_FORECAST_ETS_PIA_ARY[] = +{ + NC_("SC_OPCODE_FORECAST_ETS_PIA", "Returns a prediction interval at the specified target value(s) for additive Exponential Smoothing method"), + NC_("SC_OPCODE_FORECAST_ETS_PIA", "Target"), + NC_("SC_OPCODE_FORECAST_ETS_PIA", "The date (array) for which you want to predict a value."), + NC_("SC_OPCODE_FORECAST_ETS_PIA", "Values"), + NC_("SC_OPCODE_FORECAST_ETS_PIA", "The data array from which you want to forecast."), + NC_("SC_OPCODE_FORECAST_ETS_PIA", "Timeline"), + NC_("SC_OPCODE_FORECAST_ETS_PIA", "The date or numeric array; a consistent step between values is needed."), + NC_("SC_OPCODE_FORECAST_ETS_PIA", "Confidence level"), + NC_("SC_OPCODE_FORECAST_ETS_PIA", "Confidence level (default 0.95); value 0 to 1 (exclusive) for 0 to 100% calculated prediction interval."), + NC_("SC_OPCODE_FORECAST_ETS_PIA", "Period length"), + NC_("SC_OPCODE_FORECAST_ETS_PIA", "Number of Samples in Period (default 1); length of the seasonal pattern."), + NC_("SC_OPCODE_FORECAST_ETS_PIA", "Data completion"), + NC_("SC_OPCODE_FORECAST_ETS_PIA", "Data completion (default 1); 0 treats missing points as zero, 1 interpolates."), + NC_("SC_OPCODE_FORECAST_ETS_PIA", "Aggregation"), + NC_("SC_OPCODE_FORECAST_ETS_PIA", "Aggregation (default 1 = AVERAGE); method to be used to aggregate identical (time) values.") +}; + +// -=*# Resource for function FORECAST.ETS.PI.MULT #*=- +const TranslateId SC_OPCODE_FORECAST_ETS_PIM_ARY[] = +{ + NC_("SC_OPCODE_FORECAST_ETS_PIM", "Returns a prediction interval at the specified target value(s) for multiplicative Exponential Smoothing method"), + NC_("SC_OPCODE_FORECAST_ETS_PIM", "Target"), + NC_("SC_OPCODE_FORECAST_ETS_PIM", "The date (array) for which you want to predict a value."), + NC_("SC_OPCODE_FORECAST_ETS_PIM", "Values"), + NC_("SC_OPCODE_FORECAST_ETS_PIM", "The data array from which you want to forecast."), + NC_("SC_OPCODE_FORECAST_ETS_PIM", "Timeline"), + NC_("SC_OPCODE_FORECAST_ETS_PIM", "The date or numeric array; a consistent step between values is needed."), + NC_("SC_OPCODE_FORECAST_ETS_PIM", "Confidence level"), + NC_("SC_OPCODE_FORECAST_ETS_PIM", "Confidence level (default 0.95); value 0 to 1 (exclusive) for 0 to 100% calculated prediction interval."), + NC_("SC_OPCODE_FORECAST_ETS_PIM", "Period length"), + NC_("SC_OPCODE_FORECAST_ETS_PIM", "Number of Samples in Period (default 1); length of the seasonal pattern."), + NC_("SC_OPCODE_FORECAST_ETS_PIM", "Data completion"), + NC_("SC_OPCODE_FORECAST_ETS_PIM", "Data completion (default 1); 0 treats missing points as zero, 1 interpolates."), + NC_("SC_OPCODE_FORECAST_ETS_PIM", "Aggregation"), + NC_("SC_OPCODE_FORECAST_ETS_PIM", "Aggregation (default 1 = AVERAGE); method to be used to aggregate identical (time) values.") +}; + +// -=*# Resource for function FORECAST.ETS.SEASONALITY #*=- +const TranslateId SC_OPCODE_FORECAST_ETS_SEA_ARY[] = +{ + NC_("SC_OPCODE_FORECAST_ETS_SEA", "Calculates the number of samples in period (season) using additive Exponential Triple Smoothing algorithm."), + NC_("SC_OPCODE_FORECAST_ETS_SEA", "Values"), + NC_("SC_OPCODE_FORECAST_ETS_SEA", "The data array from which you want to forecast."), + NC_("SC_OPCODE_FORECAST_ETS_SEA", "Timeline"), + NC_("SC_OPCODE_FORECAST_ETS_SEA", "The date or numeric array; a consistent step between values is needed."), + NC_("SC_OPCODE_FORECAST_ETS_SEA", "Data completion"), + NC_("SC_OPCODE_FORECAST_ETS_SEA", "Data completion (default 1); 0 treats missing points as zero, 1 interpolates."), + NC_("SC_OPCODE_FORECAST_ETS_SEA", "Aggregation"), + NC_("SC_OPCODE_FORECAST_ETS_SEA", "Aggregation (default 1 = AVERAGE); method to be used to aggregate identical (time) values.") +}; + +// -=*# Resource for function FORECAST.ETS.STAT #*=- +const TranslateId SC_OPCODE_FORECAST_ETS_STA_ARY[] = +{ + NC_("SC_OPCODE_FORECAST_ETS_STA", "Returns statistical value(s) using additive Exponential Smoothing algorithm."), + NC_("SC_OPCODE_FORECAST_ETS_STA", "Values"), + NC_("SC_OPCODE_FORECAST_ETS_STA", "The data array from which you want to forecast."), + NC_("SC_OPCODE_FORECAST_ETS_STA", "Timeline"), + NC_("SC_OPCODE_FORECAST_ETS_STA", "The date or numeric array; a consistent step between values is needed."), + NC_("SC_OPCODE_FORECAST_ETS_STA", "Statistic type"), + NC_("SC_OPCODE_FORECAST_ETS_STA", "Value (1-9) or array of values, indicating which statistic will be returned for the calculated forecast"), + NC_("SC_OPCODE_FORECAST_ETS_STA", "Period length"), + NC_("SC_OPCODE_FORECAST_ETS_STA", "Number of Samples in Period (default 1); length of the seasonal pattern."), + NC_("SC_OPCODE_FORECAST_ETS_STA", "Data completion"), + NC_("SC_OPCODE_FORECAST_ETS_STA", "Data completion (default 1); 0 treats missing points as zero, 1 interpolates."), + NC_("SC_OPCODE_FORECAST_ETS_STA", "Aggregation"), + NC_("SC_OPCODE_FORECAST_ETS_STA", "Aggregation (default 1 = AVERAGE); method to be used to aggregate identical (time) values.") +}; + +// -=*# Resource for function FORECAST.ETS.STAT.MULT #*=- +const TranslateId SC_OPCODE_FORECAST_ETS_STM_ARY[] = +{ + NC_("SC_OPCODE_FORECAST_ETS_STM", "Returns statistical value(s) using multiplicative Exponential Smoothing algorithm."), + NC_("SC_OPCODE_FORECAST_ETS_STM", "Values"), + NC_("SC_OPCODE_FORECAST_ETS_STM", "The data array from which you want to forecast."), + NC_("SC_OPCODE_FORECAST_ETS_STM", "Timeline"), + NC_("SC_OPCODE_FORECAST_ETS_STM", "The date or numeric array; a consistent step between values is needed."), + NC_("SC_OPCODE_FORECAST_ETS_STM", "Statistic type"), + NC_("SC_OPCODE_FORECAST_ETS_STM", "Value (1-9) or array of values, indicating which statistic will be returned for the calculated forecast"), + NC_("SC_OPCODE_FORECAST_ETS_STM", "Period length"), + NC_("SC_OPCODE_FORECAST_ETS_STM", "Number of samples in period (default 1); length of the seasonal pattern."), + NC_("SC_OPCODE_FORECAST_ETS_STM", "Data completion"), + NC_("SC_OPCODE_FORECAST_ETS_STM", "Data completion (default 1); 0 treats missing points as zero, 1 interpolates."), + NC_("SC_OPCODE_FORECAST_ETS_STM", "Aggregation"), + NC_("SC_OPCODE_FORECAST_ETS_STM", "Aggregation (default 1 = AVERAGE); method to be used to aggregate identical (time) values.") +}; + +// -=*# Resource for function FORECAST.LINEAR #*=- +const TranslateId SC_OPCODE_FORECAST_LIN_ARY[] = +{ + NC_("SC_OPCODE_FORECAST_LIN", "Returns a value along a linear regression"), + NC_("SC_OPCODE_FORECAST_LIN", "Value"), + NC_("SC_OPCODE_FORECAST_LIN", "The X value for which the Y value on the regression linear is to be calculated."), + NC_("SC_OPCODE_FORECAST_LIN", "Data Y"), + NC_("SC_OPCODE_FORECAST_LIN", "The Y data array."), + NC_("SC_OPCODE_FORECAST_LIN", "Data X"), + NC_("SC_OPCODE_FORECAST_LIN", "The X data array.") +}; + +// -=*# Resource for function ADDRESS #*=- +const TranslateId SC_OPCODE_ADDRESS_ARY[] = +{ + NC_("SC_OPCODE_ADDRESS", "Returns the reference to a cell as text."), + NC_("SC_OPCODE_ADDRESS", "Row"), + NC_("SC_OPCODE_ADDRESS", "The row number of the cell."), + NC_("SC_OPCODE_ADDRESS", "Column"), + NC_("SC_OPCODE_ADDRESS", "The column number of the cell."), + NC_("SC_OPCODE_ADDRESS", "ABS"), + NC_("SC_OPCODE_ADDRESS", "Specifies whether absolute or relative referencing is to be used."), + NC_("SC_OPCODE_ADDRESS", "A1"), + NC_("SC_OPCODE_ADDRESS", "The reference style: 0 or FALSE means R1C1 style, any other value or omitted means A1 style."), + NC_("SC_OPCODE_ADDRESS", "Sheet"), + NC_("SC_OPCODE_ADDRESS", "The spreadsheet name of the cell reference.") +}; + +// -=*# Resource for function AREAS #*=- +const TranslateId SC_OPCODE_AREAS_ARY[] = +{ + NC_("SC_OPCODE_AREAS", "Returns the number of individual ranges that belong to a (multiple) range."), + NC_("SC_OPCODE_AREAS", "Reference"), + NC_("SC_OPCODE_AREAS", "The reference to a (multiple) range.") +}; + +// -=*# Resource for function CHOOSE #*=- +const TranslateId SC_OPCODE_CHOOSE_ARY[] = +{ + NC_("SC_OPCODE_CHOOSE", "Selects a value from a list of up to 30 value arguments."), + NC_("SC_OPCODE_CHOOSE", "Index"), + NC_("SC_OPCODE_CHOOSE", "The index of the value (1..30) selected."), + NC_("SC_OPCODE_CHOOSE", "Value "), + NC_("SC_OPCODE_CHOOSE", "Value 1, value 2,... The list of arguments from which a value is chosen.") +}; + +// -=*# Resource for function COLUMNS #*=- +const TranslateId SC_OPCODE_COLUMN_ARY[] = +{ + NC_("SC_OPCODE_COLUMN", "Returns the internal column number of a reference."), + NC_("SC_OPCODE_COLUMN", "Reference"), + NC_("SC_OPCODE_COLUMN", "The reference to a cell or a range.") +}; + +// -=*# Resource for function ROW #*=- +const TranslateId SC_OPCODE_ROW_ARY[] = +{ + NC_("SC_OPCODE_ROW", "Defines the internal row number of a reference."), + NC_("SC_OPCODE_ROW", "Reference"), + NC_("SC_OPCODE_ROW", "The reference to a cell or a range.") +}; + +// -=*# Resource for function SHEET #*=- +const TranslateId SC_OPCODE_SHEET_ARY[] = +{ + NC_("SC_OPCODE_SHEET", "Returns the internal sheet number of a reference or a string."), + NC_("SC_OPCODE_SHEET", "Reference"), + NC_("SC_OPCODE_SHEET", "The reference to a cell or a range or the character string of a sheet name.") +}; + +// -=*# Resource for function COLUMNS #*=- +const TranslateId SC_OPCODE_COLUMNS_ARY[] = +{ + NC_("SC_OPCODE_COLUMNS", "Returns the number of columns in an array or reference."), + NC_("SC_OPCODE_COLUMNS", "Array"), + NC_("SC_OPCODE_COLUMNS", "The array (reference) for which the number of columns is to be determined.") +}; + +// -=*# Resource for function ROWS #*=- +const TranslateId SC_OPCODE_ROWS_ARY[] = +{ + NC_("SC_OPCODE_ROWS", "Returns the number of rows in a reference or array."), + NC_("SC_OPCODE_ROWS", "Array"), + NC_("SC_OPCODE_ROWS", "The array (reference) for which the number of rows is to be determined.") +}; + +// -=*# Resource for function SHEETS #*=- +const TranslateId SC_OPCODE_SHEETS_ARY[] = +{ + NC_("SC_OPCODE_SHEETS", "Returns the number of sheets of a given reference. If no parameter has been entered, the total number of sheets in the document is returned."), + NC_("SC_OPCODE_SHEETS", "Reference"), + NC_("SC_OPCODE_SHEETS", "The reference to a cell or a range.") +}; + +// -=*# Resource for function HLOOKUP #*=- +const TranslateId SC_OPCODE_H_LOOKUP_ARY[] = +{ + NC_("SC_OPCODE_H_LOOKUP", "Horizontal search and reference to the cells located below."), + NC_("SC_OPCODE_H_LOOKUP", "Search criterion"), + NC_("SC_OPCODE_H_LOOKUP", "The value to be found in the first row."), + NC_("SC_OPCODE_H_LOOKUP", "Array"), + NC_("SC_OPCODE_H_LOOKUP", "The array or the range for the reference."), + NC_("SC_OPCODE_H_LOOKUP", "Index"), + NC_("SC_OPCODE_H_LOOKUP", "The row index in the array."), + NC_("SC_OPCODE_H_LOOKUP", "Sorted range lookup"), + NC_("SC_OPCODE_H_LOOKUP", "If the value is TRUE or not given, the search row of the array represents a series of ranges, and must be sorted in ascending order.") +}; + +// -=*# Resource for function VLOOKUP #*=- +const TranslateId SC_OPCODE_V_LOOKUP_ARY[] = +{ + NC_("SC_OPCODE_V_LOOKUP", "Vertical search and reference to indicated cells."), + NC_("SC_OPCODE_V_LOOKUP", "Search criterion"), + NC_("SC_OPCODE_V_LOOKUP", "The value to be found in the first column."), + NC_("SC_OPCODE_V_LOOKUP", "Array"), + NC_("SC_OPCODE_V_LOOKUP", "The array or range for referencing."), + NC_("SC_OPCODE_V_LOOKUP", "Index"), + NC_("SC_OPCODE_V_LOOKUP", "Column index number in the array."), + NC_("SC_OPCODE_V_LOOKUP", "Sorted range lookup"), + NC_("SC_OPCODE_V_LOOKUP", "If the value is TRUE or not given, the search column of the array represents a series of ranges, and must be sorted in ascending order.") +}; + +// -=*# Resource for function INDEX #*=- +const TranslateId SC_OPCODE_INDEX_ARY[] = +{ + NC_("SC_OPCODE_INDEX", "Returns a reference to a cell from a defined range."), + NC_("SC_OPCODE_INDEX", "Reference"), + NC_("SC_OPCODE_INDEX", "The reference to a (multiple) range."), + NC_("SC_OPCODE_INDEX", "Row"), + NC_("SC_OPCODE_INDEX", "The row in the range."), + NC_("SC_OPCODE_INDEX", "Column"), + NC_("SC_OPCODE_INDEX", "The column in the range."), + NC_("SC_OPCODE_INDEX", "Range"), + NC_("SC_OPCODE_INDEX", "The index of the subrange if referring to a multiple range.") +}; + +// -=*# Resource for function INDIRECT #*=- +const TranslateId SC_OPCODE_INDIRECT_ARY[] = +{ + NC_("SC_OPCODE_INDIRECT", "Returns the contents of a cell that is referenced in text form."), + NC_("SC_OPCODE_INDIRECT", "Reference"), + NC_("SC_OPCODE_INDIRECT", "The cell whose contents are to be evaluated is to be referenced in text form (e.g. \"A1\")."), + NC_("SC_OPCODE_INDIRECT", "A1"), + NC_("SC_OPCODE_INDIRECT", "The reference style: 0 or FALSE means R1C1 style, any other value or omitted means A1 style.") +}; + +// -=*# Resource for function LOOKUP #*=- +const TranslateId SC_OPCODE_LOOKUP_ARY[] = +{ + NC_("SC_OPCODE_LOOKUP", "Determines a value in a vector by comparison to values in another vector."), + NC_("SC_OPCODE_LOOKUP", "Search criterion"), + NC_("SC_OPCODE_LOOKUP", "The value to be used for comparison."), + NC_("SC_OPCODE_LOOKUP", "Search vector"), + NC_("SC_OPCODE_LOOKUP", "The vector (row or column) in which to search."), + NC_("SC_OPCODE_LOOKUP", "Result vector"), + NC_("SC_OPCODE_LOOKUP", "The vector (row or range) from which the value is to be determined.") +}; + +// -=*# Resource for function MATCH #*=- +const TranslateId SC_OPCODE_MATCH_ARY[] = +{ + NC_("SC_OPCODE_MATCH", "Defines a position in an array after comparing values."), + NC_("SC_OPCODE_MATCH", "Search criterion"), + NC_("SC_OPCODE_MATCH", "The value to be used for comparison."), + NC_("SC_OPCODE_MATCH", "Lookup array"), + NC_("SC_OPCODE_MATCH", "The array (range) in which the search is made."), + NC_("SC_OPCODE_MATCH", "Type"), + NC_("SC_OPCODE_MATCH", "Type can take the value 1 (first column array ascending), 0 (exact match or wildcard or regular expression match) or -1 (first column array descending) and determines the criteria to be used for comparison purposes.") +}; + +// -=*# Resource for function OFFSET #*=- +const TranslateId SC_OPCODE_OFFSET_ARY[] = +{ + NC_("SC_OPCODE_OFFSET", "Returns a reference which has been moved in relation to the starting point."), + NC_("SC_OPCODE_OFFSET", "Reference"), + NC_("SC_OPCODE_OFFSET", "The reference (cell) from which to base the movement."), + NC_("SC_OPCODE_OFFSET", "Rows"), + NC_("SC_OPCODE_OFFSET", "The number of rows to be moved either up or down."), + NC_("SC_OPCODE_OFFSET", "Columns"), + NC_("SC_OPCODE_OFFSET", "The number of columns that are to be moved to the left or to the right."), + NC_("SC_OPCODE_OFFSET", "Height"), + NC_("SC_OPCODE_OFFSET", "The number of rows of the moved reference."), + NC_("SC_OPCODE_OFFSET", "Width"), + NC_("SC_OPCODE_OFFSET", "The number of columns in the moved reference.") +}; + +// -=*# Resource for function ERRORTYPE #*=- +const TranslateId SC_OPCODE_ERROR_TYPE_ARY[] = +{ + NC_("SC_OPCODE_ERROR_TYPE", "Returns a number corresponding to an error type"), + NC_("SC_OPCODE_ERROR_TYPE", "Reference"), + NC_("SC_OPCODE_ERROR_TYPE", "The reference (cell) in which the error occurred.") +}; + +// -=*# Resource for function ERROR.TYPE #*=- +const TranslateId SC_OPCODE_ERROR_TYPE_ODF_ARY[] = +{ + NC_("SC_OPCODE_ERROR_TYPE_ODF", "Returns a number corresponding to one of the error values or #N/A if no error exists"), + NC_("SC_OPCODE_ERROR_TYPE_ODF", "Expression"), + NC_("SC_OPCODE_ERROR_TYPE_ODF", "The error value whose identifying number you want to find. Can be the actual error value or a reference to a cell that you want to test.") +}; + +// -=*# Resource for function STYLE #*=- +const TranslateId SC_OPCODE_STYLE_ARY[] = +{ + NC_("SC_OPCODE_STYLE", "Applies a Style to the formula cell."), + NC_("SC_OPCODE_STYLE", "Style"), + NC_("SC_OPCODE_STYLE", "The name of the Style to be applied."), + NC_("SC_OPCODE_STYLE", "Time"), + NC_("SC_OPCODE_STYLE", "The time (in seconds) that the Style is to remain valid."), + NC_("SC_OPCODE_STYLE", "Style 2"), + NC_("SC_OPCODE_STYLE", "The style to be applied after time expires.") +}; + +// -=*# Resource for function DDE #*=- +const TranslateId SC_OPCODE_DDE_ARY[] = +{ + NC_("SC_OPCODE_DDE", "Result of a DDE link."), + NC_("SC_OPCODE_DDE", "Server"), + NC_("SC_OPCODE_DDE", "The name of the server application."), + NC_("SC_OPCODE_DDE", "Topic/file"), + NC_("SC_OPCODE_DDE", "The topic or name of the file."), + NC_("SC_OPCODE_DDE", "Item/range"), + NC_("SC_OPCODE_DDE", "The item or range from which data is to be taken."), + NC_("SC_OPCODE_DDE", "Mode"), + NC_("SC_OPCODE_DDE", "Defines how data is to be converted to numbers.") +}; + +// -=*# Resource for function HYPERLINK #*=- +const TranslateId SC_OPCODE_HYPERLINK_ARY[] = +{ + NC_("SC_OPCODE_HYPERLINK", "Construct a Hyperlink."), + NC_("SC_OPCODE_HYPERLINK", "URL"), + NC_("SC_OPCODE_HYPERLINK", "The clickable URL."), + NC_("SC_OPCODE_HYPERLINK", "Cell text"), + NC_("SC_OPCODE_HYPERLINK", "The cell text to be displayed.") +}; + +// -=*# Resource for function GETPIVOTDATA #*=- +const TranslateId SC_OPCODE_GET_PIVOT_DATA_ARY[] = +{ + NC_("SC_OPCODE_GET_PIVOT_DATA", "Extracts value(s) from a pivot table."), + NC_("SC_OPCODE_GET_PIVOT_DATA", "Data field"), + NC_("SC_OPCODE_GET_PIVOT_DATA", "The name of the pivot table field to extract."), + NC_("SC_OPCODE_GET_PIVOT_DATA", "Pivot table"), + NC_("SC_OPCODE_GET_PIVOT_DATA", "A reference to a cell or range in the pivot table."), + NC_("SC_OPCODE_GET_PIVOT_DATA", "Field name / item"), + NC_("SC_OPCODE_GET_PIVOT_DATA", "Field name/value pair to filter the target data.") +}; + +// -=*# Resource for function BAHTTEXT #*=- +const TranslateId SC_OPCODE_BAHTTEXT_ARY[] = +{ + NC_("SC_OPCODE_BAHTTEXT", "Converts a number to text (Baht)."), + NC_("SC_OPCODE_BAHTTEXT", "Number"), + NC_("SC_OPCODE_BAHTTEXT", "The number to convert.") +}; + +// -=*# Resource for function JIS #*=- +const TranslateId SC_OPCODE_JIS_ARY[] = +{ + NC_("SC_OPCODE_JIS", "Converts half-width ASCII and katakana characters to full-width."), + NC_("SC_OPCODE_JIS", "Text"), + NC_("SC_OPCODE_JIS", "The text to convert.") +}; + +// -=*# Resource for function ASC #*=- +const TranslateId SC_OPCODE_ASC_ARY[] = +{ + NC_("SC_OPCODE_ASC", "Converts full-width ASCII and katakana characters to half-width."), + NC_("SC_OPCODE_ASC", "Text"), + NC_("SC_OPCODE_ASC", "The text to convert.") +}; + +// -=*# Resource for function CODE #*=- +const TranslateId SC_OPCODE_CODE_ARY[] = +{ + NC_("SC_OPCODE_CODE", "Returns a numeric code for the first character in a text string."), + NC_("SC_OPCODE_CODE", "Text"), + NC_("SC_OPCODE_CODE", "This is the text for which the code of the first character is to be found.") +}; + +// -=*# Resource for function DOLLAR #*=- +const TranslateId SC_OPCODE_CURRENCY_ARY[] = +{ + NC_("SC_OPCODE_CURRENCY", "Converts a number to text in currency format."), + NC_("SC_OPCODE_CURRENCY", "Value"), + NC_("SC_OPCODE_CURRENCY", "Value is a number, a reference to a cell containing a number or a formula that results in a number."), + NC_("SC_OPCODE_CURRENCY", "Decimals"), + NC_("SC_OPCODE_CURRENCY", "Decimal places. Denotes the number of digits to the right of the decimal point.") +}; + +// -=*# Resource for function CHAR #*=- +const TranslateId SC_OPCODE_CHAR_ARY[] = +{ + NC_("SC_OPCODE_CHAR", "Converts a code number into a character or letter."), + NC_("SC_OPCODE_CHAR", "Number"), + NC_("SC_OPCODE_CHAR", "The code value for the character.") +}; + +// -=*# Resource for function CLEAN #*=- +const TranslateId SC_OPCODE_CLEAN_ARY[] = +{ + NC_("SC_OPCODE_CLEAN", "Removes all nonprintable characters from text."), + NC_("SC_OPCODE_CLEAN", "Text"), + NC_("SC_OPCODE_CLEAN", "The text from which nonprintable characters are to be removed.") +}; + +// -=*# Resource for function CONCATENATE #*=- +const TranslateId SC_OPCODE_CONCAT_ARY[] = +{ + NC_("SC_OPCODE_CONCAT", "Combines several text items into one."), + NC_("SC_OPCODE_CONCAT", "Text"), + NC_("SC_OPCODE_CONCAT", "Text for the concatenation.") +}; + +// -=*# Resource for function CONCAT #*=- +const TranslateId SC_OPCODE_CONCAT_MS_ARY[] = +{ + NC_("SC_OPCODE_CONCAT_MS", "Combines several text items into one, accepts cell ranges as arguments."), + NC_("SC_OPCODE_CONCAT_MS", "Text"), + NC_("SC_OPCODE_CONCAT_MS", "Text and/or cell ranges for the concatenation.") +}; + +// -=*# Resource for function TEXTJOIN #*=- +const TranslateId SC_OPCODE_TEXTJOIN_MS_ARY[] = +{ + NC_("SC_OPCODE_TEXTJOIN_MS", "Combines several text items into one, accepts cell ranges as arguments. Uses delimiter between items."), + NC_("SC_OPCODE_TEXTJOIN_MS", "Delimiter"), + NC_("SC_OPCODE_TEXTJOIN_MS", "Text string to be used as delimiter."), + NC_("SC_OPCODE_TEXTJOIN_MS", "Skip empty cells"), + NC_("SC_OPCODE_TEXTJOIN_MS", "If TRUE, empty cells will be ignored."), + NC_("SC_OPCODE_TEXTJOIN_MS", "Text"), + NC_("SC_OPCODE_TEXTJOIN_MS", "Text and/or cell ranges for the concatenation.") +}; + +// -=*# Resource for function IFS #*=- +const TranslateId SC_OPCODE_IFS_MS_ARY[] = +{ + NC_("SC_OPCODE_IFS_MS", "Checks 1 or more conditions and returns a value corresponding to the first true condition."), + NC_("SC_OPCODE_IFS_MS", "Test"), + NC_("SC_OPCODE_IFS_MS", "Any value or expression which can be either TRUE or FALSE."), + NC_("SC_OPCODE_IFS_MS", "Result"), + NC_("SC_OPCODE_IFS_MS", "The result of the function if test is TRUE.") +}; + +// -=*# Resource for function SWITCH #*=- +const TranslateId SC_OPCODE_SWITCH_MS_ARY[] = +{ + NC_("SC_OPCODE_SWITCH_MS", "Compares expression against list of value/result pairs, and returns result for first value that matches the expression. If expression does not match any value, a default result is returned, if it is placed as final item in parameter list without a value."), + NC_("SC_OPCODE_SWITCH_MS", "Expression"), + NC_("SC_OPCODE_SWITCH_MS", "Value to be compared against value1…valueN (N ≤ 127)"), + NC_("SC_OPCODE_SWITCH_MS", "Value"), + NC_("SC_OPCODE_SWITCH_MS", "Value to compare against expression. If no result is given, then value is returned as default result."), + NC_("SC_OPCODE_SWITCH_MS", "Result"), + NC_("SC_OPCODE_SWITCH_MS", "Value to return when corresponding value argument matches expression.") +}; + +const TranslateId SC_OPCODE_MINIFS_MS_ARY[] = +{ + NC_("SC_OPCODE_MINIFS_MS", "Returns the minimum value in a range that meet multiple criteria in multiple ranges."), + NC_("SC_OPCODE_MINIFS_MS", "Min range"), + NC_("SC_OPCODE_MINIFS_MS", "The range from which the minimum will be determined."), + NC_("SC_OPCODE_MINIFS_MS", "Range "), + NC_("SC_OPCODE_MINIFS_MS", "Range 1, range 2,... are the ranges to be evaluated by the criteria given."), + NC_("SC_OPCODE_MINIFS_MS", "Criteria "), + NC_("SC_OPCODE_MINIFS_MS", "Criteria 1, criteria 2,... are the criteria to be applied to the ranges given.") +}; + +const TranslateId SC_OPCODE_MAXIFS_MS_ARY[] = +{ + NC_("SC_OPCODE_MAXIFS_MS", "Returns the maximum value in a range that meet multiple criteria in multiple ranges."), + NC_("SC_OPCODE_MAXIFS_MS", "Max range"), + NC_("SC_OPCODE_MAXIFS_MS", "The range from which the maximum will be determined."), + NC_("SC_OPCODE_MAXIFS_MS", "Range "), + NC_("SC_OPCODE_MAXIFS_MS", "Range 1, range 2,... are the ranges to be evaluated by the criteria given."), + NC_("SC_OPCODE_MAXIFS_MS", "Criteria "), + NC_("SC_OPCODE_MAXIFS_MS", "Criteria 1, criteria 2,... are the criteria to be applied to the ranges given.") +}; + +// -=*# Resource for function EXACT #*=- +const TranslateId SC_OPCODE_EXACT_ARY[] = +{ + NC_("SC_OPCODE_EXACT", "Specifies whether two texts are identical."), + NC_("SC_OPCODE_EXACT", "Text 1"), + NC_("SC_OPCODE_EXACT", "The first text to be used for comparing texts."), + NC_("SC_OPCODE_EXACT", "Text 2"), + NC_("SC_OPCODE_EXACT", "The second text for comparing texts.") +}; + +// -=*# Resource for function FIND #*=- +const TranslateId SC_OPCODE_FIND_ARY[] = +{ + NC_("SC_OPCODE_FIND", "Looks for a string of text within another (case sensitive)"), + NC_("SC_OPCODE_FIND", "Find text"), + NC_("SC_OPCODE_FIND", "The text to be found."), + NC_("SC_OPCODE_FIND", "Text"), + NC_("SC_OPCODE_FIND", "The text in which a search is to be made."), + NC_("SC_OPCODE_FIND", "Position"), + NC_("SC_OPCODE_FIND", "The position in the text from which the search starts.") +}; + +// -=*# Resource for function SEARCH #*=- +const TranslateId SC_OPCODE_SEARCH_ARY[] = +{ + NC_("SC_OPCODE_SEARCH", "Looks for one text value within another (not case-sensitive)."), + NC_("SC_OPCODE_SEARCH", "Find text"), + NC_("SC_OPCODE_SEARCH", "The text to be found."), + NC_("SC_OPCODE_SEARCH", "Text"), + NC_("SC_OPCODE_SEARCH", "The text in which a search is to be made."), + NC_("SC_OPCODE_SEARCH", "Position"), + NC_("SC_OPCODE_SEARCH", "The position in the text where the search is started.") +}; + +// -=*# Resource for function TRIM #*=- +const TranslateId SC_OPCODE_TRIM_ARY[] = +{ + NC_("SC_OPCODE_TRIM", "Removes extra spaces from text."), + NC_("SC_OPCODE_TRIM", "Text"), + NC_("SC_OPCODE_TRIM", "The text in which extra spaces between words are to be deleted.") +}; + +// -=*# Resource for function PROPER #*=- +const TranslateId SC_OPCODE_PROPER_ARY[] = +{ + NC_("SC_OPCODE_PROPER", "Capitalizes the first letter in all words."), + NC_("SC_OPCODE_PROPER", "Text"), + NC_("SC_OPCODE_PROPER", "The text in which the beginning of words are to be replaced by capital letters.") +}; + +// -=*# Resource for function UPPER #*=- +const TranslateId SC_OPCODE_UPPER_ARY[] = +{ + NC_("SC_OPCODE_UPPER", "Converts text to uppercase."), + NC_("SC_OPCODE_UPPER", "Text"), + NC_("SC_OPCODE_UPPER", "The text in which lower case letters are to be converted to capitals.") +}; + +// -=*# Resource for function LOWER #*=- +const TranslateId SC_OPCODE_LOWER_ARY[] = +{ + NC_("SC_OPCODE_LOWER", "Converts text to lowercase."), + NC_("SC_OPCODE_LOWER", "Text"), + NC_("SC_OPCODE_LOWER", "The text in which capitals are converted to lower case letters.") +}; + +// -=*# Resource for function VALUE #*=- +const TranslateId SC_OPCODE_VALUE_ARY[] = +{ + NC_("SC_OPCODE_VALUE", "Converts text to a number."), + NC_("SC_OPCODE_VALUE", "Text"), + NC_("SC_OPCODE_VALUE", "The text to be converted to a number.") +}; + +// -=*# Resource for function TEXT #*=- +const TranslateId SC_OPCODE_TEXT_ARY[] = +{ + NC_("SC_OPCODE_TEXT", "Converts a number to text according to a given format."), + NC_("SC_OPCODE_TEXT", "Number"), + NC_("SC_OPCODE_TEXT", "The numeric value to be converted."), + NC_("SC_OPCODE_TEXT", "Format"), + NC_("SC_OPCODE_TEXT", "The text that describes the format.") +}; + +// -=*# Resource for function T #*=- +const TranslateId SC_OPCODE_T_ARY[] = +{ + NC_("SC_OPCODE_T", "Returns a value if it is text, otherwise an empty string."), + NC_("SC_OPCODE_T", "Value"), + NC_("SC_OPCODE_T", "The value to be checked and returned if it is text.") +}; + +// -=*# Resource for function REPLACE #*=- +const TranslateId SC_OPCODE_REPLACE_ARY[] = +{ + NC_("SC_OPCODE_REPLACE", "Replaces characters within a text string with a different text string."), + NC_("SC_OPCODE_REPLACE", "Text"), + NC_("SC_OPCODE_REPLACE", "The text in which some characters are to be replaced."), + NC_("SC_OPCODE_REPLACE", "Position"), + NC_("SC_OPCODE_REPLACE", "The character position from which text is to be replaced."), + NC_("SC_OPCODE_REPLACE", "Length"), + NC_("SC_OPCODE_REPLACE", "The number of characters to be replaced."), + NC_("SC_OPCODE_REPLACE", "New text"), + NC_("SC_OPCODE_REPLACE", "The text to be inserted.") +}; + +// -=*# Resource for function FIXED #*=- +const TranslateId SC_OPCODE_FIXED_ARY[] = +{ + NC_("SC_OPCODE_FIXED", "Formats a number with a fixed number of places after the decimal point and thousands separator."), + NC_("SC_OPCODE_FIXED", "Number"), + NC_("SC_OPCODE_FIXED", "The number to be formatted."), + NC_("SC_OPCODE_FIXED", "Decimals"), + NC_("SC_OPCODE_FIXED", "Decimal places. The number of fixed decimal places that are to be displayed. Default 2."), + NC_("SC_OPCODE_FIXED", "No thousands separators"), + NC_("SC_OPCODE_FIXED", "Thousands separator. If 0 or omitted the locale group separator is used else the separator is suppressed.") +}; + +// -=*# Resource for function LEN #*=- +const TranslateId SC_OPCODE_LEN_ARY[] = +{ + NC_("SC_OPCODE_LEN", "Calculates length of a text string."), + NC_("SC_OPCODE_LEN", "Text"), + NC_("SC_OPCODE_LEN", "The text in which the length is to be determined.") +}; + +// -=*# Resource for function LEFT #*=- +const TranslateId SC_OPCODE_LEFT_ARY[] = +{ + NC_("SC_OPCODE_LEFT", "Returns the first character or characters of a text."), + NC_("SC_OPCODE_LEFT", "Text"), + NC_("SC_OPCODE_LEFT", "The text where the initial partial words are to be determined."), + NC_("SC_OPCODE_LEFT", "Number"), + NC_("SC_OPCODE_LEFT", "The number of characters for the start text.") +}; + +// -=*# Resource for function RIGHT #*=- +const TranslateId SC_OPCODE_RIGHT_ARY[] = +{ + NC_("SC_OPCODE_RIGHT", "Returns the last character or characters of a text."), + NC_("SC_OPCODE_RIGHT", "Text"), + NC_("SC_OPCODE_RIGHT", "The text in which the end partial words are to be determined."), + NC_("SC_OPCODE_RIGHT", "Number"), + NC_("SC_OPCODE_RIGHT", "The number of characters for the end text.") +}; + +// -=*# Resource for function MID #*=- +const TranslateId SC_OPCODE_MID_ARY[] = +{ + NC_("SC_OPCODE_MID", "Returns a partial text string of a text."), + NC_("SC_OPCODE_MID", "Text"), + NC_("SC_OPCODE_MID", "The text in which partial words are to be determined."), + NC_("SC_OPCODE_MID", "Start"), + NC_("SC_OPCODE_MID", "The position from which the part word is to be determined."), + NC_("SC_OPCODE_MID", "Number"), + NC_("SC_OPCODE_MID", "The number of characters for the text.") +}; + +// -=*# Resource for function REPT #*=- +const TranslateId SC_OPCODE_REPT_ARY[] = +{ + NC_("SC_OPCODE_REPT", "Repeats text a given number of times."), + NC_("SC_OPCODE_REPT", "Text"), + NC_("SC_OPCODE_REPT", "The text to be repeated."), + NC_("SC_OPCODE_REPT", "Number"), + NC_("SC_OPCODE_REPT", "The number of times the text is to be repeated.") +}; + +// -=*# Resource for function SUBSTITUTE #*=- +const TranslateId SC_OPCODE_SUBSTITUTE_ARY[] = +{ + NC_("SC_OPCODE_SUBSTITUTE", "Substitutes new text for old text in a string."), + NC_("SC_OPCODE_SUBSTITUTE", "Text"), + NC_("SC_OPCODE_SUBSTITUTE", "The text in which partial words are to be replaced."), + NC_("SC_OPCODE_SUBSTITUTE", "Search text"), + NC_("SC_OPCODE_SUBSTITUTE", "The partial string to be (repeatedly) replaced."), + NC_("SC_OPCODE_SUBSTITUTE", "New text"), + NC_("SC_OPCODE_SUBSTITUTE", "The text which is to replace the text string."), + NC_("SC_OPCODE_SUBSTITUTE", "Occurrence"), + NC_("SC_OPCODE_SUBSTITUTE", "Which occurrence of the old text is to be replaced.") +}; + +// -=*# Resource for function REGEX #*=- +const TranslateId SC_OPCODE_REGEX_ARY[] = +{ + NC_("SC_OPCODE_REGEX", "Matches and extracts or optionally replaces text using regular expressions."), + NC_("SC_OPCODE_REGEX", "Text"), + NC_("SC_OPCODE_REGEX", "The text to be operated on."), + NC_("SC_OPCODE_REGEX", "Expression"), + NC_("SC_OPCODE_REGEX", "The regular expression pattern to be matched."), + NC_("SC_OPCODE_REGEX", "Replacement"), + NC_("SC_OPCODE_REGEX", "The replacement text and references to capture groups."), + NC_("SC_OPCODE_REGEX", "Flags or Occurrence"), + NC_("SC_OPCODE_REGEX", "Text specifying option flags, \"g\" for global replacement. Or number of occurrence to match or replace.") +}; + +// -=*# Resource for function BASE #*=- +const TranslateId SC_OPCODE_BASE_ARY[] = +{ + NC_("SC_OPCODE_BASE", "Converts a positive integer to text from a number system to the base defined."), + NC_("SC_OPCODE_BASE", "Number"), + NC_("SC_OPCODE_BASE", "The number to be converted."), + NC_("SC_OPCODE_BASE", "Radix"), + NC_("SC_OPCODE_BASE", "The base number for conversion must be in the range 2 - 36."), + NC_("SC_OPCODE_BASE", "Minimum length"), + NC_("SC_OPCODE_BASE", "If the text is shorter than the specified length, zeros are added to the left of the string.") +}; + +// -=*# Resource for function DECIMAL #*=- +const TranslateId SC_OPCODE_DECIMAL_ARY[] = +{ + NC_("SC_OPCODE_DECIMAL", "Converts a text of a specified number system to a positive integer in the base given."), + NC_("SC_OPCODE_DECIMAL", "Text"), + NC_("SC_OPCODE_DECIMAL", "The text to be converted."), + NC_("SC_OPCODE_DECIMAL", "Radix"), + NC_("SC_OPCODE_DECIMAL", "The base number for conversion must be in the range 2 - 36.") +}; + +// -=*# Resource for function CONVERT_OOO #*=- +const TranslateId SC_OPCODE_CONVERT_OOO_ARY[] = +{ + NC_("SC_OPCODE_CONVERT_OOO", "Converts a value according to a conversion table in the configuration (main.xcd)."), + NC_("SC_OPCODE_CONVERT_OOO", "Value"), + NC_("SC_OPCODE_CONVERT_OOO", "The value to be converted."), + NC_("SC_OPCODE_CONVERT_OOO", "Text"), + NC_("SC_OPCODE_CONVERT_OOO", "Unit from which something is converted, case-sensitive."), + NC_("SC_OPCODE_CONVERT_OOO", "Text"), + NC_("SC_OPCODE_CONVERT_OOO", "Unit into which something is converted, case-sensitive.") +}; + +// -=*# Resource for function ROMAN #*=- +const TranslateId SC_OPCODE_ROMAN_ARY[] = +{ + NC_("SC_OPCODE_ROMAN", "Converts a number to a Roman numeral."), + NC_("SC_OPCODE_ROMAN", "Number"), + NC_("SC_OPCODE_ROMAN", "The number to be converted to a Roman numeral must be in the 0 - 3999 range."), + NC_("SC_OPCODE_ROMAN", "Mode"), + NC_("SC_OPCODE_ROMAN", "The more this value increases, the more the Roman numeral is simplified. The value must be in the 0 - 4 range.") +}; + +// -=*# Resource for function ARABIC #*=- +const TranslateId SC_OPCODE_ARABIC_ARY[] = +{ + NC_("SC_OPCODE_ARABIC", "Calculates the value of a Roman numeral."), + NC_("SC_OPCODE_ARABIC", "Text"), + NC_("SC_OPCODE_ARABIC", "The text that represents a Roman numeral.") +}; + +const TranslateId SC_OPCODE_INFO_ARY[] = +{ + NC_("SC_OPCODE_INFO", "Returns information about the environment."), + NC_("SC_OPCODE_INFO", "Text"), + NC_("SC_OPCODE_INFO", "Can be \"osversion\", \"system\", \"release\", \"numfile\", and \"recalc\".") +}; + +const TranslateId SC_OPCODE_UNICODE_ARY[] = +{ + NC_("SC_OPCODE_UNICODE", "Returns the numeric code for the first Unicode character in a text string."), + NC_("SC_OPCODE_UNICODE", "Text"), + NC_("SC_OPCODE_UNICODE", "This is the text for which the code of the first character is to be found.") +}; + +const TranslateId SC_OPCODE_UNICHAR_ARY[] = +{ + NC_("SC_OPCODE_UNICHAR", "Converts a code number into a Unicode character or letter."), + NC_("SC_OPCODE_UNICHAR", "Number"), + NC_("SC_OPCODE_UNICHAR", "The code value for the character.") +}; + +const TranslateId SC_OPCODE_EUROCONVERT_ARY[] = +{ + NC_("SC_OPCODE_EUROCONVERT", "Converts a value from one to another Euro currency."), + NC_("SC_OPCODE_EUROCONVERT", "Value"), + NC_("SC_OPCODE_EUROCONVERT", "The value to be converted."), + NC_("SC_OPCODE_EUROCONVERT", "From currency"), + NC_("SC_OPCODE_EUROCONVERT", "ISO 4217 code of the currency from which is converted."), + NC_("SC_OPCODE_EUROCONVERT", "To currency"), + NC_("SC_OPCODE_EUROCONVERT", "ISO 4217 code of the currency into which is converted."), + NC_("SC_OPCODE_EUROCONVERT", "Full precision"), + NC_("SC_OPCODE_EUROCONVERT", "If omitted or 0 or FALSE, the result is rounded to the decimals of To_currency. Else the result is not rounded."), + NC_("SC_OPCODE_EUROCONVERT", "Triangulation precision"), + /* This description uses almost all available space in the dialog, make sure translations fit in size */ + NC_("SC_OPCODE_EUROCONVERT", "If given and >=3, the intermediate result of a triangular conversion is rounded to that precision. If omitted, the result is not rounded.") +}; + +const TranslateId SC_OPCODE_NUMBERVALUE_ARY[] = +{ + NC_("SC_OPCODE_NUMBERVALUE", "Converts text to a number, in a locale-independent way."), + NC_("SC_OPCODE_NUMBERVALUE", "Text"), + NC_("SC_OPCODE_NUMBERVALUE", "The text to be converted to a number."), + NC_("SC_OPCODE_NUMBERVALUE", "Decimal separator"), + NC_("SC_OPCODE_NUMBERVALUE", "Defines the character used as the decimal separator."), + NC_("SC_OPCODE_NUMBERVALUE", "Group separator"), + NC_("SC_OPCODE_NUMBERVALUE", "Defines the character(s) used as the group separator.") +}; + + +const TranslateId SC_OPCODE_BITAND_ARY[] = +{ + NC_("SC_OPCODE_BITAND", "Bitwise \"AND\" of two integers."), + NC_("SC_OPCODE_BITAND", "Number1"), + NC_("SC_OPCODE_BITAND", "Positive integer less than 2^48."), + NC_("SC_OPCODE_BITAND", "Number2"), + NC_("SC_OPCODE_BITAND", "Positive integer less than 2^48.") +}; + +const TranslateId SC_OPCODE_BITOR_ARY[] = +{ + NC_("SC_OPCODE_BITOR", "Bitwise \"OR\" of two integers."), + NC_("SC_OPCODE_BITOR", "Number1"), + NC_("SC_OPCODE_BITOR", "Positive integer less than 2^48."), + NC_("SC_OPCODE_BITOR", "Number2"), + NC_("SC_OPCODE_BITOR", "Positive integer less than 2^48.") +}; + +const TranslateId SC_OPCODE_BITXOR_ARY[] = +{ + NC_("SC_OPCODE_BITXOR", "Bitwise \"exclusive OR\" of two integers."), + NC_("SC_OPCODE_BITXOR", "Number1"), + NC_("SC_OPCODE_BITXOR", "Positive integer less than 2^48."), + NC_("SC_OPCODE_BITXOR", "Number2"), + NC_("SC_OPCODE_BITXOR", "Positive integer less than 2^48.") +}; + +const TranslateId SC_OPCODE_BITRSHIFT_ARY[] = +{ + NC_("SC_OPCODE_BITRSHIFT", "Bitwise right shift of an integer value."), + NC_("SC_OPCODE_BITRSHIFT", "Number"), + NC_("SC_OPCODE_BITRSHIFT", "The value to be shifted. Positive integer less than 2^48."), + NC_("SC_OPCODE_BITRSHIFT", "Shift"), + NC_("SC_OPCODE_BITRSHIFT", "The integer number of bits the value is to be shifted.") +}; + +const TranslateId SC_OPCODE_BITLSHIFT_ARY[] = +{ + NC_("SC_OPCODE_BITLSHIFT", "Bitwise left shift of an integer value."), + NC_("SC_OPCODE_BITLSHIFT", "Number"), + NC_("SC_OPCODE_BITLSHIFT", "The value to be shifted. Positive integer less than 2^48."), + NC_("SC_OPCODE_BITLSHIFT", "Shift"), + NC_("SC_OPCODE_BITLSHIFT", "The integer number of bits the value is to be shifted.") +}; + +const TranslateId SC_OPCODE_LENB_ARY[] = +{ + NC_("SC_OPCODE_LENB", "Calculates length of a text string, with DBCS"), + NC_("SC_OPCODE_LENB", "Text"), + NC_("SC_OPCODE_LENB", "The text in which the length is to be determined.") +}; + +const TranslateId SC_OPCODE_RIGHTB_ARY[] = +{ + NC_("SC_OPCODE_RIGHTB", "Returns the last character or characters of a text,with DBCS"), + NC_("SC_OPCODE_RIGHTB", "Text"), + NC_("SC_OPCODE_RIGHTB", "The text in which the end partial words are to be determined."), + NC_("SC_OPCODE_RIGHTB", "Number"), + NC_("SC_OPCODE_RIGHTB", "The number of characters for the end text.") +}; + +const TranslateId SC_OPCODE_LEFTB_ARY[] = +{ + NC_("SC_OPCODE_LEFTB", "Returns the first character or characters of a text,with DBCS"), + NC_("SC_OPCODE_LEFTB", "Text"), + NC_("SC_OPCODE_LEFTB", "The text where the initial partial words are to be determined."), + NC_("SC_OPCODE_LEFTB", "Number"), + NC_("SC_OPCODE_LEFTB", "The number of characters for the start text.") +}; + +const TranslateId SC_OPCODE_MIDB_ARY[] = +{ + NC_("SC_OPCODE_MIDB", "Returns a partial text string of a text, with DBCS"), + NC_("SC_OPCODE_MIDB", "Text"), + NC_("SC_OPCODE_MIDB", "The text in which partial words are to be determined."), + NC_("SC_OPCODE_MIDB", "Start"), + NC_("SC_OPCODE_MIDB", "The position from which the part word is to be determined."), + NC_("SC_OPCODE_MIDB", "Number"), + NC_("SC_OPCODE_MIDB", "The number of characters for the text.") +}; + +const TranslateId SC_OPCODE_FILTERXML_ARY[] = +{ + NC_("SC_OPCODE_FILTERXML", "Apply an XPath expression to an XML document"), + NC_("SC_OPCODE_FILTERXML", "XML Document"), + NC_("SC_OPCODE_FILTERXML", "String containing a valid XML stream"), + NC_("SC_OPCODE_FILTERXML", "XPath expression"), + NC_("SC_OPCODE_FILTERXML", "String containing a valid XPath expression") +}; + +const TranslateId SC_OPCODE_COLOR_ARY[] = +{ + NC_("SC_OPCODE_COLOR", "Returns an implementation defined value representing a RGBA color"), + NC_("SC_OPCODE_COLOR", "Red"), + NC_("SC_OPCODE_COLOR", "Value of red"), + NC_("SC_OPCODE_COLOR", "Green"), + NC_("SC_OPCODE_COLOR", "Value of green"), + NC_("SC_OPCODE_COLOR", "Blue"), + NC_("SC_OPCODE_COLOR", "Value of blue"), + NC_("SC_OPCODE_COLOR", "Alpha"), + NC_("SC_OPCODE_COLOR", "Value of alpha") +}; + +const TranslateId SC_OPCODE_WEBSERVICE_ARY[] = +{ + NC_("SC_OPCODE_WEBSERVICE", "Get some web-content from a URI."), + NC_("SC_OPCODE_WEBSERVICE", "URI"), + NC_("SC_OPCODE_WEBSERVICE", "URI of the webservice") +}; + +const TranslateId SC_OPCODE_ENCODEURL_ARY[] = +{ + NC_("SC_OPCODE_ENCODEURL", "Return a URL-encoded string."), + NC_("SC_OPCODE_ENCODEURL", "Text"), + NC_("SC_OPCODE_ENCODEURL", "A string to be URL-encoded") +}; + +const TranslateId SC_OPCODE_ERF_MS_ARY[] = +{ + NC_("SC_OPCODE_ERF_MS", "Returns the error function."), + NC_("SC_OPCODE_ERF_MS", "Lower limit"), + NC_("SC_OPCODE_ERF_MS", "The lower limit for integration") +}; + +const TranslateId SC_OPCODE_ERFC_MS_ARY[] = +{ + NC_("SC_OPCODE_ERFC_MS", "Returns the complementary error function."), + NC_("SC_OPCODE_ERFC_MS", "Lower limit"), + NC_("SC_OPCODE_ERFC_MS", "The lower limit for integration") +}; + +const TranslateId SC_OPCODE_RAWSUBTRACT_ARY[] = +{ + NC_("SC_OPCODE_RAWSUBTRACT", "Returns the subtraction of numbers. Like a-b-c but without eliminating small roundoff errors."), + NC_("SC_OPCODE_RAWSUBTRACT", "Minuend"), + NC_("SC_OPCODE_RAWSUBTRACT", "Number from which following arguments are subtracted."), + NC_("SC_OPCODE_RAWSUBTRACT", "Subtrahend "), + NC_("SC_OPCODE_RAWSUBTRACT", "Subtrahend 1, subtrahend 2, ... are numerical arguments subtracted from the minuend.") +}; + +// -=*# Resource for function ROUNDSIG #*=- +const TranslateId SC_OPCODE_ROUNDSIG_ARY[] = +{ + NC_("SC_OPCODE_ROUNDSIG", "Rounds a number to predefined significant digits."), + NC_("SC_OPCODE_ROUNDSIG", "Value"), + NC_("SC_OPCODE_ROUNDSIG", "The number to be rounded."), + NC_("SC_OPCODE_ROUNDSIG", "Digits"), + NC_("SC_OPCODE_ROUNDSIG", "The number of significant digits to which value is to be rounded.") +}; + +const TranslateId SC_OPCODE_REPLACEB_ARY[] = +{ + NC_("SC_OPCODE_REPLACEB", "Replaces characters within a text string with a different text string, with DBCS."), + NC_("SC_OPCODE_REPLACEB", "Text"), + NC_("SC_OPCODE_REPLACEB", "The text in which some characters are to be replaced."), + NC_("SC_OPCODE_REPLACEB", "Position"), + NC_("SC_OPCODE_REPLACEB", "The character position from which text is to be replaced."), + NC_("SC_OPCODE_REPLACEB", "Length"), + NC_("SC_OPCODE_REPLACEB", "The number of characters to be replaced."), + NC_("SC_OPCODE_REPLACEB", "New text"), + NC_("SC_OPCODE_REPLACEB", "The text to be inserted.") +}; + + // -=*# Resource for function FINDB #*=- +const TranslateId SC_OPCODE_FINDB_ARY[] = +{ + NC_("SC_OPCODE_FINDB", "Looks for a string of text within another (case sensitive), using byte positions."), + NC_("SC_OPCODE_FINDB", "Find text"), + NC_("SC_OPCODE_FINDB", "The text to be found."), + NC_("SC_OPCODE_FINDB", "Text"), + NC_("SC_OPCODE_FINDB", "The text in which a search is to be made."), + NC_("SC_OPCODE_FINDB", "Position"), + NC_("SC_OPCODE_FINDB", "The position in the text from which the search starts.") +}; + + // -=*# Resource for function SEARCHB #*=- +const TranslateId SC_OPCODE_SEARCHB_ARY[] = +{ + NC_("SC_OPCODE_SEARCHB", "Looks for a string of text within another (not case sensitive), using byte positions."), + NC_("SC_OPCODE_SEARCHB", "Find text"), + NC_("SC_OPCODE_SEARCHB", "The text to be found."), + NC_("SC_OPCODE_SEARCHB", "Text"), + NC_("SC_OPCODE_SEARCHB", "The text in which a search is to be made."), + NC_("SC_OPCODE_SEARCHB", "Position"), + NC_("SC_OPCODE_SEARCHB", "The position in the text from which the search starts.") +}; + +// -=*# Resource for function FOURIER #*=- +const TranslateId SC_OPCODE_FOURIER_ARY[] = +{ + NC_("SC_OPCODE_FOURIER", "Computes the Discrete Fourier Transform (DFT) of an array"), + NC_("SC_OPCODE_FOURIER", "Array"), + NC_("SC_OPCODE_FOURIER", "The array whose DFT needs to be computed. The dimensions of this array can be Nx1 or Nx2 or 1xN or 2xN."), + NC_("SC_OPCODE_FOURIER", "GroupedByColumns"), + NC_("SC_OPCODE_FOURIER", "Flag to indicate whether the array is grouped by columns or not (default TRUE)."), + NC_("SC_OPCODE_FOURIER", "Inverse"), + NC_("SC_OPCODE_FOURIER", "Flag to indicate whether an inverse DFT is to be computed (default FALSE)."), + NC_("SC_OPCODE_FOURIER", "Polar"), + NC_("SC_OPCODE_FOURIER", "Flag to indicate whether to return the results in polar form (default FALSE)."), + NC_("SC_OPCODE_FOURIER", "MinimumMagnitude"), + NC_("SC_OPCODE_FOURIER", "In case of Polar=TRUE, the frequency components below this magnitude are clipped out (default 0.0).") +}; + +// -=*# Resource for function RAND.NV #*=- +const TranslateId SC_OPCODE_RANDOM_NV_ARY[] = +{ + NC_("SC_OPCODE_RANDOM_NV", "Returns a random number between 0 and 1, non-volatile.") +}; + +// -=*# Resource for function RANDBETWEEN.NV #*=- +const TranslateId SC_OPCODE_RANDBETWEEN_NV_ARY[] = +{ + NC_("SC_OPCODE_RANDBETWEEN_NV", "Returns a random integer between the specified Bottom and Top values (both inclusive), non-volatile."), + NC_("SC_OPCODE_RANDBETWEEN_NV", "Bottom"), + NC_("SC_OPCODE_RANDBETWEEN_NV", "The smallest integer that can be returned."), + NC_("SC_OPCODE_RANDBETWEEN_NV", "Top"), + NC_("SC_OPCODE_RANDBETWEEN_NV", "The largest integer that can be returned.") +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/scfuncs.hxx b/sc/inc/scfuncs.hxx new file mode 100644 index 0000000000..88b0d4958c --- /dev/null +++ b/sc/inc/scfuncs.hxx @@ -0,0 +1,33 @@ +/* -*- 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 + +#define ID_FUNCTION_GRP_DATABASE 1 +#define ID_FUNCTION_GRP_DATETIME 2 +#define ID_FUNCTION_GRP_FINANCIAL 3 +#define ID_FUNCTION_GRP_INFO 4 +#define ID_FUNCTION_GRP_LOGIC 5 +#define ID_FUNCTION_GRP_MATH 6 +#define ID_FUNCTION_GRP_MATRIX 7 +#define ID_FUNCTION_GRP_STATISTIC 8 +#define ID_FUNCTION_GRP_TABLE 9 +#define ID_FUNCTION_GRP_TEXT 10 +#define ID_FUNCTION_GRP_ADDINS 11 + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/scitems.hxx b/sc/inc/scitems.hxx new file mode 100644 index 0000000000..dd91e2f63a --- /dev/null +++ b/sc/inc/scitems.hxx @@ -0,0 +1,232 @@ +/* -*- 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 <svl/typedwhich.hxx> + +class ScConsolidateItem; +class SfxBoolItem; +class SvxCharReliefItem; +class SvxColorItem; +class SvxContourItem; +class SvxCrossedOutItem; +class SvxEmphasisMarkItem; +class SvxFontHeightItem; +class SvxFontItem; +class SvxForbiddenRuleItem; +class SvxFrameDirectionItem; +class SvxHangingPunctuationItem; +class SvxLanguageItem; +class SvxLRSpaceItem; +class SvxOverlineItem; +class SvxPostureItem; +class SvXMLAttrContainerItem; +class SvxScriptSpaceItem; +class SvxShadowedItem; +class SvxULSpaceItem; +class SvxUnderlineItem; +class SvxWeightItem; +class SvxWordLineModeItem; +class SvxShadowItem; +class SvxHorJustifyItem; +class SvxVerJustifyItem; +class SvxBrushItem; +class SvxBoxItem; +class ScCondFormatItem; +class ScLineBreakCell; +class ScRotateValueItem; +class ScVerticalStackCell; +class SvxLineItem; +class SvxRotateModeItem; +class SfxStringItem; +class SvxSizeItem; +class SvxJustifyMethodItem; +class SvxMarginItem; +class SvxPaperBinItem; +class ScHyphenateCell; +class SfxUInt32Item; +class ScIndentItem; +class ScShrinkToFitCell; +class ScMergeAttr; +class ScMergeFlagAttr; +class ScProtectionAttr; +class SvxBoxInfoItem; +class ScPatternAttr; +class SvxPageItem; +class ScViewObjectModeItem; +class SfxUInt16Item; +class ScPageHFItem; +class ScPageScaleToItem; +class SvxSetItem; + +// EditEngine is not allowed to define its own ITEMID's +#define INCLUDED_EDITENG_EEITEMID_HXX + +// Item-IDs for UI-MsgPool: + +//! shall be moved to the below-1000 range! + +#define MSGPOOL_START 1100 + +#define SCITEM_STRING TypedWhichId<SfxStringItem>(1100) +#define SCITEM_SEARCHDATA TypedWhichId<SvxSearchItem>(1101) +#define SCITEM_SORTDATA TypedWhichId<ScSortItem>(1102) +#define SCITEM_QUERYDATA TypedWhichId<ScQueryItem>(1103) +#define SCITEM_SUBTDATA TypedWhichId<ScSubTotalItem>(1104) +#define SCITEM_CONSOLIDATEDATA TypedWhichId<ScConsolidateItem>(1105) +#define SCITEM_PIVOTDATA TypedWhichId<ScPivotItem>(1106) +#define SCITEM_SOLVEDATA TypedWhichId<ScSolveItem>(1107) +#define SCITEM_USERLIST TypedWhichId<ScUserListItem>(1108) +#define SCITEM_CONDFORMATDLGDATA TypedWhichId<ScCondFormatDlgItem>(1109) + +#define MSGPOOL_END 1109 + +// Item-IDs for attributes: + +constexpr sal_uInt16 ATTR_STARTINDEX(100); // begin of attributes + +constexpr sal_uInt16 ATTR_PATTERN_START(100); // begin of cell-attribute-pattern + +constexpr TypedWhichId<SvxFontItem> ATTR_FONT (100); // begin of cell-attributes +constexpr TypedWhichId<SvxFontHeightItem> ATTR_FONT_HEIGHT (101); +constexpr TypedWhichId<SvxWeightItem> ATTR_FONT_WEIGHT (102); +constexpr TypedWhichId<SvxPostureItem> ATTR_FONT_POSTURE (103); +constexpr TypedWhichId<SvxUnderlineItem> ATTR_FONT_UNDERLINE (104); +constexpr TypedWhichId<SvxOverlineItem> ATTR_FONT_OVERLINE (105); +constexpr TypedWhichId<SvxCrossedOutItem> ATTR_FONT_CROSSEDOUT (106); +constexpr TypedWhichId<SvxContourItem> ATTR_FONT_CONTOUR (107); +constexpr TypedWhichId<SvxShadowedItem> ATTR_FONT_SHADOWED (108); +constexpr TypedWhichId<SvxColorItem> ATTR_FONT_COLOR (109); +constexpr TypedWhichId<SvxLanguageItem> ATTR_FONT_LANGUAGE (110); +constexpr TypedWhichId<SvxFontItem> ATTR_CJK_FONT (111); +constexpr TypedWhichId<SvxFontHeightItem> ATTR_CJK_FONT_HEIGHT (112); +constexpr TypedWhichId<SvxWeightItem> ATTR_CJK_FONT_WEIGHT (113); +constexpr TypedWhichId<SvxPostureItem> ATTR_CJK_FONT_POSTURE (114); +constexpr TypedWhichId<SvxLanguageItem> ATTR_CJK_FONT_LANGUAGE (115); +constexpr TypedWhichId<SvxFontItem> ATTR_CTL_FONT (116); +constexpr TypedWhichId<SvxFontHeightItem> ATTR_CTL_FONT_HEIGHT (117); +constexpr TypedWhichId<SvxWeightItem> ATTR_CTL_FONT_WEIGHT (118); +constexpr TypedWhichId<SvxPostureItem> ATTR_CTL_FONT_POSTURE (119); +constexpr TypedWhichId<SvxLanguageItem> ATTR_CTL_FONT_LANGUAGE (120); +constexpr TypedWhichId<SvxEmphasisMarkItem> ATTR_FONT_EMPHASISMARK (121); +constexpr TypedWhichId<SvXMLAttrContainerItem> ATTR_USERDEF (122); // not saved in binary files +constexpr TypedWhichId<SvxWordLineModeItem> ATTR_FONT_WORDLINE (123); +constexpr TypedWhichId<SvxCharReliefItem> ATTR_FONT_RELIEF (124); +constexpr TypedWhichId<ScHyphenateCell> ATTR_HYPHENATE (125); +constexpr TypedWhichId<SvxScriptSpaceItem> ATTR_SCRIPTSPACE (126); +constexpr TypedWhichId<SvxHangingPunctuationItem> ATTR_HANGPUNCTUATION (127); +constexpr TypedWhichId<SvxForbiddenRuleItem> ATTR_FORBIDDEN_RULES (128); +constexpr TypedWhichId<SvxHorJustifyItem> ATTR_HOR_JUSTIFY (129); +constexpr TypedWhichId<SvxJustifyMethodItem> ATTR_HOR_JUSTIFY_METHOD (130); +constexpr TypedWhichId<ScIndentItem> ATTR_INDENT (131); +constexpr TypedWhichId<SvxVerJustifyItem> ATTR_VER_JUSTIFY (132); +constexpr TypedWhichId<SvxJustifyMethodItem> ATTR_VER_JUSTIFY_METHOD (133); +constexpr TypedWhichId<ScVerticalStackCell> ATTR_STACKED (134); +constexpr TypedWhichId<ScRotateValueItem> ATTR_ROTATE_VALUE (135); +constexpr TypedWhichId<SvxRotateModeItem> ATTR_ROTATE_MODE (136); +constexpr TypedWhichId<SfxBoolItem> ATTR_VERTICAL_ASIAN (137); +constexpr TypedWhichId<SvxFrameDirectionItem> ATTR_WRITINGDIR (138); +constexpr TypedWhichId<ScLineBreakCell> ATTR_LINEBREAK (139); +constexpr TypedWhichId<ScShrinkToFitCell> ATTR_SHRINKTOFIT (140); +constexpr TypedWhichId<SvxLineItem> ATTR_BORDER_TLBR (141); +constexpr TypedWhichId<SvxLineItem> ATTR_BORDER_BLTR (142); +constexpr TypedWhichId<SvxMarginItem> ATTR_MARGIN (143); +constexpr TypedWhichId<ScMergeAttr> ATTR_MERGE (144); +constexpr TypedWhichId<ScMergeFlagAttr> ATTR_MERGE_FLAG (145); +constexpr TypedWhichId<SfxUInt32Item> ATTR_VALUE_FORMAT (146); +constexpr TypedWhichId<SvxLanguageItem> ATTR_LANGUAGE_FORMAT (147); +constexpr TypedWhichId<SvxBrushItem> ATTR_BACKGROUND (148); +constexpr TypedWhichId<ScProtectionAttr> ATTR_PROTECTION (149); +constexpr TypedWhichId<SvxBoxItem> ATTR_BORDER (150); +constexpr TypedWhichId<SvxBoxInfoItem> ATTR_BORDER_INNER (151); // inside, because of template-EditDialog +constexpr TypedWhichId<SvxShadowItem> ATTR_SHADOW (152); +constexpr TypedWhichId<SfxUInt32Item> ATTR_VALIDDATA (153); +constexpr TypedWhichId<ScCondFormatItem> ATTR_CONDITIONAL (154); +constexpr TypedWhichId<SfxStringItem> ATTR_HYPERLINK (155); + +constexpr sal_uInt16 ATTR_PATTERN_END(155); // end cell-attribute-pattern + +constexpr TypedWhichId<ScPatternAttr> ATTR_PATTERN (156); + // page attributes +constexpr TypedWhichId<SvxLRSpaceItem> ATTR_LRSPACE (157); // editor: PageDesc-TabPage +constexpr TypedWhichId<SvxULSpaceItem> ATTR_ULSPACE (158); +constexpr TypedWhichId<SvxPageItem> ATTR_PAGE (159); +constexpr TypedWhichId<SvxPaperBinItem> ATTR_PAGE_PAPERBIN (160); +constexpr TypedWhichId<SvxSizeItem> ATTR_PAGE_SIZE (161); +constexpr TypedWhichId<SfxBoolItem> ATTR_PAGE_HORCENTER (162); +constexpr TypedWhichId<SfxBoolItem> ATTR_PAGE_VERCENTER (163); + +constexpr TypedWhichId<SfxBoolItem> ATTR_PAGE_ON (164); // editor: header/footer-page +constexpr TypedWhichId<SfxBoolItem> ATTR_PAGE_DYNAMIC (165); +constexpr TypedWhichId<SfxBoolItem> ATTR_PAGE_SHARED (166); +constexpr TypedWhichId<SfxBoolItem> ATTR_PAGE_SHARED_FIRST (167); + +constexpr TypedWhichId<SfxBoolItem> ATTR_PAGE_NOTES (168); // editor: table +constexpr TypedWhichId<SfxBoolItem> ATTR_PAGE_GRID (169); +constexpr TypedWhichId<SfxBoolItem> ATTR_PAGE_HEADERS (170); +constexpr TypedWhichId<ScViewObjectModeItem> ATTR_PAGE_CHARTS (171); +constexpr TypedWhichId<ScViewObjectModeItem> ATTR_PAGE_OBJECTS (172); +constexpr TypedWhichId<ScViewObjectModeItem> ATTR_PAGE_DRAWINGS (173); +constexpr TypedWhichId<SfxBoolItem> ATTR_PAGE_TOPDOWN (174); +constexpr TypedWhichId<SfxUInt16Item> ATTR_PAGE_SCALE (175); +constexpr TypedWhichId<SfxUInt16Item> ATTR_PAGE_SCALETOPAGES (176); +constexpr TypedWhichId<SfxUInt16Item> ATTR_PAGE_FIRSTPAGENO (177); + +constexpr TypedWhichId<ScPageHFItem> ATTR_PAGE_HEADERLEFT (178); // contents of header/ +constexpr TypedWhichId<ScPageHFItem> ATTR_PAGE_FOOTERLEFT (179); // footer (left) +constexpr TypedWhichId<ScPageHFItem> ATTR_PAGE_HEADERRIGHT (180); // contents of header/ +constexpr TypedWhichId<ScPageHFItem> ATTR_PAGE_FOOTERRIGHT (181); // footer (right) +constexpr TypedWhichId<ScPageHFItem> ATTR_PAGE_HEADERFIRST (182); // contents of header/ +constexpr TypedWhichId<ScPageHFItem> ATTR_PAGE_FOOTERFIRST (183); // footer (first page) +constexpr TypedWhichId<SvxSetItem> ATTR_PAGE_HEADERSET (184); // the corresponding sets +constexpr TypedWhichId<SvxSetItem> ATTR_PAGE_FOOTERSET (185); + +constexpr TypedWhichId<SfxBoolItem> ATTR_PAGE_FORMULAS (186); +constexpr TypedWhichId<SfxBoolItem> ATTR_PAGE_NULLVALS (187); + +constexpr TypedWhichId<ScPageScaleToItem> ATTR_PAGE_SCALETO (188); // #i8868# scale printout to width/height + +constexpr TypedWhichId<SfxBoolItem> ATTR_HIDDEN (189); + +constexpr sal_uInt16 ATTR_ENDINDEX(ATTR_HIDDEN); // end of pool-range + +// Dummy Slot-IDs for dialogs + +#define SID_SCATTR_PAGE_NOTES ATTR_PAGE_NOTES +#define SID_SCATTR_PAGE_GRID ATTR_PAGE_GRID +#define SID_SCATTR_PAGE_HEADERS ATTR_PAGE_HEADERS +#define SID_SCATTR_PAGE_CHARTS ATTR_PAGE_CHARTS +#define SID_SCATTR_PAGE_OBJECTS ATTR_PAGE_OBJECTS +#define SID_SCATTR_PAGE_DRAWINGS ATTR_PAGE_DRAWINGS +#define SID_SCATTR_PAGE_TOPDOWN ATTR_PAGE_TOPDOWN +#define SID_SCATTR_PAGE_SCALE ATTR_PAGE_SCALE +#define SID_SCATTR_PAGE_SCALETOPAGES ATTR_PAGE_SCALETOPAGES +#define SID_SCATTR_PAGE_FIRSTPAGENO ATTR_PAGE_FIRSTPAGENO +#define SID_SCATTR_PAGE_HEADERLEFT ATTR_PAGE_HEADERLEFT +#define SID_SCATTR_PAGE_FOOTERLEFT ATTR_PAGE_FOOTERLEFT +#define SID_SCATTR_PAGE_HEADERRIGHT ATTR_PAGE_HEADERRIGHT +#define SID_SCATTR_PAGE_FOOTERRIGHT ATTR_PAGE_FOOTERRIGHT +#define SID_SCATTR_PAGE_HEADERFIRST ATTR_PAGE_HEADERFIRST +#define SID_SCATTR_PAGE_FOOTERFIRST ATTR_PAGE_FOOTERFIRST +#define SID_SCATTR_PAGE_FORMULAS ATTR_PAGE_FORMULAS +#define SID_SCATTR_PAGE_NULLVALS ATTR_PAGE_NULLVALS +#define SID_SCATTR_PAGE_SCALETO ATTR_PAGE_SCALETO + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/scmatrix.hxx b/sc/inc/scmatrix.hxx new file mode 100644 index 0000000000..8eb4ae7fde --- /dev/null +++ b/sc/inc/scmatrix.hxx @@ -0,0 +1,433 @@ +/* -*- 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 "address.hxx" +#include "matrixoperators.hxx" +#include "types.hxx" +#include <formula/errorcodes.hxx> +#include "scdllapi.h" +#include <svl/sharedstring.hxx> +#include <svl/sharedstringpool.hxx> + +#include <memory> +#include <utility> +#include <vector> + +#define DEBUG_MATRIX 0 + +class ScInterpreter; +class SvNumberFormatter; +class ScMatrixImpl; +enum class FormulaError : sal_uInt16; + +namespace sc { + +struct Compare; +struct CompareOptions; + +} + +/** + * Try NOT to use this struct. This struct should go away in a hopefully + * not so distant future. + */ +struct ScMatrixValue +{ + double fVal; + svl::SharedString aStr; + ScMatValType nType; + + /// Only valid if ScMatrix methods indicate so! + const svl::SharedString& GetString() const { return aStr; } + + /// Only valid if ScMatrix methods indicate that this is no string! + FormulaError GetError() const { return GetDoubleErrorValue(fVal); } + + /// Only valid if ScMatrix methods indicate that this is a boolean + bool GetBoolean() const { return fVal != 0.0; } + + ScMatrixValue() : fVal(0.0), nType(ScMatValType::Empty) {} + ScMatrixValue(const ScMatrixValue& r) = default; + ScMatrixValue& operator= (const ScMatrixValue& r) = default; + + bool operator== (const ScMatrixValue& r) const + { + if (nType != r.nType) + return false; + + switch (nType) + { + case ScMatValType::Value: + case ScMatValType::Boolean: + return fVal == r.fVal; + break; + default: + ; + } + + return aStr == r.aStr; + } + + bool operator!= (const ScMatrixValue& r) const + { + return !operator==(r); + } +}; + +/** + * Matrix data type that can store values of mixed types. Each element can + * be one of the following types: numeric, string, boolean, empty, and empty + * path. + */ +class SC_DLLPUBLIC ScMatrix final +{ + friend class ScMatrixImpl; + + mutable size_t nRefCnt; // reference count + mutable bool mbCloneIfConst; // Whether the matrix is cloned with a CloneIfConst() call. + std::unique_ptr<ScMatrixImpl> pImpl; + + ScMatrix( const ScMatrix& ) = delete; + ScMatrix& operator=( const ScMatrix&) = delete; + +public: + ScMatrix(SCSIZE nC, SCSIZE nR); + ScMatrix(SCSIZE nC, SCSIZE nR, double fInitVal); + ScMatrix( size_t nC, size_t nR, const std::vector<double>& rInitVals ); + ~ScMatrix(); + + typedef std::function<void(size_t, size_t, double)> DoubleOpFunction; + typedef std::function<void(size_t, size_t, bool)> BoolOpFunction; + typedef std::function<void(size_t, size_t, svl::SharedString)> StringOpFunction; + typedef std::function<void(size_t, size_t)> EmptyOpFunction; + typedef std::function<double(double, double)> CalculateOpFunction; + + /** + * When adding all numerical matrix elements for a scalar result such as + * summation, the interpreter wants to separate the first non-zero value + * with the rest of the summed values. This is necessary for better + * numerical stability, unless we sort all by absolute values before + * summing (not really an option) or use another algorithm, e.g. Kahan's + * summation algorithm, + * https://en.wikipedia.org/wiki/Kahan_summation_algorithm + */ + template<typename tRes> + struct IterateResultMultiple + { + std::vector<tRes> maAccumulator; + size_t mnCount; + + IterateResultMultiple(size_t nCount) : + maAccumulator(0), mnCount(nCount) {} + }; + typedef IterateResultMultiple<KahanSum> KahanIterateResultMultiple; + typedef IterateResultMultiple<double> DoubleIterateResultMultiple; + + /** + * Iterator for executing one operation with the matrix data. + */ + template<typename tRes> + struct IterateResult + { + tRes maAccumulator; + size_t mnCount; + + IterateResult(tRes fAccumulator, size_t nCount) + : maAccumulator(fAccumulator), mnCount(nCount) {} + }; + typedef IterateResult<KahanSum> KahanIterateResult; + typedef IterateResult<double> DoubleIterateResult; + + + /** Checks nC or nR for zero and uses GetElementsMax() whether a matrix of + the size of nC*nR could be allocated. A zero size (both nC and nR zero) + matrix is allowed for later resize. + */ + bool static IsSizeAllocatable( SCSIZE nC, SCSIZE nR ); + + /// Value or boolean. + static bool IsValueType( ScMatValType nType ) + { + return nType <= ScMatValType::Boolean; + } + + /// Boolean. + static bool IsBooleanType( ScMatValType nType ) + { + return nType == ScMatValType::Boolean; + } + + /// String, empty or empty path, but not value nor boolean. + static bool IsNonValueType( ScMatValType nType ) + { + return bool(nType & ScMatValType::NonvalueMask); + } + + /** String, but not empty or empty path or any other type. + Not named IsStringType to prevent confusion because previously + IsNonValueType was named IsStringType. */ + static bool IsRealStringType( ScMatValType nType ) + { + return (nType & ScMatValType::NonvalueMask) == ScMatValType::String; + } + + /// Empty, but not empty path or any other type. + static bool IsEmptyType( ScMatValType nType ) + { + return (nType & ScMatValType::NonvalueMask) == ScMatValType::Empty; + } + + /// Empty path, but not empty or any other type. + static bool IsEmptyPathType( ScMatValType nType ) + { + return (nType & ScMatValType::NonvalueMask) == ScMatValType::EmptyPath; + } + + /** Clone the matrix. */ + ScMatrix* Clone() const; + + /** Clone the matrix if mbCloneIfConst (immutable) is set, otherwise + return _this_ matrix, to be assigned to a ScMatrixRef. */ + ScMatrix* CloneIfConst(); + + /** Set the matrix to mutable for CloneIfConst(), only the interpreter + should do this and know the consequences. */ + void SetMutable(); + + /** Set the matrix to immutable for CloneIfConst(), only the interpreter + should do this and know the consequences. */ + void SetImmutable() const; + + /** + * Resize the matrix to specified new dimension. + */ + void Resize(SCSIZE nC, SCSIZE nR); + + void Resize(SCSIZE nC, SCSIZE nR, double fVal); + + /** Clone the matrix and extend it to the new size. nNewCols and nNewRows + MUST be at least of the size of the original matrix. */ + ScMatrix* CloneAndExtend(SCSIZE nNewCols, SCSIZE nNewRows) const; + + void IncRef() const; + void DecRef() const; + + void SetErrorInterpreter( ScInterpreter* p); + void GetDimensions( SCSIZE& rC, SCSIZE& rR) const; + SCSIZE GetElementCount() const; + bool ValidColRow( SCSIZE nC, SCSIZE nR) const; + + /** For a row vector or column vector, if the position does not point into + the vector but is a valid column or row offset it is adapted such that + it points to an element to be replicated, same column row 0 for a row + vector, same row column 0 for a column vector. Else, for a 2D matrix, + returns false. + */ + bool ValidColRowReplicated( SCSIZE & rC, SCSIZE & rR ) const; + + /** Checks if the matrix position is within the matrix. If it is not, for a + row vector or column vector the position is adapted such that it points + to an element to be replicated, same column row 0 for a row vector, + same row column 0 for a column vector. Else, for a 2D matrix and + position not within matrix, returns false. + */ + bool ValidColRowOrReplicated( SCSIZE & rC, SCSIZE & rR ) const; + + void PutDouble( double fVal, SCSIZE nC, SCSIZE nR); + void PutDouble( double fVal, SCSIZE nIndex); + void PutDouble(const double* pArray, size_t nLen, SCSIZE nC, SCSIZE nR); + + void PutString( const svl::SharedString& rStr, SCSIZE nC, SCSIZE nR) ; + void PutString( const svl::SharedString& rStr, SCSIZE nIndex) ; + void PutString( const svl::SharedString* pArray, size_t nLen, SCSIZE nC, SCSIZE nR) ; + + void PutEmpty( SCSIZE nC, SCSIZE nR); + + /// Jump sal_False without path + void PutEmptyPath( SCSIZE nC, SCSIZE nR) ; + void PutError( FormulaError nErrorCode, SCSIZE nC, SCSIZE nR ) ; + void PutBoolean( bool bVal, SCSIZE nC, SCSIZE nR) ; + + void FillDouble( double fVal, + SCSIZE nC1, SCSIZE nR1, SCSIZE nC2, SCSIZE nR2 ) ; + + /** Put a column vector of doubles, starting at row nR, must fit into dimensions. */ + void PutDoubleVector( const ::std::vector< double > & rVec, SCSIZE nC, SCSIZE nR ) ; + + /** Put a column vector of strings, starting at row nR, must fit into dimensions. */ + void PutStringVector( const ::std::vector< svl::SharedString > & rVec, SCSIZE nC, SCSIZE nR ) ; + + /** Put a column vector of empties, starting at row nR, must fit into dimensions. */ + void PutEmptyVector( SCSIZE nCount, SCSIZE nC, SCSIZE nR ) ; + + /** Put a column vector of empty results, starting at row nR, must fit into dimensions. */ + void PutEmptyResultVector( SCSIZE nCount, SCSIZE nC, SCSIZE nR ) ; + + /** Put a column vector of empty paths, starting at row nR, must fit into dimensions. */ + void PutEmptyPathVector( SCSIZE nCount, SCSIZE nC, SCSIZE nR ) ; + + /** May be used before obtaining the double value of an element to avoid + passing its NAN around. + @ATTENTION: MUST NOT be used if the element is a string! + Use GetErrorIfNotString() instead if not sure. + @returns 0 if no error, else one of err... constants */ + FormulaError GetError( SCSIZE nC, SCSIZE nR) const ; + + /** Use in ScInterpreter to obtain the error code, if any. + @returns 0 if no error or string element, else one of err... constants */ + FormulaError GetErrorIfNotString( SCSIZE nC, SCSIZE nR) const + { return IsValue( nC, nR) ? GetError( nC, nR) : FormulaError::NONE; } + + /// @return 0.0 if empty or empty path, else value or DoubleError. + double GetDouble( SCSIZE nC, SCSIZE nR) const ; + /// @return 0.0 if empty or empty path, else value or DoubleError. + double GetDouble( SCSIZE nIndex) const ; + /// @return value or DoubleError or string converted to value. + double GetDoubleWithStringConversion( SCSIZE nC, SCSIZE nR ) const ; + + /// @return empty string if empty or empty path, else string content. + svl::SharedString GetString( SCSIZE nC, SCSIZE nR) const ; + /// @return empty string if empty or empty path, else string content. + svl::SharedString GetString( SCSIZE nIndex) const ; + + /** @returns the matrix element's string if one is present, otherwise the + numerical value formatted as string, or in case of an error the error + string is returned; an empty string for empty, a "FALSE" string for + empty path. */ + svl::SharedString GetString( SvNumberFormatter& rFormatter, SCSIZE nC, SCSIZE nR) const ; + + /// @ATTENTION: If bString the ScMatrixValue->pS may still be NULL to indicate + /// an empty string! + ScMatrixValue Get( SCSIZE nC, SCSIZE nR) const ; + + /** @return <TRUE/> if string or any empty, empty cell, empty result, empty + path, in fact non-value. */ + bool IsStringOrEmpty( SCSIZE nIndex ) const ; + + /** @return <TRUE/> if string or any empty, empty cell, empty result, empty + path, in fact non-value. */ + bool IsStringOrEmpty( SCSIZE nC, SCSIZE nR ) const ; + + /// @return <TRUE/> if empty or empty cell or empty result, not empty path. + bool IsEmpty( SCSIZE nC, SCSIZE nR ) const ; + + /// @return <TRUE/> if empty cell, not empty or empty result or empty path. + bool IsEmptyCell( SCSIZE nC, SCSIZE nR ) const ; + + /// @return <TRUE/> if empty result, not empty or empty cell or empty path. + bool IsEmptyResult( SCSIZE nC, SCSIZE nR ) const ; + + /// @return <TRUE/> if empty path, not empty or empty cell or empty result. + bool IsEmptyPath( SCSIZE nC, SCSIZE nR ) const ; + + /// @return <TRUE/> if value or boolean. + bool IsValue( SCSIZE nIndex ) const ; + + /// @return <TRUE/> if value or boolean. + bool IsValue( SCSIZE nC, SCSIZE nR ) const ; + + /// @return <TRUE/> if value or boolean or empty or empty path. + bool IsValueOrEmpty( SCSIZE nC, SCSIZE nR ) const ; + + /// @return <TRUE/> if boolean. + bool IsBoolean( SCSIZE nC, SCSIZE nR ) const ; + + /// @return <TRUE/> if entire matrix is numeric, including booleans, with no strings or empties + bool IsNumeric() const ; + + void MatTrans( const ScMatrix& mRes) const ; + void MatCopy ( const ScMatrix& mRes) const ; + + // Convert ScInterpreter::CompareMat values (-1,0,1) to boolean values + void CompareEqual() ; + void CompareNotEqual() ; + void CompareLess() ; + void CompareGreater() ; + void CompareLessEqual() ; + void CompareGreaterEqual() ; + + double And() const ; // logical AND of all matrix values, or NAN + double Or() const ; // logical OR of all matrix values, or NAN + double Xor() const ; // logical XOR of all matrix values, or NAN + + KahanIterateResult Sum( bool bTextAsZero, bool bIgnoreErrorValues = false ) const ; + KahanIterateResult SumSquare( bool bTextAsZero, bool bIgnoreErrorValues = false ) const ; + DoubleIterateResult Product( bool bTextAsZero, bool bIgnoreErrorValues = false ) const ; + size_t Count(bool bCountStrings, bool bCountErrors, bool bIgnoreEmptyStrings = false) const ; + size_t MatchDoubleInColumns(double fValue, size_t nCol1, size_t nCol2) const ; + size_t MatchStringInColumns(const svl::SharedString& rStr, size_t nCol1, size_t nCol2) const ; + + double GetMaxValue( bool bTextAsZero, bool bIgnoreErrorValues = false ) const ; + double GetMinValue( bool bTextAsZero, bool bIgnoreErrorValues = false ) const ; + double GetGcd() const ; + double GetLcm() const ; + + ScMatrixRef CompareMatrix( + sc::Compare& rComp, size_t nMatPos, sc::CompareOptions* pOptions ) const ; + + /** + * Convert the content of matrix into a linear array of numeric values. + * String elements are mapped to NaN's and empty elements are mapped to + * either NaN or zero values. + * + * @param bEmptyAsZero if true empty elements are mapped to zero values, + * otherwise they become NaN values. + */ + void GetDoubleArray( std::vector<double>& rArray, bool bEmptyAsZero = true ) const ; + void MergeDoubleArrayMultiply( std::vector<double>& rArray ) const ; + + void NotOp(const ScMatrix& rMat) ; + void NegOp(const ScMatrix& rMat) ; + void AddOp(double fVal, const ScMatrix& rMat) ; + void SubOp(bool bFlag, double fVal, const ScMatrix& rMat) ; + void MulOp(double fVal, const ScMatrix& rMat) ; + void DivOp(bool bFlag, double fVal, const ScMatrix& rMat) ; + void PowOp(bool bFlag, double fVal, const ScMatrix& rMat) ; + + KahanIterateResultMultiple CollectKahan(const std::vector<sc::op::kOp>& aOp) ; + + void ExecuteOperation(const std::pair<size_t, size_t>& rStartPos, const std::pair<size_t, size_t>& rEndPos, + DoubleOpFunction aDoubleFunc, BoolOpFunction aBoolFunc, StringOpFunction aStringFunc, + EmptyOpFunction aEmptyFunc) const ; + + void MatConcat(SCSIZE nMaxCol, SCSIZE nMaxRow, const ScMatrixRef& xMat1, const ScMatrixRef& xMat2, + SvNumberFormatter& rFormatter, svl::SharedStringPool& rPool) ; + + /** Apply binary operation to values from two input matrices, storing result into this matrix. */ + void ExecuteBinaryOp(SCSIZE nMaxCol, SCSIZE nMaxRow, const ScMatrix& rInputMat1, const ScMatrix& rInputMat2, + ScInterpreter* pInterpreter, CalculateOpFunction op); + +#if DEBUG_MATRIX + void Dump() const; +#endif +}; + +inline void intrusive_ptr_add_ref(const ScMatrix* p) +{ + p->IncRef(); +} + +inline void intrusive_ptr_release(const ScMatrix* p) +{ + p->DecRef(); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/scmod.hxx b/sc/inc/scmod.hxx new file mode 100644 index 0000000000..f95da4a462 --- /dev/null +++ b/sc/inc/scmod.hxx @@ -0,0 +1,251 @@ +/* -*- 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 "scdllapi.h" +#include <o3tl/deleter.hxx> +#include <vcl/timer.hxx> +#include <svl/lstner.hxx> +#include <sfx2/app.hxx> +#include <sfx2/module.hxx> +#include "global.hxx" +#include "shellids.hxx" +#include <unotools/options.hxx> +#include <com/sun/star/uno/Reference.h> + +#include <vector> +#include <map> +#include <memory> + +class KeyEvent; +class EditView; +class SfxErrorHandler; +class SvtAccessibilityOptions; +class SvtCTLOptions; +class SvtUserOptions; + +namespace svtools { class ColorConfig; } +namespace ooo::vba { class XSinkCaller; } +namespace com::sun::star::uno { class Any; } +namespace com::sun::star::uno { template <typename > class Sequence; } + +class ScRange; +class ScDocument; +class ScViewCfg; +class ScDocCfg; +class ScAppCfg; +class ScDefaultsCfg; +class ScFormulaCfg; +class ScInputCfg; +class ScPrintCfg; +class ScViewOptions; +class ScDocOptions; +class ScAppOptions; +class ScDefaultsOptions; +class ScFormulaOptions; +class ScInputOptions; +class ScPrintOptions; +class ScInputHandler; +class ScTabViewShell; +class ScMessagePool; +class EditFieldInfo; +class ScNavipiCfg; +class ScAddInCfg; +class ScTransferObj; +class ScDrawTransferObj; +class ScSelectionTransferObj; +class ScFormEditData; +class ScMarkData; +struct ScDragData; +class SfxDialogController; + +class SAL_DLLPUBLIC_RTTI ScModule final : public SfxModule, public SfxListener, public utl::ConfigurationListener +{ + Timer m_aIdleTimer; + std::unique_ptr<ScDragData> m_pDragData; + ScSelectionTransferObj* m_pSelTransfer; + rtl::Reference<ScMessagePool> m_pMessagePool; + // there is no global InputHandler anymore, each View has its own + ScInputHandler* m_pRefInputHandler; + std::unique_ptr<ScViewCfg, o3tl::default_delete<ScViewCfg>> m_pViewCfg; + std::unique_ptr<ScDocCfg, o3tl::default_delete<ScDocCfg>> m_pDocCfg; + std::unique_ptr<ScAppCfg, o3tl::default_delete<ScAppCfg>> m_pAppCfg; + std::unique_ptr<ScDefaultsCfg> m_pDefaultsCfg; + std::unique_ptr<ScFormulaCfg> m_pFormulaCfg; + std::unique_ptr<ScInputCfg> m_pInputCfg; + std::unique_ptr<ScPrintCfg> m_pPrintCfg; + std::unique_ptr<ScNavipiCfg> m_pNavipiCfg; + std::unique_ptr<ScAddInCfg> m_pAddInCfg; + std::unique_ptr<svtools::ColorConfig> m_pColorConfig; + std::unique_ptr<SvtAccessibilityOptions> m_pAccessOptions; + std::unique_ptr<SvtCTLOptions> m_pCTLOptions; + std::unique_ptr<SvtUserOptions> m_pUserOptions; + std::unique_ptr<SfxErrorHandler> m_pErrorHdl; + sal_uInt16 m_nCurRefDlgId; + bool m_bIsWaterCan:1; + bool m_bIsInEditCommand:1; + bool m_bIsInExecuteDrop:1; + bool m_bIsInSharedDocLoading:1; + bool m_bIsInSharedDocSaving:1; + + // a way to find existing Dialogs for a given parent Window of the slot type + std::map<sal_uInt16, std::vector<std::pair<std::shared_ptr<SfxDialogController>, weld::Window*>>> m_mapRefController; + + css::uno::Reference< ooo::vba::XSinkCaller > mxAutomationApplicationEventsCaller; + +public: + SFX_DECL_INTERFACE(SCID_APP) + +private: + /// SfxInterface initializer. + static void InitInterface_Impl(); + +public: + ScModule( SfxObjectFactory* pFact ); + virtual ~ScModule() override; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + virtual void ConfigurationChanged( utl::ConfigurationBroadcaster*, ConfigurationHints ) override; + void DeleteCfg(); + + // moved by the application + + DECL_DLLPRIVATE_LINK( IdleHandler, Timer*, void ); // Timer instead of idle + DECL_DLLPRIVATE_LINK( CalcFieldValueHdl, EditFieldInfo*, void ); + + void Execute( SfxRequest& rReq ); + void GetState( SfxItemSet& rSet ); + static void HideDisabledSlots( SfxItemSet& rSet ); + + void AnythingChanged(); + + // Drag & Drop: + const ScDragData& GetDragData() const; + void SetDragObject( ScTransferObj* pCellObj, ScDrawTransferObj* pDrawObj ); + void ResetDragObject(); + void SetDragLink( + const OUString& rDoc, const OUString& rTab, const OUString& rArea ); + void SetDragJump( + ScDocument* pLocalDoc, const OUString& rTarget, const OUString& rText ); + + static ScDocument* GetClipDoc(); // called from document - should be removed later + + // X selection: + ScSelectionTransferObj* GetSelectionTransfer() const { return m_pSelTransfer; } + void SetSelectionTransfer( ScSelectionTransferObj* pNew ); + + void SetWaterCan( bool bNew ) { m_bIsWaterCan = bNew; } + bool GetIsWaterCan() const { return m_bIsWaterCan; } + + void SetInEditCommand( bool bNew ) { m_bIsInEditCommand = bNew; } + + void SetInExecuteDrop( bool bNew ) { m_bIsInExecuteDrop = bNew; } + bool IsInExecuteDrop() const { return m_bIsInExecuteDrop; } + + // Options: + const ScViewOptions& GetViewOptions (); + SC_DLLPUBLIC const ScDocOptions& GetDocOptions (); + SC_DLLPUBLIC const ScAppOptions& GetAppOptions (); + SC_DLLPUBLIC const ScDefaultsOptions& GetDefaultsOptions (); + SC_DLLPUBLIC const ScFormulaOptions& GetFormulaOptions (); + SC_DLLPUBLIC const ScInputOptions& GetInputOptions (); + SC_DLLPUBLIC const ScPrintOptions& GetPrintOptions (); + void SetViewOptions ( const ScViewOptions& rOpt ); + SC_DLLPUBLIC void SetDocOptions ( const ScDocOptions& rOpt ); + SC_DLLPUBLIC void SetAppOptions ( const ScAppOptions& rOpt ); + SC_DLLPUBLIC void SetDefaultsOptions ( const ScDefaultsOptions& rOpt ); + SC_DLLPUBLIC void SetFormulaOptions ( const ScFormulaOptions& rOpt ); + SC_DLLPUBLIC void SetInputOptions ( const ScInputOptions& rOpt ); + void SetPrintOptions ( const ScPrintOptions& rOpt ); + void InsertEntryToLRUList(sal_uInt16 nFIndex); + + static void GetSpellSettings( LanguageType& rDefLang, LanguageType& rCjkLang, LanguageType& rCtlLang, + bool& rAutoSpell ); + static void SetAutoSpellProperty( bool bSet ); + static bool HasThesaurusLanguage( LanguageType nLang ); + + static LanguageType GetOptDigitLanguage(); // from CTL options + + ScNavipiCfg& GetNavipiCfg(); + ScAddInCfg& GetAddInCfg(); + svtools::ColorConfig& GetColorConfig(); + SC_DLLPUBLIC SvtUserOptions& GetUserOptions(); + + void ModifyOptions( const SfxItemSet& rOptSet ); + + // InputHandler: + bool IsEditMode(); // not for SC_INPUT_TYPE + bool IsInputMode(); // also for SC_INPUT_TYPE + void SetInputMode( ScInputMode eMode, const OUString* pInitText = nullptr ); + bool InputKeyEvent( const KeyEvent& rKEvt, bool bStartEdit = false ); + SC_DLLPUBLIC void InputEnterHandler( ScEnterMode nBlockMode = ScEnterMode::NORMAL, bool bBeforeSavingInLOK = false ); + void InputCancelHandler(); + void InputSelection( const EditView* pView ); + void InputChanged( const EditView* pView ); + ScInputHandler* GetInputHdl( ScTabViewShell* pViewSh = nullptr, bool bUseRef = true ); + void SetRefInputHdl( ScInputHandler* pNew ); + ScInputHandler* GetRefInputHdl() { return m_pRefInputHandler;} + + void ViewShellGone(const ScTabViewShell* pViewSh); + void ViewShellChanged(bool bStopEditing); + // communication with function-autopilot + void InputGetSelection( sal_Int32& rStart, sal_Int32& rEnd ); + void InputSetSelection( sal_Int32 nStart, sal_Int32 nEnd ); + void InputReplaceSelection( std::u16string_view aStr ); + void InputTurnOffWinEngine(); + void ActivateInputWindow( const OUString* pStr = nullptr, + bool bMatrix = false ); + + // input of reference: + SC_DLLPUBLIC void SetRefDialog( sal_uInt16 nId, bool bVis, SfxViewFrame* pViewFrm = nullptr ); + bool IsModalMode(SfxObjectShell* pDocSh = nullptr); + bool IsFormulaMode(); + bool IsRefDialogOpen(); + bool IsTableLocked(); + void SetReference( const ScRange& rRef, ScDocument& rDoc, + const ScMarkData* pMarkData = nullptr ); + void AddRefEntry(); + void EndReference(); + sal_uInt16 GetCurRefDlgId() const { return m_nCurRefDlgId; } + + // virtual methods for the options dialog + virtual std::optional<SfxItemSet> CreateItemSet( sal_uInt16 nId ) override; + virtual void ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet ) override; + virtual std::unique_ptr<SfxTabPage> CreateTabPage( sal_uInt16 nId, weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet ) override; + virtual std::optional<SfxStyleFamilies> CreateStyleFamilies() override; + + void SetInSharedDocLoading( bool bNew ) { m_bIsInSharedDocLoading = bNew; } + bool IsInSharedDocLoading() const { return m_bIsInSharedDocLoading; } + void SetInSharedDocSaving( bool bNew ) { m_bIsInSharedDocSaving = bNew; } + bool IsInSharedDocSaving() const { return m_bIsInSharedDocSaving; } + + SC_DLLPUBLIC void RegisterRefController(sal_uInt16 nSlotId, std::shared_ptr<SfxDialogController>& rWnd, weld::Window* pWndAncestor); + SC_DLLPUBLIC void UnregisterRefController(sal_uInt16 nSlotId, const std::shared_ptr<SfxDialogController>& rWnd); + SC_DLLPUBLIC std::shared_ptr<SfxDialogController> Find1RefWindow(sal_uInt16 nSlotId, const weld::Window *pWndAncestor); + + SC_DLLPUBLIC void RegisterAutomationApplicationEventsCaller(css::uno::Reference< ooo::vba::XSinkCaller > const& xCaller); + SC_DLLPUBLIC void CallAutomationApplicationEventSinks(const OUString& Method, css::uno::Sequence< css::uno::Any >& Arguments); +}; + +#define SC_MOD() ( static_cast<ScModule*>(SfxApplication::GetModule(SfxToolsModule::Calc)) ) + +void global_InitAppOptions(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/scopetools.hxx b/sc/inc/scopetools.hxx new file mode 100644 index 0000000000..db76c86516 --- /dev/null +++ b/sc/inc/scopetools.hxx @@ -0,0 +1,109 @@ +/* -*- 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/. + */ + +#pragma once + +#include "scdllapi.h" + +class ScDocument; +class ScColumn; +namespace vcl +{ +class Window; +} + +namespace sc +{ +/** + * Temporarily switch on/off auto calculation mode. + */ +class SC_DLLPUBLIC AutoCalcSwitch +{ + ScDocument& mrDoc; + bool mbOldValue; + + AutoCalcSwitch(AutoCalcSwitch const&) = delete; + AutoCalcSwitch(AutoCalcSwitch&&) = delete; + AutoCalcSwitch& operator=(AutoCalcSwitch const&) = delete; + AutoCalcSwitch& operator=(AutoCalcSwitch&&) = delete; + +public: + AutoCalcSwitch(ScDocument& rDoc, bool bAutoCalc); + ~AutoCalcSwitch(); +}; + +class ExpandRefsSwitch +{ + ScDocument& mrDoc; + bool mbOldValue; + +public: + ExpandRefsSwitch(ScDocument& rDoc, bool bExpandRefs); + ~ExpandRefsSwitch(); +}; + +class SC_DLLPUBLIC UndoSwitch +{ + ScDocument& mrDoc; + bool mbOldValue; + +public: + UndoSwitch(ScDocument& rDoc, bool bUndo); + ~UndoSwitch(); +}; + +class IdleSwitch +{ + ScDocument& mrDoc; + bool mbOldValue; + +public: + IdleSwitch(ScDocument& rDoc, bool bEnableIdle); + ~IdleSwitch(); +}; + +/// Wrapper for ScDocument::DelayFormulaGrouping() +class DelayFormulaGroupingSwitch +{ + ScDocument& mrDoc; + bool const mbOldValue; + +public: + DelayFormulaGroupingSwitch(ScDocument& rDoc, bool delay); + ~DelayFormulaGroupingSwitch() COVERITY_NOEXCEPT_FALSE; + void reset(); +}; + +/// Wrapper for ScDocument::EnableDelayStartListeningFormulaCells() +class DelayStartListeningFormulaCells +{ + ScColumn& mColumn; + bool const mbOldValue; + +public: + DelayStartListeningFormulaCells(ScColumn& column, bool delay); + DelayStartListeningFormulaCells(ScColumn& column); + DelayStartListeningFormulaCells(const DelayStartListeningFormulaCells&) = delete; + ~DelayStartListeningFormulaCells(); + void set(); +}; + +/// Wrapper for ScDocument::EnableDelayDeletingBroadcasters() +class DelayDeletingBroadcasters +{ + ScDocument& mDoc; + const bool mOldValue; + +public: + DelayDeletingBroadcasters(ScDocument& doc); + ~DelayDeletingBroadcasters(); +}; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/scres.hrc b/sc/inc/scres.hrc new file mode 100644 index 0000000000..8089d41258 --- /dev/null +++ b/sc/inc/scres.hrc @@ -0,0 +1,53 @@ +/* -*- 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 . + */ + +#ifndef SC_SCRES_HRC +#define SC_SCRES_HRC + +#include "sc.hrc" + +#define STR_START (SC_RESOURCE_START+100) + +#define STR_END (STR_START + 554) + +#define SC_DIALOGS_START (STR_END + 100) + +#define RID_SCDLG_HFEDIT (SC_DIALOGS_START + 50) +#define RID_SCDLG_HFEDIT_ALL (SC_DIALOGS_START + 51) +#define RID_SCDLG_HFED_HEADER (SC_DIALOGS_START + 52) +#define RID_SCDLG_HFED_FOOTER (SC_DIALOGS_START + 53) + +#define RID_SCDLG_HFEDIT_SHDR (SC_DIALOGS_START + 62) +#define RID_SCDLG_HFEDIT_SFTR (SC_DIALOGS_START + 63) +#define RID_SCDLG_HFEDIT_LEFTHEADER (SC_DIALOGS_START + 64) +#define RID_SCDLG_HFEDIT_RIGHTHEADER (SC_DIALOGS_START + 65) +#define RID_SCDLG_HFEDIT_LEFTFOOTER (SC_DIALOGS_START + 66) +#define RID_SCDLG_HFEDIT_RIGHTFOOTER (SC_DIALOGS_START + 67) +#define RID_SCDLG_HFEDIT_SHAREDFIRSTHEADER (SC_DIALOGS_START + 68) +#define RID_SCDLG_HFEDIT_SHAREDLEFTHEADER (SC_DIALOGS_START + 69) +#define RID_SCDLG_HFEDIT_SHAREDFIRSTFOOTER (SC_DIALOGS_START + 70) +#define RID_SCDLG_HFEDIT_SHAREDLEFTFOOTER (SC_DIALOGS_START + 71) +#define RID_SCDLG_HFEDIT_HEADER (SC_DIALOGS_START + 72) +#define RID_SCDLG_HFEDIT_FOOTER (SC_DIALOGS_START + 73) + +#define WID_CONDFRMT_REF (SC_DIALOGS_START + 163) + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/scresid.hxx b/sc/inc/scresid.hxx new file mode 100644 index 0000000000..99a392cdb6 --- /dev/null +++ b/sc/inc/scresid.hxx @@ -0,0 +1,29 @@ +/* -*- 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 <rtl/ustring.hxx> +#include "scdllapi.h" +#include <unotools/resmgr.hxx> + +OUString SC_DLLPUBLIC ScResId(TranslateId aId); +OUString ScResId(TranslateNId aContextSingularPlural, int nCardinality); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/scstyles.hrc b/sc/inc/scstyles.hrc new file mode 100644 index 0000000000..f7df2db508 --- /dev/null +++ b/sc/inc/scstyles.hrc @@ -0,0 +1,53 @@ +/* -*- 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 <svl/style.hxx> +#include <unotools/resmgr.hxx> + +#define NC_(Context, String) TranslateId(Context, u8##String) + +const std::pair<TranslateId, SfxStyleSearchBits> RID_CELLSTYLEFAMILY[] = +{ + { NC_("RID_CELLSTYLEFAMILY", "All Styles") , SfxStyleSearchBits::AllVisible }, + { NC_("RID_CELLSTYLEFAMILY", "Hidden Styles") , SfxStyleSearchBits::Hidden }, + { NC_("RID_CELLSTYLEFAMILY", "Applied Styles") , SfxStyleSearchBits::Used }, + { NC_("RID_CELLSTYLEFAMILY", "Custom Styles") , SfxStyleSearchBits::UserDefined }, + { {}, SfxStyleSearchBits::Auto } +}; + +const std::pair<TranslateId, SfxStyleSearchBits> RID_PAGESTYLEFAMILY[] = +{ + { NC_("RID_PAGESTYLEFAMILY", "All Styles") , SfxStyleSearchBits::All }, + { NC_("RID_PAGESTYLEFAMILY", "Hidden Styles") , SfxStyleSearchBits::Hidden }, + { NC_("RID_PAGESTYLEFAMILY", "Custom Styles") , SfxStyleSearchBits::UserDefined }, + { {}, SfxStyleSearchBits::Auto } +}; + +const std::pair<TranslateId, SfxStyleSearchBits> RID_GRAPHICSTYLEFAMILY[] = +{ + { NC_("RID_GRAPHICSTYLEFAMILY", "All Styles") , SfxStyleSearchBits::AllVisible }, + { NC_("RID_GRAPHICSTYLEFAMILY", "Hidden Styles") , SfxStyleSearchBits::Hidden }, + { NC_("RID_GRAPHICSTYLEFAMILY", "Applied Styles") , SfxStyleSearchBits::Used }, + { NC_("RID_GRAPHICSTYLEFAMILY", "Custom Styles") , SfxStyleSearchBits::UserDefined }, + { {}, SfxStyleSearchBits::Auto } +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/segmenttree.hxx b/sc/inc/segmenttree.hxx new file mode 100644 index 0000000000..c980f9db56 --- /dev/null +++ b/sc/inc/segmenttree.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 "types.hxx" +#include <rtl/string.hxx> + +#include <memory> + +class ScFlatBoolSegmentsImpl; + +class ScFlatBoolRowSegments +{ +public: + struct RangeData + { + SCROW mnRow1; + SCROW mnRow2; + bool mbValue; + }; + + class ForwardIterator + { + public: + explicit ForwardIterator(ScFlatBoolRowSegments& rSegs); + + [[nodiscard]] bool getValue(SCROW nPos, bool& rVal); + SCROW getLastPos() const { return mnLastPos; } + + private: + ScFlatBoolRowSegments& mrSegs; + + SCROW mnCurPos; + SCROW mnLastPos; + bool mbCurValue; + }; + + class RangeIterator + { + public: + explicit RangeIterator(ScFlatBoolRowSegments const& rSegs); + bool getFirst(RangeData& rRange); + bool getNext(RangeData& rRange); + + private: + ScFlatBoolRowSegments const& mrSegs; + }; + + ScFlatBoolRowSegments(SCROW nMaxRow); + ScFlatBoolRowSegments(const ScFlatBoolRowSegments& r); + ~ScFlatBoolRowSegments(); + + bool setTrue(SCROW nRow1, SCROW nRow2); + bool setFalse(SCROW nRow1, SCROW nRow2); + bool getRangeData(SCROW nRow, RangeData& rData) const; + bool getRangeDataLeaf(SCROW nRow, RangeData& rData); + void removeSegment(SCROW nRow1, SCROW nRow2); + void insertSegment(SCROW nRow, SCROW nSize); + + SCROW findLastTrue() const; + + // Builds internal data (so that it doesn't build them while used in threads). + void makeReady(); + + OString dumpAsString(); + +private: + ::std::unique_ptr<ScFlatBoolSegmentsImpl> mpImpl; +}; + +class ScFlatBoolColSegments +{ +public: + struct RangeData + { + SCCOL mnCol1; + SCCOL mnCol2; + bool mbValue; + }; + ScFlatBoolColSegments(SCCOL nMaxCol); + ScFlatBoolColSegments(const ScFlatBoolColSegments& r); + ~ScFlatBoolColSegments(); + + bool setTrue(SCCOL nCol1, SCCOL nCol2); + bool setFalse(SCCOL nCol1, SCCOL nCol2); + bool getRangeData(SCCOL nCol, RangeData& rData); + void removeSegment(SCCOL nCol1, SCCOL nCol2); + void insertSegment(SCCOL nCol, SCCOL nSize); + + // Builds internal data (so that it doesn't build them while used in threads). + void makeReady(); + + OString dumpAsString(); + +private: + ::std::unique_ptr<ScFlatBoolSegmentsImpl> mpImpl; +}; + +class ScFlatUInt16SegmentsImpl; + +class ScFlatUInt16RowSegments +{ +public: + struct RangeData + { + SCROW mnRow1; + SCROW mnRow2; + sal_uInt16 mnValue; + }; + + class ForwardIterator + { + public: + explicit ForwardIterator(ScFlatUInt16RowSegments& rSegs); + + bool getValue(SCROW nPos, sal_uInt16& rVal); + SCROW getLastPos() const { return mnLastPos; } + + private: + ScFlatUInt16RowSegments& mrSegs; + + SCROW mnCurPos; + SCROW mnLastPos; + sal_uInt16 mnCurValue; + }; + + ScFlatUInt16RowSegments(SCROW nMaxRow, sal_uInt16 nDefault); + ScFlatUInt16RowSegments(const ScFlatUInt16RowSegments& r); + ~ScFlatUInt16RowSegments(); + + void setValue(SCROW nRow1, SCROW nRow2, sal_uInt16 nValue); + void setValueIf(SCROW nRow1, SCROW nRow2, sal_uInt16 nValue, + const std::function<bool(sal_uInt16)>& rPredicate); + sal_uInt16 getValue(SCROW nRow); + sal_uInt64 getSumValue(SCROW nRow1, SCROW nRow2); + bool getRangeData(SCROW nRow, RangeData& rData); + void removeSegment(SCROW nRow1, SCROW nRow2); + void insertSegment(SCROW nRow, SCROW nSize); + + SCROW findLastTrue(sal_uInt16 nValue) const; + + void enableTreeSearch(bool bEnable); + + // Builds internal data (so that it doesn't build them while used in threads). + void makeReady(); + + OString dumpAsString(); + +private: + ::std::unique_ptr<ScFlatUInt16SegmentsImpl> mpImpl; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/servuno.hxx b/sc/inc/servuno.hxx new file mode 100644 index 0000000000..b705f3ef01 --- /dev/null +++ b/sc/inc/servuno.hxx @@ -0,0 +1,75 @@ +/* -*- 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/Sequence.h> +#include <com/sun/star/uno/Reference.h> + +namespace com::sun::star::uno { class XInterface; } + +class ScDocShell; + +class ScServiceProvider +{ +public: + enum class Type + { + SHEET , URLFIELD , PAGEFIELD , PAGESFIELD , DATEFIELD , TIMEFIELD , TITLEFIELD , FILEFIELD , + SHEETFIELD , CELLSTYLE , PAGESTYLE , GRAPHICSTYLE , + // sheet + AUTOFORMAT , AUTOFORMATS, CELLRANGES , FUNCTIONDESCRIPTIONS , GLOBALSHEETSETTINGS , + RECENTFUNCTIONS , + // drawing layer tables + GRADTAB , HATCHTAB , BITMAPTAB , TRGRADTAB , MARKERTAB , DASHTAB , NUMRULES , + + DOCDEFLTS , DRAWDEFLTS , + + DOCSPRSETT , DOCCONF , + + IMAP_RECT , IMAP_CIRC , IMAP_POLY , + // Support creation of GraphicStorageHandler and EmbeddedObjectResolver + EXPORT_GRAPHIC_STORAGE_HANDLER , IMPORT_GRAPHIC_STORAGE_HANDLER , EXPORT_EOR , IMPORT_EOR , + + VALBIND , LISTCELLBIND , LISTSOURCE , + + CELLADDRESS , RANGEADDRESS , + + SHEETDOCSET , + + // BM + CHDATAPROV , CHART_PIVOTTABLE_DATAPROVIDER, + // formula parser + FORMULAPARS , OPCODEMAPPER , + // VBA specific + VBAOBJECTPROVIDER , VBACODENAMEPROVIDER , VBAGLOBALS , + + EXT_TIMEFIELD , + + INVALID + }; + + // pDocShell is not needed for all Services + static css::uno::Reference< css::uno::XInterface > + MakeInstance( Type nType, ScDocShell* pDocShell ); + static css::uno::Sequence<OUString> GetAllServiceNames(); + static Type GetProviderType(std::u16string_view rServiceName); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/shapeuno.hxx b/sc/inc/shapeuno.hxx new file mode 100644 index 0000000000..977c58be75 --- /dev/null +++ b/sc/inc/shapeuno.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 <com/sun/star/beans/XPropertyState.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/text/XTextContent.hpp> +#include <com/sun/star/text/XText.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/document/XEventsSupplier.hpp> +#include <com/sun/star/container/XChild.hpp> + +#include <cppuhelper/implbase.hxx> +#include <cppuhelper/implbase1.hxx> + +namespace com::sun::star { + namespace uno { + class XAggregation; + } + namespace drawing { + class XShape; + } +} + +class SdrObject; +struct SvEventDescription; +class ScMacroInfo; + +// object which aggregates all svx shape objects, +// to add own properties + +typedef ::cppu::WeakImplHelper < css::beans::XPropertySet + , css::beans::XPropertyState + , css::text::XTextContent + , css::document::XEventsSupplier + , css::lang::XServiceInfo + > ScShapeObj_Base; +typedef ::cppu::ImplHelper1 < css::text::XText + > ScShapeObj_TextBase; +typedef ::cppu::ImplHelper1 < css::container::XChild + > ScShapeObj_ChildBase; +class ScShapeObj final : public ScShapeObj_Base + ,public ScShapeObj_TextBase + ,public ScShapeObj_ChildBase +{ +private: + friend ScMacroInfo* ScShapeObj_getShapeHyperMacroInfo( const ScShapeObj* pShape, bool bCreate ); + css::uno::Reference< css::uno::XAggregation > mxShapeAgg; + // cached pointers to avoid repeated queryAggregation calls: + css::beans::XPropertySet* pShapePropertySet; + css::beans::XPropertyState* pShapePropertyState; + css::uno::Reference< css::beans::XPropertySetInfo > mxPropSetInfo; + bool bIsTextShape; + bool bIsNoteCaption; + + SdrObject* GetSdrObject() const noexcept; + + void GetShapePropertySet(); + void GetShapePropertyState(); + +friend class ShapeUnoEventAccessImpl; + +public: + static const SvEventDescription* GetSupportedMacroItems(); + + // ctor modifies xShape parameter + ScShapeObj( css::uno::Reference< + css::drawing::XShape > & xShape ); + virtual ~ScShapeObj() override; + + // XInterface + virtual css::uno::Any SAL_CALL queryInterface( + const css::uno::Type & rType ) override; + virtual void SAL_CALL acquire() noexcept override; + virtual void SAL_CALL release() noexcept override; + + // XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > + SAL_CALL getPropertySetInfo() override; + virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, + const css::uno::Any& aValue ) override; + virtual css::uno::Any SAL_CALL getPropertyValue( + const OUString& PropertyName ) override; + virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override; + virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override; + virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + + // XPropertyState + virtual css::beans::PropertyState SAL_CALL getPropertyState( const OUString& PropertyName ) override; + virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL + getPropertyStates( const css::uno::Sequence< OUString >& aPropertyName ) override; + virtual void SAL_CALL setPropertyToDefault( const OUString& PropertyName ) override; + virtual css::uno::Any SAL_CALL getPropertyDefault( const OUString& aPropertyName ) override; + + // XTextContent + virtual void SAL_CALL attach(const css::uno::Reference< css::text::XTextRange > & xTextRange) override; + virtual css::uno::Reference< css::text::XTextRange > SAL_CALL + getAnchor() override; + + // XComponent + virtual void SAL_CALL dispose() override; + virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > & aListener) override; + virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > & aListener) override; + + // XText + virtual void SAL_CALL insertTextContent( const css::uno::Reference< css::text::XTextRange >& xRange, + const css::uno::Reference< css::text::XTextContent >& xContent, + sal_Bool bAbsorb ) override; + virtual void SAL_CALL removeTextContent( const css::uno::Reference< css::text::XTextContent >& xContent ) override; + + // XSimpleText + virtual css::uno::Reference< css::text::XTextCursor > SAL_CALL + createTextCursor() override; + virtual css::uno::Reference< css::text::XTextCursor > SAL_CALL + createTextCursorByRange( const css::uno::Reference< css::text::XTextRange >& aTextPosition ) override; + virtual void SAL_CALL insertString( const css::uno::Reference< css::text::XTextRange >& xRange, + const OUString& aString, sal_Bool bAbsorb ) override; + virtual void SAL_CALL insertControlCharacter( const css::uno::Reference< css::text::XTextRange >& xRange, + sal_Int16 nControlCharacter, sal_Bool bAbsorb ) override; + + // XTextRange + virtual css::uno::Reference< css::text::XText > SAL_CALL + getText() override; + virtual css::uno::Reference< css::text::XTextRange > SAL_CALL + getStart() override; + virtual css::uno::Reference< css::text::XTextRange > SAL_CALL + getEnd() override; + virtual OUString SAL_CALL getString() override; + virtual void SAL_CALL setString( const OUString& aString ) override; + + // XChild + virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getParent() override; + virtual void SAL_CALL setParent( const css::uno::Reference< css::uno::XInterface >& xParent ) override; + + // XTypeProvider + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; + virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + + // XEventsSupplier + virtual css::uno::Reference< css::container::XNameReplace > SAL_CALL getEvents() override; + + // XServiceInfo + 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; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/sharedformula.hxx b/sc/inc/sharedformula.hxx new file mode 100644 index 0000000000..77567ea95d --- /dev/null +++ b/sc/inc/sharedformula.hxx @@ -0,0 +1,147 @@ +/* -*- 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/. + */ + +#pragma once + +#include "formulacell.hxx" +#include "mtvelements.hxx" + +#include <vector> + +#define USE_FORMULA_GROUP_LISTENER 1 + +namespace sc { + +class StartListeningContext; + +class SharedFormulaUtil +{ +public: + + /** + * Group formula cells stored in the passed container. The formula cells + * in the container are assumed to be all <b>non-shared</b>. + */ + template<typename Iter> + static void groupFormulaCells(const Iter& itBeg, const Iter& itEnd) + { + Iter it = itBeg; + ScFormulaCell* pPrev = *it; + ScFormulaCell* pCur = nullptr; + for (++it; it != itEnd; ++it, pPrev = pCur) + { + pCur = *it; + ScFormulaCell::CompareState eState = pCur->CompareByTokenArray(*pPrev); + if (eState == ScFormulaCell::NotEqual) + continue; + + ScFormulaCellGroupRef xGroup = pPrev->GetCellGroup(); + if (xGroup) + { + // Extend the group. + ++xGroup->mnLength; + pCur->SetCellGroup(xGroup); + continue; + } + + // Create a new group. + xGroup = pPrev->CreateCellGroup(2, eState == ScFormulaCell::EqualInvariant); + pCur->SetCellGroup(xGroup); + } + } + + /** Get shared formula top cell from position, if any, else nullptr. */ + static const ScFormulaCell* getSharedTopFormulaCell(const CellStoreType::position_type& aPos); + + /** + * Split existing shared formula range at specified position. The cell at + * specified position becomes the top cell of the lower shared formula + * range after this call. This method does nothing if the cell at + * specified position is not a formula cell. + * + * @param aPos position of cell to examine. + * @param pCxt context to be used, if any, may be nullptr. + * + * @return TRUE if there indeed was a split, else FALSE (e.g. split + * position was top or bottom cell or no formula group). + */ + static bool splitFormulaCellGroup(const CellStoreType::position_type& aPos, sc::EndListeningContext* pCxt); + + /** + * Split existing shared formula ranges at specified row positions. + * + * @param rCells cell storage container + * @param rBounds row positions at which to split existing shared formula + * ranges. Note that this method will directly modify this + * parameter to sort and remove duplicates. + * + * @return TRUE if there indeed was a split, else FALSE (e.g. split + * positions were only top or bottom cells or no formula group). + */ + static bool splitFormulaCellGroups(const ScDocument& rDoc, CellStoreType& rCells, std::vector<SCROW>& rBounds); + + /** + * See if two specified adjacent formula cells can be merged, and if they + * can, merge them into the same group. + * + * @param rPos position object of the first cell + * @param rCell1 first cell + * @param rCell2 second cell located immediately below the first cell. + * + * @return true if the cells are merged, false otherwise. If the two + * cells already belong to the same group, it returns false. + */ + static bool joinFormulaCells( + const CellStoreType::position_type& rPos, ScFormulaCell& rCell1, ScFormulaCell& rCell2 ); + /** + * Merge with an existing formula group (if any) located immediately above + * if the cell at specified position is a formula cell, and its formula + * tokens are identical to that of the above formula group. + * + * @param aPos position of cell to examine. + * + * @return true if the cells are merged, false otherwise. If the two + * cells already belong to the same group, it returns false. + */ + static bool joinFormulaCellAbove( const CellStoreType::position_type& aPos ); + + /** + * Turn a shared formula cell into a non-shared one, and split it off from + * the adjacent formula cell groups. + * + * @param aPos position of cell to examine + * @param rCell formula cell instance + */ + static void unshareFormulaCell(const CellStoreType::position_type& aPos, ScFormulaCell& rCell); + + /** + * Make specified formula cells non-shared ones, and split them off from + * their respective adjacent formula cell groups. + * + * @param rCells cell storage container + * @param rRows row positions at which to unshare formula cells. + */ + static void unshareFormulaCells(const ScDocument& rDoc, CellStoreType& rCells, std::vector<SCROW>& rRows); + + /** + * Have all formula cells belonging to a group start listening to their + * references. + * + * @param rCxt context object. + * @param ppSharedTop memory position of the pointer of the topmost + * formula cell instance in the cell storage. The + * caller is responsible for ensuring that it is indeed + * the topmost cell of a shared formula group. + */ + static void startListeningAsGroup( StartListeningContext& rCxt, ScFormulaCell** ppSharedTop ); +}; + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/sheetdata.hxx b/sc/inc/sheetdata.hxx new file mode 100644 index 0000000000..5d27c55f90 --- /dev/null +++ b/sc/inc/sheetdata.hxx @@ -0,0 +1,180 @@ +/* -*- 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 <editeng/editdata.hxx> +#include <map> +#include <unordered_set> +#include <utility> +#include <vector> + +#include "address.hxx" + +class SvXMLNamespaceMap; +enum class XmlStyleFamily; + +struct ScStreamEntry +{ + sal_Int64 mnStartOffset; + sal_Int64 mnEndOffset; + + ScStreamEntry() : + mnStartOffset(-1), + mnEndOffset(-1) + { + } + + ScStreamEntry( sal_Int64 nStart, sal_Int64 nEnd ) : + mnStartOffset(nStart), + mnEndOffset(nEnd) + { + } +}; + +struct ScCellStyleEntry +{ + OUString maName; + ScAddress maCellPos; + + ScCellStyleEntry( OUString aName, const ScAddress& rPos ) : + maName(std::move(aName)), + maCellPos(rPos) + { + } +}; + +struct ScNoteStyleEntry +{ + OUString maStyleName; + OUString maTextStyle; + ScAddress maCellPos; + + ScNoteStyleEntry( OUString aStyle, OUString aText, const ScAddress& rPos ) : + maStyleName(std::move(aStyle)), + maTextStyle(std::move(aText)), + maCellPos(rPos) + { + } +}; + +struct ScTextStyleEntry +{ + OUString maName; + ScAddress maCellPos; + ESelection maSelection; + + ScTextStyleEntry( OUString aName, const ScAddress& rPos, const ESelection& rSel ) : + maName(std::move(aName)), + maCellPos(rPos), + maSelection(rSel) + { + } +}; + +struct ScLoadedNamespaceEntry +{ + OUString maPrefix; + OUString maName; + sal_uInt16 mnKey; + + ScLoadedNamespaceEntry( OUString aPrefix, OUString aName, sal_uInt16 nKey ) : + maPrefix(std::move(aPrefix)), + maName(std::move(aName)), + mnKey(nKey) + { + } +}; + +class ScSheetSaveData +{ + std::unordered_set<OUString> maInitialPrefixes; + std::vector<ScLoadedNamespaceEntry> maLoadedNamespaces; + + std::vector<ScCellStyleEntry> maCellStyles; + std::vector<ScCellStyleEntry> maColumnStyles; + std::vector<ScCellStyleEntry> maRowStyles; + std::vector<ScCellStyleEntry> maTableStyles; + std::vector<ScNoteStyleEntry> maNoteStyles; + std::vector<ScTextStyleEntry> maNoteParaStyles; + std::vector<ScTextStyleEntry> maNoteTextStyles; + std::vector<ScTextStyleEntry> maTextStyles; + std::vector<bool> maBlocked; + std::vector<ScStreamEntry> maStreamEntries; + std::vector<ScStreamEntry> maSaveEntries; + SCTAB mnStartTab; + sal_Int64 mnStartOffset; + + ScNoteStyleEntry maPreviousNote; + + bool mbInSupportedSave; + +public: + ScSheetSaveData(); + ~ScSheetSaveData(); + + void AddCellStyle( const OUString& rName, const ScAddress& rCellPos ); + void AddColumnStyle( const OUString& rName, const ScAddress& rCellPos ); + void AddRowStyle( const OUString& rName, const ScAddress& rCellPos ); + void AddTableStyle( const OUString& rName, const ScAddress& rCellPos ); + + void HandleNoteStyles( const OUString& rStyleName, const OUString& rTextName, const ScAddress& rCellPos ); + void AddNoteContentStyle( XmlStyleFamily nFamily, const OUString& rName, const ScAddress& rCellPos, const ESelection& rSelection ); + + void AddTextStyle( const OUString& rName, const ScAddress& rCellPos, const ESelection& rSelection ); + + void BlockSheet( SCTAB nTab ); + bool IsSheetBlocked( SCTAB nTab ) const; + + void AddStreamPos( SCTAB nTab, sal_Int64 nStartOffset, sal_Int64 nEndOffset ); + void GetStreamPos( SCTAB nTab, sal_Int64& rStartOffset, sal_Int64& rEndOffset ) const; + bool HasStreamPos( SCTAB nTab ) const; + + void StartStreamPos( SCTAB nTab, sal_Int64 nStartOffset ); + void EndStreamPos( sal_Int64 nEndOffset ); + + bool HasStartPos() const { return mnStartTab >= 0; } + + void ResetSaveEntries(); + void AddSavePos( SCTAB nTab, sal_Int64 nStartOffset, sal_Int64 nEndOffset ); + void UseSaveEntries(); + + void StoreInitialNamespaces( const SvXMLNamespaceMap& rNamespaces ); + void StoreLoadedNamespaces( const SvXMLNamespaceMap& rNamespaces ); + bool AddLoadedNamespaces( SvXMLNamespaceMap& rNamespaces ) const; + + const std::vector<ScCellStyleEntry>& GetCellStyles() const { return maCellStyles; } + const std::vector<ScCellStyleEntry>& GetColumnStyles() const { return maColumnStyles; } + const std::vector<ScCellStyleEntry>& GetRowStyles() const { return maRowStyles; } + const std::vector<ScCellStyleEntry>& GetTableStyles() const { return maTableStyles; } + const std::vector<ScNoteStyleEntry>& GetNoteStyles() const { return maNoteStyles; } + const std::vector<ScTextStyleEntry>& GetNoteParaStyles() const { return maNoteParaStyles; } + const std::vector<ScTextStyleEntry>& GetNoteTextStyles() const { return maNoteTextStyles; } + const std::vector<ScTextStyleEntry>& GetTextStyles() const { return maTextStyles; } + + bool IsInSupportedSave() const { return mbInSupportedSave;} + void SetInSupportedSave( bool bSet ); +}; + +struct ScFormatSaveData +{ + std::map<sal_uInt64, OUString> maIDToName; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/sheetevents.hxx b/sc/inc/sheetevents.hxx new file mode 100644 index 0000000000..3ccecc490a --- /dev/null +++ b/sc/inc/sheetevents.hxx @@ -0,0 +1,53 @@ +/* -*- 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 <rtl/ustring.hxx> +#include <memory> + +#include <optional> + +enum class ScSheetEventId { + FOCUS, UNFOCUS, SELECT, DOUBLECLICK, RIGHTCLICK, CHANGE, CALCULATE, COUNT, + NOTFOUND = -1 // used as an error return value +}; + +class ScSheetEvents +{ + std::unique_ptr<std::optional<OUString>[]> mpScriptNames; + + void Clear(); + +public: + ScSheetEvents(); + ScSheetEvents(const ScSheetEvents& rOther); + ~ScSheetEvents(); + + ScSheetEvents& operator= (const ScSheetEvents& rOther); + + const OUString* GetScript(ScSheetEventId nEvent) const; + void SetScript(ScSheetEventId nEvent, const OUString* pNew); + + static OUString GetEventName(ScSheetEventId nEvent); + static sal_Int32 GetVbaSheetEventId(ScSheetEventId nEvent); + static sal_Int32 GetVbaDocumentEventId(ScSheetEventId nEvent); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/sheetlimits.hxx b/sc/inc/sheetlimits.hxx new file mode 100644 index 0000000000..506f63efb0 --- /dev/null +++ b/sc/inc/sheetlimits.hxx @@ -0,0 +1,81 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * 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 <salhelper/simplereferenceobject.hxx> +#include "address.hxx" + +// Because some stuff needs this info, and those objects lifetimes sometimes exceeds the lifetime +// of the ScDocument. +struct ScSheetLimits final : public salhelper::SimpleReferenceObject +{ + const SCCOL mnMaxCol; /// Maximum addressable column + const SCROW mnMaxRow; /// Maximum addressable row + + ScSheetLimits(SCCOL nMaxCol, SCROW nMaxRow) + : mnMaxCol(nMaxCol) + , mnMaxRow(nMaxRow) + { + } + + SC_DLLPUBLIC static ScSheetLimits CreateDefault(); + + [[nodiscard]] bool ValidCol(SCCOL nCol) const { return ::ValidCol(nCol, mnMaxCol); } + [[nodiscard]] bool ValidRow(SCROW nRow) const { return ::ValidRow(nRow, mnMaxRow); } + [[nodiscard]] bool ValidColRow(SCCOL nCol, SCROW nRow) const + { + return ::ValidColRow(nCol, nRow, mnMaxCol, mnMaxRow); + } + [[nodiscard]] bool ValidColRowTab(SCCOL nCol, SCROW nRow, SCTAB nTab) const + { + return ::ValidColRowTab(nCol, nRow, nTab, mnMaxCol, mnMaxRow); + } + [[nodiscard]] bool ValidRange(const ScRange& rRange) const + { + return ::ValidRange(rRange, mnMaxCol, mnMaxRow); + } + [[nodiscard]] bool ValidAddress(const ScAddress& rAddress) const + { + return ::ValidAddress(rAddress, mnMaxCol, mnMaxRow); + } + [[nodiscard]] SCCOL SanitizeCol(SCCOL nCol) const { return ::SanitizeCol(nCol, mnMaxCol); } + [[nodiscard]] SCROW SanitizeRow(SCROW nRow) const { return ::SanitizeRow(nRow, mnMaxRow); } + + // equivalent of MAXROW in address.hxx + SCROW MaxRow() const { return mnMaxRow; } + // equivalent of MAXCOL in address.hxx + SCCOL MaxCol() const { return mnMaxCol; } + // equivalent of MAXROWCOUNT in address.hxx + SCROW GetMaxRowCount() const { return mnMaxRow + 1; } + // equivalent of MAXCOLCOUNT in address.hxx + SCCOL GetMaxColCount() const { return mnMaxCol + 1; } + // max row number as string + OUString MaxRowAsString() const + { + return mnMaxRow == MAXROW ? MAXROW_STRING : MAXROW_JUMBO_STRING; + } + // mac col as string ("AMJ" or "XFD") + OUString MaxColAsString() const + { + return mnMaxCol == MAXCOL ? MAXCOL_STRING : MAXCOL_JUMBO_STRING; + } +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/shellids.hxx b/sc/inc/shellids.hxx new file mode 100644 index 0000000000..ecef989d87 --- /dev/null +++ b/sc/inc/shellids.hxx @@ -0,0 +1,44 @@ +/* -*- 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 + +// Sfx Interface-IDs +#define SCID_APP (SFX_INTERFACE_SC_START+SfxInterfaceId(0)) +#define SCID_DOC_SHELL (SFX_INTERFACE_SC_START+SfxInterfaceId(1)) +#define SCID_TABVIEW_SHELL (SFX_INTERFACE_SC_START+SfxInterfaceId(2)) +#define SCID_TABPOP_SHELL (SFX_INTERFACE_SC_START+SfxInterfaceId(3)) +#define SCID_EDIT_SHELL (SFX_INTERFACE_SC_START+SfxInterfaceId(4)) +#define SCID_DRAW_SHELL (SFX_INTERFACE_SC_START+SfxInterfaceId(5)) +#define SCID_DRAW_TEXT_SHELL (SFX_INTERFACE_SC_START+SfxInterfaceId(6)) +#define SCID_PREVIEW_SHELL (SFX_INTERFACE_SC_START+SfxInterfaceId(7)) +#define SCID_PIVOT_SHELL (SFX_INTERFACE_SC_START+SfxInterfaceId(8)) +#define SCID_AUDITING_SHELL (SFX_INTERFACE_SC_START+SfxInterfaceId(9)) +#define SCID_FORM_SHELL (SFX_INTERFACE_SC_START+SfxInterfaceId(10)) + +#define SCID_FORMAT_SHELL (SFX_INTERFACE_SC_START+SfxInterfaceId(11)) +#define SCID_CELL_SHELL (SFX_INTERFACE_SC_START+SfxInterfaceId(12)) +#define SCID_OLEOBJECT_SHELL (SFX_INTERFACE_SC_START+SfxInterfaceId(13)) +#define SCID_CHART_SHELL (SFX_INTERFACE_SC_START+SfxInterfaceId(14)) +#define SCID_GRAPHIC_SHELL (SFX_INTERFACE_SC_START+SfxInterfaceId(15)) +#define SCID_PAGEBREAK_SHELL (SFX_INTERFACE_SC_START+SfxInterfaceId(16)) +#define SCID_MEDIA_SHELL (SFX_INTERFACE_SC_START+SfxInterfaceId(17)) +#define SCID_SPARKLINE_SHELL (SFX_INTERFACE_SC_START+SfxInterfaceId(18)) + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/simpleformulacalc.hxx b/sc/inc/simpleformulacalc.hxx new file mode 100644 index 0000000000..f51a635622 --- /dev/null +++ b/sc/inc/simpleformulacalc.hxx @@ -0,0 +1,58 @@ +/* -*- 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/. + */ + +#pragma once + +#include <memory> +#include <formula/grammar.hxx> + +#include "address.hxx" +#include "formularesult.hxx" + +class ScDocument; +class ScTokenArray; + +class ScSimpleFormulaCalculator +{ +private: + SvNumFormatType mnFormatType; + + bool mbCalculated; + std::unique_ptr<ScTokenArray> mpCode; + ScAddress maAddr; + ScDocument& mrDoc; + ScFormulaResult maResult; + formula::FormulaGrammar::Grammar maGram; + bool mbMatrixResult; + OUString maMatrixFormulaResult; + bool mbLimitString; + bool mbMatrixFormula; + +public: + ScSimpleFormulaCalculator(ScDocument& rDoc, const ScAddress& rAddr, + const OUString& rFormula, bool bMatrixFormula, + formula::FormulaGrammar::Grammar eGram = formula::FormulaGrammar::GRAM_DEFAULT); + ~ScSimpleFormulaCalculator(); + + void Calculate(); + bool IsValue(); + bool IsMatrix(); + FormulaError GetErrCode(); + double GetValue(); + svl::SharedString GetString(); + SvNumFormatType GetFormatType() const { return mnFormatType; } + + bool HasColRowName() const; + + ScTokenArray* GetCode(); + + void SetLimitString(bool bLimitString); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/sortparam.hxx b/sc/inc/sortparam.hxx new file mode 100644 index 0000000000..94817b862b --- /dev/null +++ b/sc/inc/sortparam.hxx @@ -0,0 +1,189 @@ +/* -*- 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 + +#define DEFSORT 3 + +#include <vector> + +#include "address.hxx" +#include <editeng/colritem.hxx> +#include <com/sun/star/lang/Locale.hpp> +#include "scdllapi.h" + +struct ScSubTotalParam; +struct ScQueryParam; + +enum class ScColorSortMode { + None, + TextColor, + BackgroundColor +}; + +struct ScSortKeyState +{ + SCCOLROW nField; + bool bDoSort; + bool bAscending; + ScColorSortMode aColorSortMode; + Color aColorSortColor; +}; + +/** Struct to hold non-data extended area, used with + ScDocument::ShrinkToUsedDataArea(). +*/ +struct ScDataAreaExtras +{ + /// If TRUE, consider the presence of cell notes besides data. + bool mbCellNotes = false; + /// If TRUE, consider the presence of draw objects anchored to the cell. + bool mbCellDrawObjects = false; + /// If TRUE, consider the presence of cell formats. + bool mbCellFormats = false; + SCCOL mnStartCol = SCCOL_MAX; + SCROW mnStartRow = SCROW_MAX; + SCCOL mnEndCol = -1; + SCROW mnEndRow = -1; + + bool anyExtrasWanted() const { return mbCellNotes || mbCellDrawObjects || mbCellFormats; } + void resetArea() { mnStartCol = SCCOL_MAX; mnStartRow = SCROW_MAX; mnEndCol = -1; mnEndRow = -1; } + + bool operator==( const ScDataAreaExtras& rOther ) const + { + // Ignore area range, this is used in ScSortParam::operator==(). + return mbCellNotes == rOther.mbCellNotes + && mbCellDrawObjects == rOther.mbCellDrawObjects + && mbCellFormats == rOther.mbCellFormats; + } + + enum class Clip + { + None, + Col, + Row + }; + + /// Obtain the overall range if area extras are larger. + void GetOverallRange( SCCOL& nCol1, SCROW& nRow1, SCCOL& nCol2, SCROW& nRow2, Clip eClip = Clip::None ) const + { + if (eClip != Clip::Col) + { + if (nCol1 > mnStartCol) + nCol1 = mnStartCol; + if (nCol2 < mnEndCol) + nCol2 = mnEndCol; + } + if (eClip != Clip::Row) + { + if (nRow1 > mnStartRow) + nRow1 = mnStartRow; + if (nRow2 < mnEndRow) + nRow2 = mnEndRow; + } + } + + /// Set the overall range. + void SetOverallRange( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ) + { + mnStartCol = nCol1; + mnStartRow = nRow1; + mnEndCol = nCol2; + mnEndRow = nRow2; + } +}; + +struct SC_DLLPUBLIC ScSortParam +{ + SCCOL nCol1; + SCROW nRow1; + SCCOL nCol2; + SCROW nRow2; + ScDataAreaExtras aDataAreaExtras; + sal_uInt16 nUserIndex; + bool bHasHeader; + bool bByRow; + bool bCaseSens; + bool bNaturalSort; + bool bUserDef; + bool bInplace; + SCTAB nDestTab; + SCCOL nDestCol; + SCROW nDestRow; + ::std::vector<ScSortKeyState> + maKeyState; + css::lang::Locale aCollatorLocale; + OUString aCollatorAlgorithm; + sal_uInt16 nCompatHeader; + + ScSortParam(); + ScSortParam( const ScSortParam& r ); + /// SubTotals sort + ScSortParam( const ScSubTotalParam& rSub, const ScSortParam& rOld ); + /// TopTen sort + ScSortParam( const ScQueryParam&, SCCOL nCol ); + ~ScSortParam(); + + ScSortParam& operator= ( const ScSortParam& r ); + bool operator== ( const ScSortParam& rOther ) const; + void Clear (); + void MoveToDest(); + + sal_uInt16 GetSortKeyCount() const { return maKeyState.size(); } +}; + +namespace sc { + +struct ReorderParam +{ + /** + * This sort range already takes into account the presence or absence of + * header row / column i.e. if a header row / column is present, it + * excludes that row / column. + */ + ScRange maSortRange; + ScDataAreaExtras maDataAreaExtras; + + /** + * List of original column / row positions after reordering. + */ + std::vector<SCCOLROW> maOrderIndices; + bool mbByRow; + bool mbHiddenFiltered; + bool mbUpdateRefs; + bool mbHasHeaders; + + /** + * Reorder the position indices such that it can be used to undo the + * original reordering. + */ + void reverse(); + + ReorderParam() + : mbByRow(false) + , mbHiddenFiltered(false) + , mbUpdateRefs(false) + , mbHasHeaders(false) + { + } +}; + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/spellcheckcontext.hxx b/sc/inc/spellcheckcontext.hxx new file mode 100644 index 0000000000..f068d91f51 --- /dev/null +++ b/sc/inc/spellcheckcontext.hxx @@ -0,0 +1,63 @@ +/* -*- 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/. + */ + +#pragma once + +#include <i18nlangtag/lang.h> +#include <editeng/misspellrange.hxx> +#include "types.hxx" + +#include <memory> +#include <vector> + +class ScDocument; +class ScTabEditEngine; + +namespace sc +{ +/** + * Class shared between grid windows to cache + * spelling results. + */ +class SpellCheckContext +{ + class SpellCheckCache; + struct SpellCheckStatus; + struct SpellCheckResult; + + std::unique_ptr<SpellCheckCache> mpCache; + std::unique_ptr<SpellCheckResult> mpResult; + ScDocument* pDoc; + std::unique_ptr<ScTabEditEngine> mpEngine; + std::unique_ptr<SpellCheckStatus> mpStatus; + SCTAB mnTab; + LanguageType meLanguage; + +public: + SpellCheckContext(ScDocument* pDocument, SCTAB nTab); + ~SpellCheckContext(); + void dispose(); + + bool isMisspelled(SCCOL nCol, SCROW nRow) const; + const std::vector<editeng::MisspellRanges>* getMisspellRanges(SCCOL nCol, SCROW nRow) const; + void setMisspellRanges(SCCOL nCol, SCROW nRow, + const std::vector<editeng::MisspellRanges>* pRanges); + + void reset(); + void resetForContentChange(); + void setTabNo(SCTAB nTab); + +private: + void ensureResults(SCCOL nCol, SCROW nRow); + void resetCache(bool bContentChangeOnly = false); + void setup(); +}; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/srchuno.hxx b/sc/inc/srchuno.hxx new file mode 100644 index 0000000000..90381fa485 --- /dev/null +++ b/sc/inc/srchuno.hxx @@ -0,0 +1,77 @@ +/* -*- 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 <memory> +#include <com/sun/star/util/XReplaceDescriptor.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <svl/itemprop.hxx> +#include <comphelper/servicehelper.hxx> +#include <cppuhelper/implbase.hxx> + +class SvxSearchItem; + +class ScCellSearchObj final : public cppu::WeakImplHelper< + css::util::XReplaceDescriptor, + css::lang::XServiceInfo > +{ +private: + SfxItemPropertySet aPropSet; + std::unique_ptr<SvxSearchItem> + pSearchItem; + +public: + ScCellSearchObj(); + virtual ~ScCellSearchObj() override; + + SvxSearchItem* GetSearchItem() const { return pSearchItem.get(); } + + // XReplaceDescriptor + virtual OUString SAL_CALL getReplaceString() override; + virtual void SAL_CALL setReplaceString( const OUString& aReplaceString ) override; + + // XSearchDescriptor + virtual OUString SAL_CALL getSearchString() override; + virtual void SAL_CALL setSearchString( const OUString& aString ) override; + + // search/replace should be called from outside (from XSearchable)... + + // XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > + SAL_CALL getPropertySetInfo() override; + virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, + const css::uno::Any& aValue ) override; + virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override; + virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override; + virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override; + virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + + // XServiceInfo + 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; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/stlalgorithm.hxx b/sc/inc/stlalgorithm.hxx new file mode 100644 index 0000000000..f2143b9a84 --- /dev/null +++ b/sc/inc/stlalgorithm.hxx @@ -0,0 +1,76 @@ +/* -*- 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/. + */ + +#pragma once + +#include <limits> + +#include <rtl/alloc.h> + +namespace sc { + +/** + * Custom allocator for STL container to ensure that the base address of + * allocated storage is aligned to a specified boundary. + */ +template<typename T, size_t Alignment> +class AlignedAllocator +{ +public: + typedef T value_type; + typedef size_t size_type; + typedef std::ptrdiff_t difference_type; + + typedef T* pointer; + typedef const T* const_pointer; + typedef T* void_pointer; + + typedef T& reference; + typedef const T& const_reference; + + template<typename Type2> + struct rebind + { + typedef AlignedAllocator<Type2,Alignment> other; + }; + + AlignedAllocator() {} + + template<typename Type2> + AlignedAllocator(const AlignedAllocator<Type2,Alignment>&) {} + + static void construct(T* p, const value_type& val) { new(p) value_type(val); } + static void destroy(T* p) + { + p->~value_type(); + (void)p; // avoid bogus MSVC '12 "unreferenced formal parameter" warning + } + + static size_type max_size() + { + return std::numeric_limits<size_type>::max() / sizeof(value_type); + } + + bool operator== (const AlignedAllocator&) const { return true; } + bool operator!= (const AlignedAllocator&) const { return false; } + + static pointer allocate(size_type n) + { + return static_cast<pointer>(rtl_allocateAlignedMemory(Alignment, n*sizeof(value_type))); + } + + static void deallocate(pointer p, size_type) + { + rtl_freeAlignedMemory(p); + } +}; + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/stlpool.hxx b/sc/inc/stlpool.hxx new file mode 100644 index 0000000000..131b82c749 --- /dev/null +++ b/sc/inc/stlpool.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 <svl/style.hxx> +#include "scdllapi.h" + +class ScStyleSheet; +class ScDocument; + +class SC_DLLPUBLIC ScStyleSheetPool final : public SfxStyleSheetPool +{ +public: + ScStyleSheetPool( const SfxItemPool& rPool, + ScDocument* pDocument ); + + void SetDocument( ScDocument* pDocument ); + ScDocument* GetDocument() const { return pDoc; } + + virtual void Remove( SfxStyleSheetBase* pStyle ) override; + + void SetActualStyleSheet ( SfxStyleSheetBase* pActStyleSheet ) + { pActualStyleSheet = pActStyleSheet; } + + SfxStyleSheetBase* GetActualStyleSheet () + { return pActualStyleSheet; } + + void CreateStandardStyles(); + void CopyStdStylesFrom( ScStyleSheetPool* pSrcPool ); + + void CopyUsedGraphicStylesFrom( SfxStyleSheetBasePool* pSrcPool ); + void CopyStyleFrom( SfxStyleSheetBasePool* pSrcPool, + const OUString& rName, SfxStyleFamily eFamily, + bool bNewStyleHierarchy = false ); + + bool HasStandardStyles() const { return bHasStandardStyles; } + + ScStyleSheet* FindCaseIns( const OUString& rName, SfxStyleFamily eFam ); + // Finds Para style with given name case-insensitively, or STR_STYLENAME_STANDARD + ScStyleSheet* FindAutoStyle(const OUString& rName); + + virtual SfxStyleSheetBase& Make( const OUString&, SfxStyleFamily eFam, + SfxStyleSearchBits nMask = SfxStyleSearchBits::All) override; + + void setAllParaStandard(); + +private: + virtual ~ScStyleSheetPool() override; + + using SfxStyleSheetPool::Create; // calcwarnings: Create(const SfxStyleSheet&) - ever used? + + virtual rtl::Reference<SfxStyleSheetBase> Create( const OUString& rName, + SfxStyleFamily eFamily, + SfxStyleSearchBits nMask) override; + virtual rtl::Reference<SfxStyleSheetBase> Create( const SfxStyleSheetBase& rStyle ) override; + + SfxStyleSheetBase* pActualStyleSheet; + ScDocument* pDoc; + bool bHasStandardStyles; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/stlsheet.hxx b/sc/inc/stlsheet.hxx new file mode 100644 index 0000000000..e1e2c5b85e --- /dev/null +++ b/sc/inc/stlsheet.hxx @@ -0,0 +1,70 @@ +/* -*- 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 <svl/style.hxx> + +#include "scdllapi.h" + +class ScStyleSheetPool; + +class SAL_DLLPUBLIC_RTTI ScStyleSheet final : public SfxStyleSheet +{ +friend class ScStyleSheetPool; + +public: + + enum class Usage + { + UNKNOWN, + USED, + NOTUSED + }; + + ScStyleSheet( const ScStyleSheet& rStyle ); + + virtual bool SetParent ( const OUString& rParentName ) override; + SC_DLLPUBLIC void ResetParent(); + SC_DLLPUBLIC virtual SfxItemSet& GetItemSet() override; + virtual bool IsUsed () const override; + virtual bool HasFollowSupport () const override; + virtual bool HasParentSupport () const override; + + virtual bool SetName(const OUString& rNewName, bool bReindexNow = true) override; + + void SetUsage( ScStyleSheet::Usage eUse ) const { eUsage = eUse; } + ScStyleSheet::Usage GetUsage() const { return eUsage; } + + /// Fix for expensive dynamic_cast + virtual bool isScStyleSheet() const override { return true; } +private: + virtual ~ScStyleSheet() override; + + ScStyleSheet( const OUString& rName, + const ScStyleSheetPool& rPool, + SfxStyleFamily eFamily, + SfxStyleSearchBits nMask ); + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + mutable ScStyleSheet::Usage eUsage; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/strings.hrc b/sc/inc/strings.hrc new file mode 100644 index 0000000000..266cb4cc6c --- /dev/null +++ b/sc/inc/strings.hrc @@ -0,0 +1,415 @@ +/* -*- 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 + +#define NC_(Context, String) TranslateId(Context, u8##String) +#define NNC_(Context, StringSingular, StringPlural) TranslateNId(Context, reinterpret_cast<char const *>(u8##StringSingular), reinterpret_cast<char const *>(u8##StringPlural)) + +// Strings for interface names ------------------------------------------- + +#define SCSTR_LONG_SCDOC_NAME_60 NC_("SCSTR_LONG_SCDOC_NAME", "%PRODUCTNAME Spreadsheet format (calc6)") +#define SCSTR_LONG_SCDOC_NAME_80 NC_("SCSTR_LONG_SCDOC_NAME", "%PRODUCTNAME %PRODUCTVERSION Spreadsheet") +#define SCSTR_UNDEFINED NC_("SCSTR_UNDEFINED", "- undefined -") +#define SCSTR_NONE NC_("SCSTR_NONE", "- none -") +#define SCSTR_ALL NC_("SCSTR_ALL", "- all -") +#define SCSTR_MULTIPLE NC_("SCSTR_MULTIPLE", "- multiple -") +#define SCSTR_STDFILTER NC_("SCSTR_STDFILTER", "Standard Filter...") +#define SCSTR_CLEAR_FILTER NC_("SCSTR_CLEAR_FILTER", "Clear Filter") +#define SCSTR_TOP10FILTER NC_("SCSTR_TOP10FILTER", "Top 10") +#define SCSTR_BOTTOM10FILTER NC_("SCSTR_BOTTOM10FILTER", "Bottom 10") +#define SCSTR_FILTER_EMPTY NC_("SCSTR_FILTER_EMPTY", "Empty") +#define SCSTR_FILTER_NOTEMPTY NC_("SCSTR_FILTER_NOTEMPTY", "Not Empty") +#define SCSTR_FILTER_COLOR NC_("SCSTR_FILTER_COLOR", "Filter by Color") +#define SCSTR_FILTER_CONDITION NC_("SCSTR_FILTER_CONDITION", "Filter by Condition") +// This must match the translation of the same strings of standardfilterdialog|cond +#define SCSTR_FILTER_FONT_COLOR_COND NC_("STANDARDFILTERDIALOG_COND", "Font color") +#define SCSTR_FILTER_BACKGROUND_COLOR_COND NC_("STANDARDFILTERDIALOG_COND", "Background color") +#define SCSTR_FILTER_NO_FILL NC_("SCSTR_FILTER_NO_FILL", "No Fill") +#define SCSTR_FILTER_AUTOMATIC_COLOR NC_("SCSTR_FILTER_AUTOMATIC_COLOR", "Automatic") +#define SCSTR_SORT_COLOR NC_("SCSTR_SORT_COLOR", "Sort by Color") +#define SCSTR_NONAME NC_("SCSTR_NONAME", "unnamed") +#define SCSTR_INSERT_RTL NC_("SCSTR_INSERT_RTL", "Shift cells left") +// "%1 is replaced to column letter, such as 'Column A'" +#define SCSTR_COLUMN_LETTER NC_("SCSTR_COLUMN_LETTER", "Column %1") +#define SCSTR_COLUMN NC_("SCSTR_COLUMN", "Column") +#define SCSTR_ROW NC_("SCSTR_ROW", "Row") +#define SCSTR_TABLE NC_("SCSTR_TABLE", "Sheet") +#define SCSTR_NAME NC_("SCSTR_NAME", "Name") +#define SCSTR_APDTABLE NC_("SCSTR_APDTABLE", "Append Sheet") +#define SCSTR_RENAMETAB NC_("SCSTR_RENAMETAB", "Rename Sheet") +#define SCSTR_SET_TAB_BG_COLOR NC_("SCSTR_SET_TAB_BG_COLOR", "Tab Color") +#define SCSTR_NO_TAB_BG_COLOR NC_("SCSTR_NO_TAB_BG_COLOR", "Default") +#define SCSTR_RENAMEOBJECT NC_("SCSTR_RENAMEOBJECT", "Name Object") +#define STR_INSERTGRAPHIC NC_("STR_INSERTGRAPHIC", "Insert Image") +#define SCSTR_TOTAL NNC_("SCSTR_TOTAL", "One result found", "%1 results found") +#define SCSTR_SKIPPED NC_("SCSTR_SKIPPED", "(only %1 are listed)") +#define SCSTR_RESULTS_CLAMPED NC_("SCSTR_RESULTS_CLAMPED", "More than %1 results found (stopped counting)") +// Attribute +#define SCSTR_PROTECTDOC NC_("SCSTR_PROTECTDOC", "Protect Spreadsheet Structure") +#define SCSTR_UNPROTECTDOC NC_("SCSTR_UNPROTECTDOC", "Unprotect Spreadsheet Structure") +#define SCSTR_UNPROTECTTAB NC_("SCSTR_UNPROTECTTAB", "Unprotect Sheet") +#define SCSTR_CHG_PROTECT NC_("SCSTR_CHG_PROTECT", "Protect Records") +#define SCSTR_CHG_UNPROTECT NC_("SCSTR_CHG_UNPROTECT", "Unprotect Records") +#define SCSTR_PASSWORD NC_("SCSTR_PASSWORD", "Password:") +#define SCSTR_PASSWORDOPT NC_("SCSTR_PASSWORDOPT", "Password (optional):") +#define SCSTR_WRONGPASSWORD NC_("SCSTR_WRONGPASSWORD", "Incorrect Password") +#define SCSTR_END NC_("SCSTR_END", "~End") +#define SCSTR_UNKNOWN NC_("SCSTR_UNKNOWN", "Unknown") +#define SCSTR_VALID_MINIMUM NC_("SCSTR_VALID_MINIMUM", "~Minimum") +#define SCSTR_VALID_MAXIMUM NC_("SCSTR_VALID_MAXIMUM", "~Maximum") +#define SCSTR_VALID_VALUE NC_("SCSTR_VALID_VALUE", "~Value") +#define SCSTR_VALID_FORMULA NC_("SCSTR_VALID_FORMULA", "~Formula") +#define SCSTR_VALID_RANGE NC_("SCSTR_VALID_RANGE", "~Source") +#define SCSTR_VALID_LIST NC_("SCSTR_VALID_LIST", "~Entries") +// for dialogues: +#define SCSTR_CHARSET_USER NC_("SCSTR_CHARSET_USER", "System") +#define SCSTR_COLUMN_USER NC_("SCSTR_COLUMN_USER", "Standard;Text;Date (DMY);Date (MDY);Date (YMD);US English;Hide") +#define SCSTR_FIELDSEP_TAB NC_("SCSTR_FIELDSEP_TAB", "Tab") +#define SCSTR_FIELDSEP_SPACE NC_("SCSTR_FIELDSEP_SPACE", "space") +#define SCSTR_UNDO_GRAFFILTER NC_("SCSTR_UNDO_GRAFFILTER", "Image Filter") +#define STR_CAPTION_DEFAULT_TEXT NC_("STR_CAPTION_DEFAULT_TEXT", "Text") +// Select tables dialog title +#define STR_DLG_SELECTTABLES_TITLE NC_("STR_DLG_SELECTTABLES_TITLE", "Select Sheets") +#define STR_DLG_SELECTTABLE_TITLE NC_("STR_DLG_SELECTTABLE_TITLE", "Go to Sheet") +#define STR_DLG_SELECTTABLE_MASK NC_("STR_DLG_SELECTTABLE_MASK", "~Type a Sheet Name") +// Select tables dialog listbox +#define STR_DLG_SELECTTABLES_LBNAME NC_("STR_DLG_SELECTTABLES_LBNAME", "~Selected sheets") +#define STR_DLG_SELECTTABLE_LBNAME NC_("STR_DLG_SELECTTABLE_LBNAME", "~Sheets") +#define STR_ACC_CSVRULER_NAME NC_("STR_ACC_CSVRULER_NAME", "Ruler") +#define STR_ACC_CSVRULER_DESCR NC_("STR_ACC_CSVRULER_DESCR", "This ruler manages objects at fixed positions.") +#define STR_ACC_CSVGRID_NAME NC_("STR_ACC_CSVGRID_NAME", "Preview") +#define STR_ACC_CSVGRID_DESCR NC_("STR_ACC_CSVGRID_DESCR", "This sheet shows how the data will be arranged in the document.") +#define STR_ACC_DOC_NAME NC_("STR_ACC_DOC_NAME", "Document view") +#define STR_ACC_TABLE_NAME NC_("STR_ACC_TABLE_NAME", "Sheet %1") +#define STR_ACC_CELL_NAME NC_("STR_ACC_CELL_NAME", "Cell %1") +#define STR_ACC_LEFTAREA_NAME NC_("STR_ACC_LEFTAREA_NAME", "Left area") +#define STR_ACC_PREVIEWDOC_NAME NC_("STR_ACC_PREVIEWDOC_NAME", "Page preview") +#define STR_ACC_CENTERAREA_NAME NC_("STR_ACC_CENTERAREA_NAME", "Center area") +#define STR_ACC_RIGHTAREA_NAME NC_("STR_ACC_RIGHTAREA_NAME", "Right area") +#define STR_ACC_HEADER_NAME NC_("STR_ACC_HEADER_NAME", "Header of page %1") +#define STR_ACC_FOOTER_NAME NC_("STR_ACC_FOOTER_NAME", "Footer of page %1") +#define STR_ACC_EDITLINE_NAME NC_("STR_ACC_EDITLINE_NAME", "Input line") +#define STR_ACC_EDITLINE_DESCR NC_("STR_ACC_EDITLINE_DESCR", "This is where you enter or edit text, numbers and formulas.") +#define SCSTR_MEDIASHELL NC_("SCSTR_MEDIASHELL", "Media Playback") +#define RID_SCSTR_ONCLICK NC_("RID_SCSTR_ONCLICK", "Mouse button pressed") +#define STR_ACC_TOOLBAR_FORMULA NC_("STR_ACC_TOOLBAR_FORMULA", "Formula Tool Bar") +#define STR_ACC_DOC_SPREADSHEET NC_("STR_ACC_DOC_SPREADSHEET", "%PRODUCTNAME Spreadsheets") +#define STR_ACC_DOC_SPREADSHEET_READONLY NC_("STR_ACC_DOC_SPREADSHEET_READONLY", "(read-only)") +#define STR_ACC_DOC_PREVIEW_SUFFIX NC_("STR_ACC_DOC_PREVIEW_SUFFIX", "(Preview mode)") +#define SCSTR_PRINTOPT_PAGES NC_("SCSTR_PRINTOPT_PAGES", "Pages:") +#define SCSTR_PRINTOPT_SUPPRESSEMPTY NC_("SCSTR_PRINTOPT_SUPPRESSEMPTY", "~Suppress output of empty pages") +#define SCSTR_PRINTOPT_ALLSHEETS NC_("SCSTR_PRINTOPT_ALLSHEETS", "Print All Sheets") +#define SCSTR_PRINTOPT_SELECTEDSHEETS NC_("SCSTR_PRINTOPT_SELECTEDSHEETS", "Print Selected Sheets") +#define SCSTR_PRINTOPT_SELECTEDCELLS NC_("SCSTR_PRINTOPT_SELECTEDCELLS", "Print Selected Cells") +#define SCSTR_PRINTOPT_FROMWHICH NC_("SCSTR_PRINTOPT_FROMWHICH", "From which:") +#define SCSTR_PRINTOPT_PRINTALLPAGES NC_("SCSTR_PRINTOPT_PRINTALLPAGES", "All ~Pages") +#define SCSTR_PRINTOPT_PRINTPAGES NC_("SCSTR_PRINTOPT_PRINTPAGES", "Pa~ges:") +#define SCSTR_PRINTOPT_PRODNAME NC_("SCSTR_PRINTOPT_PRODNAME", "%PRODUCTNAME %s") +#define SCSTR_DDEDOC_NOT_LOADED NC_("SCSTR_DDEDOC_NOT_LOADED", "The following DDE source could not be updated possibly because the source document was not open. Please launch the source document and try again." ) +#define SCSTR_EXTDOC_NOT_LOADED NC_("SCSTR_EXTDOC_NOT_LOADED", "The following external file could not be loaded. Data linked from this file did not get updated." ) +#define SCSTR_UPDATE_EXTDOCS NC_("SCSTR_UPDATE_EXTDOCS", "Updating external links.") +#define SCSTR_FORMULA_SYNTAX_CALC_A1 NC_("SCSTR_FORMULA_SYNTAX_CALC_A1", "Calc A1") +#define SCSTR_FORMULA_SYNTAX_XL_A1 NC_("SCSTR_FORMULA_SYNTAX_XL_A1", "Excel A1") +#define SCSTR_FORMULA_SYNTAX_XL_R1C1 NC_("SCSTR_FORMULA_SYNTAX_XL_R1C1", "Excel R1C1") +#define SCSTR_COL_LABEL NC_("SCSTR_COL_LABEL", "Range contains column la~bels" ) +#define SCSTR_ROW_LABEL NC_("SCSTR_ROW_LABEL", "Range contains ~row labels" ) +#define SCSTR_NOTES_COL_LABEL NC_("SCSTR_INCLUDE_NOTES_COL_LABEL","Include boundary column(s) containing only comments") +#define SCSTR_NOTES_ROW_LABEL NC_("SCSTR_INCLUDE_NOTES_ROW_LABEL","Include boundary row(s) containing only comments") +#define SCSTR_IMAGES_COL_LABEL NC_("SCSTR_INCLUDE_IMAGES_COL_LABEL","Include boundary column(s) containing only images") +#define SCSTR_IMAGES_ROW_LABEL NC_("SCSTR_INCLUDE_IMAGES_ROW_LABEL","Include boundary row(s) containing only images") +#define SCSTR_VALERR NC_("SCSTR_VALERR", "Invalid value" ) +#define STR_NOFORMULASPECIFIED NC_("STR_NOFORMULASPECIFIED", "No formula specified." ) +#define STR_NOCOLROW NC_("STR_NOCOLROW", "Neither row or column specified." ) +#define STR_WRONGFORMULA NC_("STR_WRONGFORMULA", "Undefined name or range." ) +#define STR_WRONGROWCOL NC_("STR_WRONGROWCOL", "Undefined name or wrong cell reference." ) +#define STR_NOCOLFORMULA NC_("STR_NOCOLFORMULA", "Formulas don't form a column." ) +#define STR_NOROWFORMULA NC_("STR_NOROWFORMULA", "Formulas don't form a row." ) +#define STR_ADD_AUTOFORMAT_TITLE NC_("STR_ADD_AUTOFORMAT_TITLE", "Add AutoFormat" ) +#define STR_RENAME_AUTOFORMAT_TITLE NC_("STR_RENAME_AUTOFORMAT_TITLE", "Rename AutoFormat" ) +#define STR_ADD_AUTOFORMAT_LABEL NC_("STR_ADD_AUTOFORMAT_LABEL", "Name" ) +#define STR_DEL_AUTOFORMAT_TITLE NC_("STR_DEL_AUTOFORMAT_TITLE", "Delete AutoFormat" ) +#define STR_DEL_AUTOFORMAT_MSG NC_("STR_DEL_AUTOFORMAT_MSG", "Do you really want to delete the # AutoFormat?" ) +#define STR_BTN_AUTOFORMAT_CLOSE NC_("STR_BTN_AUTOFORMAT_CLOSE", "~Close" ) +#define STR_JAN NC_("STR_JAN", "Jan" ) +#define STR_FEB NC_("STR_FEB", "Feb" ) +#define STR_MAR NC_("STR_MAR", "Mar" ) +#define STR_NORTH NC_("STR_NORTH", "North" ) +#define STR_MID NC_("STR_MID", "Mid" ) +#define STR_SOUTH NC_("STR_SOUTH", "South" ) +#define STR_SUM NC_("STR_SUM", "Total" ) +#define SCSTR_UNDO_PAGE_ANCHOR NC_("SCSTR_UNDO_PAGE_ANCHOR", "Page Anchor" ) +#define SCSTR_UNDO_CELL_ANCHOR NC_("SCSTR_UNDO_CELL_ANCHOR", "Cell Anchor" ) +#define SCSTR_CONDITION NC_("SCSTR_CONDITION", "Condition ") + +// content description strings are also use d in ScLinkTargetsObj +#define SCSTR_CONTENT_ROOT NC_("SCSTR_CONTENT_ROOT", "Contents" ) +#define SCSTR_CONTENT_TABLE NC_("SCSTR_CONTENT_TABLE", "Sheets" ) +#define SCSTR_CONTENT_RANGENAME NC_("SCSTR_CONTENT_RANGENAME", "Range names" ) +#define SCSTR_CONTENT_DBAREA NC_("SCSTR_CONTENT_DBAREA", "Database ranges" ) +#define SCSTR_CONTENT_GRAPHIC NC_("SCSTR_CONTENT_GRAPHIC", "Images" ) +#define SCSTR_CONTENT_OLEOBJECT NC_("SCSTR_CONTENT_OLEOBJECT", "OLE objects" ) +#define SCSTR_CONTENT_NOTE NC_("SCSTR_CONTENT_NOTE", "Comments" ) +#define SCSTR_CONTENT_AREALINK NC_("SCSTR_CONTENT_AREALINK", "Linked areas" ) +#define SCSTR_CONTENT_DRAWING NC_("SCSTR_CONTENT_DRAWING", "Drawing objects") +#define SCSTR_ACTIVE NC_("SCSTR_ACTIVE", "active" ) +#define SCSTR_NOTACTIVE NC_("SCSTR_NOTACTIVE", "inactive" ) +#define SCSTR_ACTIVEWIN NC_("SCSTR_ACTIVEWIN", "Active Window" ) +#define SCSTR_QHLP_SCEN_LISTBOX NC_("SCSTR_QHLP_SCEN_LISTBOX", "Scenario Name") +#define SCSTR_QHLP_SCEN_COMMENT NC_("SCSTR_QHLP_SCEN_COMMENT", "Comment") + +#define STR_MENU_SORT_ASC NC_("STR_MENU_SORT_ASC", "Sort Ascending") +#define STR_MENU_SORT_DESC NC_("STR_MENU_SORT_DESC", "Sort Descending") +#define STR_MENU_SORT_CUSTOM NC_("STR_MENU_SORT_CUSTOM", "Custom Sort") + +#define SCSTR_QHELP_POSWND NC_("SCSTR_QHELP_POSWND", "Name Box") +#define SCSTR_QHELP_INPUTWND NC_("SCSTR_QHELP_INPUTWND", "Input line") +#define SCSTR_QHELP_BTNCALC NC_("SCSTR_QHELP_BTNCALC", "Function Wizard") +#define SCSTR_QHELP_BTNOK NC_("SCSTR_QHELP_BTNOK", "Accept") +#define SCSTR_QHELP_BTNCANCEL NC_("SCSTR_QHELP_BTNCANCEL", "Cancel") +#define SCSTR_QHELP_BTNSUM NC_("SCSTR_QHELP_BTNSUM", "Select Function") +#define SCSTR_QHELP_BTNEQUAL NC_("SCSTR_QHELP_BTNEQUAL", "Formula") +#define SCSTR_QHELP_EXPAND_FORMULA NC_("SCSTR_QHELP_EXPAND_FORMULA", "Expand Formula Bar") +#define SCSTR_QHELP_COLLAPSE_FORMULA NC_("SCSTR_QHELP_COLLAPSE_FORMULA", "Collapse Formula Bar") + +#define STR_UNKNOWN_USER_CONFLICT NC_("STR_UNKNOWN_USER_CONFLICT", "Unknown User") + +#define STR_CHG_INSERT_COLS NC_("STR_CHG_INSERT_COLS", "Column inserted") +#define STR_CHG_INSERT_ROWS NC_("STR_CHG_INSERT_ROWS", "Row inserted ") +#define STR_CHG_INSERT_TABS NC_("STR_CHG_INSERT_TABS", "Sheet inserted ") +#define STR_CHG_DELETE_COLS NC_("STR_CHG_DELETE_COLS", "Column deleted") +#define STR_CHG_DELETE_ROWS NC_("STR_CHG_DELETE_ROWS", "Row deleted") +#define STR_CHG_DELETE_TABS NC_("STR_CHG_DELETE_TABS", "Sheet deleted") +#define STR_CHG_MOVE NC_("STR_CHG_MOVE", "Range moved") +#define STR_CHG_CONTENT NC_("STR_CHG_CONTENT", "Changed contents") +#define STR_CHG_CONTENT_WITH_CHILD NC_("STR_CHG_CONTENT_WITH_CHILD", "Changed contents") +#define STR_CHG_CHILD_CONTENT NC_("STR_CHG_CHILD_CONTENT", "Changed to ") +#define STR_CHG_CHILD_ORGCONTENT NC_("STR_CHG_CHILD_ORGCONTENT", "Original") +#define STR_CHG_REJECT NC_("STR_CHG_REJECT", "Changes rejected") +#define STR_CHG_ACCEPTED NC_("STR_CHG_ACCEPTED", "Accepted") +#define STR_CHG_REJECTED NC_("STR_CHG_REJECTED", "Rejected") +#define STR_CHG_NO_ENTRY NC_("STR_CHG_NO_ENTRY", "No Entry") +#define STR_CHG_EMPTY NC_("STR_CHG_EMPTY", "<empty>") +#define STR_CHG_UNKNOWN_AUTHOR NC_("STR_CHG_UNKNOWN_AUTHOR", "Unknown Author") + +#define STR_NOT_PROTECTED NC_("STR_NOT_PROTECTED", "Not protected") +#define STR_NOT_PASS_PROTECTED NC_("STR_NOT_PASS_PROTECTED", "Not password-protected") +#define STR_HASH_BAD NC_("STR_HASH_BAD", "Hash incompatible") +#define STR_HASH_GOOD NC_("STR_HASH_GOOD", "Hash compatible") +#define STR_RETYPE NC_("STR_RETYPE", "Re-type") + +/* MovingAverageDialog */ +#define STR_MOVING_AVERAGE_UNDO_NAME NC_("STR_MOVING_AVERAGE_UNDO_NAME", "Moving Average") +/* ExponentialSmoothingDialog */ +#define STR_EXPONENTIAL_SMOOTHING_UNDO_NAME NC_("STR_EXPONENTIAL_SMOOTHING_UNDO_NAME", "Exponential Smoothing") +/* AnalysisOfVarianceDialog */ +#define STR_ANALYSIS_OF_VARIANCE_UNDO_NAME NC_("STR_ANALYSIS_OF_VARIANCE_UNDO_NAME", "Analysis of Variance") +#define STR_LABEL_ANOVA NC_("STR_LABEL_ANOVA", "Analysis of Variance (ANOVA)") +#define STR_ANOVA_SINGLE_FACTOR_LABEL NC_("STR_ANOVA_SINGLE_FACTOR_LABEL", "ANOVA - Single Factor") +#define STR_ANOVA_TWO_FACTOR_LABEL NC_("STR_ANOVA_TWO_FACTOR_LABEL", "ANOVA - Two Factor") +#define STR_ANOVA_LABEL_GROUPS NC_("STR_ANOVA_LABEL_GROUPS", "Groups") +#define STR_ANOVA_LABEL_BETWEEN_GROUPS NC_("STR_ANOVA_LABEL_BETWEEN_GROUPS", "Between Groups") +#define STR_ANOVA_LABEL_WITHIN_GROUPS NC_("STR_ANOVA_LABEL_WITHIN_GROUPS", "Within Groups") +#define STR_ANOVA_LABEL_SOURCE_OF_VARIATION NC_("STR_ANOVA_LABEL_SOURCE_OF_VARIATION", "Source of Variation") +#define STR_ANOVA_LABEL_SS NC_("STR_ANOVA_LABEL_SS", "SS") +#define STR_ANOVA_LABEL_DF NC_("STR_ANOVA_LABEL_DF", "df") +#define STR_ANOVA_LABEL_MS NC_("STR_ANOVA_LABEL_MS", "MS") +#define STR_ANOVA_LABEL_F NC_("STR_ANOVA_LABEL_F", "F") +#define STR_ANOVA_LABEL_SIGNIFICANCE_F NC_("STR_ANOVA_LABEL_SIGNIFICANCE_F", "Significance F") +#define STR_ANOVA_LABEL_P_VALUE NC_("STR_ANOVA_LABEL_P_VALUE", "P-value") +#define STR_ANOVA_LABEL_F_CRITICAL NC_("STR_ANOVA_LABEL_F_CRITICAL", "F critical") +#define STR_ANOVA_LABEL_TOTAL NC_("STR_ANOVA_LABEL_TOTAL", "Total") +/* CorrelationDialog */ +#define STR_CORRELATION_UNDO_NAME NC_("STR_CORRELATION_UNDO_NAME", "Correlation") +#define STR_CORRELATION_LABEL NC_("STR_CORRELATION_LABEL", "Correlations") +/* CovarianceDialog */ +#define STR_COVARIANCE_UNDO_NAME NC_("STR_COVARIANCE_UNDO_NAME", "Covariance") +#define STR_COVARIANCE_LABEL NC_("STR_COVARIANCE_LABEL", "Covariances") +/* DescriptiveStatisticsDialog */ +#define STR_DESCRIPTIVE_STATISTICS_UNDO_NAME NC_("STR_DESCRIPTIVE_STATISTICS_UNDO_NAME", "Descriptive Statistics") +#define STRID_CALC_MEAN NC_("STRID_CALC_MEAN", "Mean") +#define STRID_CALC_STD_ERROR NC_("STRID_CALC_STD_ERROR", "Standard Error") +#define STRID_CALC_MODE NC_("STRID_CALC_MODE", "Mode") +#define STRID_CALC_MEDIAN NC_("STRID_CALC_MEDIAN", "Median") +#define STRID_CALC_VARIANCE NC_("STRID_CALC_VARIANCE", "Variance") +#define STRID_CALC_STD_DEVIATION NC_("STRID_CALC_STD_DEVIATION", "Standard Deviation") +#define STRID_CALC_KURTOSIS NC_("STRID_CALC_KURTOSIS", "Kurtosis") +#define STRID_CALC_SKEWNESS NC_("STRID_CALC_SKEWNESS", "Skewness") +#define STRID_CALC_RANGE NC_("STRID_CALC_RANGE", "Range") +#define STRID_CALC_MIN NC_("STRID_CALC_MIN", "Minimum") +#define STRID_CALC_MAX NC_("STRID_CALC_MAX", "Maximum") +#define STRID_CALC_SUM NC_("STRID_CALC_SUM", "Sum") +#define STRID_CALC_COUNT NC_("STRID_CALC_COUNT", "Count") +#define STRID_CALC_FIRST_QUARTILE NC_("STRID_CALC_FIRST_QUARTILE", "First Quartile") +#define STRID_CALC_THIRD_QUARTILE NC_("STRID_CALC_THIRD_QUARTILE", "Third Quartile") +/* RandomNumberGeneratorDialog */ +#define STR_UNDO_DISTRIBUTION_TEMPLATE NC_("STR_UNDO_DISTRIBUTION_TEMPLATE", "Random (%1)") +#define STR_DISTRIBUTION_UNIFORM_REAL NC_("STR_DISTRIBUTION_UNIFORM_REAL", "Uniform") +#define STR_DISTRIBUTION_UNIFORM_INTEGER NC_("STR_DISTRIBUTION_UNIFORM_INTEGER", "Uniform Integer") +#define STR_DISTRIBUTION_NORMAL NC_("STR_DISTRIBUTION_NORMAL", "Normal") +#define STR_DISTRIBUTION_CAUCHY NC_("STR_DISTRIBUTION_CAUCHY", "Cauchy") +#define STR_DISTRIBUTION_BERNOULLI NC_("STR_DISTRIBUTION_BERNOULLI", "Bernoulli") +#define STR_DISTRIBUTION_BINOMIAL NC_("STR_DISTRIBUTION_BINOMIAL", "Binomial") +#define STR_DISTRIBUTION_CHI_SQUARED NC_("STR_DISTRIBUTION_CHI_SQUARED", "Chi Squared") +#define STR_DISTRIBUTION_GEOMETRIC NC_("STR_DISTRIBUTION_GEOMETRIC", "Geometric") +#define STR_DISTRIBUTION_NEGATIVE_BINOMIAL NC_("STR_DISTRIBUTION_NEGATIVE_BINOMIAL", "Negative Binomial") +#define STR_DISTRIBUTION_POISSON NC_("STR_DISTRIBUTION_POISSON", "Poisson") +#define STR_RNG_PARAMETER_MINIMUM NC_("STR_RNG_PARAMETER_MINIMUM", "Minimum") +#define STR_RNG_PARAMETER_MAXIMUM NC_("STR_RNG_PARAMETER_MAXIMUM", "Maximum") +#define STR_RNG_PARAMETER_MEAN NC_("STR_RNG_PARAMETER_MEAN", "Mean") +#define STR_RNG_PARAMETER_STANDARD_DEVIATION NC_("STR_RNG_PARAMETER_STANDARD_DEVIATION", "Standard Deviation") +#define STR_RNG_PARAMETER_STANDARD_MEDIAN NC_("STR_RNG_PARAMETER_STANDARD_MEDIAN", "Median") +#define STR_RNG_PARAMETER_STANDARD_SIGMA NC_("STR_RNG_PARAMETER_STANDARD_SIGMA", "Sigma") +#define STR_RNG_PARAMETER_STANDARD_PROBABILITY NC_("STR_RNG_PARAMETER_STANDARD_PROBABILITY", "p Value") +#define STR_RNG_PARAMETER_STANDARD_NUMBER_OF_TRIALS NC_("STR_RNG_PARAMETER_STANDARD_NUMBER_OF_TRIALS", "Number of Trials") +#define STR_RNG_PARAMETER_STANDARD_NU_VALUE NC_("STR_RNG_PARAMETER_STANDARD_NU_VALUE", "nu Value") +/* SamplingDialog */ +#define STR_SAMPLING_UNDO_NAME NC_("STR_SAMPLING_UNDO_NAME", "Sampling") +/* Names of dialogs */ +#define STR_FTEST NC_("STR_FTEST", "F-test") +#define STR_FTEST_UNDO_NAME NC_("STR_FTEST_UNDO_NAME", "F-test") +#define STR_TTEST NC_("STR_TTEST", "Paired t-test") +#define STR_TTEST_UNDO_NAME NC_("STR_TTEST_UNDO_NAME", "Paired t-test") +#define STR_ZTEST NC_("STR_ZTEST", "z-test") +#define STR_ZTEST_UNDO_NAME NC_("STR_ZTEST_UNDO_NAME", "z-test") +#define STR_CHI_SQUARE_TEST NC_("STR_CHI_SQUARE_TEST", "Test of Independence (Chi-Square)") +#define STR_REGRESSION_UNDO_NAME NC_("STR_REGRESSION_UNDO_NAME", "Regression") +#define STR_REGRESSION NC_("STR_REGRESSION", "Regression") +#define STR_FOURIER_ANALYSIS_UNDO_NAME NC_("STR_FOURIER_ANALYSIS_UNDO_NAME", "Fourier Analysis") +#define STR_FOURIER_ANALYSIS NC_("STR_FOURIER_ANALYSIS", "Fourier Analysis") +/* Common */ +#define STR_COLUMN_LABEL_TEMPLATE NC_("STR_COLUMN_LABEL_TEMPLATE", "Column %NUMBER%") +#define STR_ROW_LABEL_TEMPLATE NC_("STR_ROW_LABEL_TEMPLATE", "Row %NUMBER%") +#define STR_LABEL_ALPHA NC_("STR_LABEL_ALPHA", "Alpha") +#define STR_VARIABLE_1_LABEL NC_("STR_VARIABLE_1_LABEL", "Variable 1") +#define STR_VARIABLE_2_LABEL NC_("STR_VARIABLE_2_LABEL", "Variable 2") +#define STR_HYPOTHESIZED_MEAN_DIFFERENCE_LABEL NC_("STR_HYPOTHESIZED_MEAN_DIFFERENCE_LABEL", "Hypothesized Mean Difference") +#define STR_OBSERVATIONS_LABEL NC_("STR_OBSERVATIONS_LABEL", "Observations") +#define STR_OBSERVED_MEAN_DIFFERENCE_LABEL NC_("STR_OBSERVED_MEAN_DIFFERENCE_LABEL", "Observed Mean Difference") +#define STR_LABEL_RSQUARED NC_("STR_LABEL_RSQUARED", "R^2") +#define STR_LABEL_ADJUSTED_RSQUARED NC_("STR_LABEL_ADJUSTED_RSQUARED", "Adjusted R^2") +#define STR_LABEL_XVARIABLES_COUNT NC_("STR_LABEL_XVARIABLES_COUNT", "Count of X variables") +#define STR_DEGREES_OF_FREEDOM_LABEL NC_("STR_DEGREES_OF_FREEDOM_LABEL", "df") +#define STR_P_VALUE_LABEL NC_("STR_P_VALUE_LABEL", "P-value") +#define STR_CRITICAL_VALUE_LABEL NC_("STR_CRITICAL_VALUE_LABEL", "Critical Value") +#define STR_TEST_STATISTIC_LABEL NC_("STR_TEST_STATISTIC_LABEL", "Test Statistic") +#define STR_LABEL_LOWER NC_("STR_LABEL_LOWER", "Lower") +#define STR_LABEL_UPPER NC_("STR_LABEL_Upper", "Upper") +#define STR_MESSAGE_INVALID_INPUT_RANGE NC_("STR_MESSAGE_INVALID_INPUT_RANGE", "Input range is invalid.") +#define STR_MESSAGE_INVALID_OUTPUT_ADDR NC_("STR_MESSAGE_INVALID_OUTPUT_ADDR", "Output address is not valid.") +/* RegressionDialog */ +#define STR_LABEL_LINEAR NC_("STR_LABEL_LINEAR", "Linear") +#define STR_LABEL_LOGARITHMIC NC_("STR_LABEL_LOGARITHMIC", "Logarithmic") +#define STR_LABEL_POWER NC_("STR_LABEL_POWER", "Power") +#define STR_MESSAGE_XINVALID_RANGE NC_("STR_MESSAGE_XINVALID_RANGE", "Independent variable(s) range is not valid.") +#define STR_MESSAGE_YINVALID_RANGE NC_("STR_MESSAGE_YINVALID_RANGE", "Dependent variable(s) range is not valid.") +#define STR_MESSAGE_INVALID_CONFIDENCE_LEVEL NC_("STR_MESSAGE_INVALID_CONFIDENCE_LEVEL", "Confidence level must be in the interval (0, 1).") +#define STR_MESSAGE_YVARIABLE_MULTI_COLUMN NC_("STR_MESSAGE_YVARIABLE_MULTI_COLUMN", "Y variable range cannot have more than 1 column.") +#define STR_MESSAGE_YVARIABLE_MULTI_ROW NC_("STR_MESSAGE_YVARIABLE_MULTI_ROW", "Y variable range cannot have more than 1 row.") +#define STR_MESSAGE_UNIVARIATE_NUMOBS_MISMATCH NC_("STR_MESSAGE_UNIVARIATE_NUMOBS_MISMATCH", "Univariate regression : The observation count in X and Y must match.") +#define STR_MESSAGE_MULTIVARIATE_NUMOBS_MISMATCH NC_("STR_MESSAGE_MULTIVARIATE_NUMOBS_MISMATCH", "Multivariate regression : The observation count in X and Y must match.") +#define STR_LABEL_REGRESSION_MODEL NC_("STR_LABEL_REGRESSION_MODEL", "Regression Model") +#define STR_LABEL_REGRESSION_STATISTICS NC_("STR_LABEL_REGRESSION_STATISTICS", "Regression Statistics") +#define STR_LABEL_RESIDUAL NC_("STR_LABEL_RESIDUAL", "Residual") +#define STR_LABEL_CONFIDENCE_LEVEL NC_("STR_LABEL_CONFIDENCE_LEVEL", "Confidence level") +#define STR_LABEL_COEFFICIENTS NC_("STR_LABEL_COEFFICIENTS", "Coefficients") +#define STR_LABEL_TSTATISTIC NC_("STR_LABEL_TSTATISTIC", "t-Statistic") +#define STR_LABEL_INTERCEPT NC_("STR_LABEL_INTERCEPT", "Intercept") +#define STR_LABEL_PREDICTEDY NC_("STR_LABEL_PREDICTEDY", "Predicted Y") +#define STR_LINEST_RAW_OUTPUT_TITLE NC_("STR_LINEST_RAW_OUTPUT_TITLE", "LINEST raw output") +/*F Test */ +#define STR_FTEST_P_RIGHT_TAIL NC_("STR_FTEST_P_RIGHT_TAIL", "P (F<=f) right-tail") +#define STR_FTEST_F_CRITICAL_RIGHT_TAIL NC_("STR_FTEST_F_CRITICAL_RIGHT_TAIL", "F Critical right-tail") +#define STR_FTEST_P_LEFT_TAIL NC_("STR_FTEST_P_LEFT_TAIL", "P (F<=f) left-tail") +#define STR_FTEST_F_CRITICAL_LEFT_TAIL NC_("STR_FTEST_F_CRITICAL_LEFT_TAIL", "F Critical left-tail") +#define STR_FTEST_P_TWO_TAIL NC_("STR_FTEST_P_TWO_TAIL", "P two-tail") +#define STR_FTEST_F_CRITICAL_TWO_TAIL NC_("STR_FTEST_F_CRITICAL_TWO_TAIL", "F Critical two-tail") +/*t Test*/ +#define STR_TTEST_PEARSON_CORRELATION NC_("STR_TTEST_PEARSON_CORRELATION", "Pearson Correlation") +#define STR_TTEST_VARIANCE_OF_THE_DIFFERENCES NC_("STR_TTEST_VARIANCE_OF_THE_DIFFERENCES", "Variance of the Differences") +#define STR_TTEST_T_STAT NC_("STR_TTEST_T_STAT", "t Stat") +#define STR_TTEST_P_ONE_TAIL NC_("STR_TTEST_P_ONE_TAIL", "P (T<=t) one-tail") +#define STR_TTEST_T_CRITICAL_ONE_TAIL NC_("STR_TTEST_T_CRITICAL_ONE_TAIL", "t Critical one-tail") +#define STR_TTEST_P_TWO_TAIL NC_("STR_TTEST_P_TWO_TAIL", "P (T<=t) two-tail") +#define STR_TTEST_T_CRITICAL_TWO_TAIL NC_("STR_TTEST_T_CRITICAL_TWO_TAIL", "t Critical two-tail") +/*Z Test*/ +#define STR_ZTEST_Z_VALUE NC_("STR_ZTEST_Z_VALUE", "z") +#define STR_ZTEST_KNOWN_VARIANCE NC_("STR_ZTEST_KNOWN_VARIANCE", "Known Variance") +#define STR_ZTEST_P_ONE_TAIL NC_("STR_ZTEST_P_ONE_TAIL", "P (Z<=z) one-tail") +#define STR_ZTEST_Z_CRITICAL_ONE_TAIL NC_("STR_ZTEST_Z_CRITICAL_ONE_TAIL", "z Critical one-tail") +#define STR_ZTEST_P_TWO_TAIL NC_("STR_ZTEST_P_TWO_TAIL", "P (Z<=z) two-tail") +#define STR_ZTEST_Z_CRITICAL_TWO_TAIL NC_("STR_ZTEST_Z_CRITICAL_TWO_TAIL", "z Critical two-tail") +/*Fourier Analysis*/ +#define STR_FOURIER_TRANSFORM NC_("STR_FOURIER_TRANSFORM", "Fourier Transform") +#define STR_INVERSE_FOURIER_TRANSFORM NC_("STR_INVERSE_FOURIER_TRANSFORM", "Inverse Fourier Transform") +#define STR_REAL_PART NC_("STR_REAL_PART", "Real") +#define STR_IMAGINARY_PART NC_("STR_IMAGINARY_PART", "Imaginary") +#define STR_MAGNITUDE_PART NC_("STR_MAGNITUDE_PART", "Magnitude") +#define STR_PHASE_PART NC_("STR_PHASE_PART", "Phase") +#define STR_MESSAGE_INVALID_NUMCOLS NC_("STR_MESSAGE_INVALID_NUMCOLS", "More than two columns selected in grouped by column mode.") +#define STR_MESSAGE_INVALID_NUMROWS NC_("STR_MESSAGE_INVALID_NUMROWS", "More than two rows selected in grouped by row mode.") +#define STR_MESSAGE_NODATA_IN_RANGE NC_("STR_MESSAGE_NODATA_IN_RANGE", "No data in input range.") +#define STR_MESSAGE_OUTPUT_TOO_LONG NC_("STR_MESSAGE_OUTPUT_TOO_LONG", "Output is too long to write into the sheet.") +#define STR_INPUT_DATA_RANGE NC_("STR_INPUT_DATA_RANGE", "Input data range") +/*infobar for allowing links to update or not*/ +#define STR_ENABLE_CONTENT NC_("STR_ENABLE_CONTENT", "Allow updating") +/*tooltip for the "Allow updating" infobar button*/ +#define STR_ENABLE_CONTENT_TOOLTIP NC_("STR_ENABLE_CONTENT_TOOLTIP", "Only allow updating if you trust this document.") +#define STR_ENABLE_CONTENT_TOOLTIP_DISABLED NC_("STR_ENABLE_CONTENT_TOOLTIP_DISABLED", "Active content is disabled in the security settings. It is not possible to allow updating.") +/*Insert image dialog*/ +#define STR_ANCHOR_TO_CELL NC_("STR_ANCHOR_TO_CELL", "To cell") +#define STR_ANCHOR_TO_CELL_RESIZE NC_("STR_ANCHOR_TO_CELL_RESIZE", "To cell (resize with cell)") +#define STR_ANCHOR_TO_PAGE NC_("STR_ANCHOR_TO_PAGE", "To page") + +#define STR_NO_USER_DATA_AVAILABLE NC_("sharedocumentdlg|nouserdata", "No user data available.") +#define STR_EXCLUSIVE_ACCESS NC_("sharedocumentdlg|exclusive", "(exclusive access)") +#define STR_NO_NAMED_RANGES_AVAILABLE NC_("STR_NO_NAMED_RANGES_AVAILABLE", "No named ranges available in the selected document") +#define STR_BORDER_HAIRLINE NC_("STR_BORDER_HAIRLINE", "Hairline (%s pt)") +#define STR_BORDER_VERY_THIN NC_("STR_BORDER_VERY_THIN", "Very thin (%s pt)") +#define STR_BORDER_THIN NC_("STR_BORDER_THIN", "Thin (%s pt)") +#define STR_BORDER_MEDIUM NC_("STR_BORDER_MEDIUM", "Medium (%s pt)") +#define STR_BORDER_THICK NC_("STR_BORDER_THICK", "Thick (%s pt)") +#define STR_BORDER_EXTRA_THICK NC_("STR_BORDER_EXTRA_THICK", "Extra thick (%s pt)") +#define STR_BORDER_DOUBLE_1 NC_("STR_BORDER_DOUBLE_1", "Double Hairline (%s pt)") +#define STR_BORDER_DOUBLE_2 NC_("STR_BORDER_DOUBLE_2", "Thin/Medium (%s pt)") +#define STR_BORDER_DOUBLE_3 NC_("STR_BORDER_DOUBLE_3", "Medium/Hairline (%s pt)") +#define STR_BORDER_DOUBLE_4 NC_("STR_BORDER_DOUBLE_4", "Medium/Medium (%s pt)") + +// accessibility descriptions that use %PRODUCTNAME, we set these explicitly because querying a11y descs +// in order to change %PRODUCTNAME at runtime is expensive, so limit doing that as much as possible. +#define STR_A11Y_DESC_SORTUSER NC_("sortoptionspage|extended_tip|sortuserlb", "Select the custom sort order that you want to apply. To define a custom sort order, choose Tools - Options - %PRODUCTNAME Calc - Sort Lists.") +#define STR_A11Y_DESC_USERDEF NC_("subtotaloptionspage|extended_tip|lbuserdef", "Uses a custom sorting order that you defined in the Options dialog box at %PRODUCTNAME Calc - Sort Lists.") +#define STR_A11Y_DESC_ANNOT NC_("extended_tip|annot", "Specifies that a small rectangle in the top right corner of the cell indicates that a comment exists. The comment will be shown only when you enable tips under %PRODUCTNAME - General in the Options dialog box.") + +// Simple conditional formatting dialog +#define STR_CONDITION_EQUAL NC_("STR_CONDITION_EQUAL", "equal to") +#define STR_CONDITION_LESS NC_("STR_CONDITION_LESS", "less than") +#define STR_CONDITION_GREATER NC_("STR_CONDITION_GREATER", "greater than") +#define STR_CONDITION_EQLESS NC_("STR_CONDITION_EQLESS", "equal or less than") +#define STR_CONDITION_EQGREATER NC_("STR_CONDITION_EQGREATER", "equal or greater than") +#define STR_CONDITION_NOT_EQUAL NC_("STR_CONDITION_NOT_EQUAL", "not equal to") + +#define STR_CONDITION_BETWEEN NC_("STR_CONDITION_BETWEEN", "between") + +#define STR_CONDITION_ERROR NC_("STR_CONDITION_ERROR", "with error ") +#define STR_CONDITION_NOERROR NC_("STR_CONDITION_NOERROR", "without error ") +#define STR_CONDITION_CONTAINS_TEXT NC_("STR_CONDITION_CONTAINS_TEXT", "containing text") +#define STR_CONDITION_NOT_CONTAINS_TEXT NC_("STR_CONDITION_NOT_CONTAINS_TEXT", "not containing text") + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/strings.hxx b/sc/inc/strings.hxx new file mode 100644 index 0000000000..745ac05544 --- /dev/null +++ b/sc/inc/strings.hxx @@ -0,0 +1,28 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * 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/. + */ + +#pragma once + +#include <rtl/ustring.hxx> + +inline constexpr OUString SCSTR_FIELDSEP = u",\t44\t;\t59\t:\t58\t{%TAB}\t9\t{%SPACE}\t32 "_ustr; +inline constexpr OUString SCSTR_TEXTSEP = u"\"\t34\t'\t39"_ustr; +inline constexpr OUString STR_ACC_DOC_DESCR = u""_ustr; +inline constexpr OUString STR_ACC_TABLE_DESCR = u""_ustr; +inline constexpr OUString STR_ACC_CELL_DESCR = u""_ustr; +inline constexpr OUString STR_ACC_PREVIEWDOC_DESCR = u""_ustr; +inline constexpr OUString STR_ACC_HEADERCELL_NAME = u""_ustr; +inline constexpr OUString STR_ACC_HEADERCELL_DESCR = u""_ustr; +inline constexpr OUString STR_ACC_LEFTAREA_DESCR = u""_ustr; +inline constexpr OUString STR_ACC_CENTERAREA_DESCR = u""_ustr; +inline constexpr OUString STR_ACC_RIGHTAREA_DESCR = u""_ustr; +inline constexpr OUString STR_ACC_HEADER_DESCR = u""_ustr; +inline constexpr OUString STR_ACC_FOOTER_DESCR = u""_ustr; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/sc/inc/stringutil.hxx b/sc/inc/stringutil.hxx new file mode 100644 index 0000000000..3d930dd359 --- /dev/null +++ b/sc/inc/stringutil.hxx @@ -0,0 +1,165 @@ +/* -*- 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 <rtl/ustring.hxx> +#include "scdllapi.h" +#include <i18nlangtag/lang.h> +#include "types.hxx" + +class SvNumberFormatter; +enum class SvNumFormatType : sal_Int16; + +/** + * Store parameters used in the ScDocument::SetString() method. Various + * options for string-setting operation are specified herein. + */ +struct SAL_WARN_UNUSED SC_DLLPUBLIC ScSetStringParam +{ + /** Enum settings that take effect if mbDetectNumberFormat=false or if + true a number was not detected. + */ + enum TextFormatPolicy + { + /** + * Set Text number format if the input string can be parsed as a number + * or formula text. + */ + Always, + + /** + * Set Text number format only when the input string is considered a + * special number but we only want to detect a simple number. + */ + SpecialNumberOnly, + + /** + * Keep an existing number format, do not set Text number format and do + * not set another number format. + */ + Keep, + + /** + * Never set Text number format. + */ + Never + }; + + /** + * Stores the pointer to the number formatter instance to be used during + * number format detection. The caller must manage the life cycle of the + * instance. + */ + SvNumberFormatter* mpNumFormatter; + + /** + * Specify which number formats are detected: + * mbDetectNumberFormat=true && mbDetectScientificNumberFormat=true : detect all special number formats : basic decimal number, date, scientific notation, etc + * mbDetectNumberFormat=false && mbDetectScientificNumberFormat=true : detect scientific notation and basic decimal number, but not other special number formats (date etc) + * mbDetectNumberFormat=false && mbDetectScientificNumberFormat=false : detect only basic decimal number, but not scientific notation or other special number formats (date etc) + * Note: mbDetectNumberFormat=true && mbDetectScientificNumberFormat=false not allowed + */ + bool mbDetectNumberFormat; + bool mbDetectScientificNumberFormat; + + /** + * Determine when to set the 'Text' number format to the cell where the + * input string is being set. + */ + TextFormatPolicy meSetTextNumFormat; + + /** + * When true, treat input with a leading apostrophe as an escape character + * for all content, to treat also numeric value as a text. When + * false, the whole string input including the leading apostrophe will be + * entered literally as string. + */ + bool mbHandleApostrophe; + + sc::StartListeningType meStartListening; + + /** When true and the string results in a compiled formula, check the + formula tokens for presence of functions that could trigger access to + external resources. This is to be set to true in import filter code, + but not for user input. + */ + bool mbCheckLinkFormula; + + ScSetStringParam(); + + /** + * Call this whenever you need to unconditionally set input as text, no + * matter what the input is. + */ + void setTextInput(); + + /** + * Call this whenever you need to maximize the chance of input being + * detected as a numeric value (numbers, dates, times etc). + */ + void setNumericInput(); +}; + +struct ScInputStringType +{ + enum StringType { Unknown = 0, Text, Formula, Number }; + + StringType meType; + + OUString maText; + double mfValue; + SvNumFormatType mnFormatType; +}; + +class ScStringUtil +{ +public: + + /** + * Check if a given string is a simple decimal number (e.g. 12.345). We + * don't do any elaborate parsing here; we only check for the simplest + * case of decimal number format. + * + * Note that preceding and trailing spaces are ignored during parsing. + * + * @param rStr string to parse + * @param dsep decimal separator + * @param gsep group separator (aka thousands separator) + * @param dsepa decimal separator alternative, usually 0 + * @param rVal value of successfully parsed number + * + * @return true if the string is a valid number, false otherwise. + */ + static bool parseSimpleNumber( + const OUString& rStr, sal_Unicode dsep, sal_Unicode gsep, sal_Unicode dsepa, double& rVal, bool bDetectScientificNumber = true); + + static bool parseSimpleNumber( + const char* p, size_t n, char dsep, char gsep, double& rVal); + + static OUString SC_DLLPUBLIC GetQuotedToken(const OUString &rIn, sal_Int32 nToken, const OUString& rQuotedPairs, + sal_Unicode cTok, sal_Int32& rIndex ); + + static bool SC_DLLPUBLIC isMultiline( std::u16string_view rStr ); + + static ScInputStringType parseInputString( + SvNumberFormatter& rFormatter, const OUString& rStr, LanguageType eLang ); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/stylehelper.hxx b/sc/inc/stylehelper.hxx new file mode 100644 index 0000000000..470f809df4 --- /dev/null +++ b/sc/inc/stylehelper.hxx @@ -0,0 +1,54 @@ +/* -*- 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 <rtl/ustring.hxx> +#include "scdllapi.h" + +// conversion programmatic <-> display (visible) name +// currently, the core always has the visible names +// the api is required to use programmatic names for default styles +// these programmatic names must never change! + +inline constexpr OUString SC_STYLE_PROG_STANDARD = u"Default"_ustr; +inline constexpr OUString SC_STYLE_PROG_RESULT = u"Result"_ustr; +inline constexpr OUString SC_STYLE_PROG_RESULT1 = u"Result2"_ustr; +inline constexpr OUString SC_STYLE_PROG_HEADING = u"Heading"_ustr; +inline constexpr OUString SC_STYLE_PROG_HEADING1 = u"Heading1"_ustr; +inline constexpr OUString SC_STYLE_PROG_REPORT = u"Report"_ustr; + +inline constexpr OUString SC_PIVOT_STYLE_PROG_INNER = u"Pivot Table Value"_ustr; +inline constexpr OUString SC_PIVOT_STYLE_PROG_RESULT = u"Pivot Table Result"_ustr; +inline constexpr OUString SC_PIVOT_STYLE_PROG_CATEGORY = u"Pivot Table Category"_ustr; +inline constexpr OUString SC_PIVOT_STYLE_PROG_TITLE = u"Pivot Table Title"_ustr; +inline constexpr OUString SC_PIVOT_STYLE_PROG_FIELDNAME = u"Pivot Table Field"_ustr; +inline constexpr OUString SC_PIVOT_STYLE_PROG_TOP = u"Pivot Table Corner"_ustr; + +enum class SfxStyleFamily; + +class ScStyleNameConversion +{ +public: + static OUString DisplayToProgrammaticName(const OUString& rDispName, SfxStyleFamily nType); + static SC_DLLPUBLIC OUString ProgrammaticToDisplayName(const OUString& rProgName, + SfxStyleFamily nType); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/styleuno.hxx b/sc/inc/styleuno.hxx new file mode 100644 index 0000000000..07bf2cb7b1 --- /dev/null +++ b/sc/inc/styleuno.hxx @@ -0,0 +1,265 @@ +/* -*- 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 <svl/lstner.hxx> +#include <svl/style.hxx> +#include <com/sun/star/container/XIndexAccess.hpp> +#include <com/sun/star/style/XStyle.hpp> +#include <com/sun/star/style/XStyleLoader2.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/container/XNameContainer.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/beans/XMultiPropertySet.hpp> +#include <com/sun/star/beans/XPropertyState.hpp> +#include <com/sun/star/beans/XMultiPropertyStates.hpp> +#include <comphelper/servicehelper.hxx> +#include <cppuhelper/implbase.hxx> + +namespace com::sun::star::container { class XIndexReplace; } +namespace com::sun::star::lang { class XComponent; } + +class ScDocShell; +class SfxItemPropertySet; +class SfxItemSet; + +class ScStyleFamilyObj; +class ScStyleObj; +struct SfxItemPropertyMapEntry; + +class ScStyleFamiliesObj final : public ::cppu::WeakImplHelper< + css::container::XIndexAccess, + css::container::XNameAccess, + css::style::XStyleLoader2, + css::lang::XServiceInfo >, + public SfxListener +{ +private: + ScDocShell* pDocShell; + + rtl::Reference<ScStyleFamilyObj> GetObjectByType_Impl(SfxStyleFamily nType) const; + rtl::Reference<ScStyleFamilyObj> GetObjectByIndex_Impl(sal_uInt32 nIndex) const; + rtl::Reference<ScStyleFamilyObj> GetObjectByName_Impl(std::u16string_view aName) const; + +public: + ScStyleFamiliesObj(ScDocShell* pDocSh); + virtual ~ScStyleFamiliesObj() override; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + // XIndexAccess + virtual sal_Int32 SAL_CALL getCount() override; + virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override; + + // XNameAccess + virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override; + virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override; + + // XElementAccess + virtual css::uno::Type SAL_CALL getElementType() override; + virtual sal_Bool SAL_CALL hasElements() override; + + // XStyleLoader + virtual void SAL_CALL loadStylesFromURL( const OUString& URL, + const css::uno::Sequence< css::beans::PropertyValue >& aOptions ) override; + virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL + getStyleLoaderOptions() override; + + //XStyleLoader2 + virtual void SAL_CALL loadStylesFromDocument( const css::uno::Reference < css::lang::XComponent > & aSourceComponent, + const css::uno::Sequence< css::beans::PropertyValue >& aOptions ) override; + // XServiceInfo + 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; +private: + /// @throws css::io::IOException + /// @throws css::uno::RuntimeException + void loadStylesFromDocShell( ScDocShell* pSource, + const css::uno::Sequence< css::beans::PropertyValue>& aOptions ); +}; + +class ScStyleFamilyObj final : public ::cppu::WeakImplHelper< + css::container::XNameContainer, + css::container::XIndexAccess, + css::beans::XPropertySet, + css::lang::XServiceInfo >, + public SfxListener +{ +private: + ScDocShell* pDocShell; + SfxStyleFamily eFamily; // Family + + rtl::Reference<ScStyleObj> GetObjectByIndex_Impl(sal_Int32 nIndex); + rtl::Reference<ScStyleObj> GetObjectByName_Impl(const OUString& Name); + +public: + ScStyleFamilyObj(ScDocShell* pDocSh, SfxStyleFamily eFam); + virtual ~ScStyleFamilyObj() override; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + // XNameContainer + virtual void SAL_CALL insertByName( const OUString& aName, + const css::uno::Any& aElement ) override; + virtual void SAL_CALL removeByName( const OUString& Name ) override; + + // XNameReplace + virtual void SAL_CALL replaceByName( const OUString& aName, + const css::uno::Any& aElement ) override; + + // XNameAccess + virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override; + virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override; + + // XIndexAccess + virtual sal_Int32 SAL_CALL getCount() override; + virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override; + + // XElementAccess + virtual css::uno::Type SAL_CALL getElementType() override; + virtual sal_Bool SAL_CALL hasElements() override; + + // XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override; + virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override; + virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override; + virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override; + virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override; + virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + + // XServiceInfo + 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; +}; + +class ScStyleObj final : public ::cppu::WeakImplHelper< + css::style::XStyle, + css::beans::XPropertySet, + css::beans::XMultiPropertySet, + css::beans::XPropertyState, + css::beans::XMultiPropertyStates, + css::lang::XServiceInfo >, + public SfxListener +{ +private: + const SfxItemPropertySet* pPropSet; + ScDocShell* pDocShell; + SfxStyleFamily eFamily; // Family + OUString aStyleName; + SfxStyleSheetBase* pStyle_cached; + + const SfxItemSet* GetStyleItemSet_Impl( std::u16string_view rPropName, const SfxItemPropertyMapEntry*& rpEntry ); + /// @throws css::beans::UnknownPropertyException + /// @throws css::uno::RuntimeException + css::beans::PropertyState getPropertyState_Impl( std::u16string_view PropertyName ); + /// @throws css::beans::UnknownPropertyException + /// @throws css::lang::WrappedTargetException + /// @throws css::uno::RuntimeException + css::uno::Any getPropertyDefault_Impl( std::u16string_view aPropertyName ); + /// @throws css::beans::UnknownPropertyException + /// @throws css::lang::WrappedTargetException + /// @throws css::uno::RuntimeException + css::uno::Any getPropertyValue_Impl( std::u16string_view aPropertyName ); + /// @throws css::lang::IllegalArgumentException + /// @throws css::uno::RuntimeException + void setPropertyValue_Impl( std::u16string_view rPropertyName, + const SfxItemPropertyMapEntry* pEntry, + const css::uno::Any* pValue ); + +public: + ScStyleObj() = delete; + ScStyleObj(ScDocShell* pDocSh, SfxStyleFamily eFam, OUString aName); + virtual ~ScStyleObj() override; + + // created by getImplementation: + bool IsInserted() const { return pDocShell != nullptr; } + SfxStyleFamily GetFamily() const { return eFamily; } + void InitDoc( ScDocShell* pNewDocSh, const OUString& rNewName ); + SfxStyleSheetBase* GetStyle_Impl( bool bUseCachedValue = false ); + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + static css::uno::Reference< css::container::XIndexReplace > + CreateEmptyNumberingRules(); + + // XStyle + virtual sal_Bool SAL_CALL isUserDefined() override; + virtual sal_Bool SAL_CALL isInUse() override; + virtual OUString SAL_CALL getParentStyle() override; + virtual void SAL_CALL setParentStyle( const OUString& aParentStyle ) override; + + // XNamed + virtual OUString SAL_CALL getName() override; + virtual void SAL_CALL setName( const OUString& aName ) override; + + // XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > + SAL_CALL getPropertySetInfo() override; + virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, + const css::uno::Any& aValue ) override; + virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override; + virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override; + virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override; + virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< + css::beans::XVetoableChangeListener >& aListener ) override; + + // XMultiPropertySet + virtual void SAL_CALL setPropertyValues( const css::uno::Sequence< OUString >& aPropertyNames, + const css::uno::Sequence< css::uno::Any >& aValues ) override; + virtual css::uno::Sequence< css::uno::Any > SAL_CALL + getPropertyValues( const css::uno::Sequence< OUString >& aPropertyNames ) override; + virtual void SAL_CALL addPropertiesChangeListener( const css::uno::Sequence< OUString >& aPropertyNames, + const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override; + virtual void SAL_CALL removePropertiesChangeListener( const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override; + virtual void SAL_CALL firePropertiesChangeEvent( const css::uno::Sequence< OUString >& aPropertyNames, + const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override; + + // XPropertyState + virtual css::beans::PropertyState SAL_CALL getPropertyState( + const OUString& PropertyName ) override; + virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL + getPropertyStates( const css::uno::Sequence< OUString >& aPropertyName ) override; + virtual void SAL_CALL setPropertyToDefault( const OUString& PropertyName ) override; + virtual css::uno::Any SAL_CALL getPropertyDefault( const OUString& aPropertyName ) override; + + // XMultiPropertyStates + // getPropertyStates already defined for XPropertyState + virtual void SAL_CALL setAllPropertiesToDefault() override; + virtual void SAL_CALL setPropertiesToDefault( const css::uno::Sequence< OUString >& aPropertyNames ) override; + virtual css::uno::Sequence< css::uno::Any > SAL_CALL + getPropertyDefaults( const css::uno::Sequence< OUString >& aPropertyNames ) override; + + // XServiceInfo + 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; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/subtotal.hxx b/sc/inc/subtotal.hxx new file mode 100644 index 0000000000..a2a8459b19 --- /dev/null +++ b/sc/inc/subtotal.hxx @@ -0,0 +1,82 @@ +/* -*- 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 "global.hxx" + +class SubTotal +{ +public: + static bool SafePlus( double& fVal1, double fVal2); + static bool SafeMult( double& fVal1, double fVal2); + static bool SafeDiv( double& fVal1, double fVal2); +}; + +class ScFunctionData; + +/** Implements the Welford Online one-pass algorithm. + See https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Welford's_Online_algorithm + and Donald E. Knuth, TAoCP vol.2, 3rd edn., p. 232 + */ +class WelfordRunner +{ +public: + WelfordRunner() : mfMean(0.0), mfM2(0.0), mnCount(0) {} + void update( double fVal ); + sal_uInt64 getCount() const { return mnCount; } + double getVarianceSample() const { return mnCount > 1 ? mfM2 / (mnCount-1) : 0.0; } + double getVariancePopulation() const { return mnCount > 0 ? mfM2 / mnCount : 0.0; } + + // The private variables can be abused by ScFunctionData as general + // sum/min/max/ave/count/... variables to reduce memory footprint for that + // ScFunctionData may be a mass object during consolidation. + // ScFunctionData::update() and getResult() take care that purposes are not + // mixed. + friend class ScFunctionData; +private: + double mfMean; + double mfM2; + sal_uInt64 mnCount; +}; + +/** To calculate a single subtotal function. */ +class ScFunctionData +{ +public: + ScFunctionData() : meFunc(SUBTOTAL_FUNC_NONE), mbError(false) {} + ScFunctionData( ScSubTotalFunc eFn ) : meFunc(eFn), mbError(false) {} + + void update( double fNewVal ); + /// Check getError() after (!) obtaining the result. + double getResult(); + bool getError() const { return mbError; } + ScSubTotalFunc getFunc() const { return meFunc; } + void setError() { mbError = true; } + +private: + WelfordRunner maWelford; + ScSubTotalFunc meFunc; + bool mbError; + + double& getValueRef() { return maWelford.mfMean; } + sal_uInt64& getCountRef() { return maWelford.mnCount; } +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/subtotalparam.hxx b/sc/inc/subtotalparam.hxx new file mode 100644 index 0000000000..8e36dad839 --- /dev/null +++ b/sc/inc/subtotalparam.hxx @@ -0,0 +1,48 @@ +/* -*- 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/. + */ + +#pragma once + +#include "global.hxx" +#include <memory> + +struct SC_DLLPUBLIC ScSubTotalParam +{ + SCCOL nCol1; ///< selected area + SCROW nRow1; + SCCOL nCol2; + SCROW nRow2; + sal_uInt16 nUserIndex; ///< index into list + bool bRemoveOnly:1; + bool bReplace:1; ///< replace existing results + bool bPagebreak:1; ///< page break at change of group + bool bCaseSens:1; + bool bDoSort:1; ///< presort + bool bAscending:1; ///< sort ascending + bool bUserDef:1; ///< sort user defined + bool bIncludePattern:1; ///< sort formats + bool bGroupActive[MAXSUBTOTAL]; ///< active groups + SCCOL nField[MAXSUBTOTAL]; ///< associated field + SCCOL nSubTotals[MAXSUBTOTAL]; ///< number of SubTotals + std::unique_ptr<SCCOL[]> pSubTotals[MAXSUBTOTAL]; ///< array of columns to be calculated + std::unique_ptr<ScSubTotalFunc[]> pFunctions[MAXSUBTOTAL]; ///< array of associated functions + + ScSubTotalParam(); + ScSubTotalParam( const ScSubTotalParam& r ); + + ScSubTotalParam& operator= ( const ScSubTotalParam& r ); + bool operator== ( const ScSubTotalParam& r ) const; + void Clear(); + void SetSubTotals( sal_uInt16 nGroup, + const SCCOL* ptrSubTotals, + const ScSubTotalFunc* ptrFunctions, + sal_uInt16 nCount ); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/subtotals.hrc b/sc/inc/subtotals.hrc new file mode 100644 index 0000000000..73c701a618 --- /dev/null +++ b/sc/inc/subtotals.hrc @@ -0,0 +1,41 @@ +/* -*- 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 <unotools/resmgr.hxx> + +#define NC_(Context, String) TranslateId(Context, u8##String) + +const TranslateId SCSTR_SUBTOTALS[] = +{ + NC_("subtotalgrppage|liststore1", "Sum"), + NC_("subtotalgrppage|liststore1", "Count"), + NC_("subtotalgrppage|liststore1", "Average"), + NC_("subtotalgrppage|liststore1", "Max"), + NC_("subtotalgrppage|liststore1", "Min"), + NC_("subtotalgrppage|liststore1", "Product"), + NC_("subtotalgrppage|liststore1", "Count (numbers only)"), + NC_("subtotalgrppage|liststore1", "StDev (Sample)"), + NC_("subtotalgrppage|liststore1", "StDevP (Population)"), + NC_("subtotalgrppage|liststore1", "Var (Sample)"), + NC_("subtotalgrppage|liststore1", "VarP (Population)") +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/tabbgcolor.hxx b/sc/inc/tabbgcolor.hxx new file mode 100644 index 0000000000..1b8845eee3 --- /dev/null +++ b/sc/inc/tabbgcolor.hxx @@ -0,0 +1,39 @@ +/* -*- 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 <tools/color.hxx> +#include "types.hxx" + +#include <vector> + +struct ScUndoTabColorInfo +{ + SCTAB mnTabId; + Color maOldTabBgColor; + Color maNewTabBgColor; + + explicit ScUndoTabColorInfo(SCTAB nTab); + ScUndoTabColorInfo(const ScUndoTabColorInfo& r); + + typedef ::std::vector<ScUndoTabColorInfo> List; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx new file mode 100644 index 0000000000..e7a4f317fc --- /dev/null +++ b/sc/inc/table.hxx @@ -0,0 +1,1473 @@ +/* -*- 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 <tools/gen.hxx> +#include <tools/color.hxx> +#include "attarray.hxx" +#include "column.hxx" +#include "colcontainer.hxx" +#include "sortparam.hxx" +#include "types.hxx" +#include "cellvalue.hxx" +#include <formula/types.hxx> +#include "calcmacros.hxx" +#include <formula/errorcodes.hxx> +#include "document.hxx" +#include "drwlayer.hxx" +#include "SparklineList.hxx" +#include "SolverSettings.hxx" +#include "markdata.hxx" + +#include <algorithm> +#include <atomic> +#include <memory> +#include <optional> +#include <set> +#include <vector> + +template <typename A, typename D> class ScBitMaskCompressedArray; +template <typename A, typename D> class ScCompressedArray; + +namespace utl { + class TextSearch; +} + +namespace com::sun::star { + namespace sheet { + struct TablePageBreakData; + } +} + +namespace formula { struct VectorRefArray; } +namespace sc { + +struct BroadcasterState; +class StartListeningContext; +class EndListeningContext; +class CopyFromClipContext; +class CopyToClipContext; +class CopyToDocContext; +class MixDocContext; +class ColumnSpanSet; +class RangeColumnSpanSet; +class ColumnSet; +struct ColumnBlockPosition; +class TableColumnBlockPositionSet; +struct RefUpdateContext; +struct RefUpdateInsertTabContext; +struct RefUpdateDeleteTabContext; +struct RefUpdateMoveTabContext; +struct NoteEntry; +class DocumentStreamAccess; +class CellValues; +class TableValues; +class RowHeightContext; +class CompileFormulaContext; +struct SetFormulaDirtyContext; +class ColumnIterator; +class ScDrawObjData; +} + +class SfxItemSet; +class SfxStyleSheetBase; +class SvxBoxInfoItem; +class SvxBoxItem; +class SvxSearchItem; + +class ScAutoFormatData; +class ScEditDataArray; +class ScFormulaCell; +class ScOutlineTable; +class ScPrintSaverTab; +class ScProgress; +class ScRangeList; +class ScSheetEvents; +class ScSortInfoArray; +class ScConditionalFormat; +class ScConditionalFormatList; +class ScStyleSheet; +class ScTableProtection; +class ScUserListData; +struct RowInfo; +class ScFunctionData; +class CollatorWrapper; +class ScFlatUInt16RowSegments; +class ScFlatBoolRowSegments; +class ScFlatBoolColSegments; +struct ScSetStringParam; +struct ScColWidthParam; +class ScRangeName; +class ScDBData; +class ScHint; +class ScPostIt; +struct ScInterpreterContext; + + +class ScColumnsRange final +{ + public: + class Iterator final + { + SCCOL mCol; + public: + typedef std::bidirectional_iterator_tag iterator_category; + typedef SCCOL value_type; + typedef SCCOL difference_type; + typedef const SCCOL* pointer; + typedef SCCOL reference; + + explicit Iterator(SCCOL nCol) : mCol(nCol) {} + + Iterator& operator++() { ++mCol; return *this;} + Iterator& operator--() { --mCol; return *this;} + + // Comparing iterators from different containers is undefined, so comparing mCol is enough. + bool operator==(const Iterator & rOther) const {return mCol == rOther.mCol;} + bool operator!=(const Iterator & rOther) const {return !(*this == rOther);} + SCCOL operator*() const {return mCol;} + }; + + ScColumnsRange(SCCOL nBegin, SCCOL nEnd) : maBegin(nBegin), maEnd(nEnd) {} + const Iterator & begin() { return maBegin; } + const Iterator & end() { return maEnd; } + std::reverse_iterator<Iterator> rbegin() { return std::reverse_iterator<Iterator>(maEnd); } + std::reverse_iterator<Iterator> rend() { return std::reverse_iterator<Iterator>(maBegin); } +private: + const Iterator maBegin; + const Iterator maEnd; +}; + +class ScTable +{ +private: + typedef ::std::vector< ScRange > ScRangeVec; + + ScColContainer aCol; + + OUString aName; + OUString aCodeName; + OUString aComment; + + OUString aLinkDoc; + OUString aLinkFlt; + OUString aLinkOpt; + OUString aLinkTab; + sal_uLong nLinkRefreshDelay; + ScLinkMode nLinkMode; + + // page style template + OUString aPageStyle; + Size aPageSizeTwips; // size of the print-page + SCCOL nRepeatStartX; // repeating rows/columns + SCCOL nRepeatEndX; // REPEAT_NONE, if not used + SCROW nRepeatStartY; + SCROW nRepeatEndY; + + // Standard row height for this sheet - benefits XLSX because default height defined per sheet + sal_uInt16 mnOptimalMinRowHeight; // in Twips + + std::unique_ptr<ScTableProtection> pTabProtection; + + std::unique_ptr<ScCompressedArray<SCCOL, sal_uInt16>> mpColWidth; + std::unique_ptr<ScFlatUInt16RowSegments> mpRowHeights; + + std::unique_ptr<ScBitMaskCompressedArray<SCCOL, CRFlags>> mpColFlags; + std::unique_ptr<ScBitMaskCompressedArray< SCROW, CRFlags>> pRowFlags; + std::unique_ptr<ScFlatBoolColSegments> mpHiddenCols; + std::unique_ptr<ScFlatBoolRowSegments> mpHiddenRows; + std::unique_ptr<ScFlatBoolColSegments> mpFilteredCols; + std::unique_ptr<ScFlatBoolRowSegments> mpFilteredRows; + + ::std::set<SCROW> maRowPageBreaks; + ::std::set<SCROW> maRowManualBreaks; + ::std::set<SCCOL> maColPageBreaks; + ::std::set<SCCOL> maColManualBreaks; + + std::unique_ptr<ScOutlineTable> pOutlineTable; + + std::unique_ptr<ScSheetEvents> pSheetEvents; + + mutable SCCOL nTableAreaX; + mutable SCROW nTableAreaY; + mutable SCCOL nTableAreaVisibleX; + mutable SCROW nTableAreaVisibleY; + + SCTAB nTab; + ScDocument& rDocument; + std::unique_ptr<utl::TextSearch> pSearchText; + + mutable OUString aUpperName; // #i62977# filled only on demand, reset in SetName + + // sort parameter to minimize stack size of quicksort + ScSortParam aSortParam; + CollatorWrapper* pSortCollator; + + ScRangeVec aPrintRanges; + + std::optional<ScRange> moRepeatColRange; + std::optional<ScRange> moRepeatRowRange; + + sal_uInt16 nLockCount; + + std::unique_ptr<ScRangeList> pScenarioRanges; + Color aScenarioColor; + Color aTabBgColor; + ScScenarioFlags nScenarioFlags; + std::unique_ptr<ScDBData> pDBDataNoName; + mutable std::unique_ptr<ScRangeName> mpRangeName; + + std::unique_ptr<ScConditionalFormatList> mpCondFormatList; + sc::SparklineList maSparklineList; + + ScAddress maLOKFreezeCell; + + bool bScenario:1; + bool bLayoutRTL:1; + bool bLoadingRTL:1; + bool bPageSizeValid:1; + mutable bool bTableAreaValid:1; + mutable bool bTableAreaVisibleValid:1; + bool bVisible:1; + bool bPendingRowHeights:1; + bool bCalcNotification:1; + bool bGlobalKeepQuery:1; + bool bPrintEntireSheet:1; + bool bActiveScenario:1; + bool mbPageBreaksValid:1; + bool mbForceBreaks:1; + /** this is touched from formula group threading context */ + std::atomic<bool> bStreamValid; + + // Solver settings in current tab + std::shared_ptr<sc::SolverSettings> m_pSolverSettings; + + // Default attributes for the unallocated columns. + ScColumnData aDefaultColData; + +friend class ScDocument; // for FillInfo +friend class ScColumn; +friend class ScValueIterator; +friend class ScHorizontalValueIterator; +friend class ScDBQueryDataIterator; +friend class ScFormulaGroupIterator; +friend class ScCellIterator; +template< ScQueryCellIteratorAccess accessType, ScQueryCellIteratorType queryType > +friend class ScQueryCellIteratorBase; +template< ScQueryCellIteratorAccess accessType > +friend class ScQueryCellIteratorAccessSpecific; +friend class ScHorizontalCellIterator; +friend class ScColumnTextWidthIterator; +friend class ScDocumentImport; +friend class sc::DocumentStreamAccess; +friend class sc::ColumnSpanSet; +friend class sc::RangeColumnSpanSet; +friend class sc::EditTextIterator; +friend class sc::FormulaGroupAreaListener; + +public: + ScTable( ScDocument& rDoc, SCTAB nNewTab, const OUString& rNewName, + bool bColInfo = true, bool bRowInfo = true ); + ~ScTable() COVERITY_NOEXCEPT_FALSE; + ScTable(const ScTable&) = delete; + ScTable& operator=(const ScTable&) = delete; + + ScDocument& GetDoc() { return rDocument;} + const ScDocument& GetDoc() const { return rDocument;} + SCTAB GetTab() const { return nTab; } + + ScOutlineTable* GetOutlineTable() { return pOutlineTable.get(); } + + ScColumn& CreateColumnIfNotExists( const SCCOL nScCol ) + { + if ( nScCol >= aCol.size() ) + CreateColumnIfNotExistsImpl(nScCol); + return aCol[nScCol]; + } + // out-of-line the cold part of the function + void CreateColumnIfNotExistsImpl( const SCCOL nScCol ); + + ScColumnData& GetColumnData( SCCOL nCol ) + { + if( nCol >= aCol.size()) + return aDefaultColData; + return aCol[nCol]; + } + + sal_uInt64 GetCellCount() const; + sal_uInt64 GetWeightedCount() const; + sal_uInt64 GetWeightedCount(SCROW nStartRow, SCROW nEndRow) const; + sal_uInt64 GetCodeCount() const; // RPN code in formula + + sal_uInt16 GetTextWidth(SCCOL nCol, SCROW nRow) const; + + bool SetOutlineTable( const ScOutlineTable* pNewOutline ); + void StartOutlineTable(); + + void DoAutoOutline( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow ); + + bool TestRemoveSubTotals( const ScSubTotalParam& rParam ); + void RemoveSubTotals( ScSubTotalParam& rParam ); + bool DoSubTotals( ScSubTotalParam& rParam ); + + const ScSheetEvents* GetSheetEvents() const { return pSheetEvents.get(); } + void SetSheetEvents( std::unique_ptr<ScSheetEvents> pNew ); + + bool IsVisible() const { return bVisible; } + void SetVisible( bool bVis ); + + bool IsStreamValid() const { return bStreamValid; } + void SetStreamValid( bool bSet, bool bIgnoreLock = false ); + + [[nodiscard]] bool IsColValid( const SCCOL nScCol ) const + { + return nScCol >= static_cast< SCCOL >( 0 ) && nScCol < aCol.size(); + } + [[nodiscard]] bool IsColRowValid( const SCCOL nScCol, const SCROW nScRow ) const + { + return IsColValid( nScCol ) && GetDoc().ValidRow( nScRow ); + } + [[nodiscard]] bool IsColRowTabValid( const SCCOL nScCol, const SCROW nScRow, const SCTAB nScTab ) const + { + return IsColValid( nScCol ) && GetDoc().ValidRow( nScRow ) && ValidTab( nScTab ); + } + [[nodiscard]] bool ValidCol(SCCOL nCol) const { return GetDoc().ValidCol(nCol); } + [[nodiscard]] bool ValidRow(SCROW nRow) const { return GetDoc().ValidRow(nRow); } + [[nodiscard]] bool ValidColRow(SCCOL nCol, SCROW nRow) const { return GetDoc().ValidColRow(nCol, nRow); } + + bool IsPendingRowHeights() const { return bPendingRowHeights; } + void SetPendingRowHeights( bool bSet ); + + bool GetCalcNotification() const { return bCalcNotification; } + void SetCalcNotification( bool bSet ); + + bool IsLayoutRTL() const { return bLayoutRTL; } + bool IsLoadingRTL() const { return bLoadingRTL; } + void SetLayoutRTL( bool bSet ); + void SetLoadingRTL( bool bSet ); + + bool IsScenario() const { return bScenario; } + void SetScenario( bool bFlag ); + void GetScenarioComment( OUString& rComment) const { rComment = aComment; } + void SetScenarioComment( const OUString& rComment ) { aComment = rComment; } + const Color& GetScenarioColor() const { return aScenarioColor; } + void SetScenarioColor(const Color& rNew) { aScenarioColor = rNew; } + const Color& GetTabBgColor() const { return aTabBgColor; } + void SetTabBgColor(const Color& rColor); + ScScenarioFlags GetScenarioFlags() const { return nScenarioFlags; } + void SetScenarioFlags(ScScenarioFlags nNew) { nScenarioFlags = nNew; } + void SetActiveScenario(bool bSet) { bActiveScenario = bSet; } + bool IsActiveScenario() const { return bActiveScenario; } + + ScLinkMode GetLinkMode() const { return nLinkMode; } + bool IsLinked() const { return nLinkMode != ScLinkMode::NONE; } + const OUString& GetLinkDoc() const { return aLinkDoc; } + const OUString& GetLinkFlt() const { return aLinkFlt; } + const OUString& GetLinkOpt() const { return aLinkOpt; } + const OUString& GetLinkTab() const { return aLinkTab; } + sal_uLong GetLinkRefreshDelay() const { return nLinkRefreshDelay; } + + void SetLink( ScLinkMode nMode, const OUString& rDoc, const OUString& rFlt, + const OUString& rOpt, const OUString& rTab, sal_uLong nRefreshDelay ); + + sal_Int64 GetHashCode () const; + + const OUString& GetName() const { return aName; } + void SetName( const OUString& rNewName ); + + void SetAnonymousDBData(std::unique_ptr<ScDBData> pDBData); + ScDBData* GetAnonymousDBData() { return pDBDataNoName.get();} + + const OUString& GetCodeName() const { return aCodeName; } + void SetCodeName( const OUString& rNewName ) { aCodeName = rNewName; } + + const OUString& GetUpperName() const; + + const OUString& GetPageStyle() const { return aPageStyle; } + void SetPageStyle( const OUString& rName ); + void PageStyleModified( const OUString& rNewName ); + + bool IsProtected() const; + void SetProtection(const ScTableProtection* pProtect); + const ScTableProtection* GetProtection() const; + void GetUnprotectedCells( ScRangeList& rRangeList ) const; + + bool IsEditActionAllowed( sc::ColRowEditAction eAction, SCCOLROW nStart, SCCOLROW nEnd ) const; + + Size GetPageSize() const; + void SetPageSize( const Size& rSize ); + void SetRepeatArea( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCROW nEndRow ); + + void LockTable(); + void UnlockTable(); + + bool IsBlockEditable( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, + SCROW nRow2, bool* pOnlyNotBecauseOfMatrix = nullptr, + bool bNoMatrixAtAll = false ) const; + bool IsSelectionEditable( const ScMarkData& rMark, + bool* pOnlyNotBecauseOfMatrix = nullptr ) const; + + bool HasBlockMatrixFragment( const SCCOL nCol1, SCROW nRow1, const SCCOL nCol2, SCROW nRow2, + bool bNoMatrixAtAll = false ) const; + bool HasSelectionMatrixFragment( const ScMarkData& rMark ) const; + + // This also includes e.g. notes. Use IsEmptyData() for cell data only. + bool IsBlockEmpty( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ) const; + + bool SetString( SCCOL nCol, SCROW nRow, SCTAB nTab, const OUString& rString, + const ScSetStringParam * pParam = nullptr ); + + bool SetEditText( SCCOL nCol, SCROW nRow, std::unique_ptr<EditTextObject> pEditText ); + void SetEditText( SCCOL nCol, SCROW nRow, const EditTextObject& rEditText, const SfxItemPool* pEditPool ); + SCROW GetFirstEditTextRow( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ) const; + + void SetEmptyCell( SCCOL nCol, SCROW nRow ); + void SetFormula( + SCCOL nCol, SCROW nRow, const ScTokenArray& rArray, formula::FormulaGrammar::Grammar eGram ); + void SetFormula( + SCCOL nCol, SCROW nRow, const OUString& rFormula, formula::FormulaGrammar::Grammar eGram ); + + SC_DLLPUBLIC std::shared_ptr<sc::SolverSettings> GetSolverSettings(); + + // tdf#156815 Sets the solver settings object to nullptr to force reloading Solver settings the + // next time the dialog is opened. This is required when sheets are renamed + void ResetSolverSettings() { m_pSolverSettings.reset(); } + + /** + * Takes ownership of pCell + * + * @return pCell if it was successfully inserted, NULL otherwise. pCell + * is deleted automatically on failure to insert. + */ + ScFormulaCell* SetFormulaCell( SCCOL nCol, SCROW nRow, ScFormulaCell* pCell ); + + bool SetFormulaCells( SCCOL nCol, SCROW nRow, std::vector<ScFormulaCell*>& rCells ); + + bool HasFormulaCell( const SCCOL nCol1, SCROW nRow1, const SCCOL nCol2, SCROW nRow2 ) const; + + svl::SharedString GetSharedString( SCCOL nCol, SCROW nRow ) const; + + void SetValue( SCCOL nCol, SCROW nRow, const double& rVal ); + void SetValues( const SCCOL nCol, const SCROW nRow, const std::vector<double>& rVals ); + void SetError( SCCOL nCol, SCROW nRow, FormulaError nError); + SCSIZE GetPatternCount( SCCOL nCol ) const; + SCSIZE GetPatternCount( SCCOL nCol, SCROW nRow1, SCROW nRow2 ) const; + bool ReservePatternCount( SCCOL nCol, SCSIZE nReserve ); + + void SetRawString( SCCOL nCol, SCROW nRow, const svl::SharedString& rStr ); + OUString GetString( SCCOL nCol, SCROW nRow, const ScInterpreterContext* pContext = nullptr ) const; + double* GetValueCell( SCCOL nCol, SCROW nRow ); + // Note that if pShared is set and a value is returned that way, the returned OUString is empty. + OUString GetInputString( SCCOL nCol, SCROW nRow, bool bForceSystemLocale = false ) const; + double GetValue( SCCOL nCol, SCROW nRow ) const; + const EditTextObject* GetEditText( SCCOL nCol, SCROW nRow ) const; + void RemoveEditTextCharAttribs( SCCOL nCol, SCROW nRow, const ScPatternAttr& rAttr ); + OUString GetFormula( SCCOL nCol, SCROW nRow ) const; + const ScFormulaCell* GetFormulaCell( SCCOL nCol, SCROW nRow ) const; + ScFormulaCell* GetFormulaCell( SCCOL nCol, SCROW nRow ); + + CellType GetCellType( const ScAddress& rPos ) const + { + if (!GetDoc().ValidColRow(rPos.Col(),rPos.Row())) + return CELLTYPE_NONE; + if (rPos.Col() >= aCol.size()) + return CELLTYPE_NONE; + return aCol[rPos.Col()].GetCellType( rPos.Row() ); + } + CellType GetCellType( SCCOL nCol, SCROW nRow ) const; + ScRefCellValue GetCellValue( SCCOL nCol, sc::ColumnBlockPosition& rBlockPos, SCROW nRow ); + ScRefCellValue GetCellValue( SCCOL nCol, SCROW nRow ) const; + + void GetFirstDataPos(SCCOL& rCol, SCROW& rRow) const; + void GetLastDataPos(SCCOL& rCol, SCROW& rRow) const; + + // Sparklines + + std::shared_ptr<sc::Sparkline> GetSparkline(SCCOL nCol, SCROW nRow); + sc::Sparkline* CreateSparkline(SCCOL nCol, SCROW nRow, std::shared_ptr<sc::SparklineGroup> const& pSparklineGroup); + bool DeleteSparkline(SCCOL nCol, SCROW nRow); + + sc::SparklineList& GetSparklineList(); + void CopySparklinesToTable(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScTable* pDestTab); + void FillSparkline(bool bVertical, SCCOLROW nFixed, SCCOLROW nIteratingStart, SCCOLROW nIteratingEnd, SCCOLROW nFillStart, SCCOLROW nFillEnd); + + // Notes / Comments + std::unique_ptr<ScPostIt> ReleaseNote( SCCOL nCol, SCROW nRow ); + ScPostIt* GetNote( SCCOL nCol, SCROW nRow ); + void SetNote( SCCOL nCol, SCROW nRow, std::unique_ptr<ScPostIt> pNote ); + + size_t GetNoteCount( SCCOL nCol ) const; + SCROW GetNotePosition( SCCOL nCol, size_t nIndex ) const; + void CreateAllNoteCaptions(); + void ForgetNoteCaptions( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, bool bPreserveData ); + void CommentNotifyAddressChange(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2); + + void GetAllNoteEntries( std::vector<sc::NoteEntry>& rNotes ) const; + void GetNotesInRange( const ScRange& rRange, std::vector<sc::NoteEntry>& rNotes ) const; + CommentCaptionState GetAllNoteCaptionsState( const ScRange& rRange, std::vector<sc::NoteEntry>& rNotes ); + bool ContainsNotesInRange( const ScRange& rRange ) const; + + bool TestInsertRow( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE nSize ) const; + void InsertRow( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE nSize ); + void DeleteRow( + const sc::ColumnSet& rRegroupCols, SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE nSize, + bool* pUndoOutline, std::vector<ScAddress>* pGroupPos ); + + bool TestInsertCol( SCROW nStartRow, SCROW nEndRow, SCSIZE nSize ) const; + void InsertCol( + const sc::ColumnSet& rRegroupCols, SCCOL nStartCol, SCROW nStartRow, SCROW nEndRow, SCSIZE nSize ); + void DeleteCol( + const sc::ColumnSet& rRegroupCols, SCCOL nStartCol, SCROW nStartRow, SCROW nEndRow, SCSIZE nSize, bool* pUndoOutline ); + + void DeleteArea( + SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, InsertDeleteFlags nDelFlag, + bool bBroadcast = true, sc::ColumnSpanSet* pBroadcastSpans = nullptr ); + + void CopyToClip( sc::CopyToClipContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScTable* pTable ); + void CopyToClip( sc::CopyToClipContext& rCxt, const ScRangeList& rRanges, ScTable* pTable ); + + void CopyStaticToDocument( + SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, const SvNumberFormatterMergeMap& rMap, + ScTable* pDestTab ); + + void CopyCellToDocument( SCCOL nSrcCol, SCROW nSrcRow, SCCOL nDestCol, SCROW nDestRow, ScTable& rDestTab ); + + bool InitColumnBlockPosition( sc::ColumnBlockPosition& rBlockPos, SCCOL nCol ); + + void DeleteBeforeCopyFromClip( + sc::CopyFromClipContext& rCxt, const ScTable& rClipTab, sc::ColumnSpanSet& rBroadcastSpans ); + + void CopyOneCellFromClip( + sc::CopyFromClipContext& rCxt, const SCCOL nCol1, const SCROW nRow1, + const SCCOL nCol2, const SCROW nRow2, + const SCROW nSrcRow, const ScTable* pSrcTab ); + + void CopyFromClip( + sc::CopyFromClipContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, + SCCOL nDx, SCROW nDy, ScTable* pTable ); + + void StartListeningFormulaCells( + sc::StartListeningContext& rStartCxt, sc::EndListeningContext& rEndCxt, + SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ); + + void SetDirtyFromClip( + SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, sc::ColumnSpanSet& rBroadcastSpans ); + + void CopyToTable( + sc::CopyToDocContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, + InsertDeleteFlags nFlags, bool bMarked, ScTable* pDestTab, + const ScMarkData* pMarkData, bool bAsLink, bool bColRowFlags, + bool bGlobalNamesToLocal, bool bCopyCaptions ); + + void CopyCaptionsToTable( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScTable* pDestTab, bool bCloneCaption ); + + void UndoToTable( + sc::CopyToDocContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, + InsertDeleteFlags nFlags, bool bMarked, ScTable* pDestTab ); + + void CopyConditionalFormat( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, + SCCOL nDx, SCROW nDy, const ScTable* pTable); + /** + * @param nCombinedStartRow start row of the combined range; + * used for transposed multi range selection with row direction; + * for other cases than multi range row selection this it equal to nRow1 + * @param nRowDestOffset adjustment of destination row position; + * used for transposed multi range selection with row direction, otherwise 0 + */ + void TransposeClip(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, SCROW nCombinedStartRow, + SCROW nRowDestOffset, ScTable* pTransClip, InsertDeleteFlags nFlags, + bool bAsLink, bool bIncludeFiltered); + + // mark of this document + void MixMarked( + sc::MixDocContext& rCxt, const ScMarkData& rMark, ScPasteFunc nFunction, + bool bSkipEmpty, const ScTable* pSrcTab ); + + void MixData( + sc::MixDocContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, + ScPasteFunc nFunction, bool bSkipEmpty, const ScTable* pSrcTab ); + + void CopyData( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, + SCCOL nDestCol, SCROW nDestRow, SCTAB nDestTab ); + + void CopyScenarioFrom( const ScTable* pSrcTab ); + void CopyScenarioTo( ScTable* pDestTab ) const; + bool TestCopyScenarioTo( const ScTable* pDestTab ) const; + void MarkScenarioIn(ScMarkData& rMark, ScScenarioFlags nNeededBits) const; + bool HasScenarioRange( const ScRange& rRange ) const; + void InvalidateScenarioRanges(); + const ScRangeList* GetScenarioRanges() const; + + void CopyUpdated( const ScTable* pPosTab, ScTable* pDestTab ) const; + + void InvalidateTableArea(); + void InvalidatePageBreaks(); + + bool GetCellArea( SCCOL& rEndCol, SCROW& rEndRow ) const; // FALSE = empty + bool GetTableArea( SCCOL& rEndCol, SCROW& rEndRow, bool bCalcHiddens = false) const; + bool GetPrintArea( SCCOL& rEndCol, SCROW& rEndRow, bool bNotes, bool bCalcHiddens = false) const; + bool GetPrintAreaHor( SCROW nStartRow, SCROW nEndRow, + SCCOL& rEndCol ) const; + bool GetPrintAreaVer( SCCOL nStartCol, SCCOL nEndCol, + SCROW& rEndRow, bool bNotes ) const; + + bool GetDataStart( SCCOL& rStartCol, SCROW& rStartRow ) const; + + void ExtendPrintArea( OutputDevice* pDev, + SCCOL nStartCol, SCROW nStartRow, SCCOL& rEndCol, SCROW nEndRow ); + + void GetDataArea( SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, SCROW& rEndRow, + bool bIncludeOld, bool bOnlyDown ) const; + + void GetBackColorArea( SCCOL& rStartCol, SCROW& rStartRow, + SCCOL& rEndCol, SCROW& rEndRow ) const; + + bool GetDataAreaSubrange( ScRange& rRange ) const; + + bool ShrinkToUsedDataArea( bool& o_bShrunk, SCCOL& rStartCol, SCROW& rStartRow, + SCCOL& rEndCol, SCROW& rEndRow, bool bColumnsOnly, + bool bStickyTopRow, bool bStickyLeftCol, + ScDataAreaExtras* pDataAreaExtras ) const; + + SCROW GetLastDataRow( SCCOL nCol1, SCCOL nCol2, SCROW nLastRow, + ScDataAreaExtras* pDataAreaExtras = nullptr ) const; + + bool IsEmptyData(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow) const; + SCSIZE GetEmptyLinesInBlock( SCCOL nStartCol, SCROW nStartRow, + SCCOL nEndCol, SCROW nEndRow, ScDirection eDir ) const; + + void FindAreaPos( SCCOL& rCol, SCROW& rRow, ScMoveDirection eDirection ) const; + void GetNextPos( SCCOL& rCol, SCROW& rRow, SCCOL nMovX, SCROW nMovY, + bool bMarked, bool bUnprotected, const ScMarkData& rMark, SCCOL nTabStartCol ) const; + + bool SkipRow( const SCCOL rCol, SCROW& rRow, const SCROW nMovY, const ScMarkData& rMark, + const bool bUp, const SCROW nUsedY, const bool bMarked, const bool bSheetProtected ) const; + void LimitChartArea( SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, SCROW& rEndRow ) const; + + bool HasData( SCCOL nCol, SCROW nRow ) const; + bool HasStringData( SCCOL nCol, SCROW nRow ) const; + bool HasValueData( SCCOL nCol, SCROW nRow ) const; + bool HasStringCells( SCCOL nStartCol, SCROW nStartRow, + SCCOL nEndCol, SCROW nEndRow ) const; + + sc::MultiDataCellState HasMultipleDataCells( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ) const; + + FormulaError GetErrCode( const ScAddress& rPos ) const + { + return IsColRowValid(rPos.Col(),rPos.Row()) ? + aCol[rPos.Col()].GetErrCode( rPos.Row() ) : + FormulaError::NONE; + } + + void ResetChanged( const ScRange& rRange ); + + void CheckVectorizationState(); + void SetAllFormulasDirty( const sc::SetFormulaDirtyContext& rCxt ); + void SetDirty( const ScRange&, ScColumn::BroadcastMode ); + void SetDirtyAfterLoad(); + void SetDirtyVar(); + void SetTableOpDirty( const ScRange& ); + void CalcAll(); + void CalcAfterLoad( sc::CompileFormulaContext& rCxt, bool bStartListening ); + void CompileAll( sc::CompileFormulaContext& rCxt ); + void CompileXML( sc::CompileFormulaContext& rCxt, ScProgress& rProgress ); + + /** Broadcast single broadcasters in range, without explicitly setting + anything dirty, not doing area broadcasts. + @param rHint address is modified to adapt to the actual broadcasted + position on each iteration and upon return points to the last + position broadcasted. */ + bool BroadcastBroadcasters( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, SfxHintId nHint ); + + bool CompileErrorCells( sc::CompileFormulaContext& rCxt, FormulaError nErrCode ); + + void UpdateReference( + sc::RefUpdateContext& rCxt, ScDocument* pUndoDoc = nullptr, + bool bIncludeDraw = true, bool bUpdateNoteCaptionPos = true ); + + void UpdateDrawRef( UpdateRefMode eUpdateRefMode, SCCOL nCol1, SCROW nRow1, SCTAB nTab1, + SCCOL nCol2, SCROW nRow2, SCTAB nTab2, + SCCOL nDx, SCROW nDy, SCTAB nDz, bool bUpdateNoteCaptionPos = true ); + + void UpdateTranspose( const ScRange& rSource, const ScAddress& rDest, + ScDocument* pUndoDoc ); + + void UpdateGrow( const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY ); + + void UpdateInsertTab( sc::RefUpdateInsertTabContext& rCxt ); + void UpdateDeleteTab( sc::RefUpdateDeleteTabContext& rCxt ); + void UpdateMoveTab( sc::RefUpdateMoveTabContext& rCxt, SCTAB nTabNo, ScProgress* pProgress ); + void UpdateCompile( bool bForceIfNameInUse = false ); + void SetTabNo(SCTAB nNewTab); + void FindRangeNamesInUse(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, + sc::UpdatedRangeNames& rIndexes) const; + void Fill( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, + sal_uInt64 nFillCount, FillDir eFillDir, FillCmd eFillCmd, FillDateCmd eFillDateCmd, + double nStepValue, const tools::Duration& rDurationStep, + double nMaxValue, ScProgress* pProgress); + OUString GetAutoFillPreview( const ScRange& rSource, SCCOL nEndX, SCROW nEndY ); + + void UpdateSelectionFunction( ScFunctionData& rData, const ScMarkData& rMark ); + + void AutoFormat( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, + sal_uInt16 nFormatNo ); + void GetAutoFormatData(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, ScAutoFormatData& rData); + bool SearchAndReplace( + const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow, const ScMarkData& rMark, + ScRangeList& rMatchedRanges, OUString& rUndoStr, ScDocument* pUndoDoc, bool& bMatchedRangesWereClamped); + + void FindMaxRotCol( RowInfo* pRowInfo, SCSIZE nArrCount, SCCOL nX1, SCCOL nX2 ); + + bool HasAttrib( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, HasAttrFlags nMask ) const; + bool HasAttribSelection( const ScMarkData& rMark, HasAttrFlags nMask ) const; + bool HasAttrib( SCCOL nCol, SCROW nRow, HasAttrFlags nMask, + SCROW* nStartRow = nullptr, SCROW* nEndRow = nullptr ) const; + bool IsMerged( SCCOL nCol, SCROW nRow ) const; + bool ExtendMerge( SCCOL nStartCol, SCROW nStartRow, + SCCOL& rEndCol, SCROW& rEndRow, + bool bRefresh ); + void SetMergedCells( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ); + + const SfxPoolItem* GetAttr( SCCOL nCol, SCROW nRow, sal_uInt16 nWhich ) const; + template<class T> const T* GetAttr( SCCOL nCol, SCROW nRow, TypedWhichId<T> nWhich ) const + { + return static_cast<const T*>(GetAttr(nCol, nRow, sal_uInt16(nWhich))); + } + const SfxPoolItem* GetAttr( SCCOL nCol, SCROW nRow, sal_uInt16 nWhich, SCROW& nStartRow, SCROW& nEndRow ) const; + template<class T> const T* GetAttr( SCCOL nCol, SCROW nRow, TypedWhichId<T> nWhich, SCROW& nStartRow, SCROW& nEndRow ) const + { + return static_cast<const T*>(GetAttr(nCol, nRow, sal_uInt16(nWhich), nStartRow, nEndRow)); + } + const ScPatternAttr* GetPattern( SCCOL nCol, SCROW nRow ) const; + const ScPatternAttr* GetMostUsedPattern( SCCOL nCol, SCROW nStartRow, SCROW nEndRow ) const; + + sal_uInt32 GetNumberFormat( const ScInterpreterContext& rContext, const ScAddress& rPos ) const; + sal_uInt32 GetNumberFormat( SCCOL nCol, SCROW nRow ) const; + sal_uInt32 GetNumberFormat( SCCOL nCol, SCROW nStartRow, SCROW nEndRow ) const; + + void SetNumberFormat( SCCOL nCol, SCROW nRow, sal_uInt32 nNumberFormat ); + + void MergeSelectionPattern( ScMergePatternState& rState, + const ScMarkData& rMark, bool bDeep ) const; + void MergePatternArea( ScMergePatternState& rState, SCCOL nCol1, SCROW nRow1, + SCCOL nCol2, SCROW nRow2, bool bDeep ) const; + void MergeBlockFrame( SvxBoxItem* pLineOuter, SvxBoxInfoItem* pLineInner, + ScLineFlags& rFlags, + SCCOL nStartCol, SCROW nStartRow, + SCCOL nEndCol, SCROW nEndRow ) const; + void ApplyBlockFrame(const SvxBoxItem& rLineOuter, + const SvxBoxInfoItem* pLineInner, + SCCOL nStartCol, SCROW nStartRow, + SCCOL nEndCol, SCROW nEndRow ); + + void ApplyAttr( SCCOL nCol, SCROW nRow, const SfxPoolItem& rAttr ); + void ApplyPattern( SCCOL nCol, SCROW nRow, const ScPatternAttr& rAttr ); + void ApplyPatternArea( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, + const ScPatternAttr& rAttr, ScEditDataArray* pDataArray = nullptr, + bool* const pIsChanged = nullptr ); + void SetAttrEntries( SCCOL nStartCol, SCCOL nEndCol, std::vector<ScAttrEntry> && vNewData); + + void SetPattern( const ScAddress& rPos, const ScPatternAttr& rAttr ); + const ScPatternAttr* SetPattern( SCCOL nCol, SCROW nRow, std::unique_ptr<ScPatternAttr> ); + void SetPattern( SCCOL nCol, SCROW nRow, const ScPatternAttr& rAttr ); + void ApplyPatternIfNumberformatIncompatible( const ScRange& rRange, + const ScPatternAttr& rPattern, SvNumFormatType nNewType ); + void AddCondFormatData( const ScRangeList& rRange, sal_uInt32 nIndex ); + void RemoveCondFormatData( const ScRangeList& rRange, sal_uInt32 nIndex ); + void SetPatternAreaCondFormat( SCCOL nCol, SCROW nStartRow, SCROW nEndRow, + const ScPatternAttr& rAttr, const ScCondFormatIndexes& rCondFormatIndexes ); + + void ApplyStyle( SCCOL nCol, SCROW nRow, const ScStyleSheet* rStyle ); + void ApplyStyleArea( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, const ScStyleSheet& rStyle ); + void ApplySelectionStyle(const ScStyleSheet& rStyle, const ScMarkData& rMark); + void ApplySelectionLineStyle( const ScMarkData& rMark, + const ::editeng::SvxBorderLine* pLine, bool bColorOnly ); + + const ScStyleSheet* GetStyle( SCCOL nCol, SCROW nRow ) const; + const ScStyleSheet* GetSelectionStyle( const ScMarkData& rMark, bool& rFound ) const; + const ScStyleSheet* GetAreaStyle( bool& rFound, SCCOL nCol1, SCROW nRow1, + SCCOL nCol2, SCROW nRow2 ) const; + + void StyleSheetChanged( const SfxStyleSheetBase* pStyleSheet, bool bRemoved, + OutputDevice* pDev, + double nPPTX, double nPPTY, + const Fraction& rZoomX, const Fraction& rZoomY ); + + bool IsStyleSheetUsed( const ScStyleSheet& rStyle ) const; + + bool ApplyFlags( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, ScMF nFlags ); + bool RemoveFlags( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, ScMF nFlags ); + + void ApplySelectionCache( ScItemPoolCache* pCache, const ScMarkData& rMark, ScEditDataArray* pDataArray = nullptr, bool* const pIsChanged = nullptr ); + void DeleteSelection( InsertDeleteFlags nDelFlag, const ScMarkData& rMark, bool bBroadcast = true ); + + void ClearSelectionItems( const sal_uInt16* pWhich, const ScMarkData& rMark ); + void ChangeSelectionIndent( bool bIncrement, const ScMarkData& rMark ); + + const std::optional<ScRange>& GetRepeatColRange() const { return moRepeatColRange; } + const std::optional<ScRange>& GetRepeatRowRange() const { return moRepeatRowRange; } + void SetRepeatColRange( std::optional<ScRange> oNew ); + void SetRepeatRowRange( std::optional<ScRange> oNew ); + + sal_uInt16 GetPrintRangeCount() const { return static_cast< sal_uInt16 >( aPrintRanges.size() ); } + const ScRange* GetPrintRange(sal_uInt16 nPos) const; + /** Returns true, if the sheet is always printed. */ + bool IsPrintEntireSheet() const { return bPrintEntireSheet; } + + /** Removes all print ranges. */ + void ClearPrintRanges(); + /** Adds a new print ranges. */ + void AddPrintRange( const ScRange& rNew ); + + // Removes all named ranges used for print ranges + void ClearPrintNamedRanges(); + + /** Marks the specified sheet to be printed completely. Deletes old print ranges! */ + void SetPrintEntireSheet(); + + void FillPrintSaver( ScPrintSaverTab& rSaveTab ) const; + void RestorePrintRanges( const ScPrintSaverTab& rSaveTab ); + + sal_uInt16 GetOptimalColWidth( SCCOL nCol, OutputDevice* pDev, + double nPPTX, double nPPTY, + const Fraction& rZoomX, const Fraction& rZoomY, + bool bFormula, const ScMarkData* pMarkData, + const ScColWidthParam* pParam ); + bool SetOptimalHeight( + sc::RowHeightContext& rCxt, SCROW nStartRow, SCROW nEndRow, bool bApi, + ScProgress* pOuterProgress = nullptr, sal_uInt64 nProgressStart = 0 ); + + void SetOptimalHeightOnly( + sc::RowHeightContext& rCxt, SCROW nStartRow, SCROW nEndRow, + ScProgress* pOuterProgress = nullptr, sal_uInt64 nProgressStart = 0 ); + + tools::Long GetNeededSize( SCCOL nCol, SCROW nRow, + OutputDevice* pDev, + double nPPTX, double nPPTY, + const Fraction& rZoomX, const Fraction& rZoomY, + bool bWidth, bool bTotalSize, + bool bInPrintTwips = false); + void SetColWidth( SCCOL nCol, sal_uInt16 nNewWidth ); + void SetColWidthOnly( SCCOL nCol, sal_uInt16 nNewWidth ); + void SetRowHeight( SCROW nRow, sal_uInt16 nNewHeight ); + bool SetRowHeightRange( SCROW nStartRow, SCROW nEndRow, sal_uInt16 nNewHeight, + double nPPTY, bool bApi ); + + /** + * Set specified row height to specified ranges. Don't check for drawing + * objects etc. Just set the row height. Nothing else. + * + * Note that setting a new row height via this function will not + * invalidate page breaks. + */ + void SetRowHeightOnly( SCROW nStartRow, SCROW nEndRow, sal_uInt16 nNewHeight ); + + // nPPT to test for modification + void SetManualHeight( SCROW nStartRow, SCROW nEndRow, bool bManual ); + + sal_uInt16 GetOptimalMinRowHeight() const + { + if (!mnOptimalMinRowHeight) + return ScGlobal::nStdRowHeight; + return mnOptimalMinRowHeight; + }; + void SetOptimalMinRowHeight(sal_uInt16 nSet) { mnOptimalMinRowHeight = nSet; } + + sal_uInt16 GetColWidth( SCCOL nCol, bool bHiddenAsZero = true ) const; + tools::Long GetColWidth( SCCOL nStartCol, SCCOL nEndCol ) const; + sal_uInt16 GetRowHeight( SCROW nRow, SCROW* pStartRow, SCROW* pEndRow, bool bHiddenAsZero = true ) const; + tools::Long GetRowHeight( SCROW nStartRow, SCROW nEndRow, bool bHiddenAsZero = true ) const; + tools::Long GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, double fScale ) const; + tools::Long GetColOffset( SCCOL nCol, bool bHiddenAsZero = true ) const; + tools::Long GetRowOffset( SCROW nRow, bool bHiddenAsZero = true ) const; + + /** + * Get the last row such that the height of row 0 to the end row is as + * high as possible without exceeding the specified height value. + * + * @param nHeight maximum desired height + * + * @return SCROW last row of the range within specified height. + */ + SCROW GetRowForHeight(tools::Long nHeight) const; + + sal_uInt16 GetOriginalWidth( SCCOL nCol ) const; + sal_uInt16 GetOriginalHeight( SCROW nRow ) const; + + sal_uInt16 GetCommonWidth( SCCOL nEndCol ) const; + + SCROW GetHiddenRowCount( SCROW nRow ) const; + + void ShowCol(SCCOL nCol, bool bShow); + void ShowRow(SCROW nRow, bool bShow); + void DBShowRow(SCROW nRow, bool bShow); + + void ShowRows(SCROW nRow1, SCROW nRow2, bool bShow); + void DBShowRows(SCROW nRow1, SCROW nRow2, bool bShow); + + void SetRowFlags( SCROW nRow, CRFlags nNewFlags ); + void SetRowFlags( SCROW nStartRow, SCROW nEndRow, CRFlags nNewFlags ); + + /// @return the index of the last row with any set flags (auto-pagebreak is ignored). + SCROW GetLastFlaggedRow() const; + + /// @return the index of the last changed column (flags and column width, auto pagebreak is ignored). + SCCOL GetLastChangedColFlagsWidth() const; + /// @return the index of the last changed row (flags and row height, auto pagebreak is ignored). + SCROW GetLastChangedRowFlagsWidth() const; + + bool IsDataFiltered(SCCOL nColStart, SCROW nRowStart, SCCOL nColEnd, SCROW nRowEnd) const; + bool IsDataFiltered(const ScRange& rRange) const; + CRFlags GetColFlags( SCCOL nCol ) const; + CRFlags GetRowFlags( SCROW nRow ) const; + + const ScBitMaskCompressedArray< SCROW, CRFlags> * GetRowFlagsArray() const + { return pRowFlags.get(); } + + bool UpdateOutlineCol( SCCOL nStartCol, SCCOL nEndCol, bool bShow ); + bool UpdateOutlineRow( SCROW nStartRow, SCROW nEndRow, bool bShow ); + + void UpdatePageBreaks( const ScRange* pUserArea ); + void RemoveManualBreaks(); + bool HasManualBreaks() const; + void SetRowManualBreaks( ::std::set<SCROW>&& rBreaks ); + void SetColManualBreaks( ::std::set<SCCOL>&& rBreaks ); + + void GetAllRowBreaks(::std::set<SCROW>& rBreaks, bool bPage, bool bManual) const; + void GetAllColBreaks(::std::set<SCCOL>& rBreaks, bool bPage, bool bManual) const; + bool HasRowPageBreak(SCROW nRow) const; + bool HasColPageBreak(SCCOL nCol) const; + bool HasRowManualBreak(SCROW nRow) const; + bool HasColManualBreak(SCCOL nCol) const; + + /** + * Get the row position of the next manual break that occurs at or below + * specified row. When no more manual breaks are present at or below + * the specified row, -1 is returned. + * + * @param nRow row at which the search begins. + * + * @return SCROW next row position with manual page break, or -1 if no + * more manual breaks are present. + */ + SCROW GetNextManualBreak(SCROW nRow) const; + + void RemoveRowPageBreaks(SCROW nStartRow, SCROW nEndRow); + void RemoveRowBreak(SCROW nRow, bool bPage, bool bManual); + void RemoveColBreak(SCCOL nCol, bool bPage, bool bManual); + void SetRowBreak(SCROW nRow, bool bPage, bool bManual); + void SetColBreak(SCCOL nCol, bool bPage, bool bManual); + css::uno::Sequence< + css::sheet::TablePageBreakData> GetRowBreakData() const; + + bool RowHidden(SCROW nRow, SCROW* pFirstRow = nullptr, SCROW* pLastRow = nullptr) const; + bool RowHiddenLeaf(SCROW nRow, SCROW* pFirstRow = nullptr, SCROW* pLastRow = nullptr) const; + bool HasHiddenRows(SCROW nStartRow, SCROW nEndRow) const; + bool ColHidden(SCCOL nCol, SCCOL* pFirstCol = nullptr, SCCOL* pLastCol = nullptr) const; + bool SetRowHidden(SCROW nStartRow, SCROW nEndRow, bool bHidden); + void SetColHidden(SCCOL nStartCol, SCCOL nEndCol, bool bHidden); + void CopyColHidden(const ScTable& rTable, SCCOL nStartCol, SCCOL nEndCol); + void CopyRowHidden(const ScTable& rTable, SCROW nStartRow, SCROW nEndRow); + void CopyRowHeight(const ScTable& rSrcTable, SCROW nStartRow, SCROW nEndRow, SCROW nSrcOffset); + SCROW FirstVisibleRow(SCROW nStartRow, SCROW nEndRow) const; + SCROW LastVisibleRow(SCROW nStartRow, SCROW nEndRow) const; + SCROW CountVisibleRows(SCROW nStartRow, SCROW nEndRow) const; + tools::Long GetTotalRowHeight(SCROW nStartRow, SCROW nEndRow, bool bHiddenAsZero = true) const; + + SCCOL CountVisibleCols(SCCOL nStartCol, SCCOL nEndCol) const; + + SCCOLROW LastHiddenColRow(SCCOLROW nPos, bool bCol) const; + + bool RowFiltered(SCROW nRow, SCROW* pFirstRow = nullptr, SCROW* pLastRow = nullptr) const; + bool ColFiltered(SCCOL nCol, SCCOL* pFirstCol = nullptr, SCCOL* pLastCol = nullptr) const; + bool HasFilteredRows(SCROW nStartRow, SCROW nEndRow) const; + void CopyColFiltered(const ScTable& rTable, SCCOL nStartCol, SCCOL nEndCol); + void CopyRowFiltered(const ScTable& rTable, SCROW nStartRow, SCROW nEndRow); + void SetRowFiltered(SCROW nStartRow, SCROW nEndRow, bool bFiltered); + void SetColFiltered(SCCOL nStartCol, SCCOL nEndCol, bool bFiltered); + SCROW FirstNonFilteredRow(SCROW nStartRow, SCROW nEndRow) const; + SCROW LastNonFilteredRow(SCROW nStartRow, SCROW nEndRow) const; + SCROW CountNonFilteredRows(SCROW nStartRow, SCROW nEndRow) const; + + Color GetCellBackgroundColor(ScAddress aPos) const; + Color GetCellTextColor(ScAddress aPos) const; + + bool IsManualRowHeight(SCROW nRow) const; + + bool HasUniformRowHeight( SCROW nRow1, SCROW nRow2 ) const; + + void SyncColRowFlags(); + + void StripHidden( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2 ); + void ExtendHidden( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2 ); + + /** Sort a range of data. */ + void Sort( + const ScSortParam& rSortParam, bool bKeepQuery, bool bUpdateRefs, + ScProgress* pProgress, sc::ReorderParam* pUndo ); + + void Reorder( const sc::ReorderParam& rParam ); + + // For ValidQuery() see ScQueryEvalutor class. + void TopTenQuery( ScQueryParam& ); + void PrepareQuery( ScQueryParam& rQueryParam ); + SCSIZE Query(const ScQueryParam& rQueryParam, bool bKeepSub); + bool CreateQueryParam(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScQueryParam& rQueryParam); + + void GetFilterEntries(SCCOL nCol, SCROW nRow1, SCROW nRow2, ScFilterEntries& rFilterEntries, bool bFiltering = false); + void GetFilteredFilterEntries(SCCOL nCol, SCROW nRow1, SCROW nRow2, const ScQueryParam& rParam, ScFilterEntries& rFilterEntries, bool bFiltering ); + [[nodiscard]] + bool GetDataEntries(SCCOL nCol, SCROW nRow, std::set<ScTypedStrData>& rStrings); + + bool HasColHeader( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow ) const; + bool HasRowHeader( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow ) const; + + sal_Int32 GetMaxStringLen( SCCOL nCol, + SCROW nRowStart, SCROW nRowEnd, rtl_TextEncoding eCharSet ) const; + sal_Int32 GetMaxNumberStringLen( sal_uInt16& nPrecision, + SCCOL nCol, + SCROW nRowStart, SCROW nRowEnd ) const; + + bool IsSortCollatorGlobal() const; + void InitSortCollator( const ScSortParam& rPar ); + void DestroySortCollator(); + void SetDrawPageSize( bool bResetStreamValid = true, bool bUpdateNoteCaptionPos = true, + const ScObjectHandling eObjectHandling = ScObjectHandling::RecalcPosMode); + + void SetRangeName(std::unique_ptr<ScRangeName> pNew); + ScRangeName* GetRangeName() const; + + void PreprocessRangeNameUpdate( + sc::EndListeningContext& rEndListenCxt, sc::CompileFormulaContext& rCompileCxt ); + + void CompileHybridFormula( + sc::StartListeningContext& rStartListenCxt, sc::CompileFormulaContext& rCompileCxt ); + + void PreprocessDBDataUpdate( + sc::EndListeningContext& rEndListenCxt, sc::CompileFormulaContext& rCompileCxt ); + + ScConditionalFormatList* GetCondFormList(); + const ScConditionalFormatList* GetCondFormList() const; + void SetCondFormList( ScConditionalFormatList* pList ); + + void DeleteConditionalFormat(sal_uLong nOldIndex); + + sal_uLong AddCondFormat( std::unique_ptr<ScConditionalFormat> pNew ); + + SvtScriptType GetScriptType( SCCOL nCol, SCROW nRow ) const; + void SetScriptType( SCCOL nCol, SCROW nRow, SvtScriptType nType ); + void UpdateScriptTypes( const SCCOL nCol1, SCROW nRow1, const SCCOL nCol2, SCROW nRow2 ); + + SvtScriptType GetRangeScriptType( sc::ColumnBlockPosition& rBlockPos, SCCOL nCol, SCROW nRow1, SCROW nRow2 ); + + formula::FormulaTokenRef ResolveStaticReference( SCCOL nCol, SCROW nRow ); + formula::FormulaTokenRef ResolveStaticReference( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ); + formula::VectorRefArray FetchVectorRefArray( SCCOL nCol, SCROW nRow1, SCROW nRow2 ); + bool HandleRefArrayForParallelism( SCCOL nCol, SCROW nRow1, SCROW nRow2, + const ScFormulaCellGroupRef& mxGroup, ScAddress* pDirtiedAddress ); +#ifdef DBG_UTIL + void AssertNoInterpretNeeded( SCCOL nCol, SCROW nRow1, SCROW nRow2 ); +#endif + + void SplitFormulaGroups( SCCOL nCol, std::vector<SCROW>& rRows ); + void UnshareFormulaCells( SCCOL nCol, std::vector<SCROW>& rRows ); + void RegroupFormulaCells( SCCOL nCol ); + + ScRefCellValue GetRefCellValue( SCCOL nCol, SCROW nRow ); + ScRefCellValue GetRefCellValue( SCCOL nCol, SCROW nRow, sc::ColumnBlockPosition& rBlockPos ); + + SvtBroadcaster* GetBroadcaster( SCCOL nCol, SCROW nRow ); + const SvtBroadcaster* GetBroadcaster( SCCOL nCol, SCROW nRow ) const; + void DeleteBroadcasters( sc::ColumnBlockPosition& rBlockPos, SCCOL nCol, SCROW nRow1, SCROW nRow2 ); + void DeleteEmptyBroadcasters(); + + void FillMatrix( ScMatrix& rMat, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, svl::SharedStringPool* pPool ) const; + + void InterpretDirtyCells( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ); + bool InterpretCellsIfNeeded( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ); + + void SetFormulaResults( SCCOL nCol, SCROW nRow, const double* pResults, size_t nLen ); + + void CalculateInColumnInThread( ScInterpreterContext& rContext, SCCOL nColStart, SCCOL nColEnd, + SCROW nRowStart, SCROW nRowEnd, unsigned nThisThread, unsigned nThreadsTotal); + void HandleStuffAfterParallelCalculation( SCCOL nColStart, SCCOL nColEnd, SCROW nRow, size_t nLen, ScInterpreter* pInterpreter); + + /** + * Either start all formula cells as listeners unconditionally, or start + * those that are marked "needs listening". + * + * @param rCxt context object. + * @param bAll when true, start all formula cells as listeners. When + * false, only start those that are marked "needs listening". + */ + void StartListeners( sc::StartListeningContext& rCxt, bool bAll ); + + /** + * Mark formula cells dirty that have the mbPostponedDirty flag set or + * contain named ranges with relative references. + */ + void SetDirtyIfPostponed(); + + /** + * Broadcast dirty formula cells that contain functions such as CELL(), + * COLUMN() or ROW() which may change its value on move. + */ + void BroadcastRecalcOnRefMove(); + + void TransferCellValuesTo( const SCCOL nCol, SCROW nRow, size_t nLen, sc::CellValues& rDest ); + void CopyCellValuesFrom( const SCCOL nCol, SCROW nRow, const sc::CellValues& rSrc ); + + std::optional<sc::ColumnIterator> GetColumnIterator( SCCOL nCol, SCROW nRow1, SCROW nRow2 ) const; + + bool EnsureFormulaCellResults( const SCCOL nCol1, SCROW nRow1, const SCCOL nCol2, SCROW nRow2, bool bSkipRunning = false ); + + void ConvertFormulaToValue( + sc::EndListeningContext& rCxt, + const SCCOL nCol1, const SCROW nRow1, const SCCOL nCol2, const SCROW nRow2, + sc::TableValues* pUndo ); + + void SwapNonEmpty( + sc::TableValues& rValues, sc::StartListeningContext& rStartCxt, sc::EndListeningContext& rEndCxt ); + + void finalizeOutlineImport(); + + void StoreToCache(SvStream& rStrm) const; + + void RestoreFromCache(SvStream& rStrm); + +#if DUMP_COLUMN_STORAGE + void DumpColumnStorage( SCCOL nCol ) const; +#endif + + /** Replace behaves differently to the Search; adjust the rCol and rRow accordingly. + + 'Replace' replaces at the 'current' position, but in order to achieve + that, we have to 'shift' the rCol / rRow to the 'previous' position - + what it is depends on various settings in rSearchItem. + */ + static void UpdateSearchItemAddressForReplace( const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow ); + + ScColumnsRange GetWritableColumnsRange(SCCOL begin, SCCOL end); + ScColumnsRange GetAllocatedColumnsRange(SCCOL begin, SCCOL end) const; + ScColumnsRange GetColumnsRange(SCCOL begin, SCCOL end) const; + SCCOL ClampToAllocatedColumns(SCCOL nCol) const { return std::min(nCol, static_cast<SCCOL>(aCol.size() - 1)); } + SCCOL GetAllocatedColumnsCount() const { return aCol.size(); } + + /** + * Serializes the sheet's geometry data. + * + * @param bColumns - if true it dumps the data for columns, else it does for rows. + * @param eGeomType indicates the type of data to be dumped for rows/columns. + * @return the serialization of the sheet's geometry data as an OString. + */ + OString dumpSheetGeomData(bool bColumns, SheetGeomType eGeomType); + + std::set<SCCOL> QueryColumnsWithFormulaCells() const; + + const ScColumnData& ColumnData( SCCOL nCol ) const { return nCol < aCol.size() ? aCol[ nCol ] : aDefaultColData; } + + void CheckIntegrity() const; + + void CollectBroadcasterState(sc::BroadcasterState& rState) const; + +private: + + void FillFormulaVertical( + const ScFormulaCell& rSrcCell, + SCCOLROW& rInner, SCCOL nCol, SCROW nRow1, SCROW nRow2, + ScProgress* pProgress, sal_uInt64& rProgress ); + + void FillSeriesSimple( + const ScCellValue& rSrcCell, SCCOLROW& rInner, SCCOLROW nIMin, SCCOLROW nIMax, + const SCCOLROW& rCol, const SCCOLROW& rRow, bool bVertical, ScProgress* pProgress, sal_uInt64& rProgress ); + + void FillAutoSimple( + SCCOLROW nISrcStart, SCCOLROW nISrcEnd, SCCOLROW nIStart, SCCOLROW nIEnd, + SCCOLROW& rInner, const SCCOLROW& rCol, const SCCOLROW& rRow, + sal_uInt64 nActFormCnt, sal_uInt64 nMaxFormCnt, + bool bHasFiltered, bool bVertical, bool bPositive, + ScProgress* pProgress, sal_uInt64& rProgress ); + + void FillSeries( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, + sal_uInt64 nFillCount, FillDir eFillDir, FillCmd eFillCmd, + FillDateCmd eFillDateCmd, + double nStepValue, const tools::Duration& rDurationStep, + double nMaxValue, sal_uInt16 nMinDigits, + bool bAttribs, ScProgress* pProgress, + bool bSkipOverlappedCells = false, + std::vector<sal_Int32>* pNonOverlappedCellIdx = nullptr); + void FillAnalyse( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, + FillCmd& rCmd, FillDateCmd& rDateCmd, + double& rInc, tools::Duration& rDuration, sal_uInt16& rMinDigits, + ScUserListData*& rListData, sal_uInt16& rListIndex, + bool bHasFiltered, bool& rSkipOverlappedCells, + std::vector<sal_Int32>& rNonOverlappedCellIdx ); + void FillAuto( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, + sal_uInt64 nFillCount, FillDir eFillDir, ScProgress* pProgress ); + + bool ValidNextPos( SCCOL nCol, SCROW nRow, const ScMarkData& rMark, + bool bMarked, bool bUnprotected ) const; + + void AutoFormatArea(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, + const ScPatternAttr& rAttr, sal_uInt16 nFormatNo); + void GetAutoFormatAttr(SCCOL nCol, SCROW nRow, sal_uInt16 nIndex, ScAutoFormatData& rData); + void GetAutoFormatFrame(SCCOL nCol, SCROW nRow, sal_uInt16 nFlags, sal_uInt16 nIndex, ScAutoFormatData& rData); + bool SearchCell(const SvxSearchItem& rSearchItem, SCCOL nCol, sc::ColumnBlockConstPosition& rBlockPos, SCROW nRow, + const ScMarkData& rMark, OUString& rUndoStr, ScDocument* pUndoDoc); + bool Search(const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow, + const ScMarkData& rMark, OUString& rUndoStr, ScDocument* pUndoDoc); + bool Search(const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow, + SCCOL nLastCol, SCROW nLastRow, + const ScMarkData& rMark, OUString& rUndoStr, ScDocument* pUndoDoc, + std::vector< sc::ColumnBlockConstPosition >& blockPos); + bool SearchAll(const SvxSearchItem& rSearchItem, const ScMarkData& rMark, + ScRangeList& rMatchedRanges, OUString& rUndoStr, ScDocument* pUndoDoc); + bool Replace(const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow, + const ScMarkData& rMark, OUString& rUndoStr, ScDocument* pUndoDoc); + bool ReplaceAll( + const SvxSearchItem& rSearchItem, const ScMarkData& rMark, ScRangeList& rMatchedRanges, + OUString& rUndoStr, ScDocument* pUndoDoc, bool& bMatchedRangesWereClamped); + + bool SearchStyle(const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow, + const ScMarkData& rMark); + bool ReplaceStyle(const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow, + const ScMarkData& rMark, bool bIsUndo); + bool SearchAllStyle( + const SvxSearchItem& rSearchItem, const ScMarkData& rMark, ScRangeList& rMatchedRanges); + bool ReplaceAllStyle( + const SvxSearchItem& rSearchItem, const ScMarkData& rMark, ScRangeList& rMatchedRanges, + ScDocument* pUndoDoc); + bool SearchAndReplaceEmptyCells( + const SvxSearchItem& rSearchItem, + SCCOL& rCol, SCROW& rRow, const ScMarkData& rMark, ScRangeList& rMatchedRanges, + OUString& rUndoStr, ScDocument* pUndoDoc); + bool SearchRangeForEmptyCell(const ScRange& rRange, + const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow, + OUString& rUndoStr); + bool SearchRangeForAllEmptyCells( + const ScRange& rRange, const SvxSearchItem& rSearchItem, + ScRangeList& rMatchedRanges, OUString& rUndoStr, ScDocument* pUndoDoc); + + // use the global sort parameter: + bool IsSorted(SCCOLROW nStart, SCCOLROW nEnd) const; + static void DecoladeRow( ScSortInfoArray*, SCROW nRow1, SCROW nRow2 ); + short CompareCell( + sal_uInt16 nSort, + ScRefCellValue& rCell1, SCCOL nCell1Col, SCROW nCell1Row, + ScRefCellValue& rCell2, SCCOL nCell2Col, SCROW nCell2Row ) const; + short Compare(SCCOLROW nIndex1, SCCOLROW nIndex2) const; + short Compare( ScSortInfoArray*, SCCOLROW nIndex1, SCCOLROW nIndex2) const; + std::unique_ptr<ScSortInfoArray> CreateSortInfoArray( const sc::ReorderParam& rParam ); + std::unique_ptr<ScSortInfoArray> CreateSortInfoArray( + const ScSortParam& rSortParam, SCCOLROW nInd1, SCCOLROW nInd2, + bool bKeepQuery, bool bUpdateRefs ); + void QuickSort( ScSortInfoArray*, SCCOLROW nLo, SCCOLROW nHi); + void SortReorderByColumn( const ScSortInfoArray* pArray, SCROW nRow1, SCROW nRow2, + bool bPattern, ScProgress* pProgress ); + void SortReorderAreaExtrasByColumn( const ScSortInfoArray* pArray, SCROW nDataRow1, SCROW nDataRow2, + const ScDataAreaExtras& rDataAreaExtras, ScProgress* pProgress ); + + void SortReorderByRow( ScSortInfoArray* pArray, SCCOL nCol1, SCCOL nCol2, + ScProgress* pProgress, bool bOnlyDataAreaExtras ); + void SortReorderByRowRefUpdate( ScSortInfoArray* pArray, SCCOL nCol1, SCCOL nCol2, + ScProgress* pProgress ); + void SortReorderAreaExtrasByRow( ScSortInfoArray* pArray, SCCOL nDataCol1, SCCOL nDataCol2, + const ScDataAreaExtras& rDataAreaExtras, ScProgress* pProgress ); + + bool CreateExcelQuery(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScQueryParam& rQueryParam); + bool CreateStarQuery(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScQueryParam& rQueryParam); + OUString GetUpperCellString(SCCOL nCol, SCROW nRow); + + bool RefVisible(const ScFormulaCell* pCell); + + bool IsEmptyLine(SCROW nRow, SCCOL nStartCol, SCCOL nEndCol) const; + + void IncDate(double& rVal, sal_uInt16& nDayOfMonth, double nStep, FillDateCmd eCmd); + void FillFormula( + const ScFormulaCell* pSrcCell, SCCOL nDestCol, SCROW nDestRow, bool bLast ); + void UpdateInsertTabAbs(SCTAB nNewPos); + bool GetNextSpellingCell(SCCOL& rCol, SCROW& rRow, bool bInSel, + const ScMarkData& rMark) const; + bool GetNextMarkedCell( SCCOL& rCol, SCROW& rRow, const ScMarkData& rMark ) const; + void TestTabRefAbs(SCTAB nTable) const; + void CompileDBFormula( sc::CompileFormulaContext& rCxt ); + void CompileColRowNameFormula( sc::CompileFormulaContext& rCxt ); + + void StartListening( const ScAddress& rAddress, SvtListener* pListener ); + void EndListening( const ScAddress& rAddress, SvtListener* pListener ); + void StartListening( sc::StartListeningContext& rCxt, const ScAddress& rAddress, SvtListener& rListener ); + void EndListening( sc::EndListeningContext& rCxt, const ScAddress& rAddress, SvtListener& rListener ); + + void AttachFormulaCells( sc::StartListeningContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ); + void DetachFormulaCells( sc::EndListeningContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ); + + void SetLoadingMedium(bool bLoading); + + SCSIZE FillMaxRot( RowInfo* pRowInfo, SCSIZE nArrCount, SCCOL nX1, SCCOL nX2, + SCCOL nCol, SCROW nAttrRow1, SCROW nAttrRow2, SCSIZE nArrY, + const ScPatternAttr* pPattern, const SfxItemSet* pCondSet ); + + // idle calculation of OutputDevice text width for cell + // also invalidates script type, broadcasts for "calc as shown" + void InvalidateTextWidth( const ScAddress* pAdrFrom, const ScAddress* pAdrTo, + bool bNumFormatChanged, bool bBroadcast ); + + void SkipFilteredRows(SCROW& rRow, SCROW& rLastNonFilteredRow, bool bForward); + + /** + * In case the cell text goes beyond the column width, move the max column + * position to the right. This is called from ExtendPrintArea. + */ + void MaybeAddExtraColumn(SCCOL& rCol, SCROW nRow, OutputDevice* pDev, double nPPTX, double nPPTY); + + void CopyPrintRange(const ScTable& rTable); + + SCCOL FindNextVisibleColWithContent(SCCOL nCol, bool bRight, SCROW nRow) const; + + SCCOL FindNextVisibleCol(SCCOL nCol, bool bRight) const; + + /** + * Transpose clipboard patterns + * @param nCombinedStartRow start row of the combined range; + * used for transposed multi range selection with row direction; + * for other cases than multi range row selection this it equal to nRow1 + * @param nRowDestOffset adjustment of destination row position; + * used for transposed multi range row selections, otherwise 0 + */ + void TransposeColPatterns(ScTable* pTransClip, SCCOL nCol1, SCCOL nCol, SCROW nRow1, + SCROW nRow2, SCROW nCombinedStartRow, bool bIncludeFiltered, + const std::vector<SCROW>& rFilteredRows, SCROW nRowDestOffset); + + /** + * Transpose clipboard notes + * @param nCombinedStartRow start row of the combined range; + * used for transposed multi range selection with row direction; + * for other cases than multi range row selection this it equal to nRow1 + * @param nRowDestOffset adjustment of destination row position; + * used for transposed multi range row selections, otherwise 0 + */ + void TransposeColNotes(ScTable* pTransClip, SCCOL nCol1, SCCOL nCol, SCROW nRow1, SCROW nRow2, + SCROW nCombinedStartRow, bool bIncludeFiltered, SCROW nRowDestOffset); + + ScColumn* FetchColumn( SCCOL nCol ); + const ScColumn* FetchColumn( SCCOL nCol ) const; + + void EndListeningIntersectedGroup( + sc::EndListeningContext& rCxt, SCCOL nCol, SCROW nRow, std::vector<ScAddress>* pGroupPos ); + + void EndListeningIntersectedGroups( + sc::EndListeningContext& rCxt, const SCCOL nCol1, SCROW nRow1, const SCCOL nCol2, SCROW nRow2, + std::vector<ScAddress>* pGroupPos ); + + void EndListeningGroup( sc::EndListeningContext& rCxt, const SCCOL nCol, SCROW nRow ); + void SetNeedsListeningGroup( SCCOL nCol, SCROW nRow ); + + /// Returns list-of-spans representation of the column-widths/row-heights in twips encoded as an OString. + OString dumpColumnRowSizes(bool bColumns); + /// Returns list-of-spans representation of hidden/filtered states of columns/rows encoded as an OString. + OString dumpHiddenFiltered(bool bColumns, bool bHidden); + /// Returns list-of-spans representation of the column/row groupings encoded as an OString. + OString dumpColumnRowGroups(bool bColumns) const; + + SCCOL GetLOKFreezeCol() const; + SCROW GetLOKFreezeRow() const; + bool SetLOKFreezeCol(SCCOL nFreezeCol); + bool SetLOKFreezeRow(SCROW nFreezeRow); + + /** + * Use this to iterate through non-empty visible cells in a single column. + */ + class VisibleDataCellIterator + { + static constexpr SCROW ROW_NOT_FOUND = -1; + + public: + explicit VisibleDataCellIterator(const ScDocument& rDoc, ScFlatBoolRowSegments& rRowSegs, ScColumn& rColumn); + + /** + * Set the start row position. In case there is not visible data cell + * at the specified row position, it will move to the position of the + * first visible data cell below that point. + * + * @return First visible data cell if found, or NULL otherwise. + */ + ScRefCellValue reset(SCROW nRow); + + /** + * Find the next visible data cell position. + * + * @return Next visible data cell if found, or NULL otherwise. + */ + ScRefCellValue next(); + + /** + * Get the current row position. + * + * @return Current row position, or ROW_NOT_FOUND if the iterator + * doesn't point to a valid data cell position. + */ + SCROW getRow() const { return mnCurRow;} + + private: + const ScDocument& mrDocument; + ScFlatBoolRowSegments& mrRowSegs; + ScColumn& mrColumn; + ScRefCellValue maCell; + SCROW mnCurRow; + SCROW mnUBound; + }; + + // Applies a function to the selected ranges; makes sure to only allocate + // as few columns as needed, and applies the rest to default column data. + // The function looks like + // ApplyDataFunc(ScColumnData& applyTo, SCROW nTop, SCROW nBottom) + template <typename ApplyDataFunc> + void ApplyWithAllocation(const ScMarkData&, ApplyDataFunc); +}; + +template <typename ApplyDataFunc> +void ScTable::ApplyWithAllocation(const ScMarkData& rMark, ApplyDataFunc apply) +{ + if (!rMark.GetTableSelect(nTab) || !(rMark.IsMultiMarked() || rMark.IsMarked())) + return; + SCCOL lastChangeCol; + if (rMark.GetArea().aEnd.Col() == GetDoc().MaxCol()) + { + // For the same unallocated columns until the end we can change just the default. + lastChangeCol = rMark.GetStartOfEqualColumns(GetDoc().MaxCol(), aCol.size()) - 1; + // Allocate needed different columns before changing the default. + if (lastChangeCol >= 0) + CreateColumnIfNotExists(lastChangeCol); + + aDefaultColData.Apply(rMark, GetDoc().MaxCol(), apply); + } + else // need to allocate all columns affected + { + lastChangeCol = rMark.GetArea().aEnd.Col(); + CreateColumnIfNotExists(lastChangeCol); + } + + // The loop should go not to lastChangeCol, but over all columns, to apply to already allocated + // in the "StartOfEqualColumns" range + for (SCCOL i = 0; i < aCol.size(); i++) + aCol[i].Apply(rMark, i, apply); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/tablink.hxx b/sc/inc/tablink.hxx new file mode 100644 index 0000000000..63eba3b2ef --- /dev/null +++ b/sc/inc/tablink.hxx @@ -0,0 +1,113 @@ +/* -*- 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 "scdllapi.h" +#include "refreshtimer.hxx" +#include <sfx2/lnkbase.hxx> + +#include <sfx2/objsh.hxx> +#include <memory> + +class ScDocShell; +struct TableLink_Impl; + +namespace weld { class Window; } + +class ScTableLink final : public ::sfx2::SvBaseLink, public ScRefreshTimer +{ +private: + std::unique_ptr<TableLink_Impl> pImpl; + OUString aFileName; + OUString aFilterName; + OUString aOptions; + bool bInCreate:1; + bool bInEdit:1; + bool bAddUndo:1; + +public: + ScTableLink( ScDocShell* pDocSh, OUString aFile, + OUString aFilter, OUString aOpt, sal_Int32 nRefreshDelaySeconds ); + virtual ~ScTableLink() override; + virtual void Closed() override; + virtual ::sfx2::SvBaseLink::UpdateResult DataChanged( + const OUString& rMimeType, const css::uno::Any & rValue ) override; + + virtual void Edit(weld::Window*, const Link<SvBaseLink&,void>& rEndEditHdl) override; + + bool Refresh(const OUString& rNewFile, const OUString& rNewFilter, + const OUString* pNewOptions /* = NULL */, sal_Int32 nNewRefreshDelaySeconds ); + void SetInCreate(bool bSet) { bInCreate = bSet; } + void SetAddUndo(bool bSet) { bAddUndo = bSet; } + + const OUString& GetFileName() const { return aFileName; } + const OUString& GetFilterName() const { return aFilterName; } + const OUString& GetOptions() const { return aOptions; } + + bool IsUsed() const; + + DECL_LINK( TableEndEditHdl, ::sfx2::SvBaseLink&, void ); +}; + +class ScDocument; +class SfxMedium; +class SfxFilter; + +class SC_DLLPUBLIC ScDocumentLoader +{ +private: + ScDocShell* pDocShell; + SfxObjectShellRef aRef; + SfxMedium* pMedium; + +public: + ScDocumentLoader(const OUString& rFileName, OUString& rFilterName, OUString& rOptions, + sal_uInt32 nRekCnt = 0, weld::Window* pInteractionParent = nullptr, + css::uno::Reference<css::io::XInputStream> xInputStream + = css::uno::Reference<css::io::XInputStream>()); + ~ScDocumentLoader(); + ScDocument* GetDocument(); + ScDocShell* GetDocShell() { return pDocShell; } + bool IsError() const; + + void ReleaseDocRef(); // without calling DoClose + + /** Create SfxMedium for stream read with SfxFilter and filter options set + at the medium's SfxItemSet. + */ + static SfxMedium* CreateMedium(const OUString& rFileName, std::shared_ptr<const SfxFilter> const & pFilter, + const OUString& rOptions, weld::Window* pInteractionParent = nullptr); + + static OUString GetOptions( const SfxMedium& rMedium ); + + /** Returns the filter name and options from a file name. + @param bWithContent + true = Tries to detect the filter by looking at the file contents. + false = Detects filter by file name extension only (should be used in filter code only). + @return sal_True if a filter could be found, sal_False otherwise. */ + + static bool GetFilterName( const OUString& rFileName, + OUString& rFilter, OUString& rOptions, + bool bWithContent, bool bWithInteraction ); + + static void RemoveAppPrefix( OUString& rFilterName ); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/tabopparams.hxx b/sc/inc/tabopparams.hxx new file mode 100644 index 0000000000..0ecd727151 --- /dev/null +++ b/sc/inc/tabopparams.hxx @@ -0,0 +1,86 @@ +/* -*- 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 "address.hxx" + +#include <vector> + +class ScFormulaCell; + +struct ScInterpreterTableOpParams +{ + ScAddress aOld1; + ScAddress aNew1; + ScAddress aOld2; + ScAddress aNew2; + ScAddress aFormulaPos; + ::std::vector< ScFormulaCell* > aNotifiedFormulaCells; + ::std::vector< ScAddress > aNotifiedFormulaPos; + bool bValid; + bool bRefresh; + bool bCollectNotifications; + + ScInterpreterTableOpParams() + : bValid( false ) + , bRefresh( false ) + , bCollectNotifications( true ) + { + } + + ScInterpreterTableOpParams( const ScInterpreterTableOpParams& r ) + : aOld1( r.aOld1 ) + , aNew1( r.aNew1 ) + , aOld2( r.aOld2 ) + , aNew2( r.aNew2 ) + , aFormulaPos( r.aFormulaPos ) + , aNotifiedFormulaPos( r.aNotifiedFormulaPos ) + , bValid( r.bValid ) + , bRefresh( r.bRefresh ) + , bCollectNotifications( r.bCollectNotifications ) + { + } + + ScInterpreterTableOpParams& operator =( const ScInterpreterTableOpParams& r ) + { + aOld1 = r.aOld1; + aNew1 = r.aNew1; + aOld2 = r.aOld2; + aNew2 = r.aNew2; + aFormulaPos = r.aFormulaPos; + ::std::vector< ScFormulaCell* >().swap( aNotifiedFormulaCells ); + aNotifiedFormulaPos = r.aNotifiedFormulaPos; + bValid = r.bValid; + bRefresh = r.bRefresh; + bCollectNotifications = r.bCollectNotifications; + return *this; + } + + bool operator ==( const ScInterpreterTableOpParams& r ) const + { + return + bValid && r.bValid && + aOld1 == r.aOld1 && + aOld2 == r.aOld2 && + aFormulaPos == r.aFormulaPos ; + } +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/tabprotection.hxx b/sc/inc/tabprotection.hxx new file mode 100644 index 0000000000..2ff6188154 --- /dev/null +++ b/sc/inc/tabprotection.hxx @@ -0,0 +1,223 @@ +/* -*- 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 <sal/types.h> + +#include "global.hxx" +#include "rangelst.hxx" +#include <memory> + +class ScDocument; +class ScTableProtectionImpl; + +enum ScPasswordHash +{ + PASSHASH_SHA1 = 0, + PASSHASH_SHA1_UTF8, // tdf#115483 this is UTF8, previous one is wrong UTF16 + PASSHASH_SHA256, + PASSHASH_XL, + PASSHASH_UNSPECIFIED +}; + +/// OOXML password definitions: algorithmName, hashValue, saltValue, spinCount +struct ScOoxPasswordHash +{ + OUString maAlgorithmName; /// "SHA-512", ... + OUString maHashValue; /// base64 encoded hash value + OUString maSaltValue; /// base64 encoded salt value + sal_uInt32 mnSpinCount; /// spin count, iteration runs + + ScOoxPasswordHash() : mnSpinCount(0) {} + bool hasPassword() const { return !maHashValue.isEmpty(); } + void clear() + { + // Keep algorithm and spin count. + maHashValue.clear(); + maSaltValue.clear(); + } + bool verifyPassword( const OUString& aPassText ) const; +}; + +namespace ScPassHashHelper +{ + /** Check for the compatibility of all password hashes. If there is at + * least one hash that needs to be regenerated, it returns true. If all + * hash values are compatible with the specified hash type, then it + * returns false. */ + bool needsPassHashRegen(const ScDocument& rDoc, ScPasswordHash eHash1, ScPasswordHash eHash2 = PASSHASH_UNSPECIFIED); + + OUString getHashURI(ScPasswordHash eHash); + + ScPasswordHash getHashTypeFromURI(std::u16string_view rURI); +} + +class SAL_NO_VTABLE ScPassHashProtectable +{ +public: + virtual ~ScPassHashProtectable() = 0; + + virtual bool isProtected() const = 0; + virtual bool isProtectedWithPass() const = 0; + virtual void setProtected(bool bProtected) = 0; + + virtual bool isPasswordEmpty() const = 0; + virtual bool hasPasswordHash(ScPasswordHash eHash, ScPasswordHash eHash2 = PASSHASH_UNSPECIFIED) const = 0; + virtual void setPassword(const OUString& aPassText) = 0; + virtual css::uno::Sequence<sal_Int8> getPasswordHash( + ScPasswordHash eHash, ScPasswordHash eHas2 = PASSHASH_UNSPECIFIED) const = 0; + virtual const ScOoxPasswordHash& getPasswordHash() const = 0; + virtual void setPasswordHash( + const css::uno::Sequence<sal_Int8>& aPassword, + ScPasswordHash eHash, ScPasswordHash eHash2 = PASSHASH_UNSPECIFIED) = 0; + virtual void setPasswordHash( const OUString& rAlgorithmName, const OUString& rHashValue, + const OUString& rSaltValue, sal_uInt32 nSpinCount ) = 0; + virtual bool verifyPassword(const OUString& aPassText) const = 0; +}; + +class SC_DLLPUBLIC ScDocProtection final : public ScPassHashProtectable +{ +public: + enum Option + { + STRUCTURE = 0, + WINDOWS, + NONE ///< last item - used to resize the vector + }; + + explicit ScDocProtection(); + explicit ScDocProtection(const ScDocProtection& r); + virtual ~ScDocProtection() override; + + virtual bool isProtected() const override; + virtual bool isProtectedWithPass() const override; + virtual void setProtected(bool bProtected) override; + + virtual bool isPasswordEmpty() const override; + virtual bool hasPasswordHash(ScPasswordHash eHash, ScPasswordHash eHash2 = PASSHASH_UNSPECIFIED) const override; + virtual void setPassword(const OUString& aPassText) override; + virtual css::uno::Sequence<sal_Int8> getPasswordHash( + ScPasswordHash eHash, ScPasswordHash eHash2 = PASSHASH_UNSPECIFIED) const override; + virtual const ScOoxPasswordHash& getPasswordHash() const override; + virtual void setPasswordHash( + const css::uno::Sequence<sal_Int8>& aPassword, + ScPasswordHash eHash, ScPasswordHash eHash2 = PASSHASH_UNSPECIFIED) override; + virtual void setPasswordHash( const OUString& rAlgorithmName, const OUString& rHashValue, + const OUString& rSaltValue, sal_uInt32 nSpinCount ) override; + virtual bool verifyPassword(const OUString& aPassText) const override; + + bool isOptionEnabled(Option eOption) const; + void setOption(Option eOption, bool bEnabled); + +private: + std::unique_ptr<ScTableProtectionImpl> mpImpl; +}; + +/** Container for the Excel EnhancedProtection feature. + */ +struct ScEnhancedProtection +{ + ScRangeListRef maRangeList; + sal_uInt32 mnAreserved; + sal_uInt32 mnPasswordVerifier; + OUString maTitle; + ::std::vector< sal_uInt8 > maSecurityDescriptor; // imported as raw BIFF data + OUString maSecurityDescriptorXML; // imported from OOXML + ScOoxPasswordHash maPasswordHash; + + ScEnhancedProtection() : mnAreserved(0), mnPasswordVerifier(0) {} + + bool hasSecurityDescriptor() const + { + return !maSecurityDescriptor.empty() || !maSecurityDescriptorXML.isEmpty(); + } + + bool hasPassword() const + { + return mnPasswordVerifier != 0 || maPasswordHash.hasPassword(); + } +}; + +/** sheet protection state container + * + * This class stores sheet's protection state: 1) whether the protection + * is on, 2) password and/or password hash, and 3) any associated + * protection options. This class is also used as a protection state + * container for the undo/redo stack, in which case the password, hash and + * the options need to be preserved even when the protection flag is + * off. */ +class SC_DLLPUBLIC ScTableProtection final : public ScPassHashProtectable +{ +public: + enum Option + { + AUTOFILTER = 0, + DELETE_COLUMNS, + DELETE_ROWS, + FORMAT_CELLS, + FORMAT_COLUMNS, + FORMAT_ROWS, + INSERT_COLUMNS, + INSERT_HYPERLINKS, + INSERT_ROWS, + OBJECTS, + PIVOT_TABLES, + SCENARIOS, + SELECT_LOCKED_CELLS, + SELECT_UNLOCKED_CELLS, + SORT, + NONE ///< last item - used to resize the vector + }; + + explicit ScTableProtection(); + explicit ScTableProtection(const ScTableProtection& r); + virtual ~ScTableProtection() override; + + virtual bool isProtected() const override; + virtual bool isProtectedWithPass() const override; + virtual void setProtected(bool bProtected) override; + + virtual bool isPasswordEmpty() const override; + virtual bool hasPasswordHash(ScPasswordHash eHash, ScPasswordHash eHash2 = PASSHASH_UNSPECIFIED) const override; + virtual void setPassword(const OUString& aPassText) override; + virtual css::uno::Sequence<sal_Int8> getPasswordHash( + ScPasswordHash eHash, ScPasswordHash eHash2 = PASSHASH_UNSPECIFIED) const override; + virtual const ScOoxPasswordHash& getPasswordHash() const override; + virtual void setPasswordHash( + const css::uno::Sequence<sal_Int8>& aPassword, + ScPasswordHash eHash, ScPasswordHash eHash2 = PASSHASH_UNSPECIFIED) override; + virtual void setPasswordHash( const OUString& rAlgorithmName, const OUString& rHashValue, + const OUString& rSaltValue, sal_uInt32 nSpinCount ) override; + virtual bool verifyPassword(const OUString& aPassText) const override; + + bool isOptionEnabled(Option eOption) const; + void setOption(Option eOption, bool bEnabled); + + void setEnhancedProtection( ::std::vector< ScEnhancedProtection > && rProt ); + const ::std::vector< ScEnhancedProtection > & getEnhancedProtection() const; + bool updateReference( UpdateRefMode, const ScDocument&, const ScRange& rWhere, SCCOL nDx, SCROW nDy, SCTAB nDz ); + bool isBlockEditable( const ScRange& rRange ) const; + bool isSelectionEditable( const ScRangeList& rRangeList ) const; + +private: + std::unique_ptr<ScTableProtectionImpl> mpImpl; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/targuno.hxx b/sc/inc/targuno.hxx new file mode 100644 index 0000000000..b45c56f575 --- /dev/null +++ b/sc/inc/targuno.hxx @@ -0,0 +1,143 @@ +/* -*- 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 <svl/lstner.hxx> +#include <com/sun/star/document/XLinkTargetSupplier.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/container/XNameAccess.hpp> +#include <cppuhelper/implbase.hxx> + +namespace com::sun::star::beans { class XPropertyChangeListener; } +namespace com::sun::star::beans { class XPropertySetInfo; } +namespace com::sun::star::beans { class XVetoableChangeListener; } + +class ScDocShell; + +#define SC_LINKTARGETTYPE_SHEET 0 +#define SC_LINKTARGETTYPE_RANGENAME 1 +#define SC_LINKTARGETTYPE_DBAREA 2 + +#define SC_LINKTARGETTYPE_COUNT 3 + +inline constexpr OUString SCLINKTARGET_SERVICE = u"com.sun.star.document.LinkTarget"_ustr; + +//! Graphic / OleObject (need separate collections!) + +class ScLinkTargetTypesObj final : public ::cppu::WeakImplHelper< + css::container::XNameAccess, + css::lang::XServiceInfo >, + public SfxListener +{ +private: + ScDocShell* pDocShell; + OUString aNames[SC_LINKTARGETTYPE_COUNT]; + +public: + ScLinkTargetTypesObj(ScDocShell* pDocSh); + virtual ~ScLinkTargetTypesObj() override; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + // css::container::XNameAccess + virtual css::uno::Any SAL_CALL getByName(const OUString& aName) override; + virtual css::uno::Sequence< OUString> SAL_CALL getElementNames() override; + virtual sal_Bool SAL_CALL hasByName(const OUString& aName) override; + + // css::container::XElementAccess + virtual css::uno::Type SAL_CALL getElementType() override; + virtual sal_Bool SAL_CALL hasElements() override; + + // css::lang::XServiceInfo + 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; +}; + +class ScLinkTargetTypeObj final : public ::cppu::WeakImplHelper< + css::beans::XPropertySet, + css::document::XLinkTargetSupplier, + css::lang::XServiceInfo >, + public SfxListener +{ +private: + ScDocShell* pDocShell; + sal_uInt16 nType; + OUString aName; + +public: + ScLinkTargetTypeObj(ScDocShell* pDocSh, sal_uInt16 nT); + virtual ~ScLinkTargetTypeObj() override; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + static void SetLinkTargetBitmap( css::uno::Any& rRet, sal_uInt16 nType ); + + // css::beans::XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override; + virtual void SAL_CALL setPropertyValue(const OUString& aPropertyName, + const css::uno::Any& aValue) override; + virtual css::uno::Any SAL_CALL getPropertyValue(const OUString& PropertyName) override; + virtual void SAL_CALL addPropertyChangeListener(const OUString& aPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener > & xListener) override; + virtual void SAL_CALL removePropertyChangeListener(const OUString& aPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener > & aListener) override; + virtual void SAL_CALL addVetoableChangeListener(const OUString& PropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener > & aListener) override; + virtual void SAL_CALL removeVetoableChangeListener(const OUString& PropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener > & aListener) override; + + // css::document::XLinkTargetSupplier + virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getLinks() override; + + // css::lang::XServiceInfo + 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; +}; + +class ScLinkTargetsObj final : public ::cppu::WeakImplHelper< + css::container::XNameAccess, + css::lang::XServiceInfo > +{ +private: + css::uno::Reference< css::container::XNameAccess > xCollection; + +public: + ScLinkTargetsObj( css::uno::Reference< css::container::XNameAccess > xColl ); + virtual ~ScLinkTargetsObj() override; + + // css::container::XNameAccess + virtual css::uno::Any SAL_CALL getByName(const OUString& aName) override; + virtual css::uno::Sequence< OUString> SAL_CALL getElementNames() override; + virtual sal_Bool SAL_CALL hasByName(const OUString& aName) override; + + // css::container::XElementAccess + virtual css::uno::Type SAL_CALL getElementType() override; + virtual sal_Bool SAL_CALL hasElements() override; + + // css::lang::XServiceInfo + 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; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/testlotus.hxx b/sc/inc/testlotus.hxx new file mode 100644 index 0000000000..f160dc7327 --- /dev/null +++ b/sc/inc/testlotus.hxx @@ -0,0 +1,16 @@ +/* -*- 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/. + */ + +#include <sal/types.h> + +class SvStream; + +extern "C" SAL_DLLPUBLIC_EXPORT bool TestImportWKS(SvStream& rStream); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/textuno.hxx b/sc/inc/textuno.hxx new file mode 100644 index 0000000000..e5ec1aca0c --- /dev/null +++ b/sc/inc/textuno.hxx @@ -0,0 +1,360 @@ +/* -*- 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 "address.hxx" +#include <editeng/unotext.hxx> +#include <svl/lstner.hxx> +#include <com/sun/star/text/XTextFieldsSupplier.hpp> +#include <com/sun/star/sheet/XHeaderFooterContent.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <comphelper/servicehelper.hxx> +#include <cppuhelper/implbase.hxx> +#include <cppuhelper/weakref.hxx> + +#include <rtl/ref.hxx> + +#include <memory> + +class EditEngine; +class EditTextObject; +class SvxEditEngineForwarder; +class ScDocShell; +class ScCellObj; +class ScSimpleEditSource; +class ScCellEditSource; +class ScEditEngineDefaulter; +class ScFieldEditEngine; +class ScHeaderFooterTextObj; + +struct ScHeaderFieldData; + +enum class ScHeaderFooterPart{ LEFT, CENTER, RIGHT }; + +// ScHeaderFooterContentObj is a dumb container which must be re-written into +// the page template using setPropertyValue + +class ScHeaderFooterContentObj final : public cppu::WeakImplHelper< + css::sheet::XHeaderFooterContent, + css::lang::XServiceInfo > +{ +private: + rtl::Reference<ScHeaderFooterTextObj> mxLeftText; + rtl::Reference<ScHeaderFooterTextObj> mxCenterText; + rtl::Reference<ScHeaderFooterTextObj> mxRightText; + +public: + ScHeaderFooterContentObj(); + virtual ~ScHeaderFooterContentObj() override; + + // for ScPageHFItem (using getImplementation) + const EditTextObject* GetLeftEditObject() const; + const EditTextObject* GetCenterEditObject() const; + const EditTextObject* GetRightEditObject() const; + + void Init( const EditTextObject* pLeft, + const EditTextObject* pCenter, + const EditTextObject* pRight); + + // XHeaderFooterContent + virtual css::uno::Reference< css::text::XText > SAL_CALL + getLeftText() override; + virtual css::uno::Reference< css::text::XText > SAL_CALL + getCenterText() override; + virtual css::uno::Reference< css::text::XText > SAL_CALL + getRightText() override; + + static rtl::Reference<ScHeaderFooterContentObj> getImplementation(const css::uno::Reference<css::sheet::XHeaderFooterContent>& rObj); + + // XServiceInfo + 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; + +}; + +// ScHeaderFooterTextData: shared data between sub objects of a ScHeaderFooterTextObj + +class ScHeaderFooterTextData +{ +private: + std::unique_ptr<EditTextObject> mpTextObj; + css::uno::WeakReference<css::sheet::XHeaderFooterContent> xContentObj; + ScHeaderFooterPart nPart; + std::unique_ptr<ScEditEngineDefaulter> pEditEngine; + std::unique_ptr<SvxEditEngineForwarder> pForwarder; + bool bDataValid; + +public: + ScHeaderFooterTextData(const ScHeaderFooterTextData&) = delete; + const ScHeaderFooterTextData& operator=(const ScHeaderFooterTextData&) = delete; + ScHeaderFooterTextData( + css::uno::WeakReference<css::sheet::XHeaderFooterContent> xContent, ScHeaderFooterPart nP, const EditTextObject* pTextObj); + ~ScHeaderFooterTextData(); + + // helper functions + SvxTextForwarder* GetTextForwarder(); + void UpdateData(); + void UpdateData(EditEngine& rEditEngine); + ScEditEngineDefaulter* GetEditEngine() { GetTextForwarder(); return pEditEngine.get(); } + + ScHeaderFooterPart GetPart() const { return nPart; } + css::uno::Reference<css::sheet::XHeaderFooterContent> GetContentObj() const { return xContentObj; } + + const EditTextObject* GetTextObject() const { return mpTextObj.get(); } +}; + +/** + * Each of these instances represent, the left, center or right part of the + * header of footer of a page. + * + * ScHeaderFooterTextObj changes the text in a ScHeaderFooterContentObj. + */ +class ScHeaderFooterTextObj final : public cppu::WeakImplHelper< + css::text::XText, + css::text::XTextRangeMover, + css::container::XEnumerationAccess, + css::text::XTextFieldsSupplier, + css::lang::XServiceInfo > +{ +private: + ScHeaderFooterTextData aTextData; + rtl::Reference<SvxUnoText> mxUnoText; + + void CreateUnoText_Impl(); + +public: + ScHeaderFooterTextObj( + const css::uno::WeakReference<css::sheet::XHeaderFooterContent>& xContent, ScHeaderFooterPart nP, const EditTextObject* pTextObj); + virtual ~ScHeaderFooterTextObj() override; + + const EditTextObject* GetTextObject() const; + const SvxUnoText& GetUnoText(); + + static void FillDummyFieldData( ScHeaderFieldData& rData ); + + // XText + virtual void SAL_CALL insertTextContent( const css::uno::Reference< css::text::XTextRange >& xRange, + const css::uno::Reference< css::text::XTextContent >& xContent, + sal_Bool bAbsorb ) override; + virtual void SAL_CALL removeTextContent( const css::uno::Reference< css::text::XTextContent >& xContent ) override; + + // XSimpleText + virtual css::uno::Reference< css::text::XTextCursor > SAL_CALL + createTextCursor() override; + virtual css::uno::Reference< css::text::XTextCursor > SAL_CALL + createTextCursorByRange( const css::uno::Reference< css::text::XTextRange >& aTextPosition ) override; + virtual void SAL_CALL insertString( const css::uno::Reference< css::text::XTextRange >& xRange, + const OUString& aString, sal_Bool bAbsorb ) override; + virtual void SAL_CALL insertControlCharacter( const css::uno::Reference< css::text::XTextRange >& xRange, + sal_Int16 nControlCharacter, sal_Bool bAbsorb ) override; + + // XTextRange + virtual css::uno::Reference< css::text::XText > SAL_CALL + getText() override; + virtual css::uno::Reference< css::text::XTextRange > SAL_CALL + getStart() override; + virtual css::uno::Reference< css::text::XTextRange > SAL_CALL + getEnd() override; + virtual OUString SAL_CALL getString() override; + virtual void SAL_CALL setString( const OUString& aString ) override; + + // XTextRangeMover + virtual void SAL_CALL moveTextRange( const css::uno::Reference< css::text::XTextRange >& xRange, + sal_Int16 nParagraphs ) override; + + // XEnumerationAccess + virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL + createEnumeration() override; + + // XElementAccess + virtual css::uno::Type SAL_CALL getElementType() override; + virtual sal_Bool SAL_CALL hasElements() override; + + // XTextFieldsSupplier + virtual css::uno::Reference< css::container::XEnumerationAccess > SAL_CALL + getTextFields() override; + virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL + getTextFieldMasters() override; + + // XServiceInfo + 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; + +}; + +// derived cursor objects for getImplementation and getText/getStart/getEnd + +//! uno3: SvxUnoTextCursor is not derived from XUnoTunnel, but should be (?) + +class ScCellTextCursor final : public SvxUnoTextCursor +{ + rtl::Reference<ScCellObj> mxTextObj; + +public: + ScCellTextCursor(ScCellObj& rText); + virtual ~ScCellTextCursor() noexcept override; + + ScCellTextCursor(ScCellTextCursor const &) = default; + ScCellTextCursor(ScCellTextCursor &&) = default; + ScCellTextCursor & operator =(ScCellTextCursor const &) = delete; // due to SvxUnoTextCursor + ScCellTextCursor & operator =(ScCellTextCursor &&) = delete; // due to SvxUnoTextCursor + + ScCellObj& GetCellObj() const { return *mxTextObj; } + + // SvxUnoTextCursor methods reimplemented here: + virtual css::uno::Reference< css::text::XText > SAL_CALL + getText() override; + virtual css::uno::Reference< css::text::XTextRange > SAL_CALL + getStart() override; + virtual css::uno::Reference< css::text::XTextRange > SAL_CALL + getEnd() override; + + // XUnoTunnel + UNO3_GETIMPLEMENTATION_DECL(ScCellTextCursor) +}; + +class ScHeaderFooterTextCursor final : public SvxUnoTextCursor +{ +private: + rtl::Reference<ScHeaderFooterTextObj> rTextObj; + +public: + ScHeaderFooterTextCursor(rtl::Reference<ScHeaderFooterTextObj> const & rText); + virtual ~ScHeaderFooterTextCursor() noexcept override; + + ScHeaderFooterTextCursor(ScHeaderFooterTextCursor const &) = default; + ScHeaderFooterTextCursor(ScHeaderFooterTextCursor &&) = default; + ScHeaderFooterTextCursor & operator =(ScHeaderFooterTextCursor const &) = delete; // due to SvxUnoTextCursor + ScHeaderFooterTextCursor & operator =(ScHeaderFooterTextCursor &&) = delete; // due to SvxUnoTextCursor + + // SvxUnoTextCursor methods reimplemented here: + virtual css::uno::Reference< css::text::XText > SAL_CALL + getText() override; + virtual css::uno::Reference< css::text::XTextRange > SAL_CALL + getStart() override; + virtual css::uno::Reference< css::text::XTextRange > SAL_CALL + getEnd() override; + + // XUnoTunnel + UNO3_GETIMPLEMENTATION_DECL(ScHeaderFooterTextCursor) +}; + +class ScDrawTextCursor final : public SvxUnoTextCursor +{ +private: + css::uno::Reference< css::text::XText > xParentText; + +public: + ScDrawTextCursor( css::uno::Reference< css::text::XText > xParent, + const SvxUnoTextBase& rText ); + virtual ~ScDrawTextCursor() noexcept override; + + ScDrawTextCursor(ScDrawTextCursor const &) = default; + ScDrawTextCursor(ScDrawTextCursor &&) = default; + ScDrawTextCursor & operator =(ScDrawTextCursor const &) = delete; // due to SvxUnoTextCursor + ScDrawTextCursor & operator =(ScDrawTextCursor &&) = delete; // due to SvxUnoTextCursor + + // SvxUnoTextCursor methods reimplemented here: + virtual css::uno::Reference< css::text::XText > SAL_CALL + getText() override; + virtual css::uno::Reference< css::text::XTextRange > SAL_CALL + getStart() override; + virtual css::uno::Reference< css::text::XTextRange > SAL_CALL + getEnd() override; + + // XUnoTunnel + UNO3_GETIMPLEMENTATION_DECL(ScDrawTextCursor) +}; + +// ScAnnotationTextCursor isn't needed anymore - SvxUnoTextCursor is used instead + +// ScEditEngineTextObj for formatted cell content that is not inserted in a cell or header/footer +// (used for XML export of change tracking contents) + +class ScSimpleEditSourceHelper +{ + std::unique_ptr<ScEditEngineDefaulter> pEditEngine; + std::unique_ptr<SvxEditEngineForwarder> pForwarder; + std::unique_ptr<ScSimpleEditSource> pOriginalSource; + +public: + ScSimpleEditSourceHelper(); + ~ScSimpleEditSourceHelper(); + + ScSimpleEditSource* GetOriginalSource() const { return pOriginalSource.get(); } + ScEditEngineDefaulter* GetEditEngine() const { return pEditEngine.get(); } +}; + +class ScEditEngineTextObj final : public ScSimpleEditSourceHelper, public SvxUnoText +{ +public: + ScEditEngineTextObj(); + virtual ~ScEditEngineTextObj() noexcept override; + + void SetText( const EditTextObject& rTextObject ); + std::unique_ptr<EditTextObject> CreateTextObject(); +}; + +// ScCellTextData: shared data between sub objects of a cell text object + +class ScCellTextData : public SfxListener +{ +protected: + ScDocShell* pDocShell; + ScAddress aCellPos; + std::unique_ptr<ScFieldEditEngine> pEditEngine; + std::unique_ptr<SvxEditEngineForwarder> pForwarder; + std::unique_ptr<ScCellEditSource> pOriginalSource; + bool bDataValid; + bool bInUpdate; + bool bDirty; + bool bDoUpdate; + +public: + ScCellTextData(ScDocShell* pDocSh, const ScAddress& rP); + virtual ~ScCellTextData() override; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + // helper functions for ScSharedCellEditSource: + virtual SvxTextForwarder* GetTextForwarder(); + void UpdateData(); + ScFieldEditEngine* GetEditEngine() { GetTextForwarder(); return pEditEngine.get(); } + + ScCellEditSource* GetOriginalSource(); // used as argument for SvxUnoText ctor + + // used for ScCellEditSource: + ScDocShell* GetDocShell() const { return pDocShell; } + const ScAddress& GetCellPos() const { return aCellPos; } + + bool IsDirty() const { return bDirty; } + void SetDoUpdate(bool bValue) { bDoUpdate = bValue; } +}; + +class ScCellTextObj final : public ScCellTextData, public SvxUnoText +{ +public: + ScCellTextObj(ScDocShell* pDocSh, const ScAddress& rP); + virtual ~ScCellTextObj() COVERITY_NOEXCEPT_FALSE override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/token.hxx b/sc/inc/token.hxx new file mode 100644 index 0000000000..9969158184 --- /dev/null +++ b/sc/inc/token.hxx @@ -0,0 +1,455 @@ +/* -*- 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 <memory> +#include <vector> + +#include <formula/opcode.hxx> +#include "refdata.hxx" +#include "scdllapi.h" +#include <formula/token.hxx> +#include "calcmacros.hxx" +#include "types.hxx" + +// Matrix token constants. +#define MATRIX_TOKEN_HAS_RANGE 1 + +class ScJumpMatrix; +class ScMatrix; +struct ScSheetLimits; + +typedef ::std::vector< ScComplexRefData > ScRefList; + +#if DEBUG_FORMULA_COMPILER +void DumpToken(formula::FormulaToken const & rToken); +#endif + +/** If rTok1 and rTok2 both are SingleRef or DoubleRef tokens, extend/merge + ranges as needed for ocRange. + @param rPos + The formula's position, used to calculate absolute positions from + relative references. + @param bReuseDoubleRef + If true, a DoubleRef token is reused if passed as rTok1 or rTok2, + else a new DoubleRef token is created and returned. + @return + A reused or new'ed ScDoubleRefToken, or a NULL TokenRef if rTok1 or + rTok2 are not of sv(Single|Double)Ref +*/ +formula::FormulaTokenRef extendRangeReference( ScSheetLimits& rLimits, formula::FormulaToken & rTok1, formula::FormulaToken & rTok2, const ScAddress & rPos, bool bReuseDoubleRef ); + +class ScSingleRefToken final : public formula::FormulaToken +{ +private: + ScSheetLimits& mrSheetLimits; // don't use rtl::Reference to avoid ref-counting traffic + ScSingleRefData aSingleRef; +public: + ScSingleRefToken( ScSheetLimits& rLimits, const ScSingleRefData& r, OpCode e = ocPush ) : + FormulaToken( formula::svSingleRef, e ), mrSheetLimits(rLimits), aSingleRef( r ) {} + virtual const ScSingleRefData* GetSingleRef() const override; + virtual ScSingleRefData* GetSingleRef() override; + virtual bool TextEqual( const formula::FormulaToken& rToken ) const override; + virtual bool operator==( const formula::FormulaToken& rToken ) const override; + virtual FormulaToken* Clone() const override { return new ScSingleRefToken(*this); } +}; + +class ScDoubleRefToken final : public formula::FormulaToken +{ +private: + ScSheetLimits& mrSheetLimits; // don't use rtl::Reference to avoid ref-counting traffic + ScComplexRefData aDoubleRef; +public: + ScDoubleRefToken( ScSheetLimits& rLimits, const ScComplexRefData& r, OpCode e = ocPush ) : + FormulaToken( formula::svDoubleRef, e ), mrSheetLimits(rLimits), aDoubleRef( r ) {} + virtual const ScSingleRefData* GetSingleRef() const override; + virtual ScSingleRefData* GetSingleRef() override; + virtual const ScComplexRefData* GetDoubleRef() const override; + virtual ScComplexRefData* GetDoubleRef() override; + virtual const ScSingleRefData* GetSingleRef2() const override; + virtual ScSingleRefData* GetSingleRef2() override; + virtual bool TextEqual( const formula::FormulaToken& rToken ) const override; + virtual bool operator==( const formula::FormulaToken& rToken ) const override; + virtual FormulaToken* Clone() const override { return new ScDoubleRefToken(*this); } +}; + +class ScMatrixToken final : public formula::FormulaToken +{ +private: + ScMatrixRef pMatrix; +public: + ScMatrixToken( ScMatrixRef p ); + ScMatrixToken( const ScMatrixToken& ); + + virtual const ScMatrix* GetMatrix() const override; + virtual ScMatrix* GetMatrix() override; + virtual bool operator==( const formula::FormulaToken& rToken ) const override; + virtual FormulaToken* Clone() const override { return new ScMatrixToken(*this); } +}; + +/** + * Token storing matrix that represents values in sheet range. It stores + * both the values in matrix form, and the range address the matrix + * represents. + */ +class ScMatrixRangeToken final : public formula::FormulaToken +{ + ScMatrixRef mpMatrix; + ScComplexRefData maRef; +public: + ScMatrixRangeToken( const sc::RangeMatrix& rMat ); + ScMatrixRangeToken( const ScMatrixRangeToken& ); + + virtual sal_uInt8 GetByte() const override; + virtual const ScMatrix* GetMatrix() const override; + virtual ScMatrix* GetMatrix() override; + virtual const ScComplexRefData* GetDoubleRef() const override; + virtual ScComplexRefData* GetDoubleRef() override; + virtual bool operator==( const formula::FormulaToken& rToken ) const override; + virtual FormulaToken* Clone() const override; +}; + +class ScExternalSingleRefToken final : public formula::FormulaToken +{ + sal_uInt16 mnFileId; + svl::SharedString maTabName; + ScSingleRefData maSingleRef; + +public: + ScExternalSingleRefToken( sal_uInt16 nFileId, svl::SharedString aTabName, const ScSingleRefData& r ); + ScExternalSingleRefToken() = delete; + virtual ~ScExternalSingleRefToken() override; + + ScExternalSingleRefToken(ScExternalSingleRefToken const &) = default; + ScExternalSingleRefToken(ScExternalSingleRefToken &&) = default; + ScExternalSingleRefToken & operator =(ScExternalSingleRefToken const &) = delete; // due to FormulaToken + ScExternalSingleRefToken & operator =(ScExternalSingleRefToken &&) = delete; // due to FormulaToken + + virtual sal_uInt16 GetIndex() const override; + virtual const svl::SharedString & GetString() const override; + virtual const ScSingleRefData* GetSingleRef() const override; + virtual ScSingleRefData* GetSingleRef() override; + virtual bool operator==( const formula::FormulaToken& rToken ) const override; + virtual FormulaToken* Clone() const override { return new ScExternalSingleRefToken(*this); } +}; + +class ScExternalDoubleRefToken final : public formula::FormulaToken +{ + sal_uInt16 mnFileId; + svl::SharedString maTabName; // name of the first sheet + ScComplexRefData maDoubleRef; + +public: + ScExternalDoubleRefToken() = delete; + ScExternalDoubleRefToken( sal_uInt16 nFileId, svl::SharedString aTabName, const ScComplexRefData& r ); + virtual ~ScExternalDoubleRefToken() override; + + ScExternalDoubleRefToken(ScExternalDoubleRefToken const &) = default; + ScExternalDoubleRefToken(ScExternalDoubleRefToken &&) = default; + ScExternalDoubleRefToken & operator =(ScExternalDoubleRefToken const &) = delete; // due to FormulaToken + ScExternalDoubleRefToken & operator =(ScExternalDoubleRefToken &&) = delete; // due to FormulaToken + + virtual sal_uInt16 GetIndex() const override; + virtual const svl::SharedString & GetString() const override; + virtual const ScSingleRefData* GetSingleRef() const override; + virtual ScSingleRefData* GetSingleRef() override; + virtual const ScSingleRefData* GetSingleRef2() const override; + virtual ScSingleRefData* GetSingleRef2() override; + virtual const ScComplexRefData* GetDoubleRef() const override; + virtual ScComplexRefData* GetDoubleRef() override; + virtual bool operator==( const formula::FormulaToken& rToken ) const override; + virtual FormulaToken* Clone() const override { return new ScExternalDoubleRefToken(*this); } +}; + +class ScExternalNameToken final : public formula::FormulaToken +{ + sal_uInt16 mnFileId; + svl::SharedString maName; + +public: + ScExternalNameToken() = delete; + ScExternalNameToken( sal_uInt16 nFileId, svl::SharedString aName ); + virtual ~ScExternalNameToken() override; + + ScExternalNameToken(ScExternalNameToken const &) = default; + ScExternalNameToken(ScExternalNameToken &&) = default; + ScExternalNameToken & operator =(ScExternalNameToken const &) = delete; // due to FormulaToken + ScExternalNameToken & operator =(ScExternalNameToken &&) = delete; // due to FormulaToken + + virtual sal_uInt16 GetIndex() const override; + virtual const svl::SharedString & GetString() const override; + virtual bool operator==( const formula::FormulaToken& rToken ) const override; + virtual FormulaToken* Clone() const override { return new ScExternalNameToken(*this); } +}; + +/** Special token to remember details of ocTableRef "structured references". */ +class ScTableRefToken final : public formula::FormulaToken +{ +public: + + enum Item + { + TABLE = 0, + ALL = 1, + HEADERS = 2, + DATA = 4, + TOTALS = 8, + THIS_ROW = 16, + HEADERS_DATA = HEADERS | DATA, + DATA_TOTALS = DATA | TOTALS + }; + + ScTableRefToken() = delete; + ScTableRefToken( sal_uInt16 nIndex, Item eItem ); + ScTableRefToken( const ScTableRefToken& r ); + virtual ~ScTableRefToken() override; + + virtual sal_uInt16 GetIndex() const override; + virtual void SetIndex( sal_uInt16 n ) override; + virtual sal_Int16 GetSheet() const override; + virtual bool operator==( const formula::FormulaToken& rToken ) const override; + virtual FormulaToken* Clone() const override { return new ScTableRefToken(*this); } + + Item GetItem() const; + void AddItem( Item ); + void SetAreaRefRPN( formula::FormulaToken* pToken ); + formula::FormulaToken* GetAreaRefRPN() const; + +private: + + formula::FormulaTokenRef mxAreaRefRPN; ///< resulting RPN area + sal_uInt16 mnIndex; ///< index into table / database range collection + Item meItem; +}; + +// Only created from within the interpreter, no conversion from ScRawToken, +// never added to ScTokenArray! +class ScJumpMatrixToken final : public formula::FormulaToken +{ +private: + std::shared_ptr<ScJumpMatrix> mpJumpMatrix; +public: + ScJumpMatrixToken( std::shared_ptr<ScJumpMatrix> p ); + ScJumpMatrixToken( const ScJumpMatrixToken & ); + virtual ~ScJumpMatrixToken() override; + virtual ScJumpMatrix* GetJumpMatrix() const override; + virtual bool operator==( const formula::FormulaToken& rToken ) const override; + virtual FormulaToken* Clone() const override { return new ScJumpMatrixToken(*this); } +}; + +// Only created from within the interpreter, no conversion from ScRawToken, +// never added to ScTokenArray! +class ScRefListToken final : public formula::FormulaToken +{ +private: + ScRefList aRefList; + bool mbArrayResult; // whether RefList is an array result +public: + ScRefListToken() : + FormulaToken( formula::svRefList ), mbArrayResult(false) {} + explicit ScRefListToken( bool bArrayResult ) : + FormulaToken( formula::svRefList ), mbArrayResult( bArrayResult ) {} + bool IsArrayResult() const; + virtual const ScRefList* GetRefList() const override; + virtual ScRefList* GetRefList() override; + virtual bool operator==( const formula::FormulaToken& rToken ) const override; + virtual FormulaToken* Clone() const override { return new ScRefListToken(*this); } +}; + +class ScEmptyCellToken final : public formula::FormulaToken +{ + bool bInherited :1; + bool bDisplayedAsString :1; +public: + explicit ScEmptyCellToken( bool bInheritedP, bool bDisplayAsString ) : + FormulaToken( formula::svEmptyCell ), + bInherited( bInheritedP ), + bDisplayedAsString( bDisplayAsString ) {} + bool IsInherited() const { return bInherited; } + bool IsDisplayedAsString() const { return bDisplayedAsString; } + virtual double GetDouble() const override; + virtual const svl::SharedString & GetString() const override; + virtual bool operator==( const formula::FormulaToken& rToken ) const override; + virtual FormulaToken* Clone() const override { return new ScEmptyCellToken(*this); } +}; + +/** Transports the result from the interpreter to the formula cell. */ +class ScMatrixCellResultToken : public formula::FormulaToken +{ + // No non-const access implemented, silence down unxsols4 complaining about + // the public GetMatrix() hiding the one from FormulaToken. + virtual ScMatrix* GetMatrix() override; + +protected: + ScConstMatrixRef xMatrix; + formula::FormulaConstTokenRef xUpperLeft; +public: + ScMatrixCellResultToken( ScConstMatrixRef pMat, const formula::FormulaToken* pUL ); + ScMatrixCellResultToken( const ScMatrixCellResultToken& ); + virtual ~ScMatrixCellResultToken() override; + virtual double GetDouble() const override; + virtual const svl::SharedString & GetString() const override; + virtual const ScMatrix* GetMatrix() const override; + virtual bool operator==( const formula::FormulaToken& rToken ) const override; + virtual FormulaToken* Clone() const override; + formula::StackVar GetUpperLeftType() const + { + return xUpperLeft ? + xUpperLeft->GetType() : + formula::svUnknown; + } + const formula::FormulaConstTokenRef& GetUpperLeftToken() const { return xUpperLeft; } + void Assign( const ScMatrixCellResultToken & r ); +}; + +/** Stores the matrix result at the formula cell, additionally the range the + matrix formula occupies. */ +class ScMatrixFormulaCellToken final : public ScMatrixCellResultToken +{ +private: + SCROW nRows; + SCCOL nCols; +public: + ScMatrixFormulaCellToken( SCCOL nC, SCROW nR, const ScConstMatrixRef& pMat, const formula::FormulaToken* pUL ); + ScMatrixFormulaCellToken( SCCOL nC, SCROW nR ); + ScMatrixFormulaCellToken( const ScMatrixFormulaCellToken& r ); + virtual ~ScMatrixFormulaCellToken() override; + + virtual bool operator==( const formula::FormulaToken& rToken ) const override; + virtual FormulaToken* Clone() const override { return new ScMatrixFormulaCellToken(*this); } + void SetMatColsRows( SCCOL nC, SCROW nR ) + { + nRows = nR; + nCols = nC; + } + void GetMatColsRows( SCCOL & nC, SCROW & nR ) const + { + nR = nRows; + nC = nCols; + } + SCCOL GetMatCols() const { return nCols; } + SCROW GetMatRows() const { return nRows; } + + /** Assign matrix result, keep matrix formula + dimension. */ + void Assign( const ScMatrixCellResultToken & r ); + + /** Assign any result, keep matrix formula + dimension. If token is of type + ScMatrixCellResultToken uses the + appropriate Assign() call, other tokens + are assigned to xUpperLeft and xMatrix will + be assigned NULL. */ + void Assign( const formula::FormulaToken & r ); + + /** Modify xUpperLeft if formula::svDouble, or create + new formula::FormulaDoubleToken if not set yet. Does + nothing if xUpperLeft is of different type! */ + void SetUpperLeftDouble( double f); + + /** Reset matrix and upper left, keep matrix + formula dimension. */ + void ResetResult(); + +private: + + /** xUpperLeft is modifiable through SetUpperLeftDouble(), so clone it + whenever an svDouble token is assigned to. */ + void CloneUpperLeftIfNecessary(); +}; + +class ScHybridCellToken final : public formula::FormulaToken +{ +private: + double mfDouble; + svl::SharedString maString; + OUString maFormula; + bool mbEmptyDisplayedAsString; +public: + ScHybridCellToken( + double f, const svl::SharedString & rStr, OUString aFormula, bool bEmptyDisplayedAsString ); + + const OUString& GetFormula() const { return maFormula; } + bool IsEmptyDisplayedAsString() const { return mbEmptyDisplayedAsString; } + virtual double GetDouble() const override; + + virtual const svl::SharedString & GetString() const override; + virtual bool operator==( const formula::FormulaToken& rToken ) const override; + virtual FormulaToken* Clone() const override { return new ScHybridCellToken(*this); } +}; + +// Simplify argument passing to RefUpdate methods with ScSingleRefToken or +// ScDoubleRefToken +class SingleDoubleRefModifier +{ + ScComplexRefData aDub; + ScSingleRefData* pS; + ScComplexRefData* pD; + + SingleDoubleRefModifier( const SingleDoubleRefModifier& ) = delete; + SingleDoubleRefModifier& operator=( const SingleDoubleRefModifier& ) = delete; + +public: + SingleDoubleRefModifier( formula::FormulaToken& rT ) + { + formula::StackVar eType = rT.GetType(); + if ( eType == formula::svSingleRef || eType == formula::svExternalSingleRef ) + { + pS = rT.GetSingleRef(); + aDub.Ref1 = aDub.Ref2 = *pS; + pD = &aDub; + } + else + { + pS = nullptr; + pD = rT.GetDoubleRef(); + // coverity[uninit_member] - aDub intentionally not initialized, unnecessary because unused. + } + } + SingleDoubleRefModifier( ScSingleRefData& rS ) + { + pS = &rS; + aDub.Ref1 = aDub.Ref2 = *pS; + pD = &aDub; + } + ~SingleDoubleRefModifier() + { + if ( pS ) + *pS = (*pD).Ref1; + } + ScComplexRefData& Ref() { return *pD; } +}; + +class SingleDoubleRefProvider +{ +public: + + const ScSingleRefData& Ref1; + const ScSingleRefData& Ref2; + + SingleDoubleRefProvider( const formula::FormulaToken& r ) + : Ref1( *r.GetSingleRef() ), + Ref2( (r.GetType() == formula::svDoubleRef || + r.GetType() == formula::svExternalDoubleRef) ? + r.GetDoubleRef()->Ref2 : Ref1 ) + {} +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/tokenarray.hxx b/sc/inc/tokenarray.hxx new file mode 100644 index 0000000000..997aa0e9d8 --- /dev/null +++ b/sc/inc/tokenarray.hxx @@ -0,0 +1,276 @@ +/* -*- 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 <formula/token.hxx> +#include <rtl/ref.hxx> +#include "document.hxx" +#include "scdllapi.h" +#include "types.hxx" +#include "calcmacros.hxx" +#include "address.hxx" +#include "global.hxx" +#include <formula/tokenarray.hxx> + +namespace sc { + +struct RefUpdateContext; +struct RefUpdateInsertTabContext; +struct RefUpdateDeleteTabContext; +struct RefUpdateMoveTabContext; +struct RefUpdateResult; +struct TokenStringContext; +class ColRowReorderMapType; + +} + +struct ScRawToken; +struct ScSingleRefData; +struct ScComplexRefData; + +class SAL_WARN_UNUSED SC_DLLPUBLIC ScTokenArray final : public formula::FormulaTokenArray +{ + friend class ScCompiler; + + bool ImplGetReference( ScRange& rRange, const ScAddress& rPos, bool bValidOnly ) const; + + // hold a reference to the limits because sometimes our lifetime exceeds the lifetime of the associated ScDocument + rtl::Reference<ScSheetLimits> mxSheetLimits; + size_t mnHashValue; + ScFormulaVectorState meVectorState : 4; // Only 4 bits + bool mbOpenCLEnabled : 1; + bool mbThreadingEnabled : 1; + + void CheckForThreading( const formula::FormulaToken& r ); + +public: + ScTokenArray(const ScDocument& rDoc); + ScTokenArray(ScSheetLimits&); + /** Assignment with incrementing references of FormulaToken entries + (not copied!) */ + ScTokenArray( const ScTokenArray& ) = default; + ScTokenArray( ScTokenArray&& ) = default; + virtual ~ScTokenArray() override; + + bool EqualTokens( const ScTokenArray* pArr2 ) const; + + virtual void Clear() override; + std::unique_ptr<ScTokenArray> Clone() const; /// True copy! + ScTokenArray CloneValue() const; /// True copy! + + void GenHash(); + size_t GetHash() const { return mnHashValue;} + + ScFormulaVectorState GetVectorState() const { return meVectorState;} + void ResetVectorState(); + bool IsFormulaVectorDisabled() const; + + /** + * If the array contains at least one relative row reference or named + * expression, it's variant. Otherwise invariant. + */ + bool IsInvariant() const; + + /// Exactly and only one range (valid or deleted) + bool IsReference( ScRange& rRange, const ScAddress& rPos ) const; + /// Exactly and only one valid range (no #REF!s) + bool IsValidReference( ScRange& rRange, const ScAddress& rPos ) const; + + /** Determines the extent of direct adjacent + references. Only use with real functions, e.g. + GetOuterFuncOpCode() == ocSum ! */ + bool GetAdjacentExtendOfOuterFuncRefs( + SCCOLROW& nExtend, + const ScAddress& rPos, ScDirection ); + + formula::FormulaToken* AddRawToken( const ScRawToken& ); + virtual bool AddFormulaToken( + const css::sheet::FormulaToken& rToken, + svl::SharedStringPool& rSPool, + formula::ExternalReferenceHelper* _pRef) override; + virtual void CheckToken( const formula::FormulaToken& r ) override; + virtual formula::FormulaToken* AddOpCode( OpCode eCode ) override; + /** ScSingleRefToken with ocPush. */ + formula::FormulaToken* AddSingleReference( const ScSingleRefData& rRef ); + /** ScSingleRefOpToken with ocMatRef. */ + formula::FormulaToken* AddMatrixSingleReference( const ScSingleRefData& rRef ); + formula::FormulaToken* AddDoubleReference( const ScComplexRefData& rRef ); + void AddRangeName( sal_uInt16 n, sal_Int16 nSheet ); + formula::FormulaToken* AddDBRange( sal_uInt16 n ); + formula::FormulaToken* AddExternalName( sal_uInt16 nFileId, const svl::SharedString& rName ); + void AddExternalSingleReference( sal_uInt16 nFileId, const svl::SharedString& rTabName, const ScSingleRefData& rRef ); + formula::FormulaToken* AddExternalDoubleReference( sal_uInt16 nFileId, const svl::SharedString& rTabName, const ScComplexRefData& rRef ); + formula::FormulaToken* AddMatrix( const ScMatrixRef& p ); + /** ScSingleRefOpToken with ocColRowName. */ + formula::FormulaToken* AddColRowName( const ScSingleRefData& rRef ); + virtual formula::FormulaToken* MergeArray( ) override; + + /** Merge very last SingleRef+ocRange+SingleRef combination into DoubleRef + and adjust pCode array, or do nothing if conditions not met. */ + void MergeRangeReference( const ScAddress & rPos ); + + /// Assign XML string placeholder to the array + void AssignXMLString( const OUString &rText, const OUString &rFormulaNmsp ); + + /** Assignment with incrementing references of FormulaToken entries + (not copied!) */ + ScTokenArray& operator=( const ScTokenArray& ); + ScTokenArray& operator=( ScTokenArray&& ); + + /** + * Make all absolute references external references pointing to the old document + * + * @param rOldDoc old document + * @param rNewDoc new document + * @param rPos position of the cell to determine if the reference is in the copied area + * @param bRangeName set for range names, range names have special handling for absolute sheet ref + relative col/row ref + */ + void ReadjustAbsolute3DReferences( const ScDocument& rOldDoc, ScDocument& rNewDoc, const ScAddress& rPos, bool bRangeName = false ); + + /** + * Make all absolute references pointing to the copied range if the range is copied too + * @param bCheckCopyArea should reference pointing into the copy area be adjusted independently from being absolute, should be true only for copy&paste between documents + */ + void AdjustAbsoluteRefs( const ScDocument& rOldDoc, const ScAddress& rOldPos, const ScAddress& rNewPos, bool bCheckCopyArea ); + + /** When copying a sheet-local named expression, move sheet references that + point to the originating sheet to point to the new sheet instead. + */ + void AdjustSheetLocalNameReferences( SCTAB nOldTab, SCTAB nNewTab ); + + /** Returns true if the sheet nTab is referenced in code. Relative sheet + references are evaluated using nPosTab. + */ + bool ReferencesSheet( SCTAB nTab, SCTAB nPosTab ) const; + + /** + * Adjust all references in response to shifting of cells during cell + * insertion and deletion. + * + * @param rCxt context that stores details of shifted region. + * @param rOldPos old cell position prior to shifting. + */ + sc::RefUpdateResult AdjustReferenceOnShift( const sc::RefUpdateContext& rCxt, const ScAddress& rOldPos ); + + sc::RefUpdateResult AdjustReferenceOnMove( + const sc::RefUpdateContext& rCxt, const ScAddress& rOldPos, const ScAddress& rNewPos ); + + /** + * Move reference positions in response to column reordering. A range + * reference gets moved only when the whole range fits in a single column. + * + * @param rPos position of this formula cell + * @param nTab sheet where columns are reordered. + * @param nRow1 top row of reordered range. + * @param nRow2 bottom row of reordered range. + * @param rColMap old-to-new column mapping. + */ + void MoveReferenceColReorder( + const ScAddress& rPos, SCTAB nTab, SCROW nRow1, SCROW nRow2, + const sc::ColRowReorderMapType& rColMap ); + + void MoveReferenceRowReorder( + const ScAddress& rPos, SCTAB nTab, SCCOL nCol1, SCCOL nCol2, + const sc::ColRowReorderMapType& rRowMap ); + + /** + * Adjust all references in named expression. In named expression, we only + * update absolute positions, and leave relative positions intact. + * + * @param rCxt context that stores details of shifted region + * + * @return update result. + */ + sc::RefUpdateResult AdjustReferenceInName( const sc::RefUpdateContext& rCxt, const ScAddress& rPos ); + + sc::RefUpdateResult AdjustReferenceInMovedName( const sc::RefUpdateContext& rCxt, const ScAddress& rPos ); + + /** + * Adjust all references on sheet deletion. + * + * @param nDelPos position of sheet being deleted. + * @param nSheets number of sheets to delete. + * @param rOldPos position of formula cell prior to the deletion. + * + * @return true if at least one reference has changed its sheet reference. + */ + sc::RefUpdateResult AdjustReferenceOnDeletedTab( const sc::RefUpdateDeleteTabContext& rCxt, const ScAddress& rOldPos ); + + sc::RefUpdateResult AdjustReferenceOnInsertedTab( const sc::RefUpdateInsertTabContext& rCxt, const ScAddress& rOldPos ); + + sc::RefUpdateResult AdjustReferenceOnMovedTab( const sc::RefUpdateMoveTabContext& rCxt, const ScAddress& rOldPos ); + + /** + * Adjust all internal references on base position change. + */ + void AdjustReferenceOnMovedOrigin( const ScAddress& rOldPos, const ScAddress& rNewPos ); + + /** + * Adjust all internal references on base position change if they point to + * a sheet other than the one of rOldPos. + */ + void AdjustReferenceOnMovedOriginIfOtherSheet( const ScAddress& rOldPos, const ScAddress& rNewPos ); + + /** + * Adjust internal range references on base position change to justify / + * put in order the relative references. + */ + void AdjustReferenceOnCopy( const ScAddress& rNewPos ); + + /** + * Clear sheet deleted flag from internal reference tokens if the sheet + * index falls within specified range. Note that when a reference is on a + * sheet that's been deleted, its referenced sheet index retains the + * original index of the deleted sheet. + * + * @param rPos position of formula cell + * @param nStartTab index of first sheet, inclusive. + * @param nEndTab index of last sheet, inclusive. + */ + void ClearTabDeleted( const ScAddress& rPos, SCTAB nStartTab, SCTAB nEndTab ); + + void CheckRelativeReferenceBounds( + const sc::RefUpdateContext& rCxt, const ScAddress& rPos, SCROW nGroupLen, std::vector<SCROW>& rBounds ) const; + + void CheckRelativeReferenceBounds( + const ScAddress& rPos, SCROW nGroupLen, const ScRange& rRange, std::vector<SCROW>& rBounds ) const; + + void CheckExpandReferenceBounds( + const sc::RefUpdateContext& rCxt, const ScAddress& rPos, SCROW nGroupLen, std::vector<SCROW>& rBounds ) const; + + /** + * Create a string representation of formula token array without modifying + * the internal state of the token array. + */ + OUString CreateString( sc::TokenStringContext& rCxt, const ScAddress& rPos ) const; + + void WrapReference( const ScAddress& rPos, SCCOL nMaxCol, SCROW nMaxRow ); + + sal_Int32 GetWeight() const; + + bool IsEnabledForOpenCL() const { return mbOpenCLEnabled; } + bool IsEnabledForThreading() const { return mbThreadingEnabled; } + +#if DEBUG_FORMULA_COMPILER + void Dump() const; +#endif +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/tokenstringcontext.hxx b/sc/inc/tokenstringcontext.hxx new file mode 100644 index 0000000000..d6292e5dcb --- /dev/null +++ b/sc/inc/tokenstringcontext.hxx @@ -0,0 +1,69 @@ +/* -*- 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/. + */ + +#pragma once + +#include "compiler.hxx" + +#include <unordered_map> + +class ScDocument; + +namespace sc +{ +/** + * Context for creating string from an array of formula tokens, used in + * ScTokenArray::CreateString(). You can re-use the same string context + * between multiple CreateString() calls as long as the document content is + * unmodified. + */ +struct SC_DLLPUBLIC TokenStringContext +{ + typedef std::unordered_map<sal_uInt16, OUString> IndexNameMapType; + typedef std::unordered_map<size_t, std::vector<OUString>> IndexNamesMapType; + typedef std::unordered_map<SCTAB, IndexNameMapType> TabIndexMapType; + + formula::FormulaGrammar::Grammar meGram; + formula::FormulaCompiler::OpCodeMapPtr mxOpCodeMap; + const ScCompiler::Convention* mpRefConv; + OUString maErrRef; + + std::vector<OUString> maTabNames; + IndexNameMapType maGlobalRangeNames; + TabIndexMapType maSheetRangeNames; + IndexNameMapType maNamedDBs; + + std::vector<OUString> maExternalFileNames; + IndexNamesMapType maExternalCachedTabNames; + + TokenStringContext(const ScDocument& rDoc, formula::FormulaGrammar::Grammar eGram); +}; + +class SC_DLLPUBLIC CompileFormulaContext +{ + ScDocument& mrDoc; + formula::FormulaGrammar::Grammar meGram; + std::vector<OUString> maTabNames; + + void updateTabNames(); + +public: + CompileFormulaContext(ScDocument& rDoc); + CompileFormulaContext(ScDocument& rDoc, formula::FormulaGrammar::Grammar eGram); + + formula::FormulaGrammar::Grammar getGrammar() const { return meGram; } + void setGrammar(formula::FormulaGrammar::Grammar eGram); + + const std::vector<OUString>& getTabNames() const { return maTabNames; } + + ScDocument& getDoc() { return mrDoc; } +}; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/tokenuno.hxx b/sc/inc/tokenuno.hxx new file mode 100644 index 0000000000..d025ba0cf4 --- /dev/null +++ b/sc/inc/tokenuno.hxx @@ -0,0 +1,109 @@ +/* -*- 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 <memory> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/sheet/XFormulaParser.hpp> +#include <cppuhelper/implbase.hxx> +#include <svl/lstner.hxx> +#include <formula/FormulaOpCodeMapperObj.hxx> +#include "compiler.hxx" + +namespace com::sun::star::sheet { struct FormulaOpCodeMapEntry; } +namespace com::sun::star::sheet { struct FormulaToken; } + +class ScTokenArray; +class ScDocShell; + +class ScTokenConversion +{ +public: + static SC_DLLPUBLIC bool ConvertToTokenArray( + ScDocument& rDoc, + ScTokenArray& rTokenArray, + const css::uno::Sequence< css::sheet::FormulaToken >& rSequence ); + static SC_DLLPUBLIC void ConvertToTokenSequence( + const ScDocument& rDoc, + css::uno::Sequence< css::sheet::FormulaToken >& rSequence, + const ScTokenArray& rTokenArray ); +}; + +class ScFormulaParserObj final : public ::cppu::WeakImplHelper< + css::sheet::XFormulaParser, + css::beans::XPropertySet, + css::lang::XServiceInfo >, + public SfxListener +{ +private: + css::uno::Sequence< const css::sheet::FormulaOpCodeMapEntry > maOpCodeMapping; + css::uno::Sequence<css::sheet::ExternalLinkInfo> maExternalLinks; + ScCompiler::OpCodeMapPtr mxOpCodeMap; + ScDocShell* mpDocShell; + sal_Int16 mnConv; + bool mbEnglish; + bool mbIgnoreSpaces; + bool mbCompileFAP; + bool mbRefConventionChartOOXML; + + void SetCompilerFlags( ScCompiler& rCompiler ) const; + +public: + ScFormulaParserObj(ScDocShell* pDocSh); + virtual ~ScFormulaParserObj() override; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + // XFormulaParser + virtual css::uno::Sequence< css::sheet::FormulaToken > SAL_CALL parseFormula( + const OUString& aFormula, + const css::table::CellAddress& rReferencePos ) override; + virtual OUString SAL_CALL printFormula( const css::uno::Sequence< css::sheet::FormulaToken >& aTokens, + const css::table::CellAddress& rReferencePos ) override; + + // XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > + SAL_CALL getPropertySetInfo() override; + virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, + const css::uno::Any& aValue ) override; + virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override; + virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override; + virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override; + virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + + // XServiceInfo + 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; +}; + +class ScFormulaOpCodeMapperObj final : public formula::FormulaOpCodeMapperObj +{ +public: + ScFormulaOpCodeMapperObj(::std::unique_ptr<formula::FormulaCompiler> && _pCompiler); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/typedstrdata.hxx b/sc/inc/typedstrdata.hxx new file mode 100644 index 0000000000..b4a9bc5d37 --- /dev/null +++ b/sc/inc/typedstrdata.hxx @@ -0,0 +1,94 @@ +/* -*- 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/. + */ + +#pragma once + +#include <rtl/ustring.hxx> + +#include <set> + +class ScTypedStrData +{ +public: + enum StringType { + Value, + MRU, + Standard, + Name, + DbName, + Header + }; + + ScTypedStrData( + OUString&& rStr, double fVal = 0.0, double fRVal = 0.0, StringType nType = Standard, bool bDate = false, bool bIsHiddenByFilter = false ) : + maStrValue(std::move(rStr)), + mfValue(fVal), + mfRoundedValue(fRVal), + meStrType(nType), + mbIsDate( bDate ), + mbIsHiddenByFilter(bIsHiddenByFilter) {} + + ScTypedStrData( const OUString& rStr, double fVal = 0.0, double fRVal = 0.0, StringType eType = Standard, + bool bDate = false, bool bIsHiddenByFilter = false ); + + bool IsDate() const { return mbIsDate;} + bool IsHiddenByFilter() const { return mbIsHiddenByFilter;} + const OUString& GetString() const { return maStrValue;} + StringType GetStringType() const { return meStrType;} + double GetValue() const { return mfValue; } + double GetRoundedValue() const { return mfRoundedValue; } + + struct LessHiddenRows + { + bool operator() (const ScTypedStrData& left, const ScTypedStrData& right) const; + }; + + struct LessCaseSensitive + { + bool operator() (const ScTypedStrData& left, const ScTypedStrData& right) const; + }; + + struct LessCaseInsensitive + { + bool operator() (const ScTypedStrData& left, const ScTypedStrData& right) const; + }; + + struct EqualCaseSensitive + { + bool operator() (const ScTypedStrData& left, const ScTypedStrData& right) const; + }; + + struct EqualCaseInsensitive + { + bool operator() (const ScTypedStrData& left, const ScTypedStrData& right) const; + }; + + bool operator< (const ScTypedStrData& r) const; + +private: + OUString maStrValue; + double mfValue; + double mfRoundedValue; // rounded value by format code + StringType meStrType; + bool mbIsDate; + bool mbIsHiddenByFilter; +}; + +class FindTypedStrData +{ + ScTypedStrData maVal; + bool mbCaseSens; +public: + FindTypedStrData(ScTypedStrData aVal, bool bCaseSens); + bool operator() (const ScTypedStrData& r) const; +}; + +typedef std::set<ScTypedStrData, ScTypedStrData::LessCaseSensitive> ScTypedCaseStrSet; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/types.hxx b/sc/inc/types.hxx new file mode 100644 index 0000000000..e3a019da50 --- /dev/null +++ b/sc/inc/types.hxx @@ -0,0 +1,150 @@ +/* -*- 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/. + */ + +#pragma once + +#include <sal/types.h> + +#include <boost/intrusive_ptr.hpp> +#include <o3tl/typed_flags_set.hxx> + +class ScMatrix; + +// The typedefs +typedef sal_Int32 SCROW; +typedef sal_Int16 SCCOL; +typedef sal_Int16 SCTAB; +typedef sal_Int32 SCCOLROW; ///< a type capable of holding either SCCOL or SCROW + +typedef ::boost::intrusive_ptr<ScMatrix> ScMatrixRef; +typedef ::boost::intrusive_ptr<const ScMatrix> ScConstMatrixRef; + +namespace formula { class FormulaToken; } +typedef ::boost::intrusive_ptr<formula::FormulaToken> ScTokenRef; + +enum class ScMatValType : sal_uInt8 { + Value = 0x00, + Boolean = 0x01, + String = 0x02, + Empty = String | 0x04, // STRING plus flag + EmptyPath = Empty | 0x08, // EMPTY plus flag + NonvalueMask = EmptyPath // mask of all non-value bits +}; +namespace o3tl{ + template<> struct typed_flags<ScMatValType> : o3tl::is_typed_flags<ScMatValType, 0x0f> {}; +} + +struct ScFormulaCellGroup; +typedef ::boost::intrusive_ptr<ScFormulaCellGroup> ScFormulaCellGroupRef; + +/** + * When vectorization is enabled, we could potentially mass-calculate a + * series of formula token arrays in adjacent formula cells in one step, + * provided that they all contain identical set of tokens. + */ +enum ScFormulaVectorState +{ + FormulaVectorDisabled, + FormulaVectorDisabledNotInSubSet, + FormulaVectorDisabledByOpCode, + FormulaVectorDisabledByStackVariable, + + FormulaVectorEnabled, + FormulaVectorCheckReference, + FormulaVectorUnknown +}; + +namespace sc { + +enum class MatrixEdge{ + Nothing = 0, + Inside = 1, + Bottom = 2, + Left = 4, + Top = 8, + Right = 16, + Open = 32 +}; // typed_flags, template outside of sc namespace + +enum GroupCalcState +{ + GroupCalcDisabled = 0, + GroupCalcEnabled, + GroupCalcRunning, +}; + +struct RangeMatrix +{ + ScMatrixRef mpMat; + sal_Int32 mnCol1; + sal_Int32 mnRow1; + sal_Int32 mnTab1; + sal_Int32 mnCol2; + sal_Int32 mnRow2; + sal_Int32 mnTab2; + + RangeMatrix(); + + bool isRangeValid() const; +}; + +struct MultiDataCellState +{ + enum StateType : sal_uInt8 { Invalid = 0, Empty, HasOneCell, HasMultipleCells }; + + SCROW mnRow1; //< first non-empty row + SCCOL mnCol1; //< first non-empty column + StateType meState; + + MultiDataCellState(); + MultiDataCellState( StateType eState ); +}; + +enum class AreaOverlapType +{ + Inside, + InsideOrOverlap, + OneRowInside, + OneColumnInside +}; + +enum class ListenerGroupType +{ + Group, + Both +}; + +enum StartListeningType +{ + ConvertToGroupListening, + SingleCellListening, + NoListening +}; + +} + +namespace o3tl{ + template<> struct typed_flags<sc::MatrixEdge> : o3tl::is_typed_flags<sc::MatrixEdge, 63> {}; +} + +// Type of query done by ScQueryCellIteratorBase. +enum class ScQueryCellIteratorType +{ + Generic, + CountIf +}; + +// Type of cell access done by ScQueryCellIteratorBase. +enum class ScQueryCellIteratorAccess +{ + Direct, // Accessing directly cells. + SortedCache // Using ScSortedRangeCache. +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/undorangename.hxx b/sc/inc/undorangename.hxx new file mode 100644 index 0000000000..cbe1a2a1e5 --- /dev/null +++ b/sc/inc/undorangename.hxx @@ -0,0 +1,63 @@ +/* -*- 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/. + */ + +#pragma once + +#include <undobase.hxx> + +#include <memory> +#include <map> + +class ScDocShell; + +/** + * Undo object for named ranges, both in global and sheet-local scopes. + */ +class ScUndoAllRangeNames final : public ScSimpleUndo +{ +public: + ScUndoAllRangeNames(ScDocShell* pDocSh, const std::map<OUString, ScRangeName*>& rOldNames, + const std::map<OUString, ScRangeName>& rNewNames); + + virtual ~ScUndoAllRangeNames() override; + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + virtual OUString GetComment() const override; + +private: + void DoChange(const std::map<OUString, ScRangeName>& rNames); + +private: + std::map<OUString, ScRangeName> m_OldNames; + std::map<OUString, ScRangeName> m_NewNames; +}; + +class ScUndoAddRangeData final : public ScSimpleUndo +{ +public: + // nTab = -1 for global range names + ScUndoAddRangeData(ScDocShell* pDocSh, const ScRangeData* pRangeData, SCTAB nTab); + + virtual ~ScUndoAddRangeData() override; + + virtual void Undo() override; + virtual void Redo() override; + virtual void Repeat(SfxRepeatTarget& rTarget) override; + virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override; + virtual OUString GetComment() const override; + +private: + std::unique_ptr<ScRangeData> mpRangeData; + SCTAB mnTab; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/unitconv.hxx b/sc/inc/unitconv.hxx new file mode 100644 index 0000000000..3d0f98d351 --- /dev/null +++ b/sc/inc/unitconv.hxx @@ -0,0 +1,57 @@ +/* -*- 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 <rtl/ustring.hxx> + +#include <map> +#include <string_view> + +class ScUnitConverterData +{ + OUString maIndexString; + double mfValue; + +public: + ScUnitConverterData(std::u16string_view rFromUnit, std::u16string_view rToUnit, double fValue); + ScUnitConverterData(const ScUnitConverterData&) = default; + ScUnitConverterData& operator=(const ScUnitConverterData&) = delete; + + double GetValue() const { return mfValue; } + const OUString& GetIndexString() const { return maIndexString; } + + static OUString BuildIndexString(std::u16string_view rFromUnit, std::u16string_view rToUnit); +}; + +class ScUnitConverter +{ + typedef std::map<OUString, ScUnitConverterData> MapType; + MapType maData; + +public: + ScUnitConverter(); + ScUnitConverter(const ScUnitConverter&) = delete; + const ScUnitConverter& operator=(const ScUnitConverter&) = delete; + ~ScUnitConverter(); + + bool GetValue(double& fValue, std::u16string_view rFromUnit, std::u16string_view rToUnit) const; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/units.hrc b/sc/inc/units.hrc new file mode 100644 index 0000000000..6993f370bd --- /dev/null +++ b/sc/inc/units.hrc @@ -0,0 +1,43 @@ +/* -*- 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 <unotools/resmgr.hxx> + +#define NC_(Context, String) TranslateId(Context, u8##String) + +#include <tools/fldunit.hxx> + +#include <utility> + +const std::pair<TranslateId, FieldUnit> SCSTR_UNIT[] = +{ + { NC_("SCSTR_UNIT", "Millimeter") , FieldUnit::MM }, + { NC_("SCSTR_UNIT", "Centimeter") , FieldUnit::CM }, + { NC_("SCSTR_UNIT", "Meter") , FieldUnit::M }, + { NC_("SCSTR_UNIT", "Kilometer") , FieldUnit::KM }, + { NC_("SCSTR_UNIT", "Inch") , FieldUnit::INCH }, + { NC_("SCSTR_UNIT", "Foot") , FieldUnit::FOOT }, + { NC_("SCSTR_UNIT", "Miles") , FieldUnit::MILE }, + { NC_("SCSTR_UNIT", "Pica") , FieldUnit::PICA }, + { NC_("SCSTR_UNIT", "Point") , FieldUnit::POINT } +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/unonames.hxx b/sc/inc/unonames.hxx new file mode 100644 index 0000000000..5bc0fb2752 --- /dev/null +++ b/sc/inc/unonames.hxx @@ -0,0 +1,723 @@ +/* -*- 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 <rtl/ustring.hxx> + +// service names +inline constexpr OUString SC_SERVICENAME_VALBIND = u"com.sun.star.table.CellValueBinding"_ustr; +inline constexpr OUString SC_SERVICENAME_LISTCELLBIND = u"com.sun.star.table.ListPositionCellBinding"_ustr; +inline constexpr OUString SC_SERVICENAME_LISTSOURCE = u"com.sun.star.table.CellRangeListSource"_ustr; +inline constexpr OUString SC_SERVICENAME_CELLADDRESS = u"com.sun.star.table.CellAddressConversion"_ustr; +inline constexpr OUString SC_SERVICENAME_RANGEADDRESS = u"com.sun.star.table.CellRangeAddressConversion"_ustr; + +inline constexpr OUString SC_SERVICENAME_FORMULAPARS = u"com.sun.star.sheet.FormulaParser"_ustr; +inline constexpr OUString SC_SERVICENAME_OPCODEMAPPER = u"com.sun.star.sheet.FormulaOpCodeMapper"_ustr; + +inline constexpr OUString SC_SERVICENAME_CHDATAPROV = u"com.sun.star.chart2.data.DataProvider"_ustr; +inline constexpr OUString SC_SERVICENAME_CHRANGEHILIGHT = u"com.sun.star.chart2.data.RangeHighlightListener"_ustr; +inline constexpr OUString SC_SERVICENAME_CHART_PIVOTTABLE_DATAPROVIDER = u"com.sun.star.chart2.data.PivotTableDataProvider"_ustr; + +// document +inline constexpr OUString SC_UNO_AREALINKS = u"AreaLinks"_ustr; +inline constexpr OUString SC_UNO_DDELINKS = u"DDELinks"_ustr; +inline constexpr OUString SC_UNO_EXTERNALDOCLINKS = u"ExternalDocLinks"_ustr; +inline constexpr OUString SC_UNO_COLLABELRNG = u"ColumnLabelRanges"_ustr; +inline constexpr OUString SC_UNO_DATABASERNG = u"DatabaseRanges"_ustr; +inline constexpr OUString SC_UNO_UNNAMEDDBRNG = u"UnnamedDatabaseRanges"_ustr; +inline constexpr OUString SC_UNO_NAMEDRANGES = u"NamedRanges"_ustr; +inline constexpr OUString SC_UNO_ROWLABELRNG = u"RowLabelRanges"_ustr; +inline constexpr OUString SC_UNO_SHEETLINKS = u"SheetLinks"_ustr; +inline constexpr OUString SC_UNO_FORBIDDEN = u"ForbiddenCharacters"_ustr; +inline constexpr OUString SC_UNO_HASDRAWPAGES = u"HasDrawPages"_ustr; +inline constexpr OUString SC_UNO_THEME = u"Theme"_ustr; + +// CharacterProperties +inline constexpr OUString SC_UNONAME_CCOLOR = u"CharColor"_ustr; +inline constexpr OUString SC_UNONAME_CHAR_COMPLEX_COLOR = u"CharComplexColor"_ustr; +inline constexpr OUString SC_UNONAME_CHEIGHT = u"CharHeight"_ustr; +inline constexpr OUString SC_UNONAME_CUNDER = u"CharUnderline"_ustr; +inline constexpr OUString SC_UNONAME_CUNDLCOL = u"CharUnderlineColor"_ustr; +inline constexpr OUString SC_UNONAME_CUNDLHAS = u"CharUnderlineHasColor"_ustr; +inline constexpr OUString SC_UNONAME_COVER = u"CharOverline"_ustr; +inline constexpr OUString SC_UNONAME_COVRLCOL = u"CharOverlineColor"_ustr; +inline constexpr OUString SC_UNONAME_COVRLHAS = u"CharOverlineHasColor"_ustr; +inline constexpr OUString SC_UNONAME_CWEIGHT = u"CharWeight"_ustr; +inline constexpr OUString SC_UNONAME_CPOST = u"CharPosture"_ustr; +inline constexpr OUString SC_UNONAME_CCROSS = u"CharCrossedOut"_ustr; +inline constexpr OUString SC_UNONAME_CSTRIKE = u"CharStrikeout"_ustr; +inline constexpr OUString SC_UNONAME_CLOCAL = u"CharLocale"_ustr; +inline constexpr OUString SC_UNONAME_CSHADD = u"CharShadowed"_ustr; +inline constexpr OUString SC_UNONAME_CFONT = u"CharFont"_ustr; +inline constexpr OUString SC_UNONAME_COUTL = u"CharContoured"_ustr; +inline constexpr OUString SC_UNONAME_CEMPHAS = u"CharEmphasis"_ustr; +inline constexpr OUString SC_UNONAME_CFNAME = u"CharFontName"_ustr; +inline constexpr OUString SC_UNONAME_CFSTYLE = u"CharFontStyleName"_ustr; +inline constexpr OUString SC_UNONAME_CFFAMIL = u"CharFontFamily"_ustr; +inline constexpr OUString SC_UNONAME_CFCHARS = u"CharFontCharSet"_ustr; +inline constexpr OUString SC_UNONAME_CFPITCH = u"CharFontPitch"_ustr; +inline constexpr OUString SC_UNONAME_CRELIEF = u"CharRelief"_ustr; +inline constexpr OUString SC_UNONAME_CWORDMOD = u"CharWordMode"_ustr; + +inline constexpr OUString SC_UNO_CJK_CFNAME = u"CharFontNameAsian"_ustr; +inline constexpr OUString SC_UNO_CJK_CFSTYLE = u"CharFontStyleNameAsian"_ustr; +inline constexpr OUString SC_UNO_CJK_CFFAMIL = u"CharFontFamilyAsian"_ustr; +inline constexpr OUString SC_UNO_CJK_CFCHARS = u"CharFontCharSetAsian"_ustr; +inline constexpr OUString SC_UNO_CJK_CFPITCH = u"CharFontPitchAsian"_ustr; +inline constexpr OUString SC_UNO_CJK_CHEIGHT = u"CharHeightAsian"_ustr; +inline constexpr OUString SC_UNO_CJK_CWEIGHT = u"CharWeightAsian"_ustr; +inline constexpr OUString SC_UNO_CJK_CPOST = u"CharPostureAsian"_ustr; +inline constexpr OUString SC_UNO_CJK_CLOCAL = u"CharLocaleAsian"_ustr; + +inline constexpr OUString SC_UNO_CTL_CFNAME = u"CharFontNameComplex"_ustr; +inline constexpr OUString SC_UNO_CTL_CFSTYLE = u"CharFontStyleNameComplex"_ustr; +inline constexpr OUString SC_UNO_CTL_CFFAMIL = u"CharFontFamilyComplex"_ustr; +inline constexpr OUString SC_UNO_CTL_CFCHARS = u"CharFontCharSetComplex"_ustr; +inline constexpr OUString SC_UNO_CTL_CFPITCH = u"CharFontPitchComplex"_ustr; +inline constexpr OUString SC_UNO_CTL_CHEIGHT = u"CharHeightComplex"_ustr; +inline constexpr OUString SC_UNO_CTL_CWEIGHT = u"CharWeightComplex"_ustr; +inline constexpr OUString SC_UNO_CTL_CPOST = u"CharPostureComplex"_ustr; +inline constexpr OUString SC_UNO_CTL_CLOCAL = u"CharLocaleComplex"_ustr; + +// CellProperties +inline constexpr OUString SC_UNONAME_CELLSTYL = u"CellStyle"_ustr; +inline constexpr OUString SC_UNONAME_CELLBACK = u"CellBackColor"_ustr; +inline constexpr OUString SC_UNONAME_CELL_BACKGROUND_COMPLEX_COLOR = u"CellBackgroundComplexColor"_ustr; +inline constexpr OUString SC_UNONAME_CELLTRAN = u"IsCellBackgroundTransparent"_ustr; +inline constexpr OUString SC_UNONAME_CELLPRO = u"CellProtection"_ustr; +inline constexpr OUString SC_UNONAME_CELLHJUS = u"HoriJustify"_ustr; +inline constexpr OUString SC_UNONAME_CELLVJUS = u"VertJustify"_ustr; +inline constexpr OUString SC_UNONAME_CELLHJUS_METHOD = u"HoriJustifyMethod"_ustr; +inline constexpr OUString SC_UNONAME_CELLVJUS_METHOD = u"VertJustifyMethod"_ustr; +inline constexpr OUString SC_UNONAME_CELLORI = u"Orientation"_ustr; +inline constexpr OUString SC_UNONAME_NUMFMT = u"NumberFormat"_ustr; +inline constexpr OUString SC_UNONAME_FORMATID = u"FormatID"_ustr; +inline constexpr OUString SC_UNONAME_SHADOW = u"ShadowFormat"_ustr; +inline constexpr OUString SC_UNONAME_TBLBORD = u"TableBorder"_ustr; +inline constexpr OUString SC_UNONAME_TBLBORD2 = u"TableBorder2"_ustr; +inline constexpr OUString SC_UNONAME_WRAP = u"IsTextWrapped"_ustr; +inline constexpr OUString SC_UNONAME_PINDENT = u"ParaIndent"_ustr; +inline constexpr OUString SC_UNONAME_PTMARGIN = u"ParaTopMargin"_ustr; +inline constexpr OUString SC_UNONAME_PBMARGIN = u"ParaBottomMargin"_ustr; +inline constexpr OUString SC_UNONAME_PLMARGIN = u"ParaLeftMargin"_ustr; +inline constexpr OUString SC_UNONAME_PRMARGIN = u"ParaRightMargin"_ustr; +inline constexpr OUString SC_UNONAME_ROTANG = u"RotateAngle"_ustr; +inline constexpr OUString SC_UNONAME_ROTREF = u"RotateReference"_ustr; +inline constexpr OUString SC_UNONAME_ASIANVERT = u"AsianVerticalMode"_ustr; +inline constexpr OUString SC_UNONAME_WRITING = u"WritingMode"_ustr; +inline constexpr OUString SC_UNONAME_HIDDEN = u"Hidden"_ustr; + +inline constexpr OUString SC_UNONAME_BOTTBORDER = u"BottomBorder"_ustr; +inline constexpr OUString SC_UNONAME_LEFTBORDER = u"LeftBorder"_ustr; +inline constexpr OUString SC_UNONAME_RIGHTBORDER = u"RightBorder"_ustr; +inline constexpr OUString SC_UNONAME_TOPBORDER = u"TopBorder"_ustr; + +inline constexpr OUString SC_UNONAME_BOTTBORDER2 = u"BottomBorder2"_ustr; +inline constexpr OUString SC_UNONAME_LEFTBORDER2 = u"LeftBorder2"_ustr; +inline constexpr OUString SC_UNONAME_RIGHTBORDER2 = u"RightBorder2"_ustr; +inline constexpr OUString SC_UNONAME_TOPBORDER2 = u"TopBorder2"_ustr; + +inline constexpr OUString SC_UNONAME_BOTTOM_BORDER_COMPLEX_COLOR = u"BottomBorderComplexColor"_ustr; +inline constexpr OUString SC_UNONAME_LEFT_BORDER_COMPLEX_COLOR = u"LeftBorderComplexColor"_ustr; +inline constexpr OUString SC_UNONAME_RIGHT_BORDER_COMPLEX_COLOR = u"RightBorderComplexColor"_ustr; +inline constexpr OUString SC_UNONAME_TOP_BORDER_COMPLEX_COLOR = u"TopBorderComplexColor"_ustr; + +inline constexpr OUString SC_UNONAME_DIAGONAL_TLBR = u"DiagonalTLBR"_ustr; +inline constexpr OUString SC_UNONAME_DIAGONAL_BLTR = u"DiagonalBLTR"_ustr; + +inline constexpr OUString SC_UNONAME_DIAGONAL_TLBR2 = u"DiagonalTLBR2"_ustr; +inline constexpr OUString SC_UNONAME_DIAGONAL_BLTR2 = u"DiagonalBLTR2"_ustr; + +inline constexpr OUString SC_UNONAME_SHRINK_TO_FIT = u"ShrinkToFit"_ustr; + +inline constexpr OUString SC_UNONAME_PISHANG = u"ParaIsHangingPunctuation"_ustr; +inline constexpr OUString SC_UNONAME_PISCHDIST = u"ParaIsCharacterDistance"_ustr; +inline constexpr OUString SC_UNONAME_PISFORBID = u"ParaIsForbiddenRules"_ustr; +inline constexpr OUString SC_UNONAME_PISHYPHEN = u"ParaIsHyphenation"_ustr; +inline constexpr OUString SC_UNONAME_PADJUST = u"ParaAdjust"_ustr; +inline constexpr OUString SC_UNONAME_PLASTADJ = u"ParaLastLineAdjust"_ustr; + +inline constexpr OUString SC_UNONAME_NUMRULES = u"NumberingRules"_ustr; + +// Styles +inline constexpr OUString SC_UNONAME_DISPNAME = u"DisplayName"_ustr; + +// XStyleLoader +inline constexpr OUString SC_UNONAME_OVERWSTL = u"OverwriteStyles"_ustr; +inline constexpr OUString SC_UNONAME_LOADCELL = u"LoadCellStyles"_ustr; +inline constexpr OUString SC_UNONAME_LOADPAGE = u"LoadPageStyles"_ustr; + +// SheetCellRange +inline constexpr OUString SC_UNONAME_POS = u"Position"_ustr; +inline constexpr OUString SC_UNONAME_SIZE = u"Size"_ustr; +inline constexpr OUString SC_UNONAME_ABSNAME = u"AbsoluteName"_ustr; + +// column/row/sheet +inline constexpr OUString SC_UNONAME_CELLHGT = u"Height"_ustr; +inline constexpr OUString SC_UNONAME_CELLWID = u"Width"_ustr; +inline constexpr OUString SC_UNONAME_CELLVIS = u"IsVisible"_ustr; +inline constexpr OUString SC_UNONAME_CELLFILT = u"IsFiltered"_ustr; +inline constexpr OUString SC_UNONAME_MANPAGE = u"IsManualPageBreak"_ustr; +inline constexpr OUString SC_UNONAME_NEWPAGE = u"IsStartOfNewPage"_ustr; +inline constexpr OUString SC_UNONAME_OHEIGHT = u"OptimalHeight"_ustr; +inline constexpr OUString SC_UNONAME_OWIDTH = u"OptimalWidth"_ustr; +inline constexpr OUString SC_UNONAME_PAGESTL = u"PageStyle"_ustr; +inline constexpr OUString SC_UNONAME_ISACTIVE = u"IsActive"_ustr; +inline constexpr OUString SC_UNONAME_BORDCOL = u"BorderColor"_ustr; +inline constexpr OUString SC_UNONAME_PROTECT = u"Protected"_ustr; +inline constexpr OUString SC_UNONAME_SHOWBORD = u"ShowBorder"_ustr; +inline constexpr OUString SC_UNONAME_PRINTBORD = u"PrintBorder"_ustr; +inline constexpr OUString SC_UNONAME_COPYBACK = u"CopyBack"_ustr; +inline constexpr OUString SC_UNONAME_COPYSTYL = u"CopyStyles"_ustr; +inline constexpr OUString SC_UNONAME_COPYFORM = u"CopyFormulas"_ustr; +inline constexpr OUString SC_UNONAME_TABLAYOUT = u"TableLayout"_ustr; +inline constexpr OUString SC_UNONAME_AUTOPRINT = u"AutomaticPrintArea"_ustr; +inline constexpr OUString SC_UNONAME_TABCOLOR = u"TabColor"_ustr; +inline constexpr OUString SC_UNONAME_CONDFORMAT = u"ConditionalFormats"_ustr; + +inline constexpr OUString SC_UNONAME_VISFLAG = u"VisibleFlag"_ustr; + +// LinkTarget +inline constexpr OUString SC_UNO_LINKDISPBIT = u"LinkDisplayBitmap"_ustr; +inline constexpr OUString SC_UNO_LINKDISPNAME = u"LinkDisplayName"_ustr; + +// drawing objects +inline constexpr OUString SC_UNONAME_IMAGEMAP = u"ImageMap"_ustr; +inline constexpr OUString SC_UNONAME_ANCHOR = u"Anchor"_ustr; +inline constexpr OUString SC_UNONAME_RESIZE_WITH_CELL = u"ResizeWithCell"_ustr; +inline constexpr OUString SC_UNONAME_HORIPOS = u"HoriOrientPosition"_ustr; +inline constexpr OUString SC_UNONAME_VERTPOS = u"VertOrientPosition"_ustr; +inline constexpr OUString SC_UNONAME_HYPERLINK = u"Hyperlink"_ustr; +inline constexpr OUString SC_UNONAME_MOVEPROTECT = u"MoveProtect"_ustr; +inline constexpr OUString SC_UNONAME_STYLE = u"Style"_ustr; + +// other cell properties +inline constexpr OUString SC_UNONAME_CHCOLHDR = u"ChartColumnAsLabel"_ustr; +inline constexpr OUString SC_UNONAME_CHROWHDR = u"ChartRowAsLabel"_ustr; +inline constexpr OUString SC_UNONAME_CONDFMT = u"ConditionalFormat"_ustr; +inline constexpr OUString SC_UNONAME_CONDLOC = u"ConditionalFormatLocal"_ustr; +inline constexpr OUString SC_UNONAME_CONDXML = u"ConditionalFormatXML"_ustr; +inline constexpr OUString SC_UNONAME_VALIDAT = u"Validation"_ustr; +inline constexpr OUString SC_UNONAME_VALILOC = u"ValidationLocal"_ustr; +inline constexpr OUString SC_UNONAME_VALIXML = u"ValidationXML"_ustr; +inline constexpr OUString SC_UNONAME_FORMLOC = u"FormulaLocal"_ustr; +inline constexpr OUString SC_UNONAME_FORMRT = u"FormulaResultType"_ustr; +inline constexpr OUString SC_UNONAME_FORMRT2 = u"FormulaResultType2"_ustr; +inline constexpr OUString SC_UNONAME_CELLCONTENTTYPE = u"CellContentType"_ustr; + +inline constexpr OUString SC_UNONAME_USERDEF = u"UserDefinedAttributes"_ustr; +inline constexpr OUString SC_UNONAME_TEXTUSER = u"TextUserDefinedAttributes"_ustr; + +// auto format +inline constexpr OUString SC_UNONAME_INCBACK = u"IncludeBackground"_ustr; +inline constexpr OUString SC_UNONAME_INCBORD = u"IncludeBorder"_ustr; +inline constexpr OUString SC_UNONAME_INCFONT = u"IncludeFont"_ustr; +inline constexpr OUString SC_UNONAME_INCJUST = u"IncludeJustify"_ustr; +inline constexpr OUString SC_UNONAME_INCNUM = u"IncludeNumberFormat"_ustr; +inline constexpr OUString SC_UNONAME_INCWIDTH = u"IncludeWidthAndHeight"_ustr; + +// function description +inline constexpr OUString SC_UNONAME_ARGUMENTS = u"Arguments"_ustr; +inline constexpr OUString SC_UNONAME_CATEGORY = u"Category"_ustr; +inline constexpr OUString SC_UNONAME_DESCRIPTION = u"Description"_ustr; +inline constexpr OUString SC_UNONAME_ID = u"Id"_ustr; +inline constexpr OUString SC_UNONAME_NAME = u"Name"_ustr; + +// application settings +inline constexpr OUString SC_UNONAME_DOAUTOCP = u"DoAutoComplete"_ustr; +inline constexpr OUString SC_UNONAME_ENTERED = u"EnterEdit"_ustr; +inline constexpr OUString SC_UNONAME_EXPREF = u"ExpandReferences"_ustr; +inline constexpr OUString SC_UNONAME_EXTFMT = u"ExtendFormat"_ustr; +inline constexpr OUString SC_UNONAME_LINKUPD = u"LinkUpdateMode"_ustr; +inline constexpr OUString SC_UNONAME_MARKHDR = u"MarkHeader"_ustr; +inline constexpr OUString SC_UNONAME_METRIC = u"Metric"_ustr; +inline constexpr OUString SC_UNONAME_MOVEDIR = u"MoveDirection"_ustr; +inline constexpr OUString SC_UNONAME_MOVESEL = u"MoveSelection"_ustr; +inline constexpr OUString SC_UNONAME_RANGEFIN = u"RangeFinder"_ustr; +inline constexpr OUString SC_UNONAME_SCALE = u"Scale"_ustr; +inline constexpr OUString SC_UNONAME_STBFUNC = u"StatusBarFunction"_ustr; +inline constexpr OUString SC_UNONAME_ULISTS = u"UserLists"_ustr; +inline constexpr OUString SC_UNONAME_USETABCOL = u"UseTabCol"_ustr; +inline constexpr OUString SC_UNONAME_PRMETRICS = u"UsePrinterMetrics"_ustr; +inline constexpr OUString SC_UNONAME_PRALLSH = u"PrintAllSheets"_ustr; +inline constexpr OUString SC_UNONAME_PREMPTY = u"PrintEmptyPages"_ustr; +inline constexpr OUString SC_UNONAME_REPLWARN = u"ReplaceCellsWarning"_ustr; + +// data pilot field +inline constexpr OUString SC_UNONAME_FUNCTION = u"Function"_ustr; +inline constexpr OUString SC_UNONAME_FUNCTION2 = u"Function2"_ustr; +inline constexpr OUString SC_UNONAME_SUBTOTALS = u"Subtotals"_ustr; +inline constexpr OUString SC_UNONAME_SUBTOTALS2 = u"Subtotals2"_ustr; +inline constexpr OUString SC_UNONAME_SELPAGE = u"SelectedPage"_ustr; +inline constexpr OUString SC_UNONAME_USESELPAGE = u"UseSelectedPage"_ustr; +inline constexpr OUString SC_UNONAME_HASREFERENCE = u"HasReference"_ustr; +inline constexpr OUString SC_UNONAME_REFERENCE = u"Reference"_ustr; +inline constexpr OUString SC_UNONAME_HASAUTOSHOW = u"HasAutoShowInfo"_ustr; +inline constexpr OUString SC_UNONAME_AUTOSHOW = u"AutoShowInfo"_ustr; +inline constexpr OUString SC_UNONAME_HASSORTINFO = u"HasSortInfo"_ustr; +inline constexpr OUString SC_UNONAME_SORTINFO = u"SortInfo"_ustr; +inline constexpr OUString SC_UNONAME_HASLAYOUTINFO = u"HasLayoutInfo"_ustr; +inline constexpr OUString SC_UNONAME_LAYOUTINFO = u"LayoutInfo"_ustr; +inline constexpr OUString SC_UNONAME_ISGROUP = u"IsGroupField"_ustr; +inline constexpr OUString SC_UNONAME_GROUPINFO = u"GroupInfo"_ustr; +inline constexpr OUString SC_UNONAME_SHOWEMPTY = u"ShowEmpty"_ustr; +inline constexpr OUString SC_UNONAME_REPEATITEMLABELS = u"RepeatItemLabels"_ustr; + +// data pilot item +inline constexpr OUString SC_UNONAME_SHOWDETAIL = u"ShowDetail"_ustr; +inline constexpr OUString SC_UNONAME_ISHIDDEN = u"IsHidden"_ustr; + +// database options +inline constexpr OUString SC_UNONAME_CASE = u"CaseSensitive"_ustr; +inline constexpr OUString SC_UNONAME_DBNAME = u"DatabaseName"_ustr; +inline constexpr OUString SC_UNONAME_FORMATS = u"IncludeFormats"_ustr; +inline constexpr OUString SC_UNONAME_INSBRK = u"InsertPageBreaks"_ustr; +inline constexpr OUString SC_UNONAME_KEEPFORM = u"KeepFormats"_ustr; +inline constexpr OUString SC_UNONAME_MOVCELLS = u"MoveCells"_ustr; +inline constexpr OUString SC_UNONAME_ISUSER = u"IsUserDefined"_ustr; +inline constexpr OUString SC_UNONAME_ISNATIVE = u"IsNative"_ustr; +inline constexpr OUString SC_UNONAME_REGEXP = u"RegularExpressions"_ustr; +inline constexpr OUString SC_UNONAME_WILDCARDS = u"Wildcards"_ustr; +inline constexpr OUString SC_UNONAME_SAVEOUT = u"SaveOutputPosition"_ustr; +inline constexpr OUString SC_UNONAME_SKIPDUP = u"SkipDuplicates"_ustr; +inline constexpr OUString SC_UNONAME_SRCOBJ = u"SourceObject"_ustr; +inline constexpr OUString SC_UNONAME_SRCTYPE = u"SourceType"_ustr; +inline constexpr OUString SC_UNONAME_STRIPDAT = u"StripData"_ustr; +inline constexpr OUString SC_UNONAME_USEREGEX = u"UseRegularExpressions"_ustr; +inline constexpr OUString SC_UNONAME_ULIST = u"UserListEnabled"_ustr; +inline constexpr OUString SC_UNONAME_UINDEX = u"UserListIndex"_ustr; +inline constexpr OUString SC_UNONAME_BINDFMT = u"BindFormatsToContent"_ustr; +inline constexpr OUString SC_UNONAME_COPYOUT = u"CopyOutputData"_ustr; +inline constexpr OUString SC_UNONAME_ISCASE = u"IsCaseSensitive"_ustr; +inline constexpr OUString SC_UNONAME_ISULIST = u"IsUserListEnabled"_ustr; +inline constexpr OUString SC_UNONAME_OUTPOS = u"OutputPosition"_ustr; +inline constexpr OUString SC_UNONAME_CONTHDR = u"ContainsHeader"_ustr; +inline constexpr OUString SC_UNONAME_MAXFLD = u"MaxFieldCount"_ustr; +inline constexpr OUString SC_UNONAME_ORIENT = u"Orientation"_ustr; +inline constexpr OUString SC_UNONAME_ISSORTCOLUMNS = u"IsSortColumns"_ustr; +inline constexpr OUString SC_UNONAME_SORTFLD = u"SortFields"_ustr; +inline constexpr OUString SC_UNONAME_SORTASC = u"SortAscending"_ustr; +inline constexpr OUString SC_UNONAME_ENUSLIST = u"EnableUserSortList"_ustr; +inline constexpr OUString SC_UNONAME_USINDEX = u"UserSortListIndex"_ustr; +inline constexpr OUString SC_UNONAME_COLLLOC = u"CollatorLocale"_ustr; +inline constexpr OUString SC_UNONAME_COLLALG = u"CollatorAlgorithm"_ustr; +inline constexpr OUString SC_UNONAME_AUTOFLT = u"AutoFilter"_ustr; +inline constexpr OUString SC_UNONAME_FLTCRT = u"FilterCriteriaSource"_ustr; +inline constexpr OUString SC_UNONAME_USEFLTCRT = u"UseFilterCriteriaSource"_ustr; +inline constexpr OUString SC_UNONAME_ENABSORT = u"EnableSort"_ustr; +inline constexpr OUString SC_UNONAME_FROMSELECT = u"FromSelection"_ustr; +inline constexpr OUString SC_UNONAME_CONRES = u"ConnectionResource"_ustr; +inline constexpr OUString SC_UNONAME_TOKENINDEX = u"TokenIndex"_ustr; +inline constexpr OUString SC_UNONAME_ISSHAREDFMLA = u"IsSharedFormula"_ustr; +inline constexpr OUString SC_UNONAME_TOTALSROW = u"TotalsRow"_ustr; + +// text fields +inline constexpr OUString SC_UNONAME_ANCTYPE = u"AnchorType"_ustr; +inline constexpr OUString SC_UNONAME_ANCTYPES = u"AnchorTypes"_ustr; +inline constexpr OUString SC_UNONAME_TEXTWRAP = u"TextWrap"_ustr; +inline constexpr OUString SC_UNONAME_FILEFORM = u"FileFormat"_ustr; +inline constexpr OUString SC_UNONAME_TEXTFIELD_TYPE = u"TextFieldType"_ustr; + +// url field +inline constexpr OUString SC_UNONAME_REPR = u"Representation"_ustr; +inline constexpr OUString SC_UNONAME_TARGET = u"TargetFrame"_ustr; +inline constexpr OUString SC_UNONAME_URL = u"URL"_ustr; + +// date time field +inline constexpr OUString SC_UNONAME_ISDATE = u"IsDate"_ustr; +inline constexpr OUString SC_UNONAME_ISFIXED = u"IsFixed"_ustr; +inline constexpr OUString SC_UNONAME_DATETIME = u"DateTime"_ustr; + +// table field +inline constexpr OUString SC_UNONAME_TABLEPOS = u"TablePosition"_ustr; + +// conditional format +inline constexpr OUString SC_UNONAME_OPERATOR = u"Operator"_ustr; +inline constexpr OUString SC_UNONAME_FORMULA1 = u"Formula1"_ustr; +inline constexpr OUString SC_UNONAME_FORMULA2 = u"Formula2"_ustr; +inline constexpr OUString SC_UNONAME_SOURCEPOS = u"SourcePosition"_ustr; +inline constexpr OUString SC_UNONAME_SOURCESTR = u"SourcePositionAsString"_ustr; // only for use in XML filter +inline constexpr OUString SC_UNONAME_FORMULANMSP1 = u"FormulaNamespace1"_ustr; // only for use in XML filter +inline constexpr OUString SC_UNONAME_FORMULANMSP2 = u"FormulaNamespace2"_ustr; // only for use in XML filter +inline constexpr OUString SC_UNONAME_GRAMMAR1 = u"Grammar1"_ustr; // only for use in XML filter +inline constexpr OUString SC_UNONAME_GRAMMAR2 = u"Grammar2"_ustr; // only for use in XML filter +inline constexpr OUString SC_UNONAME_STYLENAME = u"StyleName"_ustr; + +// validation +inline constexpr OUString SC_UNONAME_ERRALSTY = u"ErrorAlertStyle"_ustr; +inline constexpr OUString SC_UNONAME_ERRMESS = u"ErrorMessage"_ustr; +inline constexpr OUString SC_UNONAME_ERRTITLE = u"ErrorTitle"_ustr; +inline constexpr OUString SC_UNONAME_IGNOREBL = u"IgnoreBlankCells"_ustr; +inline constexpr OUString SC_UNONAME_INPMESS = u"InputMessage"_ustr; +inline constexpr OUString SC_UNONAME_INPTITLE = u"InputTitle"_ustr; +inline constexpr OUString SC_UNONAME_SHOWERR = u"ShowErrorMessage"_ustr; +inline constexpr OUString SC_UNONAME_SHOWINP = u"ShowInputMessage"_ustr; +inline constexpr OUString SC_UNONAME_SHOWLIST = u"ShowList"_ustr; +inline constexpr OUString SC_UNONAME_TYPE = u"Type"_ustr; + +// links +inline constexpr OUString SC_UNONAME_FILTER = u"Filter"_ustr; +inline constexpr OUString SC_UNONAME_FILTOPT = u"FilterOptions"_ustr; +inline constexpr OUString SC_UNONAME_LINKURL = u"Url"_ustr; +inline constexpr OUString SC_UNONAME_REFPERIOD = u"RefreshPeriod"_ustr; +inline constexpr OUString SC_UNONAME_REFDELAY = u"RefreshDelay"_ustr; // deprecated, don't use anymore + +// search descriptor +inline constexpr OUString SC_UNO_SRCHBACK = u"SearchBackwards"_ustr; +inline constexpr OUString SC_UNO_SRCHBYROW = u"SearchByRow"_ustr; +inline constexpr OUString SC_UNO_SRCHCASE = u"SearchCaseSensitive"_ustr; +inline constexpr OUString SC_UNO_SRCHREGEXP = u"SearchRegularExpression"_ustr; +inline constexpr OUString SC_UNO_SRCHWILDCARD = u"SearchWildcard"_ustr; +inline constexpr OUString SC_UNO_SRCHSIM = u"SearchSimilarity"_ustr; +inline constexpr OUString SC_UNO_SRCHSIMADD = u"SearchSimilarityAdd"_ustr; +inline constexpr OUString SC_UNO_SRCHSIMEX = u"SearchSimilarityExchange"_ustr; +inline constexpr OUString SC_UNO_SRCHSIMREL = u"SearchSimilarityRelax"_ustr; +inline constexpr OUString SC_UNO_SRCHSIMREM = u"SearchSimilarityRemove"_ustr; +inline constexpr OUString SC_UNO_SRCHSTYLES = u"SearchStyles"_ustr; +inline constexpr OUString SC_UNO_SRCHTYPE = u"SearchType"_ustr; +inline constexpr OUString SC_UNO_SRCHWORDS = u"SearchWords"_ustr; +inline constexpr OUString SC_UNO_SRCHFILTERED = u"SearchFiltered"_ustr; +inline constexpr OUString SC_UNO_SRCHFORMATTED = u"SearchFormatted"_ustr; +inline constexpr OUString SC_UNO_SRCHWCESCCHAR = u"WildcardEscapeCharacter"_ustr; + +// old (5.2) property names for page styles - for compatibility only! +inline constexpr OUString OLD_UNO_PAGE_BACKCOLOR = u"BackgroundColor"_ustr; +inline constexpr OUString OLD_UNO_PAGE_BACKTRANS = u"IsBackgroundTransparent"_ustr; +inline constexpr OUString OLD_UNO_PAGE_HDRBACKCOL = u"HeaderBackgroundColor"_ustr; +inline constexpr OUString OLD_UNO_PAGE_HDRBACKTRAN = u"TransparentHeaderBackground"_ustr; +inline constexpr OUString OLD_UNO_PAGE_HDRSHARED = u"HeaderShared"_ustr; +inline constexpr OUString OLD_UNO_PAGE_HDRDYNAMIC = u"HeaderDynamic"_ustr; +inline constexpr OUString OLD_UNO_PAGE_HDRON = u"HeaderOn"_ustr; +inline constexpr OUString OLD_UNO_PAGE_FTRBACKCOL = u"FooterBackgroundColor"_ustr; +inline constexpr OUString OLD_UNO_PAGE_FTRBACKTRAN = u"TransparentFooterBackground"_ustr; +inline constexpr OUString OLD_UNO_PAGE_FTRSHARED = u"FooterShared"_ustr; +inline constexpr OUString OLD_UNO_PAGE_FTRDYNAMIC = u"FooterDynamic"_ustr; +inline constexpr OUString OLD_UNO_PAGE_FTRON = u"FooterOn"_ustr; + +// page styles +inline constexpr OUString SC_UNO_PAGE_BACKCOLOR = u"BackColor"_ustr; +inline constexpr OUString SC_UNO_PAGE_BACKTRANS = u"BackTransparent"_ustr; +inline constexpr OUString SC_UNO_PAGE_GRAPHICFILT = u"BackGraphicFilter"_ustr; +inline constexpr OUString SC_UNO_PAGE_GRAPHICLOC = u"BackGraphicLocation"_ustr; +inline constexpr OUString SC_UNO_PAGE_GRAPHICURL = u"BackGraphicURL"_ustr; +inline constexpr OUString SC_UNO_PAGE_GRAPHIC = u"BackGraphic"_ustr; +#define SC_UNO_PAGE_LEFTBORDER SC_UNONAME_LEFTBORDER +#define SC_UNO_PAGE_RIGHTBORDER SC_UNONAME_RIGHTBORDER +#define SC_UNO_PAGE_BOTTBORDER SC_UNONAME_BOTTBORDER +#define SC_UNO_PAGE_TOPBORDER SC_UNONAME_TOPBORDER +inline constexpr OUString SC_UNO_PAGE_LEFTBRDDIST = u"LeftBorderDistance"_ustr; +inline constexpr OUString SC_UNO_PAGE_RIGHTBRDDIST = u"RightBorderDistance"_ustr; +inline constexpr OUString SC_UNO_PAGE_BOTTBRDDIST = u"BottomBorderDistance"_ustr; +inline constexpr OUString SC_UNO_PAGE_TOPBRDDIST = u"TopBorderDistance"_ustr; +inline constexpr OUString SC_UNO_PAGE_BORDERDIST = u"BorderDistance"_ustr; +inline constexpr OUString SC_UNO_PAGE_SHADOWFORM = u"ShadowFormat"_ustr; +inline constexpr OUString SC_UNO_PAGE_LEFTMARGIN = u"LeftMargin"_ustr; +inline constexpr OUString SC_UNO_PAGE_RIGHTMARGIN = u"RightMargin"_ustr; +inline constexpr OUString SC_UNO_PAGE_TOPMARGIN = u"TopMargin"_ustr; +inline constexpr OUString SC_UNO_PAGE_BOTTMARGIN = u"BottomMargin"_ustr; +inline constexpr OUString SC_UNO_PAGE_LANDSCAPE = u"IsLandscape"_ustr; +inline constexpr OUString SC_UNO_PAGE_NUMBERTYPE = u"NumberingType"_ustr; +inline constexpr OUString SC_UNO_PAGE_SYTLELAYOUT = u"PageStyleLayout"_ustr; +inline constexpr OUString SC_UNO_PAGE_PAPERTRAY = u"PrinterPaperTray"_ustr; +inline constexpr OUString SC_UNO_PAGE_SIZE = u"Size"_ustr; +inline constexpr OUString SC_UNO_PAGE_WIDTH = u"Width"_ustr; +inline constexpr OUString SC_UNO_PAGE_HEIGHT = u"Height"_ustr; +inline constexpr OUString SC_UNO_PAGE_CENTERHOR = u"CenterHorizontally"_ustr; +inline constexpr OUString SC_UNO_PAGE_CENTERVER = u"CenterVertically"_ustr; +inline constexpr OUString SC_UNO_PAGE_PRINTANNOT = u"PrintAnnotations"_ustr; +inline constexpr OUString SC_UNO_PAGE_PRINTGRID = u"PrintGrid"_ustr; +inline constexpr OUString SC_UNO_PAGE_PRINTHEADER = u"PrintHeaders"_ustr; +inline constexpr OUString SC_UNO_PAGE_PRINTCHARTS = u"PrintCharts"_ustr; +inline constexpr OUString SC_UNO_PAGE_PRINTOBJS = u"PrintObjects"_ustr; +inline constexpr OUString SC_UNO_PAGE_PRINTDRAW = u"PrintDrawing"_ustr; +inline constexpr OUString SC_UNO_PAGE_PRINTDOWN = u"PrintDownFirst"_ustr; +inline constexpr OUString SC_UNO_PAGE_SCALEVAL = u"PageScale"_ustr; +inline constexpr OUString SC_UNO_PAGE_SCALETOPAG = u"ScaleToPages"_ustr; +inline constexpr OUString SC_UNO_PAGE_SCALETOX = u"ScaleToPagesX"_ustr; +inline constexpr OUString SC_UNO_PAGE_SCALETOY = u"ScaleToPagesY"_ustr; +inline constexpr OUString SC_UNO_PAGE_FIRSTPAGE = u"FirstPageNumber"_ustr; +inline constexpr OUString SC_UNO_PAGE_FIRSTHDRSHARED = u"FirstPageHeaderIsShared"_ustr; +inline constexpr OUString SC_UNO_PAGE_FIRSTFTRSHARED = u"FirstPageFooterIsShared"_ustr; +inline constexpr OUString SC_UNO_PAGE_LEFTHDRCONT = u"LeftPageHeaderContent"_ustr; +inline constexpr OUString SC_UNO_PAGE_LEFTFTRCONT = u"LeftPageFooterContent"_ustr; +inline constexpr OUString SC_UNO_PAGE_RIGHTHDRCON = u"RightPageHeaderContent"_ustr; +inline constexpr OUString SC_UNO_PAGE_RIGHTFTRCON = u"RightPageFooterContent"_ustr; +inline constexpr OUString SC_UNO_PAGE_FIRSTHDRCONT = u"FirstPageHeaderContent"_ustr; +inline constexpr OUString SC_UNO_PAGE_FIRSTFTRCONT = u"FirstPageFooterContent"_ustr; +inline constexpr OUString SC_UNO_PAGE_PRINTFORMUL = u"PrintFormulas"_ustr; +inline constexpr OUString SC_UNO_PAGE_PRINTZERO = u"PrintZeroValues"_ustr; +inline constexpr OUString SC_UNO_PAGE_HDRBACKCOL = u"HeaderBackColor"_ustr; +inline constexpr OUString SC_UNO_PAGE_HDRBACKTRAN = u"HeaderBackTransparent"_ustr; +inline constexpr OUString SC_UNO_PAGE_HDRGRFFILT = u"HeaderBackGraphicFilter"_ustr; +inline constexpr OUString SC_UNO_PAGE_HDRGRFLOC = u"HeaderBackGraphicLocation"_ustr; +inline constexpr OUString SC_UNO_PAGE_HDRGRF = u"HeaderBackGraphic"_ustr; +inline constexpr OUString SC_UNO_PAGE_HDRGRFURL = u"HeaderBackGraphicURL"_ustr; +inline constexpr OUString SC_UNO_PAGE_HDRLEFTBOR = u"HeaderLeftBorder"_ustr; +inline constexpr OUString SC_UNO_PAGE_HDRRIGHTBOR = u"HeaderRightBorder"_ustr; +inline constexpr OUString SC_UNO_PAGE_HDRBOTTBOR = u"HeaderBottomBorder"_ustr; +inline constexpr OUString SC_UNO_PAGE_HDRTOPBOR = u"HeaderTopBorder"_ustr; +inline constexpr OUString SC_UNO_PAGE_HDRLEFTBDIS = u"HeaderLeftBorderDistance"_ustr; +inline constexpr OUString SC_UNO_PAGE_HDRRIGHTBDIS = u"HeaderRightBorderDistance"_ustr; +inline constexpr OUString SC_UNO_PAGE_HDRBOTTBDIS = u"HeaderBottomBorderDistance"_ustr; +inline constexpr OUString SC_UNO_PAGE_HDRTOPBDIS = u"HeaderTopBorderDistance"_ustr; +inline constexpr OUString SC_UNO_PAGE_HDRBRDDIST = u"HeaderBorderDistance"_ustr; +inline constexpr OUString SC_UNO_PAGE_HDRSHADOW = u"HeaderShadowFormat"_ustr; +inline constexpr OUString SC_UNO_PAGE_HDRLEFTMAR = u"HeaderLeftMargin"_ustr; +inline constexpr OUString SC_UNO_PAGE_HDRRIGHTMAR = u"HeaderRightMargin"_ustr; +inline constexpr OUString SC_UNO_PAGE_HDRBODYDIST = u"HeaderBodyDistance"_ustr; +inline constexpr OUString SC_UNO_PAGE_HDRHEIGHT = u"HeaderHeight"_ustr; +inline constexpr OUString SC_UNO_PAGE_HDRON = u"HeaderIsOn"_ustr; +inline constexpr OUString SC_UNO_PAGE_HDRDYNAMIC = u"HeaderIsDynamicHeight"_ustr; +inline constexpr OUString SC_UNO_PAGE_HDRSHARED = u"HeaderIsShared"_ustr; +inline constexpr OUString SC_UNO_PAGE_FTRBACKCOL = u"FooterBackColor"_ustr; +inline constexpr OUString SC_UNO_PAGE_FTRBACKTRAN = u"FooterBackTransparent"_ustr; +inline constexpr OUString SC_UNO_PAGE_FTRGRFFILT = u"FooterBackGraphicFilter"_ustr; +inline constexpr OUString SC_UNO_PAGE_FTRGRFLOC = u"FooterBackGraphicLocation"_ustr; +inline constexpr OUString SC_UNO_PAGE_FTRGRF = u"FooterBackGraphic"_ustr; +inline constexpr OUString SC_UNO_PAGE_FTRGRFURL = u"FooterBackGraphicURL"_ustr; +inline constexpr OUString SC_UNO_PAGE_FTRLEFTBOR = u"FooterLeftBorder"_ustr; +inline constexpr OUString SC_UNO_PAGE_FTRRIGHTBOR = u"FooterRightBorder"_ustr; +inline constexpr OUString SC_UNO_PAGE_FTRBOTTBOR = u"FooterBottomBorder"_ustr; +inline constexpr OUString SC_UNO_PAGE_FTRTOPBOR = u"FooterTopBorder"_ustr; +inline constexpr OUString SC_UNO_PAGE_FTRLEFTBDIS = u"FooterLeftBorderDistance"_ustr; +inline constexpr OUString SC_UNO_PAGE_FTRRIGHTBDIS = u"FooterRightBorderDistance"_ustr; +inline constexpr OUString SC_UNO_PAGE_FTRBOTTBDIS = u"FooterBottomBorderDistance"_ustr; +inline constexpr OUString SC_UNO_PAGE_FTRTOPBDIS = u"FooterTopBorderDistance"_ustr; +inline constexpr OUString SC_UNO_PAGE_FTRBRDDIST = u"FooterBorderDistance"_ustr; +inline constexpr OUString SC_UNO_PAGE_FTRSHADOW = u"FooterShadowFormat"_ustr; +inline constexpr OUString SC_UNO_PAGE_FTRLEFTMAR = u"FooterLeftMargin"_ustr; +inline constexpr OUString SC_UNO_PAGE_FTRRIGHTMAR = u"FooterRightMargin"_ustr; +inline constexpr OUString SC_UNO_PAGE_FTRBODYDIST = u"FooterBodyDistance"_ustr; +inline constexpr OUString SC_UNO_PAGE_FTRHEIGHT = u"FooterHeight"_ustr; +inline constexpr OUString SC_UNO_PAGE_FTRON = u"FooterIsOn"_ustr; +inline constexpr OUString SC_UNO_PAGE_FTRDYNAMIC = u"FooterIsDynamicHeight"_ustr; +inline constexpr OUString SC_UNO_PAGE_FTRSHARED = u"FooterIsShared"_ustr; + +// document settings +inline constexpr OUString SC_UNO_CALCASSHOWN = u"CalcAsShown"_ustr; +inline constexpr OUString SC_UNO_DEFTABSTOP = u"DefaultTabStop"_ustr; +inline constexpr OUString SC_UNO_TABSTOPDIS = u"TabStopDistance"_ustr; // is the same like the before, but only the writer name +inline constexpr OUString SC_UNO_IGNORECASE = u"IgnoreCase"_ustr; +inline constexpr OUString SC_UNO_ITERCOUNT = u"IterationCount"_ustr; +inline constexpr OUString SC_UNO_ITERENABLED = u"IsIterationEnabled"_ustr; +inline constexpr OUString SC_UNO_ITEREPSILON = u"IterationEpsilon"_ustr; +inline constexpr OUString SC_UNO_LOOKUPLABELS = u"LookUpLabels"_ustr; +inline constexpr OUString SC_UNO_MATCHWHOLE = u"MatchWholeCell"_ustr; +inline constexpr OUString SC_UNO_NULLDATE = u"NullDate"_ustr; +inline constexpr OUString SC_UNO_SPELLONLINE = u"SpellOnline"_ustr; +inline constexpr OUString SC_UNO_STANDARDDEC = u"StandardDecimals"_ustr; +inline constexpr OUString SC_UNO_REGEXENABLED = u"RegularExpressions"_ustr; +inline constexpr OUString SC_UNO_WILDCARDSENABLED = u"Wildcards"_ustr; +inline constexpr OUString SC_UNO_BASICLIBRARIES = u"BasicLibraries"_ustr; +inline constexpr OUString SC_UNO_DIALOGLIBRARIES = u"DialogLibraries"_ustr; +inline constexpr OUString SC_UNO_RUNTIMEUID = u"RuntimeUID"_ustr; +inline constexpr OUString SC_UNO_HASVALIDSIGNATURES = u"HasValidSignatures"_ustr; +inline constexpr OUString SC_UNO_ISLOADED = u"IsLoaded"_ustr; +inline constexpr OUString SC_UNO_ISUNDOENABLED = u"IsUndoEnabled"_ustr; +inline constexpr OUString SC_UNO_ISADJUSTHEIGHTENABLED = u"IsAdjustHeightEnabled"_ustr; +inline constexpr OUString SC_UNO_ISEXECUTELINKENABLED = u"IsExecuteLinkEnabled"_ustr; +inline constexpr OUString SC_UNO_ISCHANGEREADONLYENABLED = u"IsChangeReadOnlyEnabled"_ustr; +inline constexpr OUString SC_UNO_REFERENCEDEVICE = u"ReferenceDevice"_ustr; +inline constexpr OUString SC_UNO_CODENAME = u"CodeName"_ustr; +inline constexpr OUString SC_UNO_INTEROPGRABBAG = u"InteropGrabBag"_ustr; +inline constexpr OUString SC_UNO_RECORDCHANGES = u"RecordChanges"_ustr; +inline constexpr OUString SC_UNO_ISRECORDCHANGESPROTECTED = u"IsRecordChangesProtected"_ustr; +inline constexpr OUString SC_UNO_SYNTAXSTRINGREF = u"SyntaxStringRef"_ustr; + + +// document properties from FormModel +inline constexpr OUString SC_UNO_APPLYFMDES = u"ApplyFormDesignMode"_ustr; +inline constexpr OUString SC_UNO_AUTOCONTFOC = u"AutomaticControlFocus"_ustr; + +// view options +inline constexpr OUString SC_UNO_COLROWHDR = u"HasColumnRowHeaders"_ustr; +inline constexpr OUString SC_UNO_GRIDCOLOR = u"GridColor"_ustr; +inline constexpr OUString SC_UNO_HIDESPELL = u"HideSpellMarks"_ustr; /* deprecated #i91949 */ +inline constexpr OUString SC_UNO_HORSCROLL = u"HasHorizontalScrollBar"_ustr; +inline constexpr OUString SC_UNO_OUTLSYMB = u"IsOutlineSymbolsSet"_ustr; +inline constexpr OUString SC_UNO_SHEETTABS = u"HasSheetTabs"_ustr; +inline constexpr OUString SC_UNO_SHOWANCHOR = u"ShowAnchor"_ustr; +inline constexpr OUString SC_UNO_SHOWCHARTS = u"ShowCharts"_ustr; +inline constexpr OUString SC_UNO_SHOWDRAW = u"ShowDrawing"_ustr; +inline constexpr OUString SC_UNO_SHOWFORM = u"ShowFormulas"_ustr; +inline constexpr OUString SC_UNO_SHOWGRID = u"ShowGrid"_ustr; +inline constexpr OUString SC_UNO_SHOWHELP = u"ShowHelpLines"_ustr; +inline constexpr OUString SC_UNO_SHOWNOTES = u"ShowNotes"_ustr; +inline constexpr OUString SC_UNO_SHOWFORMULASMARKS = u"ShowFormulasMarks"_ustr; +inline constexpr OUString SC_UNO_SHOWOBJ = u"ShowObjects"_ustr; +inline constexpr OUString SC_UNO_SHOWPAGEBR = u"ShowPageBreaks"_ustr; +inline constexpr OUString SC_UNO_SHOWZERO = u"ShowZeroValues"_ustr; +inline constexpr OUString SC_UNO_VALUEHIGH = u"IsValueHighlightingEnabled"_ustr; +inline constexpr OUString SC_UNO_VERTSCROLL = u"HasVerticalScrollBar"_ustr; +inline constexpr OUString SC_UNO_SNAPTORASTER = u"IsSnapToRaster"_ustr; +inline constexpr OUString SC_UNO_RASTERVIS = u"RasterIsVisible"_ustr; +inline constexpr OUString SC_UNO_RASTERRESX = u"RasterResolutionX"_ustr; +inline constexpr OUString SC_UNO_RASTERRESY = u"RasterResolutionY"_ustr; +inline constexpr OUString SC_UNO_RASTERSUBX = u"RasterSubdivisionX"_ustr; +inline constexpr OUString SC_UNO_RASTERSUBY = u"RasterSubdivisionY"_ustr; +inline constexpr OUString SC_UNO_RASTERSYNC = u"IsRasterAxisSynchronized"_ustr; +inline constexpr OUString SC_UNO_AUTOCALC = u"AutoCalculate"_ustr; +inline constexpr OUString SC_UNO_PRINTERNAME = u"PrinterName"_ustr; +inline constexpr OUString SC_UNO_PRINTERSETUP = u"PrinterSetup"_ustr; +inline constexpr OUString SC_UNO_PRINTERPAPER = u"PrinterPaperFromSetup"_ustr; +inline constexpr OUString SC_UNO_APPLYDOCINF = u"ApplyUserData"_ustr; +inline constexpr OUString SC_UNO_SAVE_THUMBNAIL = u"SaveThumbnail"_ustr; +inline constexpr OUString SC_UNO_CHARCOMP = u"CharacterCompressionType"_ustr; +inline constexpr OUString SC_UNO_ASIANKERN = u"IsKernAsianPunctuation"_ustr; +inline constexpr OUString SC_UNO_VISAREA = u"VisibleArea"_ustr; +inline constexpr OUString SC_UNO_ZOOMTYPE = u"ZoomType"_ustr; +inline constexpr OUString SC_UNO_ZOOMVALUE = u"ZoomValue"_ustr; +inline constexpr OUString SC_UNO_UPDTEMPL = u"UpdateFromTemplate"_ustr; +inline constexpr OUString SC_UNO_FILTERED_RANGE_SELECTION = u"FilteredRangeSelection"_ustr; +inline constexpr OUString SC_UNO_VISAREASCREEN = u"VisibleAreaOnScreen"_ustr; +inline constexpr OUString SC_UNO_FORMULABARHEIGHT = u"FormulaBarHeight"_ustr; +inline constexpr OUString SC_UNO_IMAGE_PREFERRED_DPI = u"ImagePreferredDPI"_ustr; + +/*Stampit enable/disable print cancel */ +inline constexpr OUString SC_UNO_ALLOWPRINTJOBCANCEL = u"AllowPrintJobCancel"_ustr; + +// old (5.2) property names for view options - for compatibility only! +inline constexpr OUString OLD_UNO_COLROWHDR = u"ColumnRowHeaders"_ustr; +inline constexpr OUString OLD_UNO_HORSCROLL = u"HorizontalScrollBar"_ustr; +inline constexpr OUString OLD_UNO_OUTLSYMB = u"OutlineSymbols"_ustr; +inline constexpr OUString OLD_UNO_SHEETTABS = u"SheetTabs"_ustr; +inline constexpr OUString OLD_UNO_VALUEHIGH = u"ValueHighlighting"_ustr; +inline constexpr OUString OLD_UNO_VERTSCROLL = u"VerticalScrollBar"_ustr; + +// data pilot source +inline constexpr OUString SC_UNO_DP_COLGRAND = u"ColumnGrand"_ustr; +inline constexpr OUString SC_UNO_DP_ROWGRAND = u"RowGrand"_ustr; +inline constexpr OUString SC_UNO_DP_ORIGINAL = u"Original"_ustr; +inline constexpr OUString SC_UNO_DP_ORIGINAL_POS = u"OriginalPosition"_ustr; +inline constexpr OUString SC_UNO_DP_ISDATALAYOUT = u"IsDataLayoutDimension"_ustr; +inline constexpr OUString SC_UNO_DP_ORIENTATION = u"Orientation"_ustr; +inline constexpr OUString SC_UNO_DP_POSITION = u"Position"_ustr; +inline constexpr OUString SC_UNO_DP_FUNCTION = u"Function"_ustr; +inline constexpr OUString SC_UNO_DP_FUNCTION2 = u"Function2"_ustr; +inline constexpr OUString SC_UNO_DP_USEDHIERARCHY = u"UsedHierarchy"_ustr; +inline constexpr OUString SC_UNO_DP_FILTER = u"Filter"_ustr; +inline constexpr OUString SC_UNO_DP_SUBTOTAL = u"SubTotals"_ustr; +inline constexpr OUString SC_UNO_DP_SUBTOTAL2 = u"SubTotals2"_ustr; +inline constexpr OUString SC_UNO_DP_SHOWEMPTY = u"ShowEmpty"_ustr; +inline constexpr OUString SC_UNO_DP_REPEATITEMLABELS = u"RepeatItemLabels"_ustr; +inline constexpr OUString SC_UNO_DP_ISVISIBLE = u"IsVisible"_ustr; +inline constexpr OUString SC_UNO_DP_SHOWDETAILS = u"ShowDetails"_ustr; +inline constexpr OUString SC_UNO_DP_IGNOREEMPTY = u"IgnoreEmptyRows"_ustr; +inline constexpr OUString SC_UNO_DP_REPEATEMPTY = u"RepeatIfEmpty"_ustr; +inline constexpr OUString SC_UNO_DP_DATADESC = u"DataDescription"_ustr; +#define SC_UNO_DP_NUMBERFO SC_UNONAME_NUMFMT +inline constexpr OUString SC_UNO_DP_ROWFIELDCOUNT = u"RowFieldCount"_ustr; +inline constexpr OUString SC_UNO_DP_COLUMNFIELDCOUNT = u"ColumnFieldCount"_ustr; +inline constexpr OUString SC_UNO_DP_DATAFIELDCOUNT = u"DataFieldCount"_ustr; +inline constexpr OUString SC_UNO_DP_LAYOUTNAME = u"LayoutName"_ustr; +inline constexpr OUString SC_UNO_DP_FIELD_SUBTOTALNAME = u"FieldSubtotalName"_ustr; +inline constexpr OUString SC_UNO_DP_GRANDTOTAL_NAME = u"GrandTotalName"_ustr; +inline constexpr OUString SC_UNO_DP_HAS_HIDDEN_MEMBER = u"HasHiddenMember"_ustr; +inline constexpr OUString SC_UNO_DP_FLAGS = u"Flags"_ustr; + +inline constexpr OUString SC_UNO_DP_REFVALUE = u"ReferenceValue"_ustr; +inline constexpr OUString SC_UNO_DP_SORTING = u"Sorting"_ustr; +inline constexpr OUString SC_UNO_DP_AUTOSHOW = u"AutoShow"_ustr; +inline constexpr OUString SC_UNO_DP_LAYOUT = u"Layout"_ustr; + +// data pilot descriptor +inline constexpr OUString SC_UNO_DP_IGNORE_EMPTYROWS = u"IgnoreEmptyRows"_ustr; +inline constexpr OUString SC_UNO_DP_DRILLDOWN = u"DrillDownOnDoubleClick"_ustr; +inline constexpr OUString SC_UNO_DP_SHOWFILTER = u"ShowFilterButton"_ustr; +inline constexpr OUString SC_UNO_DP_IMPORTDESC = u"ImportDescriptor"_ustr; +inline constexpr OUString SC_UNO_DP_SOURCESERVICE = u"SourceServiceName"_ustr; +inline constexpr OUString SC_UNO_DP_SERVICEARG = u"ServiceArguments"_ustr; + +// properties in data pilot descriptor ServiceArguments +inline constexpr OUString SC_UNO_DP_SOURCENAME = u"SourceName"_ustr; +inline constexpr OUString SC_UNO_DP_OBJECTNAME = u"ObjectName"_ustr; +inline constexpr OUString SC_UNO_DP_USERNAME = u"UserName"_ustr; +inline constexpr OUString SC_UNO_DP_PASSWORD = u"Password"_ustr; + +// range selection +inline constexpr OUString SC_UNONAME_INITVAL = u"InitialValue"_ustr; +inline constexpr OUString SC_UNONAME_TITLE = u"Title"_ustr; +inline constexpr OUString SC_UNONAME_CLOSEONUP = u"CloseOnMouseRelease"_ustr; +inline constexpr OUString SC_UNONAME_SINGLECELL = u"SingleCellMode"_ustr; +inline constexpr OUString SC_UNONAME_MULTISEL = u"MultiSelectionMode"_ustr; + +// XRenderable +inline constexpr OUString SC_UNONAME_PAGESIZE = u"PageSize"_ustr; +inline constexpr OUString SC_UNONAME_RENDERDEV = u"RenderDevice"_ustr; +inline constexpr OUString SC_UNONAME_SOURCERANGE = u"SourceRange"_ustr; +inline constexpr OUString SC_UNONAME_INC_NP_AREA = u"PageIncludesNonprintableArea"_ustr; +inline constexpr OUString SC_UNONAME_CALCPAGESIZE = u"CalcPageContentSize"_ustr; +inline constexpr OUString SC_UNONAME_CALCPAGEPOS = u"CalcPagePos"_ustr; + +// CellValueBinding +inline constexpr OUString SC_UNONAME_BOUNDCELL = u"BoundCell"_ustr; +// CellRangeListSource +inline constexpr OUString SC_UNONAME_CELLRANGE = u"CellRange"_ustr; + +// CellAddressConversion / CellRangeAddressConversion +inline constexpr OUString SC_UNONAME_ADDRESS = u"Address"_ustr; +inline constexpr OUString SC_UNONAME_UIREPR = u"UserInterfaceRepresentation"_ustr; +inline constexpr OUString SC_UNONAME_PERSREPR = u"PersistentRepresentation"_ustr; +inline constexpr OUString SC_UNONAME_XLA1REPR = u"XLA1Representation"_ustr; +inline constexpr OUString SC_UNONAME_REFSHEET = u"ReferenceSheet"_ustr; + +// Security options +inline constexpr OUString SC_UNO_LOADREADONLY = u"LoadReadonly"_ustr; +inline constexpr OUString SC_UNO_MODIFYPASSWORDINFO = u"ModifyPasswordInfo"_ustr; +inline constexpr OUString SC_UNO_MODIFYPASSWORDHASH = u"ModifyPasswordHash"_ustr; + +// FormulaParser +inline constexpr OUString SC_UNO_COMPILEENGLISH = u"CompileEnglish"_ustr; +inline constexpr OUString SC_UNO_FORMULACONVENTION = u"FormulaConvention"_ustr; +inline constexpr OUString SC_UNO_IGNORELEADING = u"IgnoreLeadingSpaces"_ustr; +inline constexpr OUString SC_UNO_OPCODEMAP = u"OpCodeMap"_ustr; +inline constexpr OUString SC_UNO_EXTERNALLINKS = u"ExternalLinks"_ustr; +inline constexpr OUString SC_UNO_COMPILEFAP = u"CompileFAP"_ustr; +inline constexpr OUString SC_UNO_REF_CONV_CHARTOOXML = u"RefConventionChartOOXML"_ustr; + +// Chart2 +inline constexpr OUString SC_UNONAME_ROLE = u"Role"_ustr; +inline constexpr OUString SC_UNONAME_HIDDENVALUES = u"HiddenValues"_ustr; +inline constexpr OUString SC_UNONAME_INCLUDEHIDDENCELLS = u"IncludeHiddenCells"_ustr; +inline constexpr OUString SC_UNONAME_USE_INTERNAL_DATA_PROVIDER = u"UseInternalDataProvider"_ustr; +inline constexpr OUString SC_UNONAME_HAS_STRING_LABEL = u"HasStringLabel"_ustr; +inline constexpr OUString SC_UNONAME_TIME_BASED = u"TimeBased"_ustr; + +// Solver +inline constexpr OUString SC_UNONAME_TIMEOUT = u"Timeout"_ustr; +inline constexpr OUString SC_UNO_SHAREDOC = u"IsDocumentShared"_ustr; + +// EventDescriptor +inline constexpr OUString SC_UNO_EVENTTYPE = u"EventType"_ustr; +inline constexpr OUString SC_UNO_SCRIPT = u"Script"_ustr; + +// Named ranges +inline constexpr OUString SC_UNO_MODIFY_BROADCAST = u"ModifyAndBroadcast"_ustr; + +inline constexpr OUString SC_UNO_EMBED_FONTS = u"EmbedFonts"_ustr; +inline constexpr OUString SC_UNO_EMBED_ONLY_USED_FONTS = u"EmbedOnlyUsedFonts"_ustr; +inline constexpr OUString SC_UNO_EMBED_FONT_SCRIPT_LATIN = u"EmbedLatinScriptFonts"_ustr; +inline constexpr OUString SC_UNO_EMBED_FONT_SCRIPT_ASIAN = u"EmbedAsianScriptFonts"_ustr; +inline constexpr OUString SC_UNO_EMBED_FONT_SCRIPT_COMPLEX = u"EmbedComplexScriptFonts"_ustr; + +inline constexpr OUString SC_UNO_ODS_LOCK_SOLAR_MUTEX = u"ODSLockSolarMutex"_ustr; +inline constexpr OUString SC_UNO_ODS_IMPORT_STYLES = u"ODSImportStyles"_ustr; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/unoreflist.hxx b/sc/inc/unoreflist.hxx new file mode 100644 index 0000000000..fb045c9434 --- /dev/null +++ b/sc/inc/unoreflist.hxx @@ -0,0 +1,72 @@ +/* -*- 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 <utility> +#include <vector> +#include <svl/hint.hxx> +#include "rangelst.hxx" + +struct ScUnoRefEntry +{ + sal_Int64 nObjectId; + ScRangeList aRanges; + + ScUnoRefEntry( sal_Int64 nId, ScRangeList aOldRanges ) : + nObjectId( nId ), + aRanges(std::move( aOldRanges )) + { + } +}; + +/** List of RefUpdate changes made to UNO objects during ScUpdateRefHint broadcast. +*/ + +class ScUnoRefList +{ +private: + ::std::vector<ScUnoRefEntry> aEntries; + +public: + ScUnoRefList(); + ~ScUnoRefList(); + + void Add( sal_Int64 nId, const ScRangeList& rOldRanges ); + void Undo( ScDocument* pDoc ); + + bool IsEmpty() const { return aEntries.empty(); } +}; + +/** Hint to restore a UNO object to its old state (used during undo). +*/ + +class ScUnoRefUndoHint final : public SfxHint +{ + ScUnoRefEntry aEntry; + +public: + ScUnoRefUndoHint( ScUnoRefEntry aRefEntry ); + virtual ~ScUnoRefUndoHint() override; + + sal_Int64 GetObjectId() const { return aEntry.nObjectId; } + const ScRangeList& GetRanges() const { return aEntry.aRanges; } +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/unowids.hxx b/sc/inc/unowids.hxx new file mode 100644 index 0000000000..cd1d6baf6a --- /dev/null +++ b/sc/inc/unowids.hxx @@ -0,0 +1,89 @@ +/* -*- 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 "scitems.hxx" + +// WIDs for uno property maps, +// never stored in files + +#define SC_WID_UNO_START 1200 + +#define SC_WID_UNO_CELLSTYL ( SC_WID_UNO_START + 0 ) +#define SC_WID_UNO_CHCOLHDR ( SC_WID_UNO_START + 1 ) +#define SC_WID_UNO_CHROWHDR ( SC_WID_UNO_START + 2 ) +#define SC_WID_UNO_CONDFMT ( SC_WID_UNO_START + 3 ) +#define SC_WID_UNO_CONDLOC ( SC_WID_UNO_START + 4 ) +#define SC_WID_UNO_CONDXML ( SC_WID_UNO_START + 5 ) +#define SC_WID_UNO_TBLBORD ( SC_WID_UNO_START + 6 ) +#define SC_WID_UNO_VALIDAT ( SC_WID_UNO_START + 7 ) +#define SC_WID_UNO_VALILOC ( SC_WID_UNO_START + 8 ) +#define SC_WID_UNO_VALIXML ( SC_WID_UNO_START + 9 ) +#define SC_WID_UNO_POS ( SC_WID_UNO_START + 10 ) +#define SC_WID_UNO_SIZE ( SC_WID_UNO_START + 11 ) +#define SC_WID_UNO_FORMLOC ( SC_WID_UNO_START + 12 ) +#define SC_WID_UNO_FORMRT ( SC_WID_UNO_START + 13 ) +#define SC_WID_UNO_PAGESTL ( SC_WID_UNO_START + 14 ) +#define SC_WID_UNO_CELLVIS ( SC_WID_UNO_START + 15 ) +#define SC_WID_UNO_LINKDISPBIT ( SC_WID_UNO_START + 16 ) +#define SC_WID_UNO_LINKDISPNAME ( SC_WID_UNO_START + 17 ) +#define SC_WID_UNO_CELLWID ( SC_WID_UNO_START + 18 ) +#define SC_WID_UNO_OWIDTH ( SC_WID_UNO_START + 19 ) +#define SC_WID_UNO_NEWPAGE ( SC_WID_UNO_START + 20 ) +#define SC_WID_UNO_MANPAGE ( SC_WID_UNO_START + 21 ) +#define SC_WID_UNO_CELLHGT ( SC_WID_UNO_START + 22 ) +#define SC_WID_UNO_CELLFILT ( SC_WID_UNO_START + 23 ) +#define SC_WID_UNO_OHEIGHT ( SC_WID_UNO_START + 24 ) +#define SC_WID_UNO_DISPNAME ( SC_WID_UNO_START + 25 ) +#define SC_WID_UNO_HEADERSET ( SC_WID_UNO_START + 26 ) +#define SC_WID_UNO_FOOTERSET ( SC_WID_UNO_START + 27 ) +#define SC_WID_UNO_NUMRULES ( SC_WID_UNO_START + 28 ) +#define SC_WID_UNO_ISACTIVE ( SC_WID_UNO_START + 29 ) +#define SC_WID_UNO_BORDCOL ( SC_WID_UNO_START + 30 ) +#define SC_WID_UNO_PROTECT ( SC_WID_UNO_START + 31 ) +#define SC_WID_UNO_SHOWBORD ( SC_WID_UNO_START + 32 ) +#define SC_WID_UNO_PRINTBORD ( SC_WID_UNO_START + 33 ) +#define SC_WID_UNO_COPYBACK ( SC_WID_UNO_START + 34 ) +#define SC_WID_UNO_COPYSTYL ( SC_WID_UNO_START + 35 ) +#define SC_WID_UNO_COPYFORM ( SC_WID_UNO_START + 36 ) +#define SC_WID_UNO_TABLAYOUT ( SC_WID_UNO_START + 37 ) +#define SC_WID_UNO_AUTOPRINT ( SC_WID_UNO_START + 38 ) +#define SC_WID_UNO_ABSNAME ( SC_WID_UNO_START + 39 ) +#define SC_WID_UNO_CODENAME ( SC_WID_UNO_START + 40 ) +#define SC_WID_UNO_TABCOLOR ( SC_WID_UNO_START + 41 ) +#define SC_WID_UNO_NAMES ( SC_WID_UNO_START + 42 ) +#define SC_WID_UNO_TBLBORD2 ( SC_WID_UNO_START + 43 ) +#define SC_WID_UNO_CONDFORMAT ( SC_WID_UNO_START + 44 ) +#define SC_WID_UNO_FORMATID ( SC_WID_UNO_START + 45 ) +#define SC_WID_UNO_FORMRT2 ( SC_WID_UNO_START + 46 ) +#define SC_WID_UNO_CELLCONTENTTYPE ( SC_WID_UNO_START + 47 ) +#define SC_WID_UNO_END ( SC_WID_UNO_START + 47 ) + +inline bool IsScUnoWid( sal_uInt16 nWid ) +{ + return nWid >= SC_WID_UNO_START && nWid <= SC_WID_UNO_END; +} + +inline bool IsScItemWid( sal_uInt16 nWid ) +{ + return nWid >= ATTR_STARTINDEX && nWid <= ATTR_ENDINDEX; // incl. page +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/userdat.hxx b/sc/inc/userdat.hxx new file mode 100644 index 0000000000..dd32a28651 --- /dev/null +++ b/sc/inc/userdat.hxx @@ -0,0 +1,88 @@ +/* -*- 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 <svx/svdobj.hxx> +#include "address.hxx" +#include "drwlayer.hxx" + +// Object IDs for UserData +#define SC_UD_OBJDATA 1 +// SVX_IMAPINFO_ID = 2 +#define SC_UD_MACRODATA 3 + +class SC_DLLPUBLIC ScDrawObjData final : public SdrObjUserData +{ +public: + enum Type { CellNote, ValidationCircle, DetectiveArrow, DrawingObject }; + + ScAddress maStart; + ScAddress maEnd; + Point maStartOffset; + Point maEndOffset; + Type meType; + bool mbResizeWithCell = false; + bool mbWasInHiddenRow = false; + + explicit ScDrawObjData(); + + const tools::Rectangle & getShapeRect() const { return maShapeRect; }; + const tools::Rectangle & getLastCellRect() const { return maLastCellRect; }; + void setShapeRect(const ScDocument* rDoc, tools::Rectangle rNewRect, bool bIsVisible=true) + { + // bIsVisible should be false when the object is hidden obviously. We don't want to store the old cell rect in that + // case because it will have height=0 + if (maStart.IsValid() && mbResizeWithCell && bIsVisible) + maLastCellRect = ScDrawLayer::GetCellRect(*rDoc, maStart, true); + maShapeRect = rNewRect; + mbWasInHiddenRow = !bIsVisible; + }; + +private: + virtual std::unique_ptr<SdrObjUserData> Clone( SdrObject* pObj ) const override; + + // Stores the last cell rect this shape was anchored to. + // Needed when the cell is resized to resize the image accordingly. + tools::Rectangle maLastCellRect; + // Stores the rect of the shape to which this ScDrawObjData belongs. + tools::Rectangle maShapeRect; +}; + +class SAL_DLLPUBLIC_RTTI ScMacroInfo final : public SdrObjUserData +{ +public: + ScMacroInfo(); + virtual ~ScMacroInfo() override; + + ScMacroInfo(ScMacroInfo const &) = default; + ScMacroInfo(ScMacroInfo &&) = default; + ScMacroInfo & operator =(ScMacroInfo const &) = delete; // due to SdrObjUserData + ScMacroInfo & operator =(ScMacroInfo &&) = delete; // due to SdrObjUserData + + virtual std::unique_ptr<SdrObjUserData> Clone( SdrObject* pObj ) const override; + + void SetMacro( const OUString& rMacro ) { maMacro = rMacro; } + const OUString& GetMacro() const { return maMacro; } + +private: + OUString maMacro; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/userlist.hxx b/sc/inc/userlist.hxx new file mode 100644 index 0000000000..5f913bc47d --- /dev/null +++ b/sc/inc/userlist.hxx @@ -0,0 +1,91 @@ +/* -*- 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 "scdllapi.h" + +#include <rtl/ustring.hxx> + +#include <vector> + +/** + * Stores individual user-defined sort list. + */ +class SC_DLLPUBLIC ScUserListData final +{ +private: + struct SAL_DLLPRIVATE SubStr + { + OUString maReal; + OUString maUpper; + SubStr(OUString&& aReal); + }; + + std::vector<SubStr> maSubStrings; + OUString aStr; + + SAL_DLLPRIVATE void InitTokens(); + +public: + ScUserListData(OUString aStr); + + const OUString& GetString() const { return aStr; } + void SetString(const OUString& rStr); + size_t GetSubCount() const { return maSubStrings.size(); } + bool GetSubIndex(const OUString& rSubStr, sal_uInt16& rIndex, bool& bMatchCase) const; + OUString GetSubStr(sal_uInt16 nIndex) const; + sal_Int32 Compare(const OUString& rSubStr1, const OUString& rSubStr2) const; + sal_Int32 ICompare(const OUString& rSubStr1, const OUString& rSubStr2) const; +}; + +/** + * Collection of user-defined sort lists. + */ +class SC_DLLPUBLIC ScUserList +{ + typedef std::vector<ScUserListData> DataType; + DataType maData; + +public: + explicit ScUserList(bool initDefault = true); + ScUserList(const ScUserList& r) = default; + + void AddDefaults(); + void EraseData(size_t nIndex) { maData.erase(maData.cbegin() + nIndex); } + + const ScUserListData* GetData(const OUString& rSubStr) const; + /// If the list in rStr is already inserted + bool HasEntry(std::u16string_view rStr) const; + + const ScUserListData& operator[](size_t nIndex) const { return maData[nIndex]; } + ScUserListData& operator[](size_t nIndex) { return maData[nIndex]; } + ScUserList& operator=(const ScUserList& r) = default; + bool operator==(const ScUserList& r) const; + bool operator!=(const ScUserList& r) const { return !operator==(r); } + + void clear() { maData.clear(); } + size_t size() const { return maData.size(); } + template <class... Args> void emplace_back(Args&&... args) + { + maData.emplace_back(std::forward<Args>(args)...); + } +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/validat.hxx b/sc/inc/validat.hxx new file mode 100644 index 0000000000..af43e37cc1 --- /dev/null +++ b/sc/inc/validat.hxx @@ -0,0 +1,243 @@ +/* -*- 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 "conditio.hxx" +#include "scdllapi.h" + +namespace weld { class Window; } + +namespace sc { + +struct RefUpdateContext; + +} + +namespace vcl { class ILibreOfficeKitNotifier; } + +class ScPatternAttr; +class ScTokenArray; +class ScTypedStrData; +struct ScValidationDataIsNumeric; + +enum ScValidationMode +{ + SC_VALID_ANY, + SC_VALID_WHOLE, + SC_VALID_DECIMAL, + SC_VALID_DATE, + SC_VALID_TIME, + SC_VALID_TEXTLEN, + SC_VALID_LIST, + SC_VALID_CUSTOM +}; + +enum ScValidErrorStyle +{ + SC_VALERR_STOP, + SC_VALERR_WARNING, + SC_VALERR_INFO, + SC_VALERR_MACRO +}; + +// Entry for validation (only one condition exists) + +class SC_DLLPUBLIC ScValidationData final : public ScConditionEntry +{ +private: + sal_uInt32 nKey; // index in attributes + + ScValidationMode eDataMode; + bool bShowInput; + bool bShowError; + ScValidErrorStyle eErrorStyle; + sal_Int16 mnListType; // selection list type: none, unsorted, sorted. + OUString aInputTitle; + OUString aInputMessage; + OUString aErrorTitle; + OUString aErrorMessage; + + bool DoMacro( const ScAddress& rPos, const OUString& rInput, + ScFormulaCell* pCell, weld::Window* pParent ) const; + + bool DoScript( const ScAddress& rPos, const OUString& rInput, + ScFormulaCell* pCell, weld::Window* pParent ) const; + + using ScConditionEntry::operator==; + + DECL_STATIC_LINK(ScValidationData, InstallLOKNotifierHdl, void*, vcl::ILibreOfficeKitNotifier*); + +public: + ScValidationData( ScValidationMode eMode, ScConditionMode eOper, + const OUString& rExpr1, const OUString& rExpr2, + ScDocument& rDocument, const ScAddress& rPos, + const OUString& rExprNmsp1 = OUString(), const OUString& rExprNmsp2 = OUString(), + formula::FormulaGrammar::Grammar eGrammar1 = formula::FormulaGrammar::GRAM_DEFAULT, + formula::FormulaGrammar::Grammar eGrammar2 = formula::FormulaGrammar::GRAM_DEFAULT ); + ScValidationData( ScValidationMode eMode, ScConditionMode eOper, + const ScTokenArray* pArr1, const ScTokenArray* pArr2, + ScDocument& rDocument, const ScAddress& rPos ); + ScValidationData( const ScValidationData& r ); + ScValidationData( ScDocument& rDocument, const ScValidationData& r ); + virtual ~ScValidationData() override; + + ScValidationData* Clone() const // real copy + { return new ScValidationData( *GetDocument(), *this ); } + ScValidationData* Clone(ScDocument* pNew) const override + { return new ScValidationData( *pNew, *this ); } + + void ResetInput(); + void ResetError(); + void SetInput( const OUString& rTitle, const OUString& rMsg ); + void SetError( const OUString& rTitle, const OUString& rMsg, + ScValidErrorStyle eStyle ); + + bool GetInput( OUString& rTitle, OUString& rMsg ) const + { rTitle = aInputTitle; rMsg = aInputMessage; return bShowInput; } + bool GetErrMsg( OUString& rTitle, OUString& rMsg, ScValidErrorStyle& rStyle ) const; + + bool HasErrMsg() const { return bShowError; } + + ScValidationMode GetDataMode() const { return eDataMode; } + + sal_Int16 GetListType() const { return mnListType; } + void SetListType( sal_Int16 nListType ) { mnListType = nListType; } + + /** Returns true, if the validation cell will show a selection list. + @descr Use this instead of GetListType() which returns the raw property + regardless of the validation type. */ + bool HasSelectionList() const; + /** Tries to fill the passed collection with list validation entries. + @descr Fills the list only, if this is a list validation and IsShowList() is enabled. + @param rStrings (out-param) The string list to fill with list validation entries. + @return true = rStrings has been filled with at least one entry. */ + bool FillSelectionList(std::vector<ScTypedStrData>& rStrings, const ScAddress& rPos) const; + + // with string: during input, with cell: for detective / RC_FORCED + bool IsDataValid( + const OUString& rTest, const ScPatternAttr& rPattern, const ScAddress& rPos ) const; + + // Custom validations (SC_VALID_CUSTOM) should be validated using this specific method. + // Take care that internally this method commits to the to be validated cell the new input, + // in order to be able to interpret the validating boolean formula on the new input. + // After the formula has been evaluated the original cell content is restored. + // At present is only used in ScInputHandler::EnterHandler: handling this case in the + // regular IsDataValid method would have been unsafe since it can be invoked + // by ScFormulaCell::InterpretTail. + + struct CustomValidationPrivateAccess + { + // so IsDataValidCustom can be invoked only by ScInputHandler methods + friend class ScInputHandler; + private: + CustomValidationPrivateAccess() {} + }; + + bool IsDataValidCustom( + const OUString& rTest, const ScPatternAttr& rPattern, + const ScAddress& rPos, const CustomValidationPrivateAccess& ) const; + + bool IsDataValid( ScRefCellValue& rCell, const ScAddress& rPos ) const; + + /** Test, if formula is valid. */ + bool isFormulaResultsValidatable(const OUString& rTest, const ScAddress& rPos, SvNumberFormatter* pFormatter, + OUString& rStrResult, double& nVal, sal_uInt32& nFormat, bool& bIsVal) const; + + // TRUE -> break + bool DoError(weld::Window* pParent, const OUString& rInput, const ScAddress& rPos) const; + void DoCalcError( ScFormulaCell* pCell ) const; + + bool IsEmpty() const; + sal_uInt32 GetKey() const { return nKey; } + void SetKey(sal_uInt32 nNew) { nKey = nNew; } // only if not inserted! + + bool EqualEntries( const ScValidationData& r ) const; // for undo + + // sort (using std::set) by index + bool operator < ( const ScValidationData& r ) const { return nKey < r.nKey; } + +private: + /** Tries to fill the passed collection with list validation entries. + @descr Fills the list only if it is non-NULL, + @param pStrings (out-param) Optionally NULL, string list to fill with list validation entries. + @param pCell can be NULL if it is not necessary to which element in the list is selected. + @param rPos the base address for relative references. + @param rTokArr Formula token array. + @param rMatch (out-param) the index of the first item that matched, -1 if nothing matched. + @return true = Cell range found, rRange is valid, or an error entry stuffed into the list if pCell==NULL. */ + bool GetSelectionFromFormula( + std::vector<ScTypedStrData>* pStrings, ScRefCellValue& rCell, const ScAddress& rPos, + const ScTokenArray& rTokArr, int& rMatch) const; + + /** Tests, if pCell is equal to what the passed token array represents. */ + bool IsEqualToTokenArray( ScRefCellValue& rCell, const ScAddress& rPos, const ScTokenArray& rTokArr ) const; + + /** Tests, if contents of pCell occur in cell range referenced by own formula, or in a string list. */ + bool IsListValid( ScRefCellValue& rCell, const ScAddress& rPos ) const; + + /** Tests, if string or numeric data has valid text length. + @param pDataNumeric + nullptr if string data to be tested, else for numeric data a + properly initialized ScValidationDataIsNumeric struct, see + implementation. + */ + bool IsDataValidTextLen( std::u16string_view rTest, const ScAddress& rPos, + ScValidationDataIsNumeric* pDataNumeric ) const; +}; + +// list of conditions: + +struct CompareScValidationDataPtr +{ + bool operator()( std::unique_ptr<ScValidationData> const& lhs, std::unique_ptr<ScValidationData> const& rhs ) const { return (*lhs)<(*rhs); } +}; + +class ScValidationDataList +{ +private: + typedef std::set<std::unique_ptr<ScValidationData>, CompareScValidationDataPtr> ScValidationDataListDataType; + ScValidationDataListDataType maData; + +public: + ScValidationDataList() {} + ScValidationDataList(const ScValidationDataList& rList); + ScValidationDataList(ScDocument& rNewDoc, const ScValidationDataList& rList); + + typedef ScValidationDataListDataType::iterator iterator; + typedef ScValidationDataListDataType::const_iterator const_iterator; + + iterator begin(); + const_iterator begin() const; + iterator end(); + const_iterator end() const; + + void InsertNew( std::unique_ptr<ScValidationData> pNew ) + { maData.insert(std::move(pNew)); } + + ScValidationData* GetData( sal_uInt32 nKey ); + + void CompileXML(); + void UpdateReference( sc::RefUpdateContext& rCxt ); + void UpdateInsertTab( sc::RefUpdateInsertTabContext& rCxt ); + void UpdateDeleteTab( sc::RefUpdateDeleteTabContext& rCxt ); + void UpdateMoveTab( sc::RefUpdateMoveTabContext& rCxt ); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/viewopti.hxx b/sc/inc/viewopti.hxx new file mode 100644 index 0000000000..beb0530e88 --- /dev/null +++ b/sc/inc/viewopti.hxx @@ -0,0 +1,166 @@ +/* -*- 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 <svx/optgrid.hxx> + +#include "scdllapi.h" +#include "optutil.hxx" +#include "global.hxx" + +// View options + +enum ScViewOption +{ + VOPT_FORMULAS = 0, + VOPT_NULLVALS, + VOPT_SYNTAX, + VOPT_NOTES, + VOPT_FORMULAS_MARKS, + VOPT_VSCROLL, + VOPT_HSCROLL, + VOPT_TABCONTROLS, + VOPT_OUTLINER, + VOPT_HEADER, + VOPT_GRID, + VOPT_GRID_ONTOP, + VOPT_HELPLINES, + VOPT_ANCHOR, + VOPT_PAGEBREAKS, + VOPT_SUMMARY, + // tdf#96854 - move/copy sheet dialog: last used option for action (true: copy, false: move) + VOPT_COPY_SHEET, + VOPT_THEMEDCURSOR, +}; + +enum ScVObjType +{ + VOBJ_TYPE_OLE = 0, + VOBJ_TYPE_CHART, + VOBJ_TYPE_DRAW +}; + +#define MAX_OPT sal_uInt16(VOPT_THEMEDCURSOR)+1 +#define MAX_TYPE sal_uInt16(VOBJ_TYPE_DRAW)+1 + +// SvxGrid options with standard operators + +class ScGridOptions : public SvxOptionsGrid +{ +public: + ScGridOptions() {} + ScGridOptions( const SvxOptionsGrid& rOpt ) : SvxOptionsGrid( rOpt ) {} + + void SetDefaults(); + bool operator== ( const ScGridOptions& rOpt ) const; + bool operator!= ( const ScGridOptions& rOpt ) const { return !(operator==(rOpt)); } +}; + +// Options - View + +class SC_DLLPUBLIC ScViewOptions +{ +public: + ScViewOptions(); + ScViewOptions( const ScViewOptions& rCpy ); + ~ScViewOptions(); + + void SetDefaults(); + + void SetOption( ScViewOption eOpt, bool bNew ) { aOptArr[eOpt] = bNew; } + bool GetOption( ScViewOption eOpt ) const { return aOptArr[eOpt]; } + + void SetObjMode( ScVObjType eObj, ScVObjMode eMode ) { aModeArr[eObj] = eMode; } + ScVObjMode GetObjMode( ScVObjType eObj ) const { return aModeArr[eObj]; } + + void SetGridColor( const Color& rCol, const OUString& rName ) { aGridCol = rCol; aGridColName = rName;} + Color const & GetGridColor( OUString* pStrName = nullptr ) const; + + const ScGridOptions& GetGridOptions() const { return aGridOpt; } + void SetGridOptions( const ScGridOptions& rNew ) { aGridOpt = rNew; } + std::unique_ptr<SvxGridItem> CreateGridItem() const; + + const OUString& GetColorSchemeName() const { return sColorSchemeName; } + void SetColorSchemeName( const OUString& rName ) { sColorSchemeName = rName; } + + const Color& GetDocColor() const { return aDocCol; } + void SetDocColor(const Color& rDocColor) { aDocCol = rDocColor; } + + ScViewOptions& operator= ( const ScViewOptions& rCpy ); + bool operator== ( const ScViewOptions& rOpt ) const; + bool operator!= ( const ScViewOptions& rOpt ) const { return !(operator==(rOpt)); } + +private: + bool aOptArr [MAX_OPT]; + ScVObjMode aModeArr [MAX_TYPE]; + Color aGridCol; + OUString aGridColName; + ScGridOptions aGridOpt; + // The name of the color scheme + OUString sColorSchemeName = "Default"; + // The background color of the document + Color aDocCol; +}; + +// Item for the options dialog - View + +class SC_DLLPUBLIC ScTpViewItem final : public SfxPoolItem +{ +public: + ScTpViewItem( const ScViewOptions& rOpt ); + virtual ~ScTpViewItem() override; + + ScTpViewItem(ScTpViewItem const &) = default; + ScTpViewItem(ScTpViewItem &&) = default; + ScTpViewItem & operator =(ScTpViewItem const &) = delete; // due to SfxPoolItem + ScTpViewItem & operator =(ScTpViewItem &&) = delete; // due to SfxPoolItem + + virtual bool operator==( const SfxPoolItem& ) const override; + virtual ScTpViewItem* Clone( SfxItemPool *pPool = nullptr ) const override; + + const ScViewOptions& GetViewOptions() const { return theOptions; } + +private: + ScViewOptions theOptions; +}; + +// CfgItem for View options + +class ScViewCfg : public ScViewOptions +{ + ScLinkConfigItem aLayoutItem; + ScLinkConfigItem aDisplayItem; + ScLinkConfigItem aGridItem; + + DECL_LINK( LayoutCommitHdl, ScLinkConfigItem&, void ); + DECL_LINK( DisplayCommitHdl, ScLinkConfigItem&, void ); + DECL_LINK( GridCommitHdl, ScLinkConfigItem&, void ); + + static css::uno::Sequence<OUString> GetLayoutPropertyNames(); + static css::uno::Sequence<OUString> GetDisplayPropertyNames(); + static css::uno::Sequence<OUString> GetGridPropertyNames(); + +public: + ScViewCfg(); + + void SetOptions( const ScViewOptions& rNew ); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/viewuno.hxx b/sc/inc/viewuno.hxx new file mode 100644 index 0000000000..027b4753a9 --- /dev/null +++ b/sc/inc/viewuno.hxx @@ -0,0 +1,302 @@ +/* -*- 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 <rtl/ref.hxx> +#include <sfx2/sfxbasecontroller.hxx> +#include <svl/itemprop.hxx> +#include <svl/lstner.hxx> +#include <tools/gen.hxx> +#include <com/sun/star/view/XFormLayerAccess.hpp> +#include <com/sun/star/view/XSelectionSupplier.hpp> +#include <com/sun/star/sheet/XCellRangeReferrer.hpp> +#include <com/sun/star/sheet/XViewSplitable.hpp> +#include <com/sun/star/sheet/XViewFreezable.hpp> +#include <com/sun/star/sheet/XSelectedSheetsSupplier.hpp> +#include <com/sun/star/sheet/XSpreadsheetView.hpp> +#include <com/sun/star/sheet/XEnhancedMouseClickBroadcaster.hpp> +#include <com/sun/star/sheet/XActivationBroadcaster.hpp> +#include <com/sun/star/sheet/XViewPane.hpp> +#include <com/sun/star/sheet/XRangeSelection.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/container/XEnumerationAccess.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/datatransfer/XTransferableSupplier.hpp> +#include <comphelper/servicehelper.hxx> + +#include "types.hxx" + +namespace com::sun::star::view { class XSelectionChangeListener; } + +class ScTabViewShell; +class ScPreviewShell; + +#define SC_VIEWPANE_ACTIVE 0xFFFF + +// ScViewPaneBase not derived from OWeakObject +// to avoid duplicate OWeakObject in ScTabViewObj + +class ScViewPaneBase : public css::sheet::XViewPane, + public css::sheet::XCellRangeReferrer, + public css::view::XFormLayerAccess, + public css::lang::XServiceInfo, + public css::lang::XTypeProvider, + public SfxListener +{ +private: + ScTabViewShell* pViewShell; + sal_uInt16 nPane; // ScSplitPos or SC_VIEWPANE_ACTIVE + +protected: + css::awt::Rectangle GetVisArea() const; + +public: + ScViewPaneBase(ScTabViewShell* pViewSh, sal_uInt16 nP); + virtual ~ScViewPaneBase() override; + + ScTabViewShell* GetViewShell() const { return pViewShell; } + + virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; + + // XViewPane + virtual sal_Int32 SAL_CALL getFirstVisibleColumn() override; + virtual void SAL_CALL setFirstVisibleColumn( sal_Int32 nFirstVisibleColumn ) override; + virtual sal_Int32 SAL_CALL getFirstVisibleRow() override; + virtual void SAL_CALL setFirstVisibleRow( sal_Int32 nFirstVisibleRow ) override; + virtual css::table::CellRangeAddress SAL_CALL getVisibleRange() override; + + // XCellRangeReferrer + virtual css::uno::Reference< css::table::XCellRange > SAL_CALL + getReferredCells() override; + + // XFormLayerAccess + virtual css::uno::Reference< css::form::runtime::XFormController > SAL_CALL + getFormController( const css::uno::Reference< css::form::XForm >& Form ) override; + virtual sal_Bool SAL_CALL + isFormDesignMode( ) override; + virtual void SAL_CALL setFormDesignMode( sal_Bool DesignMode ) override; + + // XControlAccess + virtual css::uno::Reference< css::awt::XControl > SAL_CALL + getControl( const css::uno::Reference< css::awt::XControlModel >& xModel ) override; + + // XServiceInfo + 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; + + // XTypeProvider + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; + virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; +}; + +// ScViewPaneObj for direct use (including OWeakObject) + +class ScViewPaneObj final : public ScViewPaneBase, public cppu::OWeakObject +{ +public: + ScViewPaneObj(ScTabViewShell* pViewSh, sal_uInt16 nP); + virtual ~ScViewPaneObj() override; + + virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; + virtual void SAL_CALL acquire() noexcept override; + virtual void SAL_CALL release() noexcept override; +}; + +// OWeakObject is base of SfxBaseController -> use ScViewPaneBase + +class ScTabViewObj final : public ScViewPaneBase, + public SfxBaseController, + public css::sheet::XSpreadsheetView, + public css::sheet::XEnhancedMouseClickBroadcaster, + public css::sheet::XActivationBroadcaster, + public css::container::XEnumerationAccess, + public css::container::XIndexAccess, + public css::view::XSelectionSupplier, + public css::beans::XPropertySet, + public css::sheet::XViewSplitable, + public css::sheet::XViewFreezable, + public css::sheet::XRangeSelection, + public css::datatransfer::XTransferableSupplier, + public css::sheet::XSelectedSheetsSupplier +{ +private: + SfxItemPropertySet aPropSet; + std::vector<css::uno::Reference<css::view::XSelectionChangeListener> > + aSelectionChgListeners; + std::vector<css::uno::Reference<css::sheet::XRangeSelectionListener> > + aRangeSelListeners; + std::vector<css::uno::Reference<css::sheet::XRangeSelectionChangeListener> > + aRangeChgListeners; + std::vector<css::uno::Reference<css::beans::XPropertyChangeListener> > + aPropertyChgListeners; + std::vector<css::uno::Reference<css::awt::XEnhancedMouseClickHandler> > + aMouseClickHandlers; + std::vector<css::uno::Reference<css::sheet::XActivationEventListener> > + aActivationListeners; + SCTAB nPreviousTab; + bool bDrawSelModeSet; + bool bFilteredRangeSelection; + + rtl::Reference<ScViewPaneObj> GetObjectByIndex_Impl(sal_uInt16 nIndex) const; + sal_Int16 GetZoom() const; + void SetZoom(sal_Int16 Zoom); + sal_Int16 GetZoomType() const; + void SetZoomType(sal_Int16 ZoomType); + + css::uno::Reference< css::uno::XInterface > GetClickedObject(const Point& rPoint) const; + void EndMouseListening(); + void EndActivationListening(); + bool mbLeftMousePressed; +public: + ScTabViewObj(ScTabViewShell* pViewSh); + ScTabViewObj() = delete; + virtual ~ScTabViewObj() override; + + virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; + virtual void SAL_CALL acquire() noexcept override; + virtual void SAL_CALL release() noexcept override; + + void SelectionChanged(); + void VisAreaChanged(); + // bSameTabButMoved = true if the same sheet as before is activated, used after moving/copying/inserting/deleting a sheet + void SheetChanged( bool bSameTabButMoved ); + bool IsMouseListening() const; + /// @throws css::uno::RuntimeException + bool MousePressed( const css::awt::MouseEvent& e ); + /// @throws css::uno::RuntimeException + bool MouseReleased( const css::awt::MouseEvent& e ); + + void RangeSelDone( const OUString& rText ); + void RangeSelAborted( const OUString& rText ); + void RangeSelChanged( const OUString& rText ); + + // XSelectionSupplier + virtual sal_Bool SAL_CALL select( const css::uno::Any& aSelection ) override; + virtual css::uno::Any SAL_CALL getSelection() override; + virtual void SAL_CALL addSelectionChangeListener( const css::uno::Reference< css::view::XSelectionChangeListener >& xListener ) override; + virtual void SAL_CALL removeSelectionChangeListener( const css::uno::Reference< css::view::XSelectionChangeListener >& xListener ) override; + + //! XPrintable? + + // XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > + SAL_CALL getPropertySetInfo() override; + virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, + const css::uno::Any& aValue ) override; + virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override; + virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override; + virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, + const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override; + virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, + const css::uno::Reference< + css::beans::XVetoableChangeListener >& aListener ) override; + + // XEnumerationAccess + virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL + createEnumeration() override; + + // XIndexAccess + virtual sal_Int32 SAL_CALL getCount() override; + virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override; + + // XElementAccess + virtual css::uno::Type SAL_CALL getElementType() override; + virtual sal_Bool SAL_CALL hasElements() override; + + // XSpreadsheetView + virtual css::uno::Reference< css::sheet::XSpreadsheet > SAL_CALL + getActiveSheet() override; + virtual void SAL_CALL setActiveSheet( const css::uno::Reference< css::sheet::XSpreadsheet >& xActiveSheet ) override; + + //XEnhancedMouseClickBroadcaster + + virtual void SAL_CALL addEnhancedMouseClickHandler( const css::uno::Reference< + css::awt::XEnhancedMouseClickHandler >& aListener ) override; + virtual void SAL_CALL removeEnhancedMouseClickHandler( const css::uno::Reference< css::awt::XEnhancedMouseClickHandler >& aListener ) override; + + //XActivationBroadcaster + + virtual void SAL_CALL addActivationEventListener( const css::uno::Reference< css::sheet::XActivationEventListener >& aListener ) override; + virtual void SAL_CALL removeActivationEventListener( const css::uno::Reference< css::sheet::XActivationEventListener >& aListener ) override; + + // XViewSplitable + virtual sal_Bool SAL_CALL getIsWindowSplit() override; + virtual sal_Int32 SAL_CALL getSplitHorizontal() override; + virtual sal_Int32 SAL_CALL getSplitVertical() override; + virtual sal_Int32 SAL_CALL getSplitColumn() override; + virtual sal_Int32 SAL_CALL getSplitRow() override; + virtual void SAL_CALL splitAtPosition( sal_Int32 nPixelX, sal_Int32 nPixelY ) override; + + // XViewFreezable + virtual sal_Bool SAL_CALL hasFrozenPanes() override; + virtual void SAL_CALL freezeAtPosition( sal_Int32 nColumns, sal_Int32 nRows ) override; + + // XRangeSelection + virtual void SAL_CALL startRangeSelection( const css::uno::Sequence< css::beans::PropertyValue >& aArguments ) override; + virtual void SAL_CALL abortRangeSelection() override; + virtual void SAL_CALL addRangeSelectionListener( const css::uno::Reference< css::sheet::XRangeSelectionListener >& aListener ) override; + virtual void SAL_CALL removeRangeSelectionListener( const css::uno::Reference< css::sheet::XRangeSelectionListener >& aListener ) override; + virtual void SAL_CALL addRangeSelectionChangeListener( const css::uno::Reference< css::sheet::XRangeSelectionChangeListener >& aListener ) override; + virtual void SAL_CALL removeRangeSelectionChangeListener( const css::uno::Reference< css::sheet::XRangeSelectionChangeListener >& aListener ) override; + + // XServiceInfo + 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; + + // XTypeProvider + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; + virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + + // XTransferableSupplier + virtual css::uno::Reference< css::datatransfer::XTransferable > SAL_CALL getTransferable() override; + virtual void SAL_CALL insertTransferable( const css::uno::Reference< css::datatransfer::XTransferable >& xTrans ) override; + + // XSelectedSheetsSupplier + virtual css::uno::Sequence<sal_Int32> SAL_CALL getSelectedSheets() override; +}; + +class ScPreviewObj final : public SfxBaseController, + public SfxListener, + public css::sheet::XSelectedSheetsSupplier +{ + ScPreviewShell* mpViewShell; +public: + ScPreviewObj(ScPreviewShell* pViewSh); + virtual ~ScPreviewObj() override; + + virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType) override; + + virtual void SAL_CALL acquire() noexcept override; + virtual void SAL_CALL release() noexcept override; + + virtual void Notify(SfxBroadcaster&, const SfxHint& rHint) override; + + // XSelectedSheetsSupplier + virtual css::uno::Sequence<sal_Int32> SAL_CALL getSelectedSheets() override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/waitoff.hxx b/sc/inc/waitoff.hxx new file mode 100644 index 0000000000..76a1b3156d --- /dev/null +++ b/sc/inc/waitoff.hxx @@ -0,0 +1,38 @@ +/* -*- 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 <sal/types.h> + +#include <vcl/vclptr.hxx> + +namespace vcl { class Window; } + +class ScWaitCursorOff +{ +private: + VclPtr<vcl::Window> pWin; + sal_uInt32 nWaiters; +public: + ScWaitCursorOff( vcl::Window* pWin ); + ~ScWaitCursorOff(); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/warnpassword.hxx b/sc/inc/warnpassword.hxx new file mode 100644 index 0000000000..8b4135e2f2 --- /dev/null +++ b/sc/inc/warnpassword.hxx @@ -0,0 +1,35 @@ +/* -*- 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 + +class SfxMedium; +/** Static API helper functions. */ +class ScWarnPassword +{ +public: + /** Opens a query warning dialog. + @descr Pop up Query on export with a choice of yes/no if a + an encrypted password is imported. + @return true if yes and false if no. default to true. + */ + static bool WarningOnPassword(SfxMedium& rMedium); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/xmlwrap.hxx b/sc/inc/xmlwrap.hxx new file mode 100644 index 0000000000..bfae5363cf --- /dev/null +++ b/sc/inc/xmlwrap.hxx @@ -0,0 +1,94 @@ +/* -*- 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.hxx> +#include "importfilterdata.hxx" + +#include <comphelper/errcode.hxx> + +namespace com::sun::star { + namespace beans { struct PropertyValue; } + namespace frame { class XModel; } + namespace task { class XStatusIndicator; } + namespace uno { class XComponentContext; } + namespace uno { template <class E> class Sequence; } + namespace embed { class XStorage; } + namespace xml { + namespace sax { struct InputSource; class XParser; class XWriter; } + } +} + +class ScDocument; +class SfxMedium; +class ScMySharedData; +class ScDocShell; + +enum class ImportFlags { + Styles = 0x01, + Content = 0x02, + Metadata = 0x04, + Settings = 0x08, + All = Styles | Content | Metadata | Settings +}; +namespace o3tl +{ + template<> struct typed_flags<ImportFlags> : is_typed_flags<ImportFlags, 0x0f> {}; +} + + +class ScXMLImportWrapper +{ + sc::ImportPostProcessData maPostProcessData; + + ScDocShell& mrDocShell; + ScDocument& rDoc; + SfxMedium* pMedium; + css::uno::Reference< css::embed::XStorage > xStorage; + + css::uno::Reference< css::task::XStatusIndicator> GetStatusIndicator() const; + + ErrCodeMsg ImportFromComponent(const css::uno::Reference<css::uno::XComponentContext>& xContext, + const css::uno::Reference<css::frame::XModel>& xModel, + css::xml::sax::InputSource& aParserInput, + const OUString& sComponentName, const OUString& sDocName, + const css::uno::Sequence<css::uno::Any>& aArgs, + bool bMustBeSuccessful); + + bool ExportToComponent(const css::uno::Reference<css::uno::XComponentContext>& xContext, + const css::uno::Reference<css::frame::XModel>& xModel, + const css::uno::Reference<css::xml::sax::XWriter>& xWriter, + const css::uno::Sequence<css::beans::PropertyValue>& aDescriptor, + const OUString& sName, const OUString& sMediaType, const OUString& sComponentName, + const css::uno::Sequence<css::uno::Any>& aArgs, + std::unique_ptr<ScMySharedData>& pSharedData); + +public: + + ScXMLImportWrapper( + ScDocShell& rDocSh, SfxMedium* pM, css::uno::Reference<css::embed::XStorage> xStor ); + + bool Import( ImportFlags nMode, ErrCodeMsg& rError ); + bool Export(bool bStylesOnly); + + const sc::ImportPostProcessData& GetImportPostProcessData() const { return maPostProcessData;} +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/zforauto.hxx b/sc/inc/zforauto.hxx new file mode 100644 index 0000000000..d5f0ee956c --- /dev/null +++ b/sc/inc/zforauto.hxx @@ -0,0 +1,49 @@ +/* -*- 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 <rtl/ustring.hxx> +#include <i18nlangtag/lang.h> + +class SvStream; +class SvNumberFormatter; + +class ScNumFormatAbbrev +{ + OUString sFormatstring; + LanguageType eLanguage; + LanguageType eSysLanguage; + +public: + ScNumFormatAbbrev(); + ScNumFormatAbbrev(sal_uInt32 nFormat, const SvNumberFormatter& rFormatter); + void Load(SvStream& rStream, rtl_TextEncoding eByteStrSet); // loading of the numberformats + void Save(SvStream& rStream, rtl_TextEncoding eByteStrSet) const; // saving of the numberformats + void PutFormatIndex(sal_uInt32 nFormat, const SvNumberFormatter& rFormatter); + sal_uInt32 GetFormatIndex(SvNumberFormatter& rFormatter); + bool operator==(const ScNumFormatAbbrev& rNumFormat) const + { + return ((sFormatstring == rNumFormat.sFormatstring) && (eLanguage == rNumFormat.eLanguage) + && (eSysLanguage == rNumFormat.eSysLanguage)); + } + LanguageType GetLanguage() const { return eLanguage; } +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |