filters

conversion.cc

00001 #include "conversion.h"
00002 #include <kdebug.h>
00003 #include <klocale.h>
00004 
00005 QString Conversion::importAlignment( const QString& align )
00006 {
00007     if ( align == "center" || align == "justify" )
00008         return align;
00009     if ( align == "start" )
00010         return "left";
00011     if ( align == "end" )
00012         return "right";
00013     kdWarning(30518) << "Conversion::importAlignment unknown alignment " << align << endl;
00014     return "auto";
00015 }
00016 
00017 QString Conversion::exportAlignment( const QString& align )
00018 {
00019     if ( align == "center" || align == "justify" )
00020         return align;
00021     if ( align == "left" || align == "auto" ) // auto handled by text-auto-align
00022         return "start";
00023     if ( align == "right" )
00024         return "end";
00025     kdWarning(30518) << "Conversion::exportAlignment unknown alignment " << align << endl;
00026     return "auto";
00027 }
00028 
00029 QPair<int,QString> Conversion::importWrapping( const QString& oowrap )
00030 {
00031     if ( oowrap == "none" )
00032         // 'no wrap' means 'avoid horizontal space'
00033         return qMakePair( 2, QString::null );
00034     if ( oowrap == "left" || oowrap == "right" )
00035         // Left and right, no problem
00036         return qMakePair( 1, oowrap );
00037     if ( oowrap == "run-through" )
00038         return qMakePair( 0, QString::null );
00039     if ( oowrap == "biggest" ) // OASIS extension
00040         return qMakePair( 1, QString::fromLatin1( "biggest" ) );
00041 
00043     // dynamic is called "optimal" in the OO GUI. It's different from biggest because it can lead to parallel.
00044 
00045     // Those are not supported in KWord, let's use biggest instead
00046     return qMakePair( 1, QString::fromLatin1( "biggest" ) );
00047 }
00048 
00049 QString Conversion::exportWrapping( const QPair<int,QString>& runAroundAttribs )
00050 {
00051     switch( runAroundAttribs.first ) {
00052     case 0:
00053         return "run-through";
00054     case 1: // left, right, or biggest -> ok
00055         return runAroundAttribs.second;
00056     case 2:
00057         return "none";
00058     default:
00059         return "ERROR"; // ERROR
00060     }
00061 }
00062 
00063 int Conversion::importOverflowBehavior( const QString& oasisOverflowBehavior )
00064 {
00065     if ( oasisOverflowBehavior == "auto-extend-frame" )
00066         return 0; // AutoExtendFrame
00067     if ( oasisOverflowBehavior == "auto-create-new-frame" )
00068         return 1; // AutoCreateNewFrame
00069     if ( oasisOverflowBehavior == "ignore" )
00070         return 2; // Ignore extra text
00071     kdWarning(30518) << "Invalid overflow behavior " << oasisOverflowBehavior << endl;
00072     return 0;
00073 }
00074 
00075 QString Conversion::exportOverflowBehavior( const QString& kwordAutoCreateNewFrame )
00076 {
00077     switch ( kwordAutoCreateNewFrame.toInt() ) {
00078     case 1:
00079         return "auto-create-new-frame";
00080     case 2:
00081         return "ignore";
00082     default:
00083     case 0:
00084         return "auto-extend-frame";
00085     }
00086 }
00087 
00088 int Conversion::importCounterType( const QString& numFormat )
00089 {
00090     if ( numFormat == "1" )
00091         return 1;
00092     if ( numFormat == "a" )
00093         return 2;
00094     if ( numFormat == "A" )
00095         return 3;
00096     if ( numFormat == "i" )
00097         return 4;
00098     if ( numFormat == "I" )
00099         return 5;
00100     return 0;
00101 }
00102 
00103 QString Conversion::headerTypeToFramesetName( const QString& localName, bool hasEvenOdd )
00104 {
00105     if ( localName == "header" )
00106         return hasEvenOdd ? i18n("Odd Pages Header") : i18n( "Header" );
00107     if ( localName == "header-left" )
00108         return i18n("Even Pages Header");
00109     if ( localName == "footer" )
00110         return hasEvenOdd ? i18n("Odd Pages Footer") : i18n( "Footer" );
00111     if ( localName == "footer-left" )
00112         return i18n("Even Pages Footer");
00113     kdWarning(30518) << "Unknown tag in headerTypeToFramesetName: " << localName << endl;
00114     // ######
00115     //return i18n("First Page Header");
00116     //return i18n("First Page Footer");
00117     return QString::null;
00118 }
00119 
00120 int Conversion::headerTypeToFrameInfo( const QString& localName, bool /*hasEvenOdd*/ )
00121 {
00122     if ( localName == "header" )
00123         return 3; // odd headers
00124     if ( localName == "header-left" )
00125         return 2; // even headers
00126     if ( localName == "footer" )
00127         return 6; // odd footers
00128     if ( localName == "footer-left" )
00129         return 5; // even footers
00130 
00131     // ### return 1; // first header
00132     // ### return 4; // first footer
00133     return 0;
00134 }
KDE Home | KDE Accessibility Home | Description of Access Keys