xref: /aoo41x/main/sc/source/ui/view/formatsh.cxx (revision 52d7ec27)
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 
lclConvertSlotToHAlign(sal_uInt16 nSlot)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 
lclConvertSlotToVAlign(sal_uInt16 nSlot)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 
SFX_IMPL_INTERFACE(ScFormatShell,SfxShell,ScResId (SCSTR_FORMATSHELL))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 
ScFormatShell(ScViewData * pData)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 
~ScFormatShell()167 ScFormatShell::~ScFormatShell()
168 {
169 }
170 
171 //------------------------------------------------------------------
172 
GetStyleState(SfxItemSet & rSet)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 
ExecuteStyle(SfxRequest & rReq)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 
ExecuteNumFormat(SfxRequest & rReq)915 void ScFormatShell::ExecuteNumFormat( SfxRequest& rReq )
916 {
917 	ScModule*			pScMod		= SC_MOD();
918 	ScTabViewShell*	pTabViewShell  	= GetViewData()->GetViewShell();
919 	const SfxItemSet*	pReqArgs	= rReq.GetArgs();
920 	sal_uInt16				nSlot		= rReq.GetSlot();
921 
922 	pTabViewShell->HideListBox();					// Autofilter-DropDown-Listbox
923 
924 									// Eingabe beenden
925 	if ( GetViewData()->HasEditView( GetViewData()->GetActivePart() ) )
926 	{
927 		switch ( nSlot )
928 		{
929 			case SID_NUMBER_TWODEC:
930 			case SID_NUMBER_SCIENTIFIC:
931 			case SID_NUMBER_DATE:
932 			case SID_NUMBER_CURRENCY:
933 			case SID_NUMBER_PERCENT:
934 			case SID_NUMBER_STANDARD:
935 			case SID_NUMBER_FORMAT:
936 			case SID_NUMBER_INCDEC:
937 			case SID_NUMBER_DECDEC:
938 			case FID_DEFINE_NAME:
939 			case FID_USE_NAME:
940 			case FID_INSERT_NAME:
941             case SID_SPELL_DIALOG:
942             case SID_HANGUL_HANJA_CONVERSION:
943 
944 			pScMod->InputEnterHandler();
945 			pTabViewShell->UpdateInputHandler();
946 			break;
947 
948 			default:
949 			break;
950 		}
951 	}
952 
953 	switch ( nSlot )
954 	{
955 		case SID_NUMBER_TWODEC:
956 			pTabViewShell->SetNumberFormat( NUMBERFORMAT_NUMBER, 4 );		// Standard+4 = #.##0,00
957 			rReq.Done();
958 			break;
959 		case SID_NUMBER_SCIENTIFIC:
960 			pTabViewShell->SetNumberFormat( NUMBERFORMAT_SCIENTIFIC );
961 			rReq.Done();
962 			break;
963 		case SID_NUMBER_DATE:
964 			pTabViewShell->SetNumberFormat( NUMBERFORMAT_DATE );
965 			rReq.Done();
966 			break;
967 		case SID_NUMBER_TIME:
968 			pTabViewShell->SetNumberFormat( NUMBERFORMAT_TIME );
969 			rReq.Done();
970 			break;
971 		case SID_NUMBER_CURRENCY:
972 			pTabViewShell->SetNumberFormat( NUMBERFORMAT_CURRENCY );
973 			rReq.Done();
974 			break;
975 		case SID_NUMBER_PERCENT:
976 			pTabViewShell->SetNumberFormat( NUMBERFORMAT_PERCENT );
977 			rReq.Done();
978 			break;
979 		case SID_NUMBER_STANDARD:
980 			pTabViewShell->SetNumberFormat( NUMBERFORMAT_NUMBER );
981 			rReq.Done();
982 			break;
983 		case SID_NUMBER_INCDEC:
984 			pTabViewShell->ChangeNumFmtDecimals( sal_True );
985 			rReq.Done();
986 			break;
987 		case SID_NUMBER_DECDEC:
988 			pTabViewShell->ChangeNumFmtDecimals( sal_False );
989 			rReq.Done();
990 			break;
991 
992 		case SID_NUMBER_FORMAT:
993 			//if ( pReqArgs )
994 			//{
995 			//	const SfxPoolItem* pItem;
996 			//	if(pReqArgs->GetItemState(nSlot, sal_True, &pItem) == SFX_ITEM_SET)
997 			//	{
998 			//		String aCode = ((const SfxStringItem*)pItem)->GetValue();
999 			//		pTabViewShell->SetNumFmtByStr( aCode );
1000 			//	}
1001 			//}
1002 
1003             // symphony version with format interpretation
1004 			if(pReqArgs)
1005 			{
1006 				const SfxPoolItem* pItem;
1007 				ScDocument* pDoc = pViewData->GetDocument();
1008 				SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
1009 				LanguageType eLanguage = ScGlobal::eLnge;
1010 				sal_Int16 eType = -1;
1011 				sal_uInt32 nCurrentNumberFormat;
1012 
1013                 pDoc->GetNumberFormat(pViewData->GetCurX(), pViewData->GetCurY(), pViewData->GetTabNo(), nCurrentNumberFormat);
1014 				const SvNumberformat* pEntry = pFormatter->GetEntry(nCurrentNumberFormat);
1015 
1016                 if(pEntry)
1017 				{
1018 					eLanguage = pEntry->GetLanguage();
1019 					eType = pEntry->GetType();
1020 				}
1021 
1022 				//Just use eType to judge whether the command is fired for NUMBER/PERCENT/CURRENCY
1023 				//In sidebar, users can fire SID_NUMBER_FORMAT command by operating the related UI controls before they are disable
1024 				switch(eType)
1025 				{
1026 				case NUMBERFORMAT_ALL:
1027 				case NUMBERFORMAT_NUMBER:
1028 				case NUMBERFORMAT_NUMBER| NUMBERFORMAT_DEFINED:
1029 				case NUMBERFORMAT_PERCENT:
1030 				case NUMBERFORMAT_PERCENT| NUMBERFORMAT_DEFINED:
1031 				case NUMBERFORMAT_CURRENCY:
1032 				case NUMBERFORMAT_CURRENCY|NUMBERFORMAT_DEFINED:
1033 					eType = 0;
1034 					break;
1035 				default:
1036 					eType =-1;
1037 				}
1038 
1039 				if(SFX_ITEM_SET == pReqArgs->GetItemState(nSlot, true, &pItem) && eType != -1)
1040 				{
1041 					String aCode = ((const SfxStringItem*)pItem)->GetValue();
1042 					sal_uInt16 aLen = aCode.Len();
1043 					String* sFormat = new String[4];
1044 					String sTmpStr = String::CreateFromAscii("");
1045 					sal_uInt16 nCount(0);
1046 					sal_uInt16 nStrCount(0);
1047 
1048 					while(nCount < aLen)
1049 					{
1050 						sal_Unicode cChar = aCode.GetChar(nCount);
1051 
1052 						if(cChar == sal_Unicode(','))
1053 						{
1054 							sFormat[nStrCount] = sTmpStr;
1055 							sTmpStr = String::CreateFromAscii("");
1056 							nStrCount++;
1057 						}
1058 						else
1059 						{
1060 							sTmpStr += cChar;
1061 						}
1062 
1063 						nCount++;
1064 
1065 						if(nStrCount > 3)
1066 							break;
1067 					}
1068 
1069 					const sal_Bool bThousand = (sal_Bool)sFormat[0].ToInt32();
1070 					const sal_Bool bNegRed = (sal_Bool)sFormat[1].ToInt32();
1071 					const sal_uInt16 nPrecision = (sal_uInt16)sFormat[2].ToInt32();
1072 					const sal_uInt16 nLeadZeroes = (sal_uInt16)sFormat[3].ToInt32();
1073 
1074 					pFormatter->GenerateFormat(
1075                         aCode,
1076                         nCurrentNumberFormat,//modify
1077 						eLanguage,
1078 						bThousand,
1079 						bNegRed,
1080 						nPrecision,
1081 						nLeadZeroes);
1082 					pTabViewShell->SetNumFmtByStr(aCode);
1083 					delete[] sFormat;
1084 				}
1085 			}
1086 			break;
1087 
1088         case SID_ATTR_NUMBERFORMAT_VALUE:
1089 			if ( pReqArgs )
1090 			{
1091 				const SfxPoolItem* pItem;
1092 				if ( pReqArgs->GetItemState( ATTR_VALUE_FORMAT, sal_True, &pItem ) == SFX_ITEM_SET )
1093 				{
1094                     // We have to accomplish this using ApplyAttributes()
1095                     // because we also need the language information to be
1096                     // considered.
1097                     const SfxItemSet& rOldSet =
1098                         pTabViewShell->GetSelectionPattern()->GetItemSet();
1099                     SfxItemPool* pDocPool = GetViewData()->GetDocument()->GetPool();
1100                     SfxItemSet aNewSet( *pDocPool, ATTR_PATTERN_START, ATTR_PATTERN_END );
1101                     aNewSet.Put( *pItem );
1102                     pTabViewShell->ApplyAttributes( &aNewSet, &rOldSet, sal_True );
1103 				}
1104 			}
1105 			break;
1106 
1107 		case SID_NUMBER_TYPE_FORMAT:
1108             if ( pReqArgs )
1109             {
1110                 const SfxPoolItem* pItem;
1111                 if ( pReqArgs->GetItemState( nSlot, sal_True, &pItem ) == SFX_ITEM_SET )
1112                 {
1113                     sal_uInt16 nFormat = ((SfxInt16Item *)pItem)->GetValue();
1114                     switch(nFormat)
1115                     {
1116                     case 0:
1117                         pTabViewShell->SetNumberFormat( NUMBERFORMAT_NUMBER); //Modify
1118                         break;
1119                     case 1:
1120                         pTabViewShell->SetNumberFormat( NUMBERFORMAT_NUMBER, 2 ); //Modify
1121                         break;
1122                     case 2:
1123                         pTabViewShell->SetNumberFormat( NUMBERFORMAT_PERCENT );
1124                         break;
1125                     case 3:
1126                         pTabViewShell->SetNumberFormat( NUMBERFORMAT_CURRENCY );
1127                         break;
1128                     case 4:
1129                         pTabViewShell->SetNumberFormat( NUMBERFORMAT_DATE );
1130                         break;
1131                     case 5:
1132                         pTabViewShell->SetNumberFormat( NUMBERFORMAT_TIME );
1133                         break;
1134                     case 6:
1135                         pTabViewShell->SetNumberFormat( NUMBERFORMAT_SCIENTIFIC );
1136                         break;
1137                     case 7:
1138                         pTabViewShell->SetNumberFormat( NUMBERFORMAT_FRACTION );
1139                         break;
1140                     case 8:
1141                         pTabViewShell->SetNumberFormat( NUMBERFORMAT_LOGICAL );
1142                         break;
1143                     case 9:
1144                         pTabViewShell->SetNumberFormat( NUMBERFORMAT_TEXT );
1145                         break;
1146                     default:
1147                         ;
1148                     }
1149                     rReq.Done();
1150                 }
1151             }
1152             break;
1153 
1154         default:
1155 			DBG_ERROR("falscher Slot bei ExecuteEdit");
1156 			break;
1157 	}
1158 }
1159 
1160 
1161 //------------------------------------------------------------------
1162 
1163 #define APPLY_HOR_JUSTIFY(j) \
1164 	{																		\
1165 		if ( !pHorJustify || (eHorJustify != (j) ) )                        \
1166 			pTabViewShell->ApplyAttr( SvxHorJustifyItem( (j) ) );                          \
1167 		else                                                                \
1168 			pTabViewShell->ApplyAttr( SvxHorJustifyItem( SVX_HOR_JUSTIFY_STANDARD ) );     \
1169 	}
1170 
1171 #define APPLY_VER_JUSTIFY(j) \
1172 	{																		\
1173 		if ( !pVerJustify || (eVerJustify != (j) ) )                        \
1174 			pTabViewShell->ApplyAttr( SvxVerJustifyItem( (j) ) );                          \
1175 		else                                                                \
1176 			pTabViewShell->ApplyAttr( SvxVerJustifyItem( SVX_VER_JUSTIFY_STANDARD ) );     \
1177 	}
1178 
ExecuteAlignment(SfxRequest & rReq)1179 void ScFormatShell::ExecuteAlignment( SfxRequest& rReq )
1180 {
1181 	ScTabViewShell*	pTabViewShell  		= GetViewData()->GetViewShell();
1182 	SfxBindings&			rBindings	= pViewData->GetBindings();
1183 	const SfxItemSet*       pSet		= rReq.GetArgs();
1184 	sal_uInt16					nSlot		= rReq.GetSlot();
1185 
1186 	pTabViewShell->HideListBox();	// Autofilter-DropDown-Listbox
1187 
1188     switch( nSlot )
1189     {
1190         // pseudo slots for Format menu
1191         case SID_ALIGN_ANY_HDEFAULT:
1192         case SID_ALIGN_ANY_LEFT:
1193         case SID_ALIGN_ANY_HCENTER:
1194         case SID_ALIGN_ANY_RIGHT:
1195         case SID_ALIGN_ANY_JUSTIFIED:
1196             pTabViewShell->ApplyAttr( SvxHorJustifyItem( lclConvertSlotToHAlign( nSlot ), ATTR_HOR_JUSTIFY ) );
1197         break;
1198         case SID_ALIGN_ANY_VDEFAULT:
1199         case SID_ALIGN_ANY_TOP:
1200         case SID_ALIGN_ANY_VCENTER:
1201         case SID_ALIGN_ANY_BOTTOM:
1202             pTabViewShell->ApplyAttr( SvxVerJustifyItem( lclConvertSlotToVAlign( nSlot ), ATTR_VER_JUSTIFY ) );
1203         break;
1204 
1205         default:
1206             if( pSet )
1207             {
1208                 const SfxPoolItem* pItem = NULL;
1209                 if( pSet->GetItemState(GetPool().GetWhich(nSlot), sal_True, &pItem  ) == SFX_ITEM_SET )
1210                 {
1211 
1212                     switch ( nSlot )
1213                     {
1214                         case SID_ATTR_ALIGN_HOR_JUSTIFY:
1215                         case SID_ATTR_ALIGN_VER_JUSTIFY:
1216                         case SID_ATTR_ALIGN_INDENT:
1217                         case SID_ATTR_ALIGN_HYPHENATION:
1218                         case SID_ATTR_ALIGN_DEGREES:
1219                         case SID_ATTR_ALIGN_LOCKPOS:
1220                         case SID_ATTR_ALIGN_MARGIN:
1221                         case SID_ATTR_ALIGN_STACKED:
1222                             pTabViewShell->ApplyAttr( *pItem );
1223                         break;
1224 
1225                         case SID_H_ALIGNCELL:
1226                         {
1227                             SvxCellHorJustify eJust = (SvxCellHorJustify)((const SvxHorJustifyItem*)pItem)->GetValue();
1228                             // #i78476# update alignment of text in cell edit mode
1229                             pTabViewShell->UpdateInputHandlerCellAdjust( eJust );
1230                             pTabViewShell->ApplyAttr( SvxHorJustifyItem( eJust, ATTR_HOR_JUSTIFY ) );
1231                         }
1232                         break;
1233                         case SID_V_ALIGNCELL:
1234                             pTabViewShell->ApplyAttr( SvxVerJustifyItem( (SvxCellVerJustify)((const SvxVerJustifyItem*)pItem)->GetValue(), ATTR_VER_JUSTIFY ) );
1235                         break;
1236                         default:
1237                             DBG_ERROR( "ExecuteAlignment: invalid slot" );
1238                             return;
1239                     }
1240                 }
1241             }
1242     }
1243     rBindings.Invalidate( SID_ATTR_PARA_ADJUST_LEFT );
1244     rBindings.Invalidate( SID_ATTR_PARA_ADJUST_RIGHT );
1245     rBindings.Invalidate( SID_ATTR_PARA_ADJUST_BLOCK );
1246     rBindings.Invalidate( SID_ATTR_PARA_ADJUST_CENTER);
1247     rBindings.Invalidate( SID_ALIGNLEFT );
1248     rBindings.Invalidate( SID_ALIGNRIGHT );
1249     rBindings.Invalidate( SID_ALIGNCENTERHOR );
1250     rBindings.Invalidate( SID_ALIGNBLOCK );
1251     rBindings.Invalidate( SID_ALIGNTOP );
1252     rBindings.Invalidate( SID_ALIGNBOTTOM );
1253     rBindings.Invalidate( SID_ALIGNCENTERVER );
1254     rBindings.Invalidate( SID_V_ALIGNCELL );
1255     rBindings.Invalidate( SID_H_ALIGNCELL );
1256     // pseudo slots for Format menu
1257     rBindings.Invalidate( SID_ALIGN_ANY_HDEFAULT );
1258     rBindings.Invalidate( SID_ALIGN_ANY_LEFT );
1259     rBindings.Invalidate( SID_ALIGN_ANY_HCENTER );
1260     rBindings.Invalidate( SID_ALIGN_ANY_RIGHT );
1261     rBindings.Invalidate( SID_ALIGN_ANY_JUSTIFIED );
1262     rBindings.Invalidate( SID_ALIGN_ANY_VDEFAULT );
1263     rBindings.Invalidate( SID_ALIGN_ANY_TOP );
1264     rBindings.Invalidate( SID_ALIGN_ANY_VCENTER );
1265     rBindings.Invalidate( SID_ALIGN_ANY_BOTTOM );
1266     rBindings.Update();
1267 
1268     if( ! rReq.IsAPI() )
1269         rReq.Done();
1270 }
1271 
ExecuteTextAttr(SfxRequest & rReq)1272 void ScFormatShell::ExecuteTextAttr( SfxRequest& rReq )
1273 {
1274 	ScTabViewShell*	pTabViewShell  		= GetViewData()->GetViewShell();
1275 	SfxBindings&			rBindings	= pViewData->GetBindings();
1276 	const ScPatternAttr*    pAttrs		= pTabViewShell->GetSelectionPattern();
1277 	const SfxItemSet*       pSet		= rReq.GetArgs();
1278 	sal_uInt16					nSlot		= rReq.GetSlot();
1279 	SfxAllItemSet*			pNewSet = 0;
1280 
1281 	pTabViewShell->HideListBox();					// Autofilter-DropDown-Listbox
1282 
1283 	if (  (nSlot == SID_ATTR_CHAR_WEIGHT)
1284 		||(nSlot == SID_ATTR_CHAR_POSTURE)
1285 		||(nSlot == SID_ATTR_CHAR_UNDERLINE)
1286 		||(nSlot == SID_ULINE_VAL_NONE)
1287 		||(nSlot == SID_ULINE_VAL_SINGLE)
1288 		||(nSlot == SID_ULINE_VAL_DOUBLE)
1289 		||(nSlot == SID_ULINE_VAL_DOTTED) )
1290 	{
1291 		pNewSet = new SfxAllItemSet( GetPool() );
1292 
1293 		switch ( nSlot )
1294 		{
1295 			case SID_ATTR_CHAR_WEIGHT:
1296 			{
1297 				// #i78017 establish the same behaviour as in Writer
1298 				sal_uInt8 nScript = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX;
1299 
1300 				SfxItemPool& rPool = GetPool();
1301 				SvxScriptSetItem aSetItem( nSlot, rPool );
1302 				if ( pSet )
1303 					aSetItem.PutItemForScriptType( nScript, pSet->Get( ATTR_FONT_WEIGHT ) );
1304 				else
1305 				{
1306 					//	toggle manually
1307 
1308 					FontWeight eWeight = WEIGHT_BOLD;
1309 					SvxScriptSetItem aOldSetItem( nSlot, rPool );
1310 					aOldSetItem.GetItemSet().Put( pAttrs->GetItemSet(), sal_False );
1311 					const SfxPoolItem* pCore = aOldSetItem.GetItemOfScript( nScript );
1312 					if ( pCore && ((const SvxWeightItem*)pCore)->GetWeight() == WEIGHT_BOLD )
1313 						eWeight = WEIGHT_NORMAL;
1314 
1315                     aSetItem.PutItemForScriptType( nScript, SvxWeightItem( eWeight, ATTR_FONT_WEIGHT ) );
1316 				}
1317 				pTabViewShell->ApplyUserItemSet( aSetItem.GetItemSet() );
1318 				pNewSet->Put( aSetItem.GetItemSet(), sal_False );
1319 			}
1320 			break;
1321 
1322 			case SID_ATTR_CHAR_POSTURE:
1323 			{
1324 				// #i78017 establish the same behaviour as in Writer
1325 				sal_uInt8 nScript = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX;
1326 
1327 				SfxItemPool& rPool = GetPool();
1328 				SvxScriptSetItem aSetItem( nSlot, rPool );
1329 				if ( pSet )
1330 					aSetItem.PutItemForScriptType( nScript, pSet->Get( ATTR_FONT_POSTURE ) );
1331 				else
1332 				{
1333 					//	toggle manually
1334 
1335 					FontItalic eItalic = ITALIC_NORMAL;
1336 					SvxScriptSetItem aOldSetItem( nSlot, rPool );
1337 					aOldSetItem.GetItemSet().Put( pAttrs->GetItemSet(), sal_False );
1338 					const SfxPoolItem* pCore = aOldSetItem.GetItemOfScript( nScript );
1339 					if ( pCore && ((const SvxPostureItem*)pCore)->GetPosture() == ITALIC_NORMAL )
1340 						eItalic = ITALIC_NONE;
1341 
1342                     aSetItem.PutItemForScriptType( nScript, SvxPostureItem( eItalic, ATTR_FONT_POSTURE ) );
1343 				}
1344 				pTabViewShell->ApplyUserItemSet( aSetItem.GetItemSet() );
1345 				pNewSet->Put( aSetItem.GetItemSet(), sal_False );
1346 			}
1347 			break;
1348 
1349 			case SID_ATTR_CHAR_UNDERLINE:
1350 				{
1351 					FontUnderline       eUnderline;
1352 
1353 					if( pSet )
1354 					{
1355                         const SfxPoolItem& rUnderline = pSet->Get( ATTR_FONT_UNDERLINE );
1356 
1357 						if( rUnderline.ISA(SvxUnderlineItem) )
1358 						{
1359 							pTabViewShell->ApplyAttr( rUnderline );
1360 							pNewSet->Put( rUnderline,rUnderline.Which() );
1361 						}
1362                         else if ( rUnderline.ISA(SvxTextLineItem) )
1363                         {
1364                             // #i106580# also allow SvxTextLineItem (base class of SvxUnderlineItem)
1365                             const SvxTextLineItem& rTextLineItem = static_cast<const SvxTextLineItem&>(rUnderline);
1366                             SvxUnderlineItem aNewItem( rTextLineItem.GetLineStyle(), rTextLineItem.Which() );
1367                             aNewItem.SetColor( rTextLineItem.GetColor() );
1368                             pTabViewShell->ApplyAttr( aNewItem );
1369                             pNewSet->Put( aNewItem, aNewItem.Which() );
1370                         }
1371 					}
1372 					else
1373 					{
1374 						SvxUnderlineItem aUnderline( (const SvxUnderlineItem&)
1375 														pAttrs->GetItem(
1376 															ATTR_FONT_UNDERLINE ) );
1377 						eUnderline = (UNDERLINE_NONE != aUnderline.GetLineStyle())
1378 									? UNDERLINE_NONE
1379 									: UNDERLINE_SINGLE;
1380 						aUnderline.SetLineStyle( eUnderline );
1381 						pTabViewShell->ApplyAttr( aUnderline );
1382 						pNewSet->Put( aUnderline,aUnderline.Which() );
1383 					}
1384 				}
1385 				break;
1386 
1387 			case SID_ULINE_VAL_NONE:
1388 				pTabViewShell->ApplyAttr( SvxUnderlineItem( UNDERLINE_NONE, ATTR_FONT_UNDERLINE ) );
1389 				break;
1390 			case SID_ULINE_VAL_SINGLE:		// Toggles
1391 			case SID_ULINE_VAL_DOUBLE:
1392 			case SID_ULINE_VAL_DOTTED:
1393 				{
1394 					FontUnderline eOld = ((const SvxUnderlineItem&)
1395 											pAttrs->GetItem(ATTR_FONT_UNDERLINE)).GetLineStyle();
1396 					FontUnderline eNew = eOld;
1397 					switch (nSlot)
1398 					{
1399 						case SID_ULINE_VAL_SINGLE:
1400 							eNew = ( eOld == UNDERLINE_SINGLE ) ? UNDERLINE_NONE : UNDERLINE_SINGLE;
1401 							break;
1402 						case SID_ULINE_VAL_DOUBLE:
1403 							eNew = ( eOld == UNDERLINE_DOUBLE ) ? UNDERLINE_NONE : UNDERLINE_DOUBLE;
1404 							break;
1405 						case SID_ULINE_VAL_DOTTED:
1406 							eNew = ( eOld == UNDERLINE_DOTTED ) ? UNDERLINE_NONE : UNDERLINE_DOTTED;
1407 							break;
1408 					}
1409 					pTabViewShell->ApplyAttr( SvxUnderlineItem( eNew, ATTR_FONT_UNDERLINE ) );
1410 				}
1411 				break;
1412 
1413 			default:
1414 				break;
1415 		}
1416 		rBindings.Invalidate( nSlot );
1417 	}
1418 	else
1419 	{
1420 		/*
1421 		 * "Selbstgemachte" RadioButton-Funktionalitaet
1422 		 * Beim Toggle gibt es den Standard-State, d.h. kein
1423 		 * Button ist gedrueckt
1424 		 */
1425 
1426 		const SfxItemSet&		 rAttrSet	= pTabViewShell->GetSelectionPattern()->GetItemSet();
1427 		const SfxPoolItem*       pItem       = NULL;
1428 		const SvxHorJustifyItem* pHorJustify = NULL;
1429 		const SvxVerJustifyItem* pVerJustify = NULL;
1430 		SvxCellHorJustify        eHorJustify = SVX_HOR_JUSTIFY_STANDARD;
1431 		SvxCellVerJustify        eVerJustify = SVX_VER_JUSTIFY_STANDARD;
1432 
1433 		if (rAttrSet.GetItemState(ATTR_HOR_JUSTIFY, sal_True,&pItem ) == SFX_ITEM_SET)
1434 		{
1435 			pHorJustify = (const SvxHorJustifyItem*)pItem;
1436 			eHorJustify = SvxCellHorJustify( pHorJustify->GetValue() );
1437 		}
1438 		if (rAttrSet.GetItemState(ATTR_VER_JUSTIFY, sal_True,&pItem ) == SFX_ITEM_SET)
1439 		{
1440 			pVerJustify = (const SvxVerJustifyItem*)pItem;
1441 			eVerJustify = SvxCellVerJustify( pVerJustify->GetValue() );
1442 		}
1443 
1444 		switch ( nSlot )
1445 		{
1446 			case SID_ALIGNLEFT:
1447 				rReq.SetSlot( SID_H_ALIGNCELL );
1448 				rReq.AppendItem( SvxHorJustifyItem(
1449 					!pHorJustify || (eHorJustify != SVX_HOR_JUSTIFY_LEFT) ?
1450 					SVX_HOR_JUSTIFY_LEFT : SVX_HOR_JUSTIFY_STANDARD, SID_H_ALIGNCELL ) );
1451 				ExecuteSlot( rReq, GetInterface() );
1452 				return;
1453 //				APPLY_HOR_JUSTIFY( SVX_HOR_JUSTIFY_LEFT );
1454                 //break;
1455 
1456 			case SID_ALIGNRIGHT:
1457 				rReq.SetSlot( SID_H_ALIGNCELL );
1458 				rReq.AppendItem( SvxHorJustifyItem(
1459 					!pHorJustify || (eHorJustify != SVX_HOR_JUSTIFY_RIGHT) ?
1460 					SVX_HOR_JUSTIFY_RIGHT : SVX_HOR_JUSTIFY_STANDARD, SID_H_ALIGNCELL ) );
1461 				ExecuteSlot( rReq, GetInterface() );
1462 				return;
1463 //				APPLY_HOR_JUSTIFY( SVX_HOR_JUSTIFY_RIGHT );
1464                 //break;
1465 
1466 			case SID_ALIGNCENTERHOR:
1467 				rReq.SetSlot( SID_H_ALIGNCELL );
1468 				rReq.AppendItem( SvxHorJustifyItem(
1469 					!pHorJustify || (eHorJustify != SVX_HOR_JUSTIFY_CENTER) ?
1470 					SVX_HOR_JUSTIFY_CENTER : SVX_HOR_JUSTIFY_STANDARD, SID_H_ALIGNCELL ) );
1471 				ExecuteSlot( rReq, GetInterface() );
1472 				return;
1473 //				APPLY_HOR_JUSTIFY( SVX_HOR_JUSTIFY_CENTER );
1474                 //break;
1475 
1476 			case SID_ALIGNBLOCK:
1477 				rReq.SetSlot( SID_H_ALIGNCELL );
1478 				rReq.AppendItem( SvxHorJustifyItem(
1479 					!pHorJustify || (eHorJustify != SVX_HOR_JUSTIFY_BLOCK) ?
1480 					SVX_HOR_JUSTIFY_BLOCK : SVX_HOR_JUSTIFY_STANDARD, SID_H_ALIGNCELL ) );
1481 				ExecuteSlot( rReq, GetInterface() );
1482 				return;
1483 //				APPLY_HOR_JUSTIFY( SVX_HOR_JUSTIFY_BLOCK );
1484                 //break;
1485 
1486 			case SID_ALIGNTOP:
1487 				rReq.SetSlot( SID_V_ALIGNCELL );
1488 				rReq.AppendItem( SvxVerJustifyItem(
1489 					!pVerJustify || (eVerJustify != SVX_VER_JUSTIFY_TOP) ?
1490 					SVX_VER_JUSTIFY_TOP : SVX_VER_JUSTIFY_STANDARD, SID_V_ALIGNCELL ) );
1491 				ExecuteSlot( rReq, GetInterface() );
1492 				return;
1493 //				APPLY_VER_JUSTIFY( SVX_VER_JUSTIFY_TOP );
1494                 //break;
1495 
1496 			case SID_ALIGNBOTTOM:
1497 				rReq.SetSlot( SID_V_ALIGNCELL );
1498 				rReq.AppendItem( SvxVerJustifyItem(
1499 					!pVerJustify || (eVerJustify != SVX_VER_JUSTIFY_BOTTOM) ?
1500 					SVX_VER_JUSTIFY_BOTTOM : SVX_VER_JUSTIFY_STANDARD, SID_V_ALIGNCELL ) );
1501 				ExecuteSlot( rReq, GetInterface() );
1502 				return;
1503 //				APPLY_VER_JUSTIFY( SVX_VER_JUSTIFY_BOTTOM );
1504                 //break;
1505 
1506 			case SID_ALIGNCENTERVER:
1507 				rReq.SetSlot( SID_V_ALIGNCELL );
1508 				rReq.AppendItem( SvxVerJustifyItem(
1509 					!pVerJustify || (eVerJustify != SVX_VER_JUSTIFY_CENTER) ?
1510 					SVX_VER_JUSTIFY_CENTER : SVX_VER_JUSTIFY_STANDARD, SID_V_ALIGNCELL ) );
1511 				ExecuteSlot( rReq, GetInterface() );
1512 				return;
1513 //				APPLY_VER_JUSTIFY( SVX_VER_JUSTIFY_CENTER );
1514                 //break;
1515 
1516 			default:
1517 			break;
1518 		}
1519 
1520 	}
1521 
1522 	rBindings.Update();
1523 //	rReq.Done();
1524 
1525 	if( pNewSet )
1526 	{
1527 		rReq.Done( *pNewSet );
1528 		delete pNewSet;
1529 	}
1530 	else
1531 	{
1532 		rReq.Done();
1533 	}
1534 
1535 }
1536 
1537 #undef APPLY_HOR_JUSTIFY
1538 #undef APPLY_VER_JUSTIFY
1539 
1540 //------------------------------------------------------------------
1541 
ExecuteAttr(SfxRequest & rReq)1542 void ScFormatShell::ExecuteAttr( SfxRequest& rReq )
1543 {
1544 	ScTabViewShell*	pTabViewShell  		= GetViewData()->GetViewShell();
1545 	SfxBindings&		rBindings = pViewData->GetBindings();
1546 	const SfxItemSet*	pNewAttrs = rReq.GetArgs();
1547 
1548 	pTabViewShell->HideListBox();					// Autofilter-DropDown-Listbox
1549 
1550 	if ( !pNewAttrs )
1551 	{
1552 		sal_uInt16 nSlot = rReq.GetSlot();
1553 
1554 		switch ( nSlot )
1555 		{
1556 			case SID_ATTR_CHAR_FONT:
1557 			case SID_ATTR_CHAR_FONTHEIGHT:
1558 				pTabViewShell->ExecuteCellFormatDlg( rReq, TP_FONT );	    // wenn ToolBar vertikal
1559 				break;
1560 
1561 			case SID_ATTR_ALIGN_LINEBREAK:					// ohne Parameter als Toggle
1562 				{
1563 					const ScPatternAttr* pAttrs = pTabViewShell->GetSelectionPattern();
1564 					sal_Bool bOld = ((const SfxBoolItem&)pAttrs->GetItem(ATTR_LINEBREAK)).GetValue();
1565 					SfxBoolItem aBreakItem( ATTR_LINEBREAK, !bOld );
1566 					pTabViewShell->ApplyAttr( aBreakItem );
1567 
1568 					SfxAllItemSet aNewSet( GetPool() );
1569 					aNewSet.Put( aBreakItem,aBreakItem.Which() );
1570 					rReq.Done( aNewSet );
1571 
1572 					rBindings.Invalidate( nSlot );
1573 				}
1574 				break;
1575 
1576 			case SID_BACKGROUND_COLOR:
1577 				{
1578 					//	SID_BACKGROUND_COLOR without arguments -> set transparent background
1579 
1580 					SvxBrushItem        aBrushItem( (const SvxBrushItem&)
1581 											pTabViewShell->GetSelectionPattern()->
1582 												GetItem( ATTR_BACKGROUND ) );
1583 
1584 					aBrushItem.SetColor( COL_TRANSPARENT );
1585 
1586 					pTabViewShell->ApplyAttr( aBrushItem );
1587 				}
1588 				break;
1589 		}
1590 	}
1591 	else
1592 	{
1593 		sal_uInt16 nSlot = rReq.GetSlot();
1594 
1595 		switch ( nSlot )
1596 		{
1597             case SID_ATTR_CHAR_OVERLINE:
1598             case SID_ATTR_CHAR_STRIKEOUT:
1599 			case SID_ATTR_ALIGN_LINEBREAK:
1600 			case SID_ATTR_CHAR_COLOR:
1601             case SID_ATTR_CHAR_CONTOUR:
1602             case SID_ATTR_CHAR_SHADOWED:
1603             case SID_ATTR_CHAR_RELIEF:
1604             case SID_SCATTR_PROTECTION :
1605 				pTabViewShell->ApplyAttr( pNewAttrs->Get( pNewAttrs->GetPool()->GetWhich( nSlot ) ) );
1606 				rBindings.Invalidate( nSlot );
1607 				rBindings.Update( nSlot );
1608 				break;
1609 
1610 			case SID_ATTR_CHAR_FONT:
1611 			case SID_ATTR_CHAR_FONTHEIGHT:
1612 				{
1613 					// #i78017 establish the same behaviour as in Writer
1614 					sal_uInt8 nScript = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX;
1615 					if (nSlot == SID_ATTR_CHAR_FONT)
1616 						nScript = pTabViewShell->GetSelectionScriptType();
1617 
1618 					SfxItemPool& rPool = GetPool();
1619 					SvxScriptSetItem aSetItem( nSlot, rPool );
1620 					sal_uInt16 nWhich = rPool.GetWhich( nSlot );
1621 					aSetItem.PutItemForScriptType( nScript, pNewAttrs->Get( nWhich ) );
1622 
1623 					pTabViewShell->ApplyUserItemSet( aSetItem.GetItemSet() );
1624 
1625 					rBindings.Invalidate( nSlot );
1626 					rBindings.Update( nSlot );
1627 				}
1628 				break;
1629 
1630 			case SID_FRAME_LINESTYLE:
1631 				{
1632 					// Default-Linie aktualisieren
1633 					const SvxBorderLine* pLine =
1634 							((const SvxLineItem&)
1635 								pNewAttrs->Get( SID_FRAME_LINESTYLE )).
1636 								GetLine();
1637 
1638 					if ( pLine )
1639 					{
1640 						SvxBorderLine* pDefLine = pTabViewShell->GetDefaultFrameLine();
1641 
1642 						if ( pDefLine )
1643 						{
1644 							pDefLine->SetOutWidth( pLine->GetOutWidth() );
1645 							pDefLine->SetInWidth ( pLine->GetInWidth() );
1646 							pDefLine->SetDistance( pLine->GetDistance() );
1647 							pTabViewShell->SetSelectionFrameLines( pDefLine, sal_False );
1648 						}
1649 						else
1650 						{
1651 							pTabViewShell->SetDefaultFrameLine( pLine );
1652 							pTabViewShell->GetDefaultFrameLine()->SetColor( COL_BLACK );
1653 							pTabViewShell->SetSelectionFrameLines( pLine, sal_False );
1654 						}
1655 					}
1656 					else
1657 					{
1658 						Color           aColorBlack( COL_BLACK );
1659 						SvxBorderLine   aDefLine( &aColorBlack, 20, 0, 0 );
1660 						pTabViewShell->SetDefaultFrameLine( &aDefLine );
1661 						pTabViewShell->SetSelectionFrameLines( NULL, sal_False );
1662 					}
1663 				}
1664 				break;
1665 
1666 			case SID_FRAME_LINECOLOR:
1667 				{
1668 					SvxBorderLine*  pDefLine = pTabViewShell->GetDefaultFrameLine();
1669 					const Color&    rColor = ((const SvxColorItem&)
1670 										pNewAttrs->Get( SID_FRAME_LINECOLOR )).
1671 											GetValue();
1672 
1673 					// Default-Linie aktualisieren
1674 					if ( pDefLine )
1675 					{
1676 						pDefLine->SetColor( rColor );
1677 						pTabViewShell->SetSelectionFrameLines( pDefLine, sal_True );
1678 					}
1679 					else
1680 					{
1681 						SvxBorderLine   aDefLine( &rColor, 20, 0, 0 );
1682 						pTabViewShell->SetDefaultFrameLine( &aDefLine );
1683 						pTabViewShell->SetSelectionFrameLines( &aDefLine, sal_False );
1684 					}
1685 				}
1686 				break;
1687 
1688 			case SID_ATTR_BORDER_OUTER:
1689 			case SID_ATTR_BORDER:
1690 				{
1691 					SvxBorderLine*          pDefLine = pTabViewShell->GetDefaultFrameLine();
1692 					const ScPatternAttr*    pOldAttrs = pTabViewShell->GetSelectionPattern();
1693 					ScDocument*             pDoc = GetViewData()->GetDocument();
1694 					SfxItemSet*             pOldSet =
1695 												new SfxItemSet(
1696 														*(pDoc->GetPool()),
1697 														ATTR_PATTERN_START,
1698 														ATTR_PATTERN_END );
1699 					SfxItemSet*             pNewSet =
1700 												new SfxItemSet(
1701 														*(pDoc->GetPool()),
1702 														ATTR_PATTERN_START,
1703 														ATTR_PATTERN_END );
1704 					const SfxPoolItem&      rBorderAttr =
1705 												pOldAttrs->GetItemSet().
1706 													Get( ATTR_BORDER );
1707 
1708 					// Border-Items vom Controller auswerten:
1709 					const SfxPoolItem* pItem = 0;
1710 
1711 					if ( pNewAttrs->GetItemState( ATTR_BORDER, sal_True, &pItem )
1712 						 == SFX_ITEM_SET )
1713 					{
1714 						//	#100959# The SvxFrameToolBoxControl toolbox controller uses a default
1715 						//	SvxBorderLine (all widths 0) to mark the lines that should be set.
1716 						//	Macro recording uses a SvxBoxItem with the real values (OutWidth > 0)
1717 						//	or NULL pointers for no lines.
1718 						//	-> Substitute existing lines with pDefLine only if widths are 0.
1719 						SvxBoxItem aBoxItem ( *(const SvxBoxItem*)pItem );
1720 						if ( aBoxItem.GetTop() && aBoxItem.GetTop()->GetOutWidth() == 0 )
1721 							aBoxItem.SetLine( pDefLine, BOX_LINE_TOP );
1722 						if ( aBoxItem.GetBottom() && aBoxItem.GetBottom()->GetOutWidth() == 0 )
1723 							aBoxItem.SetLine( pDefLine, BOX_LINE_BOTTOM );
1724 						if ( aBoxItem.GetLeft() && aBoxItem.GetLeft()->GetOutWidth() == 0 )
1725 							aBoxItem.SetLine( pDefLine, BOX_LINE_LEFT );
1726 						if ( aBoxItem.GetRight() && aBoxItem.GetRight()->GetOutWidth() == 0 )
1727 							aBoxItem.SetLine( pDefLine, BOX_LINE_RIGHT );
1728 						pNewSet->Put( aBoxItem );
1729                         rReq.AppendItem( aBoxItem );
1730 					}
1731 
1732 					if ( pNewAttrs->GetItemState( ATTR_BORDER_INNER, sal_True, &pItem )
1733 						 == SFX_ITEM_SET )
1734 					{
1735 						SvxBoxInfoItem aBoxInfoItem( *(const SvxBoxInfoItem*)pItem );
1736 						if ( aBoxInfoItem.GetHori() && aBoxInfoItem.GetHori()->GetOutWidth() == 0 )
1737 							aBoxInfoItem.SetLine( pDefLine, BOXINFO_LINE_HORI );
1738 						if ( aBoxInfoItem.GetVert() && aBoxInfoItem.GetVert()->GetOutWidth() == 0 )
1739 							aBoxInfoItem.SetLine( pDefLine, BOXINFO_LINE_VERT );
1740 						pNewSet->Put( aBoxInfoItem );
1741                         rReq.AppendItem( aBoxInfoItem );
1742 					}
1743 					else
1744 					{
1745 						SvxBoxInfoItem aBoxInfoItem( ATTR_BORDER_INNER );
1746 						aBoxInfoItem.SetLine( NULL, BOXINFO_LINE_HORI );
1747 						aBoxInfoItem.SetLine( NULL, BOXINFO_LINE_VERT );
1748 						pNewSet->Put( aBoxInfoItem );
1749 					}
1750 
1751 					pOldSet->Put( rBorderAttr );
1752 					pTabViewShell->ApplyAttributes( pNewSet, pOldSet );
1753 
1754 					delete pOldSet;
1755 					delete pNewSet;
1756 				}
1757 				break;
1758 
1759 			case SID_ATTR_BORDER_DIAG_TLBR:
1760 			case SID_ATTR_BORDER_DIAG_BLTR:
1761 				{
1762 					// ScDocument* pDoc = GetViewData()->GetDocument();
1763 					const ScPatternAttr* pOldAttrs = pTabViewShell->GetSelectionPattern();
1764 					SfxItemSet* pOldSet = new SfxItemSet(pOldAttrs->GetItemSet());
1765 					SfxItemSet* pNewSet = new SfxItemSet(pOldAttrs->GetItemSet());
1766 					const SfxPoolItem* pItem = 0;
1767 
1768                     if(SID_ATTR_BORDER_DIAG_TLBR == nSlot)
1769 					{
1770 						if(SFX_ITEM_SET == pNewAttrs->GetItemState(ATTR_BORDER_TLBR, true, &pItem))
1771 						{
1772 							SvxLineItem aItem(ATTR_BORDER_TLBR);
1773 							aItem.SetLine(((const SvxLineItem&)pNewAttrs->Get(ATTR_BORDER_TLBR)).GetLine());
1774 							pNewSet->Put(aItem);
1775 							rReq.AppendItem(aItem);
1776 							pTabViewShell->ApplyAttributes(pNewSet, pOldSet);
1777 						}
1778 					}
1779 					else // if( nSlot == SID_ATTR_BORDER_DIAG_BLTR )
1780 					{
1781 						if(SFX_ITEM_SET == pNewAttrs->GetItemState(ATTR_BORDER_BLTR, true, &pItem ))
1782 						{
1783 							SvxLineItem aItem(ATTR_BORDER_BLTR);
1784 							aItem.SetLine(((const SvxLineItem&)pNewAttrs->Get(ATTR_BORDER_BLTR)).GetLine());
1785 							pNewSet->Put(aItem);
1786 							rReq.AppendItem(aItem);
1787 							pTabViewShell->ApplyAttributes(pNewSet, pOldSet);
1788 						}
1789 					}
1790 
1791                     delete pOldSet;
1792 					delete pNewSet;
1793 					rBindings.Invalidate(nSlot);
1794 				}
1795 				break;
1796 
1797 			// ATTR_BACKGROUND (=SID_ATTR_BRUSH) muss ueber zwei IDs
1798 			// gesetzt werden:
1799 			case SID_BACKGROUND_COLOR:
1800 				{
1801 					const SvxColorItem  rNewColorItem = (const SvxColorItem&)
1802 											pNewAttrs->Get( SID_BACKGROUND_COLOR );
1803 
1804 					SvxBrushItem        aBrushItem( (const SvxBrushItem&)
1805 											pTabViewShell->GetSelectionPattern()->
1806 												GetItem( ATTR_BACKGROUND ) );
1807 
1808 					aBrushItem.SetColor( rNewColorItem.GetValue() );
1809 
1810 					pTabViewShell->ApplyAttr( aBrushItem );
1811 				}
1812 				break;
1813 
1814 				case SID_ATTR_BRUSH:
1815 				{
1816 					SvxBrushItem        aBrushItem( (const SvxBrushItem&)
1817 											pTabViewShell->GetSelectionPattern()->
1818 												GetItem( ATTR_BACKGROUND ) );
1819 					const SvxBrushItem& rNewBrushItem = (const SvxBrushItem&)
1820 											pNewAttrs->Get( GetPool().GetWhich(nSlot) );
1821 					aBrushItem.SetColor(rNewBrushItem.GetColor());
1822 					pTabViewShell->ApplyAttr( aBrushItem );
1823 				}
1824 				break;
1825 
1826 			case SID_ATTR_BORDER_SHADOW:
1827 				{
1828 					const SvxShadowItem& rNewShadowItem = (const SvxShadowItem&)
1829 											pNewAttrs->Get( ATTR_SHADOW );
1830 					pTabViewShell->ApplyAttr( rNewShadowItem );
1831 				}
1832 				break;
1833 
1834 			default:
1835 			break;
1836 		}
1837 
1838 		if( ! rReq.IsAPI() )
1839 			if( ! rReq.IsDone() )
1840 				rReq.Done();
1841 	}
1842 }
1843 
GetAttrState(SfxItemSet & rSet)1844 void ScFormatShell::GetAttrState( SfxItemSet& rSet )
1845 {
1846 	ScTabViewShell*	pTabViewShell  	= GetViewData()->GetViewShell();
1847 	const SfxItemSet&	 rAttrSet	= pTabViewShell->GetSelectionPattern()->GetItemSet();
1848 	// const SvxBorderLine* pLine      = pTabViewShell->GetDefaultFrameLine();
1849 	const SvxBrushItem&  rBrushItem = (const SvxBrushItem&)rAttrSet.Get( ATTR_BACKGROUND );
1850 	SfxWhichIter aIter( rSet );
1851 	sal_uInt16 nWhich = aIter.FirstWhich();
1852 
1853 	rSet.Put( rAttrSet, sal_False );
1854 
1855 	//	choose font info according to selection script type
1856 	sal_uInt8 nScript = 0;		// GetSelectionScriptType never returns 0
1857 	if ( rSet.GetItemState( ATTR_FONT ) != SFX_ITEM_UNKNOWN )
1858 	{
1859 		if (!nScript) nScript = pTabViewShell->GetSelectionScriptType();
1860 		ScViewUtil::PutItemScript( rSet, rAttrSet, ATTR_FONT, nScript );
1861 	}
1862 	if ( rSet.GetItemState( ATTR_FONT_HEIGHT ) != SFX_ITEM_UNKNOWN )
1863 	{
1864 		if (!nScript) nScript = pTabViewShell->GetSelectionScriptType();
1865 		ScViewUtil::PutItemScript( rSet, rAttrSet, ATTR_FONT_HEIGHT, nScript );
1866 	}
1867 
1868 	while ( nWhich )
1869 	{
1870 		switch(nWhich)
1871 		{
1872 			case SID_BACKGROUND_COLOR:
1873 			{
1874                 rSet.Put( SvxColorItem( rBrushItem.GetColor(), SID_BACKGROUND_COLOR ) );
1875 
1876                 if(SFX_ITEM_DONTCARE == rAttrSet.GetItemState(ATTR_BACKGROUND))
1877                 {
1878                     rSet.InvalidateItem(SID_BACKGROUND_COLOR);
1879                 }
1880 			}
1881 			break;
1882     		case SID_FRAME_LINESTYLE:
1883 			case SID_FRAME_LINECOLOR:
1884 			{
1885                 // handled together because both need the cell border information for decisions
1886                 // rSet.Put( SvxColorItem( pLine ? pLine->GetColor() : Color(), SID_FRAME_LINECOLOR ) );
1887 				Color aCol = 0;
1888 				// sal_uInt16 nOut = 0, nIn = 0, nDis = 0;
1889 				SvxBorderLine aLine(0,0,0,0);
1890 				bool bCol = 0;
1891 				bool bColDisable = 0, bStyleDisable = 0;
1892                 SvxBoxItem aBoxItem(ATTR_BORDER);
1893                 SvxBoxInfoItem aInfoItem(ATTR_BORDER_INNER);
1894 
1895                 pTabViewShell->GetSelectionFrame(aBoxItem, aInfoItem);
1896 
1897 				if( aBoxItem.GetTop() )
1898 				{
1899 					bCol = 1;
1900 					aCol = aBoxItem.GetTop()->GetColor() ;
1901 					aLine.SetColor(aCol);
1902 					aLine.SetOutWidth( aBoxItem.GetTop()->GetOutWidth());
1903 					aLine.SetInWidth( aBoxItem.GetTop()->GetInWidth());
1904 					aLine.SetDistance( aBoxItem.GetTop()->GetDistance());
1905 				}
1906 
1907                 if( aBoxItem.GetBottom() )
1908 				{
1909 					if(bCol == 0)
1910 					{
1911 						bCol = 1;
1912 						aCol = aBoxItem.GetBottom()->GetColor() ;
1913 						aLine.SetColor(aCol);
1914 						aLine.SetOutWidth( aBoxItem.GetBottom()->GetOutWidth());
1915 						aLine.SetInWidth( aBoxItem.GetBottom()->GetInWidth());
1916 						aLine.SetDistance( aBoxItem.GetBottom()->GetDistance());
1917 					}
1918 					else
1919 					{
1920 						if(aCol != aBoxItem.GetBottom()->GetColor() )
1921 							bColDisable = 1;
1922 						if(!( aLine == *(aBoxItem.GetBottom())) )
1923 							bStyleDisable = 1;
1924 					}
1925 				}
1926 
1927                 if( aBoxItem.GetLeft() )
1928 				{
1929 					if(bCol == 0)
1930 					{
1931 						bCol = 1;
1932 						aCol = aBoxItem.GetLeft()->GetColor() ;
1933 						aLine.SetColor(aCol);
1934 						aLine.SetOutWidth( aBoxItem.GetLeft()->GetOutWidth());
1935 						aLine.SetInWidth( aBoxItem.GetLeft()->GetInWidth());
1936 						aLine.SetDistance( aBoxItem.GetLeft()->GetDistance());
1937 					}
1938 					else
1939 					{
1940 						if(aCol != aBoxItem.GetLeft()->GetColor() )
1941 							bColDisable = 1;
1942 						if(!( aLine == *(aBoxItem.GetLeft())) )
1943 							bStyleDisable = 1;
1944 					}
1945 				}
1946 
1947                 if( aBoxItem.GetRight() )
1948 				{
1949 					if(bCol == 0)
1950 					{
1951 						bCol = 1;
1952 						aCol = aBoxItem.GetRight()->GetColor() ;
1953 						aLine.SetColor(aCol);
1954 						aLine.SetOutWidth( aBoxItem.GetRight()->GetOutWidth());
1955 						aLine.SetInWidth( aBoxItem.GetRight()->GetInWidth());
1956 						aLine.SetDistance( aBoxItem.GetRight()->GetDistance());
1957 					}
1958 					else
1959 					{
1960 						if(aCol != aBoxItem.GetRight()->GetColor() )
1961 							bColDisable = 1;
1962 						if(!( aLine == *(aBoxItem.GetRight())) )
1963 							bStyleDisable = 1;
1964 					}
1965 				}
1966 
1967                 if( aInfoItem.GetVert())
1968 				{
1969 					if(bCol == 0)
1970 					{
1971 						bCol = 1;
1972 						aCol = aInfoItem.GetVert()->GetColor() ;
1973 						aLine.SetColor(aCol);
1974 						aLine.SetOutWidth( aInfoItem.GetVert()->GetOutWidth());
1975 						aLine.SetInWidth( aInfoItem.GetVert()->GetInWidth());
1976 						aLine.SetDistance( aInfoItem.GetVert()->GetDistance());
1977 					}
1978 					else
1979 					{
1980 						if(aCol != aInfoItem.GetVert()->GetColor() )
1981 							bColDisable = 1;
1982 						if(!( aLine == *(aInfoItem.GetVert())) )
1983 							bStyleDisable = 1;
1984 					}
1985 				}
1986 
1987                 if( aInfoItem.GetHori())
1988 				{
1989 					if(bCol == 0)
1990 					{
1991 						bCol = 1;
1992 						aCol = aInfoItem.GetHori()->GetColor() ;
1993 						aLine.SetColor(aCol);
1994 						aLine.SetOutWidth( aInfoItem.GetHori()->GetOutWidth());
1995 						aLine.SetInWidth( aInfoItem.GetHori()->GetInWidth());
1996 						aLine.SetDistance( aInfoItem.GetHori()->GetDistance());
1997 					}
1998 					else
1999 					{
2000 						if(aCol != aInfoItem.GetHori()->GetColor() )
2001 							bColDisable = 1;
2002 						if(!( aLine == *(aInfoItem.GetHori())) )
2003 							bStyleDisable = 1;
2004 					}
2005 				}
2006 
2007 				if( !aInfoItem.IsValid( VALID_VERT )
2008 					|| !aInfoItem.IsValid( VALID_HORI )
2009 					|| !aInfoItem.IsValid( VALID_LEFT )
2010 					|| !aInfoItem.IsValid( VALID_RIGHT )
2011 					|| !aInfoItem.IsValid( VALID_TOP )
2012 					|| !aInfoItem.IsValid( VALID_BOTTOM ) )
2013 				{
2014 					bColDisable = 1;
2015 					bStyleDisable = 1;
2016 				}
2017 
2018 				if(SID_FRAME_LINECOLOR == nWhich)
2019 				{
2020 					if(bColDisable) // if different lines have differernt colors
2021 					{
2022 						aCol = COL_TRANSPARENT;
2023 						rSet.Put( SvxColorItem(aCol, SID_FRAME_LINECOLOR ) );
2024 						rSet.InvalidateItem(SID_FRAME_LINECOLOR);
2025 					}
2026 					else if( bCol == 0 && bColDisable == 0) // if no line available
2027 					{
2028 						aCol = COL_AUTO;
2029 						rSet.Put( SvxColorItem(aCol, SID_FRAME_LINECOLOR ) );
2030 					}
2031 					else
2032 						rSet.Put( SvxColorItem(aCol, SID_FRAME_LINECOLOR ) );
2033 				}
2034 				else // if( nWhich == SID_FRAME_LINESTYLE)
2035 				{
2036 					if(bStyleDisable) // if have several lines but don't have same style
2037 					{
2038 						aLine.SetOutWidth( 1 );
2039 						aLine.SetInWidth( 0 );
2040 						aLine.SetDistance( 0 );
2041 						SvxLineItem aItem(SID_FRAME_LINESTYLE);
2042 						aItem.SetLine(&aLine);
2043 						rSet.Put( aItem );
2044 						rSet.InvalidateItem(SID_FRAME_LINESTYLE);
2045 					}
2046 					else // all the lines have same style or no line availavle, use initial value (0,0,0,0)
2047 					{
2048 						SvxLineItem aItem(SID_FRAME_LINESTYLE);
2049 						aItem.SetLine(&aLine);
2050 						rSet.Put( aItem );
2051 					}
2052 				}
2053 			}
2054 			break;
2055 			case SID_ATTR_BRUSH:
2056 			{
2057 				rSet.Put( rBrushItem, GetPool().GetWhich(nWhich) );
2058 			}
2059 			break;
2060 		}
2061 		nWhich = aIter.NextWhich();
2062 	}
2063 
2064     // stuff for sidebar panels
2065     Invalidate(SID_ATTR_ALIGN_DEGREES);
2066     Invalidate(SID_ATTR_ALIGN_STACKED);
2067 }
2068 
2069 //------------------------------------------------------------------
2070 
GetTextAttrState(SfxItemSet & rSet)2071 void ScFormatShell::GetTextAttrState( SfxItemSet& rSet )
2072 {
2073 	ScTabViewShell*	pTabViewShell  	= GetViewData()->GetViewShell();
2074 	const SfxItemSet& rAttrSet	= pTabViewShell->GetSelectionPattern()->GetItemSet();
2075 	rSet.Put( rAttrSet, sal_False ); // ItemStates mitkopieren
2076 
2077 	//	choose font info according to selection script type
2078 	sal_uInt8 nScript = 0;		// GetSelectionScriptType never returns 0
2079 	if ( rSet.GetItemState( ATTR_FONT_WEIGHT ) != SFX_ITEM_UNKNOWN )
2080 	{
2081 		if (!nScript) nScript = pTabViewShell->GetSelectionScriptType();
2082 		ScViewUtil::PutItemScript( rSet, rAttrSet, ATTR_FONT_WEIGHT, nScript );
2083 	}
2084 	if ( rSet.GetItemState( ATTR_FONT_POSTURE ) != SFX_ITEM_UNKNOWN )
2085 	{
2086 		if (!nScript) nScript = pTabViewShell->GetSelectionScriptType();
2087 		ScViewUtil::PutItemScript( rSet, rAttrSet, ATTR_FONT_POSTURE, nScript );
2088 	}
2089 
2090 	SfxItemState eState;
2091 //	const SfxPoolItem* pItem;
2092 
2093 	//--------------------------------------------------------------------
2094 	// eigene Kontrolle ueber RadioButton-Funktionalitaet:
2095 	//--------------------------------------------------------------------
2096 	// Unterstreichung
2097 	//------------------------
2098 
2099 	eState = rAttrSet.GetItemState( ATTR_FONT_UNDERLINE, sal_True );
2100 	if ( eState == SFX_ITEM_DONTCARE )
2101 	{
2102 		rSet.InvalidateItem( SID_ULINE_VAL_NONE );
2103 		rSet.InvalidateItem( SID_ULINE_VAL_SINGLE );
2104 		rSet.InvalidateItem( SID_ULINE_VAL_DOUBLE );
2105 		rSet.InvalidateItem( SID_ULINE_VAL_DOTTED );
2106 	}
2107 	else
2108 	{
2109 		FontUnderline eUnderline = ((const SvxUnderlineItem&)
2110 					rAttrSet.Get(ATTR_FONT_UNDERLINE)).GetLineStyle();
2111 		sal_uInt16 nId = SID_ULINE_VAL_NONE;
2112 		switch (eUnderline)
2113 		{
2114 			case UNDERLINE_SINGLE:	nId = SID_ULINE_VAL_SINGLE;	break;
2115 			case UNDERLINE_DOUBLE:	nId = SID_ULINE_VAL_DOUBLE;	break;
2116 			case UNDERLINE_DOTTED:	nId = SID_ULINE_VAL_DOTTED;	break;
2117 			default:
2118 				break;
2119 		}
2120 		rSet.Put( SfxBoolItem( nId, sal_True ) );
2121 	}
2122 
2123 	//------------------------
2124 	// horizontale Ausrichtung
2125 	//------------------------
2126 
2127 	const SvxHorJustifyItem* pHorJustify = NULL;
2128 	const SvxVerJustifyItem* pVerJustify = NULL;
2129 	SvxCellHorJustify        eHorJustify = SVX_HOR_JUSTIFY_STANDARD;
2130 	SvxCellVerJustify        eVerJustify = SVX_VER_JUSTIFY_STANDARD;
2131 	sal_uInt16		 			 nWhich		 = 0;
2132 	sal_Bool					 bJustifyStd = sal_False;
2133 	SfxBoolItem				 aBoolItem	 ( 0, sal_True );
2134 
2135 	eState 	 = rAttrSet.GetItemState( ATTR_HOR_JUSTIFY, sal_True,
2136 										(const SfxPoolItem**)&pHorJustify );
2137 	switch ( eState )
2138 	{
2139 		case SFX_ITEM_SET:
2140 			{
2141 				eHorJustify = SvxCellHorJustify( pHorJustify->GetValue() );
2142 
2143 				switch ( SvxCellHorJustify( pHorJustify->GetValue() ) )
2144 				{
2145 					case SVX_HOR_JUSTIFY_STANDARD:
2146 						break;
2147 
2148 					case SVX_HOR_JUSTIFY_LEFT:
2149 						nWhich = SID_ALIGNLEFT;
2150 						break;
2151 
2152 					case SVX_HOR_JUSTIFY_RIGHT:
2153 						nWhich = SID_ALIGNRIGHT;
2154 						break;
2155 
2156 					case SVX_HOR_JUSTIFY_CENTER:
2157 						nWhich = SID_ALIGNCENTERHOR;
2158 						break;
2159 
2160 					case SVX_HOR_JUSTIFY_BLOCK:
2161 						nWhich = SID_ALIGNBLOCK;
2162 						break;
2163 
2164 					case SVX_HOR_JUSTIFY_REPEAT:
2165 					default:
2166 						bJustifyStd = sal_True;
2167 						break;
2168 				}
2169 			}
2170 			break;
2171 
2172 		case SFX_ITEM_DONTCARE:
2173 			rSet.InvalidateItem( SID_ALIGNLEFT );
2174 			rSet.InvalidateItem( SID_ALIGNRIGHT );
2175 			rSet.InvalidateItem( SID_ALIGNCENTERHOR );
2176 			rSet.InvalidateItem( SID_ALIGNBLOCK );
2177 			break;
2178 
2179 		default:
2180 			bJustifyStd = sal_True;
2181 			break;
2182 	}
2183 
2184 	if ( nWhich )
2185 	{
2186 		aBoolItem.SetWhich( nWhich );
2187 		rSet.Put( aBoolItem );
2188 	}
2189 	else if ( bJustifyStd )
2190 	{
2191 		aBoolItem.SetValue( sal_False );
2192 		aBoolItem.SetWhich( SID_ALIGNLEFT );	  rSet.Put( aBoolItem );
2193 		aBoolItem.SetWhich( SID_ALIGNRIGHT );	  rSet.Put( aBoolItem );
2194 		aBoolItem.SetWhich( SID_ALIGNCENTERHOR ); rSet.Put( aBoolItem );
2195 		aBoolItem.SetWhich( SID_ALIGNBLOCK );	  rSet.Put( aBoolItem );
2196 		bJustifyStd = sal_False;
2197 	}
2198 
2199 	//------------------------
2200 	// vertikale Ausrichtung
2201 	//------------------------
2202 
2203 	nWhich = 0;
2204 	aBoolItem.SetValue( sal_True );
2205 
2206 	eState = rAttrSet.GetItemState( ATTR_VER_JUSTIFY, sal_True,
2207 									(const SfxPoolItem**)&pVerJustify );
2208 
2209 	switch ( eState )
2210 	{
2211 		case SFX_ITEM_SET:
2212 			{
2213 				eVerJustify = SvxCellVerJustify( pVerJustify->GetValue() );
2214 
2215 				switch ( eVerJustify )
2216 				{
2217 					case SVX_VER_JUSTIFY_TOP:
2218 						nWhich = SID_ALIGNTOP;
2219 						break;
2220 
2221 					case SVX_VER_JUSTIFY_BOTTOM:
2222 						nWhich = SID_ALIGNBOTTOM;
2223 						break;
2224 
2225 					case SVX_VER_JUSTIFY_CENTER:
2226 						nWhich = SID_ALIGNCENTERVER;
2227 						break;
2228 
2229 					case SVX_VER_JUSTIFY_STANDARD:
2230 					default:
2231 						bJustifyStd = sal_True;
2232 						break;
2233 				}
2234 			}
2235 			break;
2236 
2237 		case SFX_ITEM_DONTCARE:
2238 			rSet.InvalidateItem( SID_ALIGNTOP );
2239 			rSet.InvalidateItem( SID_ALIGNBOTTOM );
2240 			rSet.InvalidateItem( SID_ALIGNCENTERVER );
2241 			break;
2242 
2243 		default:
2244 			bJustifyStd = sal_True;
2245 			break;
2246 	}
2247 
2248 	if ( nWhich )
2249 	{
2250 		aBoolItem.SetWhich( nWhich );
2251 		rSet.Put( aBoolItem );
2252 	}
2253 	else if ( bJustifyStd )
2254 	{
2255 		aBoolItem.SetValue( sal_False );
2256 		aBoolItem.SetWhich( SID_ALIGNTOP );	  	  rSet.Put( aBoolItem );
2257 		aBoolItem.SetWhich( SID_ALIGNBOTTOM );	  rSet.Put( aBoolItem );
2258 		aBoolItem.SetWhich( SID_ALIGNCENTERVER ); rSet.Put( aBoolItem );
2259 	}
2260 }
2261 
2262 
2263 //------------------------------------------------------------------
2264 
GetBorderState(SfxItemSet & rSet)2265 void ScFormatShell::GetBorderState( SfxItemSet& rSet )
2266 {
2267 	ScTabViewShell*	pTabViewShell  	= GetViewData()->GetViewShell();
2268 	SvxBoxItem		aBoxItem( ATTR_BORDER );
2269 	SvxBoxInfoItem	aInfoItem( ATTR_BORDER_INNER );
2270 
2271 	pTabViewShell->GetSelectionFrame( aBoxItem, aInfoItem );
2272 
2273 	if ( rSet.GetItemState( ATTR_BORDER ) != SFX_ITEM_UNKNOWN )
2274 		rSet.Put( aBoxItem );
2275 	if ( rSet.GetItemState( ATTR_BORDER_INNER ) != SFX_ITEM_UNKNOWN )
2276 		rSet.Put( aInfoItem );
2277 }
2278 
2279 //------------------------------------------------------------------
2280 
GetAlignState(SfxItemSet & rSet)2281 void ScFormatShell::GetAlignState( SfxItemSet& rSet )
2282 {
2283 	ScTabViewShell*	pTabViewShell  	= GetViewData()->GetViewShell();
2284 	const SfxItemSet& rAttrSet    = pTabViewShell->GetSelectionPattern()->GetItemSet();
2285 	SfxWhichIter	aIter(rSet);
2286 	sal_uInt16			nWhich = aIter.FirstWhich();
2287 
2288     SvxCellHorJustify eHAlign = SVX_HOR_JUSTIFY_STANDARD;
2289     bool bHasHAlign = rAttrSet.GetItemState( ATTR_HOR_JUSTIFY ) != SFX_ITEM_DONTCARE;
2290     if( bHasHAlign )
2291         eHAlign = (SvxCellHorJustify)((const SvxHorJustifyItem&) rAttrSet.Get( ATTR_HOR_JUSTIFY )).GetValue();
2292 
2293     SvxCellVerJustify eVAlign = SVX_VER_JUSTIFY_STANDARD;
2294     bool bHasVAlign = rAttrSet.GetItemState( ATTR_VER_JUSTIFY ) != SFX_ITEM_DONTCARE;
2295     if( bHasVAlign )
2296         eVAlign = (SvxCellVerJustify)((const SvxVerJustifyItem&) rAttrSet.Get( ATTR_VER_JUSTIFY )).GetValue();
2297 
2298 	while ( nWhich )
2299 	{
2300 		switch ( nWhich )
2301 		{
2302 			case SID_H_ALIGNCELL:
2303                 if ( bHasHAlign )
2304                     rSet.Put( SvxHorJustifyItem( eHAlign, nWhich ));
2305 			break;
2306 			case SID_V_ALIGNCELL:
2307                 if ( bHasVAlign )
2308                     rSet.Put( SvxVerJustifyItem( eVAlign, nWhich ));
2309 			break;
2310 
2311             // pseudo slots for Format menu
2312             case SID_ALIGN_ANY_HDEFAULT:
2313             case SID_ALIGN_ANY_LEFT:
2314             case SID_ALIGN_ANY_HCENTER:
2315             case SID_ALIGN_ANY_RIGHT:
2316             case SID_ALIGN_ANY_JUSTIFIED:
2317                 rSet.Put( SfxBoolItem( nWhich, bHasHAlign && (eHAlign == lclConvertSlotToHAlign( nWhich )) ) );
2318             break;
2319             case SID_ALIGN_ANY_VDEFAULT:
2320             case SID_ALIGN_ANY_TOP:
2321             case SID_ALIGN_ANY_VCENTER:
2322             case SID_ALIGN_ANY_BOTTOM:
2323                 rSet.Put( SfxBoolItem( nWhich, bHasVAlign && (eVAlign == lclConvertSlotToVAlign( nWhich )) ) );
2324             break;
2325 		}
2326 		nWhich = aIter.NextWhich();
2327 	}
2328 }
2329 
GetNumFormatState(SfxItemSet & rSet)2330 void ScFormatShell::GetNumFormatState( SfxItemSet& rSet )
2331 {
2332 	ScTabViewShell*	pTabViewShell  	= GetViewData()->GetViewShell();
2333 
2334     // ScViewData* pViewData   = GetViewData();
2335 	ScDocument* pDoc		= pViewData->GetDocument();
2336 
2337 	SfxWhichIter aIter(rSet);
2338 	sal_uInt16 nWhich = aIter.FirstWhich();
2339 	while ( nWhich )
2340 	{
2341 		switch ( nWhich )
2342 		{
2343 			case SID_NUMBER_FORMAT:
2344 				//{
2345 				//	String aFormatCode;			// bleibt leer, wenn dont-care
2346                 //
2347 				//	const SfxItemSet& rAttrSet  = pTabViewShell->GetSelectionPattern()->GetItemSet();
2348 				//	if ( rAttrSet.GetItemState( ATTR_VALUE_FORMAT ) != SFX_ITEM_DONTCARE )
2349 				//	{
2350 				//		sal_uLong nNumberFormat = ((const SfxUInt32Item&)rAttrSet.Get(
2351 				//									ATTR_VALUE_FORMAT )).GetValue();
2352                 //
2353 				//		SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
2354 				//		const SvNumberformat* pFormatEntry = pFormatter->GetEntry( nNumberFormat );
2355 				//		if ( pFormatEntry )
2356 				//			aFormatCode = pFormatEntry->GetFormatstring();
2357 				//	}
2358                 //
2359 				//	rSet.Put( SfxStringItem( nWhich, aFormatCode ) );
2360 				//}
2361 
2362                 // symphony version with format interpretation
2363 				{
2364 					const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet();
2365 
2366 					if(SFX_ITEM_DONTCARE != rAttrSet.GetItemState(ATTR_VALUE_FORMAT))
2367 					{
2368 						SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
2369 						sal_uInt32 nNumberFormat = ((const SfxUInt32Item&)rAttrSet.Get(ATTR_VALUE_FORMAT)).GetValue();
2370 						sal_Bool bThousand(false);
2371 						sal_Bool bNegRed(false);
2372 						sal_uInt16 nPrecision(0);
2373 						sal_uInt16 nLeadZeroes(0);
2374 
2375                         pFormatter->GetFormatSpecialInfo(nNumberFormat,bThousand, bNegRed, nPrecision, nLeadZeroes);
2376 						String aFormat;
2377 						static String sBreak = String::CreateFromAscii(",");
2378 						const String sThousand = String::CreateFromInt32(bThousand);
2379 						const String sNegRed = String::CreateFromInt32(bNegRed);
2380 						const String sPrecision = String::CreateFromInt32(nPrecision);
2381 						const String sLeadZeroes = String::CreateFromInt32(nLeadZeroes);
2382 
2383 						aFormat += sThousand;
2384 						aFormat += sBreak;
2385 						aFormat += sNegRed;
2386 						aFormat += sBreak;
2387 						aFormat += sPrecision;
2388 						aFormat += sBreak;
2389 						aFormat += sLeadZeroes;
2390 						aFormat += sBreak;
2391 
2392 						rSet.Put(SfxStringItem(nWhich, aFormat));
2393 					}
2394 					else
2395 					{
2396 						rSet.InvalidateItem( nWhich );
2397 					}
2398 				}
2399 				break;
2400 
2401 			case SID_NUMBER_TYPE_FORMAT:
2402 				{
2403 					sal_Int16 aFormatCode = -1;
2404 					const SfxItemSet& rAttrSet  = pTabViewShell->GetSelectionPattern()->GetItemSet();
2405 					if ( rAttrSet.GetItemState( ATTR_VALUE_FORMAT ) >= SFX_ITEM_AVAILABLE ) //Modify for more robust
2406 					{
2407 						SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
2408 						sal_uInt32 nNumberFormat = pTabViewShell->GetSelectionPattern()->GetNumberFormat( pFormatter );
2409 						const SvNumberformat* pFormatEntry = pFormatter->GetEntry( nNumberFormat );
2410 						bool bStandard = false;
2411 
2412 						if ( pFormatEntry )
2413 						{
2414 							aFormatCode = pFormatEntry->GetType();
2415 							bStandard = pFormatEntry->IsStandard();
2416 						}
2417 
2418                         switch(aFormatCode)
2419 						{
2420 						case NUMBERFORMAT_NUMBER:
2421 						case NUMBERFORMAT_NUMBER| NUMBERFORMAT_DEFINED:
2422 							//use format code and standard format code to judge whether it is General,
2423 							//if (nNumberFormat == nStandardNumberFormat)
2424 							if (bStandard)
2425 								aFormatCode = 0;
2426 							else
2427                                 aFormatCode = 1;
2428 							break;
2429 						case NUMBERFORMAT_PERCENT:
2430 						case NUMBERFORMAT_PERCENT| NUMBERFORMAT_DEFINED:
2431 							aFormatCode = 2;
2432 							break;
2433 						case NUMBERFORMAT_CURRENCY:
2434 						case NUMBERFORMAT_CURRENCY| NUMBERFORMAT_DEFINED:
2435 							aFormatCode = 3;
2436 							break;
2437 						case NUMBERFORMAT_DATE:
2438 						case NUMBERFORMAT_DATE| NUMBERFORMAT_DEFINED:
2439 							//Add
2440 						case NUMBERFORMAT_DATETIME:
2441 						case NUMBERFORMAT_DATETIME | NUMBERFORMAT_DEFINED:
2442 							aFormatCode = 4;
2443 							break;
2444 						case NUMBERFORMAT_TIME:
2445 						case NUMBERFORMAT_TIME| NUMBERFORMAT_DEFINED:
2446 							aFormatCode = 5;
2447 							break;
2448 						case NUMBERFORMAT_SCIENTIFIC:
2449 						case NUMBERFORMAT_SCIENTIFIC| NUMBERFORMAT_DEFINED:
2450 							aFormatCode = 6;
2451 							break;
2452 						case NUMBERFORMAT_FRACTION:
2453 						case NUMBERFORMAT_FRACTION| NUMBERFORMAT_DEFINED:
2454 							aFormatCode = 7;
2455 							break;
2456 						case NUMBERFORMAT_LOGICAL:
2457 						case NUMBERFORMAT_LOGICAL| NUMBERFORMAT_DEFINED:
2458 							aFormatCode = 8;
2459 							break;
2460 						case NUMBERFORMAT_TEXT:
2461 						case NUMBERFORMAT_TEXT| NUMBERFORMAT_DEFINED:
2462 							aFormatCode = 9;
2463 							break;
2464 						default:
2465 							aFormatCode = -1;	//for more roburst
2466 						}
2467 						if( aFormatCode == -1 )
2468 							rSet.InvalidateItem( nWhich );
2469 						else
2470 							rSet.Put( SfxInt16Item( nWhich, aFormatCode ) );
2471 					}
2472 					else
2473 					{
2474 						rSet.InvalidateItem( nWhich );
2475 					}
2476 
2477 				}
2478 				break;
2479 		}
2480 		nWhich = aIter.NextWhich();
2481 	}
2482 }
2483 
2484 
ExecuteTextDirection(SfxRequest & rReq)2485 void ScFormatShell::ExecuteTextDirection( SfxRequest& rReq )
2486 {
2487     ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
2488     pTabViewShell->HideListBox();               // Autofilter-DropDown-Listbox
2489     if ( GetViewData()->HasEditView( GetViewData()->GetActivePart() ) )
2490     {
2491         SC_MOD()->InputEnterHandler();
2492         pTabViewShell->UpdateInputHandler();
2493     }
2494 
2495     sal_uInt16 nSlot = rReq.GetSlot();
2496     switch( nSlot )
2497     {
2498         case SID_TEXTDIRECTION_LEFT_TO_RIGHT:
2499         case SID_TEXTDIRECTION_TOP_TO_BOTTOM:
2500         {
2501             sal_Bool bVert = (nSlot == SID_TEXTDIRECTION_TOP_TO_BOTTOM);
2502             ScPatternAttr aAttr( GetViewData()->GetDocument()->GetPool() );
2503             SfxItemSet& rItemSet = aAttr.GetItemSet();
2504             rItemSet.Put( SfxBoolItem( ATTR_STACKED, bVert ) );
2505             rItemSet.Put( SfxBoolItem( ATTR_VERTICAL_ASIAN, bVert ) );
2506             pTabViewShell->ApplySelectionPattern( aAttr );
2507             pTabViewShell->AdjustBlockHeight();
2508         }
2509         break;
2510 
2511         case SID_ATTR_PARA_LEFT_TO_RIGHT:
2512         case SID_ATTR_PARA_RIGHT_TO_LEFT:
2513         {
2514             SvxFrameDirection eDirection = ( nSlot == SID_ATTR_PARA_LEFT_TO_RIGHT ) ?
2515                                                 FRMDIR_HORI_LEFT_TOP : FRMDIR_HORI_RIGHT_TOP;
2516             pTabViewShell->ApplyAttr( SvxFrameDirectionItem( eDirection, ATTR_WRITINGDIR ) );
2517         }
2518         break;
2519     }
2520 }
2521 
GetTextDirectionState(SfxItemSet & rSet)2522 void ScFormatShell::GetTextDirectionState( SfxItemSet& rSet )
2523 {
2524     ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
2525     const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet();
2526 
2527     sal_Bool bVertDontCare =
2528         (rAttrSet.GetItemState( ATTR_VERTICAL_ASIAN ) == SFX_ITEM_DONTCARE) ||
2529         (rAttrSet.GetItemState( ATTR_STACKED ) == SFX_ITEM_DONTCARE);
2530     sal_Bool bLeftRight = !bVertDontCare &&
2531         !((const SfxBoolItem&) rAttrSet.Get( ATTR_STACKED )).GetValue();
2532     sal_Bool bTopBottom = !bVertDontCare && !bLeftRight &&
2533         ((const SfxBoolItem&) rAttrSet.Get( ATTR_VERTICAL_ASIAN )).GetValue();
2534 
2535     sal_Bool bBidiDontCare = (rAttrSet.GetItemState( ATTR_WRITINGDIR ) == SFX_ITEM_DONTCARE);
2536     EEHorizontalTextDirection eBidiDir = EE_HTEXTDIR_DEFAULT;
2537     if ( !bBidiDontCare )
2538     {
2539         SvxFrameDirection eCellDir = (SvxFrameDirection)((const SvxFrameDirectionItem&)
2540                                         rAttrSet.Get( ATTR_WRITINGDIR )).GetValue();
2541         if ( eCellDir == FRMDIR_ENVIRONMENT )
2542             eBidiDir = (EEHorizontalTextDirection)GetViewData()->GetDocument()->
2543                                 GetEditTextDirection( GetViewData()->GetTabNo() );
2544         else if ( eCellDir == FRMDIR_HORI_RIGHT_TOP )
2545             eBidiDir = EE_HTEXTDIR_R2L;
2546         else
2547             eBidiDir = EE_HTEXTDIR_L2R;
2548     }
2549 
2550 	SvtLanguageOptions	aLangOpt;
2551 	sal_Bool bDisableCTLFont = !aLangOpt.IsCTLFontEnabled();
2552 	sal_Bool bDisableVerticalText = !aLangOpt.IsVerticalTextEnabled();
2553 
2554     SfxWhichIter aIter( rSet );
2555     sal_uInt16 nWhich = aIter.FirstWhich();
2556     while( nWhich )
2557     {
2558         switch( nWhich )
2559         {
2560             case SID_TEXTDIRECTION_LEFT_TO_RIGHT:
2561             case SID_TEXTDIRECTION_TOP_TO_BOTTOM:
2562                 if ( bDisableVerticalText )
2563 					rSet.DisableItem( nWhich );
2564 				else
2565 				{
2566 					if( bVertDontCare )
2567 						rSet.InvalidateItem( nWhich );
2568 					else if ( nWhich == SID_TEXTDIRECTION_LEFT_TO_RIGHT )
2569 						rSet.Put( SfxBoolItem( nWhich, bLeftRight ) );
2570 					else
2571 						rSet.Put( SfxBoolItem( nWhich, bTopBottom ) );
2572 				}
2573             break;
2574 
2575             case SID_ATTR_PARA_LEFT_TO_RIGHT:
2576             case SID_ATTR_PARA_RIGHT_TO_LEFT:
2577 				if ( bDisableCTLFont )
2578 					rSet.DisableItem( nWhich );
2579 				else
2580 				{
2581 					if ( bTopBottom )
2582 						rSet.DisableItem( nWhich );
2583 					else if ( bBidiDontCare )
2584 						rSet.InvalidateItem( nWhich );
2585 					else if ( nWhich == SID_ATTR_PARA_LEFT_TO_RIGHT )
2586 						rSet.Put( SfxBoolItem( nWhich, eBidiDir == EE_HTEXTDIR_L2R ) );
2587 					else
2588 						rSet.Put( SfxBoolItem( nWhich, eBidiDir == EE_HTEXTDIR_R2L ) );
2589 				}
2590         }
2591         nWhich = aIter.NextWhich();
2592     }
2593 }
2594 
ExecFormatPaintbrush(SfxRequest & rReq)2595 void ScFormatShell::ExecFormatPaintbrush( SfxRequest& rReq )
2596 {
2597     ScViewFunc* pView = pViewData->GetView();
2598     if ( pView->HasPaintBrush() )
2599     {
2600         // cancel paintbrush mode
2601         pView->ResetBrushDocument();
2602     }
2603     else
2604     {
2605         sal_Bool bLock = sal_False;
2606         const SfxItemSet *pArgs = rReq.GetArgs();
2607         if( pArgs && pArgs->Count() >= 1 )
2608             bLock = static_cast<const SfxBoolItem&>(pArgs->Get(SID_FORMATPAINTBRUSH)).GetValue();
2609 
2610         // in case of multi selection, deselect all and use the cursor position
2611         ScRange aDummy;
2612         if ( pViewData->GetSimpleArea(aDummy) != SC_MARK_SIMPLE )
2613             pView->Unmark();
2614 
2615         ScDocument* pBrushDoc = new ScDocument( SCDOCMODE_CLIP );
2616         pView->CopyToClip( pBrushDoc, sal_False, sal_True );
2617         pView->SetBrushDocument( pBrushDoc, bLock );
2618     }
2619 }
2620 
StateFormatPaintbrush(SfxItemSet & rSet)2621 void ScFormatShell::StateFormatPaintbrush( SfxItemSet& rSet )
2622 {
2623     if ( pViewData->HasEditView( pViewData->GetActivePart() ) )
2624         rSet.DisableItem( SID_FORMATPAINTBRUSH );
2625     else
2626         rSet.Put( SfxBoolItem( SID_FORMATPAINTBRUSH, pViewData->GetView()->HasPaintBrush() ) );
2627 }
2628 
ExecViewOptions(SfxRequest & rReq)2629 void  ScFormatShell::ExecViewOptions( SfxRequest& rReq )
2630 {
2631 	ScTabViewShell*	pTabViewShell  		= GetViewData()->GetViewShell();
2632 	SfxBindings&		rBindings = pViewData->GetBindings();
2633 	const SfxItemSet*	pNewAttrs = rReq.GetArgs();
2634 
2635 	if ( pNewAttrs )
2636 	{
2637 		sal_uInt16 nSlot = rReq.GetSlot();
2638 
2639 		if( nSlot  == SID_SCGRIDSHOW)
2640 		{
2641 
2642 			ScViewData*				pViewData = pTabViewShell->GetViewData();
2643 			const ScViewOptions&	rOldOpt	  = pViewData->GetOptions();
2644 			ScDocShell*				pDocSh  = PTR_CAST(ScDocShell, SfxObjectShell::Current());
2645 			bool bState =	((const SfxBoolItem &)pNewAttrs->Get( pNewAttrs->GetPool()->GetWhich( nSlot ) )).GetValue();
2646 
2647 			if ( (bool)rOldOpt.GetOption( VOPT_GRID ) !=  bState)
2648 			{
2649 				ScViewOptions rNewOpt(rOldOpt);
2650 				rNewOpt.SetOption( VOPT_GRID,  bState);
2651 				pViewData->SetOptions( rNewOpt );
2652 				pViewData->GetDocument()->SetViewOptions( rNewOpt );
2653 				pDocSh->SetDocumentModified();
2654 				//add , write the change to sc view config
2655 				ScModule*			pScMod		= SC_MOD();
2656 				pScMod->SetViewOptions( rNewOpt );
2657 				//add end
2658 				rBindings.Invalidate( nSlot );
2659 			}
2660 		}
2661 	}
2662 
2663 }
2664 
GetViewOptions(SfxItemSet & rSet)2665 void  ScFormatShell::GetViewOptions( SfxItemSet& rSet )
2666 {
2667 	ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
2668 	if( pTabViewShell )
2669 	{
2670 		ScViewOptions	aViewOpt = pTabViewShell->GetViewData()->GetOptions();
2671 		rSet.ClearItem(SID_SCGRIDSHOW);
2672 		SfxBoolItem aItem( SID_SCGRIDSHOW, aViewOpt.GetOption( VOPT_GRID ) );
2673 		rSet.Put(aItem);
2674 	}
2675 }
2676 
2677 // eof
2678