Kaydet (Commit) a9f94e57 authored tarafından Matúš Kukan's avatar Matúš Kukan

tk: Constructor feature for DefaultGridColumnModel.

Change-Id: Id790c7af17b4b38de889a44ba1258dd1020054e3
üst 8c04ab3d
......@@ -18,45 +18,74 @@
*/
#include "defaultgridcolumnmodel.hxx"
#include "gridcolumn.hxx"
#include <com/sun/star/awt/XVclWindowPeer.hpp>
#include <com/sun/star/awt/grid/XGridColumnModel.hpp>
#include <com/sun/star/awt/grid/XGridColumn.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <comphelper/sequence.hxx>
#include <comphelper/componentguard.hxx>
#include <comphelper/processfactory.hxx>
#include <cppuhelper/basemutex.hxx>
#include <cppuhelper/compbase2.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <toolkit/helper/servicenames.hxx>
#include <rtl/ustrbuf.hxx>
#include <tools/diagnose_ex.h>
//......................................................................................................................
namespace toolkit
//......................................................................................................................
#include <vector>
using namespace css::awt;
using namespace css::awt::grid;
using namespace css::container;
using namespace css::uno;
using namespace toolkit;
namespace {
typedef ::cppu::WeakComponentImplHelper2 < css::awt::grid::XGridColumnModel
, css::lang::XServiceInfo
> DefaultGridColumnModel_Base;
class DefaultGridColumnModel :public ::cppu::BaseMutex
,public DefaultGridColumnModel_Base
{
using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::XComponentContext;
using ::com::sun::star::lang::XMultiServiceFactory;
using ::com::sun::star::uno::RuntimeException;
using ::com::sun::star::uno::Sequence;
using ::com::sun::star::uno::UNO_QUERY_THROW;
using ::com::sun::star::uno::UNO_QUERY;
using ::com::sun::star::awt::grid::XGridColumn;
using ::com::sun::star::uno::XInterface;
using ::com::sun::star::lang::XComponent;
using ::com::sun::star::lang::EventObject;
using ::com::sun::star::container::XContainerListener;
using ::com::sun::star::container::ContainerEvent;
using ::com::sun::star::uno::Exception;
using ::com::sun::star::lang::IndexOutOfBoundsException;
using ::com::sun::star::util::XCloneable;
using ::com::sun::star::lang::IllegalArgumentException;
//==================================================================================================================
//= DefaultGridColumnModel
//==================================================================================================================
//------------------------------------------------------------------------------------------------------------------
public:
DefaultGridColumnModel();
DefaultGridColumnModel( DefaultGridColumnModel const & i_copySource );
virtual ~DefaultGridColumnModel();
// XGridColumnModel
virtual ::sal_Int32 SAL_CALL getColumnCount() throw (css::uno::RuntimeException);
virtual css::uno::Reference< css::awt::grid::XGridColumn > SAL_CALL createColumn( ) throw (css::uno::RuntimeException);
virtual ::sal_Int32 SAL_CALL addColumn(const css::uno::Reference< css::awt::grid::XGridColumn > & column) throw (css::uno::RuntimeException, css::lang::IllegalArgumentException);
virtual void SAL_CALL removeColumn( ::sal_Int32 i_columnIndex ) throw (css::uno::RuntimeException, css::lang::IndexOutOfBoundsException);
virtual css::uno::Sequence< css::uno::Reference< css::awt::grid::XGridColumn > > SAL_CALL getColumns() throw (css::uno::RuntimeException);
virtual css::uno::Reference< css::awt::grid::XGridColumn > SAL_CALL getColumn(::sal_Int32 index) throw (css::lang::IndexOutOfBoundsException, css::uno::RuntimeException);
virtual void SAL_CALL setDefaultColumns(sal_Int32 rowElements) throw (css::uno::RuntimeException);
// XServiceInfo
virtual OUString SAL_CALL getImplementationName( ) throw (css::uno::RuntimeException);
virtual ::sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw (css::uno::RuntimeException);
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw (css::uno::RuntimeException);
// XContainer
virtual void SAL_CALL addContainerListener( const css::uno::Reference< css::container::XContainerListener >& xListener ) throw (css::uno::RuntimeException);
virtual void SAL_CALL removeContainerListener( const css::uno::Reference< css::container::XContainerListener >& xListener ) throw (css::uno::RuntimeException);
// XCloneable
virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone( ) throw (css::uno::RuntimeException);
// OComponentHelper
virtual void SAL_CALL disposing();
private:
typedef ::std::vector< css::uno::Reference< css::awt::grid::XGridColumn > > Columns;
::cppu::OInterfaceContainerHelper m_aContainerListeners;
Columns m_aColumns;
};
DefaultGridColumnModel::DefaultGridColumnModel()
:DefaultGridColumnModel_Base( m_aMutex )
,m_aContainerListeners( m_aMutex )
......@@ -64,7 +93,6 @@ namespace toolkit
{
}
//------------------------------------------------------------------------------------------------------------------
DefaultGridColumnModel::DefaultGridColumnModel( DefaultGridColumnModel const & i_copySource )
:cppu::BaseMutex()
,DefaultGridColumnModel_Base( m_aMutex )
......@@ -121,13 +149,14 @@ namespace toolkit
}
//------------------------------------------------------------------------------------------------------------------
::sal_Int32 SAL_CALL DefaultGridColumnModel::addColumn( const Reference< XGridColumn > & i_column ) throw (RuntimeException, IllegalArgumentException)
::sal_Int32 SAL_CALL DefaultGridColumnModel::addColumn( const Reference< XGridColumn > & i_column )
throw (RuntimeException, css::lang::IllegalArgumentException)
{
::comphelper::ComponentGuard aGuard( *this, rBHelper );
GridColumn* const pGridColumn = GridColumn::getImplementation( i_column );
if ( pGridColumn == NULL )
throw IllegalArgumentException( "invalid column implementation", *this, 1 );
throw css::lang::IllegalArgumentException( "invalid column implementation", *this, 1 );
m_aColumns.push_back( i_column );
sal_Int32 index = m_aColumns.size() - 1;
......@@ -146,12 +175,13 @@ namespace toolkit
}
//------------------------------------------------------------------------------------------------------------------
void SAL_CALL DefaultGridColumnModel::removeColumn( ::sal_Int32 i_columnIndex ) throw (RuntimeException, IndexOutOfBoundsException)
void SAL_CALL DefaultGridColumnModel::removeColumn( ::sal_Int32 i_columnIndex )
throw (RuntimeException, css::lang::IndexOutOfBoundsException)
{
::comphelper::ComponentGuard aGuard( *this, rBHelper );
if ( ( i_columnIndex < 0 ) || ( size_t( i_columnIndex ) >= m_aColumns.size() ) )
throw IndexOutOfBoundsException( OUString(), *this );
throw css::lang::IndexOutOfBoundsException( OUString(), *this );
Columns::iterator const pos = m_aColumns.begin() + i_columnIndex;
Reference< XGridColumn > const xColumn( *pos );
......@@ -202,14 +232,15 @@ namespace toolkit
}
//------------------------------------------------------------------------------------------------------------------
Reference< XGridColumn > SAL_CALL DefaultGridColumnModel::getColumn(::sal_Int32 index) throw (IndexOutOfBoundsException, RuntimeException)
Reference< XGridColumn > SAL_CALL DefaultGridColumnModel::getColumn(::sal_Int32 index)
throw (css::lang::IndexOutOfBoundsException, RuntimeException)
{
::comphelper::ComponentGuard aGuard( *this, rBHelper );
if ( index >=0 && index < ((sal_Int32)m_aColumns.size()))
return m_aColumns[index];
throw IndexOutOfBoundsException();
throw css::lang::IndexOutOfBoundsException();
}
//------------------------------------------------------------------------------------------------------------------
......@@ -299,7 +330,7 @@ namespace toolkit
//------------------------------------------------------------------------------------------------------------------
OUString SAL_CALL DefaultGridColumnModel::getImplementationName( ) throw (RuntimeException)
{
return OUString( "org.openoffice.comp.toolkit.DefaultGridColumnModel" );
return OUString("stardiv.Toolkit.DefaultGridColumnModel");
}
sal_Bool SAL_CALL DefaultGridColumnModel::supportsService( const OUString& i_serviceName ) throw (RuntimeException)
......@@ -309,7 +340,7 @@ namespace toolkit
Sequence< OUString > SAL_CALL DefaultGridColumnModel::getSupportedServiceNames( ) throw (RuntimeException)
{
const OUString aServiceName( OUString::createFromAscii( szServiceName_DefaultGridColumnModel ) );
const OUString aServiceName("com.sun.star.awt.grid.DefaultGridColumnModel");
const Sequence< OUString > aSeq( &aServiceName, 1 );
return aSeq;
}
......@@ -365,13 +396,14 @@ namespace toolkit
return new DefaultGridColumnModel( *this );
}
//......................................................................................................................
} // namespace toolkit
//......................................................................................................................
}
//----------------------------------------------------------------------------------------------------------------------
::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL DefaultGridColumnModel_CreateInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& )
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
stardiv_Toolkit_DefaultGridColumnModel_get_implementation(
css::uno::XComponentContext *,
css::uno::Sequence<css::uno::Any> const &)
{
return ::com::sun::star::uno::Reference < ::com::sun::star::uno::XInterface >( ( ::cppu::OWeakObject* ) new ::toolkit::DefaultGridColumnModel );
return cppu::acquire(new DefaultGridColumnModel());
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <com/sun/star/awt/grid/XGridColumnModel.hpp>
#include <com/sun/star/awt/grid/XGridColumn.hpp>
#include <com/sun/star/lang/XEventListener.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/lang/XUnoTunnel.hpp>
#include <com/sun/star/style/VerticalAlignment.hpp>
#include <com/sun/star/util/Color.hpp>
#include <cppuhelper/basemutex.hxx>
#include <cppuhelper/compbase2.hxx>
#include <vector>
namespace toolkit
{
typedef ::cppu::WeakComponentImplHelper2 < ::com::sun::star::awt::grid::XGridColumnModel
, ::com::sun::star::lang::XServiceInfo
> DefaultGridColumnModel_Base;
class DefaultGridColumnModel :public ::cppu::BaseMutex
,public DefaultGridColumnModel_Base
{
public:
DefaultGridColumnModel();
DefaultGridColumnModel( DefaultGridColumnModel const & i_copySource );
virtual ~DefaultGridColumnModel();
// XGridColumnModel
virtual ::sal_Int32 SAL_CALL getColumnCount() throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > SAL_CALL createColumn( ) throw (::com::sun::star::uno::RuntimeException);
virtual ::sal_Int32 SAL_CALL addColumn(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > & column) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IllegalArgumentException);
virtual void SAL_CALL removeColumn( ::sal_Int32 i_columnIndex ) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IndexOutOfBoundsException);
virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > > SAL_CALL getColumns() throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > SAL_CALL getColumn(::sal_Int32 index) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL setDefaultColumns(sal_Int32 rowElements) throw (::com::sun::star::uno::RuntimeException);
// XServiceInfo
virtual OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException);
virtual ::sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException);
// XContainer
virtual void SAL_CALL addContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL removeContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
// XCloneable
virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL createClone( ) throw (::com::sun::star::uno::RuntimeException);
// OComponentHelper
virtual void SAL_CALL disposing();
private:
typedef ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > > Columns;
::cppu::OInterfaceContainerHelper m_aContainerListeners;
Columns m_aColumns;
};
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -174,7 +174,6 @@ IMPL_CREATE_INSTANCE_WITH_GEOMETRY( UnoControlDialogModel )
extern ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL TreeControl_CreateInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& );
extern ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL TreeControlModel_CreateInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& );
extern ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL MutableTreeDataModel_CreateInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& );
extern ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL DefaultGridColumnModel_CreateInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& );
extern "C"
{
......@@ -254,7 +253,6 @@ TOOLKIT_DLLPUBLIC void* SAL_CALL tk_component_getFactory( const sal_Char* sImple
GET_FACTORY( MutableTreeDataModel, szServiceName_MutableTreeDataModel, NULL )
GET_FACTORY( UnoFixedHyperlinkControl, szServiceName_UnoControlFixedHyperlink, NULL )
GET_FACTORY( UnoControlFixedHyperlinkModel, szServiceName_UnoControlFixedHyperlinkModel, NULL )
GET_FACTORY( DefaultGridColumnModel, szServiceName_DefaultGridColumnModel, NULL );
}
return pRet;
}
......
......@@ -43,7 +43,8 @@
constructor="stardiv_Toolkit_UnoControlTabPageContainer_get_implementation">
<service name="com.sun.star.awt.tab.UnoControlTabPageContainer"/>
</implementation>
<implementation name="stardiv.Toolkit.DefaultGridColumnModel">
<implementation name="stardiv.Toolkit.DefaultGridColumnModel"
constructor="stardiv_Toolkit_DefaultGridColumnModel_get_implementation">
<service name="com.sun.star.awt.grid.DefaultGridColumnModel"/>
</implementation>
<implementation name="stardiv.Toolkit.DefaultGridDataModel"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment