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 "gridcolumn.hxx"
22 #include <com/sun/star/lang/IllegalArgumentException.hpp>
23 #include <com/sun/star/uno/XComponentContext.hpp>
24 #include <comphelper/sequence.hxx>
25 #include <cppuhelper/supportsservice.hxx>
26 #include <cppuhelper/typeprovider.hxx>
30 using namespace ::com::sun::star
;
31 using namespace ::com::sun::star::uno
;
32 using namespace ::com::sun::star::awt
;
33 using namespace ::com::sun::star::awt::grid
;
34 using namespace ::com::sun::star::lang
;
35 using namespace ::com::sun::star::util
;
36 using namespace ::com::sun::star::style
;
39 //= DefaultGridColumnModel
42 GridColumn::GridColumn()
43 :GridColumn_Base( m_aMutex
)
46 ,m_nDataColumnIndex(-1)
52 ,m_eHorizontalAlign( HorizontalAlignment_LEFT
)
57 GridColumn::GridColumn( GridColumn
const & i_copySource
)
59 ,GridColumn_Base( m_aMutex
)
60 ,m_aIdentifier( i_copySource
.m_aIdentifier
)
62 ,m_nDataColumnIndex( i_copySource
.m_nDataColumnIndex
)
63 ,m_nColumnWidth( i_copySource
.m_nColumnWidth
)
64 ,m_nMaxWidth( i_copySource
.m_nMaxWidth
)
65 ,m_nMinWidth( i_copySource
.m_nMinWidth
)
66 ,m_nFlexibility( i_copySource
.m_nFlexibility
)
67 ,m_bResizeable( i_copySource
.m_bResizeable
)
68 ,m_sTitle( i_copySource
.m_sTitle
)
69 ,m_sHelpText( i_copySource
.m_sHelpText
)
70 ,m_eHorizontalAlign( i_copySource
.m_eHorizontalAlign
)
75 GridColumn::~GridColumn()
80 void GridColumn::broadcast_changed( sal_Char
const * const i_asciiAttributeName
, const Any
& i_oldValue
, const Any
& i_newValue
,
81 ::comphelper::ComponentGuard
& i_Guard
)
83 Reference
< XInterface
> const xSource( static_cast< ::cppu::OWeakObject
* >( this ) );
84 GridColumnEvent
const aEvent(
85 xSource
, OUString::createFromAscii( i_asciiAttributeName
),
86 i_oldValue
, i_newValue
, m_nIndex
89 ::cppu::OInterfaceContainerHelper
* pIter
= rBHelper
.getContainer( cppu::UnoType
<XGridColumnListener
>::get() );
93 pIter
->notifyEach( &XGridColumnListener::columnChanged
, aEvent
);
97 css::uno::Any SAL_CALL
GridColumn::getIdentifier()
99 ::comphelper::ComponentGuard
aGuard( *this, rBHelper
);
100 return m_aIdentifier
;
104 void SAL_CALL
GridColumn::setIdentifier(const css::uno::Any
& value
)
106 ::comphelper::ComponentGuard
aGuard( *this, rBHelper
);
107 m_aIdentifier
= value
;
111 ::sal_Int32 SAL_CALL
GridColumn::getColumnWidth()
113 ::comphelper::ComponentGuard
aGuard( *this, rBHelper
);
114 return m_nColumnWidth
;
118 void SAL_CALL
GridColumn::setColumnWidth(::sal_Int32 value
)
120 impl_set( m_nColumnWidth
, value
, "ColumnWidth" );
124 ::sal_Int32 SAL_CALL
GridColumn::getMaxWidth()
126 ::comphelper::ComponentGuard
aGuard( *this, rBHelper
);
131 void SAL_CALL
GridColumn::setMaxWidth(::sal_Int32 value
)
133 impl_set( m_nMaxWidth
, value
, "MaxWidth" );
137 ::sal_Int32 SAL_CALL
GridColumn::getMinWidth()
139 ::comphelper::ComponentGuard
aGuard( *this, rBHelper
);
144 void SAL_CALL
GridColumn::setMinWidth(::sal_Int32 value
)
146 impl_set( m_nMinWidth
, value
, "MinWidth" );
150 OUString SAL_CALL
GridColumn::getTitle()
152 ::comphelper::ComponentGuard
aGuard( *this, rBHelper
);
157 void SAL_CALL
GridColumn::setTitle(const OUString
& value
)
159 impl_set( m_sTitle
, value
, "Title" );
163 OUString SAL_CALL
GridColumn::getHelpText()
165 ::comphelper::ComponentGuard
aGuard( *this, rBHelper
);
170 void SAL_CALL
GridColumn::setHelpText( const OUString
& value
)
172 impl_set( m_sHelpText
, value
, "HelpText" );
176 sal_Bool SAL_CALL
GridColumn::getResizeable()
178 ::comphelper::ComponentGuard
aGuard( *this, rBHelper
);
179 return m_bResizeable
;
183 void SAL_CALL
GridColumn::setResizeable(sal_Bool value
)
185 impl_set( m_bResizeable
, bool(value
), "Resizeable" );
189 ::sal_Int32 SAL_CALL
GridColumn::getFlexibility()
191 ::comphelper::ComponentGuard
aGuard( *this, rBHelper
);
192 return m_nFlexibility
;
196 void SAL_CALL
GridColumn::setFlexibility( ::sal_Int32 i_value
)
199 throw IllegalArgumentException( OUString(), *this, 1 );
200 impl_set( m_nFlexibility
, i_value
, "Flexibility" );
204 HorizontalAlignment SAL_CALL
GridColumn::getHorizontalAlign()
206 ::comphelper::ComponentGuard
aGuard( *this, rBHelper
);
207 return m_eHorizontalAlign
;
211 void SAL_CALL
GridColumn::setHorizontalAlign(HorizontalAlignment align
)
213 impl_set( m_eHorizontalAlign
, align
, "HorizontalAlign" );
217 void SAL_CALL
GridColumn::addGridColumnListener( const Reference
< XGridColumnListener
>& xListener
)
219 rBHelper
.addListener( cppu::UnoType
<XGridColumnListener
>::get(), xListener
);
223 void SAL_CALL
GridColumn::removeGridColumnListener( const Reference
< XGridColumnListener
>& xListener
)
225 rBHelper
.removeListener( cppu::UnoType
<XGridColumnListener
>::get(), xListener
);
229 void SAL_CALL
GridColumn::disposing()
231 ::osl::MutexGuard
aGuard( m_aMutex
);
232 m_aIdentifier
.clear();
238 ::sal_Int32 SAL_CALL
GridColumn::getIndex()
240 ::comphelper::ComponentGuard
aGuard( *this, rBHelper
);
245 void GridColumn::setIndex( sal_Int32
const i_index
)
247 ::comphelper::ComponentGuard
aGuard( *this, rBHelper
);
252 ::sal_Int32 SAL_CALL
GridColumn::getDataColumnIndex()
254 ::comphelper::ComponentGuard
aGuard( *this, rBHelper
);
255 return m_nDataColumnIndex
;
259 void SAL_CALL
GridColumn::setDataColumnIndex( ::sal_Int32 i_dataColumnIndex
)
261 impl_set( m_nDataColumnIndex
, i_dataColumnIndex
, "DataColumnIndex" );
265 OUString SAL_CALL
GridColumn::getImplementationName( )
267 return OUString( "org.openoffice.comp.toolkit.GridColumn" );
270 sal_Bool SAL_CALL
GridColumn::supportsService( const OUString
& i_serviceName
)
272 return cppu::supportsService(this, i_serviceName
);
275 css::uno::Sequence
< OUString
> SAL_CALL
GridColumn::getSupportedServiceNames( )
277 const OUString
aServiceName("com.sun.star.awt.grid.GridColumn");
278 const Sequence
< OUString
> aSeq( &aServiceName
, 1 );
283 Reference
< XCloneable
> SAL_CALL
GridColumn::createClone( )
285 return new GridColumn( *this );
289 sal_Int64 SAL_CALL
GridColumn::getSomething( const Sequence
< sal_Int8
>& i_identifier
)
291 if ( ( i_identifier
.getLength() == 16 ) && ( i_identifier
== getUnoTunnelId() ) )
292 return ::sal::static_int_cast
< sal_Int64
>( reinterpret_cast< sal_IntPtr
>( this ) );
297 Sequence
< sal_Int8
> GridColumn::getUnoTunnelId() throw()
299 static ::cppu::OImplementationId
const aId
;
300 return aId
.getImplementationId();
304 GridColumn
* GridColumn::getImplementation( const Reference
< XInterface
>& i_component
)
306 Reference
< XUnoTunnel
> const xTunnel( i_component
, UNO_QUERY
);
308 return reinterpret_cast< GridColumn
* >( ::sal::static_int_cast
< sal_IntPtr
>( xTunnel
->getSomething( getUnoTunnelId() ) ) );
313 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
314 org_openoffice_comp_toolkit_GridColumn_get_implementation(
315 css::uno::XComponentContext
*,
316 css::uno::Sequence
<css::uno::Any
> const &)
318 return cppu::acquire(new toolkit::GridColumn());
321 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */