Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef _SVX_TABLECONTROLLER_HXX_
21 : #define _SVX_TABLECONTROLLER_HXX_
22 :
23 : #include <com/sun/star/util/XModifyListener.hpp>
24 : #include <com/sun/star/table/XTable.hpp>
25 : #include <rtl/ref.hxx>
26 :
27 : #include <svx/sdr/overlay/overlayobjectlist.hxx>
28 : #include <svx/selectioncontroller.hxx>
29 : #include <svx/svdotable.hxx>
30 : #include <svx/svdview.hxx>
31 : #include <tablemodel.hxx>
32 :
33 : class SdrObjEditView;
34 : class SdrObject;
35 : class SfxItemSet;
36 :
37 : namespace sdr { namespace table {
38 :
39 : class SVX_DLLPUBLIC SvxTableController: public sdr::SelectionController
40 : {
41 : public:
42 : SVX_DLLPRIVATE SvxTableController( SdrObjEditView* pView, const SdrObject* pObj );
43 : SVX_DLLPRIVATE virtual ~SvxTableController();
44 :
45 : // from sdr::SelectionController
46 : SVX_DLLPRIVATE virtual bool onKeyInput(const KeyEvent& rKEvt, Window* pWin);
47 : SVX_DLLPRIVATE virtual bool onMouseButtonDown(const MouseEvent& rMEvt, Window* pWin);
48 : SVX_DLLPRIVATE virtual bool onMouseButtonUp(const MouseEvent& rMEvt, Window* pWin);
49 : SVX_DLLPRIVATE virtual bool onMouseMove(const MouseEvent& rMEvt, Window* pWin);
50 :
51 : SVX_DLLPRIVATE virtual bool DeleteMarked();
52 :
53 : SVX_DLLPRIVATE virtual void onSelectionHasChanged();
54 :
55 : SVX_DLLPRIVATE virtual void GetState( SfxItemSet& rSet );
56 : SVX_DLLPRIVATE virtual void Execute( SfxRequest& rReq );
57 :
58 : SVX_DLLPRIVATE virtual bool GetStyleSheet( SfxStyleSheet* &rpStyleSheet ) const;
59 : SVX_DLLPRIVATE virtual bool SetStyleSheet( SfxStyleSheet* pStyleSheet, bool bDontRemoveHardAttr );
60 :
61 : SVX_DLLPRIVATE virtual bool TakeFormatPaintBrush( boost::shared_ptr< SfxItemSet >& rFormatSet );
62 : SVX_DLLPRIVATE virtual bool ApplyFormatPaintBrush( SfxItemSet& rFormatSet, bool bNoCharacterFormats, bool bNoParagraphFormats );
63 :
64 : // slots
65 : SVX_DLLPRIVATE void onInsert( sal_uInt16 nSId, const SfxItemSet* pArgs = 0 );
66 : SVX_DLLPRIVATE void onDelete( sal_uInt16 nSId );
67 : SVX_DLLPRIVATE void onSelect( sal_uInt16 nSId );
68 : SVX_DLLPRIVATE void onFormatTable( SfxRequest& rReq );
69 : SVX_DLLPRIVATE void MergeMarkedCells();
70 : SVX_DLLPRIVATE void SplitMarkedCells();
71 : SVX_DLLPRIVATE void DistributeColumns();
72 : SVX_DLLPRIVATE void DistributeRows();
73 : SVX_DLLPRIVATE void SetVertical( sal_uInt16 nSId );
74 :
75 : SVX_DLLPRIVATE static rtl::Reference< sdr::SelectionController > create( SdrObjEditView* pView, const SdrObject* pObj, const rtl::Reference< sdr::SelectionController >& xRefController );
76 :
77 : SVX_DLLPRIVATE void MergeAttrFromSelectedCells(SfxItemSet& rAttr, bool bOnlyHardAttr) const;
78 : SVX_DLLPRIVATE void SetAttrToSelectedCells(const SfxItemSet& rAttr, bool bReplaceAll);
79 :
80 : SVX_DLLPRIVATE virtual bool GetAttributes(SfxItemSet& rTargetSet, bool bOnlyHardAttr) const;
81 : SVX_DLLPRIVATE virtual bool SetAttributes(const SfxItemSet& rSet, bool bReplaceAll);
82 :
83 : SVX_DLLPRIVATE virtual bool GetMarkedObjModel( SdrPage* pNewPage );
84 : SVX_DLLPRIVATE virtual bool PasteObjModel( const SdrModel& rModel );
85 :
86 0 : SVX_DLLPRIVATE bool hasSelectedCells() const { return mbCellSelectionMode || mpView->IsTextEdit(); }
87 :
88 : void getSelectedCells( CellPos& rFirstPos, CellPos& rLastPos );
89 : void setSelectedCells( const CellPos& rFirstPos, const CellPos& rLastPos );
90 : void clearSelection();
91 : void selectAll();
92 :
93 : SVX_DLLPRIVATE void onTableModified();
94 :
95 : private:
96 : SvxTableController(SvxTableController &); // not defined
97 : void operator =(SvxTableController &); // not defined
98 :
99 : // internals
100 : SVX_DLLPRIVATE void ApplyBorderAttr( const SfxItemSet& rAttr );
101 : SVX_DLLPRIVATE void UpdateTableShape();
102 :
103 : SVX_DLLPRIVATE void SetTableStyle( const SfxItemSet* pArgs );
104 : SVX_DLLPRIVATE void SetTableStyleSettings( const SfxItemSet* pArgs );
105 :
106 : SVX_DLLPRIVATE bool PasteObject( SdrTableObj* pPasteTableObj );
107 :
108 : SVX_DLLPRIVATE bool checkTableObject();
109 : SVX_DLLPRIVATE bool updateTableObject();
110 : SVX_DLLPRIVATE const CellPos& getSelectionStart();
111 : SVX_DLLPRIVATE void setSelectionStart( const CellPos& rPos );
112 : SVX_DLLPRIVATE const CellPos& getSelectionEnd();
113 : SVX_DLLPRIVATE void checkCell( CellPos& rPos );
114 :
115 : SVX_DLLPRIVATE void MergeRange( sal_Int32 nFirstCol, sal_Int32 nFirstRow, sal_Int32 nLastCol, sal_Int32 nLastRow );
116 :
117 : SVX_DLLPRIVATE void EditCell( const CellPos& rPos, ::Window* pWindow, const ::com::sun::star::awt::MouseEvent* pMouseEvent = 0, sal_uInt16 nAction = 0 );
118 : SVX_DLLPRIVATE bool StopTextEdit();
119 :
120 : SVX_DLLPRIVATE sal_uInt16 getKeyboardAction( const KeyEvent& rKEvt, Window* pWindow );
121 : SVX_DLLPRIVATE bool executeAction( sal_uInt16 nAction, bool bSelect, Window* pWindow );
122 : SVX_DLLPRIVATE void gotoCell( const CellPos& rCell, bool bSelect, Window* pWindow, sal_uInt16 nAction = 0 );
123 :
124 : SVX_DLLPRIVATE void StartSelection( const CellPos& rPos );
125 : SVX_DLLPRIVATE void UpdateSelection( const CellPos& rPos );
126 : SVX_DLLPRIVATE void RemoveSelection();
127 : SVX_DLLPRIVATE void updateSelectionOverlay();
128 : SVX_DLLPRIVATE void destroySelectionOverlay();
129 :
130 : SVX_DLLPRIVATE void findMergeOrigin( CellPos& rPos );
131 :
132 : DECL_LINK( UpdateHdl, void * );
133 :
134 : TableModelRef mxTable;
135 :
136 : CellPos maCursorFirstPos;
137 : CellPos maCursorLastPos;
138 : bool mbCellSelectionMode;
139 : CellPos maMouseDownPos;
140 : bool mbLeftButtonDown;
141 : ::sdr::overlay::OverlayObjectList* mpSelectionOverlay;
142 :
143 : SdrView* mpView;
144 : SdrObjectWeakRef mxTableObj;
145 : SdrModel* mpModel;
146 :
147 : ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener > mxModifyListener;
148 :
149 : sal_uLong mnUpdateEvent;
150 : };
151 :
152 : } }
153 :
154 : #endif // _SVX_TABLECONTROLLER_HXX_
155 :
156 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|