xref: /aoo4110/main/sc/source/ui/inc/autofmt.hxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef SC_AUTOFMT_HXX
25 #define SC_AUTOFMT_HXX
26 
27 #ifndef _VIRDEV_HXX //autogen
28 #include <vcl/virdev.hxx>
29 #endif
30 #ifndef SV_FIXED_HXX
31 #include <vcl/fixed.hxx>
32 #endif
33 #ifndef SV_LSTBOX_HXX
34 #include <vcl/lstbox.hxx>
35 #endif
36 #ifndef SV_BUTTON_HXX
37 #include <vcl/button.hxx>
38 #endif
39 #ifndef SV_MOREBTN_HXX
40 #include <vcl/morebtn.hxx>
41 #endif
42 #ifndef _DIALOG_HXX //autogen
43 #include <vcl/dialog.hxx>
44 #endif
45 #include <svtools/scriptedtext.hxx>
46 #include <svx/framelinkarray.hxx>
47 #include "scdllapi.h"
48 
49 //------------------------------------------------------------------------
50 
51 class ScAutoFormat;
52 class ScAutoFormatData;
53 class SvxBoxItem;
54 class SvxLineItem;
55 class ScAutoFmtPreview; // s.u.
56 class SvNumberFormatter;
57 class ScDocument;
58 
59 //------------------------------------------------------------------------
60 
61 enum AutoFmtLine { TOP_LINE, BOTTOM_LINE, LEFT_LINE, RIGHT_LINE };
62 
63 //========================================================================
64 
65 //CHINA001 class ScAutoFormatDlg : public ModalDialog
66 //CHINA001 {
67 //CHINA001 public:
68 //CHINA001 ScAutoFormatDlg( Window*					pParent,
69 //CHINA001 ScAutoFormat*				pAutoFormat,
70 //CHINA001 const ScAutoFormatData*    pSelFormatData,
71 //CHINA001 ScDocument*                pDoc );
72 //CHINA001 ~ScAutoFormatDlg();
73 //CHINA001
74 //CHINA001 sal_uInt16 GetIndex() const { return nIndex; }
75 //CHINA001 String GetCurrFormatName();
76 //CHINA001
77 //CHINA001 private:
78 //CHINA001 FixedLine       aFlFormat;
79 //CHINA001 ListBox			aLbFormat;
80 //CHINA001 ScAutoFmtPreview*	pWndPreview;
81 //CHINA001 OKButton		aBtnOk;
82 //CHINA001 CancelButton	aBtnCancel;
83 //CHINA001 HelpButton		aBtnHelp;
84 //CHINA001 PushButton		aBtnAdd;
85 //CHINA001 PushButton		aBtnRemove;
86 //CHINA001 MoreButton		aBtnMore;
87 //CHINA001 FixedLine       aFlFormatting;
88 //CHINA001 CheckBox		aBtnNumFormat;
89 //CHINA001 CheckBox		aBtnBorder;
90 //CHINA001 CheckBox		aBtnFont;
91 //CHINA001 CheckBox		aBtnPattern;
92 //CHINA001 CheckBox		aBtnAlignment;
93 //CHINA001 CheckBox		aBtnAdjust;
94 //CHINA001 PushButton		aBtnRename;
95 //CHINA001 String			aStrTitle;
96 //CHINA001 String			aStrLabel;
97 //CHINA001 String			aStrClose;
98 //CHINA001 String			aStrDelTitle;
99 //CHINA001 String			aStrDelMsg;
100 //CHINA001 String			aStrRename;
101 //CHINA001
102 //CHINA001 //------------------------
103 //CHINA001 ScAutoFormat*			pFormat;
104 //CHINA001 const ScAutoFormatData*	pSelFmtData;
105 //CHINA001 sal_uInt16					nIndex;
106 //CHINA001 sal_Bool					bCoreDataChanged;
107 //CHINA001 sal_Bool					bFmtInserted;
108 //CHINA001
109 //CHINA001 void Init			();
110 //CHINA001 void UpdateChecks	();
111 //CHINA001 //------------------------
112 //CHINA001 DECL_LINK( CheckHdl, Button * );
113 //CHINA001 DECL_LINK( AddHdl, void * );
114 //CHINA001 DECL_LINK( RemoveHdl, void * );
115 //CHINA001 DECL_LINK( SelFmtHdl, void * );
116 //CHINA001 DECL_LINK( CloseHdl, PushButton * );
117 //CHINA001 DECL_LINK( DblClkHdl, void * );
118 //CHINA001 DECL_LINK( RenameHdl, void *);
119 //CHINA001
120 //CHINA001 };
121 //CHINA001
122 //========================================================================
123 
124 class SC_DLLPUBLIC ScAutoFmtPreview : public Window
125 {
126 public:
127             ScAutoFmtPreview( Window* pParent, const ResId& rRes, ScDocument* pDoc );
128 			~ScAutoFmtPreview();
129 
130 	void NotifyChange( ScAutoFormatData* pNewData );
131 
132 protected:
133 	virtual void Paint( const Rectangle& rRect );
134 
135 private:
136     ScAutoFormatData*       pCurData;
137     VirtualDevice           aVD;
138     SvtScriptedTextHelper   aScriptedText;
139     ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XBreakIterator > xBreakIter;
140     sal_Bool                    bFitWidth;
141     svx::frame::Array       maArray;            /// Implementation to draw the frame borders.
142     bool                    mbRTL;
143     Size                    aPrvSize;
144     long                    mnLabelColWidth;
145     long                    mnDataColWidth1;
146     long                    mnDataColWidth2;
147     long                    mnRowHeight;
148     const String            aStrJan;
149     const String            aStrFeb;
150     const String            aStrMar;
151     const String            aStrNorth;
152     const String            aStrMid;
153     const String            aStrSouth;
154     const String            aStrSum;
155     SvNumberFormatter*      pNumFmt;
156 	//-------------------------------------------
157 	SC_DLLPRIVATE void	Init			();
158 	SC_DLLPRIVATE void	DoPaint			( const Rectangle& rRect );
159 	SC_DLLPRIVATE void	CalcCellArray	( sal_Bool bFitWidth );
160 	SC_DLLPRIVATE void	CalcLineMap		();
161 	SC_DLLPRIVATE void	PaintCells		();
162 
163 /*  Usage of type size_t instead of SCCOL/SCROW is correct here - used in
164     conjunction with class svx::frame::Array (svx/framelinkarray.hxx), which
165     expects size_t coordinates. */
166 
167     SC_DLLPRIVATE sal_uInt16              GetFormatIndex( size_t nCol, size_t nRow ) const;
168     SC_DLLPRIVATE const SvxBoxItem&   GetBoxItem( size_t nCol, size_t nRow ) const;
169     SC_DLLPRIVATE const SvxLineItem&  GetDiagItem( size_t nCol, size_t nRow, bool bTLBR ) const;
170 
171     SC_DLLPRIVATE void                DrawString( size_t nCol, size_t nRow );
172     SC_DLLPRIVATE void                DrawStrings();
173     SC_DLLPRIVATE void                DrawBackground();
174 
175     SC_DLLPRIVATE void    MakeFonts       ( sal_uInt16 nIndex,
176                               Font& rFont,
177                               Font& rCJKFont,
178                               Font& rCTLFont );
179 
180 	SC_DLLPRIVATE String	MakeNumberString( String cellString, sal_Bool bAddDec );
181 	SC_DLLPRIVATE void	DrawFrameLine	( const SvxBorderLine&	rLineD,
182 							  Point					from,
183 							  Point					to,
184 							  sal_Bool					bHorizontal,
185 							  const SvxBorderLine&	rLineLT,
186 							  const SvxBorderLine&	rLineL,
187 							  const SvxBorderLine&	rLineLB,
188 							  const SvxBorderLine&	rLineRT,
189 							  const SvxBorderLine&	rLineR,
190 							  const SvxBorderLine&	rLineRB );
191 	SC_DLLPRIVATE void CheckPriority	( sal_uInt16			nCurLine,
192 							  AutoFmtLine		eLine,
193 							  SvxBorderLine&	rLine );
194 	SC_DLLPRIVATE void	GetLines		( sal_uInt16 nIndex, AutoFmtLine eLine,
195 							  SvxBorderLine&	rLineD,
196 							  SvxBorderLine&	rLineLT,
197 							  SvxBorderLine&	rLineL,
198 							  SvxBorderLine&	rLineLB,
199 							  SvxBorderLine&	rLineRT,
200 							  SvxBorderLine&	rLineR,
201 							  SvxBorderLine&	rLineRB );
202 };
203 
204 #endif // SC_AUTOFMT_HXX
205 
206 
207