tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / chart2 / source / controller / chartapiwrapper / WallFloorWrapper.cxx
blob23ef0780ccaec00ea14fc970d736ba5f5a686f76
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>
25 #include <FillProperties.hxx>
26 #include <LinePropertiesHelper.hxx>
27 #include <UserDefinedProperties.hxx>
28 #include <WrappedDirectStateProperty.hxx>
30 #include <algorithm>
31 #include <utility>
33 using namespace ::com::sun::star;
35 using ::com::sun::star::beans::Property;
36 using ::com::sun::star::uno::Reference;
37 using ::com::sun::star::uno::Sequence;
39 namespace chart::wrapper
42 WallFloorWrapper::WallFloorWrapper( bool bWall,
43 std::shared_ptr<Chart2ModelContact> spChart2ModelContact ) :
44 m_spChart2ModelContact(std::move( spChart2ModelContact )),
45 m_bWall( bWall )
50 WallFloorWrapper::~WallFloorWrapper()
54 // ____ XComponent ____
55 void SAL_CALL WallFloorWrapper::dispose()
57 std::unique_lock g(m_aMutex);
58 Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) );
59 m_aEventListenerContainer.disposeAndClear( g, lang::EventObject( xSource ) );
61 clearWrappedPropertySet();
64 void SAL_CALL WallFloorWrapper::addEventListener(
65 const Reference< lang::XEventListener >& xListener )
67 std::unique_lock g(m_aMutex);
68 m_aEventListenerContainer.addInterface( g, xListener );
71 void SAL_CALL WallFloorWrapper::removeEventListener(
72 const Reference< lang::XEventListener >& aListener )
74 std::unique_lock g(m_aMutex);
75 m_aEventListenerContainer.removeInterface( g, aListener );
78 // WrappedPropertySet
79 Reference< beans::XPropertySet > WallFloorWrapper::getInnerPropertySet()
81 Reference< beans::XPropertySet > xRet;
83 rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() );
84 if( xDiagram.is() )
86 if( m_bWall )
87 xRet.set( xDiagram->getWall() );
88 else
89 xRet.set( xDiagram->getFloor() );
92 return xRet;
95 const Sequence< beans::Property >& WallFloorWrapper::getPropertySequence()
97 static Sequence< Property > aPropSeq = []()
99 std::vector< css::beans::Property > aProperties;
100 ::chart::FillProperties::AddPropertiesToVector( aProperties );
101 ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties );
102 ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
104 std::sort( aProperties.begin(), aProperties.end(),
105 ::chart::PropertyNameLess() );
107 return comphelper::containerToSequence( aProperties );
108 }();
109 return aPropSeq;
112 std::vector< std::unique_ptr<WrappedProperty> > WallFloorWrapper::createWrappedProperties()
114 std::vector< std::unique_ptr<WrappedProperty> > aWrappedProperties;
116 // use direct state always, so that in XML the value is always
117 // exported. Because in the old chart the defaults is as follows:
118 // Floor: SOLID (new and old model default), Wall: NONE, except for some chart types (line, scatter)
119 if( m_bWall )
120 aWrappedProperties.emplace_back( new WrappedDirectStateProperty( u"FillStyle"_ustr, u"FillStyle"_ustr ));
121 aWrappedProperties.emplace_back( new WrappedDirectStateProperty( u"FillColor"_ustr, u"FillColor"_ustr ));
123 return aWrappedProperties;
126 OUString SAL_CALL WallFloorWrapper::getImplementationName()
128 return u"com.sun.star.comp.chart.WallOrFloor"_ustr;
131 sal_Bool SAL_CALL WallFloorWrapper::supportsService( const OUString& rServiceName )
133 return cppu::supportsService(this, rServiceName);
136 css::uno::Sequence< OUString > SAL_CALL WallFloorWrapper::getSupportedServiceNames()
138 return {
139 u"com.sun.star.xml.UserDefinedAttributesSupplier"_ustr,
140 u"com.sun.star.drawing.FillProperties"_ustr,
141 u"com.sun.star.drawing.LineProperties"_ustr,
142 u"com.sun.star.beans.PropertySet"_ustr
146 } // namespace chart::wrapper
148 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */