Subversion Repositories Scribus

Compare Revisions

Ignore whitespace Rev 2110 → Rev 2111

/branches/Version13x/Scribus/scribus/documentchecker.cpp
0,0 → 1,156
/***************************************************************************
begin : 2005
copyright : (C) 2005 by Franz Schmid
email : Franz.Schmid@altmuehlnet.de
copyright : (C) 2005 by Craig Bradney
email : cbradney@zip.com.au
***************************************************************************/
 
/***************************************************************************
* *
* ScApp program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
 
#include "documentchecker.h"
#include "pageitem.h"
#include "scribusstructs.h"
#include "scribusdoc.h"
 
void DocumentChecker::checkDocument(ScribusDoc *currDoc)
{
PageItem* currItem;
QString chx;
struct checkerPrefs checkerSettings;
checkerSettings.ignoreErrors = currDoc->checkerProfiles[currDoc->curCheckProfile].ignoreErrors;
checkerSettings.autoCheck = currDoc->checkerProfiles[currDoc->curCheckProfile].autoCheck;
checkerSettings.checkGlyphs = currDoc->checkerProfiles[currDoc->curCheckProfile].checkGlyphs;
checkerSettings.checkOrphans = currDoc->checkerProfiles[currDoc->curCheckProfile].checkOrphans;
checkerSettings.checkOverflow = currDoc->checkerProfiles[currDoc->curCheckProfile].checkOverflow;
checkerSettings.checkPictures = currDoc->checkerProfiles[currDoc->curCheckProfile].checkPictures;
checkerSettings.checkResolution = currDoc->checkerProfiles[currDoc->curCheckProfile].checkResolution;
checkerSettings.checkTransparency = currDoc->checkerProfiles[currDoc->curCheckProfile].checkTransparency;
checkerSettings.minResolution = currDoc->checkerProfiles[currDoc->curCheckProfile].minResolution;
checkerSettings.checkAnnotations = currDoc->checkerProfiles[currDoc->curCheckProfile].checkAnnotations;
checkerSettings.checkRasterPDF = currDoc->checkerProfiles[currDoc->curCheckProfile].checkRasterPDF;
currDoc->docItemErrors.clear();
currDoc->masterItemErrors.clear();
errorCodes itemError;
for (uint d = 0; d < currDoc->MasterItems.count(); ++d)
{
currItem = currDoc->MasterItems.at(d);
itemError.clear();
if (((currItem->isAnnotation) || (currItem->isBookmark)) && (checkerSettings.checkAnnotations))
itemError.insert(7, 0);
if (((currItem->fillTransparency() != 0.0) || (currItem->lineTransparency() != 0.0)) && (checkerSettings.checkTransparency))
itemError.insert(6, 0);
if ((currItem->OwnPage == -1) && (checkerSettings.checkOrphans))
itemError.insert(3, 0);
if (currItem->itemType() == PageItem::ImageFrame)
{
if ((!currItem->PicAvail) && (checkerSettings.checkPictures))
itemError.insert(4, 0);
else
{
if (((qRound(72.0 / currItem->LocalScX) < checkerSettings.minResolution) || (qRound(72.0 / currItem->LocalScY) < checkerSettings.minResolution))
&& (currItem->isRaster) && (checkerSettings.checkResolution))
itemError.insert(5, 0);
QFileInfo fi = QFileInfo(currItem->Pfile);
QString ext = fi.extension(false).lower();
if ((ext == "pdf") && (checkerSettings.checkRasterPDF))
itemError.insert(8, 0);
}
}
if ((currItem->itemType() == PageItem::TextFrame) || (currItem->itemType() == PageItem::PathText))
{
if ((currItem->itemText.count() > currItem->MaxChars) && (checkerSettings.checkOverflow))
itemError.insert(2, 0);
for (uint e = 0; e < currItem->itemText.count(); ++e)
{
uint chr = currItem->itemText.at(e)->ch[0].unicode();
if ((chr == 13) || (chr == 32) || (chr == 29) || (chr == 9))
continue;
if (currItem->itemText.at(e)->cstyle & 64)
{
chx = currItem->itemText.at(e)->ch;
if (chx.upper() != currItem->itemText.at(e)->ch)
chx = chx.upper();
chr = chx[0].unicode();
}
if (chr == 30)
{
for (uint numco = 0x30; numco < 0x3A; ++numco)
{
if ((!currItem->itemText.at(e)->cfont->CharWidth.contains(numco)) && (checkerSettings.checkGlyphs))
itemError.insert(1, 0);
}
continue;
}
if ((!currItem->itemText.at(e)->cfont->CharWidth.contains(chr)) && (checkerSettings.checkGlyphs))
itemError.insert(1, 0);
}
}
if (itemError.count() != 0)
currDoc->masterItemErrors.insert(currItem->ItemNr, itemError);
}
for (uint d = 0; d < currDoc->DocItems.count(); ++d)
{
currItem = currDoc->DocItems.at(d);
itemError.clear();
if (((currItem->fillTransparency() != 0.0) || (currItem->lineTransparency() != 0.0)) && (checkerSettings.checkTransparency))
itemError.insert(6, 0);
if (((currItem->isAnnotation) || (currItem->isBookmark)) && (checkerSettings.checkAnnotations))
itemError.insert(7, 0);
if ((currItem->OwnPage == -1) && (checkerSettings.checkOrphans))
itemError.insert(3, 0);
if (currItem->itemType() == PageItem::ImageFrame)
{
if ((!currItem->PicAvail) && (checkerSettings.checkPictures))
itemError.insert(4, 0);
else
{
if (((qRound(72.0 / currItem->LocalScX) < checkerSettings.minResolution) || (qRound(72.0 / currItem->LocalScY) < checkerSettings.minResolution))
&& (currItem->isRaster) && (checkerSettings.checkResolution))
itemError.insert(5, 0);
QFileInfo fi = QFileInfo(currItem->Pfile);
QString ext = fi.extension(false).lower();
if ((ext == "pdf") && (checkerSettings.checkRasterPDF))
itemError.insert(8, 0);
}
}
if ((currItem->itemType() == PageItem::TextFrame) || (currItem->itemType() == PageItem::PathText))
{
if ((currItem->itemText.count() > currItem->MaxChars) && (checkerSettings.checkOverflow))
itemError.insert(2, 0);
for (uint e = 0; e < currItem->itemText.count(); ++e)
{
uint chr = currItem->itemText.at(e)->ch[0].unicode();
if ((chr == 13) || (chr == 32) || (chr == 29) || (chr == 9))
continue;
if (currItem->itemText.at(e)->cstyle & 64)
{
chx = currItem->itemText.at(e)->ch;
if (chx.upper() != currItem->itemText.at(e)->ch)
chx = chx.upper();
chr = chx[0].unicode();
}
if (chr == 30)
{
for (uint numco = 0x30; numco < 0x3A; ++numco)
{
if ((!currItem->itemText.at(e)->cfont->CharWidth.contains(numco)) && (checkerSettings.checkGlyphs))
itemError.insert(1, 0);
}
continue;
}
if ((!currItem->itemText.at(e)->cfont->CharWidth.contains(chr)) && (checkerSettings.checkGlyphs))
itemError.insert(1, 0);
}
}
if (itemError.count() != 0)
currDoc->docItemErrors.insert(currItem->ItemNr, itemError);
}
}
Property changes:
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Index: branches/Version13x/Scribus/scribus/checkDocument.cpp
===================================================================
--- branches/Version13x/Scribus/scribus/checkDocument.cpp (revision 2110)
+++ branches/Version13x/Scribus/scribus/checkDocument.cpp (revision 2111)
@@ -16,6 +16,7 @@
#include "scribus.h"
#include "scribusdoc.h"
#include "page.h"
+#include "documentchecker.h"
extern QPixmap loadIcon(QString nam);
extern ScribusApp* ScApp;
@@ -205,7 +206,9 @@
{
clearErrorList();
document->curCheckProfile = name;
- emit rescan();
+ DocumentChecker docChecker;
+ docChecker.checkDocument(document);
+ buildErrorList(document);
}
void CheckDocument::clearErrorList()
/branches/Version13x/Scribus/scribus/Makefile.am
44,6 → 44,7
delpages.cpp\
docinfo.cpp\
docitemattrprefs.ui\
documentchecker.cpp\
documentinformation.cpp\
druck.cpp\
edit1format.cpp\
232,6 → 233,7
$(INSTALL_DATA) $(srcdir)/delpages.h $(prefix)/include/scribus/delpages.h
$(INSTALL_DATA) $(srcdir)/docinfo.h $(prefix)/include/scribus/docinfo.h
$(INSTALL_DATA) $(srcdir)/docitemattrprefs.h $(prefix)/include/scribus/docitemattrprefs.h
$(INSTALL_DATA) $(srcdir)/documentchecker.h $(prefix)/include/scribus/documentchecker.h
$(INSTALL_DATA) $(srcdir)/documentinformation.h $(prefix)/include/scribus/documentinformation.h
$(INSTALL_DATA) $(srcdir)/druck.h $(prefix)/include/scribus/druck.h
$(INSTALL_DATA) $(srcdir)/edit1format.h $(prefix)/include/scribus/edit1format.h
399,6 → 401,7
-rm -f $(prefix)/include/scribus/delpages.h
-rm -f $(prefix)/include/scribus/docinfo.h
-rm -f $(prefix)/include/scribus/docitemattrprefs.h
-rm -f $(prefix)/include/scribus/documentchecker.h
-rm -f $(prefix)/include/scribus/documentinformation.h
-rm -f $(prefix)/include/scribus/druck.h
-rm -f $(prefix)/include/scribus/edit1format.h
/branches/Version13x/Scribus/scribus/scribus.cpp
133,6 → 133,7
#include "actionmanager.h"
#include "documentinformation.h"
#include "effectsdialog.h"
#include "documentchecker.h"
 
//CB TODO include for toc testing for now
#include "gtwriter.h"
802,7 → 803,6
connect(propertiesPalette->Cpal->gradEdit->Preview, SIGNAL(gradientChanged()), this, SLOT(updtGradFill()));
connect(propertiesPalette->Cpal, SIGNAL(gradientChanged()), this, SLOT(updtGradFill()));
connect(propertiesPalette->Cpal, SIGNAL(QueryItem()), this, SLOT(GetBrushPen()));
connect(docCheckerPalette, SIGNAL(rescan()), this, SLOT(slotCheckDoc()));
connect(docCheckerPalette, SIGNAL(selectElement(int, int)), this, SLOT(SelectFromOutl(int, int)));
connect(docCheckerPalette, SIGNAL(selectPage(int)), this, SLOT(SelectFromOutlS(int)));
connect(docCheckerPalette, SIGNAL(selectMasterPage(QString)), this, SLOT(manageMasterPages(QString)));
4832,6 → 4832,7
 
bool ScribusApp::DoFileClose()
{
actionManager->disconnectNewViewActions();
if (doc->viewCount > 1)
{
doc->viewCount--;
9963,145 → 9964,10
}
}
 
void ScribusApp::slotCheckDoc()
{
scanDocument();
docCheckerPalette->buildErrorList(doc);
}
 
void ScribusApp::scanDocument()
{
PageItem* it;
QString chx;
struct checkerPrefs checkerSettings;
checkerSettings.ignoreErrors = doc->checkerProfiles[doc->curCheckProfile].ignoreErrors;
checkerSettings.autoCheck = doc->checkerProfiles[doc->curCheckProfile].autoCheck;
checkerSettings.checkGlyphs = doc->checkerProfiles[doc->curCheckProfile].checkGlyphs;
checkerSettings.checkOrphans = doc->checkerProfiles[doc->curCheckProfile].checkOrphans;
checkerSettings.checkOverflow = doc->checkerProfiles[doc->curCheckProfile].checkOverflow;
checkerSettings.checkPictures = doc->checkerProfiles[doc->curCheckProfile].checkPictures;
checkerSettings.checkResolution = doc->checkerProfiles[doc->curCheckProfile].checkResolution;
checkerSettings.checkTransparency = doc->checkerProfiles[doc->curCheckProfile].checkTransparency;
checkerSettings.minResolution = doc->checkerProfiles[doc->curCheckProfile].minResolution;
checkerSettings.checkAnnotations = doc->checkerProfiles[doc->curCheckProfile].checkAnnotations;
checkerSettings.checkRasterPDF = doc->checkerProfiles[doc->curCheckProfile].checkRasterPDF;
doc->docItemErrors.clear();
doc->masterItemErrors.clear();
errorCodes itemError;
for (uint d = 0; d < doc->MasterItems.count(); ++d)
{
it = doc->MasterItems.at(d);
itemError.clear();
if (((it->isAnnotation) || (it->isBookmark)) && (checkerSettings.checkAnnotations))
itemError.insert(7, 0);
if (((it->fillTransparency() != 0.0) || (it->lineTransparency() != 0.0)) && (checkerSettings.checkTransparency))
itemError.insert(6, 0);
if ((it->OwnPage == -1) && (checkerSettings.checkOrphans))
itemError.insert(3, 0);
if (it->itemType() == PageItem::ImageFrame)
{
if ((!it->PicAvail) && (checkerSettings.checkPictures))
itemError.insert(4, 0);
else
{
if (((qRound(72.0 / it->LocalScX) < checkerSettings.minResolution) || (qRound(72.0 / it->LocalScY) < checkerSettings.minResolution))
&& (it->isRaster) && (checkerSettings.checkResolution))
itemError.insert(5, 0);
QFileInfo fi = QFileInfo(it->Pfile);
QString ext = fi.extension(false).lower();
if ((ext == "pdf") && (checkerSettings.checkRasterPDF))
itemError.insert(8, 0);
}
}
if ((it->itemType() == PageItem::TextFrame) || (it->itemType() == PageItem::PathText))
{
if ((it->itemText.count() > it->MaxChars) && (checkerSettings.checkOverflow))
itemError.insert(2, 0);
for (uint e = 0; e < it->itemText.count(); ++e)
{
uint chr = it->itemText.at(e)->ch[0].unicode();
if ((chr == 13) || (chr == 32) || (chr == 29) || (chr == 9))
continue;
if (it->itemText.at(e)->cstyle & 64)
{
chx = it->itemText.at(e)->ch;
if (chx.upper() != it->itemText.at(e)->ch)
chx = chx.upper();
chr = chx[0].unicode();
}
if (chr == 30)
{
for (uint numco = 0x30; numco < 0x3A; ++numco)
{
if ((!it->itemText.at(e)->cfont->CharWidth.contains(numco)) && (checkerSettings.checkGlyphs))
itemError.insert(1, 0);
}
continue;
}
if ((!it->itemText.at(e)->cfont->CharWidth.contains(chr)) && (checkerSettings.checkGlyphs))
itemError.insert(1, 0);
}
}
if (itemError.count() != 0)
doc->masterItemErrors.insert(it->ItemNr, itemError);
}
for (uint d = 0; d < doc->DocItems.count(); ++d)
{
it = doc->DocItems.at(d);
itemError.clear();
if (((it->fillTransparency() != 0.0) || (it->lineTransparency() != 0.0)) && (checkerSettings.checkTransparency))
itemError.insert(6, 0);
if (((it->isAnnotation) || (it->isBookmark)) && (checkerSettings.checkAnnotations))
itemError.insert(7, 0);
if ((it->OwnPage == -1) && (checkerSettings.checkOrphans))
itemError.insert(3, 0);
if (it->itemType() == PageItem::ImageFrame)
{
if ((!it->PicAvail) && (checkerSettings.checkPictures))
itemError.insert(4, 0);
else
{
if (((qRound(72.0 / it->LocalScX) < checkerSettings.minResolution) || (qRound(72.0 / it->LocalScY) < checkerSettings.minResolution))
&& (it->isRaster) && (checkerSettings.checkResolution))
itemError.insert(5, 0);
QFileInfo fi = QFileInfo(it->Pfile);
QString ext = fi.extension(false).lower();
if ((ext == "pdf") && (checkerSettings.checkRasterPDF))
itemError.insert(8, 0);
}
}
if ((it->itemType() == PageItem::TextFrame) || (it->itemType() == PageItem::PathText))
{
if ((it->itemText.count() > it->MaxChars) && (checkerSettings.checkOverflow))
itemError.insert(2, 0);
for (uint e = 0; e < it->itemText.count(); ++e)
{
uint chr = it->itemText.at(e)->ch[0].unicode();
if ((chr == 13) || (chr == 32) || (chr == 29) || (chr == 9))
continue;
if (it->itemText.at(e)->cstyle & 64)
{
chx = it->itemText.at(e)->ch;
if (chx.upper() != it->itemText.at(e)->ch)
chx = chx.upper();
chr = chx[0].unicode();
}
if (chr == 30)
{
for (uint numco = 0x30; numco < 0x3A; ++numco)
{
if ((!it->itemText.at(e)->cfont->CharWidth.contains(numco)) && (checkerSettings.checkGlyphs))
itemError.insert(1, 0);
}
continue;
}
if ((!it->itemText.at(e)->cfont->CharWidth.contains(chr)) && (checkerSettings.checkGlyphs))
itemError.insert(1, 0);
}
}
if (itemError.count() != 0)
doc->docItemErrors.insert(it->ItemNr, itemError);
}
DocumentChecker docChecker;
docChecker.checkDocument(doc);
}
 
void ScribusApp::HaveRaster(bool art)
/branches/Version13x/Scribus/scribus/scribus.h
452,7 → 452,6
void CallGimp();
void docCheckToggle(bool visible);
void scanDocument();
void slotCheckDoc();
void setUndoMode(bool isObjectSpecific);
void insertSampleText();
 
/branches/Version13x/Scribus/scribus/documentchecker.h
0,0 → 1,29
/***************************************************************************
begin : 2005
copyright : (C) 2005 by Franz Schmid
email : Franz.Schmid@altmuehlnet.de
copyright : (C) 2005 by Craig Bradney
email : cbradney@zip.com.au
***************************************************************************/
 
/***************************************************************************
* *
* ScApp program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
 
#ifndef DOCUMENTCHECKER_H
#define DOCUMENTCHECKER_H
 
class ScribusDoc;
 
class DocumentChecker
{
public:
void checkDocument(ScribusDoc *currDoc);
};
 
#endif
Property changes:
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property