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>
34using namespace ::ooo::vba::excel::XlAxisType;
35using namespace ::ooo::vba::excel::XlAxisGroup;
47 uno::Reference<container::XIndexAccess > m_xIndexAccess;
50 explicit EnumWrapper( uno::Reference< container::XIndexAccess > xIndexAccess ) : m_xIndexAccess(std::move( xIndexAccess )),
nIndex( 0 ) {}
51 virtual sal_Bool SAL_CALL hasMoreElements( )
override
53 return ( nIndex < m_xIndexAccess->getCount() );
56 virtual uno::Any SAL_CALL nextElement( )
override
58 if ( nIndex < m_xIndexAccess->getCount() )
59 return m_xIndexAccess->getByIndex(
nIndex++ );
60 throw container::NoSuchElementException();
66uno::Reference< excel::XAxis >
67ScVbaAxes::createAxis(
const uno::Reference< excel::XChart >& xChart,
const uno::Reference< uno::XComponentContext >& xContext, sal_Int32
nType, sal_Int32 nAxisGroup )
71 throw uno::RuntimeException(
"Object failure, can't access chart implementation" );
73 uno::Reference< beans::XPropertySet > xAxisPropertySet;
74 if ((
nType == xlCategory) || (
nType == xlSeriesAxis) || (
nType == xlValue))
76 if ((nAxisGroup != xlPrimary) && (nAxisGroup != xlSecondary))
82 uno::Reference< XHelperInterface > xParent( xChart, uno::UNO_QUERY_THROW );
83 return new ScVbaAxis( xParent, xContext, xAxisPropertySet,
nType, nAxisGroup);
88class AxisIndexWrapper :
public ::cppu::WeakImplHelper< container::XIndexAccess >
93 uno::Reference< uno::XComponentContext >
mxContext;
94 std::vector< AxesCoordinate > mCoordinates;
95 uno::Reference< excel::XChart > mxChart;
97 AxisIndexWrapper( uno::Reference< uno::XComponentContext > xContext, uno::Reference< excel::XChart > xChart ) :
mxContext(
std::move( xContext )), mxChart(
std::move( xChart ))
105 uno::Reference< beans::XPropertySet > xDiagramPropertySet( pChart->
xDiagramPropertySet() );
106 if ( ( xDiagramPropertySet->getPropertyValue(
"HasXAxis") >>= bBool ) && bBool )
107 mCoordinates.emplace_back( xlPrimary, xlCategory );
108 if ( ( xDiagramPropertySet->getPropertyValue(
"HasYAxis") >>= bBool ) && bBool )
109 mCoordinates.emplace_back( xlPrimary, xlSeriesAxis );
111 if ( pChart->
is3D() )
112 mCoordinates.emplace_back( xlPrimary, xlValue );
115 if ( ( xDiagramPropertySet->getPropertyValue(
"HasSecondaryXAxis") >>= bBool ) && bBool )
116 mCoordinates.emplace_back( xlSecondary, xlCategory );
117 if ( ( xDiagramPropertySet->getPropertyValue(
"HasSecondaryYAxis") >>= bBool ) && bBool )
118 mCoordinates.emplace_back( xlSecondary, xlSeriesAxis );
121 virtual ::sal_Int32 SAL_CALL getCount()
override {
return mCoordinates.size(); }
122 virtual uno::Any SAL_CALL getByIndex( ::sal_Int32
Index )
override
129 catch (
const css::script::BasicErrorException&)
132 throw css::lang::WrappedTargetException(
133 "Error Getting Index!",
139 virtual uno::Type SAL_CALL getElementType()
override
143 virtual sal_Bool SAL_CALL hasElements( )
override
145 return ( !mCoordinates.empty() );
149uno::Reference< container::XIndexAccess > createIndexWrapper(
const uno::Reference< excel::XChart >& xChart,
const uno::Reference< uno::XComponentContext >& xContext )
151 return new AxisIndexWrapper( xContext, xChart );
157ScVbaAxes::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 )
167uno::Reference< container::XEnumeration > SAL_CALL
179 sal_Int32 nAxisGroup = xlPrimary;
180 sal_Int32
nType = -1;
181 if ( !_nType.hasValue() || !( _nType >>=
nType ) )
182 throw uno::RuntimeException(
"Axes::Item Failed to extract type" );
184 if ( _oAxisGroup.hasValue() )
185 _oAxisGroup >>= nAxisGroup ;
202uno::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