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