lib

KoPageLayout.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
00003    Copyright 2002, 2003 David Faure <faure@kde.org>
00004    Copyright 2003 Nicolas GOUTTE <goutte@kde.org>
00005 
00006    This library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Library General Public
00008    License as published by the Free Software Foundation; either
00009    version 2 of the License, or (at your option) any later version.
00010 
00011    This library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Library General Public License for more details.
00015 
00016    You should have received a copy of the GNU Library General Public License
00017    along with this library; see the file COPYING.LIB.  If not, write to
00018    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019  * Boston, MA 02110-1301, USA.
00020 */
00021 
00022 #ifndef KOPAGELAYOUT_H
00023 #define KOPAGELAYOUT_H
00024 
00025 #include <KoGenStyles.h>
00026 #include <qstringlist.h>
00027 #include <koffice_export.h>
00028 class QDomElement;
00029 
00039 enum KoFormat {
00040     PG_DIN_A3 = 0,
00041     PG_DIN_A4 = 1,
00042     PG_DIN_A5 = 2,
00043     PG_US_LETTER = 3,
00044     PG_US_LEGAL = 4,
00045     PG_SCREEN = 5,
00046     PG_CUSTOM = 6,
00047     PG_DIN_B5 = 7,
00048     PG_US_EXECUTIVE = 8,
00049     PG_DIN_A0 = 9,
00050     PG_DIN_A1 = 10,
00051     PG_DIN_A2 = 11,
00052     PG_DIN_A6 = 12,
00053     PG_DIN_A7 = 13,
00054     PG_DIN_A8 = 14,
00055     PG_DIN_A9 = 15,
00056     PG_DIN_B0 = 16,
00057     PG_DIN_B1 = 17,
00058     PG_DIN_B10 = 18,
00059     PG_DIN_B2 = 19,
00060     PG_DIN_B3 = 20,
00061     PG_DIN_B4 = 21,
00062     PG_DIN_B6 = 22,
00063     PG_ISO_C5 = 23,
00064     PG_US_COMM10 = 24,
00065     PG_ISO_DL = 25,
00066     PG_US_FOLIO = 26,
00067     PG_US_LEDGER = 27,
00068     PG_US_TABLOID = 28,
00069     // update the number below and the static arrays if you add more values to the enum
00070     PG_LAST_FORMAT = PG_US_TABLOID // used by koPageLayout.cpp
00071 };
00072 
00076 enum KoOrientation {
00077     PG_PORTRAIT = 0,
00078     PG_LANDSCAPE = 1
00079 };
00080 
00081 namespace KoPageFormat
00082 {
00093     KOFFICECORE_EXPORT int /*KPrinter::PageSize*/ printerPageSize( KoFormat format );
00094 
00099     KOFFICECORE_EXPORT double width( KoFormat format, KoOrientation orientation );
00100 
00105     KOFFICECORE_EXPORT double height( KoFormat format, KoOrientation orientation );
00106 
00111     KOFFICECORE_EXPORT QString formatString( KoFormat format );
00112 
00117     KOFFICECORE_EXPORT KoFormat formatFromString( const QString & string );
00118 
00122     KOFFICECORE_EXPORT KoFormat defaultFormat();
00123 
00128     KOFFICECORE_EXPORT QString name( KoFormat format );
00129 
00133     KOFFICECORE_EXPORT QStringList allFormats();
00134 
00139     KOFFICECORE_EXPORT KoFormat guessFormat( double width, double height );
00140 }
00141 
00142 
00149 enum KoHFType {
00150     HF_SAME = 0,            
00151     HF_FIRST_EO_DIFF = 1,   
00152     HF_FIRST_DIFF = 2,      
00153     HF_EO_DIFF = 3          
00154 };
00155 
00160 struct KoPageLayout
00161 {
00163     KoFormat format;
00165     KoOrientation orientation;
00166 
00168     double ptWidth;
00170     double ptHeight;
00172     double ptLeft;
00174     double ptRight;
00176     double ptTop;
00178     double ptBottom;
00179     double ptPageEdge;
00180     double ptBindingSide;
00181 
00182     bool operator==( const KoPageLayout& l ) const {
00183        return ( ptWidth == l.ptWidth &&
00184                 ptHeight == l.ptHeight &&
00185                 ptLeft == l.ptLeft &&
00186                 ptRight == l.ptRight &&
00187                 ptTop == l.ptTop &&
00188                 ptBottom == l.ptBottom &&
00189                 ptPageEdge == l.ptPageEdge &&
00190                 ptBindingSide == l.ptBindingSide);
00191     }
00192     bool operator!=( const KoPageLayout& l ) const {
00193         return !( (*this) == l );
00194     }
00195 
00199     KOFFICECORE_EXPORT KoGenStyle saveOasis() const;
00200 
00204     KOFFICECORE_EXPORT void loadOasis(const QDomElement &style);
00205 
00211     static KOFFICECORE_EXPORT KoPageLayout standardLayout();
00212 };
00213 
00215 struct KoHeadFoot
00216 {
00217     QString headLeft;
00218     QString headMid;
00219     QString headRight;
00220     QString footLeft;
00221     QString footMid;
00222     QString footRight;
00223 };
00224 
00226 struct KoColumns
00227 {
00228     int columns;
00229     double ptColumnSpacing;
00230     bool operator==( const KoColumns& rhs ) const {
00231         return columns == rhs.columns &&
00232                QABS(ptColumnSpacing - rhs.ptColumnSpacing) <= 1E-10;
00233     }
00234     bool operator!=( const KoColumns& rhs ) const {
00235         return columns != rhs.columns ||
00236                QABS(ptColumnSpacing - rhs.ptColumnSpacing) > 1E-10;
00237     }
00238 };
00239 
00241 struct KoKWHeaderFooter
00242 {
00243     KoHFType header;
00244     KoHFType footer;
00245     double ptHeaderBodySpacing;
00246     double ptFooterBodySpacing;
00247     double ptFootNoteBodySpacing;
00248     bool operator==( const KoKWHeaderFooter& rhs ) const {
00249         return header == rhs.header && footer == rhs.footer &&
00250                QABS(ptHeaderBodySpacing - rhs.ptHeaderBodySpacing) <= 1E-10 &&
00251                QABS(ptFooterBodySpacing - rhs.ptFooterBodySpacing) <= 1E-10 &&
00252                QABS(ptFootNoteBodySpacing - rhs.ptFootNoteBodySpacing) <= 1E-10;
00253     }
00254     bool operator!=( const KoKWHeaderFooter& rhs ) const {
00255         return !( *this == rhs );
00256     }
00257 };
00258 
00259 #endif /* KOPAGELAYOUT_H */
00260 
KDE Home | KDE Accessibility Home | Description of Access Keys