Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*************************************************************************
3 : *
4 : * The Contents of this file are made available subject to the terms of
5 : * either of the following licenses
6 : *
7 : * - GNU Lesser General Public License Version 2.1
8 : * - Sun Industry Standards Source License Version 1.1
9 : *
10 : * Sun Microsystems Inc., October, 2000
11 : *
12 : * GNU Lesser General Public License Version 2.1
13 : * =============================================
14 : * Copyright 2000 by Sun Microsystems, Inc.
15 : * 901 San Antonio Road, Palo Alto, CA 94303, USA
16 : *
17 : * This library is free software; you can redistribute it and/or
18 : * modify it under the terms of the GNU Lesser General Public
19 : * License version 2.1, as published by the Free Software Foundation.
20 : *
21 : * This library is distributed in the hope that it will be useful,
22 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 : * Lesser General Public License for more details.
25 : *
26 : * You should have received a copy of the GNU Lesser General Public
27 : * License along with this library; if not, write to the Free Software
28 : * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
29 : * MA 02111-1307 USA
30 : *
31 : *
32 : * Sun Industry Standards Source License Version 1.1
33 : * =================================================
34 : * The contents of this file are subject to the Sun Industry Standards
35 : * Source License Version 1.1 (the "License"); You may not use this file
36 : * except in compliance with the License. You may obtain a copy of the
37 : * License at http://www.openoffice.org/license.html.
38 : *
39 : * Software provided under this License is provided on an "AS IS" basis,
40 : * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
41 : * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
42 : * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
43 : * See the License for the specific provisions governing your rights and
44 : * obligations concerning the Software.
45 : *
46 : * The Initial Developer of the Original Code is: IBM Corporation
47 : *
48 : * Copyright: 2008 by IBM Corporation
49 : *
50 : * All Rights Reserved.
51 : *
52 : * Contributor(s): _______________________________________
53 : *
54 : *
55 : ************************************************************************/
56 : /*************************************************************************
57 : * @file
58 : * Styles for paragraph.
59 : * Styles for paragraph may include many style,include font,indent,margin,
60 : * shadow,line height,and so on.
61 : ************************************************************************/
62 : #ifndef _XFPARASTYLE_HXX
63 : #define _XFPARASTYLE_HXX
64 :
65 : #include "xfglobal.hxx"
66 : #include "xfstyle.hxx"
67 : #include "xfcolor.hxx"
68 : #include "xfmargins.hxx"
69 : #include "xfbreaks.hxx"
70 : #include "xfpadding.hxx"
71 : #include "xfshadow.hxx"
72 : #include "xfdropcap.hxx"
73 : #include "xfstylecont.hxx"
74 : #include "xflineheight.hxx"
75 :
76 : #define XFPARA_FLAG_FONT 0X00000001
77 : #define XFPARA_FLAG_DROPCAP 0X00000002
78 : #define XFPARA_FLAG_BACKCOLOR 0X00000004
79 :
80 : class XFFont;
81 : class XFBorders;
82 : class XFBGImage;
83 :
84 : /**
85 : * @brief
86 : * Style object for aragraph.
87 : */
88 : class XFParaStyle : public XFStyle
89 : {
90 : public:
91 : XFParaStyle();
92 :
93 : XFParaStyle(const XFParaStyle& other);
94 :
95 : XFParaStyle& operator=(const XFParaStyle& other);
96 :
97 : virtual ~XFParaStyle();
98 :
99 : public:
100 : /**
101 : * @descr Set layout for the paragraph.When such property was setted, this paragraph will
102 : * start at an new page.
103 : */
104 : void SetMasterPage(const OUString& master);
105 :
106 : OUString GetMasterPage();
107 :
108 : /**
109 : * @descr set the paragraph default font.
110 : * @param font font object to be setted.Font object are deleted by font-factory,so
111 : * dont't delete it in the destructure function of para style.
112 : */
113 : void SetFont(XFFont *font);
114 :
115 : /**
116 : * @descr get the font object.
117 : */
118 275 : XFFont* GetFont(){ return m_pFont; }
119 :
120 : /**
121 : * @descr Set the indent of the paragraph.This is the indent for
122 : the first line.
123 : * @param indent value of the first-line indent.
124 : */
125 : void SetIndent(double indent );
126 :
127 : /**
128 : * @descr Set line number style.
129 : */
130 : void SetLineNumber(sal_Bool show, sal_Int32 restart=1);
131 : /**
132 : * @descr Set the pading of the paragraph.This is the distance
133 : between the border and the top of the text.
134 : * @param indent value of the padding.
135 : */
136 : void SetPadding(double left, double right = -1, double top = -1, double bottom = -1);
137 :
138 : /**
139 : * @descr Set the Margins of the paragraph.
140 : * @param -1: don't change.
141 : other: set value.
142 : */
143 : void SetMargins(double left, double right=-1,double top=-1, double bottom=-1);
144 :
145 : /**
146 : * @descr Set alignment property of the paragraph.
147 : * @param eAlign alignment type,left,right,center or justify.
148 : */
149 : void SetAlignType(enumXFAlignType eAlign);
150 :
151 : enumXFAlignType GetAlighType();
152 :
153 : /**
154 : * @descr Set last line alignment property of the paragraph.
155 : * @param eAlign alignment type,left,right,center or justify.
156 : eJustSingleWord If chars of the last-line'word should be
157 : stretched.
158 : */
159 : void SetLastLineAlign(enumXFAlignType align,sal_Bool bJustSingleWord = sal_False);
160 :
161 : /**
162 : * @descr Set the shadow of the paragraph.there is 4 postions, you
163 : can find it in the definition of enumShadowPos.
164 : * @param pos
165 : * @param offset the distance between the paragraph border and the shadow.
166 : * @param color color to fill the shadow.
167 : */
168 : void SetShadow(enumXFShadowPos pos, double offset, XFColor& color);
169 :
170 : /**
171 : * @descr The borders is complex,so you have to create one before use.
172 : Very few paragraphs will readly have borders property,this way
173 : we can save much memory.
174 : * @param pBorders borders of the paragraph,please reference the XFBorders.
175 : */
176 : void SetBorders(XFBorders *pBorders);
177 :
178 : /**
179 : * @descr Set drop caption of the paragraph.
180 : * @param nLength number of chars to be dropped.
181 : * @param nLines line of which the dropped chars will occupy.
182 : */
183 : void SetDropCap(sal_Int16 nLength = 1,sal_Int16 nLines = 3,double fDistance = 0);
184 :
185 : /**
186 : * @descr Set line height of the paragraph.
187 : * @param type type of line height,fixed,space,percent or cm.
188 : * @param value value of the line height
189 : */
190 : void SetLineHeight(enumLHType type, double value);
191 :
192 : /**
193 : * @descr Set background color of the paragraph.
194 : * @param color value of the back color.
195 : */
196 : void SetBackColor(XFColor& color);
197 :
198 : /**
199 : * @descr Set background image of the paragraph.
200 : * @param image the background image to set.
201 : */
202 : void SetBackImage(XFBGImage *image);
203 :
204 : /**
205 : * descr You can only set one break property for every para style object.
206 : */
207 : void SetBreaks(enumXFBreaks breaks);
208 :
209 : /**
210 : * @descr For paragraph numbering.
211 : */
212 : void SetPageNumber(sal_Int32 num);
213 :
214 : /**
215 : * @descr Add a tab style.
216 : */
217 : void AddTabStyle(enumXFTab type, double len, sal_Unicode leader = '*', sal_Unicode delimiter='.');
218 :
219 : /**
220 : * @descr for para style copy operator,sometimes you may need to override tab styles.
221 : */
222 : void ClearTabStyles();
223 :
224 : /**
225 : * descr set the paragraph to be in the same page with the next paragraph.
226 : * If that can't be insured,the paragraph will start with a new page.
227 : */
228 : void SetKeepWithNext(sal_Bool keepWithNext);
229 :
230 : sal_uInt32 GetFlag(){ return m_nFlag; }
231 :
232 6 : XFMargins& GetMargins(){return m_aMargin;}
233 :
234 : virtual enumXFStyle GetStyleFamily() SAL_OVERRIDE;
235 :
236 : virtual sal_Bool Equal(IXFStyle *pStyle) SAL_OVERRIDE;
237 :
238 : virtual void ToXml(IXFStream *strm) SAL_OVERRIDE;
239 :
240 28 : void SetNumberRight(sal_Bool bFlag){m_bNumberRight = bFlag;}
241 4 : sal_Bool GetNumberRight(){return m_bNumberRight;}
242 :
243 : protected:
244 : OUString m_strMasterPage;
245 : enumXFAlignType m_eAlignType;
246 : enumXFAlignType m_eLastLineAlign;
247 : sal_Bool m_bJustSingleWord;
248 : sal_Bool m_bKeepWithNext;
249 :
250 : double m_fTextIndent;
251 : XFColor m_aBackColor;
252 : XFMargins m_aMargin;
253 : XFPadding m_aPadding;
254 : XFStyleContainer m_aTabs;
255 : XFFont *m_pFont;
256 : XFShadow m_aShadow;
257 : XFBorders *m_pBorders;
258 : XFBGImage *m_pBGImage;
259 : XFDropcap m_aDropcap;
260 : XFLineHeight m_aLineHeight;
261 : XFBreaks m_aBreaks;
262 : sal_Int32 m_nPageNumber;
263 : sal_Bool m_bNumberLines;
264 : sal_Int32 m_nLineNumberRestart;
265 :
266 : sal_uInt32 m_nFlag;
267 : sal_Bool m_bNumberRight;
268 : };
269 :
270 13 : inline void XFParaStyle::SetMasterPage(const OUString& master)
271 : {
272 13 : m_strMasterPage = master;
273 13 : }
274 :
275 13 : inline void XFParaStyle::SetBreaks(enumXFBreaks breaks)
276 : {
277 13 : m_aBreaks.SetBreakType(breaks);
278 13 : }
279 :
280 : inline void XFParaStyle::SetPageNumber(sal_Int32 num)
281 : {
282 : assert(num>0);
283 : m_nPageNumber = num;
284 : }
285 :
286 : inline void XFParaStyle::SetLineNumber(sal_Bool show, sal_Int32 restart)
287 : {
288 : m_bNumberLines = show;
289 : m_nLineNumberRestart = restart;
290 : }
291 :
292 2 : inline void XFParaStyle::SetPadding(double left, double right, double top, double bottom)
293 : {
294 2 : m_aPadding.SetLeft(left);
295 2 : if( right == -1 )
296 0 : m_aPadding.SetRight(left);
297 : else
298 2 : m_aPadding.SetRight(right);
299 2 : if( top == -1 )
300 0 : m_aPadding.SetTop(left);
301 : else
302 2 : m_aPadding.SetTop(top);
303 2 : if( bottom == -1 )
304 0 : m_aPadding.SetBottom(left);
305 : else
306 2 : m_aPadding.SetBottom(bottom);
307 2 : }
308 :
309 27 : inline void XFParaStyle::SetAlignType(enumXFAlignType eAlign)
310 : {
311 27 : m_eAlignType = eAlign;
312 27 : }
313 :
314 : inline void XFParaStyle::SetLastLineAlign(enumXFAlignType align, sal_Bool bJustSingleWord)
315 : {
316 : m_eLastLineAlign = align;
317 : m_bJustSingleWord = bJustSingleWord;
318 : }
319 :
320 : inline void XFParaStyle::SetKeepWithNext(sal_Bool keep)
321 : {
322 : m_bKeepWithNext = keep;
323 : }
324 :
325 5 : inline void XFParaStyle::ClearTabStyles()
326 : {
327 5 : m_aTabs.Reset();
328 5 : }
329 :
330 11 : inline OUString XFParaStyle::GetMasterPage()
331 : {
332 11 : return m_strMasterPage;
333 : }
334 :
335 : inline enumXFAlignType XFParaStyle::GetAlighType()
336 : {
337 : return m_eAlignType;
338 : }
339 :
340 8 : class XFDefaultParaStyle : public XFStyle
341 : {
342 : public:
343 : XFDefaultParaStyle();
344 : void SetTabDistance(double len);
345 : enumXFStyle GetStyleFamily() SAL_OVERRIDE;
346 : virtual void ToXml(IXFStream *pStrm) SAL_OVERRIDE;
347 : private:
348 : double m_fTabDistance;
349 : };
350 :
351 4 : inline void XFDefaultParaStyle::SetTabDistance(double len)
352 : {
353 4 : m_fTabDistance = len;
354 4 : }
355 :
356 : #endif
357 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|