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