xref: /AOO41X/main/sd/source/ui/table/tableobjectbar.cxx (revision d5370dc8b91641fa460c79c207c7018af41d7460)
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>
35cdf0e10cSrcweir #include <svl/whiter.hxx>
36cdf0e10cSrcweir #include <svl/itempool.hxx>
37cdf0e10cSrcweir #include <svx/svdomedia.hxx>
38cdf0e10cSrcweir #include <svx/sdr/contact/viewcontactofsdrmediaobj.hxx>
39cdf0e10cSrcweir #include <svx/svxdlg.hxx>
40cdf0e10cSrcweir #include <svx/dialogs.hrc>
41cdf0e10cSrcweir #include <svx/svxids.hrc>
42cdf0e10cSrcweir 
43cdf0e10cSrcweir #include "app.hrc"
44cdf0e10cSrcweir #include "res_bmp.hrc"
45cdf0e10cSrcweir #include "glob.hrc"
46cdf0e10cSrcweir #include "strings.hrc"
47cdf0e10cSrcweir #include "DrawDocShell.hxx"
48cdf0e10cSrcweir #include "ViewShell.hxx"
49cdf0e10cSrcweir #include "Window.hxx"
50cdf0e10cSrcweir #include "drawview.hxx"
51cdf0e10cSrcweir #include "sdresid.hxx"
52cdf0e10cSrcweir #include "drawdoc.hxx"
53cdf0e10cSrcweir #include "DrawViewShell.hxx"
54cdf0e10cSrcweir 
55cdf0e10cSrcweir #include "tableobjectbar.hxx"
56cdf0e10cSrcweir 
57cdf0e10cSrcweir using namespace sd;
58cdf0e10cSrcweir using namespace sd::ui::table;
59cdf0e10cSrcweir 
60cdf0e10cSrcweir #define TableObjectBar
61cdf0e10cSrcweir #include "sdslots.hxx"
62cdf0e10cSrcweir 
63cdf0e10cSrcweir 
64cdf0e10cSrcweir namespace sd { namespace ui { namespace table {
65cdf0e10cSrcweir 
66cdf0e10cSrcweir /** creates a table object bar for the given ViewShell */
67cdf0e10cSrcweir SfxShell* CreateTableObjectBar( ViewShell& rShell, ::sd::View* pView )
68cdf0e10cSrcweir {
69cdf0e10cSrcweir 	return new TableObjectBar( &rShell, pView );
70cdf0e10cSrcweir }
71cdf0e10cSrcweir 
72cdf0e10cSrcweir 
73cdf0e10cSrcweir /** registers the interfaces from the table ui */
74cdf0e10cSrcweir void RegisterInterfaces(SfxModule* pMod)
75cdf0e10cSrcweir {
76cdf0e10cSrcweir 	TableObjectBar::RegisterInterface(pMod);
77cdf0e10cSrcweir }
78cdf0e10cSrcweir 
79cdf0e10cSrcweir // ------------------
80cdf0e10cSrcweir // - TableObjectBar -
81cdf0e10cSrcweir // ------------------
82cdf0e10cSrcweir 
83cdf0e10cSrcweir TYPEINIT1( TableObjectBar, SfxShell );
84cdf0e10cSrcweir 
85cdf0e10cSrcweir // -----------------------------------------------------------------------------
86cdf0e10cSrcweir 
87cdf0e10cSrcweir SFX_IMPL_INTERFACE( TableObjectBar, SfxShell, SdResId( STR_TABLEOBJECTBARSHELL ) )
88cdf0e10cSrcweir {
89cdf0e10cSrcweir }
90cdf0e10cSrcweir 
91cdf0e10cSrcweir // -----------------------------------------------------------------------------
92cdf0e10cSrcweir 
93cdf0e10cSrcweir TableObjectBar::TableObjectBar( ViewShell* pSdViewShell, ::sd::View* pSdView )
94cdf0e10cSrcweir :	SfxShell( pSdViewShell->GetViewShell() )
95cdf0e10cSrcweir ,	mpView( pSdView )
96cdf0e10cSrcweir ,	mpViewSh( pSdViewShell )
97cdf0e10cSrcweir {
98cdf0e10cSrcweir 	DrawDocShell* pDocShell = mpViewSh->GetDocSh();
99cdf0e10cSrcweir 	if( pDocShell )
100cdf0e10cSrcweir 	{
101cdf0e10cSrcweir 		SetPool( &pDocShell->GetPool() );
102cdf0e10cSrcweir 		SetUndoManager( pDocShell->GetUndoManager() );
103cdf0e10cSrcweir 	}
104cdf0e10cSrcweir 	SetRepeatTarget( mpView );
105cdf0e10cSrcweir 	SetHelpId( SD_IF_SDDRAWTABLEOBJECTBAR );
106cdf0e10cSrcweir 	SetName( String( SdResId( RID_DRAW_TABLE_TOOLBOX ) ) );
107cdf0e10cSrcweir }
108cdf0e10cSrcweir 
109cdf0e10cSrcweir // -----------------------------------------------------------------------------
110cdf0e10cSrcweir 
111cdf0e10cSrcweir TableObjectBar::~TableObjectBar()
112cdf0e10cSrcweir {
113cdf0e10cSrcweir 	SetRepeatTarget( NULL );
114cdf0e10cSrcweir }
115cdf0e10cSrcweir 
116cdf0e10cSrcweir // -----------------------------------------------------------------------------
117cdf0e10cSrcweir 
118cdf0e10cSrcweir void TableObjectBar::GetState( SfxItemSet& rSet )
119cdf0e10cSrcweir {
120cdf0e10cSrcweir 	bool bReadOnly = false;
121cdf0e10cSrcweir 
122cdf0e10cSrcweir 	if( bReadOnly )
123cdf0e10cSrcweir 	{
124cdf0e10cSrcweir         rSet.DisableItem (SID_INSERT_TABLE );
125cdf0e10cSrcweir 	}
126cdf0e10cSrcweir 
127cdf0e10cSrcweir 	if( mpView )
128cdf0e10cSrcweir 	{
129cdf0e10cSrcweir 		rtl::Reference< sdr::SelectionController > xController( mpView->getSelectionController() );
130cdf0e10cSrcweir 		if( xController.is() )
131cdf0e10cSrcweir 		{
132cdf0e10cSrcweir 			xController->GetState( rSet );
133cdf0e10cSrcweir 		}
134cdf0e10cSrcweir 	}
135cdf0e10cSrcweir }
136cdf0e10cSrcweir 
137cdf0e10cSrcweir // -----------------------------------------------------------------------------
138cdf0e10cSrcweir 
139cdf0e10cSrcweir void TableObjectBar::GetAttrState( SfxItemSet& rSet )
140cdf0e10cSrcweir {
141cdf0e10cSrcweir 	DrawViewShell* pDrawViewShell = dynamic_cast< DrawViewShell* >( mpViewSh );
142cdf0e10cSrcweir 	if( pDrawViewShell )
143cdf0e10cSrcweir 		pDrawViewShell->GetAttrState( rSet );
144cdf0e10cSrcweir }
145cdf0e10cSrcweir 
146cdf0e10cSrcweir // -----------------------------------------------------------------------------
147cdf0e10cSrcweir 
148cdf0e10cSrcweir void TableObjectBar::Execute( SfxRequest& rReq )
149cdf0e10cSrcweir {
150cdf0e10cSrcweir 	if( mpView )
151cdf0e10cSrcweir 	{
152cdf0e10cSrcweir 		SdrView* pView = mpView;
153cdf0e10cSrcweir 		SfxBindings* pBindings = &mpViewSh->GetViewFrame()->GetBindings();
154cdf0e10cSrcweir 
155cdf0e10cSrcweir 		rtl::Reference< sdr::SelectionController > xController( mpView->getSelectionController() );
156cdf0e10cSrcweir 		sal_uLong nSlotId = rReq.GetSlot();
157cdf0e10cSrcweir 		if( xController.is() )
158cdf0e10cSrcweir 		{
159cdf0e10cSrcweir 		    switch( nSlotId )
160cdf0e10cSrcweir 		    {
161cdf0e10cSrcweir 		    case SID_TABLE_INSERT_ROW_DLG:
162cdf0e10cSrcweir 		    case SID_TABLE_INSERT_COL_DLG:
163cdf0e10cSrcweir 		    {
164cdf0e10cSrcweir                 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
165cdf0e10cSrcweir 	            ::std::auto_ptr<SvxAbstractInsRowColDlg> pDlg( pFact ? pFact->CreateSvxInsRowColDlg( mpView->GetViewShell()->GetParentWindow(), nSlotId == SID_TABLE_INSERT_COL_DLG, SD_MOD()->GetSlotPool()->GetSlot(nSlotId)->GetCommand()) : 0);
166cdf0e10cSrcweir 
167cdf0e10cSrcweir 		        if( pDlg.get() && (pDlg->Execute() == 1) )
168cdf0e10cSrcweir 		        {
169cdf0e10cSrcweir 		            if( nSlotId == SID_TABLE_INSERT_ROW_DLG )
170cdf0e10cSrcweir 		                nSlotId = SID_TABLE_INSERT_ROW;
171cdf0e10cSrcweir 		            else
172cdf0e10cSrcweir 		                nSlotId = SID_TABLE_INSERT_COL;
173cdf0e10cSrcweir 
174cdf0e10cSrcweir 		            rReq.AppendItem( SfxInt16Item( (sal_uInt16)nSlotId, (sal_uInt16)pDlg->getInsertCount() ) );
175cdf0e10cSrcweir 		            rReq.AppendItem( SfxBoolItem( SID_TABLE_PARAM_INSERT_AFTER, !pDlg->isInsertBefore() ) );
176cdf0e10cSrcweir 
177cdf0e10cSrcweir 		             rReq.SetSlot( (sal_uInt16)nSlotId );
178cdf0e10cSrcweir 		        }
179cdf0e10cSrcweir 		    }
180cdf0e10cSrcweir 		    }
181cdf0e10cSrcweir 
182cdf0e10cSrcweir 			xController->Execute( rReq );
183cdf0e10cSrcweir 		}
184cdf0e10cSrcweir 
185cdf0e10cSrcweir 		// note: we may be deleted at this point, no more member access possible
186cdf0e10cSrcweir 
187cdf0e10cSrcweir 		switch( rReq.GetSlot() )
188cdf0e10cSrcweir 		{
189cdf0e10cSrcweir 		case SID_ATTR_BORDER:
190cdf0e10cSrcweir 		case SID_TABLE_MERGE_CELLS:
191cdf0e10cSrcweir 		case SID_TABLE_SPLIT_CELLS:
192cdf0e10cSrcweir 		case SID_OPTIMIZE_TABLE:
193cdf0e10cSrcweir 		case SID_TABLE_DELETE_ROW:
194cdf0e10cSrcweir 		case SID_TABLE_DELETE_COL:
195cdf0e10cSrcweir 		case SID_FORMAT_TABLE_DLG:
196cdf0e10cSrcweir 		case SID_TABLE_INSERT_ROW:
197cdf0e10cSrcweir 		case SID_TABLE_INSERT_COL:
198cdf0e10cSrcweir 		{
199cdf0e10cSrcweir 			pView->AdjustMarkHdl();
200cdf0e10cSrcweir 			pBindings->Invalidate( SID_TABLE_DELETE_ROW );
201cdf0e10cSrcweir 			pBindings->Invalidate( SID_TABLE_DELETE_COL );
202cdf0e10cSrcweir 			pBindings->Invalidate( SID_FRAME_LINESTYLE );
203cdf0e10cSrcweir 			pBindings->Invalidate( SID_FRAME_LINECOLOR );
204cdf0e10cSrcweir 			pBindings->Invalidate( SID_ATTR_BORDER );
205cdf0e10cSrcweir 			pBindings->Invalidate( SID_ATTR_FILL_STYLE );
206*d5370dc8SArmin Le Grand 			pBindings->Invalidate( SID_ATTR_FILL_TRANSPARENCE );
207*d5370dc8SArmin Le Grand 			pBindings->Invalidate( SID_ATTR_FILL_FLOATTRANSPARENCE );
208cdf0e10cSrcweir 			pBindings->Invalidate( SID_TABLE_MERGE_CELLS );
209cdf0e10cSrcweir 			pBindings->Invalidate( SID_TABLE_SPLIT_CELLS );
210cdf0e10cSrcweir 			pBindings->Invalidate( SID_OPTIMIZE_TABLE );
211cdf0e10cSrcweir 			pBindings->Invalidate( SID_TABLE_VERT_BOTTOM );
212cdf0e10cSrcweir 			pBindings->Invalidate( SID_TABLE_VERT_CENTER );
213cdf0e10cSrcweir 			pBindings->Invalidate( SID_TABLE_VERT_NONE );
214cdf0e10cSrcweir 			break;
215cdf0e10cSrcweir 		}
216cdf0e10cSrcweir 		case SID_TABLE_VERT_BOTTOM:
217cdf0e10cSrcweir 		case SID_TABLE_VERT_CENTER:
218cdf0e10cSrcweir 		case SID_TABLE_VERT_NONE:
219cdf0e10cSrcweir 		{
220cdf0e10cSrcweir 			pBindings->Invalidate( SID_TABLE_VERT_BOTTOM );
221cdf0e10cSrcweir 			pBindings->Invalidate( SID_TABLE_VERT_CENTER );
222cdf0e10cSrcweir 			pBindings->Invalidate( SID_TABLE_VERT_NONE );
223cdf0e10cSrcweir 			break;
224cdf0e10cSrcweir 		}
225cdf0e10cSrcweir 		}
226cdf0e10cSrcweir 
227cdf0e10cSrcweir 		pBindings->Invalidate( SID_UNDO );
228cdf0e10cSrcweir 		pBindings->Invalidate( SID_REDO );
229cdf0e10cSrcweir 	}
230cdf0e10cSrcweir }
231cdf0e10cSrcweir 
232cdf0e10cSrcweir } } }
233