1*cde9e8dcSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*cde9e8dcSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*cde9e8dcSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*cde9e8dcSAndrew Rist * distributed with this work for additional information
6*cde9e8dcSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*cde9e8dcSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*cde9e8dcSAndrew Rist * "License"); you may not use this file except in compliance
9*cde9e8dcSAndrew Rist * with the License. You may obtain a copy of the License at
10*cde9e8dcSAndrew Rist *
11*cde9e8dcSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*cde9e8dcSAndrew Rist *
13*cde9e8dcSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*cde9e8dcSAndrew Rist * software distributed under the License is distributed on an
15*cde9e8dcSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*cde9e8dcSAndrew Rist * KIND, either express or implied. See the License for the
17*cde9e8dcSAndrew Rist * specific language governing permissions and limitations
18*cde9e8dcSAndrew Rist * under the License.
19*cde9e8dcSAndrew Rist *
20*cde9e8dcSAndrew Rist *************************************************************/
21*cde9e8dcSAndrew Rist
22*cde9e8dcSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_chart2.hxx"
26cdf0e10cSrcweir #include "LineProperties.hxx"
27cdf0e10cSrcweir #include "macros.hxx"
28cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp>
29cdf0e10cSrcweir #include <com/sun/star/drawing/LineStyle.hpp>
30cdf0e10cSrcweir #include <com/sun/star/drawing/LineDash.hpp>
31cdf0e10cSrcweir #include <com/sun/star/drawing/LineJoint.hpp>
32cdf0e10cSrcweir
33cdf0e10cSrcweir using namespace ::com::sun::star;
34cdf0e10cSrcweir
35cdf0e10cSrcweir using ::com::sun::star::beans::Property;
36cdf0e10cSrcweir
37cdf0e10cSrcweir namespace chart
38cdf0e10cSrcweir {
39cdf0e10cSrcweir
AddPropertiesToVector(::std::vector<Property> & rOutProperties)40cdf0e10cSrcweir void LineProperties::AddPropertiesToVector(
41cdf0e10cSrcweir ::std::vector< Property > & rOutProperties )
42cdf0e10cSrcweir {
43cdf0e10cSrcweir // Line Properties see service drawing::LineProperties
44cdf0e10cSrcweir // ---------------
45cdf0e10cSrcweir rOutProperties.push_back(
46cdf0e10cSrcweir Property( C2U( "LineStyle" ),
47cdf0e10cSrcweir PROP_LINE_STYLE,
48cdf0e10cSrcweir ::getCppuType( reinterpret_cast< const drawing::LineStyle * >(0)),
49cdf0e10cSrcweir beans::PropertyAttribute::BOUND
50cdf0e10cSrcweir | beans::PropertyAttribute::MAYBEDEFAULT ));
51cdf0e10cSrcweir
52cdf0e10cSrcweir rOutProperties.push_back(
53cdf0e10cSrcweir Property( C2U( "LineDash" ),
54cdf0e10cSrcweir PROP_LINE_DASH,
55cdf0e10cSrcweir ::getCppuType( reinterpret_cast< const drawing::LineDash * >(0)),
56cdf0e10cSrcweir beans::PropertyAttribute::BOUND
57cdf0e10cSrcweir | beans::PropertyAttribute::MAYBEVOID ));
58cdf0e10cSrcweir
59cdf0e10cSrcweir //not in service description
60cdf0e10cSrcweir rOutProperties.push_back(
61cdf0e10cSrcweir Property( C2U( "LineDashName" ),
62cdf0e10cSrcweir PROP_LINE_DASH_NAME,
63cdf0e10cSrcweir ::getCppuType( reinterpret_cast< const ::rtl::OUString * >(0)),
64cdf0e10cSrcweir beans::PropertyAttribute::BOUND
65cdf0e10cSrcweir | beans::PropertyAttribute::MAYBEDEFAULT
66cdf0e10cSrcweir | beans::PropertyAttribute::MAYBEVOID ));
67cdf0e10cSrcweir
68cdf0e10cSrcweir rOutProperties.push_back(
69cdf0e10cSrcweir Property( C2U( "LineColor" ),
70cdf0e10cSrcweir PROP_LINE_COLOR,
71cdf0e10cSrcweir ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
72cdf0e10cSrcweir beans::PropertyAttribute::BOUND
73cdf0e10cSrcweir | beans::PropertyAttribute::MAYBEDEFAULT ));
74cdf0e10cSrcweir
75cdf0e10cSrcweir rOutProperties.push_back(
76cdf0e10cSrcweir Property( C2U( "LineTransparence" ),
77cdf0e10cSrcweir PROP_LINE_TRANSPARENCE,
78cdf0e10cSrcweir ::getCppuType( reinterpret_cast< const sal_Int16 * >(0)),
79cdf0e10cSrcweir beans::PropertyAttribute::BOUND
80cdf0e10cSrcweir | beans::PropertyAttribute::MAYBEDEFAULT ));
81cdf0e10cSrcweir
82cdf0e10cSrcweir rOutProperties.push_back(
83cdf0e10cSrcweir Property( C2U( "LineWidth" ),
84cdf0e10cSrcweir PROP_LINE_WIDTH,
85cdf0e10cSrcweir ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
86cdf0e10cSrcweir beans::PropertyAttribute::BOUND
87cdf0e10cSrcweir | beans::PropertyAttribute::MAYBEDEFAULT ));
88cdf0e10cSrcweir
89cdf0e10cSrcweir rOutProperties.push_back(
90cdf0e10cSrcweir Property( C2U( "LineJoint" ),
91cdf0e10cSrcweir PROP_LINE_JOINT,
92cdf0e10cSrcweir ::getCppuType( reinterpret_cast< const drawing::LineJoint * >(0)),
93cdf0e10cSrcweir beans::PropertyAttribute::BOUND
94cdf0e10cSrcweir | beans::PropertyAttribute::MAYBEDEFAULT ));
95cdf0e10cSrcweir }
96cdf0e10cSrcweir
AddDefaultsToMap(::chart::tPropertyValueMap & rOutMap)97cdf0e10cSrcweir void LineProperties::AddDefaultsToMap(
98cdf0e10cSrcweir ::chart::tPropertyValueMap & rOutMap )
99cdf0e10cSrcweir {
100cdf0e10cSrcweir ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LINE_STYLE, drawing::LineStyle_SOLID );
101cdf0e10cSrcweir ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_LINE_WIDTH, 0 );
102cdf0e10cSrcweir ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_LINE_COLOR, 0x000000 ); // black
103cdf0e10cSrcweir ::chart::PropertyHelper::setPropertyValueDefault< sal_Int16 >( rOutMap, PROP_LINE_TRANSPARENCE, 0 );
104cdf0e10cSrcweir ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LINE_JOINT, drawing::LineJoint_ROUND );
105cdf0e10cSrcweir }
106cdf0e10cSrcweir
IsLineVisible(const::com::sun::star::uno::Reference<::com::sun::star::beans::XPropertySet> & xLineProperties)107cdf0e10cSrcweir bool LineProperties::IsLineVisible( const ::com::sun::star::uno::Reference<
108cdf0e10cSrcweir ::com::sun::star::beans::XPropertySet >& xLineProperties )
109cdf0e10cSrcweir {
110cdf0e10cSrcweir bool bRet = false;
111cdf0e10cSrcweir try
112cdf0e10cSrcweir {
113cdf0e10cSrcweir if( xLineProperties.is() )
114cdf0e10cSrcweir {
115cdf0e10cSrcweir drawing::LineStyle aLineStyle(drawing::LineStyle_SOLID);
116cdf0e10cSrcweir xLineProperties->getPropertyValue( C2U( "LineStyle" ) ) >>= aLineStyle;
117cdf0e10cSrcweir if( aLineStyle != drawing::LineStyle_NONE )
118cdf0e10cSrcweir {
119cdf0e10cSrcweir sal_Int16 nLineTransparence=0;
120cdf0e10cSrcweir xLineProperties->getPropertyValue( C2U( "LineTransparence" ) ) >>= nLineTransparence;
121cdf0e10cSrcweir if(100!=nLineTransparence)
122cdf0e10cSrcweir {
123cdf0e10cSrcweir bRet = true;
124cdf0e10cSrcweir }
125cdf0e10cSrcweir }
126cdf0e10cSrcweir }
127cdf0e10cSrcweir }
128cdf0e10cSrcweir catch( const uno::Exception & ex )
129cdf0e10cSrcweir {
130cdf0e10cSrcweir ASSERT_EXCEPTION( ex );
131cdf0e10cSrcweir }
132cdf0e10cSrcweir return bRet;
133cdf0e10cSrcweir }
134cdf0e10cSrcweir
SetLineVisible(const::com::sun::star::uno::Reference<::com::sun::star::beans::XPropertySet> & xLineProperties)135cdf0e10cSrcweir void LineProperties::SetLineVisible( const ::com::sun::star::uno::Reference<
136cdf0e10cSrcweir ::com::sun::star::beans::XPropertySet >& xLineProperties )
137cdf0e10cSrcweir {
138cdf0e10cSrcweir try
139cdf0e10cSrcweir {
140cdf0e10cSrcweir if( xLineProperties.is() )
141cdf0e10cSrcweir {
142cdf0e10cSrcweir drawing::LineStyle aLineStyle(drawing::LineStyle_SOLID);
143cdf0e10cSrcweir xLineProperties->getPropertyValue( C2U( "LineStyle" ) ) >>= aLineStyle;
144cdf0e10cSrcweir if( aLineStyle == drawing::LineStyle_NONE )
145cdf0e10cSrcweir xLineProperties->setPropertyValue( C2U( "LineStyle" ), uno::makeAny( drawing::LineStyle_SOLID ) );
146cdf0e10cSrcweir
147cdf0e10cSrcweir sal_Int16 nLineTransparence=0;
148cdf0e10cSrcweir xLineProperties->getPropertyValue( C2U( "LineTransparence" ) ) >>= nLineTransparence;
149cdf0e10cSrcweir if(100==nLineTransparence)
150cdf0e10cSrcweir xLineProperties->setPropertyValue( C2U( "LineTransparence" ), uno::makeAny( sal_Int16(0) ) );
151cdf0e10cSrcweir }
152cdf0e10cSrcweir }
153cdf0e10cSrcweir catch( const uno::Exception & ex )
154cdf0e10cSrcweir {
155cdf0e10cSrcweir ASSERT_EXCEPTION( ex );
156cdf0e10cSrcweir }
157cdf0e10cSrcweir }
158cdf0e10cSrcweir
SetLineInvisible(const::com::sun::star::uno::Reference<::com::sun::star::beans::XPropertySet> & xLineProperties)159cdf0e10cSrcweir void LineProperties::SetLineInvisible( const ::com::sun::star::uno::Reference<
160cdf0e10cSrcweir ::com::sun::star::beans::XPropertySet >& xLineProperties )
161cdf0e10cSrcweir {
162cdf0e10cSrcweir try
163cdf0e10cSrcweir {
164cdf0e10cSrcweir if( xLineProperties.is() )
165cdf0e10cSrcweir {
166cdf0e10cSrcweir drawing::LineStyle aLineStyle(drawing::LineStyle_SOLID);
167cdf0e10cSrcweir xLineProperties->getPropertyValue( C2U( "LineStyle" ) ) >>= aLineStyle;
168cdf0e10cSrcweir if( aLineStyle != drawing::LineStyle_NONE )
169cdf0e10cSrcweir xLineProperties->setPropertyValue( C2U( "LineStyle" ), uno::makeAny( drawing::LineStyle_NONE ) );
170cdf0e10cSrcweir }
171cdf0e10cSrcweir }
172cdf0e10cSrcweir catch( const uno::Exception & ex )
173cdf0e10cSrcweir {
174cdf0e10cSrcweir ASSERT_EXCEPTION( ex );
175cdf0e10cSrcweir }
176cdf0e10cSrcweir }
177cdf0e10cSrcweir
178cdf0e10cSrcweir } // namespace chart
179