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
10b3f79822SAndrew Rist *
11b3f79822SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12b3f79822SAndrew Rist *
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.
19b3f79822SAndrew Rist *
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
lclConvertSlotToHAlign(sal_uInt16 nSlot)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
lclConvertSlotToVAlign(sal_uInt16 nSlot)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
SFX_IMPL_INTERFACE(ScFormatShell,SfxShell,ScResId (SCSTR_FORMATSHELL))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
ScFormatShell(ScViewData * pData)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
~ScFormatShell()167cdf0e10cSrcweir ScFormatShell::~ScFormatShell()
168cdf0e10cSrcweir {
169cdf0e10cSrcweir }
170cdf0e10cSrcweir
171cdf0e10cSrcweir //------------------------------------------------------------------
172cdf0e10cSrcweir
GetStyleState(SfxItemSet & rSet)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
ExecuteStyle(SfxRequest & rReq)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
ExecuteNumFormat(SfxRequest & rReq)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:
9934e8031e0SArmin Le Grand //if ( pReqArgs )
9944e8031e0SArmin Le Grand //{
9954e8031e0SArmin Le Grand // const SfxPoolItem* pItem;
9964e8031e0SArmin Le Grand // if(pReqArgs->GetItemState(nSlot, sal_True, &pItem) == SFX_ITEM_SET)
9974e8031e0SArmin Le Grand // {
9984e8031e0SArmin Le Grand // String aCode = ((const SfxStringItem*)pItem)->GetValue();
9994e8031e0SArmin Le Grand // pTabViewShell->SetNumFmtByStr( aCode );
10004e8031e0SArmin Le Grand // }
10014e8031e0SArmin Le Grand //}
10024e8031e0SArmin Le Grand
10034e8031e0SArmin Le Grand // symphony version with format interpretation
10044e8031e0SArmin Le Grand if(pReqArgs)
1005cdf0e10cSrcweir {
1006cdf0e10cSrcweir const SfxPoolItem* pItem;
10074e8031e0SArmin Le Grand ScDocument* pDoc = pViewData->GetDocument();
10084e8031e0SArmin Le Grand SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
10094e8031e0SArmin Le Grand LanguageType eLanguage = ScGlobal::eLnge;
10104e8031e0SArmin Le Grand sal_Int16 eType = -1;
10114e8031e0SArmin Le Grand sal_uInt32 nCurrentNumberFormat;
10124e8031e0SArmin Le Grand
10134e8031e0SArmin Le Grand pDoc->GetNumberFormat(pViewData->GetCurX(), pViewData->GetCurY(), pViewData->GetTabNo(), nCurrentNumberFormat);
10144e8031e0SArmin Le Grand const SvNumberformat* pEntry = pFormatter->GetEntry(nCurrentNumberFormat);
10154e8031e0SArmin Le Grand
10164e8031e0SArmin Le Grand if(pEntry)
10174e8031e0SArmin Le Grand {
10184e8031e0SArmin Le Grand eLanguage = pEntry->GetLanguage();
10194e8031e0SArmin Le Grand eType = pEntry->GetType();
10204e8031e0SArmin Le Grand }
10214e8031e0SArmin Le Grand
10224e8031e0SArmin Le Grand //Just use eType to judge whether the command is fired for NUMBER/PERCENT/CURRENCY
10234e8031e0SArmin Le Grand //In sidebar, users can fire SID_NUMBER_FORMAT command by operating the related UI controls before they are disable
10244e8031e0SArmin Le Grand switch(eType)
10254e8031e0SArmin Le Grand {
10264e8031e0SArmin Le Grand case NUMBERFORMAT_ALL:
10274e8031e0SArmin Le Grand case NUMBERFORMAT_NUMBER:
10284e8031e0SArmin Le Grand case NUMBERFORMAT_NUMBER| NUMBERFORMAT_DEFINED:
10294e8031e0SArmin Le Grand case NUMBERFORMAT_PERCENT:
10304e8031e0SArmin Le Grand case NUMBERFORMAT_PERCENT| NUMBERFORMAT_DEFINED:
10314e8031e0SArmin Le Grand case NUMBERFORMAT_CURRENCY:
10324e8031e0SArmin Le Grand case NUMBERFORMAT_CURRENCY|NUMBERFORMAT_DEFINED:
10334e8031e0SArmin Le Grand eType = 0;
10344e8031e0SArmin Le Grand break;
10354e8031e0SArmin Le Grand default:
10364e8031e0SArmin Le Grand eType =-1;
10374e8031e0SArmin Le Grand }
10384e8031e0SArmin Le Grand
10394e8031e0SArmin Le Grand if(SFX_ITEM_SET == pReqArgs->GetItemState(nSlot, true, &pItem) && eType != -1)
1040cdf0e10cSrcweir {
1041cdf0e10cSrcweir String aCode = ((const SfxStringItem*)pItem)->GetValue();
10424e8031e0SArmin Le Grand sal_uInt16 aLen = aCode.Len();
10434e8031e0SArmin Le Grand String* sFormat = new String[4];
10444e8031e0SArmin Le Grand String sTmpStr = String::CreateFromAscii("");
10454e8031e0SArmin Le Grand sal_uInt16 nCount(0);
10464e8031e0SArmin Le Grand sal_uInt16 nStrCount(0);
10474e8031e0SArmin Le Grand
10484e8031e0SArmin Le Grand while(nCount < aLen)
10494e8031e0SArmin Le Grand {
10504e8031e0SArmin Le Grand sal_Unicode cChar = aCode.GetChar(nCount);
10514e8031e0SArmin Le Grand
10524e8031e0SArmin Le Grand if(cChar == sal_Unicode(','))
10534e8031e0SArmin Le Grand {
10544e8031e0SArmin Le Grand sFormat[nStrCount] = sTmpStr;
10554e8031e0SArmin Le Grand sTmpStr = String::CreateFromAscii("");
10564e8031e0SArmin Le Grand nStrCount++;
10574e8031e0SArmin Le Grand }
10584e8031e0SArmin Le Grand else
10594e8031e0SArmin Le Grand {
10604e8031e0SArmin Le Grand sTmpStr += cChar;
10614e8031e0SArmin Le Grand }
10624e8031e0SArmin Le Grand
10634e8031e0SArmin Le Grand nCount++;
10644e8031e0SArmin Le Grand
10654e8031e0SArmin Le Grand if(nStrCount > 3)
10664e8031e0SArmin Le Grand break;
10674e8031e0SArmin Le Grand }
10684e8031e0SArmin Le Grand
10694e8031e0SArmin Le Grand const sal_Bool bThousand = (sal_Bool)sFormat[0].ToInt32();
10704e8031e0SArmin Le Grand const sal_Bool bNegRed = (sal_Bool)sFormat[1].ToInt32();
10714e8031e0SArmin Le Grand const sal_uInt16 nPrecision = (sal_uInt16)sFormat[2].ToInt32();
10724e8031e0SArmin Le Grand const sal_uInt16 nLeadZeroes = (sal_uInt16)sFormat[3].ToInt32();
10734e8031e0SArmin Le Grand
10744e8031e0SArmin Le Grand pFormatter->GenerateFormat(
10754e8031e0SArmin Le Grand aCode,
10764e8031e0SArmin Le Grand nCurrentNumberFormat,//modify
10774e8031e0SArmin Le Grand eLanguage,
10784e8031e0SArmin Le Grand bThousand,
10794e8031e0SArmin Le Grand bNegRed,
10804e8031e0SArmin Le Grand nPrecision,
10814e8031e0SArmin Le Grand nLeadZeroes);
10824e8031e0SArmin Le Grand pTabViewShell->SetNumFmtByStr(aCode);
10834e8031e0SArmin 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
11074e8031e0SArmin Le Grand case SID_NUMBER_TYPE_FORMAT:
1108a549ba6fSAndre Fischer if ( pReqArgs )
1109a549ba6fSAndre Fischer {
1110a549ba6fSAndre Fischer const SfxPoolItem* pItem;
1111a549ba6fSAndre Fischer if ( pReqArgs->GetItemState( nSlot, sal_True, &pItem ) == SFX_ITEM_SET )
1112a549ba6fSAndre Fischer {
1113a549ba6fSAndre Fischer sal_uInt16 nFormat = ((SfxInt16Item *)pItem)->GetValue();
1114a549ba6fSAndre Fischer switch(nFormat)
1115a549ba6fSAndre Fischer {
1116a549ba6fSAndre Fischer case 0:
1117a549ba6fSAndre Fischer pTabViewShell->SetNumberFormat( NUMBERFORMAT_NUMBER); //Modify
1118a549ba6fSAndre Fischer break;
1119a549ba6fSAndre Fischer case 1:
1120a549ba6fSAndre Fischer pTabViewShell->SetNumberFormat( NUMBERFORMAT_NUMBER, 2 ); //Modify
1121a549ba6fSAndre Fischer break;
1122a549ba6fSAndre Fischer case 2:
1123a549ba6fSAndre Fischer pTabViewShell->SetNumberFormat( NUMBERFORMAT_PERCENT );
1124a549ba6fSAndre Fischer break;
1125a549ba6fSAndre Fischer case 3:
1126a549ba6fSAndre Fischer pTabViewShell->SetNumberFormat( NUMBERFORMAT_CURRENCY );
1127a549ba6fSAndre Fischer break;
1128a549ba6fSAndre Fischer case 4:
1129a549ba6fSAndre Fischer pTabViewShell->SetNumberFormat( NUMBERFORMAT_DATE );
1130a549ba6fSAndre Fischer break;
1131a549ba6fSAndre Fischer case 5:
1132a549ba6fSAndre Fischer pTabViewShell->SetNumberFormat( NUMBERFORMAT_TIME );
1133a549ba6fSAndre Fischer break;
1134a549ba6fSAndre Fischer case 6:
1135a549ba6fSAndre Fischer pTabViewShell->SetNumberFormat( NUMBERFORMAT_SCIENTIFIC );
1136a549ba6fSAndre Fischer break;
1137a549ba6fSAndre Fischer case 7:
1138a549ba6fSAndre Fischer pTabViewShell->SetNumberFormat( NUMBERFORMAT_FRACTION );
1139a549ba6fSAndre Fischer break;
1140a549ba6fSAndre Fischer case 8:
1141a549ba6fSAndre Fischer pTabViewShell->SetNumberFormat( NUMBERFORMAT_LOGICAL );
1142a549ba6fSAndre Fischer break;
1143a549ba6fSAndre Fischer case 9:
1144a549ba6fSAndre Fischer pTabViewShell->SetNumberFormat( NUMBERFORMAT_TEXT );
1145a549ba6fSAndre Fischer break;
1146a549ba6fSAndre Fischer default:
1147a549ba6fSAndre Fischer ;
1148a549ba6fSAndre Fischer }
1149a549ba6fSAndre Fischer rReq.Done();
1150a549ba6fSAndre Fischer }
1151a549ba6fSAndre Fischer }
1152a549ba6fSAndre Fischer break;
11534e8031e0SArmin Le Grand
11544e8031e0SArmin Le Grand default:
1155cdf0e10cSrcweir DBG_ERROR("falscher Slot bei ExecuteEdit");
1156cdf0e10cSrcweir break;
1157cdf0e10cSrcweir }
1158cdf0e10cSrcweir }
1159cdf0e10cSrcweir
1160cdf0e10cSrcweir
1161cdf0e10cSrcweir //------------------------------------------------------------------
1162cdf0e10cSrcweir
1163cdf0e10cSrcweir #define APPLY_HOR_JUSTIFY(j) \
1164cdf0e10cSrcweir { \
1165cdf0e10cSrcweir if ( !pHorJustify || (eHorJustify != (j) ) ) \
1166cdf0e10cSrcweir pTabViewShell->ApplyAttr( SvxHorJustifyItem( (j) ) ); \
1167cdf0e10cSrcweir else \
1168cdf0e10cSrcweir pTabViewShell->ApplyAttr( SvxHorJustifyItem( SVX_HOR_JUSTIFY_STANDARD ) ); \
1169cdf0e10cSrcweir }
1170cdf0e10cSrcweir
1171cdf0e10cSrcweir #define APPLY_VER_JUSTIFY(j) \
1172cdf0e10cSrcweir { \
1173cdf0e10cSrcweir if ( !pVerJustify || (eVerJustify != (j) ) ) \
1174cdf0e10cSrcweir pTabViewShell->ApplyAttr( SvxVerJustifyItem( (j) ) ); \
1175cdf0e10cSrcweir else \
1176cdf0e10cSrcweir pTabViewShell->ApplyAttr( SvxVerJustifyItem( SVX_VER_JUSTIFY_STANDARD ) ); \
1177cdf0e10cSrcweir }
1178cdf0e10cSrcweir
ExecuteAlignment(SfxRequest & rReq)1179cdf0e10cSrcweir void ScFormatShell::ExecuteAlignment( SfxRequest& rReq )
1180cdf0e10cSrcweir {
1181cdf0e10cSrcweir ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
1182cdf0e10cSrcweir SfxBindings& rBindings = pViewData->GetBindings();
1183cdf0e10cSrcweir const SfxItemSet* pSet = rReq.GetArgs();
1184cdf0e10cSrcweir sal_uInt16 nSlot = rReq.GetSlot();
1185cdf0e10cSrcweir
1186cdf0e10cSrcweir pTabViewShell->HideListBox(); // Autofilter-DropDown-Listbox
1187cdf0e10cSrcweir
1188cdf0e10cSrcweir switch( nSlot )
1189cdf0e10cSrcweir {
1190cdf0e10cSrcweir // pseudo slots for Format menu
1191cdf0e10cSrcweir case SID_ALIGN_ANY_HDEFAULT:
1192cdf0e10cSrcweir case SID_ALIGN_ANY_LEFT:
1193cdf0e10cSrcweir case SID_ALIGN_ANY_HCENTER:
1194cdf0e10cSrcweir case SID_ALIGN_ANY_RIGHT:
1195cdf0e10cSrcweir case SID_ALIGN_ANY_JUSTIFIED:
1196cdf0e10cSrcweir pTabViewShell->ApplyAttr( SvxHorJustifyItem( lclConvertSlotToHAlign( nSlot ), ATTR_HOR_JUSTIFY ) );
1197cdf0e10cSrcweir break;
1198cdf0e10cSrcweir case SID_ALIGN_ANY_VDEFAULT:
1199cdf0e10cSrcweir case SID_ALIGN_ANY_TOP:
1200cdf0e10cSrcweir case SID_ALIGN_ANY_VCENTER:
1201cdf0e10cSrcweir case SID_ALIGN_ANY_BOTTOM:
1202cdf0e10cSrcweir pTabViewShell->ApplyAttr( SvxVerJustifyItem( lclConvertSlotToVAlign( nSlot ), ATTR_VER_JUSTIFY ) );
1203cdf0e10cSrcweir break;
1204cdf0e10cSrcweir
1205cdf0e10cSrcweir default:
1206cdf0e10cSrcweir if( pSet )
1207cdf0e10cSrcweir {
1208cdf0e10cSrcweir const SfxPoolItem* pItem = NULL;
1209cdf0e10cSrcweir if( pSet->GetItemState(GetPool().GetWhich(nSlot), sal_True, &pItem ) == SFX_ITEM_SET )
1210cdf0e10cSrcweir {
1211cdf0e10cSrcweir
1212cdf0e10cSrcweir switch ( nSlot )
1213cdf0e10cSrcweir {
1214cdf0e10cSrcweir case SID_ATTR_ALIGN_HOR_JUSTIFY:
1215cdf0e10cSrcweir case SID_ATTR_ALIGN_VER_JUSTIFY:
1216cdf0e10cSrcweir case SID_ATTR_ALIGN_INDENT:
1217cdf0e10cSrcweir case SID_ATTR_ALIGN_HYPHENATION:
1218cdf0e10cSrcweir case SID_ATTR_ALIGN_DEGREES:
1219cdf0e10cSrcweir case SID_ATTR_ALIGN_LOCKPOS:
1220cdf0e10cSrcweir case SID_ATTR_ALIGN_MARGIN:
1221cdf0e10cSrcweir case SID_ATTR_ALIGN_STACKED:
1222cdf0e10cSrcweir pTabViewShell->ApplyAttr( *pItem );
1223cdf0e10cSrcweir break;
1224cdf0e10cSrcweir
1225cdf0e10cSrcweir case SID_H_ALIGNCELL:
1226cdf0e10cSrcweir {
1227cdf0e10cSrcweir SvxCellHorJustify eJust = (SvxCellHorJustify)((const SvxHorJustifyItem*)pItem)->GetValue();
1228cdf0e10cSrcweir // #i78476# update alignment of text in cell edit mode
1229cdf0e10cSrcweir pTabViewShell->UpdateInputHandlerCellAdjust( eJust );
1230cdf0e10cSrcweir pTabViewShell->ApplyAttr( SvxHorJustifyItem( eJust, ATTR_HOR_JUSTIFY ) );
1231cdf0e10cSrcweir }
1232cdf0e10cSrcweir break;
1233cdf0e10cSrcweir case SID_V_ALIGNCELL:
1234cdf0e10cSrcweir pTabViewShell->ApplyAttr( SvxVerJustifyItem( (SvxCellVerJustify)((const SvxVerJustifyItem*)pItem)->GetValue(), ATTR_VER_JUSTIFY ) );
1235cdf0e10cSrcweir break;
1236cdf0e10cSrcweir default:
1237cdf0e10cSrcweir DBG_ERROR( "ExecuteAlignment: invalid slot" );
1238cdf0e10cSrcweir return;
1239cdf0e10cSrcweir }
1240cdf0e10cSrcweir }
1241cdf0e10cSrcweir }
1242cdf0e10cSrcweir }
1243512ec161SZheng Fan rBindings.Invalidate( SID_ATTR_PARA_ADJUST_LEFT );
1244512ec161SZheng Fan rBindings.Invalidate( SID_ATTR_PARA_ADJUST_RIGHT );
1245512ec161SZheng Fan rBindings.Invalidate( SID_ATTR_PARA_ADJUST_BLOCK );
1246512ec161SZheng Fan rBindings.Invalidate( SID_ATTR_PARA_ADJUST_CENTER);
1247cdf0e10cSrcweir rBindings.Invalidate( SID_ALIGNLEFT );
1248cdf0e10cSrcweir rBindings.Invalidate( SID_ALIGNRIGHT );
1249cdf0e10cSrcweir rBindings.Invalidate( SID_ALIGNCENTERHOR );
1250cdf0e10cSrcweir rBindings.Invalidate( SID_ALIGNBLOCK );
1251cdf0e10cSrcweir rBindings.Invalidate( SID_ALIGNTOP );
1252cdf0e10cSrcweir rBindings.Invalidate( SID_ALIGNBOTTOM );
1253cdf0e10cSrcweir rBindings.Invalidate( SID_ALIGNCENTERVER );
1254cdf0e10cSrcweir rBindings.Invalidate( SID_V_ALIGNCELL );
1255cdf0e10cSrcweir rBindings.Invalidate( SID_H_ALIGNCELL );
1256cdf0e10cSrcweir // pseudo slots for Format menu
1257cdf0e10cSrcweir rBindings.Invalidate( SID_ALIGN_ANY_HDEFAULT );
1258cdf0e10cSrcweir rBindings.Invalidate( SID_ALIGN_ANY_LEFT );
1259cdf0e10cSrcweir rBindings.Invalidate( SID_ALIGN_ANY_HCENTER );
1260cdf0e10cSrcweir rBindings.Invalidate( SID_ALIGN_ANY_RIGHT );
1261cdf0e10cSrcweir rBindings.Invalidate( SID_ALIGN_ANY_JUSTIFIED );
1262cdf0e10cSrcweir rBindings.Invalidate( SID_ALIGN_ANY_VDEFAULT );
1263cdf0e10cSrcweir rBindings.Invalidate( SID_ALIGN_ANY_TOP );
1264cdf0e10cSrcweir rBindings.Invalidate( SID_ALIGN_ANY_VCENTER );
1265cdf0e10cSrcweir rBindings.Invalidate( SID_ALIGN_ANY_BOTTOM );
1266cdf0e10cSrcweir rBindings.Update();
1267cdf0e10cSrcweir
1268cdf0e10cSrcweir if( ! rReq.IsAPI() )
1269cdf0e10cSrcweir rReq.Done();
1270cdf0e10cSrcweir }
1271cdf0e10cSrcweir
ExecuteTextAttr(SfxRequest & rReq)1272cdf0e10cSrcweir void ScFormatShell::ExecuteTextAttr( SfxRequest& rReq )
1273cdf0e10cSrcweir {
1274cdf0e10cSrcweir ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
1275cdf0e10cSrcweir SfxBindings& rBindings = pViewData->GetBindings();
1276cdf0e10cSrcweir const ScPatternAttr* pAttrs = pTabViewShell->GetSelectionPattern();
1277cdf0e10cSrcweir const SfxItemSet* pSet = rReq.GetArgs();
1278cdf0e10cSrcweir sal_uInt16 nSlot = rReq.GetSlot();
1279cdf0e10cSrcweir SfxAllItemSet* pNewSet = 0;
1280cdf0e10cSrcweir
1281cdf0e10cSrcweir pTabViewShell->HideListBox(); // Autofilter-DropDown-Listbox
1282cdf0e10cSrcweir
1283cdf0e10cSrcweir if ( (nSlot == SID_ATTR_CHAR_WEIGHT)
1284cdf0e10cSrcweir ||(nSlot == SID_ATTR_CHAR_POSTURE)
1285cdf0e10cSrcweir ||(nSlot == SID_ATTR_CHAR_UNDERLINE)
1286cdf0e10cSrcweir ||(nSlot == SID_ULINE_VAL_NONE)
1287cdf0e10cSrcweir ||(nSlot == SID_ULINE_VAL_SINGLE)
1288cdf0e10cSrcweir ||(nSlot == SID_ULINE_VAL_DOUBLE)
1289cdf0e10cSrcweir ||(nSlot == SID_ULINE_VAL_DOTTED) )
1290cdf0e10cSrcweir {
1291cdf0e10cSrcweir pNewSet = new SfxAllItemSet( GetPool() );
1292cdf0e10cSrcweir
1293cdf0e10cSrcweir switch ( nSlot )
1294cdf0e10cSrcweir {
1295cdf0e10cSrcweir case SID_ATTR_CHAR_WEIGHT:
1296cdf0e10cSrcweir {
1297cdf0e10cSrcweir // #i78017 establish the same behaviour as in Writer
1298cdf0e10cSrcweir sal_uInt8 nScript = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX;
1299cdf0e10cSrcweir
1300cdf0e10cSrcweir SfxItemPool& rPool = GetPool();
1301cdf0e10cSrcweir SvxScriptSetItem aSetItem( nSlot, rPool );
1302cdf0e10cSrcweir if ( pSet )
1303cdf0e10cSrcweir aSetItem.PutItemForScriptType( nScript, pSet->Get( ATTR_FONT_WEIGHT ) );
1304cdf0e10cSrcweir else
1305cdf0e10cSrcweir {
1306cdf0e10cSrcweir // toggle manually
1307cdf0e10cSrcweir
1308cdf0e10cSrcweir FontWeight eWeight = WEIGHT_BOLD;
1309cdf0e10cSrcweir SvxScriptSetItem aOldSetItem( nSlot, rPool );
1310cdf0e10cSrcweir aOldSetItem.GetItemSet().Put( pAttrs->GetItemSet(), sal_False );
1311cdf0e10cSrcweir const SfxPoolItem* pCore = aOldSetItem.GetItemOfScript( nScript );
1312cdf0e10cSrcweir if ( pCore && ((const SvxWeightItem*)pCore)->GetWeight() == WEIGHT_BOLD )
1313cdf0e10cSrcweir eWeight = WEIGHT_NORMAL;
1314cdf0e10cSrcweir
1315cdf0e10cSrcweir aSetItem.PutItemForScriptType( nScript, SvxWeightItem( eWeight, ATTR_FONT_WEIGHT ) );
1316cdf0e10cSrcweir }
1317cdf0e10cSrcweir pTabViewShell->ApplyUserItemSet( aSetItem.GetItemSet() );
1318cdf0e10cSrcweir pNewSet->Put( aSetItem.GetItemSet(), sal_False );
1319cdf0e10cSrcweir }
1320cdf0e10cSrcweir break;
1321cdf0e10cSrcweir
1322cdf0e10cSrcweir case SID_ATTR_CHAR_POSTURE:
1323cdf0e10cSrcweir {
1324cdf0e10cSrcweir // #i78017 establish the same behaviour as in Writer
1325cdf0e10cSrcweir sal_uInt8 nScript = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX;
1326cdf0e10cSrcweir
1327cdf0e10cSrcweir SfxItemPool& rPool = GetPool();
1328cdf0e10cSrcweir SvxScriptSetItem aSetItem( nSlot, rPool );
1329cdf0e10cSrcweir if ( pSet )
1330cdf0e10cSrcweir aSetItem.PutItemForScriptType( nScript, pSet->Get( ATTR_FONT_POSTURE ) );
1331cdf0e10cSrcweir else
1332cdf0e10cSrcweir {
1333cdf0e10cSrcweir // toggle manually
1334cdf0e10cSrcweir
1335cdf0e10cSrcweir FontItalic eItalic = ITALIC_NORMAL;
1336cdf0e10cSrcweir SvxScriptSetItem aOldSetItem( nSlot, rPool );
1337cdf0e10cSrcweir aOldSetItem.GetItemSet().Put( pAttrs->GetItemSet(), sal_False );
1338cdf0e10cSrcweir const SfxPoolItem* pCore = aOldSetItem.GetItemOfScript( nScript );
1339cdf0e10cSrcweir if ( pCore && ((const SvxPostureItem*)pCore)->GetPosture() == ITALIC_NORMAL )
1340cdf0e10cSrcweir eItalic = ITALIC_NONE;
1341cdf0e10cSrcweir
1342cdf0e10cSrcweir aSetItem.PutItemForScriptType( nScript, SvxPostureItem( eItalic, ATTR_FONT_POSTURE ) );
1343cdf0e10cSrcweir }
1344cdf0e10cSrcweir pTabViewShell->ApplyUserItemSet( aSetItem.GetItemSet() );
1345cdf0e10cSrcweir pNewSet->Put( aSetItem.GetItemSet(), sal_False );
1346cdf0e10cSrcweir }
1347cdf0e10cSrcweir break;
1348cdf0e10cSrcweir
1349cdf0e10cSrcweir case SID_ATTR_CHAR_UNDERLINE:
1350cdf0e10cSrcweir {
1351cdf0e10cSrcweir FontUnderline eUnderline;
1352cdf0e10cSrcweir
1353cdf0e10cSrcweir if( pSet )
1354cdf0e10cSrcweir {
1355cdf0e10cSrcweir const SfxPoolItem& rUnderline = pSet->Get( ATTR_FONT_UNDERLINE );
1356cdf0e10cSrcweir
1357cdf0e10cSrcweir if( rUnderline.ISA(SvxUnderlineItem) )
1358cdf0e10cSrcweir {
1359cdf0e10cSrcweir pTabViewShell->ApplyAttr( rUnderline );
1360cdf0e10cSrcweir pNewSet->Put( rUnderline,rUnderline.Which() );
1361cdf0e10cSrcweir }
1362cdf0e10cSrcweir else if ( rUnderline.ISA(SvxTextLineItem) )
1363cdf0e10cSrcweir {
1364cdf0e10cSrcweir // #i106580# also allow SvxTextLineItem (base class of SvxUnderlineItem)
1365cdf0e10cSrcweir const SvxTextLineItem& rTextLineItem = static_cast<const SvxTextLineItem&>(rUnderline);
1366cdf0e10cSrcweir SvxUnderlineItem aNewItem( rTextLineItem.GetLineStyle(), rTextLineItem.Which() );
1367cdf0e10cSrcweir aNewItem.SetColor( rTextLineItem.GetColor() );
1368cdf0e10cSrcweir pTabViewShell->ApplyAttr( aNewItem );
1369cdf0e10cSrcweir pNewSet->Put( aNewItem, aNewItem.Which() );
1370cdf0e10cSrcweir }
1371cdf0e10cSrcweir }
1372cdf0e10cSrcweir else
1373cdf0e10cSrcweir {
1374cdf0e10cSrcweir SvxUnderlineItem aUnderline( (const SvxUnderlineItem&)
1375cdf0e10cSrcweir pAttrs->GetItem(
1376cdf0e10cSrcweir ATTR_FONT_UNDERLINE ) );
1377cdf0e10cSrcweir eUnderline = (UNDERLINE_NONE != aUnderline.GetLineStyle())
1378cdf0e10cSrcweir ? UNDERLINE_NONE
1379cdf0e10cSrcweir : UNDERLINE_SINGLE;
1380cdf0e10cSrcweir aUnderline.SetLineStyle( eUnderline );
1381cdf0e10cSrcweir pTabViewShell->ApplyAttr( aUnderline );
1382cdf0e10cSrcweir pNewSet->Put( aUnderline,aUnderline.Which() );
1383cdf0e10cSrcweir }
1384cdf0e10cSrcweir }
1385cdf0e10cSrcweir break;
1386cdf0e10cSrcweir
1387cdf0e10cSrcweir case SID_ULINE_VAL_NONE:
1388cdf0e10cSrcweir pTabViewShell->ApplyAttr( SvxUnderlineItem( UNDERLINE_NONE, ATTR_FONT_UNDERLINE ) );
1389cdf0e10cSrcweir break;
1390cdf0e10cSrcweir case SID_ULINE_VAL_SINGLE: // Toggles
1391cdf0e10cSrcweir case SID_ULINE_VAL_DOUBLE:
1392cdf0e10cSrcweir case SID_ULINE_VAL_DOTTED:
1393cdf0e10cSrcweir {
1394cdf0e10cSrcweir FontUnderline eOld = ((const SvxUnderlineItem&)
1395cdf0e10cSrcweir pAttrs->GetItem(ATTR_FONT_UNDERLINE)).GetLineStyle();
1396cdf0e10cSrcweir FontUnderline eNew = eOld;
1397cdf0e10cSrcweir switch (nSlot)
1398cdf0e10cSrcweir {
1399cdf0e10cSrcweir case SID_ULINE_VAL_SINGLE:
1400cdf0e10cSrcweir eNew = ( eOld == UNDERLINE_SINGLE ) ? UNDERLINE_NONE : UNDERLINE_SINGLE;
1401cdf0e10cSrcweir break;
1402cdf0e10cSrcweir case SID_ULINE_VAL_DOUBLE:
1403cdf0e10cSrcweir eNew = ( eOld == UNDERLINE_DOUBLE ) ? UNDERLINE_NONE : UNDERLINE_DOUBLE;
1404cdf0e10cSrcweir break;
1405cdf0e10cSrcweir case SID_ULINE_VAL_DOTTED:
1406cdf0e10cSrcweir eNew = ( eOld == UNDERLINE_DOTTED ) ? UNDERLINE_NONE : UNDERLINE_DOTTED;
1407cdf0e10cSrcweir break;
1408cdf0e10cSrcweir }
1409cdf0e10cSrcweir pTabViewShell->ApplyAttr( SvxUnderlineItem( eNew, ATTR_FONT_UNDERLINE ) );
1410cdf0e10cSrcweir }
1411cdf0e10cSrcweir break;
1412cdf0e10cSrcweir
1413cdf0e10cSrcweir default:
1414cdf0e10cSrcweir break;
1415cdf0e10cSrcweir }
1416cdf0e10cSrcweir rBindings.Invalidate( nSlot );
1417cdf0e10cSrcweir }
1418cdf0e10cSrcweir else
1419cdf0e10cSrcweir {
1420cdf0e10cSrcweir /*
1421cdf0e10cSrcweir * "Selbstgemachte" RadioButton-Funktionalitaet
1422cdf0e10cSrcweir * Beim Toggle gibt es den Standard-State, d.h. kein
1423cdf0e10cSrcweir * Button ist gedrueckt
1424cdf0e10cSrcweir */
1425cdf0e10cSrcweir
1426cdf0e10cSrcweir const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet();
1427cdf0e10cSrcweir const SfxPoolItem* pItem = NULL;
1428cdf0e10cSrcweir const SvxHorJustifyItem* pHorJustify = NULL;
1429cdf0e10cSrcweir const SvxVerJustifyItem* pVerJustify = NULL;
1430cdf0e10cSrcweir SvxCellHorJustify eHorJustify = SVX_HOR_JUSTIFY_STANDARD;
1431cdf0e10cSrcweir SvxCellVerJustify eVerJustify = SVX_VER_JUSTIFY_STANDARD;
1432cdf0e10cSrcweir
1433cdf0e10cSrcweir if (rAttrSet.GetItemState(ATTR_HOR_JUSTIFY, sal_True,&pItem ) == SFX_ITEM_SET)
1434cdf0e10cSrcweir {
1435cdf0e10cSrcweir pHorJustify = (const SvxHorJustifyItem*)pItem;
1436cdf0e10cSrcweir eHorJustify = SvxCellHorJustify( pHorJustify->GetValue() );
1437cdf0e10cSrcweir }
1438cdf0e10cSrcweir if (rAttrSet.GetItemState(ATTR_VER_JUSTIFY, sal_True,&pItem ) == SFX_ITEM_SET)
1439cdf0e10cSrcweir {
1440cdf0e10cSrcweir pVerJustify = (const SvxVerJustifyItem*)pItem;
1441cdf0e10cSrcweir eVerJustify = SvxCellVerJustify( pVerJustify->GetValue() );
1442cdf0e10cSrcweir }
1443cdf0e10cSrcweir
1444cdf0e10cSrcweir switch ( nSlot )
1445cdf0e10cSrcweir {
1446cdf0e10cSrcweir case SID_ALIGNLEFT:
1447cdf0e10cSrcweir rReq.SetSlot( SID_H_ALIGNCELL );
1448cdf0e10cSrcweir rReq.AppendItem( SvxHorJustifyItem(
1449cdf0e10cSrcweir !pHorJustify || (eHorJustify != SVX_HOR_JUSTIFY_LEFT) ?
1450cdf0e10cSrcweir SVX_HOR_JUSTIFY_LEFT : SVX_HOR_JUSTIFY_STANDARD, SID_H_ALIGNCELL ) );
1451cdf0e10cSrcweir ExecuteSlot( rReq, GetInterface() );
1452cdf0e10cSrcweir return;
1453cdf0e10cSrcweir // APPLY_HOR_JUSTIFY( SVX_HOR_JUSTIFY_LEFT );
1454cdf0e10cSrcweir //break;
1455cdf0e10cSrcweir
1456cdf0e10cSrcweir case SID_ALIGNRIGHT:
1457cdf0e10cSrcweir rReq.SetSlot( SID_H_ALIGNCELL );
1458cdf0e10cSrcweir rReq.AppendItem( SvxHorJustifyItem(
1459cdf0e10cSrcweir !pHorJustify || (eHorJustify != SVX_HOR_JUSTIFY_RIGHT) ?
1460cdf0e10cSrcweir SVX_HOR_JUSTIFY_RIGHT : SVX_HOR_JUSTIFY_STANDARD, SID_H_ALIGNCELL ) );
1461cdf0e10cSrcweir ExecuteSlot( rReq, GetInterface() );
1462cdf0e10cSrcweir return;
1463cdf0e10cSrcweir // APPLY_HOR_JUSTIFY( SVX_HOR_JUSTIFY_RIGHT );
1464cdf0e10cSrcweir //break;
1465cdf0e10cSrcweir
1466cdf0e10cSrcweir case SID_ALIGNCENTERHOR:
1467cdf0e10cSrcweir rReq.SetSlot( SID_H_ALIGNCELL );
1468cdf0e10cSrcweir rReq.AppendItem( SvxHorJustifyItem(
1469cdf0e10cSrcweir !pHorJustify || (eHorJustify != SVX_HOR_JUSTIFY_CENTER) ?
1470cdf0e10cSrcweir SVX_HOR_JUSTIFY_CENTER : SVX_HOR_JUSTIFY_STANDARD, SID_H_ALIGNCELL ) );
1471cdf0e10cSrcweir ExecuteSlot( rReq, GetInterface() );
1472cdf0e10cSrcweir return;
1473cdf0e10cSrcweir // APPLY_HOR_JUSTIFY( SVX_HOR_JUSTIFY_CENTER );
1474cdf0e10cSrcweir //break;
1475cdf0e10cSrcweir
1476cdf0e10cSrcweir case SID_ALIGNBLOCK:
1477cdf0e10cSrcweir rReq.SetSlot( SID_H_ALIGNCELL );
1478cdf0e10cSrcweir rReq.AppendItem( SvxHorJustifyItem(
1479cdf0e10cSrcweir !pHorJustify || (eHorJustify != SVX_HOR_JUSTIFY_BLOCK) ?
1480cdf0e10cSrcweir SVX_HOR_JUSTIFY_BLOCK : SVX_HOR_JUSTIFY_STANDARD, SID_H_ALIGNCELL ) );
1481cdf0e10cSrcweir ExecuteSlot( rReq, GetInterface() );
1482cdf0e10cSrcweir return;
1483cdf0e10cSrcweir // APPLY_HOR_JUSTIFY( SVX_HOR_JUSTIFY_BLOCK );
1484cdf0e10cSrcweir //break;
1485cdf0e10cSrcweir
1486cdf0e10cSrcweir case SID_ALIGNTOP:
1487cdf0e10cSrcweir rReq.SetSlot( SID_V_ALIGNCELL );
1488cdf0e10cSrcweir rReq.AppendItem( SvxVerJustifyItem(
1489cdf0e10cSrcweir !pVerJustify || (eVerJustify != SVX_VER_JUSTIFY_TOP) ?
1490cdf0e10cSrcweir SVX_VER_JUSTIFY_TOP : SVX_VER_JUSTIFY_STANDARD, SID_V_ALIGNCELL ) );
1491cdf0e10cSrcweir ExecuteSlot( rReq, GetInterface() );
1492cdf0e10cSrcweir return;
1493cdf0e10cSrcweir // APPLY_VER_JUSTIFY( SVX_VER_JUSTIFY_TOP );
1494cdf0e10cSrcweir //break;
1495cdf0e10cSrcweir
1496cdf0e10cSrcweir case SID_ALIGNBOTTOM:
1497cdf0e10cSrcweir rReq.SetSlot( SID_V_ALIGNCELL );
1498cdf0e10cSrcweir rReq.AppendItem( SvxVerJustifyItem(
1499cdf0e10cSrcweir !pVerJustify || (eVerJustify != SVX_VER_JUSTIFY_BOTTOM) ?
1500cdf0e10cSrcweir SVX_VER_JUSTIFY_BOTTOM : SVX_VER_JUSTIFY_STANDARD, SID_V_ALIGNCELL ) );
1501cdf0e10cSrcweir ExecuteSlot( rReq, GetInterface() );
1502cdf0e10cSrcweir return;
1503cdf0e10cSrcweir // APPLY_VER_JUSTIFY( SVX_VER_JUSTIFY_BOTTOM );
1504cdf0e10cSrcweir //break;
1505cdf0e10cSrcweir
1506cdf0e10cSrcweir case SID_ALIGNCENTERVER:
1507cdf0e10cSrcweir rReq.SetSlot( SID_V_ALIGNCELL );
1508cdf0e10cSrcweir rReq.AppendItem( SvxVerJustifyItem(
1509cdf0e10cSrcweir !pVerJustify || (eVerJustify != SVX_VER_JUSTIFY_CENTER) ?
1510cdf0e10cSrcweir SVX_VER_JUSTIFY_CENTER : SVX_VER_JUSTIFY_STANDARD, SID_V_ALIGNCELL ) );
1511cdf0e10cSrcweir ExecuteSlot( rReq, GetInterface() );
1512cdf0e10cSrcweir return;
1513cdf0e10cSrcweir // APPLY_VER_JUSTIFY( SVX_VER_JUSTIFY_CENTER );
1514cdf0e10cSrcweir //break;
1515cdf0e10cSrcweir
1516cdf0e10cSrcweir default:
1517cdf0e10cSrcweir break;
1518cdf0e10cSrcweir }
1519cdf0e10cSrcweir
1520cdf0e10cSrcweir }
1521cdf0e10cSrcweir
1522cdf0e10cSrcweir rBindings.Update();
1523cdf0e10cSrcweir // rReq.Done();
1524cdf0e10cSrcweir
1525cdf0e10cSrcweir if( pNewSet )
1526cdf0e10cSrcweir {
1527cdf0e10cSrcweir rReq.Done( *pNewSet );
1528cdf0e10cSrcweir delete pNewSet;
1529cdf0e10cSrcweir }
1530cdf0e10cSrcweir else
1531cdf0e10cSrcweir {
1532cdf0e10cSrcweir rReq.Done();
1533cdf0e10cSrcweir }
1534cdf0e10cSrcweir
1535cdf0e10cSrcweir }
1536cdf0e10cSrcweir
1537cdf0e10cSrcweir #undef APPLY_HOR_JUSTIFY
1538cdf0e10cSrcweir #undef APPLY_VER_JUSTIFY
1539cdf0e10cSrcweir
1540cdf0e10cSrcweir //------------------------------------------------------------------
1541cdf0e10cSrcweir
ExecuteAttr(SfxRequest & rReq)1542cdf0e10cSrcweir void ScFormatShell::ExecuteAttr( SfxRequest& rReq )
1543cdf0e10cSrcweir {
1544cdf0e10cSrcweir ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
1545cdf0e10cSrcweir SfxBindings& rBindings = pViewData->GetBindings();
1546cdf0e10cSrcweir const SfxItemSet* pNewAttrs = rReq.GetArgs();
1547cdf0e10cSrcweir
1548cdf0e10cSrcweir pTabViewShell->HideListBox(); // Autofilter-DropDown-Listbox
1549cdf0e10cSrcweir
1550cdf0e10cSrcweir if ( !pNewAttrs )
1551cdf0e10cSrcweir {
1552cdf0e10cSrcweir sal_uInt16 nSlot = rReq.GetSlot();
1553cdf0e10cSrcweir
1554cdf0e10cSrcweir switch ( nSlot )
1555cdf0e10cSrcweir {
1556cdf0e10cSrcweir case SID_ATTR_CHAR_FONT:
1557cdf0e10cSrcweir case SID_ATTR_CHAR_FONTHEIGHT:
1558cdf0e10cSrcweir pTabViewShell->ExecuteCellFormatDlg( rReq, TP_FONT ); // wenn ToolBar vertikal
1559cdf0e10cSrcweir break;
1560cdf0e10cSrcweir
1561cdf0e10cSrcweir case SID_ATTR_ALIGN_LINEBREAK: // ohne Parameter als Toggle
1562cdf0e10cSrcweir {
1563cdf0e10cSrcweir const ScPatternAttr* pAttrs = pTabViewShell->GetSelectionPattern();
1564cdf0e10cSrcweir sal_Bool bOld = ((const SfxBoolItem&)pAttrs->GetItem(ATTR_LINEBREAK)).GetValue();
1565cdf0e10cSrcweir SfxBoolItem aBreakItem( ATTR_LINEBREAK, !bOld );
1566cdf0e10cSrcweir pTabViewShell->ApplyAttr( aBreakItem );
1567cdf0e10cSrcweir
1568cdf0e10cSrcweir SfxAllItemSet aNewSet( GetPool() );
1569cdf0e10cSrcweir aNewSet.Put( aBreakItem,aBreakItem.Which() );
1570cdf0e10cSrcweir rReq.Done( aNewSet );
1571cdf0e10cSrcweir
1572cdf0e10cSrcweir rBindings.Invalidate( nSlot );
1573cdf0e10cSrcweir }
1574cdf0e10cSrcweir break;
1575cdf0e10cSrcweir
1576cdf0e10cSrcweir case SID_BACKGROUND_COLOR:
1577cdf0e10cSrcweir {
1578cdf0e10cSrcweir // SID_BACKGROUND_COLOR without arguments -> set transparent background
1579cdf0e10cSrcweir
1580cdf0e10cSrcweir SvxBrushItem aBrushItem( (const SvxBrushItem&)
1581cdf0e10cSrcweir pTabViewShell->GetSelectionPattern()->
1582cdf0e10cSrcweir GetItem( ATTR_BACKGROUND ) );
1583cdf0e10cSrcweir
1584cdf0e10cSrcweir aBrushItem.SetColor( COL_TRANSPARENT );
1585cdf0e10cSrcweir
1586cdf0e10cSrcweir pTabViewShell->ApplyAttr( aBrushItem );
1587cdf0e10cSrcweir }
1588cdf0e10cSrcweir break;
1589cdf0e10cSrcweir }
1590cdf0e10cSrcweir }
1591cdf0e10cSrcweir else
1592cdf0e10cSrcweir {
1593cdf0e10cSrcweir sal_uInt16 nSlot = rReq.GetSlot();
1594cdf0e10cSrcweir
1595cdf0e10cSrcweir switch ( nSlot )
1596cdf0e10cSrcweir {
1597cdf0e10cSrcweir case SID_ATTR_CHAR_OVERLINE:
1598cdf0e10cSrcweir case SID_ATTR_CHAR_STRIKEOUT:
1599cdf0e10cSrcweir case SID_ATTR_ALIGN_LINEBREAK:
1600cdf0e10cSrcweir case SID_ATTR_CHAR_COLOR:
1601cdf0e10cSrcweir case SID_ATTR_CHAR_CONTOUR:
1602cdf0e10cSrcweir case SID_ATTR_CHAR_SHADOWED:
1603cdf0e10cSrcweir case SID_ATTR_CHAR_RELIEF:
1604cdf0e10cSrcweir case SID_SCATTR_PROTECTION :
1605cdf0e10cSrcweir pTabViewShell->ApplyAttr( pNewAttrs->Get( pNewAttrs->GetPool()->GetWhich( nSlot ) ) );
1606cdf0e10cSrcweir rBindings.Invalidate( nSlot );
1607cdf0e10cSrcweir rBindings.Update( nSlot );
1608cdf0e10cSrcweir break;
1609cdf0e10cSrcweir
1610cdf0e10cSrcweir case SID_ATTR_CHAR_FONT:
1611cdf0e10cSrcweir case SID_ATTR_CHAR_FONTHEIGHT:
1612cdf0e10cSrcweir {
1613cdf0e10cSrcweir // #i78017 establish the same behaviour as in Writer
1614cdf0e10cSrcweir sal_uInt8 nScript = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX;
1615cdf0e10cSrcweir if (nSlot == SID_ATTR_CHAR_FONT)
1616cdf0e10cSrcweir nScript = pTabViewShell->GetSelectionScriptType();
1617cdf0e10cSrcweir
1618cdf0e10cSrcweir SfxItemPool& rPool = GetPool();
1619cdf0e10cSrcweir SvxScriptSetItem aSetItem( nSlot, rPool );
1620cdf0e10cSrcweir sal_uInt16 nWhich = rPool.GetWhich( nSlot );
1621cdf0e10cSrcweir aSetItem.PutItemForScriptType( nScript, pNewAttrs->Get( nWhich ) );
1622cdf0e10cSrcweir
1623cdf0e10cSrcweir pTabViewShell->ApplyUserItemSet( aSetItem.GetItemSet() );
1624cdf0e10cSrcweir
1625cdf0e10cSrcweir rBindings.Invalidate( nSlot );
1626cdf0e10cSrcweir rBindings.Update( nSlot );
1627cdf0e10cSrcweir }
1628cdf0e10cSrcweir break;
1629cdf0e10cSrcweir
1630cdf0e10cSrcweir case SID_FRAME_LINESTYLE:
1631cdf0e10cSrcweir {
1632cdf0e10cSrcweir // Default-Linie aktualisieren
1633cdf0e10cSrcweir const SvxBorderLine* pLine =
1634cdf0e10cSrcweir ((const SvxLineItem&)
1635cdf0e10cSrcweir pNewAttrs->Get( SID_FRAME_LINESTYLE )).
1636cdf0e10cSrcweir GetLine();
1637cdf0e10cSrcweir
1638cdf0e10cSrcweir if ( pLine )
1639cdf0e10cSrcweir {
1640cdf0e10cSrcweir SvxBorderLine* pDefLine = pTabViewShell->GetDefaultFrameLine();
1641cdf0e10cSrcweir
1642cdf0e10cSrcweir if ( pDefLine )
1643cdf0e10cSrcweir {
1644cdf0e10cSrcweir pDefLine->SetOutWidth( pLine->GetOutWidth() );
1645cdf0e10cSrcweir pDefLine->SetInWidth ( pLine->GetInWidth() );
1646cdf0e10cSrcweir pDefLine->SetDistance( pLine->GetDistance() );
1647cdf0e10cSrcweir pTabViewShell->SetSelectionFrameLines( pDefLine, sal_False );
1648cdf0e10cSrcweir }
1649cdf0e10cSrcweir else
1650cdf0e10cSrcweir {
1651cdf0e10cSrcweir pTabViewShell->SetDefaultFrameLine( pLine );
1652cdf0e10cSrcweir pTabViewShell->GetDefaultFrameLine()->SetColor( COL_BLACK );
1653cdf0e10cSrcweir pTabViewShell->SetSelectionFrameLines( pLine, sal_False );
1654cdf0e10cSrcweir }
1655cdf0e10cSrcweir }
1656cdf0e10cSrcweir else
1657cdf0e10cSrcweir {
1658cdf0e10cSrcweir Color aColorBlack( COL_BLACK );
1659cdf0e10cSrcweir SvxBorderLine aDefLine( &aColorBlack, 20, 0, 0 );
1660cdf0e10cSrcweir pTabViewShell->SetDefaultFrameLine( &aDefLine );
1661cdf0e10cSrcweir pTabViewShell->SetSelectionFrameLines( NULL, sal_False );
1662cdf0e10cSrcweir }
1663cdf0e10cSrcweir }
1664cdf0e10cSrcweir break;
1665cdf0e10cSrcweir
1666cdf0e10cSrcweir case SID_FRAME_LINECOLOR:
1667cdf0e10cSrcweir {
1668cdf0e10cSrcweir SvxBorderLine* pDefLine = pTabViewShell->GetDefaultFrameLine();
1669cdf0e10cSrcweir const Color& rColor = ((const SvxColorItem&)
1670cdf0e10cSrcweir pNewAttrs->Get( SID_FRAME_LINECOLOR )).
1671cdf0e10cSrcweir GetValue();
1672cdf0e10cSrcweir
1673cdf0e10cSrcweir // Default-Linie aktualisieren
1674cdf0e10cSrcweir if ( pDefLine )
1675cdf0e10cSrcweir {
1676cdf0e10cSrcweir pDefLine->SetColor( rColor );
1677cdf0e10cSrcweir pTabViewShell->SetSelectionFrameLines( pDefLine, sal_True );
1678cdf0e10cSrcweir }
1679cdf0e10cSrcweir else
1680cdf0e10cSrcweir {
1681cdf0e10cSrcweir SvxBorderLine aDefLine( &rColor, 20, 0, 0 );
1682cdf0e10cSrcweir pTabViewShell->SetDefaultFrameLine( &aDefLine );
1683cdf0e10cSrcweir pTabViewShell->SetSelectionFrameLines( &aDefLine, sal_False );
1684cdf0e10cSrcweir }
1685cdf0e10cSrcweir }
1686cdf0e10cSrcweir break;
1687cdf0e10cSrcweir
1688cdf0e10cSrcweir case SID_ATTR_BORDER_OUTER:
1689cdf0e10cSrcweir case SID_ATTR_BORDER:
1690cdf0e10cSrcweir {
1691cdf0e10cSrcweir SvxBorderLine* pDefLine = pTabViewShell->GetDefaultFrameLine();
1692cdf0e10cSrcweir const ScPatternAttr* pOldAttrs = pTabViewShell->GetSelectionPattern();
1693cdf0e10cSrcweir ScDocument* pDoc = GetViewData()->GetDocument();
1694cdf0e10cSrcweir SfxItemSet* pOldSet =
1695cdf0e10cSrcweir new SfxItemSet(
1696cdf0e10cSrcweir *(pDoc->GetPool()),
1697cdf0e10cSrcweir ATTR_PATTERN_START,
1698cdf0e10cSrcweir ATTR_PATTERN_END );
1699cdf0e10cSrcweir SfxItemSet* pNewSet =
1700cdf0e10cSrcweir new SfxItemSet(
1701cdf0e10cSrcweir *(pDoc->GetPool()),
1702cdf0e10cSrcweir ATTR_PATTERN_START,
1703cdf0e10cSrcweir ATTR_PATTERN_END );
1704cdf0e10cSrcweir const SfxPoolItem& rBorderAttr =
1705cdf0e10cSrcweir pOldAttrs->GetItemSet().
1706cdf0e10cSrcweir Get( ATTR_BORDER );
1707cdf0e10cSrcweir
1708cdf0e10cSrcweir // Border-Items vom Controller auswerten:
1709cdf0e10cSrcweir const SfxPoolItem* pItem = 0;
1710cdf0e10cSrcweir
1711cdf0e10cSrcweir if ( pNewAttrs->GetItemState( ATTR_BORDER, sal_True, &pItem )
1712cdf0e10cSrcweir == SFX_ITEM_SET )
1713cdf0e10cSrcweir {
1714cdf0e10cSrcweir // #100959# The SvxFrameToolBoxControl toolbox controller uses a default
1715cdf0e10cSrcweir // SvxBorderLine (all widths 0) to mark the lines that should be set.
1716cdf0e10cSrcweir // Macro recording uses a SvxBoxItem with the real values (OutWidth > 0)
1717cdf0e10cSrcweir // or NULL pointers for no lines.
1718cdf0e10cSrcweir // -> Substitute existing lines with pDefLine only if widths are 0.
1719cdf0e10cSrcweir SvxBoxItem aBoxItem ( *(const SvxBoxItem*)pItem );
1720cdf0e10cSrcweir if ( aBoxItem.GetTop() && aBoxItem.GetTop()->GetOutWidth() == 0 )
1721cdf0e10cSrcweir aBoxItem.SetLine( pDefLine, BOX_LINE_TOP );
1722cdf0e10cSrcweir if ( aBoxItem.GetBottom() && aBoxItem.GetBottom()->GetOutWidth() == 0 )
1723cdf0e10cSrcweir aBoxItem.SetLine( pDefLine, BOX_LINE_BOTTOM );
1724cdf0e10cSrcweir if ( aBoxItem.GetLeft() && aBoxItem.GetLeft()->GetOutWidth() == 0 )
1725cdf0e10cSrcweir aBoxItem.SetLine( pDefLine, BOX_LINE_LEFT );
1726cdf0e10cSrcweir if ( aBoxItem.GetRight() && aBoxItem.GetRight()->GetOutWidth() == 0 )
1727cdf0e10cSrcweir aBoxItem.SetLine( pDefLine, BOX_LINE_RIGHT );
1728cdf0e10cSrcweir pNewSet->Put( aBoxItem );
1729cdf0e10cSrcweir rReq.AppendItem( aBoxItem );
1730cdf0e10cSrcweir }
1731cdf0e10cSrcweir
1732cdf0e10cSrcweir if ( pNewAttrs->GetItemState( ATTR_BORDER_INNER, sal_True, &pItem )
1733cdf0e10cSrcweir == SFX_ITEM_SET )
1734cdf0e10cSrcweir {
1735cdf0e10cSrcweir SvxBoxInfoItem aBoxInfoItem( *(const SvxBoxInfoItem*)pItem );
1736cdf0e10cSrcweir if ( aBoxInfoItem.GetHori() && aBoxInfoItem.GetHori()->GetOutWidth() == 0 )
1737cdf0e10cSrcweir aBoxInfoItem.SetLine( pDefLine, BOXINFO_LINE_HORI );
1738cdf0e10cSrcweir if ( aBoxInfoItem.GetVert() && aBoxInfoItem.GetVert()->GetOutWidth() == 0 )
1739cdf0e10cSrcweir aBoxInfoItem.SetLine( pDefLine, BOXINFO_LINE_VERT );
1740cdf0e10cSrcweir pNewSet->Put( aBoxInfoItem );
1741cdf0e10cSrcweir rReq.AppendItem( aBoxInfoItem );
1742cdf0e10cSrcweir }
1743cdf0e10cSrcweir else
1744cdf0e10cSrcweir {
1745cdf0e10cSrcweir SvxBoxInfoItem aBoxInfoItem( ATTR_BORDER_INNER );
1746cdf0e10cSrcweir aBoxInfoItem.SetLine( NULL, BOXINFO_LINE_HORI );
1747cdf0e10cSrcweir aBoxInfoItem.SetLine( NULL, BOXINFO_LINE_VERT );
1748cdf0e10cSrcweir pNewSet->Put( aBoxInfoItem );
1749cdf0e10cSrcweir }
1750cdf0e10cSrcweir
1751cdf0e10cSrcweir pOldSet->Put( rBorderAttr );
1752cdf0e10cSrcweir pTabViewShell->ApplyAttributes( pNewSet, pOldSet );
1753cdf0e10cSrcweir
1754cdf0e10cSrcweir delete pOldSet;
1755cdf0e10cSrcweir delete pNewSet;
1756cdf0e10cSrcweir }
1757cdf0e10cSrcweir break;
1758cdf0e10cSrcweir
1759facb16e7SArmin Le Grand case SID_ATTR_BORDER_DIAG_TLBR:
1760facb16e7SArmin Le Grand case SID_ATTR_BORDER_DIAG_BLTR:
1761facb16e7SArmin Le Grand {
1762816a791eSPavel Janík // ScDocument* pDoc = GetViewData()->GetDocument();
1763facb16e7SArmin Le Grand const ScPatternAttr* pOldAttrs = pTabViewShell->GetSelectionPattern();
1764facb16e7SArmin Le Grand SfxItemSet* pOldSet = new SfxItemSet(pOldAttrs->GetItemSet());
1765facb16e7SArmin Le Grand SfxItemSet* pNewSet = new SfxItemSet(pOldAttrs->GetItemSet());
1766facb16e7SArmin Le Grand const SfxPoolItem* pItem = 0;
1767facb16e7SArmin Le Grand
1768facb16e7SArmin Le Grand if(SID_ATTR_BORDER_DIAG_TLBR == nSlot)
1769facb16e7SArmin Le Grand {
1770facb16e7SArmin Le Grand if(SFX_ITEM_SET == pNewAttrs->GetItemState(ATTR_BORDER_TLBR, true, &pItem))
1771facb16e7SArmin Le Grand {
1772facb16e7SArmin Le Grand SvxLineItem aItem(ATTR_BORDER_TLBR);
1773facb16e7SArmin Le Grand aItem.SetLine(((const SvxLineItem&)pNewAttrs->Get(ATTR_BORDER_TLBR)).GetLine());
1774facb16e7SArmin Le Grand pNewSet->Put(aItem);
1775facb16e7SArmin Le Grand rReq.AppendItem(aItem);
1776facb16e7SArmin Le Grand pTabViewShell->ApplyAttributes(pNewSet, pOldSet);
1777facb16e7SArmin Le Grand }
1778facb16e7SArmin Le Grand }
1779facb16e7SArmin Le Grand else // if( nSlot == SID_ATTR_BORDER_DIAG_BLTR )
1780facb16e7SArmin Le Grand {
1781facb16e7SArmin Le Grand if(SFX_ITEM_SET == pNewAttrs->GetItemState(ATTR_BORDER_BLTR, true, &pItem ))
1782facb16e7SArmin Le Grand {
1783facb16e7SArmin Le Grand SvxLineItem aItem(ATTR_BORDER_BLTR);
1784facb16e7SArmin Le Grand aItem.SetLine(((const SvxLineItem&)pNewAttrs->Get(ATTR_BORDER_BLTR)).GetLine());
1785facb16e7SArmin Le Grand pNewSet->Put(aItem);
1786facb16e7SArmin Le Grand rReq.AppendItem(aItem);
1787facb16e7SArmin Le Grand pTabViewShell->ApplyAttributes(pNewSet, pOldSet);
1788facb16e7SArmin Le Grand }
1789facb16e7SArmin Le Grand }
1790facb16e7SArmin Le Grand
1791facb16e7SArmin Le Grand delete pOldSet;
1792facb16e7SArmin Le Grand delete pNewSet;
1793facb16e7SArmin Le Grand rBindings.Invalidate(nSlot);
1794facb16e7SArmin Le Grand }
1795facb16e7SArmin Le Grand break;
1796facb16e7SArmin Le Grand
1797cdf0e10cSrcweir // ATTR_BACKGROUND (=SID_ATTR_BRUSH) muss ueber zwei IDs
1798cdf0e10cSrcweir // gesetzt werden:
1799cdf0e10cSrcweir case SID_BACKGROUND_COLOR:
1800cdf0e10cSrcweir {
1801cdf0e10cSrcweir const SvxColorItem rNewColorItem = (const SvxColorItem&)
1802cdf0e10cSrcweir pNewAttrs->Get( SID_BACKGROUND_COLOR );
1803cdf0e10cSrcweir
1804cdf0e10cSrcweir SvxBrushItem aBrushItem( (const SvxBrushItem&)
1805cdf0e10cSrcweir pTabViewShell->GetSelectionPattern()->
1806cdf0e10cSrcweir GetItem( ATTR_BACKGROUND ) );
1807cdf0e10cSrcweir
1808cdf0e10cSrcweir aBrushItem.SetColor( rNewColorItem.GetValue() );
1809cdf0e10cSrcweir
1810cdf0e10cSrcweir pTabViewShell->ApplyAttr( aBrushItem );
1811cdf0e10cSrcweir }
1812cdf0e10cSrcweir break;
1813cdf0e10cSrcweir
1814cdf0e10cSrcweir case SID_ATTR_BRUSH:
1815cdf0e10cSrcweir {
1816cdf0e10cSrcweir SvxBrushItem aBrushItem( (const SvxBrushItem&)
1817cdf0e10cSrcweir pTabViewShell->GetSelectionPattern()->
1818cdf0e10cSrcweir GetItem( ATTR_BACKGROUND ) );
1819cdf0e10cSrcweir const SvxBrushItem& rNewBrushItem = (const SvxBrushItem&)
1820cdf0e10cSrcweir pNewAttrs->Get( GetPool().GetWhich(nSlot) );
1821cdf0e10cSrcweir aBrushItem.SetColor(rNewBrushItem.GetColor());
1822cdf0e10cSrcweir pTabViewShell->ApplyAttr( aBrushItem );
1823cdf0e10cSrcweir }
1824cdf0e10cSrcweir break;
1825cdf0e10cSrcweir
1826cdf0e10cSrcweir case SID_ATTR_BORDER_SHADOW:
1827cdf0e10cSrcweir {
1828cdf0e10cSrcweir const SvxShadowItem& rNewShadowItem = (const SvxShadowItem&)
1829cdf0e10cSrcweir pNewAttrs->Get( ATTR_SHADOW );
1830cdf0e10cSrcweir pTabViewShell->ApplyAttr( rNewShadowItem );
1831cdf0e10cSrcweir }
1832cdf0e10cSrcweir break;
1833cdf0e10cSrcweir
1834cdf0e10cSrcweir default:
1835cdf0e10cSrcweir break;
1836cdf0e10cSrcweir }
1837cdf0e10cSrcweir
1838cdf0e10cSrcweir if( ! rReq.IsAPI() )
1839cdf0e10cSrcweir if( ! rReq.IsDone() )
1840cdf0e10cSrcweir rReq.Done();
1841cdf0e10cSrcweir }
1842cdf0e10cSrcweir }
1843cdf0e10cSrcweir
GetAttrState(SfxItemSet & rSet)1844cdf0e10cSrcweir void ScFormatShell::GetAttrState( SfxItemSet& rSet )
1845cdf0e10cSrcweir {
1846cdf0e10cSrcweir ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
1847cdf0e10cSrcweir const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet();
1848816a791eSPavel Janík // const SvxBorderLine* pLine = pTabViewShell->GetDefaultFrameLine();
1849cdf0e10cSrcweir const SvxBrushItem& rBrushItem = (const SvxBrushItem&)rAttrSet.Get( ATTR_BACKGROUND );
1850cdf0e10cSrcweir SfxWhichIter aIter( rSet );
1851cdf0e10cSrcweir sal_uInt16 nWhich = aIter.FirstWhich();
1852cdf0e10cSrcweir
1853cdf0e10cSrcweir rSet.Put( rAttrSet, sal_False );
1854cdf0e10cSrcweir
1855cdf0e10cSrcweir // choose font info according to selection script type
1856cdf0e10cSrcweir sal_uInt8 nScript = 0; // GetSelectionScriptType never returns 0
1857cdf0e10cSrcweir if ( rSet.GetItemState( ATTR_FONT ) != SFX_ITEM_UNKNOWN )
1858cdf0e10cSrcweir {
1859cdf0e10cSrcweir if (!nScript) nScript = pTabViewShell->GetSelectionScriptType();
1860cdf0e10cSrcweir ScViewUtil::PutItemScript( rSet, rAttrSet, ATTR_FONT, nScript );
1861cdf0e10cSrcweir }
1862cdf0e10cSrcweir if ( rSet.GetItemState( ATTR_FONT_HEIGHT ) != SFX_ITEM_UNKNOWN )
1863cdf0e10cSrcweir {
1864cdf0e10cSrcweir if (!nScript) nScript = pTabViewShell->GetSelectionScriptType();
1865cdf0e10cSrcweir ScViewUtil::PutItemScript( rSet, rAttrSet, ATTR_FONT_HEIGHT, nScript );
1866cdf0e10cSrcweir }
1867cdf0e10cSrcweir
1868cdf0e10cSrcweir while ( nWhich )
1869cdf0e10cSrcweir {
1870cdf0e10cSrcweir switch(nWhich)
1871cdf0e10cSrcweir {
1872cdf0e10cSrcweir case SID_BACKGROUND_COLOR:
1873cdf0e10cSrcweir {
1874cdf0e10cSrcweir rSet.Put( SvxColorItem( rBrushItem.GetColor(), SID_BACKGROUND_COLOR ) );
1875facb16e7SArmin Le Grand
1876facb16e7SArmin Le Grand if(SFX_ITEM_DONTCARE == rAttrSet.GetItemState(ATTR_BACKGROUND))
1877facb16e7SArmin Le Grand {
1878facb16e7SArmin Le Grand rSet.InvalidateItem(SID_BACKGROUND_COLOR);
1879facb16e7SArmin Le Grand }
1880cdf0e10cSrcweir }
1881cdf0e10cSrcweir break;
1882facb16e7SArmin Le Grand case SID_FRAME_LINESTYLE:
1883cdf0e10cSrcweir case SID_FRAME_LINECOLOR:
1884cdf0e10cSrcweir {
1885facb16e7SArmin Le Grand // handled together because both need the cell border information for decisions
1886facb16e7SArmin Le Grand // rSet.Put( SvxColorItem( pLine ? pLine->GetColor() : Color(), SID_FRAME_LINECOLOR ) );
1887facb16e7SArmin Le Grand Color aCol = 0;
1888816a791eSPavel Janík // sal_uInt16 nOut = 0, nIn = 0, nDis = 0;
1889facb16e7SArmin Le Grand SvxBorderLine aLine(0,0,0,0);
1890facb16e7SArmin Le Grand bool bCol = 0;
1891facb16e7SArmin Le Grand bool bColDisable = 0, bStyleDisable = 0;
1892facb16e7SArmin Le Grand SvxBoxItem aBoxItem(ATTR_BORDER);
1893facb16e7SArmin Le Grand SvxBoxInfoItem aInfoItem(ATTR_BORDER_INNER);
1894facb16e7SArmin Le Grand
1895facb16e7SArmin Le Grand pTabViewShell->GetSelectionFrame(aBoxItem, aInfoItem);
1896facb16e7SArmin Le Grand
1897facb16e7SArmin Le Grand if( aBoxItem.GetTop() )
1898facb16e7SArmin Le Grand {
1899facb16e7SArmin Le Grand bCol = 1;
1900facb16e7SArmin Le Grand aCol = aBoxItem.GetTop()->GetColor() ;
1901facb16e7SArmin Le Grand aLine.SetColor(aCol);
1902facb16e7SArmin Le Grand aLine.SetOutWidth( aBoxItem.GetTop()->GetOutWidth());
1903facb16e7SArmin Le Grand aLine.SetInWidth( aBoxItem.GetTop()->GetInWidth());
1904facb16e7SArmin Le Grand aLine.SetDistance( aBoxItem.GetTop()->GetDistance());
1905facb16e7SArmin Le Grand }
1906facb16e7SArmin Le Grand
1907facb16e7SArmin Le Grand if( aBoxItem.GetBottom() )
1908facb16e7SArmin Le Grand {
1909facb16e7SArmin Le Grand if(bCol == 0)
1910facb16e7SArmin Le Grand {
1911facb16e7SArmin Le Grand bCol = 1;
1912facb16e7SArmin Le Grand aCol = aBoxItem.GetBottom()->GetColor() ;
1913facb16e7SArmin Le Grand aLine.SetColor(aCol);
1914facb16e7SArmin Le Grand aLine.SetOutWidth( aBoxItem.GetBottom()->GetOutWidth());
1915facb16e7SArmin Le Grand aLine.SetInWidth( aBoxItem.GetBottom()->GetInWidth());
1916facb16e7SArmin Le Grand aLine.SetDistance( aBoxItem.GetBottom()->GetDistance());
1917facb16e7SArmin Le Grand }
1918facb16e7SArmin Le Grand else
1919facb16e7SArmin Le Grand {
1920facb16e7SArmin Le Grand if(aCol != aBoxItem.GetBottom()->GetColor() )
1921facb16e7SArmin Le Grand bColDisable = 1;
1922facb16e7SArmin Le Grand if(!( aLine == *(aBoxItem.GetBottom())) )
1923facb16e7SArmin Le Grand bStyleDisable = 1;
1924facb16e7SArmin Le Grand }
1925facb16e7SArmin Le Grand }
1926facb16e7SArmin Le Grand
1927facb16e7SArmin Le Grand if( aBoxItem.GetLeft() )
1928facb16e7SArmin Le Grand {
1929facb16e7SArmin Le Grand if(bCol == 0)
1930facb16e7SArmin Le Grand {
1931facb16e7SArmin Le Grand bCol = 1;
1932facb16e7SArmin Le Grand aCol = aBoxItem.GetLeft()->GetColor() ;
1933facb16e7SArmin Le Grand aLine.SetColor(aCol);
1934facb16e7SArmin Le Grand aLine.SetOutWidth( aBoxItem.GetLeft()->GetOutWidth());
1935facb16e7SArmin Le Grand aLine.SetInWidth( aBoxItem.GetLeft()->GetInWidth());
1936facb16e7SArmin Le Grand aLine.SetDistance( aBoxItem.GetLeft()->GetDistance());
1937facb16e7SArmin Le Grand }
1938facb16e7SArmin Le Grand else
1939facb16e7SArmin Le Grand {
1940facb16e7SArmin Le Grand if(aCol != aBoxItem.GetLeft()->GetColor() )
1941facb16e7SArmin Le Grand bColDisable = 1;
1942facb16e7SArmin Le Grand if(!( aLine == *(aBoxItem.GetLeft())) )
1943facb16e7SArmin Le Grand bStyleDisable = 1;
1944facb16e7SArmin Le Grand }
1945facb16e7SArmin Le Grand }
1946facb16e7SArmin Le Grand
1947facb16e7SArmin Le Grand if( aBoxItem.GetRight() )
1948facb16e7SArmin Le Grand {
1949facb16e7SArmin Le Grand if(bCol == 0)
1950facb16e7SArmin Le Grand {
1951facb16e7SArmin Le Grand bCol = 1;
1952facb16e7SArmin Le Grand aCol = aBoxItem.GetRight()->GetColor() ;
1953facb16e7SArmin Le Grand aLine.SetColor(aCol);
1954facb16e7SArmin Le Grand aLine.SetOutWidth( aBoxItem.GetRight()->GetOutWidth());
1955facb16e7SArmin Le Grand aLine.SetInWidth( aBoxItem.GetRight()->GetInWidth());
1956facb16e7SArmin Le Grand aLine.SetDistance( aBoxItem.GetRight()->GetDistance());
1957facb16e7SArmin Le Grand }
1958facb16e7SArmin Le Grand else
1959facb16e7SArmin Le Grand {
1960facb16e7SArmin Le Grand if(aCol != aBoxItem.GetRight()->GetColor() )
1961facb16e7SArmin Le Grand bColDisable = 1;
1962facb16e7SArmin Le Grand if(!( aLine == *(aBoxItem.GetRight())) )
1963facb16e7SArmin Le Grand bStyleDisable = 1;
1964facb16e7SArmin Le Grand }
1965facb16e7SArmin Le Grand }
1966facb16e7SArmin Le Grand
1967facb16e7SArmin Le Grand if( aInfoItem.GetVert())
1968facb16e7SArmin Le Grand {
1969facb16e7SArmin Le Grand if(bCol == 0)
1970facb16e7SArmin Le Grand {
1971facb16e7SArmin Le Grand bCol = 1;
1972facb16e7SArmin Le Grand aCol = aInfoItem.GetVert()->GetColor() ;
1973facb16e7SArmin Le Grand aLine.SetColor(aCol);
1974facb16e7SArmin Le Grand aLine.SetOutWidth( aInfoItem.GetVert()->GetOutWidth());
1975facb16e7SArmin Le Grand aLine.SetInWidth( aInfoItem.GetVert()->GetInWidth());
1976facb16e7SArmin Le Grand aLine.SetDistance( aInfoItem.GetVert()->GetDistance());
1977facb16e7SArmin Le Grand }
1978facb16e7SArmin Le Grand else
1979facb16e7SArmin Le Grand {
1980facb16e7SArmin Le Grand if(aCol != aInfoItem.GetVert()->GetColor() )
1981facb16e7SArmin Le Grand bColDisable = 1;
1982facb16e7SArmin Le Grand if(!( aLine == *(aInfoItem.GetVert())) )
1983facb16e7SArmin Le Grand bStyleDisable = 1;
1984facb16e7SArmin Le Grand }
1985facb16e7SArmin Le Grand }
1986facb16e7SArmin Le Grand
1987facb16e7SArmin Le Grand if( aInfoItem.GetHori())
1988facb16e7SArmin Le Grand {
1989facb16e7SArmin Le Grand if(bCol == 0)
1990facb16e7SArmin Le Grand {
1991facb16e7SArmin Le Grand bCol = 1;
1992facb16e7SArmin Le Grand aCol = aInfoItem.GetHori()->GetColor() ;
1993facb16e7SArmin Le Grand aLine.SetColor(aCol);
1994facb16e7SArmin Le Grand aLine.SetOutWidth( aInfoItem.GetHori()->GetOutWidth());
1995facb16e7SArmin Le Grand aLine.SetInWidth( aInfoItem.GetHori()->GetInWidth());
1996facb16e7SArmin Le Grand aLine.SetDistance( aInfoItem.GetHori()->GetDistance());
1997facb16e7SArmin Le Grand }
1998facb16e7SArmin Le Grand else
1999facb16e7SArmin Le Grand {
2000facb16e7SArmin Le Grand if(aCol != aInfoItem.GetHori()->GetColor() )
2001facb16e7SArmin Le Grand bColDisable = 1;
2002facb16e7SArmin Le Grand if(!( aLine == *(aInfoItem.GetHori())) )
2003facb16e7SArmin Le Grand bStyleDisable = 1;
2004facb16e7SArmin Le Grand }
2005facb16e7SArmin Le Grand }
2006facb16e7SArmin Le Grand
2007facb16e7SArmin Le Grand if( !aInfoItem.IsValid( VALID_VERT )
2008facb16e7SArmin Le Grand || !aInfoItem.IsValid( VALID_HORI )
2009facb16e7SArmin Le Grand || !aInfoItem.IsValid( VALID_LEFT )
2010facb16e7SArmin Le Grand || !aInfoItem.IsValid( VALID_RIGHT )
2011facb16e7SArmin Le Grand || !aInfoItem.IsValid( VALID_TOP )
2012facb16e7SArmin Le Grand || !aInfoItem.IsValid( VALID_BOTTOM ) )
2013facb16e7SArmin Le Grand {
2014facb16e7SArmin Le Grand bColDisable = 1;
2015facb16e7SArmin Le Grand bStyleDisable = 1;
2016facb16e7SArmin Le Grand }
2017facb16e7SArmin Le Grand
2018facb16e7SArmin Le Grand if(SID_FRAME_LINECOLOR == nWhich)
2019facb16e7SArmin Le Grand {
2020facb16e7SArmin Le Grand if(bColDisable) // if different lines have differernt colors
2021facb16e7SArmin Le Grand {
2022facb16e7SArmin Le Grand aCol = COL_TRANSPARENT;
2023facb16e7SArmin Le Grand rSet.Put( SvxColorItem(aCol, SID_FRAME_LINECOLOR ) );
2024facb16e7SArmin Le Grand rSet.InvalidateItem(SID_FRAME_LINECOLOR);
2025facb16e7SArmin Le Grand }
2026facb16e7SArmin Le Grand else if( bCol == 0 && bColDisable == 0) // if no line available
2027facb16e7SArmin Le Grand {
2028facb16e7SArmin Le Grand aCol = COL_AUTO;
2029facb16e7SArmin Le Grand rSet.Put( SvxColorItem(aCol, SID_FRAME_LINECOLOR ) );
2030facb16e7SArmin Le Grand }
2031facb16e7SArmin Le Grand else
2032facb16e7SArmin Le Grand rSet.Put( SvxColorItem(aCol, SID_FRAME_LINECOLOR ) );
2033facb16e7SArmin Le Grand }
2034facb16e7SArmin Le Grand else // if( nWhich == SID_FRAME_LINESTYLE)
2035facb16e7SArmin Le Grand {
2036facb16e7SArmin Le Grand if(bStyleDisable) // if have several lines but don't have same style
2037facb16e7SArmin Le Grand {
2038facb16e7SArmin Le Grand aLine.SetOutWidth( 1 );
2039facb16e7SArmin Le Grand aLine.SetInWidth( 0 );
2040facb16e7SArmin Le Grand aLine.SetDistance( 0 );
2041facb16e7SArmin Le Grand SvxLineItem aItem(SID_FRAME_LINESTYLE);
2042facb16e7SArmin Le Grand aItem.SetLine(&aLine);
2043facb16e7SArmin Le Grand rSet.Put( aItem );
2044facb16e7SArmin Le Grand rSet.InvalidateItem(SID_FRAME_LINESTYLE);
2045facb16e7SArmin Le Grand }
2046facb16e7SArmin Le Grand else // all the lines have same style or no line availavle, use initial value (0,0,0,0)
2047facb16e7SArmin Le Grand {
2048facb16e7SArmin Le Grand SvxLineItem aItem(SID_FRAME_LINESTYLE);
2049facb16e7SArmin Le Grand aItem.SetLine(&aLine);
2050facb16e7SArmin Le Grand rSet.Put( aItem );
2051facb16e7SArmin Le Grand }
2052facb16e7SArmin Le Grand }
2053cdf0e10cSrcweir }
2054cdf0e10cSrcweir break;
2055cdf0e10cSrcweir case SID_ATTR_BRUSH:
2056cdf0e10cSrcweir {
2057cdf0e10cSrcweir rSet.Put( rBrushItem, GetPool().GetWhich(nWhich) );
2058cdf0e10cSrcweir }
2059cdf0e10cSrcweir break;
2060cdf0e10cSrcweir }
2061cdf0e10cSrcweir nWhich = aIter.NextWhich();
2062cdf0e10cSrcweir }
2063facb16e7SArmin Le Grand
2064*52d7ec27SOliver-Rainer Wittmann // stuff for sidebar panels
2065*52d7ec27SOliver-Rainer Wittmann Invalidate(SID_ATTR_ALIGN_DEGREES);
2066*52d7ec27SOliver-Rainer Wittmann Invalidate(SID_ATTR_ALIGN_STACKED);
2067cdf0e10cSrcweir }
2068cdf0e10cSrcweir
2069cdf0e10cSrcweir //------------------------------------------------------------------
2070cdf0e10cSrcweir
GetTextAttrState(SfxItemSet & rSet)2071cdf0e10cSrcweir void ScFormatShell::GetTextAttrState( SfxItemSet& rSet )
2072cdf0e10cSrcweir {
2073cdf0e10cSrcweir ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
2074cdf0e10cSrcweir const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet();
2075cdf0e10cSrcweir rSet.Put( rAttrSet, sal_False ); // ItemStates mitkopieren
2076cdf0e10cSrcweir
2077cdf0e10cSrcweir // choose font info according to selection script type
2078cdf0e10cSrcweir sal_uInt8 nScript = 0; // GetSelectionScriptType never returns 0
2079cdf0e10cSrcweir if ( rSet.GetItemState( ATTR_FONT_WEIGHT ) != SFX_ITEM_UNKNOWN )
2080cdf0e10cSrcweir {
2081cdf0e10cSrcweir if (!nScript) nScript = pTabViewShell->GetSelectionScriptType();
2082cdf0e10cSrcweir ScViewUtil::PutItemScript( rSet, rAttrSet, ATTR_FONT_WEIGHT, nScript );
2083cdf0e10cSrcweir }
2084cdf0e10cSrcweir if ( rSet.GetItemState( ATTR_FONT_POSTURE ) != SFX_ITEM_UNKNOWN )
2085cdf0e10cSrcweir {
2086cdf0e10cSrcweir if (!nScript) nScript = pTabViewShell->GetSelectionScriptType();
2087cdf0e10cSrcweir ScViewUtil::PutItemScript( rSet, rAttrSet, ATTR_FONT_POSTURE, nScript );
2088cdf0e10cSrcweir }
2089cdf0e10cSrcweir
2090cdf0e10cSrcweir SfxItemState eState;
2091cdf0e10cSrcweir // const SfxPoolItem* pItem;
2092cdf0e10cSrcweir
2093cdf0e10cSrcweir //--------------------------------------------------------------------
2094cdf0e10cSrcweir // eigene Kontrolle ueber RadioButton-Funktionalitaet:
2095cdf0e10cSrcweir //--------------------------------------------------------------------
2096cdf0e10cSrcweir // Unterstreichung
2097cdf0e10cSrcweir //------------------------
2098cdf0e10cSrcweir
2099cdf0e10cSrcweir eState = rAttrSet.GetItemState( ATTR_FONT_UNDERLINE, sal_True );
2100cdf0e10cSrcweir if ( eState == SFX_ITEM_DONTCARE )
2101cdf0e10cSrcweir {
2102cdf0e10cSrcweir rSet.InvalidateItem( SID_ULINE_VAL_NONE );
2103cdf0e10cSrcweir rSet.InvalidateItem( SID_ULINE_VAL_SINGLE );
2104cdf0e10cSrcweir rSet.InvalidateItem( SID_ULINE_VAL_DOUBLE );
2105cdf0e10cSrcweir rSet.InvalidateItem( SID_ULINE_VAL_DOTTED );
2106cdf0e10cSrcweir }
2107cdf0e10cSrcweir else
2108cdf0e10cSrcweir {
2109cdf0e10cSrcweir FontUnderline eUnderline = ((const SvxUnderlineItem&)
2110cdf0e10cSrcweir rAttrSet.Get(ATTR_FONT_UNDERLINE)).GetLineStyle();
2111cdf0e10cSrcweir sal_uInt16 nId = SID_ULINE_VAL_NONE;
2112cdf0e10cSrcweir switch (eUnderline)
2113cdf0e10cSrcweir {
2114cdf0e10cSrcweir case UNDERLINE_SINGLE: nId = SID_ULINE_VAL_SINGLE; break;
2115cdf0e10cSrcweir case UNDERLINE_DOUBLE: nId = SID_ULINE_VAL_DOUBLE; break;
2116cdf0e10cSrcweir case UNDERLINE_DOTTED: nId = SID_ULINE_VAL_DOTTED; break;
2117cdf0e10cSrcweir default:
2118cdf0e10cSrcweir break;
2119cdf0e10cSrcweir }
2120cdf0e10cSrcweir rSet.Put( SfxBoolItem( nId, sal_True ) );
2121cdf0e10cSrcweir }
2122cdf0e10cSrcweir
2123cdf0e10cSrcweir //------------------------
2124cdf0e10cSrcweir // horizontale Ausrichtung
2125cdf0e10cSrcweir //------------------------
2126cdf0e10cSrcweir
2127cdf0e10cSrcweir const SvxHorJustifyItem* pHorJustify = NULL;
2128cdf0e10cSrcweir const SvxVerJustifyItem* pVerJustify = NULL;
2129cdf0e10cSrcweir SvxCellHorJustify eHorJustify = SVX_HOR_JUSTIFY_STANDARD;
2130cdf0e10cSrcweir SvxCellVerJustify eVerJustify = SVX_VER_JUSTIFY_STANDARD;
2131cdf0e10cSrcweir sal_uInt16 nWhich = 0;
2132cdf0e10cSrcweir sal_Bool bJustifyStd = sal_False;
2133cdf0e10cSrcweir SfxBoolItem aBoolItem ( 0, sal_True );
2134cdf0e10cSrcweir
2135cdf0e10cSrcweir eState = rAttrSet.GetItemState( ATTR_HOR_JUSTIFY, sal_True,
2136cdf0e10cSrcweir (const SfxPoolItem**)&pHorJustify );
2137cdf0e10cSrcweir switch ( eState )
2138cdf0e10cSrcweir {
2139cdf0e10cSrcweir case SFX_ITEM_SET:
2140cdf0e10cSrcweir {
2141cdf0e10cSrcweir eHorJustify = SvxCellHorJustify( pHorJustify->GetValue() );
2142cdf0e10cSrcweir
2143cdf0e10cSrcweir switch ( SvxCellHorJustify( pHorJustify->GetValue() ) )
2144cdf0e10cSrcweir {
2145cdf0e10cSrcweir case SVX_HOR_JUSTIFY_STANDARD:
2146cdf0e10cSrcweir break;
2147cdf0e10cSrcweir
2148cdf0e10cSrcweir case SVX_HOR_JUSTIFY_LEFT:
2149cdf0e10cSrcweir nWhich = SID_ALIGNLEFT;
2150cdf0e10cSrcweir break;
2151cdf0e10cSrcweir
2152cdf0e10cSrcweir case SVX_HOR_JUSTIFY_RIGHT:
2153cdf0e10cSrcweir nWhich = SID_ALIGNRIGHT;
2154cdf0e10cSrcweir break;
2155cdf0e10cSrcweir
2156cdf0e10cSrcweir case SVX_HOR_JUSTIFY_CENTER:
2157cdf0e10cSrcweir nWhich = SID_ALIGNCENTERHOR;
2158cdf0e10cSrcweir break;
2159cdf0e10cSrcweir
2160cdf0e10cSrcweir case SVX_HOR_JUSTIFY_BLOCK:
2161cdf0e10cSrcweir nWhich = SID_ALIGNBLOCK;
2162cdf0e10cSrcweir break;
2163cdf0e10cSrcweir
2164cdf0e10cSrcweir case SVX_HOR_JUSTIFY_REPEAT:
2165cdf0e10cSrcweir default:
2166cdf0e10cSrcweir bJustifyStd = sal_True;
2167cdf0e10cSrcweir break;
2168cdf0e10cSrcweir }
2169cdf0e10cSrcweir }
2170cdf0e10cSrcweir break;
2171cdf0e10cSrcweir
2172cdf0e10cSrcweir case SFX_ITEM_DONTCARE:
2173cdf0e10cSrcweir rSet.InvalidateItem( SID_ALIGNLEFT );
2174cdf0e10cSrcweir rSet.InvalidateItem( SID_ALIGNRIGHT );
2175cdf0e10cSrcweir rSet.InvalidateItem( SID_ALIGNCENTERHOR );
2176cdf0e10cSrcweir rSet.InvalidateItem( SID_ALIGNBLOCK );
2177cdf0e10cSrcweir break;
2178cdf0e10cSrcweir
2179cdf0e10cSrcweir default:
2180cdf0e10cSrcweir bJustifyStd = sal_True;
2181cdf0e10cSrcweir break;
2182cdf0e10cSrcweir }
2183cdf0e10cSrcweir
2184cdf0e10cSrcweir if ( nWhich )
2185cdf0e10cSrcweir {
2186cdf0e10cSrcweir aBoolItem.SetWhich( nWhich );
2187cdf0e10cSrcweir rSet.Put( aBoolItem );
2188cdf0e10cSrcweir }
2189cdf0e10cSrcweir else if ( bJustifyStd )
2190cdf0e10cSrcweir {
2191cdf0e10cSrcweir aBoolItem.SetValue( sal_False );
2192cdf0e10cSrcweir aBoolItem.SetWhich( SID_ALIGNLEFT ); rSet.Put( aBoolItem );
2193cdf0e10cSrcweir aBoolItem.SetWhich( SID_ALIGNRIGHT ); rSet.Put( aBoolItem );
2194cdf0e10cSrcweir aBoolItem.SetWhich( SID_ALIGNCENTERHOR ); rSet.Put( aBoolItem );
2195cdf0e10cSrcweir aBoolItem.SetWhich( SID_ALIGNBLOCK ); rSet.Put( aBoolItem );
2196cdf0e10cSrcweir bJustifyStd = sal_False;
2197cdf0e10cSrcweir }
2198cdf0e10cSrcweir
2199cdf0e10cSrcweir //------------------------
2200cdf0e10cSrcweir // vertikale Ausrichtung
2201cdf0e10cSrcweir //------------------------
2202cdf0e10cSrcweir
2203cdf0e10cSrcweir nWhich = 0;
2204cdf0e10cSrcweir aBoolItem.SetValue( sal_True );
2205cdf0e10cSrcweir
2206cdf0e10cSrcweir eState = rAttrSet.GetItemState( ATTR_VER_JUSTIFY, sal_True,
2207cdf0e10cSrcweir (const SfxPoolItem**)&pVerJustify );
2208cdf0e10cSrcweir
2209cdf0e10cSrcweir switch ( eState )
2210cdf0e10cSrcweir {
2211cdf0e10cSrcweir case SFX_ITEM_SET:
2212cdf0e10cSrcweir {
2213cdf0e10cSrcweir eVerJustify = SvxCellVerJustify( pVerJustify->GetValue() );
2214cdf0e10cSrcweir
2215cdf0e10cSrcweir switch ( eVerJustify )
2216cdf0e10cSrcweir {
2217cdf0e10cSrcweir case SVX_VER_JUSTIFY_TOP:
2218cdf0e10cSrcweir nWhich = SID_ALIGNTOP;
2219cdf0e10cSrcweir break;
2220cdf0e10cSrcweir
2221cdf0e10cSrcweir case SVX_VER_JUSTIFY_BOTTOM:
2222cdf0e10cSrcweir nWhich = SID_ALIGNBOTTOM;
2223cdf0e10cSrcweir break;
2224cdf0e10cSrcweir
2225cdf0e10cSrcweir case SVX_VER_JUSTIFY_CENTER:
2226cdf0e10cSrcweir nWhich = SID_ALIGNCENTERVER;
2227cdf0e10cSrcweir break;
2228cdf0e10cSrcweir
2229cdf0e10cSrcweir case SVX_VER_JUSTIFY_STANDARD:
2230cdf0e10cSrcweir default:
2231cdf0e10cSrcweir bJustifyStd = sal_True;
2232cdf0e10cSrcweir break;
2233cdf0e10cSrcweir }
2234cdf0e10cSrcweir }
2235cdf0e10cSrcweir break;
2236cdf0e10cSrcweir
2237cdf0e10cSrcweir case SFX_ITEM_DONTCARE:
2238cdf0e10cSrcweir rSet.InvalidateItem( SID_ALIGNTOP );
2239cdf0e10cSrcweir rSet.InvalidateItem( SID_ALIGNBOTTOM );
2240cdf0e10cSrcweir rSet.InvalidateItem( SID_ALIGNCENTERVER );
2241cdf0e10cSrcweir break;
2242cdf0e10cSrcweir
2243cdf0e10cSrcweir default:
2244cdf0e10cSrcweir bJustifyStd = sal_True;
2245cdf0e10cSrcweir break;
2246cdf0e10cSrcweir }
2247cdf0e10cSrcweir
2248cdf0e10cSrcweir if ( nWhich )
2249cdf0e10cSrcweir {
2250cdf0e10cSrcweir aBoolItem.SetWhich( nWhich );
2251cdf0e10cSrcweir rSet.Put( aBoolItem );
2252cdf0e10cSrcweir }
2253cdf0e10cSrcweir else if ( bJustifyStd )
2254cdf0e10cSrcweir {
2255cdf0e10cSrcweir aBoolItem.SetValue( sal_False );
2256cdf0e10cSrcweir aBoolItem.SetWhich( SID_ALIGNTOP ); rSet.Put( aBoolItem );
2257cdf0e10cSrcweir aBoolItem.SetWhich( SID_ALIGNBOTTOM ); rSet.Put( aBoolItem );
2258cdf0e10cSrcweir aBoolItem.SetWhich( SID_ALIGNCENTERVER ); rSet.Put( aBoolItem );
2259cdf0e10cSrcweir }
2260cdf0e10cSrcweir }
2261cdf0e10cSrcweir
2262cdf0e10cSrcweir
2263cdf0e10cSrcweir //------------------------------------------------------------------
2264cdf0e10cSrcweir
GetBorderState(SfxItemSet & rSet)2265cdf0e10cSrcweir void ScFormatShell::GetBorderState( SfxItemSet& rSet )
2266cdf0e10cSrcweir {
2267cdf0e10cSrcweir ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
2268cdf0e10cSrcweir SvxBoxItem aBoxItem( ATTR_BORDER );
2269cdf0e10cSrcweir SvxBoxInfoItem aInfoItem( ATTR_BORDER_INNER );
2270cdf0e10cSrcweir
2271cdf0e10cSrcweir pTabViewShell->GetSelectionFrame( aBoxItem, aInfoItem );
2272cdf0e10cSrcweir
2273cdf0e10cSrcweir if ( rSet.GetItemState( ATTR_BORDER ) != SFX_ITEM_UNKNOWN )
2274cdf0e10cSrcweir rSet.Put( aBoxItem );
2275cdf0e10cSrcweir if ( rSet.GetItemState( ATTR_BORDER_INNER ) != SFX_ITEM_UNKNOWN )
2276cdf0e10cSrcweir rSet.Put( aInfoItem );
2277cdf0e10cSrcweir }
2278cdf0e10cSrcweir
2279cdf0e10cSrcweir //------------------------------------------------------------------
2280cdf0e10cSrcweir
GetAlignState(SfxItemSet & rSet)2281cdf0e10cSrcweir void ScFormatShell::GetAlignState( SfxItemSet& rSet )
2282cdf0e10cSrcweir {
2283cdf0e10cSrcweir ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
2284cdf0e10cSrcweir const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet();
2285cdf0e10cSrcweir SfxWhichIter aIter(rSet);
2286cdf0e10cSrcweir sal_uInt16 nWhich = aIter.FirstWhich();
2287cdf0e10cSrcweir
2288cdf0e10cSrcweir SvxCellHorJustify eHAlign = SVX_HOR_JUSTIFY_STANDARD;
2289cdf0e10cSrcweir bool bHasHAlign = rAttrSet.GetItemState( ATTR_HOR_JUSTIFY ) != SFX_ITEM_DONTCARE;
2290cdf0e10cSrcweir if( bHasHAlign )
2291cdf0e10cSrcweir eHAlign = (SvxCellHorJustify)((const SvxHorJustifyItem&) rAttrSet.Get( ATTR_HOR_JUSTIFY )).GetValue();
2292cdf0e10cSrcweir
2293cdf0e10cSrcweir SvxCellVerJustify eVAlign = SVX_VER_JUSTIFY_STANDARD;
2294cdf0e10cSrcweir bool bHasVAlign = rAttrSet.GetItemState( ATTR_VER_JUSTIFY ) != SFX_ITEM_DONTCARE;
2295cdf0e10cSrcweir if( bHasVAlign )
2296cdf0e10cSrcweir eVAlign = (SvxCellVerJustify)((const SvxVerJustifyItem&) rAttrSet.Get( ATTR_VER_JUSTIFY )).GetValue();
2297cdf0e10cSrcweir
2298cdf0e10cSrcweir while ( nWhich )
2299cdf0e10cSrcweir {
2300cdf0e10cSrcweir switch ( nWhich )
2301cdf0e10cSrcweir {
2302cdf0e10cSrcweir case SID_H_ALIGNCELL:
2303cdf0e10cSrcweir if ( bHasHAlign )
2304cdf0e10cSrcweir rSet.Put( SvxHorJustifyItem( eHAlign, nWhich ));
2305cdf0e10cSrcweir break;
2306cdf0e10cSrcweir case SID_V_ALIGNCELL:
2307cdf0e10cSrcweir if ( bHasVAlign )
2308cdf0e10cSrcweir rSet.Put( SvxVerJustifyItem( eVAlign, nWhich ));
2309cdf0e10cSrcweir break;
2310cdf0e10cSrcweir
2311cdf0e10cSrcweir // pseudo slots for Format menu
2312cdf0e10cSrcweir case SID_ALIGN_ANY_HDEFAULT:
2313cdf0e10cSrcweir case SID_ALIGN_ANY_LEFT:
2314cdf0e10cSrcweir case SID_ALIGN_ANY_HCENTER:
2315cdf0e10cSrcweir case SID_ALIGN_ANY_RIGHT:
2316cdf0e10cSrcweir case SID_ALIGN_ANY_JUSTIFIED:
2317cdf0e10cSrcweir rSet.Put( SfxBoolItem( nWhich, bHasHAlign && (eHAlign == lclConvertSlotToHAlign( nWhich )) ) );
2318cdf0e10cSrcweir break;
2319cdf0e10cSrcweir case SID_ALIGN_ANY_VDEFAULT:
2320cdf0e10cSrcweir case SID_ALIGN_ANY_TOP:
2321cdf0e10cSrcweir case SID_ALIGN_ANY_VCENTER:
2322cdf0e10cSrcweir case SID_ALIGN_ANY_BOTTOM:
2323cdf0e10cSrcweir rSet.Put( SfxBoolItem( nWhich, bHasVAlign && (eVAlign == lclConvertSlotToVAlign( nWhich )) ) );
2324cdf0e10cSrcweir break;
2325cdf0e10cSrcweir }
2326cdf0e10cSrcweir nWhich = aIter.NextWhich();
2327cdf0e10cSrcweir }
2328cdf0e10cSrcweir }
2329cdf0e10cSrcweir
GetNumFormatState(SfxItemSet & rSet)2330cdf0e10cSrcweir void ScFormatShell::GetNumFormatState( SfxItemSet& rSet )
2331cdf0e10cSrcweir {
2332cdf0e10cSrcweir ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
2333cdf0e10cSrcweir
2334cdf0e10cSrcweir // ScViewData* pViewData = GetViewData();
2335cdf0e10cSrcweir ScDocument* pDoc = pViewData->GetDocument();
2336cdf0e10cSrcweir
2337cdf0e10cSrcweir SfxWhichIter aIter(rSet);
2338cdf0e10cSrcweir sal_uInt16 nWhich = aIter.FirstWhich();
2339cdf0e10cSrcweir while ( nWhich )
2340cdf0e10cSrcweir {
2341cdf0e10cSrcweir switch ( nWhich )
2342cdf0e10cSrcweir {
2343cdf0e10cSrcweir case SID_NUMBER_FORMAT:
23444e8031e0SArmin Le Grand //{
23454e8031e0SArmin Le Grand // String aFormatCode; // bleibt leer, wenn dont-care
23464e8031e0SArmin Le Grand //
23474e8031e0SArmin Le Grand // const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet();
23484e8031e0SArmin Le Grand // if ( rAttrSet.GetItemState( ATTR_VALUE_FORMAT ) != SFX_ITEM_DONTCARE )
23494e8031e0SArmin Le Grand // {
23504e8031e0SArmin Le Grand // sal_uLong nNumberFormat = ((const SfxUInt32Item&)rAttrSet.Get(
23514e8031e0SArmin Le Grand // ATTR_VALUE_FORMAT )).GetValue();
23524e8031e0SArmin Le Grand //
23534e8031e0SArmin Le Grand // SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
23544e8031e0SArmin Le Grand // const SvNumberformat* pFormatEntry = pFormatter->GetEntry( nNumberFormat );
23554e8031e0SArmin Le Grand // if ( pFormatEntry )
23564e8031e0SArmin Le Grand // aFormatCode = pFormatEntry->GetFormatstring();
23574e8031e0SArmin Le Grand // }
23584e8031e0SArmin Le Grand //
23594e8031e0SArmin Le Grand // rSet.Put( SfxStringItem( nWhich, aFormatCode ) );
23604e8031e0SArmin Le Grand //}
23614e8031e0SArmin Le Grand
23624e8031e0SArmin Le Grand // symphony version with format interpretation
2363cdf0e10cSrcweir {
23644e8031e0SArmin Le Grand const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet();
2365cdf0e10cSrcweir
23664e8031e0SArmin Le Grand if(SFX_ITEM_DONTCARE != rAttrSet.GetItemState(ATTR_VALUE_FORMAT))
23674e8031e0SArmin Le Grand {
23684e8031e0SArmin Le Grand SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
23694e8031e0SArmin Le Grand sal_uInt32 nNumberFormat = ((const SfxUInt32Item&)rAttrSet.Get(ATTR_VALUE_FORMAT)).GetValue();
23704e8031e0SArmin Le Grand sal_Bool bThousand(false);
23714e8031e0SArmin Le Grand sal_Bool bNegRed(false);
23724e8031e0SArmin Le Grand sal_uInt16 nPrecision(0);
23734e8031e0SArmin Le Grand sal_uInt16 nLeadZeroes(0);
23744e8031e0SArmin Le Grand
23754e8031e0SArmin Le Grand pFormatter->GetFormatSpecialInfo(nNumberFormat,bThousand, bNegRed, nPrecision, nLeadZeroes);
23764e8031e0SArmin Le Grand String aFormat;
23774e8031e0SArmin Le Grand static String sBreak = String::CreateFromAscii(",");
23784e8031e0SArmin Le Grand const String sThousand = String::CreateFromInt32(bThousand);
23794e8031e0SArmin Le Grand const String sNegRed = String::CreateFromInt32(bNegRed);
23804e8031e0SArmin Le Grand const String sPrecision = String::CreateFromInt32(nPrecision);
23814e8031e0SArmin Le Grand const String sLeadZeroes = String::CreateFromInt32(nLeadZeroes);
23824e8031e0SArmin Le Grand
23834e8031e0SArmin Le Grand aFormat += sThousand;
23844e8031e0SArmin Le Grand aFormat += sBreak;
23854e8031e0SArmin Le Grand aFormat += sNegRed;
23864e8031e0SArmin Le Grand aFormat += sBreak;
23874e8031e0SArmin Le Grand aFormat += sPrecision;
23884e8031e0SArmin Le Grand aFormat += sBreak;
23894e8031e0SArmin Le Grand aFormat += sLeadZeroes;
23904e8031e0SArmin Le Grand aFormat += sBreak;
23914e8031e0SArmin Le Grand
23924e8031e0SArmin Le Grand rSet.Put(SfxStringItem(nWhich, aFormat));
23934e8031e0SArmin Le Grand }
23944e8031e0SArmin Le Grand else
2395cdf0e10cSrcweir {
23964e8031e0SArmin Le Grand rSet.InvalidateItem( nWhich );
23974e8031e0SArmin Le Grand }
23984e8031e0SArmin Le Grand }
23994e8031e0SArmin Le Grand break;
2400cdf0e10cSrcweir
24014e8031e0SArmin Le Grand case SID_NUMBER_TYPE_FORMAT:
24024e8031e0SArmin Le Grand {
24034e8031e0SArmin Le Grand sal_Int16 aFormatCode = -1;
24044e8031e0SArmin Le Grand const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet();
24054e8031e0SArmin Le Grand if ( rAttrSet.GetItemState( ATTR_VALUE_FORMAT ) >= SFX_ITEM_AVAILABLE ) //Modify for more robust
24064e8031e0SArmin Le Grand {
2407cdf0e10cSrcweir SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
24084e8031e0SArmin Le Grand sal_uInt32 nNumberFormat = pTabViewShell->GetSelectionPattern()->GetNumberFormat( pFormatter );
2409cdf0e10cSrcweir const SvNumberformat* pFormatEntry = pFormatter->GetEntry( nNumberFormat );
24104e8031e0SArmin Le Grand bool bStandard = false;
24114e8031e0SArmin Le Grand
2412cdf0e10cSrcweir if ( pFormatEntry )
24134e8031e0SArmin Le Grand {
24144e8031e0SArmin Le Grand aFormatCode = pFormatEntry->GetType();
24154e8031e0SArmin Le Grand bStandard = pFormatEntry->IsStandard();
24164e8031e0SArmin Le Grand }
2417cdf0e10cSrcweir
24184e8031e0SArmin Le Grand switch(aFormatCode)
24194e8031e0SArmin Le Grand {
24204e8031e0SArmin Le Grand case NUMBERFORMAT_NUMBER:
24214e8031e0SArmin Le Grand case NUMBERFORMAT_NUMBER| NUMBERFORMAT_DEFINED:
24224e8031e0SArmin Le Grand //use format code and standard format code to judge whether it is General,
24234e8031e0SArmin Le Grand //if (nNumberFormat == nStandardNumberFormat)
24244e8031e0SArmin Le Grand if (bStandard)
24254e8031e0SArmin Le Grand aFormatCode = 0;
24264e8031e0SArmin Le Grand else
24274e8031e0SArmin Le Grand aFormatCode = 1;
24284e8031e0SArmin Le Grand break;
24294e8031e0SArmin Le Grand case NUMBERFORMAT_PERCENT:
24304e8031e0SArmin Le Grand case NUMBERFORMAT_PERCENT| NUMBERFORMAT_DEFINED:
24314e8031e0SArmin Le Grand aFormatCode = 2;
24324e8031e0SArmin Le Grand break;
24334e8031e0SArmin Le Grand case NUMBERFORMAT_CURRENCY:
24344e8031e0SArmin Le Grand case NUMBERFORMAT_CURRENCY| NUMBERFORMAT_DEFINED:
24354e8031e0SArmin Le Grand aFormatCode = 3;
24364e8031e0SArmin Le Grand break;
24374e8031e0SArmin Le Grand case NUMBERFORMAT_DATE:
24384e8031e0SArmin Le Grand case NUMBERFORMAT_DATE| NUMBERFORMAT_DEFINED:
24394e8031e0SArmin Le Grand //Add
24404e8031e0SArmin Le Grand case NUMBERFORMAT_DATETIME:
24414e8031e0SArmin Le Grand case NUMBERFORMAT_DATETIME | NUMBERFORMAT_DEFINED:
24424e8031e0SArmin Le Grand aFormatCode = 4;
24434e8031e0SArmin Le Grand break;
24444e8031e0SArmin Le Grand case NUMBERFORMAT_TIME:
24454e8031e0SArmin Le Grand case NUMBERFORMAT_TIME| NUMBERFORMAT_DEFINED:
24464e8031e0SArmin Le Grand aFormatCode = 5;
24474e8031e0SArmin Le Grand break;
24484e8031e0SArmin Le Grand case NUMBERFORMAT_SCIENTIFIC:
24494e8031e0SArmin Le Grand case NUMBERFORMAT_SCIENTIFIC| NUMBERFORMAT_DEFINED:
24504e8031e0SArmin Le Grand aFormatCode = 6;
24514e8031e0SArmin Le Grand break;
24524e8031e0SArmin Le Grand case NUMBERFORMAT_FRACTION:
24534e8031e0SArmin Le Grand case NUMBERFORMAT_FRACTION| NUMBERFORMAT_DEFINED:
24544e8031e0SArmin Le Grand aFormatCode = 7;
24554e8031e0SArmin Le Grand break;
24564e8031e0SArmin Le Grand case NUMBERFORMAT_LOGICAL:
24574e8031e0SArmin Le Grand case NUMBERFORMAT_LOGICAL| NUMBERFORMAT_DEFINED:
24584e8031e0SArmin Le Grand aFormatCode = 8;
24594e8031e0SArmin Le Grand break;
24604e8031e0SArmin Le Grand case NUMBERFORMAT_TEXT:
24614e8031e0SArmin Le Grand case NUMBERFORMAT_TEXT| NUMBERFORMAT_DEFINED:
24624e8031e0SArmin Le Grand aFormatCode = 9;
24634e8031e0SArmin Le Grand break;
24644e8031e0SArmin Le Grand default:
24654e8031e0SArmin Le Grand aFormatCode = -1; //for more roburst
24664e8031e0SArmin Le Grand }
24674e8031e0SArmin Le Grand if( aFormatCode == -1 )
24684e8031e0SArmin Le Grand rSet.InvalidateItem( nWhich );
24694e8031e0SArmin Le Grand else
24704e8031e0SArmin Le Grand rSet.Put( SfxInt16Item( nWhich, aFormatCode ) );
24714e8031e0SArmin Le Grand }
24724e8031e0SArmin Le Grand else
24734e8031e0SArmin Le Grand {
24744e8031e0SArmin Le Grand rSet.InvalidateItem( nWhich );
24754e8031e0SArmin Le Grand }
24764e8031e0SArmin Le Grand
2477cdf0e10cSrcweir }
2478cdf0e10cSrcweir break;
2479cdf0e10cSrcweir }
2480cdf0e10cSrcweir nWhich = aIter.NextWhich();
2481cdf0e10cSrcweir }
2482cdf0e10cSrcweir }
2483cdf0e10cSrcweir
2484cdf0e10cSrcweir
ExecuteTextDirection(SfxRequest & rReq)2485cdf0e10cSrcweir void ScFormatShell::ExecuteTextDirection( SfxRequest& rReq )
2486cdf0e10cSrcweir {
2487cdf0e10cSrcweir ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
2488cdf0e10cSrcweir pTabViewShell->HideListBox(); // Autofilter-DropDown-Listbox
2489cdf0e10cSrcweir if ( GetViewData()->HasEditView( GetViewData()->GetActivePart() ) )
2490cdf0e10cSrcweir {
2491cdf0e10cSrcweir SC_MOD()->InputEnterHandler();
2492cdf0e10cSrcweir pTabViewShell->UpdateInputHandler();
2493cdf0e10cSrcweir }
2494cdf0e10cSrcweir
2495cdf0e10cSrcweir sal_uInt16 nSlot = rReq.GetSlot();
2496cdf0e10cSrcweir switch( nSlot )
2497cdf0e10cSrcweir {
2498cdf0e10cSrcweir case SID_TEXTDIRECTION_LEFT_TO_RIGHT:
2499cdf0e10cSrcweir case SID_TEXTDIRECTION_TOP_TO_BOTTOM:
2500cdf0e10cSrcweir {
2501cdf0e10cSrcweir sal_Bool bVert = (nSlot == SID_TEXTDIRECTION_TOP_TO_BOTTOM);
2502cdf0e10cSrcweir ScPatternAttr aAttr( GetViewData()->GetDocument()->GetPool() );
2503cdf0e10cSrcweir SfxItemSet& rItemSet = aAttr.GetItemSet();
2504cdf0e10cSrcweir rItemSet.Put( SfxBoolItem( ATTR_STACKED, bVert ) );
2505cdf0e10cSrcweir rItemSet.Put( SfxBoolItem( ATTR_VERTICAL_ASIAN, bVert ) );
2506cdf0e10cSrcweir pTabViewShell->ApplySelectionPattern( aAttr );
2507cdf0e10cSrcweir pTabViewShell->AdjustBlockHeight();
2508cdf0e10cSrcweir }
2509cdf0e10cSrcweir break;
2510cdf0e10cSrcweir
2511cdf0e10cSrcweir case SID_ATTR_PARA_LEFT_TO_RIGHT:
2512cdf0e10cSrcweir case SID_ATTR_PARA_RIGHT_TO_LEFT:
2513cdf0e10cSrcweir {
2514cdf0e10cSrcweir SvxFrameDirection eDirection = ( nSlot == SID_ATTR_PARA_LEFT_TO_RIGHT ) ?
2515cdf0e10cSrcweir FRMDIR_HORI_LEFT_TOP : FRMDIR_HORI_RIGHT_TOP;
2516cdf0e10cSrcweir pTabViewShell->ApplyAttr( SvxFrameDirectionItem( eDirection, ATTR_WRITINGDIR ) );
2517cdf0e10cSrcweir }
2518cdf0e10cSrcweir break;
2519cdf0e10cSrcweir }
2520cdf0e10cSrcweir }
2521cdf0e10cSrcweir
GetTextDirectionState(SfxItemSet & rSet)2522cdf0e10cSrcweir void ScFormatShell::GetTextDirectionState( SfxItemSet& rSet )
2523cdf0e10cSrcweir {
2524cdf0e10cSrcweir ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
2525cdf0e10cSrcweir const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet();
2526cdf0e10cSrcweir
2527cdf0e10cSrcweir sal_Bool bVertDontCare =
2528cdf0e10cSrcweir (rAttrSet.GetItemState( ATTR_VERTICAL_ASIAN ) == SFX_ITEM_DONTCARE) ||
2529cdf0e10cSrcweir (rAttrSet.GetItemState( ATTR_STACKED ) == SFX_ITEM_DONTCARE);
2530cdf0e10cSrcweir sal_Bool bLeftRight = !bVertDontCare &&
2531cdf0e10cSrcweir !((const SfxBoolItem&) rAttrSet.Get( ATTR_STACKED )).GetValue();
2532cdf0e10cSrcweir sal_Bool bTopBottom = !bVertDontCare && !bLeftRight &&
2533cdf0e10cSrcweir ((const SfxBoolItem&) rAttrSet.Get( ATTR_VERTICAL_ASIAN )).GetValue();
2534cdf0e10cSrcweir
2535cdf0e10cSrcweir sal_Bool bBidiDontCare = (rAttrSet.GetItemState( ATTR_WRITINGDIR ) == SFX_ITEM_DONTCARE);
2536cdf0e10cSrcweir EEHorizontalTextDirection eBidiDir = EE_HTEXTDIR_DEFAULT;
2537cdf0e10cSrcweir if ( !bBidiDontCare )
2538cdf0e10cSrcweir {
2539cdf0e10cSrcweir SvxFrameDirection eCellDir = (SvxFrameDirection)((const SvxFrameDirectionItem&)
2540cdf0e10cSrcweir rAttrSet.Get( ATTR_WRITINGDIR )).GetValue();
2541cdf0e10cSrcweir if ( eCellDir == FRMDIR_ENVIRONMENT )
2542cdf0e10cSrcweir eBidiDir = (EEHorizontalTextDirection)GetViewData()->GetDocument()->
2543cdf0e10cSrcweir GetEditTextDirection( GetViewData()->GetTabNo() );
2544cdf0e10cSrcweir else if ( eCellDir == FRMDIR_HORI_RIGHT_TOP )
2545cdf0e10cSrcweir eBidiDir = EE_HTEXTDIR_R2L;
2546cdf0e10cSrcweir else
2547cdf0e10cSrcweir eBidiDir = EE_HTEXTDIR_L2R;
2548cdf0e10cSrcweir }
2549cdf0e10cSrcweir
2550cdf0e10cSrcweir SvtLanguageOptions aLangOpt;
2551cdf0e10cSrcweir sal_Bool bDisableCTLFont = !aLangOpt.IsCTLFontEnabled();
2552cdf0e10cSrcweir sal_Bool bDisableVerticalText = !aLangOpt.IsVerticalTextEnabled();
2553cdf0e10cSrcweir
2554cdf0e10cSrcweir SfxWhichIter aIter( rSet );
2555cdf0e10cSrcweir sal_uInt16 nWhich = aIter.FirstWhich();
2556cdf0e10cSrcweir while( nWhich )
2557cdf0e10cSrcweir {
2558cdf0e10cSrcweir switch( nWhich )
2559cdf0e10cSrcweir {
2560cdf0e10cSrcweir case SID_TEXTDIRECTION_LEFT_TO_RIGHT:
2561cdf0e10cSrcweir case SID_TEXTDIRECTION_TOP_TO_BOTTOM:
2562cdf0e10cSrcweir if ( bDisableVerticalText )
2563cdf0e10cSrcweir rSet.DisableItem( nWhich );
2564cdf0e10cSrcweir else
2565cdf0e10cSrcweir {
2566cdf0e10cSrcweir if( bVertDontCare )
2567cdf0e10cSrcweir rSet.InvalidateItem( nWhich );
2568cdf0e10cSrcweir else if ( nWhich == SID_TEXTDIRECTION_LEFT_TO_RIGHT )
2569cdf0e10cSrcweir rSet.Put( SfxBoolItem( nWhich, bLeftRight ) );
2570cdf0e10cSrcweir else
2571cdf0e10cSrcweir rSet.Put( SfxBoolItem( nWhich, bTopBottom ) );
2572cdf0e10cSrcweir }
2573cdf0e10cSrcweir break;
2574cdf0e10cSrcweir
2575cdf0e10cSrcweir case SID_ATTR_PARA_LEFT_TO_RIGHT:
2576cdf0e10cSrcweir case SID_ATTR_PARA_RIGHT_TO_LEFT:
2577cdf0e10cSrcweir if ( bDisableCTLFont )
2578cdf0e10cSrcweir rSet.DisableItem( nWhich );
2579cdf0e10cSrcweir else
2580cdf0e10cSrcweir {
2581cdf0e10cSrcweir if ( bTopBottom )
2582cdf0e10cSrcweir rSet.DisableItem( nWhich );
2583cdf0e10cSrcweir else if ( bBidiDontCare )
2584cdf0e10cSrcweir rSet.InvalidateItem( nWhich );
2585cdf0e10cSrcweir else if ( nWhich == SID_ATTR_PARA_LEFT_TO_RIGHT )
2586cdf0e10cSrcweir rSet.Put( SfxBoolItem( nWhich, eBidiDir == EE_HTEXTDIR_L2R ) );
2587cdf0e10cSrcweir else
2588cdf0e10cSrcweir rSet.Put( SfxBoolItem( nWhich, eBidiDir == EE_HTEXTDIR_R2L ) );
2589cdf0e10cSrcweir }
2590cdf0e10cSrcweir }
2591cdf0e10cSrcweir nWhich = aIter.NextWhich();
2592cdf0e10cSrcweir }
2593cdf0e10cSrcweir }
2594cdf0e10cSrcweir
ExecFormatPaintbrush(SfxRequest & rReq)2595cdf0e10cSrcweir void ScFormatShell::ExecFormatPaintbrush( SfxRequest& rReq )
2596cdf0e10cSrcweir {
2597cdf0e10cSrcweir ScViewFunc* pView = pViewData->GetView();
2598cdf0e10cSrcweir if ( pView->HasPaintBrush() )
2599cdf0e10cSrcweir {
2600cdf0e10cSrcweir // cancel paintbrush mode
2601cdf0e10cSrcweir pView->ResetBrushDocument();
2602cdf0e10cSrcweir }
2603cdf0e10cSrcweir else
2604cdf0e10cSrcweir {
2605cdf0e10cSrcweir sal_Bool bLock = sal_False;
2606cdf0e10cSrcweir const SfxItemSet *pArgs = rReq.GetArgs();
2607cdf0e10cSrcweir if( pArgs && pArgs->Count() >= 1 )
2608cdf0e10cSrcweir bLock = static_cast<const SfxBoolItem&>(pArgs->Get(SID_FORMATPAINTBRUSH)).GetValue();
2609cdf0e10cSrcweir
2610cdf0e10cSrcweir // in case of multi selection, deselect all and use the cursor position
2611cdf0e10cSrcweir ScRange aDummy;
2612cdf0e10cSrcweir if ( pViewData->GetSimpleArea(aDummy) != SC_MARK_SIMPLE )
2613cdf0e10cSrcweir pView->Unmark();
2614cdf0e10cSrcweir
2615cdf0e10cSrcweir ScDocument* pBrushDoc = new ScDocument( SCDOCMODE_CLIP );
2616cdf0e10cSrcweir pView->CopyToClip( pBrushDoc, sal_False, sal_True );
2617cdf0e10cSrcweir pView->SetBrushDocument( pBrushDoc, bLock );
2618cdf0e10cSrcweir }
2619cdf0e10cSrcweir }
2620cdf0e10cSrcweir
StateFormatPaintbrush(SfxItemSet & rSet)2621cdf0e10cSrcweir void ScFormatShell::StateFormatPaintbrush( SfxItemSet& rSet )
2622cdf0e10cSrcweir {
2623cdf0e10cSrcweir if ( pViewData->HasEditView( pViewData->GetActivePart() ) )
2624cdf0e10cSrcweir rSet.DisableItem( SID_FORMATPAINTBRUSH );
2625cdf0e10cSrcweir else
2626cdf0e10cSrcweir rSet.Put( SfxBoolItem( SID_FORMATPAINTBRUSH, pViewData->GetView()->HasPaintBrush() ) );
2627cdf0e10cSrcweir }
2628cdf0e10cSrcweir
ExecViewOptions(SfxRequest & rReq)2629facb16e7SArmin Le Grand void ScFormatShell::ExecViewOptions( SfxRequest& rReq )
2630facb16e7SArmin Le Grand {
2631facb16e7SArmin Le Grand ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
2632facb16e7SArmin Le Grand SfxBindings& rBindings = pViewData->GetBindings();
2633facb16e7SArmin Le Grand const SfxItemSet* pNewAttrs = rReq.GetArgs();
2634facb16e7SArmin Le Grand
2635facb16e7SArmin Le Grand if ( pNewAttrs )
2636facb16e7SArmin Le Grand {
2637facb16e7SArmin Le Grand sal_uInt16 nSlot = rReq.GetSlot();
2638facb16e7SArmin Le Grand
2639facb16e7SArmin Le Grand if( nSlot == SID_SCGRIDSHOW)
2640facb16e7SArmin Le Grand {
2641facb16e7SArmin Le Grand
2642facb16e7SArmin Le Grand ScViewData* pViewData = pTabViewShell->GetViewData();
2643facb16e7SArmin Le Grand const ScViewOptions& rOldOpt = pViewData->GetOptions();
2644facb16e7SArmin Le Grand ScDocShell* pDocSh = PTR_CAST(ScDocShell, SfxObjectShell::Current());
2645facb16e7SArmin Le Grand bool bState = ((const SfxBoolItem &)pNewAttrs->Get( pNewAttrs->GetPool()->GetWhich( nSlot ) )).GetValue();
2646facb16e7SArmin Le Grand
2647facb16e7SArmin Le Grand if ( (bool)rOldOpt.GetOption( VOPT_GRID ) != bState)
2648facb16e7SArmin Le Grand {
2649facb16e7SArmin Le Grand ScViewOptions rNewOpt(rOldOpt);
2650facb16e7SArmin Le Grand rNewOpt.SetOption( VOPT_GRID, bState);
2651facb16e7SArmin Le Grand pViewData->SetOptions( rNewOpt );
2652facb16e7SArmin Le Grand pViewData->GetDocument()->SetViewOptions( rNewOpt );
2653facb16e7SArmin Le Grand pDocSh->SetDocumentModified();
2654facb16e7SArmin Le Grand //add , write the change to sc view config
2655facb16e7SArmin Le Grand ScModule* pScMod = SC_MOD();
2656facb16e7SArmin Le Grand pScMod->SetViewOptions( rNewOpt );
2657facb16e7SArmin Le Grand //add end
2658facb16e7SArmin Le Grand rBindings.Invalidate( nSlot );
2659facb16e7SArmin Le Grand }
2660facb16e7SArmin Le Grand }
2661facb16e7SArmin Le Grand }
2662facb16e7SArmin Le Grand
2663facb16e7SArmin Le Grand }
2664facb16e7SArmin Le Grand
GetViewOptions(SfxItemSet & rSet)2665facb16e7SArmin Le Grand void ScFormatShell::GetViewOptions( SfxItemSet& rSet )
2666facb16e7SArmin Le Grand {
2667facb16e7SArmin Le Grand ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
2668facb16e7SArmin Le Grand if( pTabViewShell )
2669facb16e7SArmin Le Grand {
2670facb16e7SArmin Le Grand ScViewOptions aViewOpt = pTabViewShell->GetViewData()->GetOptions();
2671facb16e7SArmin Le Grand rSet.ClearItem(SID_SCGRIDSHOW);
2672facb16e7SArmin Le Grand SfxBoolItem aItem( SID_SCGRIDSHOW, aViewOpt.GetOption( VOPT_GRID ) );
2673facb16e7SArmin Le Grand rSet.Put(aItem);
2674facb16e7SArmin Le Grand }
2675facb16e7SArmin Le Grand }
2676facb16e7SArmin Le Grand
2677facb16e7SArmin Le Grand // eof
2678