lib Library API Documentation

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., 59 Temple Place - Suite 330,
00017    Boston, MA 02111-1307, 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 
00038 class KOTEXT_EXPORT KoParagLayout
00039 {
00040 public:
00041     KoParagLayout();
00042     KoParagLayout( const KoParagLayout &layout ) { operator=( layout ); }
00043 
00044     ~KoParagLayout();
00045 
00048     enum { Alignment = 1,
00049            BulletNumber = 2, // TODO: we can use Counter now :)
00050            Margins = 4,
00051            LineSpacing = 8,
00052            Borders = 16,
00053            Tabulator = 32,
00054            PageBreaking = 64,
00055            /* Style is maybe missing */
00056            All = Alignment | BulletNumber | Margins | LineSpacing | Borders | Tabulator | PageBreaking
00057     } Flags;
00058 
00060     enum {
00061         BreakBetweenLines = 0, // default
00062         KeepLinesTogether = 1,
00063         HardFrameBreakBefore = 2,      // incompatible with KeepWithPrevious
00064         HardFrameBreakAfter = 4,       // incompatible with KeepWithNext
00065         KeepWithPrevious = 8,          // incompatible with HardFrameBreakBefore
00066         KeepWithNext = 16              // incompatible with HardFrameBreakAfter
00067     };
00068 
00069     // This class is used as a struct, which explains the public vars :)
00071     double margins[5];
00083     enum SpacingType { LS_SINGLE = 0, LS_ONEANDHALF = -1, LS_DOUBLE = -2,
00084                        LS_CUSTOM = -3, LS_AT_LEAST = -4, LS_MULTIPLE = -5, LS_FIXED = -6 };
00085     SpacingType lineSpacingType;
00086     double lineSpacingValue() const { return lineSpacing;}
00087     void setLineSpacingValue(double _value) { lineSpacing = _value;}
00088 
00089     static QString* shadowCssCompat; // used for compat with koffice-1.2 when loading
00090 
00091     char unused;          // for future use
00092     char pageBreaking;    // Page breaking flags
00093     char direction;       // QChar::Direction
00095     char alignment; // Qt::AlignmentFlags
00096     KoBorder leftBorder, rightBorder, topBorder, bottomBorder;
00098     KoParagCounter* counter;
00099 
00100     KoParagStyle* style;
00101 
00102     bool hasBorder() const { return topBorder.penWidth() > 0
00103                                  || bottomBorder.penWidth() > 0
00104                                  || leftBorder.penWidth() > 0
00105                                  || rightBorder.penWidth() > 0; }
00106 
00107     void setTabList( const KoTabulatorList & tabList ) { m_tabList = tabList; }
00108     const KoTabulatorList& tabList() const { return m_tabList; }
00109 
00110     void operator=( const KoParagLayout & );
00111 
00113     int compare( const KoParagLayout & layout ) const;
00114 
00118     void saveParagLayout( QDomElement & parentElem, int alignment ) const;
00119 
00123     static void loadParagLayout( KoParagLayout& layout, const QDomElement& parentElem, int docVersion = 2 );
00124 
00126     static void loadOasisParagLayout( KoParagLayout& layout, KoOasisContext& context );
00130     void saveOasis( KoGenStyle& gs, KoSavingContext& context, bool savingStyle ) const;
00131 
00133     static Qt::AlignmentFlags loadOasisAlignment( const QCString& str );
00135     static QCString saveOasisAlignment( Qt::AlignmentFlags alignment );
00136 
00137 private:
00138     static int getAttribute(const QDomElement &element, const char *attributeName, int defaultValue) {
00139         QString value = element.attribute( attributeName );
00140         return value.isNull() ? defaultValue : value.toInt();
00141     }
00142 
00143     static double getAttribute(const QDomElement &element, const char *attributeName, double defaultValue) {
00144         QString value = element.attribute( attributeName );
00145         return value.isNull() ? defaultValue : value.toDouble();
00146     }
00147 
00148 private:
00149     KoTabulatorList m_tabList;
00150     double lineSpacing;
00151     class Private;
00152     Private *d;
00153 
00155     void initialise();
00156 };
00157 
00158 #endif
KDE Logo
This file is part of the documentation for lib Library Version 1.4.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Mon Feb 13 09:40:04 2006 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003