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"
23 #include "ItemPropertyMap.hxx"
24 #include "GraphicPropertyItemConverter.hxx"
25 #include "CharacterPropertyItemConverter.hxx"
26 #include "MultipleItemConverter.hxx"
27 #include <unonames.hxx>
29 #include <svl/intitem.hxx>
30 #include <rtl/math.hxx>
35 #include <boost/checked_delete.hpp>
37 using namespace ::com::sun::star
;
39 namespace chart
{ namespace wrapper
{
43 ItemPropertyMapType
& lcl_GetEquationPropertyMap()
45 static ItemPropertyMapType aEquationPropertyMap
;
47 return aEquationPropertyMap
;
50 } // anonymous namespace
52 RegressionEquationItemConverter::RegressionEquationItemConverter(
53 const ::com::sun::star::uno::Reference
<
54 ::com::sun::star::beans::XPropertySet
> & rPropertySet
,
55 SfxItemPool
& rItemPool
,
57 const uno::Reference
< lang::XMultiServiceFactory
> & xNamedPropertyContainerFactory
,
58 const awt::Size
* pRefSize
) :
59 ItemConverter( rPropertySet
, rItemPool
)
61 m_aConverters
.push_back( new GraphicPropertyItemConverter(
62 rPropertySet
, rItemPool
, rDrawModel
,
63 xNamedPropertyContainerFactory
,
64 GraphicPropertyItemConverter::LINE_AND_FILL_PROPERTIES
));
66 m_aConverters
.push_back(
67 new CharacterPropertyItemConverter(rPropertySet
, rItemPool
, pRefSize
, "ReferencePageSize"));
70 RegressionEquationItemConverter::~RegressionEquationItemConverter()
72 ::std::for_each(m_aConverters
.begin(), m_aConverters
.end(), boost::checked_deleter
<ItemConverter
>());
75 void RegressionEquationItemConverter::FillItemSet( SfxItemSet
& rOutItemSet
) const
77 ::std::for_each( m_aConverters
.begin(), m_aConverters
.end(),
78 FillItemSetFunc( rOutItemSet
));
81 ItemConverter::FillItemSet( rOutItemSet
);
84 bool RegressionEquationItemConverter::ApplyItemSet( const SfxItemSet
& rItemSet
)
88 ::std::for_each( m_aConverters
.begin(), m_aConverters
.end(),
89 ApplyItemSetFunc( rItemSet
, bResult
));
92 return ItemConverter::ApplyItemSet( rItemSet
) || bResult
;
95 const sal_uInt16
* RegressionEquationItemConverter::GetWhichPairs() const
97 // must span all used items!
98 return nRegEquationWhichPairs
;
101 bool RegressionEquationItemConverter::GetItemProperty( tWhichIdType nWhichId
, tPropertyNameWithMemberId
& rOutProperty
) const
103 ItemPropertyMapType
& rMap( lcl_GetEquationPropertyMap());
104 ItemPropertyMapType::const_iterator
aIt( rMap
.find( nWhichId
));
106 if( aIt
== rMap
.end())
109 rOutProperty
=(*aIt
).second
;
113 bool RegressionEquationItemConverter::ApplySpecialItem(
114 sal_uInt16 nWhichId
, const SfxItemSet
& rItemSet
)
115 throw( uno::Exception
)
117 bool bChanged
= false;
121 case SID_ATTR_NUMBERFORMAT_VALUE
:
123 uno::Any
aValue( static_cast< sal_Int32
>(
124 static_cast< const SfxUInt32Item
& >(
125 rItemSet
.Get( nWhichId
)).GetValue()));
126 if (GetPropertySet()->getPropertyValue(CHART_UNONAME_NUMFMT
) != aValue
)
128 GetPropertySet()->setPropertyValue(CHART_UNONAME_NUMFMT
, aValue
);
138 void RegressionEquationItemConverter::FillSpecialItem(
139 sal_uInt16 nWhichId
, SfxItemSet
& rOutItemSet
) const
140 throw( uno::Exception
)
144 case SID_ATTR_NUMBERFORMAT_VALUE
:
146 sal_Int32 nFormatKey
= 0;
147 if (GetPropertySet()->getPropertyValue(CHART_UNONAME_NUMFMT
) >>= nFormatKey
)
149 rOutItemSet
.Put( SfxUInt32Item( nWhichId
, nFormatKey
));
158 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */