xref: /trunk/main/sc/source/ui/view/formatsh.cxx (revision 4e8031e0)
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_sc.hxx"
26 
27 
28 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
29 #include <com/sun/star/beans/XPropertySet.hpp>
30 #include <com/sun/star/container/XNameAccess.hpp>
31 
32 //------------------------------------------------------------------
33 
34 //svdraw.hxx
35 #define _SDR_NOITEMS
36 #define _SDR_NOTOUCH
37 #define _SDR_NOTRANSFORM
38 #define _SI_NOSBXCONTROLS
39 #define _VCONT_HXX
40 #define _SI_NOOTHERFORMS
41 #define _VCTRLS_HXX
42 #define _SI_NOCONTROL
43 #define _SETBRW_HXX
44 #define _VCBRW_HXX
45 #define _SI_NOSBXCONTROLS
46 
47 //------------------------------------------------------------------
48 
49 #include "scitems.hxx"
50 #include <editeng/eeitem.hxx>
51 
52 #include <sfx2/app.hxx>
53 #include <sfx2/viewfrm.hxx>
54 #include <sfx2/objface.hxx>
55 #include <sfx2/request.hxx>
56 #include <svl/whiter.hxx>
57 #include <vcl/msgbox.hxx>
58 
59 #define _ZFORLIST_DECLARE_TABLE
60 #include <svl/stritem.hxx>
61 #include <svl/zformat.hxx>
62 #include <svl/languageoptions.hxx>
63 #include <editeng/boxitem.hxx>
64 #include <editeng/langitem.hxx>
65 #include <svx/numinf.hxx>
66 #include <sfx2/dispatch.hxx>
67 #include <sfx2/templdlg.hxx>
68 #include <sfx2/tplpitem.hxx>
69 #include <editeng/svxenum.hxx>
70 #include <svx/algitem.hxx>
71 #include <editeng/wghtitem.hxx>
72 #include <editeng/postitem.hxx>
73 #include <editeng/udlnitem.hxx>
74 #include <editeng/bolnitem.hxx>
75 #include <editeng/colritem.hxx>
76 #include <editeng/brshitem.hxx>
77 #include <editeng/frmdiritem.hxx>
78 #include <editeng/scripttypeitem.hxx>
79 #include <svtools/colorcfg.hxx>
80 #include <editeng/shaditem.hxx>
81 
82 #include "formatsh.hxx"
83 #include "sc.hrc"
84 #include "globstr.hrc"
85 #include "docsh.hxx"
86 #include "patattr.hxx"
87 #include "scmod.hxx"
88 //CHINA001 #include "styledlg.hxx"
89 #include "attrdlg.hrc"
90 #include "stlpool.hxx"
91 #include "stlsheet.hxx"
92 #include "printfun.hxx"
93 #include "docpool.hxx"
94 #include "scresid.hxx"
95 #include "tabvwsh.hxx"
96 #include "undostyl.hxx"
97 
98 
99 #define ScFormatShell
100 #define	TableFont
101 #define FormatForSelection
102 #include "scslots.hxx"
103 
104 #include "scabstdlg.hxx" //CHINA001
105 
106 namespace {
107 
108 SvxCellHorJustify lclConvertSlotToHAlign( sal_uInt16 nSlot )
109 {
110     SvxCellHorJustify eHJustify = SVX_HOR_JUSTIFY_STANDARD;
111     switch( nSlot )
112     {
113         case SID_ALIGN_ANY_HDEFAULT:    eHJustify = SVX_HOR_JUSTIFY_STANDARD;   break;
114         case SID_ALIGN_ANY_LEFT:        eHJustify = SVX_HOR_JUSTIFY_LEFT;       break;
115         case SID_ALIGN_ANY_HCENTER:     eHJustify = SVX_HOR_JUSTIFY_CENTER;     break;
116         case SID_ALIGN_ANY_RIGHT:       eHJustify = SVX_HOR_JUSTIFY_RIGHT;      break;
117         case SID_ALIGN_ANY_JUSTIFIED:   eHJustify = SVX_HOR_JUSTIFY_BLOCK;      break;
118         default:    DBG_ERRORFILE( "lclConvertSlotToHAlign - invalid slot" );
119     }
120     return eHJustify;
121 }
122 
123 SvxCellVerJustify lclConvertSlotToVAlign( sal_uInt16 nSlot )
124 {
125     SvxCellVerJustify eVJustify = SVX_VER_JUSTIFY_STANDARD;
126     switch( nSlot )
127     {
128         case SID_ALIGN_ANY_VDEFAULT:    eVJustify = SVX_VER_JUSTIFY_STANDARD;   break;
129         case SID_ALIGN_ANY_TOP:         eVJustify = SVX_VER_JUSTIFY_TOP;        break;
130         case SID_ALIGN_ANY_VCENTER:     eVJustify = SVX_VER_JUSTIFY_CENTER;     break;
131         case SID_ALIGN_ANY_BOTTOM:      eVJustify = SVX_VER_JUSTIFY_BOTTOM;     break;
132         default:    DBG_ERRORFILE( "lclConvertSlotToVAlign - invalid slot" );
133     }
134     return eVJustify;
135 }
136 
137 } // namespace
138 
139 TYPEINIT1( ScFormatShell, SfxShell );
140 
141 SFX_IMPL_INTERFACE(ScFormatShell, SfxShell, ScResId(SCSTR_FORMATSHELL) )
142 {
143 	SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT | SFX_VISIBILITY_STANDARD |
144 								SFX_VISIBILITY_SERVER,
145 								ScResId(RID_OBJECTBAR_FORMAT));
146 
147 }
148 
149 
150 ScFormatShell::ScFormatShell(ScViewData* pData) :
151 	SfxShell(pData->GetViewShell()),
152 	pViewData(pData)
153 {
154 	ScTabViewShell*	pTabViewShell = GetViewData()->GetViewShell();
155 
156 	SetPool( &pTabViewShell->GetPool() );
157     ::svl::IUndoManager* pMgr = pViewData->GetSfxDocShell()->GetUndoManager();
158     SetUndoManager( pMgr );
159     if ( !pViewData->GetDocument()->IsUndoEnabled() )
160     {
161         pMgr->SetMaxUndoActionCount( 0 );
162     }
163 	SetHelpId(HID_SCSHELL_FORMATSH);
164 	SetName(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("Format")));
165 }
166 
167 ScFormatShell::~ScFormatShell()
168 {
169 }
170 
171 //------------------------------------------------------------------
172 
173 void __EXPORT ScFormatShell::GetStyleState( SfxItemSet& rSet )
174 {
175 	ScDocument*				pDoc  		= GetViewData()->GetDocument();
176 	ScTabViewShell*	pTabViewShell  		= GetViewData()->GetViewShell();
177 	SfxStyleSheetBasePool*	pStylePool	= pDoc->GetStyleSheetPool();
178 
179 	sal_Bool bProtected = sal_False;
180 	SCTAB nTabCount = pDoc->GetTableCount();
181 	for (SCTAB i=0; i<nTabCount; i++)
182 		if (pDoc->IsTabProtected(i))				// ueberhaupt eine Tabelle geschuetzt?
183 			bProtected = sal_True;
184 
185 	SfxWhichIter	aIter(rSet);
186 	sal_uInt16			nWhich = aIter.FirstWhich();
187 	sal_uInt16			nSlotId = 0;
188 
189 	while ( nWhich )
190 	{
191 		nSlotId = SfxItemPool::IsWhich( nWhich )
192 					? GetPool().GetSlotId( nWhich )
193 					: nWhich;
194 
195 		switch ( nSlotId )
196 		{
197 			case SID_STYLE_APPLY:
198 				if ( !pStylePool )
199 					rSet.DisableItem( nSlotId );
200 				break;
201 
202 			case SID_STYLE_FAMILY2:		// Zellvorlagen
203 			{
204 				SfxStyleSheet* pStyleSheet = (SfxStyleSheet*)
205 											 pTabViewShell->GetStyleSheetFromMarked();
206 
207 				if ( pStyleSheet )
208 					rSet.Put( SfxTemplateItem( nSlotId, pStyleSheet->GetName() ) );
209 				else
210 					rSet.Put( SfxTemplateItem( nSlotId, String() ) );
211 			}
212 			break;
213 
214 			case SID_STYLE_FAMILY4:		// Seitenvorlagen
215 			{
216 				SCTAB			nCurTab		= GetViewData()->GetTabNo();
217 				String			aPageStyle  = pDoc->GetPageStyle( nCurTab );
218 				SfxStyleSheet*	pStyleSheet = (SfxStyleSheet*)pStylePool->
219 									Find( aPageStyle, SFX_STYLE_FAMILY_PAGE );
220 
221 				if ( pStyleSheet )
222 					rSet.Put( SfxTemplateItem( nSlotId, aPageStyle ) );
223 				else
224 					rSet.Put( SfxTemplateItem( nSlotId, String() ) );
225 			}
226 			break;
227 
228 			case SID_STYLE_WATERCAN:
229 			{
230 				rSet.Put( SfxBoolItem( nSlotId, SC_MOD()->GetIsWaterCan() ) );
231 			}
232 			break;
233 
234 			case SID_STYLE_UPDATE_BY_EXAMPLE:
235 			{
236 				ISfxTemplateCommon* pDesigner = SFX_APP()->
237 						GetCurrentTemplateCommon(pTabViewShell->GetViewFrame()->GetBindings());
238 				sal_Bool bPage = pDesigner && SFX_STYLE_FAMILY_PAGE == pDesigner->GetActualFamily();
239 
240 				if ( bProtected || bPage )
241 					rSet.DisableItem( nSlotId );
242 			}
243 			break;
244 
245 			case SID_STYLE_EDIT:
246 			case SID_STYLE_DELETE:
247 			{
248 				ISfxTemplateCommon* pDesigner = SFX_APP()->
249 						GetCurrentTemplateCommon(pTabViewShell->GetViewFrame()->GetBindings());
250 				sal_Bool bPage = pDesigner && SFX_STYLE_FAMILY_PAGE == pDesigner->GetActualFamily();
251 
252 				if ( bProtected && !bPage )
253 					rSet.DisableItem( nSlotId );
254 			}
255 			break;
256 
257 			default:
258 				break;
259 		}
260 
261 		nWhich = aIter.NextWhich();
262 	}
263 }
264 
265 //------------------------------------------------------------------
266 
267 void __EXPORT ScFormatShell::ExecuteStyle( SfxRequest& rReq )
268 {
269 	// Wenn ToolBar vertikal :
270 	if ( !rReq.GetArgs() )
271 	{
272 		pViewData->GetDispatcher().Execute( SID_STYLE_DESIGNER, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD );
273 		return;
274 	}
275 
276 	//--------------------------------------------------------------------
277 	SfxBindings&		rBindings	= pViewData->GetBindings();
278 	const SfxItemSet*   pArgs   	= rReq.GetArgs();
279 	const sal_uInt16        nSlotId 	= rReq.GetSlot();
280 	const SCTAB		    nCurTab		= GetViewData()->GetTabNo();
281 	ScDocShell*			pDocSh		= GetViewData()->GetDocShell();
282 	ScTabViewShell*		pTabViewShell= GetViewData()->GetViewShell();
283 	ScDocument*         pDoc    	= pDocSh->GetDocument();
284 	ScMarkData&			rMark		= GetViewData()->GetMarkData();
285 	ScModule*			pScMod		= SC_MOD();
286 	String				aRefName;
287 	sal_Bool				bUndo		= pDoc->IsUndoEnabled();
288 
289 	if (   (nSlotId == SID_STYLE_NEW)
290 		|| (nSlotId == SID_STYLE_EDIT)
291 		|| (nSlotId == SID_STYLE_DELETE)
292 		|| (nSlotId == SID_STYLE_APPLY)
293 		|| (nSlotId == SID_STYLE_WATERCAN)
294 		|| (nSlotId == SID_STYLE_FAMILY)
295 		|| (nSlotId == SID_STYLE_NEW_BY_EXAMPLE)
296 		|| (nSlotId == SID_STYLE_UPDATE_BY_EXAMPLE) )
297 	{
298 		SfxStyleSheetBasePool*  pStylePool	= pDoc->GetStyleSheetPool();
299 		SfxStyleSheetBase*      pStyleSheet = NULL;
300 
301 		sal_Bool bStyleToMarked = sal_False;
302 		sal_Bool bListAction = sal_False;
303 		sal_Bool bAddUndo = sal_False;			// add ScUndoModifyStyle (style modified)
304 		ScStyleSaveData aOldData;		// for undo/redo
305 		ScStyleSaveData aNewData;
306 
307 		SfxStyleFamily eFamily = SFX_STYLE_FAMILY_PARA;
308 		const SfxPoolItem* pFamItem;
309 		if ( pArgs && SFX_ITEM_SET == pArgs->GetItemState( SID_STYLE_FAMILY, sal_True, &pFamItem ) )
310 			eFamily = (SfxStyleFamily)((const SfxUInt16Item*)pFamItem)->GetValue();
311         else
312 		if ( pArgs && SFX_ITEM_SET == pArgs->GetItemState( SID_STYLE_FAMILYNAME, sal_True, &pFamItem ) )
313         {
314             String sFamily = ((const SfxStringItem*)pFamItem)->GetValue();
315             if (sFamily.CompareToAscii("CellStyles") == COMPARE_EQUAL)
316                 eFamily = SFX_STYLE_FAMILY_PARA;
317             else
318             if (sFamily.CompareToAscii("PageStyles") == COMPARE_EQUAL)
319                 eFamily = SFX_STYLE_FAMILY_PAGE;
320         }
321 
322 		String                  aStyleName;
323 		sal_uInt16                  nRetMask = 0xffff;
324 //      #96983# only stylist sends focus to sheet
325 //        sal_Bool                    bGrabFocus = ( SID_STYLE_APPLY == nSlotId );
326 
327 		pStylePool->SetSearchMask( eFamily, SFXSTYLEBIT_ALL );
328 
329 		switch ( nSlotId )
330 		{
331 			case SID_STYLE_NEW:
332 				{
333 					const SfxPoolItem* pNameItem;
334 					if (pArgs && SFX_ITEM_SET == pArgs->GetItemState( nSlotId, sal_True, &pNameItem ))
335 						aStyleName  = ((const SfxStringItem*)pNameItem)->GetValue();
336 
337 					const SfxPoolItem* pRefItem=NULL;
338 					if (pArgs && SFX_ITEM_SET == pArgs->GetItemState( SID_STYLE_REFERENCE, sal_True, &pRefItem ))
339 					{
340 						if(pRefItem!=NULL)
341 							aRefName  = ((const SfxStringItem*)pRefItem)->GetValue();
342 					}
343 
344 					pStyleSheet = &(pStylePool->Make( aStyleName, eFamily,
345 													  SFXSTYLEBIT_USERDEF ) );
346 
347 					if ( pStyleSheet && pStyleSheet->HasParentSupport() )
348 						pStyleSheet->SetParent(aRefName);
349 				}
350 				break;
351 
352 			case SID_STYLE_APPLY:
353             {
354                 SFX_REQUEST_ARG( rReq, pNameItem, SfxStringItem, SID_APPLY_STYLE, sal_False );
355                 SFX_REQUEST_ARG( rReq, pFamilyItem, SfxStringItem, SID_STYLE_FAMILYNAME, sal_False );
356                 if ( pFamilyItem && pNameItem )
357                 {
358                     com::sun::star::uno::Reference< com::sun::star::style::XStyleFamiliesSupplier > xModel(pDocSh->GetModel(), com::sun::star::uno::UNO_QUERY);
359                     try
360                     {
361                         com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > xStyles;
362                         com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > xCont = xModel->getStyleFamilies();
363                         xCont->getByName(pFamilyItem->GetValue()) >>= xStyles;
364                         com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet > xInfo;
365                         xStyles->getByName( pNameItem->GetValue() ) >>= xInfo;
366                         ::rtl::OUString aUIName;
367                         xInfo->getPropertyValue( ::rtl::OUString::createFromAscii("DisplayName") ) >>= aUIName;
368                         if ( aUIName.getLength() )
369                             rReq.AppendItem( SfxStringItem( SID_STYLE_APPLY, aUIName ) );
370                     }
371                     catch( com::sun::star::uno::Exception& )
372                     {
373                     }
374                 }
375             }
376 			case SID_STYLE_EDIT:
377 			case SID_STYLE_DELETE:
378 			case SID_STYLE_NEW_BY_EXAMPLE:
379 				{
380 					const SfxPoolItem* pNameItem;
381 					if (pArgs && SFX_ITEM_SET == pArgs->GetItemState( nSlotId, sal_True, &pNameItem ))
382 						aStyleName  = ((const SfxStringItem*)pNameItem)->GetValue();
383 					pStyleSheet = pStylePool->Find( aStyleName, eFamily );
384 
385 					aOldData.InitFromStyle( pStyleSheet );
386 				}
387 				break;
388 
389 			case SID_STYLE_WATERCAN:
390 			{
391 				sal_Bool bWaterCan = pScMod->GetIsWaterCan();
392 
393 				if( !bWaterCan )
394 				{
395 					const SfxPoolItem* pItem;
396 
397 					if ( SFX_ITEM_SET ==
398 						 pArgs->GetItemState( nSlotId, sal_True, &pItem ) )
399 					{
400 						const SfxStringItem* pStrItem = PTR_CAST(SfxStringItem,pItem);
401 						if ( pStrItem )
402 						{
403 							aStyleName  = pStrItem->GetValue();
404 							pStyleSheet = pStylePool->Find( aStyleName, eFamily );
405 
406 							if ( pStyleSheet )
407 							{
408 								((ScStyleSheetPool*)pStylePool)->
409 										SetActualStyleSheet( pStyleSheet );
410 								rReq.Done();
411 							}
412 						}
413 					}
414 				}
415 
416 				if ( !bWaterCan && pStyleSheet )
417 				{
418 					pScMod->SetWaterCan( sal_True );
419 					pTabViewShell->SetActivePointer( Pointer(POINTER_FILL) );
420 					rReq.Done();
421 				}
422 				else
423 				{
424 					pScMod->SetWaterCan( sal_False );
425 					pTabViewShell->SetActivePointer( Pointer(POINTER_ARROW) );
426 					rReq.Done();
427 				}
428 			}
429 			break;
430 
431 			default:
432 				break;
433 		}
434 
435 		// Neuen Style fuer WaterCan-Mode setzen
436 		if ( nSlotId == SID_STYLE_APPLY && pScMod->GetIsWaterCan() && pStyleSheet )
437 			((ScStyleSheetPool*)pStylePool)->SetActualStyleSheet( pStyleSheet );
438 
439 		switch ( eFamily )
440 		{
441 			case SFX_STYLE_FAMILY_PARA:
442 			{
443 				switch ( nSlotId )
444 				{
445 					case SID_STYLE_DELETE:
446 					{
447 						if ( pStyleSheet )
448 						{
449                             pTabViewShell->RemoveStyleSheetInUse( pStyleSheet );
450 							pStylePool->Remove( pStyleSheet );
451 							pTabViewShell->InvalidateAttribs();
452 							nRetMask = sal_True;
453 							bAddUndo = sal_True;
454 							rReq.Done();
455 						}
456 						else
457 							nRetMask = sal_False;
458 					}
459 					break;
460 
461 					case SID_STYLE_APPLY:
462 					{
463 						if ( pStyleSheet && !pScMod->GetIsWaterCan() )
464 						{
465 							// Anwenden der Vorlage auf das Dokument
466 							pTabViewShell->SetStyleSheetToMarked( (SfxStyleSheet*)pStyleSheet );
467 							pTabViewShell->InvalidateAttribs();
468 							rReq.Done();
469 						}
470 					}
471 					break;
472 
473 					case SID_STYLE_NEW_BY_EXAMPLE:
474 					case SID_STYLE_UPDATE_BY_EXAMPLE:
475 					{
476 						// Vorlage erzeugen/ersetzen durch Attribute
477 						// an der Cursor-Position:
478 
479 						const ScPatternAttr* pAttrItem = NULL;
480 
481 						// Die Abfrage, ob markiert ist, war hier immer falsch,
482 						// darum jetzt gar nicht mehr, und einfach vom Cursor.
483 						// Wenn Attribute aus der Selektion genommen werden sollen,
484 						// muss noch darauf geachtet werden, Items aus Vorlagen nicht
485 						// zu uebernehmen (GetSelectionPattern sammelt auch Items aus
486 						// Vorlagen zusammen) (#44748#)
487 						//		pAttrItem = GetSelectionPattern();
488 
489                         // ScViewData* pViewData = GetViewData();
490 						SCCOL		nCol = pViewData->GetCurX();
491 						SCROW		nRow = pViewData->GetCurY();
492 						pAttrItem = pDoc->GetPattern( nCol, nRow, nCurTab );
493 
494 						SfxItemSet aAttrSet = pAttrItem->GetItemSet();
495 						aAttrSet.ClearItem( ATTR_MERGE );
496 						aAttrSet.ClearItem( ATTR_MERGE_FLAG );
497 						//	bedingte Formatierung und Gueltigkeit nicht uebernehmen,
498 						//	weil sie in der Vorlage nicht editiert werden koennen
499 						aAttrSet.ClearItem( ATTR_VALIDDATA );
500 						aAttrSet.ClearItem( ATTR_CONDITIONAL );
501 
502 						if ( SID_STYLE_NEW_BY_EXAMPLE == nSlotId )
503 						{
504 							if ( bUndo )
505 							{
506 								String aUndo = ScGlobal::GetRscString( STR_UNDO_EDITCELLSTYLE );
507 								pDocSh->GetUndoManager()->EnterListAction( aUndo, aUndo );
508 								bListAction = sal_True;
509 							}
510 
511 							sal_Bool			bConvertBack = sal_False;
512 							SfxStyleSheet*	pSheetInUse = (SfxStyleSheet*)
513 														  pTabViewShell->GetStyleSheetFromMarked();
514 
515 							// wenn neuer Style vorhanden und in der Selektion
516 							// verwendet wird, so darf der Parent nicht uebernommen
517 							// werden:
518 
519 							if ( pStyleSheet && pSheetInUse && pStyleSheet == pSheetInUse )
520 								pSheetInUse = NULL;
521 
522 							// wenn bereits vorhanden, erstmal entfernen...
523 							if ( pStyleSheet )
524 							{
525 								// Style-Pointer zu Namen vor Erase,
526 								// weil Zellen sonst ungueltige Pointer
527 								// enthalten.
528 								//!!! bei Gelenheit mal eine Methode, die
529 								//    das fuer einen bestimmten Style macht
530 								pDoc->StylesToNames();
531 								bConvertBack = sal_True;
532 								pStylePool->Remove(pStyleSheet);
533 							}
534 
535 							// ...und neu anlegen
536 							pStyleSheet = &pStylePool->Make( aStyleName, eFamily,
537 															 SFXSTYLEBIT_USERDEF );
538 
539 							// wenn ein Style vorhanden ist, so wird dieser
540 							// Parent der neuen Vorlage:
541 							if ( pSheetInUse && pStyleSheet->HasParentSupport() )
542 								pStyleSheet->SetParent( pSheetInUse->GetName() );
543 
544 							if ( bConvertBack )
545 								// Namen zu Style-Pointer
546 								pDoc->UpdStlShtPtrsFrmNms();
547                             else
548                                 pDoc->GetPool()->CellStyleCreated( aStyleName );
549 
550 							// Attribute uebernehmen und Style anwenden
551 							pStyleSheet->GetItemSet().Put( aAttrSet );
552                             pTabViewShell->UpdateStyleSheetInUse( pStyleSheet );
553 
554 							//	call SetStyleSheetToMarked after adding the ScUndoModifyStyle
555 							//	(pStyleSheet pointer is used!)
556 							bStyleToMarked = sal_True;
557 						}
558 						else // ( nSlotId == SID_STYLE_UPDATE_BY_EXAMPLE )
559 						{
560 							pStyleSheet = (SfxStyleSheet*)pTabViewShell->GetStyleSheetFromMarked();
561 
562 							if ( pStyleSheet )
563 							{
564 								aOldData.InitFromStyle( pStyleSheet );
565 
566 								if ( bUndo )
567 								{
568 									String aUndo = ScGlobal::GetRscString( STR_UNDO_EDITCELLSTYLE );
569 									pDocSh->GetUndoManager()->EnterListAction( aUndo, aUndo );
570 									bListAction = sal_True;
571 								}
572 
573 								pStyleSheet->GetItemSet().Put( aAttrSet );
574                                 pTabViewShell->UpdateStyleSheetInUse( pStyleSheet );
575 
576 								//	call SetStyleSheetToMarked after adding the ScUndoModifyStyle
577 								//	(pStyleSheet pointer is used!)
578 								bStyleToMarked = sal_True;
579 							}
580 						}
581 
582 						aNewData.InitFromStyle( pStyleSheet );
583 						bAddUndo = sal_True;
584 						rReq.Done();
585 					}
586 					break;
587 
588 					default:
589 						break;
590 				}
591 			} // case SFX_STYLE_FAMILY_PARA:
592 			break;
593 
594 			case SFX_STYLE_FAMILY_PAGE:
595 			{
596 				switch ( nSlotId )
597 				{
598 					case SID_STYLE_DELETE:
599 					{
600 						nRetMask = ( NULL != pStyleSheet );
601 						if ( pStyleSheet )
602 						{
603 							if ( pDoc->RemovePageStyleInUse( pStyleSheet->GetName() ) )
604 							{
605 								ScPrintFunc( pDocSh, pTabViewShell->GetPrinter(sal_True), nCurTab ).UpdatePages();
606 								rBindings.Invalidate( SID_STATUS_PAGESTYLE );
607 								rBindings.Invalidate( FID_RESET_PRINTZOOM );
608 							}
609 							pStylePool->Remove( pStyleSheet );
610 							rBindings.Invalidate( SID_STYLE_FAMILY4 );
611 							pDocSh->SetDocumentModified();
612 							bAddUndo = sal_True;
613 							rReq.Done();
614 						}
615 					}
616 					break;
617 
618 					case SID_STYLE_APPLY:
619 					{
620 						nRetMask = ( NULL != pStyleSheet );
621 						if ( pStyleSheet && !pScMod->GetIsWaterCan() )
622 						{
623                             ScUndoApplyPageStyle* pUndoAction = 0;
624                             for( SCTAB nTab = 0, nTabCount = pDoc->GetTableCount(); nTab < nTabCount; ++nTab )
625                             {
626                                 if( rMark.GetTableSelect( nTab ) )
627                                 {
628                                     String aOldName = pDoc->GetPageStyle( nTab );
629                                     if ( aOldName != aStyleName )
630                                     {
631                                         pDoc->SetPageStyle( nTab, aStyleName );
632                                         ScPrintFunc( pDocSh, pTabViewShell->GetPrinter(sal_True), nTab ).UpdatePages();
633                                         if( !pUndoAction )
634                                             pUndoAction = new ScUndoApplyPageStyle( pDocSh, aStyleName );
635                                         pUndoAction->AddSheetAction( nTab, aOldName );
636                                     }
637                                 }
638                             }
639                             if( pUndoAction )
640                             {
641                                 pDocSh->GetUndoManager()->AddUndoAction( pUndoAction );
642                                 pDocSh->SetDocumentModified();
643                                 rBindings.Invalidate( SID_STYLE_FAMILY4 );
644                                 rBindings.Invalidate( SID_STATUS_PAGESTYLE );
645                                 rBindings.Invalidate( FID_RESET_PRINTZOOM );
646                             }
647 							rReq.Done();
648 						}
649 					}
650 					break;
651 
652 					case SID_STYLE_NEW_BY_EXAMPLE:
653 					{
654 						const String& rStrCurStyle = pDoc->GetPageStyle( nCurTab );
655 
656 						if ( rStrCurStyle != aStyleName )
657 						{
658 							SfxStyleSheetBase*	pCurStyle = pStylePool->Find( rStrCurStyle, eFamily );
659 							SfxItemSet			aAttrSet  = pCurStyle->GetItemSet();
660 							SCTAB				nInTab;
661 							sal_Bool				bUsed = pDoc->IsPageStyleInUse( aStyleName, &nInTab );
662 
663 							// wenn bereits vorhanden, erstmal entfernen...
664 							if ( pStyleSheet )
665 								pStylePool->Remove( pStyleSheet );
666 
667 							// ...und neu anlegen
668 							pStyleSheet = &pStylePool->Make( aStyleName, eFamily,
669 															 SFXSTYLEBIT_USERDEF );
670 
671 							// Attribute uebernehmen
672 							pStyleSheet->GetItemSet().Put( aAttrSet );
673 							pDocSh->SetDocumentModified();
674 
675 							// wenn in Verwendung -> Update
676 							if ( bUsed )
677 								ScPrintFunc( pDocSh, pTabViewShell->GetPrinter(sal_True), nInTab ).UpdatePages();
678 
679 							aNewData.InitFromStyle( pStyleSheet );
680 							bAddUndo = sal_True;
681 							rReq.Done();
682 							nRetMask = sal_True;
683 						}
684 					}
685 					break;
686 
687 					default:
688 						break;
689 				} // switch ( nSlotId )
690 			} // case SFX_STYLE_FAMILY_PAGE:
691 			break;
692 
693 			default:
694 				break;
695 		} // switch ( eFamily )
696 
697 		// Neu anlegen oder bearbeiten ueber Dialog:
698 		if ( nSlotId == SID_STYLE_NEW || nSlotId == SID_STYLE_EDIT )
699 		{
700 			if ( pStyleSheet )
701 			{
702 				SvxNumberInfoItem* pNumberInfoItem = NULL;
703 
704 				SfxStyleFamily	eFam    = pStyleSheet->GetFamily();
705                 // ScDocument*     pDoc    = GetViewData()->GetDocument();
706                 // ScDocShell*     pDocSh  = GetViewData()->GetDocShell();
707 				//CHINA001 ScStyleDlg*		pDlg    = NULL;
708 				SfxAbstractTabDialog* pDlg    = NULL; //CHINA001
709 				sal_uInt16			nRsc	= 0;
710 
711 				//	#37034#/#37245# alte Items aus der Vorlage merken
712 				SfxItemSet aOldSet = pStyleSheet->GetItemSet();
713 				String aOldName = pStyleSheet->GetName();
714 
715 				switch ( eFam )
716 				{
717 					case SFX_STYLE_FAMILY_PAGE:
718 						nRsc = RID_SCDLG_STYLES_PAGE;
719 						break;
720 
721 					case SFX_STYLE_FAMILY_PARA:
722 					default:
723 						{
724 							SfxItemSet& rSet = pStyleSheet->GetItemSet();
725 
726 							const SfxPoolItem* pItem;
727 							if ( rSet.GetItemState( ATTR_VALUE_FORMAT,
728 									sal_False, &pItem ) == SFX_ITEM_SET )
729 							{
730 								// NumberFormat Value aus Value und Language
731 								// erzeugen und eintueten
732 								sal_uLong nFormat =
733 									((SfxUInt32Item*)pItem)->GetValue();
734 								LanguageType eLang =
735 									((SvxLanguageItem*)&rSet.Get(
736 									ATTR_LANGUAGE_FORMAT ))->GetLanguage();
737 								sal_uLong nLangFormat = pDoc->GetFormatTable()->
738 									GetFormatForLanguageIfBuiltIn( nFormat, eLang );
739 								if ( nLangFormat != nFormat )
740 								{
741 									SfxUInt32Item aNewItem( ATTR_VALUE_FORMAT, nLangFormat );
742 									rSet.Put( aNewItem );
743 									aOldSet.Put( aNewItem );
744 									// auch in aOldSet fuer Vergleich nach dem Dialog,
745 									// sonst geht evtl. eine Aenderung der Sprache verloren
746 								}
747 							}
748 
749 							pTabViewShell->MakeNumberInfoItem( pDoc, GetViewData(), &pNumberInfoItem );
750 							pDocSh->PutItem( *pNumberInfoItem );
751 							nRsc = RID_SCDLG_STYLES_PAR;
752 
753 							//	auf jeden Fall ein SvxBoxInfoItem mit Table = sal_False im Set:
754 							//	(wenn gar kein Item da ist, loescht der Dialog auch das
755 							//	 BORDER_OUTER SvxBoxItem aus dem Vorlagen-Set)
756 
757 							if ( rSet.GetItemState( ATTR_BORDER_INNER, sal_False ) != SFX_ITEM_SET )
758 							{
759 								SvxBoxInfoItem aBoxInfoItem( ATTR_BORDER_INNER );
760 								aBoxInfoItem.SetTable(sal_False);		// keine inneren Linien
761                                 aBoxInfoItem.SetDist(sal_True);
762                                 aBoxInfoItem.SetMinDist(sal_False);
763 								rSet.Put( aBoxInfoItem );
764 							}
765 						}
766 						break;
767 				}
768 
769 				//	If GetDefDialogParent is a dialog, it must be used
770 				//	(style catalog)
771 
772 				Window* pParent = Application::GetDefDialogParent();
773 				if ( !pParent || !pParent->IsDialog() )
774 				{
775 					//	#107256# GetDefDialogParent currently doesn't return the window
776 					//	that was set with SetDefDialogParent (but dynamically finds the
777 					//	topmost parent of the focus window), so IsDialog above is FALSE
778 					//	even if called from the style catalog.
779 					//	-> Use NULL if a modal dialog is open, to enable the Dialog's
780 					//	default parent handling.
781 					if ( Application::IsInModalMode() )
782 						pParent = NULL;
783 					else
784 						pParent = pTabViewShell->GetDialogParent();
785 				}
786 
787 				pTabViewShell->SetInFormatDialog(sal_True);
788 
789 				//CHINA001 pDlg = new ScStyleDlg( pParent, *pStyleSheet, nRsc );
790 				ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
791 				DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001
792 
793 				pDlg = pFact->CreateScStyleDlg( pParent, *pStyleSheet, nRsc, nRsc );
794 				DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001
795 				short nResult = pDlg->Execute();
796 				pTabViewShell->SetInFormatDialog(sal_False);
797 
798 				if ( nResult == RET_OK )
799 				{
800 					const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
801 
802 					if ( pOutSet )
803 					{
804 						nRetMask = pStyleSheet->GetMask();
805 
806 						//	#37034#/#37245# Attribut-Vergleiche (frueher in ModifyStyleSheet)
807 						//	jetzt hier mit den alten Werten (Style ist schon veraendert)
808 
809 						if ( SFX_STYLE_FAMILY_PARA == eFam )
810 						{
811 //							pDoc->CellStyleChanged( *pStyleSheet, aOldSet );
812 
813 							SfxItemSet& rNewSet = pStyleSheet->GetItemSet();
814 							sal_Bool bNumFormatChanged;
815 							if ( ScGlobal::CheckWidthInvalidate(
816 												bNumFormatChanged, aOldSet, rNewSet ) )
817 								pDoc->InvalidateTextWidth( NULL, NULL, bNumFormatChanged );
818 
819                             SCTAB nTabCount = pDoc->GetTableCount();
820                             for (SCTAB nTab=0; nTab<nTabCount; nTab++)
821                                 if (pDoc->IsStreamValid(nTab))
822                                     pDoc->SetStreamValid(nTab, sal_False);
823 
824 							sal_uLong nOldFormat = ((const SfxUInt32Item&)aOldSet.
825 													Get( ATTR_VALUE_FORMAT )).GetValue();
826 							sal_uLong nNewFormat = ((const SfxUInt32Item&)rNewSet.
827 													Get( ATTR_VALUE_FORMAT )).GetValue();
828 							if ( nNewFormat != nOldFormat )
829 							{
830 								SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
831 								const SvNumberformat* pOld = pFormatter->GetEntry( nOldFormat );
832 								const SvNumberformat* pNew = pFormatter->GetEntry( nNewFormat );
833 								if ( pOld && pNew && pOld->GetLanguage() != pNew->GetLanguage() )
834 									rNewSet.Put( SvxLanguageItem(
835 													pNew->GetLanguage(), ATTR_LANGUAGE_FORMAT ) );
836 							}
837 
838                             pDoc->GetPool()->CellStyleCreated( pStyleSheet->GetName() );
839 						}
840 						else
841 						{
842 							//!	auch fuer Seitenvorlagen die Abfragen hier
843 
844 							String aNewName = pStyleSheet->GetName();
845 							if ( aNewName != aOldName &&
846 									pDoc->RenamePageStyleInUse( aOldName, aNewName ) )
847 							{
848 								rBindings.Invalidate( SID_STATUS_PAGESTYLE );
849 								rBindings.Invalidate( FID_RESET_PRINTZOOM );
850 							}
851 
852 							pDoc->ModifyStyleSheet( *pStyleSheet, *pOutSet );
853 							rBindings.Invalidate( FID_RESET_PRINTZOOM );
854 						}
855 
856 						pDocSh->SetDocumentModified();
857 
858 						if ( SFX_STYLE_FAMILY_PARA == eFam )
859 						{
860 							pTabViewShell->UpdateNumberFormatter( pDoc,
861 								(const SvxNumberInfoItem&)
862 									*(pDocSh->GetItem(SID_ATTR_NUMBERFORMAT_INFO)) );
863 
864                             pTabViewShell->UpdateStyleSheetInUse( pStyleSheet );
865 							pTabViewShell->InvalidateAttribs();
866 						}
867 
868 						aNewData.InitFromStyle( pStyleSheet );
869 						bAddUndo = sal_True;
870 					}
871 				}
872 				else
873 				{
874 					if ( nSlotId == SID_STYLE_NEW )
875 						pStylePool->Remove( pStyleSheet );
876 					else
877 					{
878 						//	falls zwischendurch etwas mit dem temporaer geaenderten
879 						//	ItemSet gepainted wurde:
880 						pDocSh->PostPaintGridAll();
881 					}
882 				}
883 				delete pDlg;
884 			}
885 		}
886 
887 //		if ( nRetMask != 0xffff )// Irgendein Wert MUSS geliefert werden JN
888 			rReq.SetReturnValue( SfxUInt16Item( nSlotId, nRetMask ) );
889 
890 //      #96983# only stylist sends focus to sheet
891 //        if ( bGrabFocus )
892 //            pTabViewShell->GetActiveWin()->GrabFocus();
893 
894 		if ( bAddUndo && bUndo)
895 			pDocSh->GetUndoManager()->AddUndoAction(
896 						new ScUndoModifyStyle( pDocSh, eFamily, aOldData, aNewData ) );
897 
898 		if ( bStyleToMarked )
899 		{
900 			//	call SetStyleSheetToMarked after adding the ScUndoModifyStyle,
901 			//	so redo will find the modified style
902 			pTabViewShell->SetStyleSheetToMarked( (SfxStyleSheet*)pStyleSheet );
903 			pTabViewShell->InvalidateAttribs();
904 		}
905 
906 		if ( bListAction )
907 			pDocSh->GetUndoManager()->LeaveListAction();
908 	}
909 	else
910 	{
911 		DBG_ERROR( "Unknown slot (ScViewShell::ExecuteStyle)" );
912 	}
913 }
914 
915 void ScFormatShell::ExecuteNumFormat( SfxRequest& rReq )
916 {
917 	ScModule*			pScMod		= SC_MOD();
918 	ScTabViewShell*	pTabViewShell  	= GetViewData()->GetViewShell();
919 	const SfxItemSet*	pReqArgs	= rReq.GetArgs();
920 	sal_uInt16				nSlot		= rReq.GetSlot();
921 
922 	pTabViewShell->HideListBox();					// Autofilter-DropDown-Listbox
923 
924 									// Eingabe beenden
925 	if ( GetViewData()->HasEditView( GetViewData()->GetActivePart() ) )
926 	{
927 		switch ( nSlot )
928 		{
929 			case SID_NUMBER_TWODEC:
930 			case SID_NUMBER_SCIENTIFIC:
931 			case SID_NUMBER_DATE:
932 			case SID_NUMBER_CURRENCY:
933 			case SID_NUMBER_PERCENT:
934 			case SID_NUMBER_STANDARD:
935 			case SID_NUMBER_FORMAT:
936 			case SID_NUMBER_INCDEC:
937 			case SID_NUMBER_DECDEC:
938 			case FID_DEFINE_NAME:
939 			case FID_USE_NAME:
940 			case FID_INSERT_NAME:
941             case SID_SPELL_DIALOG:
942             case SID_HANGUL_HANJA_CONVERSION:
943 
944 			pScMod->InputEnterHandler();
945 			pTabViewShell->UpdateInputHandler();
946 			break;
947 
948 			default:
949 			break;
950 		}
951 	}
952 
953 	switch ( nSlot )
954 	{
955 		case SID_NUMBER_TWODEC:
956 			pTabViewShell->SetNumberFormat( NUMBERFORMAT_NUMBER, 4 );		// Standard+4 = #.##0,00
957 			rReq.Done();
958 			break;
959 		case SID_NUMBER_SCIENTIFIC:
960 			pTabViewShell->SetNumberFormat( NUMBERFORMAT_SCIENTIFIC );
961 			rReq.Done();
962 			break;
963 		case SID_NUMBER_DATE:
964 			pTabViewShell->SetNumberFormat( NUMBERFORMAT_DATE );
965 			rReq.Done();
966 			break;
967 		case SID_NUMBER_TIME:
968 			pTabViewShell->SetNumberFormat( NUMBERFORMAT_TIME );
969 			rReq.Done();
970 			break;
971 		case SID_NUMBER_CURRENCY:
972 			pTabViewShell->SetNumberFormat( NUMBERFORMAT_CURRENCY );
973 			rReq.Done();
974 			break;
975 		case SID_NUMBER_PERCENT:
976 			pTabViewShell->SetNumberFormat( NUMBERFORMAT_PERCENT );
977 			rReq.Done();
978 			break;
979 		case SID_NUMBER_STANDARD:
980 			pTabViewShell->SetNumberFormat( NUMBERFORMAT_NUMBER );
981 			rReq.Done();
982 			break;
983 		case SID_NUMBER_INCDEC:
984 			pTabViewShell->ChangeNumFmtDecimals( sal_True );
985 			rReq.Done();
986 			break;
987 		case SID_NUMBER_DECDEC:
988 			pTabViewShell->ChangeNumFmtDecimals( sal_False );
989 			rReq.Done();
990 			break;
991 
992 		case SID_NUMBER_FORMAT:
993 			//if ( pReqArgs )
994 			//{
995 			//	const SfxPoolItem* pItem;
996 			//	if(pReqArgs->GetItemState(nSlot, sal_True, &pItem) == SFX_ITEM_SET)
997 			//	{
998 			//		String aCode = ((const SfxStringItem*)pItem)->GetValue();
999 			//		pTabViewShell->SetNumFmtByStr( aCode );
1000 			//	}
1001 			//}
1002 
1003             // symphony version with format interpretation
1004 			if(pReqArgs)
1005 			{
1006 				const SfxPoolItem* pItem;
1007 				ScDocument* pDoc = pViewData->GetDocument();
1008 				SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
1009 				LanguageType eLanguage = ScGlobal::eLnge;
1010 				sal_Int16 eType = -1;
1011 				sal_uInt32 nCurrentNumberFormat;
1012 
1013                 pDoc->GetNumberFormat(pViewData->GetCurX(), pViewData->GetCurY(), pViewData->GetTabNo(), nCurrentNumberFormat);
1014 				const SvNumberformat* pEntry = pFormatter->GetEntry(nCurrentNumberFormat);
1015 
1016                 if(pEntry)
1017 				{
1018 					eLanguage = pEntry->GetLanguage();
1019 					eType = pEntry->GetType();
1020 				}
1021 
1022 				//Just use eType to judge whether the command is fired for NUMBER/PERCENT/CURRENCY
1023 				//In sidebar, users can fire SID_NUMBER_FORMAT command by operating the related UI controls before they are disable
1024 				switch(eType)
1025 				{
1026 				case NUMBERFORMAT_ALL:
1027 				case NUMBERFORMAT_NUMBER:
1028 				case NUMBERFORMAT_NUMBER| NUMBERFORMAT_DEFINED:
1029 				case NUMBERFORMAT_PERCENT:
1030 				case NUMBERFORMAT_PERCENT| NUMBERFORMAT_DEFINED:
1031 				case NUMBERFORMAT_CURRENCY:
1032 				case NUMBERFORMAT_CURRENCY|NUMBERFORMAT_DEFINED:
1033 					eType = 0;
1034 					break;
1035 				default:
1036 					eType =-1;
1037 				}
1038 
1039 				if(SFX_ITEM_SET == pReqArgs->GetItemState(nSlot, true, &pItem) && eType != -1)
1040 				{
1041 					String aCode = ((const SfxStringItem*)pItem)->GetValue();
1042 					sal_uInt16 aLen = aCode.Len();
1043 					String* sFormat = new String[4];
1044 					String sTmpStr = String::CreateFromAscii("");
1045 					sal_uInt16 nCount(0);
1046 					sal_uInt16 nStrCount(0);
1047 
1048 					while(nCount < aLen)
1049 					{
1050 						sal_Unicode cChar = aCode.GetChar(nCount);
1051 
1052 						if(cChar == sal_Unicode(','))
1053 						{
1054 							sFormat[nStrCount] = sTmpStr;
1055 							sTmpStr = String::CreateFromAscii("");
1056 							nStrCount++;
1057 						}
1058 						else
1059 						{
1060 							sTmpStr += cChar;
1061 						}
1062 
1063 						nCount++;
1064 
1065 						if(nStrCount > 3)
1066 							break;
1067 					}
1068 
1069 					const sal_Bool bThousand = (sal_Bool)sFormat[0].ToInt32();
1070 					const sal_Bool bNegRed = (sal_Bool)sFormat[1].ToInt32();
1071 					const sal_uInt16 nPrecision = (sal_uInt16)sFormat[2].ToInt32();
1072 					const sal_uInt16 nLeadZeroes = (sal_uInt16)sFormat[3].ToInt32();
1073 
1074 					pFormatter->GenerateFormat(
1075                         aCode,
1076                         nCurrentNumberFormat,//modify
1077 						eLanguage,
1078 						bThousand,
1079 						bNegRed,
1080 						nPrecision,
1081 						nLeadZeroes);
1082 					pTabViewShell->SetNumFmtByStr(aCode);
1083 					delete[] sFormat;
1084 				}
1085 			}
1086 			break;
1087 
1088         case SID_ATTR_NUMBERFORMAT_VALUE:
1089 			if ( pReqArgs )
1090 			{
1091 				const SfxPoolItem* pItem;
1092 				if ( pReqArgs->GetItemState( ATTR_VALUE_FORMAT, sal_True, &pItem ) == SFX_ITEM_SET )
1093 				{
1094                     // We have to accomplish this using ApplyAttributes()
1095                     // because we also need the language information to be
1096                     // considered.
1097                     const SfxItemSet& rOldSet =
1098                         pTabViewShell->GetSelectionPattern()->GetItemSet();
1099                     SfxItemPool* pDocPool = GetViewData()->GetDocument()->GetPool();
1100                     SfxItemSet aNewSet( *pDocPool, ATTR_PATTERN_START, ATTR_PATTERN_END );
1101                     aNewSet.Put( *pItem );
1102                     pTabViewShell->ApplyAttributes( &aNewSet, &rOldSet, sal_True );
1103 				}
1104 			}
1105 			break;
1106 
1107 		case SID_NUMBER_TYPE_FORMAT:
1108 			{
1109 				SfxInt16Item aFormatItem((const SfxInt16Item&)rReq.GetArgs()->Get(nSlot));
1110 				sal_uInt16 nFormat = aFormatItem.GetValue();
1111 				switch(nFormat)
1112 				{
1113 				case 0:
1114 					pTabViewShell->SetNumberFormat( NUMBERFORMAT_NUMBER); //Modify
1115 					break;
1116 				case 1:
1117 					pTabViewShell->SetNumberFormat( NUMBERFORMAT_NUMBER, 2 ); //Modify
1118 					break;
1119 				case 2:
1120 					pTabViewShell->SetNumberFormat( NUMBERFORMAT_PERCENT );
1121 					break;
1122 				case 3:
1123 					pTabViewShell->SetNumberFormat( NUMBERFORMAT_CURRENCY );
1124 					break;
1125 				case 4:
1126 					pTabViewShell->SetNumberFormat( NUMBERFORMAT_DATE );
1127 					break;
1128 				case 5:
1129 					pTabViewShell->SetNumberFormat( NUMBERFORMAT_TIME );
1130 					break;
1131 				case 6:
1132 					pTabViewShell->SetNumberFormat( NUMBERFORMAT_SCIENTIFIC );
1133 					break;
1134 				case 7:
1135 					pTabViewShell->SetNumberFormat( NUMBERFORMAT_FRACTION );
1136 					break;
1137 				case 8:
1138 					pTabViewShell->SetNumberFormat( NUMBERFORMAT_LOGICAL );
1139 					break;
1140 				case 9:
1141 					pTabViewShell->SetNumberFormat( NUMBERFORMAT_TEXT );
1142 					break;
1143 				default:
1144 					;
1145 				}
1146 				rReq.Done();
1147 			}
1148 			break;
1149 
1150         default:
1151 			DBG_ERROR("falscher Slot bei ExecuteEdit");
1152 			break;
1153 	}
1154 }
1155 
1156 
1157 //------------------------------------------------------------------
1158 
1159 #define APPLY_HOR_JUSTIFY(j) \
1160 	{																		\
1161 		if ( !pHorJustify || (eHorJustify != (j) ) )                        \
1162 			pTabViewShell->ApplyAttr( SvxHorJustifyItem( (j) ) );                          \
1163 		else                                                                \
1164 			pTabViewShell->ApplyAttr( SvxHorJustifyItem( SVX_HOR_JUSTIFY_STANDARD ) );     \
1165 	}
1166 
1167 #define APPLY_VER_JUSTIFY(j) \
1168 	{																		\
1169 		if ( !pVerJustify || (eVerJustify != (j) ) )                        \
1170 			pTabViewShell->ApplyAttr( SvxVerJustifyItem( (j) ) );                          \
1171 		else                                                                \
1172 			pTabViewShell->ApplyAttr( SvxVerJustifyItem( SVX_VER_JUSTIFY_STANDARD ) );     \
1173 	}
1174 
1175 void ScFormatShell::ExecuteAlignment( SfxRequest& rReq )
1176 {
1177 	ScTabViewShell*	pTabViewShell  		= GetViewData()->GetViewShell();
1178 	SfxBindings&			rBindings	= pViewData->GetBindings();
1179 	const SfxItemSet*       pSet		= rReq.GetArgs();
1180 	sal_uInt16					nSlot		= rReq.GetSlot();
1181 
1182 	pTabViewShell->HideListBox();	// Autofilter-DropDown-Listbox
1183 
1184     switch( nSlot )
1185     {
1186         // pseudo slots for Format menu
1187         case SID_ALIGN_ANY_HDEFAULT:
1188         case SID_ALIGN_ANY_LEFT:
1189         case SID_ALIGN_ANY_HCENTER:
1190         case SID_ALIGN_ANY_RIGHT:
1191         case SID_ALIGN_ANY_JUSTIFIED:
1192             pTabViewShell->ApplyAttr( SvxHorJustifyItem( lclConvertSlotToHAlign( nSlot ), ATTR_HOR_JUSTIFY ) );
1193         break;
1194         case SID_ALIGN_ANY_VDEFAULT:
1195         case SID_ALIGN_ANY_TOP:
1196         case SID_ALIGN_ANY_VCENTER:
1197         case SID_ALIGN_ANY_BOTTOM:
1198             pTabViewShell->ApplyAttr( SvxVerJustifyItem( lclConvertSlotToVAlign( nSlot ), ATTR_VER_JUSTIFY ) );
1199         break;
1200 
1201         default:
1202             if( pSet )
1203             {
1204                 const SfxPoolItem* pItem = NULL;
1205                 if( pSet->GetItemState(GetPool().GetWhich(nSlot), sal_True, &pItem  ) == SFX_ITEM_SET )
1206                 {
1207 
1208                     switch ( nSlot )
1209                     {
1210                         case SID_ATTR_ALIGN_HOR_JUSTIFY:
1211                         case SID_ATTR_ALIGN_VER_JUSTIFY:
1212                         case SID_ATTR_ALIGN_INDENT:
1213                         case SID_ATTR_ALIGN_HYPHENATION:
1214                         case SID_ATTR_ALIGN_DEGREES:
1215                         case SID_ATTR_ALIGN_LOCKPOS:
1216                         case SID_ATTR_ALIGN_MARGIN:
1217                         case SID_ATTR_ALIGN_STACKED:
1218                             pTabViewShell->ApplyAttr( *pItem );
1219                         break;
1220 
1221                         case SID_H_ALIGNCELL:
1222                         {
1223                             SvxCellHorJustify eJust = (SvxCellHorJustify)((const SvxHorJustifyItem*)pItem)->GetValue();
1224                             // #i78476# update alignment of text in cell edit mode
1225                             pTabViewShell->UpdateInputHandlerCellAdjust( eJust );
1226                             pTabViewShell->ApplyAttr( SvxHorJustifyItem( eJust, ATTR_HOR_JUSTIFY ) );
1227                         }
1228                         break;
1229                         case SID_V_ALIGNCELL:
1230                             pTabViewShell->ApplyAttr( SvxVerJustifyItem( (SvxCellVerJustify)((const SvxVerJustifyItem*)pItem)->GetValue(), ATTR_VER_JUSTIFY ) );
1231                         break;
1232                         default:
1233                             DBG_ERROR( "ExecuteAlignment: invalid slot" );
1234                             return;
1235                     }
1236                 }
1237             }
1238     }
1239 
1240     rBindings.Invalidate( SID_ALIGNLEFT );
1241     rBindings.Invalidate( SID_ALIGNRIGHT );
1242     rBindings.Invalidate( SID_ALIGNCENTERHOR );
1243     rBindings.Invalidate( SID_ALIGNBLOCK );
1244     rBindings.Invalidate( SID_ALIGNTOP );
1245     rBindings.Invalidate( SID_ALIGNBOTTOM );
1246     rBindings.Invalidate( SID_ALIGNCENTERVER );
1247     rBindings.Invalidate( SID_V_ALIGNCELL );
1248     rBindings.Invalidate( SID_H_ALIGNCELL );
1249     // pseudo slots for Format menu
1250     rBindings.Invalidate( SID_ALIGN_ANY_HDEFAULT );
1251     rBindings.Invalidate( SID_ALIGN_ANY_LEFT );
1252     rBindings.Invalidate( SID_ALIGN_ANY_HCENTER );
1253     rBindings.Invalidate( SID_ALIGN_ANY_RIGHT );
1254     rBindings.Invalidate( SID_ALIGN_ANY_JUSTIFIED );
1255     rBindings.Invalidate( SID_ALIGN_ANY_VDEFAULT );
1256     rBindings.Invalidate( SID_ALIGN_ANY_TOP );
1257     rBindings.Invalidate( SID_ALIGN_ANY_VCENTER );
1258     rBindings.Invalidate( SID_ALIGN_ANY_BOTTOM );
1259     rBindings.Update();
1260 
1261     if( ! rReq.IsAPI() )
1262         rReq.Done();
1263 }
1264 
1265 void ScFormatShell::ExecuteTextAttr( SfxRequest& rReq )
1266 {
1267 	ScTabViewShell*	pTabViewShell  		= GetViewData()->GetViewShell();
1268 	SfxBindings&			rBindings	= pViewData->GetBindings();
1269 	const ScPatternAttr*    pAttrs		= pTabViewShell->GetSelectionPattern();
1270 	const SfxItemSet*       pSet		= rReq.GetArgs();
1271 	sal_uInt16					nSlot		= rReq.GetSlot();
1272 	SfxAllItemSet*			pNewSet = 0;
1273 
1274 	pTabViewShell->HideListBox();					// Autofilter-DropDown-Listbox
1275 
1276 	if (  (nSlot == SID_ATTR_CHAR_WEIGHT)
1277 		||(nSlot == SID_ATTR_CHAR_POSTURE)
1278 		||(nSlot == SID_ATTR_CHAR_UNDERLINE)
1279 		||(nSlot == SID_ULINE_VAL_NONE)
1280 		||(nSlot == SID_ULINE_VAL_SINGLE)
1281 		||(nSlot == SID_ULINE_VAL_DOUBLE)
1282 		||(nSlot == SID_ULINE_VAL_DOTTED) )
1283 	{
1284 		pNewSet = new SfxAllItemSet( GetPool() );
1285 
1286 		switch ( nSlot )
1287 		{
1288 			case SID_ATTR_CHAR_WEIGHT:
1289 			{
1290 				// #i78017 establish the same behaviour as in Writer
1291 				sal_uInt8 nScript = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX;
1292 
1293 				SfxItemPool& rPool = GetPool();
1294 				SvxScriptSetItem aSetItem( nSlot, rPool );
1295 				if ( pSet )
1296 					aSetItem.PutItemForScriptType( nScript, pSet->Get( ATTR_FONT_WEIGHT ) );
1297 				else
1298 				{
1299 					//	toggle manually
1300 
1301 					FontWeight eWeight = WEIGHT_BOLD;
1302 					SvxScriptSetItem aOldSetItem( nSlot, rPool );
1303 					aOldSetItem.GetItemSet().Put( pAttrs->GetItemSet(), sal_False );
1304 					const SfxPoolItem* pCore = aOldSetItem.GetItemOfScript( nScript );
1305 					if ( pCore && ((const SvxWeightItem*)pCore)->GetWeight() == WEIGHT_BOLD )
1306 						eWeight = WEIGHT_NORMAL;
1307 
1308                     aSetItem.PutItemForScriptType( nScript, SvxWeightItem( eWeight, ATTR_FONT_WEIGHT ) );
1309 				}
1310 				pTabViewShell->ApplyUserItemSet( aSetItem.GetItemSet() );
1311 				pNewSet->Put( aSetItem.GetItemSet(), sal_False );
1312 			}
1313 			break;
1314 
1315 			case SID_ATTR_CHAR_POSTURE:
1316 			{
1317 				// #i78017 establish the same behaviour as in Writer
1318 				sal_uInt8 nScript = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX;
1319 
1320 				SfxItemPool& rPool = GetPool();
1321 				SvxScriptSetItem aSetItem( nSlot, rPool );
1322 				if ( pSet )
1323 					aSetItem.PutItemForScriptType( nScript, pSet->Get( ATTR_FONT_POSTURE ) );
1324 				else
1325 				{
1326 					//	toggle manually
1327 
1328 					FontItalic eItalic = ITALIC_NORMAL;
1329 					SvxScriptSetItem aOldSetItem( nSlot, rPool );
1330 					aOldSetItem.GetItemSet().Put( pAttrs->GetItemSet(), sal_False );
1331 					const SfxPoolItem* pCore = aOldSetItem.GetItemOfScript( nScript );
1332 					if ( pCore && ((const SvxPostureItem*)pCore)->GetPosture() == ITALIC_NORMAL )
1333 						eItalic = ITALIC_NONE;
1334 
1335                     aSetItem.PutItemForScriptType( nScript, SvxPostureItem( eItalic, ATTR_FONT_POSTURE ) );
1336 				}
1337 				pTabViewShell->ApplyUserItemSet( aSetItem.GetItemSet() );
1338 				pNewSet->Put( aSetItem.GetItemSet(), sal_False );
1339 			}
1340 			break;
1341 
1342 			case SID_ATTR_CHAR_UNDERLINE:
1343 				{
1344 					FontUnderline       eUnderline;
1345 
1346 					if( pSet )
1347 					{
1348                         const SfxPoolItem& rUnderline = pSet->Get( ATTR_FONT_UNDERLINE );
1349 
1350 						if( rUnderline.ISA(SvxUnderlineItem) )
1351 						{
1352 							pTabViewShell->ApplyAttr( rUnderline );
1353 							pNewSet->Put( rUnderline,rUnderline.Which() );
1354 						}
1355                         else if ( rUnderline.ISA(SvxTextLineItem) )
1356                         {
1357                             // #i106580# also allow SvxTextLineItem (base class of SvxUnderlineItem)
1358                             const SvxTextLineItem& rTextLineItem = static_cast<const SvxTextLineItem&>(rUnderline);
1359                             SvxUnderlineItem aNewItem( rTextLineItem.GetLineStyle(), rTextLineItem.Which() );
1360                             aNewItem.SetColor( rTextLineItem.GetColor() );
1361                             pTabViewShell->ApplyAttr( aNewItem );
1362                             pNewSet->Put( aNewItem, aNewItem.Which() );
1363                         }
1364 					}
1365 					else
1366 					{
1367 						SvxUnderlineItem aUnderline( (const SvxUnderlineItem&)
1368 														pAttrs->GetItem(
1369 															ATTR_FONT_UNDERLINE ) );
1370 						eUnderline = (UNDERLINE_NONE != aUnderline.GetLineStyle())
1371 									? UNDERLINE_NONE
1372 									: UNDERLINE_SINGLE;
1373 						aUnderline.SetLineStyle( eUnderline );
1374 						pTabViewShell->ApplyAttr( aUnderline );
1375 						pNewSet->Put( aUnderline,aUnderline.Which() );
1376 					}
1377 				}
1378 				break;
1379 
1380 			case SID_ULINE_VAL_NONE:
1381 				pTabViewShell->ApplyAttr( SvxUnderlineItem( UNDERLINE_NONE, ATTR_FONT_UNDERLINE ) );
1382 				break;
1383 			case SID_ULINE_VAL_SINGLE:		// Toggles
1384 			case SID_ULINE_VAL_DOUBLE:
1385 			case SID_ULINE_VAL_DOTTED:
1386 				{
1387 					FontUnderline eOld = ((const SvxUnderlineItem&)
1388 											pAttrs->GetItem(ATTR_FONT_UNDERLINE)).GetLineStyle();
1389 					FontUnderline eNew = eOld;
1390 					switch (nSlot)
1391 					{
1392 						case SID_ULINE_VAL_SINGLE:
1393 							eNew = ( eOld == UNDERLINE_SINGLE ) ? UNDERLINE_NONE : UNDERLINE_SINGLE;
1394 							break;
1395 						case SID_ULINE_VAL_DOUBLE:
1396 							eNew = ( eOld == UNDERLINE_DOUBLE ) ? UNDERLINE_NONE : UNDERLINE_DOUBLE;
1397 							break;
1398 						case SID_ULINE_VAL_DOTTED:
1399 							eNew = ( eOld == UNDERLINE_DOTTED ) ? UNDERLINE_NONE : UNDERLINE_DOTTED;
1400 							break;
1401 					}
1402 					pTabViewShell->ApplyAttr( SvxUnderlineItem( eNew, ATTR_FONT_UNDERLINE ) );
1403 				}
1404 				break;
1405 
1406 			default:
1407 				break;
1408 		}
1409 		rBindings.Invalidate( nSlot );
1410 	}
1411 	else
1412 	{
1413 		/*
1414 		 * "Selbstgemachte" RadioButton-Funktionalitaet
1415 		 * Beim Toggle gibt es den Standard-State, d.h. kein
1416 		 * Button ist gedrueckt
1417 		 */
1418 
1419 		const SfxItemSet&		 rAttrSet	= pTabViewShell->GetSelectionPattern()->GetItemSet();
1420 		const SfxPoolItem*       pItem       = NULL;
1421 		const SvxHorJustifyItem* pHorJustify = NULL;
1422 		const SvxVerJustifyItem* pVerJustify = NULL;
1423 		SvxCellHorJustify        eHorJustify = SVX_HOR_JUSTIFY_STANDARD;
1424 		SvxCellVerJustify        eVerJustify = SVX_VER_JUSTIFY_STANDARD;
1425 
1426 		if (rAttrSet.GetItemState(ATTR_HOR_JUSTIFY, sal_True,&pItem ) == SFX_ITEM_SET)
1427 		{
1428 			pHorJustify = (const SvxHorJustifyItem*)pItem;
1429 			eHorJustify = SvxCellHorJustify( pHorJustify->GetValue() );
1430 		}
1431 		if (rAttrSet.GetItemState(ATTR_VER_JUSTIFY, sal_True,&pItem ) == SFX_ITEM_SET)
1432 		{
1433 			pVerJustify = (const SvxVerJustifyItem*)pItem;
1434 			eVerJustify = SvxCellVerJustify( pVerJustify->GetValue() );
1435 		}
1436 
1437 		switch ( nSlot )
1438 		{
1439 			case SID_ALIGNLEFT:
1440 				rReq.SetSlot( SID_H_ALIGNCELL );
1441 				rReq.AppendItem( SvxHorJustifyItem(
1442 					!pHorJustify || (eHorJustify != SVX_HOR_JUSTIFY_LEFT) ?
1443 					SVX_HOR_JUSTIFY_LEFT : SVX_HOR_JUSTIFY_STANDARD, SID_H_ALIGNCELL ) );
1444 				ExecuteSlot( rReq, GetInterface() );
1445 				return;
1446 //				APPLY_HOR_JUSTIFY( SVX_HOR_JUSTIFY_LEFT );
1447                 //break;
1448 
1449 			case SID_ALIGNRIGHT:
1450 				rReq.SetSlot( SID_H_ALIGNCELL );
1451 				rReq.AppendItem( SvxHorJustifyItem(
1452 					!pHorJustify || (eHorJustify != SVX_HOR_JUSTIFY_RIGHT) ?
1453 					SVX_HOR_JUSTIFY_RIGHT : SVX_HOR_JUSTIFY_STANDARD, SID_H_ALIGNCELL ) );
1454 				ExecuteSlot( rReq, GetInterface() );
1455 				return;
1456 //				APPLY_HOR_JUSTIFY( SVX_HOR_JUSTIFY_RIGHT );
1457                 //break;
1458 
1459 			case SID_ALIGNCENTERHOR:
1460 				rReq.SetSlot( SID_H_ALIGNCELL );
1461 				rReq.AppendItem( SvxHorJustifyItem(
1462 					!pHorJustify || (eHorJustify != SVX_HOR_JUSTIFY_CENTER) ?
1463 					SVX_HOR_JUSTIFY_CENTER : SVX_HOR_JUSTIFY_STANDARD, SID_H_ALIGNCELL ) );
1464 				ExecuteSlot( rReq, GetInterface() );
1465 				return;
1466 //				APPLY_HOR_JUSTIFY( SVX_HOR_JUSTIFY_CENTER );
1467                 //break;
1468 
1469 			case SID_ALIGNBLOCK:
1470 				rReq.SetSlot( SID_H_ALIGNCELL );
1471 				rReq.AppendItem( SvxHorJustifyItem(
1472 					!pHorJustify || (eHorJustify != SVX_HOR_JUSTIFY_BLOCK) ?
1473 					SVX_HOR_JUSTIFY_BLOCK : SVX_HOR_JUSTIFY_STANDARD, SID_H_ALIGNCELL ) );
1474 				ExecuteSlot( rReq, GetInterface() );
1475 				return;
1476 //				APPLY_HOR_JUSTIFY( SVX_HOR_JUSTIFY_BLOCK );
1477                 //break;
1478 
1479 			case SID_ALIGNTOP:
1480 				rReq.SetSlot( SID_V_ALIGNCELL );
1481 				rReq.AppendItem( SvxVerJustifyItem(
1482 					!pVerJustify || (eVerJustify != SVX_VER_JUSTIFY_TOP) ?
1483 					SVX_VER_JUSTIFY_TOP : SVX_VER_JUSTIFY_STANDARD, SID_V_ALIGNCELL ) );
1484 				ExecuteSlot( rReq, GetInterface() );
1485 				return;
1486 //				APPLY_VER_JUSTIFY( SVX_VER_JUSTIFY_TOP );
1487                 //break;
1488 
1489 			case SID_ALIGNBOTTOM:
1490 				rReq.SetSlot( SID_V_ALIGNCELL );
1491 				rReq.AppendItem( SvxVerJustifyItem(
1492 					!pVerJustify || (eVerJustify != SVX_VER_JUSTIFY_BOTTOM) ?
1493 					SVX_VER_JUSTIFY_BOTTOM : SVX_VER_JUSTIFY_STANDARD, SID_V_ALIGNCELL ) );
1494 				ExecuteSlot( rReq, GetInterface() );
1495 				return;
1496 //				APPLY_VER_JUSTIFY( SVX_VER_JUSTIFY_BOTTOM );
1497                 //break;
1498 
1499 			case SID_ALIGNCENTERVER:
1500 				rReq.SetSlot( SID_V_ALIGNCELL );
1501 				rReq.AppendItem( SvxVerJustifyItem(
1502 					!pVerJustify || (eVerJustify != SVX_VER_JUSTIFY_CENTER) ?
1503 					SVX_VER_JUSTIFY_CENTER : SVX_VER_JUSTIFY_STANDARD, SID_V_ALIGNCELL ) );
1504 				ExecuteSlot( rReq, GetInterface() );
1505 				return;
1506 //				APPLY_VER_JUSTIFY( SVX_VER_JUSTIFY_CENTER );
1507                 //break;
1508 
1509 			default:
1510 			break;
1511 		}
1512 
1513 	}
1514 
1515 	rBindings.Update();
1516 //	rReq.Done();
1517 
1518 	if( pNewSet )
1519 	{
1520 		rReq.Done( *pNewSet );
1521 		delete pNewSet;
1522 	}
1523 	else
1524 	{
1525 		rReq.Done();
1526 	}
1527 
1528 }
1529 
1530 #undef APPLY_HOR_JUSTIFY
1531 #undef APPLY_VER_JUSTIFY
1532 
1533 //------------------------------------------------------------------
1534 
1535 void ScFormatShell::ExecuteAttr( SfxRequest& rReq )
1536 {
1537 	ScTabViewShell*	pTabViewShell  		= GetViewData()->GetViewShell();
1538 	SfxBindings&		rBindings = pViewData->GetBindings();
1539 	const SfxItemSet*	pNewAttrs = rReq.GetArgs();
1540 
1541 	pTabViewShell->HideListBox();					// Autofilter-DropDown-Listbox
1542 
1543 	if ( !pNewAttrs )
1544 	{
1545 		sal_uInt16 nSlot = rReq.GetSlot();
1546 
1547 		switch ( nSlot )
1548 		{
1549 			case SID_ATTR_CHAR_FONT:
1550 			case SID_ATTR_CHAR_FONTHEIGHT:
1551 				pTabViewShell->ExecuteCellFormatDlg( rReq, TP_FONT );	    // wenn ToolBar vertikal
1552 				break;
1553 
1554 			case SID_ATTR_ALIGN_LINEBREAK:					// ohne Parameter als Toggle
1555 				{
1556 					const ScPatternAttr* pAttrs = pTabViewShell->GetSelectionPattern();
1557 					sal_Bool bOld = ((const SfxBoolItem&)pAttrs->GetItem(ATTR_LINEBREAK)).GetValue();
1558 					SfxBoolItem aBreakItem( ATTR_LINEBREAK, !bOld );
1559 					pTabViewShell->ApplyAttr( aBreakItem );
1560 
1561 					SfxAllItemSet aNewSet( GetPool() );
1562 					aNewSet.Put( aBreakItem,aBreakItem.Which() );
1563 					rReq.Done( aNewSet );
1564 
1565 					rBindings.Invalidate( nSlot );
1566 				}
1567 				break;
1568 
1569 			case SID_BACKGROUND_COLOR:
1570 				{
1571 					//	SID_BACKGROUND_COLOR without arguments -> set transparent background
1572 
1573 					SvxBrushItem        aBrushItem( (const SvxBrushItem&)
1574 											pTabViewShell->GetSelectionPattern()->
1575 												GetItem( ATTR_BACKGROUND ) );
1576 
1577 					aBrushItem.SetColor( COL_TRANSPARENT );
1578 
1579 					pTabViewShell->ApplyAttr( aBrushItem );
1580 				}
1581 				break;
1582 		}
1583 	}
1584 	else
1585 	{
1586 		sal_uInt16 nSlot = rReq.GetSlot();
1587 
1588 		switch ( nSlot )
1589 		{
1590             case SID_ATTR_CHAR_OVERLINE:
1591             case SID_ATTR_CHAR_STRIKEOUT:
1592 			case SID_ATTR_ALIGN_LINEBREAK:
1593 			case SID_ATTR_CHAR_COLOR:
1594             case SID_ATTR_CHAR_CONTOUR:
1595             case SID_ATTR_CHAR_SHADOWED:
1596             case SID_ATTR_CHAR_RELIEF:
1597             case SID_SCATTR_PROTECTION :
1598 				pTabViewShell->ApplyAttr( pNewAttrs->Get( pNewAttrs->GetPool()->GetWhich( nSlot ) ) );
1599 				rBindings.Invalidate( nSlot );
1600 				rBindings.Update( nSlot );
1601 				break;
1602 
1603 			case SID_ATTR_CHAR_FONT:
1604 			case SID_ATTR_CHAR_FONTHEIGHT:
1605 				{
1606 					// #i78017 establish the same behaviour as in Writer
1607 					sal_uInt8 nScript = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX;
1608 					if (nSlot == SID_ATTR_CHAR_FONT)
1609 						nScript = pTabViewShell->GetSelectionScriptType();
1610 
1611 					SfxItemPool& rPool = GetPool();
1612 					SvxScriptSetItem aSetItem( nSlot, rPool );
1613 					sal_uInt16 nWhich = rPool.GetWhich( nSlot );
1614 					aSetItem.PutItemForScriptType( nScript, pNewAttrs->Get( nWhich ) );
1615 
1616 					pTabViewShell->ApplyUserItemSet( aSetItem.GetItemSet() );
1617 
1618 					rBindings.Invalidate( nSlot );
1619 					rBindings.Update( nSlot );
1620 				}
1621 				break;
1622 
1623 			case SID_FRAME_LINESTYLE:
1624 				{
1625 					// Default-Linie aktualisieren
1626 					const SvxBorderLine* pLine =
1627 							((const SvxLineItem&)
1628 								pNewAttrs->Get( SID_FRAME_LINESTYLE )).
1629 								GetLine();
1630 
1631 					if ( pLine )
1632 					{
1633 						SvxBorderLine* pDefLine = pTabViewShell->GetDefaultFrameLine();
1634 
1635 						if ( pDefLine )
1636 						{
1637 							pDefLine->SetOutWidth( pLine->GetOutWidth() );
1638 							pDefLine->SetInWidth ( pLine->GetInWidth() );
1639 							pDefLine->SetDistance( pLine->GetDistance() );
1640 							pTabViewShell->SetSelectionFrameLines( pDefLine, sal_False );
1641 						}
1642 						else
1643 						{
1644 							pTabViewShell->SetDefaultFrameLine( pLine );
1645 							pTabViewShell->GetDefaultFrameLine()->SetColor( COL_BLACK );
1646 							pTabViewShell->SetSelectionFrameLines( pLine, sal_False );
1647 						}
1648 					}
1649 					else
1650 					{
1651 						Color           aColorBlack( COL_BLACK );
1652 						SvxBorderLine   aDefLine( &aColorBlack, 20, 0, 0 );
1653 						pTabViewShell->SetDefaultFrameLine( &aDefLine );
1654 						pTabViewShell->SetSelectionFrameLines( NULL, sal_False );
1655 					}
1656 				}
1657 				break;
1658 
1659 			case SID_FRAME_LINECOLOR:
1660 				{
1661 					SvxBorderLine*  pDefLine = pTabViewShell->GetDefaultFrameLine();
1662 					const Color&    rColor = ((const SvxColorItem&)
1663 										pNewAttrs->Get( SID_FRAME_LINECOLOR )).
1664 											GetValue();
1665 
1666 					// Default-Linie aktualisieren
1667 					if ( pDefLine )
1668 					{
1669 						pDefLine->SetColor( rColor );
1670 						pTabViewShell->SetSelectionFrameLines( pDefLine, sal_True );
1671 					}
1672 					else
1673 					{
1674 						SvxBorderLine   aDefLine( &rColor, 20, 0, 0 );
1675 						pTabViewShell->SetDefaultFrameLine( &aDefLine );
1676 						pTabViewShell->SetSelectionFrameLines( &aDefLine, sal_False );
1677 					}
1678 				}
1679 				break;
1680 
1681 			case SID_ATTR_BORDER_OUTER:
1682 			case SID_ATTR_BORDER:
1683 				{
1684 					SvxBorderLine*          pDefLine = pTabViewShell->GetDefaultFrameLine();
1685 					const ScPatternAttr*    pOldAttrs = pTabViewShell->GetSelectionPattern();
1686 					ScDocument*             pDoc = GetViewData()->GetDocument();
1687 					SfxItemSet*             pOldSet =
1688 												new SfxItemSet(
1689 														*(pDoc->GetPool()),
1690 														ATTR_PATTERN_START,
1691 														ATTR_PATTERN_END );
1692 					SfxItemSet*             pNewSet =
1693 												new SfxItemSet(
1694 														*(pDoc->GetPool()),
1695 														ATTR_PATTERN_START,
1696 														ATTR_PATTERN_END );
1697 					const SfxPoolItem&      rBorderAttr =
1698 												pOldAttrs->GetItemSet().
1699 													Get( ATTR_BORDER );
1700 
1701 					// Border-Items vom Controller auswerten:
1702 					const SfxPoolItem* pItem = 0;
1703 
1704 					if ( pNewAttrs->GetItemState( ATTR_BORDER, sal_True, &pItem )
1705 						 == SFX_ITEM_SET )
1706 					{
1707 						//	#100959# The SvxFrameToolBoxControl toolbox controller uses a default
1708 						//	SvxBorderLine (all widths 0) to mark the lines that should be set.
1709 						//	Macro recording uses a SvxBoxItem with the real values (OutWidth > 0)
1710 						//	or NULL pointers for no lines.
1711 						//	-> Substitute existing lines with pDefLine only if widths are 0.
1712 						SvxBoxItem aBoxItem ( *(const SvxBoxItem*)pItem );
1713 						if ( aBoxItem.GetTop() && aBoxItem.GetTop()->GetOutWidth() == 0 )
1714 							aBoxItem.SetLine( pDefLine, BOX_LINE_TOP );
1715 						if ( aBoxItem.GetBottom() && aBoxItem.GetBottom()->GetOutWidth() == 0 )
1716 							aBoxItem.SetLine( pDefLine, BOX_LINE_BOTTOM );
1717 						if ( aBoxItem.GetLeft() && aBoxItem.GetLeft()->GetOutWidth() == 0 )
1718 							aBoxItem.SetLine( pDefLine, BOX_LINE_LEFT );
1719 						if ( aBoxItem.GetRight() && aBoxItem.GetRight()->GetOutWidth() == 0 )
1720 							aBoxItem.SetLine( pDefLine, BOX_LINE_RIGHT );
1721 						pNewSet->Put( aBoxItem );
1722                         rReq.AppendItem( aBoxItem );
1723 					}
1724 
1725 					if ( pNewAttrs->GetItemState( ATTR_BORDER_INNER, sal_True, &pItem )
1726 						 == SFX_ITEM_SET )
1727 					{
1728 						SvxBoxInfoItem aBoxInfoItem( *(const SvxBoxInfoItem*)pItem );
1729 						if ( aBoxInfoItem.GetHori() && aBoxInfoItem.GetHori()->GetOutWidth() == 0 )
1730 							aBoxInfoItem.SetLine( pDefLine, BOXINFO_LINE_HORI );
1731 						if ( aBoxInfoItem.GetVert() && aBoxInfoItem.GetVert()->GetOutWidth() == 0 )
1732 							aBoxInfoItem.SetLine( pDefLine, BOXINFO_LINE_VERT );
1733 						pNewSet->Put( aBoxInfoItem );
1734                         rReq.AppendItem( aBoxInfoItem );
1735 					}
1736 					else
1737 					{
1738 						SvxBoxInfoItem aBoxInfoItem( ATTR_BORDER_INNER );
1739 						aBoxInfoItem.SetLine( NULL, BOXINFO_LINE_HORI );
1740 						aBoxInfoItem.SetLine( NULL, BOXINFO_LINE_VERT );
1741 						pNewSet->Put( aBoxInfoItem );
1742 					}
1743 
1744 					pOldSet->Put( rBorderAttr );
1745 					pTabViewShell->ApplyAttributes( pNewSet, pOldSet );
1746 
1747 					delete pOldSet;
1748 					delete pNewSet;
1749 				}
1750 				break;
1751 
1752 			case SID_ATTR_BORDER_DIAG_TLBR:
1753 			case SID_ATTR_BORDER_DIAG_BLTR:
1754 				{
1755 					ScDocument* pDoc = GetViewData()->GetDocument();
1756 					const ScPatternAttr* pOldAttrs = pTabViewShell->GetSelectionPattern();
1757 					SfxItemSet* pOldSet = new SfxItemSet(pOldAttrs->GetItemSet());
1758 					SfxItemSet* pNewSet = new SfxItemSet(pOldAttrs->GetItemSet());
1759 					const SfxPoolItem* pItem = 0;
1760 
1761                     if(SID_ATTR_BORDER_DIAG_TLBR == nSlot)
1762 					{
1763 						if(SFX_ITEM_SET == pNewAttrs->GetItemState(ATTR_BORDER_TLBR, true, &pItem))
1764 						{
1765 							SvxLineItem aItem(ATTR_BORDER_TLBR);
1766 							aItem.SetLine(((const SvxLineItem&)pNewAttrs->Get(ATTR_BORDER_TLBR)).GetLine());
1767 							pNewSet->Put(aItem);
1768 							rReq.AppendItem(aItem);
1769 							pTabViewShell->ApplyAttributes(pNewSet, pOldSet);
1770 						}
1771 					}
1772 					else // if( nSlot == SID_ATTR_BORDER_DIAG_BLTR )
1773 					{
1774 						if(SFX_ITEM_SET == pNewAttrs->GetItemState(ATTR_BORDER_BLTR, true, &pItem ))
1775 						{
1776 							SvxLineItem aItem(ATTR_BORDER_BLTR);
1777 							aItem.SetLine(((const SvxLineItem&)pNewAttrs->Get(ATTR_BORDER_BLTR)).GetLine());
1778 							pNewSet->Put(aItem);
1779 							rReq.AppendItem(aItem);
1780 							pTabViewShell->ApplyAttributes(pNewSet, pOldSet);
1781 						}
1782 					}
1783 
1784                     delete pOldSet;
1785 					delete pNewSet;
1786 					rBindings.Invalidate(nSlot);
1787 				}
1788 				break;
1789 
1790 			// ATTR_BACKGROUND (=SID_ATTR_BRUSH) muss ueber zwei IDs
1791 			// gesetzt werden:
1792 			case SID_BACKGROUND_COLOR:
1793 				{
1794 					const SvxColorItem  rNewColorItem = (const SvxColorItem&)
1795 											pNewAttrs->Get( SID_BACKGROUND_COLOR );
1796 
1797 					SvxBrushItem        aBrushItem( (const SvxBrushItem&)
1798 											pTabViewShell->GetSelectionPattern()->
1799 												GetItem( ATTR_BACKGROUND ) );
1800 
1801 					aBrushItem.SetColor( rNewColorItem.GetValue() );
1802 
1803 					pTabViewShell->ApplyAttr( aBrushItem );
1804 				}
1805 				break;
1806 
1807 				case SID_ATTR_BRUSH:
1808 				{
1809 					SvxBrushItem        aBrushItem( (const SvxBrushItem&)
1810 											pTabViewShell->GetSelectionPattern()->
1811 												GetItem( ATTR_BACKGROUND ) );
1812 					const SvxBrushItem& rNewBrushItem = (const SvxBrushItem&)
1813 											pNewAttrs->Get( GetPool().GetWhich(nSlot) );
1814 					aBrushItem.SetColor(rNewBrushItem.GetColor());
1815 					pTabViewShell->ApplyAttr( aBrushItem );
1816 				}
1817 				break;
1818 
1819 			case SID_ATTR_BORDER_SHADOW:
1820 				{
1821 					const SvxShadowItem& rNewShadowItem = (const SvxShadowItem&)
1822 											pNewAttrs->Get( ATTR_SHADOW );
1823 					pTabViewShell->ApplyAttr( rNewShadowItem );
1824 				}
1825 				break;
1826 
1827 			default:
1828 			break;
1829 		}
1830 
1831 		if( ! rReq.IsAPI() )
1832 			if( ! rReq.IsDone() )
1833 				rReq.Done();
1834 	}
1835 }
1836 
1837 void ScFormatShell::GetAttrState( SfxItemSet& rSet )
1838 {
1839 	ScTabViewShell*	pTabViewShell  	= GetViewData()->GetViewShell();
1840 	const SfxItemSet&	 rAttrSet	= pTabViewShell->GetSelectionPattern()->GetItemSet();
1841 	const SvxBorderLine* pLine      = pTabViewShell->GetDefaultFrameLine();
1842 	const SvxBrushItem&  rBrushItem = (const SvxBrushItem&)rAttrSet.Get( ATTR_BACKGROUND );
1843 	SfxWhichIter aIter( rSet );
1844 	sal_uInt16 nWhich = aIter.FirstWhich();
1845 
1846 	rSet.Put( rAttrSet, sal_False );
1847 
1848 	//	choose font info according to selection script type
1849 	sal_uInt8 nScript = 0;		// GetSelectionScriptType never returns 0
1850 	if ( rSet.GetItemState( ATTR_FONT ) != SFX_ITEM_UNKNOWN )
1851 	{
1852 		if (!nScript) nScript = pTabViewShell->GetSelectionScriptType();
1853 		ScViewUtil::PutItemScript( rSet, rAttrSet, ATTR_FONT, nScript );
1854 	}
1855 	if ( rSet.GetItemState( ATTR_FONT_HEIGHT ) != SFX_ITEM_UNKNOWN )
1856 	{
1857 		if (!nScript) nScript = pTabViewShell->GetSelectionScriptType();
1858 		ScViewUtil::PutItemScript( rSet, rAttrSet, ATTR_FONT_HEIGHT, nScript );
1859 	}
1860 
1861 	while ( nWhich )
1862 	{
1863 		switch(nWhich)
1864 		{
1865 			case SID_BACKGROUND_COLOR:
1866 			{
1867                 rSet.Put( SvxColorItem( rBrushItem.GetColor(), SID_BACKGROUND_COLOR ) );
1868 
1869                 if(SFX_ITEM_DONTCARE == rAttrSet.GetItemState(ATTR_BACKGROUND))
1870                 {
1871                     rSet.InvalidateItem(SID_BACKGROUND_COLOR);
1872                 }
1873 			}
1874 			break;
1875     		case SID_FRAME_LINESTYLE:
1876 			case SID_FRAME_LINECOLOR:
1877 			{
1878                 // handled together because both need the cell border information for decisions
1879                 // rSet.Put( SvxColorItem( pLine ? pLine->GetColor() : Color(), SID_FRAME_LINECOLOR ) );
1880 				Color aCol = 0;
1881 				sal_uInt16 nOut = 0, nIn = 0, nDis = 0;
1882 				SvxBorderLine aLine(0,0,0,0);
1883 				bool bCol = 0;
1884 				bool bColDisable = 0, bStyleDisable = 0;
1885                 SvxBoxItem aBoxItem(ATTR_BORDER);
1886                 SvxBoxInfoItem aInfoItem(ATTR_BORDER_INNER);
1887 
1888                 pTabViewShell->GetSelectionFrame(aBoxItem, aInfoItem);
1889 
1890 				if( aBoxItem.GetTop() )
1891 				{
1892 					bCol = 1;
1893 					aCol = aBoxItem.GetTop()->GetColor() ;
1894 					aLine.SetColor(aCol);
1895 					aLine.SetOutWidth( aBoxItem.GetTop()->GetOutWidth());
1896 					aLine.SetInWidth( aBoxItem.GetTop()->GetInWidth());
1897 					aLine.SetDistance( aBoxItem.GetTop()->GetDistance());
1898 				}
1899 
1900                 if( aBoxItem.GetBottom() )
1901 				{
1902 					if(bCol == 0)
1903 					{
1904 						bCol = 1;
1905 						aCol = aBoxItem.GetBottom()->GetColor() ;
1906 						aLine.SetColor(aCol);
1907 						aLine.SetOutWidth( aBoxItem.GetBottom()->GetOutWidth());
1908 						aLine.SetInWidth( aBoxItem.GetBottom()->GetInWidth());
1909 						aLine.SetDistance( aBoxItem.GetBottom()->GetDistance());
1910 					}
1911 					else
1912 					{
1913 						if(aCol != aBoxItem.GetBottom()->GetColor() )
1914 							bColDisable = 1;
1915 						if(!( aLine == *(aBoxItem.GetBottom())) )
1916 							bStyleDisable = 1;
1917 					}
1918 				}
1919 
1920                 if( aBoxItem.GetLeft() )
1921 				{
1922 					if(bCol == 0)
1923 					{
1924 						bCol = 1;
1925 						aCol = aBoxItem.GetLeft()->GetColor() ;
1926 						aLine.SetColor(aCol);
1927 						aLine.SetOutWidth( aBoxItem.GetLeft()->GetOutWidth());
1928 						aLine.SetInWidth( aBoxItem.GetLeft()->GetInWidth());
1929 						aLine.SetDistance( aBoxItem.GetLeft()->GetDistance());
1930 					}
1931 					else
1932 					{
1933 						if(aCol != aBoxItem.GetLeft()->GetColor() )
1934 							bColDisable = 1;
1935 						if(!( aLine == *(aBoxItem.GetLeft())) )
1936 							bStyleDisable = 1;
1937 					}
1938 				}
1939 
1940                 if( aBoxItem.GetRight() )
1941 				{
1942 					if(bCol == 0)
1943 					{
1944 						bCol = 1;
1945 						aCol = aBoxItem.GetRight()->GetColor() ;
1946 						aLine.SetColor(aCol);
1947 						aLine.SetOutWidth( aBoxItem.GetRight()->GetOutWidth());
1948 						aLine.SetInWidth( aBoxItem.GetRight()->GetInWidth());
1949 						aLine.SetDistance( aBoxItem.GetRight()->GetDistance());
1950 					}
1951 					else
1952 					{
1953 						if(aCol != aBoxItem.GetRight()->GetColor() )
1954 							bColDisable = 1;
1955 						if(!( aLine == *(aBoxItem.GetRight())) )
1956 							bStyleDisable = 1;
1957 					}
1958 				}
1959 
1960                 if( aInfoItem.GetVert())
1961 				{
1962 					if(bCol == 0)
1963 					{
1964 						bCol = 1;
1965 						aCol = aInfoItem.GetVert()->GetColor() ;
1966 						aLine.SetColor(aCol);
1967 						aLine.SetOutWidth( aInfoItem.GetVert()->GetOutWidth());
1968 						aLine.SetInWidth( aInfoItem.GetVert()->GetInWidth());
1969 						aLine.SetDistance( aInfoItem.GetVert()->GetDistance());
1970 					}
1971 					else
1972 					{
1973 						if(aCol != aInfoItem.GetVert()->GetColor() )
1974 							bColDisable = 1;
1975 						if(!( aLine == *(aInfoItem.GetVert())) )
1976 							bStyleDisable = 1;
1977 					}
1978 				}
1979 
1980                 if( aInfoItem.GetHori())
1981 				{
1982 					if(bCol == 0)
1983 					{
1984 						bCol = 1;
1985 						aCol = aInfoItem.GetHori()->GetColor() ;
1986 						aLine.SetColor(aCol);
1987 						aLine.SetOutWidth( aInfoItem.GetHori()->GetOutWidth());
1988 						aLine.SetInWidth( aInfoItem.GetHori()->GetInWidth());
1989 						aLine.SetDistance( aInfoItem.GetHori()->GetDistance());
1990 					}
1991 					else
1992 					{
1993 						if(aCol != aInfoItem.GetHori()->GetColor() )
1994 							bColDisable = 1;
1995 						if(!( aLine == *(aInfoItem.GetHori())) )
1996 							bStyleDisable = 1;
1997 					}
1998 				}
1999 
2000 				if( !aInfoItem.IsValid( VALID_VERT )
2001 					|| !aInfoItem.IsValid( VALID_HORI )
2002 					|| !aInfoItem.IsValid( VALID_LEFT )
2003 					|| !aInfoItem.IsValid( VALID_RIGHT )
2004 					|| !aInfoItem.IsValid( VALID_TOP )
2005 					|| !aInfoItem.IsValid( VALID_BOTTOM ) )
2006 				{
2007 					bColDisable = 1;
2008 					bStyleDisable = 1;
2009 				}
2010 
2011 				if(SID_FRAME_LINECOLOR == nWhich)
2012 				{
2013 					if(bColDisable) // if different lines have differernt colors
2014 					{
2015 						aCol = COL_TRANSPARENT;
2016 						rSet.Put( SvxColorItem(aCol, SID_FRAME_LINECOLOR ) );
2017 						rSet.InvalidateItem(SID_FRAME_LINECOLOR);
2018 					}
2019 					else if( bCol == 0 && bColDisable == 0) // if no line available
2020 					{
2021 						aCol = COL_AUTO;
2022 						rSet.Put( SvxColorItem(aCol, SID_FRAME_LINECOLOR ) );
2023 					}
2024 					else
2025 						rSet.Put( SvxColorItem(aCol, SID_FRAME_LINECOLOR ) );
2026 				}
2027 				else // if( nWhich == SID_FRAME_LINESTYLE)
2028 				{
2029 					if(bStyleDisable) // if have several lines but don't have same style
2030 					{
2031 						aLine.SetOutWidth( 1 );
2032 						aLine.SetInWidth( 0 );
2033 						aLine.SetDistance( 0 );
2034 						SvxLineItem aItem(SID_FRAME_LINESTYLE);
2035 						aItem.SetLine(&aLine);
2036 						rSet.Put( aItem );
2037 						rSet.InvalidateItem(SID_FRAME_LINESTYLE);
2038 					}
2039 					else // all the lines have same style or no line availavle, use initial value (0,0,0,0)
2040 					{
2041 						SvxLineItem aItem(SID_FRAME_LINESTYLE);
2042 						aItem.SetLine(&aLine);
2043 						rSet.Put( aItem );
2044 					}
2045 				}
2046 			}
2047 			break;
2048 			case SID_ATTR_BRUSH:
2049 			{
2050 				rSet.Put( rBrushItem, GetPool().GetWhich(nWhich) );
2051 			}
2052 			break;
2053 /*			case SID_ATTR_ALIGN_LINEBREAK:
2054 			{
2055 				const SfxBoolItem& rBreakItem = (const SfxBoolItem&)rAttrSet.Get( ATTR_LINEBREAK );
2056 				rSet.Put( rBreakItem, GetPool().GetWhich(nWhich) );
2057 			}
2058 			break;
2059 */
2060 		}
2061 		nWhich = aIter.NextWhich();
2062 	}
2063 
2064     if(nWhich)
2065     {
2066         // stuff for sidebar panels
2067         Invalidate(SID_ATTR_ALIGN_DEGREES);
2068         Invalidate(SID_ATTR_ALIGN_STACKED);
2069     }
2070 }
2071 
2072 //------------------------------------------------------------------
2073 
2074 void ScFormatShell::GetTextAttrState( SfxItemSet& rSet )
2075 {
2076 	ScTabViewShell*	pTabViewShell  	= GetViewData()->GetViewShell();
2077 	const SfxItemSet& rAttrSet	= pTabViewShell->GetSelectionPattern()->GetItemSet();
2078 	rSet.Put( rAttrSet, sal_False ); // ItemStates mitkopieren
2079 
2080 	//	choose font info according to selection script type
2081 	sal_uInt8 nScript = 0;		// GetSelectionScriptType never returns 0
2082 	if ( rSet.GetItemState( ATTR_FONT_WEIGHT ) != SFX_ITEM_UNKNOWN )
2083 	{
2084 		if (!nScript) nScript = pTabViewShell->GetSelectionScriptType();
2085 		ScViewUtil::PutItemScript( rSet, rAttrSet, ATTR_FONT_WEIGHT, nScript );
2086 	}
2087 	if ( rSet.GetItemState( ATTR_FONT_POSTURE ) != SFX_ITEM_UNKNOWN )
2088 	{
2089 		if (!nScript) nScript = pTabViewShell->GetSelectionScriptType();
2090 		ScViewUtil::PutItemScript( rSet, rAttrSet, ATTR_FONT_POSTURE, nScript );
2091 	}
2092 
2093 	SfxItemState eState;
2094 //	const SfxPoolItem* pItem;
2095 
2096 	//--------------------------------------------------------------------
2097 	// eigene Kontrolle ueber RadioButton-Funktionalitaet:
2098 	//--------------------------------------------------------------------
2099 	// Unterstreichung
2100 	//------------------------
2101 
2102 	eState = rAttrSet.GetItemState( ATTR_FONT_UNDERLINE, sal_True );
2103 	if ( eState == SFX_ITEM_DONTCARE )
2104 	{
2105 		rSet.InvalidateItem( SID_ULINE_VAL_NONE );
2106 		rSet.InvalidateItem( SID_ULINE_VAL_SINGLE );
2107 		rSet.InvalidateItem( SID_ULINE_VAL_DOUBLE );
2108 		rSet.InvalidateItem( SID_ULINE_VAL_DOTTED );
2109 	}
2110 	else
2111 	{
2112 		FontUnderline eUnderline = ((const SvxUnderlineItem&)
2113 					rAttrSet.Get(ATTR_FONT_UNDERLINE)).GetLineStyle();
2114 		sal_uInt16 nId = SID_ULINE_VAL_NONE;
2115 		switch (eUnderline)
2116 		{
2117 			case UNDERLINE_SINGLE:	nId = SID_ULINE_VAL_SINGLE;	break;
2118 			case UNDERLINE_DOUBLE:	nId = SID_ULINE_VAL_DOUBLE;	break;
2119 			case UNDERLINE_DOTTED:	nId = SID_ULINE_VAL_DOTTED;	break;
2120 			default:
2121 				break;
2122 		}
2123 		rSet.Put( SfxBoolItem( nId, sal_True ) );
2124 	}
2125 
2126 	//------------------------
2127 	// horizontale Ausrichtung
2128 	//------------------------
2129 
2130 	const SvxHorJustifyItem* pHorJustify = NULL;
2131 	const SvxVerJustifyItem* pVerJustify = NULL;
2132 	SvxCellHorJustify        eHorJustify = SVX_HOR_JUSTIFY_STANDARD;
2133 	SvxCellVerJustify        eVerJustify = SVX_VER_JUSTIFY_STANDARD;
2134 	sal_uInt16		 			 nWhich		 = 0;
2135 	sal_Bool					 bJustifyStd = sal_False;
2136 	SfxBoolItem				 aBoolItem	 ( 0, sal_True );
2137 
2138 	eState 	 = rAttrSet.GetItemState( ATTR_HOR_JUSTIFY, sal_True,
2139 										(const SfxPoolItem**)&pHorJustify );
2140 	switch ( eState )
2141 	{
2142 		case SFX_ITEM_SET:
2143 			{
2144 				eHorJustify = SvxCellHorJustify( pHorJustify->GetValue() );
2145 
2146 				switch ( SvxCellHorJustify( pHorJustify->GetValue() ) )
2147 				{
2148 					case SVX_HOR_JUSTIFY_STANDARD:
2149 						break;
2150 
2151 					case SVX_HOR_JUSTIFY_LEFT:
2152 						nWhich = SID_ALIGNLEFT;
2153 						break;
2154 
2155 					case SVX_HOR_JUSTIFY_RIGHT:
2156 						nWhich = SID_ALIGNRIGHT;
2157 						break;
2158 
2159 					case SVX_HOR_JUSTIFY_CENTER:
2160 						nWhich = SID_ALIGNCENTERHOR;
2161 						break;
2162 
2163 					case SVX_HOR_JUSTIFY_BLOCK:
2164 						nWhich = SID_ALIGNBLOCK;
2165 						break;
2166 
2167 					case SVX_HOR_JUSTIFY_REPEAT:
2168 					default:
2169 						bJustifyStd = sal_True;
2170 						break;
2171 				}
2172 			}
2173 			break;
2174 
2175 		case SFX_ITEM_DONTCARE:
2176 			rSet.InvalidateItem( SID_ALIGNLEFT );
2177 			rSet.InvalidateItem( SID_ALIGNRIGHT );
2178 			rSet.InvalidateItem( SID_ALIGNCENTERHOR );
2179 			rSet.InvalidateItem( SID_ALIGNBLOCK );
2180 			break;
2181 
2182 		default:
2183 			bJustifyStd = sal_True;
2184 			break;
2185 	}
2186 
2187 	if ( nWhich )
2188 	{
2189 		aBoolItem.SetWhich( nWhich );
2190 		rSet.Put( aBoolItem );
2191 	}
2192 	else if ( bJustifyStd )
2193 	{
2194 		aBoolItem.SetValue( sal_False );
2195 		aBoolItem.SetWhich( SID_ALIGNLEFT );	  rSet.Put( aBoolItem );
2196 		aBoolItem.SetWhich( SID_ALIGNRIGHT );	  rSet.Put( aBoolItem );
2197 		aBoolItem.SetWhich( SID_ALIGNCENTERHOR ); rSet.Put( aBoolItem );
2198 		aBoolItem.SetWhich( SID_ALIGNBLOCK );	  rSet.Put( aBoolItem );
2199 		bJustifyStd = sal_False;
2200 	}
2201 
2202 	//------------------------
2203 	// vertikale Ausrichtung
2204 	//------------------------
2205 
2206 	nWhich = 0;
2207 	aBoolItem.SetValue( sal_True );
2208 
2209 	eState = rAttrSet.GetItemState( ATTR_VER_JUSTIFY, sal_True,
2210 									(const SfxPoolItem**)&pVerJustify );
2211 
2212 	switch ( eState )
2213 	{
2214 		case SFX_ITEM_SET:
2215 			{
2216 				eVerJustify = SvxCellVerJustify( pVerJustify->GetValue() );
2217 
2218 				switch ( eVerJustify )
2219 				{
2220 					case SVX_VER_JUSTIFY_TOP:
2221 						nWhich = SID_ALIGNTOP;
2222 						break;
2223 
2224 					case SVX_VER_JUSTIFY_BOTTOM:
2225 						nWhich = SID_ALIGNBOTTOM;
2226 						break;
2227 
2228 					case SVX_VER_JUSTIFY_CENTER:
2229 						nWhich = SID_ALIGNCENTERVER;
2230 						break;
2231 
2232 					case SVX_VER_JUSTIFY_STANDARD:
2233 					default:
2234 						bJustifyStd = sal_True;
2235 						break;
2236 				}
2237 			}
2238 			break;
2239 
2240 		case SFX_ITEM_DONTCARE:
2241 			rSet.InvalidateItem( SID_ALIGNTOP );
2242 			rSet.InvalidateItem( SID_ALIGNBOTTOM );
2243 			rSet.InvalidateItem( SID_ALIGNCENTERVER );
2244 			break;
2245 
2246 		default:
2247 			bJustifyStd = sal_True;
2248 			break;
2249 	}
2250 
2251 	if ( nWhich )
2252 	{
2253 		aBoolItem.SetWhich( nWhich );
2254 		rSet.Put( aBoolItem );
2255 	}
2256 	else if ( bJustifyStd )
2257 	{
2258 		aBoolItem.SetValue( sal_False );
2259 		aBoolItem.SetWhich( SID_ALIGNTOP );	  	  rSet.Put( aBoolItem );
2260 		aBoolItem.SetWhich( SID_ALIGNBOTTOM );	  rSet.Put( aBoolItem );
2261 		aBoolItem.SetWhich( SID_ALIGNCENTERVER ); rSet.Put( aBoolItem );
2262 	}
2263 }
2264 
2265 
2266 //------------------------------------------------------------------
2267 
2268 void ScFormatShell::GetBorderState( SfxItemSet& rSet )
2269 {
2270 	ScTabViewShell*	pTabViewShell  	= GetViewData()->GetViewShell();
2271 	SvxBoxItem		aBoxItem( ATTR_BORDER );
2272 	SvxBoxInfoItem	aInfoItem( ATTR_BORDER_INNER );
2273 
2274 	pTabViewShell->GetSelectionFrame( aBoxItem, aInfoItem );
2275 
2276 	if ( rSet.GetItemState( ATTR_BORDER ) != SFX_ITEM_UNKNOWN )
2277 		rSet.Put( aBoxItem );
2278 	if ( rSet.GetItemState( ATTR_BORDER_INNER ) != SFX_ITEM_UNKNOWN )
2279 		rSet.Put( aInfoItem );
2280 }
2281 
2282 //------------------------------------------------------------------
2283 
2284 void ScFormatShell::GetAlignState( SfxItemSet& rSet )
2285 {
2286 	ScTabViewShell*	pTabViewShell  	= GetViewData()->GetViewShell();
2287 	const SfxItemSet& rAttrSet    = pTabViewShell->GetSelectionPattern()->GetItemSet();
2288 	SfxWhichIter	aIter(rSet);
2289 	sal_uInt16			nWhich = aIter.FirstWhich();
2290 
2291     SvxCellHorJustify eHAlign = SVX_HOR_JUSTIFY_STANDARD;
2292     bool bHasHAlign = rAttrSet.GetItemState( ATTR_HOR_JUSTIFY ) != SFX_ITEM_DONTCARE;
2293     if( bHasHAlign )
2294         eHAlign = (SvxCellHorJustify)((const SvxHorJustifyItem&) rAttrSet.Get( ATTR_HOR_JUSTIFY )).GetValue();
2295 
2296     SvxCellVerJustify eVAlign = SVX_VER_JUSTIFY_STANDARD;
2297     bool bHasVAlign = rAttrSet.GetItemState( ATTR_VER_JUSTIFY ) != SFX_ITEM_DONTCARE;
2298     if( bHasVAlign )
2299         eVAlign = (SvxCellVerJustify)((const SvxVerJustifyItem&) rAttrSet.Get( ATTR_VER_JUSTIFY )).GetValue();
2300 
2301 	while ( nWhich )
2302 	{
2303 		switch ( nWhich )
2304 		{
2305 			case SID_H_ALIGNCELL:
2306                 if ( bHasHAlign )
2307                     rSet.Put( SvxHorJustifyItem( eHAlign, nWhich ));
2308 			break;
2309 			case SID_V_ALIGNCELL:
2310                 if ( bHasVAlign )
2311                     rSet.Put( SvxVerJustifyItem( eVAlign, nWhich ));
2312 			break;
2313 
2314             // pseudo slots for Format menu
2315             case SID_ALIGN_ANY_HDEFAULT:
2316             case SID_ALIGN_ANY_LEFT:
2317             case SID_ALIGN_ANY_HCENTER:
2318             case SID_ALIGN_ANY_RIGHT:
2319             case SID_ALIGN_ANY_JUSTIFIED:
2320                 rSet.Put( SfxBoolItem( nWhich, bHasHAlign && (eHAlign == lclConvertSlotToHAlign( nWhich )) ) );
2321             break;
2322             case SID_ALIGN_ANY_VDEFAULT:
2323             case SID_ALIGN_ANY_TOP:
2324             case SID_ALIGN_ANY_VCENTER:
2325             case SID_ALIGN_ANY_BOTTOM:
2326                 rSet.Put( SfxBoolItem( nWhich, bHasVAlign && (eVAlign == lclConvertSlotToVAlign( nWhich )) ) );
2327             break;
2328 		}
2329 		nWhich = aIter.NextWhich();
2330 	}
2331 }
2332 
2333 void ScFormatShell::GetNumFormatState( SfxItemSet& rSet )
2334 {
2335 	ScTabViewShell*	pTabViewShell  	= GetViewData()->GetViewShell();
2336 
2337     // ScViewData* pViewData   = GetViewData();
2338 	ScDocument* pDoc		= pViewData->GetDocument();
2339 
2340 	SfxWhichIter aIter(rSet);
2341 	sal_uInt16 nWhich = aIter.FirstWhich();
2342 	while ( nWhich )
2343 	{
2344 		switch ( nWhich )
2345 		{
2346 			case SID_NUMBER_FORMAT:
2347 				//{
2348 				//	String aFormatCode;			// bleibt leer, wenn dont-care
2349                 //
2350 				//	const SfxItemSet& rAttrSet  = pTabViewShell->GetSelectionPattern()->GetItemSet();
2351 				//	if ( rAttrSet.GetItemState( ATTR_VALUE_FORMAT ) != SFX_ITEM_DONTCARE )
2352 				//	{
2353 				//		sal_uLong nNumberFormat = ((const SfxUInt32Item&)rAttrSet.Get(
2354 				//									ATTR_VALUE_FORMAT )).GetValue();
2355                 //
2356 				//		SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
2357 				//		const SvNumberformat* pFormatEntry = pFormatter->GetEntry( nNumberFormat );
2358 				//		if ( pFormatEntry )
2359 				//			aFormatCode = pFormatEntry->GetFormatstring();
2360 				//	}
2361                 //
2362 				//	rSet.Put( SfxStringItem( nWhich, aFormatCode ) );
2363 				//}
2364 
2365                 // symphony version with format interpretation
2366 				{
2367 					const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet();
2368 
2369 					if(SFX_ITEM_DONTCARE != rAttrSet.GetItemState(ATTR_VALUE_FORMAT))
2370 					{
2371 						SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
2372 						sal_uInt32 nNumberFormat = ((const SfxUInt32Item&)rAttrSet.Get(ATTR_VALUE_FORMAT)).GetValue();
2373 						sal_Bool bThousand(false);
2374 						sal_Bool bNegRed(false);
2375 						sal_uInt16 nPrecision(0);
2376 						sal_uInt16 nLeadZeroes(0);
2377 
2378                         pFormatter->GetFormatSpecialInfo(nNumberFormat,bThousand, bNegRed, nPrecision, nLeadZeroes);
2379 						String aFormat;
2380 						static String sBreak = String::CreateFromAscii(",");
2381 						const String sThousand = String::CreateFromInt32(bThousand);
2382 						const String sNegRed = String::CreateFromInt32(bNegRed);
2383 						const String sPrecision = String::CreateFromInt32(nPrecision);
2384 						const String sLeadZeroes = String::CreateFromInt32(nLeadZeroes);
2385 
2386 						aFormat += sThousand;
2387 						aFormat += sBreak;
2388 						aFormat += sNegRed;
2389 						aFormat += sBreak;
2390 						aFormat += sPrecision;
2391 						aFormat += sBreak;
2392 						aFormat += sLeadZeroes;
2393 						aFormat += sBreak;
2394 
2395 						rSet.Put(SfxStringItem(nWhich, aFormat));
2396 					}
2397 					else
2398 					{
2399 						rSet.InvalidateItem( nWhich );
2400 					}
2401 				}
2402 				break;
2403 
2404 			case SID_NUMBER_TYPE_FORMAT:
2405 				{
2406 					sal_Int16 aFormatCode = -1;
2407 					const SfxItemSet& rAttrSet  = pTabViewShell->GetSelectionPattern()->GetItemSet();
2408 					if ( rAttrSet.GetItemState( ATTR_VALUE_FORMAT ) >= SFX_ITEM_AVAILABLE ) //Modify for more robust
2409 					{
2410 						SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
2411 						sal_uInt32 nNumberFormat = pTabViewShell->GetSelectionPattern()->GetNumberFormat( pFormatter );
2412 						const SvNumberformat* pFormatEntry = pFormatter->GetEntry( nNumberFormat );
2413 						bool bStandard = false;
2414 
2415 						if ( pFormatEntry )
2416 						{
2417 							aFormatCode = pFormatEntry->GetType();
2418 							bStandard = pFormatEntry->IsStandard();
2419 						}
2420 
2421                         switch(aFormatCode)
2422 						{
2423 						case NUMBERFORMAT_NUMBER:
2424 						case NUMBERFORMAT_NUMBER| NUMBERFORMAT_DEFINED:
2425 							//use format code and standard format code to judge whether it is General,
2426 							//if (nNumberFormat == nStandardNumberFormat)
2427 							if (bStandard)
2428 								aFormatCode = 0;
2429 							else
2430                                 aFormatCode = 1;
2431 							break;
2432 						case NUMBERFORMAT_PERCENT:
2433 						case NUMBERFORMAT_PERCENT| NUMBERFORMAT_DEFINED:
2434 							aFormatCode = 2;
2435 							break;
2436 						case NUMBERFORMAT_CURRENCY:
2437 						case NUMBERFORMAT_CURRENCY| NUMBERFORMAT_DEFINED:
2438 							aFormatCode = 3;
2439 							break;
2440 						case NUMBERFORMAT_DATE:
2441 						case NUMBERFORMAT_DATE| NUMBERFORMAT_DEFINED:
2442 							//Add
2443 						case NUMBERFORMAT_DATETIME:
2444 						case NUMBERFORMAT_DATETIME | NUMBERFORMAT_DEFINED:
2445 							aFormatCode = 4;
2446 							break;
2447 						case NUMBERFORMAT_TIME:
2448 						case NUMBERFORMAT_TIME| NUMBERFORMAT_DEFINED:
2449 							aFormatCode = 5;
2450 							break;
2451 						case NUMBERFORMAT_SCIENTIFIC:
2452 						case NUMBERFORMAT_SCIENTIFIC| NUMBERFORMAT_DEFINED:
2453 							aFormatCode = 6;
2454 							break;
2455 						case NUMBERFORMAT_FRACTION:
2456 						case NUMBERFORMAT_FRACTION| NUMBERFORMAT_DEFINED:
2457 							aFormatCode = 7;
2458 							break;
2459 						case NUMBERFORMAT_LOGICAL:
2460 						case NUMBERFORMAT_LOGICAL| NUMBERFORMAT_DEFINED:
2461 							aFormatCode = 8;
2462 							break;
2463 						case NUMBERFORMAT_TEXT:
2464 						case NUMBERFORMAT_TEXT| NUMBERFORMAT_DEFINED:
2465 							aFormatCode = 9;
2466 							break;
2467 						default:
2468 							aFormatCode = -1;	//for more roburst
2469 						}
2470 						if( aFormatCode == -1 )
2471 							rSet.InvalidateItem( nWhich );
2472 						else
2473 							rSet.Put( SfxInt16Item( nWhich, aFormatCode ) );
2474 					}
2475 					else
2476 					{
2477 						rSet.InvalidateItem( nWhich );
2478 					}
2479 
2480 				}
2481 				break;
2482 		}
2483 		nWhich = aIter.NextWhich();
2484 	}
2485 }
2486 
2487 
2488 void ScFormatShell::ExecuteTextDirection( SfxRequest& rReq )
2489 {
2490     ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
2491     pTabViewShell->HideListBox();               // Autofilter-DropDown-Listbox
2492     if ( GetViewData()->HasEditView( GetViewData()->GetActivePart() ) )
2493     {
2494         SC_MOD()->InputEnterHandler();
2495         pTabViewShell->UpdateInputHandler();
2496     }
2497 
2498     sal_uInt16 nSlot = rReq.GetSlot();
2499     switch( nSlot )
2500     {
2501         case SID_TEXTDIRECTION_LEFT_TO_RIGHT:
2502         case SID_TEXTDIRECTION_TOP_TO_BOTTOM:
2503         {
2504             sal_Bool bVert = (nSlot == SID_TEXTDIRECTION_TOP_TO_BOTTOM);
2505             ScPatternAttr aAttr( GetViewData()->GetDocument()->GetPool() );
2506             SfxItemSet& rItemSet = aAttr.GetItemSet();
2507             rItemSet.Put( SfxBoolItem( ATTR_STACKED, bVert ) );
2508             rItemSet.Put( SfxBoolItem( ATTR_VERTICAL_ASIAN, bVert ) );
2509             pTabViewShell->ApplySelectionPattern( aAttr );
2510             pTabViewShell->AdjustBlockHeight();
2511         }
2512         break;
2513 
2514         case SID_ATTR_PARA_LEFT_TO_RIGHT:
2515         case SID_ATTR_PARA_RIGHT_TO_LEFT:
2516         {
2517             SvxFrameDirection eDirection = ( nSlot == SID_ATTR_PARA_LEFT_TO_RIGHT ) ?
2518                                                 FRMDIR_HORI_LEFT_TOP : FRMDIR_HORI_RIGHT_TOP;
2519             pTabViewShell->ApplyAttr( SvxFrameDirectionItem( eDirection, ATTR_WRITINGDIR ) );
2520         }
2521         break;
2522     }
2523 }
2524 
2525 void ScFormatShell::GetTextDirectionState( SfxItemSet& rSet )
2526 {
2527     ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
2528     const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet();
2529 
2530     sal_Bool bVertDontCare =
2531         (rAttrSet.GetItemState( ATTR_VERTICAL_ASIAN ) == SFX_ITEM_DONTCARE) ||
2532         (rAttrSet.GetItemState( ATTR_STACKED ) == SFX_ITEM_DONTCARE);
2533     sal_Bool bLeftRight = !bVertDontCare &&
2534         !((const SfxBoolItem&) rAttrSet.Get( ATTR_STACKED )).GetValue();
2535     sal_Bool bTopBottom = !bVertDontCare && !bLeftRight &&
2536         ((const SfxBoolItem&) rAttrSet.Get( ATTR_VERTICAL_ASIAN )).GetValue();
2537 
2538     sal_Bool bBidiDontCare = (rAttrSet.GetItemState( ATTR_WRITINGDIR ) == SFX_ITEM_DONTCARE);
2539     EEHorizontalTextDirection eBidiDir = EE_HTEXTDIR_DEFAULT;
2540     if ( !bBidiDontCare )
2541     {
2542         SvxFrameDirection eCellDir = (SvxFrameDirection)((const SvxFrameDirectionItem&)
2543                                         rAttrSet.Get( ATTR_WRITINGDIR )).GetValue();
2544         if ( eCellDir == FRMDIR_ENVIRONMENT )
2545             eBidiDir = (EEHorizontalTextDirection)GetViewData()->GetDocument()->
2546                                 GetEditTextDirection( GetViewData()->GetTabNo() );
2547         else if ( eCellDir == FRMDIR_HORI_RIGHT_TOP )
2548             eBidiDir = EE_HTEXTDIR_R2L;
2549         else
2550             eBidiDir = EE_HTEXTDIR_L2R;
2551     }
2552 
2553 	SvtLanguageOptions	aLangOpt;
2554 	sal_Bool bDisableCTLFont = !aLangOpt.IsCTLFontEnabled();
2555 	sal_Bool bDisableVerticalText = !aLangOpt.IsVerticalTextEnabled();
2556 
2557     SfxWhichIter aIter( rSet );
2558     sal_uInt16 nWhich = aIter.FirstWhich();
2559     while( nWhich )
2560     {
2561         switch( nWhich )
2562         {
2563             case SID_TEXTDIRECTION_LEFT_TO_RIGHT:
2564             case SID_TEXTDIRECTION_TOP_TO_BOTTOM:
2565                 if ( bDisableVerticalText )
2566 					rSet.DisableItem( nWhich );
2567 				else
2568 				{
2569 					if( bVertDontCare )
2570 						rSet.InvalidateItem( nWhich );
2571 					else if ( nWhich == SID_TEXTDIRECTION_LEFT_TO_RIGHT )
2572 						rSet.Put( SfxBoolItem( nWhich, bLeftRight ) );
2573 					else
2574 						rSet.Put( SfxBoolItem( nWhich, bTopBottom ) );
2575 				}
2576             break;
2577 
2578             case SID_ATTR_PARA_LEFT_TO_RIGHT:
2579             case SID_ATTR_PARA_RIGHT_TO_LEFT:
2580 				if ( bDisableCTLFont )
2581 					rSet.DisableItem( nWhich );
2582 				else
2583 				{
2584 					if ( bTopBottom )
2585 						rSet.DisableItem( nWhich );
2586 					else if ( bBidiDontCare )
2587 						rSet.InvalidateItem( nWhich );
2588 					else if ( nWhich == SID_ATTR_PARA_LEFT_TO_RIGHT )
2589 						rSet.Put( SfxBoolItem( nWhich, eBidiDir == EE_HTEXTDIR_L2R ) );
2590 					else
2591 						rSet.Put( SfxBoolItem( nWhich, eBidiDir == EE_HTEXTDIR_R2L ) );
2592 				}
2593         }
2594         nWhich = aIter.NextWhich();
2595     }
2596 }
2597 
2598 void ScFormatShell::ExecFormatPaintbrush( SfxRequest& rReq )
2599 {
2600     ScViewFunc* pView = pViewData->GetView();
2601     if ( pView->HasPaintBrush() )
2602     {
2603         // cancel paintbrush mode
2604         pView->ResetBrushDocument();
2605     }
2606     else
2607     {
2608         sal_Bool bLock = sal_False;
2609         const SfxItemSet *pArgs = rReq.GetArgs();
2610         if( pArgs && pArgs->Count() >= 1 )
2611             bLock = static_cast<const SfxBoolItem&>(pArgs->Get(SID_FORMATPAINTBRUSH)).GetValue();
2612 
2613         // in case of multi selection, deselect all and use the cursor position
2614         ScRange aDummy;
2615         if ( pViewData->GetSimpleArea(aDummy) != SC_MARK_SIMPLE )
2616             pView->Unmark();
2617 
2618         ScDocument* pBrushDoc = new ScDocument( SCDOCMODE_CLIP );
2619         pView->CopyToClip( pBrushDoc, sal_False, sal_True );
2620         pView->SetBrushDocument( pBrushDoc, bLock );
2621     }
2622 }
2623 
2624 void ScFormatShell::StateFormatPaintbrush( SfxItemSet& rSet )
2625 {
2626     if ( pViewData->HasEditView( pViewData->GetActivePart() ) )
2627         rSet.DisableItem( SID_FORMATPAINTBRUSH );
2628     else
2629         rSet.Put( SfxBoolItem( SID_FORMATPAINTBRUSH, pViewData->GetView()->HasPaintBrush() ) );
2630 }
2631 
2632 void  ScFormatShell::ExecViewOptions( SfxRequest& rReq )
2633 {
2634 	ScTabViewShell*	pTabViewShell  		= GetViewData()->GetViewShell();
2635 	SfxBindings&		rBindings = pViewData->GetBindings();
2636 	const SfxItemSet*	pNewAttrs = rReq.GetArgs();
2637 
2638 	if ( pNewAttrs )
2639 	{
2640 		sal_uInt16 nSlot = rReq.GetSlot();
2641 
2642 		if( nSlot  == SID_SCGRIDSHOW)
2643 		{
2644 
2645 			ScViewData*				pViewData = pTabViewShell->GetViewData();
2646 			const ScViewOptions&	rOldOpt	  = pViewData->GetOptions();
2647 			ScDocShell*				pDocSh  = PTR_CAST(ScDocShell, SfxObjectShell::Current());
2648 			bool bState =	((const SfxBoolItem &)pNewAttrs->Get( pNewAttrs->GetPool()->GetWhich( nSlot ) )).GetValue();
2649 
2650 			if ( (bool)rOldOpt.GetOption( VOPT_GRID ) !=  bState)
2651 			{
2652 				ScViewOptions rNewOpt(rOldOpt);
2653 				rNewOpt.SetOption( VOPT_GRID,  bState);
2654 				pViewData->SetOptions( rNewOpt );
2655 				pViewData->GetDocument()->SetViewOptions( rNewOpt );
2656 				pDocSh->SetDocumentModified();
2657 				//add , write the change to sc view config
2658 				ScModule*			pScMod		= SC_MOD();
2659 				pScMod->SetViewOptions( rNewOpt );
2660 				//add end
2661 				rBindings.Invalidate( nSlot );
2662 			}
2663 		}
2664 	}
2665 
2666 }
2667 
2668 void  ScFormatShell::GetViewOptions( SfxItemSet& rSet )
2669 {
2670 	ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
2671 	if( pTabViewShell )
2672 	{
2673 		ScViewOptions	aViewOpt = pTabViewShell->GetViewData()->GetOptions();
2674 		rSet.ClearItem(SID_SCGRIDSHOW);
2675 		SfxBoolItem aItem( SID_SCGRIDSHOW, aViewOpt.GetOption( VOPT_GRID ) );
2676 		rSet.Put(aItem);
2677 	}
2678 }
2679 
2680 // eof
2681