/* This file is part of the KDE project Copyright 2001, 2002, 2003, 2004 Nicolas GOUTTE This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include #include #include #include #include "KWEFStructures.h" #include "KWEFBaseWorker.h" #include "KWEFKWordLeader.h" void KWEFBaseWorker::registerKWordLeader(KWEFKWordLeader* leader) { m_kwordLeader=leader; } // // At first, define all methods that do something real! // bool KWEFBaseWorker::doAbortFile(void) { // Mostly, aborting is the same than closing the file! return doCloseFile(); } bool KWEFBaseWorker::doFullDocument (const TQValueList& paraList) { if (!doOpenTextFrameSet()) return false; if (!doFullAllParagraphs(paraList)) return false; if (!doCloseTextFrameSet()) return false; return true; } bool KWEFBaseWorker::doFullAllParagraphs (const TQValueList& paraList) { TQValueList::ConstIterator it; TQValueList::ConstIterator end(paraList.end()); for (it=paraList.begin();it!=end;++it) { if (!doFullParagraph((*it).text,(*it).tqlayout,(*it).formattingList)) return false; } return true; } bool KWEFBaseWorker::loadSubFile(const TQString& fileName, TQByteArray& array) const // return value: // true if the file is not empty // false if the file is empty or if an error occurred { bool flag=false; if (m_kwordLeader) { flag=m_kwordLeader->loadSubFile(fileName,array); } else { kdWarning(30508) << "Leader is unknown! (KWEFBaseWorker::loadSubFile)" << endl; } return flag; } TQIODevice* KWEFBaseWorker::getSubFileDevice(const TQString& fileName) const { if (!m_kwordLeader) { kdWarning(30508) << "Leader is unknown! (KWEFBaseWorker::getSubFileDevice)" << endl; return NULL; } return m_kwordLeader->getSubFileDevice(fileName); } TQImage KWEFBaseWorker::loadAndConvertToImage(const TQString& strName, const TQString& inExtension) const { TQIODevice* io=getSubFileDevice(strName); if (!io) { // NO message error, as there must be already one return TQImage(); } kdDebug(30508) << "Picture " << strName << " has size: " << io->size() << endl; KoPicture picture; if (!picture.load(io, inExtension)) // we do not care about KoPictureKey { kdWarning(30508) << "Could not read picture: " << strName << " (KWEFBaseWorker::loadAndConvertToImage)" << endl; return TQImage(); } return picture.generateImage(picture.getOriginalSize()); // ### TODO: KoPicture::getOriginalSize is bad for cliparts } bool KWEFBaseWorker::loadAndConvertToImage(const TQString& strName, const TQString& inExtension, const TQString& outExtension, TQByteArray& image) const { TQImage qimage(loadAndConvertToImage(strName,inExtension)); if (qimage.isNull()) { kdWarning(30508) << "Could not load image (KWEFBaseWorker::loadAndConvertToImage)" <&, TQValueList& ) ) // The following are not generated by the leader DO_TRUE_DEFINITION (doOpenTextFrameSet (void)) DO_TRUE_DEFINITION (doCloseTextFrameSet (void))