filters
conversion.h
00001 /* This file is part of the KOffice project 00002 Copyright (C) 2002 Werner Trobin <trobin@kde.org> 00003 Copyright (C) 2002 David Faure <faure@kde.org> 00004 00005 This program is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU General Public 00007 License version 2 as published by the Free Software Foundation. 00008 00009 This program 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 General Public License for more details. 00013 00014 You should have received a copy of the GNU General Public License 00015 along with this program; see the file COPYING. 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 CONVERSION_H 00021 #define CONVERSION_H 00022 00023 #include <wv2/ustring.h> 00024 #include <qstring.h> 00025 #include <qcolor.h> 00026 00027 class QDomElement; 00028 namespace wvWare { 00029 namespace Word97 { 00030 class LSPD; 00031 class BRC; 00032 } 00033 class FLD; 00034 } 00035 00036 // Static methods for simple MSWord->KWord conversions 00037 // (enums etc.) 00038 00039 namespace Conversion 00040 { 00041 // UString -> QConstString conversion. Use .string() to get the QString. 00042 // Always store the QConstString into a variable first, to avoid a deep copy. 00043 inline QConstString string( const wvWare::UString& str ) { 00044 // Let's hope there's no copying of the QConstString happening... 00045 return QConstString( reinterpret_cast<const QChar*>( str.data() ), str.length() ); 00046 } 00047 00048 // Prepare text for inclusion in XML 00049 void encodeText(QString &text); 00050 00051 // Convert color code (ico) to QColor 00052 QColor color(int number, int defaultcolor, bool defaultWhite = false); 00053 00054 // Convert pattern style (ipat) to QBrush::BrushStyle 00055 int fillPatternStyle( int ipat ); 00056 00057 // Hackery for gray levels 00058 int ditheringToGray( int ipat, bool* ok ); 00059 00060 // Convert alignment code to string 00061 QString alignment( int jc ); 00062 00063 // Convert linespacing struct to string 00064 QString lineSpacing( const wvWare::Word97::LSPD& lspd ); 00065 00066 // Convert number format code to KWord's COUNTER.type code 00067 int numberFormatCode( int nfc ); 00068 00069 // Set the 3 color attributes in the XML element, from a color code (ico) 00070 // prefix: if empty, the attribute names will be red/blue/green 00071 // if not empty, they will be xRed/xBlue/xGreen 00072 void setColorAttributes( QDomElement& element, int ico, const QString& prefix = QString::null, bool defaultWhite = false ); 00073 00074 // Set all border attributes in the XML element, from a BRC structure 00075 // prefix: if empty, the attribute names will be red/blue/green/width/style 00076 // if not empty, they will be xRed/xBlue/xGreen/xWidth/xStyle 00077 void setBorderAttributes( QDomElement& borderElement, const wvWare::Word97::BRC& brc, const QString& prefix = QString::null ); 00078 00079 // Convert wv2's Header Type to a KWord frameInfo value 00080 int headerTypeToFrameInfo( unsigned char type ); 00081 00082 // Convert wv2's Header Type to a KWord frameset name 00083 QString headerTypeToFramesetName( unsigned char type ); 00084 00085 // Convert a mask of Header Types to the hType value for KWord 00086 int headerMaskToHType( unsigned char mask ); 00087 00088 // Convert a mask of Header Types to the fType value for KWord 00089 int headerMaskToFType( unsigned char mask ); 00090 00091 // Convert wv2's FLD to KWord FIELD.subtype (or -1 if can't be handled) 00092 int fldToFieldType( const wvWare::FLD* fld ); 00093 00094 bool isHeader( unsigned char type ); 00095 } 00096 00097 #endif