xref: /aoo41x/main/sc/source/ui/inc/autofmt.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef SC_AUTOFMT_HXX
29 #define SC_AUTOFMT_HXX
30 
31 #ifndef _VIRDEV_HXX //autogen
32 #include <vcl/virdev.hxx>
33 #endif
34 #ifndef SV_FIXED_HXX
35 #include <vcl/fixed.hxx>
36 #endif
37 #ifndef SV_LSTBOX_HXX
38 #include <vcl/lstbox.hxx>
39 #endif
40 #ifndef SV_BUTTON_HXX
41 #include <vcl/button.hxx>
42 #endif
43 #ifndef SV_MOREBTN_HXX
44 #include <vcl/morebtn.hxx>
45 #endif
46 #ifndef _DIALOG_HXX //autogen
47 #include <vcl/dialog.hxx>
48 #endif
49 #include <svtools/scriptedtext.hxx>
50 #include <svx/framelinkarray.hxx>
51 #include "scdllapi.h"
52 
53 //------------------------------------------------------------------------
54 
55 class ScAutoFormat;
56 class ScAutoFormatData;
57 class SvxBoxItem;
58 class SvxLineItem;
59 class ScAutoFmtPreview; // s.u.
60 class SvNumberFormatter;
61 class ScDocument;
62 
63 //------------------------------------------------------------------------
64 
65 enum AutoFmtLine { TOP_LINE, BOTTOM_LINE, LEFT_LINE, RIGHT_LINE };
66 
67 //========================================================================
68 
69 //CHINA001 class ScAutoFormatDlg : public ModalDialog
70 //CHINA001 {
71 //CHINA001 public:
72 //CHINA001 ScAutoFormatDlg( Window*					pParent,
73 //CHINA001 ScAutoFormat*				pAutoFormat,
74 //CHINA001 const ScAutoFormatData*    pSelFormatData,
75 //CHINA001 ScDocument*                pDoc );
76 //CHINA001 ~ScAutoFormatDlg();
77 //CHINA001
78 //CHINA001 sal_uInt16 GetIndex() const { return nIndex; }
79 //CHINA001 String GetCurrFormatName();
80 //CHINA001
81 //CHINA001 private:
82 //CHINA001 FixedLine       aFlFormat;
83 //CHINA001 ListBox			aLbFormat;
84 //CHINA001 ScAutoFmtPreview*	pWndPreview;
85 //CHINA001 OKButton		aBtnOk;
86 //CHINA001 CancelButton	aBtnCancel;
87 //CHINA001 HelpButton		aBtnHelp;
88 //CHINA001 PushButton		aBtnAdd;
89 //CHINA001 PushButton		aBtnRemove;
90 //CHINA001 MoreButton		aBtnMore;
91 //CHINA001 FixedLine       aFlFormatting;
92 //CHINA001 CheckBox		aBtnNumFormat;
93 //CHINA001 CheckBox		aBtnBorder;
94 //CHINA001 CheckBox		aBtnFont;
95 //CHINA001 CheckBox		aBtnPattern;
96 //CHINA001 CheckBox		aBtnAlignment;
97 //CHINA001 CheckBox		aBtnAdjust;
98 //CHINA001 PushButton		aBtnRename;
99 //CHINA001 String			aStrTitle;
100 //CHINA001 String			aStrLabel;
101 //CHINA001 String			aStrClose;
102 //CHINA001 String			aStrDelTitle;
103 //CHINA001 String			aStrDelMsg;
104 //CHINA001 String			aStrRename;
105 //CHINA001
106 //CHINA001 //------------------------
107 //CHINA001 ScAutoFormat*			pFormat;
108 //CHINA001 const ScAutoFormatData*	pSelFmtData;
109 //CHINA001 sal_uInt16					nIndex;
110 //CHINA001 sal_Bool					bCoreDataChanged;
111 //CHINA001 sal_Bool					bFmtInserted;
112 //CHINA001
113 //CHINA001 void Init			();
114 //CHINA001 void UpdateChecks	();
115 //CHINA001 //------------------------
116 //CHINA001 DECL_LINK( CheckHdl, Button * );
117 //CHINA001 DECL_LINK( AddHdl, void * );
118 //CHINA001 DECL_LINK( RemoveHdl, void * );
119 //CHINA001 DECL_LINK( SelFmtHdl, void * );
120 //CHINA001 DECL_LINK( CloseHdl, PushButton * );
121 //CHINA001 DECL_LINK( DblClkHdl, void * );
122 //CHINA001 DECL_LINK( RenameHdl, void *);
123 //CHINA001
124 //CHINA001 };
125 //CHINA001
126 //========================================================================
127 
128 class SC_DLLPUBLIC ScAutoFmtPreview : public Window
129 {
130 public:
131             ScAutoFmtPreview( Window* pParent, const ResId& rRes, ScDocument* pDoc );
132 			~ScAutoFmtPreview();
133 
134 	void NotifyChange( ScAutoFormatData* pNewData );
135 
136 protected:
137 	virtual void Paint( const Rectangle& rRect );
138 
139 private:
140     ScAutoFormatData*       pCurData;
141     VirtualDevice           aVD;
142     SvtScriptedTextHelper   aScriptedText;
143     ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XBreakIterator > xBreakIter;
144     sal_Bool                    bFitWidth;
145     svx::frame::Array       maArray;            /// Implementation to draw the frame borders.
146     bool                    mbRTL;
147     Size                    aPrvSize;
148     long                    mnLabelColWidth;
149     long                    mnDataColWidth1;
150     long                    mnDataColWidth2;
151     long                    mnRowHeight;
152     const String            aStrJan;
153     const String            aStrFeb;
154     const String            aStrMar;
155     const String            aStrNorth;
156     const String            aStrMid;
157     const String            aStrSouth;
158     const String            aStrSum;
159     SvNumberFormatter*      pNumFmt;
160 	//-------------------------------------------
161 	SC_DLLPRIVATE void	Init			();
162 	SC_DLLPRIVATE void	DoPaint			( const Rectangle& rRect );
163 	SC_DLLPRIVATE void	CalcCellArray	( sal_Bool bFitWidth );
164 	SC_DLLPRIVATE void	CalcLineMap		();
165 	SC_DLLPRIVATE void	PaintCells		();
166 
167 /*  Usage of type size_t instead of SCCOL/SCROW is correct here - used in
168     conjunction with class svx::frame::Array (svx/framelinkarray.hxx), which
169     expects size_t coordinates. */
170 
171     SC_DLLPRIVATE sal_uInt16              GetFormatIndex( size_t nCol, size_t nRow ) const;
172     SC_DLLPRIVATE const SvxBoxItem&   GetBoxItem( size_t nCol, size_t nRow ) const;
173     SC_DLLPRIVATE const SvxLineItem&  GetDiagItem( size_t nCol, size_t nRow, bool bTLBR ) const;
174 
175     SC_DLLPRIVATE void                DrawString( size_t nCol, size_t nRow );
176     SC_DLLPRIVATE void                DrawStrings();
177     SC_DLLPRIVATE void                DrawBackground();
178 
179     SC_DLLPRIVATE void    MakeFonts       ( sal_uInt16 nIndex,
180                               Font& rFont,
181                               Font& rCJKFont,
182                               Font& rCTLFont );
183 
184 	SC_DLLPRIVATE String	MakeNumberString( String cellString, sal_Bool bAddDec );
185 	SC_DLLPRIVATE void	DrawFrameLine	( const SvxBorderLine&	rLineD,
186 							  Point					from,
187 							  Point					to,
188 							  sal_Bool					bHorizontal,
189 							  const SvxBorderLine&	rLineLT,
190 							  const SvxBorderLine&	rLineL,
191 							  const SvxBorderLine&	rLineLB,
192 							  const SvxBorderLine&	rLineRT,
193 							  const SvxBorderLine&	rLineR,
194 							  const SvxBorderLine&	rLineRB );
195 	SC_DLLPRIVATE void CheckPriority	( sal_uInt16			nCurLine,
196 							  AutoFmtLine		eLine,
197 							  SvxBorderLine&	rLine );
198 	SC_DLLPRIVATE void	GetLines		( sal_uInt16 nIndex, AutoFmtLine eLine,
199 							  SvxBorderLine&	rLineD,
200 							  SvxBorderLine&	rLineLT,
201 							  SvxBorderLine&	rLineL,
202 							  SvxBorderLine&	rLineLB,
203 							  SvxBorderLine&	rLineRT,
204 							  SvxBorderLine&	rLineR,
205 							  SvxBorderLine&	rLineRB );
206 };
207 
208 #endif // SC_AUTOFMT_HXX
209 
210 
211