From 0a5e2fc8e92ac2775e10530ae230db69556f5047 Mon Sep 17 00:00:00 2001 From: Ingrid Halama Date: Fri, 20 Nov 2009 11:58:22 +0100 Subject: chartpositioning: #i100778# chart positioning excluding labels --- .../controller/chartapiwrapper/DiagramWrapper.cxx | 118 +++++++++++++-------- 1 file changed, 76 insertions(+), 42 deletions(-) (limited to 'chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx') diff --git a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx index 4a02d9aa99e5..1b03108d0aa7 100644 --- a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx @@ -740,29 +740,7 @@ Reference< awt::Point SAL_CALL DiagramWrapper::getPosition() throw (uno::RuntimeException) { - awt::Point aPosition; - - Reference< beans::XPropertySet > xProp( this->getInnerPropertySet() ); - if( xProp.is() ) - { - bool bSet = false; - chart2::RelativePosition aRelativePosition; - uno::Any aAPosition( xProp->getPropertyValue( C2U( "RelativePosition" ) ) ); - if( aAPosition >>= aRelativePosition ) - { - awt::Size aPageSize( m_spChart2ModelContact->GetPageSize() ); - aPosition.X = static_cast(aRelativePosition.Primary*aPageSize.Width); - aPosition.Y = static_cast(aRelativePosition.Secondary*aPageSize.Height); - - aPosition = RelativePositionHelper::getUpperLeftCornerOfAnchoredObject( - aPosition, DiagramWrapper::getSize(), aRelativePosition.Anchor ); - - bSet = true; - } - if(!bSet) - aPosition = m_spChart2ModelContact->GetDiagramPositionInclusive(); - } - + awt::Point aPosition = m_spChart2ModelContact->GetDiagramPositionIncludingTitle(); return aPosition; } @@ -792,31 +770,14 @@ void SAL_CALL DiagramWrapper::setPosition( const awt::Point& aPosition ) aRelativePosition.Primary = double(aPosition.X)/double(aPageSize.Width); aRelativePosition.Secondary = double(aPosition.Y)/double(aPageSize.Height); xProp->setPropertyValue( C2U( "RelativePosition" ), uno::makeAny(aRelativePosition) ); + xProp->setPropertyValue( C2U( "PosSizeExcludeAxes" ), uno::makeAny(false) ); } } awt::Size SAL_CALL DiagramWrapper::getSize() throw (uno::RuntimeException) { - awt::Size aSize; - - Reference< beans::XPropertySet > xProp( this->getInnerPropertySet() ); - if( xProp.is() ) - { - bool bSet = false; - chart2::RelativeSize aRelativeSize; - uno::Any aASize( xProp->getPropertyValue( C2U( "RelativeSize" ) ) ); - if(aASize>>=aRelativeSize) - { - awt::Size aPageSize( m_spChart2ModelContact->GetPageSize() ); - aSize.Width = static_cast(aRelativeSize.Primary*aPageSize.Width); - aSize.Height = static_cast(aRelativeSize.Secondary*aPageSize.Height); - bSet = true; - } - if(!bSet) - aSize = m_spChart2ModelContact->GetDiagramSizeInclusive(); - } - + awt::Size aSize = m_spChart2ModelContact->GetDiagramSizeIncludingTitle(); return aSize; } @@ -847,6 +808,7 @@ void SAL_CALL DiagramWrapper::setSize( const awt::Size& aSize ) } xProp->setPropertyValue( C2U( "RelativeSize" ), uno::makeAny(aRelativeSize) ); + xProp->setPropertyValue( C2U( "PosSizeExcludeAxes" ), uno::makeAny(false) ); } } @@ -857,6 +819,78 @@ OUString SAL_CALL DiagramWrapper::getShapeType() return C2U( "com.sun.star.chart.Diagram" ); } +// ____ XDiagramPositioning ____ + +void SAL_CALL DiagramWrapper::setAutomaticDiagramPositioning() throw (uno::RuntimeException) +{ + uno::Reference< beans::XPropertySet > xDiaProps( this->getDiagram(), uno::UNO_QUERY ); + if( xDiaProps.is() ) + { + xDiaProps->setPropertyValue( C2U( "RelativeSize" ), Any() ); + xDiaProps->setPropertyValue( C2U( "RelativePosition" ), Any() ); + } +} +::sal_Bool SAL_CALL DiagramWrapper::isAutomaticDiagramPositioning( ) throw (uno::RuntimeException) +{ + uno::Reference< beans::XPropertySet > xDiaProps( this->getDiagram(), uno::UNO_QUERY ); + if( xDiaProps.is() ) + { + Any aRelativeSize( xDiaProps->getPropertyValue( C2U( "RelativeSize" ) ) ); + Any aRelativePosition( xDiaProps->getPropertyValue( C2U( "RelativePosition" ) ) ); + if( aRelativeSize.hasValue() && aRelativePosition.hasValue() ) + return false; + } + return true; +} +void SAL_CALL DiagramWrapper::setDiagramPositionExcludingAxes( const awt::Rectangle& rPositionRect ) throw (uno::RuntimeException) +{ + DiagramHelper::setDiagramPositioning( m_spChart2ModelContact->getChartModel(), rPositionRect ); + uno::Reference< beans::XPropertySet > xDiaProps( this->getDiagram(), uno::UNO_QUERY ); + if( xDiaProps.is() ) + xDiaProps->setPropertyValue(C2U("PosSizeExcludeAxes"), uno::makeAny(true) ); +} +::sal_Bool SAL_CALL DiagramWrapper::isExcludingDiagramPositioning() throw (uno::RuntimeException) +{ + uno::Reference< beans::XPropertySet > xDiaProps( this->getDiagram(), uno::UNO_QUERY ); + if( xDiaProps.is() ) + { + Any aRelativeSize( xDiaProps->getPropertyValue( C2U( "RelativeSize" ) ) ); + Any aRelativePosition( xDiaProps->getPropertyValue( C2U( "RelativePosition" ) ) ); + if( aRelativeSize.hasValue() && aRelativePosition.hasValue() ) + { + sal_Bool bPosSizeExcludeAxes = false; + xDiaProps->getPropertyValue( C2U( "PosSizeExcludeAxes" ) ) >>= bPosSizeExcludeAxes; + return bPosSizeExcludeAxes; + } + } + return false; +} +awt::Rectangle SAL_CALL DiagramWrapper::calculateDiagramPositionExcludingAxes( ) throw (uno::RuntimeException) +{ + return m_spChart2ModelContact->GetDiagramRectangleExcludingAxes(); +} +void SAL_CALL DiagramWrapper::setDiagramPositionIncludingAxes( const awt::Rectangle& rPositionRect ) throw (uno::RuntimeException) +{ + DiagramHelper::setDiagramPositioning( m_spChart2ModelContact->getChartModel(), rPositionRect ); + uno::Reference< beans::XPropertySet > xDiaProps( this->getDiagram(), uno::UNO_QUERY ); + if( xDiaProps.is() ) + xDiaProps->setPropertyValue(C2U("PosSizeExcludeAxes"), uno::makeAny(false) ); +} +awt::Rectangle SAL_CALL DiagramWrapper::calculateDiagramPositionIncludingAxes( ) throw (uno::RuntimeException) +{ + return m_spChart2ModelContact->GetDiagramRectangleIncludingAxes(); +} +void SAL_CALL DiagramWrapper::setDiagramPositionIncludingAxesAndAxesTitles( const awt::Rectangle& rPositionRect ) throw (uno::RuntimeException) +{ + setPosition( awt::Point(rPositionRect.X,rPositionRect.Y) ); + setSize( awt::Size(rPositionRect.Width,rPositionRect.Height) ); + +} +::com::sun::star::awt::Rectangle SAL_CALL DiagramWrapper::calculateDiagramPositionIncludingAxesAndAxesTitles( ) throw (::com::sun::star::uno::RuntimeException) +{ + return m_spChart2ModelContact->GetDiagramRectangleIncludingTitle(); +} + // ____ XAxisZSupplier ____ Reference< drawing::XShape > SAL_CALL DiagramWrapper::getZAxisTitle() -- cgit From 44f707ba8cb791df91bdb028e127cca107e3596b Mon Sep 17 00:00:00 2001 From: Ingrid Halama Date: Wed, 31 Mar 2010 18:43:41 +0200 Subject: chartpositioning: #i98398# treat diagram size without title sizes (correct ODF import/export, correct diagram sizing per mouse, correct API for import) --- .../controller/chartapiwrapper/DiagramWrapper.cxx | 38 ++++++++-------------- 1 file changed, 14 insertions(+), 24 deletions(-) (limited to 'chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx') diff --git a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx index 51a72b4eb637..dc0fa30926e3 100644 --- a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx @@ -59,6 +59,7 @@ #include "DisposeHelper.hxx" #include #include "WrappedAutomaticPositionProperties.hxx" +#include "CommonConverters.hxx" #include #include @@ -737,7 +738,7 @@ Reference< awt::Point SAL_CALL DiagramWrapper::getPosition() throw (uno::RuntimeException) { - awt::Point aPosition = m_spChart2ModelContact->GetDiagramPositionIncludingTitle(); + awt::Point aPosition = ToPoint( m_spChart2ModelContact->GetDiagramRectangleIncludingAxes() ); return aPosition; } @@ -747,17 +748,12 @@ void SAL_CALL DiagramWrapper::setPosition( const awt::Point& aPosition ) Reference< beans::XPropertySet > xProp( this->getInnerPropertySet() ); if( xProp.is() ) { - if( aPosition.X < 0 || aPosition.Y < 0 ) + if( aPosition.X < 0 || aPosition.Y < 0 || aPosition.X > 1 || aPosition.Y > 1 ) { - if( !TitleHelper::getTitle( TitleHelper::X_AXIS_TITLE, m_spChart2ModelContact->getChartModel() ).is() && - !TitleHelper::getTitle( TitleHelper::Y_AXIS_TITLE, m_spChart2ModelContact->getChartModel() ).is() ) - { - DBG_ERROR("DiagramWrapper::setPosition called with negative position -> automatic values are taken instead" ); - uno::Any aEmpty; - xProp->setPropertyValue( C2U( "RelativePosition" ), aEmpty ); - return; - } - //else: The saved didagram size does include the axis title sizes thus the position and size could be negative + DBG_ERROR("DiagramWrapper::setPosition called with a position out of range -> automatic values are taken instead" ); + uno::Any aEmpty; + xProp->setPropertyValue( C2U( "RelativePosition" ), aEmpty ); + return; } awt::Size aPageSize( m_spChart2ModelContact->GetPageSize() ); @@ -774,7 +770,7 @@ void SAL_CALL DiagramWrapper::setPosition( const awt::Point& aPosition ) awt::Size SAL_CALL DiagramWrapper::getSize() throw (uno::RuntimeException) { - awt::Size aSize = m_spChart2ModelContact->GetDiagramSizeIncludingTitle(); + awt::Size aSize = ToSize( m_spChart2ModelContact->GetDiagramRectangleIncludingAxes() ); return aSize; } @@ -793,15 +789,10 @@ void SAL_CALL DiagramWrapper::setSize( const awt::Size& aSize ) if( aRelativeSize.Primary > 1 || aRelativeSize.Secondary > 1 ) { - if( !TitleHelper::getTitle( TitleHelper::X_AXIS_TITLE, m_spChart2ModelContact->getChartModel() ).is() && - !TitleHelper::getTitle( TitleHelper::Y_AXIS_TITLE, m_spChart2ModelContact->getChartModel() ).is() ) - { - DBG_ERROR("DiagramWrapper::setSize called with sizes bigger than page -> automatic values are taken instead" ); - uno::Any aEmpty; - xProp->setPropertyValue( C2U( "RelativeSize" ), aEmpty ); - return; - } - //else: The saved didagram size does include the axis title sizes thus the position and size could be out of range + DBG_ERROR("DiagramWrapper::setSize called with sizes bigger than page -> automatic values are taken instead" ); + uno::Any aEmpty; + xProp->setPropertyValue( C2U( "RelativeSize" ), aEmpty ); + return; } xProp->setPropertyValue( C2U( "RelativeSize" ), uno::makeAny(aRelativeSize) ); @@ -879,9 +870,8 @@ awt::Rectangle SAL_CALL DiagramWrapper::calculateDiagramPositionIncludingAxes( } void SAL_CALL DiagramWrapper::setDiagramPositionIncludingAxesAndAxesTitles( const awt::Rectangle& rPositionRect ) throw (uno::RuntimeException) { - setPosition( awt::Point(rPositionRect.X,rPositionRect.Y) ); - setSize( awt::Size(rPositionRect.Width,rPositionRect.Height) ); - + awt::Rectangle aRect( m_spChart2ModelContact->SubstractAxisTitleSizes(rPositionRect) ); + DiagramWrapper::setDiagramPositionIncludingAxes( aRect ); } ::com::sun::star::awt::Rectangle SAL_CALL DiagramWrapper::calculateDiagramPositionIncludingAxesAndAxesTitles( ) throw (::com::sun::star::uno::RuntimeException) { -- cgit From 1f083939cf4c353a0897d2fd275aa567f00a9ecc Mon Sep 17 00:00:00 2001 From: Ingrid Halama Date: Wed, 31 Mar 2010 20:07:14 +0200 Subject: chartpositioning: #i100778# fixed typo --- chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx') diff --git a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx index dc0fa30926e3..61b258e2eb22 100644 --- a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx @@ -868,12 +868,12 @@ awt::Rectangle SAL_CALL DiagramWrapper::calculateDiagramPositionIncludingAxes( { return m_spChart2ModelContact->GetDiagramRectangleIncludingAxes(); } -void SAL_CALL DiagramWrapper::setDiagramPositionIncludingAxesAndAxesTitles( const awt::Rectangle& rPositionRect ) throw (uno::RuntimeException) +void SAL_CALL DiagramWrapper::setDiagramPositionIncludingAxesAndAxisTitles( const awt::Rectangle& rPositionRect ) throw (uno::RuntimeException) { awt::Rectangle aRect( m_spChart2ModelContact->SubstractAxisTitleSizes(rPositionRect) ); DiagramWrapper::setDiagramPositionIncludingAxes( aRect ); } -::com::sun::star::awt::Rectangle SAL_CALL DiagramWrapper::calculateDiagramPositionIncludingAxesAndAxesTitles( ) throw (::com::sun::star::uno::RuntimeException) +::com::sun::star::awt::Rectangle SAL_CALL DiagramWrapper::calculateDiagramPositionIncludingAxesAndAxisTitles( ) throw (::com::sun::star::uno::RuntimeException) { return m_spChart2ModelContact->GetDiagramRectangleIncludingTitle(); } -- cgit From 0581e072a69d06abd1bdcc8b5cc14771b110e6f9 Mon Sep 17 00:00:00 2001 From: Ingrid Halama Date: Wed, 5 May 2010 18:16:33 +0200 Subject: chartpositioning: #i100778# simplify user interface: reduce sizing options to new excluding mode only --- chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx') diff --git a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx index 61b258e2eb22..e05279b15aae 100644 --- a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx @@ -745,6 +745,7 @@ awt::Point SAL_CALL DiagramWrapper::getPosition() void SAL_CALL DiagramWrapper::setPosition( const awt::Point& aPosition ) throw (uno::RuntimeException) { + ControllerLockGuard aCtrlLockGuard( m_spChart2ModelContact->getChartModel() ); Reference< beans::XPropertySet > xProp( this->getInnerPropertySet() ); if( xProp.is() ) { @@ -778,6 +779,7 @@ void SAL_CALL DiagramWrapper::setSize( const awt::Size& aSize ) throw (beans::PropertyVetoException, uno::RuntimeException) { + ControllerLockGuard aCtrlLockGuard( m_spChart2ModelContact->getChartModel() ); Reference< beans::XPropertySet > xProp( this->getInnerPropertySet() ); if( xProp.is() ) { @@ -811,6 +813,7 @@ OUString SAL_CALL DiagramWrapper::getShapeType() void SAL_CALL DiagramWrapper::setAutomaticDiagramPositioning() throw (uno::RuntimeException) { + ControllerLockGuard aCtrlLockGuard( m_spChart2ModelContact->getChartModel() ); uno::Reference< beans::XPropertySet > xDiaProps( this->getDiagram(), uno::UNO_QUERY ); if( xDiaProps.is() ) { @@ -832,6 +835,7 @@ void SAL_CALL DiagramWrapper::setAutomaticDiagramPositioning() throw (uno::Runti } void SAL_CALL DiagramWrapper::setDiagramPositionExcludingAxes( const awt::Rectangle& rPositionRect ) throw (uno::RuntimeException) { + ControllerLockGuard aCtrlLockGuard( m_spChart2ModelContact->getChartModel() ); DiagramHelper::setDiagramPositioning( m_spChart2ModelContact->getChartModel(), rPositionRect ); uno::Reference< beans::XPropertySet > xDiaProps( this->getDiagram(), uno::UNO_QUERY ); if( xDiaProps.is() ) @@ -859,6 +863,7 @@ awt::Rectangle SAL_CALL DiagramWrapper::calculateDiagramPositionExcludingAxes( } void SAL_CALL DiagramWrapper::setDiagramPositionIncludingAxes( const awt::Rectangle& rPositionRect ) throw (uno::RuntimeException) { + ControllerLockGuard aCtrlLockGuard( m_spChart2ModelContact->getChartModel() ); DiagramHelper::setDiagramPositioning( m_spChart2ModelContact->getChartModel(), rPositionRect ); uno::Reference< beans::XPropertySet > xDiaProps( this->getDiagram(), uno::UNO_QUERY ); if( xDiaProps.is() ) @@ -870,6 +875,7 @@ awt::Rectangle SAL_CALL DiagramWrapper::calculateDiagramPositionIncludingAxes( } void SAL_CALL DiagramWrapper::setDiagramPositionIncludingAxesAndAxisTitles( const awt::Rectangle& rPositionRect ) throw (uno::RuntimeException) { + ControllerLockGuard aCtrlLockGuard( m_spChart2ModelContact->getChartModel() ); awt::Rectangle aRect( m_spChart2ModelContact->SubstractAxisTitleSizes(rPositionRect) ); DiagramWrapper::setDiagramPositionIncludingAxes( aRect ); } -- cgit