26#include <com/sun/star/script/BasicErrorException.hpp>
27#include <ooo/vba/excel/XlAxisType.hpp>
28#include <ooo/vba/excel/XlAxisGroup.hpp>
29#include <ooo/vba/excel/XAxis.hpp>
33using namespace ::ooo::vba::excel::XlAxisType;
34using namespace ::ooo::vba::excel::XlAxisGroup;
46 uno::Reference<container::XIndexAccess > m_xIndexAccess;
49 explicit EnumWrapper(
const uno::Reference< container::XIndexAccess >& xIndexAccess ) : m_xIndexAccess( xIndexAccess ),
nIndex( 0 ) {}
50 virtual sal_Bool SAL_CALL hasMoreElements( )
override
52 return ( nIndex < m_xIndexAccess->getCount() );
55 virtual uno::Any SAL_CALL nextElement( )
override
57 if ( nIndex < m_xIndexAccess->getCount() )
58 return m_xIndexAccess->getByIndex(
nIndex++ );
59 throw container::NoSuchElementException();
65uno::Reference< excel::XAxis >
66ScVbaAxes::createAxis(
const uno::Reference< excel::XChart >& xChart,
const uno::Reference< uno::XComponentContext >& xContext, sal_Int32
nType, sal_Int32 nAxisGroup )
70 throw uno::RuntimeException(
"Object failure, can't access chart implementation" );
72 uno::Reference< beans::XPropertySet > xAxisPropertySet;
73 if ((
nType == xlCategory) || (
nType == xlSeriesAxis) || (
nType == xlValue))
75 if ((nAxisGroup != xlPrimary) && (nAxisGroup != xlSecondary))
81 uno::Reference< XHelperInterface > xParent( xChart, uno::UNO_QUERY_THROW );
82 return new ScVbaAxis( xParent, xContext, xAxisPropertySet,
nType, nAxisGroup);
87class AxisIndexWrapper :
public ::cppu::WeakImplHelper< container::XIndexAccess >
92 uno::Reference< uno::XComponentContext >
mxContext;
93 std::vector< AxesCoordinate > mCoordinates;
94 uno::Reference< excel::XChart > mxChart;
96 AxisIndexWrapper(
const uno::Reference< uno::XComponentContext >& xContext,
const uno::Reference< excel::XChart >& xChart ) :
mxContext( xContext ), mxChart( xChart )
104 uno::Reference< beans::XPropertySet > xDiagramPropertySet( pChart->
xDiagramPropertySet() );
105 if ( ( xDiagramPropertySet->getPropertyValue(
"HasXAxis") >>= bBool ) && bBool )
106 mCoordinates.emplace_back( xlPrimary, xlCategory );
107 if ( ( xDiagramPropertySet->getPropertyValue(
"HasYAxis") >>= bBool ) && bBool )
108 mCoordinates.emplace_back( xlPrimary, xlSeriesAxis );
110 if ( pChart->
is3D() )
111 mCoordinates.emplace_back( xlPrimary, xlValue );
114 if ( ( xDiagramPropertySet->getPropertyValue(
"HasSecondaryXAxis") >>= bBool ) && bBool )
115 mCoordinates.emplace_back( xlSecondary, xlCategory );
116 if ( ( xDiagramPropertySet->getPropertyValue(
"HasSecondaryYAxis") >>= bBool ) && bBool )
117 mCoordinates.emplace_back( xlSecondary, xlSeriesAxis );
120 virtual ::sal_Int32 SAL_CALL getCount()
override {
return mCoordinates.size(); }
121 virtual uno::Any SAL_CALL getByIndex( ::sal_Int32
Index )
override
128 catch (
const css::script::BasicErrorException&)
131 throw css::lang::WrappedTargetException(
132 "Error Getting Index!",
133 static_cast < OWeakObject *
> (
this ),
138 virtual uno::Type SAL_CALL getElementType()
override
142 virtual sal_Bool SAL_CALL hasElements( )
override
144 return ( !mCoordinates.empty() );
148uno::Reference< container::XIndexAccess > createIndexWrapper(
const uno::Reference< excel::XChart >& xChart,
const uno::Reference< uno::XComponentContext >& xContext )
150 return new AxisIndexWrapper( xContext, xChart );
156ScVbaAxes::ScVbaAxes(
const uno::Reference< XHelperInterface >& xParent,
const uno::Reference< uno::XComponentContext > & xContext,
const uno::Reference< excel::XChart >& xChart ) :
ScVbaAxes_BASE( xParent, xContext, createIndexWrapper( xChart, xContext )), moChartParent( xChart )
166uno::Reference< container::XEnumeration > SAL_CALL
178 sal_Int32 nAxisGroup = xlPrimary;
179 sal_Int32
nType = -1;
180 if ( !_nType.hasValue() || !( _nType >>=
nType ) )
181 throw uno::RuntimeException(
"Axes::Item Failed to extract type" );
183 if ( _oAxisGroup.hasValue() )
184 _oAxisGroup >>= nAxisGroup ;
201uno::Sequence< OUString >
css::uno::Reference< css::uno::XComponentContext > mxContext
virtual css::uno::Sequence< OUString > getServiceNames() override
css::uno::Reference< ov::excel::XChart > moChartParent
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
virtual css::uno::Type SAL_CALL getElementType() override
virtual css::uno::Any SAL_CALL Item(const css::uno::Any &aIndex, const css::uno::Any &aIndex2) override
virtual OUString getServiceImplName() override
virtual css::uno::Any createCollectionObject(const css::uno::Any &) override
static css::uno::Reference< ov::excel::XAxis > createAxis(const css::uno::Reference< ov::excel::XChart > &xChart, const css::uno::Reference< css::uno::XComponentContext > &xContext, sal_Int32 nType, sal_Int32 nAxisGroup)
ScVbaAxes(const css::uno::Reference< ov::XHelperInterface > &xParent, const css::uno::Reference< css::uno::XComponentContext > &xContext, const css::uno::Reference< ov::excel::XChart > &xChart)
const css::uno::Reference< css::beans::XPropertySet > & xDiagramPropertySet() const
css::uno::Reference< css::beans::XPropertySet > getAxisPropertySet(sal_Int32 _nAxisType, sal_Int32 _nAxisGroup)
css::uno::Reference< css::container::XIndexAccess > m_xIndexAccess
css::uno::Type const & get()
Sequence< OUString > aServiceNames
Any SAL_CALL getCaughtException()
#define ERRCODE_BASIC_METHOD_FAILED
::std::pair< sal_Int32, sal_Int32 > AxesCoordinate
::cppu::WeakImplHelper< css::container::XEnumeration > EnumerationHelper_BASE