Back to index

scribus-ng  1.3.4.dfsg+svn20071115
Public Member Functions | Private Member Functions | Private Attributes
DocIm Class Reference

#include <docim.h>

List of all members.

Public Member Functions

 DocIm (const QString &fname, const QString &enc, bool textOnly, gtWriter *w)
 ~DocIm ()
void write ()
bool isRunning ()

Private Member Functions

void toUnicode ()

Private Attributes

QString filename
QString encoding
QString text
QString error
gtWriter * writer
QProcess * proc
bool failed
bool textOnly

Detailed Description

Definition at line 28 of file docim.h.


Constructor & Destructor Documentation

DocIm::DocIm ( const QString &  fname,
const QString &  enc,
bool  textOnly,
gtWriter *  w 
)

Definition at line 86 of file docim.cpp.

                                                                              : QObject()
{
       filename = fname;
       encoding = enc;
       writer = w;
       textOnly = textO;
       failed = false;
       QTextCodec *codec;
       if (encoding.isEmpty())
              codec = QTextCodec::codecForLocale();
       else
              codec = QTextCodec::codecForName(encoding);
       QTextCodec::setCodecForCStrings(codec);
       text = "";
       error = "";
       proc = new QProcess();
#if defined(_WIN32)
       proc->addArgument( ScPaths::instance().libDir() + "tools/antiword/antiword.exe" );
       proc->setWorkingDirectory( ScPaths::instance().libDir() + "tools/antiword/" ); 
#else
       proc->addArgument("antiword");
#endif
       proc->addArgument("-t");
       proc->addArgument("-w 0");
       proc->addArgument(filename);
       //connect(proc, SIGNAL(readyReadStdout()), this, SLOT(slotReadOutput()));
       //connect(proc, SIGNAL(readyReadStderr()), this, SLOT(slotReadErr()));
#if defined(_WIN32)
       QStringList envVar;
       QString homeDir =  QDir::convertSeparators(ScPaths::instance().libDir() + "tools");
       envVar.append( QString("HOME=%1").arg(homeDir) );
       if (!proc->start(&envVar))
       {
              failed = true;
              return;
       }      
#else
       if (!proc->start())
       {
              failed = true;
              return;
       }
#endif

       while(proc->isRunning() || proc->canReadLineStdout() || proc->canReadLineStderr())
       {
              if ( proc->canReadLineStdout() )
              {
                     QByteArray bo = proc->readStdout();
                     if (bo.size() > 0)
                            text += QString(bo);
              }
              else if (proc->canReadLineStderr())
              {
                     QByteArray be = proc->readStderr();
                     if (be.size() > 0)
                            error += QString(be);
              }
              else
              {
              #ifndef _WIN32
                     usleep(5000);
              #else
                     Sleep(5);
              #endif
              }
       }

       if (proc->normalExit()) 
       {
              toUnicode();
              write();
       } 
       else
              failed = true;
}

Here is the call graph for this function:

Definition at line 189 of file docim.cpp.

{
       delete proc;
}

Member Function Documentation

Definition at line 163 of file docim.cpp.

{
       return proc->isRunning();
}

Here is the caller graph for this function:

void DocIm::toUnicode ( ) [private]

Definition at line 178 of file docim.cpp.

{
       QTextCodec *codec;
       if (encoding.isEmpty())
              codec = QTextCodec::codecForLocale();
       else
              codec = QTextCodec::codecForName(encoding);
       QString dec = codec->toUnicode( text );
       text = dec;
}

Here is the caller graph for this function:

void DocIm::write ( )

Definition at line 168 of file docim.cpp.

{
       if (!failed)
              writer->append(text);
       else
              QMessageBox::information(0, tr("Importing failed"),
                                       tr("Importing Word document failed \n%1").arg(error),
                                       QMessageBox::Ok);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

QString DocIm::encoding [private]

Definition at line 38 of file docim.h.

QString DocIm::error [private]

Definition at line 40 of file docim.h.

bool DocIm::failed [private]

Definition at line 43 of file docim.h.

QString DocIm::filename [private]

Definition at line 37 of file docim.h.

QProcess* DocIm::proc [private]

Definition at line 42 of file docim.h.

QString DocIm::text [private]

Definition at line 39 of file docim.h.

bool DocIm::textOnly [private]

Definition at line 44 of file docim.h.

gtWriter* DocIm::writer [private]

Definition at line 41 of file docim.h.


The documentation for this class was generated from the following files: