DataSourceType: use default value instead of std::optional
and use it in ScChart2DataSequence as well in preparation for a follow-up commit Change-Id: Id03c2c36f940723d64c14b3d32016f65b1c7fdcb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/207366 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org> Tested-by: Jenkins
This commit is contained in:
@@ -59,7 +59,28 @@ struct DataSourceModel
|
||||
~DataSourceModel();
|
||||
};
|
||||
|
||||
enum class DataSourceType: sal_Int32;
|
||||
/// Dimension/data source type. The STR_ and NUM_ values correspond to chartex
|
||||
/// ST_StringDimensionType and ST_NumericDimensionType, respectively. STR_CAT
|
||||
/// and NUM_VAL are also used by traditional (non-chartex) charts.
|
||||
enum class DataSourceType: sal_Int32
|
||||
{
|
||||
UNKNOWN = 0,
|
||||
|
||||
// String dimension types (strDim)
|
||||
STR_CAT, /// "cat" - categories (also used by traditional charts)
|
||||
STR_COLORSTR, /// "colorStr" - color strings
|
||||
STR_ENTITYID, /// "entityId" - entity identifiers
|
||||
// Numeric dimension types (numDim)
|
||||
NUM_VAL, /// "val" - numeric values (also used by traditional charts)
|
||||
NUM_X, /// "x" - x-axis values
|
||||
NUM_Y, /// "y" - y-axis values
|
||||
NUM_SIZE, /// "size" - size values (e.g. sunburst, treemap)
|
||||
NUM_COLORVAL, /// "colorVal" - color values (e.g. region map)
|
||||
// Non-dimension types (traditional charts only)
|
||||
POINTS, /// Data point size (e.g. bubble size in bubble charts).
|
||||
DATALABELS, /// Data point labels.
|
||||
};
|
||||
|
||||
|
||||
// Data source for chartex
|
||||
struct DataSourceCxModel
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#define INCLUDED_OOX_DRAWINGML_CHART_DATASOURCECONVERTER_HXX
|
||||
|
||||
#include <drawingml/chart/converterbase.hxx>
|
||||
#include <optional>
|
||||
#include <oox/drawingml/chart/datasourcemodel.hxx>
|
||||
|
||||
namespace com::sun::star {
|
||||
namespace chart2::data { class XDataSequence; }
|
||||
@@ -29,8 +29,6 @@ namespace com::sun::star {
|
||||
|
||||
namespace oox::drawingml::chart {
|
||||
|
||||
enum class DataSourceType : sal_Int32;
|
||||
|
||||
struct DataSequenceModel;
|
||||
|
||||
class DataSequenceConverter final : public ConverterBase< DataSequenceModel >
|
||||
@@ -43,7 +41,7 @@ public:
|
||||
@param oDimType If set, stores this as the ChartExDimType property. */
|
||||
css::uno::Reference< css::chart2::data::XDataSequence >
|
||||
createDataSequence( const OUString& rRole,
|
||||
std::optional<DataSourceType> oDimType = std::nullopt );
|
||||
DataSourceType eDimType );
|
||||
};
|
||||
|
||||
|
||||
@@ -59,7 +57,7 @@ public:
|
||||
@param oDimType If set, forwarded to DataSequenceConverter. */
|
||||
css::uno::Reference< css::chart2::data::XDataSequence >
|
||||
createDataSequence( const OUString& rRole,
|
||||
std::optional<DataSourceType> oDimType = std::nullopt );
|
||||
DataSourceType eDimType );
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -213,26 +213,6 @@ struct LayoutPropsModel
|
||||
std::optional<GeographyModel> mxGeography;
|
||||
};
|
||||
|
||||
/// Dimension/data source type. The STR_ and NUM_ values correspond to chartex
|
||||
/// ST_StringDimensionType and ST_NumericDimensionType, respectively. STR_CAT
|
||||
/// and NUM_VAL are also used by traditional (non-chartex) charts.
|
||||
enum class DataSourceType: sal_Int32
|
||||
{
|
||||
// String dimension types (strDim)
|
||||
STR_CAT, /// "cat" - categories (also used by traditional charts)
|
||||
STR_COLORSTR, /// "colorStr" - color strings
|
||||
STR_ENTITYID, /// "entityId" - entity identifiers
|
||||
// Numeric dimension types (numDim)
|
||||
NUM_VAL, /// "val" - numeric values (also used by traditional charts)
|
||||
NUM_X, /// "x" - x-axis values
|
||||
NUM_Y, /// "y" - y-axis values
|
||||
NUM_SIZE, /// "size" - size values (e.g. sunburst, treemap)
|
||||
NUM_COLORVAL, /// "colorVal" - color values (e.g. region map)
|
||||
// Non-dimension types (traditional charts only)
|
||||
POINTS, /// Data point size (e.g. bubble size in bubble charts).
|
||||
DATALABELS, /// Data point labels.
|
||||
};
|
||||
|
||||
struct SeriesModel
|
||||
{
|
||||
typedef ModelMap< DataSourceType, DataSourceModel > DataSourceMap;
|
||||
|
||||
@@ -40,7 +40,7 @@ DataSequenceConverter::~DataSequenceConverter()
|
||||
}
|
||||
|
||||
Reference< XDataSequence > DataSequenceConverter::createDataSequence(
|
||||
const OUString& rRole, std::optional<DataSourceType> oDimType )
|
||||
const OUString& rRole, DataSourceType eDimType )
|
||||
{
|
||||
// create data sequence from data source model (virtual call at chart converter)
|
||||
Reference< XDataSequence > xDataSeq;
|
||||
@@ -85,8 +85,8 @@ Reference< XDataSequence > DataSequenceConverter::createDataSequence(
|
||||
aSeqProp.setProperty(PROP_NumberFormatKey, nKey);
|
||||
|
||||
// store chartex dimension info for round-trip export
|
||||
if (oDimType)
|
||||
aSeqProp.setProperty(PROP_ChartExDimType, static_cast<sal_Int32>(*oDimType));
|
||||
if (eDimType != DataSourceType::UNKNOWN)
|
||||
aSeqProp.setProperty(PROP_ChartExDimType, static_cast<sal_Int32>(eDimType));
|
||||
if (!mrModel.maFormula.isEmpty())
|
||||
aSeqProp.setProperty(PROP_ChartExFormula, mrModel.maFormula);
|
||||
if (!mrModel.maNFormula.isEmpty())
|
||||
@@ -105,13 +105,13 @@ DataSourceConverter::~DataSourceConverter()
|
||||
}
|
||||
|
||||
Reference< XDataSequence > DataSourceConverter::createDataSequence(
|
||||
const OUString& rRole, std::optional<DataSourceType> oDimType )
|
||||
const OUString& rRole, DataSourceType eDimType )
|
||||
{
|
||||
Reference< XDataSequence > xDataSeq;
|
||||
if( mrModel.mxDataSeq.is() )
|
||||
{
|
||||
DataSequenceConverter aDataSeqConv( *this, *mrModel.mxDataSeq );
|
||||
xDataSeq = aDataSeqConv.createDataSequence( rRole, oDimType );
|
||||
xDataSeq = aDataSeqConv.createDataSequence( rRole, eDimType );
|
||||
}
|
||||
return xDataSeq;
|
||||
}
|
||||
|
||||
@@ -74,14 +74,14 @@ Reference< XLabeledDataSequence > lclCreateLabeledDataSequence(
|
||||
const ConverterRoot& rParent,
|
||||
DataSourceModel* pValues, const OUString& rRole,
|
||||
TextModel* pTitle = nullptr,
|
||||
std::optional<DataSourceType> oDimType = std::nullopt )
|
||||
DataSourceType eDimType = DataSourceType::UNKNOWN )
|
||||
{
|
||||
// create data sequence for values
|
||||
Reference< XDataSequence > xValueSeq;
|
||||
if( pValues )
|
||||
{
|
||||
DataSourceConverter aSourceConv( rParent, *pValues );
|
||||
xValueSeq = aSourceConv.createDataSequence( rRole, oDimType );
|
||||
xValueSeq = aSourceConv.createDataSequence( rRole, eDimType );
|
||||
}
|
||||
|
||||
// create data sequence for title
|
||||
|
||||
@@ -65,7 +65,7 @@ Reference< XDataSequence > TextConverter::createDataSequence( const OUString& rR
|
||||
if( mrModel.mxDataSeq.is() )
|
||||
{
|
||||
DataSequenceConverter aDataSeqConv( *this, *mrModel.mxDataSeq );
|
||||
xDataSeq = aDataSeqConv.createDataSequence( rRole );
|
||||
xDataSeq = aDataSeqConv.createDataSequence( rRole, DataSourceType::UNKNOWN );
|
||||
}
|
||||
return xDataSeq;
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
#include <com/sun/star/util/XCloneable.hpp>
|
||||
#include <com/sun/star/util/XModifyBroadcaster.hpp>
|
||||
#include <cppuhelper/implbase.hxx>
|
||||
#include <oox/drawingml/chart/datasourcemodel.hxx>
|
||||
#include <rtl/ustring.hxx>
|
||||
#include <svl/itemprop.hxx>
|
||||
|
||||
@@ -48,6 +49,8 @@
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
using oox::drawingml::chart::DataSourceType;
|
||||
|
||||
namespace com::sun::star::chart2::data { class XLabeledDataSequence; }
|
||||
|
||||
class ScDocument;
|
||||
@@ -366,7 +369,7 @@ private:
|
||||
// properties
|
||||
css::chart2::data::DataSequenceRole m_aRole;
|
||||
bool m_bIncludeHiddenCells;
|
||||
sal_Int32 m_eDimType; // actually oox::drawingml::chart::DataSourceType
|
||||
DataSourceType m_eDimType;
|
||||
OUString m_sFormula; // from <cx:f>
|
||||
OUString m_sNFormula; // from <cx:nf>
|
||||
|
||||
|
||||
@@ -3403,7 +3403,10 @@ void SAL_CALL ScChart2DataSequence::setPropertyValue(
|
||||
}
|
||||
else if( rPropertyName == "ChartExDimType" )
|
||||
{
|
||||
if ( !(rValue >>= m_eDimType))
|
||||
sal_Int32 nDimType;
|
||||
if (rValue >>= nDimType)
|
||||
m_eDimType = static_cast<DataSourceType>(nDimType);
|
||||
else
|
||||
throw lang::IllegalArgumentException();
|
||||
}
|
||||
else if( rPropertyName == "ChartExFormula" )
|
||||
@@ -3452,7 +3455,7 @@ uno::Any SAL_CALL ScChart2DataSequence::getPropertyValue(const OUString& rProper
|
||||
aRet <<= bHasStringLabel;
|
||||
}
|
||||
else if ( rPropertyName == "ChartExDimType" )
|
||||
aRet <<= m_eDimType;
|
||||
aRet <<= static_cast<sal_Int32>(m_eDimType);
|
||||
else if ( rPropertyName == "ChartExFormula" )
|
||||
aRet <<= m_sFormula;
|
||||
else if ( rPropertyName == "ChartExNFormula" )
|
||||
|
||||
Reference in New Issue
Block a user