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 <LinePropertiesHelper.hxx>
21 #include <com/sun/star/beans/PropertyAttribute.hpp>
22 #include <com/sun/star/beans/XPropertySet.hpp>
23 #include <com/sun/star/drawing/LineStyle.hpp>
24 #include <com/sun/star/drawing/LineDash.hpp>
25 #include <com/sun/star/drawing/LineCap.hpp>
26 #include <com/sun/star/drawing/LineJoint.hpp>
27 #include <comphelper/diagnose_ex.hxx>
28 #include <tools/color.hxx>
30 using namespace ::com::sun::star
;
32 using ::com::sun::star::beans::Property
;
37 void LinePropertiesHelper::AddPropertiesToVector(
38 std::vector
< Property
> & rOutProperties
)
40 // Line Properties see service drawing::LineProperties
41 rOutProperties
.emplace_back( "LineStyle",
43 cppu::UnoType
<drawing::LineStyle
>::get(),
44 beans::PropertyAttribute::BOUND
45 | beans::PropertyAttribute::MAYBEDEFAULT
);
47 rOutProperties
.emplace_back( "LineDash",
49 cppu::UnoType
<drawing::LineDash
>::get(),
50 beans::PropertyAttribute::BOUND
51 | beans::PropertyAttribute::MAYBEVOID
);
53 //not in service description
54 rOutProperties
.emplace_back( "LineDashName",
56 cppu::UnoType
<OUString
>::get(),
57 beans::PropertyAttribute::BOUND
58 | beans::PropertyAttribute::MAYBEDEFAULT
59 | beans::PropertyAttribute::MAYBEVOID
);
61 rOutProperties
.emplace_back( "LineColor",
63 cppu::UnoType
<sal_Int32
>::get(),
64 beans::PropertyAttribute::BOUND
65 | beans::PropertyAttribute::MAYBEDEFAULT
);
67 rOutProperties
.emplace_back( "LineTransparence",
68 PROP_LINE_TRANSPARENCE
,
69 cppu::UnoType
<sal_Int16
>::get(),
70 beans::PropertyAttribute::BOUND
71 | beans::PropertyAttribute::MAYBEDEFAULT
);
73 rOutProperties
.emplace_back( "LineWidth",
75 cppu::UnoType
<sal_Int32
>::get(),
76 beans::PropertyAttribute::BOUND
77 | beans::PropertyAttribute::MAYBEDEFAULT
);
79 rOutProperties
.emplace_back( "LineJoint",
81 cppu::UnoType
<drawing::LineJoint
>::get(),
82 beans::PropertyAttribute::BOUND
83 | beans::PropertyAttribute::MAYBEDEFAULT
);
85 rOutProperties
.emplace_back( "LineCap",
87 cppu::UnoType
<drawing::LineCap
>::get(),
88 beans::PropertyAttribute::BOUND
89 | beans::PropertyAttribute::MAYBEDEFAULT
);
92 void LinePropertiesHelper::AddDefaultsToMap(
93 ::chart::tPropertyValueMap
& rOutMap
)
95 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_LINE_STYLE
, drawing::LineStyle_SOLID
);
96 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_LINE_WIDTH
, sal_Int32(0) );
97 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_LINE_COLOR
, COL_BLACK
);
98 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_LINE_TRANSPARENCE
, sal_Int16(0) );
99 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_LINE_JOINT
, drawing::LineJoint_ROUND
);
100 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_LINE_CAP
, drawing::LineCap_BUTT
);
103 bool LinePropertiesHelper::IsLineVisible( const css::uno::Reference
<
104 css::beans::XPropertySet
>& xLineProperties
)
109 if( xLineProperties
.is() )
111 drawing::LineStyle
aLineStyle(drawing::LineStyle_SOLID
);
112 xLineProperties
->getPropertyValue( "LineStyle" ) >>= aLineStyle
;
113 if( aLineStyle
!= drawing::LineStyle_NONE
)
115 sal_Int16 nLineTransparence
=0;
116 xLineProperties
->getPropertyValue( "LineTransparence" ) >>= nLineTransparence
;
117 if(nLineTransparence
!=100)
124 catch( const uno::Exception
& )
126 DBG_UNHANDLED_EXCEPTION("chart2");
131 void LinePropertiesHelper::SetLineVisible( const css::uno::Reference
<
132 css::beans::XPropertySet
>& xLineProperties
)
136 if( xLineProperties
.is() )
138 drawing::LineStyle
aLineStyle(drawing::LineStyle_SOLID
);
139 xLineProperties
->getPropertyValue( "LineStyle" ) >>= aLineStyle
;
140 if( aLineStyle
== drawing::LineStyle_NONE
)
141 xLineProperties
->setPropertyValue( "LineStyle", uno::Any( drawing::LineStyle_SOLID
) );
143 sal_Int16 nLineTransparence
=0;
144 xLineProperties
->getPropertyValue( "LineTransparence" ) >>= nLineTransparence
;
145 if(nLineTransparence
==100)
146 xLineProperties
->setPropertyValue( "LineTransparence", uno::Any( sal_Int16(0) ) );
149 catch( const uno::Exception
& )
151 DBG_UNHANDLED_EXCEPTION("chart2");
155 void LinePropertiesHelper::SetLineInvisible( const css::uno::Reference
<
156 css::beans::XPropertySet
>& xLineProperties
)
160 if( xLineProperties
.is() )
162 drawing::LineStyle
aLineStyle(drawing::LineStyle_SOLID
);
163 xLineProperties
->getPropertyValue( "LineStyle" ) >>= aLineStyle
;
164 if( aLineStyle
!= drawing::LineStyle_NONE
)
165 xLineProperties
->setPropertyValue( "LineStyle", uno::Any( drawing::LineStyle_NONE
) );
168 catch( const uno::Exception
& )
170 DBG_UNHANDLED_EXCEPTION("chart2");
174 void LinePropertiesHelper::SetLineColor( const css::uno::Reference
<
175 css::beans::XPropertySet
>& xLineProperties
, sal_Int32 nColor
)
179 if( xLineProperties
.is() )
181 xLineProperties
->setPropertyValue( "LineColor", uno::Any( nColor
) );
184 catch( const uno::Exception
& )
186 DBG_UNHANDLED_EXCEPTION("chart2");
193 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */