xref: /aoo42x/main/sc/source/ui/view/formatsh.cxx (revision b3f79822)
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 			break;
1003 
1004         case SID_ATTR_NUMBERFORMAT_VALUE:
1005 			if ( pReqArgs )
1006 			{
1007 				const SfxPoolItem* pItem;
1008 				if ( pReqArgs->GetItemState( ATTR_VALUE_FORMAT, sal_True, &pItem ) == SFX_ITEM_SET )
1009 				{
1010                     // We have to accomplish this using ApplyAttributes()
1011                     // because we also need the language information to be
1012                     // considered.
1013                     const SfxItemSet& rOldSet =
1014                         pTabViewShell->GetSelectionPattern()->GetItemSet();
1015                     SfxItemPool* pDocPool = GetViewData()->GetDocument()->GetPool();
1016                     SfxItemSet aNewSet( *pDocPool, ATTR_PATTERN_START, ATTR_PATTERN_END );
1017                     aNewSet.Put( *pItem );
1018                     pTabViewShell->ApplyAttributes( &aNewSet, &rOldSet, sal_True );
1019 				}
1020 			}
1021 			break;
1022 
1023 		default:
1024 			DBG_ERROR("falscher Slot bei ExecuteEdit");
1025 			break;
1026 	}
1027 }
1028 
1029 
1030 //------------------------------------------------------------------
1031 
1032 #define APPLY_HOR_JUSTIFY(j) \
1033 	{																		\
1034 		if ( !pHorJustify || (eHorJustify != (j) ) )                        \
1035 			pTabViewShell->ApplyAttr( SvxHorJustifyItem( (j) ) );                          \
1036 		else                                                                \
1037 			pTabViewShell->ApplyAttr( SvxHorJustifyItem( SVX_HOR_JUSTIFY_STANDARD ) );     \
1038 	}
1039 
1040 #define APPLY_VER_JUSTIFY(j) \
1041 	{																		\
1042 		if ( !pVerJustify || (eVerJustify != (j) ) )                        \
1043 			pTabViewShell->ApplyAttr( SvxVerJustifyItem( (j) ) );                          \
1044 		else                                                                \
1045 			pTabViewShell->ApplyAttr( SvxVerJustifyItem( SVX_VER_JUSTIFY_STANDARD ) );     \
1046 	}
1047 
1048 void ScFormatShell::ExecuteAlignment( SfxRequest& rReq )
1049 {
1050 	ScTabViewShell*	pTabViewShell  		= GetViewData()->GetViewShell();
1051 	SfxBindings&			rBindings	= pViewData->GetBindings();
1052 	const SfxItemSet*       pSet		= rReq.GetArgs();
1053 	sal_uInt16					nSlot		= rReq.GetSlot();
1054 
1055 	pTabViewShell->HideListBox();	// Autofilter-DropDown-Listbox
1056 
1057     switch( nSlot )
1058     {
1059         // pseudo slots for Format menu
1060         case SID_ALIGN_ANY_HDEFAULT:
1061         case SID_ALIGN_ANY_LEFT:
1062         case SID_ALIGN_ANY_HCENTER:
1063         case SID_ALIGN_ANY_RIGHT:
1064         case SID_ALIGN_ANY_JUSTIFIED:
1065             pTabViewShell->ApplyAttr( SvxHorJustifyItem( lclConvertSlotToHAlign( nSlot ), ATTR_HOR_JUSTIFY ) );
1066         break;
1067         case SID_ALIGN_ANY_VDEFAULT:
1068         case SID_ALIGN_ANY_TOP:
1069         case SID_ALIGN_ANY_VCENTER:
1070         case SID_ALIGN_ANY_BOTTOM:
1071             pTabViewShell->ApplyAttr( SvxVerJustifyItem( lclConvertSlotToVAlign( nSlot ), ATTR_VER_JUSTIFY ) );
1072         break;
1073 
1074         default:
1075             if( pSet )
1076             {
1077                 const SfxPoolItem* pItem = NULL;
1078                 if( pSet->GetItemState(GetPool().GetWhich(nSlot), sal_True, &pItem  ) == SFX_ITEM_SET )
1079                 {
1080 
1081                     switch ( nSlot )
1082                     {
1083                         case SID_ATTR_ALIGN_HOR_JUSTIFY:
1084                         case SID_ATTR_ALIGN_VER_JUSTIFY:
1085                         case SID_ATTR_ALIGN_INDENT:
1086                         case SID_ATTR_ALIGN_HYPHENATION:
1087                         case SID_ATTR_ALIGN_DEGREES:
1088                         case SID_ATTR_ALIGN_LOCKPOS:
1089                         case SID_ATTR_ALIGN_MARGIN:
1090                         case SID_ATTR_ALIGN_STACKED:
1091                             pTabViewShell->ApplyAttr( *pItem );
1092                         break;
1093 
1094                         case SID_H_ALIGNCELL:
1095                         {
1096                             SvxCellHorJustify eJust = (SvxCellHorJustify)((const SvxHorJustifyItem*)pItem)->GetValue();
1097                             // #i78476# update alignment of text in cell edit mode
1098                             pTabViewShell->UpdateInputHandlerCellAdjust( eJust );
1099                             pTabViewShell->ApplyAttr( SvxHorJustifyItem( eJust, ATTR_HOR_JUSTIFY ) );
1100                         }
1101                         break;
1102                         case SID_V_ALIGNCELL:
1103                             pTabViewShell->ApplyAttr( SvxVerJustifyItem( (SvxCellVerJustify)((const SvxVerJustifyItem*)pItem)->GetValue(), ATTR_VER_JUSTIFY ) );
1104                         break;
1105                         default:
1106                             DBG_ERROR( "ExecuteAlignment: invalid slot" );
1107                             return;
1108                     }
1109                 }
1110             }
1111     }
1112 
1113     rBindings.Invalidate( SID_ALIGNLEFT );
1114     rBindings.Invalidate( SID_ALIGNRIGHT );
1115     rBindings.Invalidate( SID_ALIGNCENTERHOR );
1116     rBindings.Invalidate( SID_ALIGNBLOCK );
1117     rBindings.Invalidate( SID_ALIGNTOP );
1118     rBindings.Invalidate( SID_ALIGNBOTTOM );
1119     rBindings.Invalidate( SID_ALIGNCENTERVER );
1120     rBindings.Invalidate( SID_V_ALIGNCELL );
1121     rBindings.Invalidate( SID_H_ALIGNCELL );
1122     // pseudo slots for Format menu
1123     rBindings.Invalidate( SID_ALIGN_ANY_HDEFAULT );
1124     rBindings.Invalidate( SID_ALIGN_ANY_LEFT );
1125     rBindings.Invalidate( SID_ALIGN_ANY_HCENTER );
1126     rBindings.Invalidate( SID_ALIGN_ANY_RIGHT );
1127     rBindings.Invalidate( SID_ALIGN_ANY_JUSTIFIED );
1128     rBindings.Invalidate( SID_ALIGN_ANY_VDEFAULT );
1129     rBindings.Invalidate( SID_ALIGN_ANY_TOP );
1130     rBindings.Invalidate( SID_ALIGN_ANY_VCENTER );
1131     rBindings.Invalidate( SID_ALIGN_ANY_BOTTOM );
1132     rBindings.Update();
1133 
1134     if( ! rReq.IsAPI() )
1135         rReq.Done();
1136 }
1137 
1138 void ScFormatShell::ExecuteTextAttr( SfxRequest& rReq )
1139 {
1140 	ScTabViewShell*	pTabViewShell  		= GetViewData()->GetViewShell();
1141 	SfxBindings&			rBindings	= pViewData->GetBindings();
1142 	const ScPatternAttr*    pAttrs		= pTabViewShell->GetSelectionPattern();
1143 	const SfxItemSet*       pSet		= rReq.GetArgs();
1144 	sal_uInt16					nSlot		= rReq.GetSlot();
1145 	SfxAllItemSet*			pNewSet = 0;
1146 
1147 	pTabViewShell->HideListBox();					// Autofilter-DropDown-Listbox
1148 
1149 	if (  (nSlot == SID_ATTR_CHAR_WEIGHT)
1150 		||(nSlot == SID_ATTR_CHAR_POSTURE)
1151 		||(nSlot == SID_ATTR_CHAR_UNDERLINE)
1152 		||(nSlot == SID_ULINE_VAL_NONE)
1153 		||(nSlot == SID_ULINE_VAL_SINGLE)
1154 		||(nSlot == SID_ULINE_VAL_DOUBLE)
1155 		||(nSlot == SID_ULINE_VAL_DOTTED) )
1156 	{
1157 		pNewSet = new SfxAllItemSet( GetPool() );
1158 
1159 		switch ( nSlot )
1160 		{
1161 			case SID_ATTR_CHAR_WEIGHT:
1162 			{
1163 				// #i78017 establish the same behaviour as in Writer
1164 				sal_uInt8 nScript = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX;
1165 
1166 				SfxItemPool& rPool = GetPool();
1167 				SvxScriptSetItem aSetItem( nSlot, rPool );
1168 				if ( pSet )
1169 					aSetItem.PutItemForScriptType( nScript, pSet->Get( ATTR_FONT_WEIGHT ) );
1170 				else
1171 				{
1172 					//	toggle manually
1173 
1174 					FontWeight eWeight = WEIGHT_BOLD;
1175 					SvxScriptSetItem aOldSetItem( nSlot, rPool );
1176 					aOldSetItem.GetItemSet().Put( pAttrs->GetItemSet(), sal_False );
1177 					const SfxPoolItem* pCore = aOldSetItem.GetItemOfScript( nScript );
1178 					if ( pCore && ((const SvxWeightItem*)pCore)->GetWeight() == WEIGHT_BOLD )
1179 						eWeight = WEIGHT_NORMAL;
1180 
1181                     aSetItem.PutItemForScriptType( nScript, SvxWeightItem( eWeight, ATTR_FONT_WEIGHT ) );
1182 				}
1183 				pTabViewShell->ApplyUserItemSet( aSetItem.GetItemSet() );
1184 				pNewSet->Put( aSetItem.GetItemSet(), sal_False );
1185 			}
1186 			break;
1187 
1188 			case SID_ATTR_CHAR_POSTURE:
1189 			{
1190 				// #i78017 establish the same behaviour as in Writer
1191 				sal_uInt8 nScript = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX;
1192 
1193 				SfxItemPool& rPool = GetPool();
1194 				SvxScriptSetItem aSetItem( nSlot, rPool );
1195 				if ( pSet )
1196 					aSetItem.PutItemForScriptType( nScript, pSet->Get( ATTR_FONT_POSTURE ) );
1197 				else
1198 				{
1199 					//	toggle manually
1200 
1201 					FontItalic eItalic = ITALIC_NORMAL;
1202 					SvxScriptSetItem aOldSetItem( nSlot, rPool );
1203 					aOldSetItem.GetItemSet().Put( pAttrs->GetItemSet(), sal_False );
1204 					const SfxPoolItem* pCore = aOldSetItem.GetItemOfScript( nScript );
1205 					if ( pCore && ((const SvxPostureItem*)pCore)->GetPosture() == ITALIC_NORMAL )
1206 						eItalic = ITALIC_NONE;
1207 
1208                     aSetItem.PutItemForScriptType( nScript, SvxPostureItem( eItalic, ATTR_FONT_POSTURE ) );
1209 				}
1210 				pTabViewShell->ApplyUserItemSet( aSetItem.GetItemSet() );
1211 				pNewSet->Put( aSetItem.GetItemSet(), sal_False );
1212 			}
1213 			break;
1214 
1215 			case SID_ATTR_CHAR_UNDERLINE:
1216 				{
1217 					FontUnderline       eUnderline;
1218 
1219 					if( pSet )
1220 					{
1221                         const SfxPoolItem& rUnderline = pSet->Get( ATTR_FONT_UNDERLINE );
1222 
1223 						if( rUnderline.ISA(SvxUnderlineItem) )
1224 						{
1225 							pTabViewShell->ApplyAttr( rUnderline );
1226 							pNewSet->Put( rUnderline,rUnderline.Which() );
1227 						}
1228                         else if ( rUnderline.ISA(SvxTextLineItem) )
1229                         {
1230                             // #i106580# also allow SvxTextLineItem (base class of SvxUnderlineItem)
1231                             const SvxTextLineItem& rTextLineItem = static_cast<const SvxTextLineItem&>(rUnderline);
1232                             SvxUnderlineItem aNewItem( rTextLineItem.GetLineStyle(), rTextLineItem.Which() );
1233                             aNewItem.SetColor( rTextLineItem.GetColor() );
1234                             pTabViewShell->ApplyAttr( aNewItem );
1235                             pNewSet->Put( aNewItem, aNewItem.Which() );
1236                         }
1237 					}
1238 					else
1239 					{
1240 						SvxUnderlineItem aUnderline( (const SvxUnderlineItem&)
1241 														pAttrs->GetItem(
1242 															ATTR_FONT_UNDERLINE ) );
1243 						eUnderline = (UNDERLINE_NONE != aUnderline.GetLineStyle())
1244 									? UNDERLINE_NONE
1245 									: UNDERLINE_SINGLE;
1246 						aUnderline.SetLineStyle( eUnderline );
1247 						pTabViewShell->ApplyAttr( aUnderline );
1248 						pNewSet->Put( aUnderline,aUnderline.Which() );
1249 					}
1250 				}
1251 				break;
1252 
1253 			case SID_ULINE_VAL_NONE:
1254 				pTabViewShell->ApplyAttr( SvxUnderlineItem( UNDERLINE_NONE, ATTR_FONT_UNDERLINE ) );
1255 				break;
1256 			case SID_ULINE_VAL_SINGLE:		// Toggles
1257 			case SID_ULINE_VAL_DOUBLE:
1258 			case SID_ULINE_VAL_DOTTED:
1259 				{
1260 					FontUnderline eOld = ((const SvxUnderlineItem&)
1261 											pAttrs->GetItem(ATTR_FONT_UNDERLINE)).GetLineStyle();
1262 					FontUnderline eNew = eOld;
1263 					switch (nSlot)
1264 					{
1265 						case SID_ULINE_VAL_SINGLE:
1266 							eNew = ( eOld == UNDERLINE_SINGLE ) ? UNDERLINE_NONE : UNDERLINE_SINGLE;
1267 							break;
1268 						case SID_ULINE_VAL_DOUBLE:
1269 							eNew = ( eOld == UNDERLINE_DOUBLE ) ? UNDERLINE_NONE : UNDERLINE_DOUBLE;
1270 							break;
1271 						case SID_ULINE_VAL_DOTTED:
1272 							eNew = ( eOld == UNDERLINE_DOTTED ) ? UNDERLINE_NONE : UNDERLINE_DOTTED;
1273 							break;
1274 					}
1275 					pTabViewShell->ApplyAttr( SvxUnderlineItem( eNew, ATTR_FONT_UNDERLINE ) );
1276 				}
1277 				break;
1278 
1279 			default:
1280 				break;
1281 		}
1282 		rBindings.Invalidate( nSlot );
1283 	}
1284 	else
1285 	{
1286 		/*
1287 		 * "Selbstgemachte" RadioButton-Funktionalitaet
1288 		 * Beim Toggle gibt es den Standard-State, d.h. kein
1289 		 * Button ist gedrueckt
1290 		 */
1291 
1292 		const SfxItemSet&		 rAttrSet	= pTabViewShell->GetSelectionPattern()->GetItemSet();
1293 		const SfxPoolItem*       pItem       = NULL;
1294 		const SvxHorJustifyItem* pHorJustify = NULL;
1295 		const SvxVerJustifyItem* pVerJustify = NULL;
1296 		SvxCellHorJustify        eHorJustify = SVX_HOR_JUSTIFY_STANDARD;
1297 		SvxCellVerJustify        eVerJustify = SVX_VER_JUSTIFY_STANDARD;
1298 
1299 		if (rAttrSet.GetItemState(ATTR_HOR_JUSTIFY, sal_True,&pItem ) == SFX_ITEM_SET)
1300 		{
1301 			pHorJustify = (const SvxHorJustifyItem*)pItem;
1302 			eHorJustify = SvxCellHorJustify( pHorJustify->GetValue() );
1303 		}
1304 		if (rAttrSet.GetItemState(ATTR_VER_JUSTIFY, sal_True,&pItem ) == SFX_ITEM_SET)
1305 		{
1306 			pVerJustify = (const SvxVerJustifyItem*)pItem;
1307 			eVerJustify = SvxCellVerJustify( pVerJustify->GetValue() );
1308 		}
1309 
1310 		switch ( nSlot )
1311 		{
1312 			case SID_ALIGNLEFT:
1313 				rReq.SetSlot( SID_H_ALIGNCELL );
1314 				rReq.AppendItem( SvxHorJustifyItem(
1315 					!pHorJustify || (eHorJustify != SVX_HOR_JUSTIFY_LEFT) ?
1316 					SVX_HOR_JUSTIFY_LEFT : SVX_HOR_JUSTIFY_STANDARD, SID_H_ALIGNCELL ) );
1317 				ExecuteSlot( rReq, GetInterface() );
1318 				return;
1319 //				APPLY_HOR_JUSTIFY( SVX_HOR_JUSTIFY_LEFT );
1320                 //break;
1321 
1322 			case SID_ALIGNRIGHT:
1323 				rReq.SetSlot( SID_H_ALIGNCELL );
1324 				rReq.AppendItem( SvxHorJustifyItem(
1325 					!pHorJustify || (eHorJustify != SVX_HOR_JUSTIFY_RIGHT) ?
1326 					SVX_HOR_JUSTIFY_RIGHT : SVX_HOR_JUSTIFY_STANDARD, SID_H_ALIGNCELL ) );
1327 				ExecuteSlot( rReq, GetInterface() );
1328 				return;
1329 //				APPLY_HOR_JUSTIFY( SVX_HOR_JUSTIFY_RIGHT );
1330                 //break;
1331 
1332 			case SID_ALIGNCENTERHOR:
1333 				rReq.SetSlot( SID_H_ALIGNCELL );
1334 				rReq.AppendItem( SvxHorJustifyItem(
1335 					!pHorJustify || (eHorJustify != SVX_HOR_JUSTIFY_CENTER) ?
1336 					SVX_HOR_JUSTIFY_CENTER : SVX_HOR_JUSTIFY_STANDARD, SID_H_ALIGNCELL ) );
1337 				ExecuteSlot( rReq, GetInterface() );
1338 				return;
1339 //				APPLY_HOR_JUSTIFY( SVX_HOR_JUSTIFY_CENTER );
1340                 //break;
1341 
1342 			case SID_ALIGNBLOCK:
1343 				rReq.SetSlot( SID_H_ALIGNCELL );
1344 				rReq.AppendItem( SvxHorJustifyItem(
1345 					!pHorJustify || (eHorJustify != SVX_HOR_JUSTIFY_BLOCK) ?
1346 					SVX_HOR_JUSTIFY_BLOCK : SVX_HOR_JUSTIFY_STANDARD, SID_H_ALIGNCELL ) );
1347 				ExecuteSlot( rReq, GetInterface() );
1348 				return;
1349 //				APPLY_HOR_JUSTIFY( SVX_HOR_JUSTIFY_BLOCK );
1350                 //break;
1351 
1352 			case SID_ALIGNTOP:
1353 				rReq.SetSlot( SID_V_ALIGNCELL );
1354 				rReq.AppendItem( SvxVerJustifyItem(
1355 					!pVerJustify || (eVerJustify != SVX_VER_JUSTIFY_TOP) ?
1356 					SVX_VER_JUSTIFY_TOP : SVX_VER_JUSTIFY_STANDARD, SID_V_ALIGNCELL ) );
1357 				ExecuteSlot( rReq, GetInterface() );
1358 				return;
1359 //				APPLY_VER_JUSTIFY( SVX_VER_JUSTIFY_TOP );
1360                 //break;
1361 
1362 			case SID_ALIGNBOTTOM:
1363 				rReq.SetSlot( SID_V_ALIGNCELL );
1364 				rReq.AppendItem( SvxVerJustifyItem(
1365 					!pVerJustify || (eVerJustify != SVX_VER_JUSTIFY_BOTTOM) ?
1366 					SVX_VER_JUSTIFY_BOTTOM : SVX_VER_JUSTIFY_STANDARD, SID_V_ALIGNCELL ) );
1367 				ExecuteSlot( rReq, GetInterface() );
1368 				return;
1369 //				APPLY_VER_JUSTIFY( SVX_VER_JUSTIFY_BOTTOM );
1370                 //break;
1371 
1372 			case SID_ALIGNCENTERVER:
1373 				rReq.SetSlot( SID_V_ALIGNCELL );
1374 				rReq.AppendItem( SvxVerJustifyItem(
1375 					!pVerJustify || (eVerJustify != SVX_VER_JUSTIFY_CENTER) ?
1376 					SVX_VER_JUSTIFY_CENTER : SVX_VER_JUSTIFY_STANDARD, SID_V_ALIGNCELL ) );
1377 				ExecuteSlot( rReq, GetInterface() );
1378 				return;
1379 //				APPLY_VER_JUSTIFY( SVX_VER_JUSTIFY_CENTER );
1380                 //break;
1381 
1382 			default:
1383 			break;
1384 		}
1385 
1386 	}
1387 
1388 	rBindings.Update();
1389 //	rReq.Done();
1390 
1391 	if( pNewSet )
1392 	{
1393 		rReq.Done( *pNewSet );
1394 		delete pNewSet;
1395 	}
1396 	else
1397 	{
1398 		rReq.Done();
1399 	}
1400 
1401 }
1402 
1403 #undef APPLY_HOR_JUSTIFY
1404 #undef APPLY_VER_JUSTIFY
1405 
1406 //------------------------------------------------------------------
1407 
1408 void ScFormatShell::ExecuteAttr( SfxRequest& rReq )
1409 {
1410 	ScTabViewShell*	pTabViewShell  		= GetViewData()->GetViewShell();
1411 	SfxBindings&		rBindings = pViewData->GetBindings();
1412 	const SfxItemSet*	pNewAttrs = rReq.GetArgs();
1413 
1414 	pTabViewShell->HideListBox();					// Autofilter-DropDown-Listbox
1415 
1416 	if ( !pNewAttrs )
1417 	{
1418 		sal_uInt16 nSlot = rReq.GetSlot();
1419 
1420 		switch ( nSlot )
1421 		{
1422 			case SID_ATTR_CHAR_FONT:
1423 			case SID_ATTR_CHAR_FONTHEIGHT:
1424 				pTabViewShell->ExecuteCellFormatDlg( rReq, TP_FONT );	    // wenn ToolBar vertikal
1425 				break;
1426 
1427 			case SID_ATTR_ALIGN_LINEBREAK:					// ohne Parameter als Toggle
1428 				{
1429 					const ScPatternAttr* pAttrs = pTabViewShell->GetSelectionPattern();
1430 					sal_Bool bOld = ((const SfxBoolItem&)pAttrs->GetItem(ATTR_LINEBREAK)).GetValue();
1431 					SfxBoolItem aBreakItem( ATTR_LINEBREAK, !bOld );
1432 					pTabViewShell->ApplyAttr( aBreakItem );
1433 
1434 					SfxAllItemSet aNewSet( GetPool() );
1435 					aNewSet.Put( aBreakItem,aBreakItem.Which() );
1436 					rReq.Done( aNewSet );
1437 
1438 					rBindings.Invalidate( nSlot );
1439 				}
1440 				break;
1441 
1442 			case SID_BACKGROUND_COLOR:
1443 				{
1444 					//	SID_BACKGROUND_COLOR without arguments -> set transparent background
1445 
1446 					SvxBrushItem        aBrushItem( (const SvxBrushItem&)
1447 											pTabViewShell->GetSelectionPattern()->
1448 												GetItem( ATTR_BACKGROUND ) );
1449 
1450 					aBrushItem.SetColor( COL_TRANSPARENT );
1451 
1452 					pTabViewShell->ApplyAttr( aBrushItem );
1453 				}
1454 				break;
1455 		}
1456 	}
1457 	else
1458 	{
1459 		sal_uInt16 nSlot = rReq.GetSlot();
1460 
1461 		switch ( nSlot )
1462 		{
1463             case SID_ATTR_CHAR_OVERLINE:
1464             case SID_ATTR_CHAR_STRIKEOUT:
1465 			case SID_ATTR_ALIGN_LINEBREAK:
1466 			case SID_ATTR_CHAR_COLOR:
1467             case SID_ATTR_CHAR_CONTOUR:
1468             case SID_ATTR_CHAR_SHADOWED:
1469             case SID_ATTR_CHAR_RELIEF:
1470             case SID_SCATTR_PROTECTION :
1471 				pTabViewShell->ApplyAttr( pNewAttrs->Get( pNewAttrs->GetPool()->GetWhich( nSlot ) ) );
1472 				rBindings.Invalidate( nSlot );
1473 				rBindings.Update( nSlot );
1474 				break;
1475 
1476 			case SID_ATTR_CHAR_FONT:
1477 			case SID_ATTR_CHAR_FONTHEIGHT:
1478 				{
1479 					// #i78017 establish the same behaviour as in Writer
1480 					sal_uInt8 nScript = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX;
1481 					if (nSlot == SID_ATTR_CHAR_FONT)
1482 						nScript = pTabViewShell->GetSelectionScriptType();
1483 
1484 					SfxItemPool& rPool = GetPool();
1485 					SvxScriptSetItem aSetItem( nSlot, rPool );
1486 					sal_uInt16 nWhich = rPool.GetWhich( nSlot );
1487 					aSetItem.PutItemForScriptType( nScript, pNewAttrs->Get( nWhich ) );
1488 
1489 					pTabViewShell->ApplyUserItemSet( aSetItem.GetItemSet() );
1490 
1491 					rBindings.Invalidate( nSlot );
1492 					rBindings.Update( nSlot );
1493 				}
1494 				break;
1495 
1496 			case SID_FRAME_LINESTYLE:
1497 				{
1498 					// Default-Linie aktualisieren
1499 					const SvxBorderLine* pLine =
1500 							((const SvxLineItem&)
1501 								pNewAttrs->Get( SID_FRAME_LINESTYLE )).
1502 								GetLine();
1503 
1504 					if ( pLine )
1505 					{
1506 						SvxBorderLine* pDefLine = pTabViewShell->GetDefaultFrameLine();
1507 
1508 						if ( pDefLine )
1509 						{
1510 							pDefLine->SetOutWidth( pLine->GetOutWidth() );
1511 							pDefLine->SetInWidth ( pLine->GetInWidth() );
1512 							pDefLine->SetDistance( pLine->GetDistance() );
1513 							pTabViewShell->SetSelectionFrameLines( pDefLine, sal_False );
1514 						}
1515 						else
1516 						{
1517 							pTabViewShell->SetDefaultFrameLine( pLine );
1518 							pTabViewShell->GetDefaultFrameLine()->SetColor( COL_BLACK );
1519 							pTabViewShell->SetSelectionFrameLines( pLine, sal_False );
1520 						}
1521 					}
1522 					else
1523 					{
1524 						Color           aColorBlack( COL_BLACK );
1525 						SvxBorderLine   aDefLine( &aColorBlack, 20, 0, 0 );
1526 						pTabViewShell->SetDefaultFrameLine( &aDefLine );
1527 						pTabViewShell->SetSelectionFrameLines( NULL, sal_False );
1528 					}
1529 				}
1530 				break;
1531 
1532 			case SID_FRAME_LINECOLOR:
1533 				{
1534 					SvxBorderLine*  pDefLine = pTabViewShell->GetDefaultFrameLine();
1535 					const Color&    rColor = ((const SvxColorItem&)
1536 										pNewAttrs->Get( SID_FRAME_LINECOLOR )).
1537 											GetValue();
1538 
1539 					// Default-Linie aktualisieren
1540 					if ( pDefLine )
1541 					{
1542 						pDefLine->SetColor( rColor );
1543 						pTabViewShell->SetSelectionFrameLines( pDefLine, sal_True );
1544 					}
1545 					else
1546 					{
1547 						SvxBorderLine   aDefLine( &rColor, 20, 0, 0 );
1548 						pTabViewShell->SetDefaultFrameLine( &aDefLine );
1549 						pTabViewShell->SetSelectionFrameLines( &aDefLine, sal_False );
1550 					}
1551 				}
1552 				break;
1553 
1554 			case SID_ATTR_BORDER_OUTER:
1555 			case SID_ATTR_BORDER:
1556 				{
1557 					SvxBorderLine*          pDefLine = pTabViewShell->GetDefaultFrameLine();
1558 					const ScPatternAttr*    pOldAttrs = pTabViewShell->GetSelectionPattern();
1559 					ScDocument*             pDoc = GetViewData()->GetDocument();
1560 					SfxItemSet*             pOldSet =
1561 												new SfxItemSet(
1562 														*(pDoc->GetPool()),
1563 														ATTR_PATTERN_START,
1564 														ATTR_PATTERN_END );
1565 					SfxItemSet*             pNewSet =
1566 												new SfxItemSet(
1567 														*(pDoc->GetPool()),
1568 														ATTR_PATTERN_START,
1569 														ATTR_PATTERN_END );
1570 					const SfxPoolItem&      rBorderAttr =
1571 												pOldAttrs->GetItemSet().
1572 													Get( ATTR_BORDER );
1573 
1574 					// Border-Items vom Controller auswerten:
1575 					const SfxPoolItem* pItem = 0;
1576 
1577 					if ( pNewAttrs->GetItemState( ATTR_BORDER, sal_True, &pItem )
1578 						 == SFX_ITEM_SET )
1579 					{
1580 						//	#100959# The SvxFrameToolBoxControl toolbox controller uses a default
1581 						//	SvxBorderLine (all widths 0) to mark the lines that should be set.
1582 						//	Macro recording uses a SvxBoxItem with the real values (OutWidth > 0)
1583 						//	or NULL pointers for no lines.
1584 						//	-> Substitute existing lines with pDefLine only if widths are 0.
1585 						SvxBoxItem aBoxItem ( *(const SvxBoxItem*)pItem );
1586 						if ( aBoxItem.GetTop() && aBoxItem.GetTop()->GetOutWidth() == 0 )
1587 							aBoxItem.SetLine( pDefLine, BOX_LINE_TOP );
1588 						if ( aBoxItem.GetBottom() && aBoxItem.GetBottom()->GetOutWidth() == 0 )
1589 							aBoxItem.SetLine( pDefLine, BOX_LINE_BOTTOM );
1590 						if ( aBoxItem.GetLeft() && aBoxItem.GetLeft()->GetOutWidth() == 0 )
1591 							aBoxItem.SetLine( pDefLine, BOX_LINE_LEFT );
1592 						if ( aBoxItem.GetRight() && aBoxItem.GetRight()->GetOutWidth() == 0 )
1593 							aBoxItem.SetLine( pDefLine, BOX_LINE_RIGHT );
1594 						pNewSet->Put( aBoxItem );
1595                         rReq.AppendItem( aBoxItem );
1596 					}
1597 
1598 					if ( pNewAttrs->GetItemState( ATTR_BORDER_INNER, sal_True, &pItem )
1599 						 == SFX_ITEM_SET )
1600 					{
1601 						SvxBoxInfoItem aBoxInfoItem( *(const SvxBoxInfoItem*)pItem );
1602 						if ( aBoxInfoItem.GetHori() && aBoxInfoItem.GetHori()->GetOutWidth() == 0 )
1603 							aBoxInfoItem.SetLine( pDefLine, BOXINFO_LINE_HORI );
1604 						if ( aBoxInfoItem.GetVert() && aBoxInfoItem.GetVert()->GetOutWidth() == 0 )
1605 							aBoxInfoItem.SetLine( pDefLine, BOXINFO_LINE_VERT );
1606 						pNewSet->Put( aBoxInfoItem );
1607                         rReq.AppendItem( aBoxInfoItem );
1608 					}
1609 					else
1610 					{
1611 						SvxBoxInfoItem aBoxInfoItem( ATTR_BORDER_INNER );
1612 						aBoxInfoItem.SetLine( NULL, BOXINFO_LINE_HORI );
1613 						aBoxInfoItem.SetLine( NULL, BOXINFO_LINE_VERT );
1614 						pNewSet->Put( aBoxInfoItem );
1615 					}
1616 
1617 					pOldSet->Put( rBorderAttr );
1618 					pTabViewShell->ApplyAttributes( pNewSet, pOldSet );
1619 
1620 					delete pOldSet;
1621 					delete pNewSet;
1622 				}
1623 				break;
1624 
1625 			// ATTR_BACKGROUND (=SID_ATTR_BRUSH) muss ueber zwei IDs
1626 			// gesetzt werden:
1627 			case SID_BACKGROUND_COLOR:
1628 				{
1629 					const SvxColorItem  rNewColorItem = (const SvxColorItem&)
1630 											pNewAttrs->Get( SID_BACKGROUND_COLOR );
1631 
1632 					SvxBrushItem        aBrushItem( (const SvxBrushItem&)
1633 											pTabViewShell->GetSelectionPattern()->
1634 												GetItem( ATTR_BACKGROUND ) );
1635 
1636 					aBrushItem.SetColor( rNewColorItem.GetValue() );
1637 
1638 					pTabViewShell->ApplyAttr( aBrushItem );
1639 				}
1640 				break;
1641 
1642 				case SID_ATTR_BRUSH:
1643 				{
1644 					SvxBrushItem        aBrushItem( (const SvxBrushItem&)
1645 											pTabViewShell->GetSelectionPattern()->
1646 												GetItem( ATTR_BACKGROUND ) );
1647 					const SvxBrushItem& rNewBrushItem = (const SvxBrushItem&)
1648 											pNewAttrs->Get( GetPool().GetWhich(nSlot) );
1649 					aBrushItem.SetColor(rNewBrushItem.GetColor());
1650 					pTabViewShell->ApplyAttr( aBrushItem );
1651 				}
1652 				break;
1653 
1654 			case SID_ATTR_BORDER_SHADOW:
1655 				{
1656 					const SvxShadowItem& rNewShadowItem = (const SvxShadowItem&)
1657 											pNewAttrs->Get( ATTR_SHADOW );
1658 					pTabViewShell->ApplyAttr( rNewShadowItem );
1659 				}
1660 				break;
1661 
1662 			default:
1663 			break;
1664 		}
1665 
1666 		if( ! rReq.IsAPI() )
1667 			if( ! rReq.IsDone() )
1668 				rReq.Done();
1669 	}
1670 }
1671 
1672 void ScFormatShell::GetAttrState( SfxItemSet& rSet )
1673 {
1674 	ScTabViewShell*	pTabViewShell  	= GetViewData()->GetViewShell();
1675 	const SfxItemSet&	 rAttrSet	= pTabViewShell->GetSelectionPattern()->GetItemSet();
1676 	const SvxBorderLine* pLine      = pTabViewShell->GetDefaultFrameLine();
1677 	const SvxBrushItem&  rBrushItem = (const SvxBrushItem&)rAttrSet.Get( ATTR_BACKGROUND );
1678 	SfxWhichIter aIter( rSet );
1679 	sal_uInt16 nWhich = aIter.FirstWhich();
1680 
1681 	rSet.Put( rAttrSet, sal_False );
1682 
1683 	//	choose font info according to selection script type
1684 	sal_uInt8 nScript = 0;		// GetSelectionScriptType never returns 0
1685 	if ( rSet.GetItemState( ATTR_FONT ) != SFX_ITEM_UNKNOWN )
1686 	{
1687 		if (!nScript) nScript = pTabViewShell->GetSelectionScriptType();
1688 		ScViewUtil::PutItemScript( rSet, rAttrSet, ATTR_FONT, nScript );
1689 	}
1690 	if ( rSet.GetItemState( ATTR_FONT_HEIGHT ) != SFX_ITEM_UNKNOWN )
1691 	{
1692 		if (!nScript) nScript = pTabViewShell->GetSelectionScriptType();
1693 		ScViewUtil::PutItemScript( rSet, rAttrSet, ATTR_FONT_HEIGHT, nScript );
1694 	}
1695 
1696 	while ( nWhich )
1697 	{
1698 		switch(nWhich)
1699 		{
1700 			case SID_BACKGROUND_COLOR:
1701 			{
1702                 rSet.Put( SvxColorItem( rBrushItem.GetColor(), SID_BACKGROUND_COLOR ) );
1703 			}
1704 			break;
1705 			case SID_FRAME_LINECOLOR:
1706 			{
1707                 rSet.Put( SvxColorItem( pLine ? pLine->GetColor() : Color(), SID_FRAME_LINECOLOR ) );
1708 			}
1709 			break;
1710 			case SID_ATTR_BRUSH:
1711 			{
1712 				rSet.Put( rBrushItem, GetPool().GetWhich(nWhich) );
1713 			}
1714 			break;
1715 /*			case SID_ATTR_ALIGN_LINEBREAK:
1716 			{
1717 				const SfxBoolItem& rBreakItem = (const SfxBoolItem&)rAttrSet.Get( ATTR_LINEBREAK );
1718 				rSet.Put( rBreakItem, GetPool().GetWhich(nWhich) );
1719 			}
1720 			break;
1721 */
1722 		}
1723 		nWhich = aIter.NextWhich();
1724 	}
1725 }
1726 
1727 //------------------------------------------------------------------
1728 
1729 void ScFormatShell::GetTextAttrState( SfxItemSet& rSet )
1730 {
1731 	ScTabViewShell*	pTabViewShell  	= GetViewData()->GetViewShell();
1732 	const SfxItemSet& rAttrSet	= pTabViewShell->GetSelectionPattern()->GetItemSet();
1733 	rSet.Put( rAttrSet, sal_False ); // ItemStates mitkopieren
1734 
1735 	//	choose font info according to selection script type
1736 	sal_uInt8 nScript = 0;		// GetSelectionScriptType never returns 0
1737 	if ( rSet.GetItemState( ATTR_FONT_WEIGHT ) != SFX_ITEM_UNKNOWN )
1738 	{
1739 		if (!nScript) nScript = pTabViewShell->GetSelectionScriptType();
1740 		ScViewUtil::PutItemScript( rSet, rAttrSet, ATTR_FONT_WEIGHT, nScript );
1741 	}
1742 	if ( rSet.GetItemState( ATTR_FONT_POSTURE ) != SFX_ITEM_UNKNOWN )
1743 	{
1744 		if (!nScript) nScript = pTabViewShell->GetSelectionScriptType();
1745 		ScViewUtil::PutItemScript( rSet, rAttrSet, ATTR_FONT_POSTURE, nScript );
1746 	}
1747 
1748 	SfxItemState eState;
1749 //	const SfxPoolItem* pItem;
1750 
1751 	//--------------------------------------------------------------------
1752 	// eigene Kontrolle ueber RadioButton-Funktionalitaet:
1753 	//--------------------------------------------------------------------
1754 	// Unterstreichung
1755 	//------------------------
1756 
1757 	eState = rAttrSet.GetItemState( ATTR_FONT_UNDERLINE, sal_True );
1758 	if ( eState == SFX_ITEM_DONTCARE )
1759 	{
1760 		rSet.InvalidateItem( SID_ULINE_VAL_NONE );
1761 		rSet.InvalidateItem( SID_ULINE_VAL_SINGLE );
1762 		rSet.InvalidateItem( SID_ULINE_VAL_DOUBLE );
1763 		rSet.InvalidateItem( SID_ULINE_VAL_DOTTED );
1764 	}
1765 	else
1766 	{
1767 		FontUnderline eUnderline = ((const SvxUnderlineItem&)
1768 					rAttrSet.Get(ATTR_FONT_UNDERLINE)).GetLineStyle();
1769 		sal_uInt16 nId = SID_ULINE_VAL_NONE;
1770 		switch (eUnderline)
1771 		{
1772 			case UNDERLINE_SINGLE:	nId = SID_ULINE_VAL_SINGLE;	break;
1773 			case UNDERLINE_DOUBLE:	nId = SID_ULINE_VAL_DOUBLE;	break;
1774 			case UNDERLINE_DOTTED:	nId = SID_ULINE_VAL_DOTTED;	break;
1775 			default:
1776 				break;
1777 		}
1778 		rSet.Put( SfxBoolItem( nId, sal_True ) );
1779 	}
1780 
1781 	//------------------------
1782 	// horizontale Ausrichtung
1783 	//------------------------
1784 
1785 	const SvxHorJustifyItem* pHorJustify = NULL;
1786 	const SvxVerJustifyItem* pVerJustify = NULL;
1787 	SvxCellHorJustify        eHorJustify = SVX_HOR_JUSTIFY_STANDARD;
1788 	SvxCellVerJustify        eVerJustify = SVX_VER_JUSTIFY_STANDARD;
1789 	sal_uInt16		 			 nWhich		 = 0;
1790 	sal_Bool					 bJustifyStd = sal_False;
1791 	SfxBoolItem				 aBoolItem	 ( 0, sal_True );
1792 
1793 	eState 	 = rAttrSet.GetItemState( ATTR_HOR_JUSTIFY, sal_True,
1794 										(const SfxPoolItem**)&pHorJustify );
1795 	switch ( eState )
1796 	{
1797 		case SFX_ITEM_SET:
1798 			{
1799 				eHorJustify = SvxCellHorJustify( pHorJustify->GetValue() );
1800 
1801 				switch ( SvxCellHorJustify( pHorJustify->GetValue() ) )
1802 				{
1803 					case SVX_HOR_JUSTIFY_STANDARD:
1804 						break;
1805 
1806 					case SVX_HOR_JUSTIFY_LEFT:
1807 						nWhich = SID_ALIGNLEFT;
1808 						break;
1809 
1810 					case SVX_HOR_JUSTIFY_RIGHT:
1811 						nWhich = SID_ALIGNRIGHT;
1812 						break;
1813 
1814 					case SVX_HOR_JUSTIFY_CENTER:
1815 						nWhich = SID_ALIGNCENTERHOR;
1816 						break;
1817 
1818 					case SVX_HOR_JUSTIFY_BLOCK:
1819 						nWhich = SID_ALIGNBLOCK;
1820 						break;
1821 
1822 					case SVX_HOR_JUSTIFY_REPEAT:
1823 					default:
1824 						bJustifyStd = sal_True;
1825 						break;
1826 				}
1827 			}
1828 			break;
1829 
1830 		case SFX_ITEM_DONTCARE:
1831 			rSet.InvalidateItem( SID_ALIGNLEFT );
1832 			rSet.InvalidateItem( SID_ALIGNRIGHT );
1833 			rSet.InvalidateItem( SID_ALIGNCENTERHOR );
1834 			rSet.InvalidateItem( SID_ALIGNBLOCK );
1835 			break;
1836 
1837 		default:
1838 			bJustifyStd = sal_True;
1839 			break;
1840 	}
1841 
1842 	if ( nWhich )
1843 	{
1844 		aBoolItem.SetWhich( nWhich );
1845 		rSet.Put( aBoolItem );
1846 	}
1847 	else if ( bJustifyStd )
1848 	{
1849 		aBoolItem.SetValue( sal_False );
1850 		aBoolItem.SetWhich( SID_ALIGNLEFT );	  rSet.Put( aBoolItem );
1851 		aBoolItem.SetWhich( SID_ALIGNRIGHT );	  rSet.Put( aBoolItem );
1852 		aBoolItem.SetWhich( SID_ALIGNCENTERHOR ); rSet.Put( aBoolItem );
1853 		aBoolItem.SetWhich( SID_ALIGNBLOCK );	  rSet.Put( aBoolItem );
1854 		bJustifyStd = sal_False;
1855 	}
1856 
1857 	//------------------------
1858 	// vertikale Ausrichtung
1859 	//------------------------
1860 
1861 	nWhich = 0;
1862 	aBoolItem.SetValue( sal_True );
1863 
1864 	eState = rAttrSet.GetItemState( ATTR_VER_JUSTIFY, sal_True,
1865 									(const SfxPoolItem**)&pVerJustify );
1866 
1867 	switch ( eState )
1868 	{
1869 		case SFX_ITEM_SET:
1870 			{
1871 				eVerJustify = SvxCellVerJustify( pVerJustify->GetValue() );
1872 
1873 				switch ( eVerJustify )
1874 				{
1875 					case SVX_VER_JUSTIFY_TOP:
1876 						nWhich = SID_ALIGNTOP;
1877 						break;
1878 
1879 					case SVX_VER_JUSTIFY_BOTTOM:
1880 						nWhich = SID_ALIGNBOTTOM;
1881 						break;
1882 
1883 					case SVX_VER_JUSTIFY_CENTER:
1884 						nWhich = SID_ALIGNCENTERVER;
1885 						break;
1886 
1887 					case SVX_VER_JUSTIFY_STANDARD:
1888 					default:
1889 						bJustifyStd = sal_True;
1890 						break;
1891 				}
1892 			}
1893 			break;
1894 
1895 		case SFX_ITEM_DONTCARE:
1896 			rSet.InvalidateItem( SID_ALIGNTOP );
1897 			rSet.InvalidateItem( SID_ALIGNBOTTOM );
1898 			rSet.InvalidateItem( SID_ALIGNCENTERVER );
1899 			break;
1900 
1901 		default:
1902 			bJustifyStd = sal_True;
1903 			break;
1904 	}
1905 
1906 	if ( nWhich )
1907 	{
1908 		aBoolItem.SetWhich( nWhich );
1909 		rSet.Put( aBoolItem );
1910 	}
1911 	else if ( bJustifyStd )
1912 	{
1913 		aBoolItem.SetValue( sal_False );
1914 		aBoolItem.SetWhich( SID_ALIGNTOP );	  	  rSet.Put( aBoolItem );
1915 		aBoolItem.SetWhich( SID_ALIGNBOTTOM );	  rSet.Put( aBoolItem );
1916 		aBoolItem.SetWhich( SID_ALIGNCENTERVER ); rSet.Put( aBoolItem );
1917 	}
1918 }
1919 
1920 
1921 //------------------------------------------------------------------
1922 
1923 void ScFormatShell::GetBorderState( SfxItemSet& rSet )
1924 {
1925 	ScTabViewShell*	pTabViewShell  	= GetViewData()->GetViewShell();
1926 	SvxBoxItem		aBoxItem( ATTR_BORDER );
1927 	SvxBoxInfoItem	aInfoItem( ATTR_BORDER_INNER );
1928 
1929 	pTabViewShell->GetSelectionFrame( aBoxItem, aInfoItem );
1930 
1931 	if ( rSet.GetItemState( ATTR_BORDER ) != SFX_ITEM_UNKNOWN )
1932 		rSet.Put( aBoxItem );
1933 	if ( rSet.GetItemState( ATTR_BORDER_INNER ) != SFX_ITEM_UNKNOWN )
1934 		rSet.Put( aInfoItem );
1935 }
1936 
1937 //------------------------------------------------------------------
1938 
1939 void ScFormatShell::GetAlignState( SfxItemSet& rSet )
1940 {
1941 	ScTabViewShell*	pTabViewShell  	= GetViewData()->GetViewShell();
1942 	const SfxItemSet& rAttrSet    = pTabViewShell->GetSelectionPattern()->GetItemSet();
1943 	SfxWhichIter	aIter(rSet);
1944 	sal_uInt16			nWhich = aIter.FirstWhich();
1945 
1946     SvxCellHorJustify eHAlign = SVX_HOR_JUSTIFY_STANDARD;
1947     bool bHasHAlign = rAttrSet.GetItemState( ATTR_HOR_JUSTIFY ) != SFX_ITEM_DONTCARE;
1948     if( bHasHAlign )
1949         eHAlign = (SvxCellHorJustify)((const SvxHorJustifyItem&) rAttrSet.Get( ATTR_HOR_JUSTIFY )).GetValue();
1950 
1951     SvxCellVerJustify eVAlign = SVX_VER_JUSTIFY_STANDARD;
1952     bool bHasVAlign = rAttrSet.GetItemState( ATTR_VER_JUSTIFY ) != SFX_ITEM_DONTCARE;
1953     if( bHasVAlign )
1954         eVAlign = (SvxCellVerJustify)((const SvxVerJustifyItem&) rAttrSet.Get( ATTR_VER_JUSTIFY )).GetValue();
1955 
1956 	while ( nWhich )
1957 	{
1958 		switch ( nWhich )
1959 		{
1960 			case SID_H_ALIGNCELL:
1961                 if ( bHasHAlign )
1962                     rSet.Put( SvxHorJustifyItem( eHAlign, nWhich ));
1963 			break;
1964 			case SID_V_ALIGNCELL:
1965                 if ( bHasVAlign )
1966                     rSet.Put( SvxVerJustifyItem( eVAlign, nWhich ));
1967 			break;
1968 
1969             // pseudo slots for Format menu
1970             case SID_ALIGN_ANY_HDEFAULT:
1971             case SID_ALIGN_ANY_LEFT:
1972             case SID_ALIGN_ANY_HCENTER:
1973             case SID_ALIGN_ANY_RIGHT:
1974             case SID_ALIGN_ANY_JUSTIFIED:
1975                 rSet.Put( SfxBoolItem( nWhich, bHasHAlign && (eHAlign == lclConvertSlotToHAlign( nWhich )) ) );
1976             break;
1977             case SID_ALIGN_ANY_VDEFAULT:
1978             case SID_ALIGN_ANY_TOP:
1979             case SID_ALIGN_ANY_VCENTER:
1980             case SID_ALIGN_ANY_BOTTOM:
1981                 rSet.Put( SfxBoolItem( nWhich, bHasVAlign && (eVAlign == lclConvertSlotToVAlign( nWhich )) ) );
1982             break;
1983 		}
1984 		nWhich = aIter.NextWhich();
1985 	}
1986 }
1987 
1988 void ScFormatShell::GetNumFormatState( SfxItemSet& rSet )
1989 {
1990 	ScTabViewShell*	pTabViewShell  	= GetViewData()->GetViewShell();
1991 
1992     // ScViewData* pViewData   = GetViewData();
1993 	ScDocument* pDoc		= pViewData->GetDocument();
1994 
1995 	SfxWhichIter aIter(rSet);
1996 	sal_uInt16 nWhich = aIter.FirstWhich();
1997 	while ( nWhich )
1998 	{
1999 		switch ( nWhich )
2000 		{
2001 			case SID_NUMBER_FORMAT:
2002 				{
2003 					String aFormatCode;			// bleibt leer, wenn dont-care
2004 
2005 					const SfxItemSet& rAttrSet  = pTabViewShell->GetSelectionPattern()->GetItemSet();
2006 					if ( rAttrSet.GetItemState( ATTR_VALUE_FORMAT ) != SFX_ITEM_DONTCARE )
2007 					{
2008 						sal_uLong nNumberFormat = ((const SfxUInt32Item&)rAttrSet.Get(
2009 													ATTR_VALUE_FORMAT )).GetValue();
2010 
2011 						SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
2012 						const SvNumberformat* pFormatEntry = pFormatter->GetEntry( nNumberFormat );
2013 						if ( pFormatEntry )
2014 							aFormatCode = pFormatEntry->GetFormatstring();
2015 					}
2016 
2017 					rSet.Put( SfxStringItem( nWhich, aFormatCode ) );
2018 				}
2019 				break;
2020 
2021 		}
2022 		nWhich = aIter.NextWhich();
2023 	}
2024 }
2025 
2026 
2027 void ScFormatShell::ExecuteTextDirection( SfxRequest& rReq )
2028 {
2029     ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
2030     pTabViewShell->HideListBox();               // Autofilter-DropDown-Listbox
2031     if ( GetViewData()->HasEditView( GetViewData()->GetActivePart() ) )
2032     {
2033         SC_MOD()->InputEnterHandler();
2034         pTabViewShell->UpdateInputHandler();
2035     }
2036 
2037     sal_uInt16 nSlot = rReq.GetSlot();
2038     switch( nSlot )
2039     {
2040         case SID_TEXTDIRECTION_LEFT_TO_RIGHT:
2041         case SID_TEXTDIRECTION_TOP_TO_BOTTOM:
2042         {
2043             sal_Bool bVert = (nSlot == SID_TEXTDIRECTION_TOP_TO_BOTTOM);
2044             ScPatternAttr aAttr( GetViewData()->GetDocument()->GetPool() );
2045             SfxItemSet& rItemSet = aAttr.GetItemSet();
2046             rItemSet.Put( SfxBoolItem( ATTR_STACKED, bVert ) );
2047             rItemSet.Put( SfxBoolItem( ATTR_VERTICAL_ASIAN, bVert ) );
2048             pTabViewShell->ApplySelectionPattern( aAttr );
2049             pTabViewShell->AdjustBlockHeight();
2050         }
2051         break;
2052 
2053         case SID_ATTR_PARA_LEFT_TO_RIGHT:
2054         case SID_ATTR_PARA_RIGHT_TO_LEFT:
2055         {
2056             SvxFrameDirection eDirection = ( nSlot == SID_ATTR_PARA_LEFT_TO_RIGHT ) ?
2057                                                 FRMDIR_HORI_LEFT_TOP : FRMDIR_HORI_RIGHT_TOP;
2058             pTabViewShell->ApplyAttr( SvxFrameDirectionItem( eDirection, ATTR_WRITINGDIR ) );
2059         }
2060         break;
2061     }
2062 }
2063 
2064 void ScFormatShell::GetTextDirectionState( SfxItemSet& rSet )
2065 {
2066     ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
2067     const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet();
2068 
2069     sal_Bool bVertDontCare =
2070         (rAttrSet.GetItemState( ATTR_VERTICAL_ASIAN ) == SFX_ITEM_DONTCARE) ||
2071         (rAttrSet.GetItemState( ATTR_STACKED ) == SFX_ITEM_DONTCARE);
2072     sal_Bool bLeftRight = !bVertDontCare &&
2073         !((const SfxBoolItem&) rAttrSet.Get( ATTR_STACKED )).GetValue();
2074     sal_Bool bTopBottom = !bVertDontCare && !bLeftRight &&
2075         ((const SfxBoolItem&) rAttrSet.Get( ATTR_VERTICAL_ASIAN )).GetValue();
2076 
2077     sal_Bool bBidiDontCare = (rAttrSet.GetItemState( ATTR_WRITINGDIR ) == SFX_ITEM_DONTCARE);
2078     EEHorizontalTextDirection eBidiDir = EE_HTEXTDIR_DEFAULT;
2079     if ( !bBidiDontCare )
2080     {
2081         SvxFrameDirection eCellDir = (SvxFrameDirection)((const SvxFrameDirectionItem&)
2082                                         rAttrSet.Get( ATTR_WRITINGDIR )).GetValue();
2083         if ( eCellDir == FRMDIR_ENVIRONMENT )
2084             eBidiDir = (EEHorizontalTextDirection)GetViewData()->GetDocument()->
2085                                 GetEditTextDirection( GetViewData()->GetTabNo() );
2086         else if ( eCellDir == FRMDIR_HORI_RIGHT_TOP )
2087             eBidiDir = EE_HTEXTDIR_R2L;
2088         else
2089             eBidiDir = EE_HTEXTDIR_L2R;
2090     }
2091 
2092 	SvtLanguageOptions	aLangOpt;
2093 	sal_Bool bDisableCTLFont = !aLangOpt.IsCTLFontEnabled();
2094 	sal_Bool bDisableVerticalText = !aLangOpt.IsVerticalTextEnabled();
2095 
2096     SfxWhichIter aIter( rSet );
2097     sal_uInt16 nWhich = aIter.FirstWhich();
2098     while( nWhich )
2099     {
2100         switch( nWhich )
2101         {
2102             case SID_TEXTDIRECTION_LEFT_TO_RIGHT:
2103             case SID_TEXTDIRECTION_TOP_TO_BOTTOM:
2104                 if ( bDisableVerticalText )
2105 					rSet.DisableItem( nWhich );
2106 				else
2107 				{
2108 					if( bVertDontCare )
2109 						rSet.InvalidateItem( nWhich );
2110 					else if ( nWhich == SID_TEXTDIRECTION_LEFT_TO_RIGHT )
2111 						rSet.Put( SfxBoolItem( nWhich, bLeftRight ) );
2112 					else
2113 						rSet.Put( SfxBoolItem( nWhich, bTopBottom ) );
2114 				}
2115             break;
2116 
2117             case SID_ATTR_PARA_LEFT_TO_RIGHT:
2118             case SID_ATTR_PARA_RIGHT_TO_LEFT:
2119 				if ( bDisableCTLFont )
2120 					rSet.DisableItem( nWhich );
2121 				else
2122 				{
2123 					if ( bTopBottom )
2124 						rSet.DisableItem( nWhich );
2125 					else if ( bBidiDontCare )
2126 						rSet.InvalidateItem( nWhich );
2127 					else if ( nWhich == SID_ATTR_PARA_LEFT_TO_RIGHT )
2128 						rSet.Put( SfxBoolItem( nWhich, eBidiDir == EE_HTEXTDIR_L2R ) );
2129 					else
2130 						rSet.Put( SfxBoolItem( nWhich, eBidiDir == EE_HTEXTDIR_R2L ) );
2131 				}
2132         }
2133         nWhich = aIter.NextWhich();
2134     }
2135 }
2136 
2137 void ScFormatShell::ExecFormatPaintbrush( SfxRequest& rReq )
2138 {
2139     ScViewFunc* pView = pViewData->GetView();
2140     if ( pView->HasPaintBrush() )
2141     {
2142         // cancel paintbrush mode
2143         pView->ResetBrushDocument();
2144     }
2145     else
2146     {
2147         sal_Bool bLock = sal_False;
2148         const SfxItemSet *pArgs = rReq.GetArgs();
2149         if( pArgs && pArgs->Count() >= 1 )
2150             bLock = static_cast<const SfxBoolItem&>(pArgs->Get(SID_FORMATPAINTBRUSH)).GetValue();
2151 
2152         // in case of multi selection, deselect all and use the cursor position
2153         ScRange aDummy;
2154         if ( pViewData->GetSimpleArea(aDummy) != SC_MARK_SIMPLE )
2155             pView->Unmark();
2156 
2157         ScDocument* pBrushDoc = new ScDocument( SCDOCMODE_CLIP );
2158         pView->CopyToClip( pBrushDoc, sal_False, sal_True );
2159         pView->SetBrushDocument( pBrushDoc, bLock );
2160     }
2161 }
2162 
2163 void ScFormatShell::StateFormatPaintbrush( SfxItemSet& rSet )
2164 {
2165     if ( pViewData->HasEditView( pViewData->GetActivePart() ) )
2166         rSet.DisableItem( SID_FORMATPAINTBRUSH );
2167     else
2168         rSet.Put( SfxBoolItem( SID_FORMATPAINTBRUSH, pViewData->GetView()->HasPaintBrush() ) );
2169 }
2170 
2171