| 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 |
|
| 10 |
#include <DataTableItemConverter.hxx> |
| 11 |
#include <ItemPropertyMap.hxx> |
| 12 |
#include <CharacterPropertyItemConverter.hxx> |
| 13 |
#include <GraphicPropertyItemConverter.hxx> |
| 14 |
#include <chartview/ChartSfxItemIds.hxx> |
| 15 |
#include "SchWhichPairs.hxx" |
| 16 |
#include <ChartModel.hxx> |
| 17 |
#include <memory> |
| 18 |
|
| 19 |
using namespace css; |
| 20 |
|
| 21 |
namespace chart::wrapper |
| 22 |
{ |
| 23 |
namespace |
| 24 |
{ |
| 25 |
ItemPropertyMapType& lclDataTablePropertyMap() |
| 26 |
{ |
| 27 |
static ItemPropertyMapType aPropertyMap{ |
| 28 |
{ SCHATTR_DATA_TABLE_HORIZONTAL_BORDER, { "HBorder", 0 } }, |
| 29 |
{ SCHATTR_DATA_TABLE_VERTICAL_BORDER, { "VBorder", 0 } }, |
| 30 |
{ SCHATTR_DATA_TABLE_OUTLINE, { "Outline", 0 } }, |
| 31 |
{ SCHATTR_DATA_TABLE_KEYS, { "Keys", 0 } }, |
| 32 |
}; |
| 33 |
return aPropertyMap; |
| 34 |
}; |
| 35 |
} |
| 36 |
|
| 37 |
DataTableItemConverter::DataTableItemConverter( |
| 38 |
const uno::Reference<beans::XPropertySet>& rPropertySet, SfxItemPool& rItemPool, |
| 39 |
SdrModel& rDrawModel, const rtl::Reference<::chart::ChartModel>& xChartDoc) |
| 40 |
: ItemConverter(rPropertySet, rItemPool) |
| 41 |
{ |
| 42 |
m_aConverters.emplace_back(new GraphicPropertyItemConverter( |
| 43 |
rPropertySet, rItemPool, rDrawModel, xChartDoc, GraphicObjectType::LineProperties)); |
| 44 |
m_aConverters.emplace_back(new CharacterPropertyItemConverter(rPropertySet, rItemPool)); |
| 45 |
} |
| 46 |
|
| 47 |
DataTableItemConverter::~DataTableItemConverter() = default; |
| 48 |
|
| 49 |
void DataTableItemConverter::FillItemSet(SfxItemSet& rOutItemSet) const |
| 50 |
{ |
| 51 |
for (const auto& pConv : m_aConverters) |
| 52 |
{ |
| 53 |
pConv->FillItemSet(rOutItemSet); |
| 54 |
} |
| 55 |
|
| 56 |
// own items |
| 57 |
ItemConverter::FillItemSet(rOutItemSet); |
| 58 |
} |
| 59 |
|
| 60 |
bool DataTableItemConverter::ApplyItemSet(const SfxItemSet& rItemSet) |
| 61 |
{ |
| 62 |
bool bResult = false; |
| 63 |
|
| 64 |
for (const auto& pConv : m_aConverters) |
| 65 |
{ |
| 66 |
bResult = pConv->ApplyItemSet(rItemSet) || bResult; |
| 67 |
} |
| 68 |
|
| 69 |
// own items |
| 70 |
return ItemConverter::ApplyItemSet(rItemSet) || bResult; |
| 71 |
} |
| 72 |
|
| 73 |
const WhichRangesContainer& DataTableItemConverter::GetWhichPairs() const |
| 74 |
{ |
| 75 |
return nDataTableWhichPairs; |
| 76 |
} |
| 77 |
|
| 78 |
bool DataTableItemConverter::GetItemProperty(tWhichIdType nWhichId, |
| 79 |
tPropertyNameWithMemberId& rOutProperty) const |
| 80 |
{ |
| 81 |
ItemPropertyMapType& rMap(lclDataTablePropertyMap()); |
| 82 |
auto aIt = rMap.find(nWhichId); |
| 83 |
if (aIt == rMap.cend()) |
| 84 |
return false; |
| 85 |
|
| 86 |
rOutProperty = (*aIt).second; |
| 87 |
|
| 88 |
return true; |
| 89 |
} |
| 90 |
} |
| 91 |
|
| 92 |
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |