1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "GridWrapper.hxx"
21 #include <AxisHelper.hxx>
22 #include "Chart2ModelContact.hxx"
23 #include <AxisIndexDefines.hxx>
24 #include <BaseCoordinateSystem.hxx>
26 #include <LinePropertiesHelper.hxx>
27 #include <UserDefinedProperties.hxx>
28 #include <WrappedDefaultProperty.hxx>
30 #include <comphelper/sequence.hxx>
31 #include <cppuhelper/supportsservice.hxx>
34 #include <comphelper/diagnose_ex.hxx>
36 using namespace ::com::sun::star
;
38 using ::com::sun::star::beans::Property
;
39 using ::com::sun::star::uno::Reference
;
40 using ::com::sun::star::uno::Sequence
;
42 namespace chart::wrapper
45 GridWrapper::GridWrapper(tGridType eType
, std::shared_ptr
<Chart2ModelContact
> spChart2ModelContact
)
46 : m_spChart2ModelContact(std::move(spChart2ModelContact
))
51 GridWrapper::~GridWrapper()
54 void GridWrapper::getDimensionAndSubGridBool( tGridType eType
, sal_Int32
& rnDimensionIndex
, bool& rbSubGrid
)
62 rnDimensionIndex
= 0; rbSubGrid
= false; break;
64 rnDimensionIndex
= 1; rbSubGrid
= false; break;
66 rnDimensionIndex
= 2; rbSubGrid
= false; break;
68 rnDimensionIndex
= 0; rbSubGrid
= true; break;
70 rnDimensionIndex
= 1; rbSubGrid
= true; break;
72 rnDimensionIndex
= 2; rbSubGrid
= true; break;
76 // ____ XComponent ____
77 void SAL_CALL
GridWrapper::dispose()
79 std::unique_lock
g(m_aMutex
);
80 Reference
< uno::XInterface
> xSource( static_cast< ::cppu::OWeakObject
* >( this ) );
81 m_aEventListenerContainer
.disposeAndClear( g
, lang::EventObject( xSource
) );
83 clearWrappedPropertySet();
86 void SAL_CALL
GridWrapper::addEventListener(
87 const Reference
< lang::XEventListener
>& xListener
)
89 std::unique_lock
g(m_aMutex
);
90 m_aEventListenerContainer
.addInterface( g
, xListener
);
93 void SAL_CALL
GridWrapper::removeEventListener(
94 const Reference
< lang::XEventListener
>& aListener
)
96 std::unique_lock
g(m_aMutex
);
97 m_aEventListenerContainer
.removeInterface( g
, aListener
);
100 // WrappedPropertySet
102 Reference
< beans::XPropertySet
> GridWrapper::getInnerPropertySet()
104 Reference
< beans::XPropertySet
> xRet
;
107 rtl::Reference
< ::chart::Diagram
> xDiagram( m_spChart2ModelContact
->getDiagram() );
108 rtl::Reference
< BaseCoordinateSystem
> xCooSys( AxisHelper::getCoordinateSystemByIndex( xDiagram
, 0 /*nCooSysIndex*/ ) );
110 sal_Int32 nDimensionIndex
= 1;
111 bool bSubGrid
= false;
112 getDimensionAndSubGridBool( m_eType
, nDimensionIndex
, bSubGrid
);
114 sal_Int32 nSubGridIndex
= bSubGrid
? 0 : -1;
115 xRet
= AxisHelper::getGridProperties( xCooSys
, nDimensionIndex
, MAIN_AXIS_INDEX
, nSubGridIndex
);
117 catch( const uno::Exception
& )
119 DBG_UNHANDLED_EXCEPTION("chart2");
124 const Sequence
< beans::Property
>& GridWrapper::getPropertySequence()
126 static Sequence
< Property
> aPropSeq
= []()
128 std::vector
< css::beans::Property
> aProperties
;
129 ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties
);
130 ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties
);
132 std::sort( aProperties
.begin(), aProperties
.end(),
133 ::chart::PropertyNameLess() );
135 return comphelper::containerToSequence( aProperties
);
140 std::vector
< std::unique_ptr
<WrappedProperty
> > GridWrapper::createWrappedProperties()
142 std::vector
< std::unique_ptr
<WrappedProperty
> > aWrappedProperties
;
144 aWrappedProperties
.emplace_back( new WrappedDefaultProperty( u
"LineColor"_ustr
, u
"LineColor"_ustr
, uno::Any( sal_Int32( 0x000000) ) ) ); // black
146 return aWrappedProperties
;
149 OUString SAL_CALL
GridWrapper::getImplementationName()
151 return u
"com.sun.star.comp.chart.Grid"_ustr
;
154 sal_Bool SAL_CALL
GridWrapper::supportsService( const OUString
& rServiceName
)
156 return cppu::supportsService(this, rServiceName
);
159 css::uno::Sequence
< OUString
> SAL_CALL
GridWrapper::getSupportedServiceNames()
162 u
"com.sun.star.chart.ChartGrid"_ustr
,
163 u
"com.sun.star.xml.UserDefinedAttributesSupplier"_ustr
,
164 u
"com.sun.star.drawing.LineProperties"_ustr
,
165 u
"com.sun.star.beans.PropertySet"_ustr
169 } // namespace chart::wrapper
171 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */