diff options
author | Björn Milcke <bm@openoffice.org> | 2003-10-06 08:58:36 +0000 |
---|---|---|
committer | Björn Milcke <bm@openoffice.org> | 2003-10-06 08:58:36 +0000 |
commit | 668c6b0245b6076ac8fb3f5d734795117188675e (patch) | |
tree | 363512534f7fae13719bddccb3a365e48ef7a8d3 /chart2/source/view/main | |
parent | 2ccbe3d78ecfa9aa1527db50d304a277d3cdbe64 (diff) |
initial import
Diffstat (limited to 'chart2/source/view/main')
-rw-r--r-- | chart2/source/view/main/ChartView.cxx | 627 | ||||
-rw-r--r-- | chart2/source/view/main/Linear3DTransformation.cxx | 136 | ||||
-rw-r--r-- | chart2/source/view/main/NumberFormatterWrapper.cxx | 208 | ||||
-rw-r--r-- | chart2/source/view/main/PlotterBase.cxx | 244 | ||||
-rw-r--r-- | chart2/source/view/main/PlottingPositionHelper.cxx | 188 | ||||
-rw-r--r-- | chart2/source/view/main/PropertyMapper.cxx | 358 | ||||
-rw-r--r-- | chart2/source/view/main/ShapeFactory.cxx | 1978 | ||||
-rw-r--r-- | chart2/source/view/main/Stripe.cxx | 197 | ||||
-rw-r--r-- | chart2/source/view/main/VDataSeries.cxx | 500 | ||||
-rw-r--r-- | chart2/source/view/main/VLegend.cxx | 72 | ||||
-rw-r--r-- | chart2/source/view/main/VLegend.hxx | 81 | ||||
-rw-r--r-- | chart2/source/view/main/VTitle.cxx | 314 | ||||
-rw-r--r-- | chart2/source/view/main/VTitle.hxx | 121 | ||||
-rw-r--r-- | chart2/source/view/main/makefile.mk | 95 |
14 files changed, 5119 insertions, 0 deletions
diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx new file mode 100644 index 000000000000..1a13f806dc38 --- /dev/null +++ b/chart2/source/view/main/ChartView.cxx @@ -0,0 +1,627 @@ +/************************************************************************* + * + * $RCSfile: ChartView.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: bm $ $Date: 2003-10-06 09:58:34 $ + * + * 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 "ChartViewImpl.hxx" +#include "PlottingPositionHelper.hxx" +#include "ViewDefines.hxx" +#include "VDiagram.hxx" +#include "VTitle.hxx" +#include "ShapeFactory.hxx" +#include "VAxis.hxx" +#include "VSeriesPlotter.hxx" +#include "CommonConverters.hxx" +#include "macros.hxx" +#include "TitleHelper.hxx" + +#ifndef _DRAFTS_COM_SUN_STAR_CHART2_AXISORIENTATION_HPP_ +#include <drafts/com/sun/star/chart2/AxisOrientation.hpp> +#endif +#ifndef _DRAFTS_COM_SUN_STAR_CHART2_EXPLICITSUBINCREMENT_HPP_ +#include <drafts/com/sun/star/chart2/ExplicitSubIncrement.hpp> +#endif +#ifndef _DRAFTS_COM_SUN_STAR_CHART2_XAXISCONTAINER_HPP_ +#include <drafts/com/sun/star/chart2/XAxisContainer.hpp> +#endif +#ifndef _DRAFTS_COM_SUN_STAR_CHART2_XCHARTDOCUMENT_HPP_ +#include <drafts/com/sun/star/chart2/XChartDocument.hpp> +#endif +#ifndef _DRAFTS_COM_SUN_STAR_CHART2_XCHARTTYPEGROUP_HPP_ +#include <drafts/com/sun/star/chart2/XChartTypeGroup.hpp> +#endif +#ifndef _DRAFTS_COM_SUN_STAR_CHART2_XDATASERIES_HPP_ +#include <drafts/com/sun/star/chart2/XDataSeries.hpp> +#endif +#ifndef _DRAFTS_COM_SUN_STAR_CHART2_XDIAGRAM_HPP_ +#include <drafts/com/sun/star/chart2/XDiagram.hpp> +#endif +#ifndef _DRAFTS_COM_SUN_STAR_CHART2_XGRIDCONTAINER_HPP_ +#include <drafts/com/sun/star/chart2/XGridContainer.hpp> +#endif +#ifndef _DRAFTS_COM_SUN_STAR_CHART2_XSTACKABLESCALEGROUP_HPP_ +#include <drafts/com/sun/star/chart2/XStackableScaleGroup.hpp> +#endif +#ifndef _DRAFTS_COM_SUN_STAR_CHART2_XTITLED_HPP_ +#include <drafts/com/sun/star/chart2/XTitled.hpp> +#endif + +//............................................................................. +namespace chart +{ +//............................................................................. + +using namespace ::com::sun::star; +using namespace ::drafts::com::sun::star::chart2; + +//static +ChartView* ChartView::createView( + const uno::Reference< uno::XComponentContext >& xCC + , const uno::Reference< frame::XModel >& xChartModel + , const uno::Reference<drawing::XDrawPagesSupplier>& xDrawPagesSuplier + , NumberFormatterWrapper* pNumberFormatterWrapper ) +{ + return new ChartViewImpl(xCC,xChartModel,xDrawPagesSuplier,pNumberFormatterWrapper); +} + +ChartViewImpl::ChartViewImpl( + const uno::Reference< uno::XComponentContext >& xCC + , const uno::Reference< frame::XModel >& xChartModel + , const uno::Reference<drawing::XDrawPagesSupplier>& xDrawPagesSuplier + , NumberFormatterWrapper* pNumberFormatterWrapper ) + : m_xCC(xCC) + , m_xChartModel(xChartModel) + , m_xShapeFactory(NULL) + , m_xDrawPage(NULL) + , m_pNumberFormatterWrapper( pNumberFormatterWrapper ) + , m_pVDiagram(NULL) + , m_pVLegend(NULL) + , m_pVTitle(NULL) + , m_pVSubtitle(NULL) +{ + //get factory from draw model + m_xShapeFactory = uno::Reference<lang::XMultiServiceFactory>( xDrawPagesSuplier, uno::UNO_QUERY ); + + //create draw page: + uno::Reference<drawing::XDrawPages> xDrawPages = xDrawPagesSuplier->getDrawPages (); + m_xDrawPage = xDrawPages->insertNewByIndex ( 0 ); +} + +ChartViewImpl::~ChartViewImpl() +{ + m_xDrawPage = NULL; +} + +Matrix4D createTransformationSceneToScreen( + const awt::Point& rPos, const awt::Size& rSize ) +{ + Matrix4D aM4; + aM4.Scale(double(rSize.Width)/FIXED_SIZE_FOR_3D_CHART_VOLUME + , -double(rSize.Height)/FIXED_SIZE_FOR_3D_CHART_VOLUME, 1.0 ); + aM4.Translate(double(rPos.X), double(rPos.Y+rSize.Height-1), 0); + return aM4; +} + +drawing::HomogenMatrix createTransformationMatrix() +{ + Matrix4D aM4; + aM4.RotateY( -ZDIRECTION*F_PI/9.0 ); + aM4.RotateX( ZDIRECTION*F_PI/10.0 ); + + //aM4.RotateY( ZDIRECTION*F_PI/2.0 ); + //aM4.RotateX( -ZDIRECTION*F_PI/2.0 ); + + //aM4.RotateX( -ZDIRECTION*F_PI/2.0 ); + + aM4.Translate(0, -FIXED_SIZE_FOR_3D_CHART_VOLUME/2.0, 0); +// aM4.Scale(1, 1, ZDIRECTION); //invert direction of z coordinate to get a left handed system + aM4.Scale(1.0, 1.0, ZDIRECTION); + drawing::HomogenMatrix aHM = Matrix4DToHomogenMatrix(aM4); + return aHM; +} + +ShapeAppearance getDefaultStyle( sal_Int32 nStyle ) +{ + switch(nStyle%8) + { + case 1: + return ShapeAppearance( 0, 0, GEOMETRY_CYLINDER, SYMBOL_DIAMOND ); + case 2: + return ShapeAppearance( 0, 0, GEOMETRY_PYRAMID, SYMBOL_ARROW_DOWN ); + case 3: + return ShapeAppearance( 0, 0, GEOMETRY_CONE, SYMBOL_ARROW_UP ); + case 4: + return ShapeAppearance( 0, 0, GEOMETRY_CUBOID, SYMBOL_ARROW_RIGHT ); + case 5: + return ShapeAppearance( 0, 0, GEOMETRY_CYLINDER, SYMBOL_ARROW_LEFT ); + case 6: + return ShapeAppearance( 0, 0, GEOMETRY_PYRAMID, SYMBOL_BOWTIE ); + case 7: + return ShapeAppearance( 0, 0, GEOMETRY_CONE, SYMBOL_SANDGLASS ); + default: + return ShapeAppearance( 0, 0, GEOMETRY_CUBOID, SYMBOL_SQUARE ); + } +} + +uno::Reference< drawing::XShapes > createDiagram( + const uno::Reference< drawing::XShapes>& xPageShapes + , const uno::Reference< lang::XMultiServiceFactory>& xShapeFactory + , const awt::Point& rPos, const awt::Size& rSize + , sal_Int32 nDimension + , const uno::Reference< XDiagram > & xDia + ) +{ + VDiagram aVDiagram(xDia, nDimension); + aVDiagram.init(xPageShapes,xPageShapes,xShapeFactory); + if(3==nDimension) + aVDiagram.setSceneMatrix( createTransformationMatrix() ); + aVDiagram.createShapes(rPos,rSize); + uno::Reference< drawing::XShapes > xTarget = aVDiagram.getCoordinateRegion(); + return xTarget; +} + +void getCoordinateOrigin( double* fCoordinateOrigin, const uno::Reference< XBoundedCoordinateSystem >& xCoordSys ) +{ + if(xCoordSys.is()) + try + { + uno::Sequence< uno::Any > aCoord( xCoordSys->getOrigin()); + if( aCoord.getLength() >= 1 ) + aCoord[0]>>=fCoordinateOrigin[0]; + if( aCoord.getLength() >= 2 ) + aCoord[1]>>=fCoordinateOrigin[1]; + if( aCoord.getLength() >= 3 ) + aCoord[2]>>=fCoordinateOrigin[2]; + } + catch( uno::Exception& ex) + { + ex; + } +} + +sal_Int32 getDimension( const uno::Reference< XDiagram >& xDiagram ) +{ + sal_Int32 nDimension = 2; + + //@todo maybe get the dimension better from diagram properties ... -> need model change + uno::Reference< XDataSeriesTreeParent > xTree = xDiagram->getTree(); + if(!xTree.is()) + return nDimension; + 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()) + { + try + { + if( !(xChartTypeProp->getPropertyValue( C2U( "Dimension" )) >>= nDimension) ) + { + DBG_ERROR( "Couldn't get Dimension from ChartTypeGroup" ); + } + } + catch( beans::UnknownPropertyException ex ) + { + ex; + } + break; + } + } + return nDimension; +} + +// void getCoordinateSystems( std::vector< VCoordinateSystem >& rVCooSysList, const uno::Reference< XDiagram >& xDiagram ) +// { +// uno::Reference< XBoundedCoordinateSystemContainer > xCooSysContainer = +// uno::Reference< XBoundedCoordinateSystemContainer >::query( xDiagram ); +// if(xCooSysContainer.is()) +// { +// uno::Sequence< uno::Reference< XBoundedCoordinateSystem > > aXCooSysList = xCooSysContainer->getCoordinateSystems(); +// for( sal_Int32 nC=0; nC < aXCooSysList.getLength(); nC++) +// { +// VCoordinateSystem aCooSys(aXCooSysList[nC]); + +// double fCoordinateOrigin[3] = { 0.0, 0.0, 0.0 }; +// getCoordinateOrigin( fCoordinateOrigin, aXCooSysList ); +// aCooSys.setOrigin(fCoordinateOrigin); + +// rVCooSysList.push_back( aCooSys ); +// } +// if(!aXCooSysList.getLength()) +// { +// //get coosys from diagram tree +// //... +// } +// } +// } + +const VCoordinateSystem* findInCooSysList( const std::vector< VCoordinateSystem >& rVCooSysList + , const uno::Reference< XBoundedCoordinateSystem >& xCooSys ) +{ + for( sal_Int32 nC=0; nC < rVCooSysList.size(); nC++) + { + const VCoordinateSystem& rVCooSys = rVCooSysList[nC]; + if(rVCooSys.getModel()==xCooSys) + return &rVCooSys; + } + return NULL; +} + +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 ); + } +} + +void getAxesAndAddToCooSys( uno::Sequence< uno::Reference< XAxis > >& rAxisList + , const uno::Reference< XDiagram >& xDiagram + , std::vector< VCoordinateSystem >& rVCooSysList ) +{ + uno::Reference< XAxisContainer > xAxisContainer( xDiagram, uno::UNO_QUERY ); + if( xAxisContainer.is()) + { + rAxisList = xAxisContainer->getAxes(); + for( sal_Int32 nA = 0; nA < rAxisList.getLength(); nA++ ) + { + uno::Reference< XAxis > xAxis( rAxisList[nA] ); + for( sal_Int32 nC=0; nC < rVCooSysList.size(); nC++) + { + if(xAxis->getCoordinateSystem() == rVCooSysList[nC].getModel() ) + { + rVCooSysList[nC].addAxis( xAxis ); + } + } + } + } +} + +void addGridsToCooSys( const uno::Reference< XDiagram >& xDiagram + , std::vector< VCoordinateSystem >& rVCooSysList ) +{ + uno::Reference< XGridContainer > xGridContainer( xDiagram, uno::UNO_QUERY ); + if( xGridContainer.is()) + { + uno::Sequence< uno::Reference< XGrid > > aGridList( + xGridContainer->getGrids() ); + for( sal_Int32 nA = 0; nA < aGridList.getLength(); nA++ ) + { + uno::Reference< XGrid > xGrid( aGridList[nA] ); + for( sal_Int32 nC=0; nC < rVCooSysList.size(); nC++) + { + if(xGrid->getCoordinateSystem() == rVCooSysList[nC].getModel() ) + { + rVCooSysList[nC].addGrid( xGrid ); + } + } + } + } +} + +void initializeDiagramAndGetCooSys( std::vector< VCoordinateSystem >& rVCooSysList + , const uno::Reference< uno::XComponentContext>& xCC + , const uno::Reference< drawing::XShapes>& xPageShapes + , const uno::Reference< lang::XMultiServiceFactory>& xShapeFactory + , NumberFormatterWrapper* pNumberFormatterWrapper + , const awt::Point& rPos, const awt::Size& rSize + , const uno::Reference< frame::XModel >& xModel ) +{ + //------------ get model series from model + uno::Reference< XChartDocument > xChartDocument( xModel, uno::UNO_QUERY ); + if( !xChartDocument.is() ) + return; + uno::Reference< XDiagram > xDiagram = xChartDocument->getDiagram(); + if( !xDiagram.is()) + return; + + sal_Int32 nDimension = getDimension( xDiagram ); + + //------------ create Diagram shapes + uno::Reference< drawing::XShapes > xTarget = createDiagram( xPageShapes, xShapeFactory, rPos, rSize, nDimension, xDiagram ); + + //------------ get all coordinatesystems +// getCoordinateSystems( rVCooSysList, xDiagram ); + + //------------ add series to plotter and thus prepare him for providing minimum and maximum values + uno::Reference< XDataSeriesTreeParent > xTree = xDiagram->getTree(); + uno::Sequence< uno::Reference< XDataSeriesTreeNode > > aChartTypes( xTree->getChildren() ); + for( sal_Int32 i = 0; i < aChartTypes.getLength(); ++i ) + { + //iterate through different charttypes: + + 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; + ::std::auto_ptr< VSeriesPlotter > apPlotter( VSeriesPlotter::createSeriesPlotter( xChartTypeGroup->getChartType()->getChartType(), nDimension ) ); + + //------------ add series to plotter and thus prepare him for providing minimum and maximum values + + sal_Int32 nXSlot = -1; + sal_Int32 nYSlot = -1; + uno::Sequence< uno::Reference< XDataSeriesTreeNode > > aXSlots( xChartTypeGroup->getChildren() ); + for( sal_Int32 nX = 0; nX < aXSlots.getLength(); ++nX ) + { + uno::Reference< XDataSeriesTreeParent > xXSlot = uno::Reference< XDataSeriesTreeParent >::query( aXSlots[nX] ); + DBG_ASSERT( xXSlot.is(), "a node for the first dimension of a chart tree should always be a parent" ); + if(!xXSlot.is()) + return; + uno::Reference< XStackableScaleGroup > xStackGroup = uno::Reference< XStackableScaleGroup >::query( xXSlot ); + if( xStackGroup.is() && + xStackGroup->getStackMode()==StackMode_STACKED) + nXSlot++; + uno::Sequence< uno::Reference< XDataSeriesTreeNode > > aYSlots( + xXSlot->getChildren() ); + for( sal_Int32 nY = 0; nY < aYSlots.getLength(); ++nY ) + { + uno::Reference< XDataSeriesTreeParent > xYSlot = uno::Reference< XDataSeriesTreeParent >::query( aYSlots[nY] ); + DBG_ASSERT( xYSlot.is(), "a node for the second dimension of a chart tree should always be a parent" ); + if(!xYSlot.is()) + return; + + uno::Reference< XScaleGroup > xScaleGroup( xYSlot, uno::UNO_QUERY ); + + { + double fCoordinateOrigin[3] = { 0.0, 0.0, 0.0 }; + getCoordinateOrigin( fCoordinateOrigin, xScaleGroup->getCoordinateSystem() ); + addCooSysToList(rVCooSysList,xScaleGroup->getCoordinateSystem(),fCoordinateOrigin); + } + + uno::Reference< XStackableScaleGroup > xStackGroup = uno::Reference< XStackableScaleGroup >::query( xYSlot ); + StackMode aYStackMode = StackMode_NONE; + if(xStackGroup.is()) + aYStackMode = xStackGroup->getStackMode(); + if(aYStackMode==StackMode_STACKED) + nYSlot++; + uno::Sequence< uno::Reference< XDataSeriesTreeNode > > aSeriesList( xYSlot->getChildren() ); + for( sal_Int32 nS = 0; nS < aSeriesList.getLength(); ++nS ) + { + uno::Reference< XDataSeries > xDataSeries( aSeriesList[nS], uno::UNO_QUERY ); + + VDataSeries* pTestSeries = new VDataSeries( xDataSeries, getDefaultStyle(nS) ); + //virtual void addSeries( VDataSeries* pSeries, sal_Int32 xSlot = -1,sal_Int32 ySlot = -1 ); + sal_Int32 nXSlot = 0; + if(aYStackMode==StackMode_NONE) + nXSlot=-1; + //@todo + apPlotter->addSeries( pTestSeries, nXSlot ); + // apPlotter->addSeries( pTestSeries, nXSlot, nYSlot ); + /* + if(nN==nSeriesCount-1) + apPlotter->addSeries( pTestSeries, -1 ); + else + apPlotter->addSeries( pTestSeries, 0 ); + */ + } + } + } + + //------------ 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( sal_Int32 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 ); + + Matrix4D aM4_SceneToScreen( createTransformationSceneToScreen(rPos,rSize) ); + drawing::HomogenMatrix aHM_SceneToScreen( Matrix4DToHomogenMatrix(aM4_SceneToScreen) ); + + //------------ create axes --- @todo do auto layout / fontscaling + for( nDim = 0; nDim < 3; nDim++ ) + { + 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; + //------------------- + 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(); + } + } + //------------ create grids + rVCooSys.createGridShapes( xShapeFactory, xTarget, aHM_SceneToScreen ); + + //------------ set scale to plotter + apPlotter->init(xTarget,xPageShapes,xShapeFactory); + if(2==nDimension) + apPlotter->setTransformationSceneToScreen( aHM_SceneToScreen ); + apPlotter->setScales( rExplicitScales ); + apPlotter->createShapes(); + } + } +} + +//------------------------------------------------------------- +//------------------------------------------------------------- +//------------------------------------------------------------- + +void ChartViewImpl::getExplicitValuesForMeter( + uno::Reference< XMeter > xMeter + , ExplicitScaleData& rExplicitScale + , ExplicitIncrementData& rExplicitIncrement + , double& rfExplicitOrigin ) +{ + if(!xMeter.is()) + return; + uno::Reference< XBoundedCoordinateSystem > xCooSys = xMeter->getCoordinateSystem(); + const VCoordinateSystem* pVCooSys = findInCooSysList(m_aVCooSysList,xCooSys); + if(!pVCooSys) + return; + const uno::Sequence< ExplicitScaleData >& rScales =pVCooSys->getExplicitScales(); + const uno::Sequence< ExplicitIncrementData >& rIncrements =pVCooSys->getExplicitIncrements(); + sal_Int32 nDim = xMeter->getRepresentedDimension(); + if(nDim<=rScales.getLength()) + rExplicitScale=rScales[nDim]; + if(nDim<=rIncrements.getLength()) + rExplicitIncrement=rIncrements[nDim]; + rfExplicitOrigin = pVCooSys->getOriginByDimension( nDim ); +} + +bool getPosAndSizeForDiagram( awt::Point& rPos, awt::Size& rSize, const awt::Size& rPageSize, sal_Int32 nYOffset ) +{ + if(rPageSize.Width <= 0 || rPageSize.Height <= 0 ) + return false; + + long nHeight = (rPageSize.Height-nYOffset)*5/6; + long nOffsetY = (rPageSize.Height-nYOffset)-nHeight; + nOffsetY /= 2; + nOffsetY += nYOffset; + + long nWidth = rPageSize.Width*5/6; + long nOffsetX = rPageSize.Width-nWidth; + nOffsetX /= 2; + + if( nHeight <= 0 || nWidth <= 0 ) + return false; + + rPos = awt::Point(nOffsetX,nOffsetY); + rSize = awt::Size(nWidth,nHeight); + return true; +} + +void createTitle( const uno::Reference< XTitle >& xTitle + , sal_Int32 nXPosition + , sal_Int32& nrYOffset + , const uno::Reference< drawing::XShapes>& xPageShapes + , const uno::Reference< lang::XMultiServiceFactory>& xShapeFactory + ) +{ + if(xTitle.is()) + { + VTitle aVTitle(xTitle); + aVTitle.init(xPageShapes,xShapeFactory); + aVTitle.createShapes( awt::Point(0,0) ); + awt::Size aTitleSize = aVTitle.getSize(); + sal_Int32 nYSpacing = aTitleSize.Height/2; + aVTitle.changePosition( awt::Point( nXPosition, nrYOffset + aTitleSize.Height/2 + nYSpacing ) ); + nrYOffset += aTitleSize.Height + nYSpacing; + } +} + +bool ChartViewImpl::create( const awt::Size& rPageSize ) +{ + uno::Reference<drawing::XShapes> xPageShapes = + uno::Reference<drawing::XShapes>( m_xDrawPage, uno::UNO_QUERY ); + + sal_Int32 nYOffset = 0; + sal_Int32 nXPosition = rPageSize.Width/2; + + //------------ create main title shape + createTitle( TitleHelper::getTitle( TitleHelper::MAIN_TITLE, m_xChartModel ) + , nXPosition, nYOffset, xPageShapes, m_xShapeFactory ); + if(nYOffset>=rPageSize.Height) + return true; + + //------------ create sub title shape + createTitle( TitleHelper::getTitle( TitleHelper::SUB_TITLE, m_xChartModel ) + , nXPosition, nYOffset, xPageShapes, m_xShapeFactory ); + if(nYOffset>=rPageSize.Height) + return true; + + //------------ create complete diagram shape (inclusive axis and series) + awt::Point aPosDia; + awt::Size aSizeDia; + if( getPosAndSizeForDiagram( aPosDia, aSizeDia, rPageSize, nYOffset ) ) + initializeDiagramAndGetCooSys( m_aVCooSysList + , m_xCC, xPageShapes, m_xShapeFactory, m_pNumberFormatterWrapper + , aPosDia ,aSizeDia + , m_xChartModel ); + return true; +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/view/main/Linear3DTransformation.cxx b/chart2/source/view/main/Linear3DTransformation.cxx new file mode 100644 index 000000000000..ff33bf30475e --- /dev/null +++ b/chart2/source/view/main/Linear3DTransformation.cxx @@ -0,0 +1,136 @@ +/************************************************************************* + * + * $RCSfile: Linear3DTransformation.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: bm $ $Date: 2003-10-06 09:58:34 $ + * + * 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): _______________________________________ + * + * + ************************************************************************/ +#include "Linear3DTransformation.hxx" + +using namespace ::com::sun::star; + +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::uno::RuntimeException; + +namespace chart +{ + + Linear3DTransformation::Linear3DTransformation( const drawing::HomogenMatrix& rHomMatrix ) + : m_Matrix(rHomMatrix) +{} + +Linear3DTransformation::~Linear3DTransformation() +{} + +// ____ XTransformation ____ +Sequence< double > SAL_CALL Linear3DTransformation::transform( + const Sequence< double >& rSourceValues ) + throw (RuntimeException, + lang::IllegalArgumentException) +{ + /* + Vector3D aSource( SequenceToVector3D( rSourceValues ) ); + Vector3D aTarget = m_Matrix*aSource; + return Vector3DToSequence(aTarget); + */ + Sequence< double > aNewVec(3); + double fZwi; + + fZwi = m_Matrix.Line1.Column1 * rSourceValues[0] + + m_Matrix.Line1.Column2 * rSourceValues[1] + + m_Matrix.Line1.Column3 * rSourceValues[2] + + m_Matrix.Line1.Column4; + aNewVec[0] = fZwi; + + fZwi = m_Matrix.Line2.Column1 * rSourceValues[0] + + m_Matrix.Line2.Column2 * rSourceValues[1] + + m_Matrix.Line2.Column3 * rSourceValues[2] + + m_Matrix.Line2.Column4; + aNewVec[1] = fZwi; + + fZwi = m_Matrix.Line3.Column1 * rSourceValues[0] + + m_Matrix.Line3.Column2 * rSourceValues[1] + + m_Matrix.Line3.Column3 * rSourceValues[2] + + m_Matrix.Line3.Column4; + aNewVec[2] = fZwi; + + fZwi = m_Matrix.Line4.Column1 * rSourceValues[0] + + m_Matrix.Line4.Column2 * rSourceValues[1] + + m_Matrix.Line4.Column3 * rSourceValues[2] + + m_Matrix.Line4.Column4; + if(fZwi != 1.0 && fZwi != 0.0) + { + aNewVec[0] /= fZwi; + aNewVec[1] /= fZwi; + aNewVec[2] /= fZwi; + } + return aNewVec; +} + +sal_Int32 SAL_CALL Linear3DTransformation::getSourceDimension() + throw (RuntimeException) +{ + return 3; +} + +sal_Int32 SAL_CALL Linear3DTransformation::getTargetDimension() + throw (RuntimeException) +{ + return 3; +} + + +} // namespace chart diff --git a/chart2/source/view/main/NumberFormatterWrapper.cxx b/chart2/source/view/main/NumberFormatterWrapper.cxx new file mode 100644 index 000000000000..2e4cfc9e1236 --- /dev/null +++ b/chart2/source/view/main/NumberFormatterWrapper.cxx @@ -0,0 +1,208 @@ +/************************************************************************* + * + * $RCSfile: NumberFormatterWrapper.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: bm $ $Date: 2003-10-06 09:58:34 $ + * + * 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 "chartview/NumberFormatterWrapper.hxx" +#include "macros.hxx" + +#ifndef _COMPHELPER_PROCESSFACTORY_HXX_ +#include <comphelper/processfactory.hxx> +#endif +// header for class SvNumberformat +#ifndef _ZFORMAT_HXX +#include <svtools/zformat.hxx> +#endif +#ifndef _TOOLS_COLOR_HXX +#include <tools/color.hxx> +#endif +#ifndef _ISOLANG_HXX +#include <tools/isolang.hxx> +#endif + +//............................................................................. +namespace chart +{ +//............................................................................. +using namespace ::com::sun::star; +using namespace ::drafts::com::sun::star::chart2; + +FixedNumberFormatter::FixedNumberFormatter( + NumberFormatterWrapper* pNumberFormatterWrapper + , const ::drafts::com::sun::star::chart2::NumberFormat& rNumberFormat ) + : m_pNumberFormatterWrapper(pNumberFormatterWrapper) + , m_nFormatIndex(0) +{ + //add the given format string to the NumberFormatter and + //get the index of that format to use further + if( m_pNumberFormatterWrapper ) + m_nFormatIndex = m_pNumberFormatterWrapper->getKeyForNumberFormat( rNumberFormat ); +} + +FixedNumberFormatter::~FixedNumberFormatter() +{ +} + +/* +sal_Int32 FixedNumberFormatter::getTextAndColor( double fUnscaledValueForText, rtl::OUString& rLabel ) const +{ + sal_Int32 nLabelColor = Color(COL_BLUE).GetColor(); //@todo get this from somewheres + rLabel = getFormattedString( fUnscaledValueForText, nLabelColor ); + return nLabelColor; +} +*/ + +rtl::OUString FixedNumberFormatter::getFormattedString( double fValue, sal_Int32& rLabelColor, bool& rbColorChanged ) const +{ + String aText; + Color* pTextColor = NULL; + m_pNumberFormatterWrapper->m_pNumberFormatter->GetOutputString( + fValue, m_nFormatIndex, aText, &pTextColor); + rtl::OUString aRet( aText ); + + if(pTextColor) + { + rbColorChanged = true; + rLabelColor = pTextColor->GetColor(); + } + else + rbColorChanged = false; + + return aRet; +} + +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- + +NumberFormatterWrapper::NumberFormatterWrapper() + : m_pNumberFormatter(NULL) + +{ + //@todo: use a formatter via api (does not exsist so far) + m_pNumberFormatter = new SvNumberFormatter( + //m_xCC->getServiceManager() , + ::comphelper::getProcessServiceFactory(), + LANGUAGE_SYSTEM ); +} +NumberFormatterWrapper::~NumberFormatterWrapper() +{ + delete m_pNumberFormatter; +} + +SvNumberFormatter* NumberFormatterWrapper::getSvNumberFormatter() const +{ + return m_pNumberFormatter; +} + +LanguageType lcl_GetLanguage( const lang::Locale& rLocale ) +{ + // empty language -> LANGUAGE_SYSTEM + if ( rLocale.Language.getLength() == 0 ) + return LANGUAGE_SYSTEM; + + String aLangStr = rLocale.Language; + String aCtryStr = rLocale.Country; + // Variant is ignored + + LanguageType eRet = ConvertIsoNamesToLanguage( aLangStr, aCtryStr ); + if ( eRet == LANGUAGE_NONE ) + eRet = LANGUAGE_SYSTEM; //! or throw an exception? + + return eRet; +} + +sal_Int32 NumberFormatterWrapper::getKeyForNumberFormat( const NumberFormat& rNumberFormat ) const +{ + String aStr( rNumberFormat.aFormat ); + LanguageType eLnge = lcl_GetLanguage( rNumberFormat.aLocale ); + return m_pNumberFormatter->GetEntryKey( aStr, eLnge ); +} + +NumberFormat NumberFormatterWrapper::getNumberFormatForKey( sal_Int32 nIndex ) const +{ + const SvNumberformat* pSvNumberformat = m_pNumberFormatter->GetEntry( nIndex ); + + NumberFormat aNumberFormat; + aNumberFormat.aFormat = pSvNumberformat->GetFormatstring(); + LanguageType nLanguageType = pSvNumberformat->GetLanguage(); + aNumberFormat.aLocale = SvNumberFormatter::ConvertLanguageToLocale( nLanguageType ); + return aNumberFormat; +} + +/* + uno::Reference< i18n::XNumberFormatCode > xNumberFormatCode( + m_xCC->getServiceManager()->createInstanceWithContext( C2U( + "com.sun.star.i18n.NumberFormatMapper" ), m_xCC ), uno::UNO_QUERY ); + + i18n::NumberFormatCode aNumberFormatCode = xNumberFormatCode->getDefault ( + i18n::KNumberFormatType::MEDIUM, + i18n::KNumberFormatUsage::SCIENTIFIC_NUMBER, + aLocale ); + + uno::Sequence< i18n::NumberFormatCode > aListOfNumberFormatCode = xNumberFormatCode->getAllFormatCode( + i18n::KNumberFormatUsage::SCIENTIFIC_NUMBER, + aLocale ); + + i18n::NumberFormatCode aNumberFormatCode0 = aListOfNumberFormatCode[0]; + i18n::NumberFormatCode aNumberFormatCode1 = aListOfNumberFormatCode[1]; +*/ + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/view/main/PlotterBase.cxx b/chart2/source/view/main/PlotterBase.cxx new file mode 100644 index 000000000000..2ddd0455de25 --- /dev/null +++ b/chart2/source/view/main/PlotterBase.cxx @@ -0,0 +1,244 @@ +/************************************************************************* + * + * $RCSfile: PlotterBase.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: bm $ $Date: 2003-10-06 09:58:34 $ + * + * 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 "PlotterBase.hxx" +#include "PlottingPositionHelper.hxx" +#include "ShapeFactory.hxx" + +#ifndef _DRAFTS_COM_SUN_STAR_CHART2_DATACAPTIONSTYLE_HPP_ +#include <drafts/com/sun/star/chart2/DataCaptionStyle.hpp> +#endif + +/* +#ifndef _SV_GEN_HXX +#include <vcl/gen.hxx> +#endif +*/ +#ifndef _TOOLS_DEBUG_HXX +#include <tools/debug.hxx> +#endif + +//............................................................................. +namespace chart +{ +//............................................................................. +using namespace ::com::sun::star; +using namespace ::drafts::com::sun::star::chart2; + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +PlotterBase::PlotterBase( sal_Int32 nDimensionCount ) + : m_xLogicTarget(NULL) + , m_xFinalTarget(NULL) + , m_xShapeFactory(NULL) + , m_pShapeFactory(NULL) + , m_nDimension(nDimensionCount) + , m_pPosHelper(NULL) +{ +} + + void SAL_CALL PlotterBase +::init( 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 + m_xLogicTarget = xLogicTarget; + m_xFinalTarget = xFinalTarget; + m_xShapeFactory = xShapeFactory; + m_pShapeFactory = new ShapeFactory(xShapeFactory); +} + +PlotterBase::~PlotterBase() +{ + delete m_pShapeFactory; +} + +void SAL_CALL PlotterBase::setScales( const uno::Sequence< ExplicitScaleData >& rScales ) + throw (uno::RuntimeException) +{ + DBG_ASSERT(m_nDimension<=rScales.getLength(),"Dimension of Plotter does not fit two dimension of given scale sequence"); + m_pPosHelper->setScales( rScales ); +} + + +void PlotterBase::setTransformationSceneToScreen( const drawing::HomogenMatrix& rMatrix) +{ + DBG_ASSERT(m_nDimension==2,"Set this transformation only in case of 2D"); + if(m_nDimension!=2) + return; + m_pPosHelper->setTransformationSceneToScreen( rMatrix ); +} + +uno::Reference< drawing::XShapes > PlotterBase::createGroupShape( + const uno::Reference< drawing::XShapes >& xTarget + , const ::rtl::OUString& rName ) +{ + if(!m_xShapeFactory.is()) + return NULL; + + if(m_nDimension==2) + { + //create and add to target + return m_pShapeFactory->createGroup2D( xTarget, rName ); + } + else + { + //create and added to target + return m_pShapeFactory->createGroup3D( xTarget, rName ); + } +} + +/* +//----------------------------------------------------------------- +// chart2::XPlotter +//----------------------------------------------------------------- + + ::rtl::OUString SAL_CALL PlotterBase +::getCoordinateSystemTypeID() + throw (uno::RuntimeException) +{ + return CHART2_COOSYSTEM_CARTESIAN2D_SERVICE_NAME; +} + + void SAL_CALL PlotterBase +::setScales( const uno::Sequence< ExplicitScaleData >& rScales ) throw (uno::RuntimeException) +{ +} + void SAL_CALL PlotterBase +::setTransformation( const uno::Reference< XTransformation >& xTransformationToLogicTarget, const uno::Reference< XTransformation >& xTransformationToFinalPage ) throw (uno::RuntimeException) +{ +} +*/ + +//e.g. for Rectangle +/* +uno::Reference< drawing::XShape > PlotterBase::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 PlotterBase 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/main/PlottingPositionHelper.cxx b/chart2/source/view/main/PlottingPositionHelper.cxx new file mode 100644 index 000000000000..c05355a37766 --- /dev/null +++ b/chart2/source/view/main/PlottingPositionHelper.cxx @@ -0,0 +1,188 @@ +/************************************************************************* + * + * $RCSfile: PlottingPositionHelper.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: bm $ $Date: 2003-10-06 09:58:34 $ + * + * 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 "PlottingPositionHelper.hxx" +#include "CommonConverters.hxx" +#include "ViewDefines.hxx" +#include "Linear3DTransformation.hxx" + +#ifndef _COM_SUN_STAR_DRAWING_POSITION3D_HPP_ +#include <com/sun/star/drawing/Position3D.hpp> +#endif + +//............................................................................. +namespace chart +{ +//............................................................................. +using namespace ::com::sun::star; +using namespace ::drafts::com::sun::star::chart2; + +PlottingPositionHelper::PlottingPositionHelper() + : m_aScales() + , m_aMatrixScreenToScene() + , m_xTransformationLogicToScene(NULL) + +{ +} + +PlottingPositionHelper::~PlottingPositionHelper() +{ + +} + +void PlottingPositionHelper::setTransformationSceneToScreen( const drawing::HomogenMatrix& rMatrix) +{ + m_aMatrixScreenToScene = HomogenMatrixToMatrix4D(rMatrix); + m_xTransformationLogicToScene = NULL; +} + +void PlottingPositionHelper::setScales( const uno::Sequence< ExplicitScaleData >& rScales ) +{ + m_aScales = rScales; + m_xTransformationLogicToScene = NULL; +} + +uno::Reference< XTransformation > PlottingPositionHelper::getTransformationLogicToScene() const +{ + //this is a standard transformation for a cartesian coordinate system + + //transformation from 2) to 4) //@todo 2) and 4) need a ink to a document + + //we need to apply this transformation to each geometric object because of a bug/problem + //of the old drawing layer (the UNO_NAME_3D_EXTRUDE_DEPTH is an integer value instead of an double ) + if(!m_xTransformationLogicToScene.is()) + { + Matrix4D aMatrix; + 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); + + aMatrix.TranslateX(-MinX); + aMatrix.TranslateY(-MinY); + aMatrix.TranslateZ(-MinZ); + + double fWidthX = MaxX - MinX; + double fWidthY = MaxY - MinY; + double fWidthZ = MaxZ - MinZ; + + aMatrix.ScaleX(FIXED_SIZE_FOR_3D_CHART_VOLUME/fWidthX); + aMatrix.ScaleY(FIXED_SIZE_FOR_3D_CHART_VOLUME/fWidthY); + aMatrix.ScaleZ(FIXED_SIZE_FOR_3D_CHART_VOLUME/fWidthZ); + + aMatrix = aMatrix*m_aMatrixScreenToScene; + + m_xTransformationLogicToScene = new Linear3DTransformation(Matrix4DToHomogenMatrix( aMatrix )); + } + return m_xTransformationLogicToScene; +} + +void PlottingPositionHelper::getScreenValuesForMinimum( uno::Sequence< double >& rSeq ) const +{ + double fX = this->getLogicMinX(); + double fY = this->getLogicMinY(); + double fZ = this->getLogicMinZ(); + + this->doLogicScaling( &fX,&fY,&fZ ); + drawing::Position3D aPos( fX, fY, fZ); + + uno::Reference< XTransformation > xTransformation = + this->getTransformationLogicToScene(); + rSeq = xTransformation->transform( Position3DToSequence(aPos) ); +} + +void PlottingPositionHelper::getScreenValuesForMaximum( uno::Sequence< double >& rSeq ) const +{ + double fX = this->getLogicMaxX(); + double fY = this->getLogicMaxY(); + double fZ = this->getLogicMaxZ(); + + this->doLogicScaling( &fX,&fY,&fZ ); + drawing::Position3D aPos( fX, fY, fZ); + + uno::Reference< XTransformation > xTransformation = + this->getTransformationLogicToScene(); + rSeq = xTransformation->transform( Position3DToSequence(aPos) ); +} + +void PlottingPositionHelper::getLogicMinimum( ::com::sun::star::uno::Sequence< double >& rSeq ) const +{ + rSeq.realloc(3); + rSeq[0] = this->getLogicMinX(); + rSeq[1] = this->getLogicMinY(); + rSeq[2] = this->getLogicMinZ(); +} +void PlottingPositionHelper::getLogicMaximum( ::com::sun::star::uno::Sequence< double >& rSeq ) const +{ + rSeq.realloc(3); + rSeq[0] = this->getLogicMaxX(); + rSeq[1] = this->getLogicMaxY(); + rSeq[2] = this->getLogicMaxZ(); +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/view/main/PropertyMapper.cxx b/chart2/source/view/main/PropertyMapper.cxx new file mode 100644 index 000000000000..aedf30cd0e0c --- /dev/null +++ b/chart2/source/view/main/PropertyMapper.cxx @@ -0,0 +1,358 @@ +/************************************************************************* + * + * $RCSfile: PropertyMapper.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: bm $ $Date: 2003-10-06 09:58:34 $ + * + * 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 "PropertyMapper.hxx" +#include "macros.hxx" + +#ifndef _COM_SUN_STAR_BEANS_XMULTIPROPERTYSET_HPP_ +#include <com/sun/star/beans/XMultiPropertySet.hpp> +#endif + +//............................................................................. +namespace chart +{ +//............................................................................. +using namespace ::com::sun::star; + +//static +void PropertyMapper::setMappedProperties( + const uno::Reference< beans::XPropertySet >& xTarget + , const uno::Reference< beans::XPropertySet >& xSource + , const tPropertyNameMap& rMap ) +{ + if( !xTarget.is() || !xSource.is() ) + return; + + uno::Reference< beans::XMultiPropertySet > xMultiProp( xTarget, uno::UNO_QUERY ); + if( xMultiProp.is() ) + { + tNameSequence aNames; + tAnySequence aValues; + getMultiPropertyLists(aNames, aValues, xSource, rMap ); + try + { + xMultiProp->setPropertyValues( aNames,aValues ); + } + catch( uno::Exception& e ) + { + e; + } + } + else + { + tPropertyNameMap::const_iterator aIt( rMap.begin() ); + tPropertyNameMap::const_iterator aEnd( rMap.end() ); + for( ; aIt != aEnd; ++aIt ) + { + rtl::OUString aTarget = aIt->first; + rtl::OUString aSource = aIt->second; + try + { + uno::Any aAny( xSource->getPropertyValue(aSource) ); + xTarget->setPropertyValue( aTarget, aAny ); + } + catch( uno::Exception& e ) + { + e; + } + } + } +} + +void PropertyMapper::getValueMap( + tPropertyNameValueMap& rValueMap + , const tPropertyNameMap& rNameMap + , const uno::Reference< beans::XPropertySet >& xSourceProp + ) +{ + tPropertyNameMap::const_iterator aIt( rNameMap.begin() ); + tPropertyNameMap::const_iterator aEnd( rNameMap.end() ); + + for( ; aIt != aEnd; ++aIt ) + { + rtl::OUString aTarget = aIt->first; + rtl::OUString aSource = aIt->second; + try + { + uno::Any aAny( xSourceProp->getPropertyValue(aSource) ); + if( aAny.hasValue() ) + rValueMap.insert( tPropertyNameValueMap::value_type( aTarget, aAny ) ); + } + catch( uno::Exception& e ) + { + e; + } + } +} + +void PropertyMapper::getMultiPropertyLists( + tNameSequence& rNames + , tAnySequence& rValues + , const uno::Reference< beans::XPropertySet >& xSourceProp + , const tPropertyNameMap& rNameMap + ) +{ + tPropertyNameValueMap aValueMap; + getValueMap( aValueMap, rNameMap, xSourceProp ); + getMultiPropertyListsFromValueMap( rNames, rValues, aValueMap ); +} + +void PropertyMapper::getMultiPropertyListsFromValueMap( + tNameSequence& rNames + , tAnySequence& rValues + , const tPropertyNameValueMap& rValueMap + ) +{ + sal_Int32 nPropertyCount = rValueMap.size(); + rNames.realloc(nPropertyCount); + rValues.realloc(nPropertyCount); + + //fill sequences + tPropertyNameValueMap::const_iterator aValueIt( rValueMap.begin() ); + tPropertyNameValueMap::const_iterator aValueEnd( rValueMap.end() ); + sal_Int32 nN=0; + for( ; aValueIt != aValueEnd; ++aValueIt ) + { + const uno::Any& rAny = aValueIt->second; + if( rAny.hasValue() ) + { + //do not set empty anys because of performance (otherwise SdrAttrObj::ItemChange will take much longer) + rNames[nN] = aValueIt->first; + rValues[nN] = rAny; + ++nN; + } + } + //reduce to real property count + rNames.realloc(nN); + rValues.realloc(nN); +} + +uno::Any* PropertyMapper::getValuePointer( tAnySequence& rPropValues + , const tNameSequence& rPropNames + , const rtl::OUString& rPropName ) +{ + sal_Int32 nCount = rPropNames.getLength(); + for( sal_Int32 nN = 0; nN < nCount; nN++ ) + { + if(rPropNames[nN].equals(rPropName)) + return &rPropValues[nN]; + } + return NULL; +} + +/* +//set some properties from service style::CharacterProperties: +//-------- tabpage: Zeichen ----------- +//Schriftart z.B. Albany UNO_NAME_EDIT_CHAR_FONTNAME == UNO_NAME_EDIT_CHAR_FONTSTYLENAME //UNO_NAME_CHAR_FONT +//Schriftschnitt z.B. kursiv UNO_NAME_EDIT_CHAR_POSTURE UNO_NAME_CHAR_POSTURE awt::FontSlant NONE OBLIQUE ITALIC DONTKNOW REVERSE_OBLIQUE REVERSE_ITALIC +//Schriftgrad (Punktgrsse z.B. 12) UNO_NAME_EDIT_CHAR_HEIGHT == UNO_NAME_CHAR_HEIGHT + //? UNO_NAME_EDIT_CHAR_WEIGHT == UNO_NAME_CHAR_WEIGHT +//Sprache UNO_NAME_EDIT_CHAR_LOCALE lang::Locale + +//-------- tabpage: Schrifteffekt ----------- +//Unterstreichung UNO_NAME_CHAR_UNDERLINE sal_Int16 awt::FontUnderline_NONE _SINGLE _DOUBLE _DOTTED _DONTKNOW _DASH ... +//Unterstreichung-farbe ??? 'CharUnderlineColor' + CharUnderlineHasColor +//Durchstreichung z.B. doppelt "CharStrikeout" sal_Int16 awt::FontStrikeout_NONE _SINGLE _DOUBLE ... +//wortweise-Durchstreichung ja/nein "CharWordMode" bool +//Schriftfarbe UNO_NAME_EDIT_CHAR_COLOR sal_Int32 UNO_NAME_CHAR_COLOR +//ReliefArt ohne/erhaben/tief "CharRelief" sal_Int16 text::FontRelief_NONE FontRelief_EMBOSSED FontRelief_ENGRAVED +//Kontur "CharContoured" bool +//Schatten UNO_NAME_CHAR_SHADOWED bool +*/ + +//static +const tMakePropertyNameMap& PropertyMapper::getPropertyNameMapForCharacterProperties() +{ + //shape property -- chart model object property + static tMakePropertyNameMap m_aShapePropertyMapForCharacterProperties = + tMakePropertyNameMap + ( C2U( "CharFontName" ), C2U("CharFontName") ) + ( C2U( "CharFontStyleName" ), C2U("CharFontStyleName") ) + ( C2U( "CharFontFamily" ), C2U("CharFontFamily") ) + ( C2U( "CharFontCharSet" ), C2U("CharFontCharSet") ) + ( C2U( "CharFontPitch" ), C2U("CharFontPitch") ) + ( C2U( "CharColor" ), C2U("CharColor") ) +// ( C2U( "CharBackColor" ), C2U("TextBackgroundColor") ) + ( C2U( "CharEscapement" ), C2U("CharEscapement") ) + ( C2U( "CharHeight" ), C2U("CharHeight") ) + ( C2U( "CharUnderline" ), C2U("CharUnderline") ) + ( C2U( "CharUnderlineColor" ), C2U("CharUnderlineColor") ) + ( C2U( "CharUnderlineHasColor" ), C2U("CharUnderlineHasColor") ) + ( C2U( "CharWeight" ), C2U("CharWeight") ) + ( C2U( "CharPosture" ), C2U("CharPosture") ) + ( C2U( "CharKerning" ), C2U("CharKerning") ) +// ( C2U( "CharCaseMap" ), C2U("CaseMapping") ) +// ( C2U( "CharRotation" ), C2U("Rotation") ) --> additional feature ... +// ( C2U( "CharScaleWidth" ), C2U("CharScaleWidth") ) +// ( C2U( "CharEscapementHeight" ), C2U("EscapementHeight") ) -> assertion +/////// ( C2U( "CharCrossedOut" ), C2U("CharCrossedOut") ) //setting this explicitly somehow conflicts with CharStrikeout + ( C2U( "CharStrikeout" ), C2U("CharStrikeout") ) + ( C2U( "CharWordMode" ), C2U("CharWordMode") ) +// ( C2U( "CharFlash" ), C2U("Flashing") ) + ( C2U( "CharLocale" ), C2U("CharLocale") ) + ( C2U( "CharShadowed" ), C2U("CharShadowed") ) + ( C2U( "CharContoured" ), C2U("CharContoured") ) + ( C2U( "CharRelief" ), C2U("CharRelief") ) + ( C2U( "CharEmphasis" ), C2U("CharEmphasis") )//the service style::CharacterProperties describes a property called 'CharEmphasize' wich is nowhere implemented +// ( C2U( "RubyText" ), C2U("RubyText") ) +// ( C2U( "RubyAdjust" ), C2U("RubyAdjust") ) +// ( C2U( "RubyCharStyleName" ), C2U("RubyStyleName") ) +// ( C2U( "RubyIsAbove" ), C2U("RubyIsAbove") ) +// ( C2U( "CharNoHyphenation" ), C2U("InhibitHyphenation") ) + ( C2U( "CharFontStyleNameAsian" ), C2U("CharFontNameAsian") ) + ( C2U( "CharFontStyleNameAsian" ), C2U("CharFontStyleNameAsian") ) + ( C2U( "CharFontFamilyAsian" ), C2U("CharFontFamilyAsian") ) + ( C2U( "CharFontCharSetAsian" ), C2U("CharFontCharSetAsian") ) + ( C2U( "CharFontPitchAsian" ), C2U("CharFontPitchAsian") ) + ( C2U( "CharHeightAsian" ), C2U("CharHeightAsian") ) + ( C2U( "CharWeightAsian" ), C2U("CharWeightAsian") ) + ( C2U( "CharPostureAsian" ), C2U("CharPostureAsian") ) + ( C2U( "CharLocaleAsian" ), C2U("CharLocaleAsian") ) + + ( C2U( "CharFontStyleNameComplex" ), C2U("CharFontNameComplex") ) + ( C2U( "CharFontStyleNameComplex" ), C2U("CharFontStyleNameComplex") ) + ( C2U( "CharFontFamilyComplex" ), C2U("CharFontFamilyComplex") ) + ( C2U( "CharFontCharSetComplex" ), C2U("CharFontCharSetComplex") ) + ( C2U( "CharFontPitchComplex" ), C2U("CharFontPitchComplex") ) + ( C2U( "CharHeightComplex" ), C2U("CharHeightComplex") ) + ( C2U( "CharWeightComplex" ), C2U("CharWeightComplex") ) + ( C2U( "CharPostureComplex" ), C2U("CharPostureComplex") ) + ( C2U( "CharLocaleComplex" ), C2U("CharLocaleComplex") ) + ; + return m_aShapePropertyMapForCharacterProperties; +} + +//static +const tMakePropertyNameMap& PropertyMapper::getPropertyNameMapForParagraphProperties() +{ + //shape property -- chart model object property + static tMakePropertyNameMap m_aShapePropertyMapForParagraphProperties = + tMakePropertyNameMap + ( C2U( "ParaAdjust" ), C2U("ParaAdjust") ) + ( C2U( "ParaLastLineAdjust" ), C2U("ParaLastLineAdjust") ) + ( C2U( "ParaLeftMargin" ), C2U("ParaLeftMargin") ) + ( C2U( "ParaRightMargin" ), C2U("ParaRightMargin") ) + ( C2U( "ParaTopMargin" ), C2U("ParaTopMargin") ) + ( C2U( "ParaBottomMargin" ), C2U("ParaBottomMargin") ) + ( C2U( "ParaIsHyphenation" ), C2U("ParaIsHyphenation") ) + ; + return m_aShapePropertyMapForParagraphProperties; +} + +//static +const tMakePropertyNameMap& PropertyMapper::getPropertyNameMapForFillProperties() +{ + //shape property -- chart model object property + static tMakePropertyNameMap m_aShapePropertyMapForFillProperties = + tMakePropertyNameMap + ( C2U( "FillStyle" ), C2U("FillStyle") ) + ( C2U( "FillColor" ), C2U("FillColor") ) + ( C2U( "FillTransparence" ), C2U("FillTransparence") ) + ( C2U( "FillGradient" ), C2U("FillGradient") ) + ( C2U( "FillHatch" ), C2U("FillHatch") ) +// ( C2U( "FillTransparenceGradientName" ), C2U("TransparencyStyle") ) //@todo this property name seems to be wrong in chart model +// ( C2U( "FillTransparenceGradient" ), C2U("TransparencyGradient") ) //@todo this property name seems to be wrong in chart model + ; + return m_aShapePropertyMapForFillProperties; +} + +//static +const tMakePropertyNameMap& PropertyMapper::getPropertyNameMapForLineProperties() +{ + //shape property -- chart model object property + static tMakePropertyNameMap m_aShapePropertyMapForLineProperties = + tMakePropertyNameMap + ( C2U( "LineStyle" ), C2U("LineStyle") ) + ( C2U( "LineWidth" ), C2U("LineWidth") ) + ( C2U( "LineDash" ), C2U("LineDash") ) + ( C2U( "LineColor" ), C2U("LineColor") ) + ( C2U( "LineTransparence" ), C2U("LineTransparence") ) + ( C2U( "LineJoint" ), C2U("LineJoint") ) + ; + return m_aShapePropertyMapForLineProperties; +} + +//static +void PropertyMapper::setMultiProperties( + const tNameSequence& rNames + , const tAnySequence& rValues + , const uno::Reference< drawing::XShape >& xTarget ) +{ + try + { + uno::Reference< beans::XMultiPropertySet > xShapeMultiProp( xTarget, uno::UNO_QUERY ); + if( xShapeMultiProp.is() ) + { + xShapeMultiProp->setPropertyValues( rNames,rValues ); + } + else + { + //@todo: if no multipropertyset is available try the unperformant normal XPropertySet + } + } + catch( uno::Exception& e ) + { + e; + } +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/view/main/ShapeFactory.cxx b/chart2/source/view/main/ShapeFactory.cxx new file mode 100644 index 000000000000..68fde4dcf069 --- /dev/null +++ b/chart2/source/view/main/ShapeFactory.cxx @@ -0,0 +1,1978 @@ +/************************************************************************* + * + * $RCSfile: ShapeFactory.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: bm $ $Date: 2003-10-06 09:58:34 $ + * + * 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 "ShapeFactory.hxx" +#include "ViewDefines.hxx" +#include "Stripe.hxx" +#include "CommonConverters.hxx" +#include "macros.hxx" +#include "InlineContainer.hxx" +#include "PropertyMapper.hxx" + +/* +#ifndef _E3D_EXTRUD3D_HXX +#include <svx/extrud3d.hxx> +#endif +*/ + +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ +#include <com/sun/star/beans/XPropertySet.hpp> +#endif +/* +#ifndef _COM_SUN_STAR_DRAWING_CAMERAGEOMETRY_HPP_ +#include <com/sun/star/drawing/CameraGeometry.hpp> +#endif +*/ +#ifndef _COM_SUN_STAR_DRAWING_CIRCLEKIND_HPP_ +#include <com/sun/star/drawing/CircleKind.hpp> +#endif +#ifndef _COM_SUN_STAR_DRAWING_DOUBLESEQUENCE_HPP_ +#include <com/sun/star/drawing/DoubleSequence.hpp> +#endif +#ifndef _COM_SUN_STAR_DRAWING_FLAGSEQUENCE_HPP_ +#include <com/sun/star/drawing/FlagSequence.hpp> +#endif +#ifndef _COM_SUN_STAR_DRAWING_LINESTYLE_HPP_ +#include <com/sun/star/drawing/LineStyle.hpp> +#endif +#ifndef _COM_SUN_STAR_DRAWING_NORMALSKIND_HPP_ +#include <com/sun/star/drawing/NormalsKind.hpp> +#endif +#ifndef _COM_SUN_STAR_DRAWING_POINTSEQUENCE_HPP_ +#include <com/sun/star/drawing/PointSequence.hpp> +#endif +#ifndef _COM_SUN_STAR_DRAWING_POLYGONKIND_HPP_ +#include <com/sun/star/drawing/PolygonKind.hpp> +#endif +#ifndef _COM_SUN_STAR_DRAWING_POLYPOLYGONBEZIERCOORDS_HPP_ +#include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp> +#endif +#ifndef _COM_SUN_STAR_DRAWING_PROJECTIONMODE_HPP_ +#include <com/sun/star/drawing/ProjectionMode.hpp> +#endif +#ifndef _COM_SUN_STAR_DRAWING_SHADEMODE_HPP_ +#include <com/sun/star/drawing/ShadeMode.hpp> +#endif +#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 +/* +#ifndef _COM_SUN_STAR_DRAWING_TEXTUREMODE_HPP_ +#include <com/sun/star/drawing/TextureMode.hpp> +#endif +*/ + +//only test +/* +#ifndef _COM_SUN_STAR_AWT_FONTSTRIKEOUT_HPP_ +#include <com/sun/star/awt/FontStrikeout.hpp> +#endif +#ifndef _COM_SUN_STAR_TEXT_FONTEMPHASIS_HPP_ +#include <com/sun/star/text/FontEmphasis.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XENUMERATION_HPP_ +#include <com/sun/star/container/XEnumeration.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XENUMERATIONACCESS_HPP_ +#include <com/sun/star/container/XEnumerationAccess.hpp> +#endif +*/ + +#ifndef _COM_SUN_STAR_UNO_ANY_HXX_ +#include <com/sun/star/uno/Any.hxx> +#endif + + +#ifndef _SVX_UNOPRNMS_HXX +#include <svx/unoprnms.hxx> +#endif +#ifndef _TOOLS_COLOR_HXX +#include <tools/color.hxx> +#endif +#ifndef _TOOLS_DEBUG_HXX +#include <tools/debug.hxx> +#endif + +#ifndef INCLUDED_RTL_MATH_HXX +#include <rtl/math.hxx> +#endif + +#ifndef _XPOLY_HXX +#include <svx/xpoly.hxx> +#endif +#ifndef _SVDOCIRC_HXX +#include <svx/svdocirc.hxx> +#endif +#ifndef _SVDOPATH_HXX +#include <svx/svdopath.hxx> +#endif + +#include <algorithm> + +using namespace ::com::sun::star; + +//............................................................................. +namespace chart +{ +//............................................................................. + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +// set a name/CID at a shape (is used for selection handling) +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +//static +void ShapeFactory::setShapeName( const uno::Reference< drawing::XShape >& xShape + , const rtl::OUString& rName ) +{ + uno::Reference< beans::XPropertySet > xProp( xShape, uno::UNO_QUERY ); + DBG_ASSERT(xProp.is(), "shape offers no XPropertySet"); + if( xProp.is()) + { + try + { + xProp->setPropertyValue( C2U( UNO_NAME_MISC_OBJ_NAME ) + , uno::makeAny( rName ) ); + } + catch( uno::Exception& e ) + { + e; + } + } +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +// set appearance properties at a shape +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +//static +void ShapeFactory::setShapeAppearance( + const ShapeAppearance& rAppearance + , const uno::Reference< beans::XPropertySet >& xProp + , sal_Bool bNoLines ) + throw (beans::UnknownPropertyException + , beans::PropertyVetoException + , lang::IllegalArgumentException + , lang::WrappedTargetException + , uno::RuntimeException) +{ + //LineStyle + if(bNoLines) + { + xProp->setPropertyValue( C2U( UNO_NAME_LINESTYLE ) + , uno::makeAny(drawing::LineStyle_NONE) ); + } + //FillColor + xProp->setPropertyValue( C2U( UNO_NAME_FILLCOLOR ) + , uno::makeAny(rAppearance.m_nColorData) ); + //Transparency + xProp->setPropertyValue( C2U( UNO_NAME_FILL_TRANSPARENCE ) + , uno::makeAny( (sal_Int16)rAppearance.m_nTransparency ) ); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +// diverse PolyPolygon create methods +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +uno::Any createPolyPolygon_Cube( + const drawing::Direction3D& rSize, double fRoundedEdge, sal_Bool bRounded = true ) +{ + DBG_ASSERT(fRoundedEdge>=0, "fRoundedEdge needs to be >= 0"); + + // always use extra points, so set percent diagonal to 0.4 which is 0% in the UI (old Chart comment) + if( fRoundedEdge == 0.0 && bRounded) + fRoundedEdge = 0.4 / 200.0; + else if(!bRounded) + fRoundedEdge = 0.0; + + const double fWidthH = rSize.DirectionX/2.0; //fWidthH stands for Half Width + const double fHeight = rSize.DirectionY; + const double fDepth = rSize.DirectionZ; + + const double fOffset = (fDepth * fRoundedEdge) * 1.05; // increase by 5% for safety + const bool bRoundEdges = fRoundedEdge && fOffset < fWidthH && 2.0 * fOffset < fHeight; + const sal_Int32 nPointCount = bRoundEdges ? 13 : 5; + + //-------------------------------------- + drawing::PolyPolygonShape3D aPP; + + aPP.SequenceX.realloc(1); + aPP.SequenceY.realloc(1); + aPP.SequenceZ.realloc(1); + + drawing::DoubleSequence* pOuterSequenceX = aPP.SequenceX.getArray(); + drawing::DoubleSequence* pOuterSequenceY = aPP.SequenceY.getArray(); + drawing::DoubleSequence* pOuterSequenceZ = aPP.SequenceZ.getArray(); + + pOuterSequenceX->realloc(nPointCount); + pOuterSequenceY->realloc(nPointCount); + pOuterSequenceZ->realloc(nPointCount); + + double* pInnerSequenceX = pOuterSequenceX->getArray(); + double* pInnerSequenceY = pOuterSequenceY->getArray(); + double* pInnerSequenceZ = pOuterSequenceZ->getArray(); + + for(sal_Int32 nN = nPointCount; nN--;) + *pInnerSequenceZ++ = 0.0; + //*pInnerSequenceZ++ = -fDepth/2.0; + + if(nPointCount == 5) + { + *pInnerSequenceY++ = 0.0; + *pInnerSequenceY++ = fHeight; + *pInnerSequenceY++ = fHeight; + *pInnerSequenceY++ = 0.0; + *pInnerSequenceY++ = 0.0; + + *pInnerSequenceX++ = -fWidthH; + *pInnerSequenceX++ = -fWidthH; + *pInnerSequenceX++ = fWidthH; + *pInnerSequenceX++ = fWidthH; + *pInnerSequenceX++ = -fWidthH; + } + else + { + *pInnerSequenceY++ = 0.0; //1. + *pInnerSequenceY++ = 0.0; + *pInnerSequenceY++ = fOffset; + *pInnerSequenceY++ = fHeight - fOffset; + *pInnerSequenceY++ = fHeight; + *pInnerSequenceY++ = fHeight; //6. + *pInnerSequenceY++ = fHeight; + *pInnerSequenceY++ = fHeight; + *pInnerSequenceY++ = fHeight - fOffset; + *pInnerSequenceY++ = fOffset; //10. + *pInnerSequenceY++ = 0.0; + *pInnerSequenceY++ = 0.0; + *pInnerSequenceY++ = 0.0; + + + *pInnerSequenceX++ = -fWidthH + fOffset; //1. + *pInnerSequenceX++ = -fWidthH; + *pInnerSequenceX++ = -fWidthH; + *pInnerSequenceX++ = -fWidthH; + *pInnerSequenceX++ = -fWidthH; + *pInnerSequenceX++ = -fWidthH + fOffset; //6. + *pInnerSequenceX++ = fWidthH - fOffset; + *pInnerSequenceX++ = fWidthH; + *pInnerSequenceX++ = fWidthH; + *pInnerSequenceX++ = fWidthH; //10. + *pInnerSequenceX++ = fWidthH; + *pInnerSequenceX++ = fWidthH - fOffset; + *pInnerSequenceX++ = -fWidthH + fOffset; + } + return uno::Any( &aPP, ::getCppuType((const drawing::PolyPolygonShape3D*)0) ); +} + +uno::Any createPolyPolygon_Cylinder( + double fHeight + , double fRadius + , double fRoundedEdge ) +{ + //@todo consider offset if Height is negative + +// DBG_ASSERT(fHeight>0, "The height of a cylinder needs to be > 0"); + DBG_ASSERT(fRadius>0, "The radius of a cylinder needs to be > 0"); + DBG_ASSERT(fRoundedEdge>=0, "fRoundedEdge needs to be >= 0"); + + // always use extra points, so set percent diagonal to 0.4 which is 0% in the UI (old Chart comment) + if( fRoundedEdge == 0.0 ) + fRoundedEdge = 0.4 / 200.0; + + const double fWidth = fRadius; + + const double fOffset = (fRadius * 2.0 * fRoundedEdge) * 1.05; // increase by 5% for safety + const bool bRoundEdges = fRoundedEdge && fOffset < fRadius && 2.0 * fOffset < fHeight; + const sal_Int32 nPointCount = bRoundEdges ? 8 : 4; + + //-------------------------------------- + drawing::PolyPolygonShape3D aPP; + + aPP.SequenceX.realloc(1); + aPP.SequenceY.realloc(1); + aPP.SequenceZ.realloc(1); + + drawing::DoubleSequence* pOuterSequenceX = aPP.SequenceX.getArray(); + drawing::DoubleSequence* pOuterSequenceY = aPP.SequenceY.getArray(); + drawing::DoubleSequence* pOuterSequenceZ = aPP.SequenceZ.getArray(); + + pOuterSequenceX->realloc(nPointCount); + pOuterSequenceY->realloc(nPointCount); + pOuterSequenceZ->realloc(nPointCount); + + double* pInnerSequenceX = pOuterSequenceX->getArray(); + double* pInnerSequenceY = pOuterSequenceY->getArray(); + double* pInnerSequenceZ = pOuterSequenceZ->getArray(); + + for(sal_Int32 nN = nPointCount; nN--;) + *pInnerSequenceZ++ = 0.0; + + if(nPointCount == 4) + { + *pInnerSequenceY++ = 0.0; + *pInnerSequenceY++ = 0.0; + *pInnerSequenceY++ = fHeight; + *pInnerSequenceY++ = fHeight; + + *pInnerSequenceX++ = 0.0; + *pInnerSequenceX++ = fRadius; + *pInnerSequenceX++ = fRadius; + *pInnerSequenceX++ = 0.0; + } + else + { + *pInnerSequenceY++ = 0.0; //1. + *pInnerSequenceY++ = 0.0; + *pInnerSequenceY++ = 0.0; + *pInnerSequenceY++ = fOffset; + *pInnerSequenceY++ = fHeight - fOffset; + *pInnerSequenceY++ = fHeight; //6. + *pInnerSequenceY++ = fHeight; + *pInnerSequenceY++ = fHeight; + + *pInnerSequenceX++ = 0.0; //1. + *pInnerSequenceX++ = fRadius - fOffset; + *pInnerSequenceX++ = fRadius; + *pInnerSequenceX++ = fRadius; + *pInnerSequenceX++ = fRadius; + *pInnerSequenceX++ = fRadius; //6. + *pInnerSequenceX++ = fRadius - fOffset; + *pInnerSequenceX++ = 0.0; + } + return uno::Any( &aPP, ::getCppuType((const drawing::PolyPolygonShape3D*)0) ); +} + +uno::Any createPolyPolygon_Cone( + double fHeight + , double fRadius + , double fTopHeight + , double fRoundedEdge) +{ + //@todo consider offset if Height is negative +/* + DBG_ASSERT(fHeight>0, "The height of a cone needs to be > 0"); + DBG_ASSERT(fTopHeight>=0, "The height of the cutted top of a cone needs to be >= 0"); +*/ + + DBG_ASSERT(fRadius>0, "The radius of a cone needs to be > 0"); + DBG_ASSERT(fRoundedEdge>=0, "fRoundedEdge needs to be >= 0"); + + //for stacked charts we need cones without top -> fTopHeight != 0 resp. bTopless == true + //fTopHeight indicates the high of the cutted top only (not the full height) + + // always use extra points, so set percent diagonal to 0.4 which is 0% in the UI (old Chart comment) + if( fRoundedEdge == 0.0 ) + fRoundedEdge = 0.4 / 200.0; + + fRoundedEdge = 0.0; + + BOOL bTopless = fTopHeight != 0.0; + + double r1= 0.0, r2 = fRadius; + if(bTopless) + r1 = fRadius * (fTopHeight)/(fHeight+fTopHeight); + + const double fMinimumDimension = ::std::min(r2*2.0,fHeight); + const double fOffset = (fMinimumDimension * fRoundedEdge) * 1.05; // increase by 5% for safety + const bool bRoundEdges = fRoundedEdge && fOffset < r2 && 2.0 * fOffset < fHeight + && ( bTopless ? fOffset < r1 : true ); + sal_Int32 nPointCount = 8; + if(bTopless) + { + if(!bRoundEdges) + nPointCount = 4; + } + else + { + if(bRoundEdges) + nPointCount = 6; + else + nPointCount = 3; + } + + //-------------------------------------- + drawing::PolyPolygonShape3D aPP; + + aPP.SequenceX.realloc(1); + aPP.SequenceY.realloc(1); + aPP.SequenceZ.realloc(1); + + drawing::DoubleSequence* pOuterSequenceX = aPP.SequenceX.getArray(); + drawing::DoubleSequence* pOuterSequenceY = aPP.SequenceY.getArray(); + drawing::DoubleSequence* pOuterSequenceZ = aPP.SequenceZ.getArray(); + + pOuterSequenceX->realloc(nPointCount); + pOuterSequenceY->realloc(nPointCount); + pOuterSequenceZ->realloc(nPointCount); + + double* pInnerSequenceX = pOuterSequenceX->getArray(); + double* pInnerSequenceY = pOuterSequenceY->getArray(); + double* pInnerSequenceZ = pOuterSequenceZ->getArray(); + + for(sal_Int32 nN = nPointCount; nN--;) + *pInnerSequenceZ++ = 0.0; + + if(bTopless) + { + *pInnerSequenceY++ = fHeight; //1. + *pInnerSequenceX++ = 0.0; //1. + + if(bRoundEdges) + { + *pInnerSequenceY++ = fHeight; //2. + *pInnerSequenceX++ = r1 - fOffset; //2. + } + } + + *pInnerSequenceY++ = fHeight; //3. + *pInnerSequenceX++ = r1; //3. + + if(bRoundEdges) + { + *pInnerSequenceY++ = fHeight - fOffset; //4. + *pInnerSequenceX++ = r1 + fOffset; //4. + + *pInnerSequenceY++ = fOffset; //5. + *pInnerSequenceX++ = r2 - fOffset; //5. + } + + *pInnerSequenceY++ = 0.0; //6. + *pInnerSequenceX++ = r2; //6. + + if(bRoundEdges) + { + *pInnerSequenceY++ = 0.0; //7. + *pInnerSequenceX++ = r2 - fOffset; //7. + } + + *pInnerSequenceY++ = 0.0; //8. + *pInnerSequenceX++ = 0.0; //8. + + return uno::Any( &aPP, ::getCppuType((const drawing::PolyPolygonShape3D*)0) ); +} + +uno::Any createPolyPolygon_PieSegment( + double fHeight + , double fXWidthRadius + , double fInnerXRadius = 0.0) +{ + DBG_ASSERT(fHeight>0, "The height of a pie segment needs to be > 0"); + DBG_ASSERT(fInnerXRadius>=0, "The inner radius of a pie segment needs to be >= 0"); + DBG_ASSERT(fXWidthRadius>0, "The width radius of a pie segment needs to be > 0"); + + const BOOL bClosed = true; + + const sal_Int32 nPointCount = bClosed ? 5 : 4; + + //-------------------------------------- + drawing::PolyPolygonShape3D aPP; + + aPP.SequenceX.realloc(1); + aPP.SequenceY.realloc(1); + aPP.SequenceZ.realloc(1); + + drawing::DoubleSequence* pOuterSequenceX = aPP.SequenceX.getArray(); + drawing::DoubleSequence* pOuterSequenceY = aPP.SequenceY.getArray(); + drawing::DoubleSequence* pOuterSequenceZ = aPP.SequenceZ.getArray(); + + pOuterSequenceX->realloc(nPointCount); + pOuterSequenceY->realloc(nPointCount); + pOuterSequenceZ->realloc(nPointCount); + + double* pInnerSequenceX = pOuterSequenceX->getArray(); + double* pInnerSequenceY = pOuterSequenceY->getArray(); + double* pInnerSequenceZ = pOuterSequenceZ->getArray(); + + for(sal_Int32 nN = nPointCount; nN--;) + *pInnerSequenceZ++ = 0.0; + + *pInnerSequenceY++ = 0.0; + *pInnerSequenceY++ = 0.0; + *pInnerSequenceY++ = fHeight; + *pInnerSequenceY++ = fHeight; + if(bClosed) + *pInnerSequenceY++ = 0.0; + + *pInnerSequenceX++ = fInnerXRadius; + *pInnerSequenceX++ = fInnerXRadius+fXWidthRadius; + *pInnerSequenceX++ = fInnerXRadius+fXWidthRadius; + *pInnerSequenceX++ = fInnerXRadius; + if(bClosed) + *pInnerSequenceX++ = fInnerXRadius; + + return uno::Any( &aPP, ::getCppuType((const drawing::PolyPolygonShape3D*)0) ); +} + + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +// methods for 3D shape creation +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +uno::Reference<drawing::XShape> + ShapeFactory::createCube( + const uno::Reference<drawing::XShapes>& xTarget + , const DataPointGeometry& rGeometry + , const ShapeAppearance& rAppearance) +{ + uno::Reference<drawing::XShape> xShape = impl_createCube( xTarget, rGeometry, FALSE ); + uno::Reference< beans::XPropertySet > xProp( xShape, uno::UNO_QUERY ); + ShapeFactory::setShapeAppearance( rAppearance, xProp ); + return xShape; +} + +uno::Reference<drawing::XShape> + ShapeFactory::createRoundedCube( + const uno::Reference<drawing::XShapes>& xTarget + , const DataPointGeometry& rGeometry ) +{ + return impl_createCube( xTarget, rGeometry, TRUE); +} + +uno::Reference<drawing::XShape> + ShapeFactory::impl_createCube( + const uno::Reference<drawing::XShapes>& xTarget + , const DataPointGeometry& rGeometry + //, const ShapeAppearance& rAppearance + , sal_Bool bRounded ) +{ + //create shape + uno::Reference< drawing::XShape > xShape( + m_xShapeFactory->createInstance( 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 + { + //depth + xProp->setPropertyValue( C2U( UNO_NAME_3D_EXTRUDE_DEPTH ) + , uno::makeAny((sal_Int32)rGeometry.m_aSize.DirectionZ) ); + + //PercentDiagonal + sal_Int16 nPercentDiagonal = bRounded ? 5 : 0; + xProp->setPropertyValue( C2U( UNO_NAME_3D_PERCENT_DIAGONAL ) + , uno::makeAny( nPercentDiagonal ) ); + + //Polygon + xProp->setPropertyValue( C2U( UNO_NAME_3D_POLYPOLYGON3D ) + , createPolyPolygon_Cube( rGeometry.m_aSize, double(nPercentDiagonal)/200.0,bRounded) ); + + //Matrix for position + { + Matrix4D aM4; + aM4.Translate(rGeometry.m_aPosition.PositionX + , rGeometry.m_aPosition.PositionY + , rGeometry.m_aPosition.PositionZ - (rGeometry.m_aSize.DirectionZ/2.0)); + drawing::HomogenMatrix aHM = Matrix4DToHomogenMatrix(aM4); + xProp->setPropertyValue( C2U( UNO_NAME_3D_TRANSFORM_MATRIX ) + , uno::makeAny(aHM) ); + } + } + catch( uno::Exception& e ) + { + e; + } + } + return xShape; +} + +uno::Reference<drawing::XShape> + ShapeFactory::createCylinder( + const uno::Reference<drawing::XShapes>& xTarget + , const DataPointGeometry& rGeometry ) +{ + return impl_createConeOrCylinder( + xTarget, rGeometry, CHART_3DOBJECT_SEGMENTCOUNT, true ); +} + +uno::Reference<drawing::XShape> + ShapeFactory::createPyramid( + const uno::Reference<drawing::XShapes>& xTarget + , const DataPointGeometry& rGeometry ) +{ + return impl_createConeOrCylinder( xTarget, rGeometry, 4 ); +} + +uno::Reference<drawing::XShape> + ShapeFactory::createCone( + const uno::Reference<drawing::XShapes>& xTarget + , const DataPointGeometry& rGeometry ) +{ + return impl_createConeOrCylinder( xTarget, rGeometry, CHART_3DOBJECT_SEGMENTCOUNT ); +} + +uno::Reference<drawing::XShape> + ShapeFactory::impl_createConeOrCylinder( + const uno::Reference<drawing::XShapes>& xTarget + , const DataPointGeometry& rGeometry + , sal_Int32 nSegments + , bool bCylinder ) +{ + + static int ntest = 0; + ntest++; + + //create shape + uno::Reference< drawing::XShape > xShape( + m_xShapeFactory->createInstance( C2U( + "com.sun.star.drawing.Shape3DLatheObject") ), uno::UNO_QUERY ); + xTarget->add(xShape); + + + double fYRotateAnglePi = -ZDIRECTION*(F_PI/2.0 - F_PI/(double)nSegments); // alwayas rotate edge to front (important for pyramids) + //or: ZDIRECTION*(F_PI/2.0 - F_PI/(double)nSegments); // rotate edge to front for even segment count otherwise rotate corner to front + double fAngle = fYRotateAnglePi; + { + while(fAngle<0.0) + fAngle+=F_PI/2.0; + while(fAngle>F_PI/2.0) + fAngle-=F_PI/2.0; + } + //double fWidth = ::std::min( rGeometry.m_aSize.DirectionX, rGeometry.m_aSize.DirectionZ )/2.0; + double fWidth = rGeometry.m_aSize.DirectionX/2.0; //The depth will be corrrected within Matrix + double fRadius = fWidth; //!!!!!!!! problem in drawing layer: rotation object calculates wrong needed size -> wrong camera (it's a problem with bounding boxes) +// double fRadius = fWidth/cos(fAngle); llllllllllllllllllll + double fHeight = rGeometry.m_aSize.DirectionY; + //for Cones: + double fTopHeight = rGeometry.m_aSize2.DirectionY; + + //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_3D_TRANSFORM_MATRIX drawing::HomogenMatrix + //UNO_NAME_3D_POLYPOLYGON3D PolyPolygonShape3D + //UNO_NAME_3D_LATHE_END_ANGLE sal_Int16 + //UNO_NAME_3D_HORZ_SEGS sal_Int32 + //UNO_NAME_3D_PERCENT_DIAGONAL sal_Int16 + //UNO_NAME_3D_VERT_SEGS sal_Int32 + + //PercentDiagonal + sal_Int16 nPercentDiagonal = 5; + xProp->setPropertyValue( C2U( UNO_NAME_3D_PERCENT_DIAGONAL ) + , uno::makeAny( nPercentDiagonal ) ); + + //Polygon + uno::Any aPPolygon = bCylinder ? createPolyPolygon_Cylinder( + fHeight, fRadius, double(nPercentDiagonal)/200.0) + : createPolyPolygon_Cone( + fHeight, fRadius, fTopHeight, double(nPercentDiagonal)/200.0); + xProp->setPropertyValue( C2U( UNO_NAME_3D_POLYPOLYGON3D ), aPPolygon ); + + //Matrix for position + { + Matrix4D aM4; + //if(ntest%2) //llllllllllllllllllll + //aM4.RotateY( fYRotateAnglePi ); + + // Note: Uncomment the following to let the objects grow in z + // direction to fill the diagram +// aM4.ScaleZ(rGeometry.m_aSize.DirectionZ/rGeometry.m_aSize.DirectionX); + aM4.Translate(rGeometry.m_aPosition.PositionX, rGeometry.m_aPosition.PositionY, rGeometry.m_aPosition.PositionZ); + drawing::HomogenMatrix aHM = Matrix4DToHomogenMatrix(aM4); + xProp->setPropertyValue( C2U( UNO_NAME_3D_TRANSFORM_MATRIX ) + , uno::makeAny(aHM) ); + } + + //Segments + xProp->setPropertyValue( C2U( UNO_NAME_3D_VERT_SEGS ) + , uno::makeAny(CHART_3DOBJECT_SEGMENTCOUNT) ); + xProp->setPropertyValue( C2U( UNO_NAME_3D_HORZ_SEGS ) + , uno::makeAny(nSegments) ); + +//// ShapeFactory::setShapeAppearance( rAppearance, xProp ); + } + catch( uno::Exception& e ) + { + e; + } + } + return xShape; +} + +void appendBezierCoords( drawing::PolyPolygonBezierCoords& rReturn, const drawing::PolyPolygonBezierCoords& rAdd, sal_Bool bAppendInverse ) +{ + if(!rAdd.Coordinates.getLength()) + return; + sal_Int32 nAddCount = rAdd.Coordinates[0].getLength(); + if(!nAddCount) + return; + + sal_Int32 nOldCount = rReturn.Coordinates[0].getLength(); + + rReturn.Coordinates[0].realloc(nOldCount+nAddCount); + rReturn.Flags[0].realloc(nOldCount+nAddCount); + + for(sal_Int32 nN=0;nN<nAddCount; nN++ ) + { + sal_Int32 nAdd = bAppendInverse ? (nAddCount-1-nN) : nN; + rReturn.Coordinates[0][nOldCount+nN] = rAdd.Coordinates[0][nAdd]; + rReturn.Flags[0][nOldCount+nN] = rAdd.Flags[0][nAdd]; + } +} + +drawing::PolyPolygonBezierCoords getCircularArcBezierCoords( + double fAngleRadian + , const Matrix3D& rTransformationFromUnitCircle ) +{ + //at least one polygon is created using two normal and two control points + //if the angle is larger it is separated into multiple sub angles + + const double fSmallAngleRadian = F_PI/10.0; + + drawing::PolyPolygonBezierCoords aReturn = drawing::PolyPolygonBezierCoords(); + sal_Int32 nSegmentCount = fAngleRadian/fSmallAngleRadian; + if( fAngleRadian > fSmallAngleRadian*nSegmentCount ) + nSegmentCount++; + + sal_Int32 nPointCount = 1 + 3*nSegmentCount; //first point of next segment equals last point of former segment + + aReturn.Coordinates = drawing::PointSequenceSequence(1); + aReturn.Flags = drawing::FlagSequenceSequence(1); + + drawing::PointSequence aPoints(nPointCount); + drawing::FlagSequence aFlags(nPointCount); + + // + + Vector2D P0,P1,P2,P3; + Vector2D POrigin = rTransformationFromUnitCircle*Vector2D(0,0); + + sal_Int32 nPoint=0; + for(sal_Int32 nSegment=0; nSegment<nSegmentCount; nSegment++) + { + double fCurrentSegmentAngle = fSmallAngleRadian; + //the last segment gets the rest angle that does not fit into equal pieces + if(nSegment==(nSegmentCount-1)) + fCurrentSegmentAngle = fAngleRadian - fSmallAngleRadian*(nSegmentCount-1); + + //first create untransformed points for a unit circle arc: + const double fCos = cos(fCurrentSegmentAngle/2.0); + const double fSin = sin(fCurrentSegmentAngle/2.0); + P0.X() = P3.X() = fCos; + P0.Y() = -fSin; + P3.Y() = -P0.Y(); + + P1.X() = P2.X() = (4.0-fCos)/3.0; + P1.Y() = (1.0-fCos)*(fCos-3.0)/(3.0*fSin); + P2.Y() = -P1.Y(); + //transform thus startangle equals NULL + Matrix3D aStart; + aStart.Rotate(fCurrentSegmentAngle/2.0 + nSegment*fSmallAngleRadian); + + //apply given transformation to get final points + P0 = rTransformationFromUnitCircle*(aStart*P0); + P1 = rTransformationFromUnitCircle*(aStart*P1); + P2 = rTransformationFromUnitCircle*(aStart*P2); + P3 = rTransformationFromUnitCircle*(aStart*P3); + + aPoints[nPoint].X = P0.X(); + aPoints[nPoint].Y = P0.Y(); + aFlags [nPoint++] = drawing::PolygonFlags_NORMAL; + + aPoints[nPoint].X = P1.X(); + aPoints[nPoint].Y = P1.Y(); + aFlags[nPoint++] = drawing::PolygonFlags_CONTROL; + + aPoints[nPoint].X = P2.X(); + aPoints[nPoint].Y = P2.Y(); + aFlags [nPoint++] = drawing::PolygonFlags_CONTROL; + + if(nSegment==(nSegmentCount-1)) + { + aPoints[nPoint].X = P3.X(); + aPoints[nPoint].Y = P3.Y(); + aFlags [nPoint++] = drawing::PolygonFlags_NORMAL; + } + } + + aReturn.Coordinates[0] = aPoints; + aReturn.Flags[0] = aFlags; + + return aReturn; +} + +drawing::PolyPolygonBezierCoords getRingBezierCoords( + double fInnerXRadius + , double fOuterXRadius, double fOuterYRadius + , double fWidthAngleRadian, double fStartAngleRadian + , double fPosX, double fPosY ) +{ + drawing::PolyPolygonBezierCoords aReturn = drawing::PolyPolygonBezierCoords(); + + aReturn.Coordinates = drawing::PointSequenceSequence(1); + aReturn.Flags = drawing::FlagSequenceSequence(1); + + Matrix3D aTransformationFromUnitCircle_Outer; + aTransformationFromUnitCircle_Outer.Rotate(fStartAngleRadian); + aTransformationFromUnitCircle_Outer.ScaleX(fOuterXRadius); + aTransformationFromUnitCircle_Outer.ScaleY(fOuterYRadius); + aTransformationFromUnitCircle_Outer.TranslateX(fPosX); + aTransformationFromUnitCircle_Outer.TranslateY(fPosY); + + drawing::PolyPolygonBezierCoords aOuterArc = getCircularArcBezierCoords( fWidthAngleRadian, aTransformationFromUnitCircle_Outer ); + aReturn.Coordinates[0] = aOuterArc.Coordinates[0]; + aReturn.Flags[0] = aOuterArc.Flags[0]; + + Matrix3D aTransformationFromUnitCircle_Inner; + aTransformationFromUnitCircle_Inner.Rotate(fStartAngleRadian); + aTransformationFromUnitCircle_Inner.ScaleX(fInnerXRadius); + aTransformationFromUnitCircle_Inner.ScaleY(fInnerXRadius*fOuterYRadius/fOuterXRadius); + aTransformationFromUnitCircle_Inner.TranslateX(fPosX); + aTransformationFromUnitCircle_Inner.TranslateY(fPosY); + + drawing::PolyPolygonBezierCoords aInnerArc = getCircularArcBezierCoords( fWidthAngleRadian, aTransformationFromUnitCircle_Inner ); + appendBezierCoords( aReturn, aInnerArc, sal_True ); + + 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 ) +// , const ShapeAppearance& rAppearance ) +{ + /* + 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) + fWidthAngleDegree += 360.0; + + //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; + + //set properties + uno::Reference< beans::XPropertySet > xProp( xShape, uno::UNO_QUERY ); + DBG_ASSERT(xProp.is(), "created shape offers no XPropertySet"); + if( xProp.is()) + { + 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* + +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)) ); + */ + +// ShapeFactory::setShapeAppearance( rAppearance, xProp, sal_False ); + } + catch( uno::Exception& e ) + { + 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)) ); + + ShapeFactory::setShapeAppearance( rAppearance, xProp ); + } + 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 ) +// , const ShapeAppearance& rAppearance ) +{ + 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) + fWidthAngleDegree += 360.0; + + //create shape + uno::Reference< drawing::XShape > xShape( + m_xShapeFactory->createInstance( + C2U("com.sun.star.drawing.Shape3DLatheObject") ), 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 + { + //PercentDiagonal + xProp->setPropertyValue( C2U( UNO_NAME_3D_PERCENT_DIAGONAL ) + , uno::makeAny((sal_Int16)0) ); + + //Polygon + xProp->setPropertyValue( C2U( UNO_NAME_3D_POLYPOLYGON3D ) + , createPolyPolygon_PieSegment( fDepth, fXWidthRadius, fInnerXRadius ) ); + + //UNO_NAME_3D_LATHE_END_ANGLE sal_Int16 + xProp->setPropertyValue( C2U( UNO_NAME_3D_LATHE_END_ANGLE ) + , uno::makeAny((sal_Int16)(fWidthAngleDegree*10.0)) ); + + //Matrix for position + { + Matrix4D aM4; + aM4.ScaleZ(rGeometry.m_aSize.DirectionY/rGeometry.m_aSize.DirectionX); + aM4.RotateY( ZDIRECTION*fStartAngleDegree*F_PI/180.0 ); + aM4.Translate(rGeometry.m_aPosition.PositionX, rGeometry.m_aPosition.PositionZ, rGeometry.m_aPosition.PositionY); + drawing::HomogenMatrix aHM = Matrix4DToHomogenMatrix(aM4); + xProp->setPropertyValue( C2U( UNO_NAME_3D_TRANSFORM_MATRIX ) + , uno::makeAny(aHM) ); + } + + //Segments + xProp->setPropertyValue( C2U( UNO_NAME_3D_VERT_SEGS ) + , uno::makeAny(CHART_3DOBJECT_SEGMENTCOUNT) ); + xProp->setPropertyValue( C2U( UNO_NAME_3D_HORZ_SEGS ) + , uno::makeAny(CHART_3DOBJECT_SEGMENTCOUNT) ); + +// ShapeFactory::setShapeAppearance( rAppearance, xProp ); + } + catch( uno::Exception& e ) + { + e; + } + } + return xShape; +} + +uno::Reference< drawing::XShape > + ShapeFactory::createStripe( const uno::Reference< drawing::XShapes >& xTarget + , const Stripe& rStripe + , const ShapeAppearance& rAppearance + , sal_Bool bDoubleSided ) +{ + //create shape + uno::Reference< drawing::XShape > xShape( + m_xShapeFactory->createInstance( C2U( + "com.sun.star.drawing.Shape3DPolygonObject" ) ), 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 + { + //Polygon + xProp->setPropertyValue( C2U( UNO_NAME_3D_POLYPOLYGON3D ) + , rStripe.getPolyPolygonShape3D() ); + + //Normals Polygon + xProp->setPropertyValue( C2U( UNO_NAME_3D_NORMALSPOLYGON3D ) + , rStripe.getNormalsPolyPolygonShape3D() ); + + //NormalsKind + xProp->setPropertyValue( C2U( UNO_NAME_3D_NORMALS_KIND ) + , uno::makeAny( drawing::NormalsKind_FLAT ) ); + + //LineOnly + xProp->setPropertyValue( C2U( UNO_NAME_3D_LINEONLY ) + , uno::makeAny( (sal_Bool)false) ); + + //DoubleSided + xProp->setPropertyValue( C2U( UNO_NAME_3D_DOUBLE_SIDED ) + , uno::makeAny(bDoubleSided) ); + + ShapeFactory::setShapeAppearance( rAppearance, xProp ); + } + catch( uno::Exception& e ) + { + e; + } + } + return xShape; +} + +uno::Reference< drawing::XShape > + ShapeFactory::createArea3D( const uno::Reference< drawing::XShapes >& xTarget + , const drawing::PolyPolygonShape3D& rPolyPolygon + , double fDepth ) +{ + //create shape + uno::Reference< drawing::XShape > xShape( + m_xShapeFactory->createInstance( 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 + { + //depth + xProp->setPropertyValue( C2U( UNO_NAME_3D_EXTRUDE_DEPTH ) + , uno::makeAny((sal_Int32)fDepth) ); + + //PercentDiagonal + sal_Int16 nPercentDiagonal = 0; + xProp->setPropertyValue( C2U( UNO_NAME_3D_PERCENT_DIAGONAL ) + , uno::makeAny( nPercentDiagonal ) ); + + //Polygon + xProp->setPropertyValue( C2U( UNO_NAME_3D_POLYPOLYGON3D ) + , uno::makeAny( rPolyPolygon ) ); + } + catch( uno::Exception& e ) + { + e; + } + } + return xShape; +} + +uno::Reference< drawing::XShape > + ShapeFactory::createArea2D( const uno::Reference< drawing::XShapes >& xTarget + , const drawing::PolyPolygonShape3D& rPolyPolygon ) +{ + //create shape + uno::Reference< drawing::XShape > xShape( + m_xShapeFactory->createInstance( C2U( + "com.sun.star.drawing.PolyPolygonShape") ), 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_POLYGON "Polygon" drawing::PointSequence* + drawing::PointSequenceSequence aPoints( PolyToPointSequence(rPolyPolygon) ); + + //Polygon + xProp->setPropertyValue( C2U( UNO_NAME_POLYPOLYGON ) + , uno::makeAny( aPoints ) ); + + //ZOrder + //an area should always be behind other shapes + xProp->setPropertyValue( C2U( UNO_NAME_MISC_OBJ_ZORDER ) + , uno::makeAny( sal_Int32(0) ) ); + } + catch( uno::Exception& e ) + { + e; + } + } + return xShape; +} + +drawing::PolyPolygonShape3D createPolyPolygon_Symbol( const drawing::Position3D& rPos + , const drawing::Direction3D& rSize + , SymbolType eSymbolType ) +{ + const double& fX = rPos.PositionX; + const double& fY = rPos.PositionY; + + const double fWidthH = rSize.DirectionX/2.0; //fWidthH stands for Half Width + const double fHeightH = rSize.DirectionY/2.0; //fHeightH stands for Half Height + + DBG_ASSERT(eSymbolType!=SYMBOL_NONE, "do not create a symbol with type SYMBOL_NONE"); + if(eSymbolType==SYMBOL_NONE) + eSymbolType=SYMBOL_SQUARE; + + sal_Int32 nPointCount = 4; //all arrow symbols only need 4 points + switch( eSymbolType ) + { + case SYMBOL_SQUARE: + case SYMBOL_DIAMOND: + case SYMBOL_BOWTIE: + case SYMBOL_SANDGLASS: + nPointCount = 5; + break; + default: + break; + } + + //-------------------------------------- + drawing::PolyPolygonShape3D aPP; + + aPP.SequenceX.realloc(1); + aPP.SequenceY.realloc(1); + aPP.SequenceZ.realloc(1); + + drawing::DoubleSequence* pOuterSequenceX = aPP.SequenceX.getArray(); + drawing::DoubleSequence* pOuterSequenceY = aPP.SequenceY.getArray(); + drawing::DoubleSequence* pOuterSequenceZ = aPP.SequenceZ.getArray(); + + pOuterSequenceX->realloc(nPointCount); + pOuterSequenceY->realloc(nPointCount); + pOuterSequenceZ->realloc(nPointCount); + + double* pInnerSequenceX = pOuterSequenceX->getArray(); + double* pInnerSequenceY = pOuterSequenceY->getArray(); + double* pInnerSequenceZ = pOuterSequenceZ->getArray(); + + for(sal_Int32 nN = nPointCount; nN--;) + *pInnerSequenceZ++ = 0.0; + + switch(eSymbolType) + { + case SYMBOL_ARROW_DOWN: + { + *pInnerSequenceX++ = fX-fWidthH; + *pInnerSequenceY++ = fY+fHeightH; + + *pInnerSequenceX++ = fX+fWidthH; + *pInnerSequenceY++ = fY+fHeightH; + + *pInnerSequenceX++ = fX; + *pInnerSequenceY++ = fY-fHeightH; + + *pInnerSequenceX++ = fX-fWidthH; + *pInnerSequenceY++ = fY+fHeightH; + break; + } + case SYMBOL_ARROW_UP: + { + *pInnerSequenceX++ = fX-fWidthH; + *pInnerSequenceY++ = fY-fHeightH; + + *pInnerSequenceX++ = fX; + *pInnerSequenceY++ = fY+fHeightH; + + *pInnerSequenceX++ = fX+fWidthH; + *pInnerSequenceY++ = fY-fHeightH; + + *pInnerSequenceX++ = fX-fWidthH; + *pInnerSequenceY++ = fY-fHeightH; + break; + } + case SYMBOL_ARROW_RIGHT: + { + *pInnerSequenceX++ = fX-fWidthH; + *pInnerSequenceY++ = fY-fHeightH; + + *pInnerSequenceX++ = fX-fWidthH; + *pInnerSequenceY++ = fY+fHeightH; + + *pInnerSequenceX++ = fX+fWidthH; + *pInnerSequenceY++ = fY; + + *pInnerSequenceX++ = fX-fWidthH; + *pInnerSequenceY++ = fY-fHeightH; + break; + } + case SYMBOL_ARROW_LEFT: + { + *pInnerSequenceX++ = fX-fWidthH; + *pInnerSequenceY++ = fY; + + *pInnerSequenceX++ = fX+fWidthH; + *pInnerSequenceY++ = fY+fHeightH; + + *pInnerSequenceX++ = fX+fWidthH; + *pInnerSequenceY++ = fY-fHeightH; + + *pInnerSequenceX++ = fX-fWidthH; + *pInnerSequenceY++ = fY; + break; + } + case SYMBOL_BOWTIE: + { + *pInnerSequenceX++ = fX-fWidthH; + *pInnerSequenceY++ = fY-fHeightH; + + *pInnerSequenceX++ = fX-fWidthH; + *pInnerSequenceY++ = fY+fHeightH; + + *pInnerSequenceX++ = fX+fWidthH; + *pInnerSequenceY++ = fY-fHeightH; + + *pInnerSequenceX++ = fX+fWidthH; + *pInnerSequenceY++ = fY+fHeightH; + + *pInnerSequenceX++ = fX-fWidthH; + *pInnerSequenceY++ = fY-fHeightH; + break; + } + case SYMBOL_SANDGLASS: + { + *pInnerSequenceX++ = fX-fWidthH; + *pInnerSequenceY++ = fY+fHeightH; + + *pInnerSequenceX++ = fX+fWidthH; + *pInnerSequenceY++ = fY+fHeightH; + + *pInnerSequenceX++ = fX-fWidthH; + *pInnerSequenceY++ = fY-fHeightH; + + + *pInnerSequenceX++ = fX+fWidthH; + *pInnerSequenceY++ = fY-fHeightH; + + *pInnerSequenceX++ = fX-fWidthH; + *pInnerSequenceY++ = fY+fHeightH; + break; + } + case SYMBOL_DIAMOND: + { + *pInnerSequenceX++ = fX-fWidthH; + *pInnerSequenceY++ = fY; + + *pInnerSequenceX++ = fX; + *pInnerSequenceY++ = fY+fHeightH; + + *pInnerSequenceX++ = fX+fWidthH; + *pInnerSequenceY++ = fY; + + *pInnerSequenceX++ = fX; + *pInnerSequenceY++ = fY-fHeightH; + + *pInnerSequenceX++ = fX-fWidthH; + *pInnerSequenceY++ = fY; + break; + } + default: //case SYMBOL_SQUARE: + { + *pInnerSequenceX++ = fX-fWidthH; + *pInnerSequenceY++ = fY-fHeightH; + + *pInnerSequenceX++ = fX-fWidthH; + *pInnerSequenceY++ = fY+fHeightH; + + *pInnerSequenceX++ = fX+fWidthH; + *pInnerSequenceY++ = fY+fHeightH; + + *pInnerSequenceX++ = fX+fWidthH; + *pInnerSequenceY++ = fY-fHeightH; + + *pInnerSequenceX++ = fX-fWidthH; + *pInnerSequenceY++ = fY-fHeightH; + break; + } + } + //return uno::Any( &aPP, ::getCppuType((const drawing::PolyPolygonShape3D*)0) ); + return aPP; +} + +uno::Reference< drawing::XShape > + ShapeFactory::createSymbol2D( + const uno::Reference< drawing::XShapes >& xTarget + , const DataPointGeometry& rGeometry + , const ShapeAppearance& rAppearance ) +{ + //create shape + uno::Reference< drawing::XShape > xShape( + m_xShapeFactory->createInstance( C2U( + "com.sun.star.drawing.PolyPolygonShape") ), 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 + { + drawing::PointSequenceSequence aPoints( PolyToPointSequence( + createPolyPolygon_Symbol( rGeometry.m_aPosition + , rGeometry.m_aSize + , rAppearance.m_eSymbolType ) )); + + //Polygon + xProp->setPropertyValue( C2U( UNO_NAME_POLYPOLYGON ) + , uno::makeAny( aPoints ) ); + + ShapeFactory::setShapeAppearance( rAppearance, xProp, sal_False ); + } + catch( uno::Exception& e ) + { + e; + } + } + return xShape; +} + +uno::Reference< drawing::XShape > + ShapeFactory::createSymbol3D( const uno::Reference< drawing::XShapes >& xTarget + , const DataPointGeometry& rGeometry + , const ShapeAppearance& rAppearance ) +{ + //create shape + uno::Reference< drawing::XShape > xShape( + m_xShapeFactory->createInstance( 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 + { + //depth + xProp->setPropertyValue( C2U( UNO_NAME_3D_EXTRUDE_DEPTH ) + , uno::makeAny((sal_Int32)rGeometry.m_aSize.DirectionZ) ); + + //PercentDiagonal + sal_Int16 nPercentDiagonal = 0; + xProp->setPropertyValue( C2U( UNO_NAME_3D_PERCENT_DIAGONAL ) + , uno::makeAny( nPercentDiagonal ) ); + + //Polygon + xProp->setPropertyValue( C2U( UNO_NAME_3D_POLYPOLYGON3D ) + , uno::makeAny( createPolyPolygon_Symbol( rGeometry.m_aPosition + , rGeometry.m_aSize + , rAppearance.m_eSymbolType ) ) ); + + ShapeFactory::setShapeAppearance( rAppearance, xProp ); + } + catch( uno::Exception& e ) + { + e; + } + } + return xShape; +} + +void setShapeName( uno::Reference< drawing::XShape >& xShape , const ::rtl::OUString& rName ) +{ + uno::Reference< beans::XPropertySet > xProp( xShape, uno::UNO_QUERY ); + DBG_ASSERT(xProp.is(), "created shape offers no XPropertySet"); + if( xProp.is()) + { + try + { + xProp->setPropertyValue( C2U( UNO_NAME_MISC_OBJ_NAME ) + , uno::makeAny( rName ) ); + } + catch( uno::Exception& e ) + { + e; + } + } +} + +uno::Reference< drawing::XShapes > + ShapeFactory::createGroup2D( const uno::Reference< drawing::XShapes >& xTarget + , ::rtl::OUString aName ) +{ + //create and add to target + uno::Reference< drawing::XShape > xShape( + m_xShapeFactory->createInstance( C2U( + "com.sun.star.drawing.GroupShape" ) ), uno::UNO_QUERY ); + xTarget->add(xShape); + + //set name + if(aName.getLength()) + setShapeName( xShape , aName ); + + {//workaround + //need this null size as otherwise empty group shapes where painted with a gray border + xShape->setSize(awt::Size(0,0)); + } + + //return + uno::Reference< drawing::XShapes > xShapes = + uno::Reference<drawing::XShapes>( xShape, uno::UNO_QUERY ); + return xShapes; +} + +uno::Reference< drawing::XShapes > + ShapeFactory::createGroup3D( const uno::Reference< drawing::XShapes >& xTarget + , ::rtl::OUString aName ) +{ + //create shape + uno::Reference< drawing::XShape > xShape( + m_xShapeFactory->createInstance( C2U( + "com.sun.star.drawing.Shape3DSceneObject" ) ), uno::UNO_QUERY ); + + xTarget->add(xShape); + + //it is necessary to set the transform matrix to initialize the scene properly (bug #106316#) + //otherwise all objects which are placed into this Group will not be visible + //the following should be unnecessary after a the bug is fixed + { + //set properties + uno::Reference< beans::XPropertySet > xProp( xShape, uno::UNO_QUERY ); + DBG_ASSERT(xProp.is(), "created shape offers no XPropertySet"); + if( xProp.is()) + { + try + { + Matrix4D aM4; + xProp->setPropertyValue( C2U( UNO_NAME_3D_TRANSFORM_MATRIX ) + , uno::makeAny(Matrix4DToHomogenMatrix(aM4)) ); + } + catch( uno::Exception& e ) + { + e; + } + } + } + + //set name + if(aName.getLength()) + setShapeName( xShape , aName ); + + //return + uno::Reference< drawing::XShapes > xShapes = + uno::Reference<drawing::XShapes>( xShape, uno::UNO_QUERY ); + return xShapes; +} + +uno::Reference< drawing::XShape > + ShapeFactory::createLine3D( const uno::Reference< drawing::XShapes >& xTarget + , const drawing::PolyPolygonShape3D& rPoints + , const LineProperties& rLineProperties ) +{ + if(!rPoints.SequenceX.getLength()) + return NULL; + + //create shape + uno::Reference< drawing::XShape > xShape( + m_xShapeFactory->createInstance( C2U( + "com.sun.star.drawing.Shape3DPolygonObject") ), 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 + { + //Polygon + xProp->setPropertyValue( C2U( UNO_NAME_3D_POLYPOLYGON3D ) + , uno::makeAny( rPoints ) ); + + //LineOnly + xProp->setPropertyValue( C2U( UNO_NAME_3D_LINEONLY ) + , uno::makeAny( (sal_Bool)true ) ); +/* + //Transparency + if(rLineProperties.Transparence.hasValue()) + xProp->setPropertyValue( C2U( UNO_NAME_LINETRANSPARENCE ) + , rLineProperties.Transparence ); + + //LineStyle + if(rLineProperties.LineStyle.hasValue()) + xProp->setPropertyValue( C2U( UNO_NAME_LINESTYLE ) + , rLineProperties.LineStyle ); + + //LineWidth + if(rLineProperties.Width.hasValue()) + xProp->setPropertyValue( C2U( UNO_NAME_LINEWIDTH ) + , rLineProperties.Width ); +*/ + //LineColor + if(rLineProperties.Color.hasValue()) + xProp->setPropertyValue( C2U( UNO_NAME_LINECOLOR ) + , rLineProperties.Color ); + //, uno::makeAny( sal_Int32( Color(COL_RED).GetColor()) ) ); + } + catch( uno::Exception& e ) + { + e; + } + } + return xShape; +} + +uno::Reference< drawing::XShape > + ShapeFactory::createLine2D( const uno::Reference< drawing::XShapes >& xTarget + , const drawing::PointSequenceSequence& rPoints + , const LineProperties& rLineProperties ) +{ + if(!rPoints.getLength()) + return NULL; + + //create shape + uno::Reference< drawing::XShape > xShape( + m_xShapeFactory->createInstance( C2U( + //"com.sun.star.drawing.LineShape") ), uno::UNO_QUERY ); + "com.sun.star.drawing.PolyLineShape") ), uno::UNO_QUERY ); + //"com.sun.star.drawing.PolyLinePathShape") ), uno::UNO_QUERY ); + //"com.sun.star.drawing.PolyPolygonPathShape") ), uno::UNO_QUERY ); + //"com.sun.star.drawing.PolyPolygonShape") ), 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 + { + //Polygon + xProp->setPropertyValue( C2U( UNO_NAME_POLYPOLYGON ) + , uno::makeAny( rPoints ) ); + + //Transparency + if(rLineProperties.Transparence.hasValue()) + xProp->setPropertyValue( C2U( UNO_NAME_LINETRANSPARENCE ) + , rLineProperties.Transparence ); + + //LineStyle + if(rLineProperties.LineStyle.hasValue()) + xProp->setPropertyValue( C2U( UNO_NAME_LINESTYLE ) + , rLineProperties.LineStyle ); + + //LineWidth + if(rLineProperties.Width.hasValue()) + xProp->setPropertyValue( C2U( UNO_NAME_LINEWIDTH ) + , rLineProperties.Width ); + + //LineColor + if(rLineProperties.Color.hasValue()) + xProp->setPropertyValue( C2U( UNO_NAME_LINECOLOR ) + , rLineProperties.Color ); + + //LineDash + if(rLineProperties.Dash.hasValue()) + xProp->setPropertyValue( C2U( UNO_NAME_LINEDASH ) + , rLineProperties.Dash ); + } + catch( uno::Exception& e ) + { + e; + } + } + return xShape; +} + +uno::Any ShapeFactory::makeTransformation( const awt::Point& rScreenPosition2D, double fRotationAnglePi ) +{ + Matrix3D aM3; + //As autogrow is active the rectangle is automatically expanded to that side + //to which the text is not adjusted. + aM3.Scale( 1, 1 ); + aM3.Rotate( fRotationAnglePi ); + aM3.Translate( rScreenPosition2D.X, rScreenPosition2D.Y ); + uno::Any aATransformation = uno::makeAny( Matrix3DToHomogenMatrix3(aM3) ); + return aATransformation; +} + +uno::Reference< drawing::XShape > + ShapeFactory::createText( const uno::Reference< drawing::XShapes >& xTarget + , const ::rtl::OUString& rText + , const tNameSequence& rPropNames + , const tAnySequence& rPropValues + , const uno::Any& rATransformation ) +{ + //create shape and add to page + uno::Reference< drawing::XShape > xShape( + m_xShapeFactory->createInstance( C2U( + "com.sun.star.drawing.TextShape" ) ), uno::UNO_QUERY ); + xTarget->add(xShape); + + //set text + uno::Reference< text::XTextRange > xTextRange( xShape, uno::UNO_QUERY ); + if( xTextRange.is() ) + xTextRange->setString( rText ); + + //set properties + PropertyMapper::setMultiProperties( rPropNames, rPropValues, xShape ); + + //set position matrix + //the matrix needs to be set at the end behind autogrow and such position influencing properties + uno::Reference< beans::XPropertySet > xProp( xShape, uno::UNO_QUERY ); + if( xProp.is() ) + { + try + { + xProp->setPropertyValue( C2U( "Transformation" ), rATransformation ); + } + catch( uno::Exception& e ) + { + e; + } + } + return xShape; + /* + //create 3D anchor shape + uno::Reference< drawing::XShape > xShape3DAnchor = createCube( xTarget3D + , DataPointGeometry( rGeometry.m_aPosition,drawing::Direction3D(1000,1000,1000) ) + , ShapeAppearance( Color(COL_YELLOW).GetColor() ) ); + //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 +rtl::OUString ShapeFactory::getStackedString( const rtl::OUString& rString, bool bStacked ) +{ + sal_Int32 nLen = rString.getLength(); + if(!bStacked || !nLen) + return rString; + + rtl::OUStringBuffer aStackStr; + rtl::OUStringBuffer aSource(rString); + + //add a newline after each letter + //as we do not no letters here add a newline after each char + for( sal_Int32 nPosSrc=0; nPosSrc < nLen; nPosSrc++ ) + { + aStackStr.append( aSource.charAt( nPosSrc ) ); + aStackStr.append( sal_Unicode('\r') ); + } + return aStackStr.makeStringAndClear(); +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/view/main/Stripe.cxx b/chart2/source/view/main/Stripe.cxx new file mode 100644 index 000000000000..6a090558a196 --- /dev/null +++ b/chart2/source/view/main/Stripe.cxx @@ -0,0 +1,197 @@ +/************************************************************************* + * + * $RCSfile: Stripe.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: bm $ $Date: 2003-10-06 09:58:34 $ + * + * 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 "Stripe.hxx" + +#ifndef __CHART_COMMON_CONVERTERS_HXX +#include "CommonConverters.hxx" +#endif + +#ifndef _COM_SUN_STAR_DRAWING_POLYPOLYGONSHAPE3D_HPP_ +#include <com/sun/star/drawing/PolyPolygonShape3D.hpp> +#endif +#ifndef _COM_SUN_STAR_DRAWING_DOUBLESEQUENCE_HPP_ +#include <com/sun/star/drawing/DoubleSequence.hpp> +#endif + +#ifndef _POLY3D_HXX +#include <svx/poly3d.hxx> +#endif + +using namespace ::com::sun::star; + +//............................................................................. +namespace chart +{ +//............................................................................. + +Stripe::Stripe( const drawing::Position3D& rPoint1 + , const drawing::Direction3D& rDirectionToPoint2 + , const drawing::Direction3D& rDirectionToPoint4 ) + : m_aPoint1(rPoint1) + , m_aPoint2(rPoint1+rDirectionToPoint2) + , m_aPoint3(m_aPoint2+rDirectionToPoint4) + , m_aPoint4(rPoint1+rDirectionToPoint4) +{ + +} + +drawing::Direction3D Stripe::GetDirectionTo4() const +{ + return m_aPoint4-m_aPoint1; +} + +/* +Stripe::Stripe( const drawing::Position3D& rPoint1 + , const drawing::Position3D& rPoint2 + , const drawing::Position3D& rPoint3 + , const drawing::Position3D& rPoint4 ) + : m_aPoint1(rPoint1) + , m_aPoint2(rPoint2) + , m_aPoint3(rPoint3) + , m_aPoint4(rPoint4) +{ + +} +*/ + +uno::Any Stripe::getPolyPolygonShape3D() const +{ + drawing::PolyPolygonShape3D aPP; + + aPP.SequenceX.realloc(1); + aPP.SequenceY.realloc(1); + aPP.SequenceZ.realloc(1); + + drawing::DoubleSequence* pOuterSequenceX = aPP.SequenceX.getArray(); + drawing::DoubleSequence* pOuterSequenceY = aPP.SequenceY.getArray(); + drawing::DoubleSequence* pOuterSequenceZ = aPP.SequenceZ.getArray(); + + pOuterSequenceX->realloc(4); + pOuterSequenceY->realloc(4); + pOuterSequenceZ->realloc(4); + + double* pInnerSequenceX = pOuterSequenceX->getArray(); + double* pInnerSequenceY = pOuterSequenceY->getArray(); + double* pInnerSequenceZ = pOuterSequenceZ->getArray(); + + *pInnerSequenceX++ = m_aPoint1.PositionX; + *pInnerSequenceY++ = m_aPoint1.PositionY; + *pInnerSequenceZ++ = m_aPoint1.PositionZ; + + *pInnerSequenceX++ = m_aPoint2.PositionX; + *pInnerSequenceY++ = m_aPoint2.PositionY; + *pInnerSequenceZ++ = m_aPoint2.PositionZ; + + *pInnerSequenceX++ = m_aPoint3.PositionX; + *pInnerSequenceY++ = m_aPoint3.PositionY; + *pInnerSequenceZ++ = m_aPoint3.PositionZ; + + *pInnerSequenceX++ = m_aPoint4.PositionX; + *pInnerSequenceY++ = m_aPoint4.PositionY; + *pInnerSequenceZ++ = m_aPoint4.PositionZ; + + return uno::Any( &aPP, ::getCppuType((const drawing::PolyPolygonShape3D*)0) ); +} + +drawing::Direction3D Stripe::getNormal() const +{ + Polygon3D aPolygon3D(3); + aPolygon3D[0] = Position3DToVector3D( m_aPoint1 ); + aPolygon3D[1] = Position3DToVector3D( m_aPoint2 ); + aPolygon3D[2] = Position3DToVector3D( m_aPoint3 ); + Vector3D aNormal = aPolygon3D.GetNormal(); + return Vector3DToDirection3D(aNormal); +} + +uno::Any Stripe::getNormalsPolyPolygonShape3D() const +{ + drawing::PolyPolygonShape3D aPP; + + aPP.SequenceX.realloc(1); + aPP.SequenceY.realloc(1); + aPP.SequenceZ.realloc(1); + + drawing::DoubleSequence* pOuterSequenceX = aPP.SequenceX.getArray(); + drawing::DoubleSequence* pOuterSequenceY = aPP.SequenceY.getArray(); + drawing::DoubleSequence* pOuterSequenceZ = aPP.SequenceZ.getArray(); + + pOuterSequenceX->realloc(4); + pOuterSequenceY->realloc(4); + pOuterSequenceZ->realloc(4); + + double* pInnerSequenceX = pOuterSequenceX->getArray(); + double* pInnerSequenceY = pOuterSequenceY->getArray(); + double* pInnerSequenceZ = pOuterSequenceZ->getArray(); + + drawing::Direction3D aNormal( getNormal() ); + + for(sal_Int32 nN=4; --nN; ) + { + *pInnerSequenceX++ = aNormal.DirectionX; + *pInnerSequenceY++ = aNormal.DirectionY; + *pInnerSequenceZ++ = aNormal.DirectionZ; + } + return uno::Any( &aPP, ::getCppuType((const drawing::PolyPolygonShape3D*)0) ); +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/view/main/VDataSeries.cxx b/chart2/source/view/main/VDataSeries.cxx new file mode 100644 index 000000000000..e4fa638209f2 --- /dev/null +++ b/chart2/source/view/main/VDataSeries.cxx @@ -0,0 +1,500 @@ +/************************************************************************* + * + * $RCSfile: VDataSeries.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: bm $ $Date: 2003-10-06 09:58:34 $ + * + * 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 "VDataSeries.hxx" +#include "chartview/ObjectIdentifier.hxx" +#include "macros.hxx" + +//#include "CommonConverters.hxx" + +#ifndef INCLUDED_RTL_MATH_HXX +#include <rtl/math.hxx> +#endif + +#ifndef _TOOLS_DEBUG_HXX +#include <tools/debug.hxx> +#endif + +#ifndef _DRAFTS_COM_SUN_STAR_CHART2_XNUMERICALDATASEQUENCE_HPP_ +#include <drafts/com/sun/star/chart2/XNumericalDataSequence.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ +#include <com/sun/star/beans/XPropertySet.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 +#ifndef _COM_SUN_STAR_TEXT_WRITINGMODE_HPP_ +#include <com/sun/star/text/WritingMode.hpp> +#endif + +//............................................................................. +namespace chart +{ +//............................................................................. +using namespace ::com::sun::star; +using namespace ::drafts::com::sun::star::chart2; +/* +void PlottingPositionHelper::setTransformationSceneToScreen( const drawing::HomogenMatrix& rMatrix) +{ + m_aMatrixScreenToScene = HomogenMatrixToMatrix4D(rMatrix); +} + +void PlottingPositionHelper::setScales( const uno::Sequence< ExplicitScaleData >& rScales ) +{ + m_aScales = rScales; +} +*/ +VDataSeries::VDataSeries() + : m_xShape(NULL) + , m_xLabelsShape(NULL) + , m_aAppearanceOfSeries(12632256) //LIGHT_GRAY is default color for dataseries for testing + , m_xDataSeries(NULL) + , m_aDataSequences() + , m_nPointCount(0) + , m_xData_XValues(NULL) + , m_xData_YValues(NULL) + , m_xData_ZValues(NULL) + + , m_apCaption_Series(NULL) + , m_apLabelPropNames_Series(NULL) + , m_apLabelPropValues_Series(NULL) + , m_apCaption_AttributedPoint(NULL) + , m_apLabelPropNames_AttributedPoint(NULL) + , m_apLabelPropValues_AttributedPoint(NULL) +{ + +} + +void initDoubleValues( uno::Sequence< double >& rDoubleValues, + const uno::Reference< XDataSequence >& xDataSequence ) +{ + OSL_ASSERT( xDataSequence.is()); + if(!xDataSequence.is()) + return; + + uno::Reference< XNumericalDataSequence > xNumericalDataSequence + = uno::Reference< XNumericalDataSequence >( xDataSequence, uno::UNO_QUERY ); + if( xNumericalDataSequence.is() ) + { + rDoubleValues = xNumericalDataSequence->getNumericalData(); + } + else + { + uno::Sequence< uno::Any > aValues = xDataSequence->getData(); + rDoubleValues.realloc(aValues.getLength()); + for(sal_Int32 nN=aValues.getLength();nN--;) + { + if( !(aValues[nN] >>= rDoubleValues[nN]) ) + { + ::rtl::math::setNan( &rDoubleValues[nN] ); + } + } + } +} + +VDataSeries::VDataSeries( uno::Reference< XDataSeries > xDataSeries, const ShapeAppearance& rDefaultAppearence ) + : m_xShape(NULL) + , m_xLabelsShape(NULL) + , m_aAppearanceOfSeries(rDefaultAppearence) //LIGHT_GRAY is default color for dataseries for testing + , m_xDataSeries(xDataSeries) + , m_aDataSequences() + , m_nPointCount(0) + , m_xData_XValues(NULL) + , m_xData_YValues(NULL) + , m_xData_ZValues(NULL) + + , m_apCaption_Series(NULL) + , m_apLabelPropNames_Series(NULL) + , m_apLabelPropValues_Series(NULL) + , m_apCaption_AttributedPoint(NULL) + , m_apLabelPropNames_AttributedPoint(NULL) + , m_apLabelPropValues_AttributedPoint(NULL) +{ + uno::Reference<XDataSource> xDataSource = + uno::Reference<XDataSource>( xDataSeries, uno::UNO_QUERY ); + + m_aDataSequences = xDataSource->getDataSequences(); + + for(sal_Int32 nN = m_aDataSequences.getLength();nN--;) + { + uno::Reference<XDataSequence> xDataSequence = m_aDataSequences[nN]; + uno::Reference<beans::XPropertySet> xProp(xDataSequence, uno::UNO_QUERY ); + if( xProp.is()) + { + try + { + uno::Any aARole = xProp->getPropertyValue( C2U( "Role" ) ); + rtl::OUString aRole; + aARole >>= aRole; + + if( aRole.equals(C2U("x-values")) ) + { + m_xData_XValues = xDataSequence; + } + else if( aRole.equals(C2U("values")) ) + { + m_xData_YValues = xDataSequence; + initDoubleValues( m_YValues_Double, m_xData_YValues ); + m_nPointCount = xDataSequence->getData().getLength(); //@todo determination of m_nPointCount may needs to be improved (e.g. max of x,y,z or something) + } + //@todo assign the other roles (+ error for unknown?) + } + catch( uno::Exception& e ) + { + e; + } + } + } + + + uno::Reference<beans::XPropertySet> xProp(xDataSeries, uno::UNO_QUERY ); + if( xProp.is()) + { + try + { + //get style + uno::Any aAFirstColor = xProp->getPropertyValue( C2U( "Color" ) ); + sal_Int32 nFirstColor; + if(aAFirstColor>>=nFirstColor) + m_aAppearanceOfSeries.m_nColorData = nFirstColor; + + //get CID + uno::Any aAIdentifier = xProp->getPropertyValue( C2U( "Identifier" ) ); + aAIdentifier >>= m_aIdentifier; + + m_aCID = ObjectIdentifier::createClassifiedIdentifier( + OBJECTTYPE_DATA_SERIES, m_aIdentifier ); + m_aPointCID_Stub = ObjectIdentifier::createPointCID_Stub( m_aCID ); + + m_aLabelCID_Stub = ObjectIdentifier::createClassifiedIdentifier( + OBJECTTYPE_DATA_LABEL, ::rtl::OUString(), getLabelsCID() ); + + //get AttributedDataPoints + xProp->getPropertyValue( C2U( "AttributedDataPoints" ) ) >>= m_aAttributedDataPointIndexList; + } + catch( uno::Exception& e ) + { + e; + } + } +} + +VDataSeries::~VDataSeries() +{ +} + +rtl::OUString VDataSeries::getCID() const +{ + return m_aCID; +} +rtl::OUString VDataSeries::getPointCID_Stub() const +{ + return m_aPointCID_Stub; +} +rtl::OUString VDataSeries::getLabelsCID() const +{ + return ObjectIdentifier::createClassifiedIdentifier( + OBJECTTYPE_DATA_LABELS, m_aIdentifier ); +} +rtl::OUString VDataSeries::getLabelCID_Stub() const +{ + return m_aLabelCID_Stub; +} + +sal_Int32 VDataSeries::getTotalPointCount() const +{ + return m_nPointCount; +} + +double VDataSeries::getX( sal_Int32 index ) const +{ + if(m_xData_XValues.is()) + { + return 1; //@todo + } + else + { + return index; + } +} + +double VDataSeries::getY( sal_Int32 index ) const +{ + if( 0<=index && index<m_YValues_Double.getLength() ) + return m_YValues_Double[index]; + else + { + double fNan; + ::rtl::math::setNan( & fNan ); + return fNan; + } +} + +rtl::OUString VDataSeries::getCategoryString( sal_Int32 index ) const +{ + //@todo get real Category string if any - else return empty string + rtl::OUString aRet; + if( 0<=index && index<m_nPointCount ) + { + aRet+=C2U("index "); + aRet+=rtl::OUString::valueOf(index); + } + return aRet; +} + +ShapeAppearance VDataSeries::getAppearanceOfPoint( sal_Int32 index ) const +{ + return m_aAppearanceOfSeries; +} + +bool VDataSeries::isAttributedDataPoint( sal_Int32 index ) const +{ + //returns true if the data point assigned by the given index has set it's own properties + if( index>=m_nPointCount || m_nPointCount==0) + return false; + for(sal_Int32 nN=m_aAttributedDataPointIndexList.getLength();nN--;) + { + if(index==m_aAttributedDataPointIndexList[nN]) + return true; + } + return false; +} + +uno::Reference< beans::XPropertySet > VDataSeries::getPropertiesOfPoint( sal_Int32 index ) const +{ + if( isAttributedDataPoint( index ) ) + return m_xDataSeries->getDataPointByIndex(index); + return this->getPropertiesOfSeries(); +} + +uno::Reference< beans::XPropertySet > VDataSeries::getPropertiesOfSeries() const +{ + return uno::Reference<beans::XPropertySet>(m_xDataSeries, uno::UNO_QUERY ); +} + +::std::auto_ptr< DataCaptionStyle > getDataCaptionStyleFromPropertySet( + const uno::Reference< beans::XPropertySet >& xProp ) +{ + ::std::auto_ptr< DataCaptionStyle > apCaption( new DataCaptionStyle() ); + try + { + if( !(xProp->getPropertyValue( C2U( "DataCaption" ) ) >>= *apCaption) ) + apCaption.reset(); + } + catch( uno::Exception &e) + { + e; + } + return apCaption; +} + +DataCaptionStyle* VDataSeries::getDataCaptionStyle( sal_Int32 index ) const +{ + DataCaptionStyle* pRet = NULL; + if( isAttributedDataPoint( index ) ) + { + if(!m_apCaption_AttributedPoint.get() || m_nCurrentAttributedPoint!=index) + { + m_apCaption_AttributedPoint = getDataCaptionStyleFromPropertySet( this->getPropertiesOfPoint( index ) ); + m_nCurrentAttributedPoint = index; + } + pRet = m_apCaption_AttributedPoint.get(); + } + else + { + if(!m_apCaption_Series.get()) + m_apCaption_Series = getDataCaptionStyleFromPropertySet( this->getPropertiesOfPoint( index ) ); + pRet = m_apCaption_Series.get(); + } + return pRet; +} + + +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 +{ + pPropNames = NULL; pPropValues = NULL; + if( isAttributedDataPoint( index ) ) + { + if(!m_apLabelPropValues_AttributedPoint.get() || m_nCurrentAttributedPoint!=index) + { + createTextLabelMultiPropertyListsFromPropertySet( + this->getPropertiesOfPoint( index ) + , m_apLabelPropNames_AttributedPoint + , m_apLabelPropValues_AttributedPoint ); + m_nCurrentAttributedPoint = index; + } + pPropNames = m_apLabelPropNames_AttributedPoint.get(); + pPropValues = m_apLabelPropValues_AttributedPoint.get(); + } + else + { + if(!m_apLabelPropValues_Series.get()) + { + createTextLabelMultiPropertyListsFromPropertySet( + this->getPropertiesOfPoint( index ) + , m_apLabelPropNames_Series + , m_apLabelPropValues_Series ); + } + pPropNames = m_apLabelPropNames_Series.get(); + pPropValues = m_apLabelPropValues_Series.get(); + } + if(pPropNames&&pPropValues) + return true; + return false; +} + +//----------------------------------------------------------------------------- + +/* +//static +sal_Int32 VDataSeries::getCategoryCount( + const uno::Sequence< uno::Reference< XDataSeries > >& rSeriesList ) +{ + sal_Int32 nRet = 1; + for( sal_Int32 nN = rSeriesList.getLength(); nN--; ) + { + uno::Reference<XDataSource> xDataSource = + uno::Reference<XDataSource>( rSeriesList[nN], uno::UNO_QUERY ); + + uno::Sequence< uno::Reference< XDataSequence > > aDataSequences + = xDataSource->getDataSequences(); + + for(sal_Int32 nN = aDataSequences.getLength();nN--;) + { + uno::Reference<XDataSequence> xDataSequence = aDataSequences[nN]; + uno::Reference<beans::XPropertySet> xProp(xDataSequence, uno::UNO_QUERY ); + if( xProp.is()) + { + try + { + uno::Any aARole = xProp->getPropertyValue( C2U( "Role" ) ); + rtl::OUString aRole; + aARole >>= aRole; + + if( aRole.equals(C2U("categories")) ) + { + sal_Int32 nCount = xDataSequence->getData().getLength(); + if(nRet<nCount) + nRet = nCount; + } + } + catch( uno::Exception& e ) + { + e; + } + } + } + + } + return nRet; +} +*/ + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/view/main/VLegend.cxx b/chart2/source/view/main/VLegend.cxx new file mode 100644 index 000000000000..bf081365dc66 --- /dev/null +++ b/chart2/source/view/main/VLegend.cxx @@ -0,0 +1,72 @@ +/************************************************************************* + * + * $RCSfile: VLegend.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: bm $ $Date: 2003-10-06 09:58:34 $ + * + * 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 _VLEGEND_HXX +#include "VLegend.hxx" +#endif + +//............................................................................. +namespace chart +{ +//............................................................................. + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/view/main/VLegend.hxx b/chart2/source/view/main/VLegend.hxx new file mode 100644 index 000000000000..f9712b6c67a0 --- /dev/null +++ b/chart2/source/view/main/VLegend.hxx @@ -0,0 +1,81 @@ +/************************************************************************* + * + * $RCSfile: VLegend.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: bm $ $Date: 2003-10-06 09:58:34 $ + * + * 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 _VLEGEND_HXX +#define _VLEGEND_HXX + +//............................................................................. +namespace chart +{ +//............................................................................. + +//----------------------------------------------------------------------------- +/** +*/ + +class VLegend +{ +}; + +//............................................................................. +} //namespace chart +//............................................................................. +#endif + diff --git a/chart2/source/view/main/VTitle.cxx b/chart2/source/view/main/VTitle.cxx new file mode 100644 index 000000000000..a70235e8f555 --- /dev/null +++ b/chart2/source/view/main/VTitle.cxx @@ -0,0 +1,314 @@ +/************************************************************************* + * + * $RCSfile: VTitle.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: bm $ $Date: 2003-10-06 09:58:34 $ + * + * 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 "VTitle.hxx" +#include "CommonConverters.hxx" +#include "macros.hxx" +#include "PropertyMapper.hxx" +#include "ShapeFactory.hxx" +#include "chartview/ObjectIdentifier.hxx" + +#ifndef _DRAFTS_COM_SUN_STAR_CHART2_XFORMATTEDSTRING_HPP_ +#include <drafts/com/sun/star/chart2/XFormattedString.hpp> +#endif +#ifndef _DRAFTS_COM_SUN_STAR_CHART2_XIDENTIFIABLE_HPP_ +#include <drafts/com/sun/star/chart2/XIdentifiable.hpp> +#endif + +// header for class Matrix3D +#ifndef _B2D_MATRIX3D_HXX +#include <goodies/matrix3d.hxx> +#endif + +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ +#include <com/sun/star/beans/XPropertySet.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_CONTROLCHARACTER_HPP_ +#include <com/sun/star/text/ControlCharacter.hpp> +#endif +#ifndef _COM_SUN_STAR_TEXT_XTEXT_HPP_ +#include <com/sun/star/text/XText.hpp> +#endif +#ifndef _COM_SUN_STAR_TEXT_XTEXTCURSOR_HPP_ +#include <com/sun/star/text/XTextCursor.hpp> +#endif + +//............................................................................. +namespace chart +{ +//............................................................................. +using namespace ::com::sun::star; +using namespace ::drafts::com::sun::star::chart2; + +VTitle::VTitle( const uno::Reference< XTitle > & xTitle ) + : m_xTarget(NULL) + , m_xShapeFactory(NULL) + , m_xTitle(xTitle) + , m_xShape(NULL) + , m_fRotationAngleDegree(0.0) + , m_nXPos(0) + , m_nYPos(0) +{ +} + +VTitle::~VTitle() +{ +} + +void SAL_CALL VTitle::init( + const uno::Reference< drawing::XShapes >& xTargetPage + , const uno::Reference< lang::XMultiServiceFactory >& xFactory ) +{ + m_xTarget = xTargetPage; + m_xShapeFactory = xFactory; +} + + +awt::Size VTitle::getSize() const +{ + awt::Size aRet; + if(m_xShape.is()) + { + aRet = m_xShape->getSize(); + } + return aRet; +} + +void VTitle::changePosition( const awt::Point& rPos ) +{ + if(!m_xShape.is()) + return; + uno::Reference< beans::XPropertySet > xShapeProp( m_xShape, uno::UNO_QUERY ); + if(!xShapeProp.is()) + return; + try + { + m_nXPos = rPos.X; + m_nYPos = rPos.Y; + + //set position matrix + //the matrix needs to be set at the end behind autogrow and such position influencing properties + Matrix3D aM3; + aM3.Scale( 1, 1 ); + aM3.Rotate( m_fRotationAngleDegree ); + aM3.Translate( m_nXPos, m_nYPos); + xShapeProp->setPropertyValue( C2U( "Transformation" ), uno::makeAny( Matrix3DToHomogenMatrix3(aM3) ) ); + } + catch( uno::Exception& e ) + { + e; + } +} + +void VTitle::createShapes( const awt::Point& rPos ) +{ + try + { + if(!m_xTitle.is()) + return; + + uno::Sequence< uno::Reference< XFormattedString > > aStringList = m_xTitle->getText(); + if(aStringList.getLength()<=0) + return; + + //create shape and add to page + uno::Reference< drawing::XShape > xShape( + m_xShapeFactory->createInstance( C2U( + "com.sun.star.drawing.TextShape" ) ), uno::UNO_QUERY ); + m_xTarget->add(xShape); + m_xShape = xShape; + + //set text and text properties + uno::Reference< text::XText > xText( xShape, uno::UNO_QUERY ); + uno::Reference< text::XTextRange > xTextRange( xShape, uno::UNO_QUERY ); + uno::Reference< text::XTextCursor > xTextCursor( xText->createTextCursor() ); + uno::Reference< beans::XPropertySet > xShapeProp( xShape, uno::UNO_QUERY ); + uno::Reference< beans::XPropertySet > xTitleProperties( m_xTitle, uno::UNO_QUERY ); + if( !xText.is() || !xTextRange.is() || !xTextCursor.is() || !xShapeProp.is() || !xTitleProperties.is() ) + return; + + tPropertyNameValueMap aValueMap; + //fill line-, fill- and paragraph-properties into the ValueMap + { + tMakePropertyNameMap aNameMap = PropertyMapper::getPropertyNameMapForParagraphProperties(); + const tMakePropertyNameMap& rFillPropMap = PropertyMapper::getPropertyNameMapForFillProperties(); + const tMakePropertyNameMap& rLinePropMap = PropertyMapper::getPropertyNameMapForLineProperties(); + aNameMap.insert(rFillPropMap.begin(),rFillPropMap.end()); + aNameMap.insert(rLinePropMap.begin(),rLinePropMap.end()); + + PropertyMapper::getValueMap( aValueMap, aNameMap, xTitleProperties ); + } + + //fill some more shape properties into the ValueMap + { + 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("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("TextMaximumFrameWidth"), uno::makeAny(rSize.Width) ) ); //sal_Int32 + ////aValueMap.insert( tPropertyNameValueMap::value_type( C2U("TextMaximumFrameHeight"), uno::makeAny(rSize.Height) ) ); //sal_Int32 + + //set name/classified ObjectID (CID) + uno::Reference< XIdentifiable > xIdent( m_xTitle, uno::UNO_QUERY ); + if( xIdent.is()) + { + rtl::OUString aCID = ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_TITLE, xIdent->getIdentifier() ); + aValueMap.insert( tPropertyNameValueMap::value_type( C2U("Name"), uno::makeAny( aCID ) ) ); //CID rtl::OUString + } + } + + //set global title properties + { + tNameSequence aPropNames; + tAnySequence aPropValues; + PropertyMapper::getMultiPropertyListsFromValueMap( aPropNames, aPropValues, aValueMap ); + PropertyMapper::setMultiProperties( aPropNames, aPropValues, xShape ); + } + + sal_Bool bStackCharacters(sal_False); + try + { + xTitleProperties->getPropertyValue( C2U( "StackCharacters" ) ) >>= bStackCharacters; + } + catch( uno::Exception& e ) + { + e; + } + if(bStackCharacters) + { + //if the characters should be stacked we use only the first character properties for code simplicity + if( aStringList.getLength()>0 ) + { + rtl::OUString aLabel; + for( sal_Int32 nN=0; nN<aStringList.getLength();nN++ ) + aLabel += aStringList[nN]->getString(); + aLabel = ShapeFactory::getStackedString( aLabel, bStackCharacters ); + xTextCursor->gotoEnd(false); + xText->insertString( xTextRange, aLabel, false ); + xTextCursor->gotoEnd(true); + uno::Reference< beans::XPropertySet > xTargetProps( xTextCursor, uno::UNO_QUERY ); + uno::Reference< beans::XPropertySet > xSourceProps( aStringList[0], uno::UNO_QUERY ); + + PropertyMapper::setMappedProperties( xTargetProps, xSourceProps + , PropertyMapper::getPropertyNameMapForCharacterProperties() ); + } + } + else + { + uno::Sequence< uno::Reference< text::XTextCursor > > aCursorList( aStringList.getLength() ); + for( sal_Int32 nN=0; nN<aStringList.getLength();nN++ ) + { + xTextCursor->gotoEnd(false); + xText->insertString( xTextRange, aStringList[nN]->getString(), false ); + xTextCursor->gotoEnd(true); + aCursorList[nN] = xText->createTextCursorByRange( uno::Reference< text::XTextRange >(xTextCursor,uno::UNO_QUERY) ); + } + for( nN=0; nN<aStringList.getLength();nN++ ) + { + uno::Reference< beans::XPropertySet > xTargetProps( aCursorList[nN], uno::UNO_QUERY ); + uno::Reference< beans::XPropertySet > xSourceProps( aStringList[nN], uno::UNO_QUERY ); + PropertyMapper::setMappedProperties( xTargetProps, xSourceProps, PropertyMapper::getPropertyNameMapForCharacterProperties() ); + } + } + + double fRotationAngleDegree( 0.0 ); + try + { + xTitleProperties->getPropertyValue( C2U( "TextRotation" ) ) >>= fRotationAngleDegree; + // convert DEG to RAD + fRotationAngleDegree *= ( F_PI / 180.0 ); + } + catch( uno::Exception& e ) + { + e; + } + m_fRotationAngleDegree = fRotationAngleDegree; + m_nXPos = rPos.X; + m_nYPos = rPos.Y; + + //set position matrix + //the matrix needs to be set at the end behind autogrow and such position influencing properties + Matrix3D aM3; + aM3.Scale( 1, 1 ); + aM3.Rotate( m_fRotationAngleDegree ); + aM3.Translate( m_nXPos, m_nYPos ); + xShapeProp->setPropertyValue( C2U( "Transformation" ), uno::makeAny( Matrix3DToHomogenMatrix3(aM3) ) ); + } + catch( uno::Exception& e ) + { + e; + } +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/view/main/VTitle.hxx b/chart2/source/view/main/VTitle.hxx new file mode 100644 index 000000000000..892698abd4c1 --- /dev/null +++ b/chart2/source/view/main/VTitle.hxx @@ -0,0 +1,121 @@ +/************************************************************************* + * + * $RCSfile: VTitle.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: bm $ $Date: 2003-10-06 09:58:34 $ + * + * 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_VTITLE_HXX +#define _CHART2_VTITLE_HXX + +#ifndef _DRAFTS_COM_SUN_STAR_CHART2_XTITLE_HPP_ +#include <drafts/com/sun/star/chart2/XTitle.hpp> +#endif + +#ifndef _COM_SUN_STAR_DRAWING_XSHAPES_HPP_ +#include <com/sun/star/drawing/XShapes.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#endif + +//............................................................................. +namespace chart +{ +//............................................................................. + +//----------------------------------------------------------------------------- +/** +*/ + +class VTitle +{ +public: + VTitle( const ::com::sun::star::uno::Reference< + ::drafts::com::sun::star::chart2::XTitle > & xTitle ); + virtual ~VTitle(); + + void SAL_CALL init( const ::com::sun::star::uno::Reference< + ::com::sun::star::drawing::XShapes >& xTargetPage + , const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory); + + //void setSceneMatrix( const ::com::sun::star::drawing::HomogenMatrix& rMatrix ); + + void createShapes( const ::com::sun::star::awt::Point& rPos ); + + ::com::sun::star::awt::Size getSize() const; + void changePosition( const ::com::sun::star::awt::Point& rPos ); + +private: + ::com::sun::star::uno::Reference< + ::com::sun::star::drawing::XShapes > m_xTarget; + ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XMultiServiceFactory> m_xShapeFactory; + ::com::sun::star::uno::Reference< + ::drafts::com::sun::star::chart2::XTitle > m_xTitle; + ::com::sun::star::uno::Reference< + ::com::sun::star::drawing::XShape > m_xShape; + + double m_fRotationAngleDegree; + sal_Int32 m_nXPos; + sal_Int32 m_nYPos; +}; + +//............................................................................. +} //namespace chart +//............................................................................. +#endif + diff --git a/chart2/source/view/main/makefile.mk b/chart2/source/view/main/makefile.mk new file mode 100644 index 000000000000..7e5024ac116a --- /dev/null +++ b/chart2/source/view/main/makefile.mk @@ -0,0 +1,95 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: bm $ $Date: 2003-10-06 09:58:34 $ +# +# 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: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +PRJ= ..$/..$/.. +PRJINC= $(PRJ)$/source +PRJNAME= chart2 +TARGET= chview + +ENABLE_EXCEPTIONS= TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE: settings.mk + +# --- export library ------------------------------------------------- + +#object files to build and link together to lib $(SLB)$/$(TARGET).lib +SLOFILES = \ + $(SLO)$/NumberFormatterWrapper.obj \ + $(SLO)$/ObjectIdentifier.obj \ + $(SLO)$/PropertyMapper.obj \ + $(SLO)$/Stripe.obj \ + $(SLO)$/DatapointGeometry.obj \ + $(SLO)$/ShapeAppearance.obj \ + $(SLO)$/ShapeFactory.obj \ + $(SLO)$/Linear3DTransformation.obj \ + $(SLO)$/PlottingPositionHelper.obj \ + $(SLO)$/PlotterBase.obj \ + $(SLO)$/VDataSeries.obj \ + $(SLO)$/VLegend.obj \ + $(SLO)$/VTitle.obj \ + $(SLO)$/ChartView.obj + +# --- Targets ----------------------------------------------------------------- + +.INCLUDE: target.mk |