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 "WrappedNumberFormatProperty.hxx"
21 #include "Chart2ModelContact.hxx"
22 #include <com/sun/star/chart2/XAxis.hpp>
23 #include <com/sun/star/chart2/XDataSeries.hpp>
24 #include <unonames.hxx>
25 #include <osl/diagnose.h>
27 using namespace ::com::sun::star
;
28 using ::com::sun::star::uno::Reference
;
29 using ::com::sun::star::uno::Any
;
36 WrappedNumberFormatProperty::WrappedNumberFormatProperty(const std::shared_ptr
<Chart2ModelContact
>& spChart2ModelContact
)
37 : WrappedDirectStateProperty( CHART_UNONAME_NUMFMT
, CHART_UNONAME_NUMFMT
)
38 , m_spChart2ModelContact(spChart2ModelContact
)
42 WrappedNumberFormatProperty::~WrappedNumberFormatProperty()
46 void WrappedNumberFormatProperty::setPropertyValue( const Any
& rOuterValue
, const Reference
< beans::XPropertySet
>& xInnerPropertySet
) const
48 sal_Int32 nFormat
= 0;
49 if( ! (rOuterValue
>>= nFormat
) )
50 throw lang::IllegalArgumentException( "Property 'NumberFormat' requires value of type sal_Int32", nullptr, 0 );
52 if(xInnerPropertySet
.is())
53 xInnerPropertySet
->setPropertyValue(getInnerName(), convertOuterToInnerValue(rOuterValue
));
56 Any
WrappedNumberFormatProperty::getPropertyValue( const Reference
< beans::XPropertySet
>& xInnerPropertySet
) const
58 if( !xInnerPropertySet
.is() )
60 OSL_FAIL("missing xInnerPropertySet in WrappedNumberFormatProperty::getPropertyValue");
63 Any
aRet( xInnerPropertySet
->getPropertyValue(getInnerName()));
64 if( !aRet
.hasValue() )
67 Reference
< chart2::XDataSeries
> xSeries( xInnerPropertySet
, uno::UNO_QUERY
);
69 nKey
= m_spChart2ModelContact
->getExplicitNumberFormatKeyForSeries( xSeries
);
72 Reference
< chart2::XAxis
> xAxis( xInnerPropertySet
, uno::UNO_QUERY
);
73 nKey
= m_spChart2ModelContact
->getExplicitNumberFormatKeyForAxis( xAxis
);
80 Any
WrappedNumberFormatProperty::getPropertyDefault( const Reference
< beans::XPropertyState
>& /*xInnerPropertyState*/ ) const
82 return uno::Any( sal_Int32( 0 ) );
85 WrappedLinkNumberFormatProperty::WrappedLinkNumberFormatProperty() :
86 WrappedDirectStateProperty(CHART_UNONAME_LINK_TO_SRC_NUMFMT
, CHART_UNONAME_LINK_TO_SRC_NUMFMT
)
90 WrappedLinkNumberFormatProperty::~WrappedLinkNumberFormatProperty()
94 void WrappedLinkNumberFormatProperty::setPropertyValue( const Any
& rOuterValue
, const Reference
< beans::XPropertySet
>& xInnerPropertySet
) const
96 if( !xInnerPropertySet
.is() )
98 OSL_FAIL("missing xInnerPropertySet in WrappedNumberFormatProperty::setPropertyValue");
102 xInnerPropertySet
->setPropertyValue(getInnerName(), rOuterValue
);
105 Any
WrappedLinkNumberFormatProperty::getPropertyValue( const Reference
< beans::XPropertySet
>& xInnerPropertySet
) const
107 if( !xInnerPropertySet
.is() )
109 OSL_FAIL("missing xInnerPropertySet in WrappedNumberFormatProperty::getPropertyValue");
110 return getPropertyDefault(nullptr);
113 return xInnerPropertySet
->getPropertyValue(getInnerName());
116 Any
WrappedLinkNumberFormatProperty::getPropertyDefault( const Reference
< beans::XPropertyState
>& /*xInnerPropertyState*/ ) const
118 return uno::Any( true ); // bLink
121 } //namespace wrapper
124 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */