1*efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*efeef26fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*efeef26fSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*efeef26fSAndrew Rist * distributed with this work for additional information
6*efeef26fSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*efeef26fSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*efeef26fSAndrew Rist * "License"); you may not use this file except in compliance
9*efeef26fSAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
11*efeef26fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13*efeef26fSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*efeef26fSAndrew Rist * software distributed under the License is distributed on an
15*efeef26fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*efeef26fSAndrew Rist * KIND, either express or implied. See the License for the
17*efeef26fSAndrew Rist * specific language governing permissions and limitations
18*efeef26fSAndrew Rist * under the License.
19cdf0e10cSrcweir *
20*efeef26fSAndrew Rist *************************************************************/
21*efeef26fSAndrew Rist
22*efeef26fSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #ifdef SW_DLLIMPLEMENTATION
28cdf0e10cSrcweir #undef SW_DLLIMPLEMENTATION
29cdf0e10cSrcweir #endif
30cdf0e10cSrcweir
31cdf0e10cSrcweir
32cdf0e10cSrcweir
33cdf0e10cSrcweir
34cdf0e10cSrcweir #ifndef _EDIT_HXX //autogen
35cdf0e10cSrcweir #include <vcl/edit.hxx>
36cdf0e10cSrcweir #endif
37cdf0e10cSrcweir #ifndef _MSGBOX_HXX //autogen
38cdf0e10cSrcweir #include <vcl/msgbox.hxx>
39cdf0e10cSrcweir #endif
40cdf0e10cSrcweir #include <vcl/svapp.hxx>
41cdf0e10cSrcweir #include <svl/zforlist.hxx>
42cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
43cdf0e10cSrcweir #include <com/sun/star/i18n/XBreakIterator.hpp>
44cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
45cdf0e10cSrcweir #include <svtools/scriptedtext.hxx>
46cdf0e10cSrcweir #include <svtools/accessibilityoptions.hxx>
47cdf0e10cSrcweir #include <svx/framelinkarray.hxx>
48cdf0e10cSrcweir #include "swmodule.hxx"
49cdf0e10cSrcweir #include "swtypes.hxx"
50cdf0e10cSrcweir #ifndef _VIEW_HXX
51cdf0e10cSrcweir #include "view.hxx"
52cdf0e10cSrcweir #endif
53cdf0e10cSrcweir #include "wrtsh.hxx"
54cdf0e10cSrcweir #include "tblafmt.hxx"
55cdf0e10cSrcweir #ifndef _TAUTOFMT_HXX
56cdf0e10cSrcweir #include "tautofmt.hxx"
57cdf0e10cSrcweir #endif
58cdf0e10cSrcweir #include "shellres.hxx"
59cdf0e10cSrcweir #ifndef _TAUTOFMT_HRC
60cdf0e10cSrcweir #include "tautofmt.hrc"
61cdf0e10cSrcweir #endif
62cdf0e10cSrcweir
63cdf0e10cSrcweir using namespace com::sun::star;
64cdf0e10cSrcweir
65cdf0e10cSrcweir #define FRAME_OFFSET 4
66cdf0e10cSrcweir
67cdf0e10cSrcweir //========================================================================
68cdf0e10cSrcweir
69cdf0e10cSrcweir class AutoFmtPreview : public Window
70cdf0e10cSrcweir {
71cdf0e10cSrcweir public:
72cdf0e10cSrcweir AutoFmtPreview( Window* pParent, const ResId& rRes, SwWrtShell* pWrtShell );
73cdf0e10cSrcweir ~AutoFmtPreview();
74cdf0e10cSrcweir
75cdf0e10cSrcweir void NotifyChange( const SwTableAutoFmt& rNewData );
76cdf0e10cSrcweir
77cdf0e10cSrcweir protected:
78cdf0e10cSrcweir virtual void Paint( const Rectangle& rRect );
79cdf0e10cSrcweir
80cdf0e10cSrcweir private:
81cdf0e10cSrcweir SwTableAutoFmt aCurData;
82cdf0e10cSrcweir VirtualDevice aVD;
83cdf0e10cSrcweir SvtScriptedTextHelper aScriptedText;
84cdf0e10cSrcweir svx::frame::Array maArray; /// Implementation to draw the frame borders.
85cdf0e10cSrcweir sal_Bool bFitWidth;
86cdf0e10cSrcweir bool mbRTL;
87cdf0e10cSrcweir Size aPrvSize;
88cdf0e10cSrcweir long nLabelColWidth;
89cdf0e10cSrcweir long nDataColWidth1;
90cdf0e10cSrcweir long nDataColWidth2;
91cdf0e10cSrcweir long nRowHeight;
92cdf0e10cSrcweir const String aStrJan;
93cdf0e10cSrcweir const String aStrFeb;
94cdf0e10cSrcweir const String aStrMar;
95cdf0e10cSrcweir const String aStrNorth;
96cdf0e10cSrcweir const String aStrMid;
97cdf0e10cSrcweir const String aStrSouth;
98cdf0e10cSrcweir const String aStrSum;
99cdf0e10cSrcweir SvNumberFormatter* pNumFmt;
100cdf0e10cSrcweir
101cdf0e10cSrcweir uno::Reference< lang::XMultiServiceFactory > m_xMSF;
102cdf0e10cSrcweir uno::Reference< i18n::XBreakIterator > m_xBreak;
103cdf0e10cSrcweir
104cdf0e10cSrcweir //-------------------------------------------
105cdf0e10cSrcweir void Init ();
106cdf0e10cSrcweir void DoPaint ( const Rectangle& rRect );
107cdf0e10cSrcweir void CalcCellArray ( sal_Bool bFitWidth );
108cdf0e10cSrcweir void CalcLineMap ();
109cdf0e10cSrcweir void PaintCells ();
110cdf0e10cSrcweir
111cdf0e10cSrcweir sal_uInt8 GetFormatIndex( size_t nCol, size_t nRow ) const;
112cdf0e10cSrcweir const SvxBoxItem& GetBoxItem( size_t nCol, size_t nRow ) const;
113cdf0e10cSrcweir
114cdf0e10cSrcweir void DrawString( size_t nCol, size_t nRow );
115cdf0e10cSrcweir void DrawStrings();
116cdf0e10cSrcweir void DrawBackground();
117cdf0e10cSrcweir
118cdf0e10cSrcweir void MakeFonts ( sal_uInt8 nIndex, Font& rFont, Font& rCJKFont, Font& rCTLFont );
119cdf0e10cSrcweir String MakeNumberString( String cellString, sal_Bool bAddDec );
120cdf0e10cSrcweir };
121cdf0e10cSrcweir
122cdf0e10cSrcweir //========================================================================
123cdf0e10cSrcweir
124cdf0e10cSrcweir class SwStringInputDlg : public ModalDialog
125cdf0e10cSrcweir {
126cdf0e10cSrcweir public:
127cdf0e10cSrcweir SwStringInputDlg( Window* pParent,
128cdf0e10cSrcweir const String& rTitle,
129cdf0e10cSrcweir const String& rEditTitle,
130cdf0e10cSrcweir const String& rDefault );
131cdf0e10cSrcweir ~SwStringInputDlg();
132cdf0e10cSrcweir
133cdf0e10cSrcweir void GetInputString( String& rString ) const;
134cdf0e10cSrcweir
135cdf0e10cSrcweir private:
136cdf0e10cSrcweir Edit aEdInput; // Edit erhaelt so den Focus
137cdf0e10cSrcweir FixedText aFtEditTitle;
138cdf0e10cSrcweir OKButton aBtnOk;
139cdf0e10cSrcweir CancelButton aBtnCancel;
140cdf0e10cSrcweir };
141cdf0e10cSrcweir
142cdf0e10cSrcweir
SwStringInputDlg(Window * pParent,const String & rTitle,const String & rEditTitle,const String & rDefault)143cdf0e10cSrcweir SwStringInputDlg::SwStringInputDlg( Window* pParent,
144cdf0e10cSrcweir const String& rTitle,
145cdf0e10cSrcweir const String& rEditTitle,
146cdf0e10cSrcweir const String& rDefault ) :
147cdf0e10cSrcweir ModalDialog ( pParent, SW_RES( DLG_SWDLG_STRINPUT ) ),
148cdf0e10cSrcweir //
149cdf0e10cSrcweir aEdInput ( this, SW_RES( ED_INPUT ) ),
150cdf0e10cSrcweir aFtEditTitle ( this, SW_RES( FT_LABEL ) ),
151cdf0e10cSrcweir aBtnOk ( this, SW_RES( BTN_OK ) ),
152cdf0e10cSrcweir aBtnCancel ( this, SW_RES( BTN_CANCEL ) )
153cdf0e10cSrcweir {
154cdf0e10cSrcweir SetText( rTitle );
155cdf0e10cSrcweir aFtEditTitle.SetText( rEditTitle );
156cdf0e10cSrcweir aEdInput.SetText( rDefault );
157cdf0e10cSrcweir //-------------
158cdf0e10cSrcweir FreeResource();
159cdf0e10cSrcweir }
160cdf0e10cSrcweir
161cdf0e10cSrcweir //------------------------------------------------------------------------
162cdf0e10cSrcweir
GetInputString(String & rString) const163cdf0e10cSrcweir void SwStringInputDlg::GetInputString( String& rString ) const
164cdf0e10cSrcweir {
165cdf0e10cSrcweir rString = aEdInput.GetText();
166cdf0e10cSrcweir }
167cdf0e10cSrcweir
168cdf0e10cSrcweir
~SwStringInputDlg()169cdf0e10cSrcweir __EXPORT SwStringInputDlg::~SwStringInputDlg()
170cdf0e10cSrcweir {
171cdf0e10cSrcweir }
172cdf0e10cSrcweir
173cdf0e10cSrcweir //========================================================================
174cdf0e10cSrcweir // AutoFormat-Dialog:
175cdf0e10cSrcweir
176cdf0e10cSrcweir
SwAutoFormatDlg(Window * pParent,SwWrtShell * pWrtShell,sal_Bool bSetAutoFormat,const SwTableAutoFmt * pSelFmt)177cdf0e10cSrcweir SwAutoFormatDlg::SwAutoFormatDlg( Window* pParent, SwWrtShell* pWrtShell,
178cdf0e10cSrcweir sal_Bool bSetAutoFormat, const SwTableAutoFmt* pSelFmt )
179cdf0e10cSrcweir : SfxModalDialog( pParent, SW_RES( DLG_AUTOFMT_TABLE ) ),
180cdf0e10cSrcweir //
181cdf0e10cSrcweir aFlFormat ( this, SW_RES( FL_FORMAT ) ),
182cdf0e10cSrcweir aLbFormat ( this, SW_RES( LB_FORMAT ) ),
183cdf0e10cSrcweir aFlFormats ( this, SW_RES( FL_FORMATS ) ),
184cdf0e10cSrcweir
185cdf0e10cSrcweir aBtnNumFormat ( this, SW_RES( BTN_NUMFORMAT ) ),
186cdf0e10cSrcweir aBtnBorder ( this, SW_RES( BTN_BORDER ) ),
187cdf0e10cSrcweir aBtnFont ( this, SW_RES( BTN_FONT ) ),
188cdf0e10cSrcweir aBtnPattern ( this, SW_RES( BTN_PATTERN ) ),
189cdf0e10cSrcweir aBtnAlignment ( this, SW_RES( BTN_ALIGNMENT ) ),
190cdf0e10cSrcweir aBtnOk ( this, SW_RES( BTN_OK ) ),
191cdf0e10cSrcweir aBtnCancel ( this, SW_RES( BTN_CANCEL ) ),
192cdf0e10cSrcweir aBtnHelp ( this, SW_RES( BTN_HELP ) ),
193cdf0e10cSrcweir aBtnAdd ( this, SW_RES( BTN_ADD ) ),
194cdf0e10cSrcweir aBtnRemove ( this, SW_RES( BTN_REMOVE ) ),
195cdf0e10cSrcweir aBtnRename ( this, SW_RES( BTN_RENAME ) ),
196cdf0e10cSrcweir aBtnMore ( this, SW_RES( BTN_MORE ) ),
197cdf0e10cSrcweir aStrTitle ( SW_RES( STR_ADD_TITLE ) ),
198cdf0e10cSrcweir aStrLabel ( SW_RES( STR_ADD_LABEL ) ),
199cdf0e10cSrcweir aStrClose ( SW_RES( STR_BTN_CLOSE ) ),
200cdf0e10cSrcweir aStrDelTitle ( SW_RES( STR_DEL_TITLE ) ),
201cdf0e10cSrcweir aStrDelMsg ( SW_RES( STR_DEL_MSG ) ),
202cdf0e10cSrcweir aStrRenameTitle ( SW_RES( STR_RENAME_TITLE ) ),
203cdf0e10cSrcweir aStrInvalidFmt ( SW_RES( STR_INVALID_AFNAME )),
204cdf0e10cSrcweir pWndPreview ( new AutoFmtPreview( this, SW_RES( WND_PREVIEW ), pWrtShell )),
205cdf0e10cSrcweir //
206cdf0e10cSrcweir pShell ( pWrtShell ),
207cdf0e10cSrcweir nIndex ( 0 ),
208cdf0e10cSrcweir nDfltStylePos ( 0 ),
209cdf0e10cSrcweir bCoreDataChanged( sal_False ),
210cdf0e10cSrcweir bSetAutoFmt ( bSetAutoFormat )
211cdf0e10cSrcweir {
212cdf0e10cSrcweir pTableTbl = new SwTableAutoFmtTbl;
213cdf0e10cSrcweir pTableTbl->Load();
214cdf0e10cSrcweir
215cdf0e10cSrcweir Init( pSelFmt );
216cdf0e10cSrcweir //------------- >
217cdf0e10cSrcweir FreeResource();
218cdf0e10cSrcweir }
219cdf0e10cSrcweir
220cdf0e10cSrcweir //------------------------------------------------------------------------
221cdf0e10cSrcweir
222cdf0e10cSrcweir
~SwAutoFormatDlg()223cdf0e10cSrcweir __EXPORT SwAutoFormatDlg::~SwAutoFormatDlg()
224cdf0e10cSrcweir {
225cdf0e10cSrcweir delete pWndPreview;
226cdf0e10cSrcweir
227cdf0e10cSrcweir if( bCoreDataChanged )
228cdf0e10cSrcweir pTableTbl->Save();
229cdf0e10cSrcweir delete pTableTbl;
230cdf0e10cSrcweir }
231cdf0e10cSrcweir
232cdf0e10cSrcweir //------------------------------------------------------------------------
233cdf0e10cSrcweir
234cdf0e10cSrcweir
Init(const SwTableAutoFmt * pSelFmt)235cdf0e10cSrcweir void SwAutoFormatDlg::Init( const SwTableAutoFmt* pSelFmt )
236cdf0e10cSrcweir {
237cdf0e10cSrcweir Link aLk( LINK( this, SwAutoFormatDlg, CheckHdl ) );
238cdf0e10cSrcweir aBtnBorder.SetClickHdl( aLk );
239cdf0e10cSrcweir aBtnFont.SetClickHdl( aLk );
240cdf0e10cSrcweir aBtnPattern.SetClickHdl( aLk );
241cdf0e10cSrcweir aBtnAlignment.SetClickHdl( aLk );
242cdf0e10cSrcweir aBtnNumFormat.SetClickHdl( aLk );
243cdf0e10cSrcweir
244cdf0e10cSrcweir aBtnAdd.SetClickHdl ( LINK( this, SwAutoFormatDlg, AddHdl ) );
245cdf0e10cSrcweir aBtnRemove.SetClickHdl ( LINK( this, SwAutoFormatDlg, RemoveHdl ) );
246cdf0e10cSrcweir aBtnRename.SetClickHdl ( LINK( this, SwAutoFormatDlg, RenameHdl ) );
247cdf0e10cSrcweir aBtnOk.SetClickHdl ( LINK( this, SwAutoFormatDlg, OkHdl ) );
248cdf0e10cSrcweir aLbFormat.SetSelectHdl( LINK( this, SwAutoFormatDlg, SelFmtHdl ) );
249cdf0e10cSrcweir
250cdf0e10cSrcweir aBtnMore.AddWindow( &aBtnNumFormat );
251cdf0e10cSrcweir aBtnMore.AddWindow( &aBtnBorder );
252cdf0e10cSrcweir aBtnMore.AddWindow( &aBtnFont );
253cdf0e10cSrcweir aBtnMore.AddWindow( &aBtnPattern );
254cdf0e10cSrcweir aBtnMore.AddWindow( &aBtnAlignment );
255cdf0e10cSrcweir aBtnMore.AddWindow( &aFlFormats );
256cdf0e10cSrcweir aBtnMore.AddWindow( &aBtnRename );
257cdf0e10cSrcweir
258cdf0e10cSrcweir aBtnAdd.Enable( bSetAutoFmt );
259cdf0e10cSrcweir
260cdf0e10cSrcweir nIndex = 0;
261cdf0e10cSrcweir if( !bSetAutoFmt )
262cdf0e10cSrcweir {
263cdf0e10cSrcweir // dann muss die Liste um den Eintrag <Keins> erweitert werden.
264cdf0e10cSrcweir aLbFormat.InsertEntry( ViewShell::GetShellRes()->aStrNone );
265cdf0e10cSrcweir nDfltStylePos = 1;
266cdf0e10cSrcweir nIndex = 255;
267cdf0e10cSrcweir }
268cdf0e10cSrcweir
269cdf0e10cSrcweir for( sal_uInt8 i = 0, nCount = (sal_uInt8)pTableTbl->Count(); i < nCount; i++ )
270cdf0e10cSrcweir {
271cdf0e10cSrcweir SwTableAutoFmt* pFmt = (*pTableTbl)[ i ];
272cdf0e10cSrcweir aLbFormat.InsertEntry( pFmt->GetName() );
273cdf0e10cSrcweir if( pSelFmt && pFmt->GetName() == pSelFmt->GetName() )
274cdf0e10cSrcweir nIndex = i;
275cdf0e10cSrcweir }
276cdf0e10cSrcweir
277cdf0e10cSrcweir aLbFormat.SelectEntryPos( 255 != nIndex ? (nDfltStylePos + nIndex) : 0 );
278cdf0e10cSrcweir SelFmtHdl( 0 );
279cdf0e10cSrcweir }
280cdf0e10cSrcweir
281cdf0e10cSrcweir //------------------------------------------------------------------------
282cdf0e10cSrcweir
283cdf0e10cSrcweir
UpdateChecks(const SwTableAutoFmt & rFmt,sal_Bool bEnable)284cdf0e10cSrcweir void SwAutoFormatDlg::UpdateChecks( const SwTableAutoFmt& rFmt, sal_Bool bEnable )
285cdf0e10cSrcweir {
286cdf0e10cSrcweir aBtnNumFormat.Enable( bEnable );
287cdf0e10cSrcweir aBtnNumFormat.Check( rFmt.IsValueFormat() );
288cdf0e10cSrcweir
289cdf0e10cSrcweir aBtnBorder.Enable( bEnable );
290cdf0e10cSrcweir aBtnBorder.Check( rFmt.IsFrame() );
291cdf0e10cSrcweir
292cdf0e10cSrcweir aBtnFont.Enable( bEnable );
293cdf0e10cSrcweir aBtnFont.Check( rFmt.IsFont() );
294cdf0e10cSrcweir
295cdf0e10cSrcweir aBtnPattern.Enable( bEnable );
296cdf0e10cSrcweir aBtnPattern.Check( rFmt.IsBackground() );
297cdf0e10cSrcweir
298cdf0e10cSrcweir aBtnAlignment.Enable( bEnable );
299cdf0e10cSrcweir aBtnAlignment.Check( rFmt.IsJustify() );
300cdf0e10cSrcweir }
301cdf0e10cSrcweir
FillAutoFmtOfIndex(SwTableAutoFmt * & rToFill) const302cdf0e10cSrcweir void SwAutoFormatDlg::FillAutoFmtOfIndex( SwTableAutoFmt*& rToFill ) const
303cdf0e10cSrcweir {
304cdf0e10cSrcweir if( 255 != nIndex )
305cdf0e10cSrcweir {
306cdf0e10cSrcweir if( rToFill )
307cdf0e10cSrcweir *rToFill = *(*pTableTbl)[ nIndex ];
308cdf0e10cSrcweir else
309cdf0e10cSrcweir rToFill = new SwTableAutoFmt( *(*pTableTbl)[ nIndex ] );
310cdf0e10cSrcweir }
311cdf0e10cSrcweir else if( rToFill )
312cdf0e10cSrcweir delete rToFill, rToFill = 0;
313cdf0e10cSrcweir }
314cdf0e10cSrcweir
315cdf0e10cSrcweir
316cdf0e10cSrcweir /*------------------------------------------------------------------------
317cdf0e10cSrcweir Handler:
318cdf0e10cSrcweir ---------*/
319cdf0e10cSrcweir
320cdf0e10cSrcweir
IMPL_LINK(SwAutoFormatDlg,CheckHdl,Button *,pBtn)321cdf0e10cSrcweir IMPL_LINK( SwAutoFormatDlg, CheckHdl, Button *, pBtn )
322cdf0e10cSrcweir {
323cdf0e10cSrcweir SwTableAutoFmtPtr pData = (*pTableTbl)[nIndex];
324cdf0e10cSrcweir sal_Bool bCheck = ((CheckBox*)pBtn)->IsChecked(), bDataChgd = sal_True;
325cdf0e10cSrcweir
326cdf0e10cSrcweir if( pBtn == &aBtnNumFormat )
327cdf0e10cSrcweir pData->SetValueFormat( bCheck );
328cdf0e10cSrcweir else if ( pBtn == &aBtnBorder )
329cdf0e10cSrcweir pData->SetFrame( bCheck );
330cdf0e10cSrcweir else if ( pBtn == &aBtnFont )
331cdf0e10cSrcweir pData->SetFont( bCheck );
332cdf0e10cSrcweir else if ( pBtn == &aBtnPattern )
333cdf0e10cSrcweir pData->SetBackground( bCheck );
334cdf0e10cSrcweir else if ( pBtn == &aBtnAlignment )
335cdf0e10cSrcweir pData->SetJustify( bCheck );
336cdf0e10cSrcweir // else if ( pBtn == &aBtnAdjust )
337cdf0e10cSrcweir // pData->SetIncludeWidthHeight( bCheck );
338cdf0e10cSrcweir else
339cdf0e10cSrcweir bDataChgd = sal_False;
340cdf0e10cSrcweir
341cdf0e10cSrcweir if( bDataChgd )
342cdf0e10cSrcweir {
343cdf0e10cSrcweir if( !bCoreDataChanged )
344cdf0e10cSrcweir {
345cdf0e10cSrcweir aBtnCancel.SetText( aStrClose );
346cdf0e10cSrcweir bCoreDataChanged = sal_True;
347cdf0e10cSrcweir }
348cdf0e10cSrcweir
349cdf0e10cSrcweir pWndPreview->NotifyChange( *pData );
350cdf0e10cSrcweir }
351cdf0e10cSrcweir return 0;
352cdf0e10cSrcweir }
353cdf0e10cSrcweir
354cdf0e10cSrcweir /*------------------------------------------------------------------------*/
355cdf0e10cSrcweir
356cdf0e10cSrcweir
IMPL_LINK(SwAutoFormatDlg,AddHdl,void *,EMPTYARG)357cdf0e10cSrcweir IMPL_LINK( SwAutoFormatDlg, AddHdl, void *, EMPTYARG )
358cdf0e10cSrcweir {
359cdf0e10cSrcweir sal_Bool bOk = sal_False, bFmtInserted = sal_False;
360cdf0e10cSrcweir while( !bOk )
361cdf0e10cSrcweir {
362cdf0e10cSrcweir SwStringInputDlg* pDlg = new SwStringInputDlg( this,
363cdf0e10cSrcweir aStrTitle,
364cdf0e10cSrcweir aStrLabel,
365cdf0e10cSrcweir aEmptyStr );
366cdf0e10cSrcweir if( RET_OK == pDlg->Execute() )
367cdf0e10cSrcweir {
368cdf0e10cSrcweir String aFormatName;
369cdf0e10cSrcweir pDlg->GetInputString( aFormatName );
370cdf0e10cSrcweir
371cdf0e10cSrcweir if( aFormatName.Len() > 0 )
372cdf0e10cSrcweir {
373cdf0e10cSrcweir sal_uInt16 n;
374cdf0e10cSrcweir for( n = 0; n < pTableTbl->Count(); ++n )
375cdf0e10cSrcweir if( (*pTableTbl)[n]->GetName() == aFormatName )
376cdf0e10cSrcweir break;
377cdf0e10cSrcweir
378cdf0e10cSrcweir if( n >= pTableTbl->Count() )
379cdf0e10cSrcweir {
380cdf0e10cSrcweir // Format mit dem Namen noch nicht vorhanden, also
381cdf0e10cSrcweir // aufnehmen
382cdf0e10cSrcweir SwTableAutoFmtPtr pNewData = new
383cdf0e10cSrcweir SwTableAutoFmt( aFormatName );
384cdf0e10cSrcweir pShell->GetTableAutoFmt( *pNewData );
385cdf0e10cSrcweir
386cdf0e10cSrcweir // Sortiert einfuegen!!
387cdf0e10cSrcweir for( n = 1; n < pTableTbl->Count(); ++n )
388cdf0e10cSrcweir if( (*pTableTbl)[ n ]->GetName() > aFormatName )
389cdf0e10cSrcweir break;
390cdf0e10cSrcweir
391cdf0e10cSrcweir pTableTbl->Insert( pNewData, n );
392cdf0e10cSrcweir aLbFormat.InsertEntry( aFormatName, nDfltStylePos + n );
393cdf0e10cSrcweir aLbFormat.SelectEntryPos( nDfltStylePos + n );
394cdf0e10cSrcweir bFmtInserted = sal_True;
395cdf0e10cSrcweir aBtnAdd.Enable( sal_False );
396cdf0e10cSrcweir if ( !bCoreDataChanged )
397cdf0e10cSrcweir {
398cdf0e10cSrcweir aBtnCancel.SetText( aStrClose );
399cdf0e10cSrcweir bCoreDataChanged = sal_True;
400cdf0e10cSrcweir }
401cdf0e10cSrcweir
402cdf0e10cSrcweir SelFmtHdl( 0 );
403cdf0e10cSrcweir bOk = sal_True;
404cdf0e10cSrcweir }
405cdf0e10cSrcweir }
406cdf0e10cSrcweir
407cdf0e10cSrcweir if( !bFmtInserted )
408cdf0e10cSrcweir {
409cdf0e10cSrcweir bOk = RET_CANCEL == ErrorBox( this,
410cdf0e10cSrcweir WinBits( WB_OK_CANCEL | WB_DEF_OK),
411cdf0e10cSrcweir aStrInvalidFmt
412cdf0e10cSrcweir ).Execute();
413cdf0e10cSrcweir }
414cdf0e10cSrcweir }
415cdf0e10cSrcweir else
416cdf0e10cSrcweir bOk = sal_True;
417cdf0e10cSrcweir delete pDlg;
418cdf0e10cSrcweir }
419cdf0e10cSrcweir return 0;
420cdf0e10cSrcweir }
421cdf0e10cSrcweir
422cdf0e10cSrcweir //------------------------------------------------------------------------
423cdf0e10cSrcweir
IMPL_LINK(SwAutoFormatDlg,RemoveHdl,void *,EMPTYARG)424cdf0e10cSrcweir IMPL_LINK( SwAutoFormatDlg, RemoveHdl, void *, EMPTYARG )
425cdf0e10cSrcweir {
426cdf0e10cSrcweir String aMessage = aStrDelMsg ;
427cdf0e10cSrcweir aMessage.AppendAscii("\n\n");
428cdf0e10cSrcweir aMessage += aLbFormat.GetSelectEntry() ;
429cdf0e10cSrcweir aMessage += '\n';
430cdf0e10cSrcweir
431cdf0e10cSrcweir MessBox* pBox = new MessBox( this, WinBits( WB_OK_CANCEL ),
432cdf0e10cSrcweir aStrDelTitle, aMessage);
433cdf0e10cSrcweir
434cdf0e10cSrcweir if ( pBox->Execute() == RET_OK )
435cdf0e10cSrcweir {
436cdf0e10cSrcweir aLbFormat.RemoveEntry( nDfltStylePos + nIndex );
437cdf0e10cSrcweir aLbFormat.SelectEntryPos( nDfltStylePos + nIndex-1 );
438cdf0e10cSrcweir
439cdf0e10cSrcweir pTableTbl->DeleteAndDestroy( nIndex );
440cdf0e10cSrcweir nIndex--;
441cdf0e10cSrcweir
442cdf0e10cSrcweir if( !nIndex )
443cdf0e10cSrcweir {
444cdf0e10cSrcweir aBtnRemove.Enable(sal_False);
445cdf0e10cSrcweir aBtnRename.Enable(sal_False);
446cdf0e10cSrcweir }
447cdf0e10cSrcweir
448cdf0e10cSrcweir if( !bCoreDataChanged )
449cdf0e10cSrcweir {
450cdf0e10cSrcweir aBtnCancel.SetText( aStrClose );
451cdf0e10cSrcweir bCoreDataChanged = sal_True;
452cdf0e10cSrcweir }
453cdf0e10cSrcweir }
454cdf0e10cSrcweir delete pBox;
455cdf0e10cSrcweir
456cdf0e10cSrcweir SelFmtHdl( 0 );
457cdf0e10cSrcweir
458cdf0e10cSrcweir return 0;
459cdf0e10cSrcweir }
460cdf0e10cSrcweir
IMPL_LINK(SwAutoFormatDlg,RenameHdl,void *,EMPTYARG)461cdf0e10cSrcweir IMPL_LINK( SwAutoFormatDlg, RenameHdl, void *, EMPTYARG )
462cdf0e10cSrcweir {
463cdf0e10cSrcweir sal_Bool bOk = sal_False;
464cdf0e10cSrcweir while( !bOk )
465cdf0e10cSrcweir {
466cdf0e10cSrcweir SwStringInputDlg* pDlg = new SwStringInputDlg( this,
467cdf0e10cSrcweir aStrRenameTitle, aLbFormat.GetSelectEntry(),
468cdf0e10cSrcweir aEmptyStr );
469cdf0e10cSrcweir if( pDlg->Execute() == RET_OK )
470cdf0e10cSrcweir {
471cdf0e10cSrcweir sal_Bool bFmtRenamed = sal_False;
472cdf0e10cSrcweir String aFormatName;
473cdf0e10cSrcweir pDlg->GetInputString( aFormatName );
474cdf0e10cSrcweir
475cdf0e10cSrcweir if ( aFormatName.Len() > 0 )
476cdf0e10cSrcweir {
477cdf0e10cSrcweir sal_uInt16 n;
478cdf0e10cSrcweir for( n = 0; n < pTableTbl->Count(); ++n )
479cdf0e10cSrcweir if ((*pTableTbl)[n]->GetName() == aFormatName)
480cdf0e10cSrcweir break;
481cdf0e10cSrcweir
482cdf0e10cSrcweir if( n >= pTableTbl->Count() )
483cdf0e10cSrcweir {
484cdf0e10cSrcweir // Format mit dem Namen noch nicht vorhanden, also
485cdf0e10cSrcweir // umbenennen
486cdf0e10cSrcweir
487cdf0e10cSrcweir aLbFormat.RemoveEntry( nDfltStylePos + nIndex );
488cdf0e10cSrcweir SwTableAutoFmtPtr p = (*pTableTbl)[ nIndex ];
489cdf0e10cSrcweir pTableTbl->Remove( nIndex );
490cdf0e10cSrcweir
491cdf0e10cSrcweir p->SetName( aFormatName );
492cdf0e10cSrcweir
493cdf0e10cSrcweir // Sortiert einfuegen!!
494cdf0e10cSrcweir for( n = 1; n < pTableTbl->Count(); ++n )
495cdf0e10cSrcweir if( (*pTableTbl)[ n ]->GetName() > aFormatName )
496cdf0e10cSrcweir break;
497cdf0e10cSrcweir
498cdf0e10cSrcweir pTableTbl->Insert( p, n );
499cdf0e10cSrcweir aLbFormat.InsertEntry( aFormatName, nDfltStylePos + n );
500cdf0e10cSrcweir aLbFormat.SelectEntryPos( nDfltStylePos + n );
501cdf0e10cSrcweir
502cdf0e10cSrcweir if ( !bCoreDataChanged )
503cdf0e10cSrcweir {
504cdf0e10cSrcweir aBtnCancel.SetText( aStrClose );
505cdf0e10cSrcweir bCoreDataChanged = sal_True;
506cdf0e10cSrcweir }
507cdf0e10cSrcweir
508cdf0e10cSrcweir SelFmtHdl( 0 );
509cdf0e10cSrcweir bOk = sal_True;
510cdf0e10cSrcweir bFmtRenamed = sal_True;
511cdf0e10cSrcweir }
512cdf0e10cSrcweir }
513cdf0e10cSrcweir
514cdf0e10cSrcweir if( !bFmtRenamed )
515cdf0e10cSrcweir {
516cdf0e10cSrcweir bOk = RET_CANCEL == ErrorBox( this,
517cdf0e10cSrcweir WinBits( WB_OK_CANCEL | WB_DEF_OK),
518cdf0e10cSrcweir aStrInvalidFmt
519cdf0e10cSrcweir ).Execute();
520cdf0e10cSrcweir }
521cdf0e10cSrcweir }
522cdf0e10cSrcweir else
523cdf0e10cSrcweir bOk = sal_True;
524cdf0e10cSrcweir delete pDlg;
525cdf0e10cSrcweir }
526cdf0e10cSrcweir return 0;
527cdf0e10cSrcweir }
528cdf0e10cSrcweir
529cdf0e10cSrcweir //------------------------------------------------------------------------
530cdf0e10cSrcweir
IMPL_LINK(SwAutoFormatDlg,SelFmtHdl,void *,EMPTYARG)531cdf0e10cSrcweir IMPL_LINK( SwAutoFormatDlg, SelFmtHdl, void *, EMPTYARG )
532cdf0e10cSrcweir {
533cdf0e10cSrcweir sal_Bool bBtnEnable = sal_False;
534cdf0e10cSrcweir sal_uInt8 nSelPos = (sal_uInt8) aLbFormat.GetSelectEntryPos(), nOldIdx = nIndex;
535cdf0e10cSrcweir if( nSelPos >= nDfltStylePos )
536cdf0e10cSrcweir {
537cdf0e10cSrcweir nIndex = nSelPos - nDfltStylePos;
538cdf0e10cSrcweir pWndPreview->NotifyChange( *(*pTableTbl)[nIndex] );
539cdf0e10cSrcweir bBtnEnable = 0 != nIndex;
540cdf0e10cSrcweir UpdateChecks( *(*pTableTbl)[nIndex], sal_True );
541cdf0e10cSrcweir }
542cdf0e10cSrcweir else
543cdf0e10cSrcweir {
544cdf0e10cSrcweir nIndex = 255;
545cdf0e10cSrcweir
546cdf0e10cSrcweir SwTableAutoFmt aTmp( ViewShell::GetShellRes()->aStrNone );
547cdf0e10cSrcweir aTmp.SetFont( sal_False );
548cdf0e10cSrcweir aTmp.SetJustify( sal_False );
549cdf0e10cSrcweir aTmp.SetFrame( sal_False );
550cdf0e10cSrcweir aTmp.SetBackground( sal_False );
551cdf0e10cSrcweir aTmp.SetValueFormat( sal_False );
552cdf0e10cSrcweir aTmp.SetWidthHeight( sal_False );
553cdf0e10cSrcweir
554cdf0e10cSrcweir if( nOldIdx != nIndex )
555cdf0e10cSrcweir pWndPreview->NotifyChange( aTmp );
556cdf0e10cSrcweir UpdateChecks( aTmp, sal_False );
557cdf0e10cSrcweir }
558cdf0e10cSrcweir
559cdf0e10cSrcweir aBtnRemove.Enable( bBtnEnable );
560cdf0e10cSrcweir aBtnRename.Enable( bBtnEnable );
561cdf0e10cSrcweir
562cdf0e10cSrcweir return 0;
563cdf0e10cSrcweir }
564cdf0e10cSrcweir //------------------------------------------------------------------------
565cdf0e10cSrcweir
IMPL_LINK_INLINE_START(SwAutoFormatDlg,OkHdl,Button *,EMPTYARG)566cdf0e10cSrcweir IMPL_LINK_INLINE_START( SwAutoFormatDlg, OkHdl, Button *, EMPTYARG )
567cdf0e10cSrcweir {
568cdf0e10cSrcweir if( bSetAutoFmt )
569cdf0e10cSrcweir pShell->SetTableAutoFmt( *(*pTableTbl)[ nIndex ] );
570cdf0e10cSrcweir EndDialog( RET_OK );
571cdf0e10cSrcweir return sal_True;
572cdf0e10cSrcweir }
IMPL_LINK_INLINE_END(SwAutoFormatDlg,OkHdl,Button *,EMPTYARG)573cdf0e10cSrcweir IMPL_LINK_INLINE_END( SwAutoFormatDlg, OkHdl, Button *, EMPTYARG )
574cdf0e10cSrcweir
575cdf0e10cSrcweir //========================================================================
576cdf0e10cSrcweir // AutoFmtPreview
577cdf0e10cSrcweir
578cdf0e10cSrcweir //------------------------------------------------------------------------
579cdf0e10cSrcweir
580cdf0e10cSrcweir AutoFmtPreview::AutoFmtPreview( Window* pParent, const ResId& rRes, SwWrtShell* pWrtShell ) :
581cdf0e10cSrcweir Window ( pParent, rRes ),
582cdf0e10cSrcweir
583cdf0e10cSrcweir aCurData ( aEmptyStr ),
584cdf0e10cSrcweir aVD ( *this ),
585cdf0e10cSrcweir aScriptedText ( aVD ),
586cdf0e10cSrcweir bFitWidth ( sal_False ),
587cdf0e10cSrcweir mbRTL ( false ),
588cdf0e10cSrcweir aPrvSize ( GetSizePixel().Width() - 6, GetSizePixel().Height() - 30 ),
589cdf0e10cSrcweir nLabelColWidth ( (aPrvSize.Width() - 4) / 4 - 12 ),
590cdf0e10cSrcweir nDataColWidth1 ( (aPrvSize.Width() - 4 - 2 * nLabelColWidth) / 3 ),
591cdf0e10cSrcweir nDataColWidth2 ( (aPrvSize.Width() - 4 - 2 * nLabelColWidth) / 4 ),
592cdf0e10cSrcweir nRowHeight ( (aPrvSize.Height() - 4) / 5 ),
593cdf0e10cSrcweir aStrJan ( SW_RES( STR_JAN ) ),
594cdf0e10cSrcweir aStrFeb ( SW_RES( STR_FEB ) ),
595cdf0e10cSrcweir aStrMar ( SW_RES( STR_MAR ) ),
596cdf0e10cSrcweir aStrNorth ( SW_RES( STR_NORTH ) ),
597cdf0e10cSrcweir aStrMid ( SW_RES( STR_MID ) ),
598cdf0e10cSrcweir aStrSouth ( SW_RES( STR_SOUTH ) ),
599cdf0e10cSrcweir aStrSum ( SW_RES( STR_SUM ) ),
600cdf0e10cSrcweir m_xMSF ( comphelper::getProcessServiceFactory() )
601cdf0e10cSrcweir {
602cdf0e10cSrcweir if (!pWrtShell->IsCrsrInTbl()) // We haven't created the table yet
603cdf0e10cSrcweir mbRTL = Application::GetSettings().GetLayoutRTL();
604cdf0e10cSrcweir else
605cdf0e10cSrcweir mbRTL = pWrtShell->IsTableRightToLeft();
606cdf0e10cSrcweir
607cdf0e10cSrcweir DBG_ASSERT( m_xMSF.is(), "AutoFmtPreview: no MultiServiceFactory");
608cdf0e10cSrcweir if ( m_xMSF.is() )
609cdf0e10cSrcweir {
610cdf0e10cSrcweir m_xBreak = uno::Reference< i18n::XBreakIterator >(
611cdf0e10cSrcweir m_xMSF->createInstance (
612cdf0e10cSrcweir rtl::OUString::createFromAscii( "com.sun.star.i18n.BreakIterator" ) ),
613cdf0e10cSrcweir uno::UNO_QUERY);
614cdf0e10cSrcweir }
615cdf0e10cSrcweir pNumFmt = new SvNumberFormatter( m_xMSF, LANGUAGE_SYSTEM );
616cdf0e10cSrcweir
617cdf0e10cSrcweir Init();
618cdf0e10cSrcweir }
619cdf0e10cSrcweir
620cdf0e10cSrcweir //------------------------------------------------------------------------
621cdf0e10cSrcweir
~AutoFmtPreview()622cdf0e10cSrcweir __EXPORT AutoFmtPreview::~AutoFmtPreview()
623cdf0e10cSrcweir {
624cdf0e10cSrcweir delete pNumFmt;
625cdf0e10cSrcweir }
626cdf0e10cSrcweir
627cdf0e10cSrcweir //------------------------------------------------------------------------
628cdf0e10cSrcweir
lcl_SetFontProperties(Font & rFont,const SvxFontItem & rFontItem,const SvxWeightItem & rWeightItem,const SvxPostureItem & rPostureItem)629cdf0e10cSrcweir static void lcl_SetFontProperties(
630cdf0e10cSrcweir Font& rFont,
631cdf0e10cSrcweir const SvxFontItem& rFontItem,
632cdf0e10cSrcweir const SvxWeightItem& rWeightItem,
633cdf0e10cSrcweir const SvxPostureItem& rPostureItem )
634cdf0e10cSrcweir {
635cdf0e10cSrcweir rFont.SetFamily ( rFontItem.GetFamily() );
636cdf0e10cSrcweir rFont.SetName ( rFontItem.GetFamilyName() );
637cdf0e10cSrcweir rFont.SetStyleName ( rFontItem.GetStyleName() );
638cdf0e10cSrcweir rFont.SetCharSet ( rFontItem.GetCharSet() );
639cdf0e10cSrcweir rFont.SetPitch ( rFontItem.GetPitch() );
640cdf0e10cSrcweir rFont.SetWeight ( (FontWeight)rWeightItem.GetValue() );
641cdf0e10cSrcweir rFont.SetItalic ( (FontItalic)rPostureItem.GetValue() );
642cdf0e10cSrcweir }
643cdf0e10cSrcweir
644cdf0e10cSrcweir #define SETONALLFONTS( MethodName, Value ) \
645cdf0e10cSrcweir rFont.MethodName( Value ); \
646cdf0e10cSrcweir rCJKFont.MethodName( Value ); \
647cdf0e10cSrcweir rCTLFont.MethodName( Value );
648cdf0e10cSrcweir
MakeFonts(sal_uInt8 nIndex,Font & rFont,Font & rCJKFont,Font & rCTLFont)649cdf0e10cSrcweir void AutoFmtPreview::MakeFonts( sal_uInt8 nIndex, Font& rFont, Font& rCJKFont, Font& rCTLFont )
650cdf0e10cSrcweir {
651cdf0e10cSrcweir const SwBoxAutoFmt& rBoxFmt = aCurData.GetBoxFmt( nIndex );
652cdf0e10cSrcweir
653cdf0e10cSrcweir rFont = rCJKFont = rCTLFont = GetFont();
654cdf0e10cSrcweir Size aFontSize( rFont.GetSize().Width(), 10 );
655cdf0e10cSrcweir
656cdf0e10cSrcweir lcl_SetFontProperties( rFont, rBoxFmt.GetFont(), rBoxFmt.GetWeight(), rBoxFmt.GetPosture() );
657cdf0e10cSrcweir lcl_SetFontProperties( rCJKFont, rBoxFmt.GetCJKFont(), rBoxFmt.GetCJKWeight(), rBoxFmt.GetCJKPosture() );
658cdf0e10cSrcweir lcl_SetFontProperties( rCTLFont, rBoxFmt.GetCTLFont(), rBoxFmt.GetCTLWeight(), rBoxFmt.GetCTLPosture() );
659cdf0e10cSrcweir
660cdf0e10cSrcweir SETONALLFONTS( SetUnderline, (FontUnderline)rBoxFmt.GetUnderline().GetValue() );
661cdf0e10cSrcweir SETONALLFONTS( SetOverline, (FontUnderline)rBoxFmt.GetOverline().GetValue() );
662cdf0e10cSrcweir SETONALLFONTS( SetStrikeout, (FontStrikeout)rBoxFmt.GetCrossedOut().GetValue() );
663cdf0e10cSrcweir SETONALLFONTS( SetOutline, rBoxFmt.GetContour().GetValue() );
664cdf0e10cSrcweir SETONALLFONTS( SetShadow, rBoxFmt.GetShadowed().GetValue() );
665cdf0e10cSrcweir SETONALLFONTS( SetColor, rBoxFmt.GetColor().GetValue() );
666cdf0e10cSrcweir SETONALLFONTS( SetSize, aFontSize );
667cdf0e10cSrcweir SETONALLFONTS( SetTransparent, sal_True );
668cdf0e10cSrcweir }
669cdf0e10cSrcweir
670cdf0e10cSrcweir //------------------------------------------------------------------------
671cdf0e10cSrcweir
GetFormatIndex(size_t nCol,size_t nRow) const672cdf0e10cSrcweir sal_uInt8 AutoFmtPreview::GetFormatIndex( size_t nCol, size_t nRow ) const
673cdf0e10cSrcweir {
674cdf0e10cSrcweir static const sal_uInt8 pnFmtMap[] =
675cdf0e10cSrcweir {
676cdf0e10cSrcweir 0, 1, 2, 1, 3,
677cdf0e10cSrcweir 4, 5, 6, 5, 7,
678cdf0e10cSrcweir 8, 9, 10, 9, 11,
679cdf0e10cSrcweir 4, 5, 6, 5, 7,
680cdf0e10cSrcweir 12, 13, 14, 13, 15
681cdf0e10cSrcweir };
682cdf0e10cSrcweir return pnFmtMap[ maArray.GetCellIndex( nCol, nRow, mbRTL ) ];
683cdf0e10cSrcweir }
684cdf0e10cSrcweir
GetBoxItem(size_t nCol,size_t nRow) const685cdf0e10cSrcweir const SvxBoxItem& AutoFmtPreview::GetBoxItem( size_t nCol, size_t nRow ) const
686cdf0e10cSrcweir {
687cdf0e10cSrcweir return aCurData.GetBoxFmt( GetFormatIndex( nCol, nRow ) ).GetBox();
688cdf0e10cSrcweir }
689cdf0e10cSrcweir
690cdf0e10cSrcweir //------------------------------------------------------------------------
691cdf0e10cSrcweir
DrawString(size_t nCol,size_t nRow)692cdf0e10cSrcweir void AutoFmtPreview::DrawString( size_t nCol, size_t nRow )
693cdf0e10cSrcweir {
694cdf0e10cSrcweir //------------------------
695cdf0e10cSrcweir // Ausgabe des Zelltextes:
696cdf0e10cSrcweir //------------------------
697cdf0e10cSrcweir sal_uLong nNum;
698cdf0e10cSrcweir double nVal;
699cdf0e10cSrcweir String cellString;
700cdf0e10cSrcweir sal_uInt8 nIndex = static_cast< sal_uInt8 >( maArray.GetCellIndex( nCol, nRow, mbRTL ) );
701cdf0e10cSrcweir
702cdf0e10cSrcweir switch( nIndex )
703cdf0e10cSrcweir {
704cdf0e10cSrcweir case 1: cellString = aStrJan; break;
705cdf0e10cSrcweir case 2: cellString = aStrFeb; break;
706cdf0e10cSrcweir case 3: cellString = aStrMar; break;
707cdf0e10cSrcweir case 5: cellString = aStrNorth; break;
708cdf0e10cSrcweir case 10: cellString = aStrMid; break;
709cdf0e10cSrcweir case 15: cellString = aStrSouth; break;
710cdf0e10cSrcweir case 4:
711cdf0e10cSrcweir case 20: cellString = aStrSum; break;
712cdf0e10cSrcweir
713cdf0e10cSrcweir case 6:
714cdf0e10cSrcweir case 8:
715cdf0e10cSrcweir case 16:
716cdf0e10cSrcweir case 18: nVal = nIndex;
717cdf0e10cSrcweir nNum = 5;
718cdf0e10cSrcweir goto MAKENUMSTR;
719cdf0e10cSrcweir case 17:
720cdf0e10cSrcweir case 7: nVal = nIndex;
721cdf0e10cSrcweir nNum = 6;
722cdf0e10cSrcweir goto MAKENUMSTR;
723cdf0e10cSrcweir case 11:
724cdf0e10cSrcweir case 12:
725cdf0e10cSrcweir case 13: nVal = nIndex;
726cdf0e10cSrcweir nNum = 12 == nIndex ? 10 : 9;
727cdf0e10cSrcweir goto MAKENUMSTR;
728cdf0e10cSrcweir
729cdf0e10cSrcweir case 9: nVal = 21; nNum = 7; goto MAKENUMSTR;
730cdf0e10cSrcweir case 14: nVal = 36; nNum = 11; goto MAKENUMSTR;
731cdf0e10cSrcweir case 19: nVal = 51; nNum = 7; goto MAKENUMSTR;
732cdf0e10cSrcweir case 21: nVal = 33; nNum = 13; goto MAKENUMSTR;
733cdf0e10cSrcweir case 22: nVal = 36; nNum = 14; goto MAKENUMSTR;
734cdf0e10cSrcweir case 23: nVal = 39; nNum = 13; goto MAKENUMSTR;
735cdf0e10cSrcweir case 24: nVal = 108; nNum = 15; goto MAKENUMSTR;
736cdf0e10cSrcweir MAKENUMSTR:
737cdf0e10cSrcweir if( aCurData.IsValueFormat() )
738cdf0e10cSrcweir {
739cdf0e10cSrcweir String sFmt; LanguageType eLng, eSys;
740cdf0e10cSrcweir aCurData.GetBoxFmt( (sal_uInt8)nNum ).GetValueFormat( sFmt, eLng, eSys );
741cdf0e10cSrcweir
742cdf0e10cSrcweir short nType;
743cdf0e10cSrcweir sal_Bool bNew;
744cdf0e10cSrcweir xub_StrLen nCheckPos;
745cdf0e10cSrcweir sal_uInt32 nKey = pNumFmt->GetIndexPuttingAndConverting( sFmt, eLng,
746cdf0e10cSrcweir eSys, nType, bNew, nCheckPos);
747cdf0e10cSrcweir Color* pDummy;
748cdf0e10cSrcweir pNumFmt->GetOutputString( nVal, nKey, cellString, &pDummy );
749cdf0e10cSrcweir }
750cdf0e10cSrcweir else
751cdf0e10cSrcweir cellString = String::CreateFromInt32((sal_Int32)nVal);
752cdf0e10cSrcweir break;
753cdf0e10cSrcweir
754cdf0e10cSrcweir }
755cdf0e10cSrcweir
756cdf0e10cSrcweir if( cellString.Len() )
757cdf0e10cSrcweir {
758cdf0e10cSrcweir Size aStrSize;
759cdf0e10cSrcweir sal_uInt8 nFmtIndex = GetFormatIndex( nCol, nRow );
760cdf0e10cSrcweir Rectangle cellRect = maArray.GetCellRect( nCol, nRow );
761cdf0e10cSrcweir Point aPos = cellRect.TopLeft();
762cdf0e10cSrcweir sal_uInt16 nRightX = 0;
763cdf0e10cSrcweir // sal_Bool bJustify = aCurData.IsJustify();
764cdf0e10cSrcweir // ScHorJustifyAttr aHorJustifyItem;
765cdf0e10cSrcweir // CellHorJustify eJustification;
766cdf0e10cSrcweir
767cdf0e10cSrcweir Size theMaxStrSize( cellRect.GetWidth() - FRAME_OFFSET,
768cdf0e10cSrcweir cellRect.GetHeight() - FRAME_OFFSET );
769cdf0e10cSrcweir if( aCurData.IsFont() )
770cdf0e10cSrcweir {
771cdf0e10cSrcweir Font aFont, aCJKFont, aCTLFont;
772cdf0e10cSrcweir MakeFonts( nFmtIndex, aFont, aCJKFont, aCTLFont );
773cdf0e10cSrcweir aScriptedText.SetFonts( &aFont, &aCJKFont, &aCTLFont );
774cdf0e10cSrcweir }
775cdf0e10cSrcweir else
776cdf0e10cSrcweir aScriptedText.SetDefaultFont();
777cdf0e10cSrcweir
778cdf0e10cSrcweir aScriptedText.SetText( cellString, m_xBreak );
779cdf0e10cSrcweir aStrSize = aScriptedText.GetTextSize();
780cdf0e10cSrcweir
781cdf0e10cSrcweir if( aCurData.IsFont() &&
782cdf0e10cSrcweir theMaxStrSize.Height() < aStrSize.Height() )
783cdf0e10cSrcweir {
784cdf0e10cSrcweir // wenn der String in diesem Font nicht
785cdf0e10cSrcweir // in die Zelle passt, wird wieder der
786cdf0e10cSrcweir // Standard-Font genommen:
787cdf0e10cSrcweir aScriptedText.SetDefaultFont();
788cdf0e10cSrcweir aStrSize = aScriptedText.GetTextSize();
789cdf0e10cSrcweir }
790cdf0e10cSrcweir
791cdf0e10cSrcweir while( theMaxStrSize.Width() <= aStrSize.Width() &&
792cdf0e10cSrcweir cellString.Len() > 1 )
793cdf0e10cSrcweir {
794cdf0e10cSrcweir // if( eJustification == SVX_HOR_JUSTIFY_RIGHT )
795cdf0e10cSrcweir // cellString.Erase( 0, 1 );
796cdf0e10cSrcweir // else
797cdf0e10cSrcweir cellString.Erase( cellString.Len() - 1 );
798cdf0e10cSrcweir aScriptedText.SetText( cellString, m_xBreak );
799cdf0e10cSrcweir aStrSize = aScriptedText.GetTextSize();
800cdf0e10cSrcweir }
801cdf0e10cSrcweir
802cdf0e10cSrcweir nRightX = (sal_uInt16)( cellRect.GetWidth()
803cdf0e10cSrcweir - aStrSize.Width()
804cdf0e10cSrcweir - FRAME_OFFSET );
805cdf0e10cSrcweir //-------------
806cdf0e10cSrcweir // Ausrichtung:
807cdf0e10cSrcweir //-------------
808cdf0e10cSrcweir /* if ( bJustify )
809cdf0e10cSrcweir {
810cdf0e10cSrcweir aCurData.GetHorJustify( nFmtIndex, aHorJustifyItem );
811cdf0e10cSrcweir eJustification = (CellHorJustify)aHorJustifyItem.GetValue();
812cdf0e10cSrcweir }
813cdf0e10cSrcweir else
814cdf0e10cSrcweir {
815cdf0e10cSrcweir eJustification = SC_HOR_JUSTIFY_STANDARD;
816cdf0e10cSrcweir }*/
817cdf0e10cSrcweir
818cdf0e10cSrcweir //-----------------------------
819cdf0e10cSrcweir // vertikal (immer zentrieren):
820cdf0e10cSrcweir //-----------------------------
821cdf0e10cSrcweir aPos.Y() += (nRowHeight - (sal_uInt16)aStrSize.Height()) / 2;
822cdf0e10cSrcweir
823cdf0e10cSrcweir //-----------
824cdf0e10cSrcweir // horizontal
825cdf0e10cSrcweir //-----------
826cdf0e10cSrcweir /* if ( eJustification != SC_HOR_JUSTIFY_STANDARD )*/
827cdf0e10cSrcweir if( mbRTL )
828cdf0e10cSrcweir aPos.X() += nRightX;
829cdf0e10cSrcweir else if (aCurData.IsJustify())
830cdf0e10cSrcweir {
831cdf0e10cSrcweir sal_uInt16 nHorPos = (sal_uInt16)
832cdf0e10cSrcweir ((cellRect.GetWidth()-aStrSize.Width())/2);
833cdf0e10cSrcweir const SvxAdjustItem& rAdj = aCurData.GetBoxFmt(nFmtIndex).GetAdjust();
834cdf0e10cSrcweir switch ( rAdj.GetAdjust() )
835cdf0e10cSrcweir {
836cdf0e10cSrcweir case SVX_ADJUST_LEFT:
837cdf0e10cSrcweir aPos.X() += FRAME_OFFSET;
838cdf0e10cSrcweir break;
839cdf0e10cSrcweir case SVX_ADJUST_RIGHT:
840cdf0e10cSrcweir aPos.X() += nRightX;
841cdf0e10cSrcweir break;
842cdf0e10cSrcweir default:
843cdf0e10cSrcweir aPos.X() += nHorPos;
844cdf0e10cSrcweir break;
845cdf0e10cSrcweir }
846cdf0e10cSrcweir }
847cdf0e10cSrcweir else
848cdf0e10cSrcweir {
849cdf0e10cSrcweir //---------------------
850cdf0e10cSrcweir // Standardausrichtung:
851cdf0e10cSrcweir //---------------------
852cdf0e10cSrcweir if ( (nCol == 0) || (nIndex == 4) )
853cdf0e10cSrcweir {
854cdf0e10cSrcweir // Text-Label links oder Summe linksbuendig
855cdf0e10cSrcweir aPos.X() += FRAME_OFFSET;
856cdf0e10cSrcweir }
857cdf0e10cSrcweir else
858cdf0e10cSrcweir {
859cdf0e10cSrcweir // Zahlen/Datum rechtsbuendig
860cdf0e10cSrcweir aPos.X() += nRightX;
861cdf0e10cSrcweir }
862cdf0e10cSrcweir }
863cdf0e10cSrcweir
864cdf0e10cSrcweir //-------------------------------
865cdf0e10cSrcweir aScriptedText.DrawText( aPos );
866cdf0e10cSrcweir //-------------------------------
867cdf0e10cSrcweir }
868cdf0e10cSrcweir }
869cdf0e10cSrcweir
870cdf0e10cSrcweir #undef FRAME_OFFSET
871cdf0e10cSrcweir
872cdf0e10cSrcweir //------------------------------------------------------------------------
873cdf0e10cSrcweir
DrawStrings()874cdf0e10cSrcweir void AutoFmtPreview::DrawStrings()
875cdf0e10cSrcweir {
876cdf0e10cSrcweir for( size_t nRow = 0; nRow < 5; ++nRow )
877cdf0e10cSrcweir for( size_t nCol = 0; nCol < 5; ++nCol )
878cdf0e10cSrcweir DrawString( nCol, nRow );
879cdf0e10cSrcweir }
880cdf0e10cSrcweir
881cdf0e10cSrcweir //------------------------------------------------------------------------
882cdf0e10cSrcweir
883cdf0e10cSrcweir
DrawBackground()884cdf0e10cSrcweir void AutoFmtPreview::DrawBackground()
885cdf0e10cSrcweir {
886cdf0e10cSrcweir for( size_t nRow = 0; nRow < 5; ++nRow )
887cdf0e10cSrcweir {
888cdf0e10cSrcweir for( size_t nCol = 0; nCol < 5; ++nCol )
889cdf0e10cSrcweir {
890cdf0e10cSrcweir SvxBrushItem aBrushItem( aCurData.GetBoxFmt( GetFormatIndex( nCol, nRow ) ).GetBackground() );
891cdf0e10cSrcweir
892cdf0e10cSrcweir aVD.Push( PUSH_LINECOLOR | PUSH_FILLCOLOR );
893cdf0e10cSrcweir aVD.SetLineColor();
894cdf0e10cSrcweir aVD.SetFillColor( aBrushItem.GetColor() );
895cdf0e10cSrcweir aVD.DrawRect( maArray.GetCellRect( nCol, nRow ) );
896cdf0e10cSrcweir aVD.Pop();
897cdf0e10cSrcweir }
898cdf0e10cSrcweir }
899cdf0e10cSrcweir }
900cdf0e10cSrcweir
901cdf0e10cSrcweir //------------------------------------------------------------------------
902cdf0e10cSrcweir
903cdf0e10cSrcweir
PaintCells()904cdf0e10cSrcweir void AutoFmtPreview::PaintCells()
905cdf0e10cSrcweir {
906cdf0e10cSrcweir // 1) background
907cdf0e10cSrcweir if ( aCurData.IsBackground() )
908cdf0e10cSrcweir DrawBackground();
909cdf0e10cSrcweir
910cdf0e10cSrcweir // 2) values
911cdf0e10cSrcweir DrawStrings();
912cdf0e10cSrcweir
913cdf0e10cSrcweir // 3) border
914cdf0e10cSrcweir if ( aCurData.IsFrame() )
915cdf0e10cSrcweir maArray.DrawArray( aVD );
916cdf0e10cSrcweir }
917cdf0e10cSrcweir
918cdf0e10cSrcweir //------------------------------------------------------------------------
919cdf0e10cSrcweir
920cdf0e10cSrcweir
Init()921cdf0e10cSrcweir void __EXPORT AutoFmtPreview::Init()
922cdf0e10cSrcweir {
923cdf0e10cSrcweir SetBorderStyle( GetBorderStyle() | WINDOW_BORDER_MONO );
924cdf0e10cSrcweir maArray.Initialize( 5, 5 );
925cdf0e10cSrcweir maArray.SetUseDiagDoubleClipping( false );
926cdf0e10cSrcweir CalcCellArray( sal_False );
927cdf0e10cSrcweir CalcLineMap();
928cdf0e10cSrcweir }
929cdf0e10cSrcweir
930cdf0e10cSrcweir //------------------------------------------------------------------------
931cdf0e10cSrcweir
932cdf0e10cSrcweir
CalcCellArray(sal_Bool _bFitWidth)933cdf0e10cSrcweir void AutoFmtPreview::CalcCellArray( sal_Bool _bFitWidth )
934cdf0e10cSrcweir {
935cdf0e10cSrcweir maArray.SetXOffset( 2 );
936cdf0e10cSrcweir maArray.SetAllColWidths( _bFitWidth ? nDataColWidth2 : nDataColWidth1 );
937cdf0e10cSrcweir maArray.SetColWidth( 0, nLabelColWidth );
938cdf0e10cSrcweir maArray.SetColWidth( 4, nLabelColWidth );
939cdf0e10cSrcweir
940cdf0e10cSrcweir maArray.SetYOffset( 2 );
941cdf0e10cSrcweir maArray.SetAllRowHeights( nRowHeight );
942cdf0e10cSrcweir
943cdf0e10cSrcweir aPrvSize.Width() = maArray.GetWidth() + 4;
944cdf0e10cSrcweir aPrvSize.Height() = maArray.GetHeight() + 4;
945cdf0e10cSrcweir }
946cdf0e10cSrcweir
947cdf0e10cSrcweir //------------------------------------------------------------------------
948cdf0e10cSrcweir
lclSetStyleFromBorder(svx::frame::Style & rStyle,const SvxBorderLine * pBorder)949cdf0e10cSrcweir inline void lclSetStyleFromBorder( svx::frame::Style& rStyle, const SvxBorderLine* pBorder )
950cdf0e10cSrcweir {
951cdf0e10cSrcweir rStyle.Set( pBorder, 0.05, 5 );
952cdf0e10cSrcweir }
953cdf0e10cSrcweir
CalcLineMap()954cdf0e10cSrcweir void AutoFmtPreview::CalcLineMap()
955cdf0e10cSrcweir {
956cdf0e10cSrcweir for( size_t nRow = 0; nRow < 5; ++nRow )
957cdf0e10cSrcweir {
958cdf0e10cSrcweir for( size_t nCol = 0; nCol < 5; ++nCol )
959cdf0e10cSrcweir {
960cdf0e10cSrcweir svx::frame::Style aStyle;
961cdf0e10cSrcweir
962cdf0e10cSrcweir const SvxBoxItem& rItem = GetBoxItem( nCol, nRow );
963cdf0e10cSrcweir lclSetStyleFromBorder( aStyle, rItem.GetLeft() );
964cdf0e10cSrcweir maArray.SetCellStyleLeft( nCol, nRow, aStyle );
965cdf0e10cSrcweir lclSetStyleFromBorder( aStyle, rItem.GetRight() );
966cdf0e10cSrcweir maArray.SetCellStyleRight( nCol, nRow, aStyle );
967cdf0e10cSrcweir lclSetStyleFromBorder( aStyle, rItem.GetTop() );
968cdf0e10cSrcweir maArray.SetCellStyleTop( nCol, nRow, aStyle );
969cdf0e10cSrcweir lclSetStyleFromBorder( aStyle, rItem.GetBottom() );
970cdf0e10cSrcweir maArray.SetCellStyleBottom( nCol, nRow, aStyle );
971cdf0e10cSrcweir
972cdf0e10cSrcweir // FIXME - uncomment to draw diagonal borders
973cdf0e10cSrcweir // lclSetStyleFromBorder( aStyle, GetDiagItem( nCol, nRow, true ).GetLine() );
974cdf0e10cSrcweir // maArray.SetCellStyleTLBR( nCol, nRow, aStyle );
975cdf0e10cSrcweir // lclSetStyleFromBorder( aStyle, GetDiagItem( nCol, nRow, false ).GetLine() );
976cdf0e10cSrcweir // maArray.SetCellStyleBLTR( nCol, nRow, aStyle );
977cdf0e10cSrcweir }
978cdf0e10cSrcweir }
979cdf0e10cSrcweir }
980cdf0e10cSrcweir
981cdf0e10cSrcweir //------------------------------------------------------------------------
982cdf0e10cSrcweir
983cdf0e10cSrcweir
NotifyChange(const SwTableAutoFmt & rNewData)984cdf0e10cSrcweir void AutoFmtPreview::NotifyChange( const SwTableAutoFmt& rNewData )
985cdf0e10cSrcweir {
986cdf0e10cSrcweir aCurData = rNewData;
987cdf0e10cSrcweir bFitWidth = aCurData.IsJustify();//sal_True; //???
988cdf0e10cSrcweir CalcCellArray( bFitWidth );
989cdf0e10cSrcweir CalcLineMap();
990cdf0e10cSrcweir DoPaint( Rectangle( Point(0,0), GetSizePixel() ) );
991cdf0e10cSrcweir }
992cdf0e10cSrcweir
993cdf0e10cSrcweir //------------------------------------------------------------------------
994cdf0e10cSrcweir
995cdf0e10cSrcweir
DoPaint(const Rectangle &)996cdf0e10cSrcweir void AutoFmtPreview::DoPaint( const Rectangle& /*rRect*/ )
997cdf0e10cSrcweir {
998cdf0e10cSrcweir sal_uInt32 nOldDrawMode = aVD.GetDrawMode();
999cdf0e10cSrcweir if( GetSettings().GetStyleSettings().GetHighContrastMode() &&
1000cdf0e10cSrcweir SW_MOD()->GetAccessibilityOptions().GetIsForBorders() )
1001cdf0e10cSrcweir aVD.SetDrawMode( DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL | DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT );
1002cdf0e10cSrcweir
1003cdf0e10cSrcweir Bitmap thePreview;
1004cdf0e10cSrcweir Point aCenterPos;
1005cdf0e10cSrcweir Size theWndSize = GetSizePixel();
1006cdf0e10cSrcweir Size thePrevSize;
1007cdf0e10cSrcweir Color oldColor;
1008cdf0e10cSrcweir Font aFont;
1009cdf0e10cSrcweir
1010cdf0e10cSrcweir aFont = aVD.GetFont();
1011cdf0e10cSrcweir aFont.SetTransparent( sal_True );
1012cdf0e10cSrcweir
1013cdf0e10cSrcweir aVD.SetFont ( aFont );
1014cdf0e10cSrcweir aVD.SetLineColor ();
1015cdf0e10cSrcweir const Color& rWinColor = GetSettings().GetStyleSettings().GetWindowColor();
1016cdf0e10cSrcweir aVD.SetBackground ( Wallpaper(rWinColor) );
1017cdf0e10cSrcweir aVD.SetFillColor ( rWinColor );
1018cdf0e10cSrcweir aVD.SetOutputSizePixel ( aPrvSize );
1019cdf0e10cSrcweir
1020cdf0e10cSrcweir //--------------------------------
1021cdf0e10cSrcweir // Zellen auf virtual Device malen
1022cdf0e10cSrcweir // und Ergebnis sichern
1023cdf0e10cSrcweir //--------------------------------
1024cdf0e10cSrcweir PaintCells();
1025cdf0e10cSrcweir thePreview = aVD.GetBitmap( Point(0,0), aPrvSize );
1026cdf0e10cSrcweir
1027cdf0e10cSrcweir //--------------------------------------
1028cdf0e10cSrcweir // Rahmen malen und Vorschau zentrieren:
1029cdf0e10cSrcweir // (virtual Device fuer Fensterausgabe)
1030cdf0e10cSrcweir //--------------------------------------
1031cdf0e10cSrcweir aVD.SetOutputSizePixel( theWndSize );
1032cdf0e10cSrcweir oldColor = aVD.GetLineColor();
1033cdf0e10cSrcweir aVD.SetLineColor();
1034cdf0e10cSrcweir aVD.DrawRect( Rectangle( Point(0,0), theWndSize ) );
1035cdf0e10cSrcweir SetLineColor( oldColor );
1036cdf0e10cSrcweir aCenterPos = Point( (theWndSize.Width() - aPrvSize.Width() ) / 2,
1037cdf0e10cSrcweir (theWndSize.Height() - aPrvSize.Height()) / 2 );
1038cdf0e10cSrcweir aVD.DrawBitmap( aCenterPos, thePreview );
1039cdf0e10cSrcweir
1040cdf0e10cSrcweir //----------------------------
1041cdf0e10cSrcweir // Ausgabe im Vorschaufenster:
1042cdf0e10cSrcweir //----------------------------
1043cdf0e10cSrcweir DrawBitmap( Point(0,0), aVD.GetBitmap( Point(0,0), theWndSize ) );
1044cdf0e10cSrcweir
1045cdf0e10cSrcweir aVD.SetDrawMode( nOldDrawMode );
1046cdf0e10cSrcweir }
1047cdf0e10cSrcweir
1048cdf0e10cSrcweir //------------------------------------------------------------------------
1049cdf0e10cSrcweir
Paint(const Rectangle & rRect)1050cdf0e10cSrcweir void __EXPORT AutoFmtPreview::Paint( const Rectangle& rRect )
1051cdf0e10cSrcweir {
1052cdf0e10cSrcweir DoPaint( rRect );
1053cdf0e10cSrcweir }
1054