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