Line data Source code
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 "WallFloorWrapper.hxx"
21 : #include "macros.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>
27 :
28 : #include "FillProperties.hxx"
29 : #include "LinePropertiesHelper.hxx"
30 : #include "UserDefinedProperties.hxx"
31 : #include "WrappedDirectStateProperty.hxx"
32 :
33 : #include <algorithm>
34 : #include <rtl/ustrbuf.hxx>
35 : #include <rtl/math.hxx>
36 :
37 : using namespace ::com::sun::star;
38 : using namespace ::com::sun::star::chart2;
39 :
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;
45 :
46 : namespace
47 : {
48 : static const char lcl_aServiceName[] = "com.sun.star.comp.chart.WallOrFloor";
49 :
50 : struct StaticWallFloorWrapperPropertyArray_Initializer
51 : {
52 11 : Sequence< Property >* operator()()
53 : {
54 11 : static Sequence< Property > aPropSeq( lcl_GetPropertySequence() );
55 11 : return &aPropSeq;
56 : }
57 :
58 : private:
59 11 : static Sequence< Property > lcl_GetPropertySequence()
60 : {
61 11 : ::std::vector< ::com::sun::star::beans::Property > aProperties;
62 11 : ::chart::FillProperties::AddPropertiesToVector( aProperties );
63 11 : ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties );
64 11 : ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
65 :
66 : ::std::sort( aProperties.begin(), aProperties.end(),
67 11 : ::chart::PropertyNameLess() );
68 :
69 11 : return ::chart::ContainerHelper::ContainerToSequence( aProperties );
70 : }
71 : };
72 :
73 : struct StaticWallFloorWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticWallFloorWrapperPropertyArray_Initializer >
74 : {
75 : };
76 :
77 : } // anonymous namespace
78 :
79 : namespace chart
80 : {
81 : namespace wrapper
82 : {
83 :
84 368 : WallFloorWrapper::WallFloorWrapper( bool bWall,
85 : ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) :
86 : m_spChart2ModelContact( spChart2ModelContact ),
87 : m_aEventListenerContainer( m_aMutex ),
88 368 : m_bWall( bWall )
89 :
90 : {
91 368 : }
92 :
93 736 : WallFloorWrapper::~WallFloorWrapper()
94 : {
95 736 : }
96 :
97 : // ____ XComponent ____
98 366 : void SAL_CALL WallFloorWrapper::dispose()
99 : throw (uno::RuntimeException, std::exception)
100 : {
101 366 : Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) );
102 366 : m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) );
103 :
104 732 : MutexGuard aGuard( GetMutex());
105 732 : clearWrappedPropertySet();
106 366 : }
107 :
108 0 : void SAL_CALL WallFloorWrapper::addEventListener(
109 : const Reference< lang::XEventListener >& xListener )
110 : throw (uno::RuntimeException, std::exception)
111 : {
112 0 : m_aEventListenerContainer.addInterface( xListener );
113 0 : }
114 :
115 0 : void SAL_CALL WallFloorWrapper::removeEventListener(
116 : const Reference< lang::XEventListener >& aListener )
117 : throw (uno::RuntimeException, std::exception)
118 : {
119 0 : m_aEventListenerContainer.removeInterface( aListener );
120 0 : }
121 :
122 : // WrappedPropertySet
123 32090 : Reference< beans::XPropertySet > WallFloorWrapper::getInnerPropertySet()
124 : {
125 32090 : Reference< beans::XPropertySet > xRet;
126 :
127 64180 : Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
128 32090 : if( xDiagram.is() )
129 : {
130 31882 : if( m_bWall )
131 16544 : xRet.set( xDiagram->getWall() );
132 : else
133 15338 : xRet.set( xDiagram->getFloor() );
134 : }
135 :
136 64180 : return xRet;
137 : }
138 :
139 367 : const Sequence< beans::Property >& WallFloorWrapper::getPropertySequence()
140 : {
141 367 : return *StaticWallFloorWrapperPropertyArray::get();
142 : }
143 :
144 367 : const std::vector< WrappedProperty* > WallFloorWrapper::createWrappedProperties()
145 : {
146 367 : ::std::vector< ::chart::WrappedProperty* > aWrappedProperties;
147 :
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)
151 367 : if( m_bWall )
152 193 : aWrappedProperties.push_back( new WrappedDirectStateProperty( "FillStyle", "FillStyle" ));
153 367 : aWrappedProperties.push_back( new WrappedDirectStateProperty( "FillColor", "FillColor" ));
154 :
155 367 : return aWrappedProperties;
156 : }
157 :
158 0 : Sequence< OUString > WallFloorWrapper::getSupportedServiceNames_Static()
159 : {
160 0 : Sequence< OUString > aServices( 4 );
161 0 : aServices[ 0 ] = "com.sun.star.xml.UserDefinedAttributesSupplier";
162 0 : aServices[ 1 ] = "com.sun.star.drawing.FillProperties";
163 0 : aServices[ 2 ] = "com.sun.star.drawing.LineProperties";
164 0 : aServices[ 3 ] = "com.sun.star.beans.PropertySet";
165 :
166 0 : return aServices;
167 : }
168 :
169 : // implement XServiceInfo methods basing upon getSupportedServiceNames_Static
170 0 : OUString SAL_CALL WallFloorWrapper::getImplementationName()
171 : throw( css::uno::RuntimeException, std::exception )
172 : {
173 0 : return getImplementationName_Static();
174 : }
175 :
176 0 : OUString WallFloorWrapper::getImplementationName_Static()
177 : {
178 0 : return OUString(lcl_aServiceName);
179 : }
180 :
181 0 : sal_Bool SAL_CALL WallFloorWrapper::supportsService( const OUString& rServiceName )
182 : throw( css::uno::RuntimeException, std::exception )
183 : {
184 0 : return cppu::supportsService(this, rServiceName);
185 : }
186 :
187 0 : css::uno::Sequence< OUString > SAL_CALL WallFloorWrapper::getSupportedServiceNames()
188 : throw( css::uno::RuntimeException, std::exception )
189 : {
190 0 : return getSupportedServiceNames_Static();
191 : }
192 :
193 : } // namespace wrapper
194 : } // namespace chart
195 :
196 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|