chart2/source/view/charttypes/CandleStickChart.cxx | 44 ++-- chart2/source/view/diagram/VDiagram.cxx | 12 - chart2/source/view/inc/AbstractShapeFactory.hxx | 21 ++ chart2/source/view/inc/DummyShapeFactory.hxx | 14 + chart2/source/view/inc/ShapeFactory.hxx | 13 + chart2/source/view/main/DataPointSymbolSupplier.cxx | 9 - chart2/source/view/main/DummyShapeFactory.cxx | 19 ++ chart2/source/view/main/ShapeFactory.cxx | 171 +++++++++++++++++++ chart2/source/view/main/VTitle.cxx | 177 ++------------------ 9 files changed, 280 insertions(+), 200 deletions(-)
New commits: commit 1d6efe8a259446a8b6f8938f494121d5d23f6030 Author: Markus Mohrhard <[email protected]> Date: Tue Oct 8 02:10:04 2013 +0200 no createInstance calls any more in chart2/source/view creating shapes Change-Id: I7978d607ecd9170fff37ff0be02cdfbec7ebb89b diff --git a/chart2/source/view/inc/AbstractShapeFactory.hxx b/chart2/source/view/inc/AbstractShapeFactory.hxx index 03780eb..5f915f0 100644 --- a/chart2/source/view/inc/AbstractShapeFactory.hxx +++ b/chart2/source/view/inc/AbstractShapeFactory.hxx @@ -13,19 +13,22 @@ #include "PropertyMapper.hxx" #include "VLineProperties.hxx" #include "BaseGFXHelper.hxx" +#include <com/sun/star/awt/Size.hpp> +#include <com/sun/star/awt/Point.hpp> #include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/chart2/XFormattedString.hpp> #include <com/sun/star/drawing/Direction3D.hpp> #include <com/sun/star/drawing/HomogenMatrix.hpp> #include <com/sun/star/drawing/PointSequenceSequence.hpp> #include <com/sun/star/drawing/PolyPolygonShape3D.hpp> #include <com/sun/star/drawing/Position3D.hpp> -#include <com/sun/star/awt/Size.hpp> -#include <com/sun/star/awt/Point.hpp> #include <com/sun/star/drawing/XDrawPage.hpp> #include <com/sun/star/drawing/XShapes.hpp> #include <com/sun/star/graphic/XGraphic.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <rtl/ustring.hxx> + namespace chart { @@ -190,6 +193,15 @@ public: ) = 0; virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > + createText( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget2D, + const com::sun::star::awt::Size& rSize, + const com::sun::star::awt::Point& rPosition, + com::sun::star::uno::Sequence< com::sun::star::uno::Reference< com::sun::star::chart2::XFormattedString > > xFormattedString, + const com::sun::star::uno::Reference< + com::sun::star::beans::XPropertySet > xTextProperties, + double nRotation, const OUString& aName ) = 0; + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > createInvisibleRectangle( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget diff --git a/chart2/source/view/inc/DummyShapeFactory.hxx b/chart2/source/view/inc/DummyShapeFactory.hxx index 0cc7b90..e3731f8 100644 --- a/chart2/source/view/inc/DummyShapeFactory.hxx +++ b/chart2/source/view/inc/DummyShapeFactory.hxx @@ -146,6 +146,15 @@ public: ); virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > + createText( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget2D, + const com::sun::star::awt::Size& rSize, + const com::sun::star::awt::Point& rPosition, + com::sun::star::uno::Sequence< com::sun::star::uno::Reference< com::sun::star::chart2::XFormattedString > > xFormattedString, + const com::sun::star::uno::Reference< + com::sun::star::beans::XPropertySet > xTextProperties, + double nRotation, const OUString& aName ); + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > createInvisibleRectangle( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget diff --git a/chart2/source/view/inc/ShapeFactory.hxx b/chart2/source/view/inc/ShapeFactory.hxx index f38f47c..4e51293 100644 --- a/chart2/source/view/inc/ShapeFactory.hxx +++ b/chart2/source/view/inc/ShapeFactory.hxx @@ -161,6 +161,15 @@ public: ); virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > + createText( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget2D, + const com::sun::star::awt::Size& rSize, + const com::sun::star::awt::Point& rPosition, + com::sun::star::uno::Sequence< com::sun::star::uno::Reference< com::sun::star::chart2::XFormattedString > > xFormattedString, + const com::sun::star::uno::Reference< + com::sun::star::beans::XPropertySet > xTextProperties, + double nRotation, const OUString& aName ); + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > createInvisibleRectangle( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget diff --git a/chart2/source/view/main/DummyShapeFactory.cxx b/chart2/source/view/main/DummyShapeFactory.cxx index eb85535..4eb6283 100644 --- a/chart2/source/view/main/DummyShapeFactory.cxx +++ b/chart2/source/view/main/DummyShapeFactory.cxx @@ -269,6 +269,17 @@ uno::Reference< drawing::XShape > return new DummyXShape(); } + +uno::Reference< drawing::XShape > + DummyShapeFactory::createText( const uno::Reference< drawing::XShapes >& , + const awt::Size& , const awt::Point& , + uno::Sequence< uno::Reference< chart2::XFormattedString > > , + const uno::Reference< beans::XPropertySet > , + double , const OUString& ) +{ + return new DummyXShape(); +} + } //namespace dummy } //namespace chart diff --git a/chart2/source/view/main/ShapeFactory.cxx b/chart2/source/view/main/ShapeFactory.cxx index 5deac27..a0abdaf 100644 --- a/chart2/source/view/main/ShapeFactory.cxx +++ b/chart2/source/view/main/ShapeFactory.cxx @@ -22,6 +22,7 @@ #include "Stripe.hxx" #include "CommonConverters.hxx" #include "macros.hxx" +#include "RelativeSizeHelper.hxx" #include "PropertyMapper.hxx" #include <comphelper/InlineContainer.hxx> #include <com/sun/star/beans/XPropertySet.hpp> @@ -37,7 +38,9 @@ #include <com/sun/star/drawing/ProjectionMode.hpp> #include <com/sun/star/drawing/ShadeMode.hpp> #include <com/sun/star/drawing/TextFitToSizeType.hpp> +#include <com/sun/star/drawing/TextHorizontalAdjust.hpp> #include <com/sun/star/drawing/TextureProjectionMode.hpp> +#include <com/sun/star/drawing/TextVerticalAdjust.hpp> #include <com/sun/star/text/XText.hpp> #include <com/sun/star/uno/Any.hxx> @@ -2116,6 +2119,162 @@ uno::Reference< drawing::XShape > return xShape; } + +uno::Reference< drawing::XShape > + ShapeFactory::createText( const uno::Reference< drawing::XShapes >& xTarget, + const awt::Size& rSize, + const awt::Point& rPos, + uno::Sequence< uno::Reference< chart2::XFormattedString > > xFormattedString, + const uno::Reference< + beans::XPropertySet > xTextProperties, + double nRotation, const OUString& aName ) +{ + //create shape and add to page + uno::Reference< drawing::XShape > xShape( + m_xShapeFactory->createInstance( + "com.sun.star.drawing.TextShape" ), uno::UNO_QUERY ); + try + { + xTarget->add(xShape); + + //set text and text properties + uno::Reference< text::XText > xText( xShape, uno::UNO_QUERY ); + uno::Reference< text::XTextCursor > xTextCursor( xText->createTextCursor() ); + uno::Reference< text::XTextRange > xTextRange( xTextCursor, uno::UNO_QUERY ); + uno::Reference< beans::XPropertySet > xShapeProp( xShape, uno::UNO_QUERY ); + if( !xText.is() || !xTextRange.is() || !xTextCursor.is() || !xShapeProp.is() || !xTextProperties.is() ) + return xShape; + + tPropertyNameValueMap aValueMap; + //fill line-, fill- and paragraph-properties into the ValueMap + { + tMakePropertyNameMap aNameMap = PropertyMapper::getPropertyNameMapForParagraphProperties(); + aNameMap( PropertyMapper::getPropertyNameMapForFillAndLineProperties() ); + + PropertyMapper::getValueMap( aValueMap, aNameMap, xTextProperties ); + } + + //fill some more shape properties into the ValueMap + { + drawing::TextHorizontalAdjust eHorizontalAdjust = drawing::TextHorizontalAdjust_CENTER; + drawing::TextVerticalAdjust eVerticalAdjust = drawing::TextVerticalAdjust_CENTER; + + aValueMap.insert( tPropertyNameValueMap::value_type( "TextHorizontalAdjust", uno::makeAny(eHorizontalAdjust) ) ); // drawing::TextHorizontalAdjust + aValueMap.insert( tPropertyNameValueMap::value_type( "TextVerticalAdjust", uno::makeAny(eVerticalAdjust) ) ); //drawing::TextVerticalAdjust + aValueMap.insert( tPropertyNameValueMap::value_type( "TextAutoGrowHeight", uno::makeAny(sal_True) ) ); // sal_Bool + aValueMap.insert( tPropertyNameValueMap::value_type( "TextAutoGrowWidth", uno::makeAny(sal_True) ) ); // sal_Bool + + //set name/classified ObjectID (CID) + if( !aName.isEmpty() ) + aValueMap.insert( tPropertyNameValueMap::value_type( "Name", uno::makeAny( aName ) ) ); //CID OUString + } + + //set global title properties + { + tNameSequence aPropNames; + tAnySequence aPropValues; + PropertyMapper::getMultiPropertyListsFromValueMap( aPropNames, aPropValues, aValueMap ); + PropertyMapper::setMultiProperties( aPropNames, aPropValues, xShapeProp ); + } + + sal_Bool bStackCharacters(sal_False); + try + { + xTextProperties->getPropertyValue( "StackCharacters" ) >>= bStackCharacters; + } + catch( const uno::Exception& e ) + { + ASSERT_EXCEPTION( e ); + } + + if(bStackCharacters) + { + //if the characters should be stacked we use only the first character properties for code simplicity + if( xFormattedString.getLength()>0 ) + { + OUString aLabel; + for( sal_Int32 nN=0; nN<xFormattedString.getLength();nN++ ) + aLabel += xFormattedString[nN]->getString(); + aLabel = ShapeFactory::getStackedString( aLabel, bStackCharacters ); + + xTextCursor->gotoEnd(false); + xText->insertString( xTextRange, aLabel, false ); + xTextCursor->gotoEnd(true); + uno::Reference< beans::XPropertySet > xTargetProps( xShape, uno::UNO_QUERY ); + uno::Reference< beans::XPropertySet > xSourceProps( xFormattedString[0], uno::UNO_QUERY ); + + PropertyMapper::setMappedProperties( xTargetProps, xSourceProps + , PropertyMapper::getPropertyNameMapForCharacterProperties() ); + + // adapt font size according to page size + awt::Size aOldRefSize; + if( xTextProperties->getPropertyValue( "ReferencePageSize") >>= aOldRefSize ) + { + RelativeSizeHelper::adaptFontSizes( xTargetProps, aOldRefSize, rSize ); + } + } + } + else + { + uno::Sequence< uno::Reference< text::XTextCursor > > aCursorList( xFormattedString.getLength() ); + sal_Int32 nN = 0; + for( nN=0; nN<xFormattedString.getLength();nN++ ) + { + xTextCursor->gotoEnd(false); + xText->insertString( xTextRange, xFormattedString[nN]->getString(), false ); + xTextCursor->gotoEnd(true); + aCursorList[nN] = xText->createTextCursorByRange( uno::Reference< text::XTextRange >(xTextCursor,uno::UNO_QUERY) ); + } + awt::Size aOldRefSize; + bool bHasRefPageSize = + ( xTextProperties->getPropertyValue( "ReferencePageSize") >>= aOldRefSize ); + + if( xFormattedString.getLength()>0 ) + { + uno::Reference< beans::XPropertySet > xTargetProps( xShape, uno::UNO_QUERY ); + uno::Reference< beans::XPropertySet > xSourceProps( xFormattedString[0], uno::UNO_QUERY ); + PropertyMapper::setMappedProperties( xTargetProps, xSourceProps, PropertyMapper::getPropertyNameMapForCharacterProperties() ); + + // adapt font size according to page size + if( bHasRefPageSize ) + { + RelativeSizeHelper::adaptFontSizes( xTargetProps, aOldRefSize, rSize ); + } + } + } + + // #i109336# Improve auto positioning in chart + float fFontHeight = 0.0; + if ( xShapeProp.is() && ( xShapeProp->getPropertyValue( "CharHeight" ) >>= fFontHeight ) ) + { + fFontHeight *= ( 2540.0f / 72.0f ); // pt -> 1/100 mm + float fXFraction = 0.18f; + sal_Int32 nXDistance = static_cast< sal_Int32 >( ::rtl::math::round( fFontHeight * fXFraction ) ); + float fYFraction = 0.30f; + sal_Int32 nYDistance = static_cast< sal_Int32 >( ::rtl::math::round( fFontHeight * fYFraction ) ); + xShapeProp->setPropertyValue( "TextLeftDistance", uno::makeAny( nXDistance ) ); + xShapeProp->setPropertyValue( "TextRightDistance", uno::makeAny( nXDistance ) ); + xShapeProp->setPropertyValue( "TextUpperDistance", uno::makeAny( nYDistance ) ); + xShapeProp->setPropertyValue( "TextLowerDistance", uno::makeAny( nYDistance ) ); + } + sal_Int32 nXPos = rPos.X; + sal_Int32 nYPos = rPos.Y; + + //set position matrix + //the matrix needs to be set at the end behind autogrow and such position influencing properties + ::basegfx::B2DHomMatrix aM; + aM.rotate( -nRotation*F_PI/180.0 );//#i78696#->#i80521# + aM.translate( nXPos, nYPos ); + xShapeProp->setPropertyValue( "Transformation", uno::makeAny( B2DHomMatrixToHomogenMatrix3(aM) ) ); + } + catch( const uno::Exception& e ) + { + ASSERT_EXCEPTION( e ); + } + return xShape; +} + + } //namespace chart /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/view/main/VTitle.cxx b/chart2/source/view/main/VTitle.cxx index c95ff24..41d7eeb 100644 --- a/chart2/source/view/main/VTitle.cxx +++ b/chart2/source/view/main/VTitle.cxx @@ -21,13 +21,10 @@ #include "CommonConverters.hxx" #include "macros.hxx" #include "PropertyMapper.hxx" -#include "ShapeFactory.hxx" -#include "RelativeSizeHelper.hxx" +#include "AbstractShapeFactory.hxx" #include <com/sun/star/chart2/XFormattedString.hpp> #include <rtl/math.hxx> #include <com/sun/star/beans/XPropertySet.hpp> -#include <com/sun/star/drawing/TextVerticalAdjust.hpp> -#include <com/sun/star/drawing/TextHorizontalAdjust.hpp> #include <com/sun/star/text/ControlCharacter.hpp> #include <com/sun/star/text/XText.hpp> #include <com/sun/star/text/XTextCursor.hpp> @@ -78,7 +75,7 @@ awt::Size VTitle::getUnrotatedSize() const //size before rotation awt::Size VTitle::getFinalSize() const //size after rotation { - return ShapeFactory::getSizeAfterRotation( + return AbstractShapeFactory::getSizeAfterRotation( m_xShape, m_fRotationAngleDegree ); } @@ -111,168 +108,32 @@ void VTitle::createShapes( const awt::Point& rPos , const awt::Size& rReferenceSize ) { - try - { - if(!m_xTitle.is()) - return; - - uno::Sequence< uno::Reference< XFormattedString > > aStringList = m_xTitle->getText(); - if(aStringList.getLength()<=0) - return; - - //create shape and add to page - uno::Reference< drawing::XShape > xShape( - m_xShapeFactory->createInstance( - "com.sun.star.drawing.TextShape" ), uno::UNO_QUERY ); - m_xTarget->add(xShape); - m_xShape = xShape; - - //set text and text properties - uno::Reference< text::XText > xText( xShape, uno::UNO_QUERY ); - uno::Reference< text::XTextCursor > xTextCursor( xText->createTextCursor() ); - uno::Reference< text::XTextRange > xTextRange( xTextCursor, uno::UNO_QUERY ); - uno::Reference< beans::XPropertySet > xShapeProp( xShape, uno::UNO_QUERY ); - uno::Reference< beans::XPropertySet > xTitleProperties( m_xTitle, uno::UNO_QUERY ); - if( !xText.is() || !xTextRange.is() || !xTextCursor.is() || !xShapeProp.is() || !xTitleProperties.is() ) - return; - - tPropertyNameValueMap aValueMap; - //fill line-, fill- and paragraph-properties into the ValueMap - { - tMakePropertyNameMap aNameMap = PropertyMapper::getPropertyNameMapForParagraphProperties(); - aNameMap( PropertyMapper::getPropertyNameMapForFillAndLineProperties() ); - - PropertyMapper::getValueMap( aValueMap, aNameMap, xTitleProperties ); - } - - //fill some more shape properties into the ValueMap - { - drawing::TextHorizontalAdjust eHorizontalAdjust = drawing::TextHorizontalAdjust_CENTER; - drawing::TextVerticalAdjust eVerticalAdjust = drawing::TextVerticalAdjust_CENTER; - - aValueMap.insert( tPropertyNameValueMap::value_type( "TextHorizontalAdjust", uno::makeAny(eHorizontalAdjust) ) ); // drawing::TextHorizontalAdjust - aValueMap.insert( tPropertyNameValueMap::value_type( "TextVerticalAdjust", uno::makeAny(eVerticalAdjust) ) ); //drawing::TextVerticalAdjust - aValueMap.insert( tPropertyNameValueMap::value_type( "TextAutoGrowHeight", uno::makeAny(sal_True) ) ); // sal_Bool - aValueMap.insert( tPropertyNameValueMap::value_type( "TextAutoGrowWidth", uno::makeAny(sal_True) ) ); // sal_Bool - - //set name/classified ObjectID (CID) - if( !m_aCID.isEmpty() ) - aValueMap.insert( tPropertyNameValueMap::value_type( "Name", uno::makeAny( m_aCID ) ) ); //CID OUString - } - - //set global title properties - { - tNameSequence aPropNames; - tAnySequence aPropValues; - PropertyMapper::getMultiPropertyListsFromValueMap( aPropNames, aPropValues, aValueMap ); - PropertyMapper::setMultiProperties( aPropNames, aPropValues, xShapeProp ); - } - - sal_Bool bStackCharacters(sal_False); - try - { - xTitleProperties->getPropertyValue( "StackCharacters" ) >>= bStackCharacters; - } - catch( const uno::Exception& e ) - { - ASSERT_EXCEPTION( e ); - } - - if(bStackCharacters) - { - //if the characters should be stacked we use only the first character properties for code simplicity - if( aStringList.getLength()>0 ) - { - OUString aLabel; - for( sal_Int32 nN=0; nN<aStringList.getLength();nN++ ) - aLabel += aStringList[nN]->getString(); - aLabel = ShapeFactory::getStackedString( aLabel, bStackCharacters ); - - xTextCursor->gotoEnd(false); - xText->insertString( xTextRange, aLabel, false ); - xTextCursor->gotoEnd(true); - uno::Reference< beans::XPropertySet > xTargetProps( xShape, uno::UNO_QUERY ); - uno::Reference< beans::XPropertySet > xSourceProps( aStringList[0], uno::UNO_QUERY ); - - PropertyMapper::setMappedProperties( xTargetProps, xSourceProps - , PropertyMapper::getPropertyNameMapForCharacterProperties() ); - - // adapt font size according to page size - awt::Size aOldRefSize; - if( xTitleProperties->getPropertyValue( "ReferencePageSize") >>= aOldRefSize ) - { - RelativeSizeHelper::adaptFontSizes( xTargetProps, aOldRefSize, rReferenceSize ); - } - } - } - else - { - uno::Sequence< uno::Reference< text::XTextCursor > > aCursorList( aStringList.getLength() ); - sal_Int32 nN = 0; - for( nN=0; nN<aStringList.getLength();nN++ ) - { - xTextCursor->gotoEnd(false); - xText->insertString( xTextRange, aStringList[nN]->getString(), false ); - xTextCursor->gotoEnd(true); - aCursorList[nN] = xText->createTextCursorByRange( uno::Reference< text::XTextRange >(xTextCursor,uno::UNO_QUERY) ); - } - awt::Size aOldRefSize; - bool bHasRefPageSize = - ( xTitleProperties->getPropertyValue( "ReferencePageSize") >>= aOldRefSize ); + if(!m_xTitle.is()) + return; - if( aStringList.getLength()>0 ) - { - uno::Reference< beans::XPropertySet > xTargetProps( xShape, uno::UNO_QUERY ); - uno::Reference< beans::XPropertySet > xSourceProps( aStringList[0], uno::UNO_QUERY ); - PropertyMapper::setMappedProperties( xTargetProps, xSourceProps, PropertyMapper::getPropertyNameMapForCharacterProperties() ); + uno::Sequence< uno::Reference< XFormattedString > > aStringList = m_xTitle->getText(); + if(aStringList.getLength()<=0) + return; - // adapt font size according to page size - if( bHasRefPageSize ) - { - RelativeSizeHelper::adaptFontSizes( xTargetProps, aOldRefSize, rReferenceSize ); - } - } - } + m_nXPos = rPos.X; + m_nYPos = rPos.Y; - // #i109336# Improve auto positioning in chart - float fFontHeight = 0.0; - if ( xShapeProp.is() && ( xShapeProp->getPropertyValue( "CharHeight" ) >>= fFontHeight ) ) - { - fFontHeight *= ( 2540.0f / 72.0f ); // pt -> 1/100 mm - float fXFraction = 0.18f; - sal_Int32 nXDistance = static_cast< sal_Int32 >( ::rtl::math::round( fFontHeight * fXFraction ) ); - float fYFraction = 0.30f; - sal_Int32 nYDistance = static_cast< sal_Int32 >( ::rtl::math::round( fFontHeight * fYFraction ) ); - xShapeProp->setPropertyValue( "TextLeftDistance", uno::makeAny( nXDistance ) ); - xShapeProp->setPropertyValue( "TextRightDistance", uno::makeAny( nXDistance ) ); - xShapeProp->setPropertyValue( "TextUpperDistance", uno::makeAny( nYDistance ) ); - xShapeProp->setPropertyValue( "TextLowerDistance", uno::makeAny( nYDistance ) ); - } + uno::Reference< beans::XPropertySet > xTitleProperties( m_xTitle, uno::UNO_QUERY ); - try - { - double fAngleDegree = 0; - xTitleProperties->getPropertyValue( "TextRotation" ) >>= fAngleDegree; - m_fRotationAngleDegree += fAngleDegree; - } - catch( const uno::Exception& e ) - { - ASSERT_EXCEPTION( e ); - } - m_nXPos = rPos.X; - m_nYPos = rPos.Y; - - //set position matrix - //the matrix needs to be set at the end behind autogrow and such position influencing properties - ::basegfx::B2DHomMatrix aM; - aM.rotate( -m_fRotationAngleDegree*F_PI/180.0 );//#i78696#->#i80521# - aM.translate( m_nXPos, m_nYPos ); - xShapeProp->setPropertyValue( "Transformation", uno::makeAny( B2DHomMatrixToHomogenMatrix3(aM) ) ); + try + { + double fAngleDegree = 0; + xTitleProperties->getPropertyValue( "TextRotation" ) >>= fAngleDegree; + m_fRotationAngleDegree += fAngleDegree; } catch( const uno::Exception& e ) { ASSERT_EXCEPTION( e ); } + + AbstractShapeFactory* pShapeFactory = AbstractShapeFactory::getOrCreateShapeFactory(m_xShapeFactory); + m_xShape =pShapeFactory->createText( m_xTarget, rReferenceSize, rPos, aStringList, + xTitleProperties, m_fRotationAngleDegree, m_aCID ); } } //namespace chart commit eccd6d1afc4a0fcfd569d70eb1f4a3aaf8ef3b95 Author: Markus Mohrhard <[email protected]> Date: Tue Oct 8 00:17:37 2013 +0200 only one createInstance call left Change-Id: Iabefaea11e9190f84cecc1991585c4a958802fae diff --git a/chart2/source/view/charttypes/CandleStickChart.cxx b/chart2/source/view/charttypes/CandleStickChart.cxx index 88cb2c2..3c62b26 100644 --- a/chart2/source/view/charttypes/CandleStickChart.cxx +++ b/chart2/source/view/charttypes/CandleStickChart.cxx @@ -231,37 +231,33 @@ void CandleStickChart::createShapes() //create min-max line if( isValidPosition(aPosMiddleMinimum) && isValidPosition(aPosMiddleMaximum) ) { - uno::Reference< drawing::XShape > xShape( - m_xShapeFactory->createInstance( "com.sun.star.drawing.PolyLineShape" ), - uno::UNO_QUERY ); - xPointGroupShape_Shapes->add(xShape); - uno::Reference< beans::XPropertySet > xProp( xShape, uno::UNO_QUERY ); - if(xProp.is()) - { - drawing::PolyPolygonShape3D aPoly; - sal_Int32 nLineIndex =0; - AddPointToPoly( aPoly, aPosMiddleMinimum, nLineIndex); - AddPointToPoly( aPoly, aPosMiddleMaximum, nLineIndex); - xProp->setPropertyValue( UNO_NAME_POLYPOLYGON, uno::makeAny( PolyToPointSequence(aPoly) ) ); - } + drawing::PolyPolygonShape3D aPoly; + sal_Int32 nLineIndex =0; + AddPointToPoly( aPoly, aPosMiddleMinimum, nLineIndex); + AddPointToPoly( aPoly, aPosMiddleMaximum, nLineIndex); + + uno::Reference< drawing::XShape > xShape = + m_pShapeFactory->createLine2D( xPointGroupShape_Shapes, + PolyToPointSequence(aPoly), NULL); this->setMappedProperties( xShape, xPointProp, PropertyMapper::getPropertyNameMapForLineSeriesProperties() ); } //create first-last shape if(bJapaneseStyle && isValidPosition(aPosLeftFirst) && isValidPosition(aPosRightLast) ) { - uno::Reference< drawing::XShape > xShape( - m_xShapeFactory->createInstance( "com.sun.star.drawing.RectangleShape" ), - uno::UNO_QUERY ); - xLossGainTarget->add(xShape); - - xShape->setPosition( Position3DToAWTPoint( aPosLeftFirst ) ); drawing::Direction3D aDiff = aPosRightLast-aPosLeftFirst; awt::Size aAWTSize( Direction3DToAWTSize( aDiff )); // workaround for bug in drawing: if height is 0 the box gets infinitely large if( aAWTSize.Height == 0 ) aAWTSize.Height = 1; - xShape->setSize( aAWTSize ); + + tNameSequence aNames; + tAnySequence aValues; + + uno::Reference< drawing::XShape > xShape = + m_pShapeFactory->createRectangle( xLossGainTarget, + aAWTSize, Position3DToAWTPoint( aPosLeftFirst ), + aNames, aValues); uno::Reference< beans::XPropertySet > xProp( xShape, uno::UNO_QUERY ); if(xProp.is()) @@ -292,14 +288,12 @@ void CandleStickChart::createShapes() if( aPoly.SequenceX.getLength() ) { - uno::Reference< drawing::XShape > xShape( - m_xShapeFactory->createInstance( "com.sun.star.drawing.PolyLineShape" ), - uno::UNO_QUERY ); - xPointGroupShape_Shapes->add(xShape); + uno::Reference< drawing::XShape > xShape = + m_pShapeFactory->createLine2D( xPointGroupShape_Shapes, + PolyToPointSequence(aPoly), NULL ); uno::Reference< beans::XPropertySet > xProp( xShape, uno::UNO_QUERY ); if(xProp.is()) { - xProp->setPropertyValue( UNO_NAME_POLYPOLYGON, uno::makeAny( PolyToPointSequence(aPoly) ) ); this->setMappedProperties( xShape, xPointProp, PropertyMapper::getPropertyNameMapForLineSeriesProperties() ); } } commit afc7b3d7923d354ef0933d1f360e32bbc8e6887f Author: Markus Mohrhard <[email protected]> Date: Mon Oct 7 01:43:11 2013 +0200 use AbstractShapeFactory in more places Change-Id: I1c34f6e56579c4a43e4ba28a81799c3f67d679cb diff --git a/chart2/source/view/diagram/VDiagram.cxx b/chart2/source/view/diagram/VDiagram.cxx index 643146c..a07d262 100644 --- a/chart2/source/view/diagram/VDiagram.cxx +++ b/chart2/source/view/diagram/VDiagram.cxx @@ -170,11 +170,10 @@ void VDiagram::createShapes_2d() //add back wall { - m_xWall2D = uno::Reference< drawing::XShape >( - m_xShapeFactory->createInstance( - "com.sun.star.drawing.RectangleShape" ), uno::UNO_QUERY ); + AbstractShapeFactory* pShapeFactory = AbstractShapeFactory::getOrCreateShapeFactory(m_xShapeFactory); + m_xWall2D = pShapeFactory->createRectangle( + xGroupForWall ); - xGroupForWall->add(m_xWall2D); uno::Reference< beans::XPropertySet > xProp( m_xWall2D, uno::UNO_QUERY ); if( xProp.is()) { @@ -477,10 +476,7 @@ void VDiagram::createShapes_3d() //create shape m_xOuterGroupShape = uno::Reference< drawing::XShape >( - m_xShapeFactory->createInstance( - "com.sun.star.drawing.Shape3DSceneObject" ), uno::UNO_QUERY ); - AbstractShapeFactory::setShapeName( m_xOuterGroupShape, "PlotAreaExcludingAxes" ); - m_xTarget->add(m_xOuterGroupShape); + m_pShapeFactory->createGroup3D( m_xTarget, "PlotAreaExcludingAxes" ), uno::UNO_QUERY); uno::Reference< drawing::XShapes > xOuterGroup_Shapes = uno::Reference<drawing::XShapes>( m_xOuterGroupShape, uno::UNO_QUERY ); diff --git a/chart2/source/view/inc/AbstractShapeFactory.hxx b/chart2/source/view/inc/AbstractShapeFactory.hxx index fc25226..03780eb 100644 --- a/chart2/source/view/inc/AbstractShapeFactory.hxx +++ b/chart2/source/view/inc/AbstractShapeFactory.hxx @@ -204,6 +204,11 @@ public: , const tNameSequence& rPropNames , const tAnySequence& rPropValues ) = 0; + virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > + createRectangle( + const ::com::sun::star::uno::Reference< + ::com::sun::star::drawing::XShapes >& xTarget ) = 0; + virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes > getOrCreateChartRootShape( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage>& xPage ) = 0; diff --git a/chart2/source/view/inc/DummyShapeFactory.hxx b/chart2/source/view/inc/DummyShapeFactory.hxx index fab8132..0cc7b90 100644 --- a/chart2/source/view/inc/DummyShapeFactory.hxx +++ b/chart2/source/view/inc/DummyShapeFactory.hxx @@ -160,6 +160,11 @@ public: , const tNameSequence& rPropNames , const tAnySequence& rPropValues ); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > + createRectangle( + const ::com::sun::star::uno::Reference< + ::com::sun::star::drawing::XShapes >& xTarget ); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes > getOrCreateChartRootShape( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage>& xPage ); diff --git a/chart2/source/view/inc/ShapeFactory.hxx b/chart2/source/view/inc/ShapeFactory.hxx index 0f5d5e9..f38f47c 100644 --- a/chart2/source/view/inc/ShapeFactory.hxx +++ b/chart2/source/view/inc/ShapeFactory.hxx @@ -175,6 +175,10 @@ public: , const tNameSequence& rPropNames , const tAnySequence& rPropValues ); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > + createRectangle( + const ::com::sun::star::uno::Reference< + ::com::sun::star::drawing::XShapes >& xTarget ); virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes > getOrCreateChartRootShape( const ::com::sun::star::uno::Reference< diff --git a/chart2/source/view/main/DataPointSymbolSupplier.cxx b/chart2/source/view/main/DataPointSymbolSupplier.cxx index af87754..96190d1 100644 --- a/chart2/source/view/main/DataPointSymbolSupplier.cxx +++ b/chart2/source/view/main/DataPointSymbolSupplier.cxx @@ -30,15 +30,10 @@ uno::Reference< drawing::XShapes > DataPointSymbolSupplier::create2DSymbolList( , const uno::Reference< drawing::XShapes >& xTarget , const drawing::Direction3D& rSize ) { - uno::Reference< drawing::XShape > xGroup( - xShapeFactory->createInstance( - "com.sun.star.drawing.GroupShape" ), uno::UNO_QUERY ); - if(xTarget.is()) - xTarget->add(xGroup); + AbstractShapeFactory* pShapeFactory = AbstractShapeFactory::getOrCreateShapeFactory(xShapeFactory); uno::Reference< drawing::XShapes > xGroupShapes = - uno::Reference<drawing::XShapes>( xGroup, uno::UNO_QUERY ); + pShapeFactory->createGroup2D( xTarget ); - AbstractShapeFactory* pShapeFactory = AbstractShapeFactory::getOrCreateShapeFactory(xShapeFactory); drawing::Position3D aPos(0,0,0); for(sal_Int32 nS=0;nS<AbstractShapeFactory::getSymbolCount();nS++) { diff --git a/chart2/source/view/main/DummyShapeFactory.cxx b/chart2/source/view/main/DummyShapeFactory.cxx index 187e8fe..eb85535 100644 --- a/chart2/source/view/main/DummyShapeFactory.cxx +++ b/chart2/source/view/main/DummyShapeFactory.cxx @@ -252,6 +252,14 @@ uno::Reference< drawing::XShape > DummyShapeFactory::createRectangle( } uno::Reference< drawing::XShape > + DummyShapeFactory::createRectangle( + const uno::Reference< + drawing::XShapes >& ) +{ + return new DummyXShape(); +} + +uno::Reference< drawing::XShape > DummyShapeFactory::createText( const uno::Reference< drawing::XShapes >& , const OUString& , const tNameSequence& diff --git a/chart2/source/view/main/ShapeFactory.cxx b/chart2/source/view/main/ShapeFactory.cxx index 69cc0c1..5deac27 100644 --- a/chart2/source/view/main/ShapeFactory.cxx +++ b/chart2/source/view/main/ShapeFactory.cxx @@ -2061,6 +2061,18 @@ uno::Reference< drawing::XShape > ShapeFactory::createRectangle( } uno::Reference< drawing::XShape > + ShapeFactory::createRectangle( + const uno::Reference< + drawing::XShapes >& xTarget ) +{ + uno::Reference< drawing::XShape > xShape( m_xShapeFactory->createInstance( + "com.sun.star.drawing.RectangleShape"), uno::UNO_QUERY ); + xTarget->add( xShape ); + + return xShape; +} + +uno::Reference< drawing::XShape > ShapeFactory::createText( const uno::Reference< drawing::XShapes >& xTarget , const OUString& rText , const tNameSequence& rPropNames _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
