/* This file is part of the KDE project Copyright (C) 1998, 1999 Torben Weis Copyright 2002, 2003 David Faure Copyright 2003 Nicolas GOUTTE Copyright 2005 Jason Kivlighn This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "krepagelayout.h" #include #include #include #include #include #include "kreunit.h" // paper formats ( mm ) #define PG_A3_WIDTH 297.0 #define PG_A3_HEIGHT 420.0 #define PG_A4_WIDTH 210.0 #define PG_A4_HEIGHT 297.0 #define PG_A5_WIDTH 148.0 #define PG_A5_HEIGHT 210.0 #define PG_B5_WIDTH 182.0 #define PG_B5_HEIGHT 257.0 #define PG_US_LETTER_WIDTH 216.0 #define PG_US_LETTER_HEIGHT 279.0 #define PG_US_LEGAL_WIDTH 216.0 #define PG_US_LEGAL_HEIGHT 356.0 #define PG_US_EXECUTIVE_WIDTH 191.0 #define PG_US_EXECUTIVE_HEIGHT 254.0 TQDomElement KoPageLayout::saveKreFormat( TQDomDocument &doc ) const { TQDomElement style = doc.createElement( "page-layout-properties" ); style.setAttribute("page-width", ptWidth); style.setAttribute("page-height", ptHeight); style.setAttribute("margin-left", ptLeft); style.setAttribute("margin-right", ptRight); style.setAttribute("margin-top", ptTop); style.setAttribute("margin-bottom", ptBottom); style.setAttribute("print-orientation", (orientation == PG_LANDSCAPE ? "landscape" : "portrait"));kdDebug()<<"margin-left: "<(i); } return PG_CUSTOM; } TQString KoPageFormat::formatString( KoFormat format ) { if ( format <= PG_LAST_FORMAT ) return TQString::fromLatin1( pageFormatInfo[ format ].shortName ); return TQString::fromLatin1( "A4" ); } KoFormat KoPageFormat::formatFromString( const TQString & string ) { for ( int i = 0 ; i <= PG_LAST_FORMAT ; ++i ) { if (string == TQString::fromLatin1( pageFormatInfo[ i ].shortName )) return pageFormatInfo[ i ].format; } // We do not know the format name, so we have a custom format return PG_CUSTOM; } KoFormat KoPageFormat::defaultFormat() { int kprinter = TDEGlobal::locale()->pageSize(); for ( int i = 0 ; i <= PG_LAST_FORMAT ; ++i ) { if ( pageFormatInfo[ i ].kprinter == kprinter ) return static_cast(i); } return PG_DIN_A4; } TQString KoPageFormat::name( KoFormat format ) { if ( format <= PG_LAST_FORMAT ) return i18n( pageFormatInfo[ format ].descriptiveName ); return i18n( pageFormatInfo[ PG_DIN_A4 ].descriptiveName ); } TQStringList KoPageFormat::allFormats() { TQStringList lst; for ( int i = 0 ; i <= PG_LAST_FORMAT ; ++i ) { lst << i18n( pageFormatInfo[ i ].descriptiveName ); } return lst; }