1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <RegressionEquationItemConverter.hxx>
21 #include "SchWhichPairs.hxx"
22 #include <ItemPropertyMap.hxx>
23 #include <GraphicPropertyItemConverter.hxx>
24 #include <CharacterPropertyItemConverter.hxx>
25 #include <unonames.hxx>
26 #include <com/sun/star/beans/XPropertySet.hpp>
28 #include <svl/intitem.hxx>
32 using namespace ::com::sun::star
;
34 namespace chart::wrapper
{
38 ItemPropertyMapType
& lcl_GetEquationPropertyMap()
40 static ItemPropertyMapType aEquationPropertyMap
;
42 return aEquationPropertyMap
;
45 } // anonymous namespace
47 RegressionEquationItemConverter::RegressionEquationItemConverter(
48 const css::uno::Reference
< css::beans::XPropertySet
> & rPropertySet
,
49 SfxItemPool
& rItemPool
,
51 const uno::Reference
< lang::XMultiServiceFactory
> & xNamedPropertyContainerFactory
,
52 const std::optional
<awt::Size
>& pRefSize
) :
53 ItemConverter( rPropertySet
, rItemPool
)
55 m_aConverters
.emplace_back( new GraphicPropertyItemConverter(
56 rPropertySet
, rItemPool
, rDrawModel
,
57 xNamedPropertyContainerFactory
,
58 GraphicObjectType::LineAndFillProperties
));
60 m_aConverters
.emplace_back(
61 new CharacterPropertyItemConverter(rPropertySet
, rItemPool
, pRefSize
, u
"ReferencePageSize"_ustr
));
64 RegressionEquationItemConverter::~RegressionEquationItemConverter()
68 void RegressionEquationItemConverter::FillItemSet( SfxItemSet
& rOutItemSet
) const
70 for( const auto& pConv
: m_aConverters
)
71 pConv
->FillItemSet( rOutItemSet
);
74 ItemConverter::FillItemSet( rOutItemSet
);
77 bool RegressionEquationItemConverter::ApplyItemSet( const SfxItemSet
& rItemSet
)
81 for( const auto& pConv
: m_aConverters
)
82 bResult
= pConv
->ApplyItemSet( rItemSet
);
85 return ItemConverter::ApplyItemSet( rItemSet
) || bResult
;
88 const WhichRangesContainer
& RegressionEquationItemConverter::GetWhichPairs() const
90 // must span all used items!
91 return nRegEquationWhichPairs
;
94 bool RegressionEquationItemConverter::GetItemProperty( tWhichIdType nWhichId
, tPropertyNameWithMemberId
& rOutProperty
) const
96 ItemPropertyMapType
& rMap( lcl_GetEquationPropertyMap());
97 ItemPropertyMapType::const_iterator
aIt( rMap
.find( nWhichId
));
99 if( aIt
== rMap
.end())
102 rOutProperty
=(*aIt
).second
;
106 bool RegressionEquationItemConverter::ApplySpecialItem(
107 sal_uInt16 nWhichId
, const SfxItemSet
& rItemSet
)
109 bool bChanged
= false;
113 case SID_ATTR_NUMBERFORMAT_VALUE
:
115 uno::Any
aValue( static_cast< sal_Int32
>(
116 static_cast< const SfxUInt32Item
& >(
117 rItemSet
.Get( nWhichId
)).GetValue()));
118 if (GetPropertySet()->getPropertyValue(CHART_UNONAME_NUMFMT
) != aValue
)
120 GetPropertySet()->setPropertyValue(CHART_UNONAME_NUMFMT
, aValue
);
130 void RegressionEquationItemConverter::FillSpecialItem(
131 sal_uInt16 nWhichId
, SfxItemSet
& rOutItemSet
) const
135 case SID_ATTR_NUMBERFORMAT_VALUE
:
137 sal_Int32 nFormatKey
= 0;
138 if (GetPropertySet()->getPropertyValue(CHART_UNONAME_NUMFMT
) >>= nFormatKey
)
140 rOutItemSet
.Put( SfxUInt32Item( nWhichId
, nFormatKey
));
149 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */