1 /* This file is part of the KDE project
2  * Copyright (C) 2006-2009 Thomas Zander <zander@kde.org>
3  * Copyright (C) 2007,2008 Sebastian Sauer <mail@dipe.org>
4  * Copyright (C) 2007-2011 Pierre Ducroquet <pinaraf@gmail.com>
5  * Copyright (C) 2008 Thorsten Zachmann <zachmann@kde.org>
6  * Copyright (C) 2008 Girish Ramakrishnan <girish@forwardbias.in>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public License
19  * along with this library; see the file COPYING.LIB.  If not, write to
20  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21  * Boston, MA 02110-1301, USA.
22  */
23 #ifndef KOPARAGRAPHSTYLE_H
24 #define KOPARAGRAPHSTYLE_H
25 
26 #include "KoCharacterStyle.h"
27 #include "KoText.h"
28 #include "kotext_export.h"
29 
30 #include <KoXmlReaderForward.h>
31 #include <KoBorder.h>
32 
33 #include <QVariant>
34 #include <QTextFormat>
35 
36 extern QVariant val;
37 class KoShadowStyle;
38 class KoListStyle;
39 class QTextBlock;
40 class KoGenStyle;
41 class KoShapeLoadingContext;
42 class KoShapeSavingContext;
43 class KoList;
44 
45 /**
46  * A container for all properties for the paragraph wide style.
47  * Each paragraph in the main text either is based on a parag style, or its not. Where
48  * it is based on a paragraph style this is indicated that it has a property 'StyleId'
49  * with an integer as value.  The integer value corresponds to the styleId() output of
50  * a specific KoParagraphStyle.
51  * @see KoStyleManager
52  */
53 class KOTEXT_EXPORT KoParagraphStyle : public KoCharacterStyle
54 {
55     Q_OBJECT
56 public:
57     enum Property {
58         // Every 10 properties, the decimal number shown indicates the decimal offset over the QTextFormat::UserProperty enum value
59         StyleId = QTextFormat::UserProperty + 1,
60         // Linespacing properties
61         PercentLineHeight,  ///< this property is used for a percentage of the highest character on that line
62         FixedLineHeight,    ///< this property is used to use a non-default line height
63         MinimumLineHeight,  ///< this property is used to have a minimum line spacing
64         LineSpacing,        ///< Hard leader height.
65         LineSpacingFromFont,  ///< if false, use fontsize (in pt) solely, otherwise respect font settings
66         AlignLastLine,      ///< When the paragraph is justified, what to do with the last word line
67         WidowThreshold,     ///< If 'keep together'=false, amount of lines to keep it anyway.
68         OrphanThreshold,   ///< If 'keep together'=false, amount of lines to keep it anyway.
69         DropCaps, /*10*/   ///< defines if a paragraph renders its first char(s) with drop-caps
70         DropCapsLength, ///< Number of glyphs to show as drop-caps
71         DropCapsLines,  ///< Number of lines that the drop-caps span
72         DropCapsDistance,   ///< Distance between drop caps and text
73         DropCapsTextStyle,  ///< Text style of dropped chars.
74         FollowDocBaseline,  ///< If true the baselines will be aligned with the doc-wide grid
75 
76         // border stuff
77         HasLeftBorder,  ///< If true, paint a border on the left
78         HasTopBorder,   ///< If true, paint a border on the top
79         HasRightBorder, ///< If true, paint a border on the right
80         HasBottomBorder,///< If true, paint a border on the bottom
81         BorderLineWidth, /*20*/ ///< Thickness of inner-border
82         SecondBorderLineWidth,  ///< Thickness of outer-border
83         DistanceToSecondBorder, ///< Distance between inner and outer border
84         LeftPadding,    ///< distance between text and border
85         TopPadding,     ///< distance between text and border
86         RightPadding,   ///< distance between text and border
87         BottomPadding,   ///< distance between text and border
88         LeftBorderWidth,        ///< The thickness of the border, or 0 if there is no border
89         LeftInnerBorderWidth,   ///< In case of style being 'double' the thickness of the inner border line
90         LeftBorderSpacing,      ///< In case of style being 'double' the space between the inner and outer border lines
91         LeftBorderStyle, /*30*/ ///< The border style. (see BorderStyle)
92         LeftBorderColor,        ///< The border Color
93         TopBorderWidth,         ///< The thickness of the border, or 0 if there is no border
94         TopInnerBorderWidth,    ///< In case of style being 'double' the thickness of the inner border line
95         TopBorderSpacing,       ///< In case of style being 'double' the space between the inner and outer border lines
96         TopBorderStyle,         ///< The border style. (see BorderStyle)
97         TopBorderColor,         ///< The border Color
98         RightBorderWidth,       ///< The thickness of the border, or 0 if there is no border
99         RightInnerBorderWidth,  ///< In case of style being 'double' the thickness of the inner border line
100         RightBorderSpacing,     ///< In case of style being 'double' the space between the inner and outer border lines
101         RightBorderStyle, /*40*/ ///< The border style. (see BorderStyle)
102         RightBorderColor,       ///< The border Color
103         BottomBorderWidth,      ///< The thickness of the border, or 0 if there is no border
104         BottomInnerBorderWidth, ///< In case of style being 'double' the thickness of the inner border line
105         BottomBorderSpacing,    ///< In case of style being 'double' the space between the inner and outer border lines
106         BottomBorderStyle,      ///< The border style. (see BorderStyle)
107         BottomBorderColor,      ///< The border Color
108 
109         // lists
110         ListStyleId,            ///< Style Id of associated list style
111         ListStartValue,         ///< Int with the list-value that that parag will have. Ignored if this is not a list.
112         RestartListNumbering,   ///< boolean to indicate that this paragraph will have numbering restart at the list-start. Ignored if this is not a list.
113         ListLevel, /*50*/       ///< int with the list-level that the paragraph will get when this is a list (numbered paragraphs)
114         IsListHeader,           ///< bool, if true the paragraph shows up as a list item, but w/o a list label.
115         UnnumberedListItem,     ///< bool. if true this paragraph is part of a list but is not numbered
116 
117         AutoTextIndent,         ///< bool, says whether the paragraph is auto-indented or not
118 
119         TabStopDistance,        ///< Double, Length. specifies that there's a tab stop every n inches
120         ///< (after the last of the TabPositions, if any)
121         TabPositions,           ///< A list of tab positions
122         TextProgressionDirection,
123 
124         MasterPageName,         ///< Optional name of the master-page
125 
126         OutlineLevel,            ///< Outline level for headings
127         DefaultOutlineLevel,
128 
129         // numbering
130         LineNumbering,         /*60*/   ///< bool, specifies whether lines should be numbered in this paragraph
131         LineNumberStartValue, ///< integer value that specifies the number for the first line in the paragraph
132         SectionStartings,            ///< list of section definitions
133         SectionEndings,               ///< list <end of a named section>
134 // do 15.5.24
135 // continue at 15.5.28
136         ForceDisablingList,       ///< bool, for compatibility with the weird text:enable-numbering attribute not used anymore by OpenOffice.org
137 
138         // other properties
139         BackgroundTransparency,   ///< qreal between 0 and 1, background transparency
140         SnapToLayoutGrid,         ///< bool, snap the paragraph to the layout grid of the page
141         JoinBorder,               ///< bool, whether a border for one paragraph is to be extended around the following paragraph
142         RegisterTrue,             ///< bool, align lines on both sides of a printed text
143         StrictLineBreak,          ///< bool, if true, line breaks are forbidden between some characters
144         JustifySingleWord,        ///< bool, if true, a single word will be justified
145         BreakBefore,              ///< KoText::TextBreakProperty, whether there is a page/column break before the paragraphs
146         BreakAfter,               ///< KoText::TextBreakProperty, whether there is a page/column break after the paragraphs
147         AutomaticWritingMode,     ///< bool
148         PageNumber,               ///< int, 0 means auto (ie. previous page number + 1), N sets up a new page number
149         TextAutoSpace,            ///< AutoSpace, indicating whether to add space between portions of Asian, Western and complex texts
150         KeepWithNext,             ///< Try to keep this block with its following block on the same page
151         KeepHyphenation,          ///< bool, whether both parts of a hyphenated word shall lie within a single page
152         HyphenationLadderCount,   ///< int, 0 means no limit, else limit the number of successive hyphenated line areas in a block
153         PunctuationWrap,          ///< bool, whether a punctuation mark can be at the end of a full line (false) or not (true)
154         VerticalAlignment,        ///< KoParagraphStyle::VerticalAlign, the alignment of this paragraph text
155         HiddenByTable,        ///< don't let this paragraph have any height
156 
157         NormalLineHeight,         ///< bool, internal property for reserved usage
158         BibliographyData,
159 
160         TableOfContentsData,      // set when block is instead a TableOfContents
161         GeneratedDocument,  // set when block is instead a generated document
162         Shadow,                    //< KoShadowStyle, the shadow of this paragraph
163         NextStyle,                  ///< holds the styleId of the style to be used on a new paragraph
164         ParagraphListStyleId,        ///< this holds the listStyleId of the list got from style:list-style-name property from ODF 1.2
165         EndCharStyle           // QSharedPointer<KoCharacterStyle>  used when final line is empty
166     };
167 
168     enum AutoSpace {
169         NoAutoSpace,              ///< space should not be added between portions of Asian, Western and complex texts
170         IdeographAlpha            ///< space should be added between portions of Asian, Western and complex texts
171     };
172 
173     enum VerticalAlign {
174         VAlignAuto,
175         VAlignBaseline,
176         VAlignBottom,
177         VAlignMiddle,
178         VAlignTop
179     };
180 
181     /// Constructor
182     KoParagraphStyle(QObject *parent = 0);
183     /// Creates a KoParagrahStyle with the given block format, the block character format and \a parent
184     KoParagraphStyle(const QTextBlockFormat &blockFormat, const QTextCharFormat &blockCharFormat, QObject *parent = 0);
185     /// Destructor
186     ~KoParagraphStyle() override;
187 
188     KoCharacterStyle::Type styleType() const override;
189 
190     /// Creates a KoParagraphStyle that represents the formatting of \a block.
191     static KoParagraphStyle *fromBlock(const QTextBlock &block, QObject *parent = 0);
192 
193     /// creates a clone of this style with the specified parent
194     KoParagraphStyle *clone(QObject *parent = 0) const;
195 
196     //  ***** Linespacing
197     /**
198      * Sets the line height as a percentage of the highest character on that line.
199      * A good typographically correct value would be 120%
200      * Note that lineSpacing() is added to this.
201      * You should consider doing a remove(KoParagraphStyle::LineSpacing); because if set, it will
202      *  be used instead of this value.
203      * @see setLineSpacingFromFont
204      */
205     void setLineHeightPercent(qreal lineHeight);
206     /// @see setLineHeightPercent
207     qreal lineHeightPercent() const;
208 
209     /**
210      * Sets the line height to a specific pt-based height, ignoring the font size.
211      * Setting this will ignore the lineHeightPercent() and lineSpacing() values.
212      */
213     void setLineHeightAbsolute(qreal height);
214     /// @see setLineHeightAbsolute
215     qreal lineHeightAbsolute() const;
216 
217     /**
218      * Sets the line height to have a minimum height in pt.
219      * You should consider doing a remove(KoParagraphStyle::FixedLineHeight); because if set, it will
220      *  be used instead of this value.
221      */
222     void setMinimumLineHeight(const QTextLength &height);
223     /// @see setMinimumLineHeight
224     qreal minimumLineHeight() const;
225 
226     /**
227      * Sets the space between two lines to be a specific height. The total linespacing will become
228      * the line height + this height.  Where the line height is dependent on the font.
229      * You should consider doing a remove(KoParagraphStyle::FixedLineHeight) and a
230      * remove(KoParagraphStyle::PercentLineHeight); because if set, they will be used instead of this value.
231      */
232     void setLineSpacing(qreal spacing);
233     /// @see setLineSpacing
234     qreal lineSpacing() const;
235 
236     /**
237      * Set the line-height to "normal". This overwrites a line-height set before either
238      * with \a setLineHeightAbsolute or \a setMinimumLineHeight . If set then a value
239      * set with \a setLineSpacing will be ignored.
240      */
241     void setNormalLineHeight();
242     /// @see setNormalLineHeight
243     bool hasNormalLineHeight() const;
244 
245     /**
246      * If set to true the font-encoded height will be used instead of the font-size property
247      * This property influences setLineHeightPercent() behavior.
248      * When off (default) a font of 12pt will always have a linespacing of 12pt times the
249      * current linespacing percentage.  When on the linespacing embedded in the font
250      * is used which can differ for various fonts, even if they are the same pt-size.
251      */
252     void setLineSpacingFromFont(bool on);
253     /**
254      * @see setLineSpacingFromFont
255      */
256     bool lineSpacingFromFont() const;
257 
258 
259     /**
260      * For paragraphs that are justified the last line alignment is specified here.
261      * There are only 3 valid options, Left, Center and Justified. (where Left will
262      * be right aligned for RTL text).
263      */
264     void setAlignLastLine(Qt::Alignment alignment);
265     /**
266      * @see setAlignLastLine
267      */
268     Qt::Alignment alignLastLine() const;
269     /**
270      * Paragraphs that are broken across two frames are normally broken at the bottom
271      * of the frame.  Using this property we can set the minimum number of lines that should
272      * appear in the second frame to avoid really short paragraphs standing alone (also called
273      * widows).  So, if a 10 line parag is broken in a way that only one line is in the second
274      * frame, setting a widowThreshold of 4 will break at 6 lines instead to leave the
275      * requested 4 lines.
276      */
277 
278     void setWidowThreshold(int lines);
279     /**
280      * @see setWidowThreshold
281      */
282     int widowThreshold() const;
283     /**
284      * Paragraphs that are broken across two frames are normally broken at the bottom
285      * of the frame.  Using this property we can set the minimum number of lines that should
286      * appear in the first frame to avoid really short paragraphs standing alone (also called
287      * orphans).  So, if a paragraph is broken so only 2 line is left in the first frame
288      * setting the orphanThreshold to something greater than 2 will move the whole paragraph
289      * to the second frame.
290      */
291 
292     void setOrphanThreshold(int lines);
293     /**
294      * @see setOrphanThreshold
295      */
296     int orphanThreshold() const;
297     /**
298      * If true, make the first character span multiple lines.
299      * @see setDropCapsLength
300      * @see setDropCapsLines
301      * @see dropCapsDistance
302      */
303 
304     void setDropCaps(bool on);
305     /**
306      * @see setDropCaps
307      */
308     bool dropCaps() const;
309     /**
310      * Set the number of glyphs to show as drop-caps
311      * @see setDropCaps
312      * @see setDropCapsLines
313      * @see dropCapsDistance
314      */
315 
316     void setDropCapsLength(int characters);
317     /**
318      * set dropCaps Length in characters
319      * @see setDropCapsLength
320      */
321     int dropCapsLength() const;
322     /**
323      * Set the number of lines that the drop-caps span
324      * @see setDropCapsLength
325      * @see setDropCaps
326      * @see dropCapsDistance
327      */
328 
329     void setDropCapsLines(int lines);
330     /**
331      * The dropCapsLines
332      * @see setDropCapsLines
333      */
334     int dropCapsLines() const;
335     /**
336      * set the distance between drop caps and text in pt
337      * @see setDropCapsLength
338      * @see setDropCaps
339      * @see setDropCapsLines
340      */
341 
342     void setDropCapsDistance(qreal distance);
343     /**
344      * The dropCaps distance
345      * @see setDropCapsDistance
346      */
347     qreal dropCapsDistance() const;
348 
349     /**
350      * Set the style id of the text style used for dropcaps
351      * @see setDropCapsDistance
352      */
353     void setDropCapsTextStyleId(int id);
354 
355     /**
356      * The style id of the text style used for dropcaps
357      * @see setDropCapsTextStyleId
358      */
359     int dropCapsTextStyleId() const;
360 
361     /**
362      * If true the baselines will be aligned with the doc-wide grid
363      */
364     void setFollowDocBaseline(bool on);
365     /**
366      * return if baseline alignment is used
367      * @see setFollowDocBaseline
368      */
369     bool followDocBaseline() const;
370 
371     /// See similar named method on QTextBlockFormat
372     void setBackground(const QBrush &brush);
373     /// See similar named method on QTextBlockFormat
374     QBrush background() const;
375     /// See similar named method on QTextBlockFormat
376     void clearBackground();
377 
378     qreal backgroundTransparency() const;
379     void setBackgroundTransparency(qreal transparency);
380 
381     bool snapToLayoutGrid() const;
382     void setSnapToLayoutGrid(bool value);
383 
384     bool registerTrue() const;
385     void setRegisterTrue(bool value);
386 
387     bool strictLineBreak() const;
388     void setStrictLineBreak(bool value);
389 
390     bool justifySingleWord() const;
391     void setJustifySingleWord(bool value);
392 
393     bool automaticWritingMode() const;
394     void setAutomaticWritingMode(bool value);
395 
396     void setPageNumber(int pageNumber);
397     int pageNumber() const;
398 
399     void setKeepWithNext(bool value);
400     bool keepWithNext() const;
401 
402     void setPunctuationWrap(bool value);
403     bool punctuationWrap() const;
404 
405     void setTextAutoSpace(AutoSpace value);
406     AutoSpace textAutoSpace() const;
407 
408     void setKeepHyphenation(bool value);
409     bool keepHyphenation() const;
410 
411     void setHyphenationLadderCount(int value);
412     int hyphenationLadderCount() const;
413 
414     VerticalAlign verticalAlignment() const;
415     void setVerticalAlignment(VerticalAlign value);
416 
417     void setBreakBefore(KoText::KoTextBreakProperty value);
418     KoText::KoTextBreakProperty breakBefore() const;
419     void setBreakAfter(KoText::KoTextBreakProperty value);
420     KoText::KoTextBreakProperty breakAfter() const;
421     void setLeftPadding(qreal padding);
422     qreal leftPadding() const;
423     void setTopPadding(qreal padding);
424     qreal topPadding() const;
425     void setRightPadding(qreal padding);
426     qreal rightPadding() const;
427     void setBottomPadding(qreal padding);
428     qreal bottomPadding() const;
429     void setPadding(qreal padding);
430 
431     void setLeftBorderWidth(qreal width);
432     qreal leftBorderWidth() const;
433     void setLeftInnerBorderWidth(qreal width);
434     qreal leftInnerBorderWidth() const;
435     void setLeftBorderSpacing(qreal width);
436     qreal leftBorderSpacing() const;
437     void setLeftBorderStyle(KoBorder::BorderStyle style);
438     KoBorder::BorderStyle leftBorderStyle() const;
439     void setLeftBorderColor(const QColor &color);
440     QColor leftBorderColor() const;
441     void setTopBorderWidth(qreal width);
442     qreal topBorderWidth() const;
443     void setTopInnerBorderWidth(qreal width);
444     qreal topInnerBorderWidth() const;
445     void setTopBorderSpacing(qreal width);
446     qreal topBorderSpacing() const;
447     void setTopBorderStyle(KoBorder::BorderStyle style);
448     KoBorder::BorderStyle topBorderStyle() const;
449     void setTopBorderColor(const QColor &color);
450     QColor topBorderColor() const;
451     void setRightBorderWidth(qreal width);
452     qreal rightBorderWidth() const;
453     void setRightInnerBorderWidth(qreal width);
454     qreal rightInnerBorderWidth() const;
455     void setRightBorderSpacing(qreal width);
456     qreal rightBorderSpacing() const;
457     void setRightBorderStyle(KoBorder::BorderStyle style);
458     KoBorder::BorderStyle rightBorderStyle() const;
459     void setRightBorderColor(const QColor &color);
460     QColor rightBorderColor() const;
461     void setBottomBorderWidth(qreal width);
462     qreal bottomBorderWidth() const;
463     void setBottomInnerBorderWidth(qreal width);
464     qreal bottomInnerBorderWidth() const;
465     void setBottomBorderSpacing(qreal width);
466     qreal bottomBorderSpacing() const;
467     void setBottomBorderStyle(KoBorder::BorderStyle style);
468     KoBorder::BorderStyle bottomBorderStyle() const;
469     void setBottomBorderColor(const QColor &color);
470     QColor bottomBorderColor() const;
471 
472     bool joinBorder() const;
473     void setJoinBorder(bool value);
474 
475     KoText::Direction textProgressionDirection() const;
476     void setTextProgressionDirection(KoText::Direction dir);
477 
478     // ************ properties from QTextBlockFormat
479     /// duplicated property from QTextBlockFormat
480     void setTopMargin(QTextLength topMargin);
481     /// duplicated property from QTextBlockFormat
482     qreal topMargin() const;
483     /// duplicated property from QTextBlockFormat
484     void setBottomMargin(QTextLength margin);
485     /// duplicated property from QTextBlockFormat
486     qreal bottomMargin() const;
487     /// duplicated property from QTextBlockFormat
488     void setLeftMargin(QTextLength margin);
489     /// duplicated property from QTextBlockFormat
490     qreal leftMargin() const;
491     /// duplicated property from QTextBlockFormat
492     void setRightMargin(QTextLength margin);
493     /// duplicated property from QTextBlockFormat
494     qreal rightMargin() const;
495     /// set the margin around the paragraph, making the margin on all sides equal.
496     void setMargin(QTextLength margin);
497 
498     void setIsListHeader(bool on);
499     bool isListHeader() const;
500 
501     /// duplicated property from QTextBlockFormat
502     void setAlignment(Qt::Alignment alignment);
503     /// duplicated property from QTextBlockFormat
504     Qt::Alignment alignment() const;
505     /// duplicated property from QTextBlockFormat
506     void setTextIndent(QTextLength margin);
507     /// duplicated property from QTextBlockFormat
508     qreal textIndent() const;
509     /// Custom KoParagraphStyle property for auto-text-indent
510     void setAutoTextIndent(bool on);
511     bool autoTextIndent() const;
512 
513     /// duplicated property from QTextBlockFormat
514     void setNonBreakableLines(bool on);
515     /// duplicated property from QTextBlockFormat
516     bool nonBreakableLines() const;
517 
518     /// set the default style this one inherits its unset properties from if no parent style.
519     void setDefaultStyle(KoParagraphStyle *parent);
520 
521     /// set the parent style this one inherits its unset properties from.
522     void setParentStyle(KoParagraphStyle *parent);
523 
524     /// return the parent style
525     KoParagraphStyle *parentStyle() const;
526 
527     /// the 'next' style is the one used when the user creates a new paragraph after this one.
528     void setNextStyle(int next);
529 
530     /// the 'next' style is the one used when the user creates a new paragraph after this one.
531     int nextStyle() const;
532 
533     /// return the name of the style.
534     QString name() const;
535 
536     /// set a user-visible name on the style.
537     void setName(const QString &name);
538 
539     /// each style has a unique ID (non persistent) given out by the styleManager
540     int styleId() const;
541 
542     /// each style has a unique ID (non persistent) given out by the styleManager
543     void setStyleId(int id);
544 
545     /// return the optional name of the master-page or a QString() if this paragraph isn't attached to a master-page.
546     QString masterPageName() const;
547     /// Set the name of the master-page.
548     void setMasterPageName(const QString &name);
549 
550 
551     /// Set the list start value
552     void setListStartValue(int value);
553     /// Returns the list start value
554     int listStartValue() const;
555 
556     /// Set to true if this paragraph is marked to start the list numbering from the first entry.
557     void setRestartListNumbering(bool on);
558     /// return if this paragraph is marked to start the list numbering from the first entry.
559     bool restartListNumbering();
560 
561     /// Set the tab stop distance for this paragraph style.
562     void setTabStopDistance(qreal value);
563     /// return the tab stop distance for this paragraph style
564     qreal tabStopDistance() const;
565     /// Set the tab data for this paragraph style.
566     void setTabPositions(const QVector<KoText::Tab> &tabs);
567     /// return the tabs data for this paragraph style
568     QVector<KoText::Tab> tabPositions() const;
569 
570     /// If this style is a list, then this sets the nested-ness (aka level) of this paragraph.  A H2 has level 2.
571     void setListLevel(int value);
572     /// return the list level.
573     int listLevel() const;
574 
575     /**
576      * Return the outline level of this block, or 0 if it's not a heading.
577      * This information is here and not in the styles because the OpenDocument specification says so.
578      * See ODF Spec 1.1, §14.1, Outline Numbering Level, but also other parts of the specification.
579      */
580     int outlineLevel() const;
581 
582     /**
583      * Change this block outline level
584      */
585     void setOutlineLevel(int outline);
586 
587     /**
588      * Return the default outline level of this style, or 0 if there is none.
589      */
590     int defaultOutlineLevel() const;
591 
592     /**
593      * Change the default outline level for this style.
594      */
595     void setDefaultOutlineLevel(int outline);
596 
597 
598     /**
599      * 15.5.30: The text:number-lines attribute controls whether or not lines are numbered
600      */
601     bool lineNumbering() const;
602     void setLineNumbering(bool lineNumbering);
603 
604     /**
605      * 15.5.31:
606      * The text:line-number property specifies a new start value for line numbering. The attribute is
607      * only recognized if there is also a text:number-lines attribute with a value of true in the
608      * same properties element.
609      */
610     int lineNumberStartValue() const;
611     void setLineNumberStartValue(int lineNumberStartValue);
612 
613     /**
614      * 20.349 style:shadow
615      * The style:shadow attribute specifies a shadow effect.
616      * The defined values for this attribute are those defined in §7.16.5 of [XSL], except the value
617      * inherit.
618      * The shadow effect is not applied to the text content of an element, but depending on the element
619      * where the attribute appears, to a paragraph, a text box, a page body, a header, a footer, a table
620      * or a table cell.
621      */
622     KoShadowStyle shadow() const;
623     void setShadow (const KoShadowStyle &shadow);
624 
625     /// copy all the properties from the other style to this style, effectively duplicating it.
626     void copyProperties(const KoParagraphStyle *style);
627 
628     void unapplyStyle(QTextBlock &block) const;
629 
630     /**
631      * Apply this style to a blockFormat by copying all properties from this, and parent
632      * styles to the target block format.  Note that the character format will not be applied
633      * using this method, use the other applyStyle() method for that.
634      */
635     void applyStyle(QTextBlockFormat &format) const;
636 
637     /**
638      * Apply this style to the textBlock by copying all properties from this, parent and
639      * the character style (where relevant) to the target block formats.
640      */
641     void applyStyle(QTextBlock &block, bool applyListStyle = true) const;
642 /*
643     /// return the character "properties" for this paragraph style, Note it does not inherit
644     KoCharacterStyle *characterStyle();
645     /// return the character "properties" for this paragraph style, Note it does not inherit
646     const KoCharacterStyle *characterStyle() const;
647     /// set the character "properties" for this paragraph style
648     void setCharacterStyle(KoCharacterStyle *style);
649 */
650     /**
651      * Returns the list style for this paragraph style.
652      * @see KoListStyle::isValid()
653      * @see setListStyle()
654      * @see removeListStyle()
655      */
656     KoListStyle *listStyle() const;
657     /**
658      * Set a new liststyle on this paragraph style, making all paragraphs that use this style
659      *  automatically be part of the list.
660      * @see setListStyle()
661      * @see removeListStyle()
662      */
663     void setListStyle(KoListStyle *style);
664 
665     void remove(int key);
666 
667     /// Compare the paragraph, character and list properties of this style with the other
668     bool operator==(const KoParagraphStyle &other) const;
669     /// Compare the paragraph properties of this style with other
670     bool compareParagraphProperties(const KoParagraphStyle &other) const;
671 
672     void removeDuplicates(const KoParagraphStyle &other);
673 
674     /**
675      * Load the style form the element
676      *
677      * @param context the odf loading context
678      * @param element the element containing the style
679      * @param loadParents true = use the stylestack, false = use just the element
680      */
681     void loadOdf(const KoXmlElement *element, KoShapeLoadingContext &context,
682                 bool loadParents = false);
683 
684     void saveOdf(KoGenStyle &style, KoShapeSavingContext &context) const;
685 
686     /**
687      * Returns true if this paragraph style has the property set.
688      * Note that this method does not delegate to the parent style.
689      * @param key the key as found in the Property enum
690      */
691     bool hasProperty(int key) const;
692 
693     /**
694      * Set a property with key to a certain value, overriding the value from the parent style.
695      * If the value set is equal to the value of the parent style, the key will be removed instead.
696      * @param key the Property to set.
697      * @param value the new value to set on this style.
698      * @see hasProperty(), value()
699      */
700     void setProperty(int key, const QVariant &value);
701     /**
702      * Return the value of key as represented on this style, taking into account parent styles.
703      * You should consider using the direct accessors for individual properties instead.
704      * @param key the Property to request.
705      * @returns a QVariant which holds the property value.
706      */
707     QVariant value(int key) const;
708     /**
709      * Returns true if this pragraph style has default properties
710      * Note that the value of StyleId property is not considered
711      */
712     bool hasDefaults() const;
713 
714     KoList *list() const;
715 
716     void applyParagraphListStyle(QTextBlock &block, const QTextBlockFormat &blockFormat) const;
717 
718     /** Returns true if the style is in use.
719      */
720     bool isApplied() const;
721 
722 
723 Q_SIGNALS:
724     void styleApplied(const KoParagraphStyle*) const;
725 
726 private:
727     /**
728      * Load the style from the \a KoStyleStack style stack using the
729      * OpenDocument format.
730      */
731     void loadOdfProperties(KoShapeLoadingContext &scontext);
732     qreal propertyDouble(int key) const;
733     QTextLength propertyLength(int key) const;
734     int propertyInt(int key) const;
735     bool propertyBoolean(int key) const;
736     QColor propertyColor(int key) const;
737 
738     class Private;
739     Private * const d;
740 };
741 Q_DECLARE_METATYPE(KoParagraphStyle *)
742 Q_DECLARE_METATYPE(const KoParagraphStyle *)
743 Q_DECLARE_METATYPE(QSharedPointer<KoParagraphStyle>)
744 #endif
745