xref: /trunk/main/sc/source/ui/view/formatsh.cxx (revision 512ec161)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_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     rBindings.Invalidate( SID_ATTR_PARA_ADJUST_LEFT );
1240     rBindings.Invalidate( SID_ATTR_PARA_ADJUST_RIGHT );
1241     rBindings.Invalidate( SID_ATTR_PARA_ADJUST_BLOCK );
1242     rBindings.Invalidate( SID_ATTR_PARA_ADJUST_CENTER);
1243     rBindings.Invalidate( SID_ALIGNLEFT );
1244     rBindings.Invalidate( SID_ALIGNRIGHT );
1245     rBindings.Invalidate( SID_ALIGNCENTERHOR );
1246     rBindings.Invalidate( SID_ALIGNBLOCK );
1247     rBindings.Invalidate( SID_ALIGNTOP );
1248     rBindings.Invalidate( SID_ALIGNBOTTOM );
1249     rBindings.Invalidate( SID_ALIGNCENTERVER );
1250     rBindings.Invalidate( SID_V_ALIGNCELL );
1251     rBindings.Invalidate( SID_H_ALIGNCELL );
1252     // pseudo slots for Format menu
1253     rBindings.Invalidate( SID_ALIGN_ANY_HDEFAULT );
1254     rBindings.Invalidate( SID_ALIGN_ANY_LEFT );
1255     rBindings.Invalidate( SID_ALIGN_ANY_HCENTER );
1256     rBindings.Invalidate( SID_ALIGN_ANY_RIGHT );
1257     rBindings.Invalidate( SID_ALIGN_ANY_JUSTIFIED );
1258     rBindings.Invalidate( SID_ALIGN_ANY_VDEFAULT );
1259     rBindings.Invalidate( SID_ALIGN_ANY_TOP );
1260     rBindings.Invalidate( SID_ALIGN_ANY_VCENTER );
1261     rBindings.Invalidate( SID_ALIGN_ANY_BOTTOM );
1262     rBindings.Update();
1263 
1264     if( ! rReq.IsAPI() )
1265         rReq.Done();
1266 }
1267 
1268 void ScFormatShell::ExecuteTextAttr( SfxRequest& rReq )
1269 {
1270 	ScTabViewShell*	pTabViewShell  		= GetViewData()->GetViewShell();
1271 	SfxBindings&			rBindings	= pViewData->GetBindings();
1272 	const ScPatternAttr*    pAttrs		= pTabViewShell->GetSelectionPattern();
1273 	const SfxItemSet*       pSet		= rReq.GetArgs();
1274 	sal_uInt16					nSlot		= rReq.GetSlot();
1275 	SfxAllItemSet*			pNewSet = 0;
1276 
1277 	pTabViewShell->HideListBox();					// Autofilter-DropDown-Listbox
1278 
1279 	if (  (nSlot == SID_ATTR_CHAR_WEIGHT)
1280 		||(nSlot == SID_ATTR_CHAR_POSTURE)
1281 		||(nSlot == SID_ATTR_CHAR_UNDERLINE)
1282 		||(nSlot == SID_ULINE_VAL_NONE)
1283 		||(nSlot == SID_ULINE_VAL_SINGLE)
1284 		||(nSlot == SID_ULINE_VAL_DOUBLE)
1285 		||(nSlot == SID_ULINE_VAL_DOTTED) )
1286 	{
1287 		pNewSet = new SfxAllItemSet( GetPool() );
1288 
1289 		switch ( nSlot )
1290 		{
1291 			case SID_ATTR_CHAR_WEIGHT:
1292 			{
1293 				// #i78017 establish the same behaviour as in Writer
1294 				sal_uInt8 nScript = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX;
1295 
1296 				SfxItemPool& rPool = GetPool();
1297 				SvxScriptSetItem aSetItem( nSlot, rPool );
1298 				if ( pSet )
1299 					aSetItem.PutItemForScriptType( nScript, pSet->Get( ATTR_FONT_WEIGHT ) );
1300 				else
1301 				{
1302 					//	toggle manually
1303 
1304 					FontWeight eWeight = WEIGHT_BOLD;
1305 					SvxScriptSetItem aOldSetItem( nSlot, rPool );
1306 					aOldSetItem.GetItemSet().Put( pAttrs->GetItemSet(), sal_False );
1307 					const SfxPoolItem* pCore = aOldSetItem.GetItemOfScript( nScript );
1308 					if ( pCore && ((const SvxWeightItem*)pCore)->GetWeight() == WEIGHT_BOLD )
1309 						eWeight = WEIGHT_NORMAL;
1310 
1311                     aSetItem.PutItemForScriptType( nScript, SvxWeightItem( eWeight, ATTR_FONT_WEIGHT ) );
1312 				}
1313 				pTabViewShell->ApplyUserItemSet( aSetItem.GetItemSet() );
1314 				pNewSet->Put( aSetItem.GetItemSet(), sal_False );
1315 			}
1316 			break;
1317 
1318 			case SID_ATTR_CHAR_POSTURE:
1319 			{
1320 				// #i78017 establish the same behaviour as in Writer
1321 				sal_uInt8 nScript = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX;
1322 
1323 				SfxItemPool& rPool = GetPool();
1324 				SvxScriptSetItem aSetItem( nSlot, rPool );
1325 				if ( pSet )
1326 					aSetItem.PutItemForScriptType( nScript, pSet->Get( ATTR_FONT_POSTURE ) );
1327 				else
1328 				{
1329 					//	toggle manually
1330 
1331 					FontItalic eItalic = ITALIC_NORMAL;
1332 					SvxScriptSetItem aOldSetItem( nSlot, rPool );
1333 					aOldSetItem.GetItemSet().Put( pAttrs->GetItemSet(), sal_False );
1334 					const SfxPoolItem* pCore = aOldSetItem.GetItemOfScript( nScript );
1335 					if ( pCore && ((const SvxPostureItem*)pCore)->GetPosture() == ITALIC_NORMAL )
1336 						eItalic = ITALIC_NONE;
1337 
1338                     aSetItem.PutItemForScriptType( nScript, SvxPostureItem( eItalic, ATTR_FONT_POSTURE ) );
1339 				}
1340 				pTabViewShell->ApplyUserItemSet( aSetItem.GetItemSet() );
1341 				pNewSet->Put( aSetItem.GetItemSet(), sal_False );
1342 			}
1343 			break;
1344 
1345 			case SID_ATTR_CHAR_UNDERLINE:
1346 				{
1347 					FontUnderline       eUnderline;
1348 
1349 					if( pSet )
1350 					{
1351                         const SfxPoolItem& rUnderline = pSet->Get( ATTR_FONT_UNDERLINE );
1352 
1353 						if( rUnderline.ISA(SvxUnderlineItem) )
1354 						{
1355 							pTabViewShell->ApplyAttr( rUnderline );
1356 							pNewSet->Put( rUnderline,rUnderline.Which() );
1357 						}
1358                         else if ( rUnderline.ISA(SvxTextLineItem) )
1359                         {
1360                             // #i106580# also allow SvxTextLineItem (base class of SvxUnderlineItem)
1361                             const SvxTextLineItem& rTextLineItem = static_cast<const SvxTextLineItem&>(rUnderline);
1362                             SvxUnderlineItem aNewItem( rTextLineItem.GetLineStyle(), rTextLineItem.Which() );
1363                             aNewItem.SetColor( rTextLineItem.GetColor() );
1364                             pTabViewShell->ApplyAttr( aNewItem );
1365                             pNewSet->Put( aNewItem, aNewItem.Which() );
1366                         }
1367 					}
1368 					else
1369 					{
1370 						SvxUnderlineItem aUnderline( (const SvxUnderlineItem&)
1371 														pAttrs->GetItem(
1372 															ATTR_FONT_UNDERLINE ) );
1373 						eUnderline = (UNDERLINE_NONE != aUnderline.GetLineStyle())
1374 									? UNDERLINE_NONE
1375 									: UNDERLINE_SINGLE;
1376 						aUnderline.SetLineStyle( eUnderline );
1377 						pTabViewShell->ApplyAttr( aUnderline );
1378 						pNewSet->Put( aUnderline,aUnderline.Which() );
1379 					}
1380 				}
1381 				break;
1382 
1383 			case SID_ULINE_VAL_NONE:
1384 				pTabViewShell->ApplyAttr( SvxUnderlineItem( UNDERLINE_NONE, ATTR_FONT_UNDERLINE ) );
1385 				break;
1386 			case SID_ULINE_VAL_SINGLE:		// Toggles
1387 			case SID_ULINE_VAL_DOUBLE:
1388 			case SID_ULINE_VAL_DOTTED:
1389 				{
1390 					FontUnderline eOld = ((const SvxUnderlineItem&)
1391 											pAttrs->GetItem(ATTR_FONT_UNDERLINE)).GetLineStyle();
1392 					FontUnderline eNew = eOld;
1393 					switch (nSlot)
1394 					{
1395 						case SID_ULINE_VAL_SINGLE:
1396 							eNew = ( eOld == UNDERLINE_SINGLE ) ? UNDERLINE_NONE : UNDERLINE_SINGLE;
1397 							break;
1398 						case SID_ULINE_VAL_DOUBLE:
1399 							eNew = ( eOld == UNDERLINE_DOUBLE ) ? UNDERLINE_NONE : UNDERLINE_DOUBLE;
1400 							break;
1401 						case SID_ULINE_VAL_DOTTED:
1402 							eNew = ( eOld == UNDERLINE_DOTTED ) ? UNDERLINE_NONE : UNDERLINE_DOTTED;
1403 							break;
1404 					}
1405 					pTabViewShell->ApplyAttr( SvxUnderlineItem( eNew, ATTR_FONT_UNDERLINE ) );
1406 				}
1407 				break;
1408 
1409 			default:
1410 				break;
1411 		}
1412 		rBindings.Invalidate( nSlot );
1413 	}
1414 	else
1415 	{
1416 		/*
1417 		 * "Selbstgemachte" RadioButton-Funktionalitaet
1418 		 * Beim Toggle gibt es den Standard-State, d.h. kein
1419 		 * Button ist gedrueckt
1420 		 */
1421 
1422 		const SfxItemSet&		 rAttrSet	= pTabViewShell->GetSelectionPattern()->GetItemSet();
1423 		const SfxPoolItem*       pItem       = NULL;
1424 		const SvxHorJustifyItem* pHorJustify = NULL;
1425 		const SvxVerJustifyItem* pVerJustify = NULL;
1426 		SvxCellHorJustify        eHorJustify = SVX_HOR_JUSTIFY_STANDARD;
1427 		SvxCellVerJustify        eVerJustify = SVX_VER_JUSTIFY_STANDARD;
1428 
1429 		if (rAttrSet.GetItemState(ATTR_HOR_JUSTIFY, sal_True,&pItem ) == SFX_ITEM_SET)
1430 		{
1431 			pHorJustify = (const SvxHorJustifyItem*)pItem;
1432 			eHorJustify = SvxCellHorJustify( pHorJustify->GetValue() );
1433 		}
1434 		if (rAttrSet.GetItemState(ATTR_VER_JUSTIFY, sal_True,&pItem ) == SFX_ITEM_SET)
1435 		{
1436 			pVerJustify = (const SvxVerJustifyItem*)pItem;
1437 			eVerJustify = SvxCellVerJustify( pVerJustify->GetValue() );
1438 		}
1439 
1440 		switch ( nSlot )
1441 		{
1442 			case SID_ALIGNLEFT:
1443 				rReq.SetSlot( SID_H_ALIGNCELL );
1444 				rReq.AppendItem( SvxHorJustifyItem(
1445 					!pHorJustify || (eHorJustify != SVX_HOR_JUSTIFY_LEFT) ?
1446 					SVX_HOR_JUSTIFY_LEFT : SVX_HOR_JUSTIFY_STANDARD, SID_H_ALIGNCELL ) );
1447 				ExecuteSlot( rReq, GetInterface() );
1448 				return;
1449 //				APPLY_HOR_JUSTIFY( SVX_HOR_JUSTIFY_LEFT );
1450                 //break;
1451 
1452 			case SID_ALIGNRIGHT:
1453 				rReq.SetSlot( SID_H_ALIGNCELL );
1454 				rReq.AppendItem( SvxHorJustifyItem(
1455 					!pHorJustify || (eHorJustify != SVX_HOR_JUSTIFY_RIGHT) ?
1456 					SVX_HOR_JUSTIFY_RIGHT : SVX_HOR_JUSTIFY_STANDARD, SID_H_ALIGNCELL ) );
1457 				ExecuteSlot( rReq, GetInterface() );
1458 				return;
1459 //				APPLY_HOR_JUSTIFY( SVX_HOR_JUSTIFY_RIGHT );
1460                 //break;
1461 
1462 			case SID_ALIGNCENTERHOR:
1463 				rReq.SetSlot( SID_H_ALIGNCELL );
1464 				rReq.AppendItem( SvxHorJustifyItem(
1465 					!pHorJustify || (eHorJustify != SVX_HOR_JUSTIFY_CENTER) ?
1466 					SVX_HOR_JUSTIFY_CENTER : SVX_HOR_JUSTIFY_STANDARD, SID_H_ALIGNCELL ) );
1467 				ExecuteSlot( rReq, GetInterface() );
1468 				return;
1469 //				APPLY_HOR_JUSTIFY( SVX_HOR_JUSTIFY_CENTER );
1470                 //break;
1471 
1472 			case SID_ALIGNBLOCK:
1473 				rReq.SetSlot( SID_H_ALIGNCELL );
1474 				rReq.AppendItem( SvxHorJustifyItem(
1475 					!pHorJustify || (eHorJustify != SVX_HOR_JUSTIFY_BLOCK) ?
1476 					SVX_HOR_JUSTIFY_BLOCK : SVX_HOR_JUSTIFY_STANDARD, SID_H_ALIGNCELL ) );
1477 				ExecuteSlot( rReq, GetInterface() );
1478 				return;
1479 //				APPLY_HOR_JUSTIFY( SVX_HOR_JUSTIFY_BLOCK );
1480                 //break;
1481 
1482 			case SID_ALIGNTOP:
1483 				rReq.SetSlot( SID_V_ALIGNCELL );
1484 				rReq.AppendItem( SvxVerJustifyItem(
1485 					!pVerJustify || (eVerJustify != SVX_VER_JUSTIFY_TOP) ?
1486 					SVX_VER_JUSTIFY_TOP : SVX_VER_JUSTIFY_STANDARD, SID_V_ALIGNCELL ) );
1487 				ExecuteSlot( rReq, GetInterface() );
1488 				return;
1489 //				APPLY_VER_JUSTIFY( SVX_VER_JUSTIFY_TOP );
1490                 //break;
1491 
1492 			case SID_ALIGNBOTTOM:
1493 				rReq.SetSlot( SID_V_ALIGNCELL );
1494 				rReq.AppendItem( SvxVerJustifyItem(
1495 					!pVerJustify || (eVerJustify != SVX_VER_JUSTIFY_BOTTOM) ?
1496 					SVX_VER_JUSTIFY_BOTTOM : SVX_VER_JUSTIFY_STANDARD, SID_V_ALIGNCELL ) );
1497 				ExecuteSlot( rReq, GetInterface() );
1498 				return;
1499 //				APPLY_VER_JUSTIFY( SVX_VER_JUSTIFY_BOTTOM );
1500                 //break;
1501 
1502 			case SID_ALIGNCENTERVER:
1503 				rReq.SetSlot( SID_V_ALIGNCELL );
1504 				rReq.AppendItem( SvxVerJustifyItem(
1505 					!pVerJustify || (eVerJustify != SVX_VER_JUSTIFY_CENTER) ?
1506 					SVX_VER_JUSTIFY_CENTER : SVX_VER_JUSTIFY_STANDARD, SID_V_ALIGNCELL ) );
1507 				ExecuteSlot( rReq, GetInterface() );
1508 				return;
1509 //				APPLY_VER_JUSTIFY( SVX_VER_JUSTIFY_CENTER );
1510                 //break;
1511 
1512 			default:
1513 			break;
1514 		}
1515 
1516 	}
1517 
1518 	rBindings.Update();
1519 //	rReq.Done();
1520 
1521 	if( pNewSet )
1522 	{
1523 		rReq.Done( *pNewSet );
1524 		delete pNewSet;
1525 	}
1526 	else
1527 	{
1528 		rReq.Done();
1529 	}
1530 
1531 }
1532 
1533 #undef APPLY_HOR_JUSTIFY
1534 #undef APPLY_VER_JUSTIFY
1535 
1536 //------------------------------------------------------------------
1537 
1538 void ScFormatShell::ExecuteAttr( SfxRequest& rReq )
1539 {
1540 	ScTabViewShell*	pTabViewShell  		= GetViewData()->GetViewShell();
1541 	SfxBindings&		rBindings = pViewData->GetBindings();
1542 	const SfxItemSet*	pNewAttrs = rReq.GetArgs();
1543 
1544 	pTabViewShell->HideListBox();					// Autofilter-DropDown-Listbox
1545 
1546 	if ( !pNewAttrs )
1547 	{
1548 		sal_uInt16 nSlot = rReq.GetSlot();
1549 
1550 		switch ( nSlot )
1551 		{
1552 			case SID_ATTR_CHAR_FONT:
1553 			case SID_ATTR_CHAR_FONTHEIGHT:
1554 				pTabViewShell->ExecuteCellFormatDlg( rReq, TP_FONT );	    // wenn ToolBar vertikal
1555 				break;
1556 
1557 			case SID_ATTR_ALIGN_LINEBREAK:					// ohne Parameter als Toggle
1558 				{
1559 					const ScPatternAttr* pAttrs = pTabViewShell->GetSelectionPattern();
1560 					sal_Bool bOld = ((const SfxBoolItem&)pAttrs->GetItem(ATTR_LINEBREAK)).GetValue();
1561 					SfxBoolItem aBreakItem( ATTR_LINEBREAK, !bOld );
1562 					pTabViewShell->ApplyAttr( aBreakItem );
1563 
1564 					SfxAllItemSet aNewSet( GetPool() );
1565 					aNewSet.Put( aBreakItem,aBreakItem.Which() );
1566 					rReq.Done( aNewSet );
1567 
1568 					rBindings.Invalidate( nSlot );
1569 				}
1570 				break;
1571 
1572 			case SID_BACKGROUND_COLOR:
1573 				{
1574 					//	SID_BACKGROUND_COLOR without arguments -> set transparent background
1575 
1576 					SvxBrushItem        aBrushItem( (const SvxBrushItem&)
1577 											pTabViewShell->GetSelectionPattern()->
1578 												GetItem( ATTR_BACKGROUND ) );
1579 
1580 					aBrushItem.SetColor( COL_TRANSPARENT );
1581 
1582 					pTabViewShell->ApplyAttr( aBrushItem );
1583 				}
1584 				break;
1585 		}
1586 	}
1587 	else
1588 	{
1589 		sal_uInt16 nSlot = rReq.GetSlot();
1590 
1591 		switch ( nSlot )
1592 		{
1593             case SID_ATTR_CHAR_OVERLINE:
1594             case SID_ATTR_CHAR_STRIKEOUT:
1595 			case SID_ATTR_ALIGN_LINEBREAK:
1596 			case SID_ATTR_CHAR_COLOR:
1597             case SID_ATTR_CHAR_CONTOUR:
1598             case SID_ATTR_CHAR_SHADOWED:
1599             case SID_ATTR_CHAR_RELIEF:
1600             case SID_SCATTR_PROTECTION :
1601 				pTabViewShell->ApplyAttr( pNewAttrs->Get( pNewAttrs->GetPool()->GetWhich( nSlot ) ) );
1602 				rBindings.Invalidate( nSlot );
1603 				rBindings.Update( nSlot );
1604 				break;
1605 
1606 			case SID_ATTR_CHAR_FONT:
1607 			case SID_ATTR_CHAR_FONTHEIGHT:
1608 				{
1609 					// #i78017 establish the same behaviour as in Writer
1610 					sal_uInt8 nScript = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX;
1611 					if (nSlot == SID_ATTR_CHAR_FONT)
1612 						nScript = pTabViewShell->GetSelectionScriptType();
1613 
1614 					SfxItemPool& rPool = GetPool();
1615 					SvxScriptSetItem aSetItem( nSlot, rPool );
1616 					sal_uInt16 nWhich = rPool.GetWhich( nSlot );
1617 					aSetItem.PutItemForScriptType( nScript, pNewAttrs->Get( nWhich ) );
1618 
1619 					pTabViewShell->ApplyUserItemSet( aSetItem.GetItemSet() );
1620 
1621 					rBindings.Invalidate( nSlot );
1622 					rBindings.Update( nSlot );
1623 				}
1624 				break;
1625 
1626 			case SID_FRAME_LINESTYLE:
1627 				{
1628 					// Default-Linie aktualisieren
1629 					const SvxBorderLine* pLine =
1630 							((const SvxLineItem&)
1631 								pNewAttrs->Get( SID_FRAME_LINESTYLE )).
1632 								GetLine();
1633 
1634 					if ( pLine )
1635 					{
1636 						SvxBorderLine* pDefLine = pTabViewShell->GetDefaultFrameLine();
1637 
1638 						if ( pDefLine )
1639 						{
1640 							pDefLine->SetOutWidth( pLine->GetOutWidth() );
1641 							pDefLine->SetInWidth ( pLine->GetInWidth() );
1642 							pDefLine->SetDistance( pLine->GetDistance() );
1643 							pTabViewShell->SetSelectionFrameLines( pDefLine, sal_False );
1644 						}
1645 						else
1646 						{
1647 							pTabViewShell->SetDefaultFrameLine( pLine );
1648 							pTabViewShell->GetDefaultFrameLine()->SetColor( COL_BLACK );
1649 							pTabViewShell->SetSelectionFrameLines( pLine, sal_False );
1650 						}
1651 					}
1652 					else
1653 					{
1654 						Color           aColorBlack( COL_BLACK );
1655 						SvxBorderLine   aDefLine( &aColorBlack, 20, 0, 0 );
1656 						pTabViewShell->SetDefaultFrameLine( &aDefLine );
1657 						pTabViewShell->SetSelectionFrameLines( NULL, sal_False );
1658 					}
1659 				}
1660 				break;
1661 
1662 			case SID_FRAME_LINECOLOR:
1663 				{
1664 					SvxBorderLine*  pDefLine = pTabViewShell->GetDefaultFrameLine();
1665 					const Color&    rColor = ((const SvxColorItem&)
1666 										pNewAttrs->Get( SID_FRAME_LINECOLOR )).
1667 											GetValue();
1668 
1669 					// Default-Linie aktualisieren
1670 					if ( pDefLine )
1671 					{
1672 						pDefLine->SetColor( rColor );
1673 						pTabViewShell->SetSelectionFrameLines( pDefLine, sal_True );
1674 					}
1675 					else
1676 					{
1677 						SvxBorderLine   aDefLine( &rColor, 20, 0, 0 );
1678 						pTabViewShell->SetDefaultFrameLine( &aDefLine );
1679 						pTabViewShell->SetSelectionFrameLines( &aDefLine, sal_False );
1680 					}
1681 				}
1682 				break;
1683 
1684 			case SID_ATTR_BORDER_OUTER:
1685 			case SID_ATTR_BORDER:
1686 				{
1687 					SvxBorderLine*          pDefLine = pTabViewShell->GetDefaultFrameLine();
1688 					const ScPatternAttr*    pOldAttrs = pTabViewShell->GetSelectionPattern();
1689 					ScDocument*             pDoc = GetViewData()->GetDocument();
1690 					SfxItemSet*             pOldSet =
1691 												new SfxItemSet(
1692 														*(pDoc->GetPool()),
1693 														ATTR_PATTERN_START,
1694 														ATTR_PATTERN_END );
1695 					SfxItemSet*             pNewSet =
1696 												new SfxItemSet(
1697 														*(pDoc->GetPool()),
1698 														ATTR_PATTERN_START,
1699 														ATTR_PATTERN_END );
1700 					const SfxPoolItem&      rBorderAttr =
1701 												pOldAttrs->GetItemSet().
1702 													Get( ATTR_BORDER );
1703 
1704 					// Border-Items vom Controller auswerten:
1705 					const SfxPoolItem* pItem = 0;
1706 
1707 					if ( pNewAttrs->GetItemState( ATTR_BORDER, sal_True, &pItem )
1708 						 == SFX_ITEM_SET )
1709 					{
1710 						//	#100959# The SvxFrameToolBoxControl toolbox controller uses a default
1711 						//	SvxBorderLine (all widths 0) to mark the lines that should be set.
1712 						//	Macro recording uses a SvxBoxItem with the real values (OutWidth > 0)
1713 						//	or NULL pointers for no lines.
1714 						//	-> Substitute existing lines with pDefLine only if widths are 0.
1715 						SvxBoxItem aBoxItem ( *(const SvxBoxItem*)pItem );
1716 						if ( aBoxItem.GetTop() && aBoxItem.GetTop()->GetOutWidth() == 0 )
1717 							aBoxItem.SetLine( pDefLine, BOX_LINE_TOP );
1718 						if ( aBoxItem.GetBottom() && aBoxItem.GetBottom()->GetOutWidth() == 0 )
1719 							aBoxItem.SetLine( pDefLine, BOX_LINE_BOTTOM );
1720 						if ( aBoxItem.GetLeft() && aBoxItem.GetLeft()->GetOutWidth() == 0 )
1721 							aBoxItem.SetLine( pDefLine, BOX_LINE_LEFT );
1722 						if ( aBoxItem.GetRight() && aBoxItem.GetRight()->GetOutWidth() == 0 )
1723 							aBoxItem.SetLine( pDefLine, BOX_LINE_RIGHT );
1724 						pNewSet->Put( aBoxItem );
1725                         rReq.AppendItem( aBoxItem );
1726 					}
1727 
1728 					if ( pNewAttrs->GetItemState( ATTR_BORDER_INNER, sal_True, &pItem )
1729 						 == SFX_ITEM_SET )
1730 					{
1731 						SvxBoxInfoItem aBoxInfoItem( *(const SvxBoxInfoItem*)pItem );
1732 						if ( aBoxInfoItem.GetHori() && aBoxInfoItem.GetHori()->GetOutWidth() == 0 )
1733 							aBoxInfoItem.SetLine( pDefLine, BOXINFO_LINE_HORI );
1734 						if ( aBoxInfoItem.GetVert() && aBoxInfoItem.GetVert()->GetOutWidth() == 0 )
1735 							aBoxInfoItem.SetLine( pDefLine, BOXINFO_LINE_VERT );
1736 						pNewSet->Put( aBoxInfoItem );
1737                         rReq.AppendItem( aBoxInfoItem );
1738 					}
1739 					else
1740 					{
1741 						SvxBoxInfoItem aBoxInfoItem( ATTR_BORDER_INNER );
1742 						aBoxInfoItem.SetLine( NULL, BOXINFO_LINE_HORI );
1743 						aBoxInfoItem.SetLine( NULL, BOXINFO_LINE_VERT );
1744 						pNewSet->Put( aBoxInfoItem );
1745 					}
1746 
1747 					pOldSet->Put( rBorderAttr );
1748 					pTabViewShell->ApplyAttributes( pNewSet, pOldSet );
1749 
1750 					delete pOldSet;
1751 					delete pNewSet;
1752 				}
1753 				break;
1754 
1755 			case SID_ATTR_BORDER_DIAG_TLBR:
1756 			case SID_ATTR_BORDER_DIAG_BLTR:
1757 				{
1758 					ScDocument* pDoc = GetViewData()->GetDocument();
1759 					const ScPatternAttr* pOldAttrs = pTabViewShell->GetSelectionPattern();
1760 					SfxItemSet* pOldSet = new SfxItemSet(pOldAttrs->GetItemSet());
1761 					SfxItemSet* pNewSet = new SfxItemSet(pOldAttrs->GetItemSet());
1762 					const SfxPoolItem* pItem = 0;
1763 
1764                     if(SID_ATTR_BORDER_DIAG_TLBR == nSlot)
1765 					{
1766 						if(SFX_ITEM_SET == pNewAttrs->GetItemState(ATTR_BORDER_TLBR, true, &pItem))
1767 						{
1768 							SvxLineItem aItem(ATTR_BORDER_TLBR);
1769 							aItem.SetLine(((const SvxLineItem&)pNewAttrs->Get(ATTR_BORDER_TLBR)).GetLine());
1770 							pNewSet->Put(aItem);
1771 							rReq.AppendItem(aItem);
1772 							pTabViewShell->ApplyAttributes(pNewSet, pOldSet);
1773 						}
1774 					}
1775 					else // if( nSlot == SID_ATTR_BORDER_DIAG_BLTR )
1776 					{
1777 						if(SFX_ITEM_SET == pNewAttrs->GetItemState(ATTR_BORDER_BLTR, true, &pItem ))
1778 						{
1779 							SvxLineItem aItem(ATTR_BORDER_BLTR);
1780 							aItem.SetLine(((const SvxLineItem&)pNewAttrs->Get(ATTR_BORDER_BLTR)).GetLine());
1781 							pNewSet->Put(aItem);
1782 							rReq.AppendItem(aItem);
1783 							pTabViewShell->ApplyAttributes(pNewSet, pOldSet);
1784 						}
1785 					}
1786 
1787                     delete pOldSet;
1788 					delete pNewSet;
1789 					rBindings.Invalidate(nSlot);
1790 				}
1791 				break;
1792 
1793 			// ATTR_BACKGROUND (=SID_ATTR_BRUSH) muss ueber zwei IDs
1794 			// gesetzt werden:
1795 			case SID_BACKGROUND_COLOR:
1796 				{
1797 					const SvxColorItem  rNewColorItem = (const SvxColorItem&)
1798 											pNewAttrs->Get( SID_BACKGROUND_COLOR );
1799 
1800 					SvxBrushItem        aBrushItem( (const SvxBrushItem&)
1801 											pTabViewShell->GetSelectionPattern()->
1802 												GetItem( ATTR_BACKGROUND ) );
1803 
1804 					aBrushItem.SetColor( rNewColorItem.GetValue() );
1805 
1806 					pTabViewShell->ApplyAttr( aBrushItem );
1807 				}
1808 				break;
1809 
1810 				case SID_ATTR_BRUSH:
1811 				{
1812 					SvxBrushItem        aBrushItem( (const SvxBrushItem&)
1813 											pTabViewShell->GetSelectionPattern()->
1814 												GetItem( ATTR_BACKGROUND ) );
1815 					const SvxBrushItem& rNewBrushItem = (const SvxBrushItem&)
1816 											pNewAttrs->Get( GetPool().GetWhich(nSlot) );
1817 					aBrushItem.SetColor(rNewBrushItem.GetColor());
1818 					pTabViewShell->ApplyAttr( aBrushItem );
1819 				}
1820 				break;
1821 
1822 			case SID_ATTR_BORDER_SHADOW:
1823 				{
1824 					const SvxShadowItem& rNewShadowItem = (const SvxShadowItem&)
1825 											pNewAttrs->Get( ATTR_SHADOW );
1826 					pTabViewShell->ApplyAttr( rNewShadowItem );
1827 				}
1828 				break;
1829 
1830 			default:
1831 			break;
1832 		}
1833 
1834 		if( ! rReq.IsAPI() )
1835 			if( ! rReq.IsDone() )
1836 				rReq.Done();
1837 	}
1838 }
1839 
1840 void ScFormatShell::GetAttrState( SfxItemSet& rSet )
1841 {
1842 	ScTabViewShell*	pTabViewShell  	= GetViewData()->GetViewShell();
1843 	const SfxItemSet&	 rAttrSet	= pTabViewShell->GetSelectionPattern()->GetItemSet();
1844 	const SvxBorderLine* pLine      = pTabViewShell->GetDefaultFrameLine();
1845 	const SvxBrushItem&  rBrushItem = (const SvxBrushItem&)rAttrSet.Get( ATTR_BACKGROUND );
1846 	SfxWhichIter aIter( rSet );
1847 	sal_uInt16 nWhich = aIter.FirstWhich();
1848 
1849 	rSet.Put( rAttrSet, sal_False );
1850 
1851 	//	choose font info according to selection script type
1852 	sal_uInt8 nScript = 0;		// GetSelectionScriptType never returns 0
1853 	if ( rSet.GetItemState( ATTR_FONT ) != SFX_ITEM_UNKNOWN )
1854 	{
1855 		if (!nScript) nScript = pTabViewShell->GetSelectionScriptType();
1856 		ScViewUtil::PutItemScript( rSet, rAttrSet, ATTR_FONT, nScript );
1857 	}
1858 	if ( rSet.GetItemState( ATTR_FONT_HEIGHT ) != SFX_ITEM_UNKNOWN )
1859 	{
1860 		if (!nScript) nScript = pTabViewShell->GetSelectionScriptType();
1861 		ScViewUtil::PutItemScript( rSet, rAttrSet, ATTR_FONT_HEIGHT, nScript );
1862 	}
1863 
1864 	while ( nWhich )
1865 	{
1866 		switch(nWhich)
1867 		{
1868 			case SID_BACKGROUND_COLOR:
1869 			{
1870                 rSet.Put( SvxColorItem( rBrushItem.GetColor(), SID_BACKGROUND_COLOR ) );
1871 
1872                 if(SFX_ITEM_DONTCARE == rAttrSet.GetItemState(ATTR_BACKGROUND))
1873                 {
1874                     rSet.InvalidateItem(SID_BACKGROUND_COLOR);
1875                 }
1876 			}
1877 			break;
1878     		case SID_FRAME_LINESTYLE:
1879 			case SID_FRAME_LINECOLOR:
1880 			{
1881                 // handled together because both need the cell border information for decisions
1882                 // rSet.Put( SvxColorItem( pLine ? pLine->GetColor() : Color(), SID_FRAME_LINECOLOR ) );
1883 				Color aCol = 0;
1884 				sal_uInt16 nOut = 0, nIn = 0, nDis = 0;
1885 				SvxBorderLine aLine(0,0,0,0);
1886 				bool bCol = 0;
1887 				bool bColDisable = 0, bStyleDisable = 0;
1888                 SvxBoxItem aBoxItem(ATTR_BORDER);
1889                 SvxBoxInfoItem aInfoItem(ATTR_BORDER_INNER);
1890 
1891                 pTabViewShell->GetSelectionFrame(aBoxItem, aInfoItem);
1892 
1893 				if( aBoxItem.GetTop() )
1894 				{
1895 					bCol = 1;
1896 					aCol = aBoxItem.GetTop()->GetColor() ;
1897 					aLine.SetColor(aCol);
1898 					aLine.SetOutWidth( aBoxItem.GetTop()->GetOutWidth());
1899 					aLine.SetInWidth( aBoxItem.GetTop()->GetInWidth());
1900 					aLine.SetDistance( aBoxItem.GetTop()->GetDistance());
1901 				}
1902 
1903                 if( aBoxItem.GetBottom() )
1904 				{
1905 					if(bCol == 0)
1906 					{
1907 						bCol = 1;
1908 						aCol = aBoxItem.GetBottom()->GetColor() ;
1909 						aLine.SetColor(aCol);
1910 						aLine.SetOutWidth( aBoxItem.GetBottom()->GetOutWidth());
1911 						aLine.SetInWidth( aBoxItem.GetBottom()->GetInWidth());
1912 						aLine.SetDistance( aBoxItem.GetBottom()->GetDistance());
1913 					}
1914 					else
1915 					{
1916 						if(aCol != aBoxItem.GetBottom()->GetColor() )
1917 							bColDisable = 1;
1918 						if(!( aLine == *(aBoxItem.GetBottom())) )
1919 							bStyleDisable = 1;
1920 					}
1921 				}
1922 
1923                 if( aBoxItem.GetLeft() )
1924 				{
1925 					if(bCol == 0)
1926 					{
1927 						bCol = 1;
1928 						aCol = aBoxItem.GetLeft()->GetColor() ;
1929 						aLine.SetColor(aCol);
1930 						aLine.SetOutWidth( aBoxItem.GetLeft()->GetOutWidth());
1931 						aLine.SetInWidth( aBoxItem.GetLeft()->GetInWidth());
1932 						aLine.SetDistance( aBoxItem.GetLeft()->GetDistance());
1933 					}
1934 					else
1935 					{
1936 						if(aCol != aBoxItem.GetLeft()->GetColor() )
1937 							bColDisable = 1;
1938 						if(!( aLine == *(aBoxItem.GetLeft())) )
1939 							bStyleDisable = 1;
1940 					}
1941 				}
1942 
1943                 if( aBoxItem.GetRight() )
1944 				{
1945 					if(bCol == 0)
1946 					{
1947 						bCol = 1;
1948 						aCol = aBoxItem.GetRight()->GetColor() ;
1949 						aLine.SetColor(aCol);
1950 						aLine.SetOutWidth( aBoxItem.GetRight()->GetOutWidth());
1951 						aLine.SetInWidth( aBoxItem.GetRight()->GetInWidth());
1952 						aLine.SetDistance( aBoxItem.GetRight()->GetDistance());
1953 					}
1954 					else
1955 					{
1956 						if(aCol != aBoxItem.GetRight()->GetColor() )
1957 							bColDisable = 1;
1958 						if(!( aLine == *(aBoxItem.GetRight())) )
1959 							bStyleDisable = 1;
1960 					}
1961 				}
1962 
1963                 if( aInfoItem.GetVert())
1964 				{
1965 					if(bCol == 0)
1966 					{
1967 						bCol = 1;
1968 						aCol = aInfoItem.GetVert()->GetColor() ;
1969 						aLine.SetColor(aCol);
1970 						aLine.SetOutWidth( aInfoItem.GetVert()->GetOutWidth());
1971 						aLine.SetInWidth( aInfoItem.GetVert()->GetInWidth());
1972 						aLine.SetDistance( aInfoItem.GetVert()->GetDistance());
1973 					}
1974 					else
1975 					{
1976 						if(aCol != aInfoItem.GetVert()->GetColor() )
1977 							bColDisable = 1;
1978 						if(!( aLine == *(aInfoItem.GetVert())) )
1979 							bStyleDisable = 1;
1980 					}
1981 				}
1982 
1983                 if( aInfoItem.GetHori())
1984 				{
1985 					if(bCol == 0)
1986 					{
1987 						bCol = 1;
1988 						aCol = aInfoItem.GetHori()->GetColor() ;
1989 						aLine.SetColor(aCol);
1990 						aLine.SetOutWidth( aInfoItem.GetHori()->GetOutWidth());
1991 						aLine.SetInWidth( aInfoItem.GetHori()->GetInWidth());
1992 						aLine.SetDistance( aInfoItem.GetHori()->GetDistance());
1993 					}
1994 					else
1995 					{
1996 						if(aCol != aInfoItem.GetHori()->GetColor() )
1997 							bColDisable = 1;
1998 						if(!( aLine == *(aInfoItem.GetHori())) )
1999 							bStyleDisable = 1;
2000 					}
2001 				}
2002 
2003 				if( !aInfoItem.IsValid( VALID_VERT )
2004 					|| !aInfoItem.IsValid( VALID_HORI )
2005 					|| !aInfoItem.IsValid( VALID_LEFT )
2006 					|| !aInfoItem.IsValid( VALID_RIGHT )
2007 					|| !aInfoItem.IsValid( VALID_TOP )
2008 					|| !aInfoItem.IsValid( VALID_BOTTOM ) )
2009 				{
2010 					bColDisable = 1;
2011 					bStyleDisable = 1;
2012 				}
2013 
2014 				if(SID_FRAME_LINECOLOR == nWhich)
2015 				{
2016 					if(bColDisable) // if different lines have differernt colors
2017 					{
2018 						aCol = COL_TRANSPARENT;
2019 						rSet.Put( SvxColorItem(aCol, SID_FRAME_LINECOLOR ) );
2020 						rSet.InvalidateItem(SID_FRAME_LINECOLOR);
2021 					}
2022 					else if( bCol == 0 && bColDisable == 0) // if no line available
2023 					{
2024 						aCol = COL_AUTO;
2025 						rSet.Put( SvxColorItem(aCol, SID_FRAME_LINECOLOR ) );
2026 					}
2027 					else
2028 						rSet.Put( SvxColorItem(aCol, SID_FRAME_LINECOLOR ) );
2029 				}
2030 				else // if( nWhich == SID_FRAME_LINESTYLE)
2031 				{
2032 					if(bStyleDisable) // if have several lines but don't have same style
2033 					{
2034 						aLine.SetOutWidth( 1 );
2035 						aLine.SetInWidth( 0 );
2036 						aLine.SetDistance( 0 );
2037 						SvxLineItem aItem(SID_FRAME_LINESTYLE);
2038 						aItem.SetLine(&aLine);
2039 						rSet.Put( aItem );
2040 						rSet.InvalidateItem(SID_FRAME_LINESTYLE);
2041 					}
2042 					else // all the lines have same style or no line availavle, use initial value (0,0,0,0)
2043 					{
2044 						SvxLineItem aItem(SID_FRAME_LINESTYLE);
2045 						aItem.SetLine(&aLine);
2046 						rSet.Put( aItem );
2047 					}
2048 				}
2049 			}
2050 			break;
2051 			case SID_ATTR_BRUSH:
2052 			{
2053 				rSet.Put( rBrushItem, GetPool().GetWhich(nWhich) );
2054 			}
2055 			break;
2056 /*			case SID_ATTR_ALIGN_LINEBREAK:
2057 			{
2058 				const SfxBoolItem& rBreakItem = (const SfxBoolItem&)rAttrSet.Get( ATTR_LINEBREAK );
2059 				rSet.Put( rBreakItem, GetPool().GetWhich(nWhich) );
2060 			}
2061 			break;
2062 */
2063 		}
2064 		nWhich = aIter.NextWhich();
2065 	}
2066 
2067     if(nWhich)
2068     {
2069         // stuff for sidebar panels
2070         Invalidate(SID_ATTR_ALIGN_DEGREES);
2071         Invalidate(SID_ATTR_ALIGN_STACKED);
2072     }
2073 }
2074 
2075 //------------------------------------------------------------------
2076 
2077 void ScFormatShell::GetTextAttrState( SfxItemSet& rSet )
2078 {
2079 	ScTabViewShell*	pTabViewShell  	= GetViewData()->GetViewShell();
2080 	const SfxItemSet& rAttrSet	= pTabViewShell->GetSelectionPattern()->GetItemSet();
2081 	rSet.Put( rAttrSet, sal_False ); // ItemStates mitkopieren
2082 
2083 	//	choose font info according to selection script type
2084 	sal_uInt8 nScript = 0;		// GetSelectionScriptType never returns 0
2085 	if ( rSet.GetItemState( ATTR_FONT_WEIGHT ) != SFX_ITEM_UNKNOWN )
2086 	{
2087 		if (!nScript) nScript = pTabViewShell->GetSelectionScriptType();
2088 		ScViewUtil::PutItemScript( rSet, rAttrSet, ATTR_FONT_WEIGHT, nScript );
2089 	}
2090 	if ( rSet.GetItemState( ATTR_FONT_POSTURE ) != SFX_ITEM_UNKNOWN )
2091 	{
2092 		if (!nScript) nScript = pTabViewShell->GetSelectionScriptType();
2093 		ScViewUtil::PutItemScript( rSet, rAttrSet, ATTR_FONT_POSTURE, nScript );
2094 	}
2095 
2096 	SfxItemState eState;
2097 //	const SfxPoolItem* pItem;
2098 
2099 	//--------------------------------------------------------------------
2100 	// eigene Kontrolle ueber RadioButton-Funktionalitaet:
2101 	//--------------------------------------------------------------------
2102 	// Unterstreichung
2103 	//------------------------
2104 
2105 	eState = rAttrSet.GetItemState( ATTR_FONT_UNDERLINE, sal_True );
2106 	if ( eState == SFX_ITEM_DONTCARE )
2107 	{
2108 		rSet.InvalidateItem( SID_ULINE_VAL_NONE );
2109 		rSet.InvalidateItem( SID_ULINE_VAL_SINGLE );
2110 		rSet.InvalidateItem( SID_ULINE_VAL_DOUBLE );
2111 		rSet.InvalidateItem( SID_ULINE_VAL_DOTTED );
2112 	}
2113 	else
2114 	{
2115 		FontUnderline eUnderline = ((const SvxUnderlineItem&)
2116 					rAttrSet.Get(ATTR_FONT_UNDERLINE)).GetLineStyle();
2117 		sal_uInt16 nId = SID_ULINE_VAL_NONE;
2118 		switch (eUnderline)
2119 		{
2120 			case UNDERLINE_SINGLE:	nId = SID_ULINE_VAL_SINGLE;	break;
2121 			case UNDERLINE_DOUBLE:	nId = SID_ULINE_VAL_DOUBLE;	break;
2122 			case UNDERLINE_DOTTED:	nId = SID_ULINE_VAL_DOTTED;	break;
2123 			default:
2124 				break;
2125 		}
2126 		rSet.Put( SfxBoolItem( nId, sal_True ) );
2127 	}
2128 
2129 	//------------------------
2130 	// horizontale Ausrichtung
2131 	//------------------------
2132 
2133 	const SvxHorJustifyItem* pHorJustify = NULL;
2134 	const SvxVerJustifyItem* pVerJustify = NULL;
2135 	SvxCellHorJustify        eHorJustify = SVX_HOR_JUSTIFY_STANDARD;
2136 	SvxCellVerJustify        eVerJustify = SVX_VER_JUSTIFY_STANDARD;
2137 	sal_uInt16		 			 nWhich		 = 0;
2138 	sal_Bool					 bJustifyStd = sal_False;
2139 	SfxBoolItem				 aBoolItem	 ( 0, sal_True );
2140 
2141 	eState 	 = rAttrSet.GetItemState( ATTR_HOR_JUSTIFY, sal_True,
2142 										(const SfxPoolItem**)&pHorJustify );
2143 	switch ( eState )
2144 	{
2145 		case SFX_ITEM_SET:
2146 			{
2147 				eHorJustify = SvxCellHorJustify( pHorJustify->GetValue() );
2148 
2149 				switch ( SvxCellHorJustify( pHorJustify->GetValue() ) )
2150 				{
2151 					case SVX_HOR_JUSTIFY_STANDARD:
2152 						break;
2153 
2154 					case SVX_HOR_JUSTIFY_LEFT:
2155 						nWhich = SID_ALIGNLEFT;
2156 						break;
2157 
2158 					case SVX_HOR_JUSTIFY_RIGHT:
2159 						nWhich = SID_ALIGNRIGHT;
2160 						break;
2161 
2162 					case SVX_HOR_JUSTIFY_CENTER:
2163 						nWhich = SID_ALIGNCENTERHOR;
2164 						break;
2165 
2166 					case SVX_HOR_JUSTIFY_BLOCK:
2167 						nWhich = SID_ALIGNBLOCK;
2168 						break;
2169 
2170 					case SVX_HOR_JUSTIFY_REPEAT:
2171 					default:
2172 						bJustifyStd = sal_True;
2173 						break;
2174 				}
2175 			}
2176 			break;
2177 
2178 		case SFX_ITEM_DONTCARE:
2179 			rSet.InvalidateItem( SID_ALIGNLEFT );
2180 			rSet.InvalidateItem( SID_ALIGNRIGHT );
2181 			rSet.InvalidateItem( SID_ALIGNCENTERHOR );
2182 			rSet.InvalidateItem( SID_ALIGNBLOCK );
2183 			break;
2184 
2185 		default:
2186 			bJustifyStd = sal_True;
2187 			break;
2188 	}
2189 
2190 	if ( nWhich )
2191 	{
2192 		aBoolItem.SetWhich( nWhich );
2193 		rSet.Put( aBoolItem );
2194 	}
2195 	else if ( bJustifyStd )
2196 	{
2197 		aBoolItem.SetValue( sal_False );
2198 		aBoolItem.SetWhich( SID_ALIGNLEFT );	  rSet.Put( aBoolItem );
2199 		aBoolItem.SetWhich( SID_ALIGNRIGHT );	  rSet.Put( aBoolItem );
2200 		aBoolItem.SetWhich( SID_ALIGNCENTERHOR ); rSet.Put( aBoolItem );
2201 		aBoolItem.SetWhich( SID_ALIGNBLOCK );	  rSet.Put( aBoolItem );
2202 		bJustifyStd = sal_False;
2203 	}
2204 
2205 	//------------------------
2206 	// vertikale Ausrichtung
2207 	//------------------------
2208 
2209 	nWhich = 0;
2210 	aBoolItem.SetValue( sal_True );
2211 
2212 	eState = rAttrSet.GetItemState( ATTR_VER_JUSTIFY, sal_True,
2213 									(const SfxPoolItem**)&pVerJustify );
2214 
2215 	switch ( eState )
2216 	{
2217 		case SFX_ITEM_SET:
2218 			{
2219 				eVerJustify = SvxCellVerJustify( pVerJustify->GetValue() );
2220 
2221 				switch ( eVerJustify )
2222 				{
2223 					case SVX_VER_JUSTIFY_TOP:
2224 						nWhich = SID_ALIGNTOP;
2225 						break;
2226 
2227 					case SVX_VER_JUSTIFY_BOTTOM:
2228 						nWhich = SID_ALIGNBOTTOM;
2229 						break;
2230 
2231 					case SVX_VER_JUSTIFY_CENTER:
2232 						nWhich = SID_ALIGNCENTERVER;
2233 						break;
2234 
2235 					case SVX_VER_JUSTIFY_STANDARD:
2236 					default:
2237 						bJustifyStd = sal_True;
2238 						break;
2239 				}
2240 			}
2241 			break;
2242 
2243 		case SFX_ITEM_DONTCARE:
2244 			rSet.InvalidateItem( SID_ALIGNTOP );
2245 			rSet.InvalidateItem( SID_ALIGNBOTTOM );
2246 			rSet.InvalidateItem( SID_ALIGNCENTERVER );
2247 			break;
2248 
2249 		default:
2250 			bJustifyStd = sal_True;
2251 			break;
2252 	}
2253 
2254 	if ( nWhich )
2255 	{
2256 		aBoolItem.SetWhich( nWhich );
2257 		rSet.Put( aBoolItem );
2258 	}
2259 	else if ( bJustifyStd )
2260 	{
2261 		aBoolItem.SetValue( sal_False );
2262 		aBoolItem.SetWhich( SID_ALIGNTOP );	  	  rSet.Put( aBoolItem );
2263 		aBoolItem.SetWhich( SID_ALIGNBOTTOM );	  rSet.Put( aBoolItem );
2264 		aBoolItem.SetWhich( SID_ALIGNCENTERVER ); rSet.Put( aBoolItem );
2265 	}
2266 }
2267 
2268 
2269 //------------------------------------------------------------------
2270 
2271 void ScFormatShell::GetBorderState( SfxItemSet& rSet )
2272 {
2273 	ScTabViewShell*	pTabViewShell  	= GetViewData()->GetViewShell();
2274 	SvxBoxItem		aBoxItem( ATTR_BORDER );
2275 	SvxBoxInfoItem	aInfoItem( ATTR_BORDER_INNER );
2276 
2277 	pTabViewShell->GetSelectionFrame( aBoxItem, aInfoItem );
2278 
2279 	if ( rSet.GetItemState( ATTR_BORDER ) != SFX_ITEM_UNKNOWN )
2280 		rSet.Put( aBoxItem );
2281 	if ( rSet.GetItemState( ATTR_BORDER_INNER ) != SFX_ITEM_UNKNOWN )
2282 		rSet.Put( aInfoItem );
2283 }
2284 
2285 //------------------------------------------------------------------
2286 
2287 void ScFormatShell::GetAlignState( SfxItemSet& rSet )
2288 {
2289 	ScTabViewShell*	pTabViewShell  	= GetViewData()->GetViewShell();
2290 	const SfxItemSet& rAttrSet    = pTabViewShell->GetSelectionPattern()->GetItemSet();
2291 	SfxWhichIter	aIter(rSet);
2292 	sal_uInt16			nWhich = aIter.FirstWhich();
2293 
2294     SvxCellHorJustify eHAlign = SVX_HOR_JUSTIFY_STANDARD;
2295     bool bHasHAlign = rAttrSet.GetItemState( ATTR_HOR_JUSTIFY ) != SFX_ITEM_DONTCARE;
2296     if( bHasHAlign )
2297         eHAlign = (SvxCellHorJustify)((const SvxHorJustifyItem&) rAttrSet.Get( ATTR_HOR_JUSTIFY )).GetValue();
2298 
2299     SvxCellVerJustify eVAlign = SVX_VER_JUSTIFY_STANDARD;
2300     bool bHasVAlign = rAttrSet.GetItemState( ATTR_VER_JUSTIFY ) != SFX_ITEM_DONTCARE;
2301     if( bHasVAlign )
2302         eVAlign = (SvxCellVerJustify)((const SvxVerJustifyItem&) rAttrSet.Get( ATTR_VER_JUSTIFY )).GetValue();
2303 
2304 	while ( nWhich )
2305 	{
2306 		switch ( nWhich )
2307 		{
2308 			case SID_H_ALIGNCELL:
2309                 if ( bHasHAlign )
2310                     rSet.Put( SvxHorJustifyItem( eHAlign, nWhich ));
2311 			break;
2312 			case SID_V_ALIGNCELL:
2313                 if ( bHasVAlign )
2314                     rSet.Put( SvxVerJustifyItem( eVAlign, nWhich ));
2315 			break;
2316 
2317             // pseudo slots for Format menu
2318             case SID_ALIGN_ANY_HDEFAULT:
2319             case SID_ALIGN_ANY_LEFT:
2320             case SID_ALIGN_ANY_HCENTER:
2321             case SID_ALIGN_ANY_RIGHT:
2322             case SID_ALIGN_ANY_JUSTIFIED:
2323                 rSet.Put( SfxBoolItem( nWhich, bHasHAlign && (eHAlign == lclConvertSlotToHAlign( nWhich )) ) );
2324             break;
2325             case SID_ALIGN_ANY_VDEFAULT:
2326             case SID_ALIGN_ANY_TOP:
2327             case SID_ALIGN_ANY_VCENTER:
2328             case SID_ALIGN_ANY_BOTTOM:
2329                 rSet.Put( SfxBoolItem( nWhich, bHasVAlign && (eVAlign == lclConvertSlotToVAlign( nWhich )) ) );
2330             break;
2331 		}
2332 		nWhich = aIter.NextWhich();
2333 	}
2334 }
2335 
2336 void ScFormatShell::GetNumFormatState( SfxItemSet& rSet )
2337 {
2338 	ScTabViewShell*	pTabViewShell  	= GetViewData()->GetViewShell();
2339 
2340     // ScViewData* pViewData   = GetViewData();
2341 	ScDocument* pDoc		= pViewData->GetDocument();
2342 
2343 	SfxWhichIter aIter(rSet);
2344 	sal_uInt16 nWhich = aIter.FirstWhich();
2345 	while ( nWhich )
2346 	{
2347 		switch ( nWhich )
2348 		{
2349 			case SID_NUMBER_FORMAT:
2350 				//{
2351 				//	String aFormatCode;			// bleibt leer, wenn dont-care
2352                 //
2353 				//	const SfxItemSet& rAttrSet  = pTabViewShell->GetSelectionPattern()->GetItemSet();
2354 				//	if ( rAttrSet.GetItemState( ATTR_VALUE_FORMAT ) != SFX_ITEM_DONTCARE )
2355 				//	{
2356 				//		sal_uLong nNumberFormat = ((const SfxUInt32Item&)rAttrSet.Get(
2357 				//									ATTR_VALUE_FORMAT )).GetValue();
2358                 //
2359 				//		SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
2360 				//		const SvNumberformat* pFormatEntry = pFormatter->GetEntry( nNumberFormat );
2361 				//		if ( pFormatEntry )
2362 				//			aFormatCode = pFormatEntry->GetFormatstring();
2363 				//	}
2364                 //
2365 				//	rSet.Put( SfxStringItem( nWhich, aFormatCode ) );
2366 				//}
2367 
2368                 // symphony version with format interpretation
2369 				{
2370 					const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet();
2371 
2372 					if(SFX_ITEM_DONTCARE != rAttrSet.GetItemState(ATTR_VALUE_FORMAT))
2373 					{
2374 						SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
2375 						sal_uInt32 nNumberFormat = ((const SfxUInt32Item&)rAttrSet.Get(ATTR_VALUE_FORMAT)).GetValue();
2376 						sal_Bool bThousand(false);
2377 						sal_Bool bNegRed(false);
2378 						sal_uInt16 nPrecision(0);
2379 						sal_uInt16 nLeadZeroes(0);
2380 
2381                         pFormatter->GetFormatSpecialInfo(nNumberFormat,bThousand, bNegRed, nPrecision, nLeadZeroes);
2382 						String aFormat;
2383 						static String sBreak = String::CreateFromAscii(",");
2384 						const String sThousand = String::CreateFromInt32(bThousand);
2385 						const String sNegRed = String::CreateFromInt32(bNegRed);
2386 						const String sPrecision = String::CreateFromInt32(nPrecision);
2387 						const String sLeadZeroes = String::CreateFromInt32(nLeadZeroes);
2388 
2389 						aFormat += sThousand;
2390 						aFormat += sBreak;
2391 						aFormat += sNegRed;
2392 						aFormat += sBreak;
2393 						aFormat += sPrecision;
2394 						aFormat += sBreak;
2395 						aFormat += sLeadZeroes;
2396 						aFormat += sBreak;
2397 
2398 						rSet.Put(SfxStringItem(nWhich, aFormat));
2399 					}
2400 					else
2401 					{
2402 						rSet.InvalidateItem( nWhich );
2403 					}
2404 				}
2405 				break;
2406 
2407 			case SID_NUMBER_TYPE_FORMAT:
2408 				{
2409 					sal_Int16 aFormatCode = -1;
2410 					const SfxItemSet& rAttrSet  = pTabViewShell->GetSelectionPattern()->GetItemSet();
2411 					if ( rAttrSet.GetItemState( ATTR_VALUE_FORMAT ) >= SFX_ITEM_AVAILABLE ) //Modify for more robust
2412 					{
2413 						SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
2414 						sal_uInt32 nNumberFormat = pTabViewShell->GetSelectionPattern()->GetNumberFormat( pFormatter );
2415 						const SvNumberformat* pFormatEntry = pFormatter->GetEntry( nNumberFormat );
2416 						bool bStandard = false;
2417 
2418 						if ( pFormatEntry )
2419 						{
2420 							aFormatCode = pFormatEntry->GetType();
2421 							bStandard = pFormatEntry->IsStandard();
2422 						}
2423 
2424                         switch(aFormatCode)
2425 						{
2426 						case NUMBERFORMAT_NUMBER:
2427 						case NUMBERFORMAT_NUMBER| NUMBERFORMAT_DEFINED:
2428 							//use format code and standard format code to judge whether it is General,
2429 							//if (nNumberFormat == nStandardNumberFormat)
2430 							if (bStandard)
2431 								aFormatCode = 0;
2432 							else
2433                                 aFormatCode = 1;
2434 							break;
2435 						case NUMBERFORMAT_PERCENT:
2436 						case NUMBERFORMAT_PERCENT| NUMBERFORMAT_DEFINED:
2437 							aFormatCode = 2;
2438 							break;
2439 						case NUMBERFORMAT_CURRENCY:
2440 						case NUMBERFORMAT_CURRENCY| NUMBERFORMAT_DEFINED:
2441 							aFormatCode = 3;
2442 							break;
2443 						case NUMBERFORMAT_DATE:
2444 						case NUMBERFORMAT_DATE| NUMBERFORMAT_DEFINED:
2445 							//Add
2446 						case NUMBERFORMAT_DATETIME:
2447 						case NUMBERFORMAT_DATETIME | NUMBERFORMAT_DEFINED:
2448 							aFormatCode = 4;
2449 							break;
2450 						case NUMBERFORMAT_TIME:
2451 						case NUMBERFORMAT_TIME| NUMBERFORMAT_DEFINED:
2452 							aFormatCode = 5;
2453 							break;
2454 						case NUMBERFORMAT_SCIENTIFIC:
2455 						case NUMBERFORMAT_SCIENTIFIC| NUMBERFORMAT_DEFINED:
2456 							aFormatCode = 6;
2457 							break;
2458 						case NUMBERFORMAT_FRACTION:
2459 						case NUMBERFORMAT_FRACTION| NUMBERFORMAT_DEFINED:
2460 							aFormatCode = 7;
2461 							break;
2462 						case NUMBERFORMAT_LOGICAL:
2463 						case NUMBERFORMAT_LOGICAL| NUMBERFORMAT_DEFINED:
2464 							aFormatCode = 8;
2465 							break;
2466 						case NUMBERFORMAT_TEXT:
2467 						case NUMBERFORMAT_TEXT| NUMBERFORMAT_DEFINED:
2468 							aFormatCode = 9;
2469 							break;
2470 						default:
2471 							aFormatCode = -1;	//for more roburst
2472 						}
2473 						if( aFormatCode == -1 )
2474 							rSet.InvalidateItem( nWhich );
2475 						else
2476 							rSet.Put( SfxInt16Item( nWhich, aFormatCode ) );
2477 					}
2478 					else
2479 					{
2480 						rSet.InvalidateItem( nWhich );
2481 					}
2482 
2483 				}
2484 				break;
2485 		}
2486 		nWhich = aIter.NextWhich();
2487 	}
2488 }
2489 
2490 
2491 void ScFormatShell::ExecuteTextDirection( SfxRequest& rReq )
2492 {
2493     ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
2494     pTabViewShell->HideListBox();               // Autofilter-DropDown-Listbox
2495     if ( GetViewData()->HasEditView( GetViewData()->GetActivePart() ) )
2496     {
2497         SC_MOD()->InputEnterHandler();
2498         pTabViewShell->UpdateInputHandler();
2499     }
2500 
2501     sal_uInt16 nSlot = rReq.GetSlot();
2502     switch( nSlot )
2503     {
2504         case SID_TEXTDIRECTION_LEFT_TO_RIGHT:
2505         case SID_TEXTDIRECTION_TOP_TO_BOTTOM:
2506         {
2507             sal_Bool bVert = (nSlot == SID_TEXTDIRECTION_TOP_TO_BOTTOM);
2508             ScPatternAttr aAttr( GetViewData()->GetDocument()->GetPool() );
2509             SfxItemSet& rItemSet = aAttr.GetItemSet();
2510             rItemSet.Put( SfxBoolItem( ATTR_STACKED, bVert ) );
2511             rItemSet.Put( SfxBoolItem( ATTR_VERTICAL_ASIAN, bVert ) );
2512             pTabViewShell->ApplySelectionPattern( aAttr );
2513             pTabViewShell->AdjustBlockHeight();
2514         }
2515         break;
2516 
2517         case SID_ATTR_PARA_LEFT_TO_RIGHT:
2518         case SID_ATTR_PARA_RIGHT_TO_LEFT:
2519         {
2520             SvxFrameDirection eDirection = ( nSlot == SID_ATTR_PARA_LEFT_TO_RIGHT ) ?
2521                                                 FRMDIR_HORI_LEFT_TOP : FRMDIR_HORI_RIGHT_TOP;
2522             pTabViewShell->ApplyAttr( SvxFrameDirectionItem( eDirection, ATTR_WRITINGDIR ) );
2523         }
2524         break;
2525     }
2526 }
2527 
2528 void ScFormatShell::GetTextDirectionState( SfxItemSet& rSet )
2529 {
2530     ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
2531     const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet();
2532 
2533     sal_Bool bVertDontCare =
2534         (rAttrSet.GetItemState( ATTR_VERTICAL_ASIAN ) == SFX_ITEM_DONTCARE) ||
2535         (rAttrSet.GetItemState( ATTR_STACKED ) == SFX_ITEM_DONTCARE);
2536     sal_Bool bLeftRight = !bVertDontCare &&
2537         !((const SfxBoolItem&) rAttrSet.Get( ATTR_STACKED )).GetValue();
2538     sal_Bool bTopBottom = !bVertDontCare && !bLeftRight &&
2539         ((const SfxBoolItem&) rAttrSet.Get( ATTR_VERTICAL_ASIAN )).GetValue();
2540 
2541     sal_Bool bBidiDontCare = (rAttrSet.GetItemState( ATTR_WRITINGDIR ) == SFX_ITEM_DONTCARE);
2542     EEHorizontalTextDirection eBidiDir = EE_HTEXTDIR_DEFAULT;
2543     if ( !bBidiDontCare )
2544     {
2545         SvxFrameDirection eCellDir = (SvxFrameDirection)((const SvxFrameDirectionItem&)
2546                                         rAttrSet.Get( ATTR_WRITINGDIR )).GetValue();
2547         if ( eCellDir == FRMDIR_ENVIRONMENT )
2548             eBidiDir = (EEHorizontalTextDirection)GetViewData()->GetDocument()->
2549                                 GetEditTextDirection( GetViewData()->GetTabNo() );
2550         else if ( eCellDir == FRMDIR_HORI_RIGHT_TOP )
2551             eBidiDir = EE_HTEXTDIR_R2L;
2552         else
2553             eBidiDir = EE_HTEXTDIR_L2R;
2554     }
2555 
2556 	SvtLanguageOptions	aLangOpt;
2557 	sal_Bool bDisableCTLFont = !aLangOpt.IsCTLFontEnabled();
2558 	sal_Bool bDisableVerticalText = !aLangOpt.IsVerticalTextEnabled();
2559 
2560     SfxWhichIter aIter( rSet );
2561     sal_uInt16 nWhich = aIter.FirstWhich();
2562     while( nWhich )
2563     {
2564         switch( nWhich )
2565         {
2566             case SID_TEXTDIRECTION_LEFT_TO_RIGHT:
2567             case SID_TEXTDIRECTION_TOP_TO_BOTTOM:
2568                 if ( bDisableVerticalText )
2569 					rSet.DisableItem( nWhich );
2570 				else
2571 				{
2572 					if( bVertDontCare )
2573 						rSet.InvalidateItem( nWhich );
2574 					else if ( nWhich == SID_TEXTDIRECTION_LEFT_TO_RIGHT )
2575 						rSet.Put( SfxBoolItem( nWhich, bLeftRight ) );
2576 					else
2577 						rSet.Put( SfxBoolItem( nWhich, bTopBottom ) );
2578 				}
2579             break;
2580 
2581             case SID_ATTR_PARA_LEFT_TO_RIGHT:
2582             case SID_ATTR_PARA_RIGHT_TO_LEFT:
2583 				if ( bDisableCTLFont )
2584 					rSet.DisableItem( nWhich );
2585 				else
2586 				{
2587 					if ( bTopBottom )
2588 						rSet.DisableItem( nWhich );
2589 					else if ( bBidiDontCare )
2590 						rSet.InvalidateItem( nWhich );
2591 					else if ( nWhich == SID_ATTR_PARA_LEFT_TO_RIGHT )
2592 						rSet.Put( SfxBoolItem( nWhich, eBidiDir == EE_HTEXTDIR_L2R ) );
2593 					else
2594 						rSet.Put( SfxBoolItem( nWhich, eBidiDir == EE_HTEXTDIR_R2L ) );
2595 				}
2596         }
2597         nWhich = aIter.NextWhich();
2598     }
2599 }
2600 
2601 void ScFormatShell::ExecFormatPaintbrush( SfxRequest& rReq )
2602 {
2603     ScViewFunc* pView = pViewData->GetView();
2604     if ( pView->HasPaintBrush() )
2605     {
2606         // cancel paintbrush mode
2607         pView->ResetBrushDocument();
2608     }
2609     else
2610     {
2611         sal_Bool bLock = sal_False;
2612         const SfxItemSet *pArgs = rReq.GetArgs();
2613         if( pArgs && pArgs->Count() >= 1 )
2614             bLock = static_cast<const SfxBoolItem&>(pArgs->Get(SID_FORMATPAINTBRUSH)).GetValue();
2615 
2616         // in case of multi selection, deselect all and use the cursor position
2617         ScRange aDummy;
2618         if ( pViewData->GetSimpleArea(aDummy) != SC_MARK_SIMPLE )
2619             pView->Unmark();
2620 
2621         ScDocument* pBrushDoc = new ScDocument( SCDOCMODE_CLIP );
2622         pView->CopyToClip( pBrushDoc, sal_False, sal_True );
2623         pView->SetBrushDocument( pBrushDoc, bLock );
2624     }
2625 }
2626 
2627 void ScFormatShell::StateFormatPaintbrush( SfxItemSet& rSet )
2628 {
2629     if ( pViewData->HasEditView( pViewData->GetActivePart() ) )
2630         rSet.DisableItem( SID_FORMATPAINTBRUSH );
2631     else
2632         rSet.Put( SfxBoolItem( SID_FORMATPAINTBRUSH, pViewData->GetView()->HasPaintBrush() ) );
2633 }
2634 
2635 void  ScFormatShell::ExecViewOptions( SfxRequest& rReq )
2636 {
2637 	ScTabViewShell*	pTabViewShell  		= GetViewData()->GetViewShell();
2638 	SfxBindings&		rBindings = pViewData->GetBindings();
2639 	const SfxItemSet*	pNewAttrs = rReq.GetArgs();
2640 
2641 	if ( pNewAttrs )
2642 	{
2643 		sal_uInt16 nSlot = rReq.GetSlot();
2644 
2645 		if( nSlot  == SID_SCGRIDSHOW)
2646 		{
2647 
2648 			ScViewData*				pViewData = pTabViewShell->GetViewData();
2649 			const ScViewOptions&	rOldOpt	  = pViewData->GetOptions();
2650 			ScDocShell*				pDocSh  = PTR_CAST(ScDocShell, SfxObjectShell::Current());
2651 			bool bState =	((const SfxBoolItem &)pNewAttrs->Get( pNewAttrs->GetPool()->GetWhich( nSlot ) )).GetValue();
2652 
2653 			if ( (bool)rOldOpt.GetOption( VOPT_GRID ) !=  bState)
2654 			{
2655 				ScViewOptions rNewOpt(rOldOpt);
2656 				rNewOpt.SetOption( VOPT_GRID,  bState);
2657 				pViewData->SetOptions( rNewOpt );
2658 				pViewData->GetDocument()->SetViewOptions( rNewOpt );
2659 				pDocSh->SetDocumentModified();
2660 				//add , write the change to sc view config
2661 				ScModule*			pScMod		= SC_MOD();
2662 				pScMod->SetViewOptions( rNewOpt );
2663 				//add end
2664 				rBindings.Invalidate( nSlot );
2665 			}
2666 		}
2667 	}
2668 
2669 }
2670 
2671 void  ScFormatShell::GetViewOptions( SfxItemSet& rSet )
2672 {
2673 	ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
2674 	if( pTabViewShell )
2675 	{
2676 		ScViewOptions	aViewOpt = pTabViewShell->GetViewData()->GetOptions();
2677 		rSet.ClearItem(SID_SCGRIDSHOW);
2678 		SfxBoolItem aItem( SID_SCGRIDSHOW, aViewOpt.GetOption( VOPT_GRID ) );
2679 		rSet.Put(aItem);
2680 	}
2681 }
2682 
2683 // eof
2684