office-gobmx/chart2/source/inc/DiagramHelper.hxx
Vladimir Glazounov ade1860aeb INTEGRATION: CWS chart2mst3 (1.2.4); FILE MERGED
2007/04/20 08:08:49 iha 1.2.4.51: #i75393# Connect Bars per diagram not per series
2007/04/19 16:10:53 iha 1.2.4.50: #i76130# write attribute sort-by-x-values per plot-area not per series
2007/03/01 13:54:29 iha 1.2.4.49: #i71167 & i74564# keep charttype properties if possible when switching charttypes
2007/02/09 17:29:18 bm 1.2.4.48: XChartDocument::createInternalDataProvider() works like expected now
2007/01/10 12:39:25 bm 1.2.4.47: extra qualifier removed
2006/12/07 23:17:54 iha 1.2.4.46: #i67833# simple 3D look - bring light to front
2006/08/21 16:13:59 iha 1.2.4.45: #i46521# replace modal x value sorting dialog by a checkbox in the chartwizard; perform sorting in view only and not in the cached chart data (as there is no cached data in the model anymore)
2006/08/09 17:40:26 iha 1.2.4.44: #i63017# disable/enable menu Format->Arrangement
2006/06/30 22:20:19 iha 1.2.4.43: correct 3D pie rotation: different default camera for pies
2006/06/24 18:30:02 iha 1.2.4.42: don't show wall nor floor for pies and donuts until older files can be detected
2006/06/18 19:27:41 iha 1.2.4.41: implement camera distance
2006/06/09 15:30:20 iha 1.2.4.40: concentrated helping method for getting and setting rotation of diagram - don't touch the camera rotation but take it into account
2006/04/22 11:12:44 iha 1.2.4.39: park unused categories in scale with AxisType not being CATEGORY
2006/04/10 12:25:08 iha 1.2.4.38: api restructure axis, grids, scales and increments
2006/01/16 12:08:57 bm 1.2.4.37: also reset diagram rotation in rearrange function
2005/12/21 21:29:13 iha 1.2.4.36: remove identifiers from model objects and create an index based CID protocol instead for selection purposes
2005/11/28 15:35:40 bm 1.2.4.35: BarConnectors implemented the old way (all series at once) but model offers the property ConnectDataPoints for each series independently
2005/11/23 15:14:04 iha 1.2.4.34: support BarOverlap and GapWidth
2005/11/08 14:55:50 iha 1.2.4.33: set and remove categories also to and from secondary scales
2005/11/07 20:55:47 iha 1.2.4.32: implement changing series order
2005/11/02 19:16:18 iha 1.2.4.31: enable load of stock chart with japanese boxes
2005/11/02 16:09:43 bm 1.2.4.30: removed unused function getInterpretedDataFromDiagram
2005/11/02 13:49:20 bm 1.2.4.29: scene properties changed from SceneDescriptor property to the D3D properties offered by SceneProperties.hxx (this way XML im-/export works with the xmloff helper)
2005/11/01 13:05:56 iha 1.2.4.28: support sequence mapping
2005/10/24 11:06:40 iha 1.2.4.27: coordinate system restructure
2005/10/13 17:38:50 iha 1.2.4.26: renamed BoundedCoordinateSystem to CoordinateSystem
2005/10/11 12:51:23 bm 1.2.4.25: +removeUnusedCoordinateSystems
2005/10/07 11:40:06 bm 1.2.4.24: RESYNC: (1.2-1.3); FILE MERGED
2005/09/22 16:56:15 iha 1.2.4.23: automatic categories for pie legend
2005/09/16 16:50:10 iha 1.2.4.22: no creation of dummy categories in model - instead trigger generation of missing labels and categories in view
2005/07/14 14:51:10 bm 1.2.4.21: function for creating dummy categories (preliminary, not localized yet)
2005/05/09 09:51:04 bm 1.2.4.20: moved parts of API to data namespace
2005/05/04 12:51:51 iha 1.2.4.19: added methods isSeriesAttachedToMainAxis(), attachSeriesToAxis(), getChartTypeOfSeries(), getCoordinateSystemOfChartType(), clearCoordinateSystem()
2005/04/19 14:34:07 bm 1.2.4.18: +getScaleHoldingCategoriesFromDiagram
2005/04/11 11:32:45 iha 1.2.4.17: changed parameter for methods set/getVertical() for old api
2004/09/20 17:25:48 bm 1.2.4.16: add parameter to setStackMode that only sets the mode at the first chart-type
2004/09/16 14:43:48 iha 1.2.4.15: implement api redesign
2004/09/16 12:21:56 bm 1.2.4.14: API simplification
2004/09/15 17:06:29 bm 1.2.4.13: +getStackModeFromChartType
2004/09/15 14:32:04 iha 1.2.4.12: implement api redesign
2004/09/15 14:30:19 bm 1.2.4.11: API simplification
2004/09/15 11:48:43 iha 1.2.4.10: implement api redesign
2004/09/15 11:21:11 bm 1.2.4.9: API simplification
2004/06/29 12:42:44 bm 1.2.4.8: +getInterpretedDataFromDiagram
2004/05/27 17:28:26 bm 1.2.4.7: +bTreatBarsAsVertical flag in get/setVertical methods
2004/05/13 09:51:53 bm 1.2.4.6: getTemplateForDiagram() supports a parameter rPreferredTemplateName for faster
access in case the template didn't change
2004/04/01 16:03:01 bm 1.2.4.5: some more fixes for setDimension() for old API
2004/04/01 10:48:41 bm 1.2.4.4: +functions to get/set the SwapXAndYAxis property at coordinate-systems
2004/03/24 19:05:23 bm 1.2.4.3: XChartTypeTemplate changed: matchesTemplate may modify the
template s properties if bAdaptProperties is true
2004/03/24 10:35:14 bm 1.2.4.2: +getTemplateNameForDiagram
2004/02/13 16:51:23 bm 1.2.4.1: join from changes on branch bm_post_chart01
2007-05-22 17:15:39 +00:00

386 lines
15 KiB
C++

/*************************************************************************
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: DiagramHelper.hxx,v $
*
* $Revision: 1.4 $
*
* last change: $Author: vg $ $Date: 2007-05-22 18:15:39 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
*
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2005 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
*
************************************************************************/
#ifndef CHART2_DIAGRAMHELPER_HXX
#define CHART2_DIAGRAMHELPER_HXX
#include "StackMode.hxx"
#ifndef _COM_SUN_STAR_CHART2_XAXIS_HPP_
#include <com/sun/star/chart2/XAxis.hpp>
#endif
#ifndef _COM_SUN_STAR_CHART2_XDIAGRAM_HPP_
#include <com/sun/star/chart2/XDiagram.hpp>
#endif
#ifndef _COM_SUN_STAR_CHART2_XCHARTTYPETEMPLATE_HPP_
#include <com/sun/star/chart2/XChartTypeTemplate.hpp>
#endif
#ifndef _COM_SUN_STAR_CHART2_XCOORDINATESYSTEM_HPP_
#include <com/sun/star/chart2/XCoordinateSystem.hpp>
#endif
#ifndef _COM_SUN_STAR_CHART2_INTERPRETEDDATA_HPP_
#include <com/sun/star/chart2/InterpretedData.hpp>
#endif
#ifndef _COM_SUN_STAR_CHART2_STACKINGDIRECTION_HPP_
#include <com/sun/star/chart2/StackingDirection.hpp>
#endif
#ifndef _COM_SUN_STAR_CHART2_XCHARTDOCUMENT_HPP_
#include <com/sun/star/chart2/XChartDocument.hpp>
#endif
#ifndef _COM_SUN_STAR_DRAWING_CAMERAGEOMETRY_HPP_
#include <com/sun/star/drawing/CameraGeometry.hpp>
#endif
#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#endif
#ifndef _COM_SUN_STAR_UNO_XCOMPONENTCONTEXT_HPP_
#include <com/sun/star/uno/XComponentContext.hpp>
#endif
#include <utility>
#include <vector>
namespace chart
{
class DiagramHelper
{
public:
typedef ::std::pair<
::com::sun::star::uno::Reference<
::com::sun::star::chart2::XChartTypeTemplate >,
::rtl::OUString >
tTemplateWithServiceName;
/** tries to find a template in the chart-type manager that matches the
given diagram.
@param rPreferredTemplateName
Check this template first. This may speed up searching, if the
caller assumes a certain template as most likely to be the one that
matches.
@return
A pair containing a template with the correct properties set as
first entry and the service name of the templateas second entry. If
no template was found both elements are empty.
*/
static tTemplateWithServiceName
getTemplateForDiagram(
const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XDiagram > & xDiagram,
const ::com::sun::star::uno::Reference<
::com::sun::star::lang::XMultiServiceFactory > & xChartTypeManager,
const ::rtl::OUString & rPreferredTemplateName = ::rtl::OUString());
/** Sets the "SwapXAndYAxis" property at all coordinate systems found in the
given diagram.
"vertical==true" for bar charts, "vertical==false" for column charts
*/
static void setVertical( const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XDiagram > & xDiagram,
bool bVertical = true );
/** Gets the "SwapXAndYAxis" property at all coordinate systems found in the
given diagram.
"vertical==true" for bar charts, "vertical==false" for column charts
*/
static bool getVertical( const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XDiagram > & xDiagram,
bool& rbOutFoundResult, bool& rbOutAmbiguousResult );
static StackMode getStackMode(
const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XDiagram > & xDiagram
);
/** @param bOnlyAtFirstChartType
If </TRUE>, the stacking mode is only set at the series found inside
the first chart type. This is the standard for all current
templates (the only template that has more than one chart-type and
allows stacking is bar/line combi, and for this the stacking only
applies to the first chart type/the bars)
*/
static void setStackMode(
const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XDiagram > & xDiagram,
StackMode eStackMode,
bool bOnlyAtFirstChartType = false
);
/** Retrieves the stackmode of a ChartType. If the series inside the
ChartType are differing, the StackMode StackMode_AMBIGUOUS is returned.
@param xCorrespondingCoordinateSystem
The coordinate system in which the given chart type xChartType is
located. (This is needed for determining percent stacking. If
omitted, the result will just indicate "not stacked", "stacked" or
"ambiguous")
*/
static StackMode getStackModeFromChartType(
const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XChartType > & xChartType,
const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XCoordinateSystem > & xCorrespondingCoordinateSystem =
::com::sun::star::uno::Reference< ::com::sun::star::chart2::XCoordinateSystem >()
);
/** Returns the dimension found for all chart types in the tree. If the
dimension is not unique, 0 is returned.
*/
static sal_Int32 getDimension(
const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XDiagram > & xDiagram );
/** Sets the dimension of the diagram given.
1. Sets the dimension of all used ChartTypes
2. Adapts the DataSeriesTree to reflect the new dimension
3. If new coordinate-systems have to be created, adapts the
XCoordinateSystemContainer of the diagram.
*/
static void setDimension(
const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XDiagram > & xDiagram,
sal_Int32 nNewDimensionCount );
/** Replaces all occurences of xCooSysToReplace in the tree with
xReplacement in the diagram's tree
*/
static void replaceCoordinateSystem(
const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XDiagram > & xDiagram,
const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XCoordinateSystem > & xCooSysToReplace,
const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XCoordinateSystem > & xReplacement );
static bool isSeriesAttachedToMainAxis(
const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XDataSeries >& xDataSeries );
static bool attachSeriesToAxis( bool bMainAxis,
const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XDataSeries >& xSeries,
const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XDiagram >& xDiagram,
const ::com::sun::star::uno::Reference<
::com::sun::star::uno::XComponentContext > & xContext );
static ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XAxis > getAttachedAxis(
const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XDataSeries >& xSeries,
const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XDiagram >& xDiagram );
static ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XChartType >
getChartTypeOfSeries(
const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XDiagram >& xDiagram,
const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XDataSeries >& xSeries );
static ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XCoordinateSystem >
getCoordinateSystemOfChartType(
const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XDiagram >& xDiagram,
const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XChartType >& xChartType );
static ::std::vector<
::com::sun::star::uno::Reference<
::com::sun::star::chart2::XDataSeries > >
getDataSeriesFromDiagram(
const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XDiagram > & xDiagram );
/** return all data series in this diagram grouped by chart-types
*/
static ::com::sun::star::uno::Sequence<
::com::sun::star::uno::Sequence<
::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries > > >
getDataSeriesGroups(
const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XDiagram > & xDiagram );
static bool isCategoryDiagram(
const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XDiagram >& xDiagram );
static void setCategoriesToDiagram(
const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::data::XLabeledDataSequence >& xCategories,
const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XDiagram >& xDiagram,
bool bSetAxisType = false, // when this flag is true ...
bool bCategoryAxis = true);// set the AxisType to CATEGORY or back to REALNUMBER
static ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XLabeledDataSequence >
getCategoriesFromDiagram(
const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XDiagram > & xDiagram );
static ::com::sun::star::uno::Sequence< rtl::OUString >
generateAutomaticCategories(
const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XChartDocument > & xChartDoc );
static ::com::sun::star::uno::Sequence< rtl::OUString >
generateAutomaticCategories(
const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XCoordinateSystem > & xCooSys );
static void generateAutomaticCategoriesFromChartType(
::com::sun::star::uno::Sequence< rtl::OUString >& rRet,
const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartType >& xChartType );
static ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XChartType >
getChartTypeByIndex( const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XDiagram >& xDiagram, sal_Int32 nIndex );
static ::com::sun::star::uno::Sequence<
::com::sun::star::uno::Reference<
::com::sun::star::chart2::XChartType > >
getChartTypesFromDiagram(
const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XDiagram > & xDiagram );
static bool areChartTypesCompatible( const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XChartType >& xFirstType,
const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XChartType >& xSecondType );
/**
* Test if a series can be moved.
*
* @param xDiagram
* Reference to the diagram that contains the series.
*
* @param xGivenDataSeries
* Reference to the series that should be tested for moving.
*
* @param bForward
* Direction of the move to be checked.
*
* @returns </TRUE> if the series can be moved.
*
*/
static bool isSeriesMoveable(
const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XDiagram >& xDiagram,
const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XDataSeries >& xGivenDataSeries,
bool bForward );
/**
* Move a series forward or backward.
*
* @param xDiagram
* Reference to the diagram that contains the series.
*
* @param xGivenDataSeries
* Reference to the series that should be moved.
*
* @param bForward
* Direction in which the series should be moved.
*
* @returns </TRUE> if the series was moved successfully.
*
*/
static bool moveSeries(
const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XDiagram >& xDiagram,
const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XDataSeries >& xGivenDataSeries,
bool bForward );
static sal_Int32 getIndexOfSeriesWithinChartType(
const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XDataSeries >& xDataSeries,
const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XChartType >& xChartType );
/** Returns the default camera geometry that is set in the Diagram CTOR.
This is not the property default!
@todo deprecate the hard set camera geometry and use the property
default
*/
static ::com::sun::star::drawing::CameraGeometry getDefaultCameraGeometry( bool bPie=false );
static void getRotationAngleFromDiagram(
const ::com::sun::star::uno::Reference<
::com::sun::star::beans::XPropertySet >& xSceneProperties
, double& rfXAngleRad, double& rfYAngleRad, double& rfZAngleRad );
static void setRotationAngleToDiagram(
const ::com::sun::star::uno::Reference<
::com::sun::star::beans::XPropertySet >& xSceneProperties
, double fXAngleRad, double fYAngleRad, double fZAngleRad );
static double getCameraDistance(
const ::com::sun::star::uno::Reference<
::com::sun::star::beans::XPropertySet >& xSceneProperties );
static void setCameraDistance(
const ::com::sun::star::uno::Reference<
::com::sun::star::beans::XPropertySet >& xSceneProperties
, double fCameraDistance );
static void ensureCameraDistanceRange( double& rfCameraDistance );
static void getCameraDistanceRange( double& rfMinimumDistance, double& rfMaximumDistance );
static bool isSupportingFloorAndWall( const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XDiagram > & xDiagram );
static bool isPieOrDonutChart( const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XDiagram >& xDiagram );
private:
// not implemented
DiagramHelper();
};
} // namespace chart
// CHART2_DIAGRAMHELPER_HXX
#endif