Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / svx / source / table / tablecontroller.hxx
blobea06f17bd4a73cb2d5dc16ec9357c2351cc2a3e9
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #ifndef _SVX_TABLECONTROLLER_HXX_
30 #define _SVX_TABLECONTROLLER_HXX_
32 #include <com/sun/star/util/XModifyListener.hpp>
33 #include <com/sun/star/table/XTable.hpp>
34 #include <rtl/ref.hxx>
36 #include <svx/sdr/overlay/overlayobjectlist.hxx>
37 #include <svx/selectioncontroller.hxx>
38 #include <svx/svdotable.hxx>
39 #include <svx/svdview.hxx>
40 #include <tablemodel.hxx>
42 class SdrObjEditView;
43 class SdrObject;
44 class SfxItemSet;
46 namespace sdr { namespace table {
48 class SVX_DLLPUBLIC SvxTableController: public sdr::SelectionController
50 public:
51 SVX_DLLPRIVATE SvxTableController( SdrObjEditView* pView, const SdrObject* pObj );
52 SVX_DLLPRIVATE virtual ~SvxTableController();
54 // from sdr::SelectionController
55 SVX_DLLPRIVATE virtual bool onKeyInput(const KeyEvent& rKEvt, Window* pWin);
56 SVX_DLLPRIVATE virtual bool onMouseButtonDown(const MouseEvent& rMEvt, Window* pWin);
57 SVX_DLLPRIVATE virtual bool onMouseButtonUp(const MouseEvent& rMEvt, Window* pWin);
58 SVX_DLLPRIVATE virtual bool onMouseMove(const MouseEvent& rMEvt, Window* pWin);
60 SVX_DLLPRIVATE virtual bool DeleteMarked();
62 SVX_DLLPRIVATE virtual void onSelectionHasChanged();
64 SVX_DLLPRIVATE virtual void GetState( SfxItemSet& rSet );
65 SVX_DLLPRIVATE virtual void Execute( SfxRequest& rReq );
67 SVX_DLLPRIVATE virtual bool GetStyleSheet( SfxStyleSheet* &rpStyleSheet ) const;
68 SVX_DLLPRIVATE virtual bool SetStyleSheet( SfxStyleSheet* pStyleSheet, bool bDontRemoveHardAttr );
70 SVX_DLLPRIVATE virtual bool TakeFormatPaintBrush( boost::shared_ptr< SfxItemSet >& rFormatSet );
71 SVX_DLLPRIVATE virtual bool ApplyFormatPaintBrush( SfxItemSet& rFormatSet, bool bNoCharacterFormats, bool bNoParagraphFormats );
73 // slots
74 SVX_DLLPRIVATE void onInsert( sal_uInt16 nSId, const SfxItemSet* pArgs = 0 );
75 SVX_DLLPRIVATE void onDelete( sal_uInt16 nSId );
76 SVX_DLLPRIVATE void onSelect( sal_uInt16 nSId );
77 SVX_DLLPRIVATE void onFormatTable( SfxRequest& rReq );
78 SVX_DLLPRIVATE void MergeMarkedCells();
79 SVX_DLLPRIVATE void SplitMarkedCells();
80 SVX_DLLPRIVATE void DistributeColumns();
81 SVX_DLLPRIVATE void DistributeRows();
82 SVX_DLLPRIVATE void SetVertical( sal_uInt16 nSId );
84 SVX_DLLPRIVATE static rtl::Reference< sdr::SelectionController > create( SdrObjEditView* pView, const SdrObject* pObj, const rtl::Reference< sdr::SelectionController >& xRefController );
86 SVX_DLLPRIVATE void MergeAttrFromSelectedCells(SfxItemSet& rAttr, bool bOnlyHardAttr) const;
87 SVX_DLLPRIVATE void SetAttrToSelectedCells(const SfxItemSet& rAttr, bool bReplaceAll);
89 SVX_DLLPRIVATE virtual bool GetAttributes(SfxItemSet& rTargetSet, bool bOnlyHardAttr) const;
90 SVX_DLLPRIVATE virtual bool SetAttributes(const SfxItemSet& rSet, bool bReplaceAll);
92 SVX_DLLPRIVATE virtual bool GetMarkedObjModel( SdrPage* pNewPage );
93 SVX_DLLPRIVATE virtual bool PasteObjModel( const SdrModel& rModel );
95 SVX_DLLPRIVATE bool hasSelectedCells() const { return mbCellSelectionMode || mpView->IsTextEdit(); }
97 void getSelectedCells( CellPos& rFirstPos, CellPos& rLastPos );
98 void setSelectedCells( const CellPos& rFirstPos, const CellPos& rLastPos );
99 void clearSelection();
100 void selectAll();
102 SVX_DLLPRIVATE void onTableModified();
104 private:
105 SvxTableController(SvxTableController &); // not defined
106 void operator =(SvxTableController &); // not defined
108 // internals
109 SVX_DLLPRIVATE void ApplyBorderAttr( const SfxItemSet& rAttr );
110 SVX_DLLPRIVATE void UpdateTableShape();
112 SVX_DLLPRIVATE void SetTableStyle( const SfxItemSet* pArgs );
113 SVX_DLLPRIVATE void SetTableStyleSettings( const SfxItemSet* pArgs );
115 SVX_DLLPRIVATE bool PasteObject( SdrTableObj* pPasteTableObj );
117 SVX_DLLPRIVATE bool checkTableObject();
118 SVX_DLLPRIVATE bool updateTableObject();
119 SVX_DLLPRIVATE const CellPos& getSelectionStart();
120 SVX_DLLPRIVATE void setSelectionStart( const CellPos& rPos );
121 SVX_DLLPRIVATE const CellPos& getSelectionEnd();
122 SVX_DLLPRIVATE void checkCell( CellPos& rPos );
124 SVX_DLLPRIVATE void MergeRange( sal_Int32 nFirstCol, sal_Int32 nFirstRow, sal_Int32 nLastCol, sal_Int32 nLastRow );
126 SVX_DLLPRIVATE void EditCell( const CellPos& rPos, ::Window* pWindow, const ::com::sun::star::awt::MouseEvent* pMouseEvent = 0, sal_uInt16 nAction = 0 );
127 SVX_DLLPRIVATE bool StopTextEdit();
129 SVX_DLLPRIVATE sal_uInt16 getKeyboardAction( const KeyEvent& rKEvt, Window* pWindow );
130 SVX_DLLPRIVATE bool executeAction( sal_uInt16 nAction, bool bSelect, Window* pWindow );
131 SVX_DLLPRIVATE void gotoCell( const CellPos& rCell, bool bSelect, Window* pWindow, sal_uInt16 nAction = 0 );
133 SVX_DLLPRIVATE void StartSelection( const CellPos& rPos );
134 SVX_DLLPRIVATE void UpdateSelection( const CellPos& rPos );
135 SVX_DLLPRIVATE void RemoveSelection();
136 SVX_DLLPRIVATE void updateSelectionOverlay();
137 SVX_DLLPRIVATE void destroySelectionOverlay();
139 SVX_DLLPRIVATE void findMergeOrigin( CellPos& rPos );
141 DECL_LINK( UpdateHdl, void * );
143 TableModelRef mxTable;
145 CellPos maCursorFirstPos;
146 CellPos maCursorLastPos;
147 bool mbCellSelectionMode;
148 CellPos maMouseDownPos;
149 bool mbLeftButtonDown;
150 ::sdr::overlay::OverlayObjectList* mpSelectionOverlay;
152 SdrView* mpView;
153 SdrObjectWeakRef mxTableObj;
154 SdrModel* mpModel;
156 ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener > mxModifyListener;
158 sal_uLong mnUpdateEvent;
163 #endif // _SVX_TABLECONTROLLER_HXX_
165 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */