| 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 "AreaWrapper.hxx" |
| 21 |
#include "Chart2ModelContact.hxx" |
| 22 |
#include <WrappedDirectStateProperty.hxx> |
| 23 |
#include <comphelper/sequence.hxx> |
| 24 |
#include <cppuhelper/supportsservice.hxx> |
| 25 |
|
| 26 |
#include <LinePropertiesHelper.hxx> |
| 27 |
#include <FillProperties.hxx> |
| 28 |
#include <UserDefinedProperties.hxx> |
| 29 |
|
| 30 |
#include <algorithm> |
| 31 |
#include <utility> |
| 32 |
|
| 33 |
using namespace ::com::sun::star; |
| 34 |
using ::com::sun::star::beans::Property; |
| 35 |
using ::com::sun::star::uno::Reference; |
| 36 |
using ::com::sun::star::uno::Sequence; |
| 37 |
|
| 38 |
namespace chart::wrapper |
| 39 |
{ |
| 40 |
|
| 41 |
AreaWrapper::AreaWrapper(std::shared_ptr<Chart2ModelContact> spChart2ModelContact) |
| 42 |
: m_spChart2ModelContact(std::move(spChart2ModelContact)) |
| 43 |
{ |
| 44 |
} |
| 45 |
|
| 46 |
AreaWrapper::~AreaWrapper() |
| 47 |
{} |
| 48 |
|
| 49 |
// ____ XShape ____ |
| 50 |
awt::Point SAL_CALL AreaWrapper::getPosition() |
| 51 |
{ |
| 52 |
return awt::Point(0,0); |
| 53 |
} |
| 54 |
|
| 55 |
void SAL_CALL AreaWrapper::setPosition( const awt::Point& /*aPosition*/ ) |
| 56 |
{ |
| 57 |
OSL_FAIL( "trying to set position of chart area" ); |
| 58 |
} |
| 59 |
|
| 60 |
awt::Size SAL_CALL AreaWrapper::getSize() |
| 61 |
{ |
| 62 |
return m_spChart2ModelContact->GetPageSize(); |
| 63 |
} |
| 64 |
|
| 65 |
void SAL_CALL AreaWrapper::setSize( const awt::Size& /*aSize*/ ) |
| 66 |
{ |
| 67 |
OSL_FAIL( "trying to set size of chart area" ); |
| 68 |
} |
| 69 |
|
| 70 |
// ____ XShapeDescriptor (base of XShape) ____ |
| 71 |
OUString SAL_CALL AreaWrapper::getShapeType() |
| 72 |
{ |
| 73 |
return u"com.sun.star.chart.ChartArea"_ustr; |
| 74 |
} |
| 75 |
|
| 76 |
// ____ XComponent ____ |
| 77 |
void SAL_CALL AreaWrapper::dispose() |
| 78 |
{ |
| 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 ) ); |
| 82 |
|
| 83 |
clearWrappedPropertySet(); |
| 84 |
} |
| 85 |
|
| 86 |
void SAL_CALL AreaWrapper::addEventListener( |
| 87 |
const Reference< lang::XEventListener >& xListener ) |
| 88 |
{ |
| 89 |
std::unique_lock g(m_aMutex); |
| 90 |
m_aEventListenerContainer.addInterface( g, xListener ); |
| 91 |
} |
| 92 |
|
| 93 |
void SAL_CALL AreaWrapper::removeEventListener( |
| 94 |
const Reference< lang::XEventListener >& aListener ) |
| 95 |
{ |
| 96 |
std::unique_lock g(m_aMutex); |
| 97 |
m_aEventListenerContainer.removeInterface( g, aListener ); |
| 98 |
} |
| 99 |
|
| 100 |
// WrappedPropertySet |
| 101 |
Reference< beans::XPropertySet > AreaWrapper::getInnerPropertySet() |
| 102 |
{ |
| 103 |
rtl::Reference< ChartModel > xChartDoc( m_spChart2ModelContact->getDocumentModel() ); |
| 104 |
if( xChartDoc.is() ) |
| 105 |
return xChartDoc->getPageBackground(); |
| 106 |
OSL_FAIL("AreaWrapper::getInnerPropertySet() is NULL"); |
| 107 |
return nullptr; |
| 108 |
} |
| 109 |
|
| 110 |
const Sequence< beans::Property >& AreaWrapper::getPropertySequence() |
| 111 |
{ |
| 112 |
static Sequence< Property > aPropSeq = []() |
| 113 |
{ |
| 114 |
std::vector< css::beans::Property > aProperties; |
| 115 |
::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties ); |
| 116 |
::chart::FillProperties::AddPropertiesToVector( aProperties ); |
| 117 |
::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); |
| 118 |
|
| 119 |
std::sort( aProperties.begin(), aProperties.end(), |
| 120 |
::chart::PropertyNameLess() ); |
| 121 |
|
| 122 |
return comphelper::containerToSequence( aProperties ); |
| 123 |
}(); |
| 124 |
return aPropSeq; |
| 125 |
} |
| 126 |
|
| 127 |
std::vector< std::unique_ptr<WrappedProperty> > AreaWrapper::createWrappedProperties() |
| 128 |
{ |
| 129 |
std::vector< std::unique_ptr<WrappedProperty> > aWrappedProperties; |
| 130 |
|
| 131 |
aWrappedProperties.emplace_back( new WrappedDirectStateProperty(u"LineStyle"_ustr,u"LineStyle"_ustr) ); |
| 132 |
|
| 133 |
return aWrappedProperties; |
| 134 |
} |
| 135 |
|
| 136 |
OUString SAL_CALL AreaWrapper::getImplementationName() |
| 137 |
{ |
| 138 |
return u"com.sun.star.comp.chart.Area"_ustr; |
| 139 |
} |
| 140 |
|
| 141 |
sal_Bool SAL_CALL AreaWrapper::supportsService( const OUString& rServiceName ) |
| 142 |
{ |
| 143 |
return cppu::supportsService(this, rServiceName); |
| 144 |
} |
| 145 |
|
| 146 |
css::uno::Sequence< OUString > SAL_CALL AreaWrapper::getSupportedServiceNames() |
| 147 |
{ |
| 148 |
return { |
| 149 |
u"com.sun.star.xml.UserDefinedAttributesSupplier"_ustr, |
| 150 |
u"com.sun.star.beans.PropertySet"_ustr, |
| 151 |
u"com.sun.star.drawing.FillProperties"_ustr, |
| 152 |
u"com.sun.star.drawing.LineProperties"_ustr }; |
| 153 |
} |
| 154 |
|
| 155 |
} // namespace chart::wrapper |
| 156 |
|
| 157 |
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |