Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / chart2 / source / controller / chartapiwrapper / WallFloorWrapper.cxx
blobb95872fb414630ba5800371b9592c3cc0093dce1
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 "WallFloorWrapper.hxx"
21 #include "Chart2ModelContact.hxx"
22 #include <comphelper/sequence.hxx>
23 #include <cppuhelper/supportsservice.hxx>
24 #include <com/sun/star/chart2/XDiagram.hpp>
26 #include <FillProperties.hxx>
27 #include <LinePropertiesHelper.hxx>
28 #include <UserDefinedProperties.hxx>
29 #include <WrappedDirectStateProperty.hxx>
31 #include <algorithm>
33 using namespace ::com::sun::star;
34 using namespace ::com::sun::star::chart2;
36 using ::com::sun::star::beans::Property;
37 using ::osl::MutexGuard;
38 using ::com::sun::star::uno::Reference;
39 using ::com::sun::star::uno::Sequence;
41 namespace
44 struct StaticWallFloorWrapperPropertyArray_Initializer
46 Sequence< Property >* operator()()
48 static Sequence< Property > aPropSeq( lcl_GetPropertySequence() );
49 return &aPropSeq;
52 private:
53 static Sequence< Property > lcl_GetPropertySequence()
55 std::vector< css::beans::Property > aProperties;
56 ::chart::FillProperties::AddPropertiesToVector( aProperties );
57 ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties );
58 ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
60 std::sort( aProperties.begin(), aProperties.end(),
61 ::chart::PropertyNameLess() );
63 return comphelper::containerToSequence( aProperties );
67 struct StaticWallFloorWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticWallFloorWrapperPropertyArray_Initializer >
71 } // anonymous namespace
73 namespace chart
75 namespace wrapper
78 WallFloorWrapper::WallFloorWrapper( bool bWall,
79 const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact ) :
80 m_spChart2ModelContact( spChart2ModelContact ),
81 m_aEventListenerContainer( m_aMutex ),
82 m_bWall( bWall )
87 WallFloorWrapper::~WallFloorWrapper()
91 // ____ XComponent ____
92 void SAL_CALL WallFloorWrapper::dispose()
94 Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) );
95 m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) );
97 MutexGuard aGuard( m_aMutex);
98 clearWrappedPropertySet();
101 void SAL_CALL WallFloorWrapper::addEventListener(
102 const Reference< lang::XEventListener >& xListener )
104 m_aEventListenerContainer.addInterface( xListener );
107 void SAL_CALL WallFloorWrapper::removeEventListener(
108 const Reference< lang::XEventListener >& aListener )
110 m_aEventListenerContainer.removeInterface( aListener );
113 // WrappedPropertySet
114 Reference< beans::XPropertySet > WallFloorWrapper::getInnerPropertySet()
116 Reference< beans::XPropertySet > xRet;
118 Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
119 if( xDiagram.is() )
121 if( m_bWall )
122 xRet.set( xDiagram->getWall() );
123 else
124 xRet.set( xDiagram->getFloor() );
127 return xRet;
130 const Sequence< beans::Property >& WallFloorWrapper::getPropertySequence()
132 return *StaticWallFloorWrapperPropertyArray::get();
135 std::vector< std::unique_ptr<WrappedProperty> > WallFloorWrapper::createWrappedProperties()
137 std::vector< std::unique_ptr<WrappedProperty> > aWrappedProperties;
139 // use direct state always, so that in XML the value is always
140 // exported. Because in the old chart the defaults is as follows:
141 // Floor: SOLID (new and old model default), Wall: NONE, except for some chart types (line, scatter)
142 if( m_bWall )
143 aWrappedProperties.emplace_back( new WrappedDirectStateProperty( "FillStyle", "FillStyle" ));
144 aWrappedProperties.emplace_back( new WrappedDirectStateProperty( "FillColor", "FillColor" ));
146 return aWrappedProperties;
149 OUString SAL_CALL WallFloorWrapper::getImplementationName()
151 return "com.sun.star.comp.chart.WallOrFloor";
154 sal_Bool SAL_CALL WallFloorWrapper::supportsService( const OUString& rServiceName )
156 return cppu::supportsService(this, rServiceName);
159 css::uno::Sequence< OUString > SAL_CALL WallFloorWrapper::getSupportedServiceNames()
161 return {
162 "com.sun.star.xml.UserDefinedAttributesSupplier",
163 "com.sun.star.drawing.FillProperties",
164 "com.sun.star.drawing.LineProperties",
165 "com.sun.star.beans.PropertySet"
169 } // namespace wrapper
170 } // namespace chart
172 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */