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