/trunk/Scribus/scribus/loadsaveplugin.h |
---|
114,6 → 114,9 |
/// Unregister all formats owned by the calling plugin |
void unregisterAll(); |
// Set standard message for dom style errors with line and column |
virtual void setDomParsingError(const QString& msg, int line, int column); |
ScribusDoc* m_Doc; |
ScribusView* m_View; //For 1.2.x loader at the moment |
/trunk/Scribus/scribus/scplugin.h |
---|
196,6 → 196,12 |
*/ |
const QString & lastError() const; |
//! \brief Returns if lastError message is not empty |
bool hasLastError() const; |
//! \brief Clear last error message |
void clearLastError(); |
/*! @brief Update all user-visible text to reflect current UI language |
* |
* Updates the text on all widgets on the plug-in to reflect the new |
/trunk/Scribus/scribus/loadsaveplugin.cpp |
---|
5,8 → 5,8 |
for which a new license (GPL+exception) is in place. |
*/ |
#include "loadsaveplugin.h" |
//#include "loadsaveplugin.moc" |
//Added by qt3to4: |
#include "commonstrings.h" |
#include "scribuscore.h" |
#include <QList> |
QList<FileFormat> LoadSavePlugin::formats; |
88,6 → 88,11 |
return false; |
} |
void LoadSavePlugin::setDomParsingError(const QString& msg, int line, int column) |
{ |
m_lastError = tr("An error occured while parsing file at line %1, column %2 :\n%3").arg(line).arg(column).arg(msg); |
} |
const QString& LoadSavePlugin::lastSavedFile(void) |
{ |
return m_lastSavedFile; |
253,7 → 258,25 |
bool FileFormat::loadFile(const QString & fileName, int flags, int index) const |
{ |
return (plug && load) ? plug->loadFile(fileName, *this, flags, index) : false; |
if (plug && load) |
{ |
plug->clearLastError(); |
bool success = plug->loadFile(fileName, *this, flags, index); |
if (!success && plug->hasLastError()) |
{ |
if (ScCore->usingGUI()) |
{ |
QMessageBox::warning(ScCore->primaryMainWindow(), CommonStrings::trWarning, |
plug->lastError(), CommonStrings::tr_OK); |
} |
else |
{ |
qDebug() << plug->lastError(); |
} |
} |
return success; |
} |
return false; |
} |
bool FileFormat::saveFile(const QString & fileName) const |
282,7 → 305,25 |
bool FileFormat::loadPage(const QString & fileName, int pageNumber, bool Mpage, QString renamedPageName) const |
{ |
return (plug && load) ? plug->loadPage(fileName, pageNumber, Mpage, renamedPageName) : false; |
if (plug && load) |
{ |
plug->clearLastError(); |
bool success = plug->loadPage(fileName, pageNumber, Mpage, renamedPageName); |
if (!success && plug->hasLastError()) |
{ |
if (ScCore->usingGUI()) |
{ |
QMessageBox::warning(ScCore->primaryMainWindow(), CommonStrings::trWarning, |
plug->lastError(), CommonStrings::tr_OK); |
} |
else |
{ |
qDebug() << plug->lastError(); |
} |
} |
return success; |
} |
return false; |
} |
bool FileFormat::readStyles(const QString& fileName, ScribusDoc* doc, StyleSet<ParagraphStyle> &docParagraphStyles) const |
/trunk/Scribus/scribus/scplugin.cpp |
---|
9,8 → 9,8 |
#include "deferredtask.h" |
#include "scribus.h" |
#include "scribusapp.h" |
#include "selection.h" |
#include "ui/prefspanel.h" |
#include "selection.h" |
//=====================================================// |
// ScPlugin // |
38,6 → 38,16 |
return m_lastError; |
} |
bool ScPlugin::hasLastError() const |
{ |
return (!m_lastError.isEmpty()); |
} |
void ScPlugin::clearLastError() |
{ |
m_lastError.clear(); |
} |
const QString ScPlugin::pluginTypeName() const |
{ |
// These tests must be in reverse order of inheritance, |
/trunk/Scribus/scribus/plugins/fileloader/scribus12format/scribus12format.cpp |
---|
230,8 → 230,13 |
if (f.isEmpty()) |
return false; |
// Build the DOM from it |
if (!docu.setContent(f)) |
QString errorMsg; |
int errorLine, errorColumn; |
if (!docu.setContent(f, &errorMsg, &errorLine, &errorColumn)) |
{ |
setDomParsingError(errorMsg, errorLine, errorColumn); |
return false; |
} |
// Get file directory |
QString fileDir = QFileInfo(fileName).absolutePath(); |
// and begin loading the doc |
1193,8 → 1198,13 |
QString f(readSLA(fileName)); |
if (f.isEmpty()) |
return false; |
if(!docu.setContent(f)) |
QString errorMsg; |
int errorLine, errorColumn; |
if (!docu.setContent(f, &errorMsg, &errorLine, &errorColumn)) |
{ |
setDomParsingError(errorMsg, errorLine, errorColumn); |
return false; |
} |
QString fileDir = QFileInfo(fileName).absolutePath(); |
ScColor lf = ScColor(); |
QDomElement elem=docu.documentElement(); |
/trunk/Scribus/scribus/plugins/fileloader/scribus13format/scribus13format.cpp |
---|
199,8 → 199,13 |
QString fileDir = QFileInfo(fileName).absolutePath(); |
/* 2004/10/02 - petr vanek - bug #1092 - missing <PAGE> crash Scribus. The check constraint moved into IsScribus() |
FIXME: I've add test on containig tag PAGE but returning false freezes S. in scribus.cpp need some hack too... */ |
if (!docu.setContent(f)) |
QString errorMsg; |
int errorLine, errorColumn; |
if (!docu.setContent(f, &errorMsg, &errorLine, &errorColumn)) |
{ |
setDomParsingError(errorMsg, errorLine, errorColumn); |
return false; |
} |
m_Doc->PageColors.clear(); |
m_Doc->Layers.clear(); |
int layerToSetActive=0; |
2620,8 → 2625,13 |
QString f(readSLA(fileName)); |
if (f.isEmpty()) |
return false; |
if(!docu.setContent(f)) |
QString errorMsg; |
int errorLine, errorColumn; |
if (!docu.setContent(f, &errorMsg, &errorLine, &errorColumn)) |
{ |
setDomParsingError(errorMsg, errorLine, errorColumn); |
return false; |
} |
QString fileDir = QFileInfo(fileName).absolutePath(); |
ScColor lf = ScColor(); |
QDomElement elem=docu.documentElement(); |
/trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp |
---|
451,7 → 451,10 |
} |
if (reader.hasError()) |
{ |
setDomParsingError(reader.errorString(), reader.lineNumber(), reader.columnNumber()); |
return false; |
} |
QMap<int, ScribusDoc::BookMa>::Iterator it; |
for (it = bookmarks.begin(); it != bookmarks.end(); ++it) |
3186,7 → 3189,10 |
} |
if (reader.hasError()) |
{ |
setDomParsingError(reader.errorString(), reader.lineNumber(), reader.columnNumber()); |
return false; |
} |
QMap<int, ScribusDoc::BookMa>::Iterator it; |
for (it = bookmarks.begin(); it != bookmarks.end(); ++it) |
/trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp |
---|
442,7 → 442,10 |
} |
if (reader.hasError()) |
{ |
setDomParsingError(reader.errorString(), reader.lineNumber(), reader.columnNumber()); |
return false; |
} |
QMap<int, ScribusDoc::BookMa>::Iterator it; |
for (it = bookmarks.begin(); it != bookmarks.end(); ++it) |
3150,7 → 3153,10 |
} |
if (reader.hasError()) |
{ |
setDomParsingError(reader.errorString(), reader.lineNumber(), reader.columnNumber()); |
return false; |
} |
QMap<int, ScribusDoc::BookMa>::Iterator it; |
for (it = bookmarks.begin(); it != bookmarks.end(); ++it) |