Back to index

scribus-ng  1.3.4.dfsg+svn20071115
checkDocument.cpp
Go to the documentation of this file.
00001 /*
00002 For general Scribus (>=1.3.2) copyright and licensing information please refer
00003 to the COPYING file provided with the program. Following this notice may exist
00004 a copyright and/or license notice that predates the release of Scribus 1.3.2
00005 for which a new license (GPL+exception) is in place.
00006 */
00007 #include "checkDocument.h"
00008 #include "checkDocument.moc"
00009 
00010 #include <qvariant.h>
00011 #include <qheader.h>
00012 #include <qlistview.h>
00013 #include <qlayout.h>
00014 #include <qtooltip.h>
00015 #include <qwhatsthis.h>
00016 #include <qimage.h>
00017 #include <qpixmap.h>
00018 #include <qmap.h>
00019 #include <qlabel.h>
00020 
00021 #include "sccombobox.h"
00022 #include "scribuscore.h"
00023 #include "scribusdoc.h"
00024 #include "page.h"
00025 #include "documentchecker.h"
00026 
00027 extern QPixmap loadIcon(QString nam);
00028 
00029 
00030 static const unsigned char image0_data[] =
00031     {
00032         0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
00033         0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x0b,
00034         0x08, 0x06, 0x00, 0x00, 0x00, 0xa9, 0xac, 0x77, 0x26, 0x00, 0x00, 0x00,
00035         0xff, 0x49, 0x44, 0x41, 0x54, 0x78, 0x9c, 0x75, 0x91, 0x31, 0x4e, 0xc3,
00036         0x40, 0x10, 0x45, 0x9f, 0xad, 0x2d, 0xe6, 0x0a, 0xdc, 0xc2, 0x8e, 0x44,
00037         0x91, 0x83, 0x50, 0x51, 0x91, 0x58, 0x29, 0x42, 0xba, 0x80, 0x28, 0x10,
00038         0x55, 0xe4, 0x02, 0x45, 0x74, 0x18, 0x24, 0x64, 0xdc, 0xe5, 0x28, 0x31,
00039         0x92, 0xd1, 0xe2, 0x74, 0x5c, 0x83, 0x72, 0x0a, 0x4b, 0x43, 0xe1, 0x78,
00040         0xb1, 0x22, 0xb1, 0xcd, 0x6a, 0x67, 0xde, 0xfc, 0x9d, 0x99, 0x1f, 0xf9,
00041         0xc6, 0x43, 0x07, 0x38, 0xd0, 0x4e, 0x11, 0x27, 0xff, 0xbe, 0xdd, 0x10,
00042         0xd0, 0x4e, 0x59, 0x2d, 0xdf, 0x8d, 0xd1, 0x29, 0xdf, 0xae, 0xa3, 0x71,
00043         0xde, 0x89, 0x13, 0x8a, 0x57, 0xec, 0xbb, 0xdd, 0x51, 0x1e, 0x2a, 0x00,
00044         0x14, 0x10, 0x20, 0x5b, 0x60, 0xd3, 0xf3, 0x35, 0x97, 0x57, 0x3f, 0x91,
00045         0x38, 0x21, 0xd6, 0x4e, 0x69, 0xdb, 0x82, 0xfa, 0xe2, 0x8c, 0x49, 0xbe,
00046         0x0d, 0xa0, 0x02, 0xe5, 0xa1, 0xe2, 0xe3, 0xf3, 0x29, 0x28, 0xc7, 0x37,
00047         0xcb, 0x9d, 0x95, 0x87, 0x0a, 0x5c, 0x8f, 0xc8, 0xb1, 0x85, 0x71, 0x41,
00048         0xb6, 0x28, 0x4c, 0x9c, 0xe0, 0x14, 0x05, 0xa0, 0xbe, 0xbb, 0x0d, 0xc0,
00049         0xe9, 0x0d, 0xfd, 0xb0, 0x31, 0x48, 0x48, 0x70, 0x02, 0x4e, 0xf2, 0xcd,
00050         0x5f, 0xdc, 0x09, 0xf1, 0xf0, 0x75, 0x50, 0x18, 0x81, 0x83, 0xd0, 0xa0,
00051         0x8c, 0x6f, 0x3c, 0x69, 0x32, 0x33, 0x0f, 0xb6, 0x07, 0xf3, 0x60, 0x96,
00052         0x6f, 0xcc, 0x1e, 0xb7, 0xb6, 0x07, 0x9b, 0x26, 0x4b, 0xf3, 0xb5, 0xc7,
00053         0x37, 0xbe, 0xdf, 0x73, 0x9a, 0xae, 0xc9, 0x8e, 0xc3, 0x28, 0xf0, 0x75,
00054         0xff, 0x80, 0x02, 0xab, 0x64, 0x46, 0x9a, 0xce, 0x83, 0x41, 0x91, 0x6f,
00055         0x7c, 0x70, 0x2a, 0x5b, 0x14, 0x36, 0x74, 0x2d, 0x08, 0xcf, 0x2f, 0xf3,
00056         0x68, 0xec, 0xe4, 0x2f, 0x90, 0x07, 0x8c, 0x36, 0xce, 0xc2, 0x57, 0x47,
00057         0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
00058     };
00059 
00060 static const unsigned char image1_data[] =
00061     {
00062         0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
00063         0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x0b,
00064         0x08, 0x06, 0x00, 0x00, 0x00, 0xa9, 0xac, 0x77, 0x26, 0x00, 0x00, 0x00,
00065         0xfa, 0x49, 0x44, 0x41, 0x54, 0x78, 0x9c, 0x75, 0x91, 0x31, 0x6e, 0x83,
00066         0x40, 0x10, 0x45, 0x1f, 0x68, 0x8b, 0xb9, 0x4a, 0x3a, 0x63, 0xc9, 0x05,
00067         0x25, 0xe7, 0x48, 0x15, 0x8c, 0x28, 0x88, 0x3b, 0xe7, 0x1a, 0xe9, 0x02,
00068         0x91, 0x2c, 0x42, 0xe7, 0x73, 0x50, 0x19, 0x24, 0xac, 0x35, 0xa5, 0xaf,
00069         0x91, 0x72, 0x0b, 0xa4, 0x49, 0x41, 0xb2, 0x46, 0x48, 0x99, 0x66, 0x35,
00070         0x33, 0x7f, 0xdf, 0xd7, 0xee, 0x0f, 0xec, 0x60, 0x61, 0x02, 0x0c, 0xb8,
00071         0xc9, 0x21, 0x46, 0xfe, 0xed, 0xcd, 0xdf, 0xc0, 0x4d, 0x8e, 0x43, 0xf1,
00072         0xa5, 0x2c, 0xaa, 0x3e, 0xbd, 0x06, 0xcb, 0xbd, 0x11, 0x23, 0x94, 0x9f,
00073         0xe8, 0x7d, 0x3c, 0x53, 0x57, 0xcd, 0x2f, 0x11, 0xc4, 0x40, 0x96, 0xa3,
00074         0xf1, 0xee, 0xc8, 0xf3, 0xcb, 0x77, 0x20, 0x46, 0x08, 0xdd, 0xe4, 0x18,
00075         0xc7, 0x92, 0x6e, 0xbc, 0xb3, 0x8d, 0x13, 0x2f, 0x74, 0x13, 0xd4, 0xa7,
00076         0x86, 0xfe, 0xfa, 0xee, 0xc9, 0xe1, 0x5b, 0x71, 0xd6, 0xba, 0x6a, 0xbc,
00077         0xb5, 0x18, 0x60, 0x75, 0x21, 0xcb, 0x4b, 0x15, 0x23, 0x18, 0x87, 0x03,
00078         0x03, 0x5d, 0xdf, 0x7a, 0xc1, 0xfa, 0x84, 0xf9, 0xb1, 0x21, 0x88, 0x5f,
00079         0xb0, 0x12, 0x6e, 0x77, 0xc9, 0x3c, 0x07, 0xc4, 0x08, 0x21, 0xb8, 0x07,
00080         0x61, 0x25, 0x9c, 0x89, 0x0f, 0x32, 0x76, 0xb0, 0x44, 0x9b, 0x54, 0xed,
00081         0x80, 0x5e, 0x3a, 0xd4, 0x0e, 0xa8, 0x6a, 0xa2, 0xaa, 0x89, 0x5e, 0x3a,
00082         0x34, 0xde, 0x14, 0x6a, 0x3b, 0x8b, 0x1d, 0xec, 0xfc, 0x1b, 0x51, 0x74,
00083         0x24, 0xcb, 0x53, 0xef, 0x70, 0xbb, 0xb6, 0x74, 0x7d, 0xcb, 0xa1, 0x48,
00084         0x79, 0x8a, 0xf6, 0x3e, 0xa0, 0xc0, 0x0e, 0xd6, 0x27, 0x95, 0xe5, 0xa5,
00085         0x82, 0x00, 0x0e, 0x41, 0xf8, 0xa8, 0xf6, 0xc1, 0x32, 0xc9, 0x1f, 0x9e,
00086         0x1c, 0x9d, 0xca, 0x9e, 0x4f, 0x38, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x49,
00087         0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
00088     };
00089 
00090 static const unsigned char image2_data[] =
00091     {
00092         0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
00093         0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x0b,
00094         0x08, 0x06, 0x00, 0x00, 0x00, 0xa9, 0xac, 0x77, 0x26, 0x00, 0x00, 0x01,
00095         0x02, 0x49, 0x44, 0x41, 0x54, 0x78, 0x9c, 0x75, 0x91, 0xb1, 0x4a, 0xc4,
00096         0x40, 0x10, 0x86, 0xbf, 0x84, 0x29, 0xc6, 0x37, 0xb8, 0xd6, 0xf2, 0xca,
00097         0x10, 0xae, 0xc8, 0x2b, 0xf8, 0x0a, 0xa9, 0x84, 0xa4, 0x08, 0xd8, 0x1c,
00098         0xa4, 0xb4, 0x13, 0xbb, 0x80, 0x85, 0x4a, 0xe0, 0x12, 0xb8, 0x46, 0x4b,
00099         0x5b, 0x3b, 0xeb, 0xc0, 0x49, 0xd8, 0xd2, 0x57, 0x48, 0x69, 0x21, 0xb8,
00100         0xc5, 0x42, 0x2c, 0x72, 0xc9, 0xad, 0x88, 0xdb, 0x2c, 0x33, 0x3b, 0xf3,
00101         0xfd, 0x3f, 0xfb, 0x07, 0xfd, 0xa1, 0x07, 0x07, 0x08, 0x58, 0x67, 0x51,
00102         0xd1, 0x7f, 0x6b, 0x99, 0x1b, 0xd6, 0x59, 0xae, 0x9b, 0xab, 0x11, 0xef,
00103         0x54, 0x45, 0x1b, 0xf8, 0xef, 0xa2, 0xa2, 0x74, 0xf2, 0x38, 0xbe, 0x36,
00104         0x1f, 0x0c, 0xb9, 0x01, 0x01, 0x1c, 0xa8, 0x40, 0x59, 0x67, 0x63, 0xba,
00105         0x4d, 0x58, 0x7f, 0xa5, 0x81, 0x8a, 0x12, 0x5a, 0x67, 0x79, 0xb9, 0x37,
00106         0x3c, 0xed, 0x2c, 0x7d, 0x12, 0x79, 0x16, 0x60, 0x28, 0x0c, 0xcf, 0x77,
00107         0xdd, 0x42, 0x0e, 0x6f, 0xf7, 0xe5, 0x38, 0xe4, 0x06, 0x3d, 0x4a, 0xeb,
00108         0x91, 0x3c, 0x2b, 0x7c, 0x16, 0x86, 0xb2, 0xce, 0x46, 0x15, 0x45, 0xbe,
00109         0x9d, 0x05, 0x81, 0xb8, 0x3b, 0x59, 0xf0, 0x6f, 0xeb, 0x26, 0x88, 0x75,
00110         0x96, 0xd0, 0xf7, 0xe8, 0x0f, 0xaa, 0x40, 0xbf, 0x89, 0xa6, 0x1a, 0x50,
00111         0x51, 0xc2, 0x5f, 0x04, 0x6f, 0xe1, 0x6d, 0x13, 0x4d, 0x53, 0x3e, 0xb9,
00112         0x2a, 0xda, 0x60, 0x55, 0x47, 0x7f, 0x88, 0xca, 0x64, 0xed, 0x7c, 0x9f,
00113         0x50, 0xe5, 0xed, 0xe9, 0x37, 0xd2, 0x6d, 0xc4, 0xbc, 0x60, 0x1d, 0xc4,
00114         0xef, 0x86, 0xb8, 0x33, 0xac, 0x9a, 0x88, 0x8b, 0x62, 0xbd, 0x04, 0x14,
00115         0xf4, 0x87, 0x7e, 0x49, 0xaa, 0xac, 0xb3, 0x71, 0x56, 0x38, 0x13, 0xe5,
00116         0xe6, 0xf2, 0x21, 0xf0, 0x93, 0xfc, 0x01, 0x78, 0x2a, 0x84, 0x98, 0x28,
00117         0xe8, 0xa9, 0x58, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae,
00118         0x42, 0x60, 0x82
00119     };
00120 
00121 CheckDocument::CheckDocument( QWidget* parent, bool modal )  : ScrPaletteBase( parent, "checkDocument", modal, 0 ),
00122 m_Doc(0)
00123 {
00124        QImage img;
00125        img.loadFromData( image0_data, sizeof( image0_data ), "PNG" );
00126        graveError = img;
00127        img.loadFromData( image1_data, sizeof( image1_data ), "PNG" );
00128        onlyWarning = img;
00129        img.loadFromData( image2_data, sizeof( image2_data ), "PNG" );
00130        noErrors = img;
00131        checkDocumentLayout = new QVBoxLayout( this, 5, 5, "checkDocumentLayout");
00132 
00133        layout1 = new QHBoxLayout( 0, 0, 5, "layout1");
00134        textLabel1 = new QLabel( this, "textLabel1" );
00135        layout1->addWidget( textLabel1 );
00136        curCheckProfile = new ScComboBox( false, this, "Profiles" );
00137        layout1->addWidget( curCheckProfile );
00138        checkDocumentLayout->addLayout( layout1 );
00139        reportDisplay = new QListView( this, "reportDisplay" );
00140        reportDisplay->addColumn("Items");
00141        reportDisplay->header()->setClickEnabled( false, reportDisplay->header()->count() - 1 );
00142        reportDisplay->header()->setResizeEnabled( false, reportDisplay->header()->count() - 1 );
00143        reportDisplay->addColumn("Problems");
00144        reportDisplay->header()->setClickEnabled( false, reportDisplay->header()->count() - 1 );
00145        reportDisplay->header()->setResizeEnabled( false, reportDisplay->header()->count() - 1 );
00146        reportDisplay->setSorting(-1);
00147        checkDocumentLayout->addWidget( reportDisplay );
00148        layout2 = new QHBoxLayout( 0, 0, 5, "layou2");
00149        reScan = new QPushButton(this, "reScan" );
00150        layout2->addWidget( reScan );
00151        QSpacerItem* spacer = new QSpacerItem( 2, 2, QSizePolicy::Expanding, QSizePolicy::Minimum );
00152        layout2->addItem( spacer );
00153        ignoreErrors = new QPushButton(this, "ignoreErrors" );
00154        layout2->addWidget( ignoreErrors );
00155        checkDocumentLayout->addLayout( layout2 );
00156        setIgnoreEnabled(false);
00157        checkMode = checkNULL;
00158        languageChange();
00159        itemMap.clear();
00160        pageMap.clear();
00161        masterPageMap.clear();
00162        masterPageItemMap.clear();
00163        resize( QSize(320, 260).expandedTo(minimumSizeHint()) );
00164        clearWState( WState_Polished );
00165        connect(ignoreErrors, SIGNAL(clicked()), this, SIGNAL(ignoreAllErrors()));
00166        connect(curCheckProfile, SIGNAL(activated(const QString&)), this, SLOT(newScan(const QString&)));
00167        connect(reScan, SIGNAL(clicked()), this, SLOT(doReScan()));
00168 }
00169 /*
00170 void CheckDocument::closeEvent(QCloseEvent *ce)
00171 {
00172        emit closePal(false);
00173        QDialog::closeEvent(ce);
00174 }
00175 
00176 void CheckDocument::keyPressEvent(QKeyEvent *ke)
00177 {
00178        QDialog::keyPressEvent(ke);
00179 }
00180 */
00181 
00182 void CheckDocument::slotSelect(QListViewItem* ite)
00183 {
00184        if (itemMap.contains(ite))
00185        {
00186               ScCore->primaryMainWindow()->closeActiveWindowMasterPageEditor();
00187               emit selectElement(m_Doc->DocItems.at(itemMap[ite])->OwnPage, itemMap[ite]);
00188               return;
00189        }
00190        if (pageMap.contains(ite))
00191        {
00192               ScCore->primaryMainWindow()->closeActiveWindowMasterPageEditor();
00193               emit selectPage(pageMap[ite]);
00194               return;
00195        }
00196        if (masterPageMap.contains(ite))
00197        {
00198               emit selectMasterPage(masterPageMap[ite]);
00199               return;
00200        }
00201        if (masterPageItemMap.contains(ite))
00202        {
00203               if (!m_Doc->masterPageMode())
00204                      emit selectMasterPage(m_Doc->MasterItems.at(masterPageItemMap[ite])->OnMasterPage);
00205               emit selectElement(-1, masterPageItemMap[ite]);
00206               return;
00207        }
00208 }
00209 
00210 void CheckDocument::doReScan()
00211 {
00212        newScan(curCheckProfile->currentText());
00213 //     clearErrorList();
00214 //     if (m_Doc==0)
00215 //            return;
00216 //     m_Doc->curCheckProfile = curCheckProfile->currentText();
00217 //     DocumentChecker::checkDocument(m_Doc);
00218 //     buildErrorList(m_Doc);
00219 }
00220 
00221 void CheckDocument::newScan(const QString& name)
00222 {
00223        clearErrorList();
00224        if (m_Doc==0)
00225               return;
00226        m_Doc->curCheckProfile = name;
00227        DocumentChecker::checkDocument(m_Doc);
00228        buildErrorList(m_Doc);
00229 }
00230 
00231 void CheckDocument::clearErrorList()
00232 {
00233        disconnect(reportDisplay, SIGNAL(selectionChanged(QListViewItem*)), this, SLOT(slotSelect(QListViewItem*)));
00234        reportDisplay->clear();
00235        reportDisplay->setSorting(-1);
00236        itemMap.clear();
00237        pageMap.clear();
00238        masterPageMap.clear();
00239        masterPageItemMap.clear();
00240 }
00241 
00242 void CheckDocument::buildErrorList(ScribusDoc *doc)
00243 {
00244        bool resultError = false;
00245        m_Doc = doc;
00246        disconnect(curCheckProfile, SIGNAL(activated(const QString&)), this, SLOT(newScan(const QString&)));
00247        curCheckProfile->clear();
00248        clearErrorList();
00249 
00250        if (m_Doc==0)
00251               return;
00252 
00253        CheckerPrefsList::Iterator it;
00254        CheckerPrefsList::Iterator itend=doc->checkerProfiles.end();
00255        for (it = doc->checkerProfiles.begin(); it != itend ; ++it)
00256               curCheckProfile->insertItem(it.key());
00257        curCheckProfile->setCurrentText(doc->curCheckProfile);
00258 
00259        int minRes = qRound(doc->checkerProfiles[doc->curCheckProfile].minResolution);
00260        int maxRes = qRound(doc->checkerProfiles[doc->curCheckProfile].maxResolution);
00261        int xres, yres;
00262 
00263        QListViewItem * item = new QListViewItem( reportDisplay, 0 );
00264        item->setText( 0, tr( "Document" ) );
00265        if ((doc->docItemErrors.count() == 0) && (doc->masterItemErrors.count() == 0) && (doc->docLayerErrors.count() == 0))
00266        {
00267               item->setPixmap( 0, noErrors );
00268               item->setText( 1, tr( "No Problems found" ) );
00269               ignoreErrors->setText( tr("OK"));
00270        }
00271        else
00272        {
00273               resultError = true;
00274               bool hasError = false;
00275               bool hasGraveError = false;
00276               QListViewItem * pagep = 0;
00277               if (doc->docLayerErrors.count() != 0)
00278               {
00279                      QMap<int, errorCodes>::Iterator it01;
00280                      for (it01 = doc->docLayerErrors.begin(); it01 != doc->docLayerErrors.end(); ++it01)
00281                      {
00282                             QListViewItem * layer = new QListViewItem( item, pagep );
00283                             errorCodes::Iterator it03;
00284                             for (it03 = it01.data().begin(); it03 != it01.data().end(); ++it03)
00285                             {
00286                                    QListViewItem * errorText = new QListViewItem( layer, 0 );
00287                                    switch (it03.key())
00288                                    {
00289                                           case Transparency:
00290                                                  errorText->setText(0, tr("Transparency used"));
00291                                                  break;
00292                                           case BlendMode:
00293                                                  errorText->setText(0, tr("Blendmode used"));
00294                                                  break;
00295                                           default:
00296                                                  break;
00297                                    }
00298                                    errorText->setPixmap( 0, graveError );
00299                             }
00300                             layer->setText(0, QString( tr("Layer \"%1\"")).arg(doc->layerName(it01.key())));
00301                             layer->setPixmap( 0, graveError );
00302                             pagep = layer;
00303                             hasGraveError = true;
00304                      }
00305               }
00306               for (int a = 0; a < static_cast<int>(doc->MasterPages.count()); ++a)
00307               {
00308                      QString tmp;
00309                      hasError = false;
00310                      bool pageGraveError = false;
00311                      QListViewItem * page = new QListViewItem( item, pagep );
00312                      masterPageMap.insert(page, doc->MasterPages.at(a)->pageName());
00313                      pagep = page;
00314                      QMap<int, errorCodes>::Iterator it2;
00315                      for (it2 = doc->masterItemErrors.begin(); it2 != doc->masterItemErrors.end(); ++it2)
00316                      {
00317                             if ((doc->MasterItems.at(it2.key())->OwnPage == a) || (doc->MasterItems.at(it2.key())->OnMasterPage == doc->MasterPages.at(a)->pageName()))
00318                             {
00319                                    hasError = true;
00320                                    bool itemError = false;
00321                                    QListViewItem * object = new QListViewItem( page, 0 );
00322                                    masterPageItemMap.insert(object, doc->MasterItems.at(it2.key())->ItemNr);
00323                                    object->setText(0, doc->MasterItems.at(it2.key())->itemName());
00324                                    errorCodes::Iterator it3;
00325                                    if (it2.data().count() == 1)
00326                                    {
00327                                           it3 = it2.data().begin();
00328                                           switch (it3.key())
00329                                           {
00330                                           case MissingGlyph:
00331                                                  object->setText(1, missingGlyph);
00332                                                  hasGraveError = true;
00333                                                  pageGraveError = true;
00334                                                  itemError = true;
00335                                                  break;
00336                                           case TextOverflow:
00337                                                  object->setText(1, textOverflow);
00338                                                  break;
00339                                           case ObjectNotOnPage:
00340                                                  object->setText(1, notOnPage);
00341                                                  break;
00342                                           case MissingImage:
00343                                                  object->setText(1, missingImg);
00344                                                  hasGraveError = true;
00345                                                  pageGraveError = true;
00346                                                  itemError = true;
00347                                                  break;
00348                                           case ImageDPITooLow:
00349                                                  xres = qRound(72.0 / doc->MasterItems.at(it2.key())->imageXScale());
00350                                                  yres = qRound(72.0 / doc->MasterItems.at(it2.key())->imageYScale());
00351                                                  object->setText(1, lowDPI.arg(minRes).arg(xres).arg(yres));
00352                                                  break;
00353                                           case ImageDPITooHigh:
00354                                                  xres = qRound(72.0 / doc->MasterItems.at(it2.key())->imageXScale());
00355                                                  yres = qRound(72.0 / doc->MasterItems.at(it2.key())->imageYScale());
00356                                                  object->setText(1, highDPI.arg(maxRes).arg(xres).arg(yres));
00357                                                  break;
00358                                           case Transparency:
00359                                                  object->setText(1, transpar);
00360                                                  hasGraveError = true;
00361                                                  pageGraveError = true;
00362                                                  itemError = true;
00363                                                  break;
00364                                           case PDFAnnotField:
00365                                                  object->setText(1, annot);
00366                                                  break;
00367                                           case PlacedPDF:
00368                                                  object->setText(1, rasterPDF);
00369                                                  break;
00370                                           case ImageIsGIF:
00371                                                  object->setText(1, isGIF);
00372                                                  //QToolTip::add(object, isGIFtoolTip);
00373                                                  break;
00374                                           case WrongFontInAnnotation:
00375                                                  object->setText(1, WrongFont);
00376                                                  hasGraveError = true;
00377                                                  pageGraveError = true;
00378                                                  itemError = true;
00379                                                  break;
00380                                           default:
00381                                                  break;
00382                                           }
00383                                    }
00384                                    else
00385                                    {
00386                                           for (it3 = it2.data().begin(); it3 != it2.data().end(); ++it3)
00387                                           {
00388                                                  QListViewItem * errorText = new QListViewItem( object, 0 );
00389                                                  switch (it3.key())
00390                                                  {
00391                                                  case MissingGlyph:
00392                                                         errorText->setText(1, missingGlyph);
00393                                                         errorText->setPixmap( 0, graveError );
00394                                                         hasGraveError = true;
00395                                                         pageGraveError = true;
00396                                                         itemError = true;
00397                                                         break;
00398                                                  case TextOverflow:
00399                                                         errorText->setText(1, textOverflow);
00400                                                         errorText->setPixmap( 0, onlyWarning );
00401                                                         break;
00402                                                  case ObjectNotOnPage:
00403                                                         errorText->setText(1, notOnPage);
00404                                                         errorText->setPixmap( 0, onlyWarning );
00405                                                         break;
00406                                                  case MissingImage:
00407                                                         errorText->setText(1, missingImg);
00408                                                         errorText->setPixmap( 0, graveError );
00409                                                         hasGraveError = true;
00410                                                         pageGraveError = true;
00411                                                         itemError = true;
00412                                                         break;
00413                                                  case ImageDPITooLow:
00414                                                         xres = qRound(72.0 / doc->MasterItems.at(it2.key())->imageXScale());
00415                                                         yres = qRound(72.0 / doc->MasterItems.at(it2.key())->imageYScale());
00416                                                         errorText->setText(1, lowDPI.arg(minRes).arg(xres).arg(yres));
00417                                                         errorText->setPixmap( 0, onlyWarning );
00418                                                         break;
00419                                                  case ImageDPITooHigh:
00420                                                         xres = qRound(72.0 / doc->MasterItems.at(it2.key())->imageXScale());
00421                                                         yres = qRound(72.0 / doc->MasterItems.at(it2.key())->imageYScale());
00422                                                         errorText->setText(1, highDPI.arg(maxRes).arg(xres).arg(yres));
00423                                                         errorText->setPixmap( 0, onlyWarning );
00424                                                         break;
00425                                                  case Transparency:
00426                                                         errorText->setText(1, transpar);
00427                                                         errorText->setPixmap( 0, graveError );
00428                                                         hasGraveError = true;
00429                                                         pageGraveError = true;
00430                                                         itemError = true;
00431                                                         break;
00432                                                  case PDFAnnotField:
00433                                                         errorText->setText(1, annot);
00434                                                         errorText->setPixmap( 0, onlyWarning );
00435                                                         break;
00436                                                  case PlacedPDF:
00437                                                         errorText->setText(1, rasterPDF);
00438                                                         errorText->setPixmap( 0, onlyWarning );
00439                                                         break;
00440                                                  case ImageIsGIF:
00441                                                         errorText->setText(1, isGIF);
00442                                                         errorText->setPixmap(0, onlyWarning);
00443                                                         //QToolTip::add(errorText, isGIFtoolTip);
00444                                                         break;
00445                                                  case WrongFontInAnnotation:
00446                                                         errorText->setText(1, WrongFont);
00447                                                         errorText->setPixmap( 0, graveError );
00448                                                         hasGraveError = true;
00449                                                         pageGraveError = true;
00450                                                         itemError = true;
00451                                                         break;
00452                                                  default:
00453                                                         break;
00454                                                  }
00455                                           }
00456                                           object->setOpen( true );
00457                                    }
00458                                    if (itemError)
00459                                           object->setPixmap( 0, graveError );
00460                                    else
00461                                           object->setPixmap( 0, onlyWarning );
00462                             }
00463                      }
00464                      if (hasError)
00465                      {
00466                             if (pageGraveError)
00467                                    page->setPixmap( 0, graveError );
00468                             else
00469                                    page->setPixmap( 0, onlyWarning );
00470                             page->setOpen( true );
00471                      }
00472                      else
00473                             page->setPixmap( 0, noErrors );
00474                      page->setText(0, doc->MasterPages.at(a)->pageName());
00475               }
00476               for (int a = 0; a < static_cast<int>(doc->DocPages.count()); ++a)
00477               {
00478                      QString tmp;
00479                      hasError = false;
00480                      bool pageGraveError = false;
00481                      QListViewItem * page = new QListViewItem( item, pagep );
00482                      pageMap.insert(page, a);
00483                      pagep = page;
00484                      QMap<int, errorCodes>::Iterator it2;
00485                      for (it2 = doc->docItemErrors.begin(); it2 != doc->docItemErrors.end(); ++it2)
00486                      {
00487                             if (doc->DocItems.at(it2.key())->OwnPage == a)
00488                             {
00489                                    hasError = true;
00490                                    bool itemError = false;
00491                                    QListViewItem * object = new QListViewItem( page, 0 );
00492                                    object->setText(0, doc->DocItems.at(it2.key())->itemName());
00493                                    itemMap.insert(object, doc->DocItems.at(it2.key())->ItemNr);
00494                                    errorCodes::Iterator it3;
00495                                    if (it2.data().count() == 1)
00496                                    {
00497                                           it3 = it2.data().begin();
00498                                           switch (it3.key())
00499                                           {
00500                                           case MissingGlyph:
00501                                                  object->setText(1, missingGlyph);
00502                                                  hasGraveError = true;
00503                                                  pageGraveError = true;
00504                                                  itemError = true;
00505                                                  break;
00506                                           case TextOverflow:
00507                                                  object->setText(1, textOverflow);
00508                                                  break;
00509                                           case ObjectNotOnPage:
00510                                                  object->setText(1, notOnPage);
00511                                                  break;
00512                                           case MissingImage:
00513                                                  object->setText(1, missingImg);
00514                                                  hasGraveError = true;
00515                                                  pageGraveError = true;
00516                                                  itemError = true;
00517                                                  break;
00518                                           case ImageDPITooLow:
00519                                                  xres = qRound(72.0 / doc->DocItems.at(it2.key())->imageXScale());
00520                                                  yres = qRound(72.0 / doc->DocItems.at(it2.key())->imageYScale());
00521                                                  object->setText(1, lowDPI.arg(minRes).arg(xres).arg(yres));
00522                                                  break;
00523                                           case ImageDPITooHigh:
00524                                                  xres = qRound(72.0 / doc->DocItems.at(it2.key())->imageXScale());
00525                                                  yres = qRound(72.0 / doc->DocItems.at(it2.key())->imageYScale());
00526                                                  object->setText(1, highDPI.arg(maxRes).arg(xres).arg(yres));
00527                                                  break;
00528                                           case Transparency:
00529                                                  object->setText(1, transpar);
00530                                                  hasGraveError = true;
00531                                                  pageGraveError = true;
00532                                                  itemError = true;
00533                                                  break;
00534                                           case PDFAnnotField:
00535                                                  object->setText(1, annot);
00536                                                  break;
00537                                           case PlacedPDF:
00538                                                  object->setText(1, rasterPDF);
00539                                                  break;
00540                                           case ImageIsGIF:
00541                                                  object->setText(1, isGIF);
00542                                                  //QToolTip::add(object, isGIFtoolTip);
00543                                                  break;
00544                                           case WrongFontInAnnotation:
00545                                                  object->setText(1, WrongFont);
00546                                                  hasGraveError = true;
00547                                                  pageGraveError = true;
00548                                                  itemError = true;
00549                                                  break;
00550                                           default:
00551                                                  break;
00552                                           }
00553                                    }
00554                                    else
00555                                    {
00556                                           for (it3 = it2.data().begin(); it3 != it2.data().end(); ++it3)
00557                                           {
00558                                                  QListViewItem * errorText = new QListViewItem( object, 0 );
00559                                                  switch (it3.key())
00560                                                  {
00561                                                  case MissingGlyph:
00562                                                         errorText->setText(1, missingGlyph);
00563                                                         errorText->setPixmap( 0, graveError );
00564                                                         hasGraveError = true;
00565                                                         pageGraveError = true;
00566                                                         itemError = true;
00567                                                         break;
00568                                                  case TextOverflow:
00569                                                         errorText->setText(1, textOverflow);
00570                                                         errorText->setPixmap( 0, onlyWarning );
00571                                                         break;
00572                                                  case ObjectNotOnPage:
00573                                                         errorText->setText(1, notOnPage);
00574                                                         errorText->setPixmap( 0, onlyWarning );
00575                                                         break;
00576                                                  case MissingImage:
00577                                                         errorText->setText(1, missingImg);
00578                                                         errorText->setPixmap( 0, graveError );
00579                                                         hasGraveError = true;
00580                                                         pageGraveError = true;
00581                                                         itemError = true;
00582                                                         break;
00583                                                  case ImageDPITooLow:
00584                                                         xres = qRound(72.0 / doc->DocItems.at(it2.key())->imageXScale());
00585                                                         yres = qRound(72.0 / doc->DocItems.at(it2.key())->imageYScale());
00586                                                         errorText->setText(1, lowDPI.arg(minRes).arg(xres).arg(yres));
00587                                                         errorText->setPixmap( 0, onlyWarning );
00588                                                         break;
00589                                                  case ImageDPITooHigh:
00590                                                         xres = qRound(72.0 / doc->DocItems.at(it2.key())->imageXScale());
00591                                                         yres = qRound(72.0 / doc->DocItems.at(it2.key())->imageYScale());
00592                                                         errorText->setText(1, highDPI.arg(maxRes).arg(xres).arg(yres));
00593                                                         errorText->setPixmap( 0, onlyWarning );
00594                                                         break;
00595                                                  case Transparency:
00596                                                         errorText->setText(1, transpar);
00597                                                         errorText->setPixmap( 0, graveError );
00598                                                         hasGraveError = true;
00599                                                         pageGraveError = true;
00600                                                         itemError = true;
00601                                                         break;
00602                                                  case PDFAnnotField:
00603                                                         errorText->setText(1, annot);
00604                                                         errorText->setPixmap( 0, onlyWarning );
00605                                                         break;
00606                                                  case PlacedPDF:
00607                                                         errorText->setText(1, rasterPDF);
00608                                                         errorText->setPixmap( 0, onlyWarning );
00609                                                         break;
00610                                                  case ImageIsGIF:
00611                                                         errorText->setText(1, isGIF);
00612                                                         errorText->setPixmap(0, onlyWarning);
00613                                                         //QToolTip::add(errorText, isGIFtoolTip);
00614                                                         break;
00615                                                  case WrongFontInAnnotation:
00616                                                         errorText->setText(1, WrongFont);
00617                                                         errorText->setPixmap( 0, graveError );
00618                                                         hasGraveError = true;
00619                                                         pageGraveError = true;
00620                                                         itemError = true;
00621                                                         break;
00622                                                  default:
00623                                                         break;
00624                                                  }
00625                                           }
00626                                           object->setOpen( true );
00627                                    }
00628                                    if (itemError)
00629                                           object->setPixmap( 0, graveError );
00630                                    else
00631                                           object->setPixmap( 0, onlyWarning );
00632                             }
00633                      }
00634                      if (hasError)
00635                      {
00636                             if (pageGraveError)
00637                                    page->setPixmap( 0, graveError );
00638                             else
00639                                    page->setPixmap( 0, onlyWarning );
00640                             page->setOpen( true );
00641                      }
00642                      else
00643                             page->setPixmap( 0, noErrors );
00644                      page->setText(0, tr("Page ")+tmp.setNum(a+1));
00645               }
00646               QMap<int, errorCodes>::Iterator it2;
00647               bool hasfreeItems = false;
00648               for (it2 = doc->docItemErrors.begin(); it2 != doc->docItemErrors.end(); ++it2)
00649               {
00650                      if (doc->DocItems.at(it2.key())->OwnPage == -1)
00651                      {
00652                             hasfreeItems = true;
00653                             break;
00654                      }
00655               }
00656               if (hasfreeItems)
00657               {
00658                      bool hasError = false;
00659                      bool pageGraveError = false;
00660                      QListViewItem * page = new QListViewItem( item, pagep );
00661                      pagep = page;
00662                      for (it2 = doc->docItemErrors.begin(); it2 != doc->docItemErrors.end(); ++it2)
00663                      {
00664                             if (doc->DocItems.at(it2.key())->OwnPage == -1)
00665                             {
00666                                    hasError = true;
00667                                    QListViewItem * object = new QListViewItem( page, 0 );
00668                                    object->setText(0, doc->DocItems.at(it2.key())->itemName());
00669                                    itemMap.insert(object, doc->DocItems.at(it2.key())->ItemNr);
00670                                    errorCodes::Iterator it3;
00671                                    if (it2.data().count() == 1)
00672                                    {
00673                                           it3 = it2.data().begin();
00674                                           switch (it3.key())
00675                                           {
00676                                           case MissingGlyph:
00677                                                  object->setText(1, missingGlyph);
00678                                                  hasGraveError = true;
00679                                                  pageGraveError = true;
00680                                                  break;
00681                                           case TextOverflow:
00682                                                  object->setText(1, textOverflow);
00683                                                  break;
00684                                           case ObjectNotOnPage:
00685                                                  object->setText(1, notOnPage);
00686                                                  break;
00687                                           case MissingImage:
00688                                                  object->setText(1, missingImg);
00689                                                  hasGraveError = true;
00690                                                  pageGraveError = true;
00691                                                  break;
00692                                           case ImageDPITooLow:
00693                                                  xres = qRound(72.0 / doc->DocItems.at(it2.key())->imageXScale());
00694                                                  yres = qRound(72.0 / doc->DocItems.at(it2.key())->imageYScale());
00695                                                  object->setText(1, lowDPI.arg(minRes).arg(xres).arg(yres));
00696                                                  break;
00697                                           case ImageDPITooHigh:
00698                                                  xres = qRound(72.0 / doc->DocItems.at(it2.key())->imageXScale());
00699                                                  yres = qRound(72.0 / doc->DocItems.at(it2.key())->imageYScale());
00700                                                  object->setText(1, highDPI.arg(maxRes).arg(xres).arg(yres));
00701                                                  break;
00702                                           case Transparency:
00703                                                  object->setText(1, transpar);
00704                                                  hasGraveError = true;
00705                                                  pageGraveError = true;
00706                                                  break;
00707                                           case PDFAnnotField:
00708                                                  object->setText(1, annot);
00709                                                  break;
00710                                           case PlacedPDF:
00711                                                  object->setText(1, rasterPDF);
00712                                                  break;
00713                                           case ImageIsGIF:
00714                                                  object->setText(1, isGIF);
00715                                                  //QToolTip::add(object, isGIFtoolTip);
00716                                                  break;
00717                                           case WrongFontInAnnotation:
00718                                                  object->setText(1, WrongFont);
00719                                                  hasGraveError = true;
00720                                                  pageGraveError = true;
00721                                                  break;
00722                                           default:
00723                                                  break;
00724                                           }
00725                                    }
00726                                    else
00727                                    {
00728                                           for (it3 = it2.data().begin(); it3 != it2.data().end(); ++it3)
00729                                           {
00730                                                  QListViewItem * errorText = new QListViewItem( object, 0 );
00731                                                  switch (it3.key())
00732                                                  {
00733                                                  case MissingGlyph:
00734                                                         errorText->setText(1, missingGlyph);
00735                                                         errorText->setPixmap( 0, graveError );
00736                                                         hasGraveError = true;
00737                                                         pageGraveError = true;
00738                                                         break;
00739                                                  case TextOverflow:
00740                                                         errorText->setText(1, textOverflow);
00741                                                         errorText->setPixmap( 0, onlyWarning );
00742                                                         break;
00743                                                  case ObjectNotOnPage:
00744                                                         errorText->setText(1, notOnPage);
00745                                                         errorText->setPixmap( 0, onlyWarning );
00746                                                         break;
00747                                                  case MissingImage:
00748                                                         errorText->setText(1, missingImg);
00749                                                         errorText->setPixmap( 0, graveError );
00750                                                         hasGraveError = true;
00751                                                         pageGraveError = true;
00752                                                         break;
00753                                                  case ImageDPITooLow:
00754                                                         xres = qRound(72.0 / doc->DocItems.at(it2.key())->imageXScale());
00755                                                         yres = qRound(72.0 / doc->DocItems.at(it2.key())->imageYScale());
00756                                                         errorText->setText(1, lowDPI.arg(minRes).arg(xres).arg(yres));
00757                                                         errorText->setPixmap( 0, onlyWarning );
00758                                                         break;
00759                                                  case ImageDPITooHigh:
00760                                                         xres = qRound(72.0 / doc->DocItems.at(it2.key())->imageXScale());
00761                                                         yres = qRound(72.0 / doc->DocItems.at(it2.key())->imageYScale());
00762                                                         errorText->setText(1, highDPI.arg(maxRes).arg(xres).arg(yres));
00763                                                         errorText->setPixmap( 0, onlyWarning );
00764                                                         break;
00765                                                  case Transparency:
00766                                                         errorText->setText(1, transpar);
00767                                                         errorText->setPixmap( 0, graveError );
00768                                                         hasGraveError = true;
00769                                                         pageGraveError = true;
00770                                                         break;
00771                                                  case PDFAnnotField:
00772                                                         errorText->setText(1, annot);
00773                                                         errorText->setPixmap( 0, onlyWarning );
00774                                                         break;
00775                                                  case PlacedPDF:
00776                                                         errorText->setText(1, rasterPDF);
00777                                                         errorText->setPixmap( 0, onlyWarning );
00778                                                         break;
00779                                                  case ImageIsGIF:
00780                                                         errorText->setText(1, isGIF);
00781                                                         errorText->setPixmap(0, onlyWarning);
00782                                                         //QToolTip::add(errorText, isGIFtoolTip);
00783                                                         break;
00784                                                  case WrongFontInAnnotation:
00785                                                         errorText->setText(1, WrongFont);
00786                                                         errorText->setPixmap( 0, graveError );
00787                                                         hasGraveError = true;
00788                                                         pageGraveError = true;
00789                                                         break;
00790                                                  default:
00791                                                         break;
00792                                                  }
00793                                           }
00794                                           object->setOpen( true );
00795                                    }
00796                                    if (pageGraveError)
00797                                           object->setPixmap( 0, graveError );
00798                                    else
00799                                           object->setPixmap( 0, onlyWarning );
00800                             }
00801                      }
00802                      if (hasError)
00803                      {
00804                             if (pageGraveError)
00805                                    page->setPixmap( 0, graveError );
00806                             else
00807                                    page->setPixmap( 0, onlyWarning );
00808                             page->setOpen( true );
00809                      }
00810                      else
00811                             page->setPixmap( 0, noErrors );
00812                      page->setText(0, tr("Free Objects"));
00813               }
00814               if (hasGraveError)
00815                      item->setPixmap( 0, graveError );
00816               else
00817                      item->setPixmap( 0, onlyWarning );
00818               item->setText( 1, tr( "Problems found" ) );
00819               item->setOpen( true );
00820               ignoreErrors->setText( tr("&Ignore Errors"));
00821        }
00822        connect(curCheckProfile, SIGNAL(activated(const QString&)), this, SLOT(newScan(const QString&)));
00823        connect(reportDisplay, SIGNAL(selectionChanged(QListViewItem*)), this, SLOT(slotSelect(QListViewItem*)));
00824 }
00825 
00826 /*
00827  *  Sets the strings of the subwidgets using the current
00828  *  language.
00829  */
00830 void CheckDocument::languageChange()
00831 {
00832        setCaption( tr( "Preflight Verifier" ) );
00833        reportDisplay->header()->setLabel( 0, tr( "Items" ) );
00834        reportDisplay->header()->setLabel( 1, tr( "Problems" ) );
00835 
00836        textLabel1->setText( tr("Current Profile:"));
00837        ignoreErrors->setText( tr("&Ignore Errors"));
00838        reScan->setText( tr("Check again"));
00839        
00840        missingGlyph = tr("Glyphs missing");
00841        textOverflow = tr("Text overflow");
00842        notOnPage = tr("Object is not on a Page");
00843        missingImg = tr("Missing Image");
00844        lowDPI = tr("Image resolution below %1 DPI, currently %2 x %3 DPI");
00845        highDPI = tr("Image resolution above %1 DPI, currently %2 x %3 DPI");
00846        transpar = tr("Object has transparency");
00847        annot = tr("Object is a PDF Annotation or Field");
00848        rasterPDF = tr("Object is a placed PDF");
00849        isGIF = tr("Image is GIF");
00850        WrongFont = tr("Annotation uses a non TrueType font");
00851        //isGIFtoolTip = "<qt>" + tr("GIF images are not reccomended for print. See the online docs for more info") + "</qt>";
00852 }
00853 
00854 void CheckDocument::setIgnoreEnabled(bool state)
00855 {
00856        noButton = !state;
00857        ignoreErrors->setShown(state);
00858 }
00859 
00860 bool CheckDocument::isIgnoreEnabled()
00861 {
00862        return !noButton;
00863 }