xref: /AOO41X/main/sw/source/ui/shells/tabsh.cxx (revision efeef26f81c84063fb0a91bde3856d4a51172d90)
1*efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*efeef26fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*efeef26fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*efeef26fSAndrew Rist  * distributed with this work for additional information
6*efeef26fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*efeef26fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*efeef26fSAndrew Rist  * "License"); you may not use this file except in compliance
9*efeef26fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*efeef26fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*efeef26fSAndrew Rist  * software distributed under the License is distributed on an
15*efeef26fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*efeef26fSAndrew Rist  * KIND, either express or implied.  See the License for the
17*efeef26fSAndrew Rist  * specific language governing permissions and limitations
18*efeef26fSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*efeef26fSAndrew Rist  *************************************************************/
21*efeef26fSAndrew Rist 
22*efeef26fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir #include <hintids.hxx>
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #ifndef _ZFORLIST_HXX
29cdf0e10cSrcweir #define _ZFORLIST_DECLARE_TABLE
30cdf0e10cSrcweir #include <svl/zforlist.hxx>
31cdf0e10cSrcweir #endif
32cdf0e10cSrcweir #include <svl/stritem.hxx>
33cdf0e10cSrcweir #include <svl/whiter.hxx>
34cdf0e10cSrcweir #include <unotools/moduleoptions.hxx>
35cdf0e10cSrcweir #include <svx/rulritem.hxx>
36cdf0e10cSrcweir #include <svl/srchitem.hxx>
37cdf0e10cSrcweir #include <editeng/lrspitem.hxx>
38cdf0e10cSrcweir #include <editeng/ulspitem.hxx>
39cdf0e10cSrcweir #include <editeng/brshitem.hxx>
40cdf0e10cSrcweir #include <editeng/boxitem.hxx>
41cdf0e10cSrcweir #include <editeng/shaditem.hxx>
42cdf0e10cSrcweir #include <editeng/spltitem.hxx>
43cdf0e10cSrcweir #include <editeng/langitem.hxx>
44cdf0e10cSrcweir #include <editeng/keepitem.hxx>
45cdf0e10cSrcweir #include <editeng/bolnitem.hxx>
46cdf0e10cSrcweir #include <editeng/colritem.hxx>
47cdf0e10cSrcweir #include <editeng/frmdiritem.hxx>
48cdf0e10cSrcweir #include <svx/numinf.hxx>
49cdf0e10cSrcweir #include <svx/svddef.hxx>
50cdf0e10cSrcweir #include <svx/svxdlg.hxx>
51cdf0e10cSrcweir #include <svl/zformat.hxx>
52cdf0e10cSrcweir #include <sfx2/bindings.hxx>
53cdf0e10cSrcweir #include <vcl/msgbox.hxx>
54cdf0e10cSrcweir #include <sfx2/request.hxx>
55cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
56cdf0e10cSrcweir #include <sfx2/objface.hxx>
57cdf0e10cSrcweir 
58cdf0e10cSrcweir 
59cdf0e10cSrcweir #include <fmtornt.hxx>
60cdf0e10cSrcweir #include <fmtclds.hxx>
61cdf0e10cSrcweir #include <fmtlsplt.hxx>
62cdf0e10cSrcweir #include <fmtrowsplt.hxx>
63cdf0e10cSrcweir #include <fmtfsize.hxx>
64cdf0e10cSrcweir #include <swmodule.hxx>
65cdf0e10cSrcweir #include <wrtsh.hxx>
66cdf0e10cSrcweir #include <wview.hxx>
67cdf0e10cSrcweir #include <frmatr.hxx>
68cdf0e10cSrcweir #include <uitool.hxx>
69cdf0e10cSrcweir #include <inputwin.hxx>
70cdf0e10cSrcweir #include <uiitems.hxx>
71cdf0e10cSrcweir #include <usrpref.hxx>
72cdf0e10cSrcweir #include <tabsh.hxx>
73cdf0e10cSrcweir #include "swtablerep.hxx"
74cdf0e10cSrcweir #include <tablemgr.hxx>
75cdf0e10cSrcweir #include <cellatr.hxx>
76cdf0e10cSrcweir #include <frmfmt.hxx>
77cdf0e10cSrcweir #include <swundo.hxx>
78cdf0e10cSrcweir #include <swtable.hxx>
79cdf0e10cSrcweir #include <docsh.hxx>
80cdf0e10cSrcweir #include <tblsel.hxx>
81cdf0e10cSrcweir 
82cdf0e10cSrcweir #include <dialog.hrc>
83cdf0e10cSrcweir 
84cdf0e10cSrcweir 
85cdf0e10cSrcweir 
86cdf0e10cSrcweir //!!! new: insert table
87cdf0e10cSrcweir /*
88cdf0e10cSrcweir #include <svx/htmlmode.hxx>
89cdf0e10cSrcweir #include <modcfg.hxx>
90cdf0e10cSrcweir #include <tblafmt.hxx>
91cdf0e10cSrcweir #include <instable.hxx>
92cdf0e10cSrcweir */
93cdf0e10cSrcweir //!!!
94cdf0e10cSrcweir 
95cdf0e10cSrcweir #ifndef _POPUP_HRC
96cdf0e10cSrcweir #include <popup.hrc>
97cdf0e10cSrcweir #endif
98cdf0e10cSrcweir #ifndef _SHELLS_HRC
99cdf0e10cSrcweir #include <shells.hrc>
100cdf0e10cSrcweir #endif
101cdf0e10cSrcweir #ifndef _TABLE_HRC
102cdf0e10cSrcweir #include <table.hrc>
103cdf0e10cSrcweir #endif
104cdf0e10cSrcweir #include <cmdid.h>
105cdf0e10cSrcweir #ifndef _GLOBALS_HRC
106cdf0e10cSrcweir #include <globals.hrc>
107cdf0e10cSrcweir #endif
108cdf0e10cSrcweir #include <helpid.h>
109cdf0e10cSrcweir #include <unobaseclass.hxx>
110cdf0e10cSrcweir 
111cdf0e10cSrcweir #define SwTableShell
112cdf0e10cSrcweir #include <sfx2/msg.hxx>
113cdf0e10cSrcweir #include <swslots.hxx>
114cdf0e10cSrcweir 
115cdf0e10cSrcweir #include "swabstdlg.hxx"
116cdf0e10cSrcweir #include <table.hrc>
117cdf0e10cSrcweir 
118cdf0e10cSrcweir using namespace ::com::sun::star;
119cdf0e10cSrcweir 
120cdf0e10cSrcweir //-----------------------------------------------------------------------------
121cdf0e10cSrcweir 
122cdf0e10cSrcweir SFX_IMPL_INTERFACE(SwTableShell, SwBaseShell, SW_RES(STR_SHELLNAME_TABLE))
123cdf0e10cSrcweir {
124cdf0e10cSrcweir 	SFX_POPUPMENU_REGISTRATION(SW_RES(MN_TAB_POPUPMENU));
125cdf0e10cSrcweir 	SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_TABLE_TOOLBOX));
126cdf0e10cSrcweir }
127cdf0e10cSrcweir 
128cdf0e10cSrcweir 
129cdf0e10cSrcweir TYPEINIT1(SwTableShell,SwBaseShell)
130cdf0e10cSrcweir 
131cdf0e10cSrcweir /************************************************************************/
132cdf0e10cSrcweir 
133cdf0e10cSrcweir const sal_uInt16 __FAR_DATA aUITableAttrRange[] =
134cdf0e10cSrcweir {
135cdf0e10cSrcweir 	FN_PARAM_TABLE_NAME, 			FN_PARAM_TABLE_NAME,
136cdf0e10cSrcweir 	FN_PARAM_TABLE_HEADLINE, 		FN_PARAM_TABLE_HEADLINE,
137cdf0e10cSrcweir 	FN_PARAM_TABLE_SPACE, 			FN_PARAM_TABLE_SPACE,
138cdf0e10cSrcweir 	FN_TABLE_REP,					FN_TABLE_REP,
139cdf0e10cSrcweir 	SID_RULER_BORDERS,              SID_RULER_BORDERS,
140cdf0e10cSrcweir 	RES_LR_SPACE,					RES_UL_SPACE,
141cdf0e10cSrcweir 	SID_ATTR_BORDER_INNER,			SID_ATTR_BORDER_SHADOW,
142cdf0e10cSrcweir 	RES_BOX, 			   			RES_SHADOW,
143cdf0e10cSrcweir 	RES_BACKGROUND, 	   			RES_BACKGROUND,
144cdf0e10cSrcweir 	SID_BACKGRND_DESTINATION, 		SID_BACKGRND_DESTINATION,
145cdf0e10cSrcweir 	SID_HTML_MODE,					SID_HTML_MODE,
146cdf0e10cSrcweir 	SID_ATTR_BRUSH_ROW, 			SID_ATTR_BRUSH_TABLE,
147cdf0e10cSrcweir 	RES_PAGEDESC,					RES_BREAK,
148cdf0e10cSrcweir 	RES_KEEP,						RES_KEEP,
149cdf0e10cSrcweir 	RES_LAYOUT_SPLIT,				RES_LAYOUT_SPLIT,
150cdf0e10cSrcweir 	FN_TABLE_SET_VERT_ALIGN,		FN_TABLE_SET_VERT_ALIGN,
151cdf0e10cSrcweir     RES_FRAMEDIR,                   RES_FRAMEDIR,
152cdf0e10cSrcweir     RES_ROW_SPLIT,                  RES_ROW_SPLIT,
153cdf0e10cSrcweir     FN_TABLE_BOX_TEXTDIRECTION,		FN_TABLE_BOX_TEXTDIRECTION,
154cdf0e10cSrcweir // --> collapsing borders FME 2005-05-27 #i29550#
155cdf0e10cSrcweir     RES_COLLAPSING_BORDERS,         RES_COLLAPSING_BORDERS,
156cdf0e10cSrcweir // <-- collapsing borders
157cdf0e10cSrcweir 	0
158cdf0e10cSrcweir };
159cdf0e10cSrcweir 
160cdf0e10cSrcweir const sal_uInt16* SwuiGetUITableAttrRange()
161cdf0e10cSrcweir {
162cdf0e10cSrcweir 	return aUITableAttrRange;
163cdf0e10cSrcweir }
164cdf0e10cSrcweir 
165cdf0e10cSrcweir static void lcl_SetAttr( SwWrtShell &rSh, const SfxPoolItem &rItem )
166cdf0e10cSrcweir {
167cdf0e10cSrcweir 	SfxItemSet aSet( rSh.GetView().GetPool(), rItem.Which(), rItem.Which(), 0);
168cdf0e10cSrcweir 	aSet.Put( rItem );
169cdf0e10cSrcweir 	rSh.SetTblAttr( aSet );
170cdf0e10cSrcweir }
171cdf0e10cSrcweir 
172cdf0e10cSrcweir /************************************************************************/
173cdf0e10cSrcweir 
174cdf0e10cSrcweir 
175cdf0e10cSrcweir static SwTableRep*  lcl_TableParamToItemSet( SfxItemSet& rSet, SwWrtShell &rSh )
176cdf0e10cSrcweir {
177cdf0e10cSrcweir 	SwFrmFmt *pFmt = rSh.GetTableFmt();
178cdf0e10cSrcweir 	SwTabCols aCols;
179cdf0e10cSrcweir 	rSh.GetTabCols( aCols );
180cdf0e10cSrcweir 
181cdf0e10cSrcweir 	//Ersteinmal die einfachen Attribute besorgen.
182cdf0e10cSrcweir 	rSet.Put( SfxStringItem( FN_PARAM_TABLE_NAME, pFmt->GetName()));
183cdf0e10cSrcweir     rSet.Put( SfxUInt16Item( FN_PARAM_TABLE_HEADLINE, rSh.GetRowsToRepeat() ) );
184cdf0e10cSrcweir 	rSet.Put( pFmt->GetShadow() );
185cdf0e10cSrcweir 	rSet.Put(SfxUInt16Item(FN_TABLE_SET_VERT_ALIGN, rSh.GetBoxAlign()));
186cdf0e10cSrcweir     rSet.Put( pFmt->GetFrmDir() );
187cdf0e10cSrcweir 
188cdf0e10cSrcweir     SvxULSpaceItem aULSpace( pFmt->GetULSpace() );
189cdf0e10cSrcweir 	rSet.Put( aULSpace );
190cdf0e10cSrcweir 
191cdf0e10cSrcweir 	sal_uInt16  nBackgroundDestination = rSh.GetViewOptions()->GetTblDest();
192cdf0e10cSrcweir 	rSet.Put(SwBackgroundDestinationItem(SID_BACKGRND_DESTINATION, nBackgroundDestination ));
193cdf0e10cSrcweir 	SvxBrushItem aBrush( RES_BACKGROUND );
194cdf0e10cSrcweir // 		rSh.GetBoxBackground(aBrush);
195cdf0e10cSrcweir //	rSet.Put( aBrush );
196cdf0e10cSrcweir 	if(rSh.GetRowBackground(aBrush))
197cdf0e10cSrcweir 		rSet.Put( aBrush, SID_ATTR_BRUSH_ROW );
198cdf0e10cSrcweir 	else
199cdf0e10cSrcweir 		rSet.InvalidateItem(SID_ATTR_BRUSH_ROW);
200cdf0e10cSrcweir 	rSh.GetTabBackground(aBrush);
201cdf0e10cSrcweir 	rSet.Put( aBrush, SID_ATTR_BRUSH_TABLE );
202cdf0e10cSrcweir 
203cdf0e10cSrcweir     // text direction in boxes
204cdf0e10cSrcweir     SvxFrameDirectionItem aBoxDirection( FRMDIR_ENVIRONMENT, RES_FRAMEDIR );
205cdf0e10cSrcweir     if(rSh.GetBoxDirection( aBoxDirection ))
206cdf0e10cSrcweir         rSet.Put(aBoxDirection, FN_TABLE_BOX_TEXTDIRECTION);
207cdf0e10cSrcweir 
208cdf0e10cSrcweir     sal_Bool bTableSel = rSh.IsTableMode();
209cdf0e10cSrcweir 	if(!bTableSel)
210cdf0e10cSrcweir 	{
211cdf0e10cSrcweir 		rSh.StartAllAction();
212cdf0e10cSrcweir 		rSh.Push();
213cdf0e10cSrcweir 		rSh.GetView().GetViewFrame()->GetDispatcher()->Execute( FN_TABLE_SELECT_ALL, sal_False );
214cdf0e10cSrcweir 	}
215cdf0e10cSrcweir     SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
216cdf0e10cSrcweir 
217cdf0e10cSrcweir 		// Tabellenvariante, wenn mehrere Tabellenzellen selektiert
218cdf0e10cSrcweir 	rSh.GetCrsr();					//Damit GetCrsrCnt() auch das Richtige liefert
219cdf0e10cSrcweir 	aBoxInfo.SetTable          ((rSh.IsTableMode() && rSh.GetCrsrCnt() > 1) ||
220cdf0e10cSrcweir 									!bTableSel);
221cdf0e10cSrcweir 		// Abstandsfeld immer anzeigen
222cdf0e10cSrcweir 	aBoxInfo.SetDist           ((sal_Bool) sal_True);
223cdf0e10cSrcweir 		// Minimalgroesse in Tabellen und Absaetzen setzen
224cdf0e10cSrcweir 	aBoxInfo.SetMinDist( !bTableSel || rSh.IsTableMode() ||
225cdf0e10cSrcweir 							rSh.GetSelectionType() &
226cdf0e10cSrcweir 							(nsSelectionType::SEL_TXT | nsSelectionType::SEL_TBL));
227cdf0e10cSrcweir 		// Default-Abstand immer setzen
228cdf0e10cSrcweir 	aBoxInfo.SetDefDist        (MIN_BORDER_DIST);
229cdf0e10cSrcweir 		// Einzelne Linien koennen nur in Tabellen DontCare-Status haben
230cdf0e10cSrcweir 	aBoxInfo.SetValid( VALID_DISABLE, !bTableSel || !rSh.IsTableMode() );
231cdf0e10cSrcweir 
232cdf0e10cSrcweir 	rSet.Put(aBoxInfo);
233cdf0e10cSrcweir 	rSh.GetTabBorders( rSet );
234cdf0e10cSrcweir 
235cdf0e10cSrcweir     //row split
236cdf0e10cSrcweir     SwFmtRowSplit* pSplit = 0;
237cdf0e10cSrcweir     rSh.GetRowSplit(pSplit);
238cdf0e10cSrcweir     if(pSplit)
239cdf0e10cSrcweir     {
240cdf0e10cSrcweir         rSet.Put(*pSplit);
241cdf0e10cSrcweir         delete pSplit;
242cdf0e10cSrcweir     }
243cdf0e10cSrcweir 
244cdf0e10cSrcweir     if(!bTableSel)
245cdf0e10cSrcweir 	{
246cdf0e10cSrcweir 		rSh.ClearMark();
247cdf0e10cSrcweir 		rSh.Pop(sal_False);
248cdf0e10cSrcweir 		rSh.EndAllAction();
249cdf0e10cSrcweir 	}
250cdf0e10cSrcweir 
251cdf0e10cSrcweir 	SwTabCols aTabCols;
252cdf0e10cSrcweir 	rSh.GetTabCols( aTabCols );
253cdf0e10cSrcweir 	SvxColumnItem aColItem;
254cdf0e10cSrcweir 
255cdf0e10cSrcweir 
256cdf0e10cSrcweir 	// Pointer wird nach der Dialogausfuehrung geloescht
257cdf0e10cSrcweir 	SwTableRep* pRep = new SwTableRep( aTabCols, rSh.IsTblComplex());
258cdf0e10cSrcweir 	pRep->SetSpace(aCols.GetRightMax());
259cdf0e10cSrcweir 
260cdf0e10cSrcweir 	sal_uInt16 nPercent = 0;
261cdf0e10cSrcweir 	long nWidth = ::GetTableWidth(pFmt, aCols, &nPercent, &rSh );
262cdf0e10cSrcweir 	// Die Tabellenbreite ist fuer relative Angaben nicht korrekt
263cdf0e10cSrcweir 	if(nPercent)
264cdf0e10cSrcweir 		nWidth = pRep->GetSpace() * nPercent / 100;
265cdf0e10cSrcweir 	sal_uInt16 nAlign = pFmt->GetHoriOrient().GetHoriOrient();
266cdf0e10cSrcweir 	pRep->SetAlign(nAlign);
267cdf0e10cSrcweir 	SvxLRSpaceItem aLRSpace( pFmt->GetLRSpace() );
268cdf0e10cSrcweir 	SwTwips nLeft = aLRSpace.GetLeft();
269cdf0e10cSrcweir 	SwTwips nRight = aLRSpace.GetRight();
270cdf0e10cSrcweir 	SwTwips nDiff = pRep->GetSpace() - nRight - nLeft - nWidth;
271cdf0e10cSrcweir     if(nAlign != text::HoriOrientation::FULL && Abs(nDiff) > 2)
272cdf0e10cSrcweir 	{
273cdf0e10cSrcweir 		SwTwips nLR = pRep->GetSpace() - nWidth;
274cdf0e10cSrcweir 		switch ( nAlign )
275cdf0e10cSrcweir 		{
276cdf0e10cSrcweir             case text::HoriOrientation::CENTER: nLeft = nRight = nLR / 2;
277cdf0e10cSrcweir 			break;
278cdf0e10cSrcweir             case text::HoriOrientation::LEFT: nRight = nLR; nLeft = 0;
279cdf0e10cSrcweir 			break;
280cdf0e10cSrcweir             case text::HoriOrientation::RIGHT: nLeft = nLR, nRight = 0;
281cdf0e10cSrcweir 			break;
282cdf0e10cSrcweir             case text::HoriOrientation::LEFT_AND_WIDTH:
283cdf0e10cSrcweir 				nRight = nLR - nLeft;
284cdf0e10cSrcweir 			break;
285cdf0e10cSrcweir             case text::HoriOrientation::NONE:
286cdf0e10cSrcweir 				if(!nPercent)
287cdf0e10cSrcweir 					nWidth = pRep->GetSpace() - nLeft - nRight;
288cdf0e10cSrcweir 			break;
289cdf0e10cSrcweir 		}
290cdf0e10cSrcweir 	}
291cdf0e10cSrcweir 	pRep->SetLeftSpace(nLeft);
292cdf0e10cSrcweir 	pRep->SetRightSpace(nRight);
293cdf0e10cSrcweir 
294cdf0e10cSrcweir 	pRep->SetWidth(nWidth);
295cdf0e10cSrcweir 	pRep->SetWidthPercent(nPercent);
296cdf0e10cSrcweir 	// sind einzelne Zeilen/Zellen selektiert, wird die Spaltenbearbeitung veraendert
297cdf0e10cSrcweir 	pRep->SetLineSelected(bTableSel && ! rSh.HasWholeTabSelection());
298cdf0e10cSrcweir 	rSet.Put(SwPtrItem(FN_TABLE_REP, pRep));
299cdf0e10cSrcweir 	return pRep;
300cdf0e10cSrcweir }
301cdf0e10cSrcweir 
302cdf0e10cSrcweir /************************************************************************/
303cdf0e10cSrcweir 
304cdf0e10cSrcweir 
305cdf0e10cSrcweir void ItemSetToTableParam( const SfxItemSet& rSet,
306cdf0e10cSrcweir 								SwWrtShell &rSh )
307cdf0e10cSrcweir {
308cdf0e10cSrcweir 	rSh.StartAllAction();
309cdf0e10cSrcweir 	rSh.StartUndo( UNDO_TABLE_ATTR );
310cdf0e10cSrcweir 	const SfxPoolItem* pItem = 0;
311cdf0e10cSrcweir 
312cdf0e10cSrcweir 	SwViewOption aUsrPref( *rSh.GetViewOptions() );
313cdf0e10cSrcweir 	sal_uInt16 nBackgroundDestination = aUsrPref.GetTblDest();
314cdf0e10cSrcweir 	if(SFX_ITEM_SET == rSet.GetItemState(SID_BACKGRND_DESTINATION, sal_False, &pItem))
315cdf0e10cSrcweir 	{
316cdf0e10cSrcweir 		nBackgroundDestination = ((SfxUInt16Item*)pItem)->GetValue();
317cdf0e10cSrcweir 		aUsrPref.SetTblDest((sal_uInt8)nBackgroundDestination);
318cdf0e10cSrcweir 		SW_MOD()->ApplyUsrPref(aUsrPref, &rSh.GetView());
319cdf0e10cSrcweir 	}
320cdf0e10cSrcweir 	sal_Bool bBorder = ( SFX_ITEM_SET == rSet.GetItemState( RES_BOX ) ||
321cdf0e10cSrcweir 			SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_BORDER_INNER ) );
322cdf0e10cSrcweir 	pItem = 0;
323cdf0e10cSrcweir 	sal_Bool bBackground = SFX_ITEM_SET == rSet.GetItemState( RES_BACKGROUND, sal_False, &pItem );
324cdf0e10cSrcweir 	const SfxPoolItem* pRowItem = 0, *pTableItem = 0;
325cdf0e10cSrcweir 	bBackground |= SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_BRUSH_ROW, sal_False, &pRowItem );
326cdf0e10cSrcweir 	bBackground |= SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_BRUSH_TABLE, sal_False, &pTableItem );
327cdf0e10cSrcweir     const SfxPoolItem* pSplit = 0;
328cdf0e10cSrcweir     sal_Bool bRowSplit = SFX_ITEM_SET == rSet.GetItemState( RES_ROW_SPLIT, sal_False, &pSplit );
329cdf0e10cSrcweir     const SfxPoolItem* pBoxDirection = 0;
330cdf0e10cSrcweir     sal_Bool bBoxDirection = SFX_ITEM_SET == rSet.GetItemState( FN_TABLE_BOX_TEXTDIRECTION, sal_False, &pBoxDirection );
331cdf0e10cSrcweir     if( bBackground || bBorder || bRowSplit || bBoxDirection)
332cdf0e10cSrcweir 	{
333cdf0e10cSrcweir 		/*
334cdf0e10cSrcweir 		 Die Umrandung wird auf die vorliegende Selektion angewendet
335cdf0e10cSrcweir 		 Liegt keine Selektion vor, wird die Tabelle vollstaendig selektiert.
336cdf0e10cSrcweir 		 Der Hintergrund wird immer auf den aktuellen Zustand angewendet.
337cdf0e10cSrcweir 		 */
338cdf0e10cSrcweir 
339cdf0e10cSrcweir 		sal_Bool bTableSel = rSh.IsTableMode();
340cdf0e10cSrcweir 		rSh.StartAllAction();
341cdf0e10cSrcweir 
342cdf0e10cSrcweir 		if(bBackground)
343cdf0e10cSrcweir 		{
344cdf0e10cSrcweir 			if(pItem)
345cdf0e10cSrcweir 				rSh.SetBoxBackground( *(const SvxBrushItem*)pItem );
346cdf0e10cSrcweir 			if(pRowItem)
347cdf0e10cSrcweir 			{
348cdf0e10cSrcweir 				SvxBrushItem aBrush(*(const SvxBrushItem*)pRowItem);
349cdf0e10cSrcweir 				aBrush.SetWhich(RES_BACKGROUND);
350cdf0e10cSrcweir 				rSh.SetRowBackground(aBrush);
351cdf0e10cSrcweir 			}
352cdf0e10cSrcweir 			if(pTableItem)
353cdf0e10cSrcweir 			{
354cdf0e10cSrcweir 				SvxBrushItem aBrush(*(const SvxBrushItem*)pTableItem);
355cdf0e10cSrcweir 				aBrush.SetWhich(RES_BACKGROUND);
356cdf0e10cSrcweir 				rSh.SetTabBackground( aBrush );
357cdf0e10cSrcweir 			}
358cdf0e10cSrcweir 		}
359cdf0e10cSrcweir 
360cdf0e10cSrcweir         if(bBoxDirection)
361cdf0e10cSrcweir         {
362cdf0e10cSrcweir             SvxFrameDirectionItem aDirection( FRMDIR_ENVIRONMENT, RES_FRAMEDIR );
363cdf0e10cSrcweir             aDirection.SetValue(static_cast< const SvxFrameDirectionItem* >(pBoxDirection)->GetValue());
364cdf0e10cSrcweir             rSh.SetBoxDirection(aDirection);
365cdf0e10cSrcweir         }
366cdf0e10cSrcweir 
367cdf0e10cSrcweir         if(bBorder || bRowSplit)
368cdf0e10cSrcweir 		{
369cdf0e10cSrcweir 			rSh.Push();
370cdf0e10cSrcweir 			if(!bTableSel)
371cdf0e10cSrcweir 			{
372cdf0e10cSrcweir 				rSh.GetView().GetViewFrame()->GetDispatcher()->Execute( FN_TABLE_SELECT_ALL );
373cdf0e10cSrcweir 			}
374cdf0e10cSrcweir 			if(bBorder)
375cdf0e10cSrcweir                 rSh.SetTabBorders( rSet );
376cdf0e10cSrcweir 
377cdf0e10cSrcweir             if(bRowSplit)
378cdf0e10cSrcweir             {
379cdf0e10cSrcweir                 rSh.SetRowSplit(*static_cast<const SwFmtRowSplit*>(pSplit));
380cdf0e10cSrcweir             }
381cdf0e10cSrcweir 
382cdf0e10cSrcweir             if(!bTableSel)
383cdf0e10cSrcweir 			{
384cdf0e10cSrcweir 				rSh.ClearMark();
385cdf0e10cSrcweir 			}
386cdf0e10cSrcweir 			rSh.Pop(sal_False);
387cdf0e10cSrcweir 		}
388cdf0e10cSrcweir 
389cdf0e10cSrcweir 		rSh.EndAllAction();
390cdf0e10cSrcweir 	}
391cdf0e10cSrcweir 
392cdf0e10cSrcweir 	SwTabCols aTabCols;
393cdf0e10cSrcweir 	sal_Bool bTabCols = sal_False;
394cdf0e10cSrcweir 	sal_Bool bSingleLine = sal_False;
395cdf0e10cSrcweir 	SwTableRep* pRep = 0;
396cdf0e10cSrcweir 	SwFrmFmt *pFmt = rSh.GetTableFmt();
397cdf0e10cSrcweir 	SfxItemSet aSet( rSh.GetAttrPool(), RES_FRMATR_BEGIN, RES_FRMATR_END-1 );
398cdf0e10cSrcweir 	if(SFX_ITEM_SET == rSet.GetItemState( FN_TABLE_REP, sal_False, &pItem ))
399cdf0e10cSrcweir 	{
400cdf0e10cSrcweir 		pRep = (SwTableRep*)((const SwPtrItem*)pItem)->GetValue();
401cdf0e10cSrcweir 
402cdf0e10cSrcweir 		const SwTwips nWidth = pRep->GetWidth();
403cdf0e10cSrcweir         if ( text::HoriOrientation::FULL == pRep->GetAlign() )
404cdf0e10cSrcweir 		{
405cdf0e10cSrcweir 			SwFmtHoriOrient aAttr( pFmt->GetHoriOrient() );
406cdf0e10cSrcweir             aAttr.SetHoriOrient( text::HoriOrientation::FULL );
407cdf0e10cSrcweir 			aSet.Put( aAttr );
408cdf0e10cSrcweir 		}
409cdf0e10cSrcweir 		else
410cdf0e10cSrcweir 		{
411cdf0e10cSrcweir 			SwFmtFrmSize aSz( ATT_VAR_SIZE, nWidth );
412cdf0e10cSrcweir 			if(pRep->GetWidthPercent())
413cdf0e10cSrcweir 			{
414cdf0e10cSrcweir 				aSz.SetWidthPercent( (sal_uInt8)pRep->GetWidthPercent() );
415cdf0e10cSrcweir 			}
416cdf0e10cSrcweir 			aSet.Put(aSz);
417cdf0e10cSrcweir 		}
418cdf0e10cSrcweir 
419cdf0e10cSrcweir 		SvxLRSpaceItem aLRSpace( RES_LR_SPACE );
420cdf0e10cSrcweir 		aLRSpace.SetLeft(pRep->GetLeftSpace());
421cdf0e10cSrcweir 		aLRSpace.SetRight(pRep->GetRightSpace());
422cdf0e10cSrcweir 		aSet.Put( aLRSpace );
423cdf0e10cSrcweir 
424cdf0e10cSrcweir         sal_Int16 eOrient = pRep->GetAlign();
425cdf0e10cSrcweir 		SwFmtHoriOrient aAttr( 0, eOrient );
426cdf0e10cSrcweir 		aSet.Put( aAttr );
427cdf0e10cSrcweir 	// Damit beim recording die Ausrichtung nicht durch die Abstaende ueberschrieben
428cdf0e10cSrcweir 	// wird, darf das Item nur bei manueller Ausrichtung aufgez. werden
429cdf0e10cSrcweir         if(eOrient != text::HoriOrientation::NONE)
430cdf0e10cSrcweir 			((SfxItemSet&)rSet).ClearItem( SID_ATTR_LRSPACE );
431cdf0e10cSrcweir 
432cdf0e10cSrcweir 
433cdf0e10cSrcweir 		if(pRep->HasColsChanged())
434cdf0e10cSrcweir 		{
435cdf0e10cSrcweir 			bTabCols = sal_True;
436cdf0e10cSrcweir 		}
437cdf0e10cSrcweir 	}
438cdf0e10cSrcweir 
439cdf0e10cSrcweir 
440cdf0e10cSrcweir 	if( SFX_ITEM_SET == rSet.GetItemState( FN_PARAM_TABLE_HEADLINE, sal_False, &pItem))
441cdf0e10cSrcweir         rSh.SetRowsToRepeat( ((SfxUInt16Item*)pItem)->GetValue() );
442cdf0e10cSrcweir 
443cdf0e10cSrcweir 	if( SFX_ITEM_SET == rSet.GetItemState( FN_TABLE_SET_VERT_ALIGN, sal_False, &pItem))
444cdf0e10cSrcweir 		rSh.SetBoxAlign(((SfxUInt16Item*)(pItem))->GetValue());
445cdf0e10cSrcweir 
446cdf0e10cSrcweir 	if( SFX_ITEM_SET == rSet.GetItemState( FN_PARAM_TABLE_NAME, sal_False, &pItem ))
447cdf0e10cSrcweir 		rSh.SetTableName( *pFmt, ((const SfxStringItem*)pItem)->GetValue() );
448cdf0e10cSrcweir 
449cdf0e10cSrcweir     // kopiere die ausgesuchten Attribute in den ItemSet
450cdf0e10cSrcweir 	static sal_uInt16 __READONLY_DATA aIds[] =
451cdf0e10cSrcweir 		{
452cdf0e10cSrcweir             RES_PAGEDESC,
453cdf0e10cSrcweir             RES_BREAK,
454cdf0e10cSrcweir             RES_KEEP,
455cdf0e10cSrcweir             RES_LAYOUT_SPLIT,
456cdf0e10cSrcweir             RES_UL_SPACE,
457cdf0e10cSrcweir             RES_SHADOW,
458cdf0e10cSrcweir             RES_FRAMEDIR,
459cdf0e10cSrcweir             // --> collapsing borders FME 2005-05-27 #i29550#
460cdf0e10cSrcweir             RES_COLLAPSING_BORDERS,
461cdf0e10cSrcweir             // <-- collapsing borders
462cdf0e10cSrcweir             0
463cdf0e10cSrcweir 		};
464cdf0e10cSrcweir     for( const sal_uInt16* pIds = aIds; *pIds; ++pIds )
465cdf0e10cSrcweir 		if( SFX_ITEM_SET == rSet.GetItemState( *pIds, sal_False, &pItem))
466cdf0e10cSrcweir 			aSet.Put( *pItem );
467cdf0e10cSrcweir 
468cdf0e10cSrcweir 	if( aSet.Count() )
469cdf0e10cSrcweir 		rSh.SetTblAttr( aSet );
470cdf0e10cSrcweir 
471cdf0e10cSrcweir     if(bTabCols)
472cdf0e10cSrcweir 	{
473cdf0e10cSrcweir 		rSh.GetTabCols( aTabCols );
474cdf0e10cSrcweir 		bSingleLine = pRep->FillTabCols( aTabCols );
475cdf0e10cSrcweir 		rSh.SetTabCols( aTabCols, bSingleLine );
476cdf0e10cSrcweir 	}
477cdf0e10cSrcweir 
478cdf0e10cSrcweir 	rSh.EndUndo( UNDO_TABLE_ATTR );
479cdf0e10cSrcweir 	rSh.EndAllAction();
480cdf0e10cSrcweir }
481cdf0e10cSrcweir 
482cdf0e10cSrcweir /************************************************************************/
483cdf0e10cSrcweir 
484cdf0e10cSrcweir 
485cdf0e10cSrcweir static void lcl_TabGetMaxLineWidth(const SvxBorderLine* pBorderLine, SvxBorderLine& rBorderLine)
486cdf0e10cSrcweir {
487cdf0e10cSrcweir 	if(pBorderLine->GetInWidth() > rBorderLine.GetInWidth())
488cdf0e10cSrcweir 		rBorderLine.SetInWidth(pBorderLine->GetInWidth());
489cdf0e10cSrcweir 
490cdf0e10cSrcweir 	if(pBorderLine->GetOutWidth() > rBorderLine.GetOutWidth())
491cdf0e10cSrcweir 		rBorderLine.SetOutWidth(pBorderLine->GetOutWidth());
492cdf0e10cSrcweir 
493cdf0e10cSrcweir 	if(pBorderLine->GetDistance() > rBorderLine.GetDistance())
494cdf0e10cSrcweir 		rBorderLine.SetDistance(pBorderLine->GetDistance());
495cdf0e10cSrcweir 
496cdf0e10cSrcweir 	rBorderLine.SetColor(pBorderLine->GetColor());
497cdf0e10cSrcweir }
498cdf0e10cSrcweir 
499cdf0e10cSrcweir 
500cdf0e10cSrcweir void SwTableShell::Execute(SfxRequest &rReq)
501cdf0e10cSrcweir {
502cdf0e10cSrcweir     sal_Bool bUseDialog = sal_True;
503cdf0e10cSrcweir 	const SfxItemSet* pArgs = rReq.GetArgs();
504cdf0e10cSrcweir 	SwWrtShell &rSh = GetShell();
505cdf0e10cSrcweir 
506cdf0e10cSrcweir 	//Erstmal die Slots, die keinen FrmMgr benoetigen.
507cdf0e10cSrcweir 	sal_Bool bMore = sal_False;
508cdf0e10cSrcweir 	const SfxPoolItem* pItem = 0;
509cdf0e10cSrcweir 	sal_uInt16 nSlot = rReq.GetSlot();
510cdf0e10cSrcweir 	if(pArgs)
511cdf0e10cSrcweir 		pArgs->GetItemState(GetPool().GetWhich(nSlot), sal_False, &pItem);
512cdf0e10cSrcweir     sal_Bool bCallDone = sal_False;
513cdf0e10cSrcweir     switch ( nSlot )
514cdf0e10cSrcweir 	{
515cdf0e10cSrcweir 		case SID_ATTR_BORDER:
516cdf0e10cSrcweir 		{
517cdf0e10cSrcweir /*			sal_Bool bPopCrsr = sal_False;
518cdf0e10cSrcweir 			if ( !rReq.IsAPI() )
519cdf0e10cSrcweir 			{
520cdf0e10cSrcweir 				//Keine Tabellenselektion -> Aenderung wird auf die gesamte
521cdf0e10cSrcweir 				//Tabelle.
522cdf0e10cSrcweir 				if ( !rSh.IsTableMode() )
523cdf0e10cSrcweir 				{
524cdf0e10cSrcweir 					rSh.StartAction();
525cdf0e10cSrcweir 					bPopCrsr = sal_True;
526cdf0e10cSrcweir 					rSh.Push();
527cdf0e10cSrcweir 					rSh.EnterStdMode();
528cdf0e10cSrcweir 					rSh.MoveTable( fnTableCurr, fnTableStart );
529cdf0e10cSrcweir 					rSh.SttSelect();
530cdf0e10cSrcweir 					rSh.MoveTable( fnTableCurr, fnTableEnd );
531cdf0e10cSrcweir 					rSh.EndSelect();
532cdf0e10cSrcweir 				}
533cdf0e10cSrcweir 			}*/
534cdf0e10cSrcweir 			if(!pArgs)
535cdf0e10cSrcweir 				break;
536cdf0e10cSrcweir 			//Items erzeugen, weil wir sowieso nacharbeiten muessen
537cdf0e10cSrcweir             SvxBoxItem     aBox( RES_BOX );
538cdf0e10cSrcweir 			SfxItemSet aCoreSet( GetPool(),
539cdf0e10cSrcweir 							RES_BOX, RES_BOX,
540cdf0e10cSrcweir                             SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER,
541cdf0e10cSrcweir                             0);
542cdf0e10cSrcweir             SvxBoxInfoItem aCoreInfo( SID_ATTR_BORDER_INNER );
543cdf0e10cSrcweir 			aCoreSet.Put(aCoreInfo);
544cdf0e10cSrcweir 			rSh.GetTabBorders( aCoreSet );
545cdf0e10cSrcweir 			const SvxBoxItem& rCoreBox = (const SvxBoxItem&)
546cdf0e10cSrcweir 													aCoreSet.Get(RES_BOX);
547cdf0e10cSrcweir             const SfxPoolItem *pBoxItem = 0;
548cdf0e10cSrcweir             if ( pArgs->GetItemState(RES_BOX, sal_True, &pBoxItem) == SFX_ITEM_SET )
549cdf0e10cSrcweir 			{
550cdf0e10cSrcweir                 aBox = *(SvxBoxItem*)pBoxItem;
551cdf0e10cSrcweir 				if ( !rReq.IsAPI() )
552cdf0e10cSrcweir 					aBox.SetDistance( Max(rCoreBox.GetDistance(),sal_uInt16(55)) );
553cdf0e10cSrcweir 				else if ( aBox.GetDistance() < MIN_BORDER_DIST )
554cdf0e10cSrcweir 					aBox.SetDistance( Max(rCoreBox.GetDistance(),(sal_uInt16)MIN_BORDER_DIST)  );
555cdf0e10cSrcweir 			}
556cdf0e10cSrcweir 			else
557cdf0e10cSrcweir 				{ASSERT( !this, "Wo ist das Box-Item?" )}
558cdf0e10cSrcweir 
559cdf0e10cSrcweir             //since the drawing layer also supports borders the which id might be a different one
560cdf0e10cSrcweir             SvxBoxInfoItem aInfo( SID_ATTR_BORDER_INNER );
561cdf0e10cSrcweir             if (pArgs->GetItemState(SID_ATTR_BORDER_INNER, sal_True, &pBoxItem) == SFX_ITEM_SET)
562cdf0e10cSrcweir                 aInfo = *(SvxBoxInfoItem*)pBoxItem;
563cdf0e10cSrcweir             else if( pArgs->GetItemState(SDRATTR_TABLE_BORDER_INNER, sal_True, &pBoxItem) == SFX_ITEM_SET )
564cdf0e10cSrcweir             {
565cdf0e10cSrcweir                 aInfo = *(SvxBoxInfoItem*)pBoxItem;
566cdf0e10cSrcweir                 aInfo.SetWhich(SID_ATTR_BORDER_INNER);
567cdf0e10cSrcweir             }
568cdf0e10cSrcweir 
569cdf0e10cSrcweir 			aInfo.SetTable( sal_True );
570cdf0e10cSrcweir 			aInfo.SetValid( VALID_DISABLE, sal_False );
571cdf0e10cSrcweir 
572cdf0e10cSrcweir 
573cdf0e10cSrcweir // Die Attribute aller Linien werden gelesen und das staerkste gewinnt
574cdf0e10cSrcweir 			const SvxBorderLine* pBorderLine;
575cdf0e10cSrcweir 			SvxBorderLine aBorderLine;
576cdf0e10cSrcweir 			if ((pBorderLine = rCoreBox.GetTop()) != NULL)
577cdf0e10cSrcweir 				lcl_TabGetMaxLineWidth(pBorderLine, aBorderLine);
578cdf0e10cSrcweir 			if ((pBorderLine = rCoreBox.GetBottom()) != NULL)
579cdf0e10cSrcweir 				lcl_TabGetMaxLineWidth(pBorderLine, aBorderLine);
580cdf0e10cSrcweir 			if ((pBorderLine = rCoreBox.GetLeft()) != NULL)
581cdf0e10cSrcweir 				lcl_TabGetMaxLineWidth(pBorderLine, aBorderLine);
582cdf0e10cSrcweir 			if ((pBorderLine = rCoreBox.GetRight()) != NULL)
583cdf0e10cSrcweir 				lcl_TabGetMaxLineWidth(pBorderLine, aBorderLine);
584cdf0e10cSrcweir 			if ((pBorderLine = aCoreInfo.GetHori()) != NULL)
585cdf0e10cSrcweir 				lcl_TabGetMaxLineWidth(pBorderLine, aBorderLine);
586cdf0e10cSrcweir 			if ((pBorderLine = aCoreInfo.GetVert()) != NULL)
587cdf0e10cSrcweir 				lcl_TabGetMaxLineWidth(pBorderLine, aBorderLine);
588cdf0e10cSrcweir 
589cdf0e10cSrcweir 			if(aBorderLine.GetOutWidth() == 0)
590cdf0e10cSrcweir 			{
591cdf0e10cSrcweir 				aBorderLine.SetInWidth(0);
592cdf0e10cSrcweir 				aBorderLine.SetOutWidth(DEF_LINE_WIDTH_0);
593cdf0e10cSrcweir 			}
594cdf0e10cSrcweir 
595cdf0e10cSrcweir 			sal_Bool bLine = sal_False;
596cdf0e10cSrcweir 			if ( (pBorderLine = aBox.GetTop()) != NULL)
597cdf0e10cSrcweir 				aBox.SetLine(&aBorderLine, BOX_LINE_TOP), bLine |= sal_True;
598cdf0e10cSrcweir 			if ((pBorderLine = aBox.GetBottom()) != NULL)
599cdf0e10cSrcweir 				aBox.SetLine(&aBorderLine, BOX_LINE_BOTTOM), bLine |= sal_True;
600cdf0e10cSrcweir 			if ((pBorderLine = aBox.GetLeft()) != NULL)
601cdf0e10cSrcweir 				aBox.SetLine(&aBorderLine, BOX_LINE_LEFT), bLine |= sal_True;
602cdf0e10cSrcweir 			if ((pBorderLine = aBox.GetRight()) != NULL)
603cdf0e10cSrcweir 				aBox.SetLine(&aBorderLine, BOX_LINE_RIGHT), bLine |= sal_True;
604cdf0e10cSrcweir 			if ((pBorderLine = aInfo.GetHori()) != NULL)
605cdf0e10cSrcweir 				aInfo.SetLine(&aBorderLine, BOXINFO_LINE_HORI), bLine |= sal_True;
606cdf0e10cSrcweir 			if ((pBorderLine = aInfo.GetVert()) != NULL)
607cdf0e10cSrcweir 				aInfo.SetLine(&aBorderLine, BOXINFO_LINE_VERT), bLine |= sal_True;
608cdf0e10cSrcweir 
609cdf0e10cSrcweir //			if ( bPopCrsr && !bLine )
610cdf0e10cSrcweir //				aBox.SetDistance( 0 );
611cdf0e10cSrcweir 
612cdf0e10cSrcweir 			aCoreSet.Put( aBox  );
613cdf0e10cSrcweir 			aCoreSet.Put( aInfo );
614cdf0e10cSrcweir 			rSh.SetTabBorders( aCoreSet );
615cdf0e10cSrcweir 
616cdf0e10cSrcweir             // we must record the "real" values because otherwise the lines can't be reconstructed on playtime
617cdf0e10cSrcweir             // the coding style of the controller (setting lines with width 0) is not transportable via Query/PutValue in
618cdf0e10cSrcweir             // the SvxBoxItem
619cdf0e10cSrcweir             rReq.AppendItem( aBox );
620cdf0e10cSrcweir             rReq.AppendItem( aInfo );
621cdf0e10cSrcweir             bCallDone = sal_True;
622cdf0e10cSrcweir 
623cdf0e10cSrcweir /*			if ( bPopCrsr )
624cdf0e10cSrcweir 			{
625cdf0e10cSrcweir 				rSh.KillPams();
626cdf0e10cSrcweir 				rSh.Pop(sal_False);
627cdf0e10cSrcweir 				rSh.EndAction();
628cdf0e10cSrcweir 			}*/
629cdf0e10cSrcweir 		}
630cdf0e10cSrcweir 		break;
631cdf0e10cSrcweir 		case FN_INSERT_TABLE:
632cdf0e10cSrcweir 			InsertTable( rReq );
633cdf0e10cSrcweir 		break;
634cdf0e10cSrcweir 		case FN_FORMAT_TABLE_DLG:
635cdf0e10cSrcweir 		{
636cdf0e10cSrcweir             //#127012# get the bindings before the dialog is called
637cdf0e10cSrcweir             // it might happen that this shell is removed after closing the dialog
638cdf0e10cSrcweir             SfxBindings& rBindings = GetView().GetViewFrame()->GetBindings();
639cdf0e10cSrcweir             SfxItemSet aCoreSet( GetPool(), aUITableAttrRange);
640cdf0e10cSrcweir 
641cdf0e10cSrcweir             FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, &rSh.GetView()));
642cdf0e10cSrcweir             SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)));
643cdf0e10cSrcweir             SwTableRep* pTblRep = ::lcl_TableParamToItemSet( aCoreSet, rSh );
644cdf0e10cSrcweir 			SfxAbstractTabDialog * pDlg = NULL;
645cdf0e10cSrcweir             if ( bUseDialog )
646cdf0e10cSrcweir 			{
647cdf0e10cSrcweir                 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
648cdf0e10cSrcweir                 DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
649cdf0e10cSrcweir 
650cdf0e10cSrcweir                 pDlg = pFact->CreateSwTableTabDlg( GetView().GetWindow(), GetPool(), &aCoreSet, &rSh, DLG_FORMAT_TABLE );
651cdf0e10cSrcweir                 DBG_ASSERT(pDlg, "Dialogdiet fail!");
652cdf0e10cSrcweir 			}
653cdf0e10cSrcweir 			aCoreSet.Put(SfxUInt16Item(SID_HTML_MODE, ::GetHtmlMode(GetView().GetDocShell())));
654cdf0e10cSrcweir 			rSh.GetTblAttr(aCoreSet);
655cdf0e10cSrcweir 			// GetTblAttr buegelt den Background ueber!
656cdf0e10cSrcweir 			SvxBrushItem aBrush( RES_BACKGROUND );
657cdf0e10cSrcweir             if(rSh.GetBoxBackground(aBrush))
658cdf0e10cSrcweir                 aCoreSet.Put( aBrush );
659cdf0e10cSrcweir             else
660cdf0e10cSrcweir                 aCoreSet.InvalidateItem( RES_BACKGROUND );
661cdf0e10cSrcweir 
662cdf0e10cSrcweir             if ( (!pDlg && rReq.GetArgs()) || pDlg->Execute() == RET_OK )
663cdf0e10cSrcweir 			{
664cdf0e10cSrcweir                 const SfxItemSet* pOutSet = pDlg ? pDlg->GetOutputItemSet() : rReq.GetArgs();
665cdf0e10cSrcweir                 if ( pDlg )
666cdf0e10cSrcweir                 {
667cdf0e10cSrcweir                     //to record FN_INSERT_TABLE correctly
668cdf0e10cSrcweir                     rReq.SetSlot(FN_FORMAT_TABLE_DLG);
669cdf0e10cSrcweir                     rReq.Done( *pOutSet );
670cdf0e10cSrcweir                 }
671cdf0e10cSrcweir                 ItemSetToTableParam( *pOutSet, rSh );
672cdf0e10cSrcweir 			}
673cdf0e10cSrcweir 
674cdf0e10cSrcweir 			delete pDlg;
675cdf0e10cSrcweir 			delete pTblRep;
676cdf0e10cSrcweir             rBindings.Update(SID_RULER_BORDERS);
677cdf0e10cSrcweir 			rBindings.Update(SID_ATTR_TABSTOP);
678cdf0e10cSrcweir             rBindings.Update(SID_RULER_BORDERS_VERTICAL);
679cdf0e10cSrcweir             rBindings.Update(SID_ATTR_TABSTOP_VERTICAL);
680cdf0e10cSrcweir         }
681cdf0e10cSrcweir 		break;
682cdf0e10cSrcweir         case SID_ATTR_BRUSH:
683cdf0e10cSrcweir         case SID_ATTR_BRUSH_ROW :
684cdf0e10cSrcweir         case SID_ATTR_BRUSH_TABLE :
685cdf0e10cSrcweir             if(rReq.GetArgs())
686cdf0e10cSrcweir                 ItemSetToTableParam(*rReq.GetArgs(), rSh);
687cdf0e10cSrcweir         break;
688cdf0e10cSrcweir 		case FN_NUM_FORMAT_TABLE_DLG:
689cdf0e10cSrcweir 		{
690cdf0e10cSrcweir 			SwView* pView = GetActiveView();
691cdf0e10cSrcweir 			if(pView)
692cdf0e10cSrcweir 			{
693cdf0e10cSrcweir 				FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, pView));
694cdf0e10cSrcweir                 SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)));
695cdf0e10cSrcweir 				SvNumberFormatter* pFormatter = rSh.GetNumberFormatter();
696cdf0e10cSrcweir 				SfxItemSet aCoreSet( GetPool(),
697cdf0e10cSrcweir 								 SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_VALUE,
698cdf0e10cSrcweir 								 SID_ATTR_NUMBERFORMAT_INFO, SID_ATTR_NUMBERFORMAT_INFO,
699cdf0e10cSrcweir 								 0 );
700cdf0e10cSrcweir 
701cdf0e10cSrcweir 				SfxItemSet aBoxSet( *aCoreSet.GetPool(),
702cdf0e10cSrcweir 									RES_BOXATR_FORMAT, RES_BOXATR_FORMAT,
703cdf0e10cSrcweir 									RES_BOXATR_VALUE, RES_BOXATR_VALUE,
704cdf0e10cSrcweir 									0 );
705cdf0e10cSrcweir 				rSh.GetTblBoxFormulaAttrs( aBoxSet );
706cdf0e10cSrcweir 
707cdf0e10cSrcweir 				SfxItemState eState = aBoxSet.GetItemState(RES_BOXATR_FORMAT);
708cdf0e10cSrcweir 				if(eState == SFX_ITEM_DEFAULT)
709cdf0e10cSrcweir 				{
710cdf0e10cSrcweir 					aCoreSet.Put( SfxUInt32Item( SID_ATTR_NUMBERFORMAT_VALUE,
711cdf0e10cSrcweir 					pFormatter->GetFormatIndex(NF_TEXT, LANGUAGE_SYSTEM)));
712cdf0e10cSrcweir 				}
713cdf0e10cSrcweir 				else
714cdf0e10cSrcweir 					aCoreSet.Put( SfxUInt32Item( SID_ATTR_NUMBERFORMAT_VALUE,
715cdf0e10cSrcweir 									((SwTblBoxNumFormat&)aBoxSet.Get(
716cdf0e10cSrcweir 									RES_BOXATR_FORMAT )).GetValue() ));
717cdf0e10cSrcweir 
718cdf0e10cSrcweir 				String sCurText( rSh.GetTableBoxText() );
719cdf0e10cSrcweir 				aCoreSet.Put( SvxNumberInfoItem( pFormatter,
720cdf0e10cSrcweir 									((SwTblBoxValue&)aBoxSet.Get(
721cdf0e10cSrcweir 										RES_BOXATR_VALUE)).GetValue(),
722cdf0e10cSrcweir 									sCurText, SID_ATTR_NUMBERFORMAT_INFO ));
723cdf0e10cSrcweir 
724cdf0e10cSrcweir                 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
725cdf0e10cSrcweir                 DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
726cdf0e10cSrcweir 
727cdf0e10cSrcweir                 SfxAbstractDialog* pDlg = pFact->CreateSfxDialog( GetView().GetWindow(),aCoreSet,
728cdf0e10cSrcweir 					pView->GetViewFrame()->GetFrame().GetFrameInterface(),
729cdf0e10cSrcweir 					RC_DLG_SWNUMFMTDLG );
730cdf0e10cSrcweir                 DBG_ASSERT(pDlg, "Dialogdiet fail!");
731cdf0e10cSrcweir 
732cdf0e10cSrcweir 				if (RET_OK == pDlg->Execute())
733cdf0e10cSrcweir 				{
734cdf0e10cSrcweir                     const SfxPoolItem* pNumberFormatItem = GetView().GetDocShell()->
735cdf0e10cSrcweir 									GetItem( SID_ATTR_NUMBERFORMAT_INFO );
736cdf0e10cSrcweir 
737cdf0e10cSrcweir                     if( pNumberFormatItem && 0 != ((SvxNumberInfoItem*)pNumberFormatItem)->GetDelCount() )
738cdf0e10cSrcweir 					{
739cdf0e10cSrcweir 						const sal_uInt32* pDelArr = ((SvxNumberInfoItem*)
740cdf0e10cSrcweir                                                         pNumberFormatItem)->GetDelArray();
741cdf0e10cSrcweir 
742cdf0e10cSrcweir                         for ( sal_uInt16 i = 0; i < ((SvxNumberInfoItem*)pNumberFormatItem)->GetDelCount(); i++ )
743cdf0e10cSrcweir                             ((SvxNumberInfoItem*)pNumberFormatItem)->
744cdf0e10cSrcweir 							GetNumberFormatter()->DeleteEntry( pDelArr[i] );
745cdf0e10cSrcweir 					}
746cdf0e10cSrcweir 
747cdf0e10cSrcweir 					if( SFX_ITEM_SET == pDlg->GetOutputItemSet()->GetItemState(
748cdf0e10cSrcweir                         SID_ATTR_NUMBERFORMAT_VALUE, sal_False, &pNumberFormatItem ))
749cdf0e10cSrcweir 					{
750cdf0e10cSrcweir                         SfxItemSet aBoxFormatSet( *aCoreSet.GetPool(),
751cdf0e10cSrcweir 									RES_BOXATR_FORMAT, RES_BOXATR_FORMAT );
752cdf0e10cSrcweir                         aBoxFormatSet.Put( SwTblBoxNumFormat(
753cdf0e10cSrcweir                                 ((SfxUInt32Item*)pNumberFormatItem)->GetValue() ));
754cdf0e10cSrcweir                         rSh.SetTblBoxFormulaAttrs( aBoxFormatSet );
755cdf0e10cSrcweir 
756cdf0e10cSrcweir 					}
757cdf0e10cSrcweir 				}
758cdf0e10cSrcweir 				delete pDlg;
759cdf0e10cSrcweir 			}
760cdf0e10cSrcweir 		}
761cdf0e10cSrcweir 		break;
762cdf0e10cSrcweir 		case FN_CALC_TABLE:
763cdf0e10cSrcweir 			rSh.UpdateTable();
764cdf0e10cSrcweir             bCallDone = sal_True;
765cdf0e10cSrcweir         break;
766cdf0e10cSrcweir 		case FN_TABLE_OPTIMAL_HEIGHT:
767cdf0e10cSrcweir 		{
768cdf0e10cSrcweir 			const SwFmtFrmSize aSz;
769cdf0e10cSrcweir 			rSh.SetRowHeight( aSz );
770cdf0e10cSrcweir             bCallDone = sal_True;
771cdf0e10cSrcweir         }
772cdf0e10cSrcweir 		break;
773cdf0e10cSrcweir 		case FN_TABLE_DELETE_COL:
774cdf0e10cSrcweir 			if ( rSh.DeleteCol() && rSh.HasSelection() )
775cdf0e10cSrcweir 				rSh.EnterStdMode();
776cdf0e10cSrcweir             bCallDone = sal_True;
777cdf0e10cSrcweir         break;
778cdf0e10cSrcweir 		case FN_END_TABLE:
779cdf0e10cSrcweir 			rSh.MoveTable( fnTableCurr, fnTableEnd );
780cdf0e10cSrcweir             bCallDone = sal_True;
781cdf0e10cSrcweir         break;
782cdf0e10cSrcweir 		case FN_START_TABLE:
783cdf0e10cSrcweir 			rSh.MoveTable( fnTableCurr, fnTableStart );
784cdf0e10cSrcweir             bCallDone = sal_True;
785cdf0e10cSrcweir         break;
786cdf0e10cSrcweir         case FN_GOTO_NEXT_CELL:
787cdf0e10cSrcweir         {
788cdf0e10cSrcweir             sal_Bool bAppendLine = sal_True;
789cdf0e10cSrcweir             if( pItem )
790cdf0e10cSrcweir                 bAppendLine = ((SfxBoolItem*)pItem)->GetValue();
791cdf0e10cSrcweir             rReq.SetReturnValue( SfxBoolItem( nSlot,
792cdf0e10cSrcweir                                     rSh.GoNextCell( bAppendLine ) ) );
793cdf0e10cSrcweir             bCallDone = sal_True;
794cdf0e10cSrcweir         }
795cdf0e10cSrcweir         break;
796cdf0e10cSrcweir         case FN_GOTO_PREV_CELL:
797cdf0e10cSrcweir             rReq.SetReturnValue( SfxBoolItem( nSlot, rSh.GoPrevCell() ) );
798cdf0e10cSrcweir             bCallDone = sal_True;
799cdf0e10cSrcweir         break;
800cdf0e10cSrcweir 		case FN_TABLE_DELETE_ROW:
801cdf0e10cSrcweir 			if ( rSh.DeleteRow() && rSh.HasSelection() )
802cdf0e10cSrcweir 				rSh.EnterStdMode();
803cdf0e10cSrcweir             bCallDone = sal_True;
804cdf0e10cSrcweir         break;
805cdf0e10cSrcweir 		case FN_TABLE_MERGE_CELLS:
806cdf0e10cSrcweir 			if ( rSh.IsTableMode() )
807cdf0e10cSrcweir 				switch ( rSh.MergeTab() )
808cdf0e10cSrcweir 				{
809cdf0e10cSrcweir 					case TBLMERGE_OK:
810cdf0e10cSrcweir                          bCallDone = sal_True;
811cdf0e10cSrcweir                     //no break;
812cdf0e10cSrcweir 					case TBLMERGE_NOSELECTION:	break;
813cdf0e10cSrcweir 					case TBLMERGE_TOOCOMPLEX:
814cdf0e10cSrcweir 					{
815cdf0e10cSrcweir 						InfoBox aInfoBox( GetView().GetWindow(),
816cdf0e10cSrcweir 									SW_RES( MSG_ERR_TABLE_MERGE ) );
817cdf0e10cSrcweir 						aInfoBox.Execute();
818cdf0e10cSrcweir 						break;
819cdf0e10cSrcweir 					}
820cdf0e10cSrcweir 					default: ASSERT( !this, "unbekannter Returnwert MergeTab.");
821cdf0e10cSrcweir 				}
822cdf0e10cSrcweir 		break;
823cdf0e10cSrcweir 		case FN_TABLE_ADJUST_CELLS:
824cdf0e10cSrcweir         case FN_TABLE_BALANCE_CELLS:
825cdf0e10cSrcweir         {
826cdf0e10cSrcweir             sal_Bool bBalance = (FN_TABLE_BALANCE_CELLS == nSlot);
827cdf0e10cSrcweir             if ( rSh.IsAdjustCellWidthAllowed(bBalance) )
828cdf0e10cSrcweir             {
829cdf0e10cSrcweir                 {
830cdf0e10cSrcweir                     // remove actions to make a valid table selection
831cdf0e10cSrcweir                     UnoActionRemoveContext aRemoveContext(rSh.GetDoc());
832cdf0e10cSrcweir                 }
833cdf0e10cSrcweir                 rSh.AdjustCellWidth(bBalance);
834cdf0e10cSrcweir             }
835cdf0e10cSrcweir             bCallDone = sal_True;
836cdf0e10cSrcweir         }
837cdf0e10cSrcweir 		break;
838cdf0e10cSrcweir 		case FN_TABLE_BALANCE_ROWS:
839cdf0e10cSrcweir 			if ( rSh.BalanceRowHeight(sal_True) )
840cdf0e10cSrcweir 				rSh.BalanceRowHeight(sal_False);
841cdf0e10cSrcweir             bCallDone = sal_True;
842cdf0e10cSrcweir         break;
843cdf0e10cSrcweir 		case FN_TABLE_SELECT_ALL:
844cdf0e10cSrcweir 			rSh.EnterStdMode();
845cdf0e10cSrcweir 			rSh.MoveTable( fnTableCurr, fnTableStart );
846cdf0e10cSrcweir 			rSh.SttSelect();
847cdf0e10cSrcweir 			rSh.MoveTable( fnTableCurr, fnTableEnd );
848cdf0e10cSrcweir 			rSh.EndSelect();
849cdf0e10cSrcweir             bCallDone = sal_True;
850cdf0e10cSrcweir         break;
851cdf0e10cSrcweir 		case FN_TABLE_SELECT_COL:
852cdf0e10cSrcweir 			rSh.EnterStdMode();
853cdf0e10cSrcweir 			rSh.SelectTableCol();
854cdf0e10cSrcweir             bCallDone = sal_True;
855cdf0e10cSrcweir         break;
856cdf0e10cSrcweir 		case FN_TABLE_SELECT_ROW:
857cdf0e10cSrcweir 			rSh.EnterStdMode();
858cdf0e10cSrcweir 			rSh.SelectTableRow();
859cdf0e10cSrcweir             bCallDone = sal_True;
860cdf0e10cSrcweir         break;
861cdf0e10cSrcweir 		case FN_TABLE_SET_READ_ONLY_CELLS:
862cdf0e10cSrcweir 			rSh.ProtectCells();
863cdf0e10cSrcweir 			rSh.ResetSelect( 0, sal_False );
864cdf0e10cSrcweir             bCallDone = sal_True;
865cdf0e10cSrcweir         break;
866cdf0e10cSrcweir 		case FN_TABLE_UNSET_READ_ONLY_CELLS:
867cdf0e10cSrcweir 			rSh.UnProtectCells();
868cdf0e10cSrcweir             bCallDone = sal_True;
869cdf0e10cSrcweir         break;
870cdf0e10cSrcweir 		case SID_AUTOFORMAT:
871cdf0e10cSrcweir 		{
872cdf0e10cSrcweir             SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
873cdf0e10cSrcweir             DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
874cdf0e10cSrcweir 
875cdf0e10cSrcweir             AbstractSwAutoFormatDlg* pDlg = pFact->CreateSwAutoFormatDlg(&GetView().GetViewFrame()->GetWindow(), &rSh , DLG_AUTOFMT_TABLE );
876cdf0e10cSrcweir             DBG_ASSERT(pDlg, "Dialogdiet fail!");
877cdf0e10cSrcweir 			pDlg->Execute();
878cdf0e10cSrcweir 			delete pDlg;
879cdf0e10cSrcweir 		}
880cdf0e10cSrcweir 		break;
881cdf0e10cSrcweir 		case FN_TABLE_SET_ROW_HEIGHT:
882cdf0e10cSrcweir 		{
883cdf0e10cSrcweir             SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
884cdf0e10cSrcweir             DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
885cdf0e10cSrcweir 
886cdf0e10cSrcweir             VclAbstractDialog* pDlg = pFact->CreateVclAbstractDialog( GetView().GetWindow(), rSh, DLG_ROW_HEIGHT );
887cdf0e10cSrcweir             DBG_ASSERT(pDlg, "Dialogdiet fail!");
888cdf0e10cSrcweir 			pDlg->Execute();
889cdf0e10cSrcweir 			delete pDlg;
890cdf0e10cSrcweir 		}
891cdf0e10cSrcweir 		break;
892cdf0e10cSrcweir 		case FN_NUMBER_BULLETS:
893cdf0e10cSrcweir 		case FN_NUM_BULLET_ON:
894cdf0e10cSrcweir 			ASSERT( !this, "Funktion darf zur Zeit nicht gerufen werden." );
895cdf0e10cSrcweir 		break;
896cdf0e10cSrcweir 
897cdf0e10cSrcweir 		case FN_TABLE_INSERT_COL:
898cdf0e10cSrcweir 		case FN_TABLE_INSERT_ROW:
899cdf0e10cSrcweir 		{
900cdf0e10cSrcweir 			sal_Bool bColumn = rReq.GetSlot() == FN_TABLE_INSERT_COL;
901cdf0e10cSrcweir 			sal_uInt16 nCount = 0;
902cdf0e10cSrcweir 			sal_Bool bAfter = sal_True;
903cdf0e10cSrcweir 			if (pItem)
904cdf0e10cSrcweir 			{
905cdf0e10cSrcweir 				nCount = ((const SfxInt16Item* )pItem)->GetValue();
906cdf0e10cSrcweir 				if(SFX_ITEM_SET == pArgs->GetItemState(FN_PARAM_INSERT_AFTER, sal_True, &pItem))
907cdf0e10cSrcweir 					bAfter = ((const SfxBoolItem* )pItem)->GetValue();
908cdf0e10cSrcweir 			}
909cdf0e10cSrcweir 			else if( !rReq.IsAPI() )
910cdf0e10cSrcweir 				++nCount;
911cdf0e10cSrcweir 
912cdf0e10cSrcweir 			if( nCount )
913cdf0e10cSrcweir 			{
914cdf0e10cSrcweir                 // i74180: Table border patch submitted by chensuchun:
915cdf0e10cSrcweir                 // -->get the SvxBoxInfoItem of the table before insert
916cdf0e10cSrcweir                 SfxItemSet aCoreSet( GetPool(), aUITableAttrRange);
917cdf0e10cSrcweir                 ::lcl_TableParamToItemSet( aCoreSet, rSh );
918cdf0e10cSrcweir                 bool bSetInnerBorders = false;
919cdf0e10cSrcweir                 SwUndoId nUndoId = UNDO_EMPTY;
920cdf0e10cSrcweir                 // <--End
921cdf0e10cSrcweir 
922cdf0e10cSrcweir 				if( bColumn )
923cdf0e10cSrcweir                 {
924cdf0e10cSrcweir                     rSh.StartUndo( UNDO_TABLE_INSCOL );
925cdf0e10cSrcweir                     rSh.InsertCol( nCount, bAfter );
926cdf0e10cSrcweir                     bSetInnerBorders = true;
927cdf0e10cSrcweir                     nUndoId = UNDO_TABLE_INSCOL;
928cdf0e10cSrcweir                 }
929cdf0e10cSrcweir                 else if ( !rSh.IsInRepeatedHeadline() )
930cdf0e10cSrcweir                 {
931cdf0e10cSrcweir                     rSh.StartUndo( UNDO_TABLE_INSROW );
932cdf0e10cSrcweir                     rSh.InsertRow( nCount, bAfter );
933cdf0e10cSrcweir                     bSetInnerBorders = true;
934cdf0e10cSrcweir                     nUndoId = UNDO_TABLE_INSROW;
935cdf0e10cSrcweir                 }
936cdf0e10cSrcweir 
937cdf0e10cSrcweir                 // -->after inserting,reset the inner table borders
938cdf0e10cSrcweir                 if ( bSetInnerBorders )
939cdf0e10cSrcweir                 {
940cdf0e10cSrcweir                     const SvxBoxInfoItem aBoxInfo((const SvxBoxInfoItem&)
941cdf0e10cSrcweir                         aCoreSet.Get(SID_ATTR_BORDER_INNER));
942cdf0e10cSrcweir                     SfxItemSet aSet( GetPool(), SID_ATTR_BORDER_INNER,
943cdf0e10cSrcweir                                                 SID_ATTR_BORDER_INNER, 0);
944cdf0e10cSrcweir                     aSet.Put( aBoxInfo );
945cdf0e10cSrcweir                     ItemSetToTableParam( aSet, rSh );
946cdf0e10cSrcweir                     rSh.EndUndo( nUndoId );
947cdf0e10cSrcweir                 }
948cdf0e10cSrcweir                 // <--
949cdf0e10cSrcweir 
950cdf0e10cSrcweir                 bCallDone = sal_True;
951cdf0e10cSrcweir 				break;
952cdf0e10cSrcweir 			}
953cdf0e10cSrcweir 
954cdf0e10cSrcweir 			nSlot = bColumn ? FN_TABLE_INSERT_COL_DLG : FN_TABLE_INSERT_ROW_DLG;
955cdf0e10cSrcweir 		}
956cdf0e10cSrcweir 		// kein break;  bei Count = 0 kommt der Dialog
957cdf0e10cSrcweir 		case FN_TABLE_INSERT_COL_DLG:
958cdf0e10cSrcweir 		case FN_TABLE_INSERT_ROW_DLG:
959cdf0e10cSrcweir 		{
960cdf0e10cSrcweir             const SfxSlot* pSlot = GetStaticInterface()->GetSlot(nSlot);
961cdf0e10cSrcweir 			if ( FN_TABLE_INSERT_ROW_DLG != nSlot || !rSh.IsInRepeatedHeadline())
962cdf0e10cSrcweir 			{
963cdf0e10cSrcweir                 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
964cdf0e10cSrcweir 	            ::std::auto_ptr<SvxAbstractInsRowColDlg> pDlg( pFact ? pFact->CreateSvxInsRowColDlg( GetView().GetWindow(), nSlot == FN_TABLE_INSERT_COL_DLG, pSlot->GetCommand() ) : 0);
965cdf0e10cSrcweir 
966cdf0e10cSrcweir 		        if( pDlg.get() && (pDlg->Execute() == 1) )
967cdf0e10cSrcweir 		        {
968cdf0e10cSrcweir 	                sal_uInt16 nDispatchSlot = (nSlot == FN_TABLE_INSERT_COL_DLG) ? FN_TABLE_INSERT_COL : FN_TABLE_INSERT_ROW;
969cdf0e10cSrcweir                     SfxUInt16Item aCountItem( nDispatchSlot, static_cast< sal_uInt16 >(pDlg->getInsertCount()) );
970cdf0e10cSrcweir 	                SfxBoolItem  aAfter( FN_PARAM_INSERT_AFTER, !pDlg->isInsertBefore() );
971cdf0e10cSrcweir            			SfxViewFrame* pVFrame = GetView().GetViewFrame();
972cdf0e10cSrcweir            			if( pVFrame )
973cdf0e10cSrcweir                         pVFrame->GetDispatcher()->Execute( nDispatchSlot, SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD, &aCountItem, &aAfter, 0L);
974cdf0e10cSrcweir 		        }
975cdf0e10cSrcweir 			}
976cdf0e10cSrcweir 		}
977cdf0e10cSrcweir 		break;
978cdf0e10cSrcweir 		case FN_TABLE_SPLIT_CELLS:
979cdf0e10cSrcweir 		{
980cdf0e10cSrcweir             long nCount=0;
981cdf0e10cSrcweir             sal_Bool bHorizontal=sal_True;
982cdf0e10cSrcweir             sal_Bool bProportional = sal_False;
983cdf0e10cSrcweir             SFX_REQUEST_ARG( rReq, pSplit, SfxInt32Item, FN_TABLE_SPLIT_CELLS, sal_False );
984cdf0e10cSrcweir             SFX_REQUEST_ARG( rReq, pHor, SfxBoolItem, FN_PARAM_1, sal_False );
985cdf0e10cSrcweir             SFX_REQUEST_ARG( rReq, pProp, SfxBoolItem, FN_PARAM_2, sal_False );
986cdf0e10cSrcweir             if ( pSplit )
987cdf0e10cSrcweir             {
988cdf0e10cSrcweir                 nCount = pSplit->GetValue();
989cdf0e10cSrcweir                 if ( pHor )
990cdf0e10cSrcweir                     bHorizontal = pHor->GetValue();
991cdf0e10cSrcweir                 if ( pProp )
992cdf0e10cSrcweir                     bProportional = pProp->GetValue();
993cdf0e10cSrcweir             }
994cdf0e10cSrcweir             else
995cdf0e10cSrcweir             {
996cdf0e10cSrcweir 				SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
997cdf0e10cSrcweir 				if( pFact )
998cdf0e10cSrcweir 				{
999cdf0e10cSrcweir 					const long nMaxVert = rSh.GetAnyCurRect( RECT_FRM ).Width() / MINLAY;
1000cdf0e10cSrcweir 					SvxAbstractSplittTableDialog* pDlg = pFact->CreateSvxSplittTableDialog( GetView().GetWindow(), rSh.IsTableVertical(), nMaxVert, 99 );
1001cdf0e10cSrcweir 					if( pDlg && (pDlg->Execute() == RET_OK) )
1002cdf0e10cSrcweir 					{
1003cdf0e10cSrcweir 						nCount = pDlg->GetCount();
1004cdf0e10cSrcweir 						bHorizontal = pDlg->IsHorizontal();
1005cdf0e10cSrcweir 						bProportional = pDlg->IsProportional();
1006cdf0e10cSrcweir 						rReq.AppendItem( SfxInt32Item( FN_TABLE_SPLIT_CELLS, nCount ) );
1007cdf0e10cSrcweir 						rReq.AppendItem( SfxBoolItem( FN_PARAM_1, bHorizontal ) );
1008cdf0e10cSrcweir 						rReq.AppendItem( SfxBoolItem( FN_PARAM_2, bProportional ) );
1009cdf0e10cSrcweir 					}
1010cdf0e10cSrcweir 	                delete pDlg;
1011cdf0e10cSrcweir 				}
1012cdf0e10cSrcweir             }
1013cdf0e10cSrcweir 
1014cdf0e10cSrcweir             if ( nCount>1 )
1015cdf0e10cSrcweir             {
1016cdf0e10cSrcweir                 rSh.SplitTab(!bHorizontal, static_cast< sal_uInt16 >( nCount-1 ), bProportional );
1017cdf0e10cSrcweir                 bCallDone = sal_True;
1018cdf0e10cSrcweir             }
1019cdf0e10cSrcweir             else
1020cdf0e10cSrcweir                 rReq.Ignore();
1021cdf0e10cSrcweir 		}
1022cdf0e10cSrcweir 		break;
1023cdf0e10cSrcweir 
1024cdf0e10cSrcweir 		case FN_TABLE_SPLIT_TABLE:
1025cdf0e10cSrcweir 		{
1026cdf0e10cSrcweir             SFX_REQUEST_ARG( rReq, pType, SfxUInt16Item, FN_PARAM_1, sal_False );
1027cdf0e10cSrcweir             if( pType )
1028cdf0e10cSrcweir             {
1029cdf0e10cSrcweir                 switch( pType->GetValue() )
1030cdf0e10cSrcweir                 {
1031cdf0e10cSrcweir                     case HEADLINE_NONE    :
1032cdf0e10cSrcweir                     case HEADLINE_BORDERCOPY:
1033cdf0e10cSrcweir                     case HEADLINE_CNTNTCOPY:
1034cdf0e10cSrcweir                     case HEADLINE_BOXATTRCOPY:
1035cdf0e10cSrcweir                     case HEADLINE_BOXATRCOLLCOPY:
1036cdf0e10cSrcweir                         rSh.SplitTable(pType->GetValue()) ;
1037cdf0e10cSrcweir                     default: ;//wrong parameter, do nothing
1038cdf0e10cSrcweir                 }
1039cdf0e10cSrcweir             }
1040cdf0e10cSrcweir             else
1041cdf0e10cSrcweir             {
1042cdf0e10cSrcweir                 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
1043cdf0e10cSrcweir                 DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
1044cdf0e10cSrcweir 
1045cdf0e10cSrcweir                 AbstractSplitTableDialog* pDlg = pFact->CreateSplitTblDialog( GetView().GetWindow(), rSh );
1046cdf0e10cSrcweir                 DBG_ASSERT(pDlg, "Dialogdiet fail!");
1047cdf0e10cSrcweir                 pDlg->Execute();
1048cdf0e10cSrcweir                 rReq.AppendItem( SfxUInt16Item( FN_PARAM_1, pDlg->GetSplitMode() ) );
1049cdf0e10cSrcweir                 delete pDlg;
1050cdf0e10cSrcweir                 bCallDone = sal_True;
1051cdf0e10cSrcweir             }
1052cdf0e10cSrcweir 		}
1053cdf0e10cSrcweir 		break;
1054cdf0e10cSrcweir 
1055cdf0e10cSrcweir 		case FN_TABLE_MERGE_TABLE:
1056cdf0e10cSrcweir 		{
1057cdf0e10cSrcweir 			sal_Bool bPrev = rSh.CanMergeTable( sal_True );
1058cdf0e10cSrcweir 			sal_Bool bNext = rSh.CanMergeTable( sal_False );
1059cdf0e10cSrcweir 
1060cdf0e10cSrcweir 			if( bPrev && bNext )
1061cdf0e10cSrcweir 			{
1062cdf0e10cSrcweir                 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
1063cdf0e10cSrcweir                 DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
1064cdf0e10cSrcweir                 VclAbstractDialog* pDlg = pFact->CreateSwVclDialog( DLG_MERGE_TABLE, GetView().GetWindow(), bPrev );
1065cdf0e10cSrcweir                 DBG_ASSERT(pDlg, "dialogdiet pDlg fail!");
1066cdf0e10cSrcweir 				if( RET_OK != pDlg->Execute())
1067cdf0e10cSrcweir 					bPrev = bNext = sal_False;
1068cdf0e10cSrcweir 				delete pDlg;
1069cdf0e10cSrcweir 			}
1070cdf0e10cSrcweir 
1071cdf0e10cSrcweir 			if( bPrev || bNext )
1072cdf0e10cSrcweir 				rSh.MergeTable( bPrev );
1073cdf0e10cSrcweir 		}
1074cdf0e10cSrcweir 		break;
1075cdf0e10cSrcweir 
1076cdf0e10cSrcweir 		case FN_TABLE_MODE_FIX       :
1077cdf0e10cSrcweir 		case FN_TABLE_MODE_FIX_PROP  :
1078cdf0e10cSrcweir 		case FN_TABLE_MODE_VARIABLE	 :
1079cdf0e10cSrcweir 		{
1080cdf0e10cSrcweir 			rSh.SetTblChgMode( ( FN_TABLE_MODE_FIX == nSlot ? TBLFIX_CHGABS
1081cdf0e10cSrcweir 									: FN_TABLE_MODE_FIX_PROP == nSlot
1082cdf0e10cSrcweir 										? TBLFIX_CHGPROP
1083cdf0e10cSrcweir 										: TBLVAR_CHGABS ) );
1084cdf0e10cSrcweir 
1085cdf0e10cSrcweir 			SfxBindings& rBind = GetView().GetViewFrame()->GetBindings();
1086cdf0e10cSrcweir 			static sal_uInt16 __READONLY_DATA aInva[] =
1087cdf0e10cSrcweir 							{   FN_TABLE_MODE_FIX,
1088cdf0e10cSrcweir 								FN_TABLE_MODE_FIX_PROP,
1089cdf0e10cSrcweir 								FN_TABLE_MODE_VARIABLE,
1090cdf0e10cSrcweir 								0
1091cdf0e10cSrcweir 							};
1092cdf0e10cSrcweir 			rBind.Invalidate( aInva );
1093cdf0e10cSrcweir             bCallDone = sal_True;
1094cdf0e10cSrcweir         }
1095cdf0e10cSrcweir 		break;
1096cdf0e10cSrcweir 		case FN_TABLE_AUTOSUM:
1097cdf0e10cSrcweir 		{
1098cdf0e10cSrcweir 			SfxViewFrame* pVFrame = GetView().GetViewFrame();
1099cdf0e10cSrcweir 			pVFrame->GetDispatcher()->Execute(FN_EDIT_FORMULA, SFX_CALLMODE_SYNCHRON);
1100cdf0e10cSrcweir 			const sal_uInt16 nId = SwInputChild::GetChildWindowId();
1101cdf0e10cSrcweir 			SwInputChild* pChildWin = (SwInputChild*)pVFrame->
1102cdf0e10cSrcweir 												GetChildWindow( nId );
1103cdf0e10cSrcweir 			String sSum;
1104cdf0e10cSrcweir 			GetShell().GetAutoSum(sSum);
1105cdf0e10cSrcweir 			if( pChildWin )
1106cdf0e10cSrcweir 				pChildWin->SetFormula( sSum );
1107cdf0e10cSrcweir 
1108cdf0e10cSrcweir 		}
1109cdf0e10cSrcweir 		break;
1110cdf0e10cSrcweir         case FN_TABLE_HEADLINE_REPEAT:
1111cdf0e10cSrcweir             if(0 != rSh.GetRowsToRepeat())
1112cdf0e10cSrcweir                 rSh.SetRowsToRepeat( 0 );
1113cdf0e10cSrcweir             else
1114cdf0e10cSrcweir                 rSh.SetRowsToRepeat(rSh.GetRowSelectionFromTop());
1115cdf0e10cSrcweir         break;
1116cdf0e10cSrcweir         case FN_TABLE_SELECT_CELL   :
1117cdf0e10cSrcweir             rSh.SelectTableCell();
1118cdf0e10cSrcweir         break;
1119cdf0e10cSrcweir         case FN_TABLE_DELETE_TABLE  :
1120cdf0e10cSrcweir         {
1121cdf0e10cSrcweir             rSh.StartAction();
1122cdf0e10cSrcweir             rSh.StartUndo();
1123cdf0e10cSrcweir             rSh.GetView().GetViewFrame()->GetDispatcher()->Execute(FN_TABLE_SELECT_ALL);
1124cdf0e10cSrcweir             rSh.DeleteRow();
1125cdf0e10cSrcweir             rSh.EndUndo();
1126cdf0e10cSrcweir             rSh.EndAction();
1127cdf0e10cSrcweir         }
1128cdf0e10cSrcweir         //'this' is already destroyed
1129cdf0e10cSrcweir         return;
1130cdf0e10cSrcweir         //break;
1131cdf0e10cSrcweir 		default:
1132cdf0e10cSrcweir 			bMore = sal_True;
1133cdf0e10cSrcweir 	}
1134cdf0e10cSrcweir 
1135cdf0e10cSrcweir 	if ( !bMore )
1136cdf0e10cSrcweir 	{
1137cdf0e10cSrcweir         if(bCallDone)
1138cdf0e10cSrcweir             rReq.Done();
1139cdf0e10cSrcweir         return;
1140cdf0e10cSrcweir 	}
1141cdf0e10cSrcweir 	else
1142cdf0e10cSrcweir 		bMore = sal_False;
1143cdf0e10cSrcweir 	//Jetzt die Slots, die direkt auf dem TableFmt arbeiten.
1144cdf0e10cSrcweir 	SwFrmFmt *pFmt = rSh.GetTableFmt();
1145cdf0e10cSrcweir 	switch ( nSlot )
1146cdf0e10cSrcweir 	{
1147cdf0e10cSrcweir 		case SID_ATTR_ULSPACE:
1148cdf0e10cSrcweir 		{
1149cdf0e10cSrcweir 			if(pItem)
1150cdf0e10cSrcweir 			{
1151cdf0e10cSrcweir 				SvxULSpaceItem aULSpace( *(const SvxULSpaceItem*)pItem );
1152cdf0e10cSrcweir 				aULSpace.SetWhich( RES_UL_SPACE );
1153cdf0e10cSrcweir 				::lcl_SetAttr( rSh, aULSpace );
1154cdf0e10cSrcweir 			}
1155cdf0e10cSrcweir 		}
1156cdf0e10cSrcweir 			break;
1157cdf0e10cSrcweir 
1158cdf0e10cSrcweir 		case SID_ATTR_LRSPACE:
1159cdf0e10cSrcweir 		{
1160cdf0e10cSrcweir 			if(pItem)
1161cdf0e10cSrcweir 			{
1162cdf0e10cSrcweir 				SfxItemSet aSet( GetPool(), RES_LR_SPACE, RES_LR_SPACE,
1163cdf0e10cSrcweir 											RES_HORI_ORIENT, RES_HORI_ORIENT, 0 );
1164cdf0e10cSrcweir 				SvxLRSpaceItem aLRSpace( *(const SvxLRSpaceItem*)pItem );
1165cdf0e10cSrcweir 				aLRSpace.SetWhich( RES_LR_SPACE );
1166cdf0e10cSrcweir 				aSet.Put( aLRSpace );
1167cdf0e10cSrcweir 				SwFmtHoriOrient aHori( pFmt->GetHoriOrient() );
1168cdf0e10cSrcweir                 aHori.SetHoriOrient( text::HoriOrientation::NONE );
1169cdf0e10cSrcweir 				aSet.Put( aLRSpace );
1170cdf0e10cSrcweir 				rSh.SetTblAttr( aSet );
1171cdf0e10cSrcweir 			}
1172cdf0e10cSrcweir 		}
1173cdf0e10cSrcweir 		break;
1174cdf0e10cSrcweir // der letzte case-Zweig der noch einen TabellenManager braucht!!
1175cdf0e10cSrcweir 		case FN_TABLE_SET_COL_WIDTH:
1176cdf0e10cSrcweir 		{
1177cdf0e10cSrcweir 			SwTableFUNC aMgr( &rSh, sal_False);
1178cdf0e10cSrcweir 			aMgr.ColWidthDlg(GetView().GetWindow());
1179cdf0e10cSrcweir 		}
1180cdf0e10cSrcweir 		break;
1181cdf0e10cSrcweir         case FN_TABLE_VERT_NONE:
1182cdf0e10cSrcweir 		case FN_TABLE_VERT_CENTER:
1183cdf0e10cSrcweir 		case FN_TABLE_VERT_BOTTOM:
1184cdf0e10cSrcweir 		{
1185cdf0e10cSrcweir 			sal_uInt16 nAlign = nSlot == FN_TABLE_VERT_NONE ?
1186cdf0e10cSrcweir                                 text::VertOrientation::NONE :
1187cdf0e10cSrcweir 									nSlot == FN_TABLE_VERT_CENTER ?
1188cdf0e10cSrcweir                                         text::VertOrientation::CENTER : text::VertOrientation::BOTTOM;
1189cdf0e10cSrcweir 			rSh.SetBoxAlign(nAlign);
1190cdf0e10cSrcweir             bCallDone = sal_True;
1191cdf0e10cSrcweir         }
1192cdf0e10cSrcweir 		break;
1193cdf0e10cSrcweir 
1194cdf0e10cSrcweir 		case SID_ATTR_PARA_SPLIT:
1195cdf0e10cSrcweir 			if ( pItem )
1196cdf0e10cSrcweir 			{
1197cdf0e10cSrcweir 				SwFmtLayoutSplit aSplit( ((const SvxFmtSplitItem*)pItem)->GetValue());
1198cdf0e10cSrcweir 				SfxItemSet aSet(GetPool(),  RES_LAYOUT_SPLIT, RES_LAYOUT_SPLIT, 0 );
1199cdf0e10cSrcweir 				aSet.Put(aSplit);
1200cdf0e10cSrcweir 				rSh.SetTblAttr(aSet);
1201cdf0e10cSrcweir 			}
1202cdf0e10cSrcweir 		break;
1203cdf0e10cSrcweir 
1204cdf0e10cSrcweir 		case SID_ATTR_PARA_KEEP:
1205cdf0e10cSrcweir 			if ( pItem )
1206cdf0e10cSrcweir 			{
1207cdf0e10cSrcweir 				SvxFmtKeepItem aKeep( *(const SvxFmtKeepItem*)pItem );
1208cdf0e10cSrcweir 				aKeep.SetWhich( RES_KEEP );
1209cdf0e10cSrcweir 				SfxItemSet aSet(GetPool(),  RES_KEEP, RES_KEEP, 0 );
1210cdf0e10cSrcweir 				aSet.Put(aKeep);
1211cdf0e10cSrcweir 				rSh.SetTblAttr(aSet);
1212cdf0e10cSrcweir 			}
1213cdf0e10cSrcweir 		break;
1214cdf0e10cSrcweir         case FN_TABLE_ROW_SPLIT :
1215cdf0e10cSrcweir         {
1216cdf0e10cSrcweir             const SfxBoolItem* pBool = static_cast<const SfxBoolItem*>(pItem);
1217cdf0e10cSrcweir             SwFmtRowSplit* pSplit = 0;
1218cdf0e10cSrcweir             if(!pBool)
1219cdf0e10cSrcweir             {
1220cdf0e10cSrcweir                 rSh.GetRowSplit(pSplit);
1221cdf0e10cSrcweir                 if(pSplit)
1222cdf0e10cSrcweir                     pSplit->SetValue(!pSplit->GetValue());
1223cdf0e10cSrcweir                 else
1224cdf0e10cSrcweir                    pSplit = new SwFmtRowSplit(sal_True);
1225cdf0e10cSrcweir             }
1226cdf0e10cSrcweir             else
1227cdf0e10cSrcweir             {
1228cdf0e10cSrcweir                 pSplit = new SwFmtRowSplit(pBool->GetValue());
1229cdf0e10cSrcweir             }
1230cdf0e10cSrcweir             rSh.SetRowSplit( *pSplit );
1231cdf0e10cSrcweir             delete pSplit;
1232cdf0e10cSrcweir         }
1233cdf0e10cSrcweir         break;
1234cdf0e10cSrcweir 
1235cdf0e10cSrcweir 		default:
1236cdf0e10cSrcweir 			ASSERT( !this, "falscher Dispatcher" );
1237cdf0e10cSrcweir 			return;
1238cdf0e10cSrcweir 	}
1239cdf0e10cSrcweir     if(bCallDone)
1240cdf0e10cSrcweir         rReq.Done();
1241cdf0e10cSrcweir }
1242cdf0e10cSrcweir /*--------------------------------------------------------------------
1243cdf0e10cSrcweir 	Beschreibung:
1244cdf0e10cSrcweir  --------------------------------------------------------------------*/
1245cdf0e10cSrcweir 
1246cdf0e10cSrcweir void SwTableShell::GetState(SfxItemSet &rSet)
1247cdf0e10cSrcweir {
1248cdf0e10cSrcweir 	SfxWhichIter aIter( rSet );
1249cdf0e10cSrcweir 	SwWrtShell &rSh = GetShell();
1250cdf0e10cSrcweir 	SwFrmFmt *pFmt = rSh.GetTableFmt();
1251cdf0e10cSrcweir     // os #124829# crash report: in case of an invalid shell selection return immediately
1252cdf0e10cSrcweir     if(!pFmt)
1253cdf0e10cSrcweir         return;
1254cdf0e10cSrcweir 	sal_uInt16 nSlot = aIter.FirstWhich();
1255cdf0e10cSrcweir 	while ( nSlot )
1256cdf0e10cSrcweir 	{
1257cdf0e10cSrcweir 		switch ( nSlot )
1258cdf0e10cSrcweir 		{
1259cdf0e10cSrcweir 			case FN_TABLE_MERGE_CELLS:
1260cdf0e10cSrcweir 				if ( !rSh.IsTableMode() )
1261cdf0e10cSrcweir 					rSet.DisableItem(FN_TABLE_MERGE_CELLS);
1262cdf0e10cSrcweir 			break;
1263cdf0e10cSrcweir 			case FN_TABLE_ADJUST_CELLS:
1264cdf0e10cSrcweir 				if ( !rSh.IsAdjustCellWidthAllowed() )
1265cdf0e10cSrcweir 					rSet.DisableItem(FN_TABLE_ADJUST_CELLS);
1266cdf0e10cSrcweir 			break;
1267cdf0e10cSrcweir 
1268cdf0e10cSrcweir 			case FN_TABLE_BALANCE_CELLS:
1269cdf0e10cSrcweir 				if ( !rSh.IsAdjustCellWidthAllowed(sal_True) )
1270cdf0e10cSrcweir 					rSet.DisableItem(FN_TABLE_BALANCE_CELLS);
1271cdf0e10cSrcweir 			break;
1272cdf0e10cSrcweir 
1273cdf0e10cSrcweir 			case FN_TABLE_BALANCE_ROWS:
1274cdf0e10cSrcweir 				if ( !rSh.BalanceRowHeight(sal_True) )
1275cdf0e10cSrcweir 					rSet.DisableItem(FN_TABLE_BALANCE_ROWS);
1276cdf0e10cSrcweir 			break;
1277cdf0e10cSrcweir             case FN_OPTIMIZE_TABLE:
1278cdf0e10cSrcweir                 if ( !rSh.IsTableMode() &&
1279cdf0e10cSrcweir                         !rSh.IsAdjustCellWidthAllowed() &&
1280cdf0e10cSrcweir                         !rSh.IsAdjustCellWidthAllowed(sal_True) &&
1281cdf0e10cSrcweir                         !rSh.BalanceRowHeight(sal_True) )
1282cdf0e10cSrcweir                     rSet.DisableItem(FN_OPTIMIZE_TABLE);
1283cdf0e10cSrcweir             break;
1284cdf0e10cSrcweir 			case SID_INSERT_DIAGRAM:
1285cdf0e10cSrcweir 				{
1286cdf0e10cSrcweir 					SvtModuleOptions aMOpt;
1287cdf0e10cSrcweir 					if ( !aMOpt.IsMath() || rSh.IsTblComplexForChart() )
1288cdf0e10cSrcweir 						rSet.DisableItem(nSlot);
1289cdf0e10cSrcweir 				}
1290cdf0e10cSrcweir 				break;
1291cdf0e10cSrcweir 
1292cdf0e10cSrcweir 			case FN_INSERT_TABLE:
1293cdf0e10cSrcweir 				// Irgendeinen Wert "putten", damit Controller enabled bleibt.
1294cdf0e10cSrcweir 				// Statt "Insert:Table" erscheint dann "Format:Table".
1295cdf0e10cSrcweir //				rSet.Put(SfxUInt16Item(nSlot, 1));
1296cdf0e10cSrcweir 				break;
1297cdf0e10cSrcweir 
1298cdf0e10cSrcweir 			case FN_TABLE_OPTIMAL_HEIGHT:
1299cdf0e10cSrcweir 			{
1300cdf0e10cSrcweir 				//Disablen wenn bereits auto-Hoehe eingestellt ist.
1301cdf0e10cSrcweir 				SwFmtFrmSize *pSz;
1302cdf0e10cSrcweir 				rSh.GetRowHeight( pSz );
1303cdf0e10cSrcweir 				if ( pSz )
1304cdf0e10cSrcweir 				{
1305cdf0e10cSrcweir                     if ( ATT_VAR_SIZE == pSz->GetHeightSizeType() )
1306cdf0e10cSrcweir 						rSet.DisableItem( nSlot );
1307cdf0e10cSrcweir 					delete pSz;
1308cdf0e10cSrcweir 				}
1309cdf0e10cSrcweir 			}
1310cdf0e10cSrcweir 			break;
1311cdf0e10cSrcweir 			case FN_TABLE_INSERT_ROW:
1312cdf0e10cSrcweir 			case FN_TABLE_INSERT_ROW_DLG:
1313cdf0e10cSrcweir 			{
1314cdf0e10cSrcweir 				if ( rSh.IsInRepeatedHeadline() )
1315cdf0e10cSrcweir 					rSet.DisableItem( nSlot );
1316cdf0e10cSrcweir 			}
1317cdf0e10cSrcweir 			break;
1318cdf0e10cSrcweir 			case RES_LR_SPACE:
1319cdf0e10cSrcweir 				rSet.Put(pFmt->GetLRSpace());
1320cdf0e10cSrcweir 			break;
1321cdf0e10cSrcweir 			case RES_UL_SPACE:
1322cdf0e10cSrcweir                 rSet.Put(pFmt->GetULSpace());
1323cdf0e10cSrcweir 			break;
1324cdf0e10cSrcweir 			case FN_TABLE_VERT_NONE:
1325cdf0e10cSrcweir 			case FN_TABLE_VERT_CENTER:
1326cdf0e10cSrcweir 			case FN_TABLE_VERT_BOTTOM:
1327cdf0e10cSrcweir 			{
1328cdf0e10cSrcweir 				sal_uInt16 nAlign = rSh.GetBoxAlign();
1329cdf0e10cSrcweir                 sal_Bool bSet = (nSlot == FN_TABLE_VERT_NONE && nAlign == text::VertOrientation::NONE) ||
1330cdf0e10cSrcweir                             (nSlot == FN_TABLE_VERT_CENTER && nAlign == text::VertOrientation::CENTER) ||
1331cdf0e10cSrcweir                             (nSlot == FN_TABLE_VERT_BOTTOM && nAlign == text::VertOrientation::BOTTOM);
1332cdf0e10cSrcweir 				rSet.Put(SfxBoolItem(nSlot, bSet));
1333cdf0e10cSrcweir 			}
1334cdf0e10cSrcweir 			break;
1335cdf0e10cSrcweir 
1336cdf0e10cSrcweir 			case FN_TABLE_MODE_FIX       :
1337cdf0e10cSrcweir 			case FN_TABLE_MODE_FIX_PROP  :
1338cdf0e10cSrcweir 			case FN_TABLE_MODE_VARIABLE	 :
1339cdf0e10cSrcweir 				{
1340cdf0e10cSrcweir                     TblChgMode nMode = rSh.GetTblChgMode();
1341cdf0e10cSrcweir 					sal_Bool bSet = (nSlot == FN_TABLE_MODE_FIX && nMode == TBLFIX_CHGABS) ||
1342cdf0e10cSrcweir 							(nSlot == FN_TABLE_MODE_FIX_PROP && nMode == TBLFIX_CHGPROP) ||
1343cdf0e10cSrcweir 							(nSlot == FN_TABLE_MODE_VARIABLE && nMode == TBLVAR_CHGABS);
1344cdf0e10cSrcweir 					rSet.Put(SfxBoolItem(nSlot, bSet));
1345cdf0e10cSrcweir 				}
1346cdf0e10cSrcweir 			break;
1347cdf0e10cSrcweir 
1348cdf0e10cSrcweir 			case SID_ATTR_PARA_SPLIT:
1349cdf0e10cSrcweir 				rSet.Put( pFmt->GetKeep() );
1350cdf0e10cSrcweir 			break;
1351cdf0e10cSrcweir 
1352cdf0e10cSrcweir 			case SID_ATTR_PARA_KEEP:
1353cdf0e10cSrcweir 				rSet.Put( pFmt->GetLayoutSplit() );
1354cdf0e10cSrcweir 			break;
1355cdf0e10cSrcweir 			case FN_TABLE_SPLIT_TABLE:
1356cdf0e10cSrcweir 			{
1357cdf0e10cSrcweir 				if ( rSh.IsInHeadline() )
1358cdf0e10cSrcweir 					rSet.DisableItem( nSlot );
1359cdf0e10cSrcweir 			}
1360cdf0e10cSrcweir 			break;
1361cdf0e10cSrcweir 			case FN_TABLE_MERGE_TABLE:
1362cdf0e10cSrcweir 			{
1363cdf0e10cSrcweir 				sal_Bool bAsk;
1364cdf0e10cSrcweir 				if( !rSh.CanMergeTable( sal_True, &bAsk ))
1365cdf0e10cSrcweir 					rSet.DisableItem( nSlot );
1366cdf0e10cSrcweir 			}
1367cdf0e10cSrcweir 			break;
1368cdf0e10cSrcweir 
1369cdf0e10cSrcweir             case FN_TABLE_DELETE_ROW:
1370cdf0e10cSrcweir                 {
1371cdf0e10cSrcweir                     SwSelBoxes aBoxes;
1372cdf0e10cSrcweir                     ::GetTblSel( rSh, aBoxes, nsSwTblSearchType::TBLSEARCH_ROW );
1373cdf0e10cSrcweir                     if( ::HasProtectedCells( aBoxes ))
1374cdf0e10cSrcweir                         rSet.DisableItem( nSlot );
1375cdf0e10cSrcweir                 }
1376cdf0e10cSrcweir                 break;
1377cdf0e10cSrcweir             case FN_TABLE_DELETE_COL:
1378cdf0e10cSrcweir                 {
1379cdf0e10cSrcweir                     SwSelBoxes aBoxes;
1380cdf0e10cSrcweir                     ::GetTblSel( rSh, aBoxes, nsSwTblSearchType::TBLSEARCH_COL );
1381cdf0e10cSrcweir                     if( ::HasProtectedCells( aBoxes ))
1382cdf0e10cSrcweir                         rSet.DisableItem( nSlot );
1383cdf0e10cSrcweir                 }
1384cdf0e10cSrcweir                 break;
1385cdf0e10cSrcweir 
1386cdf0e10cSrcweir             case FN_TABLE_UNSET_READ_ONLY_CELLS:
1387cdf0e10cSrcweir                 // disable in readonly sections, but enable in protected cells
1388cdf0e10cSrcweir                 if( !rSh.CanUnProtectCells() )
1389cdf0e10cSrcweir                     rSet.DisableItem( nSlot );
1390cdf0e10cSrcweir                 break;
1391cdf0e10cSrcweir             case RES_ROW_SPLIT:
1392cdf0e10cSrcweir             {
1393cdf0e10cSrcweir                 const SwFmtLayoutSplit& rTabSplit = pFmt->GetLayoutSplit();
1394cdf0e10cSrcweir                 if ( 0 == rTabSplit.GetValue() )
1395cdf0e10cSrcweir                 {
1396cdf0e10cSrcweir                     rSet.DisableItem( nSlot );
1397cdf0e10cSrcweir                 }
1398cdf0e10cSrcweir                 else
1399cdf0e10cSrcweir                 {
1400cdf0e10cSrcweir                     SwFmtRowSplit* pSplit = 0;
1401cdf0e10cSrcweir                     rSh.GetRowSplit(pSplit);
1402cdf0e10cSrcweir                     if(pSplit)
1403cdf0e10cSrcweir                         rSet.Put(*pSplit);
1404cdf0e10cSrcweir                     else
1405cdf0e10cSrcweir                         rSet.InvalidateItem( nSlot );
1406cdf0e10cSrcweir                     delete pSplit;
1407cdf0e10cSrcweir                 }
1408cdf0e10cSrcweir             }
1409cdf0e10cSrcweir             break;
1410cdf0e10cSrcweir             case FN_TABLE_HEADLINE_REPEAT:
1411cdf0e10cSrcweir                 if(0 != rSh.GetRowsToRepeat())
1412cdf0e10cSrcweir                     rSet.Put(SfxBoolItem(nSlot, sal_True));
1413cdf0e10cSrcweir                 else if(!rSh.GetRowSelectionFromTop())
1414cdf0e10cSrcweir                     rSet.DisableItem( nSlot );
1415cdf0e10cSrcweir                 else
1416cdf0e10cSrcweir                     rSet.Put(SfxBoolItem(nSlot, sal_False));
1417cdf0e10cSrcweir             break;
1418cdf0e10cSrcweir             case FN_TABLE_SELECT_CELL   :
1419cdf0e10cSrcweir                 if(rSh.HasBoxSelection())
1420cdf0e10cSrcweir                     rSet.DisableItem( nSlot );
1421cdf0e10cSrcweir             break;
1422cdf0e10cSrcweir         }
1423cdf0e10cSrcweir     nSlot = aIter.NextWhich();
1424cdf0e10cSrcweir 	}
1425cdf0e10cSrcweir }
1426cdf0e10cSrcweir 
1427cdf0e10cSrcweir /*--------------------------------------------------------------------
1428cdf0e10cSrcweir 	Beschreibung:
1429cdf0e10cSrcweir  --------------------------------------------------------------------*/
1430cdf0e10cSrcweir 
1431cdf0e10cSrcweir SwTableShell::SwTableShell(SwView &_rView) :
1432cdf0e10cSrcweir     SwBaseShell(_rView)
1433cdf0e10cSrcweir {
1434cdf0e10cSrcweir 	SetName(String::CreateFromAscii("Table"));
1435cdf0e10cSrcweir 	SetHelpId(SW_TABSHELL);
1436cdf0e10cSrcweir }
1437cdf0e10cSrcweir 
1438cdf0e10cSrcweir /*--------------------------------------------------------------------
1439cdf0e10cSrcweir 	Beschreibung:
1440cdf0e10cSrcweir  --------------------------------------------------------------------*/
1441cdf0e10cSrcweir 
1442cdf0e10cSrcweir void SwTableShell::GetFrmBorderState(SfxItemSet &rSet)
1443cdf0e10cSrcweir {
1444cdf0e10cSrcweir 	SfxItemSet aCoreSet( GetPool(),
1445cdf0e10cSrcweir 						 RES_BOX, RES_BOX,
1446cdf0e10cSrcweir 						 SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, 0 );
1447cdf0e10cSrcweir     SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
1448cdf0e10cSrcweir 	aCoreSet.Put( aBoxInfo );
1449cdf0e10cSrcweir 	GetShell().GetTabBorders( aCoreSet );
1450cdf0e10cSrcweir 	rSet.Put( aCoreSet );
1451cdf0e10cSrcweir }
1452cdf0e10cSrcweir 
1453cdf0e10cSrcweir /*--------------------------------------------------------------------
1454cdf0e10cSrcweir 	Beschreibung:
1455cdf0e10cSrcweir  --------------------------------------------------------------------*/
1456cdf0e10cSrcweir 
1457cdf0e10cSrcweir void SwTableShell::ExecTableStyle(SfxRequest& rReq)
1458cdf0e10cSrcweir {
1459cdf0e10cSrcweir 	SwWrtShell &rSh = GetShell();
1460cdf0e10cSrcweir 	const SfxItemSet *pArgs = rReq.GetArgs();
1461cdf0e10cSrcweir 	if(pArgs)
1462cdf0e10cSrcweir 		switch ( rReq.GetSlot() )
1463cdf0e10cSrcweir 		{
1464cdf0e10cSrcweir 			case SID_FRAME_LINESTYLE:
1465cdf0e10cSrcweir 			case SID_FRAME_LINECOLOR:
1466cdf0e10cSrcweir 			{
1467cdf0e10cSrcweir /*	Tabellenselektion ist abgeschafft
1468cdf0e10cSrcweir 				sal_Bool bPopCrsr = sal_False;
1469cdf0e10cSrcweir 				if ( !rReq.IsAPI() )
1470cdf0e10cSrcweir 				{
1471cdf0e10cSrcweir 					//Keine Tabellenselektion -> Aenderung wird auf die gesamte
1472cdf0e10cSrcweir 					//Tabelle.
1473cdf0e10cSrcweir 					if ( !rSh.IsTableMode() )
1474cdf0e10cSrcweir 					{
1475cdf0e10cSrcweir 						bPopCrsr = sal_True;
1476cdf0e10cSrcweir 						rSh.Push();
1477cdf0e10cSrcweir 						rSh.StartAction();
1478cdf0e10cSrcweir 						rSh.EnterStdMode();
1479cdf0e10cSrcweir 						rSh.MoveTable( fnTableCurr, fnTableStart );
1480cdf0e10cSrcweir 						rSh.SttSelect();
1481cdf0e10cSrcweir 						rSh.MoveTable( fnTableCurr, fnTableEnd );
1482cdf0e10cSrcweir 						rSh.EndSelect();
1483cdf0e10cSrcweir 					}
1484cdf0e10cSrcweir 				}*/
1485cdf0e10cSrcweir 				if ( rReq.GetSlot() == SID_FRAME_LINESTYLE )
1486cdf0e10cSrcweir 				{
1487cdf0e10cSrcweir 					const SvxLineItem &rLineItem = (const SvxLineItem&)pArgs->
1488cdf0e10cSrcweir 															Get( SID_FRAME_LINESTYLE );
1489cdf0e10cSrcweir 					const SvxBorderLine* pBorderLine = rLineItem.GetLine();
1490cdf0e10cSrcweir 					rSh.SetTabLineStyle( 0, sal_True, pBorderLine);
1491cdf0e10cSrcweir 				}
1492cdf0e10cSrcweir 				else
1493cdf0e10cSrcweir 				{
1494cdf0e10cSrcweir 					const SvxColorItem &rNewColorItem = (const SvxColorItem&)pArgs->
1495cdf0e10cSrcweir 															Get( SID_FRAME_LINECOLOR );
1496cdf0e10cSrcweir 					rSh.SetTabLineStyle( &rNewColorItem.GetValue() );
1497cdf0e10cSrcweir 				}
1498cdf0e10cSrcweir 
1499cdf0e10cSrcweir                 rReq.Done();
1500cdf0e10cSrcweir /*				if ( bPopCrsr )
1501cdf0e10cSrcweir 				{
1502cdf0e10cSrcweir 					rSh.KillPams();
1503cdf0e10cSrcweir 					rSh.Pop(sal_False);
1504cdf0e10cSrcweir 					rSh.EndAction();
1505cdf0e10cSrcweir 				}*/
1506cdf0e10cSrcweir 				break;
1507cdf0e10cSrcweir 			}
1508cdf0e10cSrcweir 		}
1509cdf0e10cSrcweir }
1510cdf0e10cSrcweir 
1511cdf0e10cSrcweir 
1512cdf0e10cSrcweir void SwTableShell::GetLineStyleState(SfxItemSet &rSet)
1513cdf0e10cSrcweir {
1514cdf0e10cSrcweir 	SfxItemSet aCoreSet( GetPool(),
1515cdf0e10cSrcweir 							RES_BOX, RES_BOX,
1516cdf0e10cSrcweir 							SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, 0);
1517cdf0e10cSrcweir     SvxBoxInfoItem aCoreInfo( SID_ATTR_BORDER_INNER );
1518cdf0e10cSrcweir 	aCoreSet.Put(aCoreInfo);
1519cdf0e10cSrcweir 	GetShell().GetTabBorders( aCoreSet );
1520cdf0e10cSrcweir 
1521cdf0e10cSrcweir 	const SvxBoxItem& rBoxItem = (const SvxBoxItem&)aCoreSet.Get( RES_BOX );
1522cdf0e10cSrcweir 	const SvxBorderLine* pLine = rBoxItem.GetTop();
1523cdf0e10cSrcweir 
1524cdf0e10cSrcweir 	rSet.Put( SvxColorItem( pLine ? pLine->GetColor() : Color(), SID_FRAME_LINECOLOR ) );
1525cdf0e10cSrcweir 	SvxLineItem aLine( SID_FRAME_LINESTYLE );
1526cdf0e10cSrcweir 	aLine.SetLine(pLine);
1527cdf0e10cSrcweir 	rSet.Put( aLine );
1528cdf0e10cSrcweir }
1529cdf0e10cSrcweir 
1530cdf0e10cSrcweir void SwTableShell::ExecNumberFormat(SfxRequest& rReq)
1531cdf0e10cSrcweir {
1532cdf0e10cSrcweir 	const SfxItemSet* pArgs = rReq.GetArgs();
1533cdf0e10cSrcweir 	SwWrtShell &rSh = GetShell();
1534cdf0e10cSrcweir 
1535cdf0e10cSrcweir 	//Erstmal die Slots, die keinen FrmMgr benoetigen.
1536cdf0e10cSrcweir 	const SfxPoolItem* pItem = 0;
1537cdf0e10cSrcweir 	sal_uInt16 nSlot = rReq.GetSlot();
1538cdf0e10cSrcweir 	if(pArgs)
1539cdf0e10cSrcweir 		pArgs->GetItemState(GetPool().GetWhich(nSlot), sal_False, &pItem);
1540cdf0e10cSrcweir 
1541cdf0e10cSrcweir 	//	Sprache immer von Cursorposition besorgen
1542cdf0e10cSrcweir 	LanguageType eLang = rSh.GetCurLang();
1543cdf0e10cSrcweir 	SvNumberFormatter* pFormatter = rSh.GetNumberFormatter();
1544cdf0e10cSrcweir 	sal_uInt32 nNumberFormat = NUMBERFORMAT_ENTRY_NOT_FOUND;
1545cdf0e10cSrcweir 	sal_uInt16 nFmtType = 0, nOffset = 0;
1546cdf0e10cSrcweir 
1547cdf0e10cSrcweir 	switch ( nSlot )
1548cdf0e10cSrcweir 	{
1549cdf0e10cSrcweir 	case FN_NUMBER_FORMAT:
1550cdf0e10cSrcweir 		if( pItem )
1551cdf0e10cSrcweir 		{
1552cdf0e10cSrcweir 			//	Index fuer String bestimmen
1553cdf0e10cSrcweir 			String aCode( ((const SfxStringItem*)pItem)->GetValue() );
1554cdf0e10cSrcweir 			nNumberFormat = pFormatter->GetEntryKey( aCode, eLang );
1555cdf0e10cSrcweir 			if( NUMBERFORMAT_ENTRY_NOT_FOUND == nNumberFormat )
1556cdf0e10cSrcweir 			{
1557cdf0e10cSrcweir 				//	neu eintragen
1558cdf0e10cSrcweir 				xub_StrLen nErrPos;
1559cdf0e10cSrcweir 				short nType;
1560cdf0e10cSrcweir 				if( !pFormatter->PutEntry( aCode, nErrPos, nType,
1561cdf0e10cSrcweir 											nNumberFormat, eLang ))
1562cdf0e10cSrcweir 					nNumberFormat = NUMBERFORMAT_ENTRY_NOT_FOUND;
1563cdf0e10cSrcweir 			}
1564cdf0e10cSrcweir 		}
1565cdf0e10cSrcweir 		break;
1566cdf0e10cSrcweir 	case FN_NUMBER_STANDARD:		nFmtType = NUMBERFORMAT_NUMBER; break;
1567cdf0e10cSrcweir 	case FN_NUMBER_SCIENTIFIC:		nFmtType = NUMBERFORMAT_SCIENTIFIC; break;
1568cdf0e10cSrcweir 	case FN_NUMBER_DATE:            nFmtType = NUMBERFORMAT_DATE; break;
1569cdf0e10cSrcweir 	case FN_NUMBER_TIME:			nFmtType = NUMBERFORMAT_TIME; break;
1570cdf0e10cSrcweir 	case FN_NUMBER_CURRENCY:		nFmtType = NUMBERFORMAT_CURRENCY; break;
1571cdf0e10cSrcweir 	case FN_NUMBER_PERCENT:			nFmtType = NUMBERFORMAT_PERCENT; break;
1572cdf0e10cSrcweir 
1573cdf0e10cSrcweir 	case FN_NUMBER_TWODEC:  		// #.##0,00
1574cdf0e10cSrcweir 		nFmtType = NUMBERFORMAT_NUMBER;
1575cdf0e10cSrcweir 		nOffset = NF_NUMBER_1000DEC2;
1576cdf0e10cSrcweir 		break;
1577cdf0e10cSrcweir 
1578cdf0e10cSrcweir 	default:
1579cdf0e10cSrcweir 		ASSERT(sal_False, falscher Dispatcher);
1580cdf0e10cSrcweir 		return;
1581cdf0e10cSrcweir 	}
1582cdf0e10cSrcweir 
1583cdf0e10cSrcweir 	if( nFmtType )
1584cdf0e10cSrcweir 		nNumberFormat =	pFormatter->GetStandardFormat( nFmtType, eLang ) + nOffset;
1585cdf0e10cSrcweir 
1586cdf0e10cSrcweir 	if( NUMBERFORMAT_ENTRY_NOT_FOUND != nNumberFormat )
1587cdf0e10cSrcweir 	{
1588cdf0e10cSrcweir 		SfxItemSet aBoxSet( GetPool(), RES_BOXATR_FORMAT, RES_BOXATR_FORMAT );
1589cdf0e10cSrcweir 		aBoxSet.Put( SwTblBoxNumFormat( nNumberFormat ));
1590cdf0e10cSrcweir 		rSh.SetTblBoxFormulaAttrs( aBoxSet );
1591cdf0e10cSrcweir 	}
1592cdf0e10cSrcweir 
1593cdf0e10cSrcweir }
1594cdf0e10cSrcweir 
1595