tdf#130857 qt weld: Implement QtInstanceWidget::get_text_height
[LibreOffice.git] / chart2 / source / controller / chartapiwrapper / AreaWrapper.cxx
blob11884859927af22c3a9544edfb1e3b5b018f60e5
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 "AreaWrapper.hxx"
21 #include "Chart2ModelContact.hxx"
22 #include <WrappedDirectStateProperty.hxx>
23 #include <comphelper/sequence.hxx>
24 #include <cppuhelper/supportsservice.hxx>
26 #include <LinePropertiesHelper.hxx>
27 #include <FillProperties.hxx>
28 #include <UserDefinedProperties.hxx>
30 #include <algorithm>
31 #include <utility>
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;
38 namespace chart::wrapper
41 AreaWrapper::AreaWrapper(std::shared_ptr<Chart2ModelContact> spChart2ModelContact)
42 : m_spChart2ModelContact(std::move(spChart2ModelContact))
46 AreaWrapper::~AreaWrapper()
49 // ____ XShape ____
50 awt::Point SAL_CALL AreaWrapper::getPosition()
52 return awt::Point(0,0);
55 void SAL_CALL AreaWrapper::setPosition( const awt::Point& /*aPosition*/ )
57 OSL_FAIL( "trying to set position of chart area" );
60 awt::Size SAL_CALL AreaWrapper::getSize()
62 return m_spChart2ModelContact->GetPageSize();
65 void SAL_CALL AreaWrapper::setSize( const awt::Size& /*aSize*/ )
67 OSL_FAIL( "trying to set size of chart area" );
70 // ____ XShapeDescriptor (base of XShape) ____
71 OUString SAL_CALL AreaWrapper::getShapeType()
73 return u"com.sun.star.chart.ChartArea"_ustr;
76 // ____ XComponent ____
77 void SAL_CALL AreaWrapper::dispose()
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 ) );
83 clearWrappedPropertySet();
86 void SAL_CALL AreaWrapper::addEventListener(
87 const Reference< lang::XEventListener >& xListener )
89 std::unique_lock g(m_aMutex);
90 m_aEventListenerContainer.addInterface( g, xListener );
93 void SAL_CALL AreaWrapper::removeEventListener(
94 const Reference< lang::XEventListener >& aListener )
96 std::unique_lock g(m_aMutex);
97 m_aEventListenerContainer.removeInterface( g, aListener );
100 // WrappedPropertySet
101 Reference< beans::XPropertySet > AreaWrapper::getInnerPropertySet()
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;
110 const Sequence< beans::Property >& AreaWrapper::getPropertySequence()
112 static Sequence< Property > aPropSeq = []()
114 std::vector< css::beans::Property > aProperties;
115 ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties );
116 ::chart::FillProperties::AddPropertiesToVector( aProperties );
117 ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
119 std::sort( aProperties.begin(), aProperties.end(),
120 ::chart::PropertyNameLess() );
122 return comphelper::containerToSequence( aProperties );
123 }();
124 return aPropSeq;
127 std::vector< std::unique_ptr<WrappedProperty> > AreaWrapper::createWrappedProperties()
129 std::vector< std::unique_ptr<WrappedProperty> > aWrappedProperties;
131 aWrappedProperties.emplace_back( new WrappedDirectStateProperty(u"LineStyle"_ustr,u"LineStyle"_ustr) );
133 return aWrappedProperties;
136 OUString SAL_CALL AreaWrapper::getImplementationName()
138 return u"com.sun.star.comp.chart.Area"_ustr;
141 sal_Bool SAL_CALL AreaWrapper::supportsService( const OUString& rServiceName )
143 return cppu::supportsService(this, rServiceName);
146 css::uno::Sequence< OUString > SAL_CALL AreaWrapper::getSupportedServiceNames()
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 };
155 } // namespace chart::wrapper
157 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */