LibreOffice Module svx (master)  1
tablecontroller.hxx
Go to the documentation of this file.
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 INCLUDED_SVX_SDR_TABLE_TABLECONTROLLER_HXX
21 #define INCLUDED_SVX_SDR_TABLE_TABLECONTROLLER_HXX
22 
23 #include <com/sun/star/util/XModifyListener.hpp>
24 #include <rtl/ref.hxx>
25 
28 #include <svx/svdotable.hxx>
29 #include <svx/svdview.hxx>
30 #include <memory>
31 
32 class SdrView;
33 class SdrObject;
34 class SfxItemSet;
35 class SvxBoxInfoItem;
36 class SvxBoxItem;
37 
38 namespace sdr::table {
39 
40 class TableModel;
41 
43 {
44 public:
46  SdrView& rView,
47  const SdrTableObj& rObj);
48  SVX_DLLPRIVATE virtual ~SvxTableController() override;
49 
50  // from sdr::SelectionController
51  SVX_DLLPRIVATE virtual bool onKeyInput(const KeyEvent& rKEvt, vcl::Window* pWin) override;
52  SVX_DLLPRIVATE virtual bool onMouseButtonDown(const MouseEvent& rMEvt, vcl::Window* pWin) override;
53  SVX_DLLPRIVATE virtual bool onMouseButtonUp(const MouseEvent& rMEvt, vcl::Window* pWin) override;
54  SVX_DLLPRIVATE virtual bool onMouseMove(const MouseEvent& rMEvt, vcl::Window* pWin) override;
55 
56  SVX_DLLPRIVATE bool HasMarked() const;
57  SVX_DLLPRIVATE virtual bool DeleteMarked() override;
58 
59  SVX_DLLPRIVATE virtual void onSelectionHasChanged() override;
60 
61  SVX_DLLPRIVATE virtual void GetState( SfxItemSet& rSet ) override;
62  virtual void Execute( SfxRequest& rReq ) override;
63 
64  SVX_DLLPRIVATE virtual bool GetStyleSheet( SfxStyleSheet* &rpStyleSheet ) const override;
65  SVX_DLLPRIVATE virtual bool SetStyleSheet( SfxStyleSheet* pStyleSheet, bool bDontRemoveHardAttr ) override;
66 
67  SVX_DLLPRIVATE virtual bool ApplyFormatPaintBrush( SfxItemSet& rFormatSet, bool bNoCharacterFormats, bool bNoParagraphFormats ) override;
68 
69  // slots
70  SVX_DLLPRIVATE void onInsert( sal_uInt16 nSId, const SfxItemSet* pArgs = nullptr );
71  SVX_DLLPRIVATE void onDelete( sal_uInt16 nSId );
72  SVX_DLLPRIVATE void onSelect( sal_uInt16 nSId );
73  SVX_DLLPRIVATE void onFormatTable(const SfxRequest& rReq);
74  SVX_DLLPRIVATE void MergeMarkedCells();
75  SVX_DLLPRIVATE void SplitMarkedCells(const SfxRequest& rReq);
76  SVX_DLLPRIVATE void DistributeColumns( const bool bOptimize, const bool bMinimize );
77  SVX_DLLPRIVATE void DistributeRows( const bool bOptimize, const bool bMinimize );
78  SVX_DLLPRIVATE void SetVertical( sal_uInt16 nSId );
79  SVX_DLLPRIVATE void changeTableEdge(const SfxRequest& rReq);
80 
82  SdrView& rView,
83  const SdrTableObj& rObj,
84  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  void SetAttrToSelectedShape(const SfxItemSet& rAttr);
94  SVX_DLLPRIVATE void FillCommonBorderAttrFromSelectedCells(SvxBoxItem& rBox, SvxBoxInfoItem& rBoxInfo) const;
95 
96  SVX_DLLPRIVATE virtual bool GetAttributes(SfxItemSet& rTargetSet, bool bOnlyHardAttr) const override;
97  SVX_DLLPRIVATE virtual bool SetAttributes(const SfxItemSet& rSet, bool bReplaceAll) override;
98 
99  SVX_DLLPRIVATE virtual SdrObject* GetMarkedSdrObjClone( SdrModel& rTargetModel ) override;
100  SVX_DLLPRIVATE virtual bool PasteObjModel( const SdrModel& rModel ) override;
101 
102  SVX_DLLPRIVATE virtual bool hasSelectedCells() const override { return mbCellSelectionMode || mrView.IsTextEdit(); }
104  SVX_DLLPRIVATE virtual bool setCursorLogicPosition(const Point& rPosition, bool bPoint) override;
105 
107  void getSelectedCells( CellPos& rFirstPos, CellPos& rLastPos ) override;
108  void setSelectedCells( const CellPos& rFirstPos, const CellPos& rLastPos );
109 
110  virtual bool ChangeFontSize(bool bGrow, const FontList* pFontList) override;
111 
112  void clearSelection();
113  void selectAll();
114 
115  SVX_DLLPRIVATE void onTableModified();
116 
117  bool selectRow( sal_Int32 row );
118  bool selectColumn( sal_Int32 column );
119  bool deselectRow( sal_Int32 row );
120  bool deselectColumn( sal_Int32 column );
121  bool isRowSelected( sal_Int32 nRow );
122  bool isColumnSelected( sal_Int32 nColumn );
123  bool isRowHeader();
124  bool isColumnHeader();
125  sdr::table::SdrTableObj* GetTableObj() { return mxTableObj.get(); }
126 private:
127  SvxTableController(SvxTableController const &) = delete;
128  SvxTableController& operator =(SvxTableController const &) = delete;
129 
130  // internals
131  enum class TblAction
132  {
133  NONE,
134  GotoFirstCell, GotoFirstColumn, GotoFirstRow,
135  GotoLeftCell, GotoUpCell, GotoRightCell, GotoDownCell,
136  GotoLastCell, GotoLastColumn, GotoLastRow,
137  EditCell, StopTextEdit,
138  RemoveSelection,
139  HandledByView, Tab
140  };
141  SVX_DLLPRIVATE void ApplyBorderAttr( const SfxItemSet& rAttr );
142  SVX_DLLPRIVATE void UpdateTableShape();
143 
144  SVX_DLLPRIVATE void SetTableStyle( const SfxItemSet* pArgs );
145  SVX_DLLPRIVATE void SetTableStyleSettings( const SfxItemSet* pArgs );
146 
147  SVX_DLLPRIVATE bool PasteObject( SdrTableObj const * pPasteTableObj );
148 
149  SVX_DLLPRIVATE bool checkTableObject();
150  SVX_DLLPRIVATE const CellPos& getSelectionStart();
151  SVX_DLLPRIVATE void setSelectionStart( const CellPos& rPos );
152  SVX_DLLPRIVATE const CellPos& getSelectionEnd();
153  SVX_DLLPRIVATE void checkCell( CellPos& rPos );
154 
155  SVX_DLLPRIVATE void MergeRange( sal_Int32 nFirstCol, sal_Int32 nFirstRow, sal_Int32 nLastCol, sal_Int32 nLastRow );
156 
157  SVX_DLLPRIVATE void EditCell(const CellPos& rPos, vcl::Window* pWindow, TblAction nAction);
158  SVX_DLLPRIVATE void StopTextEdit();
159 
160  SVX_DLLPRIVATE TblAction getKeyboardAction(const KeyEvent& rKEvt);
161  SVX_DLLPRIVATE bool executeAction(TblAction nAction, bool bSelect, vcl::Window* pWindow);
162  SVX_DLLPRIVATE void gotoCell(const CellPos& rCell, bool bSelect, vcl::Window* pWindow, TblAction nAction = TblAction::NONE);
163 
164  SVX_DLLPRIVATE void StartSelection( const CellPos& rPos );
165  SVX_DLLPRIVATE void UpdateSelection( const CellPos& rPos );
166  SVX_DLLPRIVATE void RemoveSelection();
167  SVX_DLLPRIVATE void updateSelectionOverlay();
168  SVX_DLLPRIVATE void destroySelectionOverlay();
169 
170  SVX_DLLPRIVATE void findMergeOrigin( CellPos& rPos );
171 
172  DECL_LINK( UpdateHdl, void *, void );
173 
174  //TableModelRef mxTable;
176 
183  std::unique_ptr<sdr::overlay::OverlayObjectList> mpSelectionOverlay;
186  css::uno::Reference< css::util::XModifyListener > mxModifyListener;
188 };
189 
191  SdrView& rView,
192  const SdrTableObj& rObj,
193  const rtl::Reference< sdr::SelectionController >& xRefController );
194 
195 }
196 
197 #endif // INCLUDED_SVX_SDR_TABLE_TABLECONTROLLER_HXX
198 
199 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool findMergeOrigin(const TableModelRef &xTable, sal_Int32 nMergedX, sal_Int32 nMergedY, sal_Int32 &rOriginX, sal_Int32 &rOriginY)
returns true if the cell(nMergedX,nMergedY) is merged with other cells.
css::uno::Reference< css::util::XModifyListener > mxModifyListener
rtl::Reference< sdr::SelectionController > CreateTableController(SdrView &rView, const SdrTableObj &rObj, const rtl::Reference< sdr::SelectionController > &xRefController)
virtual SVX_DLLPRIVATE bool hasSelectedCells() const override
This is a table object, and one or more of its cells are selected.
tools::WeakReference< SdrTableObj > mxTableObj
sdr::table::SdrTableObj * GetTableObj()
Reference< deployment::XPackageRegistry > create(Reference< deployment::XPackageRegistry > const &xRootRegistry, OUString const &context, OUString const &cachePath, Reference< XComponentContext > const &xComponentContext)
rtl::Reference< TableModel > mxTable
std::unique_ptr< sdr::overlay::OverlayObjectList > mpSelectionOverlay
Abstract DrawObject.
Definition: svdobj.hxx:260
SlideSorterView & mrView
#define SVXCORE_DLLPUBLIC
Definition: svxdllapi.h:35
#define SVX_DLLPRIVATE
Definition: svxdllapi.h:30