diff options
author | Ingrid Halama [iha] <Ingrid.Halama@oracle.com> | 2011-01-27 20:57:37 +0100 |
---|---|---|
committer | Ingrid Halama [iha] <Ingrid.Halama@oracle.com> | 2011-01-27 20:57:37 +0100 |
commit | d6f9cfd061e34b2354b2f2fa09f833a0dcf1cefe (patch) | |
tree | c2dda935b703456af4784f8348176d78458c834c /chart2 | |
parent | c634a9b59904c79872ba2376fa032e4f68986280 (diff) |
chart52: #28670# make the legend within charts resizeable - part 3
Diffstat (limited to 'chart2')
-rw-r--r-- | chart2/source/controller/dialogs/res_LegendPosition.cxx | 69 | ||||
-rw-r--r-- | chart2/source/controller/itemsetwrapper/LegendItemConverter.cxx | 131 | ||||
-rw-r--r-- | chart2/source/inc/chartview/ChartSfxItemIds.hxx | 3 | ||||
-rwxr-xr-x | chart2/source/model/main/Legend.cxx | 1 | ||||
-rw-r--r-- | chart2/source/view/main/ChartItemPool.cxx | 6 | ||||
-rw-r--r-- | chart2/source/view/main/VLegend.cxx | 167 |
6 files changed, 216 insertions, 161 deletions
diff --git a/chart2/source/controller/dialogs/res_LegendPosition.cxx b/chart2/source/controller/dialogs/res_LegendPosition.cxx index 4d6c7509052c..361019825539 100644 --- a/chart2/source/controller/dialogs/res_LegendPosition.cxx +++ b/chart2/source/controller/dialogs/res_LegendPosition.cxx @@ -45,9 +45,8 @@ //itemset stuff #include "chartview/ChartSfxItemIds.hxx" -#include <svx/chrtitem.hxx> -// header for class SfxItemPool -#include <svl/itempool.hxx> +#include <svl/intitem.hxx> +#include <svl/eitem.hxx> //............................................................................. namespace chart @@ -197,51 +196,51 @@ IMPL_LINK( LegendPositionResources, PositionEnableHdl, void*, EMPTYARG ) void LegendPositionResources::initFromItemSet( const SfxItemSet& rInAttrs ) { - SvxChartLegendPos ePos = CHLEGEND_NONE; - const SfxPoolItem* pPoolItem = NULL; - if( rInAttrs.GetItemState( SCHATTR_LEGEND_POS, - TRUE, &pPoolItem ) != SFX_ITEM_SET ) - pPoolItem = &(rInAttrs.GetPool()->GetDefaultItem( SCHATTR_LEGEND_POS )); - - if( pPoolItem ) - ePos = ((const SvxChartLegendPosItem*)pPoolItem)->GetValue(); + if( rInAttrs.GetItemState( SCHATTR_LEGEND_POS, TRUE, &pPoolItem ) == SFX_ITEM_SET ) + { + sal_Int32 nLegendPosition = ((const SfxInt32Item*)pPoolItem)->GetValue(); + switch( nLegendPosition ) + { + case chart2::LegendPosition_LINE_START: + m_aRbtLeft.Check(TRUE); + break; + case chart2::LegendPosition_PAGE_START: + m_aRbtTop.Check(TRUE); + break; + case chart2::LegendPosition_LINE_END: + m_aRbtRight.Check(TRUE); + break; + case chart2::LegendPosition_PAGE_END: + m_aRbtBottom.Check(TRUE); + break; + default: + break; + } + } - switch( ePos ) + if( rInAttrs.GetItemState( SCHATTR_LEGEND_SHOW, TRUE, &pPoolItem ) == SFX_ITEM_SET ) { - case CHLEGEND_LEFT: - m_aRbtLeft.Check(TRUE); - break; - case CHLEGEND_TOP: - m_aRbtTop.Check(TRUE); - break; - case CHLEGEND_RIGHT: - m_aRbtRight.Check(TRUE); - break; - case CHLEGEND_BOTTOM: - m_aRbtBottom.Check(TRUE); - break; - default: - break; + bool bShow = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue(); + m_aCbxShow.Check(bShow); } + } void LegendPositionResources::writeToItemSet( SfxItemSet& rOutAttrs ) const { - SvxChartLegendPos ePos; - + sal_Int32 nLegendPosition = chart2::LegendPosition_CUSTOM; if( m_aRbtLeft.IsChecked() ) - ePos = CHLEGEND_LEFT; + nLegendPosition = chart2::LegendPosition_LINE_START; else if( m_aRbtTop.IsChecked() ) - ePos = CHLEGEND_TOP; + nLegendPosition = chart2::LegendPosition_PAGE_START; else if( m_aRbtRight.IsChecked() ) - ePos = CHLEGEND_RIGHT; + nLegendPosition = chart2::LegendPosition_LINE_END; else if( m_aRbtBottom.IsChecked() ) - ePos = CHLEGEND_BOTTOM; - else - ePos = CHLEGEND_NONE; + nLegendPosition = chart2::LegendPosition_PAGE_END; + rOutAttrs.Put(SfxInt32Item(SCHATTR_LEGEND_POS, nLegendPosition )); - rOutAttrs.Put(SvxChartLegendPosItem( ePos, SCHATTR_LEGEND_POS )); + rOutAttrs.Put( SfxBoolItem(SCHATTR_LEGEND_SHOW, m_aCbxShow.IsChecked()) ); } IMPL_LINK( LegendPositionResources, PositionChangeHdl, RadioButton*, pRadio ) diff --git a/chart2/source/controller/itemsetwrapper/LegendItemConverter.cxx b/chart2/source/controller/itemsetwrapper/LegendItemConverter.cxx index c02df4aa4bfc..c93505181c0d 100644 --- a/chart2/source/controller/itemsetwrapper/LegendItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/LegendItemConverter.cxx @@ -33,11 +33,13 @@ #include "ItemPropertyMap.hxx" #include "GraphicPropertyItemConverter.hxx" #include "CharacterPropertyItemConverter.hxx" -#include <svx/chrtitem.hxx> #include <com/sun/star/chart2/XLegend.hpp> #include <com/sun/star/chart2/LegendPosition.hpp> #include <com/sun/star/chart/ChartLegendExpansion.hpp> +#include <svl/intitem.hxx> +#include <svl/eitem.hxx> + #include <functional> #include <algorithm> @@ -104,52 +106,19 @@ bool LegendItemConverter::GetItemProperty( tWhichIdType /*nWhichId*/, tPropertyN } -bool LegendItemConverter::ApplySpecialItem( - USHORT nWhichId, const SfxItemSet & rItemSet ) +bool LegendItemConverter::ApplySpecialItem( USHORT nWhichId, const SfxItemSet& rInItemSet ) throw( uno::Exception ) { bool bChanged = false; switch( nWhichId ) { - case SCHATTR_LEGEND_POS: + case SCHATTR_LEGEND_SHOW: { - chart2::LegendPosition eNewPos = chart2::LegendPosition_LINE_END; - chart2::LegendPosition eOldPos; - bool bIsWide = false; - sal_Bool bShow = sal_True; - - SvxChartLegendPos eItemPos = - static_cast< const SvxChartLegendPosItem & >( - rItemSet.Get( nWhichId )).GetValue(); - switch( eItemPos ) - { - case CHLEGEND_LEFT: - eNewPos = chart2::LegendPosition_LINE_START; - break; - case CHLEGEND_RIGHT: - eNewPos = chart2::LegendPosition_LINE_END; - break; - case CHLEGEND_TOP: - eNewPos = chart2::LegendPosition_PAGE_START; - bIsWide = true; - break; - case CHLEGEND_BOTTOM: - eNewPos = chart2::LegendPosition_PAGE_END; - bIsWide = true; - break; - - case CHLEGEND_NONE: - case CHLEGEND_NONE_LEFT: - case CHLEGEND_NONE_RIGHT: - case CHLEGEND_NONE_TOP: - case CHLEGEND_NONE_BOTTOM: - bShow = sal_False; - break; - } - - try + const SfxPoolItem* pPoolItem = NULL; + if( rInItemSet.GetItemState( SCHATTR_LEGEND_SHOW, TRUE, &pPoolItem ) == SFX_ITEM_SET ) { + sal_Bool bShow = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue(); sal_Bool bWasShown = sal_True; if( ! (GetPropertySet()->getPropertyValue( C2U("Show")) >>= bWasShown) || ( bWasShown != bShow )) @@ -157,25 +126,48 @@ bool LegendItemConverter::ApplySpecialItem( GetPropertySet()->setPropertyValue( C2U("Show"), uno::makeAny( bShow )); bChanged = true; } + } + + } + break; + case SCHATTR_LEGEND_POS: + { + const SfxPoolItem* pPoolItem = NULL; + if( rInItemSet.GetItemState( SCHATTR_LEGEND_POS, TRUE, &pPoolItem ) == SFX_ITEM_SET ) + { + chart2::LegendPosition eNewPos = static_cast<chart2::LegendPosition>(((const SfxInt32Item*)pPoolItem)->GetValue()); - if( bShow ) + ::com::sun::star::chart::ChartLegendExpansion eExpansion = ::com::sun::star::chart::ChartLegendExpansion_HIGH; + switch( eNewPos ) { + case chart2::LegendPosition_LINE_START: + case chart2::LegendPosition_LINE_END: + eExpansion = ::com::sun::star::chart::ChartLegendExpansion_HIGH; + break; + case chart2::LegendPosition_PAGE_START: + case chart2::LegendPosition_PAGE_END: + eExpansion = ::com::sun::star::chart::ChartLegendExpansion_WIDE; + break; + default: + break; + } + + try + { + chart2::LegendPosition eOldPos; if( ! ( GetPropertySet()->getPropertyValue( C2U( "AnchorPosition" )) >>= eOldPos ) || ( eOldPos != eNewPos )) { GetPropertySet()->setPropertyValue( C2U( "AnchorPosition" ), uno::makeAny( eNewPos )); - ::com::sun::star::chart::ChartLegendExpansion eExp = bIsWide - ? ::com::sun::star::chart::ChartLegendExpansion_WIDE - : ::com::sun::star::chart::ChartLegendExpansion_HIGH; - GetPropertySet()->setPropertyValue( C2U( "Expansion" ), uno::makeAny( eExp )); + GetPropertySet()->setPropertyValue( C2U( "Expansion" ), uno::makeAny( eExpansion )); GetPropertySet()->setPropertyValue( C2U( "RelativePosition" ), uno::Any()); bChanged = true; } } - } - catch( uno::Exception & ex ) - { - ASSERT_EXCEPTION( ex ); + catch( uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } } } break; @@ -190,43 +182,18 @@ void LegendItemConverter::FillSpecialItem( { switch( nWhichId ) { - case SCHATTR_LEGEND_POS: + case SCHATTR_LEGEND_SHOW: { - SvxChartLegendPos eItemPos( CHLEGEND_RIGHT ); - chart2::LegendPosition ePos; - sal_Bool bShow = sal_True; GetPropertySet()->getPropertyValue( C2U( "Show" )) >>= bShow; - - if( ! bShow ) - { - eItemPos = CHLEGEND_NONE; - } - else if( GetPropertySet()->getPropertyValue( C2U( "AnchorPosition" )) >>= ePos ) - { - switch( ePos ) - { - case chart2::LegendPosition_LINE_START: - eItemPos = CHLEGEND_LEFT; - break; - case chart2::LegendPosition_LINE_END: - eItemPos = CHLEGEND_RIGHT; - break; - case chart2::LegendPosition_PAGE_START: - eItemPos = CHLEGEND_TOP; - break; - case chart2::LegendPosition_PAGE_END: - eItemPos = CHLEGEND_BOTTOM; - break; - - case chart2::LegendPosition_CUSTOM: - default: - eItemPos = CHLEGEND_RIGHT; - break; - } - } - - rOutItemSet.Put( SvxChartLegendPosItem( eItemPos, SCHATTR_LEGEND_POS ) ); + rOutItemSet.Put( SfxBoolItem(SCHATTR_LEGEND_SHOW, bShow) ); + } + break; + case SCHATTR_LEGEND_POS: + { + chart2::LegendPosition eLegendPos( chart2::LegendPosition_LINE_END ); + GetPropertySet()->getPropertyValue( C2U( "AnchorPosition" )) >>= eLegendPos; + rOutItemSet.Put( SfxInt32Item(SCHATTR_LEGEND_POS, eLegendPos ) ); } break; } diff --git a/chart2/source/inc/chartview/ChartSfxItemIds.hxx b/chart2/source/inc/chartview/ChartSfxItemIds.hxx index fbcce70bd1d6..980509fc5890 100644 --- a/chart2/source/inc/chartview/ChartSfxItemIds.hxx +++ b/chart2/source/inc/chartview/ChartSfxItemIds.hxx @@ -53,7 +53,8 @@ #define SCHATTR_LEGEND_START (SCHATTR_DATADESCR_END + 1) #define SCHATTR_LEGEND_POS SCHATTR_LEGEND_START -#define SCHATTR_LEGEND_END SCHATTR_LEGEND_POS +#define SCHATTR_LEGEND_SHOW (SCHATTR_LEGEND_START + 1) +#define SCHATTR_LEGEND_END SCHATTR_LEGEND_SHOW #define SCHATTR_TEXT_START (SCHATTR_LEGEND_END + 1) // #define SCHATTR_TEXT_ORIENT SCHATTR_TEXT_START diff --git a/chart2/source/model/main/Legend.cxx b/chart2/source/model/main/Legend.cxx index 86ee1180e372..64fb39f91b65 100755 --- a/chart2/source/model/main/Legend.cxx +++ b/chart2/source/model/main/Legend.cxx @@ -108,7 +108,6 @@ void lcl_AddPropertiesToVector( beans::PropertyAttribute::BOUND | beans::PropertyAttribute::MAYBEVOID )); - rOutProperties.push_back( Property( C2U( "RelativeSize" ), PROP_LEGEND_REL_SIZE, diff --git a/chart2/source/view/main/ChartItemPool.cxx b/chart2/source/view/main/ChartItemPool.cxx index c997f9ee483d..b58ac633e392 100644 --- a/chart2/source/view/main/ChartItemPool.cxx +++ b/chart2/source/view/main/ChartItemPool.cxx @@ -44,6 +44,8 @@ #include <editeng/editids.hrc> #include <svx/svxids.hrc> +#include <com/sun/star/chart2/LegendPosition.hpp> + namespace chart { @@ -66,7 +68,9 @@ ChartItemPool::ChartItemPool(): ppPoolDefaults[SCHATTR_DATADESCR_AVAILABLE_PLACEMENTS - SCHATTR_START] = new SfxIntegerListItem(SCHATTR_DATADESCR_AVAILABLE_PLACEMENTS,aTmp); ppPoolDefaults[SCHATTR_DATADESCR_NO_PERCENTVALUE - SCHATTR_START] = new SfxBoolItem(SCHATTR_DATADESCR_NO_PERCENTVALUE); - ppPoolDefaults[SCHATTR_LEGEND_POS - SCHATTR_START] = new SvxChartLegendPosItem( CHLEGEND_RIGHT, SCHATTR_LEGEND_POS ); + ppPoolDefaults[SCHATTR_LEGEND_POS - SCHATTR_START] = new SfxInt32Item(SCHATTR_LEGEND_POS, ::com::sun::star::chart2::LegendPosition_LINE_END ); + ppPoolDefaults[SCHATTR_LEGEND_SHOW - SCHATTR_START] = new SfxBoolItem(SCHATTR_LEGEND_SHOW, TRUE); + // ppPoolDefaults[SCHATTR_TEXT_ORIENT - SCHATTR_START] = new SvxChartTextOrientItem; ppPoolDefaults[SCHATTR_TEXT_STACKED - SCHATTR_START] = new SfxBoolItem(SCHATTR_TEXT_STACKED,FALSE); ppPoolDefaults[SCHATTR_TEXT_ORDER - SCHATTR_START] = new SvxChartTextOrderItem(CHTXTORDER_SIDEBYSIDE, SCHATTR_TEXT_ORDER); diff --git a/chart2/source/view/main/VLegend.cxx b/chart2/source/view/main/VLegend.cxx index 046947c50e65..ef6be843694e 100644 --- a/chart2/source/view/main/VLegend.cxx +++ b/chart2/source/view/main/VLegend.cxx @@ -45,6 +45,7 @@ #include <com/sun/star/chart/ChartLegendExpansion.hpp> #include <com/sun/star/chart2/LegendPosition.hpp> #include <com/sun/star/chart2/RelativePosition.hpp> +#include <com/sun/star/container/XChild.hpp> #include <rtl/ustrbuf.hxx> #include <svl/languageoptions.hxx> @@ -266,8 +267,8 @@ awt::Size lcl_placeLegendEntries( double fXOffset = 0.15; double fYOffset = 0.15; - const sal_Int32 nXPadding = static_cast< sal_Int32 >( fViewFontSize * fXPadding ); - const sal_Int32 nYPadding = static_cast< sal_Int32 >( fViewFontSize * fYPadding ); + sal_Int32 nXPadding = static_cast< sal_Int32 >( fViewFontSize * fXPadding ); + sal_Int32 nYPadding = static_cast< sal_Int32 >( fViewFontSize * fYPadding ); const sal_Int32 nXOffset = static_cast< sal_Int32 >( fViewFontSize * fXOffset ); const sal_Int32 nYOffset = static_cast< sal_Int32 >( fViewFontSize * fYOffset ); @@ -294,15 +295,10 @@ awt::Size lcl_placeLegendEntries( awt::Size aMaxEntryExtent = lcl_createTextShapes( rEntries, xShapeFactory, xTarget, aTextShapes, rTextProperties ); OSL_ASSERT( aTextShapes.size() == rEntries.size()); - sal_Int32 nCurrentXPos = nXPadding; - sal_Int32 nCurrentYPos = nYPadding; sal_Int32 nMaxEntryWidth = 2 * nXOffset + aMaxSymbolExtent.Width + aMaxEntryExtent.Width; sal_Int32 nMaxEntryHeight = nYOffset + aMaxEntryExtent.Height; sal_Int32 nNumberOfEntries = rEntries.size(); - if( !bSymbolsLeftSide ) - nCurrentXPos = -nXPadding; - sal_Int32 nNumberOfColumns = 0, nNumberOfRows = 0; std::vector< sal_Int32 > aColumnWidths; @@ -376,6 +372,18 @@ awt::Size lcl_placeLegendEntries( } nNumberOfColumns = aColumnWidths.size(); nNumberOfRows = nCurrentRow+1; + + //check if some space is left an should be spread equally over all entries + sal_Int32 nSumWidth = 0; + for( sal_Int32 nC=0; nC<nNumberOfColumns; nC++ ) + nSumWidth += aColumnWidths[nC]; + sal_Int32 nRemainingSpace = (rAvailableSpace.Width - nSumWidth)/(nNumberOfColumns+1); + if( nRemainingSpace>0 ) + { + nXPadding += nRemainingSpace; + for( sal_Int32 nC=0; nC<nNumberOfColumns; nC++ ) + aColumnWidths[nC] = aColumnWidths[nC] + nRemainingSpace; + } } else if( eExpansion == ::com::sun::star::chart::ChartLegendExpansion_HIGH ) { @@ -429,21 +437,23 @@ awt::Size lcl_placeLegendEntries( if(nNumberOfRows<=0) return aResultingLegendSize; - // calculate maximum height for current row - std::vector< sal_Int32 > nMaxHeights( nNumberOfRows ); + // calculate maximum height for each row + // and collect column widths + std::vector< sal_Int32 > aRowHeights( nNumberOfRows ); sal_Int32 nRow = 0; sal_Int32 nColumn = 0; for( ; nRow < nNumberOfRows; ++nRow ) { - sal_Int32 nMaxHeight = 0; + sal_Int32 nCurrentRowHeight = 0; for( nColumn = 0; nColumn < nNumberOfColumns; ++nColumn ) { sal_Int32 nEntry = (nColumn + nRow * nNumberOfColumns); if( nEntry < nNumberOfEntries ) { awt::Size aTextSize( aTextShapes[ nEntry ]->getSize() ); - nMaxHeight = ::std::max( - nMaxHeight, nYOffset + aTextSize.Height ); + nCurrentRowHeight = ::std::max( nCurrentRowHeight, nYOffset + aTextSize.Height ); + + //collect column widths if( eExpansion != ::com::sun::star::chart::ChartLegendExpansion_CUSTOM ) { sal_Int32 nWidth = nXOffset + aMaxSymbolExtent.Width + aTextSize.Width; @@ -456,54 +466,129 @@ awt::Size lcl_placeLegendEntries( } } } - nMaxHeights[ nRow ] = nMaxHeight; + aRowHeights[ nRow ] = nCurrentRowHeight; } - // place entries ordered in optimal-width columns + const sal_Int32 nFontHeight = static_cast< sal_Int32 >( fViewFontSize ); + sal_Int32 nTextLineHeight = nFontHeight; + for( sal_Int32 nR=0; nR<nNumberOfRows; nR++ ) + { + sal_Int32 nFullTextHeight = aRowHeights[ nR ] - nYOffset; + if( ( nFullTextHeight / nFontHeight ) <= 1 ) + { + nTextLineHeight = nFullTextHeight;//found an entry with one line-> have real text height + break; + } + } + + //check if there is some remaining space that should be spread equally over all rows or whether some rows must be limited + bool bSetMaximumFrameHeight = false; + OUString aPropNameTextMaximumFrameHeight( C2U("TextMaximumFrameHeight") ); + if( eExpansion == ::com::sun::star::chart::ChartLegendExpansion_CUSTOM ) + { + sal_Int32 nSumHeight = 0; + for( sal_Int32 nR=0; nR<nNumberOfRows; nR++ ) + nSumHeight += aRowHeights[nR]; + sal_Int32 nRemainingSpace = (rAvailableSpace.Height - nSumHeight)/(nNumberOfRows+1); + if( nRemainingSpace>0 ) + { + nYPadding += nRemainingSpace; + for( sal_Int32 nR=0; nR<nNumberOfRows; nR++ ) + aRowHeights[nR] = aRowHeights[nR] + nRemainingSpace; + } + else if( nRemainingSpace<0 ) + { + bSetMaximumFrameHeight = true; + } + } + + sal_Int32 nCurrentXPos = nXPadding; + sal_Int32 nCurrentYPos = nYPadding; + if( !bSymbolsLeftSide ) + nCurrentXPos = -nXPadding; + + // place entries into column and rows sal_Int32 nMaxYPos = 0; for( nColumn = 0; nColumn < nNumberOfColumns; ++nColumn ) { nCurrentYPos = nYPadding; - for( nRow = 0; nRow < nNumberOfRows; ++nRow ) { sal_Int32 nEntry = (nColumn + nRow * nNumberOfColumns); - if( nEntry >= nNumberOfEntries ) break; + bool bRemove = false; + // text shape + Reference< drawing::XShape > xTextShape( aTextShapes[nEntry] ); + if( xTextShape.is() ) + { + awt::Size aTextSize( xTextShape->getSize() ); + sal_Int32 nTextXPos = nCurrentXPos + aMaxSymbolExtent.Width; + if( !bSymbolsLeftSide ) + nTextXPos = nCurrentXPos - aMaxSymbolExtent.Width - aTextSize.Width; + xTextShape->setPosition( awt::Point( nTextXPos, nCurrentYPos )); + + if( bSetMaximumFrameHeight ) + { + sal_Int32 nRemainingSpace = rAvailableSpace.Height - (nCurrentYPos + aTextSize.Height); + if( nRemainingSpace < 0 ) + { + Reference< beans::XPropertySet > xTextProp( xTextShape, uno::UNO_QUERY ); + if( xTextProp.is() ) + { + sal_Int32 nLimit = rAvailableSpace.Height - nCurrentYPos; + xTextShape->setSize( awt::Size( aTextSize.Width, nLimit ) ); + static bool bTest = false; + if( bTest ) + { + //todo + xTextProp->setPropertyValue( aPropNameTextMaximumFrameHeight, uno::makeAny(nLimit) ); + xTextProp->setPropertyValue( C2U("TextAutoGrowHeight"), uno::makeAny(sal_False) ); + } + } + bRemove = true; + } + } + } + // symbol Reference< drawing::XShape > xSymbol( rEntries[ nEntry ].aSymbol ); - if( xSymbol.is() ) { - // Note: aspect ratio should always be 3:2 - - // set symbol size to 75% of maximum space - awt::Size aSymbolSize( - 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; - - // #i109336# Improve auto positioning in chart - sal_Int32 nTextHeight = nMaxHeights[ nRow ] - nYOffset; - sal_Int32 nFontSize = static_cast< sal_Int32 >( fViewFontSize ); - sal_Int32 nMaxRowHeight = ( ( ( nTextHeight / nFontSize ) <= 1 ) ? nTextHeight : nFontSize ); - sal_Int32 nSymbolYPos = nCurrentYPos + ( ( nMaxRowHeight - aSymbolSize.Height ) / 2 ); - xSymbol->setPosition( awt::Point( nSymbolXPos, nSymbolYPos ) ); + if( bRemove ) + { + uno::Reference< container::XChild > xChild( xSymbol, uno::UNO_QUERY ); + if( xChild.is() ) + { + uno::Reference<drawing::XShapes> xShapes( xChild->getParent(), uno::UNO_QUERY ); + if( xShapes.is() ) + { + xShapes->remove(xSymbol); + } + } + } + else + { + // Note: aspect ratio should always be 3:2 + // set symbol size to 75% of maximum space + awt::Size aSymbolSize( + 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; + + sal_Int32 nSymbolYPos = nCurrentYPos + ( ( nTextLineHeight - aSymbolSize.Height ) / 2 ); + xSymbol->setPosition( awt::Point( nSymbolXPos, nSymbolYPos ) ); + } } - // position text shape - awt::Size aTextSize( aTextShapes[ nEntry ]->getSize()); - sal_Int32 nTextXPos = nCurrentXPos + aMaxSymbolExtent.Width; - if( !bSymbolsLeftSide ) - nTextXPos = nCurrentXPos - aMaxSymbolExtent.Width - aTextSize.Width; - aTextShapes[ nEntry ]->setPosition( awt::Point( nTextXPos, nCurrentYPos )); + if( bRemove ) + break; //-> next column - nCurrentYPos += nMaxHeights[ nRow ]; + nCurrentYPos += aRowHeights[ nRow ]; nMaxYPos = ::std::max( nMaxYPos, nCurrentYPos ); } if( bSymbolsLeftSide ) |