diff options
author | Mathias Bauer <mba@openoffice.org> | 2009-12-05 19:29:07 +0100 |
---|---|---|
committer | Mathias Bauer <mba@openoffice.org> | 2009-12-05 19:29:07 +0100 |
commit | 342e37f151084dfb8f840c0cfaa4674dcf880267 (patch) | |
tree | 2dea2ded6ba96ae62da1d9dd7faeb9a80ca7065a /svtools | |
parent | 549fb21f357eaa2cda1a53d4fa84cf87896aed6d (diff) | |
parent | 2f883652c1af80075dc68b5cb439a13cd1dc4129 (diff) |
merge to m67
Diffstat (limited to 'svtools')
-rw-r--r-- | svtools/inc/svtools/accessiblefactory.hxx | 6 | ||||
-rwxr-xr-x | svtools/inc/svtools/accessibletable.hxx | 185 | ||||
-rw-r--r-- | svtools/inc/svtools/table/tablecontrol.hxx | 86 | ||||
-rw-r--r-- | svtools/inc/svtools/table/tablemodel.hxx | 4 | ||||
-rw-r--r-- | svtools/prj/d.lst | 3 | ||||
-rw-r--r-- | svtools/source/misc/svtaccessiblefactory.cxx | 9 | ||||
-rw-r--r-- | svtools/source/table/tablecontrol.cxx | 372 | ||||
-rw-r--r-- | svtools/source/table/tablecontrol_impl.cxx | 25 | ||||
-rw-r--r-- | svtools/source/table/tablecontrol_impl.hxx | 20 | ||||
-rw-r--r-- | svtools/source/uno/makefile.mk | 3 | ||||
-rwxr-xr-x | svtools/source/uno/svtxgridcontrol.cxx | 458 | ||||
-rwxr-xr-x | svtools/source/uno/svtxgridcontrol.hxx | 106 | ||||
-rw-r--r-- | svtools/source/uno/unocontroltablemodel.cxx | 481 | ||||
-rw-r--r-- | svtools/source/uno/unocontroltablemodel.hxx | 96 | ||||
-rw-r--r-- | svtools/source/uno/unoiface.cxx | 9 |
15 files changed, 1316 insertions, 547 deletions
diff --git a/svtools/inc/svtools/accessiblefactory.hxx b/svtools/inc/svtools/accessiblefactory.hxx index f7cad847edda..f4d8a03ef872 100644 --- a/svtools/inc/svtools/accessiblefactory.hxx +++ b/svtools/inc/svtools/accessiblefactory.hxx @@ -40,6 +40,7 @@ #endif #include "AccessibleBrowseBoxObjType.hxx" #include "accessibletableprovider.hxx" +#include "accessibletable.hxx" namespace com { namespace sun { namespace star { namespace accessibility { @@ -89,6 +90,11 @@ namespace svt const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& _rxParent, IAccessibleTableProvider& _rBrowseBox ) const = 0; + virtual table::IAccessibleTableControl* + createAccessibleTableControl( + const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& _rxParent, + table::IAccessibleTable& _rTable + ) const = 0; virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > createAccessibleIconChoiceCtrl( diff --git a/svtools/inc/svtools/accessibletable.hxx b/svtools/inc/svtools/accessibletable.hxx new file mode 100755 index 000000000000..0e3f08bfc568 --- /dev/null +++ b/svtools/inc/svtools/accessibletable.hxx @@ -0,0 +1,185 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: accessibletable.hxx,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SVTOOLS_ACCESSIBLETABLE_HXX +#define _SVTOOLS_ACCESSIBLETABLE_HXX + +#include <vcl/window.hxx> +#include <unotools/accessiblestatesethelper.hxx> +#include <com/sun/star/lang/IndexOutOfBoundsException.hpp> + +// ============================================================================ + +namespace svt{ namespace table +{ + +typedef sal_Int32 RowPos; + +// ============================================================================ + +enum AccessibleTableType +{ + /** Child index of the column header bar (first row). */ + TCINDEX_COLUMNHEADERBAR = 0, + /** Child index of the row header bar ("handle column"). */ + TCINDEX_ROWHEADERBAR = 1, + /** Child index of the data table. */ + TCINDEX_TABLE = 2 +}; + +enum AccessibleTableControlObjType +{ + TCTYPE_GRIDCONTROL, /// The GridControl itself. + TCTYPE_TABLE, /// The data table. + TCTYPE_ROWHEADERBAR, /// The row header bar. + TCTYPE_COLUMNHEADERBAR, /// The horizontal column header bar. + TCTYPE_TABLECELL, /// A cell of the data table. + TCTYPE_ROWHEADERCELL, /// A cell of the row header bar. + TCTYPE_COLUMNHEADERCELL, /// A cell of the column header bar. +}; + +// ============================================================================ + +#define XACC ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > + +/** This abstract class provides methods to implement an accessible table object. +*/ +class IAccessibleTable +{ +public: + /** @return The position of the current row. */ + virtual sal_Int32 GetCurrentRow() const = 0; + /** @return The position of the current column. */ + virtual sal_Int32 GetCurrentColumn() const = 0; + /** Creates and returns the accessible object of the whole GridControl. */ + virtual XACC CreateAccessible()= 0; + virtual XACC CreateAccessibleControl( sal_Int32 _nIndex )= 0; + virtual ::rtl::OUString GetAccessibleObjectName(AccessibleTableControlObjType eObjType, sal_Int32 _nRow, sal_Int32 _nCol) const= 0; + virtual sal_Bool GoToCell( sal_Int32 _nColumnPos, sal_Int32 _nRow )= 0; + virtual sal_Bool HasColHeader() = 0; + virtual sal_Bool HasRowHeader() = 0; + + /** return the description of the specified object. + @param eObjType + The type to ask for + @param _nPosition + The position of a tablecell (index position), header bar colum/row cell + @return + The description of the specified object. + */ + virtual ::rtl::OUString GetAccessibleObjectDescription(AccessibleTableControlObjType eObjType, sal_Int32 _nPosition = -1) const= 0; + + /** Fills the StateSet with all states (except DEFUNC and SHOWING, done by + the accessible object), depending on the specified object type. */ + virtual void FillAccessibleStateSet( + ::utl::AccessibleStateSetHelper& rStateSet, + AccessibleTableControlObjType eObjType ) const= 0; + + // Window + virtual Rectangle GetWindowExtentsRelative( Window *pRelativeWindow ) = 0; + virtual void GrabFocus()= 0; + virtual XACC GetAccessible( BOOL bCreate = TRUE )= 0; + virtual Window* GetAccessibleParentWindow() const= 0; + virtual Window* GetWindowInstance()= 0; + virtual sal_Int32 GetAccessibleControlCount() const = 0; + virtual sal_Bool ConvertPointToControlIndex( sal_Int32& _rnIndex, const Point& _rPoint )= 0; + virtual long GetRowCount() const= 0; + virtual long GetColumnCount() const= 0; + virtual sal_Bool HasRowHeader() const= 0; + virtual sal_Int32 GetSelectedRowCount() const= 0; + virtual bool IsRowSelected( long _nRow ) const= 0; + virtual sal_Bool ConvertPointToCellAddress( sal_Int32& _rnRow, sal_Int32& _rnColPos, const Point& _rPoint )= 0; + virtual Rectangle calcHeaderRect( sal_Bool _bIsColumnBar, BOOL _bOnScreen = TRUE ) = 0; + virtual Rectangle calcTableRect( BOOL _bOnScreen = TRUE ) = 0; + virtual Rectangle GetFieldCharacterBounds(sal_Int32 _nRow,sal_Int32 _nColumnPos,sal_Int32 nIndex)= 0; + virtual sal_Int32 GetFieldIndexAtPoint(sal_Int32 _nRow,sal_Int32 _nColumnPos,const Point& _rPoint)= 0; + virtual void FillAccessibleStateSetForCell( ::utl::AccessibleStateSetHelper& _rStateSet, sal_Int32 _nRow, sal_uInt16 _nColumnPos ) const= 0; + virtual ::rtl::OUString GetRowDescription( sal_Int32 _nRow ) const = 0; + virtual ::rtl::OUString GetRowName(sal_Int32 _nIndex) const = 0; + virtual ::rtl::OUString GetColumnDescription( sal_uInt16 _nColumnPos ) const = 0; + virtual ::rtl::OUString GetColumnName( sal_Int32 _nIndex ) const = 0; + virtual ::rtl::OUString GetCellContent( sal_Int32 _nRowPos, sal_Int32 _nColPos) const = 0; + virtual std::vector<sal_Int32>& GetSelectedRows() = 0; +}; + +// ---------------------------------------------------------------------------- + +/** interface for an implementation of a table control's Accesible component +*/ +class IAccessibleTableControl +{ +public: + /** returns the XAccessible object itself + + The reference returned here can be used to control the life time of the + IAccessibleTableImplementation object. + + The returned reference is guaranteed to not be <NULL/>. + */ + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > + getMyself() = 0; + + /** disposes the accessible implementation, so that it becomes defunc + */ + virtual void dispose() = 0; + + /** checks whether the accessible implementation, and its context, are still alive + @return <TRUE/>, if the object is not disposed or disposing. + */ + virtual sal_Bool isAlive() const = 0; + + /** returns the accessible object for the row or the column header bar + */ + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > + getTableHeader( ::svt::table::AccessibleTableControlObjType _eObjType ) = 0; + + /** returns the accessible object for the table representation + */ + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > + getTable() = 0; + + ///** Commits an event to all listeners. */ + virtual void commitEvent( + sal_Int16 nEventId, + const ::com::sun::star::uno::Any& rNewValue, + const ::com::sun::star::uno::Any& rOldValue + ) = 0; +}; + +// ---------------------------------------------------------------------------- + +// ============================================================================ +} // namespace table +} // namespace svt + +// ============================================================================ + +#endif // _SVTOOLS_ACCESSIBLETABLE_HXX + diff --git a/svtools/inc/svtools/table/tablecontrol.hxx b/svtools/inc/svtools/table/tablecontrol.hxx index 98fddcb7d9e1..e3edd0b681ae 100644 --- a/svtools/inc/svtools/table/tablecontrol.hxx +++ b/svtools/inc/svtools/table/tablecontrol.hxx @@ -30,6 +30,8 @@ #include <vcl/ctrl.hxx> #include <vcl/seleng.hxx> #include <svtools/table/tabledatawindow.hxx> +#include <svtools/accessibletable.hxx> +#include "svtaccessiblefactory.hxx" //........................................................................ namespace svt { namespace table @@ -38,6 +40,8 @@ namespace svt { namespace table class TableControl_Impl; class TableDataWindow; + class AccessibleTableControl_Impl; + //==================================================================== //= TableControl //==================================================================== @@ -55,10 +59,11 @@ namespace svt { namespace table The control supports the concept of a <em>current</em> (or <em>active</em> cell). + The control supports accessibility, this is encapsulated in IAccessibleTable // TODO: scrolling? */ - class TableControl : public Control + class TableControl : public Control, public IAccessibleTable { private: DECL_LINK( ImplMouseButtonDownHdl, MouseEvent* ); @@ -66,6 +71,8 @@ namespace svt { namespace table TableControl_Impl* m_pImpl; public: + ::std::auto_ptr< AccessibleTableControl_Impl > m_pAccessTable; + TableControl( Window* _pParent, WinBits _nStyle ); ~TableControl(); @@ -88,11 +95,11 @@ namespace svt { namespace table if there is no active cell, e.g. because the table does not contain any rows or columns. */ - RowPos GetCurrentRow() const; + sal_Int32 GetCurrentRow() const; /** returns the row, which contains the input point*/ - RowPos GetCurrentRow (const Point& rPoint); + ColPos GetCurrentRow (const Point& rPoint); /** retrieves the current column @@ -103,7 +110,7 @@ namespace svt { namespace table if there is no active cell, e.g. because the table does not contain any rows or columns. */ - ColPos GetCurrentColumn() const; + sal_Int32 GetCurrentColumn() const; /** activates the cell at the given position @@ -113,7 +120,7 @@ namespace svt { namespace table or impossibility to execute the move at all (for instance because of invalid coordinates). */ - bool GoTo( ColPos _nColumn, RowPos _nRow ); + bool GoTo( ColPos _nColumnPos, RowPos _nRow); /** moves the active cell to the given column, by keeping the active row @@ -147,26 +154,91 @@ namespace svt { namespace table void InvalidateDataWindow(RowPos _nRowStart, bool _bRemoved); /**gets the vector, which contains the selected rows */ - std::vector<RowPos> getSelectedRows(); + std::vector<sal_Int32>& GetSelectedRows(); /**after removing a row, updates the vector which contains the selected rows if the row, which should be removed, is selected, it will be erased from the vector */ void removeSelectedRow(RowPos _nRowPos); SelectionEngine* getSelEngine(); TableDataWindow* getDataWindow(); - // protected: + // Window overridables virtual void GetFocus(); virtual void LoseFocus(); virtual void KeyInput( const KeyEvent& rKEvt ); //virtual long Notify(NotifyEvent& rNEvt); + /** Creates and returns the accessible object of the whole BrowseBox. */ + virtual XACC CreateAccessible(); + virtual XACC CreateAccessibleControl( sal_Int32 _nIndex ); + virtual ::rtl::OUString GetAccessibleObjectName(AccessibleTableControlObjType eObjType, sal_Int32 _nRow, sal_Int32 _nCol) const; + virtual sal_Bool GoToCell( sal_Int32 _nColumnPos, sal_Int32 _nRow ); + virtual ::rtl::OUString GetAccessibleObjectDescription(AccessibleTableControlObjType eObjType, sal_Int32 _nPosition = -1) const; + virtual void FillAccessibleStateSet( + ::utl::AccessibleStateSetHelper& rStateSet, + AccessibleTableControlObjType eObjType ) const; + + //// Window + virtual Rectangle GetWindowExtentsRelative( Window *pRelativeWindow ); + virtual void GrabFocus(); + virtual XACC GetAccessible( BOOL bCreate = TRUE ); + virtual Window* GetAccessibleParentWindow() const; + virtual Window* GetWindowInstance(); + virtual sal_Int32 GetAccessibleControlCount() const; + virtual sal_Bool ConvertPointToControlIndex( sal_Int32& _rnIndex, const Point& _rPoint ); + virtual long GetRowCount() const; + virtual long GetColumnCount() const; + virtual sal_Bool HasRowHeader() const; + virtual sal_Int32 GetSelectedRowCount() const; + virtual bool IsRowSelected( long _nRow ) const; + virtual sal_Bool ConvertPointToCellAddress( sal_Int32& _rnRow, sal_Int32& _rnColPos, const Point& _rPoint ); + virtual Rectangle calcHeaderRect( sal_Bool _bIsColumnBar, BOOL _bOnScreen = TRUE ); + virtual Rectangle calcTableRect( BOOL _bOnScreen = TRUE ); + virtual Rectangle GetFieldCharacterBounds(sal_Int32 _nRow,sal_Int32 _nColumnPos,sal_Int32 nIndex); + virtual sal_Int32 GetFieldIndexAtPoint(sal_Int32 _nRow,sal_Int32 _nColumnPos,const Point& _rPoint); + virtual void FillAccessibleStateSetForCell( ::utl::AccessibleStateSetHelper& _rStateSet, sal_Int32 _nRow, sal_uInt16 _nColumnPos ) const; + virtual ::rtl::OUString GetRowDescription( sal_Int32 _nRow ) const; + virtual ::rtl::OUString GetRowName(sal_Int32 _nIndex) const; + virtual ::rtl::OUString GetColumnDescription( sal_uInt16 _nColumnPos ) const; + virtual ::rtl::OUString GetColumnName( sal_Int32 _nIndex ) const; + virtual ::rtl::OUString GetCellContent( sal_Int32 _nRowPos, sal_Int32 _nColPos) const; + virtual sal_Bool HasRowHeader(); + virtual sal_Bool HasColHeader(); + virtual sal_Bool isAccessibleAlive( ) const; + virtual void commitGridControlEvent( sal_Int16 _nEventId, const com::sun::star::uno::Any& _rNewValue, const com::sun::star::uno::Any& _rOldValue ); + + + protected: + /// retrieves the XAccessible implementation associated with the GridControl instance + ::svt::IAccessibleFactory& getAccessibleFactory(); + private: TableControl(); // never implemented TableControl( const TableControl& ); // never implemented TableControl& operator=( const TableControl& ); // never implemented }; + class AccessibleTableControl_Impl + { + public: + AccessibleFactoryAccess m_aFactoryAccess; + IAccessibleTableControl* m_pAccessible; + + public: + AccessibleTableControl_Impl() : m_pAccessible(NULL) + { + } + + + /// @see AccessibleTableControl::getTableRowHeader + ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > + getAccessibleTableHeader( AccessibleTableControlObjType _eObjType ); + /// @see AccessibleTableControl::getTable + ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > + getAccessibleTable( ); + + }; + //........................................................................ } } // namespace svt::table //........................................................................ diff --git a/svtools/inc/svtools/table/tablemodel.hxx b/svtools/inc/svtools/table/tablemodel.hxx index a1af1e1750ed..6e74d35b8586 100644 --- a/svtools/inc/svtools/table/tablemodel.hxx +++ b/svtools/inc/svtools/table/tablemodel.hxx @@ -434,13 +434,13 @@ namespace svt { namespace table virtual void setCellContent(std::vector<std::vector<rtl::OUString> > cellContent)=0; /** gets the content of the cells */ - virtual std::vector<std::vector<rtl::OUString> > getCellContent() = 0; + virtual std::vector<std::vector<rtl::OUString> >& getCellContent() = 0; /**sets title of header rows */ virtual void setRowHeaderName(std::vector<rtl::OUString> cellColumnContent)=0; /** gets title of header rows */ - virtual std::vector<rtl::OUString> getRowHeaderName() = 0; + virtual std::vector<rtl::OUString>& getRowHeaderName() = 0; /// destroys the table model instance virtual ~ITableModel() { } diff --git a/svtools/prj/d.lst b/svtools/prj/d.lst index 3570ea9bf143..924459d9c9f0 100644 --- a/svtools/prj/d.lst +++ b/svtools/prj/d.lst @@ -81,6 +81,7 @@ mkdir: %_DEST%\inc%_EXT%\svtools ..\inc\svtools\accessibletableprovider.hxx %_DEST%\inc%_EXT%\svtools\accessibletableprovider.hxx ..\inc\svtools\AccessibleBrowseBoxObjType.hxx %_DEST%\inc%_EXT%\svtools\AccessibleBrowseBoxObjType.hxx ..\inc\svtools\accessiblefactory.hxx %_DEST%\inc%_EXT%\svtools\accessiblefactory.hxx +..\inc\svtools\accessibletable.hxx %_DEST%\inc%_EXT%\svtools\accessibletable.hxx ..\inc\svtools\textwindowpeer.hxx %_DEST%\inc%_EXT%\svtools\textwindowpeer.hxx ..\inc\imgdef.hxx %_DEST%\inc%_EXT%\svtools\imgdef.hxx ..\inc\inetdef.hxx %_DEST%\inc%_EXT%\svtools\inetdef.hxx @@ -313,6 +314,8 @@ mkdir: %_DEST%\inc%_EXT%\svtools ..\inc\textwindowaccessibility.hxx %_DEST%\inc%_EXT%\svtools\textwindowaccessibility.hxx +..\inc\docpasswdrequest.hxx %_DEST%\inc%_EXT%\svtools\docpasswdrequest.hxx +..\inc\docmspasswdrequest.hxx %_DEST%\inc%_EXT%\svtools\docmspasswdrequest.hxx ..\inc\fontsubstconfig.hxx %_DEST%\inc%_EXT%\svtools\fontsubstconfig.hxx ..\inc\apearcfg.hxx %_DEST%\inc%_EXT%\svtools\apearcfg.hxx ..\inc\fltrcfg.hxx %_DEST%\inc%_EXT%\svtools\fltrcfg.hxx diff --git a/svtools/source/misc/svtaccessiblefactory.cxx b/svtools/source/misc/svtaccessiblefactory.cxx index b2d57c250d32..a4b3cc1e8ecc 100644 --- a/svtools/source/misc/svtaccessiblefactory.cxx +++ b/svtools/source/misc/svtaccessiblefactory.cxx @@ -107,6 +107,15 @@ namespace svt return NULL; } + virtual table::IAccessibleTableControl* + createAccessibleTableControl( + const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& /*_rxParent*/, + table::IAccessibleTable& /*_rTable*/ + ) const + { + return NULL; + } + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > createAccessibleIconChoiceCtrl( SvtIconChoiceCtrl& /*_rIconCtrl*/, diff --git a/svtools/source/table/tablecontrol.cxx b/svtools/source/table/tablecontrol.cxx index c8895a19408d..1d7b046ae94b 100644 --- a/svtools/source/table/tablecontrol.cxx +++ b/svtools/source/table/tablecontrol.cxx @@ -30,10 +30,35 @@ #include "tablegeometry.hxx" #include "tablecontrol_impl.hxx" #include "svtools/table/tabledatawindow.hxx" +#include <com/sun/star/accessibility/AccessibleStateType.hpp> +#include <com/sun/star/accessibility/AccessibleRole.hpp> + +using namespace ::com::sun::star::uno; +using ::com::sun::star::accessibility::XAccessible; +using namespace ::com::sun::star::accessibility; +using namespace ::com::sun::star::lang; +using namespace utl; +//using namespace rtl; //........................................................................ namespace svt { namespace table { -//........................................................................ + //==================================================================== + //= AccessibleTableControl_Impl + //==================================================================== + // ---------------------------------------------------------------------------- + Reference< XAccessible > AccessibleTableControl_Impl::getAccessibleTableHeader( AccessibleTableControlObjType _eObjType ) + { + if ( m_pAccessible && m_pAccessible->isAlive() ) + return m_pAccessible->getTableHeader( _eObjType ); + return NULL; + } + // ---------------------------------------------------------------------------- + Reference< XAccessible > AccessibleTableControl_Impl::getAccessibleTable( ) + { + if ( m_pAccessible && m_pAccessible->isAlive() ) + return m_pAccessible->getTable( ); + return NULL; + } //==================================================================== //= TableControl @@ -45,12 +70,17 @@ namespace svt { namespace table { m_pImpl->getDataWindow()->SetMouseButtonDownHdl( LINK( this, TableControl, ImplMouseButtonDownHdl ) ); m_pImpl->getDataWindow()->SetMouseButtonUpHdl( LINK( this, TableControl, ImplMouseButtonUpHdl ) ); + m_pAccessTable.reset(new ::svt::table::AccessibleTableControl_Impl()); } //-------------------------------------------------------------------- TableControl::~TableControl() { DELETEZ( m_pImpl ); + if ( m_pAccessTable->m_pAccessible ) + { + m_pAccessTable->m_pAccessible->dispose(); + } } //-------------------------------------------------------------------- @@ -59,7 +89,7 @@ namespace svt { namespace table if ( !m_pImpl->getInputHandler()->GetFocus( *m_pImpl ) ) { Control::GetFocus(); - GrabFocus(); + Control::GrabFocus(); } } @@ -109,13 +139,13 @@ namespace svt { namespace table } //-------------------------------------------------------------------- - RowPos TableControl::GetCurrentRow() const + sal_Int32 TableControl::GetCurrentRow() const { return m_pImpl->getCurRow(); } //-------------------------------------------------------------------- - ColPos TableControl::GetCurrentColumn() const + sal_Int32 TableControl::GetCurrentColumn() const { return m_pImpl->getCurColumn(); } @@ -126,6 +156,11 @@ namespace svt { namespace table return m_pImpl->goTo( _nColumn, _nRow ); } //-------------------------------------------------------------------- + sal_Bool TableControl::GoToCell(sal_Int32 _nColPos, sal_Int32 _nRowPos) + { + return m_pImpl->goTo( _nColPos, _nRowPos ); + } + //-------------------------------------------------------------------- void TableControl::InvalidateDataWindow(RowPos _nRowStart, bool _bRemoved) { Rectangle _rRect; @@ -135,7 +170,7 @@ namespace svt { namespace table return m_pImpl->invalidateRow(_nRowStart, _rRect); } //-------------------------------------------------------------------- - std::vector<RowPos> TableControl::getSelectedRows() + std::vector<sal_Int32>& TableControl::GetSelectedRows() { return m_pImpl->getSelectedRows(); } @@ -174,6 +209,331 @@ namespace svt { namespace table { return m_pImpl->getDataWindow(); } + + Reference< XAccessible > TableControl::CreateAccessible() + { + Window* pParent = GetAccessibleParentWindow(); + DBG_ASSERT( pParent, "TableControl::CreateAccessible - parent not found" ); + + if( pParent && !m_pAccessTable->m_pAccessible) + { + Reference< XAccessible > xAccParent = pParent->GetAccessible(); + if( xAccParent.is() ) + { + m_pAccessTable->m_pAccessible = getAccessibleFactory().createAccessibleTableControl( + xAccParent, *this + ); + } + } + Reference< XAccessible > xAccessible; + if ( m_pAccessTable->m_pAccessible ) + xAccessible = m_pAccessTable->m_pAccessible->getMyself(); + return xAccessible; + } + Reference<XAccessible> TableControl::CreateAccessibleControl( sal_Int32 _nIndex ) + { + (void)_nIndex; + DBG_ASSERT( FALSE, "TableControl::CreateAccessibleControl: to be overwritten!" ); + return NULL; + } + ::rtl::OUString TableControl::GetAccessibleObjectName( AccessibleTableControlObjType eObjType, sal_Int32 _nRow, sal_Int32 _nCol) const + { + ::rtl::OUString aRetText; + switch( eObjType ) + { + case TCTYPE_GRIDCONTROL: + aRetText = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "GridControl" ) ); + break; + case TCTYPE_TABLE: + aRetText = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Table" ) ); + break; + case TCTYPE_ROWHEADERBAR: + aRetText = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "RowHeaderBar" ) ); + break; + case TCTYPE_COLUMNHEADERBAR: + aRetText = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ColumnHeaderBar" ) ); + break; + case TCTYPE_TABLECELL: + aRetText = GetCellContent(_nRow, _nCol); + break; + case TCTYPE_ROWHEADERCELL: + aRetText = GetRowName(_nRow); + break; + case TCTYPE_COLUMNHEADERCELL: + aRetText = GetColumnName(_nCol); + break; + default: + OSL_ENSURE(0,"GridControl::GetAccessibleName: invalid enum!"); + } + return aRetText; + } +// ----------------------------------------------------------------------------- + +::rtl::OUString TableControl::GetAccessibleObjectDescription( AccessibleTableControlObjType eObjType, sal_Int32 ) const +{ + ::rtl::OUString aRetText; + switch( eObjType ) + { + case TCTYPE_GRIDCONTROL: + aRetText = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "GridControl description" ) ); + break; + case TCTYPE_TABLE: + aRetText = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TABLE description" ) ); + break; + case TCTYPE_ROWHEADERBAR: + aRetText = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ROWHEADERBAR description" ) ); + break; + case TCTYPE_COLUMNHEADERBAR: + aRetText = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "COLUMNHEADERBAR description" ) ); + break; + case TCTYPE_TABLECELL: + aRetText = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TABLECELL description" ) ); + break; + case TCTYPE_ROWHEADERCELL: + aRetText = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ROWHEADERCELL description" ) ); + break; + case TCTYPE_COLUMNHEADERCELL: + aRetText = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "COLUMNHEADERCELL description" ) ); + break; + } + return aRetText; +} +// ----------------------------------------------------------------------------- + +::rtl::OUString TableControl::GetRowDescription( sal_Int32 _nRow) const +{ + (void)_nRow; + return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "row description" ) ); +} +// ----------------------------------------------------------------------------- + +::rtl::OUString TableControl::GetRowName( sal_Int32 _nIndex) const +{ + return GetModel()->getRowHeaderName()[_nIndex]; +} +// ----------------------------------------------------------------------------- + +::rtl::OUString TableControl::GetColumnDescription( sal_uInt16 _nColumn) const +{ + (void)_nColumn; + return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "col description" ) ); +} +// ----------------------------------------------------------------------------- + +::rtl::OUString TableControl::GetColumnName( sal_Int32 _nIndex) const +{ + return GetModel()->getColumnModel(_nIndex)->getName(); +} + +// ----------------------------------------------------------------------------- + +::rtl::OUString TableControl::GetCellContent( sal_Int32 _nRowPos, sal_Int32 _nColPos) const +{ + ::rtl::OUString cellContent = ::rtl::OUString::createFromAscii(""); + std::vector<std::vector<rtl::OUString> >& aTableContent = GetModel()->getCellContent(); + if(&aTableContent) + { + std::vector<rtl::OUString>& aRowContent = aTableContent[_nRowPos]; + if(&aRowContent) + cellContent = aRowContent[_nColPos]; + } + return cellContent; +} +// ----------------------------------------------------------------------------- + +void TableControl::FillAccessibleStateSet( + ::utl::AccessibleStateSetHelper& rStateSet, + AccessibleTableControlObjType eObjType ) const +{ + switch( eObjType ) + { + case TCTYPE_GRIDCONTROL: + case TCTYPE_TABLE: + + rStateSet.AddState( AccessibleStateType::FOCUSABLE ); + rStateSet.AddState( AccessibleStateType::MULTI_SELECTABLE); + if ( HasFocus() ) + rStateSet.AddState( AccessibleStateType::FOCUSED ); + if ( IsActive() ) + rStateSet.AddState( AccessibleStateType::ACTIVE ); + if ( IsEnabled() ) + rStateSet.AddState( AccessibleStateType::ENABLED ); + if ( IsReallyVisible() ) + rStateSet.AddState( AccessibleStateType::VISIBLE ); + rStateSet.AddState( AccessibleStateType::MANAGES_DESCENDANTS ); + + break; + case TCTYPE_ROWHEADERBAR: + rStateSet.AddState( AccessibleStateType::VISIBLE ); + rStateSet.AddState( AccessibleStateType::MANAGES_DESCENDANTS ); + break; + case TCTYPE_COLUMNHEADERBAR: + rStateSet.AddState( AccessibleStateType::VISIBLE ); + rStateSet.AddState( AccessibleStateType::MANAGES_DESCENDANTS ); + break; + case TCTYPE_TABLECELL: + { + //sal_Int32 nRow = GetCurRow(); + //sal_uInt16 nColumn = GetCurColumnId(); + //if ( IsFieldVisible(nRow,nColumn) ) + // rStateSet.AddState( AccessibleStateType::VISIBLE ); + rStateSet.AddState( AccessibleStateType::TRANSIENT ); + rStateSet.AddState( AccessibleStateType::SELECTABLE); + if( GetSelectedRowCount()>0) + rStateSet.AddState( AccessibleStateType::SELECTED); + } + break; + case TCTYPE_ROWHEADERCELL: + rStateSet.AddState( AccessibleStateType::VISIBLE ); + rStateSet.AddState( AccessibleStateType::TRANSIENT ); + break; + case TCTYPE_COLUMNHEADERCELL: + rStateSet.AddState( AccessibleStateType::VISIBLE ); + break; + } +} + +Rectangle TableControl::GetWindowExtentsRelative( Window *pRelativeWindow ) +{ + return Control::GetWindowExtentsRelative( pRelativeWindow ); +} +//----------------------------------------------------------------------------- +void TableControl::GrabFocus() +{ + Control::GrabFocus(); +} +// ----------------------------------------------------------------------------- +Reference< XAccessible > TableControl::GetAccessible( BOOL bCreate ) +{ + return Control::GetAccessible( bCreate ); +} +// ----------------------------------------------------------------------------- +Window* TableControl::GetAccessibleParentWindow() const +{ + return Control::GetAccessibleParentWindow(); +} +// ----------------------------------------------------------------------------- +Window* TableControl::GetWindowInstance() +{ + return this; +} + +sal_Bool TableControl::HasRowHeader() +{ + return GetModel()->hasRowHeaders(); +} +//-------------------------------------------------------------------------------- +sal_Bool TableControl::HasColHeader() +{ + return GetModel()->hasColumnHeaders(); +} +//-------------------------------------------------------------------------------- +sal_Int32 TableControl::GetAccessibleControlCount() const +{ + sal_Int32 count = 0; + if(GetRowCount()>0) + count+=1; + if(GetModel()->hasRowHeaders()) + count+=1; + if(GetModel()->hasColumnHeaders()) + count+=1; + return count; +} +sal_Bool TableControl::ConvertPointToControlIndex( sal_Int32& _rnIndex, const Point& _rPoint ) +{ + sal_Int32 nRow = m_pImpl->getCurrentRow(_rPoint); + sal_Int32 nCol = GetCurrentColumn(); + _rnIndex = nRow * GetColumnCount() + nCol; + return nRow>=0 ? sal_True : sal_False; +} + +long TableControl::GetRowCount() const +{ + return m_pImpl->getRowCount(); +} +long TableControl::GetColumnCount() const +{ + return m_pImpl->getColumnCount(); +} +sal_Bool TableControl::HasRowHeader() const +{ + PTableModel pModel = GetModel(); + return pModel->hasRowHeaders(); +} +sal_Int32 TableControl::GetSelectedRowCount() const +{ + return m_pImpl->getSelectedRows().size(); +} +bool TableControl::IsRowSelected( long _nRow ) const +{ + return m_pImpl->isRowSelected(m_pImpl->getSelectedRows(), _nRow); +} +sal_Bool TableControl::ConvertPointToCellAddress( sal_Int32& _rnRow, sal_Int32& _rnColPos, const Point& _rPoint ) +{ + _rnRow = m_pImpl->getCurrentRow(_rPoint); + _rnColPos = GetCurrentColumn(); + return _rnRow>=0 ? sal_True : sal_False; +} +void TableControl::FillAccessibleStateSetForCell( ::utl::AccessibleStateSetHelper& _rStateSet, sal_Int32 _nRow, sal_uInt16 _nColumnPos ) const +{ + if ( GetCurrentRow() == _nRow && GetCurrentColumn() == _nColumnPos ) + _rStateSet.AddState( AccessibleStateType::FOCUSED ); + else // only transient when column is not focused + _rStateSet.AddState( AccessibleStateType::TRANSIENT ); +} +Rectangle TableControl::GetFieldCharacterBounds(sal_Int32 _nRow,sal_Int32 _nColumnPos,sal_Int32 nIndex) +{ + (void)_nRow; + (void)_nColumnPos; + return GetCharacterBounds(nIndex); +} +sal_Int32 TableControl::GetFieldIndexAtPoint(sal_Int32 _nRow,sal_Int32 _nColumnPos,const Point& _rPoint) +{ + (void)_nRow; + (void)_nColumnPos; + return GetIndexForPoint(_rPoint);
+; +} + // -----------------------------------------------------------------------------
+sal_Bool TableControl::isAccessibleAlive( ) const
+{
+ return ( NULL != m_pAccessTable->m_pAccessible ) && m_pAccessTable->m_pAccessible->isAlive();
+}
+ +// ----------------------------------------------------------------------------- +::svt::IAccessibleFactory& TableControl::getAccessibleFactory() +{ + return m_pAccessTable->m_aFactoryAccess.getFactory(); +} +// -----------------------------------------------------------------------------
+void TableControl::commitGridControlEvent( sal_Int16 _nEventId, const Any& _rNewValue, const Any& _rOldValue )
+{
+ if ( isAccessibleAlive() )
+ m_pAccessTable->m_pAccessible->commitEvent( _nEventId, _rNewValue, _rOldValue);
+} +// -----------------------------------------------------------------------------
+Rectangle TableControl::calcHeaderRect(sal_Bool _bIsColumnBar,BOOL _bOnScreen)
+{
+ (void)_bOnScreen;
+ Rectangle aRectTable, aRectTableWithHeaders;
+ m_pImpl->impl_getAllVisibleDataCellArea(aRectTable);
+ m_pImpl->impl_getAllVisibleCellsArea(aRectTableWithHeaders);
+ Size aSizeTable(aRectTable.GetSize());
+ Size aSizeTableWithHeaders(aRectTableWithHeaders.GetSize());
+ if(_bIsColumnBar)
+ return Rectangle(aRectTableWithHeaders.TopLeft(),Size(aSizeTableWithHeaders.Width()-aSizeTable.Width(), aSizeTableWithHeaders.Height()));
+ else
+ return Rectangle(aRectTableWithHeaders.TopLeft(),Size(aSizeTableWithHeaders.Width(), aSizeTableWithHeaders.Height()-aSizeTable.Height()));
+}
+// -----------------------------------------------------------------------------
+Rectangle TableControl::calcTableRect(BOOL _bOnScreen)
+{
+ (void)_bOnScreen;
+ Rectangle aRect;
+ m_pImpl->impl_getAllVisibleDataCellArea(aRect);
+ return aRect;
+}
+ //........................................................................ -} } // namespace svt::table +}} // namespace svt::table //........................................................................ diff --git a/svtools/source/table/tablecontrol_impl.cxx b/svtools/source/table/tablecontrol_impl.cxx index e1ff3aeb7f2a..89c0eed4229a 100644 --- a/svtools/source/table/tablecontrol_impl.cxx +++ b/svtools/source/table/tablecontrol_impl.cxx @@ -181,24 +181,23 @@ namespace svt { namespace table { (void)pCellEntryType; } - virtual std::vector<std::vector<rtl::OUString> > getCellContent() + virtual std::vector<std::vector<rtl::OUString> >& getCellContent() { - std::vector<rtl::OUString> cCC; - cCC.push_back(rtl::OUString::createFromAscii("")); - std::vector<std::vector<rtl::OUString> > cC; - cC.push_back(cCC); - return cC; + return *( new std::vector<std::vector<rtl::OUString> >); } virtual void setRowHeaderName(std::vector<rtl::OUString> pCellEntryType) { (void)pCellEntryType; } - virtual std::vector<rtl::OUString> getRowHeaderName() + virtual std::vector<rtl::OUString>& getRowHeaderName() { - std::vector<rtl::OUString> cCC; - cCC.push_back(rtl::OUString::createFromAscii("")); - return cCC; + aRowHeaderNames.clear(); + aRowHeaderNames.push_back(rtl::OUString::createFromAscii("")); + return aRowHeaderNames; } + + private: + std::vector<rtl::OUString> aRowHeaderNames; }; @@ -882,7 +881,7 @@ namespace svt { namespace table impl_getAllVisibleDataCellArea( aAllDataCellsArea ); //get the vector, which contains row vectors, each containing the data for the cells in this row - std::vector<std::vector<rtl::OUString> > aCellContent = m_pModel->getCellContent(); + std::vector<std::vector<rtl::OUString> >& aCellContent = m_pModel->getCellContent(); //if the vector is empty, fill it with empty data, so the table can be painted if(aCellContent.empty()) { @@ -895,7 +894,7 @@ namespace svt { namespace table } std::vector<std::vector<rtl::OUString> >::iterator it = aCellContent.begin()+m_nTopRow; //get the vector, which contains the row header titles - std::vector<rtl::OUString> aRowHeaderContent; + std::vector<rtl::OUString>& aRowHeaderContent = m_pModel->getRowHeaderName(); ::std::vector<rtl::OUString>::iterator itRowName = aRowHeaderContent.begin(); if(m_pModel->hasRowHeaders()) @@ -1525,7 +1524,7 @@ namespace svt { namespace table } //------------------------------------------------------------------------------- - std::vector<RowPos> TableControl_Impl::getSelectedRows() + std::vector<RowPos>& TableControl_Impl::getSelectedRows() { return m_nRowSelected; } diff --git a/svtools/source/table/tablecontrol_impl.hxx b/svtools/source/table/tablecontrol_impl.hxx index 410bc8b4c3a1..0a25e82e4502 100644 --- a/svtools/source/table/tablecontrol_impl.hxx +++ b/svtools/source/table/tablecontrol_impl.hxx @@ -138,6 +138,8 @@ namespace svt { namespace table inline RowPos getCurRow() const { return m_nCurRow; } inline void setCurRow(RowPos curRow){ m_nCurRow = curRow; } inline RowPos getTopRow() const { return m_nTopRow; } + inline long getRowCount() const { return m_nRowCount; } + inline long getColumnCount() const { return m_nColumnCount; } inline long getColHeaderHightPixel() const { return m_nColHeaderHeightPixel; } @@ -194,7 +196,7 @@ namespace svt { namespace table /** to be called when a new row is added to the control*/ void invalidateRow(RowPos _nRowPos, Rectangle& _rCellRect ); /** returns the vector, which contains the selected rows*/ - std::vector<RowPos> getSelectedRows(); + std::vector<RowPos>& getSelectedRows(); /** updates the vector, which contains the selected rows after removing the row nRowPos*/ void removeSelectedRow(RowPos _nRowPos); void invalidateRows(RowPos _nRowStart, Rectangle& _rCellRect ); @@ -208,15 +210,6 @@ namespace svt { namespace table virtual SelectionEngine* getSelEngine(); TableDataWindow* getDataWindow(); - - private: - /** toggles the cursor visibility - - The method is not bound to the classes public invariants, as it's used in - situations where the they must not necessarily be fullfilled. - */ - void impl_ni_doSwitchCursor( bool _bOn ); - /** retrieves the area occupied by the totality of (at least partially) visible cells The returned area includes row and column headers. Also, it takes into @@ -234,6 +227,13 @@ namespace svt { namespace table minus the row and column header areas. */ void impl_getAllVisibleDataCellArea( Rectangle& _rCellArea ) const; + private: + /** toggles the cursor visibility + + The method is not bound to the classes public invariants, as it's used in + situations where the they must not necessarily be fullfilled. + */ + void impl_ni_doSwitchCursor( bool _bOn ); /** returns the number of visible rows. diff --git a/svtools/source/uno/makefile.mk b/svtools/source/uno/makefile.mk index d8438bd48ccf..7b992637e152 100644 --- a/svtools/source/uno/makefile.mk +++ b/svtools/source/uno/makefile.mk @@ -58,7 +58,8 @@ SLOFILES= \ $(SLO)$/unocontroltablemodel.obj \ $(SLO)$/unoevent.obj \ $(SLO)$/unoiface.obj \ - $(SLO)$/unoimap.obj + $(SLO)$/unoimap.obj \ + $(SLO)$/svtxgridcontrol.obj # --- Targets ------------------------------------------------------ diff --git a/svtools/source/uno/svtxgridcontrol.cxx b/svtools/source/uno/svtxgridcontrol.cxx new file mode 100755 index 000000000000..2f2c896ee6a8 --- /dev/null +++ b/svtools/source/uno/svtxgridcontrol.cxx @@ -0,0 +1,458 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: SVTXGridControl.cxx,v $ + * $Revision: 1.32 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svtools.hxx" + +#include "svtxgridcontrol.hxx" +#include <com/sun/star/view/SelectionType.hpp> +#include "svtools/table/gridtablerenderer.hxx" +#include "svtools/table/defaultinputhandler.hxx" +#include "svtools/table/tablecontrol.hxx" +#include "unocontroltablemodel.hxx" +#include <comphelper/sequence.hxx> +#include <rtl/ref.hxx> +#include <tools/debug.hxx> +#include <toolkit/helper/property.hxx> +#include <comphelper/processfactory.hxx> +#include <com/sun/star/awt/grid/XGridColumn.hpp> +#include <com/sun/star/accessibility/AccessibleTableModelChange.hpp>
+#include <com/sun/star/accessibility/AccessibleTableModelChangeType.hpp>
+#include <com/sun/star/accessibility/AccessibleEventId.hpp>
+ + +using ::rtl::OUString; +using namespace ::svt::table; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::awt::grid; +using namespace ::com::sun::star::view; +using namespace ::toolkit; +using namespace ::com::sun::star::accessibility; +using namespace ::com::sun::star::accessibility::AccessibleEventId;
+using namespace ::com::sun::star::accessibility::AccessibleTableModelChangeType;
+using ::com::sun::star::accessibility::AccessibleTableModelChange;
+ + +SVTXGridControl::SVTXGridControl() + :m_pTableModel (new UnoControlTableModel()), + m_xDataModel(0), + m_xColumnModel(0), + m_bHasColumnHeaders(false), + m_bHasRowHeaders(false), + m_bVScroll(false), + m_bHScroll(false) +{ +} + +//-------------------------------------------------------------------- +SVTXGridControl::~SVTXGridControl() +{ + DELETEZ(m_pTableModel); +} + +::com::sun::star::uno::Any SVTXGridControl::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) +{ + ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType, + SAL_STATIC_CAST( ::com::sun::star::awt::grid::XGridControl*, this ), + SAL_STATIC_CAST( ::com::sun::star::awt::grid::XGridDataListener*, this ), + SAL_STATIC_CAST( ::com::sun::star::lang::XTypeProvider*, this ) ); + return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType )); +} + +// ::com::sun::star::lang::XTypeProvider +IMPL_XTYPEPROVIDER_START( SVTXGridControl ) + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridControl>* ) NULL ), + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridDataModel>* ) NULL ), + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseListener>* ) NULL ), + VCLXWindow::getTypes() +IMPL_XTYPEPROVIDER_END + +::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumnModel > SAL_CALL SVTXGridControl::getColumnModel( ) throw (::com::sun::star::uno::RuntimeException) +{ + return NULL; +} +void SAL_CALL SVTXGridControl::setColumnModel( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumnModel >& model ) throw (::com::sun::star::uno::RuntimeException) +{ + (void)model; +} +::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridDataModel > SAL_CALL SVTXGridControl::getDataModel( ) throw (::com::sun::star::uno::RuntimeException) +{ + return NULL; +} +void SAL_CALL SVTXGridControl::setDataModel( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridDataModel >& model ) throw (::com::sun::star::uno::RuntimeException) +{ + (void)model; +} +sal_Int32 SAL_CALL SVTXGridControl::getItemIndexAtPoint(::sal_Int32 x, ::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException) +{ + TableControl* pTable = (TableControl*)GetWindow(); + return pTable->GetCurrentRow( Point(x,y) ); +} + +void SAL_CALL SVTXGridControl::addSelectionListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridSelectionListener > & listener) throw (::com::sun::star::uno::RuntimeException) +{ + (void)listener; +} + +void SAL_CALL SVTXGridControl::removeSelectionListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridSelectionListener > & listener) throw (::com::sun::star::uno::RuntimeException) +{ + (void) listener; +} + +void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const Any& aValue) throw(RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + TableControl* pTable = (TableControl*)GetWindow(); + + switch( GetPropertyId( PropertyName ) ) + { + case BASEPROPERTY_GRID_SELECTIONMODE: + { + SelectionType eSelectionType; + if( aValue >>= eSelectionType ) + { + SelectionMode eSelMode; + switch( eSelectionType ) + { + case SelectionType_SINGLE: eSelMode = SINGLE_SELECTION; break; + case SelectionType_RANGE: eSelMode = RANGE_SELECTION; break; + case SelectionType_MULTI: eSelMode = MULTIPLE_SELECTION; break; + // case SelectionType_NONE: + default: eSelMode = NO_SELECTION; break; + } + if( pTable->getSelEngine()->GetSelectionMode() != eSelMode ) + pTable->getSelEngine()->SetSelectionMode( eSelMode ); + } + break; + } + case BASEPROPERTY_HSCROLL: + { + sal_Bool bHScroll = true; + if( aValue >>= bHScroll ) + { + m_bHScroll = bHScroll; + } + break; + } + case BASEPROPERTY_VSCROLL: + { + sal_Bool bVScroll = true; + if( aValue >>= bVScroll ) + { + m_bVScroll = bVScroll; + } + break; + } + case BASEPROPERTY_GRID_SHOWROWHEADER: + { + sal_Bool rowHeader = true; + if( aValue >>= rowHeader ) + { + m_pTableModel->setRowHeaders(rowHeader); + } + break; + } + + case BASEPROPERTY_GRID_SHOWCOLUMNHEADER: + { + sal_Bool colHeader = true; + if( aValue >>= colHeader ) + { + m_pTableModel->setColumnHeaders(colHeader); + } + break; + } + case BASEPROPERTY_GRID_DATAMODEL: + { + m_xDataModel = Reference< XGridDataModel >( aValue, UNO_QUERY ); + Sequence<Sequence< ::rtl::OUString > > cellData = m_xDataModel->getData(); + Sequence<rtl::OUString> rowData(0); + std::vector< std::vector< rtl::OUString > > aCellContent(0); + for(int i = 0; i< m_xDataModel->getRowCount();++i) + { + rowData = cellData[i]; + std::vector<rtl::OUString> newRow( + comphelper::sequenceToContainer< std::vector<rtl::OUString > >(rowData)); + if(newRow.size() < (unsigned)m_pTableModel->getColumnCount()) + newRow.resize( m_pTableModel->getColumnCount(),rtl::OUString::createFromAscii("")); + aCellContent.push_back(newRow); + } + m_pTableModel->setCellContent(aCellContent); + Sequence< ::rtl::OUString > rowHeaders = m_xDataModel->getRowHeaders(); + std::vector< rtl::OUString > newRow( + comphelper::sequenceToContainer< std::vector<rtl::OUString > >(rowHeaders)); + m_pTableModel->setRowCount(m_xDataModel->getRowCount()); + m_pTableModel->setRowHeaderName(newRow); + break; + } + case BASEPROPERTY_GRID_COLUMNMODEL: + { + m_xColumnModel = Reference< XGridColumnModel >( aValue, UNO_QUERY ); + Sequence<Reference< XGridColumn > > columns = m_xColumnModel->getColumns(); + std::vector<Reference< XGridColumn > > aNewColumns( + comphelper::sequenceToContainer<std::vector<Reference< XGridColumn > > >(columns)); + /* if(m_pTable->GetColumnCount().size()>0) + m_pTable->GetColumnName.clear();*/ + for ( ::svt::table::ColPos col = 0; col < m_xColumnModel->getColumnCount(); ++col ) + { + UnoControlTableColumn* tableColumn = new UnoControlTableColumn(aNewColumns[col]); + m_pTableModel->getColumnModel().push_back((PColumnModel)tableColumn); + } + break; + } + default: + VCLXWindow::setProperty( PropertyName, aValue ); + break; + } +} + +Any SVTXGridControl::getProperty( const ::rtl::OUString& PropertyName ) throw(RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + + const sal_uInt16 nPropId = GetPropertyId( PropertyName ); + TableControl* pTable = (TableControl*)GetWindow(); + if(pTable) + { + switch(nPropId) + { + case BASEPROPERTY_GRID_SELECTIONMODE: + { + SelectionType eSelectionType; + + SelectionMode eSelMode = pTable->getSelEngine()->GetSelectionMode(); + switch( eSelMode ) + { + case SINGLE_SELECTION: eSelectionType = SelectionType_SINGLE; break; + case RANGE_SELECTION: eSelectionType = SelectionType_RANGE; break; + case MULTIPLE_SELECTION:eSelectionType = SelectionType_MULTI; break; +// case NO_SELECTION: + default: eSelectionType = SelectionType_NONE; break; + } + return Any( eSelectionType ); + } + case BASEPROPERTY_GRID_SHOWROWHEADER: + { + return Any ((sal_Bool) m_pTableModel->hasRowHeaders()); + } + case BASEPROPERTY_GRID_SHOWCOLUMNHEADER: + return Any ((sal_Bool) m_pTableModel->hasColumnHeaders()); + case BASEPROPERTY_GRID_DATAMODEL: + return Any ( m_xDataModel ); + case BASEPROPERTY_GRID_COLUMNMODEL: + return Any ( m_xColumnModel); + case BASEPROPERTY_HSCROLL: + return Any ( m_bHScroll); + case BASEPROPERTY_VSCROLL: + return Any ( m_bVScroll); + } + } + return VCLXWindow::getProperty( PropertyName ); +} + +void SVTXGridControl::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) +{ + PushPropertyIds( rIds, + BASEPROPERTY_GRID_SHOWROWHEADER, + BASEPROPERTY_GRID_SHOWCOLUMNHEADER, + BASEPROPERTY_GRID_DATAMODEL, + BASEPROPERTY_GRID_COLUMNMODEL, + BASEPROPERTY_GRID_SELECTIONMODE, + 0); + VCLXWindow::ImplGetPropertyIds( rIds, true ); +} +void SAL_CALL SVTXGridControl::setVisible( sal_Bool bVisible ) throw(::com::sun::star::uno::RuntimeException) +{ + TableControl* pTable = (TableControl*)GetWindow(); + if ( pTable ) + { + pTable->SetModel(PTableModel(m_pTableModel)); + //m_pTable->SetPosSizePixel( Point( nPosX, nPosY ), Size(nWidth, nHeight) ); + pTable->Show( bVisible ); + } +} +void SAL_CALL SVTXGridControl::setFocus() throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + if ( GetWindow()) + GetWindow()->GrabFocus(); +} +void SAL_CALL SVTXGridControl::rowAdded(const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException) +{ + std::vector<OUString> aNewRow( + comphelper::sequenceToContainer< std::vector<rtl::OUString > >(Event.rowData)); + if(aNewRow.size()< (unsigned)m_pTableModel->getColumnCount()) + aNewRow.resize(m_pTableModel->getColumnCount(),rtl::OUString::createFromAscii("")); + m_pTableModel->getCellContent().push_back(aNewRow); + if(m_pTableModel->hasRowHeaders()) + m_pTableModel->getRowHeaderName().push_back(Event.headerName); + m_pTableModel->setRowCount(m_pTableModel->getRowHeaderName().size()); + TableControl* pTable = (TableControl*)GetWindow(); + pTable->InvalidateDataWindow(m_pTableModel->getRowHeaderName().size()-1, false); + //pTable->GrabFocus(); + if(pTable->isAccessibleAlive()) + { + pTable->commitGridControlEvent(TABLE_MODEL_CHANGED,
+ makeAny( AccessibleTableModelChange(INSERT, m_pTableModel->getRowCount()-1, m_pTableModel->getRowCount(), 0, m_pTableModel->getColumnCount())),
+ Any());
+ pTable->commitGridControlEvent(CHILD,
+ makeAny( pTable->m_pAccessTable->m_pAccessible->getTableHeader(TCTYPE_ROWHEADERBAR)),
+ Any());
+ for (sal_Int32 i = 0 ; i <= m_pTableModel->getColumnCount() ; ++i) + { + pTable->commitGridControlEvent( + CHILD, + makeAny( pTable->m_pAccessTable->m_pAccessible->getTable() ), + Any()); + }
+ } +} + +void SAL_CALL SVTXGridControl::rowRemoved(const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException) +{ + TableControl* pTable = (TableControl*)GetWindow(); + //unsigned int rows =m_pImpl->aCellContent.size()-1; + if(Event.index == -1) + { + if(m_pTableModel->hasRowHeaders()) + m_pTableModel->getRowHeaderName().clear(); + m_pTableModel->getCellContent().clear(); + if(pTable->isAccessibleAlive()) + { + pTable->commitGridControlEvent(TABLE_MODEL_CHANGED,
+ makeAny( AccessibleTableModelChange(DELETE, 0, m_pTableModel->getColumnCount(), 0, m_pTableModel->getColumnCount())),
+ Any());
+ } + } + else + { + pTable->removeSelectedRow(Event.index); + if(m_pTableModel->getCellContent().size()>1) + { + if(m_pTableModel->hasRowHeaders()) + m_pTableModel->getRowHeaderName().erase(m_pTableModel->getRowHeaderName().begin()+Event.index); + m_pTableModel->getCellContent().erase(m_pTableModel->getCellContent().begin()+Event.index); + + } + else + { + if(m_pTableModel->hasRowHeaders()) + m_pTableModel->getRowHeaderName().clear(); + m_pTableModel->getCellContent().clear(); + //m_pImpl->nRowCount=0; + } + } + //pTable->InvalidateDataWindow(Event.index, true); + m_pTableModel->setRowCount(m_pTableModel->getCellContent().size()); + pTable->InvalidateDataWindow(Event.index, true); + if(pTable->isAccessibleAlive()) + { + pTable->commitGridControlEvent(TABLE_MODEL_CHANGED,
+ makeAny( AccessibleTableModelChange(DELETE, Event.index, Event.index+1, 0, m_pTableModel->getColumnCount())),
+ Any());
+ //pTable->commitGridControlEvent(CHILD,
+ // makeAny( pTable->m_pAccessTable->m_pAccessible->getTableHeader(TCTYPE_ROWHEADERBAR)),
+ // Any());
+ //for (sal_Int32 i = 0 ; i <= m_pTableModel->getColumnCount() ; ++i) + //{ + // pTable->commitGridControlEvent( + // CHILD, + // makeAny( pTable->m_pAccessTable->m_pAccessible->getTable() ), + // Any()); + //}
+ } + //pTable->Invalidate(); +} + +void SAL_CALL SVTXGridControl::dataChanged(const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException) +{ + (void) Event; +} + + void SAL_CALL SVTXGridControl::disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException) + { + VCLXWindow::disposing( Source ); + } + +::sal_Int32 SAL_CALL SVTXGridControl::getMinSelectionIndex() throw (::com::sun::star::uno::RuntimeException) +{ + return 0; +} + +::sal_Int32 SAL_CALL SVTXGridControl::getMaxSelectionIndex() throw (::com::sun::star::uno::RuntimeException) +{ + return 0; +} + +void SAL_CALL SVTXGridControl::insertIndexIntervall(::sal_Int32 start, ::sal_Int32 length) throw (::com::sun::star::uno::RuntimeException) +{ + (void)length; + (void)start; +} + +void SAL_CALL SVTXGridControl::removeIndexIntervall(::sal_Int32 start, ::sal_Int32 end) throw (::com::sun::star::uno::RuntimeException) +{ + (void)end; + (void)start; +} + +::com::sun::star::uno::Sequence< ::sal_Int32 > SAL_CALL SVTXGridControl::getSelection() throw (::com::sun::star::uno::RuntimeException) +{ + TableControl* pTable = (TableControl*)GetWindow(); + std::vector<RowPos>& selectedRows = pTable->GetSelectedRows(); + Sequence<sal_Int32> selectedRowsToSequence(comphelper::containerToSequence(selectedRows)); + return selectedRowsToSequence; +} + +::sal_Bool SAL_CALL SVTXGridControl::isCellEditable() throw (::com::sun::star::uno::RuntimeException) +{ + return sal_False; +} + +::sal_Bool SAL_CALL SVTXGridControl::isSelectionEmpty() throw (::com::sun::star::uno::RuntimeException) +{ + return sal_False; +} + +::sal_Bool SAL_CALL SVTXGridControl::isSelectedIndex(::sal_Int32 index) throw (::com::sun::star::uno::RuntimeException) +{ + (void)index; + return sal_False; +} + +void SAL_CALL SVTXGridControl::selectRow(::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException) +{ + (void)y; +} + +void SAL_CALL SVTXGridControl::selectColumn(::sal_Int32 x) throw (::com::sun::star::uno::RuntimeException) +{ + (void)x; +} diff --git a/svtools/source/uno/svtxgridcontrol.hxx b/svtools/source/uno/svtxgridcontrol.hxx new file mode 100755 index 000000000000..9ca6901681c9 --- /dev/null +++ b/svtools/source/uno/svtxgridcontrol.hxx @@ -0,0 +1,106 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: SVTXGridControl.hxx,v $ + * $Revision: 1.32 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SVT_GRIDCONTROL_HXX_ +#define _SVT_GRIDCONTROL_HXX_ + +#include <unocontroltablemodel.hxx> +#include <svtools/table/tablecontrol.hxx> +#include <com/sun/star/awt/grid/XGridControl.hpp> +#include <com/sun/star/awt/grid/XGridDataListener.hpp> +#include <com/sun/star/awt/grid/GridDataEvent.hpp> +#include <com/sun/star/awt/grid/XGridColumnModel.hpp> +#include <com/sun/star/awt/grid/XGridDataModel.hpp> +#include <com/sun/star/awt/grid/XGridSelectionListener.hpp> +#include <toolkit/awt/vclxwindow.hxx> +#include <toolkit/awt/vclxwindows.hxx> +#include <cppuhelper/typeprovider.hxx> +#include <cppuhelper/implbase2.hxx> +//#include <toolkit/helper/listenermultiplexer.hxx> + + +using namespace ::svt::table; + +class SVTXGridControl : public ::cppu::ImplInheritanceHelper2< VCLXWindow, ::com::sun::star::awt::grid::XGridControl, + ::com::sun::star::awt::grid::XGridDataListener> +{ +private: + UnoControlTableModel* m_pTableModel; + ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridDataModel >m_xDataModel; + ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumnModel >m_xColumnModel; + bool m_bHasColumnHeaders; + bool m_bHasRowHeaders; + bool m_bVScroll; + bool m_bHScroll; + +public: + SVTXGridControl(); + ~SVTXGridControl(); + //XGridDataListener overridables + virtual void SAL_CALL rowAdded(const ::com::sun::star::awt::grid::GridDataEvent& Event) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL rowRemoved(const ::com::sun::star::awt::grid::GridDataEvent & Event) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL dataChanged(const ::com::sun::star::awt::grid::GridDataEvent & Event) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException); + + ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); + void SAL_CALL acquire() throw() { VCLXWindow::acquire(); } + void SAL_CALL release() throw() { VCLXWindow::release(); } + + // ::com::sun::star::lang::XTypeProvider + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw(::com::sun::star::uno::RuntimeException); + ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw(::com::sun::star::uno::RuntimeException); + + //::com::sun::star::awt::grid::XGridControl + ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumnModel > SAL_CALL getColumnModel( ) throw (::com::sun::star::uno::RuntimeException); + void SAL_CALL setColumnModel( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumnModel >& model ) throw (::com::sun::star::uno::RuntimeException); + ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridDataModel > SAL_CALL getDataModel( ) throw (::com::sun::star::uno::RuntimeException); + void SAL_CALL setDataModel( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridDataModel >& model ) throw (::com::sun::star::uno::RuntimeException); + + virtual ::sal_Int32 SAL_CALL getMinSelectionIndex() throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int32 SAL_CALL getMaxSelectionIndex() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL insertIndexIntervall(::sal_Int32 start, ::sal_Int32 length) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeIndexIntervall(::sal_Int32 start, ::sal_Int32 end) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::sal_Int32 > SAL_CALL getSelection() throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL isCellEditable() throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL isSelectionEmpty() throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL isSelectedIndex(::sal_Int32 index) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL selectRow(::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL selectColumn(::sal_Int32 x) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addSelectionListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridSelectionListener > & listener) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeSelectionListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridSelectionListener > & listener) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int32 SAL_CALL getItemIndexAtPoint(::sal_Int32 x, ::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException); + + void SAL_CALL setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value ) throw(::com::sun::star::uno::RuntimeException); + ::com::sun::star::uno::Any SAL_CALL getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException); + static void ImplGetPropertyIds( std::list< sal_uInt16 > &aIds ); + void SAL_CALL setVisible(sal_Bool bVisible) throw(::com::sun::star::uno::RuntimeException); + void SAL_CALL setFocus() throw(::com::sun::star::uno::RuntimeException); + }; + #endif // _SVT_GRIDCONTROL_HXX_ diff --git a/svtools/source/uno/unocontroltablemodel.cxx b/svtools/source/uno/unocontroltablemodel.cxx index e322dbb8f96e..b4ddc2cc472d 100644 --- a/svtools/source/uno/unocontroltablemodel.cxx +++ b/svtools/source/uno/unocontroltablemodel.cxx @@ -47,38 +47,6 @@ using namespace ::svt::table; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::awt::grid; -using namespace ::svt::table; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::view; -using namespace ::toolkit; - -class UnoControlTableColumn : public IColumnModel - { - private: - ColumnID m_nID; - String m_sName; - bool m_bIsResizable; - TableMetrics m_nWidth; - TableMetrics m_nMinWidth; - TableMetrics m_nMaxWidth; - - public: - UnoControlTableColumn(Reference<XGridColumn>); - - // IColumnModel overridables - virtual ColumnID getID() const; - virtual bool setID( const ColumnID _nID ); - virtual String getName() const; - virtual void setName( const String& _rName ); - virtual bool isResizable() const; - virtual void setResizable( bool _bResizable ); - virtual TableMetrics getWidth() const; - virtual void setWidth( TableMetrics _nWidth ); - virtual TableMetrics getMinWidth() const; - virtual void setMinWidth( TableMetrics _nMinWidth ); - virtual TableMetrics getMaxWidth() const; - virtual void setMaxWidth( TableMetrics _nMaxWidth ); - }; //-------------------------------------------------------------------- UnoControlTableColumn::UnoControlTableColumn(Reference<XGridColumn> m_xGridColumn) @@ -181,7 +149,7 @@ class UnoControlTableColumn : public IColumnModel //==================================================================== struct UnoControlTableModel_Impl { - ::std::vector< PColumnModel > aColumns; + ::std::vector< PColumnModel >& aColumns; TableSize nRowCount; bool bHasColumnHeaders; bool bHasRowHeaders; @@ -190,11 +158,12 @@ class UnoControlTableColumn : public IColumnModel TableMetrics nRowHeight; TableMetrics nColumnHeaderHeight; TableMetrics nRowHeaderWidth; - std::vector<rtl::OUString> aRowHeadersTitle; - std::vector<std::vector<rtl::OUString> > aCellContent; + std::vector<rtl::OUString>& aRowHeadersTitle; + std::vector<std::vector<rtl::OUString> >& aCellContent; UnoControlTableModel_Impl() - :nRowCount ( 0 ) + :aColumns ( *(new std::vector< PColumnModel> (0))) + ,nRowCount ( 0 ) ,bHasColumnHeaders ( false ) ,bHasRowHeaders ( false ) ,pRenderer ( ) @@ -202,8 +171,8 @@ class UnoControlTableColumn : public IColumnModel ,nRowHeight ( 4 * 100 ) // 40 mm ,nColumnHeaderHeight( 5 * 100 ) // 50 mm ,nRowHeaderWidth ( 10 * 100 ) // 50 mm - ,aRowHeadersTitle ( 0 ) - ,aCellContent ( 0 ) + ,aRowHeadersTitle ( *(new std::vector<rtl::OUString>(0))) + ,aCellContent ( *(new std::vector<std::vector<OUString> >(0))) { } }; @@ -213,16 +182,10 @@ class UnoControlTableColumn : public IColumnModel //==================================================================== //-------------------------------------------------------------------- UnoControlTableModel::UnoControlTableModel() - :m_pImpl( new UnoControlTableModel_Impl ), - m_xDataModel(0), - m_xColumnModel(0), - m_bHasColumnHeaders(false), - m_bHasRowHeaders(false), - m_bVScroll(false), - m_bHScroll(false) - { - m_pImpl->bHasColumnHeaders = m_bHasColumnHeaders; - m_pImpl->bHasRowHeaders = m_bHasRowHeaders; + :m_pImpl( new UnoControlTableModel_Impl ) + { + m_pImpl->bHasColumnHeaders = false; + m_pImpl->bHasRowHeaders = false; m_pImpl->pRenderer.reset( new GridTableRenderer( *this ) ); m_pImpl->pInputHandler.reset( new DefaultInputHandler ); } @@ -236,7 +199,7 @@ class UnoControlTableColumn : public IColumnModel //-------------------------------------------------------------------- TableSize UnoControlTableModel::getColumnCount() const { - m_pImpl->aColumns.resize( m_xColumnModel->getColumnCount()); + //m_pImpl->aColumns.resize( m_xColumnModel->getColumnCount()); return (TableSize)m_pImpl->aColumns.size(); } @@ -312,6 +275,11 @@ class UnoControlTableColumn : public IColumnModel } //-------------------------------------------------------------------- + std::vector<PColumnModel>& UnoControlTableModel::getColumnModel() + { + return m_pImpl->aColumns; + } + //-------------------------------------------------------------------- PColumnModel UnoControlTableModel::getColumnModelByID( ColumnID id ) { (void)id; @@ -376,7 +344,7 @@ class UnoControlTableColumn : public IColumnModel //-------------------------------------------------------------------- ScrollbarVisibility UnoControlTableModel::getVerticalScrollbarVisibility(int overAllHeight, int actHeight) const { - if(overAllHeight>=actHeight && !m_bVScroll) + if(overAllHeight>=actHeight)// && !m_bVScroll) return ScrollbarShowNever; else return ScrollbarShowAlways; @@ -385,7 +353,7 @@ class UnoControlTableColumn : public IColumnModel //-------------------------------------------------------------------- ScrollbarVisibility UnoControlTableModel::getHorizontalScrollbarVisibility(int overAllWidth, int actWidth) const { - if(overAllWidth>=actWidth && !m_bHScroll) + if(overAllWidth>=actWidth)// && !m_bHScroll) return ScrollbarShowNever; else return ScrollbarShowAlways; @@ -393,25 +361,26 @@ class UnoControlTableColumn : public IColumnModel //-------------------------------------------------------------------- void UnoControlTableModel::setCellContent(std::vector<std::vector<rtl::OUString> > cellContent) { - if(cellContent.empty()) - { - unsigned int i = m_pImpl->aColumns.size(); - std::vector<rtl::OUString> emptyCells; - while(i!=0) - { - cellContent.push_back(emptyCells); - --i; - } - } - std::vector<rtl::OUString> cCC; - for(::std::vector<std::vector<rtl::OUString> >::iterator iter = cellContent.begin(); iter!= cellContent.end();++iter) - { - cCC = *iter; - m_pImpl->aCellContent.push_back(cCC); - } - } - - std::vector<std::vector<rtl::OUString> > UnoControlTableModel::getCellContent() + //if(cellContent.empty()) + //{ + // unsigned int i = m_pImpl->aColumns.size(); + // std::vector<rtl::OUString>& emptyCells; + // while(i!=0) + // { + // cellContent.push_back(emptyCells); + // --i; + // } + //} + //std::vector<rtl::OUString> cCC; + //for(::std::vector<std::vector<rtl::OUString> >::iterator iter = cellContent.begin(); iter!= cellContent.end();++iter) + //{ + // cCC = *iter; + // m_pImpl->aCellContent.push_back(cCC); + //} + m_pImpl->aCellContent.swap( cellContent ); + } + + std::vector<std::vector<rtl::OUString> >& UnoControlTableModel::getCellContent() { return m_pImpl->aCellContent; } @@ -435,378 +404,8 @@ class UnoControlTableColumn : public IColumnModel } } - std::vector<rtl::OUString> UnoControlTableModel::getRowHeaderName() + std::vector<rtl::OUString>& UnoControlTableModel::getRowHeaderName() { return m_pImpl->aRowHeadersTitle; } -::com::sun::star::uno::Any UnoControlTableModel::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) -{ - ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType, - SAL_STATIC_CAST( ::com::sun::star::awt::grid::XGridControl*, this ), - SAL_STATIC_CAST( ::com::sun::star::awt::grid::XGridDataListener*, this ), - //SAL_STATIC_CAST( com::sun::star::lang::XEventListener*, this ), - //SAL_STATIC_CAST( com::sun::star::awt::XMouseListener*, this ), - SAL_STATIC_CAST( ::com::sun::star::lang::XTypeProvider*, this ) ); - return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType )); -} - -// ::com::sun::star::lang::XTypeProvider -IMPL_XTYPEPROVIDER_START( UnoControlTableModel ) - getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridControl>* ) NULL ), - getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridDataModel>* ) NULL ), - getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseListener>* ) NULL ), - VCLXWindow::getTypes() -IMPL_XTYPEPROVIDER_END - -::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumnModel > SAL_CALL UnoControlTableModel::getColumnModel( ) throw (::com::sun::star::uno::RuntimeException) -{ - return NULL; -} -void SAL_CALL UnoControlTableModel::setColumnModel( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumnModel >& model ) throw (::com::sun::star::uno::RuntimeException) -{ - (void)model; -} -::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridDataModel > SAL_CALL UnoControlTableModel::getDataModel( ) throw (::com::sun::star::uno::RuntimeException) -{ - return NULL; -} -void SAL_CALL UnoControlTableModel::setDataModel( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridDataModel >& model ) throw (::com::sun::star::uno::RuntimeException) -{ - (void)model; -} -sal_Int32 SAL_CALL UnoControlTableModel::getItemIndexAtPoint(::sal_Int32 x, ::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException) -{ - TableControl* pTableControl = (TableControl*)GetWindow(); - return pTableControl->GetCurrentRow( Point(x,y) ); -} - -/* -void SAL_CALL UnoControlTableModel::addMouseListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseListener > & listener ) throw(::com::sun::star::uno::RuntimeException) -{ - VCLXWindow::addMouseListener( listener ); -} - -void SAL_CALL UnoControlTableModel::removeMouseListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseListener > & listener ) throw(::com::sun::star::uno::RuntimeException) -{ - VCLXWindow::removeMouseListener( listener ); -} -*/ -/* -void SAL_CALL UnoControlTableModel::mousePressed( const ::com::sun::star::awt::MouseEvent& rEvent ) throw(::com::sun::star::uno::RuntimeException) -{ - (void)rEvent; -} -void SAL_CALL UnoControlTableModel::mouseReleased( const ::com::sun::star::awt::MouseEvent& rEvent ) throw(::com::sun::star::uno::RuntimeException) -{ - (void)rEvent; -} -void SAL_CALL UnoControlTableModel::mouseEntered( const ::com::sun::star::awt::MouseEvent& rEvent ) throw(::com::sun::star::uno::RuntimeException) -{ - (void) rEvent; -} -void SAL_CALL UnoControlTableModel::mouseExited( const ::com::sun::star::awt::MouseEvent& rEvent ) throw(::com::sun::star::uno::RuntimeException) -{ - (void) rEvent; -} -*/ -void SAL_CALL UnoControlTableModel::addSelectionListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridSelectionListener > & listener) throw (::com::sun::star::uno::RuntimeException) -{ - (void)listener; -} - -void SAL_CALL UnoControlTableModel::removeSelectionListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridSelectionListener > & listener) throw (::com::sun::star::uno::RuntimeException) -{ - (void) listener; -} - -void UnoControlTableModel::setProperty( const ::rtl::OUString& PropertyName, const Any& aValue) throw(RuntimeException) -{ - ::vos::OGuard aGuard( GetMutex() ); - - TableControl* pTableControl = (TableControl*)GetWindow(); - - switch( GetPropertyId( PropertyName ) ) - { - case BASEPROPERTY_GRID_SELECTIONMODE: - { - SelectionType eSelectionType; - if( aValue >>= eSelectionType ) - { - SelectionMode eSelMode; - switch( eSelectionType ) - { - case SelectionType_SINGLE: eSelMode = SINGLE_SELECTION; break; - case SelectionType_RANGE: eSelMode = RANGE_SELECTION; break; - case SelectionType_MULTI: eSelMode = MULTIPLE_SELECTION; break; - // case SelectionType_NONE: - default: eSelMode = NO_SELECTION; break; - } - if( pTableControl->getSelEngine()->GetSelectionMode() != eSelMode ) - pTableControl->getSelEngine()->SetSelectionMode( eSelMode ); - } - break; - } - case BASEPROPERTY_HSCROLL: - { - sal_Bool bHScroll = true; - if( aValue >>= bHScroll ) - { - m_bHScroll = bHScroll; - } - break; - } - case BASEPROPERTY_VSCROLL: - { - sal_Bool bVScroll = true; - if( aValue >>= bVScroll ) - { - m_bVScroll = bVScroll; - } - break; - } - case BASEPROPERTY_GRID_SHOWROWHEADER: - { - sal_Bool rowHeader = true; - if( aValue >>= rowHeader ) - { - setRowHeaders(rowHeader); - } - break; - } - - case BASEPROPERTY_GRID_SHOWCOLUMNHEADER: - { - sal_Bool colHeader = true; - if( aValue >>= colHeader ) - { - setColumnHeaders(colHeader); - } - break; - } - case BASEPROPERTY_GRID_DATAMODEL: - { - m_xDataModel = Reference< XGridDataModel >( aValue, UNO_QUERY ); - Sequence<Sequence< ::rtl::OUString > > cellData = m_xDataModel->getData(); - Sequence<rtl::OUString> rowData(0); - for(int i = 0; i< m_xDataModel->getRowCount();++i) - { - rowData = cellData[i]; - std::vector<rtl::OUString> newRow( - comphelper::sequenceToContainer< std::vector<rtl::OUString > >(rowData)); - if(newRow.size()<m_pImpl->aColumns.size()) - newRow.resize(m_pImpl->aColumns.size(),rtl::OUString::createFromAscii("")); - m_pImpl->aCellContent.push_back(newRow); - } - Sequence< ::rtl::OUString > rowHeaders = m_xDataModel->getRowHeaders(); - std::vector< rtl::OUString > newRow( - comphelper::sequenceToContainer< std::vector<rtl::OUString > >(rowHeaders)); - m_pImpl->nRowCount = m_xDataModel->getRowCount(); - setRowHeaderName(newRow); - break; - } - case BASEPROPERTY_GRID_COLUMNMODEL: - { - m_xColumnModel = Reference< XGridColumnModel >( aValue, UNO_QUERY ); - Sequence<Reference< XGridColumn > > columns = m_xColumnModel->getColumns(); - std::vector<Reference< XGridColumn > > aNewColumns( - comphelper::sequenceToContainer<std::vector<Reference< XGridColumn > > >(columns)); - if(!m_pImpl->aColumns.empty()) - m_pImpl->aColumns.clear(); - for ( ::svt::table::ColPos col = 0; col < m_xColumnModel->getColumnCount(); ++col ) - { - UnoControlTableColumn* tableColumn = new UnoControlTableColumn(aNewColumns[col]); - m_pImpl->aColumns.push_back((PColumnModel)tableColumn); - } - break; - } - default: - VCLXWindow::setProperty( PropertyName, aValue ); - break; - } -} - -Any UnoControlTableModel::getProperty( const ::rtl::OUString& PropertyName ) throw(RuntimeException) -{ - ::vos::OGuard aGuard( GetMutex() ); - - const sal_uInt16 nPropId = GetPropertyId( PropertyName ); - TableControl* pTableControl = (TableControl*)GetWindow(); - if(pTableControl) - { - switch(nPropId) - { - case BASEPROPERTY_GRID_SELECTIONMODE: - { - SelectionType eSelectionType; - - SelectionMode eSelMode = pTableControl->getSelEngine()->GetSelectionMode(); - switch( eSelMode ) - { - case SINGLE_SELECTION: eSelectionType = SelectionType_SINGLE; break; - case RANGE_SELECTION: eSelectionType = SelectionType_RANGE; break; - case MULTIPLE_SELECTION:eSelectionType = SelectionType_MULTI; break; -// case NO_SELECTION: - default: eSelectionType = SelectionType_NONE; break; - } - return Any( eSelectionType ); - } - case BASEPROPERTY_GRID_SHOWROWHEADER: - { - return Any ((sal_Bool) pTableControl->GetModel()->hasRowHeaders()); - } - case BASEPROPERTY_GRID_SHOWCOLUMNHEADER: - return Any ((sal_Bool) pTableControl->GetModel()->hasColumnHeaders()); - case BASEPROPERTY_GRID_DATAMODEL: - return Any ( m_xDataModel ); - case BASEPROPERTY_GRID_COLUMNMODEL: - return Any ( m_xColumnModel); - case BASEPROPERTY_HSCROLL: - return Any ( m_bHScroll); - case BASEPROPERTY_VSCROLL: - return Any ( m_bVScroll); - } - } - return VCLXWindow::getProperty( PropertyName ); -} - -void UnoControlTableModel::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) -{ - PushPropertyIds( rIds, - BASEPROPERTY_GRID_SHOWROWHEADER, - BASEPROPERTY_GRID_SHOWCOLUMNHEADER, - BASEPROPERTY_GRID_DATAMODEL, - BASEPROPERTY_GRID_COLUMNMODEL, - BASEPROPERTY_GRID_SELECTIONMODE, - 0); - VCLXWindow::ImplGetPropertyIds( rIds, true ); -} -void SAL_CALL UnoControlTableModel::setVisible( sal_Bool bVisible ) throw(::com::sun::star::uno::RuntimeException) -{ - TableControl* pTable = (TableControl*)GetWindow(); - if ( pTable ) - { - pTable->SetModel(PTableModel(this)); - pTable->Show( bVisible ); - } -} -void SAL_CALL UnoControlTableModel::setFocus() throw(::com::sun::star::uno::RuntimeException) -{ - ::vos::OGuard aGuard( GetMutex() ); - if ( GetWindow()) - GetWindow()->GrabFocus(); -} -void SAL_CALL UnoControlTableModel::rowAdded(const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException) -{ - std::vector<OUString> aNewRow( - comphelper::sequenceToContainer< std::vector<rtl::OUString > >(Event.rowData)); - if(aNewRow.size()<m_pImpl->aColumns.size()) - aNewRow.resize(m_pImpl->aColumns.size(),rtl::OUString::createFromAscii("")); - m_pImpl->aCellContent.push_back(aNewRow); - if(hasRowHeaders()) - m_pImpl->aRowHeadersTitle.push_back(Event.headerName); - m_pImpl->nRowCount=m_pImpl->aCellContent.size(); - TableControl* pTable = (TableControl*)GetWindow(); - pTable->InvalidateDataWindow(m_pImpl->nRowCount-1, false); - //pTable->GrabFocus(); -} - -void SAL_CALL UnoControlTableModel::rowRemoved(const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException) -{ - TableControl* pTable = (TableControl*)GetWindow(); - //unsigned int rows =m_pImpl->aCellContent.size()-1; - if(Event.index == -1) - { - if(hasRowHeaders()) - m_pImpl->aRowHeadersTitle.clear(); - m_pImpl->aCellContent.clear(); - } - else - { - pTable->removeSelectedRow(Event.index); - if(m_pImpl->aCellContent.size()>1) - { - if(hasRowHeaders()) - m_pImpl->aRowHeadersTitle.erase(m_pImpl->aRowHeadersTitle.begin()+Event.index); - m_pImpl->aCellContent.erase(m_pImpl->aCellContent.begin()+Event.index); - - } - else - { - if(hasRowHeaders()) - m_pImpl->aRowHeadersTitle.clear(); - m_pImpl->aCellContent.clear(); - //m_pImpl->nRowCount=0; - } - } - //pTable->InvalidateDataWindow(Event.index, true); - setRowCount(m_pImpl->aCellContent.size()); - pTable->InvalidateDataWindow(Event.index, true); - //pTable->Invalidate(); -} - -void SAL_CALL UnoControlTableModel::dataChanged(const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException) -{ - (void) Event; -} - - void SAL_CALL UnoControlTableModel::disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException) - { - VCLXWindow::disposing( Source ); - } - -::sal_Int32 SAL_CALL UnoControlTableModel::getMinSelectionIndex() throw (::com::sun::star::uno::RuntimeException) -{ - return 0; -} - -::sal_Int32 SAL_CALL UnoControlTableModel::getMaxSelectionIndex() throw (::com::sun::star::uno::RuntimeException) -{ - return 0; -} - -void SAL_CALL UnoControlTableModel::insertIndexIntervall(::sal_Int32 start, ::sal_Int32 length) throw (::com::sun::star::uno::RuntimeException) -{ - (void)length; - (void)start; -} - -void SAL_CALL UnoControlTableModel::removeIndexIntervall(::sal_Int32 start, ::sal_Int32 end) throw (::com::sun::star::uno::RuntimeException) -{ - (void)end; - (void)start; -} - -::com::sun::star::uno::Sequence< ::sal_Int32 > SAL_CALL UnoControlTableModel::getSelection() throw (::com::sun::star::uno::RuntimeException) -{ - TableControl* pTable = (TableControl*)GetWindow(); - std::vector<RowPos> selectedRows = pTable->getSelectedRows(); - Sequence<sal_Int32> selectedRowsToSequence(comphelper::containerToSequence(selectedRows)); - return selectedRowsToSequence; -} - -::sal_Bool SAL_CALL UnoControlTableModel::isCellEditable() throw (::com::sun::star::uno::RuntimeException) -{ - return sal_False; -} - -::sal_Bool SAL_CALL UnoControlTableModel::isSelectionEmpty() throw (::com::sun::star::uno::RuntimeException) -{ - return sal_False; -} - -::sal_Bool SAL_CALL UnoControlTableModel::isSelectedIndex(::sal_Int32 index) throw (::com::sun::star::uno::RuntimeException) -{ - (void)index; - return sal_False; -} - -void SAL_CALL UnoControlTableModel::selectRow(::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException) -{ - (void)y; -} - -void SAL_CALL UnoControlTableModel::selectColumn(::sal_Int32 x) throw (::com::sun::star::uno::RuntimeException) -{ - (void)x; -} diff --git a/svtools/source/uno/unocontroltablemodel.hxx b/svtools/source/uno/unocontroltablemodel.hxx index 5da9cc871756..fe3d1f28e9ed 100644 --- a/svtools/source/uno/unocontroltablemodel.hxx +++ b/svtools/source/uno/unocontroltablemodel.hxx @@ -43,25 +43,48 @@ #include <toolkit/awt/vclxwindows.hxx> #include <cppuhelper/typeprovider.hxx> #include <cppuhelper/implbase2.hxx> +#include <com/sun/star/awt/grid/XGridColumn.hpp> //#include <toolkit/helper/listenermultiplexer.hxx> using namespace ::svt::table; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::awt::grid; + +class UnoControlTableColumn : public IColumnModel + { + private: + ColumnID m_nID; + String m_sName; + bool m_bIsResizable; + TableMetrics m_nWidth; + TableMetrics m_nMinWidth; + TableMetrics m_nMaxWidth; + + public: + UnoControlTableColumn(Reference<XGridColumn>); + + // IColumnModel overridables + virtual ColumnID getID() const; + virtual bool setID( const ColumnID _nID ); + virtual String getName() const; + virtual void setName( const String& _rName ); + virtual bool isResizable() const; + virtual void setResizable( bool _bResizable ); + virtual TableMetrics getWidth() const; + virtual void setWidth( TableMetrics _nWidth ); + virtual TableMetrics getMinWidth() const; + virtual void setMinWidth( TableMetrics _nMinWidth ); + virtual TableMetrics getMaxWidth() const; + virtual void setMaxWidth( TableMetrics _nMaxWidth ); + }; struct UnoControlTableModel_Impl; - class UnoControlTableModel : public ITableModel, public ::cppu::ImplInheritanceHelper2< VCLXWindow, ::com::sun::star::awt::grid::XGridControl, - ::com::sun::star::awt::grid::XGridDataListener> + class UnoControlTableModel : public ITableModel { private: UnoControlTableModel_Impl* m_pImpl; - ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridDataModel >m_xDataModel; - ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumnModel >m_xColumnModel; - bool m_bHasColumnHeaders; - bool m_bHasRowHeaders; - bool m_bVScroll; - bool m_bHScroll; - //MouseListenerMultiplexer m_aMouseListeners; public: UnoControlTableModel(); @@ -103,6 +126,7 @@ using namespace ::svt::table; virtual void addTableModelListener( const PTableModelListener& listener ); virtual void removeTableModelListener( const PTableModelListener& listener ); virtual PColumnModel getColumnModel( ColPos column ); + virtual std::vector<PColumnModel>& getColumnModel(); virtual PColumnModel getColumnModelByID( ColumnID id ); virtual PTableRenderer getRenderer() const; virtual PTableInputHandler getInputHandler() const; @@ -112,59 +136,9 @@ using namespace ::svt::table; virtual ScrollbarVisibility getVerticalScrollbarVisibility(int overAllHeight, int actHeight) const; virtual ScrollbarVisibility getHorizontalScrollbarVisibility(int overAllWidth, int actWidth) const; virtual void setCellContent(std::vector<std::vector<rtl::OUString> > cellContent); - virtual std::vector<std::vector<rtl::OUString> > getCellContent(); + virtual std::vector<std::vector<rtl::OUString> >& getCellContent(); virtual void setRowHeaderName(std::vector<rtl::OUString> cellColumnContent); - virtual std::vector<rtl::OUString> getRowHeaderName(); - - //XGridDataListener overridables - virtual void SAL_CALL rowAdded(const ::com::sun::star::awt::grid::GridDataEvent& Event) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL rowRemoved(const ::com::sun::star::awt::grid::GridDataEvent & Event) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL dataChanged(const ::com::sun::star::awt::grid::GridDataEvent & Event) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException); - - ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); - void SAL_CALL acquire() throw() { VCLXWindow::acquire(); } - void SAL_CALL release() throw() { VCLXWindow::release(); } - - // ::com::sun::star::lang::XTypeProvider - ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw(::com::sun::star::uno::RuntimeException); - ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw(::com::sun::star::uno::RuntimeException); - - //::com::sun::star::awt::grid::XGridControl - ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumnModel > SAL_CALL getColumnModel( ) throw (::com::sun::star::uno::RuntimeException); - void SAL_CALL setColumnModel( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumnModel >& model ) throw (::com::sun::star::uno::RuntimeException); - ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridDataModel > SAL_CALL getDataModel( ) throw (::com::sun::star::uno::RuntimeException); - void SAL_CALL setDataModel( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridDataModel >& model ) throw (::com::sun::star::uno::RuntimeException); - - virtual ::sal_Int32 SAL_CALL getMinSelectionIndex() throw (::com::sun::star::uno::RuntimeException); - virtual ::sal_Int32 SAL_CALL getMaxSelectionIndex() throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL insertIndexIntervall(::sal_Int32 start, ::sal_Int32 length) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removeIndexIntervall(::sal_Int32 start, ::sal_Int32 end) throw (::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::sal_Int32 > SAL_CALL getSelection() throw (::com::sun::star::uno::RuntimeException); - virtual ::sal_Bool SAL_CALL isCellEditable() throw (::com::sun::star::uno::RuntimeException); - virtual ::sal_Bool SAL_CALL isSelectionEmpty() throw (::com::sun::star::uno::RuntimeException); - virtual ::sal_Bool SAL_CALL isSelectedIndex(::sal_Int32 index) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL selectRow(::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL selectColumn(::sal_Int32 x) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addSelectionListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridSelectionListener > & listener) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removeSelectionListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridSelectionListener > & listener) throw (::com::sun::star::uno::RuntimeException); - virtual ::sal_Int32 SAL_CALL getItemIndexAtPoint(::sal_Int32 x, ::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException); - - //void SAL_CALL addMouseListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseListener > & listener ) throw(::com::sun::star::uno::RuntimeException); - //void SAL_CALL removeMouseListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseListener > & listener ) throw(::com::sun::star::uno::RuntimeException); - //::com::sun::star::awt::XMouseListener - /* - virtual void SAL_CALL mousePressed( const ::com::sun::star::awt::MouseEvent& rEvent ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL mouseReleased( const ::com::sun::star::awt::MouseEvent& rEvent ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL mouseEntered( const ::com::sun::star::awt::MouseEvent& rEvent ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL mouseExited( const ::com::sun::star::awt::MouseEvent& rEvent ) throw(::com::sun::star::uno::RuntimeException); - */ - - void SAL_CALL setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value ) throw(::com::sun::star::uno::RuntimeException); - ::com::sun::star::uno::Any SAL_CALL getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException); - static void ImplGetPropertyIds( std::list< sal_uInt16 > &aIds ); - void SAL_CALL setVisible(sal_Bool bVisible) throw(::com::sun::star::uno::RuntimeException); - void SAL_CALL setFocus() throw(::com::sun::star::uno::RuntimeException); + virtual std::vector<rtl::OUString>& getRowHeaderName(); }; inline void UnoControlTableModel::SetColumnWidth( ColPos _nColumn, TableMetrics _nWidth100thMM ) diff --git a/svtools/source/uno/unoiface.cxx b/svtools/source/uno/unoiface.cxx index 711abe1b6617..a1ff1ad2ac3e 100644 --- a/svtools/source/uno/unoiface.cxx +++ b/svtools/source/uno/unoiface.cxx @@ -54,8 +54,7 @@ #include <svtools/svtreebx.hxx> #include "treecontrolpeer.hxx" -//#include "vclxgridcontrol.hxx" -#include "unocontroltablemodel.hxx" +#include "svtxgridcontrol.hxx" #include <svtools/table/tablecontrol.hxx> namespace @@ -172,10 +171,8 @@ SAL_DLLPUBLIC_EXPORT Window* CreateWindow( VCLXWindow** ppNewComp, const ::com:: { if ( pParent ) { - ::svt::table::TableControl* m_pTable = new ::svt::table::TableControl(pParent, nWinBits); - UnoControlTableModel* pModel = new UnoControlTableModel(); - *ppNewComp = pModel; - pWindow = m_pTable; + pWindow = new ::svt::table::TableControl(pParent, nWinBits); + *ppNewComp = new SVTXGridControl; } else { |