Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
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.
15 : : *
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).
21 : : *
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.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _SVX_TABLECONTROLLER_HXX_
30 : : #define _SVX_TABLECONTROLLER_HXX_
31 : :
32 : : #include <com/sun/star/util/XModifyListener.hpp>
33 : : #include <com/sun/star/table/XTable.hpp>
34 : : #include <rtl/ref.hxx>
35 : :
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>
41 : :
42 : : class SdrObjEditView;
43 : : class SdrObject;
44 : : class SfxItemSet;
45 : :
46 : : namespace sdr { namespace table {
47 : :
48 : : class SVX_DLLPUBLIC SvxTableController: public sdr::SelectionController
49 : : {
50 : : public:
51 : : SVX_DLLPRIVATE SvxTableController( SdrObjEditView* pView, const SdrObject* pObj );
52 : : SVX_DLLPRIVATE virtual ~SvxTableController();
53 : :
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);
59 : :
60 : : SVX_DLLPRIVATE virtual bool DeleteMarked();
61 : :
62 : : SVX_DLLPRIVATE virtual void onSelectionHasChanged();
63 : :
64 : : SVX_DLLPRIVATE virtual void GetState( SfxItemSet& rSet );
65 : : SVX_DLLPRIVATE virtual void Execute( SfxRequest& rReq );
66 : :
67 : : SVX_DLLPRIVATE virtual bool GetStyleSheet( SfxStyleSheet* &rpStyleSheet ) const;
68 : : SVX_DLLPRIVATE virtual bool SetStyleSheet( SfxStyleSheet* pStyleSheet, bool bDontRemoveHardAttr );
69 : :
70 : : SVX_DLLPRIVATE virtual bool TakeFormatPaintBrush( boost::shared_ptr< SfxItemSet >& rFormatSet );
71 : : SVX_DLLPRIVATE virtual bool ApplyFormatPaintBrush( SfxItemSet& rFormatSet, bool bNoCharacterFormats, bool bNoParagraphFormats );
72 : :
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 );
83 : :
84 : : SVX_DLLPRIVATE static rtl::Reference< sdr::SelectionController > create( SdrObjEditView* pView, const SdrObject* pObj, const rtl::Reference< sdr::SelectionController >& xRefController );
85 : :
86 : : SVX_DLLPRIVATE void MergeAttrFromSelectedCells(SfxItemSet& rAttr, bool bOnlyHardAttr) const;
87 : : SVX_DLLPRIVATE void SetAttrToSelectedCells(const SfxItemSet& rAttr, bool bReplaceAll);
88 : :
89 : : SVX_DLLPRIVATE virtual bool GetAttributes(SfxItemSet& rTargetSet, bool bOnlyHardAttr) const;
90 : : SVX_DLLPRIVATE virtual bool SetAttributes(const SfxItemSet& rSet, bool bReplaceAll);
91 : :
92 : : SVX_DLLPRIVATE virtual bool GetMarkedObjModel( SdrPage* pNewPage );
93 : : SVX_DLLPRIVATE virtual bool PasteObjModel( const SdrModel& rModel );
94 : :
95 [ # # ][ # # ]: 0 : SVX_DLLPRIVATE bool hasSelectedCells() const { return mbCellSelectionMode || mpView->IsTextEdit(); }
96 : :
97 : : void getSelectedCells( CellPos& rFirstPos, CellPos& rLastPos );
98 : : void setSelectedCells( const CellPos& rFirstPos, const CellPos& rLastPos );
99 : : void clearSelection();
100 : : void selectAll();
101 : :
102 : : SVX_DLLPRIVATE void onTableModified();
103 : :
104 : : private:
105 : : SvxTableController(SvxTableController &); // not defined
106 : : void operator =(SvxTableController &); // not defined
107 : :
108 : : // internals
109 : : SVX_DLLPRIVATE void ApplyBorderAttr( const SfxItemSet& rAttr );
110 : : SVX_DLLPRIVATE void UpdateTableShape();
111 : :
112 : : SVX_DLLPRIVATE void SetTableStyle( const SfxItemSet* pArgs );
113 : : SVX_DLLPRIVATE void SetTableStyleSettings( const SfxItemSet* pArgs );
114 : :
115 : : SVX_DLLPRIVATE bool PasteObject( SdrTableObj* pPasteTableObj );
116 : :
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 );
123 : :
124 : : SVX_DLLPRIVATE void MergeRange( sal_Int32 nFirstCol, sal_Int32 nFirstRow, sal_Int32 nLastCol, sal_Int32 nLastRow );
125 : :
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();
128 : :
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 );
132 : :
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();
138 : :
139 : : SVX_DLLPRIVATE void findMergeOrigin( CellPos& rPos );
140 : :
141 : : DECL_LINK( UpdateHdl, void * );
142 : :
143 : : TableModelRef mxTable;
144 : :
145 : : CellPos maCursorFirstPos;
146 : : CellPos maCursorLastPos;
147 : : bool mbCellSelectionMode;
148 : : CellPos maMouseDownPos;
149 : : bool mbLeftButtonDown;
150 : : ::sdr::overlay::OverlayObjectList* mpSelectionOverlay;
151 : :
152 : : SdrView* mpView;
153 : : SdrObjectWeakRef mxTableObj;
154 : : SdrModel* mpModel;
155 : :
156 : : ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener > mxModifyListener;
157 : :
158 : : sal_uLong mnUpdateEvent;
159 : : };
160 : :
161 : : } }
162 : :
163 : : #endif // _SVX_TABLECONTROLLER_HXX_
164 : :
165 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|