diff options
author | Ingrid Halama <iha@openoffice.org> | 2004-01-17 12:10:08 +0000 |
---|---|---|
committer | Ingrid Halama <iha@openoffice.org> | 2004-01-17 12:10:08 +0000 |
commit | b064ca8aa953835e683f3e4679b08c37fc48507d (patch) | |
tree | f30b96e3d9039e482432f3e1aa7b8432cd632bfb /chart2 | |
parent | 8fb7f58276fd9541f6e17da81965648c8af5519f (diff) |
introduced polarcoordinate system + axis + grids + some cleanup
Diffstat (limited to 'chart2')
56 files changed, 5076 insertions, 1206 deletions
diff --git a/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx b/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx index 2990ccaece19..b5412dbb492f 100644 --- a/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx +++ b/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx @@ -2,9 +2,9 @@ * * $RCSfile: dlg_ObjectProperties.cxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: iha $ $Date: 2003-12-15 20:23:20 $ + * last change: $Author: iha $ $Date: 2004-01-17 13:09:45 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -127,10 +127,10 @@ namespace sal_Int32 lcl_getDimensionCount( const uno::Reference< frame::XModel >& xChartModel ) { - uno::Reference< XDiagram > xDiagram = ChartModelHelper::findDiagram( xChartModel ); - rtl::OUString aChartType; - sal_Int32 nDimension = ChartModelHelper::getDimensionAndFirstChartType(xDiagram,aChartType); - return nDimension; + sal_Int32 nDimensionCount = ChartTypeHelper::getDimensionCount( + ChartModelHelper::getFirstChartType( + ChartModelHelper::findDiagram( xChartModel ) ) ); + return nDimensionCount; } }//end anonymous namespace @@ -179,7 +179,7 @@ void ObjectPropertiesDialogParameter::init( const uno::Reference< frame::XModel { m_bHasStatisticProperties = ChartTypeHelper::isSupportingStatisticProperties( xChartType ); m_bHasRegressionProperties = ChartTypeHelper::isSupportingRegressionProperties( xChartType ); - m_bProvidesSecondaryYAxis = ChartTypeHelper::isSupportingSecondaryYAxis( xChartType ); + m_bProvidesSecondaryYAxis = ChartTypeHelper::isSupportingSecondaryAxis( xChartType, 1 ); } if( OBJECTTYPE_AXIS == m_eObjectType ) diff --git a/chart2/source/controller/main/ChartController_Window.cxx b/chart2/source/controller/main/ChartController_Window.cxx index e8108e9edaba..6656f121498b 100644 --- a/chart2/source/controller/main/ChartController_Window.cxx +++ b/chart2/source/controller/main/ChartController_Window.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ChartController_Window.cxx,v $ * - * $Revision: 1.14 $ + * $Revision: 1.15 $ * - * last change: $Author: iha $ $Date: 2004-01-06 19:37:12 $ + * last change: $Author: iha $ $Date: 2004-01-17 13:09:46 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -69,6 +69,7 @@ #include "CommonConverters.hxx" #include "Rotation.hxx" #include "ChartModelHelper.hxx" +#include "ChartTypeHelper.hxx" #ifndef _DRAFTS_COM_SUN_STAR_CHART2_SCENEDESCRIPTOR_HPP_ #include <drafts/com/sun/star/chart2/SceneDescriptor.hpp> @@ -415,9 +416,9 @@ bool lcl_isRotateableObject( const rtl::OUString& rSelectedObjectCID, const uno: if( rSelectedObjectCID.indexOf(C2U("Diagram"))==-1 ) return false; - rtl::OUString aDummy; - sal_Int32 nDimensionCount = ChartModelHelper::getDimensionAndFirstChartType( - ChartModelHelper::findDiagram( xChartModel ), aDummy ); + sal_Int32 nDimensionCount = ChartTypeHelper::getDimensionCount( + ChartModelHelper::getFirstChartType( + ChartModelHelper::findDiagram( xChartModel ) ) ); if( nDimensionCount == 3 ) return true; return false; diff --git a/chart2/source/controller/makefile.mk b/chart2/source/controller/makefile.mk index b0c0e198864c..895afd7e8c81 100644 --- a/chart2/source/controller/makefile.mk +++ b/chart2/source/controller/makefile.mk @@ -2,9 +2,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.3 $ +# $Revision: 1.4 $ # -# last change: $Author: bm $ $Date: 2003-12-18 13:54:57 $ +# last change: $Author: iha $ $Date: 2004-01-17 13:09:45 $ # # The Contents of this file are made available subject to the terms of # either of the following licenses @@ -90,13 +90,13 @@ LIB1FILES= \ SHL1TARGET= $(TARGET)$(UPD)$(DLLPOSTFIX) #indicates dependencies: -# .IF "$(COM)" == "MSC" -# SHL1DEPN = \ -# $(SLB)$/charttools.lib \ -# $(SLB)$/chartview.lib -# .ELSE -# SHL1DEPN = -# .ENDIF +.IF "$(COM)" == "MSC" +SHL1DEPN = \ + $(SLB)$/charttools.lib \ + $(SLB)$/chartview.lib +.ELSE +SHL1DEPN = +.ENDIF #Specifies an import library to create. For Win32 only. SHL1IMPLIB= i$(TARGET) diff --git a/chart2/source/inc/ChartModelHelper.hxx b/chart2/source/inc/ChartModelHelper.hxx index 8883f7f0dd8d..2f08b76108fc 100644 --- a/chart2/source/inc/ChartModelHelper.hxx +++ b/chart2/source/inc/ChartModelHelper.hxx @@ -2,9 +2,9 @@ * * $RCSfile: ChartModelHelper.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: iha $ $Date: 2003-11-08 22:52:47 $ + * last change: $Author: iha $ $Date: 2004-01-17 13:09:47 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -93,8 +93,10 @@ public: ::drafts::com::sun::star::chart2::XDiagram > findDiagram( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xModel ); - static sal_Int32 getDimensionAndFirstChartType( const ::com::sun::star::uno::Reference< - ::drafts::com::sun::star::chart2::XDiagram >& xDiagram, rtl::OUString& rChartType ); + static ::com::sun::star::uno::Reference< + ::drafts::com::sun::star::chart2::XChartType > + getFirstChartType( const ::com::sun::star::uno::Reference< + ::drafts::com::sun::star::chart2::XDiagram >& xDiagram ); static ::std::vector< ::com::sun::star::uno::Reference< ::drafts::com::sun::star::chart2::XDataSeries > > getDataSeries( diff --git a/chart2/source/inc/ChartTypeHelper.hxx b/chart2/source/inc/ChartTypeHelper.hxx index 35fe6abc653c..429ca12e60c0 100644 --- a/chart2/source/inc/ChartTypeHelper.hxx +++ b/chart2/source/inc/ChartTypeHelper.hxx @@ -2,9 +2,9 @@ * * $RCSfile: ChartTypeHelper.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: iha $ $Date: 2003-12-17 10:40:20 $ + * last change: $Author: iha $ $Date: 2004-01-17 13:09:47 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -85,13 +85,16 @@ public: static sal_Bool isSupportingGeometryProperties( const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::chart2::XChartType >& xChartType ); static sal_Bool isSupportingStatisticProperties( const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::chart2::XChartType >& xChartType ); static sal_Bool isSupportingRegressionProperties(const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::chart2::XChartType >& xChartType ); - static sal_Bool isSupportingSecondaryYAxis( const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::chart2::XChartType >& xChartType ); + static sal_Bool isSupportingMainAxis( const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::chart2::XChartType >& xChartType, sal_Int32 nDimensionIndex ); + static sal_Bool isSupportingSecondaryAxis( const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::chart2::XChartType >& xChartType, sal_Int32 nDimensionIndex ); static sal_Bool isSupportingAreaProperties( const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::chart2::XChartType >& xChartType ); static sal_Bool isSupportingSymbolProperties( const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::chart2::XChartType >& xChartType ); static ::drafts::com::sun::star::chart2::AxisType getAxisType( const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::chart2::XChartType >& xChartType , sal_Int32 nDimensionIndex ); + + static sal_Int32 getDimensionCount( const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::chart2::XChartType >& xChartType ); }; //............................................................................. diff --git a/chart2/source/inc/CommonConverters.hxx b/chart2/source/inc/CommonConverters.hxx index 834e18e4322c..a68e7b024b61 100644 --- a/chart2/source/inc/CommonConverters.hxx +++ b/chart2/source/inc/CommonConverters.hxx @@ -2,9 +2,9 @@ * * $RCSfile: CommonConverters.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: bm $ $Date: 2003-12-17 14:30:30 $ + * last change: $Author: iha $ $Date: 2004-01-17 13:09:48 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -180,6 +180,12 @@ com::sun::star::drawing::PointSequenceSequence PolyToPointSequence( const com::sun::star::drawing::PolyPolygonShape3D& rPolyPolygon ); //----------------------------------------------------------------------------- +/** drawing::PointSequenceSequence + drawing::PointSequenceSequence +*/ +void appendPointSequence( com::sun::star::drawing::PointSequenceSequence& rTarget + , com::sun::star::drawing::PointSequenceSequence& rAdd ); + +//----------------------------------------------------------------------------- /** PolyPolygonShape3D -> Polygon (2D,integer!) */ Polygon PolyToToolsPoly( diff --git a/chart2/source/inc/servicenames_coosystems.hxx b/chart2/source/inc/servicenames_coosystems.hxx new file mode 100644 index 000000000000..da37f628b02b --- /dev/null +++ b/chart2/source/inc/servicenames_coosystems.hxx @@ -0,0 +1,77 @@ +/************************************************************************* + * + * $RCSfile: servicenames_coosystems.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: iha $ $Date: 2004-01-17 13:09:48 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2003 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef _CHART2_SERVICENAMES_COOSYSTEMS_HXX +#define _CHART2_SERVICENAMES_COOSYSTEMS_HXX + +//............................................................................. +namespace chart +{ +//............................................................................. + +#define CHART2_COOSYSTEM_CARTESIAN_SERVICE_NAME ::rtl::OUString::createFromAscii("com.sun.star.chart2.CoordinateSystems.Cartesian") +#define CHART2_COOSYSTEM_CARTESIAN_VIEW_SERVICE_NAME ::rtl::OUString::createFromAscii("com.sun.star.chart2.CoordinateSystems.CartesianView") +#define CHART2_COOSYSTEM_POLAR_SERVICE_NAME ::rtl::OUString::createFromAscii("com.sun.star.chart2.CoordinateSystems.Polar") +#define CHART2_COOSYSTEM_POLAR_VIEW_SERVICE_NAME ::rtl::OUString::createFromAscii("com.sun.star.chart2.CoordinateSystems.PolarView") + +//............................................................................. +} //namespace chart +//............................................................................. +#endif diff --git a/chart2/source/model/inc/CartesianCoordinateSystem.hxx b/chart2/source/model/inc/CartesianCoordinateSystem.hxx new file mode 100644 index 000000000000..6fcfcbda575f --- /dev/null +++ b/chart2/source/model/inc/CartesianCoordinateSystem.hxx @@ -0,0 +1,115 @@ +/************************************************************************* + * + * $RCSfile: CartesianCoordinateSystem.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: iha $ $Date: 2004-01-17 13:09:50 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2002 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef _CHART_CARTESIANCOORDINATESYSTEM_HXX +#define _CHART_CARTESIANCOORDINATESYSTEM_HXX + +#include "ServiceMacros.hxx" + +#ifndef _CPPUHELPER_IMPLBASE2_HXX_ +#include <cppuhelper/implbase2.hxx> +#endif + +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include <com/sun/star/lang/XServiceInfo.hpp> +#endif +#ifndef _DRAFTS_COM_SUN_STAR_CHART2_XCOORDINATESYSTEM_HPP_ +#include <drafts/com/sun/star/chart2/XCoordinateSystem.hpp> +#endif + +namespace chart +{ + +class CartesianCoordinateSystem : public ::cppu::WeakImplHelper2< + ::com::sun::star::lang::XServiceInfo, + ::drafts::com::sun::star::chart2::XCoordinateSystem + > +{ +public: + explicit CartesianCoordinateSystem( sal_Int32 nDim = 2 ); + virtual ~CartesianCoordinateSystem(); + + // ____ XCoordinateSystem ____ + // ___________________________ + /// @see ::drafts::com::sun::star::chart2::XCoordinateSystem + virtual ::com::sun::star::uno::Reference< ::drafts::com::sun::star::chart2::XTransformation > SAL_CALL getTransformationToCartesian() + throw (::com::sun::star::uno::RuntimeException); + /// @see ::drafts::com::sun::star::chart2::XCoordinateSystem + virtual ::com::sun::star::uno::Reference< ::drafts::com::sun::star::chart2::XTransformation > SAL_CALL getTransformationFromCartesian() + throw (::com::sun::star::uno::RuntimeException); + /// @see ::drafts::com::sun::star::chart2::XCoordinateSystem + virtual sal_Int32 SAL_CALL getDimension() throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getCoordinateSystemType() throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getViewServiceName() throw (::com::sun::star::uno::RuntimeException); + + APPHELPER_XSERVICEINFO_DECL() + +private: + ::com::sun::star::uno::Reference< ::drafts::com::sun::star::chart2::XTransformation > + m_aTransformationToCartesian; + ::com::sun::star::uno::Reference< ::drafts::com::sun::star::chart2::XTransformation > + m_aTransformationFromCartesian; + sal_Int32 m_nDim; +}; + +} // namespace chart + +// _CHART_CARTESIANCOORDINATESYSTEM_HXX +#endif diff --git a/chart2/source/model/inc/PolarCoordinateSystem.hxx b/chart2/source/model/inc/PolarCoordinateSystem.hxx index 4754833c07d0..49f634e83cb5 100644 --- a/chart2/source/model/inc/PolarCoordinateSystem.hxx +++ b/chart2/source/model/inc/PolarCoordinateSystem.hxx @@ -2,9 +2,9 @@ * * $RCSfile: PolarCoordinateSystem.hxx,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: bm $ $Date: 2003-10-06 09:58:30 $ + * last change: $Author: iha $ $Date: 2004-01-17 13:09:50 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -96,6 +96,8 @@ public: throw (::com::sun::star::uno::RuntimeException); /// @see ::drafts::com::sun::star::chart2::XCoordinateSystem virtual sal_Int32 SAL_CALL getDimension() throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getCoordinateSystemType() throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getViewServiceName() throw (::com::sun::star::uno::RuntimeException); APPHELPER_XSERVICEINFO_DECL() diff --git a/chart2/source/model/main/CartesianCoordinateSystem.cxx b/chart2/source/model/main/CartesianCoordinateSystem.cxx index be117ce2b6d1..ce8853987139 100644 --- a/chart2/source/model/main/CartesianCoordinateSystem.cxx +++ b/chart2/source/model/main/CartesianCoordinateSystem.cxx @@ -2,9 +2,9 @@ * * $RCSfile: CartesianCoordinateSystem.cxx,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: bm $ $Date: 2003-10-06 09:58:30 $ + * last change: $Author: iha $ $Date: 2004-01-17 13:09:51 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -61,6 +61,7 @@ #include "CartesianCoordinateSystem.hxx" #include "IdentityTransformation.hxx" #include "macros.hxx" +#include "servicenames_coosystems.hxx" using ::com::sun::star::uno::RuntimeException; using ::com::sun::star::uno::Sequence; @@ -99,6 +100,15 @@ sal_Int32 SAL_CALL CartesianCoordinateSystem::getDimension() throw (RuntimeExcep return m_nDim; } +::rtl::OUString SAL_CALL CartesianCoordinateSystem::getCoordinateSystemType() throw (RuntimeException) +{ + return CHART2_COOSYSTEM_CARTESIAN_SERVICE_NAME; +} + +::rtl::OUString SAL_CALL CartesianCoordinateSystem::getViewServiceName() throw (RuntimeException) +{ + return CHART2_COOSYSTEM_CARTESIAN_VIEW_SERVICE_NAME; +} // ____ XServiceInfo ____ diff --git a/chart2/source/model/main/PolarCoordinateSystem.cxx b/chart2/source/model/main/PolarCoordinateSystem.cxx index 9f215a97c15d..53a2e90e4d6c 100644 --- a/chart2/source/model/main/PolarCoordinateSystem.cxx +++ b/chart2/source/model/main/PolarCoordinateSystem.cxx @@ -2,9 +2,9 @@ * * $RCSfile: PolarCoordinateSystem.cxx,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: bm $ $Date: 2003-10-06 09:58:31 $ + * last change: $Author: iha $ $Date: 2004-01-17 13:09:51 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -61,6 +61,7 @@ #include "PolarCoordinateSystem.hxx" #include "PolarTransformation.hxx" #include "macros.hxx" +#include "servicenames_coosystems.hxx" using ::com::sun::star::uno::RuntimeException; using ::com::sun::star::uno::Sequence; @@ -101,6 +102,15 @@ sal_Int32 SAL_CALL PolarCoordinateSystem::getDimension() throw (RuntimeException return m_nDim; } +::rtl::OUString SAL_CALL PolarCoordinateSystem::getCoordinateSystemType() throw (RuntimeException) +{ + return CHART2_COOSYSTEM_POLAR_SERVICE_NAME; +} + +::rtl::OUString SAL_CALL PolarCoordinateSystem::getViewServiceName() throw (RuntimeException) +{ + return CHART2_COOSYSTEM_POLAR_VIEW_SERVICE_NAME; +} // ____ XServiceInfo ____ diff --git a/chart2/source/model/template/ChartTypeManager.cxx b/chart2/source/model/template/ChartTypeManager.cxx index f05587ce62fd..7acdef1d765f 100644 --- a/chart2/source/model/template/ChartTypeManager.cxx +++ b/chart2/source/model/template/ChartTypeManager.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ChartTypeManager.cxx,v $ * - * $Revision: 1.9 $ + * $Revision: 1.10 $ * - * last change: $Author: bm $ $Date: 2004-01-12 14:33:47 $ + * last change: $Author: iha $ $Date: 2004-01-17 13:09:52 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -179,7 +179,7 @@ void lcl_AddDefaultsToMap( OSL_ASSERT( rOutMap.end() == rOutMap.find( PROP_TEMPLATE_MANAGER_CHART_TEMPLATE_NAME )); rOutMap[ PROP_TEMPLATE_MANAGER_CHART_TEMPLATE_NAME ] = uno::makeAny( - ::rtl::OUString( C2U( "com.sun.star.chart2.template.Column" ))); + ::rtl::OUString( C2U( "com.sun.star.chart2.template.Pie" ))); OSL_ASSERT( rOutMap.end() == rOutMap.find( PROP_TEMPLATE_MANAGER_SOLID_TYPE )); rOutMap[ PROP_TEMPLATE_MANAGER_SOLID_TYPE ] = diff --git a/chart2/source/model/template/NetChartTypeTemplate.cxx b/chart2/source/model/template/NetChartTypeTemplate.cxx index d457e1df4f03..67dabeeeb105 100644 --- a/chart2/source/model/template/NetChartTypeTemplate.cxx +++ b/chart2/source/model/template/NetChartTypeTemplate.cxx @@ -2,9 +2,9 @@ * * $RCSfile: NetChartTypeTemplate.cxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: bm $ $Date: 2004-01-12 14:26:00 $ + * last change: $Author: iha $ $Date: 2004-01-17 13:09:52 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -125,11 +125,12 @@ Reference< chart2::XBoundedCoordinateSystem > NetChartTypeTemplate::createCoordi new BoundedCoordinateSystem( xCoordSys )); chart2::ScaleData aScale; - aScale.Orientation = chart2::AxisOrientation_MATHEMATICAL; aScale.Scaling = new LinearScaling( 1.0, 0.0 ); + aScale.Orientation = chart2::AxisOrientation_REVERSE; xResult->setScaleByDimension( 0, Reference< chart2::XScale >( new Scale( GetComponentContext(), aScale ) )); + aScale.Orientation = chart2::AxisOrientation_MATHEMATICAL; xResult->setScaleByDimension( 1, Reference< chart2::XScale >( new Scale( GetComponentContext(), aScale ) )); diff --git a/chart2/source/model/template/PieChartTypeTemplate.cxx b/chart2/source/model/template/PieChartTypeTemplate.cxx index 5f6a5d689f9f..ea01077f7c1b 100644 --- a/chart2/source/model/template/PieChartTypeTemplate.cxx +++ b/chart2/source/model/template/PieChartTypeTemplate.cxx @@ -2,9 +2,9 @@ * * $RCSfile: PieChartTypeTemplate.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: bm $ $Date: 2003-11-26 10:44:39 $ + * last change: $Author: iha $ $Date: 2004-01-17 13:09:52 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -280,12 +280,16 @@ uno::Reference< chart2::XBoundedCoordinateSystem > PieChartTypeTemplate::createC new BoundedCoordinateSystem( xCoordSys )); chart2::ScaleData aScale; - aScale.Orientation = chart2::AxisOrientation_MATHEMATICAL; aScale.Scaling = new LinearScaling( 1.0, 0.0 ); for( sal_Int32 i = 0; i < getDimension(); ++i ) + { + aScale.Orientation = chart2::AxisOrientation_MATHEMATICAL; + if( i==1 ) + aScale.Orientation = chart2::AxisOrientation_REVERSE; xResult->setScaleByDimension( i, uno::Reference< chart2::XScale >( new Scale( GetComponentContext(), aScale ) )); + } try { diff --git a/chart2/source/tools/ChartModelHelper.cxx b/chart2/source/tools/ChartModelHelper.cxx index 44ba48f9f68e..4ffc806c2f22 100644 --- a/chart2/source/tools/ChartModelHelper.cxx +++ b/chart2/source/tools/ChartModelHelper.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ChartModelHelper.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: iha $ $Date: 2003-11-10 19:33:21 $ + * last change: $Author: iha $ $Date: 2004-01-17 13:09:53 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -90,49 +90,26 @@ uno::Reference< XDiagram > ChartModelHelper::findDiagram( const uno::Reference< } //static -sal_Int32 ChartModelHelper::getDimensionAndFirstChartType( const uno::Reference< XDiagram >& xDiagram, rtl::OUString& rChartType ) +uno::Reference< XChartType > ChartModelHelper::getFirstChartType( const uno::Reference< XDiagram >& xDiagram ) { - sal_Int32 nDimension = 2; - - //@todo maybe get the dimension better from diagram properties ... -> need model change if(!xDiagram.is()) - return nDimension; + return 0; uno::Reference< XDataSeriesTreeParent > xTree = xDiagram->getTree(); if(!xTree.is()) - return nDimension; + return 0; uno::Sequence< uno::Reference< XDataSeriesTreeNode > > aChartTypes( xTree->getChildren() ); for( sal_Int32 i = 0; i < aChartTypes.getLength(); ++i ) { uno::Reference< XChartTypeGroup > xChartTypeGroup( aChartTypes[i], uno::UNO_QUERY ); DBG_ASSERT(xChartTypeGroup.is(),"First node at the diagram tree needs to be a ChartTypeGroup"); - if( !xChartTypeGroup.is() ) - continue; - uno::Reference< XChartType > xChartType = xChartTypeGroup->getChartType(); - if( !xChartType.is() ) - continue; - uno::Reference< beans::XPropertySet > xChartTypeProp( xChartType, uno::UNO_QUERY ); - if( xChartTypeProp.is()) + if( xChartTypeGroup.is() ) { - try - { - if( (xChartTypeProp->getPropertyValue( C2U( "Dimension" )) >>= nDimension) ) - { - rChartType = xChartType->getChartType(); - return nDimension; - } - else - { - DBG_ERROR( "Couldn't get Dimension from ChartTypeGroup" ); - } - } - catch( beans::UnknownPropertyException ex ) - { - ASSERT_EXCEPTION( ex ); - } - break; + uno::Reference< XChartType > xChartType = xChartTypeGroup->getChartType(); + if( xChartType.is() ) + return xChartType; } } - return nDimension; + return 0; } namespace diff --git a/chart2/source/tools/ChartTypeHelper.cxx b/chart2/source/tools/ChartTypeHelper.cxx index 0634ab65e52a..d58c97906204 100644 --- a/chart2/source/tools/ChartTypeHelper.cxx +++ b/chart2/source/tools/ChartTypeHelper.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ChartTypeHelper.cxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: iha $ $Date: 2003-12-17 10:40:42 $ + * last change: $Author: iha $ $Date: 2004-01-17 13:09:53 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -62,6 +62,11 @@ #include "ChartTypeHelper.hxx" #include "macros.hxx" +// header for define DBG_ASSERT +#ifndef _TOOLS_DEBUG_HXX +#include <tools/debug.hxx> +#endif + #ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ #include <com/sun/star/beans/XPropertySet.hpp> #endif @@ -131,31 +136,6 @@ sal_Bool ChartTypeHelper::isSupportingRegressionProperties( const uno::Reference return isSupportingStatisticProperties( xChartType ); } -sal_Bool ChartTypeHelper::isSupportingSecondaryYAxis( const uno::Reference< XChartType >& xChartType ) -{ - //3D, pie and net charts do not support a second y-axis - - //@todo ask charttype itself --> need model change first - if(xChartType.is()) - { - sal_Int32 nDimension=2; - { - uno::Reference< beans::XPropertySet > xChartTypeProp( xChartType, uno::UNO_QUERY ); - if(xChartTypeProp.is()) - xChartTypeProp->getPropertyValue( C2U( "Dimension" )) >>= nDimension; - } - if(nDimension==3) - return sal_False; - - rtl::OUString aChartTypeName = xChartType->getChartType(); - if( aChartTypeName.match(C2U("com.sun.star.chart2.PieChart")) ) - return sal_False; - if( aChartTypeName.match(C2U("com.sun.star.chart2.Net")) ) - return sal_False; - } - return sal_True; -} - sal_Bool ChartTypeHelper::isSupportingAreaProperties( const uno::Reference< XChartType >& xChartType ) { //2D line charts do not support area properties @@ -208,6 +188,49 @@ sal_Bool ChartTypeHelper::isSupportingSymbolProperties( const uno::Reference< XC return sal_False; } +sal_Bool ChartTypeHelper::isSupportingMainAxis( const uno::Reference< XChartType >& xChartType, sal_Int32 nDimensionIndex ) +{ + //pie charts do not support axis at all + //no 3rd axis for 2D charts + + //@todo ask charttype itself --> need model change first + if(xChartType.is()) + { + rtl::OUString aChartTypeName = xChartType->getChartType(); + if( aChartTypeName.match(C2U("com.sun.star.chart2.PieChart")) ) + return sal_True; //@todo replace true by false sal_False; + + if( nDimensionIndex == 2 ) + return ChartTypeHelper::getDimensionCount( xChartType ) == 3; + } + return sal_True; +} + +sal_Bool ChartTypeHelper::isSupportingSecondaryAxis( const uno::Reference< XChartType >& xChartType, sal_Int32 nDimensionIndex ) +{ + //3D, pie and net charts do not support a secondary axis at all + + //@todo ask charttype itself --> need model change first + if(xChartType.is()) + { + sal_Int32 nDimension=2; + { + uno::Reference< beans::XPropertySet > xChartTypeProp( xChartType, uno::UNO_QUERY ); + if(xChartTypeProp.is()) + xChartTypeProp->getPropertyValue( C2U( "Dimension" )) >>= nDimension; + } + if(nDimension==3) + return sal_False; + + rtl::OUString aChartTypeName = xChartType->getChartType(); + if( aChartTypeName.match(C2U("com.sun.star.chart2.PieChart")) ) + return sal_False; + if( aChartTypeName.match(C2U("com.sun.star.chart2.Net")) ) + return sal_False; + } + return sal_True; +} + AxisType ChartTypeHelper::getAxisType( const uno::Reference< XChartType >& xChartType, sal_Int32 nDimensionIndex ) { @@ -229,6 +252,34 @@ AxisType ChartTypeHelper::getAxisType( const uno::Reference< return AxisType_CATEGORY; } +sal_Int32 ChartTypeHelper::getDimensionCount( const uno::Reference< XChartType >& xChartType ) +{ + sal_Int32 nDimension = 2; + if( xChartType.is() ) + { + uno::Reference< beans::XPropertySet > xChartTypeProp( xChartType, uno::UNO_QUERY ); + if( xChartTypeProp.is()) + { + try + { + if( (xChartTypeProp->getPropertyValue( C2U( "Dimension" )) >>= nDimension) ) + { + return nDimension; + } + else + { + DBG_ERROR( "Couldn't get Dimension from ChartTypeGroup" ); + } + } + catch( beans::UnknownPropertyException ex ) + { + ASSERT_EXCEPTION( ex ); + } + } + } + return nDimension; +} + //............................................................................. } //namespace chart //............................................................................. diff --git a/chart2/source/tools/CommonConverters.cxx b/chart2/source/tools/CommonConverters.cxx index b47b54b29558..f887a282b0c6 100644 --- a/chart2/source/tools/CommonConverters.cxx +++ b/chart2/source/tools/CommonConverters.cxx @@ -2,9 +2,9 @@ * * $RCSfile: CommonConverters.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: bm $ $Date: 2003-12-17 14:30:48 $ + * last change: $Author: iha $ $Date: 2004-01-17 13:09:53 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -483,6 +483,19 @@ drawing::PointSequenceSequence PolyToPointSequence( return aRet; } +void appendPointSequence( com::sun::star::drawing::PointSequenceSequence& rTarget + , com::sun::star::drawing::PointSequenceSequence& rAdd ) +{ + sal_Int32 nAddCount = rAdd.getLength(); + if(!nAddCount) + return; + sal_Int32 nOldCount = rTarget.getLength(); + + rTarget.realloc(nOldCount+nAddCount); + for(sal_Int32 nS=0; nS<nAddCount; nS++ ) + rTarget[nOldCount+nS]=rAdd[nS]; +} + Polygon PolyToToolsPoly( const drawing::PolyPolygonShape3D& rPolyPolygon ) { sal_Int32 nOuterLength = rPolyPolygon.SequenceX.getLength(); diff --git a/chart2/source/view/axes/VAxisProperties.cxx b/chart2/source/view/axes/VAxisProperties.cxx index 943a35a3694b..63adbf2d46cc 100644 --- a/chart2/source/view/axes/VAxisProperties.cxx +++ b/chart2/source/view/axes/VAxisProperties.cxx @@ -2,9 +2,9 @@ * * $RCSfile: VAxisProperties.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: iha $ $Date: 2003-11-19 16:39:12 $ + * last change: $Author: iha $ $Date: 2004-01-17 13:09:55 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -201,7 +201,6 @@ AxisProperties::AxisProperties() , m_nMinorTickmarks(1) , m_aTickmarkPropertiesList() , m_aLineProperties() - , m_bTESTTEST_HorizontalAdjustmentIsLeft(true) { } @@ -217,7 +216,6 @@ AxisProperties::AxisProperties( const AxisProperties& rAxisProperties ) , m_nMinorTickmarks( rAxisProperties.m_nMinorTickmarks ) , m_aTickmarkPropertiesList( rAxisProperties.m_aTickmarkPropertiesList ) , m_aLineProperties( rAxisProperties.m_aLineProperties ) - , m_bTESTTEST_HorizontalAdjustmentIsLeft( rAxisProperties.m_bTESTTEST_HorizontalAdjustmentIsLeft ) { if( rAxisProperties.m_pfMainLinePositionAtOtherAxis ) m_pfMainLinePositionAtOtherAxis = new double(*rAxisProperties.m_pfMainLinePositionAtOtherAxis); @@ -271,62 +269,6 @@ void AxisProperties::init() } } -sal_Int32 getAxisScreenPosition( double fCrossOtherAxis - , const PlottingPositionHelper& rPosHelper, bool bIsYAxis ) -{ - double fX = bIsYAxis ? fCrossOtherAxis : rPosHelper.getLogicMinX(); - double fY = bIsYAxis ? rPosHelper.getLogicMinY() : fCrossOtherAxis; - - rPosHelper.clipLogicValues( &fX,&fY,0 ); - rPosHelper.doLogicScaling( &fX,&fY,0 ); - drawing::Position3D aPos( fX, fY, 0); - - uno::Reference< XTransformation > xTransformation = - rPosHelper.getTransformationLogicToScene(); - uno::Sequence< double > aSeq = - xTransformation->transform( Position3DToSequence(aPos) ); - - return static_cast<sal_Int32>( - bIsYAxis ? aSeq[0] : aSeq[1] ); -} - - - -sal_Int32 AxisProperties::getMainLineScreenPosition( - const PlottingPositionHelper& rPosHelper ) const -{ - double fMin = m_bIsYAxis ? rPosHelper.getLogicMinX() : rPosHelper.getLogicMinY(); - double fMax = m_bIsYAxis ? rPosHelper.getLogicMaxX() : rPosHelper.getLogicMaxY(); - - double fCrossOtherAxis; - if(m_pfMainLinePositionAtOtherAxis) - fCrossOtherAxis = *m_pfMainLinePositionAtOtherAxis; - else - { - bool bMinimumForLeftAxis = ( m_bIsYAxis && rPosHelper.isMathematicalOrientationY() ) - || ( !m_bIsYAxis && rPosHelper.isMathematicalOrientationX() ); - fCrossOtherAxis = ( bMinimumForLeftAxis && m_bIsLeftOrBottomAxis ) ? fMin : fMax; - } - sal_Int32 nRet = getAxisScreenPosition( fCrossOtherAxis, rPosHelper, m_bIsYAxis ); - return nRet; -} - -bool AxisProperties::getExtraLineScreenPosition( - sal_Int32& rnExtraLineScreenPosition, const PlottingPositionHelper& rPosHelper ) const -{ - if( !m_pfExrtaLinePositionAtOtherAxis ) - return false; - - double fMin = m_bIsYAxis ? rPosHelper.getLogicMinX() : rPosHelper.getLogicMinY(); - double fMax = m_bIsYAxis ? rPosHelper.getLogicMaxX() : rPosHelper.getLogicMaxY(); - if( *m_pfExrtaLinePositionAtOtherAxis <= fMin - || *m_pfExrtaLinePositionAtOtherAxis >= fMax ) - return false; - rnExtraLineScreenPosition = getAxisScreenPosition( - *m_pfExrtaLinePositionAtOtherAxis, rPosHelper, m_bIsYAxis ); - return true; -} - //----------------------------------------------------------------------------- AxisLabelProperties::AxisLabelProperties() @@ -425,50 +367,6 @@ sal_Bool AxisLabelProperties::getIsStaggered() const return sal_False; } -//------------------------ - -drawing::TextVerticalAdjust AxisProperties::getVerticalAdjustment() const -{ - drawing::TextVerticalAdjust aRet = - !m_bIsYAxis && !m_bIsLeftOrBottomAxis - ? drawing::TextVerticalAdjust_BOTTOM - : drawing::TextVerticalAdjust_TOP; - return aRet; -} - -sal_Int16 AxisProperties::getWritingMode()const -{ - //@todo get this dependent on the locale ... - sal_Int16 nWritingMode( text::WritingMode2::LR_TB ); - return nWritingMode; -} - -drawing::TextHorizontalAdjust AxisProperties::getHorizontalAdjustment() const -{ - return m_bTESTTEST_HorizontalAdjustmentIsLeft - ? drawing::TextHorizontalAdjust_LEFT - : drawing::TextHorizontalAdjust_RIGHT; -// - - bool bIsYAxis = m_bIsYAxis; - bool bIsLeftOrBottomAxis = m_bIsLeftOrBottomAxis; - sal_Int16 nWritingMode = getWritingMode(); - - switch( nWritingMode ) - { - case text::WritingMode2::RL_TB: - case text::WritingMode2::TB_RL: - return bIsYAxis && !bIsLeftOrBottomAxis - ? drawing::TextHorizontalAdjust_LEFT - : drawing::TextHorizontalAdjust_RIGHT; - case text::WritingMode2::TB_LR: - default: - return bIsYAxis && bIsLeftOrBottomAxis - ? drawing::TextHorizontalAdjust_RIGHT - : drawing::TextHorizontalAdjust_LEFT; - } -} - //............................................................................. } //namespace chart //............................................................................. diff --git a/chart2/source/view/axes/VAxisProperties.hxx b/chart2/source/view/axes/VAxisProperties.hxx new file mode 100644 index 000000000000..cfb51c6877bf --- /dev/null +++ b/chart2/source/view/axes/VAxisProperties.hxx @@ -0,0 +1,191 @@ +/************************************************************************* + * + * $RCSfile: VAxisProperties.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: iha $ $Date: 2004-01-17 13:09:55 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2003 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef _CHART2_VAXIS_PROPERTIES_HXX +#define _CHART2_VAXIS_PROPERTIES_HXX + +#include "VLineProperties.hxx" +#include "PlottingPositionHelper.hxx" + +#ifndef _DRAFTS_COM_SUN_STAR_CHART2_NUMBERFORMAT_HPP_ +#include <drafts/com/sun/star/chart2/NumberFormat.hpp> +#endif +#ifndef _DRAFTS_COM_SUN_STAR_CHART2_XAXIS_HPP_ +#include <drafts/com/sun/star/chart2/XAxis.hpp> +#endif + +#ifndef _COM_SUN_STAR_AWT_SIZE_HPP_ +#include <com/sun/star/awt/Size.hpp> +#endif +#ifndef _COM_SUN_STAR_DRAWING_TEXTVERTICALADJUST_HPP_ +#include <com/sun/star/drawing/TextVerticalAdjust.hpp> +#endif +#ifndef _COM_SUN_STAR_DRAWING_TEXTHORIZONTALADJUST_HPP_ +#include <com/sun/star/drawing/TextHorizontalAdjust.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_LOCALE_HPP_ +#include <com/sun/star/lang/Locale.hpp> +#endif + +#include <vector> + +//............................................................................. +namespace chart +{ +//............................................................................. + +//----------------------------------------------------------------------------- +/** +*/ + +struct TickmarkProperties +{ + sal_Int32 RelativePos;//Position in screen values relative to the axis where the tickmark line starts + sal_Int32 Length;//Length of the tickmark line in screen values + + VLineProperties aLineProperties; +}; + +//These properties describe how a couple of labels are arranged one to another. +//The couple can contain all labels for all tickmark depth or just the labels for one single depth or +//the labels from an coherent range of tick depths (e.g. the major and first minor tickmarks should be handled together). +//... only allow side by side for different tick depth +enum AxisLabelStaggering +{ + SIDE_BY_SIDE + , STAGGER_EVEN + , STAGGER_ODD + , STAGGER_AUTO +}; + +struct AxisLabelProperties +{ + AxisLabelProperties(); + + drafts::com::sun::star::chart2::NumberFormat aNumberFormat; + + sal_Bool bDisplayLabels; + + AxisLabelStaggering eStaggering; + + sal_Bool bLineBreakAllowed; + sal_Bool bOverlapAllowed; + + sal_Bool bStackCharacters; + double fRotationAngleDegree; + + sal_Int32 nRhythm; //show only each nth label with n==nRhythm + bool bRhythmIsFix; //states wether the given rythm is fix or may be changed + + //methods: + void init( const ::com::sun::star::uno::Reference< + ::drafts::com::sun::star::chart2::XAxis >& xAxisModel ); + + sal_Bool getIsStaggered() const; +}; + +struct AxisProperties +{ + ::com::sun::star::uno::Reference< ::drafts::com::sun::star::chart2::XAxis > m_xAxisModel; + + bool m_bIsYAxis; + bool m_bIsLeftOrBottomAxis; + double* m_pfMainLinePositionAtOtherAxis; + double* m_pfExrtaLinePositionAtOtherAxis; + + /* + sal_Int32 m_nOrthogonalAxisScreenPosition;//gives a position in the direction orthogonal to the axis direction + //e.g. for an y-axis this value describes a x position on the screen + sal_Int32 m_nOrthogonalAxisExtraLineScreenPosition;//gives the screen value for an additional line ( e.g. a line at 0 ) at the other axis + */ + + enum RelativeLabelPosition { NONE, LEFTORBOTTOM_OF_DIAGRAM, RIGHTORTOP_OF_DIAGRAM, + LEFTORBOTTOM_OF_AXIS, RIGHTORTOP_OF_AXIS }; + + RelativeLabelPosition m_eRelativeLabelPosition; + ::com::sun::star::awt::Size m_aReferenceSize; + + + /* + 0: no tickmarks 1: inner tickmarks + 2: outer tickmarks 3: inner and outer tickmarks + */ + sal_Int32 m_nMajorTickmarks; + sal_Int32 m_nMinorTickmarks; + ::std::vector<TickmarkProperties> m_aTickmarkPropertiesList; + + VLineProperties m_aLineProperties; + + //methods: + AxisProperties(); + AxisProperties( const AxisProperties& rAxisProperties ); + ~AxisProperties(); + void init();//init from model data (m_xAxisModel) + +private: + TickmarkProperties makeTickmarkProperties( sal_Int32 nDepth ) const; + sal_Int32 calcTickLengthForDepth( sal_Int32 nDepth, sal_Int32 nTickmarkStyle ) const; + VLineProperties makeLinePropertiesForDepth( sal_Int32 nDepth ) const; +}; + +//............................................................................. +} //namespace chart +//............................................................................. +#endif diff --git a/chart2/source/view/axes/VCartesianAxis.cxx b/chart2/source/view/axes/VCartesianAxis.cxx new file mode 100644 index 000000000000..8125b4b497a7 --- /dev/null +++ b/chart2/source/view/axes/VCartesianAxis.cxx @@ -0,0 +1,1143 @@ +/************************************************************************* + * + * $RCSfile: VCartesianAxis.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: iha $ $Date: 2004-01-17 13:09:55 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2003 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#include "VCartesianAxis.hxx" +#include "PlottingPositionHelper.hxx" +#include "ShapeFactory.hxx" +#include "CommonConverters.hxx" +#include "macros.hxx" +#include "ViewDefines.hxx" +#include "TickmarkHelper.hxx" +#include "PropertyMapper.hxx" +#include "chartview/NumberFormatterWrapper.hxx" +#include "chartview/ObjectIdentifier.hxx" +#include "LabelPositionHelper.hxx" + +#ifndef _DRAFTS_COM_SUN_STAR_CHART2_XIDENTIFIABLE_HPP_ +#include <drafts/com/sun/star/chart2/XIdentifiable.hpp> +#endif + +#ifndef INCLUDED_RTL_MATH_HXX +#include <rtl/math.hxx> +#endif +#ifndef _TOOLS_COLOR_HXX +#include <tools/color.hxx> +#endif +#ifndef _TOOLS_DEBUG_HXX +#include <tools/debug.hxx> +#endif +#ifndef _COM_SUN_STAR_TEXT_XTEXT_HPP_ +#include <com/sun/star/text/XText.hpp> +#endif +#ifndef _COM_SUN_STAR_TEXT_WRITINGMODE2_HPP_ +#include <com/sun/star/text/WritingMode2.hpp> +#endif + +#ifndef _SVX_UNOPRNMS_HXX +#include <svx/unoprnms.hxx> +#endif + +#include <algorithm> +#include <memory> + +//............................................................................. +namespace chart +{ +//............................................................................. +using namespace ::com::sun::star; +using namespace ::drafts::com::sun::star::chart2; +using namespace ::rtl::math; + +LabelAlignment lcl_getLabelAlignment( const AxisProperties& rAxisProperties ) +{ + sal_Int16 nWritingMode( text::WritingMode2::LR_TB );//@todo get correct one + bool bIsYAxis = rAxisProperties.m_bIsYAxis; + bool bIsLeftOrBottomAxis = rAxisProperties.m_bIsLeftOrBottomAxis; + + bool bTop = !bIsYAxis && !bIsLeftOrBottomAxis; + bool bLeft = true; + switch( nWritingMode ) + { + case text::WritingMode2::RL_TB: + case text::WritingMode2::TB_RL: + bLeft = !( bIsYAxis && !bIsLeftOrBottomAxis ); + case text::WritingMode2::TB_LR: + default: + bLeft = bIsYAxis && bIsLeftOrBottomAxis; + } + + LabelAlignment aRet( LABEL_ALIGN_LEFT ); + if(bTop) + { + if(bLeft) + aRet = LABEL_ALIGN_LEFT_TOP; + else + aRet = LABEL_ALIGN_RIGHT_TOP; + } + else + { + if(bLeft) + aRet = LABEL_ALIGN_LEFT_BOTTOM; + else + aRet = LABEL_ALIGN_RIGHT_BOTTOM; + } + return aRet; +} + +sal_Int32 lcl_getAxisScreenPosition( double fCrossOtherAxis + , const PlottingPositionHelper& rPosHelper, bool bIsYAxis ) +{ + double fX = bIsYAxis ? fCrossOtherAxis : rPosHelper.getLogicMinX(); + double fY = bIsYAxis ? rPosHelper.getLogicMinY() : fCrossOtherAxis; + + rPosHelper.clipLogicValues( &fX,&fY,0 ); + rPosHelper.doLogicScaling( &fX,&fY,0 ); + drawing::Position3D aPos( fX, fY, 0); + + uno::Reference< XTransformation > xTransformation = + rPosHelper.getTransformationLogicToScene(); + uno::Sequence< double > aSeq = + xTransformation->transform( Position3DToSequence(aPos) ); + + return static_cast<sal_Int32>( + bIsYAxis ? aSeq[0] : aSeq[1] ); +} + +sal_Int32 lcl_getMainLineScreenPosition( + const PlottingPositionHelper& rPosHelper + , const AxisProperties& rAxisProperties ) +{ + double fMin = rAxisProperties.m_bIsYAxis ? rPosHelper.getLogicMinX() : rPosHelper.getLogicMinY(); + double fMax = rAxisProperties.m_bIsYAxis ? rPosHelper.getLogicMaxX() : rPosHelper.getLogicMaxY(); + + double fCrossOtherAxis; + if(rAxisProperties.m_pfMainLinePositionAtOtherAxis) + fCrossOtherAxis = *rAxisProperties.m_pfMainLinePositionAtOtherAxis; + else + { + bool bMinimumForLeftAxis = ( rAxisProperties.m_bIsYAxis && rPosHelper.isMathematicalOrientationY() ) + || ( !rAxisProperties.m_bIsYAxis && rPosHelper.isMathematicalOrientationX() ); + fCrossOtherAxis = ( bMinimumForLeftAxis && rAxisProperties.m_bIsLeftOrBottomAxis ) ? fMin : fMax; + } + sal_Int32 nRet = lcl_getAxisScreenPosition( fCrossOtherAxis, rPosHelper + , rAxisProperties.m_bIsYAxis ); + return nRet; +} + +bool lcl_getExtraLineScreenPosition( + sal_Int32& rnExtraLineScreenPosition + , const PlottingPositionHelper& rPosHelper + , const AxisProperties& rAxisProperties ) +{ + if( !rAxisProperties.m_pfExrtaLinePositionAtOtherAxis ) + return false; + + double fMin = rAxisProperties.m_bIsYAxis ? rPosHelper.getLogicMinX() : rPosHelper.getLogicMinY(); + double fMax = rAxisProperties.m_bIsYAxis ? rPosHelper.getLogicMaxX() : rPosHelper.getLogicMaxY(); + if( *rAxisProperties.m_pfExrtaLinePositionAtOtherAxis <= fMin + || *rAxisProperties.m_pfExrtaLinePositionAtOtherAxis >= fMax ) + return false; + rnExtraLineScreenPosition = lcl_getAxisScreenPosition( + *rAxisProperties.m_pfExrtaLinePositionAtOtherAxis + , rPosHelper, rAxisProperties.m_bIsYAxis ); + return true; +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +VAxis::VAxis( const AxisProperties& rAxisProperties + , NumberFormatterWrapper* pNumberFormatterWrapper + , sal_Int32 nDimensionCount ) + : VMeterBase( uno::Reference<XMeter>::query(rAxisProperties.m_xAxisModel) + , nDimensionCount ) + , m_aAxisProperties( rAxisProperties ) + , m_pNumberFormatterWrapper( pNumberFormatterWrapper ) +{ + m_pPosHelper = new PlottingPositionHelper(); +} + +VAxis::~VAxis() +{ + delete m_pPosHelper; + m_pPosHelper = NULL; +} + +void lcl_correctRotation_Left( double& rfXCorrection, double& rfYCorrection + , double fAnglePositiveDegree, const awt::Size& aSize ) +{ + //correct position for left y-axis with right top alignment + double fAnglePi = fAnglePositiveDegree*F_PI/180.0; + if( fAnglePositiveDegree==0.0 ) + { + rfXCorrection = 0.0; + rfYCorrection = -aSize.Height/2.0; + } + else if( fAnglePositiveDegree<= 90.0 ) + { + rfXCorrection = -aSize.Height*rtl::math::sin( fAnglePi ); + rfYCorrection = -aSize.Height*rtl::math::cos( fAnglePi )/2.0; + } + else if( fAnglePositiveDegree<= 180.0 ) + { + rfXCorrection = -aSize.Width *rtl::math::sin( fAnglePi - F_PI/2.0 ) + -aSize.Height*rtl::math::cos( fAnglePi - F_PI/2.0 ); + rfYCorrection = -aSize.Width *rtl::math::cos( fAnglePi - F_PI/2.0 ) + +aSize.Height*rtl::math::sin( fAnglePi - F_PI/2.0 )/2.0; + } + else if( fAnglePositiveDegree<= 270.0 ) + { + double beta = fAnglePi - F_PI; + double gamma = 3*F_PI/2.0 - fAnglePi; + rfXCorrection = -aSize.Width *rtl::math::cos( beta ); + rfYCorrection = +aSize.Height*rtl::math::sin( gamma )/2.0 + +aSize.Width *rtl::math::sin( beta ); + } + else + { + rfXCorrection = 0.0; + rfYCorrection = -aSize.Height*rtl::math::cos( fAnglePi )/2.0; + } +} + +void lcl_correctRotation_Right( double& rfXCorrection, double& rfYCorrection + , double fAnglePositiveDegree, const awt::Size& aSize ) +{ + //correct position for right y-axis with left top alignment + double fAnglePi = fAnglePositiveDegree*F_PI/180.0; + if( fAnglePositiveDegree==0.0 ) + { + rfXCorrection = 0.0; + rfYCorrection = -aSize.Height/2.0; + } + else if( fAnglePositiveDegree<= 90.0 ) + { + rfXCorrection = 0.0; + rfYCorrection = -aSize.Height*rtl::math::cos( fAnglePi )/2.0; + } + else if( fAnglePositiveDegree<= 180.0 ) + { + double beta = F_PI - fAnglePi; + double gamma = fAnglePi - F_PI/2.0; + rfXCorrection = aSize.Width *rtl::math::cos( beta ); + rfYCorrection = +aSize.Height*rtl::math::sin( gamma )/2.0 + +aSize.Width *rtl::math::sin( beta ); + } + else if( fAnglePositiveDegree<= 270.0 ) + { + double beta = 3*F_PI/2.0 - fAnglePi; + rfXCorrection = aSize.Width *rtl::math::sin( beta ) + +aSize.Height*rtl::math::cos( beta ); + rfYCorrection = -aSize.Width *rtl::math::cos( beta ) + +aSize.Height*rtl::math::sin( beta )/2.0; + } + else + { + rfXCorrection = aSize.Height*rtl::math::sin( 2*F_PI - fAnglePi ); + rfYCorrection = -aSize.Height*rtl::math::cos( 2*F_PI - fAnglePi )/2.0; + } +} +void lcl_correctRotation_Bottom_Left( double& rfXCorrection, double& rfYCorrection + , double fAnglePositiveDegree, const awt::Size& aSize ) +{ + //correct position for bottom x-axis with left top alignment + double fAnglePi = fAnglePositiveDegree*F_PI/180.0; + if( fAnglePositiveDegree==0.0 ) + { + rfXCorrection = -aSize.Width/2.0; + rfYCorrection = 0.0; + } + else if( fAnglePositiveDegree<= 90.0 ) + { + rfXCorrection = -aSize.Height*rtl::math::sin( fAnglePi )/2.0 + -aSize.Width *rtl::math::cos( fAnglePi ); + rfYCorrection = aSize.Width *rtl::math::sin( fAnglePi ); + } + else if( fAnglePositiveDegree<= 180.0 ) + { + double beta = F_PI - fAnglePi; + rfYCorrection = aSize.Width *rtl::math::sin( beta ) + +aSize.Height*rtl::math::cos( beta ); + rfXCorrection = aSize.Width *rtl::math::cos( beta ) + -aSize.Height*rtl::math::sin( beta )/2.0; + } + else if( fAnglePositiveDegree<= 270.0 ) + { + double beta = 3*F_PI/2.0 - fAnglePi; + rfXCorrection = aSize.Height*rtl::math::cos( beta )/2.0; + rfYCorrection = aSize.Height*rtl::math::sin( beta ); + } + else + { + double beta = 2*F_PI - fAnglePi; + rfXCorrection = aSize.Height*rtl::math::sin( beta )/2.0; + rfYCorrection = 0.0; + } +} + +void lcl_correctRotation_Bottom_Right( double& rfXCorrection, double& rfYCorrection + , double fAnglePositiveDegree, const awt::Size& aSize ) +{ + //correct position for bottom x-axis with right top alignment + double fAnglePi = fAnglePositiveDegree*F_PI/180.0; + if( fAnglePositiveDegree==0.0 ) + { + rfXCorrection = aSize.Width/2.0; + rfYCorrection = 0.0; + } + else if( fAnglePositiveDegree<= 90.0 ) + { + rfXCorrection = -aSize.Height*rtl::math::sin( fAnglePi )/2.0; + rfYCorrection = 0.0; + } + else if( fAnglePositiveDegree<= 180.0 ) + { + double beta = F_PI - fAnglePi; + rfYCorrection = aSize.Height*rtl::math::cos( beta ); + rfXCorrection = -aSize.Height*rtl::math::sin( beta )/2.0; + } + else if( fAnglePositiveDegree<= 270.0 ) + { + double beta = 3*F_PI/2.0 - fAnglePi; + rfXCorrection = aSize.Height*rtl::math::cos( beta )/2.0 + -aSize.Width*rtl::math::sin( beta ); + + rfYCorrection = aSize.Height*rtl::math::sin( beta ) + +aSize.Width*rtl::math::cos( beta ); + } + else + { + double beta = 2*F_PI - fAnglePi; + rfXCorrection = aSize.Height*rtl::math::sin( beta )/2.0 + +aSize.Width*rtl::math::cos( beta ); + rfYCorrection = aSize.Width*rtl::math::sin( beta ); + } +} + +void lcl_correctRotation_Top_Left( double& rfXCorrection, double& rfYCorrection + , double fAnglePositiveDegree, const awt::Size& aSize ) +{ + //correct position for top x-axis with left top alignment + double fAnglePi = fAnglePositiveDegree*F_PI/180.0; + if( fAnglePositiveDegree==0.0 ) + { + rfXCorrection = -aSize.Width/2.0; + rfYCorrection = 0.0; + } + else if( fAnglePositiveDegree<= 90.0 ) + { + rfXCorrection = +aSize.Height*rtl::math::sin( fAnglePi )/2.0; + rfYCorrection = 0.0; + } + else if( fAnglePositiveDegree<= 180.0 ) + { + double beta = F_PI - fAnglePi; + rfYCorrection = -aSize.Height*rtl::math::cos( beta ); + rfXCorrection = aSize.Height*rtl::math::sin( beta )/2.0; + } + else if( fAnglePositiveDegree<= 270.0 ) + { + double beta = 3*F_PI/2.0 - fAnglePi; + rfXCorrection = -aSize.Height*rtl::math::cos( beta )/2.0 + +aSize.Width *rtl::math::sin( beta ); + rfYCorrection = -aSize.Width *rtl::math::cos( beta ) + -aSize.Height*rtl::math::sin( beta ); + } + else + { + double beta = 2*F_PI - fAnglePi; + rfXCorrection = - aSize.Width*rtl::math::cos( beta ) + - aSize.Height*rtl::math::sin( beta )/2.0; + rfYCorrection = - aSize.Width*rtl::math::sin( beta ); + } +} + +void lcl_correctRotation_Top_Right( double& rfXCorrection, double& rfYCorrection + , double fAnglePositiveDegree, const awt::Size& aSize ) +{ + //correct position for top x-axis with right top alignment + double fAnglePi = fAnglePositiveDegree*F_PI/180.0; + if( fAnglePositiveDegree==0.0 ) + { + rfXCorrection = aSize.Width/2.0; + rfYCorrection = 0.0; + } + else if( fAnglePositiveDegree<= 90.0 ) + { + rfXCorrection = aSize.Height*rtl::math::sin( fAnglePi )/2.0 + +aSize.Width*rtl::math::cos( fAnglePi ); + rfYCorrection = -aSize.Width*rtl::math::sin( fAnglePi ); + } + else if( fAnglePositiveDegree<= 180.0 ) + { + double beta = F_PI - fAnglePi; + rfYCorrection = -aSize.Height*rtl::math::cos( beta ) + -aSize.Width*rtl::math::sin( beta ); + rfXCorrection = -aSize.Width*rtl::math::cos( beta ) + +aSize.Height*rtl::math::sin( beta )/2.0; + } + else if( fAnglePositiveDegree<= 270.0 ) + { + double beta = 3*F_PI/2.0 - fAnglePi; + rfXCorrection = -aSize.Height*rtl::math::cos( beta )/2.0; + rfYCorrection = -aSize.Height*rtl::math::sin( beta ); + } + else + { + double beta = 2*F_PI - fAnglePi; + rfXCorrection = - aSize.Height*rtl::math::sin( beta )/2.0; + rfYCorrection = - 0.0; + } +} + +enum ShiftDirection { SHIFT_LEFT, SHIFT_TOP, SHIFT_RIGHT, SHIFT_BOTTOM }; +enum RotationCentre { ROTATE_LEFT_TOP, ROTATE_LEFT_BOTTOM, ROTATE_RIGHT_TOP, ROTATE_RIGHT_BOTTOM }; + +ShiftDirection lcl_getLabelShiftDirection( const AxisProperties& rAxisProperties ) +{ + ShiftDirection aShiftDirection = SHIFT_RIGHT; + if(rAxisProperties.m_bIsYAxis) + { + if(rAxisProperties.m_bIsLeftOrBottomAxis) + aShiftDirection = SHIFT_LEFT; + } + else + { + if(rAxisProperties.m_bIsLeftOrBottomAxis) + aShiftDirection = SHIFT_BOTTOM; + else + aShiftDirection = SHIFT_TOP; + } + return aShiftDirection; +} + +RotationCentre lcl_getLabelRotationCentre( + const AxisProperties& rAxisProperties + , const AxisLabelProperties& rAxisLabelProperties ) +{ + //indicate where the centre of the rotation lies (e.g. top left or bottom left corner of the text shape) + RotationCentre aRotationCentre = ROTATE_LEFT_TOP; + { + LabelAlignment eLabelAlignment( lcl_getLabelAlignment( rAxisProperties ) ); + switch(eLabelAlignment) + { + case LABEL_ALIGN_LEFT_TOP: + aRotationCentre = ROTATE_RIGHT_BOTTOM; + break; + case LABEL_ALIGN_LEFT_BOTTOM: + aRotationCentre = ROTATE_RIGHT_TOP; + break; + case LABEL_ALIGN_RIGHT_TOP: + aRotationCentre = ROTATE_LEFT_BOTTOM; + break; + case LABEL_ALIGN_RIGHT_BOTTOM: + aRotationCentre = ROTATE_LEFT_TOP; + break; + case LABEL_ALIGN_LEFT: + case LABEL_ALIGN_TOP: + case LABEL_ALIGN_RIGHT: + case LABEL_ALIGN_BOTTOM: + default: //LABEL_ALIGN_CENTER + ROTATE_RIGHT_BOTTOM; + break; + }; + } + return aRotationCentre; +} + +void lcl_getPositionCorrectionForRotation( + double& rfXCorrection + , double& rfYCorrection + , const ShiftDirection& aShiftDirection + , const RotationCentre& aRotationCentre + , const double fRotationAngle + , const awt::Size& aSize ) +{ + double fAnglePositiveDegree = fRotationAngle; + while(fAnglePositiveDegree<0.0) + fAnglePositiveDegree+=360.0; + + if( SHIFT_LEFT ==aShiftDirection ) + { + DBG_ASSERT( ROTATE_RIGHT_TOP ==aRotationCentre, "it is assumed that rotation centre is at left top corner if labels are shifted to the right" ); + + lcl_correctRotation_Left( rfXCorrection, rfYCorrection, fAnglePositiveDegree, aSize ); + } + else if( SHIFT_RIGHT ==aShiftDirection ) + { + DBG_ASSERT( ROTATE_LEFT_TOP ==aRotationCentre, "it is assumed that rotation centre is at left top corner if labels are shifted to the right" ); + + lcl_correctRotation_Right( rfXCorrection, rfYCorrection, fAnglePositiveDegree, aSize ); + } + else if( SHIFT_BOTTOM ==aShiftDirection ) + { + DBG_ASSERT( ROTATE_LEFT_TOP ==aRotationCentre + || ROTATE_RIGHT_TOP ==aRotationCentre + , "it is assumed that rotation centre is at left or right top corner if labels are shifted to the bottom" ); + + if( ROTATE_LEFT_TOP ==aRotationCentre ) + lcl_correctRotation_Bottom_Left( rfXCorrection, rfYCorrection, fAnglePositiveDegree, aSize ); + else + lcl_correctRotation_Bottom_Right( rfXCorrection, rfYCorrection, fAnglePositiveDegree, aSize ); + } + else if( SHIFT_TOP ==aShiftDirection ) + { + DBG_ASSERT( ROTATE_LEFT_BOTTOM ==aRotationCentre + || ROTATE_RIGHT_BOTTOM ==aRotationCentre + , "it is assumed that rotation centre is at left or right bottom corner if labels are shifted to the top" ); + + if( ROTATE_LEFT_BOTTOM ==aRotationCentre ) + lcl_correctRotation_Top_Left( rfXCorrection, rfYCorrection, fAnglePositiveDegree, aSize ); + else + lcl_correctRotation_Top_Right( rfXCorrection, rfYCorrection, fAnglePositiveDegree, aSize ); + } +} +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +uno::Reference< drawing::XShape > createSingleLabel( + const uno::Reference< lang::XMultiServiceFactory>& xShapeFactory + , const uno::Reference< drawing::XShapes >& xTarget + , const awt::Point& rAnchorScreenPosition2D + , const rtl::OUString& rLabel + , const AxisLabelProperties& rAxisLabelProperties + , const AxisProperties& rAxisProperties + , const tNameSequence& rPropNames + , const tAnySequence& rPropValues + ) +{ + double fRotationAnglePi = rAxisLabelProperties.fRotationAngleDegree*F_PI/180.0; + uno::Any aATransformation = ShapeFactory::makeTransformation( rAnchorScreenPosition2D, fRotationAnglePi ); + rtl::OUString aLabel = ShapeFactory::getStackedString( rLabel, rAxisLabelProperties.bStackCharacters ); + + uno::Reference< drawing::XShape > xShape2DText = ShapeFactory(xShapeFactory) + .createText( xTarget, aLabel, rPropNames, rPropValues, aATransformation ); + //------------- + //correctPositionForRotation() + awt::Point aOldPos = xShape2DText->getPosition(); + awt::Size aSize = xShape2DText->getSize(); + + ShiftDirection aShiftDirection = lcl_getLabelShiftDirection( rAxisProperties ); + RotationCentre aRotationCentre = lcl_getLabelRotationCentre( rAxisProperties, rAxisLabelProperties ); + + double fYCorrection = 0.0; + double fXCorrection = 0.0; + + lcl_getPositionCorrectionForRotation( fXCorrection, fYCorrection + , aShiftDirection, aRotationCentre + , rAxisLabelProperties.fRotationAngleDegree, aSize ); + + xShape2DText->setPosition( awt::Point( + static_cast<sal_Int32>(aOldPos.X + fXCorrection ) + , static_cast<sal_Int32>(aOldPos.Y + fYCorrection ) ) ); + //------------- + + return xShape2DText; +} + +bool lcl_doesOverlap( const uno::Reference< drawing::XShape >& xShape +, sal_Int32 nScreenTickValue, bool bCheckDirectionIsY ) +{ + if(!xShape.is()) + return false; + + awt::Size aSize = xShape->getSize(); + awt::Point aPos = xShape->getPosition(); + + sal_Int32 nMin = bCheckDirectionIsY ? aPos.Y : aPos.X; + sal_Int32 nMax = nMin + ( bCheckDirectionIsY ? aSize.Height : aSize.Width ); + + return nMin <= nScreenTickValue && nScreenTickValue <= nMax; +} + +bool doesOverlap( const uno::Reference< drawing::XShape >& xShape1 + , const uno::Reference< drawing::XShape >& xShape2 + , bool bCheckDirectionIsY ) +{ + awt::Size aSize1 = xShape1->getSize(); + awt::Point aPos1 = xShape1->getPosition(); + + sal_Int32 nMin1 = bCheckDirectionIsY ? aPos1.Y : aPos1.X; + sal_Int32 nMax1 = nMin1 + ( bCheckDirectionIsY ? aSize1.Height : aSize1.Width ); + + awt::Size aSize2 = xShape2->getSize(); + awt::Point aPos2 = xShape2->getPosition(); + + sal_Int32 nMin2 = bCheckDirectionIsY ? aPos2.Y : aPos2.X; + sal_Int32 nMax2 = nMin2 + ( bCheckDirectionIsY ? aSize2.Height : aSize2.Width ); + + if( nMax1 < nMin2 ) + return false; + if( nMax2 < nMin1 ) + return false; + return true; +} + +void removeShapesAtWrongRythm( TickIter& rIter + , sal_Int32 nCorrectRhythm + , sal_Int32 nMaxTickToCheck + , const uno::Reference< drawing::XShapes >& xTarget ) +{ + sal_Int32 nTick = 0; + for( TickInfo* pTickInfo = rIter.firstInfo() + ; pTickInfo && nTick <= nMaxTickToCheck + ; pTickInfo = rIter.nextInfo(), nTick++ ) + { + //remove labels which does not fit into the rythm + if( nTick%nCorrectRhythm != 0) + { + if(pTickInfo->xTextShape.is()) + { + xTarget->remove(pTickInfo->xTextShape); + pTickInfo->xTextShape = NULL; + } + } + } +} + +class LabelIterator : private TickIter +{ + //this Iterator iterates over existing text labels + + //if the labels are staggered and bInnerLine is true + //we iterate only through the labels which are lying more inside the diagram + + //if the labels are staggered and bInnerLine is false + //we iterate only through the labels which are lying more outside the diagram + + //if the labels are not staggered + //we iterate through all labels + +public: + LabelIterator( ::std::vector< ::std::vector< TickInfo > >& rTickInfos + , const ::drafts::com::sun::star::chart2::ExplicitIncrementData& rIncrement + , const AxisLabelStaggering eAxisLabelStaggering + , bool bInnerLine + , sal_Int32 nMinDepth=0, sal_Int32 nMaxDepth=-1 ); + + TickInfo* firstInfo(); + TickInfo* nextInfo(); + +private: //methods + LabelIterator(); + +private: //member + const AxisLabelStaggering m_eAxisLabelStaggering; + bool m_bInnerLine; +}; + +LabelIterator::LabelIterator( ::std::vector< ::std::vector< TickInfo > >& rTickInfos + , const ::drafts::com::sun::star::chart2::ExplicitIncrementData& rIncrement + , const AxisLabelStaggering eAxisLabelStaggering + , bool bInnerLine + , sal_Int32 nMinDepth, sal_Int32 nMaxDepth ) + : TickIter( rTickInfos, rIncrement, nMinDepth, nMaxDepth ) + , m_eAxisLabelStaggering(eAxisLabelStaggering) + , m_bInnerLine(bInnerLine) +{ +} + +TickInfo* LabelIterator::firstInfo() +{ + TickInfo* pTickInfo = TickIter::firstInfo(); + while( pTickInfo && !pTickInfo->xTextShape.is() ) + pTickInfo = TickIter::nextInfo(); + if(!pTickInfo) + return NULL; + if( (STAGGER_EVEN==m_eAxisLabelStaggering && !m_bInnerLine) + || + (STAGGER_ODD==m_eAxisLabelStaggering && m_bInnerLine) + ) + { + //skip first label + do + pTickInfo = TickIter::nextInfo(); + while( pTickInfo && !pTickInfo->xTextShape.is() ); + } + if(!pTickInfo) + return NULL; + return pTickInfo; +} + +TickInfo* LabelIterator::nextInfo() +{ + TickInfo* pTickInfo = NULL; + //get next label + do + pTickInfo = TickIter::nextInfo(); + while( pTickInfo && !pTickInfo->xTextShape.is() ); + + if( STAGGER_EVEN==m_eAxisLabelStaggering + || STAGGER_ODD==m_eAxisLabelStaggering ) + { + //skip one label + do + pTickInfo = TickIter::nextInfo(); + while( pTickInfo && !pTickInfo->xTextShape.is() ); + } + return pTickInfo; +} + +sal_Int32 lcl_getStaggerDistance( + LabelIterator& rIter + , const ShiftDirection aShiftDirection ) +{ + //calculates the height or width of the first line of labels + //thus the second line of labels needs to be shifted for that distance + + sal_Int32 nRet=0; + uno::Reference< drawing::XShape > xShape2DText(NULL); + for( TickInfo* pTickInfo = rIter.firstInfo() + ; pTickInfo + ; pTickInfo = rIter.nextInfo() ) + { + xShape2DText = pTickInfo->xTextShape; + DBG_ASSERT(xShape2DText.is(),"LabelIterator does not work correctly"); + + awt::Size aSize = xShape2DText->getSize(); + switch(aShiftDirection) + { + case SHIFT_TOP: + nRet = ::std::max(nRet,aSize.Height); break; + case SHIFT_BOTTOM: + nRet = ::std::max(nRet,aSize.Height); break; + case SHIFT_LEFT: + nRet = ::std::max(nRet,aSize.Width); break; + case SHIFT_RIGHT: + nRet = ::std::max(nRet,aSize.Width); break; + } + } + return nRet; +} + +void lcl_correctPositionForStaggering( + LabelIterator& rIter + , const ShiftDirection aShiftDirection + , sal_Int32 nStaggerDistance + ) +{ + uno::Reference< drawing::XShape > xShape2DText(NULL); + for( TickInfo* pTickInfo = rIter.firstInfo() + ; pTickInfo + ; pTickInfo = rIter.nextInfo() ) + { + xShape2DText = pTickInfo->xTextShape; + DBG_ASSERT(xShape2DText.is(),"LabelIterator does not work correctly"); + + awt::Point aPos = xShape2DText->getPosition(); + switch(aShiftDirection) + { + case SHIFT_TOP: + aPos.Y -= nStaggerDistance; break; + case SHIFT_BOTTOM: + aPos.Y += nStaggerDistance; break; + case SHIFT_LEFT: + aPos.X -= nStaggerDistance; break; + case SHIFT_RIGHT: + aPos.X += nStaggerDistance; break; + } + xShape2DText->setPosition( aPos ); + } +} + +bool createTextShapes( const uno::Reference< lang::XMultiServiceFactory >& xShapeFactory + , const uno::Reference< drawing::XShapes >& xTarget + , ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos + , const ExplicitIncrementData& rIncrement + , AxisLabelProperties& rAxisLabelProperties + , const AxisProperties& rAxisProperties + , sal_Int32 nTextReferenceScreenPosition + , const FixedNumberFormatter& rFixedNumberFormatter + , const uno::Reference< XScaling >& xInverseScaling ) +{ + //returns true if the text shapes have been created succesfully + //otherwise false - in this case the AxisLabelProperties have changed + //and contain new instructions for the next try for text shape creation + + bool bOverlapCheckDirectionIsY = rAxisProperties.m_bIsYAxis; + //@todo: iterate through all tick depth wich should be labeled + TickIter aIter( rAllTickInfos, rIncrement, 0, 0 ); + TickInfo* pPreviousVisibleTickInfo = NULL; + TickInfo* pPREPreviousVisibleTickInfo = NULL; + TickInfo* pLastVisibleNeighbourTickInfo = NULL; + bool bIsStaggered = rAxisLabelProperties.getIsStaggered(); + sal_Int32 nLimitedSpaceForStaggering = -1; + if( bIsStaggered && rAxisLabelProperties.bLineBreakAllowed + && rAxisLabelProperties.fRotationAngleDegree == 0.0 //use line break only, if labels are not rotated + ) + { + nLimitedSpaceForStaggering = 2*TickmarkHelper_2D::getTickScreenDistance( aIter ); + if( nLimitedSpaceForStaggering > 0 ) + { //reduce space for a small amount to have a visible distance between the labels: + sal_Int32 nReduce = (nLimitedSpaceForStaggering*5)/100; + if(!nReduce) + nReduce = 1; + nLimitedSpaceForStaggering -= nReduce; + } + //maybe @todo in future: + //if the labeled tickmarks are not equidistant [this is not considered to be a relevant case so far] + //the limited space maybe needs to be calculated for each tickmark seperatly + //or the staggering could be ignored in that case + } + + //------------------------------------------------ + //prepare properties for multipropertyset-interface of shape + tNameSequence aPropNames; + tAnySequence aPropValues; + + uno::Reference< beans::XPropertySet > xProps( rAxisProperties.m_xAxisModel, uno::UNO_QUERY ); + PropertyMapper::getTextLabelMultiPropertyLists( xProps, aPropNames, aPropValues, false + , nLimitedSpaceForStaggering, rAxisProperties.m_bIsYAxis ); + LabelPositionHelper::doDynamicFontResize( aPropValues, aPropNames, xProps + , rAxisProperties.m_aReferenceSize ); + LabelPositionHelper::changeTextAdjustment( aPropValues, aPropNames, lcl_getLabelAlignment( rAxisProperties ) ); + + uno::Any* pColorAny = PropertyMapper::getValuePointer(aPropValues,aPropNames,C2U("CharColor")); + sal_Int32 nColor = Color( COL_AUTO ).GetColor(); + if(pColorAny) + *pColorAny >>= nColor; + //------------------------------------------------ + + sal_Int32 nTick = 0; + for( TickInfo* pTickInfo = aIter.firstInfo() + ; pTickInfo + ; pTickInfo = aIter.nextInfo(), nTick++ ) + { + pLastVisibleNeighbourTickInfo = bIsStaggered ? + pPREPreviousVisibleTickInfo : pPreviousVisibleTickInfo; + + //don't create labels which does not fit into the rythm + if( nTick%rAxisLabelProperties.nRhythm != 0) + continue; + + //don't create labels for invisible ticks + if( !pTickInfo->bPaintIt ) + continue; + + //if NO OVERLAP -> don't create labels where the tick overlaps + //with the text of the last neighbour tickmark + if( pLastVisibleNeighbourTickInfo && !rAxisLabelProperties.bOverlapAllowed ) + { + if( lcl_doesOverlap( pLastVisibleNeighbourTickInfo->xTextShape, pTickInfo->nScreenTickValue, bOverlapCheckDirectionIsY ) ) + { + if( rAxisLabelProperties.bRhythmIsFix ) + continue; + rAxisLabelProperties.nRhythm++; + TickIter aRemoveIter( rAllTickInfos, rIncrement, 0, 0 ); + removeShapesAtWrongRythm( aRemoveIter, rAxisLabelProperties.nRhythm, nTick, xTarget ); + return false; + } + } + + pTickInfo->updateUnscaledValue( xInverseScaling ); + + bool bHasExtraColor=false; + sal_Int32 nExtraColor=0; + rtl::OUString aLabel = rFixedNumberFormatter.getFormattedString( pTickInfo->fUnscaledTickValue, nExtraColor, bHasExtraColor ); + if(pColorAny) + *pColorAny = uno::makeAny(bHasExtraColor?nExtraColor:nColor); + + awt::Point aAnchorScreenPosition2D; + {//get anchor position + sal_Int32 nAxisPos = nTextReferenceScreenPosition; + sal_Int32 nTickPos = pTickInfo->nScreenTickValue; + if( rAxisProperties.m_bIsYAxis ) + aAnchorScreenPosition2D = awt::Point(nAxisPos,nTickPos); + else + aAnchorScreenPosition2D = awt::Point(nTickPos,nAxisPos); + } + + //create single label + if(!pTickInfo->xTextShape.is()) + pTickInfo->xTextShape = createSingleLabel( xShapeFactory, xTarget + , aAnchorScreenPosition2D, aLabel + , rAxisLabelProperties, rAxisProperties + , aPropNames, aPropValues ); + + //if NO OVERLAP -> remove overlapping shapes + if( pLastVisibleNeighbourTickInfo && !rAxisLabelProperties.bOverlapAllowed ) + { + if( doesOverlap( pLastVisibleNeighbourTickInfo->xTextShape, pTickInfo->xTextShape, bOverlapCheckDirectionIsY ) ) + { + if( rAxisLabelProperties.bRhythmIsFix ) + { + xTarget->remove(pTickInfo->xTextShape); + pTickInfo->xTextShape = NULL; + continue; + } + rAxisLabelProperties.nRhythm++; + TickIter aRemoveIter( rAllTickInfos, rIncrement, 0, 0 ); + removeShapesAtWrongRythm( aRemoveIter, rAxisLabelProperties.nRhythm, nTick, xTarget ); + return false; + } + } + + pPREPreviousVisibleTickInfo = pPreviousVisibleTickInfo; + pPreviousVisibleTickInfo = pTickInfo; + } + return true; +} + +sal_Int32 lcl_getTextReferenceScreenPosition( const ::std::vector<TickmarkProperties>& rTickmarkPropertiesList + , bool bIsYAxis + , bool bIsLeftOrBottomAxis + , sal_Int32 nAxisPos ) +{ + sal_Int32 nRet = 0; + + bool bFindMin = (bIsYAxis && bIsLeftOrBottomAxis) || (!bIsYAxis && !bIsLeftOrBottomAxis); + ::std::vector<TickmarkProperties>::const_iterator aIter = rTickmarkPropertiesList.begin(); + const ::std::vector<TickmarkProperties>::const_iterator aIterEnd = rTickmarkPropertiesList.end(); + for( ; aIter != aIterEnd; aIter++ ) + { + if( ( bFindMin && (*aIter).RelativePos < nRet ) + || + ( !bFindMin && (*aIter).RelativePos > nRet ) + ) + { + nRet = (*aIter).RelativePos; + } + } + nRet+=nAxisPos; + + if(bFindMin) + nRet-=AXIS2D_TICKLABELSPACING; + else + nRet+=AXIS2D_TICKLABELSPACING; + return nRet; +} + +void addLine( drawing::PointSequenceSequence& rPoints, sal_Int32 nIndex + , sal_Int32 nScreenTickValue, sal_Int32 nOrthogonalAxisScreenPosition + , const TickmarkProperties& rTickmarkProperties, bool bIsYAxis ) +{ + sal_Int32 nStartX = bIsYAxis ? nOrthogonalAxisScreenPosition + rTickmarkProperties.RelativePos : nScreenTickValue; + sal_Int32 nStartY = bIsYAxis ? nScreenTickValue : nOrthogonalAxisScreenPosition + rTickmarkProperties.RelativePos; + + sal_Int32 nEndX = nStartX; + sal_Int32 nEndY = nStartY; + if( bIsYAxis ) + nEndX += rTickmarkProperties.Length; + else + nEndY += rTickmarkProperties.Length; + + rPoints[nIndex].realloc(2); + rPoints[nIndex][0].X = nStartX; + rPoints[nIndex][0].Y = nStartY; + rPoints[nIndex][1].X = nEndX; + rPoints[nIndex][1].Y = nEndY; +} + +void createPointSequenceForAxisMainLine( drawing::PointSequenceSequence& rPoints, + bool bIsYAxis, sal_Int32 nOrthogonalPos, sal_Int32 nMin, sal_Int32 nMax ) +{ + rPoints[0].realloc(2); + rPoints[0][0].X = bIsYAxis ? nOrthogonalPos : nMin; + rPoints[0][0].Y = bIsYAxis ? nMin : nOrthogonalPos; + rPoints[0][1].X = bIsYAxis ? nOrthogonalPos : nMax; + rPoints[0][1].Y = bIsYAxis ? nMax : nOrthogonalPos; +} + +void SAL_CALL VAxis::createShapes() +{ + DBG_ASSERT(m_pShapeFactory&&m_xLogicTarget.is()&&m_xFinalTarget.is(),"Axis is not proper initialized"); + if(!(m_pShapeFactory&&m_xLogicTarget.is()&&m_xFinalTarget.is())) + return; + + m_aAxisProperties.init(); + bool bIsYAxis = m_aAxisProperties.m_bIsYAxis; + bool bIsLeftOrBottomAxis = m_aAxisProperties.m_bIsLeftOrBottomAxis; + sal_Int32 nMainLineScreenPosition = lcl_getMainLineScreenPosition( *m_pPosHelper, m_aAxisProperties ); + + //----------------------------------------- + //create named group shape + uno::Reference< XIdentifiable > xIdent( m_aAxisProperties.m_xAxisModel, uno::UNO_QUERY ); + DBG_ASSERT( xIdent.is(), "Axis should support XIdentifiable" ); + if( ! xIdent.is()) + return; + uno::Reference< drawing::XShapes > xGroupShape_Shapes( + m_pShapeFactory->createGroup2D( m_xLogicTarget + , ObjectIdentifier::createClassifiedIdentifier( + OBJECTTYPE_AXIS, xIdent->getIdentifier() ) + ) ); + + //----------------------------------------- + //create all scaled tickmark values + std::auto_ptr< TickmarkHelper > apTickmarkHelper( this->createTickmarkHelper() ); + ::std::vector< ::std::vector< TickInfo > > aAllTickInfos; + apTickmarkHelper->getAllTicks( aAllTickInfos ); + + //----------------------------------------- + //create tick mark line shapes + ::std::vector< ::std::vector< TickInfo > >::iterator aDepthIter = aAllTickInfos.begin(); + const ::std::vector< ::std::vector< TickInfo > >::const_iterator aDepthEnd = aAllTickInfos.end(); + + if(aDepthIter == aDepthEnd)//no tickmarks at all + return; + + sal_Int32 nTickmarkPropertiesCount = m_aAxisProperties.m_aTickmarkPropertiesList.size(); + for( sal_Int32 nDepth=0 + ; aDepthIter != aDepthEnd && nDepth < nTickmarkPropertiesCount + ; aDepthIter++, nDepth++ ) + { + const TickmarkProperties& rTickmarkProperties = m_aAxisProperties.m_aTickmarkPropertiesList[nDepth]; + + sal_Int32 nPointCount = (*aDepthIter).size(); + drawing::PointSequenceSequence aPoints(nPointCount); + + ::std::vector< TickInfo >::const_iterator aTickIter = (*aDepthIter).begin(); + const ::std::vector< TickInfo >::const_iterator aTickEnd = (*aDepthIter).end(); + sal_Int32 nN = 0; + for( ; aTickIter != aTickEnd; aTickIter++ ) + { + if( !(*aTickIter).bPaintIt ) + continue; + addLine( aPoints, nN + , (*aTickIter).nScreenTickValue, nMainLineScreenPosition + , rTickmarkProperties, bIsYAxis); + nN++; + } + aPoints.realloc(nN); + m_pShapeFactory->createLine2D( xGroupShape_Shapes, aPoints + , rTickmarkProperties.aLineProperties ); + } + //----------------------------------------- + //create axis main lines + if(2==m_nDimension) + { + //TickmarkHelper_2D& aTickmarkHelper = *dynamic_cast<TickmarkHelper_2D*>(apTickmarkHelper.get()); + TickmarkHelper_2D& aTickmarkHelper = *reinterpret_cast<TickmarkHelper_2D*>(apTickmarkHelper.get()); + //create axis line + //it serves also as the handle shape for the axis selection + { + drawing::PointSequenceSequence aPoints(1); + createPointSequenceForAxisMainLine( aPoints + , bIsYAxis, nMainLineScreenPosition + , aTickmarkHelper.getScreenValueForMinimum(), aTickmarkHelper.getScreenValueForMaximum() ); + + uno::Reference< drawing::XShape > xShape = m_pShapeFactory->createLine2D( + xGroupShape_Shapes, aPoints + , m_aAxisProperties.m_aLineProperties ); + //because of this name this line will be used for marking the axis + m_pShapeFactory->setShapeName( xShape, C2U("MarkHandles") ); + } + //----------------------------------------- + //create an additional line at NULL + sal_Int32 nExtraLineScreenPosition; + if( lcl_getExtraLineScreenPosition( nExtraLineScreenPosition, *m_pPosHelper, m_aAxisProperties ) ) + { + drawing::PointSequenceSequence aPoints(1); + createPointSequenceForAxisMainLine( aPoints + , bIsYAxis, nExtraLineScreenPosition + , aTickmarkHelper.getScreenValueForMinimum(), aTickmarkHelper.getScreenValueForMaximum() ); + + uno::Reference< drawing::XShape > xShape = m_pShapeFactory->createLine2D( + xGroupShape_Shapes, aPoints + , m_aAxisProperties.m_aLineProperties ); + } + } + //----------------------------------------- + //create labels + AxisLabelProperties aAxisLabelProperties; + aAxisLabelProperties.init(m_aAxisProperties.m_xAxisModel); + if( aAxisLabelProperties.bDisplayLabels ) + { + FixedNumberFormatter aFixedNumberFormatter( + m_pNumberFormatterWrapper, aAxisLabelProperties.aNumberFormat ); + + uno::Reference< XScaling > xInverseScaling( NULL ); + if( m_aScale.Scaling.is() ) + xInverseScaling = m_aScale.Scaling->getInverseScaling(); + + sal_Int32 nTextReferenceScreenPosition = lcl_getTextReferenceScreenPosition( + m_aAxisProperties.m_aTickmarkPropertiesList + , bIsYAxis, bIsLeftOrBottomAxis, nMainLineScreenPosition ); + + //create tick mark text shapes + while( !createTextShapes( m_xShapeFactory, xGroupShape_Shapes, aAllTickInfos + , m_aIncrement, aAxisLabelProperties, m_aAxisProperties + , nTextReferenceScreenPosition + , aFixedNumberFormatter, xInverseScaling + ) ) + { + }; + + //staggering + if( aAxisLabelProperties.getIsStaggered() ) + { + LabelIterator aInnerIter( aAllTickInfos, m_aIncrement + , aAxisLabelProperties.eStaggering, true, 0, 0 ); + LabelIterator aOuterIter( aAllTickInfos, m_aIncrement + , aAxisLabelProperties.eStaggering, false, 0, 0 ); + + sal_Int32 nStaggerDistance = lcl_getStaggerDistance( aInnerIter + , lcl_getLabelShiftDirection( m_aAxisProperties ) ); + + lcl_correctPositionForStaggering( aOuterIter + , lcl_getLabelShiftDirection( m_aAxisProperties ) + , nStaggerDistance ); + } + } +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/view/axes/VCartesianAxis.hxx b/chart2/source/view/axes/VCartesianAxis.hxx new file mode 100644 index 000000000000..8f29d974e0dd --- /dev/null +++ b/chart2/source/view/axes/VCartesianAxis.hxx @@ -0,0 +1,129 @@ +/************************************************************************* + * + * $RCSfile: VCartesianAxis.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: iha $ $Date: 2004-01-17 13:09:55 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2003 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef _CHART2_VAXIS_HXX +#define _CHART2_VAXIS_HXX + +#include "VMeterBase.hxx" +#include "VAxisProperties.hxx" + +//............................................................................. +namespace chart +{ +//............................................................................. + +//----------------------------------------------------------------------------- +/** +*/ + +class NumberFormatterWrapper; + +class VAxis : public VMeterBase +{ + //------------------------------------------------------------------------- + // public methods + //------------------------------------------------------------------------- +public: + VAxis( const AxisProperties& rAxisProperties + , NumberFormatterWrapper* pNumberFormatterWrapper + , sal_Int32 nDimensionCount=2 ); + + virtual ~VAxis(); + + //------------------------------------------------------------------------- + // partly chart2::XPlotter + //------------------------------------------------------------------------- + + /* + virtual ::rtl::OUString SAL_CALL getCoordinateSystemTypeID( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setTransformation( const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::chart2::XTransformation >& xTransformationToLogicTarget, const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::chart2::XTransformation >& xTransformationToFinalPage ) throw (::com::sun::star::uno::RuntimeException); + */ + + virtual void SAL_CALL createShapes(); + + //------------------------------------------------------------------------- + //Layout interface for cartesian axes: + + //the returned value describes the minimum size that is necessary + //for the text labels in the direction orthogonal to the axis + //(for an y-axis a width is returned; in case of an x-axis the value describes a height) + //the return value is measured in screen dimension + //As an example the MinimumOrthogonalSize of an x-axis equals the + //Font Height if the label properties allow for labels parallel to the axis. +// sal_Int32 calculateMinimumOrthogonalSize( /*... parallel...*/ ); + //Minimum->Preferred + + //returns true if the MinimumOrthogonalSize can be calculated + //with the creation of at most one text shape + //(this is e.g. true if the parameters allow for labels parallel to the axis.) +// sal_bool canQuicklyCalculateMinimumOrthogonalSize(); + + + //------------------------------------------------------------------------- + //------------------------------------------------------------------------- +private: //member + AxisProperties m_aAxisProperties; + NumberFormatterWrapper* m_pNumberFormatterWrapper; +}; + +//............................................................................. +} //namespace chart +//............................................................................. +#endif diff --git a/chart2/source/view/axes/VCartesianCoordinateSystem.cxx b/chart2/source/view/axes/VCartesianCoordinateSystem.cxx new file mode 100644 index 000000000000..b9f1b897b245 --- /dev/null +++ b/chart2/source/view/axes/VCartesianCoordinateSystem.cxx @@ -0,0 +1,133 @@ +/************************************************************************* + * + * $RCSfile: VCartesianCoordinateSystem.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: iha $ $Date: 2004-01-17 13:09:56 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2003 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#include "VCartesianCoordinateSystem.hxx" +#include "VCartesianGrid.hxx" +#include "VCartesianAxis.hxx" + +//............................................................................. +namespace chart +{ +//............................................................................. +using namespace ::com::sun::star; +using namespace ::drafts::com::sun::star::chart2; + +VCartesianCoordinateSystem::VCartesianCoordinateSystem( const uno::Reference< XBoundedCoordinateSystem >& xCooSys ) + : VCoordinateSystem(xCooSys) +{ +} + +VCartesianCoordinateSystem::~VCartesianCoordinateSystem() +{ +} + +void VCartesianCoordinateSystem::createGridShapes() +{ + sal_Int32 nDimensionCount = m_xCooSysModel->getDimension(); + for( sal_Int32 nDim=0; nDim<3; nDim++) + { + uno::Sequence< uno::Reference< XGrid > >& rGridList + = getGridListByDimension( nDim ); + for( sal_Int32 nN=0; nN<rGridList.getLength(); nN++ ) + { + VCartesianGrid aGrid(rGridList[nN],nDimensionCount); + aGrid.setMeterData( m_aExplicitScales[nDim], m_aExplicitIncrements[nDim] ); + + aGrid.init(m_xLogicTargetForGrids,m_xFinalTarget,m_xShapeFactory); + if(2==nDimensionCount) + aGrid.setTransformationSceneToScreen( m_aMatrixSceneToScreen ); + aGrid.setScales( m_aExplicitScales ); + aGrid.createShapes(); + } + } +} + +void VCartesianCoordinateSystem::createAxesShapes( const awt::Size& rReferenceSize, NumberFormatterWrapper* pNumberFormatterWrapper ) +{ + sal_Int32 nDimensionCount = m_xCooSysModel->getDimension(); + double fCoordinateOrigin[3] = { 0.0, 0.0, 0.0 }; + for( sal_Int32 nDim = 0; nDim < 3; nDim++ ) + fCoordinateOrigin[nDim] = this->getOriginByDimension( nDim ); + for( nDim = 0; nDim < 3; nDim++ ) + { + uno::Reference< XAxis > xAxis = this->getAxisByDimension(nDim); + if(xAxis.is() + &&2==nDimensionCount) //@todo remove this restriction if 3D axes are available + { + AxisProperties aAxisProperties; + aAxisProperties.m_xAxisModel = xAxis; + aAxisProperties.m_pfExrtaLinePositionAtOtherAxis = + new double(nDim==1?fCoordinateOrigin[0]:fCoordinateOrigin[1]); + aAxisProperties.m_aReferenceSize = rReferenceSize; + //------------------- + VAxis aAxis(aAxisProperties,pNumberFormatterWrapper); + aAxis.setMeterData( m_aExplicitScales[nDim], m_aExplicitIncrements[nDim] ); + aAxis.init(m_xLogicTargetForAxes,m_xFinalTarget,m_xShapeFactory); + if(2==nDimensionCount) + aAxis.setTransformationSceneToScreen( m_aMatrixSceneToScreen ); + aAxis.setScales( m_aExplicitScales ); + aAxis.createShapes(); + } + } +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/view/axes/VCartesianCoordinateSystem.hxx b/chart2/source/view/axes/VCartesianCoordinateSystem.hxx new file mode 100644 index 000000000000..7f073a94971b --- /dev/null +++ b/chart2/source/view/axes/VCartesianCoordinateSystem.hxx @@ -0,0 +1,91 @@ +/************************************************************************* + * + * $RCSfile: VCartesianCoordinateSystem.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: iha $ $Date: 2004-01-17 13:09:56 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2003 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef _CHART2_VCARTESIAN_COORDINATESYSTEM_HXX +#define _CHART2_VCARTESIAN_COORDINATESYSTEM_HXX + +#include "VCoordinateSystem.hxx" + +//............................................................................. +namespace chart +{ +//............................................................................. + +//----------------------------------------------------------------------------- +/** +*/ +class VCartesianCoordinateSystem : public VCoordinateSystem +{ +public: + VCartesianCoordinateSystem( const ::com::sun::star::uno::Reference< + ::drafts::com::sun::star::chart2::XBoundedCoordinateSystem >& xCooSys ); + virtual ~VCartesianCoordinateSystem(); + + virtual void createGridShapes(); + virtual void createAxesShapes( const ::com::sun::star::awt::Size& rReferenceSize, NumberFormatterWrapper* pNumberFormatterWrapper ); + +private: + VCartesianCoordinateSystem(); +}; + +//............................................................................. +} //namespace chart +//............................................................................. +#endif diff --git a/chart2/source/view/axes/VCartesianGrid.cxx b/chart2/source/view/axes/VCartesianGrid.cxx new file mode 100644 index 000000000000..ecf83a51fbcf --- /dev/null +++ b/chart2/source/view/axes/VCartesianGrid.cxx @@ -0,0 +1,318 @@ +/************************************************************************* + * + * $RCSfile: VCartesianGrid.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: iha $ $Date: 2004-01-17 13:09:56 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2003 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#include "VCartesianGrid.hxx" +#include "TickmarkHelper.hxx" +#include "PlottingPositionHelper.hxx" +#include "ShapeFactory.hxx" +#include "chartview/ObjectIdentifier.hxx" +#include "macros.hxx" +#include "CommonConverters.hxx" + +#ifndef _DRAFTS_COM_SUN_STAR_CHART2_XIDENTIFIABLE_HPP_ +#include <drafts/com/sun/star/chart2/XIdentifiable.hpp> +#endif +#ifndef _COM_SUN_STAR_DRAWING_POINTSEQUENCESEQUENCE_HPP_ +#include <com/sun/star/drawing/PointSequenceSequence.hpp> +#endif +#ifndef _COM_SUN_STAR_DRAWING_LINESTYLE_HPP_ +#include <com/sun/star/drawing/LineStyle.hpp> +#endif + +#include <vector> +#include <memory> + +//............................................................................. +namespace chart +{ +//............................................................................. +using namespace ::com::sun::star; +using namespace ::drafts::com::sun::star::chart2; + +VCartesianGrid::VCartesianGrid( const uno::Reference< XGrid >& xGrid, sal_Int32 nDimensionCount ) + : VMeterBase( uno::Reference<XMeter>::query(xGrid), nDimensionCount ) +{ + m_pPosHelper = new PlottingPositionHelper(); +} + +VCartesianGrid::~VCartesianGrid() +{ + delete m_pPosHelper; + m_pPosHelper = NULL; +} + +//static +void VCartesianGrid::fillLinePropertiesFromGridModel( ::std::vector<VLineProperties>& rLinePropertiesList + , uno::Reference< beans::XPropertySet > xProps ) +{ + rLinePropertiesList.clear(); + VLineProperties aLineProperties; + aLineProperties.initFromPropertySet( xProps ); + rLinePropertiesList.assign(2,aLineProperties); +}; + +void addLine2D( drawing::PointSequenceSequence& rPoints, sal_Int32 nIndex + , bool bIsYGrid , sal_Int32 nScreenTickValue + , sal_Int32 nOrthogonalStart, sal_Int32 nOrthogonalEnd + ) +{ + rPoints[nIndex].realloc(2); + rPoints[nIndex][0].X = bIsYGrid ? nOrthogonalStart : nScreenTickValue; + rPoints[nIndex][0].Y = bIsYGrid ? nScreenTickValue : nOrthogonalStart; + rPoints[nIndex][1].X = bIsYGrid ? nOrthogonalEnd : nScreenTickValue; + rPoints[nIndex][1].Y = bIsYGrid ? nScreenTickValue : nOrthogonalEnd; +} + +struct GridLinePoints +{ + uno::Sequence< double > P0; + uno::Sequence< double > P1; + uno::Sequence< double > P2; + + GridLinePoints( const uno::Sequence< double >& rMinEdgeSeq, const uno::Sequence< double >& rMaxEdgeSeq ); + void update( double fScaledTickValue ); +}; + +GridLinePoints::GridLinePoints( const uno::Sequence< double >& rMinEdgeSeq + , const uno::Sequence< double >& rMaxEdgeSeq ) +{ + P0.realloc(3); + P0[0]=rMinEdgeSeq[0]; + P0[1]=rMinEdgeSeq[1]; + P0[2]=rMaxEdgeSeq[2]; + + P1.realloc(3); + P1[0]=rMinEdgeSeq[0]; + P1[1]=rMaxEdgeSeq[1]; + P1[2]=rMinEdgeSeq[2]; + + P2.realloc(3); + P2[0]=rMaxEdgeSeq[0]; + P2[1]=rMaxEdgeSeq[1]; + P2[2]=rMinEdgeSeq[2]; +} + +void GridLinePoints::update( double fScaledTickValue ) +{ + P0[1] = P1[1] = P2[1] = fScaledTickValue; +} + +void addLine3D( drawing::PolyPolygonShape3D& rPoints, sal_Int32 nIndex + , const GridLinePoints& rBasePoints + , const uno::Reference< XTransformation > & xTransformation ) +{ + drawing::Position3D aPoint = SequenceToPosition3D( xTransformation->transform( rBasePoints.P0 ) ); + AddPointToPoly( rPoints, aPoint, nIndex ); + aPoint = SequenceToPosition3D( xTransformation->transform( rBasePoints.P1 ) ); + AddPointToPoly( rPoints, aPoint, nIndex ); + aPoint = SequenceToPosition3D( xTransformation->transform( rBasePoints.P2 ) ); + AddPointToPoly( rPoints, aPoint, nIndex ); +} + +void SAL_CALL VCartesianGrid::createShapes() +{ + if( !m_xMeter.is()) + return; + uno::Reference< beans::XPropertySet > xGridProps( m_xMeter, uno::UNO_QUERY ); + if(!xGridProps.is()) + return; + //somehow equal to axis tickmarks + + //----------------------------------------- + //create named group shape + uno::Reference< XIdentifiable > xIdent( m_xMeter, uno::UNO_QUERY ); + if( ! xIdent.is()) + return; + + uno::Reference< drawing::XShapes > xGroupShape_Shapes( + this->createGroupShape( m_xLogicTarget + , ObjectIdentifier::createClassifiedIdentifier( + OBJECTTYPE_GRID, xIdent->getIdentifier() ) + ) ); + + //----------------------------------------- + + sal_Int32 nDimensionIndex = m_xMeter->getRepresentedDimension(); + ::std::vector<VLineProperties> aLinePropertiesList; + fillLinePropertiesFromGridModel( aLinePropertiesList, xGridProps ); + + //----------------------------------------- + //create all scaled tickmark values + std::auto_ptr< TickmarkHelper > apTickmarkHelper( this->createTickmarkHelper() ); + TickmarkHelper& aTickmarkHelper = *apTickmarkHelper.get(); + ::std::vector< ::std::vector< TickInfo > > aAllTickInfos; + aTickmarkHelper.getAllTicks( aAllTickInfos ); + + //----------------------------------------- + //create tick mark line shapes + ::std::vector< ::std::vector< TickInfo > >::iterator aDepthIter = aAllTickInfos.begin(); + const ::std::vector< ::std::vector< TickInfo > >::const_iterator aDepthEnd = aAllTickInfos.end(); + + if(aDepthIter == aDepthEnd)//no tickmarks at all + return; + + if(2==m_nDimension) + { + uno::Sequence< double > aMinEdgeSeq, aMaxEdgeSeq; + m_pPosHelper->getScreenValuesForMinimum( aMinEdgeSeq ); + m_pPosHelper->getScreenValuesForMaximum( aMaxEdgeSeq ); + sal_Int32 nOrthogonalDimensionIndex = nDimensionIndex==1 ? 0 : 1; + sal_Int32 nOrthogonalScreenPositionStart=static_cast<sal_Int32>(aMinEdgeSeq[nOrthogonalDimensionIndex]); + sal_Int32 nOrthogonalScreenPositionEnd =static_cast<sal_Int32>(aMaxEdgeSeq[nOrthogonalDimensionIndex]); + + drawing::PointSequenceSequence aHandlesPoints(1); + + sal_Int32 nLinePropertiesCount = aLinePropertiesList.size(); + for( sal_Int32 nDepth=0 + ; aDepthIter != aDepthEnd && nDepth < nLinePropertiesCount + ; aDepthIter++, nDepth++ ) + { + sal_Int32 nPointCount = (*aDepthIter).size(); + drawing::PointSequenceSequence aPoints(nPointCount); + + ::std::vector< TickInfo >::const_iterator aTickIter = (*aDepthIter).begin(); + const ::std::vector< TickInfo >::const_iterator aTickEnd = (*aDepthIter).end(); + sal_Int32 nRealPointCount = 0; + for( ; aTickIter != aTickEnd; aTickIter++ ) + { + if( !(*aTickIter).bPaintIt ) + continue; + addLine2D( aPoints, nRealPointCount, 1==nDimensionIndex, (*aTickIter).nScreenTickValue + , nOrthogonalScreenPositionStart, nOrthogonalScreenPositionEnd ); + nRealPointCount++; + } + aPoints.realloc(nRealPointCount); + m_pShapeFactory->createLine2D( xGroupShape_Shapes, aPoints, aLinePropertiesList[nDepth] ); + + //prepare polygon for handle shape: + sal_Int32 nOldHandleCount = aHandlesPoints[0].getLength(); + aHandlesPoints[0].realloc(nOldHandleCount+nRealPointCount); + for( sal_Int32 nN = 0; nN<nRealPointCount; nN++) + aHandlesPoints[0][nOldHandleCount+nN] = aPoints[nN][1]; + } + + //create handle shape: + VLineProperties aHandleLineProperties; + aHandleLineProperties.LineStyle = uno::makeAny( drawing::LineStyle_NONE ); + uno::Reference< drawing::XShape > xHandleShape = + m_pShapeFactory->createLine2D( xGroupShape_Shapes, aHandlesPoints, aHandleLineProperties ); + m_pShapeFactory->setShapeName( xHandleShape, C2U("HandlesOnly") ); + } + //----------------------------------------- + else //if(2!=m_nDimension) + { + sal_Int32 nLinePropertiesCount = aLinePropertiesList.size(); + for( sal_Int32 nDepth=0 + ; aDepthIter != aDepthEnd && nDepth < nLinePropertiesCount + ; aDepthIter++, nDepth++ ) + { + sal_Int32 nPointCount = (*aDepthIter).size(); + drawing::PolyPolygonShape3D aPoints; + aPoints.SequenceX.realloc(nPointCount); + aPoints.SequenceY.realloc(nPointCount); + aPoints.SequenceZ.realloc(nPointCount); + uno::Sequence< double > aLogicMinEdge, aLogicMaxEdge; + m_pPosHelper->getLogicMinimum( aLogicMinEdge ); + m_pPosHelper->getLogicMaximum( aLogicMaxEdge ); + + if(!m_pPosHelper->isMathematicalOrientationX()) + { + double fHelp = aLogicMinEdge[0]; + aLogicMinEdge[0] = aLogicMaxEdge[0]; + aLogicMaxEdge[0] = fHelp; + } + if(!m_pPosHelper->isMathematicalOrientationY()) + { + double fHelp = aLogicMinEdge[1]; + aLogicMinEdge[1] = aLogicMaxEdge[1]; + aLogicMaxEdge[1] = fHelp; + } + if(m_pPosHelper->isMathematicalOrientationZ())//z axis in draw is reverse to mathematical + { + double fHelp = aLogicMinEdge[2]; + aLogicMinEdge[2] = aLogicMaxEdge[2]; + aLogicMaxEdge[2] = fHelp; + } + + GridLinePoints aGridLinePoints( aLogicMinEdge, aLogicMaxEdge ); + + ::std::vector< TickInfo >::const_iterator aTickIter = (*aDepthIter).begin(); + const ::std::vector< TickInfo >::const_iterator aTickEnd = (*aDepthIter).end(); + sal_Int32 nRealPointCount = 0; + for( ; aTickIter != aTickEnd; aTickIter++ ) + { + if( !(*aTickIter).bPaintIt ) + continue; + + aGridLinePoints.update( (*aTickIter).fScaledTickValue ); + addLine3D( aPoints, nRealPointCount, aGridLinePoints, m_pPosHelper->getTransformationLogicToScene() ); + nRealPointCount+=3; + } + aPoints.SequenceX.realloc(nRealPointCount); + aPoints.SequenceY.realloc(nRealPointCount); + aPoints.SequenceZ.realloc(nRealPointCount); + m_pShapeFactory->createLine3D( xGroupShape_Shapes, aPoints, aLinePropertiesList[nDepth] ); + } + } +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/view/axes/VCartesianGrid.hxx b/chart2/source/view/axes/VCartesianGrid.hxx new file mode 100644 index 000000000000..010a30a4f2c0 --- /dev/null +++ b/chart2/source/view/axes/VCartesianGrid.hxx @@ -0,0 +1,100 @@ +/************************************************************************* + * + * $RCSfile: VCartesianGrid.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: iha $ $Date: 2004-01-17 13:09:57 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2003 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef _CHART2_VCARTESIANGRID_HXX +#define _CHART2_VCARTESIANGRID_HXX + +#include "VMeterBase.hxx" +#include "VLineProperties.hxx" + +#ifndef _DRAFTS_COM_SUN_STAR_CHART2_XGRID_HPP_ +#include <drafts/com/sun/star/chart2/XGrid.hpp> +#endif + +//............................................................................. +namespace chart +{ +//............................................................................. + +//----------------------------------------------------------------------------- +/** +*/ + +class VCartesianGrid : public VMeterBase +{ +//------------------------------------------------------------------------- +// public methods +//------------------------------------------------------------------------- +public: + VCartesianGrid( const ::com::sun::star::uno::Reference< + ::drafts::com::sun::star::chart2::XGrid >& xGrid + , sal_Int32 nDimensionCount ); + virtual ~VCartesianGrid(); + + virtual void SAL_CALL createShapes(); + + static void fillLinePropertiesFromGridModel( ::std::vector<VLineProperties>& rLinePropertiesList + , ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xProps ); +}; + +//............................................................................. +} //namespace chart +//............................................................................. +#endif diff --git a/chart2/source/view/axes/VCoordinateSystem.cxx b/chart2/source/view/axes/VCoordinateSystem.cxx index 16a5af0e9dd0..6b48d8397c28 100644 --- a/chart2/source/view/axes/VCoordinateSystem.cxx +++ b/chart2/source/view/axes/VCoordinateSystem.cxx @@ -2,9 +2,9 @@ * * $RCSfile: VCoordinateSystem.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: iha $ $Date: 2003-11-17 19:57:47 $ + * last change: $Author: iha $ $Date: 2004-01-17 13:09:57 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -59,9 +59,17 @@ * ************************************************************************/ #include "VCoordinateSystem.hxx" +#include "VCartesianCoordinateSystem.hxx" +#include "VPolarCoordinateSystem.hxx" #include "ScaleAutomatism.hxx" #include "VSeriesPlotter.hxx" -#include "VGrid.hxx" +#include "ShapeFactory.hxx" +#include "servicenames_coosystems.hxx" + +// header for define DBG_ASSERT +#ifndef _TOOLS_DEBUG_HXX +#include <tools/debug.hxx> +#endif //............................................................................. namespace chart @@ -70,6 +78,23 @@ namespace chart using namespace ::com::sun::star; using namespace ::drafts::com::sun::star::chart2; +//static +VCoordinateSystem* VCoordinateSystem::createCoordinateSystem( const uno::Reference< + XBoundedCoordinateSystem >& xCooSysModel ) +{ + rtl::OUString aViewServiceName = xCooSysModel->getViewServiceName(); + + //@todo: in future the coordinatesystems should be instanciated via service factory + VCoordinateSystem* pRet=NULL; + if( aViewServiceName.equals( CHART2_COOSYSTEM_CARTESIAN_VIEW_SERVICE_NAME ) ) + pRet = new VCartesianCoordinateSystem(xCooSysModel); + else if( aViewServiceName.equals( CHART2_COOSYSTEM_POLAR_VIEW_SERVICE_NAME ) ) + pRet = new VPolarCoordinateSystem(xCooSysModel); + if(!pRet) + pRet = new VCoordinateSystem(xCooSysModel); + return pRet; +} + VCoordinateSystem::VCoordinateSystem( const uno::Reference< XBoundedCoordinateSystem >& xCooSys ) : m_xCooSysModel(xCooSys) , m_xAxis0(NULL) @@ -80,11 +105,42 @@ VCoordinateSystem::VCoordinateSystem( const uno::Reference< XBoundedCoordinateSy , m_xGridList2() , m_aExplicitScales(3) , m_aExplicitIncrements(3) + , m_xLogicTargetForGrids(0) + , m_xLogicTargetForAxes(0) + , m_xFinalTarget(0) + , m_xShapeFactory(0) + , m_aMatrixSceneToScreen() { } VCoordinateSystem::~VCoordinateSystem() { +} + +void SAL_CALL VCoordinateSystem::initPlottingTargets( const uno::Reference< drawing::XShapes >& xLogicTarget + , const uno::Reference< drawing::XShapes >& xFinalTarget + , const uno::Reference< lang::XMultiServiceFactory >& xShapeFactory ) + throw (uno::RuntimeException) +{ + DBG_ASSERT(xLogicTarget.is()&&xFinalTarget.is()&&xShapeFactory.is(),"no proper initialization parameters"); + //is only allowed to be called once + sal_Int32 nDimensionCount = m_xCooSysModel->getDimension(); + //create group shape for grids first thus axes are always painted above grids + ShapeFactory aShapeFactory(xShapeFactory); + if(nDimensionCount==2) + { + //create and add to target + m_xLogicTargetForGrids = aShapeFactory.createGroup2D( xLogicTarget ); + m_xLogicTargetForAxes = aShapeFactory.createGroup2D( xLogicTarget ); + } + else + { + //create and added to target + m_xLogicTargetForGrids = aShapeFactory.createGroup3D( xLogicTarget ); + m_xLogicTargetForAxes = aShapeFactory.createGroup3D( xLogicTarget ); + } + m_xFinalTarget = xFinalTarget; + m_xShapeFactory = xShapeFactory; } void VCoordinateSystem::setOrigin( double* fCoordinateOrigin ) @@ -94,6 +150,12 @@ void VCoordinateSystem::setOrigin( double* fCoordinateOrigin ) m_fCoordinateOrigin[2]=fCoordinateOrigin[2]; } +void VCoordinateSystem::setTransformationSceneToScreen( + const drawing::HomogenMatrix& rMatrix ) +{ + m_aMatrixSceneToScreen = rMatrix; +} + uno::Reference< XBoundedCoordinateSystem > VCoordinateSystem::getModel() const { return m_xCooSysModel; @@ -133,30 +195,6 @@ void VCoordinateSystem::addGrid( const uno::Reference< XGrid >& xGrid ) rGridList[rGridList.getLength()-1] = xGrid; } -void VCoordinateSystem::createGridShapes( - const uno::Reference< lang::XMultiServiceFactory>& xShapeFactory - , const uno::Reference< drawing::XShapes >& xTarget - , const drawing::HomogenMatrix& rHM_SceneToScreen ) -{ - sal_Int32 nDimensionCount = m_xCooSysModel->getDimension(); - for( sal_Int32 nDim=0; nDim<3; nDim++) - { - uno::Sequence< uno::Reference< XGrid > >& rGridList - = getGridListByDimension( nDim ); - for( sal_Int32 nN=0; nN<rGridList.getLength(); nN++ ) - { - VGrid aGrid(rGridList[nN],nDimensionCount); - aGrid.setMeterData( m_aExplicitScales[nDim], m_aExplicitIncrements[nDim] ); - - aGrid.init(xTarget,xTarget,xShapeFactory); - if(2==nDimensionCount) - aGrid.setTransformationSceneToScreen( rHM_SceneToScreen ); - aGrid.setScales( m_aExplicitScales ); - aGrid.createShapes(); - } - } -} - uno::Reference< XAxis > VCoordinateSystem::getAxisByDimension( sal_Int32 nDim ) const { uno::Reference< XAxis > xAxis(NULL); @@ -201,22 +239,31 @@ void VCoordinateSystem::doAutoScale( MinimumAndMaximumSupplier* pMinMaxSupplier } if(0==nDim) { - aScaleAutomatism.m_fValueMinimum = pMinMaxSupplier->getMinimumX(); - aScaleAutomatism.m_fValueMaximum = pMinMaxSupplier->getMaximumX(); + if(pMinMaxSupplier) + { + aScaleAutomatism.m_fValueMinimum = pMinMaxSupplier->getMinimumX(); + aScaleAutomatism.m_fValueMaximum = pMinMaxSupplier->getMaximumX(); + } } else if(1==nDim) { - const ExplicitScaleData& rScale = m_aExplicitScales[0]; - //@todo iterate through all xSlots which belong to coordinate system dimension in this plotter - //and iterate through all plotter for this coordinate system dimension - sal_Int32 nXSlotIndex = 0; - aScaleAutomatism.m_fValueMinimum = pMinMaxSupplier->getMinimumYInRange(rScale.Minimum,rScale.Maximum); - aScaleAutomatism.m_fValueMaximum = pMinMaxSupplier->getMaximumYInRange(rScale.Minimum,rScale.Maximum); + if(pMinMaxSupplier) + { + const ExplicitScaleData& rScale = m_aExplicitScales[0]; + //@todo iterate through all xSlots which belong to coordinate system dimension in this plotter + //and iterate through all plotter for this coordinate system dimension + sal_Int32 nXSlotIndex = 0; + aScaleAutomatism.m_fValueMinimum = pMinMaxSupplier->getMinimumYInRange(rScale.Minimum,rScale.Maximum); + aScaleAutomatism.m_fValueMaximum = pMinMaxSupplier->getMaximumYInRange(rScale.Minimum,rScale.Maximum); + } } else if(2==nDim) { - aScaleAutomatism.m_fValueMinimum = pMinMaxSupplier->getMinimumZ(); - aScaleAutomatism.m_fValueMaximum = pMinMaxSupplier->getMaximumZ(); + if(pMinMaxSupplier) + { + aScaleAutomatism.m_fValueMinimum = pMinMaxSupplier->getMinimumZ(); + aScaleAutomatism.m_fValueMaximum = pMinMaxSupplier->getMaximumZ(); + } } aScaleAutomatism.calculateExplicitScaleAndIncrement( m_aExplicitScales[nDim], m_aExplicitIncrements[nDim] ); @@ -225,6 +272,13 @@ void VCoordinateSystem::doAutoScale( MinimumAndMaximumSupplier* pMinMaxSupplier setExplicitScaleToDefault(m_aExplicitScales[2]); } +void VCoordinateSystem::createGridShapes() +{ +} +void VCoordinateSystem::createAxesShapes( const ::com::sun::star::awt::Size& rReferenceSize, NumberFormatterWrapper* pNumberFormatterWrapper ) +{ +} + //............................................................................. } //namespace chart //............................................................................. diff --git a/chart2/source/view/axes/VPolarAxis.cxx b/chart2/source/view/axes/VPolarAxis.cxx new file mode 100644 index 000000000000..833a61518126 --- /dev/null +++ b/chart2/source/view/axes/VPolarAxis.cxx @@ -0,0 +1,360 @@ +/************************************************************************* + * + * $RCSfile: VPolarAxis.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: iha $ $Date: 2004-01-17 13:09:58 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2003 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#include "VPolarAxis.hxx" +#include "VPolarGrid.hxx" +#include "PlottingPositionHelper.hxx" +#include "ShapeFactory.hxx" +#include "CommonConverters.hxx" +#include "macros.hxx" +#include "ViewDefines.hxx" +#include "TickmarkHelper.hxx" +#include "PropertyMapper.hxx" +#include "chartview/NumberFormatterWrapper.hxx" +#include "chartview/ObjectIdentifier.hxx" +#include "PolarLabelPositionHelper.hxx" + +#ifndef INCLUDED_RTL_MATH_HXX +#include <rtl/math.hxx> +#endif +#ifndef _TOOLS_COLOR_HXX +#include <tools/color.hxx> +#endif +#ifndef _TOOLS_DEBUG_HXX +#include <tools/debug.hxx> +#endif +#ifndef _COM_SUN_STAR_STYLE_PARAGRAPHADJUST_HPP_ +#include <com/sun/star/style/ParagraphAdjust.hpp> +#endif +#ifndef _COM_SUN_STAR_TEXT_XTEXT_HPP_ +#include <com/sun/star/text/XText.hpp> +#endif +#ifndef _DRAFTS_COM_SUN_STAR_CHART2_XIDENTIFIABLE_HPP_ +#include <drafts/com/sun/star/chart2/XIdentifiable.hpp> +#endif + +#ifndef _SVX_UNOPRNMS_HXX +#include <svx/unoprnms.hxx> +#endif + +#include <algorithm> +#include <memory> + +//............................................................................. +namespace chart +{ +//............................................................................. +using namespace ::com::sun::star; +using namespace ::drafts::com::sun::star::chart2; +using namespace ::rtl::math; + +VPolarAxis::VPolarAxis( const AxisProperties& rAxisProperties + , NumberFormatterWrapper* pNumberFormatterWrapper + , sal_Int32 nDimensionCount ) + : VMeterBase( uno::Reference<XMeter>::query(rAxisProperties.m_xAxisModel) + , nDimensionCount ) + , m_aAxisProperties( rAxisProperties ) + , m_pNumberFormatterWrapper( pNumberFormatterWrapper ) + , m_pPosHelper( new PolarPlottingPositionHelper(false) ) +{ + PlotterBase::m_pPosHelper = m_pPosHelper; +} + +VPolarAxis::~VPolarAxis() +{ + delete m_pPosHelper; + m_pPosHelper = NULL; +} + +bool createTextShapes_ForAngleAxis( const uno::Reference< lang::XMultiServiceFactory >& xShapeFactory + , const uno::Reference< drawing::XShapes >& xTarget + , ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos + , const ExplicitIncrementData& rIncrement + , AxisLabelProperties& rAxisLabelProperties + , const AxisProperties& rAxisProperties + , PolarPlottingPositionHelper* pPosHelper + , double fLogicRadius + , double fLogicZ + , const FixedNumberFormatter& rFixedNumberFormatter ) +{ + sal_Int32 nDimensionCount = 2; + ShapeFactory aShapeFactory(xShapeFactory); + + //------------------------------------------------ + //prepare text properties for multipropertyset-interface of shape + tNameSequence aPropNames; + tAnySequence aPropValues; + + uno::Reference< beans::XPropertySet > xProps( rAxisProperties.m_xAxisModel, uno::UNO_QUERY ); + PropertyMapper::getTextLabelMultiPropertyLists( xProps, aPropNames, aPropValues, false ); + LabelPositionHelper::doDynamicFontResize( aPropValues, aPropNames, xProps + , rAxisProperties.m_aReferenceSize ); + + uno::Any* pColorAny = PropertyMapper::getValuePointer(aPropValues,aPropNames,C2U("CharColor")); + sal_Int32 nColor = Color( COL_AUTO ).GetColor(); + if(pColorAny) + *pColorAny >>= nColor; + //------------------------------------------------ + + //TickInfo* pLastVisibleNeighbourTickInfo = NULL; + sal_Int32 nTick = 0; + TickIter aIter( rAllTickInfos, rIncrement, 0, 0 ); + for( TickInfo* pTickInfo = aIter.firstInfo() + ; pTickInfo + ; pTickInfo = aIter.nextInfo(), nTick++ ) + { + //don't create labels which does not fit into the rythm + if( nTick%rAxisLabelProperties.nRhythm != 0) + continue; + + //don't create labels for invisible ticks + if( !pTickInfo->bPaintIt ) + continue; + + //if NO OVERLAP -> don't create labels where the + //anchor position is the same as for the last label + //@todo + /* + if( pLastVisibleNeighbourTickInfo && !rAxisLabelProperties.bOverlapAllowed ) + { + if( lcl_doesOverlap( pLastVisibleNeighbourTickInfo->xTextShape, pTickInfo->nScreenTickValue, bOverlapCheckDirectionIsY ) ) + { + if( rAxisLabelProperties.bRhythmIsFix ) + continue; + rAxisLabelProperties.nRhythm++; + TickIter aRemoveIter( rAllTickInfos, rIncrement, 0, 0 ); + removeShapesAtWrongRythm( aRemoveIter, rAxisLabelProperties.nRhythm, nTick, xTarget ); + return false; + } + } + */ + + if(!pTickInfo->xTextShape.is()) + { + //create single label + bool bHasExtraColor=false; + sal_Int32 nExtraColor=0; + rtl::OUString aLabel = rFixedNumberFormatter.getFormattedString( pTickInfo->fUnscaledTickValue, nExtraColor, bHasExtraColor ); + if(pColorAny) + *pColorAny = uno::makeAny(bHasExtraColor?nExtraColor:nColor); + + double fLogicAngle = pTickInfo->fUnscaledTickValue; + + LabelAlignment eLabelAlignment(LABEL_ALIGN_CENTER); + PolarLabelPositionHelper aPolarLabelPositionHelper(pPosHelper,nDimensionCount,xTarget,&aShapeFactory); + awt::Point aAnchorScreenPosition2D( aPolarLabelPositionHelper.getLabelScreenPositionAndAlignment( + eLabelAlignment, true, fLogicAngle, fLogicAngle, fLogicRadius, fLogicRadius, fLogicZ )); + LabelPositionHelper::changeTextAdjustment( aPropValues, aPropNames, eLabelAlignment ); + + double fRotationAnglePi = rAxisLabelProperties.fRotationAngleDegree*F_PI/180.0; + uno::Any aATransformation = ShapeFactory::makeTransformation( aAnchorScreenPosition2D, fRotationAnglePi ); + rtl::OUString aStackedLabel = ShapeFactory::getStackedString( aLabel, rAxisLabelProperties.bStackCharacters ); + + pTickInfo->xTextShape = aShapeFactory.createText( xTarget, aStackedLabel, aPropNames, aPropValues, aATransformation ); + } + + //if NO OVERLAP -> remove overlapping shapes + //@todo + /* + if( pLastVisibleNeighbourTickInfo && !rAxisLabelProperties.bOverlapAllowed ) + { + if( doesOverlap( pLastVisibleNeighbourTickInfo->xTextShape, pTickInfo->xTextShape, bOverlapCheckDirectionIsY ) ) + { + if( rAxisLabelProperties.bRhythmIsFix ) + { + xTarget->remove(pTickInfo->xTextShape); + pTickInfo->xTextShape = NULL; + continue; + } + rAxisLabelProperties.nRhythm++; + TickIter aRemoveIter( rAllTickInfos, rIncrement, 0, 0 ); + removeShapesAtWrongRythm( aRemoveIter, rAxisLabelProperties.nRhythm, nTick, xTarget ); + return false; + } + } + */ + //pLastVisibleNeighbourTickInfo = pTickInfo; + } + return true; +} + +void VPolarAxis::create2DAngleAxis( const uno::Reference< drawing::XShapes >& xTarget, ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) +{ + double fLogicRadius = m_pPosHelper->getOuterLogicRadius(); + double fLogicZ = -0.5;//as defined + + //----------------------------------------- + //create axis main lines + drawing::PointSequenceSequence aPoints(1); + VPolarGrid::createLinePointSequence_ForAngleAxis( aPoints, rAllTickInfos, m_aIncrement, m_aScale, m_pPosHelper, fLogicRadius, fLogicZ ); + uno::Reference< drawing::XShape > xShape = m_pShapeFactory->createLine2D( + xTarget, aPoints, m_aAxisProperties.m_aLineProperties ); + //because of this name this line will be used for marking the axis + m_pShapeFactory->setShapeName( xShape, C2U("MarkHandles") ); + + //----------------------------------------- + //create labels + AxisLabelProperties aAxisLabelProperties; + aAxisLabelProperties.init(m_aAxisProperties.m_xAxisModel); + if( aAxisLabelProperties.bDisplayLabels ) + { + FixedNumberFormatter aFixedNumberFormatter( + m_pNumberFormatterWrapper, aAxisLabelProperties.aNumberFormat ); + + while( !createTextShapes_ForAngleAxis( m_xShapeFactory, xTarget, rAllTickInfos + , m_aIncrement, aAxisLabelProperties, m_aAxisProperties, m_pPosHelper + , fLogicRadius, fLogicZ + , aFixedNumberFormatter + ) ) + { + }; + + //no staggering for polar angle axis + } +} + +void VPolarAxis::create2DRadiusAxis( const uno::Reference< drawing::XShapes >& xTarget, ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) +{ + /* + sal_Int32 nTickmarkPropertiesCount = m_aAxisProperties.m_aTickmarkPropertiesList.size(); + for( sal_Int32 nDepth=0 + ; aDepthIter != aDepthEnd && nDepth < nTickmarkPropertiesCount + ; aDepthIter++, nDepth++ ) + { + const TickmarkProperties& rTickmarkProperties = m_aAxisProperties.m_aTickmarkPropertiesList[nDepth]; + + sal_Int32 nPointCount = (*aDepthIter).size(); + drawing::PointSequenceSequence aPoints(nPointCount); + + ::std::vector< TickInfo >::const_iterator aTickIter = (*aDepthIter).begin(); + const ::std::vector< TickInfo >::const_iterator aTickEnd = (*aDepthIter).end(); + sal_Int32 nN = 0; + for( ; aTickIter != aTickEnd; aTickIter++ ) + { + if( !(*aTickIter).bPaintIt ) + continue; + //addLine( aPoints, nN + // , (*aTickIter).nScreenTickValue, nMainLineScreenPosition + // , rTickmarkProperties, bIsRadiusAxis); + + nN++; + } + aPoints.realloc(nN); + m_pShapeFactory->createLine2D( xGroupShape_Shapes, aPoints + , rTickmarkProperties.aLineProperties ); + } + + //----------------------------------------- + //create all scaled tickmark values + std::auto_ptr< TickmarkHelper > apTickmarkHelper( this->createTickmarkHelper() ); + ::std::vector< ::std::vector< TickInfo > > aAllTickInfos; + apTickmarkHelper->getAllTicks( aAllTickInfos ); + + //----------------------------------------- + //create tick mark line shapes + ::std::vector< ::std::vector< TickInfo > >::iterator aDepthIter = aAllTickInfos.begin(); + const ::std::vector< ::std::vector< TickInfo > >::const_iterator aDepthEnd = aAllTickInfos.end(); + + if(aDepthIter == aDepthEnd)//no tickmarks at all + return; + */ +} + +void SAL_CALL VPolarAxis::createShapes() +{ + DBG_ASSERT(m_pShapeFactory&&m_xLogicTarget.is()&&m_xFinalTarget.is(),"Axis is not proper initialized"); + if(!(m_pShapeFactory&&m_xLogicTarget.is()&&m_xFinalTarget.is())) + return; + + m_aAxisProperties.init(); + + //----------------------------------------- + //create named group shape + uno::Reference< XIdentifiable > xIdent( m_aAxisProperties.m_xAxisModel, uno::UNO_QUERY ); + DBG_ASSERT( xIdent.is(), "Axis should support XIdentifiable" ); + if( ! xIdent.is()) + return; + uno::Reference< drawing::XShapes > xGroupShape_Shapes( + m_pShapeFactory->createGroup2D( m_xLogicTarget + , ObjectIdentifier::createClassifiedIdentifier( + OBJECTTYPE_AXIS, xIdent->getIdentifier() ) + ) ); + + //----------------------------------------- + //create all scaled tickmark values + std::auto_ptr< TickmarkHelper > apTickmarkHelper( this->createTickmarkHelper() ); + ::std::vector< ::std::vector< TickInfo > > aAllTickInfos; + apTickmarkHelper->getAllTicks( aAllTickInfos ); + + //----------------------------------------- + //create different axes + if(2==m_nDimension) + { + sal_Int32 nDimensionIndex = m_xMeter->getRepresentedDimension(); + if(nDimensionIndex==1) + this->create2DRadiusAxis( xGroupShape_Shapes, aAllTickInfos ); + else + this->create2DAngleAxis( xGroupShape_Shapes, aAllTickInfos ); + } +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/view/axes/VPolarAxis.hxx b/chart2/source/view/axes/VPolarAxis.hxx new file mode 100644 index 000000000000..1ee108bf3c80 --- /dev/null +++ b/chart2/source/view/axes/VPolarAxis.hxx @@ -0,0 +1,103 @@ +/************************************************************************* + * + * $RCSfile: VPolarAxis.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: iha $ $Date: 2004-01-17 13:09:58 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2003 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef _CHART2_VPOLARAXIS_HXX +#define _CHART2_VPOLARAXIS_HXX + +#include "TickmarkHelper.hxx" +#include "VMeterBase.hxx" +#include "VAxisProperties.hxx" + +//............................................................................. +namespace chart +{ +//............................................................................. + +//----------------------------------------------------------------------------- +/** +*/ + +class NumberFormatterWrapper; +class PolarPlottingPositionHelper; + +class VPolarAxis : public VMeterBase +{ +public: + VPolarAxis( const AxisProperties& rAxisProperties + , NumberFormatterWrapper* pNumberFormatterWrapper + , sal_Int32 nDimensionCount=2 ); + virtual ~VPolarAxis(); + + virtual void SAL_CALL createShapes(); + +private: //methods + void create2DAngleAxis( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget, ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ); + void create2DRadiusAxis( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget, ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ); + +private: //member + AxisProperties m_aAxisProperties; + NumberFormatterWrapper* m_pNumberFormatterWrapper; + PolarPlottingPositionHelper* m_pPosHelper; +}; + +//............................................................................. +} //namespace chart +//............................................................................. +#endif diff --git a/chart2/source/view/axes/VPolarCoordinateSystem.cxx b/chart2/source/view/axes/VPolarCoordinateSystem.cxx new file mode 100644 index 000000000000..d2f5d4e08610 --- /dev/null +++ b/chart2/source/view/axes/VPolarCoordinateSystem.cxx @@ -0,0 +1,154 @@ +/************************************************************************* + * + * $RCSfile: VPolarCoordinateSystem.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: iha $ $Date: 2004-01-17 13:09:59 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2003 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#include "VPolarCoordinateSystem.hxx" +#include "VPolarGrid.hxx" +#include "VPolarAxis.hxx" + +//............................................................................. +namespace chart +{ +//............................................................................. +using namespace ::com::sun::star; +using namespace ::drafts::com::sun::star::chart2; + +VPolarCoordinateSystem::VPolarCoordinateSystem( const uno::Reference< XBoundedCoordinateSystem >& xCooSys ) + : VCoordinateSystem(xCooSys) +{ +} + +VPolarCoordinateSystem::~VPolarCoordinateSystem() +{ +} + +void VPolarCoordinateSystem::createGridShapes() +{ + sal_Int32 nDimensionCount = m_xCooSysModel->getDimension(); + for( sal_Int32 nDim=0; nDim<3; nDim++) + { + uno::Sequence< uno::Reference< XGrid > >& rGridList + = getGridListByDimension( nDim ); + for( sal_Int32 nN=0; nN<rGridList.getLength(); nN++ ) + { + VPolarGrid aGrid(rGridList[nN],nDimensionCount); + aGrid.setIncrements( m_aExplicitIncrements ); + + aGrid.init(m_xLogicTargetForGrids,m_xFinalTarget,m_xShapeFactory); + if(2==nDimensionCount) + aGrid.setTransformationSceneToScreen( m_aMatrixSceneToScreen ); + aGrid.setScales( m_aExplicitScales ); + aGrid.createShapes(); + } + } +} + +void VPolarCoordinateSystem::createAxesShapes( const awt::Size& rReferenceSize, NumberFormatterWrapper* pNumberFormatterWrapper ) +{ + sal_Int32 nDimensionCount = m_xCooSysModel->getDimension(); + double fCoordinateOrigin[3] = { 0.0, 0.0, 0.0 }; + for( sal_Int32 nDim = 0; nDim < 3; nDim++ ) + fCoordinateOrigin[nDim] = this->getOriginByDimension( nDim ); + //create angle axis (dimension index 0) + nDim = 0; + { + uno::Reference< XAxis > xAxis = this->getAxisByDimension(0); + AxisProperties aAxisProperties; + aAxisProperties.m_xAxisModel = xAxis; + aAxisProperties.m_pfExrtaLinePositionAtOtherAxis = + new double(nDim==1?fCoordinateOrigin[0]:fCoordinateOrigin[1]); + aAxisProperties.m_aReferenceSize = rReferenceSize; + //------------------- + VPolarAxis aAxis(aAxisProperties,pNumberFormatterWrapper); + aAxis.setMeterData( m_aExplicitScales[nDim], m_aExplicitIncrements[nDim] ); + aAxis.init(m_xLogicTargetForAxes,m_xFinalTarget,m_xShapeFactory); + if(2==nDimensionCount) + aAxis.setTransformationSceneToScreen( m_aMatrixSceneToScreen ); + aAxis.setScales( m_aExplicitScales ); + aAxis.createShapes(); + } + + /* + for( nDim = 0; nDim < 3; nDim++ ) + { + uno::Reference< XAxis > xAxis = this->getAxisByDimension(nDim); + if(xAxis.is() + &&2==nDimensionCount) //@todo remove this restriction if 3D axes are available + { + AxisProperties aAxisProperties; + aAxisProperties.m_xAxisModel = xAxis; + aAxisProperties.m_pfExrtaLinePositionAtOtherAxis = + new double(nDim==1?fCoordinateOrigin[0]:fCoordinateOrigin[1]); + aAxisProperties.m_aReferenceSize = rReferenceSize; + //------------------- + VAxis aAxis(aAxisProperties,pNumberFormatterWrapper); + aAxis.setMeterData( m_aExplicitScales[nDim], m_aExplicitIncrements[nDim] ); + aAxis.init(m_xLogicTargetForAxes,m_xFinalTarget,m_xShapeFactory); + if(2==nDimensionCount) + aAxis.setTransformationSceneToScreen( m_aMatrixSceneToScreen ); + aAxis.setScales( m_aExplicitScales ); + aAxis.createShapes(); + } + } + */ +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/view/axes/VPolarCoordinateSystem.hxx b/chart2/source/view/axes/VPolarCoordinateSystem.hxx new file mode 100644 index 000000000000..61ba559fad76 --- /dev/null +++ b/chart2/source/view/axes/VPolarCoordinateSystem.hxx @@ -0,0 +1,91 @@ +/************************************************************************* + * + * $RCSfile: VPolarCoordinateSystem.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: iha $ $Date: 2004-01-17 13:09:59 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2003 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef _CHART2_VPOLAR_COORDINATESYSTEM_HXX +#define _CHART2_VPOLAR_COORDINATESYSTEM_HXX + +#include "VCoordinateSystem.hxx" + +//............................................................................. +namespace chart +{ +//............................................................................. + +//----------------------------------------------------------------------------- +/** +*/ +class VPolarCoordinateSystem : public VCoordinateSystem +{ +public: + VPolarCoordinateSystem( const ::com::sun::star::uno::Reference< + ::drafts::com::sun::star::chart2::XBoundedCoordinateSystem >& xCooSys ); + virtual ~VPolarCoordinateSystem(); + + virtual void createGridShapes(); + virtual void createAxesShapes( const ::com::sun::star::awt::Size& rReferenceSize, NumberFormatterWrapper* pNumberFormatterWrapper ); + +private: + VPolarCoordinateSystem(); +}; + +//............................................................................. +} //namespace chart +//............................................................................. +#endif diff --git a/chart2/source/view/axes/VPolarGrid.cxx b/chart2/source/view/axes/VPolarGrid.cxx new file mode 100644 index 000000000000..ea0b104ca9a5 --- /dev/null +++ b/chart2/source/view/axes/VPolarGrid.cxx @@ -0,0 +1,303 @@ +/************************************************************************* + * + * $RCSfile: VPolarGrid.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: iha $ $Date: 2004-01-17 13:09:59 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2003 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#include "VPolarGrid.hxx" +#include "VCartesianGrid.hxx" +#include "TickmarkHelper.hxx" +#include "PlottingPositionHelper.hxx" +#include "ShapeFactory.hxx" +#include "chartview/ObjectIdentifier.hxx" +#include "macros.hxx" +#include "CommonConverters.hxx" + +#ifndef _DRAFTS_COM_SUN_STAR_CHART2_XIDENTIFIABLE_HPP_ +#include <drafts/com/sun/star/chart2/XIdentifiable.hpp> +#endif +#ifndef _COM_SUN_STAR_DRAWING_LINESTYLE_HPP_ +#include <com/sun/star/drawing/LineStyle.hpp> +#endif + +#include <vector> +#include <memory> + +//............................................................................. +namespace chart +{ +//............................................................................. +using namespace ::com::sun::star; +using namespace ::drafts::com::sun::star::chart2; + +VPolarGrid::VPolarGrid( const uno::Reference< XGrid >& xGrid, sal_Int32 nDimensionCount ) + : VMeterBase( uno::Reference<XMeter>::query(xGrid), nDimensionCount ) + , m_pPosHelper( new PolarPlottingPositionHelper(false) ) +{ + PlotterBase::m_pPosHelper = m_pPosHelper; +} + +VPolarGrid::~VPolarGrid() +{ + delete m_pPosHelper; + m_pPosHelper = NULL; +} + +void VPolarGrid::setIncrements( const uno::Sequence< ExplicitIncrementData >& rIncrements ) +{ + m_aIncrements = rIncrements; +} + +void VPolarGrid::getAllTickInfos( sal_Int32 nDimensionIndex, ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const +{ + TickmarkHelper_2D aTickmarkHelper( + m_pPosHelper->getScales()[nDimensionIndex], m_aIncrements[nDimensionIndex] + , m_aMatrixScreenToScene[nDimensionIndex][nDimensionIndex] + , m_aMatrixScreenToScene[nDimensionIndex][3] + ); + aTickmarkHelper.getAllTicks( rAllTickInfos ); +} + +//static +void VPolarGrid::createLinePointSequence_ForAngleAxis( + drawing::PointSequenceSequence& rPoints + , ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos + , const ExplicitIncrementData& rIncrement + , const ExplicitScaleData& rScale + , PolarPlottingPositionHelper* pPosHelper + , double fLogicRadius, double fLogicZ ) +{ + uno::Reference< XScaling > xInverseScaling( NULL ); + if( rScale.Scaling.is() ) + xInverseScaling = rScale.Scaling->getInverseScaling(); + + sal_Int32 nTick = 0; + TickIter aIter( rAllTickInfos, rIncrement, 0, 0 ); + for( TickInfo* pTickInfo = aIter.firstInfo() + ; pTickInfo + ; pTickInfo = aIter.nextInfo(), nTick++ ) + { + if(nTick>=rPoints[0].getLength()) + rPoints[0].realloc(rPoints.getLength()+30); + + pTickInfo->updateUnscaledValue( xInverseScaling ); + double fLogicAngle = pTickInfo->fUnscaledTickValue; + + drawing::Position3D aScenePosition3D( pPosHelper->transformLogicToScene( fLogicAngle, fLogicRadius, fLogicZ ) ); + rPoints[0][nTick].X = static_cast<sal_Int32>(aScenePosition3D.PositionX); + rPoints[0][nTick].Y = static_cast<sal_Int32>(aScenePosition3D.PositionY); + } + if(rPoints.getLength()>1) + { + rPoints[0].realloc(nTick+1); + rPoints[0][nTick].X = rPoints[0][0].X; + rPoints[0][nTick].Y = rPoints[0][0].Y; + } + else + rPoints[0].realloc(nTick); +} + +void VPolarGrid::create2DAngleGrid( const uno::Reference< drawing::XShapes >& xTarget + , ::std::vector< ::std::vector< TickInfo > >& rRadiusTickInfos + , ::std::vector< ::std::vector< TickInfo > >& rAngleTickInfos + , const ::std::vector<VLineProperties>& rLinePropertiesList ) +{ + const ExplicitScaleData& rAngleScale = m_pPosHelper->getScales()[0]; + const ExplicitIncrementData& rAngleIncrement = m_aIncrements[0]; + uno::Reference< XScaling > xInverseScaling( NULL ); + if( rAngleScale.Scaling.is() ) + xInverseScaling = rAngleScale.Scaling->getInverseScaling(); + + double fLogicInnerRadius = m_pPosHelper->getInnerLogicRadius(); + double fLogicOuterRadius = m_pPosHelper->getOuterLogicRadius(); + double fLogicZ = -0.5;//as defined + + sal_Int32 nLinePropertiesCount = rLinePropertiesList.size(); + ::std::vector< ::std::vector< TickInfo > >::iterator aDepthIter = rAngleTickInfos.begin(); + sal_Int32 nDepth=0; + /* + //no subgrids so far for polar angle grid (need different radii) + const ::std::vector< ::std::vector< TickInfo > >::const_iterator aDepthEnd = rAngleTickInfos.end(); + for( ; aDepthIter != aDepthEnd && nDepth < nLinePropertiesCount + ; aDepthIter++, nDepth++ ) + */ + if(nLinePropertiesCount) + { + //create axis main lines + drawing::PointSequenceSequence aAllPoints(1); + ::std::vector< TickInfo >::iterator aTickIter = (*aDepthIter).begin(); + const ::std::vector< TickInfo >::const_iterator aTickEnd = (*aDepthIter).end(); + sal_Int32 nRealPointCount = 0; + for( ; aTickIter != aTickEnd; aTickIter++ ) + { + TickInfo& rTickInfo = *aTickIter; + if( !rTickInfo.bPaintIt ) + continue; + + rTickInfo.updateUnscaledValue( xInverseScaling ); + double fLogicAngle = rTickInfo.fUnscaledTickValue; + + drawing::PointSequenceSequence aPoints(1); + aPoints[0].realloc(2); + drawing::Position3D aScenePositionStart( m_pPosHelper->transformLogicToScene( fLogicAngle, fLogicInnerRadius, fLogicZ ) ); + drawing::Position3D aScenePositionEnd( m_pPosHelper->transformLogicToScene( fLogicAngle, fLogicOuterRadius, fLogicZ ) ); + aPoints[0][0].X = static_cast<sal_Int32>(aScenePositionStart.PositionX); + aPoints[0][0].Y = static_cast<sal_Int32>(aScenePositionStart.PositionY); + aPoints[0][1].X = static_cast<sal_Int32>(aScenePositionEnd.PositionX); + aPoints[0][1].Y = static_cast<sal_Int32>(aScenePositionEnd.PositionY); + appendPointSequence( aAllPoints, aPoints ); + } + + uno::Reference< drawing::XShape > xShape = m_pShapeFactory->createLine2D( + xTarget, aAllPoints, rLinePropertiesList[nDepth] ); + //because of this name this line will be used for marking + m_pShapeFactory->setShapeName( xShape, C2U("MarkHandles") ); + } +} + +void VPolarGrid::create2DRadiusGrid( const uno::Reference< drawing::XShapes >& xTarget + , ::std::vector< ::std::vector< TickInfo > >& rRadiusTickInfos + , ::std::vector< ::std::vector< TickInfo > >& rAngleTickInfos + , const ::std::vector<VLineProperties>& rLinePropertiesList ) +{ + const ExplicitScaleData& rRadiusScale = m_pPosHelper->getScales()[1]; + const ExplicitIncrementData& rRadiusIncrement = m_aIncrements[1]; + uno::Reference< XScaling > xInverseScaling( NULL ); + if( rRadiusScale.Scaling.is() ) + xInverseScaling = rRadiusScale.Scaling->getInverseScaling(); + + sal_Int32 nLinePropertiesCount = rLinePropertiesList.size(); + ::std::vector< ::std::vector< TickInfo > >::iterator aDepthIter = rRadiusTickInfos.begin(); + const ::std::vector< ::std::vector< TickInfo > >::const_iterator aDepthEnd = rRadiusTickInfos.end(); + for( sal_Int32 nDepth=0 + ; aDepthIter != aDepthEnd && nDepth < nLinePropertiesCount + ; aDepthIter++, nDepth++ ) + { + //create axis main lines + drawing::PointSequenceSequence aAllPoints(1); + ::std::vector< TickInfo >::iterator aTickIter = (*aDepthIter).begin(); + const ::std::vector< TickInfo >::const_iterator aTickEnd = (*aDepthIter).end(); + sal_Int32 nRealPointCount = 0; + for( ; aTickIter != aTickEnd; aTickIter++ ) + { + TickInfo& rTickInfo = *aTickIter; + if( !rTickInfo.bPaintIt ) + continue; + + rTickInfo.updateUnscaledValue( xInverseScaling ); + double fLogicRadius = rTickInfo.fUnscaledTickValue; + double fLogicZ = -0.5;//as defined + + drawing::PointSequenceSequence aPoints(1); + VPolarGrid::createLinePointSequence_ForAngleAxis( aPoints, rAngleTickInfos + , rRadiusIncrement, rRadiusScale, m_pPosHelper, fLogicRadius, fLogicZ ); + appendPointSequence( aAllPoints, aPoints ); + } + + uno::Reference< drawing::XShape > xShape = m_pShapeFactory->createLine2D( + xTarget, aAllPoints, rLinePropertiesList[nDepth] ); + //because of this name this line will be used for marking + m_pShapeFactory->setShapeName( xShape, C2U("MarkHandles") ); + } +} + +void SAL_CALL VPolarGrid::createShapes() +{ + DBG_ASSERT(m_pShapeFactory&&m_xLogicTarget.is()&&m_xFinalTarget.is(),"Axis is not proper initialized"); + if(!(m_pShapeFactory&&m_xLogicTarget.is()&&m_xFinalTarget.is())) + return; + if( !m_xMeter.is()) + return; + uno::Reference< beans::XPropertySet > xGridProps( m_xMeter, uno::UNO_QUERY ); + if(!xGridProps.is()) + return; + + //----------------------------------------- + //create named group shape + uno::Reference< XIdentifiable > xIdent( m_xMeter, uno::UNO_QUERY ); + if( ! xIdent.is()) + return; + + uno::Reference< drawing::XShapes > xTarget( + this->createGroupShape( m_xLogicTarget + , ObjectIdentifier::createClassifiedIdentifier( + OBJECTTYPE_GRID, xIdent->getIdentifier() ) + ) ); + + //----------------------------------------- + //create all scaled tickmark values + ::std::vector< ::std::vector< TickInfo > > aAngleTickInfos; + ::std::vector< ::std::vector< TickInfo > > aRadiusTickInfos; + getAllTickInfos( 0, aAngleTickInfos ); + getAllTickInfos( 1, aRadiusTickInfos ); + + //----------------------------------------- + ::std::vector<VLineProperties> aLinePropertiesList; + VCartesianGrid::fillLinePropertiesFromGridModel( aLinePropertiesList, xGridProps ); + + //----------------------------------------- + //create tick mark line shapes + sal_Int32 nDimensionIndex = m_xMeter->getRepresentedDimension(); + if(nDimensionIndex==1) + this->create2DRadiusGrid( xTarget, aRadiusTickInfos, aAngleTickInfos, aLinePropertiesList ); + else + this->create2DAngleGrid( xTarget, aRadiusTickInfos, aAngleTickInfos, aLinePropertiesList ); +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/view/axes/VPolarGrid.hxx b/chart2/source/view/axes/VPolarGrid.hxx new file mode 100644 index 000000000000..92f463f78dbf --- /dev/null +++ b/chart2/source/view/axes/VPolarGrid.hxx @@ -0,0 +1,130 @@ +/************************************************************************* + * + * $RCSfile: VPolarGrid.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: iha $ $Date: 2004-01-17 13:10:00 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2003 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef _CHART2_VPOLARGRID_HXX +#define _CHART2_VPOLARGRID_HXX + +#include "VMeterBase.hxx" +#include "TickmarkHelper.hxx" +#include "VLineProperties.hxx" + +#ifndef _DRAFTS_COM_SUN_STAR_CHART2_XGRID_HPP_ +#include <drafts/com/sun/star/chart2/XGrid.hpp> +#endif + +#ifndef _COM_SUN_STAR_DRAWING_POINTSEQUENCESEQUENCE_HPP_ +#include <com/sun/star/drawing/PointSequenceSequence.hpp> +#endif + +//............................................................................. +namespace chart +{ +//............................................................................. + +//----------------------------------------------------------------------------- +/** +*/ +class PolarPlottingPositionHelper; + +class VPolarGrid : public VMeterBase +{ +//------------------------------------------------------------------------- +// public methods +//------------------------------------------------------------------------- +public: + VPolarGrid( const ::com::sun::star::uno::Reference< + ::drafts::com::sun::star::chart2::XGrid >& xGrid + , sal_Int32 nDimensionCount ); + virtual ~VPolarGrid(); + + virtual void SAL_CALL createShapes(); + + void setIncrements( const ::com::sun::star::uno::Sequence< + ::drafts::com::sun::star::chart2::ExplicitIncrementData >& rIncrements ); + + static void createLinePointSequence_ForAngleAxis( + ::com::sun::star::drawing::PointSequenceSequence& rPoints + , ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos + , const ::drafts::com::sun::star::chart2::ExplicitIncrementData& rIncrement + , const ::drafts::com::sun::star::chart2::ExplicitScaleData& rScale + , PolarPlottingPositionHelper* pPosHelper + , double fLogicRadius, double fLogicZ ); + +private: //member + PolarPlottingPositionHelper* m_pPosHelper; + ::com::sun::star::uno::Sequence< + ::drafts::com::sun::star::chart2::ExplicitIncrementData > m_aIncrements; + + void getAllTickInfos( sal_Int32 nDimensionIndex, ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const; + + void create2DRadiusGrid( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget + , ::std::vector< ::std::vector< TickInfo > >& rRadiusTickInfos + , ::std::vector< ::std::vector< TickInfo > >& rAngleTickInfos + , const ::std::vector<VLineProperties>& rLinePropertiesList ); + void create2DAngleGrid( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget + , ::std::vector< ::std::vector< TickInfo > >& rRadiusTickInfos + , ::std::vector< ::std::vector< TickInfo > >& rAngleTickInfos + , const ::std::vector<VLineProperties>& rLinePropertiesList ); +}; + +//............................................................................. +} //namespace chart +//............................................................................. +#endif diff --git a/chart2/source/view/axes/makefile.mk b/chart2/source/view/axes/makefile.mk index dd0fac9cff24..4117a7dc299f 100644 --- a/chart2/source/view/axes/makefile.mk +++ b/chart2/source/view/axes/makefile.mk @@ -2,9 +2,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.1.1.1 $ +# $Revision: 1.2 $ # -# last change: $Author: bm $ $Date: 2003-10-06 09:58:33 $ +# last change: $Author: iha $ $Date: 2004-01-17 13:10:00 $ # # The Contents of this file are made available subject to the terms of # either of the following licenses @@ -81,10 +81,14 @@ SLOFILES = \ $(SLO)$/VMeterBase.obj \ $(SLO)$/TickmarkHelper.obj \ $(SLO)$/ScaleAutomatism.obj \ - $(SLO)$/VCoordinateSystem.obj \ $(SLO)$/VAxisProperties.obj \ - $(SLO)$/VAxis.obj \ - $(SLO)$/VGrid.obj + $(SLO)$/VCartesianAxis.obj \ + $(SLO)$/VCartesianGrid.obj \ + $(SLO)$/VCartesianCoordinateSystem.obj \ + $(SLO)$/VPolarAxis.obj \ + $(SLO)$/VPolarGrid.obj \ + $(SLO)$/VPolarCoordinateSystem.obj \ + $(SLO)$/VCoordinateSystem.obj # --- Targets ----------------------------------------------------------------- diff --git a/chart2/source/view/charttypes/AreaChart.cxx b/chart2/source/view/charttypes/AreaChart.cxx index b8121fc35636..3333fb9921c0 100644 --- a/chart2/source/view/charttypes/AreaChart.cxx +++ b/chart2/source/view/charttypes/AreaChart.cxx @@ -2,7 +2,6 @@ #include "PlottingPositionHelper.hxx" #include "ShapeFactory.hxx" //#include "chartview/servicenames_charttypes.hxx" -//#include "chartview/servicenames_coosystems.hxx" #include "CommonConverters.hxx" #include "macros.hxx" #include "ViewDefines.hxx" @@ -10,6 +9,7 @@ #include "chartview/ObjectIdentifier.hxx" #include "Splines.hxx" #include "ChartTypeHelper.hxx" +#include "LabelPositionHelper.hxx" #ifndef _DRAFTS_COM_SUN_STAR_CHART2_SYMBOL_HPP_ #include <drafts/com/sun/star/chart2/Symbol.hpp> @@ -168,16 +168,7 @@ APPHELPER_XSERVICEINFO_IMPL(AreaChart,CHART2_VIEW_AREACHART_SERVICE_IMPLEMENTATI ::getCoordinateSystemTypeID() throw (uno::RuntimeException) { - return CHART2_COOSYSTEM_CARTESIAN2D_SERVICE_NAME; -} - - void SAL_CALL AreaChart -::setScales( const uno::Sequence< ExplicitScaleData >& rScales ) throw (uno::RuntimeException) -{ -} - void SAL_CALL AreaChart -::setTransformation( const uno::Reference< XTransformation >& xTransformationToLogicTarget, const uno::Reference< XTransformation >& xTransformationToFinalPage ) throw (uno::RuntimeException) -{ + return CHART2_COOSYSTEM_CARTESIAN_SERVICE_NAME; } */ @@ -647,7 +638,8 @@ void AreaChart::createShapes() drawing::Position3D aScenePosition3D( aTransformedGeom.m_aPosition.PositionX , aTransformedGeom.m_aPosition.PositionY-aSymbolSize.DirectionY/2-1 , aTransformedGeom.m_aPosition.PositionZ+m_pPosHelper->getTransformedDepth() ); - awt::Point aScreenPosition2D( this->transformSceneToScreenPosition( aScenePosition3D ) ); + awt::Point aScreenPosition2D( LabelPositionHelper(m_pPosHelper,m_nDimension,m_xLogicTarget,m_pShapeFactory) + .transformSceneToScreenPosition( aScenePosition3D ) ); this->createDataLabel( m_xTextTarget, **aSeriesIter, nIndex , aUnscaledLogicPosition.PositionY , fLogicYSum, aScreenPosition2D, eAlignment ); diff --git a/chart2/source/view/charttypes/BarChart.cxx b/chart2/source/view/charttypes/BarChart.cxx index 4df588b466a2..9a665c6e51be 100644 --- a/chart2/source/view/charttypes/BarChart.cxx +++ b/chart2/source/view/charttypes/BarChart.cxx @@ -2,13 +2,14 @@ #include "PlottingPositionHelper.hxx" #include "ShapeFactory.hxx" //#include "chartview/servicenames_charttypes.hxx" -//#include "chartview/servicenames_coosystems.hxx" +//#include "servicenames_coosystems.hxx" #include "CommonConverters.hxx" #include "Linear3DTransformation.hxx" #include "ViewDefines.hxx" #include "CategoryPositionHelper.hxx" #include "TransformationHelper.hxx" #include "chartview/ObjectIdentifier.hxx" +#include "LabelPositionHelper.hxx" #ifndef _TOOLS_DEBUG_HXX #include <tools/debug.hxx> @@ -175,16 +176,7 @@ APPHELPER_XSERVICEINFO_IMPL(BarChart,CHART2_VIEW_BARCHART_SERVICE_IMPLEMENTATION ::getCoordinateSystemTypeID() throw (uno::RuntimeException) { - return CHART2_COOSYSTEM_CARTESIAN2D_SERVICE_NAME; -} - - void SAL_CALL BarChart -::setScales( const uno::Sequence< ExplicitScaleData >& rScales ) throw (uno::RuntimeException) -{ -} - void SAL_CALL BarChart -::setTransformation( const uno::Reference< XTransformation >& xTransformationToLogicTarget, const uno::Reference< XTransformation >& xTransformationToFinalPage ) throw (uno::RuntimeException) -{ + return CHART2_COOSYSTEM_CARTESIAN_SERVICE_NAME; } */ @@ -207,7 +199,8 @@ awt::Point BarChart::getLabelScreenPositionAndAlignment( if(bMiddlePosition) aScenePosition3D.PositionZ -= rTransformedGeom.m_aSize.DirectionZ/2.0; } - return this->transformSceneToScreenPosition( aScenePosition3D ); + return LabelPositionHelper(m_pPosHelper,m_nDimension,m_xLogicTarget,m_pShapeFactory) + .transformSceneToScreenPosition( aScenePosition3D ); } uno::Reference< drawing::XShape > BarChart::createDataPoint2D_Bar( diff --git a/chart2/source/view/charttypes/PieChart.cxx b/chart2/source/view/charttypes/PieChart.cxx index 70da314a9896..41dd3b097598 100644 --- a/chart2/source/view/charttypes/PieChart.cxx +++ b/chart2/source/view/charttypes/PieChart.cxx @@ -1,11 +1,11 @@ #include "PieChart.hxx" #include "PlottingPositionHelper.hxx" #include "ShapeFactory.hxx" +#include "PolarLabelPositionHelper.hxx" //#include "chartview/servicenames_charttypes.hxx" -//#include "chartview/servicenames_coosystems.hxx" +//#include "servicenames_coosystems.hxx" #include "CommonConverters.hxx" -#include "Linear3DTransformation.hxx" #include "ViewDefines.hxx" #include "chartview/ObjectIdentifier.hxx" @@ -15,10 +15,6 @@ #ifndef INCLUDED_RTL_MATH_HXX #include <rtl/math.hxx> #endif -// header for class Vector2D -#ifndef _VECTOR2D_HXX -#include <tools/vector2d.hxx> -#endif //............................................................................. namespace chart @@ -27,30 +23,13 @@ namespace chart using namespace ::com::sun::star; using namespace ::drafts::com::sun::star::chart2; -class PiePositionHelper : public PlottingPositionHelper +class PiePositionHelper : public PolarPlottingPositionHelper { public: PiePositionHelper(); virtual ~PiePositionHelper(); - ::com::sun::star::uno::Reference< ::drafts::com::sun::star::chart2::XTransformation > - getTransformationLogicToScene( sal_Int32 nDim ) const; - - double getCatCount() const { - double fMin = getLogicMinX(); - double fMax = getLogicMaxX(); - //categories are defined to be at positive whole numbers only - if(fMax<0.0) - return 0.0; - if(fMin<0.0) - fMin=0.0; - //don't remove cast - return (long)(fMax - fMin)+1; } - - double getInnerRadius( double fCategoryX, bool& bIsVisible ) const; - double getOuterRadius( double fCategoryX ) const; - - DataPointGeometry transformLogicGeom( const DataPointGeometry& rGeom, sal_Int32 nDim ) const; + bool getInnerAndOuterRadius( double fCategoryX, double& fLogicInnerRadius, double& fLogicOuterRadius ) const; sal_Int32 getStartCategoryIndex() const { //first category (index 0) matches with real number 1.0 @@ -67,132 +46,53 @@ public: return nEnd; } -private: //member - double m_fDepth; - public: - //Radius Offset for all rings in absolute logic values (1.0 == 1 category) - double m_fRingOffset; - //Distance between different category rings, seen relative to width of a ring: double m_fRingDistance; //>=0 m_fRingDistance=1 --> distance == width }; PiePositionHelper::PiePositionHelper() - : m_fDepth(1.0) - , m_fRingOffset(0.5) - , m_fRingDistance(0.2) + : PolarPlottingPositionHelper(true) + , m_fRingDistance(0.0) { + m_fRadiusOffset = 0.0; } PiePositionHelper::~PiePositionHelper() { } - -double PiePositionHelper::getInnerRadius( double fCategoryX, bool& bIsVisible ) const +bool PiePositionHelper::getInnerAndOuterRadius( double fCategoryX, double& fLogicInnerRadius, double& fLogicOuterRadius ) const { - bIsVisible = true; - double fRet = m_fRingOffset + fCategoryX-0.5+m_fRingDistance/(2.0*(1+m_fRingDistance)) - getLogicMinX(); - if(fRet<m_fRingOffset) - fRet=m_fRingOffset; - if(fRet>(m_fRingOffset+getLogicMaxX()-getLogicMinX())) - { - fRet=m_fRingOffset+getLogicMaxX()- getLogicMinX(); - bIsVisible = false; - } - doLogicScaling(&fRet,NULL,NULL); - return fRet; -} - -double PiePositionHelper::getOuterRadius( double fCategoryX ) const -{ - double fRet = m_fRingOffset + fCategoryX+0.5-m_fRingDistance/(2.0*(1+m_fRingDistance)) - getLogicMinX(); - if(fRet<m_fRingOffset) - fRet=m_fRingOffset; - if(fRet>(m_fRingOffset+getLogicMaxX()-getLogicMinX())) - fRet=m_fRingOffset+getLogicMaxX()- getLogicMinX(); - doLogicScaling(&fRet,NULL,NULL); - return fRet; + bool bIsVisible = true; + double fLogicInner = fCategoryX -0.5+m_fRingDistance/2.0; + double fLogicOuter = fCategoryX +0.5-m_fRingDistance/2.0; + + if( fLogicInner >= getLogicMaxX() ) + return false; + if( fLogicOuter <= getLogicMinX() ) + return false; + + if( fLogicInner < getLogicMinX() ) + fLogicInner = getLogicMinX(); + if( fLogicOuter > getLogicMaxX() ) + fLogicOuter = getLogicMaxX(); + + fLogicInnerRadius = fLogicInner; + fLogicOuterRadius = fLogicOuter; + return bIsVisible; } - -uno::Reference< XTransformation > PiePositionHelper::getTransformationLogicToScene( - sal_Int32 nDim ) const -{ - //transformation from 2) to 4) //@todo 2) and 4) need a ink to a document - - //?? need to apply this transformation to each geometric object, or would group be sufficient?? - - if( !m_xTransformationLogicToScene.is() ) - { - double fLogicDiameter = 2*(getLogicMaxX() - getLogicMinX() + m_fRingOffset); - - Matrix4D aMatrix; - //the middle of the pie circle is the middle of the diagram - aMatrix.TranslateX(fLogicDiameter/2.0); - aMatrix.ScaleX(FIXED_SIZE_FOR_3D_CHART_VOLUME/fLogicDiameter); - - aMatrix.TranslateY(fLogicDiameter/2.0); - aMatrix.ScaleY(FIXED_SIZE_FOR_3D_CHART_VOLUME/fLogicDiameter); - - aMatrix.ScaleZ(FIXED_SIZE_FOR_3D_CHART_VOLUME/m_fDepth); - -// if(nDim==2) - aMatrix = m_aMatrixScreenToScene*aMatrix; - - m_xTransformationLogicToScene = new Linear3DTransformation(Matrix4DToHomogenMatrix( aMatrix )); - } - return m_xTransformationLogicToScene; -} - -DataPointGeometry PiePositionHelper::transformLogicGeom( const DataPointGeometry& rGeom, sal_Int32 nDim ) const -{ - uno::Reference< XTransformation > xTransformation = getTransformationLogicToScene( nDim ); - DataPointGeometry aTransformedGeom( rGeom ); - - /* - DataPointGeometry aLogicGeom( drawing::Position3D(0.0,0.0,0.0) - , drawing::Direction3D(fOuterXDiameter,fOuterYDiameter,fDepth) - , drawing::Direction3D(fInnerXDiameter,fStartAngleDegree,fWidthAngleDegree) ); - */ - aTransformedGeom.m_aPosition = SequenceToPosition3D( xTransformation->transform( Position3DToSequence(rGeom.m_aPosition) ) ); - - drawing::Position3D aLogicPos1; - drawing::Position3D aLogicPos2( aLogicPos1 ); - aLogicPos2.PositionX += rGeom.m_aSize2.DirectionX;//fInnerXDiameter; - aLogicPos2.PositionZ += rGeom.m_aSize.DirectionZ; - drawing::Position3D aLogicPos3( aLogicPos1 ); - aLogicPos3.PositionX += rGeom.m_aSize.DirectionX; //fOuterXDiameter; - aLogicPos3.PositionY += rGeom.m_aSize.DirectionY; //fOuterYDiameter; - - drawing::Position3D aTransformedPos1( SequenceToPosition3D( xTransformation->transform( Position3DToSequence(aLogicPos1) ) ) ); - drawing::Position3D aTransformedPos2( SequenceToPosition3D( xTransformation->transform( Position3DToSequence(aLogicPos2) ) ) ); - drawing::Position3D aTransformedPos3( SequenceToPosition3D( xTransformation->transform( Position3DToSequence(aLogicPos3) ) ) ); - - - double fTransformedInnerXDiameter = aTransformedPos2.PositionX - aTransformedPos1.PositionX; - double fTransformedOuterXDiameter = aTransformedPos3.PositionX - aTransformedPos1.PositionX; - double fTransformedOuterYDiameter = aTransformedPos3.PositionY - aTransformedPos1.PositionY; - double fTransformedDepth = aTransformedPos2.PositionZ - aTransformedPos1.PositionZ; - - aTransformedGeom.m_aSize2.DirectionX = fTransformedInnerXDiameter; - aTransformedGeom.m_aSize.DirectionX = fTransformedOuterXDiameter; - aTransformedGeom.m_aSize.DirectionY = fTransformedOuterYDiameter; - aTransformedGeom.m_aSize.DirectionZ = fTransformedDepth; - - return aTransformedGeom; -} - - //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -PieChart::PieChart( const uno::Reference<XChartType>& xChartTypeModel ) +PieChart::PieChart( const uno::Reference<XChartType>& xChartTypeModel, double fRadiusOffset, double fRingDistance ) : VSeriesPlotter( xChartTypeModel ) , m_pPosHelper( new PiePositionHelper() ) { PlotterBase::m_pPosHelper = m_pPosHelper; + m_pPosHelper->m_fRadiusOffset = fRadiusOffset; + m_pPosHelper->m_fRingDistance = fRingDistance; } PieChart::~PieChart() @@ -215,173 +115,89 @@ APPHELPER_XSERVICEINFO_IMPL(PieChart,CHART2_VIEW_PIECHART_SERVICE_IMPLEMENTATION } */ -/* -//----------------------------------------------------------------- -// chart2::XPlotter -//----------------------------------------------------------------- - - ::rtl::OUString SAL_CALL PieChart -::getCoordinateSystemTypeID() - throw (uno::RuntimeException) -{ - return CHART2_COOSYSTEM_CARTESIAN2D_SERVICE_NAME; -} - - void SAL_CALL PieChart -::setScales( const uno::Sequence< ExplicitScaleData >& rScales ) throw (uno::RuntimeException) -{ -} - void SAL_CALL PieChart -::setTransformation( const uno::Reference< XTransformation >& xTransformationToLogicTarget, const uno::Reference< XTransformation >& xTransformationToFinalPage ) throw (uno::RuntimeException) -{ -} -*/ - bool PieChart::isSingleRingChart() const { return m_pPosHelper->getEndCategoryIndex()==1 ; } -awt::Point PieChart::transformLogicToScreenPosition( const drawing::Position3D& rLogicPosition3D ) const +uno::Reference< drawing::XShape > PieChart::createDataPoint( + const uno::Reference< drawing::XShapes >& xTarget + , const uno::Reference< beans::XPropertySet >& xObjectProperties + , double fLogicStartAngleValue, double fLogicEndAngleValue + , double fLogicInnerRadius, double fLogicOuterRadius + , double fLogicZ, double fDepth ) { - drawing::Position3D aScenePosition3D( SequenceToPosition3D( - m_pPosHelper->getTransformationLogicToScene( m_nDimension )->transform( - Position3DToSequence(rLogicPosition3D) ) ) ); - if(3==m_nDimension) - { - drawing::Position3D aScenePosition3D_rotated( aScenePosition3D.PositionX, -aScenePosition3D.PositionZ, aScenePosition3D.PositionY ); - aScenePosition3D = aScenePosition3D_rotated; - } - awt::Point aScreenPosition2D( this->transformSceneToScreenPosition( aScenePosition3D ) ); - return aScreenPosition2D; -} + //transformation 3) -> 4) + uno::Reference< XTransformation > xTransformation = m_pPosHelper->getTransformationLogicToScene(); -awt::Point PieChart::getLabelScreenPositionAndAlignment( LabelAlignment& rAlignment, bool bOutsidePosition - , double fAngleDegree, double fOuterRadius, double fInnerRadius, double fLogicZ) const -{ - //outer positions only for pure pie chart(one ring only) + //--------------------------- + //transformed angle: + double fWidthAngleDegree = m_pPosHelper->getWidthAngleDegree(fLogicStartAngleValue,fLogicEndAngleValue); + double fStartAngleDegree = m_pPosHelper->transformToAngleDegree(fLogicStartAngleValue ); - double fAnglePi = fAngleDegree*F_PI/180.0; - double fRadius = 0.0; - if( bOutsidePosition ) + //--------------------------- + //transform origin: + drawing::Position3D aTransformedOrigin; { - fRadius = fOuterRadius; - if(3!=m_nDimension) //for 3D better add 10percent of the 2D distance - fRadius += 0.1*fOuterRadius; + drawing::Position3D aLogicOrigin(0.0,0.0,0.0); + aTransformedOrigin = SequenceToPosition3D( xTransformation->transform( Position3DToSequence(aLogicOrigin) ) ); } - else - fRadius = fInnerRadius + (fOuterRadius-fInnerRadius)/2.0 ; - - if(3==m_nDimension) - fAnglePi *= -1.0; - drawing::Position3D aLogicPos(fRadius*cos(fAnglePi),fRadius*sin(fAnglePi),fLogicZ+0.5); - awt::Point aRet( this->transformLogicToScreenPosition( aLogicPos ) ); - if(3==m_nDimension) + //--------------------------- + //transform radii: + double fTransformedInnerXRadius, fTransformedOuterXRadius, fTransformedOuterYRadius; + double fTransformedDepth; { - //check wether the upper or the downer edge is more distant from the center - //take the farest point to put the label to - drawing::Position3D aLogicPos2(fRadius*cos(fAnglePi),fRadius*sin(fAnglePi),fLogicZ-0.5); - drawing::Position3D aLogicCenter(0,0,fLogicZ); - - awt::Point aP0( this->transformLogicToScreenPosition( - drawing::Position3D(0,0,fLogicZ) ) ); - awt::Point aP1(aRet); - awt::Point aP2( this->transformLogicToScreenPosition( - drawing::Position3D(fRadius*cos(fAnglePi),fRadius*sin(fAnglePi),fLogicZ-0.5) ) ); - - Vector2D aV0( aP0.X, aP0.Y ); - Vector2D aV1( aP1.X, aP1.Y ); - Vector2D aV2( aP2.X, aP2.Y ); - - double fL1 = (aV1-aV0).GetLength(); - double fL2 = (aV2-aV0).GetLength(); - - if(fL2>fL1) - aRet = aP2; - - //calculate new angle for alignment - double fDX = aRet.X-aP0.X; - double fDY = aRet.Y-aP0.Y; - fDY*=-1.0;//drawing layer has inverse y values - if( fDX != 0.0 ) - { - fAngleDegree = atan(fDY/fDX)*180.0/F_PI; - if(fDX<0.0) - fAngleDegree+=180.0; - } - else - { - if(fDY>0.0) - fAngleDegree = 90.0; - else - fAngleDegree = 270.0; - } - } - //------------------------------ - //set LabelAlignment - if( bOutsidePosition ) - { - while(fAngleDegree>360.0) - fAngleDegree-=360.0; - while(fAngleDegree<0.0) - fAngleDegree+=360.0; - - if(fAngleDegree==0.0) - rAlignment = LABEL_ALIGN_CENTER; - else if(fAngleDegree<=22.5) - rAlignment = LABEL_ALIGN_RIGHT; - else if(fAngleDegree<67.5) - rAlignment = LABEL_ALIGN_RIGHT_TOP; - else if(fAngleDegree<112.5) - rAlignment = LABEL_ALIGN_TOP; - else if(fAngleDegree<=157.5) - rAlignment = LABEL_ALIGN_LEFT_TOP; - else if(fAngleDegree<=202.5) - rAlignment = LABEL_ALIGN_LEFT; - else if(fAngleDegree<247.5) - rAlignment = LABEL_ALIGN_LEFT_BOTTOM; - else if(fAngleDegree<292.5) - rAlignment = LABEL_ALIGN_BOTTOM; - else if(fAngleDegree<337.5) - rAlignment = LABEL_ALIGN_RIGHT_BOTTOM; - else - rAlignment = LABEL_ALIGN_RIGHT; + double fInnerRadius = m_pPosHelper->transformToRadius( fLogicInnerRadius ); + double fOuterRadius = m_pPosHelper->transformToRadius( fLogicOuterRadius ); + + drawing::Position3D aLogicPos1; + drawing::Position3D aLogicPos2( aLogicPos1 ); + aLogicPos2.PositionX += fInnerRadius; + aLogicPos2.PositionZ += fDepth; + drawing::Position3D aLogicPos3( aLogicPos1 ); + aLogicPos3.PositionX += fOuterRadius; + aLogicPos3.PositionY += fOuterRadius; + + drawing::Position3D aTransformedPos1( SequenceToPosition3D( xTransformation->transform( Position3DToSequence(aLogicPos1) ) ) ); + drawing::Position3D aTransformedPos2( SequenceToPosition3D( xTransformation->transform( Position3DToSequence(aLogicPos2) ) ) ); + drawing::Position3D aTransformedPos3( SequenceToPosition3D( xTransformation->transform( Position3DToSequence(aLogicPos3) ) ) ); + + fTransformedInnerXRadius = aTransformedPos2.PositionX - aTransformedPos1.PositionX; + fTransformedOuterXRadius = aTransformedPos3.PositionX - aTransformedPos1.PositionX; + fTransformedOuterYRadius = aTransformedPos3.PositionY - aTransformedPos1.PositionY; + fTransformedDepth = aTransformedPos2.PositionZ - aTransformedPos1.PositionZ; } - else - { - rAlignment = LABEL_ALIGN_CENTER; - } - return aRet; -} -uno::Reference< drawing::XShape > PieChart::createDataPoint2D( - const uno::Reference< drawing::XShapes >& xTarget - , const DataPointGeometry& rGeometry - , const uno::Reference< beans::XPropertySet >& xObjectProperties ) -{ - uno::Reference< drawing::XShape > xShape = - m_pShapeFactory->createPieSegment2D( xTarget, rGeometry ); + uno::Reference< drawing::XShape > xShape(0); + if(m_nDimension==3) + xShape = m_pShapeFactory->createPieSegment( xTarget + , fStartAngleDegree, fWidthAngleDegree + , fTransformedInnerXRadius, fTransformedOuterXRadius, fTransformedOuterYRadius + , aTransformedOrigin, fTransformedDepth ); + else + xShape = m_pShapeFactory->createPieSegment2D( xTarget + , fStartAngleDegree, fWidthAngleDegree + , fTransformedInnerXRadius, fTransformedOuterXRadius, fTransformedOuterYRadius + , aTransformedOrigin ); this->setMappedProperties( xShape, xObjectProperties, m_aShapePropertyMapForArea ); return xShape; } -uno::Reference< drawing::XShape > PieChart::createDataPoint3D( - const uno::Reference< drawing::XShapes >& xTarget - , const DataPointGeometry& rGeometry - , const uno::Reference< beans::XPropertySet >& xObjectProperties ) +void PieChart::addSeries( VDataSeries* pSeries, sal_Int32 xSlot, sal_Int32 ySlot ) { - uno::Reference< drawing::XShape > xShape = - m_pShapeFactory->createPieSegment( xTarget, rGeometry ); + VSeriesPlotter::addSeries( pSeries, 0, ySlot ); +} - this->setMappedProperties( xShape, xObjectProperties, m_aShapePropertyMapForArea ); - return xShape; +double PieChart::getMinimumYInRange( double fMinimumX, double fMaximumX ) +{ + return 0.0; } -void PieChart::addSeries( VDataSeries* pSeries, sal_Int32 xSlot, sal_Int32 ySlot ) +double PieChart::getMaximumYInRange( double fMinimumX, double fMaximumX ) { - VSeriesPlotter::addSeries( pSeries, 0, ySlot ); + return 1.0; } void PieChart::createShapes() @@ -398,18 +214,10 @@ void PieChart::createShapes() uno::Reference< drawing::XShapes > xTextTarget( m_pShapeFactory->createGroup2D( m_xFinalTarget,rtl::OUString() )); - if( this->isSingleRingChart() ) - { - m_pPosHelper->m_fRingOffset = 0.0; - m_pPosHelper->m_fRingDistance = 0.0; - } - //--------------------------------------------- //check necessary here that different Y axis can not be stacked in the same group? ... hm? //update/create information for current group - double fLogicZ = -0.5;//as defined - //(@todo maybe different iteration for breaks in axis ?) sal_Int32 nStartCategoryIndex = m_pPosHelper->getStartCategoryIndex(); // inclusive sal_Int32 nEndCategoryIndex = m_pPosHelper->getEndCategoryIndex(); //inclusive @@ -446,15 +254,13 @@ void PieChart::createShapes() continue; aSeriesIter = pSeriesList->begin(); - bool bIsVisible; - double fInnerXRadius = m_pPosHelper->getInnerRadius( (double)nCatIndex+1.0, bIsVisible ); + double fLogicInnerRadius, fLogicOuterRadius; + bool bIsVisible = m_pPosHelper->getInnerAndOuterRadius( (double)nCatIndex+1.0, fLogicInnerRadius, fLogicOuterRadius ); if( !bIsVisible ) continue; - double fOuterXRadius = m_pPosHelper->getOuterRadius( (double)nCatIndex+1.0 ); - double fOuterYRadius = fOuterXRadius; - //the radii are already clipped and had scaling now - double fDepth = 1.0; + double fLogicZ = -0.5;//as defined + double fDepth = 1.0; //as defined //============================================================================= //iterate through all series in this x slot (in this ring) for( ; aSeriesIter != aSeriesEnd; aSeriesIter++ ) @@ -480,46 +286,24 @@ void PieChart::createShapes() //iterate through all subsystems to create partial points { - //clip logic coordinates: - //check fLogicX only necessary if we will allow breaks in category axes (see above for-loop) - //check fLogicZ hm ... - //check fLogicYValue get Y-scale for this series/stack group - //@todo fLogicYValue =... fInnerRadius = ... - - //---------------------------------- - double fStartAngleDegree = fLogicYPos/fLogicYSum*360.0; - double fWidthAngleDegree = fLogicYValue/fLogicYSum*360.0; - - DataPointGeometry aLogicGeom( drawing::Position3D(0.0,0.0,0.0) - , drawing::Direction3D(2.0*fOuterXRadius,2.0*fOuterYRadius,fDepth) - , drawing::Direction3D(2.0*fInnerXRadius,fStartAngleDegree,fWidthAngleDegree) ); - - //@todo: consider scaling here (transformation logic to logic) - //assumed scaling here: linear + //logic values on angle axis: + double fLogicStartAngleValue = fLogicYPos/fLogicYSum; + double fLogicEndAngleValue = (fLogicYPos+fLogicYValue)/fLogicYSum; - //transformation 3) -> 4) - DataPointGeometry aTransformedGeom( m_pPosHelper->transformLogicGeom(aLogicGeom, m_nDimension) ); + //create data point + createDataPoint( xPointGroupShape_Shapes ,(*aSeriesIter)->getPropertiesOfPoint( nCatIndex ) + , fLogicStartAngleValue, fLogicEndAngleValue + , fLogicInnerRadius, fLogicOuterRadius + , fLogicZ, fDepth ); - if(m_nDimension==3) - { - uno::Reference< drawing::XShape > xShape = createDataPoint3D( - xPointGroupShape_Shapes - , aTransformedGeom - ,(*aSeriesIter)->getPropertiesOfPoint( nCatIndex )); - } - else //m_nDimension!=3 - { - uno::Reference< drawing::XShape > xShape = createDataPoint2D( - xPointGroupShape_Shapes - , aTransformedGeom - ,(*aSeriesIter)->getPropertiesOfPoint( nCatIndex )); - } - //create data point label + //create label if( (**aSeriesIter).getDataPointLabelIfLabel(nCatIndex) ) { LabelAlignment eAlignment(LABEL_ALIGN_CENTER); - awt::Point aScreenPosition2D( this->getLabelScreenPositionAndAlignment(eAlignment, this->isSingleRingChart() - , fStartAngleDegree + fWidthAngleDegree/2.0, fOuterXRadius, fInnerXRadius, fLogicZ )); + awt::Point aScreenPosition2D( + PolarLabelPositionHelper(m_pPosHelper,m_nDimension,m_xLogicTarget,m_pShapeFactory).getLabelScreenPositionAndAlignment(eAlignment, this->isSingleRingChart() + , fLogicStartAngleValue, fLogicEndAngleValue + , fLogicInnerRadius, fLogicOuterRadius, fLogicZ )); this->createDataLabel( xTextTarget, **aSeriesIter, nCatIndex , fLogicYValue, fLogicYSum, aScreenPosition2D, eAlignment ); } @@ -549,73 +333,6 @@ void PieChart::createShapes() //... todo } -//e.g. for Rectangle -/* -uno::Reference< drawing::XShape > PieChart::createPartialPointShape( - CooPoint + series dependent properties ...(create a special struct for each chart type) - , uno::Reference< XThinCoordinateSystem > xCoo - , sal_Bool bIsInBreak - , PointStyle* pStyle ) -{ - //create one here; use scaling and transformation to logic target - - //maybe do not show anything in the break //maybe read the behavior out of the configuration - //if(bIsInBreak) - // return NULL; - - uno::Reference< drawing::XShape > xNewPartialPointShape( - m_xShapeFactory->createInstance( - rtl::OUString::createFromAscii( "com.sun.star.drawing.RectangleShape" ) ) - , uno::UNO_QUERY ); - //set size and position - { - // - } - if(pStyle||bIsInBreak) - { - //set style properties if any for a single point - uno::Reference< beans::XPropertySet > xProp( xNewPartialPointShape, uno::UNO_QUERY ); - xProp->setPropertyValue( ... ); - - //set special properties if point in break (e.g. additional transparency ...) - } -} - -//e.g. for PieChart in 2 dim cartesian coordinates: -sal_Bool ShapeFactory::isShown( const Sequence< ExplicitScaleData >& rScales, const CooPoint& rP, double dLogicalWidthBeforeScaling ) -{ - ASSERT(rScales.getLength()==2) - double dMin_x = rScales[0].Minimum; - double dMax_x = rScales[0].Maximum; - double dMin_y = rScales[1].Minimum; - double dMax_y = rScales[1].Maximum; - - //we know that we have cartesian geometry - Rectangle aSysRect( rScales[0].Minimum, rScales[1].Maximum, rScales[0].Maximum, rScales[1].Minimum ); - Rectangle aPointRect( dLogicalWidthBeforeScaling ) - if(rP) -} - -//----------------------------------------------------------------------------- - -class FatCoordinateSystem -{ -public: - //XCoordinateSystemType getType(); - Sequence<XThinCoordinateSystem> getCoordinateSystems(); -} - -class ThinCoordinateSystem -{ -private: - -public: - sal_Bool isBreak(); - Sequence< ExplicitScaleData > getScales();//SubScales without beak - - -} -*/ //............................................................................. } //namespace chart //............................................................................. diff --git a/chart2/source/view/charttypes/PieChart.hxx b/chart2/source/view/charttypes/PieChart.hxx index 43aee9cff770..d6aa084d957e 100644 --- a/chart2/source/view/charttypes/PieChart.hxx +++ b/chart2/source/view/charttypes/PieChart.hxx @@ -2,7 +2,6 @@ #define _CHART2_PIECHART_HXX #include "VSeriesPlotter.hxx" -#include "DatapointGeometry.hxx" //............................................................................. namespace chart @@ -17,7 +16,8 @@ class PieChart : public VSeriesPlotter //------------------------------------------------------------------------- public: PieChart( const ::com::sun::star::uno::Reference< - ::drafts::com::sun::star::chart2::XChartType >& xChartTypeModel ); + ::drafts::com::sun::star::chart2::XChartType >& xChartTypeModel + , double fRadiusOffset=0.0, double fRingDistance=0.0 ); virtual ~PieChart(); //------------------------------------------------------------------------- @@ -33,6 +33,10 @@ public: virtual void addSeries( VDataSeries* pSeries, sal_Int32 xSlot = -1,sal_Int32 ySlot = -1 ); + //MinimumAndMaximumSupplier + virtual double getMinimumYInRange( double fMinimumX, double fMaximumX ); + virtual double getMaximumYInRange( double fMinimumX, double fMaximumX ); + //------------------------------------------------------------------------- //------------------------------------------------------------------------- //------------------------------------------------------------------------- @@ -41,27 +45,13 @@ private: //methods PieChart(); ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > - createDataPoint3D( - const ::com::sun::star::uno::Reference< - ::com::sun::star::drawing::XShapes >& xTarget - , const DataPointGeometry& rGeometry - , const ::com::sun::star::uno::Reference< - ::com::sun::star::beans::XPropertySet >& xObjectProperties ); - ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > - createDataPoint2D( - const ::com::sun::star::uno::Reference< + createDataPoint( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget - , const DataPointGeometry& rGeometry , const ::com::sun::star::uno::Reference< - ::com::sun::star::beans::XPropertySet >& xObjectProperties ); - - ::com::sun::star::awt::Point getLabelScreenPositionAndAlignment( - LabelAlignment& rAlignment, bool bCenteredPosition - , double fAngleDegree, double fOuterRadius, double fInnerRadius - , double fLogicZ) const; - - ::com::sun::star::awt::Point transformLogicToScreenPosition( - const ::com::sun::star::drawing::Position3D& rScenePosition3D ) const; + ::com::sun::star::beans::XPropertySet >& xObjectProperties + , double fLogicStartAngleValue, double fLogicEndAngleValue + , double fLogicInnerRadius, double fLogicOuterRadius + , double fLogicZ, double fDepth ); bool isSingleRingChart() const; diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx b/chart2/source/view/charttypes/VSeriesPlotter.cxx index 825b0f7a6822..2c908cfaeae7 100644 --- a/chart2/source/view/charttypes/VSeriesPlotter.cxx +++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx @@ -7,6 +7,7 @@ #include "chartview/ObjectIdentifier.hxx" #include "StatisticsHelper.hxx" #include "PlottingPositionHelper.hxx" +#include "LabelPositionHelper.hxx" //only for creation: @todo remove if all plotter are uno components and instanciated via servicefactory #include "BarChart.hxx" @@ -41,13 +42,6 @@ #include <algorithm> -#ifndef _COM_SUN_STAR_DRAWING_TEXTVERTICALADJUST_HPP_ -#include <com/sun/star/drawing/TextVerticalAdjust.hpp> -#endif -#ifndef _COM_SUN_STAR_DRAWING_TEXTHORIZONTALADJUST_HPP_ -#include <com/sun/star/drawing/TextHorizontalAdjust.hpp> -#endif - //............................................................................. namespace chart { @@ -365,32 +359,9 @@ void VSeriesPlotter::createDataLabel( const uno::Reference< drawing::XShapes >& rtl::OUString aCID = ObjectIdentifier::createPointCID( rDataSeries.getLabelCID_Stub(),nPointIndex ); *pCIDAny = uno::makeAny(aCID); } + LabelPositionHelper::changeTextAdjustment( *pPropValues, *pPropNames, eAlignment ); - //HorizontalAdjustment - { - drawing::TextHorizontalAdjust eHorizontalAdjust = drawing::TextHorizontalAdjust_CENTER; - if( LABEL_ALIGN_RIGHT==eAlignment || LABEL_ALIGN_RIGHT_TOP==eAlignment || LABEL_ALIGN_RIGHT_BOTTOM==eAlignment ) - eHorizontalAdjust = drawing::TextHorizontalAdjust_LEFT; - else if( LABEL_ALIGN_LEFT==eAlignment || LABEL_ALIGN_LEFT_TOP==eAlignment || LABEL_ALIGN_LEFT_BOTTOM==eAlignment ) - eHorizontalAdjust = drawing::TextHorizontalAdjust_RIGHT; - uno::Any* pHorizontalAdjustAny = PropertyMapper::getValuePointer(*pPropValues,*pPropNames,C2U("TextHorizontalAdjust")); - if(pHorizontalAdjustAny) - *pHorizontalAdjustAny = uno::makeAny(eHorizontalAdjust); - } - - //VerticalAdjustment - { - drawing::TextVerticalAdjust eVerticalAdjust = drawing::TextVerticalAdjust_CENTER; - if( LABEL_ALIGN_TOP==eAlignment || LABEL_ALIGN_RIGHT_TOP==eAlignment || LABEL_ALIGN_LEFT_TOP==eAlignment ) - eVerticalAdjust = drawing::TextVerticalAdjust_BOTTOM; - else if( LABEL_ALIGN_BOTTOM==eAlignment || LABEL_ALIGN_RIGHT_BOTTOM==eAlignment || LABEL_ALIGN_LEFT_BOTTOM==eAlignment ) - eVerticalAdjust = drawing::TextVerticalAdjust_TOP; - uno::Any* pVerticalAdjustAny = PropertyMapper::getValuePointer(*pPropValues,*pPropNames,C2U("TextVerticalAdjust")); - if(pVerticalAdjustAny) - *pVerticalAdjustAny = uno::makeAny(eVerticalAdjust); - } //------------------------------------------------ - //create text shape uno::Reference< drawing::XShape > xTextShape = ShapeFactory(m_xShapeFactory). createText( xTarget_, aText.makeStringAndClear() @@ -1063,6 +1034,8 @@ VSeriesPlotter* VSeriesPlotter::createSeriesPlotter( const uno::Reference<XChart pRet = new AreaChart(xChartTypeModel,false,true); else if( aChartType.equalsIgnoreAsciiCase(C2U("com.sun.star.chart2.PieChart")) ) pRet = new PieChart(xChartTypeModel); + else if( aChartType.equalsIgnoreAsciiCase(C2U("com.sun.star.chart2.NetChart")) ) + pRet = 0; else { //@todo create other charttypes diff --git a/chart2/source/view/inc/LabelAlignment.hxx b/chart2/source/view/inc/LabelAlignment.hxx new file mode 100644 index 000000000000..7f8aa7305f71 --- /dev/null +++ b/chart2/source/view/inc/LabelAlignment.hxx @@ -0,0 +1,75 @@ +/************************************************************************* + * + * $RCSfile: LabelAlignment.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: iha $ $Date: 2004-01-17 13:10:02 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2003 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _CHART2_VIEW_LabelAlignment_HXX +#define _CHART2_VIEW_LabelAlignment_HXX + +//............................................................................. +namespace chart +{ +//............................................................................. + +enum LabelAlignment { LABEL_ALIGN_CENTER, LABEL_ALIGN_LEFT, LABEL_ALIGN_TOP, LABEL_ALIGN_RIGHT, LABEL_ALIGN_BOTTOM, LABEL_ALIGN_LEFT_TOP, LABEL_ALIGN_LEFT_BOTTOM, LABEL_ALIGN_RIGHT_TOP, LABEL_ALIGN_RIGHT_BOTTOM }; + +//............................................................................. +} //namespace chart +//............................................................................. +#endif diff --git a/chart2/source/view/inc/LabelPositionHelper.hxx b/chart2/source/view/inc/LabelPositionHelper.hxx new file mode 100644 index 000000000000..8730e19cce77 --- /dev/null +++ b/chart2/source/view/inc/LabelPositionHelper.hxx @@ -0,0 +1,126 @@ +/************************************************************************* + * + * $RCSfile: LabelPositionHelper.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: iha $ $Date: 2004-01-17 13:10:02 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2003 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _CHART2_VIEW_LABELPOSITIONHELPER_HXX +#define _CHART2_VIEW_LABELPOSITIONHELPER_HXX + +#include "LabelAlignment.hxx" +#include "PropertyMapper.hxx" + +#ifndef _COM_SUN_STAR_AWT_POINT_HPP_ +#include <com/sun/star/awt/Point.hpp> +#endif +#ifndef _COM_SUN_STAR_DRAWING_POSITION3D_HPP_ +#include <com/sun/star/drawing/Position3D.hpp> +#endif +#ifndef _COM_SUN_STAR_DRAWING_XSHAPES_HPP_ +#include <com/sun/star/drawing/XShapes.hpp> +#endif + +//............................................................................. +namespace chart +{ +//............................................................................. + +//----------------------------------------------------------------------------- +/** +*/ +class PlottingPositionHelper; +class ShapeFactory; + +class LabelPositionHelper +{ +public: + LabelPositionHelper( + PlottingPositionHelper* pPosHelper + , sal_Int32 nDimensionCount + , const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xLogicTarget + , ShapeFactory* pShapeFactory ); + virtual ~LabelPositionHelper(); + + ::com::sun::star::awt::Point transformSceneToScreenPosition( + const ::com::sun::star::drawing::Position3D& rScenePosition3D ) const; + ::com::sun::star::awt::Point transformLogicToScreenPosition( + const ::com::sun::star::drawing::Position3D& rScenePosition3D ) const; + + static void changeTextAdjustment( tAnySequence& rPropValues, const tNameSequence& rPropNames, LabelAlignment eAlignment); + static void doDynamicFontResize( tAnySequence& rPropValues, const tNameSequence& rPropNames + , const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xAxisModelProps + , const ::com::sun::star::awt::Size& rNewReferenceSize ); + +private: + LabelPositionHelper(); + +protected: + PlottingPositionHelper* m_pPosHelper; + sal_Int32 m_nDimensionCount; + +private: + //these members are only necessary for transformation from 3D to 2D + ::com::sun::star::uno::Reference< + ::com::sun::star::drawing::XShapes > m_xLogicTarget; + ShapeFactory* m_pShapeFactory; +}; + +//............................................................................. +} //namespace chart +//............................................................................. +#endif diff --git a/chart2/source/view/inc/PlotterBase.hxx b/chart2/source/view/inc/PlotterBase.hxx index 00e0d844e111..b76df8291090 100644 --- a/chart2/source/view/inc/PlotterBase.hxx +++ b/chart2/source/view/inc/PlotterBase.hxx @@ -2,9 +2,9 @@ * * $RCSfile: PlotterBase.hxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: iha $ $Date: 2004-01-06 19:40:19 $ + * last change: $Author: iha $ $Date: 2004-01-17 13:10:02 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -161,10 +161,6 @@ protected: //methods ::com::sun::star::drawing::XShapes >& xTarget , ::rtl::OUString rName=::rtl::OUString() ); - ::com::sun::star::awt::Point transformSceneToScreenPosition( - const ::com::sun::star::drawing::Position3D& rScenePosition3D ) const; - - protected: //member ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes > m_xLogicTarget; diff --git a/chart2/source/view/inc/PlottingPositionHelper.hxx b/chart2/source/view/inc/PlottingPositionHelper.hxx index 5f7f90107b9d..189b560aa68f 100644 --- a/chart2/source/view/inc/PlottingPositionHelper.hxx +++ b/chart2/source/view/inc/PlottingPositionHelper.hxx @@ -2,9 +2,9 @@ * * $RCSfile: PlottingPositionHelper.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: iha $ $Date: 2003-12-15 19:30:05 $ + * last change: $Author: iha $ $Date: 2004-01-17 13:10:03 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -73,11 +73,19 @@ #ifndef _COM_SUN_STAR_DRAWING_HOMOGENMATRIX_HPP_ #include <com/sun/star/drawing/HomogenMatrix.hpp> #endif +#ifndef _COM_SUN_STAR_DRAWING_POSITION3D_HPP_ +#include <com/sun/star/drawing/Position3D.hpp> +#endif #ifndef _B3D_HMATRIX_HXX #include <goodies/hmatrix.hxx> #endif - +/* +//for WeakImplHelper1 +#ifndef _CPPUHELPER_IMPLBASE1_HXX_ +#include <cppuhelper/implbase1.hxx> +#endif +*/ //............................................................................. namespace chart { @@ -135,6 +143,59 @@ protected: //member ::drafts::com::sun::star::chart2::XTransformation > m_xTransformationLogicToScene; }; +class PolarPlottingPositionHelper : public PlottingPositionHelper + /* + , public ::cppu::WeakImplHelper1< + ::drafts::com::sun::star::chart2::XTransformation > + */ +{ +public: + PolarPlottingPositionHelper( bool bRadiusAxisMapsToFirstDimension ); + virtual ~PolarPlottingPositionHelper(); + + virtual ::com::sun::star::uno::Reference< ::drafts::com::sun::star::chart2::XTransformation > + getTransformationLogicToScene() const; + + //the resulting values should be used for input to the transformation + //received with 'getTransformationLogicToScene' + double transformToRadius( double fLogicValueOnRadiusAxis ) const; + double transformToAngleDegree( double fLogicValueOnAngleAxis ) const; + double getWidthAngleDegree( double& fStartLogicValueOnAngleAxis, double& fEndLogicValueOnAngleAxis ) const; + // + + ::com::sun::star::drawing::Position3D + transformLogicToScene( double fLogicValueOnAngleAxis, double fLogicValueOnRadiusAxis, double fLogicZ ) const; + + double getInnerLogicRadius() const; + double getOuterLogicRadius() const; + + const ::com::sun::star::uno::Sequence< + ::drafts::com::sun::star::chart2::ExplicitScaleData >& getScales() const; + /* + // ____ XTransformation ____ + /// @see ::drafts::com::sun::star::chart2::XTransformation + virtual ::com::sun::star::uno::Sequence< double > SAL_CALL transform( + const ::com::sun::star::uno::Sequence< double >& rSourceValues ) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + /// @see ::drafts::com::sun::star::chart2::XTransformation + virtual sal_Int32 SAL_CALL getSourceDimension() + throw (::com::sun::star::uno::RuntimeException); + /// @see ::drafts::com::sun::star::chart2::XTransformation + virtual sal_Int32 SAL_CALL getTargetDimension() + throw (::com::sun::star::uno::RuntimeException); + */ +public: + //Offset for radius axis in absolute logic scaled values (1.0 == 1 category) + double m_fRadiusOffset; + //Offset for angle axis in real degree + double m_fAngleDegreeOffset; + +private: + PolarPlottingPositionHelper(); + bool m_bRadiusAxisMapsToFirstDimension; +}; + bool PlottingPositionHelper::isLogicVisible( double fX, double fY, double fZ ) const { diff --git a/chart2/source/view/inc/PolarLabelPositionHelper.hxx b/chart2/source/view/inc/PolarLabelPositionHelper.hxx new file mode 100644 index 000000000000..7bd9966181f6 --- /dev/null +++ b/chart2/source/view/inc/PolarLabelPositionHelper.hxx @@ -0,0 +1,107 @@ +/************************************************************************* + * + * $RCSfile: PolarLabelPositionHelper.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: iha $ $Date: 2004-01-17 13:10:03 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2003 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _CHART2_VIEW_POLARLABELPOSITIONHELPER_HXX +#define _CHART2_VIEW_POLARLABELPOSITIONHELPER_HXX + +#include "LabelPositionHelper.hxx" + +#ifndef _COM_SUN_STAR_AWT_POINT_HPP_ +#include <com/sun/star/awt/Point.hpp> +#endif +#ifndef _COM_SUN_STAR_DRAWING_POSITION3D_HPP_ +#include <com/sun/star/drawing/Position3D.hpp> +#endif + +//............................................................................. +namespace chart +{ +//............................................................................. + +//----------------------------------------------------------------------------- +/** +*/ +class PolarPlottingPositionHelper; + +class PolarLabelPositionHelper : public LabelPositionHelper +{ +public: + PolarLabelPositionHelper( + PolarPlottingPositionHelper* pPosHelper + , sal_Int32 nDimensionCount + , const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xLogicTarget + , ShapeFactory* pShapeFactory ); + virtual ~PolarLabelPositionHelper(); + + ::com::sun::star::awt::Point getLabelScreenPositionAndAlignment( + LabelAlignment& rAlignment, bool bCenteredPosition + , double fStartLogicValueOnAngleAxis, double fEndLogicValueOnAngleAxis + , double fLogicInnerRadius, double fLogicOuterRadius + , double fLogicZ) const; + +private: + PolarPlottingPositionHelper* m_pPosHelper; +}; + +//............................................................................. +} //namespace chart +//............................................................................. +#endif diff --git a/chart2/source/view/inc/PropertyMapper.hxx b/chart2/source/view/inc/PropertyMapper.hxx index 910353d70e72..e97fe27fd2ef 100644 --- a/chart2/source/view/inc/PropertyMapper.hxx +++ b/chart2/source/view/inc/PropertyMapper.hxx @@ -2,9 +2,9 @@ * * $RCSfile: PropertyMapper.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: bm $ $Date: 2003-10-17 14:50:27 $ + * last change: $Author: iha $ $Date: 2004-01-17 13:10:03 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -139,6 +139,14 @@ public: static const tMakePropertyNameMap& getPropertyNameMapForFilledSeriesProperties(); static const tMakePropertyNameMap& getPropertyNameMapForLineSeriesProperties(); + + static void getTextLabelMultiPropertyLists( + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet >& xSourceProp + , tNameSequence& rPropNames, tAnySequence& rPropValues + , bool bName=true + , sal_Int32 nLimitedSpace=-1 + , bool bLimitedHeight=false ); }; //............................................................................. diff --git a/chart2/source/view/inc/ShapeFactory.hxx b/chart2/source/view/inc/ShapeFactory.hxx index 4dbd3e4d2a96..da4997466a82 100644 --- a/chart2/source/view/inc/ShapeFactory.hxx +++ b/chart2/source/view/inc/ShapeFactory.hxx @@ -2,9 +2,9 @@ * * $RCSfile: ShapeFactory.hxx,v $ * - * $Revision: 1.9 $ + * $Revision: 1.10 $ * - * last change: $Author: bm $ $Date: 2003-12-15 10:01:02 $ + * last change: $Author: iha $ $Date: 2004-01-17 13:10:03 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -147,12 +147,17 @@ public: , const DataPointGeometry& rGeometry ); ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > - createPieSegment( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget - , const DataPointGeometry& rGeometry ); + createPieSegment2D( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget + , double fStartAngleDegree, double fWidthAngleDegree + , double fInnerXRadius, double fOuterXRadius, double fOuterYRadius + , const ::com::sun::star::drawing::Position3D& rOrigin ); ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > - createPieSegment2D( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget - , const DataPointGeometry& rGeometry ); + createPieSegment( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget + , double fStartAngleDegree, double fWidthAngleDegree + , double fInnerXRadius, double fOuterXRadius, double fOuterYRadius + , const ::com::sun::star::drawing::Position3D& rOrigin + , double fDepth ); ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > createStripe( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget diff --git a/chart2/source/view/inc/VCoordinateSystem.hxx b/chart2/source/view/inc/VCoordinateSystem.hxx index 4a071cf48210..2d395124726a 100644 --- a/chart2/source/view/inc/VCoordinateSystem.hxx +++ b/chart2/source/view/inc/VCoordinateSystem.hxx @@ -2,9 +2,9 @@ * * $RCSfile: VCoordinateSystem.hxx,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: bm $ $Date: 2003-10-06 09:58:33 $ + * last change: $Author: iha $ $Date: 2004-01-17 13:10:04 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -96,21 +96,30 @@ namespace chart /** */ class MinimumAndMaximumSupplier; +class NumberFormatterWrapper; class VCoordinateSystem { public: - VCoordinateSystem( const ::com::sun::star::uno::Reference< - ::drafts::com::sun::star::chart2::XBoundedCoordinateSystem >& xCooSys ); virtual ~VCoordinateSystem(); - void addAxis( const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::chart2::XAxis >& xAxis ); + static VCoordinateSystem* createCoordinateSystem( const ::com::sun::star::uno::Reference< + ::drafts::com::sun::star::chart2::XBoundedCoordinateSystem >& xCooSysModel ); + + virtual void SAL_CALL initPlottingTargets( + const ::com::sun::star::uno::Reference< + ::com::sun::star::drawing::XShapes >& xLogicTarget + , const ::com::sun::star::uno::Reference< + ::com::sun::star::drawing::XShapes >& xFinalTarget + , const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XMultiServiceFactory >& xFactory ) + throw (::com::sun::star::uno::RuntimeException); void setOrigin( double* fCoordinateOrigin ); + void addAxis( const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::chart2::XAxis >& xAxis ); void addGrid( const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::chart2::XGrid >& xGrid ); - void doAutoScale( MinimumAndMaximumSupplier* pMinMaxSupplier ); - ::com::sun::star::uno::Reference< ::drafts::com::sun::star::chart2::XAxis > getAxisByDimension( sal_Int32 nDim ) const; + void setTransformationSceneToScreen( const ::com::sun::star::drawing::HomogenMatrix& rMatrix ); const ::com::sun::star::uno::Sequence< ::drafts::com::sun::star::chart2::ExplicitScaleData >& getExplicitScales() const {return m_aExplicitScales;} const ::com::sun::star::uno::Sequence< ::drafts::com::sun::star::chart2::ExplicitIncrementData >& getExplicitIncrements() const {return m_aExplicitIncrements;} @@ -120,20 +129,19 @@ public: ::drafts::com::sun::star::chart2::XBoundedCoordinateSystem > getModel() const; - void createGridShapes( const ::com::sun::star::uno::Reference< - ::com::sun::star::lang::XMultiServiceFactory>& xShapeFactory - , const ::com::sun::star::uno::Reference< - ::com::sun::star::drawing::XShapes >& xTarget - , const ::com::sun::star::drawing::HomogenMatrix& rHM_SceneToScreen - ); + virtual void createGridShapes(); + virtual void createAxesShapes( const ::com::sun::star::awt::Size& rReferenceSize, NumberFormatterWrapper* pNumberFormatterWrapper ); -private: //methods - ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< - ::drafts::com::sun::star::chart2::XGrid > >& - getGridListByDimension( sal_Int32 nDim ); +protected: //methods + VCoordinateSystem( const ::com::sun::star::uno::Reference< + ::drafts::com::sun::star::chart2::XBoundedCoordinateSystem >& xCooSys ); -private: //member + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::drafts::com::sun::star::chart2::XGrid > >& + getGridListByDimension( sal_Int32 nDim ); + ::com::sun::star::uno::Reference< ::drafts::com::sun::star::chart2::XAxis > + getAxisByDimension( sal_Int32 nDim ) const; +protected: //member ::com::sun::star::uno::Reference< ::drafts::com::sun::star::chart2::XBoundedCoordinateSystem > m_xCooSysModel; @@ -155,6 +163,17 @@ private: //member ::com::sun::star::uno::Sequence< ::drafts::com::sun::star::chart2::ExplicitScaleData > m_aExplicitScales; ::com::sun::star::uno::Sequence< ::drafts::com::sun::star::chart2::ExplicitIncrementData > m_aExplicitIncrements; + + // + ::com::sun::star::uno::Reference< + ::com::sun::star::drawing::XShapes > m_xLogicTargetForGrids; + ::com::sun::star::uno::Reference< + ::com::sun::star::drawing::XShapes > m_xLogicTargetForAxes; + ::com::sun::star::uno::Reference< + ::com::sun::star::drawing::XShapes > m_xFinalTarget; + ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XMultiServiceFactory> m_xShapeFactory; + ::com::sun::star::drawing::HomogenMatrix m_aMatrixSceneToScreen; }; //............................................................................. diff --git a/chart2/source/view/inc/VSeriesPlotter.hxx b/chart2/source/view/inc/VSeriesPlotter.hxx index db89f62a7012..8df204eff32e 100644 --- a/chart2/source/view/inc/VSeriesPlotter.hxx +++ b/chart2/source/view/inc/VSeriesPlotter.hxx @@ -2,9 +2,9 @@ * * $RCSfile: VSeriesPlotter.hxx,v $ * - * $Revision: 1.14 $ + * $Revision: 1.15 $ * - * last change: $Author: iha $ $Date: 2004-01-05 20:04:32 $ + * last change: $Author: iha $ $Date: 2004-01-17 13:10:05 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -64,6 +64,7 @@ #include "PlotterBase.hxx" #include "VDataSeries.hxx" #include "PropertyMapper.hxx" +#include "LabelAlignment.hxx" #ifndef _DRAFTS_COM_SUN_STAR_CHART2_XCHARTTYPE_HPP_ #include <drafts/com/sun/star/chart2/XChartType.hpp> @@ -131,17 +132,12 @@ private: sal_Int32 m_nMaxPointCount; }; -enum LabelAlignment { LABEL_ALIGN_CENTER, LABEL_ALIGN_LEFT, LABEL_ALIGN_TOP, LABEL_ALIGN_RIGHT, LABEL_ALIGN_BOTTOM, LABEL_ALIGN_LEFT_TOP, LABEL_ALIGN_LEFT_BOTTOM, LABEL_ALIGN_RIGHT_TOP, LABEL_ALIGN_RIGHT_BOTTOM }; - class VSeriesPlotter : public PlotterBase, public MinimumAndMaximumSupplier { //------------------------------------------------------------------------- // public methods //------------------------------------------------------------------------- public: - VSeriesPlotter( const ::com::sun::star::uno::Reference< - ::drafts::com::sun::star::chart2::XChartType >& xChartTypeModel - , bool bCategoryXAxis=true ); virtual ~VSeriesPlotter(); /* @@ -196,6 +192,11 @@ private: //methods VSeriesPlotter(); protected: //methods + + VSeriesPlotter( const ::com::sun::star::uno::Reference< + ::drafts::com::sun::star::chart2::XChartType >& xChartTypeModel + , bool bCategoryXAxis=true ); + ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes > getSeriesGroupShape( VDataSeries* pDataSeries , const::com::sun::star:: uno::Reference< diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx index e3bad798c6f5..29368d198ee4 100644 --- a/chart2/source/view/main/ChartView.cxx +++ b/chart2/source/view/main/ChartView.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ChartView.cxx,v $ * - * $Revision: 1.30 $ + * $Revision: 1.31 $ * - * last change: $Author: iha $ $Date: 2004-01-08 10:47:24 $ + * last change: $Author: iha $ $Date: 2004-01-17 13:10:06 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -59,12 +59,11 @@ * ************************************************************************/ #include "ChartViewImpl.hxx" -#include "PlottingPositionHelper.hxx" #include "ViewDefines.hxx" #include "VDiagram.hxx" #include "VTitle.hxx" #include "ShapeFactory.hxx" -#include "VAxis.hxx" +#include "VCoordinateSystem.hxx" #include "VSeriesPlotter.hxx" #include "CommonConverters.hxx" #include "macros.hxx" @@ -73,6 +72,7 @@ #include "VLegend.hxx" #include "PropertyMapper.hxx" #include "ChartModelHelper.hxx" +#include "ChartTypeHelper.hxx" #ifndef _DRAFTS_COM_SUN_STAR_CHART2_EXPLICITSUBINCREMENT_HPP_ #include <drafts/com/sun/star/chart2/ExplicitSubIncrement.hpp> @@ -160,6 +160,15 @@ ChartViewImpl::~ChartViewImpl() { m_xDrawPages->remove( m_xDrawPage ); m_xDrawPage = NULL; + + //delete all coordinate systems + ::std::vector< VCoordinateSystem* >::const_iterator aIter = m_aVCooSysList.begin(); + const ::std::vector< VCoordinateSystem* >::const_iterator aEnd = m_aVCooSysList.end(); + for( ; aIter != aEnd; aIter++ ) + { + delete *aIter; + } + m_aVCooSysList.clear(); } Matrix4D createTransformationSceneToScreen( @@ -208,8 +217,8 @@ void getCoordinateOrigin( double* fCoordinateOrigin, const uno::Reference< XBoun sal_Int32 getDimension( const uno::Reference< XDiagram >& xDiagram ) { - rtl::OUString aChartType; - return ChartModelHelper::getDimensionAndFirstChartType( xDiagram, aChartType ); + return ChartTypeHelper::getDimensionCount( + ChartModelHelper::getFirstChartType( xDiagram ) ); } // void getCoordinateSystems( std::vector< VCoordinateSystem >& rVCooSysList, const uno::Reference< XDiagram >& xDiagram ) @@ -237,34 +246,36 @@ sal_Int32 getDimension( const uno::Reference< XDiagram >& xDiagram ) // } // } -const VCoordinateSystem* findInCooSysList( const std::vector< VCoordinateSystem >& rVCooSysList +const VCoordinateSystem* findInCooSysList( const std::vector< VCoordinateSystem* >& rVCooSysList , const uno::Reference< XBoundedCoordinateSystem >& xCooSys ) { for( size_t nC=0; nC < rVCooSysList.size(); nC++) { - const VCoordinateSystem& rVCooSys = rVCooSysList[nC]; - if(rVCooSys.getModel()==xCooSys) - return &rVCooSys; + const VCoordinateSystem* pVCooSys = rVCooSysList[nC]; + if(pVCooSys->getModel()==xCooSys) + return pVCooSys; } return NULL; } -void addCooSysToList( std::vector< VCoordinateSystem >& rVCooSysList +void addCooSysToList( std::vector< VCoordinateSystem* >& rVCooSysList , const uno::Reference< XBoundedCoordinateSystem >& xCooSys , double fCoordinateOrigin [] ) { if( !findInCooSysList( rVCooSysList, xCooSys ) ) { - VCoordinateSystem aVCooSys(xCooSys); - aVCooSys.setOrigin(fCoordinateOrigin); - - rVCooSysList.push_back( aVCooSys ); + VCoordinateSystem* pVCooSys( VCoordinateSystem::createCoordinateSystem(xCooSys ) ); + if(pVCooSys) + { + pVCooSys->setOrigin(fCoordinateOrigin); + rVCooSysList.push_back( pVCooSys ); + } } } void getAxesAndAddToCooSys( uno::Sequence< uno::Reference< XAxis > >& rAxisList , const uno::Reference< XDiagram >& xDiagram - , std::vector< VCoordinateSystem >& rVCooSysList ) + , std::vector< VCoordinateSystem* >& rVCooSysList ) { uno::Reference< XAxisContainer > xAxisContainer( xDiagram, uno::UNO_QUERY ); if( xAxisContainer.is()) @@ -275,9 +286,9 @@ void getAxesAndAddToCooSys( uno::Sequence< uno::Reference< XAxis > >& rAxisList uno::Reference< XAxis > xAxis( rAxisList[nA] ); for( size_t nC=0; nC < rVCooSysList.size(); nC++) { - if(xAxis->getCoordinateSystem() == rVCooSysList[nC].getModel() ) + if(xAxis->getCoordinateSystem() == rVCooSysList[nC]->getModel() ) { - rVCooSysList[nC].addAxis( xAxis ); + rVCooSysList[nC]->addAxis( xAxis ); } } } @@ -285,7 +296,7 @@ void getAxesAndAddToCooSys( uno::Sequence< uno::Reference< XAxis > >& rAxisList } void addGridsToCooSys( const uno::Reference< XDiagram >& xDiagram - , std::vector< VCoordinateSystem >& rVCooSysList ) + , std::vector< VCoordinateSystem* >& rVCooSysList ) { uno::Reference< XGridContainer > xGridContainer( xDiagram, uno::UNO_QUERY ); if( xGridContainer.is()) @@ -297,9 +308,9 @@ void addGridsToCooSys( const uno::Reference< XDiagram >& xDiagram uno::Reference< XGrid > xGrid( aGridList[nA] ); for( size_t nC=0; nC < rVCooSysList.size(); nC++) { - if(xGrid->getCoordinateSystem() == rVCooSysList[nC].getModel() ) + if(xGrid->getCoordinateSystem() == rVCooSysList[nC]->getModel() ) { - rVCooSysList[nC].addGrid( xGrid ); + rVCooSysList[nC]->addGrid( xGrid ); } } } @@ -310,6 +321,8 @@ void addSeriesToPlotter( const uno::Sequence< uno::Reference< XDataSeriesTreeNod , VSeriesPlotter* pPlotter , StackMode eYStackMode ) { + if(!pPlotter) + return; for( sal_Int32 nS = 0; nS < rSeriesList.getLength(); ++nS ) { uno::Reference< XDataSeries > xDataSeries( rSeriesList[nS], uno::UNO_QUERY ); @@ -331,7 +344,7 @@ void addSeriesToPlotter( const uno::Sequence< uno::Reference< XDataSeriesTreeNod */ } } -void initializeDiagramAndGetCooSys( std::vector< VCoordinateSystem >& rVCooSysList +void initializeDiagramAndGetCooSys( std::vector< VCoordinateSystem* >& rVCooSysList , const uno::Reference< uno::XComponentContext>& xCC , const uno::Reference< drawing::XShapes>& xPageShapes , const uno::Reference< lang::XMultiServiceFactory>& xShapeFactory @@ -427,61 +440,34 @@ void initializeDiagramAndGetCooSys( std::vector< VCoordinateSystem >& rVCooSysLi //------------ get all axes from model and add to VCoordinateSystems uno::Sequence< uno::Reference< XAxis > > aAxisList; getAxesAndAddToCooSys( aAxisList, xDiagram, rVCooSysList ); - addGridsToCooSys( xDiagram, rVCooSysList ); - //------------ iterate through all coordinate systems for( size_t nC=0; nC < rVCooSysList.size(); nC++) { //------------ create explicit scales and increments - VCoordinateSystem& rVCooSys = rVCooSysList[nC]; - rVCooSys.doAutoScale( apPlotter.get() ); - - const uno::Sequence< ExplicitScaleData >& rExplicitScales = rVCooSys.getExplicitScales(); - const uno::Sequence< ExplicitIncrementData >& rExplicitIncrements = rVCooSys.getExplicitIncrements(); - - double fCoordinateOrigin[3] = { 0.0, 0.0, 0.0 }; - for( sal_Int32 nDim = 0; nDim < 3; nDim++ ) - fCoordinateOrigin[nDim] = rVCooSys.getOriginByDimension( nDim ); + VCoordinateSystem* pVCooSys = rVCooSysList[nC]; + pVCooSys->doAutoScale( apPlotter.get() ); Matrix4D aM4_SceneToScreen( createTransformationSceneToScreen(rPos,rSize) ); drawing::HomogenMatrix aHM_SceneToScreen( Matrix4DToHomogenMatrix(aM4_SceneToScreen) ); - //------------ create grids - rVCooSys.createGridShapes( xShapeFactory, xTarget, aHM_SceneToScreen ); + pVCooSys->initPlottingTargets(xTarget,xPageShapes,xShapeFactory); + pVCooSys->setTransformationSceneToScreen(aHM_SceneToScreen); + + //------------ create axes and grids --- @todo do auto layout / fontscaling + pVCooSys->createAxesShapes( rSize, pNumberFormatterWrapper ); + pVCooSys->createGridShapes(); - //------------ create axes --- @todo do auto layout / fontscaling - for( nDim = 0; nDim < 3; nDim++ ) + //------------ set scale to plotter / create series + if(apPlotter.get()) { - uno::Reference< XAxis > xAxis = rVCooSys.getAxisByDimension(nDim); - if(xAxis.is() - &&2==nDimension) //@todo remove this restriction if 3D axes are available - { - AxisProperties aAxisProperties; - aAxisProperties.m_xAxisModel = xAxis; - aAxisProperties.m_pfExrtaLinePositionAtOtherAxis = - new double(nDim==1?fCoordinateOrigin[0]:fCoordinateOrigin[1]); - aAxisProperties.m_bTESTTEST_HorizontalAdjustmentIsLeft = sal_False; - aAxisProperties.m_aReferenceSize = rSize; - //------------------- - VAxis aAxis(aAxisProperties,pNumberFormatterWrapper); - aAxis.setMeterData( rExplicitScales[nDim], rExplicitIncrements[nDim] ); - - aAxis.init(xTarget,xPageShapes,xShapeFactory); - if(2==nDimension) - aAxis.setTransformationSceneToScreen( aHM_SceneToScreen ); - aAxis.setScales( rExplicitScales ); - aAxis.createShapes(); - } + apPlotter->init(xTarget,xPageShapes,xShapeFactory); + if(2==nDimension) + apPlotter->setTransformationSceneToScreen( aHM_SceneToScreen ); + apPlotter->setScales( pVCooSys->getExplicitScales() ); + apPlotter->createShapes(); } - - //------------ set scale to plotter - apPlotter->init(xTarget,xPageShapes,xShapeFactory); - if(2==nDimension) - apPlotter->setTransformationSceneToScreen( aHM_SceneToScreen ); - apPlotter->setScales( rExplicitScales ); - apPlotter->createShapes(); } } } diff --git a/chart2/source/view/main/LabelPositionHelper.cxx b/chart2/source/view/main/LabelPositionHelper.cxx new file mode 100644 index 000000000000..d548e855b197 --- /dev/null +++ b/chart2/source/view/main/LabelPositionHelper.cxx @@ -0,0 +1,202 @@ +/************************************************************************* + * + * $RCSfile: LabelPositionHelper.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: iha $ $Date: 2004-01-17 13:10:06 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2003 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include "LabelPositionHelper.hxx" +#include "PlottingPositionHelper.hxx" +#include "CommonConverters.hxx" +#include "PropertyMapper.hxx" +#include "ShapeFactory.hxx" +#include "macros.hxx" +#include "RelativeSizeHelper.hxx" + +// header for class Vector2D +#ifndef _VECTOR2D_HXX +#include <tools/vector2d.hxx> +#endif + +#ifndef _COM_SUN_STAR_DRAWING_TEXTVERTICALADJUST_HPP_ +#include <com/sun/star/drawing/TextVerticalAdjust.hpp> +#endif +#ifndef _COM_SUN_STAR_DRAWING_TEXTHORIZONTALADJUST_HPP_ +#include <com/sun/star/drawing/TextHorizontalAdjust.hpp> +#endif + +//............................................................................. +namespace chart +{ +//............................................................................. +using namespace ::com::sun::star; +using namespace ::drafts::com::sun::star::chart2; + +LabelPositionHelper::LabelPositionHelper( + PlottingPositionHelper* pPosHelper + , sal_Int32 nDimensionCount + , const uno::Reference< drawing::XShapes >& xLogicTarget + , ShapeFactory* pShapeFactory ) + : m_pPosHelper(pPosHelper) + , m_nDimensionCount(nDimensionCount) + , m_xLogicTarget(xLogicTarget) + , m_pShapeFactory(pShapeFactory) +{ +} + +LabelPositionHelper::~LabelPositionHelper() +{ +} + +awt::Point LabelPositionHelper::transformSceneToScreenPosition( const drawing::Position3D& rScenePosition3D ) const +{ + //@todo would like to have a cheaper method to do this transformation + awt::Point aScreenPoint( static_cast<sal_Int32>(rScenePosition3D.PositionX), static_cast<sal_Int32>(rScenePosition3D.PositionY) ); + + //transformation from scene to screen (only neccessary for 3D): + if(3==m_nDimensionCount) + { + //create 3D anchor shape + tPropertyNameMap aDummyPropertyNameMap; + uno::Reference< drawing::XShape > xShape3DAnchor = m_pShapeFactory->createCube( m_xLogicTarget + , DataPointGeometry( rScenePosition3D,drawing::Direction3D(1,1,1) ) + , 0, aDummyPropertyNameMap); + //get 2D position from xShape3DAnchor + aScreenPoint = xShape3DAnchor->getPosition(); + m_xLogicTarget->remove(xShape3DAnchor); + } + return aScreenPoint; +} + +awt::Point LabelPositionHelper::transformLogicToScreenPosition( const drawing::Position3D& rLogicPosition3D ) const +{ + drawing::Position3D aScenePosition3D( SequenceToPosition3D( + m_pPosHelper->getTransformationLogicToScene()->transform( + Position3DToSequence(rLogicPosition3D) ) ) ); + if(3==m_nDimensionCount) + { + drawing::Position3D aScenePosition3D_rotated( aScenePosition3D.PositionX, -aScenePosition3D.PositionZ, aScenePosition3D.PositionY ); + aScenePosition3D = aScenePosition3D_rotated; + } + awt::Point aScreenPosition2D( this->transformSceneToScreenPosition( aScenePosition3D ) ); + return aScreenPosition2D; +} + +//static +void LabelPositionHelper::changeTextAdjustment( tAnySequence& rPropValues, const tNameSequence& rPropNames, LabelAlignment eAlignment) +{ + //HorizontalAdjustment + { + drawing::TextHorizontalAdjust eHorizontalAdjust = drawing::TextHorizontalAdjust_CENTER; + if( LABEL_ALIGN_RIGHT==eAlignment || LABEL_ALIGN_RIGHT_TOP==eAlignment || LABEL_ALIGN_RIGHT_BOTTOM==eAlignment ) + eHorizontalAdjust = drawing::TextHorizontalAdjust_LEFT; + else if( LABEL_ALIGN_LEFT==eAlignment || LABEL_ALIGN_LEFT_TOP==eAlignment || LABEL_ALIGN_LEFT_BOTTOM==eAlignment ) + eHorizontalAdjust = drawing::TextHorizontalAdjust_RIGHT; + uno::Any* pHorizontalAdjustAny = PropertyMapper::getValuePointer(rPropValues,rPropNames,C2U("TextHorizontalAdjust")); + if(pHorizontalAdjustAny) + *pHorizontalAdjustAny = uno::makeAny(eHorizontalAdjust); + } + + //VerticalAdjustment + { + drawing::TextVerticalAdjust eVerticalAdjust = drawing::TextVerticalAdjust_CENTER; + if( LABEL_ALIGN_TOP==eAlignment || LABEL_ALIGN_RIGHT_TOP==eAlignment || LABEL_ALIGN_LEFT_TOP==eAlignment ) + eVerticalAdjust = drawing::TextVerticalAdjust_BOTTOM; + else if( LABEL_ALIGN_BOTTOM==eAlignment || LABEL_ALIGN_RIGHT_BOTTOM==eAlignment || LABEL_ALIGN_LEFT_BOTTOM==eAlignment ) + eVerticalAdjust = drawing::TextVerticalAdjust_TOP; + uno::Any* pVerticalAdjustAny = PropertyMapper::getValuePointer(rPropValues,rPropNames,C2U("TextVerticalAdjust")); + if(pVerticalAdjustAny) + *pVerticalAdjustAny = uno::makeAny(eVerticalAdjust); + } +} + +void lcl_doDynamicFontResize( uno::Any* pAOldFontHeightAny + , const awt::Size& rOldReferenceSize + , const awt::Size& rNewReferenceSize ) +{ + double fOldFontHeight, fNewFontHeight; + if( pAOldFontHeightAny && ( *pAOldFontHeightAny >>= fOldFontHeight ) ) + { + fNewFontHeight = RelativeSizeHelper::calculate( fOldFontHeight, rOldReferenceSize, rNewReferenceSize ); + *pAOldFontHeightAny = uno::makeAny(fNewFontHeight); + } +} + +//static +void LabelPositionHelper::doDynamicFontResize( tAnySequence& rPropValues + , const tNameSequence& rPropNames + , const uno::Reference< beans::XPropertySet >& xAxisModelProps + , const awt::Size& rNewReferenceSize + ) +{ + //------------------------- + //handle dynamic font resize: + awt::Size aOldReferenceSize; + if( xAxisModelProps->getPropertyValue( C2U("ReferenceDiagramSize")) >>= aOldReferenceSize ) + { + uno::Any* pAOldFontHeightAny = PropertyMapper::getValuePointer( rPropValues, rPropNames, C2U("CharHeight") ); + lcl_doDynamicFontResize( pAOldFontHeightAny, aOldReferenceSize, rNewReferenceSize ); + pAOldFontHeightAny = PropertyMapper::getValuePointer( rPropValues, rPropNames, C2U("CharHeightAsian") ); + lcl_doDynamicFontResize( pAOldFontHeightAny, aOldReferenceSize, rNewReferenceSize ); + pAOldFontHeightAny = PropertyMapper::getValuePointer( rPropValues, rPropNames, C2U("CharHeightComplex") ); + lcl_doDynamicFontResize( pAOldFontHeightAny, aOldReferenceSize, rNewReferenceSize ); + } +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/view/main/PlotterBase.cxx b/chart2/source/view/main/PlotterBase.cxx index 126e1efdb93c..b17adc6b620f 100644 --- a/chart2/source/view/main/PlotterBase.cxx +++ b/chart2/source/view/main/PlotterBase.cxx @@ -2,9 +2,9 @@ * * $RCSfile: PlotterBase.cxx,v $ * - * $Revision: 1.10 $ + * $Revision: 1.11 $ * - * last change: $Author: iha $ $Date: 2004-01-06 19:41:01 $ + * last change: $Author: iha $ $Date: 2004-01-17 13:10:07 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -149,26 +149,6 @@ uno::Reference< drawing::XShapes > PlotterBase::createGroupShape( } } -awt::Point PlotterBase::transformSceneToScreenPosition( const drawing::Position3D& rScenePosition3D ) const -{ - //@todo would like to have a cheaper method to do this transformation - awt::Point aScreenPoint( rScenePosition3D.PositionX, rScenePosition3D.PositionY ); - - //transformation from scene to screen (only neccessary for 3D): - if(3==m_nDimension) - { - //create 3D anchor shape - tPropertyNameMap aDummyPropertyNameMap; - uno::Reference< drawing::XShape > xShape3DAnchor = m_pShapeFactory->createCube( m_xLogicTarget - , DataPointGeometry( rScenePosition3D,drawing::Direction3D(1,1,1) ) - , 0, aDummyPropertyNameMap); - //get 2D position from xShape3DAnchor - aScreenPoint = xShape3DAnchor->getPosition(); - m_xLogicTarget->remove(xShape3DAnchor); - } - return aScreenPoint; -} - /* //----------------------------------------------------------------- // chart2::XPlotter @@ -178,7 +158,7 @@ awt::Point PlotterBase::transformSceneToScreenPosition( const drawing::Position3 ::getCoordinateSystemTypeID() throw (uno::RuntimeException) { - return CHART2_COOSYSTEM_CARTESIAN2D_SERVICE_NAME; + return CHART2_COOSYSTEM_CARTESIAN_SERVICE_NAME; } void SAL_CALL PlotterBase diff --git a/chart2/source/view/main/PlottingPositionHelper.cxx b/chart2/source/view/main/PlottingPositionHelper.cxx index b41f1d8127d3..a4618748cc27 100644 --- a/chart2/source/view/main/PlottingPositionHelper.cxx +++ b/chart2/source/view/main/PlottingPositionHelper.cxx @@ -2,9 +2,9 @@ * * $RCSfile: PlottingPositionHelper.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: iha $ $Date: 2003-12-15 19:30:38 $ + * last change: $Author: iha $ $Date: 2004-01-17 13:10:07 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -236,6 +236,222 @@ DoubleRectangle PlottingPositionHelper::getTransformedClipDoubleRect() const return aRet; } +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +PolarPlottingPositionHelper::PolarPlottingPositionHelper( bool bRadiusAxisMapsToFirstDimension ) + : m_fRadiusOffset(0.0) + , m_fAngleDegreeOffset(90.0) + , m_bRadiusAxisMapsToFirstDimension(bRadiusAxisMapsToFirstDimension) +{ +} + +PolarPlottingPositionHelper::~PolarPlottingPositionHelper() +{ +} + +const uno::Sequence< ExplicitScaleData >& PolarPlottingPositionHelper::getScales() const +{ + return m_aScales; +} + +uno::Reference< XTransformation > PolarPlottingPositionHelper::getTransformationLogicToScene() const +{ + //transformation from 2) to 4) //@todo 2) and 4) need a ink to a document + + //?? need to apply this transformation to each geometric object, or would group be sufficient?? + + if( !m_xTransformationLogicToScene.is() ) + { + double MinX = getLogicMinX(); + double MinY = getLogicMinY(); + double MinZ = getLogicMinZ(); + double MaxX = getLogicMaxX(); + double MaxY = getLogicMaxY(); + double MaxZ = getLogicMaxZ(); + + //apply scaling + doLogicScaling( &MinX, &MinY, &MinZ ); + doLogicScaling( &MaxX, &MaxY, &MaxZ); + + double fLogicDiameter = 2*(fabs(MaxY - MinY) + m_fRadiusOffset); + if( m_bRadiusAxisMapsToFirstDimension ) + fLogicDiameter = 2*(fabs(MaxX - MinX) + m_fRadiusOffset); + + double fScaleDirectionZ = AxisOrientation_MATHEMATICAL==m_aScales[2].Orientation ? 1.0 : -1.0; + + Matrix4D aMatrix; + //the middle of the pie circle is the middle of the diagram + aMatrix.TranslateX(fLogicDiameter/2.0); + aMatrix.ScaleX(FIXED_SIZE_FOR_3D_CHART_VOLUME/fLogicDiameter); + + aMatrix.TranslateY(fLogicDiameter/2.0); + aMatrix.ScaleY(FIXED_SIZE_FOR_3D_CHART_VOLUME/fLogicDiameter); + + aMatrix.ScaleZ(fScaleDirectionZ*FIXED_SIZE_FOR_3D_CHART_VOLUME); + + aMatrix = m_aMatrixScreenToScene*aMatrix; + + m_xTransformationLogicToScene = new Linear3DTransformation(Matrix4DToHomogenMatrix( aMatrix )); + } + return m_xTransformationLogicToScene; +} + +double PolarPlottingPositionHelper::getWidthAngleDegree( double& fStartLogicValueOnAngleAxis, double& fEndLogicValueOnAngleAxis ) const +{ + if( !this->isMathematicalOrientationY() ) + { + double fHelp = fEndLogicValueOnAngleAxis; + fEndLogicValueOnAngleAxis = fStartLogicValueOnAngleAxis; + fStartLogicValueOnAngleAxis = fHelp; + } + + double fStartAngleDegree = this->transformToAngleDegree( fStartLogicValueOnAngleAxis ); + double fEndAngleDegree = this->transformToAngleDegree( fEndLogicValueOnAngleAxis ); + double fWidthAngleDegree = fEndAngleDegree - fStartAngleDegree; + + while(fWidthAngleDegree<0.0) + fWidthAngleDegree+=360.0; + while(fWidthAngleDegree>360.0) + fWidthAngleDegree-=360.0; + + return fWidthAngleDegree; +} + +double PolarPlottingPositionHelper::transformToAngleDegree( double fLogicValueOnAngleAxis ) const +{ + double fRet=0.0; + + double fAxisAngleScaleDirection = 1.0; + { + const ExplicitScaleData& rScale = m_bRadiusAxisMapsToFirstDimension ? m_aScales[1] : m_aScales[0]; + if(AxisOrientation_MATHEMATICAL != rScale.Orientation) + fAxisAngleScaleDirection *= -1.0; + } + + double MinAngleValue = 0.0; + double MaxAngleValue = 0.0; + { + double MinX = getLogicMinX(); + double MinY = getLogicMinY(); + double MaxX = getLogicMaxX(); + double MaxY = getLogicMaxY(); + double MinZ = getLogicMinZ(); + double MaxZ = getLogicMaxZ(); + + doLogicScaling( &MinX, &MinY, &MinZ ); + doLogicScaling( &MaxX, &MaxY, &MaxZ); + + MinAngleValue = m_bRadiusAxisMapsToFirstDimension ? MinY : MinX; + MaxAngleValue = m_bRadiusAxisMapsToFirstDimension ? MaxY : MaxX; + } + + double fScaledLogicAngleValue = 0.0; + { + double fX = m_bRadiusAxisMapsToFirstDimension ? getLogicMaxX() : fLogicValueOnAngleAxis; + double fY = m_bRadiusAxisMapsToFirstDimension ? fLogicValueOnAngleAxis : getLogicMaxY(); + double fZ = getLogicMaxZ(); + clipLogicValues( &fX, &fY, &fZ ); + doLogicScaling( &fX, &fY, &fZ ); + fScaledLogicAngleValue = m_bRadiusAxisMapsToFirstDimension ? fY : fX; + } + + fRet = m_fAngleDegreeOffset + + fAxisAngleScaleDirection*(fScaledLogicAngleValue-MinAngleValue)*360.0 + /fabs(MaxAngleValue-MinAngleValue); + while(fRet>360.0) + fRet-=360.0; + while(fRet<0) + fRet+=360.0; + return fRet; +} + +double PolarPlottingPositionHelper::transformToRadius( double fLogicValueOnRadiusAxis ) const +{ + double fRet=0.0; + + double fScaledLogicRadiusValue = 0.0; + { + double fX = m_bRadiusAxisMapsToFirstDimension ? fLogicValueOnRadiusAxis: getLogicMaxX(); + double fY = m_bRadiusAxisMapsToFirstDimension ? getLogicMaxY() : fLogicValueOnRadiusAxis; + doLogicScaling( &fX, &fY, 0 ); + + fScaledLogicRadiusValue = m_fRadiusOffset + ( m_bRadiusAxisMapsToFirstDimension ? fX : fY ); + + bool bMinIsInnerRadius = true; + const ExplicitScaleData& rScale = m_bRadiusAxisMapsToFirstDimension ? m_aScales[0] : m_aScales[1]; + if(AxisOrientation_MATHEMATICAL != rScale.Orientation) + bMinIsInnerRadius = false; + if(bMinIsInnerRadius) + { + double MinX = getLogicMinX(); + double MinY = getLogicMinY(); + doLogicScaling( &MinX, &MinY, 0 ); + fScaledLogicRadiusValue -= ( m_bRadiusAxisMapsToFirstDimension ? MinX : MinY ); + } + else + { + double MaxX = getLogicMaxX(); + double MaxY = getLogicMaxY(); + doLogicScaling( &MaxX, &MaxY, 0 ); + fScaledLogicRadiusValue -= ( m_bRadiusAxisMapsToFirstDimension ? MaxX : MaxY ); + } + } + return fScaledLogicRadiusValue; +} + +drawing::Position3D PolarPlottingPositionHelper::transformLogicToScene( double fLogicValueOnAngleAxis, double fLogicValueOnRadiusAxis, double fLogicZ ) const +{ + double fAngleDegree = this->transformToAngleDegree(fLogicValueOnAngleAxis); + double fAnglePi = fAngleDegree*F_PI/180.0; + double fRadius = this->transformToRadius(fLogicValueOnRadiusAxis); + drawing::Position3D aLogicPos(fRadius*cos(fAnglePi),fRadius*sin(fAnglePi),fLogicZ+0.5); + drawing::Position3D aScenePosition3D( SequenceToPosition3D( + this->getTransformationLogicToScene()->transform( + Position3DToSequence(aLogicPos) ) ) ); + return aScenePosition3D; +} + +double PolarPlottingPositionHelper::getInnerLogicRadius() const +{ + const ExplicitScaleData& rScale = m_bRadiusAxisMapsToFirstDimension ? m_aScales[0] : m_aScales[1]; + if( AxisOrientation_MATHEMATICAL==rScale.Orientation ) + return rScale.Minimum; + else + return rScale.Maximum; +} + +double PolarPlottingPositionHelper::getOuterLogicRadius() const +{ + const ExplicitScaleData& rScale = m_bRadiusAxisMapsToFirstDimension ? m_aScales[0] : m_aScales[1]; + if( AxisOrientation_MATHEMATICAL==rScale.Orientation ) + return rScale.Maximum; + else + return rScale.Minimum; +} + +/* +// ____ XTransformation ____ +uno::Sequence< double > SAL_CALL PolarPlottingPositionHelper::transform( + const uno::Sequence< double >& rSourceValues ) + throw (uno::RuntimeException, lang::IllegalArgumentException) +{ + uno::Sequence< double > aSourceValues(3); + return aSourceValues; +} + +sal_Int32 SAL_CALL PolarPlottingPositionHelper::getSourceDimension() throw (uno::RuntimeException) +{ + return 3; +} + +sal_Int32 SAL_CALL PolarPlottingPositionHelper::getTargetDimension() throw (uno::RuntimeException) +{ + return 3; +} +*/ + //............................................................................. } //namespace chart //............................................................................. diff --git a/chart2/source/view/main/PolarLabelPositionHelper.cxx b/chart2/source/view/main/PolarLabelPositionHelper.cxx new file mode 100644 index 000000000000..478a081fed30 --- /dev/null +++ b/chart2/source/view/main/PolarLabelPositionHelper.cxx @@ -0,0 +1,201 @@ +/************************************************************************* + * + * $RCSfile: PolarLabelPositionHelper.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: iha $ $Date: 2004-01-17 13:10:07 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2003 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include "PolarLabelPositionHelper.hxx" +#include "PlottingPositionHelper.hxx" +#include "CommonConverters.hxx" + +// header for class Vector2D +#ifndef _VECTOR2D_HXX +#include <tools/vector2d.hxx> +#endif + +//............................................................................. +namespace chart +{ +//............................................................................. +using namespace ::com::sun::star; +using namespace ::drafts::com::sun::star::chart2; + +PolarLabelPositionHelper::PolarLabelPositionHelper( + PolarPlottingPositionHelper* pPosHelper + , sal_Int32 nDimensionCount + , const uno::Reference< drawing::XShapes >& xLogicTarget + , ShapeFactory* pShapeFactory ) + : LabelPositionHelper( pPosHelper, nDimensionCount, xLogicTarget, pShapeFactory ) + , m_pPosHelper(pPosHelper) +{ +} + +PolarLabelPositionHelper::~PolarLabelPositionHelper() +{ +} + +awt::Point PolarLabelPositionHelper::getLabelScreenPositionAndAlignment( + LabelAlignment& rAlignment, bool bOutsidePosition + , double fStartLogicValueOnAngleAxis, double fEndLogicValueOnAngleAxis + , double fLogicInnerRadius, double fLogicOuterRadius + , double fLogicZ) const +{ + double fWidthAngleDegree = m_pPosHelper->getWidthAngleDegree( fStartLogicValueOnAngleAxis, fEndLogicValueOnAngleAxis ); + double fStartAngleDegree = m_pPosHelper->transformToAngleDegree( fStartLogicValueOnAngleAxis ); + double fAngleDegree = fStartAngleDegree + fWidthAngleDegree/2.0; + double fAnglePi = fAngleDegree*F_PI/180.0; + + double fInnerRadius = m_pPosHelper->transformToRadius(fLogicInnerRadius); + double fOuterRadius = m_pPosHelper->transformToRadius(fLogicOuterRadius); + + double fRadius = 0.0; + if( bOutsidePosition ) //e.g. for pure pie chart(one ring only) or for angle axis of polyar coordinate system + { + fRadius = fOuterRadius; + if(3!=m_nDimensionCount) + fRadius += 0.1*fOuterRadius; + } + else + fRadius = fInnerRadius + (fOuterRadius-fInnerRadius)/2.0 ; + + if(3==m_nDimensionCount) + fAnglePi *= -1.0; + drawing::Position3D aLogicPos(fRadius*cos(fAnglePi),fRadius*sin(fAnglePi),fLogicZ+0.5); + awt::Point aRet( this->transformLogicToScreenPosition( aLogicPos ) ); + + if(3==m_nDimensionCount) + { + //check wether the upper or the downer edge is more distant from the center + //take the farest point to put the label to + drawing::Position3D aLogicPos2(fRadius*cos(fAnglePi),fRadius*sin(fAnglePi),fLogicZ-0.5); + drawing::Position3D aLogicCenter(0,0,fLogicZ); + + awt::Point aP0( this->transformLogicToScreenPosition( + drawing::Position3D(0,0,fLogicZ) ) ); + awt::Point aP1(aRet); + awt::Point aP2( this->transformLogicToScreenPosition( + drawing::Position3D(fRadius*cos(fAnglePi),fRadius*sin(fAnglePi),fLogicZ-0.5) ) ); + + Vector2D aV0( aP0.X, aP0.Y ); + Vector2D aV1( aP1.X, aP1.Y ); + Vector2D aV2( aP2.X, aP2.Y ); + + double fL1 = (aV1-aV0).GetLength(); + double fL2 = (aV2-aV0).GetLength(); + + if(fL2>fL1) + aRet = aP2; + + //calculate new angle for alignment + double fDX = aRet.X-aP0.X; + double fDY = aRet.Y-aP0.Y; + fDY*=-1.0;//drawing layer has inverse y values + if( fDX != 0.0 ) + { + fAngleDegree = atan(fDY/fDX)*180.0/F_PI; + if(fDX<0.0) + fAngleDegree+=180.0; + } + else + { + if(fDY>0.0) + fAngleDegree = 90.0; + else + fAngleDegree = 270.0; + } + } + //------------------------------ + //set LabelAlignment + if( bOutsidePosition ) + { + while(fAngleDegree>360.0) + fAngleDegree-=360.0; + while(fAngleDegree<0.0) + fAngleDegree+=360.0; + + if(fAngleDegree==0.0) + rAlignment = LABEL_ALIGN_CENTER; + else if(fAngleDegree<=22.5) + rAlignment = LABEL_ALIGN_RIGHT; + else if(fAngleDegree<67.5) + rAlignment = LABEL_ALIGN_RIGHT_TOP; + else if(fAngleDegree<112.5) + rAlignment = LABEL_ALIGN_TOP; + else if(fAngleDegree<=157.5) + rAlignment = LABEL_ALIGN_LEFT_TOP; + else if(fAngleDegree<=202.5) + rAlignment = LABEL_ALIGN_LEFT; + else if(fAngleDegree<247.5) + rAlignment = LABEL_ALIGN_LEFT_BOTTOM; + else if(fAngleDegree<292.5) + rAlignment = LABEL_ALIGN_BOTTOM; + else if(fAngleDegree<337.5) + rAlignment = LABEL_ALIGN_RIGHT_BOTTOM; + else + rAlignment = LABEL_ALIGN_RIGHT; + } + else + { + rAlignment = LABEL_ALIGN_CENTER; + } + return aRet; +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/view/main/PropertyMapper.cxx b/chart2/source/view/main/PropertyMapper.cxx index f372f811edd9..7c02cbc33e44 100644 --- a/chart2/source/view/main/PropertyMapper.cxx +++ b/chart2/source/view/main/PropertyMapper.cxx @@ -2,9 +2,9 @@ * * $RCSfile: PropertyMapper.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: bm $ $Date: 2003-10-17 14:50:28 $ + * last change: $Author: iha $ $Date: 2004-01-17 13:10:07 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -64,6 +64,15 @@ #ifndef _COM_SUN_STAR_BEANS_XMULTIPROPERTYSET_HPP_ #include <com/sun/star/beans/XMultiPropertySet.hpp> #endif +#ifndef _COM_SUN_STAR_DRAWING_LINESTYLE_HPP_ +#include <com/sun/star/drawing/LineStyle.hpp> +#endif +#ifndef _COM_SUN_STAR_DRAWING_TEXTVERTICALADJUST_HPP_ +#include <com/sun/star/drawing/TextVerticalAdjust.hpp> +#endif +#ifndef _COM_SUN_STAR_DRAWING_TEXTHORIZONTALADJUST_HPP_ +#include <com/sun/star/drawing/TextHorizontalAdjust.hpp> +#endif //............................................................................. namespace chart @@ -393,6 +402,49 @@ void PropertyMapper::setMultiProperties( } } +void PropertyMapper::getTextLabelMultiPropertyLists( + const uno::Reference< beans::XPropertySet >& xSourceProp + , tNameSequence& rPropNames, tAnySequence& rPropValues + , bool bName + , sal_Int32 nLimitedSpace + , bool bLimitedHeight ) +{ + //fill character properties into the ValueMap + tPropertyNameValueMap aValueMap; + PropertyMapper::getValueMap( aValueMap + , PropertyMapper::getPropertyNameMapForCharacterProperties() + , xSourceProp ); + + //some more shape properties apart from character properties, position-matrix and label string + aValueMap.insert( tPropertyNameValueMap::value_type( C2U("LineStyle"), uno::makeAny(drawing::LineStyle_NONE) ) ); // drawing::LineStyle + aValueMap.insert( tPropertyNameValueMap::value_type( C2U("TextHorizontalAdjust"), uno::makeAny(drawing::TextHorizontalAdjust_CENTER) ) ); // drawing::TextHorizontalAdjust - needs to be overwritten + aValueMap.insert( tPropertyNameValueMap::value_type( C2U("TextVerticalAdjust"), uno::makeAny(drawing::TextVerticalAdjust_CENTER) ) ); //drawing::TextVerticalAdjust - needs to be overwritten + //aValueMap.insert( tPropertyNameValueMap::value_type( C2U("TextWritingMode"), uno::makeAny(eWritingMode) ) ); //text::WritingMode + aValueMap.insert( tPropertyNameValueMap::value_type( C2U("TextAutoGrowHeight"), uno::makeAny(sal_True) ) ); // sal_Bool + aValueMap.insert( tPropertyNameValueMap::value_type( C2U("TextAutoGrowWidth"), uno::makeAny(sal_True) ) ); // sal_Bool + if( bName ) + aValueMap.insert( tPropertyNameValueMap::value_type( C2U("Name"), uno::makeAny( rtl::OUString() ) ) ); //CID rtl::OUString - needs to be overwritten for each point + + if( nLimitedSpace > 0 ) + { + if(bLimitedHeight) + aValueMap.insert( tPropertyNameValueMap::value_type( C2U("TextMaximumFrameHeight"), uno::makeAny(nLimitedSpace) ) ); //sal_Int32 + else + aValueMap.insert( tPropertyNameValueMap::value_type( C2U("TextMaximumFrameWidth"), uno::makeAny(nLimitedSpace) ) ); //sal_Int32 + } + + /* + //@todo ?: add paragraph properties: + //(uno::makeAny(eParaAdjust)) //ParaAdjust - style::ParagraphAdjust + //(uno::makeAny( (sal_Bool)rAxisLabelProperties.bLineBreakAllowed )) //ParaIsHyphenation - sal_Bool + style::ParagraphAdjust eParaAdjust( style::ParagraphAdjust_LEFT ); + if( eHorizontalAdjust == drawing::TextHorizontalAdjust_RIGHT ) + eParaAdjust = style::ParagraphAdjust_RIGHT; + */ + + PropertyMapper::getMultiPropertyListsFromValueMap( rPropNames, rPropValues, aValueMap ); +} + //............................................................................. } //namespace chart //............................................................................. diff --git a/chart2/source/view/main/ShapeFactory.cxx b/chart2/source/view/main/ShapeFactory.cxx index ab51ed7dd63e..6caae9919e95 100644 --- a/chart2/source/view/main/ShapeFactory.cxx +++ b/chart2/source/view/main/ShapeFactory.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ShapeFactory.cxx,v $ * - * $Revision: 1.17 $ + * $Revision: 1.18 $ * - * last change: $Author: iha $ $Date: 2004-01-06 19:38:32 $ + * last change: $Author: iha $ $Date: 2004-01-17 13:10:08 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -102,12 +102,6 @@ #ifndef _COM_SUN_STAR_DRAWING_TEXTFITTOSIZETYPE_HPP_ #include <com/sun/star/drawing/TextFitToSizeType.hpp> #endif -#ifndef _COM_SUN_STAR_DRAWING_TEXTVERTICALADJUST_HPP_ -#include <com/sun/star/drawing/TextVerticalAdjust.hpp> -#endif -#ifndef _COM_SUN_STAR_DRAWING_TEXTHORIZONTALADJUST_HPP_ -#include <com/sun/star/drawing/TextHorizontalAdjust.hpp> -#endif #ifndef _COM_SUN_STAR_TEXT_XTEXT_HPP_ #include <com/sun/star/text/XText.hpp> #endif @@ -713,6 +707,10 @@ uno::Reference<drawing::XShape> return xShape; } +//------------------------------------------------------------------------------------------------------------ +//------------------------------------------------------------------------------------------------------------ +//------------------------------------------------------------------------------------------------------------ + void appendBezierCoords( drawing::PolyPolygonBezierCoords& rReturn, const drawing::PolyPolygonBezierCoords& rAdd, sal_Bool bAppendInverse ) { if(!rAdd.Coordinates.getLength()) @@ -734,6 +732,8 @@ void appendBezierCoords( drawing::PolyPolygonBezierCoords& rReturn, const drawin } } +//------------------------------------------------------------------------------------------------------------ + drawing::PolyPolygonBezierCoords getCircularArcBezierCoords( double fAngleRadian , const Matrix3D& rTransformationFromUnitCircle ) @@ -815,6 +815,8 @@ drawing::PolyPolygonBezierCoords getCircularArcBezierCoords( return aReturn; } +//------------------------------------------------------------------------------------------------------------ + drawing::PolyPolygonBezierCoords getRingBezierCoords( double fInnerXRadius , double fOuterXRadius, double fOuterYRadius @@ -849,78 +851,16 @@ drawing::PolyPolygonBezierCoords getRingBezierCoords( return aReturn; } -/* -XPolygon ImpCalcXPoly(const Rectangle& rRect1, long nStart, long nEnd) -{ - long rx=rRect1.GetWidth()/2; // Da GetWidth()/GetHeight() jeweils 1 - long ry=rRect1.GetHeight()/2; // draufaddieren wird korrekt gerundet. - long a=0,e=3600; - { - a=nStart/10; - e=nEnd/10; - { - // Drehrichtung umkehren, damit Richtungssinn genauso wie Rechteck - rx=-rx; - a=1800-a; if (a<0) a+=3600; - e=1800-e; if (e<0) e+=3600; - long nTmp=a; - a=e; - e=nTmp; - } - } - FASTBOOL bClose=FALSE; - XPolygon aXPoly(rRect1.Center(),rx,ry,USHORT(a),USHORT(e),bClose); - if (nStart==nEnd) - { - Point aMerk(aXPoly[0]); - aXPoly=XPolygon(2); - aXPoly[0]=rRect1.Center(); - aXPoly[1]=aMerk; - } - { // Der Sektor soll Start/Ende im Zentrum haben - // Polygon um einen Punkt rotieren (Punkte im Array verschieben) - unsigned nPointAnz=aXPoly.GetPointCount(); - aXPoly.Insert(0,rRect1.Center(),XPOLY_NORMAL); - aXPoly[aXPoly.GetPointCount()]=rRect1.Center(); - } - // Die Winkelangaben beziehen sich immer auf die linke obere Ecke von !aRect! -// if (aGeo.nShearWink!=0) ShearXPoly(aXPoly,aRect.TopLeft(),aGeo.nTan); -// if (aGeo.nDrehWink!=0) RotateXPoly(aXPoly,aRect.TopLeft(),aGeo.nSin,aGeo.nCos); - return aXPoly; -} -*/ + +//------------------------------------------------------------------------------------------------------------ + uno::Reference< drawing::XShape > ShapeFactory::createPieSegment2D( const uno::Reference< drawing::XShapes >& xTarget - , const DataPointGeometry& rGeometry ) + , double fStartAngleDegree, double fWidthAngleDegree + , double fInnerXRadius, double fOuterXRadius, double fOuterYRadius + , const drawing::Position3D& rOrigin ) { - /* - DataPointGeometry aLogicGeom( drawing::Position3D(0.0,0.0,0.0) - , drawing::Direction3D(fOuterXDiameter,fOuterYDiameter,fDepth) - , drawing::Direction3D(fInnerXDiameter,fStartAngleDegree,fWidthAngleDegree) ); - */ - - double fInnerXRadius = rGeometry.m_aSize2.DirectionX/2.0; - //only test - //fInnerXRadius = 0.0; - //if( fInnerXRadius > 0.0 ) return NULL; - - double fOuterXRadius = rGeometry.m_aSize.DirectionX/2.0; - double fOuterYRadius = rGeometry.m_aSize.DirectionY/2.0; - - double fStartAngleDegree = rGeometry.m_aSize2.DirectionY; - double fWidthAngleDegree = rGeometry.m_aSize2.DirectionZ; - - /* - DBG_ASSERT(fOuterXRadius>0, "The radius of a pie needs to be > 0"); - DBG_ASSERT(fInnerXRadius>=0, "The inner radius of a pie needs to be >= 0"); - DBG_ASSERT(fOuterXRadius>fInnerXRadius, "The outer radius needs to be greater than the inner radius of a pie"); - DBG_ASSERT(fOuterYRadius>0, "The radius of a pie needs to be > 0"); - - DBG_ASSERT(fWidthAngleDegree>0, "The angle of a pie needs to be > 0"); - DBG_ASSERT(fWidthAngleDegree<=360, "The angle of a pie needs to be <= 360 degree"); - */ - while(fWidthAngleDegree>360) fWidthAngleDegree -= 360.0; while(fWidthAngleDegree<0) @@ -929,25 +869,8 @@ uno::Reference< drawing::XShape > //create shape uno::Reference< drawing::XShape > xShape( m_xShapeFactory->createInstance( -// C2U("com.sun.star.drawing.EllipseShape") ), uno::UNO_QUERY ); -// C2U("com.sun.star.drawing.PolyPolygonShape") ), uno::UNO_QUERY ); -// C2U("com.sun.star.drawing.OpenFreeHandShape") ), uno::UNO_QUERY ); C2U("com.sun.star.drawing.ClosedBezierShape") ), uno::UNO_QUERY ); -// C2U("com.sun.star.drawing.LineShape") ), uno::UNO_QUERY ); -// C2U("com.sun.star.drawing.PolyLineShape") ), uno::UNO_QUERY ); - - //need to add the shape before setting of properties - xTarget->add(xShape); - - //need left upper corner not the middle of the circle (!! x and y are assumed to scale in the same way here) - double fXPos = rGeometry.m_aPosition.PositionX; - double fYPos = rGeometry.m_aPosition.PositionY; - - double fXSize = rGeometry.m_aSize.DirectionX; - double fYSize = rGeometry.m_aSize.DirectionY; - - fXPos -= fXSize/2.0; - fYPos -= fYSize/2.0; + xTarget->add(xShape); //need to add the shape before setting of properties //set properties uno::Reference< beans::XPropertySet > xProp( xShape, uno::UNO_QUERY ); @@ -956,171 +879,31 @@ uno::Reference< drawing::XShape > { try { - /* - Matrix3D aTransformationFromUnitCircle; - aTransformationFromUnitCircle.Rotate(fStartAngleDegree*F_PI/180.0); - aTransformationFromUnitCircle.ScaleX(fInnerXRadius+fXWidthRadius); - aTransformationFromUnitCircle.ScaleY(fInnerXRadius+fXWidthRadius); - aTransformationFromUnitCircle.TranslateX(rGeometry.m_aPosition.PositionX); - aTransformationFromUnitCircle.TranslateY(rGeometry.m_aPosition.PositionY); - drawing::PolyPolygonBezierCoords aCoords = getCircularArcBezierCoords( fWidthAngleDegree * F_PI/180.0 - , aTransformationFromUnitCircle ); - */ - drawing::PolyPolygonBezierCoords aCoords = getRingBezierCoords( fInnerXRadius, fOuterXRadius, fOuterYRadius , fWidthAngleDegree*F_PI/180.0, fStartAngleDegree*F_PI/180.0 - , rGeometry.m_aPosition.PositionX, rGeometry.m_aPosition.PositionY); - xProp->setPropertyValue( C2U( "PolyPolygonBezier" ) - , uno::makeAny( aCoords ) ); - - /* - Rectangle aRect(fXPos,fYPos+fYSize,fXPos+fXSize,fYPos); - XPolygon aXPolygon = ImpCalcXPoly(aRect - , fStartAngleDegree*100.0 - , (fStartAngleDegree+fWidthAngleDegree)*100.0); - - sal_Int32 nCount = aXPolygon.GetSize(); - if( nCount > 0 ) - { - */ - /* - drawing::PointSequence aSeq( nCount ); - awt::Point* pSequence = aSeq.getArray(); - - for(sal_Int32 b=0;b<nCount;b++) - { - *pSequence = awt::Point( aXPolygon[b].X(), aXPolygon[b].Y() ); - pSequence++; - } - */ - /* - - drawing::PointSequence aSeq( 4 ); - awt::Point* pSequence = aSeq.getArray(); - pSequence[0] = awt::Point( 0, 0 ); - pSequence[1] = awt::Point( 10000, -10000 ); - pSequence[2] = awt::Point( 10000, 0 ); - pSequence[3] = awt::Point( 0, 0 ); - - - //UNO_NAME_POLYGON drawing::PointSequence* - xProp->setPropertyValue( C2U( UNO_NAME_POLYGON ) - , uno::makeAny( aSeq ) ); - } - */ - -/* -UNO_NAME_POLYGONKIND "PolygonKind" drawing::PolygonKind* (readonly) - -UNO_NAME_POLYPOLYGON "PolyPolygon" drawing::PointSequenceSequence* -UNO_NAME_POLYGON "Polygon" drawing::PointSequence* + , rOrigin.PositionX, rOrigin.PositionY); -UNO_NAME_POLYPOLYGONBEZIER "PolyPolygonBezier" drawing::PolyPolygonBezierCoords* -*/ - - /* - //UNO_NAME_CIRCKIND drawing::CircleKind - xProp->setPropertyValue( C2U( UNO_NAME_CIRCKIND ) - , uno::makeAny(drawing::CircleKind_SECTION) ); - - double factor = 100.0; - - //UNO_NAME_CIRCSTARTANGLE sal_Int32 - xProp->setPropertyValue( C2U( UNO_NAME_CIRCSTARTANGLE ) - , uno::makeAny((sal_Int32)(fStartAngleDegree*factor)) ); - - //UNO_NAME_CIRCENDANGLE sal_Int32 - xProp->setPropertyValue( C2U( UNO_NAME_CIRCENDANGLE ) - , uno::makeAny((sal_Int32)((fStartAngleDegree+fWidthAngleDegree)*factor)) ); - */ + xProp->setPropertyValue( C2U( "PolyPolygonBezier" ), uno::makeAny( aCoords ) ); } catch( uno::Exception& e ) { ASSERT_EXCEPTION( e ); } } - -// xShape->setPosition(awt::Point(rGeometry.m_aPosition.PositionX,rGeometry.m_aPosition.PositionY)); - -// xShape->setPosition(awt::Point(fXPos,fYPos)); -// xShape->setSize(awt::Size(fXSize,fYSize)); - - /* - xShape->setPosition(awt::Point(100,100)); - xShape->setSize(awt::Size(10000,10000)); - */ - - /* - //create shape - uno::Reference< drawing::XShape > xShape( - m_xShapeFactory->createInstance( - //C2U("com.sun.star.drawing.EllipseShape") ), uno::UNO_QUERY ); - C2U("com.sun.star.drawing.Shape3DExtrudeObject") ), uno::UNO_QUERY ); - - xTarget->add(xShape); - - //set properties - uno::Reference< beans::XPropertySet > xProp( xShape, uno::UNO_QUERY ); - DBG_ASSERT(xProp.is(), "created shape offers no XPropertySet"); - if( xProp.is()) - { - try - { - //UNO_NAME_CIRCKIND drawing::CircleKind - xProp->setPropertyValue( C2U( UNO_NAME_CIRCKIND ) - , uno::makeAny(drawing::CircleKind_SECTION) ); - - double factor = 100.0; - - //UNO_NAME_CIRCSTARTANGLE sal_Int32 - xProp->setPropertyValue( C2U( UNO_NAME_CIRCSTARTANGLE ) - , uno::makeAny((sal_Int32)(fStartAngleDegree*factor)) ); - - //UNO_NAME_CIRCENDANGLE sal_Int32 - xProp->setPropertyValue( C2U( UNO_NAME_CIRCENDANGLE ) - , uno::makeAny((sal_Int32)((fStartAngleDegree+fWidthAngleDegree)*factor)) ); - } - catch( uno::Exception& e ) - { - e; - } - } - //need left upper corner not the middle of the circle (!! x and y are assumed to scale in the same way here) - double fXPos = rGeometry.m_aPosition.PositionX; - double fYPos = rGeometry.m_aPosition.PositionY; - - double fXSize = rGeometry.m_aSize.DirectionX; - double fYSize = rGeometry.m_aSize.DirectionY; - - fXPos -= fXSize/2.0; - fYPos -= fYSize/2.0; - - xShape->setPosition(awt::Point(fXPos,fYPos)); - xShape->setSize(awt::Size(fXSize,fYSize)); - */ return xShape; } +//------------------------------------------------------------------------------------------------------------ + uno::Reference< drawing::XShape > ShapeFactory::createPieSegment( const uno::Reference< drawing::XShapes >& xTarget - , const DataPointGeometry& rGeometry ) + , double fStartAngleDegree, double fWidthAngleDegree + , double fInnerXRadius, double fOuterXRadius, double fOuterYRadius + , const drawing::Position3D& rOrigin + , double fDepth ) { - double fInnerXRadius = rGeometry.m_aSize2.DirectionX/2.0; - double fXWidthRadius = rGeometry.m_aSize.DirectionX/2.0 - fInnerXRadius; - - double fDepth = rGeometry.m_aSize.DirectionZ; - - double fStartAngleDegree = rGeometry.m_aSize2.DirectionY; - double fWidthAngleDegree = rGeometry.m_aSize2.DirectionZ; - - DBG_ASSERT(fDepth>0, "The height of a pie needs to be > 0"); - DBG_ASSERT(fXWidthRadius>0, "The radius of a pie needs to be > 0"); - DBG_ASSERT(fInnerXRadius>=0, "The inner radius of a pie needs to be > 0"); - DBG_ASSERT(fWidthAngleDegree>0, "The angle of a pie needs to be > 0"); - DBG_ASSERT(fWidthAngleDegree<=360, "The angle of a pie needs to be <= 360 degree"); - while(fWidthAngleDegree>360) fWidthAngleDegree -= 360.0; while(fWidthAngleDegree<0) @@ -1130,8 +913,7 @@ uno::Reference< drawing::XShape > uno::Reference< drawing::XShape > xShape( m_xShapeFactory->createInstance( C2U("com.sun.star.drawing.Shape3DLatheObject") ), uno::UNO_QUERY ); - - xTarget->add(xShape); + xTarget->add(xShape); //need to add the shape before setting of properties //set properties uno::Reference< beans::XPropertySet > xProp( xShape, uno::UNO_QUERY ); @@ -1140,6 +922,8 @@ uno::Reference< drawing::XShape > { try { + double fXWidthRadius = fOuterXRadius - fInnerXRadius; + //PercentDiagonal xProp->setPropertyValue( C2U( UNO_NAME_3D_PERCENT_DIAGONAL ) , uno::makeAny((sal_Int16)0) ); @@ -1155,9 +939,9 @@ uno::Reference< drawing::XShape > //Matrix for position { Matrix4D aM4; - aM4.ScaleZ(rGeometry.m_aSize.DirectionY/rGeometry.m_aSize.DirectionX); + aM4.ScaleZ(fOuterYRadius/fOuterXRadius); aM4.RotateY( ZDIRECTION*fStartAngleDegree*F_PI/180.0 ); - aM4.Translate(rGeometry.m_aPosition.PositionX, rGeometry.m_aPosition.PositionZ, rGeometry.m_aPosition.PositionY); + aM4.Translate(rOrigin.PositionX, rOrigin.PositionZ, rOrigin.PositionY); drawing::HomogenMatrix aHM = Matrix4DToHomogenMatrix(aM4); xProp->setPropertyValue( C2U( UNO_NAME_3D_TRANSFORM_MATRIX ) , uno::makeAny(aHM) ); @@ -1177,6 +961,10 @@ uno::Reference< drawing::XShape > return xShape; } +//------------------------------------------------------------------------------------------------------------ +//------------------------------------------------------------------------------------------------------------ +//------------------------------------------------------------------------------------------------------------ + uno::Reference< drawing::XShape > ShapeFactory::createStripe( const uno::Reference< drawing::XShapes >& xTarget , const Stripe& rStripe @@ -1981,66 +1769,6 @@ uno::Reference< drawing::XShape > } } return xShape; - /* - //create 3D anchor shape - uno::Reference< drawing::XShape > xShape3DAnchor = createCube( xTarget3D - , DataPointGeometry( rGeometry.m_aPosition,drawing::Direction3D(1000,1000,1000) ) - , ...); - //get 2D position from xShape3DAnchor - //the 2D position of the 3D Shape is not correct initially this is a bug in draw @todo - //awt::Point aPosition2D( xShape3DAnchor->getPosition() ); - */ - - //-- - /* - uno::Reference< text::XTextRange > xTextRange( xShape2DText, uno::UNO_QUERY ); - uno::Reference< text::XText > xText11( xShape2DText, uno::UNO_QUERY ); - if( xTextRange.is() ) - { - uno::Reference< text::XText > xText = xTextRange->getText(); - - xText->insertString( xTextRange, C2U( "Hello" ), true ); - xText->insertControlCharacter( xTextRange, - text::ControlCharacter::LINE_BREAK, false ); - xText->insertString( xTextRange, C2U( "World" ), false ); - - rtl::OUString aTmp = xText->getString(); - int a=1; - } - */ - - //-- - /* - //get the created paragraph and set the character properties there - uno::Reference< container::XEnumerationAccess > xEnumerationAccess( xShape, uno::UNO_QUERY ); - uno::Reference< container::XEnumeration > xEnumeration = xEnumerationAccess->createEnumeration(); - uno::Any aAParagraph = xEnumeration->nextElement(); - uno::Reference< text::XTextContent > xTextContent = NULL; - aAParagraph >>= xTextContent; - uno::Reference< beans::XPropertySet > xParaProp( xTextContent, uno::UNO_QUERY ); - if(xParaProp.is()) - { - try - { - //test: - //ControlTextEmphasis - //FontEmphasisMark - //CharEmphasis - xParaProp->setPropertyValue( C2U( "CharEmphasize" ), - uno::makeAny( text::FontEmphasis::DOT_ABOVE ) ); - - xParaProp->setPropertyValue( C2U( "FontEmphasisMark" ), - uno::makeAny( sal_Int16(2) ) ); - - xParaProp->setPropertyValue( C2U( "ControlTextEmphasis" ), - uno::makeAny( sal_Int16(2) ) ); - } - catch( uno::Exception& e ) - { - e; - } - } - */ } //static diff --git a/chart2/source/view/main/VDataSeries.cxx b/chart2/source/view/main/VDataSeries.cxx index 253003b095d0..a0853c523cac 100644 --- a/chart2/source/view/main/VDataSeries.cxx +++ b/chart2/source/view/main/VDataSeries.cxx @@ -2,9 +2,9 @@ * * $RCSfile: VDataSeries.cxx,v $ * - * $Revision: 1.19 $ + * $Revision: 1.20 $ * - * last change: $Author: iha $ $Date: 2004-01-06 19:39:38 $ + * last change: $Author: iha $ $Date: 2004-01-17 13:10:08 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -421,45 +421,6 @@ DataPointLabel* VDataSeries::getDataPointLabelIfLabel( sal_Int32 index ) const return pLabel; } -void createTextLabelMultiPropertyListsFromPropertySet( - const uno::Reference< beans::XPropertySet >& xSourceProp - , ::std::auto_ptr< tNameSequence >& rLabelPropNames - , ::std::auto_ptr< tAnySequence >& rLabelPropValues - ) -{ - tPropertyNameValueMap aValueMap; - - //fill character properties into the ValueMap - PropertyMapper::getValueMap( aValueMap - , PropertyMapper::getPropertyNameMapForCharacterProperties() - , uno::Reference< beans::XPropertySet >::query( xSourceProp ) //Text Properties source - ); - - //------------------------- - //some more shape properties apart from character properties, position-matrix and label string - - //@todo get correct horizontal and vertical adjust and writing mode - drawing::TextHorizontalAdjust eHorizontalAdjust = drawing::TextHorizontalAdjust_CENTER; - drawing::TextVerticalAdjust eVerticalAdjust = drawing::TextVerticalAdjust_CENTER; - //text::WritingMode eWritingMode = text::WritingMode_LR_TB;//@todo get correct one - - aValueMap.insert( tPropertyNameValueMap::value_type( C2U("LineStyle"), uno::makeAny(drawing::LineStyle_NONE) ) ); // drawing::LineStyle - aValueMap.insert( tPropertyNameValueMap::value_type( C2U("TextHorizontalAdjust"), uno::makeAny(eHorizontalAdjust) ) ); // drawing::TextHorizontalAdjust - aValueMap.insert( tPropertyNameValueMap::value_type( C2U("TextVerticalAdjust"), uno::makeAny(eVerticalAdjust) ) ); //drawing::TextVerticalAdjust - //aValueMap.insert( tPropertyNameValueMap::value_type( C2U("TextWritingMode"), uno::makeAny(eWritingMode) ) ); //text::WritingMode - aValueMap.insert( tPropertyNameValueMap::value_type( C2U("TextAutoGrowHeight"), uno::makeAny(sal_True) ) ); // sal_Bool - aValueMap.insert( tPropertyNameValueMap::value_type( C2U("TextAutoGrowWidth"), uno::makeAny(sal_True) ) ); // sal_Bool - aValueMap.insert( tPropertyNameValueMap::value_type( C2U("Name"), uno::makeAny( rtl::OUString() ) ) ); //CID rtl::OUString - needs to be overwritten for each point - - //------------------------- - tNameSequence* pPropNames = new tNameSequence(); - tAnySequence* pPropValues = new tAnySequence(); - PropertyMapper::getMultiPropertyListsFromValueMap( *pPropNames, *pPropValues, aValueMap ); - - rLabelPropNames = ::std::auto_ptr< tNameSequence >(pPropNames); - rLabelPropValues = ::std::auto_ptr< tAnySequence >(pPropValues); -} - bool VDataSeries::getTextLabelMultiPropertyLists( sal_Int32 index , tNameSequence*& pPropNames , tAnySequence*& pPropValues ) const @@ -469,10 +430,13 @@ bool VDataSeries::getTextLabelMultiPropertyLists( sal_Int32 index { if(!m_apLabelPropValues_AttributedPoint.get() || m_nCurrentAttributedPoint!=index) { - createTextLabelMultiPropertyListsFromPropertySet( - this->getPropertiesOfPoint( index ) - , m_apLabelPropNames_AttributedPoint - , m_apLabelPropValues_AttributedPoint ); + pPropNames = new tNameSequence(); + pPropValues = new tAnySequence(); + PropertyMapper::getTextLabelMultiPropertyLists( + this->getPropertiesOfPoint( index ), *pPropNames, *pPropValues ); + m_apLabelPropNames_AttributedPoint = ::std::auto_ptr< tNameSequence >(pPropNames); + m_apLabelPropValues_AttributedPoint = ::std::auto_ptr< tAnySequence >(pPropValues); + m_nCurrentAttributedPoint = index; } pPropNames = m_apLabelPropNames_AttributedPoint.get(); @@ -482,10 +446,12 @@ bool VDataSeries::getTextLabelMultiPropertyLists( sal_Int32 index { if(!m_apLabelPropValues_Series.get()) { - createTextLabelMultiPropertyListsFromPropertySet( - this->getPropertiesOfPoint( index ) - , m_apLabelPropNames_Series - , m_apLabelPropValues_Series ); + pPropNames = new tNameSequence(); + pPropValues = new tAnySequence(); + PropertyMapper::getTextLabelMultiPropertyLists( + this->getPropertiesOfPoint( index ), *pPropNames, *pPropValues ); + m_apLabelPropNames_Series = ::std::auto_ptr< tNameSequence >(pPropNames); + m_apLabelPropValues_Series = ::std::auto_ptr< tAnySequence >(pPropValues); } pPropNames = m_apLabelPropNames_Series.get(); pPropValues = m_apLabelPropValues_Series.get(); diff --git a/chart2/source/view/main/makefile.mk b/chart2/source/view/main/makefile.mk index 099b7344876c..87a890778997 100644 --- a/chart2/source/view/main/makefile.mk +++ b/chart2/source/view/main/makefile.mk @@ -2,9 +2,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.5 $ +# $Revision: 1.6 $ # -# last change: $Author: iha $ $Date: 2003-12-15 19:36:25 $ +# last change: $Author: iha $ $Date: 2004-01-17 13:10:08 $ # # The Contents of this file are made available subject to the terms of # either of the following licenses @@ -86,6 +86,8 @@ SLOFILES = \ $(SLO)$/Linear3DTransformation.obj \ $(SLO)$/Clipping.obj \ $(SLO)$/PlottingPositionHelper.obj \ + $(SLO)$/LabelPositionHelper.obj \ + $(SLO)$/PolarLabelPositionHelper.obj \ $(SLO)$/PlotterBase.obj \ $(SLO)$/VDataSeries.obj \ $(SLO)$/VLegend.obj \ |