xref: /AOO41X/main/chart2/source/controller/chartapiwrapper/WallFloorWrapper.cxx (revision cde9e8dc2218e857da4894ecba5c903312256674)
1*cde9e8dcSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*cde9e8dcSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*cde9e8dcSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*cde9e8dcSAndrew Rist  * distributed with this work for additional information
6*cde9e8dcSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*cde9e8dcSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*cde9e8dcSAndrew Rist  * "License"); you may not use this file except in compliance
9*cde9e8dcSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*cde9e8dcSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*cde9e8dcSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*cde9e8dcSAndrew Rist  * software distributed under the License is distributed on an
15*cde9e8dcSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*cde9e8dcSAndrew Rist  * KIND, either express or implied.  See the License for the
17*cde9e8dcSAndrew Rist  * specific language governing permissions and limitations
18*cde9e8dcSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*cde9e8dcSAndrew Rist  *************************************************************/
21*cde9e8dcSAndrew Rist 
22*cde9e8dcSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_chart2.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "WallFloorWrapper.hxx"
28cdf0e10cSrcweir #include "macros.hxx"
29cdf0e10cSrcweir #include "Chart2ModelContact.hxx"
30cdf0e10cSrcweir #include "ContainerHelper.hxx"
31cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp>
32cdf0e10cSrcweir #include <com/sun/star/drawing/FillStyle.hpp>
33cdf0e10cSrcweir 
34cdf0e10cSrcweir #include "FillProperties.hxx"
35cdf0e10cSrcweir #include "LineProperties.hxx"
36cdf0e10cSrcweir #include "UserDefinedProperties.hxx"
37cdf0e10cSrcweir #include "WrappedDirectStateProperty.hxx"
38cdf0e10cSrcweir 
39cdf0e10cSrcweir #include <algorithm>
40cdf0e10cSrcweir #include <rtl/ustrbuf.hxx>
41cdf0e10cSrcweir #include <rtl/math.hxx>
42cdf0e10cSrcweir 
43cdf0e10cSrcweir using namespace ::com::sun::star;
44cdf0e10cSrcweir using namespace ::com::sun::star::chart2;
45cdf0e10cSrcweir 
46cdf0e10cSrcweir using ::com::sun::star::beans::Property;
47cdf0e10cSrcweir using ::osl::MutexGuard;
48cdf0e10cSrcweir using ::com::sun::star::uno::Any;
49cdf0e10cSrcweir using ::com::sun::star::uno::Reference;
50cdf0e10cSrcweir using ::com::sun::star::uno::Sequence;
51cdf0e10cSrcweir using ::rtl::OUString;
52cdf0e10cSrcweir 
53cdf0e10cSrcweir namespace
54cdf0e10cSrcweir {
55cdf0e10cSrcweir static const OUString lcl_aServiceName(
56cdf0e10cSrcweir     RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart.WallOrFloor" ));
57cdf0e10cSrcweir 
58cdf0e10cSrcweir struct StaticWallFloorWrapperPropertyArray_Initializer
59cdf0e10cSrcweir {
operator ()__anon61b413340111::StaticWallFloorWrapperPropertyArray_Initializer60cdf0e10cSrcweir     Sequence< Property >* operator()()
61cdf0e10cSrcweir     {
62cdf0e10cSrcweir         static Sequence< Property > aPropSeq( lcl_GetPropertySequence() );
63cdf0e10cSrcweir         return &aPropSeq;
64cdf0e10cSrcweir     }
65cdf0e10cSrcweir 
66cdf0e10cSrcweir private:
lcl_GetPropertySequence__anon61b413340111::StaticWallFloorWrapperPropertyArray_Initializer67cdf0e10cSrcweir     Sequence< Property > lcl_GetPropertySequence()
68cdf0e10cSrcweir     {
69cdf0e10cSrcweir         ::std::vector< ::com::sun::star::beans::Property > aProperties;
70cdf0e10cSrcweir         ::chart::FillProperties::AddPropertiesToVector( aProperties );
71cdf0e10cSrcweir         ::chart::LineProperties::AddPropertiesToVector( aProperties );
72cdf0e10cSrcweir         //::chart::NamedProperties::AddPropertiesToVector( aProperties );
73cdf0e10cSrcweir         ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
74cdf0e10cSrcweir 
75cdf0e10cSrcweir         ::std::sort( aProperties.begin(), aProperties.end(),
76cdf0e10cSrcweir                      ::chart::PropertyNameLess() );
77cdf0e10cSrcweir 
78cdf0e10cSrcweir         return ::chart::ContainerHelper::ContainerToSequence( aProperties );
79cdf0e10cSrcweir     }
80cdf0e10cSrcweir };
81cdf0e10cSrcweir 
82cdf0e10cSrcweir struct StaticWallFloorWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticWallFloorWrapperPropertyArray_Initializer >
83cdf0e10cSrcweir {
84cdf0e10cSrcweir };
85cdf0e10cSrcweir 
86cdf0e10cSrcweir } // anonymous namespace
87cdf0e10cSrcweir 
88cdf0e10cSrcweir // --------------------------------------------------------------------------------
89cdf0e10cSrcweir 
90cdf0e10cSrcweir namespace chart
91cdf0e10cSrcweir {
92cdf0e10cSrcweir namespace wrapper
93cdf0e10cSrcweir {
94cdf0e10cSrcweir 
WallFloorWrapper(bool bWall,::boost::shared_ptr<Chart2ModelContact> spChart2ModelContact)95cdf0e10cSrcweir WallFloorWrapper::WallFloorWrapper( bool bWall,
96cdf0e10cSrcweir     ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) :
97cdf0e10cSrcweir         m_spChart2ModelContact( spChart2ModelContact ),
98cdf0e10cSrcweir         m_aEventListenerContainer( m_aMutex ),
99cdf0e10cSrcweir         m_bWall( bWall )
100cdf0e10cSrcweir 
101cdf0e10cSrcweir {
102cdf0e10cSrcweir }
103cdf0e10cSrcweir 
~WallFloorWrapper()104cdf0e10cSrcweir WallFloorWrapper::~WallFloorWrapper()
105cdf0e10cSrcweir {
106cdf0e10cSrcweir }
107cdf0e10cSrcweir 
108cdf0e10cSrcweir // ____ XComponent ____
dispose()109cdf0e10cSrcweir void SAL_CALL WallFloorWrapper::dispose()
110cdf0e10cSrcweir     throw (uno::RuntimeException)
111cdf0e10cSrcweir {
112cdf0e10cSrcweir     Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) );
113cdf0e10cSrcweir     m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) );
114cdf0e10cSrcweir 
115cdf0e10cSrcweir     // /--
116cdf0e10cSrcweir     MutexGuard aGuard( GetMutex());
117cdf0e10cSrcweir     clearWrappedPropertySet();
118cdf0e10cSrcweir     // \--
119cdf0e10cSrcweir }
120cdf0e10cSrcweir 
addEventListener(const Reference<lang::XEventListener> & xListener)121cdf0e10cSrcweir void SAL_CALL WallFloorWrapper::addEventListener(
122cdf0e10cSrcweir     const Reference< lang::XEventListener >& xListener )
123cdf0e10cSrcweir     throw (uno::RuntimeException)
124cdf0e10cSrcweir {
125cdf0e10cSrcweir 	m_aEventListenerContainer.addInterface( xListener );
126cdf0e10cSrcweir }
127cdf0e10cSrcweir 
removeEventListener(const Reference<lang::XEventListener> & aListener)128cdf0e10cSrcweir void SAL_CALL WallFloorWrapper::removeEventListener(
129cdf0e10cSrcweir     const Reference< lang::XEventListener >& aListener )
130cdf0e10cSrcweir     throw (uno::RuntimeException)
131cdf0e10cSrcweir {
132cdf0e10cSrcweir 	m_aEventListenerContainer.removeInterface( aListener );
133cdf0e10cSrcweir }
134cdf0e10cSrcweir 
135cdf0e10cSrcweir // ================================================================================
136cdf0e10cSrcweir 
137cdf0e10cSrcweir // WrappedPropertySet
getInnerPropertySet()138cdf0e10cSrcweir Reference< beans::XPropertySet > WallFloorWrapper::getInnerPropertySet()
139cdf0e10cSrcweir {
140cdf0e10cSrcweir     Reference< beans::XPropertySet > xRet;
141cdf0e10cSrcweir 
142cdf0e10cSrcweir     Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
143cdf0e10cSrcweir     if( xDiagram.is() )
144cdf0e10cSrcweir     {
145cdf0e10cSrcweir         if( m_bWall )
146cdf0e10cSrcweir             xRet.set( xDiagram->getWall() );
147cdf0e10cSrcweir         else
148cdf0e10cSrcweir             xRet.set( xDiagram->getFloor() );
149cdf0e10cSrcweir     }
150cdf0e10cSrcweir 
151cdf0e10cSrcweir     return xRet;
152cdf0e10cSrcweir }
153cdf0e10cSrcweir 
getPropertySequence()154cdf0e10cSrcweir const Sequence< beans::Property >& WallFloorWrapper::getPropertySequence()
155cdf0e10cSrcweir {
156cdf0e10cSrcweir     return *StaticWallFloorWrapperPropertyArray::get();
157cdf0e10cSrcweir }
158cdf0e10cSrcweir 
createWrappedProperties()159cdf0e10cSrcweir const std::vector< WrappedProperty* > WallFloorWrapper::createWrappedProperties()
160cdf0e10cSrcweir {
161cdf0e10cSrcweir     ::std::vector< ::chart::WrappedProperty* > aWrappedProperties;
162cdf0e10cSrcweir 
163cdf0e10cSrcweir     // use direct state always, so that in XML the value is always
164cdf0e10cSrcweir     // exported. Because in the old chart the defaults is as follows:
165cdf0e10cSrcweir     // Floor: SOLID (new and old model default), Wall: NONE, except for some chart types (line, scatter)
166cdf0e10cSrcweir     if( m_bWall )
167cdf0e10cSrcweir         aWrappedProperties.push_back( new WrappedDirectStateProperty( C2U("FillStyle"), C2U("FillStyle") ));
168cdf0e10cSrcweir     aWrappedProperties.push_back( new WrappedDirectStateProperty( C2U("FillColor"), C2U("FillColor") ));
169cdf0e10cSrcweir 
170cdf0e10cSrcweir     return aWrappedProperties;
171cdf0e10cSrcweir }
172cdf0e10cSrcweir 
173cdf0e10cSrcweir // ================================================================================
174cdf0e10cSrcweir 
getSupportedServiceNames_Static()175cdf0e10cSrcweir Sequence< OUString > WallFloorWrapper::getSupportedServiceNames_Static()
176cdf0e10cSrcweir {
177cdf0e10cSrcweir     Sequence< OUString > aServices( 4 );
178cdf0e10cSrcweir     aServices[ 0 ] = C2U( "com.sun.star.xml.UserDefinedAttributeSupplier" );
179cdf0e10cSrcweir     aServices[ 1 ] = C2U( "com.sun.star.drawing.FillProperties" );
180cdf0e10cSrcweir     aServices[ 2 ] = C2U( "com.sun.star.drawing.LineProperties" );
181cdf0e10cSrcweir     aServices[ 3 ] = C2U( "com.sun.star.beans.PropertySet" );
182cdf0e10cSrcweir 
183cdf0e10cSrcweir     return aServices;
184cdf0e10cSrcweir }
185cdf0e10cSrcweir 
186cdf0e10cSrcweir // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
187cdf0e10cSrcweir APPHELPER_XSERVICEINFO_IMPL( WallFloorWrapper, lcl_aServiceName );
188cdf0e10cSrcweir 
189cdf0e10cSrcweir } //  namespace wrapper
190cdf0e10cSrcweir } //  namespace chart
191