Back to index

scribus-ng  1.3.4.dfsg+svn20071115
prefsmanager.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 /***************************************************************************
00008        copyright            : (C) 2005 by Craig Bradney
00009        email                : cbradney@zip.com.au
00010 ***************************************************************************/
00011 
00012 /***************************************************************************
00013 *                                                                         *
00014 *   This program is free software; you can redistribute it and/or modify  *
00015 *   it under the terms of the GNU General Public License as published by  *
00016 *   the Free Software Foundation; either version 2 of the License, or     *
00017 *   (at your option) any later version.                                   *
00018 *                                                                         *
00019 ***************************************************************************/
00020 
00021 #include <qcolor.h>
00022 #include <qdir.h>
00023 #include <qdom.h>
00024 #include <qfile.h>
00025 #include <qstring.h>
00026 #include <qstylefactory.h>
00027 #include <qwmatrix.h>
00028 
00029 #include "prefsmanager.h"
00030 #include "prefsmanager.moc"
00031 
00032 #include "actionmanager.h"
00033 #include "colorsetmanager.h"
00034 #include "commonstrings.h"
00035 #include "filewatcher.h"
00036 #include "missing.h"
00037 #include "tabkeyboardshortcutswidget.h"
00038 #include "pagesize.h"
00039 #include "pagestructs.h"
00040 #include "pdfoptions.h"
00041 #include "prefsfile.h"
00042 #include "scfonts.h"
00043 #include "scmessagebox.h"
00044 #include "scpaths.h"
00045 #include "scribuscore.h"
00046 #include "scribusstructs.h"
00047 #include "scribuscore.h"
00048 #include "gsutil.h"
00049 #include "util.h"
00050 #include "werktoolb.h"
00051 
00052 
00053 extern bool emergencyActivated;
00054 
00055 PrefsManager* PrefsManager::_instance = 0;
00056 
00057 PrefsManager::PrefsManager(QObject *parent, const char *name)
00058  : QObject(parent, name)
00059 {
00060 }
00061 
00062 PrefsManager::~PrefsManager()
00063 {
00064        appPrefs.AvailFonts.~SCFonts();
00065        delete prefsFile;
00066 }
00067 
00068 PrefsManager* PrefsManager::instance()
00069 {
00070     if (_instance == 0)
00071         _instance = new PrefsManager();
00072 
00073     return _instance;
00074 }
00075 
00076 void PrefsManager::deleteInstance()
00077 {
00078     if (_instance)
00079         delete _instance;
00080     _instance = 0;
00081 }
00082 
00083 
00084 ApplicationPrefs* PrefsManager::applicationPrefs()
00085 {
00086        return &appPrefs;
00087 }
00088 
00089 PrefsFile* PrefsManager::applicationPrefsFile()
00090 {
00091        return prefsFile;
00092 }
00093 
00094 const bool PrefsManager::importingFrom12x()
00095 {
00096        return importingFrom12;
00097 }
00098 
00099 
00100 void PrefsManager::setup()
00101 {
00102        setupPreferencesLocation();
00103 
00104        importingFrom12=copyOldPreferences();
00105        prefsFile = new PrefsFile( prefsLocation + "/prefs134.xml" );
00106        if (importingFrom12)
00107               convert12Preferences();
00108        //<<CB TODO Reset keyboard shortcuts of all 1.3 users as too many
00109        //     have conflicts if they dont nuke their settings.
00110        // - Remove for 1.3.0 release: importingFrom12=true;
00111        //>>CB
00112 }
00113 
00114 void PrefsManager::initDefaults()
00115 {
00117        SCFontsIterator it(appPrefs.AvailFonts);
00118        bool goodFont = false;
00119        for ( SCFontsIterator itf(appPrefs.AvailFonts); itf.hasNext(); itf.next())
00120        {
00121               if ((itf.currentKey() == "Arial Regular") || (itf.currentKey() == "Times New Roman Regular"))
00122               {
00123                      appPrefs.toolSettings.defFont = itf.currentKey();
00124                      goodFont = true;
00125                      break;
00126               }
00127        }
00128        if (!goodFont)
00129               appPrefs.toolSettings.defFont = it.currentKey();
00130        appPrefs.toolSettings.defSize = 120;
00131 
00133        appPrefs.DColors.clear();
00134        
00135        ColorSetManager csm;
00136        csm.initialiseDefaultPrefs(appPrefs);
00137        csm.findPaletteLocations();
00138        csm.findPalettes();
00139        /*
00140        QString pfadC = ScPaths::instance().libDir()+"swatches/";
00141        QString pfadC2 = pfadC + "Scribus_X11.txt";
00142        QFile fiC(pfadC2);
00143        if (!fiC.exists())
00144        {
00145               appPrefs.DColors.insert("White", ScColor(0, 0, 0, 0));
00146               appPrefs.DColors.insert("Black", ScColor(0, 0, 0, 255));
00147               appPrefs.DColors.insert("Blue", ScColor(255, 255, 0, 0));
00148               appPrefs.DColors.insert("Cyan", ScColor(255, 0, 0, 0));
00149               appPrefs.DColors.insert("Green", ScColor(255, 0, 255, 0));
00150               appPrefs.DColors.insert("Red", ScColor(0, 255, 255, 0));
00151               appPrefs.DColors.insert("Yellow", ScColor(0, 0, 255, 0));
00152               appPrefs.DColors.insert("Magenta", ScColor(0, 255, 0, 0));
00153               appPrefs.DColorSet = "Scribus-Small";
00154        }
00155        else
00156        {
00157               if (fiC.open(IO_ReadOnly))
00158               {
00159                      QString ColorEn, Cname;
00160                      int Rval, Gval, Bval;
00161                      QTextStream tsC(&fiC);
00162                      ColorEn = tsC.readLine();
00163                      while (!tsC.atEnd())
00164                      {
00165                             ColorEn = tsC.readLine();
00166                             QTextStream CoE(&ColorEn, IO_ReadOnly);
00167                             CoE >> Rval;
00168                             CoE >> Gval;
00169                             CoE >> Bval;
00170                             CoE >> Cname;
00171                             ScColor tmp;
00172                             tmp.setColorRGB(Rval, Gval, Bval);
00173                             appPrefs.DColors.insert(Cname, tmp);
00174                      }
00175                      fiC.close();
00176               }
00177               appPrefs.DColorSet = "X11 RGB-Set";
00178        }
00179        */
00180 
00181        appPrefs.Wheelval = 40;
00183        appPrefs.mainWinSettings.xPosition = 0;
00184        appPrefs.mainWinSettings.yPosition = 0;
00185        appPrefs.mainWinSettings.width = 640;
00186        appPrefs.mainWinSettings.height = 480;
00187        appPrefs.mainWinSettings.maximized = false;
00188        appPrefs.guidesSettings.marginsShown = true;
00189        appPrefs.guidesSettings.framesShown = true;
00190        appPrefs.guidesSettings.layerMarkersShown = false;
00191        appPrefs.guidesSettings.gridShown = false;
00192        appPrefs.guidesSettings.guidesShown = false;
00193        appPrefs.guidesSettings.colBordersShown = false;
00194        appPrefs.guidesSettings.baseShown = false;
00195        appPrefs.guidesSettings.showPic = true;
00196        appPrefs.guidesSettings.showControls = false;
00197        appPrefs.guidesSettings.linkShown = false;
00198        appPrefs.guidesSettings.rulersShown = true;
00199        appPrefs.guidesSettings.showBleed = true;
00200        appPrefs.guidesSettings.rulerMode = true;
00201        appPrefs.guidesSettings.grabRad = 4;
00202        appPrefs.guidesSettings.guideRad = 10;
00203        appPrefs.guidesSettings.minorGrid = 20;
00204        appPrefs.guidesSettings.majorGrid = 100;
00205        appPrefs.guidesSettings.minorColor = QColor(green);
00206        appPrefs.guidesSettings.majorColor = QColor(green);
00207        appPrefs.guidesSettings.margColor = QColor(blue);
00208        appPrefs.guidesSettings.guideColor = QColor(darkBlue);
00209        appPrefs.guidesSettings.baseColor = QColor(lightGray);
00210        appPrefs.typographicSettings.valueSuperScript = 33;
00211        appPrefs.typographicSettings.scalingSuperScript = 100;
00212        appPrefs.typographicSettings.valueSubScript = 33;
00213        appPrefs.typographicSettings.scalingSubScript = 100;
00214        appPrefs.typographicSettings.valueSmallCaps = 75;
00215        appPrefs.typographicSettings.autoLineSpacing = 20;
00216        appPrefs.typographicSettings.valueUnderlinePos = -1;
00217        appPrefs.typographicSettings.valueUnderlineWidth = -1;
00218        appPrefs.typographicSettings.valueStrikeThruPos = -1;
00219        appPrefs.typographicSettings.valueStrikeThruWidth = -1;
00220        appPrefs.typographicSettings.valueBaseGrid = 14.4;
00221        appPrefs.typographicSettings.offsetBaseGrid = 0.0;
00222        appPrefs.GUI = "Default";
00223        appPrefs.showToolTips = true;
00224        appPrefs.moveTimeout = 150;
00225        appPrefs.stickyTools = false;
00226        //FIXME
00227        //Black here causes issues when a colour set is loaded without "Black" in it.
00228        //"Black" is created with wrong values. Eg SVG colour set
00229        appPrefs.toolSettings.dPen = "Black";
00230        appPrefs.toolSettings.dBrush = "Black";
00231        appPrefs.toolSettings.dShade = 100;
00232        appPrefs.toolSettings.dShade2 = 100;
00233        appPrefs.toolSettings.dLineArt = SolidLine;
00234        appPrefs.toolSettings.dWidth = 1;
00235        appPrefs.toolSettings.dPenLine = "Black";
00236        appPrefs.toolSettings.dPenText = "Black";
00237        appPrefs.toolSettings.dStrokeText = "Black";
00238        appPrefs.toolSettings.dTextBackGround = CommonStrings::None;
00239        appPrefs.toolSettings.dTextLineColor = CommonStrings::None;
00240        appPrefs.toolSettings.dTextBackGroundShade = 100;
00241        appPrefs.toolSettings.dTextLineShade = 100;
00242        appPrefs.toolSettings.dTextPenShade = 100;
00243        appPrefs.toolSettings.dTextStrokeShade = 100;
00244        appPrefs.toolSettings.tabFillChar = "";
00245        appPrefs.toolSettings.dTabWidth = 36.0;
00246        appPrefs.toolSettings.dispX = 10.0;
00247        appPrefs.toolSettings.dispY = 10.0;
00248        appPrefs.toolSettings.constrain = 15.0;
00249        appPrefs.DpapColor = QColor(white);
00250        appPrefs.DFrameColor = QColor(red);
00251        appPrefs.DFrameNormColor = QColor(black);
00252        appPrefs.DFrameGroupColor = QColor(darkCyan);
00253        appPrefs.DFrameLockColor = QColor(darkRed);
00254        appPrefs.DFrameLinkColor = QColor(red);
00255        appPrefs.DFrameAnnotationColor = QColor(blue);
00256        appPrefs.DPageBorderColor = QColor(red);
00257        appPrefs.DControlCharColor = QColor(darkRed);
00258        appPrefs.toolSettings.dCols = 1;
00259        appPrefs.toolSettings.dGap = 0.0;
00260        appPrefs.toolSettings.dShadeLine = 100;
00261        appPrefs.toolSettings.dLstyleLine = SolidLine;
00262        appPrefs.toolSettings.dWidthLine = 1;
00263        appPrefs.toolSettings.dStartArrow = 0;
00264        appPrefs.toolSettings.dEndArrow = 0;
00265        appPrefs.toolSettings.magMin = 10;
00266        appPrefs.toolSettings.magMax = 3200;
00267        appPrefs.toolSettings.magStep = 200;
00268        appPrefs.toolSettings.dBrushPict = CommonStrings::None;
00269        appPrefs.toolSettings.shadePict = 100;
00270        appPrefs.toolSettings.scaleX = 1;
00271        appPrefs.toolSettings.scaleY = 1;
00272        appPrefs.guidesSettings.before = true;
00273        appPrefs.docUnitIndex = 0;
00274        appPrefs.toolSettings.polyC = 4;
00275        appPrefs.toolSettings.polyF = 0.5;
00276        appPrefs.toolSettings.polyS = false;
00277        appPrefs.toolSettings.polyFd = 0;
00278        appPrefs.toolSettings.polyR = 0;
00279 //     appPrefs.PSize = 40;
00280        appPrefs.ClipMargin = false;
00281        appPrefs.GCRMode = false;
00282        appPrefs.doOverprint = false;
00283        appPrefs.RecentDocs.clear();
00284        appPrefs.RecentScrapbooks.clear();
00285        appPrefs.RecentDCount = 5;
00286        appPrefs.doCopyToScrapbook = true;
00287        appPrefs.persistentScrapbook = false;
00288        appPrefs.numScrapbookCopies = 10;
00289        appPrefs.marginColored = false;
00290        appPrefs.pageSize = "A4";
00291        appPrefs.pageOrientation = 0;
00292        PageSize a4("A4");
00293        appPrefs.PageWidth = a4.width();
00294        appPrefs.PageHeight = a4.height();
00295        appPrefs.margins.Top = 40;
00296        appPrefs.margins.Bottom = 40;
00297        appPrefs.margins.Left = 40;
00298        appPrefs.margins.Right = 40;
00299        appPrefs.bleeds.Top = 0;
00300        appPrefs.bleeds.Left = 0;
00301        appPrefs.bleeds.Right = 0;
00302        appPrefs.bleeds.Bottom = 0;
00303        appPrefs.toolSettings.scaleType = true;
00304        appPrefs.toolSettings.aspectRatio = true;
00305        appPrefs.toolSettings.lowResType = 1;
00306        appPrefs.toolSettings.useEmbeddedPath = false;
00307        appPrefs.MinWordLen = 3;
00308        appPrefs.HyCount = 2;
00309        appPrefs.Language = "";
00310        appPrefs.Automatic = true;
00311        appPrefs.AutoCheck = false;
00312        appPrefs.AutoSave = true;
00313        appPrefs.AutoSaveTime = 600000;
00314        appPrefs.DisScale = 1.0;
00315        appPrefs.DocDir = ScPaths::getUserDocumentDir();
00316        appPrefs.ProfileDir = "";
00317        appPrefs.ScriptDir = "";
00318        appPrefs.documentTemplatesDir = "";
00319        appPrefs.CustomColorSets.clear();
00320        appPrefs.PrPr_Mode = false;
00321        appPrefs.Gcr_Mode = true;
00322        appPrefs.PrPr_AntiAliasing = false;
00323        appPrefs.PrPr_Transparency = false;
00324        appPrefs.PrPr_C = true;
00325        appPrefs.PrPr_M = true;
00326        appPrefs.PrPr_Y = true;
00327        appPrefs.PrPr_K = true;
00328        appPrefs.imageEditorExecutable = "gimp";
00329        appPrefs.extBrowserExecutable = "";
00330        appPrefs.gs_AntiAliasGraphics = true;
00331        appPrefs.gs_AntiAliasText = true;
00332        appPrefs.gs_exe = getGSDefaultExeName();
00333        appPrefs.gs_Resolution = 72;
00334        appPrefs.STEcolor = QColor(white);
00335        appPrefs.DCMSset.DefaultMonitorProfile = "";
00336        appPrefs.DCMSset.DefaultPrinterProfile = "";
00337        appPrefs.DCMSset.DefaultImageRGBProfile = "";
00338        appPrefs.DCMSset.DefaultSolidColorRGBProfile = "";
00339        appPrefs.DCMSset.DefaultSolidColorCMYKProfile = "";
00340        appPrefs.DCMSset.CMSinUse = false;
00341        appPrefs.DCMSset.SoftProofOn = false;
00342        appPrefs.DCMSset.SoftProofFullOn = false;
00343        appPrefs.DCMSset.GamutCheck = false;
00344        appPrefs.DCMSset.BlackPoint = true;
00345        appPrefs.DCMSset.DefaultIntentColors = 1;
00346        appPrefs.DCMSset.DefaultIntentImages = 0;
00347        appPrefs.GFontSub.clear();
00348        appPrefs.scratch.Left = 100;
00349        appPrefs.scratch.Right = 100;
00350        appPrefs.scratch.Top = 20;
00351        appPrefs.scratch.Bottom = 20;
00352        struct PageSet pageS;
00353        pageS.Name = CommonStrings::pageSet1;
00354        pageS.FirstPage = 0;
00355        pageS.Rows = 1;
00356        pageS.Columns = 1;
00357        pageS.GapHorizontal = 0.0;
00358        pageS.GapVertical = 0.0;
00359        pageS.GapBelow = 40.0;
00360        pageS.pageNames.clear();
00361        appPrefs.pageSets.append(pageS);
00362        pageS.Name = CommonStrings::pageSet2;
00363        pageS.FirstPage = 1;
00364        pageS.Columns = 2;
00365        pageS.pageNames.clear();
00366        pageS.pageNames.append(CommonStrings::pageLocLeft);
00367        pageS.pageNames.append(CommonStrings::pageLocRight);
00368        appPrefs.pageSets.append(pageS);
00369        pageS.Name = CommonStrings::pageSet3;
00370        pageS.FirstPage = 0;
00371        pageS.Columns = 3;
00372        pageS.pageNames.clear();
00373        pageS.pageNames.append(CommonStrings::pageLocLeft);
00374        pageS.pageNames.append(CommonStrings::pageLocMiddle);
00375        pageS.pageNames.append(CommonStrings::pageLocRight);
00376        appPrefs.pageSets.append(pageS);
00377        pageS.Name = CommonStrings::pageSet4;
00378        pageS.FirstPage = 0;
00379        pageS.Columns = 4;
00380        pageS.pageNames.clear();
00381        pageS.pageNames.append(CommonStrings::pageLocLeft);
00382        pageS.pageNames.append(CommonStrings::pageLocMiddleLeft);
00383        pageS.pageNames.append(CommonStrings::pageLocMiddleRight);
00384        pageS.pageNames.append(CommonStrings::pageLocRight);
00385        appPrefs.pageSets.append(pageS);
00386        appPrefs.FacingPages = singlePage;
00387        appPrefs.askBeforeSubstituite = true;
00388        appPrefs.haveStylePreview = true;
00389        // lorem ipsum defaults
00390        appPrefs.useStandardLI = false;
00391        appPrefs.paragraphsLI = 10;
00392        appPrefs.showStartupDialog = true;
00393        initDefaultCheckerPrefs(&appPrefs.checkerProfiles);
00394        appPrefs.curCheckProfile = tr("PostScript");
00395        appPrefs.PDF_Options.Thumbnails = false;
00396        appPrefs.PDF_Options.Articles = false;
00397        appPrefs.PDF_Options.useLayers = false;
00398        appPrefs.PDF_Options.Compress = true;
00399        appPrefs.PDF_Options.CompressMethod = 0;
00400        appPrefs.PDF_Options.Quality = 0;
00401        appPrefs.PDF_Options.RecalcPic = false;
00402        appPrefs.PDF_Options.Bookmarks = false;
00403        appPrefs.PDF_Options.PicRes = 300;
00404        appPrefs.PDF_Options.Version = PDFOptions::PDFVersion_14;
00405        appPrefs.PDF_Options.Resolution = 300;
00406        appPrefs.PDF_Options.Binding = 0;
00407        appPrefs.PDF_Options.EmbedList.clear();
00408        appPrefs.PDF_Options.SubsetList.clear();
00409        appPrefs.PDF_Options.MirrorH = false;
00410        appPrefs.PDF_Options.MirrorV = false;
00411        appPrefs.PDF_Options.doClip = false;
00412        appPrefs.PDF_Options.RotateDeg = 0;
00413        appPrefs.PDF_Options.PresentMode = false;
00414        appPrefs.PDF_Options.Datei = "";
00415        appPrefs.PDF_Options.PresentVals.clear();
00416        appPrefs.PDF_Options.isGrayscale = false;
00417        appPrefs.PDF_Options.UseRGB = true;
00418        appPrefs.PDF_Options.UseProfiles = false;
00419        appPrefs.PDF_Options.UseProfiles2 = false;
00420        appPrefs.PDF_Options.SolidProf = "";
00421        appPrefs.PDF_Options.SComp = 3;
00422        appPrefs.PDF_Options.ImageProf = "";
00423        appPrefs.PDF_Options.PrintProf = "";
00424        appPrefs.PDF_Options.Info = "";
00425        appPrefs.PDF_Options.Intent = 0;
00426        appPrefs.PDF_Options.Intent2 = 0;
00427        appPrefs.PDF_Options.bleeds.Top = 0;
00428        appPrefs.PDF_Options.bleeds.Left = 0;
00429        appPrefs.PDF_Options.bleeds.Right = 0;
00430        appPrefs.PDF_Options.bleeds.Bottom = 0;
00431        appPrefs.PDF_Options.useDocBleeds = false;
00432        appPrefs.PDF_Options.cropMarks = false;
00433        appPrefs.PDF_Options.bleedMarks = false;
00434        appPrefs.PDF_Options.registrationMarks = false;
00435        appPrefs.PDF_Options.colorMarks = false;
00436        appPrefs.PDF_Options.docInfoMarks = false;
00437        appPrefs.PDF_Options.markOffset = 0;
00438        appPrefs.PDF_Options.EmbeddedI = false;
00439        appPrefs.PDF_Options.Encrypt = false;
00440        appPrefs.PDF_Options.PassOwner = "";
00441        appPrefs.PDF_Options.PassUser = "";
00442        appPrefs.PDF_Options.Permissions = -4;
00443        appPrefs.PDF_Options.UseLPI = false;
00444        appPrefs.PDF_Options.LPISettings.clear();
00445        appPrefs.PDF_Options.UseSpotColors = true;
00446        appPrefs.PDF_Options.doOverprint = false;
00447        appPrefs.PDF_Options.doMultiFile = false;
00448        appPrefs.PDF_Options.displayBookmarks = false;
00449        appPrefs.PDF_Options.displayFullscreen = false;
00450        appPrefs.PDF_Options.displayLayers = false;
00451        appPrefs.PDF_Options.displayThumbs = false;
00452        appPrefs.PDF_Options.hideMenuBar = false;
00453        appPrefs.PDF_Options.hideToolBar = false;
00454        appPrefs.PDF_Options.fitWindow = false;
00455        appPrefs.PDF_Options.PageLayout = PDFOptions::SinglePage;
00456        appPrefs.PDF_Options.openAction = "";
00457 
00458        //Attribute setup
00459        appPrefs.defaultItemAttributes.clear();
00460        appPrefs.defaultToCSetups.clear();
00461        
00462        initDefaultActionKeys();
00463 }
00464 
00465 void PrefsManager::initDefaultActionKeys()
00466 {
00467        ActionManager::createDefaultShortcuts();
00468        QMap<QString, QKeySequence > *map=ActionManager::defaultShortcuts();
00469        for( QMap<QString, QKeySequence >::ConstIterator it = map->begin(); it!=map->end(); ++it )
00470        {
00471               appPrefs.KeyActions[it.key()].actionName = it.key();
00472               appPrefs.KeyActions[it.key()].keySequence = it.data();
00473        }
00474 }
00475 
00476 void PrefsManager::initDefaultGUIFont(const QFont& guiFont)
00477 {
00478        appPrefs.AppFontSize = guiFont.pointSize();
00479        appPrefs.STEfont = guiFont.toString();
00480        appPrefs.PaletteFontSize = appPrefs.AppFontSize;
00481 }
00482 
00483 void PrefsManager::initArrowStyles()
00484 {
00485        struct ArrowDesc arrow;
00486        FPointArray points;
00487        QWMatrix arrowScaling;
00488        arrowScaling.scale(0.5, 0.5);
00489        arrow.name = "Arrow1L";
00490        arrow.userArrow = false;
00491        points.addQuadPoint(0, 0, 0, 0, 0, 0, 0, 0);
00492        points.addQuadPoint(-5, -5, -5, -5, -5, -5, -5, -5);
00493        points.addQuadPoint(12, 0, 12, 0, 12, 0, 12, 0);
00494        points.addQuadPoint(-5, 5, -5, 5, -5, 5, -5, 5);
00495        points.addQuadPoint(0, 0, 0, 0, 0, 0, 0, 0);
00496        arrow.points = points.copy();
00497        appPrefs.arrowStyles.append(arrow);
00498        arrow.name = "Arrow1M";
00499        points.map(arrowScaling);
00500        arrow.points = points.copy();
00501        appPrefs.arrowStyles.append(arrow);
00502        arrow.name = "Arrow1S";
00503        points.map(arrowScaling);
00504        arrow.points = points.copy();
00505        appPrefs.arrowStyles.append(arrow);
00506        arrow.name = "SquareL";
00507        points.resize(0);
00508        points.addQuadPoint(-5, -5, -5, -5, -5, -5, -5, -5);
00509        points.addQuadPoint(5, -5, 5, -5, 5, -5, 5, -5);
00510        points.addQuadPoint(5, 5, 5, 5, 5, 5, 5, 5);
00511        points.addQuadPoint(-5, 5, -5, 5, -5, 5, -5, 5);
00512        points.addQuadPoint(-5, -5, -5, -5, -5, -5, -5, -5);
00513        arrow.points = points.copy();
00514        appPrefs.arrowStyles.append(arrow);
00515        arrow.name = "SquareM";
00516        points.map(arrowScaling);
00517        arrow.points = points.copy();
00518        appPrefs.arrowStyles.append(arrow);
00519        arrow.name = "SquareS";
00520        points.map(arrowScaling);
00521        arrow.points = points.copy();
00522        appPrefs.arrowStyles.append(arrow);
00523        arrow.name = "TriangleInL";
00524        points.resize(0);
00525        points.addQuadPoint(5.77, 0, 5.77, 0, 5.77, 0, 5.77, 0);
00526        points.addQuadPoint(-2.88, 5, -2.88, 5, -2.88, 5, -2.88, 5);
00527        points.addQuadPoint(-2.88, -5, -2.88, -5, -2.88, -5, -2.88, -5);
00528        points.addQuadPoint(5.77, 0, 5.77, 0, 5.77, 0, 5.77, 0);
00529        arrow.points = points.copy();
00530        appPrefs.arrowStyles.append(arrow);
00531        arrow.name = "TriangleInM";
00532        points.map(arrowScaling);
00533        arrow.points = points.copy();
00534        appPrefs.arrowStyles.append(arrow);
00535        arrow.name = "TriangleInS";
00536        points.map(arrowScaling);
00537        arrow.points = points.copy();
00538        appPrefs.arrowStyles.append(arrow);
00539        arrow.name = "TriangleOutL";
00540        points.resize(0);
00541        points.addQuadPoint(-5.77, 0, -5.77, 0, -5.77, 0, -5.77, 0);
00542        points.addQuadPoint(2.88, 5, 2.88, 5, 2.88, 5, 2.88, 5);
00543        points.addQuadPoint(2.88, -5, 2.88, -5, 2.88, -5, 2.88, -5);
00544        points.addQuadPoint(-5.77, 0, -5.77, 0, -5.77, 0, -5.77, 0);
00545        arrow.points = points.copy();
00546        appPrefs.arrowStyles.append(arrow);
00547        arrow.name = "TriangleOutM";
00548        points.map(arrowScaling);
00549        arrow.points = points.copy();
00550        appPrefs.arrowStyles.append(arrow);
00551        arrow.name = "TriangleOutS";
00552        points.map(arrowScaling);
00553        arrow.points = points.copy();
00554        appPrefs.arrowStyles.append(arrow);
00555 }
00556 
00557 QString PrefsManager::setupPreferencesLocation()
00558 {
00559        QString Pff = QDir::convertSeparators(ScPaths::getApplicationDataDir());
00560        QFileInfo Pffi = QFileInfo(Pff);
00561        QString PrefsPfad;
00562        //If we are using ~/.scribus
00563        if (Pffi.exists())
00564        {
00565               if (Pffi.isDir())
00566                      PrefsPfad = Pff;
00567               else
00568                      PrefsPfad = QDir::homeDirPath();
00569        }
00570        else // Move to using ~/.scribus/scribus.* from ~/.scribus.*
00571        {
00572               QDir prefsDirectory = QDir();
00573               prefsDirectory.mkdir(Pff);
00574               PrefsPfad = Pff;
00575               QString oldPR = QDir::convertSeparators(QDir::homeDirPath()+"/.scribus.rc");
00576               QFileInfo oldPi = QFileInfo(oldPR);
00577               if (oldPi.exists())
00578                      moveFile(oldPR, Pff+"/scribus.rc");
00579               QString oldPR2 = QDir::convertSeparators(QDir::homeDirPath()+"/.scribusfont.rc");
00580               QFileInfo oldPi2 = QFileInfo(oldPR2);
00581               if (oldPi2.exists())
00582                      moveFile(oldPR2, Pff+"/scribusfont.rc");
00583               QString oldPR3 = QDir::convertSeparators(QDir::homeDirPath()+"/.scribusscrap.scs");
00584               QFileInfo oldPi3 = QFileInfo(oldPR3);
00585               if (oldPi3.exists())
00586                      moveFile(oldPR3, Pff+"/scrap.scs");
00587        }
00588        QString scB = QDir::convertSeparators(Pff+"/scrapbook");
00589        QFileInfo scBi = QFileInfo(scB);
00590        if (!scBi.exists())
00591        {
00592               QDir scrapDirectory = QDir();
00593               scrapDirectory.mkdir(scB);
00594               QDir scrapMainDirectory = QDir();
00595               scrapDirectory.mkdir(QDir::convertSeparators(scB+"/main"));
00596        }
00597        QFileInfo scTmp = QFileInfo(QDir::convertSeparators(scB+"/tmp"));
00598        if (!scTmp.exists())
00599        {
00600               QDir scrapDirectoryT = QDir();
00601               scrapDirectoryT.mkdir(QDir::convertSeparators(scB+"/tmp"));
00602        }
00603        prefsLocation=PrefsPfad;
00604        return PrefsPfad;
00605 }
00606 
00607 const QString PrefsManager::preferencesLocation()
00608 {
00609        return prefsLocation;
00610 }
00611 
00612 bool PrefsManager::copyOldPreferences()
00613 {
00614        //Now make copies for 1.3 use and leave the old ones alone for <1.3.0 usage
00615        QString prefs12[4], prefs130[4], prefs134[4];
00616 
00617        // Special case for scribus.rc - if found, use scribus123.rc,
00618        // otherwise fall back to the possibly mis-encoded scribus.rc .
00619        prefs12[0]=QDir::convertSeparators(prefsLocation+"/scribus123.rc");
00620        if (!QFile::exists(prefs12[0]))
00621               prefs12[0] = prefsLocation+"/scribus.rc";
00622 
00623        prefs12[1]=QDir::convertSeparators(prefsLocation+"/scrap.scs");
00624        prefs12[2]=QDir::convertSeparators(prefsLocation+"/prefs.xml");
00625        prefs12[3]=QDir::convertSeparators(prefsLocation+"/scripter.rc");
00626        prefs130[0]=QDir::convertSeparators(prefsLocation+"/scribus13.rc");
00627        prefs130[1]=QDir::convertSeparators(prefsLocation+"/scrap13.scs");
00628        prefs130[2]=QDir::convertSeparators(prefsLocation+"/prefs13.xml");
00629        prefs130[3]=QDir::convertSeparators(prefsLocation+"/scripter13.rc");
00630        prefs134[0]=QDir::convertSeparators(prefsLocation+"/scribus134.rc");
00631        prefs134[1]=QDir::convertSeparators(prefsLocation+"/scrap134.scs");
00632        prefs134[2]=QDir::convertSeparators(prefsLocation+"/prefs134.xml");
00633        prefs134[3]=QDir::convertSeparators(prefsLocation+"/scripter134.rc");
00634 
00635        bool existsPrefs12[4], existsPrefs130[4], existsPrefs134[4];
00636        for (uint i=0;i<4;++i)
00637        {
00638               existsPrefs12[i]=QFile::exists(prefs12[i]);
00639               existsPrefs130[i]=QFile::exists(prefs130[i]);
00640               existsPrefs134[i]=QFile::exists(prefs134[i]);
00641        }
00642 
00643        bool retVal=false;
00644        if (existsPrefs134[0] && existsPrefs134[2])
00645               return retVal;
00646        //Only check for these two as they will be autocreated if they dont exist.
00647        if( (existsPrefs12[0] && !existsPrefs130[0]) || (existsPrefs12[2] && !existsPrefs130[2]) )
00648        {
00649               retVal=true; // converting from 1.2 prefs
00650               if (ScCore->usingGUI())
00651               {
00652                      bool splashShown=ScCore->splashShowing();
00653                      if (splashShown)
00654                             ScCore->showSplash(false);
00655                      if ( (ScMessageBox::question( ScCore->primaryMainWindow(), tr("Migrate Old Scribus Settings?"),
00656                             tr("Scribus has detected existing Scribus 1.2 preferences files.\n"
00657                                           "Do you want to migrate them to the new Scribus version?"),
00658                             QMessageBox::Yes | QMessageBox::Default, QMessageBox::No, QMessageBox::NoButton))==QMessageBox::Yes )
00659                      {
00660                             for (uint i=0;i<4;++i)
00661                             {
00662                                    if (existsPrefs12[i] && !existsPrefs134[i])
00663                                           copyFile(prefs12[i], prefs134[i]);
00664                             }
00665                      }
00666                      if (splashShown)
00667                             ScCore->showSplash(true);
00668               }
00669        }
00670        else
00671        if(existsPrefs130[0])
00672        {
00673               for (uint i=0;i<4;++i)
00674               {
00675                      if (existsPrefs130[i] && !existsPrefs134[i])
00676                             copyFile(prefs130[i], prefs134[i]);
00677               }
00678        }
00679        return retVal;
00680 }
00681 
00682 void PrefsManager::convert12Preferences()
00683 {
00684        // Import 1.2 font search path prefs
00685        QFile fontPrefsFile12(QDir::convertSeparators(prefsLocation+"/scribusfont.rc"));
00686        if (fontPrefsFile12.open(IO_ReadOnly))
00687        {
00688               PrefsContext *pc = prefsFile->getContext("Fonts");
00689               PrefsTable *fontPrefs = pc->getTable("ExtraFontDirs");
00690               QTextStream tsx(&fontPrefsFile12);
00691               QString extraPath = tsx.read();
00692               fontPrefsFile12.close();
00693               QStringList extraFonts = QStringList::split("\n",extraPath);
00694               for (uint i = 0; i < extraFonts.count(); ++i)
00695                      fontPrefs->set(i, 0, extraFonts[i]);
00696        }
00697 }
00698 
00699 void PrefsManager::ReadPrefs(const QString & fname)
00700 {
00701        QString realFile;
00702        if (fname.isNull())
00703               realFile = prefsLocation + "/scribus134.rc";
00704        else
00705               realFile = fname;
00706 
00707        if (QFile::exists(realFile))
00708        {
00709               if (!ReadPref(realFile))
00710               {
00711                      alertLoadPrefsFailed();
00712                      return;
00713               }
00714        }
00715 }
00716 
00717 void PrefsManager::setupMainWindow(ScribusMainWindow* mw)
00718 {
00719        mw->setDefaultPrinter(appPrefs.PrinterName, appPrefs.PrinterFile, appPrefs.PrinterCommand);
00720 
00721        uint max = QMIN(appPrefs.RecentDCount, appPrefs.RecentDocs.count());
00722        for (uint m = 0; m < max; ++m)
00723        {
00724               QFileInfo fd(appPrefs.RecentDocs[m]);
00725               if (fd.exists())
00726               {
00727                      mw->RecentDocs.append(appPrefs.RecentDocs[m]);
00728                      ScCore->fileWatcher->addFile(appPrefs.RecentDocs[m]);
00729               }
00730        }
00731        mw->rebuildRecentFileMenu();
00732        mw->move(appPrefs.mainWinSettings.xPosition, appPrefs.mainWinSettings.yPosition);
00733        mw->resize(appPrefs.mainWinSettings.width, appPrefs.mainWinSettings.height);
00734        if (appPrefs.mainWinSettings.maximized)
00735               mw->setWindowState(ScCore->primaryMainWindow()->windowState() & ~Qt::WindowMinimized | Qt::WindowMaximized);
00736        ReadPrefsXML();
00737        if (appPrefs.checkerProfiles.count() == 0)
00738        {
00739               initDefaultCheckerPrefs(&appPrefs.checkerProfiles);
00740               appPrefs.curCheckProfile = tr("PostScript");
00741        }
00742 }
00743 
00744 void PrefsManager::ReadPrefsXML()
00745 {
00746     if (prefsFile)
00747     {
00748         PrefsContext* userprefsContext = prefsFile->getContext("user_preferences");
00749         if (userprefsContext) {
00750             appPrefs.guiLanguage = userprefsContext->get("gui_language","");
00751             //continue here...
00752             //Prefs."blah blah" =...
00753         }
00754     }
00755 }
00756 
00757 
00758 void PrefsManager::SavePrefs(const QString & fname)
00759 {
00760        // If closing because of a crash don't save prefs as we can
00761        // accidentally nuke the settings if the crash is before prefs are loaded
00762        // The caller is responsible for ensuring we aren't called under those
00763        // conditions.
00764        Q_ASSERT(!emergencyActivated);
00765        appPrefs.mainWinSettings.xPosition = abs(ScCore->primaryMainWindow()->pos().x());
00766        appPrefs.mainWinSettings.yPosition = abs(ScCore->primaryMainWindow()->pos().y());
00767        appPrefs.mainWinSettings.width = ScCore->primaryMainWindow()->size().width();
00768        appPrefs.mainWinSettings.height = ScCore->primaryMainWindow()->size().height();
00769        appPrefs.mainWinSettings.maximized = ScCore->primaryMainWindow()->isMaximized();
00770 
00771        appPrefs.RecentDocs.clear();
00772        uint max = QMIN(appPrefs.RecentDCount, ScCore->primaryMainWindow()->RecentDocs.count());
00773        for (uint m = 0; m < max; ++m)
00774        {
00775               appPrefs.RecentDocs.append(ScCore->primaryMainWindow()->RecentDocs[m]);
00776        }
00777        ScCore->primaryMainWindow()->getDefaultPrinter(&appPrefs.PrinterName, &appPrefs.PrinterFile, &appPrefs.PrinterCommand);
00778        SavePrefsXML();
00779        QString realFile;
00780        if (fname.isNull())
00781               realFile = prefsLocation+"/scribus134.rc";
00782        else
00783               realFile = fname;
00784        if (!WritePref(realFile))
00785               alertSavePrefsFailed();
00786        emit prefsChanged();
00787 }
00788 
00789 void PrefsManager::SavePrefsXML()
00790 {
00791     if (prefsFile)
00792     {
00793         PrefsContext* userprefsContext = prefsFile->getContext("user_preferences");
00794         if (userprefsContext) {
00795             userprefsContext->set("gui_language",appPrefs.guiLanguage);
00796             //continue here...
00797             //Prefs."blah blah" =...
00798         }
00799         prefsFile->write();
00800     }
00801 }
00802 
00803 void PrefsManager::setGhostscriptExecutable(const QString& executableName)
00804 {
00805        appPrefs.gs_exe=executableName;
00806 }
00807 
00808 void PrefsManager::setImageEditorExecutable(const QString& executableName)
00809 {
00810        appPrefs.imageEditorExecutable=executableName;
00811 }
00812 
00813 void PrefsManager::setExtBrowserExecutable(const QString& executableName)
00814 {
00815        appPrefs.extBrowserExecutable=executableName;
00816 }
00817 
00818 const QString PrefsManager::documentDir()
00819 {
00820        return appPrefs.DocDir;
00821 }
00822 
00823 void PrefsManager::setDocumentDir(const QString& dirname)
00824 {
00825        appPrefs.DocDir = dirname;
00826 }
00827 
00828 const int PrefsManager::mouseWheelValue()
00829 {
00830        return appPrefs.Wheelval;
00831 }
00832 
00833 //Changed to return false when we have no fonts
00834 bool PrefsManager::GetAllFonts(bool showFontInfo)
00835 {
00836        appPrefs.AvailFonts.GetFonts(prefsLocation, showFontInfo);
00837        return !appPrefs.AvailFonts.isEmpty();
00838 }
00839 
00840 void PrefsManager::setShowStartupDialog(const bool showDialog)
00841 {
00842        appPrefs.showStartupDialog=showDialog;
00843 }
00844 
00845 const ColorList& PrefsManager::colorSet()
00846 {
00847        return appPrefs.DColors;
00848 }
00849 
00850 ColorList* PrefsManager::colorSetPtr()
00851 {
00852        return &appPrefs.DColors;
00853 }
00854 
00855 const QString& PrefsManager::colorSetName()
00856 {
00857        return appPrefs.DColorSet;
00858 }
00859 
00860 bool PrefsManager::isToolColor(const QString& name)
00861 {
00862        return isToolColor(appPrefs.toolSettings, name);
00863 }
00864 
00865 bool PrefsManager::isToolColor(const struct toolPrefs& settings, const QString& name)
00866 {
00867        if (settings.dPenText == name)
00868               return true;
00869        if (settings.dStrokeText == name)
00870               return true;
00871        if (settings.dTextBackGround == name)
00872               return true;
00873        if (settings.dTextLineColor == name)
00874               return true;
00875        if (settings.dPen == name)
00876               return true;
00877        if (settings.dBrush == name)
00878               return true;
00879        if (settings.dPenLine == name)
00880               return true;
00881        if (settings.dBrushPict == name)
00882               return true;
00883        return false;
00884 }
00885 
00886 QStringList PrefsManager::toolColorNames()
00887 {
00888        return toolColorNames(appPrefs.toolSettings);
00889 }
00890 
00891 QStringList PrefsManager::toolColorNames(const struct toolPrefs& settings)
00892 {
00893        QStringList names;
00894        names.append(settings.dPenText);
00895        if (!names.contains(settings.dStrokeText))
00896               names.append(settings.dStrokeText);
00897        if (!names.contains(settings.dTextBackGround))
00898               names.append(settings.dTextBackGround);
00899        if (!names.contains(settings.dTextLineColor))
00900               names.append(settings.dTextLineColor);
00901        if (!names.contains(settings.dPen))
00902               names.append(settings.dPen);
00903        if (!names.contains(settings.dBrush))
00904               names.append(settings.dBrush);
00905        if (!names.contains(settings.dPenLine))
00906               names.append(settings.dPenLine);
00907        if (!names.contains(settings.dBrushPict))
00908               names.append(settings.dBrushPict);
00909        return names;
00910 }
00911 
00912 void PrefsManager::replaceToolColors(const QMap<QString, QString> replaceMap)
00913 {
00914        replaceToolColors(appPrefs.toolSettings, replaceMap);
00915 }
00916 
00917 void PrefsManager::replaceToolColors(struct toolPrefs& settings, const QMap<QString, QString> replaceMap)
00918 {
00919        if (replaceMap.contains(settings.dPenText))
00920               settings.dPenText = replaceMap[settings.dPenText];
00921        if (replaceMap.contains(settings.dStrokeText))
00922               settings.dStrokeText = replaceMap[settings.dStrokeText];
00923        if (replaceMap.contains(settings.dTextBackGround))
00924               settings.dTextBackGround = replaceMap[settings.dTextBackGround];
00925        if (replaceMap.contains(settings.dTextLineColor))
00926               settings.dTextLineColor = replaceMap[settings.dTextLineColor];
00927        if (replaceMap.contains(settings.dPen))
00928               settings.dPen = replaceMap[settings.dPen];
00929        if (replaceMap.contains(settings.dBrush))
00930               settings.dBrush = replaceMap[settings.dBrush];
00931        if (replaceMap.contains(settings.dPenLine))
00932               settings.dPenLine = replaceMap[settings.dPenLine];
00933        if (replaceMap.contains(settings.dBrushPict))
00934               settings.dBrushPict = replaceMap[settings.dBrushPict];
00935 }
00936 
00937 void PrefsManager::setColorSet(const ColorList& colorSet)
00938 {
00939        // Color set may have changed and tools color not be present in the new color set
00940        ColorList tmpSet = colorSet;
00941        QString penText = appPrefs.toolSettings.dPenText;
00942        if (!tmpSet.contains(penText) && penText != CommonStrings::None)
00943               tmpSet[penText] = appPrefs.DColors[penText];
00944        QString strokeText = appPrefs.toolSettings.dStrokeText;
00945        if (!tmpSet.contains(strokeText) && strokeText != CommonStrings::None)
00946               tmpSet[strokeText] = appPrefs.DColors[strokeText];
00947        QString textBackGround = appPrefs.toolSettings.dTextBackGround;
00948        if (!tmpSet.contains(textBackGround) && textBackGround != CommonStrings::None)
00949               tmpSet[textBackGround] = appPrefs.DColors[textBackGround];
00950        QString textLineColor = appPrefs.toolSettings.dTextLineColor;
00951        if (!tmpSet.contains(textLineColor) && textLineColor != CommonStrings::None)
00952               tmpSet[textLineColor] = appPrefs.DColors[textLineColor];
00953        QString pen = appPrefs.toolSettings.dPen;
00954        if (!tmpSet.contains(pen) && pen != CommonStrings::None)
00955               tmpSet[pen] = appPrefs.DColors[pen];
00956        QString brush = appPrefs.toolSettings.dBrush;
00957        if (!tmpSet.contains(brush) && brush != CommonStrings::None)
00958               tmpSet[brush] = appPrefs.DColors[brush];
00959        QString penLine = appPrefs.toolSettings.dPenLine;
00960        if (!tmpSet.contains(penLine) && penLine != CommonStrings::None)
00961               tmpSet[penLine] = appPrefs.DColors[penLine];
00962        QString brushPict = appPrefs.toolSettings.dBrushPict;
00963        if (!tmpSet.contains(brushPict) && brushPict != CommonStrings::None)
00964               tmpSet[brushPict] = appPrefs.DColors[brushPict];
00965        appPrefs.DColors = tmpSet;
00966 }
00967 
00968 void PrefsManager::setColorSetName(const QString& colorSetName)
00969 {
00970        appPrefs.DColorSet=colorSetName;
00971 }
00972 
00973 
00974 void PrefsManager::setKeyEntry(const QString& actName, const QString& cleanMenuText, const QKeySequence& keyseq, const int& rowNumber)
00975 {
00976        Keys ke;
00977        if (!actName.isEmpty())
00978        {
00979               if (ScCore->primaryMainWindow()->scrActions[actName])
00980               {
00981                      ke.actionName=actName;
00982                      ke.keySequence = keyseq;
00983                      ke.cleanMenuText=cleanMenuText;
00984                      ke.tableRow=rowNumber;
00985                      appPrefs.KeyActions.insert(actName, ke);
00986               }
00987               else
00988                      qDebug("%s", QString("Action Name: %1 does not exist").arg(actName).ascii());
00989        }
00990 }
00991 
00992 const double PrefsManager::displayScale()
00993 {
00994        return appPrefs.DisScale;
00995 }
00996 
00997 const QString& PrefsManager::guiLanguage()
00998 {
00999        return appPrefs.guiLanguage;
01000 }
01001 
01002 const QString& PrefsManager::guiStyle()
01003 {
01004        return appPrefs.GUI;
01005 }
01006 
01007 const int& PrefsManager::guiFontSize()
01008 {
01009        return appPrefs.AppFontSize;
01010 }
01011 
01012 const int& PrefsManager::paletteFontSize()
01013 {
01014        return appPrefs.PaletteFontSize;
01015 }
01016 
01017 bool PrefsManager::WritePref(QString ho)
01018 {
01019        QDomDocument docu("scribusrc");
01020        QString st="<SCRIBUSRC></SCRIBUSRC>";
01021        docu.setContent(st);
01022        QDomElement elem=docu.documentElement();
01023        QDomElement dc=docu.createElement("GUI");
01024        dc.setAttribute("STILT",appPrefs.GUI);
01025        dc.setAttribute("RAD",appPrefs.Wheelval);
01026        dc.setAttribute("MOVT", appPrefs.moveTimeout);
01027        dc.setAttribute("APF",appPrefs.AppFontSize);
01028        dc.setAttribute("PFS",appPrefs.PaletteFontSize);
01029        dc.setAttribute("GRAB",appPrefs.guidesSettings.grabRad);
01030        dc.setAttribute("UNIT",appPrefs.docUnitIndex);
01031        dc.setAttribute("RCD", appPrefs.RecentDCount);
01032        dc.setAttribute("DOC", appPrefs.DocDir);
01033        dc.setAttribute("PROFILES", appPrefs.ProfileDir);
01034        dc.setAttribute("SCRIPTS", appPrefs.ScriptDir);
01035        dc.setAttribute("TEMPLATES", appPrefs.documentTemplatesDir);
01036        dc.setAttribute("SHOWGUIDES", static_cast<int>(appPrefs.guidesSettings.guidesShown));
01037        dc.setAttribute("showcolborders", static_cast<int>(appPrefs.guidesSettings.colBordersShown));
01038        dc.setAttribute("FRV", static_cast<int>(appPrefs.guidesSettings.framesShown));
01039        dc.setAttribute("SHOWLAYERM", static_cast<int>(appPrefs.guidesSettings.layerMarkersShown));
01040        dc.setAttribute("SHOWMARGIN", static_cast<int>(appPrefs.guidesSettings.marginsShown));
01041        dc.setAttribute("SHOWBASE", static_cast<int>(appPrefs.guidesSettings.baseShown));
01042        dc.setAttribute("SHOWLINK", static_cast<int>(appPrefs.guidesSettings.linkShown));
01043        dc.setAttribute("SHOWPICT", static_cast<int>(appPrefs.guidesSettings.showPic));
01044        dc.setAttribute("SHOWControl", static_cast<int>(appPrefs.guidesSettings.showControls));
01045        dc.setAttribute("rulersShown", static_cast<int>(appPrefs.guidesSettings.rulersShown));
01046        dc.setAttribute("showBleed", static_cast<int>(appPrefs.guidesSettings.showBleed));
01047        dc.setAttribute("rulerMode", static_cast<int>(appPrefs.guidesSettings.rulerMode));
01048        dc.setAttribute("ScratchBottom", appPrefs.scratch.Bottom);
01049        dc.setAttribute("ScratchLeft", appPrefs.scratch.Left);
01050        dc.setAttribute("ScratchRight", appPrefs.scratch.Right);
01051        dc.setAttribute("ScratchTop", appPrefs.scratch.Top);
01052        dc.setAttribute("STECOLOR", appPrefs.STEcolor.name());
01053        dc.setAttribute("STEFONT", appPrefs.STEfont);
01054        dc.setAttribute("STYLEPREVIEW", static_cast<int>(appPrefs.haveStylePreview));
01055        dc.setAttribute("StartUp", static_cast<int>(appPrefs.showStartupDialog));
01056        dc.setAttribute("ToolTips", static_cast<int>(appPrefs.showToolTips));
01057        dc.setAttribute("stickyTools", static_cast<int>(appPrefs.stickyTools));
01058        elem.appendChild(dc);
01059        QDomElement dc1=docu.createElement("GRID");
01060        dc1.setAttribute("MINOR",appPrefs.guidesSettings.minorGrid);
01061        dc1.setAttribute("MAJOR",appPrefs.guidesSettings.majorGrid);
01062        dc1.setAttribute("MINORC",appPrefs.guidesSettings.minorColor.name());
01063        dc1.setAttribute("MAJORC",appPrefs.guidesSettings.majorColor.name());
01064        dc1.setAttribute("GuideC", appPrefs.guidesSettings.guideColor.name());
01065        dc1.setAttribute("BaseC", appPrefs.guidesSettings.baseColor.name());
01066        dc1.setAttribute("GuideZ", appPrefs.guidesSettings.guideRad);
01067        dc1.setAttribute("BACKG", static_cast<int>(appPrefs.guidesSettings.before));
01068        dc1.setAttribute("SHOW", static_cast<int>(appPrefs.guidesSettings.gridShown));
01069        elem.appendChild(dc1);
01070        QDomElement dc1a=docu.createElement("PAGE");
01071        dc1a.setAttribute("PAGEC",appPrefs.DpapColor.name());
01072        dc1a.setAttribute("SELEC",appPrefs.DFrameColor.name());
01073        dc1a.setAttribute("DFrameNormColor",appPrefs.DFrameNormColor.name());
01074        dc1a.setAttribute("DFrameGroupColor",appPrefs.DFrameGroupColor.name());
01075        dc1a.setAttribute("DFrameLockColor",appPrefs.DFrameLockColor.name());
01076        dc1a.setAttribute("DFrameLinkColor",appPrefs.DFrameLinkColor.name());
01077        dc1a.setAttribute("DFrameAnnotationColor",appPrefs.DFrameAnnotationColor.name());
01078        dc1a.setAttribute("DPageBorderColor",appPrefs.DPageBorderColor.name());
01079        dc1a.setAttribute("DControlCharColor",appPrefs.DControlCharColor.name());
01080        dc1a.setAttribute("MARGC",appPrefs.guidesSettings.margColor.name());
01081        dc1a.setAttribute("RANDF", static_cast<int>(appPrefs.marginColored));
01082        dc1a.setAttribute("DScale",appPrefs.DisScale);
01083        elem.appendChild(dc1a);
01084        QDomElement dc2=docu.createElement("FONTS");
01085        dc2.setAttribute("FACE",appPrefs.toolSettings.defFont);
01086        dc2.setAttribute("SIZE",appPrefs.toolSettings.defSize / 10.0);
01087        dc2.setAttribute("AutomaticSubst", static_cast<int>(appPrefs.askBeforeSubstituite));
01088        elem.appendChild(dc2);
01089        QDomElement dc3=docu.createElement("TYPO");
01090        dc3.setAttribute("TIEF",appPrefs.typographicSettings.valueSubScript);
01091        dc3.setAttribute("TIEFSC",appPrefs.typographicSettings.scalingSubScript);
01092        dc3.setAttribute("HOCH",appPrefs.typographicSettings.valueSuperScript);
01093        dc3.setAttribute("HOCHSC",appPrefs.typographicSettings.scalingSuperScript);
01094        dc3.setAttribute("SMCAPS",appPrefs.typographicSettings.valueSmallCaps);
01095        dc3.setAttribute("AUTOL", appPrefs.typographicSettings.autoLineSpacing);
01096        dc3.setAttribute("BASE", appPrefs.typographicSettings.valueBaseGrid);
01097        dc3.setAttribute("BASEO", appPrefs.typographicSettings.offsetBaseGrid);
01098        if (appPrefs.typographicSettings.valueUnderlinePos == -1)
01099               dc3.setAttribute("UnderlinePos", appPrefs.typographicSettings.valueUnderlinePos);
01100        else
01101               dc3.setAttribute("UnderlinePos", appPrefs.typographicSettings.valueUnderlinePos / 10.0);
01102        if (appPrefs.typographicSettings.valueUnderlineWidth == -1)
01103               dc3.setAttribute("UnderlineWidth", appPrefs.typographicSettings.valueUnderlineWidth);
01104        else
01105               dc3.setAttribute("UnderlineWidth", appPrefs.typographicSettings.valueUnderlineWidth / 10.0);
01106        if (appPrefs.typographicSettings.valueStrikeThruPos == -1)
01107               dc3.setAttribute("StrikeThruPos", appPrefs.typographicSettings.valueStrikeThruPos);
01108        else
01109               dc3.setAttribute("StrikeThruPos", appPrefs.typographicSettings.valueStrikeThruPos / 10.0);
01110        if (appPrefs.typographicSettings.valueStrikeThruWidth == -1)
01111               dc3.setAttribute("StrikeThruWidth", appPrefs.typographicSettings.valueStrikeThruWidth);
01112        else
01113               dc3.setAttribute("StrikeThruWidth", appPrefs.typographicSettings.valueStrikeThruWidth / 10.0);
01114        elem.appendChild(dc3);
01115        QDomElement dc9=docu.createElement("TOOLS");
01116        dc9.setAttribute("PEN",appPrefs.toolSettings.dPen);
01117        dc9.setAttribute("BRUSH",appPrefs.toolSettings.dBrush);
01118        dc9.setAttribute("PENLINE",appPrefs.toolSettings.dPenLine);
01119        dc9.setAttribute("PENTEXT",appPrefs.toolSettings.dPenText);
01120        dc9.setAttribute("StrokeText",appPrefs.toolSettings.dStrokeText);
01121        dc9.setAttribute("TextBackGround", appPrefs.toolSettings.dTextBackGround);
01122        dc9.setAttribute("TextLineColor", appPrefs.toolSettings.dTextLineColor);
01123        dc9.setAttribute("TextBackGroundShade", appPrefs.toolSettings.dTextBackGroundShade);
01124        dc9.setAttribute("TextLineShade", appPrefs.toolSettings.dTextLineShade);
01125        dc9.setAttribute("TextPenShade", appPrefs.toolSettings.dTextPenShade);
01126        dc9.setAttribute("TextStrokeShade", appPrefs.toolSettings.dTextStrokeShade);
01127        dc9.setAttribute("TEXTCOL",appPrefs.toolSettings.dCols);
01128        dc9.setAttribute("TEXTGAP",appPrefs.toolSettings.dGap);
01129        dc9.setAttribute("TabWidth",appPrefs.toolSettings.dTabWidth);
01130        dc9.setAttribute("TabFill",appPrefs.toolSettings.tabFillChar);
01131        dc9.setAttribute("STIL",appPrefs.toolSettings.dLineArt);
01132        dc9.setAttribute("STILLINE",appPrefs.toolSettings.dLstyleLine);
01133        dc9.setAttribute("WIDTH",appPrefs.toolSettings.dWidth);
01134        dc9.setAttribute("WIDTHLINE",appPrefs.toolSettings.dWidthLine);
01135        dc9.setAttribute("PENSHADE",appPrefs.toolSettings.dShade2);
01136        dc9.setAttribute("LINESHADE",appPrefs.toolSettings.dShadeLine);
01137        dc9.setAttribute("BRUSHSHADE",appPrefs.toolSettings.dShade);
01138        dc9.setAttribute("MAGMIN",appPrefs.toolSettings.magMin);
01139        dc9.setAttribute("MAGMAX",appPrefs.toolSettings.magMax);
01140        dc9.setAttribute("MAGSTEP",appPrefs.toolSettings.magStep);
01141        dc9.setAttribute("CPICT",appPrefs.toolSettings.dBrushPict);
01142        dc9.setAttribute("PICTSHADE",appPrefs.toolSettings.shadePict);
01143        dc9.setAttribute("PICTSCX",appPrefs.toolSettings.scaleX);
01144        dc9.setAttribute("PICTSCY",appPrefs.toolSettings.scaleY);
01145        dc9.setAttribute("POLYC", appPrefs.toolSettings.polyC);
01146        dc9.setAttribute("POLYF", appPrefs.toolSettings.polyF);
01147        dc9.setAttribute("POLYR", appPrefs.toolSettings.polyR);
01148        dc9.setAttribute("POLYFD", appPrefs.toolSettings.polyFd);
01149        dc9.setAttribute("POLYS", static_cast<int>(appPrefs.toolSettings.polyS));
01150        dc9.setAttribute("PSCALE", static_cast<int>(appPrefs.toolSettings.scaleType));
01151        dc9.setAttribute("PASPECT", static_cast<int>(appPrefs.toolSettings.aspectRatio));
01152        dc9.setAttribute("EmbeddedPath", static_cast<int>(appPrefs.toolSettings.useEmbeddedPath));
01153        dc9.setAttribute("HalfRes", appPrefs.toolSettings.lowResType);
01154        dc9.setAttribute("StartArrow", appPrefs.toolSettings.dStartArrow);
01155        dc9.setAttribute("EndArrow", appPrefs.toolSettings.dEndArrow);
01156        dc9.setAttribute("dispX", appPrefs.toolSettings.dispX);
01157        dc9.setAttribute("dispY", appPrefs.toolSettings.dispY);
01158        dc9.setAttribute("constrain", appPrefs.toolSettings.constrain);
01159        elem.appendChild(dc9);
01160        QDomElement dc4=docu.createElement("MAINWINDOW");
01161        dc4.setAttribute("XPOS",appPrefs.mainWinSettings.xPosition);
01162        dc4.setAttribute("YPOS",appPrefs.mainWinSettings.yPosition);
01163        dc4.setAttribute("WIDTH",appPrefs.mainWinSettings.width);
01164        dc4.setAttribute("HEIGHT",appPrefs.mainWinSettings.height);
01165        dc4.setAttribute("MAXIMIZED",static_cast<int>(appPrefs.mainWinSettings.maximized));
01166        elem.appendChild(dc4);
01167        QDomElement dc73=docu.createElement("SCRAPBOOK");
01168        dc73.setAttribute("CopyToScrapbook",static_cast<int>(appPrefs.doCopyToScrapbook));
01169        dc73.setAttribute("persistentScrapbook",static_cast<int>(appPrefs.persistentScrapbook));
01170        dc73.setAttribute("numScrapbookCopies",appPrefs.numScrapbookCopies);
01171        for (uint rd=0; rd<appPrefs.RecentScrapbooks.count(); ++rd)
01172        {
01173               QDomElement rde=docu.createElement("RECENT");
01174               rde.setAttribute("NAME",appPrefs.RecentScrapbooks[rd]);
01175               dc73.appendChild(rde);
01176        }
01177        elem.appendChild(dc73);
01178        QDomElement dc75=docu.createElement("PAGEPALETTE");
01179        dc75.setAttribute("THUMBS", static_cast<int>(appPrefs.SepalT));
01180        dc75.setAttribute("NAMES", static_cast<int>(appPrefs.SepalN));
01181        elem.appendChild(dc75);
01182        QDomElement dc76=docu.createElement("DOKUMENT");
01183        dc76.setAttribute("PAGESIZE",appPrefs.pageSize);
01184        dc76.setAttribute("AUSRICHTUNG",appPrefs.pageOrientation);
01185        dc76.setAttribute("BREITE",appPrefs.PageWidth);
01186        dc76.setAttribute("HOEHE",appPrefs.PageHeight);
01187        dc76.setAttribute("RANDO",appPrefs.margins.Top);
01188        dc76.setAttribute("RANDU",appPrefs.margins.Bottom);
01189        dc76.setAttribute("RANDL",appPrefs.margins.Left);
01190        dc76.setAttribute("RANDR",appPrefs.margins.Right);
01191        dc76.setAttribute("DOPPEL", appPrefs.FacingPages);
01192        dc76.setAttribute("AutoSave", static_cast<int>(appPrefs.AutoSave));
01193        dc76.setAttribute("AutoSaveTime", appPrefs.AutoSaveTime);
01194        dc76.setAttribute("BleedTop", appPrefs.bleeds.Top);
01195        dc76.setAttribute("BleedLeft", appPrefs.bleeds.Left);
01196        dc76.setAttribute("BleedRight", appPrefs.bleeds.Right);
01197        dc76.setAttribute("BleedBottom", appPrefs.bleeds.Bottom);
01198        elem.appendChild(dc76);
01199        QDomElement pageSetAttr = docu.createElement("PageSets");
01200        QValueList<PageSet>::Iterator itpgset;
01201        for(itpgset = appPrefs.pageSets.begin(); itpgset != appPrefs.pageSets.end(); ++itpgset )
01202        {
01203               QDomElement pgst = docu.createElement("Set");
01204               pgst.setAttribute("Name", (*itpgset).Name);
01205               pgst.setAttribute("FirstPage", (*itpgset).FirstPage);
01206               pgst.setAttribute("Rows", (*itpgset).Rows);
01207               pgst.setAttribute("Columns", (*itpgset).Columns);
01208               pgst.setAttribute("GapHorizontal", (*itpgset).GapHorizontal);
01209               pgst.setAttribute("GapVertical", (*itpgset).GapVertical);
01210               pgst.setAttribute("GapBelow", (*itpgset).GapBelow);
01211               QStringList pNames = (*itpgset).pageNames;
01212               QStringList::Iterator itpgsetN;
01213               for(itpgsetN = pNames.begin(); itpgsetN != pNames.end(); ++itpgsetN )
01214               {
01215                      QDomElement pgstN = docu.createElement("PageNames");
01216                      pgstN.setAttribute("Name", (*itpgsetN));
01217                      pgst.appendChild(pgstN);
01218               }
01219               pageSetAttr.appendChild(pgst);
01220        }
01221        elem.appendChild(pageSetAttr);
01222        QDomElement dc79ac=docu.createElement("Checker");
01223        dc79ac.setAttribute("currentProfile", appPrefs.curCheckProfile);
01224        elem.appendChild(dc79ac);
01225        CheckerPrefsList::Iterator itcp;
01226        CheckerPrefsList::Iterator itcpend=appPrefs.checkerProfiles.end();
01227        for (itcp = appPrefs.checkerProfiles.begin(); itcp != itcpend; ++itcp)
01228        {
01229               QDomElement dc79a=docu.createElement("CheckProfile");
01230               dc79a.setAttribute("Name",itcp.key());
01231               dc79a.setAttribute("ignoreErrors", static_cast<int>(itcp.data().ignoreErrors));
01232               dc79a.setAttribute("autoCheck", static_cast<int>(itcp.data().autoCheck));
01233               dc79a.setAttribute("checkGlyphs", static_cast<int>(itcp.data().checkGlyphs));
01234               dc79a.setAttribute("checkOrphans", static_cast<int>(itcp.data().checkOrphans));
01235               dc79a.setAttribute("checkOverflow", static_cast<int>(itcp.data().checkOverflow));
01236               dc79a.setAttribute("checkPictures", static_cast<int>(itcp.data().checkPictures));
01237               dc79a.setAttribute("checkResolution", static_cast<int>(itcp.data().checkResolution));
01238               dc79a.setAttribute("checkTransparency", static_cast<int>(itcp.data().checkTransparency));
01239               dc79a.setAttribute("checkAnnotations", static_cast<int>(itcp.data().checkAnnotations));
01240               dc79a.setAttribute("checkRasterPDF", static_cast<int>(itcp.data().checkRasterPDF));
01241               dc79a.setAttribute("checkForGIF", static_cast<int>(itcp.data().checkForGIF));
01242               dc79a.setAttribute("ignoreOffLayers", static_cast<int>(itcp.data().ignoreOffLayers));
01243               dc79a.setAttribute("minResolution",itcp.data().minResolution);
01244               dc79a.setAttribute("maxResolution",itcp.data().maxResolution);
01245               elem.appendChild(dc79a);
01246        }
01247        QDomElement dc81=docu.createElement("CMS");
01248        dc81.setAttribute("DPSo", static_cast<int>(appPrefs.DCMSset.SoftProofOn));
01249        dc81.setAttribute("DPSFo", static_cast<int>(appPrefs.DCMSset.SoftProofFullOn));
01250        dc81.setAttribute("DPuse", static_cast<int>(appPrefs.DCMSset.CMSinUse));
01251        dc81.setAttribute("DPgam", static_cast<int>(appPrefs.DCMSset.GamutCheck));
01252        dc81.setAttribute("DPbla", static_cast<int>(appPrefs.DCMSset.BlackPoint));
01253        dc81.setAttribute("DPMo",appPrefs.DCMSset.DefaultMonitorProfile);
01254        dc81.setAttribute("DPPr",appPrefs.DCMSset.DefaultPrinterProfile);
01255        dc81.setAttribute("DPIn",appPrefs.DCMSset.DefaultImageRGBProfile);
01256        dc81.setAttribute("DPInCMYK",appPrefs.DCMSset.DefaultImageCMYKProfile);
01257        dc81.setAttribute("DPIn2",appPrefs.DCMSset.DefaultSolidColorRGBProfile);
01258        dc81.setAttribute("DPIn3",appPrefs.DCMSset.DefaultSolidColorCMYKProfile);
01259        //dc81.setAttribute("DIPr",appPrefs.DCMSset.DefaultIntentPrinter);
01260        //dc81.setAttribute("DIMo",appPrefs.DCMSset.DefaultIntentMonitor);
01261        dc81.setAttribute("DISc",appPrefs.DCMSset.DefaultIntentColors);
01262        dc81.setAttribute("DIIm",appPrefs.DCMSset.DefaultIntentImages);
01263        elem.appendChild(dc81);
01264        QDomElement dc82=docu.createElement("PRINTER");
01265        dc82.setAttribute("NAME",appPrefs.PrinterName);
01266        dc82.setAttribute("FILE",appPrefs.PrinterFile);
01267        dc82.setAttribute("COMMAND",appPrefs.PrinterCommand);
01268        dc82.setAttribute("CLIPMARGIN", static_cast<int>(appPrefs.ClipMargin));
01269        dc82.setAttribute("GMODE", static_cast<int>(appPrefs.GCRMode));
01270        elem.appendChild(dc82);
01271        QDomElement dc8Pr=docu.createElement("PRINTPREVIEW");
01272        dc8Pr.setAttribute("Mode", static_cast<int>(appPrefs.PrPr_Mode));
01273        dc8Pr.setAttribute("GcrMode", static_cast<int>(appPrefs.Gcr_Mode));
01274        dc8Pr.setAttribute("doOverprint", static_cast<int>(appPrefs.doOverprint));
01275        dc8Pr.setAttribute("AntiAliasing", static_cast<int>(appPrefs.PrPr_AntiAliasing));
01276        dc8Pr.setAttribute("Transparency", static_cast<int>(appPrefs.PrPr_Transparency));
01277        dc8Pr.setAttribute("Cyan", static_cast<int>(appPrefs.PrPr_C));
01278        dc8Pr.setAttribute("Magenta", static_cast<int>(appPrefs.PrPr_M));
01279        dc8Pr.setAttribute("Yellow", static_cast<int>(appPrefs.PrPr_Y));
01280        dc8Pr.setAttribute("Black", static_cast<int>(appPrefs.PrPr_K));
01281        elem.appendChild(dc8Pr);
01282        QDomElement dc8Ex = docu.createElement("EXTERNAL");
01283        dc8Ex.setAttribute("GIMP", imageEditorExecutable());
01284        dc8Ex.setAttribute("GS", ghostscriptExecutable());
01285        dc8Ex.setAttribute("WebBrowser", extBrowserExecutable());
01286        dc8Ex.setAttribute("AlphaGraphics", static_cast<int>(appPrefs.gs_AntiAliasGraphics));
01287        dc8Ex.setAttribute("AlphaText", static_cast<int>(appPrefs.gs_AntiAliasText));
01288        dc8Ex.setAttribute("Resolution", appPrefs.gs_Resolution);
01289        elem.appendChild(dc8Ex);
01290        QDomElement rde=docu.createElement("HYPHEN");
01291        rde.setAttribute("LANG", appPrefs.Language);
01292        rde.setAttribute("WORDLEN", appPrefs.MinWordLen);
01293        rde.setAttribute("HYCOUNT", appPrefs.HyCount);
01294        rde.setAttribute("MODE", static_cast<int>(appPrefs.Automatic));
01295        rde.setAttribute("INMODE", static_cast<int>(appPrefs.AutoCheck));
01296        elem.appendChild(rde);
01297        ColorList::Iterator itc;
01298        for (itc = appPrefs.DColors.begin(); itc != appPrefs.DColors.end(); ++itc)
01299        {
01300               QDomElement co=docu.createElement("COLOR");
01301               co.setAttribute("NAME",itc.key());
01302               if (itc.data().getColorModel() == colorModelRGB)
01303                      co.setAttribute("RGB", itc.data().nameRGB());
01304               else
01305                      co.setAttribute("CMYK", itc.data().nameCMYK());
01306               co.setAttribute("Spot", static_cast<int>(itc.data().isSpotColor()));
01307               co.setAttribute("Register", static_cast<int>(itc.data().isRegistrationColor()));
01308               elem.appendChild(co);
01309        }
01310        for ( SCFontsIterator itf(appPrefs.AvailFonts); itf.hasNext(); itf.next())
01311        {
01312               QDomElement fn=docu.createElement("FONT");
01313               fn.setAttribute("NAME",itf.currentKey());
01314               fn.setAttribute("EMBED",static_cast<int>(itf.current().embedPs()));
01315               fn.setAttribute("USE", static_cast<int>(itf.current().usable()));
01316               fn.setAttribute("SUBSET", static_cast<int>(itf.current().subset()));
01317               elem.appendChild(fn);
01318        }
01319        for (uint rd=0; rd<appPrefs.RecentDocs.count(); ++rd)
01320        {
01321               QDomElement rde=docu.createElement("RECENT");
01322               rde.setAttribute("NAME",appPrefs.RecentDocs[rd]);
01323               elem.appendChild(rde);
01324        }
01325        for (QMap<QString,Keys>::Iterator ksc=appPrefs.KeyActions.begin(); ksc!=appPrefs.KeyActions.end(); ++ksc)
01326        {
01327               if (ksc.data().actionName.isEmpty())
01328                      continue;
01329               QDomElement kscc=docu.createElement("SHORTCUT");
01330               kscc.setAttribute("ACTION",ksc.data().actionName);
01331               kscc.setAttribute("SEQUENCE",TabKeyboardShortcutsWidget::getKeyText(ksc.data().keySequence));
01332               elem.appendChild(kscc);
01333        }
01334        QMap<QString,QString>::Iterator itfsu;
01335        for (itfsu = appPrefs.GFontSub.begin(); itfsu != appPrefs.GFontSub.end(); ++itfsu)
01336        {
01337               QDomElement fosu = docu.createElement("Substitute");
01338               fosu.setAttribute("Name",itfsu.key());
01339               fosu.setAttribute("Replace",itfsu.data());
01340               elem.appendChild(fosu);
01341        }
01342        for (uint ccs=0; ccs<appPrefs.CustomColorSets.count(); ++ccs)
01343        {
01344               QDomElement cos=docu.createElement("COLORSET");
01345               cos.setAttribute("NAME",appPrefs.CustomColorSets[ccs]);
01346               elem.appendChild(cos);
01347        }
01348        QDomElement cosd=docu.createElement("DCOLORSET");
01349        cosd.setAttribute("NAME",appPrefs.DColorSet);
01350        elem.appendChild(cosd);
01351        QDomElement pdf = docu.createElement("PDF");
01352        pdf.setAttribute("Thumbnails", static_cast<int>(appPrefs.PDF_Options.Thumbnails));
01353        pdf.setAttribute("Articles", static_cast<int>(appPrefs.PDF_Options.Articles));
01354        pdf.setAttribute("Bookmarks", static_cast<int>(appPrefs.PDF_Options.Bookmarks));
01355        pdf.setAttribute("Compress", static_cast<int>(appPrefs.PDF_Options.Compress));
01356        pdf.setAttribute("CMethod", appPrefs.PDF_Options.CompressMethod);
01357        pdf.setAttribute("Quality", appPrefs.PDF_Options.Quality);
01358        pdf.setAttribute("MirrorH", static_cast<int>(appPrefs.PDF_Options.MirrorH));
01359        pdf.setAttribute("MirrorV", static_cast<int>(appPrefs.PDF_Options.MirrorV));
01360        pdf.setAttribute("Clip", static_cast<int>(appPrefs.PDF_Options.doClip));
01361        pdf.setAttribute("RotateDeg", static_cast<int>(appPrefs.PDF_Options.RotateDeg));
01362        pdf.setAttribute("PresentMode", static_cast<int>(appPrefs.PDF_Options.PresentMode));
01363        pdf.setAttribute("RecalcPic", static_cast<int>(appPrefs.PDF_Options.RecalcPic));
01364        pdf.setAttribute("Grayscale", static_cast<int>(appPrefs.PDF_Options.isGrayscale));
01365        pdf.setAttribute("RGBMode", static_cast<int>(appPrefs.PDF_Options.UseRGB));
01366        pdf.setAttribute("UseProfiles", static_cast<int>(appPrefs.PDF_Options.UseProfiles));
01367        pdf.setAttribute("UseProfiles2", static_cast<int>(appPrefs.PDF_Options.UseProfiles2));
01368        pdf.setAttribute("Binding", appPrefs.PDF_Options.Binding);
01369        pdf.setAttribute("PicRes", appPrefs.PDF_Options.PicRes);
01370        pdf.setAttribute("Resolution", appPrefs.PDF_Options.Resolution);
01371        pdf.setAttribute("Version", appPrefs.PDF_Options.Version);
01372        pdf.setAttribute("Intent", appPrefs.PDF_Options.Intent);
01373        pdf.setAttribute("Intent2", appPrefs.PDF_Options.Intent2);
01374        pdf.setAttribute("SolidP", appPrefs.PDF_Options.SolidProf);
01375        pdf.setAttribute("ImageP", appPrefs.PDF_Options.ImageProf);
01376        pdf.setAttribute("PrintP", appPrefs.PDF_Options.PrintProf);
01377        pdf.setAttribute("InfoString", appPrefs.PDF_Options.Info);
01378        pdf.setAttribute("BTop", appPrefs.PDF_Options.bleeds.Top);
01379        pdf.setAttribute("BLeft", appPrefs.PDF_Options.bleeds.Left);
01380        pdf.setAttribute("BRight", appPrefs.PDF_Options.bleeds.Right);
01381        pdf.setAttribute("BBottom", appPrefs.PDF_Options.bleeds.Bottom);
01382        pdf.setAttribute("useDocBleeds", static_cast<int>(appPrefs.PDF_Options.useDocBleeds));
01383        pdf.setAttribute("cropMarks", static_cast<int>(appPrefs.PDF_Options.cropMarks));
01384        pdf.setAttribute("bleedMarks", static_cast<int>(appPrefs.PDF_Options.bleedMarks));
01385        pdf.setAttribute("registrationMarks", static_cast<int>(appPrefs.PDF_Options.registrationMarks));
01386        pdf.setAttribute("colorMarks", static_cast<int>(appPrefs.PDF_Options.colorMarks));
01387        pdf.setAttribute("docInfoMarks", static_cast<int>(appPrefs.PDF_Options.docInfoMarks));
01388        pdf.setAttribute("markOffset", appPrefs.PDF_Options.markOffset);
01389        pdf.setAttribute("ImagePr", static_cast<int>(appPrefs.PDF_Options.EmbeddedI));
01390        pdf.setAttribute("PassOwner", appPrefs.PDF_Options.PassOwner);
01391        pdf.setAttribute("PassUser", appPrefs.PDF_Options.PassUser);
01392        pdf.setAttribute("Permissions", appPrefs.PDF_Options.Permissions);
01393        pdf.setAttribute("Encrypt", static_cast<int>(appPrefs.PDF_Options.Encrypt));
01394        pdf.setAttribute("UseLayers", static_cast<int>(appPrefs.PDF_Options.useLayers));
01395        pdf.setAttribute("UseLpi", static_cast<int>(appPrefs.PDF_Options.UseLPI));
01396        pdf.setAttribute("UseSpotColors", static_cast<int>(appPrefs.PDF_Options.UseSpotColors));
01397        pdf.setAttribute("doOverprint", static_cast<int>(appPrefs.PDF_Options.doOverprint));
01398        pdf.setAttribute("doMultiFile", static_cast<int>(appPrefs.PDF_Options.doMultiFile));
01399        pdf.setAttribute("displayBookmarks", static_cast<int>(appPrefs.PDF_Options.displayBookmarks));
01400        pdf.setAttribute("displayFullscreen", static_cast<int>(appPrefs.PDF_Options.displayFullscreen));
01401        pdf.setAttribute("displayLayers", static_cast<int>(appPrefs.PDF_Options.displayLayers));
01402        pdf.setAttribute("displayThumbs", static_cast<int>(appPrefs.PDF_Options.displayThumbs));
01403        pdf.setAttribute("PageLayout", appPrefs.PDF_Options.PageLayout);
01404        pdf.setAttribute("openAction", appPrefs.PDF_Options.openAction);
01405        QMap<QString,LPIData>::Iterator itlp;
01406        for (itlp = appPrefs.PDF_Options.LPISettings.begin(); itlp != appPrefs.PDF_Options.LPISettings.end(); ++itlp)
01407        {
01408               QDomElement pdf4 = docu.createElement("LPI");
01409               pdf4.setAttribute("Color", itlp.key());
01410               pdf4.setAttribute("Frequency", itlp.data().Frequency);
01411               pdf4.setAttribute("Angle", itlp.data().Angle);
01412               pdf4.setAttribute("SpotFunction", itlp.data().SpotFunc);
01413               pdf.appendChild(pdf4);
01414        }
01415        elem.appendChild(pdf);
01416        QDomElement docItemAttrs = docu.createElement("DefaultItemAttributes");
01417        for(ObjAttrVector::Iterator objAttrIt = appPrefs.defaultItemAttributes.begin() ; objAttrIt != appPrefs.defaultItemAttributes.end(); ++objAttrIt )
01418        {
01419               QDomElement itemAttr = docu.createElement("ItemAttribute");
01420               itemAttr.setAttribute("Name", (*objAttrIt).name);
01421               itemAttr.setAttribute("Type", (*objAttrIt).type);
01422               itemAttr.setAttribute("Value", (*objAttrIt).value);
01423               itemAttr.setAttribute("Parameter", (*objAttrIt).parameter);
01424               itemAttr.setAttribute("Relationship", (*objAttrIt).relationship);
01425               itemAttr.setAttribute("RelationshipTo", (*objAttrIt).relationshipto);
01426               itemAttr.setAttribute("AutoAddTo", (*objAttrIt).autoaddto);
01427               docItemAttrs.appendChild(itemAttr);
01428        }
01429        elem.appendChild(docItemAttrs);
01430        QDomElement tocElem = docu.createElement("TablesOfContents");
01431        for(ToCSetupVector::Iterator tocSetupIt = appPrefs.defaultToCSetups.begin() ; tocSetupIt != appPrefs.defaultToCSetups.end(); ++tocSetupIt )
01432        {
01433               QDomElement tocsetup = docu.createElement("TableOfContents");
01434               tocsetup.setAttribute("Name", (*tocSetupIt).name);
01435               tocsetup.setAttribute("ItemAttributeName", (*tocSetupIt).itemAttrName);
01436               tocsetup.setAttribute("FrameName", (*tocSetupIt).frameName);
01437               tocsetup.setAttribute("ListNonPrinting", (*tocSetupIt).listNonPrintingFrames);
01438               tocsetup.setAttribute("Style", (*tocSetupIt).textStyle);
01439               tocsetup.setAttribute("NumberPlacement", (*tocSetupIt).pageLocation);
01440               tocElem.appendChild(tocsetup);
01441        }
01442        elem.appendChild(tocElem);
01443        // lorem ipsum
01444        QDomElement liElem = docu.createElement("LoremIpsum");
01445        liElem.setAttribute("useStandardLI", static_cast<int>(appPrefs.useStandardLI));
01446        liElem.setAttribute("paragraphsLI", appPrefs.paragraphsLI);
01447        elem.appendChild(liElem);
01448        // write file
01449        bool result = false;
01450        QFile f(ho);
01451        if(!f.open(IO_WriteOnly))
01452        {
01453               m_lastError = tr("Could not open preferences file \"%1\" for writing: %2")
01454                      .arg(ho).arg(qApp->translate("QFile",f.errorString()));
01455        }
01456        else
01457        {
01458               QTextStream s(&f);
01459               s.setEncoding(QTextStream::UnicodeUTF8);
01460               s<<docu.toString();
01461               if (f.status() == IO_Ok)
01462                      result = true;
01463               else
01464                      m_lastError = tr("Writing to preferences file \"%1\" failed: "
01465                                          "QIODevice status code %2")
01466                             .arg(ho).arg(f.status());
01467        }
01468        if (f.isOpen())
01469               f.close();
01470        return result;
01471 }
01472 
01473 bool PrefsManager::ReadPref(QString ho)
01474 {
01475        QDomDocument docu("scridoc");
01476        QFile f(ho);
01477        if(!f.open(IO_ReadOnly))
01478        {
01479               m_lastError = tr("Failed to open prefs file \"%1\": %2")
01480                      .arg(ho).arg( qApp->translate("QFile",f.errorString()) );
01481               return false;
01482        }
01483        QTextStream ts(&f);
01484        ts.setEncoding(QTextStream::UnicodeUTF8);
01485        QString errorMsg;
01486        int errorLine = 0, errorColumn = 0;
01487        if( !docu.setContent(ts.read(), &errorMsg, &errorLine, &errorColumn) )
01488        {
01489               m_lastError = tr("Failed to read prefs XML from \"%1\": %2 at line %3, col %4")
01490                      .arg(ho).arg(errorMsg).arg(errorLine).arg(errorColumn);
01491               f.close();
01492               return false;
01493        }
01494        f.close();
01495        QDomElement elem=docu.documentElement();
01496        if (elem.tagName() != "SCRIBUSRC")
01497               return false;
01498        appPrefs.DColors.clear();
01499        ScColor lf = ScColor();
01500        QDomNode DOC=elem.firstChild();
01501        if (!DOC.namedItem("CheckProfile").isNull())
01502               appPrefs.checkerProfiles.clear();
01503        while(!DOC.isNull())
01504        {
01505               QDomElement dc=DOC.toElement();
01506               if (dc.tagName()=="GUI")
01507               {
01508                      appPrefs.GUI = dc.attribute("STILT","Default");
01509                      appPrefs.Wheelval = dc.attribute("RAD").toInt();
01510                      appPrefs.moveTimeout = dc.attribute("MOVT", "150").toInt();
01511                      appPrefs.guidesSettings.grabRad = dc.attribute("GRAB", "4").toInt();
01512                      appPrefs.docUnitIndex = dc.attribute("UNIT", "0").toInt();
01513                      appPrefs.AppFontSize = dc.attribute("APF", "12").toInt();
01514                      appPrefs.PaletteFontSize = dc.attribute("PFS", "10").toInt();
01515                      appPrefs.RecentDCount = dc.attribute("RCD","5").toUInt();
01516                      appPrefs.DocDir = dc.attribute("DOC","");
01517                      appPrefs.ProfileDir = dc.attribute("PROFILES","");
01518                      appPrefs.ScriptDir = dc.attribute("SCRIPTS","");
01519                      appPrefs.documentTemplatesDir = dc.attribute("TEMPLATES","");
01520                      appPrefs.guidesSettings.guidesShown = static_cast<bool>(dc.attribute("SHOWGUIDES", "1").toInt());
01521                      appPrefs.guidesSettings.colBordersShown = static_cast<bool>(dc.attribute("showcolborders", "0").toInt());
01522                      appPrefs.guidesSettings.framesShown = static_cast<bool>(dc.attribute("FRV", "1").toInt());
01523                      appPrefs.guidesSettings.layerMarkersShown = static_cast<bool>(dc.attribute("SHOWLAYERM", "0").toInt());
01524                      appPrefs.guidesSettings.marginsShown = static_cast<bool>(dc.attribute("SHOWMARGIN", "1").toInt());
01525                      appPrefs.guidesSettings.baseShown = static_cast<bool>(dc.attribute("SHOWBASE", "1").toInt());
01526                      appPrefs.guidesSettings.linkShown = static_cast<bool>(dc.attribute("SHOWLINK", "0").toInt());
01527                      appPrefs.guidesSettings.showPic = static_cast<bool>(dc.attribute("SHOWPICT", "1").toInt());
01528                      appPrefs.guidesSettings.showControls = static_cast<bool>(dc.attribute("SHOWControl", "0").toInt());
01529                      appPrefs.guidesSettings.rulersShown = static_cast<bool>(dc.attribute("rulersShown", "1").toInt());
01530                      appPrefs.guidesSettings.showBleed = static_cast<bool>(dc.attribute("showBleed", "1").toInt());
01531                      appPrefs.guidesSettings.rulerMode = static_cast<bool>(dc.attribute("rulerMode", "1").toInt());
01532                      appPrefs.haveStylePreview = static_cast<bool>(dc.attribute("STYLEPREVIEW", "1").toInt());
01533                      appPrefs.showStartupDialog = static_cast<bool>(dc.attribute("StartUp", "1").toInt());
01534                      appPrefs.scratch.Bottom = dc.attribute("ScratchBottom", "20").toDouble();
01535                      appPrefs.scratch.Left = dc.attribute("ScratchLeft", "100").toDouble();
01536                      appPrefs.scratch.Right = dc.attribute("ScratchRight", "100").toDouble();
01537                      appPrefs.scratch.Top = dc.attribute("ScratchTop", "20").toDouble();
01538                      if (dc.hasAttribute("STECOLOR"))
01539                             appPrefs.STEcolor = QColor(dc.attribute("STECOLOR"));
01540                      if (dc.hasAttribute("STEFONT"))
01541                             appPrefs.STEfont = dc.attribute("STEFONT");
01542                      appPrefs.showToolTips = static_cast<bool>(dc.attribute("ToolTips", "1").toInt());
01543                      appPrefs.stickyTools = static_cast<bool>(dc.attribute("stickyTools", "0").toInt());
01544               }
01545               if (dc.tagName()=="GRID")
01546               {
01547                      appPrefs.guidesSettings.minorGrid = dc.attribute("MINOR").toDouble();
01548                      appPrefs.guidesSettings.majorGrid = dc.attribute("MAJOR").toDouble();
01549                      appPrefs.guidesSettings.minorColor = QColor(dc.attribute("MINORC"));
01550                      appPrefs.guidesSettings.majorColor = QColor(dc.attribute("MAJORC"));
01551                      appPrefs.guidesSettings.before = static_cast<bool>(dc.attribute("BACKG", "1").toInt());
01552                      appPrefs.guidesSettings.gridShown = static_cast<bool>(dc.attribute("SHOW", "0").toInt());
01553                      if (dc.hasAttribute("GuideC"))
01554                             appPrefs.guidesSettings.guideColor = QColor(dc.attribute("GuideC"));
01555                      if (dc.hasAttribute("GuideZ"))
01556                             appPrefs.guidesSettings.guideRad = dc.attribute("GuideZ").toDouble();
01557                      if (dc.hasAttribute("BaseC"))
01558                             appPrefs.guidesSettings.baseColor = QColor(dc.attribute("BaseC"));
01559               }
01560               if (dc.tagName()=="PAGE")
01561               {
01562                      appPrefs.DpapColor = QColor(dc.attribute("PAGEC"));
01563                      appPrefs.DFrameColor = QColor(dc.attribute("SELEC","#ff0000"));
01564                      appPrefs.DFrameNormColor = QColor(dc.attribute("DFrameNormColor","#000000"));
01565                      appPrefs.DFrameGroupColor = QColor(dc.attribute("DFrameGroupColor","#008080"));
01566                      appPrefs.DFrameLockColor = QColor(dc.attribute("DFrameLockColor","#800000"));
01567                      appPrefs.DFrameLinkColor = QColor(dc.attribute("DFrameLinkColor","#ff0000"));
01568                      appPrefs.DFrameAnnotationColor = QColor(dc.attribute("DFrameAnnotationColor","#0000ff"));
01569                      appPrefs.DPageBorderColor = QColor(dc.attribute("DPageBorderColor","#ff0000"));
01570                      appPrefs.DControlCharColor = QColor(dc.attribute("DControlCharColor","#800000"));
01571                      appPrefs.guidesSettings.margColor = QColor(dc.attribute("MARGC","#0000ff"));
01572                      appPrefs.marginColored = static_cast<bool>(dc.attribute("RANDF", "0").toInt());
01573                      appPrefs.DisScale = dc.attribute("DScale", "1").toDouble();
01574               }
01575               if (dc.tagName()=="TYPO")
01576               {
01577                      appPrefs.typographicSettings.valueSuperScript = dc.attribute("HOCH").toInt();
01578                      appPrefs.typographicSettings.scalingSuperScript = dc.attribute("HOCHSC").toInt();
01579                      appPrefs.typographicSettings.valueSubScript = dc.attribute("TIEF").toInt();
01580                      appPrefs.typographicSettings.scalingSubScript = dc.attribute("TIEFSC").toInt();
01581                      appPrefs.typographicSettings.valueSmallCaps = dc.attribute("SMCAPS").toInt();
01582                      appPrefs.typographicSettings.valueBaseGrid = dc.attribute("BASE", "12").toDouble();
01583                      appPrefs.typographicSettings.offsetBaseGrid = dc.attribute("BASEO", "0").toDouble();
01584                      appPrefs.typographicSettings.autoLineSpacing = dc.attribute("AUTOL", "20").toInt();
01585                      double ulp = dc.attribute("UnderlinePos", "-1").toDouble();
01586                      if (ulp != -1)
01587                             appPrefs.typographicSettings.valueUnderlinePos = qRound(ulp * 10);
01588                      else
01589                             appPrefs.typographicSettings.valueUnderlinePos = -1;
01590                      double ulw = dc.attribute("UnderlineWidth", "-1").toDouble();
01591                      if (ulw != -1)
01592                             appPrefs.typographicSettings.valueUnderlineWidth = qRound(ulw * 10);
01593                      else
01594                             appPrefs.typographicSettings.valueUnderlineWidth = -1;
01595                      double stp = dc.attribute("StrikeThruPos", "-1").toDouble();
01596                      if (stp != -1)
01597                             appPrefs.typographicSettings.valueStrikeThruPos = qRound(ulp * 10);
01598                      else
01599                             appPrefs.typographicSettings.valueStrikeThruPos = -1;
01600                      double stw = dc.attribute("StrikeThruWidth", "-1").toDouble();
01601                      if (stw != -1)
01602                             appPrefs.typographicSettings.valueStrikeThruWidth = qRound(stw * 10);
01603                      else
01604                             appPrefs.typographicSettings.valueStrikeThruWidth = -1;
01605               }
01606               if (dc.tagName()=="TOOLS")
01607               {
01608                      appPrefs.toolSettings.dPen = dc.attribute("PEN");
01609                      appPrefs.toolSettings.dBrush = dc.attribute("BRUSH");
01610                      appPrefs.toolSettings.dPenLine = dc.attribute("PENLINE");
01611                      appPrefs.toolSettings.dPenText = dc.attribute("PENTEXT");
01612                      appPrefs.toolSettings.dStrokeText = dc.attribute("StrokeText", appPrefs.toolSettings.dPenText);
01613                      appPrefs.toolSettings.dTextBackGround = dc.attribute("TextBackGround", CommonStrings::None);
01614                      appPrefs.toolSettings.dTextLineColor = dc.attribute("TextLineColor", CommonStrings::None);
01615                      appPrefs.toolSettings.dTextBackGroundShade = dc.attribute("TextBackGroundShade", "100").toInt();
01616                      appPrefs.toolSettings.dTextLineShade = dc.attribute("TextLineShade", "100").toInt();
01617                      appPrefs.toolSettings.dTextPenShade = dc.attribute("TextPenShade", "100").toInt();
01618                      appPrefs.toolSettings.dTextStrokeShade = dc.attribute("TextStrokeShade", "100").toInt();
01619                      appPrefs.toolSettings.dCols = dc.attribute("TEXTCOL", "1").toInt();
01620                      appPrefs.toolSettings.dGap = dc.attribute("TEXTGAP", "0.0").toDouble();
01621                      appPrefs.toolSettings.tabFillChar = dc.attribute("TabFill", "");
01622                      appPrefs.toolSettings.dTabWidth = dc.attribute("TabWidth", "36.0").toDouble();
01623                      appPrefs.toolSettings.dLineArt = dc.attribute("STIL").toInt();
01624                      appPrefs.toolSettings.dLstyleLine = dc.attribute("STILLINE").toInt();
01625                      appPrefs.toolSettings.dWidth = dc.attribute("WIDTH").toDouble();
01626                      appPrefs.toolSettings.dWidthLine = dc.attribute("WIDTHLINE").toDouble();
01627                      appPrefs.toolSettings.dShade2 = dc.attribute("PENSHADE").toInt();
01628                      appPrefs.toolSettings.dShadeLine = dc.attribute("LINESHADE").toInt();
01629                      appPrefs.toolSettings.dShade = dc.attribute("BRUSHSHADE").toInt();
01630                      appPrefs.toolSettings.magMin = dc.attribute("MAGMIN", "10").toInt();
01631                      appPrefs.toolSettings.magMax = dc.attribute("MAGMAX", "3200").toInt();
01632                      appPrefs.toolSettings.magStep = dc.attribute("MAGSTEP", "200").toInt();
01633                      //CB Reset prefs zoom step value to 200% instead of old values.
01634                      if (appPrefs.toolSettings.magStep<100)
01635                             appPrefs.toolSettings.magStep=200;
01636                      appPrefs.toolSettings.dBrushPict = dc.attribute("CPICT", CommonStrings::None);
01637                      appPrefs.toolSettings.shadePict = dc.attribute("PICTSHADE", "100").toInt();
01638                      appPrefs.toolSettings.scaleX = dc.attribute("PICTSCX", "1").toDouble();
01639                      appPrefs.toolSettings.scaleY = dc.attribute("PICTSCY", "1").toDouble();
01640                      appPrefs.toolSettings.scaleType = static_cast<bool>(dc.attribute("PSCALE", "1").toInt());
01641                      appPrefs.toolSettings.aspectRatio = static_cast<bool>(dc.attribute("PASPECT", "0").toInt());
01642                      appPrefs.toolSettings.useEmbeddedPath = static_cast<bool>(dc.attribute("EmbeddedPath", "0").toInt());
01643                      appPrefs.toolSettings.lowResType = dc.attribute("HalfRes", "1").toInt();
01644                      appPrefs.toolSettings.polyC = dc.attribute("POLYC", "4").toInt();
01645                      appPrefs.toolSettings.polyF = dc.attribute("POLYF", "0.5").toDouble();
01646                      appPrefs.toolSettings.polyR = dc.attribute("POLYR", "0").toDouble();
01647                      appPrefs.toolSettings.polyFd = dc.attribute("POLYFD", "0").toInt();
01648                      appPrefs.toolSettings.polyS = static_cast<bool>(dc.attribute("POLYS", "0").toInt());
01649                      appPrefs.toolSettings.dStartArrow = dc.attribute("StartArrow", "0").toInt();
01650                      appPrefs.toolSettings.dEndArrow = dc.attribute("EndArrow", "0").toInt();
01651                      appPrefs.toolSettings.dispX = dc.attribute("dispX", "10").toDouble();
01652                      appPrefs.toolSettings.dispY = dc.attribute("dispY", "10").toDouble();
01653                      appPrefs.toolSettings.constrain = dc.attribute("constrain", "15").toDouble();
01654               }
01655               if (dc.tagName()=="MAINWINDOW")
01656               {
01657                      appPrefs.mainWinSettings.xPosition = dc.attribute("XPOS", "0").toInt();
01658                      appPrefs.mainWinSettings.yPosition = dc.attribute("YPOS", "0").toInt();
01659                      appPrefs.mainWinSettings.width = dc.attribute("WIDTH", "640").toInt();
01660                      appPrefs.mainWinSettings.height = dc.attribute("HEIGHT", "480").toInt();
01661                      appPrefs.mainWinSettings.maximized = static_cast<bool>(dc.attribute("MAXIMIZED", "0").toInt());
01662                      QDesktopWidget *d = QApplication::desktop();
01663                      QSize gStrut = QApplication::globalStrut();
01664                      int minX = 0;
01665 #ifndef QT_MAC
01666                      int minY = 0;
01667 #else
01668                      // on Mac you're dead if the titlebar is not on screen
01669                      int minY = 22;
01670 #endif
01671                      if (appPrefs.mainWinSettings.xPosition < minX )
01672                             appPrefs.mainWinSettings.xPosition = minX;
01673                      if (appPrefs.mainWinSettings.yPosition <  minY)
01674                             appPrefs.mainWinSettings.yPosition = minY;
01675                      int minWidth = 5*gStrut.width();
01676                      int minHeight = 5*gStrut.width();
01677                      int maxWidth = d->width();
01678                      int maxHeight = d->height();
01679                      if (appPrefs.mainWinSettings.width > maxWidth)
01680                             appPrefs.mainWinSettings.width = maxWidth;
01681                      if (appPrefs.mainWinSettings.width < minWidth)
01682                             appPrefs.mainWinSettings.width = minWidth;
01683                      if (appPrefs.mainWinSettings.height > maxHeight)
01684                             appPrefs.mainWinSettings.height = maxHeight;
01685                      if (appPrefs.mainWinSettings.height < minHeight)
01686                             appPrefs.mainWinSettings.height = minHeight;
01687                      int maxX = d->width() - minWidth;
01688                      int maxY = d->height() - minHeight;
01689                      if (appPrefs.mainWinSettings.xPosition >= maxX)
01690                             appPrefs.mainWinSettings.xPosition = maxX;
01691                      if (appPrefs.mainWinSettings.yPosition >= maxY)
01692                             appPrefs.mainWinSettings.yPosition = maxY;
01693               }
01694               if (dc.tagName()=="PAGEPALETTE")
01695               {
01696                      appPrefs.SepalT = static_cast<bool>(dc.attribute("THUMBS").toInt());
01697                      appPrefs.SepalN = static_cast<bool>(dc.attribute("NAMES").toInt());
01698               }
01699               if (dc.tagName()=="SCRAPBOOK")
01700               {
01701                      appPrefs.doCopyToScrapbook = static_cast<bool>(dc.attribute("CopyToScrapbook", "1").toInt());
01702                      appPrefs.persistentScrapbook = static_cast<bool>(dc.attribute("persistentScrapbook", "0").toInt());
01703                      appPrefs.numScrapbookCopies = dc.attribute("numScrapbookCopies", "10").toInt();
01704                      QDomNode scrp = dc.firstChild();
01705                      while(!scrp.isNull())
01706                      {
01707                             QDomElement scrpElem = scrp.toElement();
01708                             if (scrpElem.tagName()=="RECENT")
01709                             {
01710                                    QString nam = scrpElem.attribute("NAME");
01711                                    QFileInfo fd(nam);
01712                                    if (fd.exists())
01713                                           appPrefs.RecentScrapbooks.append(nam);
01714                             }
01715                             scrp = scrp.nextSibling();
01716                      }
01717               }
01718               if (dc.tagName() == "DOKUMENT")
01719               {
01720                      appPrefs.pageSize = dc.attribute("PAGESIZE","A4");
01721                      appPrefs.pageOrientation = dc.attribute("AUSRICHTUNG", "0").toInt();
01722                      appPrefs.PageWidth = dc.attribute("BREITE", "595").toDouble();
01723                      appPrefs.PageHeight = dc.attribute("HOEHE", "842").toDouble();
01724                      appPrefs.margins.Top = dc.attribute("RANDO", "9").toDouble();
01725                      appPrefs.margins.Bottom = dc.attribute("RANDU", "40").toDouble();
01726                      appPrefs.margins.Left = dc.attribute("RANDL", "9").toDouble();
01727                      appPrefs.margins.Right = dc.attribute("RANDR", "9").toDouble();
01728                      appPrefs.FacingPages = dc.attribute("DOPPEL", "0").toInt();
01729                      appPrefs.AutoSave = static_cast<bool>(dc.attribute("AutoSave", "0").toInt());
01730                      appPrefs.AutoSaveTime = dc.attribute("AutoSaveTime", "600000").toInt();
01731                      appPrefs.bleeds.Top = dc.attribute("BleedTop", "0").toDouble();
01732                      appPrefs.bleeds.Left = dc.attribute("BleedLeft", "0").toDouble();
01733                      appPrefs.bleeds.Right = dc.attribute("BleedRight", "0").toDouble();
01734                      appPrefs.bleeds.Bottom = dc.attribute("BleedBottom", "0").toDouble();
01735               }
01736               if (dc.tagName()=="PageSets")
01737               {
01738                      QDomNode PGS = DOC.firstChild();
01739                      if  (!PGS.namedItem("PageNames").isNull())
01740                      {
01741                             appPrefs.pageSets.clear();
01742                             while(!PGS.isNull())
01743                             {
01744                                    QDomElement PgsAttr = PGS.toElement();
01745                                    if(PgsAttr.tagName() == "Set")
01746                                    {
01747                                           struct PageSet pageS;
01748                                           pageS.Name = PgsAttr.attribute("Name");
01749                                           pageS.FirstPage = PgsAttr.attribute("FirstPage", "0").toInt();
01750                                           pageS.Rows = PgsAttr.attribute("Rows", "1").toInt();
01751                                           pageS.Columns = PgsAttr.attribute("Columns", "1").toInt();
01752                                           pageS.GapHorizontal = PgsAttr.attribute("GapHorizontal", "0").toDouble();
01753                                           pageS.GapVertical = PgsAttr.attribute("GapVertical", "0").toDouble();
01754                                           pageS.GapBelow = PgsAttr.attribute("GapBelow", "0").toDouble();
01755                                           pageS.pageNames.clear();
01756                                           QDomNode PGSN = PGS.firstChild();
01757                                           while(!PGSN.isNull())
01758                                           {
01759                                                  QDomElement PgsAttrN = PGSN.toElement();
01760                                                  if(PgsAttrN.tagName() == "PageNames")
01761                                                         pageS.pageNames.append(PgsAttrN.attribute("Name"));
01762                                                  PGSN = PGSN.nextSibling();
01763                                           }
01764                                           appPrefs.pageSets.append(pageS);
01765                                    }
01766                                    PGS = PGS.nextSibling();
01767                             }
01768                      }
01769               }
01770               if (dc.tagName()=="CMS")
01771               {
01772                      appPrefs.DCMSset.SoftProofOn = static_cast<bool>(dc.attribute("DPSo", "0").toInt());
01773                      appPrefs.DCMSset.SoftProofFullOn = static_cast<bool>(dc.attribute("DPSFo", "0").toInt());
01774                      appPrefs.DCMSset.CMSinUse = static_cast<bool>(dc.attribute("DPuse", "0").toInt());
01775                      appPrefs.DCMSset.GamutCheck = static_cast<bool>(dc.attribute("DPgam", "0").toInt());
01776                      appPrefs.DCMSset.BlackPoint = static_cast<bool>(dc.attribute("DPbla", "1").toInt());
01777                      appPrefs.DCMSset.DefaultMonitorProfile = dc.attribute("DPMo","");
01778                      appPrefs.DCMSset.DefaultPrinterProfile = dc.attribute("DPPr","");
01779                      appPrefs.DCMSset.DefaultImageRGBProfile = dc.attribute("DPIn","");
01780                      appPrefs.DCMSset.DefaultImageCMYKProfile = dc.attribute("DPInCMYK","");
01781                      appPrefs.DCMSset.DefaultSolidColorRGBProfile = dc.attribute("DPIn2","");
01782                      appPrefs.DCMSset.DefaultSolidColorCMYKProfile = dc.attribute("DPIn3","");
01783                      appPrefs.DCMSset.DefaultIntentColors = dc.attribute("DISc", "1").toInt();
01784                      appPrefs.DCMSset.DefaultIntentImages = dc.attribute("DIIm", "0").toInt();
01785               }
01786               if (!importingFrom12 && dc.tagName()=="SHORTCUT")
01787               {
01788                      if (appPrefs.KeyActions.contains(dc.attribute("ACTION")))
01789                      {
01790                             appPrefs.KeyActions[dc.attribute("ACTION")].actionName = dc.attribute("ACTION");
01791                             QKeySequence newKeySequence = QKeySequence(dc.attribute("SEQUENCE"));
01792                             appPrefs.KeyActions[dc.attribute("ACTION")].keySequence = newKeySequence;
01793                      }
01794               }
01795               if (dc.tagName()=="RECENT")
01796                      appPrefs.RecentDocs.append(dc.attribute("NAME"));
01797               if (dc.tagName()=="Checker")
01798               {
01799                      appPrefs.curCheckProfile = dc.attribute("currentProfile", tr("PostScript"));
01800                      //#2516 work around old values until people wont have them anymore, not that these
01801                      //translated strings should be going into prefs anyway!
01802                      if ((appPrefs.curCheckProfile == tr("Postscript")) || (appPrefs.curCheckProfile == "Postscript"))
01803                             appPrefs.curCheckProfile = tr("PostScript");
01804               }
01805               if (dc.tagName()=="CheckProfile")
01806               {
01807                      QString name=dc.attribute("Name");
01808                      if ((name == tr("Postscript")) || (name == "Postscript"))
01809                             name = tr("PostScript");
01810                      struct checkerPrefs checkerSettings;
01811                      checkerSettings.ignoreErrors = static_cast<bool>(dc.attribute("ignoreErrors", "0").toInt());
01812                      checkerSettings.autoCheck = static_cast<bool>(dc.attribute("autoCheck", "1").toInt());
01813                      checkerSettings.checkGlyphs = static_cast<bool>(dc.attribute("checkGlyphs", "1").toInt());
01814                      checkerSettings.checkOrphans = static_cast<bool>(dc.attribute("checkOrphans", "1").toInt());
01815                      checkerSettings.checkOverflow = static_cast<bool>(dc.attribute("checkOverflow", "1").toInt());
01816                      checkerSettings.checkPictures = static_cast<bool>(dc.attribute("checkPictures", "1").toInt());
01817                      checkerSettings.checkResolution = static_cast<bool>(dc.attribute("checkResolution", "1").toInt());
01818                      checkerSettings.checkTransparency = static_cast<bool>(dc.attribute("checkTransparency", "1").toInt());
01819                      checkerSettings.minResolution = dc.attribute("minResolution", "72").toDouble();
01820                      checkerSettings.maxResolution = dc.attribute("maxResolution", "4800").toDouble();
01821                      checkerSettings.checkAnnotations = static_cast<bool>(dc.attribute("checkAnnotations", "0").toInt());
01822                      checkerSettings.checkRasterPDF = static_cast<bool>(dc.attribute("checkRasterPDF", "1").toInt());
01823                      checkerSettings.checkForGIF = static_cast<bool>(dc.attribute("checkForGIF", "1").toInt());
01824                      checkerSettings.ignoreOffLayers = static_cast<bool>(dc.attribute("ignoreOffLayers", "0").toInt());
01825                      appPrefs.checkerProfiles[name] = checkerSettings;
01826               }
01827               if (dc.tagName()=="PRINTER")
01828               {
01829                      appPrefs.PrinterName = dc.attribute("NAME");
01830                      appPrefs.PrinterFile = dc.attribute("FILE");
01831                      appPrefs.PrinterCommand = dc.attribute("COMMAND");
01832                      appPrefs.ClipMargin = static_cast<bool>(dc.attribute("CLIPMARGIN", "1").toInt());
01833                      appPrefs.GCRMode = static_cast<bool>(dc.attribute("GMODE", "1").toInt());
01834               }
01835               if (dc.tagName()=="PRINTPREVIEW")
01836               {
01837                      appPrefs.PrPr_Mode = static_cast<bool>(dc.attribute("Mode", "0").toInt());
01838                      appPrefs.Gcr_Mode = static_cast<bool>(dc.attribute("GcrMode", "1").toInt());
01839                      appPrefs.doOverprint = static_cast<bool>(dc.attribute("doOverprint", "0").toInt());
01840                      appPrefs.PrPr_AntiAliasing = static_cast<bool>(dc.attribute("AntiAliasing", "0").toInt());
01841                      appPrefs.PrPr_Transparency = static_cast<bool>(dc.attribute("Transparency", "0").toInt());
01842                      appPrefs.PrPr_C = static_cast<bool>(dc.attribute("Cyan", "1").toInt());
01843                      appPrefs.PrPr_M = static_cast<bool>(dc.attribute("Magenta", "1").toInt());
01844                      appPrefs.PrPr_Y = static_cast<bool>(dc.attribute("Yellow", "1").toInt());
01845                      appPrefs.PrPr_K = static_cast<bool>(dc.attribute("Black", "1").toInt());
01846               }
01847               if (dc.tagName()=="EXTERNAL")
01848               {
01849                      int gsa1 = testGSAvailability(dc.attribute("GS", "gs"));
01850                      int gsa2 = testGSAvailability(ghostscriptExecutable());
01851                      if( (gsa1 == 0) || (gsa2 != 0) )
01852                             setGhostscriptExecutable(dc.attribute("GS", "gs"));
01853                      appPrefs.gs_AntiAliasText = static_cast<bool>(dc.attribute("AlphaText", "0").toInt());
01854                      appPrefs.gs_AntiAliasGraphics = static_cast<bool>(dc.attribute("AlphaGraphics", "0").toInt());
01855                      appPrefs.gs_Resolution = dc.attribute("Resolution", "72").toInt();
01856                      setImageEditorExecutable(dc.attribute("GIMP", "gimp"));
01857                      setExtBrowserExecutable(dc.attribute("WebBrowser", ""));
01858               }
01859               if (dc.tagName()=="HYPHEN")
01860               {
01861                      if (!dc.attribute("LANG", "").isEmpty())
01862                             appPrefs.Language = dc.attribute("LANG");
01863                      appPrefs.MinWordLen = dc.attribute("WORDLEN", "3").toInt();
01864                      appPrefs.HyCount = dc.attribute("HYCOUNT", "2").toInt();
01865                      appPrefs.Automatic = static_cast<bool>(dc.attribute("MODE", "1").toInt());
01866                      appPrefs.AutoCheck = static_cast<bool>(dc.attribute("INMODE", "1").toInt());
01867               }
01868               if (dc.tagName()=="FONTS")
01869               {
01870                      QString tmpf(dc.attribute("FACE"));
01871                      if (!tmpf.isEmpty())
01872                      {
01873                             QString newFont = "";
01874                             if (!appPrefs.AvailFonts.contains(tmpf))
01875                             {
01876                                    ScCore->showSplash(false);
01877                                    MissingFont *dia = new MissingFont(0, tmpf, 0);
01878                                    dia->exec();
01879                                    newFont = dia->getReplacementFont();
01880                                    delete dia;
01881                             }
01882                             else
01883                                    newFont = tmpf;
01884                             if (!newFont.isEmpty())
01885                                    appPrefs.toolSettings.defFont = newFont;
01886                             appPrefs.toolSettings.defSize = qRound(dc.attribute("SIZE").toDouble() * 10.0);
01887                             appPrefs.askBeforeSubstituite = static_cast<bool>(dc.attribute("AutomaticSubst", "1").toInt());
01888                      }
01889               }
01890               if (dc.tagName()=="FONT")
01891               {
01892                      QString tmpf(dc.attribute("NAME"));
01893                      if (!tmpf.isEmpty() && appPrefs.AvailFonts.contains(tmpf))
01894                      {
01895                             appPrefs.AvailFonts[tmpf].embedPs(static_cast<bool>(dc.attribute("EMBED").toInt()));
01896                             appPrefs.AvailFonts[tmpf].usable(appPrefs.AvailFonts[tmpf].usable() && static_cast<bool>(dc.attribute("USE", "1").toInt()));
01897                             appPrefs.AvailFonts[tmpf].subset(static_cast<bool>(dc.attribute("SUBSET", "0").toInt()));
01898                      }
01899               }
01900               if (dc.tagName()=="COLOR")
01901               {
01902                      if (dc.hasAttribute("CMYK"))
01903                             lf.setNamedColor(dc.attribute("CMYK"));
01904                      else
01905                             lf.fromQColor(QColor(dc.attribute("RGB")));
01906                      if (dc.hasAttribute("Spot"))
01907                             lf.setSpotColor(static_cast<bool>(dc.attribute("Spot").toInt()));
01908                      else
01909                             lf.setSpotColor(false);
01910                      if (dc.hasAttribute("Register"))
01911                             lf.setRegistrationColor(static_cast<bool>(dc.attribute("Register").toInt()));
01912                      else
01913                             lf.setRegistrationColor(false);
01914                      appPrefs.DColors[dc.attribute("NAME")] = lf;
01915               }
01916               if (dc.tagName()=="Substitute")
01917                 appPrefs.GFontSub[dc.attribute("Name")] = dc.attribute("Replace");
01918               if (dc.tagName()=="COLORSET")
01919                      appPrefs.CustomColorSets.append(dc.attribute("NAME"));
01920               if (dc.tagName()=="DCOLORSET")
01921                      appPrefs.DColorSet = dc.attribute("NAME");
01922               if(dc.tagName()=="PDF")
01923               {
01924                      appPrefs.PDF_Options.Articles = static_cast<bool>(dc.attribute("Articles").toInt());
01925                      appPrefs.PDF_Options.Thumbnails = static_cast<bool>(dc.attribute("Thumbnails").toInt());
01926                      appPrefs.PDF_Options.Compress = static_cast<bool>(dc.attribute("Compress").toInt());
01927                      appPrefs.PDF_Options.CompressMethod = dc.attribute("CMethod", "0").toInt();
01928                      appPrefs.PDF_Options.Quality = dc.attribute("Quality", "0").toInt();
01929                      appPrefs.PDF_Options.RecalcPic = static_cast<bool>(dc.attribute("RecalcPic").toInt());
01930                      appPrefs.PDF_Options.Bookmarks = static_cast<bool>(dc.attribute("Bookmarks").toInt());
01931                      appPrefs.PDF_Options.MirrorH = static_cast<bool>(dc.attribute("MirrorH").toInt());
01932                      appPrefs.PDF_Options.MirrorV = static_cast<bool>(dc.attribute("MirrorV").toInt());
01933                      appPrefs.PDF_Options.doClip = static_cast<bool>(dc.attribute("Clip").toInt());
01934                      appPrefs.PDF_Options.RotateDeg = dc.attribute("RotateDeg", "0").toInt();
01935                      appPrefs.PDF_Options.PresentMode = static_cast<bool>(dc.attribute("PresentMode").toInt());
01936                      appPrefs.PDF_Options.PicRes = dc.attribute("PicRes").toInt();
01937                      appPrefs.PDF_Options.Version = (PDFOptions::PDFVersion)dc.attribute("Version").toInt();
01938                      appPrefs.PDF_Options.Resolution = dc.attribute("Resolution").toInt();
01939                      appPrefs.PDF_Options.Binding = dc.attribute("Binding").toInt();
01940                      appPrefs.PDF_Options.Datei = "";
01941                      appPrefs.PDF_Options.isGrayscale = static_cast<bool>(dc.attribute("Grayscale", "0").toInt());
01942                      appPrefs.PDF_Options.UseRGB = static_cast<bool>(dc.attribute("RGBMode", "0").toInt());
01943                      appPrefs.PDF_Options.UseProfiles = static_cast<bool>(dc.attribute("UseProfiles", "0").toInt());
01944                      appPrefs.PDF_Options.UseProfiles2 = static_cast<bool>(dc.attribute("UseProfiles2", "0").toInt());
01945                      appPrefs.PDF_Options.Intent = dc.attribute("Intent", "1").toInt();
01946                      appPrefs.PDF_Options.Intent2 = dc.attribute("Intent2", "1").toInt();
01947                      appPrefs.PDF_Options.SolidProf = dc.attribute("SolidP", "");
01948                      appPrefs.PDF_Options.ImageProf = dc.attribute("ImageP", "");
01949                      appPrefs.PDF_Options.PrintProf = dc.attribute("PrintP", "");
01950                      appPrefs.PDF_Options.Info = dc.attribute("InfoString", "");
01951                      appPrefs.PDF_Options.bleeds.Top = dc.attribute("BTop", "0").toDouble();
01952                      appPrefs.PDF_Options.bleeds.Left = dc.attribute("BLeft", "0").toDouble();
01953                      appPrefs.PDF_Options.bleeds.Right = dc.attribute("BRight", "0").toDouble();
01954                      appPrefs.PDF_Options.bleeds.Bottom = dc.attribute("BBottom", "0").toDouble();
01955                      appPrefs.PDF_Options.useDocBleeds = static_cast<bool>(dc.attribute("useDocBleeds", "0").toInt());
01956                      appPrefs.PDF_Options.cropMarks = static_cast<bool>(dc.attribute("cropMarks", "0").toInt());
01957                      appPrefs.PDF_Options.bleedMarks = static_cast<bool>(dc.attribute("bleedMarks", "0").toInt());
01958                      appPrefs.PDF_Options.registrationMarks = static_cast<bool>(dc.attribute("registrationMarks", "0").toInt());
01959                      appPrefs.PDF_Options.colorMarks = static_cast<bool>(dc.attribute("colorMarks", "0").toInt());
01960                      appPrefs.PDF_Options.docInfoMarks = static_cast<bool>(dc.attribute("docInfoMarks", "0").toInt());
01961                      appPrefs.PDF_Options.markOffset = dc.attribute("markOffset", "0").toDouble();
01962                      appPrefs.PDF_Options.EmbeddedI = static_cast<bool>(dc.attribute("ImagePr", "0").toInt());
01963                      appPrefs.PDF_Options.PassOwner = dc.attribute("PassOwner", "");
01964                      appPrefs.PDF_Options.PassUser = dc.attribute("PassUser", "");
01965                      appPrefs.PDF_Options.Permissions = dc.attribute("Permissions", "-4").toInt();
01966                      appPrefs.PDF_Options.Encrypt = static_cast<bool>(dc.attribute("Encrypt", "0").toInt());
01967                      appPrefs.PDF_Options.useLayers = static_cast<bool>(dc.attribute("UseLayers", "0").toInt());
01968                      appPrefs.PDF_Options.UseLPI = static_cast<bool>(dc.attribute("UseLpi", "0").toInt());
01969                      appPrefs.PDF_Options.UseSpotColors = static_cast<bool>(dc.attribute("UseSpotColors", "1").toInt());
01970                      appPrefs.PDF_Options.doOverprint = static_cast<bool>(dc.attribute("doOverprint", "0").toInt());
01971                      appPrefs.PDF_Options.doMultiFile = static_cast<bool>(dc.attribute("doMultiFile", "0").toInt());
01972                      appPrefs.PDF_Options.displayBookmarks = static_cast<bool>(dc.attribute("displayBookmarks", "0").toInt());
01973                      appPrefs.PDF_Options.displayFullscreen = static_cast<bool>(dc.attribute("displayFullscreen", "0").toInt());
01974                      appPrefs.PDF_Options.displayLayers = static_cast<bool>(dc.attribute("displayLayers", "0").toInt());
01975                      appPrefs.PDF_Options.displayThumbs = static_cast<bool>(dc.attribute("displayThumbs", "0").toInt());
01976                      appPrefs.PDF_Options.PageLayout = dc.attribute("PageLayout", "0").toInt();
01977                      appPrefs.PDF_Options.openAction = dc.attribute("openAction", "");
01978                      QDomNode PFO = DOC.firstChild();
01979                      appPrefs.PDF_Options.LPISettings.clear();
01980                      while(!PFO.isNull())
01981                      {
01982                             QDomElement pdfF = PFO.toElement();
01983                             if(pdfF.tagName() == "LPI")
01984                             {
01985                                    struct LPIData lpo;
01986                                    lpo.Angle = pdfF.attribute("Angle").toInt();
01987                                    lpo.Frequency = pdfF.attribute("Frequency").toInt();
01988                                    lpo.SpotFunc = pdfF.attribute("SpotFunction").toInt();
01989                                    appPrefs.PDF_Options.LPISettings[pdfF.attribute("Color")] = lpo;
01990                             }
01991                             PFO = PFO.nextSibling();
01992                      }
01993               }
01994               if(dc.tagName()=="DefaultItemAttributes")
01995               {
01996                      QDomNode DIA = DOC.firstChild();
01997                      appPrefs.defaultItemAttributes.clear();
01998                      while(!DIA.isNull())
01999                      {
02000                             QDomElement itemAttr = DIA.toElement();
02001                             if(itemAttr.tagName() == "ItemAttribute")
02002                             {
02003                                    ObjectAttribute objattr;
02004                                    objattr.name=itemAttr.attribute("Name");
02005                                    objattr.type=itemAttr.attribute("Type");
02006                                    objattr.value=itemAttr.attribute("Value");
02007                                    objattr.parameter=itemAttr.attribute("Parameter");
02008                                    objattr.relationship=itemAttr.attribute("Relationship");
02009                                    objattr.relationshipto=itemAttr.attribute("RelationshipTo");
02010                                    objattr.autoaddto=itemAttr.attribute("AutoAddTo");
02011                                    appPrefs.defaultItemAttributes.append(objattr);
02012                             }
02013                             DIA = DIA.nextSibling();
02014                      }
02015               }
02016               if(dc.tagName()=="TablesOfContents")
02017               {
02018                      QDomNode TOC = DOC.firstChild();
02019                      appPrefs.defaultToCSetups.clear();
02020                      while(!TOC.isNull())
02021                      {
02022                             QDomElement tocElem = TOC.toElement();
02023                             if(tocElem.tagName() == "TableOfContents")
02024                             {
02025                                    ToCSetup tocsetup;
02026                                    tocsetup.name=tocElem.attribute("Name");
02027                                    tocsetup.itemAttrName=tocElem.attribute("ItemAttributeName");
02028                                    tocsetup.frameName=tocElem.attribute("FrameName");
02029                                    tocsetup.listNonPrintingFrames=tocElem.attribute("ListNonPrinting");
02030                                    tocsetup.textStyle=tocElem.attribute("Style");
02031                                    QString numberPlacement=tocElem.attribute("NumberPlacement");
02032                                    if (numberPlacement=="Beginning")
02033                                           tocsetup.pageLocation=Beginning;
02034                                    if (numberPlacement=="End")
02035                                           tocsetup.pageLocation=End;
02036                                    if (numberPlacement=="NotShown")
02037                                           tocsetup.pageLocation=NotShown;
02038                                    appPrefs.defaultToCSetups.append(tocsetup);
02039                             }
02040                             TOC = TOC.nextSibling();
02041                      }
02042               }
02043               // lorem ispum
02044               if (dc.tagName() == "LoremIpsum")
02045               {
02046                      appPrefs.useStandardLI = static_cast<bool>(dc.attribute("useStandardLI", "0").toInt());
02047                      appPrefs.paragraphsLI = dc.attribute("paragraphsLI", "10").toInt();
02048               }
02049               DOC=DOC.nextSibling();
02050        }
02051        appPrefs.DColors.ensureBlackAndWhite();
02052        if (appPrefs.GUI != "Default")
02053               qApp->setStyle(QStyleFactory::create(appPrefs.GUI));
02054        QFont apf = qApp->font();
02055        apf.setPointSize(appPrefs.AppFontSize);
02056        qApp->setFont(apf,true);
02057        return true;
02058 }
02059 
02060 void PrefsManager::initDefaultCheckerPrefs(CheckerPrefsList* cp)
02061 {
02062        if (cp!=NULL)
02063        {
02064               struct checkerPrefs checkerSettings;
02065               checkerSettings.ignoreErrors = false;
02066               checkerSettings.autoCheck = true;
02067               checkerSettings.checkGlyphs = true;
02068               checkerSettings.checkOrphans = true;
02069               checkerSettings.checkOverflow = true;
02070               checkerSettings.checkPictures = true;
02071               checkerSettings.checkResolution = true;
02072               checkerSettings.checkTransparency = true;
02073               checkerSettings.checkAnnotations = false;
02074               checkerSettings.checkRasterPDF = true;
02075               checkerSettings.checkForGIF = true;
02076               checkerSettings.ignoreOffLayers = false;
02077               checkerSettings.minResolution = 72.0;
02078               checkerSettings.maxResolution = 2400.0;
02079               //TODO Stop translating these into settings!!!!!!!!!
02080               cp->insert( QT_TR_NOOP("PostScript"), checkerSettings);
02081               cp->insert( QT_TR_NOOP("PDF 1.3"), checkerSettings);
02082               checkerSettings.checkTransparency = false;
02083               cp->insert( QT_TR_NOOP("PDF 1.4"), checkerSettings);
02084               cp->insert( QT_TR_NOOP("PDF 1.5"), checkerSettings);
02085               checkerSettings.checkTransparency = true;
02086               checkerSettings.checkAnnotations = true;
02087               checkerSettings.minResolution = 144.0;
02088               cp->insert( QT_TR_NOOP("PDF/X-3"), checkerSettings);
02089        }
02090 }
02091 
02092 const QString & PrefsManager::lastError() const
02093 {
02094        return m_lastError;
02095 }
02096 
02097 // It's hard to say whether this should be here and called from SavePrefs, or
02098 // triggered by a signal sent from here and displayed by ScribusMainWindow.
02099 void PrefsManager::alertSavePrefsFailed() const
02100 {
02101        QMessageBox::critical(ScCore->primaryMainWindow(), tr("Error Writing Preferences"),
02102                      "<qt>" +
02103                      tr("Scribus was not able to save its preferences:<br>"
02104                         "%1<br>"
02105                         "Please check file and directory permissions and "
02106                         "available disk space.", "scribus app error")
02107                         .arg(lastError())
02108                      + "</qt>",
02109                      QMessageBox::Ok|QMessageBox::Default|QMessageBox::Escape,
02110                      QMessageBox::NoButton);
02111 }
02112 
02113 // It's hard to say whether this should be here and called from ReadPrefs, or
02114 // triggered by a signal sent from here and displayed by ScribusMainWindow.
02115 void PrefsManager::alertLoadPrefsFailed() const
02116 {
02117        bool splashShowing = ScCore->splashShowing();
02118        if (splashShowing)
02119               ScCore->showSplash(false);
02120        QMessageBox::critical(ScCore->primaryMainWindow(), tr("Error Loading Preferences"),
02121                      "<qt>" +
02122                      tr("Scribus was not able to load its preferences:<br>"
02123                         "%1<br>"
02124                         "Default settings will be loaded.")
02125                         .arg(lastError())
02126                      + "</qt>",
02127                      QMessageBox::Ok|QMessageBox::Default|QMessageBox::Escape,
02128                      QMessageBox::NoButton);
02129        ScCore->showSplash(splashShowing);
02130 }
02131 
02132 const int PrefsManager::gsResolution()
02133 {
02134        return appPrefs.gs_Resolution;
02135 }