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