1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_chart2.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include "WrappedSymbolProperties.hxx" 32*cdf0e10cSrcweir #include "WrappedSeriesOrDiagramProperty.hxx" 33*cdf0e10cSrcweir #include "macros.hxx" 34*cdf0e10cSrcweir #include "FastPropertyIdRanges.hxx" 35*cdf0e10cSrcweir #include "ChartTypeHelper.hxx" 36*cdf0e10cSrcweir #include <com/sun/star/chart2/Symbol.hpp> 37*cdf0e10cSrcweir #include <com/sun/star/chart2/SymbolStyle.hpp> 38*cdf0e10cSrcweir #include <com/sun/star/awt/Size.hpp> 39*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp> 40*cdf0e10cSrcweir #include <com/sun/star/chart/ChartSymbolType.hpp> 41*cdf0e10cSrcweir #include <com/sun/star/drawing/LineStyle.hpp> 42*cdf0e10cSrcweir 43*cdf0e10cSrcweir #include <com/sun/star/graphic/XGraphicProvider.hpp> 44*cdf0e10cSrcweir 45*cdf0e10cSrcweir // for UNO_NAME_GRAPHOBJ_URLPREFIX 46*cdf0e10cSrcweir #include <editeng/unoprnms.hxx> 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir // for Graphic 49*cdf0e10cSrcweir #include <vcl/graph.hxx> 50*cdf0e10cSrcweir // for GraphicObject 51*cdf0e10cSrcweir #include <svtools/grfmgr.hxx> 52*cdf0e10cSrcweir #include <vcl/outdev.hxx> 53*cdf0e10cSrcweir 54*cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir using namespace ::com::sun::star; 57*cdf0e10cSrcweir using ::com::sun::star::uno::Any; 58*cdf0e10cSrcweir using ::com::sun::star::uno::Reference; 59*cdf0e10cSrcweir using ::com::sun::star::uno::Sequence; 60*cdf0e10cSrcweir using ::com::sun::star::beans::Property; 61*cdf0e10cSrcweir using ::rtl::OUString; 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir //............................................................................. 64*cdf0e10cSrcweir namespace chart 65*cdf0e10cSrcweir { 66*cdf0e10cSrcweir namespace wrapper 67*cdf0e10cSrcweir { 68*cdf0e10cSrcweir 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir //----------------------------------------------------------------------------- 71*cdf0e10cSrcweir //----------------------------------------------------------------------------- 72*cdf0e10cSrcweir //----------------------------------------------------------------------------- 73*cdf0e10cSrcweir 74*cdf0e10cSrcweir class WrappedSymbolTypeProperty : public WrappedSeriesOrDiagramProperty< sal_Int32 > 75*cdf0e10cSrcweir { 76*cdf0e10cSrcweir public: 77*cdf0e10cSrcweir virtual sal_Int32 getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const; 78*cdf0e10cSrcweir virtual void setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, sal_Int32 aNewValue ) const; 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir virtual Any getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const 81*cdf0e10cSrcweir throw ( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException); 82*cdf0e10cSrcweir virtual beans::PropertyState getPropertyState( const Reference< beans::XPropertyState >& xInnerPropertyState ) const 83*cdf0e10cSrcweir throw (beans::UnknownPropertyException, uno::RuntimeException); 84*cdf0e10cSrcweir 85*cdf0e10cSrcweir explicit WrappedSymbolTypeProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact, 86*cdf0e10cSrcweir tSeriesOrDiagramPropertyType ePropertyType ); 87*cdf0e10cSrcweir virtual ~WrappedSymbolTypeProperty(); 88*cdf0e10cSrcweir }; 89*cdf0e10cSrcweir 90*cdf0e10cSrcweir class WrappedSymbolBitmapURLProperty : public WrappedSeriesOrDiagramProperty< OUString > 91*cdf0e10cSrcweir { 92*cdf0e10cSrcweir public: 93*cdf0e10cSrcweir virtual OUString getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const; 94*cdf0e10cSrcweir virtual void setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, OUString aNewGraphicURL ) const; 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir explicit WrappedSymbolBitmapURLProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact, 97*cdf0e10cSrcweir tSeriesOrDiagramPropertyType ePropertyType ); 98*cdf0e10cSrcweir virtual ~WrappedSymbolBitmapURLProperty(); 99*cdf0e10cSrcweir }; 100*cdf0e10cSrcweir 101*cdf0e10cSrcweir // this operator is not defined by default 102*cdf0e10cSrcweir bool operator!=( const awt::Size & rSize1, const awt::Size & rSize2 ) 103*cdf0e10cSrcweir { 104*cdf0e10cSrcweir return (rSize1.Width != rSize2.Width) || (rSize1.Height != rSize2.Height); 105*cdf0e10cSrcweir } 106*cdf0e10cSrcweir 107*cdf0e10cSrcweir class WrappedSymbolSizeProperty : public WrappedSeriesOrDiagramProperty< awt::Size > 108*cdf0e10cSrcweir { 109*cdf0e10cSrcweir public: 110*cdf0e10cSrcweir virtual awt::Size getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const; 111*cdf0e10cSrcweir virtual void setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, awt::Size aNewSize ) const; 112*cdf0e10cSrcweir virtual beans::PropertyState getPropertyState( const Reference< beans::XPropertyState >& xInnerPropertyState ) const 113*cdf0e10cSrcweir throw (beans::UnknownPropertyException, uno::RuntimeException); 114*cdf0e10cSrcweir 115*cdf0e10cSrcweir explicit WrappedSymbolSizeProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact, 116*cdf0e10cSrcweir tSeriesOrDiagramPropertyType ePropertyType ); 117*cdf0e10cSrcweir virtual ~WrappedSymbolSizeProperty(); 118*cdf0e10cSrcweir }; 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir class WrappedSymbolAndLinesProperty : public WrappedSeriesOrDiagramProperty< sal_Bool > 121*cdf0e10cSrcweir { 122*cdf0e10cSrcweir public: 123*cdf0e10cSrcweir virtual sal_Bool getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const; 124*cdf0e10cSrcweir virtual void setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, sal_Bool bDrawLines ) const; 125*cdf0e10cSrcweir virtual beans::PropertyState getPropertyState( const Reference< beans::XPropertyState >& xInnerPropertyState ) const 126*cdf0e10cSrcweir throw (beans::UnknownPropertyException, uno::RuntimeException); 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir explicit WrappedSymbolAndLinesProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact, 129*cdf0e10cSrcweir tSeriesOrDiagramPropertyType ePropertyType ); 130*cdf0e10cSrcweir virtual ~WrappedSymbolAndLinesProperty(); 131*cdf0e10cSrcweir }; 132*cdf0e10cSrcweir 133*cdf0e10cSrcweir namespace 134*cdf0e10cSrcweir { 135*cdf0e10cSrcweir enum 136*cdf0e10cSrcweir { 137*cdf0e10cSrcweir //symbol properties 138*cdf0e10cSrcweir PROP_CHART_SYMBOL_TYPE = FAST_PROPERTY_ID_START_CHART_SYMBOL_PROP, 139*cdf0e10cSrcweir PROP_CHART_SYMBOL_BITMAP_URL, 140*cdf0e10cSrcweir PROP_CHART_SYMBOL_SIZE, 141*cdf0e10cSrcweir PROP_CHART_SYMBOL_AND_LINES 142*cdf0e10cSrcweir }; 143*cdf0e10cSrcweir 144*cdf0e10cSrcweir sal_Int32 lcl_getSymbolType( const ::com::sun::star::chart2::Symbol& rSymbol ) 145*cdf0e10cSrcweir { 146*cdf0e10cSrcweir sal_Int32 nSymbol = ::com::sun::star::chart::ChartSymbolType::NONE; 147*cdf0e10cSrcweir switch( rSymbol.Style ) 148*cdf0e10cSrcweir { 149*cdf0e10cSrcweir case chart2::SymbolStyle_NONE: 150*cdf0e10cSrcweir break; 151*cdf0e10cSrcweir case chart2::SymbolStyle_AUTO: 152*cdf0e10cSrcweir nSymbol = ::com::sun::star::chart::ChartSymbolType::AUTO; 153*cdf0e10cSrcweir break; 154*cdf0e10cSrcweir case chart2::SymbolStyle_STANDARD: 155*cdf0e10cSrcweir nSymbol = rSymbol.StandardSymbol%8; 156*cdf0e10cSrcweir break; 157*cdf0e10cSrcweir case chart2::SymbolStyle_POLYGON://new feature 158*cdf0e10cSrcweir nSymbol = ::com::sun::star::chart::ChartSymbolType::AUTO; 159*cdf0e10cSrcweir break; 160*cdf0e10cSrcweir case chart2::SymbolStyle_GRAPHIC: 161*cdf0e10cSrcweir nSymbol = ::com::sun::star::chart::ChartSymbolType::BITMAPURL; 162*cdf0e10cSrcweir break; 163*cdf0e10cSrcweir default: 164*cdf0e10cSrcweir nSymbol = ::com::sun::star::chart::ChartSymbolType::AUTO; 165*cdf0e10cSrcweir break; 166*cdf0e10cSrcweir } 167*cdf0e10cSrcweir return nSymbol; 168*cdf0e10cSrcweir } 169*cdf0e10cSrcweir void lcl_setSymbolTypeToSymbol( sal_Int32 nSymbolType, chart2::Symbol& rSymbol ) 170*cdf0e10cSrcweir { 171*cdf0e10cSrcweir switch( nSymbolType ) 172*cdf0e10cSrcweir { 173*cdf0e10cSrcweir case ::com::sun::star::chart::ChartSymbolType::NONE: 174*cdf0e10cSrcweir rSymbol.Style = chart2::SymbolStyle_NONE; 175*cdf0e10cSrcweir break; 176*cdf0e10cSrcweir case ::com::sun::star::chart::ChartSymbolType::AUTO: 177*cdf0e10cSrcweir rSymbol.Style = chart2::SymbolStyle_AUTO; 178*cdf0e10cSrcweir break; 179*cdf0e10cSrcweir case ::com::sun::star::chart::ChartSymbolType::BITMAPURL: 180*cdf0e10cSrcweir rSymbol.Style = chart2::SymbolStyle_GRAPHIC; 181*cdf0e10cSrcweir break; 182*cdf0e10cSrcweir default: 183*cdf0e10cSrcweir rSymbol.Style = chart2::SymbolStyle_STANDARD; 184*cdf0e10cSrcweir rSymbol.StandardSymbol = nSymbolType; 185*cdf0e10cSrcweir break; 186*cdf0e10cSrcweir } 187*cdf0e10cSrcweir } 188*cdf0e10cSrcweir 189*cdf0e10cSrcweir void lcl_addWrappedProperties( std::vector< WrappedProperty* >& rList 190*cdf0e10cSrcweir , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact 191*cdf0e10cSrcweir , tSeriesOrDiagramPropertyType ePropertyType ) 192*cdf0e10cSrcweir { 193*cdf0e10cSrcweir rList.push_back( new WrappedSymbolTypeProperty( spChart2ModelContact, ePropertyType ) ); 194*cdf0e10cSrcweir rList.push_back( new WrappedSymbolBitmapURLProperty( spChart2ModelContact, ePropertyType ) ); 195*cdf0e10cSrcweir rList.push_back( new WrappedSymbolSizeProperty( spChart2ModelContact, ePropertyType ) ); 196*cdf0e10cSrcweir rList.push_back( new WrappedSymbolAndLinesProperty( spChart2ModelContact, ePropertyType ) ); 197*cdf0e10cSrcweir } 198*cdf0e10cSrcweir 199*cdf0e10cSrcweir }//anonymous namespace 200*cdf0e10cSrcweir 201*cdf0e10cSrcweir //----------------------------------------------------------------------------- 202*cdf0e10cSrcweir //----------------------------------------------------------------------------- 203*cdf0e10cSrcweir //----------------------------------------------------------------------------- 204*cdf0e10cSrcweir void WrappedSymbolProperties::addProperties( ::std::vector< Property > & rOutProperties ) 205*cdf0e10cSrcweir { 206*cdf0e10cSrcweir rOutProperties.push_back( 207*cdf0e10cSrcweir Property( C2U( "SymbolType" ), 208*cdf0e10cSrcweir PROP_CHART_SYMBOL_TYPE, 209*cdf0e10cSrcweir ::getCppuType( reinterpret_cast< sal_Int32 * >(0)), 210*cdf0e10cSrcweir beans::PropertyAttribute::BOUND 211*cdf0e10cSrcweir | beans::PropertyAttribute::MAYBEDEFAULT )); 212*cdf0e10cSrcweir 213*cdf0e10cSrcweir rOutProperties.push_back( 214*cdf0e10cSrcweir Property( C2U( "SymbolBitmapURL" ), 215*cdf0e10cSrcweir PROP_CHART_SYMBOL_BITMAP_URL, 216*cdf0e10cSrcweir ::getCppuType( reinterpret_cast< ::rtl::OUString * >(0)), 217*cdf0e10cSrcweir beans::PropertyAttribute::BOUND 218*cdf0e10cSrcweir | beans::PropertyAttribute::MAYBEDEFAULT )); 219*cdf0e10cSrcweir 220*cdf0e10cSrcweir rOutProperties.push_back( 221*cdf0e10cSrcweir Property( C2U( "SymbolSize" ), 222*cdf0e10cSrcweir PROP_CHART_SYMBOL_SIZE, 223*cdf0e10cSrcweir ::getCppuType( reinterpret_cast< awt::Size * >(0)), 224*cdf0e10cSrcweir beans::PropertyAttribute::BOUND 225*cdf0e10cSrcweir | beans::PropertyAttribute::MAYBEDEFAULT )); 226*cdf0e10cSrcweir 227*cdf0e10cSrcweir rOutProperties.push_back( 228*cdf0e10cSrcweir Property( C2U( "Lines" ), 229*cdf0e10cSrcweir PROP_CHART_SYMBOL_AND_LINES, 230*cdf0e10cSrcweir ::getBooleanCppuType(), 231*cdf0e10cSrcweir beans::PropertyAttribute::BOUND 232*cdf0e10cSrcweir | beans::PropertyAttribute::MAYBEDEFAULT )); 233*cdf0e10cSrcweir } 234*cdf0e10cSrcweir 235*cdf0e10cSrcweir //----------------------------------------------------------------------------- 236*cdf0e10cSrcweir //----------------------------------------------------------------------------- 237*cdf0e10cSrcweir 238*cdf0e10cSrcweir void WrappedSymbolProperties::addWrappedPropertiesForSeries( std::vector< WrappedProperty* >& rList 239*cdf0e10cSrcweir , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) 240*cdf0e10cSrcweir { 241*cdf0e10cSrcweir lcl_addWrappedProperties( rList, spChart2ModelContact, DATA_SERIES ); 242*cdf0e10cSrcweir } 243*cdf0e10cSrcweir 244*cdf0e10cSrcweir //----------------------------------------------------------------------------- 245*cdf0e10cSrcweir //----------------------------------------------------------------------------- 246*cdf0e10cSrcweir 247*cdf0e10cSrcweir void WrappedSymbolProperties::addWrappedPropertiesForDiagram( std::vector< WrappedProperty* >& rList 248*cdf0e10cSrcweir , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) 249*cdf0e10cSrcweir { 250*cdf0e10cSrcweir lcl_addWrappedProperties( rList, spChart2ModelContact, DIAGRAM ); 251*cdf0e10cSrcweir } 252*cdf0e10cSrcweir 253*cdf0e10cSrcweir //----------------------------------------------------------------------------- 254*cdf0e10cSrcweir //----------------------------------------------------------------------------- 255*cdf0e10cSrcweir //----------------------------------------------------------------------------- 256*cdf0e10cSrcweir 257*cdf0e10cSrcweir WrappedSymbolTypeProperty::WrappedSymbolTypeProperty( 258*cdf0e10cSrcweir ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact, 259*cdf0e10cSrcweir tSeriesOrDiagramPropertyType ePropertyType ) 260*cdf0e10cSrcweir : WrappedSeriesOrDiagramProperty< sal_Int32 >( C2U("SymbolType") 261*cdf0e10cSrcweir , uno::makeAny( ::com::sun::star::chart::ChartSymbolType::NONE ) 262*cdf0e10cSrcweir , spChart2ModelContact 263*cdf0e10cSrcweir , ePropertyType ) 264*cdf0e10cSrcweir { 265*cdf0e10cSrcweir } 266*cdf0e10cSrcweir WrappedSymbolTypeProperty::~WrappedSymbolTypeProperty() 267*cdf0e10cSrcweir { 268*cdf0e10cSrcweir } 269*cdf0e10cSrcweir 270*cdf0e10cSrcweir sal_Int32 WrappedSymbolTypeProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const 271*cdf0e10cSrcweir { 272*cdf0e10cSrcweir sal_Int32 aRet = 0; 273*cdf0e10cSrcweir m_aDefaultValue >>= aRet; 274*cdf0e10cSrcweir chart2::Symbol aSymbol; 275*cdf0e10cSrcweir if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue(C2U("Symbol")) >>= aSymbol ) ) 276*cdf0e10cSrcweir aRet = lcl_getSymbolType( aSymbol ); 277*cdf0e10cSrcweir return aRet; 278*cdf0e10cSrcweir } 279*cdf0e10cSrcweir 280*cdf0e10cSrcweir void WrappedSymbolTypeProperty::setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, sal_Int32 nSymbolType ) const 281*cdf0e10cSrcweir { 282*cdf0e10cSrcweir if(!xSeriesPropertySet.is()) 283*cdf0e10cSrcweir return; 284*cdf0e10cSrcweir 285*cdf0e10cSrcweir chart2::Symbol aSymbol; 286*cdf0e10cSrcweir xSeriesPropertySet->getPropertyValue(C2U("Symbol")) >>= aSymbol; 287*cdf0e10cSrcweir 288*cdf0e10cSrcweir lcl_setSymbolTypeToSymbol( nSymbolType, aSymbol ); 289*cdf0e10cSrcweir xSeriesPropertySet->setPropertyValue( C2U("Symbol"), uno::makeAny( aSymbol ) ); 290*cdf0e10cSrcweir } 291*cdf0e10cSrcweir 292*cdf0e10cSrcweir Any WrappedSymbolTypeProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const 293*cdf0e10cSrcweir throw ( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 294*cdf0e10cSrcweir { 295*cdf0e10cSrcweir //the old chart (< OOo 2.3) needs symbol-type="automatic" at the plot-area if any of the series should be able to have symbols 296*cdf0e10cSrcweir if( m_ePropertyType == DIAGRAM ) 297*cdf0e10cSrcweir { 298*cdf0e10cSrcweir bool bHasAmbiguousValue = false; 299*cdf0e10cSrcweir sal_Int32 aValue = 0; 300*cdf0e10cSrcweir if( detectInnerValue( aValue, bHasAmbiguousValue ) ) 301*cdf0e10cSrcweir { 302*cdf0e10cSrcweir if(bHasAmbiguousValue) 303*cdf0e10cSrcweir { 304*cdf0e10cSrcweir m_aOuterValue = uno::makeAny( ::com::sun::star::chart::ChartSymbolType::AUTO ); 305*cdf0e10cSrcweir } 306*cdf0e10cSrcweir else 307*cdf0e10cSrcweir { 308*cdf0e10cSrcweir if( ::com::sun::star::chart::ChartSymbolType::NONE == aValue ) 309*cdf0e10cSrcweir m_aOuterValue = uno::makeAny( ::com::sun::star::chart::ChartSymbolType::NONE ); 310*cdf0e10cSrcweir else 311*cdf0e10cSrcweir m_aOuterValue = uno::makeAny( ::com::sun::star::chart::ChartSymbolType::AUTO ); 312*cdf0e10cSrcweir } 313*cdf0e10cSrcweir } 314*cdf0e10cSrcweir return m_aOuterValue; 315*cdf0e10cSrcweir } 316*cdf0e10cSrcweir else 317*cdf0e10cSrcweir { 318*cdf0e10cSrcweir ::com::sun::star::uno::Any aRet( m_aDefaultValue ); 319*cdf0e10cSrcweir aRet <<= getValueFromSeries( xInnerPropertySet ); 320*cdf0e10cSrcweir return aRet; 321*cdf0e10cSrcweir } 322*cdf0e10cSrcweir } 323*cdf0e10cSrcweir 324*cdf0e10cSrcweir beans::PropertyState WrappedSymbolTypeProperty::getPropertyState( const Reference< beans::XPropertyState >& xInnerPropertyState ) const 325*cdf0e10cSrcweir throw (beans::UnknownPropertyException, uno::RuntimeException) 326*cdf0e10cSrcweir { 327*cdf0e10cSrcweir //the special situation for this property here is that the diagram default can be 328*cdf0e10cSrcweir //different from the normal default and different from all sinlges series values 329*cdf0e10cSrcweir //so we need to return PropertyState_DIRECT_VALUE for more cases 330*cdf0e10cSrcweir 331*cdf0e10cSrcweir if( m_ePropertyType == DATA_SERIES && //single series or point 332*cdf0e10cSrcweir m_spChart2ModelContact.get()) 333*cdf0e10cSrcweir { 334*cdf0e10cSrcweir Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); 335*cdf0e10cSrcweir Reference< chart2::XDataSeries > xSeries( xInnerPropertyState, uno::UNO_QUERY ); 336*cdf0e10cSrcweir Reference< chart2::XChartType > xChartType( DiagramHelper::getChartTypeOfSeries( xDiagram, xSeries ) ); 337*cdf0e10cSrcweir if( ChartTypeHelper::isSupportingSymbolProperties( xChartType, 2 ) ) 338*cdf0e10cSrcweir return beans::PropertyState_DIRECT_VALUE; 339*cdf0e10cSrcweir } 340*cdf0e10cSrcweir return WrappedProperty::getPropertyState( xInnerPropertyState ); 341*cdf0e10cSrcweir } 342*cdf0e10cSrcweir 343*cdf0e10cSrcweir //----------------------------------------------------------------------------- 344*cdf0e10cSrcweir //----------------------------------------------------------------------------- 345*cdf0e10cSrcweir //----------------------------------------------------------------------------- 346*cdf0e10cSrcweir 347*cdf0e10cSrcweir WrappedSymbolBitmapURLProperty::WrappedSymbolBitmapURLProperty( 348*cdf0e10cSrcweir ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact, 349*cdf0e10cSrcweir tSeriesOrDiagramPropertyType ePropertyType ) 350*cdf0e10cSrcweir : WrappedSeriesOrDiagramProperty< OUString >( C2U("SymbolBitmapURL") 351*cdf0e10cSrcweir , uno::makeAny( OUString() ), spChart2ModelContact, ePropertyType ) 352*cdf0e10cSrcweir { 353*cdf0e10cSrcweir } 354*cdf0e10cSrcweir 355*cdf0e10cSrcweir WrappedSymbolBitmapURLProperty::~WrappedSymbolBitmapURLProperty() 356*cdf0e10cSrcweir { 357*cdf0e10cSrcweir } 358*cdf0e10cSrcweir 359*cdf0e10cSrcweir OUString WrappedSymbolBitmapURLProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const 360*cdf0e10cSrcweir { 361*cdf0e10cSrcweir OUString aRet; 362*cdf0e10cSrcweir m_aDefaultValue >>= aRet; 363*cdf0e10cSrcweir chart2::Symbol aSymbol; 364*cdf0e10cSrcweir if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue(C2U("Symbol")) >>= aSymbol ) 365*cdf0e10cSrcweir && aSymbol.Graphic.is()) 366*cdf0e10cSrcweir { 367*cdf0e10cSrcweir GraphicObject aGrObj( Graphic( aSymbol.Graphic )); 368*cdf0e10cSrcweir aRet = OUString( RTL_CONSTASCII_USTRINGPARAM( UNO_NAME_GRAPHOBJ_URLPREFIX )); 369*cdf0e10cSrcweir aRet += OUString::createFromAscii( aGrObj.GetUniqueID().GetBuffer()); 370*cdf0e10cSrcweir } 371*cdf0e10cSrcweir return aRet; 372*cdf0e10cSrcweir } 373*cdf0e10cSrcweir 374*cdf0e10cSrcweir void WrappedSymbolBitmapURLProperty::setValueToSeries( 375*cdf0e10cSrcweir const Reference< beans::XPropertySet >& xSeriesPropertySet, 376*cdf0e10cSrcweir OUString aNewGraphicURL ) const 377*cdf0e10cSrcweir { 378*cdf0e10cSrcweir if(!xSeriesPropertySet.is()) 379*cdf0e10cSrcweir return; 380*cdf0e10cSrcweir 381*cdf0e10cSrcweir chart2::Symbol aSymbol; 382*cdf0e10cSrcweir if( xSeriesPropertySet->getPropertyValue(C2U("Symbol")) >>= aSymbol ) 383*cdf0e10cSrcweir { 384*cdf0e10cSrcweir bool bMatchesPrefix = 385*cdf0e10cSrcweir aNewGraphicURL.matchAsciiL( RTL_CONSTASCII_STRINGPARAM( UNO_NAME_GRAPHOBJ_URLPREFIX )); 386*cdf0e10cSrcweir if( bMatchesPrefix ) 387*cdf0e10cSrcweir { 388*cdf0e10cSrcweir GraphicObject aGrObj = GraphicObject( 389*cdf0e10cSrcweir ByteString( U2C( aNewGraphicURL.copy( sizeof( UNO_NAME_GRAPHOBJ_URLPREFIX ) - 1 )))); 390*cdf0e10cSrcweir aSymbol.Graphic.set( aGrObj.GetGraphic().GetXGraphic()); 391*cdf0e10cSrcweir xSeriesPropertySet->setPropertyValue( C2U("Symbol"), uno::makeAny( aSymbol ) ); 392*cdf0e10cSrcweir } 393*cdf0e10cSrcweir else 394*cdf0e10cSrcweir { 395*cdf0e10cSrcweir try 396*cdf0e10cSrcweir { 397*cdf0e10cSrcweir // @todo: get factory from some context? 398*cdf0e10cSrcweir Reference< lang::XMultiServiceFactory > xFact( comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW ); 399*cdf0e10cSrcweir Reference< graphic::XGraphicProvider > xGraphProv( 400*cdf0e10cSrcweir xFact->createInstance( C2U("com.sun.star.graphic.GraphicProvider")), uno::UNO_QUERY_THROW ); 401*cdf0e10cSrcweir Sequence< beans::PropertyValue > aArgs(1); 402*cdf0e10cSrcweir aArgs[0] = beans::PropertyValue( 403*cdf0e10cSrcweir C2U("URL"), -1, uno::makeAny( aNewGraphicURL ), 404*cdf0e10cSrcweir beans::PropertyState_DIRECT_VALUE ); 405*cdf0e10cSrcweir aSymbol.Graphic.set( xGraphProv->queryGraphic( aArgs )); 406*cdf0e10cSrcweir OSL_ENSURE( aSymbol.Graphic.is(), "Invalid URL for Symbol Bitmap" ); 407*cdf0e10cSrcweir xSeriesPropertySet->setPropertyValue( C2U("Symbol"), uno::makeAny( aSymbol ) ); 408*cdf0e10cSrcweir } 409*cdf0e10cSrcweir catch( const uno::Exception & ex ) 410*cdf0e10cSrcweir { 411*cdf0e10cSrcweir ASSERT_EXCEPTION( ex ); 412*cdf0e10cSrcweir } 413*cdf0e10cSrcweir } 414*cdf0e10cSrcweir } 415*cdf0e10cSrcweir } 416*cdf0e10cSrcweir 417*cdf0e10cSrcweir 418*cdf0e10cSrcweir //----------------------------------------------------------------------------- 419*cdf0e10cSrcweir //----------------------------------------------------------------------------- 420*cdf0e10cSrcweir //----------------------------------------------------------------------------- 421*cdf0e10cSrcweir 422*cdf0e10cSrcweir namespace 423*cdf0e10cSrcweir { 424*cdf0e10cSrcweir 425*cdf0e10cSrcweir void lcl_correctSymbolSizeForBitmaps( chart2::Symbol& rSymbol ) 426*cdf0e10cSrcweir { 427*cdf0e10cSrcweir if( rSymbol.Style != chart2::SymbolStyle_GRAPHIC ) 428*cdf0e10cSrcweir return; 429*cdf0e10cSrcweir if( rSymbol.Size.Width != -1 ) 430*cdf0e10cSrcweir return; 431*cdf0e10cSrcweir if( rSymbol.Size.Height != -1 ) 432*cdf0e10cSrcweir return; 433*cdf0e10cSrcweir 434*cdf0e10cSrcweir //find a good automatic size 435*cdf0e10cSrcweir try 436*cdf0e10cSrcweir { 437*cdf0e10cSrcweir const awt::Size aDefaultSize(250,250); 438*cdf0e10cSrcweir awt::Size aSize = aDefaultSize; 439*cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xProp( rSymbol.Graphic, uno::UNO_QUERY ); 440*cdf0e10cSrcweir if( xProp.is() ) 441*cdf0e10cSrcweir { 442*cdf0e10cSrcweir bool bFoundSize = false; 443*cdf0e10cSrcweir try 444*cdf0e10cSrcweir { 445*cdf0e10cSrcweir if( (xProp->getPropertyValue( C2U( "Size100thMM" ) ) >>= aSize) ) 446*cdf0e10cSrcweir { 447*cdf0e10cSrcweir if( aSize.Width == 0 && aSize.Height == 0 ) 448*cdf0e10cSrcweir aSize = aDefaultSize; 449*cdf0e10cSrcweir else 450*cdf0e10cSrcweir bFoundSize = true; 451*cdf0e10cSrcweir } 452*cdf0e10cSrcweir } 453*cdf0e10cSrcweir catch( uno::Exception& e ) 454*cdf0e10cSrcweir { 455*cdf0e10cSrcweir ASSERT_EXCEPTION( e ); 456*cdf0e10cSrcweir } 457*cdf0e10cSrcweir 458*cdf0e10cSrcweir if(!bFoundSize) 459*cdf0e10cSrcweir { 460*cdf0e10cSrcweir awt::Size aAWTPixelSize(10,10); 461*cdf0e10cSrcweir if( (xProp->getPropertyValue( C2U( "SizePixel" ) ) >>= aAWTPixelSize) ) 462*cdf0e10cSrcweir { 463*cdf0e10cSrcweir Size aPixelSize(aAWTPixelSize.Width,aAWTPixelSize.Height); 464*cdf0e10cSrcweir Size aNewSize = ( OutputDevice::LogicToLogic( aPixelSize, MAP_PIXEL, MAP_100TH_MM )); 465*cdf0e10cSrcweir aSize = awt::Size( aNewSize.Width(), aNewSize.Height() ); 466*cdf0e10cSrcweir 467*cdf0e10cSrcweir if( aSize.Width == 0 && aSize.Height == 0 ) 468*cdf0e10cSrcweir aSize = aDefaultSize; 469*cdf0e10cSrcweir } 470*cdf0e10cSrcweir } 471*cdf0e10cSrcweir } 472*cdf0e10cSrcweir rSymbol.Size = aSize; 473*cdf0e10cSrcweir } 474*cdf0e10cSrcweir catch( uno::Exception& e ) 475*cdf0e10cSrcweir { 476*cdf0e10cSrcweir ASSERT_EXCEPTION( e ); 477*cdf0e10cSrcweir } 478*cdf0e10cSrcweir } 479*cdf0e10cSrcweir 480*cdf0e10cSrcweir }//end anonymous namespace 481*cdf0e10cSrcweir 482*cdf0e10cSrcweir WrappedSymbolSizeProperty::WrappedSymbolSizeProperty( 483*cdf0e10cSrcweir ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact, 484*cdf0e10cSrcweir tSeriesOrDiagramPropertyType ePropertyType ) 485*cdf0e10cSrcweir : WrappedSeriesOrDiagramProperty< awt::Size >( C2U("SymbolSize") 486*cdf0e10cSrcweir , uno::makeAny( awt::Size(250,250) ), spChart2ModelContact, ePropertyType ) 487*cdf0e10cSrcweir { 488*cdf0e10cSrcweir } 489*cdf0e10cSrcweir 490*cdf0e10cSrcweir WrappedSymbolSizeProperty::~WrappedSymbolSizeProperty() 491*cdf0e10cSrcweir { 492*cdf0e10cSrcweir } 493*cdf0e10cSrcweir 494*cdf0e10cSrcweir awt::Size WrappedSymbolSizeProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const 495*cdf0e10cSrcweir { 496*cdf0e10cSrcweir awt::Size aRet; 497*cdf0e10cSrcweir m_aDefaultValue >>= aRet; 498*cdf0e10cSrcweir chart2::Symbol aSymbol; 499*cdf0e10cSrcweir if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue(C2U("Symbol")) >>= aSymbol )) 500*cdf0e10cSrcweir aRet = aSymbol.Size; 501*cdf0e10cSrcweir return aRet; 502*cdf0e10cSrcweir } 503*cdf0e10cSrcweir 504*cdf0e10cSrcweir void WrappedSymbolSizeProperty::setValueToSeries( 505*cdf0e10cSrcweir const Reference< beans::XPropertySet >& xSeriesPropertySet, 506*cdf0e10cSrcweir awt::Size aNewSize ) const 507*cdf0e10cSrcweir { 508*cdf0e10cSrcweir if(!xSeriesPropertySet.is()) 509*cdf0e10cSrcweir return; 510*cdf0e10cSrcweir 511*cdf0e10cSrcweir chart2::Symbol aSymbol; 512*cdf0e10cSrcweir if( xSeriesPropertySet->getPropertyValue(C2U("Symbol")) >>= aSymbol ) 513*cdf0e10cSrcweir { 514*cdf0e10cSrcweir aSymbol.Size = aNewSize; 515*cdf0e10cSrcweir lcl_correctSymbolSizeForBitmaps(aSymbol); 516*cdf0e10cSrcweir xSeriesPropertySet->setPropertyValue( C2U("Symbol"), uno::makeAny( aSymbol ) ); 517*cdf0e10cSrcweir } 518*cdf0e10cSrcweir } 519*cdf0e10cSrcweir 520*cdf0e10cSrcweir beans::PropertyState WrappedSymbolSizeProperty::getPropertyState( const Reference< beans::XPropertyState >& xInnerPropertyState ) const 521*cdf0e10cSrcweir throw (beans::UnknownPropertyException, uno::RuntimeException) 522*cdf0e10cSrcweir { 523*cdf0e10cSrcweir //only export symbol size if necessary 524*cdf0e10cSrcweir if( m_ePropertyType == DIAGRAM ) 525*cdf0e10cSrcweir return beans::PropertyState_DEFAULT_VALUE; 526*cdf0e10cSrcweir 527*cdf0e10cSrcweir try 528*cdf0e10cSrcweir { 529*cdf0e10cSrcweir chart2::Symbol aSymbol; 530*cdf0e10cSrcweir Reference< beans::XPropertySet > xSeriesPropertySet( xInnerPropertyState, uno::UNO_QUERY ); 531*cdf0e10cSrcweir if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue(C2U("Symbol")) >>= aSymbol )) 532*cdf0e10cSrcweir { 533*cdf0e10cSrcweir if( chart2::SymbolStyle_NONE != aSymbol.Style ) 534*cdf0e10cSrcweir return beans::PropertyState_DIRECT_VALUE; 535*cdf0e10cSrcweir } 536*cdf0e10cSrcweir } 537*cdf0e10cSrcweir catch( const uno::Exception & ex ) 538*cdf0e10cSrcweir { 539*cdf0e10cSrcweir ASSERT_EXCEPTION( ex ); 540*cdf0e10cSrcweir } 541*cdf0e10cSrcweir return beans::PropertyState_DEFAULT_VALUE; 542*cdf0e10cSrcweir } 543*cdf0e10cSrcweir 544*cdf0e10cSrcweir //----------------------------------------------------------------------------- 545*cdf0e10cSrcweir //----------------------------------------------------------------------------- 546*cdf0e10cSrcweir //----------------------------------------------------------------------------- 547*cdf0e10cSrcweir 548*cdf0e10cSrcweir WrappedSymbolAndLinesProperty::WrappedSymbolAndLinesProperty( 549*cdf0e10cSrcweir ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact, 550*cdf0e10cSrcweir tSeriesOrDiagramPropertyType ePropertyType ) 551*cdf0e10cSrcweir : WrappedSeriesOrDiagramProperty< sal_Bool >( C2U("Lines") 552*cdf0e10cSrcweir , uno::makeAny( sal_True ), spChart2ModelContact, ePropertyType ) 553*cdf0e10cSrcweir { 554*cdf0e10cSrcweir } 555*cdf0e10cSrcweir 556*cdf0e10cSrcweir WrappedSymbolAndLinesProperty::~WrappedSymbolAndLinesProperty() 557*cdf0e10cSrcweir { 558*cdf0e10cSrcweir } 559*cdf0e10cSrcweir 560*cdf0e10cSrcweir sal_Bool WrappedSymbolAndLinesProperty::getValueFromSeries( const Reference< beans::XPropertySet >& /*xSeriesPropertySet*/ ) const 561*cdf0e10cSrcweir { 562*cdf0e10cSrcweir //do not export this property anymore, instead use a linestyle none for no lines 563*cdf0e10cSrcweir return sal_True; 564*cdf0e10cSrcweir } 565*cdf0e10cSrcweir 566*cdf0e10cSrcweir void WrappedSymbolAndLinesProperty::setValueToSeries( 567*cdf0e10cSrcweir const Reference< beans::XPropertySet >& xSeriesPropertySet, 568*cdf0e10cSrcweir sal_Bool bDrawLines ) const 569*cdf0e10cSrcweir { 570*cdf0e10cSrcweir if(!xSeriesPropertySet.is()) 571*cdf0e10cSrcweir return; 572*cdf0e10cSrcweir 573*cdf0e10cSrcweir drawing::LineStyle eOldLineStyle( drawing::LineStyle_SOLID ); 574*cdf0e10cSrcweir xSeriesPropertySet->getPropertyValue( C2U("LineStyle") ) >>= eOldLineStyle; 575*cdf0e10cSrcweir if( bDrawLines ) 576*cdf0e10cSrcweir { 577*cdf0e10cSrcweir //#i114298# don't overwrite dashed lines with solid lines here 578*cdf0e10cSrcweir if( eOldLineStyle == drawing::LineStyle_NONE ) 579*cdf0e10cSrcweir xSeriesPropertySet->setPropertyValue( C2U("LineStyle"), uno::makeAny( drawing::LineStyle_SOLID ) ); 580*cdf0e10cSrcweir } 581*cdf0e10cSrcweir else 582*cdf0e10cSrcweir { 583*cdf0e10cSrcweir if( eOldLineStyle != drawing::LineStyle_NONE ) 584*cdf0e10cSrcweir xSeriesPropertySet->setPropertyValue( C2U("LineStyle"), uno::makeAny( drawing::LineStyle_NONE ) ); 585*cdf0e10cSrcweir } 586*cdf0e10cSrcweir } 587*cdf0e10cSrcweir 588*cdf0e10cSrcweir beans::PropertyState WrappedSymbolAndLinesProperty::getPropertyState( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const 589*cdf0e10cSrcweir throw (beans::UnknownPropertyException, uno::RuntimeException) 590*cdf0e10cSrcweir { 591*cdf0e10cSrcweir //do not export this property anymore, instead use a linestyle none for no lines 592*cdf0e10cSrcweir return beans::PropertyState_DEFAULT_VALUE; 593*cdf0e10cSrcweir } 594*cdf0e10cSrcweir 595*cdf0e10cSrcweir //----------------------------------------------------------------------------- 596*cdf0e10cSrcweir //----------------------------------------------------------------------------- 597*cdf0e10cSrcweir //----------------------------------------------------------------------------- 598*cdf0e10cSrcweir 599*cdf0e10cSrcweir } //namespace wrapper 600*cdf0e10cSrcweir } //namespace chart 601*cdf0e10cSrcweir //............................................................................. 602