chart2/source/view/main/VLegend.cxx | 74 +++++++++++++++--------------------- 1 file changed, 31 insertions(+), 43 deletions(-)
New commits: commit aaa0728d88a05706aba7b097fe3542a71cc66bb5 Author: Tomaž Vajngerl <[email protected]> Date: Thu Jan 26 10:35:15 2017 +0100 chart2: too long line Change-Id: I1ed0b51156ef2d6231908f18be64e49b754789bd diff --git a/chart2/source/view/main/VLegend.cxx b/chart2/source/view/main/VLegend.cxx index c96cbd4..766b16d 100644 --- a/chart2/source/view/main/VLegend.cxx +++ b/chart2/source/view/main/VLegend.cxx @@ -877,7 +877,9 @@ void VLegend::createShapes( { if (pLegendEntryProvider) { - std::vector< ViewLegendEntry > aNewEntries = pLegendEntryProvider->createLegendEntries( aMaxSymbolExtent, eExpansion, xLegendProp, xLegendContainer, m_xShapeFactory, m_xContext ); + std::vector<ViewLegendEntry> aNewEntries = pLegendEntryProvider->createLegendEntries( + aMaxSymbolExtent, eExpansion, xLegendProp, + xLegendContainer, m_xShapeFactory, m_xContext); aViewEntries.insert( aViewEntries.end(), aNewEntries.begin(), aNewEntries.end() ); } } commit 8a8a946c88a01a4fdbfe64bb03fa713fba5c2776 Author: Tomaž Vajngerl <[email protected]> Date: Thu Jan 26 10:30:49 2017 +0100 chart2: some more for-loop changes in VLegend Change-Id: I3c0c0b7463a45917c98f8dc766c781acf62da963 diff --git a/chart2/source/view/main/VLegend.cxx b/chart2/source/view/main/VLegend.cxx index e756155..c96cbd4 100644 --- a/chart2/source/view/main/VLegend.cxx +++ b/chart2/source/view/main/VLegend.cxx @@ -153,13 +153,12 @@ awt::Size lcl_createTextShapes( awt::Size aResult; AbstractShapeFactory* pShapeFactory = AbstractShapeFactory::getOrCreateShapeFactory(xShapeFactory); - for( std::vector<ViewLegendEntry>::const_iterator aIt( rEntries.begin()); - aIt != rEntries.end(); ++aIt ) + for (ViewLegendEntry const & rEntry : rEntries) { try { OUString aLabelString; - Sequence< Reference< XFormattedString2 > > aLabelSeq = (*aIt).aLabel; + Sequence< Reference< XFormattedString2 > > aLabelSeq = rEntry.aLabel; for( sal_Int32 i = 0; i < aLabelSeq.getLength(); ++i ) { // todo: support more than one text range @@ -196,12 +195,10 @@ void lcl_collectColumnWidths( std::vector< sal_Int32 >& rColumnWidths, const sal const ::std::vector< Reference< drawing::XShape > >& rTextShapes, sal_Int32 nSymbolPlusDistanceWidth ) { rColumnWidths.clear(); - sal_Int32 nRow = 0; - sal_Int32 nColumn = 0; sal_Int32 nNumberOfEntries = rTextShapes.size(); - for( ; nRow < nNumberOfRows; ++nRow ) + for (sal_Int32 nRow = 0; nRow < nNumberOfRows; ++nRow ) { - for( nColumn = 0; nColumn < nNumberOfColumns; ++nColumn ) + for (sal_Int32 nColumn = 0; nColumn < nNumberOfColumns; ++nColumn ) { sal_Int32 nEntry = (nColumn + nRow * nNumberOfColumns); if( nEntry < nNumberOfEntries ) @@ -223,13 +220,11 @@ void lcl_collectRowHeighs( std::vector< sal_Int32 >& rRowHeights, const sal_Int3 // calculate maximum height for each row // and collect column widths rRowHeights.clear(); - sal_Int32 nRow = 0; - sal_Int32 nColumn = 0; sal_Int32 nNumberOfEntries = rTextShapes.size(); - for( ; nRow < nNumberOfRows; ++nRow ) + for (sal_Int32 nRow = 0; nRow < nNumberOfRows; ++nRow) { sal_Int32 nCurrentRowHeight = 0; - for( nColumn = 0; nColumn < nNumberOfColumns; ++nColumn ) + for (sal_Int32 nColumn = 0; nColumn < nNumberOfColumns; ++nColumn) { sal_Int32 nEntry = (nColumn + nRow * nNumberOfColumns); if( nEntry < nNumberOfEntries ) @@ -246,9 +241,9 @@ sal_Int32 lcl_getTextLineHeight( const std::vector< sal_Int32 >& aRowHeights, co { const sal_Int32 nFontHeight = static_cast< sal_Int32 >( fViewFontSize ); sal_Int32 nTextLineHeight = nFontHeight; - for( sal_Int32 nR=0; nR<nNumberOfRows; nR++ ) + for (sal_Int32 nRow = 0; nRow < nNumberOfRows; ++nRow) { - sal_Int32 nFullTextHeight = aRowHeights[ nR ]; + sal_Int32 nFullTextHeight = aRowHeights[nRow]; if( ( nFullTextHeight / nFontHeight ) <= 1 ) { nTextLineHeight = nFullTextHeight;//found an entry with one line-> have real text height @@ -347,8 +342,8 @@ awt::Size lcl_placeLegendEntries( //do the columns still fit into the given size? nCurrentColumnCount = aColumnWidths.size();//update count sal_Int32 nSumWidth = 0; - for( sal_Int32 nC=0; nC<nCurrentColumnCount; nC++ ) - nSumWidth += aColumnWidths[nC]; + for (sal_Int32 nColumn = 0; nColumn < nCurrentColumnCount; nColumn++) + nSumWidth += aColumnWidths[nColumn]; if( nSumWidth <= rAvailableSpace.Width || nCurrentColumnCount==1 ) { @@ -381,18 +376,18 @@ awt::Size lcl_placeLegendEntries( lcl_collectRowHeighs( aRowHeights, nNumberOfRows, nNumberOfColumns, aTextShapes ); nTextLineHeight = lcl_getTextLineHeight( aRowHeights, nNumberOfRows, fViewFontSize ); sal_Int32 nSumHeight = 0; - for( sal_Int32 nR=0; nR<nNumberOfRows; nR++ ) - nSumHeight += aRowHeights[nR]; + for (sal_Int32 nRow=0; nRow < nNumberOfRows; nRow++) + nSumHeight += aRowHeights[nRow]; sal_Int32 nRemainingSpace = rAvailableSpace.Height - nSumHeight; if( nRemainingSpace < -100 ) // 1mm tolerance for OOXML interop tdf#90404 { //remove entries that are too big - for( sal_Int32 nR=nNumberOfRows; nR--; ) + for (sal_Int32 nRow = nNumberOfRows; nRow--; ) { - for( sal_Int32 nC=nNumberOfColumns; nC--; ) + for (sal_Int32 nColumn = nNumberOfColumns; nColumn--; ) { - sal_Int32 nEntry = (nC + nR * nNumberOfColumns); + sal_Int32 nEntry = (nColumn + nRow * nNumberOfColumns); if( nEntry < static_cast<sal_Int32>(aTextShapes.size()) ) { DrawModelWrapper::removeShape( aTextShapes[nEntry] ); @@ -405,7 +400,7 @@ awt::Size lcl_placeLegendEntries( nNumberOfEntries--; } } - nSumHeight -= aRowHeights[nR]; + nSumHeight -= aRowHeights[nRow]; aRowHeights.pop_back(); nRemainingSpace = rAvailableSpace.Height - nSumHeight; if( nRemainingSpace>=0 ) @@ -432,8 +427,8 @@ awt::Size lcl_placeLegendEntries( //check spacing between columns sal_Int32 nSumWidth = 0; - for( sal_Int32 nC=0; nC<nNumberOfColumns; nC++ ) - nSumWidth += aColumnWidths[nC]; + for (sal_Int32 nColumn = 0; nColumn < nNumberOfColumns; nColumn++) + nSumWidth += aColumnWidths[nColumn]; nRemainingSpace = rAvailableSpace.Width - nSumWidth; if( nRemainingSpace>=0 ) { @@ -515,12 +510,11 @@ awt::Size lcl_placeLegendEntries( // place entries into column and rows sal_Int32 nMaxYPos = 0; - sal_Int32 nRow = 0; - sal_Int32 nColumn = 0; - for( nColumn = 0; nColumn < nNumberOfColumns; ++nColumn ) + + for (sal_Int32 nColumn = 0; nColumn < nNumberOfColumns; ++nColumn) { sal_Int32 nCurrentYPos = nYPadding; - for( nRow = 0; nRow < nNumberOfRows; ++nRow ) + for (sal_Int32 nRow = 0; nRow < nNumberOfRows; ++nRow) { sal_Int32 nEntry = (nColumn + nRow * nNumberOfColumns); if( nEntry >= nNumberOfEntries ) commit 7e9d2ccdbb6a4aa81c8280aa04f6f2ef492d6154 Author: Tomaž Vajngerl <[email protected]> Date: Thu Jan 26 10:13:03 2017 +0100 chart2: remove typedef for std::vector, remove commented code Change-Id: I62c4cbd0f1ed3d7ea0715475d58e0ee130f3ca00 diff --git a/chart2/source/view/main/VLegend.cxx b/chart2/source/view/main/VLegend.cxx index 6aa089b..e756155 100644 --- a/chart2/source/view/main/VLegend.cxx +++ b/chart2/source/view/main/VLegend.cxx @@ -56,8 +56,6 @@ namespace typedef ::std::pair< ::chart::tNameSequence, ::chart::tAnySequence > tPropertyValues; -typedef ::std::vector< ViewLegendEntry > tViewLegendEntryContainer; - double lcl_CalcViewFontSize( const Reference< beans::XPropertySet > & xProp, const awt::Size & rReferenceSize ) @@ -146,7 +144,7 @@ void lcl_getProperties( } awt::Size lcl_createTextShapes( - const tViewLegendEntryContainer & rEntries, + const std::vector<ViewLegendEntry> & rEntries, const Reference< lang::XMultiServiceFactory > & xShapeFactory, const Reference< drawing::XShapes > & xTarget, ::std::vector< Reference< drawing::XShape > > & rOutTextShapes, @@ -155,7 +153,7 @@ awt::Size lcl_createTextShapes( awt::Size aResult; AbstractShapeFactory* pShapeFactory = AbstractShapeFactory::getOrCreateShapeFactory(xShapeFactory); - for( tViewLegendEntryContainer::const_iterator aIt( rEntries.begin()); + for( std::vector<ViewLegendEntry>::const_iterator aIt( rEntries.begin()); aIt != rEntries.end(); ++aIt ) { try @@ -262,7 +260,7 @@ sal_Int32 lcl_getTextLineHeight( const std::vector< sal_Int32 >& aRowHeights, co //returns resulting legend size awt::Size lcl_placeLegendEntries( - tViewLegendEntryContainer & rEntries, + std::vector<ViewLegendEntry> & rEntries, css::chart::ChartLegendExpansion eExpansion, bool bSymbolsLeftSide, double fViewFontSize, @@ -279,11 +277,9 @@ awt::Size lcl_placeLegendEntries( // #i109336# Improve auto positioning in chart sal_Int32 nXPadding = static_cast< sal_Int32 >( std::max( 100.0, fViewFontSize * 0.33 ) ); - //sal_Int32 nXPadding = static_cast< sal_Int32 >( std::max( 200.0, fViewFontSize * 0.33 ) ); sal_Int32 nXOffset = static_cast< sal_Int32 >( std::max( 100.0, fViewFontSize * 0.66 ) ); sal_Int32 nYPadding = static_cast< sal_Int32 >( std::max( 100.0, fViewFontSize * 0.2 ) ); sal_Int32 nYOffset = static_cast< sal_Int32 >( std::max( 100.0, fViewFontSize * 0.2 ) ); - //sal_Int32 nYOffset = static_cast< sal_Int32 >( std::max( 230.0, fViewFontSize * 0.45 ) ); const sal_Int32 nSymbolToTextDistance = static_cast< sal_Int32 >( std::max( 100.0, fViewFontSize * 0.22 ) );//minimum 1mm const sal_Int32 nSymbolPlusDistanceWidth = rMaxSymbolExtent.Width + nSymbolToTextDistance; @@ -882,7 +878,7 @@ void VLegend::createShapes( } awt::Size aMaxSymbolExtent( nSymbolWidth, nSymbolHeight ); - tViewLegendEntryContainer aViewEntries; + std::vector<ViewLegendEntry> aViewEntries; for(LegendEntryProvider* pLegendEntryProvider : m_aLegendEntryProviderList) { if (pLegendEntryProvider) commit 85295504351bf71206fd36bcb38e3e8a262996a3 Author: Tomaž Vajngerl <[email protected]> Date: Thu Jan 26 10:03:50 2017 +0100 chart2: use c++11 for-loop in VLegend Change-Id: I8f42fa30f49a8c1dc271017dda826279c45460eb diff --git a/chart2/source/view/main/VLegend.cxx b/chart2/source/view/main/VLegend.cxx index a923694..6aa089b 100644 --- a/chart2/source/view/main/VLegend.cxx +++ b/chart2/source/view/main/VLegend.cxx @@ -867,12 +867,9 @@ void VLegend::createShapes( sal_Int32 nSymbolHeight = static_cast< sal_Int32 >( fViewFontSize * 0.6 ); sal_Int32 nSymbolWidth = static_cast< sal_Int32 >( nSymbolHeight ); - ::std::vector< LegendEntryProvider* >::const_iterator aIter = m_aLegendEntryProviderList.begin(); - const ::std::vector< LegendEntryProvider* >::const_iterator aEnd = m_aLegendEntryProviderList.end(); - for( aIter = m_aLegendEntryProviderList.begin(); aIter != aEnd; ++aIter ) + for (LegendEntryProvider* pLegendEntryProvider : m_aLegendEntryProviderList) { - LegendEntryProvider* pLegendEntryProvider( *aIter ); - if( pLegendEntryProvider ) + if (pLegendEntryProvider) { awt::Size aCurrentRatio = pLegendEntryProvider->getPreferredLegendKeyAspectRatio(); sal_Int32 nCurrentWidth = aCurrentRatio.Width; @@ -886,10 +883,9 @@ void VLegend::createShapes( awt::Size aMaxSymbolExtent( nSymbolWidth, nSymbolHeight ); tViewLegendEntryContainer aViewEntries; - for( aIter = m_aLegendEntryProviderList.begin(); aIter != aEnd; ++aIter ) + for(LegendEntryProvider* pLegendEntryProvider : m_aLegendEntryProviderList) { - LegendEntryProvider* pLegendEntryProvider( *aIter ); - if( pLegendEntryProvider ) + if (pLegendEntryProvider) { std::vector< ViewLegendEntry > aNewEntries = pLegendEntryProvider->createLegendEntries( aMaxSymbolExtent, eExpansion, xLegendProp, xLegendContainer, m_xShapeFactory, m_xContext ); aViewEntries.insert( aViewEntries.end(), aNewEntries.begin(), aNewEntries.end() );
_______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
