android: Update app-specific/MIME type icons
[LibreOffice.git] / sd / source / ui / table / tableobjectbar.cxx
blob6dfd86928530ab3ac62b57aa10ed45806344c759
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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>
31 #include <createtableobjectbar.hxx>
32 #include <registerinterfaces.hxx>
34 #include <strings.hrc>
35 #include <DrawDocShell.hxx>
36 #include <ViewShell.hxx>
37 #include <sdmod.hxx>
38 #include <sdresid.hxx>
39 #include <DrawViewShell.hxx>
41 #include "tableobjectbar.hxx"
43 using namespace sd;
44 using namespace sd::ui::table;
46 #define ShellClass_TableObjectBar
47 #include <sdslots.hxx>
49 namespace sd::ui::table {
51 /** creates a table object bar for the given ViewShell */
52 SfxShell* CreateTableObjectBar( ViewShell& rShell, ::sd::View* pView )
54 return new TableObjectBar( &rShell, pView );
57 /** registers the interfaces from the table ui */
58 void RegisterInterfaces(const SfxModule* pMod)
60 TableObjectBar::RegisterInterface(pMod);
64 SFX_IMPL_INTERFACE(TableObjectBar, SfxShell)
66 void TableObjectBar::InitInterface_Impl()
70 TableObjectBar::TableObjectBar( ViewShell* pSdViewShell, ::sd::View* pSdView )
71 : SfxShell( pSdViewShell->GetViewShell() )
72 , mpView( pSdView )
73 , mpViewSh( pSdViewShell )
75 DrawDocShell* pDocShell = mpViewSh->GetDocSh();
76 if( pDocShell )
78 SetPool( &pDocShell->GetPool() );
79 SetUndoManager( pDocShell->GetUndoManager() );
81 SetRepeatTarget( mpView );
82 SetName( SdResId( RID_DRAW_TABLE_TOOLBOX ) );
83 SetContextName(vcl::EnumContext::GetContextName(vcl::EnumContext::Context::Table));
86 TableObjectBar::~TableObjectBar()
88 SetRepeatTarget( nullptr );
91 void TableObjectBar::GetState( SfxItemSet& rSet )
93 if( mpView )
95 rtl::Reference< sdr::SelectionController > xController( mpView->getSelectionController() );
96 if( xController.is() )
98 xController->GetState( rSet );
103 void TableObjectBar::GetAttrState( SfxItemSet& rSet )
105 DrawViewShell* pDrawViewShell = dynamic_cast< DrawViewShell* >( mpViewSh );
106 if( pDrawViewShell )
107 pDrawViewShell->GetAttrState( rSet );
110 void TableObjectBar::Execute( SfxRequest& rReq )
112 if( !mpView )
113 return;
115 SdrView* pView = mpView;
116 SfxBindings* pBindings = &mpViewSh->GetViewFrame()->GetBindings();
118 rtl::Reference< sdr::SelectionController > xController( mpView->getSelectionController() );
119 sal_uInt16 nSlotId = rReq.GetSlot();
120 if( xController.is() )
122 switch( nSlotId )
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:
131 ScopedVclPtr<SvxAbstractInsRowColDlg> pDlg;
132 if (nSlotId == SID_TABLE_INSERT_ROW_DLG || nSlotId == SID_TABLE_INSERT_COL_DLG)
134 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
135 vcl::Window* pWin = mpView->GetViewShell()->GetParentWindow();
136 pDlg.disposeAndReset( pFact->CreateSvxInsRowColDlg(pWin ? pWin->GetFrameWeld() : nullptr,
137 nSlotId == SID_TABLE_INSERT_COL_DLG,
138 SD_MOD()->GetSlotPool()->GetSlot(nSlotId)->GetCommand()) );
140 if (pDlg->Execute() != 1)
141 break;
144 sal_uInt16 nCount = 1;
145 bool bInsertAfter = (nSlotId == SID_TABLE_INSERT_ROW_AFTER) || (nSlotId == SID_TABLE_INSERT_COL_AFTER);
147 if (nSlotId == SID_TABLE_INSERT_ROW_DLG)
149 nCount = pDlg->getInsertCount();
150 bInsertAfter = !pDlg->isInsertBefore();
152 else if (nSlotId == SID_TABLE_INSERT_COL_DLG)
154 nCount = pDlg->getInsertCount();
155 bInsertAfter = !pDlg->isInsertBefore();
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;
163 rReq.AppendItem(SfxInt16Item(nSlotId, nCount));
164 rReq.AppendItem(SfxBoolItem(SID_TABLE_PARAM_INSERT_AFTER, bInsertAfter));
166 rReq.SetSlot( nSlotId );
170 xController->Execute( rReq );
173 // note: we may be deleted at this point, no more member access possible
175 switch( rReq.GetSlot() )
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:
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;
207 case SID_TABLE_VERT_BOTTOM:
208 case SID_TABLE_VERT_CENTER:
209 case SID_TABLE_VERT_NONE:
211 pBindings->Invalidate( SID_TABLE_VERT_BOTTOM );
212 pBindings->Invalidate( SID_TABLE_VERT_CENTER );
213 pBindings->Invalidate( SID_TABLE_VERT_NONE );
214 break;
218 pBindings->Invalidate( SID_UNDO );
219 pBindings->Invalidate( SID_REDO );
224 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */