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