Rev 16786 | Rev 16856 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4430 | cbradney | 1 | /* |
2 | For general Scribus (>=1.3.2) copyright and licensing information please refer |
||
3 | to the COPYING file provided with the program. Following this notice may exist |
||
4 | a copyright and/or license notice that predates the release of Scribus 1.3.2 |
||
5 | for which a new license (GPL+exception) is in place. |
||
6 | */ |
||
3 | paul | 7 | /*************************************************************************** |
8 | scribusdoc.cpp - description |
||
9 | ------------------- |
||
10 | begin : Fre Apr 6 21:47:55 CEST 2001 |
||
11 | copyright : (C) 2001 by Franz Schmid |
||
12 | email : Franz.Schmid@altmuehlnet.de |
||
13 | ***************************************************************************/ |
||
14 | |||
15 | /*************************************************************************** |
||
16 | * * |
||
17 | * This program is free software; you can redistribute it and/or modify * |
||
18 | * it under the terms of the GNU General Public License as published by * |
||
19 | * the Free Software Foundation; either version 2 of the License, or * |
||
20 | * (at your option) any later version. * |
||
21 | * * |
||
22 | ***************************************************************************/ |
||
10455 | cbradney | 23 | |
15193 | jghali | 24 | #include <memory> |
3670 | cbradney | 25 | #include <utility> |
15239 | jghali | 26 | #include <sstream> |
7736 | cbradney | 27 | |
10749 | cbradney | 28 | #include <QByteArray> |
12660 | fschmid | 29 | #include <QDebug> |
10749 | cbradney | 30 | #include <QEventLoop> |
10220 | cbradney | 31 | #include <QFile> |
10749 | cbradney | 32 | #include <QList> |
12319 | cbradney | 33 | #include <QTime> |
10220 | cbradney | 34 | #include <QPainter> |
10749 | cbradney | 35 | #include <QPixmap> |
9953 | cbradney | 36 | #include <QProgressBar> |
10011 | fschmid | 37 | |
10749 | cbradney | 38 | #include "canvas.h" |
14150 | fschmid | 39 | #include "colorblind.h" |
10212 | cbradney | 40 | #include "commonstrings.h" |
15239 | jghali | 41 | #include "desaxe/digester.h" |
16159 | fschmid | 42 | //#include "desaxe/saxXML.h" |
5642 | cbradney | 43 | #include "fileloader.h" |
3757 | cbradney | 44 | #include "filewatcher.h" |
13544 | cbradney | 45 | #include "ui/guidemanager.h" |
3757 | cbradney | 46 | #include "hyphenator.h" |
456 | fschmid | 47 | #include "pageitem.h" |
3617 | cbradney | 48 | #include "pageitem_imageframe.h" |
10749 | cbradney | 49 | #include "pageitem_latexframe.h" |
3617 | cbradney | 50 | #include "pageitem_line.h" |
51 | #include "pageitem_pathtext.h" |
||
52 | #include "pageitem_polygon.h" |
||
53 | #include "pageitem_polyline.h" |
||
54 | #include "pageitem_textframe.h" |
||
13845 | jghali | 55 | #ifdef HAVE_OSG |
56 | #include "pageitem_osgframe.h" |
||
57 | #endif |
||
15060 | fschmid | 58 | #include "pageitem_symbol.h" |
16105 | fschmid | 59 | #include "pageitem_group.h" |
16191 | fschmid | 60 | #include "pageitem_regularpolygon.h" |
16215 | fschmid | 61 | #include "pageitem_arc.h" |
16311 | fschmid | 62 | #include "pageitem_spiral.h" |
13551 | cbradney | 63 | #include "ui/pagepalette.h" |
10749 | cbradney | 64 | #include "pagesize.h" |
3757 | cbradney | 65 | #include "pagestructs.h" |
6124 | cbradney | 66 | #include "prefsfile.h" |
3757 | cbradney | 67 | #include "prefsmanager.h" |
8455 | avox | 68 | #include "resourcecollection.h" |
14744 | fschmid | 69 | #include "scclocale.h" |
15023 | jghali | 70 | #include "sclimits.h" |
16736 | jghali | 71 | #include "sccolorengine.h" |
16729 | fschmid | 72 | #include "scpage.h" |
16736 | jghali | 73 | #include "scpainter.h" |
4688 | cbradney | 74 | #include "scraction.h" |
10749 | cbradney | 75 | #include "scribus.h" |
5642 | cbradney | 76 | #include "scribusXml.h" |
10749 | cbradney | 77 | #include "scribuscore.h" |
78 | #include "scribusdoc.h" |
||
79 | #include "scribusview.h" |
||
80 | #include "scribuswin.h" |
||
3903 | cbradney | 81 | #include "selection.h" |
12407 | pierre | 82 | #include "serializer.h" |
10212 | cbradney | 83 | #include "text/nlsconfig.h" |
1179 | tsoots | 84 | #include "undomanager.h" |
2965 | cbradney | 85 | #include "units.h" |
3809 | cbradney | 86 | #include "util.h" |
10212 | cbradney | 87 | #include "util_icon.h" |
10203 | cbradney | 88 | #include "util_math.h" |
410 | Franz | 89 | |
16736 | jghali | 90 | #include "colormgmt/sccolormgmtenginefactory.h" |
91 | #include "ui/hruler.h" |
||
92 | #include "ui/layers.h" |
||
93 | #include "ui/scmessagebox.h" |
||
94 | #include "ui/storyeditor.h" |
||
3205 | craig | 95 | |
10684 | fschmid | 96 | // static const bool FRAMESELECTION_EDITS_DEFAULTSTYLE = false; |
9607 | avox | 97 | |
10532 | avox | 98 | |
99 | |||
100 | /** |
||
101 | This class forwards change events for pages and pageitems to |
||
102 | the region occupied by this page or pageitem. |
||
103 | */ |
||
16729 | fschmid | 104 | class DocUpdater : public Observer<ScPage*>, public Observer<PageItem*> |
10532 | avox | 105 | { |
106 | ScribusDoc* doc; |
||
14283 | jghali | 107 | int m_updateEnabled; |
108 | bool m_docChangeNeeded; |
||
10532 | avox | 109 | public: |
14283 | jghali | 110 | DocUpdater(ScribusDoc* d) : doc(d), m_updateEnabled(0), m_docChangeNeeded(false) {} |
111 | |||
14370 | jghali | 112 | bool inUpdateSession() const |
113 | { |
||
114 | return m_updateEnabled > 0; |
||
115 | } |
||
116 | |||
14283 | jghali | 117 | void beginUpdate(void) |
118 | { |
||
119 | if (m_updateEnabled == 0) |
||
120 | m_docChangeNeeded = false; |
||
121 | ++m_updateEnabled; |
||
122 | } |
||
123 | |||
124 | void endUpdate(void) |
||
125 | { |
||
126 | --m_updateEnabled; |
||
127 | if (m_updateEnabled <= 0) |
||
128 | { |
||
129 | if (m_docChangeNeeded) |
||
130 | { |
||
131 | doc->changed(); |
||
132 | m_docChangeNeeded = false; |
||
133 | } |
||
134 | } |
||
135 | } |
||
10532 | avox | 136 | |
16729 | fschmid | 137 | void changed(ScPage* pg, bool /*doLayout*/) |
10532 | avox | 138 | { |
11046 | avox | 139 | QRectF pagebox(pg->xOffset(), pg->yOffset(), pg->width(), pg->height()); |
140 | doc->invalidateRegion(pagebox); |
||
141 | doc->regionsChanged()->update(pagebox); |
||
14283 | jghali | 142 | if (m_updateEnabled <= 0) |
143 | { |
||
144 | doc->changed(); |
||
145 | return; |
||
146 | } |
||
147 | m_docChangeNeeded = true; |
||
10532 | avox | 148 | } |
149 | |||
16639 | jghali | 150 | void changed(PageItem* it, bool doLayout) |
10532 | avox | 151 | { |
11046 | avox | 152 | it->invalidateLayout(); |
16639 | jghali | 153 | if (doLayout) |
154 | it->layout(); |
||
14197 | fschmid | 155 | doc->regionsChanged()->update(it->getVisualBoundingRect()); |
14283 | jghali | 156 | if (m_updateEnabled <= 0) |
157 | { |
||
158 | doc->changed(); |
||
159 | return; |
||
160 | } |
||
161 | m_docChangeNeeded = true; |
||
10532 | avox | 162 | } |
163 | }; |
||
164 | |||
165 | |||
166 | |||
167 | |||
168 | ScribusDoc::ScribusDoc() : UndoObject( tr("Document")), Observable<ScribusDoc>(NULL), |
||
5892 | jghali | 169 | m_hasGUI(false), |
14871 | cbradney | 170 | appPrefsData(PrefsManager::instance()->appPrefs), |
171 | docPrefsData(PrefsManager::instance()->appPrefs), |
||
3983 | craig | 172 | undoManager(UndoManager::instance()), |
173 | loading(false), |
||
174 | modified(false), |
||
175 | ActiveLayer(0), |
||
13839 | fschmid | 176 | rotMode(0), |
3983 | craig | 177 | automaticTextFrames(0), |
178 | m_masterPageMode(false), |
||
16029 | fschmid | 179 | m_symbolEditMode(false), |
5781 | cbradney | 180 | m_ScMW(0), |
5798 | jghali | 181 | m_View(0), |
7906 | jghali | 182 | m_guardedObject(this), |
13659 | cbradney | 183 | m_serializer(NULL), |
3983 | craig | 184 | is12doc(false), |
185 | NrItems(0), |
||
186 | First(1), Last(0), |
||
187 | viewCount(0), viewID(0), |
||
188 | SnapGuides(false), GuideLock(false), |
||
189 | minCanvasCoordinate(FPoint(0, 0)), |
||
190 | rulerXoffset(0.0), rulerYoffset(0.0), |
||
3984 | craig | 191 | Pages(0), MasterPages(), DocPages(), |
3983 | craig | 192 | MasterNames(), |
5885 | jghali | 193 | Items(0), MasterItems(), DocItems(), FrameItems(), |
4847 | cbradney | 194 | m_Selection(new Selection(this, true)), |
3983 | craig | 195 | PageSp(1), PageSpa(0), |
196 | FirstPnum(1), |
||
197 | useRaster(false), |
||
5892 | jghali | 198 | PageColors(this, true), |
3983 | craig | 199 | appMode(modeNormal), |
200 | SubMode(-1), |
||
201 | ShapeValues(0), |
||
202 | ValCount(0), |
||
6260 | fschmid | 203 | DocName( tr("Document")+"-"), |
3983 | craig | 204 | UsedFonts(), |
14871 | cbradney | 205 | AllFonts(&appPrefsData.fontPrefs.AvailFonts), |
3983 | craig | 206 | AObjects(), |
207 | CurrentSel(-1), |
||
10532 | avox | 208 | nodeEdit(), |
3983 | craig | 209 | LastAuto(0), FirstAuto(0), |
210 | DraggedElem(0), |
||
211 | ElemToLink(0), |
||
212 | DragElements(), |
||
213 | docParagraphStyles(), |
||
5980 | avox | 214 | docCharStyles(), |
3983 | craig | 215 | Layers(), |
216 | GroupCounter(1), |
||
14170 | jghali | 217 | colorEngine(ScCore->defaultEngine), |
3983 | craig | 218 | JavaScripts(), |
219 | TotalItems(0), |
||
220 | RePos(false), |
||
221 | BookMarks(), |
||
222 | OldBM(false), |
||
223 | hasName(false), |
||
224 | autoSaveTimer(new QTimer(this)), |
||
225 | MLineStyles(), |
||
226 | WinHan(0), |
||
227 | DoDrawing(true), |
||
228 | OpenNodes(), |
||
229 | CurTimer(0), |
||
5696 | avox | 230 | docLayerErrors(), |
3983 | craig | 231 | docItemErrors(), |
232 | masterItemErrors(), |
||
233 | symReturn(), symNewLine(), symTab(), symNonBreak(), symNewCol(), symNewFrame(), |
||
5781 | cbradney | 234 | docHyphenator(0), |
11576 | avox | 235 | m_itemCreationTransaction(NULL), |
11625 | jghali | 236 | m_alignTransaction(NULL), |
237 | m_currentPage(NULL), |
||
238 | m_updateManager(), |
||
239 | m_docUpdater(NULL) |
||
3 | paul | 240 | { |
14924 | cbradney | 241 | docUnitRatio=unitGetRatioFromIndex(docPrefsData.docSetupPrefs.docUnitIndex); |
14991 | cbradney | 242 | docPrefsData.docSetupPrefs.pageHeight=0; |
243 | docPrefsData.docSetupPrefs.pageWidth=0; |
||
15407 | craig | 244 | docPrefsData.docSetupPrefs.pagePositioning=0; |
14924 | cbradney | 245 | maxCanvasCoordinate=(FPoint(docPrefsData.displayPrefs.scratch.Left + docPrefsData.displayPrefs.scratch.Right, docPrefsData.displayPrefs.scratch.Top + docPrefsData.displayPrefs.scratch.Bottom)), |
5789 | cbradney | 246 | init(); |
14992 | cbradney | 247 | docPrefsData.pdfPrefs.bleeds = docPrefsData.docSetupPrefs.bleeds; |
14925 | cbradney | 248 | docPrefsData.pdfPrefs.useDocBleeds = true; |
7104 | fschmid | 249 | Print_Options.firstUse = true; |
16177 | fschmid | 250 | drawAsPreview = false; |
16241 | fschmid | 251 | viewAsPreview = false; |
252 | previewVisual = -1; |
||
5789 | cbradney | 253 | } |
254 | |||
10532 | avox | 255 | |
5789 | cbradney | 256 | ScribusDoc::ScribusDoc(const QString& docName, int unitindex, const PageSize& pagesize, const MarginStruct& margins, const DocPagesSetup& pagesSetup) : UndoObject( tr("Document")), |
5892 | jghali | 257 | m_hasGUI(false), |
14871 | cbradney | 258 | appPrefsData(PrefsManager::instance()->appPrefs), |
259 | docPrefsData(PrefsManager::instance()->appPrefs), |
||
5789 | cbradney | 260 | undoManager(UndoManager::instance()), |
261 | loading(false), |
||
262 | modified(false), |
||
263 | ActiveLayer(0), |
||
14924 | cbradney | 264 | docUnitRatio(unitGetRatioFromIndex(appPrefsData.docSetupPrefs.docUnitIndex)), |
13839 | fschmid | 265 | rotMode(0), |
5789 | cbradney | 266 | automaticTextFrames(pagesSetup.autoTextFrames), |
267 | m_masterPageMode(false), |
||
16029 | fschmid | 268 | m_symbolEditMode(false), |
5789 | cbradney | 269 | m_ScMW(0), |
270 | m_View(0), |
||
7906 | jghali | 271 | m_guardedObject(this), |
13659 | cbradney | 272 | m_serializer(NULL), |
5789 | cbradney | 273 | is12doc(false), |
274 | NrItems(0), |
||
275 | First(1), Last(0), |
||
276 | viewCount(0), viewID(0), |
||
277 | SnapGuides(false), GuideLock(false), |
||
278 | minCanvasCoordinate(FPoint(0, 0)), |
||
279 | rulerXoffset(0.0), rulerYoffset(0.0), |
||
280 | Pages(0), MasterPages(), DocPages(), |
||
281 | MasterNames(), |
||
282 | Items(0), MasterItems(), DocItems(), FrameItems(), |
||
283 | m_Selection(new Selection(this, true)), |
||
284 | PageSp(pagesSetup.columnCount), PageSpa(pagesSetup.columnDistance), |
||
285 | FirstPnum(pagesSetup.firstPageNumber), |
||
286 | useRaster(false), |
||
5892 | jghali | 287 | PageColors(this, true), |
5789 | cbradney | 288 | appMode(modeNormal), |
289 | SubMode(-1), |
||
290 | ShapeValues(0), |
||
291 | ValCount(0), |
||
292 | DocName(docName), |
||
293 | UsedFonts(), |
||
14871 | cbradney | 294 | AllFonts(&appPrefsData.fontPrefs.AvailFonts), |
5789 | cbradney | 295 | AObjects(), |
296 | CurrentSel(-1), |
||
10532 | avox | 297 | nodeEdit(), |
5789 | cbradney | 298 | LastAuto(0), FirstAuto(0), |
299 | DraggedElem(0), |
||
300 | ElemToLink(0), |
||
301 | DragElements(), |
||
302 | docParagraphStyles(), |
||
5980 | avox | 303 | docCharStyles(), |
5789 | cbradney | 304 | Layers(), |
305 | GroupCounter(1), |
||
14170 | jghali | 306 | colorEngine(ScCore->defaultEngine), |
5789 | cbradney | 307 | JavaScripts(), |
308 | TotalItems(0), |
||
309 | RePos(false), |
||
310 | BookMarks(), |
||
311 | OldBM(false), |
||
312 | hasName(false), |
||
313 | autoSaveTimer(new QTimer(this)), |
||
314 | MLineStyles(), |
||
315 | WinHan(0), |
||
316 | DoDrawing(true), |
||
317 | OpenNodes(), |
||
318 | CurTimer(0), |
||
319 | docLayerErrors(), |
||
320 | docItemErrors(), |
||
321 | masterItemErrors(), |
||
322 | symReturn(), symNewLine(), symTab(), symNonBreak(), symNewCol(), symNewFrame(), |
||
323 | docHyphenator(0), |
||
11576 | avox | 324 | m_itemCreationTransaction(NULL), |
11625 | jghali | 325 | m_alignTransaction(NULL), |
326 | m_currentPage(NULL), |
||
327 | m_updateManager(), |
||
328 | m_docUpdater(NULL) |
||
5789 | cbradney | 329 | { |
14924 | cbradney | 330 | docPrefsData.docSetupPrefs.docUnitIndex=unitindex; |
14991 | cbradney | 331 | docPrefsData.docSetupPrefs.pageHeight=pagesize.height(); |
332 | docPrefsData.docSetupPrefs.pageWidth=pagesize.width(); |
||
333 | docPrefsData.docSetupPrefs.pageSize=pagesize.name(); |
||
14994 | cbradney | 334 | docPrefsData.docSetupPrefs.margins=margins; |
14924 | cbradney | 335 | maxCanvasCoordinate=(FPoint(docPrefsData.displayPrefs.scratch.Left + docPrefsData.displayPrefs.scratch.Right, docPrefsData.displayPrefs.scratch.Top + docPrefsData.displayPrefs.scratch.Bottom)), |
336 | setPageSetFirstPage(pagesSetup.pageArrangement, pagesSetup.firstPageLocation); |
||
5789 | cbradney | 337 | init(); |
14992 | cbradney | 338 | docPrefsData.pdfPrefs.bleeds = docPrefsData.docSetupPrefs.bleeds; |
14925 | cbradney | 339 | docPrefsData.pdfPrefs.useDocBleeds = true; |
14991 | cbradney | 340 | docPrefsData.docSetupPrefs.pageOrientation=pagesSetup.orientation; |
15407 | craig | 341 | docPrefsData.docSetupPrefs.pagePositioning=pagesSetup.pageArrangement; |
7104 | fschmid | 342 | Print_Options.firstUse = true; |
16177 | fschmid | 343 | drawAsPreview = false; |
16241 | fschmid | 344 | viewAsPreview = false; |
345 | previewVisual = -1; |
||
5789 | cbradney | 346 | } |
347 | |||
10532 | avox | 348 | |
5789 | cbradney | 349 | void ScribusDoc::init() |
350 | { |
||
4847 | cbradney | 351 | Q_CHECK_PTR(m_Selection); |
3983 | craig | 352 | Q_CHECK_PTR(autoSaveTimer); |
353 | |||
5880 | jghali | 354 | HasCMS = false; |
15001 | cbradney | 355 | docPrefsData.colorPrefs.DCMSset.CMSinUse = false; |
6464 | jghali | 356 | |
14170 | jghali | 357 | colorEngine = ScCore->defaultEngine; |
10338 | jghali | 358 | SetDefaultCMSParams(); |
5880 | jghali | 359 | |
10532 | avox | 360 | // init update change management |
361 | setUpdateManager(&m_updateManager); |
||
362 | m_itemsChanged.setUpdateManager(&m_updateManager); |
||
363 | m_pagesChanged.setUpdateManager(&m_updateManager); |
||
364 | m_regionsChanged.setUpdateManager(&m_updateManager); |
||
365 | nodeEdit.setUpdateManager(&m_updateManager); |
||
366 | |||
367 | // setup update() event chains |
||
368 | m_docUpdater = new DocUpdater(this); |
||
369 | m_itemsChanged.connectObserver(m_docUpdater); |
||
370 | m_pagesChanged.connectObserver(m_docUpdater); |
||
371 | |||
6464 | jghali | 372 | PrefsManager *prefsManager = PrefsManager::instance(); |
15001 | cbradney | 373 | docPrefsData.colorPrefs.DCMSset = prefsManager->appPrefs.colorPrefs.DCMSset; |
374 | docPrefsData.pdfPrefs.SolidProf = docPrefsData.colorPrefs.DCMSset.DefaultSolidColorRGBProfile; |
||
375 | docPrefsData.pdfPrefs.ImageProf = docPrefsData.colorPrefs.DCMSset.DefaultImageRGBProfile; |
||
376 | docPrefsData.pdfPrefs.PrintProf = docPrefsData.colorPrefs.DCMSset.DefaultPrinterProfile; |
||
377 | docPrefsData.pdfPrefs.Intent = docPrefsData.colorPrefs.DCMSset.DefaultIntentColors; |
||
378 | docPrefsData.pdfPrefs.Intent2 = docPrefsData.colorPrefs.DCMSset.DefaultIntentImages; |
||
6464 | jghali | 379 | |
14871 | cbradney | 380 | AddFont(appPrefsData.itemToolPrefs.textFont);//, prefsData.AvailFonts[prefsData.itemToolPrefs.textFont]->Font); |
14932 | cbradney | 381 | //FIXME: aren't we doing this now anyway with prefs struct copy? |
382 | docPrefsData.itemToolPrefs.textFont = appPrefsData.itemToolPrefs.textFont; |
||
383 | docPrefsData.itemToolPrefs.textSize = appPrefsData.itemToolPrefs.textSize; |
||
384 | docPrefsData.itemToolPrefs.textTabFillChar = appPrefsData.itemToolPrefs.textTabFillChar; |
||
385 | docPrefsData.opToolPrefs.dispX = appPrefsData.opToolPrefs.dispX; |
||
386 | docPrefsData.opToolPrefs.dispY = appPrefsData.opToolPrefs.dispY; |
||
387 | docPrefsData.opToolPrefs.constrain = appPrefsData.opToolPrefs.constrain; |
||
5880 | jghali | 388 | |
15912 | jghali | 389 | PageColors.ensureDefaultColors(); |
14871 | cbradney | 390 | if (appPrefsData.itemToolPrefs.shapeLineColor != CommonStrings::None) |
391 | PageColors.insert(appPrefsData.itemToolPrefs.shapeLineColor, appPrefsData.colorPrefs.DColors[appPrefsData.itemToolPrefs.shapeLineColor]); |
||
14932 | cbradney | 392 | docPrefsData.itemToolPrefs.shapeLineColor = appPrefsData.itemToolPrefs.shapeLineColor; |
14871 | cbradney | 393 | if (appPrefsData.itemToolPrefs.lineColor != CommonStrings::None) |
394 | PageColors.insert(appPrefsData.itemToolPrefs.lineColor, appPrefsData.colorPrefs.DColors[appPrefsData.itemToolPrefs.lineColor]); |
||
14932 | cbradney | 395 | docPrefsData.itemToolPrefs.lineColor = appPrefsData.itemToolPrefs.lineColor; |
14871 | cbradney | 396 | if (appPrefsData.itemToolPrefs.textColor != CommonStrings::None) |
397 | PageColors.insert(appPrefsData.itemToolPrefs.textColor, appPrefsData.colorPrefs.DColors[appPrefsData.itemToolPrefs.textColor]); |
||
14932 | cbradney | 398 | docPrefsData.itemToolPrefs.textColor = appPrefsData.itemToolPrefs.textColor; |
14871 | cbradney | 399 | if (appPrefsData.itemToolPrefs.textStrokeColor != CommonStrings::None) |
400 | PageColors.insert(appPrefsData.itemToolPrefs.textStrokeColor, appPrefsData.colorPrefs.DColors[appPrefsData.itemToolPrefs.textStrokeColor]); |
||
14932 | cbradney | 401 | docPrefsData.itemToolPrefs.textStrokeColor = appPrefsData.itemToolPrefs.textStrokeColor; |
14871 | cbradney | 402 | if (appPrefsData.itemToolPrefs.shapeFillColor != CommonStrings::None) |
403 | PageColors.insert(appPrefsData.itemToolPrefs.shapeFillColor, appPrefsData.colorPrefs.DColors[appPrefsData.itemToolPrefs.shapeFillColor]); |
||
14932 | cbradney | 404 | docPrefsData.itemToolPrefs.shapeFillColor = appPrefsData.itemToolPrefs.shapeFillColor; |
14871 | cbradney | 405 | if (appPrefsData.itemToolPrefs.imageFillColor != CommonStrings::None) |
406 | PageColors.insert(appPrefsData.itemToolPrefs.imageFillColor, appPrefsData.colorPrefs.DColors[appPrefsData.itemToolPrefs.imageFillColor]); |
||
14932 | cbradney | 407 | docPrefsData.itemToolPrefs.imageFillColor = appPrefsData.itemToolPrefs.imageFillColor; |
14871 | cbradney | 408 | if (appPrefsData.itemToolPrefs.textFillColor != CommonStrings::None) |
409 | PageColors.insert(appPrefsData.itemToolPrefs.textFillColor, appPrefsData.colorPrefs.DColors[appPrefsData.itemToolPrefs.textFillColor]); |
||
14932 | cbradney | 410 | docPrefsData.itemToolPrefs.textFillColor = appPrefsData.itemToolPrefs.textFillColor; |
14871 | cbradney | 411 | if (appPrefsData.itemToolPrefs.textLineColor != CommonStrings::None) |
412 | PageColors.insert(appPrefsData.itemToolPrefs.textLineColor, appPrefsData.colorPrefs.DColors[appPrefsData.itemToolPrefs.textLineColor]); |
||
15847 | fschmid | 413 | if (appPrefsData.itemToolPrefs.calligrapicPenFillColor != CommonStrings::None) |
414 | PageColors.insert(appPrefsData.itemToolPrefs.calligrapicPenFillColor, appPrefsData.colorPrefs.DColors[appPrefsData.itemToolPrefs.calligrapicPenFillColor]); |
||
415 | if (appPrefsData.itemToolPrefs.calligrapicPenLineColor != CommonStrings::None) |
||
416 | PageColors.insert(appPrefsData.itemToolPrefs.calligrapicPenLineColor, appPrefsData.colorPrefs.DColors[appPrefsData.itemToolPrefs.calligrapicPenLineColor]); |
||
6733 | avox | 417 | |
418 | |||
7059 | avox | 419 | ParagraphStyle pstyle; |
12283 | cbradney | 420 | pstyle.setDefaultStyle(true); |
421 | pstyle.setName(CommonStrings::DefaultParagraphStyle); |
||
7059 | avox | 422 | pstyle.setLineSpacingMode(ParagraphStyle::FixedLineSpacing); |
423 | pstyle.setLineSpacing(15); |
||
424 | pstyle.setAlignment(ParagraphStyle::Leftaligned); |
||
425 | pstyle.setLeftMargin(0); |
||
426 | pstyle.setFirstIndent(0); |
||
427 | pstyle.setRightMargin(0); |
||
428 | pstyle.setGapBefore(0); |
||
429 | pstyle.setGapAfter(0); |
||
430 | pstyle.setHasDropCap(false); |
||
431 | pstyle.setDropCapLines(2); |
||
432 | pstyle.setDropCapOffset(0); |
||
7095 | avox | 433 | pstyle.charStyle().setParent(""); |
6733 | avox | 434 | |
7059 | avox | 435 | CharStyle cstyle; |
12283 | cbradney | 436 | cstyle.setDefaultStyle(true); |
437 | cstyle.setName(CommonStrings::DefaultCharacterStyle); |
||
14932 | cbradney | 438 | cstyle.setFont(appPrefsData.fontPrefs.AvailFonts[docPrefsData.itemToolPrefs.textFont]); |
439 | cstyle.setFontSize(docPrefsData.itemToolPrefs.textSize); |
||
9607 | avox | 440 | cstyle.setFeatures(QStringList(CharStyle::INHERIT)); |
14932 | cbradney | 441 | cstyle.setFillColor(docPrefsData.itemToolPrefs.textColor); |
442 | cstyle.setFillShade(docPrefsData.itemToolPrefs.textShade); |
||
443 | cstyle.setStrokeColor(docPrefsData.itemToolPrefs.textStrokeColor); |
||
444 | cstyle.setStrokeShade(docPrefsData.itemToolPrefs.textStrokeShade); |
||
6733 | avox | 445 | cstyle.setBaselineOffset(0); |
446 | cstyle.setShadowXOffset(50); |
||
447 | cstyle.setShadowYOffset(-50); |
||
448 | cstyle.setOutlineWidth(10); |
||
14932 | cbradney | 449 | cstyle.setUnderlineOffset(docPrefsData.typoPrefs.valueUnderlinePos); |
450 | cstyle.setUnderlineWidth(docPrefsData.typoPrefs.valueUnderlineWidth); |
||
451 | cstyle.setStrikethruOffset(docPrefsData.typoPrefs.valueStrikeThruPos); |
||
452 | cstyle.setStrikethruWidth(docPrefsData.typoPrefs.valueStrikeThruPos); |
||
6733 | avox | 453 | cstyle.setScaleH(1000); |
454 | cstyle.setScaleV(1000); |
||
455 | cstyle.setTracking(0); |
||
13955 | cbradney | 456 | cstyle.setLanguage(PrefsManager::instance()->appPrefs.hyphPrefs.Language); |
6733 | avox | 457 | |
7059 | avox | 458 | docParagraphStyles.create(pstyle); |
7018 | avox | 459 | docParagraphStyles.makeDefault( &(docParagraphStyles[0]) ); |
8058 | avox | 460 | |
7059 | avox | 461 | docCharStyles.create(cstyle); |
462 | docCharStyles.makeDefault( &(docCharStyles[0]) ); |
||
8058 | avox | 463 | |
464 | docParagraphStyles[0].breakImplicitCharStyleInheritance(); |
||
8134 | avox | 465 | docParagraphStyles[0].charStyle().setContext( & docCharStyles ); |
8191 | avox | 466 | // docParagraphStyles[0].charStyle().setName( "cdocdefault" ); // DONT TRANSLATE |
7059 | avox | 467 | |
468 | currentStyle = pstyle; |
||
5698 | avox | 469 | |
10146 | jghali | 470 | Layers.addLayer( tr("Background") ); |
14925 | cbradney | 471 | // FIXME: Check PDF version input |
472 | //TODO: Check if this is needed now we ue appPrefsData --> docPrefsData |
||
473 | pdfOptions().Version = (PDFOptions::PDFVersion)appPrefsData.pdfPrefs.Version; |
||
3201 | subik | 474 | |
14925 | cbradney | 475 | pdfOptions().firstUse = true; |
6368 | fschmid | 476 | docPatterns.clear(); |
14150 | fschmid | 477 | docGradients.clear(); |
6368 | fschmid | 478 | |
14925 | cbradney | 479 | if (autoSave() && ScCore->usingGUI()) |
480 | autoSaveTimer->start(autoSaveTime()); |
||
3724 | cbradney | 481 | //Do this after all the collections have been created and cleared! |
482 | m_masterPageMode=true; // quick hack to force the change of pointers in setMasterPageMode(); |
||
483 | setMasterPageMode(false); |
||
2891 | cbradney | 484 | addSymbols(); |
3 | paul | 485 | } |
486 | |||
10532 | avox | 487 | |
3 | paul | 488 | ScribusDoc::~ScribusDoc() |
489 | { |
||
7906 | jghali | 490 | m_guardedObject.nullify(); |
9616 | jghali | 491 | CloseCMSProfiles(); |
14662 | fschmid | 492 | ScCore->fileWatcher->stop(); |
493 | ScCore->fileWatcher->removeFile(DocName); |
||
16105 | fschmid | 494 | QList<PageItem*> allItems; |
14662 | fschmid | 495 | for (int a = 0; a < DocItems.count(); ++a) |
496 | { |
||
497 | PageItem *currItem = DocItems.at(a); |
||
16105 | fschmid | 498 | if (currItem->isGroup()) |
499 | allItems = currItem->getItemList(); |
||
500 | else |
||
501 | allItems.append(currItem); |
||
502 | for (int ii = 0; ii < allItems.count(); ii++) |
||
14662 | fschmid | 503 | { |
16105 | fschmid | 504 | currItem = allItems.at(ii); |
505 | if (currItem->PictureIsAvailable) |
||
506 | ScCore->fileWatcher->removeFile(currItem->Pfile); |
||
507 | if ((currItem->asImageFrame()) && (!currItem->Pfile.isEmpty())) |
||
508 | { |
||
509 | QFileInfo fi(currItem->Pfile); |
||
510 | ScCore->fileWatcher->removeDir(fi.absolutePath()); |
||
511 | } |
||
14662 | fschmid | 512 | } |
16148 | fschmid | 513 | allItems.clear(); |
14662 | fschmid | 514 | } |
515 | for (int a = 0; a < MasterItems.count(); ++a) |
||
516 | { |
||
517 | PageItem *currItem = MasterItems.at(a); |
||
16105 | fschmid | 518 | if (currItem->isGroup()) |
519 | allItems = currItem->getItemList(); |
||
520 | else |
||
521 | allItems.append(currItem); |
||
522 | for (int ii = 0; ii < allItems.count(); ii++) |
||
14662 | fschmid | 523 | { |
16105 | fschmid | 524 | currItem = allItems.at(ii); |
525 | if (currItem->PictureIsAvailable) |
||
526 | ScCore->fileWatcher->removeFile(currItem->Pfile); |
||
527 | if ((currItem->asImageFrame()) && (!currItem->Pfile.isEmpty())) |
||
528 | { |
||
529 | QFileInfo fi(currItem->Pfile); |
||
530 | ScCore->fileWatcher->removeDir(fi.absolutePath()); |
||
531 | } |
||
14662 | fschmid | 532 | } |
16148 | fschmid | 533 | allItems.clear(); |
14662 | fschmid | 534 | } |
535 | for (int a = 0; a < FrameItems.count(); ++a) |
||
536 | { |
||
537 | PageItem *currItem = FrameItems.at(a); |
||
16105 | fschmid | 538 | if (currItem->isGroup()) |
539 | allItems = currItem->getItemList(); |
||
540 | else |
||
541 | allItems.append(currItem); |
||
542 | for (int ii = 0; ii < allItems.count(); ii++) |
||
14662 | fschmid | 543 | { |
16105 | fschmid | 544 | currItem = allItems.at(ii); |
545 | if (currItem->PictureIsAvailable) |
||
546 | ScCore->fileWatcher->removeFile(currItem->Pfile); |
||
547 | if ((currItem->asImageFrame()) && (!currItem->Pfile.isEmpty())) |
||
548 | { |
||
549 | QFileInfo fi(currItem->Pfile); |
||
550 | ScCore->fileWatcher->removeDir(fi.absolutePath()); |
||
551 | } |
||
14662 | fschmid | 552 | } |
16148 | fschmid | 553 | allItems.clear(); |
14662 | fschmid | 554 | } |
555 | QStringList patterns = docPatterns.keys(); |
||
556 | for (int c = 0; c < patterns.count(); ++c) |
||
557 | { |
||
558 | ScPattern pa = docPatterns[patterns[c]]; |
||
559 | for (int o = 0; o < pa.items.count(); o++) |
||
560 | { |
||
561 | PageItem *currItem = pa.items.at(o); |
||
16105 | fschmid | 562 | if (currItem->isGroup()) |
563 | allItems = currItem->getItemList(); |
||
564 | else |
||
565 | allItems.append(currItem); |
||
566 | for (int ii = 0; ii < allItems.count(); ii++) |
||
14662 | fschmid | 567 | { |
16105 | fschmid | 568 | currItem = allItems.at(ii); |
569 | if (currItem->itemType() == PageItem::ImageFrame) |
||
16016 | fschmid | 570 | { |
16105 | fschmid | 571 | if ((currItem->PictureIsAvailable) && (!currItem->Pfile.isEmpty())) |
572 | { |
||
573 | ScCore->fileWatcher->removeFile(currItem->Pfile); |
||
574 | QFileInfo fi(currItem->Pfile); |
||
575 | ScCore->fileWatcher->removeDir(fi.absolutePath()); |
||
576 | } |
||
16016 | fschmid | 577 | } |
14662 | fschmid | 578 | } |
16148 | fschmid | 579 | allItems.clear(); |
14662 | fschmid | 580 | } |
16016 | fschmid | 581 | while (!pa.items.isEmpty()) |
582 | { |
||
583 | delete pa.items.takeFirst(); |
||
584 | } |
||
14662 | fschmid | 585 | } |
16016 | fschmid | 586 | docPatterns.clear(); |
587 | docGradients.clear(); |
||
9856 | fschmid | 588 | while (!DocItems.isEmpty()) |
589 | { |
||
590 | delete DocItems.takeFirst(); |
||
591 | } |
||
16016 | fschmid | 592 | while (!FrameItems.isEmpty()) |
593 | { |
||
594 | delete FrameItems.takeFirst(); |
||
595 | } |
||
596 | // FrameItems.clear(); |
||
10013 | cbradney | 597 | |
598 | while (!MasterPages.isEmpty()) |
||
599 | { |
||
600 | delete MasterPages.takeFirst(); |
||
601 | } |
||
602 | while (!DocPages.isEmpty()) |
||
603 | { |
||
604 | delete DocPages.takeFirst(); |
||
605 | } |
||
9856 | fschmid | 606 | while (!MasterItems.isEmpty()) |
607 | { |
||
608 | delete MasterItems.takeFirst(); |
||
609 | } |
||
3544 | avox | 610 | QMap<QString,int>::Iterator it3; |
494 | fschmid | 611 | for (it3 = UsedFonts.begin(); it3 != UsedFonts.end(); ++it3) |
612 | { |
||
5980 | avox | 613 | if (!(*AllFonts)[it3.key()].localForDocument().isEmpty()) |
494 | fschmid | 614 | (*AllFonts).removeFont(it3.key()); |
5559 | avox | 615 | else |
5980 | avox | 616 | (*AllFonts)[it3.key()].decreaseUsage(); |
494 | fschmid | 617 | } |
12993 | jghali | 618 | if (docHyphenator) |
619 | delete docHyphenator; |
||
14681 | fschmid | 620 | if (m_serializer) |
621 | delete m_serializer; |
||
14662 | fschmid | 622 | ScCore->fileWatcher->start(); |
3 | paul | 623 | } |
624 | |||
16105 | fschmid | 625 | QList<PageItem*> ScribusDoc::getAllItems(QList<PageItem*> &items) |
626 | { |
||
627 | QList<PageItem*> ret; |
||
628 | for (int em = 0; em < items.count(); ++em) |
||
629 | { |
||
630 | PageItem* embedded = items.at(em); |
||
631 | ret.append(embedded); |
||
632 | if (embedded->isGroup()) |
||
633 | ret += embedded->getItemList(); |
||
634 | } |
||
635 | return ret; |
||
636 | } |
||
10532 | avox | 637 | |
16594 | fschmid | 638 | QList<PageItem*> *ScribusDoc::parentGroup(PageItem* item, QList<PageItem*> *list) |
639 | { |
||
640 | QList<PageItem*> *retList = NULL; |
||
641 | if (list->contains(item)) |
||
642 | retList = list; |
||
643 | else |
||
644 | { |
||
645 | for (int a = 0; a < list->count(); ++a) |
||
646 | { |
||
647 | PageItem* embedded = list->at(a); |
||
648 | if (embedded->isGroup()) |
||
649 | { |
||
650 | retList = parentGroup(item, &embedded->asGroupFrame()->groupItemList); |
||
651 | if (retList != NULL) |
||
652 | break; |
||
653 | } |
||
654 | } |
||
655 | } |
||
656 | return retList; |
||
657 | } |
||
658 | |||
2901 | fschmid | 659 | void ScribusDoc::setup(const int unitIndex, const int fp, const int firstLeft, const int orientation, const int firstPageNumber, const QString& defaultPageSize, const QString& documentName) |
2891 | cbradney | 660 | { |
14924 | cbradney | 661 | docPrefsData.docSetupPrefs.docUnitIndex=unitIndex; |
662 | setPageSetFirstPage(fp, firstLeft); |
||
14991 | cbradney | 663 | docPrefsData.docSetupPrefs.pageOrientation = orientation; |
664 | docPrefsData.docSetupPrefs.pageSize = defaultPageSize; |
||
2891 | cbradney | 665 | FirstPnum = firstPageNumber; |
15407 | craig | 666 | docPrefsData.docSetupPrefs.pagePositioning = fp; |
2891 | cbradney | 667 | setName(documentName); |
5880 | jghali | 668 | HasCMS = false; |
14925 | cbradney | 669 | if (!pdfOptions().UseLPI) |
4039 | fschmid | 670 | { |
14925 | cbradney | 671 | pdfOptions().LPISettings.clear(); |
4039 | fschmid | 672 | struct LPIData lpo; |
11726 | cbradney | 673 | lpo.Frequency = 133; |
11720 | cbradney | 674 | lpo.SpotFunc = 3; |
4039 | fschmid | 675 | lpo.Angle = 105; |
14925 | cbradney | 676 | pdfOptions().LPISettings.insert("Cyan", lpo); |
4039 | fschmid | 677 | lpo.Angle = 75; |
14925 | cbradney | 678 | pdfOptions().LPISettings.insert("Magenta", lpo); |
4039 | fschmid | 679 | lpo.Angle = 90; |
14925 | cbradney | 680 | pdfOptions().LPISettings.insert("Yellow", lpo); |
4039 | fschmid | 681 | lpo.Angle = 45; |
14925 | cbradney | 682 | pdfOptions().LPISettings.insert("Black", lpo); |
4039 | fschmid | 683 | ActiveLayer = 0; |
684 | } |
||
3201 | subik | 685 | |
2891 | cbradney | 686 | appMode = modeNormal; |
687 | PrefsManager *prefsManager=PrefsManager::instance(); |
||
14150 | fschmid | 688 | |
15001 | cbradney | 689 | docPrefsData.colorPrefs.DCMSset = prefsManager->appPrefs.colorPrefs.DCMSset; |
690 | docPrefsData.pdfPrefs.SolidProf = docPrefsData.colorPrefs.DCMSset.DefaultSolidColorRGBProfile; |
||
691 | docPrefsData.pdfPrefs.ImageProf = docPrefsData.colorPrefs.DCMSset.DefaultImageRGBProfile; |
||
692 | docPrefsData.pdfPrefs.PrintProf = docPrefsData.colorPrefs.DCMSset.DefaultPrinterProfile; |
||
693 | docPrefsData.pdfPrefs.Intent = docPrefsData.colorPrefs.DCMSset.DefaultIntentColors; |
||
694 | docPrefsData.pdfPrefs.Intent2 = docPrefsData.colorPrefs.DCMSset.DefaultIntentImages; |
||
695 | BlackPoint = docPrefsData.colorPrefs.DCMSset.BlackPoint; |
||
696 | SoftProofing = docPrefsData.colorPrefs.DCMSset.SoftProofOn; |
||
697 | Gamut = docPrefsData.colorPrefs.DCMSset.GamutCheck; |
||
698 | IntentColors = docPrefsData.colorPrefs.DCMSset.DefaultIntentColors; |
||
699 | IntentImages = docPrefsData.colorPrefs.DCMSset.DefaultIntentImages; |
||
700 | if (ScCore->haveCMS() && docPrefsData.colorPrefs.DCMSset.CMSinUse) |
||
2891 | cbradney | 701 | { |
5345 | mrdocs | 702 | if (OpenCMSProfiles(ScCore->InputProfiles, ScCore->InputProfilesCMYK, ScCore->MonitorProfiles, ScCore->PrinterProfiles)) |
5178 | mrdocs | 703 | { |
5880 | jghali | 704 | HasCMS = true; |
15001 | cbradney | 705 | pdfOptions().SComp = docPrefsData.colorPrefs.DCMSset.ComponentsInput2; |
5178 | mrdocs | 706 | } |
707 | else |
||
10338 | jghali | 708 | { |
709 | SetDefaultCMSParams(); |
||
5880 | jghali | 710 | HasCMS = false; |
10338 | jghali | 711 | } |
2891 | cbradney | 712 | } |
713 | } |
||
714 | |||
10532 | avox | 715 | |
5824 | cbradney | 716 | void ScribusDoc::setGUI(bool hasgui, ScribusMainWindow* mw, ScribusView* view) |
5781 | cbradney | 717 | { |
5824 | cbradney | 718 | m_hasGUI = hasgui; |
14681 | fschmid | 719 | m_ScMW = mw; |
10532 | avox | 720 | //FIXME: stop using m_View |
14681 | fschmid | 721 | m_View = view; |
722 | if (m_hasGUI) |
||
723 | { |
||
724 | docHyphenator = new Hyphenator(m_ScMW, this); |
||
725 | Q_CHECK_PTR(docHyphenator); |
||
726 | } |
||
727 | else |
||
728 | docHyphenator = NULL; |
||
5781 | cbradney | 729 | } |
730 | |||
10532 | avox | 731 | |
2891 | cbradney | 732 | void ScribusDoc::setLoading(const bool docLoading) |
733 | { |
||
734 | loading = docLoading; |
||
735 | } |
||
736 | |||
10532 | avox | 737 | |
3985 | cbradney | 738 | bool ScribusDoc::isLoading() const |
2891 | cbradney | 739 | { |
740 | return loading; |
||
741 | } |
||
742 | |||
10532 | avox | 743 | |
744 | //AV: eeks. That should not be used |
||
4320 | cbradney | 745 | ScribusView* ScribusDoc::view() const |
746 | { |
||
5781 | cbradney | 747 | // return (WinHan ? (((ScribusWin*) WinHan)->view()) : 0); |
748 | return m_View; |
||
4320 | cbradney | 749 | } |
750 | |||
10532 | avox | 751 | |
7906 | jghali | 752 | const ScGuardedPtr<ScribusDoc>& ScribusDoc::guardedPtr() const |
753 | { |
||
754 | return m_guardedObject; |
||
755 | } |
||
756 | |||
10532 | avox | 757 | |
1330 | fschmid | 758 | void ScribusDoc::CloseCMSProfiles() |
759 | { |
||
5880 | jghali | 760 | HasCMS = false; |
10338 | jghali | 761 | SetDefaultCMSParams(); |
1330 | fschmid | 762 | } |
763 | |||
10338 | jghali | 764 | void ScribusDoc::SetDefaultCMSParams() |
765 | { |
||
766 | BlackPoint = true; |
||
767 | SoftProofing = false; |
||
768 | Gamut = false; |
||
14170 | jghali | 769 | IntentColors = Intent_Relative_Colorimetric; |
770 | IntentImages = Intent_Relative_Colorimetric; |
||
10338 | jghali | 771 | DocInputRGBProf = ScCore->defaultRGBProfile; |
772 | DocInputCMYKProf = ScCore->defaultCMYKProfile; |
||
773 | DocInputImageRGBProf = ScCore->defaultRGBProfile; |
||
774 | DocInputImageCMYKProf = ScCore->defaultCMYKProfile; |
||
14281 | jghali | 775 | DocDisplayProf = ScCore->defaultRGBProfile; |
10338 | jghali | 776 | DocPrinterProf = ScCore->defaultCMYKProfile; |
777 | stdTransRGBMon = ScCore->defaultRGBToScreenSolidTrans; |
||
778 | stdTransCMYKMon = ScCore->defaultCMYKToRGBTrans; |
||
10393 | jghali | 779 | stdTransRGB = ScCore->defaultCMYKToRGBTrans; |
780 | stdTransCMYK = ScCore->defaultRGBToCMYKTrans; |
||
10338 | jghali | 781 | stdProof = ScCore->defaultRGBToScreenSolidTrans; |
782 | stdProofGC = ScCore->defaultRGBToScreenSolidTrans; |
||
783 | stdProofCMYK = ScCore->defaultCMYKToRGBTrans; |
||
784 | stdProofCMYKGC = ScCore->defaultCMYKToRGBTrans; |
||
785 | stdTransImg = ScCore->defaultRGBToScreenImageTrans; |
||
786 | stdProofImg = ScCore->defaultRGBToScreenImageTrans; |
||
787 | stdProofImgCMYK = ScCore->defaultCMYKToScreenImageTrans; |
||
788 | } |
||
789 | |||
5345 | mrdocs | 790 | bool ScribusDoc::OpenCMSProfiles(ProfilesL InPo, ProfilesL InPoCMYK, ProfilesL MoPo, ProfilesL PrPo) |
1330 | fschmid | 791 | { |
5880 | jghali | 792 | HasCMS = false; |
14170 | jghali | 793 | ScColorProfile inputProf; |
794 | |||
14491 | jghali | 795 | colorEngine = colorMgmtEngineFactory.createDefaultEngine(); |
796 | ScColorMgmtStrategy colorStrategy; |
||
15001 | cbradney | 797 | colorStrategy.useBlackPointCompensation = docPrefsData.colorPrefs.DCMSset.BlackPoint; |
14170 | jghali | 798 | colorStrategy.useBlackPreservation = false; |
799 | colorEngine.setStrategy(colorStrategy); |
||
800 | |||
14281 | jghali | 801 | DocDisplayProf = ScCore->monitorProfile; |
15001 | cbradney | 802 | DocInputRGBProf = colorEngine.openProfileFromFile( InPo[docPrefsData.colorPrefs.DCMSset.DefaultSolidColorRGBProfile] ); |
803 | DocInputCMYKProf = colorEngine.openProfileFromFile( InPoCMYK[docPrefsData.colorPrefs.DCMSset.DefaultSolidColorCMYKProfile] ); |
||
804 | DocPrinterProf = colorEngine.openProfileFromFile( PrPo[docPrefsData.colorPrefs.DCMSset.DefaultPrinterProfile] ); |
||
805 | DocInputImageRGBProf = colorEngine.openProfileFromFile( InPo[docPrefsData.colorPrefs.DCMSset.DefaultImageRGBProfile] ); |
||
806 | DocInputImageCMYKProf = colorEngine.openProfileFromFile( InPoCMYK[docPrefsData.colorPrefs.DCMSset.DefaultImageCMYKProfile] ); |
||
14281 | jghali | 807 | if ((!DocDisplayProf) || (!DocInputRGBProf) || (!DocInputCMYKProf) || (!DocPrinterProf) || (!DocInputImageCMYKProf) || (!DocInputImageRGBProf)) |
1330 | fschmid | 808 | { |
15001 | cbradney | 809 | docPrefsData.colorPrefs.DCMSset.CMSinUse = false; |
5178 | mrdocs | 810 | return false; |
1330 | fschmid | 811 | } |
14170 | jghali | 812 | |
813 | int dcmsFlags = 0; |
||
5369 | mrdocs | 814 | int dcmsFlagsGC = 0; |
15001 | cbradney | 815 | if (docPrefsData.colorPrefs.DCMSset.GamutCheck) |
14170 | jghali | 816 | dcmsFlagsGC |= Ctf_GamutCheck; |
15001 | cbradney | 817 | if (docPrefsData.colorPrefs.DCMSset.BlackPoint) |
1330 | fschmid | 818 | { |
14170 | jghali | 819 | dcmsFlags |= Ctf_BlackPointCompensation; |
820 | dcmsFlagsGC |= Ctf_BlackPointCompensation; |
||
1330 | fschmid | 821 | } |
14170 | jghali | 822 | stdTransRGBMon = colorEngine.createTransform(DocInputRGBProf, Format_RGB_16, |
14281 | jghali | 823 | DocDisplayProf, Format_RGB_16, |
14170 | jghali | 824 | IntentColors, dcmsFlags); |
825 | stdTransCMYKMon = colorEngine.createTransform(DocInputCMYKProf, Format_CMYK_16, |
||
14281 | jghali | 826 | DocDisplayProf, Format_RGB_16, |
14170 | jghali | 827 | IntentColors, dcmsFlags); |
5345 | mrdocs | 828 | // TODO : check input profiles used for images |
15128 | jghali | 829 | stdProofImg = colorEngine.createProofingTransform(DocInputImageRGBProf, Format_BGRA_8, |
830 | DocDisplayProf, Format_BGRA_8, DocPrinterProf, |
||
14170 | jghali | 831 | IntentImages, Intent_Relative_Colorimetric, dcmsFlagsGC); |
832 | stdProofImgCMYK = colorEngine.createProofingTransform(DocInputImageCMYKProf, Format_CMYK_8, |
||
15128 | jghali | 833 | DocDisplayProf, Format_BGRA_8, DocPrinterProf, |
14170 | jghali | 834 | IntentImages, Intent_Relative_Colorimetric, dcmsFlagsGC); |
15128 | jghali | 835 | stdTransImg = colorEngine.createTransform(DocInputRGBProf, Format_BGRA_8, |
836 | DocDisplayProf, Format_BGRA_8, |
||
14170 | jghali | 837 | IntentImages, dcmsFlags); |
838 | stdTransRGB = colorEngine.createTransform(DocInputCMYKProf, Format_CMYK_16, |
||
839 | DocInputRGBProf, Format_RGB_16, |
||
840 | IntentColors, dcmsFlags); |
||
841 | stdTransCMYK = colorEngine.createTransform(DocInputRGBProf, Format_RGB_16, |
||
842 | DocInputCMYKProf, Format_CMYK_16, |
||
843 | IntentColors, dcmsFlags); |
||
844 | |||
845 | ScColorProfile inputProfRGB; |
||
846 | ScColorProfile inputProfCMYK; |
||
14772 | jghali | 847 | if (DocPrinterProf.colorSpace() == ColorSpace_Cmyk) |
1491 | fschmid | 848 | { |
15001 | cbradney | 849 | inputProf = (docPrefsData.colorPrefs.DCMSset.SoftProofOn && docPrefsData.colorPrefs.DCMSset.SoftProofFullOn) ? DocInputCMYKProf : DocPrinterProf; |
6070 | jghali | 850 | inputProfRGB = DocInputRGBProf; |
851 | inputProfCMYK = inputProf; |
||
1491 | fschmid | 852 | } |
853 | else |
||
854 | { |
||
15001 | cbradney | 855 | inputProf = (docPrefsData.colorPrefs.DCMSset.SoftProofOn && docPrefsData.colorPrefs.DCMSset.SoftProofFullOn) ? DocInputRGBProf : DocPrinterProf; |
6070 | jghali | 856 | inputProfRGB = inputProf; |
857 | inputProfCMYK = DocInputCMYKProf; |
||
1491 | fschmid | 858 | } |
14170 | jghali | 859 | stdProof = colorEngine.createProofingTransform(inputProfRGB, Format_RGB_16, |
14281 | jghali | 860 | DocDisplayProf, Format_RGB_16, |
6070 | jghali | 861 | DocPrinterProf, |
862 | IntentColors, |
||
14170 | jghali | 863 | Intent_Relative_Colorimetric, dcmsFlags); |
864 | stdProofGC = colorEngine.createProofingTransform(inputProfRGB, Format_RGB_16, |
||
14281 | jghali | 865 | DocDisplayProf, Format_RGB_16, |
14170 | jghali | 866 | DocPrinterProf, IntentColors, |
14179 | jghali | 867 | Intent_Relative_Colorimetric, dcmsFlags| Ctf_GamutCheck); |
14170 | jghali | 868 | stdProofCMYK = colorEngine.createProofingTransform(inputProfCMYK, Format_CMYK_16, |
14281 | jghali | 869 | DocDisplayProf, Format_RGB_16, |
14170 | jghali | 870 | DocPrinterProf, IntentColors, |
871 | Intent_Relative_Colorimetric, dcmsFlags); |
||
872 | stdProofCMYKGC = colorEngine.createProofingTransform(inputProfCMYK, Format_CMYK_16, |
||
14281 | jghali | 873 | DocDisplayProf, Format_RGB_16, |
6070 | jghali | 874 | DocPrinterProf, |
875 | IntentColors, |
||
14179 | jghali | 876 | Intent_Relative_Colorimetric, dcmsFlags | Ctf_GamutCheck); |
6464 | jghali | 877 | |
14772 | jghali | 878 | if (DocInputRGBProf.colorSpace() == ColorSpace_Rgb) |
15001 | cbradney | 879 | docPrefsData.colorPrefs.DCMSset.ComponentsInput2 = 3; |
14772 | jghali | 880 | if (DocInputRGBProf.colorSpace() == ColorSpace_Cmyk) |
15001 | cbradney | 881 | docPrefsData.colorPrefs.DCMSset.ComponentsInput2 = 4; |
14772 | jghali | 882 | if (DocInputRGBProf.colorSpace() == ColorSpace_Cmy) |
15001 | cbradney | 883 | docPrefsData.colorPrefs.DCMSset.ComponentsInput2 = 3; |
14772 | jghali | 884 | if (DocInputCMYKProf.colorSpace() == ColorSpace_Rgb) |
15001 | cbradney | 885 | docPrefsData.colorPrefs.DCMSset.ComponentsInput3 = 3; |
14772 | jghali | 886 | if (DocInputCMYKProf.colorSpace() == ColorSpace_Cmyk) |
15001 | cbradney | 887 | docPrefsData.colorPrefs.DCMSset.ComponentsInput3 = 4; |
14772 | jghali | 888 | if (DocInputCMYKProf.colorSpace() == ColorSpace_Cmy) |
15001 | cbradney | 889 | docPrefsData.colorPrefs.DCMSset.ComponentsInput3 = 3; |
14772 | jghali | 890 | if (DocPrinterProf.colorSpace() == ColorSpace_Rgb) |
15001 | cbradney | 891 | docPrefsData.colorPrefs.DCMSset.ComponentsPrinter = 3; |
14772 | jghali | 892 | if (DocPrinterProf.colorSpace() == ColorSpace_Cmyk) |
15001 | cbradney | 893 | docPrefsData.colorPrefs.DCMSset.ComponentsPrinter = 4; |
14772 | jghali | 894 | if (DocPrinterProf.colorSpace() == ColorSpace_Cmy) |
15001 | cbradney | 895 | docPrefsData.colorPrefs.DCMSset.ComponentsPrinter = 3; |
6464 | jghali | 896 | |
14179 | jghali | 897 | bool success = (stdTransRGBMon && stdTransCMYKMon && stdProofImg && stdProofImgCMYK && |
898 | stdTransImg && stdTransRGB && stdTransCMYK && stdProof && |
||
899 | stdProofGC && stdProofCMYK && stdProofCMYKGC); |
||
900 | if (!success) |
||
901 | { |
||
902 | CloseCMSProfiles(); |
||
15001 | cbradney | 903 | docPrefsData.colorPrefs.DCMSset.CMSinUse = false; |
14179 | jghali | 904 | QString message = tr("An error occurred while opening ICC profiles, color management is not enabled." ); |
905 | if (ScCore->usingGUI()) |
||
906 | QMessageBox::warning(m_ScMW, CommonStrings::trWarning, message, QMessageBox::Ok, 0, 0); |
||
907 | else |
||
908 | qWarning( "%s", message.toLocal8Bit().data() ); |
||
909 | } |
||
5178 | mrdocs | 910 | return true; |
1330 | fschmid | 911 | } |
912 | |||
10532 | avox | 913 | |
6726 | fschmid | 914 | void ScribusDoc::enableCMS(bool enable) |
915 | { |
||
916 | m_ScMW->setStatusBarInfoText( tr("Adjusting Colors")); |
||
917 | m_ScMW->mainWindowProgressBar->reset(); |
||
14532 | jghali | 918 | int cc = PageColors.count() + MasterItems.count() + DocItems.count(); |
9953 | cbradney | 919 | m_ScMW->mainWindowProgressBar->setMaximum(cc); |
10726 | jghali | 920 | qApp->changeOverrideCursor(QCursor(Qt::WaitCursor)); |
15001 | cbradney | 921 | bool oldCM = docPrefsData.colorPrefs.DCMSset.CMSinUse; |
10726 | jghali | 922 | bool newCM = enable; |
923 | CloseCMSProfiles(); |
||
15001 | cbradney | 924 | docPrefsData.colorPrefs.DCMSset.CMSinUse = newCM; |
925 | HasCMS = docPrefsData.colorPrefs.DCMSset.CMSinUse; |
||
926 | BlackPoint = docPrefsData.colorPrefs.DCMSset.BlackPoint; |
||
927 | SoftProofing = docPrefsData.colorPrefs.DCMSset.SoftProofOn; |
||
928 | Gamut = docPrefsData.colorPrefs.DCMSset.GamutCheck; |
||
929 | IntentColors = docPrefsData.colorPrefs.DCMSset.DefaultIntentColors; |
||
930 | IntentImages = docPrefsData.colorPrefs.DCMSset.DefaultIntentImages; |
||
931 | if (!docPrefsData.colorPrefs.DCMSset.CMSinUse) |
||
6726 | fschmid | 932 | { |
933 | HasCMS = false; |
||
934 | if (oldCM) |
||
935 | { |
||
936 | m_ScMW->recalcColors(m_ScMW->mainWindowProgressBar); |
||
937 | RecalcPictures(&ScCore->InputProfiles, &ScCore->InputProfilesCMYK, m_ScMW->mainWindowProgressBar); |
||
938 | } |
||
939 | } |
||
940 | else if (OpenCMSProfiles(ScCore->InputProfiles, ScCore->InputProfilesCMYK, ScCore->MonitorProfiles, ScCore->PrinterProfiles) ) |
||
941 | { |
||
942 | HasCMS = true; |
||
15001 | cbradney | 943 | docPrefsData.pdfPrefs.SComp = docPrefsData.colorPrefs.DCMSset.ComponentsInput2; |
944 | docPrefsData.pdfPrefs.SolidProf = docPrefsData.colorPrefs.DCMSset.DefaultSolidColorRGBProfile; |
||
945 | docPrefsData.pdfPrefs.ImageProf = docPrefsData.colorPrefs.DCMSset.DefaultImageRGBProfile; |
||
946 | docPrefsData.pdfPrefs.PrintProf = docPrefsData.colorPrefs.DCMSset.DefaultPrinterProfile; |
||
947 | docPrefsData.pdfPrefs.Intent = docPrefsData.colorPrefs.DCMSset.DefaultIntentColors; |
||
6726 | fschmid | 948 | m_ScMW->recalcColors(m_ScMW->mainWindowProgressBar); |
949 | RecalcPictures(&ScCore->InputProfiles, &ScCore->InputProfilesCMYK, m_ScMW->mainWindowProgressBar); |
||
950 | } |
||
951 | else |
||
10338 | jghali | 952 | { |
953 | SetDefaultCMSParams(); |
||
6726 | fschmid | 954 | HasCMS = false; |
10338 | jghali | 955 | } |
9953 | cbradney | 956 | m_ScMW->mainWindowProgressBar->setValue(cc); |
9380 | fschmid | 957 | qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor)); |
6726 | fschmid | 958 | m_ScMW->setStatusBarInfoText(""); |
959 | m_ScMW->mainWindowProgressBar->reset(); |
||
960 | } |
||
7442 | avox | 961 | |
962 | |||
8455 | avox | 963 | void ScribusDoc::getNamedResources(ResourceCollection& lists) const |
964 | { |
||
8776 | cbradney | 965 | lists.availableFonts = AllFonts; |
8775 | cbradney | 966 | lists.availableColors = const_cast<ColorList*>(& PageColors); |
967 | |||
9856 | fschmid | 968 | const QList<PageItem*> * itemlist = & MasterItems; |
8455 | avox | 969 | while (itemlist != NULL) |
970 | { |
||
9856 | fschmid | 971 | for (int i=0; i < itemlist->count(); ++i) |
8455 | avox | 972 | { |
9856 | fschmid | 973 | const PageItem * currItem = const_cast<QList<PageItem*>*>(itemlist)->at(i); |
8455 | avox | 974 | if (currItem) |
9296 | jghali | 975 | currItem->getNamedResources(lists); |
8455 | avox | 976 | } |
977 | if (itemlist == &MasterItems) |
||
978 | itemlist = &DocItems; |
||
979 | else if (itemlist == &DocItems) |
||
980 | itemlist = &FrameItems; |
||
981 | else |
||
982 | itemlist = NULL; |
||
983 | } |
||
10400 | subik | 984 | for (int i = 0; i < docParagraphStyles.count(); ++i) |
8455 | avox | 985 | docParagraphStyles[i].getNamedResources(lists); |
10400 | subik | 986 | for (int i = 0; i < docCharStyles.count(); ++i) |
8455 | avox | 987 | docCharStyles[i].getNamedResources(lists); |
988 | // for (uint i = 0; i < docLineStyles.count(); ++i) |
||
989 | // docLineStyles[i].getNamedResources(lists); |
||
990 | |||
991 | QMap<QString,ScPattern>::ConstIterator it; |
||
992 | for (it = docPatterns.begin(); it != docPatterns.end(); ++it) |
||
993 | { |
||
994 | ScPattern pa = *it; |
||
9856 | fschmid | 995 | for (int o = 0; o < pa.items.count(); o++) |
8455 | avox | 996 | { |
997 | pa.items.at(o)->getNamedResources(lists); |
||
998 | } |
||
14813 | fschmid | 999 | } |
1000 | QMap<QString,VGradient>::ConstIterator itg; |
||
1001 | for (itg = docGradients.begin(); itg != docGradients.end(); ++itg) |
||
1002 | { |
||
1003 | QList<VColorStop*> cstops = itg.value().colorStops(); |
||
1004 | for (uint cst = 0; cst < itg.value().Stops(); ++cst) |
||
1005 | { |
||
1006 | lists.collectColor(cstops.at(cst)->name); |
||
1007 | } |
||
1008 | } |
||
8455 | avox | 1009 | } |
1010 | |||
16386 | fschmid | 1011 | bool ScribusDoc::styleExists(QString styleName) |
1012 | { |
||
1013 | for (int ff = 0; ff < paragraphStyles().count(); ++ff) |
||
1014 | { |
||
1015 | if (paragraphStyles()[ff].name() == styleName) |
||
1016 | return true; |
||
1017 | } |
||
1018 | return false; |
||
1019 | } |
||
8455 | avox | 1020 | |
16396 | fschmid | 1021 | QList<int> ScribusDoc::getSortedStyleList() |
1022 | { |
||
1023 | QList<int> retList; |
||
16682 | jghali | 1024 | for (int ff = 0; ff < docParagraphStyles.count(); ++ff) |
16396 | fschmid | 1025 | { |
16682 | jghali | 1026 | if (docParagraphStyles[ff].parent().isEmpty()) |
16396 | fschmid | 1027 | { |
1028 | if (!retList.contains(ff)) |
||
1029 | retList.append(ff); |
||
16692 | jghali | 1030 | continue; |
16396 | fschmid | 1031 | } |
16692 | jghali | 1032 | |
1033 | QList<int> retList2; |
||
1034 | QString name = docParagraphStyles[ff].name(); |
||
1035 | QString par = docParagraphStyles[ff].parent(); |
||
1036 | retList2.prepend(ff); |
||
1037 | while ((!par.isEmpty()) && (par != name)) |
||
16396 | fschmid | 1038 | { |
16692 | jghali | 1039 | int pp = docParagraphStyles.find(par); |
1040 | if ((pp >= 0) && (!retList2.contains(pp))) |
||
1041 | retList2.prepend(pp); |
||
1042 | par = (pp >= 0) ? docParagraphStyles[pp].parent() : QString(); |
||
16396 | fschmid | 1043 | } |
16692 | jghali | 1044 | for (int r = 0; r < retList2.count(); ++r) |
1045 | { |
||
1046 | if (!retList.contains(retList2[r])) |
||
1047 | retList.append(retList2[r]); |
||
1048 | } |
||
16396 | fschmid | 1049 | } |
1050 | return retList; |
||
1051 | } |
||
16386 | fschmid | 1052 | |
16396 | fschmid | 1053 | QList<int> ScribusDoc::getSortedCharStyleList() |
1054 | { |
||
1055 | QList<int> retList; |
||
1056 | for (int ff = 0; ff < docCharStyles.count(); ++ff) |
||
1057 | { |
||
1058 | if (docCharStyles[ff].parent().isEmpty()) |
||
1059 | { |
||
1060 | if (!retList.contains(ff)) |
||
1061 | retList.append(ff); |
||
16692 | jghali | 1062 | continue; |
16396 | fschmid | 1063 | } |
16692 | jghali | 1064 | |
1065 | QList<int> retList2; |
||
1066 | QString name = docCharStyles[ff].name(); |
||
1067 | QString par = docCharStyles[ff].parent(); |
||
1068 | retList2.prepend(ff); |
||
1069 | while ((!par.isEmpty()) && (par != name)) |
||
16396 | fschmid | 1070 | { |
16692 | jghali | 1071 | int pp = docCharStyles.find(par); |
1072 | if ((pp >= 0) && (!retList2.contains(pp))) |
||
1073 | retList2.prepend(pp); |
||
1074 | par = (pp >= 0) ? docCharStyles[pp].parent() : QString(); |
||
16396 | fschmid | 1075 | } |
16692 | jghali | 1076 | for (int r = 0; r < retList2.count(); ++r) |
1077 | { |
||
1078 | if (!retList.contains(retList2[r])) |
||
1079 | retList.append(retList2[r]); |
||
1080 | } |
||
16396 | fschmid | 1081 | } |
1082 | return retList; |
||
1083 | } |
||
1084 | |||
7947 | cbradney | 1085 | void ScribusDoc::replaceStyles(const QMap<QString,QString>& newNameForOld) |
7442 | avox | 1086 | { |
8455 | avox | 1087 | ResourceCollection newNames; |
8775 | cbradney | 1088 | newNames.mapStyles(newNameForOld); |
8455 | avox | 1089 | replaceNamedResources(newNames); |
1090 | } |
||
1091 | |||
1092 | |||
1093 | void ScribusDoc::replaceNamedResources(ResourceCollection& newNames) |
||
1094 | { |
||
7595 | avox | 1095 | // replace names in items |
9856 | fschmid | 1096 | QList<PageItem*> * itemlist = & MasterItems; |
7442 | avox | 1097 | while (itemlist != NULL) |
1098 | { |
||
9856 | fschmid | 1099 | for (int i=0; i < itemlist->count(); ++i) |
7442 | avox | 1100 | { |
9433 | jghali | 1101 | PageItem * currItem = itemlist->at(i); |
7442 | avox | 1102 | if (currItem) |
9433 | jghali | 1103 | currItem->replaceNamedResources(newNames); |
7442 | avox | 1104 | } |
1105 | if (itemlist == &MasterItems) |
||
1106 | itemlist = &DocItems; |
||
1107 | else if (itemlist == &DocItems) |
||
1108 | itemlist = &FrameItems; |
||
1109 | else |
||
1110 | itemlist = NULL; |
||
1111 | } |
||
8455 | avox | 1112 | |
7595 | avox | 1113 | // replace names in styles... |
1114 | for (int i=docParagraphStyles.count()-1; i >= 0; --i) |
||
1115 | { |
||
8814 | cbradney | 1116 | if (newNames.styles().contains(docParagraphStyles[i].name())) |
1117 | docParagraphStyles.remove(i); |
||
1118 | else |
||
1119 | docParagraphStyles[i].replaceNamedResources(newNames); |
||
8455 | avox | 1120 | } |
1121 | for (int i=docCharStyles.count()-1; i >= 0; --i) |
||
1122 | { |
||
8814 | cbradney | 1123 | if (newNames.charStyles().contains(docCharStyles[i].name())) |
1124 | docCharStyles.remove(i); |
||
1125 | else |
||
1126 | docCharStyles[i].replaceNamedResources(newNames); |
||
8455 | avox | 1127 | } |
1128 | |||
1129 | QMap<QString,ScPattern>::Iterator it; |
||
1130 | for (it = docPatterns.begin(); it != docPatterns.end(); ++it) |
||
1131 | { |
||
8814 | cbradney | 1132 | if (newNames.patterns().contains(it.key())) |
10571 | fschmid | 1133 | docPatterns.erase(it); |
8814 | cbradney | 1134 | else |
8455 | avox | 1135 | { |
8814 | cbradney | 1136 | ScPattern pa = *it; |
9856 | fschmid | 1137 | for (int o = 0; o < pa.items.count(); o++) |
8814 | cbradney | 1138 | { |
1139 | pa.items.at(o)->replaceNamedResources(newNames); |
||
1140 | } |
||
8058 | avox | 1141 | } |
8772 | cbradney | 1142 | } |
14150 | fschmid | 1143 | |
1144 | QMap<QString,VGradient>::Iterator itg; |
||
1145 | for (itg = docGradients.begin(); itg != docGradients.end(); ++itg) |
||
1146 | { |
||
1147 | if (newNames.gradients().contains(itg.key())) |
||
1148 | docGradients.erase(itg); |
||
1149 | else |
||
1150 | { |
||
1151 | QMap<QString,QString>::ConstIterator itc; |
||
1152 | QList<VColorStop*> cstops = itg.value().colorStops(); |
||
1153 | for (uint cst = 0; cst < itg.value().Stops(); ++cst) |
||
1154 | { |
||
1155 | itc = newNames.colors().find(cstops.at(cst)->name); |
||
1156 | if (itc != newNames.colors().end()) |
||
1157 | { |
||
1158 | if (*itc != CommonStrings::None) |
||
1159 | cstops.at(cst)->name = *itc; |
||
1160 | } |
||
1161 | } |
||
1162 | } |
||
1163 | } |
||
8772 | cbradney | 1164 | |
8783 | cbradney | 1165 | if (newNames.colors().count() > 0 || newNames.fonts().count() > 0) |
1166 | { |
||
8772 | cbradney | 1167 | docCharStyles.invalidate(); |
1168 | docParagraphStyles.invalidate(); |
||
8783 | cbradney | 1169 | } |
1170 | else |
||
1171 | { |
||
1172 | if (newNames.charStyles().count() > 0) |
||
1173 | docCharStyles.invalidate(); |
||
1174 | if (newNames.styles().count() > 0) |
||
1175 | docParagraphStyles.invalidate(); |
||
1176 | } |
||
8916 | avox | 1177 | if (!isLoading() && !(newNames.colors().isEmpty() && newNames.fonts().isEmpty() && newNames.patterns().isEmpty() |
1178 | && newNames.styles().isEmpty() && newNames.charStyles().isEmpty() && newNames.lineStyles().isEmpty()) ) |
||
1179 | changed(); |
||
7442 | avox | 1180 | } |
1181 | |||
1182 | |||
7947 | cbradney | 1183 | void ScribusDoc::replaceCharStyles(const QMap<QString,QString>& newNameForOld) |
7442 | avox | 1184 | { |
8455 | avox | 1185 | ResourceCollection newNames; |
8775 | cbradney | 1186 | newNames.mapCharStyles(newNameForOld); |
8455 | avox | 1187 | replaceNamedResources(newNames); |
1188 | |||
1189 | /* |
||
7595 | avox | 1190 | // replace style in items |
7442 | avox | 1191 | QPtrList<PageItem> * itemlist = & MasterItems; |
1192 | while (itemlist != NULL) |
||
1193 | { |
||
7595 | avox | 1194 | for (uint i=0; i < itemlist->count(); ++i) |
7442 | avox | 1195 | { |
1196 | PageItem_TextFrame * currItem = itemlist->at(i)->asTextFrame(); |
||
1197 | if (currItem) |
||
1198 | currItem->itemText.replaceCharStyles(newNameForOld); |
||
1199 | } |
||
1200 | if (itemlist == &MasterItems) |
||
1201 | itemlist = &DocItems; |
||
1202 | else if (itemlist == &DocItems) |
||
1203 | itemlist = &FrameItems; |
||
1204 | else |
||
1205 | itemlist = NULL; |
||
1206 | } |
||
7595 | avox | 1207 | // replace names in styles |
1208 | for (uint i=0; i < docParagraphStyles.count(); ++i) |
||
1209 | { |
||
1210 | // ...parent of parstyle's charstyle |
||
1211 | const QString& parent(docParagraphStyles[i].charStyle().parent()); |
||
1212 | if (newNameForOld.contains(parent)) |
||
1213 | docParagraphStyles[i].charStyle().setParent(newNameForOld[parent]); |
||
1214 | } |
||
1215 | for (int i=docCharStyles.count()-1; i >= 0; --i) |
||
1216 | { |
||
1217 | // ...parent of charstyle |
||
1218 | const QString& parent(docCharStyles[i].parent()); |
||
1219 | if (newNameForOld.contains(parent)) |
||
1220 | docCharStyles[i].setParent(newNameForOld[parent]); |
||
1221 | // ... as name |
||
1222 | if (newNameForOld.contains(docCharStyles[i].name())) |
||
1223 | docCharStyles.remove(i); |
||
1224 | } |
||
8455 | avox | 1225 | */ |
7442 | avox | 1226 | } |
1227 | |||
10532 | avox | 1228 | |
7595 | avox | 1229 | void ScribusDoc::redefineStyles(const StyleSet<ParagraphStyle>& newStyles, bool removeUnused) |
1230 | { |
||
1231 | docParagraphStyles.redefine(newStyles, false); |
||
1232 | if (removeUnused) |
||
1233 | { |
||
1234 | QMap<QString, QString> deletion; |
||
1235 | QString deflt(""); |
||
10400 | subik | 1236 | for (int i=0; i < docParagraphStyles.count(); ++i) |
7595 | avox | 1237 | { |
1238 | const QString& nam(docParagraphStyles[i].name()); |
||
1239 | if (newStyles.find(nam) < 0) |
||
1240 | deletion[nam] = deflt; |
||
1241 | } |
||
1242 | if (deletion.count() > 0) |
||
1243 | replaceStyles(deletion); |
||
1244 | } |
||
8134 | avox | 1245 | // repair charstyle context: |
10400 | subik | 1246 | for (int i=0; i < docParagraphStyles.count(); ++i) |
8058 | avox | 1247 | { |
1248 | ParagraphStyle& sty(docParagraphStyles[i]); |
||
1249 | if (docParagraphStyles.isDefault(sty)) |
||
1250 | { |
||
1251 | sty.breakImplicitCharStyleInheritance(true); |
||
8134 | avox | 1252 | sty.charStyle().setContext( & docCharStyles ); |
8191 | avox | 1253 | // sty.charStyle().setName( "cdocdefault" ); // DONT TRANSLATE |
8058 | avox | 1254 | } |
1255 | else { |
||
1256 | sty.breakImplicitCharStyleInheritance(false); |
||
1257 | } |
||
1258 | } |
||
8772 | cbradney | 1259 | docParagraphStyles.invalidate(); |
7595 | avox | 1260 | } |
1261 | |||
1262 | void ScribusDoc::redefineCharStyles(const StyleSet<CharStyle>& newStyles, bool removeUnused) |
||
1263 | { |
||
1264 | docCharStyles.redefine(newStyles, false); |
||
1265 | if (removeUnused) |
||
1266 | { |
||
1267 | QMap<QString, QString> deletion; |
||
1268 | QString deflt(""); |
||
10400 | subik | 1269 | for (int i=0; i < docCharStyles.count(); ++i) |
7595 | avox | 1270 | { |
1271 | const QString& nam(docCharStyles[i].name()); |
||
1272 | if (newStyles.find(nam) < 0) |
||
8772 | cbradney | 1273 | { |
7595 | avox | 1274 | deletion[nam] = deflt; |
8772 | cbradney | 1275 | } |
7595 | avox | 1276 | } |
1277 | if (deletion.count() > 0) |
||
1278 | replaceCharStyles(deletion); |
||
1279 | } |
||
8772 | cbradney | 1280 | docCharStyles.invalidate(); |
7595 | avox | 1281 | } |
1282 | |||
8274 | tsoots | 1283 | |
456 | fschmid | 1284 | /* |
1285 | * Split out from loadStyles in editFormats.cpp so it's callable from anywhere, |
||
1286 | * including plugins. |
||
1287 | * - 2004-09-14 Craig Ringer |
||
1288 | */ |
||
8455 | avox | 1289 | // dont like this here. could as well be a static method for reading this stuff into temp., then always use redefineXY() - av |
12548 | pierre | 1290 | void ScribusDoc::loadStylesFromFile(QString fileName) |
1291 | { |
||
1292 | StyleSet<ParagraphStyle> *wrkStyles = &docParagraphStyles; |
||
1293 | StyleSet<CharStyle> *wrkCharStyles = &docCharStyles; |
||
1294 | QMap<QString, multiLine> *wrkLineStyles = &MLineStyles; |
||
1295 | |||
1296 | int oldStyles = wrkStyles->count(); |
||
1297 | int oldCharStyles = wrkCharStyles->count(); |
||
1298 | int oldLineStyles = wrkLineStyles->count(); |
||
1299 | |||
1300 | if (!fileName.isEmpty()) |
||
1301 | { |
||
1302 | FileLoader fl(fileName); |
||
1303 | if (fl.TestFile() == -1) |
||
1304 | //TODO put in nice user warning |
||
1305 | return; |
||
1306 | |||
1307 | if (!fl.ReadStyles(fileName, this, *wrkStyles)) |
||
1308 | { |
||
1309 | //TODO put in nice user warning |
||
1310 | } |
||
1311 | |||
1312 | if (!fl.ReadCharStyles(fileName, this, *wrkCharStyles)) |
||
1313 | { |
||
1314 | //TODO put in nice user warning |
||
1315 | } |
||
1316 | |||
1317 | if (!fl.ReadLineStyles(fileName, wrkLineStyles)) |
||
1318 | { |
||
1319 | //TODO put in nice user warning |
||
1320 | } |
||
1321 | |||
1322 | if ( !isLoading() && ((wrkStyles->count() > oldStyles) |
||
1323 | || (wrkCharStyles->count() > oldCharStyles) |
||
1324 | || (wrkLineStyles->count() > oldLineStyles) ) ) |
||
1325 | changed(); |
||
1326 | } |
||
1327 | } |
||
1328 | |||
8274 | tsoots | 1329 | void ScribusDoc::loadStylesFromFile(QString fileName, StyleSet<ParagraphStyle> *tempStyles, |
1330 | StyleSet<CharStyle> *tempCharStyles, |
||
1331 | QMap<QString, multiLine> *tempLineStyles) |
||
456 | fschmid | 1332 | { |
12548 | pierre | 1333 | StyleSet<ParagraphStyle> *wrkStyles = tempStyles; |
1334 | StyleSet<CharStyle> *wrkCharStyles = tempCharStyles; |
||
1335 | QMap<QString, multiLine> *wrkLineStyles = tempLineStyles; |
||
8916 | avox | 1336 | |
456 | fschmid | 1337 | if (!fileName.isEmpty()) |
1338 | { |
||
5642 | cbradney | 1339 | FileLoader fl(fileName); |
1340 | if (fl.TestFile() == -1) |
||
1341 | //TODO put in nice user warning |
||
1342 | return; |
||
5980 | avox | 1343 | |
8151 | avox | 1344 | if (!fl.ReadStyles(fileName, this, *wrkStyles)) |
456 | fschmid | 1345 | { |
8274 | tsoots | 1346 | //TODO put in nice user warning |
456 | fschmid | 1347 | } |
8274 | tsoots | 1348 | |
1349 | if (!fl.ReadCharStyles(fileName, this, *wrkCharStyles)) |
||
1350 | { |
||
1351 | //TODO put in nice user warning |
||
1352 | } |
||
1353 | |||
1354 | if (!fl.ReadLineStyles(fileName, wrkLineStyles)) |
||
1355 | { |
||
1356 | //TODO put in nice user warning |
||
1357 | } |
||
12550 | pierre | 1358 | |
1359 | // Which are the default styles |
||
1360 | // Sadly StyleSet is not updated at import |
||
1361 | // and it might break something to do so. |
||
1362 | // We need to loop then - pm |
||
1363 | // ParagraphStyle* parDefault(wrkStyles->getDefault()); |
||
1364 | // CharStyle* charDefault(wrkCharStyles->getDefault()); |
||
1365 | |||
1366 | QFileInfo fi(fileName); |
||
1367 | QString importPrefix(tr("Imported ","Prefix of imported default style")); |
||
1368 | QString importSuffix(" (" + fi.baseName() + ")"); |
||
1369 | |||
1370 | for(int j(0) ; j < wrkStyles->count() ; ++j) |
||
1371 | { |
||
1372 | if((*wrkStyles)[j].isDefaultStyle()) |
||
1373 | { |
||
1374 | ParagraphStyle& parDefault((*wrkStyles)[j]); |
||
1375 | parDefault.setDefaultStyle(false); |
||
1376 | QMap<QString, QString> namesMap; |
||
1377 | namesMap[parDefault.name()] = importPrefix + parDefault.name() + importSuffix; |
||
1378 | for(int i(0) ; i < wrkStyles->count() ; ++i) |
||
1379 | { |
||
1380 | if( (*wrkStyles)[i] != parDefault ) |
||
1381 | namesMap[(*wrkStyles)[i].name()] = (*wrkStyles)[i].name(); |
||
1382 | } |
||
1383 | wrkStyles->rename(namesMap); |
||
1384 | } |
||
1385 | } |
||
1386 | for(int j(0) ; j < wrkCharStyles->count() ; ++j) |
||
1387 | { |
||
1388 | if((*wrkCharStyles)[j].isDefaultStyle()) |
||
1389 | { |
||
1390 | CharStyle& charDefault((*wrkCharStyles)[j]); |
||
1391 | charDefault.setDefaultStyle(false); |
||
1392 | QMap<QString, QString> namesMap; |
||
1393 | namesMap[charDefault.name()] = importPrefix + charDefault.name() + importSuffix; |
||
1394 | for(int i(0) ; i < wrkCharStyles->count() ; ++i) |
||
1395 | { |
||
1396 | if( (*wrkCharStyles)[i] != charDefault ) |
||
1397 | namesMap[(*wrkCharStyles)[i].name()] = (*wrkCharStyles)[i].name(); |
||
1398 | } |
||
1399 | wrkCharStyles->rename(namesMap); |
||
1400 | } |
||
1401 | } |
||
456 | fschmid | 1402 | } |
1403 | } |
||
1404 | |||
10532 | avox | 1405 | |
1179 | tsoots | 1406 | void ScribusDoc::lockGuides(bool isLocked) |
1407 | { |
||
1180 | tsoots | 1408 | if (GuideLock == isLocked) |
1409 | return; |
||
1179 | tsoots | 1410 | GuideLock = isLocked; |
1411 | if (UndoManager::undoEnabled()) |
||
1412 | { |
||
1413 | QString name; |
||
1414 | if (isLocked) |
||
1190 | tsoots | 1415 | name = Um::LockGuides; |
1179 | tsoots | 1416 | else |
1190 | tsoots | 1417 | name = Um::UnlockGuides; |
1418 | SimpleState *ss = new SimpleState(name, "", Um::ILockGuides); |
||
1179 | tsoots | 1419 | ss->set("GUIDE_LOCK", isLocked); |
1420 | undoManager->action(this, ss); |
||
1421 | } |
||
1422 | } |
||
1423 | |||
13349 | jghali | 1424 | void ScribusDoc::undoRedoBegin() |
1425 | { |
||
14370 | jghali | 1426 | m_docUpdater->beginUpdate(); |
13349 | jghali | 1427 | m_Selection->delaySignalsOn(); |
1428 | } |
||
10532 | avox | 1429 | |
13349 | jghali | 1430 | void ScribusDoc::undoRedoDone() |
1431 | { |
||
1432 | m_Selection->delaySignalsOff(); |
||
14370 | jghali | 1433 | m_docUpdater->endUpdate(); |
13349 | jghali | 1434 | } |
1435 | |||
1179 | tsoots | 1436 | void ScribusDoc::restore(UndoState* state, bool isUndo) |
1437 | { |
||
1438 | SimpleState *ss = dynamic_cast<SimpleState*>(state); |
||
1439 | if (ss) |
||
1440 | { |
||
2941 | cbradney | 1441 | bool layersUndo=false; |
13331 | jghali | 1442 | |
13194 | jghali | 1443 | if (ss->contains("GROUP")) |
1444 | restoreGrouping(ss, isUndo); |
||
1445 | else if (ss->contains("UNGROUP")) |
||
1446 | restoreUngrouping(ss, isUndo); |
||
1447 | else if (ss->contains("GUIDE_LOCK")) |
||
1179 | tsoots | 1448 | { |
1449 | if (isUndo) |
||
1450 | GuideLock = !ss->getBool("GUIDE_LOCK"); |
||
1451 | else |
||
3201 | subik | 1452 | GuideLock = ss->getBool("GUIDE_LOCK"); |
1179 | tsoots | 1453 | } |
2937 | cbradney | 1454 | else if (ss->contains("UP_LAYER")) |
1455 | { |
||
1456 | if (isUndo) |
||
1457 | lowerLayer(ss->getInt("ACTIVE")); |
||
1458 | else |
||
1459 | raiseLayer(ss->getInt("ACTIVE")); |
||
2941 | cbradney | 1460 | layersUndo=true; |
2937 | cbradney | 1461 | } |
1462 | else if (ss->contains("DOWN_LAYER")) |
||
1463 | { |
||
1464 | if (isUndo) |
||
1465 | raiseLayer(ss->getInt("ACTIVE")); |
||
1466 | else |
||
1467 | lowerLayer(ss->getInt("ACTIVE")); |
||
2941 | cbradney | 1468 | layersUndo=true; |
2937 | cbradney | 1469 | } |
1470 | else if (ss->contains("PRINT_LAYER")) |
||
1471 | { |
||
1472 | bool print = ss->getBool("PRINT"); |
||
1473 | setLayerPrintable(ss->getInt("ACTIVE"), isUndo ? !print : print); |
||
2941 | cbradney | 1474 | layersUndo=true; |
2937 | cbradney | 1475 | } |
16497 | craig | 1476 | else if (ss->contains("LAYER_FLOW")) |
16492 | craig | 1477 | { |
1478 | bool flow = ss->getBool("FLOW"); |
||
1479 | setLayerFlow(ss->getInt("ACTIVE"), isUndo ? !flow : flow); |
||
1480 | layersUndo=true; |
||
1481 | } |
||
16499 | craig | 1482 | else if (ss->contains("LAYER_LOCK")) |
1483 | { |
||
1484 | bool lock = ss->getBool("LOCK"); |
||
1485 | setLayerLocked(ss->getInt("ACTIVE"), isUndo ? !lock : lock); |
||
1486 | layersUndo=true; |
||
1487 | } |
||
16497 | craig | 1488 | else if (ss->contains("LAYER_TRANSPARENCY")) |
1489 | { |
||
1490 | double old_trans = ss->getDouble("OLD_TRANS"); |
||
1491 | double new_trans = ss->getDouble("NEW_TRANS"); |
||
1492 | setLayerTransparency(ss->getInt("ACTIVE"), isUndo ? old_trans : new_trans); |
||
1493 | layersUndo=true; |
||
1494 | } |
||
1495 | else if (ss->contains("LAYER_BLENDMODE")) |
||
1496 | { |
||
1497 | int old_blend = ss->getInt("OLD_BLENDMODE"); |
||
1498 | int new_blend = ss->getInt("NEW_BLENDMODE"); |
||
1499 | setLayerBlendMode(ss->getInt("ACTIVE"), isUndo ? old_blend : new_blend); |
||
1500 | layersUndo=true; |
||
1501 | } |
||
2937 | cbradney | 1502 | else if (ss->contains("ADD_LAYER")) |
1503 | { |
||
1504 | if (isUndo) |
||
2944 | cbradney | 1505 | deleteLayer(ss->getInt("LAYER_NR"), false); |
2937 | cbradney | 1506 | else |
1507 | { |
||
13875 | jghali | 1508 | int layerID=addLayer( ss->get("NAME"), false ); |
1509 | int newLayerID=ss->getInt("LAYER_NR"); |
||
1510 | bool renumberedOk=renumberLayer(layerID, newLayerID); |
||
2944 | cbradney | 1511 | Q_ASSERT(renumberedOk); |
2937 | cbradney | 1512 | } |
2944 | cbradney | 1513 | layersUndo=true; |
2937 | cbradney | 1514 | } |
1515 | else if (ss->contains("REMOVE_LAYER")) |
||
1516 | { |
||
1517 | if (isUndo) |
||
1518 | { |
||
13875 | jghali | 1519 | int layerID=addLayer( ss->get("NAME"), false ); |
1520 | int newLayerID=ss->getInt("LAYER_NR"); |
||
1521 | bool renumberedOk=renumberLayer(layerID, newLayerID); |
||
2944 | cbradney | 1522 | Q_ASSERT(renumberedOk); |
13875 | jghali | 1523 | layerID=newLayerID; |
2944 | cbradney | 1524 | //Layer is at the top now, lower it until it reaches the old level |
2937 | cbradney | 1525 | int level = ss->getInt("LEVEL"); |
13875 | jghali | 1526 | while (layerLevelFromID(layerID)!=level) |
1527 | lowerLayer(layerID); |
||
2937 | cbradney | 1528 | } |
1529 | else |
||
2944 | cbradney | 1530 | deleteLayer(ss->getInt("LAYER_NR"), ss->getBool("DELETE")); |
1531 | layersUndo=true; |
||
2937 | cbradney | 1532 | } |
1533 | else if (ss->contains("CHANGE_NAME")) |
||
1534 | { |
||
1535 | QString name = ss->get("OLD_NAME"); |
||
1536 | if (!isUndo) |
||
1537 | name = ss->get("NEW_NAME"); |
||
2938 | cbradney | 1538 | changeLayerName(ss->getInt("ACTIVE"), name); |
2941 | cbradney | 1539 | layersUndo=true; |
1540 | } |
||
3004 | cbradney | 1541 | else if (ss->contains("OLD_MASTERPAGE")) |
1542 | restoreMasterPageApplying(ss, isUndo); |
||
7897 | tsoots | 1543 | else if (ss->contains("COPY_PAGE")) |
1544 | restorePageCopy(ss, isUndo); |
||
16509 | craig | 1545 | else if (ss->contains("PAGE_CHANGEPROPS")) |
1546 | { |
||
1547 | if (isUndo) |
||
1548 | { |
||
1549 | changePageMargins(ss->getDouble("OLD_PAGE_INITIALTOP"), ss->getDouble("OLD_PAGE_INITIALBOTTOM"), |
||
1550 | ss->getDouble("OLD_PAGE_INITIALLEFT"), ss->getDouble("OLD_PAGE_INITIALRIGHT"), |
||
1551 | ss->getDouble("OLD_PAGE_INITIALHEIGHT"), ss->getDouble("OLD_PAGE_INITIALWIDTH"), |
||
1552 | ss->getDouble("OLD_PAGE_HEIGHT"), ss->getDouble("OLD_PAGE_WIDTH"), ss->getInt("OLD_PAGE_ORIENTATION"), |
||
1553 | ss->get("OLD_PAGE_SIZE"), ss->getInt("OLD_PAGE_MARGINPRESET"), ss->getBool("OLD_PAGE_MOVEOBJECTS"), ss->getInt("PAGE_NUM"), ss->getInt("OLD_PAGE_TYPE")); |
||
1554 | } |
||
1555 | else |
||
1556 | { |
||
1557 | changePageMargins(ss->getDouble("NEW_PAGE_INITIALTOP"), ss->getDouble("NEW_PAGE_INITIALBOTTOM"), |
||
1558 | ss->getDouble("NEW_PAGE_INITIALLEFT"), ss->getDouble("NEW_PAGE_INITIALRIGHT"), |
||
1559 | ss->getDouble("NEW_PAGE_INITIALHEIGHT"), ss->getDouble("NEW_PAGE_INITIALWIDTH"), |
||
1560 | ss->getDouble("NEW_PAGE_HEIGHT"), ss->getDouble("NEW_PAGE_WIDTH"), ss->getInt("NEW_PAGE_ORIENTATION"), |
||
1561 | ss->get("NEW_PAGE_SIZE"), ss->getInt("NEW_PAGE_MARGINPRESET"), ss->getBool("OLD_PAGE_MOVEOBJECTS"), ss->getInt("PAGE_NUM"), ss->getInt("NEW_PAGE_TYPE")); |
||
1562 | } |
||
1563 | } |
||
2941 | cbradney | 1564 | if (layersUndo) |
1565 | { |
||
5243 | cbradney | 1566 | if (ScCore->usingGUI()) |
2952 | cbradney | 1567 | { |
5781 | cbradney | 1568 | m_ScMW->changeLayer(ss->getInt("ACTIVE")); |
1569 | m_ScMW->layerPalette->rebuildList(); |
||
2952 | cbradney | 1570 | } |
2937 | cbradney | 1571 | } |
1179 | tsoots | 1572 | } |
1573 | } |
||
1574 | |||
13194 | jghali | 1575 | void ScribusDoc::restoreGrouping(SimpleState *state, bool isUndo) |
1576 | { |
||
1577 | double x, y, w, h; |
||
1578 | Selection tmpSelection(this, false); |
||
1579 | int itemCount = state->getInt("itemcount"); |
||
1580 | m_Selection->setGroupRect(); |
||
1581 | m_Selection->getGroupRect(&x, &y, &w, &h); |
||
1582 | m_Selection->delaySignalsOn(); |
||
1583 | m_Selection->clear(); |
||
1584 | for (int i = 0; i < itemCount; ++i) |
||
1585 | { |
||
1586 | int itemNr = getItemNrfromUniqueID(state->getUInt(QString("item%1").arg(i))); |
||
1587 | if (Items->at(itemNr)->uniqueNr == state->getUInt(QString("item%1").arg(i))) |
||
1588 | tmpSelection.addItem(Items->at(itemNr)); |
||
1589 | } |
||
1590 | if (isUndo) |
||
1591 | itemSelection_UnGroupObjects(&tmpSelection); |
||
1592 | else |
||
1593 | itemSelection_GroupObjects(false, false, &tmpSelection); |
||
1594 | QRectF rect(x, y , w, h); |
||
1595 | regionsChanged()->update(rect.adjusted(-10, -10, 20, 20)); |
||
1596 | m_Selection->delaySignalsOff(); |
||
1597 | } |
||
10532 | avox | 1598 | |
13194 | jghali | 1599 | void ScribusDoc::restoreUngrouping(SimpleState *state, bool isUndo) |
1600 | { |
||
1601 | double x, y, w, h; |
||
1602 | Selection tmpSelection(this, false); |
||
1603 | int itemCount = state->getInt("itemcount"); |
||
1604 | m_Selection->setGroupRect(); |
||
1605 | m_Selection->getGroupRect(&x, &y, &w, &h); |
||
1606 | m_Selection->delaySignalsOn(); |
||
1607 | m_Selection->clear(); |
||
1608 | for (int i = 0; i < itemCount; ++i) |
||
1609 | { |
||
1610 | int itemNr = getItemNrfromUniqueID(state->getUInt(QString("item%1").arg(i))); |
||
1611 | if (Items->at(itemNr)->uniqueNr == state->getUInt(QString("item%1").arg(i))) |
||
1612 | { |
||
1613 | if (isUndo) |
||
1614 | Items->at(itemNr)->isTableItem = static_cast<bool>(state->getInt(QString("tableitem%1").arg(i))); |
||
1615 | tmpSelection.addItem(Items->at(itemNr)); |
||
1616 | } |
||
1617 | } |
||
1618 | if (isUndo) |
||
1619 | itemSelection_GroupObjects(false, false, &tmpSelection); |
||
1620 | else |
||
1621 | itemSelection_UnGroupObjects(&tmpSelection); |
||
1622 | QRectF rect(x, y , w, h); |
||
1623 | regionsChanged()->update(rect.adjusted(-10, -10, 20, 20)); |
||
1624 | m_Selection->delaySignalsOff(); |
||
1625 | } |
||
1626 | |||
1179 | tsoots | 1627 | void ScribusDoc::setName(const QString& name) |
1628 | { |
||
1629 | DocName = name; |
||
1630 | } |
||
1631 | |||
10532 | avox | 1632 | |
2891 | cbradney | 1633 | void ScribusDoc::setModified(const bool isModified) |
3 | paul | 1634 | { |
10532 | avox | 1635 | if (modified != isModified) |
1636 | { |
||
1637 | modified = isModified; |
||
1638 | update(); |
||
1639 | } |
||
3 | paul | 1640 | } |
1641 | |||
10532 | avox | 1642 | |
3 | paul | 1643 | bool ScribusDoc::isModified() const |
1644 | { |
||
12034 | cbradney | 1645 | return modified; |
3 | paul | 1646 | } |
10532 | avox | 1647 | |
1648 | |||
1649 | /** sets page properties */ |
||
14994 | cbradney | 1650 | void ScribusDoc::setPage(double w, double h, double t, double l, double r, double b, double sp, double ab, bool atf, int fp) |
3 | paul | 1651 | { |
14994 | cbradney | 1652 | docPrefsData.docSetupPrefs.pageWidth = w; |
14991 | cbradney | 1653 | docPrefsData.docSetupPrefs.pageHeight = h; |
14994 | cbradney | 1654 | docPrefsData.docSetupPrefs.margins.set(t, l, b ,r); |
3 | paul | 1655 | PageSp = sp; |
1656 | PageSpa = ab; |
||
15407 | craig | 1657 | docPrefsData.docSetupPrefs.pagePositioning = fp; |
3648 | cbradney | 1658 | automaticTextFrames = atf; |
4546 | subik | 1659 | |
3695 | cbradney | 1660 | //CB Moved from scribus.cpp. Overrides the defaults... |
6921 | fschmid | 1661 | // PDF_Options.BleedTop = pageMargins.Top; |
1662 | // PDF_Options.BleedLeft = pageMargins.Left; |
||
1663 | // PDF_Options.BleedRight = pageMargins.Right; |
||
1664 | // PDF_Options.BleedBottom = pageMargins.Bottom; |
||
3 | paul | 1665 | } |
1666 | |||
14994 | cbradney | 1667 | void ScribusDoc::resetPage(int fp, MarginStruct* newMargins) |
3 | paul | 1668 | { |
14994 | cbradney | 1669 | if (newMargins!=0) |
1670 | docPrefsData.docSetupPrefs.margins = *newMargins; |
||
15407 | craig | 1671 | docPrefsData.docSetupPrefs.pagePositioning = fp; |
3 | paul | 1672 | } |
1673 | |||
10532 | avox | 1674 | |
3544 | avox | 1675 | bool ScribusDoc::AddFont(QString name, int fsize) |
3 | paul | 1676 | { |
220 | Franz | 1677 | bool ret = false; |
6549 | fschmid | 1678 | // FT_Face face; |
2295 | cbradney | 1679 | |
3201 | subik | 1680 | if (UsedFonts.contains(name)) |
1681 | return true; |
||
2295 | cbradney | 1682 | |
5980 | avox | 1683 | if (! AllFonts->contains(name) || name == "" ) |
5559 | avox | 1684 | return false; |
3572 | avox | 1685 | |
5980 | avox | 1686 | // face = (*AllFonts)[name]->ftFace(); |
1687 | // if ( !face ) |
||
1688 | // return false; |
||
2295 | cbradney | 1689 | |
5980 | avox | 1690 | /* if ((*AllFonts)[name].ReadMetrics()) FIXME: needed? |
167 | Franz | 1691 | { |
5387 | avox | 1692 | // (*AllFonts)[name]->CharWidth[13] = 0; |
1693 | // (*AllFonts)[name]->CharWidth[28] = 0; |
||
1694 | // (*AllFonts)[name]->CharWidth[26] = 0; |
||
1695 | // (*AllFonts)[name]->CharWidth[9] = 1; |
||
5980 | avox | 1696 | QString afnm = (*AllFonts)[name].fontFilePath().left((*AllFonts)[name].fontFilePath().length()-3); |
220 | Franz | 1697 | QFile afm(afnm+"afm"); |
3 | paul | 1698 | if(!(afm.exists())) |
220 | Franz | 1699 | { |
5387 | avox | 1700 | afm.setName(afnm+"pfm"); |
1701 | } |
||
1702 | if(!(afm.exists())) { |
||
1703 | afm.setName(afnm+"AFM"); |
||
1704 | } |
||
1705 | if(!(afm.exists())) |
||
1706 | { |
||
1707 | afm.setName(afnm+"PFM"); |
||
1708 | } |
||
1709 | if(!(afm.exists())) |
||
1710 | { |
||
220 | Franz | 1711 | afm.setName(afnm+"Afm"); |
1712 | } |
||
5387 | avox | 1713 | if(!(afm.exists())) |
1714 | { |
||
1715 | afm.setName(afnm+"Pfm"); |
||
1716 | } |
||
220 | Franz | 1717 | if (afm.exists()) |
1718 | FT_Attach_File(face, afm.name()); |
||
167 | Franz | 1719 | } |
5980 | avox | 1720 | */ |
1721 | UsedFonts[name] = fsize; |
||
1722 | (*AllFonts)[name].increaseUsage(); |
||
1723 | ret = true; |
||
220 | Franz | 1724 | return ret; |
3 | paul | 1725 | } |
1694 | cbradney | 1726 | |
10532 | avox | 1727 | |
1694 | cbradney | 1728 | QStringList ScribusDoc::getItemAttributeNames() |
1729 | { |
||
1730 | QStringList nameList; |
||
3201 | subik | 1731 | |
14927 | cbradney | 1732 | for(ObjAttrVector::Iterator it = itemAttributes().begin(); it!= itemAttributes().end(); ++it) |
1694 | cbradney | 1733 | nameList.append((*it).name); |
1734 | return nameList; |
||
1749 | craig | 1735 | } |
1736 | |||
10532 | avox | 1737 | |
2891 | cbradney | 1738 | void ScribusDoc::addSymbols() |
1739 | { |
||
1740 | symReturn.resize(0); |
||
1741 | symReturn.addQuadPoint(1.98438, 9.14062, 1.98438, 9.14062, 1.98438, 4.03125, 1.98438, 4.03125); |
||
1742 | symReturn.addQuadPoint(1.98438, 4.03125, 1.98438, 4.03125, 0.546875, 3.45312, 1.09375, 4); |
||
1743 | symReturn.addQuadPoint(0.546875, 3.45312, 0.546875, 3.45312, 0, 2.0625, 0, 2.92188); |
||
1744 | symReturn.addQuadPoint(0, 2.0625, 0, 2.0625, 0.65625, 0.5, 0, 1.04688); |
||
1745 | symReturn.addQuadPoint(0.65625, 0.5, 0.65625, 0.5, 2.3125, 0, 1.28125, 0); |
||
1746 | symReturn.addQuadPoint(2.3125, 0, 2.3125, 0, 5.40625, 0, 5.40625, 0); |
||
1747 | symReturn.addQuadPoint(5.40625, 0, 5.40625, 0, 5.40625, 0.84375, 5.40625, 0.84375); |
||
1748 | symReturn.addQuadPoint(5.40625, 0.84375, 5.40625, 0.84375, 4.70312, 0.84375, 4.70312, 0.84375); |
||
1749 | symReturn.addQuadPoint(4.70312, 0.84375, 4.70312, 0.84375, 4.70312, 9.14062, 4.70312, 9.14062); |
||
1750 | symReturn.addQuadPoint(4.70312, 9.14062, 4.70312, 9.14062, 3.875, 9.14062, 3.875, 9.14062); |
||
1751 | symReturn.addQuadPoint(3.875, 9.14062, 3.875, 9.14062, 3.875, 0.84375, 3.875, 0.84375); |
||
1752 | symReturn.addQuadPoint(3.875, 0.84375, 3.875, 0.84375, 2.78125, 0.84375, 2.78125, 0.84375); |
||
1753 | symReturn.addQuadPoint(2.78125, 0.84375, 2.78125, 0.84375, 2.78125, 9.14062, 2.78125, 9.14062); |
||
1754 | symReturn.addQuadPoint(2.78125, 9.14062, 2.78125, 9.14062, 1.98438, 9.14062, 1.98438, 9.14062); |
||
1755 | symNewLine.resize(0); |
||
1756 | symNewLine.addQuadPoint(6.51562, 2.625, 6.51562, 2.625, 0.90625, 2.64062, 0.90625, 2.64062); |
||
1757 | symNewLine.addQuadPoint(0.90625, 2.64062, 0.90625, 2.64062, 1.4375, 1.92188, 1.26562, 2.1875); |
||
1758 | symNewLine.addQuadPoint(1.4375, 1.92188, 1.4375, 1.92188, 1.76562, 1.14062, 1.75, 1.42188); |
||
1759 | symNewLine.addQuadPoint(1.76562, 1.14062, 1.76562, 1.14062, 1.60938, 1.03125, 1.60938, 1.03125); |
||
1760 | symNewLine.addQuadPoint(1.60938, 1.03125, 1.60938, 1.03125, 0.90625, 1.92188, 0.90625, 1.92188); |
||
1761 | symNewLine.addQuadPoint(0.90625, 1.92188, 0.90625, 1.92188, 0, 2.90625, 0.578125, 2.23438); |
||
1762 | symNewLine.addQuadPoint(0, 2.90625, 0, 2.90625, 0.75, 3.875, 0.75, 3.875); |
||
1763 | symNewLine.addQuadPoint(0.75, 3.875, 0.75, 3.875, 1.57812, 4.78125, 1.1875, 4.40625); |
||
1764 | symNewLine.addQuadPoint(1.57812, 4.78125, 1.57812, 4.78125, 1.65625, 4.79688, 1.65625, 4.79688); |
||
1765 | symNewLine.addQuadPoint(1.65625, 4.79688, 1.65625, 4.79688, 1.76562, 4.65625, 1.76562, 4.65625); |
||
1766 | symNewLine.addQuadPoint(1.76562, 4.65625, 1.76562, 4.65625, 0.90625, 3.17188, 1.73438, 4.34375); |
||
1767 | symNewLine.addQuadPoint(0.90625, 3.17188, 0.90625, 3.17188, 0.96875, 3.125, 0.96875, 3.125); |
||
1768 | symNewLine.addQuadPoint(0.96875, 3.125, 0.96875, 3.125, 6.75, 3.125, 6.75, 3.125); |
||
1769 | symNewLine.addQuadPoint(6.75, 3.125, 6.75, 3.125, 6.51562, 2.625, 6.51562, 2.625); |
||
1770 | symNewLine.addQuadPoint(6.51562, 2.625, 6.51562, 2.625, 6.51562, 2.625, 6.51562, 2.625); |
||
1771 | symNewLine.addQuadPoint(999999, 999999, 999999, 999999, 999999, 999999, 999999, 999999); |
||
1772 | symNewLine.addQuadPoint(6.875, 0, 6.875, 0, 6.51562, 0, 6.51562, 0); |
||
1773 | symNewLine.addQuadPoint(6.51562, 0, 6.51562, 0, 6.51562, 2.84375, 6.51562, 2.84375); |
||
1774 | symNewLine.addQuadPoint(6.51562, 2.84375, 6.51562, 2.84375, 6.75, 3.125, 6.51562, 3.125); |
||
1775 | symNewLine.addQuadPoint(6.75, 3.125, 6.75, 3.125, 6.85938, 3.0625, 6.85938, 3.0625); |
||
1776 | symNewLine.addQuadPoint(6.85938, 3.0625, 6.85938, 3.0625, 6.875, 0, 6.875, 0); |
||
1777 | symTab.resize(0); |
||
1778 | symTab.addQuadPoint(4.82812, 3.96875, 4.82812, 3.96875, 4.5625, 3.73438, 4.5625, 3.96875); |
||
1779 | symTab.addQuadPoint(4.5625, 3.73438, 4.5625, 3.73438, 5.07812, 3.10938, 4.5625, 3.57812); |
||
1780 | symTab.addQuadPoint(5.07812, 3.10938, 5.07812, 3.10938, 0, 3.10938, 0, 3.10938); |
||
1781 | symTab.addQuadPoint(0, 3.10938, 0, 3.10938, 0, 2.625, 0, 2.625); |
||
1782 | symTab.addQuadPoint(0, 2.625, 0, 2.625, 5.53125, 2.625, 5.53125, 2.625); |
||
1783 | symTab.addQuadPoint(5.53125, 2.625, 5.53125, 2.625, 6.3125, 1.8125, 6.3125, 1.8125); |
||
1784 | symTab.addQuadPoint(6.3125, 1.8125, 6.3125, 1.8125, 5.64062, 1.29688, 5.64062, 1.29688); |
||
1785 | symTab.addQuadPoint(5.64062, 1.29688, 5.64062, 1.29688, 0, 1.29688, 0, 1.29688); |
||
1786 | symTab.addQuadPoint(0, 1.29688, 0, 1.29688, 0, 0.8125, 0, 0.8125); |
||
1787 | symTab.addQuadPoint(0, 0.8125, 0, 0.8125, 5.01562, 0.8125, 5.01562, 0.8125); |
||
1788 | symTab.addQuadPoint(5.01562, 0.8125, 5.01562, 0.8125, 4.45312, 0.265625, 4.45312, 0.453125); |
||
1789 | symTab.addQuadPoint(4.45312, 0.265625, 4.45312, 0.265625, 4.6875, 0, 4.45312, 0); |
||
1790 | symTab.addQuadPoint(4.6875, 0, 4.6875, 0, 5.90625, 0.828125, 4.875, 0); |
||
1791 | symTab.addQuadPoint(5.90625, 0.828125, 5.90625, 0.828125, 6.9375, 1.79688, 6.9375, 1.64062); |
||
1792 | symTab.addQuadPoint(6.9375, 1.79688, 6.9375, 1.79688, 5.95312, 2.96875, 6.9375, 1.95312); |
||
1793 | symTab.addQuadPoint(5.95312, 2.96875, 5.95312, 2.96875, 4.82812, 3.96875, 4.98438, 3.96875); |
||
1794 | symNonBreak.resize(0); |
||
1795 | symNonBreak.addQuadPoint(1.32812, 2.59375, 1.32812, 2.59375, 0.390625, 2.21875, 0.796875, 2.59375); |
||
1796 | symNonBreak.addQuadPoint(0.390625, 2.21875, 0.390625, 2.21875, 0, 1.3125, 0, 1.84375); |
||
1797 | symNonBreak.addQuadPoint(0, 1.3125, 0, 1.3125, 0.390625, 0.390625, 0, 0.765625); |
||
1798 | symNonBreak.addQuadPoint(0.390625, 0.390625, 0.390625, 0.390625, 1.32812, 0, 0.796875, 0); |
||
1799 | symNonBreak.addQuadPoint(1.32812, 0, 1.32812, 0, 2.23438, 0.390625, 1.85938, 0); |
||
1800 | symNonBreak.addQuadPoint(2.23438, 0.390625, 2.23438, 0.390625, 2.60938, 1.29688, 2.60938, 0.765625); |
||
1801 | symNonBreak.addQuadPoint(2.60938, 1.29688, 2.60938, 1.29688, 2.23438, 2.21875, 2.60938, 1.84375); |
||
1802 | symNonBreak.addQuadPoint(2.23438, 2.21875, 2.23438, 2.21875, 1.32812, 2.59375, 1.875, 2.59375); |
||
1803 | symNewCol.resize(0); |
||
1804 | symNewCol.addQuadPoint(1.73438, 0, 1.73438, 0, 2.67188, 0.109375, 2.03125, 0); |
||
1805 | symNewCol.addQuadPoint(2.67188, 0.109375, 2.67188, 0.109375, 3.59375, 0.203125, 3.26562, 0.21875); |
||
1806 | symNewCol.addQuadPoint(3.59375, 0.203125, 3.59375, 0.203125, 3.79688, 0.1875, 3.64062, 0.203125); |
||
1807 | symNewCol.addQuadPoint(3.79688, 0.1875, 3.79688, 0.1875, 4, 0.171875, 3.92188, 0.171875); |
||
1808 | symNewCol.addQuadPoint(4, 0.171875, 4, 0.171875, 4.20312, 0.1875, 4.20312, 0.1875); |
||
1809 | symNewCol.addQuadPoint(4.20312, 0.1875, 4.20312, 0.1875, 4.3125, 1.39062, 4.20312, 0.5625); |
||
1810 | symNewCol.addQuadPoint(4.3125, 1.39062, 4.3125, 1.39062, 4.42188, 2.64062, 4.42188, 2.21875); |
||
1811 | symNewCol.addQuadPoint(4.42188, 2.64062, 4.42188, 2.64062, 4.28125, 2.73438, 4.28125, 2.73438); |
||
1812 | symNewCol.addQuadPoint(4.28125, 2.73438, 4.28125, 2.73438, 3.75, 1.03125, 4.01562, 2.64062); |
||
1813 | symNewCol.addQuadPoint(3.75, 1.03125, 3.75, 1.03125, 3.67188, 1.03125, 3.67188, 1.03125); |
||
1814 | symNewCol.addQuadPoint(3.67188, 1.03125, 3.67188, 1.03125, 0.28125, 6.20312, 0.28125, 6.20312); |
||
1815 | symNewCol.addQuadPoint(0.28125, 6.20312, 0.28125, 6.20312, 0, 5.95312, 0.03125, 6.17188); |
||
1816 | symNewCol.addQuadPoint(0, 5.95312, 0, 5.95312, 3.35938, 0.71875, 3.35938, 0.71875); |
||
1817 | symNewCol.addQuadPoint(3.35938, 0.71875, 3.35938, 0.71875, 3.375, 0.640625, 3.375, 0.640625); |
||
1818 | symNewCol.addQuadPoint(3.375, 0.640625, 3.375, 0.640625, 2.4375, 0.484375, 2.79688, 0.5625); |
||
1819 | symNewCol.addQuadPoint(2.4375, 0.484375, 2.4375, 0.484375, 1.67188, 0.140625, 1.71875, 0.328125); |
||
1820 | symNewCol.addQuadPoint(1.67188, 0.140625, 1.67188, 0.140625, 1.73438, 0, 1.73438, 0); |
||
1821 | symNewFrame.resize(0); |
||
1822 | symNewFrame.addQuadPoint(1.75, 6.20312, 1.75, 6.20312, 2.67188, 6.09375, 2.0625, 6.20312); |
||
1823 | symNewFrame.addQuadPoint(2.67188, 6.09375, 2.67188, 6.09375, 3.60938, 5.98438, 3.28125, 5.98438); |
||
1824 | symNewFrame.addQuadPoint(3.60938, 5.98438, 3.60938, 5.98438, 3.84375, 6.01562, 3.6875, 5.98438); |
||
1825 | symNewFrame.addQuadPoint(3.84375, 6.01562, 3.84375, 6.01562, 4.07812, 6.03125, 4, 6.03125); |
||
1826 | symNewFrame.addQuadPoint(4.07812, 6.03125, 4.07812, 6.03125, 4.20312, 6.01562, 4.20312, 6.01562); |
||
1827 | symNewFrame.addQuadPoint(4.20312, 6.01562, 4.20312, 6.01562, 4.32812, 4.79688, 4.21875, 5.625); |
||
1828 | symNewFrame.addQuadPoint( 4.32812, 4.79688, 4.32812, 4.79688, 4.42188, 3.5625, 4.42188, 3.98438); |
||
1829 | symNewFrame.addQuadPoint(4.42188, 3.5625, 4.42188, 3.5625, 4.29688, 3.45312, 4.29688, 3.45312); |
||
1830 | symNewFrame.addQuadPoint(4.29688, 3.45312, 4.29688, 3.45312, 3.75, 5.17188, 4.03125, 3.54688); |
||
1831 | symNewFrame.addQuadPoint(3.75, 5.17188, 3.75, 5.17188, 3.67188, 5.17188, 3.67188, 5.17188); |
||
1832 | symNewFrame.addQuadPoint(3.67188, 5.17188, 3.67188, 5.17188, 0.28125, 0, 0.28125, 0); |
||
1833 | symNewFrame.addQuadPoint(0.28125, 0, 0.28125, 0, 0, 0.25, 0.03125, 0.015625); |
||
1834 | symNewFrame.addQuadPoint(0, 0.25, 0, 0.25, 3.375, 5.46875, 3.375, 5.46875); |
||
1835 | symNewFrame.addQuadPoint(3.375, 5.46875, 3.375, 5.46875, 3.39062, 5.54688, 3.39062, 5.54688); |
||
1836 | symNewFrame.addQuadPoint(3.39062, 5.54688, 3.39062, 5.54688, 2.4375, 5.70312, 2.8125, 5.625); |
||
1837 | symNewFrame.addQuadPoint(2.4375, 5.70312, 2.4375, 5.70312, 1.67188, 6.0625, 1.71875, 5.875); |
||
1838 | symNewFrame.addQuadPoint(1.67188, 6.0625, 1.67188, 6.0625, 1.75, 6.20312, 1.75, 6.20312); |
||
1839 | } |
||
2893 | cbradney | 1840 | |
10532 | avox | 1841 | |
16729 | fschmid | 1842 | ScPage* ScribusDoc::addPage(const int pageIndex, const QString& masterPageName, const bool addAutoFrame) |
2893 | cbradney | 1843 | { |
9119 | avox | 1844 | assert(masterPageMode()==false); |
16729 | fschmid | 1845 | ScPage* addedPage = new ScPage(docPrefsData.displayPrefs.scratch.Left, DocPages.count()*(docPrefsData.docSetupPrefs.pageHeight+docPrefsData.displayPrefs.scratch.Bottom+docPrefsData.displayPrefs.scratch.Top)+docPrefsData.displayPrefs.scratch.Top, docPrefsData.docSetupPrefs.pageWidth, docPrefsData.docSetupPrefs.pageHeight); |
9119 | avox | 1846 | assert(addedPage!=NULL); |
4738 | cbradney | 1847 | addedPage->setDocument(this); |
14994 | cbradney | 1848 | addedPage->Margins.Top = docPrefsData.docSetupPrefs.margins.Top; |
1849 | addedPage->Margins.Bottom = docPrefsData.docSetupPrefs.margins.Bottom; |
||
1850 | addedPage->initialMargins.Top = docPrefsData.docSetupPrefs.margins.Top; |
||
1851 | addedPage->initialMargins.Bottom = docPrefsData.docSetupPrefs.margins.Bottom; |
||
1852 | addedPage->initialMargins.Left = docPrefsData.docSetupPrefs.margins.Left; |
||
1853 | addedPage->initialMargins.Right = docPrefsData.docSetupPrefs.margins.Right; |
||
3852 | cbradney | 1854 | addedPage->setPageNr(pageIndex); |
14991 | cbradney | 1855 | addedPage->m_pageSize = docPrefsData.docSetupPrefs.pageSize; |
1856 | addedPage->setOrientation(docPrefsData.docSetupPrefs.pageOrientation); |
||
14992 | cbradney | 1857 | addedPage->marginPreset = docPrefsData.docSetupPrefs.marginPreset; |
10013 | cbradney | 1858 | DocPages.insert(pageIndex, addedPage); |
1859 | assert(DocPages.at(pageIndex)!=NULL); |
||
5087 | subik | 1860 | setCurrentPage(addedPage); |
3787 | cbradney | 1861 | //if (!masterPageMode()) |
3985 | cbradney | 1862 | if (!masterPageName.isEmpty()) |
3911 | cbradney | 1863 | applyMasterPage(masterPageName, pageIndex); |
6330 | fschmid | 1864 | setLocationBasedPageLRMargins(pageIndex); |
3852 | cbradney | 1865 | if (addAutoFrame && automaticTextFrames) |
1866 | addAutomaticTextFrame(pageIndex); |
||
11916 | fschmid | 1867 | // if (!isLoading()) |
1868 | // changed(); |
||
2893 | cbradney | 1869 | return addedPage; |
1870 | } |
||
2895 | cbradney | 1871 | |
10532 | avox | 1872 | |
16729 | fschmid | 1873 | ScPage* ScribusDoc::addMasterPage(const int pageNumber, const QString& pageName) |
3695 | cbradney | 1874 | { |
1875 | //CB We dont create master pages (yet) with a pageCount based location |
||
4069 | craig | 1876 | //Page* addedPage = new Page(ScratchLeft, MasterPages.count()*(pageHeight+ScratchBottom+ScratchTop)+ScratchTop, pageWidth, pageHeight); |
16729 | fschmid | 1877 | ScPage* addedPage = new ScPage(docPrefsData.displayPrefs.scratch.Left, docPrefsData.displayPrefs.scratch.Top, docPrefsData.docSetupPrefs.pageWidth, docPrefsData.docSetupPrefs.pageHeight); |
9119 | avox | 1878 | assert(addedPage!=NULL); |
4738 | cbradney | 1879 | addedPage->setDocument(this); |
14994 | cbradney | 1880 | addedPage->Margins = docPrefsData.docSetupPrefs.margins; |
1881 | addedPage->initialMargins = docPrefsData.docSetupPrefs.margins; |
||
14991 | cbradney | 1882 | addedPage->m_pageSize = docPrefsData.docSetupPrefs.pageSize; |
1883 | addedPage->setOrientation(docPrefsData.docSetupPrefs.pageOrientation); |
||
14992 | cbradney | 1884 | addedPage->marginPreset = docPrefsData.docSetupPrefs.marginPreset; |
3787 | cbradney | 1885 | addedPage->MPageNam = ""; |
3695 | cbradney | 1886 | addedPage->setPageName(pageName); |
4715 | fschmid | 1887 | addedPage->setPageNr(pageNumber); |
3695 | cbradney | 1888 | MasterNames.insert(pageName, pageNumber); |
10013 | cbradney | 1889 | MasterPages.insert(pageNumber, addedPage); |
1890 | assert(MasterPages.at(pageNumber)!=NULL); |
||
8916 | avox | 1891 | if (!isLoading()) |
1892 | changed(); |
||
3695 | cbradney | 1893 | return addedPage; |
1894 | } |
||
1895 | |||
10532 | avox | 1896 | |
5685 | cbradney | 1897 | bool ScribusDoc::renameMasterPage(const QString& oldPageName, const QString& newPageName) |
1898 | { |
||
6715 | cbradney | 1899 | Q_ASSERT(oldPageName!=CommonStrings::masterPageNormal && oldPageName!=CommonStrings::trMasterPageNormal); |
5685 | cbradney | 1900 | if (MasterNames.contains(oldPageName) && !MasterNames.contains(newPageName)) |
1901 | { |
||
1902 | //Rename our master page lists |
||
1903 | int number=MasterNames[oldPageName]; |
||
1904 | MasterNames.insert(newPageName, number); |
||
1905 | MasterNames.remove(oldPageName); |
||
1906 | Q_ASSERT(MasterPages.at(number)->pageName()==oldPageName); |
||
1907 | MasterPages.at(number)->setPageName(newPageName); |
||
1908 | //Update any pages that were linking to our old name |
||
16729 | fschmid | 1909 | ScPage* docPage=NULL; |
10013 | cbradney | 1910 | for (int i=0; i < DocPages.count(); ++i ) |
5685 | cbradney | 1911 | { |
10013 | cbradney | 1912 | docPage=DocPages[i]; |
5685 | cbradney | 1913 | if (docPage->MPageNam == oldPageName) |
1914 | docPage->MPageNam = newPageName; |
||
1915 | } |
||
5686 | cbradney | 1916 | //Update any items that were linking to our old name |
1917 | uint masterItemsCount=MasterItems.count(); |
||
1918 | for (uint i = 0; i < masterItemsCount; ++i) |
||
1919 | { |
||
1920 | if (MasterItems.at(i)->OnMasterPage == oldPageName) |
||
1921 | MasterItems.at(i)->OnMasterPage = newPageName; |
||
1922 | } |
||
5685 | cbradney | 1923 | changed(); |
1924 | return true; |
||
1925 | } |
||
1926 | return false; |
||
1927 | } |
||
1928 | |||
10532 | avox | 1929 | |
4069 | craig | 1930 | void ScribusDoc::deleteMasterPage(const int pageNumber) |
2895 | cbradney | 1931 | { |
9119 | avox | 1932 | assert(masterPageMode()); |
10013 | cbradney | 1933 | assert( Pages->count() > 1 && Pages->count() > pageNumber ); |
7890 | fschmid | 1934 | setCurrentPage(Pages->at(0)); |
16729 | fschmid | 1935 | ScPage* page = Pages->takeAt(pageNumber); |
5685 | cbradney | 1936 | QString oldPageName(page->pageName()); |
4069 | craig | 1937 | delete page; |
1938 | // remove the master page from the master page name list |
||
4615 | cbradney | 1939 | //MasterNames.remove(page->PageNam); |
1940 | /*CB TODO moved back to muster.cpp for now as this must happen after reformPages |
||
1941 | MasterNames.clear(); |
||
1942 | for (uint a = 0; a < Pages->count(); ++a) |
||
1943 | MasterNames[Pages->at(a)->PageNam] = Pages->at(a)->pageNr(); |
||
4069 | craig | 1944 | // and fix up any pages that refer to the deleted master page |
1945 | for (Page* docPage = DocPages.first(); docPage; docPage = DocPages.next() ) |
||
2895 | cbradney | 1946 | { |
4615 | cbradney | 1947 | if (docPage->MPageNam == oldPageName) |
6715 | cbradney | 1948 | docPage->MPageNam = CommonStrings::masterPageNormal; |
2895 | cbradney | 1949 | } |
4615 | cbradney | 1950 | */ |
4730 | subik | 1951 | //QPtrList docs: The item after the removed item becomes the new current list item if the removed item is not the last item in the list. If the last item is removed, the new last item becomes the current item. |
5545 | cbradney | 1952 | changed(); |
4069 | craig | 1953 | } |
1954 | |||
10532 | avox | 1955 | |
10155 | jghali | 1956 | void ScribusDoc::rebuildMasterNames(void) |
1957 | { |
||
1958 | MasterNames.clear(); |
||
10162 | cbradney | 1959 | for (int a = 0; a < MasterPages.count(); ++a) |
10155 | jghali | 1960 | MasterNames[MasterPages.at(a)->pageName()] = MasterPages.at(a)->pageNr(); |
1961 | } |
||
1962 | |||
10532 | avox | 1963 | |
10155 | jghali | 1964 | void ScribusDoc::replaceMasterPage(const QString& oldMasterPage) |
1965 | { |
||
1966 | uint pageIndex = 0; |
||
1967 | QMap<QString,int>::Iterator it = MasterNames.begin(); |
||
16729 | fschmid | 1968 | QListIterator<ScPage *> dpIt(DocPages); |
1969 | ScPage* docPage=NULL; |
||
10155 | jghali | 1970 | while(dpIt.hasNext()) |
1971 | //for (Page* docPage = currentDoc->DocPages.first(); docPage; docPage = currentDoc->DocPages.next() ) |
||
1972 | { |
||
1973 | docPage=dpIt.next(); |
||
1974 | if (docPage->MPageNam == oldMasterPage) |
||
1975 | { |
||
1976 | PageLocation pageLoc = locationOfPage(pageIndex); |
||
1977 | if (pageLoc == LeftPage) |
||
1978 | { |
||
1979 | if (MasterNames.contains( CommonStrings::trMasterPageNormalLeft)) |
||
1980 | docPage->MPageNam = CommonStrings::trMasterPageNormalLeft; |
||
1981 | else if (MasterNames.contains( CommonStrings::trMasterPageNormal)) |
||
1982 | docPage->MPageNam = CommonStrings::trMasterPageNormal; |
||
1983 | else |
||
1984 | docPage->MPageNam = it.key(); |
||
1985 | } |
||
1986 | else if (pageLoc == RightPage) |
||
1987 | { |
||
1988 | if (MasterNames.contains( CommonStrings::trMasterPageNormalRight)) |
||
1989 | docPage->MPageNam = CommonStrings::trMasterPageNormalRight; |
||
1990 | else if (MasterNames.contains( CommonStrings::trMasterPageNormal)) |
||
1991 | docPage->MPageNam = CommonStrings::trMasterPageNormal; |
||
1992 | else |
||
1993 | docPage->MPageNam = it.key(); |
||
1994 | } |
||
1995 | else |
||
1996 | { |
||
1997 | if (MasterNames.contains( CommonStrings::trMasterPageNormalMiddle)) |
||
1998 | docPage->MPageNam = CommonStrings::trMasterPageNormalMiddle; |
||
1999 | else if (MasterNames.contains( CommonStrings::trMasterPageNormal)) |
||
2000 | docPage->MPageNam = CommonStrings::trMasterPageNormal; |
||
2001 | else |
||
2002 | docPage->MPageNam = it.key(); |
||
2003 | } |
||
2004 | } |
||
2005 | pageIndex++; |
||
2006 | } |
||
2007 | } |
||
2008 | |||
10532 | avox | 2009 | |
4069 | craig | 2010 | void ScribusDoc::deletePage(const int pageNumber) |
2011 | { |
||
10013 | cbradney | 2012 | assert( Pages->count() > 1 && Pages->count() > pageNumber ); |
9030 | cbradney | 2013 | //#5561: If we are going to delete the first page, do not set the current page to it |
9855 | jghali | 2014 | setCurrentPage(Pages->at(pageNumber!=0?0:1)); |
16729 | fschmid | 2015 | ScPage* page = Pages->takeAt(pageNumber); |
4069 | craig | 2016 | delete page; |
5545 | cbradney | 2017 | changed(); |
2895 | cbradney | 2018 | } |
2019 | |||
10532 | avox | 2020 | |
2895 | cbradney | 2021 | void ScribusDoc::movePage(const int from, const int to, const int ziel, const int art) |
2022 | { |
||
16729 | fschmid | 2023 | QList<ScPage*> Buf; |
2895 | cbradney | 2024 | int zz = ziel; |
2025 | Buf.clear(); |
||
3778 | cbradney | 2026 | for (int a = from; a < to; ++a) |
2895 | cbradney | 2027 | { |
10014 | cbradney | 2028 | Buf.append(Pages->takeAt(from)); |
2895 | cbradney | 2029 | if (a <= zz) |
3778 | cbradney | 2030 | --zz; |
2895 | cbradney | 2031 | } |
10011 | fschmid | 2032 | int bufCount=Buf.count(); |
2895 | cbradney | 2033 | switch (art) |
2034 | { |
||
2035 | case 0: |
||
10013 | cbradney | 2036 | for (int b = 0; b < bufCount; ++b) |
3724 | cbradney | 2037 | Pages->insert(zz++, Buf.at(b)); |
2895 | cbradney | 2038 | break; |
2039 | case 1: |
||
10013 | cbradney | 2040 | for (int b = 0; b < bufCount; ++b) |
3724 | cbradney | 2041 | Pages->insert(++zz, Buf.at(b)); |
2895 | cbradney | 2042 | break; |
2043 | case 2: |
||
10013 | cbradney | 2044 | for (int b = 0; b < bufCount; ++b) |
3724 | cbradney | 2045 | Pages->append(Buf.at(b)); |
2895 | cbradney | 2046 | break; |
2047 | } |
||
5226 | cbradney | 2048 | changed(); |
2895 | cbradney | 2049 | } |
2937 | cbradney | 2050 | |
10532 | avox | 2051 | |
3985 | cbradney | 2052 | int ScribusDoc::addAutomaticTextFrame(const int pageNumber) |
3778 | cbradney | 2053 | { |
3852 | cbradney | 2054 | if (!automaticTextFrames) |
2055 | return -1; |
||
16729 | fschmid | 2056 | ScPage *addToPage=DocPages.at(pageNumber); |
3843 | cbradney | 2057 | if ((!masterPageMode()) && (usesAutomaticTextFrames()))// && (!isLoading())) |
3778 | cbradney | 2058 | { |
4546 | subik | 2059 | int z = itemAdd(PageItem::TextFrame, PageItem::Unspecified, |
3778 | cbradney | 2060 | addToPage->Margins.Left+addToPage->xOffset(), |
14991 | cbradney | 2061 | addToPage->Margins.Top+addToPage->yOffset(), docPrefsData.docSetupPrefs.pageWidth-addToPage->Margins.Right-addToPage->Margins.Left, |
2062 | docPrefsData.docSetupPrefs.pageHeight-addToPage->Margins.Bottom-addToPage->Margins.Top, |
||
14932 | cbradney | 2063 | 1, CommonStrings::None, docPrefsData.itemToolPrefs.shapeLineColor, true); |
3778 | cbradney | 2064 | Items->at(z)->isAutoText = true; |
2065 | Items->at(z)->Cols = qRound(PageSp); |
||
2066 | Items->at(z)->ColGap = PageSpa; |
||
5732 | avox | 2067 | if (LastAuto != 0) { |
7994 | avox | 2068 | LastAuto->link(Items->at(z)); |
5732 | avox | 2069 | } |
3778 | cbradney | 2070 | else |
2071 | FirstAuto = Items->at(z); |
||
2072 | LastAuto = Items->at(z); |
||
2073 | Items->at(z)->setRedrawBounding(); |
||
3781 | cbradney | 2074 | return z; |
3778 | cbradney | 2075 | } |
3781 | cbradney | 2076 | return -1; |
3778 | cbradney | 2077 | } |
2078 | |||
10532 | avox | 2079 | |
4645 | subik | 2080 | int ScribusDoc::addLayer(const QString& layerName, const bool activate) |
2937 | cbradney | 2081 | { |
13875 | jghali | 2082 | int lId = Layers.addLayer(layerName); |
2083 | if (lId==-1) |
||
12793 | cbradney | 2084 | return -1; |
2937 | cbradney | 2085 | if (activate) |
13875 | jghali | 2086 | setActiveLayer(lId); |
2087 | const ScLayer* ll = Layers.layerByID(lId); |
||
12793 | cbradney | 2088 | if (!ll) |
2089 | qWarning() << "Layer added without undo, could not get layer back for undo action creation"; |
||
2090 | else |
||
2937 | cbradney | 2091 | if (UndoManager::undoEnabled()) |
2092 | { |
||
2093 | SimpleState *ss = new SimpleState(Um::AddLayer, "", Um::ICreate); |
||
2094 | ss->set("ADD_LAYER", "add_layer"); |
||
2095 | ss->set("ACTIVE", ActiveLayer); |
||
10140 | jghali | 2096 | ss->set("NAME", ll->Name); |
13875 | jghali | 2097 | ss->set("LAYER_NR", ll->ID); |
2937 | cbradney | 2098 | undoManager->action(this, ss, DocName, Um::ILayer); |
2099 | } |
||
13875 | jghali | 2100 | return lId; |
2937 | cbradney | 2101 | } |
2102 | |||
10532 | avox | 2103 | |
13875 | jghali | 2104 | void ScribusDoc::copyLayer(int layerIDToCopy, int whereToInsert) |
6290 | fschmid | 2105 | { |
12405 | pierre | 2106 | if(!setActiveLayer(whereToInsert)) |
2107 | return; |
||
12407 | pierre | 2108 | Selection sourceSelection(this); |
16159 | fschmid | 2109 | for (int ite = 0; ite < Items->count(); ++ite) |
6290 | fschmid | 2110 | { |
2111 | PageItem *itemToCopy = Items->at(ite); |
||
13875 | jghali | 2112 | if (itemToCopy->LayerID == layerIDToCopy) |
6290 | fschmid | 2113 | { |
12407 | pierre | 2114 | sourceSelection.addItem(itemToCopy); |
6290 | fschmid | 2115 | } |
12407 | pierre | 2116 | } |
16546 | jghali | 2117 | if (sourceSelection.count() != 0) |
2118 |