? i91970.patch Index: ChartView.cxx =================================================================== RCS file: /cvs/graphics/chart2/source/view/main/ChartView.cxx,v retrieving revision 1.47 diff -c -r1.47 ChartView.cxx *** ChartView.cxx 30 Jul 2008 11:57:54 -0000 1.47 --- ChartView.cxx 14 Nov 2008 14:23:42 -0000 *************** *** 99,104 **** --- 99,106 ---- #include #include + #include + //............................................................................. namespace chart { *************** *** 1024,1029 **** --- 1026,1043 ---- return DiagramHelper::isPieOrDonutChart( xDiagram ); } + sal_Int16 lcl_getDefaultWritingModeFromPool( ::boost::shared_ptr< DrawModelWrapper > pDrawModelWrapper ) + { + sal_Int16 nWritingMode = text::WritingMode2::LR_TB; + if( pDrawModelWrapper.get() ) + { + const SfxPoolItem* pItem = &(pDrawModelWrapper->GetItemPool().GetDefaultItem( EE_PARA_WRITINGDIR )); + if( pItem ) + nWritingMode = static_cast< sal_Int16 >((static_cast< const SfxInt32Item * >( pItem ))->GetValue()); + } + return nWritingMode; + } + } //end anonymous namespace //------------ create complete diagram shape (inclusive axis and series) *************** *** 1916,1927 **** , awt::Rectangle & rRemainingSpace , const awt::Size & rPageSize , const uno::Reference< frame::XModel > & xModel ! , const std::vector< LegendEntryProvider* >& rLegendEntryProviderList ) { if( VLegend::isVisible( xLegend )) { VLegend aVLegend( xLegend, xContext, rLegendEntryProviderList ); aVLegend.init( xPageShapes, xShapeFactory, xModel ); aVLegend.createShapes( awt::Size( rRemainingSpace.Width, rRemainingSpace.Height ), rPageSize ); aVLegend.changePosition( rRemainingSpace, rPageSize ); --- 1930,1943 ---- , awt::Rectangle & rRemainingSpace , const awt::Size & rPageSize , const uno::Reference< frame::XModel > & xModel ! , const std::vector< LegendEntryProvider* >& rLegendEntryProviderList ! , sal_Int16 nDefaultWritingMode ) { if( VLegend::isVisible( xLegend )) { VLegend aVLegend( xLegend, xContext, rLegendEntryProviderList ); aVLegend.init( xPageShapes, xShapeFactory, xModel ); + aVLegend.setDefaultWritingMode( nDefaultWritingMode ); aVLegend.createShapes( awt::Size( rRemainingSpace.Width, rRemainingSpace.Height ), rPageSize ); aVLegend.changePosition( rRemainingSpace, rPageSize ); *************** *** 2147,2153 **** //------------ create legend lcl_createLegend( LegendHelper::getLegend( m_xChartModel ), xPageShapes, m_xShapeFactory, m_xCC ! , aRemainingSpace, aPageSize, m_xChartModel, aSeriesPlotterContainer.getLegendEntryProviderList() ); if(aRemainingSpace.Width<=0||aRemainingSpace.Height<=0) return; --- 2163,2170 ---- //------------ create legend lcl_createLegend( LegendHelper::getLegend( m_xChartModel ), xPageShapes, m_xShapeFactory, m_xCC ! , aRemainingSpace, aPageSize, m_xChartModel, aSeriesPlotterContainer.getLegendEntryProviderList() ! , lcl_getDefaultWritingModeFromPool( m_pDrawModelWrapper ) ); if(aRemainingSpace.Width<=0||aRemainingSpace.Height<=0) return; Index: VLegend.cxx =================================================================== RCS file: /cvs/graphics/chart2/source/view/main/VLegend.cxx,v retrieving revision 1.40 diff -c -r1.40 VLegend.cxx *** VLegend.cxx 10 Apr 2008 22:51:27 -0000 1.40 --- VLegend.cxx 14 Nov 2008 14:23:42 -0000 *************** *** 40,52 **** --- 40,55 ---- #include "RelativeSizeHelper.hxx" #include "LegendEntryProvider.hxx" #include + #include #include + #include #include #include #include #include #include #include + #include #include #include *************** *** 242,250 **** } ! void lcl_createLegend( const tViewLegendEntryContainer & rEntries, LegendExpansion eExpansion, const Reference< beans::XPropertySet > & xProperties, tPropertyValues & rTextProperties, const Reference< drawing::XShapes > & xTarget, --- 245,254 ---- } ! void lcl_placeLegendEntries( const tViewLegendEntryContainer & rEntries, LegendExpansion eExpansion, + bool bSymbolsLeftSide, const Reference< beans::XPropertySet > & xProperties, tPropertyValues & rTextProperties, const Reference< drawing::XShapes > & xTarget, *************** *** 280,285 **** --- 284,292 ---- sal_Int32 nMaxEntryHeight = nYOffset + aMaxEntryExtent.Height; sal_Int32 nNumberOfEntries = rEntries.size(); + if( !bSymbolsLeftSide ) + nCurrentXPos = -nXPadding; + sal_Int32 nNumberOfColumns = 0, nNumberOfRows = 0; // determine layout depending on LegendExpansion *************** *** 384,409 **** aMaxSymbolExtent.Width * 75 / 100, aMaxSymbolExtent.Height * 75 / 100 ); xSymbol->setSize( aSymbolSize ); ! xSymbol->setPosition( ! awt::Point( ! nCurrentXPos + ((aMaxSymbolExtent.Width - aSymbolSize.Width) / 2), nCurrentYPos + ((aMaxSymbolExtent.Height - aSymbolSize.Height) / 2))); } // position text shape awt::Size aTextSize( aTextShapes[ nEntry ]->getSize()); ! nMaxWidth = ::std::max( ! nMaxWidth, 2 * nXOffset + aMaxSymbolExtent.Width + aTextSize.Width ); ! aTextShapes[ nEntry ]->setPosition( ! awt::Point( nCurrentXPos + aMaxSymbolExtent.Width, nCurrentYPos )); nCurrentYPos += nMaxHeights[ nRow ]; nMaxYPos = ::std::max( nMaxYPos, nCurrentYPos ); } ! nCurrentXPos += nMaxWidth; } ! rOutLegendSize.Width = nCurrentXPos + nXPadding; rOutLegendSize.Height = nMaxYPos + nYPadding; } --- 391,441 ---- aMaxSymbolExtent.Width * 75 / 100, aMaxSymbolExtent.Height * 75 / 100 ); xSymbol->setSize( aSymbolSize ); ! sal_Int32 nSymbolXPos = nCurrentXPos + ((aMaxSymbolExtent.Width - aSymbolSize.Width) / 2); ! if( !bSymbolsLeftSide ) ! nSymbolXPos = nSymbolXPos - aMaxSymbolExtent.Width; ! xSymbol->setPosition( awt::Point( nSymbolXPos, nCurrentYPos + ((aMaxSymbolExtent.Height - aSymbolSize.Height) / 2))); } // position text shape awt::Size aTextSize( aTextShapes[ nEntry ]->getSize()); ! nMaxWidth = ::std::max( nMaxWidth, 2 * nXOffset + aMaxSymbolExtent.Width + aTextSize.Width ); ! sal_Int32 nTextXPos = nCurrentXPos + aMaxSymbolExtent.Width; ! if( !bSymbolsLeftSide ) ! nTextXPos = nCurrentXPos - aMaxSymbolExtent.Width - aTextSize.Width; ! aTextShapes[ nEntry ]->setPosition( awt::Point( nTextXPos, nCurrentYPos )); nCurrentYPos += nMaxHeights[ nRow ]; nMaxYPos = ::std::max( nMaxYPos, nCurrentYPos ); } ! if( bSymbolsLeftSide ) ! nCurrentXPos += nMaxWidth; ! else ! nCurrentXPos -= nMaxWidth; } ! if( bSymbolsLeftSide ) ! rOutLegendSize.Width = nCurrentXPos + nXPadding; ! else ! { ! sal_Int32 nLegendWidth = -(nCurrentXPos-nXPadding); ! rOutLegendSize.Width = nLegendWidth; ! ! sal_Int32 nNumberOfEntries = rEntries.size(); ! awt::Point aPos(0,0); ! for( sal_Int32 nEntry=0; nEntry xSymbol( rEntries[ nEntry ].aSymbol ); ! aPos = xSymbol->getPosition(); ! aPos.X += nLegendWidth; ! xSymbol->setPosition( aPos ); ! Reference< drawing::XShape > xText( aTextShapes[ nEntry ] ); ! aPos = xText->getPosition(); ! aPos.X += nLegendWidth; ! xText->setPosition( aPos ); ! } ! } rOutLegendSize.Height = nMaxYPos + nYPadding; } *************** *** 528,533 **** --- 560,592 ---- rDest.push_back( rSource[ i ] ); } + bool lcl_shouldSymbolsBePlacedOnTheLeftSide( const Reference< beans::XPropertySet >& xLegendProp, sal_Int16 nDefaultWritingMode ) + { + bool bSymbolsLeftSide = true; + try + { + if( SvtLanguageOptions().IsCTLFontEnabled() ) + { + if(xLegendProp.is()) + { + sal_Int16 nWritingMode=-1; + if( (xLegendProp->getPropertyValue( C2U("WritingMode") ) >>= nWritingMode) ) + { + if( nWritingMode == text::WritingMode2::PAGE ) + nWritingMode = nDefaultWritingMode; + if( nWritingMode == text::WritingMode2::RL_TB ) + bSymbolsLeftSide=false; + } + } + } + } + catch( uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } + return bSymbolsLeftSide; + } + } // anonymous namespace VLegend::VLegend( *************** *** 554,559 **** --- 613,625 ---- // ---------------------------------------- + void VLegend::setDefaultWritingMode( sal_Int16 nDefaultWritingMode ) + { + m_nDefaultWritingMode = nDefaultWritingMode; + } + + // ---------------------------------------- + // static bool VLegend::isVisible( const Reference< XLegend > & xLegend ) { *************** *** 653,665 **** } } // place entries awt::Size aLegendSize; ! lcl_createLegend( aViewEntries, eExpansion, xLegendProp, ! aTextProperties, ! xLegendContainer, m_xShapeFactory, m_xContext, ! rAvailableSpace, rPageSize, ! aLegendSize ); if( xBorder.is()) xBorder->setSize( aLegendSize ); --- 719,732 ---- } } + bool bSymbolsLeftSide = lcl_shouldSymbolsBePlacedOnTheLeftSide( xLegendProp, m_nDefaultWritingMode ); + // place entries awt::Size aLegendSize; ! lcl_placeLegendEntries( aViewEntries, eExpansion, bSymbolsLeftSide ! , xLegendProp, aTextProperties ! , xLegendContainer, m_xShapeFactory, m_xContext ! , rAvailableSpace, rPageSize, aLegendSize ); if( xBorder.is()) xBorder->setSize( aLegendSize ); Index: VLegend.hxx =================================================================== RCS file: /cvs/graphics/chart2/source/view/main/VLegend.hxx,v retrieving revision 1.16 diff -c -r1.16 VLegend.hxx *** VLegend.hxx 10 Apr 2008 22:51:47 -0000 1.16 --- VLegend.hxx 14 Nov 2008 14:23:42 -0000 *************** *** 66,71 **** --- 66,73 ---- const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & xModel ); + void setDefaultWritingMode( sal_Int16 nDefaultWritingMode ); + void createShapes( const ::com::sun::star::awt::Size & rAvailableSpace, const ::com::sun::star::awt::Size & rPageSize ); *************** *** 101,106 **** --- 103,110 ---- ::com::sun::star::uno::XComponentContext > m_xContext; std::vector< LegendEntryProvider* > m_aLegendEntryProviderList; + + sal_Int16 m_nDefaultWritingMode;//to be used when writing mode is set to page }; //.............................................................................