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 "WallFloorWrapper.hxx"
22 #include "Chart2ModelContact.hxx"
23 #include "ContainerHelper.hxx"
24 #include <cppuhelper/supportsservice.hxx>
25 #include <com/sun/star/beans/PropertyAttribute.hpp>
26 #include <com/sun/star/drawing/FillStyle.hpp>
28 #include "FillProperties.hxx"
29 #include "LinePropertiesHelper.hxx"
30 #include "UserDefinedProperties.hxx"
31 #include "WrappedDirectStateProperty.hxx"
34 #include <rtl/ustrbuf.hxx>
35 #include <rtl/math.hxx>
37 using namespace ::com::sun::star
;
38 using namespace ::com::sun::star::chart2
;
40 using ::com::sun::star::beans::Property
;
41 using ::osl::MutexGuard
;
42 using ::com::sun::star::uno::Any
;
43 using ::com::sun::star::uno::Reference
;
44 using ::com::sun::star::uno::Sequence
;
48 static const char lcl_aServiceName
[] = "com.sun.star.comp.chart.WallOrFloor";
50 struct StaticWallFloorWrapperPropertyArray_Initializer
52 Sequence
< Property
>* operator()()
54 static Sequence
< Property
> aPropSeq( lcl_GetPropertySequence() );
59 static Sequence
< Property
> lcl_GetPropertySequence()
61 ::std::vector
< ::com::sun::star::beans::Property
> aProperties
;
62 ::chart::FillProperties::AddPropertiesToVector( aProperties
);
63 ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties
);
64 ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties
);
66 ::std::sort( aProperties
.begin(), aProperties
.end(),
67 ::chart::PropertyNameLess() );
69 return ::chart::ContainerHelper::ContainerToSequence( aProperties
);
73 struct StaticWallFloorWrapperPropertyArray
: public rtl::StaticAggregate
< Sequence
< Property
>, StaticWallFloorWrapperPropertyArray_Initializer
>
77 } // anonymous namespace
84 WallFloorWrapper::WallFloorWrapper( bool bWall
,
85 ::boost::shared_ptr
< Chart2ModelContact
> spChart2ModelContact
) :
86 m_spChart2ModelContact( spChart2ModelContact
),
87 m_aEventListenerContainer( m_aMutex
),
93 WallFloorWrapper::~WallFloorWrapper()
97 // ____ XComponent ____
98 void SAL_CALL
WallFloorWrapper::dispose()
99 throw (uno::RuntimeException
, std::exception
)
101 Reference
< uno::XInterface
> xSource( static_cast< ::cppu::OWeakObject
* >( this ) );
102 m_aEventListenerContainer
.disposeAndClear( lang::EventObject( xSource
) );
104 MutexGuard
aGuard( GetMutex());
105 clearWrappedPropertySet();
108 void SAL_CALL
WallFloorWrapper::addEventListener(
109 const Reference
< lang::XEventListener
>& xListener
)
110 throw (uno::RuntimeException
, std::exception
)
112 m_aEventListenerContainer
.addInterface( xListener
);
115 void SAL_CALL
WallFloorWrapper::removeEventListener(
116 const Reference
< lang::XEventListener
>& aListener
)
117 throw (uno::RuntimeException
, std::exception
)
119 m_aEventListenerContainer
.removeInterface( aListener
);
122 // WrappedPropertySet
123 Reference
< beans::XPropertySet
> WallFloorWrapper::getInnerPropertySet()
125 Reference
< beans::XPropertySet
> xRet
;
127 Reference
< chart2::XDiagram
> xDiagram( m_spChart2ModelContact
->getChart2Diagram() );
131 xRet
.set( xDiagram
->getWall() );
133 xRet
.set( xDiagram
->getFloor() );
139 const Sequence
< beans::Property
>& WallFloorWrapper::getPropertySequence()
141 return *StaticWallFloorWrapperPropertyArray::get();
144 const std::vector
< WrappedProperty
* > WallFloorWrapper::createWrappedProperties()
146 ::std::vector
< ::chart::WrappedProperty
* > aWrappedProperties
;
148 // use direct state always, so that in XML the value is always
149 // exported. Because in the old chart the defaults is as follows:
150 // Floor: SOLID (new and old model default), Wall: NONE, except for some chart types (line, scatter)
152 aWrappedProperties
.push_back( new WrappedDirectStateProperty( "FillStyle", "FillStyle" ));
153 aWrappedProperties
.push_back( new WrappedDirectStateProperty( "FillColor", "FillColor" ));
155 return aWrappedProperties
;
158 Sequence
< OUString
> WallFloorWrapper::getSupportedServiceNames_Static()
160 Sequence
< OUString
> aServices( 4 );
161 aServices
[ 0 ] = "com.sun.star.xml.UserDefinedAttributesSupplier";
162 aServices
[ 1 ] = "com.sun.star.drawing.FillProperties";
163 aServices
[ 2 ] = "com.sun.star.drawing.LineProperties";
164 aServices
[ 3 ] = "com.sun.star.beans.PropertySet";
169 // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
170 OUString SAL_CALL
WallFloorWrapper::getImplementationName()
171 throw( css::uno::RuntimeException
, std::exception
)
173 return getImplementationName_Static();
176 OUString
WallFloorWrapper::getImplementationName_Static()
178 return OUString(lcl_aServiceName
);
181 sal_Bool SAL_CALL
WallFloorWrapper::supportsService( const OUString
& rServiceName
)
182 throw( css::uno::RuntimeException
, std::exception
)
184 return cppu::supportsService(this, rServiceName
);
187 css::uno::Sequence
< OUString
> SAL_CALL
WallFloorWrapper::getSupportedServiceNames()
188 throw( css::uno::RuntimeException
, std::exception
)
190 return getSupportedServiceNames_Static();
193 } // namespace wrapper
196 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */