LibreOffice Module sd (master) 1
tableobjectbar.cxx
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#include <sfx2/bindings.hxx>
21#include <sfx2/msg.hxx>
22#include <sfx2/request.hxx>
23#include <sfx2/objface.hxx>
24#include <sfx2/viewfrm.hxx>
25#include <sfx2/msgpool.hxx>
26#include <vcl/EnumContext.hxx>
27#include <svl/intitem.hxx>
28#include <svx/svxdlg.hxx>
29#include <svx/svxids.hrc>
30
33
34#include <strings.hrc>
35#include <DrawDocShell.hxx>
36#include <ViewShell.hxx>
37#include <sdmod.hxx>
38#include <sdresid.hxx>
39#include <DrawViewShell.hxx>
40
41#include "tableobjectbar.hxx"
42
43using namespace sd;
44using namespace sd::ui::table;
45
46#define ShellClass_TableObjectBar
47#include <sdslots.hxx>
48
49namespace sd::ui::table {
50
53{
54 return new TableObjectBar( &rShell, pView );
55}
56
59{
60 TableObjectBar::RegisterInterface(pMod);
61}
62
63
65
66void TableObjectBar::InitInterface_Impl()
67{
68}
69
71: SfxShell( pSdViewShell->GetViewShell() )
72, mpView( pSdView )
73, mpViewSh( pSdViewShell )
74{
75 DrawDocShell* pDocShell = mpViewSh->GetDocSh();
76 if( pDocShell )
77 {
78 SetPool( &pDocShell->GetPool() );
79 SetUndoManager( pDocShell->GetUndoManager() );
80 }
82 SetName( SdResId( RID_DRAW_TABLE_TOOLBOX ) );
84}
85
87{
88 SetRepeatTarget( nullptr );
89}
90
92{
93 if( mpView )
94 {
96 if( xController.is() )
97 {
98 xController->GetState( rSet );
99 }
100 }
101}
102
104{
105 DrawViewShell* pDrawViewShell = dynamic_cast< DrawViewShell* >( mpViewSh );
106 if( pDrawViewShell )
107 pDrawViewShell->GetAttrState( rSet );
108}
109
111{
112 if( !mpView )
113 return;
114
115 SdrView* pView = mpView;
116 SfxBindings* pBindings = &mpViewSh->GetViewFrame()->GetBindings();
117
119 sal_uInt16 nSlotId = rReq.GetSlot();
120 if( xController.is() )
121 {
122 switch( nSlotId )
123 {
124 case SID_TABLE_INSERT_ROW_DLG:
125 case SID_TABLE_INSERT_ROW_BEFORE:
126 case SID_TABLE_INSERT_ROW_AFTER:
127 case SID_TABLE_INSERT_COL_DLG:
128 case SID_TABLE_INSERT_COL_BEFORE:
129 case SID_TABLE_INSERT_COL_AFTER:
130 {
132 if (nSlotId == SID_TABLE_INSERT_ROW_DLG || nSlotId == SID_TABLE_INSERT_COL_DLG)
133 {
136 pDlg.disposeAndReset( pFact->CreateSvxInsRowColDlg(pWin ? pWin->GetFrameWeld() : nullptr,
137 nSlotId == SID_TABLE_INSERT_COL_DLG,
138 SD_MOD()->GetSlotPool()->GetSlot(nSlotId)->GetCommand()) );
139
140 if (pDlg->Execute() != 1)
141 break;
142 }
143
144 sal_uInt16 nCount = 1;
145 bool bInsertAfter = (nSlotId == SID_TABLE_INSERT_ROW_AFTER) || (nSlotId == SID_TABLE_INSERT_COL_AFTER);
146
147 if (nSlotId == SID_TABLE_INSERT_ROW_DLG)
148 {
149 nCount = pDlg->getInsertCount();
150 bInsertAfter = !pDlg->isInsertBefore();
151 }
152 else if (nSlotId == SID_TABLE_INSERT_COL_DLG)
153 {
154 nCount = pDlg->getInsertCount();
155 bInsertAfter = !pDlg->isInsertBefore();
156 }
157
158 if (nSlotId == SID_TABLE_INSERT_ROW_DLG || nSlotId == SID_TABLE_INSERT_ROW_BEFORE || nSlotId == SID_TABLE_INSERT_ROW_AFTER)
159 nSlotId = SID_TABLE_INSERT_ROW;
160 else
161 nSlotId = SID_TABLE_INSERT_COL;
162
163 rReq.AppendItem(SfxInt16Item(nSlotId, nCount));
164 rReq.AppendItem(SfxBoolItem(SID_TABLE_PARAM_INSERT_AFTER, bInsertAfter));
165
166 rReq.SetSlot( nSlotId );
167 }
168 }
169
170 xController->Execute( rReq );
171 }
172
173 // note: we may be deleted at this point, no more member access possible
174
175 switch( rReq.GetSlot() )
176 {
177 case SID_ATTR_BORDER:
178 case SID_TABLE_MERGE_CELLS:
179 case SID_TABLE_SPLIT_CELLS:
180 case SID_OPTIMIZE_TABLE:
181 case SID_TABLE_DELETE_ROW:
182 case SID_TABLE_DELETE_COL:
183 case SID_TABLE_DELETE_TABLE:
184 case SID_FORMAT_TABLE_DLG:
185 case SID_TABLE_INSERT_ROW:
186 case SID_TABLE_INSERT_COL:
187 {
188 pView->AdjustMarkHdl();
189 pBindings->Invalidate( SID_TABLE_DELETE_ROW );
190 pBindings->Invalidate( SID_TABLE_DELETE_COL );
191 pBindings->Invalidate( SID_TABLE_DELETE_TABLE );
192 pBindings->Invalidate( SID_FRAME_LINESTYLE );
193 pBindings->Invalidate( SID_FRAME_LINECOLOR );
194 pBindings->Invalidate( SID_ATTR_BORDER );
195 pBindings->Invalidate( SID_ATTR_FILL_STYLE );
196 pBindings->Invalidate( SID_ATTR_FILL_USE_SLIDE_BACKGROUND );
197 pBindings->Invalidate( SID_ATTR_FILL_TRANSPARENCE );
198 pBindings->Invalidate( SID_ATTR_FILL_FLOATTRANSPARENCE );
199 pBindings->Invalidate( SID_TABLE_MERGE_CELLS );
200 pBindings->Invalidate( SID_TABLE_SPLIT_CELLS );
201 pBindings->Invalidate( SID_OPTIMIZE_TABLE );
202 pBindings->Invalidate( SID_TABLE_VERT_BOTTOM );
203 pBindings->Invalidate( SID_TABLE_VERT_CENTER );
204 pBindings->Invalidate( SID_TABLE_VERT_NONE );
205 break;
206 }
207 case SID_TABLE_VERT_BOTTOM:
208 case SID_TABLE_VERT_CENTER:
209 case SID_TABLE_VERT_NONE:
210 {
211 pBindings->Invalidate( SID_TABLE_VERT_BOTTOM );
212 pBindings->Invalidate( SID_TABLE_VERT_CENTER );
213 pBindings->Invalidate( SID_TABLE_VERT_NONE );
214 break;
215 }
216 }
217
218 pBindings->Invalidate( SID_UNDO );
219 pBindings->Invalidate( SID_REDO );
220}
221
222}
223
224/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void disposeAndReset(reference_type *pBody)
void AdjustMarkHdl(SfxViewShell *pOtherShell=nullptr)
const rtl::Reference< sdr::SelectionController > & getSelectionController() const
void Invalidate(sal_uInt16 nId)
sal_uInt16 GetSlot() const
void SetSlot(sal_uInt16 nNewSlot)
void AppendItem(const SfxPoolItem &)
void SetUndoManager(SfxUndoManager *pNewUndoMgr)
SfxItemPool & GetPool() const
void SetRepeatTarget(SfxRepeatTarget *pTarget)
void SetContextName(const OUString &rsContextName)
void SetPool(SfxItemPool *pNewPool)
void SetName(const OUString &rName)
SfxBindings & GetBindings()
virtual VclPtr< SvxAbstractInsRowColDlg > CreateSvxInsRowColDlg(weld::Window *pParent, bool bCol, const OUString &rHelpId)=0
static SvxAbstractDialogFactory * Create()
virtual SfxUndoManager * GetUndoManager() override
Definition: docshell.cxx:363
Base class of the stacked shells that provide graphical views to Draw and Impress documents and editi...
void GetAttrState(SfxItemSet &rSet)
Definition: drviewsf.cxx:258
Base class of the stacked shell hierarchy.
Definition: ViewShell.hxx:92
SD_DLLPUBLIC DrawDocShell * GetDocSh() const
Definition: viewshel.cxx:1407
vcl::Window * GetParentWindow() const
Return the window that is the parent of all controls of this view shell.
Definition: ViewShell.hxx:140
SD_DLLPUBLIC SfxViewFrame * GetViewFrame() const
Definition: viewshel.cxx:118
ViewShell * GetViewShell() const
Definition: View.hxx:144
virtual ~TableObjectBar() override
void GetAttrState(SfxItemSet &rSet)
void GetState(SfxItemSet &rSet)
TableObjectBar(::sd::ViewShell *pSdViewShell, ::sd::View *pSdView)
void Execute(SfxRequest &rReq)
static const OUString & GetContextName(const Context eContext)
weld::Window * GetFrameWeld() const
int nCount
void RegisterInterfaces(const SfxModule *pMod)
registers the interfaces from the table ui
SfxShell * CreateTableObjectBar(ViewShell &rShell, ::sd::View *pView)
creates a table object bar for the given ViewShell
OUString SdResId(TranslateId aId)
Definition: sdmod.cxx:83
#define SD_MOD()
Definition: sdmod.hxx:184
static SfxItemSet & rSet
#define SFX_IMPL_INTERFACE(Class, SuperClass)
UnoViewSharedPtr mpView
Reference< XController > xController