xref: /trunk/main/sc/source/ui/miscdlgs/autofmt.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 
33*cdf0e10cSrcweir //------------------------------------------------------------------
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir #include "scitems.hxx"
36*cdf0e10cSrcweir #include <svx/algitem.hxx>
37*cdf0e10cSrcweir #include <editeng/boxitem.hxx>
38*cdf0e10cSrcweir #include <editeng/brshitem.hxx>
39*cdf0e10cSrcweir #include <editeng/cntritem.hxx>
40*cdf0e10cSrcweir #include <editeng/colritem.hxx>
41*cdf0e10cSrcweir #include <editeng/crsditem.hxx>
42*cdf0e10cSrcweir #include <editeng/fontitem.hxx>
43*cdf0e10cSrcweir #include <editeng/postitem.hxx>
44*cdf0e10cSrcweir #include <editeng/shdditem.hxx>
45*cdf0e10cSrcweir #include <editeng/udlnitem.hxx>
46*cdf0e10cSrcweir #include <editeng/wghtitem.hxx>
47*cdf0e10cSrcweir #include <vcl/svapp.hxx>
48*cdf0e10cSrcweir #include <svl/zforlist.hxx>
49*cdf0e10cSrcweir #include <vcl/msgbox.hxx>
50*cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
51*cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir #include "sc.hrc"
54*cdf0e10cSrcweir #include "scmod.hxx"
55*cdf0e10cSrcweir #include "attrib.hxx"
56*cdf0e10cSrcweir #include "zforauto.hxx"
57*cdf0e10cSrcweir #include "scitems.hxx"
58*cdf0e10cSrcweir #include "global.hxx"
59*cdf0e10cSrcweir #include "globstr.hrc"
60*cdf0e10cSrcweir #include "autoform.hxx"
61*cdf0e10cSrcweir //CHINA001 #include "strindlg.hxx"
62*cdf0e10cSrcweir #include "miscdlgs.hrc"
63*cdf0e10cSrcweir #include "autofmt.hxx"
64*cdf0e10cSrcweir #include "scresid.hxx"
65*cdf0e10cSrcweir #include "document.hxx"
66*cdf0e10cSrcweir #include "docsh.hxx"
67*cdf0e10cSrcweir #include "tabvwsh.hxx"
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir #define FRAME_OFFSET 4
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir 
72*cdf0e10cSrcweir //CHINA001 //========================================================================
73*cdf0e10cSrcweir //CHINA001 // AutoFormat-Dialog:
74*cdf0e10cSrcweir //CHINA001
75*cdf0e10cSrcweir //CHINA001 ScAutoFormatDlg::ScAutoFormatDlg( Window*                 pParent,
76*cdf0e10cSrcweir //CHINA001                               ScAutoFormat*             pAutoFormat,
77*cdf0e10cSrcweir //CHINA001                                 const ScAutoFormatData*   pSelFormatData,
78*cdf0e10cSrcweir //CHINA001                                 ScDocument*               pDoc ) :
79*cdf0e10cSrcweir //CHINA001
80*cdf0e10cSrcweir //CHINA001   ModalDialog     ( pParent, ScResId( RID_SCDLG_AUTOFORMAT ) ),
81*cdf0e10cSrcweir //CHINA001   //
82*cdf0e10cSrcweir //CHINA001   aLbFormat       ( this, ScResId( LB_FORMAT ) ),
83*cdf0e10cSrcweir //CHINA001   aFlFormat       ( this, ScResId( FL_FORMAT ) ),
84*cdf0e10cSrcweir //CHINA001   pWndPreview     ( new ScAutoFmtPreview( this, ScResId( WND_PREVIEW ), pDoc ) ),
85*cdf0e10cSrcweir //CHINA001   aBtnNumFormat   ( this, ScResId( BTN_NUMFORMAT ) ),
86*cdf0e10cSrcweir //CHINA001   aBtnBorder      ( this, ScResId( BTN_BORDER ) ),
87*cdf0e10cSrcweir //CHINA001   aBtnFont        ( this, ScResId( BTN_FONT ) ),
88*cdf0e10cSrcweir //CHINA001   aBtnPattern     ( this, ScResId( BTN_PATTERN ) ),
89*cdf0e10cSrcweir //CHINA001   aBtnAlignment   ( this, ScResId( BTN_ALIGNMENT ) ),
90*cdf0e10cSrcweir //CHINA001   aBtnAdjust      ( this, ScResId( BTN_ADJUST ) ),
91*cdf0e10cSrcweir //CHINA001   aFlFormatting   ( this, ScResId( FL_FORMATTING ) ),
92*cdf0e10cSrcweir //CHINA001   aBtnOk          ( this, ScResId( BTN_OK ) ),
93*cdf0e10cSrcweir //CHINA001   aBtnCancel      ( this, ScResId( BTN_CANCEL ) ),
94*cdf0e10cSrcweir //CHINA001   aBtnHelp        ( this, ScResId( BTN_HELP ) ),
95*cdf0e10cSrcweir //CHINA001   aBtnAdd         ( this, ScResId( BTN_ADD ) ),
96*cdf0e10cSrcweir //CHINA001   aBtnRemove      ( this, ScResId( BTN_REMOVE ) ),
97*cdf0e10cSrcweir //CHINA001   aBtnMore        ( this, ScResId( BTN_MORE ) ),
98*cdf0e10cSrcweir //CHINA001   aBtnRename      ( this, ScResId( BTN_RENAME ) ),
99*cdf0e10cSrcweir //CHINA001   aStrTitle       ( ScResId( STR_ADD_TITLE ) ),
100*cdf0e10cSrcweir //CHINA001   aStrLabel       ( ScResId( STR_ADD_LABEL ) ),
101*cdf0e10cSrcweir //CHINA001   aStrRename      ( ScResId( STR_RENAME_TITLE ) ),
102*cdf0e10cSrcweir //CHINA001   aStrClose       ( ScResId( STR_BTN_CLOSE ) ),
103*cdf0e10cSrcweir //CHINA001   aStrDelTitle    ( ScResId( STR_DEL_TITLE ) ),
104*cdf0e10cSrcweir //CHINA001   aStrDelMsg      ( ScResId( STR_DEL_MSG ) ) ,
105*cdf0e10cSrcweir //CHINA001   //
106*cdf0e10cSrcweir //CHINA001   nIndex          ( 0 ),
107*cdf0e10cSrcweir //CHINA001   bFmtInserted    ( sal_False ),
108*cdf0e10cSrcweir //CHINA001   bCoreDataChanged( sal_False ),
109*cdf0e10cSrcweir //CHINA001   pFormat         ( pAutoFormat ),
110*cdf0e10cSrcweir //CHINA001   pSelFmtData     ( pSelFormatData )
111*cdf0e10cSrcweir //CHINA001 {
112*cdf0e10cSrcweir //CHINA001   Init();
113*cdf0e10cSrcweir //CHINA001   pWndPreview->NotifyChange( (*pFormat)[0] );
114*cdf0e10cSrcweir //CHINA001   FreeResource();
115*cdf0e10cSrcweir //CHINA001 }
116*cdf0e10cSrcweir //CHINA001
117*cdf0e10cSrcweir //CHINA001 //------------------------------------------------------------------------
118*cdf0e10cSrcweir //CHINA001
119*cdf0e10cSrcweir //CHINA001 ScAutoFormatDlg::~ScAutoFormatDlg()
120*cdf0e10cSrcweir //CHINA001 {
121*cdf0e10cSrcweir //CHINA001   delete pWndPreview;
122*cdf0e10cSrcweir //CHINA001 }
123*cdf0e10cSrcweir //CHINA001
124*cdf0e10cSrcweir //CHINA001 //------------------------------------------------------------------------
125*cdf0e10cSrcweir //CHINA001
126*cdf0e10cSrcweir //CHINA001 void ScAutoFormatDlg::Init()
127*cdf0e10cSrcweir //CHINA001 {
128*cdf0e10cSrcweir //CHINA001   sal_uInt16 nCount;
129*cdf0e10cSrcweir //CHINA001   String aEntry;
130*cdf0e10cSrcweir //CHINA001
131*cdf0e10cSrcweir //CHINA001   aLbFormat    .SetSelectHdl( LINK( this, ScAutoFormatDlg, SelFmtHdl ) );
132*cdf0e10cSrcweir //CHINA001   aBtnNumFormat.SetClickHdl ( LINK( this, ScAutoFormatDlg, CheckHdl ) );
133*cdf0e10cSrcweir //CHINA001   aBtnBorder   .SetClickHdl ( LINK( this, ScAutoFormatDlg, CheckHdl ) );
134*cdf0e10cSrcweir //CHINA001   aBtnFont     .SetClickHdl ( LINK( this, ScAutoFormatDlg, CheckHdl ) );
135*cdf0e10cSrcweir //CHINA001   aBtnPattern  .SetClickHdl ( LINK( this, ScAutoFormatDlg, CheckHdl ) );
136*cdf0e10cSrcweir //CHINA001   aBtnAlignment.SetClickHdl ( LINK( this, ScAutoFormatDlg, CheckHdl ) );
137*cdf0e10cSrcweir //CHINA001   aBtnAdjust   .SetClickHdl ( LINK( this, ScAutoFormatDlg, CheckHdl ) );
138*cdf0e10cSrcweir //CHINA001   aBtnAdd      .SetClickHdl ( LINK( this, ScAutoFormatDlg, AddHdl ) );
139*cdf0e10cSrcweir //CHINA001   aBtnRemove   .SetClickHdl ( LINK( this, ScAutoFormatDlg, RemoveHdl ) );
140*cdf0e10cSrcweir //CHINA001   aBtnOk       .SetClickHdl ( LINK( this, ScAutoFormatDlg, CloseHdl ) );
141*cdf0e10cSrcweir //CHINA001   aBtnCancel   .SetClickHdl ( LINK( this, ScAutoFormatDlg, CloseHdl ) );
142*cdf0e10cSrcweir //CHINA001   aBtnRename   .SetClickHdl ( LINK( this, ScAutoFormatDlg, RenameHdl ) );
143*cdf0e10cSrcweir //CHINA001   aLbFormat    .SetDoubleClickHdl( LINK( this, ScAutoFormatDlg, DblClkHdl ) );
144*cdf0e10cSrcweir //CHINA001
145*cdf0e10cSrcweir //CHINA001   aBtnMore.AddWindow( &aBtnRename );
146*cdf0e10cSrcweir //CHINA001   aBtnMore.AddWindow( &aBtnNumFormat );
147*cdf0e10cSrcweir //CHINA001   aBtnMore.AddWindow( &aBtnBorder );
148*cdf0e10cSrcweir //CHINA001   aBtnMore.AddWindow( &aBtnFont );
149*cdf0e10cSrcweir //CHINA001   aBtnMore.AddWindow( &aBtnPattern );
150*cdf0e10cSrcweir //CHINA001   aBtnMore.AddWindow( &aBtnAlignment );
151*cdf0e10cSrcweir //CHINA001   aBtnMore.AddWindow( &aBtnAdjust );
152*cdf0e10cSrcweir //CHINA001   aBtnMore.AddWindow( &aFlFormatting );
153*cdf0e10cSrcweir //CHINA001
154*cdf0e10cSrcweir //CHINA001   nCount = pFormat->GetCount();
155*cdf0e10cSrcweir //CHINA001
156*cdf0e10cSrcweir //CHINA001   for ( sal_uInt16 i = 0; i < nCount; i++ )
157*cdf0e10cSrcweir //CHINA001   {
158*cdf0e10cSrcweir //CHINA001     ((*pFormat)[i])->GetName( aEntry );
159*cdf0e10cSrcweir //CHINA001     aLbFormat.InsertEntry( aEntry );
160*cdf0e10cSrcweir //CHINA001   }
161*cdf0e10cSrcweir //CHINA001
162*cdf0e10cSrcweir //CHINA001   if ( nCount == 1 )
163*cdf0e10cSrcweir //CHINA001     aBtnRemove.Disable();
164*cdf0e10cSrcweir //CHINA001
165*cdf0e10cSrcweir //CHINA001   aLbFormat.SelectEntryPos( 0 );
166*cdf0e10cSrcweir //CHINA001   aBtnRename.Disable();
167*cdf0e10cSrcweir //CHINA001   aBtnRemove.Disable();
168*cdf0e10cSrcweir //CHINA001
169*cdf0e10cSrcweir //CHINA001   nIndex = 0;
170*cdf0e10cSrcweir //CHINA001   UpdateChecks();
171*cdf0e10cSrcweir //CHINA001
172*cdf0e10cSrcweir //CHINA001   if ( !pSelFmtData )
173*cdf0e10cSrcweir //CHINA001   {
174*cdf0e10cSrcweir //CHINA001     aBtnAdd.Disable();
175*cdf0e10cSrcweir //CHINA001     aBtnRemove.Disable();
176*cdf0e10cSrcweir //CHINA001     bFmtInserted = sal_True;
177*cdf0e10cSrcweir //CHINA001   }
178*cdf0e10cSrcweir //CHINA001 }
179*cdf0e10cSrcweir //CHINA001
180*cdf0e10cSrcweir //CHINA001 //------------------------------------------------------------------------
181*cdf0e10cSrcweir //CHINA001
182*cdf0e10cSrcweir //CHINA001 void ScAutoFormatDlg::UpdateChecks()
183*cdf0e10cSrcweir //CHINA001 {
184*cdf0e10cSrcweir //CHINA001   ScAutoFormatData* pData = (*pFormat)[nIndex];
185*cdf0e10cSrcweir //CHINA001
186*cdf0e10cSrcweir //CHINA001   aBtnNumFormat.Check( pData->GetIncludeValueFormat() );
187*cdf0e10cSrcweir //CHINA001   aBtnBorder   .Check( pData->GetIncludeFrame() );
188*cdf0e10cSrcweir //CHINA001   aBtnFont     .Check( pData->GetIncludeFont() );
189*cdf0e10cSrcweir //CHINA001   aBtnPattern  .Check( pData->GetIncludeBackground() );
190*cdf0e10cSrcweir //CHINA001   aBtnAlignment.Check( pData->GetIncludeJustify() );
191*cdf0e10cSrcweir //CHINA001   aBtnAdjust   .Check( pData->GetIncludeWidthHeight() );
192*cdf0e10cSrcweir //CHINA001 }
193*cdf0e10cSrcweir //CHINA001
194*cdf0e10cSrcweir //CHINA001 //------------------------------------------------------------------------
195*cdf0e10cSrcweir //CHINA001 // Handler:
196*cdf0e10cSrcweir //CHINA001 //---------
197*cdf0e10cSrcweir //CHINA001
198*cdf0e10cSrcweir //CHINA001 IMPL_LINK( ScAutoFormatDlg, CloseHdl, PushButton *, pBtn )
199*cdf0e10cSrcweir //CHINA001 {
200*cdf0e10cSrcweir //CHINA001   if ( pBtn == &aBtnOk || pBtn == &aBtnCancel )
201*cdf0e10cSrcweir //CHINA001   {
202*cdf0e10cSrcweir //CHINA001     if ( bCoreDataChanged )
203*cdf0e10cSrcweir //CHINA001         ScGlobal::GetAutoFormat()->Save();
204*cdf0e10cSrcweir //CHINA001
205*cdf0e10cSrcweir //CHINA001     EndDialog( (pBtn == &aBtnOk) ? RET_OK : RET_CANCEL );
206*cdf0e10cSrcweir //CHINA001   }
207*cdf0e10cSrcweir //CHINA001   return 0;
208*cdf0e10cSrcweir //CHINA001 }
209*cdf0e10cSrcweir //CHINA001
210*cdf0e10cSrcweir //CHINA001 //------------------------------------------------------------------------
211*cdf0e10cSrcweir //CHINA001
212*cdf0e10cSrcweir //CHINA001 IMPL_LINK_INLINE_START( ScAutoFormatDlg, DblClkHdl, void *, EMPTYARG )
213*cdf0e10cSrcweir //CHINA001 {
214*cdf0e10cSrcweir //CHINA001   if ( bCoreDataChanged )
215*cdf0e10cSrcweir //CHINA001     ScGlobal::GetAutoFormat()->Save();
216*cdf0e10cSrcweir //CHINA001
217*cdf0e10cSrcweir //CHINA001   EndDialog( RET_OK );
218*cdf0e10cSrcweir //CHINA001   return 0;
219*cdf0e10cSrcweir //CHINA001 }
220*cdf0e10cSrcweir //CHINA001 IMPL_LINK_INLINE_END( ScAutoFormatDlg, DblClkHdl, void *, EMPTYARG )
221*cdf0e10cSrcweir //CHINA001
222*cdf0e10cSrcweir //CHINA001 //------------------------------------------------------------------------
223*cdf0e10cSrcweir //CHINA001
224*cdf0e10cSrcweir //CHINA001 IMPL_LINK( ScAutoFormatDlg, CheckHdl, Button *, pBtn )
225*cdf0e10cSrcweir //CHINA001 {
226*cdf0e10cSrcweir //CHINA001   ScAutoFormatData* pData  = (*pFormat)[nIndex];
227*cdf0e10cSrcweir //CHINA001   sal_Bool              bCheck = ((CheckBox*)pBtn)->IsChecked();
228*cdf0e10cSrcweir //CHINA001
229*cdf0e10cSrcweir //CHINA001   if ( pBtn == &aBtnNumFormat )
230*cdf0e10cSrcweir //CHINA001     pData->SetIncludeValueFormat( bCheck );
231*cdf0e10cSrcweir //CHINA001   else if ( pBtn == &aBtnBorder )
232*cdf0e10cSrcweir //CHINA001     pData->SetIncludeFrame( bCheck );
233*cdf0e10cSrcweir //CHINA001   else if ( pBtn == &aBtnFont )
234*cdf0e10cSrcweir //CHINA001     pData->SetIncludeFont( bCheck );
235*cdf0e10cSrcweir //CHINA001   else if ( pBtn == &aBtnPattern )
236*cdf0e10cSrcweir //CHINA001     pData->SetIncludeBackground( bCheck );
237*cdf0e10cSrcweir //CHINA001   else if ( pBtn == &aBtnAlignment )
238*cdf0e10cSrcweir //CHINA001     pData->SetIncludeJustify( bCheck );
239*cdf0e10cSrcweir //CHINA001   else if ( pBtn == &aBtnAdjust )
240*cdf0e10cSrcweir //CHINA001     pData->SetIncludeWidthHeight( bCheck );
241*cdf0e10cSrcweir //CHINA001
242*cdf0e10cSrcweir //CHINA001   if ( !bCoreDataChanged )
243*cdf0e10cSrcweir //CHINA001   {
244*cdf0e10cSrcweir //CHINA001     aBtnCancel.SetText( aStrClose );
245*cdf0e10cSrcweir //CHINA001     bCoreDataChanged = sal_True;
246*cdf0e10cSrcweir //CHINA001   }
247*cdf0e10cSrcweir //CHINA001
248*cdf0e10cSrcweir //CHINA001   pWndPreview->NotifyChange( pData );
249*cdf0e10cSrcweir //CHINA001
250*cdf0e10cSrcweir //CHINA001   return 0;
251*cdf0e10cSrcweir //CHINA001 }
252*cdf0e10cSrcweir //CHINA001
253*cdf0e10cSrcweir //CHINA001 //------------------------------------------------------------------------
254*cdf0e10cSrcweir //CHINA001
255*cdf0e10cSrcweir //CHINA001 IMPL_LINK( ScAutoFormatDlg, AddHdl, void *, EMPTYARG )
256*cdf0e10cSrcweir //CHINA001 {
257*cdf0e10cSrcweir //CHINA001   if ( !bFmtInserted && pSelFmtData )
258*cdf0e10cSrcweir //CHINA001   {
259*cdf0e10cSrcweir //CHINA001     String              aStrStandard( ScResId(STR_STANDARD) );
260*cdf0e10cSrcweir //CHINA001     String              aFormatName;
261*cdf0e10cSrcweir //CHINA001     ScStringInputDlg*   pDlg;
262*cdf0e10cSrcweir //CHINA001     sal_Bool                bOk = sal_False;
263*cdf0e10cSrcweir //CHINA001
264*cdf0e10cSrcweir //CHINA001     while ( !bOk )
265*cdf0e10cSrcweir //CHINA001     {
266*cdf0e10cSrcweir //CHINA001         pDlg = new ScStringInputDlg( this,
267*cdf0e10cSrcweir //CHINA001                                      aStrTitle,
268*cdf0e10cSrcweir //CHINA001                                      aStrLabel,
269*cdf0e10cSrcweir //CHINA001                                      aFormatName,
270*cdf0e10cSrcweir //CHINA001                                      HID_SC_ADD_AUTOFMT );
271*cdf0e10cSrcweir //CHINA001
272*cdf0e10cSrcweir //CHINA001         if ( pDlg->Execute() == RET_OK )
273*cdf0e10cSrcweir //CHINA001         {
274*cdf0e10cSrcweir //CHINA001             pDlg->GetInputString( aFormatName );
275*cdf0e10cSrcweir //CHINA001
276*cdf0e10cSrcweir //CHINA001             if ( (aFormatName.Len() > 0) && (aFormatName != aStrStandard) )
277*cdf0e10cSrcweir //CHINA001             {
278*cdf0e10cSrcweir //CHINA001                 ScAutoFormatData* pNewData
279*cdf0e10cSrcweir //CHINA001                     = new ScAutoFormatData( *pSelFmtData );
280*cdf0e10cSrcweir //CHINA001
281*cdf0e10cSrcweir //CHINA001                 pNewData->SetName( aFormatName );
282*cdf0e10cSrcweir //CHINA001                 bFmtInserted = pFormat->Insert( pNewData );
283*cdf0e10cSrcweir //CHINA001
284*cdf0e10cSrcweir //CHINA001                 if ( bFmtInserted )
285*cdf0e10cSrcweir //CHINA001                 {
286*cdf0e10cSrcweir //CHINA001                     sal_uInt16 nAt = pFormat->IndexOf( pNewData );
287*cdf0e10cSrcweir //CHINA001
288*cdf0e10cSrcweir //CHINA001                     aLbFormat.InsertEntry( aFormatName, nAt );
289*cdf0e10cSrcweir //CHINA001                     aLbFormat.SelectEntry( aFormatName );
290*cdf0e10cSrcweir //CHINA001                     aBtnAdd.Disable();
291*cdf0e10cSrcweir //CHINA001
292*cdf0e10cSrcweir //CHINA001                     if ( !bCoreDataChanged )
293*cdf0e10cSrcweir //CHINA001                     {
294*cdf0e10cSrcweir //CHINA001                         aBtnCancel.SetText( aStrClose );
295*cdf0e10cSrcweir //CHINA001                         bCoreDataChanged = sal_True;
296*cdf0e10cSrcweir //CHINA001                     }
297*cdf0e10cSrcweir //CHINA001
298*cdf0e10cSrcweir //CHINA001                     SelFmtHdl( 0 );
299*cdf0e10cSrcweir //CHINA001                     bOk = sal_True;
300*cdf0e10cSrcweir //CHINA001                 }
301*cdf0e10cSrcweir //CHINA001                 else
302*cdf0e10cSrcweir //CHINA001                     delete pNewData;
303*cdf0e10cSrcweir //CHINA001
304*cdf0e10cSrcweir //CHINA001             }
305*cdf0e10cSrcweir //CHINA001
306*cdf0e10cSrcweir //CHINA001             if ( !bFmtInserted )
307*cdf0e10cSrcweir //CHINA001             {
308*cdf0e10cSrcweir //CHINA001                 sal_uInt16 nRet = ErrorBox( this,
309*cdf0e10cSrcweir //CHINA001                                         WinBits( WB_OK_CANCEL | WB_DEF_OK),
310*cdf0e10cSrcweir //CHINA001                                         ScGlobal::GetRscString(STR_INVALID_AFNAME)
311*cdf0e10cSrcweir //CHINA001                                       ).Execute();
312*cdf0e10cSrcweir //CHINA001
313*cdf0e10cSrcweir //CHINA001                 bOk = ( nRet == RET_CANCEL );
314*cdf0e10cSrcweir //CHINA001             }
315*cdf0e10cSrcweir //CHINA001         }
316*cdf0e10cSrcweir //CHINA001         else
317*cdf0e10cSrcweir //CHINA001             bOk = sal_True;
318*cdf0e10cSrcweir //CHINA001
319*cdf0e10cSrcweir //CHINA001         delete pDlg;
320*cdf0e10cSrcweir //CHINA001     }
321*cdf0e10cSrcweir //CHINA001   }
322*cdf0e10cSrcweir //CHINA001
323*cdf0e10cSrcweir //CHINA001   return 0;
324*cdf0e10cSrcweir //CHINA001 }
325*cdf0e10cSrcweir //CHINA001
326*cdf0e10cSrcweir //CHINA001 //------------------------------------------------------------------------
327*cdf0e10cSrcweir //CHINA001
328*cdf0e10cSrcweir //CHINA001 IMPL_LINK( ScAutoFormatDlg, RemoveHdl, void *, EMPTYARG )
329*cdf0e10cSrcweir //CHINA001 {
330*cdf0e10cSrcweir //CHINA001   if ( (nIndex > 0) && (aLbFormat.GetEntryCount() > 0) )
331*cdf0e10cSrcweir //CHINA001   {
332*cdf0e10cSrcweir //CHINA001     String aMsg( aStrDelMsg.GetToken( 0, '#' ) );
333*cdf0e10cSrcweir //CHINA001
334*cdf0e10cSrcweir //CHINA001     aMsg += aLbFormat.GetSelectEntry();
335*cdf0e10cSrcweir //CHINA001     aMsg += aStrDelMsg.GetToken( 1, '#' );
336*cdf0e10cSrcweir //CHINA001
337*cdf0e10cSrcweir //CHINA001     if ( RET_YES ==
338*cdf0e10cSrcweir //CHINA001          QueryBox( this, WinBits( WB_YES_NO | WB_DEF_YES ), aMsg ).Execute() )
339*cdf0e10cSrcweir //CHINA001     {
340*cdf0e10cSrcweir //CHINA001         aLbFormat.RemoveEntry( nIndex );
341*cdf0e10cSrcweir //CHINA001         aLbFormat.SelectEntryPos( nIndex-1 );
342*cdf0e10cSrcweir //CHINA001
343*cdf0e10cSrcweir //CHINA001         if ( nIndex-1 == 0 )
344*cdf0e10cSrcweir //CHINA001             aBtnRemove.Disable();
345*cdf0e10cSrcweir //CHINA001
346*cdf0e10cSrcweir //CHINA001         if ( !bCoreDataChanged )
347*cdf0e10cSrcweir //CHINA001         {
348*cdf0e10cSrcweir //CHINA001             aBtnCancel.SetText( aStrClose );
349*cdf0e10cSrcweir //CHINA001             bCoreDataChanged = sal_True;
350*cdf0e10cSrcweir //CHINA001         }
351*cdf0e10cSrcweir //CHINA001
352*cdf0e10cSrcweir //CHINA001         pFormat->AtFree( nIndex ); // in der Core loeschen
353*cdf0e10cSrcweir //CHINA001         nIndex--;
354*cdf0e10cSrcweir //CHINA001
355*cdf0e10cSrcweir //CHINA001         SelFmtHdl( 0 );
356*cdf0e10cSrcweir //CHINA001     }
357*cdf0e10cSrcweir //CHINA001   }
358*cdf0e10cSrcweir //CHINA001
359*cdf0e10cSrcweir //CHINA001   SelFmtHdl( 0 );
360*cdf0e10cSrcweir //CHINA001
361*cdf0e10cSrcweir //CHINA001   return 0;
362*cdf0e10cSrcweir //CHINA001 }
363*cdf0e10cSrcweir //CHINA001
364*cdf0e10cSrcweir //CHINA001 IMPL_LINK( ScAutoFormatDlg, RenameHdl, void *, pBtn)
365*cdf0e10cSrcweir //CHINA001 {
366*cdf0e10cSrcweir //CHINA001   sal_Bool bOk = sal_False;
367*cdf0e10cSrcweir //CHINA001   while( !bOk )
368*cdf0e10cSrcweir //CHINA001   {
369*cdf0e10cSrcweir //CHINA001
370*cdf0e10cSrcweir //CHINA001     String aFormatName=aLbFormat.GetSelectEntry();
371*cdf0e10cSrcweir //CHINA001     String aEntry;
372*cdf0e10cSrcweir //CHINA001
373*cdf0e10cSrcweir //CHINA001     ScStringInputDlg* pDlg = new ScStringInputDlg( this,
374*cdf0e10cSrcweir //CHINA001                                      aStrRename,
375*cdf0e10cSrcweir //CHINA001                                      aStrLabel,
376*cdf0e10cSrcweir //CHINA001                                      aFormatName,
377*cdf0e10cSrcweir //CHINA001                                      HID_SC_RENAME_AUTOFMT );
378*cdf0e10cSrcweir //CHINA001     if( pDlg->Execute() == RET_OK )
379*cdf0e10cSrcweir //CHINA001     {
380*cdf0e10cSrcweir //CHINA001         sal_Bool bFmtRenamed = sal_False;
381*cdf0e10cSrcweir //CHINA001         pDlg->GetInputString( aFormatName );
382*cdf0e10cSrcweir //CHINA001         sal_uInt16 n;
383*cdf0e10cSrcweir //CHINA001
384*cdf0e10cSrcweir //CHINA001         if ( aFormatName.Len() > 0 )
385*cdf0e10cSrcweir //CHINA001         {
386*cdf0e10cSrcweir //CHINA001             for( n = 0; n < pFormat->GetCount(); ++n )
387*cdf0e10cSrcweir //CHINA001             {
388*cdf0e10cSrcweir //CHINA001                 (*pFormat)[n]->GetName(aEntry);
389*cdf0e10cSrcweir //CHINA001                 if ( aEntry== aFormatName)
390*cdf0e10cSrcweir //CHINA001                     break;
391*cdf0e10cSrcweir //CHINA001             }
392*cdf0e10cSrcweir //CHINA001             if( n >= pFormat->GetCount() )
393*cdf0e10cSrcweir //CHINA001             {
394*cdf0e10cSrcweir //CHINA001                 // Format mit dem Namen noch nicht vorhanden, also
395*cdf0e10cSrcweir //CHINA001                 // umbenennen
396*cdf0e10cSrcweir //CHINA001
397*cdf0e10cSrcweir //CHINA001                 aLbFormat.RemoveEntry(nIndex );
398*cdf0e10cSrcweir //CHINA001                 ScAutoFormatData* p=(*pFormat)[ nIndex ];
399*cdf0e10cSrcweir //CHINA001                 ScAutoFormatData* pNewData
400*cdf0e10cSrcweir //CHINA001                     = new ScAutoFormatData(*p);
401*cdf0e10cSrcweir //CHINA001
402*cdf0e10cSrcweir //CHINA001                 pFormat->AtFree( nIndex );
403*cdf0e10cSrcweir //CHINA001
404*cdf0e10cSrcweir //CHINA001                 pNewData->SetName( aFormatName );
405*cdf0e10cSrcweir //CHINA001
406*cdf0e10cSrcweir //CHINA001                 pFormat->Insert( pNewData);
407*cdf0e10cSrcweir //CHINA001
408*cdf0e10cSrcweir //CHINA001                 sal_uInt16 nCount = pFormat->GetCount();
409*cdf0e10cSrcweir //CHINA001
410*cdf0e10cSrcweir //CHINA001                 aLbFormat.SetUpdateMode(sal_False);
411*cdf0e10cSrcweir //CHINA001                 aLbFormat.Clear();
412*cdf0e10cSrcweir //CHINA001                 for ( sal_uInt16 i = 0; i < nCount; i++ )
413*cdf0e10cSrcweir //CHINA001                 {
414*cdf0e10cSrcweir //CHINA001                     ((*pFormat)[i])->GetName( aEntry );
415*cdf0e10cSrcweir //CHINA001                     aLbFormat.InsertEntry( aEntry );
416*cdf0e10cSrcweir //CHINA001                 }
417*cdf0e10cSrcweir //CHINA001
418*cdf0e10cSrcweir //CHINA001                 aLbFormat.SetUpdateMode( sal_True);
419*cdf0e10cSrcweir //CHINA001                 aLbFormat.SelectEntry( aFormatName);
420*cdf0e10cSrcweir //CHINA001
421*cdf0e10cSrcweir //CHINA001                 if ( !bCoreDataChanged )
422*cdf0e10cSrcweir //CHINA001                 {
423*cdf0e10cSrcweir //CHINA001                     aBtnCancel.SetText( aStrClose );
424*cdf0e10cSrcweir //CHINA001                     bCoreDataChanged = sal_True;
425*cdf0e10cSrcweir //CHINA001                 }
426*cdf0e10cSrcweir //CHINA001
427*cdf0e10cSrcweir //CHINA001
428*cdf0e10cSrcweir //CHINA001                 SelFmtHdl( 0 );
429*cdf0e10cSrcweir //CHINA001                 bOk = sal_True;
430*cdf0e10cSrcweir //CHINA001                 bFmtRenamed = sal_True;
431*cdf0e10cSrcweir //CHINA001             }
432*cdf0e10cSrcweir //CHINA001         }
433*cdf0e10cSrcweir //CHINA001         if( !bFmtRenamed )
434*cdf0e10cSrcweir //CHINA001         {
435*cdf0e10cSrcweir //CHINA001             bOk = RET_CANCEL == ErrorBox( this,
436*cdf0e10cSrcweir //CHINA001                                 WinBits( WB_OK_CANCEL | WB_DEF_OK),
437*cdf0e10cSrcweir //CHINA001                                 ScGlobal::GetRscString(STR_INVALID_AFNAME)
438*cdf0e10cSrcweir //CHINA001                                 ).Execute();
439*cdf0e10cSrcweir //CHINA001         }
440*cdf0e10cSrcweir //CHINA001     }
441*cdf0e10cSrcweir //CHINA001     else
442*cdf0e10cSrcweir //CHINA001         bOk = sal_True;
443*cdf0e10cSrcweir //CHINA001     delete pDlg;
444*cdf0e10cSrcweir //CHINA001   }
445*cdf0e10cSrcweir //CHINA001
446*cdf0e10cSrcweir //CHINA001   return 0;
447*cdf0e10cSrcweir //CHINA001 }
448*cdf0e10cSrcweir //CHINA001
449*cdf0e10cSrcweir //CHINA001 //------------------------------------------------------------------------
450*cdf0e10cSrcweir //CHINA001
451*cdf0e10cSrcweir //CHINA001 IMPL_LINK( ScAutoFormatDlg, SelFmtHdl, void *, EMPTYARG )
452*cdf0e10cSrcweir //CHINA001 {
453*cdf0e10cSrcweir //CHINA001  nIndex = aLbFormat.GetSelectEntryPos();
454*cdf0e10cSrcweir //CHINA001  UpdateChecks();
455*cdf0e10cSrcweir //CHINA001
456*cdf0e10cSrcweir //CHINA001  if ( nIndex == 0 )
457*cdf0e10cSrcweir //CHINA001  {
458*cdf0e10cSrcweir //CHINA001      aBtnRename.Disable();
459*cdf0e10cSrcweir //CHINA001      aBtnRemove.Disable();
460*cdf0e10cSrcweir //CHINA001  }
461*cdf0e10cSrcweir //CHINA001  else
462*cdf0e10cSrcweir //CHINA001  {
463*cdf0e10cSrcweir //CHINA001      aBtnRename.Enable();
464*cdf0e10cSrcweir //CHINA001      aBtnRemove.Enable();
465*cdf0e10cSrcweir //CHINA001  }
466*cdf0e10cSrcweir //CHINA001
467*cdf0e10cSrcweir //CHINA001  pWndPreview->NotifyChange( (*pFormat)[nIndex] );
468*cdf0e10cSrcweir //CHINA001
469*cdf0e10cSrcweir //CHINA001  return 0;
470*cdf0e10cSrcweir //CHINA001 }
471*cdf0e10cSrcweir //CHINA001
472*cdf0e10cSrcweir //CHINA001 //------------------------------------------------------------------------
473*cdf0e10cSrcweir //CHINA001
474*cdf0e10cSrcweir //CHINA001 String ScAutoFormatDlg::GetCurrFormatName()
475*cdf0e10cSrcweir //CHINA001 {
476*cdf0e10cSrcweir //CHINA001  String  aResult;
477*cdf0e10cSrcweir //CHINA001
478*cdf0e10cSrcweir //CHINA001  ((*pFormat)[nIndex])->GetName( aResult );
479*cdf0e10cSrcweir //CHINA001
480*cdf0e10cSrcweir //CHINA001  return aResult;
481*cdf0e10cSrcweir //CHINA001 }
482*cdf0e10cSrcweir //CHINA001
483*cdf0e10cSrcweir //========================================================================
484*cdf0e10cSrcweir // ScAutoFmtPreview
485*cdf0e10cSrcweir 
486*cdf0e10cSrcweir ScAutoFmtPreview::ScAutoFmtPreview( Window* pParent, const ResId& rRes, ScDocument* pDoc ) :
487*cdf0e10cSrcweir         Window          ( pParent, rRes ),
488*cdf0e10cSrcweir         pCurData        ( NULL ),
489*cdf0e10cSrcweir         aVD             ( *this ),
490*cdf0e10cSrcweir         aScriptedText   ( aVD ),
491*cdf0e10cSrcweir         xBreakIter      ( pDoc->GetBreakIterator() ),
492*cdf0e10cSrcweir         bFitWidth       ( sal_False ),
493*cdf0e10cSrcweir         mbRTL           ( false ),
494*cdf0e10cSrcweir         aPrvSize        ( GetSizePixel().Width() - 6, GetSizePixel().Height() - 30 ),
495*cdf0e10cSrcweir         mnLabelColWidth ( (aPrvSize.Width() - 4) / 4 - 12 ),
496*cdf0e10cSrcweir         mnDataColWidth1 ( (aPrvSize.Width() - 4 - 2 * mnLabelColWidth) / 3 ),
497*cdf0e10cSrcweir         mnDataColWidth2 ( (aPrvSize.Width() - 4 - 2 * mnLabelColWidth) / 4 ),
498*cdf0e10cSrcweir         mnRowHeight     ( (aPrvSize.Height() - 4) / 5 ),
499*cdf0e10cSrcweir         aStrJan         ( ScResId( STR_JAN ) ),
500*cdf0e10cSrcweir         aStrFeb         ( ScResId( STR_FEB ) ),
501*cdf0e10cSrcweir         aStrMar         ( ScResId( STR_MAR ) ),
502*cdf0e10cSrcweir         aStrNorth       ( ScResId( STR_NORTH ) ),
503*cdf0e10cSrcweir         aStrMid         ( ScResId( STR_MID ) ),
504*cdf0e10cSrcweir         aStrSouth       ( ScResId( STR_SOUTH ) ),
505*cdf0e10cSrcweir         aStrSum         ( ScResId( STR_SUM ) ),
506*cdf0e10cSrcweir         pNumFmt         ( new SvNumberFormatter( ::comphelper::getProcessServiceFactory(), ScGlobal::eLnge ) )
507*cdf0e10cSrcweir {
508*cdf0e10cSrcweir     Init();
509*cdf0e10cSrcweir }
510*cdf0e10cSrcweir 
511*cdf0e10cSrcweir //------------------------------------------------------------------------
512*cdf0e10cSrcweir 
513*cdf0e10cSrcweir ScAutoFmtPreview::~ScAutoFmtPreview()
514*cdf0e10cSrcweir {
515*cdf0e10cSrcweir     delete pNumFmt;
516*cdf0e10cSrcweir }
517*cdf0e10cSrcweir 
518*cdf0e10cSrcweir //------------------------------------------------------------------------
519*cdf0e10cSrcweir 
520*cdf0e10cSrcweir void lcl_SetFontProperties(
521*cdf0e10cSrcweir         Font& rFont,
522*cdf0e10cSrcweir         const SvxFontItem& rFontItem,
523*cdf0e10cSrcweir         const SvxWeightItem& rWeightItem,
524*cdf0e10cSrcweir         const SvxPostureItem& rPostureItem )
525*cdf0e10cSrcweir {
526*cdf0e10cSrcweir     rFont.SetFamily     ( rFontItem.GetFamily() );
527*cdf0e10cSrcweir     rFont.SetName       ( rFontItem.GetFamilyName() );
528*cdf0e10cSrcweir     rFont.SetStyleName  ( rFontItem.GetStyleName() );
529*cdf0e10cSrcweir     rFont.SetCharSet    ( rFontItem.GetCharSet() );
530*cdf0e10cSrcweir     rFont.SetPitch      ( rFontItem.GetPitch() );
531*cdf0e10cSrcweir     rFont.SetWeight     ( (FontWeight)rWeightItem.GetValue() );
532*cdf0e10cSrcweir     rFont.SetItalic     ( (FontItalic)rPostureItem.GetValue() );
533*cdf0e10cSrcweir }
534*cdf0e10cSrcweir 
535*cdf0e10cSrcweir void ScAutoFmtPreview::MakeFonts( sal_uInt16 nIndex, Font& rFont, Font& rCJKFont, Font& rCTLFont )
536*cdf0e10cSrcweir {
537*cdf0e10cSrcweir     if ( pCurData )
538*cdf0e10cSrcweir     {
539*cdf0e10cSrcweir         rFont = rCJKFont = rCTLFont = GetFont();
540*cdf0e10cSrcweir         Size aFontSize( rFont.GetSize().Width(), 10 );
541*cdf0e10cSrcweir 
542*cdf0e10cSrcweir         const SvxFontItem*        pFontItem       = (const SvxFontItem*)      pCurData->GetItem( nIndex, ATTR_FONT );
543*cdf0e10cSrcweir         const SvxWeightItem*      pWeightItem     = (const SvxWeightItem*)    pCurData->GetItem( nIndex, ATTR_FONT_WEIGHT );
544*cdf0e10cSrcweir         const SvxPostureItem*     pPostureItem    = (const SvxPostureItem*)   pCurData->GetItem( nIndex, ATTR_FONT_POSTURE );
545*cdf0e10cSrcweir         const SvxFontItem*        pCJKFontItem    = (const SvxFontItem*)      pCurData->GetItem( nIndex, ATTR_CJK_FONT );
546*cdf0e10cSrcweir         const SvxWeightItem*      pCJKWeightItem  = (const SvxWeightItem*)    pCurData->GetItem( nIndex, ATTR_CJK_FONT_WEIGHT );
547*cdf0e10cSrcweir         const SvxPostureItem*     pCJKPostureItem = (const SvxPostureItem*)   pCurData->GetItem( nIndex, ATTR_CJK_FONT_POSTURE );
548*cdf0e10cSrcweir         const SvxFontItem*        pCTLFontItem    = (const SvxFontItem*)      pCurData->GetItem( nIndex, ATTR_CTL_FONT );
549*cdf0e10cSrcweir         const SvxWeightItem*      pCTLWeightItem  = (const SvxWeightItem*)    pCurData->GetItem( nIndex, ATTR_CTL_FONT_WEIGHT );
550*cdf0e10cSrcweir         const SvxPostureItem*     pCTLPostureItem = (const SvxPostureItem*)   pCurData->GetItem( nIndex, ATTR_CTL_FONT_POSTURE );
551*cdf0e10cSrcweir         const SvxUnderlineItem*   pUnderlineItem  = (const SvxUnderlineItem*) pCurData->GetItem( nIndex, ATTR_FONT_UNDERLINE );
552*cdf0e10cSrcweir         const SvxOverlineItem*    pOverlineItem   = (const SvxOverlineItem*)  pCurData->GetItem( nIndex, ATTR_FONT_OVERLINE );
553*cdf0e10cSrcweir         const SvxCrossedOutItem*  pCrossedOutItem = (const SvxCrossedOutItem*)pCurData->GetItem( nIndex, ATTR_FONT_CROSSEDOUT );
554*cdf0e10cSrcweir         const SvxContourItem*     pContourItem    = (const SvxContourItem*)   pCurData->GetItem( nIndex, ATTR_FONT_CONTOUR );
555*cdf0e10cSrcweir         const SvxShadowedItem*    pShadowedItem   = (const SvxShadowedItem*)  pCurData->GetItem( nIndex, ATTR_FONT_SHADOWED );
556*cdf0e10cSrcweir         const SvxColorItem*       pColorItem      = (const SvxColorItem*)     pCurData->GetItem( nIndex, ATTR_FONT_COLOR );
557*cdf0e10cSrcweir 
558*cdf0e10cSrcweir         lcl_SetFontProperties( rFont, *pFontItem, *pWeightItem, *pPostureItem );
559*cdf0e10cSrcweir         lcl_SetFontProperties( rCJKFont, *pCJKFontItem, *pCJKWeightItem, *pCJKPostureItem );
560*cdf0e10cSrcweir         lcl_SetFontProperties( rCTLFont, *pCTLFontItem, *pCTLWeightItem, *pCTLPostureItem );
561*cdf0e10cSrcweir 
562*cdf0e10cSrcweir         Color aColor( pColorItem->GetValue() );
563*cdf0e10cSrcweir         if( aColor.GetColor() == COL_TRANSPARENT )
564*cdf0e10cSrcweir             aColor = GetSettings().GetStyleSettings().GetWindowTextColor();
565*cdf0e10cSrcweir 
566*cdf0e10cSrcweir #define SETONALLFONTS( MethodName, Value ) \
567*cdf0e10cSrcweir rFont.MethodName( Value ); rCJKFont.MethodName( Value ); rCTLFont.MethodName( Value );
568*cdf0e10cSrcweir 
569*cdf0e10cSrcweir         SETONALLFONTS( SetUnderline,    (FontUnderline)pUnderlineItem->GetValue() )
570*cdf0e10cSrcweir         SETONALLFONTS( SetOverline,     (FontUnderline)pOverlineItem->GetValue() )
571*cdf0e10cSrcweir         SETONALLFONTS( SetStrikeout,    (FontStrikeout)pCrossedOutItem->GetValue() )
572*cdf0e10cSrcweir         SETONALLFONTS( SetOutline,      pContourItem->GetValue() )
573*cdf0e10cSrcweir         SETONALLFONTS( SetShadow,       pShadowedItem->GetValue() )
574*cdf0e10cSrcweir         SETONALLFONTS( SetColor,        aColor )
575*cdf0e10cSrcweir         SETONALLFONTS( SetSize,         aFontSize )
576*cdf0e10cSrcweir         SETONALLFONTS( SetTransparent,  sal_True )
577*cdf0e10cSrcweir 
578*cdf0e10cSrcweir #undef SETONALLFONTS
579*cdf0e10cSrcweir     }
580*cdf0e10cSrcweir }
581*cdf0e10cSrcweir 
582*cdf0e10cSrcweir //------------------------------------------------------------------------
583*cdf0e10cSrcweir 
584*cdf0e10cSrcweir sal_uInt16 ScAutoFmtPreview::GetFormatIndex( size_t nCol, size_t nRow ) const
585*cdf0e10cSrcweir {
586*cdf0e10cSrcweir     static const sal_uInt16 pnFmtMap[] =
587*cdf0e10cSrcweir     {
588*cdf0e10cSrcweir         0,  1,  2,  1,  3,
589*cdf0e10cSrcweir         4,  5,  6,  5,  7,
590*cdf0e10cSrcweir         8,  9,  10, 9,  11,
591*cdf0e10cSrcweir         4,  5,  6,  5,  7,
592*cdf0e10cSrcweir         12, 13, 14, 13, 15
593*cdf0e10cSrcweir     };
594*cdf0e10cSrcweir     return pnFmtMap[ maArray.GetCellIndex( nCol, nRow, mbRTL ) ];
595*cdf0e10cSrcweir }
596*cdf0e10cSrcweir 
597*cdf0e10cSrcweir const SvxBoxItem& ScAutoFmtPreview::GetBoxItem( size_t nCol, size_t nRow ) const
598*cdf0e10cSrcweir {
599*cdf0e10cSrcweir     DBG_ASSERT( pCurData, "ScAutoFmtPreview::GetBoxItem - no format data found" );
600*cdf0e10cSrcweir     return *static_cast< const SvxBoxItem* >( pCurData->GetItem( GetFormatIndex( nCol, nRow ), ATTR_BORDER ) );
601*cdf0e10cSrcweir }
602*cdf0e10cSrcweir 
603*cdf0e10cSrcweir const SvxLineItem& ScAutoFmtPreview::GetDiagItem( size_t nCol, size_t nRow, bool bTLBR ) const
604*cdf0e10cSrcweir {
605*cdf0e10cSrcweir     DBG_ASSERT( pCurData, "ScAutoFmtPreview::GetDiagItem - no format data found" );
606*cdf0e10cSrcweir     return *static_cast< const SvxLineItem* >( pCurData->GetItem( GetFormatIndex( nCol, nRow ), bTLBR ? ATTR_BORDER_TLBR : ATTR_BORDER_BLTR ) );
607*cdf0e10cSrcweir }
608*cdf0e10cSrcweir 
609*cdf0e10cSrcweir //------------------------------------------------------------------------
610*cdf0e10cSrcweir 
611*cdf0e10cSrcweir void ScAutoFmtPreview::DrawString( size_t nCol, size_t nRow )
612*cdf0e10cSrcweir {
613*cdf0e10cSrcweir     if ( pCurData )
614*cdf0e10cSrcweir     {
615*cdf0e10cSrcweir         //------------------------
616*cdf0e10cSrcweir         // Ausgabe des Zelltextes:
617*cdf0e10cSrcweir         //------------------------
618*cdf0e10cSrcweir 
619*cdf0e10cSrcweir         String  cellString;
620*cdf0e10cSrcweir         sal_Bool    bNumFormat  = pCurData->GetIncludeValueFormat();
621*cdf0e10cSrcweir         sal_uLong   nNum;
622*cdf0e10cSrcweir         double  nVal;
623*cdf0e10cSrcweir         Color*  pDummy = NULL;
624*cdf0e10cSrcweir         sal_uInt16  nIndex = static_cast< sal_uInt16 >( maArray.GetCellIndex( nCol, nRow, mbRTL ) );
625*cdf0e10cSrcweir 
626*cdf0e10cSrcweir         switch( nIndex )
627*cdf0e10cSrcweir         {
628*cdf0e10cSrcweir             case  1: cellString = aStrJan;          break;
629*cdf0e10cSrcweir             case  2: cellString = aStrFeb;          break;
630*cdf0e10cSrcweir             case  3: cellString = aStrMar;          break;
631*cdf0e10cSrcweir             case  5: cellString = aStrNorth;        break;
632*cdf0e10cSrcweir             case 10: cellString = aStrMid;          break;
633*cdf0e10cSrcweir             case 15: cellString = aStrSouth;        break;
634*cdf0e10cSrcweir             case  4:
635*cdf0e10cSrcweir             case 20: cellString = aStrSum;          break;
636*cdf0e10cSrcweir 
637*cdf0e10cSrcweir             case  6:
638*cdf0e10cSrcweir             case  8:
639*cdf0e10cSrcweir             case 16:
640*cdf0e10cSrcweir             case 18: nVal = nIndex;
641*cdf0e10cSrcweir                      nNum = 5;
642*cdf0e10cSrcweir                      goto mknum;
643*cdf0e10cSrcweir             case 17:
644*cdf0e10cSrcweir             case  7: nVal = nIndex;
645*cdf0e10cSrcweir                      nNum = 6;
646*cdf0e10cSrcweir                      goto mknum;
647*cdf0e10cSrcweir             case 11:
648*cdf0e10cSrcweir             case 12:
649*cdf0e10cSrcweir             case 13: nVal = nIndex;
650*cdf0e10cSrcweir                      nNum = 12 == nIndex ? 10 : 9;
651*cdf0e10cSrcweir                      goto mknum;
652*cdf0e10cSrcweir 
653*cdf0e10cSrcweir             case  9: nVal = 21; nNum = 7; goto mknum;
654*cdf0e10cSrcweir             case 14: nVal = 36; nNum = 11; goto mknum;
655*cdf0e10cSrcweir             case 19: nVal = 51; nNum = 7; goto mknum;
656*cdf0e10cSrcweir             case 21: nVal = 33; nNum = 13; goto mknum;
657*cdf0e10cSrcweir             case 22: nVal = 36; nNum = 14; goto mknum;
658*cdf0e10cSrcweir             case 23: nVal = 39; nNum = 13; goto mknum;
659*cdf0e10cSrcweir             case 24: nVal = 108; nNum = 15;
660*cdf0e10cSrcweir             mknum:
661*cdf0e10cSrcweir                 if( bNumFormat )
662*cdf0e10cSrcweir                 {
663*cdf0e10cSrcweir                     ScNumFormatAbbrev& rNumFormat = (ScNumFormatAbbrev&)pCurData->GetNumFormat( (sal_uInt16) nNum );
664*cdf0e10cSrcweir                     nNum = rNumFormat.GetFormatIndex( *pNumFmt );
665*cdf0e10cSrcweir                 }
666*cdf0e10cSrcweir                 else
667*cdf0e10cSrcweir                     nNum = 0;
668*cdf0e10cSrcweir                 pNumFmt->GetOutputString( nVal, nNum, cellString, &pDummy );
669*cdf0e10cSrcweir                 break;
670*cdf0e10cSrcweir         }
671*cdf0e10cSrcweir 
672*cdf0e10cSrcweir         if ( cellString.Len() > 0 )
673*cdf0e10cSrcweir         {
674*cdf0e10cSrcweir             Size                aStrSize;
675*cdf0e10cSrcweir             sal_uInt16              nFmtIndex       = GetFormatIndex( nCol, nRow );
676*cdf0e10cSrcweir             Rectangle           cellRect        = maArray.GetCellRect( nCol, nRow );
677*cdf0e10cSrcweir             Point               aPos            = cellRect.TopLeft();
678*cdf0e10cSrcweir             sal_uInt16              nRightX         = 0;
679*cdf0e10cSrcweir             sal_Bool                bJustify        = pCurData->GetIncludeJustify();
680*cdf0e10cSrcweir             SvxHorJustifyItem    aHorJustifyItem( SVX_HOR_JUSTIFY_STANDARD, ATTR_HOR_JUSTIFY );
681*cdf0e10cSrcweir             SvxCellHorJustify      eJustification;
682*cdf0e10cSrcweir 
683*cdf0e10cSrcweir             //-------------
684*cdf0e10cSrcweir             // Ausrichtung:
685*cdf0e10cSrcweir             //-------------
686*cdf0e10cSrcweir             eJustification  = mbRTL ? SVX_HOR_JUSTIFY_RIGHT : bJustify ?
687*cdf0e10cSrcweir                 (SvxCellHorJustify)(((const SvxHorJustifyItem*)pCurData->GetItem( nFmtIndex, ATTR_HOR_JUSTIFY ))->GetValue()) :
688*cdf0e10cSrcweir                 SVX_HOR_JUSTIFY_STANDARD;
689*cdf0e10cSrcweir 
690*cdf0e10cSrcweir             if ( pCurData->GetIncludeFont() )
691*cdf0e10cSrcweir             {
692*cdf0e10cSrcweir                 Font aFont, aCJKFont, aCTLFont;
693*cdf0e10cSrcweir                 Size theMaxStrSize;
694*cdf0e10cSrcweir 
695*cdf0e10cSrcweir                 MakeFonts( nFmtIndex, aFont, aCJKFont, aCTLFont );
696*cdf0e10cSrcweir 
697*cdf0e10cSrcweir                 theMaxStrSize           = cellRect.GetSize();
698*cdf0e10cSrcweir                 theMaxStrSize.Width()  -= FRAME_OFFSET;
699*cdf0e10cSrcweir                 theMaxStrSize.Height() -= FRAME_OFFSET;
700*cdf0e10cSrcweir 
701*cdf0e10cSrcweir                 aScriptedText.SetFonts( &aFont, &aCJKFont, &aCTLFont );
702*cdf0e10cSrcweir                 aScriptedText.SetText( cellString, xBreakIter );
703*cdf0e10cSrcweir                 aStrSize = aScriptedText.GetTextSize();
704*cdf0e10cSrcweir 
705*cdf0e10cSrcweir                 if ( theMaxStrSize.Height() < aStrSize.Height() )
706*cdf0e10cSrcweir                 {
707*cdf0e10cSrcweir                     // wenn der String in diesem Font nicht
708*cdf0e10cSrcweir                     // in die Zelle passt, wird wieder der
709*cdf0e10cSrcweir                     // Standard-Font genommen:
710*cdf0e10cSrcweir                     aScriptedText.SetDefaultFont();
711*cdf0e10cSrcweir                     aStrSize = aScriptedText.GetTextSize();
712*cdf0e10cSrcweir                 }
713*cdf0e10cSrcweir                 while ( ( theMaxStrSize.Width() <= aStrSize.Width() )
714*cdf0e10cSrcweir                     && ( cellString.Len() > 1 ) )
715*cdf0e10cSrcweir                 {
716*cdf0e10cSrcweir                     if( eJustification == SVX_HOR_JUSTIFY_RIGHT )
717*cdf0e10cSrcweir                         cellString.Erase( 0, 1 );
718*cdf0e10cSrcweir                     else
719*cdf0e10cSrcweir                         cellString.Erase( cellString.Len() - 1 );
720*cdf0e10cSrcweir 
721*cdf0e10cSrcweir                     aScriptedText.SetText( cellString, xBreakIter );
722*cdf0e10cSrcweir                     aStrSize = aScriptedText.GetTextSize();
723*cdf0e10cSrcweir                 }
724*cdf0e10cSrcweir             }
725*cdf0e10cSrcweir             else
726*cdf0e10cSrcweir             {
727*cdf0e10cSrcweir                 aScriptedText.SetDefaultFont();
728*cdf0e10cSrcweir                 aScriptedText.SetText( cellString, xBreakIter );
729*cdf0e10cSrcweir                 aStrSize = aScriptedText.GetTextSize();
730*cdf0e10cSrcweir             }
731*cdf0e10cSrcweir 
732*cdf0e10cSrcweir             nRightX  = (sal_uInt16)(  cellRect.GetWidth()
733*cdf0e10cSrcweir                                   - aStrSize.Width()
734*cdf0e10cSrcweir                                   - FRAME_OFFSET );
735*cdf0e10cSrcweir 
736*cdf0e10cSrcweir             //-----------------------------
737*cdf0e10cSrcweir             // vertikal (immer zentrieren):
738*cdf0e10cSrcweir             //-----------------------------
739*cdf0e10cSrcweir             aPos.Y() += (mnRowHeight - (sal_uInt16)aStrSize.Height()) / 2;
740*cdf0e10cSrcweir 
741*cdf0e10cSrcweir             //-----------
742*cdf0e10cSrcweir             // horizontal
743*cdf0e10cSrcweir             //-----------
744*cdf0e10cSrcweir             if ( eJustification != SVX_HOR_JUSTIFY_STANDARD )
745*cdf0e10cSrcweir             {
746*cdf0e10cSrcweir                 sal_uInt16 nHorPos = (sal_uInt16)
747*cdf0e10cSrcweir                                  ((cellRect.GetWidth()-aStrSize.Width())/2);
748*cdf0e10cSrcweir 
749*cdf0e10cSrcweir                 switch ( eJustification )
750*cdf0e10cSrcweir                 {
751*cdf0e10cSrcweir                     case SVX_HOR_JUSTIFY_LEFT:
752*cdf0e10cSrcweir                         aPos.X() += FRAME_OFFSET;
753*cdf0e10cSrcweir                         break;
754*cdf0e10cSrcweir                     case SVX_HOR_JUSTIFY_RIGHT:
755*cdf0e10cSrcweir                         aPos.X() += nRightX;
756*cdf0e10cSrcweir                         break;
757*cdf0e10cSrcweir                     case SVX_HOR_JUSTIFY_BLOCK:
758*cdf0e10cSrcweir                     case SVX_HOR_JUSTIFY_REPEAT:
759*cdf0e10cSrcweir                     case SVX_HOR_JUSTIFY_CENTER:
760*cdf0e10cSrcweir                         aPos.X() += nHorPos;
761*cdf0e10cSrcweir                         break;
762*cdf0e10cSrcweir                     case SVX_HOR_JUSTIFY_STANDARD:
763*cdf0e10cSrcweir                     default:
764*cdf0e10cSrcweir                         // Standard wird hier nicht behandelt
765*cdf0e10cSrcweir                         break;
766*cdf0e10cSrcweir                 }
767*cdf0e10cSrcweir             }
768*cdf0e10cSrcweir             else
769*cdf0e10cSrcweir             {
770*cdf0e10cSrcweir                 //---------------------
771*cdf0e10cSrcweir                 // Standardausrichtung:
772*cdf0e10cSrcweir                 //---------------------
773*cdf0e10cSrcweir                 if ( (nCol == 0) || (nRow == 0) )
774*cdf0e10cSrcweir                 {
775*cdf0e10cSrcweir                     // Text-Label links oder Summe linksbuendig
776*cdf0e10cSrcweir                     aPos.X() += FRAME_OFFSET;
777*cdf0e10cSrcweir                 }
778*cdf0e10cSrcweir                 else
779*cdf0e10cSrcweir                 {
780*cdf0e10cSrcweir                      // Zahlen/Datum rechtsbuendig
781*cdf0e10cSrcweir                     aPos.X() += nRightX;
782*cdf0e10cSrcweir                 }
783*cdf0e10cSrcweir             }
784*cdf0e10cSrcweir 
785*cdf0e10cSrcweir             //-------------------------------
786*cdf0e10cSrcweir             aScriptedText.DrawText( aPos );
787*cdf0e10cSrcweir             //-------------------------------
788*cdf0e10cSrcweir         }
789*cdf0e10cSrcweir     }
790*cdf0e10cSrcweir }
791*cdf0e10cSrcweir 
792*cdf0e10cSrcweir #undef FRAME_OFFSET
793*cdf0e10cSrcweir 
794*cdf0e10cSrcweir //------------------------------------------------------------------------
795*cdf0e10cSrcweir 
796*cdf0e10cSrcweir void ScAutoFmtPreview::DrawStrings()
797*cdf0e10cSrcweir {
798*cdf0e10cSrcweir     for( size_t nRow = 0; nRow < 5; ++nRow )
799*cdf0e10cSrcweir         for( size_t nCol = 0; nCol < 5; ++nCol )
800*cdf0e10cSrcweir             DrawString( nCol, nRow );
801*cdf0e10cSrcweir }
802*cdf0e10cSrcweir 
803*cdf0e10cSrcweir //------------------------------------------------------------------------
804*cdf0e10cSrcweir 
805*cdf0e10cSrcweir void ScAutoFmtPreview::DrawBackground()
806*cdf0e10cSrcweir {
807*cdf0e10cSrcweir     if( pCurData )
808*cdf0e10cSrcweir     {
809*cdf0e10cSrcweir         for( size_t nRow = 0; nRow < 5; ++nRow )
810*cdf0e10cSrcweir         {
811*cdf0e10cSrcweir             for( size_t nCol = 0; nCol < 5; ++nCol )
812*cdf0e10cSrcweir             {
813*cdf0e10cSrcweir                 const SvxBrushItem* pItem = static_cast< const SvxBrushItem* >(
814*cdf0e10cSrcweir                     pCurData->GetItem( GetFormatIndex( nCol, nRow ), ATTR_BACKGROUND ) );
815*cdf0e10cSrcweir 
816*cdf0e10cSrcweir                 aVD.Push( PUSH_LINECOLOR | PUSH_FILLCOLOR );
817*cdf0e10cSrcweir                 aVD.SetLineColor();
818*cdf0e10cSrcweir                 aVD.SetFillColor( pItem->GetColor() );
819*cdf0e10cSrcweir                 aVD.DrawRect( maArray.GetCellRect( nCol, nRow ) );
820*cdf0e10cSrcweir                 aVD.Pop();
821*cdf0e10cSrcweir             }
822*cdf0e10cSrcweir         }
823*cdf0e10cSrcweir     }
824*cdf0e10cSrcweir }
825*cdf0e10cSrcweir 
826*cdf0e10cSrcweir //------------------------------------------------------------------------
827*cdf0e10cSrcweir 
828*cdf0e10cSrcweir void ScAutoFmtPreview::PaintCells()
829*cdf0e10cSrcweir {
830*cdf0e10cSrcweir     if ( pCurData )
831*cdf0e10cSrcweir     {
832*cdf0e10cSrcweir         // 1) background
833*cdf0e10cSrcweir         if ( pCurData->GetIncludeBackground() )
834*cdf0e10cSrcweir             DrawBackground();
835*cdf0e10cSrcweir 
836*cdf0e10cSrcweir         // 2) values
837*cdf0e10cSrcweir         DrawStrings();
838*cdf0e10cSrcweir 
839*cdf0e10cSrcweir         // 3) border
840*cdf0e10cSrcweir         if ( pCurData->GetIncludeFrame() )
841*cdf0e10cSrcweir             maArray.DrawArray( aVD );
842*cdf0e10cSrcweir     }
843*cdf0e10cSrcweir }
844*cdf0e10cSrcweir 
845*cdf0e10cSrcweir //------------------------------------------------------------------------
846*cdf0e10cSrcweir 
847*cdf0e10cSrcweir void ScAutoFmtPreview::Init()
848*cdf0e10cSrcweir {
849*cdf0e10cSrcweir     SetBorderStyle( WINDOW_BORDER_MONO );
850*cdf0e10cSrcweir     maArray.Initialize( 5, 5 );
851*cdf0e10cSrcweir     maArray.SetUseDiagDoubleClipping( false );
852*cdf0e10cSrcweir     CalcCellArray( sal_False );
853*cdf0e10cSrcweir     CalcLineMap();
854*cdf0e10cSrcweir 
855*cdf0e10cSrcweir     TypeId aType(TYPE(ScDocShell));
856*cdf0e10cSrcweir     ScDocShell* pDocShell = (ScDocShell*)SfxObjectShell::GetFirst(&aType);
857*cdf0e10cSrcweir     SfxViewFrame* pFrame = SfxViewFrame::GetFirst( pDocShell );
858*cdf0e10cSrcweir     SfxViewShell* p = pFrame->GetViewShell();
859*cdf0e10cSrcweir     ScTabViewShell* pViewSh = dynamic_cast< ScTabViewShell* >( p );
860*cdf0e10cSrcweir     ScViewData* pViewData = pViewSh->GetViewData();
861*cdf0e10cSrcweir     SCTAB nCurrentTab = pViewData->GetTabNo();
862*cdf0e10cSrcweir     ScDocument* pDoc = pViewData->GetDocument();
863*cdf0e10cSrcweir     mbRTL = pDoc->IsLayoutRTL( nCurrentTab );
864*cdf0e10cSrcweir }
865*cdf0e10cSrcweir 
866*cdf0e10cSrcweir //------------------------------------------------------------------------
867*cdf0e10cSrcweir 
868*cdf0e10cSrcweir void ScAutoFmtPreview::CalcCellArray( sal_Bool bFitWidthP )
869*cdf0e10cSrcweir {
870*cdf0e10cSrcweir     maArray.SetXOffset( 2 );
871*cdf0e10cSrcweir     maArray.SetAllColWidths( bFitWidthP ? mnDataColWidth2 : mnDataColWidth1 );
872*cdf0e10cSrcweir     maArray.SetColWidth( 0, mnLabelColWidth );
873*cdf0e10cSrcweir     maArray.SetColWidth( 4, mnLabelColWidth );
874*cdf0e10cSrcweir 
875*cdf0e10cSrcweir     maArray.SetYOffset( 2 );
876*cdf0e10cSrcweir     maArray.SetAllRowHeights( mnRowHeight );
877*cdf0e10cSrcweir 
878*cdf0e10cSrcweir     aPrvSize.Width() = maArray.GetWidth() + 4;
879*cdf0e10cSrcweir     aPrvSize.Height() = maArray.GetHeight() + 4;
880*cdf0e10cSrcweir }
881*cdf0e10cSrcweir 
882*cdf0e10cSrcweir //------------------------------------------------------------------------
883*cdf0e10cSrcweir 
884*cdf0e10cSrcweir inline void lclSetStyleFromBorder( svx::frame::Style& rStyle, const SvxBorderLine* pBorder )
885*cdf0e10cSrcweir {
886*cdf0e10cSrcweir     rStyle.Set( pBorder, 1.0 / TWIPS_PER_POINT, 5 );
887*cdf0e10cSrcweir }
888*cdf0e10cSrcweir 
889*cdf0e10cSrcweir void ScAutoFmtPreview::CalcLineMap()
890*cdf0e10cSrcweir {
891*cdf0e10cSrcweir     if ( pCurData )
892*cdf0e10cSrcweir     {
893*cdf0e10cSrcweir         for( size_t nRow = 0; nRow < 5; ++nRow )
894*cdf0e10cSrcweir         {
895*cdf0e10cSrcweir             for( size_t nCol = 0; nCol < 5; ++nCol )
896*cdf0e10cSrcweir             {
897*cdf0e10cSrcweir                 svx::frame::Style aStyle;
898*cdf0e10cSrcweir 
899*cdf0e10cSrcweir                 const SvxBoxItem& rItem = GetBoxItem( nCol, nRow );
900*cdf0e10cSrcweir                 lclSetStyleFromBorder( aStyle, rItem.GetLeft() );
901*cdf0e10cSrcweir                 maArray.SetCellStyleLeft( nCol, nRow, aStyle );
902*cdf0e10cSrcweir                 lclSetStyleFromBorder( aStyle, rItem.GetRight() );
903*cdf0e10cSrcweir                 maArray.SetCellStyleRight( nCol, nRow, aStyle );
904*cdf0e10cSrcweir                 lclSetStyleFromBorder( aStyle, rItem.GetTop() );
905*cdf0e10cSrcweir                 maArray.SetCellStyleTop( nCol, nRow, aStyle );
906*cdf0e10cSrcweir                 lclSetStyleFromBorder( aStyle, rItem.GetBottom() );
907*cdf0e10cSrcweir                 maArray.SetCellStyleBottom( nCol, nRow, aStyle );
908*cdf0e10cSrcweir 
909*cdf0e10cSrcweir                 lclSetStyleFromBorder( aStyle, GetDiagItem( nCol, nRow, true ).GetLine() );
910*cdf0e10cSrcweir                 maArray.SetCellStyleTLBR( nCol, nRow, aStyle );
911*cdf0e10cSrcweir                 lclSetStyleFromBorder( aStyle, GetDiagItem( nCol, nRow, false ).GetLine() );
912*cdf0e10cSrcweir                 maArray.SetCellStyleBLTR( nCol, nRow, aStyle );
913*cdf0e10cSrcweir             }
914*cdf0e10cSrcweir         }
915*cdf0e10cSrcweir     }
916*cdf0e10cSrcweir }
917*cdf0e10cSrcweir 
918*cdf0e10cSrcweir //------------------------------------------------------------------------
919*cdf0e10cSrcweir 
920*cdf0e10cSrcweir void ScAutoFmtPreview::NotifyChange( ScAutoFormatData* pNewData )
921*cdf0e10cSrcweir {
922*cdf0e10cSrcweir     if ( pNewData != pCurData )
923*cdf0e10cSrcweir     {
924*cdf0e10cSrcweir         pCurData  = pNewData;
925*cdf0e10cSrcweir         bFitWidth = pNewData->GetIncludeWidthHeight();
926*cdf0e10cSrcweir         CalcCellArray( bFitWidth );
927*cdf0e10cSrcweir         CalcLineMap();
928*cdf0e10cSrcweir     }
929*cdf0e10cSrcweir     else if ( bFitWidth != pNewData->GetIncludeWidthHeight() )
930*cdf0e10cSrcweir     {
931*cdf0e10cSrcweir         bFitWidth = !bFitWidth;
932*cdf0e10cSrcweir         CalcCellArray( bFitWidth );
933*cdf0e10cSrcweir     }
934*cdf0e10cSrcweir 
935*cdf0e10cSrcweir     DoPaint( Rectangle( Point(0,0), GetSizePixel() ) );
936*cdf0e10cSrcweir }
937*cdf0e10cSrcweir 
938*cdf0e10cSrcweir //------------------------------------------------------------------------
939*cdf0e10cSrcweir 
940*cdf0e10cSrcweir void ScAutoFmtPreview::DoPaint( const Rectangle& /* rRect */ )
941*cdf0e10cSrcweir {
942*cdf0e10cSrcweir     sal_uInt32 nOldDrawMode = aVD.GetDrawMode();
943*cdf0e10cSrcweir     //  #105733# SvtAccessibilityOptions::GetIsForBorders is no longer used (always assumed sal_True)
944*cdf0e10cSrcweir     if( GetSettings().GetStyleSettings().GetHighContrastMode() )
945*cdf0e10cSrcweir         aVD.SetDrawMode( DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL | DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT );
946*cdf0e10cSrcweir 
947*cdf0e10cSrcweir     Size aWndSize( GetSizePixel() );
948*cdf0e10cSrcweir     Font aFont( aVD.GetFont() );
949*cdf0e10cSrcweir     Color aBackCol( GetSettings().GetStyleSettings().GetWindowColor() );
950*cdf0e10cSrcweir     Point aTmpPoint;
951*cdf0e10cSrcweir     Rectangle aRect( aTmpPoint, aWndSize );
952*cdf0e10cSrcweir 
953*cdf0e10cSrcweir     aFont.SetTransparent( sal_True );
954*cdf0e10cSrcweir     aVD.SetFont( aFont );
955*cdf0e10cSrcweir     aVD.SetLineColor();
956*cdf0e10cSrcweir     aVD.SetFillColor( aBackCol );
957*cdf0e10cSrcweir     aVD.SetOutputSize( aWndSize );
958*cdf0e10cSrcweir     aVD.DrawRect( aRect );
959*cdf0e10cSrcweir 
960*cdf0e10cSrcweir     PaintCells();
961*cdf0e10cSrcweir     SetLineColor();
962*cdf0e10cSrcweir     SetFillColor( aBackCol );
963*cdf0e10cSrcweir     DrawRect( aRect );
964*cdf0e10cSrcweir 
965*cdf0e10cSrcweir     Point aPos( (aWndSize.Width() - aPrvSize.Width()) / 2, (aWndSize.Height() - aPrvSize.Height()) / 2 );
966*cdf0e10cSrcweir     if (Application::GetSettings().GetLayoutRTL())
967*cdf0e10cSrcweir        aPos.X() = -aPos.X();
968*cdf0e10cSrcweir     DrawOutDev( aPos, aWndSize, Point(), aWndSize, aVD );
969*cdf0e10cSrcweir 
970*cdf0e10cSrcweir     aVD.SetDrawMode( nOldDrawMode );
971*cdf0e10cSrcweir }
972*cdf0e10cSrcweir 
973*cdf0e10cSrcweir //------------------------------------------------------------------------
974*cdf0e10cSrcweir 
975*cdf0e10cSrcweir void ScAutoFmtPreview::Paint( const Rectangle& rRect )
976*cdf0e10cSrcweir {
977*cdf0e10cSrcweir     DoPaint( rRect );
978*cdf0e10cSrcweir }
979*cdf0e10cSrcweir 
980