| 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 "WallFloorWrapper.hxx" |
| 21 |
#include "Chart2ModelContact.hxx" |
| 22 |
#include <comphelper/sequence.hxx> |
| 23 |
#include <cppuhelper/supportsservice.hxx> |
| 24 |
|
| 25 |
#include <FillProperties.hxx> |
| 26 |
#include <LinePropertiesHelper.hxx> |
| 27 |
#include <UserDefinedProperties.hxx> |
| 28 |
#include <WrappedDirectStateProperty.hxx> |
| 29 |
|
| 30 |
#include <algorithm> |
| 31 |
#include <utility> |
| 32 |
|
| 33 |
using namespace ::com::sun::star; |
| 34 |
|
| 35 |
using ::com::sun::star::beans::Property; |
| 36 |
using ::com::sun::star::uno::Reference; |
| 37 |
using ::com::sun::star::uno::Sequence; |
| 38 |
|
| 39 |
namespace chart::wrapper |
| 40 |
{ |
| 41 |
|
| 42 |
WallFloorWrapper::WallFloorWrapper( bool bWall, |
| 43 |
std::shared_ptr<Chart2ModelContact> spChart2ModelContact ) : |
| 44 |
m_spChart2ModelContact(std::move( spChart2ModelContact )), |
| 45 |
m_bWall( bWall ) |
| 46 |
|
| 47 |
{ |
| 48 |
} |
| 49 |
|
| 50 |
WallFloorWrapper::~WallFloorWrapper() |
| 51 |
{ |
| 52 |
} |
| 53 |
|
| 54 |
// ____ XComponent ____ |
| 55 |
void SAL_CALL WallFloorWrapper::dispose() |
| 56 |
{ |
| 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 ) ); |
| 60 |
|
| 61 |
clearWrappedPropertySet(); |
| 62 |
} |
| 63 |
|
| 64 |
void SAL_CALL WallFloorWrapper::addEventListener( |
| 65 |
const Reference< lang::XEventListener >& xListener ) |
| 66 |
{ |
| 67 |
std::unique_lock g(m_aMutex); |
| 68 |
m_aEventListenerContainer.addInterface( g, xListener ); |
| 69 |
} |
| 70 |
|
| 71 |
void SAL_CALL WallFloorWrapper::removeEventListener( |
| 72 |
const Reference< lang::XEventListener >& aListener ) |
| 73 |
{ |
| 74 |
std::unique_lock g(m_aMutex); |
| 75 |
m_aEventListenerContainer.removeInterface( g, aListener ); |
| 76 |
} |
| 77 |
|
| 78 |
// WrappedPropertySet |
| 79 |
Reference< beans::XPropertySet > WallFloorWrapper::getInnerPropertySet() |
| 80 |
{ |
| 81 |
Reference< beans::XPropertySet > xRet; |
| 82 |
|
| 83 |
rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); |
| 84 |
if( xDiagram.is() ) |
| 85 |
{ |
| 86 |
if( m_bWall ) |
| 87 |
xRet.set( xDiagram->getWall() ); |
| 88 |
else |
| 89 |
xRet.set( xDiagram->getFloor() ); |
| 90 |
} |
| 91 |
|
| 92 |
return xRet; |
| 93 |
} |
| 94 |
|
| 95 |
const Sequence< beans::Property >& WallFloorWrapper::getPropertySequence() |
| 96 |
{ |
| 97 |
static Sequence< Property > aPropSeq = []() |
| 98 |
{ |
| 99 |
std::vector< css::beans::Property > aProperties; |
| 100 |
::chart::FillProperties::AddPropertiesToVector( aProperties ); |
| 101 |
::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties ); |
| 102 |
::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); |
| 103 |
|
| 104 |
std::sort( aProperties.begin(), aProperties.end(), |
| 105 |
::chart::PropertyNameLess() ); |
| 106 |
|
| 107 |
return comphelper::containerToSequence( aProperties ); |
| 108 |
}(); |
| 109 |
return aPropSeq; |
| 110 |
} |
| 111 |
|
| 112 |
std::vector< std::unique_ptr<WrappedProperty> > WallFloorWrapper::createWrappedProperties() |
| 113 |
{ |
| 114 |
std::vector< std::unique_ptr<WrappedProperty> > aWrappedProperties; |
| 115 |
|
| 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 )); |
| 122 |
|
| 123 |
return aWrappedProperties; |
| 124 |
} |
| 125 |
|
| 126 |
OUString SAL_CALL WallFloorWrapper::getImplementationName() |
| 127 |
{ |
| 128 |
return u"com.sun.star.comp.chart.WallOrFloor"_ustr; |
| 129 |
} |
| 130 |
|
| 131 |
sal_Bool SAL_CALL WallFloorWrapper::supportsService( const OUString& rServiceName ) |
| 132 |
{ |
| 133 |
return cppu::supportsService(this, rServiceName); |
| 134 |
} |
| 135 |
|
| 136 |
css::uno::Sequence< OUString > SAL_CALL WallFloorWrapper::getSupportedServiceNames() |
| 137 |
{ |
| 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 |
| 143 |
}; |
| 144 |
} |
| 145 |
|
| 146 |
} // namespace chart::wrapper |
| 147 |
|
| 148 |
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |