1
// $Header: /home/kde/koffice/filters/kword/libexport/KWEFBaseWorker.cc,v 1.26 2003/08/16 12:22:48 mueller Exp $
4
This file is part of the KDE project
5
Copyright 2001, 2002, 2003 Nicolas GOUTTE <goutte@kde.org>
7
This library is free software; you can redistribute it and/or
8
modify it under the terms of the GNU Library General Public
9
License as published by the Free Software Foundation; either
10
version 2 of the License, or (at your option) any later version.
12
This library is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
Library General Public License for more details.
17
You should have received a copy of the GNU Library General Public License
18
along with this library; see the file COPYING.LIB. If not, write to
19
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20
Boston, MA 02111-1307, USA.
28
#include <koPicture.h>
30
#include "KWEFStructures.h"
31
#include "KWEFBaseWorker.h"
32
#include "KWEFKWordLeader.h"
34
void KWEFBaseWorker::registerKWordLeader(KWEFKWordLeader* leader)
40
// At first, define all methods that do something real!
43
bool KWEFBaseWorker::doAbortFile(void)
45
// Mostly, aborting is the same than closing the file!
49
bool KWEFBaseWorker::doFullDocument (const QValueList<ParaData>& paraList)
51
if (!doOpenTextFrameSet())
53
if (!doFullAllParagraphs(paraList))
55
if (!doCloseTextFrameSet())
61
bool KWEFBaseWorker::doFullAllParagraphs (const QValueList<ParaData>& paraList)
63
QValueList<ParaData>::ConstIterator it;
64
for (it=paraList.begin();it!=paraList.end();it++)
66
if (!doFullParagraph((*it).text,(*it).layout,(*it).formattingList))
72
bool KWEFBaseWorker::loadSubFile(const QString& fileName, QByteArray& array) const
74
// true if the file is not empty
75
// false if the file is empty or if an error occurred
80
flag=m_kwordLeader->loadSubFile(fileName,array);
84
kdWarning(30508) << "Leader is unknown! (KWEFBaseWorker::loadSubFile)" << endl;
89
QIODevice* KWEFBaseWorker::getSubFileDevice(const QString& fileName) const
93
kdWarning(30508) << "Leader is unknown! (KWEFBaseWorker::getSubFileDevice)" << endl;
96
return m_kwordLeader->getSubFileDevice(fileName);
99
QImage KWEFBaseWorker::loadAndConvertToImage(const QString& strName, const QString& inExtension) const
101
QIODevice* io=getSubFileDevice(strName);
104
// NO message error, as there must be already one
108
kdDebug(30508) << "Picture " << strName << " has size: " << io->size() << endl;
111
if (!picture.load(io, inExtension)) // we do not care about KoPictureKey
113
kdWarning(30508) << "Could not read picture: " << strName << " (KWEFBaseWorker::loadAndConvertToImage)" << endl;
117
return picture.generateImage(picture.getOriginalSize()); // ### TODO: KoPicture::getOriginalSize is bad for cliparts
120
bool KWEFBaseWorker::loadAndConvertToImage(const QString& strName, const QString& inExtension, const QString& outExtension, QByteArray& image) const
122
QImage qimage(loadAndConvertToImage(strName,inExtension));
126
kdWarning(30508) << "Could not load image (KWEFBaseWorker::loadAndConvertToImage)" <<endl;
131
imageIO.setImage(qimage);
133
QBuffer buffer(image); // A QBuffer is a QIODevice
134
if (!buffer.open(IO_WriteOnly))
136
kdWarning(30508) << "Could not open buffer! (KWEFBaseWorker::loadAndConvertToImage)" << endl;
140
imageIO.setIODevice(&buffer);
141
imageIO.setFormat(outExtension.utf8());
143
if (!imageIO.write())
145
kdWarning(30508) << "Could not write converted image! (KWEFBaseWorker::loadAndConvertToImage)" << endl;
155
// Secondly, define all methods returning false
158
#define DO_FALSE_DEFINITION(string) \
159
bool KWEFBaseWorker::string \
161
kdWarning(30508) << "KWEFBaseWorker::" << #string << " was called (Worker not correctly defined?)" << endl; \
165
DO_FALSE_DEFINITION (doOpenFile (const QString& , const QString& ))
166
DO_FALSE_DEFINITION (doCloseFile (void))
167
DO_FALSE_DEFINITION (doOpenDocument (void))
168
DO_FALSE_DEFINITION (doCloseDocument (void))
170
// The following is not generated by the leader
171
DO_FALSE_DEFINITION (doFullParagraph(const QString&, const LayoutData&, const ValueListFormatData&))
174
// Thirdly, define all methods returning true
177
#define DO_TRUE_DEFINITION(string) \
178
bool KWEFBaseWorker::string \
183
DO_TRUE_DEFINITION (doFullDocumentInfo (const KWEFDocumentInfo&))
184
DO_TRUE_DEFINITION (doVariableSettings (const VariableSettingsData &))
185
DO_TRUE_DEFINITION (doFullPaperFormat (const int, const double, const double, const int))
186
DO_TRUE_DEFINITION (doFullPaperBorders (const double, const double, const double, const double))
187
DO_TRUE_DEFINITION (doPageInfo(int,int))
188
DO_TRUE_DEFINITION (doOpenHead (void))
189
DO_TRUE_DEFINITION (doCloseHead (void))
190
DO_TRUE_DEFINITION (doOpenBody (void))
191
DO_TRUE_DEFINITION (doCloseBody (void))
192
DO_TRUE_DEFINITION (doOpenStyles (void))
193
DO_TRUE_DEFINITION (doCloseStyles (void))
194
DO_TRUE_DEFINITION (doFullDefineStyle (LayoutData&))
195
DO_TRUE_DEFINITION (doOpenSpellCheckIgnoreList (void))
196
DO_TRUE_DEFINITION (doCloseSpellCheckIgnoreList (void))
197
DO_TRUE_DEFINITION (doFullSpellCheckIgnoreWord (const QString&))
198
DO_TRUE_DEFINITION (doHeader(const HeaderData&))
199
DO_TRUE_DEFINITION (doFooter(const FooterData&))
201
// The following are not generated by the leader
202
DO_TRUE_DEFINITION (doOpenTextFrameSet (void))
203
DO_TRUE_DEFINITION (doCloseTextFrameSet (void))