LibreOffice Module chart2 (master) 1
RegressionEquationItemConverter.cxx
Go to the documentation of this file.
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
21#include "SchWhichPairs.hxx"
22#include <ItemPropertyMap.hxx>
25#include <unonames.hxx>
26#include <com/sun/star/beans/XPropertySet.hpp>
27
28#include <svl/intitem.hxx>
29
30#include <memory>
31
32using namespace ::com::sun::star;
33
34namespace chart::wrapper {
35
36namespace {
37
38ItemPropertyMapType & lcl_GetEquationPropertyMap()
39{
40 static ItemPropertyMapType aEquationPropertyMap;
41
42 return aEquationPropertyMap;
43};
44
45} // anonymous namespace
46
48 const css::uno::Reference< css::beans::XPropertySet > & rPropertySet,
49 SfxItemPool& rItemPool,
50 SdrModel& rDrawModel,
51 const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory,
52 const awt::Size* pRefSize ) :
53 ItemConverter( rPropertySet, rItemPool )
54{
56 rPropertySet, rItemPool, rDrawModel,
57 xNamedPropertyContainerFactory,
59
60 m_aConverters.emplace_back(
61 new CharacterPropertyItemConverter(rPropertySet, rItemPool, pRefSize, "ReferencePageSize"));
62}
63
65{
66}
67
69{
70 for( const auto& pConv : m_aConverters )
71 pConv->FillItemSet( rOutItemSet );
72
73 // own items
74 ItemConverter::FillItemSet( rOutItemSet );
75}
76
78{
79 bool bResult = false;
80
81 for( const auto& pConv : m_aConverters )
82 bResult = pConv->ApplyItemSet( rItemSet );
83
84 // own items
85 return ItemConverter::ApplyItemSet( rItemSet ) || bResult;
86}
87
89{
90 // must span all used items!
92}
93
95{
96 ItemPropertyMapType & rMap( lcl_GetEquationPropertyMap());
97 ItemPropertyMapType::const_iterator aIt( rMap.find( nWhichId ));
98
99 if( aIt == rMap.end())
100 return false;
101
102 rOutProperty =(*aIt).second;
103 return true;
104}
105
107 sal_uInt16 nWhichId, const SfxItemSet & rItemSet )
108{
109 bool bChanged = false;
110
111 switch( nWhichId )
112 {
113 case SID_ATTR_NUMBERFORMAT_VALUE:
114 {
115 uno::Any aValue( static_cast< sal_Int32 >(
116 static_cast< const SfxUInt32Item & >(
117 rItemSet.Get( nWhichId )).GetValue()));
119 {
120 GetPropertySet()->setPropertyValue(CHART_UNONAME_NUMFMT, aValue);
121 bChanged = true;
122 }
123 }
124 break;
125 }
126
127 return bChanged;
128}
129
131 sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const
132{
133 switch( nWhichId )
134 {
135 case SID_ATTR_NUMBERFORMAT_VALUE:
136 {
137 sal_Int32 nFormatKey = 0;
139 {
140 rOutItemSet.Put( SfxUInt32Item( nWhichId, nFormatKey ));
141 }
142 }
143 break;
144 }
145}
146
147}
148
149/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const WhichRangesContainer nRegEquationWhichPairs(svl::Items< XATTR_LINE_FIRST, XATTR_LINE_LAST, XATTR_FILL_FIRST, XATTR_FILL_LAST, SDRATTR_SHADOW_FIRST, SDRATTR_SHADOW_LAST, EE_ITEMS_START, EE_ITEMS_END, SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_VALUE, SID_CHAR_DLG_PREVIEW_STRING, SID_CHAR_DLG_PREVIEW_STRING >)
sal_uInt32 GetValue() const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
This class serves for conversion between properties of an XPropertySet and SfxItems in SfxItemSets.
virtual void FillItemSet(SfxItemSet &rOutItemSet) const
applies all properties that can be mapped to items into the given item set.
std::pair< tPropertyNameType, tMemberIdType > tPropertyNameWithMemberId
const css::uno::Reference< css::beans::XPropertySet > & GetPropertySet() const
Returns the XPropertySet that was given in the CTOR and is used to apply items in ApplyItemSet().
virtual bool ApplyItemSet(const SfxItemSet &rItemSet)
applies all properties that are results of a conversion from all items in rItemSet to the internal XP...
virtual void FillSpecialItem(sal_uInt16 nWhichId, SfxItemSet &rOutItemSet) const override
for items that can not be mapped directly to a property.
std::vector< std::unique_ptr< ItemConverter > > m_aConverters
virtual const WhichRangesContainer & GetWhichPairs() const override
implement this method to provide an array of which-ranges
RegressionEquationItemConverter(const css::uno::Reference< css::beans::XPropertySet > &rPropertySet, SfxItemPool &rItemPool, SdrModel &rDrawModel, const css::uno::Reference< css::lang::XMultiServiceFactory > &xNamedPropertyContainerFactory, const css::awt::Size *pRefSize)
virtual bool ApplySpecialItem(sal_uInt16 nWhichId, const SfxItemSet &rItemSet) override
for items that can not be mapped directly to a property.
virtual void FillItemSet(SfxItemSet &rOutItemSet) const override
applies all properties that can be mapped to items into the given item set.
virtual bool GetItemProperty(tWhichIdType nWhichId, tPropertyNameWithMemberId &rOutProperty) const override
implement this method to return a Property object for a given which id.
virtual bool ApplyItemSet(const SfxItemSet &rItemSet) override
applies all properties that are results of a conversion from all items in rItemSet to the internal XP...
std::map< ItemConverter::tWhichIdType, std::pair< ItemConverter::tPropertyNameType, ItemConverter::tMemberIdType > > ItemPropertyMapType
bool getPropertyValue(ValueType &rValue, css::uno::Reference< css::beans::XPropertySet > const &xPropSet, OUString const &propName)
constexpr OUStringLiteral CHART_UNONAME_NUMFMT
Definition: unonames.hxx:20