| 1 |
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
| 2 |
/* |
| 3 |
* This file is part of the LibreOffice project. |
| 4 |
* |
| 5 |
* This Source Code Form is subject to the terms of the Mozilla Public |
| 6 |
* License, v. 2.0. If a copy of the MPL was not distributed with this |
| 7 |
* file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 8 |
* |
| 9 |
* This file incorporates work covered by the following license notice: |
| 10 |
* |
| 11 |
* Licensed to the Apache Software Foundation (ASF) under one or more |
| 12 |
* contributor license agreements. See the NOTICE file distributed |
| 13 |
* with this work for additional information regarding copyright |
| 14 |
* ownership. The ASF licenses this file to you under the Apache |
| 15 |
* License, Version 2.0 (the "License"); you may not use this file |
| 16 |
* except in compliance with the License. You may obtain a copy of |
| 17 |
* the License at http://www.apache.org/licenses/LICENSE-2.0 . |
| 18 |
*/ |
| 19 |
|
| 20 |
#include <MultipleChartConverters.hxx> |
| 21 |
|
| 22 |
#include "SchWhichPairs.hxx" |
| 23 |
#include <AxisItemConverter.hxx> |
| 24 |
#include <StatisticsItemConverter.hxx> |
| 25 |
#include <GraphicPropertyItemConverter.hxx> |
| 26 |
#include <DataPointItemConverter.hxx> |
| 27 |
#include <ChartModel.hxx> |
| 28 |
#include <Diagram.hxx> |
| 29 |
#include <DataSeries.hxx> |
| 30 |
#include <GridProperties.hxx> |
| 31 |
#include <TitleHelper.hxx> |
| 32 |
#include <TitleItemConverter.hxx> |
| 33 |
#include <Axis.hxx> |
| 34 |
#include <AxisHelper.hxx> |
| 35 |
#include <ChartView.hxx> |
| 36 |
|
| 37 |
using namespace ::com::sun::star; |
| 38 |
using ::com::sun::star::uno::Reference; |
| 39 |
|
| 40 |
namespace chart::wrapper { |
| 41 |
|
| 42 |
AllAxisItemConverter::AllAxisItemConverter( |
| 43 |
const rtl::Reference<::chart::ChartModel> & xChartModel, |
| 44 |
SfxItemPool& rItemPool, |
| 45 |
SdrModel& rDrawModel, |
| 46 |
const std::optional<awt::Size>& pRefSize ) |
| 47 |
: MultipleItemConverter( rItemPool ) |
| 48 |
{ |
| 49 |
rtl::Reference< Diagram > xDiagram( xChartModel->getFirstChartDiagram() ); |
| 50 |
const std::vector< rtl::Reference< Axis > > aElementList = AxisHelper::getAllAxesOfDiagram( xDiagram ); |
| 51 |
for( rtl::Reference< Axis > const & axis : aElementList ) |
| 52 |
{ |
| 53 |
m_aConverters.emplace_back( new ::chart::wrapper::AxisItemConverter( |
| 54 |
uno::Reference< beans::XPropertySet >(axis), |
| 55 |
rItemPool, rDrawModel, |
| 56 |
xChartModel, nullptr, nullptr, |
| 57 |
pRefSize)); |
| 58 |
} |
| 59 |
} |
| 60 |
|
| 61 |
AllAxisItemConverter::~AllAxisItemConverter() |
| 62 |
{ |
| 63 |
} |
| 64 |
|
| 65 |
const WhichRangesContainer& AllAxisItemConverter::GetWhichPairs() const |
| 66 |
{ |
| 67 |
// must span all used items! |
| 68 |
return nAllAxisWhichPairs; |
| 69 |
} |
| 70 |
|
| 71 |
AllGridItemConverter::AllGridItemConverter( |
| 72 |
const rtl::Reference<::chart::ChartModel> & xChartModel, |
| 73 |
SfxItemPool& rItemPool, |
| 74 |
SdrModel& rDrawModel ) |
| 75 |
: MultipleItemConverter( rItemPool ) |
| 76 |
{ |
| 77 |
rtl::Reference< Diagram > xDiagram( xChartModel->getFirstChartDiagram() ); |
| 78 |
std::vector< rtl::Reference< GridProperties > > aElementList( AxisHelper::getAllGrids( xDiagram ) ); |
| 79 |
for( rtl::Reference< GridProperties > const & xObjectProperties : aElementList ) |
| 80 |
{ |
| 81 |
m_aConverters.emplace_back( new ::chart::wrapper::GraphicPropertyItemConverter( |
| 82 |
xObjectProperties, rItemPool, rDrawModel, xChartModel, |
| 83 |
::chart::wrapper::GraphicObjectType::LineProperties ) ); |
| 84 |
} |
| 85 |
} |
| 86 |
|
| 87 |
AllGridItemConverter::~AllGridItemConverter() |
| 88 |
{ |
| 89 |
} |
| 90 |
|
| 91 |
const WhichRangesContainer& AllGridItemConverter::GetWhichPairs() const |
| 92 |
{ |
| 93 |
// must span all used items! |
| 94 |
return nGridWhichPairs; |
| 95 |
} |
| 96 |
|
| 97 |
AllDataLabelItemConverter::AllDataLabelItemConverter( |
| 98 |
const rtl::Reference<::chart::ChartModel> & xChartModel, |
| 99 |
SfxItemPool& rItemPool, |
| 100 |
SdrModel& rDrawModel ) |
| 101 |
: MultipleItemConverter( rItemPool ) |
| 102 |
{ |
| 103 |
std::vector< rtl::Reference< DataSeries > > aSeriesList = |
| 104 |
xChartModel->getDataSeries(); |
| 105 |
|
| 106 |
for (auto const& series : aSeriesList) |
| 107 |
{ |
| 108 |
uno::Reference< uno::XComponentContext> xContext;//do not need Context for label properties |
| 109 |
|
| 110 |
sal_Int32 nNumberFormat = series->getExplicitNumberFormatKeyForDataLabel(); |
| 111 |
sal_Int32 nPercentNumberFormat=ChartView::getExplicitPercentageNumberFormatKeyForDataLabel( |
| 112 |
series,xChartModel); |
| 113 |
|
| 114 |
m_aConverters.emplace_back( |
| 115 |
new ::chart::wrapper::DataPointItemConverter( |
| 116 |
xChartModel, xContext, series, series, rItemPool, rDrawModel, |
| 117 |
GraphicObjectType::FilledDataPoint, |
| 118 |
std::nullopt, true, false, 0, true, nNumberFormat, nPercentNumberFormat)); |
| 119 |
} |
| 120 |
} |
| 121 |
|
| 122 |
AllDataLabelItemConverter::~AllDataLabelItemConverter() |
| 123 |
{ |
| 124 |
} |
| 125 |
|
| 126 |
const WhichRangesContainer& AllDataLabelItemConverter::GetWhichPairs() const |
| 127 |
{ |
| 128 |
// must span all used items! |
| 129 |
return nDataLabelWhichPairs; |
| 130 |
} |
| 131 |
|
| 132 |
AllTitleItemConverter::AllTitleItemConverter( |
| 133 |
const rtl::Reference<::chart::ChartModel> & xChartModel, |
| 134 |
SfxItemPool& rItemPool, |
| 135 |
SdrModel& rDrawModel ) |
| 136 |
: MultipleItemConverter( rItemPool ) |
| 137 |
{ |
| 138 |
for(sal_Int32 nTitle = TitleHelper::TITLE_BEGIN; nTitle < TitleHelper::NORMAL_TITLE_END; nTitle++ ) |
| 139 |
{ |
| 140 |
rtl::Reference< Title > xTitle( TitleHelper::getTitle( TitleHelper::eTitleType(nTitle), xChartModel ) ); |
| 141 |
if(!xTitle.is()) |
| 142 |
continue; |
| 143 |
m_aConverters.emplace_back( |
| 144 |
new ::chart::wrapper::TitleItemConverter( |
| 145 |
uno::Reference< beans::XPropertySet >( xTitle ), |
| 146 |
rItemPool, rDrawModel, xChartModel, std::nullopt)); |
| 147 |
} |
| 148 |
} |
| 149 |
|
| 150 |
AllTitleItemConverter::~AllTitleItemConverter() |
| 151 |
{ |
| 152 |
} |
| 153 |
|
| 154 |
const WhichRangesContainer& AllTitleItemConverter::GetWhichPairs() const |
| 155 |
{ |
| 156 |
// must span all used items! |
| 157 |
return nTitleWhichPairs; |
| 158 |
} |
| 159 |
|
| 160 |
AllSeriesStatisticsConverter::AllSeriesStatisticsConverter( |
| 161 |
const rtl::Reference<::chart::ChartModel> & xChartModel, |
| 162 |
SfxItemPool& rItemPool ) |
| 163 |
: MultipleItemConverter( rItemPool ) |
| 164 |
{ |
| 165 |
std::vector< rtl::Reference< DataSeries > > aSeriesList = |
| 166 |
xChartModel->getDataSeries(); |
| 167 |
|
| 168 |
for (auto const& series : aSeriesList) |
| 169 |
{ |
| 170 |
m_aConverters.emplace_back( new ::chart::wrapper::StatisticsItemConverter( |
| 171 |
xChartModel, series, rItemPool )); |
| 172 |
} |
| 173 |
} |
| 174 |
|
| 175 |
AllSeriesStatisticsConverter::~AllSeriesStatisticsConverter() |
| 176 |
{} |
| 177 |
|
| 178 |
const WhichRangesContainer& AllSeriesStatisticsConverter::GetWhichPairs() const |
| 179 |
{ |
| 180 |
// must span all used items! |
| 181 |
return nStatWhichPairs; |
| 182 |
} |
| 183 |
|
| 184 |
} |
| 185 |
|
| 186 |
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |