[Libreoffice-commits] core.git: Branch 'private/moggi/abstract-chart-rendering' - 4 commits - chart2/source

Markus Mohrhard markus.mohrhard at googlemail.com
Sat Oct 5 21:52:56 PDT 2013


 chart2/source/view/diagram/VDiagram.cxx          |    1 
 chart2/source/view/inc/AbstractShapeFactory.hxx  |   20 +++
 chart2/source/view/inc/DummyShapeFactory.hxx     |   18 +++
 chart2/source/view/inc/ShapeFactory.hxx          |   20 +++
 chart2/source/view/main/ChartView.cxx            |   48 ++------
 chart2/source/view/main/DummyShapeFactory.cxx    |   26 ++++
 chart2/source/view/main/PlotterBase.cxx          |    1 
 chart2/source/view/main/ShapeFactory.cxx         |   53 ++++++++
 chart2/source/view/main/VLegend.cxx              |   75 ++++--------
 chart2/source/view/main/VLegendSymbolFactory.cxx |  136 +++++++++++------------
 chart2/source/view/main/VTitle.cxx               |    1 
 11 files changed, 250 insertions(+), 149 deletions(-)

New commits:
commit 8c687694daff0351d00042f31d01616964846928
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sun Oct 6 07:43:07 2013 +0200

    more use of ShapeFactory and set Properties in factory if possible
    
    Change-Id: I7d172fd7bde506233fc74ec07b9603ee29149e5c

diff --git a/chart2/source/view/inc/AbstractShapeFactory.hxx b/chart2/source/view/inc/AbstractShapeFactory.hxx
index 6b97276..fc25226 100644
--- a/chart2/source/view/inc/AbstractShapeFactory.hxx
+++ b/chart2/source/view/inc/AbstractShapeFactory.hxx
@@ -200,7 +200,9 @@ public:
             const ::com::sun::star::uno::Reference<
                 ::com::sun::star::drawing::XShapes >& xTarget
                 , const ::com::sun::star::awt::Size& rSize
-                , const ::com::sun::star::awt::Point& rPosition ) = 0;
+                , const ::com::sun::star::awt::Point& rPosition
+                , const tNameSequence& rPropNames
+                , const tAnySequence& rPropValues ) = 0;
 
     virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >
          getOrCreateChartRootShape( const ::com::sun::star::uno::Reference<
diff --git a/chart2/source/view/inc/DummyShapeFactory.hxx b/chart2/source/view/inc/DummyShapeFactory.hxx
index d774333..fab8132 100644
--- a/chart2/source/view/inc/DummyShapeFactory.hxx
+++ b/chart2/source/view/inc/DummyShapeFactory.hxx
@@ -156,7 +156,9 @@ public:
             const ::com::sun::star::uno::Reference<
                 ::com::sun::star::drawing::XShapes >& xTarget
                 , const ::com::sun::star::awt::Size& rSize
-                , const ::com::sun::star::awt::Point& rPosition );
+                , const ::com::sun::star::awt::Point& rPosition
+                , const tNameSequence& rPropNames
+                , const tAnySequence& rPropValues );
 
     virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >
          getOrCreateChartRootShape( const ::com::sun::star::uno::Reference<
diff --git a/chart2/source/view/inc/ShapeFactory.hxx b/chart2/source/view/inc/ShapeFactory.hxx
index 577ce20..0f5d5e9 100644
--- a/chart2/source/view/inc/ShapeFactory.hxx
+++ b/chart2/source/view/inc/ShapeFactory.hxx
@@ -171,7 +171,9 @@ public:
             const ::com::sun::star::uno::Reference<
                 ::com::sun::star::drawing::XShapes >& xTarget
                 , const ::com::sun::star::awt::Size& rSize
-                , const ::com::sun::star::awt::Point& rPosition );
+                , const ::com::sun::star::awt::Point& rPosition
+                , const tNameSequence& rPropNames
+                , const tAnySequence& rPropValues );
 
 
     virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >
diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx
index c9198be..ae309b4 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -2303,39 +2303,25 @@ void formatPage(
         if( !xShapeFactory.is() )
             return;
 
-        uno::Reference< beans::XPropertySet > xPageProp;
-        // create a shape for the background
-        {
-            uno::Reference< drawing::XShape > xShape(
-                xShapeFactory->createInstance(
-                    "com.sun.star.drawing.RectangleShape"), uno::UNO_QUERY );
-            if( xTarget.is() &&
-                xShape.is())
-            {
-                xTarget->add( xShape );
-                xShape->setSize( rPageSize );
-                xPageProp.set( xShape, uno::UNO_QUERY );
-                if( xPageProp.is())
-                {
-                    xPageProp->setPropertyValue( "LineStyle", uno::makeAny( drawing::LineStyle_NONE ));
-                }
-            }
-        }
 
         //format page
-        if( xPageProp.is())
-        {
-            tPropertyNameValueMap aNameValueMap;
-            PropertyMapper::getValueMap( aNameValueMap, PropertyMapper::getPropertyNameMapForFillAndLineProperties(), xModelPage );
-
-            OUString aCID( ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_PAGE, OUString() ) );
-            aNameValueMap.insert( tPropertyNameValueMap::value_type( "Name", uno::makeAny( aCID ) ) ); //CID OUString
-
-            tNameSequence aNames;
-            tAnySequence aValues;
-            PropertyMapper::getMultiPropertyListsFromValueMap( aNames, aValues, aNameValueMap );
-            PropertyMapper::setMultiProperties( aNames, aValues, xPageProp );
-        }
+        tPropertyNameValueMap aNameValueMap;
+        aNameValueMap.insert( tPropertyNameValueMap::value_type( "LineStyle", uno::makeAny( drawing::LineStyle_NONE )));
+        PropertyMapper::getValueMap( aNameValueMap, PropertyMapper::getPropertyNameMapForFillAndLineProperties(), xModelPage );
+
+        OUString aCID( ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_PAGE, OUString() ) );
+        aNameValueMap.insert( tPropertyNameValueMap::value_type( "Name", uno::makeAny( aCID ) ) ); //CID OUString
+
+        tNameSequence aNames;
+        tAnySequence aValues;
+        PropertyMapper::getMultiPropertyListsFromValueMap( aNames, aValues, aNameValueMap );
+
+        AbstractShapeFactory* pShapeFactory = AbstractShapeFactory::getOrCreateShapeFactory(xShapeFactory);
+        uno::Reference< drawing::XShape > xShape =
+            pShapeFactory->createRectangle( xTarget,
+                    rPageSize,
+                    awt::Point( 0, 0 ),
+                    aNames, aValues );
     }
     catch( const uno::Exception & ex )
     {
diff --git a/chart2/source/view/main/DummyShapeFactory.cxx b/chart2/source/view/main/DummyShapeFactory.cxx
index 1972297..187e8fe 100644
--- a/chart2/source/view/main/DummyShapeFactory.cxx
+++ b/chart2/source/view/main/DummyShapeFactory.cxx
@@ -244,7 +244,9 @@ uno::Reference< drawing::XShape > DummyShapeFactory::createInvisibleRectangle(
 uno::Reference< drawing::XShape > DummyShapeFactory::createRectangle(
         const uno::Reference< drawing::XShapes >&
         , const awt::Size&
-        , const awt::Point& )
+        , const awt::Point&
+        , const tNameSequence&
+        , const tAnySequence& )
 {
     return new DummyXShape();
 }
diff --git a/chart2/source/view/main/ShapeFactory.cxx b/chart2/source/view/main/ShapeFactory.cxx
index 3353f3c..69cc0c1 100644
--- a/chart2/source/view/main/ShapeFactory.cxx
+++ b/chart2/source/view/main/ShapeFactory.cxx
@@ -2042,7 +2042,9 @@ uno::Reference< drawing::XShape > ShapeFactory::createInvisibleRectangle(
 uno::Reference< drawing::XShape > ShapeFactory::createRectangle(
         const uno::Reference< drawing::XShapes >& xTarget
         , const awt::Size& rSize
-        , const awt::Point& rPosition )
+        , const awt::Point& rPosition
+        , const tNameSequence& rPropNames
+        , const tAnySequence& rPropValues )
 {
     uno::Reference< drawing::XShape > xShape( m_xShapeFactory->createInstance(
                 "com.sun.star.drawing.RectangleShape"), uno::UNO_QUERY );
@@ -2051,6 +2053,8 @@ uno::Reference< drawing::XShape > ShapeFactory::createRectangle(
         xTarget->add( xShape );
         xShape->setSize( rSize );
         xShape->setPosition( rPosition );
+        uno::Reference< beans::XPropertySet > xPropSet( xShape, uno::UNO_QUERY_THROW );
+        PropertyMapper::setMultiProperties( rPropNames, rPropValues, xPropSet );
     }
 
     return xShape;
diff --git a/chart2/source/view/main/VLegend.cxx b/chart2/source/view/main/VLegend.cxx
index f13724d..60872ec 100644
--- a/chart2/source/view/main/VLegend.cxx
+++ b/chart2/source/view/main/VLegend.cxx
@@ -915,19 +915,12 @@ void VLegend::createShapes(
             Reference< drawing::XShape > xBorder =
                 pShapeFactory->createRectangle( xLegendContainer,
                         aLegendSize,
-                        awt::Point(0,0));
+                        awt::Point(0,0),
+                        aLineFillProperties.first,
+                        aLineFillProperties.second );
 
-            if( xBorder.is())
-            {
-
-                // apply legend properties
-                PropertyMapper::setMultiProperties(
-                    aLineFillProperties.first, aLineFillProperties.second,
-                    Reference< beans::XPropertySet >( xBorder, uno::UNO_QUERY ));
-
-                //because of this name this border will be used for marking the legend
-                AbstractShapeFactory::setShapeName( xBorder, "MarkHandles" );
-            }
+            //because of this name this border will be used for marking the legend
+            AbstractShapeFactory::setShapeName( xBorder, "MarkHandles" );
         }
     }
     catch( const uno::Exception & ex )
diff --git a/chart2/source/view/main/VLegendSymbolFactory.cxx b/chart2/source/view/main/VLegendSymbolFactory.cxx
index cd8dcc9..465b690 100644
--- a/chart2/source/view/main/VLegendSymbolFactory.cxx
+++ b/chart2/source/view/main/VLegendSymbolFactory.cxx
@@ -31,11 +31,12 @@ using ::com::sun::star::uno::Sequence;
 
 namespace
 {
-void lcl_setPropetiesToShape(
-    const Reference< beans::XPropertySet > & xProp,
-    const Reference< drawing::XShape > & xShape,
-    ::chart::VLegendSymbolFactory::tPropertyType ePropertyType,
-    const awt::Size& aMaxSymbolExtent = awt::Size(0,0))
+
+void getPropNamesAndValues( const Reference< beans::XPropertySet >& xProp,
+        ::chart::tNameSequence& rNames,
+        ::chart::tAnySequence& rValues,
+        ::chart::VLegendSymbolFactory::tPropertyType ePropertyType,
+        const awt::Size& aMaxSymbolExtent = awt::Size(0,0))
 {
     const ::chart::tPropertyNameMap & aFilledSeriesNameMap( ::chart::PropertyMapper::getPropertyNameMapForFilledSeriesProperties());
     const ::chart::tPropertyNameMap & aLineSeriesNameMap( ::chart::PropertyMapper::getPropertyNameMapForLineSeriesProperties());
@@ -43,47 +44,54 @@ void lcl_setPropetiesToShape(
     const ::chart::tPropertyNameMap & aFillNameMap( ::chart::PropertyMapper::getPropertyNameMapForFillProperties());
     const ::chart::tPropertyNameMap & aFillLineNameMap( ::chart::PropertyMapper::getPropertyNameMapForFillAndLineProperties());
 
-    Reference< beans::XPropertySet > xShapeProp( xShape, uno::UNO_QUERY );
-    if( xProp.is() && xShapeProp.is() )
+    ::chart::tPropertyNameValueMap aValueMap;
+    switch( ePropertyType )
     {
-        ::chart::tPropertyNameValueMap aValueMap;
-        switch( ePropertyType )
-        {
-            case ::chart::VLegendSymbolFactory::PROP_TYPE_FILLED_SERIES:
-                ::chart::PropertyMapper::getValueMap( aValueMap, aFilledSeriesNameMap, xProp );
-                break;
-            case ::chart::VLegendSymbolFactory::PROP_TYPE_LINE_SERIES:
-                ::chart::PropertyMapper::getValueMap( aValueMap, aLineSeriesNameMap, xProp );
-                break;
-            case ::chart::VLegendSymbolFactory::PROP_TYPE_LINE:
-                ::chart::PropertyMapper::getValueMap( aValueMap, aLineNameMap, xProp );
-                break;
-            case ::chart::VLegendSymbolFactory::PROP_TYPE_FILL:
-                ::chart::PropertyMapper::getValueMap( aValueMap, aFillNameMap, xProp );
-                break;
-            case ::chart::VLegendSymbolFactory::PROP_TYPE_FILL_AND_LINE:
-                ::chart::PropertyMapper::getValueMap( aValueMap, aFillLineNameMap, xProp );
-                break;
-        }
+        case ::chart::VLegendSymbolFactory::PROP_TYPE_FILLED_SERIES:
+            ::chart::PropertyMapper::getValueMap( aValueMap, aFilledSeriesNameMap, xProp );
+            break;
+        case ::chart::VLegendSymbolFactory::PROP_TYPE_LINE_SERIES:
+            ::chart::PropertyMapper::getValueMap( aValueMap, aLineSeriesNameMap, xProp );
+            break;
+        case ::chart::VLegendSymbolFactory::PROP_TYPE_LINE:
+            ::chart::PropertyMapper::getValueMap( aValueMap, aLineNameMap, xProp );
+            break;
+        case ::chart::VLegendSymbolFactory::PROP_TYPE_FILL:
+            ::chart::PropertyMapper::getValueMap( aValueMap, aFillNameMap, xProp );
+            break;
+        case ::chart::VLegendSymbolFactory::PROP_TYPE_FILL_AND_LINE:
+            ::chart::PropertyMapper::getValueMap( aValueMap, aFillLineNameMap, xProp );
+            break;
+    }
 
-        ::chart::tNameSequence aPropNames;
-        ::chart::tAnySequence aPropValues;
-        ::chart::PropertyMapper::getMultiPropertyListsFromValueMap( aPropNames, aPropValues, aValueMap );
+    ::chart::PropertyMapper::getMultiPropertyListsFromValueMap( rNames, rValues, aValueMap );
 
-        uno::Any* pLineWidthAny = ::chart::PropertyMapper::getValuePointer(aPropValues,aPropNames,"LineWidth");
-        sal_Int32 nLineWidth = 0;
-        if( pLineWidthAny && (*pLineWidthAny>>=nLineWidth) )
-        {
-            // use legend entry height as upper limit for line width
-            sal_Int32 nMaxLineWidthForLegend = aMaxSymbolExtent.Height;
-            if( nLineWidth>nMaxLineWidthForLegend )
-                *pLineWidthAny = uno::makeAny( nMaxLineWidthForLegend );
-        }
-
-        ::chart::PropertyMapper::setMultiProperties( aPropNames, aPropValues, xShapeProp );
+    uno::Any* pLineWidthAny = ::chart::PropertyMapper::getValuePointer(rValues,rNames,"LineWidth");
+    sal_Int32 nLineWidth = 0;
+    if( pLineWidthAny && (*pLineWidthAny>>=nLineWidth) )
+    {
+        // use legend entry height as upper limit for line width
+        sal_Int32 nMaxLineWidthForLegend = aMaxSymbolExtent.Height;
+        if( nLineWidth>nMaxLineWidthForLegend )
+            *pLineWidthAny = uno::makeAny( nMaxLineWidthForLegend );
     }
 }
 
+void lcl_setPropetiesToShape(
+    const Reference< beans::XPropertySet > & xProp,
+    const Reference< drawing::XShape > & xShape,
+    ::chart::VLegendSymbolFactory::tPropertyType ePropertyType,
+    const awt::Size& aMaxSymbolExtent = awt::Size(0,0))
+{
+    ::chart::tNameSequence aPropNames;
+    ::chart::tAnySequence aPropValues;
+    getPropNamesAndValues( xProp, aPropNames, aPropValues,
+            ePropertyType, aMaxSymbolExtent );
+
+    Reference< beans::XPropertySet > xShapeProp( xShape, uno::UNO_QUERY );
+    ::chart::PropertyMapper::setMultiProperties( aPropNames, aPropValues, xShapeProp );
+}
+
 } // anonymous namespace
 
 namespace chart
@@ -176,13 +184,16 @@ Reference< drawing::XShape > VLegendSymbolFactory::createSymbol(
         }
         else // eStyle == LegendSymbolStyle_BOX
         {
+            tNameSequence aPropNames;
+            tAnySequence aPropValues;
+
+            getPropNamesAndValues( xLegendEntryProperties, aPropNames, aPropValues,
+                    ePropertyType );// PROP_TYPE_FILLED_SERIES
+
             Reference< drawing::XShape > xShape =
                 pShapeFactory->createRectangle( xResultGroup,
-                        rEntryKeyAspectRatio, awt::Point( 0, 0 ));
-            if( xShape.is() )
-            {
-                lcl_setPropetiesToShape( xLegendEntryProperties, xShape, ePropertyType ); // PROP_TYPE_FILLED_SERIES );
-            }
+                        rEntryKeyAspectRatio, awt::Point( 0, 0 ),
+                        aPropNames, aPropValues );
         }
     }
     catch( const uno::Exception & ex )
commit 0c3913cabf16228a38f228d210f5edea143ffcab
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sun Oct 6 03:30:51 2013 +0200

    and another file that only uses AbstractShapeFactory
    
    Change-Id: I5f986083fcbedae81281eb2bdaa6361115e1063a

diff --git a/chart2/source/view/main/VLegend.cxx b/chart2/source/view/main/VLegend.cxx
index 5efb74a..f13724d 100644
--- a/chart2/source/view/main/VLegend.cxx
+++ b/chart2/source/view/main/VLegend.cxx
@@ -153,19 +153,14 @@ awt::Size lcl_createTextShapes(
     const tPropertyValues & rTextProperties )
 {
     awt::Size aResult;
+    AbstractShapeFactory* pShapeFactory = AbstractShapeFactory::getOrCreateShapeFactory(xShapeFactory);
 
     for( tViewLegendEntryContainer::const_iterator aIt( rEntries.begin());
          aIt != rEntries.end(); ++aIt )
     {
         try
         {
-            // create label shape
-            Reference< drawing::XShape > xEntry(
-                xShapeFactory->createInstance(
-                    "com.sun.star.drawing.TextShape"), uno::UNO_QUERY_THROW );
-            xTarget->add( xEntry );
-
-            // set label text
+            OUString aLabelString;
             Sequence< Reference< XFormattedString2 > > aLabelSeq = (*aIt).aLabel;
             for( sal_Int32 i = 0; i < aLabelSeq.getLength(); ++i )
             {
@@ -173,23 +168,20 @@ awt::Size lcl_createTextShapes(
                 if( i == 1 )
                     break;
 
-                Reference< text::XTextRange > xRange( xEntry, uno::UNO_QUERY );
-                OUString aLabelString( aLabelSeq[i]->getString());
+                aLabelString = aLabelString + aLabelSeq[i]->getString();
                 // workaround for Issue #i67540#
                 if( aLabelString.isEmpty())
                     aLabelString = " ";
-                if( xRange.is())
-                    xRange->setString( aLabelString );
+            }
 
-                PropertyMapper::setMultiProperties(
-                    rTextProperties.first, rTextProperties.second,
-                    Reference< beans::XPropertySet >( xRange, uno::UNO_QUERY ));
+            Reference< drawing::XShape > xEntry =
+                pShapeFactory->createText( xTarget, aLabelString,
+                        rTextProperties.first, rTextProperties.second, uno::Any() );
 
-                // adapt max-extent
-                awt::Size aCurrSize( xEntry->getSize());
-                aResult.Width  = ::std::max( aResult.Width,  aCurrSize.Width  );
-                aResult.Height = ::std::max( aResult.Height, aCurrSize.Height );
-            }
+            // adapt max-extent
+            awt::Size aCurrSize( xEntry->getSize());
+            aResult.Width  = ::std::max( aResult.Width,  aCurrSize.Width  );
+            aResult.Height = ::std::max( aResult.Height, aCurrSize.Height );
 
             rOutTextShapes.push_back( xEntry );
         }
@@ -840,24 +832,16 @@ void VLegend::createShapes(
     try
     {
         //create shape and add to page
-        m_xShape.set( m_xShapeFactory->createInstance(
-                          "com.sun.star.drawing.GroupShape"), uno::UNO_QUERY );
-        m_xTarget->add( m_xShape );
-
-        // set name to enable selection
-        {
-            OUString aLegendParticle( ObjectIdentifier::createParticleForLegend( m_xLegend, m_xModel ) );
-            AbstractShapeFactory::setShapeName( m_xShape, ObjectIdentifier::createClassifiedIdentifierForParticle( aLegendParticle ) );
-        }
+        AbstractShapeFactory* pShapeFactory = AbstractShapeFactory::getOrCreateShapeFactory(m_xShapeFactory);
+        OUString aLegendParticle( ObjectIdentifier::createParticleForLegend( m_xLegend, m_xModel ) );
+        m_xShape.set( pShapeFactory->createGroup2D( m_xTarget,
+                    ObjectIdentifier::createClassifiedIdentifierForParticle( aLegendParticle )),
+                uno::UNO_QUERY);
 
         // create and insert sub-shapes
         Reference< drawing::XShapes > xLegendContainer( m_xShape, uno::UNO_QUERY );
         if( xLegendContainer.is())
         {
-            Reference< drawing::XShape > xBorder(
-                m_xShapeFactory->createInstance(
-                    "com.sun.star.drawing.RectangleShape"), uno::UNO_QUERY );
-
             // for quickly setting properties
             tPropertyValues aLineFillProperties;
             tPropertyValues aTextProperties;
@@ -884,19 +868,6 @@ void VLegend::createShapes(
                 lcl_getProperties( xLegendProp, aLineFillProperties, aTextProperties, rPageSize );
             }
 
-            if( xBorder.is())
-            {
-                xLegendContainer->add( xBorder );
-
-                // apply legend properties
-                PropertyMapper::setMultiProperties(
-                    aLineFillProperties.first, aLineFillProperties.second,
-                    Reference< beans::XPropertySet >( xBorder, uno::UNO_QUERY ));
-
-                //because of this name this border will be used for marking the legend
-                AbstractShapeFactory::setShapeName( xBorder, "MarkHandles" );
-            }
-
             // create entries
             double fViewFontSize = lcl_CalcViewFontSize( xLegendProp, rPageSize );//todo
             // #i109336# Improve auto positioning in chart
@@ -934,13 +905,28 @@ void VLegend::createShapes(
 
             bool bSymbolsLeftSide = lcl_shouldSymbolsBePlacedOnTheLeftSide( xLegendProp, m_nDefaultWritingMode );
 
-            if( aViewEntries.size() ) {
+            if( !aViewEntries.empty() ) {
                 // place entries
                 aLegendSize = lcl_placeLegendEntries( aViewEntries, eExpansion, bSymbolsLeftSide, fViewFontSize, aMaxSymbolExtent,
                                                       aTextProperties, xLegendContainer, m_xShapeFactory, aLegendSize );
 
-                if( xBorder.is() )
-                    xBorder->setSize( aLegendSize );
+            }
+
+            Reference< drawing::XShape > xBorder =
+                pShapeFactory->createRectangle( xLegendContainer,
+                        aLegendSize,
+                        awt::Point(0,0));
+
+            if( xBorder.is())
+            {
+
+                // apply legend properties
+                PropertyMapper::setMultiProperties(
+                    aLineFillProperties.first, aLineFillProperties.second,
+                    Reference< beans::XPropertySet >( xBorder, uno::UNO_QUERY ));
+
+                //because of this name this border will be used for marking the legend
+                AbstractShapeFactory::setShapeName( xBorder, "MarkHandles" );
             }
         }
     }
commit 60e8ae2e37a34dfcb850ba8dee01628bf8afd47f
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sun Oct 6 02:57:26 2013 +0200

    use the AbstractShapeFactory in more places
    
    Change-Id: I992533b5e38ca5cb91f7688d94c35652f7dbaa38

diff --git a/chart2/source/view/inc/AbstractShapeFactory.hxx b/chart2/source/view/inc/AbstractShapeFactory.hxx
index 163bfa3..6b97276 100644
--- a/chart2/source/view/inc/AbstractShapeFactory.hxx
+++ b/chart2/source/view/inc/AbstractShapeFactory.hxx
@@ -19,6 +19,8 @@
 #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>
@@ -160,6 +162,10 @@ public:
                     , const ::com::sun::star::drawing::PointSequenceSequence& rPoints
                     , const VLineProperties* pLineProperties = NULL ) = 0;
 
+    virtual com::sun::star::uno::Reference< com::sun::star::drawing::XShape >
+        createLine ( const ::com::sun::star::uno::Reference< com::sun::star::drawing::XShapes >& xTarget,
+                const com::sun::star::awt::Size& rSize, const com::sun::star::awt::Point& rPosition ) = 0;
+
     virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
         createLine3D( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget
                     , const ::com::sun::star::drawing::PolyPolygonShape3D& rPoints
@@ -171,6 +177,11 @@ public:
                     , const ::com::sun::star::drawing::Direction3D& rSize ) = 0;
 
     virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
+        createCircle( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget
+                    , const ::com::sun::star::awt::Size& rSize
+                    , const ::com::sun::star::awt::Point& rPosition ) = 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 OUString& rText
                     , const tNameSequence& rPropNames
@@ -184,6 +195,13 @@ public:
                 ::com::sun::star::drawing::XShapes >& xTarget
                 , const ::com::sun::star::awt::Size& rSize ) = 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
+                , const ::com::sun::star::awt::Size& rSize
+                , const ::com::sun::star::awt::Point& rPosition ) = 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 57ab726..d774333 100644
--- a/chart2/source/view/inc/DummyShapeFactory.hxx
+++ b/chart2/source/view/inc/DummyShapeFactory.hxx
@@ -118,6 +118,10 @@ public:
                     , const ::com::sun::star::drawing::PointSequenceSequence& rPoints
                     , const VLineProperties* pLineProperties = NULL );
 
+    virtual com::sun::star::uno::Reference< com::sun::star::drawing::XShape >
+        createLine ( const ::com::sun::star::uno::Reference< com::sun::star::drawing::XShapes >& xTarget,
+                const com::sun::star::awt::Size& rSize, const com::sun::star::awt::Point& rPosition );
+
     virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
         createLine3D( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget
                     , const ::com::sun::star::drawing::PolyPolygonShape3D& rPoints
@@ -129,6 +133,11 @@ public:
                     , const ::com::sun::star::drawing::Direction3D& rSize );
 
     virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
+        createCircle( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget
+                    , const ::com::sun::star::awt::Size& rSize
+                    , const ::com::sun::star::awt::Point& rPosition );
+
+    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 OUString& rText
                     , const tNameSequence& rPropNames
@@ -142,6 +151,13 @@ public:
                 ::com::sun::star::drawing::XShapes >& xTarget
                 , const ::com::sun::star::awt::Size& rSize );
 
+    virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
+        createRectangle(
+            const ::com::sun::star::uno::Reference<
+                ::com::sun::star::drawing::XShapes >& xTarget
+                , const ::com::sun::star::awt::Size& rSize
+                , const ::com::sun::star::awt::Point& rPosition );
+
     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 f67bfcc..577ce20 100644
--- a/chart2/source/view/inc/ShapeFactory.hxx
+++ b/chart2/source/view/inc/ShapeFactory.hxx
@@ -20,7 +20,6 @@
 #define _CHART2_VIEW_SHAPEFACTORY_HXX
 
 #include "AbstractShapeFactory.hxx"
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
 
 namespace chart
 {
@@ -134,6 +133,10 @@ public:
                     , const ::com::sun::star::drawing::PointSequenceSequence& rPoints
                     , const VLineProperties* pLineProperties = NULL );
 
+    virtual com::sun::star::uno::Reference< com::sun::star::drawing::XShape >
+        createLine ( const ::com::sun::star::uno::Reference< com::sun::star::drawing::XShapes >& xTarget,
+                const com::sun::star::awt::Size& rSize, const com::sun::star::awt::Point& rPosition );
+
     virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
         createLine3D( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget
                     , const ::com::sun::star::drawing::PolyPolygonShape3D& rPoints
@@ -145,6 +148,11 @@ public:
                     , const ::com::sun::star::drawing::Direction3D& rSize );
 
     virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
+        createCircle( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget
+                    , const ::com::sun::star::awt::Size& rSize
+                    , const ::com::sun::star::awt::Point& rPosition );
+
+    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 OUString& rText
                     , const tNameSequence& rPropNames
@@ -158,6 +166,14 @@ public:
                 ::com::sun::star::drawing::XShapes >& xTarget
                 , const ::com::sun::star::awt::Size& rSize );
 
+    virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
+        createRectangle(
+            const ::com::sun::star::uno::Reference<
+                ::com::sun::star::drawing::XShapes >& xTarget
+                , const ::com::sun::star::awt::Size& rSize
+                , const ::com::sun::star::awt::Point& rPosition );
+
+
     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/main/DummyShapeFactory.cxx b/chart2/source/view/main/DummyShapeFactory.cxx
index 452de3a..1972297 100644
--- a/chart2/source/view/main/DummyShapeFactory.cxx
+++ b/chart2/source/view/main/DummyShapeFactory.cxx
@@ -204,6 +204,14 @@ uno::Reference< drawing::XShape >
 }
 
 uno::Reference< drawing::XShape >
+    DummyShapeFactory::createCircle( const uno::Reference< drawing::XShapes >&
+                    , const awt::Size&
+                    , const awt::Point& )
+{
+    return new DummyXShape();
+}
+
+uno::Reference< drawing::XShape >
         DummyShapeFactory::createLine3D( const uno::Reference< drawing::XShapes >&
                     , const drawing::PolyPolygonShape3D&
                     , const VLineProperties& )
@@ -219,6 +227,13 @@ uno::Reference< drawing::XShape >
     return new DummyXShape();
 }
 
+uno::Reference< drawing::XShape >
+    DummyShapeFactory::createLine ( const uno::Reference< drawing::XShapes >& ,
+            const awt::Size& , const awt::Point& )
+{
+    return new DummyXShape();
+}
+
 uno::Reference< drawing::XShape > DummyShapeFactory::createInvisibleRectangle(
             const uno::Reference< drawing::XShapes >&
             , const awt::Size& )
@@ -226,6 +241,14 @@ uno::Reference< drawing::XShape > DummyShapeFactory::createInvisibleRectangle(
     return new DummyXShape();
 }
 
+uno::Reference< drawing::XShape > DummyShapeFactory::createRectangle(
+        const uno::Reference< drawing::XShapes >&
+        , const awt::Size&
+        , const awt::Point& )
+{
+    return new DummyXShape();
+}
+
 uno::Reference< drawing::XShape >
         DummyShapeFactory::createText( const uno::Reference< drawing::XShapes >&
                     , const OUString&
diff --git a/chart2/source/view/main/ShapeFactory.cxx b/chart2/source/view/main/ShapeFactory.cxx
index bf8b360..3353f3c 100644
--- a/chart2/source/view/main/ShapeFactory.cxx
+++ b/chart2/source/view/main/ShapeFactory.cxx
@@ -1859,6 +1859,21 @@ uno::Reference< drawing::XShape >
 }
 
 uno::Reference< drawing::XShape >
+    ShapeFactory::createCircle( const uno::Reference< drawing::XShapes >& xTarget
+                    , const awt::Size& rSize
+                    , const awt::Point& rPosition )
+{
+    uno::Reference< drawing::XShape > xShape(
+        m_xShapeFactory->createInstance(
+            "com.sun.star.drawing.EllipseShape" ), uno::UNO_QUERY );
+    xTarget->add(xShape);
+    xShape->setSize( rSize );
+    xShape->setPosition( rPosition );
+
+    return xShape;
+}
+
+uno::Reference< drawing::XShape >
         ShapeFactory::createLine3D( const uno::Reference< drawing::XShapes >& xTarget
                     , const drawing::PolyPolygonShape3D& rPoints
                     , const VLineProperties& rLineProperties )
@@ -1983,6 +1998,21 @@ uno::Reference< drawing::XShape >
     return xShape;
 }
 
+uno::Reference< drawing::XShape >
+    ShapeFactory::createLine ( const uno::Reference< drawing::XShapes >& xTarget,
+            const awt::Size& rSize, const awt::Point& rPosition )
+{
+    //create shape
+    uno::Reference< drawing::XShape > xShape(
+        m_xShapeFactory->createInstance(
+            "com.sun.star.drawing.LineShape" ), uno::UNO_QUERY );
+    xTarget->add(xShape);
+    xShape->setSize( rSize );
+    xShape->setPosition( rPosition );
+
+    return xShape;
+}
+
 uno::Reference< drawing::XShape > ShapeFactory::createInvisibleRectangle(
             const uno::Reference< drawing::XShapes >& xTarget
             , const awt::Size& rSize )
@@ -1994,7 +2024,7 @@ uno::Reference< drawing::XShape > ShapeFactory::createInvisibleRectangle(
 
         uno::Reference< drawing::XShape > xShape( m_xShapeFactory->createInstance(
                 "com.sun.star.drawing.RectangleShape"), uno::UNO_QUERY );
-        if( xTarget.is() && xShape.is())
+        if( xShape.is())
         {
             xTarget->add( xShape );
             ShapeFactory::makeShapeInvisible( xShape );
@@ -2009,6 +2039,23 @@ uno::Reference< drawing::XShape > ShapeFactory::createInvisibleRectangle(
     return 0;
 }
 
+uno::Reference< drawing::XShape > ShapeFactory::createRectangle(
+        const uno::Reference< drawing::XShapes >& xTarget
+        , const awt::Size& rSize
+        , const awt::Point& rPosition )
+{
+    uno::Reference< drawing::XShape > xShape( m_xShapeFactory->createInstance(
+                "com.sun.star.drawing.RectangleShape"), uno::UNO_QUERY );
+    if( xShape.is())
+    {
+        xTarget->add( xShape );
+        xShape->setSize( rSize );
+        xShape->setPosition( rPosition );
+    }
+
+    return xShape;
+}
+
 uno::Reference< drawing::XShape >
         ShapeFactory::createText( const uno::Reference< drawing::XShapes >& xTarget
                     , const OUString& rText
diff --git a/chart2/source/view/main/VLegendSymbolFactory.cxx b/chart2/source/view/main/VLegendSymbolFactory.cxx
index 4588273..cd8dcc9 100644
--- a/chart2/source/view/main/VLegendSymbolFactory.cxx
+++ b/chart2/source/view/main/VLegendSymbolFactory.cxx
@@ -102,15 +102,15 @@ Reference< drawing::XShape > VLegendSymbolFactory::createSymbol(
     if( ! (xSymbolContainer.is() && xShapeFactory.is()))
         return xResult;
 
-    xResult.set( xShapeFactory->createInstance(
-                     "com.sun.star.drawing.GroupShape"), uno::UNO_QUERY );
-    xSymbolContainer->add( xResult );
+    AbstractShapeFactory* pShapeFactory = AbstractShapeFactory::getOrCreateShapeFactory(xShapeFactory);
+    xResult.set( pShapeFactory->createGroup2D( xSymbolContainer ), uno::UNO_QUERY );
+
     Reference< drawing::XShapes > xResultGroup( xResult, uno::UNO_QUERY );
     if( ! xResultGroup.is())
         return xResult;
 
     // add an invisible square box to maintain aspect ratio
-    Reference< drawing::XShape > xBound( AbstractShapeFactory::getOrCreateShapeFactory(xShapeFactory)->createInvisibleRectangle(
+    Reference< drawing::XShape > xBound( pShapeFactory->createInvisibleRectangle(
                 xResultGroup, rEntryKeyAspectRatio  ));
 
     // create symbol
@@ -118,14 +118,11 @@ Reference< drawing::XShape > VLegendSymbolFactory::createSymbol(
     {
         if( eStyle == LegendSymbolStyle_LINE )
         {
-            Reference< drawing::XShape > xLine( xShapeFactory->createInstance(
-                    "com.sun.star.drawing.LineShape"), uno::UNO_QUERY );
+            Reference< drawing::XShape > xLine =
+                pShapeFactory->createLine( xResultGroup, awt::Size( rEntryKeyAspectRatio.Width, 0 ),
+                        awt::Point( 0, rEntryKeyAspectRatio.Height/2 ));
             if( xLine.is())
             {
-                xResultGroup->add( xLine );
-                xLine->setSize(  awt::Size( rEntryKeyAspectRatio.Width, 0 ));
-                xLine->setPosition( awt::Point( 0, rEntryKeyAspectRatio.Height/2 ));
-
                 lcl_setPropetiesToShape( xLegendEntryProperties, xLine, ePropertyType, rEntryKeyAspectRatio );
             }
 
@@ -162,32 +159,28 @@ Reference< drawing::XShape > VLegendSymbolFactory::createSymbol(
                 }
                 else if( aSymbol.Style == chart2::SymbolStyle_AUTO )
                 {
-                    OSL_TRACE("the given parameter is not allowed to contain an automatic symbol style");
+                    SAL_WARN("chart", "the given parameter is not allowed to contain an automatic symbol style");
                 }
             }
         }
         else if( eStyle == LegendSymbolStyle_CIRCLE )
         {
-            Reference< drawing::XShape > xShape( xShapeFactory->createInstance(
-                "com.sun.star.drawing.EllipseShape"), uno::UNO_QUERY );
+            sal_Int32 nSize = std::min( rEntryKeyAspectRatio.Width, rEntryKeyAspectRatio.Height );
+            Reference< drawing::XShape > xShape =
+                pShapeFactory->createCircle( xResultGroup, awt::Size( nSize, nSize ),
+                        awt::Point( rEntryKeyAspectRatio.Width/2-nSize/2, rEntryKeyAspectRatio.Height/2-nSize/2 ));
             if( xShape.is() )
             {
-                xResultGroup->add( xShape );
-                sal_Int32 nSize = std::min( rEntryKeyAspectRatio.Width, rEntryKeyAspectRatio.Height );
-                xShape->setSize( awt::Size( nSize, nSize ) );
-                xShape->setPosition( awt::Point( rEntryKeyAspectRatio.Width/2-nSize/2, rEntryKeyAspectRatio.Height/2-nSize/2 ) );
                 lcl_setPropetiesToShape( xLegendEntryProperties, xShape, ePropertyType ); // PROP_TYPE_FILLED_SERIES );
             }
         }
         else // eStyle == LegendSymbolStyle_BOX
         {
-            Reference< drawing::XShape > xShape( xShapeFactory->createInstance(
-                "com.sun.star.drawing.RectangleShape"), uno::UNO_QUERY );
+            Reference< drawing::XShape > xShape =
+                pShapeFactory->createRectangle( xResultGroup,
+                        rEntryKeyAspectRatio, awt::Point( 0, 0 ));
             if( xShape.is() )
             {
-                xResultGroup->add( xShape );
-                xShape->setSize( rEntryKeyAspectRatio );
-                xShape->setPosition( awt::Point( 0, 0 ) );
                 lcl_setPropetiesToShape( xLegendEntryProperties, xShape, ePropertyType ); // PROP_TYPE_FILLED_SERIES );
             }
         }
diff --git a/chart2/source/view/main/VTitle.cxx b/chart2/source/view/main/VTitle.cxx
index 81b1be5..c95ff24 100644
--- a/chart2/source/view/main/VTitle.cxx
+++ b/chart2/source/view/main/VTitle.cxx
@@ -177,6 +177,7 @@ void VTitle::createShapes(
         {
             ASSERT_EXCEPTION( e );
         }
+
         if(bStackCharacters)
         {
             //if the characters should be stacked we use only the first character properties for code simplicity
commit 5f62355a0707f1b988e66bc60d594522753efbcf
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sat Oct 5 22:43:47 2013 +0200

    some small fixes
    
    Change-Id: I9e18fc04e0e8d8be0bed0b9c7b80fd0e983893f1

diff --git a/chart2/source/view/diagram/VDiagram.cxx b/chart2/source/view/diagram/VDiagram.cxx
index 36b0d20..643146c 100644
--- a/chart2/source/view/diagram/VDiagram.cxx
+++ b/chart2/source/view/diagram/VDiagram.cxx
@@ -85,7 +85,6 @@ VDiagram::VDiagram(
 
 VDiagram::~VDiagram()
 {
-    delete m_pShapeFactory;
 }
 
 void VDiagram::init(
diff --git a/chart2/source/view/main/DummyShapeFactory.cxx b/chart2/source/view/main/DummyShapeFactory.cxx
index 19f9030..452de3a 100644
--- a/chart2/source/view/main/DummyShapeFactory.cxx
+++ b/chart2/source/view/main/DummyShapeFactory.cxx
@@ -86,6 +86,7 @@ uno::Reference<drawing::XShape>
           , const drawing::Position3D& , const drawing::Direction3D&
           , sal_Int32 )
 {
+    return new DummyXShape();
 }
 
 uno::Reference<drawing::XShape>
diff --git a/chart2/source/view/main/PlotterBase.cxx b/chart2/source/view/main/PlotterBase.cxx
index a81b041..94eee35 100644
--- a/chart2/source/view/main/PlotterBase.cxx
+++ b/chart2/source/view/main/PlotterBase.cxx
@@ -56,7 +56,6 @@ void PlotterBase::initPlotter(  const uno::Reference< drawing::XShapes >& xLogic
 
 PlotterBase::~PlotterBase()
 {
-    delete m_pShapeFactory;
 }
 
 void PlotterBase::setScales( const std::vector< ExplicitScaleData >& rScales, bool bSwapXAndYAxis )


More information about the Libreoffice-commits mailing list