1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: tableobjectbar.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
34 #include <sfx2/msg.hxx>
35 #include <sfx2/app.hxx>
36 #include <sfx2/sfxsids.hrc>
37 #include <sfx2/request.hxx>
38 #include <sfx2/objface.hxx>
39 #include <sfx2/viewfrm.hxx>
40 #include <sfx2/dispatch.hxx>
42 #include <svtools/whiter.hxx>
43 #include <svtools/itempool.hxx>
44 #include <svx/svdomedia.hxx>
45 #include <svx/sdr/contact/viewcontactofsdrmediaobj.hxx>
46 #include <svx/svxdlg.hxx>
47 #include <svx/dialogs.hrc>
48 #include <svx/svxids.hrc>
51 #include "res_bmp.hrc"
53 #include "strings.hrc"
54 #include "DrawDocShell.hxx"
55 #include "ViewShell.hxx"
57 #include "drawview.hxx"
58 #include "sdresid.hxx"
59 #include "drawdoc.hxx"
60 #include "DrawViewShell.hxx"
62 #include "tableobjectbar.hxx"
65 using namespace sd::ui::table
;
67 #define TableObjectBar
68 #include "sdslots.hxx"
71 namespace sd
{ namespace ui
{ namespace table
{
73 /** creates a table object bar for the given ViewShell */
74 SfxShell
* CreateTableObjectBar( ViewShell
& rShell
, ::sd::View
* pView
)
76 return new TableObjectBar( &rShell
, pView
);
80 /** registers the interfaces from the table ui */
81 void RegisterInterfaces(SfxModule
* pMod
)
83 TableObjectBar::RegisterInterface(pMod
);
90 TYPEINIT1( TableObjectBar
, SfxShell
);
92 // -----------------------------------------------------------------------------
94 SFX_IMPL_INTERFACE( TableObjectBar
, SfxShell
, SdResId( STR_TABLEOBJECTBARSHELL
) )
98 // -----------------------------------------------------------------------------
100 TableObjectBar::TableObjectBar( ViewShell
* pSdViewShell
, ::sd::View
* pSdView
)
101 : SfxShell( pSdViewShell
->GetViewShell() )
103 , mpViewSh( pSdViewShell
)
105 DrawDocShell
* pDocShell
= mpViewSh
->GetDocSh();
108 SetPool( &pDocShell
->GetPool() );
109 SetUndoManager( pDocShell
->GetUndoManager() );
111 SetRepeatTarget( mpView
);
112 SetHelpId( SD_IF_SDDRAWTABLEOBJECTBAR
);
113 SetName( String( SdResId( RID_DRAW_TABLE_TOOLBOX
) ) );
116 // -----------------------------------------------------------------------------
118 TableObjectBar::~TableObjectBar()
120 SetRepeatTarget( NULL
);
123 // -----------------------------------------------------------------------------
125 void TableObjectBar::GetState( SfxItemSet
& rSet
)
127 bool bReadOnly
= false;
131 rSet
.DisableItem (SID_INSERT_TABLE
);
136 rtl::Reference
< sdr::SelectionController
> xController( mpView
->getSelectionController() );
137 if( xController
.is() )
139 xController
->GetState( rSet
);
144 // -----------------------------------------------------------------------------
146 void TableObjectBar::GetAttrState( SfxItemSet
& rSet
)
148 DrawViewShell
* pDrawViewShell
= dynamic_cast< DrawViewShell
* >( mpViewSh
);
150 pDrawViewShell
->GetAttrState( rSet
);
153 // -----------------------------------------------------------------------------
155 void TableObjectBar::Execute( SfxRequest
& rReq
)
159 SdrView
* pView
= mpView
;
160 SfxBindings
* pBindings
= &mpViewSh
->GetViewFrame()->GetBindings();
162 rtl::Reference
< sdr::SelectionController
> xController( mpView
->getSelectionController() );
163 ULONG nSlotId
= rReq
.GetSlot();
164 if( xController
.is() )
168 case SID_TABLE_INSERT_ROW_DLG
:
169 case SID_TABLE_INSERT_COL_DLG
:
171 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
172 ::std::auto_ptr
<SvxAbstractInsRowColDlg
> pDlg( pFact
? pFact
->CreateSvxInsRowColDlg( mpView
->GetViewShell()->GetParentWindow(), nSlotId
== SID_TABLE_INSERT_COL_DLG
, nSlotId
) : 0);
174 if( pDlg
.get() && (pDlg
->Execute() == 1) )
176 if( nSlotId
== SID_TABLE_INSERT_ROW_DLG
)
177 nSlotId
= SID_TABLE_INSERT_ROW
;
179 nSlotId
= SID_TABLE_INSERT_COL
;
181 rReq
.AppendItem( SfxInt16Item( (USHORT
)nSlotId
, (sal_uInt16
)pDlg
->getInsertCount() ) );
182 rReq
.AppendItem( SfxBoolItem( SID_TABLE_PARAM_INSERT_AFTER
, !pDlg
->isInsertBefore() ) );
184 rReq
.SetSlot( (USHORT
)nSlotId
);
189 xController
->Execute( rReq
);
192 // note: we may be deleted at this point, no more member access possible
194 switch( rReq
.GetSlot() )
196 case SID_ATTR_BORDER
:
197 case SID_TABLE_MERGE_CELLS
:
198 case SID_TABLE_SPLIT_CELLS
:
199 case SID_OPTIMIZE_TABLE
:
200 case SID_TABLE_DELETE_ROW
:
201 case SID_TABLE_DELETE_COL
:
202 case SID_FORMAT_TABLE_DLG
:
203 case SID_TABLE_INSERT_ROW
:
204 case SID_TABLE_INSERT_COL
:
206 pView
->AdjustMarkHdl();
207 pBindings
->Invalidate( SID_TABLE_DELETE_ROW
);
208 pBindings
->Invalidate( SID_TABLE_DELETE_COL
);
209 pBindings
->Invalidate( SID_FRAME_LINESTYLE
);
210 pBindings
->Invalidate( SID_FRAME_LINECOLOR
);
211 pBindings
->Invalidate( SID_ATTR_BORDER
);
212 pBindings
->Invalidate( SID_ATTR_FILL_STYLE
);
213 pBindings
->Invalidate( SID_TABLE_MERGE_CELLS
);
214 pBindings
->Invalidate( SID_TABLE_SPLIT_CELLS
);
215 pBindings
->Invalidate( SID_OPTIMIZE_TABLE
);
216 pBindings
->Invalidate( SID_TABLE_VERT_BOTTOM
);
217 pBindings
->Invalidate( SID_TABLE_VERT_CENTER
);
218 pBindings
->Invalidate( SID_TABLE_VERT_NONE
);
221 case SID_TABLE_VERT_BOTTOM
:
222 case SID_TABLE_VERT_CENTER
:
223 case SID_TABLE_VERT_NONE
:
225 pBindings
->Invalidate( SID_TABLE_VERT_BOTTOM
);
226 pBindings
->Invalidate( SID_TABLE_VERT_CENTER
);
227 pBindings
->Invalidate( SID_TABLE_VERT_NONE
);
232 pBindings
->Invalidate( SID_UNDO
);
233 pBindings
->Invalidate( SID_REDO
);