26#include <tqtextcodec.h>
28#include <tqfileinfo.h>
29#include <tqtextstream.h>
30#include <tqvaluevector.h>
32#include <KWEFBaseWorker.h>
33#include <KWEFKWordLeader.h>
38bool WPSixWorker::doOpenFile(
const TQString& filenameOut,
const TQString& )
40 filename = filenameOut;
41 outfile.setName( filename );
42 if( !outfile.open( IO_WriteOnly ) )
45 output.setDevice( &outfile );
46 output.setByteOrder (TQDataStream::LittleEndian);
50bool WPSixWorker::doCloseFile(
void)
53 TQ_UINT32 total_filesize = outfile.at();
59 if( !outfile.open( IO_ReadWrite ) )
61 output.setDevice( &outfile );
67 output << total_filesize;
71 output << document_area_ptr;
77bool WPSixWorker::doOpenDocument(
void)
83 TQ_UINT8 magic[] = { 0xff, 0x57, 0x50, 0x43 };
84 for(
int i=0; i<4; i++ ) output << magic[i];
87 TQ_UINT8 docptr[] = { 0x0E, 0x02, 0x00, 0x00 } ;
88 for(
int i=0; i<4; i++ ) output << docptr[i];
91 TQ_UINT8 product_type = 1;
92 output << product_type;
95 TQ_UINT8 file_type = 10;
99 TQ_UINT16 version = 0x0202;
103 TQ_UINT16 encrypt = 0;
107 TQ_UINT16 index_header_ptr = 0x200;
108 output << index_header_ptr;
111 TQ_UINT32 extheader = 5;
115 TQ_UINT32 filesize = 0;
120 for(
int i=0; i<488; i++ ) output << dummy;
123 TQ_UINT8 index_header[] = { 2, 0, 0, 0, 0, 0, 0, 0, 0, 0,
125 for(
int i=0; i<14; i++ ) output << index_header[i];
128 document_area_ptr = output.device()->at();
133bool WPSixWorker::doCloseDocument(
void)
141static TQCString WPSixEscape(
const TQString& text )
145 for(
unsigned int i=0; i < text.length(); i++ )
147 int c = text[i].unicode();
148 if( c < 32 ) result +=
'.';
149 else if ( c == 32 ) result += 0x80 ;
150 else if ( c < 128 ) result += text[i].latin1();
157bool WPSixWorker::doFullParagraph(
const TQString& paraText,
158 const LayoutData& layout,
const ValueListFormatData& paraFormatDataList)
161 unsigned char wp_align[] = { 0xd3, 5, 12, 0, 0, 1, 0, 0, 2, 12, 0, 0xd3 };
162 if( layout.
alignment ==
"left" ) wp_align[7] = 0;
163 if( layout.
alignment ==
"justify" ) wp_align[7] = 1;
164 if( layout.
alignment ==
"center" ) wp_align[7] = 2;
165 if( layout.
alignment ==
"right" ) wp_align[7] = 3;
166 output.writeRawBytes( (
const char*)wp_align, 12 );
168 ValueListFormatData::ConstIterator it;
169 for( it = paraFormatDataList.begin(); it!=paraFormatDataList.end(); ++it )
171 const FormatData& formatData = *it;
174 if( formatData.id == 1 )
178 if( formatData.text.weight >= 75 ) attr = 12;
179 if( formatData.text.italic ) attr = 8;
180 if( formatData.text.underline )
182 if( formatData.text.underlineValue ==
"double" )
187 if( formatData.text.verticalAlignment == 1 ) attr = 6;
188 if( formatData.text.verticalAlignment == 2 ) attr = 5;
189 if( formatData.text.strikeout ) attr = 13;
191 TQColor fgColor = formatData.text.fgColor;
192 TQColor bgColor = formatData.text.bgColor;
198 if( attr > 0 ) output << (TQ_UINT8)0xf2 << attr << (TQ_UINT8)0xf2;
201 if( fgColor.isValid() )
203 TQ_UINT8 wp_color[] = { 0xd4, 0x18, 16, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0xd4 };
204 wp_color[7] = (TQ_UINT8) fgColor.red();
205 wp_color[8] = (TQ_UINT8) fgColor.green();
206 wp_color[9] = (TQ_UINT8) fgColor.blue();
207 output.writeRawBytes( (
const char*)wp_color, 16 );
211 if( bgColor.isValid() )
213 output << (TQ_UINT8) 0xfb;
214 output << (TQ_UINT8)bgColor.red() << (TQ_UINT8)bgColor.green() << (TQ_UINT8)bgColor.blue();
215 output << (TQ_UINT8) 100 << (TQ_UINT8) 0xfb;
219 TQCString out = WPSixEscape( paraText.mid( formatData.pos, formatData.len ) );
220 output.writeRawBytes( (
const char*)out, out.length() );
223 if( attr > 0 ) output << (TQ_UINT8)0xf3 << attr << (TQ_UINT8)0xf3;
226 if( bgColor.isValid() )
228 output << (TQ_UINT8) 0xfc;
229 output << (TQ_UINT8)bgColor.red() << (TQ_UINT8)bgColor.green() << (TQ_UINT8)bgColor.blue();
230 output << (TQ_UINT8) 100 << (TQ_UINT8) 0xfc;
237 output << (TQ_UINT8) 0xcc;
TQString alignment
left, right, center, justify