Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
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/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
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 .
18 : : */
19 : :
20 : : #include "LineProperties.hxx"
21 : : #include "macros.hxx"
22 : : #include <com/sun/star/beans/PropertyAttribute.hpp>
23 : : #include <com/sun/star/drawing/LineStyle.hpp>
24 : : #include <com/sun/star/drawing/LineDash.hpp>
25 : : #include <com/sun/star/drawing/LineJoint.hpp>
26 : :
27 : : using namespace ::com::sun::star;
28 : :
29 : : using ::com::sun::star::beans::Property;
30 : :
31 : : namespace chart
32 : : {
33 : :
34 : 135 : void LineProperties::AddPropertiesToVector(
35 : : ::std::vector< Property > & rOutProperties )
36 : : {
37 : : // Line Properties see service drawing::LineProperties
38 : : // ---------------
39 : : rOutProperties.push_back(
40 : : Property( C2U( "LineStyle" ),
41 : : PROP_LINE_STYLE,
42 [ + - ]: 135 : ::getCppuType( reinterpret_cast< const drawing::LineStyle * >(0)),
43 : : beans::PropertyAttribute::BOUND
44 [ + - ][ + - ]: 135 : | beans::PropertyAttribute::MAYBEDEFAULT ));
45 : :
46 : : rOutProperties.push_back(
47 : : Property( C2U( "LineDash" ),
48 : : PROP_LINE_DASH,
49 [ + - ]: 135 : ::getCppuType( reinterpret_cast< const drawing::LineDash * >(0)),
50 : : beans::PropertyAttribute::BOUND
51 [ + - ][ + - ]: 135 : | beans::PropertyAttribute::MAYBEVOID ));
52 : :
53 : : //not in service description
54 : : rOutProperties.push_back(
55 : : Property( C2U( "LineDashName" ),
56 : : PROP_LINE_DASH_NAME,
57 [ + - ]: 135 : ::getCppuType( reinterpret_cast< const ::rtl::OUString * >(0)),
58 : : beans::PropertyAttribute::BOUND
59 : : | beans::PropertyAttribute::MAYBEDEFAULT
60 [ + - ][ + - ]: 135 : | beans::PropertyAttribute::MAYBEVOID ));
61 : :
62 : : rOutProperties.push_back(
63 : : Property( C2U( "LineColor" ),
64 : : PROP_LINE_COLOR,
65 [ + - ]: 135 : ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
66 : : beans::PropertyAttribute::BOUND
67 [ + - ][ + - ]: 135 : | beans::PropertyAttribute::MAYBEDEFAULT ));
68 : :
69 : : rOutProperties.push_back(
70 : : Property( C2U( "LineTransparence" ),
71 : : PROP_LINE_TRANSPARENCE,
72 [ + - ]: 135 : ::getCppuType( reinterpret_cast< const sal_Int16 * >(0)),
73 : : beans::PropertyAttribute::BOUND
74 [ + - ][ + - ]: 135 : | beans::PropertyAttribute::MAYBEDEFAULT ));
75 : :
76 : : rOutProperties.push_back(
77 : : Property( C2U( "LineWidth" ),
78 : : PROP_LINE_WIDTH,
79 [ + - ]: 135 : ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
80 : : beans::PropertyAttribute::BOUND
81 [ + - ][ + - ]: 135 : | beans::PropertyAttribute::MAYBEDEFAULT ));
82 : :
83 : : rOutProperties.push_back(
84 : : Property( C2U( "LineJoint" ),
85 : : PROP_LINE_JOINT,
86 [ + - ]: 135 : ::getCppuType( reinterpret_cast< const drawing::LineJoint * >(0)),
87 : : beans::PropertyAttribute::BOUND
88 [ + - ][ + - ]: 135 : | beans::PropertyAttribute::MAYBEDEFAULT ));
89 : 135 : }
90 : :
91 : 81 : void LineProperties::AddDefaultsToMap(
92 : : ::chart::tPropertyValueMap & rOutMap )
93 : : {
94 [ + - ]: 81 : ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LINE_STYLE, drawing::LineStyle_SOLID );
95 [ + - ]: 81 : ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_LINE_WIDTH, 0 );
96 [ + - ]: 81 : ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_LINE_COLOR, 0x000000 ); // black
97 [ + - ]: 81 : ::chart::PropertyHelper::setPropertyValueDefault< sal_Int16 >( rOutMap, PROP_LINE_TRANSPARENCE, 0 );
98 [ + - ]: 81 : ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LINE_JOINT, drawing::LineJoint_ROUND );
99 : 81 : }
100 : :
101 : 8027 : bool LineProperties::IsLineVisible( const ::com::sun::star::uno::Reference<
102 : : ::com::sun::star::beans::XPropertySet >& xLineProperties )
103 : : {
104 : 8027 : bool bRet = false;
105 : : try
106 : : {
107 [ + - ]: 8027 : if( xLineProperties.is() )
108 : : {
109 : 8027 : drawing::LineStyle aLineStyle(drawing::LineStyle_SOLID);
110 [ + - ][ + - ]: 8027 : xLineProperties->getPropertyValue( C2U( "LineStyle" ) ) >>= aLineStyle;
[ + - ][ + - ]
111 [ + + ]: 8027 : if( aLineStyle != drawing::LineStyle_NONE )
112 : : {
113 : 7667 : sal_Int16 nLineTransparence=0;
114 [ + - ][ + - ]: 7667 : xLineProperties->getPropertyValue( C2U( "LineTransparence" ) ) >>= nLineTransparence;
[ + - ][ # # ]
115 [ + - ]: 7667 : if(100!=nLineTransparence)
116 : : {
117 : 8027 : bRet = true;
118 : : }
119 : : }
120 : : }
121 : : }
122 : 0 : catch( const uno::Exception & ex )
123 : : {
124 : : ASSERT_EXCEPTION( ex );
125 : : }
126 : 8027 : return bRet;
127 : : }
128 : :
129 : 106 : void LineProperties::SetLineVisible( const ::com::sun::star::uno::Reference<
130 : : ::com::sun::star::beans::XPropertySet >& xLineProperties )
131 : : {
132 : : try
133 : : {
134 [ + - ]: 106 : if( xLineProperties.is() )
135 : : {
136 : 106 : drawing::LineStyle aLineStyle(drawing::LineStyle_SOLID);
137 [ + - ][ + - ]: 106 : xLineProperties->getPropertyValue( C2U( "LineStyle" ) ) >>= aLineStyle;
[ + - ][ + - ]
138 [ - + ]: 106 : if( aLineStyle == drawing::LineStyle_NONE )
139 [ # # ][ # # ]: 0 : xLineProperties->setPropertyValue( C2U( "LineStyle" ), uno::makeAny( drawing::LineStyle_SOLID ) );
[ # # ][ # # ]
140 : :
141 : 106 : sal_Int16 nLineTransparence=0;
142 [ + - ][ + - ]: 106 : xLineProperties->getPropertyValue( C2U( "LineTransparence" ) ) >>= nLineTransparence;
[ + - ]
143 [ - + ]: 106 : if(100==nLineTransparence)
144 [ # # ][ # # ]: 106 : xLineProperties->setPropertyValue( C2U( "LineTransparence" ), uno::makeAny( sal_Int16(0) ) );
[ # # ][ # # ]
[ # # ]
145 : : }
146 : : }
147 : 0 : catch( const uno::Exception & ex )
148 : : {
149 : : ASSERT_EXCEPTION( ex );
150 : : }
151 : 106 : }
152 : :
153 : 222 : void LineProperties::SetLineInvisible( const ::com::sun::star::uno::Reference<
154 : : ::com::sun::star::beans::XPropertySet >& xLineProperties )
155 : : {
156 : : try
157 : : {
158 [ + - ]: 222 : if( xLineProperties.is() )
159 : : {
160 : 222 : drawing::LineStyle aLineStyle(drawing::LineStyle_SOLID);
161 [ + - ][ + - ]: 222 : xLineProperties->getPropertyValue( C2U( "LineStyle" ) ) >>= aLineStyle;
[ + - ][ + - ]
162 [ + - ]: 222 : if( aLineStyle != drawing::LineStyle_NONE )
163 [ + - ][ + - ]: 222 : xLineProperties->setPropertyValue( C2U( "LineStyle" ), uno::makeAny( drawing::LineStyle_NONE ) );
[ + - ][ + - ]
[ # # ]
164 : : }
165 : : }
166 : 0 : catch( const uno::Exception & ex )
167 : : {
168 : : ASSERT_EXCEPTION( ex );
169 : : }
170 : 222 : }
171 : :
172 : : } // namespace chart
173 : :
174 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|