15b190011SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 35b190011SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 45b190011SAndrew Rist * or more contributor license agreements. See the NOTICE file 55b190011SAndrew Rist * distributed with this work for additional information 65b190011SAndrew Rist * regarding copyright ownership. The ASF licenses this file 75b190011SAndrew Rist * to you under the Apache License, Version 2.0 (the 85b190011SAndrew Rist * "License"); you may not use this file except in compliance 95b190011SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 115b190011SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 135b190011SAndrew Rist * Unless required by applicable law or agreed to in writing, 145b190011SAndrew Rist * software distributed under the License is distributed on an 155b190011SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 165b190011SAndrew Rist * KIND, either express or implied. See the License for the 175b190011SAndrew Rist * specific language governing permissions and limitations 185b190011SAndrew Rist * under the License. 19cdf0e10cSrcweir * 205b190011SAndrew Rist *************************************************************/ 215b190011SAndrew Rist 225b190011SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_sd.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <sfx2/msg.hxx> 28cdf0e10cSrcweir #include <sfx2/app.hxx> 29cdf0e10cSrcweir #include <sfx2/sfxsids.hrc> 30cdf0e10cSrcweir #include <sfx2/request.hxx> 31cdf0e10cSrcweir #include <sfx2/objface.hxx> 32cdf0e10cSrcweir #include <sfx2/viewfrm.hxx> 33cdf0e10cSrcweir #include <sfx2/dispatch.hxx> 34cdf0e10cSrcweir #include <sfx2/msgpool.hxx> 35*f120fe41SAndre Fischer #include <sfx2/sidebar/EnumContext.hxx> 36cdf0e10cSrcweir #include <svl/whiter.hxx> 37cdf0e10cSrcweir #include <svl/itempool.hxx> 38cdf0e10cSrcweir #include <svx/svdomedia.hxx> 39cdf0e10cSrcweir #include <svx/sdr/contact/viewcontactofsdrmediaobj.hxx> 40cdf0e10cSrcweir #include <svx/svxdlg.hxx> 41cdf0e10cSrcweir #include <svx/dialogs.hrc> 42cdf0e10cSrcweir #include <svx/svxids.hrc> 43cdf0e10cSrcweir 44cdf0e10cSrcweir #include "app.hrc" 45cdf0e10cSrcweir #include "res_bmp.hrc" 46cdf0e10cSrcweir #include "glob.hrc" 47cdf0e10cSrcweir #include "strings.hrc" 48cdf0e10cSrcweir #include "DrawDocShell.hxx" 49cdf0e10cSrcweir #include "ViewShell.hxx" 50cdf0e10cSrcweir #include "Window.hxx" 51cdf0e10cSrcweir #include "drawview.hxx" 52cdf0e10cSrcweir #include "sdresid.hxx" 53cdf0e10cSrcweir #include "drawdoc.hxx" 54cdf0e10cSrcweir #include "DrawViewShell.hxx" 55cdf0e10cSrcweir 56cdf0e10cSrcweir #include "tableobjectbar.hxx" 57cdf0e10cSrcweir 58cdf0e10cSrcweir using namespace sd; 59cdf0e10cSrcweir using namespace sd::ui::table; 60cdf0e10cSrcweir 61cdf0e10cSrcweir #define TableObjectBar 62cdf0e10cSrcweir #include "sdslots.hxx" 63cdf0e10cSrcweir 64cdf0e10cSrcweir 65cdf0e10cSrcweir namespace sd { namespace ui { namespace table { 66cdf0e10cSrcweir 67cdf0e10cSrcweir /** creates a table object bar for the given ViewShell */ 68cdf0e10cSrcweir SfxShell* CreateTableObjectBar( ViewShell& rShell, ::sd::View* pView ) 69cdf0e10cSrcweir { 70cdf0e10cSrcweir return new TableObjectBar( &rShell, pView ); 71cdf0e10cSrcweir } 72cdf0e10cSrcweir 73cdf0e10cSrcweir 74cdf0e10cSrcweir /** registers the interfaces from the table ui */ 75cdf0e10cSrcweir void RegisterInterfaces(SfxModule* pMod) 76cdf0e10cSrcweir { 77cdf0e10cSrcweir TableObjectBar::RegisterInterface(pMod); 78cdf0e10cSrcweir } 79cdf0e10cSrcweir 80cdf0e10cSrcweir // ------------------ 81cdf0e10cSrcweir // - TableObjectBar - 82cdf0e10cSrcweir // ------------------ 83cdf0e10cSrcweir 84cdf0e10cSrcweir TYPEINIT1( TableObjectBar, SfxShell ); 85cdf0e10cSrcweir 86cdf0e10cSrcweir // ----------------------------------------------------------------------------- 87cdf0e10cSrcweir 88cdf0e10cSrcweir SFX_IMPL_INTERFACE( TableObjectBar, SfxShell, SdResId( STR_TABLEOBJECTBARSHELL ) ) 89cdf0e10cSrcweir { 90cdf0e10cSrcweir } 91cdf0e10cSrcweir 92cdf0e10cSrcweir // ----------------------------------------------------------------------------- 93cdf0e10cSrcweir 94cdf0e10cSrcweir TableObjectBar::TableObjectBar( ViewShell* pSdViewShell, ::sd::View* pSdView ) 95cdf0e10cSrcweir : SfxShell( pSdViewShell->GetViewShell() ) 96cdf0e10cSrcweir , mpView( pSdView ) 97cdf0e10cSrcweir , mpViewSh( pSdViewShell ) 98cdf0e10cSrcweir { 99cdf0e10cSrcweir DrawDocShell* pDocShell = mpViewSh->GetDocSh(); 100cdf0e10cSrcweir if( pDocShell ) 101cdf0e10cSrcweir { 102cdf0e10cSrcweir SetPool( &pDocShell->GetPool() ); 103cdf0e10cSrcweir SetUndoManager( pDocShell->GetUndoManager() ); 104cdf0e10cSrcweir } 105cdf0e10cSrcweir SetRepeatTarget( mpView ); 106cdf0e10cSrcweir SetHelpId( SD_IF_SDDRAWTABLEOBJECTBAR ); 107cdf0e10cSrcweir SetName( String( SdResId( RID_DRAW_TABLE_TOOLBOX ) ) ); 108*f120fe41SAndre Fischer SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_Table)); 109cdf0e10cSrcweir } 110cdf0e10cSrcweir 111cdf0e10cSrcweir // ----------------------------------------------------------------------------- 112cdf0e10cSrcweir 113cdf0e10cSrcweir TableObjectBar::~TableObjectBar() 114cdf0e10cSrcweir { 115cdf0e10cSrcweir SetRepeatTarget( NULL ); 116cdf0e10cSrcweir } 117cdf0e10cSrcweir 118cdf0e10cSrcweir // ----------------------------------------------------------------------------- 119cdf0e10cSrcweir 120cdf0e10cSrcweir void TableObjectBar::GetState( SfxItemSet& rSet ) 121cdf0e10cSrcweir { 122cdf0e10cSrcweir bool bReadOnly = false; 123cdf0e10cSrcweir 124cdf0e10cSrcweir if( bReadOnly ) 125cdf0e10cSrcweir { 126cdf0e10cSrcweir rSet.DisableItem (SID_INSERT_TABLE ); 127cdf0e10cSrcweir } 128cdf0e10cSrcweir 129cdf0e10cSrcweir if( mpView ) 130cdf0e10cSrcweir { 131cdf0e10cSrcweir rtl::Reference< sdr::SelectionController > xController( mpView->getSelectionController() ); 132cdf0e10cSrcweir if( xController.is() ) 133cdf0e10cSrcweir { 134cdf0e10cSrcweir xController->GetState( rSet ); 135cdf0e10cSrcweir } 136cdf0e10cSrcweir } 137cdf0e10cSrcweir } 138cdf0e10cSrcweir 139cdf0e10cSrcweir // ----------------------------------------------------------------------------- 140cdf0e10cSrcweir 141cdf0e10cSrcweir void TableObjectBar::GetAttrState( SfxItemSet& rSet ) 142cdf0e10cSrcweir { 143cdf0e10cSrcweir DrawViewShell* pDrawViewShell = dynamic_cast< DrawViewShell* >( mpViewSh ); 144cdf0e10cSrcweir if( pDrawViewShell ) 145cdf0e10cSrcweir pDrawViewShell->GetAttrState( rSet ); 146cdf0e10cSrcweir } 147cdf0e10cSrcweir 148cdf0e10cSrcweir // ----------------------------------------------------------------------------- 149cdf0e10cSrcweir 150cdf0e10cSrcweir void TableObjectBar::Execute( SfxRequest& rReq ) 151cdf0e10cSrcweir { 152cdf0e10cSrcweir if( mpView ) 153cdf0e10cSrcweir { 154cdf0e10cSrcweir SdrView* pView = mpView; 155cdf0e10cSrcweir SfxBindings* pBindings = &mpViewSh->GetViewFrame()->GetBindings(); 156cdf0e10cSrcweir 157cdf0e10cSrcweir rtl::Reference< sdr::SelectionController > xController( mpView->getSelectionController() ); 158cdf0e10cSrcweir sal_uLong nSlotId = rReq.GetSlot(); 159cdf0e10cSrcweir if( xController.is() ) 160cdf0e10cSrcweir { 161cdf0e10cSrcweir switch( nSlotId ) 162cdf0e10cSrcweir { 163cdf0e10cSrcweir case SID_TABLE_INSERT_ROW_DLG: 164cdf0e10cSrcweir case SID_TABLE_INSERT_COL_DLG: 165cdf0e10cSrcweir { 166cdf0e10cSrcweir SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); 167cdf0e10cSrcweir ::std::auto_ptr<SvxAbstractInsRowColDlg> pDlg( pFact ? pFact->CreateSvxInsRowColDlg( mpView->GetViewShell()->GetParentWindow(), nSlotId == SID_TABLE_INSERT_COL_DLG, SD_MOD()->GetSlotPool()->GetSlot(nSlotId)->GetCommand()) : 0); 168cdf0e10cSrcweir 169cdf0e10cSrcweir if( pDlg.get() && (pDlg->Execute() == 1) ) 170cdf0e10cSrcweir { 171cdf0e10cSrcweir if( nSlotId == SID_TABLE_INSERT_ROW_DLG ) 172cdf0e10cSrcweir nSlotId = SID_TABLE_INSERT_ROW; 173cdf0e10cSrcweir else 174cdf0e10cSrcweir nSlotId = SID_TABLE_INSERT_COL; 175cdf0e10cSrcweir 176cdf0e10cSrcweir rReq.AppendItem( SfxInt16Item( (sal_uInt16)nSlotId, (sal_uInt16)pDlg->getInsertCount() ) ); 177cdf0e10cSrcweir rReq.AppendItem( SfxBoolItem( SID_TABLE_PARAM_INSERT_AFTER, !pDlg->isInsertBefore() ) ); 178cdf0e10cSrcweir 179cdf0e10cSrcweir rReq.SetSlot( (sal_uInt16)nSlotId ); 180cdf0e10cSrcweir } 181cdf0e10cSrcweir } 182cdf0e10cSrcweir } 183cdf0e10cSrcweir 184cdf0e10cSrcweir xController->Execute( rReq ); 185cdf0e10cSrcweir } 186cdf0e10cSrcweir 187cdf0e10cSrcweir // note: we may be deleted at this point, no more member access possible 188cdf0e10cSrcweir 189cdf0e10cSrcweir switch( rReq.GetSlot() ) 190cdf0e10cSrcweir { 191cdf0e10cSrcweir case SID_ATTR_BORDER: 192cdf0e10cSrcweir case SID_TABLE_MERGE_CELLS: 193cdf0e10cSrcweir case SID_TABLE_SPLIT_CELLS: 194cdf0e10cSrcweir case SID_OPTIMIZE_TABLE: 195cdf0e10cSrcweir case SID_TABLE_DELETE_ROW: 196cdf0e10cSrcweir case SID_TABLE_DELETE_COL: 197cdf0e10cSrcweir case SID_FORMAT_TABLE_DLG: 198cdf0e10cSrcweir case SID_TABLE_INSERT_ROW: 199cdf0e10cSrcweir case SID_TABLE_INSERT_COL: 200cdf0e10cSrcweir { 201cdf0e10cSrcweir pView->AdjustMarkHdl(); 202cdf0e10cSrcweir pBindings->Invalidate( SID_TABLE_DELETE_ROW ); 203cdf0e10cSrcweir pBindings->Invalidate( SID_TABLE_DELETE_COL ); 204cdf0e10cSrcweir pBindings->Invalidate( SID_FRAME_LINESTYLE ); 205cdf0e10cSrcweir pBindings->Invalidate( SID_FRAME_LINECOLOR ); 206cdf0e10cSrcweir pBindings->Invalidate( SID_ATTR_BORDER ); 207cdf0e10cSrcweir pBindings->Invalidate( SID_ATTR_FILL_STYLE ); 208d5370dc8SArmin Le Grand pBindings->Invalidate( SID_ATTR_FILL_TRANSPARENCE ); 209d5370dc8SArmin Le Grand pBindings->Invalidate( SID_ATTR_FILL_FLOATTRANSPARENCE ); 210cdf0e10cSrcweir pBindings->Invalidate( SID_TABLE_MERGE_CELLS ); 211cdf0e10cSrcweir pBindings->Invalidate( SID_TABLE_SPLIT_CELLS ); 212cdf0e10cSrcweir pBindings->Invalidate( SID_OPTIMIZE_TABLE ); 213cdf0e10cSrcweir pBindings->Invalidate( SID_TABLE_VERT_BOTTOM ); 214cdf0e10cSrcweir pBindings->Invalidate( SID_TABLE_VERT_CENTER ); 215cdf0e10cSrcweir pBindings->Invalidate( SID_TABLE_VERT_NONE ); 216cdf0e10cSrcweir break; 217cdf0e10cSrcweir } 218cdf0e10cSrcweir case SID_TABLE_VERT_BOTTOM: 219cdf0e10cSrcweir case SID_TABLE_VERT_CENTER: 220cdf0e10cSrcweir case SID_TABLE_VERT_NONE: 221cdf0e10cSrcweir { 222cdf0e10cSrcweir pBindings->Invalidate( SID_TABLE_VERT_BOTTOM ); 223cdf0e10cSrcweir pBindings->Invalidate( SID_TABLE_VERT_CENTER ); 224cdf0e10cSrcweir pBindings->Invalidate( SID_TABLE_VERT_NONE ); 225cdf0e10cSrcweir break; 226cdf0e10cSrcweir } 227cdf0e10cSrcweir } 228cdf0e10cSrcweir 229cdf0e10cSrcweir pBindings->Invalidate( SID_UNDO ); 230cdf0e10cSrcweir pBindings->Invalidate( SID_REDO ); 231cdf0e10cSrcweir } 232cdf0e10cSrcweir } 233cdf0e10cSrcweir 234cdf0e10cSrcweir } } } 235