1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/msg.hxx>
21 #include <sfx2/app.hxx>
22 #include <sfx2/sfxsids.hrc>
23 #include <sfx2/request.hxx>
24 #include <sfx2/objface.hxx>
25 #include <sfx2/viewfrm.hxx>
26 #include <sfx2/dispatch.hxx>
27 #include <sfx2/msgpool.hxx>
28 #include <sfx2/sidebar/EnumContext.hxx>
29 #include <svl/whiter.hxx>
30 #include <svl/itempool.hxx>
31 #include <svx/svdomedia.hxx>
32 #include <svx/sdr/contact/viewcontactofsdrmediaobj.hxx>
33 #include <svx/svxdlg.hxx>
34 #include <svx/dialogs.hrc>
35 #include <svx/svxids.hrc>
38 #include "createtableobjectbar.hxx"
39 #include "registerinterfaces.hxx"
40 #include "res_bmp.hrc"
42 #include "strings.hrc"
43 #include "DrawDocShell.hxx"
44 #include "ViewShell.hxx"
46 #include "drawview.hxx"
47 #include "sdresid.hxx"
48 #include "drawdoc.hxx"
49 #include "DrawViewShell.hxx"
51 #include "tableobjectbar.hxx"
53 #include <boost/scoped_ptr.hpp>
56 using namespace sd::ui::table
;
58 #define TableObjectBar
59 #include "sdslots.hxx"
61 namespace sd
{ namespace ui
{ namespace table
{
63 /** creates a table object bar for the given ViewShell */
64 SfxShell
* CreateTableObjectBar( ViewShell
& rShell
, ::sd::View
* pView
)
66 return new TableObjectBar( &rShell
, pView
);
69 /** registers the interfaces from the table ui */
70 void RegisterInterfaces(SfxModule
* pMod
)
72 TableObjectBar::RegisterInterface(pMod
);
77 TYPEINIT1( TableObjectBar
, SfxShell
);
79 SFX_IMPL_INTERFACE(TableObjectBar
, SfxShell
)
81 void TableObjectBar::InitInterface_Impl()
85 TableObjectBar::TableObjectBar( ViewShell
* pSdViewShell
, ::sd::View
* pSdView
)
86 : SfxShell( pSdViewShell
->GetViewShell() )
88 , mpViewSh( pSdViewShell
)
90 DrawDocShell
* pDocShell
= mpViewSh
->GetDocSh();
93 SetPool( &pDocShell
->GetPool() );
94 SetUndoManager( pDocShell
->GetUndoManager() );
96 SetRepeatTarget( mpView
);
97 SetHelpId( SD_IF_SDDRAWTABLEOBJECTBAR
);
98 SetName( SD_RESSTR( RID_DRAW_TABLE_TOOLBOX
) );
99 SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_Table
));
102 TableObjectBar::~TableObjectBar()
104 SetRepeatTarget( NULL
);
107 void TableObjectBar::GetState( SfxItemSet
& rSet
)
111 rtl::Reference
< sdr::SelectionController
> xController( mpView
->getSelectionController() );
112 if( xController
.is() )
114 xController
->GetState( rSet
);
119 void TableObjectBar::GetAttrState( SfxItemSet
& rSet
)
121 DrawViewShell
* pDrawViewShell
= dynamic_cast< DrawViewShell
* >( mpViewSh
);
123 pDrawViewShell
->GetAttrState( rSet
);
126 void TableObjectBar::Execute( SfxRequest
& rReq
)
130 SdrView
* pView
= mpView
;
131 SfxBindings
* pBindings
= &mpViewSh
->GetViewFrame()->GetBindings();
133 rtl::Reference
< sdr::SelectionController
> xController( mpView
->getSelectionController() );
134 sal_uLong nSlotId
= rReq
.GetSlot();
135 if( xController
.is() )
139 case SID_TABLE_INSERT_ROW_DLG
:
140 case SID_TABLE_INSERT_COL_DLG
:
142 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
143 boost::scoped_ptr
<SvxAbstractInsRowColDlg
> pDlg( pFact
? pFact
->CreateSvxInsRowColDlg( mpView
->GetViewShell()->GetParentWindow(), nSlotId
== SID_TABLE_INSERT_COL_DLG
, SD_MOD()->GetSlotPool()->GetSlot(nSlotId
)->GetCommand()) : 0);
145 if( pDlg
.get() && (pDlg
->Execute() == 1) )
147 if( nSlotId
== SID_TABLE_INSERT_ROW_DLG
)
148 nSlotId
= SID_TABLE_INSERT_ROW
;
150 nSlotId
= SID_TABLE_INSERT_COL
;
152 rReq
.AppendItem( SfxInt16Item( (sal_uInt16
)nSlotId
, (sal_uInt16
)pDlg
->getInsertCount() ) );
153 rReq
.AppendItem( SfxBoolItem( SID_TABLE_PARAM_INSERT_AFTER
, !pDlg
->isInsertBefore() ) );
155 rReq
.SetSlot( (sal_uInt16
)nSlotId
);
160 xController
->Execute( rReq
);
163 // note: we may be deleted at this point, no more member access possible
165 switch( rReq
.GetSlot() )
167 case SID_ATTR_BORDER
:
168 case SID_TABLE_MERGE_CELLS
:
169 case SID_TABLE_SPLIT_CELLS
:
170 case SID_OPTIMIZE_TABLE
:
171 case SID_TABLE_DELETE_ROW
:
172 case SID_TABLE_DELETE_COL
:
173 case SID_FORMAT_TABLE_DLG
:
174 case SID_TABLE_INSERT_ROW
:
175 case SID_TABLE_INSERT_COL
:
177 pView
->AdjustMarkHdl();
178 pBindings
->Invalidate( SID_TABLE_DELETE_ROW
);
179 pBindings
->Invalidate( SID_TABLE_DELETE_COL
);
180 pBindings
->Invalidate( SID_FRAME_LINESTYLE
);
181 pBindings
->Invalidate( SID_FRAME_LINECOLOR
);
182 pBindings
->Invalidate( SID_ATTR_BORDER
);
183 pBindings
->Invalidate( SID_ATTR_FILL_STYLE
);
184 pBindings
->Invalidate( SID_ATTR_FILL_TRANSPARENCE
);
185 pBindings
->Invalidate( SID_ATTR_FILL_FLOATTRANSPARENCE
);
186 pBindings
->Invalidate( SID_TABLE_MERGE_CELLS
);
187 pBindings
->Invalidate( SID_TABLE_SPLIT_CELLS
);
188 pBindings
->Invalidate( SID_OPTIMIZE_TABLE
);
189 pBindings
->Invalidate( SID_TABLE_VERT_BOTTOM
);
190 pBindings
->Invalidate( SID_TABLE_VERT_CENTER
);
191 pBindings
->Invalidate( SID_TABLE_VERT_NONE
);
194 case SID_TABLE_VERT_BOTTOM
:
195 case SID_TABLE_VERT_CENTER
:
196 case SID_TABLE_VERT_NONE
:
198 pBindings
->Invalidate( SID_TABLE_VERT_BOTTOM
);
199 pBindings
->Invalidate( SID_TABLE_VERT_CENTER
);
200 pBindings
->Invalidate( SID_TABLE_VERT_NONE
);
205 pBindings
->Invalidate( SID_UNDO
);
206 pBindings
->Invalidate( SID_REDO
);
212 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */