LibreOffice Module chart2 (master) 1
GridWrapper.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include "GridWrapper.hxx"
21#include <AxisHelper.hxx>
23#include <AxisIndexDefines.hxx>
25#include <GridProperties.hxx>
26
30
33#include <algorithm>
34#include <utility>
36
37using namespace ::com::sun::star;
38using namespace ::com::sun::star::chart2;
39
40using ::com::sun::star::beans::Property;
41using ::com::sun::star::uno::Reference;
42using ::com::sun::star::uno::Sequence;
43
44namespace chart::wrapper
45{
46
47GridWrapper::GridWrapper(tGridType eType, std::shared_ptr<Chart2ModelContact> spChart2ModelContact)
48 : m_spChart2ModelContact(std::move(spChart2ModelContact))
49 , m_eType(eType)
50{
51}
52
54{}
55
56void GridWrapper::getDimensionAndSubGridBool( tGridType eType, sal_Int32& rnDimensionIndex, bool& rbSubGrid )
57{
58 rnDimensionIndex = 1;
59 rbSubGrid = false;
60
61 switch( eType )
62 {
63 case X_MAJOR_GRID:
64 rnDimensionIndex = 0; rbSubGrid = false; break;
65 case Y_MAJOR_GRID:
66 rnDimensionIndex = 1; rbSubGrid = false; break;
67 case Z_MAJOR_GRID:
68 rnDimensionIndex = 2; rbSubGrid = false; break;
69 case X_MINOR_GRID:
70 rnDimensionIndex = 0; rbSubGrid = true; break;
71 case Y_MINOR_GRID:
72 rnDimensionIndex = 1; rbSubGrid = true; break;
73 case Z_MINOR_GRID:
74 rnDimensionIndex = 2; rbSubGrid = true; break;
75 }
76}
77
78// ____ XComponent ____
79void SAL_CALL GridWrapper::dispose()
80{
81 std::unique_lock g(m_aMutex);
82 Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) );
83 m_aEventListenerContainer.disposeAndClear( g, lang::EventObject( xSource ) );
84
85 clearWrappedPropertySet();
86}
87
89 const Reference< lang::XEventListener >& xListener )
90{
91 std::unique_lock g(m_aMutex);
93}
94
96 const Reference< lang::XEventListener >& aListener )
97{
98 std::unique_lock g(m_aMutex);
100}
101
102// WrappedPropertySet
103
105{
107 try
108 {
111
112 sal_Int32 nDimensionIndex = 1;
113 bool bSubGrid = false;
114 getDimensionAndSubGridBool( m_eType, nDimensionIndex, bSubGrid );
115
116 sal_Int32 nSubGridIndex = bSubGrid ? 0 : -1;
117 xRet = AxisHelper::getGridProperties( xCooSys , nDimensionIndex, MAIN_AXIS_INDEX, nSubGridIndex );
118 }
119 catch( const uno::Exception & )
120 {
121 DBG_UNHANDLED_EXCEPTION("chart2");
122 }
123 return xRet;
124}
125
127{
128 static Sequence< Property > aPropSeq = []()
129 {
130 std::vector< css::beans::Property > aProperties;
133
134 std::sort( aProperties.begin(), aProperties.end(),
136
138 }();
139 return aPropSeq;
140}
141
142std::vector< std::unique_ptr<WrappedProperty> > GridWrapper::createWrappedProperties()
143{
144 std::vector< std::unique_ptr<WrappedProperty> > aWrappedProperties;
145
146 aWrappedProperties.emplace_back( new WrappedDefaultProperty( "LineColor", "LineColor", uno::Any( sal_Int32( 0x000000) ) ) ); // black
147
148 return aWrappedProperties;
149}
150
152{
153 return "com.sun.star.comp.chart.Grid";
154}
155
156sal_Bool SAL_CALL GridWrapper::supportsService( const OUString& rServiceName )
157{
158 return cppu::supportsService(this, rServiceName);
159}
160
161css::uno::Sequence< OUString > SAL_CALL GridWrapper::getSupportedServiceNames()
162{
163 return {
164 "com.sun.star.chart.ChartGrid",
165 "com.sun.star.xml.UserDefinedAttributesSupplier",
166 "com.sun.star.drawing.LineProperties",
167 "com.sun.star.beans.PropertySet"
168 };
169}
170
171} // namespace chart::wrapper
172
173/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact
PropertiesInfo aProperties
PropertySetType m_eType
static rtl::Reference< ::chart::BaseCoordinateSystem > getCoordinateSystemByIndex(const rtl::Reference< ::chart::Diagram > &xDiagram, sal_Int32 nIndex)
Definition: AxisHelper.cxx:550
static rtl::Reference< ::chart::GridProperties > getGridProperties(const rtl::Reference< ::chart::BaseCoordinateSystem > &xCooSys, sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex, sal_Int32 nSubGridIndex)
Definition: AxisHelper.cxx:678
virtual css::uno::Reference< css::beans::XPropertySet > getInnerPropertySet() override
static void getDimensionAndSubGridBool(tGridType eType, sal_Int32 &rnDimensionIndex, bool &rbSubGrid)
Definition: GridWrapper.cxx:56
virtual std::vector< std::unique_ptr< WrappedProperty > > createWrappedProperties() override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual const css::uno::Sequence< css::beans::Property > & getPropertySequence() override
virtual OUString SAL_CALL getImplementationName() override
XServiceInfo declarations.
GridWrapper(tGridType eType, std::shared_ptr< Chart2ModelContact > spChart2ModelContact)
Definition: GridWrapper.cxx:47
::comphelper::OInterfaceContainerHelper4< css::lang::XEventListener > m_aEventListenerContainer
Definition: GridWrapper.hxx:74
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &aListener) override
Definition: GridWrapper.cxx:95
virtual void SAL_CALL dispose() override
Definition: GridWrapper.cxx:79
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
Definition: GridWrapper.cxx:88
virtual ~GridWrapper() override
Definition: GridWrapper.cxx:53
std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact
Definition: GridWrapper.hxx:73
sal_Int32 addInterface(std::unique_lock< std::mutex > &rGuard, const css::uno::Reference< ListenerT > &rxIFace)
void disposeAndClear(::std::unique_lock<::std::mutex > &rGuard, const css::lang::EventObject &rEvt)
sal_Int32 removeInterface(std::unique_lock< std::mutex > &rGuard, const css::uno::Reference< ListenerT > &rxIFace)
#define DBG_UNHANDLED_EXCEPTION(...)
DocumentType eType
std::mutex m_aMutex
OOO_DLLPUBLIC_CHARTTOOLS void AddPropertiesToVector(std::vector< css::beans::Property > &rOutProperties)
const sal_Int32 MAIN_AXIS_INDEX
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
unsigned char sal_Bool