summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2013-10-06 07:43:07 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2013-11-19 13:47:34 +0100
commitdde6b8047384ffad5bcf8dad24aa5fb814217334 (patch)
treeab32211278b490ca57722fac4b3728907a280f70 /chart2
parent1a3d09935d30e7ae356dd87b72cdfa6e7c684ff0 (diff)
more use of ShapeFactory and set Properties in factory if possible
Change-Id: I7d172fd7bde506233fc74ec07b9603ee29149e5c
Diffstat (limited to 'chart2')
-rw-r--r--chart2/source/view/inc/AbstractShapeFactory.hxx4
-rw-r--r--chart2/source/view/inc/DummyShapeFactory.hxx4
-rw-r--r--chart2/source/view/inc/ShapeFactory.hxx4
-rw-r--r--chart2/source/view/main/ChartView.cxx48
-rw-r--r--chart2/source/view/main/DummyShapeFactory.cxx4
-rw-r--r--chart2/source/view/main/ShapeFactory.cxx6
-rw-r--r--chart2/source/view/main/VLegend.cxx17
-rw-r--r--chart2/source/view/main/VLegendSymbolFactory.cxx101
8 files changed, 95 insertions, 93 deletions
diff --git a/chart2/source/view/inc/AbstractShapeFactory.hxx b/chart2/source/view/inc/AbstractShapeFactory.hxx
index 6b97276a03d4..fc25226ddf9a 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 d77433343ff1..fab81324f50d 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 b8aac7a42a75..d73367f1a071 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 c9198beda0cf..ae309b4f7cb8 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 1972297e19b9..187e8fe69bc8 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 3353f3c48e33..69cc0c1ce51d 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 f13724dc9913..60872ec74118 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 cd8dcc9eea78..465b6907666f 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 )