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 --- .../chartapiwrapper/Chart2ModelContact.cxx | 45 +- .../chartapiwrapper/Chart2ModelContact.hxx | 24 +- .../controller/chartapiwrapper/DiagramWrapper.cxx | 118 +-- .../controller/chartapiwrapper/DiagramWrapper.hxx | 18 +- chart2/source/controller/dialogs/ResourceIds.hrc | 1 + chart2/source/controller/dialogs/Strings.src | 5 + chart2/source/controller/dialogs/TabPages.hrc | 1 - .../controller/dialogs/dlg_ObjectProperties.cxx | 10 +- chart2/source/controller/dialogs/makefile.mk | 2 + .../controller/dialogs/tp_DiagramPosition.cxx | 788 +++++++++++++++++++++ .../controller/dialogs/tp_DiagramPosition.hrc | 51 ++ .../controller/dialogs/tp_DiagramPosition.hxx | 140 ++++ .../controller/dialogs/tp_DiagramPosition.src | 217 ++++++ .../controller/drawinglayer/DrawViewWrapper.cxx | 9 + .../source/controller/inc/DiagramItemConverter.hxx | 81 +++ .../itemsetwrapper/DiagramItemConverter.cxx | 226 ++++++ .../controller/itemsetwrapper/SchWhichPairs.hxx | 29 +- .../source/controller/itemsetwrapper/makefile.mk | 3 +- .../controller/main/ChartController_Position.cxx | 21 +- .../controller/main/ChartController_Properties.cxx | 4 + .../controller/main/ChartController_Tools.cxx | 1 + .../controller/main/PositionAndSizeHelper.cxx | 7 +- chart2/source/inc/DiagramHelper.hxx | 17 + chart2/source/inc/ObjectIdentifier.hxx | 2 +- chart2/source/inc/Strings.hrc | 2 +- chart2/source/inc/chartview/ChartSfxItemIds.hxx | 11 +- .../source/inc/chartview/ExplicitValueProvider.hxx | 6 +- chart2/source/model/main/Diagram.cxx | 9 + chart2/source/tools/DiagramHelper.cxx | 160 +++++ chart2/source/view/charttypes/PieChart.cxx | 14 +- chart2/source/view/charttypes/PieChart.hxx | 4 +- chart2/source/view/charttypes/VSeriesPlotter.cxx | 12 +- chart2/source/view/diagram/VDiagram.cxx | 8 +- chart2/source/view/inc/VSeriesPlotter.hxx | 4 +- chart2/source/view/main/ChartItemPool.cxx | 8 + chart2/source/view/main/ChartView.cxx | 173 ++++- chart2/source/view/main/ChartView.hxx | 10 +- 37 files changed, 2095 insertions(+), 146 deletions(-) create mode 100644 chart2/source/controller/dialogs/tp_DiagramPosition.cxx create mode 100644 chart2/source/controller/dialogs/tp_DiagramPosition.hrc create mode 100644 chart2/source/controller/dialogs/tp_DiagramPosition.hxx create mode 100644 chart2/source/controller/dialogs/tp_DiagramPosition.src create mode 100644 chart2/source/controller/inc/DiagramItemConverter.hxx create mode 100644 chart2/source/controller/itemsetwrapper/DiagramItemConverter.cxx (limited to 'chart2') diff --git a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx index 3d930f72f0af..aaebdb663120 100644 --- a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx +++ b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx @@ -41,6 +41,7 @@ #include "chartview/ExplicitValueProvider.hxx" #include "chartview/DrawModelWrapper.hxx" #include "AxisHelper.hxx" +#include "DiagramHelper.hxx" using namespace ::com::sun::star; using namespace ::com::sun::star::chart2; @@ -195,30 +196,50 @@ awt::Size Chart2ModelContact::GetPageSize() const return ChartModelHelper::getPageSize(m_xChartModel); } -awt::Rectangle Chart2ModelContact::GetDiagramRectangleInclusive() const +awt::Rectangle Chart2ModelContact::GetDiagramRectangleIncludingTitle() const { - awt::Rectangle aRect; + awt::Rectangle aRect( GetDiagramRectangleIncludingAxes() ); - ExplicitValueProvider* pProvider( getExplicitValueProvider() ); - if( pProvider ) - { - aRect = pProvider->getRectangleOfObject( lcl_getCIDForDiagram( m_xChartModel ) ); - } //add axis title sizes to the diagram size - aRect = ExplicitValueProvider::calculateDiagramPositionAndSizeInclusiveTitle( + aRect = ExplicitValueProvider::calculateDiagramPositionAndSizeIncludingTitle( m_xChartModel, m_xChartView, aRect ); return aRect; } -awt::Size Chart2ModelContact::GetDiagramSizeInclusive() const +awt::Rectangle Chart2ModelContact::GetDiagramRectangleIncludingAxes() const +{ + awt::Rectangle aRect(0,0,0,0); + uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( m_xChartModel ) ); + + if( DiagramPositioningMode_INCLUDING == DiagramHelper::getDiagramPositioningMode( xDiagram ) ) + aRect = DiagramHelper::getDiagramRectangleFromModel(m_xChartModel); + else + { + ExplicitValueProvider* pProvider( getExplicitValueProvider() ); + if( pProvider ) + aRect = pProvider->getRectangleOfObject( C2U("PlotAreaIncludingAxes") ); + } + return aRect; +} + +awt::Rectangle Chart2ModelContact::GetDiagramRectangleExcludingAxes() const +{ + awt::Rectangle aRect; + ExplicitValueProvider* pProvider( getExplicitValueProvider() ); + if( pProvider ) + aRect = pProvider->getDiagramRectangleExcludingAxes(); + return aRect; +} + +awt::Size Chart2ModelContact::GetDiagramSizeIncludingTitle() const { - return ToSize( this->GetDiagramRectangleInclusive() ); + return ToSize( this->GetDiagramRectangleIncludingTitle() ); } -awt::Point Chart2ModelContact::GetDiagramPositionInclusive() const +awt::Point Chart2ModelContact::GetDiagramPositionIncludingTitle() const { - return ToPoint( this->GetDiagramRectangleInclusive() ); + return ToPoint( this->GetDiagramRectangleIncludingTitle() ); } awt::Size Chart2ModelContact::GetLegendSize() const diff --git a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx index 0cc8a16bafff..10a02a724e90 100644 --- a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx +++ b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx @@ -96,15 +96,30 @@ public: */ ::com::sun::star::awt::Size GetPageSize() const; - /** Returns the size of the diagram object in logic coordinates inclusive + /** Returns the size of the diagram object in logic coordinates including the space reserved for axis titles. */ - ::com::sun::star::awt::Size GetDiagramSizeInclusive() const; + ::com::sun::star::awt::Size GetDiagramSizeIncludingTitle() const; - /** Returns the position of the diagram in logic coordinates inclusive + /** Returns the position of the diagram in logic coordinates including the space reserved for axis titles. */ - ::com::sun::star::awt::Point GetDiagramPositionInclusive() const; + ::com::sun::star::awt::Point GetDiagramPositionIncludingTitle() const; + + /** Returns the position and size of the diagram in logic coordinates (100th mm) including + the space used for axes including axes titles. + */ + ::com::sun::star::awt::Rectangle GetDiagramRectangleIncludingTitle() const; + + /** Returns the position and size of the diagram in logic coordinates (100th mm) including + the space used for axes excluding axes titles. + */ + ::com::sun::star::awt::Rectangle GetDiagramRectangleIncludingAxes() const; + + /** Returns the position and size of the diagram in logic coordinates (100th mm) excluding + the space used for axes (inner plot area). + */ + ::com::sun::star::awt::Rectangle GetDiagramRectangleExcludingAxes() const; /** Returns the size of the object in logic coordinates. */ @@ -137,7 +152,6 @@ public: private: //methods ExplicitValueProvider* getExplicitValueProvider() const; - ::com::sun::star::awt::Rectangle GetDiagramRectangleInclusive() const; public: //member ::com::sun::star::uno::Reference< 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() diff --git a/chart2/source/controller/chartapiwrapper/DiagramWrapper.hxx b/chart2/source/controller/chartapiwrapper/DiagramWrapper.hxx index b69a856a557f..1594f30ae631 100644 --- a/chart2/source/controller/chartapiwrapper/DiagramWrapper.hxx +++ b/chart2/source/controller/chartapiwrapper/DiagramWrapper.hxx @@ -33,12 +33,13 @@ #include "WrappedPropertySet.hxx" #include "ServiceMacros.hxx" #include "DiagramHelper.hxx" -#include +#include #include #include #include #include #include +#include #include #include #include @@ -64,7 +65,7 @@ namespace wrapper class Chart2ModelContact; -class DiagramWrapper : public ::cppu::ImplInheritanceHelper11< +class DiagramWrapper : public ::cppu::ImplInheritanceHelper12< WrappedPropertySet , ::com::sun::star::chart::XDiagram , ::com::sun::star::chart::XAxisZSupplier @@ -76,6 +77,7 @@ class DiagramWrapper : public ::cppu::ImplInheritanceHelper11< , ::com::sun::star::lang::XServiceInfo , ::com::sun::star::lang::XComponent // , ::com::sun::star::lang::XEventListener + , ::com::sun::star::chart::XDiagramPositioning , ::com::sun::star::chart2::XDiagramProvider , ::com::sun::star::chart::XSecondAxisTitleSupplier > @@ -212,6 +214,18 @@ public: // virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) // throw (::com::sun::star::uno::RuntimeException); + // ____ XDiagramPositioning ____ + + virtual void SAL_CALL setAutomaticDiagramPositioning( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL isAutomaticDiagramPositioning( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setDiagramPositionExcludingAxes( const ::com::sun::star::awt::Rectangle& PositionRect ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL isExcludingDiagramPositioning( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::awt::Rectangle SAL_CALL calculateDiagramPositionExcludingAxes( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setDiagramPositionIncludingAxes( const ::com::sun::star::awt::Rectangle& PositionRect ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::awt::Rectangle SAL_CALL calculateDiagramPositionIncludingAxes( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setDiagramPositionIncludingAxesAndAxesTitles( const ::com::sun::star::awt::Rectangle& PositionRect ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::awt::Rectangle SAL_CALL calculateDiagramPositionIncludingAxesAndAxesTitles( ) throw (::com::sun::star::uno::RuntimeException); + // ____ XDiagramProvider ____ virtual ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram > SAL_CALL getDiagram() diff --git a/chart2/source/controller/dialogs/ResourceIds.hrc b/chart2/source/controller/dialogs/ResourceIds.hrc index 8674aba240da..fbb92e4b9c15 100644 --- a/chart2/source/controller/dialogs/ResourceIds.hrc +++ b/chart2/source/controller/dialogs/ResourceIds.hrc @@ -64,6 +64,7 @@ #define TP_AXIS_LABEL 920 #define TP_SCALE 903 #define TP_AXIS_POSITIONS 904 +#define TP_DIAGRAM_POSITION 905 #define TP_CHARTTYPE 910 #define TP_RANGECHOOSER 911 #define TP_WIZARD_TITLEANDOBJECTS 912 diff --git a/chart2/source/controller/dialogs/Strings.src b/chart2/source/controller/dialogs/Strings.src index b7ef643e3ff3..ad512f8fad77 100644 --- a/chart2/source/controller/dialogs/Strings.src +++ b/chart2/source/controller/dialogs/Strings.src @@ -124,6 +124,11 @@ String STR_PAGE_POSITIONING Text [ en-US ] = "Positioning" ; }; +String STR_PAGE_POSITIONANDSIZE +{ + Text [ en-US ] = "Position and Size" ; +}; + // String STR_PAGE_STATISTICS // { // Text [ en-US ] = "Statistics" ; diff --git a/chart2/source/controller/dialogs/TabPages.hrc b/chart2/source/controller/dialogs/TabPages.hrc index 8c92c062ad14..4dcf588758d6 100644 --- a/chart2/source/controller/dialogs/TabPages.hrc +++ b/chart2/source/controller/dialogs/TabPages.hrc @@ -49,7 +49,6 @@ ////#define RBT_DOWNUP 3 ////#define RBT_AUTOORDER 4 -//#define TP_STAT 905 #define FL_TEXTBREAK 3 #define CBX_TEXTBREAK 2 #define CBX_TEXTOVERLAP 4 diff --git a/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx b/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx index 097c6c1d0107..66083180d19e 100644 --- a/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx +++ b/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx @@ -52,6 +52,7 @@ #include "tp_SeriesToAxis.hxx" #include "tp_TitleRotation.hxx" #include "tp_PolarOptions.hxx" +#include "tp_DiagramPosition.hxx" #include "ResId.hxx" #include "ViewElementListProvider.hxx" #include "macros.hxx" @@ -249,6 +250,9 @@ void ObjectPropertiesDialogParameter::init( const uno::Reference< frame::XModel else m_aLocalizedName = ObjectNameProvider::getName_ObjectForSeries( m_eObjectType, m_aObjectCID, m_xChartDocument ); break; + case OBJECTTYPE_DIAGRAM: + m_aLocalizedName = String(SchResId(STR_PAGE_POSITIONANDSIZE)); + break; default: m_aLocalizedName = ObjectNameProvider::getName(m_eObjectType,m_bAffectsMultipleObjects); break; @@ -462,12 +466,14 @@ SchAttribTabDlg::SchAttribTabDlg(Window* pParent, AddTabPage(RID_SVXPAGE_LINE, String(SchResId(STR_PAGE_LINE))); break; + case OBJECTTYPE_DIAGRAM: + AddTabPage(TP_DIAGRAM_POSITION, String(SchResId(STR_PAGE_POSITIONANDSIZE)), DiagramPositionTabPage::Create, NULL); + break; + case OBJECTTYPE_DIAGRAM_WALL: case OBJECTTYPE_DATA_STOCK_LOSS: case OBJECTTYPE_DATA_STOCK_GAIN: case OBJECTTYPE_PAGE: case OBJECTTYPE_DIAGRAM_FLOOR: - case OBJECTTYPE_DIAGRAM_WALL: - case OBJECTTYPE_DIAGRAM: AddTabPage(RID_SVXPAGE_LINE, String(SchResId(STR_PAGE_BORDER))); AddTabPage(RID_SVXPAGE_AREA, String(SchResId(STR_PAGE_AREA))); AddTabPage(RID_SVXPAGE_TRANSPARENCE, String(SchResId(STR_PAGE_TRANSPARENCY))); diff --git a/chart2/source/controller/dialogs/makefile.mk b/chart2/source/controller/dialogs/makefile.mk index 6b64f2cae8db..65dd6aa2545c 100644 --- a/chart2/source/controller/dialogs/makefile.mk +++ b/chart2/source/controller/dialogs/makefile.mk @@ -71,6 +71,7 @@ SLOFILES= \ $(SLO)$/tp_RangeChooser.obj \ $(SLO)$/tp_Wizard_TitlesAndObjects.obj \ $(SLO)$/tp_Location.obj \ + $(SLO)$/tp_DiagramPosition.obj \ $(SLO)$/tp_AxisLabel.obj \ $(SLO)$/tp_AxisPositions.obj \ $(SLO)$/tp_DataLabel.obj \ @@ -121,6 +122,7 @@ SRC1FILES= \ tp_RangeChooser.src \ tp_Wizard_TitlesAndObjects.src \ tp_Location.src \ + tp_DiagramPosition.src \ tp_AxisLabel.src \ tp_AxisPositions.src \ tp_DataLabel.src \ diff --git a/chart2/source/controller/dialogs/tp_DiagramPosition.cxx b/chart2/source/controller/dialogs/tp_DiagramPosition.cxx new file mode 100644 index 000000000000..ff9b6e23cfd7 --- /dev/null +++ b/chart2/source/controller/dialogs/tp_DiagramPosition.cxx @@ -0,0 +1,788 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_DiagramPosition.cxx,v $ + * $Revision: 1.13 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" +#include "tp_DiagramPosition.hxx" +#include "tp_DiagramPosition.hrc" + +#include "DiagramHelper.hxx" +#include "ResId.hxx" +#include "chartview/ChartSfxItemIds.hxx" + +#include +#include +//GetModuleFieldUnit +#include +#include +#include +// header for class SvxDoubleItem +#include + +using namespace ::com::sun::star; + +//............................................................................. +namespace chart +{ +//............................................................................. + +void lcl_ConvertRect(basegfx::B2DRange& rRange, const sal_uInt16 nDigits, const MapUnit ePoolUnit, const FieldUnit eDlgUnit) +{ + const basegfx::B2DPoint aTopLeft( + (double)MetricField::ConvertValue(basegfx::fround(rRange.getMinX()), nDigits, ePoolUnit, eDlgUnit), + (double)MetricField::ConvertValue(basegfx::fround(rRange.getMinY()), nDigits, ePoolUnit, eDlgUnit)); + const basegfx::B2DPoint aBottomRight( + (double)MetricField::ConvertValue(basegfx::fround(rRange.getMaxX()), nDigits, ePoolUnit, eDlgUnit), + (double)MetricField::ConvertValue(basegfx::fround(rRange.getMaxY()), nDigits, ePoolUnit, eDlgUnit)); + + rRange = basegfx::B2DRange(aTopLeft, aBottomRight); +} + +void lcl_ScaleRect(basegfx::B2DRange& rRange, const Fraction aUIScale) +{ + const double fFactor(1.0 / double(aUIScale)); + rRange = basegfx::B2DRange(rRange.getMinimum() * fFactor, rRange.getMaximum() * fFactor); +} + +DiagramPositionTabPage::DiagramPositionTabPage( Window* pParent, const SfxItemSet& rInAttrs ) : + SvxTabPage ( pParent, SchResId( TP_DIAGRAM_POSITION ), rInAttrs ), + + m_aFlPosMode( this, SchResId( FL_POSITIONING_MODE ) ), + + m_aRbPosMode_Auto( this, SchResId( RB_POSITIONING_MODE_AUTOMATIC ) ), + m_aRbPosMode_Including( this, SchResId( RB_POSITIONING_MODE_INCLUDING ) ), + m_aRbPosMode_Excluding( this, SchResId( RB_POSITIONING_MODE_EXCLUDING ) ), + + maFlPosition ( this, SchResId( FL_POSITION ) ), + maFtPosX ( this, SchResId( FT_POS_X ) ), + maMtrPosX ( this, SchResId( MTR_FLD_POS_X ) ), + maFtPosY ( this, SchResId( FT_POS_Y ) ), + maMtrPosY ( this, SchResId( MTR_FLD_POS_Y ) ), + maFtPosReference ( this, SchResId( FT_POSREFERENCE ) ), + maCtlPos ( this, SchResId( CTL_POSRECT ), RP_LT ), + + maFlSize ( this, SchResId( FL_SIZE ) ), + maFtWidth ( this, SchResId( FT_WIDTH ) ), + maMtrWidth ( this, SchResId( MTR_FLD_WIDTH ) ), + maFtHeight ( this, SchResId( FT_HEIGHT ) ), + maMtrHeight ( this, SchResId( MTR_FLD_HEIGHT ) ), + maCbxScale ( this, SchResId( CBX_SCALE ) ), + maFtSizeReference ( this, SchResId( FT_SIZEREFERENCE) ), + maCtlSize ( this, SchResId( CTL_SIZERECT ), RP_LT ), + m_aExcludingRect(1,2,3,4), + m_aIncludingRect(1,2,3,4), + m_aMaxRect(1,2,3,4), + m_fUIScale( 1.0 ), + m_aCurrentRect(1,2,3,4), + m_bRectChangedByUser( false ) +{ + FreeResource(); + + // this pege needs ExchangeSupport + // SetExchangeSupport(); + + // evaluate PoolUnit + SfxItemPool* pPool = rInAttrs.GetPool(); + DBG_ASSERT( pPool, "no pool (!)" ); + mePoolUnit = pPool->GetMetric( SID_ATTR_TRANSFORM_POS_X ); + + Construct(); + + m_aRbPosMode_Auto.SetClickHdl( LINK( this, DiagramPositionTabPage, ChangeModeHdl ) ); + m_aRbPosMode_Including.SetClickHdl( LINK( this, DiagramPositionTabPage, ChangeModeHdl ) ); + m_aRbPosMode_Excluding.SetClickHdl( LINK( this, DiagramPositionTabPage, ChangeModeHdl ) ); + + maMtrPosX.SetModifyHdl( LINK( this, DiagramPositionTabPage, ChangePosXHdl ) ); + maMtrPosY.SetModifyHdl( LINK( this, DiagramPositionTabPage, ChangePosYHdl ) ); + + maMtrWidth.SetModifyHdl( LINK( this, DiagramPositionTabPage, ChangeWidthHdl ) ); + maMtrHeight.SetModifyHdl( LINK( this, DiagramPositionTabPage, ChangeHeightHdl ) ); + maCbxScale.SetClickHdl( LINK( this, DiagramPositionTabPage, ClickScaleHdl ) ); +} + +// ----------------------------------------------------------------------- + +void DiagramPositionTabPage::Construct() +{ + // get range and work area + meDlgUnit = GetModuleFieldUnit( &GetItemSet() ); + SetFieldUnit( maMtrPosX, meDlgUnit, TRUE ); + SetFieldUnit( maMtrPosY, meDlgUnit, TRUE ); + SetFieldUnit( maMtrWidth, meDlgUnit, TRUE ); + SetFieldUnit( maMtrHeight, meDlgUnit, TRUE ); + + if(FUNIT_MILE == meDlgUnit || FUNIT_KM == meDlgUnit) + { + maMtrPosX.SetDecimalDigits( 3 ); + maMtrPosY.SetDecimalDigits( 3 ); + maMtrWidth.SetDecimalDigits( 3 ); + maMtrHeight.SetDecimalDigits( 3 ); + } +} + +// ----------------------------------------------------------------------- + +void DiagramPositionTabPage::Reset( const SfxItemSet& rInAttrs ) +{ + //positioning mode + DiagramPositioningMode ePos = DiagramPositioningMode_AUTO; + const SfxPoolItem* pItem = NULL; + if( rInAttrs.GetItemState( SCHATTR_DIAGRAM_POS_MODE, TRUE, &pItem ) == SFX_ITEM_SET ) + ePos = DiagramPositioningMode(((const SfxInt32Item*)pItem)->GetValue()); + if( ePos == DiagramPositioningMode_AUTO ) + m_aRbPosMode_Auto.Check(); + else if( ePos == DiagramPositioningMode_INCLUDING ) + m_aRbPosMode_Including.Check(); + else if( ePos == DiagramPositioningMode_EXCLUDING ) + m_aRbPosMode_Excluding.Check(); + + ReleaseBorders(); + maCtlPos.Reset(); + maCtlSize.Reset(); + + //rectangles + if( rInAttrs.GetItemState( SCHATTR_DIAGRAM_RECT_MAX, TRUE, &pItem ) == SFX_ITEM_SET ) + { + m_aMaxRect = ((const SfxRectangleItem*)pItem)->GetValue(); + SetRectIn100thmm( m_aMaxRect ); + m_aMaxRect = GetRectIn100thmm(); + } + + if( rInAttrs.GetItemState( SCHATTR_DIAGRAM_RECT_EXCLUDING, TRUE, &pItem ) == SFX_ITEM_SET ) + { + m_aExcludingRect = ((const SfxRectangleItem*)pItem)->GetValue(); + SetRectIn100thmm( m_aExcludingRect ); + m_aExcludingRect = GetRectIn100thmm(); + } + + if( rInAttrs.GetItemState( SCHATTR_DIAGRAM_RECT_INCLUDING, TRUE, &pItem ) == SFX_ITEM_SET ) + { + m_aIncludingRect = ((const SfxRectangleItem*)pItem)->GetValue(); + SetRectIn100thmm( m_aIncludingRect ); + m_aIncludingRect = GetRectIn100thmm(); + } + + if( rInAttrs.GetItemState( SCHATTR_DIAGRAM_UI_SCALE, TRUE, &pItem ) == SFX_ITEM_SET ) + m_fUIScale = ((const SvxDoubleItem*)pItem)->GetValue(); + + m_aCurrentRect = m_aIncludingRect; + if( rInAttrs.GetItemState( SCHATTR_DIAGRAM_RECT_TO_USE, TRUE, &pItem ) == SFX_ITEM_SET ) + { + m_aCurrentRect = ((const SfxRectangleItem*)pItem)->GetValue(); + SetRectIn100thmm( m_aCurrentRect ); + m_aCurrentRect = GetRectIn100thmm(); + } + + // scale + String aStr = GetUserData(); + maCbxScale.Check( (BOOL)aStr.ToInt32() ); + mfScaleSizeX = std::max( (double)GetCoreValue( maMtrWidth, mePoolUnit ), 1.0 ); + mfScaleSizeY = std::max( (double)GetCoreValue( maMtrHeight, mePoolUnit ), 1.0 ); + + + m_bRectChangedByUser = false; + SetMinMaxPosition(); + UpdateControlStates(); +} + +// ----------------------------------------------------------------------- + +BOOL DiagramPositionTabPage::FillItemSet( SfxItemSet& rOutAttrs ) +{ + BOOL bModified(TRUE); + + //positioning mode + sal_Int32 nMode = 0; + if( m_aRbPosMode_Including.IsChecked() ) + nMode = 1; + else if( m_aRbPosMode_Excluding.IsChecked() ) + nMode = 2; + rOutAttrs.Put( SfxInt32Item( SCHATTR_DIAGRAM_POS_MODE, nMode ) ); + + rOutAttrs.Put( SfxRectangleItem( SCHATTR_DIAGRAM_RECT_TO_USE, GetRectIn100thmm() ) ); + + return bModified; +} + +// ----------------------------------------------------------------------- + +SfxTabPage* DiagramPositionTabPage::Create( Window* pWindow, const SfxItemSet& rOutAttrs ) +{ + return( new DiagramPositionTabPage( pWindow, rOutAttrs ) ); +} + +//------------------------------------------------------------------------ + +void DiagramPositionTabPage::ActivatePage( const SfxItemSet& /*rSet*/ ) +{ +} + +// ----------------------------------------------------------------------- + +int DiagramPositionTabPage::DeactivatePage( SfxItemSet* pItemSet ) +{ + if( pItemSet ) + FillItemSet( *pItemSet ); + return LEAVE_PAGE; +} + +//------------------------------------------------------------------------ + +long DiagramPositionTabPage::get1oothMMPosValue( MetricField& rField ) +{ + double fValue( GetCoreValue( rField, mePoolUnit ) * m_fUIScale); + return basegfx::fround(fValue); +} + +long DiagramPositionTabPage::get1oothMMSizeValue( MetricField& rField ) +{ + double fValue = static_cast(rField.GetValue( meDlgUnit )); + fValue = MetricField::ConvertDoubleValue( fValue, rField.GetBaseValue(), rField.GetDecimalDigits(), meDlgUnit, FUNIT_100TH_MM ); + long nValue = long(fValue*m_fUIScale); + nValue = OutputDevice::LogicToLogic( nValue, MAP_100TH_MM, (MapUnit)mePoolUnit ); + nValue = static_cast(rField.Denormalize( nValue )); + return nValue; +} + +/* +const double fTmp((((const SfxInt32Item*)pItem)->GetValue() - maAnchor.getY()) / fUIScale); +SetMetricValue(maMtrPosY, basegfx::fround(fTmp), mePoolUnit); + sal_Int64 nVal = OutputDevice::LogicToLogic( nCoreValue, (MapUnit)eUnit, MAP_100TH_MM ); + nVal = rField.Normalize( nVal ); + rField.SetValue( nVal, FUNIT_100TH_MM ); + */ + +void DiagramPositionTabPage::set1oothMMPosValue( MetricField& rField, long n100thMM ) +{ + const double fTmp( n100thMM / m_fUIScale ); + SetMetricValue(rField, basegfx::fround(fTmp), mePoolUnit); +} +void DiagramPositionTabPage::set1oothMMSizeValue( MetricField& rField, long n100thMM ) +{ + double fValue((OutputDevice::LogicToLogic( n100thMM, (MapUnit)mePoolUnit, MAP_100TH_MM)) ); + fValue /= m_fUIScale; + if(rField.GetDecimalDigits()) + fValue *= pow(10.0, rField.GetDecimalDigits()); + fValue = MetricField::ConvertDoubleValue(fValue, rField.GetBaseValue(), rField.GetDecimalDigits(), FUNIT_100TH_MM, meDlgUnit); + rField.SetValue(static_cast(fValue), meDlgUnit); +} + +sal_Int64 DiagramPositionTabPage::convert1oothMMValueToFieldUnit( MetricField& rField, long n100thMM ) +{ + double fValue((OutputDevice::LogicToLogic( n100thMM, (MapUnit)mePoolUnit, MAP_100TH_MM)) ); + fValue /= m_fUIScale; + if(rField.GetDecimalDigits()) + fValue *= pow(10.0, rField.GetDecimalDigits()); + fValue = MetricField::ConvertDoubleValue(fValue, rField.GetBaseValue(), rField.GetDecimalDigits(), FUNIT_100TH_MM, meDlgUnit); + return basegfx::fround64(fValue); +} + +//------------------------------------------------------------------------ + +void DiagramPositionTabPage::SetRectIn100thmm( const Rectangle& rRect ) +{ + ReleaseBorders(); + + m_aCurrentRect = rRect; + long nLeft = m_aCurrentRect.Left(); + long nTop = m_aCurrentRect.Top(); + long nWidth = m_aCurrentRect.getWidth(); + long nHeight = m_aCurrentRect.getHeight(); + + switch ( maCtlPos.GetActualRP() ) + { + case RP_LT: + { + break; + } + case RP_MT: + { + nLeft += nWidth / 2; + break; + } + case RP_RT: + { + nLeft += nWidth; + break; + } + case RP_LM: + { + nTop += nHeight / 2; + break; + } + case RP_MM: + { + nLeft += nWidth / 2; + nTop += nHeight / 2; + break; + } + case RP_RM: + { + nLeft += nWidth; + nTop += nHeight / 2; + break; + } + case RP_LB: + { + nTop += nHeight; + break; + } + case RP_MB: + { + nLeft += nWidth / 2; + nTop += nHeight; + break; + } + case RP_RB: + { + nLeft += nWidth; + nTop += nHeight; + break; + } + } + + set1oothMMPosValue( maMtrPosX, nLeft ); + set1oothMMPosValue( maMtrPosY, nTop ); + set1oothMMSizeValue( maMtrWidth, nWidth ); + set1oothMMSizeValue( maMtrHeight, nHeight ); + + SetMinMaxPosition(); +} + +//------------------------------------------------------------------------ + +Rectangle DiagramPositionTabPage::GetRectIn100thmm() +{ + long nX = get1oothMMPosValue( maMtrPosX ); + long nY = get1oothMMPosValue( maMtrPosY ); + long nWidth = get1oothMMSizeValue( maMtrWidth ); + long nHeight = get1oothMMSizeValue( maMtrHeight ); + + switch( maCtlPos.GetActualRP() ) + { + case RP_LT: + { + break; + } + case RP_MT: + { + nX -= nWidth/2; + break; + } + case RP_RT: + { + nX -= nWidth; + break; + } + case RP_LM: + { + nY -= nHeight/2; + break; + } + case RP_MM: + { + nX -= nWidth/2; + nY -= nHeight/2; + break; + } + case RP_RM: + { + nX -= nWidth; + nY -= nHeight/2; + break; + } + case RP_LB: + { + nY -= nHeight; + break; + } + case RP_MB: + { + nX -= nWidth/2; + nY -= nHeight; + break; + } + case RP_RB: + { + nX -= nWidth; + nY -= nHeight; + break; + } + } + + return Rectangle(nX,nY,nX+nWidth,nY+nHeight); +} + +//------------------------------------------------------------------------ + +void DiagramPositionTabPage::UpdateControlStates() +{ + bool bEnable = true; + + m_aRbPosMode_Auto.Enable( bEnable ); + m_aRbPosMode_Including.Enable( bEnable ); + m_aRbPosMode_Excluding.Enable( bEnable ); + + if( m_aRbPosMode_Auto.IsChecked() ) + bEnable = false; + + maFlPosition.Enable( bEnable ); + maFtPosX.Enable( bEnable ); + maMtrPosX.Enable( bEnable ); + maFtPosY.Enable( bEnable ); + maMtrPosY.Enable( bEnable ); + maFtPosReference.Enable( bEnable ); + maCtlPos.Enable( bEnable ); + + maFlSize.Enable( bEnable ); + maCtlSize.Enable( bEnable ); + maFtWidth.Enable( bEnable ); + maMtrWidth.Enable( bEnable ); + maFtHeight.Enable( bEnable ); + maMtrHeight.Enable( bEnable ); + maCbxScale.Enable( bEnable ); + maFtSizeReference.Enable( bEnable ); + + maCtlSize.Invalidate(); + maCtlPos.Invalidate(); +} + +//------------------------------------------------------------------------ + +void DiagramPositionTabPage::ReleaseBorders() +{ + //make it possible to set new values that will lead to different min max values afterwards + maMtrPosX.SetMin( convert1oothMMValueToFieldUnit( maMtrPosX, m_aMaxRect.Left() ), meDlgUnit); + maMtrPosX.SetMax( convert1oothMMValueToFieldUnit( maMtrPosX, m_aMaxRect.Right() ), meDlgUnit); + maMtrPosY.SetMin( convert1oothMMValueToFieldUnit( maMtrPosY, m_aMaxRect.Top() ), meDlgUnit); + maMtrPosY.SetMax( convert1oothMMValueToFieldUnit( maMtrPosY, m_aMaxRect.Bottom() ), meDlgUnit); + maMtrWidth.SetMax( convert1oothMMValueToFieldUnit( maMtrWidth, m_aMaxRect.GetWidth() ), meDlgUnit); + maMtrHeight.SetMax( convert1oothMMValueToFieldUnit( maMtrHeight, m_aMaxRect.GetHeight() ), meDlgUnit); +} + +//------------------------------------------------------------------------ + +void DiagramPositionTabPage::SetMinMaxPosition() +{ + // position + + long nLeft( m_aMaxRect.Left() ); + long nTop( m_aMaxRect.Top() ); + long nRight( m_aMaxRect.Right() ); + long nBottom( m_aMaxRect.Bottom() ); + + const long nWidth( m_aCurrentRect.GetWidth() ); + const long nHeight( m_aCurrentRect.GetHeight() ); + + switch ( maCtlPos.GetActualRP() ) + { + case RP_LT: + { + nRight -= nWidth; + nBottom -= nHeight; + break; + } + case RP_MT: + { + nLeft += nWidth / 2; + nRight -= nWidth / 2; + nBottom -= nHeight; + break; + } + case RP_RT: + { + nLeft += nWidth; + nBottom -= nHeight; + break; + } + case RP_LM: + { + nRight -= nWidth; + nTop += nHeight / 2; + nBottom -= nHeight / 2; + break; + } + case RP_MM: + { + nLeft += nWidth / 2; + nRight -= nWidth / 2; + nTop += nHeight / 2; + nBottom -= nHeight / 2; + break; + } + case RP_RM: + { + nLeft += nWidth; + nTop += nHeight / 2; + nBottom -= nHeight / 2; + break; + } + case RP_LB: + { + nRight -= nWidth; + nTop += nHeight; + break; + } + case RP_MB: + { + nLeft += nWidth / 2; + nRight -= nWidth / 2; + nTop += nHeight; + break; + } + case RP_RB: + { + nLeft += nWidth; + nTop += nHeight; + break; + } + } + + maMtrPosX.SetMin( convert1oothMMValueToFieldUnit( maMtrPosX, nLeft ), meDlgUnit); + maMtrPosX.SetFirst( convert1oothMMValueToFieldUnit( maMtrPosX, nLeft ), meDlgUnit); + maMtrPosX.SetMax( convert1oothMMValueToFieldUnit( maMtrPosX, nRight ), meDlgUnit); + maMtrPosX.SetLast( convert1oothMMValueToFieldUnit( maMtrPosX, nRight ), meDlgUnit); + maMtrPosY.SetMin( convert1oothMMValueToFieldUnit( maMtrPosY, nTop ), meDlgUnit); + maMtrPosY.SetFirst( convert1oothMMValueToFieldUnit( maMtrPosY, nTop ), meDlgUnit); + maMtrPosY.SetMax( convert1oothMMValueToFieldUnit( maMtrPosY, nBottom ), meDlgUnit); + maMtrPosY.SetLast( convert1oothMMValueToFieldUnit( maMtrPosY, nBottom ), meDlgUnit); + + // size + + nLeft = m_aMaxRect.Left(); + nTop = m_aMaxRect.Top(); + nRight = m_aMaxRect.Right(); + nBottom = m_aMaxRect.Bottom(); + + long nMaxWidth( m_aMaxRect.GetWidth() ); + long nMaxHeight( m_aMaxRect.GetHeight() ); + + switch ( maCtlSize.GetActualRP() ) + { + case RP_LT: + { + nMaxWidth -= ( m_aCurrentRect.Left() - nLeft ); + nMaxHeight -= ( m_aCurrentRect.Top() - nTop ); + break; + } + case RP_MT: + { + nMaxWidth = std::min( m_aCurrentRect.Center().X() - nLeft, nRight - m_aCurrentRect.Center().X() ) * 2; + nMaxHeight -= ( m_aCurrentRect.Top() - nTop ); + break; + } + case RP_RT: + { + nMaxWidth -= ( nRight - m_aCurrentRect.Right() ); + nMaxHeight -= ( m_aCurrentRect.Top() - nTop ); + break; + } + case RP_LM: + { + nMaxWidth -= ( m_aCurrentRect.Left() - nLeft ); + nMaxHeight = std::min( m_aCurrentRect.Center().Y() - nTop, nBottom - m_aCurrentRect.Center().Y() ) * 2; + break; + } + case RP_MM: + { + nMaxWidth = std::min( m_aCurrentRect.Center().X() - nLeft, nRight - m_aCurrentRect.Center().X() ) * 2; + nMaxHeight = std::min( m_aCurrentRect.Center().Y() - nTop, nBottom - m_aCurrentRect.Center().Y() ) * 2; + break; + } + case RP_RM: + { + nMaxWidth -= ( nRight - m_aCurrentRect.Right() ); + nMaxHeight = std::min( m_aCurrentRect.Center().Y() - nTop, nBottom - m_aCurrentRect.Center().Y() ) * 2; + break; + } + case RP_LB: + { + nMaxWidth -= ( m_aCurrentRect.Left() - nLeft ); + nMaxHeight -=( nBottom - m_aCurrentRect.Bottom() ); + break; + } + case RP_MB: + { + nMaxWidth = std::min( m_aCurrentRect.Center().X() - nLeft, nRight - m_aCurrentRect.Center().X() ) * 2; + nMaxHeight -= ( m_aCurrentRect.Bottom() - nBottom ); + break; + } + case RP_RB: + { + nMaxWidth -= ( nRight - m_aCurrentRect.Right() ); + nMaxHeight -= ( nBottom - m_aCurrentRect.Bottom() ); + break; + } + } + + if( maCbxScale.IsChecked() && maCbxScale.IsEnabled() ) + { + sal_Int64 nMaxHeightResultingFromScale(basegfx::fround64((mfScaleSizeY * (double)nMaxWidth) / mfScaleSizeX)); + if( nMaxHeightResultingFromScale > nMaxHeight ) + nMaxWidth = basegfx::fround64((mfScaleSizeX * (double)nMaxHeight / mfScaleSizeY)); + sal_Int64 nMaxWidthResultingFromScale(basegfx::fround64((mfScaleSizeX * (double)nMaxHeight) / mfScaleSizeY)); + if( nMaxWidthResultingFromScale > nMaxWidth ) + nMaxHeight = basegfx::fround64((mfScaleSizeY * (double)nMaxWidth / mfScaleSizeX)); + } + + maMtrWidth.SetMax( convert1oothMMValueToFieldUnit( maMtrWidth, nMaxWidth ), meDlgUnit); + maMtrWidth.SetLast( convert1oothMMValueToFieldUnit( maMtrWidth, nMaxWidth ), meDlgUnit); + maMtrHeight.SetMax( convert1oothMMValueToFieldUnit( maMtrHeight, nMaxHeight ), meDlgUnit); + maMtrHeight.SetLast( convert1oothMMValueToFieldUnit( maMtrHeight, nMaxHeight ), meDlgUnit); +} + +//------------------------------------------------------------------------ + +void DiagramPositionTabPage::PointChanged( Window* pWindow, RECT_POINT /*eRP*/ ) +{ + if( pWindow == &maCtlPos ) + SetRectIn100thmm( m_aCurrentRect ); + else + SetMinMaxPosition(); +} + +//------------------------------------------------------------------------ + +IMPL_LINK( DiagramPositionTabPage, ChangeModeHdl, RadioButton*, pButton ) +{ + UpdateControlStates(); + if( pButton == &m_aRbPosMode_Including ) + { + if( !m_bRectChangedByUser ) + SetRectIn100thmm( m_aIncludingRect ); + } + else if( pButton == &m_aRbPosMode_Excluding ) + { + if( !m_bRectChangedByUser ) + SetRectIn100thmm( m_aExcludingRect ); + } + + return( 0L ); +} + +//------------------------------------------------------------------------ + +IMPL_LINK( DiagramPositionTabPage, ChangePosXHdl, void *, EMPTYARG ) +{ + m_aCurrentRect = GetRectIn100thmm(); + SetMinMaxPosition(); + m_bRectChangedByUser = true; + return( 0L ); +} + +//------------------------------------------------------------------------ + +IMPL_LINK( DiagramPositionTabPage, ChangePosYHdl, void *, EMPTYARG ) +{ + m_aCurrentRect = GetRectIn100thmm(); + SetMinMaxPosition(); + m_bRectChangedByUser = true; + return( 0L ); +} + +//------------------------------------------------------------------------ + +IMPL_LINK( DiagramPositionTabPage, ChangeWidthHdl, void *, EMPTYARG ) +{ + if( maCbxScale.IsChecked() && maCbxScale.IsEnabled() ) + { + sal_Int64 nHeight(basegfx::fround64((mfScaleSizeY * (double)maMtrWidth.GetValue()) / mfScaleSizeX)); + + if(nHeight <= maMtrHeight.GetMax(FUNIT_NONE)) + { + maMtrHeight.SetUserValue(nHeight, FUNIT_NONE); + } + else + { + nHeight = maMtrHeight.GetMax(FUNIT_NONE); + maMtrHeight.SetUserValue(nHeight); + + const sal_Int64 nWidth(basegfx::fround64((mfScaleSizeX * (double)nHeight) / mfScaleSizeY)); + maMtrWidth.SetUserValue(nWidth, FUNIT_NONE); + } + } + m_bRectChangedByUser = true; + m_aCurrentRect = GetRectIn100thmm(); + SetMinMaxPosition(); + return( 0L ); +} + +//------------------------------------------------------------------------ + +IMPL_LINK( DiagramPositionTabPage, ChangeHeightHdl, void *, EMPTYARG ) +{ + if( maCbxScale.IsChecked() && maCbxScale.IsEnabled() ) + { + sal_Int64 nWidth(basegfx::fround64((mfScaleSizeX * (double)maMtrHeight.GetValue()) / mfScaleSizeY)); + + if(nWidth <= maMtrWidth.GetMax(FUNIT_NONE)) + { + maMtrWidth.SetUserValue(nWidth, FUNIT_NONE); + } + else + { + nWidth = maMtrWidth.GetMax(FUNIT_NONE); + maMtrWidth.SetUserValue(nWidth); + + const sal_Int64 nHeight(basegfx::fround64((mfScaleSizeY * (double)nWidth) / mfScaleSizeX)); + maMtrHeight.SetUserValue(nHeight, FUNIT_NONE); + } + } + m_bRectChangedByUser = true; + m_aCurrentRect = GetRectIn100thmm(); + SetMinMaxPosition(); + return( 0L ); +} + +//------------------------------------------------------------------------ + +IMPL_LINK( DiagramPositionTabPage, ClickScaleHdl, void *, EMPTYARG ) +{ + if( maCbxScale.IsChecked() ) + { + mfScaleSizeX = std::max( (double)GetCoreValue( maMtrWidth, mePoolUnit ), 1.0 ); + mfScaleSizeY = std::max( (double)GetCoreValue( maMtrHeight, mePoolUnit ), 1.0 ); + } + SetMinMaxPosition(); + return( 0L ); +} + +//------------------------------------------------------------------------ + +void DiagramPositionTabPage::FillUserData() +{ + // Abgleich wird in der Ini-Datei festgehalten + UniString aStr = UniString::CreateFromInt32( (sal_Int32) maCbxScale.IsChecked() ); + SetUserData( aStr ); +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/dialogs/tp_DiagramPosition.hrc b/chart2/source/controller/dialogs/tp_DiagramPosition.hrc new file mode 100644 index 000000000000..c91771e3da91 --- /dev/null +++ b/chart2/source/controller/dialogs/tp_DiagramPosition.hrc @@ -0,0 +1,51 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ,v $ + * $Revision: $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "ResourceIds.hrc" + +#define FL_POSITIONING_MODE 1 +#define RB_POSITIONING_MODE_AUTOMATIC 2 +#define RB_POSITIONING_MODE_INCLUDING 3 +#define RB_POSITIONING_MODE_EXCLUDING 4 +#define FL_POSITION 5 +#define FT_POS_X 6 +#define FT_POS_Y 7 +#define MTR_FLD_POS_X 8 +#define MTR_FLD_POS_Y 9 +#define FT_POSREFERENCE 10 +#define CTL_POSRECT 11 +#define FL_SIZE 12 +#define FT_WIDTH 13 +#define FT_HEIGHT 14 +#define MTR_FLD_WIDTH 15 +#define MTR_FLD_HEIGHT 16 +#define FT_SIZEREFERENCE 17 +#define CTL_SIZERECT 18 +#define CBX_SCALE 19 diff --git a/chart2/source/controller/dialogs/tp_DiagramPosition.hxx b/chart2/source/controller/dialogs/tp_DiagramPosition.hxx new file mode 100644 index 000000000000..153c9d26ca75 --- /dev/null +++ b/chart2/source/controller/dialogs/tp_DiagramPosition.hxx @@ -0,0 +1,140 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_DiagramPosition.hxx,v $ + * $Revision: 1.7 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CHART2_TP_DIAGRAMPOSITION_HXX +#define _CHART2_TP_DIAGRAMPOSITION_HXX + +// header for class FormattedField +#include +// header for FixedText +#include +// header for CheckBox +#include +// header for MetricField +#include +// header for SvxTabPage and SvxRectCtl +#include + +//............................................................................. +namespace chart +{ +//............................................................................. +class DiagramPositionTabPage : public SvxTabPage +{ + using TabPage::ActivatePage; + using TabPage::DeactivatePage; + +public: + DiagramPositionTabPage( Window* pParent, const SfxItemSet& rInAttrs ); + + static SfxTabPage* Create( Window*, const SfxItemSet& ); + + virtual BOOL FillItemSet( SfxItemSet& ); + virtual void Reset( const SfxItemSet & ); + + virtual void ActivatePage( const SfxItemSet& rSet ); + virtual int DeactivatePage( SfxItemSet* pSet ); + + //SvxTabPage communication interface with SvxRectCtl + virtual void PointChanged( Window* pWindow, RECT_POINT eRP ); + + void Construct(); + + virtual void FillUserData(); + +private: + //methods + + DECL_LINK( ChangeModeHdl, RadioButton * ); + DECL_LINK( ChangePosXHdl, void * ); + DECL_LINK( ChangePosYHdl, void * ); + DECL_LINK( ChangeWidthHdl, void * ); + DECL_LINK( ChangeHeightHdl, void * ); + DECL_LINK( ClickScaleHdl, void * ); + + void SetRectIn100thmm( const Rectangle& rRect ); + Rectangle GetRectIn100thmm(); + long get1oothMMPosValue( MetricField& rField ); + long get1oothMMSizeValue( MetricField& rField ); + void set1oothMMPosValue( MetricField& rField, long n100thMM ); + void set1oothMMSizeValue( MetricField& rField, long n100thMM ); + sal_Int64 convert1oothMMValueToFieldUnit( MetricField& rField, long n100thMM ); + void ReleaseBorders(); + void SetMinMaxPosition(); + void UpdateControlStates(); + +private: + + //positioning mode + FixedLine m_aFlPosMode; + + RadioButton m_aRbPosMode_Auto; + RadioButton m_aRbPosMode_Including; + RadioButton m_aRbPosMode_Excluding; + + // position + FixedLine maFlPosition; + FixedText maFtPosX; + MetricField maMtrPosX; + FixedText maFtPosY; + MetricField maMtrPosY; + FixedText maFtPosReference; + SvxRectCtl maCtlPos; + + // size + FixedLine maFlSize; + FixedText maFtWidth; + MetricField maMtrWidth; + FixedText maFtHeight; + MetricField maMtrHeight; + CheckBox maCbxScale; + FixedText maFtSizeReference; + SvxRectCtl maCtlSize; + +private: + Rectangle m_aExcludingRect; + Rectangle m_aIncludingRect; + Rectangle m_aMaxRect; + double m_fUIScale; + Rectangle m_aCurrentRect; + bool m_bRectChangedByUser; + + SfxMapUnit mePoolUnit; + FieldUnit meDlgUnit; + + double mfScaleSizeX; + double mfScaleSizeY; +}; + +//............................................................................. +} //namespace chart +//............................................................................. + +#endif + diff --git a/chart2/source/controller/dialogs/tp_DiagramPosition.src b/chart2/source/controller/dialogs/tp_DiagramPosition.src new file mode 100644 index 000000000000..3ee028d88e94 --- /dev/null +++ b/chart2/source/controller/dialogs/tp_DiagramPosition.src @@ -0,0 +1,217 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_DiagramPosition.src,v $ + * $Revision: 1.10 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "tp_DiagramPosition.hrc" +#include "TabPages.hrc" +#include + +#define LABELWIDTH 40 +#define LABELHEIGHT 10 + +#define Y_MODE_0 3 +#define Y_MODE_1 (Y_MODE_0+18) +#define Y_MODE_2 (Y_MODE_1+13) +#define Y_MODE_3 (Y_MODE_2+13) +#define Y_POSITION (Y_MODE_3+18) +#define Y_SIZE (Y_POSITION+53) + +#define X1 6 +#define X2 12 +#define X3 (X2+LABELWIDTH+4) +#define X4 178 + + +TabPage TP_DIAGRAM_POSITION +{ + Hide = TRUE ; + Size = MAP_APPFONT ( 260 , 185 ) ; + + FixedLine FL_POSITIONING_MODE + { + Pos = MAP_APPFONT ( X1 , Y_MODE_0 ) ; + Size = MAP_APPFONT ( 248 , RSC_CD_FIXEDLINE_HEIGHT ) ; + Text [ en-US ] = "Positioning Mode" ; + }; + RadioButton RB_POSITIONING_MODE_AUTOMATIC + { + Pos = MAP_APPFONT ( X2 , Y_MODE_1 ) ; + Size = MAP_APPFONT ( 236 , 10 ) ; + TabStop = TRUE ; + Text [ en-US ] = "Automatic" ; + }; + RadioButton RB_POSITIONING_MODE_INCLUDING + { + Pos = MAP_APPFONT ( X2 , Y_MODE_2 ) ; + Size = MAP_APPFONT ( 236 , 10 ) ; + TabStop = TRUE ; + Text [ en-US ] = "Include labels" ; + }; + RadioButton RB_POSITIONING_MODE_EXCLUDING + { + Pos = MAP_APPFONT ( X2 , Y_MODE_3 ) ; + Size = MAP_APPFONT ( 236 , 10 ) ; + TabStop = TRUE ; + Text [ en-US ] = "Exclude labels" ; + }; + + FixedLine FL_POSITION + { + Pos = MAP_APPFONT ( X1 , Y_POSITION ) ; + Size = MAP_APPFONT ( 248 , RSC_CD_FIXEDLINE_HEIGHT ) ; + Text [ en-US ] = "Position" ; + }; + FixedText FT_POS_X + { + Pos = MAP_APPFONT ( X2 , Y_POSITION - 3 + 16 + 8 ) ; + Size = MAP_APPFONT ( LABELWIDTH , LABELHEIGHT ) ; + Text [ en-US ] = "Position ~X" ; + }; + FixedText FT_POS_Y + { + Pos = MAP_APPFONT ( X2 , Y_POSITION - 3 + 32 + 8 ) ; + Size = MAP_APPFONT ( LABELWIDTH , LABELHEIGHT ) ; + Text [ en-US ] = "Position ~Y" ; + }; + MetricField MTR_FLD_POS_X + { + Border = TRUE ; + Pos = MAP_APPFONT ( X3 , Y_POSITION - 3 + 14 + 8 ) ; + Size = MAP_APPFONT ( 54 , 12 ) ; + TabStop = TRUE ; + Repeat = TRUE ; + Spin = TRUE ; + Minimum = -120000 ; + Maximum = 240000 ; + StrictFormat = TRUE ; + DecimalDigits = 2 ; + Unit = FUNIT_MM ; + SpinSize = 10 ; + }; + MetricField MTR_FLD_POS_Y + { + Border = TRUE ; + Pos = MAP_APPFONT ( X3 , Y_POSITION - 3 + 30 + 8 ) ; + Size = MAP_APPFONT ( 54 , 12 ) ; + TabStop = TRUE ; + Repeat = TRUE ; + Spin = TRUE ; + Minimum = -120000 ; + Maximum = 240000 ; + StrictFormat = TRUE ; + DecimalDigits = 2 ; + Unit = FUNIT_MM ; + SpinSize = 10 ; + }; + FixedText FT_POSREFERENCE + { + Pos = MAP_APPFONT ( X4 , Y_POSITION - 3 + 2 + 8 ) ; + Size = MAP_APPFONT ( 70 , LABELHEIGHT ) ; + Text [ en-US ] = "Base point"; + }; + Control CTL_POSRECT + { + Border = TRUE ; + Pos = MAP_APPFONT ( X4 , Y_POSITION - 3 + 12 + 8 ) ; + Size = MAP_APPFONT ( 48 , 34 ) ; + TabStop = TRUE ; + QuickHelpText [ en-US ] = "Base point" ; + }; + + // size + + FixedLine FL_SIZE + { + Pos = MAP_APPFONT ( X1 , Y_SIZE ) ; + Size = MAP_APPFONT ( 248 , RSC_CD_FIXEDLINE_HEIGHT ) ; + Text [ en-US ] = "Size" ; + }; + FixedText FT_WIDTH + { + Pos = MAP_APPFONT ( X2 , Y_SIZE - 56 + 16 + 61 ) ; + Size = MAP_APPFONT ( LABELWIDTH , LABELHEIGHT ) ; + Text [ en-US ] = "Wi~dth" ; + }; + FixedText FT_HEIGHT + { + Pos = MAP_APPFONT ( X2 , Y_SIZE - 56 + 32 + 61 ) ; + Size = MAP_APPFONT ( LABELWIDTH , LABELHEIGHT ) ; + Text [ en-US ] = "H~eight" ; + }; + MetricField MTR_FLD_WIDTH + { + Border = TRUE ; + Pos = MAP_APPFONT ( X3 , Y_SIZE - 56 + 14 + 61 ) ; + Size = MAP_APPFONT ( 54 , 12 ) ; + TabStop = TRUE ; + Repeat = TRUE ; + Spin = TRUE ; + Minimum = 1 ; + Maximum = 120000 ; + StrictFormat = TRUE ; + DecimalDigits = 2 ; + Unit = FUNIT_MM ; + SpinSize = 10 ; + }; + MetricField MTR_FLD_HEIGHT + { + Border = TRUE ; + Pos = MAP_APPFONT ( X3 , Y_SIZE - 56 + 30 + 61 ) ; + Size = MAP_APPFONT ( 54 , 12 ) ; + TabStop = TRUE ; + Repeat = TRUE ; + Spin = TRUE ; + Minimum = 1 ; + Maximum = 120000 ; + StrictFormat = TRUE ; + DecimalDigits = 2 ; + Unit = FUNIT_MM ; + SpinSize = 10 ; + }; + FixedText FT_SIZEREFERENCE + { + Pos = MAP_APPFONT ( X4 , Y_SIZE - 56 + 2 + 61 ) ; + Size = MAP_APPFONT ( 70 , LABELHEIGHT ) ; + Text [ en-US ] = "Base point"; + }; + Control CTL_SIZERECT + { + Border = TRUE ; + Pos = MAP_APPFONT ( X4 , Y_SIZE - 56 + 12 + 61 ) ; + Size = MAP_APPFONT ( 48 , 34 ) ; + TabStop = TRUE ; + QuickHelpText [ en-US ] = "Base point" ; + }; + CheckBox CBX_SCALE + { + Pos = MAP_APPFONT ( X2 , Y_SIZE - 56 + 47 + 61 ) ; + Size = MAP_APPFONT ( 162 , LABELHEIGHT ) ; + TabStop = TRUE ; + Text [ en-US ] = "~Keep ratio" ; + }; +}; diff --git a/chart2/source/controller/drawinglayer/DrawViewWrapper.cxx b/chart2/source/controller/drawinglayer/DrawViewWrapper.cxx index fa285f98d991..8af723aa7b4d 100644 --- a/chart2/source/controller/drawinglayer/DrawViewWrapper.cxx +++ b/chart2/source/controller/drawinglayer/DrawViewWrapper.cxx @@ -33,6 +33,7 @@ #include "DrawViewWrapper.hxx" #include "chartview/DrawModelWrapper.hxx" #include "ConfigurationAccess.hxx" +#include "macros.hxx" // header for class SdrPage #include @@ -223,6 +224,14 @@ SdrObject* DrawViewWrapper::getHitObject( const Point& rPnt ) const if( pRet ) { + //ignore some special shapes + rtl::OUString aShapeName = pRet->GetName(); + if( aShapeName.match(C2U("PlotAreaIncludingAxes")) || aShapeName.match(C2U("PlotAreaExcludingAxes")) ) + { + pRet->SetMarkProtect( true ); + return getHitObject( rPnt ); + } + //3d objects need a special treatment //because the simple PickObj method is not accurate in this case for performance reasons E3dObject* pE3d = dynamic_cast< E3dObject* >(pRet); diff --git a/chart2/source/controller/inc/DiagramItemConverter.hxx b/chart2/source/controller/inc/DiagramItemConverter.hxx new file mode 100644 index 000000000000..9df7b093d573 --- /dev/null +++ b/chart2/source/controller/inc/DiagramItemConverter.hxx @@ -0,0 +1,81 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: AxisItemConverter.hxx,v $ + * $Revision: 1.9 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART_DIAGRAM_CONVERTER_HXX +#define CHART_DIAGRAM_CONVERTER_HXX + +#include "ItemConverter.hxx" +#include +#include + +#include +#include + +class SdrModel; + +namespace chart +{ +namespace wrapper +{ + +class DiagramItemConverter : public ::comphelper::ItemConverter +{ +public: + DiagramItemConverter( + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > & rPropertySet, + SfxItemPool& rItemPool, + SdrModel& rDrawModel, + const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel > & xChartModel, double fUIScale ); + virtual ~DiagramItemConverter(); + + virtual void FillItemSet( SfxItemSet & rOutItemSet ) const; + virtual bool ApplyItemSet( const SfxItemSet & rItemSet ); + +protected: + virtual const USHORT * GetWhichPairs() const; + virtual bool GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId & rOutProperty ) const; + + virtual void FillSpecialItem( USHORT nWhichId, SfxItemSet & rOutItemSet ) const + throw( ::com::sun::star::uno::Exception ); + virtual bool ApplySpecialItem( USHORT nWhichId, const SfxItemSet & rItemSet ) + throw( ::com::sun::star::uno::Exception ); + +private: + ::std::vector< ItemConverter * > m_aConverters; + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xChartModel; + double m_fUIScale; +}; + +} // namespace wrapper +} // namespace chart + +// CHART_DIAGRAM_CONVERTER_HXX +#endif diff --git a/chart2/source/controller/itemsetwrapper/DiagramItemConverter.cxx b/chart2/source/controller/itemsetwrapper/DiagramItemConverter.cxx new file mode 100644 index 000000000000..00f1fb664739 --- /dev/null +++ b/chart2/source/controller/itemsetwrapper/DiagramItemConverter.cxx @@ -0,0 +1,226 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: DiagramItemConverter.cxx,v $ + * $Revision: 1.16 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" +#include "DiagramItemConverter.hxx" +#include "DiagramHelper.hxx" +#include "ChartModelHelper.hxx" +#include "SchWhichPairs.hxx" +#include "macros.hxx" +#include "servicenames.hxx" +#include "chartview/ExplicitValueProvider.hxx" +#include +#include "ItemPropertyMap.hxx" +#include "GraphicPropertyItemConverter.hxx" +#include +#include + +#include +#include + +using namespace ::com::sun::star; + +namespace chart +{ +namespace wrapper +{ + +DiagramItemConverter::DiagramItemConverter( + const uno::Reference< beans::XPropertySet > & xPropertySet + , SfxItemPool& rItemPool + , SdrModel& rDrawModel + , const uno::Reference< frame::XModel >& xChartModel + , double fUIScale ) + : ItemConverter( xPropertySet, rItemPool ) + , m_xChartModel( xChartModel ) + , m_fUIScale( fUIScale ) +{ + m_aConverters.push_back( new GraphicPropertyItemConverter( + xPropertySet, rItemPool, rDrawModel, uno::Reference< lang::XMultiServiceFactory >( xChartModel, uno::UNO_QUERY ), + GraphicPropertyItemConverter::LINE_AND_FILL_PROPERTIES )); +} + +DiagramItemConverter::~DiagramItemConverter() +{ + ::std::for_each( m_aConverters.begin(), m_aConverters.end(), + ::comphelper::DeleteItemConverterPtr() ); +} + +void DiagramItemConverter::FillItemSet( SfxItemSet & rOutItemSet ) const +{ + ::std::for_each( m_aConverters.begin(), m_aConverters.end(), + ::comphelper::FillItemSetFunc( rOutItemSet )); + + // own items + ItemConverter::FillItemSet( rOutItemSet ); +} + +bool DiagramItemConverter::ApplyItemSet( const SfxItemSet & rItemSet ) +{ + bool bResult = false; + + ::std::for_each( m_aConverters.begin(), m_aConverters.end(), + ::comphelper::ApplyItemSetFunc( rItemSet, bResult )); + + // own items + return ItemConverter::ApplyItemSet( rItemSet ) || bResult; +} + +const USHORT * DiagramItemConverter::GetWhichPairs() const +{ + // must span all used items! + return nDiagramWhichPairs; +} + +bool DiagramItemConverter::GetItemProperty( tWhichIdType /*nWhichId*/, tPropertyNameWithMemberId & /*rOutProperty*/ ) const +{ + // No own (non-special) properties + return false; +} + + +bool DiagramItemConverter::ApplySpecialItem( + USHORT nWhichId, const SfxItemSet & rItemSet ) + throw( uno::Exception ) +{ + bool bChanged = false; + + switch( nWhichId ) + { + case SCHATTR_DIAGRAM_POS_MODE: + { + try + { + sal_Int32 nValue = static_cast< const SfxInt32Item & >( rItemSet.Get( nWhichId )).GetValue(); + DiagramPositioningMode eMode = static_cast< DiagramPositioningMode >(nValue); + bChanged = DiagramHelper::setDiagramPositioningMode( ChartModelHelper::findDiagram( m_xChartModel ), eMode ); + } + catch( uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } + } + break; + case SCHATTR_DIAGRAM_RECT_TO_USE: + { + sal_Int32 nValue = static_cast< const SfxInt32Item & >( rItemSet.Get( SCHATTR_DIAGRAM_POS_MODE )).GetValue(); + DiagramPositioningMode ePosMode = static_cast< DiagramPositioningMode >(nValue); + if( ePosMode != DiagramPositioningMode_AUTO ) + { + Rectangle aRect = static_cast< const SfxRectangleItem & >( rItemSet.Get( nWhichId )).GetValue(); + bChanged = DiagramHelper::setDiagramPositioning( m_xChartModel, awt::Rectangle( aRect.getX(), aRect.getY(), aRect.getWidth(), aRect.getHeight() ) ); + } + } + break; + } + + return bChanged; +} + +void DiagramItemConverter::FillSpecialItem( + USHORT nWhichId, SfxItemSet & rOutItemSet ) const + throw( uno::Exception ) +{ + switch( nWhichId ) + { + case SCHATTR_DIAGRAM_POS_MODE: + { + DiagramPositioningMode eMode = DiagramHelper::getDiagramPositioningMode( ChartModelHelper::findDiagram( m_xChartModel ) ); + rOutItemSet.Put( SfxInt32Item( nWhichId, eMode ) ); + } + break; + case SCHATTR_DIAGRAM_RECT_TO_USE: + { + awt::Rectangle aRect(0,0,0,0); + DiagramPositioningMode eMode = DiagramHelper::getDiagramPositioningMode( ChartModelHelper::findDiagram( m_xChartModel ) ); + uno::Reference< lang::XMultiServiceFactory > xFact( m_xChartModel, uno::UNO_QUERY ); + if( xFact.is() ) + { + ExplicitValueProvider* pProvider = ExplicitValueProvider::getExplicitValueProvider( xFact->createInstance( CHART_VIEW_SERVICE_NAME ) ); + //test + awt::Rectangle aTestInclusive = pProvider->getRectangleOfObject( C2U("PlotAreaIncludingAxes") ); + awt::Rectangle aTestExclusive = pProvider->getDiagramRectangleExcludingAxes(); + awt::Rectangle aModelRect = DiagramHelper::getDiagramRectangleFromModel( m_xChartModel ); + //end test + + if( eMode == DiagramPositioningMode_EXCLUDING ) + aRect = pProvider->getDiagramRectangleExcludingAxes(); + else + aRect = pProvider->getRectangleOfObject( C2U("PlotAreaIncludingAxes") ); + rOutItemSet.Put( SfxRectangleItem( nWhichId, Rectangle( aRect.X, aRect.Y, aRect.X+aRect.Width, aRect.Y+aRect.Height ) ) ); + } + } + break; + case SCHATTR_DIAGRAM_RECT_INCLUDING: + { + uno::Reference< lang::XMultiServiceFactory > xFact( m_xChartModel, uno::UNO_QUERY ); + if( xFact.is() ) + { + ExplicitValueProvider* pProvider = ExplicitValueProvider::getExplicitValueProvider( xFact->createInstance( CHART_VIEW_SERVICE_NAME ) ); + if( pProvider ) + { + awt::Rectangle aRect = pProvider->getRectangleOfObject( C2U("PlotAreaIncludingAxes") ); + rOutItemSet.Put( SfxRectangleItem( nWhichId, Rectangle( aRect.X, aRect.Y, aRect.X+aRect.Width, aRect.Y+aRect.Height ) ) ); + } + } + } + break; + case SCHATTR_DIAGRAM_RECT_EXCLUDING: + { + uno::Reference< lang::XMultiServiceFactory > xFact( m_xChartModel, uno::UNO_QUERY ); + if( xFact.is() ) + { + ExplicitValueProvider* pProvider = ExplicitValueProvider::getExplicitValueProvider( xFact->createInstance( CHART_VIEW_SERVICE_NAME ) ); + if( pProvider ) + { + awt::Rectangle aRect = pProvider->getDiagramRectangleExcludingAxes(); + rOutItemSet.Put( SfxRectangleItem( nWhichId, Rectangle( aRect.X, aRect.Y, aRect.X+aRect.Width, aRect.Y+aRect.Height ) ) ); + } + } + } + break; + case SCHATTR_DIAGRAM_RECT_MAX: + { + awt::Size aPageSize( ChartModelHelper::getPageSize( m_xChartModel) ); + Rectangle aRect(0,0,aPageSize.Width,aPageSize.Height); + rOutItemSet.Put( SfxRectangleItem( nWhichId, aRect ) ); + } + break; + case SCHATTR_DIAGRAM_UI_SCALE: + { + rOutItemSet.Put( SvxDoubleItem( m_fUIScale, nWhichId ) ); + } + break; + } +} + +} // namespace wrapper +} // namespace chart diff --git a/chart2/source/controller/itemsetwrapper/SchWhichPairs.hxx b/chart2/source/controller/itemsetwrapper/SchWhichPairs.hxx index dbefb0e7f025..5b3ab5922d7b 100644 --- a/chart2/source/controller/itemsetwrapper/SchWhichPairs.hxx +++ b/chart2/source/controller/itemsetwrapper/SchWhichPairs.hxx @@ -90,34 +90,23 @@ const USHORT nGridWhichPairs[] = 0 }; -const USHORT nChartWhichPairs[] = -{ - SCHATTR_STYLE_START,SCHATTR_STYLE_END, // 59 - 68 sch/schattr.hxx - 0 -}; - -const USHORT nDiagramAreaWhichPairs[] = -{ - XATTR_LINE_FIRST, XATTR_LINE_LAST, // 1000 - 1016 svx/xdef.hxx - XATTR_FILL_FIRST, XATTR_FILL_LAST, // 1018 - 1046 svx/xdef.hxx - 0 -}; - -const USHORT nAreaAndChartWhichPairs[] = // pairs for chart AND area +const USHORT nLegendWhichPairs[] = { XATTR_LINE_FIRST, XATTR_LINE_LAST, // 1000 - 1016 svx/xdef.hxx XATTR_FILL_FIRST, XATTR_FILL_LAST, // 1018 - 1046 svx/xdef.hxx - SCHATTR_STYLE_START,SCHATTR_STYLE_END, // 59 - 68 sch/schattr.hxx + SDRATTR_SHADOW_FIRST, SDRATTR_SHADOW_LAST, // 1067 - 1078 svx/svddef.hxx + CHARACTER_WHICHPAIRS, + SCHATTR_LEGEND_START, SCHATTR_LEGEND_END, // 3 - 3 sch/schattr.hxx 0 }; -const USHORT nLegendWhichPairs[] = +const USHORT nDiagramWhichPairs[] = { XATTR_LINE_FIRST, XATTR_LINE_LAST, // 1000 - 1016 svx/xdef.hxx - XATTR_FILL_FIRST, XATTR_FILL_LAST, // 1018 - 1046 svx/xdef.hxx - SDRATTR_SHADOW_FIRST, SDRATTR_SHADOW_LAST, // 1067 - 1078 svx/svddef.hxx - CHARACTER_WHICHPAIRS, - SCHATTR_LEGEND_START, SCHATTR_LEGEND_END, // 3 - 3 sch/schattr.hxx + XATTR_FILL_FIRST, XATTR_FILL_LAST, // 1000 - 1016 svx/xdef.hxx + SCHATTR_DIAGRAM_START, SCHATTR_DIAGRAM_END, + SID_ATTR_TRANSFORM_POS_Y, SID_ATTR_TRANSFORM_POS_Y, + SID_ATTR_TRANSFORM_WIDTH, SID_ATTR_TRANSFORM_HEIGHT, 0 }; diff --git a/chart2/source/controller/itemsetwrapper/makefile.mk b/chart2/source/controller/itemsetwrapper/makefile.mk index 0ab981bba643..a34ead7b1841 100644 --- a/chart2/source/controller/itemsetwrapper/makefile.mk +++ b/chart2/source/controller/itemsetwrapper/makefile.mk @@ -56,7 +56,8 @@ SLOFILES= $(SLO)$/ItemConverter.obj \ $(SLO)$/TitleItemConverter.obj \ $(SLO)$/RegressionCurveItemConverter.obj \ $(SLO)$/RegressionEquationItemConverter.obj \ - $(SLO)$/ErrorBarItemConverter.obj + $(SLO)$/ErrorBarItemConverter.obj \ + $(SLO)$/DiagramItemConverter.obj # --- Targets ----------------------------------------------------------------- diff --git a/chart2/source/controller/main/ChartController_Position.cxx b/chart2/source/controller/main/ChartController_Position.cxx index 4cf4de81480b..344335fe4bc1 100644 --- a/chart2/source/controller/main/ChartController_Position.cxx +++ b/chart2/source/controller/main/ChartController_Position.cxx @@ -133,17 +133,28 @@ void SAL_CALL ChartController::executeDispatch_PositionAndSize() if( !aCID.getLength() ) return; - awt::Size aSelectedSize; - ExplicitValueProvider* pProvider( ExplicitValueProvider::getExplicitValueProvider( m_xChartView ) ); - if( pProvider ) - aSelectedSize = ToSize( ( pProvider->getRectangleOfObject( aCID ) ) ); + ObjectType eObjectType = ObjectIdentifier::getObjectType( aCID ); UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::POS_SIZE, - ObjectNameProvider::getName( ObjectIdentifier::getObjectType( aCID ))), + ObjectNameProvider::getName( eObjectType )), m_xUndoManager, m_aModel->getModel() ); + if( OBJECTTYPE_DIAGRAM == eObjectType || OBJECTTYPE_DIAGRAM_WALL == eObjectType ) + { + rtl::OUString aDiaCID = ObjectIdentifier::createClassifiedIdentifierForParticle( ObjectIdentifier::createParticleForDiagram( ChartModelHelper::findDiagram( m_aModel->getModel() ), m_aModel->getModel() ) ); + bool bSuccess = executeDlg_ObjectProperties_withoutUndoGuard( aDiaCID, false ); + if( bSuccess ) + aUndoGuard.commitAction(); + return; + } + + awt::Size aSelectedSize; + ExplicitValueProvider* pProvider( ExplicitValueProvider::getExplicitValueProvider( m_xChartView ) ); + if( pProvider ) + aSelectedSize = ToSize( ( pProvider->getRectangleOfObject( aCID ) ) ); + SfxAbstractTabDialog * pDlg = NULL; try { diff --git a/chart2/source/controller/main/ChartController_Properties.cxx b/chart2/source/controller/main/ChartController_Properties.cxx index 754e66ec7d17..574cf68d9896 100644 --- a/chart2/source/controller/main/ChartController_Properties.cxx +++ b/chart2/source/controller/main/ChartController_Properties.cxx @@ -63,6 +63,7 @@ #include "Strings.hrc" #include "ReferenceSizeProvider.hxx" #include "RegressionCurveHelper.hxx" +#include "DiagramItemConverter.hxx" #include //for auto_ptr @@ -154,6 +155,9 @@ namespace case OBJECTTYPE_LEGEND_ENTRY: break; case OBJECTTYPE_DIAGRAM: + pItemConverter = new wrapper::DiagramItemConverter( + xObjectProperties, rDrawModel.GetItemPool(), + rDrawModel, xChartModel, rDrawModel.GetUIScale() ); break; case OBJECTTYPE_DIAGRAM_WALL: case OBJECTTYPE_DIAGRAM_FLOOR: diff --git a/chart2/source/controller/main/ChartController_Tools.cxx b/chart2/source/controller/main/ChartController_Tools.cxx index 8dca62d93ee1..ce1cf9aa7b43 100644 --- a/chart2/source/controller/main/ChartController_Tools.cxx +++ b/chart2/source/controller/main/ChartController_Tools.cxx @@ -273,6 +273,7 @@ void ChartController::executeDispatch_NewArrangement() Reference< beans::XPropertyState > xState( xDiagram, uno::UNO_QUERY_THROW ); xState->setPropertyToDefault( C2U("RelativeSize")); xState->setPropertyToDefault( C2U("RelativePosition")); + xState->setPropertyToDefault( C2U("PosSizeExcludeAxes")); // 3d rotation ThreeDHelper::set3DSettingsToDefault( uno::Reference< beans::XPropertySet >( xDiagram, uno::UNO_QUERY ) ); diff --git a/chart2/source/controller/main/PositionAndSizeHelper.cxx b/chart2/source/controller/main/PositionAndSizeHelper.cxx index a4a50af995a9..f2995370fe70 100644 --- a/chart2/source/controller/main/PositionAndSizeHelper.cxx +++ b/chart2/source/controller/main/PositionAndSizeHelper.cxx @@ -188,8 +188,11 @@ bool PositionAndSizeHelper::moveObject( const rtl::OUString& rObjectCID return false; //add axis title sizes to the diagram size - aNewPositionAndSize = ExplicitValueProvider::calculateDiagramPositionAndSizeInclusiveTitle( - xChartModel, xChartView, rNewPositionAndSize ); + bool bPosSizeExcludeAxes = false; + xObjectProp->getPropertyValue( C2U( "PosSizeExcludeAxes" ) ) >>= bPosSizeExcludeAxes; + if( !bPosSizeExcludeAxes ) + aNewPositionAndSize = ExplicitValueProvider::calculateDiagramPositionAndSizeIncludingTitle( + xChartModel, xChartView, rNewPositionAndSize ); } return moveObject( eObjectType, xObjectProp, aNewPositionAndSize, rPageRectangle ); } diff --git a/chart2/source/inc/DiagramHelper.hxx b/chart2/source/inc/DiagramHelper.hxx index 119d206a2937..bfbc7dd9980f 100644 --- a/chart2/source/inc/DiagramHelper.hxx +++ b/chart2/source/inc/DiagramHelper.hxx @@ -49,6 +49,13 @@ namespace chart { +enum DiagramPositioningMode +{ + DiagramPositioningMode_AUTO, + DiagramPositioningMode_INCLUDING, + DiagramPositioningMode_EXCLUDING +}; + class OOO_DLLPUBLIC_CHARTTOOLS DiagramHelper { public: @@ -324,6 +331,16 @@ public: const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartType >& xChartType ); + static DiagramPositioningMode getDiagramPositioningMode( const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XDiagram > & xDiagram ); + static bool setDiagramPositioningMode( const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XDiagram > & xDiagram, DiagramPositioningMode eMode ); + + static bool setDiagramPositioning( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xChartModel, + const ::com::sun::star::awt::Rectangle& rPosRect /*100th mm*/ ); + + static ::com::sun::star::awt::Rectangle getDiagramRectangleFromModel( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xChartModel ); + private: // not implemented DiagramHelper(); diff --git a/chart2/source/inc/ObjectIdentifier.hxx b/chart2/source/inc/ObjectIdentifier.hxx index 7793cd57d21e..63a2c0be8ea5 100644 --- a/chart2/source/inc/ObjectIdentifier.hxx +++ b/chart2/source/inc/ObjectIdentifier.hxx @@ -124,7 +124,7 @@ public: ::com::sun::star::frame::XModel >& xChartModel , sal_Int32 nSubIndex = -1 );//-1: main grid, 0: first subgrid etc - SAL_DLLPRIVATE static rtl::OUString createParticleForDiagram( + static rtl::OUString createParticleForDiagram( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram >& xDiagram , const ::com::sun::star::uno::Reference< diff --git a/chart2/source/inc/Strings.hrc b/chart2/source/inc/Strings.hrc index fea8bb867057..15157b4adbb5 100644 --- a/chart2/source/inc/Strings.hrc +++ b/chart2/source/inc/Strings.hrc @@ -34,7 +34,6 @@ #include //next free is 290 -//single free is: 134 //#define RID_APP_START 30000 ////#define STR_NULL (RID_APP_START + 1) @@ -299,6 +298,7 @@ #define STR_DLG_NUMBERFORMAT_FOR_PERCENTAGE_VALUE (RID_APP_START + 266) #define STR_PAGE_POSITIONING (RID_APP_START + 277) +#define STR_PAGE_POSITIONANDSIZE (RID_APP_START + 134) #define STR_PAGE_ASIAN (RID_APP_START + 281) //----------------------------------------------------------------------------- diff --git a/chart2/source/inc/chartview/ChartSfxItemIds.hxx b/chart2/source/inc/chartview/ChartSfxItemIds.hxx index e4afc0d9efbd..637a0f3b757d 100644 --- a/chart2/source/inc/chartview/ChartSfxItemIds.hxx +++ b/chart2/source/inc/chartview/ChartSfxItemIds.hxx @@ -58,7 +58,16 @@ #define SCHATTR_LEGEND_POS SCHATTR_LEGEND_START #define SCHATTR_LEGEND_END SCHATTR_LEGEND_POS -#define SCHATTR_TEXT_START (SCHATTR_LEGEND_END + 1) +#define SCHATTR_DIAGRAM_START (SCHATTR_LEGEND_END + 1) +#define SCHATTR_DIAGRAM_POS_MODE SCHATTR_DIAGRAM_START +#define SCHATTR_DIAGRAM_RECT_TO_USE SCHATTR_DIAGRAM_START + 1 +#define SCHATTR_DIAGRAM_RECT_INCLUDING SCHATTR_DIAGRAM_START + 2 +#define SCHATTR_DIAGRAM_RECT_EXCLUDING SCHATTR_DIAGRAM_START + 3 +#define SCHATTR_DIAGRAM_RECT_MAX SCHATTR_DIAGRAM_START + 4 +#define SCHATTR_DIAGRAM_UI_SCALE SCHATTR_DIAGRAM_START + 5 +#define SCHATTR_DIAGRAM_END SCHATTR_DIAGRAM_UI_SCALE + +#define SCHATTR_TEXT_START (SCHATTR_DIAGRAM_END + 1) // #define SCHATTR_TEXT_ORIENT SCHATTR_TEXT_START // name changed: #define SCHATTR_TEXT_STACKED SCHATTR_TEXT_START diff --git a/chart2/source/inc/chartview/ExplicitValueProvider.hxx b/chart2/source/inc/chartview/ExplicitValueProvider.hxx index ab94e7e1c337..ecd95fdcd5b8 100644 --- a/chart2/source/inc/chartview/ExplicitValueProvider.hxx +++ b/chart2/source/inc/chartview/ExplicitValueProvider.hxx @@ -71,6 +71,8 @@ public: virtual ::com::sun::star::awt::Rectangle getRectangleOfObject( const rtl::OUString& rObjectCID, bool bSnapRect=false )=0; + virtual ::com::sun::star::awt::Rectangle getDiagramRectangleExcludingAxes()=0; + virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > getShapeForCID( const rtl::OUString& rObjectCID )=0; @@ -80,12 +82,12 @@ public: static ExplicitValueProvider* getExplicitValueProvider( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xChartView ); static ::com::sun::star::awt::Rectangle - calculateDiagramPositionAndSizeInclusiveTitle( + calculateDiagramPositionAndSizeIncludingTitle( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xChartModel , const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xChartView - , const ::com::sun::star::awt::Rectangle& rExclusivePositionAndSize ); + , const ::com::sun::star::awt::Rectangle& rExcludingPositionAndSize ); static sal_Int32 getExplicitNumberFormatKeyForAxis( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis >& xAxis diff --git a/chart2/source/model/main/Diagram.cxx b/chart2/source/model/main/Diagram.cxx index 3e8c8ea9cd24..f01e8611f59b 100644 --- a/chart2/source/model/main/Diagram.cxx +++ b/chart2/source/model/main/Diagram.cxx @@ -75,6 +75,7 @@ enum { PROP_DIAGRAM_REL_POS, PROP_DIAGRAM_REL_SIZE, + PROP_DIAGRAM_POSSIZE_EXCLUDE_LABELS, PROP_DIAGRAM_SORT_BY_X_VALUES, PROP_DIAGRAM_CONNECT_BARS, PROP_DIAGRAM_GROUP_BARS_PER_AXIS, @@ -104,6 +105,13 @@ void lcl_AddPropertiesToVector( beans::PropertyAttribute::BOUND | beans::PropertyAttribute::MAYBEVOID )); + rOutProperties.push_back( + Property( C2U( "PosSizeExcludeAxes" ), + PROP_DIAGRAM_POSSIZE_EXCLUDE_LABELS, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + rOutProperties.push_back( Property( C2U( "SortByXValues" ), PROP_DIAGRAM_SORT_BY_X_VALUES, @@ -175,6 +183,7 @@ void lcl_AddPropertiesToVector( void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap ) { + ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_POSSIZE_EXCLUDE_LABELS, false ); ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_SORT_BY_X_VALUES, false ); ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_CONNECT_BARS, false ); ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_GROUP_BARS_PER_AXIS, true ); diff --git a/chart2/source/tools/DiagramHelper.cxx b/chart2/source/tools/DiagramHelper.cxx index fbc8042af27b..e1d8a78eb4f6 100644 --- a/chart2/source/tools/DiagramHelper.cxx +++ b/chart2/source/tools/DiagramHelper.cxx @@ -40,6 +40,8 @@ #include "ChartTypeHelper.hxx" #include "CommonConverters.hxx" #include "servicenames_charttypes.hxx" +#include "ChartModelHelper.hxx" +#include "RelativePositionHelper.hxx" #include #include @@ -50,6 +52,8 @@ #include #include #include +#include +#include #include #include @@ -1432,4 +1436,160 @@ sal_Int32 DiagramHelper::getCorrectedMissingValueTreatment( return nResult; } +//static +DiagramPositioningMode DiagramHelper::getDiagramPositioningMode( const uno::Reference< + chart2::XDiagram > & xDiagram ) +{ + DiagramPositioningMode eMode = DiagramPositioningMode_AUTO; + uno::Reference< beans::XPropertySet > xDiaProps( xDiagram, uno::UNO_QUERY ); + if( xDiaProps.is() ) + { + RelativePosition aRelPos; + RelativeSize aRelSize; + if( (xDiaProps->getPropertyValue(C2U("RelativePosition")) >>= aRelPos ) && + (xDiaProps->getPropertyValue(C2U("RelativeSize")) >>= aRelSize ) ) + { + bool bPosSizeExcludeAxes=false; + xDiaProps->getPropertyValue(C2U("PosSizeExcludeAxes")) >>= bPosSizeExcludeAxes; + if( bPosSizeExcludeAxes ) + eMode = DiagramPositioningMode_EXCLUDING; + else + eMode = DiagramPositioningMode_INCLUDING; + } + } + return eMode; +} + +//static +bool DiagramHelper::setDiagramPositioningMode( const uno::Reference< + chart2::XDiagram > & xDiagram, DiagramPositioningMode eMode ) +{ + bool bChanged = false; + uno::Reference< beans::XPropertySet > xDiaProps( xDiagram, uno::UNO_QUERY ); + if( !xDiaProps.is() ) + return bChanged; + + bool bOld = false; + xDiaProps->getPropertyValue(C2U("PosSizeExcludeAxes")) >>= bOld; + bool bNew = bOld; + + if( eMode == DiagramPositioningMode_AUTO ) + { + + RelativePosition aPos; + if( (xDiaProps->getPropertyValue(C2U("RelativePosition") ) >>= aPos) ) + bChanged = true; + if( !bChanged ) + { + RelativeSize aSize; + if( (xDiaProps->getPropertyValue(C2U("RelativeSize") ) >>= aSize) ) + bChanged = true; + } + + if( bChanged ) + { + xDiaProps->setPropertyValue(C2U("RelativePosition"), uno::Any() ); + xDiaProps->setPropertyValue(C2U("RelativeSize"), uno::Any() ); + } + } + else if( eMode == DiagramPositioningMode_EXCLUDING ) + { + bNew = true; + bChanged = (bNew!=bOld); + if(bChanged) + xDiaProps->setPropertyValue(C2U("PosSizeExcludeAxes"), uno::makeAny(bNew) ); + } + else if( eMode == DiagramPositioningMode_INCLUDING) + { + bNew = false; + bChanged = (bNew!=bOld); + if(bChanged) + xDiaProps->setPropertyValue(C2U("PosSizeExcludeAxes"), uno::makeAny(bNew) ); + } + return bChanged; +} + +void lcl_ensureRange0to1( double& rValue ) +{ + if(rValue<0.0) + rValue=0.0; + if(rValue>1.0) + rValue=1.0; +} + +//static +bool DiagramHelper::setDiagramPositioning( const uno::Reference< frame::XModel >& xChartModel, + const awt::Rectangle& rPosRect /*100th mm*/ ) +{ + bool bChanged = false; + awt::Size aPageSize( ChartModelHelper::getPageSize(xChartModel) ); + uno::Reference< beans::XPropertySet > xDiaProps( ChartModelHelper::findDiagram( xChartModel ), uno::UNO_QUERY ); + if( !xDiaProps.is() ) + return bChanged; + + RelativePosition aOldPos; + RelativeSize aOldSize; + xDiaProps->getPropertyValue(C2U("RelativePosition") ) >>= aOldPos; + xDiaProps->getPropertyValue(C2U("RelativeSize") ) >>= aOldSize; + + RelativePosition aNewPos; + aNewPos.Anchor = drawing::Alignment_TOP_LEFT; + aNewPos.Primary = double(rPosRect.X)/double(aPageSize.Width); + aNewPos.Secondary = double(rPosRect.Y)/double(aPageSize.Height); + + chart2::RelativeSize aNewSize; + aNewSize.Primary = double(rPosRect.Width)/double(aPageSize.Width); + aNewSize.Secondary = double(rPosRect.Height)/double(aPageSize.Height); + + lcl_ensureRange0to1( aNewPos.Primary ); + lcl_ensureRange0to1( aNewPos.Secondary ); + lcl_ensureRange0to1( aNewSize.Primary ); + lcl_ensureRange0to1( aNewSize.Secondary ); + if( (aNewPos.Primary + aNewSize.Primary) > 1.0 ) + aNewPos.Primary = 1.0 - aNewSize.Primary; + if( (aNewPos.Secondary + aNewSize.Secondary) > 1.0 ) + aNewPos.Secondary = 1.0 - aNewSize.Secondary; + + xDiaProps->setPropertyValue( C2U( "RelativePosition" ), uno::makeAny(aNewPos) ); + xDiaProps->setPropertyValue( C2U( "RelativeSize" ), uno::makeAny(aNewSize) ); + + bChanged = (aOldPos.Anchor!=aNewPos.Anchor) || + (aOldPos.Primary!=aNewPos.Primary) || + (aOldPos.Secondary!=aNewPos.Secondary) || + (aOldSize.Primary!=aNewSize.Primary) || + (aOldSize.Secondary!=aNewSize.Secondary); + return bChanged; +} + +//static +awt::Rectangle DiagramHelper::getDiagramRectangleFromModel( const uno::Reference< frame::XModel >& xChartModel ) +{ + awt::Rectangle aRet(-1,-1,-1,-1); + + uno::Reference< beans::XPropertySet > xDiaProps( ChartModelHelper::findDiagram( xChartModel ), uno::UNO_QUERY ); + if( !xDiaProps.is() ) + return aRet; + + awt::Size aPageSize( ChartModelHelper::getPageSize(xChartModel) ); + + RelativePosition aRelPos; + RelativeSize aRelSize; + xDiaProps->getPropertyValue(C2U("RelativePosition") ) >>= aRelPos; + xDiaProps->getPropertyValue(C2U("RelativeSize") ) >>= aRelSize; + + awt::Size aAbsSize( + aRelSize.Primary * aPageSize.Width, + aRelSize.Secondary * aPageSize.Height ); + + awt::Point aAbsPos( + static_cast< sal_Int32 >( aRelPos.Primary * aPageSize.Width ), + static_cast< sal_Int32 >( aRelPos.Secondary * aPageSize.Height )); + + awt::Point aAbsPosLeftTop = RelativePositionHelper::getUpperLeftCornerOfAnchoredObject( aAbsPos, aAbsSize, aRelPos.Anchor ); + + aRet = awt::Rectangle(aAbsPosLeftTop.X, aAbsPosLeftTop.Y, aAbsSize.Width, aAbsSize.Height ); + + return aRet; +} + } // namespace chart diff --git a/chart2/source/view/charttypes/PieChart.cxx b/chart2/source/view/charttypes/PieChart.cxx index 608adb49290b..9bce64ad7395 100644 --- a/chart2/source/view/charttypes/PieChart.cxx +++ b/chart2/source/view/charttypes/PieChart.cxx @@ -124,10 +124,12 @@ bool PiePositionHelper::getInnerAndOuterRadius( double fCategoryX //----------------------------------------------------------------------------- PieChart::PieChart( const uno::Reference& xChartTypeModel - , sal_Int32 nDimensionCount ) + , sal_Int32 nDimensionCount + , bool bExcludingPositioning ) : VSeriesPlotter( xChartTypeModel, nDimensionCount ) , m_pPosHelper( new PiePositionHelper( NormalAxis_Z, (m_nDimension==3)?0.0:90.0 ) ) , m_bUseRings(false) + , m_bSizeExcludesLabelsAndExplodedSegments(bExcludingPositioning) { PlotterBase::m_pPosHelper = m_pPosHelper; VSeriesPlotter::m_pMainPosHelper = m_pPosHelper; @@ -182,6 +184,11 @@ bool PieChart::keepAspectRatio() const return true; } +bool PieChart::shouldSnapRectToUsedArea() +{ + return true; +} + //----------------------------------------------------------------- // lang::XServiceInfo //----------------------------------------------------------------- @@ -289,7 +296,7 @@ double PieChart::getMaxOffset() const } double PieChart::getMaximumX() { - double fMaxOffset = getMaxOffset(); + double fMaxOffset = m_bSizeExcludesLabelsAndExplodedSegments ? 0.0 : getMaxOffset(); if( m_aZSlots.size()>0 && m_bUseRings) return m_aZSlots[0].size()+0.5+fMaxOffset; return 1.5+fMaxOffset; @@ -392,7 +399,8 @@ void PieChart::createShapes() for( nPointIndex = 0; nPointIndex < nPointCount; nPointIndex++ ) { double fLogicInnerRadius, fLogicOuterRadius; - bool bIsVisible = m_pPosHelper->getInnerAndOuterRadius( fSlotX+1.0, fLogicInnerRadius, fLogicOuterRadius, m_bUseRings, getMaxOffset() ); + double fOffset = m_bSizeExcludesLabelsAndExplodedSegments ? 0.0 : getMaxOffset(); + bool bIsVisible = m_pPosHelper->getInnerAndOuterRadius( fSlotX+1.0, fLogicInnerRadius, fLogicOuterRadius, m_bUseRings, fOffset ); if( !bIsVisible ) continue; diff --git a/chart2/source/view/charttypes/PieChart.hxx b/chart2/source/view/charttypes/PieChart.hxx index e65cfdcc5626..b358e6b21fdb 100644 --- a/chart2/source/view/charttypes/PieChart.hxx +++ b/chart2/source/view/charttypes/PieChart.hxx @@ -49,7 +49,7 @@ class PieChart : public VSeriesPlotter public: PieChart( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartType >& xChartTypeModel - , sal_Int32 nDimensionCount ); + , sal_Int32 nDimensionCount, bool bExcludingPositioning ); virtual ~PieChart(); //------------------------------------------------------------------------- @@ -75,6 +75,7 @@ public: //------------------- virtual ::com::sun::star::drawing::Direction3D getPreferredDiagramAspectRatio() const; virtual bool keepAspectRatio() const; + virtual bool shouldSnapRectToUsedArea(); //MinimumAndMaximumSupplier virtual double getMinimumX(); @@ -116,6 +117,7 @@ struct PieLabelInfo; private: //member PiePositionHelper* m_pPosHelper; bool m_bUseRings; + bool m_bSizeExcludesLabelsAndExplodedSegments; struct PieLabelInfo { diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx b/chart2/source/view/charttypes/VSeriesPlotter.cxx index c8f473d226d0..63933c6254cc 100644 --- a/chart2/source/view/charttypes/VSeriesPlotter.cxx +++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx @@ -1731,6 +1731,13 @@ bool VSeriesPlotter::WantToPlotInFrontOfAxisLine() return ChartTypeHelper::isSeriesInFrontOfAxisLine( m_xChartTypeModel ); } +bool VSeriesPlotter::shouldSnapRectToUsedArea() +{ + if( m_nDimension == 3 ) + return false; + return true; +} + Sequence< ViewLegendEntry > SAL_CALL VSeriesPlotter::createLegendEntries( LegendExpansion eLegendExpansion , const Reference< beans::XPropertySet >& xTextProperties @@ -2053,7 +2060,8 @@ std::vector< ViewLegendEntry > SAL_CALL VSeriesPlotter::createLegendEntriesForCh //static VSeriesPlotter* VSeriesPlotter::createSeriesPlotter( const uno::Reference& xChartTypeModel - , sal_Int32 nDimensionCount ) + , sal_Int32 nDimensionCount + , bool bExcludingPositioning ) { rtl::OUString aChartType = xChartTypeModel->getChartType(); @@ -2072,7 +2080,7 @@ VSeriesPlotter* VSeriesPlotter::createSeriesPlotter( else if( aChartType.equalsIgnoreAsciiCase(CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE) ) pRet = new BubbleChart(xChartTypeModel,nDimensionCount); else if( aChartType.equalsIgnoreAsciiCase(CHART2_SERVICE_NAME_CHARTTYPE_PIE) ) - pRet = new PieChart(xChartTypeModel,nDimensionCount); + pRet = new PieChart(xChartTypeModel,nDimensionCount, bExcludingPositioning ); else if( aChartType.equalsIgnoreAsciiCase(CHART2_SERVICE_NAME_CHARTTYPE_NET) ) pRet = new AreaChart(xChartTypeModel,nDimensionCount,true,true,new PolarPlottingPositionHelper(),true,true,false,1,drawing::Direction3D(1,1,1) ); else if( aChartType.equalsIgnoreAsciiCase(CHART2_SERVICE_NAME_CHARTTYPE_FILLED_NET) ) diff --git a/chart2/source/view/diagram/VDiagram.cxx b/chart2/source/view/diagram/VDiagram.cxx index 5e0db2644cc5..65d603aaf05f 100644 --- a/chart2/source/view/diagram/VDiagram.cxx +++ b/chart2/source/view/diagram/VDiagram.cxx @@ -52,6 +52,8 @@ #include // header for class SvxShape #include +// header for GetSdrObjectFromXShape +#include // header for class E3dScene #include #include @@ -182,6 +184,8 @@ void VDiagram::createShapes_2d() uno::Reference< drawing::XShapes > xOuterGroup_Shapes = m_pShapeFactory->createGroup2D(m_xLogicTarget); m_xOuterGroupShape = uno::Reference( xOuterGroup_Shapes, uno::UNO_QUERY ); + uno::Reference< drawing::XShapes > xGroupForWall( m_pShapeFactory->createGroup2D(xOuterGroup_Shapes,C2U("PlotAreaExcludingAxes")) ); + //create independent group shape as container for datapoints and such things { uno::Reference< drawing::XShapes > xShapes = m_pShapeFactory->createGroup2D(xOuterGroup_Shapes,C2U("testonly;CooContainer=XXX_CID")); @@ -198,8 +202,7 @@ void VDiagram::createShapes_2d() "com.sun.star.drawing.RectangleShape" ) ), uno::UNO_QUERY ); //m_xWall2D->setPosition(m_aAvailablePosIncludingAxes); //m_xWall2D->setSize(m_aAvailableSizeIncludingAxes); - uno::Reference< drawing::XShapes > xShapes( m_xCoordinateRegionShape, uno::UNO_QUERY ); - xShapes->add(m_xWall2D); + xGroupForWall->add(m_xWall2D); uno::Reference< beans::XPropertySet > xProp( m_xWall2D, uno::UNO_QUERY ); if( xProp.is()) { @@ -521,6 +524,7 @@ void VDiagram::createShapes_3d() m_xOuterGroupShape = uno::Reference< drawing::XShape >( m_xShapeFactory->createInstance( C2U( "com.sun.star.drawing.Shape3DSceneObject" ) ), uno::UNO_QUERY ); + ShapeFactory::setShapeName( m_xOuterGroupShape, C2U("PlotAreaExcludingAxes") ); m_xLogicTarget->add(m_xOuterGroupShape); uno::Reference< drawing::XShapes > xOuterGroup_Shapes = diff --git a/chart2/source/view/inc/VSeriesPlotter.hxx b/chart2/source/view/inc/VSeriesPlotter.hxx index e94ef6c68687..3fddf7bb8d96 100644 --- a/chart2/source/view/inc/VSeriesPlotter.hxx +++ b/chart2/source/view/inc/VSeriesPlotter.hxx @@ -267,7 +267,8 @@ public: static VSeriesPlotter* createSeriesPlotter( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartType >& xChartTypeModel - , sal_Int32 nDimensionCount ); + , sal_Int32 nDimensionCount + , bool bExcludingPositioning = false /*for pie and donut charts labels and exploded segments are excluded from the given size*/); sal_Int32 getPointCount() const; @@ -297,6 +298,7 @@ public: virtual void rearrangeLabelToAvoidOverlapIfRequested( const ::com::sun::star::awt::Size& rPageSize ); bool WantToPlotInFrontOfAxisLine(); + virtual bool shouldSnapRectToUsedArea(); //------------------------------------------------------------------------- //------------------------------------------------------------------------- diff --git a/chart2/source/view/main/ChartItemPool.cxx b/chart2/source/view/main/ChartItemPool.cxx index f3024a10e958..2810ad1e8d89 100644 --- a/chart2/source/view/main/ChartItemPool.cxx +++ b/chart2/source/view/main/ChartItemPool.cxx @@ -41,6 +41,7 @@ #include // header for class SfxStringItem #include +#include //SfxIntegerListItem #include #define _SVSTDARR_ULONGS @@ -69,6 +70,13 @@ ChartItemPool::ChartItemPool(): ppPoolDefaults[SCHATTR_DATADESCR_NO_PERCENTVALUE - SCHATTR_START] = new SfxBoolItem(SCHATTR_DATADESCR_NO_PERCENTVALUE); ppPoolDefaults[SCHATTR_LEGEND_POS - SCHATTR_START] = new SvxChartLegendPosItem( CHLEGEND_RIGHT, SCHATTR_LEGEND_POS ); + ppPoolDefaults[SCHATTR_DIAGRAM_POS_MODE - SCHATTR_START] = new SfxInt32Item( SCHATTR_DIAGRAM_POS_MODE,0 ); + ppPoolDefaults[SCHATTR_DIAGRAM_RECT_TO_USE - SCHATTR_START] = new SfxRectangleItem( SCHATTR_DIAGRAM_RECT_TO_USE, Rectangle(0,0,100,100) ); + ppPoolDefaults[SCHATTR_DIAGRAM_RECT_INCLUDING - SCHATTR_START] = new SfxRectangleItem( SCHATTR_DIAGRAM_RECT_INCLUDING, Rectangle(0,0,100,100) ); + ppPoolDefaults[SCHATTR_DIAGRAM_RECT_EXCLUDING - SCHATTR_START] = new SfxRectangleItem( SCHATTR_DIAGRAM_RECT_EXCLUDING, Rectangle(0,0,100,100) ); + ppPoolDefaults[SCHATTR_DIAGRAM_RECT_MAX - SCHATTR_START] = new SfxRectangleItem( SCHATTR_DIAGRAM_RECT_MAX, Rectangle(0,0,100,100) ); + ppPoolDefaults[SCHATTR_DIAGRAM_UI_SCALE - SCHATTR_START] = new SvxDoubleItem(1.0, SCHATTR_DIAGRAM_UI_SCALE); + // ppPoolDefaults[SCHATTR_TEXT_ORIENT - SCHATTR_START] = new SvxChartTextOrientItem; ppPoolDefaults[SCHATTR_TEXT_STACKED - SCHATTR_START] = new SfxBoolItem(SCHATTR_TEXT_STACKED,FALSE); ppPoolDefaults[SCHATTR_TEXT_ORDER - SCHATTR_START] = new SvxChartTextOrderItem(CHTXTORDER_SIDEBYSIDE, SCHATTR_TEXT_ORDER); diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx index dfd57f9bce92..fddb8edc95c4 100644 --- a/chart2/source/view/main/ChartView.cxx +++ b/chart2/source/view/main/ChartView.cxx @@ -170,6 +170,7 @@ ChartView::ChartView( , m_nScaleYNumerator(1) , m_nScaleYDenominator(1) , m_bSdrViewIsInEditMode(sal_False) + , m_aResultingDiagramRectangleExcludingAxes(0,0,0,0) { } @@ -678,7 +679,8 @@ void SeriesPlotterContainer::initializeCooSysAndSeriesPlotter( if(nT==0) m_bShiftXAxisTicks = ChartTypeHelper::shiftTicksAtXAxisPerDefault( xChartType ); - VSeriesPlotter* pPlotter = VSeriesPlotter::createSeriesPlotter( xChartType, nDimensionCount ); + bool bExcludingPositioning = DiagramPositioningMode_EXCLUDING == DiagramHelper::getDiagramPositioningMode( xDiagram ); + VSeriesPlotter* pPlotter = VSeriesPlotter::createSeriesPlotter( xChartType, nDimensionCount, bExcludingPositioning ); if( !pPlotter ) continue; m_aSeriesPlotterList.push_back( pPlotter ); @@ -1161,7 +1163,7 @@ drawing::Direction3D SeriesPlotterContainer::getPreferredAspectRatio() namespace { -bool lcl_resizeAfterCompleteCreation( const uno::Reference< XDiagram >& xDiagram ) +bool lcl_IsPieOrDonut( const uno::Reference< XDiagram >& xDiagram ) { //special treatment for pie charts //the size is checked after complete creation to get the datalabels into the given space @@ -1319,16 +1321,23 @@ sal_Int16 lcl_getDefaultWritingModeFromPool( ::boost::shared_ptr< DrawModelWrapp } //end anonymous namespace //------------ create complete diagram shape (inclusive axis and series) -void ChartView::impl_createDiagramAndContent( SeriesPlotterContainer& rSeriesPlotterContainer + +awt::Rectangle ChartView::impl_createDiagramAndContent( SeriesPlotterContainer& rSeriesPlotterContainer , const uno::Reference< drawing::XShapes>& xDiagramPlusAxes_Shapes , const awt::Point& rAvailablePos , const awt::Size& rAvailableSize - , const awt::Size& rPageSize ) + , const awt::Size& rPageSize + , bool bUseFixedInnerSize + , const uno::Reference< drawing::XShape>& xDiagram_MarkHandles /*needs to be resized to fit the result*/ + ) { + //return the used rectangle + awt::Rectangle aUsedOuterRect( rAvailablePos.X, rAvailablePos.Y, 0, 0 ); + // sal_Int32 nDiagramIndex = 0;//todo if more than one diagam is supported uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( m_xChartModel ) ); if( !xDiagram.is()) - return; + return aUsedOuterRect; sal_Int32 nDimensionCount = DiagramHelper::getDimension( xDiagram ); if(!nDimensionCount) @@ -1384,7 +1393,8 @@ void ChartView::impl_createDiagramAndContent( SeriesPlotterContainer& rSeriesPlo aVDiagram.init(xDiagramPlusAxes_Shapes,xDiagramPlusAxes_Shapes,m_xShapeFactory); aVDiagram.createShapes(rAvailablePos,rAvailableSize); xSeriesTargetInFrontOfAxis = aVDiagram.getCoordinateRegion(); - aVDiagram.reduceToMimimumSize(); + if( !bUseFixedInnerSize ) + aVDiagram.reduceToMimimumSize(); } uno::Reference< drawing::XShapes > xTextTargetShapes( ShapeFactory(m_xShapeFactory).createGroup2D(xDiagramPlusAxes_Shapes) ); @@ -1405,19 +1415,21 @@ void ChartView::impl_createDiagramAndContent( SeriesPlotterContainer& rSeriesPlo //calculate resulting size respecting axis label layout and fontscaling + uno::Reference< drawing::XShape > xBoundingShape( xDiagramPlusAxes_Shapes, uno::UNO_QUERY ); + ::basegfx::B2IRectangle aConsumedOuterRect; + //use first coosys only so far; todo: calculate for more than one coosys if we have more in future //todo: this is just a workaround at the moment for pie and donut labels - if( !lcl_resizeAfterCompleteCreation(xDiagram) && rVCooSysList.size() > 0 ) + bool bIsPieOrDonut = lcl_IsPieOrDonut(xDiagram); + if( !bIsPieOrDonut && rVCooSysList.size() > 0 ) { - uno::Reference< drawing::XShape > xBoundingShape( xDiagramPlusAxes_Shapes, uno::UNO_QUERY ); - - ::basegfx::B2IRectangle aFirstConsumedOuterRect( ShapeFactory::getRectangleOfShape(xBoundingShape) ); - VCoordinateSystem* pVCooSys = rVCooSysList[0]; pVCooSys->createMaximumAxesLabels(); - ::basegfx::B2IRectangle aConsumedOuterRect( ShapeFactory::getRectangleOfShape(xBoundingShape) ); - ::basegfx::B2IRectangle aNewInnerRect( aVDiagram.adjustInnerSize( aConsumedOuterRect ) ); + aConsumedOuterRect = ::basegfx::B2IRectangle( ShapeFactory::getRectangleOfShape(xBoundingShape) ); + ::basegfx::B2IRectangle aNewInnerRect( aVDiagram.getCurrentRectangle() ); + if( !bUseFixedInnerSize ) + aNewInnerRect = aVDiagram.adjustInnerSize( aConsumedOuterRect ); pVCooSys->setTransformationSceneToScreen( B3DHomMatrixToHomogenMatrix( createTransformationSceneToScreen( aNewInnerRect ) )); @@ -1440,13 +1452,13 @@ void ChartView::impl_createDiagramAndContent( SeriesPlotterContainer& rSeriesPlo bLessSpaceConsumedThanExpected = true; } - if( bLessSpaceConsumedThanExpected ) + if( bLessSpaceConsumedThanExpected && !bUseFixedInnerSize ) { aVDiagram.adjustInnerSize( aConsumedOuterRect ); pVCooSys->setTransformationSceneToScreen( B3DHomMatrixToHomogenMatrix( createTransformationSceneToScreen( aVDiagram.getCurrentRectangle() ) )); - pVCooSys->updatePositions(); } + pVCooSys->updatePositions();//todo: logically this belongs to the condition above, but it seems also to be neccessary to give the axes group shapes the right bounding rects for hit test - probably caused by bug i106183 -> check again if fixed } //create axes and grids for the final size @@ -1476,7 +1488,7 @@ void ChartView::impl_createDiagramAndContent( SeriesPlotterContainer& rSeriesPlo else { xSeriesTarget = xSeriesTargetBehindAxis; - DBG_ASSERT( !lcl_resizeAfterCompleteCreation(xDiagram), "not implemented yet! - during a complete recreation this shape is destroyed so no series can be created anymore" ); + DBG_ASSERT( !bIsPieOrDonut, "not implemented yet! - during a complete recreation this shape is destroyed so no series can be created anymore" ); } pSeriesPlotter->initPlotter( xSeriesTarget,xTextTargetShapes,m_xShapeFactory,aCID ); pSeriesPlotter->setPageReferenceSize( rPageSize ); @@ -1495,15 +1507,15 @@ void ChartView::impl_createDiagramAndContent( SeriesPlotterContainer& rSeriesPlo m_bPointsWereSkipped = m_bPointsWereSkipped || pSeriesPlotter->PointsWereSkipped(); } - //recreate with corrected sizes if requested - if( lcl_resizeAfterCompleteCreation(xDiagram) ) + //recreate all with corrected sizes if requested + if( bIsPieOrDonut ) { m_bPointsWereSkipped = false; - uno::Reference< drawing::XShape > xBoundingShape( xDiagramPlusAxes_Shapes, uno::UNO_QUERY ); - ::basegfx::B2IRectangle aConsumedOuterRect( ShapeFactory::getRectangleOfShape(xBoundingShape) ); - - ::basegfx::B2IRectangle aNewInnerRect( aVDiagram.adjustInnerSize( aConsumedOuterRect ) ); + aConsumedOuterRect = ::basegfx::B2IRectangle( ShapeFactory::getRectangleOfShape(xBoundingShape) ); + ::basegfx::B2IRectangle aNewInnerRect( aVDiagram.getCurrentRectangle() ); + if( !bUseFixedInnerSize ) + aNewInnerRect = aVDiagram.adjustInnerSize( aConsumedOuterRect ); for( aPlotterIter = rSeriesPlotterList.begin(); aPlotterIter != aPlotterEnd; aPlotterIter++ ) { @@ -1560,6 +1572,53 @@ void ChartView::impl_createDiagramAndContent( SeriesPlotterContainer& rSeriesPlo pSeriesPlotter->rearrangeLabelToAvoidOverlapIfRequested( rPageSize ); } } + + if( bUseFixedInnerSize ) + { + //if( !bIsPieOrDonut ) + // aConsumedOuterRect = ::basegfx::B2IRectangle( ShapeFactory::getRectangleOfShape(xBoundingShape) ); + aUsedOuterRect = awt::Rectangle( aConsumedOuterRect.getMinX(), aConsumedOuterRect.getMinY(), aConsumedOuterRect.getWidth(), aConsumedOuterRect.getHeight() ); + } + else + aUsedOuterRect = awt::Rectangle( rAvailablePos.X, rAvailablePos.Y, rAvailableSize.Width, rAvailableSize.Height ); + + bool bSnapRectToUsedArea = false; + for( aPlotterIter = rSeriesPlotterList.begin(); aPlotterIter != aPlotterEnd; aPlotterIter++ ) + { + VSeriesPlotter* pSeriesPlotter = *aPlotterIter; + bSnapRectToUsedArea = pSeriesPlotter->shouldSnapRectToUsedArea(); + if(bSnapRectToUsedArea) + break; + } + if(bSnapRectToUsedArea) + { + if( bUseFixedInnerSize ) + m_aResultingDiagramRectangleExcludingAxes = getRectangleOfObject( C2U("PlotAreaExcludingAxes") ); + else + { + ::basegfx::B2IRectangle aConsumedInnerRect = aVDiagram.getCurrentRectangle(); + m_aResultingDiagramRectangleExcludingAxes = awt::Rectangle( aConsumedInnerRect.getMinX(), aConsumedInnerRect.getMinY(), aConsumedInnerRect.getWidth(), aConsumedInnerRect.getHeight() ); + } + } + else + { + m_aResultingDiagramRectangleExcludingAxes = awt::Rectangle( rAvailablePos.X, rAvailablePos.Y, rAvailableSize.Width, rAvailableSize.Height ); + } + + if( xDiagram_MarkHandles.is() ) + { + awt::Point aPos(rAvailablePos); + awt::Size aSize(rAvailableSize); + if( bUseFixedInnerSize ) + { + aPos = awt::Point( m_aResultingDiagramRectangleExcludingAxes.X, m_aResultingDiagramRectangleExcludingAxes.Y ); + aSize = awt::Size( m_aResultingDiagramRectangleExcludingAxes.Width, m_aResultingDiagramRectangleExcludingAxes.Height ); + } + xDiagram_MarkHandles->setPosition( aPos ); + xDiagram_MarkHandles->setSize( aSize ); + } + + return aUsedOuterRect; } //------------------------------------------------------------- @@ -1617,6 +1676,12 @@ uno::Reference< drawing::XShape > ChartView::getShapeForCID( const rtl::OUString return 0; } +awt::Rectangle ChartView::getDiagramRectangleExcludingAxes() +{ + impl_updateView(); + return m_aResultingDiagramRectangleExcludingAxes; +} + awt::Rectangle ChartView::getRectangleOfObject( const rtl::OUString& rObjectCID, bool bSnapRect ) { impl_updateView(); @@ -1640,7 +1705,10 @@ awt::Rectangle ChartView::getRectangleOfObject( const rtl::OUString& rObjectCID, SdrObjList* pRootList = pRootSdrObject->GetSubList(); if( pRootList ) { - SdrObject* pShape = DrawModelWrapper::getNamedSdrObject( C2U("MarkHandles"), pRootList ); + OUString aShapeName = C2U("MarkHandles"); + if( eObjectType == OBJECTTYPE_DIAGRAM ) + aShapeName = C2U("PlotAreaIncludingAxes"); + SdrObject* pShape = DrawModelWrapper::getNamedSdrObject( aShapeName, pRootList ); if( pShape ) xShape = uno::Reference< drawing::XShape >( pShape->getUnoShape(), uno::UNO_QUERY); } @@ -1927,12 +1995,12 @@ sal_Int32 ExplicitValueProvider::getExplicitPercentageNumberFormatKeyForDataLabe } //static -awt::Rectangle ExplicitValueProvider::calculateDiagramPositionAndSizeInclusiveTitle( +awt::Rectangle ExplicitValueProvider::calculateDiagramPositionAndSizeIncludingTitle( const Reference< frame::XModel >& xChartModel , const Reference< uno::XInterface >& xChartView - , const awt::Rectangle& rExclusivePositionAndSize ) + , const awt::Rectangle& rExcludingPositionAndSize ) { - awt::Rectangle aRet(rExclusivePositionAndSize); + awt::Rectangle aRet(rExcludingPositionAndSize); //add axis title sizes to the diagram size uno::Reference< chart2::XTitle > xTitle_Height( TitleHelper::getTitle( TitleHelper::TITLE_AT_STANDARD_X_AXIS_POSITION, xChartModel ) ); @@ -2005,8 +2073,11 @@ bool getAvailablePosAndSizeForDiagram( , const awt::Size & rPageSize , const uno::Reference< XDiagram > & xDiagram , VTitle* pXTitle, VTitle* pYTitle - , VTitle* pSecondXTitle, VTitle* pSecondYTitle ) + , VTitle* pSecondXTitle, VTitle* pSecondYTitle + , bool& bUseFixedInnerSize ) { + bUseFixedInnerSize = false; + //@todo: we need a size dependent on the axis labels awt::Rectangle aRemainingSpace(rSpaceLeft); { @@ -2023,6 +2094,9 @@ bool getAvailablePosAndSizeForDiagram( uno::Reference< beans::XPropertySet > xProp(xDiagram, uno::UNO_QUERY); bool bMakeRoomForTitle = false; + bool bPosSizeExcludeAxes = false; + if( xProp.is() ) + xProp->getPropertyValue( C2U( "PosSizeExcludeAxes" ) ) >>= bPosSizeExcludeAxes; //size: ::com::sun::star::chart2::RelativeSize aRelativeSize; @@ -2030,7 +2104,8 @@ bool getAvailablePosAndSizeForDiagram( { rOutAvailableDiagramSize.Height = static_cast(aRelativeSize.Secondary*rPageSize.Height); rOutAvailableDiagramSize.Width = static_cast(aRelativeSize.Primary*rPageSize.Width); - bMakeRoomForTitle = true; + bMakeRoomForTitle = !bPosSizeExcludeAxes; + bUseFixedInnerSize = bPosSizeExcludeAxes; } else rOutAvailableDiagramSize = awt::Size(aRemainingSpace.Width,aRemainingSpace.Height); @@ -2048,7 +2123,8 @@ bool getAvailablePosAndSizeForDiagram( rOutPos = RelativePositionHelper::getUpperLeftCornerOfAnchoredObject( awt::Point(static_cast(fX),static_cast(fY)) , rOutAvailableDiagramSize, aRelativePosition.Anchor ); - bMakeRoomForTitle = true; + bMakeRoomForTitle = !bPosSizeExcludeAxes; + bUseFixedInnerSize = bPosSizeExcludeAxes; } else rOutPos = awt::Point(aRemainingSpace.X,aRemainingSpace.Y); @@ -2148,6 +2224,19 @@ void changePositionOfAxisTitle( VTitle* pVTitle, TitleAlignment eAlignment break; } + sal_Int32 nMaxY = rPageSize.Height - aTitleSize.Height/2; + sal_Int32 nMaxX = rPageSize.Width - aTitleSize.Width/2; + sal_Int32 nMinX = aTitleSize.Width/2; + sal_Int32 nMinY = aTitleSize.Height/2; + if( aNewPosition.Y > nMaxY ) + aNewPosition.Y = nMaxY; + if( aNewPosition.X > nMaxX ) + aNewPosition.X = nMaxX; + if( aNewPosition.Y < nMinY ) + aNewPosition.Y = nMinY; + if( aNewPosition.X < nMinX ) + aNewPosition.X = nMinX; + pVTitle->changePosition( aNewPosition ); } @@ -2421,6 +2510,7 @@ void ChartView::createShapes() if( impl_AddInDrawsAllByItself() ) return; + m_aResultingDiagramRectangleExcludingAxes = awt::Rectangle(0,0,0,0); impl_deleteCoordinateSystems(); if( m_pDrawModelWrapper ) { @@ -2460,9 +2550,15 @@ void ChartView::createShapes() uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( m_xChartModel ) ); rtl::OUString aDiagramCID( ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DIAGRAM, rtl::OUString::valueOf( sal_Int32(0) ) ) );//todo: other index if more than one diagram is possible uno::Reference< drawing::XShapes > xDiagramPlusAxesPlusMarkHandlesGroup_Shapes( ShapeFactory(m_xShapeFactory).createGroup2D(xPageShapes,aDiagramCID) ); - uno::Reference< drawing::XShape > xDiagramPlusAxes_MarkHandles( ShapeFactory(m_xShapeFactory).createInvisibleRectangle( + + uno::Reference< drawing::XShape > xDiagram_MarkHandles( ShapeFactory(m_xShapeFactory).createInvisibleRectangle( xDiagramPlusAxesPlusMarkHandlesGroup_Shapes, awt::Size(0,0) ) ); - ShapeFactory::setShapeName( xDiagramPlusAxes_MarkHandles, C2U("MarkHandles") ); + ShapeFactory::setShapeName( xDiagram_MarkHandles, C2U("MarkHandles") ); + + uno::Reference< drawing::XShape > xDiagram_OuterRect( ShapeFactory(m_xShapeFactory).createInvisibleRectangle( + xDiagramPlusAxesPlusMarkHandlesGroup_Shapes, awt::Size(0,0) ) ); + ShapeFactory::setShapeName( xDiagram_OuterRect, C2U("PlotAreaIncludingAxes") ); + uno::Reference< drawing::XShapes > xDiagramPlusAxes_Shapes( ShapeFactory(m_xShapeFactory).createGroup2D(xDiagramPlusAxesPlusMarkHandlesGroup_Shapes ) ); //------------ create some titles @@ -2547,21 +2643,22 @@ void ChartView::createShapes() //------------ create complete diagram shape (inclusive axis and series) awt::Point aAvailablePosDia; awt::Size aAvailableSizeForDiagram; + bool bUseFixedInnerSize = false; if( getAvailablePosAndSizeForDiagram( aAvailablePosDia, aAvailableSizeForDiagram, aRemainingSpace, aPageSize, ChartModelHelper::findDiagram( m_xChartModel ) - , apVTitle_X.get(), apVTitle_Y.get(), apVTitle_SecondX.get(), apVTitle_SecondY.get() ) ) + , apVTitle_X.get(), apVTitle_Y.get(), apVTitle_SecondX.get(), apVTitle_SecondY.get(), bUseFixedInnerSize ) ) { - impl_createDiagramAndContent( aSeriesPlotterContainer + awt::Rectangle aUsedOuterRect = impl_createDiagramAndContent( aSeriesPlotterContainer , xDiagramPlusAxes_Shapes - , aAvailablePosDia ,aAvailableSizeForDiagram, aPageSize ); + , aAvailablePosDia ,aAvailableSizeForDiagram, aPageSize, bUseFixedInnerSize, xDiagram_MarkHandles ); - if(xDiagramPlusAxes_MarkHandles.is()) + if( xDiagram_OuterRect.is() ) { - xDiagramPlusAxes_MarkHandles->setPosition( aAvailablePosDia ); - xDiagramPlusAxes_MarkHandles->setSize( aAvailableSizeForDiagram ); + xDiagram_OuterRect->setPosition( awt::Point( aUsedOuterRect.X, aUsedOuterRect.Y ) ); + xDiagram_OuterRect->setSize( awt::Size( aUsedOuterRect.Width, aUsedOuterRect.Height ) ); } //correct axis title position - awt::Rectangle aDiagramPlusAxesRect(aAvailablePosDia.X,aAvailablePosDia.Y,aAvailableSizeForDiagram.Width,aAvailableSizeForDiagram.Height); + awt::Rectangle aDiagramPlusAxesRect( aUsedOuterRect ); if(bAutoPosition_XTitle) changePositionOfAxisTitle( apVTitle_X.get(), ALIGN_BOTTOM, aDiagramPlusAxesRect, aPageSize ); if(bAutoPosition_YTitle) diff --git a/chart2/source/view/main/ChartView.hxx b/chart2/source/view/main/ChartView.hxx index b536998fd5bd..78d1e20760db 100644 --- a/chart2/source/view/main/ChartView.hxx +++ b/chart2/source/view/main/ChartView.hxx @@ -112,6 +112,8 @@ public: virtual ::com::sun::star::awt::Rectangle getRectangleOfObject( const rtl::OUString& rObjectCID, bool bSnapRect=false ); + virtual ::com::sun::star::awt::Rectangle getDiagramRectangleExcludingAxes(); + ::boost::shared_ptr< DrawModelWrapper > getDrawModelWrapper(); // ___XTransferable___ @@ -189,11 +191,13 @@ private: //methods void impl_updateView(); - void impl_createDiagramAndContent( SeriesPlotterContainer& rSeriesPlotterContainer + ::com::sun::star::awt::Rectangle impl_createDiagramAndContent( SeriesPlotterContainer& rSeriesPlotterContainer , const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes>& xDiagramPlusAxes_Shapes , const ::com::sun::star::awt::Point& rAvailablePos , const ::com::sun::star::awt::Size& rAvailableSize - , const ::com::sun::star::awt::Size& rPageSize ); + , const ::com::sun::star::awt::Size& rPageSize + , bool bUseFixedInnerSize + , const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape>& xDiagram_MarkHandles ); private: //member @@ -232,6 +236,8 @@ private: //member sal_Int32 m_nScaleYDenominator; sal_Bool m_bSdrViewIsInEditMode; + + ::com::sun::star::awt::Rectangle m_aResultingDiagramRectangleExcludingAxes; }; //............................................................................. -- cgit From 754c2fcb779f9c2cbe37f1bf99cf49cec01a0947 Mon Sep 17 00:00:00 2001 From: Ingrid Halama Date: Fri, 19 Mar 2010 14:36:03 +0100 Subject: chartpositioning: merge with DEV300_m75 (part2) --- chart2/source/controller/dialogs/tp_DiagramPosition.cxx | 11 ++++------- chart2/source/controller/dialogs/tp_DiagramPosition.hxx | 5 +---- chart2/source/controller/inc/DiagramItemConverter.hxx | 5 +---- .../source/controller/itemsetwrapper/DiagramItemConverter.cxx | 9 +++------ 4 files changed, 9 insertions(+), 21 deletions(-) (limited to 'chart2') diff --git a/chart2/source/controller/dialogs/tp_DiagramPosition.cxx b/chart2/source/controller/dialogs/tp_DiagramPosition.cxx index ff9b6e23cfd7..68150dceeb22 100644 --- a/chart2/source/controller/dialogs/tp_DiagramPosition.cxx +++ b/chart2/source/controller/dialogs/tp_DiagramPosition.cxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: tp_DiagramPosition.cxx,v $ - * $Revision: 1.13 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -41,8 +38,8 @@ #include //GetModuleFieldUnit #include -#include -#include +#include +#include // header for class SvxDoubleItem #include @@ -132,7 +129,7 @@ DiagramPositionTabPage::DiagramPositionTabPage( Window* pParent, const SfxItemSe void DiagramPositionTabPage::Construct() { // get range and work area - meDlgUnit = GetModuleFieldUnit( &GetItemSet() ); + meDlgUnit = GetModuleFieldUnit( GetItemSet() ); SetFieldUnit( maMtrPosX, meDlgUnit, TRUE ); SetFieldUnit( maMtrPosY, meDlgUnit, TRUE ); SetFieldUnit( maMtrWidth, meDlgUnit, TRUE ); diff --git a/chart2/source/controller/dialogs/tp_DiagramPosition.hxx b/chart2/source/controller/dialogs/tp_DiagramPosition.hxx index 153c9d26ca75..90825b97ba15 100644 --- a/chart2/source/controller/dialogs/tp_DiagramPosition.hxx +++ b/chart2/source/controller/dialogs/tp_DiagramPosition.hxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: tp_DiagramPosition.hxx,v $ - * $Revision: 1.7 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/chart2/source/controller/inc/DiagramItemConverter.hxx b/chart2/source/controller/inc/DiagramItemConverter.hxx index 9df7b093d573..280b9cffb45b 100644 --- a/chart2/source/controller/inc/DiagramItemConverter.hxx +++ b/chart2/source/controller/inc/DiagramItemConverter.hxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: AxisItemConverter.hxx,v $ - * $Revision: 1.9 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/chart2/source/controller/itemsetwrapper/DiagramItemConverter.cxx b/chart2/source/controller/itemsetwrapper/DiagramItemConverter.cxx index 00f1fb664739..bc1cd71ed338 100644 --- a/chart2/source/controller/itemsetwrapper/DiagramItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/DiagramItemConverter.cxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: DiagramItemConverter.cxx,v $ - * $Revision: 1.16 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -37,11 +34,11 @@ #include "macros.hxx" #include "servicenames.hxx" #include "chartview/ExplicitValueProvider.hxx" -#include +#include #include "ItemPropertyMap.hxx" #include "GraphicPropertyItemConverter.hxx" #include -#include +#include #include #include -- cgit From 9ffefc5a02fe8c45c8dc6c2627b67e32101b2960 Mon Sep 17 00:00:00 2001 From: Ingrid Halama Date: Tue, 30 Mar 2010 13:09:38 +0200 Subject: chartpositioning: #i100778# avoid assertions upon opening of pos&size dialog --- chart2/source/controller/dialogs/tp_DiagramPosition.cxx | 4 ++-- chart2/source/controller/itemsetwrapper/SchWhichPairs.hxx | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) (limited to 'chart2') diff --git a/chart2/source/controller/dialogs/tp_DiagramPosition.cxx b/chart2/source/controller/dialogs/tp_DiagramPosition.cxx index 68150dceeb22..c8e2ec552192 100644 --- a/chart2/source/controller/dialogs/tp_DiagramPosition.cxx +++ b/chart2/source/controller/dialogs/tp_DiagramPosition.cxx @@ -30,13 +30,13 @@ #include "tp_DiagramPosition.hxx" #include "tp_DiagramPosition.hrc" +#include "ConfigurationAccess.hxx" #include "DiagramHelper.hxx" #include "ResId.hxx" #include "chartview/ChartSfxItemIds.hxx" #include #include -//GetModuleFieldUnit #include #include #include @@ -129,7 +129,7 @@ DiagramPositionTabPage::DiagramPositionTabPage( Window* pParent, const SfxItemSe void DiagramPositionTabPage::Construct() { // get range and work area - meDlgUnit = GetModuleFieldUnit( GetItemSet() ); + meDlgUnit = ConfigurationAccess::getFieldUnit(); SetFieldUnit( maMtrPosX, meDlgUnit, TRUE ); SetFieldUnit( maMtrPosY, meDlgUnit, TRUE ); SetFieldUnit( maMtrWidth, meDlgUnit, TRUE ); diff --git a/chart2/source/controller/itemsetwrapper/SchWhichPairs.hxx b/chart2/source/controller/itemsetwrapper/SchWhichPairs.hxx index c1ec0eabcccc..bd971752954c 100644 --- a/chart2/source/controller/itemsetwrapper/SchWhichPairs.hxx +++ b/chart2/source/controller/itemsetwrapper/SchWhichPairs.hxx @@ -99,8 +99,6 @@ const USHORT nLegendWhichPairs[] = const USHORT nDiagramWhichPairs[] = { - XATTR_LINE_FIRST, XATTR_LINE_LAST, // 1000 - 1016 svx/xdef.hxx - XATTR_FILL_FIRST, XATTR_FILL_LAST, // 1000 - 1016 svx/xdef.hxx SCHATTR_DIAGRAM_START, SCHATTR_DIAGRAM_END, SID_ATTR_TRANSFORM_POS_Y, SID_ATTR_TRANSFORM_POS_Y, SID_ATTR_TRANSFORM_WIDTH, SID_ATTR_TRANSFORM_HEIGHT, -- 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) --- .../chartapiwrapper/Chart2ModelContact.cxx | 28 ++--- .../chartapiwrapper/Chart2ModelContact.hxx | 12 +-- .../controller/chartapiwrapper/DiagramWrapper.cxx | 38 +++---- .../controller/main/PositionAndSizeHelper.cxx | 7 -- .../source/inc/chartview/ExplicitValueProvider.hxx | 10 +- chart2/source/view/main/ChartView.cxx | 119 ++++++++++++--------- 6 files changed, 111 insertions(+), 103 deletions(-) (limited to 'chart2') diff --git a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx index 3742feaf8e8a..69e11198095a 100644 --- a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx +++ b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx @@ -119,7 +119,7 @@ Reference< chart2::XDiagram > Chart2ModelContact::getChart2Diagram() const return ChartModelHelper::findDiagram( this->getChartModel() ); } -ExplicitValueProvider* Chart2ModelContact::getExplicitValueProvider() const +uno::Reference< lang::XUnoTunnel > Chart2ModelContact::getChartView() const { if(!m_xChartView.is()) { @@ -129,7 +129,12 @@ ExplicitValueProvider* Chart2ModelContact::getExplicitValueProvider() const if( xFact.is() ) m_xChartView = Reference< lang::XUnoTunnel >( xFact->createInstance( CHART_VIEW_SERVICE_NAME ), uno::UNO_QUERY ); } + return m_xChartView; +} +ExplicitValueProvider* Chart2ModelContact::getExplicitValueProvider() const +{ + getChartView(); if(!m_xChartView.is()) return 0; @@ -193,13 +198,20 @@ awt::Size Chart2ModelContact::GetPageSize() const return ChartModelHelper::getPageSize(m_xChartModel); } +awt::Rectangle Chart2ModelContact::SubstractAxisTitleSizes( const awt::Rectangle& rPositionRect ) +{ + awt::Rectangle aRect = ExplicitValueProvider::substractAxisTitleSizes( + m_xChartModel, getChartView(), rPositionRect ); + return aRect; +} + awt::Rectangle Chart2ModelContact::GetDiagramRectangleIncludingTitle() const { awt::Rectangle aRect( GetDiagramRectangleIncludingAxes() ); //add axis title sizes to the diagram size - aRect = ExplicitValueProvider::calculateDiagramPositionAndSizeIncludingTitle( - m_xChartModel, m_xChartView, aRect ); + aRect = ExplicitValueProvider::addAxisTitleSizes( + m_xChartModel, getChartView(), aRect ); return aRect; } @@ -229,16 +241,6 @@ awt::Rectangle Chart2ModelContact::GetDiagramRectangleExcludingAxes() const return aRect; } -awt::Size Chart2ModelContact::GetDiagramSizeIncludingTitle() const -{ - return ToSize( this->GetDiagramRectangleIncludingTitle() ); -} - -awt::Point Chart2ModelContact::GetDiagramPositionIncludingTitle() const -{ - return ToPoint( this->GetDiagramRectangleIncludingTitle() ); -} - awt::Size Chart2ModelContact::GetLegendSize() const { awt::Size aSize; diff --git a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx index bab2eaff2d14..e20167e216c2 100644 --- a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx +++ b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx @@ -93,15 +93,9 @@ public: */ ::com::sun::star::awt::Size GetPageSize() const; - /** Returns the size of the diagram object in logic coordinates including - the space reserved for axis titles. + /** calculates the current axes title sizes and substract that space them from the given recangle */ - ::com::sun::star::awt::Size GetDiagramSizeIncludingTitle() const; - - /** Returns the position of the diagram in logic coordinates including - the space reserved for axis titles. - */ - ::com::sun::star::awt::Point GetDiagramPositionIncludingTitle() const; + ::com::sun::star::awt::Rectangle SubstractAxisTitleSizes( const ::com::sun::star::awt::Rectangle& rPositionRect ); /** Returns the position and size of the diagram in logic coordinates (100th mm) including the space used for axes including axes titles. @@ -149,6 +143,8 @@ public: private: //methods ExplicitValueProvider* getExplicitValueProvider() const; + ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XUnoTunnel > getChartView() const; public: //member ::com::sun::star::uno::Reference< 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) { diff --git a/chart2/source/controller/main/PositionAndSizeHelper.cxx b/chart2/source/controller/main/PositionAndSizeHelper.cxx index d2e271e92147..6c81f6ede170 100644 --- a/chart2/source/controller/main/PositionAndSizeHelper.cxx +++ b/chart2/source/controller/main/PositionAndSizeHelper.cxx @@ -183,13 +183,6 @@ bool PositionAndSizeHelper::moveObject( const rtl::OUString& rObjectCID xObjectProp = uno::Reference< beans::XPropertySet >( ObjectIdentifier::getDiagramForCID( rObjectCID, xChartModel ), uno::UNO_QUERY ); if(!xObjectProp.is()) return false; - - //add axis title sizes to the diagram size - bool bPosSizeExcludeAxes = false; - xObjectProp->getPropertyValue( C2U( "PosSizeExcludeAxes" ) ) >>= bPosSizeExcludeAxes; - if( !bPosSizeExcludeAxes ) - aNewPositionAndSize = ExplicitValueProvider::calculateDiagramPositionAndSizeIncludingTitle( - xChartModel, xChartView, rNewPositionAndSize ); } return moveObject( eObjectType, xObjectProp, aNewPositionAndSize, rPageRectangle ); } diff --git a/chart2/source/inc/chartview/ExplicitValueProvider.hxx b/chart2/source/inc/chartview/ExplicitValueProvider.hxx index 287d8a708ce5..d10ee8d415fc 100644 --- a/chart2/source/inc/chartview/ExplicitValueProvider.hxx +++ b/chart2/source/inc/chartview/ExplicitValueProvider.hxx @@ -79,13 +79,21 @@ public: static ExplicitValueProvider* getExplicitValueProvider( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xChartView ); static ::com::sun::star::awt::Rectangle - calculateDiagramPositionAndSizeIncludingTitle( + addAxisTitleSizes( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xChartModel , const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xChartView , const ::com::sun::star::awt::Rectangle& rExcludingPositionAndSize ); + static ::com::sun::star::awt::Rectangle + substractAxisTitleSizes( + const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel >& xChartModel + , const ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XInterface >& xChartView + , const ::com::sun::star::awt::Rectangle& rPositionAndSizeIncludingTitles ); + static sal_Int32 getExplicitNumberFormatKeyForAxis( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis >& xAxis , const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XCoordinateSystem > & xCorrespondingCoordinateSystem diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx index a5232571f045..cfea3896ad2e 100644 --- a/chart2/source/view/main/ChartView.cxx +++ b/chart2/source/view/main/ChartView.cxx @@ -1999,7 +1999,7 @@ sal_Int32 ExplicitValueProvider::getExplicitPercentageNumberFormatKeyForDataLabe } //static -awt::Rectangle ExplicitValueProvider::calculateDiagramPositionAndSizeIncludingTitle( +awt::Rectangle ExplicitValueProvider::addAxisTitleSizes( const Reference< frame::XModel >& xChartModel , const Reference< uno::XInterface >& xChartView , const awt::Rectangle& rExcludingPositionAndSize ) @@ -2066,6 +2066,74 @@ awt::Rectangle ExplicitValueProvider::calculateDiagramPositionAndSizeIncludingTi return aRet; } +//static +awt::Rectangle ExplicitValueProvider::substractAxisTitleSizes( + const Reference< frame::XModel >& xChartModel + , const Reference< uno::XInterface >& xChartView + , const awt::Rectangle& rPositionAndSizeIncludingTitles ) +{ + awt::Rectangle aRet(rPositionAndSizeIncludingTitles); + + //add axis title sizes to the diagram size + uno::Reference< chart2::XTitle > xTitle_Height( TitleHelper::getTitle( TitleHelper::TITLE_AT_STANDARD_X_AXIS_POSITION, xChartModel ) ); + uno::Reference< chart2::XTitle > xTitle_Width( TitleHelper::getTitle( TitleHelper::TITLE_AT_STANDARD_Y_AXIS_POSITION, xChartModel ) ); + uno::Reference< chart2::XTitle > xSecondTitle_Height( TitleHelper::getTitle( TitleHelper::SECONDARY_X_AXIS_TITLE, xChartModel ) ); + uno::Reference< chart2::XTitle > xSecondTitle_Width( TitleHelper::getTitle( TitleHelper::SECONDARY_Y_AXIS_TITLE, xChartModel ) ); + if( xTitle_Height.is() || xTitle_Width.is() || xSecondTitle_Height.is() || xSecondTitle_Width.is() ) + { + ExplicitValueProvider* pExplicitValueProvider = ExplicitValueProvider::getExplicitValueProvider(xChartView); + if( pExplicitValueProvider ) + { + //detect wether x axis points into x direction or not + if( lcl_getPropertySwapXAndYAxis( ChartModelHelper::findDiagram( xChartModel ) ) ) + { + std::swap( xTitle_Height, xTitle_Width ); + std::swap( xSecondTitle_Height, xSecondTitle_Width ); + } + + sal_Int32 nTitleSpaceWidth = 0; + sal_Int32 nTitleSpaceHeight = 0; + sal_Int32 nSecondTitleSpaceWidth = 0; + sal_Int32 nSecondTitleSpaceHeight = 0; + + if( xTitle_Height.is() ) + { + rtl::OUString aCID_X( ObjectIdentifier::createClassifiedIdentifierForObject( xTitle_Height, xChartModel ) ); + nTitleSpaceHeight = pExplicitValueProvider->getRectangleOfObject( aCID_X, true ).Height; + if( nTitleSpaceHeight ) + nTitleSpaceHeight+=lcl_getDiagramTitleSpace(); + } + if( xTitle_Width.is() ) + { + rtl::OUString aCID_Y( ObjectIdentifier::createClassifiedIdentifierForObject( xTitle_Width, xChartModel ) ); + nTitleSpaceWidth = pExplicitValueProvider->getRectangleOfObject( aCID_Y, true ).Width; + if(nTitleSpaceWidth) + nTitleSpaceWidth+=lcl_getDiagramTitleSpace(); + } + if( xSecondTitle_Height.is() ) + { + rtl::OUString aCID_X( ObjectIdentifier::createClassifiedIdentifierForObject( xSecondTitle_Height, xChartModel ) ); + nSecondTitleSpaceHeight = pExplicitValueProvider->getRectangleOfObject( aCID_X, true ).Height; + if( nSecondTitleSpaceHeight ) + nSecondTitleSpaceHeight+=lcl_getDiagramTitleSpace(); + } + if( xSecondTitle_Width.is() ) + { + rtl::OUString aCID_Y( ObjectIdentifier::createClassifiedIdentifierForObject( xSecondTitle_Width, xChartModel ) ); + nSecondTitleSpaceWidth += pExplicitValueProvider->getRectangleOfObject( aCID_Y, true ).Width; + if( nSecondTitleSpaceWidth ) + nSecondTitleSpaceWidth+=lcl_getDiagramTitleSpace(); + } + + aRet.X += nTitleSpaceWidth; + aRet.Y += nSecondTitleSpaceHeight; + aRet.Width -= (nTitleSpaceWidth + nSecondTitleSpaceWidth); + aRet.Height -= (nTitleSpaceHeight + nSecondTitleSpaceHeight); + } + } + return aRet; +} + double lcl_getPageLayoutDistancePercentage() { return 0.02; @@ -2097,7 +2165,6 @@ bool getAvailablePosAndSizeForDiagram( uno::Reference< beans::XPropertySet > xProp(xDiagram, uno::UNO_QUERY); - bool bMakeRoomForTitle = false; bool bPosSizeExcludeAxes = false; if( xProp.is() ) xProp->getPropertyValue( C2U( "PosSizeExcludeAxes" ) ) >>= bPosSizeExcludeAxes; @@ -2108,7 +2175,6 @@ bool getAvailablePosAndSizeForDiagram( { rOutAvailableDiagramSize.Height = static_cast(aRelativeSize.Secondary*rPageSize.Height); rOutAvailableDiagramSize.Width = static_cast(aRelativeSize.Primary*rPageSize.Width); - bMakeRoomForTitle = !bPosSizeExcludeAxes; bUseFixedInnerSize = bPosSizeExcludeAxes; } else @@ -2127,7 +2193,6 @@ bool getAvailablePosAndSizeForDiagram( rOutPos = RelativePositionHelper::getUpperLeftCornerOfAnchoredObject( awt::Point(static_cast(fX),static_cast(fY)) , rOutAvailableDiagramSize, aRelativePosition.Anchor ); - bMakeRoomForTitle = !bPosSizeExcludeAxes; bUseFixedInnerSize = bPosSizeExcludeAxes; } else @@ -2141,52 +2206,6 @@ bool getAvailablePosAndSizeForDiagram( rOutAvailableDiagramSize.Width = rPageSize.Width - rOutPos.X; } - if( bMakeRoomForTitle ) - { - sal_Int32 nTitleSpaceWidth = 0; - sal_Int32 nTitleSpaceHeight = 0; - sal_Int32 nSecondTitleSpaceWidth = 0; - sal_Int32 nSecondTitleSpaceHeight = 0; - { - //todo detect wether x axis points into x direction or not - //detect wether x axis points into x direction or not - if( lcl_getPropertySwapXAndYAxis( xDiagram ) ) - { - std::swap( pXTitle, pYTitle ); - std::swap( pSecondXTitle, pSecondYTitle ); - } - - if( pXTitle ) - { - nTitleSpaceHeight = pXTitle->getFinalSize().Height; - if(nTitleSpaceHeight) - nTitleSpaceHeight+=lcl_getDiagramTitleSpace(); - } - if( pYTitle ) - { - nTitleSpaceWidth = pYTitle->getFinalSize().Width; - if(nTitleSpaceWidth) - nTitleSpaceWidth+=lcl_getDiagramTitleSpace(); - } - if( pSecondXTitle) - { - nSecondTitleSpaceHeight += pSecondXTitle->getFinalSize().Height; - if(nSecondTitleSpaceHeight) - nSecondTitleSpaceHeight+=lcl_getDiagramTitleSpace(); - } - if( pSecondYTitle) - { - nSecondTitleSpaceWidth += pSecondYTitle->getFinalSize().Width; - if(nSecondTitleSpaceWidth) - nSecondTitleSpaceWidth+=lcl_getDiagramTitleSpace(); - } - } - rOutAvailableDiagramSize.Height -= nTitleSpaceHeight + nSecondTitleSpaceHeight; - rOutAvailableDiagramSize.Width -= nTitleSpaceWidth + nSecondTitleSpaceWidth; - rOutPos.X += nTitleSpaceWidth; - rOutPos.Y += nSecondTitleSpaceHeight; - } - return true; } -- 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 ++-- chart2/source/controller/chartapiwrapper/DiagramWrapper.hxx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'chart2') 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(); } diff --git a/chart2/source/controller/chartapiwrapper/DiagramWrapper.hxx b/chart2/source/controller/chartapiwrapper/DiagramWrapper.hxx index 4674295d1238..111e24bd6a8b 100644 --- a/chart2/source/controller/chartapiwrapper/DiagramWrapper.hxx +++ b/chart2/source/controller/chartapiwrapper/DiagramWrapper.hxx @@ -220,8 +220,8 @@ public: virtual ::com::sun::star::awt::Rectangle SAL_CALL calculateDiagramPositionExcludingAxes( ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setDiagramPositionIncludingAxes( const ::com::sun::star::awt::Rectangle& PositionRect ) throw (::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::awt::Rectangle SAL_CALL calculateDiagramPositionIncludingAxes( ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setDiagramPositionIncludingAxesAndAxesTitles( const ::com::sun::star::awt::Rectangle& PositionRect ) throw (::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::awt::Rectangle SAL_CALL calculateDiagramPositionIncludingAxesAndAxesTitles( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setDiagramPositionIncludingAxesAndAxisTitles( const ::com::sun::star::awt::Rectangle& PositionRect ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::awt::Rectangle SAL_CALL calculateDiagramPositionIncludingAxesAndAxisTitles( ) throw (::com::sun::star::uno::RuntimeException); // ____ XDiagramProvider ____ virtual ::com::sun::star::uno::Reference< -- cgit From 3031bc2b4f85a211f026408e84a174e6aecdd91b Mon Sep 17 00:00:00 2001 From: Ingrid Halama Date: Thu, 1 Apr 2010 11:38:41 +0200 Subject: chartpositioning: #i98398# compiler warnings --- chart2/source/controller/inc/PositionAndSizeHelper.hxx | 3 +-- chart2/source/controller/main/ChartController_Position.cxx | 3 +-- chart2/source/controller/main/ChartController_Window.cxx | 3 +-- chart2/source/controller/main/PositionAndSizeHelper.cxx | 3 --- chart2/source/view/main/ChartView.cxx | 6 ++---- 5 files changed, 5 insertions(+), 13 deletions(-) (limited to 'chart2') diff --git a/chart2/source/controller/inc/PositionAndSizeHelper.hxx b/chart2/source/controller/inc/PositionAndSizeHelper.hxx index 43392e7a8235..312c92997055 100644 --- a/chart2/source/controller/inc/PositionAndSizeHelper.hxx +++ b/chart2/source/controller/inc/PositionAndSizeHelper.hxx @@ -51,8 +51,7 @@ public: static bool moveObject( const rtl::OUString& rObjectCID , const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xChartModel , const ::com::sun::star::awt::Rectangle& rNewPositionAndSize - , const ::com::sun::star::awt::Rectangle& rPageRectangle - , ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xChartView ); + , const ::com::sun::star::awt::Rectangle& rPageRectangle ); }; //............................................................................. diff --git a/chart2/source/controller/main/ChartController_Position.cxx b/chart2/source/controller/main/ChartController_Position.cxx index 51f1cafccd8d..83061be07fe5 100644 --- a/chart2/source/controller/main/ChartController_Position.cxx +++ b/chart2/source/controller/main/ChartController_Position.cxx @@ -183,8 +183,7 @@ void SAL_CALL ChartController::executeDispatch_PositionAndSize() bool bChanged = PositionAndSizeHelper::moveObject( m_aSelection.getSelectedCID() , m_aModel->getModel() , awt::Rectangle(aObjectRect.getX(),aObjectRect.getY(),aObjectRect.getWidth(),aObjectRect.getHeight()) - , awt::Rectangle(aPageRect.getX(),aPageRect.getY(),aPageRect.getWidth(),aPageRect.getHeight()) - , m_xChartView ); + , awt::Rectangle(aPageRect.getX(),aPageRect.getY(),aPageRect.getWidth(),aPageRect.getHeight()) ); if( bChanged ) aUndoGuard.commitAction(); } diff --git a/chart2/source/controller/main/ChartController_Window.cxx b/chart2/source/controller/main/ChartController_Window.cxx index 7822c8c1cc21..176d38aa5fc3 100644 --- a/chart2/source/controller/main/ChartController_Window.cxx +++ b/chart2/source/controller/main/ChartController_Window.cxx @@ -869,8 +869,7 @@ void ChartController::execute_MouseButtonUp( const MouseEvent& rMEvt ) bool bChanged = PositionAndSizeHelper::moveObject( m_aSelection.getSelectedCID() , m_aModel->getModel() , awt::Rectangle(aObjectRect.getX(),aObjectRect.getY(),aObjectRect.getWidth(),aObjectRect.getHeight()) - , awt::Rectangle(aPageRect.getX(),aPageRect.getY(),aPageRect.getWidth(),aPageRect.getHeight()) - , m_xChartView ); + , awt::Rectangle(aPageRect.getX(),aPageRect.getY(),aPageRect.getWidth(),aPageRect.getHeight()) ); if( bChanged ) { bDraggingDone = true; diff --git a/chart2/source/controller/main/PositionAndSizeHelper.cxx b/chart2/source/controller/main/PositionAndSizeHelper.cxx index 6c81f6ede170..f0ce3eaaa04e 100644 --- a/chart2/source/controller/main/PositionAndSizeHelper.cxx +++ b/chart2/source/controller/main/PositionAndSizeHelper.cxx @@ -141,8 +141,6 @@ bool PositionAndSizeHelper::moveObject( ObjectType eObjectType { //@todo decide wether x is primary or secondary - //xChartView - //set position: chart2::RelativePosition aRelativePosition; aRelativePosition.Anchor = drawing::Alignment_CENTER; @@ -169,7 +167,6 @@ bool PositionAndSizeHelper::moveObject( const rtl::OUString& rObjectCID , const uno::Reference< frame::XModel >& xChartModel , const awt::Rectangle& rNewPositionAndSize , const awt::Rectangle& rPageRectangle - , uno::Reference< uno::XInterface > xChartView ) { ControllerLockGuard aLockedControllers( xChartModel ); diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx index cfea3896ad2e..3505ef92c793 100644 --- a/chart2/source/view/main/ChartView.cxx +++ b/chart2/source/view/main/ChartView.cxx @@ -2144,8 +2144,6 @@ bool getAvailablePosAndSizeForDiagram( , const awt::Rectangle& rSpaceLeft , const awt::Size & rPageSize , const uno::Reference< XDiagram > & xDiagram - , VTitle* pXTitle, VTitle* pYTitle - , VTitle* pSecondXTitle, VTitle* pSecondYTitle , bool& bUseFixedInnerSize ) { bUseFixedInnerSize = false; @@ -2669,8 +2667,8 @@ void ChartView::createShapes() awt::Point aAvailablePosDia; awt::Size aAvailableSizeForDiagram; bool bUseFixedInnerSize = false; - if( getAvailablePosAndSizeForDiagram( aAvailablePosDia, aAvailableSizeForDiagram, aRemainingSpace, aPageSize, ChartModelHelper::findDiagram( m_xChartModel ) - , apVTitle_X.get(), apVTitle_Y.get(), apVTitle_SecondX.get(), apVTitle_SecondY.get(), bUseFixedInnerSize ) ) + if( getAvailablePosAndSizeForDiagram( aAvailablePosDia, aAvailableSizeForDiagram, aRemainingSpace, aPageSize + , ChartModelHelper::findDiagram( m_xChartModel ), bUseFixedInnerSize ) ) { awt::Rectangle aUsedOuterRect = impl_createDiagramAndContent( aSeriesPlotterContainer , xDiagramPlusAxes_Shapes -- cgit From 06e2110957f0515ce075a83a41ea5556c2c32ea3 Mon Sep 17 00:00:00 2001 From: Ingrid Halama Date: Thu, 1 Apr 2010 14:26:26 +0200 Subject: chartpositioning: #i100778# changed default to exclude axes --- .../controller/dialogs/tp_DiagramPosition.cxx | 23 +++++++++++----------- .../controller/dialogs/tp_DiagramPosition.hrc | 4 ++-- .../controller/dialogs/tp_DiagramPosition.hxx | 2 +- .../controller/dialogs/tp_DiagramPosition.src | 8 ++++---- chart2/source/inc/DiagramHelper.hxx | 4 ++-- chart2/source/model/main/Diagram.cxx | 2 +- chart2/source/view/main/ChartView.cxx | 6 +++++- 7 files changed, 27 insertions(+), 22 deletions(-) (limited to 'chart2') diff --git a/chart2/source/controller/dialogs/tp_DiagramPosition.cxx b/chart2/source/controller/dialogs/tp_DiagramPosition.cxx index c8e2ec552192..b8d0df131f63 100644 --- a/chart2/source/controller/dialogs/tp_DiagramPosition.cxx +++ b/chart2/source/controller/dialogs/tp_DiagramPosition.cxx @@ -74,8 +74,8 @@ DiagramPositionTabPage::DiagramPositionTabPage( Window* pParent, const SfxItemSe m_aFlPosMode( this, SchResId( FL_POSITIONING_MODE ) ), m_aRbPosMode_Auto( this, SchResId( RB_POSITIONING_MODE_AUTOMATIC ) ), - m_aRbPosMode_Including( this, SchResId( RB_POSITIONING_MODE_INCLUDING ) ), m_aRbPosMode_Excluding( this, SchResId( RB_POSITIONING_MODE_EXCLUDING ) ), + m_aRbPosMode_Including( this, SchResId( RB_POSITIONING_MODE_INCLUDING ) ), maFlPosition ( this, SchResId( FL_POSITION ) ), maFtPosX ( this, SchResId( FT_POS_X ) ), @@ -113,8 +113,8 @@ DiagramPositionTabPage::DiagramPositionTabPage( Window* pParent, const SfxItemSe Construct(); m_aRbPosMode_Auto.SetClickHdl( LINK( this, DiagramPositionTabPage, ChangeModeHdl ) ); - m_aRbPosMode_Including.SetClickHdl( LINK( this, DiagramPositionTabPage, ChangeModeHdl ) ); m_aRbPosMode_Excluding.SetClickHdl( LINK( this, DiagramPositionTabPage, ChangeModeHdl ) ); + m_aRbPosMode_Including.SetClickHdl( LINK( this, DiagramPositionTabPage, ChangeModeHdl ) ); maMtrPosX.SetModifyHdl( LINK( this, DiagramPositionTabPage, ChangePosXHdl ) ); maMtrPosY.SetModifyHdl( LINK( this, DiagramPositionTabPage, ChangePosYHdl ) ); @@ -155,10 +155,10 @@ void DiagramPositionTabPage::Reset( const SfxItemSet& rInAttrs ) ePos = DiagramPositioningMode(((const SfxInt32Item*)pItem)->GetValue()); if( ePos == DiagramPositioningMode_AUTO ) m_aRbPosMode_Auto.Check(); - else if( ePos == DiagramPositioningMode_INCLUDING ) - m_aRbPosMode_Including.Check(); else if( ePos == DiagramPositioningMode_EXCLUDING ) m_aRbPosMode_Excluding.Check(); + else if( ePos == DiagramPositioningMode_INCLUDING ) + m_aRbPosMode_Including.Check(); ReleaseBorders(); maCtlPos.Reset(); @@ -217,10 +217,11 @@ BOOL DiagramPositionTabPage::FillItemSet( SfxItemSet& rOutAttrs ) //positioning mode sal_Int32 nMode = 0; - if( m_aRbPosMode_Including.IsChecked() ) + if( m_aRbPosMode_Excluding.IsChecked() ) nMode = 1; - else if( m_aRbPosMode_Excluding.IsChecked() ) + else if( m_aRbPosMode_Including.IsChecked() ) nMode = 2; + rOutAttrs.Put( SfxInt32Item( SCHATTR_DIAGRAM_POS_MODE, nMode ) ); rOutAttrs.Put( SfxRectangleItem( SCHATTR_DIAGRAM_RECT_TO_USE, GetRectIn100thmm() ) ); @@ -444,8 +445,8 @@ void DiagramPositionTabPage::UpdateControlStates() bool bEnable = true; m_aRbPosMode_Auto.Enable( bEnable ); - m_aRbPosMode_Including.Enable( bEnable ); m_aRbPosMode_Excluding.Enable( bEnable ); + m_aRbPosMode_Including.Enable( bEnable ); if( m_aRbPosMode_Auto.IsChecked() ) bEnable = false; @@ -670,15 +671,15 @@ void DiagramPositionTabPage::PointChanged( Window* pWindow, RECT_POINT /*eRP*/ ) IMPL_LINK( DiagramPositionTabPage, ChangeModeHdl, RadioButton*, pButton ) { UpdateControlStates(); - if( pButton == &m_aRbPosMode_Including ) + if( pButton == &m_aRbPosMode_Excluding ) { if( !m_bRectChangedByUser ) - SetRectIn100thmm( m_aIncludingRect ); + SetRectIn100thmm( m_aExcludingRect ); } - else if( pButton == &m_aRbPosMode_Excluding ) + else if( pButton == &m_aRbPosMode_Including ) { if( !m_bRectChangedByUser ) - SetRectIn100thmm( m_aExcludingRect ); + SetRectIn100thmm( m_aIncludingRect ); } return( 0L ); diff --git a/chart2/source/controller/dialogs/tp_DiagramPosition.hrc b/chart2/source/controller/dialogs/tp_DiagramPosition.hrc index c91771e3da91..b2a558636a18 100644 --- a/chart2/source/controller/dialogs/tp_DiagramPosition.hrc +++ b/chart2/source/controller/dialogs/tp_DiagramPosition.hrc @@ -32,8 +32,8 @@ #define FL_POSITIONING_MODE 1 #define RB_POSITIONING_MODE_AUTOMATIC 2 -#define RB_POSITIONING_MODE_INCLUDING 3 -#define RB_POSITIONING_MODE_EXCLUDING 4 +#define RB_POSITIONING_MODE_EXCLUDING 3 +#define RB_POSITIONING_MODE_INCLUDING 4 #define FL_POSITION 5 #define FT_POS_X 6 #define FT_POS_Y 7 diff --git a/chart2/source/controller/dialogs/tp_DiagramPosition.hxx b/chart2/source/controller/dialogs/tp_DiagramPosition.hxx index 90825b97ba15..93dddb406500 100644 --- a/chart2/source/controller/dialogs/tp_DiagramPosition.hxx +++ b/chart2/source/controller/dialogs/tp_DiagramPosition.hxx @@ -92,8 +92,8 @@ private: FixedLine m_aFlPosMode; RadioButton m_aRbPosMode_Auto; - RadioButton m_aRbPosMode_Including; RadioButton m_aRbPosMode_Excluding; + RadioButton m_aRbPosMode_Including; // position FixedLine maFlPosition; diff --git a/chart2/source/controller/dialogs/tp_DiagramPosition.src b/chart2/source/controller/dialogs/tp_DiagramPosition.src index 3ee028d88e94..4c98d13c7db4 100644 --- a/chart2/source/controller/dialogs/tp_DiagramPosition.src +++ b/chart2/source/controller/dialogs/tp_DiagramPosition.src @@ -65,19 +65,19 @@ TabPage TP_DIAGRAM_POSITION TabStop = TRUE ; Text [ en-US ] = "Automatic" ; }; - RadioButton RB_POSITIONING_MODE_INCLUDING + RadioButton RB_POSITIONING_MODE_EXCLUDING { Pos = MAP_APPFONT ( X2 , Y_MODE_2 ) ; Size = MAP_APPFONT ( 236 , 10 ) ; TabStop = TRUE ; - Text [ en-US ] = "Include labels" ; + Text [ en-US ] = "Exclude labels" ; }; - RadioButton RB_POSITIONING_MODE_EXCLUDING + RadioButton RB_POSITIONING_MODE_INCLUDING { Pos = MAP_APPFONT ( X2 , Y_MODE_3 ) ; Size = MAP_APPFONT ( 236 , 10 ) ; TabStop = TRUE ; - Text [ en-US ] = "Exclude labels" ; + Text [ en-US ] = "Include labels" ; }; FixedLine FL_POSITION diff --git a/chart2/source/inc/DiagramHelper.hxx b/chart2/source/inc/DiagramHelper.hxx index 3213886db4c1..41d6e2fca8ff 100644 --- a/chart2/source/inc/DiagramHelper.hxx +++ b/chart2/source/inc/DiagramHelper.hxx @@ -49,8 +49,8 @@ namespace chart enum DiagramPositioningMode { DiagramPositioningMode_AUTO, - DiagramPositioningMode_INCLUDING, - DiagramPositioningMode_EXCLUDING + DiagramPositioningMode_EXCLUDING, + DiagramPositioningMode_INCLUDING }; class OOO_DLLPUBLIC_CHARTTOOLS DiagramHelper diff --git a/chart2/source/model/main/Diagram.cxx b/chart2/source/model/main/Diagram.cxx index 2f81e3b91c0f..b24f4059ba74 100644 --- a/chart2/source/model/main/Diagram.cxx +++ b/chart2/source/model/main/Diagram.cxx @@ -179,7 +179,7 @@ void lcl_AddPropertiesToVector( void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap ) { - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_POSSIZE_EXCLUDE_LABELS, false ); + ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_POSSIZE_EXCLUDE_LABELS, true ); ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_SORT_BY_X_VALUES, false ); ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_CONNECT_BARS, false ); ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_GROUP_BARS_PER_AXIS, true ); diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx index 3505ef92c793..b67af5fd7716 100644 --- a/chart2/source/view/main/ChartView.cxx +++ b/chart2/source/view/main/ChartView.cxx @@ -1612,7 +1612,11 @@ awt::Rectangle ChartView::impl_createDiagramAndContent( SeriesPlotterContainer& { awt::Point aPos(rAvailablePos); awt::Size aSize(rAvailableSize); - if( bUseFixedInnerSize ) + bool bPosSizeExcludeAxesProperty = true; + uno::Reference< beans::XPropertySet > xDiaProps( xDiagram, uno::UNO_QUERY_THROW ); + if( xDiaProps.is() ) + xDiaProps->getPropertyValue(C2U("PosSizeExcludeAxes")) >>= bPosSizeExcludeAxesProperty; + if( bUseFixedInnerSize || bPosSizeExcludeAxesProperty ) { aPos = awt::Point( m_aResultingDiagramRectangleExcludingAxes.X, m_aResultingDiagramRectangleExcludingAxes.Y ); aSize = awt::Size( m_aResultingDiagramRectangleExcludingAxes.Width, m_aResultingDiagramRectangleExcludingAxes.Height ); -- cgit From 41ada097ec91c9bb6c73a7a370d6d7531ce14175 Mon Sep 17 00:00:00 2001 From: Ingrid Halama Date: Tue, 6 Apr 2010 12:00:23 +0200 Subject: chartpositioning: #i100778# correct inner rectangle in case of 3D charts if outer rectangle is used for sizing --- chart2/source/view/main/ChartView.cxx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'chart2') diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx index b67af5fd7716..01dda54e172c 100644 --- a/chart2/source/view/main/ChartView.cxx +++ b/chart2/source/view/main/ChartView.cxx @@ -1605,7 +1605,13 @@ awt::Rectangle ChartView::impl_createDiagramAndContent( SeriesPlotterContainer& } else { - m_aResultingDiagramRectangleExcludingAxes = awt::Rectangle( rAvailablePos.X, rAvailablePos.Y, rAvailableSize.Width, rAvailableSize.Height ); + if( bUseFixedInnerSize ) + m_aResultingDiagramRectangleExcludingAxes = awt::Rectangle( rAvailablePos.X, rAvailablePos.Y, rAvailableSize.Width, rAvailableSize.Height ); + else + { + ::basegfx::B2IRectangle aConsumedInnerRect = aVDiagram.getCurrentRectangle(); + m_aResultingDiagramRectangleExcludingAxes = awt::Rectangle( aConsumedInnerRect.getMinX(), aConsumedInnerRect.getMinY(), aConsumedInnerRect.getWidth(), aConsumedInnerRect.getHeight() ); + } } if( xDiagram_MarkHandles.is() ) -- cgit From 5c4de21a30e1ae06345a735c321bc66db1e004f6 Mon Sep 17 00:00:00 2001 From: Ingrid Halama Date: Tue, 6 Apr 2010 18:41:51 +0200 Subject: chartpositioning: #i100778# do only calculate inner rectangle if necessary --- .../controller/chartapiwrapper/Chart2ModelContact.cxx | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'chart2') diff --git a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx index 69e11198095a..ffc1e95ca796 100644 --- a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx +++ b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx @@ -234,10 +234,17 @@ awt::Rectangle Chart2ModelContact::GetDiagramRectangleIncludingAxes() const awt::Rectangle Chart2ModelContact::GetDiagramRectangleExcludingAxes() const { - awt::Rectangle aRect; - ExplicitValueProvider* pProvider( getExplicitValueProvider() ); - if( pProvider ) - aRect = pProvider->getDiagramRectangleExcludingAxes(); + awt::Rectangle aRect(0,0,0,0); + uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( m_xChartModel ) ); + + if( DiagramPositioningMode_EXCLUDING == DiagramHelper::getDiagramPositioningMode( xDiagram ) ) + aRect = DiagramHelper::getDiagramRectangleFromModel(m_xChartModel); + else + { + ExplicitValueProvider* pProvider( getExplicitValueProvider() ); + if( pProvider ) + aRect = pProvider->getDiagramRectangleExcludingAxes(); + } return aRect; } -- 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 --- .../controller/chartapiwrapper/DiagramWrapper.cxx | 6 + chart2/source/controller/dialogs/ResourceIds.hrc | 1 - chart2/source/controller/dialogs/Strings.src | 5 - .../controller/dialogs/dlg_ObjectProperties.cxx | 10 +- chart2/source/controller/dialogs/makefile.mk | 2 - .../controller/dialogs/tp_DiagramPosition.cxx | 786 --------------------- .../controller/dialogs/tp_DiagramPosition.hrc | 51 -- .../controller/dialogs/tp_DiagramPosition.hxx | 137 ---- .../controller/dialogs/tp_DiagramPosition.src | 217 ------ .../source/controller/inc/DiagramItemConverter.hxx | 78 -- .../itemsetwrapper/DiagramItemConverter.cxx | 223 ------ .../controller/itemsetwrapper/SchWhichPairs.hxx | 8 - .../source/controller/itemsetwrapper/makefile.mk | 3 +- .../controller/main/ChartController_Position.cxx | 21 +- .../controller/main/ChartController_Properties.cxx | 4 - chart2/source/inc/DiagramHelper.hxx | 2 - chart2/source/inc/ObjectIdentifier.hxx | 2 +- chart2/source/inc/Strings.hrc | 2 +- chart2/source/inc/chartview/ChartSfxItemIds.hxx | 11 +- chart2/source/tools/DiagramHelper.cxx | 52 +- chart2/source/view/main/ChartItemPool.cxx | 7 - chart2/source/view/main/ChartView.cxx | 43 +- 22 files changed, 51 insertions(+), 1620 deletions(-) delete mode 100644 chart2/source/controller/dialogs/tp_DiagramPosition.cxx delete mode 100644 chart2/source/controller/dialogs/tp_DiagramPosition.hrc delete mode 100644 chart2/source/controller/dialogs/tp_DiagramPosition.hxx delete mode 100644 chart2/source/controller/dialogs/tp_DiagramPosition.src delete mode 100644 chart2/source/controller/inc/DiagramItemConverter.hxx delete mode 100644 chart2/source/controller/itemsetwrapper/DiagramItemConverter.cxx (limited to 'chart2') 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 ); } diff --git a/chart2/source/controller/dialogs/ResourceIds.hrc b/chart2/source/controller/dialogs/ResourceIds.hrc index 5fd05388bfc3..2ab544c77ab1 100644 --- a/chart2/source/controller/dialogs/ResourceIds.hrc +++ b/chart2/source/controller/dialogs/ResourceIds.hrc @@ -63,7 +63,6 @@ #define TP_AXIS_LABEL 920 #define TP_SCALE 903 #define TP_AXIS_POSITIONS 904 -#define TP_DIAGRAM_POSITION 905 #define TP_CHARTTYPE 910 #define TP_RANGECHOOSER 911 #define TP_WIZARD_TITLEANDOBJECTS 912 diff --git a/chart2/source/controller/dialogs/Strings.src b/chart2/source/controller/dialogs/Strings.src index e4792361b5ab..4b4cec65426e 100644 --- a/chart2/source/controller/dialogs/Strings.src +++ b/chart2/source/controller/dialogs/Strings.src @@ -121,11 +121,6 @@ String STR_PAGE_POSITIONING Text [ en-US ] = "Positioning" ; }; -String STR_PAGE_POSITIONANDSIZE -{ - Text [ en-US ] = "Position and Size" ; -}; - // String STR_PAGE_STATISTICS // { // Text [ en-US ] = "Statistics" ; diff --git a/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx b/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx index b2287437c377..2a41d35313e8 100644 --- a/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx +++ b/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx @@ -49,7 +49,6 @@ #include "tp_SeriesToAxis.hxx" #include "tp_TitleRotation.hxx" #include "tp_PolarOptions.hxx" -#include "tp_DiagramPosition.hxx" #include "ResId.hxx" #include "ViewElementListProvider.hxx" #include "macros.hxx" @@ -247,9 +246,6 @@ void ObjectPropertiesDialogParameter::init( const uno::Reference< frame::XModel else m_aLocalizedName = ObjectNameProvider::getName_ObjectForSeries( m_eObjectType, m_aObjectCID, m_xChartDocument ); break; - case OBJECTTYPE_DIAGRAM: - m_aLocalizedName = String(SchResId(STR_PAGE_POSITIONANDSIZE)); - break; default: m_aLocalizedName = ObjectNameProvider::getName(m_eObjectType,m_bAffectsMultipleObjects); break; @@ -463,14 +459,12 @@ SchAttribTabDlg::SchAttribTabDlg(Window* pParent, AddTabPage(RID_SVXPAGE_LINE, String(SchResId(STR_PAGE_LINE))); break; - case OBJECTTYPE_DIAGRAM: - AddTabPage(TP_DIAGRAM_POSITION, String(SchResId(STR_PAGE_POSITIONANDSIZE)), DiagramPositionTabPage::Create, NULL); - break; - case OBJECTTYPE_DIAGRAM_WALL: case OBJECTTYPE_DATA_STOCK_LOSS: case OBJECTTYPE_DATA_STOCK_GAIN: case OBJECTTYPE_PAGE: case OBJECTTYPE_DIAGRAM_FLOOR: + case OBJECTTYPE_DIAGRAM_WALL: + case OBJECTTYPE_DIAGRAM: AddTabPage(RID_SVXPAGE_LINE, String(SchResId(STR_PAGE_BORDER))); AddTabPage(RID_SVXPAGE_AREA, String(SchResId(STR_PAGE_AREA))); AddTabPage(RID_SVXPAGE_TRANSPARENCE, String(SchResId(STR_PAGE_TRANSPARENCY))); diff --git a/chart2/source/controller/dialogs/makefile.mk b/chart2/source/controller/dialogs/makefile.mk index 3121c2e3dfdd..d22f5c83b081 100644 --- a/chart2/source/controller/dialogs/makefile.mk +++ b/chart2/source/controller/dialogs/makefile.mk @@ -67,7 +67,6 @@ SLOFILES= \ $(SLO)$/tp_RangeChooser.obj \ $(SLO)$/tp_Wizard_TitlesAndObjects.obj \ $(SLO)$/tp_Location.obj \ - $(SLO)$/tp_DiagramPosition.obj \ $(SLO)$/tp_AxisLabel.obj \ $(SLO)$/tp_AxisPositions.obj \ $(SLO)$/tp_DataLabel.obj \ @@ -120,7 +119,6 @@ SRC1FILES= \ tp_RangeChooser.src \ tp_Wizard_TitlesAndObjects.src \ tp_Location.src \ - tp_DiagramPosition.src \ tp_AxisLabel.src \ tp_AxisPositions.src \ tp_DataLabel.src \ diff --git a/chart2/source/controller/dialogs/tp_DiagramPosition.cxx b/chart2/source/controller/dialogs/tp_DiagramPosition.cxx deleted file mode 100644 index b8d0df131f63..000000000000 --- a/chart2/source/controller/dialogs/tp_DiagramPosition.cxx +++ /dev/null @@ -1,786 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_chart2.hxx" -#include "tp_DiagramPosition.hxx" -#include "tp_DiagramPosition.hrc" - -#include "ConfigurationAccess.hxx" -#include "DiagramHelper.hxx" -#include "ResId.hxx" -#include "chartview/ChartSfxItemIds.hxx" - -#include -#include -#include -#include -#include -// header for class SvxDoubleItem -#include - -using namespace ::com::sun::star; - -//............................................................................. -namespace chart -{ -//............................................................................. - -void lcl_ConvertRect(basegfx::B2DRange& rRange, const sal_uInt16 nDigits, const MapUnit ePoolUnit, const FieldUnit eDlgUnit) -{ - const basegfx::B2DPoint aTopLeft( - (double)MetricField::ConvertValue(basegfx::fround(rRange.getMinX()), nDigits, ePoolUnit, eDlgUnit), - (double)MetricField::ConvertValue(basegfx::fround(rRange.getMinY()), nDigits, ePoolUnit, eDlgUnit)); - const basegfx::B2DPoint aBottomRight( - (double)MetricField::ConvertValue(basegfx::fround(rRange.getMaxX()), nDigits, ePoolUnit, eDlgUnit), - (double)MetricField::ConvertValue(basegfx::fround(rRange.getMaxY()), nDigits, ePoolUnit, eDlgUnit)); - - rRange = basegfx::B2DRange(aTopLeft, aBottomRight); -} - -void lcl_ScaleRect(basegfx::B2DRange& rRange, const Fraction aUIScale) -{ - const double fFactor(1.0 / double(aUIScale)); - rRange = basegfx::B2DRange(rRange.getMinimum() * fFactor, rRange.getMaximum() * fFactor); -} - -DiagramPositionTabPage::DiagramPositionTabPage( Window* pParent, const SfxItemSet& rInAttrs ) : - SvxTabPage ( pParent, SchResId( TP_DIAGRAM_POSITION ), rInAttrs ), - - m_aFlPosMode( this, SchResId( FL_POSITIONING_MODE ) ), - - m_aRbPosMode_Auto( this, SchResId( RB_POSITIONING_MODE_AUTOMATIC ) ), - m_aRbPosMode_Excluding( this, SchResId( RB_POSITIONING_MODE_EXCLUDING ) ), - m_aRbPosMode_Including( this, SchResId( RB_POSITIONING_MODE_INCLUDING ) ), - - maFlPosition ( this, SchResId( FL_POSITION ) ), - maFtPosX ( this, SchResId( FT_POS_X ) ), - maMtrPosX ( this, SchResId( MTR_FLD_POS_X ) ), - maFtPosY ( this, SchResId( FT_POS_Y ) ), - maMtrPosY ( this, SchResId( MTR_FLD_POS_Y ) ), - maFtPosReference ( this, SchResId( FT_POSREFERENCE ) ), - maCtlPos ( this, SchResId( CTL_POSRECT ), RP_LT ), - - maFlSize ( this, SchResId( FL_SIZE ) ), - maFtWidth ( this, SchResId( FT_WIDTH ) ), - maMtrWidth ( this, SchResId( MTR_FLD_WIDTH ) ), - maFtHeight ( this, SchResId( FT_HEIGHT ) ), - maMtrHeight ( this, SchResId( MTR_FLD_HEIGHT ) ), - maCbxScale ( this, SchResId( CBX_SCALE ) ), - maFtSizeReference ( this, SchResId( FT_SIZEREFERENCE) ), - maCtlSize ( this, SchResId( CTL_SIZERECT ), RP_LT ), - m_aExcludingRect(1,2,3,4), - m_aIncludingRect(1,2,3,4), - m_aMaxRect(1,2,3,4), - m_fUIScale( 1.0 ), - m_aCurrentRect(1,2,3,4), - m_bRectChangedByUser( false ) -{ - FreeResource(); - - // this pege needs ExchangeSupport - // SetExchangeSupport(); - - // evaluate PoolUnit - SfxItemPool* pPool = rInAttrs.GetPool(); - DBG_ASSERT( pPool, "no pool (!)" ); - mePoolUnit = pPool->GetMetric( SID_ATTR_TRANSFORM_POS_X ); - - Construct(); - - m_aRbPosMode_Auto.SetClickHdl( LINK( this, DiagramPositionTabPage, ChangeModeHdl ) ); - m_aRbPosMode_Excluding.SetClickHdl( LINK( this, DiagramPositionTabPage, ChangeModeHdl ) ); - m_aRbPosMode_Including.SetClickHdl( LINK( this, DiagramPositionTabPage, ChangeModeHdl ) ); - - maMtrPosX.SetModifyHdl( LINK( this, DiagramPositionTabPage, ChangePosXHdl ) ); - maMtrPosY.SetModifyHdl( LINK( this, DiagramPositionTabPage, ChangePosYHdl ) ); - - maMtrWidth.SetModifyHdl( LINK( this, DiagramPositionTabPage, ChangeWidthHdl ) ); - maMtrHeight.SetModifyHdl( LINK( this, DiagramPositionTabPage, ChangeHeightHdl ) ); - maCbxScale.SetClickHdl( LINK( this, DiagramPositionTabPage, ClickScaleHdl ) ); -} - -// ----------------------------------------------------------------------- - -void DiagramPositionTabPage::Construct() -{ - // get range and work area - meDlgUnit = ConfigurationAccess::getFieldUnit(); - SetFieldUnit( maMtrPosX, meDlgUnit, TRUE ); - SetFieldUnit( maMtrPosY, meDlgUnit, TRUE ); - SetFieldUnit( maMtrWidth, meDlgUnit, TRUE ); - SetFieldUnit( maMtrHeight, meDlgUnit, TRUE ); - - if(FUNIT_MILE == meDlgUnit || FUNIT_KM == meDlgUnit) - { - maMtrPosX.SetDecimalDigits( 3 ); - maMtrPosY.SetDecimalDigits( 3 ); - maMtrWidth.SetDecimalDigits( 3 ); - maMtrHeight.SetDecimalDigits( 3 ); - } -} - -// ----------------------------------------------------------------------- - -void DiagramPositionTabPage::Reset( const SfxItemSet& rInAttrs ) -{ - //positioning mode - DiagramPositioningMode ePos = DiagramPositioningMode_AUTO; - const SfxPoolItem* pItem = NULL; - if( rInAttrs.GetItemState( SCHATTR_DIAGRAM_POS_MODE, TRUE, &pItem ) == SFX_ITEM_SET ) - ePos = DiagramPositioningMode(((const SfxInt32Item*)pItem)->GetValue()); - if( ePos == DiagramPositioningMode_AUTO ) - m_aRbPosMode_Auto.Check(); - else if( ePos == DiagramPositioningMode_EXCLUDING ) - m_aRbPosMode_Excluding.Check(); - else if( ePos == DiagramPositioningMode_INCLUDING ) - m_aRbPosMode_Including.Check(); - - ReleaseBorders(); - maCtlPos.Reset(); - maCtlSize.Reset(); - - //rectangles - if( rInAttrs.GetItemState( SCHATTR_DIAGRAM_RECT_MAX, TRUE, &pItem ) == SFX_ITEM_SET ) - { - m_aMaxRect = ((const SfxRectangleItem*)pItem)->GetValue(); - SetRectIn100thmm( m_aMaxRect ); - m_aMaxRect = GetRectIn100thmm(); - } - - if( rInAttrs.GetItemState( SCHATTR_DIAGRAM_RECT_EXCLUDING, TRUE, &pItem ) == SFX_ITEM_SET ) - { - m_aExcludingRect = ((const SfxRectangleItem*)pItem)->GetValue(); - SetRectIn100thmm( m_aExcludingRect ); - m_aExcludingRect = GetRectIn100thmm(); - } - - if( rInAttrs.GetItemState( SCHATTR_DIAGRAM_RECT_INCLUDING, TRUE, &pItem ) == SFX_ITEM_SET ) - { - m_aIncludingRect = ((const SfxRectangleItem*)pItem)->GetValue(); - SetRectIn100thmm( m_aIncludingRect ); - m_aIncludingRect = GetRectIn100thmm(); - } - - if( rInAttrs.GetItemState( SCHATTR_DIAGRAM_UI_SCALE, TRUE, &pItem ) == SFX_ITEM_SET ) - m_fUIScale = ((const SvxDoubleItem*)pItem)->GetValue(); - - m_aCurrentRect = m_aIncludingRect; - if( rInAttrs.GetItemState( SCHATTR_DIAGRAM_RECT_TO_USE, TRUE, &pItem ) == SFX_ITEM_SET ) - { - m_aCurrentRect = ((const SfxRectangleItem*)pItem)->GetValue(); - SetRectIn100thmm( m_aCurrentRect ); - m_aCurrentRect = GetRectIn100thmm(); - } - - // scale - String aStr = GetUserData(); - maCbxScale.Check( (BOOL)aStr.ToInt32() ); - mfScaleSizeX = std::max( (double)GetCoreValue( maMtrWidth, mePoolUnit ), 1.0 ); - mfScaleSizeY = std::max( (double)GetCoreValue( maMtrHeight, mePoolUnit ), 1.0 ); - - - m_bRectChangedByUser = false; - SetMinMaxPosition(); - UpdateControlStates(); -} - -// ----------------------------------------------------------------------- - -BOOL DiagramPositionTabPage::FillItemSet( SfxItemSet& rOutAttrs ) -{ - BOOL bModified(TRUE); - - //positioning mode - sal_Int32 nMode = 0; - if( m_aRbPosMode_Excluding.IsChecked() ) - nMode = 1; - else if( m_aRbPosMode_Including.IsChecked() ) - nMode = 2; - - rOutAttrs.Put( SfxInt32Item( SCHATTR_DIAGRAM_POS_MODE, nMode ) ); - - rOutAttrs.Put( SfxRectangleItem( SCHATTR_DIAGRAM_RECT_TO_USE, GetRectIn100thmm() ) ); - - return bModified; -} - -// ----------------------------------------------------------------------- - -SfxTabPage* DiagramPositionTabPage::Create( Window* pWindow, const SfxItemSet& rOutAttrs ) -{ - return( new DiagramPositionTabPage( pWindow, rOutAttrs ) ); -} - -//------------------------------------------------------------------------ - -void DiagramPositionTabPage::ActivatePage( const SfxItemSet& /*rSet*/ ) -{ -} - -// ----------------------------------------------------------------------- - -int DiagramPositionTabPage::DeactivatePage( SfxItemSet* pItemSet ) -{ - if( pItemSet ) - FillItemSet( *pItemSet ); - return LEAVE_PAGE; -} - -//------------------------------------------------------------------------ - -long DiagramPositionTabPage::get1oothMMPosValue( MetricField& rField ) -{ - double fValue( GetCoreValue( rField, mePoolUnit ) * m_fUIScale); - return basegfx::fround(fValue); -} - -long DiagramPositionTabPage::get1oothMMSizeValue( MetricField& rField ) -{ - double fValue = static_cast(rField.GetValue( meDlgUnit )); - fValue = MetricField::ConvertDoubleValue( fValue, rField.GetBaseValue(), rField.GetDecimalDigits(), meDlgUnit, FUNIT_100TH_MM ); - long nValue = long(fValue*m_fUIScale); - nValue = OutputDevice::LogicToLogic( nValue, MAP_100TH_MM, (MapUnit)mePoolUnit ); - nValue = static_cast(rField.Denormalize( nValue )); - return nValue; -} - -/* -const double fTmp((((const SfxInt32Item*)pItem)->GetValue() - maAnchor.getY()) / fUIScale); -SetMetricValue(maMtrPosY, basegfx::fround(fTmp), mePoolUnit); - sal_Int64 nVal = OutputDevice::LogicToLogic( nCoreValue, (MapUnit)eUnit, MAP_100TH_MM ); - nVal = rField.Normalize( nVal ); - rField.SetValue( nVal, FUNIT_100TH_MM ); - */ - -void DiagramPositionTabPage::set1oothMMPosValue( MetricField& rField, long n100thMM ) -{ - const double fTmp( n100thMM / m_fUIScale ); - SetMetricValue(rField, basegfx::fround(fTmp), mePoolUnit); -} -void DiagramPositionTabPage::set1oothMMSizeValue( MetricField& rField, long n100thMM ) -{ - double fValue((OutputDevice::LogicToLogic( n100thMM, (MapUnit)mePoolUnit, MAP_100TH_MM)) ); - fValue /= m_fUIScale; - if(rField.GetDecimalDigits()) - fValue *= pow(10.0, rField.GetDecimalDigits()); - fValue = MetricField::ConvertDoubleValue(fValue, rField.GetBaseValue(), rField.GetDecimalDigits(), FUNIT_100TH_MM, meDlgUnit); - rField.SetValue(static_cast(fValue), meDlgUnit); -} - -sal_Int64 DiagramPositionTabPage::convert1oothMMValueToFieldUnit( MetricField& rField, long n100thMM ) -{ - double fValue((OutputDevice::LogicToLogic( n100thMM, (MapUnit)mePoolUnit, MAP_100TH_MM)) ); - fValue /= m_fUIScale; - if(rField.GetDecimalDigits()) - fValue *= pow(10.0, rField.GetDecimalDigits()); - fValue = MetricField::ConvertDoubleValue(fValue, rField.GetBaseValue(), rField.GetDecimalDigits(), FUNIT_100TH_MM, meDlgUnit); - return basegfx::fround64(fValue); -} - -//------------------------------------------------------------------------ - -void DiagramPositionTabPage::SetRectIn100thmm( const Rectangle& rRect ) -{ - ReleaseBorders(); - - m_aCurrentRect = rRect; - long nLeft = m_aCurrentRect.Left(); - long nTop = m_aCurrentRect.Top(); - long nWidth = m_aCurrentRect.getWidth(); - long nHeight = m_aCurrentRect.getHeight(); - - switch ( maCtlPos.GetActualRP() ) - { - case RP_LT: - { - break; - } - case RP_MT: - { - nLeft += nWidth / 2; - break; - } - case RP_RT: - { - nLeft += nWidth; - break; - } - case RP_LM: - { - nTop += nHeight / 2; - break; - } - case RP_MM: - { - nLeft += nWidth / 2; - nTop += nHeight / 2; - break; - } - case RP_RM: - { - nLeft += nWidth; - nTop += nHeight / 2; - break; - } - case RP_LB: - { - nTop += nHeight; - break; - } - case RP_MB: - { - nLeft += nWidth / 2; - nTop += nHeight; - break; - } - case RP_RB: - { - nLeft += nWidth; - nTop += nHeight; - break; - } - } - - set1oothMMPosValue( maMtrPosX, nLeft ); - set1oothMMPosValue( maMtrPosY, nTop ); - set1oothMMSizeValue( maMtrWidth, nWidth ); - set1oothMMSizeValue( maMtrHeight, nHeight ); - - SetMinMaxPosition(); -} - -//------------------------------------------------------------------------ - -Rectangle DiagramPositionTabPage::GetRectIn100thmm() -{ - long nX = get1oothMMPosValue( maMtrPosX ); - long nY = get1oothMMPosValue( maMtrPosY ); - long nWidth = get1oothMMSizeValue( maMtrWidth ); - long nHeight = get1oothMMSizeValue( maMtrHeight ); - - switch( maCtlPos.GetActualRP() ) - { - case RP_LT: - { - break; - } - case RP_MT: - { - nX -= nWidth/2; - break; - } - case RP_RT: - { - nX -= nWidth; - break; - } - case RP_LM: - { - nY -= nHeight/2; - break; - } - case RP_MM: - { - nX -= nWidth/2; - nY -= nHeight/2; - break; - } - case RP_RM: - { - nX -= nWidth; - nY -= nHeight/2; - break; - } - case RP_LB: - { - nY -= nHeight; - break; - } - case RP_MB: - { - nX -= nWidth/2; - nY -= nHeight; - break; - } - case RP_RB: - { - nX -= nWidth; - nY -= nHeight; - break; - } - } - - return Rectangle(nX,nY,nX+nWidth,nY+nHeight); -} - -//------------------------------------------------------------------------ - -void DiagramPositionTabPage::UpdateControlStates() -{ - bool bEnable = true; - - m_aRbPosMode_Auto.Enable( bEnable ); - m_aRbPosMode_Excluding.Enable( bEnable ); - m_aRbPosMode_Including.Enable( bEnable ); - - if( m_aRbPosMode_Auto.IsChecked() ) - bEnable = false; - - maFlPosition.Enable( bEnable ); - maFtPosX.Enable( bEnable ); - maMtrPosX.Enable( bEnable ); - maFtPosY.Enable( bEnable ); - maMtrPosY.Enable( bEnable ); - maFtPosReference.Enable( bEnable ); - maCtlPos.Enable( bEnable ); - - maFlSize.Enable( bEnable ); - maCtlSize.Enable( bEnable ); - maFtWidth.Enable( bEnable ); - maMtrWidth.Enable( bEnable ); - maFtHeight.Enable( bEnable ); - maMtrHeight.Enable( bEnable ); - maCbxScale.Enable( bEnable ); - maFtSizeReference.Enable( bEnable ); - - maCtlSize.Invalidate(); - maCtlPos.Invalidate(); -} - -//------------------------------------------------------------------------ - -void DiagramPositionTabPage::ReleaseBorders() -{ - //make it possible to set new values that will lead to different min max values afterwards - maMtrPosX.SetMin( convert1oothMMValueToFieldUnit( maMtrPosX, m_aMaxRect.Left() ), meDlgUnit); - maMtrPosX.SetMax( convert1oothMMValueToFieldUnit( maMtrPosX, m_aMaxRect.Right() ), meDlgUnit); - maMtrPosY.SetMin( convert1oothMMValueToFieldUnit( maMtrPosY, m_aMaxRect.Top() ), meDlgUnit); - maMtrPosY.SetMax( convert1oothMMValueToFieldUnit( maMtrPosY, m_aMaxRect.Bottom() ), meDlgUnit); - maMtrWidth.SetMax( convert1oothMMValueToFieldUnit( maMtrWidth, m_aMaxRect.GetWidth() ), meDlgUnit); - maMtrHeight.SetMax( convert1oothMMValueToFieldUnit( maMtrHeight, m_aMaxRect.GetHeight() ), meDlgUnit); -} - -//------------------------------------------------------------------------ - -void DiagramPositionTabPage::SetMinMaxPosition() -{ - // position - - long nLeft( m_aMaxRect.Left() ); - long nTop( m_aMaxRect.Top() ); - long nRight( m_aMaxRect.Right() ); - long nBottom( m_aMaxRect.Bottom() ); - - const long nWidth( m_aCurrentRect.GetWidth() ); - const long nHeight( m_aCurrentRect.GetHeight() ); - - switch ( maCtlPos.GetActualRP() ) - { - case RP_LT: - { - nRight -= nWidth; - nBottom -= nHeight; - break; - } - case RP_MT: - { - nLeft += nWidth / 2; - nRight -= nWidth / 2; - nBottom -= nHeight; - break; - } - case RP_RT: - { - nLeft += nWidth; - nBottom -= nHeight; - break; - } - case RP_LM: - { - nRight -= nWidth; - nTop += nHeight / 2; - nBottom -= nHeight / 2; - break; - } - case RP_MM: - { - nLeft += nWidth / 2; - nRight -= nWidth / 2; - nTop += nHeight / 2; - nBottom -= nHeight / 2; - break; - } - case RP_RM: - { - nLeft += nWidth; - nTop += nHeight / 2; - nBottom -= nHeight / 2; - break; - } - case RP_LB: - { - nRight -= nWidth; - nTop += nHeight; - break; - } - case RP_MB: - { - nLeft += nWidth / 2; - nRight -= nWidth / 2; - nTop += nHeight; - break; - } - case RP_RB: - { - nLeft += nWidth; - nTop += nHeight; - break; - } - } - - maMtrPosX.SetMin( convert1oothMMValueToFieldUnit( maMtrPosX, nLeft ), meDlgUnit); - maMtrPosX.SetFirst( convert1oothMMValueToFieldUnit( maMtrPosX, nLeft ), meDlgUnit); - maMtrPosX.SetMax( convert1oothMMValueToFieldUnit( maMtrPosX, nRight ), meDlgUnit); - maMtrPosX.SetLast( convert1oothMMValueToFieldUnit( maMtrPosX, nRight ), meDlgUnit); - maMtrPosY.SetMin( convert1oothMMValueToFieldUnit( maMtrPosY, nTop ), meDlgUnit); - maMtrPosY.SetFirst( convert1oothMMValueToFieldUnit( maMtrPosY, nTop ), meDlgUnit); - maMtrPosY.SetMax( convert1oothMMValueToFieldUnit( maMtrPosY, nBottom ), meDlgUnit); - maMtrPosY.SetLast( convert1oothMMValueToFieldUnit( maMtrPosY, nBottom ), meDlgUnit); - - // size - - nLeft = m_aMaxRect.Left(); - nTop = m_aMaxRect.Top(); - nRight = m_aMaxRect.Right(); - nBottom = m_aMaxRect.Bottom(); - - long nMaxWidth( m_aMaxRect.GetWidth() ); - long nMaxHeight( m_aMaxRect.GetHeight() ); - - switch ( maCtlSize.GetActualRP() ) - { - case RP_LT: - { - nMaxWidth -= ( m_aCurrentRect.Left() - nLeft ); - nMaxHeight -= ( m_aCurrentRect.Top() - nTop ); - break; - } - case RP_MT: - { - nMaxWidth = std::min( m_aCurrentRect.Center().X() - nLeft, nRight - m_aCurrentRect.Center().X() ) * 2; - nMaxHeight -= ( m_aCurrentRect.Top() - nTop ); - break; - } - case RP_RT: - { - nMaxWidth -= ( nRight - m_aCurrentRect.Right() ); - nMaxHeight -= ( m_aCurrentRect.Top() - nTop ); - break; - } - case RP_LM: - { - nMaxWidth -= ( m_aCurrentRect.Left() - nLeft ); - nMaxHeight = std::min( m_aCurrentRect.Center().Y() - nTop, nBottom - m_aCurrentRect.Center().Y() ) * 2; - break; - } - case RP_MM: - { - nMaxWidth = std::min( m_aCurrentRect.Center().X() - nLeft, nRight - m_aCurrentRect.Center().X() ) * 2; - nMaxHeight = std::min( m_aCurrentRect.Center().Y() - nTop, nBottom - m_aCurrentRect.Center().Y() ) * 2; - break; - } - case RP_RM: - { - nMaxWidth -= ( nRight - m_aCurrentRect.Right() ); - nMaxHeight = std::min( m_aCurrentRect.Center().Y() - nTop, nBottom - m_aCurrentRect.Center().Y() ) * 2; - break; - } - case RP_LB: - { - nMaxWidth -= ( m_aCurrentRect.Left() - nLeft ); - nMaxHeight -=( nBottom - m_aCurrentRect.Bottom() ); - break; - } - case RP_MB: - { - nMaxWidth = std::min( m_aCurrentRect.Center().X() - nLeft, nRight - m_aCurrentRect.Center().X() ) * 2; - nMaxHeight -= ( m_aCurrentRect.Bottom() - nBottom ); - break; - } - case RP_RB: - { - nMaxWidth -= ( nRight - m_aCurrentRect.Right() ); - nMaxHeight -= ( nBottom - m_aCurrentRect.Bottom() ); - break; - } - } - - if( maCbxScale.IsChecked() && maCbxScale.IsEnabled() ) - { - sal_Int64 nMaxHeightResultingFromScale(basegfx::fround64((mfScaleSizeY * (double)nMaxWidth) / mfScaleSizeX)); - if( nMaxHeightResultingFromScale > nMaxHeight ) - nMaxWidth = basegfx::fround64((mfScaleSizeX * (double)nMaxHeight / mfScaleSizeY)); - sal_Int64 nMaxWidthResultingFromScale(basegfx::fround64((mfScaleSizeX * (double)nMaxHeight) / mfScaleSizeY)); - if( nMaxWidthResultingFromScale > nMaxWidth ) - nMaxHeight = basegfx::fround64((mfScaleSizeY * (double)nMaxWidth / mfScaleSizeX)); - } - - maMtrWidth.SetMax( convert1oothMMValueToFieldUnit( maMtrWidth, nMaxWidth ), meDlgUnit); - maMtrWidth.SetLast( convert1oothMMValueToFieldUnit( maMtrWidth, nMaxWidth ), meDlgUnit); - maMtrHeight.SetMax( convert1oothMMValueToFieldUnit( maMtrHeight, nMaxHeight ), meDlgUnit); - maMtrHeight.SetLast( convert1oothMMValueToFieldUnit( maMtrHeight, nMaxHeight ), meDlgUnit); -} - -//------------------------------------------------------------------------ - -void DiagramPositionTabPage::PointChanged( Window* pWindow, RECT_POINT /*eRP*/ ) -{ - if( pWindow == &maCtlPos ) - SetRectIn100thmm( m_aCurrentRect ); - else - SetMinMaxPosition(); -} - -//------------------------------------------------------------------------ - -IMPL_LINK( DiagramPositionTabPage, ChangeModeHdl, RadioButton*, pButton ) -{ - UpdateControlStates(); - if( pButton == &m_aRbPosMode_Excluding ) - { - if( !m_bRectChangedByUser ) - SetRectIn100thmm( m_aExcludingRect ); - } - else if( pButton == &m_aRbPosMode_Including ) - { - if( !m_bRectChangedByUser ) - SetRectIn100thmm( m_aIncludingRect ); - } - - return( 0L ); -} - -//------------------------------------------------------------------------ - -IMPL_LINK( DiagramPositionTabPage, ChangePosXHdl, void *, EMPTYARG ) -{ - m_aCurrentRect = GetRectIn100thmm(); - SetMinMaxPosition(); - m_bRectChangedByUser = true; - return( 0L ); -} - -//------------------------------------------------------------------------ - -IMPL_LINK( DiagramPositionTabPage, ChangePosYHdl, void *, EMPTYARG ) -{ - m_aCurrentRect = GetRectIn100thmm(); - SetMinMaxPosition(); - m_bRectChangedByUser = true; - return( 0L ); -} - -//------------------------------------------------------------------------ - -IMPL_LINK( DiagramPositionTabPage, ChangeWidthHdl, void *, EMPTYARG ) -{ - if( maCbxScale.IsChecked() && maCbxScale.IsEnabled() ) - { - sal_Int64 nHeight(basegfx::fround64((mfScaleSizeY * (double)maMtrWidth.GetValue()) / mfScaleSizeX)); - - if(nHeight <= maMtrHeight.GetMax(FUNIT_NONE)) - { - maMtrHeight.SetUserValue(nHeight, FUNIT_NONE); - } - else - { - nHeight = maMtrHeight.GetMax(FUNIT_NONE); - maMtrHeight.SetUserValue(nHeight); - - const sal_Int64 nWidth(basegfx::fround64((mfScaleSizeX * (double)nHeight) / mfScaleSizeY)); - maMtrWidth.SetUserValue(nWidth, FUNIT_NONE); - } - } - m_bRectChangedByUser = true; - m_aCurrentRect = GetRectIn100thmm(); - SetMinMaxPosition(); - return( 0L ); -} - -//------------------------------------------------------------------------ - -IMPL_LINK( DiagramPositionTabPage, ChangeHeightHdl, void *, EMPTYARG ) -{ - if( maCbxScale.IsChecked() && maCbxScale.IsEnabled() ) - { - sal_Int64 nWidth(basegfx::fround64((mfScaleSizeX * (double)maMtrHeight.GetValue()) / mfScaleSizeY)); - - if(nWidth <= maMtrWidth.GetMax(FUNIT_NONE)) - { - maMtrWidth.SetUserValue(nWidth, FUNIT_NONE); - } - else - { - nWidth = maMtrWidth.GetMax(FUNIT_NONE); - maMtrWidth.SetUserValue(nWidth); - - const sal_Int64 nHeight(basegfx::fround64((mfScaleSizeY * (double)nWidth) / mfScaleSizeX)); - maMtrHeight.SetUserValue(nHeight, FUNIT_NONE); - } - } - m_bRectChangedByUser = true; - m_aCurrentRect = GetRectIn100thmm(); - SetMinMaxPosition(); - return( 0L ); -} - -//------------------------------------------------------------------------ - -IMPL_LINK( DiagramPositionTabPage, ClickScaleHdl, void *, EMPTYARG ) -{ - if( maCbxScale.IsChecked() ) - { - mfScaleSizeX = std::max( (double)GetCoreValue( maMtrWidth, mePoolUnit ), 1.0 ); - mfScaleSizeY = std::max( (double)GetCoreValue( maMtrHeight, mePoolUnit ), 1.0 ); - } - SetMinMaxPosition(); - return( 0L ); -} - -//------------------------------------------------------------------------ - -void DiagramPositionTabPage::FillUserData() -{ - // Abgleich wird in der Ini-Datei festgehalten - UniString aStr = UniString::CreateFromInt32( (sal_Int32) maCbxScale.IsChecked() ); - SetUserData( aStr ); -} - -//............................................................................. -} //namespace chart -//............................................................................. diff --git a/chart2/source/controller/dialogs/tp_DiagramPosition.hrc b/chart2/source/controller/dialogs/tp_DiagramPosition.hrc deleted file mode 100644 index b2a558636a18..000000000000 --- a/chart2/source/controller/dialogs/tp_DiagramPosition.hrc +++ /dev/null @@ -1,51 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: ,v $ - * $Revision: $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "ResourceIds.hrc" - -#define FL_POSITIONING_MODE 1 -#define RB_POSITIONING_MODE_AUTOMATIC 2 -#define RB_POSITIONING_MODE_EXCLUDING 3 -#define RB_POSITIONING_MODE_INCLUDING 4 -#define FL_POSITION 5 -#define FT_POS_X 6 -#define FT_POS_Y 7 -#define MTR_FLD_POS_X 8 -#define MTR_FLD_POS_Y 9 -#define FT_POSREFERENCE 10 -#define CTL_POSRECT 11 -#define FL_SIZE 12 -#define FT_WIDTH 13 -#define FT_HEIGHT 14 -#define MTR_FLD_WIDTH 15 -#define MTR_FLD_HEIGHT 16 -#define FT_SIZEREFERENCE 17 -#define CTL_SIZERECT 18 -#define CBX_SCALE 19 diff --git a/chart2/source/controller/dialogs/tp_DiagramPosition.hxx b/chart2/source/controller/dialogs/tp_DiagramPosition.hxx deleted file mode 100644 index 93dddb406500..000000000000 --- a/chart2/source/controller/dialogs/tp_DiagramPosition.hxx +++ /dev/null @@ -1,137 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef _CHART2_TP_DIAGRAMPOSITION_HXX -#define _CHART2_TP_DIAGRAMPOSITION_HXX - -// header for class FormattedField -#include -// header for FixedText -#include -// header for CheckBox -#include -// header for MetricField -#include -// header for SvxTabPage and SvxRectCtl -#include - -//............................................................................. -namespace chart -{ -//............................................................................. -class DiagramPositionTabPage : public SvxTabPage -{ - using TabPage::ActivatePage; - using TabPage::DeactivatePage; - -public: - DiagramPositionTabPage( Window* pParent, const SfxItemSet& rInAttrs ); - - static SfxTabPage* Create( Window*, const SfxItemSet& ); - - virtual BOOL FillItemSet( SfxItemSet& ); - virtual void Reset( const SfxItemSet & ); - - virtual void ActivatePage( const SfxItemSet& rSet ); - virtual int DeactivatePage( SfxItemSet* pSet ); - - //SvxTabPage communication interface with SvxRectCtl - virtual void PointChanged( Window* pWindow, RECT_POINT eRP ); - - void Construct(); - - virtual void FillUserData(); - -private: - //methods - - DECL_LINK( ChangeModeHdl, RadioButton * ); - DECL_LINK( ChangePosXHdl, void * ); - DECL_LINK( ChangePosYHdl, void * ); - DECL_LINK( ChangeWidthHdl, void * ); - DECL_LINK( ChangeHeightHdl, void * ); - DECL_LINK( ClickScaleHdl, void * ); - - void SetRectIn100thmm( const Rectangle& rRect ); - Rectangle GetRectIn100thmm(); - long get1oothMMPosValue( MetricField& rField ); - long get1oothMMSizeValue( MetricField& rField ); - void set1oothMMPosValue( MetricField& rField, long n100thMM ); - void set1oothMMSizeValue( MetricField& rField, long n100thMM ); - sal_Int64 convert1oothMMValueToFieldUnit( MetricField& rField, long n100thMM ); - void ReleaseBorders(); - void SetMinMaxPosition(); - void UpdateControlStates(); - -private: - - //positioning mode - FixedLine m_aFlPosMode; - - RadioButton m_aRbPosMode_Auto; - RadioButton m_aRbPosMode_Excluding; - RadioButton m_aRbPosMode_Including; - - // position - FixedLine maFlPosition; - FixedText maFtPosX; - MetricField maMtrPosX; - FixedText maFtPosY; - MetricField maMtrPosY; - FixedText maFtPosReference; - SvxRectCtl maCtlPos; - - // size - FixedLine maFlSize; - FixedText maFtWidth; - MetricField maMtrWidth; - FixedText maFtHeight; - MetricField maMtrHeight; - CheckBox maCbxScale; - FixedText maFtSizeReference; - SvxRectCtl maCtlSize; - -private: - Rectangle m_aExcludingRect; - Rectangle m_aIncludingRect; - Rectangle m_aMaxRect; - double m_fUIScale; - Rectangle m_aCurrentRect; - bool m_bRectChangedByUser; - - SfxMapUnit mePoolUnit; - FieldUnit meDlgUnit; - - double mfScaleSizeX; - double mfScaleSizeY; -}; - -//............................................................................. -} //namespace chart -//............................................................................. - -#endif - diff --git a/chart2/source/controller/dialogs/tp_DiagramPosition.src b/chart2/source/controller/dialogs/tp_DiagramPosition.src deleted file mode 100644 index 4c98d13c7db4..000000000000 --- a/chart2/source/controller/dialogs/tp_DiagramPosition.src +++ /dev/null @@ -1,217 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: tp_DiagramPosition.src,v $ - * $Revision: 1.10 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "tp_DiagramPosition.hrc" -#include "TabPages.hrc" -#include - -#define LABELWIDTH 40 -#define LABELHEIGHT 10 - -#define Y_MODE_0 3 -#define Y_MODE_1 (Y_MODE_0+18) -#define Y_MODE_2 (Y_MODE_1+13) -#define Y_MODE_3 (Y_MODE_2+13) -#define Y_POSITION (Y_MODE_3+18) -#define Y_SIZE (Y_POSITION+53) - -#define X1 6 -#define X2 12 -#define X3 (X2+LABELWIDTH+4) -#define X4 178 - - -TabPage TP_DIAGRAM_POSITION -{ - Hide = TRUE ; - Size = MAP_APPFONT ( 260 , 185 ) ; - - FixedLine FL_POSITIONING_MODE - { - Pos = MAP_APPFONT ( X1 , Y_MODE_0 ) ; - Size = MAP_APPFONT ( 248 , RSC_CD_FIXEDLINE_HEIGHT ) ; - Text [ en-US ] = "Positioning Mode" ; - }; - RadioButton RB_POSITIONING_MODE_AUTOMATIC - { - Pos = MAP_APPFONT ( X2 , Y_MODE_1 ) ; - Size = MAP_APPFONT ( 236 , 10 ) ; - TabStop = TRUE ; - Text [ en-US ] = "Automatic" ; - }; - RadioButton RB_POSITIONING_MODE_EXCLUDING - { - Pos = MAP_APPFONT ( X2 , Y_MODE_2 ) ; - Size = MAP_APPFONT ( 236 , 10 ) ; - TabStop = TRUE ; - Text [ en-US ] = "Exclude labels" ; - }; - RadioButton RB_POSITIONING_MODE_INCLUDING - { - Pos = MAP_APPFONT ( X2 , Y_MODE_3 ) ; - Size = MAP_APPFONT ( 236 , 10 ) ; - TabStop = TRUE ; - Text [ en-US ] = "Include labels" ; - }; - - FixedLine FL_POSITION - { - Pos = MAP_APPFONT ( X1 , Y_POSITION ) ; - Size = MAP_APPFONT ( 248 , RSC_CD_FIXEDLINE_HEIGHT ) ; - Text [ en-US ] = "Position" ; - }; - FixedText FT_POS_X - { - Pos = MAP_APPFONT ( X2 , Y_POSITION - 3 + 16 + 8 ) ; - Size = MAP_APPFONT ( LABELWIDTH , LABELHEIGHT ) ; - Text [ en-US ] = "Position ~X" ; - }; - FixedText FT_POS_Y - { - Pos = MAP_APPFONT ( X2 , Y_POSITION - 3 + 32 + 8 ) ; - Size = MAP_APPFONT ( LABELWIDTH , LABELHEIGHT ) ; - Text [ en-US ] = "Position ~Y" ; - }; - MetricField MTR_FLD_POS_X - { - Border = TRUE ; - Pos = MAP_APPFONT ( X3 , Y_POSITION - 3 + 14 + 8 ) ; - Size = MAP_APPFONT ( 54 , 12 ) ; - TabStop = TRUE ; - Repeat = TRUE ; - Spin = TRUE ; - Minimum = -120000 ; - Maximum = 240000 ; - StrictFormat = TRUE ; - DecimalDigits = 2 ; - Unit = FUNIT_MM ; - SpinSize = 10 ; - }; - MetricField MTR_FLD_POS_Y - { - Border = TRUE ; - Pos = MAP_APPFONT ( X3 , Y_POSITION - 3 + 30 + 8 ) ; - Size = MAP_APPFONT ( 54 , 12 ) ; - TabStop = TRUE ; - Repeat = TRUE ; - Spin = TRUE ; - Minimum = -120000 ; - Maximum = 240000 ; - StrictFormat = TRUE ; - DecimalDigits = 2 ; - Unit = FUNIT_MM ; - SpinSize = 10 ; - }; - FixedText FT_POSREFERENCE - { - Pos = MAP_APPFONT ( X4 , Y_POSITION - 3 + 2 + 8 ) ; - Size = MAP_APPFONT ( 70 , LABELHEIGHT ) ; - Text [ en-US ] = "Base point"; - }; - Control CTL_POSRECT - { - Border = TRUE ; - Pos = MAP_APPFONT ( X4 , Y_POSITION - 3 + 12 + 8 ) ; - Size = MAP_APPFONT ( 48 , 34 ) ; - TabStop = TRUE ; - QuickHelpText [ en-US ] = "Base point" ; - }; - - // size - - FixedLine FL_SIZE - { - Pos = MAP_APPFONT ( X1 , Y_SIZE ) ; - Size = MAP_APPFONT ( 248 , RSC_CD_FIXEDLINE_HEIGHT ) ; - Text [ en-US ] = "Size" ; - }; - FixedText FT_WIDTH - { - Pos = MAP_APPFONT ( X2 , Y_SIZE - 56 + 16 + 61 ) ; - Size = MAP_APPFONT ( LABELWIDTH , LABELHEIGHT ) ; - Text [ en-US ] = "Wi~dth" ; - }; - FixedText FT_HEIGHT - { - Pos = MAP_APPFONT ( X2 , Y_SIZE - 56 + 32 + 61 ) ; - Size = MAP_APPFONT ( LABELWIDTH , LABELHEIGHT ) ; - Text [ en-US ] = "H~eight" ; - }; - MetricField MTR_FLD_WIDTH - { - Border = TRUE ; - Pos = MAP_APPFONT ( X3 , Y_SIZE - 56 + 14 + 61 ) ; - Size = MAP_APPFONT ( 54 , 12 ) ; - TabStop = TRUE ; - Repeat = TRUE ; - Spin = TRUE ; - Minimum = 1 ; - Maximum = 120000 ; - StrictFormat = TRUE ; - DecimalDigits = 2 ; - Unit = FUNIT_MM ; - SpinSize = 10 ; - }; - MetricField MTR_FLD_HEIGHT - { - Border = TRUE ; - Pos = MAP_APPFONT ( X3 , Y_SIZE - 56 + 30 + 61 ) ; - Size = MAP_APPFONT ( 54 , 12 ) ; - TabStop = TRUE ; - Repeat = TRUE ; - Spin = TRUE ; - Minimum = 1 ; - Maximum = 120000 ; - StrictFormat = TRUE ; - DecimalDigits = 2 ; - Unit = FUNIT_MM ; - SpinSize = 10 ; - }; - FixedText FT_SIZEREFERENCE - { - Pos = MAP_APPFONT ( X4 , Y_SIZE - 56 + 2 + 61 ) ; - Size = MAP_APPFONT ( 70 , LABELHEIGHT ) ; - Text [ en-US ] = "Base point"; - }; - Control CTL_SIZERECT - { - Border = TRUE ; - Pos = MAP_APPFONT ( X4 , Y_SIZE - 56 + 12 + 61 ) ; - Size = MAP_APPFONT ( 48 , 34 ) ; - TabStop = TRUE ; - QuickHelpText [ en-US ] = "Base point" ; - }; - CheckBox CBX_SCALE - { - Pos = MAP_APPFONT ( X2 , Y_SIZE - 56 + 47 + 61 ) ; - Size = MAP_APPFONT ( 162 , LABELHEIGHT ) ; - TabStop = TRUE ; - Text [ en-US ] = "~Keep ratio" ; - }; -}; diff --git a/chart2/source/controller/inc/DiagramItemConverter.hxx b/chart2/source/controller/inc/DiagramItemConverter.hxx deleted file mode 100644 index 280b9cffb45b..000000000000 --- a/chart2/source/controller/inc/DiagramItemConverter.hxx +++ /dev/null @@ -1,78 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef CHART_DIAGRAM_CONVERTER_HXX -#define CHART_DIAGRAM_CONVERTER_HXX - -#include "ItemConverter.hxx" -#include -#include - -#include -#include - -class SdrModel; - -namespace chart -{ -namespace wrapper -{ - -class DiagramItemConverter : public ::comphelper::ItemConverter -{ -public: - DiagramItemConverter( - const ::com::sun::star::uno::Reference< - ::com::sun::star::beans::XPropertySet > & rPropertySet, - SfxItemPool& rItemPool, - SdrModel& rDrawModel, - const ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xChartModel, double fUIScale ); - virtual ~DiagramItemConverter(); - - virtual void FillItemSet( SfxItemSet & rOutItemSet ) const; - virtual bool ApplyItemSet( const SfxItemSet & rItemSet ); - -protected: - virtual const USHORT * GetWhichPairs() const; - virtual bool GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId & rOutProperty ) const; - - virtual void FillSpecialItem( USHORT nWhichId, SfxItemSet & rOutItemSet ) const - throw( ::com::sun::star::uno::Exception ); - virtual bool ApplySpecialItem( USHORT nWhichId, const SfxItemSet & rItemSet ) - throw( ::com::sun::star::uno::Exception ); - -private: - ::std::vector< ItemConverter * > m_aConverters; - ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xChartModel; - double m_fUIScale; -}; - -} // namespace wrapper -} // namespace chart - -// CHART_DIAGRAM_CONVERTER_HXX -#endif diff --git a/chart2/source/controller/itemsetwrapper/DiagramItemConverter.cxx b/chart2/source/controller/itemsetwrapper/DiagramItemConverter.cxx deleted file mode 100644 index bc1cd71ed338..000000000000 --- a/chart2/source/controller/itemsetwrapper/DiagramItemConverter.cxx +++ /dev/null @@ -1,223 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_chart2.hxx" -#include "DiagramItemConverter.hxx" -#include "DiagramHelper.hxx" -#include "ChartModelHelper.hxx" -#include "SchWhichPairs.hxx" -#include "macros.hxx" -#include "servicenames.hxx" -#include "chartview/ExplicitValueProvider.hxx" -#include -#include "ItemPropertyMap.hxx" -#include "GraphicPropertyItemConverter.hxx" -#include -#include - -#include -#include - -using namespace ::com::sun::star; - -namespace chart -{ -namespace wrapper -{ - -DiagramItemConverter::DiagramItemConverter( - const uno::Reference< beans::XPropertySet > & xPropertySet - , SfxItemPool& rItemPool - , SdrModel& rDrawModel - , const uno::Reference< frame::XModel >& xChartModel - , double fUIScale ) - : ItemConverter( xPropertySet, rItemPool ) - , m_xChartModel( xChartModel ) - , m_fUIScale( fUIScale ) -{ - m_aConverters.push_back( new GraphicPropertyItemConverter( - xPropertySet, rItemPool, rDrawModel, uno::Reference< lang::XMultiServiceFactory >( xChartModel, uno::UNO_QUERY ), - GraphicPropertyItemConverter::LINE_AND_FILL_PROPERTIES )); -} - -DiagramItemConverter::~DiagramItemConverter() -{ - ::std::for_each( m_aConverters.begin(), m_aConverters.end(), - ::comphelper::DeleteItemConverterPtr() ); -} - -void DiagramItemConverter::FillItemSet( SfxItemSet & rOutItemSet ) const -{ - ::std::for_each( m_aConverters.begin(), m_aConverters.end(), - ::comphelper::FillItemSetFunc( rOutItemSet )); - - // own items - ItemConverter::FillItemSet( rOutItemSet ); -} - -bool DiagramItemConverter::ApplyItemSet( const SfxItemSet & rItemSet ) -{ - bool bResult = false; - - ::std::for_each( m_aConverters.begin(), m_aConverters.end(), - ::comphelper::ApplyItemSetFunc( rItemSet, bResult )); - - // own items - return ItemConverter::ApplyItemSet( rItemSet ) || bResult; -} - -const USHORT * DiagramItemConverter::GetWhichPairs() const -{ - // must span all used items! - return nDiagramWhichPairs; -} - -bool DiagramItemConverter::GetItemProperty( tWhichIdType /*nWhichId*/, tPropertyNameWithMemberId & /*rOutProperty*/ ) const -{ - // No own (non-special) properties - return false; -} - - -bool DiagramItemConverter::ApplySpecialItem( - USHORT nWhichId, const SfxItemSet & rItemSet ) - throw( uno::Exception ) -{ - bool bChanged = false; - - switch( nWhichId ) - { - case SCHATTR_DIAGRAM_POS_MODE: - { - try - { - sal_Int32 nValue = static_cast< const SfxInt32Item & >( rItemSet.Get( nWhichId )).GetValue(); - DiagramPositioningMode eMode = static_cast< DiagramPositioningMode >(nValue); - bChanged = DiagramHelper::setDiagramPositioningMode( ChartModelHelper::findDiagram( m_xChartModel ), eMode ); - } - catch( uno::Exception & ex ) - { - ASSERT_EXCEPTION( ex ); - } - } - break; - case SCHATTR_DIAGRAM_RECT_TO_USE: - { - sal_Int32 nValue = static_cast< const SfxInt32Item & >( rItemSet.Get( SCHATTR_DIAGRAM_POS_MODE )).GetValue(); - DiagramPositioningMode ePosMode = static_cast< DiagramPositioningMode >(nValue); - if( ePosMode != DiagramPositioningMode_AUTO ) - { - Rectangle aRect = static_cast< const SfxRectangleItem & >( rItemSet.Get( nWhichId )).GetValue(); - bChanged = DiagramHelper::setDiagramPositioning( m_xChartModel, awt::Rectangle( aRect.getX(), aRect.getY(), aRect.getWidth(), aRect.getHeight() ) ); - } - } - break; - } - - return bChanged; -} - -void DiagramItemConverter::FillSpecialItem( - USHORT nWhichId, SfxItemSet & rOutItemSet ) const - throw( uno::Exception ) -{ - switch( nWhichId ) - { - case SCHATTR_DIAGRAM_POS_MODE: - { - DiagramPositioningMode eMode = DiagramHelper::getDiagramPositioningMode( ChartModelHelper::findDiagram( m_xChartModel ) ); - rOutItemSet.Put( SfxInt32Item( nWhichId, eMode ) ); - } - break; - case SCHATTR_DIAGRAM_RECT_TO_USE: - { - awt::Rectangle aRect(0,0,0,0); - DiagramPositioningMode eMode = DiagramHelper::getDiagramPositioningMode( ChartModelHelper::findDiagram( m_xChartModel ) ); - uno::Reference< lang::XMultiServiceFactory > xFact( m_xChartModel, uno::UNO_QUERY ); - if( xFact.is() ) - { - ExplicitValueProvider* pProvider = ExplicitValueProvider::getExplicitValueProvider( xFact->createInstance( CHART_VIEW_SERVICE_NAME ) ); - //test - awt::Rectangle aTestInclusive = pProvider->getRectangleOfObject( C2U("PlotAreaIncludingAxes") ); - awt::Rectangle aTestExclusive = pProvider->getDiagramRectangleExcludingAxes(); - awt::Rectangle aModelRect = DiagramHelper::getDiagramRectangleFromModel( m_xChartModel ); - //end test - - if( eMode == DiagramPositioningMode_EXCLUDING ) - aRect = pProvider->getDiagramRectangleExcludingAxes(); - else - aRect = pProvider->getRectangleOfObject( C2U("PlotAreaIncludingAxes") ); - rOutItemSet.Put( SfxRectangleItem( nWhichId, Rectangle( aRect.X, aRect.Y, aRect.X+aRect.Width, aRect.Y+aRect.Height ) ) ); - } - } - break; - case SCHATTR_DIAGRAM_RECT_INCLUDING: - { - uno::Reference< lang::XMultiServiceFactory > xFact( m_xChartModel, uno::UNO_QUERY ); - if( xFact.is() ) - { - ExplicitValueProvider* pProvider = ExplicitValueProvider::getExplicitValueProvider( xFact->createInstance( CHART_VIEW_SERVICE_NAME ) ); - if( pProvider ) - { - awt::Rectangle aRect = pProvider->getRectangleOfObject( C2U("PlotAreaIncludingAxes") ); - rOutItemSet.Put( SfxRectangleItem( nWhichId, Rectangle( aRect.X, aRect.Y, aRect.X+aRect.Width, aRect.Y+aRect.Height ) ) ); - } - } - } - break; - case SCHATTR_DIAGRAM_RECT_EXCLUDING: - { - uno::Reference< lang::XMultiServiceFactory > xFact( m_xChartModel, uno::UNO_QUERY ); - if( xFact.is() ) - { - ExplicitValueProvider* pProvider = ExplicitValueProvider::getExplicitValueProvider( xFact->createInstance( CHART_VIEW_SERVICE_NAME ) ); - if( pProvider ) - { - awt::Rectangle aRect = pProvider->getDiagramRectangleExcludingAxes(); - rOutItemSet.Put( SfxRectangleItem( nWhichId, Rectangle( aRect.X, aRect.Y, aRect.X+aRect.Width, aRect.Y+aRect.Height ) ) ); - } - } - } - break; - case SCHATTR_DIAGRAM_RECT_MAX: - { - awt::Size aPageSize( ChartModelHelper::getPageSize( m_xChartModel) ); - Rectangle aRect(0,0,aPageSize.Width,aPageSize.Height); - rOutItemSet.Put( SfxRectangleItem( nWhichId, aRect ) ); - } - break; - case SCHATTR_DIAGRAM_UI_SCALE: - { - rOutItemSet.Put( SvxDoubleItem( m_fUIScale, nWhichId ) ); - } - break; - } -} - -} // namespace wrapper -} // namespace chart diff --git a/chart2/source/controller/itemsetwrapper/SchWhichPairs.hxx b/chart2/source/controller/itemsetwrapper/SchWhichPairs.hxx index bd971752954c..f7ddeb42c11e 100644 --- a/chart2/source/controller/itemsetwrapper/SchWhichPairs.hxx +++ b/chart2/source/controller/itemsetwrapper/SchWhichPairs.hxx @@ -97,14 +97,6 @@ const USHORT nLegendWhichPairs[] = 0 }; -const USHORT nDiagramWhichPairs[] = -{ - SCHATTR_DIAGRAM_START, SCHATTR_DIAGRAM_END, - SID_ATTR_TRANSFORM_POS_Y, SID_ATTR_TRANSFORM_POS_Y, - SID_ATTR_TRANSFORM_WIDTH, SID_ATTR_TRANSFORM_HEIGHT, - 0 -}; - const USHORT nDataLabelWhichPairs[] = { SCHATTR_DATADESCR_START, SCHATTR_DATADESCR_END, diff --git a/chart2/source/controller/itemsetwrapper/makefile.mk b/chart2/source/controller/itemsetwrapper/makefile.mk index 80ee9b5fed0b..8f12443c13f6 100644 --- a/chart2/source/controller/itemsetwrapper/makefile.mk +++ b/chart2/source/controller/itemsetwrapper/makefile.mk @@ -52,8 +52,7 @@ SLOFILES= $(SLO)$/ItemConverter.obj \ $(SLO)$/TitleItemConverter.obj \ $(SLO)$/RegressionCurveItemConverter.obj \ $(SLO)$/RegressionEquationItemConverter.obj \ - $(SLO)$/ErrorBarItemConverter.obj \ - $(SLO)$/DiagramItemConverter.obj + $(SLO)$/ErrorBarItemConverter.obj # --- Targets ----------------------------------------------------------------- diff --git a/chart2/source/controller/main/ChartController_Position.cxx b/chart2/source/controller/main/ChartController_Position.cxx index 83061be07fe5..3105ee53bf14 100644 --- a/chart2/source/controller/main/ChartController_Position.cxx +++ b/chart2/source/controller/main/ChartController_Position.cxx @@ -130,28 +130,17 @@ void SAL_CALL ChartController::executeDispatch_PositionAndSize() if( !aCID.getLength() ) return; - ObjectType eObjectType = ObjectIdentifier::getObjectType( aCID ); + awt::Size aSelectedSize; + ExplicitValueProvider* pProvider( ExplicitValueProvider::getExplicitValueProvider( m_xChartView ) ); + if( pProvider ) + aSelectedSize = ToSize( ( pProvider->getRectangleOfObject( aCID ) ) ); UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::POS_SIZE, - ObjectNameProvider::getName( eObjectType )), + ObjectNameProvider::getName( ObjectIdentifier::getObjectType( aCID ))), m_xUndoManager, m_aModel->getModel() ); - if( OBJECTTYPE_DIAGRAM == eObjectType || OBJECTTYPE_DIAGRAM_WALL == eObjectType ) - { - rtl::OUString aDiaCID = ObjectIdentifier::createClassifiedIdentifierForParticle( ObjectIdentifier::createParticleForDiagram( ChartModelHelper::findDiagram( m_aModel->getModel() ), m_aModel->getModel() ) ); - bool bSuccess = executeDlg_ObjectProperties_withoutUndoGuard( aDiaCID, false ); - if( bSuccess ) - aUndoGuard.commitAction(); - return; - } - - awt::Size aSelectedSize; - ExplicitValueProvider* pProvider( ExplicitValueProvider::getExplicitValueProvider( m_xChartView ) ); - if( pProvider ) - aSelectedSize = ToSize( ( pProvider->getRectangleOfObject( aCID ) ) ); - SfxAbstractTabDialog * pDlg = NULL; try { diff --git a/chart2/source/controller/main/ChartController_Properties.cxx b/chart2/source/controller/main/ChartController_Properties.cxx index 1b467cdbee7a..3c5a0b135622 100644 --- a/chart2/source/controller/main/ChartController_Properties.cxx +++ b/chart2/source/controller/main/ChartController_Properties.cxx @@ -60,7 +60,6 @@ #include "Strings.hrc" #include "ReferenceSizeProvider.hxx" #include "RegressionCurveHelper.hxx" -#include "DiagramItemConverter.hxx" #include //for auto_ptr @@ -152,9 +151,6 @@ namespace case OBJECTTYPE_LEGEND_ENTRY: break; case OBJECTTYPE_DIAGRAM: - pItemConverter = new wrapper::DiagramItemConverter( - xObjectProperties, rDrawModel.GetItemPool(), - rDrawModel, xChartModel, rDrawModel.GetUIScale() ); break; case OBJECTTYPE_DIAGRAM_WALL: case OBJECTTYPE_DIAGRAM_FLOOR: diff --git a/chart2/source/inc/DiagramHelper.hxx b/chart2/source/inc/DiagramHelper.hxx index 541587cd0520..1886609d8600 100644 --- a/chart2/source/inc/DiagramHelper.hxx +++ b/chart2/source/inc/DiagramHelper.hxx @@ -327,8 +327,6 @@ public: static DiagramPositioningMode getDiagramPositioningMode( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram > & xDiagram ); - static bool setDiagramPositioningMode( const ::com::sun::star::uno::Reference< - ::com::sun::star::chart2::XDiagram > & xDiagram, DiagramPositioningMode eMode ); static bool setDiagramPositioning( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xChartModel, const ::com::sun::star::awt::Rectangle& rPosRect /*100th mm*/ ); diff --git a/chart2/source/inc/ObjectIdentifier.hxx b/chart2/source/inc/ObjectIdentifier.hxx index ed598269a420..0765c9acf94a 100644 --- a/chart2/source/inc/ObjectIdentifier.hxx +++ b/chart2/source/inc/ObjectIdentifier.hxx @@ -135,7 +135,7 @@ public: ::com::sun::star::frame::XModel >& xChartModel , sal_Int32 nSubIndex = -1 );//-1: main grid, 0: first subgrid etc - static rtl::OUString createParticleForDiagram( + SAL_DLLPRIVATE static rtl::OUString createParticleForDiagram( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram >& xDiagram , const ::com::sun::star::uno::Reference< diff --git a/chart2/source/inc/Strings.hrc b/chart2/source/inc/Strings.hrc index a9b827407a99..47ed75e80a9a 100644 --- a/chart2/source/inc/Strings.hrc +++ b/chart2/source/inc/Strings.hrc @@ -31,6 +31,7 @@ #include //next free is 291 +//single free is: 134 //#define RID_APP_START 30000 ////#define STR_NULL (RID_APP_START + 1) @@ -297,7 +298,6 @@ #define STR_DLG_NUMBERFORMAT_FOR_PERCENTAGE_VALUE (RID_APP_START + 266) #define STR_PAGE_POSITIONING (RID_APP_START + 277) -#define STR_PAGE_POSITIONANDSIZE (RID_APP_START + 134) #define STR_PAGE_ASIAN (RID_APP_START + 281) //----------------------------------------------------------------------------- diff --git a/chart2/source/inc/chartview/ChartSfxItemIds.hxx b/chart2/source/inc/chartview/ChartSfxItemIds.hxx index dc390791b81e..fbcce70bd1d6 100644 --- a/chart2/source/inc/chartview/ChartSfxItemIds.hxx +++ b/chart2/source/inc/chartview/ChartSfxItemIds.hxx @@ -55,16 +55,7 @@ #define SCHATTR_LEGEND_POS SCHATTR_LEGEND_START #define SCHATTR_LEGEND_END SCHATTR_LEGEND_POS -#define SCHATTR_DIAGRAM_START (SCHATTR_LEGEND_END + 1) -#define SCHATTR_DIAGRAM_POS_MODE SCHATTR_DIAGRAM_START -#define SCHATTR_DIAGRAM_RECT_TO_USE SCHATTR_DIAGRAM_START + 1 -#define SCHATTR_DIAGRAM_RECT_INCLUDING SCHATTR_DIAGRAM_START + 2 -#define SCHATTR_DIAGRAM_RECT_EXCLUDING SCHATTR_DIAGRAM_START + 3 -#define SCHATTR_DIAGRAM_RECT_MAX SCHATTR_DIAGRAM_START + 4 -#define SCHATTR_DIAGRAM_UI_SCALE SCHATTR_DIAGRAM_START + 5 -#define SCHATTR_DIAGRAM_END SCHATTR_DIAGRAM_UI_SCALE - -#define SCHATTR_TEXT_START (SCHATTR_DIAGRAM_END + 1) +#define SCHATTR_TEXT_START (SCHATTR_LEGEND_END + 1) // #define SCHATTR_TEXT_ORIENT SCHATTR_TEXT_START // name changed: #define SCHATTR_TEXT_STACKED SCHATTR_TEXT_START diff --git a/chart2/source/tools/DiagramHelper.cxx b/chart2/source/tools/DiagramHelper.cxx index 146f45ed0c63..a71daa4139eb 100644 --- a/chart2/source/tools/DiagramHelper.cxx +++ b/chart2/source/tools/DiagramHelper.cxx @@ -41,6 +41,7 @@ #include "servicenames_charttypes.hxx" #include "ChartModelHelper.hxx" #include "RelativePositionHelper.hxx" +#include "ControllerLockGuard.hxx" #include #include @@ -1435,55 +1436,6 @@ DiagramPositioningMode DiagramHelper::getDiagramPositioningMode( const uno::Refe return eMode; } -//static -bool DiagramHelper::setDiagramPositioningMode( const uno::Reference< - chart2::XDiagram > & xDiagram, DiagramPositioningMode eMode ) -{ - bool bChanged = false; - uno::Reference< beans::XPropertySet > xDiaProps( xDiagram, uno::UNO_QUERY ); - if( !xDiaProps.is() ) - return bChanged; - - bool bOld = false; - xDiaProps->getPropertyValue(C2U("PosSizeExcludeAxes")) >>= bOld; - bool bNew = bOld; - - if( eMode == DiagramPositioningMode_AUTO ) - { - - RelativePosition aPos; - if( (xDiaProps->getPropertyValue(C2U("RelativePosition") ) >>= aPos) ) - bChanged = true; - if( !bChanged ) - { - RelativeSize aSize; - if( (xDiaProps->getPropertyValue(C2U("RelativeSize") ) >>= aSize) ) - bChanged = true; - } - - if( bChanged ) - { - xDiaProps->setPropertyValue(C2U("RelativePosition"), uno::Any() ); - xDiaProps->setPropertyValue(C2U("RelativeSize"), uno::Any() ); - } - } - else if( eMode == DiagramPositioningMode_EXCLUDING ) - { - bNew = true; - bChanged = (bNew!=bOld); - if(bChanged) - xDiaProps->setPropertyValue(C2U("PosSizeExcludeAxes"), uno::makeAny(bNew) ); - } - else if( eMode == DiagramPositioningMode_INCLUDING) - { - bNew = false; - bChanged = (bNew!=bOld); - if(bChanged) - xDiaProps->setPropertyValue(C2U("PosSizeExcludeAxes"), uno::makeAny(bNew) ); - } - return bChanged; -} - void lcl_ensureRange0to1( double& rValue ) { if(rValue<0.0) @@ -1496,6 +1448,8 @@ void lcl_ensureRange0to1( double& rValue ) bool DiagramHelper::setDiagramPositioning( const uno::Reference< frame::XModel >& xChartModel, const awt::Rectangle& rPosRect /*100th mm*/ ) { + ControllerLockGuard aCtrlLockGuard( xChartModel ); + bool bChanged = false; awt::Size aPageSize( ChartModelHelper::getPageSize(xChartModel) ); uno::Reference< beans::XPropertySet > xDiaProps( ChartModelHelper::findDiagram( xChartModel ), uno::UNO_QUERY ); diff --git a/chart2/source/view/main/ChartItemPool.cxx b/chart2/source/view/main/ChartItemPool.cxx index 222345f016e4..d8f997d36da9 100644 --- a/chart2/source/view/main/ChartItemPool.cxx +++ b/chart2/source/view/main/ChartItemPool.cxx @@ -67,13 +67,6 @@ ChartItemPool::ChartItemPool(): ppPoolDefaults[SCHATTR_DATADESCR_NO_PERCENTVALUE - SCHATTR_START] = new SfxBoolItem(SCHATTR_DATADESCR_NO_PERCENTVALUE); ppPoolDefaults[SCHATTR_LEGEND_POS - SCHATTR_START] = new SvxChartLegendPosItem( CHLEGEND_RIGHT, SCHATTR_LEGEND_POS ); - ppPoolDefaults[SCHATTR_DIAGRAM_POS_MODE - SCHATTR_START] = new SfxInt32Item( SCHATTR_DIAGRAM_POS_MODE,0 ); - ppPoolDefaults[SCHATTR_DIAGRAM_RECT_TO_USE - SCHATTR_START] = new SfxRectangleItem( SCHATTR_DIAGRAM_RECT_TO_USE, Rectangle(0,0,100,100) ); - ppPoolDefaults[SCHATTR_DIAGRAM_RECT_INCLUDING - SCHATTR_START] = new SfxRectangleItem( SCHATTR_DIAGRAM_RECT_INCLUDING, Rectangle(0,0,100,100) ); - ppPoolDefaults[SCHATTR_DIAGRAM_RECT_EXCLUDING - SCHATTR_START] = new SfxRectangleItem( SCHATTR_DIAGRAM_RECT_EXCLUDING, Rectangle(0,0,100,100) ); - ppPoolDefaults[SCHATTR_DIAGRAM_RECT_MAX - SCHATTR_START] = new SfxRectangleItem( SCHATTR_DIAGRAM_RECT_MAX, Rectangle(0,0,100,100) ); - ppPoolDefaults[SCHATTR_DIAGRAM_UI_SCALE - SCHATTR_START] = new SvxDoubleItem(1.0, SCHATTR_DIAGRAM_UI_SCALE); - // ppPoolDefaults[SCHATTR_TEXT_ORIENT - SCHATTR_START] = new SvxChartTextOrientItem; ppPoolDefaults[SCHATTR_TEXT_STACKED - SCHATTR_START] = new SfxBoolItem(SCHATTR_TEXT_STACKED,FALSE); ppPoolDefaults[SCHATTR_TEXT_ORDER - SCHATTR_START] = new SvxChartTextOrderItem(CHTXTORDER_SIDEBYSIDE, SCHATTR_TEXT_ORDER); diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx index d36c20837f95..534c24cae1ad 100644 --- a/chart2/source/view/main/ChartView.cxx +++ b/chart2/source/view/main/ChartView.cxx @@ -72,12 +72,15 @@ #include #include #include +#include #include #include #include #include +#include +#include #include #include #include @@ -314,7 +317,7 @@ uno::Any SAL_CALL ChartView::getTransferData( const datatransfer::DataFlavor& aF if( ! (bHighContrastMetaFile || aFlavor.MimeType.equals(lcl_aGDIMetaFileMIMEType)) ) return aRet; - impl_updateView(); + update(); SvMemoryStream aStream( 1024, 1024 ); utl::OStreamWrapper* pStreamWrapper = new utl::OStreamWrapper( aStream ); @@ -2815,17 +2818,6 @@ void ChartView::impl_updateView() //create chart view { - /* - ::vos::OGuard aGuard( Application::GetSolarMutex()); - while( m_bViewDirty ) - { - createShapes(); - m_bViewDirty = m_bViewUpdatePending; - m_bViewUpdatePending = false; - m_bInViewUpdate = false; - } - */ - m_bViewDirty = false; m_bViewUpdatePending = false; createShapes(); @@ -2991,6 +2983,33 @@ void SAL_CALL ChartView::removeModeChangeApproveListener( const uno::Reference< void SAL_CALL ChartView::update() throw (uno::RuntimeException) { impl_updateView(); + + //#i100778# migrate all imported or old documents to a plot area sizing exclusive axes (in case the save settings allow for this): + //Although in general it is a bad idea to change the model from within the view this is exceptionally the best place to do this special conversion. + //When a view update is requested (what happens for creating the metafile or displaying + //the chart in edit mode or printing) it is most likely that all necessary informations are available - like the underlying spreadsheet data for example. + //Those data is important for the correct axis lable sizes which are needed during conversion. + const SvtSaveOptions::ODFDefaultVersion nCurrentODFVersion( SvtSaveOptions().GetODFDefaultVersion() ); + if( nCurrentODFVersion == SvtSaveOptions::ODFVER_LATEST )//#i100778# todo: change this dependent on fileformat evolution + { + uno::Reference< ::com::sun::star::chart::XChartDocument > xOldDoc( m_xChartModel, uno::UNO_QUERY ) ; + if( xOldDoc.is() ) + { + uno::Reference< ::com::sun::star::chart::XDiagramPositioning > xDiagramPositioning( xOldDoc->getDiagram(), uno::UNO_QUERY ); + if( xDiagramPositioning.is() && !xDiagramPositioning->isAutomaticDiagramPositioning() && !xDiagramPositioning->isExcludingDiagramPositioning() ) + { + { + ControllerLockGuard aCtrlLockGuard( m_xChartModel ); + uno::Reference< util::XModifiable > xModifiable( m_xChartModel, uno::UNO_QUERY ); + bool bModelWasModified = xModifiable.is() && xModifiable->isModified(); + xDiagramPositioning->setDiagramPositionExcludingAxes( xDiagramPositioning->calculateDiagramPositionExcludingAxes() ); + if(!bModelWasModified && xModifiable.is() ) + xModifiable->setModified(sal_False); + } + impl_updateView(); + } + } + } } // ____ XPropertySet ____ -- cgit From e0a1128c4b13e2f32a76e0b5f55839b705798da0 Mon Sep 17 00:00:00 2001 From: Ingrid Halama Date: Mon, 10 May 2010 16:30:45 +0200 Subject: chartpositioning: #i100778# switch to manual positioning if shapes are added via user interface --- chart2/source/controller/main/ChartController.hxx | 2 ++ .../controller/main/ChartController_Tools.cxx | 15 ++++++++++ .../controller/main/ChartController_Window.cxx | 1 + chart2/source/inc/DiagramHelper.hxx | 5 ++++ chart2/source/tools/DiagramHelper.cxx | 35 +++++++++++++++++++++- chart2/source/view/main/ChartView.cxx | 26 ++-------------- 6 files changed, 59 insertions(+), 25 deletions(-) (limited to 'chart2') diff --git a/chart2/source/controller/main/ChartController.hxx b/chart2/source/controller/main/ChartController.hxx index 8deffe47396f..81f4ba5a549e 100644 --- a/chart2/source/controller/main/ChartController.hxx +++ b/chart2/source/controller/main/ChartController.hxx @@ -725,6 +725,8 @@ private: void impl_SetMousePointer( const MouseEvent & rEvent ); void impl_ClearSelection(); + + void impl_switchDiagramPositioningToExcludingPositioning(); }; //............................................................................. diff --git a/chart2/source/controller/main/ChartController_Tools.cxx b/chart2/source/controller/main/ChartController_Tools.cxx index be9bc092ba4c..11fa5e74054e 100644 --- a/chart2/source/controller/main/ChartController_Tools.cxx +++ b/chart2/source/controller/main/ChartController_Tools.cxx @@ -50,6 +50,7 @@ #include "RegressionCurveHelper.hxx" #include "ShapeController.hxx" #include "DiagramHelper.hxx" +#include "ObjectNameProvider.hxx" #include #include @@ -469,6 +470,8 @@ void ChartController::impl_PasteShapes( SdrModel* pModel ) m_aSelection.applySelection( m_pDrawViewWrapper ); m_pDrawViewWrapper->EndUndo(); + + impl_switchDiagramPositioningToExcludingPositioning(); } } } @@ -515,6 +518,8 @@ void ChartController::impl_PasteStringAsTextShape( const OUString& rString, cons m_pDrawViewWrapper->BegUndo( SVX_RESSTR( RID_SVX_3D_UNDO_EXCHANGE_PASTE ) ); m_pDrawViewWrapper->AddUndo( new SdrUndoInsertObj( *pObj ) ); m_pDrawViewWrapper->EndUndo(); + + impl_switchDiagramPositioningToExcludingPositioning(); } } catch ( const uno::Exception& ex ) @@ -903,4 +908,14 @@ void ChartController::impl_ShapeControllerDispatch( const util::URL& rURL, const } } +void ChartController::impl_switchDiagramPositioningToExcludingPositioning() +{ + UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( + ActionDescriptionProvider::POS_SIZE, + ObjectNameProvider::getName( OBJECTTYPE_DIAGRAM)), + m_xUndoManager, m_aModel->getModel() ); + if( DiagramHelper::switchDiagramPositioningToExcludingPositioning( m_aModel->getModel(), true, true ) ) + aUndoGuard.commitAction(); +} + } // namespace chart diff --git a/chart2/source/controller/main/ChartController_Window.cxx b/chart2/source/controller/main/ChartController_Window.cxx index 176d38aa5fc3..91531683f7c5 100644 --- a/chart2/source/controller/main/ChartController_Window.cxx +++ b/chart2/source/controller/main/ChartController_Window.cxx @@ -796,6 +796,7 @@ void ChartController::execute_MouseButtonUp( const MouseEvent& rMEvt ) if ( m_eDrawMode == CHARTDRAW_INSERT && pDrawViewWrapper->IsCreateObj() ) { pDrawViewWrapper->EndCreateObj( SDRCREATE_FORCEEND ); + impl_switchDiagramPositioningToExcludingPositioning(); if ( pDrawViewWrapper->AreObjectsMarked() ) { if ( pDrawViewWrapper->GetCurrentObjIdentifier() == OBJ_TEXT ) diff --git a/chart2/source/inc/DiagramHelper.hxx b/chart2/source/inc/DiagramHelper.hxx index 1886609d8600..c7cda6189680 100644 --- a/chart2/source/inc/DiagramHelper.hxx +++ b/chart2/source/inc/DiagramHelper.hxx @@ -333,6 +333,11 @@ public: static ::com::sun::star::awt::Rectangle getDiagramRectangleFromModel( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xChartModel ); + static bool switchDiagramPositioningToExcludingPositioning( const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel >& xChartModel + , bool bResetModifiedState //set model back to unchanged if it was unchanged before + , bool bConvertAlsoFromAutoPositioning ); + private: // not implemented DiagramHelper(); diff --git a/chart2/source/tools/DiagramHelper.cxx b/chart2/source/tools/DiagramHelper.cxx index a71daa4139eb..4ce623ae460c 100644 --- a/chart2/source/tools/DiagramHelper.cxx +++ b/chart2/source/tools/DiagramHelper.cxx @@ -44,6 +44,8 @@ #include "ControllerLockGuard.hxx" #include +#include +#include #include #include #include @@ -54,10 +56,12 @@ #include #include #include -#include +#include #include +#include + using namespace ::com::sun::star; using namespace ::com::sun::star::chart2; using namespace ::std; @@ -1521,4 +1525,33 @@ awt::Rectangle DiagramHelper::getDiagramRectangleFromModel( const uno::Reference return aRet; } +//static +bool DiagramHelper::switchDiagramPositioningToExcludingPositioning( + const uno::Reference< frame::XModel >& xChartModel + , bool bResetModifiedState, bool bConvertAlsoFromAutoPositioning ) +{ + //return true if something was changed + const SvtSaveOptions::ODFDefaultVersion nCurrentODFVersion( SvtSaveOptions().GetODFDefaultVersion() ); + if( nCurrentODFVersion == SvtSaveOptions::ODFVER_LATEST )//#i100778# todo: change this dependent on fileformat evolution + { + uno::Reference< ::com::sun::star::chart::XChartDocument > xOldDoc( xChartModel, uno::UNO_QUERY ) ; + if( xOldDoc.is() ) + { + uno::Reference< ::com::sun::star::chart::XDiagramPositioning > xDiagramPositioning( xOldDoc->getDiagram(), uno::UNO_QUERY ); + if( xDiagramPositioning.is() && ( bConvertAlsoFromAutoPositioning || !xDiagramPositioning->isAutomaticDiagramPositioning() ) + && !xDiagramPositioning->isExcludingDiagramPositioning() ) + { + ControllerLockGuard aCtrlLockGuard( xChartModel ); + uno::Reference< util::XModifiable > xModifiable( xChartModel, uno::UNO_QUERY ); + bool bModelWasModified = xModifiable.is() && xModifiable->isModified(); + xDiagramPositioning->setDiagramPositionExcludingAxes( xDiagramPositioning->calculateDiagramPositionExcludingAxes() ); + if(bResetModifiedState && !bModelWasModified && xModifiable.is() ) + xModifiable->setModified(sal_False); + return true; + } + } + } + return false; +} + } // namespace chart diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx index 534c24cae1ad..886bab7ced29 100644 --- a/chart2/source/view/main/ChartView.cxx +++ b/chart2/source/view/main/ChartView.cxx @@ -72,15 +72,12 @@ #include #include #include -#include #include #include #include #include -#include -#include #include #include #include @@ -2989,27 +2986,8 @@ void SAL_CALL ChartView::update() throw (uno::RuntimeException) //When a view update is requested (what happens for creating the metafile or displaying //the chart in edit mode or printing) it is most likely that all necessary informations are available - like the underlying spreadsheet data for example. //Those data is important for the correct axis lable sizes which are needed during conversion. - const SvtSaveOptions::ODFDefaultVersion nCurrentODFVersion( SvtSaveOptions().GetODFDefaultVersion() ); - if( nCurrentODFVersion == SvtSaveOptions::ODFVER_LATEST )//#i100778# todo: change this dependent on fileformat evolution - { - uno::Reference< ::com::sun::star::chart::XChartDocument > xOldDoc( m_xChartModel, uno::UNO_QUERY ) ; - if( xOldDoc.is() ) - { - uno::Reference< ::com::sun::star::chart::XDiagramPositioning > xDiagramPositioning( xOldDoc->getDiagram(), uno::UNO_QUERY ); - if( xDiagramPositioning.is() && !xDiagramPositioning->isAutomaticDiagramPositioning() && !xDiagramPositioning->isExcludingDiagramPositioning() ) - { - { - ControllerLockGuard aCtrlLockGuard( m_xChartModel ); - uno::Reference< util::XModifiable > xModifiable( m_xChartModel, uno::UNO_QUERY ); - bool bModelWasModified = xModifiable.is() && xModifiable->isModified(); - xDiagramPositioning->setDiagramPositionExcludingAxes( xDiagramPositioning->calculateDiagramPositionExcludingAxes() ); - if(!bModelWasModified && xModifiable.is() ) - xModifiable->setModified(sal_False); - } - impl_updateView(); - } - } - } + if( DiagramHelper::switchDiagramPositioningToExcludingPositioning( m_xChartModel, true, false ) ) + impl_updateView(); } // ____ XPropertySet ____ -- cgit From 017f1bc3f7b1810f2cbf1ba5971184920be87cf8 Mon Sep 17 00:00:00 2001 From: Ingrid Halama Date: Mon, 10 May 2010 18:52:14 +0200 Subject: chartpositioning: #i100778# for exploded pie charts use the offset of the series as radius for excluding positioning --- chart2/source/view/charttypes/PieChart.cxx | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'chart2') diff --git a/chart2/source/view/charttypes/PieChart.cxx b/chart2/source/view/charttypes/PieChart.cxx index 93f9440d2317..eee13848b11b 100644 --- a/chart2/source/view/charttypes/PieChart.cxx +++ b/chart2/source/view/charttypes/PieChart.cxx @@ -280,18 +280,21 @@ double PieChart::getMaxOffset() if(fExplodePercentage>m_fMaxOffset) m_fMaxOffset=fExplodePercentage; - uno::Sequence< sal_Int32 > aAttributedDataPointIndexList; - if( xSeriesProp->getPropertyValue( C2U( "AttributedDataPoints" ) ) >>= aAttributedDataPointIndexList ) + if(!m_bSizeExcludesLabelsAndExplodedSegments) { - for(sal_Int32 nN=aAttributedDataPointIndexList.getLength();nN--;) + uno::Sequence< sal_Int32 > aAttributedDataPointIndexList; + if( xSeriesProp->getPropertyValue( C2U( "AttributedDataPoints" ) ) >>= aAttributedDataPointIndexList ) { - uno::Reference< beans::XPropertySet > xPointProp( pSeries->getPropertiesOfPoint(aAttributedDataPointIndexList[nN]) ); - if(xPointProp.is()) + for(sal_Int32 nN=aAttributedDataPointIndexList.getLength();nN--;) { - fExplodePercentage=0.0; - xPointProp->getPropertyValue( C2U( "Offset" )) >>= fExplodePercentage; - if(fExplodePercentage>m_fMaxOffset) - m_fMaxOffset=fExplodePercentage; + uno::Reference< beans::XPropertySet > xPointProp( pSeries->getPropertiesOfPoint(aAttributedDataPointIndexList[nN]) ); + if(xPointProp.is()) + { + fExplodePercentage=0.0; + xPointProp->getPropertyValue( C2U( "Offset" )) >>= fExplodePercentage; + if(fExplodePercentage>m_fMaxOffset) + m_fMaxOffset=fExplodePercentage; + } } } } @@ -299,7 +302,7 @@ double PieChart::getMaxOffset() } double PieChart::getMaximumX() { - double fMaxOffset = m_bSizeExcludesLabelsAndExplodedSegments ? 0.0 : getMaxOffset(); + double fMaxOffset = getMaxOffset(); if( m_aZSlots.size()>0 && m_bUseRings) return m_aZSlots[0].size()+0.5+fMaxOffset; return 1.5+fMaxOffset; @@ -403,7 +406,7 @@ void PieChart::createShapes() for( nPointIndex = 0; nPointIndex < nPointCount; nPointIndex++ ) { double fLogicInnerRadius, fLogicOuterRadius; - double fOffset = m_bSizeExcludesLabelsAndExplodedSegments ? 0.0 : getMaxOffset(); + double fOffset = getMaxOffset(); bool bIsVisible = m_pPosHelper->getInnerAndOuterRadius( fSlotX+1.0, fLogicInnerRadius, fLogicOuterRadius, m_bUseRings, fOffset ); if( !bIsVisible ) continue; -- cgit