summaryrefslogtreecommitdiff
path: root/svtools
diff options
context:
space:
mode:
Diffstat (limited to 'svtools')
-rw-r--r--svtools/Library_svt.mk3
-rw-r--r--svtools/Package_inc.mk4
-rwxr-xr-xsvtools/inc/svtools/accessiblefactory.hxx15
-rw-r--r--svtools/inc/svtools/accessibletable.hxx10
-rw-r--r--svtools/inc/svtools/svtools.hrc9
-rw-r--r--svtools/inc/svtools/table/abstracttablecontrol.hxx134
-rw-r--r--svtools/inc/svtools/table/defaultinputhandler.hxx41
-rw-r--r--svtools/inc/svtools/table/gridtablerenderer.hxx50
-rw-r--r--svtools/inc/svtools/table/tablecontrol.hxx165
-rw-r--r--svtools/inc/svtools/table/tablecontrolinterface.hxx254
-rw-r--r--svtools/inc/svtools/table/tableinputhandler.hxx22
-rwxr-xr-x[-rw-r--r--]svtools/inc/svtools/table/tablemodel.hxx331
-rw-r--r--svtools/inc/svtools/table/tablerenderer.hxx79
-rwxr-xr-xsvtools/inc/svtools/table/tablesort.hxx91
-rw-r--r--svtools/inc/svtools/table/tabletypes.hxx7
-rw-r--r--svtools/prj/build.lst2
-rw-r--r--svtools/qa/unoapi/makefile.mk48
-rw-r--r--svtools/source/brwbox/datwin.cxx9
-rw-r--r--svtools/source/contnr/svcontnr.src27
-rw-r--r--svtools/source/contnr/svlbox.cxx1
-rwxr-xr-x[-rw-r--r--]svtools/source/control/filectrl.src40
-rwxr-xr-xsvtools/source/control/ruler.cxx1
-rwxr-xr-xsvtools/source/control/tabbar.cxx13
-rw-r--r--svtools/source/control/toolbarmenuacc.cxx2
-rw-r--r--svtools/source/control/valueacc.cxx2
-rw-r--r--svtools/source/dialogs/colrdlg.hrc2
-rw-r--r--svtools/source/dialogs/colrdlg.src38
-rw-r--r--svtools/source/filter/FilterConfigItem.cxx4
-rw-r--r--svtools/source/inc/filectrl.hrc7
-rw-r--r--svtools/source/misc/langtab.src8
-rwxr-xr-xsvtools/source/table/cellvalueconversion.cxx77
-rwxr-xr-x[-rw-r--r--]svtools/source/table/cellvalueconversion.hxx (renamed from svtools/source/inc/accessibletableimp.hxx)48
-rw-r--r--svtools/source/table/defaultinputhandler.cxx197
-rw-r--r--svtools/source/table/gridtablerenderer.cxx663
-rwxr-xr-xsvtools/source/table/mousefunction.cxx320
-rwxr-xr-xsvtools/source/table/mousefunction.hxx161
-rw-r--r--svtools/source/table/tablecontrol.cxx788
-rwxr-xr-x[-rw-r--r--]svtools/source/table/tablecontrol_impl.cxx2601
-rwxr-xr-x[-rw-r--r--]svtools/source/table/tablecontrol_impl.hxx315
-rw-r--r--svtools/source/table/tabledatawindow.cxx199
-rw-r--r--svtools/source/table/tabledatawindow.hxx (renamed from svtools/inc/svtools/table/tabledatawindow.hxx)11
-rw-r--r--svtools/source/table/tablegeometry.cxx132
-rw-r--r--svtools/source/table/tablegeometry.hxx44
-rw-r--r--[-rwxr-xr-x]svtools/source/uno/svtxgridcontrol.cxx1045
-rwxr-xr-xsvtools/source/uno/svtxgridcontrol.hxx88
-rw-r--r--svtools/source/uno/treecontrolpeer.cxx4
-rw-r--r--svtools/source/uno/unocontroltablemodel.cxx980
-rw-r--r--svtools/source/uno/unocontroltablemodel.hxx240
-rwxr-xr-xsvtools/source/uno/unogridcolumnfacade.cxx427
-rwxr-xr-xsvtools/source/uno/unogridcolumnfacade.hxx114
-rw-r--r--svtools/source/uno/unoiface.cxx1
51 files changed, 6168 insertions, 3706 deletions
diff --git a/svtools/Library_svt.mk b/svtools/Library_svt.mk
index dd668caf5302..39b135f16b1e 100644
--- a/svtools/Library_svt.mk
+++ b/svtools/Library_svt.mk
@@ -250,6 +250,8 @@ $(eval $(call gb_Library_add_exception_objects,svt,\
svtools/source/table/tablecontrol \
svtools/source/table/tablecontrol_impl \
svtools/source/table/tabledatawindow \
+ svtools/source/table/mousefunction \
+ svtools/source/table/cellvalueconversion \
svtools/source/table/tablegeometry \
svtools/source/toolpanel/drawerlayouter \
svtools/source/toolpanel/dummypanel \
@@ -278,6 +280,7 @@ $(eval $(call gb_Library_add_exception_objects,svt,\
svtools/source/uno/toolboxcontroller \
svtools/source/uno/treecontrolpeer \
svtools/source/uno/unocontroltablemodel \
+ svtools/source/uno/unogridcolumnfacade \
svtools/source/uno/unoevent \
svtools/source/uno/unoiface \
svtools/source/uno/unoimap \
diff --git a/svtools/Package_inc.mk b/svtools/Package_inc.mk
index 6cc92a14c823..4162e8f53fea 100644
--- a/svtools/Package_inc.mk
+++ b/svtools/Package_inc.mk
@@ -145,15 +145,15 @@ $(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/svxbox.hxx,svtools/svx
$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/sychconv.hxx,svtools/sychconv.hxx))
$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/syntaxhighlight.hxx,svtools/syntaxhighlight.hxx))
$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/tabbar.hxx,svtools/tabbar.hxx))
-$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/table/abstracttablecontrol.hxx,svtools/table/abstracttablecontrol.hxx))
+$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/table/tablecontrolinterface.hxx,svtools/table/tablecontrolinterface.hxx))
$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/table/defaultinputhandler.hxx,svtools/table/defaultinputhandler.hxx))
$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/table/gridtablerenderer.hxx,svtools/table/gridtablerenderer.hxx))
$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/table/tablecontrol.hxx,svtools/table/tablecontrol.hxx))
-$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/table/tabledatawindow.hxx,svtools/table/tabledatawindow.hxx))
$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/table/tableinputhandler.hxx,svtools/table/tableinputhandler.hxx))
$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/table/tablemodel.hxx,svtools/table/tablemodel.hxx))
$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/table/tablerenderer.hxx,svtools/table/tablerenderer.hxx))
$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/table/tabletypes.hxx,svtools/table/tabletypes.hxx))
+$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/table/tablesort.hxx,svtools/table/tablesort.hxx))
$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/taskbar.hxx,svtools/taskbar.hxx))
$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/templatefoldercache.hxx,svtools/templatefoldercache.hxx))
$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/templdlg.hxx,svtools/templdlg.hxx))
diff --git a/svtools/inc/svtools/accessiblefactory.hxx b/svtools/inc/svtools/accessiblefactory.hxx
index 9606e93a2fa0..372af4fdca25 100755
--- a/svtools/inc/svtools/accessiblefactory.hxx
+++ b/svtools/inc/svtools/accessiblefactory.hxx
@@ -28,16 +28,12 @@
#ifndef SVTOOLS_ACCESSIBLE_FACTORY_HXX
#define SVTOOLS_ACCESSIBLE_FACTORY_HXX
-#ifndef _COM_SUN_STAR_UNO_REFERENCE_HXX
+#include "AccessibleBrowseBoxObjType.hxx"
+#include "accessibletableprovider.hxx"
+
#include <com/sun/star/uno/Reference.hxx>
-#endif
-#ifndef _RTL_REF_HXX
#include <rtl/ref.hxx>
-#endif
-#include "AccessibleBrowseBoxObjType.hxx"
-#include "accessibletableprovider.hxx"
-#include "accessibletable.hxx"
namespace com { namespace sun { namespace star {
namespace accessibility {
@@ -64,6 +60,11 @@ namespace svt
class ToolPanelDeck;
class IToolPanelDeck;
class PanelTabBar;
+ namespace table
+ {
+ class IAccessibleTable;
+ class IAccessibleTableControl;
+ }
/** a function which is able to create a factory for the standard Accessible/Context
components needed for standard toolkit controls
diff --git a/svtools/inc/svtools/accessibletable.hxx b/svtools/inc/svtools/accessibletable.hxx
index 807760ef9b97..d7bd98481404 100644
--- a/svtools/inc/svtools/accessibletable.hxx
+++ b/svtools/inc/svtools/accessibletable.hxx
@@ -109,8 +109,6 @@ public:
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, sal_Bool _bOnScreen = sal_True ) = 0;
virtual Rectangle calcTableRect( sal_Bool _bOnScreen = sal_True ) = 0;
@@ -122,9 +120,13 @@ public:
virtual ::rtl::OUString GetColumnDescription( sal_uInt16 _nColumnPos ) const = 0;
virtual ::rtl::OUString GetColumnName( sal_Int32 _nIndex ) const = 0;
virtual ::com::sun::star::uno::Any GetCellContent( sal_Int32 _nRowPos, sal_Int32 _nColPos) const = 0;
- virtual std::vector<sal_Int32>& GetSelectedRows() = 0;
- virtual void RemoveSelectedRow(sal_Int32 _nRowPos) = 0;
virtual ::rtl::OUString GetAccessibleCellText(sal_Int32 _nRowPos, sal_Int32 _nColPos) const = 0;
+
+ virtual sal_Int32 GetSelectedRowCount() const = 0;
+ virtual sal_Int32 GetSelectedRowIndex( sal_Int32 const i_selectionIndex ) const = 0;
+ virtual bool IsRowSelected( sal_Int32 const i_rowIndex ) const = 0;
+ virtual void SelectRow( sal_Int32 const i_rowIndex, bool const i_select ) = 0;
+ virtual void SelectAllRows( bool const i_select ) = 0;
};
// ----------------------------------------------------------------------------
diff --git a/svtools/inc/svtools/svtools.hrc b/svtools/inc/svtools/svtools.hrc
index b4bf84532b26..554fc63f5c7c 100644
--- a/svtools/inc/svtools/svtools.hrc
+++ b/svtools/inc/svtools/svtools.hrc
@@ -252,6 +252,10 @@
#define STR_SVT_ACC_DESC_FOLDER (STR_SVT_ACC_BEGIN+4)
#define STR_SVT_ACC_DESC_FILE (STR_SVT_ACC_BEGIN+5)
#define STR_SVT_ACC_EMPTY_FIELD (STR_SVT_ACC_BEGIN+6)
+//IAccessible2 implementation
+#define STR_SVT_ACC_LISTENTRY_SELCTED_STATE (STR_SVT_ACC_BEGIN+7)
+#define STR_SVT_ACC_RULER_VERT_NAME (STR_SVT_ACC_BEGIN+8)
+#define STR_SVT_ACC_RULER_HORZ_NAME (STR_SVT_ACC_BEGIN+9)
#define STR_SVT_ACC_END (STR_SVT_ACC_EMPTY_FIELD)
#define STR_SVT_INDEXENTRY_START (STR_SVT_ACC_END + 1)
@@ -390,6 +394,11 @@
#define RID_IMG_PRNDLG_COLLATE_HC (STR_SVT_PRNDLG_START + 31)
#define RID_IMG_PRNDLG_NOCOLLATE_HC (STR_SVT_PRNDLG_START + 32)
+// IAccessible2 implementation in 2009
+#define STR_PARAGRAPH_START (STR_SVT_PRNDLG_START + 50)
+#define STR_PARAGRAPH (STR_PARAGRAPH_START + 0)
+#define STR_PARAGRAPH_END (STR_PARAGRAPH)
+
#endif // #ifndef _SVTOOLS_HRC
// ******************************************************************* EOF
diff --git a/svtools/inc/svtools/table/abstracttablecontrol.hxx b/svtools/inc/svtools/table/abstracttablecontrol.hxx
deleted file mode 100644
index 9206f20ecbcb..000000000000
--- a/svtools/inc/svtools/table/abstracttablecontrol.hxx
+++ /dev/null
@@ -1,134 +0,0 @@
-/*************************************************************************
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * 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_INC_TABLE_ABSTRACTTABLECONTROL_HXX
-#define SVTOOLS_INC_TABLE_ABSTRACTTABLECONTROL_HXX
-
-#include <sal/types.h>
-#include <vcl/event.hxx>
-#include <vcl/seleng.hxx>
-#include "tabletypes.hxx"
-//........................................................................
-namespace svt { namespace table
-{
-//........................................................................
-
- enum TableControlAction
- {
- /// moves the cursor in the table control one row up, if possible, by keeping the current column
- cursorUp,
- /// moves the cursor in the table control one row down, if possible, by keeping the current column
- cursorDown,
- /// moves the cursor in the table control one column to the left, if possible, by keeping the current row
- cursorLeft,
- /// moves the cursor in the table control one column to the right, if possible, by keeping the current row
- cursorRight,
- /// moves the cursor to the beginning of the current line
- cursorToLineStart,
- /// moves the cursor to the end of the current line
- cursorToLineEnd,
- /// moves the cursor to the first row, keeping the current column
- cursorToFirstLine,
- /// moves the cursor to the last row, keeping the current column
- cursorToLastLine,
- /// moves the cursor one page up, keeping the current column
- cursorPageUp,
- /// moves the cursor one page down, keeping the current column
- cursorPageDown,
- /// moves the cursor to the top-most, left-most cell
- cursorTopLeft,
- /// moves the cursor to the bottom-most, right-most cell
- cursorBottomRight,
- /// selects the row, where the actual cursor is
- cursorSelectRow,
- /// selects the rows, above the actual cursor is
- cursorSelectRowUp,
- /// selects the row, beneath the actual cursor is
- cursorSelectRowDown,
- /// selects the row, from the actual cursor till top
- cursorSelectRowAreaTop,
- /// selects the row, from the actual cursor till bottom
- cursorSelectRowAreaBottom,
-
-
- /// invalid and final enumeration value, not to be actually used
- invalidTableControlAction
- };
-
- //====================================================================
- //= IAbstractTableControl
- //====================================================================
- /** defines a callback interface to be implemented by a concrete table control
- */
- class SAL_NO_VTABLE IAbstractTableControl
- {
- public:
- /** hides the cell cursor
-
- The method cares for successive calls, that is, for every call to
- ->hideCursor(), you need one call to ->showCursor. Only if the number
- of both calls matches, the cursor is really shown.
-
- @see showCursor
- */
- virtual void hideCursor() = 0;
-
- /** shows the cell cursor
-
- @see hideCursor
- */
- virtual void showCursor() = 0;
-
- /** dispatches an action to the table control
-
- @return
- <TRUE/> if the action could be dispatched successfully, <FALSE/> otherwise. Usual
- failure conditions include some other instance vetoing the action, or impossibility
- to execute the action at all (for instance moving up one row when already positioned
- on the very first row).
-
- @see TableControlAction
- */
- virtual bool dispatchAction( TableControlAction _eAction ) = 0;
- /** returns selection engine*/
- virtual SelectionEngine* getSelEngine() = 0;
- virtual void setCursorAtCurrentCell(const Point& rPoint) = 0;
- virtual bool isTooltipActive() = 0;
- virtual rtl::OUString& setTooltip(const Point& rPoint ) = 0;
- virtual RowPos getCurrentRow(const Point& rPoint ) = 0;
- virtual void resizeColumn(const Point& rPoint ) = 0;
- virtual bool startResizeColumn(const Point& rPoint) = 0;
- virtual bool endResizeColumn(const Point& rPoint) = 0;
- virtual bool isRowSelected(RowPos _nRow) = 0;
-
- virtual ~IAbstractTableControl() {};
- };
-
-//........................................................................
-} } // namespace svt::table
-//........................................................................
-
-#endif // SVTOOLS_INC_TABLE_ABSTRACTTABLECONTROL_HXX
diff --git a/svtools/inc/svtools/table/defaultinputhandler.hxx b/svtools/inc/svtools/table/defaultinputhandler.hxx
index ca760896d539..6990f903cdb2 100644
--- a/svtools/inc/svtools/table/defaultinputhandler.hxx
+++ b/svtools/inc/svtools/table/defaultinputhandler.hxx
@@ -27,43 +27,44 @@
#ifndef SVTOOLS_INC_TABLE_DEFAULTINPUTHANDLER_HXX
#define SVTOOLS_INC_TABLE_DEFAULTINPUTHANDLER_HXX
-#include <svtools/table/tableinputhandler.hxx>
+#include "svtools/table/tableinputhandler.hxx"
+#include "svtools/table/tabletypes.hxx"
-//........................................................................
+#include <boost/scoped_ptr.hpp>
+
+//......................................................................................................................
namespace svt { namespace table
{
-//........................................................................
+//......................................................................................................................
struct DefaultInputHandler_Impl;
- //====================================================================
+ //==================================================================================================================
//= DefaultInputHandler
- //====================================================================
+ //==================================================================================================================
class DefaultInputHandler : public ITableInputHandler
{
- friend class TableDataWindow;
private:
- DefaultInputHandler_Impl* m_pImpl;
- bool m_bResize;
+ ::boost::scoped_ptr< DefaultInputHandler_Impl > m_pImpl;
public:
DefaultInputHandler();
~DefaultInputHandler();
- virtual bool MouseMove ( IAbstractTableControl& _rControl, const MouseEvent& rMEvt );
- virtual bool MouseButtonDown ( IAbstractTableControl& _rControl, const MouseEvent& rMEvt );
- virtual bool MouseButtonUp ( IAbstractTableControl& _rControl, const MouseEvent& rMEvt );
- virtual bool KeyInput ( IAbstractTableControl& _rControl, const KeyEvent& rKEvt );
- virtual bool GetFocus ( IAbstractTableControl& _rControl );
- virtual bool LoseFocus ( IAbstractTableControl& _rControl );
- virtual bool RequestHelp ( IAbstractTableControl& _rControl, const HelpEvent& rHEvt );
- virtual bool Command ( IAbstractTableControl& _rControl, const CommandEvent& rCEvt );
- virtual bool PreNotify ( IAbstractTableControl& _rControl, NotifyEvent& rNEvt );
- virtual bool Notify ( IAbstractTableControl& _rControl, NotifyEvent& rNEvt );
+ virtual bool MouseMove ( ITableControl& _rControl, const MouseEvent& rMEvt );
+ virtual bool MouseButtonDown ( ITableControl& _rControl, const MouseEvent& rMEvt );
+ virtual bool MouseButtonUp ( ITableControl& _rControl, const MouseEvent& rMEvt );
+ virtual bool KeyInput ( ITableControl& _rControl, const KeyEvent& rKEvt );
+ virtual bool GetFocus ( ITableControl& _rControl );
+ virtual bool LoseFocus ( ITableControl& _rControl );
+ virtual bool RequestHelp ( ITableControl& _rControl, const HelpEvent& rHEvt );
+ virtual bool Command ( ITableControl& _rControl, const CommandEvent& rCEvt );
+ virtual bool PreNotify ( ITableControl& _rControl, NotifyEvent& rNEvt );
+ virtual bool Notify ( ITableControl& _rControl, NotifyEvent& rNEvt );
};
-//........................................................................
+//......................................................................................................................
} } // namespace svt::table
-//........................................................................
+//......................................................................................................................
#endif // SVTOOLS_INC_TABLE_DEFAULTINPUTHANDLER_HXX
diff --git a/svtools/inc/svtools/table/gridtablerenderer.hxx b/svtools/inc/svtools/table/gridtablerenderer.hxx
index e474306c0423..c472fa408574 100644
--- a/svtools/inc/svtools/table/gridtablerenderer.hxx
+++ b/svtools/inc/svtools/table/gridtablerenderer.hxx
@@ -29,6 +29,8 @@
#include <svtools/table/tablemodel.hxx>
+#include <boost/scoped_ptr.hpp>
+
//........................................................................
namespace svt { namespace table
{
@@ -43,14 +45,11 @@ namespace svt { namespace table
This class is able to paint a table grid, table headers, and cell
backgrounds according to the selected/active state of cells.
-
- TODO update the documentation when it's decided whether this renderer
- also does value handling
*/
class GridTableRenderer : public ITableRenderer
{
private:
- GridTableRenderer_Impl* m_pImpl;
+ ::boost::scoped_ptr< GridTableRenderer_Impl > m_pImpl;
public:
/** creates a table renderer associated with the given model
@@ -72,9 +71,17 @@ namespace svt { namespace table
This method returns the index of the last row which has been prepared
*/
- RowPos getCurrentRow();
+ RowPos getCurrentRow() const;
+
+ /** determines whether or not to paint grid lines
+ */
+ bool useGridLines() const;
- protected:
+ /** controls whether or not to paint grid lines
+ */
+ void useGridLines( bool const i_use );
+
+ public:
// ITableRenderer overridables
virtual void PaintHeaderArea(
OutputDevice& _rDevice, const Rectangle& _rArea,
@@ -89,17 +96,34 @@ namespace svt { namespace table
virtual void PaintRowHeader(
bool _bActive, bool _bSelected,
OutputDevice& _rDevice, const Rectangle& _rArea,
- const StyleSettings& _rStyle, rtl::OUString& _rText );
- virtual void PaintCellImage( ColPos _nColumn,
- bool _bActive, bool _bSelected,
- OutputDevice& _rDevice, const Rectangle& _rArea,
- const StyleSettings& _rStyle, Image* _pCellData );
- virtual void PaintCellString( ColPos _nColumn,
+ const StyleSettings& _rStyle );
+ virtual void PaintCell( ColPos const i_col,
bool _bActive, bool _bSelected,
OutputDevice& _rDevice, const Rectangle& _rArea,
- const StyleSettings& _rStyle, rtl::OUString& _rText );
+ const StyleSettings& _rStyle );
virtual void ShowCellCursor( Window& _rView, const Rectangle& _rCursorRect);
virtual void HideCellCursor( Window& _rView, const Rectangle& _rCursorRect);
+ virtual bool FitsIntoCell(
+ ::com::sun::star::uno::Any const & i_cellContent,
+ ColPos const i_colPos, RowPos const i_rowPos,
+ bool const i_active, bool const i_selected,
+ OutputDevice& i_targetDevice, Rectangle const & i_targetArea
+ );
+
+ private:
+ struct CellRenderContext;
+
+ void impl_paintCellContent(
+ CellRenderContext const & i_context
+ );
+ void impl_paintCellImage(
+ CellRenderContext const & i_context,
+ Image const & i_image
+ );
+ void impl_paintCellText(
+ CellRenderContext const & i_context,
+ ::rtl::OUString const & i_text
+ );
};
//........................................................................
} } // namespace svt::table
diff --git a/svtools/inc/svtools/table/tablecontrol.hxx b/svtools/inc/svtools/table/tablecontrol.hxx
index 28ac3583bd5a..8afc2209227c 100644
--- a/svtools/inc/svtools/table/tablecontrol.hxx
+++ b/svtools/inc/svtools/table/tablecontrol.hxx
@@ -28,13 +28,16 @@
#define SVTOOLS_INC_TABLE_TABLECONTROL_HXX
#include "svtools/svtdllapi.h"
-#include <svtools/table/tablemodel.hxx>
+#include "svtools/table/tablemodel.hxx"
+#include "svtools/accessibletable.hxx"
+#include "svtools/accessiblefactory.hxx"
+
#include <vcl/ctrl.hxx>
#include <vcl/seleng.hxx>
-#include <svtools/table/tabledatawindow.hxx>
-#include <svtools/accessibletable.hxx>
-#include <com/sun/star/util/Color.hpp>
-#include <svtools/accessiblefactory.hxx>
+
+#include <boost/shared_ptr.hpp>
+#include <boost/scoped_ptr.hpp>
+
//........................................................................
namespace svt { namespace table
@@ -42,8 +45,6 @@ namespace svt { namespace table
//........................................................................
class TableControl_Impl;
- class TableDataWindow;
- class AccessibleTableControl_Impl;
//====================================================================
//= TableControl
@@ -63,31 +64,19 @@ 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 SVT_DLLPUBLIC TableControl : public Control, public IAccessibleTable
{
private:
- DECL_DLLPRIVATE_LINK( ImplMouseButtonDownHdl, MouseEvent* );
- DECL_DLLPRIVATE_LINK( ImplMouseButtonUpHdl, MouseEvent* );
+ ::boost::shared_ptr< TableControl_Impl > m_pImpl;
- DECL_DLLPRIVATE_LINK( ImplSelectHdl, void* );
- TableControl_Impl* m_pImpl;
- ::com::sun::star::uno::Sequence< sal_Int32 > m_nCols;
- ::com::sun::star::uno::Sequence< ::rtl::OUString > m_aText;
- Link m_aSelectHdl;
- bool m_bSelectionChanged;
- bool m_bTooltip;
public:
- ::std::auto_ptr< AccessibleTableControl_Impl > m_pAccessTable;
-
TableControl( Window* _pParent, WinBits _nStyle );
~TableControl();
/// sets a new table model
- SVT_DLLPRIVATE void SetModel( PTableModel _pModel );
+ void SetModel( PTableModel _pModel );
/// retrieves the current table model
PTableModel GetModel() const;
@@ -107,9 +96,8 @@ namespace svt { namespace table
*/
sal_Int32 GetCurrentRow() const;
- /** returns the row, which contains the input point*/
-
- ColPos GetCurrentRow (const Point& rPoint);
+ ITableControl&
+ getTableControlInterface();
/** retrieves the current column
@@ -125,7 +113,7 @@ namespace svt { namespace table
/** activates the cell at the given position
@return
- <TRUE/> if the move was successful, <FALSE/> otherwise. Usual
+ <sal_True/> if the move was successful, <FALSE/> otherwise. Usual
failure conditions include some other instance vetoing the move,
or impossibility to execute the move at all (for instance because
of invalid coordinates).
@@ -135,7 +123,7 @@ namespace svt { namespace table
/** moves the active cell to the given column, by keeping the active row
@return
- <TRUE/> if the move was successful, <FALSE/> otherwise. Usual
+ <sal_True/> if the move was successful, <FALSE/> otherwise. Usual
failure conditions include some other instance vetoing the move,
or impossibility to execute the move at all (for instance because
of invalid coordinates).
@@ -148,7 +136,7 @@ namespace svt { namespace table
/** moves the active cell to the given row, by keeping the active column
@return
- <TRUE/> if the move was successful, <FALSE/> otherwise. Usual
+ <sal_True/> if the move was successful, <FALSE/> otherwise. Usual
failure conditions include some other instance vetoing the move,
or impossibility to execute the move at all (for instance because
of invalid coordinates).
@@ -157,22 +145,17 @@ namespace svt { namespace table
{
return GoTo( GetCurrentColumn(), _nRow );
}
- SVT_DLLPRIVATE virtual void Resize();
- virtual void Select();
- SVT_DLLPRIVATE void SetSelectHdl( const Link& rLink ) { m_aSelectHdl = rLink; }
- const Link& GetSelectHdl() const { return m_aSelectHdl; }
- /**invalidates the table if table has been changed e.g. new row added
- */
- void InvalidateDataWindow(RowPos _nRowStart, RowPos _nRowEnd, bool _bRemoved);
- /**gets the vector, which contains the selected rows
- */
- 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
- */
- SelectionEngine* getSelEngine();
- TableDataWindow* getDataWindow();
+ SVT_DLLPRIVATE virtual void Resize();
+ virtual void Select();
+ void SetSelectHdl( const Link& rLink );
+ const Link& GetSelectHdl() const;
+
+ /**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
+ */
+ SelectionEngine* getSelEngine();
+ Window& getDataWindow();
// Window overridables
virtual void GetFocus();
@@ -180,55 +163,55 @@ namespace svt { namespace table
virtual void KeyInput( const KeyEvent& rKEvt );
virtual void StateChanged( StateChangedType i_nStateChange );
- /** Creates and returns the accessible object of the whole GridControl. */
- SVT_DLLPRIVATE virtual XACC CreateAccessible();
- SVT_DLLPRIVATE virtual XACC CreateAccessibleControl( sal_Int32 _nIndex );
- SVT_DLLPRIVATE virtual ::rtl::OUString GetAccessibleObjectName(AccessibleTableControlObjType eObjType, sal_Int32 _nRow, sal_Int32 _nCol) const;
- SVT_DLLPRIVATE virtual sal_Bool GoToCell( sal_Int32 _nColumnPos, sal_Int32 _nRow );
- SVT_DLLPRIVATE 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 ) const;
- virtual void GrabFocus();
- virtual XACC GetAccessible( sal_Bool bCreate = sal_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, sal_Bool _bOnScreen = sal_True );
- virtual Rectangle calcTableRect( sal_Bool _bOnScreen = sal_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 ::com::sun::star::uno::Any 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 );
- virtual void RemoveSelectedRow(RowPos _nRowPos);
- virtual ::rtl::OUString GetAccessibleCellText(sal_Int32 _nRowPos, sal_Int32 _nColPos) const;
- ::com::sun::star::uno::Sequence< sal_Int32 >& getColumnsForTooltip();
- ::com::sun::star::uno::Sequence< ::rtl::OUString >& getTextForTooltip();
- void setTooltip(const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aText, const ::com::sun::star::uno::Sequence< sal_Int32 >& nCols);
- void clearSelection();
- void selectionChanged(bool _bChanged);
- bool isTooltip();
-
- protected:
- /// retrieves the XAccessible implementation associated with the GridControl instance
- ::svt::IAccessibleFactory& getAccessibleFactory();
+ /** Creates and returns the accessible object of the whole GridControl. */
+ SVT_DLLPRIVATE virtual XACC CreateAccessible();
+ SVT_DLLPRIVATE virtual XACC CreateAccessibleControl( sal_Int32 _nIndex );
+ SVT_DLLPRIVATE virtual ::rtl::OUString GetAccessibleObjectName(AccessibleTableControlObjType eObjType, sal_Int32 _nRow, sal_Int32 _nCol) const;
+ SVT_DLLPRIVATE virtual sal_Bool GoToCell( sal_Int32 _nColumnPos, sal_Int32 _nRow );
+ SVT_DLLPRIVATE virtual ::rtl::OUString GetAccessibleObjectDescription(AccessibleTableControlObjType eObjType, sal_Int32 _nPosition = -1) const;
+ virtual void FillAccessibleStateSet(
+ ::utl::AccessibleStateSetHelper& rStateSet,
+ AccessibleTableControlObjType eObjType ) const;
+
+ // .............................................................................................................
+ // IAccessibleTable
+ virtual Rectangle GetWindowExtentsRelative( Window *pRelativeWindow ) const;
+ virtual void GrabFocus();
+ virtual XACC GetAccessible( sal_Bool bCreate = sal_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_Bool ConvertPointToCellAddress( sal_Int32& _rnRow, sal_Int32& _rnColPos, const Point& _rPoint );
+ virtual Rectangle calcHeaderRect( sal_Bool _bIsColumnBar, sal_Bool _bOnScreen = sal_True );
+ virtual Rectangle calcTableRect( sal_Bool _bOnScreen = sal_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 ::com::sun::star::uno::Any GetCellContent( sal_Int32 _nRowPos, sal_Int32 _nColPos) const;
+ virtual sal_Bool HasRowHeader();
+ virtual sal_Bool HasColHeader();
+ virtual ::rtl::OUString GetAccessibleCellText(sal_Int32 _nRowPos, sal_Int32 _nColPos) const;
+
+ virtual sal_Int32 GetSelectedRowCount() const;
+ virtual sal_Int32 GetSelectedRowIndex( sal_Int32 const i_selectionIndex ) const;
+ virtual bool IsRowSelected( sal_Int32 const i_rowIndex ) const;
+ virtual void SelectRow( sal_Int32 const i_rowIndex, bool const i_select );
+ virtual void SelectAllRows( bool const i_select );
+ // .............................................................................................................
+
+ private:
+ DECL_DLLPRIVATE_LINK( ImplMouseButtonDownHdl, MouseEvent* );
+ DECL_DLLPRIVATE_LINK( ImplMouseButtonUpHdl, MouseEvent* );
+
+ DECL_DLLPRIVATE_LINK( ImplSelectHdl, void* );
private:
TableControl(); // never implemented
diff --git a/svtools/inc/svtools/table/tablecontrolinterface.hxx b/svtools/inc/svtools/table/tablecontrolinterface.hxx
new file mode 100644
index 000000000000..74e9688d01db
--- /dev/null
+++ b/svtools/inc/svtools/table/tablecontrolinterface.hxx
@@ -0,0 +1,254 @@
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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_INC_TABLE_ABSTRACTTABLECONTROL_HXX
+#define SVTOOLS_INC_TABLE_ABSTRACTTABLECONTROL_HXX
+
+#include <sal/types.h>
+#include <vcl/event.hxx>
+#include <vcl/seleng.hxx>
+
+#include "svtools/table/tabletypes.hxx"
+#include "svtools/table/tablemodel.hxx"
+
+class Pointer;
+
+//......................................................................................................................
+namespace svt { namespace table
+{
+//......................................................................................................................
+
+ //==================================================================================================================
+ //= TableControlAction
+ //==================================================================================================================
+ enum TableControlAction
+ {
+ /// moves the cursor in the table control one row up, if possible, by keeping the current column
+ cursorUp,
+ /// moves the cursor in the table control one row down, if possible, by keeping the current column
+ cursorDown,
+ /// moves the cursor in the table control one column to the left, if possible, by keeping the current row
+ cursorLeft,
+ /// moves the cursor in the table control one column to the right, if possible, by keeping the current row
+ cursorRight,
+ /// moves the cursor to the beginning of the current line
+ cursorToLineStart,
+ /// moves the cursor to the end of the current line
+ cursorToLineEnd,
+ /// moves the cursor to the first row, keeping the current column
+ cursorToFirstLine,
+ /// moves the cursor to the last row, keeping the current column
+ cursorToLastLine,
+ /// moves the cursor one page up, keeping the current column
+ cursorPageUp,
+ /// moves the cursor one page down, keeping the current column
+ cursorPageDown,
+ /// moves the cursor to the top-most, left-most cell
+ cursorTopLeft,
+ /// moves the cursor to the bottom-most, right-most cell
+ cursorBottomRight,
+ /// selects the row, where the actual cursor is
+ cursorSelectRow,
+ /// selects the rows, above the actual cursor is
+ cursorSelectRowUp,
+ /// selects the row, beneath the actual cursor is
+ cursorSelectRowDown,
+ /// selects the row, from the actual cursor till top
+ cursorSelectRowAreaTop,
+ /// selects the row, from the actual cursor till bottom
+ cursorSelectRowAreaBottom,
+
+ /// invalid and final enumeration value, not to be actually used
+ invalidTableControlAction
+ };
+
+ //==================================================================================================================
+ //= TableCellArea
+ //==================================================================================================================
+ enum TableCellArea
+ {
+ CellContent,
+ ColumnDivider
+ };
+
+ //==================================================================================================================
+ //= TableCell
+ //==================================================================================================================
+ struct TableCell
+ {
+ ColPos nColumn;
+ RowPos nRow;
+ TableCellArea eArea;
+
+ TableCell()
+ :nColumn( COL_INVALID )
+ ,nRow( ROW_INVALID )
+ ,eArea( CellContent )
+ {
+ }
+
+ TableCell( ColPos const i_column, RowPos const i_row )
+ :nColumn( i_column )
+ ,nRow( i_row )
+ ,eArea( CellContent )
+ {
+ }
+ };
+
+ //==================================================================================================================
+ //= ColumnMetrics
+ //==================================================================================================================
+ struct ColumnMetrics
+ {
+ /** the start of the column, in pixels. Might be negative, in case the column is scrolled out of the visible
+ area.
+ */
+ long nStartPixel;
+
+ /** the end of the column, in pixels, plus 1. Effectively, this is the accumulated width of a all columns
+ up to the current one.
+ */
+ long nEndPixel;
+
+ ColumnMetrics()
+ :nStartPixel(0)
+ ,nEndPixel(0)
+ {
+ }
+
+ ColumnMetrics( long const i_start, long const i_end )
+ :nStartPixel( i_start )
+ ,nEndPixel( i_end )
+ {
+ }
+ };
+
+ //==================================================================================================================
+ //= TableArea
+ //==================================================================================================================
+ enum TableArea
+ {
+ TableAreaColumnHeaders,
+ TableAreaRowHeaders,
+ TableAreaDataArea,
+ TableAreaAll
+ };
+
+ //==================================================================================================================
+ //= ITableControl
+ //==================================================================================================================
+ /** defines a callback interface to be implemented by a concrete table control
+ */
+ class SAL_NO_VTABLE ITableControl
+ {
+ public:
+ /** hides the cell cursor
+
+ The method cares for successive calls, that is, for every call to
+ ->hideCursor(), you need one call to ->showCursor. Only if the number
+ of both calls matches, the cursor is really shown.
+
+ @see showCursor
+ */
+ virtual void hideCursor() = 0;
+
+ /** shows the cell cursor
+
+ @see hideCursor
+ */
+ virtual void showCursor() = 0;
+
+ /** dispatches an action to the table control
+
+ @return
+ <TRUE/> if the action could be dispatched successfully, <FALSE/> otherwise. Usual
+ failure conditions include some other instance vetoing the action, or impossibility
+ to execute the action at all (for instance moving up one row when already positioned
+ on the very first row).
+
+ @see TableControlAction
+ */
+ virtual bool dispatchAction( TableControlAction _eAction ) = 0;
+
+ /** returns selection engine*/
+ virtual SelectionEngine* getSelEngine() = 0;
+
+ /** returns the table model
+
+ The returned model is guaranteed to not be <NULL/>.
+ */
+ virtual PTableModel getModel() const = 0;
+
+ /// returns the index of the currently active column
+ virtual ColPos getCurrentColumn() const = 0;
+
+ /// returns the index of the currently active row
+ virtual RowPos getCurrentRow() const = 0;
+
+ /// activates the given cell
+ virtual bool activateCell( ColPos const i_col, RowPos const i_row ) = 0;
+
+ /// retrieves the size of the table window, in pixels
+ virtual ::Size getTableSizePixel() const = 0;
+
+ /// sets a new mouse pointer for the table window
+ virtual void setPointer( Pointer const & i_pointer ) = 0;
+
+ /// captures the mouse to the table window
+ virtual void captureMouse() = 0;
+
+ /// releases the mouse, after it had previously been captured
+ virtual void releaseMouse() = 0;
+
+ /// invalidates the table window
+ virtual void invalidate( TableArea const i_what ) = 0;
+
+ /// calculates a width, given in pixels, into a AppFont-based width
+ virtual long pixelWidthToAppFont( long const i_pixels ) const = 0;
+
+ /// shows a trackign rectangle
+ virtual void showTracking( Rectangle const & i_location, sal_uInt16 const i_flags ) = 0;
+
+ /// hides a prviously shown tracking rectangle
+ virtual void hideTracking() = 0;
+
+ /// does a hit test for the given pixel coordinates
+ virtual TableCell hitTest( const Point& rPoint ) const = 0;
+
+ /// retrieves the metrics for a given column
+ virtual ColumnMetrics getColumnMetrics( ColPos const i_column ) const = 0;
+
+ /// determines whether a given row is selected
+ virtual bool isRowSelected( RowPos _nRow ) const = 0;
+
+ virtual ~ITableControl() {};
+ };
+
+//......................................................................................................................
+} } // namespace svt::table
+//......................................................................................................................
+
+#endif // SVTOOLS_INC_TABLE_ABSTRACTTABLECONTROL_HXX
diff --git a/svtools/inc/svtools/table/tableinputhandler.hxx b/svtools/inc/svtools/table/tableinputhandler.hxx
index 6d6af9f641bb..87803f03e240 100644
--- a/svtools/inc/svtools/table/tableinputhandler.hxx
+++ b/svtools/inc/svtools/table/tableinputhandler.hxx
@@ -40,7 +40,7 @@ namespace svt { namespace table
{
//........................................................................
- class IAbstractTableControl;
+ class ITableControl;
//====================================================================
//= ITableInputHandler
@@ -56,16 +56,16 @@ namespace svt { namespace table
// or whether it has been sufficiently handled by the ->ITableInputHandler instance
// (<FALSE/>).
- virtual bool MouseMove ( IAbstractTableControl& _rControl, const MouseEvent& rMEvt ) = 0;
- virtual bool MouseButtonDown ( IAbstractTableControl& _rControl, const MouseEvent& rMEvt ) = 0;
- virtual bool MouseButtonUp ( IAbstractTableControl& _rControl, const MouseEvent& rMEvt ) = 0;
- virtual bool KeyInput ( IAbstractTableControl& _rControl, const KeyEvent& rKEvt ) = 0;
- virtual bool GetFocus ( IAbstractTableControl& _rControl ) = 0;
- virtual bool LoseFocus ( IAbstractTableControl& _rControl ) = 0;
- virtual bool RequestHelp ( IAbstractTableControl& _rControl, const HelpEvent& rHEvt ) = 0;
- virtual bool Command ( IAbstractTableControl& _rControl, const CommandEvent& rCEvt ) = 0;
- virtual bool PreNotify ( IAbstractTableControl& _rControl, NotifyEvent& rNEvt ) = 0;
- virtual bool Notify ( IAbstractTableControl& _rControl, NotifyEvent& rNEvt ) = 0;
+ virtual bool MouseMove ( ITableControl& _rControl, const MouseEvent& rMEvt ) = 0;
+ virtual bool MouseButtonDown ( ITableControl& _rControl, const MouseEvent& rMEvt ) = 0;
+ virtual bool MouseButtonUp ( ITableControl& _rControl, const MouseEvent& rMEvt ) = 0;
+ virtual bool KeyInput ( ITableControl& _rControl, const KeyEvent& rKEvt ) = 0;
+ virtual bool GetFocus ( ITableControl& _rControl ) = 0;
+ virtual bool LoseFocus ( ITableControl& _rControl ) = 0;
+ virtual bool RequestHelp ( ITableControl& _rControl, const HelpEvent& rHEvt ) = 0;
+ virtual bool Command ( ITableControl& _rControl, const CommandEvent& rCEvt ) = 0;
+ virtual bool PreNotify ( ITableControl& _rControl, NotifyEvent& rNEvt ) = 0;
+ virtual bool Notify ( ITableControl& _rControl, NotifyEvent& rNEvt ) = 0;
virtual ~ITableInputHandler() { }
};
diff --git a/svtools/inc/svtools/table/tablemodel.hxx b/svtools/inc/svtools/table/tablemodel.hxx
index 3da396d9d86c..94f03b684e64 100644..100755
--- a/svtools/inc/svtools/table/tablemodel.hxx
+++ b/svtools/inc/svtools/table/tablemodel.hxx
@@ -28,16 +28,22 @@
#define SVTOOLS_INC_TABLE_TABLEMODEL_HXX
#include "svtools/svtdllapi.h"
-#include <svtools/table/tabletypes.hxx>
-#include <svtools/table/tablerenderer.hxx>
-#include <svtools/table/tableinputhandler.hxx>
-#include <rtl/ref.hxx>
-#include <sal/types.h>
+#include "svtools/table/tabletypes.hxx"
+#include "svtools/table/tablerenderer.hxx"
+#include "svtools/table/tableinputhandler.hxx"
+#include "svtools/table/tablesort.hxx"
+
#include <com/sun/star/util/Color.hpp>
-#include <boost/shared_ptr.hpp>
#include <com/sun/star/style/VerticalAlignment.hpp>
#include <com/sun/star/style/HorizontalAlignment.hpp>
+#include <rtl/ref.hxx>
+#include <sal/types.h>
+
+#include <boost/shared_ptr.hpp>
+#include <boost/optional.hpp>
+#include <boost/enable_shared_from_this.hpp>
+
//........................................................................
namespace svt { namespace table
{
@@ -45,19 +51,6 @@ namespace svt { namespace table
//====================================================================
- //= cell data
- //====================================================================
- struct TableContentType
- {
- ::rtl::OUString sContent;
- Image* pImage;
- TableContentType() :
- sContent(),
- pImage( )
- {
- }
- };
- //====================================================================
//= ScrollbarVisibility
//====================================================================
enum ScrollbarVisibility
@@ -78,13 +71,24 @@ namespace svt { namespace table
//====================================================================
//= ITableModelListener
//====================================================================
+ typedef sal_Int32 ColumnAttributeGroup;
+ #define COL_ATTRS_NONE (0x00000000)
+ /// denotes column attributes related to the width of the column
+ #define COL_ATTRS_WIDTH (0x00000001)
+ /// denotes column attributes related to the appearance of the column, i.e. those relevant for rendering
+ #define COL_ATTRS_APPEARANCE (0x00000002)
+ /// denotes the entirety of column attributes
+ #define COL_ATTRS_ALL (0x7FFFFFFF)
+
+ //====================================================================
+ //= ITableModelListener
+ //====================================================================
/** declares an interface to be implemented by components interested in
changes in an ->ITableModel
*/
- class SAL_NO_VTABLE ITableModelListener
+ class SAL_NO_VTABLE ITableModelListener : public ::boost::enable_shared_from_this< ITableModelListener >
{
public:
- //virtual void onTableModelChanged(PTableModel pTableModel) = 0;
/** notifies the listener that one or more rows have been inserted into
the table
@@ -100,7 +104,8 @@ namespace svt { namespace table
the table
@param first
- the old index of the first removed row
+ the old index of the first removed row. If this is <code>-1</code>, then all
+ rows have been removed from the model.
@param last
the old index of the last removed row. Must not be smaller
than ->first
@@ -116,27 +121,19 @@ namespace svt { namespace table
the index of the last newly inserted row. Must not be smaller
than ->first
*/
- virtual void columnsInserted( ColPos first, ColPos last ) = 0;
+ virtual void columnInserted( ColPos const i_colIndex ) = 0;
/** notifies the listener that one or more columns have been removed from
the table
- @param first
- the old index of the first removed row
- @param last
- the old index of the last removed row. Must not be smaller
- than ->first
+ @param i_colIndex
+ the old index of the removed column
*/
- virtual void columnsRemoved( ColPos first, ColPos last ) = 0;
-
- /** notifies the listener that a column in the table has moved
+ virtual void columnRemoved( ColPos const i_colIndex ) = 0;
- @param oldIndex
- the old index of the column within the model
- @param newIndex
- the new index of the column within the model
+ /** notifies the listener that all columns have been removed form the model
*/
- virtual void columnMoved( ColPos oldIndex, ColPos newIndex ) = 0;
+ virtual void allColumnsRemoved() = 0;
/** notifies the listener that a rectangular cell range in the table
has been updated
@@ -145,7 +142,24 @@ namespace svt { namespace table
they have about the cells in question, in particular any possibly
cached cell values.
*/
- virtual void cellsUpdated( ColPos firstCol, ColPos lastCol, RowPos firstRow, RowPos lastRow ) = 0;
+ virtual void cellsUpdated( ColPos const i_firstCol, ColPos i_lastCol, RowPos const i_firstRow, RowPos const i_lastRow ) = 0;
+
+ /** notifies the listener that attributes of a given column changed
+
+ @param i_column
+ the position of the column whose attributes changed
+ @param i_attributeGroup
+ a combination of one or more <code>COL_ATTRS_*</code> flags, denoting the attribute group(s)
+ in which changes occurred.
+ */
+ virtual void columnChanged( ColPos const i_column, ColumnAttributeGroup const i_attributeGroup ) = 0;
+
+ /** notifies the listener that the metrics of the table changed.
+
+ Metrics here include the column header height, the row header width, the row height, and the presence
+ of both the row and column header.
+ */
+ virtual void tableMetricsChanged() = 0;
/// deletes the listener instance
virtual ~ITableModelListener(){};
@@ -172,7 +186,8 @@ namespace svt { namespace table
@see setID
*/
- virtual ColumnID getID() const = 0;
+ virtual ::com::sun::star::uno::Any
+ getID() const = 0;
/** sets a new column ID
@@ -183,7 +198,7 @@ namespace svt { namespace table
@see getID
*/
- virtual bool setID( const ColumnID _nID ) = 0;
+ virtual void setID( const ::com::sun::star::uno::Any& _nID ) = 0;
/** returns the name of the column
@@ -200,7 +215,15 @@ namespace svt { namespace table
*/
virtual void setName( const String& _rName ) = 0;
- /** determines whether the column can be resized
+ /** retrieves the help text to be displayed for the column.
+ */
+ virtual String getHelpText() const = 0;
+
+ /** sets a new the help text to be displayed for the column.
+ */
+ virtual void setHelpText( const String& i_helpText ) = 0;
+
+ /** determines whether the column can be interactively resized
@see getMinWidth
@see getMaxWidth
@@ -216,40 +239,41 @@ namespace svt { namespace table
*/
virtual void setResizable( bool _bResizable ) = 0;
- /** returns the width of the column, in 1/100 millimeters
+ /** denotes the relative flexibility of the column
- The returned value must be a positive ->TableMetrics value.
+ This flexibility is taken into account when a table control auto-resizes its columns, because the available
+ space changed. In this case, the columns grow or shrink according to their flexibility.
- It can also be COLWIDTH_FIT_TO_VIEW, to indicate that the width of the column
- should automatically be adjusted to completely fit the view. For instance, a
- model's last column could return this value, to indicate that it is to occupy
- all horizontal space remaining in the view, after all other columns have been
- layouted.
+ A value of 0 means the column is not auto-resized at all.
+ */
+ virtual sal_Int32 getFlexibility() const = 0;
- If there is more than one column with width COLWIDTH_FIT_TO_VIEW in a model,
- they're all layouted equal-width.
+ /** sets a new flexibility value for the column
- If the columns with a read width (i.e. other than COLWIDTH_FIT_TO_VIEW) are,
- in sum, wider than the view, then the view is free to choose a real width for any
- columns which return COLWIDTH_FIT_TO_VIEW here.
+ @see getFlexibility
+ */
+ virtual void setFlexibility( sal_Int32 const i_flexibility ) = 0;
+
+ /** returns the width of the column, in app-font unitss
+
+ The returned value must be a positive ->TableMetrics value.
@see setWidth
@see getMinWidth
@see getMaxWidth
- @see COLWIDTH_FIT_TO_VIEW
*/
virtual TableMetrics getWidth() const = 0;
/** sets a new width for the column
@param _nWidth
- the new width, in 1/100 millimeters
+ the new width, app-font units
@see getWidth
*/
virtual void setWidth( TableMetrics _nWidth ) = 0;
- /** returns the minimum width of the column, in 1/100 millimeters, or 0 if the column
+ /** returns the minimum width of the column, in app-font units, or 0 if the column
does not have a minimal width
@see setMinWidth
@@ -258,7 +282,7 @@ namespace svt { namespace table
*/
virtual TableMetrics getMinWidth() const = 0;
- /** sets the minimum width of the column, in 1/100 millimeters
+ /** sets the minimum width of the column, in app-font units
@see getMinWidth
@see setMaxWidth
@@ -266,7 +290,7 @@ namespace svt { namespace table
*/
virtual void setMinWidth( TableMetrics _nMinWidth ) = 0;
- /** returns the maximum width of the column, in 1/100 millimeters, or 0 if the column
+ /** returns the maximum width of the column, in app-font units, or 0 if the column
does not have a minimal width
@see setMaxWidth
@@ -275,7 +299,7 @@ namespace svt { namespace table
*/
virtual TableMetrics getMaxWidth() const = 0;
- /** sets the maximum width of the column, in 1/100 millimeters
+ /** sets the maximum width of the column, in app-font units
@see getMaxWidth
@see setMinWidth
@@ -283,24 +307,14 @@ namespace svt { namespace table
*/
virtual void setMaxWidth( TableMetrics _nMaxWidth ) = 0;
- /** returns the preferred width of the column, or 0 if the column
- does not have a preferred width.
-
- @see setMaxWidth
- @see getMinWidth
- @see getWidth
+ /** retrieves the horizontal alignment to be used for content in this cell
*/
- virtual TableMetrics getPreferredWidth() const = 0;
- /** sets the preferred width of the column, to be used when user resizes column
+ virtual ::com::sun::star::style::HorizontalAlignment getHorizontalAlign() = 0;
- @see getMaxWidth
- @see setMinWidth
- @see setWidth
+ /** sets a new the horizontal alignment to be used for content in this cell
*/
- virtual void setPreferredWidth( TableMetrics _nPrefWidth ) = 0;
-
- virtual ::com::sun::star::style::HorizontalAlignment getHorizontalAlign() = 0;
virtual void setHorizontalAlign(::com::sun::star::style::HorizontalAlignment _xAlign) = 0;
+
/// deletes the column model instance
virtual ~IColumnModel() { }
};
@@ -322,9 +336,6 @@ namespace svt { namespace table
*/
virtual TableSize getRowCount() const = 0;
- SVT_DLLPRIVATE virtual void setColumnCount(TableSize _nColCount) = 0;
- SVT_DLLPRIVATE virtual void setRowCount(TableSize _nRowCount) = 0;
-
/** determines whether the table has column headers
If this method returns <TRUE/>, the renderer returned by
@@ -333,15 +344,6 @@ namespace svt { namespace table
@see IColumnRenderer
*/
virtual bool hasColumnHeaders() const = 0;
- /** sets whether the table should have row headers
- @see IColumnRenderer
- */
- SVT_DLLPRIVATE virtual void setRowHeaders( bool rowHeaders) = 0;
-
- /** sets whether the table should have column headers
- @see IColumnRenderer
- */
- SVT_DLLPRIVATE virtual void setColumnHeaders( bool columnHeaders) = 0;
/** determines whether the table has row headers
@@ -359,14 +361,6 @@ namespace svt { namespace table
*/
virtual bool isCellEditable( ColPos col, RowPos row ) const = 0;
- /** adds the given listener to the list of ->ITableModelListener's
- */
- SVT_DLLPRIVATE virtual void addTableModelListener( const PTableModelListener& listener ) = 0;
-
- /** revokes the given listener from the list of ->ITableModelListener's
- */
- SVT_DLLPRIVATE virtual void removeTableModelListener( const PTableModelListener& listener ) = 0;
-
/** returns a model for a certain column
@param column
@@ -375,27 +369,15 @@ namespace svt { namespace table
@return
the model of the column in question. Must not be <NULL/>
-
- @see getColumnModelByID
*/
virtual PColumnModel getColumnModel( ColPos column ) = 0;
- /** finds a column model by ID
-
- @param id
- the id of the column which is to be looked up
- @return
- the column model with the given ID, or <NULL/> if there is
- no such column
- */
- virtual PColumnModel getColumnModelByID( ColumnID id ) = 0;
-
/** returns a renderer which is able to paint the table represented
by this table model
@return the renderer to use. Must not be <NULL/>
*/
- SVT_DLLPRIVATE virtual PTableRenderer getRenderer() const = 0;
+ virtual PTableRenderer getRenderer() const = 0;
/** returns the component handling input in a view associated with the model
*/
@@ -404,12 +386,10 @@ namespace svt { namespace table
/** determines the height of rows in the table.
@return
- the logical height of rows in the table, in 1/100 millimeters. The height must be
+ the logical height of rows in the table, in app-font units. The height must be
greater 0.
*/
- SVT_DLLPRIVATE virtual TableMetrics getRowHeight() const = 0;
-
- SVT_DLLPRIVATE virtual void setRowHeight(TableMetrics _nRowHeight) = 0;
+ virtual TableMetrics getRowHeight() const = 0;
/** determines the height of the column header row
@@ -417,10 +397,10 @@ namespace svt { namespace table
returned <FALSE/>.
@return
- the logical height of the column header row, in 1/100 millimeters.
+ the logical height of the column header row, in app-font units.
Must be greater than 0.
*/
- SVT_DLLPRIVATE virtual TableMetrics getColumnHeaderHeight() const = 0;
+ virtual TableMetrics getColumnHeaderHeight() const = 0;
/** determines the width of the row header column
@@ -428,48 +408,105 @@ namespace svt { namespace table
returned <FALSE/>.
@return
- the logical width of the row header column, in 1/100 millimeters.
+ the logical width of the row header column, in app-font units.
Must be greater than 0.
*/
- SVT_DLLPRIVATE virtual TableMetrics getRowHeaderWidth() const = 0;
+ virtual TableMetrics getRowHeaderWidth() const = 0;
- /** determines the visibility of the vertical scrollbar of the table control
- @param overAllHeight the height of the table with all rows
- @param actHeight the given height of the table
+ /** returns the visibilit mode of the vertical scrollbar
*/
- virtual ScrollbarVisibility getVerticalScrollbarVisibility(int overAllHeight,int actHeight) const = 0;
+ virtual ScrollbarVisibility getVerticalScrollbarVisibility() const = 0;
- /** determines the visibility of the horizontal scrollbar of the table control
- @param overAllWidth the width of the table with all columns
- @param actWidth the given width of the table
+ /** returns the visibilit mode of the horizontal scrollbar
*/
- virtual ScrollbarVisibility getHorizontalScrollbarVisibility(int overAllWidth, int actWidth) const = 0;
- virtual bool hasVerticalScrollbar() =0;
- virtual bool hasHorizontalScrollbar() = 0;
- /** fills cells with content
- */
- virtual void setCellContent(const std::vector< std::vector< ::com::sun::star::uno::Any > >& cellContent)=0;
- /** gets the content of the cells
- */
- virtual std::vector< std::vector< ::com::sun::star::uno::Any > >& getCellContent() = 0;
- /**sets title of header rows
- */
- SVT_DLLPRIVATE virtual void setRowHeaderName(const std::vector<rtl::OUString>& cellColumnContent)=0;
- /** gets title of header rows
- */
- virtual std::vector<rtl::OUString>& getRowHeaderName() = 0;
- SVT_DLLPRIVATE virtual ::com::sun::star::util::Color getLineColor() = 0;
- SVT_DLLPRIVATE virtual void setLineColor(::com::sun::star::util::Color _rColor) = 0;
- SVT_DLLPRIVATE virtual ::com::sun::star::util::Color getHeaderBackgroundColor() = 0;
- SVT_DLLPRIVATE virtual void setHeaderBackgroundColor(::com::sun::star::util::Color _rColor) = 0;
- SVT_DLLPRIVATE virtual ::com::sun::star::util::Color getTextColor() = 0;
- SVT_DLLPRIVATE virtual void setTextColor(::com::sun::star::util::Color _rColor) = 0;
- SVT_DLLPRIVATE virtual ::com::sun::star::util::Color getOddRowBackgroundColor() = 0;
- SVT_DLLPRIVATE virtual void setOddRowBackgroundColor(::com::sun::star::util::Color _rColor) = 0;
- SVT_DLLPRIVATE virtual ::com::sun::star::util::Color getEvenRowBackgroundColor() = 0;
- SVT_DLLPRIVATE virtual void setEvenRowBackgroundColor(::com::sun::star::util::Color _rColor) = 0;
- SVT_DLLPRIVATE virtual ::com::sun::star::style::VerticalAlignment getVerticalAlign() = 0;
- SVT_DLLPRIVATE virtual void setVerticalAlign(::com::sun::star::style::VerticalAlignment _xAlign) = 0;
+ virtual ScrollbarVisibility getHorizontalScrollbarVisibility() const = 0;
+
+ /** adds a listener to be notified of changes in the table model
+ */
+ virtual void addTableModelListener( const PTableModelListener& i_listener ) = 0;
+
+ /** remove a listener to be notified of changes in the table model
+ */
+ virtual void removeTableModelListener( const PTableModelListener& i_listener ) = 0;
+
+ /** retrieves the content of the given cell
+ */
+ virtual void getCellContent( ColPos const i_col, RowPos const i_row, ::com::sun::star::uno::Any& o_cellContent ) = 0;
+
+ /** returns an object which should be displayed as tooltip for the given cell
+
+ At the moment, only string-convertible values are supported here. In the future, one might imagine displaying
+ scaled-down versions of a graphic in a cell, and a larger version of that very graphic as tooltip.
+
+ If no tooltip object is provided, then the cell content is used, and displayed as tooltip for the cell
+ if and only if it doesn't fit into the cell's space itself.
+
+ @param i_col
+ The column index of the cell in question. COL_ROW_HEADERS is a valid argument here.
+ @param i_row
+ The row index of the cell in question.
+ @param o_cellToolTip
+ takes the tooltip object upon return.
+ */
+ virtual void getCellToolTip( ColPos const i_col, RowPos const i_row, ::com::sun::star::uno::Any & o_cellToolTip ) = 0;
+
+ /** retrieves title of a given row
+ */
+ virtual ::com::sun::star::uno::Any getRowHeading( RowPos const i_rowPos ) const = 0;
+
+ /** returns the color to be used for rendering the grid lines.
+
+ If this value is not set, a default color from the style settings will be used.
+ */
+ virtual ::boost::optional< ::Color > getLineColor() const = 0;
+
+ /** returns the color to be used for rendering the header background.
+
+ If this value is not set, a default color from the style settings will be used.
+ */
+ virtual ::boost::optional< ::Color > getHeaderBackgroundColor() const = 0;
+
+ /** returns the color to be used for rendering the header text.
+
+ If this value is not set, a default color from the style settings will be used.
+ */
+ virtual ::boost::optional< ::Color > getHeaderTextColor() const = 0;
+
+ /** returns the color to be used for rendering cell texts.
+
+ If this value is not set, a default color from the style settings will be used.
+ */
+ virtual ::boost::optional< ::Color > getTextColor() const = 0;
+
+ /** returns the color to be used for text lines (underline, strikethrough) when rendering cell text.
+
+ If this value is not set, a default color from the style settings will be used.
+ */
+ virtual ::boost::optional< ::Color > getTextLineColor() const = 0;
+
+ /** returns the colors to be used for the row backgrounds.
+
+ If this value is not set, every second row will have a background color derived from the style settings's
+ selection color, the other rows will not have a special background at all.
+
+ If this value is an empty sequence, the rows will not have a special background at all, instead the
+ normal background of the complete control will be used.
+
+ If value is a non-empty sequence, then rows will have the background colors as specified in the sequence,
+ in alternating order.
+ */
+ virtual ::boost::optional< ::std::vector< ::Color > >
+ getRowBackgroundColors() const = 0;
+
+ /** determines the vertical alignment of content within a cell
+ */
+ virtual ::com::sun::star::style::VerticalAlignment getVerticalAlign() const = 0;
+
+ /** returns an adapter to the sorting functionality of the model
+
+ It is legitimate to return <NULL/> here, in this case, the table model does not support sorting.
+ */
+ virtual ITableDataSort* getSortAdapter() = 0;
/// destroys the table model instance
virtual ~ITableModel() { }
diff --git a/svtools/inc/svtools/table/tablerenderer.hxx b/svtools/inc/svtools/table/tablerenderer.hxx
index f81771dd22e6..3d50c9d70ee7 100644
--- a/svtools/inc/svtools/table/tablerenderer.hxx
+++ b/svtools/inc/svtools/table/tablerenderer.hxx
@@ -46,6 +46,7 @@ namespace svt { namespace table
class SAL_NO_VTABLE ITableRenderer
{
public:
+
/** paints a (part of) header area
There are two header areas in a table control:
@@ -175,12 +176,10 @@ namespace svt { namespace table
the are into which the row header should be painted
@param _rStyle
the style to be used for drawing
- @param _rText
- the title of the header row
*/
virtual void PaintRowHeader( bool _bActive, bool _bSelected,
OutputDevice& _rDevice, const Rectangle& _rArea,
- const StyleSettings& _rStyle, rtl::OUString& _rText ) = 0;
+ const StyleSettings& _rStyle ) = 0;
/** paints a certain cell
@@ -207,46 +206,11 @@ namespace svt { namespace table
the are into which the cell should be painted
@param _rStyle
the style to be used for drawing
- @param _pCellData
- the content of the cell
*/
- virtual void PaintCellImage( ColPos _nColumn,
+ virtual void PaintCell( ColPos const i_col,
bool _bActive, bool _bSelected,
OutputDevice& _rDevice, const Rectangle& _rArea,
- const StyleSettings& _rStyle, Image* _pCellData ) = 0;
-
- /** paints a certain cell
-
- The row to be painted is denoted by the most recent call to
- ->PrepareRow.
-
- @param _bSelected
- <TRUE/> if and only if the cell to be painted is
- selected currently. This is the case if either
- the row or the column of the cell is currently selected.
- <br/>
- Note that this flag is equal to the respective flag in the
- previous ->PrepareRow call, it's passed here for convinience
- only.
- @param _bActive
- <TRUE/> if the cell is currently active.
- <br/>
- Note that this flag is equal to the respective flag in the
- previous ->PrepareRow call, it's passed here for convinience
- only.
- @param _rDevice
- denotes the device to paint onto
- @param _rArea
- the are into which the cell should be painted
- @param _rStyle
- the style to be used for drawing
- @param _rText
- the content of the cell
- */
- virtual void PaintCellString( ColPos _nColumn,
- bool _bActive, bool _bSelected,
- OutputDevice& _rDevice, const Rectangle& _rArea,
- const StyleSettings& _rStyle, rtl::OUString& _rText ) = 0;
+ const StyleSettings& _rStyle ) = 0;
/** draws a cell cursor in the given rectangle
@@ -262,6 +226,41 @@ namespace svt { namespace table
*/
virtual void HideCellCursor( Window& _rView, const Rectangle& _rCursorRect) = 0;
+ /** checks whether a given cell content fits into a given target area on a given device.
+
+ @param i_colPos
+ denotes the column which the cell content would be painted into. Your renderer implementation
+ would only need this parameter if rendering is done differently for different columns.
+
+ @param i_rowPos
+ denotes the row which the cell content would be painted into. Your renderer implementation
+ would only need this parameter if rendering is done differently for different rows.
+
+ @param i_active
+ is <TRUE/> if and only if the renderer should assume the cell content would be painted for the active
+ cell.
+
+ @param i_selected
+ is <TRUE/> if and only if the renderer should assume the cell content would be painted for a selected
+ cell.
+
+ @param i_targetDevice
+ denotes the target device for the assumed rendering operation
+
+ @param i_targetArea
+ denotes the area within the target device for the assumed rendering operation.
+
+ @return
+ <TRUE/> if and only if the given cell content could be rendered into the given device and the
+ given area.
+ */
+ virtual bool FitsIntoCell(
+ ::com::sun::star::uno::Any const & i_cellContent,
+ ColPos const i_colPos, RowPos const i_rowPos,
+ bool const i_active, bool const i_selected,
+ OutputDevice& i_targetDevice, Rectangle const & i_targetArea
+ ) = 0;
+
/// deletes the renderer instance
virtual ~ITableRenderer() { }
};
diff --git a/svtools/inc/svtools/table/tablesort.hxx b/svtools/inc/svtools/table/tablesort.hxx
new file mode 100755
index 000000000000..1690b4d51344
--- /dev/null
+++ b/svtools/inc/svtools/table/tablesort.hxx
@@ -0,0 +1,91 @@
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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_TABLESORT_HXX
+#define SVTOOLS_TABLESORT_HXX
+
+#include "svtools/table/tabletypes.hxx"
+
+//......................................................................................................................
+namespace svt { namespace table
+{
+//......................................................................................................................
+
+ //==================================================================================================================
+ //= ColumnSortDirection
+ //==================================================================================================================
+ enum ColumnSortDirection
+ {
+ ColumnSortAscending,
+ ColumnSortDescending
+ };
+
+ //==================================================================================================================
+ //= ColumnSort
+ //==================================================================================================================
+ struct ColumnSort
+ {
+ ColPos nColumnPos;
+ ColumnSortDirection eSortDirection;
+
+ ColumnSort()
+ :nColumnPos( COL_INVALID )
+ ,eSortDirection( ColumnSortAscending )
+ {
+ }
+
+ ColumnSort( ColPos const i_columnPos, ColumnSortDirection const i_sortDirection )
+ :nColumnPos( i_columnPos )
+ ,eSortDirection( i_sortDirection )
+ {
+ }
+ };
+
+ //==================================================================================================================
+ //= ITableDataSort
+ //==================================================================================================================
+ /** provides sorting functionality for the datta underlying an ITableModel
+ */
+ class SAL_NO_VTABLE ITableDataSort
+ {
+ public:
+ /** sorts the rows in the model by the given column's data, in the given direction.
+ */
+ virtual void sortByColumn( ColPos const i_column, ColumnSortDirection const i_sortDirection ) = 0;
+
+ /** retrieves the current sort order of the data
+
+ If the <code>nColumnIndex</code> member of the returned srtructure is <code>COL_INVALID</code>, then
+ the data is currently not sorted.
+ */
+ virtual ColumnSort getCurrentSortOrder() const = 0;
+ };
+
+//......................................................................................................................
+} } // namespace svt::table
+//......................................................................................................................
+
+#endif // SVTOOLS_TABLESORT_HXX
diff --git a/svtools/inc/svtools/table/tabletypes.hxx b/svtools/inc/svtools/table/tabletypes.hxx
index 645120e30d4b..ae20851992e3 100644
--- a/svtools/inc/svtools/table/tabletypes.hxx
+++ b/svtools/inc/svtools/table/tabletypes.hxx
@@ -49,14 +49,7 @@ namespace svt { namespace table
*/
typedef sal_Int32 AnyPos;
- /// the ID of a column in a table
- typedef sal_Int32 ColumnID;
-
typedef sal_Int32 TableMetrics;
-/** special column width value which indicates that the column should be
- automatically resized to fit the view
-*/
-#define COLWIDTH_FIT_TO_VIEW ((::svt::table::TableMetrics)-1)
/// denotes the column containing the row headers
#define COL_ROW_HEADERS ((::svt::table::ColPos)-1)
diff --git a/svtools/prj/build.lst b/svtools/prj/build.lst
index fd0f1a560c18..ff9aa6a9875c 100644
--- a/svtools/prj/build.lst
+++ b/svtools/prj/build.lst
@@ -1,2 +1,2 @@
-st svtools : l10n svl offuh toolkit ucbhelper unotools JPEG:jpeg cppu cppuhelper comphelper sal sot jvmfwk LIBXSLT:libxslt NULL
+st svtools : L10N:l10n svl offuh toolkit ucbhelper unotools JPEG:jpeg cppu cppuhelper comphelper sal sot jvmfwk LIBXSLT:libxslt NULL
st svtools\prj nmake - all st_prj NULL
diff --git a/svtools/qa/unoapi/makefile.mk b/svtools/qa/unoapi/makefile.mk
new file mode 100644
index 000000000000..e3afb77e637a
--- /dev/null
+++ b/svtools/qa/unoapi/makefile.mk
@@ -0,0 +1,48 @@
+#*************************************************************************
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# 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.
+#***********************************************************************/
+
+.IF "$(OOO_SUBSEQUENT_TESTS)" == ""
+nothing .PHONY:
+.ELSE
+
+PRJ = ../..
+PRJNAME = svtools
+TARGET = qa_unoapi
+
+.IF "$(OOO_JUNIT_JAR)" != ""
+PACKAGE = org/openoffice/svtools/qa/unoapi
+JAVATESTFILES = Test.java
+JAVAFILES = $(JAVATESTFILES)
+JARFILES = OOoRunner.jar ridl.jar test.jar
+EXTRAJARFILES = $(OOO_JUNIT_JAR)
+.END
+
+.INCLUDE: settings.mk
+.INCLUDE: target.mk
+.INCLUDE: installationtest.mk
+
+ALLTAR : javatest
+
+.END
diff --git a/svtools/source/brwbox/datwin.cxx b/svtools/source/brwbox/datwin.cxx
index c13eabd2314e..377180653780 100644
--- a/svtools/source/brwbox/datwin.cxx
+++ b/svtools/source/brwbox/datwin.cxx
@@ -752,17 +752,18 @@ void BrowserScrollBar::Tracking( const TrackingEvent& rTEvt )
sal_uLong nPos = GetThumbPos();
if ( nPos != _nLastPos )
{
- if ( _nTip )
- Help::HideTip( _nTip );
-
String aTip( String::CreateFromInt32(nPos) );
aTip += '/';
if ( _pDataWin->GetRealRowCount().Len() )
aTip += _pDataWin->GetRealRowCount();
else
aTip += String::CreateFromInt32(GetRangeMax());
+
Rectangle aRect( GetPointerPosPixel(), Size( GetTextHeight(), GetTextWidth( aTip ) ) );
- _nTip = Help::ShowTip( this, aRect, aTip );
+ if ( _nTip )
+ Help::UpdateTip( _nTip, this, aRect, aTip );
+ else
+ _nTip = Help::ShowTip( this, aRect, aTip );
_nLastPos = nPos;
}
diff --git a/svtools/source/contnr/svcontnr.src b/svtools/source/contnr/svcontnr.src
index bcd1e060664f..e0449fc3f644 100644
--- a/svtools/source/contnr/svcontnr.src
+++ b/svtools/source/contnr/svcontnr.src
@@ -74,30 +74,3 @@ String STR_SVT_ACC_EMPTY_FIELD
Text [ en-US ] = "Empty Field";
};
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/svtools/source/contnr/svlbox.cxx b/svtools/source/contnr/svlbox.cxx
index e34ed061cd69..e4e4abdc96a2 100644
--- a/svtools/source/contnr/svlbox.cxx
+++ b/svtools/source/contnr/svlbox.cxx
@@ -683,6 +683,7 @@ SvViewDataEntry::~SvViewDataEntry()
SvLBox_Impl::SvLBox_Impl( SvLBox& _rBox )
:m_bIsEmptyTextAllowed( true )
,m_bEntryMnemonicsEnabled( false )
+ ,m_bDoingQuickSelection( false )
,m_pLink( NULL )
,m_aMnemonicEngine( _rBox )
,m_aQuickSelectionEngine( _rBox )
diff --git a/svtools/source/control/filectrl.src b/svtools/source/control/filectrl.src
index dc8bbb5905d6..f9d63b65b838 100644..100755
--- a/svtools/source/control/filectrl.src
+++ b/svtools/source/control/filectrl.src
@@ -31,28 +31,20 @@ String STR_FILECTRL_BUTTONTEXT
Text [ en-US ] = "Browse..." ;
};
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+String STR_TABBAR_PUSHBUTTON_MOVET0HOME
+{
+ Text [ en-US ] = "Move To Home" ;
+};
+String STR_TABBAR_PUSHBUTTON_MOVELEFT
+{
+ Text [ en-US ] = "Move Left" ;
+};
+String STR_TABBAR_PUSHBUTTON_MOVERIGHT
+{
+ Text [ en-US ] = "Move Right" ;
+};
+String STR_TABBAR_PUSHBUTTON_MOVETOEND
+{
+ Text [ en-US ] = "Move To End" ;
+};
diff --git a/svtools/source/control/ruler.cxx b/svtools/source/control/ruler.cxx
index 164118d12ef9..1c5b95460232 100755
--- a/svtools/source/control/ruler.cxx
+++ b/svtools/source/control/ruler.cxx
@@ -303,6 +303,7 @@ void Ruler::ImplInit( WinBits nWinBits )
else
aDefSize.Width() = nDefHeight;
SetOutputSizePixel( aDefSize );
+ SetType(WINDOW_RULER);
}
// -----------------------------------------------------------------------
diff --git a/svtools/source/control/tabbar.cxx b/svtools/source/control/tabbar.cxx
index 033ae63e8a0a..b7511d24b5c8 100755
--- a/svtools/source/control/tabbar.cxx
+++ b/svtools/source/control/tabbar.cxx
@@ -38,7 +38,8 @@
#include <vcl/button.hxx>
#include <vcl/edit.hxx>
#include "svtaccessiblefactory.hxx"
-
+#include <filectrl.hrc>
+#include <svtools/svtdata.hxx>
#include <limits>
// =======================================================================
@@ -397,6 +398,16 @@ void TabBar::ImplInit( WinBits nWinStyle )
mnOffY++;
ImplInitControls();
+
+ if(mpFirstBtn)
+ mpFirstBtn->SetAccessibleName(String(SvtResId(STR_TABBAR_PUSHBUTTON_MOVET0HOME)));
+ if(mpPrevBtn)
+ mpPrevBtn->SetAccessibleName( String(SvtResId(STR_TABBAR_PUSHBUTTON_MOVELEFT)));
+ if(mpNextBtn)
+ mpNextBtn->SetAccessibleName(String(SvtResId(STR_TABBAR_PUSHBUTTON_MOVERIGHT)));
+ if(mpLastBtn)
+ mpLastBtn->SetAccessibleName( String(SvtResId(STR_TABBAR_PUSHBUTTON_MOVETOEND)));
+
SetSizePixel( Size( 100, CalcWindowSizePixel().Height() ) );
ImplInitSettings( sal_True, sal_True );
}
diff --git a/svtools/source/control/toolbarmenuacc.cxx b/svtools/source/control/toolbarmenuacc.cxx
index 9ffc4fc55f04..620002017e6c 100644
--- a/svtools/source/control/toolbarmenuacc.cxx
+++ b/svtools/source/control/toolbarmenuacc.cxx
@@ -252,7 +252,7 @@ OUString SAL_CALL ToolbarMenuAcc::getAccessibleName() throw (RuntimeException)
if( !aRet.getLength() )
{
- Window* pLabel = mpParent->mrMenu.GetLabeledBy();
+ Window* pLabel = mpParent->mrMenu.GetAccessibleRelationLabeledBy();
if( pLabel && pLabel != &mpParent->mrMenu )
aRet = OutputDevice::GetNonMnemonicString( pLabel->GetText() );
}
diff --git a/svtools/source/control/valueacc.cxx b/svtools/source/control/valueacc.cxx
index 848ef4c3e10e..1b98e3197bd3 100644
--- a/svtools/source/control/valueacc.cxx
+++ b/svtools/source/control/valueacc.cxx
@@ -317,7 +317,7 @@ sal_Int16 SAL_CALL ValueSetAcc::getAccessibleRole()
if ( !aRet.Len() )
{
- Window* pLabel = mpParent->GetLabeledBy();
+ Window* pLabel = mpParent->GetAccessibleRelationLabeledBy();
if ( pLabel && pLabel != mpParent )
aRet = OutputDevice::GetNonMnemonicString( pLabel->GetText() );
}
diff --git a/svtools/source/dialogs/colrdlg.hrc b/svtools/source/dialogs/colrdlg.hrc
index 41329df6e366..b1e785bd2f17 100644
--- a/svtools/source/dialogs/colrdlg.hrc
+++ b/svtools/source/dialogs/colrdlg.hrc
@@ -65,3 +65,5 @@
#define BTN_CANCEL 1
#define BTN_HELP 1
+//IAccessibility2 Implementation 2009-----
+#define STR_COLORDES 3001
diff --git a/svtools/source/dialogs/colrdlg.src b/svtools/source/dialogs/colrdlg.src
index a93642b0bd05..fee6314b28cc 100644
--- a/svtools/source/dialogs/colrdlg.src
+++ b/svtools/source/dialogs/colrdlg.src
@@ -277,45 +277,19 @@ ModalDialog DLG_COLOR
Border = TRUE ;
Pos = MAP_APPFONT ( 200 , 109 ) ;
Size = MAP_APPFONT ( 26 , 51 + DIFF ) ;
- TabStop = TRUE ;
+ TabStop = FALSE ;
};
Control CTL_PREVIEW
{
Border = TRUE ;
Pos = MAP_APPFONT ( 229 , 109 ) ;
Size = MAP_APPFONT ( 26 , 51 + DIFF ) ;
- TabStop = TRUE ;
+ TabStop = FALSE ;
};
};
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+String STR_COLORDES
+{
+ Text [ en-US ] = "RGB(%1, %2, %3) Hue:%4 Saturation:%5 Brightness:%6";
+};
diff --git a/svtools/source/filter/FilterConfigItem.cxx b/svtools/source/filter/FilterConfigItem.cxx
index 1e836cde8785..8d7752ddd7df 100644
--- a/svtools/source/filter/FilterConfigItem.cxx
+++ b/svtools/source/filter/FilterConfigItem.cxx
@@ -428,7 +428,7 @@ void FilterConfigItem::WriteBool( const OUString& rKey, sal_Bool bNewValue )
Any aAny;
if ( ImplGetPropertyValue( aAny, xPropSet, rKey, sal_True ) )
{
- sal_Bool bOldValue = bNewValue;
+ sal_Bool bOldValue(sal_True);
if ( aAny >>= bOldValue )
{
if ( bOldValue != bNewValue )
@@ -462,7 +462,7 @@ void FilterConfigItem::WriteInt32( const OUString& rKey, sal_Int32 nNewValue )
if ( ImplGetPropertyValue( aAny, xPropSet, rKey, sal_True ) )
{
- sal_Int32 nOldValue = nNewValue;
+ sal_Int32 nOldValue = 0;
if ( aAny >>= nOldValue )
{
if ( nOldValue != nNewValue )
diff --git a/svtools/source/inc/filectrl.hrc b/svtools/source/inc/filectrl.hrc
index 1707e306e1b0..150bbba4ac68 100644
--- a/svtools/source/inc/filectrl.hrc
+++ b/svtools/source/inc/filectrl.hrc
@@ -30,5 +30,12 @@
#define STR_FILECTRL_BUTTONTEXT 333 // ID-Range?!
+//IAccessibility2 Implementation 2009-----
+#define STR_TABBAR_PUSHBUTTON_MOVET0HOME ( STR_FILECTRL_BUTTONTEXT+ 1)
+#define STR_TABBAR_PUSHBUTTON_MOVELEFT ( STR_FILECTRL_BUTTONTEXT+ 2)
+#define STR_TABBAR_PUSHBUTTON_MOVERIGHT ( STR_FILECTRL_BUTTONTEXT+ 3)
+#define STR_TABBAR_PUSHBUTTON_MOVETOEND ( STR_FILECTRL_BUTTONTEXT+ 4)
+//-----IAccessibility2 Implementation 2009
+
#endif
diff --git a/svtools/source/misc/langtab.src b/svtools/source/misc/langtab.src
index 067eb601a5af..bb5fa2dfd363 100644
--- a/svtools/source/misc/langtab.src
+++ b/svtools/source/misc/langtab.src
@@ -301,7 +301,7 @@ StringArray STR_ARR_SVT_LANGUAGE_TABLE
< "Shuswap" ; LANGUAGE_USER_SHUSWAP ; > ;
< "Oromo" ; LANGUAGE_OROMO ; > ;
< "Greek, Ancient" ; LANGUAGE_USER_ANCIENT_GREEK ; > ;
- < "Yiddish" ; LANGUAGE_YIDDISH ; > ;
+ < "Yiddish (Israel)" ; LANGUAGE_YIDDISH ; > ;
< "Quechua (Ecuador)" ; LANGUAGE_QUECHUA_ECUADOR ; > ;
< "Uyghur" ; LANGUAGE_UIGHUR_CHINA ; > ;
< "Asturian" ; LANGUAGE_USER_ASTURIAN ; > ;
@@ -323,6 +323,12 @@ StringArray STR_ARR_SVT_LANGUAGE_TABLE
< "Yoruba" ; LANGUAGE_YORUBA ; > ;
< "Rusyn (Ukraine)" ; LANGUAGE_USER_RUSYN_UKRAINE ; > ;
< "Rusyn (Slovakia)" ; LANGUAGE_USER_RUSYN_SLOVAKIA ; > ;
+ < "Yiddish (USA)" ; LANGUAGE_USER_YIDDISH_US ; > ;
+ < "Hawaiian" ; LANGUAGE_HAWAIIAN_UNITED_STATES ; > ;
+ < "Limbu" ; LANGUAGE_USER_LIMBU ; > ;
+ < "Lojban" ; LANGUAGE_USER_LOJBAN ; > ;
+ < "Kabyle" ; LANGUAGE_USER_KABYLE ; > ;
+ < "Haitian" ; LANGUAGE_USER_HAITIAN ; > ;
};
};
diff --git a/svtools/source/table/cellvalueconversion.cxx b/svtools/source/table/cellvalueconversion.cxx
new file mode 100755
index 000000000000..286ca505bb30
--- /dev/null
+++ b/svtools/source/table/cellvalueconversion.cxx
@@ -0,0 +1,77 @@
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include "precompiled_svtools.hxx"
+
+#include "cellvalueconversion.hxx"
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+//......................................................................................................................
+namespace svt
+{
+//......................................................................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Any;
+ /** === end UNO using === **/
+
+ //==================================================================================================================
+ //= CellValueConversion
+ //==================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
+ ::rtl::OUString CellValueConversion::convertToString( const Any& i_value )
+ {
+ ::rtl::OUString sConvertString;
+ if ( !i_value.hasValue() )
+ return sConvertString;
+
+
+ // TODO: use css.script.XTypeConverter?
+
+ sal_Int32 nInt = 0;
+ sal_Bool bBool = false;
+ double fDouble = 0;
+
+ ::rtl::OUString sStringValue;
+ if ( i_value >>= sConvertString )
+ sStringValue = sConvertString;
+ else if ( i_value >>= nInt )
+ sStringValue = sConvertString.valueOf( nInt );
+ else if ( i_value >>= bBool )
+ sStringValue = sConvertString.valueOf( bBool );
+ else if ( i_value >>= fDouble )
+ sStringValue = sConvertString.valueOf( fDouble );
+ else
+ OSL_ENSURE( !i_value.hasValue(), "CellValueConversion::convertToString: cannot handle the given cell content type!" );
+
+ return sStringValue;
+ }
+
+//......................................................................................................................
+} // namespace svt
+//......................................................................................................................
diff --git a/svtools/source/inc/accessibletableimp.hxx b/svtools/source/table/cellvalueconversion.hxx
index 3a01c01567d3..4d6b8c8d6aac 100644..100755
--- a/svtools/source/inc/accessibletableimp.hxx
+++ b/svtools/source/table/cellvalueconversion.hxx
@@ -22,41 +22,31 @@
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
-************************************************************************/
+ ************************************************************************/
-#ifndef SVTOOLS_SOURCE_INC_ACCESSIBLETABLEIMP_HXX
-#define SVTOOLS_SOURCE_INC_ACCESSIBLETABLEIMP_HXX
+#ifndef SVTOOLS_CELLVALUECONVERSION_HXX
+#define SVTOOLS_CELLVALUECONVERSION_HXX
-#include "svtaccessiblefactory.hxx"
+/** === begin UNO includes === **/
+#include <com/sun/star/uno/Any.hxx>
+/** === end UNO includes === **/
-namespace svt { namespace table
+//......................................................................................................................
+namespace svt
{
-//........................................................................
+//......................................................................................................................
-
- class AccessibleTableControl_Impl
+ //==================================================================================================================
+ //= CellValueConversion
+ //==================================================================================================================
+ class CellValueConversion
{
- 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( );
-
+ public:
+ static ::rtl::OUString convertToString( const ::com::sun::star::uno::Any& i_cellValue );
};
-//........................................................................
-} } // namespace svt::table
-//........................................................................
+//......................................................................................................................
+} // namespace svt
+//......................................................................................................................
-#endif // SVTOOLS_SOURCE_INC_ACCESSIBLETABLEIMP_HXX
+#endif // SVTOOLS_CELLVALUECONVERSION_HXX
diff --git a/svtools/source/table/defaultinputhandler.cxx b/svtools/source/table/defaultinputhandler.cxx
index 133575fdf8cf..733366d16904 100644
--- a/svtools/source/table/defaultinputhandler.cxx
+++ b/svtools/source/table/defaultinputhandler.cxx
@@ -28,111 +28,123 @@
#include "precompiled_svtools.hxx"
#include "svtools/table/defaultinputhandler.hxx"
-#include "svtools/table/abstracttablecontrol.hxx"
+#include "svtools/table/tablecontrolinterface.hxx"
+
+#include "tabledatawindow.hxx"
+#include "mousefunction.hxx"
#include <tools/debug.hxx>
#include <vcl/event.hxx>
#include <vcl/cursor.hxx>
-#include "svtools/table/tabledatawindow.hxx"
-//........................................................................
+//......................................................................................................................
namespace svt { namespace table
{
-//.......................................................................
+//......................................................................................................................
+ typedef ::rtl::Reference< IMouseFunction > PMouseFunction;
+ typedef ::std::vector< PMouseFunction > MouseFunctions;
struct DefaultInputHandler_Impl
{
+ PMouseFunction pActiveFunction;
+ MouseFunctions aMouseFunctions;
};
- //====================================================================
+ //==================================================================================================================
//= DefaultInputHandler
- //====================================================================
- //--------------------------------------------------------------------
+ //==================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
DefaultInputHandler::DefaultInputHandler()
:m_pImpl( new DefaultInputHandler_Impl )
- ,m_bResize(false)
{
+ m_pImpl->aMouseFunctions.push_back( new ColumnResize );
+ m_pImpl->aMouseFunctions.push_back( new RowSelection );
+ m_pImpl->aMouseFunctions.push_back( new ColumnSortHandler );
}
- //--------------------------------------------------------------------
+ //------------------------------------------------------------------------------------------------------------------
DefaultInputHandler::~DefaultInputHandler()
{
- DELETEZ( m_pImpl );
}
- //--------------------------------------------------------------------
- bool DefaultInputHandler::MouseMove( IAbstractTableControl& _rControl, const MouseEvent& _rMEvt )
+ //------------------------------------------------------------------------------------------------------------------
+ namespace
{
- Point aPoint = _rMEvt.GetPosPixel();
- if(m_bResize)
+ bool lcl_delegateMouseEvent( DefaultInputHandler_Impl& i_impl, ITableControl& i_control, const MouseEvent& i_event,
+ FunctionResult ( IMouseFunction::*i_handlerMethod )( ITableControl&, const MouseEvent& ) )
{
- _rControl.resizeColumn(aPoint);
- return true;
- }
- return false;
- }
-
- //--------------------------------------------------------------------
- bool DefaultInputHandler::MouseButtonDown( IAbstractTableControl& _rControl, const MouseEvent& _rMEvt )
- {
- bool bHandled = false;
- Point aPoint = _rMEvt.GetPosPixel();
- RowPos nRow = _rControl.getCurrentRow(aPoint);
- if(nRow == -1)
- {
- m_bResize = _rControl.startResizeColumn(aPoint);
- bHandled = true;
- }
- else if(nRow >= 0)
- {
- if(_rControl.getSelEngine()->GetSelectionMode() == NO_SELECTION)
+ if ( i_impl.pActiveFunction.is() )
{
- _rControl.setCursorAtCurrentCell(aPoint);
- bHandled = true;
+ bool furtherHandler = false;
+ switch ( (i_impl.pActiveFunction.get()->*i_handlerMethod)( i_control, i_event ) )
+ {
+ case ActivateFunction:
+ OSL_ENSURE( false, "lcl_delegateMouseEvent: unexpected - function already *is* active!" );
+ break;
+ case ContinueFunction:
+ break;
+ case DeactivateFunction:
+ i_impl.pActiveFunction.clear();
+ break;
+ case SkipFunction:
+ furtherHandler = true;
+ break;
+ }
+ if ( !furtherHandler )
+ // handled the event
+ return true;
}
- else
+
+ // ask all other handlers
+ bool handled = false;
+ for ( MouseFunctions::iterator handler = i_impl.aMouseFunctions.begin();
+ ( handler != i_impl.aMouseFunctions.end() ) && !handled;
+ ++handler
+ )
{
- if(!_rControl.isRowSelected(nRow))
- bHandled = _rControl.getSelEngine()->SelMouseButtonDown(_rMEvt);
- else
- bHandled = true;
+ if ( *handler == i_impl.pActiveFunction )
+ // we already invoked this function
+ continue;
+
+ switch ( (handler->get()->*i_handlerMethod)( i_control, i_event ) )
+ {
+ case ActivateFunction:
+ i_impl.pActiveFunction = *handler;
+ handled = true;
+ break;
+ case ContinueFunction:
+ case DeactivateFunction:
+ OSL_ENSURE( false, "lcl_delegateMouseEvent: unexpected: inactivate handler cannot be continued or deactivated!" );
+ break;
+ case SkipFunction:
+ handled = false;
+ break;
+ }
}
+ return handled;
}
- return bHandled;
}
- //--------------------------------------------------------------------
- bool DefaultInputHandler::MouseButtonUp( IAbstractTableControl& _rControl, const MouseEvent& _rMEvt )
+
+ //------------------------------------------------------------------------------------------------------------------
+ bool DefaultInputHandler::MouseMove( ITableControl& i_tableControl, const MouseEvent& i_event )
{
- bool bHandled = false;
- Point aPoint = _rMEvt.GetPosPixel();
- if(_rControl.getCurrentRow(aPoint) >= 0)
- {
- if(m_bResize)
- {
- m_bResize = _rControl.endResizeColumn(aPoint);
- bHandled = true;
- }
- else if(_rControl.getSelEngine()->GetSelectionMode() == NO_SELECTION)
- {
- bHandled = true;
- }
- else
- {
- bHandled = _rControl.getSelEngine()->SelMouseButtonUp(_rMEvt);
- }
- }
- else
- {
- if(m_bResize)
- {
- m_bResize = _rControl.endResizeColumn(aPoint);
- bHandled = true;
- }
- }
- return bHandled;
+ return lcl_delegateMouseEvent( *m_pImpl, i_tableControl, i_event, &IMouseFunction::handleMouseMove );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ bool DefaultInputHandler::MouseButtonDown( ITableControl& i_tableControl, const MouseEvent& i_event )
+ {
+ return lcl_delegateMouseEvent( *m_pImpl, i_tableControl, i_event, &IMouseFunction::handleMouseDown );
}
- //--------------------------------------------------------------------
- bool DefaultInputHandler::KeyInput( IAbstractTableControl& _rControl, const KeyEvent& rKEvt )
+
+ //------------------------------------------------------------------------------------------------------------------
+ bool DefaultInputHandler::MouseButtonUp( ITableControl& i_tableControl, const MouseEvent& i_event )
+ {
+ return lcl_delegateMouseEvent( *m_pImpl, i_tableControl, i_event, &IMouseFunction::handleMouseUp );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ bool DefaultInputHandler::KeyInput( ITableControl& _rControl, const KeyEvent& rKEvt )
{
bool bHandled = false;
@@ -158,11 +170,11 @@ namespace svt { namespace table
{ KEY_PAGEDOWN, KEY_MOD1, cursorToLastLine },
{ KEY_HOME, KEY_MOD1, cursorTopLeft },
{ KEY_END, KEY_MOD1, cursorBottomRight },
- { KEY_SPACE, KEY_MOD1, cursorSelectRow },
- { KEY_UP, KEY_SHIFT, cursorSelectRowUp },
- { KEY_DOWN, KEY_SHIFT, cursorSelectRowDown },
- { KEY_END, KEY_SHIFT, cursorSelectRowAreaBottom },
- { KEY_HOME, KEY_SHIFT, cursorSelectRowAreaTop },
+ { KEY_SPACE, KEY_MOD1, cursorSelectRow },
+ { KEY_UP, KEY_SHIFT, cursorSelectRowUp },
+ { KEY_DOWN, KEY_SHIFT, cursorSelectRowDown },
+ { KEY_END, KEY_SHIFT, cursorSelectRowAreaBottom },
+ { KEY_HOME, KEY_SHIFT, cursorSelectRowAreaTop },
{ 0, 0, invalidTableControlAction }
};
@@ -173,7 +185,6 @@ namespace svt { namespace table
if ( ( pActions->nKeyCode == nKeyCode ) && ( pActions->nKeyModifier == rKeyCode.GetAllModifier() ) )
{
bHandled = _rControl.dispatchAction( pActions->eAction );
- bHandled = true; // always handled issue #i114340
break;
}
}
@@ -181,22 +192,22 @@ namespace svt { namespace table
return bHandled;
}
- //--------------------------------------------------------------------
- bool DefaultInputHandler::GetFocus( IAbstractTableControl& _rControl )
+ //------------------------------------------------------------------------------------------------------------------
+ bool DefaultInputHandler::GetFocus( ITableControl& _rControl )
{
_rControl.showCursor();
return false; // continue processing
}
- //--------------------------------------------------------------------
- bool DefaultInputHandler::LoseFocus( IAbstractTableControl& _rControl )
+ //------------------------------------------------------------------------------------------------------------------
+ bool DefaultInputHandler::LoseFocus( ITableControl& _rControl )
{
_rControl.hideCursor();
return false; // continue processing
}
- //--------------------------------------------------------------------
- bool DefaultInputHandler::RequestHelp( IAbstractTableControl& _rControl, const HelpEvent& _rHEvt )
+ //------------------------------------------------------------------------------------------------------------------
+ bool DefaultInputHandler::RequestHelp( ITableControl& _rControl, const HelpEvent& _rHEvt )
{
(void)_rControl;
(void)_rHEvt;
@@ -204,8 +215,8 @@ namespace svt { namespace table
return false;
}
- //--------------------------------------------------------------------
- bool DefaultInputHandler::Command( IAbstractTableControl& _rControl, const CommandEvent& _rCEvt )
+ //------------------------------------------------------------------------------------------------------------------
+ bool DefaultInputHandler::Command( ITableControl& _rControl, const CommandEvent& _rCEvt )
{
(void)_rControl;
(void)_rCEvt;
@@ -213,8 +224,8 @@ namespace svt { namespace table
return false;
}
- //--------------------------------------------------------------------
- bool DefaultInputHandler::PreNotify( IAbstractTableControl& _rControl, NotifyEvent& _rNEvt )
+ //------------------------------------------------------------------------------------------------------------------
+ bool DefaultInputHandler::PreNotify( ITableControl& _rControl, NotifyEvent& _rNEvt )
{
(void)_rControl;
(void)_rNEvt;
@@ -222,14 +233,14 @@ namespace svt { namespace table
return false;
}
- //--------------------------------------------------------------------
- bool DefaultInputHandler::Notify( IAbstractTableControl& _rControl, NotifyEvent& _rNEvt )
+ //------------------------------------------------------------------------------------------------------------------
+ bool DefaultInputHandler::Notify( ITableControl& _rControl, NotifyEvent& _rNEvt )
{
(void)_rControl;
(void)_rNEvt;
// TODO
return false;
}
-//........................................................................
+//......................................................................................................................
} } // namespace svt::table
-//........................................................................
+//......................................................................................................................
diff --git a/svtools/source/table/gridtablerenderer.cxx b/svtools/source/table/gridtablerenderer.cxx
index 5fb61a9f385e..1e230d372c24 100644
--- a/svtools/source/table/gridtablerenderer.cxx
+++ b/svtools/source/table/gridtablerenderer.cxx
@@ -27,51 +27,209 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_svtools.hxx"
+#include "cellvalueconversion.hxx"
#include "svtools/table/gridtablerenderer.hxx"
+#include "svtools/colorcfg.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/graphic/XGraphic.hpp>
+/** === end UNO includes === **/
#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
#include <vcl/window.hxx>
#include <vcl/image.hxx>
+#include <vcl/virdev.hxx>
+#include <vcl/decoview.hxx>
-//........................................................................
+//......................................................................................................................
namespace svt { namespace table
{
-//........................................................................
+//......................................................................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::uno::UNO_QUERY;
+ using ::com::sun::star::uno::XInterface;
+ using ::com::sun::star::uno::TypeClass_INTERFACE;
+ using ::com::sun::star::graphic::XGraphic;
+ using ::com::sun::star::style::HorizontalAlignment;
+ using ::com::sun::star::style::HorizontalAlignment_LEFT;
+ using ::com::sun::star::style::HorizontalAlignment_CENTER;
+ using ::com::sun::star::style::HorizontalAlignment_RIGHT;
+ using ::com::sun::star::style::VerticalAlignment;
+ using ::com::sun::star::style::VerticalAlignment_TOP;
+ using ::com::sun::star::style::VerticalAlignment_MIDDLE;
+ using ::com::sun::star::style::VerticalAlignment_BOTTOM;
+ /** === end UNO using === **/
+
+ //==================================================================================================================
+ //= CachedSortIndicator
+ //==================================================================================================================
+ class CachedSortIndicator
+ {
+ public:
+ CachedSortIndicator()
+ :m_lastHeaderHeight( 0 )
+ ,m_lastArrowColor( COL_TRANSPARENT )
+ {
+ }
+
+ BitmapEx const & getBitmapFor( OutputDevice const & i_device, long const i_headerHeight, StyleSettings const & i_style, bool const i_sortAscending );
+
+ private:
+ long m_lastHeaderHeight;
+ Color m_lastArrowColor;
+ BitmapEx m_sortAscending;
+ BitmapEx m_sortDescending;
+ };
+
+ //------------------------------------------------------------------------------------------------------------------
+ BitmapEx const & CachedSortIndicator::getBitmapFor( OutputDevice const & i_device, long const i_headerHeight,
+ StyleSettings const & i_style, bool const i_sortAscending )
+ {
+ BitmapEx & rBitmap( i_sortAscending ? m_sortAscending : m_sortDescending );
+ if ( !rBitmap || ( i_headerHeight != m_lastHeaderHeight ) || ( i_style.GetActiveColor() != m_lastArrowColor ) )
+ {
+ long const nSortIndicatorWidth = 2 * i_headerHeight / 3;
+ long const nSortIndicatorHeight = 2 * nSortIndicatorWidth / 3;
+
+ Point const aBitmapPos( 0, 0 );
+ Size const aBitmapSize( nSortIndicatorWidth, nSortIndicatorHeight );
+ VirtualDevice aDevice( i_device, 0, 0 );
+ aDevice.SetOutputSizePixel( aBitmapSize );
+
+ DecorationView aDecoView( &aDevice );
+ aDecoView.DrawSymbol(
+ Rectangle( aBitmapPos, aBitmapSize ),
+ i_sortAscending ? SYMBOL_SPIN_UP : SYMBOL_SPIN_DOWN,
+ i_style.GetActiveColor()
+ );
+
+ rBitmap = aDevice.GetBitmapEx( aBitmapPos, aBitmapSize );
+ m_lastHeaderHeight = i_headerHeight;
+ m_lastArrowColor = i_style.GetActiveColor();
+ }
+ return rBitmap;
+ }
+ //==================================================================================================================
+ //= GridTableRenderer_Impl
+ //==================================================================================================================
struct GridTableRenderer_Impl
{
- ITableModel& rModel;
- RowPos nCurrentRow;
+ ITableModel& rModel;
+ RowPos nCurrentRow;
+ bool bUseGridLines;
+ CachedSortIndicator aSortIndicator;
GridTableRenderer_Impl( ITableModel& _rModel )
:rModel( _rModel )
,nCurrentRow( ROW_INVALID )
+ ,bUseGridLines( true )
{
}
};
- //====================================================================
+ //==================================================================================================================
+ //= helper
+ //==================================================================================================================
+ namespace
+ {
+ static Rectangle lcl_getContentArea( GridTableRenderer_Impl const & i_impl, Rectangle const & i_cellArea )
+ {
+ Rectangle aContentArea( i_cellArea );
+ if ( i_impl.bUseGridLines )
+ {
+ --aContentArea.Right();
+ --aContentArea.Bottom();
+ }
+ return aContentArea;
+ }
+ static Rectangle lcl_getTextRenderingArea( Rectangle const & i_contentArea )
+ {
+ Rectangle aTextArea( i_contentArea );
+ aTextArea.Left() += 2; aTextArea.Right() -= 2;
+ ++aTextArea.Top(); --aTextArea.Bottom();
+ return aTextArea;
+ }
+
+ static sal_uLong lcl_getAlignmentTextDrawFlags( GridTableRenderer_Impl const & i_impl, ColPos const i_columnPos )
+ {
+ sal_uLong nVertFlag = TEXT_DRAW_TOP;
+ VerticalAlignment const eVertAlign = i_impl.rModel.getVerticalAlign();
+ switch ( eVertAlign )
+ {
+ case VerticalAlignment_MIDDLE: nVertFlag = TEXT_DRAW_VCENTER; break;
+ case VerticalAlignment_BOTTOM: nVertFlag = TEXT_DRAW_BOTTOM; break;
+ default:
+ break;
+ }
+
+ sal_uLong nHorzFlag = TEXT_DRAW_LEFT;
+ HorizontalAlignment const eHorzAlign = i_impl.rModel.getColumnModel( i_columnPos )->getHorizontalAlign();
+ switch ( eHorzAlign )
+ {
+ case HorizontalAlignment_CENTER: nHorzFlag = TEXT_DRAW_CENTER; break;
+ case HorizontalAlignment_RIGHT: nHorzFlag = TEXT_DRAW_RIGHT; break;
+ default:
+ break;
+ }
+
+ return nVertFlag | nHorzFlag;
+ }
+
+ }
+
+ //==================================================================================================================
//= GridTableRenderer
- //====================================================================
- //--------------------------------------------------------------------
+ //==================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
GridTableRenderer::GridTableRenderer( ITableModel& _rModel )
:m_pImpl( new GridTableRenderer_Impl( _rModel ) )
{
}
- //--------------------------------------------------------------------
+ //------------------------------------------------------------------------------------------------------------------
GridTableRenderer::~GridTableRenderer()
{
- DELETEZ( m_pImpl );
}
- //--------------------------------------------------------------------
- RowPos GridTableRenderer::getCurrentRow()
+ //------------------------------------------------------------------------------------------------------------------
+ RowPos GridTableRenderer::getCurrentRow() const
{
return m_pImpl->nCurrentRow;
}
- //--------------------------------------------------------------------
+ //------------------------------------------------------------------------------------------------------------------
+ bool GridTableRenderer::useGridLines() const
+ {
+ return m_pImpl->bUseGridLines;
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void GridTableRenderer::useGridLines( bool const i_use )
+ {
+ m_pImpl->bUseGridLines = i_use;
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ namespace
+ {
+ Color lcl_getEffectiveColor(
+ ::boost::optional< ::Color > const & i_modelColor,
+ StyleSettings const & i_styleSettings,
+ ::Color const & ( StyleSettings::*i_getDefaultColor ) () const
+ )
+ {
+ if ( !!i_modelColor )
+ return *i_modelColor;
+ return ( i_styleSettings.*i_getDefaultColor )();
+ }
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
void GridTableRenderer::PaintHeaderArea(
OutputDevice& _rDevice, const Rectangle& _rArea, bool _bIsColHeaderArea, bool _bIsRowHeaderArea,
const StyleSettings& _rStyle )
@@ -79,15 +237,18 @@ namespace svt { namespace table
OSL_PRECOND( _bIsColHeaderArea || _bIsRowHeaderArea,
"GridTableRenderer::PaintHeaderArea: invalid area flags!" );
- _rDevice.Push( PUSH_FILLCOLOR | PUSH_LINECOLOR);
- Color background = m_pImpl->rModel.getHeaderBackgroundColor();
- if( background != 0xFFFFFF)
- _rDevice.SetFillColor(background);
- else
- _rDevice.SetFillColor(_rStyle.GetDialogColor());
- _rDevice.SetLineColor(_rStyle.GetSeparatorColor());
+ _rDevice.Push( PUSH_FILLCOLOR | PUSH_LINECOLOR );
+
+ Color const background = lcl_getEffectiveColor( m_pImpl->rModel.getHeaderBackgroundColor(), _rStyle, &StyleSettings::GetDialogColor );
+ _rDevice.SetFillColor( background );
+
+ _rDevice.SetLineColor();
_rDevice.DrawRect( _rArea );
+
// delimiter lines at bottom/right
+ ::boost::optional< ::Color > aLineColor( m_pImpl->rModel.getLineColor() );
+ ::Color const lineColor = !aLineColor ? _rStyle.GetSeparatorColor() : *aLineColor;
+ _rDevice.SetLineColor( lineColor );
_rDevice.DrawLine( _rArea.BottomLeft(), _rArea.BottomRight() );
_rDevice.DrawLine( _rArea.BottomRight(), _rArea.TopRight() );
@@ -96,48 +257,73 @@ namespace svt { namespace table
(void)_bIsRowHeaderArea;
}
- //--------------------------------------------------------------------
+ //------------------------------------------------------------------------------------------------------------------
void GridTableRenderer::PaintColumnHeader( ColPos _nCol, bool _bActive, bool _bSelected,
OutputDevice& _rDevice, const Rectangle& _rArea, const StyleSettings& _rStyle )
{
_rDevice.Push( PUSH_LINECOLOR);
- _rDevice.SetLineColor(_rStyle.GetSeparatorColor());
- _rDevice.DrawLine( _rArea.BottomRight(), _rArea.TopRight());
String sHeaderText;
- PColumnModel pColumn = m_pImpl->rModel.getColumnModel( _nCol );
+ PColumnModel const pColumn = m_pImpl->rModel.getColumnModel( _nCol );
DBG_ASSERT( !!pColumn, "GridTableRenderer::PaintColumnHeader: invalid column model object!" );
if ( !!pColumn )
sHeaderText = pColumn->getName();
- if(m_pImpl->rModel.getTextColor() != 0x000000)
- _rDevice.SetTextColor(m_pImpl->rModel.getTextColor());
- else
- _rDevice.SetTextColor(_rStyle.GetFieldTextColor());
- sal_uLong nHorFlag = TEXT_DRAW_LEFT;
- sal_uLong nVerFlag = TEXT_DRAW_TOP;
- if(m_pImpl->rModel.getVerticalAlign() == 1)
- nVerFlag = TEXT_DRAW_VCENTER;
- else if(m_pImpl->rModel.getVerticalAlign() == 2)
- nVerFlag = TEXT_DRAW_BOTTOM;
- if(m_pImpl->rModel.getColumnModel(_nCol)->getHorizontalAlign() == 1)
- nHorFlag = TEXT_DRAW_CENTER;
- else if(m_pImpl->rModel.getColumnModel(_nCol)->getHorizontalAlign() == 2)
- nHorFlag = TEXT_DRAW_RIGHT;
- Rectangle aRect(_rArea);
- aRect.Left()+=4; aRect.Right()-=4;
- aRect.Bottom()-=2;
- _rDevice.DrawText( aRect, sHeaderText, nHorFlag | nVerFlag | TEXT_DRAW_CLIP);
+
+ ::Color const textColor = lcl_getEffectiveColor( m_pImpl->rModel.getTextColor(), _rStyle, &StyleSettings::GetFieldTextColor );
+ _rDevice.SetTextColor( textColor );
+
+ Rectangle const aTextRect( lcl_getTextRenderingArea( lcl_getContentArea( *m_pImpl, _rArea ) ) );
+ sal_uLong const nDrawTextFlags = lcl_getAlignmentTextDrawFlags( *m_pImpl, _nCol ) | TEXT_DRAW_CLIP;
+ _rDevice.DrawText( aTextRect, sHeaderText, nDrawTextFlags );
+
+ ::boost::optional< ::Color > const aLineColor( m_pImpl->rModel.getLineColor() );
+ ::Color const lineColor = !aLineColor ? _rStyle.GetSeparatorColor() : *aLineColor;
+ _rDevice.SetLineColor( lineColor );
+ _rDevice.DrawLine( _rArea.BottomRight(), _rArea.TopRight());
_rDevice.DrawLine( _rArea.BottomLeft(), _rArea.BottomRight() );
+
+ // draw sort indicator if the model data is sorted by the given column
+ ITableDataSort const * pSortAdapter = m_pImpl->rModel.getSortAdapter();
+ ColumnSort aCurrentSortOrder;
+ if ( pSortAdapter != NULL )
+ aCurrentSortOrder = pSortAdapter->getCurrentSortOrder();
+ if ( aCurrentSortOrder.nColumnPos == _nCol )
+ {
+ long const nHeaderHeight( _rArea.GetHeight() );
+ BitmapEx const aIndicatorBitmap = m_pImpl->aSortIndicator.getBitmapFor( _rDevice, nHeaderHeight, _rStyle,
+ aCurrentSortOrder.eSortDirection == ColumnSortAscending );
+ Size const aBitmapSize( aIndicatorBitmap.GetSizePixel() );
+ long const nSortIndicatorPaddingX = 2;
+ long const nSortIndicatorPaddingY = ( nHeaderHeight - aBitmapSize.Height() ) / 2;
+
+ if ( ( nDrawTextFlags & TEXT_DRAW_RIGHT ) != 0 )
+ {
+ // text is right aligned => draw the sort indicator at the left hand side
+ _rDevice.DrawBitmapEx(
+ Point( _rArea.Left() + nSortIndicatorPaddingX, _rArea.Top() + nSortIndicatorPaddingY ),
+ aIndicatorBitmap
+ );
+ }
+ else
+ {
+ // text is left-aligned or centered => draw the sort indicator at the right hand side
+ _rDevice.DrawBitmapEx(
+ Point( _rArea.Right() - nSortIndicatorPaddingX - aBitmapSize.Width(), nSortIndicatorPaddingY ),
+ aIndicatorBitmap
+ );
+ }
+ }
+
_rDevice.Pop();
(void)_bActive;
// no special painting for the active column at the moment
(void)_bSelected;
- //selection for column header not yet implemented
+ // selection for column header not yet implemented
}
- //--------------------------------------------------------------------
+ //------------------------------------------------------------------------------------------------------------------
void GridTableRenderer::PrepareRow( RowPos _nRow, bool _bActive, bool _bSelected,
OutputDevice& _rDevice, const Rectangle& _rRowArea, const StyleSettings& _rStyle )
{
@@ -146,237 +332,288 @@ namespace svt { namespace table
_rDevice.Push( PUSH_FILLCOLOR | PUSH_LINECOLOR);
- Color aRowBackground = m_pImpl->rModel.getOddRowBackgroundColor();
- Color line = m_pImpl->rModel.getLineColor();
- Color aRowBackground2 = m_pImpl->rModel.getEvenRowBackgroundColor();
- Color fieldColor = _rStyle.GetFieldColor();
- if(aRowBackground == 0xFFFFFF)
- aRowBackground = fieldColor;
- if(aRowBackground2 == 0xFFFFFF)
- aRowBackground2 = fieldColor;
- //if row is selected background color becomes blue, and lines should be also blue
- //if they aren't user defined
- if(_bSelected)
+ ::Color backgroundColor = _rStyle.GetFieldColor();
+
+ ::boost::optional< ::Color > aLineColor( m_pImpl->rModel.getLineColor() );
+ ::Color lineColor = !aLineColor ? _rStyle.GetSeparatorColor() : *aLineColor;
+
+ if ( _bSelected )
{
- Color aSelected(_rStyle.GetHighlightColor());
- aRowBackground = aSelected;
- if(line == 0xFFFFFF)
- _rDevice.SetLineColor(aRowBackground);
- else
- _rDevice.SetLineColor(line);
+ // selected rows use the background color from the style
+ backgroundColor = _rStyle.GetHighlightColor();
+ if ( !aLineColor )
+ lineColor = backgroundColor;
}
- //if row not selected, check the cases whether user defined backgrounds are set
- //and set line color to be the same
else
{
- if(aRowBackground2 != fieldColor && _nRow%2)
+ ::boost::optional< ::std::vector< ::Color > > aRowColors = m_pImpl->rModel.getRowBackgroundColors();
+ if ( !aRowColors )
{
- aRowBackground = aRowBackground2;
- if(line == 0xFFFFFF)
- _rDevice.SetLineColor(aRowBackground);
+ // use alternating default colors
+ Color const fieldColor = _rStyle.GetFieldColor();
+ if ( _rStyle.GetHighContrastMode() || ( ( m_pImpl->nCurrentRow % 2 ) == 0 ) )
+ {
+ backgroundColor = fieldColor;
+ }
else
- _rDevice.SetLineColor(line);
+ {
+ Color hilightColor = _rStyle.GetHighlightColor();
+ hilightColor.SetRed( 9 * ( fieldColor.GetRed() - hilightColor.GetRed() ) / 10 + hilightColor.GetRed() );
+ hilightColor.SetGreen( 9 * ( fieldColor.GetGreen() - hilightColor.GetGreen() ) / 10 + hilightColor.GetGreen() );
+ hilightColor.SetBlue( 9 * ( fieldColor.GetBlue() - hilightColor.GetBlue() ) / 10 + hilightColor.GetBlue() );
+ backgroundColor = hilightColor;
+ }
}
- //fill the rows with alternating background colors if second background color is specified
- else if(aRowBackground != fieldColor && line == 0xFFFFFF)
- _rDevice.SetLineColor(aRowBackground);
else
{
- //if Line color is set, then it was user defined and should be visible
- //if it wasn't set, it'll be the same as the default background color, so lines still won't be visible
- _rDevice.SetLineColor(line);
+ if ( aRowColors->empty() )
+ {
+ // all colors have the same background color
+ backgroundColor = _rStyle.GetFieldColor();
+ }
+ else
+ {
+ backgroundColor = aRowColors->at( m_pImpl->nCurrentRow % aRowColors->size() );
+ }
}
}
- _rDevice.SetFillColor( aRowBackground );
- _rDevice.DrawRect( _rRowArea );
- // TODO: active?
+ //m_pImpl->bUseGridLines ? _rDevice.SetLineColor( lineColor ) : _rDevice.SetLineColor();
+ _rDevice.SetLineColor();
+ _rDevice.SetFillColor( backgroundColor );
+ _rDevice.DrawRect( _rRowArea );
_rDevice.Pop();
+
(void)_bActive;
+ // row containing the active cell not rendered any special at the moment
}
- //--------------------------------------------------------------------
+ //------------------------------------------------------------------------------------------------------------------
void GridTableRenderer::PaintRowHeader( bool _bActive, bool _bSelected, OutputDevice& _rDevice, const Rectangle& _rArea,
- const StyleSettings& _rStyle, rtl::OUString& _rText )
+ const StyleSettings& _rStyle )
{
- _rDevice.Push( PUSH_LINECOLOR);
- _rDevice.SetLineColor(_rStyle.GetSeparatorColor());
+ _rDevice.Push( PUSH_LINECOLOR | PUSH_TEXTCOLOR );
+
+ ::boost::optional< ::Color > const aLineColor( m_pImpl->rModel.getLineColor() );
+ ::Color const lineColor = !aLineColor ? _rStyle.GetSeparatorColor() : *aLineColor;
+ _rDevice.SetLineColor( lineColor );
_rDevice.DrawLine( _rArea.BottomLeft(), _rArea.BottomRight() );
- if(m_pImpl->rModel.getTextColor() != 0x000000)
- _rDevice.SetTextColor(m_pImpl->rModel.getTextColor());
- else
- _rDevice.SetTextColor(_rStyle.GetFieldTextColor());
- sal_uLong nHorFlag = TEXT_DRAW_LEFT;
- sal_uLong nVerFlag = TEXT_DRAW_TOP;
- if(m_pImpl->rModel.getVerticalAlign() == 1)
- nVerFlag = TEXT_DRAW_VCENTER;
- else if(m_pImpl->rModel.getVerticalAlign() == 2)
- nVerFlag = TEXT_DRAW_BOTTOM;
- if(m_pImpl->rModel.getColumnModel(0)->getHorizontalAlign() == 1)
- nHorFlag = TEXT_DRAW_CENTER;
- else if(m_pImpl->rModel.getColumnModel(0)->getHorizontalAlign() == 2)
- nHorFlag = TEXT_DRAW_RIGHT;
- Rectangle aRect(_rArea);
- aRect.Left()+=4; aRect.Right()-=4;
- aRect.Bottom()-=2;
- _rDevice.DrawText( aRect, _rText, nHorFlag | nVerFlag | TEXT_DRAW_CLIP);
+
+ Any const rowHeading( m_pImpl->rModel.getRowHeading( m_pImpl->nCurrentRow ) );
+ ::rtl::OUString const rowTitle( CellValueConversion::convertToString( rowHeading ) );
+ if ( rowTitle.getLength() )
+ {
+ ::Color const textColor = lcl_getEffectiveColor( m_pImpl->rModel.getHeaderTextColor(), _rStyle, &StyleSettings::GetFieldTextColor );
+ _rDevice.SetTextColor( textColor );
+
+ Rectangle const aTextRect( lcl_getTextRenderingArea( lcl_getContentArea( *m_pImpl, _rArea ) ) );
+ sal_uLong const nDrawTextFlags = lcl_getAlignmentTextDrawFlags( *m_pImpl, 0 ) | TEXT_DRAW_CLIP;
+ // TODO: is using the horizontal alignment of the 0'th column a good idea here? This is pretty ... arbitray ..
+ _rDevice.DrawText( aTextRect, rowTitle, nDrawTextFlags );
+ }
+
// TODO: active? selected?
(void)_bActive;
(void)_bSelected;
- //at the moment no special paint for selected row header
_rDevice.Pop();
}
- //--------------------------------------------------------------------
- void GridTableRenderer::PaintCellImage( ColPos _nColumn, bool _bSelected, bool _bActive,
- OutputDevice& _rDevice, const Rectangle& _rArea, const StyleSettings& _rStyle, Image* _pCellData )
- {
- _rDevice.Push( PUSH_LINECOLOR | PUSH_FILLCOLOR);
- Color background1 = m_pImpl->rModel.getOddRowBackgroundColor();
- Color background2 = m_pImpl->rModel.getEvenRowBackgroundColor();
- Color line = m_pImpl->rModel.getLineColor();
- //if row is selected and line color isn't user specified, set it blue
- if(_bSelected)
+ //------------------------------------------------------------------------------------------------------------------
+ struct GridTableRenderer::CellRenderContext
+ {
+ OutputDevice& rDevice;
+ Rectangle const aContentArea;
+ StyleSettings const & rStyle;
+ ColPos const nColumn;
+ bool const bSelected;
+
+ CellRenderContext( OutputDevice& i_device, Rectangle const & i_contentArea,
+ StyleSettings const & i_style, ColPos const i_column, bool const i_selected )
+ :rDevice( i_device )
+ ,aContentArea( i_contentArea )
+ ,rStyle( i_style )
+ ,nColumn( i_column )
+ ,bSelected( i_selected )
{
- if(line == 0xFFFFFF)
- _rDevice.SetLineColor(_rStyle.GetHighlightColor());
- else
- _rDevice.SetLineColor(line);
}
- //else set line color to the color of row background
- else
+ };
+
+ //------------------------------------------------------------------------------------------------------------------
+ void GridTableRenderer::PaintCell( ColPos const i_column, bool _bSelected, bool _bActive,
+ OutputDevice& _rDevice, const Rectangle& _rArea, const StyleSettings& _rStyle )
+ {
+ _rDevice.Push( PUSH_LINECOLOR | PUSH_FILLCOLOR );
+
+ Rectangle const aContentArea( lcl_getContentArea( *m_pImpl, _rArea ) );
+ CellRenderContext const aRenderContext( _rDevice, aContentArea, _rStyle, i_column, _bSelected );
+ impl_paintCellContent( aRenderContext );
+
+ if ( m_pImpl->bUseGridLines )
{
- if(background2 != 0xFFFFFF && m_pImpl->nCurrentRow%2)
- {
- if(line == 0xFFFFFF)
- _rDevice.SetLineColor(background2);
- else
- _rDevice.SetLineColor(line);
- }
- else if(background1 != 0xFFFFFF && line == 0xFFFFFF)
- _rDevice.SetLineColor(background1);
- else
+ ::boost::optional< ::Color > aLineColor( m_pImpl->rModel.getLineColor() );
+ ::Color lineColor = !aLineColor ? _rStyle.GetSeparatorColor() : *aLineColor;
+
+ if ( _bSelected && !aLineColor )
{
- //if line color is set, then it was user defined and should be visible
- //if it wasn't set, it'll be the same as the default background color, so lines still won't be visible
- _rDevice.SetLineColor(line);
+ // if no line color is specified by the model, use the usual selection color for lines in selected cells
+ lineColor = _rStyle.GetHighlightColor();
}
- }
- _rDevice.DrawLine( _rArea.BottomRight(), _rArea.TopRight() );
- Rectangle aRect( _rArea );
- ++aRect.Left(); --aRect.Right();
- aRect.Top(); aRect.Bottom();
- Point imagePos(Point(aRect.Left(), aRect.Top()));
- Size imageSize = _pCellData->GetSizePixel();
- if(aRect.GetWidth() > imageSize.Width())
- {
- if(m_pImpl->rModel.getColumnModel(_nColumn)->getHorizontalAlign() == 1)
- imagePos.X() = aRect.Left()+((double)(aRect.GetWidth() - imageSize.Width()))/2;
- else if(m_pImpl->rModel.getColumnModel(_nColumn)->getHorizontalAlign() == 2)
- imagePos.X() = aRect.Right() - imageSize.Width();
- }
- else
- imageSize.Width() = aRect.GetWidth();
- if(aRect.GetHeight() > imageSize.Height())
- {
- if(m_pImpl->rModel.getVerticalAlign() == 1)
- imagePos.Y() = aRect.Top()+((double)(aRect.GetHeight() - imageSize.Height()))/2;
- else if(m_pImpl->rModel.getVerticalAlign() == 2)
- imagePos.Y() = aRect.Bottom() - imageSize.Height();
+ _rDevice.SetLineColor( lineColor );
+ _rDevice.DrawLine( _rArea.BottomLeft(), _rArea.BottomRight() );
+ _rDevice.DrawLine( _rArea.BottomRight(), _rArea.TopRight() );
}
- else
- imageSize.Height() = aRect.GetHeight()-1;
- Image& image (*_pCellData);
- _rDevice.DrawImage(imagePos, imageSize, image, 0);
+
_rDevice.Pop();
(void)_bActive;
// no special painting for the active cell at the moment
}
- //--------------------------------------------------------------------
- void GridTableRenderer::PaintCellString( ColPos _nColumn, bool _bSelected, bool _bActive,
- OutputDevice& _rDevice, const Rectangle& _rArea, const StyleSettings& _rStyle, rtl::OUString& _rText )
- {
- _rDevice.Push( PUSH_LINECOLOR | PUSH_FILLCOLOR );
- Color background1 = m_pImpl->rModel.getOddRowBackgroundColor();
- Color background2 = m_pImpl->rModel.getEvenRowBackgroundColor();
- Color line = m_pImpl->rModel.getLineColor();
- //if row is selected and line color isn't user specified, set it blue
- if(_bSelected)
+ //------------------------------------------------------------------------------------------------------------------
+ void GridTableRenderer::impl_paintCellImage( CellRenderContext const & i_context, Image const & i_image )
+ {
+ Point imagePos( Point( i_context.aContentArea.Left(), i_context.aContentArea.Top() ) );
+ Size imageSize = i_image.GetSizePixel();
+ if ( i_context.aContentArea.GetWidth() > imageSize.Width() )
{
- if(line == 0xFFFFFF)
- _rDevice.SetLineColor(_rStyle.GetHighlightColor());
- else
- _rDevice.SetLineColor(line);
+ const HorizontalAlignment eHorzAlign = m_pImpl->rModel.getColumnModel( i_context.nColumn )->getHorizontalAlign();
+ switch ( eHorzAlign )
+ {
+ case HorizontalAlignment_CENTER:
+ imagePos.X() += ( i_context.aContentArea.GetWidth() - imageSize.Width() ) / 2;
+ break;
+ case HorizontalAlignment_RIGHT:
+ imagePos.X() = i_context.aContentArea.Right() - imageSize.Width();
+ break;
+ default:
+ break;
+ }
+
}
- //else set line color to the color of row background
else
+ imageSize.Width() = i_context.aContentArea.GetWidth();
+
+ if ( i_context.aContentArea.GetHeight() > imageSize.Height() )
{
- if(background2 != 0xFFFFFF && m_pImpl->nCurrentRow%2)
+ const VerticalAlignment eVertAlign = m_pImpl->rModel.getVerticalAlign();
+ switch ( eVertAlign )
{
- if(line == 0xFFFFFF)
- _rDevice.SetLineColor(background2);
- else
- _rDevice.SetLineColor(line);
- }
- else if(background1 != 0xFFFFFF && line == 0xFFFFFF)
- _rDevice.SetLineColor(background1);
- else
- {
- //if Line color is set, then it was user defined and should be visible
- //if it wasn't set, it'll be the same as the default background color, so lines still won't be visible
- _rDevice.SetLineColor(line);
+ case VerticalAlignment_MIDDLE:
+ imagePos.Y() += ( i_context.aContentArea.GetHeight() - imageSize.Height() ) / 2;
+ break;
+ case VerticalAlignment_BOTTOM:
+ imagePos.Y() = i_context.aContentArea.Bottom() - imageSize.Height();
+ break;
+ default:
+ break;
}
}
- _rDevice.DrawLine( _rArea.BottomRight(), _rArea.TopRight() );
+ else
+ imageSize.Height() = i_context.aContentArea.GetHeight() - 1;
+
+ i_context.rDevice.DrawImage( imagePos, imageSize, i_image, 0 );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void GridTableRenderer::impl_paintCellContent( CellRenderContext const & i_context )
+ {
+ Any aCellContent;
+ m_pImpl->rModel.getCellContent( i_context.nColumn, m_pImpl->nCurrentRow, aCellContent );
+
+ if ( aCellContent.getValueTypeClass() == TypeClass_INTERFACE )
+ {
+ Reference< XInterface > const xContentInterface( aCellContent, UNO_QUERY );
+ if ( !xContentInterface.is() )
+ // allowed. kind of.
+ return;
- Rectangle aRect( _rArea );
- ++aRect.Left(); --aRect.Right();
- aRect.Top(); aRect.Bottom();
- if(_bSelected)
- _rDevice.SetTextColor(_rStyle.GetHighlightTextColor());
- else if(m_pImpl->rModel.getTextColor() != 0x000000)
- _rDevice.SetTextColor(m_pImpl->rModel.getTextColor());
+ Reference< XGraphic > const xGraphic( aCellContent, UNO_QUERY );
+ ENSURE_OR_RETURN_VOID( xGraphic.is(), "GridTableRenderer::impl_paintCellContent: only XGraphic interfaces (or NULL) are supported for painting." );
+
+ const Image aImage( xGraphic );
+ impl_paintCellImage( i_context, aImage );
+ return;
+ }
+
+ const ::rtl::OUString sText( CellValueConversion::convertToString( aCellContent ) );
+ impl_paintCellText( i_context, sText );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void GridTableRenderer::impl_paintCellText( CellRenderContext const & i_context, ::rtl::OUString const & i_text )
+ {
+ if ( i_context.bSelected )
+ i_context.rDevice.SetTextColor( i_context.rStyle.GetHighlightTextColor() );
else
- _rDevice.SetTextColor(_rStyle.GetFieldTextColor());
- sal_uLong nHorFlag = TEXT_DRAW_LEFT;
- sal_uLong nVerFlag = TEXT_DRAW_TOP;
- if(m_pImpl->rModel.getVerticalAlign() == 1)
- nVerFlag = TEXT_DRAW_VCENTER;
- else if(m_pImpl->rModel.getVerticalAlign() == 2)
- nVerFlag = TEXT_DRAW_BOTTOM;
- if(m_pImpl->rModel.getColumnModel(_nColumn)->getHorizontalAlign() == 1)
- nHorFlag = TEXT_DRAW_CENTER;
- else if(m_pImpl->rModel.getColumnModel(_nColumn)->getHorizontalAlign() == 2)
- nHorFlag = TEXT_DRAW_RIGHT;
- Rectangle textRect(_rArea);
- textRect.Left()+=4; textRect.Right()-=4;
- textRect.Bottom()-=2;
- _rDevice.DrawText( textRect, _rText, nHorFlag | nVerFlag | TEXT_DRAW_CLIP);
+ {
+ ::Color const textColor = lcl_getEffectiveColor( m_pImpl->rModel.getTextColor(), i_context.rStyle, &StyleSettings::GetFieldTextColor );
+ i_context.rDevice.SetTextColor( textColor );
+ }
- _rDevice.Pop();
- (void)_bActive;
- // no special painting for the active cell at the moment
+ Rectangle const textRect( lcl_getTextRenderingArea( i_context.aContentArea ) );
+ sal_uLong const nDrawTextFlags = lcl_getAlignmentTextDrawFlags( *m_pImpl, i_context.nColumn ) | TEXT_DRAW_CLIP;
+ i_context.rDevice.DrawText( textRect, i_text, nDrawTextFlags );
}
- //--------------------------------------------------------------------
+ //------------------------------------------------------------------------------------------------------------------
void GridTableRenderer::ShowCellCursor( Window& _rView, const Rectangle& _rCursorRect)
{
_rView.ShowFocus( _rCursorRect );
}
- //--------------------------------------------------------------------
+ //------------------------------------------------------------------------------------------------------------------
void GridTableRenderer::HideCellCursor( Window& _rView, const Rectangle& _rCursorRect)
{
- (void)_rCursorRect;
+ (void)_rCursorRect;
_rView.HideFocus();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ bool GridTableRenderer::FitsIntoCell( Any const & i_cellContent, ColPos const i_colPos, RowPos const i_rowPos,
+ bool const i_active, bool const i_selected, OutputDevice& i_targetDevice, Rectangle const & i_targetArea )
+ {
+ if ( !i_cellContent.hasValue() )
+ return true;
+
+ if ( i_cellContent.getValueTypeClass() == TypeClass_INTERFACE )
+ {
+ Reference< XInterface > const xContentInterface( i_cellContent, UNO_QUERY );
+ if ( !xContentInterface.is() )
+ return true;
+
+ Reference< XGraphic > const xGraphic( i_cellContent, UNO_QUERY );
+ if ( xGraphic.is() )
+ // for the moment, assume it fits. We can always scale it down during painting ...
+ return true;
+
+ OSL_ENSURE( false, "GridTableRenderer::FitsIntoCell: only XGraphic interfaces (or NULL) are supported for painting." );
+ return true;
+ }
+
+ ::rtl::OUString const sText( CellValueConversion::convertToString( i_cellContent ) );
+ if ( sText.getLength() == 0 )
+ return true;
+
+ Rectangle const aTargetArea( lcl_getTextRenderingArea( lcl_getContentArea( *m_pImpl, i_targetArea ) ) );
+
+ long const nTextHeight = i_targetDevice.GetTextHeight();
+ if ( nTextHeight > aTargetArea.GetHeight() )
+ return false;
+
+ long const nTextWidth = i_targetDevice.GetTextWidth( sText );
+ if ( nTextWidth > aTargetArea.GetWidth() )
+ return false;
+ OSL_UNUSED( i_active );
+ OSL_UNUSED( i_selected );
+ OSL_UNUSED( i_rowPos );
+ OSL_UNUSED( i_colPos );
+ return true;
}
-//........................................................................
+//......................................................................................................................
} } // namespace svt::table
-//........................................................................
+//......................................................................................................................
diff --git a/svtools/source/table/mousefunction.cxx b/svtools/source/table/mousefunction.cxx
new file mode 100755
index 000000000000..20d505e911e9
--- /dev/null
+++ b/svtools/source/table/mousefunction.cxx
@@ -0,0 +1,320 @@
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include "precompiled_svtools.hxx"
+
+#include "mousefunction.hxx"
+#include "svtools/table/tablecontrolinterface.hxx"
+
+#include <tools/diagnose_ex.h>
+#include <vcl/window.hxx>
+
+//......................................................................................................................
+namespace svt { namespace table
+{
+//......................................................................................................................
+
+ //==================================================================================================================
+ //= MouseFunction
+ //==================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
+ oslInterlockedCount MouseFunction::acquire()
+ {
+ return osl_incrementInterlockedCount( &m_refCount );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ oslInterlockedCount MouseFunction::release()
+ {
+ oslInterlockedCount newCount = osl_decrementInterlockedCount( &m_refCount );
+ if ( newCount == 0 )
+ {
+ delete this;
+ return 0;
+ }
+ return newCount;
+ }
+
+ //==================================================================================================================
+ //= ColumnResize
+ //==================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
+ FunctionResult ColumnResize::handleMouseMove( ITableControl& i_tableControl, MouseEvent const & i_event )
+ {
+ Point const aPoint = i_event.GetPosPixel();
+
+ if ( m_nResizingColumn == COL_INVALID )
+ {
+ // if we hit a column divider, change the mosue pointer accordingly
+ Pointer aNewPointer( POINTER_ARROW );
+ TableCell const tableCell = i_tableControl.hitTest( aPoint );
+ if ( ( tableCell.nRow == ROW_COL_HEADERS ) && ( tableCell.eArea == ColumnDivider ) )
+ {
+ aNewPointer = Pointer( POINTER_HSPLIT );
+ }
+ i_tableControl.setPointer( aNewPointer );
+
+ return SkipFunction; // TODO: is this correct?
+ }
+
+ ::Size const tableSize = i_tableControl.getTableSizePixel();
+
+ // set proper pointer
+ Pointer aNewPointer( POINTER_ARROW );
+ ColumnMetrics const & columnMetrics( i_tableControl.getColumnMetrics( m_nResizingColumn ) );
+ if ( ( aPoint.X() > tableSize.Width() )
+ || ( aPoint.X() < columnMetrics.nStartPixel )
+ )
+ {
+ aNewPointer = Pointer( POINTER_NOTALLOWED );
+ }
+ else
+ {
+ aNewPointer = Pointer( POINTER_HSPLIT );
+ }
+ i_tableControl.setPointer( aNewPointer );
+
+ // show tracking line
+ i_tableControl.hideTracking();
+ i_tableControl.showTracking(
+ Rectangle(
+ Point( aPoint.X(), 0 ),
+ Size( 1, tableSize.Height() )
+ ),
+ SHOWTRACK_SPLIT | SHOWTRACK_WINDOW
+ );
+
+ (void)i_event;
+ return ContinueFunction;
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ FunctionResult ColumnResize::handleMouseDown( ITableControl& i_tableControl, MouseEvent const & i_event )
+ {
+ if ( m_nResizingColumn != COL_INVALID )
+ {
+ OSL_ENSURE( false, "ColumnResize::handleMouseDown: suspicious: MouseButtonDown while still tracking?" );
+ return ContinueFunction;
+ }
+
+ TableCell const tableCell( i_tableControl.hitTest( i_event.GetPosPixel() ) );
+ if ( tableCell.nRow == ROW_COL_HEADERS )
+ {
+ if ( ( tableCell.nColumn != COL_INVALID )
+ && ( tableCell.eArea == ColumnDivider )
+ )
+ {
+ m_nResizingColumn = tableCell.nColumn;
+ i_tableControl.captureMouse();
+ return ActivateFunction;
+ }
+ }
+
+ return SkipFunction;
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ FunctionResult ColumnResize::handleMouseUp( ITableControl& i_tableControl, MouseEvent const & i_event )
+ {
+ if ( m_nResizingColumn == COL_INVALID )
+ return SkipFunction;
+
+ Point const aPoint = i_event.GetPosPixel();
+
+ i_tableControl.hideTracking();
+ PColumnModel const pColumn = i_tableControl.getModel()->getColumnModel( m_nResizingColumn );
+ long const maxWidthLogical = pColumn->getMaxWidth();
+ long const minWidthLogical = pColumn->getMinWidth();
+
+ // new position of mouse
+ long const requestedEnd = aPoint.X();
+
+ // old position of right border
+ long const oldEnd = i_tableControl.getColumnMetrics( m_nResizingColumn ).nEndPixel;
+
+ // position of left border if cursor in the to-be-resized column
+ long const columnStart = i_tableControl.getColumnMetrics( m_nResizingColumn ).nStartPixel;
+ long const requestedWidth = requestedEnd - columnStart;
+ // TODO: this is not correct, strictly: It assumes that the mouse was pressed exactly on the "end" pos,
+ // but for a while now, we have relaxed this, and allow clicking a few pixels aside, too
+
+ if ( requestedEnd >= columnStart )
+ {
+ long requestedWidthLogical = i_tableControl.pixelWidthToAppFont( requestedWidth );
+ // respect column width limits
+ if ( oldEnd > requestedEnd )
+ {
+ // column has become smaller, check against minimum width
+ if ( ( minWidthLogical != 0 ) && ( requestedWidthLogical < minWidthLogical ) )
+ requestedWidthLogical = minWidthLogical;
+ }
+ else if ( oldEnd < requestedEnd )
+ {
+ // column has become larger, check against max width
+ if ( ( maxWidthLogical != 0 ) && ( requestedWidthLogical >= maxWidthLogical ) )
+ requestedWidthLogical = maxWidthLogical;
+ }
+ pColumn->setWidth( requestedWidthLogical );
+ i_tableControl.invalidate( TableAreaAll );
+ }
+
+ i_tableControl.setPointer( Pointer() );
+ i_tableControl.releaseMouse();
+
+ m_nResizingColumn = COL_INVALID;
+ return DeactivateFunction;
+ }
+
+ //==================================================================================================================
+ //= RowSelection
+ //==================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
+ FunctionResult RowSelection::handleMouseMove( ITableControl& i_tableControl, MouseEvent const & i_event )
+ {
+ OSL_UNUSED( i_tableControl );
+ OSL_UNUSED( i_event );
+ return SkipFunction;
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ FunctionResult RowSelection::handleMouseDown( ITableControl& i_tableControl, MouseEvent const & i_event )
+ {
+ bool handled = false;
+
+ TableCell const tableCell( i_tableControl.hitTest( i_event.GetPosPixel() ) );
+ if ( tableCell.nRow >= 0 )
+ {
+ bool bSetCursor = false;
+ if ( i_tableControl.getSelEngine()->GetSelectionMode() == NO_SELECTION )
+ {
+ bSetCursor = true;
+ }
+ else
+ {
+ if ( !i_tableControl.isRowSelected( tableCell.nRow ) )
+ {
+ handled = i_tableControl.getSelEngine()->SelMouseButtonDown( i_event );
+ }
+ else
+ {
+ bSetCursor = true;
+ }
+ }
+
+ if ( bSetCursor )
+ {
+ i_tableControl.activateCell( tableCell.nColumn, tableCell.nRow );
+ handled = true;
+ }
+ }
+
+ if ( handled )
+ m_bActive = true;
+ return handled ? ActivateFunction : SkipFunction;
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ FunctionResult RowSelection::handleMouseUp( ITableControl& i_tableControl, MouseEvent const & i_event )
+ {
+ TableCell const tableCell = i_tableControl.hitTest( i_event.GetPosPixel() );
+ if ( tableCell.nRow >= 0 )
+ {
+ if ( i_tableControl.getSelEngine()->GetSelectionMode() != NO_SELECTION )
+ {
+ i_tableControl.getSelEngine()->SelMouseButtonUp( i_event );
+ }
+ }
+ if ( m_bActive )
+ {
+ m_bActive = false;
+ return DeactivateFunction;
+ }
+ return SkipFunction;
+ }
+
+ //==================================================================================================================
+ //= ColumnSortHandler
+ //==================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
+ FunctionResult ColumnSortHandler::handleMouseMove( ITableControl& i_tableControl, MouseEvent const & i_event )
+ {
+ OSL_UNUSED( i_tableControl );
+ OSL_UNUSED( i_event );
+ return SkipFunction;
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ FunctionResult ColumnSortHandler::handleMouseDown( ITableControl& i_tableControl, MouseEvent const & i_event )
+ {
+ if ( m_nActiveColumn != COL_INVALID )
+ {
+ OSL_ENSURE( false, "ColumnSortHandler::handleMouseDown: called while already active - suspicious!" );
+ return ContinueFunction;
+ }
+
+ if ( i_tableControl.getModel()->getSortAdapter() == NULL )
+ // no sorting support at the model
+ return SkipFunction;
+
+ TableCell const tableCell( i_tableControl.hitTest( i_event.GetPosPixel() ) );
+ if ( ( tableCell.nRow != ROW_COL_HEADERS ) || ( tableCell.nColumn < 0 ) )
+ return SkipFunction;
+
+ // TODO: ensure the column header is rendered in some special way, indicating its current state
+
+ m_nActiveColumn = tableCell.nColumn;
+ return ActivateFunction;
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ FunctionResult ColumnSortHandler::handleMouseUp( ITableControl& i_tableControl, MouseEvent const & i_event )
+ {
+ if ( m_nActiveColumn == COL_INVALID )
+ return SkipFunction;
+
+ TableCell const tableCell( i_tableControl.hitTest( i_event.GetPosPixel() ) );
+ if ( ( tableCell.nRow == ROW_COL_HEADERS ) && ( tableCell.nColumn == m_nActiveColumn ) )
+ {
+ ITableDataSort* pSort = i_tableControl.getModel()->getSortAdapter();
+ ENSURE_OR_RETURN( pSort != NULL, "ColumnSortHandler::handleMouseUp: somebody is mocking with us!", DeactivateFunction );
+ // in handleMousButtonDown, the model claimed to have sort support ...
+
+ ColumnSortDirection eSortDirection = ColumnSortAscending;
+ ColumnSort const aCurrentSort = pSort->getCurrentSortOrder();
+ if ( aCurrentSort.nColumnPos == m_nActiveColumn )
+ // invert existing sort order
+ eSortDirection = ( aCurrentSort.eSortDirection == ColumnSortAscending ) ? ColumnSortDescending : ColumnSortAscending;
+
+ pSort->sortByColumn( m_nActiveColumn, eSortDirection );
+ }
+
+ m_nActiveColumn = COL_INVALID;
+ return DeactivateFunction;
+ }
+
+//......................................................................................................................
+} } // namespace svt::table
+//......................................................................................................................
diff --git a/svtools/source/table/mousefunction.hxx b/svtools/source/table/mousefunction.hxx
new file mode 100755
index 000000000000..2149026a0923
--- /dev/null
+++ b/svtools/source/table/mousefunction.hxx
@@ -0,0 +1,161 @@
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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_MOUSEFUNCTION_HXX
+#define SVTOOLS_MOUSEFUNCTION_HXX
+
+#include "svtools/table/tabletypes.hxx"
+
+#include <rtl/ref.hxx>
+
+#include <boost/noncopyable.hpp>
+
+class MouseEvent;
+
+//......................................................................................................................
+namespace svt { namespace table
+{
+//......................................................................................................................
+
+ class ITableControl;
+
+ //==================================================================================================================
+ //= FunctionResult
+ //==================================================================================================================
+ enum FunctionResult
+ {
+ ActivateFunction,
+ ContinueFunction,
+ DeactivateFunction,
+
+ SkipFunction
+ };
+
+ //==================================================================================================================
+ //= IMouseFunction
+ //==================================================================================================================
+ class IMouseFunction : public ::rtl::IReference, public ::boost::noncopyable
+ {
+ public:
+ virtual FunctionResult handleMouseMove( ITableControl& i_tableControl, MouseEvent const & i_event ) = 0;
+ virtual FunctionResult handleMouseDown( ITableControl& i_tableControl, MouseEvent const & i_event ) = 0;
+ virtual FunctionResult handleMouseUp( ITableControl& i_tableControl, MouseEvent const & i_event ) = 0;
+
+ protected:
+ virtual ~IMouseFunction() { }
+ };
+
+ //==================================================================================================================
+ //= MouseFunction
+ //==================================================================================================================
+ class MouseFunction : public IMouseFunction
+ {
+ public:
+ MouseFunction()
+ :m_refCount( 0 )
+ {
+ }
+ protected:
+ ~MouseFunction()
+ {
+ }
+
+ public:
+ virtual oslInterlockedCount SAL_CALL acquire();
+ virtual oslInterlockedCount SAL_CALL release();
+
+ private:
+ oslInterlockedCount m_refCount;
+ };
+
+ //==================================================================================================================
+ //= ColumnResize
+ //==================================================================================================================
+ class ColumnResize : public MouseFunction
+ {
+ public:
+ ColumnResize()
+ :m_nResizingColumn( COL_INVALID )
+ {
+ }
+
+ public:
+ // IMouseFunction
+ virtual FunctionResult handleMouseMove( ITableControl& i_tableControl, MouseEvent const & i_event );
+ virtual FunctionResult handleMouseDown( ITableControl& i_tableControl, MouseEvent const & i_event );
+ virtual FunctionResult handleMouseUp( ITableControl& i_tableControl, MouseEvent const & i_event );
+
+ private:
+ ColPos m_nResizingColumn;
+ };
+
+ //==================================================================================================================
+ //= RowSelection
+ //==================================================================================================================
+ class RowSelection : public MouseFunction
+ {
+ public:
+ RowSelection()
+ :m_bActive( false )
+ {
+ }
+
+ public:
+ // IMouseFunction
+ virtual FunctionResult handleMouseMove( ITableControl& i_tableControl, MouseEvent const & i_event );
+ virtual FunctionResult handleMouseDown( ITableControl& i_tableControl, MouseEvent const & i_event );
+ virtual FunctionResult handleMouseUp( ITableControl& i_tableControl, MouseEvent const & i_event );
+
+ private:
+ bool m_bActive;
+ };
+
+ //==================================================================================================================
+ //= ColumnSortHandler
+ //==================================================================================================================
+ class ColumnSortHandler : public MouseFunction
+ {
+ public:
+ ColumnSortHandler()
+ :m_nActiveColumn( COL_INVALID )
+ {
+ }
+
+ public:
+ // IMouseFunction
+ virtual FunctionResult handleMouseMove( ITableControl& i_tableControl, MouseEvent const & i_event );
+ virtual FunctionResult handleMouseDown( ITableControl& i_tableControl, MouseEvent const & i_event );
+ virtual FunctionResult handleMouseUp( ITableControl& i_tableControl, MouseEvent const & i_event );
+
+ private:
+ ColPos m_nActiveColumn;
+ };
+
+//......................................................................................................................
+} } // namespace svt::table
+//......................................................................................................................
+
+#endif // SVTOOLS_MOUSEFUNCTION_HXX
diff --git a/svtools/source/table/tablecontrol.cxx b/svtools/source/table/tablecontrol.cxx
index d6122e7917a0..01a9b667a8f7 100644
--- a/svtools/source/table/tablecontrol.cxx
+++ b/svtools/source/table/tablecontrol.cxx
@@ -28,55 +28,39 @@
#include "precompiled_svtools.hxx"
#include "svtools/table/tablecontrol.hxx"
+
#include "tablegeometry.hxx"
#include "tablecontrol_impl.hxx"
-#include "accessibletableimp.hxx"
-#include "svtools/table/tabledatawindow.hxx"
+#include "tabledatawindow.hxx"
+
#include <com/sun/star/accessibility/AccessibleStateType.hpp>
#include <com/sun/star/accessibility/AccessibleRole.hpp>
+#include <tools/diagnose_ex.h>
+
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
- //====================================================================
- //--------------------------------------------------------------------
+ //==================================================================================================================
+ // -----------------------------------------------------------------------------------------------------------------
TableControl::TableControl( Window* _pParent, WinBits _nStyle )
:Control( _pParent, _nStyle )
,m_pImpl( new TableControl_Impl( *this ) )
- ,m_bSelectionChanged(false)
- ,m_bTooltip(false)
{
- TableDataWindow* aTableData = m_pImpl->getDataWindow();
- aTableData->SetMouseButtonDownHdl( LINK( this, TableControl, ImplMouseButtonDownHdl ) );
- aTableData->SetMouseButtonUpHdl( LINK( this, TableControl, ImplMouseButtonUpHdl ) );
- aTableData->SetSelectHdl( LINK( this, TableControl, ImplSelectHdl ) );
- m_pAccessTable.reset(new ::svt::table::AccessibleTableControl_Impl());
+ TableDataWindow& rDataWindow = m_pImpl->getDataWindow();
+ rDataWindow.SetMouseButtonDownHdl( LINK( this, TableControl, ImplMouseButtonDownHdl ) );
+ rDataWindow.SetMouseButtonUpHdl( LINK( this, TableControl, ImplMouseButtonUpHdl ) );
+ rDataWindow.SetSelectHdl( LINK( this, TableControl, ImplSelectHdl ) );
// by default, use the background as determined by the style settings
const Color aWindowColor( GetSettings().GetStyleSettings().GetFieldColor() );
@@ -84,51 +68,39 @@ namespace svt { namespace table
SetFillColor( aWindowColor );
}
- //--------------------------------------------------------------------
+ // -----------------------------------------------------------------------------------------------------------------
TableControl::~TableControl()
{
ImplCallEventListeners( VCLEVENT_OBJECT_DYING );
- DELETEZ( m_pImpl );
- if ( m_pAccessTable->m_pAccessible )
- {
- m_pAccessTable->m_pAccessible->dispose();
- }
+
+ m_pImpl->setModel( PTableModel() );
+ m_pImpl->disposeAccessible();
+ m_pImpl.reset();
}
- //--------------------------------------------------------------------
+ // -----------------------------------------------------------------------------------------------------------------
void TableControl::GetFocus()
{
if ( !m_pImpl->getInputHandler()->GetFocus( *m_pImpl ) )
- {
Control::GetFocus();
- Control::GrabFocus();
- }
}
- //--------------------------------------------------------------------
+ // -----------------------------------------------------------------------------------------------------------------
void TableControl::LoseFocus()
{
if ( !m_pImpl->getInputHandler()->LoseFocus( *m_pImpl ) )
Control::LoseFocus();
}
- //--------------------------------------------------------------------
+ // -----------------------------------------------------------------------------------------------------------------
void TableControl::KeyInput( const KeyEvent& rKEvt )
{
if ( !m_pImpl->getInputHandler()->KeyInput( *m_pImpl, rKEvt ) )
Control::KeyInput( rKEvt );
- else
- {
- if(m_bSelectionChanged)
- {
- Select();
- m_bSelectionChanged = false;
- }
- }
}
- //--------------------------------------------------------------------
+ // -----------------------------------------------------------------------------------------------------------------
void TableControl::StateChanged( StateChangedType i_nStateChange )
{
Control::StateChanged( i_nStateChange );
@@ -138,156 +110,180 @@ namespace svt { namespace table
{
case STATE_CHANGE_CONTROLBACKGROUND:
if ( IsControlBackground() )
- getDataWindow()->SetControlBackground( GetControlBackground() );
+ getDataWindow().SetControlBackground( GetControlBackground() );
else
- getDataWindow()->SetControlBackground();
+ getDataWindow().SetControlBackground();
break;
case STATE_CHANGE_CONTROLFOREGROUND:
if ( IsControlForeground() )
- getDataWindow()->SetControlForeground( GetControlForeground() );
+ getDataWindow().SetControlForeground( GetControlForeground() );
else
- getDataWindow()->SetControlForeground();
+ getDataWindow().SetControlForeground();
break;
case STATE_CHANGE_CONTROLFONT:
if ( IsControlFont() )
- getDataWindow()->SetControlFont( GetControlFont() );
+ getDataWindow().SetControlFont( GetControlFont() );
else
- getDataWindow()->SetControlFont();
+ getDataWindow().SetControlFont();
break;
}
}
- //--------------------------------------------------------------------
+ // -----------------------------------------------------------------------------------------------------------------
void TableControl::Resize()
{
Control::Resize();
m_pImpl->onResize();
}
- //--------------------------------------------------------------------
+ // -----------------------------------------------------------------------------------------------------------------
void TableControl::SetModel( PTableModel _pModel )
{
m_pImpl->setModel( _pModel );
}
- //--------------------------------------------------------------------
+ // -----------------------------------------------------------------------------------------------------------------
PTableModel TableControl::GetModel() const
{
return m_pImpl->getModel();
}
- //--------------------------------------------------------------------
+ // -----------------------------------------------------------------------------------------------------------------
RowPos TableControl::GetTopRow() const
{
return m_pImpl->getTopRow();
}
- //--------------------------------------------------------------------
+ // -----------------------------------------------------------------------------------------------------------------
void TableControl::SetTopRow( RowPos _nRow )
{
- // TODO
- (void)_nRow;
+ OSL_ENSURE( false, "TableControl::SetTopRow: not implemented!" );
+ OSL_UNUSED( _nRow );
}
- //--------------------------------------------------------------------
+ // -----------------------------------------------------------------------------------------------------------------
sal_Int32 TableControl::GetCurrentRow() const
{
- return m_pImpl->getCurRow();
+ return m_pImpl->getCurrentRow();
}
- //--------------------------------------------------------------------
+ // -----------------------------------------------------------------------------------------------------------------
sal_Int32 TableControl::GetCurrentColumn() const
{
- return m_pImpl->getCurColumn();
+ return m_pImpl->getCurrentColumn();
}
- //--------------------------------------------------------------------
+ // -----------------------------------------------------------------------------------------------------------------
bool TableControl::GoTo( ColPos _nColumn, RowPos _nRow )
{
return m_pImpl->goTo( _nColumn, _nRow );
}
- //--------------------------------------------------------------------
+
+ // -----------------------------------------------------------------------------------------------------------------
sal_Bool TableControl::GoToCell(sal_Int32 _nColPos, sal_Int32 _nRowPos)
{
return m_pImpl->goTo( _nColPos, _nRowPos );
}
- //--------------------------------------------------------------------
- void TableControl::clearSelection()
+
+ //------------------------------------------------------------------------------------------------------------------
+ sal_Int32 TableControl::GetSelectedRowCount() const
+ {
+ return sal_Int32( m_pImpl->getSelectedRowCount() );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ sal_Int32 TableControl::GetSelectedRowIndex( sal_Int32 const i_selectionIndex ) const
{
- m_pImpl->clearSelection();
+ return sal_Int32( m_pImpl->getSelectedRowIndex( i_selectionIndex ) );
}
- //--------------------------------------------------------------------
- void TableControl::InvalidateDataWindow(RowPos _nRowStart, RowPos _nRowEnd, bool _bRemoved)
+
+ //------------------------------------------------------------------------------------------------------------------
+ bool TableControl::IsRowSelected( sal_Int32 const i_rowIndex ) const
{
- Rectangle _rRect;
- if(_bRemoved)
- m_pImpl->invalidateRows();
+ return m_pImpl->isRowSelected( i_rowIndex );
+ }
+
+ // -----------------------------------------------------------------------------------------------------------------
+ void TableControl::SelectRow( RowPos const i_rowIndex, bool const i_select )
+ {
+ ENSURE_OR_RETURN_VOID( ( i_rowIndex >= 0 ) && ( i_rowIndex < m_pImpl->getModel()->getRowCount() ),
+ "TableControl::SelectRow: no control (anymore)!" );
+
+ if ( i_select )
+ {
+ if ( !m_pImpl->markRowAsSelected( i_rowIndex ) )
+ // nothing to do
+ return;
+ }
else
{
- if(m_bSelectionChanged)
- {
- m_pImpl->invalidateSelectedRegion(_nRowStart, _nRowEnd, _rRect);
- m_bSelectionChanged = false;
- }
- else
- m_pImpl->invalidateRow(_nRowStart, _rRect);
+ m_pImpl->markRowAsDeselected( i_rowIndex );
}
+
+ m_pImpl->invalidateRowRange( i_rowIndex, i_rowIndex );
+ Select();
}
- //--------------------------------------------------------------------
- std::vector<sal_Int32>& TableControl::GetSelectedRows()
- {
- return m_pImpl->getSelectedRows();
- }
- //--------------------------------------------------------------------
- void TableControl::RemoveSelectedRow(RowPos _nRowPos)
+
+ // -----------------------------------------------------------------------------------------------------------------
+ void TableControl::SelectAllRows( bool const i_select )
{
- m_pImpl->removeSelectedRow(_nRowPos);
+ if ( i_select )
+ {
+ if ( !m_pImpl->markAllRowsAsSelected() )
+ // nothing to do
+ return;
+ }
+ else
+ {
+ if ( !m_pImpl->markAllRowsAsDeselected() )
+ // nothing to do
+ return;
+ }
+
+
+ Invalidate();
+ // TODO: can't we do better than this, and invalidate only the rows which changed?
+ Select();
}
- //--------------------------------------------------------------------
- RowPos TableControl::GetCurrentRow(const Point& rPoint)
+ // -----------------------------------------------------------------------------------------------------------------
+ ITableControl& TableControl::getTableControlInterface()
{
- return m_pImpl->getCurrentRow( rPoint );
+ return *m_pImpl;
}
+ // -----------------------------------------------------------------------------------------------------------------
SelectionEngine* TableControl::getSelEngine()
{
return m_pImpl->getSelEngine();
}
- TableDataWindow* TableControl::getDataWindow()
+ // -----------------------------------------------------------------------------------------------------------------
+ Window& TableControl::getDataWindow()
{
return m_pImpl->getDataWindow();
}
+ // -----------------------------------------------------------------------------------------------------------------
Reference< XAccessible > TableControl::CreateAccessible()
{
Window* pParent = GetAccessibleParentWindow();
- DBG_ASSERT( pParent, "TableControl::CreateAccessible - parent not found" );
+ ENSURE_OR_RETURN( pParent, "TableControl::CreateAccessible - parent not found", NULL );
- 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;
+ return m_pImpl->getAccessible( *pParent );
}
+
+ // -----------------------------------------------------------------------------------------------------------------
Reference<XAccessible> TableControl::CreateAccessibleControl( sal_Int32 _nIndex )
{
(void)_nIndex;
DBG_ASSERT( sal_False, "TableControl::CreateAccessibleControl: to be overwritten!" );
return NULL;
}
+
+ // -----------------------------------------------------------------------------------------------------------------
::rtl::OUString TableControl::GetAccessibleObjectName( AccessibleTableControlObjType eObjType, sal_Int32 _nRow, sal_Int32 _nCol) const
{
::rtl::OUString aRetText;
@@ -320,309 +316,297 @@ namespace svt { namespace table
}
return aRetText;
}
-// -----------------------------------------------------------------------------
-::rtl::OUString TableControl::GetAccessibleObjectDescription( AccessibleTableControlObjType eObjType, sal_Int32 ) const
-{
- ::rtl::OUString aRetText;
- switch( eObjType )
+ //------------------------------------------------------------------------------------------------------------------
+ ::rtl::OUString TableControl::GetAccessibleObjectDescription( AccessibleTableControlObjType eObjType, sal_Int32 ) const
{
- 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;
+ ::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;
}
- return aRetText;
-}
-// -----------------------------------------------------------------------------
-::rtl::OUString TableControl::GetRowDescription( sal_Int32 _nRow) const
-{
- (void)_nRow;
- return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "row description" ) );
-}
-// -----------------------------------------------------------------------------
+ //------------------------------------------------------------------------------------------------------------------
+ ::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::GetRowName( sal_Int32 _nIndex) const
+ {
+ ::rtl::OUString sRowName;
+ GetModel()->getRowHeading( _nIndex ) >>= sRowName;
+ return sRowName;
+ }
-::rtl::OUString TableControl::GetColumnDescription( sal_uInt16 _nColumn) const
-{
- (void)_nColumn;
- return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "col description" ) );
-}
-// -----------------------------------------------------------------------------
+ //------------------------------------------------------------------------------------------------------------------
+ ::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::GetColumnName( sal_Int32 _nIndex) const
+ {
+ return GetModel()->getColumnModel(_nIndex)->getName();
+ }
-// -----------------------------------------------------------------------------
+ //------------------------------------------------------------------------------------------------------------------
+ ::com::sun::star::uno::Any TableControl::GetCellContent( sal_Int32 _nRowPos, sal_Int32 _nColPos ) const
+ {
+ Any aCellContent;
+ GetModel()->getCellContent( _nColPos, _nRowPos, aCellContent );
+ return aCellContent;
+ }
-::com::sun::star::uno::Any TableControl::GetCellContent( sal_Int32 _nRowPos, sal_Int32 _nColPos) const
-{
- ::com::sun::star::uno::Any cellContent(::com::sun::star::uno::Any(::rtl::OUString::createFromAscii("")));
- std::vector<std::vector< ::com::sun::star::uno::Any > >& aTableContent = GetModel()->getCellContent();
- if(&aTableContent)
- cellContent = aTableContent[_nRowPos][_nColPos];
- return cellContent;
-}
-// -----------------------------------------------------------------------------
-
-::rtl::OUString TableControl::GetAccessibleCellText( sal_Int32 _nRowPos, sal_Int32 _nColPos) const
-{
- const ::com::sun::star::uno::Any cellContent = GetCellContent(_nRowPos, _nColPos);
- return m_pImpl->convertToString(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 );
+ //------------------------------------------------------------------------------------------------------------------
+ ::rtl::OUString TableControl::GetAccessibleCellText( sal_Int32 _nRowPos, sal_Int32 _nColPos) const
+ {
+ return m_pImpl->getCellContentAsString( _nRowPos, _nColPos );
+ }
- 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:
- {
+ //------------------------------------------------------------------------------------------------------------------
+ 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:
+ {
+ 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 );
- 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;
+ break;
+ case TCTYPE_COLUMNHEADERCELL:
+ rStateSet.AddState( AccessibleStateType::VISIBLE );
+ break;
+ }
}
-}
-Rectangle TableControl::GetWindowExtentsRelative( Window *pRelativeWindow ) const
-{
- return Control::GetWindowExtentsRelative( pRelativeWindow );
-}
-//-----------------------------------------------------------------------------
-void TableControl::GrabFocus()
-{
- Control::GrabFocus();
-}
-// -----------------------------------------------------------------------------
-Reference< XAccessible > TableControl::GetAccessible( sal_Bool bCreate )
-{
- return Control::GetAccessible( bCreate );
-}
-// -----------------------------------------------------------------------------
-Window* TableControl::GetAccessibleParentWindow() const
-{
- return Control::GetAccessibleParentWindow();
-}
-// -----------------------------------------------------------------------------
-Window* TableControl::GetWindowInstance()
-{
- return this;
-}
+ //------------------------------------------------------------------------------------------------------------------
+ Rectangle TableControl::GetWindowExtentsRelative( Window *pRelativeWindow ) const
+ {
+ return Control::GetWindowExtentsRelative( pRelativeWindow );
+ }
-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;
-}
+ //------------------------------------------------------------------------------------------------------------------
+ void TableControl::GrabFocus()
+ {
+ Control::GrabFocus();
+ }
-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();
-}
+ //------------------------------------------------------------------------------------------------------------------
+ Reference< XAccessible > TableControl::GetAccessible( sal_Bool bCreate )
+ {
+ return Control::GetAccessible( bCreate );
+ }
-// -----------------------------------------------------------------------------
-::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,sal_Bool _bOnScreen)
-{
- (void)_bOnScreen;
- return m_pImpl->calcHeaderRect(_bIsColumnBar);
-}
-// -----------------------------------------------------------------------------
-Rectangle TableControl::calcTableRect(sal_Bool _bOnScreen)
-{
- (void)_bOnScreen;
- return m_pImpl->calcTableRect();
-}
-//--------------------------------------------------------------------
-::com::sun::star::uno::Sequence< sal_Int32 >& TableControl::getColumnsForTooltip()
-{
- return m_nCols;
-}
-//--------------------------------------------------------------------
-::com::sun::star::uno::Sequence< ::rtl::OUString >& TableControl::getTextForTooltip()
-{
- return m_aText;
-}
-//--------------------------------------------------------------------
-void TableControl::setTooltip(const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aText, const ::com::sun::star::uno::Sequence< sal_Int32 >& nCols )
-{
- m_aText = aText;
- m_nCols = nCols;
- m_bTooltip = true;
-}
-// -----------------------------------------------------------------------
-void TableControl::selectionChanged(bool _bChanged)
-{
- m_bSelectionChanged = _bChanged;
-}
-// -----------------------------------------------------------------------
-bool TableControl::isTooltip()
-{
- return m_bTooltip;
-}
-// -----------------------------------------------------------------------
-IMPL_LINK( TableControl, ImplSelectHdl, void*, EMPTYARG )
-{
- Select();
- return 1;
-}
-IMPL_LINK( TableControl, ImplMouseButtonDownHdl, MouseEvent*, pData )
-{
- CallEventListeners( VCLEVENT_WINDOW_MOUSEBUTTONDOWN, pData );
- return 1;
-}
-IMPL_LINK( TableControl, ImplMouseButtonUpHdl, MouseEvent*, pData )
-{
- CallEventListeners( VCLEVENT_WINDOW_MOUSEBUTTONUP, pData );
- return 1;
-}
-// -----------------------------------------------------------------------
-void TableControl::Select()
-{
- ImplCallEventListenersAndHandler( VCLEVENT_TABLEROW_SELECT, m_aSelectHdl, this );
-}
-//........................................................................
+ //------------------------------------------------------------------------------------------------------------------
+ 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->getRowAtPoint( _rPoint );
+ sal_Int32 nCol = m_pImpl->getColAtPoint( _rPoint );
+ _rnIndex = nRow * GetColumnCount() + nCol;
+ return nRow >= 0 ? sal_True : sal_False;
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ long TableControl::GetRowCount() const
+ {
+ return GetModel()->getRowCount();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ long TableControl::GetColumnCount() const
+ {
+ return GetModel()->getColumnCount();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ sal_Bool TableControl::HasRowHeader() const
+ {
+ return GetModel()->hasRowHeaders();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ sal_Bool TableControl::ConvertPointToCellAddress( sal_Int32& _rnRow, sal_Int32& _rnColPos, const Point& _rPoint )
+ {
+ _rnRow = m_pImpl->getRowAtPoint( _rPoint );
+ _rnColPos = m_pImpl->getColAtPoint( _rPoint );
+ 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);
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ Rectangle TableControl::calcHeaderRect(sal_Bool _bIsColumnBar,sal_Bool _bOnScreen)
+ {
+ (void)_bOnScreen;
+ return m_pImpl->calcHeaderRect( _bIsColumnBar ? false : true );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ Rectangle TableControl::calcTableRect(sal_Bool _bOnScreen)
+ {
+ (void)_bOnScreen;
+ return m_pImpl->calcTableRect();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ IMPL_LINK( TableControl, ImplSelectHdl, void*, EMPTYARG )
+ {
+ Select();
+ return 1;
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ IMPL_LINK( TableControl, ImplMouseButtonDownHdl, MouseEvent*, pData )
+ {
+ CallEventListeners( VCLEVENT_WINDOW_MOUSEBUTTONDOWN, pData );
+ return 1;
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ IMPL_LINK( TableControl, ImplMouseButtonUpHdl, MouseEvent*, pData )
+ {
+ CallEventListeners( VCLEVENT_WINDOW_MOUSEBUTTONUP, pData );
+ return 1;
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void TableControl::Select()
+ {
+ ImplCallEventListenersAndHandler( VCLEVENT_TABLEROW_SELECT, m_pImpl->getSelectHandler(), this );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void TableControl::SetSelectHdl( const Link& i_selectHandler )
+ {
+ m_pImpl->setSelectHandler( i_selectHandler );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ const Link& TableControl::GetSelectHdl() const
+ {
+ return m_pImpl->getSelectHandler();
+ }
+
+//......................................................................................................................
}} // namespace svt::table
-//........................................................................
+//......................................................................................................................
diff --git a/svtools/source/table/tablecontrol_impl.cxx b/svtools/source/table/tablecontrol_impl.cxx
index 4c109529244d..8e481d27d993 100644..100755
--- a/svtools/source/table/tablecontrol_impl.cxx
+++ b/svtools/source/table/tablecontrol_impl.cxx
@@ -30,40 +30,60 @@
#include "svtools/table/tablecontrol.hxx"
#include "svtools/table/defaultinputhandler.hxx"
#include "svtools/table/tablemodel.hxx"
+
+#include "tabledatawindow.hxx"
#include "tablecontrol_impl.hxx"
#include "tablegeometry.hxx"
-#include "svtools/table/tabledatawindow.hxx"
-#include <com/sun/star/awt/XControl.hpp>
+#include "cellvalueconversion.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/accessibility/XAccessible.hpp>
+#include <com/sun/star/accessibility/AccessibleTableModelChange.hpp>
+#include <com/sun/star/accessibility/AccessibleEventId.hpp>
+#include <com/sun/star/accessibility/AccessibleTableModelChangeType.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/flagguard.hxx>
#include <vcl/scrbar.hxx>
#include <vcl/seleng.hxx>
#include <rtl/ref.hxx>
-#include <toolkit/awt/vclxwindow.hxx>
#include <vcl/image.hxx>
-#include <com/sun/star/graphic/XGraphic.hpp>
+#include <tools/diagnose_ex.h>
#include <functional>
-#include <stdlib.h>
-//........................................................................
+#define MIN_COLUMN_WIDTH_PIXEL 4
+
+//......................................................................................................................
namespace svt { namespace table
{
-//........................................................................
-
- //====================================================================
- //= TempHideCursor
- //====================================================================
- class TempHideCursor
+//......................................................................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::accessibility::AccessibleTableModelChange;
+ using ::com::sun::star::uno::makeAny;
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::accessibility::XAccessible;
+ using ::com::sun::star::uno::Reference;
+ /** === end UNO using === **/
+ namespace AccessibleEventId = ::com::sun::star::accessibility::AccessibleEventId;
+ namespace AccessibleTableModelChangeType = ::com::sun::star::accessibility::AccessibleTableModelChangeType;
+
+ //==================================================================================================================
+ //= SuppressCursor
+ //==================================================================================================================
+ class SuppressCursor
{
private:
- IAbstractTableControl& m_rTable;
+ ITableControl& m_rTable;
public:
- TempHideCursor( IAbstractTableControl& _rTable )
+ SuppressCursor( ITableControl& _rTable )
:m_rTable( _rTable )
{
m_rTable.hideCursor();
}
- ~TempHideCursor()
+ ~SuppressCursor()
{
m_rTable.showCursor();
}
@@ -102,50 +122,18 @@ namespace svt { namespace table
{
return false;
}
- virtual void setRowHeaders(bool _bRowHeaders)
- {
- (void)_bRowHeaders;
- }
- virtual void setColumnHeaders(bool _bColumnHeaders)
- {
- (void)_bColumnHeaders;
- }
- void setColumnCount(TableSize _nColCount)
- {
- (void) _nColCount;
- }
- void setRowCount(TableSize _nRowCount)
- {
- (void)_nRowCount;
- }
virtual bool isCellEditable( ColPos col, RowPos row ) const
{
(void)col;
(void)row;
return false;
}
- virtual void addTableModelListener( const PTableModelListener& listener )
- {
- (void)listener;
- // ignore
- }
- virtual void removeTableModelListener( const PTableModelListener& listener )
- {
- (void)listener;
- // ignore
- }
virtual PColumnModel getColumnModel( ColPos column )
{
DBG_ERROR( "EmptyTableModel::getColumnModel: invalid call!" );
(void)column;
return PColumnModel();
}
- virtual PColumnModel getColumnModelByID( ColumnID id )
- {
- DBG_ERROR( "EmptyTableModel::getColumnModel: invalid call!" );
- (void)id;
- return PColumnModel();
- }
virtual PTableRenderer getRenderer() const
{
return PTableRenderer();
@@ -170,83 +158,68 @@ namespace svt { namespace table
{
return 0;
}
- virtual ScrollbarVisibility getVerticalScrollbarVisibility(int , int ) const
+ virtual ScrollbarVisibility getVerticalScrollbarVisibility() const
{
- return ScrollbarShowNever;
+ return ScrollbarShowNever;
}
- virtual ScrollbarVisibility getHorizontalScrollbarVisibility(int , int ) const
+ virtual ScrollbarVisibility getHorizontalScrollbarVisibility() const
{
- return ScrollbarShowNever;
+ return ScrollbarShowNever;
+ }
+ virtual void addTableModelListener( const PTableModelListener& i_listener )
+ {
+ (void)i_listener;
+ }
+ virtual void removeTableModelListener( const PTableModelListener& i_listener )
+ {
+ (void)i_listener;
+ }
+ virtual ::boost::optional< ::Color > getLineColor() const
+ {
+ return ::boost::optional< ::Color >();
+ }
+ virtual ::boost::optional< ::Color > getHeaderBackgroundColor() const
+ {
+ return ::boost::optional< ::Color >();
+ }
+ virtual ::boost::optional< ::Color > getHeaderTextColor() const
+ {
+ return ::boost::optional< ::Color >();
+ }
+ virtual ::boost::optional< ::Color > getTextColor() const
+ {
+ return ::boost::optional< ::Color >();
+ }
+ virtual ::boost::optional< ::Color > getTextLineColor() const
+ {
+ return ::boost::optional< ::Color >();
+ }
+ virtual ::boost::optional< ::std::vector< ::Color > > getRowBackgroundColors() const
+ {
+ return ::boost::optional< ::std::vector< ::Color > >();
+ }
+ virtual ::com::sun::star::style::VerticalAlignment getVerticalAlign() const
+ {
+ return com::sun::star::style::VerticalAlignment(0);
+ }
+ virtual ITableDataSort* getSortAdapter()
+ {
+ return NULL;
+ }
+ virtual void getCellContent( ColPos const i_col, RowPos const i_row, ::com::sun::star::uno::Any& o_cellContent )
+ {
+ (void)i_row;
+ (void)i_col;
+ o_cellContent.clear();
+ }
+ virtual void getCellToolTip( ColPos const, RowPos const, ::com::sun::star::uno::Any& )
+ {
+ }
+ virtual Any getRowHeading( RowPos const i_rowPos ) const
+ {
+ (void)i_rowPos;
+ return Any();
}
- virtual bool hasVerticalScrollbar()
- {
- return false;
- }
- virtual bool hasHorizontalScrollbar()
- {
- return false;
- }
- virtual void setCellContent(const std::vector<std::vector< ::com::sun::star::uno::Any > >& )
- {
- }
- virtual ::com::sun::star::util::Color getLineColor()
- {
- return 0;
- }
- virtual void setLineColor(::com::sun::star::util::Color )
- {
- }
- virtual ::com::sun::star::util::Color getHeaderBackgroundColor()
- {
- return -1;
- }
- virtual void setHeaderBackgroundColor(::com::sun::star::util::Color )
- {
- }
- virtual ::com::sun::star::util::Color getTextColor()
- {
- return 0;
- }
- virtual void setTextColor(::com::sun::star::util::Color )
- {
- }
- virtual ::com::sun::star::util::Color getOddRowBackgroundColor()
- {
- return -1;
- }
- virtual void setOddRowBackgroundColor(::com::sun::star::util::Color )
- {
- }
- virtual ::com::sun::star::style::VerticalAlignment getVerticalAlign()
- {
- return com::sun::star::style::VerticalAlignment(0);
- }
- virtual void setVerticalAlign(com::sun::star::style::VerticalAlignment )
- {
- }
- virtual ::com::sun::star::util::Color getEvenRowBackgroundColor()
- {
- return -1;
- }
- virtual void setEvenRowBackgroundColor(::com::sun::star::util::Color )
- {
- }
- virtual std::vector<std::vector< ::com::sun::star::uno::Any > >& getCellContent()
- {
- return m_aCellContent;
- }
- virtual void setRowHeaderName(const std::vector<rtl::OUString>& )
- {
- }
- virtual std::vector<rtl::OUString>& getRowHeaderName()
- {
- aRowHeaderNames.clear();
- aRowHeaderNames.push_back(rtl::OUString::createFromAscii(""));
- return aRowHeaderNames;
- }
- private:
- std::vector<rtl::OUString> aRowHeaderNames;
- std::vector<std::vector< ::com::sun::star::uno::Any > > m_aCellContent;
};
@@ -312,7 +285,7 @@ namespace svt { namespace table
}
}
- //--------------------------------------------------------------------
+ //------------------------------------------------------------------------------------------------------------------
const sal_Char* TableControl_Impl::impl_checkInvariants() const
{
if ( !m_pModel )
@@ -327,12 +300,9 @@ namespace svt { namespace table
if ( m_pModel->getRowCount() != m_nRowCount )
return "row counts are inconsistent!";
- if ( ( m_nCurColumn != COL_INVALID ) && !m_aColumnWidthsPixel.empty() && ( m_nCurColumn < 0 ) || ( m_nCurColumn >= (ColPos)m_aColumnWidthsPixel.size() ) )
+ if ( ( m_nCurColumn != COL_INVALID ) && !m_aColumnWidths.empty() && ( m_nCurColumn < 0 ) || ( m_nCurColumn >= (ColPos)m_aColumnWidths.size() ) )
return "current column is invalid!";
- if ( m_aColumnWidthsPixel.size() != m_aAccColumnWidthsPixel.size() )
- return "columnd width caches are inconsistent!";
-
if ( !lcl_checkLimitsExclusive_OrDefault_OrFallback( m_nTopRow, (RowPos)-1, m_nRowCount, getModel(), (RowPos)0 ) )
return "invalid top row value!";
@@ -348,6 +318,20 @@ namespace svt { namespace table
if ( m_pInputHandler != m_pModel->getInputHandler() )
return "input handler is not the model-provided one!";
+ // m_aSelectedRows should have reasonable content
+ {
+ if ( m_aSelectedRows.size() > size_t( m_pModel->getRowCount() ) )
+ return "there are more rows selected than actually exist";
+ for ( ::std::vector< RowPos >::const_iterator selRow = m_aSelectedRows.begin();
+ selRow != m_aSelectedRows.end();
+ ++selRow
+ )
+ {
+ if ( ( *selRow < 0 ) || ( *selRow >= m_pModel->getRowCount() ) )
+ return "a non-existent row is selected";
+ }
+ }
+
// m_nColHeaderHeightPixel consistent with the model's value?
{
TableMetrics nHeaderHeight = m_pModel->hasColumnHeaders() ? m_pModel->getColumnHeaderHeight() : 0;
@@ -373,7 +357,28 @@ namespace svt { namespace table
return "row header widths are inconsistent!";
}
- // TODO: check m_aColumnWidthsPixel and m_aAccColumnWidthsPixel
+ // m_aColumnWidths consistency
+ if ( size_t( m_nColumnCount ) != m_aColumnWidths.size() )
+ return "wrong number of cached column widths";
+
+ for ( ColumnPositions::const_iterator col = m_aColumnWidths.begin();
+ col != m_aColumnWidths.end();
+ )
+ {
+ if ( col->getEnd() < col->getStart() )
+ return "column widths: 'end' is expected to not be smaller than start";
+
+ ColumnPositions::const_iterator nextCol = col + 1;
+ if ( nextCol != m_aColumnWidths.end() )
+ if ( col->getEnd() != nextCol->getStart() )
+ return "column widths: one column's end should be the next column's start";
+ col = nextCol;
+ }
+
+ if ( m_nLeftColumn < m_nColumnCount )
+ if ( m_aColumnWidths[ m_nLeftColumn ].getStart() != m_nRowHeaderWidthPixel )
+ return "the left-most column should start immediately after the row header";
+
if ( m_nCursorHidden < 0 )
return "invalid hidden count for the cursor!";
@@ -382,6 +387,8 @@ namespace svt { namespace table
DBG_SUSPEND_INV( INV_SCROLL_POSITION );
// prevent infinite recursion
+ if ( m_nLeftColumn < 0 )
+ return "invalid left-most column index";
if ( m_pVScroll->GetThumbPos() != m_nTopRow )
return "vertical scroll bar |position| is incorrect!";
if ( m_pVScroll->GetRange().Max() != m_nRowCount )
@@ -410,44 +417,44 @@ namespace svt { namespace table
#define DBG_CHECK_ME() \
DBG_CHKTHIS( TableControl_Impl, TableControl_Impl_checkInvariants )
- //--------------------------------------------------------------------
+ //------------------------------------------------------------------------------------------------------------------
TableControl_Impl::TableControl_Impl( TableControl& _rAntiImpl )
:m_rAntiImpl ( _rAntiImpl )
,m_pModel ( new EmptyTableModel )
,m_pInputHandler ( )
,m_nRowHeightPixel ( 15 )
- ,m_nColHeaderHeightPixel( 0 )
+ ,m_nColHeaderHeightPixel( 0 )
,m_nRowHeaderWidthPixel ( 0 )
,m_nColumnCount ( 0 )
,m_nRowCount ( 0 )
+ ,m_bColumnsFit ( true )
,m_nCurColumn ( COL_INVALID )
,m_nCurRow ( ROW_INVALID )
,m_nLeftColumn ( 0 )
- ,m_nTopRow ( 0 )
+ ,m_nTopRow ( 0 )
,m_nCursorHidden ( 1 )
,m_pDataWindow ( new TableDataWindow( *this ) )
- ,m_pVScroll ( NULL )
+ ,m_pVScroll ( NULL )
,m_pHScroll ( NULL )
,m_pScrollCorner ( NULL )
- ,m_pSelEngine ( )
- ,m_nRowSelected ( )
- ,m_pTableFunctionSet ( new TableFunctionSet(this ) )
- ,m_nAnchor (-1 )
- ,m_bResizing ( false )
- ,m_nResizingColumn ( 0 )
- ,m_bResizingGrid ( false )
+ ,m_pSelEngine ( )
+ ,m_aSelectedRows ( )
+ ,m_pTableFunctionSet ( new TableFunctionSet( this ) )
+ ,m_nAnchor ( -1 )
+ ,m_bUpdatingColWidths ( false )
+ ,m_pAccessibleTable ( NULL )
#if DBG_UTIL
,m_nRequiredInvariants ( INV_SCROLL_POSITION )
#endif
{
DBG_CTOR( TableControl_Impl, TableControl_Impl_checkInvariants );
- m_pSelEngine = new SelectionEngine(m_pDataWindow, m_pTableFunctionSet);
- m_pSelEngine->SetSelectionMode(SINGLE_SELECTION);
+ m_pSelEngine = new SelectionEngine( m_pDataWindow.get(), m_pTableFunctionSet );
+ m_pSelEngine->SetSelectionMode(SINGLE_SELECTION);
m_pDataWindow->SetPosPixel( Point( 0, 0 ) );
m_pDataWindow->Show();
}
- //--------------------------------------------------------------------
+ //------------------------------------------------------------------------------------------------------------------
TableControl_Impl::~TableControl_Impl()
{
DBG_DTOR( TableControl_Impl, TableControl_Impl_checkInvariants );
@@ -457,35 +464,30 @@ namespace svt { namespace table
DELETEZ( m_pScrollCorner );
DELETEZ( m_pTableFunctionSet );
DELETEZ( m_pSelEngine );
- DELETEZ( m_pDataWindow );
}
- //--------------------------------------------------------------------
- PTableModel TableControl_Impl::getModel() const
- {
- if ( dynamic_cast< const EmptyTableModel* >( m_pModel.get() ) != NULL )
- // if it's an EmptyTableModel, pretend that there is no model
- return PTableModel();
-
- return m_pModel;
- }
-
- //--------------------------------------------------------------------
+ //------------------------------------------------------------------------------------------------------------------
void TableControl_Impl::setModel( PTableModel _pModel )
{
DBG_CHECK_ME();
- TempHideCursor aHideCursor( *this );
+ SuppressCursor aHideCursor( *this );
+
+ if ( !!m_pModel )
+ m_pModel->removeTableModelListener( shared_from_this() );
m_pModel = _pModel;
if ( !m_pModel)
m_pModel.reset( new EmptyTableModel );
+ m_pModel->addTableModelListener( shared_from_this() );
+
m_nCurRow = ROW_INVALID;
m_nCurColumn = COL_INVALID;
// recalc some model-dependent cached info
impl_ni_updateCachedModelValues();
+ impl_ni_updateScrollbars();
// completely invalidate
m_rAntiImpl.Invalidate();
@@ -495,67 +497,308 @@ namespace svt { namespace table
if ( m_nColumnCount ) m_nCurColumn = 0;
}
- //--------------------------------------------------------------------
- void TableControl_Impl::impl_getAllVisibleCellsArea( Rectangle& _rCellArea ) const
+ //------------------------------------------------------------------------------------------------------------------
+ namespace
+ {
+ bool lcl_adjustSelectedRows( ::std::vector< RowPos >& io_selectionIndexes, RowPos const i_firstAffectedRowIndex, TableSize const i_offset )
+ {
+ bool didChanges = false;
+ for ( ::std::vector< RowPos >::iterator selPos = io_selectionIndexes.begin();
+ selPos != io_selectionIndexes.end();
+ ++selPos
+ )
+ {
+ if ( *selPos < i_firstAffectedRowIndex )
+ continue;
+ *selPos += i_offset;
+ didChanges = true;
+ }
+ return didChanges;
+ }
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void TableControl_Impl::rowsInserted( RowPos i_first, RowPos i_last )
+ {
+ DBG_CHECK_ME();
+ OSL_PRECOND( i_last >= i_first, "TableControl_Impl::rowsInserted: invalid row indexes!" );
+
+ TableSize const insertedRows = i_last - i_first + 1;
+
+ // adjust selection, if necessary
+ bool const selectionChanged = lcl_adjustSelectedRows( m_aSelectedRows, i_first, insertedRows );
+
+ // adjust our cached row count
+ m_nRowCount = m_pModel->getRowCount();
+
+ // if the rows have been inserted before the current row, adjust this
+ if ( i_first <= m_nCurRow )
+ goTo( m_nCurColumn, m_nCurRow + insertedRows );
+
+ // adjust scrollbars
+ impl_ni_updateScrollbars();
+
+ // notify A1YY events
+ if ( impl_isAccessibleAlive() )
+ {
+ impl_commitAccessibleEvent( AccessibleEventId::TABLE_MODEL_CHANGED,
+ makeAny( AccessibleTableModelChange( AccessibleTableModelChangeType::INSERT, i_first, i_last, 0, m_pModel->getColumnCount() ) ),
+ Any()
+ );
+ impl_commitAccessibleEvent( AccessibleEventId::CHILD,
+ makeAny( m_pAccessibleTable->getTableHeader( TCTYPE_ROWHEADERBAR ) ),
+ Any()
+ );
+
+// for ( sal_Int32 i = 0 ; i <= m_pModel->getColumnCount(); ++i )
+// {
+// impl_commitAccessibleEvent(
+// CHILD,
+// makeAny( m_pAccessibleTable->getTable() ),
+// Any());
+// }
+ // Huh? What's that? We're notifying |columnCount| CHILD events here, claiming the *table* itself
+ // has been inserted. Doesn't make much sense, does it?
+ }
+
+ // schedule repaint
+ invalidateRowRange( i_first, ROW_INVALID );
+
+ // call selection handlers, if necessary
+ if ( selectionChanged )
+ m_rAntiImpl.Select();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void TableControl_Impl::rowsRemoved( RowPos i_first, RowPos i_last )
+ {
+ sal_Int32 firstRemovedRow = i_first;
+ sal_Int32 lastRemovedRow = i_last;
+
+ // adjust selection, if necessary
+ bool selectionChanged = false;
+ if ( i_first == -1 )
+ {
+ selectionChanged = markAllRowsAsDeselected();
+
+ firstRemovedRow = 0;
+ lastRemovedRow = m_nRowCount - 1;
+ }
+ else
+ {
+ ENSURE_OR_RETURN_VOID( i_last >= i_first, "TableControl_Impl::rowsRemoved: illegal indexes!" );
+
+ for ( sal_Int32 row = i_first; row <= i_last; ++row )
+ {
+ if ( markRowAsDeselected( row ) )
+ selectionChanged = true;
+ }
+
+ if ( lcl_adjustSelectedRows( m_aSelectedRows, i_last + 1, i_first - i_last - 1 ) )
+ selectionChanged = true;
+ }
+
+ // adjust cached row count
+ m_nRowCount = m_pModel->getRowCount();
+
+ // adjust the current row, if it is larger than the row count now
+ if ( m_nCurRow >= m_nRowCount )
+ {
+ if ( m_nRowCount > 0 )
+ goTo( m_nCurColumn, m_nRowCount - 1 );
+ else
+ m_nCurRow = ROW_INVALID;
+ }
+
+ // adjust scrollbars
+ impl_ni_updateScrollbars();
+
+ // notify A11Y events
+ if ( impl_isAccessibleAlive() )
+ {
+ impl_commitAccessibleEvent(
+ AccessibleEventId::TABLE_MODEL_CHANGED,
+ makeAny( AccessibleTableModelChange(
+ AccessibleTableModelChangeType::DELETE,
+ firstRemovedRow,
+ lastRemovedRow,
+ 0,
+ m_pModel->getColumnCount()
+ ) ),
+ Any()
+ );
+ }
+
+ // schedule a repaint
+ invalidateRowRange( firstRemovedRow, ROW_INVALID );
+
+ // call selection handlers, if necessary
+ if ( selectionChanged )
+ m_rAntiImpl.Select();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void TableControl_Impl::columnInserted( ColPos const i_colIndex )
+ {
+ m_nColumnCount = m_pModel->getColumnCount();
+ impl_ni_updateColumnWidths();
+ impl_ni_updateScrollbars();
+
+ m_rAntiImpl.Invalidate();
+
+ OSL_UNUSED( i_colIndex );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void TableControl_Impl::columnRemoved( ColPos const i_colIndex )
+ {
+ m_nColumnCount = m_pModel->getColumnCount();
+ impl_ni_updateColumnWidths();
+ impl_ni_updateScrollbars();
+
+ m_rAntiImpl.Invalidate();
+
+ OSL_UNUSED( i_colIndex );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void TableControl_Impl::allColumnsRemoved()
+ {
+ m_nColumnCount = m_pModel->getColumnCount();
+ impl_ni_updateColumnWidths();
+ impl_ni_updateScrollbars();
+
+ m_rAntiImpl.Invalidate();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void TableControl_Impl::cellsUpdated( ColPos const i_firstCol, ColPos i_lastCol, RowPos const i_firstRow, RowPos const i_lastRow )
+ {
+ invalidateRowRange( i_firstRow, i_lastRow );
+
+ OSL_UNUSED( i_firstCol );
+ OSL_UNUSED( i_lastCol );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void TableControl_Impl::tableMetricsChanged()
+ {
+ long const oldRowHeaderWidthPixel = m_nRowHeaderWidthPixel;
+ impl_ni_updateCachedTableMetrics();
+ if ( oldRowHeaderWidthPixel != m_nRowHeaderWidthPixel )
+ impl_ni_updateColumnWidths();
+ impl_ni_updateScrollbars();
+ m_rAntiImpl.Invalidate();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void TableControl_Impl::impl_invalidateColumn( ColPos const i_column )
{
DBG_CHECK_ME();
- _rCellArea.Left() = 0;
- _rCellArea.Top() = 0;
+ Rectangle const aAllCellsArea( impl_getAllVisibleCellsArea() );
+
+ const TableColumnGeometry aColumn( *this, aAllCellsArea, i_column );
+ if ( aColumn.isValid() )
+ m_rAntiImpl.Invalidate( aColumn.getRect() );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void TableControl_Impl::columnChanged( ColPos const i_column, ColumnAttributeGroup const i_attributeGroup )
+ {
+ ColumnAttributeGroup nGroup( i_attributeGroup );
+ if ( nGroup & COL_ATTRS_APPEARANCE )
+ {
+ impl_invalidateColumn( i_column );
+ nGroup &= ~COL_ATTRS_APPEARANCE;
+ }
+
+ if ( nGroup & COL_ATTRS_WIDTH )
+ {
+ if ( !m_bUpdatingColWidths )
+ {
+ impl_ni_updateColumnWidths( i_column );
+ invalidate( TableAreaAll );
+ impl_ni_updateScrollbars();
+ }
+
+ nGroup &= ~COL_ATTRS_WIDTH;
+ }
+
+ OSL_ENSURE( ( nGroup == COL_ATTRS_NONE ) || ( i_attributeGroup == COL_ATTRS_ALL ),
+ "TableControl_Impl::columnChanged: don't know how to handle this change!" );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ Rectangle TableControl_Impl::impl_getAllVisibleCellsArea() const
+ {
+ DBG_CHECK_ME();
+
+ Rectangle aArea( Point( 0, 0 ), Size( 0, 0 ) );
// determine the right-most border of the last column which is
// at least partially visible
- _rCellArea.Right() = m_nRowHeaderWidthPixel;
- if ( !m_aAccColumnWidthsPixel.empty() )
+ aArea.Right() = m_nRowHeaderWidthPixel;
+ if ( !m_aColumnWidths.empty() )
{
- // the number of pixels which are scroll out of the left hand
+ // the number of pixels which are scrolled out of the left hand
// side of the window
- long nScrolledOutLeft = m_nLeftColumn == 0 ? 0 : m_aAccColumnWidthsPixel[ m_nLeftColumn - 1 ];
+ const long nScrolledOutLeft = m_nLeftColumn == 0 ? 0 : m_aColumnWidths[ m_nLeftColumn - 1 ].getEnd();
- ArrayOfLong::const_reverse_iterator loop = m_aAccColumnWidthsPixel.rbegin();
+ ColumnPositions::const_reverse_iterator loop = m_aColumnWidths.rbegin();
do
{
- _rCellArea.Right() = *loop++ - nScrolledOutLeft + m_nRowHeaderWidthPixel;
+ aArea.Right() = loop->getEnd() - nScrolledOutLeft + m_nRowHeaderWidthPixel;
+ ++loop;
}
- while ( ( loop != m_aAccColumnWidthsPixel.rend() )
- && ( *loop - nScrolledOutLeft >= _rCellArea.Right() )
+ while ( ( loop != m_aColumnWidths.rend() )
+ && ( loop->getEnd() - nScrolledOutLeft >= aArea.Right() )
);
}
- // so far, _rCellArea.Right() denotes the first pixel *after* the cell area
- --_rCellArea.Right();
+ // so far, aArea.Right() denotes the first pixel *after* the cell area
+ --aArea.Right();
// determine the last row which is at least partially visible
- _rCellArea.Bottom() =
+ aArea.Bottom() =
m_nColHeaderHeightPixel
+ impl_getVisibleRows( true ) * m_nRowHeightPixel
- 1;
+
+ return aArea;
}
- //--------------------------------------------------------------------
- void TableControl_Impl::impl_getAllVisibleDataCellArea( Rectangle& _rCellArea ) const
+ //------------------------------------------------------------------------------------------------------------------
+ Rectangle TableControl_Impl::impl_getAllVisibleDataCellArea() const
{
DBG_CHECK_ME();
- impl_getAllVisibleCellsArea( _rCellArea );
- _rCellArea.Left() = m_nRowHeaderWidthPixel;
- _rCellArea.Top() = m_nColHeaderHeightPixel;
+ Rectangle aArea( impl_getAllVisibleCellsArea() );
+ aArea.Left() = m_nRowHeaderWidthPixel;
+ aArea.Top() = m_nColHeaderHeightPixel;
+ return aArea;
}
- //--------------------------------------------------------------------
- void TableControl_Impl::impl_ni_updateCachedModelValues()
+ //------------------------------------------------------------------------------------------------------------------
+ void TableControl_Impl::impl_ni_updateCachedTableMetrics()
{
- m_nRowHeightPixel = 15;
- m_nColHeaderHeightPixel = 0;
- m_nRowHeaderWidthPixel = 0;
- m_pInputHandler.reset();
- m_nColumnCount = m_nRowCount = 0;
+ m_nRowHeightPixel = m_rAntiImpl.LogicToPixel( Size( 0, m_pModel->getRowHeight() ), MAP_APPFONT ).Height();
- m_nRowHeightPixel = m_rAntiImpl.LogicToPixel( Size( 0, m_pModel->getRowHeight() ), MAP_APPFONT ).Height();
- if ( m_pModel->hasColumnHeaders() )
+ m_nColHeaderHeightPixel = 0;
+ if ( m_pModel->hasColumnHeaders() )
m_nColHeaderHeightPixel = m_rAntiImpl.LogicToPixel( Size( 0, m_pModel->getColumnHeaderHeight() ), MAP_APPFONT ).Height();
+
+ m_nRowHeaderWidthPixel = 0;
if ( m_pModel->hasRowHeaders() )
m_nRowHeaderWidthPixel = m_rAntiImpl.LogicToPixel( Size( m_pModel->getRowHeaderWidth(), 0 ), MAP_APPFONT).Width();
+ }
+ //------------------------------------------------------------------------------------------------------------------
+ void TableControl_Impl::impl_ni_updateCachedModelValues()
+ {
+ m_pInputHandler.reset();
+ m_nColumnCount = m_nRowCount = 0;
+
+ impl_ni_updateCachedTableMetrics();
impl_ni_updateColumnWidths();
m_pInputHandler = m_pModel->getInputHandler();
@@ -566,144 +809,279 @@ namespace svt { namespace table
m_nRowCount = m_pModel->getRowCount();
}
- //--------------------------------------------------------------------
- void TableControl_Impl::impl_ni_updateColumnWidths()
+ //------------------------------------------------------------------------------------------------------------------
+ void TableControl_Impl::impl_ni_updateColumnWidths( ColPos const i_assumeInflexibleColumnsUpToIncluding )
{
- m_aColumnWidthsPixel.resize( 0 );
- m_aAccColumnWidthsPixel.resize( 0 );
+ ENSURE_OR_RETURN_VOID( !m_bUpdatingColWidths, "TableControl_Impl::impl_ni_updateColumnWidths: recursive call detected!" );
+
+ m_aColumnWidths.resize( 0 );
if ( !m_pModel )
return;
- TableSize colCount = m_pModel->getColumnCount();
+ const TableSize colCount = m_pModel->getColumnCount();
+ if ( colCount == 0 )
+ return;
+
+ m_bUpdatingColWidths = true;
+ const ::comphelper::FlagGuard aWidthUpdateFlag( m_bUpdatingColWidths );
- m_aColumnWidthsPixel.reserve( colCount );
- m_aAccColumnWidthsPixel.reserve( colCount );
- if(colCount>0)
+ m_aColumnWidths.reserve( colCount );
+
+ // the available horizontal space
+ long gridWidthPixel = m_rAntiImpl.GetOutputSizePixel().Width();
+ if ( m_pModel->hasRowHeaders() && ( gridWidthPixel != 0 ) )
{
- std::vector<sal_Int32> aPrePixelWidths(0);
- long accumulatedPixelWidth = 0;
- int lastResizableCol = -1;
- double gridWidth = m_rAntiImpl.GetOutputSizePixel().Width();
- if(m_pModel->hasRowHeaders())
- {
- TableMetrics rowHeaderWidth = m_pModel->getRowHeaderWidth();
- gridWidth-= m_rAntiImpl.LogicToPixel( Size( rowHeaderWidth, 0 ), MAP_APPFONT ).Width();
- }
- if(m_pModel->hasVerticalScrollbar())
+ gridWidthPixel -= m_nRowHeaderWidthPixel;
+ }
+ if ( m_pModel->getVerticalScrollbarVisibility() != ScrollbarShowNever )
+ {
+ long nScrollbarMetrics = m_rAntiImpl.GetSettings().GetStyleSettings().GetScrollBarSize();
+ gridWidthPixel -= nScrollbarMetrics;
+ }
+
+ // TODO: shouldn't we take the visibility of the vertical scroll bar into account here, too?
+ long const gridWidthAppFont = m_rAntiImpl.PixelToLogic( Size( gridWidthPixel, 0 ), MAP_APPFONT ).Width();
+
+ // determine the accumulated current width of all columns
+ for ( ColPos col = 0; col < colCount; ++col )
+ {
+ const PColumnModel pColumn = m_pModel->getColumnModel( col );
+ ENSURE_OR_THROW( !!pColumn, "invalid column returned by the model!" );
+
+ }
+
+ // collect some meta data for our columns:
+ // - their current (appt-font) metrics
+ long accumulatedCurrentWidth = 0;
+ ::std::vector< long > currentColWidths;
+ currentColWidths.reserve( colCount );
+ // - their effective minimal and maximal width (app-font!)
+ typedef ::std::vector< ::std::pair< long, long > > ColumnLimits;
+ ColumnLimits effectiveColumnLimits;
+ effectiveColumnLimits.reserve( colCount );
+ long accumulatedMinWidth = 0;
+ long accumulatedMaxWidth = 0;
+ // - their relative flexibility
+ ::std::vector< ::sal_Int32 > columnFlexibilities;
+ columnFlexibilities.reserve( colCount );
+ long flexibilityDenominator = 0;
+ for ( ColPos col = 0; col < colCount; ++col )
+ {
+ PColumnModel const pColumn = m_pModel->getColumnModel( col );
+ ENSURE_OR_THROW( !!pColumn, "invalid column returned by the model!" );
+
+ // current width
+ TableMetrics const currentWidth = pColumn->getWidth();
+ currentColWidths.push_back( currentWidth );
+
+ // accumulated width
+ accumulatedCurrentWidth += currentWidth;
+
+ // flexibility
+ ::sal_Int32 flexibility = pColumn->getFlexibility();
+ OSL_ENSURE( flexibility >= 0, "TableControl_Impl::impl_ni_updateColumnWidths: a column's flexibility should be non-negative." );
+ if ( ( flexibility < 0 ) // normalization
+ || ( !pColumn->isResizable() ) // column not resizeable => no auto-resize
+ || ( col <= i_assumeInflexibleColumnsUpToIncluding ) // column shall be treated as inflexible => respec this
+ )
+ flexibility = 0;
+
+ // min/max width
+ long effectiveMin = currentWidth, effectiveMax = currentWidth;
+ // if the column is not flexible, it will not be asked for min/max, but we assume the current width as limit then
+ if ( flexibility > 0 )
{
- sal_Int32 scrollbarWidth = m_rAntiImpl.GetSettings().GetStyleSettings().GetScrollBarSize();
- gridWidth-=scrollbarWidth;
+ long const minWidth = pColumn->getMinWidth();
+ if ( minWidth > 0 )
+ effectiveMin = minWidth;
+ else
+ effectiveMin = MIN_COLUMN_WIDTH_PIXEL;
+
+ long const maxWidth = pColumn->getMaxWidth();
+ OSL_ENSURE( minWidth <= maxWidth, "TableControl_Impl::impl_ni_updateColumnWidths: pretty undecided 'bout its width limits, this column!" );
+ if ( ( maxWidth > 0 ) && ( maxWidth >= minWidth ) )
+ effectiveMax = maxWidth;
+ else
+ effectiveMax = gridWidthAppFont; // TODO: any better guess here?
+
+ if ( effectiveMin == effectiveMax )
+ // if the min and the max are identical, this implies no flexibility at all
+ flexibility = 0;
}
- double colWidthsSum = 0.0;
- double colWithoutFixedWidthsSum = 0.0;
- double minColWithoutFixedSum = 0.0;
- for ( ColPos col = 0; col < colCount; ++col )
+
+ columnFlexibilities.push_back( flexibility );
+ flexibilityDenominator += flexibility;
+
+ effectiveColumnLimits.push_back( ::std::pair< long, long >( effectiveMin, effectiveMax ) );
+ accumulatedMinWidth += effectiveMin;
+ accumulatedMaxWidth += effectiveMax;
+ }
+
+ ::std::vector< long > newWidths( currentColWidths );
+ if ( flexibilityDenominator == 0 )
+ {
+ // no column is flexible => don't adjust anything
+ }
+ else if ( gridWidthAppFont > accumulatedCurrentWidth )
+ { // we have space to give away ...
+ long distributeAppFontUnits = gridWidthAppFont - accumulatedCurrentWidth;
+ if ( gridWidthAppFont > accumulatedMaxWidth )
{
- PColumnModel pColumn = m_pModel->getColumnModel( col );
- DBG_ASSERT( !!pColumn, "TableControl_Impl::impl_ni_updateColumnWidths: invalid column returned by the model!" );
- if ( !pColumn )
- continue;
- TableMetrics colWidth = 0;
- TableMetrics colPrefWidth = pColumn->getPreferredWidth();
- bool bResizable = pColumn->isResizable();
- if(pColumn->getMinWidth() == 0 && bResizable)
- {
- pColumn->setMinWidth(1);
- minColWithoutFixedSum+=m_rAntiImpl.PixelToLogic( Size( 1, 0 ), MAP_APPFONT ).Width();
- }
- if(pColumn->getMaxWidth() == 0 && bResizable)
- pColumn->setMaxWidth(m_rAntiImpl.PixelToLogic( Size( (int)gridWidth, 0 ), MAP_APPFONT ).Width());
- if( colPrefWidth != 0)
- {
- if(m_bResizingGrid)
- {
- colWidth = pColumn->getWidth();
- pColumn->setPreferredWidth(0);
- }
- else
- {
- colWidth = colPrefWidth;
- pColumn->setWidth(colPrefWidth);
- }
- }
- else
- colWidth = pColumn->getWidth();
- long pixelWidth = m_rAntiImpl.LogicToPixel( Size( colWidth, 0 ), MAP_APPFONT ).Width();
- if(bResizable && colPrefWidth == 0)
+ // ... but the column's maximal widths are still less than we have
+ // => set them all to max
+ for ( size_t i = 0; i < size_t( colCount ); ++i )
{
- colWithoutFixedWidthsSum+=pixelWidth;
- lastResizableCol = col;
+ newWidths[i] = effectiveColumnLimits[i].second;
}
- colWidthsSum+=pixelWidth;
- aPrePixelWidths.push_back(pixelWidth);
- }
- double gridWidthWithoutFixed = gridWidth - colWidthsSum + colWithoutFixedWidthsSum;
- double scalingFactor = 1.0;
- if(m_bResizingGrid)
- {
- if(gridWidthWithoutFixed > (minColWithoutFixedSum+colWidthsSum - colWithoutFixedWidthsSum))
- scalingFactor = gridWidthWithoutFixed/colWithoutFixedWidthsSum;
}
else
{
- if(colWidthsSum < gridWidthWithoutFixed)
+ bool startOver = false;
+ do
{
- if(colWithoutFixedWidthsSum>0)
- scalingFactor = gridWidthWithoutFixed/colWithoutFixedWidthsSum;
+ startOver = false;
+ // distribute the remaining space amongst all columns with a positive flexibility
+ for ( size_t i=0; i<newWidths.size() && !startOver; ++i )
+ {
+ long const columnFlexibility = columnFlexibilities[i];
+ if ( columnFlexibility == 0 )
+ continue;
+
+ long newColWidth = currentColWidths[i] + columnFlexibility * distributeAppFontUnits / flexibilityDenominator;
+
+ if ( newColWidth > effectiveColumnLimits[i].second )
+ { // that was too much, we hit the col's maximum
+ // set the new width to exactly this maximum
+ newColWidth = effectiveColumnLimits[i].second;
+ // adjust the flexibility denominator ...
+ flexibilityDenominator -= columnFlexibility;
+ columnFlexibilities[i] = 0;
+ // ... and the remaining width ...
+ long const difference = newColWidth - currentColWidths[i];
+ distributeAppFontUnits -= difference;
+ // ... this way, we ensure that the width not taken up by this column is consumed by the other
+ // flexible ones (if there are some)
+
+ // and start over with the first column, since there might be earlier columns which need
+ // to be recalculated now
+ startOver = true;
+ }
+
+ newWidths[i] = newColWidth;
+ }
}
+ while ( startOver );
}
- for ( ColPos i = 0; i < colCount; ++i )
+ }
+ else if ( gridWidthAppFont < accumulatedCurrentWidth )
+ { // we need to take away some space from the columns which allow it ...
+ long takeAwayAppFontUnits = accumulatedCurrentWidth - gridWidthAppFont;
+ if ( gridWidthAppFont < accumulatedMinWidth )
{
- PColumnModel pColumn = m_pModel->getColumnModel( i );
- DBG_ASSERT( !!pColumn, "TableControl_Impl::impl_ni_updateColumnWidths: invalid column returned by the model!" );
- if ( !pColumn )
- continue;
- if(pColumn->isResizable() && pColumn->getPreferredWidth() == 0)
+ // ... but the column's minimal widths are still more than we have
+ // => set them all to min
+ for ( size_t i = 0; i < size_t( colCount ); ++i )
{
- aPrePixelWidths[i]*=scalingFactor;
- TableMetrics logicColWidth = m_rAntiImpl.PixelToLogic( Size( aPrePixelWidths[i], 0 ), MAP_APPFONT ).Width();
- pColumn->setWidth(logicColWidth);
+ newWidths[i] = effectiveColumnLimits[i].first;
}
- m_aColumnWidthsPixel.push_back( aPrePixelWidths[i] );
- m_aAccColumnWidthsPixel.push_back( accumulatedPixelWidth += aPrePixelWidths[i] );
}
- if(gridWidth > m_aAccColumnWidthsPixel[colCount-1])
+ else
{
- if(lastResizableCol >= 0)
+ bool startOver = false;
+ do
{
- PColumnModel pColumn = m_pModel->getColumnModel(lastResizableCol);
- m_aColumnWidthsPixel[lastResizableCol]+=gridWidth-m_aAccColumnWidthsPixel[colCount-1];
- TableMetrics logicColWidth1 = m_rAntiImpl.PixelToLogic( Size( m_aColumnWidthsPixel[lastResizableCol], 0 ), MAP_APPFONT ).Width();
- pColumn->setWidth(logicColWidth1);
- while(lastResizableCol < colCount)
+ startOver = false;
+ // take away the space we need from the columns with a positive flexibility
+ for ( size_t i=0; i<newWidths.size() && !startOver; ++i )
{
- if(lastResizableCol == 0)
- m_aAccColumnWidthsPixel[0] = m_aColumnWidthsPixel[lastResizableCol];
- else
- m_aAccColumnWidthsPixel[lastResizableCol]=m_aAccColumnWidthsPixel[lastResizableCol-1]+m_aColumnWidthsPixel[lastResizableCol];
- ++lastResizableCol;
+ long const columnFlexibility = columnFlexibilities[i];
+ if ( columnFlexibility == 0 )
+ continue;
+
+ long newColWidth = currentColWidths[i] - columnFlexibility * takeAwayAppFontUnits / flexibilityDenominator;
+
+ if ( newColWidth < effectiveColumnLimits[i].first )
+ { // that was too much, we hit the col's minimum
+ // set the new width to exactly this minimum
+ newColWidth = effectiveColumnLimits[i].first;
+ // adjust the flexibility denominator ...
+ flexibilityDenominator -= columnFlexibility;
+ columnFlexibilities[i] = 0;
+ // ... and the remaining width ...
+ long const difference = currentColWidths[i] - newColWidth;
+ takeAwayAppFontUnits -= difference;
+
+ // and start over with the first column, since there might be earlier columns which need
+ // to be recalculated now
+ startOver = true;
+ }
+
+ newWidths[i] = newColWidth;
}
}
+ while ( startOver );
+ }
+ }
+
+ // now that we have calculated the app-font widths, get the actual pixels
+ long accumulatedWidthPixel = m_nRowHeaderWidthPixel;
+ for ( ColPos col = 0; col < colCount; ++col )
+ {
+ long const colWidth = m_rAntiImpl.LogicToPixel( Size( newWidths[col], 0 ), MAP_APPFONT ).Width();
+ const long columnStart = accumulatedWidthPixel;
+ const long columnEnd = columnStart + colWidth;
+ m_aColumnWidths.push_back( MutableColumnMetrics( columnStart, columnEnd ) );
+ accumulatedWidthPixel = columnEnd;
+
+ // and don't forget to forward this to the column models
+ PColumnModel const pColumn = m_pModel->getColumnModel( col );
+ ENSURE_OR_THROW( !!pColumn, "invalid column returned by the model!" );
+ pColumn->setWidth( newWidths[col] );
+ }
+
+ // if the column resizing happened to leave some space at the right, but there are columns
+ // scrolled out to the left, scroll them in
+ while ( ( m_nLeftColumn > 0 )
+ && ( accumulatedWidthPixel - m_aColumnWidths[ m_nLeftColumn - 1 ].getStart() <= gridWidthPixel )
+ )
+ {
+ --m_nLeftColumn;
+ }
+
+ // now adjust the column metrics, since they currently ignore the horizontal scroll position
+ if ( m_nLeftColumn > 0 )
+ {
+ const long offsetPixel = m_aColumnWidths[ 0 ].getStart() - m_aColumnWidths[ m_nLeftColumn ].getStart();
+ for ( ColumnPositions::iterator colPos = m_aColumnWidths.begin();
+ colPos != m_aColumnWidths.end();
+ ++colPos
+ )
+ {
+ colPos->move( offsetPixel );
}
}
}
- //--------------------------------------------------------------------
+ //------------------------------------------------------------------------------------------------------------------
namespace
{
- //................................................................
+ //..............................................................................................................
/// determines whether a scrollbar is needed for the given values
- bool lcl_determineScrollbarNeed( ScrollbarVisibility _eVisibility,
- long _nVisibleUnits, long _nRange )
+ bool lcl_determineScrollbarNeed( long const i_position, ScrollbarVisibility const i_visibility,
+ long const i_availableSpace, long const i_neededSpace )
{
- if ( _eVisibility == ScrollbarShowNever )
+ if ( i_visibility == ScrollbarShowNever )
return false;
- if ( _eVisibility == ScrollbarShowAlways )
+ if ( i_visibility == ScrollbarShowAlways )
+ return true;
+ if ( i_position > 0 )
return true;
- return _nVisibleUnits > _nRange;
+ if ( i_availableSpace >= i_neededSpace )
+ return false;
+ return true;
}
- //................................................................
+ //..............................................................................................................
void lcl_setButtonRepeat( Window& _rWindow, sal_uLong _nDelay )
{
AllSettings aSettings = _rWindow.GetSettings();
@@ -715,24 +1093,23 @@ namespace svt { namespace table
_rWindow.SetSettings( aSettings, sal_True );
}
- //................................................................
+ //..............................................................................................................
void lcl_updateScrollbar( Window& _rParent, ScrollBar*& _rpBar,
- ScrollbarVisibility _eVisibility, long _nVisibleUnits,
+ bool const i_needBar, long _nVisibleUnits,
long _nPosition, long _nLineSize, long _nRange,
bool _bHorizontal, const Link& _rScrollHandler )
{
- // do we need the scrollbar?
- bool bNeedBar = lcl_determineScrollbarNeed( _eVisibility, _nVisibleUnits, _nRange );
-
// do we currently have the scrollbar?
bool bHaveBar = _rpBar != NULL;
// do we need to correct the scrollbar visibility?
- if ( bHaveBar && !bNeedBar )
+ if ( bHaveBar && !i_needBar )
{
+ if ( _rpBar->IsTracking() )
+ _rpBar->EndTracking();
DELETEZ( _rpBar );
}
- else if ( !bHaveBar && bNeedBar )
+ else if ( !bHaveBar && i_needBar )
{
_rpBar = new ScrollBar(
&_rParent,
@@ -754,7 +1131,7 @@ namespace svt { namespace table
}
}
- //................................................................
+ //..............................................................................................................
/** returns the number of rows fitting into the given range,
for the given row height. Partially fitting rows are counted, too, if the
respective parameter says so.
@@ -766,7 +1143,7 @@ namespace svt { namespace table
: _nOverallHeight / _nRowHeightPixel;
}
- //................................................................
+ //..............................................................................................................
/** returns the number of columns fitting into the given area,
with the first visible column as given. Partially fitting columns are counted, too,
if the respective parameter says so.
@@ -791,15 +1168,13 @@ namespace svt { namespace table
}
- //--------------------------------------------------------------------
+ //------------------------------------------------------------------------------------------------------------------
void TableControl_Impl::impl_ni_updateScrollbars()
{
- TempHideCursor aHideCursor( *this );
+ SuppressCursor aHideCursor( *this );
// the width/height of a scrollbar, needed several times below
- long nScrollbarMetrics = m_rAntiImpl.GetSettings().GetStyleSettings().GetScrollBarSize();
- if ( m_rAntiImpl.IsZoom() )
- nScrollbarMetrics = (long)( nScrollbarMetrics * (double)m_rAntiImpl.GetZoom() );
+ long const nScrollbarMetrics = m_rAntiImpl.GetSettings().GetStyleSettings().GetScrollBarSize();
// determine the playground for the data cells (excluding headers)
// TODO: what if the control is smaller than needed for the headers/scrollbars?
@@ -809,26 +1184,28 @@ namespace svt { namespace table
m_nRowCount = m_pModel->getRowCount();
m_nColumnCount = m_pModel->getColumnCount();
- if(m_aAccColumnWidthsPixel.empty())
- {
+ if ( m_aColumnWidths.empty() )
impl_ni_updateColumnWidths();
- }
+ OSL_ENSURE( m_aColumnWidths.size() == size_t( m_nColumnCount ), "TableControl_Impl::impl_ni_updateScrollbars: inconsistency!" );
+ const long nAllColumnsWidth = m_aColumnWidths.empty()
+ ? 0
+ : m_aColumnWidths[ m_nColumnCount - 1 ].getEnd() - m_aColumnWidths[ 0 ].getStart();
+
+ const ScrollbarVisibility eVertScrollbar = m_pModel->getVerticalScrollbarVisibility();
+ const ScrollbarVisibility eHorzScrollbar = m_pModel->getHorizontalScrollbarVisibility();
// do we need a vertical scrollbar?
+ bool bNeedVerticalScrollbar = lcl_determineScrollbarNeed(
+ m_nTopRow, eVertScrollbar, aDataCellPlayground.GetHeight(), m_nRowHeightPixel * m_nRowCount );
bool bFirstRoundVScrollNeed = false;
- if ( lcl_determineScrollbarNeed(
- m_pModel->getVerticalScrollbarVisibility(aDataCellPlayground.GetHeight(), m_nRowHeightPixel*m_nRowCount),
- lcl_getRowsFittingInto( aDataCellPlayground.GetHeight(), m_nRowHeightPixel ),
- m_nRowCount ) )
+ if ( bNeedVerticalScrollbar )
{
aDataCellPlayground.Right() -= nScrollbarMetrics;
bFirstRoundVScrollNeed = true;
}
// do we need a horizontal scrollbar?
- if ( lcl_determineScrollbarNeed(
- m_pModel->getHorizontalScrollbarVisibility(aDataCellPlayground.GetWidth(), m_aAccColumnWidthsPixel[m_nColumnCount-1]),
- lcl_getColumnsVisibleWithin( aDataCellPlayground, m_nLeftColumn, *this, false ),
- m_nColumnCount ) )
+ const bool bNeedHorizontalScrollbar = lcl_determineScrollbarNeed( m_nLeftColumn, eHorzScrollbar, aDataCellPlayground.GetWidth(), nAllColumnsWidth );
+ if ( bNeedHorizontalScrollbar )
{
aDataCellPlayground.Bottom() -= nScrollbarMetrics;
@@ -836,19 +1213,21 @@ namespace svt { namespace table
// the need for a vertical one may have changed, since the horizontal
// SB might just occupy enough space so that not all rows do fit
// anymore
- if ( !bFirstRoundVScrollNeed && lcl_determineScrollbarNeed(
- m_pModel->getVerticalScrollbarVisibility(aDataCellPlayground.GetHeight(),m_nRowHeightPixel*m_nRowCount),
- lcl_getRowsFittingInto( aDataCellPlayground.GetHeight(), m_nRowHeightPixel ),
- m_nRowCount ) )
+ if ( !bFirstRoundVScrollNeed )
{
- aDataCellPlayground.Right() -= nScrollbarMetrics;
+ bNeedVerticalScrollbar = lcl_determineScrollbarNeed(
+ m_nTopRow, eVertScrollbar, aDataCellPlayground.GetHeight(), m_nRowHeightPixel * m_nRowCount );
+ if ( bNeedVerticalScrollbar )
+ {
+ aDataCellPlayground.Right() -= nScrollbarMetrics;
+ }
}
}
// create or destroy the vertical scrollbar, as needed
lcl_updateScrollbar(
m_rAntiImpl,
m_pVScroll,
- m_pModel->getVerticalScrollbarVisibility(aDataCellPlayground.GetHeight(),m_nRowHeightPixel*m_nRowCount),
+ bNeedVerticalScrollbar,
lcl_getRowsFittingInto( aDataCellPlayground.GetHeight(), m_nRowHeightPixel ),
// visible units
m_nTopRow, // current position
@@ -872,7 +1251,7 @@ namespace svt { namespace table
lcl_updateScrollbar(
m_rAntiImpl,
m_pHScroll,
- m_pModel->getHorizontalScrollbarVisibility(aDataCellPlayground.GetWidth(), m_aAccColumnWidthsPixel[m_nColumnCount-1]),
+ bNeedHorizontalScrollbar,
lcl_getColumnsVisibleWithin( aDataCellPlayground, m_nLeftColumn, *this, false ),
// visible units
m_nLeftColumn, // current position
@@ -884,14 +1263,14 @@ namespace svt { namespace table
// position it
if ( m_pHScroll )
{
- TableSize nVisibleUnits = lcl_getColumnsVisibleWithin( aDataCellPlayground, m_nLeftColumn, *this, false );
- int nRange = m_nColumnCount;
- if( m_nLeftColumn + nVisibleUnits == nRange-1)
+ TableSize const nVisibleUnits = lcl_getColumnsVisibleWithin( aDataCellPlayground, m_nLeftColumn, *this, false );
+ TableMetrics const nRange = m_nColumnCount;
+ if( m_nLeftColumn + nVisibleUnits == nRange - 1 )
{
- if(m_aAccColumnWidthsPixel[nRange-2] - m_aAccColumnWidthsPixel[m_nLeftColumn] + m_aColumnWidthsPixel[nRange-1]>aDataCellPlayground.GetWidth())
+ if ( m_aColumnWidths[ nRange - 1 ].getStart() - m_aColumnWidths[ m_nLeftColumn ].getEnd() + m_aColumnWidths[ nRange-1 ].getWidth() > aDataCellPlayground.GetWidth() )
{
m_pHScroll->SetVisibleSize( nVisibleUnits -1 );
- m_pHScroll->SetPageSize(nVisibleUnits -1);
+ m_pHScroll->SetPageSize( nVisibleUnits - 1 );
}
}
Rectangle aScrollbarArea(
@@ -929,41 +1308,17 @@ namespace svt { namespace table
) );
}
- //--------------------------------------------------------------------
+ //------------------------------------------------------------------------------------------------------------------
void TableControl_Impl::onResize()
{
DBG_CHECK_ME();
- if(m_nRowCount != 0)
- {
- if(m_nColumnCount != 0)
- {
- if(m_bResizingGrid)
- impl_ni_updateColumnWidths();
- invalidateRows();
- m_bResizingGrid = true;
- }
- }
- else
- {
- //In the case that column headers are defined but data hasn't yet been set,
- //only column headers will be shown
- if(m_pModel->hasColumnHeaders())
- {
- if(m_nColHeaderHeightPixel>1)
- {
- m_pDataWindow->SetSizePixel( m_rAntiImpl.GetOutputSizePixel());
- if(m_bResizingGrid)
- //update column widths to fit in grid
- impl_ni_updateColumnWidths();
- m_bResizingGrid = true;
- }
- }
- if(m_nColumnCount != 0)
- impl_ni_updateScrollbars();
- }
+
+ impl_ni_updateColumnWidths();
+ impl_ni_updateScrollbars();
+ checkCursorPosition();
}
- //--------------------------------------------------------------------
+ //------------------------------------------------------------------------------------------------------------------
void TableControl_Impl::doPaintContent( const Rectangle& _rUpdateRect )
{
DBG_CHECK_ME();
@@ -971,32 +1326,24 @@ namespace svt { namespace table
if ( !getModel() )
return;
PTableRenderer pRenderer = getModel()->getRenderer();
- DBG_ASSERT( !!pRenderer, "TableDataWindow::Paint: invalid renderer!" );
+ DBG_ASSERT( !!pRenderer, "TableDataWindow::doPaintContent: invalid renderer!" );
if ( !pRenderer )
return;
// our current style settings, to be passed to the renderer
const StyleSettings& rStyle = m_rAntiImpl.GetSettings().GetStyleSettings();
m_nRowCount = m_pModel->getRowCount();
- TableSize nVisibleRows = impl_getVisibleRows(true);
- TableSize nActualRows = m_nRowCount;
- if(m_nRowCount>nVisibleRows)
- nActualRows = nVisibleRows;
// the area occupied by all (at least partially) visible cells, including
// headers
- Rectangle aAllCellsWithHeaders;
- impl_getAllVisibleCellsArea( aAllCellsWithHeaders );
+ Rectangle const aAllCellsWithHeaders( impl_getAllVisibleCellsArea() );
// ............................
// draw the header column area
if ( m_pModel->hasColumnHeaders() )
{
- TableRowGeometry aHeaderRow( *this, Rectangle( Point( 0, 0 ),
+ TableRowGeometry const aHeaderRow( *this, Rectangle( Point( 0, 0 ),
aAllCellsWithHeaders.BottomRight() ), ROW_COL_HEADERS );
- Rectangle aColRect(aHeaderRow.getRect());
- //to avoid double lines when scrolling horizontally
- if(m_nLeftColumn != 0)
- --aColRect.Left();
+ Rectangle const aColRect(aHeaderRow.getRect());
pRenderer->PaintHeaderArea(
*m_pDataWindow, aColRect, true, false, rStyle
);
@@ -1012,7 +1359,7 @@ namespace svt { namespace table
if ( _rUpdateRect.GetIntersection( aCell.getRect() ).IsEmpty() )
continue;
- bool isActiveColumn = ( aCell.getColumn() == getCurColumn() );
+ bool isActiveColumn = ( aCell.getColumn() == getCurrentColumn() );
bool isSelectedColumn = false;
pRenderer->PaintColumnHeader( aCell.getColumn(), isActiveColumn, isSelectedColumn,
*m_pDataWindow, aCell.getRect(), rStyle );
@@ -1024,31 +1371,23 @@ namespace svt { namespace table
{
aRowHeaderArea = aAllCellsWithHeaders;
aRowHeaderArea.Right() = m_nRowHeaderWidthPixel - 1;
- if(m_nTopRow+nActualRows>m_nRowCount)
- aRowHeaderArea.Bottom() = m_nRowHeightPixel * (nActualRows -1)+ m_nColHeaderHeightPixel - 1;
- else
- aRowHeaderArea.Bottom() = m_nRowHeightPixel * nActualRows + m_nColHeaderHeightPixel - 1;
- //to avoid double lines when scrolling vertically
- if(m_nTopRow != 0)
- --aRowHeaderArea.Top();
- --aRowHeaderArea.Right();
- pRenderer->PaintHeaderArea(*m_pDataWindow, aRowHeaderArea, false, true, rStyle);
+
+ TableSize const nVisibleRows = impl_getVisibleRows( true );
+ TableSize nActualRows = nVisibleRows;
+ if ( m_nTopRow + nActualRows > m_nRowCount )
+ nActualRows = m_nRowCount - m_nTopRow;
+ aRowHeaderArea.Bottom() = m_nColHeaderHeightPixel + m_nRowHeightPixel * nActualRows - 1;
+
+ pRenderer->PaintHeaderArea( *m_pDataWindow, aRowHeaderArea, false, true, rStyle );
// Note that strictly, aRowHeaderArea also contains the intersection between column
// and row header area. However, below we go to paint this intersection, again,
// so this hopefully doesn't hurt if we already paint it here.
if ( m_pModel->hasColumnHeaders() )
{
- TableCellGeometry aIntersection( *this, Rectangle( Point( 0, 0 ),
+ TableCellGeometry const aIntersection( *this, Rectangle( Point( 0, 0 ),
aAllCellsWithHeaders.BottomRight() ), COL_ROW_HEADERS, ROW_COL_HEADERS );
- Rectangle aInters(aIntersection.getRect());
- //to avoid double line when scrolling vertically
- if( m_nTopRow != 0 )
- {
- --aInters.Top();
- --aInters.Bottom();
- }
- --aInters.Right();
+ Rectangle const aInters( aIntersection.getRect() );
pRenderer->PaintHeaderArea(
*m_pDataWindow, aInters, true, true, rStyle
);
@@ -1061,51 +1400,36 @@ namespace svt { namespace table
TableSize colCount = getModel()->getColumnCount();
// paint all rows
- Rectangle aAllDataCellsArea;
- impl_getAllVisibleDataCellArea( aAllDataCellsArea );
- ::std::vector< std::vector< ::com::sun::star::uno::Any > >& aCellContent = m_pModel->getCellContent();
+ Rectangle const aAllDataCellsArea( impl_getAllVisibleDataCellArea() );
for ( TableRowGeometry aRowIterator( *this, aAllCellsWithHeaders, getTopRow() );
aRowIterator.isValid();
aRowIterator.moveDown() )
{
if ( _rUpdateRect.GetIntersection( aRowIterator.getRect() ).IsEmpty() )
continue;
- bool isActiveRow = ( aRowIterator.getRow() == getCurRow() );
- bool isSelectedRow = false;
- if(!m_nRowSelected.empty())
- {
- for(std::vector<RowPos>::iterator itSel=m_nRowSelected.begin();
- itSel!=m_nRowSelected.end();++itSel)
- {
- if(*itSel == aRowIterator.getRow())
- isSelectedRow = true;
- }
- }
- Rectangle aRect = aRowIterator.getRect().GetIntersection( aAllDataCellsArea );
- //to avoid double lines
- if( aRowIterator.getRow() != 0 )
- --aRect.Top();
- if(m_nLeftColumn != 0)
- --aRect.Left();
- else
- {
- if(m_pModel->hasRowHeaders())
- --aRect.Left();
- }
+
+ bool const isActiveRow = ( aRowIterator.getRow() == getCurrentRow() );
+ bool const isSelectedRow = isRowSelected( aRowIterator.getRow() );
+
+ Rectangle const aRect = aRowIterator.getRect().GetIntersection( aAllDataCellsArea );
+
// give the redenderer a chance to prepare the row
- pRenderer->PrepareRow( aRowIterator.getRow(), isActiveRow, isSelectedRow,
- *m_pDataWindow, aRect, rStyle );
+ pRenderer->PrepareRow(
+ aRowIterator.getRow(), isActiveRow, isSelectedRow,
+ *m_pDataWindow, aRect, rStyle
+ );
// paint the row header
if ( m_pModel->hasRowHeaders() )
{
- Rectangle aCurrentRowHeader( aRowHeaderArea.GetIntersection( aRowIterator.getRect() ) );
- rtl::OUString rowHeaderName = m_pModel->getRowHeaderName()[aRowIterator.getRow()];
+ const Rectangle aCurrentRowHeader( aRowHeaderArea.GetIntersection( aRowIterator.getRect() ) );
pRenderer->PaintRowHeader( isActiveRow, isSelectedRow, *m_pDataWindow, aCurrentRowHeader,
- rStyle, rowHeaderName );
+ rStyle );
}
+
if ( !colCount )
continue;
+
// paint all cells in this row
for ( TableCellGeometry aCell( aRowIterator, m_nLeftColumn );
aCell.isValid();
@@ -1113,25 +1437,12 @@ namespace svt { namespace table
)
{
bool isSelectedColumn = false;
- ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >xGraphic;
- ::com::sun::star::uno::Any rCellData = aCellContent[aRowIterator.getRow()][aCell.getColumn()];
- if(rCellData>>=xGraphic)
- {
- Image* pImage = new Image(xGraphic);
- if(pImage!=NULL)
- pRenderer->PaintCellImage( aCell.getColumn(), isSelectedRow || isSelectedColumn, isActiveRow,
- *m_pDataWindow, aCell.getRect(), rStyle, pImage );
- }
- else
- {
- ::rtl::OUString sContent = convertToString(rCellData);
- pRenderer->PaintCellString( aCell.getColumn(), isSelectedRow || isSelectedColumn, isActiveRow,
- *m_pDataWindow, aCell.getRect(), rStyle, sContent );
- }
+ pRenderer->PaintCell( aCell.getColumn(), isSelectedRow || isSelectedColumn, isActiveRow,
+ *m_pDataWindow, aCell.getRect(), rStyle );
}
}
}
- //--------------------------------------------------------------------
+ //------------------------------------------------------------------------------------------------------------------
void TableControl_Impl::hideCursor()
{
DBG_CHECK_ME();
@@ -1140,7 +1451,7 @@ namespace svt { namespace table
impl_ni_doSwitchCursor( false );
}
- //--------------------------------------------------------------------
+ //------------------------------------------------------------------------------------------------------------------
void TableControl_Impl::showCursor()
{
DBG_CHECK_ME();
@@ -1150,12 +1461,14 @@ namespace svt { namespace table
impl_ni_doSwitchCursor( true );
}
- //--------------------------------------------------------------------
+ //------------------------------------------------------------------------------------------------------------------
bool TableControl_Impl::dispatchAction( TableControlAction _eAction )
{
DBG_CHECK_ME();
bool bSuccess = false;
+ bool selectionChanged = false;
+
Rectangle rCells;
switch ( _eAction )
{
@@ -1163,25 +1476,25 @@ namespace svt { namespace table
if(m_pSelEngine->GetSelectionMode() == SINGLE_SELECTION)
{
//if other rows already selected, deselect them
- if(m_nRowSelected.size()>0)
+ if(m_aSelectedRows.size()>0)
{
- for(std::vector<RowPos>::iterator it=m_nRowSelected.begin();
- it!=m_nRowSelected.end();++it)
+ for(std::vector<RowPos>::iterator it=m_aSelectedRows.begin();
+ it!=m_aSelectedRows.end();++it)
{
invalidateSelectedRegion(*it, *it, rCells);
}
- m_nRowSelected.clear();
+ m_aSelectedRows.clear();
}
if(m_nCurRow < m_nRowCount-1)
{
++m_nCurRow;
- m_nRowSelected.push_back(m_nCurRow);
+ m_aSelectedRows.push_back(m_nCurRow);
}
else
- m_nRowSelected.push_back(m_nCurRow);
+ m_aSelectedRows.push_back(m_nCurRow);
invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells);
ensureVisible(m_nCurColumn,m_nCurRow,false);
- m_rAntiImpl.selectionChanged(true);
+ selectionChanged = true;
bSuccess = true;
}
else
@@ -1194,28 +1507,28 @@ namespace svt { namespace table
case cursorUp:
if(m_pSelEngine->GetSelectionMode() == SINGLE_SELECTION)
{
- if(m_nRowSelected.size()>0)
+ if(m_aSelectedRows.size()>0)
{
- for(std::vector<RowPos>::iterator it=m_nRowSelected.begin();
- it!=m_nRowSelected.end();++it)
+ for(std::vector<RowPos>::iterator it=m_aSelectedRows.begin();
+ it!=m_aSelectedRows.end();++it)
{
invalidateSelectedRegion(*it, *it, rCells);
}
- m_nRowSelected.clear();
+ m_aSelectedRows.clear();
}
if(m_nCurRow>0)
{
--m_nCurRow;
- m_nRowSelected.push_back(m_nCurRow);
+ m_aSelectedRows.push_back(m_nCurRow);
invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells);
}
else
{
- m_nRowSelected.push_back(m_nCurRow);
+ m_aSelectedRows.push_back(m_nCurRow);
invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells);
}
ensureVisible(m_nCurColumn,m_nCurRow,false);
- m_rAntiImpl.selectionChanged(true);
+ selectionChanged = true;
bSuccess = true;
}
else
@@ -1277,259 +1590,269 @@ namespace svt { namespace table
case cursorBottomRight:
bSuccess = goTo( m_nColumnCount - 1, m_nRowCount - 1 );
break;
- case cursorSelectRow:
- {
- if(m_pSelEngine->GetSelectionMode() == NO_SELECTION)
- return bSuccess = false;
- //pos is the position of the current row in the vector of selected rows, if current row is selected
- int pos = getRowSelectedNumber(m_nRowSelected, m_nCurRow);
- //if current row is selected, it should be deselected, when ALT+SPACE are pressed
- if(pos>-1)
- {
- m_nRowSelected.erase(m_nRowSelected.begin()+pos);
- if(m_nRowSelected.empty() && m_nAnchor != -1)
- m_nAnchor = -1;
- }
- //else select the row->put it in the vector
- else
- m_nRowSelected.push_back(m_nCurRow);
- invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells);
- m_rAntiImpl.selectionChanged(true);
- bSuccess = true;
- }
- break;
- case cursorSelectRowUp:
- {
- if(m_pSelEngine->GetSelectionMode() == NO_SELECTION)
- return bSuccess = false;
- else if(m_pSelEngine->GetSelectionMode() == SINGLE_SELECTION)
+
+ case cursorSelectRow:
{
- //if there are other selected rows, deselect them
- return false;
+ if(m_pSelEngine->GetSelectionMode() == NO_SELECTION)
+ return bSuccess = false;
+ //pos is the position of the current row in the vector of selected rows, if current row is selected
+ int pos = getRowSelectedNumber(m_aSelectedRows, m_nCurRow);
+ //if current row is selected, it should be deselected, when ALT+SPACE are pressed
+ if(pos>-1)
+ {
+ m_aSelectedRows.erase(m_aSelectedRows.begin()+pos);
+ if(m_aSelectedRows.empty() && m_nAnchor != -1)
+ m_nAnchor = -1;
+ }
+ //else select the row->put it in the vector
+ else
+ m_aSelectedRows.push_back(m_nCurRow);
+ invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells);
+ selectionChanged = true;
+ bSuccess = true;
}
- else
+ break;
+ case cursorSelectRowUp:
{
- //there are other selected rows
- if(m_nRowSelected.size()>0)
+ if(m_pSelEngine->GetSelectionMode() == NO_SELECTION)
+ return bSuccess = false;
+ else if(m_pSelEngine->GetSelectionMode() == SINGLE_SELECTION)
+ {
+ //if there are other selected rows, deselect them
+ return false;
+ }
+ else
{
- //the anchor wasn't set -> a region is not selected, that's why clear all selection
- //and select the current row
- if(m_nAnchor==-1)
+ //there are other selected rows
+ if(m_aSelectedRows.size()>0)
{
- for(std::vector<RowPos>::iterator it=m_nRowSelected.begin();
- it!=m_nRowSelected.end();++it)
+ //the anchor wasn't set -> a region is not selected, that's why clear all selection
+ //and select the current row
+ if(m_nAnchor==-1)
{
- invalidateSelectedRegion(*it, *it, rCells);
- }
- m_nRowSelected.clear();
- m_nRowSelected.push_back(m_nCurRow);
- invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells);
- }
- else
- {
- //a region is already selected, prevRow is last selected row and the row above - nextRow - should be selected
- int prevRow = getRowSelectedNumber(m_nRowSelected, m_nCurRow);
- int nextRow = getRowSelectedNumber(m_nRowSelected, m_nCurRow-1);
- if(prevRow>-1)
- {
- //if m_nCurRow isn't the upper one, can move up, otherwise not
- if(m_nCurRow>0)
- m_nCurRow--;
- else
- return bSuccess = true;
- //if nextRow already selected, deselect it, otherwise select it
- if(nextRow>-1 && m_nRowSelected[nextRow] == m_nCurRow)
- {
- m_nRowSelected.erase(m_nRowSelected.begin()+prevRow);
- invalidateSelectedRegion(m_nCurRow+1, m_nCurRow+1, rCells);
- }
- else
+ for(std::vector<RowPos>::iterator it=m_aSelectedRows.begin();
+ it!=m_aSelectedRows.end();++it)
{
- m_nRowSelected.push_back(m_nCurRow);
- invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells);
- }
- }
+ invalidateSelectedRegion(*it, *it, rCells);
+ }
+ m_aSelectedRows.clear();
+ m_aSelectedRows.push_back(m_nCurRow);
+ invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells);
+ }
else
{
- if(m_nCurRow>0)
+ //a region is already selected, prevRow is last selected row and the row above - nextRow - should be selected
+ int prevRow = getRowSelectedNumber(m_aSelectedRows, m_nCurRow);
+ int nextRow = getRowSelectedNumber(m_aSelectedRows, m_nCurRow-1);
+ if(prevRow>-1)
+ {
+ //if m_nCurRow isn't the upper one, can move up, otherwise not
+ if(m_nCurRow>0)
+ m_nCurRow--;
+ else
+ return bSuccess = true;
+ //if nextRow already selected, deselect it, otherwise select it
+ if(nextRow>-1 && m_aSelectedRows[nextRow] == m_nCurRow)
+ {
+ m_aSelectedRows.erase(m_aSelectedRows.begin()+prevRow);
+ invalidateSelectedRegion(m_nCurRow+1, m_nCurRow+1, rCells);
+ }
+ else
+ {
+ m_aSelectedRows.push_back(m_nCurRow);
+ invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells);
+ }
+ }
+ else
{
- m_nRowSelected.push_back(m_nCurRow);
- m_nCurRow--;
- m_nRowSelected.push_back(m_nCurRow);
- invalidateSelectedRegion(m_nCurRow+1, m_nCurRow, rCells);
+ if(m_nCurRow>0)
+ {
+ m_aSelectedRows.push_back(m_nCurRow);
+ m_nCurRow--;
+ m_aSelectedRows.push_back(m_nCurRow);
+ invalidateSelectedRegion(m_nCurRow+1, m_nCurRow, rCells);
+ }
}
}
}
- }
- else
- {
- //if nothing is selected and the current row isn't the upper one
- //select the current and one row above
- //otherwise select only the upper row
- if(m_nCurRow>0)
- {
- m_nRowSelected.push_back(m_nCurRow);
- m_nCurRow--;
- m_nRowSelected.push_back(m_nCurRow);
- invalidateSelectedRegion(m_nCurRow+1, m_nCurRow, rCells);
- }
else
{
- m_nRowSelected.push_back(m_nCurRow);
- invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells);
+ //if nothing is selected and the current row isn't the upper one
+ //select the current and one row above
+ //otherwise select only the upper row
+ if(m_nCurRow>0)
+ {
+ m_aSelectedRows.push_back(m_nCurRow);
+ m_nCurRow--;
+ m_aSelectedRows.push_back(m_nCurRow);
+ invalidateSelectedRegion(m_nCurRow+1, m_nCurRow, rCells);
+ }
+ else
+ {
+ m_aSelectedRows.push_back(m_nCurRow);
+ invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells);
+ }
}
+ m_pSelEngine->SetAnchor(sal_True);
+ m_nAnchor = m_nCurRow;
+ ensureVisible(m_nCurColumn, m_nCurRow, false);
+ selectionChanged = true;
+ bSuccess = true;
}
- m_pSelEngine->SetAnchor(sal_True);
- m_nAnchor = m_nCurRow;
- ensureVisible(m_nCurColumn, m_nCurRow, false);
- m_rAntiImpl.selectionChanged(true);
- bSuccess = true;
}
- }
- break;
- case cursorSelectRowDown:
- {
- if(m_pSelEngine->GetSelectionMode() == NO_SELECTION)
- bSuccess = false;
- else if(m_pSelEngine->GetSelectionMode() == SINGLE_SELECTION)
- {
- bSuccess = false;
- }
- else
+ break;
+ case cursorSelectRowDown:
{
- if(m_nRowSelected.size()>0)
+ if(m_pSelEngine->GetSelectionMode() == NO_SELECTION)
+ bSuccess = false;
+ else if(m_pSelEngine->GetSelectionMode() == SINGLE_SELECTION)
+ {
+ bSuccess = false;
+ }
+ else
{
- //the anchor wasn't set -> a region is not selected, that's why clear all selection
- //and select the current row
- if(m_nAnchor==-1)
+ if(m_aSelectedRows.size()>0)
{
- for(std::vector<RowPos>::iterator it=m_nRowSelected.begin();
- it!=m_nRowSelected.end();++it)
+ //the anchor wasn't set -> a region is not selected, that's why clear all selection
+ //and select the current row
+ if(m_nAnchor==-1)
{
- invalidateSelectedRegion(*it, *it, rCells);
- }
- m_nRowSelected.clear();
- m_nRowSelected.push_back(m_nCurRow);
- invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells);
+ for(std::vector<RowPos>::iterator it=m_aSelectedRows.begin();
+ it!=m_aSelectedRows.end();++it)
+ {
+ invalidateSelectedRegion(*it, *it, rCells);
+ }
+ m_aSelectedRows.clear();
+ m_aSelectedRows.push_back(m_nCurRow);
+ invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells);
+ }
+ else
+ {
+ //a region is already selected, prevRow is last selected row and the row beneath - nextRow - should be selected
+ int prevRow = getRowSelectedNumber(m_aSelectedRows, m_nCurRow);
+ int nextRow = getRowSelectedNumber(m_aSelectedRows, m_nCurRow+1);
+ if(prevRow>-1)
+ {
+ //if m_nCurRow isn't the last one, can move down, otherwise not
+ if(m_nCurRow<m_nRowCount-1)
+ m_nCurRow++;
+ else
+ return bSuccess = true;
+ //if next row already selected, deselect it, otherwise select it
+ if(nextRow>-1 && m_aSelectedRows[nextRow] == m_nCurRow)
+ {
+ m_aSelectedRows.erase(m_aSelectedRows.begin()+prevRow);
+ invalidateSelectedRegion(m_nCurRow-1, m_nCurRow-1, rCells);
+ }
+ else
+ {
+ m_aSelectedRows.push_back(m_nCurRow);
+ invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells);
+ }
+ }
+ else
+ {
+ if(m_nCurRow<m_nRowCount-1)
+ {
+ m_aSelectedRows.push_back(m_nCurRow);
+ m_nCurRow++;
+ m_aSelectedRows.push_back(m_nCurRow);
+ invalidateSelectedRegion(m_nCurRow-1, m_nCurRow, rCells);
+ }
+ }
}
+ }
else
{
- //a region is already selected, prevRow is last selected row and the row beneath - nextRow - should be selected
- int prevRow = getRowSelectedNumber(m_nRowSelected, m_nCurRow);
- int nextRow = getRowSelectedNumber(m_nRowSelected, m_nCurRow+1);
- if(prevRow>-1)
- {
- //if m_nCurRow isn't the last one, can move down, otherwise not
- if(m_nCurRow<m_nRowCount-1)
- m_nCurRow++;
- else
- return bSuccess = true;
- //if next row already selected, deselect it, otherwise select it
- if(nextRow>-1 && m_nRowSelected[nextRow] == m_nCurRow)
- {
- m_nRowSelected.erase(m_nRowSelected.begin()+prevRow);
- invalidateSelectedRegion(m_nCurRow-1, m_nCurRow-1, rCells);
- }
- else
- {
- m_nRowSelected.push_back(m_nCurRow);
- invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells);
- }
+ //there wasn't any selection, select current and row beneath, otherwise only row beneath
+ if(m_nCurRow<m_nRowCount-1)
+ {
+ m_aSelectedRows.push_back(m_nCurRow);
+ m_nCurRow++;
+ m_aSelectedRows.push_back(m_nCurRow);
+ invalidateSelectedRegion(m_nCurRow-1, m_nCurRow, rCells);
}
else
{
- if(m_nCurRow<m_nRowCount-1)
- {
- m_nRowSelected.push_back(m_nCurRow);
- m_nCurRow++;
- m_nRowSelected.push_back(m_nCurRow);
- invalidateSelectedRegion(m_nCurRow-1, m_nCurRow, rCells);
- }
+ m_aSelectedRows.push_back(m_nCurRow);
+ invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells);
}
}
+ m_pSelEngine->SetAnchor(sal_True);
+ m_nAnchor = m_nCurRow;
+ ensureVisible(m_nCurColumn, m_nCurRow, false);
+ selectionChanged = true;
+ bSuccess = true;
}
+ }
+ break;
+
+ case cursorSelectRowAreaTop:
+ {
+ if(m_pSelEngine->GetSelectionMode() == NO_SELECTION)
+ bSuccess = false;
+ else if(m_pSelEngine->GetSelectionMode() == SINGLE_SELECTION)
+ bSuccess = false;
else
{
- //there wasn't any selection, select current and row beneath, otherwise only row beneath
- if(m_nCurRow<m_nRowCount-1)
+ //select the region between the current and the upper row
+ RowPos iter = m_nCurRow;
+ invalidateSelectedRegion(m_nCurRow, 0, rCells);
+ //put the rows in vector
+ while(iter>=0)
{
- m_nRowSelected.push_back(m_nCurRow);
- m_nCurRow++;
- m_nRowSelected.push_back(m_nCurRow);
- invalidateSelectedRegion(m_nCurRow-1, m_nCurRow, rCells);
- }
- else
- {
- m_nRowSelected.push_back(m_nCurRow);
- invalidateSelectedRegion(m_nCurRow, m_nCurRow, rCells);
+ if ( !isRowSelected( iter ) )
+ m_aSelectedRows.push_back(iter);
+ --iter;
}
+ m_nCurRow = 0;
+ m_nAnchor = m_nCurRow;
+ m_pSelEngine->SetAnchor(sal_True);
+ ensureVisible(m_nCurColumn, 0, false);
+ selectionChanged = true;
+ bSuccess = true;
}
- m_pSelEngine->SetAnchor(sal_True);
- m_nAnchor = m_nCurRow;
- ensureVisible(m_nCurColumn, m_nCurRow, false);
- m_rAntiImpl.selectionChanged(true);
- bSuccess = true;
}
- }
break;
- case cursorSelectRowAreaTop:
- {
- if(m_pSelEngine->GetSelectionMode() == NO_SELECTION)
- bSuccess = false;
- else if(m_pSelEngine->GetSelectionMode() == SINGLE_SELECTION)
- bSuccess = false;
- else
+
+ case cursorSelectRowAreaBottom:
{
- //select the region between the current and the upper row
+ if(m_pSelEngine->GetSelectionMode() == NO_SELECTION)
+ return bSuccess = false;
+ else if(m_pSelEngine->GetSelectionMode() == SINGLE_SELECTION)
+ return bSuccess = false;
+ //select the region between the current and the last row
RowPos iter = m_nCurRow;
- invalidateSelectedRegion(m_nCurRow, 0, rCells);
- //put the rows in vector
- while(iter>=0)
+ invalidateSelectedRegion(m_nCurRow, m_nRowCount-1, rCells);
+ //put the rows in the vector
+ while(iter<=m_nRowCount)
{
- if(!isRowSelected(m_nRowSelected, iter))
- m_nRowSelected.push_back(iter);
- --iter;
+ if ( !isRowSelected( iter ) )
+ m_aSelectedRows.push_back(iter);
+ ++iter;
}
- m_nCurRow = 0;
+ m_nCurRow = m_nRowCount-1;
m_nAnchor = m_nCurRow;
m_pSelEngine->SetAnchor(sal_True);
- ensureVisible(m_nCurColumn, 0, false);
- m_rAntiImpl.selectionChanged(true);
+ ensureVisible(m_nCurColumn, m_nRowCount-1, false);
+ selectionChanged = true;
bSuccess = true;
}
- }
- break;
- case cursorSelectRowAreaBottom:
- {
- if(m_pSelEngine->GetSelectionMode() == NO_SELECTION)
- return bSuccess = false;
- else if(m_pSelEngine->GetSelectionMode() == SINGLE_SELECTION)
- return bSuccess = false;
- //select the region between the current and the last row
- RowPos iter = m_nCurRow;
- invalidateSelectedRegion(m_nCurRow, m_nRowCount-1, rCells);
- //put the rows in the vector
- while(iter<=m_nRowCount)
- {
- if(!isRowSelected(m_nRowSelected, iter))
- m_nRowSelected.push_back(iter);
- ++iter;
- }
- m_nCurRow = m_nRowCount-1;
- m_nAnchor = m_nCurRow;
- m_pSelEngine->SetAnchor(sal_True);
- ensureVisible(m_nCurColumn, m_nRowCount-1, false);
- m_rAntiImpl.selectionChanged(true);
- bSuccess = true;
- }
break;
default:
DBG_ERROR( "TableControl_Impl::dispatchAction: unsupported action!" );
+ break;
+ }
+
+ if ( bSuccess && selectionChanged )
+ {
+ m_rAntiImpl.Select();
}
+
return bSuccess;
}
- //--------------------------------------------------------------------
+ //------------------------------------------------------------------------------------------------------------------
void TableControl_Impl::impl_ni_doSwitchCursor( bool _bShow )
{
PTableRenderer pRenderer = !!m_pModel ? m_pModel->getRenderer() : PTableRenderer();
@@ -1537,16 +1860,14 @@ namespace svt { namespace table
{
Rectangle aCellRect;
impl_getCellRect( m_nCurColumn, m_nCurRow, aCellRect );
- if(!m_pModel->hasRowHeaders() && m_nCurColumn == 0)
- aCellRect.Left()++;
if ( _bShow )
- pRenderer->ShowCellCursor( *m_pDataWindow, aCellRect);
+ pRenderer->ShowCellCursor( *m_pDataWindow, aCellRect );
else
- pRenderer->HideCellCursor( *m_pDataWindow, aCellRect);
+ pRenderer->HideCellCursor( *m_pDataWindow, aCellRect );
}
}
- //--------------------------------------------------------------------
+ //------------------------------------------------------------------------------------------------------------------
void TableControl_Impl::impl_getCellRect( ColPos _nColumn, RowPos _nRow, Rectangle& _rCellRect ) const
{
DBG_CHECK_ME();
@@ -1560,164 +1881,236 @@ namespace svt { namespace table
return;
}
- Rectangle aAllCells;
- impl_getAllVisibleCellsArea( aAllCells );
-
- TableCellGeometry aCell( *this, aAllCells, _nColumn, _nRow );
+ TableCellGeometry aCell( *this, impl_getAllVisibleCellsArea(), _nColumn, _nRow );
_rCellRect = aCell.getRect();
- _rCellRect.Top()--;_rCellRect.Left()--;
}
- //-------------------------------------------------------------------------------
- RowPos TableControl_Impl::getCurrentRow(const Point& rPoint)
+
+ //------------------------------------------------------------------------------------------------------------------
+ RowPos TableControl_Impl::getRowAtPoint( const Point& rPoint ) const
+ {
+ DBG_CHECK_ME();
+ return impl_getRowForAbscissa( rPoint.Y() );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ ColPos TableControl_Impl::getColAtPoint( const Point& rPoint ) const
{
DBG_CHECK_ME();
- Rectangle rCellRect;
- RowPos newRowPos = -2;//-1 is HeaderRow
- ColPos newColPos = 0;
- for(int i=-1;i<m_nRowCount;i++)
+ return impl_getColumnForOrdinate( rPoint.X() );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ TableCell TableControl_Impl::hitTest( Point const & i_point ) const
+ {
+ TableCell aCell( getColAtPoint( i_point ), getRowAtPoint( i_point ) );
+ if ( aCell.nColumn > COL_ROW_HEADERS )
{
- for(int j=-1;j<m_nColumnCount;j++)
+ PColumnModel const pColumn = m_pModel->getColumnModel( aCell.nColumn );
+ MutableColumnMetrics const & rColInfo( m_aColumnWidths[ aCell.nColumn ] );
+ if ( ( rColInfo.getEnd() - 3 <= i_point.X() )
+ && ( rColInfo.getEnd() >= i_point.X() )
+ && pColumn->isResizable()
+ )
{
- impl_getCellRect(j,i,rCellRect);
- if((rPoint.X() >= rCellRect.Left() && rPoint.X() <= rCellRect.Right()) && rPoint.Y() >= rCellRect.Top() && rPoint.Y() <= rCellRect.Bottom())
- {
- newRowPos = i;
- newColPos = j;
- if(newColPos != -1)
- m_nCurColumn = newColPos;
- return newRowPos;
- }
+ aCell.eArea = ColumnDivider;
}
}
- return newRowPos;
+ return aCell;
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ ColumnMetrics TableControl_Impl::getColumnMetrics( ColPos const i_column ) const
+ {
+ DBG_CHECK_ME();
+
+ ENSURE_OR_RETURN( ( i_column >= 0 ) && ( i_column < m_pModel->getColumnCount() ),
+ "TableControl_Impl::getColumnMetrics: illegal column index!", ColumnMetrics() );
+ return (ColumnMetrics const &)m_aColumnWidths[ i_column ];
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ PTableModel TableControl_Impl::getModel() const
+ {
+ return m_pModel;
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ RowPos TableControl_Impl::getCurrentColumn() const
+ {
+ return m_nCurColumn;
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ RowPos TableControl_Impl::getCurrentRow() const
+ {
+ return m_nCurRow;
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ ::Size TableControl_Impl::getTableSizePixel() const
+ {
+ return m_pDataWindow->GetOutputSizePixel();
}
- //-------------------------------------------------------------------------------
- void TableControl_Impl::setCursorAtCurrentCell(const Point& rPoint)
+
+ //------------------------------------------------------------------------------------------------------------------
+ void TableControl_Impl::setPointer( Pointer const & i_pointer )
{
DBG_CHECK_ME();
- hideCursor();
- Rectangle rCellRect;
- RowPos newRowPos = -2;//-1 is HeaderRow
- ColPos newColPos = 0;
- for(int i=0;i<m_nRowCount;i++)
+ m_pDataWindow->SetPointer( i_pointer );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void TableControl_Impl::captureMouse()
+ {
+ m_pDataWindow->CaptureMouse();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void TableControl_Impl::releaseMouse()
+ {
+ m_pDataWindow->ReleaseMouse();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void TableControl_Impl::invalidate( TableArea const i_what )
+ {
+ switch ( i_what )
{
- for(int j=-1;j<m_nColumnCount;j++)
- {
- impl_getCellRect(j,i,rCellRect);
- if((rPoint.X() >= rCellRect.Left() && rPoint.X() <= rCellRect.Right()) && rPoint.Y() >= rCellRect.Top() && rPoint.Y() <= rCellRect.Bottom())
- {
- newRowPos = i;
- m_nCurRow = newRowPos;
- newColPos = j;
- if(newColPos == -1)
- m_nCurColumn = 0;
- else
- m_nCurColumn = newColPos;
- }
- }
+ case TableAreaColumnHeaders:
+ m_pDataWindow->Invalidate( calcHeaderRect( true ) );
+ break;
+
+ case TableAreaRowHeaders:
+ m_pDataWindow->Invalidate( calcHeaderRect( false ) );
+ break;
+
+ case TableAreaDataArea:
+ m_pDataWindow->Invalidate( impl_getAllVisibleDataCellArea() );
+ break;
+
+ case TableAreaAll:
+ m_pDataWindow->Invalidate();
+ break;
}
- showCursor();
}
- //-------------------------------------------------------------------------------
+
+ //------------------------------------------------------------------------------------------------------------------
+ long TableControl_Impl::pixelWidthToAppFont( long const i_pixels ) const
+ {
+ return m_pDataWindow->PixelToLogic( Size( i_pixels, 0 ), MAP_APPFONT ).Width();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void TableControl_Impl::hideTracking()
+ {
+ m_pDataWindow->HideTracking();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void TableControl_Impl::showTracking( Rectangle const & i_location, sal_uInt16 const i_flags )
+ {
+ m_pDataWindow->ShowTracking( i_location, i_flags );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ bool TableControl_Impl::activateCell( ColPos const i_col, RowPos const i_row )
+ {
+ DBG_CHECK_ME();
+ return goTo( i_col, i_row );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
void TableControl_Impl::invalidateSelectedRegion(RowPos _nPrevRow, RowPos _nCurRow, Rectangle& _rCellRect)
{
DBG_CHECK_ME();
- Rectangle aAllCells;
//get the visible area of the table control and set the Left and right border of the region to be repainted
- impl_getAllVisibleCellsArea( aAllCells );
+ Rectangle const aAllCells( impl_getAllVisibleCellsArea() );
_rCellRect.Left() = aAllCells.Left();
_rCellRect.Right() = aAllCells.Right();
- Rectangle rCells;
//if only one row is selected
if(_nPrevRow == _nCurRow)
{
- impl_getCellRect(m_nCurColumn,_nCurRow,rCells);
- _rCellRect.Top()=--rCells.Top();
- _rCellRect.Bottom()=rCells.Bottom();
+ Rectangle aCellRect;
+ impl_getCellRect( m_nCurColumn, _nCurRow, aCellRect );
+ _rCellRect.Top() = aCellRect.Top();
+ _rCellRect.Bottom() = aCellRect.Bottom();
}
//if the region is above the current row
else if(_nPrevRow < _nCurRow )
{
- impl_getCellRect(m_nCurColumn,_nPrevRow,rCells);
- _rCellRect.Top()= --rCells.Top();
- impl_getCellRect(m_nCurColumn,_nCurRow,rCells);
- _rCellRect.Bottom()=rCells.Bottom();
+ Rectangle aCellRect;
+ impl_getCellRect( m_nCurColumn, _nPrevRow, aCellRect );
+ _rCellRect.Top() = aCellRect.Top();
+ impl_getCellRect( m_nCurColumn, _nCurRow, aCellRect );
+ _rCellRect.Bottom() = aCellRect.Bottom();
}
//if the region is beneath the current row
else
{
- impl_getCellRect(m_nCurColumn,_nCurRow,rCells);
- _rCellRect.Top()= --rCells.Top();
- impl_getCellRect(m_nCurColumn,_nPrevRow,rCells);
- _rCellRect.Bottom()=rCells.Bottom();
+ Rectangle aCellRect;
+ impl_getCellRect( m_nCurColumn, _nCurRow, aCellRect );
+ _rCellRect.Top() = aCellRect.Top();
+ impl_getCellRect( m_nCurColumn, _nPrevRow, aCellRect );
+ _rCellRect.Bottom() = aCellRect.Bottom();
}
m_pDataWindow->Invalidate(_rCellRect);
}
- //-------------------------------------------------------------------------------
- //this method is to be called, when a new row is added
- void TableControl_Impl::invalidateRow(RowPos _nRowPos, Rectangle& _rCellRect)
+ //------------------------------------------------------------------------------------------------------------------
+ void TableControl_Impl::invalidateRowRange( RowPos const i_firstRow, RowPos const i_lastRow )
{
- if(m_nCurRow < 0)
- m_nCurRow = 0;
- if(m_nCursorHidden == 2)
+ if ( m_nCursorHidden == 2 )
+ // WTF? what kind of hack is this?
--m_nCursorHidden;
- impl_getAllVisibleCellsArea( _rCellRect );
- TableRowGeometry _rRow( *this, _rCellRect, _nRowPos);
- impl_ni_updateScrollbars();
- m_pDataWindow->Invalidate(_rRow.getRect());
- }
- //-------------------------------------------------------------------------------
- std::vector<RowPos>& TableControl_Impl::getSelectedRows()
- {
- return m_nRowSelected;
- }
- //--------------------------------------------------------------------
- void TableControl_Impl::clearSelection()
- {
- m_nRowSelected.clear();
- }
- //--------------------------------------------------------------------
- //-------------------------------------------------------------------------------
- void TableControl_Impl::removeSelectedRow(RowPos _nRowPos)
- {
- int i =0;
- //if the row is selected, remove it from the selection vector
- if(isRowSelected(m_nRowSelected, _nRowPos))
- {
- if(m_nRowSelected.size()>1)
- m_nRowSelected.erase(m_nRowSelected.begin()+_nRowPos);
- else
- m_nRowSelected.clear();
- }
- //after removing a row, row positions must be updated, so selected rows could stay selected
- if(m_nRowSelected.size()>1)
+
+ RowPos const firstRow = i_firstRow < m_nTopRow ? m_nTopRow : i_firstRow;
+ RowPos const lastVisibleRow = m_nTopRow + impl_getVisibleRows( true ) - 1;
+ RowPos const lastRow = ( ( i_lastRow == ROW_INVALID ) || ( i_lastRow > lastVisibleRow ) ) ? lastVisibleRow : i_lastRow;
+
+ Rectangle aInvalidateRect;
+
+ Rectangle const aVisibleCellsArea( impl_getAllVisibleCellsArea() );
+ TableRowGeometry aRow( *this, aVisibleCellsArea, firstRow, true );
+ while ( aRow.isValid() && ( aRow.getRow() <= lastRow ) )
{
- for(std::vector<RowPos>::iterator it=m_nRowSelected.begin();it!=m_nRowSelected.end();++it)
- {
- if(*it > _nRowPos)
- m_nRowSelected[i]=*it-1;
- ++i;
- }
+ aInvalidateRect.Union( aRow.getRect() );
+ aRow.moveDown();
}
- if(_nRowPos == 0)
- m_nCurRow = 0;
- else
- m_nCurRow = _nRowPos-1;
+
+ if ( i_lastRow == ROW_INVALID )
+ aInvalidateRect.Bottom() = m_pDataWindow->GetOutputSizePixel().Height();
+
+ m_pDataWindow->Invalidate( aInvalidateRect );
}
+
//------------------------------------------------------------------------------
- void TableControl_Impl::invalidateRows()
+ void TableControl_Impl::checkCursorPosition()
{
- impl_ni_updateScrollbars();
+ DBG_CHECK_ME();
+
TableSize nVisibleRows = impl_getVisibleRows(true);
TableSize nVisibleCols = impl_getVisibleColumns(true);
- if(m_nTopRow+nVisibleRows>m_nRowCount && m_nRowCount>=nVisibleRows)
- m_nTopRow--;
+ if ( ( m_nTopRow + nVisibleRows > m_nRowCount )
+ && ( m_nRowCount >= nVisibleRows )
+ )
+ {
+ --m_nTopRow;
+ }
else
+ {
m_nTopRow = 0;
- if(m_nLeftColumn+nVisibleCols>m_nColumnCount && m_nColumnCount>=nVisibleCols)
- m_nLeftColumn--;
+ }
+
+ if ( ( m_nLeftColumn + nVisibleCols > m_nColumnCount )
+ && ( m_nColumnCount >= nVisibleCols )
+ )
+ {
+ --m_nLeftColumn;
+ }
else
+ {
m_nLeftColumn = 0;
+ }
+
m_pDataWindow->Invalidate();
}
@@ -1736,7 +2129,7 @@ namespace svt { namespace table
}
//--------------------------------------------------------------------
- TableSize TableControl_Impl::impl_getVisibleColumns( bool _bAcceptPartialRow ) const
+ TableSize TableControl_Impl::impl_getVisibleColumns( bool _bAcceptPartialCol ) const
{
DBG_CHECK_ME();
@@ -1746,7 +2139,7 @@ namespace svt { namespace table
Rectangle( Point( 0, 0 ), m_pDataWindow->GetOutputSizePixel() ),
m_nLeftColumn,
*this,
- _bAcceptPartialRow
+ _bAcceptPartialCol
);
}
@@ -1757,12 +2150,15 @@ namespace svt { namespace table
// TODO: give veto listeners a chance
- if ( ( _nColumn < -1 ) || ( _nColumn >= m_nColumnCount )
- || ( _nRow < -1 ) || ( _nRow >= m_nRowCount )
+ if ( ( _nColumn < 0 ) || ( _nColumn >= m_nColumnCount )
+ || ( _nRow < 0 ) || ( _nRow >= m_nRowCount )
)
+ {
+ OSL_ENSURE( false, "TableControl_Impl::goTo: invalid row or column index!" );
return false;
+ }
- TempHideCursor aHideCursor( *this );
+ SuppressCursor aHideCursor( *this );
m_nCurColumn = _nColumn;
m_nCurRow = _nRow;
@@ -1779,32 +2175,40 @@ namespace svt { namespace table
&& ( _nRow >= 0 ) && ( _nRow < m_nRowCount ),
"TableControl_Impl::ensureVisible: invalid coordinates!" );
- TempHideCursor aHideCursor( *this );
+ SuppressCursor aHideCursor( *this );
if ( _nColumn < m_nLeftColumn )
- impl_ni_ScrollColumns( _nColumn - m_nLeftColumn );
+ impl_scrollColumns( _nColumn - m_nLeftColumn );
else
{
TableSize nVisibleColumns = impl_getVisibleColumns( _bAcceptPartialVisibility );
if ( _nColumn > m_nLeftColumn + nVisibleColumns - 1 )
{
- impl_ni_ScrollColumns( _nColumn - ( m_nLeftColumn + nVisibleColumns - 1 ) );
+ impl_scrollColumns( _nColumn - ( m_nLeftColumn + nVisibleColumns - 1 ) );
// TODO: since not all columns have the same width, this might in theory result
// in the column still not being visible.
}
}
if ( _nRow < m_nTopRow )
- impl_ni_ScrollRows( _nRow - m_nTopRow );
+ impl_scrollRows( _nRow - m_nTopRow );
else
{
TableSize nVisibleRows = impl_getVisibleRows( _bAcceptPartialVisibility );
if ( _nRow > m_nTopRow + nVisibleRows - 1 )
- impl_ni_ScrollRows( _nRow - ( m_nTopRow + nVisibleRows - 1 ) );
+ impl_scrollRows( _nRow - ( m_nTopRow + nVisibleRows - 1 ) );
}
}
//--------------------------------------------------------------------
+ ::rtl::OUString TableControl_Impl::getCellContentAsString( RowPos const i_row, ColPos const i_col )
+ {
+ ::com::sun::star::uno::Any content;
+ m_pModel->getCellContent( i_col, i_row, content );
+ return CellValueConversion::convertToString( content );
+ }
+
+ //--------------------------------------------------------------------
TableSize TableControl_Impl::impl_ni_ScrollRows( TableSize _nRowDelta )
{
// compute new top row
@@ -1818,10 +2222,10 @@ namespace svt { namespace table
m_nTopRow = nNewTopRow;
// if updates are enabled currently, scroll the viewport
- if ( m_rAntiImpl.IsUpdateMode() && ( m_nTopRow != nOldTopRow ) )
+ if ( m_nTopRow != nOldTopRow )
{
DBG_SUSPEND_INV( INV_SCROLL_POSITION );
- TempHideCursor aHideCursor( *this );
+ SuppressCursor aHideCursor( *this );
// TODO: call a onStartScroll at our listener (or better an own onStartScroll,
// which hides the cursor and then calls the listener)
// Same for onEndScroll
@@ -1844,43 +2248,68 @@ namespace svt { namespace table
m_pVScroll->SetThumbPos( m_nTopRow );
}
+ // The scroll bar availaility might change when we scrolled. This is because we do not hide
+ // the scrollbar when it is, in theory, unnecessary, but currently at a position > 0. In this case, it will
+ // be auto-hidden when it's scrolled back to pos 0.
+ if ( m_nTopRow == 0 )
+ m_rAntiImpl.PostUserEvent( LINK( this, TableControl_Impl, OnUpdateScrollbars ) );
+
return (TableSize)( m_nTopRow - nOldTopRow );
}
//--------------------------------------------------------------------
+ TableSize TableControl_Impl::impl_scrollRows( TableSize const i_rowDelta )
+ {
+ DBG_CHECK_ME();
+ return impl_ni_ScrollRows( i_rowDelta );
+ }
+
+ //--------------------------------------------------------------------
TableSize TableControl_Impl::impl_ni_ScrollColumns( TableSize _nColumnDelta )
{
// compute new left column
- ColPos nNewLeftColumn =
+ const ColPos nNewLeftColumn =
::std::max(
::std::min( (ColPos)( m_nLeftColumn + _nColumnDelta ), (ColPos)( m_nColumnCount - 1 ) ),
(ColPos)0
);
- ColPos nOldLeftColumn = m_nLeftColumn;
+ const ColPos nOldLeftColumn = m_nLeftColumn;
m_nLeftColumn = nNewLeftColumn;
// if updates are enabled currently, scroll the viewport
- if ( m_rAntiImpl.IsUpdateMode() && ( m_nLeftColumn != nOldLeftColumn ) )
+ if ( m_nLeftColumn != nOldLeftColumn )
{
DBG_SUSPEND_INV( INV_SCROLL_POSITION );
- TempHideCursor aHideCursor( *this );
+ SuppressCursor aHideCursor( *this );
// TODO: call a onStartScroll at our listener (or better an own onStartScroll,
// which hides the cursor and then calls the listener)
// Same for onEndScroll
// scroll the view port, if possible
- Rectangle aDataArea( Point( m_nRowHeaderWidthPixel, 0 ), m_pDataWindow->GetOutputSizePixel() );
+ const Rectangle aDataArea( Point( m_nRowHeaderWidthPixel, 0 ), m_pDataWindow->GetOutputSizePixel() );
long nPixelDelta =
- ( m_nLeftColumn > 0 ? m_aAccColumnWidthsPixel[ m_nLeftColumn - 1 ] : 0 )
- - ( nOldLeftColumn > 0 ? m_aAccColumnWidthsPixel[ nOldLeftColumn - 1 ] : 0 );
+ m_aColumnWidths[ nOldLeftColumn ].getStart()
+ - m_aColumnWidths[ m_nLeftColumn ].getStart();
+
+ // update our column positions
+ // Do this *before* scrolling, as SCROLL_UPDATE will trigger a paint, which already needs the correct
+ // information in m_aColumnWidths
+ for ( ColumnPositions::iterator colPos = m_aColumnWidths.begin();
+ colPos != m_aColumnWidths.end();
+ ++colPos
+ )
+ {
+ colPos->move( nPixelDelta );
+ }
+ // scroll the window content (if supported and possible), or invalidate the complete window
if ( m_pDataWindow->GetBackground().IsScrollable()
&& abs( nPixelDelta ) < aDataArea.GetWidth()
)
{
- m_pDataWindow->Scroll( (long)-nPixelDelta, 0, aDataArea, SCROLL_CLIP | SCROLL_UPDATE );
+ m_pDataWindow->Scroll( nPixelDelta, 0, aDataArea, SCROLL_CLIP | SCROLL_UPDATE );
}
else
m_pDataWindow->Invalidate( INVALIDATE_UPDATE );
@@ -1889,39 +2318,55 @@ namespace svt { namespace table
m_pHScroll->SetThumbPos( m_nLeftColumn );
}
+ // The scroll bar availaility might change when we scrolled. This is because we do not hide
+ // the scrollbar when it is, in theory, unnecessary, but currently at a position > 0. In this case, it will
+ // be auto-hidden when it's scrolled back to pos 0.
+ if ( m_nLeftColumn == 0 )
+ m_rAntiImpl.PostUserEvent( LINK( this, TableControl_Impl, OnUpdateScrollbars ) );
+
return (TableSize)( m_nLeftColumn - nOldLeftColumn );
}
- //-------------------------------------------------------------------------------
- SelectionEngine* TableControl_Impl::getSelEngine()
+
+ //------------------------------------------------------------------------------------------------------------------
+ TableSize TableControl_Impl::impl_scrollColumns( TableSize const i_columnDelta )
{
- return m_pSelEngine;
+ DBG_CHECK_ME();
+ return impl_ni_ScrollColumns( i_columnDelta );
}
- //-------------------------------------------------------------------------------
- TableDataWindow* TableControl_Impl::getDataWindow()
+
+ //------------------------------------------------------------------------------------------------------------------
+ SelectionEngine* TableControl_Impl::getSelEngine()
{
- return m_pDataWindow;
+ return m_pSelEngine;
}
- //-------------------------------------------------------------------------------
+
+ //------------------------------------------------------------------------------------------------------------------
ScrollBar* TableControl_Impl::getHorzScrollbar()
{
return m_pHScroll;
}
- //-------------------------------------------------------------------------------
+
+ //------------------------------------------------------------------------------------------------------------------
ScrollBar* TableControl_Impl::getVertScrollbar()
{
return m_pVScroll;
}
- //-------------------------------------------------------------------------------
- sal_Bool TableControl_Impl::isRowSelected(const ::std::vector<RowPos>& selectedRows, RowPos current)
+
+ //------------------------------------------------------------------------------------------------------------------
+ bool TableControl_Impl::isRowSelected( RowPos i_row ) const
{
- return ::std::find(selectedRows.begin(),selectedRows.end(),current) != selectedRows.end();
+ return ::std::find( m_aSelectedRows.begin(), m_aSelectedRows.end(), i_row ) != m_aSelectedRows.end();
}
- //-------------------------------------------------------------------------------
- bool TableControl_Impl::isRowSelected(RowPos current)
+
+ //------------------------------------------------------------------------------------------------------------------
+ RowPos TableControl_Impl::getSelectedRowIndex( size_t const i_selectionIndex ) const
{
- return ::std::find(m_nRowSelected.begin(),m_nRowSelected.end(),current) != m_nRowSelected.end();
+ if ( i_selectionIndex < m_aSelectedRows.size() )
+ return m_aSelectedRows[ i_selectionIndex ];
+ return ROW_INVALID;
}
- //-------------------------------------------------------------------------------
+
+ //------------------------------------------------------------------------------------------------------------------
int TableControl_Impl::getRowSelectedNumber(const ::std::vector<RowPos>& selectedRows, RowPos current)
{
std::vector<RowPos>::const_iterator it = ::std::find(selectedRows.begin(),selectedRows.end(),current);
@@ -1931,281 +2376,158 @@ namespace svt { namespace table
}
return -1;
}
- //-------------------------------------------------------------------------------
- bool TableControl_Impl::isTooltipActive()
- {
- return m_rAntiImpl.isTooltip();
- }
- //-------------------------------------------------------------------------------
- ::rtl::OUString& TableControl_Impl::setTooltip(const Point& rPoint )
+
+ //--------------------------------------------------------------------
+ ColPos TableControl_Impl::impl_getColumnForOrdinate( long const i_ordinate ) const
{
- ::rtl::OUString aTooltipText;
- RowPos current = getCurrentRow(rPoint);
- com::sun::star::uno::Sequence< sal_Int32 > cols = m_rAntiImpl.getColumnsForTooltip();
- com::sun::star::uno::Sequence< ::rtl::OUString > text = m_rAntiImpl.getTextForTooltip();
- if(text.getLength()==0 && cols.getLength()==0)
- {
- ::com::sun::star::uno::Any content = m_pModel->getCellContent()[current][m_nCurColumn];
- aTooltipText = convertToString(content);
- }
- else if(text.getLength() == 0)
- {
- for(int i=0; i<cols.getLength(); i++)
- {
- if(i==0)
- {
- ::com::sun::star::uno::Any content = m_pModel->getCellContent()[current][cols[i]];
- aTooltipText = convertToString(content);
- }
- else
- {
- aTooltipText+= ::rtl::OUString::createFromAscii("\n");
- ::com::sun::star::uno::Any content = m_pModel->getCellContent()[current][cols[i]];
- aTooltipText += convertToString(content);
- }
- }
- }
- else if(cols.getLength() == 0)
- {
- for(int i=0; i<text.getLength(); i++)
- {
- if(i==0)
- aTooltipText = text[i];
- else
- {
- aTooltipText+= ::rtl::OUString::createFromAscii("\n");
- aTooltipText+= text[i];
- }
- }
- }
- else
+ DBG_CHECK_ME();
+
+ if ( ( m_aColumnWidths.empty() ) || ( i_ordinate < 0 ) )
+ return COL_INVALID;
+
+ if ( i_ordinate < m_nRowHeaderWidthPixel )
+ return COL_ROW_HEADERS;
+
+ long const ordinate = i_ordinate - m_nRowHeaderWidthPixel;
+
+ ColumnPositions::const_iterator lowerBound = ::std::lower_bound(
+ m_aColumnWidths.begin(),
+ m_aColumnWidths.end(),
+ ordinate + 1,
+ ColumnInfoPositionLess()
+ );
+ if ( lowerBound == m_aColumnWidths.end() )
{
- int nCols = cols.getLength();
- int mText = text.getLength();
- if(nCols < mText )
- cols.realloc(mText);
- else if(mText < nCols)
- text.realloc(nCols);
- for(int i=0; i<cols.getLength(); i++)
- {
- if(i==0)
- {
- ::com::sun::star::uno::Any content = m_pModel->getCellContent()[current][cols[i]];
- aTooltipText = text[i] + convertToString(content);
- }
- else
- {
- aTooltipText+= ::rtl::OUString::createFromAscii("\n");
- aTooltipText+= text[i];
- if(nCols > i)
- {
- ::com::sun::star::uno::Any content = m_pModel->getCellContent()[current][cols[i]];
- ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >xGraphic;
- aTooltipText += convertToString(content);
- }
- }
- }
+ // point is *behind* the start of the last column ...
+ if ( ordinate < m_aColumnWidths.rbegin()->getEnd() )
+ // ... but still before its end
+ return m_nColumnCount - 1;
+ return COL_INVALID;
}
- return m_aTooltipText = aTooltipText;
+ return lowerBound - m_aColumnWidths.begin();
}
+
//--------------------------------------------------------------------
- void TableControl_Impl::resizeColumn(const Point& rPoint)
- {
- Pointer aNewPointer(POINTER_ARROW);
- int headerRowWidth = 0;
- if(m_pModel->hasRowHeaders())
- headerRowWidth = m_rAntiImpl.LogicToPixel( Size(m_pModel->getRowHeaderWidth(), 0 ), MAP_APPFONT ).Width();
- int resizingColumn=m_nCurColumn-m_nLeftColumn;
- PColumnModel pColumn = m_pModel->getColumnModel(m_nCurColumn);
- impl_ni_getAccVisibleColWidths();
- int newColWidth = m_aColumnWidthsPixel[m_nCurColumn];
- //make resize area for the separator wider
- int nLeft = m_aVisibleColumnWidthsPixel[resizingColumn]-4;
- //subtract 1 from m_aAccColumnWidthPixel because right border should be part of the current cell
- int nRight = m_aVisibleColumnWidthsPixel[resizingColumn]-1;
- if( rPoint.X()> nLeft && rPoint.X()<nRight && pColumn->isResizable())
- aNewPointer = Pointer( POINTER_HSPLIT );
- //MouseButton was pressed but not yet released, mouse is moving
- if(m_bResizing)
- {
- if(rPoint.X() > m_pDataWindow->GetOutputSizePixel().Width() || rPoint.X() < m_aVisibleColumnWidthsPixel[resizingColumn]-newColWidth)
- aNewPointer = Pointer( POINTER_NOTALLOWED);
- else
- aNewPointer = Pointer( POINTER_HSPLIT );
- m_pDataWindow->HideTracking();
- int lineHeight = 0;
- if(m_pModel->hasColumnHeaders())
- lineHeight+= m_nColHeaderHeightPixel;
- lineHeight+=m_nRowHeightPixel*m_nRowCount;
- int gridHeight = m_pDataWindow->GetOutputSizePixel().Height();
- if(lineHeight >= gridHeight)
- lineHeight = gridHeight;
- m_pDataWindow->ShowTracking(Rectangle(Point(rPoint.X(),0), Size(1, lineHeight )),
- SHOWTRACK_SPLIT | SHOWTRACK_WINDOW);
- }
- m_pDataWindow->SetPointer(aNewPointer);
+ RowPos TableControl_Impl::impl_getRowForAbscissa( long const i_abscissa ) const
+ {
+ DBG_CHECK_ME();
+
+ if ( i_abscissa < 0 )
+ return ROW_INVALID;
+
+ if ( i_abscissa < m_nColHeaderHeightPixel )
+ return ROW_COL_HEADERS;
+
+ long const abscissa = i_abscissa - m_nColHeaderHeightPixel;
+ long const row = m_nTopRow + abscissa / m_nRowHeightPixel;
+ return row < m_pModel->getRowCount() ? row : ROW_INVALID;
}
+
//--------------------------------------------------------------------
- bool TableControl_Impl::startResizeColumn(const Point& rPoint)
+ bool TableControl_Impl::markRowAsDeselected( RowPos const i_rowIndex )
{
- m_bResizingGrid = false;
- m_nResizingColumn = m_nCurColumn;
- PColumnModel pColumn = m_pModel->getColumnModel(m_nResizingColumn);
- //make resize area for the separator wider
- int nLeft = m_aVisibleColumnWidthsPixel[m_nResizingColumn-m_nLeftColumn]-4;
- int nRight = m_aVisibleColumnWidthsPixel[m_nResizingColumn-m_nLeftColumn]-1;
- if(rPoint.X()> nLeft && rPoint.X()<nRight && pColumn->isResizable())
- {
- m_pDataWindow->CaptureMouse();
- m_bResizing = true;
- }
- return m_bResizing;
+ DBG_CHECK_ME();
+
+ ::std::vector< RowPos >::iterator selPos = ::std::find( m_aSelectedRows.begin(), m_aSelectedRows.end(), i_rowIndex );
+ if ( selPos == m_aSelectedRows.end() )
+ return false;
+
+ m_aSelectedRows.erase( selPos );
+ return true;
}
+
//--------------------------------------------------------------------
- bool TableControl_Impl::endResizeColumn(const Point& rPoint)
- {
- if(m_bResizing)
- {
- m_pDataWindow->HideTracking();
- PColumnModel pColumn = m_pModel->getColumnModel(m_nResizingColumn);
- int maxWidth = m_rAntiImpl.LogicToPixel( Size( pColumn->getMaxWidth(), 0 ), MAP_APPFONT ).Width();
- int minWidth = m_rAntiImpl.LogicToPixel( Size( pColumn->getMinWidth(), 0 ), MAP_APPFONT ).Width();
- int resizeCol = m_nResizingColumn-m_nLeftColumn;
- //new position of mouse
- int actX = rPoint.X();
- //old position of right border
- int oldX = m_aVisibleColumnWidthsPixel[resizeCol];
- //position of left border if cursor in the first cell
- int leftX = 0;
- if(m_nResizingColumn > m_nLeftColumn)
- leftX = m_aVisibleColumnWidthsPixel[resizeCol-1];
- else if(m_nResizingColumn == m_nLeftColumn && m_pModel->hasRowHeaders())
- leftX = m_rAntiImpl.LogicToPixel( Size( m_pModel->getRowHeaderWidth(), 0 ), MAP_APPFONT ).Width();
- int actWidth = actX - leftX;
- int newActWidth = 0;
- //minimize the column width
- if(oldX > actX && actX >= leftX)
+ bool TableControl_Impl::markRowAsSelected( RowPos const i_rowIndex )
+ {
+ DBG_CHECK_ME();
+
+ if ( isRowSelected( i_rowIndex ) )
+ return false;
+
+ SelectionMode const eSelMode = getSelEngine()->GetSelectionMode();
+ switch ( eSelMode )
+ {
+ case SINGLE_SELECTION:
+ if ( !m_aSelectedRows.empty() )
{
- if(minWidth < actWidth)
- {
- newActWidth = m_rAntiImpl.PixelToLogic( Size( actWidth, 0 ), MAP_APPFONT ).Width();
- pColumn->setPreferredWidth(newActWidth);
- }
- else
- pColumn->setPreferredWidth(pColumn->getMinWidth());
- if(m_nLeftColumn != 0)
- impl_updateLeftColumn();
+ OSL_ENSURE( m_aSelectedRows.size() == 1, "TableControl::markRowAsSelected: SingleSelection with more than one selected element?" );
+ m_aSelectedRows[0] = i_rowIndex;
+ break;
+ }
+ // fall through
+
+ case MULTIPLE_SELECTION:
+ m_aSelectedRows.push_back( i_rowIndex );
+ break;
+
+ default:
+ OSL_ENSURE( false, "TableControl_Impl::markRowAsSelected: unsupported selection mode!" );
+ return false;
}
- else if(oldX < actX)
+
+ return true;
+ }
+
+ //--------------------------------------------------------------------
+ bool TableControl_Impl::markAllRowsAsDeselected()
+ {
+ if ( m_aSelectedRows.empty() )
+ return false;
+
+ m_aSelectedRows.clear();
+ return true;
+ }
+
+ //--------------------------------------------------------------------
+ bool TableControl_Impl::markAllRowsAsSelected()
+ {
+ DBG_CHECK_ME();
+
+ SelectionMode const eSelMode = getSelEngine()->GetSelectionMode();
+ ENSURE_OR_RETURN_FALSE( eSelMode == MULTIPLE_SELECTION, "TableControl_Impl::markAllRowsAsSelected: unsupported selection mode!" );
+
+ if ( m_aSelectedRows.size() == size_t( m_pModel->getRowCount() ) )
{
- if(actWidth < maxWidth)
+ #if OSL_DEBUG_LEVEL > 0
+ for ( TableSize row = 0; row < m_pModel->getRowCount(); ++row )
{
- newActWidth = m_rAntiImpl.PixelToLogic( Size( actWidth, 0 ), MAP_APPFONT ).Width();
- pColumn->setPreferredWidth(newActWidth);
+ OSL_ENSURE( isRowSelected( row ), "TableControl_Impl::markAllRowsAsSelected: inconsistency in the selected rows!" );
}
- else
- pColumn->setPreferredWidth(pColumn->getMaxWidth());
+ #endif
+ // already all rows marked as selected
+ return false;
}
- m_nCurColumn = m_nResizingColumn;
- impl_ni_updateColumnWidths();
- impl_ni_updateScrollbars();
- m_pDataWindow->Invalidate(INVALIDATE_UPDATE);
- m_pDataWindow->SetPointer(Pointer());
- m_bResizing = false;
- m_bResizingGrid = true;
- }
- m_pDataWindow->ReleaseMouse();
- return m_bResizing;
- }
- //-------------------------------------------------------------------------------
- void TableControl_Impl::impl_ni_getAccVisibleColWidths()
- {
- TableSize nVisCols = impl_getVisibleColumns(true);
- int widthsPixel = 0;
- m_aVisibleColumnWidthsPixel.resize(0);
- m_aVisibleColumnWidthsPixel.reserve(nVisCols);
- int headerRowWidth = 0;
- if(m_pModel->hasRowHeaders())
- {
- headerRowWidth = m_rAntiImpl.LogicToPixel( Size(m_pModel->getRowHeaderWidth(), 0 ), MAP_APPFONT ).Width();
- widthsPixel+=headerRowWidth;
- }
- int col = m_nLeftColumn;
- while(nVisCols)
- {
- m_aVisibleColumnWidthsPixel.push_back(widthsPixel+=m_aColumnWidthsPixel[col]);
- col++;
- nVisCols--;
- }
- }
- //-------------------------------------------------------------------------------
- void TableControl_Impl::impl_updateLeftColumn()
- {
- int nVisCols = m_aVisibleColumnWidthsPixel.size();
- int headerRowWidth = 0;
- //sum of currently visible columns
- int widthsPixel = 0;
- //header pixel should be added, because header doesn't vanish when scrolling
- if(m_pModel->hasRowHeaders())
- {
- headerRowWidth = m_rAntiImpl.LogicToPixel( Size(m_pModel->getRowHeaderWidth(), 0 ), MAP_APPFONT ).Width();
- widthsPixel+=headerRowWidth;
- }
- int col = m_nLeftColumn;
- //add column width of the neighbour of the left column
- widthsPixel+=m_aColumnWidthsPixel[col-1];
- //compute the sum of the new column widths
- while(nVisCols)
- {
- PColumnModel pColumn = m_pModel->getColumnModel(col);
- int colWidth = pColumn->getWidth();
- int colPrefWidth = pColumn->getPreferredWidth();
- if(colPrefWidth!=0)
- colWidth = colPrefWidth;
- widthsPixel += m_rAntiImpl.LogicToPixel( Size( colWidth, 0 ), MAP_APPFONT ).Width();
- col++;
- nVisCols--;
- }
- //when the sum of all visible columns and the next to the left column is smaller than
- //window width, then update m_nLeftColumn
- if(widthsPixel<m_pDataWindow->GetOutputSizePixel().Width())
- m_nLeftColumn--;
+
+ m_aSelectedRows.clear();
+ for ( RowPos i=0; i < m_pModel->getRowCount(); ++i )
+ m_aSelectedRows.push_back(i);
+
+ return true;
}
+
//--------------------------------------------------------------------
- rtl::OUString TableControl_Impl::convertToString(const ::com::sun::star::uno::Any& value)
- {
- sal_Int32 nInt = 0;
- sal_Bool bBool = false;
- double fDouble = 0;
- ::rtl::OUString sNewString;
- ::rtl::OUString sConvertString;
- if(value >>= sConvertString)
- sNewString = sConvertString;
- else if(value >>= nInt)
- sNewString = sConvertString.valueOf(nInt);
- else if(value >>= bBool)
- sNewString = sConvertString.valueOf(bBool);
- else if(value >>= fDouble)
- sNewString = sConvertString.valueOf(fDouble);
- return sNewString;
- }
Rectangle TableControl_Impl::calcHeaderRect(bool bColHeader)
{
- Rectangle aRectTable, aRectTableWithHeaders;
- impl_getAllVisibleDataCellArea(aRectTable);
- impl_getAllVisibleCellsArea(aRectTableWithHeaders);
- Size aSizeTable(aRectTable.GetSize());
- Size aSizeTableWithHeaders(aRectTableWithHeaders.GetSize());
- if(bColHeader)
- return Rectangle(aRectTableWithHeaders.TopLeft(),Size(aSizeTableWithHeaders.Width()-aSizeTable.Width(), aSizeTableWithHeaders.Height()));
+ Rectangle const aRectTableWithHeaders( impl_getAllVisibleCellsArea() );
+ Size const aSizeTableWithHeaders( aRectTableWithHeaders.GetSize() );
+ if ( bColHeader )
+ return Rectangle( aRectTableWithHeaders.TopLeft(), Size( aSizeTableWithHeaders.Width(), m_nColHeaderHeightPixel ) );
else
- return Rectangle(aRectTableWithHeaders.TopLeft(),Size(aSizeTableWithHeaders.Width(), aSizeTableWithHeaders.Height()-aSizeTable.Height()));
+ return Rectangle( aRectTableWithHeaders.TopLeft(), Size( m_nRowHeaderWidthPixel, aSizeTableWithHeaders.Height() ) );
}
+
+ //--------------------------------------------------------------------
Rectangle TableControl_Impl::calcTableRect()
{
- Rectangle aRect;
- impl_getAllVisibleDataCellArea(aRect);
- return aRect;
+ return impl_getAllVisibleDataCellArea();
+ }
+
+ //--------------------------------------------------------------------
+ IMPL_LINK( TableControl_Impl, OnUpdateScrollbars, void*, /**/ )
+ {
+ DBG_CHECK_ME();
+ impl_ni_updateScrollbars();
+ return 1L;
}
//--------------------------------------------------------------------
@@ -2221,157 +2543,200 @@ namespace svt { namespace table
return 0L;
}
- //---------------------------------------------------------------------------------------
+
+ //------------------------------------------------------------------------------------------------------------------
+ Reference< XAccessible > TableControl_Impl::getAccessible( Window& i_parentWindow )
+ {
+ DBG_TESTSOLARMUTEX();
+ if ( m_pAccessibleTable == NULL )
+ {
+ Reference< XAccessible > const xAccParent = i_parentWindow.GetAccessible();
+ if ( xAccParent.is() )
+ {
+ m_pAccessibleTable = m_aFactoryAccess.getFactory().createAccessibleTableControl(
+ xAccParent, m_rAntiImpl
+ );
+ }
+ }
+
+ Reference< XAccessible > xAccessible;
+ if ( m_pAccessibleTable )
+ xAccessible = m_pAccessibleTable->getMyself();
+ return xAccessible;
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void TableControl_Impl::disposeAccessible()
+ {
+ if ( m_pAccessibleTable )
+ m_pAccessibleTable->dispose();
+ m_pAccessibleTable = NULL;
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ bool TableControl_Impl::impl_isAccessibleAlive() const
+ {
+ DBG_CHECK_ME();
+ return ( NULL != m_pAccessibleTable ) && m_pAccessibleTable->isAlive();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void TableControl_Impl::impl_commitAccessibleEvent( sal_Int16 const i_eventID, Any const & i_newValue, Any const & i_oldValue )
+ {
+ DBG_CHECK_ME();
+ if ( impl_isAccessibleAlive() )
+ m_pAccessibleTable->commitEvent( i_eventID, i_newValue, i_oldValue );
+ }
+
+ //==================================================================================================================
+ //= TableFunctionSet
+ //==================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
TableFunctionSet::TableFunctionSet(TableControl_Impl* _pTableControl)
:m_pTableControl( _pTableControl)
- ,m_nCurrentRow (-2)
+ ,m_nCurrentRow( ROW_INVALID )
{
}
- //-------------------------------------------------------------------------------
+ //------------------------------------------------------------------------------------------------------------------
TableFunctionSet::~TableFunctionSet()
{
}
- //-------------------------------------------------------------------------------
+ //------------------------------------------------------------------------------------------------------------------
void TableFunctionSet::BeginDrag()
{
}
- //-------------------------------------------------------------------------------
+ //------------------------------------------------------------------------------------------------------------------
void TableFunctionSet::CreateAnchor()
{
- m_pTableControl->m_nAnchor = m_pTableControl->m_nCurRow;
+ m_pTableControl->setAnchor( m_pTableControl->getCurRow() );
}
- //-------------------------------------------------------------------------------
+
+ //------------------------------------------------------------------------------------------------------------------
void TableFunctionSet::DestroyAnchor()
{
- m_pTableControl->m_nAnchor = -1;
+ m_pTableControl->setAnchor( ROW_INVALID );
}
- //-------------------------------------------------------------------------------
+
+ //------------------------------------------------------------------------------------------------------------------
sal_Bool TableFunctionSet::SetCursorAtPoint(const Point& rPoint, sal_Bool bDontSelectAtCursor)
{
sal_Bool bHandled = sal_False;
- Rectangle rCells;
- //curRow is the row where the mouse click happened, m_nCurRow is the last selected row, before the mouse click
- RowPos curRow = m_pTableControl->getCurrentRow(rPoint);
- if(curRow == -2)
+ // newRow is the row which includes the point, getCurRow() is the last selected row, before the mouse click
+ RowPos newRow = m_pTableControl->getRowAtPoint( rPoint );
+ if ( newRow == ROW_COL_HEADERS )
+ newRow = m_pTableControl->getTopRow();
+
+ ColPos newCol = m_pTableControl->getColAtPoint( rPoint );
+ if ( newCol == COL_ROW_HEADERS )
+ newCol = m_pTableControl->getLeftColumn();
+
+ if ( ( newRow == ROW_INVALID ) || ( newCol == COL_INVALID ) )
return sal_False;
- if( bDontSelectAtCursor )
+
+ if ( bDontSelectAtCursor )
{
- if(m_pTableControl->m_nRowSelected.size()>1)
- m_pTableControl->m_pSelEngine->AddAlways(sal_True);
+ if ( m_pTableControl->getSelectedRowCount() > 1 )
+ m_pTableControl->getSelEngine()->AddAlways(sal_True);
bHandled = sal_True;
}
- else if(m_pTableControl->m_nAnchor == m_pTableControl->m_nCurRow)
+ else if ( m_pTableControl->getAnchor() == m_pTableControl->getCurRow() )
{
//selecting region,
- int diff = m_pTableControl->m_nCurRow - curRow;
+ int diff = m_pTableControl->getCurRow() - newRow;
//selected region lies above the last selection
if( diff >= 0)
{
//put selected rows in vector
- while(m_pTableControl->m_nAnchor>=curRow)
+ while ( m_pTableControl->getAnchor() >= newRow )
{
- bool isAlreadySelected = m_pTableControl->isRowSelected(m_pTableControl->m_nRowSelected, m_pTableControl->m_nAnchor);
- //if row isn't selected, put it in vector, otherwise don't put it there, because it will be twice there
- if(!isAlreadySelected)
- m_pTableControl->m_nRowSelected.push_back(m_pTableControl->m_nAnchor);
- m_pTableControl->m_nAnchor--;
+ m_pTableControl->markRowAsSelected( m_pTableControl->getAnchor() );
+ m_pTableControl->setAnchor( m_pTableControl->getAnchor() - 1 );
diff--;
}
- m_pTableControl->m_nAnchor++;
+ m_pTableControl->setAnchor( m_pTableControl->getAnchor() + 1 );
}
//selected region lies beneath the last selected row
else
{
- while(m_pTableControl->m_nAnchor<=curRow)
+ while ( m_pTableControl->getAnchor() <= newRow )
{
- bool isAlreadySelected = m_pTableControl->isRowSelected(m_pTableControl->m_nRowSelected, m_pTableControl->m_nAnchor);
- if(!isAlreadySelected)
- m_pTableControl->m_nRowSelected.push_back(m_pTableControl->m_nAnchor);
- m_pTableControl->m_nAnchor++;
+ m_pTableControl->markRowAsSelected( m_pTableControl->getAnchor() );
+ m_pTableControl->setAnchor( m_pTableControl->getAnchor() + 1 );
diff++;
}
- m_pTableControl->m_nAnchor--;
+ m_pTableControl->setAnchor( m_pTableControl->getAnchor() - 1 );
}
- m_pTableControl->invalidateSelectedRegion(m_pTableControl->m_nCurRow, curRow, rCells);
+ Rectangle aCellRect;
+ m_pTableControl->invalidateSelectedRegion( m_pTableControl->getCurRow(), newRow, aCellRect );
bHandled = sal_True;
}
//no region selected
else
{
- if(m_pTableControl->m_nRowSelected.empty())
- m_pTableControl->m_nRowSelected.push_back(curRow);
+ if ( !m_pTableControl->hasRowSelection() )
+ m_pTableControl->markRowAsSelected( newRow );
else
{
- if(m_pTableControl->m_pSelEngine->GetSelectionMode()==SINGLE_SELECTION)
+ if ( m_pTableControl->getSelEngine()->GetSelectionMode() == SINGLE_SELECTION )
{
DeselectAll();
- m_pTableControl->m_nRowSelected.push_back(curRow);
+ m_pTableControl->markRowAsSelected( newRow );
}
else
{
- bool isAlreadySelected = m_pTableControl->isRowSelected(m_pTableControl->m_nRowSelected, curRow);
- if(!isAlreadySelected)
- m_pTableControl->m_nRowSelected.push_back(curRow);
+ m_pTableControl->markRowAsSelected( newRow );
}
}
- if(m_pTableControl->m_nRowSelected.size()>1 && m_pTableControl->m_pSelEngine->GetSelectionMode()!=SINGLE_SELECTION)
- m_pTableControl->m_pSelEngine->AddAlways(sal_True);
- m_pTableControl->invalidateSelectedRegion(curRow, curRow, rCells);
+ if ( m_pTableControl->getSelectedRowCount() > 1 && m_pTableControl->getSelEngine()->GetSelectionMode() != SINGLE_SELECTION )
+ m_pTableControl->getSelEngine()->AddAlways(sal_True);
+
+ Rectangle aCellRect;
+ m_pTableControl->invalidateSelectedRegion( newRow, newRow, aCellRect );
bHandled = sal_True;
}
- m_pTableControl->m_nCurRow = curRow;
- m_pTableControl->ensureVisible(m_pTableControl->m_nCurColumn,m_pTableControl->m_nCurRow,false);
+ m_pTableControl->goTo( newCol, newRow );
return bHandled;
}
- //-------------------------------------------------------------------------------
+ //------------------------------------------------------------------------------------------------------------------
sal_Bool TableFunctionSet::IsSelectionAtPoint( const Point& rPoint )
{
- m_pTableControl->m_pSelEngine->AddAlways(sal_False);
- if(m_pTableControl->m_nRowSelected.empty())
+ m_pTableControl->getSelEngine()->AddAlways(sal_False);
+ if ( !m_pTableControl->hasRowSelection() )
return sal_False;
else
{
- RowPos curRow = m_pTableControl->getCurrentRow(rPoint);
- m_pTableControl->m_nAnchor = -1;
- bool selected = m_pTableControl->isRowSelected(m_pTableControl->m_nRowSelected, curRow);
+ RowPos curRow = m_pTableControl->getRowAtPoint( rPoint );
+ m_pTableControl->setAnchor( ROW_INVALID );
+ bool selected = m_pTableControl->isRowSelected( curRow );
m_nCurrentRow = curRow;
return selected;
}
}
- //-------------------------------------------------------------------------------
+ //------------------------------------------------------------------------------------------------------------------
void TableFunctionSet::DeselectAtPoint( const Point& rPoint )
{
(void)rPoint;
- long pos = 0;
- long i = 0;
- Rectangle rCells;
- for(std::vector<RowPos>::iterator it=m_pTableControl->m_nRowSelected.begin();
- it!=m_pTableControl->m_nRowSelected.end();++it)
- {
- if(*it == m_nCurrentRow)
- {
- pos = i;
- m_pTableControl->invalidateSelectedRegion(*it, *it, rCells);
- }
- ++i;
- }
- m_pTableControl->m_nRowSelected.erase(m_pTableControl->m_nRowSelected.begin()+pos);
+ Rectangle aCellRange;
+ m_pTableControl->invalidateSelectedRegion( m_nCurrentRow, m_nCurrentRow, aCellRange );
+ m_pTableControl->markRowAsDeselected( m_nCurrentRow );
}
- //-------------------------------------------------------------------------------
+
+ //------------------------------------------------------------------------------------------------------------------
void TableFunctionSet::DeselectAll()
{
- if(!m_pTableControl->m_nRowSelected.empty())
+ if ( m_pTableControl->hasRowSelection() )
{
- Rectangle rCells;
- for(std::vector<RowPos>::iterator it=m_pTableControl->m_nRowSelected.begin();
- it!=m_pTableControl->m_nRowSelected.end();++it)
+ Rectangle aCellRange;
+ for ( size_t i=0; i<m_pTableControl->getSelectedRowCount(); ++i )
{
- m_pTableControl->invalidateSelectedRegion(*it, *it, rCells);
+ RowPos const rowIndex = m_pTableControl->getSelectedRowIndex(i);
+ m_pTableControl->invalidateSelectedRegion( rowIndex, rowIndex, aCellRange );
}
- m_pTableControl->m_nRowSelected.clear();
+
+ m_pTableControl->markAllRowsAsDeselected();
}
}
-//........................................................................
+//......................................................................................................................
} } // namespace svt::table
-//........................................................................
+//......................................................................................................................
diff --git a/svtools/source/table/tablecontrol_impl.hxx b/svtools/source/table/tablecontrol_impl.hxx
index c0604be15cdb..bc1ac55fbe51 100644..100755
--- a/svtools/source/table/tablecontrol_impl.hxx
+++ b/svtools/source/table/tablecontrol_impl.hxx
@@ -27,18 +27,16 @@
#ifndef SVTOOLS_TABLECONTROL_IMPL_HXX
#define SVTOOLS_TABLECONTROL_IMPL_HXX
-#ifndef SVTOOLS_INC_TABLE_TABLEMODEL_HXX
-#include <svtools/table/tablemodel.hxx>
-#endif
+#include "svtools/table/tablemodel.hxx"
+#include "svtools/table/tablecontrolinterface.hxx"
-#ifndef SVTOOLS_INC_TABLE_ABSTRACTTABLECONTROL_HXX
-#include <svtools/table/abstracttablecontrol.hxx>
-#endif
+#include "svtaccessiblefactory.hxx"
-#include <svtools/table/tablemodel.hxx>
-#include <vector>
#include <vcl/seleng.hxx>
+#include <vector>
+
+#include <boost/scoped_ptr.hpp>
class ScrollBar;
class ScrollBarBox;
@@ -48,7 +46,42 @@ namespace svt { namespace table
{
//........................................................................
- typedef ::std::vector< long > ArrayOfLong;
+ struct MutableColumnMetrics : protected ColumnMetrics
+ {
+ MutableColumnMetrics()
+ :ColumnMetrics()
+ {
+ }
+
+ MutableColumnMetrics( long const i_startPixel, long const i_endPixel )
+ :ColumnMetrics( i_startPixel, i_endPixel )
+ {
+ }
+
+ long getStart() const { return nStartPixel; }
+ long getEnd() const { return nEndPixel; }
+
+ void setEnd( long const i_end ) { nEndPixel = i_end; }
+ void move( long const i_offset ) { nStartPixel += i_offset; nEndPixel += i_offset; }
+
+ long getWidth() const { return nEndPixel - nStartPixel; }
+
+ ColumnMetrics const & operator()() { return *this; }
+ };
+
+ struct ColumnInfoPositionLess
+ {
+ bool operator()( MutableColumnMetrics const& i_colInfo, long const i_position )
+ {
+ return i_colInfo.getEnd() < i_position;
+ }
+ bool operator()( long const i_position, MutableColumnMetrics const& i_colInfo )
+ {
+ return i_position < i_colInfo.getStart();
+ }
+ };
+
+ typedef ::std::vector< MutableColumnMetrics > ColumnPositions;
class TableControl;
class TableDataWindow;
@@ -57,13 +90,14 @@ namespace svt { namespace table
//====================================================================
//= TableControl_Impl
//====================================================================
- class TableControl_Impl : public IAbstractTableControl
+ class TableControl_Impl :public ITableControl
+ ,public ITableModelListener
{
friend class TableGeometry;
friend class TableRowGeometry;
friend class TableColumnGeometry;
friend class SuspendInvariants;
- friend class TableFunctionSet;
+
private:
/// the control whose impl-instance we implemnt
TableControl& m_rAntiImpl;
@@ -71,14 +105,9 @@ namespace svt { namespace table
PTableModel m_pModel;
/// the input handler to use, usually the input handler as provided by ->m_pModel
PTableInputHandler m_pInputHandler;
- /// the widths of the single columns, measured in pixel
- ArrayOfLong m_aColumnWidthsPixel;
- /** the accumulated widths of the single columns, i.e. their exclusive right borders,
- <strong<not</strong> counting the space for a possible row header column
- */
- ArrayOfLong m_aAccColumnWidthsPixel;
+ /// info about the widths of our columns
+ ColumnPositions m_aColumnWidths;
- ArrayOfLong m_aVisibleColumnWidthsPixel;
/// the height of a single row in the table, measured in pixels
long m_nRowHeightPixel;
/// the height of the column header row in the table, measured in pixels
@@ -88,9 +117,13 @@ namespace svt { namespace table
/// the number of columns in the table control. Cached model value.
TableSize m_nColumnCount;
+
/// the number of rows in the table control. Cached model value.
TableSize m_nRowCount;
+ /// denotes whether or not the columns fitted into the available width, last time we checked
+ long m_bColumnsFit;
+
ColPos m_nCurColumn;
RowPos m_nCurRow;
ColPos m_nLeftColumn;
@@ -103,24 +136,27 @@ namespace svt { namespace table
The window's upper left corner is at position (0,0), relative to the
table control, which is the direct parent of the data window.
*/
- TableDataWindow* m_pDataWindow;
+ ::boost::scoped_ptr< TableDataWindow >
+ m_pDataWindow;
/// the vertical scrollbar, if any
ScrollBar* m_pVScroll;
/// the horizontal scrollbar, if any
- ScrollBar* m_pHScroll;
+ ScrollBar* m_pHScroll;
ScrollBarBox* m_pScrollCorner;
- //selection engine - for determining selection range, e.g. single, multiple
- SelectionEngine* m_pSelEngine;
- //vector which contains the selected rows
- std::vector<RowPos> m_nRowSelected;
- //part of selection engine
- TableFunctionSet* m_pTableFunctionSet;
- //part of selection engine
- RowPos m_nAnchor;
- bool m_bResizing;
- ColPos m_nResizingColumn;
- bool m_bResizingGrid;
- rtl::OUString m_aTooltipText;
+ //selection engine - for determining selection range, e.g. single, multiple
+ SelectionEngine* m_pSelEngine;
+ //vector which contains the selected rows
+ std::vector<RowPos> m_aSelectedRows;
+ //part of selection engine
+ TableFunctionSet* m_pTableFunctionSet;
+ //part of selection engine
+ RowPos m_nAnchor;
+ bool m_bUpdatingColWidths;
+
+ Link m_aSelectHdl;
+
+ AccessibleFactoryAccess m_aFactoryAccess;
+ IAccessibleTableControl* m_pAccessibleTable;
#if DBG_UTIL
#define INV_SCROLL_POSITION 1
@@ -133,21 +169,18 @@ namespace svt { namespace table
#endif
public:
-
-
- PTableModel getModel() const;
void setModel( PTableModel _pModel );
inline const PTableInputHandler& getInputHandler() const { return m_pInputHandler; }
- inline ColPos getCurColumn() const { return m_nCurColumn; }
- 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 RowPos getCurRow() const { return m_nCurRow; }
+ inline void setCurRow( RowPos i_curRow ){ m_nCurRow = i_curRow; }
- inline long getColHeaderHightPixel() const { return m_nColHeaderHeightPixel; }
+ RowPos getAnchor() const { return m_nAnchor; }
+ void setAnchor( RowPos const i_anchor ) { m_nAnchor = i_anchor; }
+
+ inline RowPos getTopRow() const { return m_nTopRow; }
+ inline ColPos getLeftColumn() const { return m_nLeftColumn; }
inline const TableControl& getAntiImpl() const { return m_rAntiImpl; }
inline TableControl& getAntiImpl() { return m_rAntiImpl; }
@@ -185,45 +218,115 @@ namespace svt { namespace table
<TRUE/> if it's okay that the given cooordinate is only partially visible
*/
void ensureVisible( ColPos _nColumn, RowPos _nRow, bool _bAcceptPartialVisibility );
- /** returns the row, which contains the input point*/
- virtual RowPos getCurrentRow (const Point& rPoint);
-
- void setCursorAtCurrentCell(const Point& rPoint);
- /** checks whether the vector with the selected rows contains the current row*/
- sal_Bool isRowSelected(const ::std::vector<RowPos>& selectedRows, RowPos current);
-
- bool isRowSelected(RowPos current);
- /** returns the position of the current row in the selection vector */
- int getRowSelectedNumber(const ::std::vector<RowPos>& selectedRows, RowPos current);
- /** _rCellRect contains the region, which should be invalidate after some action e.g. selecting row*/
- void invalidateSelectedRegion(RowPos _nPrevRow, RowPos _nCurRow, Rectangle& _rCellRect );
- /** 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();
- /** updates the vector, which contains the selected rows after removing the row nRowPos*/
- void removeSelectedRow(RowPos _nRowPos);
- void invalidateRows();
- void clearSelection();
- // IAbstractTableControl
- virtual void hideCursor();
- virtual void showCursor();
- virtual bool dispatchAction( TableControlAction _eAction );
- virtual SelectionEngine* getSelEngine();
- virtual bool isTooltipActive();
- virtual rtl::OUString& setTooltip(const Point& rPoint );
- virtual void resizeColumn(const Point& rPoint);
- virtual bool startResizeColumn(const Point& rPoint);
- virtual bool endResizeColumn(const Point& rPoint);
-
- TableDataWindow* getDataWindow();
- ScrollBar* getHorzScrollbar();
- ScrollBar* getVertScrollbar();
-
- ::rtl::OUString convertToString(const ::com::sun::star::uno::Any& _value);
- Rectangle calcHeaderRect(bool bColHeader);
- Rectangle calcTableRect();
+
+ /** retrieves the content of the given cell, converted to a string
+ */
+ ::rtl::OUString getCellContentAsString( RowPos const i_row, ColPos const i_col );
+
+ /** returns the position of the current row in the selection vector */
+ int getRowSelectedNumber(const ::std::vector<RowPos>& selectedRows, RowPos current);
+
+ /** _rCellRect contains the region, which should be invalidate after some action e.g. selecting row*/
+ void invalidateSelectedRegion(RowPos _nPrevRow, RowPos _nCurRow, Rectangle& _rCellRect );
+
+ /** invalidates the part of the data window which is covered by the given row
+ @param i_firstRow
+ the index of the first row to include in the invalidation
+ @param i_lastRow
+ the index of the last row to include in the invalidation, or ROW_INVALID if the invalidation
+ should happen down to the bottom of the data window.
+ */
+ void invalidateRowRange( RowPos const i_firstRow, RowPos const i_lastRow );
+
+ void checkCursorPosition();
+
+ bool hasRowSelection() const { return !m_aSelectedRows.empty(); }
+ size_t getSelectedRowCount() const { return m_aSelectedRows.size(); }
+ RowPos getSelectedRowIndex( size_t const i_selectionIndex ) const;
+
+ /** removes the given row index from m_aSelectedRows
+
+ @return
+ <TRUE/> if and only if the row was previously marked as selected
+ */
+ bool markRowAsDeselected( RowPos const i_rowIndex );
+
+ /** marks the given row as selectged, by putting it into m_aSelectedRows
+ @return
+ <TRUE/> if and only if the row was previously <em>not</em> marked as selected
+ */
+ bool markRowAsSelected( RowPos const i_rowIndex );
+
+ /** marks all rows as deselected
+ @return
+ <TRUE/> if and only if the selection actually changed by this operation
+ */
+ bool markAllRowsAsDeselected();
+
+ /** marks all rows as selected
+ @return
+ <FALSE/> if and only if all rows were selected already.
+ */
+ bool markAllRowsAsSelected();
+
+ void setSelectHandler( Link const & i_selectHandler ) { m_aSelectHdl = i_selectHandler; }
+ Link const& getSelectHandler() const { return m_aSelectHdl; }
+
+ // ITableControl
+ virtual void hideCursor();
+ virtual void showCursor();
+ virtual bool dispatchAction( TableControlAction _eAction );
+ virtual SelectionEngine* getSelEngine();
+ virtual PTableModel getModel() const;
+ virtual ColPos getCurrentColumn() const;
+ virtual RowPos getCurrentRow() const;
+ virtual bool activateCell( ColPos const i_col, RowPos const i_row );
+ virtual ::Size getTableSizePixel() const;
+ virtual void setPointer( Pointer const & i_pointer );
+ virtual void captureMouse();
+ virtual void releaseMouse();
+ virtual void invalidate( TableArea const i_what );
+ virtual long pixelWidthToAppFont( long const i_pixels ) const;
+ virtual void hideTracking();
+ virtual void showTracking( Rectangle const & i_location, sal_uInt16 const i_flags );
+ virtual RowPos getRowAtPoint( const Point& rPoint ) const;
+ virtual ColPos getColAtPoint( const Point& rPoint ) const;
+ virtual TableCell hitTest( const Point& rPoint ) const;
+ virtual ColumnMetrics getColumnMetrics( ColPos const i_column ) const;
+ virtual bool isRowSelected( RowPos i_row ) const;
+
+
+ TableDataWindow& getDataWindow() { return *m_pDataWindow; }
+ const TableDataWindow& getDataWindow() const { return *m_pDataWindow; }
+ ScrollBar* getHorzScrollbar();
+ ScrollBar* getVertScrollbar();
+
+ Rectangle calcHeaderRect(bool bColHeader);
+ Rectangle calcTableRect();
+
+ // A11Y
+ ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
+ getAccessible( Window& i_parentWindow );
+ void disposeAccessible();
+
+ // ITableModelListener
+ virtual void rowsInserted( RowPos first, RowPos last );
+ virtual void rowsRemoved( RowPos first, RowPos last );
+ virtual void columnInserted( ColPos const i_colIndex );
+ virtual void columnRemoved( ColPos const i_colIndex );
+ virtual void allColumnsRemoved();
+ virtual void cellsUpdated( ColPos const i_firstCol, ColPos i_lastCol, RowPos const i_firstRow, RowPos const i_lastRow );
+ virtual void columnChanged( ColPos const i_column, ColumnAttributeGroup const i_attributeGroup );
+ virtual void tableMetricsChanged();
+
private:
+ bool impl_isAccessibleAlive() const;
+ void impl_commitAccessibleEvent(
+ sal_Int16 const i_eventID,
+ ::com::sun::star::uno::Any const & i_newValue,
+ ::com::sun::star::uno::Any const & i_oldValue
+ );
+
/** toggles the cursor visibility
The method is not bound to the classes public invariants, as it's used in
@@ -251,7 +354,7 @@ namespace svt { namespace table
specifies whether a possible only partially visible last row is
counted, too.
*/
- TableSize impl_getVisibleColumns( bool _bAcceptPartialRow ) const;
+ TableSize impl_getVisibleColumns( bool _bAcceptPartialCol ) const;
/** determines the rectangle occupied by the given cell
*/
@@ -264,15 +367,20 @@ namespace svt { namespace table
*/
void impl_ni_updateCachedModelValues();
- /** updates ->m_aColumnWidthsPixel with the current pixel widths of all model columns
+ /** updates the cached table metrics (row height etc.)
+ */
+ void impl_ni_updateCachedTableMetrics();
- The method takes into account the current zoom factor and map mode of the table
- control, plus any possible COLWIDTH_FIT_TO_VIEW widths in the model columns.
+ /** updates ->m_aColumnWidthsPixel with the current pixel widths of all model columns
The method is not bound to the classes public invariants, as it's used in
situations where the they must not necessarily be fullfilled.
+
+ @param i_assumeInflexibleColumnsUpToIncluding
+ the index of a column up to which all columns should be considered as inflexible, or
+ <code>COL_INVALID</code>.
*/
- void impl_ni_updateColumnWidths();
+ void impl_ni_updateColumnWidths( ColPos const i_assumeInflexibleColumnsUpToIncluding = COL_INVALID );
/** updates the scrollbars of the control
@@ -296,6 +404,10 @@ namespace svt { namespace table
*/
TableSize impl_ni_ScrollRows( TableSize _nRowDelta );
+ /** equivalent to impl_ni_ScrollRows, but checks the instances invariants beforehand (in a non-product build only)
+ */
+ TableSize impl_scrollRows( TableSize const i_rowDelta );
+
/** scrolls the view by the given number of columns
The method is not bound to the classes public invariants, as it's used in
@@ -306,8 +418,13 @@ namespace svt { namespace table
from the given numbers to scroll in case the begin or the end of the
column range were reached.
*/
- TableSize impl_ni_ScrollColumns( TableSize _nRowDelta );
- /** retrieves the area occupied by the totality of (at least partially) visible cells
+ TableSize impl_ni_ScrollColumns( TableSize _nColumnDelta );
+
+ /** equivalent to impl_ni_ScrollColumns, but checks the instances invariants beforehand (in a non-product build only)
+ */
+ TableSize impl_scrollColumns( TableSize const i_columnDelta );
+
+ /** 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
account the the fact that there might be less columns than would normally
@@ -316,27 +433,37 @@ namespace svt { namespace table
As a result of respecting the partial visibility of rows and columns,
the returned area might be larger than the data window's output size.
*/
- void impl_getAllVisibleCellsArea( Rectangle& _rCellArea ) const;
+ Rectangle impl_getAllVisibleCellsArea() const;
/** retrieves the area occupied by all (at least partially) visible data cells.
Effectively, the returned area is the same as returned by ->impl_getAllVisibleCellsArea,
minus the row and column header areas.
*/
- void impl_getAllVisibleDataCellArea( Rectangle& _rCellArea ) const;
+ Rectangle impl_getAllVisibleDataCellArea() const;
+
+ /** retrieves the column which covers the given ordinate
+ */
+ ColPos impl_getColumnForOrdinate( long const i_ordinate ) const;
- void impl_ni_getAccVisibleColWidths();
- void impl_updateLeftColumn();
+ /** retrieves the row which covers the given abscissa
+ */
+ RowPos impl_getRowForAbscissa( long const i_abscissa ) const;
+
+ /// invalidates the window area occupied by the given column
+ void impl_invalidateColumn( ColPos const i_column );
DECL_LINK( OnScroll, ScrollBar* );
+ DECL_LINK( OnUpdateScrollbars, void* );
};
+
//see seleng.hxx, seleng.cxx, FunctionSet overridables, part of selection engine
class TableFunctionSet : public FunctionSet
{
- friend class TableDataWindow;
private:
- TableControl_Impl* m_pTableControl;
- RowPos m_nCurrentRow;
+ TableControl_Impl* m_pTableControl;
+ RowPos m_nCurrentRow;
+
public:
TableFunctionSet(TableControl_Impl* _pTableControl);
virtual ~TableFunctionSet();
diff --git a/svtools/source/table/tabledatawindow.cxx b/svtools/source/table/tabledatawindow.cxx
index bbd7f6829369..11605e36c8b2 100644
--- a/svtools/source/table/tabledatawindow.cxx
+++ b/svtools/source/table/tabledatawindow.cxx
@@ -28,23 +28,31 @@
#include "precompiled_svtools.hxx"
#include "svtools/table/tablecontrol.hxx"
-#include "svtools/table/tabledatawindow.hxx"
+
+#include "tabledatawindow.hxx"
#include "tablecontrol_impl.hxx"
+#include "tablegeometry.hxx"
+#include "cellvalueconversion.hxx"
+
#include <vcl/help.hxx>
-//........................................................................
+//......................................................................................................................
namespace svt { namespace table
{
- class TableControl_Impl;
-//........................................................................
+//......................................................................................................................
- //====================================================================
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Any;
+ /** === end UNO using === **/
+
+ //==================================================================================================================
//= TableDataWindow
- //====================================================================
- //--------------------------------------------------------------------
+ //==================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
TableDataWindow::TableDataWindow( TableControl_Impl& _rTableControl )
:Window( &_rTableControl.getAntiImpl() )
- ,m_rTableControl ( _rTableControl )
+ ,m_rTableControl( _rTableControl )
+ ,m_nTipWindowHandle( 0 )
{
// by default, use the background as determined by the style settings
const Color aWindowColor( GetSettings().GetStyleSettings().GetFieldColor() );
@@ -52,105 +60,164 @@ namespace svt { namespace table
SetFillColor( aWindowColor );
}
- //--------------------------------------------------------------------
+ //------------------------------------------------------------------------------------------------------------------
+ TableDataWindow::~TableDataWindow()
+ {
+ impl_hideTipWindow();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
void TableDataWindow::Paint( const Rectangle& rUpdateRect )
{
m_rTableControl.doPaintContent( rUpdateRect );
}
- //--------------------------------------------------------------------
+ //------------------------------------------------------------------------------------------------------------------
void TableDataWindow::SetBackground( const Wallpaper& rColor )
{
Window::SetBackground( rColor );
}
- //--------------------------------------------------------------------
+ //------------------------------------------------------------------------------------------------------------------
void TableDataWindow::SetControlBackground( const Color& rColor )
{
Window::SetControlBackground( rColor );
}
- //--------------------------------------------------------------------
+ //------------------------------------------------------------------------------------------------------------------
void TableDataWindow::SetBackground()
{
Window::SetBackground();
}
- //--------------------------------------------------------------------
+ //------------------------------------------------------------------------------------------------------------------
void TableDataWindow::SetControlBackground()
{
Window::SetControlBackground();
}
- //--------------------------------------------------------------------
- void TableDataWindow::MouseMove( const MouseEvent& rMEvt )
+
+ //------------------------------------------------------------------------------------------------------------------
+ void TableDataWindow::RequestHelp( const HelpEvent& rHEvt )
{
- Point aPoint = rMEvt.GetPosPixel();
- if ( !m_rTableControl.getInputHandler()->MouseMove( m_rTableControl, rMEvt ) )
+ sal_uInt16 const nHelpMode = rHEvt.GetMode();
+ if ( ( IsMouseCaptured() )
+ || ( ( nHelpMode & HELPMODE_QUICK ) == 0 )
+ )
+ {
+ Window::RequestHelp( rHEvt );
+ return;
+ }
+
+ ::rtl::OUString sHelpText;
+ sal_uInt16 nHelpStyle = 0;
+
+ Point const aMousePos( ScreenToOutputPixel( rHEvt.GetMousePosPixel() ) );
+ RowPos const hitRow = m_rTableControl.getRowAtPoint( aMousePos );
+ ColPos const hitCol = m_rTableControl.getColAtPoint( aMousePos );
+
+ PTableModel const pTableModel( m_rTableControl.getModel() );
+ if ( ( hitCol >= 0 ) && ( hitCol < pTableModel->getColumnCount() ) )
{
- if(m_rTableControl.getCurrentRow(aPoint)>=0 && m_rTableControl.isTooltipActive() )
+ if ( hitRow == ROW_COL_HEADERS )
{
- SetPointer(POINTER_ARROW);
- rtl::OUString& rHelpText = m_rTableControl.setTooltip(aPoint);
- Help::EnableBalloonHelp();
- Window::SetHelpText( rHelpText.getStr());
+ sHelpText = pTableModel->getColumnModel( hitCol )->getHelpText();
}
- else if(m_rTableControl.getCurrentRow(aPoint) == -1)
+ else if ( ( hitRow >= 0 ) && ( hitRow < pTableModel->getRowCount() ) )
{
- if(Help::IsBalloonHelpEnabled())
- Help::DisableBalloonHelp();
- m_rTableControl.resizeColumn(aPoint);
+ Any aCellToolTip;
+ pTableModel->getCellToolTip( hitCol, hitRow, aCellToolTip );
+ if ( !aCellToolTip.hasValue() )
+ {
+ // use the cell content
+ pTableModel->getCellContent( hitCol, hitRow, aCellToolTip );
+
+ // use the cell content as tool tip only if it doesn't fit into the cell.
+ bool const activeCell = ( hitRow == m_rTableControl.getCurrentRow() ) && ( hitCol == m_rTableControl.getCurrentColumn() );
+ bool const selectedCell = m_rTableControl.isRowSelected( hitRow );
+
+ Rectangle const aWindowRect( Point( 0, 0 ), GetOutputSizePixel() );
+ TableCellGeometry const aCell( m_rTableControl, aWindowRect, hitCol, hitRow );
+ Rectangle const aCellRect( aCell.getRect() );
+
+ PTableRenderer const pRenderer = pTableModel->getRenderer();
+ if ( pRenderer->FitsIntoCell( aCellToolTip, hitCol, hitRow, activeCell, selectedCell, *this, aCellRect ) )
+ aCellToolTip.clear();
+ }
+
+ sHelpText = CellValueConversion::convertToString( aCellToolTip );
+
+ if ( sHelpText.indexOf( '\n' ) >= 0 )
+ nHelpStyle = QUICKHELP_TIP_STYLE_BALLOON;
}
+ }
+
+ if ( sHelpText.getLength() )
+ {
+ Rectangle const aControlScreenRect(
+ OutputToScreenPixel( Point( 0, 0 ) ),
+ GetOutputSizePixel()
+ );
+
+ if ( m_nTipWindowHandle )
+ Help::UpdateTip( m_nTipWindowHandle, this, aControlScreenRect, sHelpText );
else
- {
- if(Help::IsBalloonHelpEnabled())
- Help::DisableBalloonHelp();
- Window::MouseMove( rMEvt );
- }
+ m_nTipWindowHandle = Help::ShowTip( this, aControlScreenRect, sHelpText, nHelpStyle );
}
+ else
+ impl_hideTipWindow();
}
- //--------------------------------------------------------------------
+
+ //------------------------------------------------------------------------------------------------------------------
+ void TableDataWindow::impl_hideTipWindow()
+ {
+ if ( m_nTipWindowHandle != 0 )
+ {
+ Help::HideTip( m_nTipWindowHandle );
+ m_nTipWindowHandle = 0;
+ }
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void TableDataWindow::MouseMove( const MouseEvent& rMEvt )
+ {
+ if ( rMEvt.IsLeaveWindow() )
+ impl_hideTipWindow();
+
+ if ( !m_rTableControl.getInputHandler()->MouseMove( m_rTableControl, rMEvt ) )
+ {
+ Window::MouseMove( rMEvt );
+ }
+ }
+ //------------------------------------------------------------------------------------------------------------------
void TableDataWindow::MouseButtonDown( const MouseEvent& rMEvt )
{
- Point aPoint = rMEvt.GetPosPixel();
- RowPos nCurRow = m_rTableControl.getCurrentRow(aPoint);
- std::vector<RowPos> selectedRows(m_rTableControl.getSelectedRows());
+ impl_hideTipWindow();
+
+ Point const aPoint = rMEvt.GetPosPixel();
+ RowPos const hitRow = m_rTableControl.getRowAtPoint( aPoint );
+ bool const wasRowSelected = m_rTableControl.isRowSelected( hitRow );
+
if ( !m_rTableControl.getInputHandler()->MouseButtonDown( m_rTableControl, rMEvt ) )
- Window::MouseButtonDown( rMEvt );
- else
{
- if(nCurRow >= 0 && m_rTableControl.getSelEngine()->GetSelectionMode() != NO_SELECTION)
- {
- bool found = std::find(selectedRows.begin(),selectedRows.end(), nCurRow) != selectedRows.end();
+ Window::MouseButtonDown( rMEvt );
+ return;
+ }
- if( !found )
- {
- m_aSelectHdl.Call( NULL );
- }
- }
+ bool const isRowSelected = m_rTableControl.isRowSelected( hitRow );
+ if ( isRowSelected != wasRowSelected )
+ {
+ m_aSelectHdl.Call( NULL );
}
m_aMouseButtonDownHdl.Call((MouseEvent*) &rMEvt);
- m_rTableControl.getAntiImpl().LoseFocus();
}
- //--------------------------------------------------------------------
+
+ //------------------------------------------------------------------------------------------------------------------
void TableDataWindow::MouseButtonUp( const MouseEvent& rMEvt )
{
if ( !m_rTableControl.getInputHandler()->MouseButtonUp( m_rTableControl, rMEvt ) )
Window::MouseButtonUp( rMEvt );
+
m_aMouseButtonUpHdl.Call((MouseEvent*) &rMEvt);
- m_rTableControl.getAntiImpl().GetFocus();
+ m_rTableControl.getAntiImpl().GrabFocus();
}
- //--------------------------------------------------------------------
- void TableDataWindow::SetPointer( const Pointer& rPointer )
- {
- Window::SetPointer(rPointer);
- }
- //--------------------------------------------------------------------
- void TableDataWindow::CaptureMouse()
- {
- Window::CaptureMouse();
- }
- //--------------------------------------------------------------------
- void TableDataWindow::ReleaseMouse( )
- {
- Window::ReleaseMouse();
- }
- // -----------------------------------------------------------------------
+
+ //------------------------------------------------------------------------------------------------------------------
long TableDataWindow::Notify(NotifyEvent& rNEvt )
{
long nDone = 0;
@@ -168,6 +235,6 @@ namespace svt { namespace table
}
return nDone ? nDone : Window::Notify( rNEvt );
}
-//........................................................................
+//......................................................................................................................
} } // namespace svt::table
-//........................................................................
+//......................................................................................................................
diff --git a/svtools/inc/svtools/table/tabledatawindow.hxx b/svtools/source/table/tabledatawindow.hxx
index 829feecd5836..6f78ac49c44d 100644
--- a/svtools/inc/svtools/table/tabledatawindow.hxx
+++ b/svtools/source/table/tabledatawindow.hxx
@@ -55,8 +55,12 @@ namespace svt { namespace table
Link m_aMouseButtonDownHdl;
Link m_aMouseButtonUpHdl;
Link m_aSelectHdl;
+ sal_uLong m_nTipWindowHandle;
+
public:
TableDataWindow( TableControl_Impl& _rTableControl );
+ ~TableDataWindow();
+
inline void SetMouseButtonDownHdl( const Link& rLink ) { m_aMouseButtonDownHdl = rLink; }
inline const Link& GetMouseButtonDownHdl() const { return m_aMouseButtonDownHdl; }
inline void SetMouseButtonUpHdl( const Link& rLink ) { m_aMouseButtonUpHdl = rLink; }
@@ -69,15 +73,16 @@ namespace svt { namespace table
virtual void MouseMove( const MouseEvent& rMEvt);
virtual void MouseButtonDown( const MouseEvent& rMEvt);
virtual void MouseButtonUp( const MouseEvent& rMEvt);
- virtual void SetPointer( const Pointer& rPointer );
- virtual void CaptureMouse();
- virtual void ReleaseMouse();
virtual long Notify(NotifyEvent& rNEvt);
virtual void SetControlBackground(const Color& rColor);
virtual void SetControlBackground();
+ virtual void RequestHelp( const HelpEvent& rHEvt );
void SetBackground(const Wallpaper& rColor);
void SetBackground();
+
+ private:
+ void impl_hideTipWindow();
};
//........................................................................
} } // namespace svt::table
diff --git a/svtools/source/table/tablegeometry.cxx b/svtools/source/table/tablegeometry.cxx
index d60de9e6438f..661079775daa 100644
--- a/svtools/source/table/tablegeometry.cxx
+++ b/svtools/source/table/tablegeometry.cxx
@@ -27,105 +27,139 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_svtools.hxx"
-
#include "tablegeometry.hxx"
#include "tablecontrol_impl.hxx"
#include <tools/debug.hxx>
-//........................................................................
+//......................................................................................................................
namespace svt { namespace table
{
-//........................................................................
+//......................................................................................................................
- //====================================================================
+ //==================================================================================================================
//= TableRowGeometry
- //====================================================================
- //--------------------------------------------------------------------
- TableRowGeometry::TableRowGeometry( const TableControl_Impl& _rControl, const Rectangle& _rBoundaries,
- RowPos _nRow )
+ //==================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
+ TableRowGeometry::TableRowGeometry( TableControl_Impl const & _rControl, Rectangle const & _rBoundaries,
+ RowPos const _nRow, bool const i_allowVirtualRows )
:TableGeometry( _rControl, _rBoundaries )
,m_nRowPos( _nRow )
+ ,m_bAllowVirtualRows( i_allowVirtualRows )
{
if ( m_nRowPos == ROW_COL_HEADERS )
{
- //DBG_ASSERT( m_rControl.m_pModel->hasColumnHeaders(),
- // "TableRowGeometry::TableRowGeometry: why asking for the geoemtry of the non-existent column header row?" );
m_aRect.Top() = 0;
m_aRect.Bottom() = m_rControl.m_nColHeaderHeightPixel - 1;
}
else
{
- if ( ( m_nRowPos >= m_rControl.m_nTopRow ) && ( m_nRowPos < m_rControl.m_pModel->getRowCount() ) )
- {
- m_aRect.Top() = m_rControl.m_nColHeaderHeightPixel + ( m_nRowPos - m_rControl.m_nTopRow ) * m_rControl.m_nRowHeightPixel;
- m_aRect.Bottom() = m_aRect.Top() + m_rControl.m_nRowHeightPixel - 1;
- }
- else
- m_aRect.SetEmpty();
+ impl_initRect();
}
}
- //--------------------------------------------------------------------
- bool TableRowGeometry::moveDown()
+ //------------------------------------------------------------------------------------------------------------------
+ void TableRowGeometry::impl_initRect()
{
- if ( ++m_nRowPos < m_rControl.m_pModel->getRowCount() )
- m_aRect.Move( 0, m_rControl.m_nRowHeightPixel );
+ if ( ( m_nRowPos >= m_rControl.m_nTopRow ) && impl_isValidRow( m_nRowPos ) )
+ {
+ m_aRect.Top() = m_rControl.m_nColHeaderHeightPixel + ( m_nRowPos - m_rControl.m_nTopRow ) * m_rControl.m_nRowHeightPixel;
+ m_aRect.Bottom() = m_aRect.Top() + m_rControl.m_nRowHeightPixel - 1;
+ }
else
m_aRect.SetEmpty();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ bool TableRowGeometry::impl_isValidRow( RowPos const i_row ) const
+ {
+ return m_bAllowVirtualRows || ( i_row < m_rControl.m_pModel->getRowCount() );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ bool TableRowGeometry::moveDown()
+ {
+ if ( m_nRowPos == ROW_COL_HEADERS )
+ {
+ m_nRowPos = m_rControl.m_nTopRow;
+ impl_initRect();
+ }
+ else
+ {
+ if ( impl_isValidRow( ++m_nRowPos ) )
+ m_aRect.Move( 0, m_rControl.m_nRowHeightPixel );
+ else
+ m_aRect.SetEmpty();
+ }
return isValid();
}
- //====================================================================
+ //==================================================================================================================
//= TableColumnGeometry
- //====================================================================
- //--------------------------------------------------------------------
- TableColumnGeometry::TableColumnGeometry( const TableControl_Impl& _rControl, const Rectangle& _rBoundaries,
- ColPos _nCol )
+ //==================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
+ TableColumnGeometry::TableColumnGeometry( TableControl_Impl const & _rControl, Rectangle const & _rBoundaries,
+ ColPos const _nCol, bool const i_allowVirtualColumns )
:TableGeometry( _rControl, _rBoundaries )
,m_nColPos( _nCol )
+ ,m_bAllowVirtualColumns( i_allowVirtualColumns )
{
if ( m_nColPos == COL_ROW_HEADERS )
{
-/* DBG_ASSERT( m_rControl.m_pModel->hasRowHeaders(),
- "TableColumnGeometry::TableColumnGeometry: why asking for the geoemtry of the non-existent row header column?" )*/;
m_aRect.Left() = 0;
m_aRect.Right() = m_rControl.m_nRowHeaderWidthPixel - 1;
}
else
{
- ColPos nLeftColumn = m_rControl.m_nLeftColumn;
- if ( ( m_nColPos >= nLeftColumn ) && ( m_nColPos < (ColPos)m_rControl.m_aColumnWidthsPixel.size() ) )
- {
- m_aRect.Left() = m_rControl.m_nRowHeaderWidthPixel;
- // TODO: take into account any possibly frozen columns
+ impl_initRect();
+ }
+ }
- for ( ColPos col = nLeftColumn; col < m_nColPos; ++col )
- m_aRect.Left() += m_rControl.m_aColumnWidthsPixel[ col ];
- m_aRect.Right() = m_aRect.Left() + m_rControl.m_aColumnWidthsPixel[ m_nColPos ] - 1;
- }
- else
- m_aRect.SetEmpty();
+ //------------------------------------------------------------------------------------------------------------------
+ void TableColumnGeometry::impl_initRect()
+ {
+ ColPos nLeftColumn = m_rControl.m_nLeftColumn;
+ if ( ( m_nColPos >= nLeftColumn ) && impl_isValidColumn( m_nColPos ) )
+ {
+ m_aRect.Left() = m_rControl.m_nRowHeaderWidthPixel;
+ // TODO: take into account any possibly frozen columns
+
+ for ( ColPos col = nLeftColumn; col < m_nColPos; ++col )
+ m_aRect.Left() += m_rControl.m_aColumnWidths[ col ].getWidth();
+ m_aRect.Right() = m_aRect.Left() + m_rControl.m_aColumnWidths[ m_nColPos ].getWidth() - 1;
}
+ else
+ m_aRect.SetEmpty();
}
- //--------------------------------------------------------------------
- bool TableColumnGeometry::moveRight()
+ //------------------------------------------------------------------------------------------------------------------
+ bool TableColumnGeometry::impl_isValidColumn( ColPos const i_column ) const
{
- DBG_ASSERT( m_nColPos != COL_ROW_HEADERS, "TableColumnGeometry::moveRight: cannot move the row header column!" );
- // what would be COL_ROW_HEADERS + 1?
+ return m_bAllowVirtualColumns || ( i_column < ColPos( m_rControl.m_aColumnWidths.size() ) );
+ }
- if ( ++m_nColPos < (ColPos)m_rControl.m_aColumnWidthsPixel.size() )
+ //------------------------------------------------------------------------------------------------------------------
+ bool TableColumnGeometry::moveRight()
+ {
+ if ( m_nColPos == COL_ROW_HEADERS )
{
- m_aRect.Left() = m_aRect.Right() + 1;
- m_aRect.Right() += m_rControl.m_aColumnWidthsPixel[ m_nColPos ];
+ m_nColPos = m_rControl.m_nLeftColumn;
+ impl_initRect();
}
else
- m_aRect.SetEmpty();
+ {
+ if ( impl_isValidColumn( ++m_nColPos ) )
+ {
+ m_aRect.Left() = m_aRect.Right() + 1;
+ m_aRect.Right() += m_rControl.m_aColumnWidths[ m_nColPos ].getWidth();
+ }
+ else
+ m_aRect.SetEmpty();
+ }
return isValid();
}
-//........................................................................
+//......................................................................................................................
} } // namespace svt::table
-//........................................................................
+//......................................................................................................................
diff --git a/svtools/source/table/tablegeometry.hxx b/svtools/source/table/tablegeometry.hxx
index 3ddde0c98c64..fedc7cb2f24f 100644
--- a/svtools/source/table/tablegeometry.hxx
+++ b/svtools/source/table/tablegeometry.hxx
@@ -27,13 +27,9 @@
#ifndef SVTOOLS_TABLEGEOMETRY_HXX
#define SVTOOLS_TABLEGEOMETRY_HXX
-#ifndef SVTOOLS_INC_TABLE_TABLETYPES_HXX
-#include <svtools/table/tabletypes.hxx>
-#endif
+#include "svtools/table/tabletypes.hxx"
-#ifndef _SV_GEN_HXX
#include <tools/gen.hxx>
-#endif
//........................................................................
namespace svt { namespace table
@@ -79,18 +75,25 @@ namespace svt { namespace table
{
protected:
RowPos m_nRowPos;
+ bool m_bAllowVirtualRows;
public:
TableRowGeometry(
- const TableControl_Impl& _rControl,
- const Rectangle& _rBoundaries,
- RowPos _nRow
+ TableControl_Impl const & _rControl,
+ Rectangle const & _rBoundaries,
+ RowPos const _nRow,
+ bool const i_allowVirtualRows = false
+ // allow rows >= getRowCount()?
);
// status
RowPos getRow() const { return m_nRowPos; }
// operations
bool moveDown();
+
+ private:
+ void impl_initRect();
+ bool impl_isValidRow( RowPos const i_row ) const;
};
//====================================================================
@@ -100,18 +103,24 @@ namespace svt { namespace table
{
protected:
ColPos m_nColPos;
+ bool m_bAllowVirtualColumns;
public:
TableColumnGeometry(
- const TableControl_Impl& _rControl,
- const Rectangle& _rBoundaries,
- ColPos _nCol
+ TableControl_Impl const & _rControl,
+ Rectangle const & _rBoundaries,
+ ColPos const _nCol,
+ bool const i_allowVirtualColumns = false
);
// status
ColPos getCol() const { return m_nColPos; }
// operations
bool moveRight();
+
+ private:
+ void impl_initRect();
+ bool impl_isValidColumn( ColPos const i_column ) const;
};
//====================================================================
@@ -127,13 +136,14 @@ namespace svt { namespace table
public:
TableCellGeometry(
- const TableControl_Impl& _rControl,
- const Rectangle& _rBoundaries,
- ColPos _nCol,
- RowPos _nRow
+ TableControl_Impl const & _rControl,
+ Rectangle const & _rBoundaries,
+ ColPos const _nCol,
+ RowPos const _nRow,
+ bool const i_alllowVirtualCells = false
)
- :m_aRow( _rControl, _rBoundaries, _nRow )
- ,m_aCol( _rControl, _rBoundaries, _nCol )
+ :m_aRow( _rControl, _rBoundaries, _nRow, i_alllowVirtualCells )
+ ,m_aCol( _rControl, _rBoundaries, _nCol, i_alllowVirtualCells )
{
}
diff --git a/svtools/source/uno/svtxgridcontrol.cxx b/svtools/source/uno/svtxgridcontrol.cxx
index f5bc837f60b0..0e826ef6bff3 100755..100644
--- a/svtools/source/uno/svtxgridcontrol.cxx
+++ b/svtools/source/uno/svtxgridcontrol.cxx
@@ -28,115 +28,193 @@
#include "precompiled_svtools.hxx"
#include "svtxgridcontrol.hxx"
-#include "accessibletableimp.hxx"
#include <com/sun/star/view/SelectionType.hpp>
+#include "svtools/table/tablecontrolinterface.hxx"
#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 <tools/diagnose_ex.h>
#include <toolkit/helper/property.hxx>
#include <toolkit/helper/vclunohelper.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>
#include <com/sun/star/awt/XControl.hpp>
#include <com/sun/star/awt/grid/GridInvalidDataException.hpp>
#include <com/sun/star/awt/grid/GridInvalidModelException.hpp>
#include <com/sun/star/util/Color.hpp>
#include <com/sun/star/awt/FontDescriptor.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::style;
+using namespace ::com::sun::star::container;
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),
- m_bUpdate(false),
- m_nSelectedRowCount(0),
- m_aSelectionListeners( *this )
+ :m_pTableModel( new UnoControlTableModel() )
+ ,m_bHasColumnHeaders( false )
+ ,m_bHasRowHeaders( false )
+ ,m_bTableModelInitCompleted( false )
+ ,m_nSelectedRowCount( 0 )
+ ,m_aSelectionListeners( *this )
{
}
-//--------------------------------------------------------------------
+// ---------------------------------------------------------------------------------------------------------------------
SVTXGridControl::~SVTXGridControl()
{
}
-::com::sun::star::uno::Any SVTXGridControl::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException)
+// ---------------------------------------------------------------------------------------------------------------------
+void SVTXGridControl::SetWindow( Window* pWindow )
{
- ::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::awt::grid::XGridColumnListener*, this ),
- SAL_STATIC_CAST( ::com::sun::star::lang::XTypeProvider*, this ) );
- return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType ));
+ SVTXGridControl_Base::SetWindow( pWindow );
+ impl_checkTableModelInit();
}
-// ::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
+// ---------------------------------------------------------------------------------------------------------------------
+sal_Int32 SAL_CALL SVTXGridControl::getRowAtPoint(::sal_Int32 x, ::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException)
+{
+ ::vos::OGuard aGuard( GetMutex() );
+
+ TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() );
+ ENSURE_OR_RETURN( pTable != NULL, "SVTXGridControl::getRowAtPoint: no control (anymore)!", -1 );
+
+ TableCell const tableCell = pTable->getTableControlInterface().hitTest( Point( x, y ) );
+ return ( tableCell.nRow >= 0 ) ? tableCell.nRow : -1;
+}
-sal_Int32 SAL_CALL SVTXGridControl::getItemIndexAtPoint(::sal_Int32 x, ::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException)
+// ---------------------------------------------------------------------------------------------------------------------
+sal_Int32 SAL_CALL SVTXGridControl::getColumnAtPoint(::sal_Int32 x, ::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException)
{
- TableControl* pTable = (TableControl*)GetWindow();
- return pTable->GetCurrentRow( Point(x,y) );
+ ::vos::OGuard aGuard( GetMutex() );
+
+ TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() );
+ ENSURE_OR_RETURN( pTable != NULL, "SVTXGridControl::getColumnAtPoint: no control (anymore)!", -1 );
+
+ TableCell const tableCell = pTable->getTableControlInterface().hitTest( Point( x, y ) );
+ return ( tableCell.nColumn >= 0 ) ? tableCell.nColumn : -1;
}
-void SAL_CALL SVTXGridControl::setToolTip(const ::com::sun::star::uno::Sequence< ::rtl::OUString >& text, const com::sun::star::uno::Sequence< sal_Int32 >& columns) throw (::com::sun::star::uno::RuntimeException)
+// ---------------------------------------------------------------------------------------------------------------------
+sal_Int32 SAL_CALL SVTXGridControl::getCurrentColumn( ) throw (RuntimeException)
{
- TableControl* pTable = (TableControl*)GetWindow();
- pTable->setTooltip(text, columns);
+ ::vos::OGuard aGuard( GetMutex() );
+
+ TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() );
+ ENSURE_OR_RETURN( pTable != NULL, "SVTXGridControl::getCurrentColumn: no control (anymore)!", -1 );
+
+ sal_Int32 const nColumn = pTable->GetCurrentColumn();
+ return ( nColumn >= 0 ) ? nColumn : -1;
}
+// ---------------------------------------------------------------------------------------------------------------------
+sal_Int32 SAL_CALL SVTXGridControl::getCurrentRow( ) throw (RuntimeException)
+{
+ ::vos::OGuard aGuard( GetMutex() );
+
+ TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() );
+ ENSURE_OR_RETURN( pTable != NULL, "SVTXGridControl::getCurrentRow: no control (anymore)!", -1 );
+
+ sal_Int32 const nRow = pTable->GetCurrentRow();
+ return ( nRow >= 0 ) ? nRow : -1;
+}
+
+// ---------------------------------------------------------------------------------------------------------------------
void SAL_CALL SVTXGridControl::addSelectionListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridSelectionListener > & listener) throw (::com::sun::star::uno::RuntimeException)
{
m_aSelectionListeners.addInterface(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)
{
m_aSelectionListeners.removeInterface(listener);
}
+// ---------------------------------------------------------------------------------------------------------------------
void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const Any& aValue) throw(RuntimeException)
{
::vos::OGuard aGuard( GetMutex() );
- TableControl* pTable = (TableControl*)GetWindow();
+ TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() );
+ ENSURE_OR_RETURN_VOID( pTable != NULL, "SVTXGridControl::setProperty: no control (anymore)!" );
+
switch( GetPropertyId( PropertyName ) )
{
+ case BASEPROPERTY_ROW_HEADER_WIDTH:
+ {
+ sal_Int32 rowHeaderWidth( -1 );
+ aValue >>= rowHeaderWidth;
+ ENSURE_OR_BREAK( rowHeaderWidth > 0, "SVTXGridControl::setProperty: illegal row header width!" );
+ m_pTableModel->setRowHeaderWidth( rowHeaderWidth );
+ // TODO: the model should broadcast this change itself, and the table should invalidate itself as needed
+ pTable->Invalidate();
+ }
+ break;
+
+ case BASEPROPERTY_COLUMN_HEADER_HEIGHT:
+ {
+ sal_Int32 columnHeaderHeight = 0;
+ if ( !aValue.hasValue() )
+ {
+ columnHeaderHeight = pTable->PixelToLogic( Size( 0, pTable->GetTextHeight() + 3 ), MAP_APPFONT ).Height();
+ }
+ else
+ {
+ aValue >>= columnHeaderHeight;
+ }
+ ENSURE_OR_BREAK( columnHeaderHeight > 0, "SVTXGridControl::setProperty: illegal column header height!" );
+ m_pTableModel->setColumnHeaderHeight( columnHeaderHeight );
+ // TODO: the model should broadcast this change itself, and the table should invalidate itself as needed
+ pTable->Invalidate();
+ }
+ break;
+
+ case BASEPROPERTY_USE_GRID_LINES:
+ {
+ GridTableRenderer* pGridRenderer = dynamic_cast< GridTableRenderer* >(
+ m_pTableModel->getRenderer().get() );
+ ENSURE_OR_BREAK( pGridRenderer != NULL, "SVTXGridControl::setProperty(UseGridLines): invalid renderer!" );
+ sal_Bool bUseGridLines = sal_False;
+ OSL_VERIFY( aValue >>= bUseGridLines );
+ pGridRenderer->useGridLines( bUseGridLines );
+ pTable->Invalidate();
+ }
+ break;
+
+ case BASEPROPERTY_ROW_HEIGHT:
+ {
+ sal_Int32 rowHeight = 0;
+ if ( !aValue.hasValue() )
+ {
+ rowHeight = pTable->PixelToLogic( Size( 0, pTable->GetTextHeight() + 3 ), MAP_APPFONT ).Height();
+ }
+ else
+ {
+ aValue >>= rowHeight;
+ }
+ m_pTableModel->setRowHeight( rowHeight );
+ ENSURE_OR_BREAK( rowHeight > 0, "SVTXGridControl::setProperty: illegal row height!" );
+ // TODO: the model should broadcast this change itself, and the table should invalidate itself as needed
+ pTable->Invalidate();
+ }
+ break;
+
case BASEPROPERTY_BACKGROUNDCOLOR:
{
// let the base class handle this for the TableControl
VCLXWindow::setProperty( PropertyName, aValue );
// and forward to the grid control's data window
if ( pTable->IsBackground() )
- pTable->getDataWindow()->SetBackground( pTable->GetBackground() );
+ pTable->getDataWindow().SetBackground( pTable->GetBackground() );
else
- pTable->getDataWindow()->SetBackground();
+ pTable->getDataWindow().SetBackground();
}
break;
@@ -151,7 +229,6 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An
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 )
@@ -163,19 +240,16 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An
{
sal_Bool bHScroll = true;
if( aValue >>= bHScroll )
- {
- m_bHScroll = bHScroll;
- m_pTableModel->setHorizontalScrollbarVisibility(bHScroll);
- }
+ m_pTableModel->setHorizontalScrollbarVisibility( bHScroll ? ScrollbarShowAlways : ScrollbarShowSmart );
break;
}
+
case BASEPROPERTY_VSCROLL:
{
sal_Bool bVScroll = true;
if( aValue >>= bVScroll )
{
- m_bVScroll = bVScroll;
- m_pTableModel->setVerticalScrollbarVisibility(bVScroll);
+ m_pTableModel->setVerticalScrollbarVisibility( bVScroll ? ScrollbarShowAlways : ScrollbarShowSmart );
}
break;
}
@@ -189,64 +263,42 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An
}
break;
}
- case BASEPROPERTY_GRID_HEADER_BACKGROUND:
- {
- sal_Int32 colorHeader = 0xFFFFFF;
- if( aValue >>= colorHeader )
- {
- m_pTableModel->setHeaderBackgroundColor(colorHeader);
- }
+
+ case BASEPROPERTY_GRID_ROW_BACKGROUND_COLORS:
+ m_pTableModel->setRowBackgroundColors( aValue );
+ pTable->Invalidate();
break;
- }
+
case BASEPROPERTY_GRID_LINE_COLOR:
- {
- sal_Int32 colorLine = 0xFFFFFF;
- if( aValue >>= colorLine )
- {
- m_pTableModel->setLineColor(colorLine);
- }
+ m_pTableModel->setLineColor( aValue );
+ pTable->Invalidate();
break;
- }
- case BASEPROPERTY_GRID_EVEN_ROW_BACKGROUND:
- {
- sal_Int32 colorEvenRow = 0xFFFFFF;
- if( aValue >>= colorEvenRow )
- {
- m_pTableModel->setEvenRowBackgroundColor(colorEvenRow);
- }
+
+ case BASEPROPERTY_GRID_HEADER_BACKGROUND:
+ m_pTableModel->setHeaderBackgroundColor( aValue );
+ pTable->Invalidate();
break;
- }
- case BASEPROPERTY_GRID_ROW_BACKGROUND:
- {
- sal_Int32 colorBackground = 0xFFFFFF;
- if( aValue >>= colorBackground )
- {
- m_pTableModel->setOddRowBackgroundColor(colorBackground);
- }
+
+ case BASEPROPERTY_GRID_HEADER_TEXT_COLOR:
+ m_pTableModel->setHeaderTextColor( aValue );
+ pTable->Invalidate();
break;
- }
+
case BASEPROPERTY_TEXTCOLOR:
- {
- sal_Int32 colorText = 0x000000;
- if( aValue >>= colorText )
- {
- m_pTableModel->setTextColor(colorText);
- }
+ m_pTableModel->setTextColor( aValue );
+ pTable->Invalidate();
break;
- }
+
+ case BASEPROPERTY_TEXTLINECOLOR:
+ m_pTableModel->setTextLineColor( aValue );
+ pTable->Invalidate();
+ break;
+
case BASEPROPERTY_VERTICALALIGN:
{
- com::sun::star::style::VerticalAlignment vAlign(com::sun::star::style::VerticalAlignment(0));
- if( aValue >>= vAlign )
- {
- switch( vAlign )
- {
- case com::sun::star::style::VerticalAlignment_TOP: m_pTableModel->setVerticalAlign(com::sun::star::style::VerticalAlignment(0)); break;
- case com::sun::star::style::VerticalAlignment_MIDDLE: m_pTableModel->setVerticalAlign(com::sun::star::style::VerticalAlignment(1)); break;
- case com::sun::star::style::VerticalAlignment_BOTTOM: m_pTableModel->setVerticalAlign(com::sun::star::style::VerticalAlignment(2)); break;
- default: m_pTableModel->setVerticalAlign(com::sun::star::style::VerticalAlignment(0)); break;
- }
- }
+ VerticalAlignment eAlign( VerticalAlignment_TOP );
+ if ( aValue >>= eAlign )
+ m_pTableModel->setVerticalAlign( eAlign );
break;
}
@@ -261,97 +313,31 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An
}
case BASEPROPERTY_GRID_DATAMODEL:
{
- {
- m_xDataModel = Reference< XGridDataModel >( aValue, UNO_QUERY );
- if(m_xDataModel != NULL)
- {
- Sequence<Sequence< Any > > cellData = m_xDataModel->getData();
- if(cellData.getLength()!= 0)
- {
- for (int i = 0; i < cellData.getLength(); i++)
- {
- std::vector< Any > newRow;
- Sequence< Any > rawRowData = cellData[i];
- //check whether the data row vector length matches with the column count
- if(m_xColumnModel->getColumnCount() == 0)
- {
- for ( ::svt::table::ColPos col = 0; col < rawRowData.getLength(); ++col )
- {
- UnoControlTableColumn* tableColumn = new UnoControlTableColumn();
- m_pTableModel->getColumnModel().push_back((PColumnModel)tableColumn);
- }
- m_xColumnModel->setDefaultColumns(rawRowData.getLength());
- }
- else
- if((unsigned int)rawRowData.getLength()!=(unsigned)m_pTableModel->getColumnCount())
- throw GridInvalidDataException(rtl::OUString::createFromAscii("The column count doesn't match with the length of row data"), m_xDataModel);
-
- for ( int k = 0; k < rawRowData.getLength(); k++)
- {
- newRow.push_back(rawRowData[k]);
- }
- m_pTableModel->getCellContent().push_back(newRow);
- }
-
- 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);
- }
- }
- else
- throw GridInvalidDataException(rtl::OUString::createFromAscii("The data model isn't set!"), m_xDataModel);
- sal_Int32 fontHeight = pTable->PixelToLogic( Size( 0, pTable->GetTextHeight()+3 ), MAP_APPFONT ).Height();
- if(m_xDataModel->getRowHeight() == 0)
- {
- m_pTableModel->setRowHeight(fontHeight);
- m_xDataModel->setRowHeight(fontHeight);
- }
- else
- m_pTableModel->setRowHeight(m_xDataModel->getRowHeight());
- m_pTableModel->setRowHeaderWidth(m_xDataModel->getRowHeaderWidth());
- }
- break;
+ Reference< XGridDataModel > const xDataModel( aValue, UNO_QUERY );
+ if ( !xDataModel.is() )
+ throw GridInvalidDataException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Invalid data model." ) ), *this );
+
+ m_pTableModel->setDataModel( xDataModel );
+ impl_checkTableModelInit();
}
+ break;
+
case BASEPROPERTY_GRID_COLUMNMODEL:
{
- m_xColumnModel = Reference< XGridColumnModel >( aValue, UNO_QUERY );
- if(m_xColumnModel != NULL)
- {
- if(m_xColumnModel->getColumnCount() != 0)
- {
- Sequence<Reference< XGridColumn > > columns = m_xColumnModel->getColumns();
- std::vector<Reference< XGridColumn > > aNewColumns(
- comphelper::sequenceToContainer<std::vector<Reference< XGridColumn > > >(columns));
- sal_Int32 fontHeight = pTable->PixelToLogic( Size( 0, pTable->GetTextHeight()+3 ), MAP_APPFONT ).Height();
- if(m_xColumnModel->getColumnHeaderHeight() == 0)
- {
- m_pTableModel->setColumnHeaderHeight(fontHeight);
- m_xColumnModel->setColumnHeaderHeight(fontHeight);
- }
- else
- m_pTableModel->setColumnHeaderHeight(m_xColumnModel->getColumnHeaderHeight());
- for ( ::svt::table::ColPos col = 0; col < m_xColumnModel->getColumnCount(); ++col )
- {
- UnoControlTableColumn* tableColumn = new UnoControlTableColumn(aNewColumns[col]);
- Reference< XGridColumn > xGridColumn = m_xColumnModel->getColumn(col);
- m_pTableModel->getColumnModel().push_back((PColumnModel)tableColumn);
- tableColumn->setHorizontalAlign(xGridColumn->getHorizontalAlign());
- tableColumn->setWidth(xGridColumn->getColumnWidth());
- if(xGridColumn->getPreferredWidth() != 0)
- tableColumn->setPreferredWidth(xGridColumn->getPreferredWidth());
- if(xGridColumn->getMaxWidth() != 0)
- tableColumn->setMaxWidth(xGridColumn->getMaxWidth());
- if(xGridColumn->getMinWidth() != 0)
- tableColumn->setMinWidth(xGridColumn->getMinWidth());
- tableColumn->setResizable(xGridColumn->getResizeable());
- }
- }
- }
- else
- throw GridInvalidModelException(rtl::OUString::createFromAscii("The column model isn't set!"), m_xColumnModel);
+ // obtain new col model
+ Reference< XGridColumnModel > const xColumnModel( aValue, UNO_QUERY );
+ if ( !xColumnModel.is() )
+ throw GridInvalidModelException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Invalid column model." ) ), *this );
+
+ // remove all old columns
+ m_pTableModel->removeAllColumns();
+
+ // announce to the TableModel
+ m_pTableModel->setColumnModel( xColumnModel );
+ impl_checkTableModelInit();
+ // add new columns
+ impl_updateColumnsFromModel_nothrow();
break;
}
default:
@@ -360,489 +346,354 @@ void SVTXGridControl::setProperty( const ::rtl::OUString& PropertyName, const An
}
}
+
+void SVTXGridControl::impl_checkTableModelInit()
+{
+ if ( !m_bTableModelInitCompleted && m_pTableModel->hasColumnModel() && m_pTableModel->hasDataModel() )
+ {
+ TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() );
+ if ( pTable )
+ {
+ pTable->SetModel( PTableModel( m_pTableModel ) );
+
+ m_bTableModelInitCompleted = true;
+
+ // ensure default columns exist, if they have not previously been added
+ Reference< XGridDataModel > const xDataModel( m_pTableModel->getDataModel(), UNO_QUERY_THROW );
+ Reference< XGridColumnModel > const xColumnModel( m_pTableModel->getColumnModel(), UNO_QUERY_THROW );
+
+ sal_Int32 const nDataColumnCount = xDataModel->getColumnCount();
+ if ( ( nDataColumnCount > 0 ) && ( xColumnModel->getColumnCount() == 0 ) )
+ xColumnModel->setDefaultColumns( nDataColumnCount );
+ // this will trigger notifications, which in turn will let us update our m_pTableModel
+ }
+ }
+}
+
+namespace
+{
+ void lcl_convertColor( ::boost::optional< ::Color > const & i_color, Any & o_colorValue )
+ {
+ if ( !i_color )
+ o_colorValue.clear();
+ else
+ o_colorValue <<= i_color->GetColor();
+ }
+}
+
Any SVTXGridControl::getProperty( const ::rtl::OUString& PropertyName ) throw(RuntimeException)
{
::vos::OGuard aGuard( GetMutex() );
+ TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() );
+ ENSURE_OR_RETURN( pTable != NULL, "SVTXGridControl::getProperty: no control (anymore)!", Any() );
+
+ Any aPropertyValue;
+
const sal_uInt16 nPropId = GetPropertyId( PropertyName );
- TableControl* pTable = (TableControl*)GetWindow();
- if(pTable)
+ switch(nPropId)
+ {
+ case BASEPROPERTY_GRID_SELECTIONMODE:
{
- switch(nPropId)
+ SelectionType eSelectionType;
+
+ SelectionMode eSelMode = pTable->getSelEngine()->GetSelectionMode();
+ switch( eSelMode )
{
- case BASEPROPERTY_GRID_SELECTIONMODE:
+ case SINGLE_SELECTION: eSelectionType = SelectionType_SINGLE; break;
+ case RANGE_SELECTION: eSelectionType = SelectionType_RANGE; break;
+ case MULTIPLE_SELECTION:eSelectionType = SelectionType_MULTI; break;
+ default: eSelectionType = SelectionType_NONE; break;
+ }
+ aPropertyValue <<= eSelectionType;
+ break;
+ }
+
+ case BASEPROPERTY_GRID_SHOWROWHEADER:
+ aPropertyValue <<= sal_Bool( m_pTableModel->hasRowHeaders() );
+ break;
+
+ case BASEPROPERTY_GRID_SHOWCOLUMNHEADER:
+ aPropertyValue <<= sal_Bool( m_pTableModel->hasColumnHeaders() );
+ break;
+
+ case BASEPROPERTY_GRID_DATAMODEL:
+ aPropertyValue <<= m_pTableModel->getDataModel();
+ break;
+
+ case BASEPROPERTY_GRID_COLUMNMODEL:
+ aPropertyValue <<= m_pTableModel->getColumnModel();
+ break;
+
+ case BASEPROPERTY_HSCROLL:
{
- SelectionType eSelectionType;
+ sal_Bool const bHasScrollbar = ( m_pTableModel->getHorizontalScrollbarVisibility() != ScrollbarShowNever );
+ aPropertyValue <<= bHasScrollbar;
+ break;
+ }
- 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_VSCROLL:
+ {
+ sal_Bool const bHasScrollbar = ( m_pTableModel->getVerticalScrollbarVisibility() != ScrollbarShowNever );
+ aPropertyValue <<= bHasScrollbar;
+ break;
}
- case BASEPROPERTY_GRID_SHOWROWHEADER:
+
+ case BASEPROPERTY_USE_GRID_LINES:
+ {
+ GridTableRenderer* pGridRenderer = dynamic_cast< GridTableRenderer* >(
+ m_pTableModel->getRenderer().get() );
+ ENSURE_OR_BREAK( pGridRenderer != NULL, "SVTXGridControl::getProperty(UseGridLines): invalid renderer!" );
+ aPropertyValue <<= pGridRenderer->useGridLines();
+ }
+ break;
+
+ case BASEPROPERTY_GRID_ROW_BACKGROUND_COLORS:
+ {
+ ::boost::optional< ::std::vector< ::Color > > aColors( m_pTableModel->getRowBackgroundColors() );
+ if ( !aColors )
+ aPropertyValue.clear();
+ else
+ {
+ Sequence< ::com::sun::star::util::Color > aAPIColors( aColors->size() );
+ for ( size_t i=0; i<aColors->size(); ++i )
{
- return Any ((sal_Bool) m_pTableModel->hasRowHeaders());
+ aAPIColors[i] = aColors->at(i).GetColor();
}
- 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);
+ aPropertyValue <<= aAPIColors;
}
}
- return VCLXWindow::getProperty( PropertyName );
+ break;
+
+ case BASEPROPERTY_GRID_LINE_COLOR:
+ lcl_convertColor( m_pTableModel->getLineColor(), aPropertyValue );
+ break;
+
+ case BASEPROPERTY_GRID_HEADER_BACKGROUND:
+ lcl_convertColor( m_pTableModel->getHeaderBackgroundColor(), aPropertyValue );
+ break;
+
+ case BASEPROPERTY_GRID_HEADER_TEXT_COLOR:
+ lcl_convertColor( m_pTableModel->getHeaderTextColor(), aPropertyValue );
+ break;
+
+ case BASEPROPERTY_TEXTCOLOR:
+ lcl_convertColor( m_pTableModel->getTextColor(), aPropertyValue );
+ break;
+
+ case BASEPROPERTY_TEXTLINECOLOR:
+ lcl_convertColor( m_pTableModel->getTextLineColor(), aPropertyValue );
+ break;
+
+ default:
+ aPropertyValue = VCLXWindow::getProperty( PropertyName );
+ break;
+ }
+
+ return aPropertyValue;
}
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,
- BASEPROPERTY_GRID_EVEN_ROW_BACKGROUND,
- BASEPROPERTY_GRID_HEADER_BACKGROUND,
- BASEPROPERTY_GRID_LINE_COLOR,
- BASEPROPERTY_GRID_ROW_BACKGROUND,
- 0);
+ BASEPROPERTY_GRID_SHOWROWHEADER,
+ BASEPROPERTY_GRID_SHOWCOLUMNHEADER,
+ BASEPROPERTY_GRID_DATAMODEL,
+ BASEPROPERTY_GRID_COLUMNMODEL,
+ BASEPROPERTY_GRID_SELECTIONMODE,
+ BASEPROPERTY_GRID_HEADER_BACKGROUND,
+ BASEPROPERTY_GRID_HEADER_TEXT_COLOR,
+ BASEPROPERTY_GRID_LINE_COLOR,
+ BASEPROPERTY_GRID_ROW_BACKGROUND_COLORS,
+ 0
+ );
VCLXWindow::ImplGetPropertyIds( rIds, true );
}
-void SAL_CALL SVTXGridControl::setVisible( sal_Bool bVisible ) throw(::com::sun::star::uno::RuntimeException)
+
+//----------------------------------------------------------------------------------------------------------------------
+void SAL_CALL SVTXGridControl::rowsInserted( const GridDataEvent& i_event ) throw (RuntimeException)
{
::vos::OGuard aGuard( GetMutex() );
- TableControl* pTable = (TableControl*)GetWindow();
- if ( pTable )
- {
- pTable->SetModel(PTableModel(m_pTableModel));
- pTable->Show( bVisible );
- }
+ m_pTableModel->notifyRowsInserted( i_event );
}
-void SAL_CALL SVTXGridControl::setFocus() throw(::com::sun::star::uno::RuntimeException)
+
+//----------------------------------------------------------------------------------------------------------------------
+void SAL_CALL//----------------------------------------------------------------------------------------------------------------------
+ SVTXGridControl::rowsRemoved( const GridDataEvent& i_event ) throw (RuntimeException)
{
::vos::OGuard aGuard( GetMutex() );
- if ( GetWindow())
- GetWindow()->GrabFocus();
+ m_pTableModel->notifyRowsRemoved( i_event );
}
-void SAL_CALL SVTXGridControl::rowAdded(const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException)
+
+//----------------------------------------------------------------------------------------------------------------------
+void SAL_CALL SVTXGridControl::dataChanged( const GridDataEvent& i_event ) throw (RuntimeException)
{
::vos::OGuard aGuard( GetMutex() );
- std::vector< Any > newRow;
- Sequence< Any > rawRowData = Event.rowData;
- int colCount = m_xColumnModel->getColumnCount();
- if(colCount == 0)
- {
- Reference<XGridColumnListener> listener(*this,UNO_QUERY_THROW);
- m_xColumnModel->setDefaultColumns(rawRowData.getLength());
- for ( ::svt::table::ColPos col = 0; col < rawRowData.getLength(); ++col )
- {
- UnoControlTableColumn* tableColumn = new UnoControlTableColumn();
- m_pTableModel->getColumnModel().push_back((PColumnModel)tableColumn);
- m_xColumnModel->getColumn(col)->addColumnListener(listener);
- }
+ m_pTableModel->notifyDataChanged( i_event );
- }
- else if((unsigned int)rawRowData.getLength()!=(unsigned)colCount)
- throw GridInvalidDataException(rtl::OUString::createFromAscii("The column count doesn't match with the length of row data"), m_xDataModel);
-
- for ( int k = 0; k < rawRowData.getLength(); k++)
- newRow.push_back(rawRowData[k]);
- m_pTableModel->getCellContent().push_back(newRow);
- if(m_pTableModel->hasRowHeaders())
- m_pTableModel->getRowHeaderName().push_back(Event.headerName);
- m_pTableModel->setRowCount(m_pTableModel->getCellContent().size());
- TableControl* pTable = (TableControl*)GetWindow();
- pTable->InvalidateDataWindow(m_pTableModel->getCellContent().size()-1, 0, false);
- 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());
- }
- }
+ // if the data model is sortable, a dataChanged event is also fired in case the sort order changed.
+ // So, just in case, invalidate the column header area, too.
+ TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() );
+ ENSURE_OR_RETURN_VOID( pTable, "SVTXGridControl::dataChanged: no control (anymore)!" );
+ pTable->getTableControlInterface().invalidate( TableAreaColumnHeaders );
}
-void SAL_CALL SVTXGridControl::rowRemoved(const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException)
+//----------------------------------------------------------------------------------------------------------------------
+void SAL_CALL SVTXGridControl::rowHeadingChanged( const GridDataEvent& i_event ) throw (RuntimeException)
{
::vos::OGuard aGuard( GetMutex() );
+ OSL_UNUSED( i_event );
- TableControl* pTable = (TableControl*)GetWindow();
- if(Event.index == -1)
- {
- if(!isSelectionEmpty())
- deselectAllRows();
- if(m_pTableModel->hasRowHeaders())
- m_pTableModel->getRowHeaderName().clear();
- pTable->clearSelection();
- 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 if(Event.index >= 0 && Event.index < m_pTableModel->getRowCount())
- {
- if(isSelectedIndex(Event.index))
- {
- Sequence<sal_Int32> selected(1);
- selected[0]=Event.index;
- deselectRows(selected);
- }
- if(m_pTableModel->hasRowHeaders())
- m_pTableModel->getRowHeaderName().erase(m_pTableModel->getRowHeaderName().begin()+Event.index);
- std::vector<std::vector<Any> >::iterator rowPos =m_pTableModel->getCellContent().begin() + Event.index;
- m_pTableModel->getCellContent().erase( rowPos );
- }
- m_pTableModel->setRowCount(m_pTableModel->getCellContent().size());
- pTable->InvalidateDataWindow(Event.index, Event.index, true);
- if(pTable->isAccessibleAlive())
- {
- pTable->commitGridControlEvent(TABLE_MODEL_CHANGED,
- makeAny( AccessibleTableModelChange(DELETE, Event.index, Event.index+1, 0, m_pTableModel->getColumnCount())),
- Any());
- }
+ TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() );
+ ENSURE_OR_RETURN_VOID( pTable, "SVTXGridControl::rowHeadingChanged: no control (anymore)!" );
+
+ // TODO: we could do better than this - invalidate the header area only
+ pTable->getTableControlInterface().invalidate( TableAreaRowHeaders );
}
-void SAL_CALL SVTXGridControl::columnChanged(const ::com::sun::star::awt::grid::GridColumnEvent& Event ) throw (::com::sun::star::uno::RuntimeException)
+//----------------------------------------------------------------------------------------------------------------------
+void SAL_CALL SVTXGridControl::elementInserted( const ContainerEvent& i_event ) throw (RuntimeException)
{
::vos::OGuard aGuard( GetMutex() );
- TableControl* pTable = (TableControl*)GetWindow();
- if(Event.valueName == rtl::OUString::createFromAscii("ColumnResize"))
- {
- bool resizable = m_pTableModel->getColumnModel()[Event.index]->isResizable();
- Event.newValue>>=resizable;
- m_pTableModel->getColumnModel()[Event.index]->setResizable(resizable);
- }
- else if(Event.valueName == rtl::OUString::createFromAscii("ColWidth"))
- {
- sal_Int32 colWidth = m_pTableModel->getColumnModel()[Event.index]->getWidth();
- Event.newValue>>=colWidth;
- m_pTableModel->getColumnModel()[Event.index]->setWidth(colWidth);
- }
- else if(Event.valueName == rtl::OUString::createFromAscii("MaxWidth"))
- {
- sal_Int32 maxWidth = m_pTableModel->getColumnModel()[Event.index]->getMaxWidth();
- Event.newValue>>=maxWidth;
- m_pTableModel->getColumnModel()[Event.index]->setMaxWidth(maxWidth);
- }
- else if(Event.valueName == rtl::OUString::createFromAscii("MinWidth"))
- {
- sal_Int32 minWidth = m_pTableModel->getColumnModel()[Event.index]->getMinWidth();
- Event.newValue>>=minWidth;
- m_pTableModel->getColumnModel()[Event.index]->setMinWidth(minWidth);
- }
- else if(Event.valueName == rtl::OUString::createFromAscii("PrefWidth"))
- {
- sal_Int32 prefWidth = m_pTableModel->getColumnModel()[Event.index]->getPreferredWidth();
- Event.newValue>>=prefWidth;
- m_pTableModel->getColumnModel()[Event.index]->setPreferredWidth(prefWidth);
- }
- else if(Event.valueName == rtl::OUString::createFromAscii("HAlign"))
- {
- ::com::sun::star::style::HorizontalAlignment hAlign = m_pTableModel->getColumnModel()[Event.index]->getHorizontalAlign();
- Event.newValue>>=hAlign;
- m_pTableModel->getColumnModel()[Event.index]->setHorizontalAlign(hAlign);
- }
- else if(Event.valueName == rtl::OUString::createFromAscii("UpdateWidth"))
- {
- if(m_pTableModel->getColumnModel()[Event.index]->getPreferredWidth() != 0)
- m_xColumnModel->getColumn(Event.index)->updateColumn(rtl::OUString::createFromAscii("PrefWidth"), m_pTableModel->getColumnModel()[Event.index]->getPreferredWidth());
- m_xColumnModel->getColumn(Event.index)->updateColumn(rtl::OUString::createFromAscii("ColWidth"), m_pTableModel->getColumnModel()[Event.index]->getWidth());
- }
- pTable->Invalidate();
+ Reference< XGridColumn > const xGridColumn( i_event.Element, UNO_QUERY_THROW );
+
+ sal_Int32 nIndex( m_pTableModel->getColumnCount() );
+ OSL_VERIFY( i_event.Accessor >>= nIndex );
+ m_pTableModel->insertColumn( nIndex, xGridColumn );
}
-void SAL_CALL SVTXGridControl::dataChanged(const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException)
+
+//----------------------------------------------------------------------------------------------------------------------
+void SAL_CALL SVTXGridControl::elementRemoved( const ContainerEvent& i_event ) throw (RuntimeException)
{
::vos::OGuard aGuard( GetMutex() );
- TableControl* pTable = (TableControl*)GetWindow();
- if(Event.valueName == rtl::OUString::createFromAscii("RowHeight"))
- {
- sal_Int32 rowHeight = m_pTableModel->getRowHeight();
- Event.newValue>>=rowHeight;
- m_pTableModel->setRowHeight(rowHeight);
- pTable->Invalidate();
- }
- else if(Event.valueName == rtl::OUString::createFromAscii("RowHeaderWidth"))
- {
- sal_Int32 rowHeaderWidth = m_pTableModel->getRowHeaderWidth();
- Event.newValue>>=rowHeaderWidth;
- m_pTableModel->setRowHeaderWidth(rowHeaderWidth);
- pTable->Invalidate();
- }
- else if(Event.valueName == rtl::OUString::createFromAscii("RowHeaders"))
- {
- Sequence< rtl::OUString > headers(0);
- Event.newValue>>=headers;
- std::vector< rtl::OUString > headerNames( comphelper::sequenceToContainer <std::vector< rtl::OUString > >(headers) );
- m_pTableModel->setRowHeaderName(headerNames);
- pTable->Invalidate();
- }
- else if(Event.valueName == rtl::OUString::createFromAscii("CellUpdated"))
- {
- std::vector< std::vector< Any > >& rowContent = m_pTableModel->getCellContent();
- sal_Int32 col = -1;
- Event.oldValue>>=col;
- rowContent[Event.index][col] = Event.newValue;
- pTable->InvalidateDataWindow(Event.index, Event.index, false);
- }
- else if(Event.valueName == rtl::OUString::createFromAscii("RowUpdated"))
- {
- std::vector<std::vector< Any > >& rowContent = m_pTableModel->getCellContent();
- Sequence< sal_Int32 > cols(0);
- Sequence< Any > values(0);
- Event.oldValue>>=cols;
- Event.newValue>>=values;
- for(int i = 0; i< cols.getLength(); i++)
- {
- if(cols[i]>=0 && cols[i]<m_pTableModel->getColumnCount())
- rowContent[Event.index][cols[i]]=values[i];
- else
- break;
- }
- pTable->InvalidateDataWindow(Event.index, Event.index, false);
- }
+ sal_Int32 nIndex( -1 );
+ OSL_VERIFY( i_event.Accessor >>= nIndex );
+ m_pTableModel->removeColumn( nIndex );
}
-void SAL_CALL SVTXGridControl::disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException)
+//----------------------------------------------------------------------------------------------------------------------
+void SAL_CALL SVTXGridControl::elementReplaced( const ContainerEvent& i_event ) throw (RuntimeException)
{
- VCLXWindow::disposing( Source );
+ OSL_ENSURE( false, "SVTXGridControl::elementReplaced: not implemented!" );
+ // at the moment, the XGridColumnModel API does not allow replacing columns
+ OSL_UNUSED( i_event );
+ // TODO: replace the respective column in our table model
}
-::sal_Int32 SAL_CALL SVTXGridControl::getMinSelectionIndex() throw (::com::sun::star::uno::RuntimeException)
-{
- TableControl* pTable = (TableControl*)GetWindow();
- std::vector<RowPos>& selectedRows = pTable->GetSelectedRows();
- if(selectedRows.empty())
- return -1;
- else
- {
- std::vector<RowPos>::iterator itStart = selectedRows.begin();
- std::vector<RowPos>::iterator itEnd = selectedRows.end();
- return *(std::min_element(itStart, itEnd));
- }
-}
-::sal_Int32 SAL_CALL SVTXGridControl::getMaxSelectionIndex() throw (::com::sun::star::uno::RuntimeException)
+//----------------------------------------------------------------------------------------------------------------------
+void SAL_CALL SVTXGridControl::disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException)
{
- TableControl* pTable = (TableControl*)GetWindow();
- std::vector<RowPos>& selectedRows = pTable->GetSelectedRows();
- if(selectedRows.empty())
- return -1;
- else
- {
- std::vector<RowPos>::iterator itStart = selectedRows.begin();
- std::vector<RowPos>::iterator itEnd = selectedRows.end();
- return *(std::max_element(itStart, itEnd));
- }
+ VCLXWindow::disposing( Source );
}
-void SAL_CALL SVTXGridControl::selectRows(const ::com::sun::star::uno::Sequence< ::sal_Int32 >& rangeOfRows) throw (::com::sun::star::uno::RuntimeException)
+//----------------------------------------------------------------------------------------------------------------------
+void SAL_CALL SVTXGridControl::selectRow( ::sal_Int32 i_rowIndex ) throw (::com::sun::star::uno::RuntimeException)
{
- TableControl* pTable = (TableControl*)GetWindow();
- SelectionMode eSelMode = pTable->getSelEngine()->GetSelectionMode();
- if(eSelMode != NO_SELECTION)
- {
- sal_Int32 start = rangeOfRows[0];
- int seqSize = rangeOfRows.getLength();
- sal_Int32 end = rangeOfRows[seqSize-1];
- if((start >= 0 && start < m_pTableModel->getRowCount()) && (end >= 0 && end < m_pTableModel->getRowCount()))
- {
- std::vector<RowPos>& selectedRows = pTable->GetSelectedRows();
- if(eSelMode == SINGLE_SELECTION)
- {
- if(!selectedRows.empty())
- selectedRows.clear();
- if(rangeOfRows.getLength() == 1)
- selectedRows.push_back(start);
- else
- return;
- }
- else
- {
- for(int i=0;i<seqSize;i++)
- {
- if(!isSelectedIndex(rangeOfRows[i]))
- selectedRows.push_back(rangeOfRows[i]);
- }
- }
- pTable->selectionChanged(true);
- pTable->InvalidateDataWindow(start, end, false);
- SetSynthesizingVCLEvent( sal_True );
- pTable->Select();
- SetSynthesizingVCLEvent( sal_False );
- }
- }
+ ::vos::OGuard aGuard( GetMutex() );
+
+ TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() );
+ ENSURE_OR_RETURN_VOID( pTable, "SVTXGridControl::selectRow: no control (anymore)!" );
+
+ pTable->SelectRow( i_rowIndex, true );
}
+//----------------------------------------------------------------------------------------------------------------------
void SAL_CALL SVTXGridControl::selectAllRows() throw (::com::sun::star::uno::RuntimeException)
{
- TableControl* pTable = (TableControl*)GetWindow();
- SelectionMode eSelMode = pTable->getSelEngine()->GetSelectionMode();
- if(eSelMode != NO_SELECTION)
- {
- std::vector<RowPos>& selectedRows = pTable->GetSelectedRows();
- if(!selectedRows.empty())
- selectedRows.clear();
- for(int i=0;i<m_pTableModel->getRowCount();i++)
- selectedRows.push_back(i);
- pTable->Invalidate();
- SetSynthesizingVCLEvent( sal_True );
- pTable->Select();
- SetSynthesizingVCLEvent( sal_False );
- }
+ ::vos::OGuard aGuard( GetMutex() );
+
+ TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() );
+ ENSURE_OR_RETURN_VOID( pTable, "SVTXGridControl::selectAllRows: no control (anymore)!" );
+
+ pTable->SelectAllRows( true );
}
-void SAL_CALL SVTXGridControl::deselectRows(const ::com::sun::star::uno::Sequence< ::sal_Int32 >& rangeOfRows) throw (::com::sun::star::uno::RuntimeException)
+//----------------------------------------------------------------------------------------------------------------------
+void SAL_CALL SVTXGridControl::deselectRow( ::sal_Int32 i_rowIndex ) throw (::com::sun::star::uno::RuntimeException)
{
- TableControl* pTable = (TableControl*)GetWindow();
- std::vector<RowPos>& selectedRows = pTable->GetSelectedRows();
- std::vector<RowPos>::iterator itStart = selectedRows.begin();
- std::vector<RowPos>::iterator itEnd = selectedRows.end();
- for(int i = 0; i < rangeOfRows.getLength(); i++ )
- {
- std::vector<RowPos>::iterator iter = std::find(itStart, itEnd, rangeOfRows[i]);
- selectedRows.erase(iter);
- }
- pTable->selectionChanged(true);
- pTable->Invalidate();
- SetSynthesizingVCLEvent( sal_True );
- pTable->Select();
- SetSynthesizingVCLEvent( sal_False );
+ ::vos::OGuard aGuard( GetMutex() );
+
+ TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() );
+ ENSURE_OR_RETURN_VOID( pTable, "SVTXGridControl::deselectRow: no control (anymore)!" );
+
+ pTable->SelectRow( i_rowIndex, false );
}
+//----------------------------------------------------------------------------------------------------------------------
void SAL_CALL SVTXGridControl::deselectAllRows() throw (::com::sun::star::uno::RuntimeException)
{
- TableControl* pTable = (TableControl*)GetWindow();
- std::vector<RowPos>& selectedRows = pTable->GetSelectedRows();
- if(!selectedRows.empty())
- selectedRows.clear();
- pTable->Invalidate();
- SetSynthesizingVCLEvent( sal_True );
- pTable->Select();
- SetSynthesizingVCLEvent( sal_False );
+ ::vos::OGuard aGuard( GetMutex() );
+
+ TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() );
+ ENSURE_OR_RETURN_VOID( pTable, "SVTXGridControl::deselectAllRows: no control (anymore)!" );
+
+ pTable->SelectAllRows( false );
}
+//----------------------------------------------------------------------------------------------------------------------
::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;
-}
+ ::vos::OGuard aGuard( GetMutex() );
-::sal_Bool SAL_CALL SVTXGridControl::isCellEditable() throw (::com::sun::star::uno::RuntimeException)
-{
- return sal_False;
+ TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() );
+ ENSURE_OR_RETURN( pTable, "SVTXGridControl::getSelection: no control (anymore)!", Sequence< sal_Int32 >() );
+
+ sal_Int32 selectionCount = pTable->GetSelectedRowCount();
+ Sequence< sal_Int32 > selectedRows( selectionCount );
+ for ( sal_Int32 i=0; i<selectionCount; ++i )
+ selectedRows[i] = pTable->GetSelectedRowIndex(i);
+ return selectedRows;
}
+//----------------------------------------------------------------------------------------------------------------------
::sal_Bool SAL_CALL SVTXGridControl::isSelectionEmpty() throw (::com::sun::star::uno::RuntimeException)
{
- TableControl* pTable = (TableControl*)GetWindow();
- std::vector<RowPos>& selectedRows = pTable->GetSelectedRows();
- if(selectedRows.empty())
- return sal_True;
- else
- return sal_False;
-}
+ ::vos::OGuard aGuard( GetMutex() );
-::sal_Bool SAL_CALL SVTXGridControl::isSelectedIndex(::sal_Int32 index) throw (::com::sun::star::uno::RuntimeException)
-{
- TableControl* pTable = (TableControl*)GetWindow();
- std::vector<RowPos>& selectedRows = pTable->GetSelectedRows();
- return std::find(selectedRows.begin(),selectedRows.end(), index) != selectedRows.end();
-}
+ TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() );
+ ENSURE_OR_RETURN( pTable, "SVTXGridControl::getSelection: no control (anymore)!", sal_True );
-void SAL_CALL SVTXGridControl::selectRow(::sal_Int32 index) throw (::com::sun::star::uno::RuntimeException)
-{
- if(index<0 || index>=m_pTableModel->getRowCount())
- return;
- TableControl* pTable = (TableControl*)GetWindow();
- SelectionMode eSelMode = pTable->getSelEngine()->GetSelectionMode();
- if(eSelMode != NO_SELECTION)
- {
- std::vector<RowPos>& selectedRows = pTable->GetSelectedRows();
- if(eSelMode == MULTIPLE_SELECTION)
- {
- if(!isSelectedIndex(index))
- selectedRows.push_back(index);
- else
- return;
- }
- else if(eSelMode == SINGLE_SELECTION)
- {
- if(!selectedRows.empty())
- {
- if(!isSelectedIndex(index))
- deselectRows(getSelection());
- else
- return;
- }
- selectedRows.push_back(index);
- }
- pTable->selectionChanged(true);
- pTable->InvalidateDataWindow(index, index, false);
- SetSynthesizingVCLEvent( sal_True );
- pTable->Select();
- SetSynthesizingVCLEvent( sal_False );
- }
+ return pTable->GetSelectedRowCount() > 0;
}
-void SAL_CALL SVTXGridControl::selectColumn(::sal_Int32 x) throw (::com::sun::star::uno::RuntimeException)
+//----------------------------------------------------------------------------------------------------------------------
+::sal_Bool SAL_CALL SVTXGridControl::isSelectedIndex( ::sal_Int32 index ) throw (::com::sun::star::uno::RuntimeException)
{
- (void)x;
+ ::vos::OGuard aGuard( GetMutex() );
+
+ TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() );
+ ENSURE_OR_RETURN( pTable, "SVTXGridControl::isSelectedIndex: no control (anymore)!", sal_False );
+
+ return pTable->IsRowSelected( index );
}
+
+//----------------------------------------------------------------------------------------------------------------------
void SVTXGridControl::dispose() throw(::com::sun::star::uno::RuntimeException)
{
- ::vos::OGuard aGuard( GetMutex() );
-
::com::sun::star::lang::EventObject aObj;
aObj.Source = (::cppu::OWeakObject*)this;
m_aSelectionListeners.disposeAndClear( aObj );
VCLXWindow::dispose();
}
+//----------------------------------------------------------------------------------------------------------------------
void SVTXGridControl::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
{
- ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xKeepAlive( this );
+ ::vos::OGuard aGuard( GetMutex() );
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xKeepAlive( this );
switch ( rVclWindowEvent.GetId() )
{
case VCLEVENT_TABLEROW_SELECT:
{
- TableControl* pTable = (TableControl*)GetWindow();
-
- if( pTable )
- {
- if ( m_aSelectionListeners.getLength() )
- {
- ImplCallItemListeners();
- }
- }
+ TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() );
+ ENSURE_OR_BREAK( pTable, "SVTXGridControl::ProcessWindowEvent: no control (anymore)!" );
+ if ( m_aSelectionListeners.getLength() )
+ ImplCallItemListeners();
}
break;
@@ -852,28 +703,30 @@ void SVTXGridControl::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent
}
}
+//----------------------------------------------------------------------------------------------------------------------
void SVTXGridControl::ImplCallItemListeners()
{
- TableControl* pTable = (TableControl*) GetWindow();
- if ( pTable && m_aSelectionListeners.getLength() )
+ TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() );
+ ENSURE_OR_RETURN_VOID( pTable, "SVTXGridControl::ImplCallItemListeners: no control (anymore)!" );
+
+ if ( m_aSelectionListeners.getLength() )
{
- ::std::vector<sal_Int32> selRows = pTable->GetSelectedRows();
+ sal_Int32 const actSelRowCount = pTable->GetSelectedRowCount();
::com::sun::star::awt::grid::GridSelectionEvent aEvent;
aEvent.Source = (::cppu::OWeakObject*)this;
aEvent.Column = 0;
- sal_Int32 actSelRowCount = selRows.size();
sal_Int32 diff = actSelRowCount - m_nSelectedRowCount;
//row added to selection
if(diff >= 1)
{
aEvent.Action = com::sun::star::awt::grid::SelectionEventType(0);
- aEvent.Row = selRows[actSelRowCount-1];
+ aEvent.Row = pTable->GetSelectedRowIndex( actSelRowCount - 1 );
aEvent.Range = diff;
}
//selected row changed
else if(diff == 0 && actSelRowCount != 0)
{
- aEvent.Row = selRows[actSelRowCount-1];
+ aEvent.Row = pTable->GetSelectedRowIndex( actSelRowCount - 1 );
aEvent.Action = com::sun::star::awt::grid::SelectionEventType(2);
aEvent.Range = 0;
}
@@ -882,7 +735,7 @@ void SVTXGridControl::ImplCallItemListeners()
//selection changed: multiple row deselected, only 1 row is selected
if(actSelRowCount == 1)
{
- aEvent.Row = selRows[actSelRowCount-1];
+ aEvent.Row = pTable->GetSelectedRowIndex( actSelRowCount - 1 );
aEvent.Action = com::sun::star::awt::grid::SelectionEventType(2);
}
//row is deselected
@@ -897,3 +750,31 @@ void SVTXGridControl::ImplCallItemListeners()
m_aSelectionListeners.selectionChanged( aEvent );
}
}
+
+//----------------------------------------------------------------------------------------------------------------------
+void SVTXGridControl::impl_updateColumnsFromModel_nothrow()
+{
+ Reference< XGridColumnModel > const xColumnModel( m_pTableModel->getColumnModel() );
+ ENSURE_OR_RETURN_VOID( xColumnModel.is(), "no model!" );
+ TableControl* pTable = dynamic_cast< TableControl* >( GetWindow() );
+ ENSURE_OR_RETURN_VOID( pTable != NULL, "no table!" );
+
+ try
+ {
+ const Sequence< Reference< XGridColumn > > columns = xColumnModel->getColumns();
+ for ( const Reference< XGridColumn >* colRef = columns.getConstArray();
+ colRef != columns.getConstArray() + columns.getLength();
+ ++colRef
+ )
+ {
+ ENSURE_OR_CONTINUE( colRef->is(), "illegal column!" );
+
+ m_pTableModel->appendColumn( *colRef );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
diff --git a/svtools/source/uno/svtxgridcontrol.hxx b/svtools/source/uno/svtxgridcontrol.hxx
index b15507e4614f..525327b3c760 100755
--- a/svtools/source/uno/svtxgridcontrol.hxx
+++ b/svtools/source/uno/svtxgridcontrol.hxx
@@ -32,86 +32,88 @@
#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/XGridColumnListener.hpp>
#include <com/sun/star/awt/grid/GridDataEvent.hpp>
#include <com/sun/star/awt/grid/GridColumnEvent.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 <com/sun/star/container/XContainerListener.hpp>
#include <toolkit/awt/vclxwindow.hxx>
#include <toolkit/awt/vclxwindows.hxx>
#include <cppuhelper/typeprovider.hxx>
-#include <cppuhelper/implbase3.hxx>
+#include <cppuhelper/implbase4.hxx>
#include <toolkit/helper/listenermultiplexer.hxx>
using namespace ::svt::table;
-class SVTXGridControl : public ::cppu::ImplInheritanceHelper3< VCLXWindow, ::com::sun::star::awt::grid::XGridControl,
- ::com::sun::star::awt::grid::XGridDataListener, ::com::sun::star::awt::grid::XGridColumnListener>
+typedef ::cppu::ImplInheritanceHelper3 < VCLXWindow
+ , ::com::sun::star::awt::grid::XGridControl
+ , ::com::sun::star::awt::grid::XGridDataListener
+ , ::com::sun::star::container::XContainerListener
+ > SVTXGridControl_Base;
+class SVTXGridControl : public SVTXGridControl_Base
{
private:
- ::boost::shared_ptr< 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;
- bool m_bUpdate;
- sal_Int32 m_nSelectedRowCount;
- SelectionListenerMultiplexer m_aSelectionListeners;
+ ::boost::shared_ptr< UnoControlTableModel > m_pTableModel;
+ bool m_bHasColumnHeaders;
+ bool m_bHasRowHeaders;
+ bool m_bTableModelInitCompleted;
+ sal_Int32 m_nSelectedRowCount;
+ SelectionListenerMultiplexer m_aSelectionListeners;
protected:
virtual void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent );
void ImplCallItemListeners();
public:
- SVTXGridControl();
+ 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);
- //XGridColumnListener overridables
- virtual void SAL_CALL columnChanged(const ::com::sun::star::awt::grid::GridColumnEvent & Event) throw (::com::sun::star::uno::RuntimeException);
+ // XGridDataListener
+ virtual void SAL_CALL rowsInserted( const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL rowsRemoved( 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 rowHeadingChanged( 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(); }
+ // XContainerListener
+ virtual void SAL_CALL elementInserted( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL elementRemoved( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL elementReplaced( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException);
- // ::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);
+ // XEventListener
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException);
- //::com::sun::star::awt::grid::XGridControl
- 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 selectRows(const ::com::sun::star::uno::Sequence< ::sal_Int32 >& rangeOfRows) throw (::com::sun::star::uno::RuntimeException);
+ // XGridSelection
+ virtual void SAL_CALL selectRow( ::sal_Int32 i_rowIndex ) throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL selectAllRows() throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL deselectRows(const ::com::sun::star::uno::Sequence< ::sal_Int32 >& rangeOfRows) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL deselectRow( ::sal_Int32 i_rowIndex ) throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL deselectAllRows() 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);
- virtual void SAL_CALL setToolTip(const ::com::sun::star::uno::Sequence< ::rtl::OUString >& text, const ::com::sun::star::uno::Sequence< sal_Int32 >& columns) throw (::com::sun::star::uno::RuntimeException);
+
+ // XGridControl
+ virtual ::sal_Int32 SAL_CALL getRowAtPoint(::sal_Int32 x, ::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getColumnAtPoint(::sal_Int32 x, ::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getCurrentColumn( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getCurrentRow( ) 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);
// ::com::sun::star::lang::XComponent
void SAL_CALL dispose( ) throw(::com::sun::star::uno::RuntimeException);
- };
- #endif // _SVT_GRIDCONTROL_HXX_
+
+protected:
+ // VCLXWindow
+ virtual void SetWindow( Window* pWindow );
+
+private:
+ void impl_updateColumnsFromModel_nothrow();
+ void impl_checkTableModelInit();
+};
+#endif // _SVT_GRIDCONTROL_HXX_
diff --git a/svtools/source/uno/treecontrolpeer.cxx b/svtools/source/uno/treecontrolpeer.cxx
index d6809635e5e5..c36368023a22 100644
--- a/svtools/source/uno/treecontrolpeer.cxx
+++ b/svtools/source/uno/treecontrolpeer.cxx
@@ -1360,7 +1360,7 @@ void TreeControlPeer::setProperty( const ::rtl::OUString& PropertyName, const An
case BASEPROPERTY_TREE_DATAMODEL:
onChangeDataModel( rTree, Reference< XTreeDataModel >( aValue, UNO_QUERY ) );
break;
- case BASEPROPERTY_TREE_ROWHEIGHT:
+ case BASEPROPERTY_ROW_HEIGHT:
{
sal_Int32 nHeight = 0;
if( aValue >>= nHeight )
@@ -1445,7 +1445,7 @@ Any TreeControlPeer::getProperty( const ::rtl::OUString& PropertyName ) throw(Ru
}
return Any( eSelectionType );
}
- case BASEPROPERTY_TREE_ROWHEIGHT:
+ case BASEPROPERTY_ROW_HEIGHT:
return Any( (sal_Int32)rTree.GetEntryHeight() );
case BASEPROPERTY_TREE_DATAMODEL:
return Any( mxDataModel );
diff --git a/svtools/source/uno/unocontroltablemodel.cxx b/svtools/source/uno/unocontroltablemodel.cxx
index d239ee3c740d..933363115810 100644
--- a/svtools/source/uno/unocontroltablemodel.cxx
+++ b/svtools/source/uno/unocontroltablemodel.cxx
@@ -28,486 +28,866 @@
#include "precompiled_svtools.hxx"
#include "unocontroltablemodel.hxx"
-#include <com/sun/star/view/SelectionType.hpp>
-#include "svtools/table/gridtablerenderer.hxx"
+#include "unogridcolumnfacade.hxx"
+
#include "svtools/table/defaultinputhandler.hxx"
+#include "svtools/table/gridtablerenderer.hxx"
#include "svtools/table/tablecontrol.hxx"
-#include <comphelper/sequence.hxx>
-#include <rtl/ref.hxx>
-#include <tools/debug.hxx>
-#include <toolkit/helper/property.hxx>
-#include <comphelper/processfactory.hxx>
+
+/** === begin UNO includes === **/
#include <com/sun/star/awt/grid/XGridColumn.hpp>
+#include <com/sun/star/view/SelectionType.hpp>
+#include <com/sun/star/awt/grid/XGridColumnListener.hpp>
+#include <com/sun/star/awt/grid/XSortableGridData.hpp>
+/** === end UNO includes === **/
-using ::rtl::OUString;
-using namespace ::svt::table;
-using namespace ::com::sun::star::uno;
+#include <comphelper/stlunosequence.hxx>
+#include <cppuhelper/weakref.hxx>
+#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
+#include <vcl/svapp.hxx>
+#include <vos/mutex.hxx>
+
+// .....................................................................................................................
+namespace svt { namespace table
+{
+// .....................................................................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ 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::uno::Exception;
+ using ::com::sun::star::awt::grid::XGridColumnListener;
+ using ::com::sun::star::lang::EventObject;
+ using ::com::sun::star::awt::grid::GridColumnEvent;
+ using ::com::sun::star::awt::grid::XGridDataModel;
+ using ::com::sun::star::awt::grid::XGridColumnModel;
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::style::HorizontalAlignment_LEFT;
+ using ::com::sun::star::style::HorizontalAlignment;
+ using ::com::sun::star::style::VerticalAlignment_TOP;
+ using ::com::sun::star::style::VerticalAlignment;
+ using ::com::sun::star::uno::WeakReference;
+ using ::com::sun::star::awt::grid::GridDataEvent;
+ using ::com::sun::star::awt::grid::XSortableGridData;
+ using ::com::sun::star::beans::Pair;
+ /** === end UNO using === **/
+
+ //==================================================================================================================
+ //= UnoControlTableModel_Impl
+ //==================================================================================================================
+ typedef ::std::vector< PTableModelListener > ModellListeners;
+ typedef ::std::vector< PColumnModel > ColumnModels;
+ struct UnoControlTableModel_Impl
+ {
+ ColumnModels aColumns;
+ bool bHasColumnHeaders;
+ bool bHasRowHeaders;
+ ScrollbarVisibility eVScrollMode;
+ ScrollbarVisibility eHScrollMode;
+ PTableRenderer pRenderer;
+ PTableInputHandler pInputHandler;
+ TableMetrics nRowHeight;
+ TableMetrics nColumnHeaderHeight;
+ TableMetrics nRowHeaderWidth;
+ ::boost::optional< ::Color > m_aGridLineColor;
+ ::boost::optional< ::Color > m_aHeaderBackgroundColor;
+ ::boost::optional< ::Color > m_aHeaderTextColor;
+ ::boost::optional< ::Color > m_aTextColor;
+ ::boost::optional< ::Color > m_aTextLineColor;
+ ::boost::optional< ::std::vector< ::Color > > m_aRowColors;
+ VerticalAlignment m_eVerticalAlign;
+ ModellListeners m_aListeners;
+ WeakReference< XGridDataModel > m_aDataModel;
+ WeakReference< XGridColumnModel > m_aColumnModel;
+ UnoControlTableModel_Impl()
+ :aColumns ( )
+ ,bHasColumnHeaders ( true )
+ ,bHasRowHeaders ( false )
+ ,eVScrollMode ( ScrollbarShowNever )
+ ,eHScrollMode ( ScrollbarShowNever )
+ ,pRenderer ( )
+ ,pInputHandler ( )
+ ,nRowHeight ( 10 )
+ ,nColumnHeaderHeight ( 10 )
+ ,nRowHeaderWidth ( 10 )
+ ,m_aGridLineColor ( )
+ ,m_aHeaderBackgroundColor ( )
+ ,m_aHeaderTextColor ( )
+ ,m_aTextColor ( )
+ ,m_aTextLineColor ( )
+ ,m_aRowColors ( )
+ ,m_eVerticalAlign ( VerticalAlignment_TOP )
+ {
+ }
+ };
- //--------------------------------------------------------------------
- UnoControlTableColumn::UnoControlTableColumn(Reference<XGridColumn> m_xGridColumn)
- :m_nID( 0 )
- ,m_sName()
- ,m_bIsResizable( true )
- ,m_nWidth( 4 )
- ,m_nMinWidth( 0 )
- ,m_nMaxWidth( 0 )
- ,m_nPrefWidth ( 0 )
- ,m_xHorizontalAlign(com::sun::star::style::HorizontalAlignment(0))
- {
- m_sName = m_xGridColumn->getTitle();
- }
- //--------------------------------------------------------------------
- UnoControlTableColumn::UnoControlTableColumn()
- :m_nID( 0 )
- ,m_sName()
- ,m_bIsResizable( true )
- ,m_nWidth( 4 )
- ,m_nMinWidth( 0 )
- ,m_nMaxWidth( 0 )
- ,m_nPrefWidth ( 0 )
- ,m_xHorizontalAlign(com::sun::star::style::HorizontalAlignment(0))
+ //==================================================================================================================
+ //= UnoControlTableModel
+ //==================================================================================================================
+#ifdef DBG_UTIL
+ const char* UnoControlTableModel_checkInvariants( const void* _pInstance )
{
+ return static_cast< const UnoControlTableModel* >( _pInstance )->checkInvariants();
}
- //--------------------------------------------------------------------
- ColumnID UnoControlTableColumn::getID() const
+ //------------------------------------------------------------------------------------------------------------------
+ const char* UnoControlTableModel::checkInvariants() const
{
- return m_nID;
- }
+ Reference< XGridDataModel > const xDataModel( m_pImpl->m_aDataModel );
+ if ( !xDataModel.is() )
+ return "data model anymore";
- //--------------------------------------------------------------------
- bool UnoControlTableColumn::setID( const ColumnID _nID )
- {
- m_nID = _nID;
- return true;
- }
+ // TODO: more?
- //--------------------------------------------------------------------
- String UnoControlTableColumn::getName() const
- {
- return m_sName;
+ return NULL;
}
+#endif
- //--------------------------------------------------------------------
- void UnoControlTableColumn::setName( const String& _rName )
+#define DBG_CHECK_ME() \
+ DBG_TESTSOLARMUTEX(); \
+ DBG_CHKTHIS( UnoControlTableModel, UnoControlTableModel_checkInvariants )
+
+ //------------------------------------------------------------------------------------------------------------------
+ DBG_NAME( UnoControlTableModel )
+ UnoControlTableModel::UnoControlTableModel()
+ :m_pImpl( new UnoControlTableModel_Impl )
{
- m_sName = _rName;
+ DBG_CTOR( UnoControlTableModel, UnoControlTableModel_checkInvariants );
+ m_pImpl->bHasColumnHeaders = true;
+ m_pImpl->bHasRowHeaders = false;
+ m_pImpl->pRenderer.reset( new GridTableRenderer( *this ) );
+ m_pImpl->pInputHandler.reset( new DefaultInputHandler );
}
- //--------------------------------------------------------------------
- bool UnoControlTableColumn::isResizable() const
+
+ //------------------------------------------------------------------------------------------------------------------
+ UnoControlTableModel::~UnoControlTableModel()
{
- return m_bIsResizable;
+ DBG_DTOR( UnoControlTableModel, UnoControlTableModel_checkInvariants );
+ DELETEZ( m_pImpl );
}
- //--------------------------------------------------------------------
- void UnoControlTableColumn::setResizable( bool _bResizable )
+ //------------------------------------------------------------------------------------------------------------------
+ TableSize UnoControlTableModel::getColumnCount() const
{
- m_bIsResizable = _bResizable;
+ DBG_CHECK_ME();
+ return (TableSize)m_pImpl->aColumns.size();
}
- //--------------------------------------------------------------------
- TableMetrics UnoControlTableColumn::getWidth() const
+ //------------------------------------------------------------------------------------------------------------------
+ TableSize UnoControlTableModel::getRowCount() const
{
- return m_nWidth;
+ DBG_CHECK_ME();
+
+ TableSize nRowCount = 0;
+ try
+ {
+ Reference< XGridDataModel > const xDataModel( m_pImpl->m_aDataModel );
+ ENSURE_OR_THROW( xDataModel.is(), "no data model anymore!" );
+ nRowCount = xDataModel->getRowCount();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return nRowCount;
}
- //--------------------------------------------------------------------
- void UnoControlTableColumn::setWidth( TableMetrics _nWidth )
+ //------------------------------------------------------------------------------------------------------------------
+ bool UnoControlTableModel::hasColumnHeaders() const
{
- m_nWidth = _nWidth;
+ DBG_CHECK_ME();
+ return m_pImpl->bHasColumnHeaders;
}
- //--------------------------------------------------------------------
- TableMetrics UnoControlTableColumn::getMinWidth() const
+ //------------------------------------------------------------------------------------------------------------------
+ bool UnoControlTableModel::hasRowHeaders() const
{
- return m_nMinWidth;
+ DBG_CHECK_ME();
+ return m_pImpl->bHasRowHeaders;
}
- //--------------------------------------------------------------------
- void UnoControlTableColumn::setMinWidth( TableMetrics _nMinWidth )
+ //------------------------------------------------------------------------------------------------------------------
+ void UnoControlTableModel::setRowHeaders(bool _bRowHeaders)
{
- m_nMinWidth = _nMinWidth;
+ DBG_CHECK_ME();
+ if ( m_pImpl->bHasRowHeaders == _bRowHeaders )
+ return;
+
+ m_pImpl->bHasRowHeaders = _bRowHeaders;
+ impl_notifyTableMetricsChanged();
}
- //--------------------------------------------------------------------
- TableMetrics UnoControlTableColumn::getMaxWidth() const
+ //------------------------------------------------------------------------------------------------------------------
+ void UnoControlTableModel::setColumnHeaders(bool _bColumnHeaders)
{
- return m_nMaxWidth;
+ DBG_CHECK_ME();
+ if ( m_pImpl->bHasColumnHeaders == _bColumnHeaders )
+ return;
+
+ m_pImpl->bHasColumnHeaders = _bColumnHeaders;
+ impl_notifyTableMetricsChanged();
}
- //--------------------------------------------------------------------
- void UnoControlTableColumn::setMaxWidth( TableMetrics _nMaxWidth )
+ //------------------------------------------------------------------------------------------------------------------
+ bool UnoControlTableModel::isCellEditable( ColPos col, RowPos row ) const
{
- m_nMaxWidth = _nMaxWidth;
+ DBG_CHECK_ME();
+ (void)col;
+ (void)row;
+ return false;
}
- //--------------------------------------------------------------------
- TableMetrics UnoControlTableColumn::getPreferredWidth() const
+
+ //------------------------------------------------------------------------------------------------------------------
+ PColumnModel UnoControlTableModel::getColumnModel( ColPos column )
{
- return m_nPrefWidth;
+ DBG_CHECK_ME();
+ ENSURE_OR_RETURN( ( column >= 0 ) && ( column < getColumnCount() ),
+ "DefaultTableModel::getColumnModel: invalid index!", PColumnModel() );
+ return m_pImpl->aColumns[ column ];
}
- //--------------------------------------------------------------------
- void UnoControlTableColumn::setPreferredWidth( TableMetrics _nPrefWidth )
+ //------------------------------------------------------------------------------------------------------------------
+ void UnoControlTableModel::appendColumn( Reference< XGridColumn > const & i_column )
{
- m_nPrefWidth = _nPrefWidth;
+ DBG_CHECK_ME();
+ insertColumn( m_pImpl->aColumns.size(), i_column );
}
- //--------------------------------------------------------------------
- ::com::sun::star::style::HorizontalAlignment UnoControlTableColumn::getHorizontalAlign()
+
+ //------------------------------------------------------------------------------------------------------------------
+ void UnoControlTableModel::insertColumn( ColPos const i_position, Reference< XGridColumn > const & i_column )
{
- return m_xHorizontalAlign;
+ DBG_CHECK_ME();
+ ENSURE_OR_RETURN_VOID( ( i_position >= 0 ) && ( size_t( i_position ) <= m_pImpl->aColumns.size() ),
+ "UnoControlTableModel::insertColumn: illegal position!" );
+
+ const PColumnModel pColumn( new UnoGridColumnFacade( *this, i_column ) );
+ m_pImpl->aColumns.insert( m_pImpl->aColumns.begin() + i_position, pColumn );
+
+ // notify listeners
+ ModellListeners aListeners( m_pImpl->m_aListeners );
+ for ( ModellListeners::const_iterator loop = aListeners.begin();
+ loop != aListeners.end();
+ ++loop
+ )
+ {
+ (*loop)->columnInserted( i_position );
+ }
}
- //--------------------------------------------------------------------
- void UnoControlTableColumn::setHorizontalAlign( com::sun::star::style::HorizontalAlignment _align )
+ //------------------------------------------------------------------------------------------------------------------
+ void UnoControlTableModel::removeColumn( ColPos const i_position )
{
- m_xHorizontalAlign = _align;
+ DBG_CHECK_ME();
+ ENSURE_OR_RETURN_VOID( ( i_position >= 0 ) && ( size_t( i_position ) <= m_pImpl->aColumns.size() ),
+ "UnoControlTableModel::removeColumn: illegal position!" );
+
+ // remove the column
+ ColumnModels::iterator pos = m_pImpl->aColumns.begin() + i_position;
+ const PColumnModel pColumn = *pos;
+ m_pImpl->aColumns.erase( pos );
+
+ // notify listeners
+ ModellListeners aListeners( m_pImpl->m_aListeners );
+ for ( ModellListeners::const_iterator loop = aListeners.begin();
+ loop != aListeners.end();
+ ++loop
+ )
+ {
+ (*loop)->columnRemoved( i_position );
+ }
+
+ // dispose the column
+ UnoGridColumnFacade* pColumnImpl = dynamic_cast< UnoGridColumnFacade* >( pColumn.get() );
+ OSL_ENSURE( pColumnImpl != NULL, "UnoControlTableModel::removeColumn: illegal column implementation!" );
+ if ( pColumnImpl )
+ pColumnImpl->dispose();
}
- //====================================================================
- //= DefaultTableModel_Impl
- //====================================================================
- struct UnoControlTableModel_Impl
+ //------------------------------------------------------------------------------------------------------------------
+ void UnoControlTableModel::removeAllColumns()
{
- ::std::vector< PColumnModel > aColumns;
- TableSize nRowCount;
- bool bHasColumnHeaders;
- bool bHasRowHeaders;
- bool bVScroll;
- bool bHScroll;
- PTableRenderer pRenderer;
- PTableInputHandler pInputHandler;
- TableMetrics nRowHeight;
- TableMetrics nColumnHeaderHeight;
- TableMetrics nRowHeaderWidth;
- std::vector<rtl::OUString> aRowHeadersTitle;
- std::vector<std::vector< Any > > aCellContent;
- ::com::sun::star::util::Color m_xLineColor;
- ::com::sun::star::util::Color m_xHeaderColor;
- ::com::sun::star::util::Color m_xTextColor;
- ::com::sun::star::util::Color m_xRowColor1;
- ::com::sun::star::util::Color m_xRowColor2;
- ::com::sun::star::style::VerticalAlignment m_xVerticalAlign;
+ DBG_CHECK_ME();
+ if ( m_pImpl->aColumns.empty() )
+ return;
- UnoControlTableModel_Impl()
- :aColumns ( )
- ,nRowCount ( 0 )
- ,bHasColumnHeaders ( false )
- ,bHasRowHeaders ( false )
- ,bVScroll ( false )
- ,bHScroll ( false )
- ,pRenderer ( )
- ,pInputHandler ( )
- ,nRowHeight ( 0 )
- ,nColumnHeaderHeight( 0 )
- ,nRowHeaderWidth ( 10 )
- ,aRowHeadersTitle ( )
- ,aCellContent ( )
- ,m_xLineColor ( 0xFFFFFF )
- ,m_xHeaderColor ( 0xFFFFFF )
- ,m_xTextColor ( 0 )//black as default
- ,m_xRowColor1 ( 0xFFFFFF )
- ,m_xRowColor2 ( 0xFFFFFF )
- ,m_xVerticalAlign (com::sun::star::style::VerticalAlignment(0))
+ // dispose the column instances
+ for ( ColumnModels::const_iterator col = m_pImpl->aColumns.begin();
+ col != m_pImpl->aColumns.end();
+ ++col
+ )
{
+ UnoGridColumnFacade* pColumn = dynamic_cast< UnoGridColumnFacade* >( col->get() );
+ ENSURE_OR_CONTINUE( pColumn != NULL, "UnoControlTableModel::removeAllColumns: illegal column implementation!" );
+ pColumn->dispose();
}
- };
+ m_pImpl->aColumns.clear();
+
+ // notify listeners
+ ModellListeners aListeners( m_pImpl->m_aListeners );
+ for ( ModellListeners::const_iterator loop = aListeners.begin();
+ loop != aListeners.end();
+ ++loop
+ )
+ {
+ (*loop)->allColumnsRemoved();
+ }
+ }
- //====================================================================
- //= UnoControlTableModel
- //====================================================================
- //--------------------------------------------------------------------
- UnoControlTableModel::UnoControlTableModel()
- :m_pImpl( new UnoControlTableModel_Impl )
+ //------------------------------------------------------------------------------------------------------------------
+ void UnoControlTableModel::impl_notifyTableMetricsChanged() const
{
- m_pImpl->bHasColumnHeaders = false;
- m_pImpl->bHasRowHeaders = false;
- m_pImpl->pRenderer.reset( new GridTableRenderer( *this ) );
- m_pImpl->pInputHandler.reset( new DefaultInputHandler );
+ ModellListeners aListeners( m_pImpl->m_aListeners );
+ for ( ModellListeners::const_iterator loop = aListeners.begin();
+ loop != aListeners.end();
+ ++loop
+ )
+ {
+ (*loop)->tableMetricsChanged();
+ }
}
- //--------------------------------------------------------------------
- UnoControlTableModel::~UnoControlTableModel()
+ //------------------------------------------------------------------------------------------------------------------
+ PTableRenderer UnoControlTableModel::getRenderer() const
{
- DELETEZ( m_pImpl );
+ DBG_CHECK_ME();
+ return m_pImpl->pRenderer;
}
- //--------------------------------------------------------------------
- TableSize UnoControlTableModel::getColumnCount() const
+ //------------------------------------------------------------------------------------------------------------------
+ PTableInputHandler UnoControlTableModel::getInputHandler() const
{
- return (TableSize)m_pImpl->aColumns.size();
+ DBG_CHECK_ME();
+ return m_pImpl->pInputHandler;
}
- //--------------------------------------------------------------------
- TableSize UnoControlTableModel::getRowCount() const
+ //------------------------------------------------------------------------------------------------------------------
+ TableMetrics UnoControlTableModel::getRowHeight() const
{
- return m_pImpl->nRowCount;
+ DBG_CHECK_ME();
+ return m_pImpl->nRowHeight;
}
- //--------------------------------------------------------------------
- bool UnoControlTableModel::hasColumnHeaders() const
+ //------------------------------------------------------------------------------------------------------------------
+ void UnoControlTableModel::setRowHeight(TableMetrics _nRowHeight)
{
- return m_pImpl->bHasColumnHeaders;
+ DBG_CHECK_ME();
+ if ( m_pImpl->nRowHeight == _nRowHeight )
+ return;
+
+ m_pImpl->nRowHeight = _nRowHeight;
+ impl_notifyTableMetricsChanged();
}
- //--------------------------------------------------------------------
- bool UnoControlTableModel::hasRowHeaders() const
+ //------------------------------------------------------------------------------------------------------------------
+ TableMetrics UnoControlTableModel::getColumnHeaderHeight() const
{
- return m_pImpl->bHasRowHeaders;
+ DBG_CHECK_ME();
+ DBG_ASSERT( hasColumnHeaders(), "DefaultTableModel::getColumnHeaderHeight: invalid call!" );
+ return m_pImpl->nColumnHeaderHeight;
}
- //--------------------------------------------------------------------
- void UnoControlTableModel::setRowHeaders(bool _bRowHeaders)
+ //------------------------------------------------------------------------------------------------------------------
+ TableMetrics UnoControlTableModel::getRowHeaderWidth() const
{
- m_pImpl->bHasRowHeaders = _bRowHeaders;
+ DBG_CHECK_ME();
+ DBG_ASSERT( hasRowHeaders(), "DefaultTableModel::getRowHeaderWidth: invalid call!" );
+ return m_pImpl->nRowHeaderWidth;
}
- //--------------------------------------------------------------------
- void UnoControlTableModel::setColumnHeaders(bool _bColumnHeaders)
+ //------------------------------------------------------------------------------------------------------------------
+ void UnoControlTableModel::setColumnHeaderHeight(TableMetrics _nHeight)
{
- m_pImpl->bHasColumnHeaders = _bColumnHeaders;
+ DBG_CHECK_ME();
+ if ( m_pImpl->nColumnHeaderHeight == _nHeight )
+ return;
+
+ m_pImpl->nColumnHeaderHeight = _nHeight;
+ impl_notifyTableMetricsChanged();
}
- void UnoControlTableModel::setColumnCount(TableSize _nColCount)
+ //------------------------------------------------------------------------------------------------------------------
+ void UnoControlTableModel::setRowHeaderWidth(TableMetrics _nWidth)
{
- m_pImpl->aColumns.resize( _nColCount);
+ DBG_CHECK_ME();
+ if ( m_pImpl->nRowHeaderWidth == _nWidth )
+ return;
+
+ m_pImpl->nRowHeaderWidth = _nWidth;
+ impl_notifyTableMetricsChanged();
}
- //--------------------------------------------------------------------
- void UnoControlTableModel::setRowCount(TableSize _nRowCount)
+
+ //------------------------------------------------------------------------------------------------------------------
+ ScrollbarVisibility UnoControlTableModel::getVerticalScrollbarVisibility() const
{
- m_pImpl->nRowCount = _nRowCount;
+ DBG_CHECK_ME();
+ return m_pImpl->eVScrollMode;
}
- //--------------------------------------------------------------------
- bool UnoControlTableModel::isCellEditable( ColPos col, RowPos row ) const
+
+ //------------------------------------------------------------------------------------------------------------------
+ ScrollbarVisibility UnoControlTableModel::getHorizontalScrollbarVisibility() const
{
- (void)col;
- (void)row;
- return false;
+ DBG_CHECK_ME();
+ return m_pImpl->eHScrollMode;
}
- //--------------------------------------------------------------------
- void UnoControlTableModel::addTableModelListener( const PTableModelListener& listener )
+ //------------------------------------------------------------------------------------------------------------------
+ void UnoControlTableModel::addTableModelListener( const PTableModelListener& i_listener )
{
- (void) listener;
- // TODO
- DBG_ERROR( "DefaultTableModel::addTableModelListener: not yet implemented!" );
+ DBG_CHECK_ME();
+ ENSURE_OR_RETURN_VOID( !!i_listener, "illegal NULL listener" );
+ m_pImpl->m_aListeners.push_back( i_listener );
}
- //--------------------------------------------------------------------
- void UnoControlTableModel::removeTableModelListener( const PTableModelListener& listener )
+ //------------------------------------------------------------------------------------------------------------------
+ void UnoControlTableModel::removeTableModelListener( const PTableModelListener& i_listener )
{
- (void)listener;
- // TODO
- DBG_ERROR( "DefaultTableModel::removeTableModelListener: not yet implemented!" );
+ DBG_CHECK_ME();
+ for ( ModellListeners::iterator lookup = m_pImpl->m_aListeners.begin();
+ lookup != m_pImpl->m_aListeners.end();
+ ++lookup
+ )
+ {
+ if ( *lookup == i_listener )
+ {
+ m_pImpl->m_aListeners.erase( lookup );
+ return;
+ }
+ }
+ OSL_ENSURE( false, "UnoControlTableModel::removeTableModelListener: listener is not registered - sure you're doing the right thing here?" );
}
- //--------------------------------------------------------------------
- PColumnModel UnoControlTableModel::getColumnModel( ColPos column )
+ //------------------------------------------------------------------------------------------------------------------
+ void UnoControlTableModel::setVerticalScrollbarVisibility( ScrollbarVisibility const i_visibility ) const
{
- DBG_ASSERT( ( column >= 0 ) && ( column < getColumnCount() ),
- "DefaultTableModel::getColumnModel: invalid index!" );
- return m_pImpl->aColumns[ column ];
+ DBG_CHECK_ME();
+ m_pImpl->eVScrollMode = i_visibility;
}
- //--------------------------------------------------------------------
- std::vector<PColumnModel>& UnoControlTableModel::getColumnModel()
+ //------------------------------------------------------------------------------------------------------------------
+ void UnoControlTableModel::setHorizontalScrollbarVisibility( ScrollbarVisibility const i_visibility ) const
{
- return m_pImpl->aColumns;
+ DBG_CHECK_ME();
+ m_pImpl->eHScrollMode = i_visibility;
}
- //--------------------------------------------------------------------
- PColumnModel UnoControlTableModel::getColumnModelByID( ColumnID id )
+
+ //------------------------------------------------------------------------------------------------------------------
+ void UnoControlTableModel::setDataModel( Reference< XGridDataModel > const & i_gridDataModel )
{
- (void)id;
- // TODO
- DBG_ERROR( "DefaultTableModel::getColumnModelByID: not yet implemented!" );
- return PColumnModel();
+ DBG_CHECK_ME();
+ m_pImpl->m_aDataModel = i_gridDataModel;
+ // TODO: register as listener, so we're notified of row/data changes, and can multiplex them to our
+ // own listeners
}
- //--------------------------------------------------------------------
- PTableRenderer UnoControlTableModel::getRenderer() const
+ //------------------------------------------------------------------------------------------------------------------
+ Reference< XGridDataModel > UnoControlTableModel::getDataModel() const
{
- return m_pImpl->pRenderer;
+ Reference< XGridDataModel > const xDataModel( m_pImpl->m_aDataModel );
+ return xDataModel;
}
- //--------------------------------------------------------------------
- PTableInputHandler UnoControlTableModel::getInputHandler() const
+ //------------------------------------------------------------------------------------------------------------------
+ bool UnoControlTableModel::hasDataModel() const
{
- return m_pImpl->pInputHandler;
+ return getDataModel().is();
}
- //--------------------------------------------------------------------
- TableMetrics UnoControlTableModel::getRowHeight() const
+ //------------------------------------------------------------------------------------------------------------------
+ void UnoControlTableModel::setColumnModel( Reference< XGridColumnModel > const & i_gridColumnModel )
{
- return m_pImpl->nRowHeight;
+ DBG_CHECK_ME();
+ m_pImpl->m_aColumnModel = i_gridColumnModel;
}
- //--------------------------------------------------------------------
- void UnoControlTableModel::setRowHeight(TableMetrics _nRowHeight)
+
+ //------------------------------------------------------------------------------------------------------------------
+ Reference< XGridColumnModel > UnoControlTableModel::getColumnModel() const
{
- m_pImpl->nRowHeight = _nRowHeight;
+ Reference< XGridColumnModel > const xColumnModel( m_pImpl->m_aColumnModel );
+ return xColumnModel;
}
- //--------------------------------------------------------------------
- TableMetrics UnoControlTableModel::getColumnHeaderHeight() const
+ //------------------------------------------------------------------------------------------------------------------
+ bool UnoControlTableModel::hasColumnModel() const
{
- DBG_ASSERT( hasColumnHeaders(), "DefaultTableModel::getColumnHeaderHeight: invalid call!" );
- return m_pImpl->nColumnHeaderHeight;
+ return getColumnModel().is();
}
- //--------------------------------------------------------------------
- TableMetrics UnoControlTableModel::getRowHeaderWidth() const
+ //------------------------------------------------------------------------------------------------------------------
+ void UnoControlTableModel::getCellContent( ColPos const i_col, RowPos const i_row, Any& o_cellContent )
{
- DBG_ASSERT( hasRowHeaders(), "DefaultTableModel::getRowHeaderWidth: invalid call!" );
- return m_pImpl->nRowHeaderWidth;
+ DBG_CHECK_ME();
+
+ o_cellContent.clear();
+ try
+ {
+ Reference< XGridDataModel > const xDataModel( m_pImpl->m_aDataModel );
+ ENSURE_OR_RETURN_VOID( xDataModel.is(), "UnoControlTableModel::getCellContent: no data model anymore!" );
+
+ PColumnModel const pColumn = getColumnModel( i_col );
+ UnoGridColumnFacade* pColumnImpl = dynamic_cast< UnoGridColumnFacade* >( pColumn.get() );
+ ENSURE_OR_RETURN_VOID( pColumnImpl != NULL, "UnoControlTableModel::getCellContent: no (valid) column at this position!" );
+ sal_Int32 const nDataColumnIndex = pColumnImpl->getDataColumnIndex() >= 0 ? pColumnImpl->getDataColumnIndex() : i_col;
+
+ if ( nDataColumnIndex >= xDataModel->getColumnCount() )
+ {
+ // this is allowed, in case the column model has been dynamically extended, but the data model does
+ // not (yet?) know about it.
+ // So, handle it gracefully.
+ #if OSL_DEBUG_LEVEL > 0
+ {
+ Reference< XGridColumnModel > const xColumnModel( m_pImpl->m_aColumnModel );
+ OSL_ENSURE( xColumnModel.is() && i_col < xColumnModel->getColumnCount(),
+ "UnoControlTableModel::getCellContent: request a column's value which the ColumnModel doesn't know about!" );
+ }
+ #endif
+ }
+ else
+ {
+ o_cellContent = xDataModel->getCellData( nDataColumnIndex, i_row );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
}
- //--------------------------------------------------------------------
- void UnoControlTableModel::setColumnHeaderHeight(TableMetrics _nHeight)
+
+ //------------------------------------------------------------------------------------------------------------------
+ void UnoControlTableModel::getCellToolTip( ColPos const i_col, RowPos const i_row, Any& o_cellToolTip )
{
- m_pImpl->nColumnHeaderHeight = _nHeight;
+ DBG_CHECK_ME();
+ try
+ {
+ Reference< XGridDataModel > const xDataModel( m_pImpl->m_aDataModel );
+ ENSURE_OR_THROW( xDataModel.is(), "no data model anymore!" );
+
+ o_cellToolTip = xDataModel->getCellToolTip( i_col, i_row );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
}
- //--------------------------------------------------------------------
- void UnoControlTableModel::setRowHeaderWidth(TableMetrics _nWidth)
+ //------------------------------------------------------------------------------------------------------------------
+ Any UnoControlTableModel::getRowHeading( RowPos const i_rowPos ) const
{
- m_pImpl->nRowHeaderWidth = _nWidth;
+ DBG_CHECK_ME();
+
+ Any aRowHeading;
+
+ Reference< XGridDataModel > const xDataModel( m_pImpl->m_aDataModel );
+ ENSURE_OR_RETURN( xDataModel.is(), "UnoControlTableModel::getRowHeading: no data model anymore!", aRowHeading );
+
+ try
+ {
+ aRowHeading = xDataModel->getRowHeading( i_rowPos );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return aRowHeading;
}
- //--------------------------------------------------------------------
- void UnoControlTableModel::SetTitleHeight( TableMetrics _nHeight )
+ //------------------------------------------------------------------------------------------------------------------
+ namespace
{
- DBG_ASSERT( _nHeight > 0, "DefaultTableModel::SetTitleHeight: invalid height value!" );
- m_pImpl->nColumnHeaderHeight = _nHeight;
- // TODO: notification
+ void lcl_setColor( Any const & i_color, ::boost::optional< ::Color > & o_convertedColor )
+ {
+ if ( !i_color.hasValue() )
+ o_convertedColor.reset();
+ else
+ {
+ sal_Int32 nColor = COL_TRANSPARENT;
+ if ( i_color >>= nColor )
+ {
+ o_convertedColor.reset( ::Color( nColor ) );
+ }
+ else
+ {
+ OSL_ENSURE( false, "lcl_setColor: could not extract color value!" );
+ }
+ }
+ }
}
- //--------------------------------------------------------------------
- void UnoControlTableModel::SetHandleWidth( TableMetrics _nWidth )
+ //------------------------------------------------------------------------------------------------------------------
+ ::boost::optional< ::Color > UnoControlTableModel::getLineColor() const
{
- DBG_ASSERT( _nWidth > 0, "DefaultTableModel::SetHandleWidth: invalid width value!" );
- m_pImpl->nRowHeaderWidth = _nWidth;
- // TODO: notification
+ DBG_CHECK_ME();
+ return m_pImpl->m_aGridLineColor;
}
- //--------------------------------------------------------------------
- ScrollbarVisibility UnoControlTableModel::getVerticalScrollbarVisibility(int overAllHeight, int actHeight) const
+ //------------------------------------------------------------------------------------------------------------------
+ void UnoControlTableModel::setLineColor( Any const & i_color )
{
- if(overAllHeight>=actHeight && !m_pImpl->bVScroll)
- return ScrollbarShowNever;
- else
- return ScrollbarShowAlways;
+ DBG_CHECK_ME();
+ lcl_setColor( i_color, m_pImpl->m_aGridLineColor );
}
- //--------------------------------------------------------------------
- ScrollbarVisibility UnoControlTableModel::getHorizontalScrollbarVisibility(int overAllWidth, int actWidth) const
+ //------------------------------------------------------------------------------------------------------------------
+ ::boost::optional< ::Color > UnoControlTableModel::getHeaderBackgroundColor() const
{
- if(overAllWidth>=actWidth && !m_pImpl->bHScroll)
- return ScrollbarShowNever;
- else
- return ScrollbarShowAlways;
+ DBG_CHECK_ME();
+ return m_pImpl->m_aHeaderBackgroundColor;
}
- //--------------------------------------------------------------------
- void UnoControlTableModel::setVerticalScrollbarVisibility(bool _bVScroll) const
+
+ //------------------------------------------------------------------------------------------------------------------
+ void UnoControlTableModel::setHeaderBackgroundColor( Any const & i_color )
{
- m_pImpl->bVScroll = _bVScroll;
+ DBG_CHECK_ME();
+ lcl_setColor( i_color, m_pImpl->m_aHeaderBackgroundColor );
}
- //--------------------------------------------------------------------
- void UnoControlTableModel::setHorizontalScrollbarVisibility(bool _bHScroll) const
+ //------------------------------------------------------------------------------------------------------------------
+ ::boost::optional< ::Color > UnoControlTableModel::getHeaderTextColor() const
{
- m_pImpl->bHScroll = _bHScroll;
+ DBG_CHECK_ME();
+ return m_pImpl->m_aHeaderTextColor;
}
- //--------------------------------------------------------------------
- bool UnoControlTableModel::hasVerticalScrollbar()
+
+ //------------------------------------------------------------------------------------------------------------------
+ void UnoControlTableModel::setHeaderTextColor( Any const & i_color )
{
- return m_pImpl->bVScroll;
+ DBG_CHECK_ME();
+ lcl_setColor( i_color, m_pImpl->m_aHeaderTextColor );
}
- //--------------------------------------------------------------------
- bool UnoControlTableModel::hasHorizontalScrollbar()
+
+ //------------------------------------------------------------------------------------------------------------------
+ ::boost::optional< ::Color > UnoControlTableModel::getTextColor() const
{
- return m_pImpl->bHScroll;
+ DBG_CHECK_ME();
+ return m_pImpl->m_aTextColor;
}
- //--------------------------------------------------------------------
- void UnoControlTableModel::setCellContent(const std::vector<std::vector< Any > >& cellContent)
+
+ //------------------------------------------------------------------------------------------------------------------
+ void UnoControlTableModel::setTextColor( Any const & i_color )
{
- m_pImpl->aCellContent = cellContent;
+ DBG_CHECK_ME();
+ lcl_setColor( i_color, m_pImpl->m_aTextColor );
}
- std::vector<std::vector< Any > >& UnoControlTableModel::getCellContent()
+ //------------------------------------------------------------------------------------------------------------------
+ ::boost::optional< ::Color > UnoControlTableModel::getTextLineColor() const
{
- return m_pImpl->aCellContent;
+ DBG_CHECK_ME();
+ return m_pImpl->m_aTextColor;
}
- //--------------------------------------------------------------------
- void UnoControlTableModel::setRowHeaderName(const std::vector<rtl::OUString>& cellColumnContent)
+
+ //------------------------------------------------------------------------------------------------------------------
+ void UnoControlTableModel::setTextLineColor( Any const & i_color )
{
- m_pImpl->aRowHeadersTitle = cellColumnContent;
+ DBG_CHECK_ME();
+ lcl_setColor( i_color, m_pImpl->m_aTextLineColor );
}
- std::vector<rtl::OUString>& UnoControlTableModel::getRowHeaderName()
+ //------------------------------------------------------------------------------------------------------------------
+ ::boost::optional< ::std::vector< ::Color > > UnoControlTableModel::getRowBackgroundColors() const
{
- return m_pImpl->aRowHeadersTitle;
+ DBG_CHECK_ME();
+ return m_pImpl->m_aRowColors;
}
- //--------------------------------------------------------------------
- ::com::sun::star::util::Color UnoControlTableModel::getLineColor()
+
+ //------------------------------------------------------------------------------------------------------------------
+ void UnoControlTableModel::setRowBackgroundColors( ::com::sun::star::uno::Any const & i_APIValue )
{
- return m_pImpl->m_xLineColor;
+ DBG_CHECK_ME();
+ Sequence< ::com::sun::star::util::Color > aAPIColors;
+ if ( !( i_APIValue >>= aAPIColors ) )
+ m_pImpl->m_aRowColors.reset();
+ else
+ {
+ ::std::vector< ::Color > aColors( aAPIColors.getLength() );
+ for ( sal_Int32 i=0; i<aAPIColors.getLength(); ++i )
+ {
+ aColors[i] = ::Color( aAPIColors[i] );
+ }
+ m_pImpl->m_aRowColors.reset( aColors );
+ }
}
- //--------------------------------------------------------------------
- void UnoControlTableModel::setLineColor( ::com::sun::star::util::Color _rColor )
+ //------------------------------------------------------------------------------------------------------------------
+ VerticalAlignment UnoControlTableModel::getVerticalAlign() const
{
- m_pImpl->m_xLineColor = _rColor;
+ DBG_CHECK_ME();
+ return m_pImpl->m_eVerticalAlign;
}
- //--------------------------------------------------------------------
- ::com::sun::star::util::Color UnoControlTableModel::getHeaderBackgroundColor()
+
+ //------------------------------------------------------------------------------------------------------------------
+ void UnoControlTableModel::setVerticalAlign( VerticalAlignment _xAlign )
{
- return m_pImpl->m_xHeaderColor;
+ DBG_CHECK_ME();
+ m_pImpl->m_eVerticalAlign = _xAlign;
}
- //--------------------------------------------------------------------
- void UnoControlTableModel::setHeaderBackgroundColor( ::com::sun::star::util::Color _rColor )
+ //------------------------------------------------------------------------------------------------------------------
+ ColPos UnoControlTableModel::getColumnPos( UnoGridColumnFacade const & i_column ) const
{
- m_pImpl->m_xHeaderColor = _rColor;
+ DBG_CHECK_ME();
+ for ( ColumnModels::const_iterator col = m_pImpl->aColumns.begin();
+ col != m_pImpl->aColumns.end();
+ ++col
+ )
+ {
+ if ( &i_column == col->get() )
+ return col - m_pImpl->aColumns.begin();
+ }
+ OSL_ENSURE( false, "UnoControlTableModel::getColumnPos: column not found!" );
+ return COL_INVALID;
}
- //--------------------------------------------------------------------
- ::com::sun::star::util::Color UnoControlTableModel::getTextColor()
+
+ //------------------------------------------------------------------------------------------------------------------
+ ITableDataSort* UnoControlTableModel::getSortAdapter()
{
- return m_pImpl->m_xTextColor;
+ DBG_CHECK_ME();
+
+ Reference< XSortableGridData > const xSortAccess( getDataModel(), UNO_QUERY );
+ if ( xSortAccess.is() )
+ return this;
+ return NULL;
}
- //--------------------------------------------------------------------
- void UnoControlTableModel::setTextColor( ::com::sun::star::util::Color _rColor )
+ //------------------------------------------------------------------------------------------------------------------
+ void UnoControlTableModel::sortByColumn( ColPos const i_column, ColumnSortDirection const i_sortDirection )
{
- m_pImpl->m_xTextColor = _rColor;
+ DBG_CHECK_ME();
+
+ try
+ {
+ Reference< XSortableGridData > const xSortAccess( getDataModel(), UNO_QUERY_THROW );
+ xSortAccess->sortByColumn( i_column, i_sortDirection == ColumnSortAscending );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
}
- //--------------------------------------------------------------------
- ::com::sun::star::util::Color UnoControlTableModel::getOddRowBackgroundColor()
+
+ //------------------------------------------------------------------------------------------------------------------
+ ColumnSort UnoControlTableModel::getCurrentSortOrder() const
{
- return m_pImpl->m_xRowColor1;
+ DBG_CHECK_ME();
+
+ ColumnSort currentSort;
+ try
+ {
+ Reference< XSortableGridData > const xSortAccess( getDataModel(), UNO_QUERY_THROW );
+ Pair< ::sal_Int32, ::sal_Bool > const aCurrentSortOrder( xSortAccess->getCurrentSortOrder() );
+ currentSort.nColumnPos = aCurrentSortOrder.First;
+ currentSort.eSortDirection = aCurrentSortOrder.Second ? ColumnSortAscending : ColumnSortDescending;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return currentSort;
}
//--------------------------------------------------------------------
- void UnoControlTableModel::setOddRowBackgroundColor( ::com::sun::star::util::Color _rColor )
+ void UnoControlTableModel::notifyColumnChange( ColPos const i_columnPos, ColumnAttributeGroup const i_attributeGroup ) const
{
- m_pImpl->m_xRowColor1 = _rColor;
+ DBG_CHECK_ME();
+ ENSURE_OR_RETURN_VOID( ( i_columnPos >= 0 ) && ( i_columnPos < getColumnCount() ),
+ "UnoControlTableModel::notifyColumnChange: invalid column index!" );
+
+ ModellListeners aListeners( m_pImpl->m_aListeners );
+ for ( ModellListeners::const_iterator loop = aListeners.begin();
+ loop != aListeners.end();
+ ++loop
+ )
+ {
+ (*loop)->columnChanged( i_columnPos, i_attributeGroup );
+ }
}
- //--------------------------------------------------------------------
- ::com::sun::star::util::Color UnoControlTableModel::getEvenRowBackgroundColor()
+
+ //------------------------------------------------------------------------------------------------------------------
+ void UnoControlTableModel::notifyRowsInserted( GridDataEvent const & i_event ) const
{
- return m_pImpl->m_xRowColor2;
+ // check sanity of the event
+ ENSURE_OR_RETURN_VOID( i_event.FirstRow >= 0, "UnoControlTableModel::notifyRowsInserted: invalid first row!" );
+ ENSURE_OR_RETURN_VOID( i_event.LastRow >= i_event.FirstRow, "UnoControlTableModel::notifyRowsInserted: invalid row indexes!" );
+
+ // check own sanity
+ Reference< XGridColumnModel > const xColumnModel( m_pImpl->m_aColumnModel );
+ ENSURE_OR_RETURN_VOID( xColumnModel.is(), "UnoControlTableModel::notifyRowsInserted: no column model anymore!" );
+
+ Reference< XGridDataModel > const xDataModel( m_pImpl->m_aDataModel );
+ ENSURE_OR_RETURN_VOID( xDataModel.is(), "UnoControlTableModel::notifyRowsInserted: no data model anymore!" );
+
+ // implicitly add columns to the column model
+ // TODO: is this really a good idea?
+ sal_Int32 const dataColumnCount = xDataModel->getColumnCount();
+ OSL_ENSURE( dataColumnCount > 0, "UnoControlTableModel::notifyRowsInserted: no columns at all?" );
+
+ sal_Int32 const modelColumnCount = xColumnModel->getColumnCount();
+ if ( ( modelColumnCount == 0 ) && ( dataColumnCount > 0 ) )
+ {
+ // TODO: shouldn't we clear the mutexes guard for this call?
+ xColumnModel->setDefaultColumns( dataColumnCount );
+ }
+
+ // multiplex the event to our own listeners
+ ModellListeners aListeners( m_pImpl->m_aListeners );
+ for ( ModellListeners::const_iterator loop = aListeners.begin();
+ loop != aListeners.end();
+ ++loop
+ )
+ {
+ (*loop)->rowsInserted( i_event.FirstRow, i_event.LastRow );
+ }
}
- //--------------------------------------------------------------------
- void UnoControlTableModel::setEvenRowBackgroundColor( ::com::sun::star::util::Color _rColor )
+ //------------------------------------------------------------------------------------------------------------------
+ void UnoControlTableModel::notifyRowsRemoved( GridDataEvent const & i_event ) const
{
- m_pImpl->m_xRowColor2 = _rColor;
+ ModellListeners aListeners( m_pImpl->m_aListeners );
+ for ( ModellListeners::const_iterator loop = aListeners.begin();
+ loop != aListeners.end();
+ ++loop
+ )
+ {
+ (*loop)->rowsRemoved( i_event.FirstRow, i_event.LastRow );
+ }
}
- //--------------------------------------------------------------------
- ::com::sun::star::style::VerticalAlignment UnoControlTableModel::getVerticalAlign()
+
+ //------------------------------------------------------------------------------------------------------------------
+ void UnoControlTableModel::notifyDataChanged( ::com::sun::star::awt::grid::GridDataEvent const & i_event ) const
{
- return m_pImpl->m_xVerticalAlign;
+ ColPos const firstCol = i_event.FirstColumn == -1 ? 0 : i_event.FirstColumn;
+ ColPos const lastCol = i_event.FirstColumn == -1 ? getColumnCount() - 1 : i_event.LastColumn;
+ RowPos const firstRow = i_event.FirstRow == -1 ? 0 : i_event.FirstRow;
+ RowPos const lastRow = i_event.FirstRow == -1 ? getRowCount() - 1 : i_event.LastRow;
+
+ ModellListeners aListeners( m_pImpl->m_aListeners );
+ for ( ModellListeners::const_iterator loop = aListeners.begin();
+ loop != aListeners.end();
+ ++loop
+ )
+ {
+ (*loop)->cellsUpdated( firstCol, lastCol, firstRow, lastRow );
+ }
}
- //--------------------------------------------------------------------
- void UnoControlTableModel::setVerticalAlign( com::sun::star::style::VerticalAlignment _xAlign )
+ //------------------------------------------------------------------------------------------------------------------
+ void UnoControlTableModel::notifyAllDataChanged() const
{
- m_pImpl->m_xVerticalAlign = _xAlign;
+ ModellListeners aListeners( m_pImpl->m_aListeners );
+ for ( ModellListeners::const_iterator loop = aListeners.begin();
+ loop != aListeners.end();
+ ++loop
+ )
+ {
+ (*loop)->cellsUpdated( 0, getColumnCount() - 1, 0, getRowCount() - 1 );
+ }
}
+// .....................................................................................................................
+} } // svt::table
+// .....................................................................................................................
diff --git a/svtools/source/uno/unocontroltablemodel.hxx b/svtools/source/uno/unocontroltablemodel.hxx
index c00642448f79..537c3d9a5249 100644
--- a/svtools/source/uno/unocontroltablemodel.hxx
+++ b/svtools/source/uno/unocontroltablemodel.hxx
@@ -28,67 +28,37 @@
#ifndef _UNOCONTROL_TABLEMODEL_HXX_
#define _UNOCONTROL_TABLEMODEL_HXX_
-#include <svtools/table/tablemodel.hxx>
-#include <svtools/table/tablecontrol.hxx>
+#include "svtools/table/tablemodel.hxx"
+#include "svtools/table/tablecontrol.hxx"
+
+/** === begin UNO includes === **/
#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 <com/sun/star/awt/grid/XGridColumn.hpp>
#include <com/sun/star/util/Color.hpp>
#include <com/sun/star/style/VerticalAlignment.hpp>
-#include <com/sun/star/style/HorizontalAlignment.hpp>
+/** === end UNO includes === **/
+#include <cppuhelper/implbase2.hxx>
+#include <rtl/ref.hxx>
-using namespace ::svt::table;
-using namespace ::com::sun::star::uno;
-using namespace ::com::sun::star::awt::grid;
+#include <boost/noncopyable.hpp>
-class UnoControlTableColumn : public IColumnModel
-{
- private:
- ColumnID m_nID;
- String m_sName;
- bool m_bIsResizable;
- TableMetrics m_nWidth;
- TableMetrics m_nMinWidth;
- TableMetrics m_nMaxWidth;
- TableMetrics m_nPrefWidth;
- ::com::sun::star::style::HorizontalAlignment m_xHorizontalAlign;
-
- public:
- UnoControlTableColumn(Reference<XGridColumn>);
- UnoControlTableColumn();
-
- // 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 );
- virtual TableMetrics getPreferredWidth() const;
- virtual void setPreferredWidth( TableMetrics _nPrefWidth );
- virtual ::com::sun::star::style::HorizontalAlignment getHorizontalAlign();
- virtual void setHorizontalAlign(::com::sun::star::style::HorizontalAlignment _xAlign);
-};
-
-struct UnoControlTableModel_Impl;
-
-class UnoControlTableModel : public ITableModel
+// .....................................................................................................................
+namespace svt { namespace table
{
+// .....................................................................................................................
+
+ //==================================================================================================================
+ //= UnoControlTableModel
+ //==================================================================================================================
+ class UnoGridColumnFacade;
+ struct UnoControlTableModel_Impl;
+ class UnoControlTableModel : public ITableModel, public ITableDataSort
+ {
private:
UnoControlTableModel_Impl* m_pImpl;
@@ -96,82 +66,102 @@ class UnoControlTableModel : public ITableModel
UnoControlTableModel();
~UnoControlTableModel();
- /// returns the current row height, in 1/100 millimeters
- inline TableMetrics GetRowHeight() const { return getRowHeight(); }
- /// sets a new row height.
- void setRowHeight( TableMetrics _nHeight );
- /// sets a new row header width.
- void setRowHeaderWidth( TableMetrics _nWidth );
- /// sets a new column header height.
- void setColumnHeaderHeight( TableMetrics _nHeight );
-
- /// returns the height of the title row (containing the column headers)
- inline TableMetrics GetTitleHeight() const { return getColumnHeaderHeight(); }
- /// sets a new height for the title row (containing the column headers)
- void SetTitleHeight( TableMetrics _nHeight );
-
- /// returns the width of the handle column (containing the row headers)
- inline TableMetrics GetHandleWidth() const { return getRowHeaderWidth(); }
- /// sets a new width for the handle column (containing the row headers)
- void SetHandleWidth( TableMetrics _nWidth );
-
- /// sets the width of a column
- inline void SetColumnWidth( ColPos _nColumn, TableMetrics _nWidth100thMM );
- /// retrieves the width of a column, in 1/100th millimeters
- inline TableMetrics GetColumnWidth( ColPos _nColumn );
-
public:
// ITableModel overridables
- virtual TableSize getColumnCount() const;
- virtual TableSize getRowCount() const;
- virtual void setColumnCount(TableSize _nColCount);
- virtual void setRowCount(TableSize _nRowCount);
- virtual bool hasColumnHeaders() const;
- virtual bool hasRowHeaders() const;
- virtual void setRowHeaders(bool _bRowHeaders);
- virtual void setColumnHeaders(bool _bColumnHeaders);
- virtual bool isCellEditable( ColPos col, RowPos row ) const;
- 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;
- virtual TableMetrics getRowHeight() const;
- virtual TableMetrics getColumnHeaderHeight() const;
- virtual TableMetrics getRowHeaderWidth() const;
- virtual ScrollbarVisibility getVerticalScrollbarVisibility(int overAllHeight, int actHeight) const;
- virtual ScrollbarVisibility getHorizontalScrollbarVisibility(int overAllWidth, int actWidth) const;
- virtual void setVerticalScrollbarVisibility(bool _bVScroll) const;
- virtual void setHorizontalScrollbarVisibility(bool _bHScroll) const;
- virtual void setCellContent(const std::vector<std::vector< Any > >& cellContent);
- virtual std::vector<std::vector< Any > >& getCellContent();
- virtual void setRowHeaderName(const std::vector<rtl::OUString>& cellColumnContent);
- virtual std::vector<rtl::OUString>& getRowHeaderName();
- virtual ::com::sun::star::util::Color getLineColor();
- virtual void setLineColor(::com::sun::star::util::Color _rColor);
- virtual ::com::sun::star::util::Color getHeaderBackgroundColor();
- virtual void setHeaderBackgroundColor(::com::sun::star::util::Color _rColor);
- virtual ::com::sun::star::util::Color getTextColor();
- virtual void setTextColor(::com::sun::star::util::Color _rColor);
- virtual ::com::sun::star::util::Color getOddRowBackgroundColor();
- virtual void setOddRowBackgroundColor(::com::sun::star::util::Color _rColor);
- virtual ::com::sun::star::util::Color getEvenRowBackgroundColor();
- virtual void setEvenRowBackgroundColor(::com::sun::star::util::Color _rColor);
- virtual ::com::sun::star::style::VerticalAlignment getVerticalAlign();
- virtual void setVerticalAlign(::com::sun::star::style::VerticalAlignment _rAlign);
- virtual bool hasVerticalScrollbar();
- virtual bool hasHorizontalScrollbar();
-};
-
-inline void UnoControlTableModel::SetColumnWidth( ColPos _nColumn, TableMetrics _nWidth100thMM )
-{
- getColumnModel( _nColumn )->setWidth( _nWidth100thMM );
-}
+ virtual TableSize getColumnCount() const;
+ virtual TableSize getRowCount() const;
+ virtual bool hasColumnHeaders() const;
+ virtual bool hasRowHeaders() const;
+ virtual bool isCellEditable( ColPos col, RowPos row ) const;
+ virtual PColumnModel getColumnModel( ColPos column );
+ virtual PTableRenderer getRenderer() const;
+ virtual PTableInputHandler getInputHandler() const;
+ virtual TableMetrics getRowHeight() const;
+ virtual TableMetrics getColumnHeaderHeight() const;
+ virtual TableMetrics getRowHeaderWidth() const;
+ virtual ScrollbarVisibility getVerticalScrollbarVisibility() const;
+ virtual ScrollbarVisibility getHorizontalScrollbarVisibility() const;
+ virtual void addTableModelListener( const PTableModelListener& i_listener );
+ virtual void removeTableModelListener( const PTableModelListener& i_listener );
+ virtual void getCellContent( ColPos const i_col, RowPos const i_row, ::com::sun::star::uno::Any& o_cellContent );
+ virtual void getCellToolTip( ColPos const i_col, RowPos const i_row, ::com::sun::star::uno::Any & o_cellToolTip );
+ virtual ::com::sun::star::uno::Any getRowHeading( RowPos const i_rowPos ) const;
+ virtual ::boost::optional< ::Color > getLineColor() const;
+ virtual ::boost::optional< ::Color > getHeaderBackgroundColor() const;
+ virtual ::boost::optional< ::Color > getHeaderTextColor() const;
+ virtual ::boost::optional< ::Color > getTextColor() const;
+ virtual ::boost::optional< ::Color > getTextLineColor() const;
+ virtual ::boost::optional< ::std::vector< ::Color > >
+ getRowBackgroundColors() const;
+ virtual ::com::sun::star::style::VerticalAlignment
+ getVerticalAlign() const;
+ virtual ITableDataSort* getSortAdapter();
+
+ // ITableDataSort overridables
+ virtual void sortByColumn( ColPos const i_column, ColumnSortDirection const i_sortDirection );
+ virtual ColumnSort getCurrentSortOrder() const;
+
+ // column write access
+ void appendColumn( ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > const & i_column );
+ void insertColumn( ColPos const i_position, ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > const & i_column );
+ void removeColumn( ColPos const i_position );
+ void removeAllColumns();
+
+ // other operations
+ void setVerticalScrollbarVisibility( ScrollbarVisibility const i_visibility ) const;
+ void setHorizontalScrollbarVisibility( ScrollbarVisibility const i_visibility ) const;
+
+ void setDataModel( ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridDataModel > const & i_gridDataModel );
+ bool hasDataModel() const;
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridDataModel >
+ getDataModel() const;
+ void setColumnModel( ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumnModel > const & i_gridColumnModel );
+ bool hasColumnModel() const;
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumnModel >
+ getColumnModel() const;
+
+ void setRowHeaders(bool _bRowHeaders);
+ void setColumnHeaders(bool _bColumnHeaders);
+
+ void setRowHeight( TableMetrics _nHeight );
+ void setRowHeaderWidth( TableMetrics _nWidth );
+ void setColumnHeaderHeight( TableMetrics _nHeight );
+
+ void setLineColor( ::com::sun::star::uno::Any const & i_color );
+ void setHeaderBackgroundColor( ::com::sun::star::uno::Any const & i_color );
+ void setHeaderTextColor( ::com::sun::star::uno::Any const & i_color );
+ void setTextColor( ::com::sun::star::uno::Any const & i_color );
+ void setTextLineColor( ::com::sun::star::uno::Any const & i_color );
+ void setRowBackgroundColors( ::com::sun::star::uno::Any const & i_APIValue );
+
+ void setVerticalAlign(::com::sun::star::style::VerticalAlignment _rAlign);
+
+ // multiplexing of XGridDataListener events
+ void notifyRowsInserted( ::com::sun::star::awt::grid::GridDataEvent const & i_event ) const;
+ void notifyRowsRemoved( ::com::sun::star::awt::grid::GridDataEvent const & i_event ) const;
+ void notifyDataChanged( ::com::sun::star::awt::grid::GridDataEvent const & i_event ) const;
+
+ /// retrieves the index of a column within the model
+ ColPos getColumnPos( UnoGridColumnFacade const & i_column ) const;
+
+ /// notifies a change in a column belonging to the model
+ void notifyColumnChange( ColPos const i_columnPos, ColumnAttributeGroup const i_attributeGroup ) const;
+
+ /** notifies a change in all data represented by the model. To be used if you cannot specified the changed data
+ in more detail.
+ */
+ void notifyAllDataChanged() const;
+
+#ifdef DBG_UTIL
+ const char* checkInvariants() const;
+#endif
-inline TableMetrics UnoControlTableModel::GetColumnWidth( ColPos _nColumn )
-{
- return getColumnModel( _nColumn )->getWidth();
-}
- #endif // _UNOCONTROL_TABLEMODEL_HXX_
+ private:
+ void impl_notifyTableMetricsChanged() const;
+ };
+
+// .....................................................................................................................
+} } // svt::table
+// .....................................................................................................................
+
+#endif // _UNOCONTROL_TABLEMODEL_HXX_
diff --git a/svtools/source/uno/unogridcolumnfacade.cxx b/svtools/source/uno/unogridcolumnfacade.cxx
new file mode 100755
index 000000000000..d2f5e7b565fd
--- /dev/null
+++ b/svtools/source/uno/unogridcolumnfacade.cxx
@@ -0,0 +1,427 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "unogridcolumnfacade.hxx"
+#include "unocontroltablemodel.hxx"
+
+#include "svtools/table/defaultinputhandler.hxx"
+#include "svtools/table/gridtablerenderer.hxx"
+#include "svtools/table/tablecontrol.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/awt/grid/XGridColumn.hpp>
+#include <com/sun/star/view/SelectionType.hpp>
+#include <com/sun/star/awt/grid/XGridColumnListener.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/stlunosequence.hxx>
+#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
+#include <vcl/svapp.hxx>
+#include <vos/mutex.hxx>
+
+// .....................................................................................................................
+namespace svt { namespace table
+{
+// .....................................................................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ 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::uno::Exception;
+ using ::com::sun::star::awt::grid::XGridColumnListener;
+ using ::com::sun::star::lang::EventObject;
+ using ::com::sun::star::awt::grid::GridColumnEvent;
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::style::HorizontalAlignment_LEFT;
+ using ::com::sun::star::style::HorizontalAlignment;
+ /** === end UNO using === **/
+
+ //------------------------------------------------------------------------------------------------------------------
+ namespace
+ {
+ template< class ATTRIBUTE_TYPE >
+ void lcl_set( Reference< XGridColumn > const & i_column, void ( SAL_CALL XGridColumn::*i_setter )( ATTRIBUTE_TYPE ),
+ ATTRIBUTE_TYPE i_value )
+ {
+ try
+ {
+ (i_column.get()->*i_setter) ( i_value );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ template< class ATTRIBUTE_TYPE >
+ ATTRIBUTE_TYPE lcl_get( Reference< XGridColumn > const & i_column, ATTRIBUTE_TYPE ( SAL_CALL XGridColumn::*i_getter )() )
+ {
+ ATTRIBUTE_TYPE value = ATTRIBUTE_TYPE();
+ try
+ {
+ value = (i_column.get()->*i_getter)();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return value;
+ }
+ }
+
+ //==================================================================================================================
+ //= ColumnChangeMultiplexer
+ //==================================================================================================================
+ typedef ::cppu::WeakImplHelper1 < XGridColumnListener
+ > ColumnChangeMultiplexer_Base;
+ class ColumnChangeMultiplexer :public ColumnChangeMultiplexer_Base
+ ,public ::boost::noncopyable
+ {
+ public:
+ ColumnChangeMultiplexer( UnoGridColumnFacade& i_colImpl );
+
+ void dispose();
+
+ protected:
+ ~ColumnChangeMultiplexer();
+
+ // XGridColumnListener
+ virtual void SAL_CALL columnChanged( const GridColumnEvent& i_event ) throw (RuntimeException);
+
+ // XEventListener
+ virtual void SAL_CALL disposing( const EventObject& i_event ) throw (RuntimeException);
+
+ private:
+ UnoGridColumnFacade* m_pColumnImplementation;
+ };
+
+ //------------------------------------------------------------------------------------------------------------------
+ ColumnChangeMultiplexer::ColumnChangeMultiplexer( UnoGridColumnFacade& i_colImpl )
+ :m_pColumnImplementation( &i_colImpl )
+ {
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ ColumnChangeMultiplexer::~ColumnChangeMultiplexer()
+ {
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void ColumnChangeMultiplexer::dispose()
+ {
+ DBG_TESTSOLARMUTEX();
+ m_pColumnImplementation = NULL;
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void SAL_CALL ColumnChangeMultiplexer::columnChanged( const GridColumnEvent& i_event ) throw (RuntimeException)
+ {
+ if ( i_event.AttributeName.equalsAscii( "DataColumnIndex" ) )
+ {
+ ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ if ( m_pColumnImplementation != NULL )
+ m_pColumnImplementation->dataColumnIndexChanged();
+ return;
+ }
+
+ ColumnAttributeGroup nChangedAttributes( COL_ATTRS_NONE );
+
+ if ( i_event.AttributeName.equalsAscii( "HorizontalAlign" ) )
+ nChangedAttributes |= COL_ATTRS_APPEARANCE;
+
+ if ( i_event.AttributeName.equalsAscii( "ColumnWidth" )
+ || i_event.AttributeName.equalsAscii( "MaxWidth" )
+ || i_event.AttributeName.equalsAscii( "MinWidth" )
+ || i_event.AttributeName.equalsAscii( "PreferredWidth" )
+ || i_event.AttributeName.equalsAscii( "Resizeable" )
+ || i_event.AttributeName.equalsAscii( "Flexibility" )
+ )
+ nChangedAttributes |= COL_ATTRS_WIDTH;
+
+ OSL_ENSURE( nChangedAttributes != COL_ATTRS_NONE,
+ "ColumnChangeMultiplexer::columnChanged: unknown column attributed changed!" );
+
+ ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+ if ( m_pColumnImplementation != NULL )
+ m_pColumnImplementation->columnChanged( nChangedAttributes );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void SAL_CALL ColumnChangeMultiplexer::disposing( const EventObject& i_event ) throw (RuntimeException)
+ {
+ OSL_UNUSED( i_event );
+ }
+
+ //==================================================================================================================
+ //= UnoGridColumnFacade
+ //==================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
+ UnoGridColumnFacade::UnoGridColumnFacade( UnoControlTableModel const & i_owner, Reference< XGridColumn > const & i_gridColumn )
+ :m_pOwner( &i_owner )
+ ,m_nDataColumnIndex( -1 )
+ ,m_xGridColumn( i_gridColumn, UNO_QUERY_THROW )
+ ,m_pChangeMultiplexer( new ColumnChangeMultiplexer( *this ) )
+ {
+ m_xGridColumn->addGridColumnListener( m_pChangeMultiplexer.get() );
+ impl_updateDataColumnIndex_nothrow();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ UnoGridColumnFacade::~UnoGridColumnFacade()
+ {
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void UnoGridColumnFacade::dispose()
+ {
+ DBG_TESTSOLARMUTEX();
+ ENSURE_OR_RETURN_VOID( m_pOwner != NULL, "UnoGridColumnFacade::dispose: already disposed!" );
+
+ m_xGridColumn->removeGridColumnListener( m_pChangeMultiplexer.get() );
+ m_pChangeMultiplexer->dispose();
+ m_pChangeMultiplexer.clear();
+ m_xGridColumn.clear();
+ m_pOwner = NULL;
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void UnoGridColumnFacade::impl_updateDataColumnIndex_nothrow()
+ {
+ m_nDataColumnIndex = -1;
+ ENSURE_OR_RETURN_VOID( m_xGridColumn.is(), "UnoGridColumnFacade: already disposed!" );
+ try
+ {
+ m_nDataColumnIndex = m_xGridColumn->getDataColumnIndex();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void UnoGridColumnFacade::dataColumnIndexChanged()
+ {
+ DBG_TESTSOLARMUTEX();
+ impl_updateDataColumnIndex_nothrow();
+ if ( m_pOwner != NULL )
+ m_pOwner->notifyAllDataChanged();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void UnoGridColumnFacade::columnChanged( ColumnAttributeGroup const i_attributeGroup )
+ {
+ DBG_TESTSOLARMUTEX();
+ if ( m_pOwner != NULL )
+ m_pOwner->notifyColumnChange( m_pOwner->getColumnPos( *this ), i_attributeGroup );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ Any UnoGridColumnFacade::getID() const
+ {
+ Any aID;
+ ENSURE_OR_RETURN( m_xGridColumn.is(), "UnoGridColumnFacade: already disposed!", aID );
+ try
+ {
+ aID = m_xGridColumn->getIdentifier();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return aID;
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void UnoGridColumnFacade::setID( const Any& i_ID )
+ {
+ ENSURE_OR_RETURN_VOID( m_xGridColumn.is(), "UnoGridColumnFacade: already disposed!" );
+ try
+ {
+ m_xGridColumn->setIdentifier( i_ID );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ String UnoGridColumnFacade::getName() const
+ {
+ ::rtl::OUString sName;
+ ENSURE_OR_RETURN( m_xGridColumn.is(), "UnoGridColumnFacade: already disposed!", sName );
+ try
+ {
+ sName = m_xGridColumn->getTitle();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return sName;
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void UnoGridColumnFacade::setName( const String& _rName )
+ {
+ ENSURE_OR_RETURN_VOID( m_xGridColumn.is(), "UnoGridColumnFacade: already disposed!" );
+ try
+ {
+ m_xGridColumn->setTitle( _rName );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ String UnoGridColumnFacade::getHelpText() const
+ {
+ ::rtl::OUString sHelpText;
+ ENSURE_OR_RETURN( m_xGridColumn.is(), "UnoGridColumnFacade: already disposed!", sHelpText );
+ try
+ {
+ sHelpText = m_xGridColumn->getHelpText();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return sHelpText;
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void UnoGridColumnFacade::setHelpText( const String& i_helpText )
+ {
+ ENSURE_OR_RETURN_VOID( m_xGridColumn.is(), "UnoGridColumnFacade: already disposed!" );
+ try
+ {
+ m_xGridColumn->setHelpText( i_helpText );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ bool UnoGridColumnFacade::isResizable() const
+ {
+ ENSURE_OR_RETURN( m_xGridColumn.is(), "UnoGridColumnFacade: already disposed!", false );
+ return lcl_get( m_xGridColumn, &XGridColumn::getResizeable );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void UnoGridColumnFacade::setResizable( bool i_resizable )
+ {
+ ENSURE_OR_RETURN_VOID( m_xGridColumn.is(), "UnoGridColumnFacade: already disposed!" );
+ lcl_set( m_xGridColumn, &XGridColumn::setResizeable, sal_Bool( i_resizable ) );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ sal_Int32 UnoGridColumnFacade::getFlexibility() const
+ {
+ ENSURE_OR_RETURN( m_xGridColumn.is(), "UnoGridColumnFacade: already disposed!", 1 );
+ return lcl_get( m_xGridColumn, &XGridColumn::getFlexibility );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void UnoGridColumnFacade::setFlexibility( sal_Int32 const i_flexibility )
+ {
+ ENSURE_OR_RETURN_VOID( m_xGridColumn.is(), "UnoGridColumnFacade: already disposed!" );
+ lcl_set( m_xGridColumn, &XGridColumn::setFlexibility, i_flexibility );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ TableMetrics UnoGridColumnFacade::getWidth() const
+ {
+ ENSURE_OR_RETURN( m_xGridColumn.is(), "UnoGridColumnFacade: already disposed!", 0 );
+ return lcl_get( m_xGridColumn, &XGridColumn::getColumnWidth );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void UnoGridColumnFacade::setWidth( TableMetrics _nWidth )
+ {
+ ENSURE_OR_RETURN_VOID( m_xGridColumn.is(), "UnoGridColumnFacade: already disposed!" );
+ lcl_set( m_xGridColumn, &XGridColumn::setColumnWidth, _nWidth );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ TableMetrics UnoGridColumnFacade::getMinWidth() const
+ {
+ ENSURE_OR_RETURN( m_xGridColumn.is(), "UnoGridColumnFacade: already disposed!", 0 );
+ return lcl_get( m_xGridColumn, &XGridColumn::getMinWidth );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void UnoGridColumnFacade::setMinWidth( TableMetrics _nMinWidth )
+ {
+ ENSURE_OR_RETURN_VOID( m_xGridColumn.is(), "UnoGridColumnFacade: already disposed!" );
+ lcl_set( m_xGridColumn, &XGridColumn::setMinWidth, _nMinWidth );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ TableMetrics UnoGridColumnFacade::getMaxWidth() const
+ {
+ ENSURE_OR_RETURN( m_xGridColumn.is(), "UnoGridColumnFacade: already disposed!", 0 );
+ return lcl_get( m_xGridColumn, &XGridColumn::getMaxWidth );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void UnoGridColumnFacade::setMaxWidth( TableMetrics _nMaxWidth )
+ {
+ ENSURE_OR_RETURN_VOID( m_xGridColumn.is(), "UnoGridColumnFacade: already disposed!" );
+ lcl_set( m_xGridColumn, &XGridColumn::setMinWidth, _nMaxWidth );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ ::com::sun::star::style::HorizontalAlignment UnoGridColumnFacade::getHorizontalAlign()
+ {
+ ENSURE_OR_RETURN( m_xGridColumn.is(), "UnoGridColumnFacade: already disposed!", HorizontalAlignment_LEFT );
+ return lcl_get( m_xGridColumn, &XGridColumn::getHorizontalAlign );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void UnoGridColumnFacade::setHorizontalAlign( com::sun::star::style::HorizontalAlignment _align )
+ {
+ ENSURE_OR_RETURN_VOID( m_xGridColumn.is(), "UnoGridColumnFacade: already disposed!" );
+ lcl_set( m_xGridColumn, &XGridColumn::setHorizontalAlign, _align );
+ }
+
+// .....................................................................................................................
+} } // svt::table
+// .....................................................................................................................
diff --git a/svtools/source/uno/unogridcolumnfacade.hxx b/svtools/source/uno/unogridcolumnfacade.hxx
new file mode 100755
index 000000000000..7499621ba8af
--- /dev/null
+++ b/svtools/source/uno/unogridcolumnfacade.hxx
@@ -0,0 +1,114 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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_GRIDCOLUMNFACADE_HXX
+#define SVTOOLS_GRIDCOLUMNFACADE_HXX
+
+#include "svtools/table/tablemodel.hxx"
+#include "svtools/table/tablecontrol.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/awt/grid/XGridColumn.hpp>
+#include <com/sun/star/style/VerticalAlignment.hpp>
+#include <com/sun/star/style/HorizontalAlignment.hpp>
+/** === end UNO includes === **/
+
+#include <cppuhelper/implbase2.hxx>
+#include <rtl/ref.hxx>
+
+#include <boost/noncopyable.hpp>
+
+// .....................................................................................................................
+namespace svt { namespace table
+{
+// .....................................................................................................................
+
+ //==================================================================================================================
+ //= UnoGridColumnFacade
+ //==================================================================================================================
+ class ColumnChangeMultiplexer;
+ class UnoControlTableModel;
+ class UnoGridColumnFacade :public IColumnModel
+ ,public ::boost::noncopyable
+ {
+ public:
+ UnoGridColumnFacade(
+ UnoControlTableModel const & i_owner,
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > const & i_gridColumn
+ );
+ ~UnoGridColumnFacade();
+
+ // IColumnModel overridables
+ virtual ::com::sun::star::uno::Any
+ getID() const;
+ virtual void setID( const ::com::sun::star::uno::Any& i_ID );
+ virtual String getName() const;
+ virtual void setName( const String& _rName );
+ virtual String getHelpText() const;
+ virtual void setHelpText( const String& i_helpText );
+ virtual bool isResizable() const;
+ virtual void setResizable( bool _bResizable );
+ virtual sal_Int32 getFlexibility() const;
+ virtual void setFlexibility( sal_Int32 const i_flexibility );
+ 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 );
+ virtual ::com::sun::star::style::HorizontalAlignment getHorizontalAlign();
+ virtual void setHorizontalAlign(::com::sun::star::style::HorizontalAlignment _xAlign);
+
+ /** disposes the column wrapper
+
+ Note that the XGridColumn which is wrapped by the instance is <strong>not</strong> disposed, as we
+ do not own it.
+ */
+ void dispose();
+
+ sal_Int32
+ getDataColumnIndex() const { return m_nDataColumnIndex; }
+
+ // callbacks for the XGridColumnListener
+ void columnChanged( ColumnAttributeGroup const i_attributeGroup );
+ void dataColumnIndexChanged();
+
+ private:
+ void impl_updateDataColumnIndex_nothrow();
+
+ private:
+ UnoControlTableModel const * m_pOwner;
+ sal_Int32 m_nDataColumnIndex;
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > m_xGridColumn;
+ ::rtl::Reference< ColumnChangeMultiplexer > m_pChangeMultiplexer;
+ };
+
+// .....................................................................................................................
+} } // svt::table
+// .....................................................................................................................
+
+#endif // SVTOOLS_GRIDCOLUMNFACADE_HXX
diff --git a/svtools/source/uno/unoiface.cxx b/svtools/source/uno/unoiface.cxx
index a60a210e8fa7..18af2c696a8c 100644
--- a/svtools/source/uno/unoiface.cxx
+++ b/svtools/source/uno/unoiface.cxx
@@ -80,6 +80,7 @@ SAL_DLLPUBLIC_EXPORT Window* CreateWindow( VCLXWindow** ppNewComp, const ::com::
if ( pParent )
{
pWindow = new MultiLineEdit( pParent, nWinBits|WB_IGNORETAB);
+ static_cast< MultiLineEdit* >( pWindow )->DisableSelectionOnFocus();
*ppNewComp = new VCLXMultiLineEdit;
}
else