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 <optional>
31#include <unotools/weakref.hxx>
32#include <memory>
33
34struct ImplSVEvent;
35class SdrView;
36class SdrObject;
37class SfxItemSet;
38class SvxBoxInfoItem;
39class SvxBoxItem;
40
41namespace sdr::table {
42
43class TableModel;
44
46{
47public:
49 SdrView& rView,
50 const SdrTableObj& rObj);
51 SVX_DLLPRIVATE virtual ~SvxTableController() override;
52
53 // from sdr::SelectionController
54 SVX_DLLPRIVATE virtual bool onKeyInput(const KeyEvent& rKEvt, vcl::Window* pWin) override;
55 SVX_DLLPRIVATE virtual bool onMouseButtonDown(const MouseEvent& rMEvt, vcl::Window* pWin) override;
56 SVX_DLLPRIVATE virtual bool onMouseButtonUp(const MouseEvent& rMEvt, vcl::Window* pWin) override;
57 SVX_DLLPRIVATE virtual bool onMouseMove(const MouseEvent& rMEvt, vcl::Window* pWin) override;
58
59 SVX_DLLPRIVATE bool HasMarked() const;
60 SVX_DLLPRIVATE virtual bool DeleteMarked() override;
61
62 SVX_DLLPRIVATE virtual void onSelectionHasChanged() override;
63 SVX_DLLPRIVATE virtual void onSelectAll() override;
64
65 SVX_DLLPRIVATE virtual void GetState( SfxItemSet& rSet ) override;
66 virtual void Execute( SfxRequest& rReq ) override;
67
68 SVX_DLLPRIVATE virtual bool GetStyleSheet( SfxStyleSheet* &rpStyleSheet ) const override;
69 SVX_DLLPRIVATE virtual bool SetStyleSheet( SfxStyleSheet* pStyleSheet, bool bDontRemoveHardAttr ) override;
70
71 SVX_DLLPRIVATE virtual bool ApplyFormatPaintBrush( SfxItemSet& rFormatSet, bool bNoCharacterFormats, bool bNoParagraphFormats ) override;
72
73 // slots
74 SVX_DLLPRIVATE void onInsert( sal_uInt16 nSId, const SfxItemSet* pArgs = nullptr );
75 SVX_DLLPRIVATE void onDelete( sal_uInt16 nSId );
76 SVX_DLLPRIVATE void onSelect( sal_uInt16 nSId );
77 SVX_DLLPRIVATE void onFormatTable(const SfxRequest& rReq);
78 SVX_DLLPRIVATE void MergeMarkedCells();
79 SVX_DLLPRIVATE void SplitMarkedCells(const SfxRequest& rReq);
80 SVX_DLLPRIVATE void DistributeColumns( const bool bOptimize, const bool bMinimize );
81 SVX_DLLPRIVATE void DistributeRows( const bool bOptimize, const bool bMinimize );
82 SVX_DLLPRIVATE void SetVertical( sal_uInt16 nSId );
83 SVX_DLLPRIVATE void changeTableEdge(const SfxRequest& rReq);
84
86 SdrView& rView,
87 const SdrTableObj& rObj,
88 const rtl::Reference< sdr::SelectionController >& xRefController);
89
90 static SvxBoxItem TextDistancesToSvxBoxItem(const SfxItemSet& rAttrSet);
91 static void SvxBoxItemToTextDistances(const SvxBoxItem& pOriginalItem, SfxItemSet& rAttrSet);
92
93 SVX_DLLPRIVATE void MergeAttrFromSelectedCells(SfxItemSet& rAttr, bool bOnlyHardAttr) const;
94 SVX_DLLPRIVATE void SetAttrToSelectedCells(const SfxItemSet& rAttr, bool bReplaceAll);
95 void SetAttrToSelectedShape(const SfxItemSet& rAttr);
101 SVX_DLLPRIVATE void FillCommonBorderAttrFromSelectedCells(SvxBoxItem& rBox, SvxBoxInfoItem& rBoxInfo) const;
102
103 SVX_DLLPRIVATE virtual bool GetAttributes(SfxItemSet& rTargetSet, bool bOnlyHardAttr) const override;
104 SVX_DLLPRIVATE virtual bool SetAttributes(const SfxItemSet& rSet, bool bReplaceAll) override;
105
106 SVX_DLLPRIVATE virtual rtl::Reference<SdrObject> GetMarkedSdrObjClone( SdrModel& rTargetModel ) override;
107 SVX_DLLPRIVATE virtual bool PasteObjModel( const SdrModel& rModel ) override;
108
109 SVX_DLLPRIVATE virtual bool hasSelectedCells() const override { return mbCellSelectionMode || mrView.IsTextEdit(); }
111 SVX_DLLPRIVATE virtual bool setCursorLogicPosition(const Point& rPosition, bool bPoint) override;
112
114 void getSelectedCells( CellPos& rFirstPos, CellPos& rLastPos ) override;
115 void setSelectedCells( const CellPos& rFirstPos, const CellPos& rLastPos );
116
117 virtual bool ChangeFontSize(bool bGrow, const FontList* pFontList) override;
118
119 void clearSelection();
120 void selectAll();
121
122 SVX_DLLPRIVATE void onTableModified();
123
124 bool selectRow( sal_Int32 row );
125 bool selectColumn( sal_Int32 column );
126 bool deselectRow( sal_Int32 row );
127 bool deselectColumn( sal_Int32 column );
128 bool isRowSelected( sal_Int32 nRow );
129 bool isColumnSelected( sal_Int32 nColumn );
130 bool isRowHeader();
131 bool isColumnHeader();
132 sdr::table::SdrTableObj* GetTableObj() { return mxTableObj.get().get(); }
133private:
135 SvxTableController& operator =(SvxTableController const &) = delete;
136
137 // internals
138 enum class TblAction
139 {
140 NONE,
141 GotoFirstCell, GotoFirstColumn, GotoFirstRow,
142 GotoLeftCell, GotoUpCell, GotoRightCell, GotoDownCell,
143 GotoLastCell, GotoLastColumn, GotoLastRow,
144 EditCell, StopTextEdit,
145 RemoveSelection,
146 HandledByView, Tab
147 };
148 SVX_DLLPRIVATE void ApplyBorderAttr( const SfxItemSet& rAttr );
149 SVX_DLLPRIVATE void UpdateTableShape();
150
151 SVX_DLLPRIVATE void SetTableStyle( const SfxItemSet* pArgs );
152 SVX_DLLPRIVATE void SetTableStyleSettings( const SfxItemSet* pArgs );
153
154 SVX_DLLPRIVATE bool PasteObject( SdrTableObj const * pPasteTableObj );
155
156 SVX_DLLPRIVATE bool checkTableObject();
157 SVX_DLLPRIVATE const CellPos& getSelectionStart();
158 SVX_DLLPRIVATE void setSelectionStart( const CellPos& rPos );
159 SVX_DLLPRIVATE const CellPos& getSelectionEnd();
160 SVX_DLLPRIVATE void checkCell( CellPos& rPos ) const;
161
162 SVX_DLLPRIVATE void MergeRange( sal_Int32 nFirstCol, sal_Int32 nFirstRow, sal_Int32 nLastCol, sal_Int32 nLastRow );
163
164 SVX_DLLPRIVATE void EditCell(const CellPos& rPos, vcl::Window* pWindow, TblAction nAction);
165 SVX_DLLPRIVATE void StopTextEdit();
166
167 SVX_DLLPRIVATE TblAction getKeyboardAction(const KeyEvent& rKEvt);
168 SVX_DLLPRIVATE bool executeAction(TblAction nAction, bool bSelect, vcl::Window* pWindow);
169 SVX_DLLPRIVATE void gotoCell(const CellPos& rCell, bool bSelect, vcl::Window* pWindow, TblAction nAction = TblAction::NONE);
170
171 SVX_DLLPRIVATE void StartSelection( const CellPos& rPos );
172 SVX_DLLPRIVATE void UpdateSelection( const CellPos& rPos );
173 SVX_DLLPRIVATE void RemoveSelection();
174 SVX_DLLPRIVATE void updateSelectionOverlay();
175 SVX_DLLPRIVATE void destroySelectionOverlay();
176
178
179 DECL_DLLPRIVATE_LINK( UpdateHdl, void *, void );
180
181 //TableModelRef mxTable;
183
190 std::optional<sdr::overlay::OverlayObjectList> mpSelectionOverlay;
193 css::uno::Reference< css::util::XModifyListener > mxModifyListener;
195};
196
198 SdrView& rView,
199 const SdrTableObj& rObj,
200 const rtl::Reference< sdr::SelectionController >& xRefController );
201
202}
203
204#endif // INCLUDED_SVX_SDR_TABLE_TABLECONTROLLER_HXX
205
206/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SlideSorterView & mrView
Abstract DrawObject.
Definition: svdobj.hxx:260
SvxTableController(SvxTableController const &)=delete
sdr::table::SdrTableObj * GetTableObj()
std::optional< sdr::overlay::OverlayObjectList > mpSelectionOverlay
css::uno::Reference< css::util::XModifyListener > mxModifyListener
rtl::Reference< TableModel > mxTable
unotools::WeakReference< SdrTableObj > mxTableObj
virtual SVX_DLLPRIVATE bool hasSelectedCells() const override
This is a table object, and one or more of its cells are selected.
DECL_DLLPRIVATE_LINK(UpdateHdl, void *, void)
NONE
css::uno::Reference< css::deployment::XPackageRegistry > create(css::uno::Reference< css::deployment::XPackageRegistry > const &xRootRegistry, OUString const &context, OUString const &cachePath, css::uno::Reference< css::uno::XComponentContext > const &xComponentContext)
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.
rtl::Reference< sdr::SelectionController > CreateTableController(SdrView &rView, const SdrTableObj &rObj, const rtl::Reference< sdr::SelectionController > &xRefController)
void GetState(const SdrMarkView *pSdrView, SfxItemSet &rSet)
static SfxItemSet & rSet
#define SVX_DLLPRIVATE
Definition: svxdllapi.h:30
#define SVXCORE_DLLPUBLIC
Definition: svxdllapi.h:35