1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: autofmt.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SC_AUTOFMT_HXX
32 #define SC_AUTOFMT_HXX
34 #ifndef _VIRDEV_HXX //autogen
35 #include <vcl/virdev.hxx>
38 #include <vcl/fixed.hxx>
41 #include <vcl/lstbox.hxx>
44 #include <vcl/button.hxx>
46 #ifndef SV_MOREBTN_HXX
47 #include <vcl/morebtn.hxx>
49 #ifndef _DIALOG_HXX //autogen
50 #include <vcl/dialog.hxx>
52 #include <svtools/scriptedtext.hxx>
53 #include <svx/framelinkarray.hxx>
56 //------------------------------------------------------------------------
59 class ScAutoFormatData
;
62 class ScAutoFmtPreview
; // s.u.
63 class SvNumberFormatter
;
66 //------------------------------------------------------------------------
68 enum AutoFmtLine
{ TOP_LINE
, BOTTOM_LINE
, LEFT_LINE
, RIGHT_LINE
};
70 //========================================================================
72 //CHINA001 class ScAutoFormatDlg : public ModalDialog
75 //CHINA001 ScAutoFormatDlg( Window* pParent,
76 //CHINA001 ScAutoFormat* pAutoFormat,
77 //CHINA001 const ScAutoFormatData* pSelFormatData,
78 //CHINA001 ScDocument* pDoc );
79 //CHINA001 ~ScAutoFormatDlg();
81 //CHINA001 USHORT GetIndex() const { return nIndex; }
82 //CHINA001 String GetCurrFormatName();
85 //CHINA001 FixedLine aFlFormat;
86 //CHINA001 ListBox aLbFormat;
87 //CHINA001 ScAutoFmtPreview* pWndPreview;
88 //CHINA001 OKButton aBtnOk;
89 //CHINA001 CancelButton aBtnCancel;
90 //CHINA001 HelpButton aBtnHelp;
91 //CHINA001 PushButton aBtnAdd;
92 //CHINA001 PushButton aBtnRemove;
93 //CHINA001 MoreButton aBtnMore;
94 //CHINA001 FixedLine aFlFormatting;
95 //CHINA001 CheckBox aBtnNumFormat;
96 //CHINA001 CheckBox aBtnBorder;
97 //CHINA001 CheckBox aBtnFont;
98 //CHINA001 CheckBox aBtnPattern;
99 //CHINA001 CheckBox aBtnAlignment;
100 //CHINA001 CheckBox aBtnAdjust;
101 //CHINA001 PushButton aBtnRename;
102 //CHINA001 String aStrTitle;
103 //CHINA001 String aStrLabel;
104 //CHINA001 String aStrClose;
105 //CHINA001 String aStrDelTitle;
106 //CHINA001 String aStrDelMsg;
107 //CHINA001 String aStrRename;
109 //CHINA001 //------------------------
110 //CHINA001 ScAutoFormat* pFormat;
111 //CHINA001 const ScAutoFormatData* pSelFmtData;
112 //CHINA001 USHORT nIndex;
113 //CHINA001 BOOL bCoreDataChanged;
114 //CHINA001 BOOL bFmtInserted;
116 //CHINA001 void Init ();
117 //CHINA001 void UpdateChecks ();
118 //CHINA001 //------------------------
119 //CHINA001 DECL_LINK( CheckHdl, Button * );
120 //CHINA001 DECL_LINK( AddHdl, void * );
121 //CHINA001 DECL_LINK( RemoveHdl, void * );
122 //CHINA001 DECL_LINK( SelFmtHdl, void * );
123 //CHINA001 DECL_LINK( CloseHdl, PushButton * );
124 //CHINA001 DECL_LINK( DblClkHdl, void * );
125 //CHINA001 DECL_LINK( RenameHdl, void *);
129 //========================================================================
131 class SC_DLLPUBLIC ScAutoFmtPreview
: public Window
134 ScAutoFmtPreview( Window
* pParent
, const ResId
& rRes
, ScDocument
* pDoc
);
137 void NotifyChange( ScAutoFormatData
* pNewData
);
140 virtual void Paint( const Rectangle
& rRect
);
143 ScAutoFormatData
* pCurData
;
145 SvtScriptedTextHelper aScriptedText
;
146 ::com::sun::star::uno::Reference
< ::com::sun::star::i18n::XBreakIterator
> xBreakIter
;
148 svx::frame::Array maArray
; /// Implementation to draw the frame borders.
151 long mnLabelColWidth
;
152 long mnDataColWidth1
;
153 long mnDataColWidth2
;
155 const String aStrJan
;
156 const String aStrFeb
;
157 const String aStrMar
;
158 const String aStrNorth
;
159 const String aStrMid
;
160 const String aStrSouth
;
161 const String aStrSum
;
162 SvNumberFormatter
* pNumFmt
;
163 //-------------------------------------------
164 SC_DLLPRIVATE
void Init ();
165 SC_DLLPRIVATE
void DoPaint ( const Rectangle
& rRect
);
166 SC_DLLPRIVATE
void CalcCellArray ( BOOL bFitWidth
);
167 SC_DLLPRIVATE
void CalcLineMap ();
168 SC_DLLPRIVATE
void PaintCells ();
170 /* Usage of type size_t instead of SCCOL/SCROW is correct here - used in
171 conjunction with class svx::frame::Array (svx/framelinkarray.hxx), which
172 expects size_t coordinates. */
174 SC_DLLPRIVATE USHORT
GetFormatIndex( size_t nCol
, size_t nRow
) const;
175 SC_DLLPRIVATE
const SvxBoxItem
& GetBoxItem( size_t nCol
, size_t nRow
) const;
176 SC_DLLPRIVATE
const SvxLineItem
& GetDiagItem( size_t nCol
, size_t nRow
, bool bTLBR
) const;
178 SC_DLLPRIVATE
void DrawString( size_t nCol
, size_t nRow
);
179 SC_DLLPRIVATE
void DrawStrings();
180 SC_DLLPRIVATE
void DrawBackground();
182 SC_DLLPRIVATE
void MakeFonts ( USHORT nIndex
,
187 SC_DLLPRIVATE String
MakeNumberString( String cellString
, BOOL bAddDec
);
188 SC_DLLPRIVATE
void DrawFrameLine ( const SvxBorderLine
& rLineD
,
192 const SvxBorderLine
& rLineLT
,
193 const SvxBorderLine
& rLineL
,
194 const SvxBorderLine
& rLineLB
,
195 const SvxBorderLine
& rLineRT
,
196 const SvxBorderLine
& rLineR
,
197 const SvxBorderLine
& rLineRB
);
198 SC_DLLPRIVATE
void CheckPriority ( USHORT nCurLine
,
200 SvxBorderLine
& rLine
);
201 SC_DLLPRIVATE
void GetLines ( USHORT nIndex
, AutoFmtLine eLine
,
202 SvxBorderLine
& rLineD
,
203 SvxBorderLine
& rLineLT
,
204 SvxBorderLine
& rLineL
,
205 SvxBorderLine
& rLineLB
,
206 SvxBorderLine
& rLineRT
,
207 SvxBorderLine
& rLineR
,
208 SvxBorderLine
& rLineRB
);
211 #endif // SC_AUTOFMT_HXX