xref: /aoo41x/main/sw/source/ui/shells/tabsh.cxx (revision 69a74367)
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 
SFX_IMPL_INTERFACE(SwTableShell,SwBaseShell,SW_RES (STR_SHELLNAME_TABLE))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 
SwuiGetUITableAttrRange()161 const sal_uInt16* SwuiGetUITableAttrRange()
162 {
163 	return aUITableAttrRange;
164 }
165 
lcl_SetAttr(SwWrtShell & rSh,const SfxPoolItem & rItem)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 
lcl_TableParamToItemSet(SfxItemSet & rSet,SwWrtShell & rSh)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 
ItemSetToTableParam(const SfxItemSet & rSet,SwWrtShell & rSh)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 
lcl_TabGetMaxLineWidth(const SvxBorderLine * pBorderLine,SvxBorderLine & rBorderLine)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 
Execute(SfxRequest & rReq)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 SID_TABLE_VERT_NONE:
1183 		case SID_TABLE_VERT_CENTER:
1184 		case SID_TABLE_VERT_BOTTOM:
1185 		{
1186 				sal_uInt16 nAlign = nSlot == SID_TABLE_VERT_NONE ?
1187                                 text::VertOrientation::NONE :
1188 									nSlot == SID_TABLE_VERT_CENTER ?
1189                                         text::VertOrientation::CENTER : text::VertOrientation::BOTTOM;
1190 			rSh.SetBoxAlign(nAlign);
1191 			bCallDone = sal_True;
1192 
1193 		}
1194 		break;
1195 
1196 		case SID_ATTR_PARA_SPLIT:
1197 			if ( pItem )
1198 			{
1199 				SwFmtLayoutSplit aSplit( ((const SvxFmtSplitItem*)pItem)->GetValue());
1200 				SfxItemSet aSet(GetPool(),  RES_LAYOUT_SPLIT, RES_LAYOUT_SPLIT, 0 );
1201 				aSet.Put(aSplit);
1202 				rSh.SetTblAttr(aSet);
1203 			}
1204 		break;
1205 
1206 		case SID_ATTR_PARA_KEEP:
1207 			if ( pItem )
1208 			{
1209 				SvxFmtKeepItem aKeep( *(const SvxFmtKeepItem*)pItem );
1210 				aKeep.SetWhich( RES_KEEP );
1211 				SfxItemSet aSet(GetPool(),  RES_KEEP, RES_KEEP, 0 );
1212 				aSet.Put(aKeep);
1213 				rSh.SetTblAttr(aSet);
1214 			}
1215 		break;
1216         case FN_TABLE_ROW_SPLIT :
1217         {
1218             const SfxBoolItem* pBool = static_cast<const SfxBoolItem*>(pItem);
1219             SwFmtRowSplit* pSplit = 0;
1220             if(!pBool)
1221             {
1222                 rSh.GetRowSplit(pSplit);
1223                 if(pSplit)
1224                     pSplit->SetValue(!pSplit->GetValue());
1225                 else
1226                    pSplit = new SwFmtRowSplit(sal_True);
1227             }
1228             else
1229             {
1230                 pSplit = new SwFmtRowSplit(pBool->GetValue());
1231             }
1232             rSh.SetRowSplit( *pSplit );
1233             delete pSplit;
1234         }
1235         break;
1236 
1237 		default:
1238 			ASSERT( !this, "falscher Dispatcher" );
1239 			return;
1240 	}
1241     if(bCallDone)
1242         rReq.Done();
1243 }
1244 /*--------------------------------------------------------------------
1245 	Beschreibung:
1246  --------------------------------------------------------------------*/
1247 
GetState(SfxItemSet & rSet)1248 void SwTableShell::GetState(SfxItemSet &rSet)
1249 {
1250 	SfxWhichIter aIter( rSet );
1251 	SwWrtShell &rSh = GetShell();
1252 	SwFrmFmt *pFmt = rSh.GetTableFmt();
1253     // os #124829# crash report: in case of an invalid shell selection return immediately
1254     if(!pFmt)
1255         return;
1256 	sal_uInt16 nSlot = aIter.FirstWhich();
1257 	while ( nSlot )
1258 	{
1259 		switch ( nSlot )
1260 		{
1261 			case FN_TABLE_MERGE_CELLS:
1262 				if ( !rSh.IsTableMode() )
1263 					rSet.DisableItem(FN_TABLE_MERGE_CELLS);
1264 			break;
1265 			case FN_TABLE_ADJUST_CELLS:
1266 				if ( !rSh.IsAdjustCellWidthAllowed() )
1267 					rSet.DisableItem(FN_TABLE_ADJUST_CELLS);
1268 			break;
1269 
1270 			case FN_TABLE_BALANCE_CELLS:
1271 				if ( !rSh.IsAdjustCellWidthAllowed(sal_True) )
1272 					rSet.DisableItem(FN_TABLE_BALANCE_CELLS);
1273 			break;
1274 
1275 			case FN_TABLE_BALANCE_ROWS:
1276 				if ( !rSh.BalanceRowHeight(sal_True) )
1277 					rSet.DisableItem(FN_TABLE_BALANCE_ROWS);
1278 			break;
1279             case FN_OPTIMIZE_TABLE:
1280                 if ( !rSh.IsTableMode() &&
1281                         !rSh.IsAdjustCellWidthAllowed() &&
1282                         !rSh.IsAdjustCellWidthAllowed(sal_True) &&
1283                         !rSh.BalanceRowHeight(sal_True) )
1284                     rSet.DisableItem(FN_OPTIMIZE_TABLE);
1285             break;
1286 			case SID_INSERT_DIAGRAM:
1287 				{
1288 					SvtModuleOptions aMOpt;
1289 					if ( !aMOpt.IsMath() || rSh.IsTblComplexForChart() )
1290 						rSet.DisableItem(nSlot);
1291 				}
1292 				break;
1293 
1294             case FN_INSERT_TABLE:
1295                 if ( rSh.CrsrInsideInputFld() )
1296                 {
1297                     rSet.DisableItem( nSlot );
1298                 }
1299                 break;
1300 
1301 			case FN_TABLE_OPTIMAL_HEIGHT:
1302 			{
1303 				//Disablen wenn bereits auto-Hoehe eingestellt ist.
1304 				SwFmtFrmSize *pSz;
1305 				rSh.GetRowHeight( pSz );
1306 				if ( pSz )
1307 				{
1308                     if ( ATT_VAR_SIZE == pSz->GetHeightSizeType() )
1309 						rSet.DisableItem( nSlot );
1310 					delete pSz;
1311 				}
1312 			}
1313 			break;
1314 			case FN_TABLE_INSERT_ROW:
1315 			case FN_TABLE_INSERT_ROW_DLG:
1316 			{
1317 				if ( rSh.IsInRepeatedHeadline() )
1318 					rSet.DisableItem( nSlot );
1319 			}
1320 			break;
1321 			case RES_LR_SPACE:
1322 				rSet.Put(pFmt->GetLRSpace());
1323 			break;
1324 			case RES_UL_SPACE:
1325                 rSet.Put(pFmt->GetULSpace());
1326 			break;
1327 
1328             case SID_TABLE_VERT_NONE:
1329             case SID_TABLE_VERT_CENTER:
1330             case SID_TABLE_VERT_BOTTOM:
1331             {
1332                 sal_uInt16 nAlign = rSh.GetBoxAlign();
1333                 sal_Bool bSet = nSlot == SID_TABLE_VERT_NONE && nAlign == text::VertOrientation::NONE||
1334                             nSlot == SID_TABLE_VERT_CENTER && nAlign == text::VertOrientation::CENTER ||
1335                             nSlot == SID_TABLE_VERT_BOTTOM && nAlign == text::VertOrientation::BOTTOM;
1336                 rSet.Put(SfxBoolItem(nSlot, bSet));
1337             }
1338             break;
1339 
1340 			case FN_TABLE_MODE_FIX       :
1341 			case FN_TABLE_MODE_FIX_PROP  :
1342 			case FN_TABLE_MODE_VARIABLE	 :
1343 				{
1344                     TblChgMode nMode = rSh.GetTblChgMode();
1345 					sal_Bool bSet = (nSlot == FN_TABLE_MODE_FIX && nMode == TBLFIX_CHGABS) ||
1346 							(nSlot == FN_TABLE_MODE_FIX_PROP && nMode == TBLFIX_CHGPROP) ||
1347 							(nSlot == FN_TABLE_MODE_VARIABLE && nMode == TBLVAR_CHGABS);
1348 					rSet.Put(SfxBoolItem(nSlot, bSet));
1349 				}
1350 			break;
1351 
1352 			case SID_ATTR_PARA_SPLIT:
1353 				rSet.Put( pFmt->GetKeep() );
1354 			break;
1355 
1356 			case SID_ATTR_PARA_KEEP:
1357 				rSet.Put( pFmt->GetLayoutSplit() );
1358 			break;
1359 			case FN_TABLE_SPLIT_TABLE:
1360 			{
1361 				if ( rSh.IsInHeadline() )
1362 					rSet.DisableItem( nSlot );
1363 			}
1364 			break;
1365 			case FN_TABLE_MERGE_TABLE:
1366 			{
1367 				sal_Bool bAsk;
1368 				if( !rSh.CanMergeTable( sal_True, &bAsk ))
1369 					rSet.DisableItem( nSlot );
1370 			}
1371 			break;
1372 
1373             case FN_TABLE_DELETE_ROW:
1374                 {
1375                     SwSelBoxes aBoxes;
1376                     ::GetTblSel( rSh, aBoxes, nsSwTblSearchType::TBLSEARCH_ROW );
1377                     if( ::HasProtectedCells( aBoxes ))
1378                         rSet.DisableItem( nSlot );
1379                 }
1380                 break;
1381             case FN_TABLE_DELETE_COL:
1382                 {
1383                     SwSelBoxes aBoxes;
1384                     ::GetTblSel( rSh, aBoxes, nsSwTblSearchType::TBLSEARCH_COL );
1385                     if( ::HasProtectedCells( aBoxes ))
1386                         rSet.DisableItem( nSlot );
1387                 }
1388                 break;
1389 
1390             case FN_TABLE_UNSET_READ_ONLY_CELLS:
1391                 // disable in readonly sections, but enable in protected cells
1392                 if( !rSh.CanUnProtectCells() )
1393                     rSet.DisableItem( nSlot );
1394                 break;
1395             case RES_ROW_SPLIT:
1396             {
1397                 const SwFmtLayoutSplit& rTabSplit = pFmt->GetLayoutSplit();
1398                 if ( 0 == rTabSplit.GetValue() )
1399                 {
1400                     rSet.DisableItem( nSlot );
1401                 }
1402                 else
1403                 {
1404                     SwFmtRowSplit* pSplit = 0;
1405                     rSh.GetRowSplit(pSplit);
1406                     if(pSplit)
1407                         rSet.Put(*pSplit);
1408                     else
1409                         rSet.InvalidateItem( nSlot );
1410                     delete pSplit;
1411                 }
1412             }
1413             break;
1414             case FN_TABLE_HEADLINE_REPEAT:
1415                 if(0 != rSh.GetRowsToRepeat())
1416                     rSet.Put(SfxBoolItem(nSlot, sal_True));
1417                 else if(!rSh.GetRowSelectionFromTop())
1418                     rSet.DisableItem( nSlot );
1419                 else
1420                     rSet.Put(SfxBoolItem(nSlot, sal_False));
1421             break;
1422             case FN_TABLE_SELECT_CELL   :
1423                 if(rSh.HasBoxSelection())
1424                     rSet.DisableItem( nSlot );
1425             break;
1426         }
1427     nSlot = aIter.NextWhich();
1428 	}
1429 }
1430 
1431 /*--------------------------------------------------------------------
1432 	Beschreibung:
1433  --------------------------------------------------------------------*/
1434 
SwTableShell(SwView & _rView)1435 SwTableShell::SwTableShell(SwView &_rView) :
1436     SwBaseShell(_rView)
1437 {
1438 	SetName(String::CreateFromAscii("Table"));
1439 	SetHelpId(SW_TABSHELL);
1440     SfxShell::SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_Table));
1441 }
1442 
1443 /*--------------------------------------------------------------------
1444 	Beschreibung:
1445  --------------------------------------------------------------------*/
1446 
GetFrmBorderState(SfxItemSet & rSet)1447 void SwTableShell::GetFrmBorderState(SfxItemSet &rSet)
1448 {
1449 	SfxItemSet aCoreSet( GetPool(),
1450 						 RES_BOX, RES_BOX,
1451 						 SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, 0 );
1452     SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
1453 	aCoreSet.Put( aBoxInfo );
1454 	GetShell().GetTabBorders( aCoreSet );
1455 	rSet.Put( aCoreSet );
1456 }
1457 
1458 /*--------------------------------------------------------------------
1459 	Beschreibung:
1460  --------------------------------------------------------------------*/
1461 
ExecTableStyle(SfxRequest & rReq)1462 void SwTableShell::ExecTableStyle(SfxRequest& rReq)
1463 {
1464 	SwWrtShell &rSh = GetShell();
1465 	const SfxItemSet *pArgs = rReq.GetArgs();
1466 	if(pArgs)
1467 		switch ( rReq.GetSlot() )
1468 		{
1469 			case SID_FRAME_LINESTYLE:
1470 			case SID_FRAME_LINECOLOR:
1471 			{
1472 /*	Tabellenselektion ist abgeschafft
1473 				sal_Bool bPopCrsr = sal_False;
1474 				if ( !rReq.IsAPI() )
1475 				{
1476 					//Keine Tabellenselektion -> Aenderung wird auf die gesamte
1477 					//Tabelle.
1478 					if ( !rSh.IsTableMode() )
1479 					{
1480 						bPopCrsr = sal_True;
1481 						rSh.Push();
1482 						rSh.StartAction();
1483 						rSh.EnterStdMode();
1484 						rSh.MoveTable( fnTableCurr, fnTableStart );
1485 						rSh.SttSelect();
1486 						rSh.MoveTable( fnTableCurr, fnTableEnd );
1487 						rSh.EndSelect();
1488 					}
1489 				}*/
1490 				if ( rReq.GetSlot() == SID_FRAME_LINESTYLE )
1491 				{
1492 					const SvxLineItem &rLineItem = (const SvxLineItem&)pArgs->
1493 															Get( SID_FRAME_LINESTYLE );
1494 					const SvxBorderLine* pBorderLine = rLineItem.GetLine();
1495 					rSh.SetTabLineStyle( 0, sal_True, pBorderLine);
1496 				}
1497 				else
1498 				{
1499 					const SvxColorItem &rNewColorItem = (const SvxColorItem&)pArgs->
1500 															Get( SID_FRAME_LINECOLOR );
1501 					rSh.SetTabLineStyle( &rNewColorItem.GetValue() );
1502 				}
1503 
1504                 rReq.Done();
1505 /*				if ( bPopCrsr )
1506 				{
1507 					rSh.KillPams();
1508 					rSh.Pop(sal_False);
1509 					rSh.EndAction();
1510 				}*/
1511 				break;
1512 			}
1513 		}
1514 }
1515 
1516 
GetLineStyleState(SfxItemSet & rSet)1517 void SwTableShell::GetLineStyleState(SfxItemSet &rSet)
1518 {
1519 	SfxItemSet aCoreSet( GetPool(),
1520 							RES_BOX, RES_BOX,
1521 							SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, 0);
1522     SvxBoxInfoItem aCoreInfo( SID_ATTR_BORDER_INNER );
1523 	aCoreSet.Put(aCoreInfo);
1524 	GetShell().GetTabBorders( aCoreSet );
1525 
1526 	const SvxBoxItem& rBoxItem = (const SvxBoxItem&)aCoreSet.Get( RES_BOX );
1527 	const SvxBorderLine* pLine = rBoxItem.GetTop();
1528 
1529 	rSet.Put( SvxColorItem( pLine ? pLine->GetColor() : Color(), SID_FRAME_LINECOLOR ) );
1530 	SvxLineItem aLine( SID_FRAME_LINESTYLE );
1531 	aLine.SetLine(pLine);
1532 	rSet.Put( aLine );
1533 }
1534 
ExecNumberFormat(SfxRequest & rReq)1535 void SwTableShell::ExecNumberFormat(SfxRequest& rReq)
1536 {
1537 	const SfxItemSet* pArgs = rReq.GetArgs();
1538 	SwWrtShell &rSh = GetShell();
1539 
1540 	//Erstmal die Slots, die keinen FrmMgr benoetigen.
1541 	const SfxPoolItem* pItem = 0;
1542 	sal_uInt16 nSlot = rReq.GetSlot();
1543 	if(pArgs)
1544 		pArgs->GetItemState(GetPool().GetWhich(nSlot), sal_False, &pItem);
1545 
1546 	//	Sprache immer von Cursorposition besorgen
1547 	LanguageType eLang = rSh.GetCurLang();
1548 	SvNumberFormatter* pFormatter = rSh.GetNumberFormatter();
1549 	sal_uInt32 nNumberFormat = NUMBERFORMAT_ENTRY_NOT_FOUND;
1550 	sal_uInt16 nFmtType = 0, nOffset = 0;
1551 
1552 	switch ( nSlot )
1553 	{
1554 	case FN_NUMBER_FORMAT:
1555 		if( pItem )
1556 		{
1557 			//	Index fuer String bestimmen
1558 			String aCode( ((const SfxStringItem*)pItem)->GetValue() );
1559 			nNumberFormat = pFormatter->GetEntryKey( aCode, eLang );
1560 			if( NUMBERFORMAT_ENTRY_NOT_FOUND == nNumberFormat )
1561 			{
1562 				//	neu eintragen
1563 				xub_StrLen nErrPos;
1564 				short nType;
1565 				if( !pFormatter->PutEntry( aCode, nErrPos, nType,
1566 											nNumberFormat, eLang ))
1567 					nNumberFormat = NUMBERFORMAT_ENTRY_NOT_FOUND;
1568 			}
1569 		}
1570 		break;
1571 	case FN_NUMBER_STANDARD:		nFmtType = NUMBERFORMAT_NUMBER; break;
1572 	case FN_NUMBER_SCIENTIFIC:		nFmtType = NUMBERFORMAT_SCIENTIFIC; break;
1573 	case FN_NUMBER_DATE:            nFmtType = NUMBERFORMAT_DATE; break;
1574 	case FN_NUMBER_TIME:			nFmtType = NUMBERFORMAT_TIME; break;
1575 	case FN_NUMBER_CURRENCY:		nFmtType = NUMBERFORMAT_CURRENCY; break;
1576 	case FN_NUMBER_PERCENT:			nFmtType = NUMBERFORMAT_PERCENT; break;
1577 
1578 	case FN_NUMBER_TWODEC:  		// #.##0,00
1579 		nFmtType = NUMBERFORMAT_NUMBER;
1580 		nOffset = NF_NUMBER_1000DEC2;
1581 		break;
1582 
1583 	default:
1584 		ASSERT(sal_False, falscher Dispatcher);
1585 		return;
1586 	}
1587 
1588 	if( nFmtType )
1589 		nNumberFormat =	pFormatter->GetStandardFormat( nFmtType, eLang ) + nOffset;
1590 
1591 	if( NUMBERFORMAT_ENTRY_NOT_FOUND != nNumberFormat )
1592 	{
1593 		SfxItemSet aBoxSet( GetPool(), RES_BOXATR_FORMAT, RES_BOXATR_FORMAT );
1594 		aBoxSet.Put( SwTblBoxNumFormat( nNumberFormat ));
1595 		rSh.SetTblBoxFormulaAttrs( aBoxSet );
1596 	}
1597 
1598 }
1599