Update ooo320-m1
[ooovba.git] / svx / source / table / tablecontroller.hxx
blobb4eecf09029d1c5d7255ce8caa317e78ed2c51a7
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: tablecontroller.hxx,v $
10 * $Revision: 1.3 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _SVX_TABLECONTROLLER_HXX_
32 #define _SVX_TABLECONTROLLER_HXX_
34 #include <com/sun/star/util/XModifyListener.hpp>
35 #include <com/sun/star/table/XTable.hpp>
36 #include <rtl/ref.hxx>
38 #include <svx/sdr/overlay/overlayobjectlist.hxx>
39 #include <svx/selectioncontroller.hxx>
40 #include <svx/svdotable.hxx>
41 #include <svx/svdview.hxx>
42 #include <tablemodel.hxx>
44 class SdrObjEditView;
45 class SdrObject;
46 class SfxItemSet;
48 namespace sdr { namespace table {
50 const sal_Int16 SELTYPE_NONE = 0;
51 const sal_Int16 SELTYPE_MOUSE = 1;
52 const sal_Int16 SELTYPE_KEYS = 2;
54 class SVX_DLLPUBLIC SvxTableController: public sdr::SelectionController
56 public:
57 SVX_DLLPRIVATE SvxTableController( SdrObjEditView* pView, const SdrObject* pObj );
58 SVX_DLLPRIVATE virtual ~SvxTableController();
60 SVX_DLLPRIVATE virtual bool onKeyInput(const KeyEvent& rKEvt, Window* pWin);
61 SVX_DLLPRIVATE virtual bool onMouseButtonDown(const MouseEvent& rMEvt, Window* pWin);
62 SVX_DLLPRIVATE virtual bool onMouseButtonUp(const MouseEvent& rMEvt, Window* pWin);
63 SVX_DLLPRIVATE virtual bool onMouseMove(const MouseEvent& rMEvt, Window* pWin);
65 SVX_DLLPRIVATE virtual bool DeleteMarked();
67 SVX_DLLPRIVATE virtual void onSelectionHasChanged();
69 SVX_DLLPRIVATE virtual void GetState( SfxItemSet& rSet );
70 SVX_DLLPRIVATE virtual void Execute( SfxRequest& rReq );
72 SVX_DLLPRIVATE virtual bool GetStyleSheet( SfxStyleSheet* &rpStyleSheet ) const;
73 SVX_DLLPRIVATE virtual bool SetStyleSheet( SfxStyleSheet* pStyleSheet, bool bDontRemoveHardAttr );
75 // slots
76 SVX_DLLPRIVATE void onInsert( sal_uInt16 nSId, const SfxItemSet* pArgs = 0 );
77 SVX_DLLPRIVATE void onDelete( sal_uInt16 nSId );
78 SVX_DLLPRIVATE void onSelect( sal_uInt16 nSId );
79 SVX_DLLPRIVATE void onFormatTable( SfxRequest& rReq );
80 SVX_DLLPRIVATE void MergeMarkedCells();
81 SVX_DLLPRIVATE void SplitMarkedCells();
82 SVX_DLLPRIVATE void DistributeColumns();
83 SVX_DLLPRIVATE void DistributeRows();
84 SVX_DLLPRIVATE void SetVertical( sal_uInt16 nSId );
86 SVX_DLLPRIVATE static rtl::Reference< sdr::SelectionController > create( SdrObjEditView* pView, const SdrObject* pObj, const rtl::Reference< sdr::SelectionController >& xRefController );
88 SVX_DLLPRIVATE void MergeAttrFromSelectedCells(SfxItemSet& rAttr, bool bOnlyHardAttr) const;
89 SVX_DLLPRIVATE void SetAttrToSelectedCells(const SfxItemSet& rAttr, bool bReplaceAll);
91 SVX_DLLPRIVATE virtual bool GetAttributes(SfxItemSet& rTargetSet, bool bOnlyHardAttr) const;
92 SVX_DLLPRIVATE virtual bool SetAttributes(const SfxItemSet& rSet, bool bReplaceAll);
94 SVX_DLLPRIVATE virtual bool GetMarkedObjModel( SdrPage* pNewPage );
95 SVX_DLLPRIVATE virtual bool PasteObjModel( const SdrModel& rModel );
97 SVX_DLLPRIVATE bool hasSelectedCells() const { return mbCellSelectionMode || mpView->IsTextEdit(); }
99 void getSelectedCells( CellPos& rFirstPos, CellPos& rLastPos );
100 void setSelectedCells( const CellPos& rFirstPos, const CellPos& rLastPos );
101 void clearSelection();
102 void selectAll();
104 SVX_DLLPRIVATE void onTableModified();
106 private:
107 SvxTableController(SvxTableController &); // not defined
108 void operator =(SvxTableController &); // not defined
110 // internals
111 SVX_DLLPRIVATE void ApplyBorderAttr( const SfxItemSet& rAttr );
112 SVX_DLLPRIVATE void UpdateTableShape();
114 SVX_DLLPRIVATE void SetTableStyle( const SfxItemSet* pArgs );
115 SVX_DLLPRIVATE void SetTableStyleSettings( const SfxItemSet* pArgs );
117 SVX_DLLPRIVATE bool PasteObject( SdrTableObj* pPasteTableObj );
119 SVX_DLLPRIVATE bool checkTableObject();
120 SVX_DLLPRIVATE bool updateTableObject();
121 SVX_DLLPRIVATE const CellPos& getSelectionStart();
122 SVX_DLLPRIVATE void setSelectionStart( const CellPos& rPos );
123 SVX_DLLPRIVATE const CellPos& getSelectionEnd();
124 SVX_DLLPRIVATE ::com::sun::star::uno::Reference< ::com::sun::star::table::XCellCursor > getSelectionCursor();
125 SVX_DLLPRIVATE void checkCell( CellPos& rPos );
127 SVX_DLLPRIVATE void MergeRange( sal_Int32 nFirstCol, sal_Int32 nFirstRow, sal_Int32 nLastCol, sal_Int32 nLastRow );
129 SVX_DLLPRIVATE void EditCell( const CellPos& rPos, ::Window* pWindow, const ::com::sun::star::awt::MouseEvent* pMouseEvent = 0, sal_uInt16 nAction = 0 );
130 SVX_DLLPRIVATE bool StopTextEdit();
132 SVX_DLLPRIVATE void DeleteTable();
134 SVX_DLLPRIVATE sal_uInt16 getKeyboardAction( const KeyEvent& rKEvt, Window* pWindow );
135 SVX_DLLPRIVATE bool executeAction( sal_uInt16 nAction, bool bSelect, Window* pWindow );
136 SVX_DLLPRIVATE void gotoCell( const CellPos& rCell, bool bSelect, Window* pWindow, sal_uInt16 nAction = 0 );
138 SVX_DLLPRIVATE void StartSelection( const CellPos& rPos );
139 SVX_DLLPRIVATE void UpdateSelection( const CellPos& rPos );
140 SVX_DLLPRIVATE void RemoveSelection();
141 SVX_DLLPRIVATE void updateSelectionOverlay();
142 SVX_DLLPRIVATE void destroySelectionOverlay();
144 SVX_DLLPRIVATE void findMergeOrigin( CellPos& rPos );
146 DECL_LINK( UpdateHdl, void * );
148 TableModelRef mxTable;
150 CellPos maCursorFirstPos;
151 CellPos maCursorLastPos;
152 bool mbCellSelectionMode;
153 CellPos maMouseDownPos;
154 bool mbLeftButtonDown;
155 ::sdr::overlay::OverlayObjectList* mpSelectionOverlay;
157 SdrView* mpView;
158 SdrObjectWeakRef mxTableObj;
159 SdrModel* mpModel;
161 ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener > mxModifyListener;
163 ULONG mnUpdateEvent;
168 #endif // _SVX_TABLECONTROLLER_HXX_