Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include "gridcolumn.hxx"
30 : :
31 : : #include <comphelper/sequence.hxx>
32 : : #include <cppuhelper/typeprovider.hxx>
33 : : #include <toolkit/helper/servicenames.hxx>
34 : :
35 : : namespace toolkit
36 : : {
37 : : using namespace ::com::sun::star;
38 : : using namespace ::com::sun::star::uno;
39 : : using namespace ::com::sun::star::awt;
40 : : using namespace ::com::sun::star::awt::grid;
41 : : using namespace ::com::sun::star::lang;
42 : : using namespace ::com::sun::star::util;
43 : : using namespace ::com::sun::star::style;
44 : :
45 : : //==================================================================================================================
46 : : //= DefaultGridColumnModel
47 : : //==================================================================================================================
48 : : //------------------------------------------------------------------------------------------------------------------
49 : 0 : GridColumn::GridColumn()
50 : : :GridColumn_Base( m_aMutex )
51 : : ,m_aIdentifier()
52 : : ,m_nIndex(-1)
53 : : ,m_nDataColumnIndex(-1)
54 : : ,m_nColumnWidth(4)
55 : : ,m_nMaxWidth(0)
56 : : ,m_nMinWidth(0)
57 : : ,m_nFlexibility(1)
58 : : ,m_bResizeable(true)
59 : 0 : ,m_eHorizontalAlign( HorizontalAlignment_LEFT )
60 : : {
61 : 0 : }
62 : :
63 : : //------------------------------------------------------------------------------------------------------------------
64 : 0 : GridColumn::GridColumn( GridColumn const & i_copySource )
65 : : :cppu::BaseMutex()
66 : : ,GridColumn_Base( m_aMutex )
67 : : ,m_aIdentifier( i_copySource.m_aIdentifier )
68 : : ,m_nIndex( -1 )
69 : : ,m_nDataColumnIndex( i_copySource.m_nDataColumnIndex )
70 : : ,m_nColumnWidth( i_copySource.m_nColumnWidth )
71 : : ,m_nMaxWidth( i_copySource.m_nMaxWidth )
72 : : ,m_nMinWidth( i_copySource.m_nMinWidth )
73 : : ,m_nFlexibility( i_copySource.m_nFlexibility )
74 : : ,m_bResizeable( i_copySource.m_bResizeable )
75 : : ,m_sTitle( i_copySource.m_sTitle )
76 : : ,m_sHelpText( i_copySource.m_sHelpText )
77 : 0 : ,m_eHorizontalAlign( i_copySource.m_eHorizontalAlign )
78 : : {
79 : 0 : }
80 : :
81 : : //------------------------------------------------------------------------------------------------------------------
82 [ # # ]: 0 : GridColumn::~GridColumn()
83 : : {
84 [ # # ]: 0 : }
85 : :
86 : : //------------------------------------------------------------------------------------------------------------------
87 : 0 : void GridColumn::broadcast_changed( sal_Char const * const i_asciiAttributeName, Any i_oldValue, Any i_newValue,
88 : : ::comphelper::ComponentGuard& i_Guard )
89 : : {
90 [ # # ]: 0 : Reference< XInterface > const xSource( static_cast< ::cppu::OWeakObject* >( this ) );
91 : : GridColumnEvent const aEvent(
92 : : xSource, ::rtl::OUString::createFromAscii( i_asciiAttributeName ),
93 : : i_oldValue, i_newValue, m_nIndex
94 [ # # ]: 0 : );
95 : :
96 [ # # ][ # # ]: 0 : ::cppu::OInterfaceContainerHelper* pIter = rBHelper.getContainer( XGridColumnListener::static_type() );
97 : :
98 [ # # ]: 0 : i_Guard.clear();
99 [ # # ]: 0 : if( pIter )
100 [ # # ][ # # ]: 0 : pIter->notifyEach( &XGridColumnListener::columnChanged, aEvent );
101 : 0 : }
102 : :
103 : : //------------------------------------------------------------------------------------------------------------------
104 : 0 : ::com::sun::star::uno::Any SAL_CALL GridColumn::getIdentifier() throw (::com::sun::star::uno::RuntimeException)
105 : : {
106 [ # # ]: 0 : ::comphelper::ComponentGuard aGuard( *this, rBHelper );
107 [ # # ]: 0 : return m_aIdentifier;
108 : : }
109 : :
110 : : //------------------------------------------------------------------------------------------------------------------
111 : 0 : void SAL_CALL GridColumn::setIdentifier(const ::com::sun::star::uno::Any & value) throw (::com::sun::star::uno::RuntimeException)
112 : : {
113 [ # # ]: 0 : ::comphelper::ComponentGuard aGuard( *this, rBHelper );
114 [ # # ]: 0 : m_aIdentifier = value;
115 : 0 : }
116 : :
117 : : //------------------------------------------------------------------------------------------------------------------
118 : 0 : ::sal_Int32 SAL_CALL GridColumn::getColumnWidth() throw (::com::sun::star::uno::RuntimeException)
119 : : {
120 [ # # ]: 0 : ::comphelper::ComponentGuard aGuard( *this, rBHelper );
121 [ # # ]: 0 : return m_nColumnWidth;
122 : : }
123 : :
124 : : //------------------------------------------------------------------------------------------------------------------
125 : 0 : void SAL_CALL GridColumn::setColumnWidth(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException)
126 : : {
127 : 0 : impl_set( m_nColumnWidth, value, "ColumnWidth" );
128 : 0 : }
129 : :
130 : : //------------------------------------------------------------------------------------------------------------------
131 : 0 : ::sal_Int32 SAL_CALL GridColumn::getMaxWidth() throw (::com::sun::star::uno::RuntimeException)
132 : : {
133 [ # # ]: 0 : ::comphelper::ComponentGuard aGuard( *this, rBHelper );
134 [ # # ]: 0 : return m_nMaxWidth;
135 : : }
136 : :
137 : : //------------------------------------------------------------------------------------------------------------------
138 : 0 : void SAL_CALL GridColumn::setMaxWidth(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException)
139 : : {
140 : 0 : impl_set( m_nMaxWidth, value, "MaxWidth" );
141 : 0 : }
142 : :
143 : : //------------------------------------------------------------------------------------------------------------------
144 : 0 : ::sal_Int32 SAL_CALL GridColumn::getMinWidth() throw (::com::sun::star::uno::RuntimeException)
145 : : {
146 [ # # ]: 0 : ::comphelper::ComponentGuard aGuard( *this, rBHelper );
147 [ # # ]: 0 : return m_nMinWidth;
148 : : }
149 : :
150 : : //------------------------------------------------------------------------------------------------------------------
151 : 0 : void SAL_CALL GridColumn::setMinWidth(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException)
152 : : {
153 : 0 : impl_set( m_nMinWidth, value, "MinWidth" );
154 : 0 : }
155 : :
156 : : //------------------------------------------------------------------------------------------------------------------
157 : 0 : ::rtl::OUString SAL_CALL GridColumn::getTitle() throw (::com::sun::star::uno::RuntimeException)
158 : : {
159 [ # # ]: 0 : ::comphelper::ComponentGuard aGuard( *this, rBHelper );
160 [ # # ]: 0 : return m_sTitle;
161 : : }
162 : :
163 : : //------------------------------------------------------------------------------------------------------------------
164 : 0 : void SAL_CALL GridColumn::setTitle(const ::rtl::OUString & value) throw (::com::sun::star::uno::RuntimeException)
165 : : {
166 : 0 : impl_set( m_sTitle, value, "Title" );
167 : 0 : }
168 : :
169 : : //------------------------------------------------------------------------------------------------------------------
170 : 0 : ::rtl::OUString SAL_CALL GridColumn::getHelpText() throw (RuntimeException)
171 : : {
172 [ # # ]: 0 : ::comphelper::ComponentGuard aGuard( *this, rBHelper );
173 [ # # ]: 0 : return m_sHelpText;
174 : : }
175 : :
176 : : //------------------------------------------------------------------------------------------------------------------
177 : 0 : void SAL_CALL GridColumn::setHelpText( const ::rtl::OUString & value ) throw (RuntimeException)
178 : : {
179 : 0 : impl_set( m_sHelpText, value, "HelpText" );
180 : 0 : }
181 : :
182 : : //------------------------------------------------------------------------------------------------------------------
183 : 0 : sal_Bool SAL_CALL GridColumn::getResizeable() throw (::com::sun::star::uno::RuntimeException)
184 : : {
185 [ # # ]: 0 : ::comphelper::ComponentGuard aGuard( *this, rBHelper );
186 [ # # ]: 0 : return m_bResizeable;
187 : : }
188 : :
189 : : //------------------------------------------------------------------------------------------------------------------
190 : 0 : void SAL_CALL GridColumn::setResizeable(sal_Bool value) throw (::com::sun::star::uno::RuntimeException)
191 : : {
192 : 0 : impl_set( m_bResizeable, value, "Resizeable" );
193 : 0 : }
194 : :
195 : : //------------------------------------------------------------------------------------------------------------------
196 : 0 : ::sal_Int32 SAL_CALL GridColumn::getFlexibility() throw (RuntimeException)
197 : : {
198 [ # # ]: 0 : ::comphelper::ComponentGuard aGuard( *this, rBHelper );
199 [ # # ]: 0 : return m_nFlexibility;
200 : : }
201 : :
202 : : //------------------------------------------------------------------------------------------------------------------
203 : 0 : void SAL_CALL GridColumn::setFlexibility( ::sal_Int32 i_value ) throw (IllegalArgumentException, RuntimeException)
204 : : {
205 [ # # ]: 0 : if ( i_value < 0 )
206 [ # # ][ # # ]: 0 : throw IllegalArgumentException( ::rtl::OUString(), *this, 1 );
207 : 0 : impl_set( m_nFlexibility, i_value, "Flexibility" );
208 : 0 : }
209 : :
210 : : //------------------------------------------------------------------------------------------------------------------
211 : 0 : HorizontalAlignment SAL_CALL GridColumn::getHorizontalAlign() throw (::com::sun::star::uno::RuntimeException)
212 : : {
213 [ # # ]: 0 : ::comphelper::ComponentGuard aGuard( *this, rBHelper );
214 [ # # ]: 0 : return m_eHorizontalAlign;
215 : : }
216 : :
217 : : //------------------------------------------------------------------------------------------------------------------
218 : 0 : void SAL_CALL GridColumn::setHorizontalAlign(HorizontalAlignment align) throw (::com::sun::star::uno::RuntimeException)
219 : : {
220 : 0 : impl_set( m_eHorizontalAlign, align, "HorizontalAlign" );
221 : 0 : }
222 : :
223 : : //------------------------------------------------------------------------------------------------------------------
224 : 0 : void SAL_CALL GridColumn::addGridColumnListener( const Reference< XGridColumnListener >& xListener ) throw (RuntimeException)
225 : : {
226 : 0 : rBHelper.addListener( XGridColumnListener::static_type(), xListener );
227 : 0 : }
228 : :
229 : : //------------------------------------------------------------------------------------------------------------------
230 : 0 : void SAL_CALL GridColumn::removeGridColumnListener( const Reference< XGridColumnListener >& xListener ) throw (RuntimeException)
231 : : {
232 : 0 : rBHelper.removeListener( XGridColumnListener::static_type(), xListener );
233 : 0 : }
234 : :
235 : : //------------------------------------------------------------------------------------------------------------------
236 : 0 : void SAL_CALL GridColumn::disposing()
237 : : {
238 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
239 : 0 : m_aIdentifier.clear();
240 [ # # ]: 0 : m_sTitle = m_sHelpText = ::rtl::OUString();
241 : 0 : }
242 : :
243 : : //------------------------------------------------------------------------------------------------------------------
244 : 0 : ::sal_Int32 SAL_CALL GridColumn::getIndex() throw (RuntimeException)
245 : : {
246 [ # # ]: 0 : ::comphelper::ComponentGuard aGuard( *this, rBHelper );
247 [ # # ]: 0 : return m_nIndex;
248 : : }
249 : :
250 : : //------------------------------------------------------------------------------------------------------------------
251 : 0 : void GridColumn::setIndex( sal_Int32 const i_index )
252 : : {
253 [ # # ]: 0 : ::comphelper::ComponentGuard aGuard( *this, rBHelper );
254 [ # # ]: 0 : m_nIndex = i_index;
255 : 0 : }
256 : :
257 : : //------------------------------------------------------------------------------------------------------------------
258 : 0 : ::sal_Int32 SAL_CALL GridColumn::getDataColumnIndex() throw(RuntimeException)
259 : : {
260 [ # # ]: 0 : ::comphelper::ComponentGuard aGuard( *this, rBHelper );
261 [ # # ]: 0 : return m_nDataColumnIndex;
262 : : }
263 : :
264 : : //------------------------------------------------------------------------------------------------------------------
265 : 0 : void SAL_CALL GridColumn::setDataColumnIndex( ::sal_Int32 i_dataColumnIndex ) throw(RuntimeException)
266 : : {
267 : 0 : impl_set( m_nDataColumnIndex, i_dataColumnIndex, "DataColumnIndex" );
268 : 0 : }
269 : :
270 : : //------------------------------------------------------------------------------------------------------------------
271 : 0 : ::rtl::OUString SAL_CALL GridColumn::getImplementationName( ) throw (RuntimeException)
272 : : {
273 : 0 : return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.comp.toolkit.GridColumn" ) );
274 : : }
275 : :
276 : : //------------------------------------------------------------------------------------------------------------------
277 : 0 : sal_Bool SAL_CALL GridColumn::supportsService( const ::rtl::OUString& i_serviceName ) throw (RuntimeException)
278 : : {
279 [ # # ]: 0 : const Sequence< ::rtl::OUString > aServiceNames( getSupportedServiceNames() );
280 [ # # ]: 0 : for ( sal_Int32 i=0; i<aServiceNames.getLength(); ++i )
281 [ # # ]: 0 : if ( aServiceNames[i] == i_serviceName )
282 : 0 : return sal_True;
283 [ # # ]: 0 : return sal_False;
284 : : }
285 : :
286 : : //------------------------------------------------------------------------------------------------------------------
287 : 0 : ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL GridColumn::getSupportedServiceNames( ) throw (RuntimeException)
288 : : {
289 : 0 : const ::rtl::OUString aServiceName( ::rtl::OUString::createFromAscii( szServiceName_GridColumn ) );
290 [ # # ]: 0 : const Sequence< ::rtl::OUString > aSeq( &aServiceName, 1 );
291 : 0 : return aSeq;
292 : : }
293 : :
294 : : //------------------------------------------------------------------------------------------------------------------
295 : 0 : Reference< XCloneable > SAL_CALL GridColumn::createClone( ) throw (RuntimeException)
296 : : {
297 [ # # ][ # # ]: 0 : return new GridColumn( *this );
298 : : }
299 : :
300 : : //------------------------------------------------------------------------------------------------------------------
301 : 0 : sal_Int64 SAL_CALL GridColumn::getSomething( const Sequence< sal_Int8 >& i_identifier ) throw(RuntimeException)
302 : : {
303 [ # # ][ # # ]: 0 : if ( ( i_identifier.getLength() == 16 ) && ( i_identifier == getUnoTunnelId() ) )
[ # # ][ # # ]
[ # # # # ]
304 : 0 : return ::sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >( this ) );
305 : 0 : return 0;
306 : : }
307 : :
308 : : //------------------------------------------------------------------------------------------------------------------
309 : 0 : Sequence< sal_Int8 > GridColumn::getUnoTunnelId() throw()
310 : : {
311 [ # # ][ # # ]: 0 : static ::cppu::OImplementationId const aId;
312 : 0 : return aId.getImplementationId();
313 : : }
314 : :
315 : : //------------------------------------------------------------------------------------------------------------------
316 : 0 : GridColumn* GridColumn::getImplementation( const Reference< XInterface >& i_component )
317 : : {
318 [ # # ]: 0 : Reference< XUnoTunnel > const xTunnel( i_component, UNO_QUERY );
319 [ # # ]: 0 : if ( xTunnel.is() )
320 [ # # ][ # # ]: 0 : return reinterpret_cast< GridColumn* >( ::sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething( getUnoTunnelId() ) ) );
[ # # ]
321 : 0 : return NULL;
322 : : }
323 : : }
324 : :
325 : 0 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL GridColumn_CreateInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& )
326 : : {
327 [ # # ]: 0 : return *( new ::toolkit::GridColumn );
328 : : }
329 : :
330 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|