26#include <tqtextcodec.h>
28#include <tqfileinfo.h>
29#include <tqtextstream.h>
32#include <KoFilterChain.h>
33#include <kgenericfactory.h>
35#include <KWEFStructures.h>
36#include <KWEFBaseWorker.h>
37#include <KWEFKWordLeader.h>
40#include <amiproexport.h>
42typedef KGenericFactory<AmiProExport, KoFilter> AmiProExportFactory;
43K_EXPORT_COMPONENT_FACTORY( libamiproexport, AmiProExportFactory(
"kofficefilters" ) )
47 AmiProWorker(
void) { }
48 virtual ~AmiProWorker(
void) { }
49 virtual bool doOpenFile(
const TQString& filenameOut,
const TQString& to);
50 virtual bool doCloseFile(
void);
51 virtual bool doOpenDocument(
void);
52 virtual bool doCloseDocument(
void);
53 virtual bool doFullParagraph(
const TQString& paraText,
const LayoutData& layout,
54 const ValueListFormatData& paraFormatDataList);
58 bool m_bold, m_italic, m_underline, m_underlineDouble;
59 bool m_strike, m_subscript, m_superscript;
62bool AmiProWorker::doOpenFile(
const TQString& filenameOut,
const TQString& )
64 filename = filenameOut;
69bool AmiProWorker::doCloseFile(
void)
71 TQFile out( filename );
72 if( !out.open( IO_WriteOnly ) )
75 stream.setDevice( &out );
80bool AmiProWorker::doOpenDocument(
void)
82 result =
"[ver]\n\t4\n";
83 result +=
"[sty]\n\t\n";
85 result +=
"\tStandard\n";
87 result +=
"\t[rght]\n";
90 int magic[] = { 16833, 11908, 1, 1440, 1440, 1, 1440, 1440,
91 0, 1, 0, 1, 0, 2, 1, 1440, 10465, 12, 1, 720, 1, 1440,
92 1, 2160, 1, 2880, 1, 3600, 1, 4320, 1, 5040, 1, 5760,
93 1, 6480, 1, 7200, 1, 7920, 1, 8640 };
94 for( uint i=0; i<
sizeof(magic)/
sizeof(magic[0]); i++ )
95 result +=
"\t\t" + TQString::number(magic[i]) +
"\n";
100 m_bold = m_italic = m_underline = m_underlineDouble =
101 m_strike = m_subscript = m_superscript =
false;
106bool AmiProWorker::doCloseDocument(
void)
112static TQString AmiProEscape(
const TQString& text )
116 for(
unsigned i=0; i<text.length(); i++ )
119 switch( ch.unicode() )
121 case '<': result +=
"<<";
break;
122 case '>': result +=
"<;>";
break;
123 case '[': result +=
"<[>";
break;
124 case '@': result +=
"@@";
break;
125 case '\'': result +=
"</R>";
break;
126 default: result += ch;
break;
133bool AmiProWorker::doFullParagraph(
const TQString& paraText,
134 const LayoutData& ,
const ValueListFormatData& paraFormatDataList)
136 TQString amiproText =
"";
137 TQString text = paraText;
139 ValueListFormatData::ConstIterator it;
140 for( it = paraFormatDataList.begin(); it!=paraFormatDataList.end(); ++it )
142 const FormatData& formatData = *it;
145 if( formatData.id == 1 )
147 TQString partialText;
148 partialText = text.mid( formatData.pos, formatData.len );
150 partialText = AmiProEscape( partialText );
153 m_bold = formatData.text.weight >= 75;
154 m_italic = formatData.text.italic;
157 m_subscript = formatData.text.verticalAlignment == 1;
158 m_superscript = formatData.text.verticalAlignment == 2;
161 if( m_bold ) partialText =
"<+!>" + partialText +
"<-!>";
162 if( m_italic ) partialText =
"<+\">" + partialText +
"<-\">";
163 if( m_underline && !m_underlineDouble ) partialText =
"<+#>" + partialText +
"<-#>";
164 if( m_underlineDouble ) partialText =
"<+)>" + partialText +
"<-)>";
165 if( m_subscript ) partialText =
"<+'>" + partialText +
"<-'>";
166 if( m_superscript ) partialText =
"<+&>" + partialText +
"<-&>";
167 if( m_strike) partialText =
"<+%>" + partialText +
"<-%>";
169 amiproText += partialText;
173 result += amiproText +
"\n\n";
178AmiProExport::AmiProExport( KoFilter *,
const char *,
const TQStringList& ):
183KoFilter::ConversionStatus
184AmiProExport::convert(
const TQCString& from,
185 const TQCString& to )
188 if( to!=
"application/x-amipro" || from !=
"application/x-kword" )
189 return KoFilter::NotImplemented;
191 AmiProWorker* worker =
new AmiProWorker();
192 KWEFKWordLeader* leader =
new KWEFKWordLeader( worker );
194 KoFilter::ConversionStatus result;
195 result = leader->convert( m_chain, from, to );
203#include "amiproexport.moc"
Base worker of the libexport system.
bool underline
Any underline? (If true, we do not know if simple or double or what else).
bool strikeout
true if strikeout
TQString underlineValue
"value" of the underline: single, double, bold-single...