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