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