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