diff options
Diffstat (limited to 'chart2/source/view/main')
-rw-r--r-- | chart2/source/view/main/ChartView.cxx | 81 | ||||
-rw-r--r-- | chart2/source/view/main/PropertyMapper.cxx | 2 | ||||
-rw-r--r-- | chart2/source/view/main/ShapeFactory.cxx | 425 | ||||
-rw-r--r-- | chart2/source/view/main/Stripe.cxx | 161 | ||||
-rw-r--r-- | chart2/source/view/main/VDataSeries.cxx | 4 | ||||
-rw-r--r-- | chart2/source/view/main/VLegend.cxx | 108 | ||||
-rw-r--r-- | chart2/source/view/main/VLegendSymbolFactory.cxx | 14 | ||||
-rw-r--r-- | chart2/source/view/main/VTitle.cxx | 15 |
8 files changed, 588 insertions, 222 deletions
diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx index da8798fe31b6..549ef0273595 100644 --- a/chart2/source/view/main/ChartView.cxx +++ b/chart2/source/view/main/ChartView.cxx @@ -218,13 +218,15 @@ ChartView::~ChartView() void ChartView::impl_deleteCoordinateSystems() { //delete all coordinate systems - ::std::vector< VCoordinateSystem* >::const_iterator aIter = m_aVCooSysList.begin(); - const ::std::vector< VCoordinateSystem* >::const_iterator aEnd = m_aVCooSysList.end(); + ::std::vector< VCoordinateSystem* > aVectorToDeleteObjects; + ::std::swap( aVectorToDeleteObjects, m_aVCooSysList );//#i109770# + ::std::vector< VCoordinateSystem* >::const_iterator aIter = aVectorToDeleteObjects.begin(); + const ::std::vector< VCoordinateSystem* >::const_iterator aEnd = aVectorToDeleteObjects.end(); for( ; aIter != aEnd; aIter++ ) { delete *aIter; } - m_aVCooSysList.clear(); + aVectorToDeleteObjects.clear(); } @@ -2155,7 +2157,7 @@ void changePositionOfAxisTitle( VTitle* pVTitle, TitleAlignment eAlignment pVTitle->changePosition( aNewPosition ); } -std::auto_ptr<VTitle> lcl_createTitle( const uno::Reference< XTitle >& xTitle +std::auto_ptr<VTitle> lcl_createTitle( TitleHelper::eTitleType eType , const uno::Reference< drawing::XShapes>& xPageShapes , const uno::Reference< lang::XMultiServiceFactory>& xShapeFactory , const uno::Reference< frame::XModel >& xChartModel @@ -2165,10 +2167,32 @@ std::auto_ptr<VTitle> lcl_createTitle( const uno::Reference< XTitle >& xTitle , bool& rbAutoPosition ) { std::auto_ptr<VTitle> apVTitle; + + // #i109336# Improve auto positioning in chart + double fPercentage = lcl_getPageLayoutDistancePercentage(); + sal_Int32 nXDistance = static_cast< sal_Int32 >( rPageSize.Width * fPercentage ); + sal_Int32 nYDistance = static_cast< sal_Int32 >( rPageSize.Height * fPercentage ); + if ( eType == TitleHelper::MAIN_TITLE ) + { + sal_Int32 nYOffset = 135; // 1/100 mm + nYDistance += nYOffset; + } + else if ( eType == TitleHelper::TITLE_AT_STANDARD_X_AXIS_POSITION ) + { + sal_Int32 nYOffset = 420; // 1/100 mm + nYDistance = nYOffset; + } + else if ( eType == TitleHelper::TITLE_AT_STANDARD_Y_AXIS_POSITION ) + { + sal_Int32 nXOffset = 450; // 1/100 mm + nXDistance = nXOffset; + } + + uno::Reference< XTitle > xTitle( TitleHelper::getTitle( eType, xChartModel ) ); if(xTitle.is()) { rtl::OUString aCompleteString( TitleHelper::getCompleteString( xTitle ) ); - if( aCompleteString.getLength()==0 ) + if ( aCompleteString.getLength() == 0 ) return apVTitle;//don't create empty titles as the resulting diagram position is wrong then //create title @@ -2182,8 +2206,6 @@ std::auto_ptr<VTitle> lcl_createTitle( const uno::Reference< XTitle >& xTitle //position rbAutoPosition=true; awt::Point aNewPosition(0,0); - sal_Int32 nYDistance = static_cast<sal_Int32>(rPageSize.Height*lcl_getPageLayoutDistancePercentage()); - sal_Int32 nXDistance = static_cast<sal_Int32>(rPageSize.Width*lcl_getPageLayoutDistancePercentage()); chart2::RelativePosition aRelativePosition; uno::Reference< beans::XPropertySet > xProp(xTitle, uno::UNO_QUERY); if( xProp.is() && (xProp->getPropertyValue( C2U( "RelativePosition" ) )>>=aRelativePosition) ) @@ -2247,6 +2269,37 @@ std::auto_ptr<VTitle> lcl_createTitle( const uno::Reference< XTitle >& xTitle break; } } + else + { + // #i109336# Improve auto positioning in chart + switch ( eAlignment ) + { + case ALIGN_TOP: + { + rRemainingSpace.Y += nYDistance; + rRemainingSpace.Height -= nYDistance; + } + break; + case ALIGN_BOTTOM: + { + rRemainingSpace.Height -= nYDistance; + } + break; + case ALIGN_LEFT: + { + rRemainingSpace.X += nXDistance; + rRemainingSpace.Width -= nXDistance; + } + break; + case ALIGN_RIGHT: + { + rRemainingSpace.Width -= nXDistance; + } + break; + default: + break; + } + } return apVTitle; } @@ -2476,13 +2529,13 @@ void ChartView::createShapes() bool bAutoPositionDummy = true; //------------ create main title shape - lcl_createTitle( TitleHelper::getTitle( TitleHelper::MAIN_TITLE, m_xChartModel ), xPageShapes, m_xShapeFactory, m_xChartModel + lcl_createTitle( TitleHelper::MAIN_TITLE, xPageShapes, m_xShapeFactory, m_xChartModel , aRemainingSpace, aPageSize, ALIGN_TOP, bAutoPositionDummy ); if(aRemainingSpace.Width<=0||aRemainingSpace.Height<=0) return; //------------ create sub title shape - lcl_createTitle( TitleHelper::getTitle( TitleHelper::SUB_TITLE, m_xChartModel ), xPageShapes, m_xShapeFactory, m_xChartModel + lcl_createTitle( TitleHelper::SUB_TITLE, xPageShapes, m_xShapeFactory, m_xChartModel , aRemainingSpace, aPageSize, ALIGN_TOP, bAutoPositionDummy ); if(aRemainingSpace.Width<=0||aRemainingSpace.Height<=0) return; @@ -2506,7 +2559,7 @@ void ChartView::createShapes() bool bAutoPosition_XTitle = true; std::auto_ptr<VTitle> apVTitle_X; if( ChartTypeHelper::isSupportingMainAxis( xChartType, nDimension, 0 ) ) - apVTitle_X = lcl_createTitle( TitleHelper::getTitle( TitleHelper::TITLE_AT_STANDARD_X_AXIS_POSITION, m_xChartModel ), xPageShapes, m_xShapeFactory, m_xChartModel + apVTitle_X = lcl_createTitle( TitleHelper::TITLE_AT_STANDARD_X_AXIS_POSITION, xPageShapes, m_xShapeFactory, m_xChartModel , aRemainingSpace, aPageSize, ALIGN_BOTTOM, bAutoPosition_XTitle ); if(aRemainingSpace.Width<=0||aRemainingSpace.Height<=0) return; @@ -2515,7 +2568,7 @@ void ChartView::createShapes() bool bAutoPosition_YTitle = true; std::auto_ptr<VTitle> apVTitle_Y; if( ChartTypeHelper::isSupportingMainAxis( xChartType, nDimension, 1 ) ) - apVTitle_Y = lcl_createTitle( TitleHelper::getTitle( TitleHelper::TITLE_AT_STANDARD_Y_AXIS_POSITION, m_xChartModel ), xPageShapes, m_xShapeFactory, m_xChartModel + apVTitle_Y = lcl_createTitle( TitleHelper::TITLE_AT_STANDARD_Y_AXIS_POSITION, xPageShapes, m_xShapeFactory, m_xChartModel , aRemainingSpace, aPageSize, ALIGN_LEFT, bAutoPosition_YTitle ); if(aRemainingSpace.Width<=0||aRemainingSpace.Height<=0) return; @@ -2524,7 +2577,7 @@ void ChartView::createShapes() bool bAutoPosition_ZTitle = true; std::auto_ptr<VTitle> apVTitle_Z; if( ChartTypeHelper::isSupportingMainAxis( xChartType, nDimension, 2 ) ) - apVTitle_Z = lcl_createTitle( TitleHelper::getTitle( TitleHelper::Z_AXIS_TITLE, m_xChartModel ), xPageShapes, m_xShapeFactory, m_xChartModel + apVTitle_Z = lcl_createTitle( TitleHelper::Z_AXIS_TITLE, xPageShapes, m_xShapeFactory, m_xChartModel , aRemainingSpace, aPageSize, ALIGN_RIGHT, bAutoPosition_ZTitle ); if(aRemainingSpace.Width<=0||aRemainingSpace.Height<=0) return; @@ -2536,7 +2589,7 @@ void ChartView::createShapes() bool bAutoPosition_SecondXTitle = true; std::auto_ptr<VTitle> apVTitle_SecondX; if( ChartTypeHelper::isSupportingSecondaryAxis( xChartType, nDimension, 0 ) ) - apVTitle_SecondX = lcl_createTitle( TitleHelper::getTitle( TitleHelper::SECONDARY_X_AXIS_TITLE, m_xChartModel ), xPageShapes, m_xShapeFactory, m_xChartModel + apVTitle_SecondX = lcl_createTitle( TitleHelper::SECONDARY_X_AXIS_TITLE, xPageShapes, m_xShapeFactory, m_xChartModel , aRemainingSpace, aPageSize, bIsVertical? ALIGN_RIGHT : ALIGN_TOP, bAutoPosition_SecondXTitle ); if(aRemainingSpace.Width<=0||aRemainingSpace.Height<=0) return; @@ -2545,7 +2598,7 @@ void ChartView::createShapes() bool bAutoPosition_SecondYTitle = true; std::auto_ptr<VTitle> apVTitle_SecondY; if( ChartTypeHelper::isSupportingSecondaryAxis( xChartType, nDimension, 1 ) ) - apVTitle_SecondY = lcl_createTitle( TitleHelper::getTitle( TitleHelper::SECONDARY_Y_AXIS_TITLE, m_xChartModel ), xPageShapes, m_xShapeFactory, m_xChartModel + apVTitle_SecondY = lcl_createTitle( TitleHelper::SECONDARY_Y_AXIS_TITLE, xPageShapes, m_xShapeFactory, m_xChartModel , aRemainingSpace, aPageSize, bIsVertical? ALIGN_TOP : ALIGN_RIGHT, bAutoPosition_SecondYTitle ); if(aRemainingSpace.Width<=0||aRemainingSpace.Height<=0) return; diff --git a/chart2/source/view/main/PropertyMapper.cxx b/chart2/source/view/main/PropertyMapper.cxx index 6e53ce22aff7..1979582763fa 100644 --- a/chart2/source/view/main/PropertyMapper.cxx +++ b/chart2/source/view/main/PropertyMapper.cxx @@ -529,7 +529,7 @@ void PropertyMapper::getPreparedTextShapePropertyLists( // use a line-joint showing the border of thick lines like two rectangles // filled in between. - aValueMap[C2U("LineJoint")] <<= drawing::LineJoint_MITER; + aValueMap[C2U("LineJoint")] <<= drawing::LineJoint_ROUND; PropertyMapper::getMultiPropertyListsFromValueMap( rPropNames, rPropValues, aValueMap ); } diff --git a/chart2/source/view/main/ShapeFactory.cxx b/chart2/source/view/main/ShapeFactory.cxx index 0be0c04c18d9..721cabd15d83 100644 --- a/chart2/source/view/main/ShapeFactory.cxx +++ b/chart2/source/view/main/ShapeFactory.cxx @@ -67,6 +67,7 @@ #include <algorithm> using namespace ::com::sun::star; +using ::com::sun::star::uno::Reference; //............................................................................. namespace chart @@ -268,110 +269,99 @@ uno::Any createPolyPolygon_Cube( uno::Any createPolyPolygon_Cylinder( double fHeight , double fRadius - , double fRoundedEdge , sal_Int32& nVerticalSegmentCount ) { - //@todo consider offset if Height is negative - -// DBG_ASSERT(fHeight>0, "The height of a cylinder needs to be > 0"); + //fHeight may be negative DBG_ASSERT(fRadius>0, "The radius of a cylinder needs to be > 0"); - DBG_ASSERT(fRoundedEdge>=0, "fRoundedEdge needs to be >= 0"); - - // always use extra points, so set percent diagonal to 0.4 which is 0% in the UI (old Chart comment) - if( fRoundedEdge == 0.0 ) - fRoundedEdge = 0.4 / 200.0; - -// const double fWidth = fRadius; - - fRoundedEdge = 0.0; - const double fOffset = (fRadius * 2.0 * fRoundedEdge) * 1.05; // increase by 5% for safety - const bool bRoundEdges = fRoundedEdge && fOffset < fRadius && 2.0 * fOffset < fHeight; - const sal_Int32 nPointCount = bRoundEdges ? 8 : 4; - nVerticalSegmentCount = nPointCount-1; //-------------------------------------- drawing::PolyPolygonShape3D aPP; - aPP.SequenceX.realloc(1); - aPP.SequenceY.realloc(1); - aPP.SequenceZ.realloc(1); + nVerticalSegmentCount=1; + + aPP.SequenceX.realloc(3); + aPP.SequenceY.realloc(3); + aPP.SequenceZ.realloc(3); drawing::DoubleSequence* pOuterSequenceX = aPP.SequenceX.getArray(); drawing::DoubleSequence* pOuterSequenceY = aPP.SequenceY.getArray(); drawing::DoubleSequence* pOuterSequenceZ = aPP.SequenceZ.getArray(); - pOuterSequenceX->realloc(nPointCount); - pOuterSequenceY->realloc(nPointCount); - pOuterSequenceZ->realloc(nPointCount); + pOuterSequenceX->realloc(2); + pOuterSequenceY->realloc(2); + pOuterSequenceZ->realloc(2); double* pInnerSequenceX = pOuterSequenceX->getArray(); double* pInnerSequenceY = pOuterSequenceY->getArray(); double* pInnerSequenceZ = pOuterSequenceZ->getArray(); - for(sal_Int32 nN = nPointCount; nN--;) + double fY1 = 0.0; + double fY2 = fHeight; + + if( fHeight<0.0 ) + ::std::swap(fY1,fY2); + + //---------------------------- + for(sal_Int32 nN = 2; nN--;) *pInnerSequenceZ++ = 0.0; - if(nPointCount == 4) - { - *pInnerSequenceY++ = 0.0; - *pInnerSequenceY++ = 0.0; - *pInnerSequenceY++ = fHeight; - *pInnerSequenceY++ = fHeight; + *pInnerSequenceX++ = 0.0; + *pInnerSequenceY++ = fY1; - *pInnerSequenceX++ = 0.0; - *pInnerSequenceX++ = fRadius; - *pInnerSequenceX++ = fRadius; - *pInnerSequenceX++ = 0.0; - } - else - { - *pInnerSequenceY++ = 0.0; //1. - *pInnerSequenceY++ = 0.0; - *pInnerSequenceY++ = 0.0; - *pInnerSequenceY++ = fOffset; - *pInnerSequenceY++ = fHeight - fOffset; - *pInnerSequenceY++ = fHeight; //6. - *pInnerSequenceY++ = fHeight; - *pInnerSequenceY++ = fHeight; + *pInnerSequenceX++ = fRadius; + *pInnerSequenceY++ = fY1; + //---------------------------- + + pOuterSequenceX++;pOuterSequenceY++;pOuterSequenceZ++; + pOuterSequenceX->realloc(2); + pOuterSequenceY->realloc(2); + pOuterSequenceZ->realloc(2); + + pInnerSequenceX = pOuterSequenceX->getArray(); + pInnerSequenceY = pOuterSequenceY->getArray(); + pInnerSequenceZ = pOuterSequenceZ->getArray(); + + //---------------------------- + for(sal_Int32 nN = 2; nN--;) + *pInnerSequenceZ++ = 0.0; + + *pInnerSequenceX++ = fRadius; + *pInnerSequenceY++ = fY1; + + *pInnerSequenceX++ = fRadius; + *pInnerSequenceY++ = fY2; + //---------------------------- + + pOuterSequenceX++;pOuterSequenceY++;pOuterSequenceZ++; + pOuterSequenceX->realloc(2); + pOuterSequenceY->realloc(2); + pOuterSequenceZ->realloc(2); + + pInnerSequenceX = pOuterSequenceX->getArray(); + pInnerSequenceY = pOuterSequenceY->getArray(); + pInnerSequenceZ = pOuterSequenceZ->getArray(); + + //---------------------------- + for(sal_Int32 nN = 2; nN--;) + *pInnerSequenceZ++ = 0.0; + + *pInnerSequenceX++ = fRadius; + *pInnerSequenceY++ = fY2; + + *pInnerSequenceX++ = 0.0; + *pInnerSequenceY++ = fY2; + //---------------------------- - *pInnerSequenceX++ = 0.0; //1. - *pInnerSequenceX++ = fRadius - fOffset; - *pInnerSequenceX++ = fRadius; - *pInnerSequenceX++ = fRadius; - *pInnerSequenceX++ = fRadius; - *pInnerSequenceX++ = fRadius; //6. - *pInnerSequenceX++ = fRadius - fOffset; - *pInnerSequenceX++ = 0.0; - } return uno::Any( &aPP, ::getCppuType((const drawing::PolyPolygonShape3D*)0) ); } -uno::Any createPolyPolygon_Cone( - double fHeight - , double fRadius - , double fTopHeight - , double fRoundedEdge +uno::Any createPolyPolygon_Cone( double fHeight, double fRadius, double fTopHeight , sal_Int32& nVerticalSegmentCount ) { - //@todo consider offset if Height is negative -/* - DBG_ASSERT(fHeight>0, "The height of a cone needs to be > 0"); - DBG_ASSERT(fTopHeight>=0, "The height of the cutted top of a cone needs to be >= 0"); -*/ - DBG_ASSERT(fRadius>0, "The radius of a cone needs to be > 0"); - DBG_ASSERT(fRoundedEdge>=0, "fRoundedEdge needs to be >= 0"); //for stacked charts we need cones without top -> fTopHeight != 0 resp. bTopless == true //fTopHeight indicates the high of the cutted top only (not the full height) - - // always use extra points, so set percent diagonal to 0.4 which is 0% in the UI (old Chart comment) - if( fRoundedEdge == 0.0 ) - fRoundedEdge = 0.4 / 200.0; - - fRoundedEdge = 0.0; - - // ::rtl::math::approxEqual cannot compare to 0.0 bool bTopless = !::rtl::math::approxEqual( fHeight, fHeight + fTopHeight ); double r1= 0.0, r2 = fRadius; @@ -379,82 +369,69 @@ uno::Any createPolyPolygon_Cone( // #i63212# fHeight may be negative, fTopHeight is always positive -> use fabs(fHeight) r1 = fRadius * (fTopHeight)/(fabs(fHeight)+fTopHeight); - const double fMinimumDimension = ::std::min(r2*2.0,fHeight); - const double fOffset = (fMinimumDimension * fRoundedEdge) * 1.05; // increase by 5% for safety - const bool bRoundEdges = fRoundedEdge && fOffset < r2 && 2.0 * fOffset < fHeight - && ( bTopless ? fOffset < r1 : true ); - sal_Int32 nPointCount = 8; - if(bTopless) - { - if(!bRoundEdges) - nPointCount = 4; - } - else - { - if(bRoundEdges) - nPointCount = 6; - else - nPointCount = 3; - } - nVerticalSegmentCount = nPointCount-1; - - //-------------------------------------- + nVerticalSegmentCount=1; drawing::PolyPolygonShape3D aPP; - aPP.SequenceX.realloc(1); - aPP.SequenceY.realloc(1); - aPP.SequenceZ.realloc(1); + aPP.SequenceX.realloc(2); + aPP.SequenceY.realloc(2); + aPP.SequenceZ.realloc(2); drawing::DoubleSequence* pOuterSequenceX = aPP.SequenceX.getArray(); drawing::DoubleSequence* pOuterSequenceY = aPP.SequenceY.getArray(); drawing::DoubleSequence* pOuterSequenceZ = aPP.SequenceZ.getArray(); - pOuterSequenceX->realloc(nPointCount); - pOuterSequenceY->realloc(nPointCount); - pOuterSequenceZ->realloc(nPointCount); + pOuterSequenceX->realloc(2); + pOuterSequenceY->realloc(2); + pOuterSequenceZ->realloc(2); double* pInnerSequenceX = pOuterSequenceX->getArray(); double* pInnerSequenceY = pOuterSequenceY->getArray(); double* pInnerSequenceZ = pOuterSequenceZ->getArray(); - for(sal_Int32 nN = nPointCount; nN--;) - *pInnerSequenceZ++ = 0.0; + double fX1 = 0.0; + double fX2 = r2; + double fX3 = r1; - if(bTopless) - { - *pInnerSequenceY++ = fHeight; //1. - *pInnerSequenceX++ = 0.0; //1. + double fY1 = 0.0; + double fY2 = 0.0; + double fY3 = fHeight; - if(bRoundEdges) - { - *pInnerSequenceY++ = fHeight; //2. - *pInnerSequenceX++ = r1 - fOffset; //2. - } + if( fHeight<0.0 ) + { + ::std::swap(fX1,fX3); + ::std::swap(fY1,fY3); } - *pInnerSequenceY++ = fHeight; //3. - *pInnerSequenceX++ = r1; //3. + //---------------------------- + for(sal_Int32 nN = 2; nN--;) + *pInnerSequenceZ++ = 0.0; - if(bRoundEdges) - { - *pInnerSequenceY++ = fHeight - fOffset; //4. - *pInnerSequenceX++ = r1 + fOffset; //4. + *pInnerSequenceY++ = fY1; + *pInnerSequenceX++ = fX1; - *pInnerSequenceY++ = fOffset; //5. - *pInnerSequenceX++ = r2 - fOffset; //5. - } + *pInnerSequenceY++ = fY2; + *pInnerSequenceX++ = fX2; + //---------------------------- - *pInnerSequenceY++ = 0.0; //6. - *pInnerSequenceX++ = r2; //6. + pOuterSequenceX++;pOuterSequenceY++;pOuterSequenceZ++; + pOuterSequenceX->realloc(2); + pOuterSequenceY->realloc(2); + pOuterSequenceZ->realloc(2); - if(bRoundEdges) - { - *pInnerSequenceY++ = 0.0; //7. - *pInnerSequenceX++ = r2 - fOffset; //7. - } + pInnerSequenceX = pOuterSequenceX->getArray(); + pInnerSequenceY = pOuterSequenceY->getArray(); + pInnerSequenceZ = pOuterSequenceZ->getArray(); - *pInnerSequenceY++ = 0.0; //8. - *pInnerSequenceX++ = 0.0; //8. + //---------------------------- + for(sal_Int32 nN = 2; nN--;) + *pInnerSequenceZ++ = 0.0; + + *pInnerSequenceY++ = fY2; + *pInnerSequenceX++ = fX2; + + *pInnerSequenceY++ = fY3; + *pInnerSequenceX++ = fX3; + //---------------------------- return uno::Any( &aPP, ::getCppuType((const drawing::PolyPolygonShape3D*)0) ); } @@ -567,16 +544,167 @@ uno::Reference<drawing::XShape> , sal_Int32 nRotateZAngleHundredthDegree ) { return impl_createConeOrCylinder( - xTarget, rPosition, rSize, 0.0, nRotateZAngleHundredthDegree, CHART_3DOBJECT_SEGMENTCOUNT, true ); + xTarget, rPosition, rSize, 0.0, nRotateZAngleHundredthDegree, true ); } uno::Reference<drawing::XShape> ShapeFactory::createPyramid( const uno::Reference<drawing::XShapes>& xTarget , const drawing::Position3D& rPosition, const drawing::Direction3D& rSize - , double fTopHeight, sal_Int32 nRotateZAngleHundredthDegree ) + , double fTopHeight, bool bRotateZ + , const uno::Reference< beans::XPropertySet >& xSourceProp + , const tPropertyNameMap& rPropertyNameMap ) { - return impl_createConeOrCylinder( xTarget, rPosition, rSize, fTopHeight, nRotateZAngleHundredthDegree, 4 ); + if( !xTarget.is() ) + return 0; + + Reference< drawing::XShapes > xGroup( ShapeFactory::createGroup3D( xTarget, rtl::OUString() ) ); + + sal_Bool bDoubleSided = false; + short nRotatedTexture = 0; + + const double fWidth = rSize.DirectionX; + const double fDepth = rSize.DirectionZ; + const double fHeight = rSize.DirectionY; + + drawing::Position3D aBottomP1( rPosition.PositionX, rPosition.PositionY, rPosition.PositionZ - fDepth/2.0 ); + if(bRotateZ) + aBottomP1.PositionY -= fWidth/2.0; + else + aBottomP1.PositionX -= fWidth/2.0; + drawing::Position3D aBottomP2( aBottomP1 ); + if(bRotateZ) + aBottomP2.PositionY += fWidth; + else + aBottomP2.PositionX += fWidth; + drawing::Position3D aBottomP3( aBottomP2 ); + drawing::Position3D aBottomP4( aBottomP1 ); + aBottomP3.PositionZ += fDepth; + aBottomP4.PositionZ += fDepth; + + const double fTopFactor = (fTopHeight)/(fabs(fHeight)+fTopHeight); + drawing::Position3D aTopP1( rPosition.PositionX, rPosition.PositionY, rPosition.PositionZ - fDepth*fTopFactor/2.0 ); + if(bRotateZ) + { + aTopP1.PositionY -= fWidth*fTopFactor/2.0; + aTopP1.PositionX += fHeight; + } + else + { + aTopP1.PositionX -= fWidth*fTopFactor/2.0; + aTopP1.PositionY += fHeight; + } + drawing::Position3D aTopP2( aTopP1 ); + if(bRotateZ) + aTopP2.PositionY += fWidth*fTopFactor; + else + aTopP2.PositionX += fWidth*fTopFactor; + drawing::Position3D aTopP3( aTopP2 ); + drawing::Position3D aTopP4( aTopP1 ); + aTopP3.PositionZ += fDepth*fTopFactor; + aTopP4.PositionZ += fDepth*fTopFactor; + + Stripe aStripeBottom( aBottomP1, aBottomP4, aBottomP3, aBottomP2 ); + + drawing::Position3D aNormalsBottomP1( aBottomP1 ); + drawing::Position3D aNormalsBottomP2( aBottomP2 ); + drawing::Position3D aNormalsBottomP3( aBottomP3 ); + drawing::Position3D aNormalsBottomP4( aBottomP4 ); + drawing::Position3D aNormalsTopP1( aBottomP1 ); + drawing::Position3D aNormalsTopP2( aBottomP2 ); + drawing::Position3D aNormalsTopP3( aBottomP3 ); + drawing::Position3D aNormalsTopP4( aBottomP4 ); + if( bRotateZ ) + { + aNormalsTopP1.PositionX += fHeight; + aNormalsTopP2.PositionX += fHeight; + aNormalsTopP3.PositionX += fHeight; + aNormalsTopP4.PositionX += fHeight; + } + else + { + aNormalsTopP1.PositionY += fHeight; + aNormalsTopP2.PositionY += fHeight; + aNormalsTopP3.PositionY += fHeight; + aNormalsTopP4.PositionY += fHeight; + } + + bool bInvertPolygon = false; + bool bInvertNormals = false; + + if(bRotateZ) + { + //bars + if(fHeight>=0.0) + { + nRotatedTexture = 2; + bInvertNormals = true; + aStripeBottom = Stripe( aBottomP1, aBottomP4, aBottomP3, aBottomP2 ); + } + else + { + bInvertPolygon = true; + nRotatedTexture = 1; + aStripeBottom = Stripe( aBottomP2, aBottomP3, aBottomP4, aBottomP1 ); + } + } + else + { + //columns + if(fHeight>=0.0) + { + bInvertPolygon = true; + nRotatedTexture = 2; + aStripeBottom = Stripe( aBottomP2, aBottomP3, aBottomP4, aBottomP1 ); + } + else + { + nRotatedTexture = 3; + bInvertNormals = true; + aStripeBottom = Stripe( aBottomP4, aBottomP3, aBottomP2, aBottomP1 ); + } + } + aStripeBottom.InvertNormal(true); + + Stripe aStripe1( aTopP2, aTopP1, aBottomP1, aBottomP2 ); + Stripe aStripe2( aTopP3, aTopP2, aBottomP2, aBottomP3 ); + Stripe aStripe3( aTopP4, aTopP3, aBottomP3, aBottomP4 ); + Stripe aStripe4( aTopP1, aTopP4, aBottomP4, aBottomP1 ); + + if( bInvertPolygon ) + { + aStripe1 = Stripe( aBottomP1, aTopP1, aTopP2, aBottomP2 ); + aStripe2 = Stripe( aBottomP2, aTopP2, aTopP3, aBottomP3 ); + aStripe3 = Stripe( aBottomP3, aTopP3, aTopP4, aBottomP4 ); + aStripe4 = Stripe( aBottomP4, aTopP4, aTopP1, aBottomP1 ); + } + + Stripe aNormalsStripe1( aNormalsTopP1, aNormalsBottomP1, aNormalsBottomP2, aNormalsTopP2 ); + Stripe aNormalsStripe2( aNormalsTopP2, aNormalsBottomP2, aNormalsBottomP3, aNormalsTopP3 ); + Stripe aNormalsStripe3( aNormalsTopP3, aNormalsBottomP3, aNormalsBottomP4, aNormalsTopP4 ); + Stripe aNormalsStripe4( aNormalsTopP4, aNormalsBottomP4, aNormalsBottomP1, aNormalsTopP1 ); + + if( bInvertNormals ) + { + aNormalsStripe1 = Stripe( aNormalsTopP2, aNormalsBottomP2, aNormalsBottomP1, aNormalsTopP1 ); + aNormalsStripe2 = Stripe( aNormalsTopP3, aNormalsBottomP3, aNormalsBottomP2, aNormalsTopP2 ); + aNormalsStripe3 = Stripe( aNormalsTopP4, aNormalsBottomP4, aNormalsBottomP3, aNormalsTopP3 ); + aNormalsStripe4 = Stripe( aNormalsTopP1, aNormalsBottomP1, aNormalsBottomP4, aNormalsTopP4 ); + } + + aStripe1.SetManualNormal( aNormalsStripe1.getNormal() ); + aStripe2.SetManualNormal( aNormalsStripe2.getNormal() ); + aStripe3.SetManualNormal( aNormalsStripe3.getNormal() ); + aStripe4.SetManualNormal( aNormalsStripe4.getNormal() ); + + const bool bFlatNormals = false; + ShapeFactory::createStripe( xGroup, aStripe1, xSourceProp, rPropertyNameMap, bDoubleSided, nRotatedTexture, bFlatNormals ); + ShapeFactory::createStripe( xGroup, aStripe2, xSourceProp, rPropertyNameMap, bDoubleSided, nRotatedTexture, bFlatNormals ); + ShapeFactory::createStripe( xGroup, aStripe3, xSourceProp, rPropertyNameMap, bDoubleSided, nRotatedTexture, bFlatNormals ); + ShapeFactory::createStripe( xGroup, aStripe4, xSourceProp, rPropertyNameMap, bDoubleSided, nRotatedTexture, bFlatNormals ); + ShapeFactory::createStripe( xGroup, aStripeBottom, xSourceProp, rPropertyNameMap, bDoubleSided, nRotatedTexture, bFlatNormals ); + + return Reference< drawing::XShape >( xGroup, uno::UNO_QUERY ); } uno::Reference<drawing::XShape> @@ -585,7 +713,7 @@ uno::Reference<drawing::XShape> , const drawing::Position3D& rPosition, const drawing::Direction3D& rSize , double fTopHeight, sal_Int32 nRotateZAngleHundredthDegree ) { - return impl_createConeOrCylinder( xTarget, rPosition, rSize, fTopHeight, nRotateZAngleHundredthDegree, CHART_3DOBJECT_SEGMENTCOUNT ); + return impl_createConeOrCylinder( xTarget, rPosition, rSize, fTopHeight, nRotateZAngleHundredthDegree ); } uno::Reference<drawing::XShape> @@ -593,7 +721,6 @@ uno::Reference<drawing::XShape> const uno::Reference<drawing::XShapes>& xTarget , const drawing::Position3D& rPosition, const drawing::Direction3D& rSize , double fTopHeight, sal_Int32 nRotateZAngleHundredthDegree - , sal_Int32 nSegments , bool bCylinder ) { if( !xTarget.is() ) @@ -605,19 +732,8 @@ uno::Reference<drawing::XShape> "com.sun.star.drawing.Shape3DLatheObject") ), uno::UNO_QUERY ); xTarget->add(xShape); - - double fYRotateAnglePi = -ZDIRECTION*(F_PI/2.0 - F_PI/(double)nSegments); // alwayas rotate edge to front (important for pyramids) - //or: ZDIRECTION*(F_PI/2.0 - F_PI/(double)nSegments); // rotate edge to front for even segment count otherwise rotate corner to front - double fAngle = fYRotateAnglePi; - { - while(fAngle<0.0) - fAngle+=F_PI/2.0; - while(fAngle>F_PI/2.0) - fAngle-=F_PI/2.0; - } double fWidth = rSize.DirectionX/2.0; //The depth will be corrrected within Matrix double fRadius = fWidth; //!!!!!!!! problem in drawing layer: rotation object calculates wrong needed size -> wrong camera (it's a problem with bounding boxes) -// double fRadius = fWidth/cos(fAngle); llllllllllllllllllll double fHeight = rSize.DirectionY; //set properties @@ -635,15 +751,14 @@ uno::Reference<drawing::XShape> //Polygon sal_Int32 nVerticalSegmentCount = 0; uno::Any aPPolygon = bCylinder ? createPolyPolygon_Cylinder( - fHeight, fRadius, double(nPercentDiagonal)/200.0, nVerticalSegmentCount) + fHeight, fRadius, nVerticalSegmentCount) : createPolyPolygon_Cone( - fHeight, fRadius, fTopHeight, double(nPercentDiagonal)/200.0, nVerticalSegmentCount); + fHeight, fRadius, fTopHeight, nVerticalSegmentCount); xProp->setPropertyValue( C2U( UNO_NAME_3D_POLYPOLYGON3D ), aPPolygon ); //Matrix for position { ::basegfx::B3DHomMatrix aM; - //aM.RotateY( fYRotateAnglePi ); if(nRotateZAngleHundredthDegree!=0) aM.rotate(0.0,0.0,-nRotateZAngleHundredthDegree/18000.00*F_PI); //stretch the symmetric objects to given depth @@ -656,7 +771,7 @@ uno::Reference<drawing::XShape> //Segments xProp->setPropertyValue( C2U( UNO_NAME_3D_HORZ_SEGS ) - , uno::makeAny(nSegments) ); + , uno::makeAny(CHART_3DOBJECT_SEGMENTCOUNT) ); xProp->setPropertyValue( C2U( UNO_NAME_3D_VERT_SEGS ) , uno::makeAny((sal_Int32)nVerticalSegmentCount) );//depends on point count of the used polygon @@ -1021,7 +1136,8 @@ uno::Reference< drawing::XShape > , const uno::Reference< beans::XPropertySet >& xSourceProp , const tPropertyNameMap& rPropertyNameMap , sal_Bool bDoubleSided - , bool bRotatedTexture ) + , short nRotatedTexture + , bool bFlatNormals ) { if( !xTarget.is() ) return 0; @@ -1045,16 +1161,15 @@ uno::Reference< drawing::XShape > //TexturePolygon xProp->setPropertyValue( C2U( UNO_NAME_3D_TEXTUREPOLYGON3D ) - , rStripe.getTexturePolygon( bRotatedTexture ) ); - + , rStripe.getTexturePolygon( nRotatedTexture ) ); //Normals Polygon xProp->setPropertyValue( C2U( UNO_NAME_3D_NORMALSPOLYGON3D ) , rStripe.getNormalsPolygon() ); - //NormalsKind - xProp->setPropertyValue( C2U( UNO_NAME_3D_NORMALS_KIND ) - , uno::makeAny( drawing::NormalsKind_FLAT ) ); + if(bFlatNormals) + xProp->setPropertyValue( C2U( UNO_NAME_3D_NORMALS_KIND ) + , uno::makeAny( drawing::NormalsKind_FLAT ) ); //LineOnly xProp->setPropertyValue( C2U( UNO_NAME_3D_LINEONLY ) diff --git a/chart2/source/view/main/Stripe.cxx b/chart2/source/view/main/Stripe.cxx index 7f282e3d5559..2df78e2a8e91 100644 --- a/chart2/source/view/main/Stripe.cxx +++ b/chart2/source/view/main/Stripe.cxx @@ -48,8 +48,9 @@ Stripe::Stripe( const drawing::Position3D& rPoint1 , m_aPoint2(rPoint1+rDirectionToPoint2) , m_aPoint3(m_aPoint2+rDirectionToPoint4) , m_aPoint4(rPoint1+rDirectionToPoint4) + , m_bInvertNormal(false) + , m_bManualNormalSet(false) { - } Stripe::Stripe( const drawing::Position3D& rPoint1 @@ -59,12 +60,13 @@ Stripe::Stripe( const drawing::Position3D& rPoint1 , m_aPoint2(rPoint2) , m_aPoint3(rPoint2) , m_aPoint4(rPoint1) + , m_bInvertNormal(false) + , m_bManualNormalSet(false) { m_aPoint3.PositionZ += fDepth; m_aPoint4.PositionZ += fDepth; } -/* Stripe::Stripe( const drawing::Position3D& rPoint1 , const drawing::Position3D& rPoint2 , const drawing::Position3D& rPoint3 @@ -73,10 +75,21 @@ Stripe::Stripe( const drawing::Position3D& rPoint1 , m_aPoint2(rPoint2) , m_aPoint3(rPoint3) , m_aPoint4(rPoint4) + , m_bInvertNormal(false) + , m_bManualNormalSet(false) +{ +} + +void Stripe::SetManualNormal( const drawing::Direction3D& rNormal ) { + m_aManualNormal = rNormal; + m_bManualNormalSet = true; +} +void Stripe::InvertNormal( bool bInvertNormal ) +{ + m_bInvertNormal = bInvertNormal; } -*/ uno::Any Stripe::getPolyPolygonShape3D() const { @@ -119,12 +132,28 @@ uno::Any Stripe::getPolyPolygonShape3D() const drawing::Direction3D Stripe::getNormal() const { - ::basegfx::B3DPolygon aPolygon3D; - aPolygon3D.append(Position3DToB3DPoint( m_aPoint1 )); - aPolygon3D.append(Position3DToB3DPoint( m_aPoint2 )); - aPolygon3D.append(Position3DToB3DPoint( m_aPoint3 )); - ::basegfx::B3DVector aNormal(::basegfx::tools::getNormal(aPolygon3D)); - return B3DVectorToDirection3D(aNormal); + drawing::Direction3D aRet(1.0,0.0,0.0); + + if( m_bManualNormalSet ) + aRet = m_aManualNormal; + else + { + ::basegfx::B3DPolygon aPolygon3D; + aPolygon3D.append(Position3DToB3DPoint( m_aPoint1 )); + aPolygon3D.append(Position3DToB3DPoint( m_aPoint2 )); + aPolygon3D.append(Position3DToB3DPoint( m_aPoint3 )); + aPolygon3D.append(Position3DToB3DPoint( m_aPoint4 )); + ::basegfx::B3DVector aNormal(::basegfx::tools::getNormal(aPolygon3D)); + aRet = B3DVectorToDirection3D(aNormal); + } + + if( m_bInvertNormal ) + { + aRet.DirectionX *= -1.0; + aRet.DirectionY *= -1.0; + aRet.DirectionZ *= -1.0; + } + return aRet; } uno::Any Stripe::getNormalsPolygon() const @@ -158,7 +187,7 @@ uno::Any Stripe::getNormalsPolygon() const return uno::Any( &aPP, ::getCppuType((const drawing::PolyPolygonShape3D*)0) ); } -uno::Any Stripe::getTexturePolygon( bool bRotatedTexture ) const +uno::Any Stripe::getTexturePolygon( short nRotatedTexture ) const { drawing::PolyPolygonShape3D aPP; @@ -178,26 +207,124 @@ uno::Any Stripe::getTexturePolygon( bool bRotatedTexture ) const double* pInnerSequenceY = pOuterSequenceY->getArray(); double* pInnerSequenceZ = pOuterSequenceZ->getArray(); - if( !bRotatedTexture ) + if( nRotatedTexture==0 ) { *pInnerSequenceX++ = 0.0; *pInnerSequenceY++ = 0.0; *pInnerSequenceZ++ = 0.0; + *pInnerSequenceX++ = 0.0; + *pInnerSequenceY++ = 1.0; + *pInnerSequenceZ++ = 0.0; + + *pInnerSequenceX++ = 1.0; + *pInnerSequenceY++ = 1.0; + *pInnerSequenceZ++ = 0.0; + + *pInnerSequenceX++ = 1.0; + *pInnerSequenceY++ = 0.0; + *pInnerSequenceZ++ = 0.0; + } + else if( nRotatedTexture==1 ) + { *pInnerSequenceX++ = 1.0; *pInnerSequenceY++ = 0.0; *pInnerSequenceZ++ = 0.0; + *pInnerSequenceX++ = 0.0; + *pInnerSequenceY++ = 0.0; + *pInnerSequenceZ++ = 0.0; + + *pInnerSequenceX++ = 0.0; + *pInnerSequenceY++ = 1.0; + *pInnerSequenceZ++ = 0.0; + + *pInnerSequenceX++ = 1.0; + *pInnerSequenceY++ = 1.0; + *pInnerSequenceZ++ = 0.0; + } + else if( nRotatedTexture==2 ) + { *pInnerSequenceX++ = 1.0; *pInnerSequenceY++ = 1.0; *pInnerSequenceZ++ = 0.0; + *pInnerSequenceX++ = 1.0; + *pInnerSequenceY++ = 0.0; + *pInnerSequenceZ++ = 0.0; + + *pInnerSequenceX++ = 0.0; + *pInnerSequenceY++ = 0.0; + *pInnerSequenceZ++ = 0.0; + *pInnerSequenceX++ = 0.0; *pInnerSequenceY++ = 1.0; *pInnerSequenceZ++ = 0.0; } - else + else if( nRotatedTexture==3 ) + { + *pInnerSequenceX++ = 0.0; + *pInnerSequenceY++ = 1.0; + *pInnerSequenceZ++ = 0.0; + + *pInnerSequenceX++ = 1.0; + *pInnerSequenceY++ = 1.0; + *pInnerSequenceZ++ = 0.0; + + *pInnerSequenceX++ = 1.0; + *pInnerSequenceY++ = 0.0; + *pInnerSequenceZ++ = 0.0; + + *pInnerSequenceX++ = 0.0; + *pInnerSequenceY++ = 0.0; + *pInnerSequenceZ++ = 0.0; + } + else if( nRotatedTexture==4 ) + { + *pInnerSequenceX++ = 1.0; + *pInnerSequenceY++ = 0.0; + *pInnerSequenceZ++ = 0.0; + + *pInnerSequenceX++ = 1.0; + *pInnerSequenceY++ = 1.0; + *pInnerSequenceZ++ = 0.0; + + *pInnerSequenceX++ = 0.0; + *pInnerSequenceY++ = 1.0; + *pInnerSequenceZ++ = 0.0; + + *pInnerSequenceX++ = 0.0; + *pInnerSequenceY++ = 0.0; + *pInnerSequenceZ++ = 0.0; + } + else if( nRotatedTexture==5 ) + { + *pInnerSequenceX++ = 0.0; + *pInnerSequenceY++ = 0.0; + *pInnerSequenceZ++ = 0.0; + + *pInnerSequenceX++ = 1.0; + *pInnerSequenceY++ = 0.0; + *pInnerSequenceZ++ = 0.0; + + *pInnerSequenceX++ = 1.0; + *pInnerSequenceY++ = 1.0; + *pInnerSequenceZ++ = 0.0; + + *pInnerSequenceX++ = 0.0; + *pInnerSequenceY++ = 1.0; + *pInnerSequenceZ++ = 0.0; + } + else if( nRotatedTexture==6 ) { + *pInnerSequenceX++ = 0.0; + *pInnerSequenceY++ = 1.0; + *pInnerSequenceZ++ = 0.0; + + *pInnerSequenceX++ = 0.0; + *pInnerSequenceY++ = 0.0; + *pInnerSequenceZ++ = 0.0; + *pInnerSequenceX++ = 1.0; *pInnerSequenceY++ = 0.0; *pInnerSequenceZ++ = 0.0; @@ -205,6 +332,12 @@ uno::Any Stripe::getTexturePolygon( bool bRotatedTexture ) const *pInnerSequenceX++ = 1.0; *pInnerSequenceY++ = 1.0; *pInnerSequenceZ++ = 0.0; + } + else if( nRotatedTexture==7 ) + { + *pInnerSequenceX++ = 1.0; + *pInnerSequenceY++ = 1.0; + *pInnerSequenceZ++ = 0.0; *pInnerSequenceX++ = 0.0; *pInnerSequenceY++ = 1.0; @@ -213,6 +346,10 @@ uno::Any Stripe::getTexturePolygon( bool bRotatedTexture ) const *pInnerSequenceX++ = 0.0; *pInnerSequenceY++ = 0.0; *pInnerSequenceZ++ = 0.0; + + *pInnerSequenceX++ = 1.0; + *pInnerSequenceY++ = 0.0; + *pInnerSequenceZ++ = 0.0; } return uno::Any( &aPP, ::getCppuType((const drawing::PolyPolygonShape3D*)0) ); diff --git a/chart2/source/view/main/VDataSeries.cxx b/chart2/source/view/main/VDataSeries.cxx index c94193c5a7c8..8bb6a11b4baf 100644 --- a/chart2/source/view/main/VDataSeries.cxx +++ b/chart2/source/view/main/VDataSeries.cxx @@ -734,10 +734,10 @@ double VDataSeries::getYMeanValue() const { if( xProp->getPropertyValue( C2U( "Symbol" ) ) >>= *apSymbolProps ) { - // border of symbols always black - apSymbolProps->BorderColor = 0x000000; //use main color to fill symbols xProp->getPropertyValue( C2U( "Color" ) ) >>= apSymbolProps->FillColor; + // border of symbols always same as fill color + apSymbolProps->BorderColor = apSymbolProps->FillColor; } else apSymbolProps.reset(); diff --git a/chart2/source/view/main/VLegend.cxx b/chart2/source/view/main/VLegend.cxx index 1b6abd9bb812..f0bcc12c0440 100644 --- a/chart2/source/view/main/VLegend.cxx +++ b/chart2/source/view/main/VLegend.cxx @@ -258,10 +258,11 @@ void lcl_placeLegendEntries( double fViewFontSize = lcl_CalcViewFontSize( xProperties, rPageSize ); // padding as percentage of the font height - double fXPadding = (1.0 / 5.0); - double fYPadding = (1.0 / 3.0); - double fXOffset = (1.0 / 5.0); - double fYOffset = (1.0 / 5.0); + // #i109336# Improve auto positioning in chart + double fXPadding = 0.1; + double fYPadding = 0.2; + 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 ); @@ -273,8 +274,11 @@ void lcl_placeLegendEntries( rEntries, xShapeFactory, xTarget, aTextShapes, rTextProperties ); OSL_ASSERT( aTextShapes.size() == rEntries.size()); - awt::Size aMaxSymbolExtent( static_cast< sal_Int32 >( fViewFontSize * 3.0 / 2.0 ), - static_cast< sal_Int32 >( fViewFontSize )); + // #i109336# Improve auto positioning in chart + double fSymbolSizeFraction = 0.8; + awt::Size aMaxSymbolExtent( static_cast< sal_Int32 >( fViewFontSize * fSymbolSizeFraction * 3.0 / 2.0 ), + static_cast< sal_Int32 >( fViewFontSize * fSymbolSizeFraction ) ); + sal_Int32 nCurrentXPos = nXPadding; sal_Int32 nCurrentYPos = nYPadding; sal_Int32 nMaxEntryWidth = 2 * nXOffset + aMaxSymbolExtent.Width + aMaxEntryExtent.Width; @@ -391,8 +395,13 @@ void lcl_placeLegendEntries( 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))); + + // #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 ) ); } // position text shape @@ -435,37 +444,60 @@ void lcl_placeLegendEntries( rOutLegendSize.Height = nMaxYPos + nYPadding; } -double lcl_getPageLayoutDistancePercentage() +// #i109336# Improve auto positioning in chart +sal_Int32 lcl_getLegendLeftRightMargin() { - return 0.02; + return 210; // 1/100 mm +} + +// #i109336# Improve auto positioning in chart +sal_Int32 lcl_getLegendTopBottomMargin() +{ + return 185; // 1/100 mm } chart2::RelativePosition lcl_getDefaultPosition( LegendPosition ePos, const awt::Rectangle& rOutAvailableSpace, const awt::Size & rPageSize ) { - // shift legend about 2% of page size into the primary direction by default - const double fDefaultDistance = lcl_getPageLayoutDistancePercentage(); chart2::RelativePosition aResult; switch( ePos ) { case LegendPosition_LINE_START: - aResult = chart2::RelativePosition( - fDefaultDistance, 0.5, drawing::Alignment_LEFT ); + { + // #i109336# Improve auto positioning in chart + const double fDefaultDistance = ( static_cast< double >( lcl_getLegendLeftRightMargin() ) / + static_cast< double >( rPageSize.Width ) ); + aResult = chart2::RelativePosition( + fDefaultDistance, 0.5, drawing::Alignment_LEFT ); + } break; case LegendPosition_LINE_END: - aResult = chart2::RelativePosition( - 1.0 - fDefaultDistance, 0.5, drawing::Alignment_RIGHT ); + { + // #i109336# Improve auto positioning in chart + const double fDefaultDistance = ( static_cast< double >( lcl_getLegendLeftRightMargin() ) / + static_cast< double >( rPageSize.Width ) ); + aResult = chart2::RelativePosition( + 1.0 - fDefaultDistance, 0.5, drawing::Alignment_RIGHT ); + } break; case LegendPosition_PAGE_START: { + // #i109336# Improve auto positioning in chart + const double fDefaultDistance = ( static_cast< double >( lcl_getLegendTopBottomMargin() ) / + static_cast< double >( rPageSize.Height ) ); double fDistance = (static_cast<double>(rOutAvailableSpace.Y)/static_cast<double>(rPageSize.Height)) + fDefaultDistance; aResult = chart2::RelativePosition( 0.5, fDistance, drawing::Alignment_TOP ); } break; case LegendPosition_PAGE_END: - aResult = chart2::RelativePosition( - 0.5, 1.0 - fDefaultDistance, drawing::Alignment_BOTTOM ); + { + // #i109336# Improve auto positioning in chart + const double fDefaultDistance = ( static_cast< double >( lcl_getLegendTopBottomMargin() ) / + static_cast< double >( rPageSize.Height ) ); + aResult = chart2::RelativePosition( + 0.5, 1.0 - fDefaultDistance, drawing::Alignment_BOTTOM ); + } break; case LegendPosition_CUSTOM: @@ -498,31 +530,34 @@ awt::Point lcl_calculatePositionAndRemainingSpace( aResult, aLegendSize, aRelPos.Anchor ); // adapt rRemainingSpace if LegendPosition is not CUSTOM - sal_Int32 nYDistance = static_cast<sal_Int32>(rPageSize.Height*lcl_getPageLayoutDistancePercentage()); - sal_Int32 nXDistance = static_cast<sal_Int32>(rPageSize.Width*lcl_getPageLayoutDistancePercentage()); - rRemainingSpace.Width-=nXDistance; - rRemainingSpace.Height-=nYDistance; + // #i109336# Improve auto positioning in chart + sal_Int32 nXDistance = lcl_getLegendLeftRightMargin(); + sal_Int32 nYDistance = lcl_getLegendTopBottomMargin(); switch( ePos ) { case LegendPosition_LINE_START: - { - sal_Int32 nExtent = aLegendSize.Width; - rRemainingSpace.Width -= nExtent; - rRemainingSpace.X += ( nExtent + nXDistance ); - } + { + sal_Int32 nExtent = aLegendSize.Width; + rRemainingSpace.Width -= ( nExtent + nXDistance ); + rRemainingSpace.X += ( nExtent + nXDistance ); + } break; case LegendPosition_LINE_END: - rRemainingSpace.Width -= ( aLegendSize.Width ); + { + rRemainingSpace.Width -= ( aLegendSize.Width + nXDistance ); + } break; case LegendPosition_PAGE_START: - { - sal_Int32 nExtent = aLegendSize.Height; - rRemainingSpace.Height -= nExtent; - rRemainingSpace.Y += ( nExtent + nYDistance ); - } + { + sal_Int32 nExtent = aLegendSize.Height; + rRemainingSpace.Height -= ( nExtent + nYDistance ); + rRemainingSpace.Y += ( nExtent + nYDistance ); + } break; case LegendPosition_PAGE_END: - rRemainingSpace.Height -= ( aLegendSize.Height ); + { + rRemainingSpace.Height -= ( aLegendSize.Height + nYDistance ); + } break; default: @@ -672,8 +707,9 @@ void VLegend::createShapes( tPropertyValues aLineFillProperties; tPropertyValues aTextProperties; - // limit the width of texts to 20% of the total available width - sal_Int32 nMaxLabelWidth = rAvailableSpace.Width / 5; + // limit the width of texts to 30% of the total available width + // #i109336# Improve auto positioning in chart + sal_Int32 nMaxLabelWidth = rAvailableSpace.Width * 3 / 10; Reference< beans::XPropertySet > xLegendProp( m_xLegend, uno::UNO_QUERY ); LegendExpansion eExpansion = LegendExpansion_HIGH; if( xLegendProp.is()) diff --git a/chart2/source/view/main/VLegendSymbolFactory.cxx b/chart2/source/view/main/VLegendSymbolFactory.cxx index 682ff7fb7a5b..958a8defe0b6 100644 --- a/chart2/source/view/main/VLegendSymbolFactory.cxx +++ b/chart2/source/view/main/VLegendSymbolFactory.cxx @@ -85,6 +85,16 @@ void lcl_setPropetiesToShape( ::chart::tNameSequence aPropNames; ::chart::tAnySequence aPropValues; ::chart::PropertyMapper::getMultiPropertyListsFromValueMap( aPropNames, aPropValues, aValueMap ); + + uno::Any* pLineWidthAny = ::chart::PropertyMapper::getValuePointer(aPropValues,aPropNames,C2U("LineWidth")); + sal_Int32 nLineWidth = 0; + if( pLineWidthAny && (*pLineWidthAny>>=nLineWidth) ) + { + const sal_Int32 nMaxLineWidthForLegend = 50;/*1/100 mm*///todo: make this dependent from legend entry height + if( nLineWidth>nMaxLineWidthForLegend ) + *pLineWidthAny = uno::makeAny( nMaxLineWidthForLegend ); + } + ::chart::PropertyMapper::setMultiProperties( aPropNames, aPropValues, xShapeProp ); } } @@ -316,10 +326,10 @@ Reference< drawing::XShape > VLegendSymbolFactory::createSymbol( ShapeFactory aFactory( xShapeFactory ); if( aSymbol.Style == chart2::SymbolStyle_STANDARD ) { - // border of symbols always black - aSymbol.BorderColor = 0x000000; // take series color as fill color xLegendEntryProperties->getPropertyValue( C2U("Color")) >>= aSymbol.FillColor; + // border of symbols always same as fill color + aSymbol.BorderColor = aSymbol.FillColor; xSymbol.set( aFactory.createSymbol2D( xResultGroup, diff --git a/chart2/source/view/main/VTitle.cxx b/chart2/source/view/main/VTitle.cxx index f804a505219f..f62142735b7c 100644 --- a/chart2/source/view/main/VTitle.cxx +++ b/chart2/source/view/main/VTitle.cxx @@ -253,6 +253,21 @@ void VTitle::createShapes( } } + // #i109336# Improve auto positioning in chart + float fFontHeight = 0.0; + if ( xShapeProp.is() && ( xShapeProp->getPropertyValue( C2U( "CharHeight" ) ) >>= fFontHeight ) ) + { + fFontHeight *= ( 2540. / 72. ); // pt -> 1/100 mm + float fXFraction = 0.18; + sal_Int32 nXDistance = static_cast< sal_Int32 >( ::rtl::math::round( fFontHeight * fXFraction ) ); + float fYFraction = 0.30; + sal_Int32 nYDistance = static_cast< sal_Int32 >( ::rtl::math::round( fFontHeight * fYFraction ) ); + xShapeProp->setPropertyValue( C2U( "TextLeftDistance" ), uno::makeAny( nXDistance ) ); + xShapeProp->setPropertyValue( C2U( "TextRightDistance" ), uno::makeAny( nXDistance ) ); + xShapeProp->setPropertyValue( C2U( "TextUpperDistance" ), uno::makeAny( nYDistance ) ); + xShapeProp->setPropertyValue( C2U( "TextLowerDistance" ), uno::makeAny( nYDistance ) ); + } + try { double fAngleDegree = 0; |