21#include <tqiodevice.h>
24#include <tdetempfile.h>
26#include "kword13utils.h"
27#include "kword13layout.h"
28#include "kword13picture.h"
29#include "kword13document.h"
31KWord13Document::KWord13Document(
void ) : m_previewFile( 0 )
33 m_normalTextFramesetList.setAutoDelete(
true );
34 m_tableFramesetList.setAutoDelete(
true );
35 m_otherFramesetList.setAutoDelete(
true );
36 m_headerFooterFramesetList.setAutoDelete(
true );
37 m_footEndNoteFramesetList.setAutoDelete(
true );
38 m_pictureFramesetList.setAutoDelete(
true );
39 m_pictureDict.setAutoDelete(
true );
42KWord13Document::~KWord13Document(
void )
47void KWord13Document::xmldump( TQIODevice* io )
49 TQTextStream iostream( io );
50 iostream.setEncoding( TQTextStream::UnicodeUTF8 );
52 iostream <<
"<?xml encoding='UTF-8'?>\n";
53 iostream <<
"<kworddocument>\n";
55 for ( TQMap<TQString,TQString>::ConstIterator it = m_documentProperties.begin();
56 it != m_documentProperties.end();
59 iostream <<
" <param key=\"" << it.key() <<
"\" data=\"" << EscapeXmlDump( it.data() ) <<
"\"/>\n";
62 iostream <<
" <documentinfo>\n";
63 for ( TQMap<TQString,TQString>::ConstIterator it11 = m_documentInfo.begin();
64 it11 != m_documentInfo.end();
67 iostream <<
" <param key=\"" << it11.key() <<
"\" data=\"" << EscapeXmlDump( it11.data() ) <<
"\"/>\n";
69 iostream <<
" </documentinfo>\n";
71 iostream <<
" <normalframesets>\n";
72 for ( KWordTextFrameset* item = m_normalTextFramesetList.first();
74 item = m_normalTextFramesetList.next() )
76 item->xmldump( iostream );
78 iostream <<
" </normalframesets>\n";
80 iostream <<
" <tableframesets>\n";
81 for ( KWordTextFrameset* item12 = m_tableFramesetList.first();
83 item12 = m_tableFramesetList.next() )
85 item12->xmldump( iostream );
87 iostream <<
" </tableframesets>\n";
89 iostream <<
" <headerfooterframesets>\n";
90 for ( KWordTextFrameset* item2 = m_headerFooterFramesetList.first();
92 item2 = m_headerFooterFramesetList.next() )
94 item2->xmldump( iostream );
96 iostream <<
" </headerfooterframesets>\n";
98 iostream <<
" <footendnoteframesets>\n";
99 for ( KWordTextFrameset* item3 = m_footEndNoteFramesetList.first();
101 item3 = m_footEndNoteFramesetList.next() )
103 item3->xmldump( iostream );
105 iostream <<
" </footendnoteframesets>\n";
107 iostream <<
" <otherframesets>\n";
108 for ( KWord13Frameset* item4 = m_otherFramesetList.first();
110 item4 = m_otherFramesetList.next() )
112 item4->xmldump( iostream );
114 iostream <<
" </otherframesets>\n";
116 iostream <<
" <pictureframesets>\n";
117 for ( KWord13Frameset* item5 = m_pictureFramesetList.first();
119 item5 = m_pictureFramesetList.next() )
121 item5->xmldump( iostream );
123 iostream <<
" </pictureframesets>\n";
125 iostream <<
" <styles>\n";
127 for ( TQValueList<KWord13Layout>::Iterator it2 = m_styles.begin();
128 it2 != m_styles.end();
131 (*it2).xmldump( iostream );
134 iostream <<
" </styles>\n";
136 iostream <<
" <pictures>\n";
138 for ( TQDictIterator<KWord13Picture> it3( m_pictureDict ) ; it3.current(); ++it3 )
140 iostream <<
" <key>" << it3.currentKey() <<
"</key>" << endl;
143 iostream <<
" </pictures>\n";
145 iostream <<
"</kworddocument>\n";
148TQString KWord13Document::getDocumentInfo(
const TQString& name )
const
150 TQMap<TQString,TQString>::ConstIterator it ( m_documentInfo.find( name ) );
151 if ( it == m_documentInfo.end() )
162TQString KWord13Document::getProperty(
const TQString& name,
const TQString& oldName )
const
164 const TQString result ( getPropertyInternal( name ) );
166 if ( result.isEmpty() && !oldName.isEmpty() )
169 return getPropertyInternal( oldName );
177TQString KWord13Document::getPropertyInternal(
const TQString& name )
const
179 TQMap<TQString,TQString>::ConstIterator it ( m_documentProperties.find( name ) );
180 if ( it == m_documentProperties.end() )
191TQDateTime KWord13Document::lastPrintingDate(
void )
const
193 const TQString strDate( getPropertyInternal(
"VARIABLESETTINGS:lastPrintingDate" ) );
197 if ( strDate.isEmpty() )
200 kdDebug(30520) <<
"No syntax 3 printing date!" << endl;
204 dt = TQDateTime::fromString( strDate, TQt::ISODate );
209TQDateTime KWord13Document::creationDate(
void )
const
211 const TQString strDate( getPropertyInternal(
"VARIABLESETTINGS:creationDate" ) );
215 if ( strDate.isEmpty() )
217 kdDebug(30520) <<
"No syntax 3 creation date!" << endl;
218 const int year = getPropertyInternal(
"VARIABLESETTINGS:createFileYear" ).toInt();
219 const int month = getPropertyInternal(
"VARIABLESETTINGS:createFileMonth" ).toInt();
220 const int day = getPropertyInternal(
"VARIABLESETTINGS:createFileDay" ).toInt();
222 if ( TQDate::isValid( year, month, day) )
224 dt.setDate( TQDate ( year, month, day) );
228 kdDebug(30520) <<
"No syntax 2 creation date!" << endl;
233 dt = TQDateTime::fromString( strDate, TQt::ISODate );
238TQDateTime KWord13Document::modificationDate(
void )
const
240 const TQString strDate( getPropertyInternal(
"VARIABLESETTINGS:modificationDate" ) );
244 if ( strDate.isEmpty() )
246 kdDebug(30520) <<
"No syntax 3 modification date!" << endl;
247 const int year = getPropertyInternal(
"VARIABLESETTINGS:modifyFileYear" ).toInt();
248 const int month = getPropertyInternal(
"VARIABLESETTINGS:modifyFileMonth" ).toInt();
249 const int day = getPropertyInternal(
"VARIABLESETTINGS:modifyFileDay" ).toInt();
250 if ( TQDate::isValid( year, month, day) )
252 dt.setDate( TQDate ( year, month, day) );
256 kdDebug(30520) <<
"No syntax 2 modification date!" << endl;
261 dt = TQDateTime::fromString( strDate, TQt::ISODate );