1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <com/sun/star/chart2/XChartDocument.hpp>
24 #include <comphelper/sequence.hxx>
25 #include <cppuhelper/supportsservice.hxx>
27 #include <LinePropertiesHelper.hxx>
28 #include <FillProperties.hxx>
29 #include <UserDefinedProperties.hxx>
33 using namespace ::com::sun::star
;
34 using ::com::sun::star::beans::Property
;
35 using ::osl::MutexGuard
;
36 using ::com::sun::star::uno::Reference
;
37 using ::com::sun::star::uno::Sequence
;
42 struct StaticAreaWrapperPropertyArray_Initializer
44 Sequence
< Property
>* operator()()
46 static Sequence
< Property
> aPropSeq( lcl_GetPropertySequence() );
51 static Sequence
< Property
> lcl_GetPropertySequence()
53 std::vector
< css::beans::Property
> aProperties
;
54 ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties
);
55 ::chart::FillProperties::AddPropertiesToVector( aProperties
);
56 ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties
);
58 std::sort( aProperties
.begin(), aProperties
.end(),
59 ::chart::PropertyNameLess() );
61 return comphelper::containerToSequence( aProperties
);
65 struct StaticAreaWrapperPropertyArray
: public rtl::StaticAggregate
< Sequence
< Property
>, StaticAreaWrapperPropertyArray_Initializer
>
69 } // anonymous namespace
76 AreaWrapper::AreaWrapper(const std::shared_ptr
<Chart2ModelContact
>& spChart2ModelContact
)
77 : m_spChart2ModelContact(spChart2ModelContact
)
78 , m_aEventListenerContainer(m_aMutex
)
82 AreaWrapper::~AreaWrapper()
86 awt::Point SAL_CALL
AreaWrapper::getPosition()
88 return awt::Point(0,0);
91 void SAL_CALL
AreaWrapper::setPosition( const awt::Point
& /*aPosition*/ )
93 OSL_FAIL( "trying to set position of chart area" );
96 awt::Size SAL_CALL
AreaWrapper::getSize()
98 return m_spChart2ModelContact
->GetPageSize();
101 void SAL_CALL
AreaWrapper::setSize( const awt::Size
& /*aSize*/ )
103 OSL_FAIL( "trying to set size of chart area" );
106 // ____ XShapeDescriptor (base of XShape) ____
107 OUString SAL_CALL
AreaWrapper::getShapeType()
109 return "com.sun.star.chart.ChartArea";
112 // ____ XComponent ____
113 void SAL_CALL
AreaWrapper::dispose()
115 Reference
< uno::XInterface
> xSource( static_cast< ::cppu::OWeakObject
* >( this ) );
116 m_aEventListenerContainer
.disposeAndClear( lang::EventObject( xSource
) );
118 MutexGuard
aGuard( m_aMutex
);
119 clearWrappedPropertySet();
122 void SAL_CALL
AreaWrapper::addEventListener(
123 const Reference
< lang::XEventListener
>& xListener
)
125 m_aEventListenerContainer
.addInterface( xListener
);
128 void SAL_CALL
AreaWrapper::removeEventListener(
129 const Reference
< lang::XEventListener
>& aListener
)
131 m_aEventListenerContainer
.removeInterface( aListener
);
134 // WrappedPropertySet
135 Reference
< beans::XPropertySet
> AreaWrapper::getInnerPropertySet()
137 Reference
< chart2::XChartDocument
> xChartDoc( m_spChart2ModelContact
->getChart2Document() );
139 return xChartDoc
->getPageBackground();
140 OSL_FAIL("AreaWrapper::getInnerPropertySet() is NULL");
144 const Sequence
< beans::Property
>& AreaWrapper::getPropertySequence()
146 return *StaticAreaWrapperPropertyArray::get();
149 std::vector
< std::unique_ptr
<WrappedProperty
> > AreaWrapper::createWrappedProperties()
151 std::vector
< std::unique_ptr
<WrappedProperty
> > aWrappedProperties
;
153 aWrappedProperties
.emplace_back( new WrappedDirectStateProperty("LineStyle","LineStyle") );
155 return aWrappedProperties
;
158 OUString SAL_CALL
AreaWrapper::getImplementationName()
160 return "com.sun.star.comp.chart.Area";
163 sal_Bool SAL_CALL
AreaWrapper::supportsService( const OUString
& rServiceName
)
165 return cppu::supportsService(this, rServiceName
);
168 css::uno::Sequence
< OUString
> SAL_CALL
AreaWrapper::getSupportedServiceNames()
171 "com.sun.star.xml.UserDefinedAttributesSupplier",
172 "com.sun.star.beans.PropertySet",
173 "com.sun.star.drawing.FillProperties",
174 "com.sun.star.drawing.LineProperties" };
177 } // namespace wrapper
180 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */