lib

KoParagLayout.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2001 David Faure <faure@kde.org>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #ifndef koparaglayout_h
00021 #define koparaglayout_h
00022 
00023 #include <KoRuler.h> // for KoTabulatorList
00024 #include <qdom.h>
00025 #include "KoBorder.h"
00026 #include <koffice_export.h>
00027 class KoSavingContext;
00028 class KoGenStyle;
00029 class KoParagCounter;
00030 class KoParagStyle;
00031 class KoOasisContext;
00032 class QColor;
00033 
00039 class KOTEXT_EXPORT KoParagLayout
00040 {
00041 public:
00042     KoParagLayout();
00043     KoParagLayout( const KoParagLayout &layout ) { operator=( layout ); }
00044 
00045     ~KoParagLayout();
00046 
00049     enum { Alignment = 1,
00050            BulletNumber = 2, // TODO: we can use Counter now :)
00051            Margins = 4,
00052            LineSpacing = 8,
00053            Borders = 16,
00054            Tabulator = 32,
00055            PageBreaking = 64,
00056            BackgroundColor = 128,
00057            /* Style is maybe missing */
00058            All = Alignment | BulletNumber | Margins | LineSpacing |
00059                  Borders | Tabulator | PageBreaking | BackgroundColor
00060     } Flags;
00061 
00063     enum {
00064         BreakBetweenLines = 0, // default
00065         KeepLinesTogether = 1,
00066         HardFrameBreakBefore = 2,      // incompatible with KeepWithPrevious
00067         HardFrameBreakAfter = 4,       // incompatible with KeepWithNext
00068         KeepWithPrevious = 8,          // incompatible with HardFrameBreakBefore
00069         KeepWithNext = 16              // incompatible with HardFrameBreakAfter
00070     };
00071 
00072     // This class is used as a struct, which explains the public vars :)
00074     double margins[5];
00086     enum SpacingType { LS_SINGLE = 0, LS_ONEANDHALF = -1, LS_DOUBLE = -2,
00087                        LS_CUSTOM = -3, LS_AT_LEAST = -4, LS_MULTIPLE = -5, LS_FIXED = -6 };
00088     SpacingType lineSpacingType;
00089     double lineSpacingValue() const { return lineSpacing;}
00090     void setLineSpacingValue(double _value) { lineSpacing = _value;}
00091 
00092     static QString* shadowCssCompat; // used for compat with koffice-1.2 when loading
00093 
00094     bool joinBorder:1;
00095     bool unused:7;          // for future use
00096     char pageBreaking;    // Page breaking flags
00097     char direction;       // QChar::Direction
00099     char alignment; // Qt::AlignmentFlags
00100     KoBorder leftBorder, rightBorder, topBorder, bottomBorder;
00101 
00103 
00109     QColor backgroundColor;
00110 
00112     KoParagCounter* counter;
00113 
00114     KoParagStyle* style;
00115 
00116     bool hasBorder() const { return topBorder.penWidth() > 0
00117                                  || bottomBorder.penWidth() > 0
00118                                  || leftBorder.penWidth() > 0
00119                                  || rightBorder.penWidth() > 0; }
00120 
00121     void setTabList( const KoTabulatorList & tabList ) { m_tabList = tabList; }
00122     const KoTabulatorList& tabList() const { return m_tabList; }
00123 
00125 
00130     void operator=( const KoParagLayout & );
00131 
00133     int compare( const KoParagLayout & layout ) const;
00134 
00138     void saveParagLayout( QDomElement & parentElem, int alignment ) const;
00139 
00143     static void loadParagLayout( KoParagLayout& layout, const QDomElement& parentElem, int docVersion = 2 );
00144 
00146     static void loadOasisParagLayout( KoParagLayout& layout, KoOasisContext& context );
00152     void saveOasis( KoGenStyle& gs, KoSavingContext& context, bool savingStyle ) const;
00153 
00155     static Qt::AlignmentFlags loadOasisAlignment( const QCString& str );
00157     static QCString saveOasisAlignment( Qt::AlignmentFlags alignment );
00158 
00159 private:
00160     static int getAttribute(const QDomElement &element, const char *attributeName, int defaultValue) {
00161         QString value = element.attribute( attributeName );
00162         return value.isNull() ? defaultValue : value.toInt();
00163     }
00164 
00165     static double getAttribute(const QDomElement &element, const char *attributeName, double defaultValue) {
00166         QString value = element.attribute( attributeName );
00167         return value.isNull() ? defaultValue : value.toDouble();
00168     }
00169 
00170 private:
00171     KoTabulatorList m_tabList;
00172     double lineSpacing;
00173     class Private;
00174     Private *d;
00175 
00177     void initialise();
00178 };
00179 
00180 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys