Rev 5232 | Rev 5243 | 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" |
25 | #include "scribusapp.h" |
||
3 | paul | 26 | #include "scribusdoc.h" |
4320 | cbradney | 27 | #include "scribusview.h" |
28 | #include "scribuswin.h" |
||
410 | Franz | 29 | #include "scribusXml.h" |
5087 | subik | 30 | #include "guidemanager.h" |
2016 | cbradney | 31 | |
3670 | cbradney | 32 | #include <utility> |
2016 | cbradney | 33 | #include <qfile.h> |
3942 | cbradney | 34 | #include <qprogressbar.h> |
2016 | cbradney | 35 | |
3757 | cbradney | 36 | #include "filewatcher.h" |
4584 | cbradney | 37 | //CBVTD |
38 | #include "hruler.h" |
||
3757 | cbradney | 39 | #include "hyphenator.h" |
40 | #include "layers.h" |
||
456 | fschmid | 41 | #include "page.h" |
42 | #include "pageitem.h" |
||
3617 | cbradney | 43 | #include "pageitem_imageframe.h" |
44 | #include "pageitem_line.h" |
||
45 | #include "pageitem_pathtext.h" |
||
46 | #include "pageitem_polygon.h" |
||
47 | #include "pageitem_polyline.h" |
||
48 | #include "pageitem_textframe.h" |
||
3757 | cbradney | 49 | #include "pagestructs.h" |
50 | #include "prefsmanager.h" |
||
4705 | cbradney | 51 | #include "scmessagebox.h" |
4584 | cbradney | 52 | #include "scfontmetrics.h" |
4688 | cbradney | 53 | #include "scraction.h" |
3903 | cbradney | 54 | #include "selection.h" |
4707 | cbradney | 55 | #include "story.h" |
56 | #include "tree.h" |
||
1179 | tsoots | 57 | #include "undomanager.h" |
58 | #include "undostate.h" |
||
2965 | cbradney | 59 | #include "units.h" |
3809 | cbradney | 60 | #include "util.h" |
4546 | subik | 61 | #include "commonstrings.h" |
410 | Franz | 62 | |
5184 | avox | 63 | #include "text/nlsconfig.h" |
3205 | craig | 64 | |
5184 | avox | 65 | |
2952 | cbradney | 66 | extern ScribusQApp* ScQApp; |
2016 | cbradney | 67 | |
2891 | cbradney | 68 | #ifdef HAVE_CMS |
5178 | mrdocs | 69 | #include "cmserrorhandling.h" |
2891 | cbradney | 70 | extern cmsHPROFILE CMSoutputProf; |
71 | extern cmsHPROFILE CMSprinterProf; |
||
72 | extern cmsHTRANSFORM stdTransG; |
||
73 | extern cmsHTRANSFORM stdProofG; |
||
74 | extern cmsHTRANSFORM stdTransImgG; |
||
75 | extern cmsHTRANSFORM stdProofImgG; |
||
76 | extern cmsHTRANSFORM stdTransCMYKG; |
||
77 | extern cmsHTRANSFORM stdProofCMYKG; |
||
78 | extern cmsHTRANSFORM stdTransRGBG; |
||
3046 | fschmid | 79 | extern cmsHTRANSFORM stdProofGCG; |
80 | extern cmsHTRANSFORM stdProofCMYKGCG; |
||
2891 | cbradney | 81 | extern bool BlackPoint; |
82 | extern bool SoftProofing; |
||
83 | extern bool Gamut; |
||
84 | extern bool CMSuse; |
||
85 | extern int IntentMonitor; |
||
86 | extern int IntentPrinter; |
||
87 | #endif |
||
88 | |||
89 | extern bool CMSavail; |
||
1179 | tsoots | 90 | extern QPixmap loadIcon(QString nam); |
91 | |||
3983 | craig | 92 | ScribusDoc::ScribusDoc() : UndoObject( tr("Document")), |
93 | prefsData(PrefsManager::instance()->appPrefs), |
||
94 | undoManager(UndoManager::instance()), |
||
95 | loading(false), |
||
96 | modified(false), |
||
97 | ActiveLayer(0), |
||
98 | docUnitIndex(prefsData.docUnitIndex), |
||
99 | docUnitRatio(unitGetRatioFromIndex(docUnitIndex)), |
||
100 | automaticTextFrames(0), |
||
101 | m_masterPageMode(false), |
||
102 | is12doc(false), |
||
103 | NrItems(0), |
||
104 | First(1), Last(0), |
||
105 | viewCount(0), viewID(0), |
||
106 | SnapGuides(false), GuideLock(false), |
||
107 | ScratchLeft(prefsData.ScratchLeft), |
||
108 | ScratchRight(prefsData.ScratchRight), |
||
109 | ScratchTop(prefsData.ScratchTop), |
||
110 | ScratchBottom(prefsData.ScratchBottom), |
||
111 | minCanvasCoordinate(FPoint(0, 0)), |
||
112 | maxCanvasCoordinate(FPoint(ScratchLeft + ScratchRight, ScratchTop + ScratchBottom)), |
||
113 | rulerXoffset(0.0), rulerYoffset(0.0), |
||
3984 | craig | 114 | Pages(0), MasterPages(), DocPages(), |
3983 | craig | 115 | MasterNames(), |
3984 | craig | 116 | Items(0), MasterItems(), DocItems(), FrameItems(), |
4847 | cbradney | 117 | m_Selection(new Selection(this, true)), |
4069 | craig | 118 | pageWidth(0), pageHeight(0), |
119 | // pageCount(0) CR |
||
3983 | craig | 120 | // pageMargins |
121 | pageSets(prefsData.pageSets), |
||
122 | PageSp(1), PageSpa(0), |
||
123 | currentPageLayout(0), |
||
124 | PageOri(0), PageSize(0), |
||
125 | FirstPnum(1), |
||
126 | useRaster(false), |
||
127 | // documentInfo |
||
128 | appMode(modeNormal), |
||
129 | SubMode(-1), |
||
130 | ShapeValues(0), |
||
131 | ValCount(0), |
||
132 | DocName(tr("Document")+"-"), |
||
133 | UsedFonts(), |
||
134 | AllFonts(&prefsData.AvailFonts), |
||
135 | AObjects(), |
||
136 | papColor(prefsData.DpapColor), |
||
137 | CurrentSel(-1), |
||
138 | CurrentStyle(0), currentParaStyle(0), |
||
139 | // CurrFont, blah blah to CurrTextStrikeWidth are poked externally |
||
140 | EditClip(false), |
||
141 | EditClipMode(0), |
||
142 | typographicSettings(prefsData.typographicSettings), |
||
143 | guidesSettings(prefsData.guidesSettings), |
||
144 | toolSettings(prefsData.toolSettings), |
||
145 | checkerProfiles(prefsData.checkerProfiles), |
||
146 | curCheckProfile(prefsData.curCheckProfile), |
||
147 | LastAuto(0), FirstAuto(0), |
||
148 | // DragP, leaveDrag |
||
149 | DraggedElem(0), |
||
150 | ElemToLink(0), |
||
151 | DragElements(), |
||
152 | docParagraphStyles(), |
||
153 | Layers(), |
||
154 | marginColored(prefsData.marginColored), |
||
155 | GroupCounter(1), |
||
156 | // CMSSettings, HasCMS, etc done by setup() |
||
157 | JavaScripts(), |
||
158 | TotalItems(0), |
||
159 | MinWordLen(prefsData.MinWordLen), |
||
160 | HyCount(prefsData.HyCount), |
||
161 | Language(prefsData.Language), |
||
162 | Automatic(prefsData.Automatic), |
||
163 | AutoCheck(prefsData.AutoCheck), |
||
164 | PDF_Options(prefsData.PDF_Options), |
||
165 | RePos(false), |
||
166 | BookMarks(), |
||
167 | OldBM(false), |
||
168 | hasName(false), |
||
169 | RotMode(0), |
||
170 | AutoSave(prefsData.AutoSave), |
||
171 | AutoSaveTime(prefsData.AutoSaveTime), |
||
172 | autoSaveTimer(new QTimer(this)), |
||
173 | // library |
||
174 | FFonts(), |
||
175 | MLineStyles(), |
||
176 | arrowStyles(prefsData.arrowStyles), |
||
177 | WinHan(0), |
||
178 | DoDrawing(true), |
||
179 | OpenNodes(), |
||
180 | CurTimer(0), |
||
181 | docItemErrors(), |
||
182 | masterItemErrors(), |
||
183 | docItemAttributes(prefsData.defaultItemAttributes), |
||
184 | docToCSetups(prefsData.defaultToCSetups), |
||
185 | // sections |
||
186 | symReturn(), symNewLine(), symTab(), symNonBreak(), symNewCol(), symNewFrame(), |
||
4026 | craig | 187 | docHyphenator(new Hyphenator(ScMW, this)), // MUST be constructed late |
3983 | craig | 188 | _itemCreationTransactionStarted(false) |
3 | paul | 189 | { |
4847 | cbradney | 190 | Q_CHECK_PTR(m_Selection); |
3983 | craig | 191 | Q_CHECK_PTR(docHyphenator); |
192 | Q_CHECK_PTR(autoSaveTimer); |
||
193 | |||
823 | fschmid | 194 | FT_Init_FreeType( &library ); |
3983 | craig | 195 | AddFont(prefsData.toolSettings.defFont);//, prefsData.AvailFonts[prefsData.toolSettings.defFont]->Font); |
196 | toolSettings.defFont = prefsData.toolSettings.defFont; |
||
197 | toolSettings.defSize = prefsData.toolSettings.defSize; |
||
198 | toolSettings.tabFillChar = prefsData.toolSettings.tabFillChar; |
||
2886 | fschmid | 199 | PageColors.insert("Black", ScColor(0, 0, 0, 255)); |
200 | PageColors.insert("White", ScColor(0, 0, 0, 0)); |
||
4546 | subik | 201 | if (prefsData.toolSettings.dPen != CommonStrings::None) |
3983 | craig | 202 | PageColors.insert(prefsData.toolSettings.dPen, prefsData.DColors[prefsData.toolSettings.dPen]); |
203 | toolSettings.dPen = prefsData.toolSettings.dPen; |
||
4546 | subik | 204 | if (prefsData.toolSettings.dPenLine != CommonStrings::None) |
3983 | craig | 205 | PageColors.insert(prefsData.toolSettings.dPenLine, prefsData.DColors[prefsData.toolSettings.dPenLine]); |
206 | toolSettings.dPenLine = prefsData.toolSettings.dPenLine; |
||
4546 | subik | 207 | if (prefsData.toolSettings.dPenText != CommonStrings::None) |
3983 | craig | 208 | PageColors.insert(prefsData.toolSettings.dPenText, prefsData.DColors[prefsData.toolSettings.dPenText]); |
209 | toolSettings.dPenText = prefsData.toolSettings.dPenText; |
||
4546 | subik | 210 | if (prefsData.toolSettings.dStrokeText != CommonStrings::None) |
3983 | craig | 211 | PageColors.insert(prefsData.toolSettings.dStrokeText, prefsData.DColors[prefsData.toolSettings.dStrokeText]); |
212 | toolSettings.dStrokeText = prefsData.toolSettings.dStrokeText; |
||
4546 | subik | 213 | if (prefsData.toolSettings.dBrush != CommonStrings::None) |
3983 | craig | 214 | PageColors.insert(prefsData.toolSettings.dBrush, prefsData.DColors[prefsData.toolSettings.dBrush]); |
215 | toolSettings.dBrush = prefsData.toolSettings.dBrush; |
||
4546 | subik | 216 | if (prefsData.toolSettings.dBrushPict != CommonStrings::None) |
3983 | craig | 217 | PageColors.insert(prefsData.toolSettings.dBrushPict, prefsData.DColors[prefsData.toolSettings.dBrushPict]); |
218 | toolSettings.dBrushPict = prefsData.toolSettings.dBrushPict; |
||
4546 | subik | 219 | if (prefsData.toolSettings.dTextBackGround != CommonStrings::None) |
3983 | craig | 220 | PageColors.insert(prefsData.toolSettings.dTextBackGround, prefsData.DColors[prefsData.toolSettings.dTextBackGround]); |
221 | toolSettings.dTextBackGround = prefsData.toolSettings.dTextBackGround; |
||
4546 | subik | 222 | if (prefsData.toolSettings.dTextLineColor != CommonStrings::None) |
3983 | craig | 223 | PageColors.insert(prefsData.toolSettings.dTextLineColor, prefsData.DColors[prefsData.toolSettings.dTextLineColor]); |
5215 | mrdocs | 224 | ParagraphStyle vg; |
5184 | avox | 225 | vg.setName("Normal Internal"); |
226 | vg.setLineSpacingMode(ParagraphStyle::FixedLineSpacing); |
||
227 | vg.setLineSpacing(15); |
||
228 | vg.setAlignment(0); |
||
229 | vg.setLeftMargin(0); |
||
230 | vg.setFirstIndent(0); |
||
231 | vg.setGapBefore(0); |
||
232 | vg.setGapAfter(0); |
||
233 | vg.charStyle().cfont = NULL; |
||
234 | vg.charStyle().csize = toolSettings.defSize; |
||
235 | vg.tabValues().clear(); |
||
236 | vg.setHasDropCap(false); |
||
237 | vg.setDropCapLines(2); |
||
238 | vg.setDropCapOffset(0); |
||
239 | vg.charStyle().cstyle = ScStyle_Default; |
||
240 | vg.charStyle().ccolor = toolSettings.dBrush; |
||
241 | vg.charStyle().cshade = toolSettings.dShade; |
||
242 | vg.charStyle().cstroke = toolSettings.dPen; |
||
243 | vg.charStyle().cshade2 = toolSettings.dShade2; |
||
244 | vg.charStyle().cbase = false; |
||
245 | vg.charStyle().cshadowx = 50; |
||
246 | vg.charStyle().cshadowy = -50; |
||
247 | vg.charStyle().coutline = 10; |
||
248 | vg.charStyle().cunderpos = typographicSettings.valueUnderlinePos; |
||
249 | vg.charStyle().cunderwidth = typographicSettings.valueUnderlineWidth; |
||
250 | vg.charStyle().cstrikepos = typographicSettings.valueStrikeThruPos; |
||
251 | vg.charStyle().cstrikewidth = typographicSettings.valueStrikeThruPos; |
||
252 | vg.charStyle().cscale = 1000; |
||
253 | vg.charStyle().cscalev = 1000; |
||
254 | vg.charStyle().cbase = 0; |
||
255 | vg.charStyle().cextra = 0; |
||
1065 | cbradney | 256 | docParagraphStyles.append(vg); |
5184 | avox | 257 | vg.setName("Center Internal"); |
258 | vg.setAlignment(1); |
||
1065 | cbradney | 259 | docParagraphStyles.append(vg); |
5184 | avox | 260 | vg.setName("Rechts Internal"); |
261 | vg.setAlignment(2); |
||
1065 | cbradney | 262 | docParagraphStyles.append(vg); |
5184 | avox | 263 | vg.setName("Block Internal"); |
264 | vg.setAlignment(3); |
||
1065 | cbradney | 265 | docParagraphStyles.append(vg); |
5184 | avox | 266 | vg.setName("EBlock Internal"); |
267 | vg.setAlignment(4); |
||
1065 | cbradney | 268 | docParagraphStyles.append(vg); |
3 | paul | 269 | struct Layer ll; |
270 | ll.LNr = 0; |
||
271 | ll.Level = 0; |
||
3173 | fschmid | 272 | ll.Name = tr("Background"); |
1065 | cbradney | 273 | ll.isViewable = true; |
274 | ll.isPrintable = true; |
||
4832 | fschmid | 275 | ll.isEditable = true; |
3 | paul | 276 | Layers.append(ll); |
1973 | craig | 277 | // Fixme: Check PDF version input |
3983 | craig | 278 | PDF_Options.Version = (PDFOptions::PDFVersion)prefsData.PDF_Options.Version; |
3201 | subik | 279 | |
3784 | cbradney | 280 | if (AutoSave && ScQApp->usingGUI()) |
281 | autoSaveTimer->start(AutoSaveTime); |
||
3724 | cbradney | 282 | //Do this after all the collections have been created and cleared! |
283 | m_masterPageMode=true; // quick hack to force the change of pointers in setMasterPageMode(); |
||
284 | setMasterPageMode(false); |
||
2891 | cbradney | 285 | addSymbols(); |
5178 | mrdocs | 286 | |
287 | #ifdef HAVE_CMS |
||
288 | DocInputProf = NULL; |
||
289 | DocOutputProf = NULL; |
||
290 | DocPrinterProf = NULL; |
||
291 | stdTrans = NULL; |
||
292 | stdProof = NULL; |
||
293 | stdTransImg = NULL; |
||
294 | stdProofImg = NULL; |
||
295 | stdTransCMYK = NULL; |
||
296 | stdProofCMYK = NULL; |
||
297 | stdTransRGB = NULL; |
||
298 | stdProofGC = NULL; |
||
299 | stdProofCMYKGC = NULL; |
||
300 | #endif |
||
3 | paul | 301 | } |
302 | |||
303 | ScribusDoc::~ScribusDoc() |
||
304 | { |
||
456 | fschmid | 305 | DocItems.setAutoDelete(true); |
2498 | fschmid | 306 | FrameItems.setAutoDelete(true); |
456 | fschmid | 307 | DocItems.clear(); |
2498 | fschmid | 308 | FrameItems.clear(); |
456 | fschmid | 309 | MasterPages.setAutoDelete(true); |
310 | DocPages.setAutoDelete(true); |
||
311 | MasterPages.clear(); |
||
312 | DocPages.clear(); |
||
4199 | mrdocs | 313 | MasterItems.setAutoDelete(true); |
314 | MasterItems.clear(); |
||
3544 | avox | 315 | QMap<QString,int>::Iterator it3; |
494 | fschmid | 316 | for (it3 = UsedFonts.begin(); it3 != UsedFonts.end(); ++it3) |
317 | { |
||
2877 | cbradney | 318 | if (!(*AllFonts)[it3.key()]->PrivateFont.isEmpty()) |
494 | fschmid | 319 | (*AllFonts).removeFont(it3.key()); |
320 | } |
||
3 | paul | 321 | FT_Done_FreeType( library ); |
322 | } |
||
323 | |||
2901 | fschmid | 324 | 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 | 325 | { |
326 | docUnitIndex=unitIndex; |
||
3016 | fschmid | 327 | pageSets[fp].FirstPage = firstLeft; |
2891 | cbradney | 328 | PageOri = orientation; |
329 | PageSize = defaultPageSize; |
||
330 | FirstPnum = firstPageNumber; |
||
3032 | fschmid | 331 | currentPageLayout = fp; |
2891 | cbradney | 332 | setName(documentName); |
333 | HasCMS = true; |
||
4039 | fschmid | 334 | if (!PDF_Options.UseLPI) |
335 | { |
||
336 | PDF_Options.LPISettings.clear(); |
||
337 | struct LPIData lpo; |
||
338 | lpo.Frequency = 75; |
||
339 | lpo.SpotFunc = 2; |
||
340 | lpo.Angle = 105; |
||
341 | PDF_Options.LPISettings.insert("Cyan", lpo); |
||
342 | lpo.Angle = 75; |
||
343 | PDF_Options.LPISettings.insert("Magenta", lpo); |
||
344 | lpo.Angle = 90; |
||
345 | PDF_Options.LPISettings.insert("Yellow", lpo); |
||
346 | lpo.Angle = 45; |
||
347 | PDF_Options.LPISettings.insert("Black", lpo); |
||
348 | ActiveLayer = 0; |
||
349 | } |
||
3201 | subik | 350 | |
2891 | cbradney | 351 | appMode = modeNormal; |
352 | PrefsManager *prefsManager=PrefsManager::instance(); |
||
353 | PageColors = prefsManager->colorSet(); |
||
3201 | subik | 354 | |
3983 | craig | 355 | CMSSettings = prefsManager->appPrefs.DCMSset; |
2984 | fschmid | 356 | PDF_Options.SolidProf = CMSSettings.DefaultSolidColorProfile; |
357 | PDF_Options.ImageProf = CMSSettings.DefaultImageRGBProfile; |
||
2891 | cbradney | 358 | PDF_Options.PrintProf = CMSSettings.DefaultPrinterProfile; |
359 | PDF_Options.Intent = CMSSettings.DefaultIntentMonitor; |
||
2984 | fschmid | 360 | PDF_Options.Intent2 = CMSSettings.DefaultIntentImages; |
4546 | subik | 361 | #ifdef HAVE_CMS |
2892 | fschmid | 362 | SoftProofing = CMSSettings.SoftProofOn; |
363 | Gamut = CMSSettings.GamutCheck; |
||
364 | IntentPrinter = CMSSettings.DefaultIntentPrinter; |
||
365 | IntentMonitor = CMSSettings.DefaultIntentMonitor; |
||
366 | BlackPoint = CMSSettings.BlackPoint; |
||
3438 | cbradney | 367 | #endif |
3051 | fschmid | 368 | if ((CMSavail) && (CMSSettings.CMSinUse)) |
2891 | cbradney | 369 | { |
370 | #ifdef HAVE_CMS |
||
5178 | mrdocs | 371 | if (OpenCMSProfiles(ScMW->InputProfiles, ScMW->MonitorProfiles, ScMW->PrinterProfiles)) |
372 | { |
||
373 | stdProofG = stdProof; |
||
374 | stdTransG = stdTrans; |
||
375 | stdProofImgG = stdProofImg; |
||
376 | stdTransImgG = stdTransImg; |
||
377 | stdProofCMYKG = stdProofCMYK; |
||
378 | stdTransCMYKG = stdTransCMYK; |
||
379 | stdTransRGBG = stdTransRGB; |
||
380 | stdProofGCG = stdProofGC; |
||
381 | stdProofCMYKGCG = stdProofCMYKGC; |
||
382 | CMSoutputProf = DocOutputProf; |
||
383 | CMSprinterProf = DocPrinterProf; |
||
384 | if (static_cast<int>(cmsGetColorSpace(DocInputProf)) == icSigRgbData) |
||
385 | CMSSettings.ComponentsInput2 = 3; |
||
386 | if (static_cast<int>(cmsGetColorSpace(DocInputProf)) == icSigCmykData) |
||
387 | CMSSettings.ComponentsInput2 = 4; |
||
388 | if (static_cast<int>(cmsGetColorSpace(DocInputProf)) == icSigCmyData) |
||
389 | CMSSettings.ComponentsInput2 = 3; |
||
390 | if (static_cast<int>(cmsGetColorSpace(DocPrinterProf)) == icSigRgbData) |
||
391 | CMSSettings.ComponentsPrinter = 3; |
||
392 | if (static_cast<int>(cmsGetColorSpace(DocPrinterProf)) == icSigCmykData) |
||
393 | CMSSettings.ComponentsPrinter = 4; |
||
394 | if (static_cast<int>(cmsGetColorSpace(DocPrinterProf)) == icSigCmyData) |
||
395 | CMSSettings.ComponentsPrinter = 3; |
||
396 | PDF_Options.SComp = CMSSettings.ComponentsInput2; |
||
397 | } |
||
398 | else |
||
399 | CMSSettings.CMSinUse = false; |
||
2891 | cbradney | 400 | #endif |
401 | } |
||
402 | } |
||
403 | |||
404 | void ScribusDoc::setLoading(const bool docLoading) |
||
405 | { |
||
406 | loading = docLoading; |
||
407 | } |
||
408 | |||
3985 | cbradney | 409 | bool ScribusDoc::isLoading() const |
2891 | cbradney | 410 | { |
411 | return loading; |
||
412 | } |
||
413 | |||
4320 | cbradney | 414 | ScribusView* ScribusDoc::view() const |
415 | { |
||
416 | return (WinHan ? (((ScribusWin*) WinHan)->view()) : 0); |
||
417 | } |
||
418 | |||
1330 | fschmid | 419 | void ScribusDoc::CloseCMSProfiles() |
420 | { |
||
421 | #ifdef HAVE_CMS |
||
5178 | mrdocs | 422 | if ((CMSavail) /*&& (CMSSettings.CMSinUse)*/) |
3051 | fschmid | 423 | { |
5178 | mrdocs | 424 | if (DocInputProf) |
425 | cmsCloseProfile(DocInputProf); |
||
426 | if (DocOutputProf) |
||
427 | cmsCloseProfile(DocOutputProf); |
||
428 | if (DocPrinterProf) |
||
429 | cmsCloseProfile(DocPrinterProf); |
||
430 | if (stdTrans) |
||
431 | cmsDeleteTransform(stdTrans); |
||
432 | if (stdProof) |
||
433 | cmsDeleteTransform(stdProof); |
||
434 | if (stdTransImg) |
||
435 | cmsDeleteTransform(stdTransImg); |
||
436 | if (stdProofImg) |
||
437 | cmsDeleteTransform(stdProofImg); |
||
438 | if (stdTransCMYK) |
||
439 | cmsDeleteTransform(stdTransCMYK); |
||
440 | if (stdProofCMYK) |
||
441 | cmsDeleteTransform(stdProofCMYK); |
||
442 | if (stdTransRGB) |
||
443 | cmsDeleteTransform(stdTransRGB); |
||
444 | if (stdProofCMYKGC) |
||
445 | cmsDeleteTransform(stdProofCMYKGC); |
||
446 | if (stdProofGC) |
||
447 | cmsDeleteTransform(stdProofGC); |
||
448 | DocInputProf = NULL; |
||
449 | DocOutputProf = NULL; |
||
450 | DocPrinterProf = NULL; |
||
451 | stdTrans = NULL; |
||
452 | stdProof = NULL; |
||
453 | stdTransImg = NULL; |
||
454 | stdProofImg = NULL; |
||
455 | stdTransCMYK = NULL; |
||
456 | stdProofCMYK = NULL; |
||
457 | stdTransRGB = NULL; |
||
458 | stdProofCMYKGC = NULL; |
||
459 | stdProofGC = NULL; |
||
3051 | fschmid | 460 | } |
1330 | fschmid | 461 | #endif |
462 | } |
||
463 | |||
5178 | mrdocs | 464 | bool ScribusDoc::OpenCMSProfiles(ProfilesL InPo, ProfilesL MoPo, ProfilesL PrPo) |
1330 | fschmid | 465 | { |
466 | #ifdef HAVE_CMS |
||
5178 | mrdocs | 467 | cmsErrorAction(LCMS_ERROR_ABORT); |
468 | if (setjmp(cmsJumpBuffer)) |
||
469 | { |
||
470 | // Reset to the default handler otherwise may enter a loop |
||
471 | // if an error occur afterwards |
||
472 | cmsSetErrorHandler(NULL); |
||
473 | CloseCMSProfiles(); |
||
474 | CMSSettings.CMSinUse = CMSuse = false; |
||
475 | QString message = tr("An error occurred while opening icc profiles, color management is not enabled." ); |
||
476 | if (ScQApp->usingGUI()) |
||
477 | QMessageBox::warning(ScMW, CommonStrings::trWarning, message, QMessageBox::Ok, 0, 0); |
||
478 | else |
||
479 | qWarning( message.local8Bit().data() ); |
||
480 | return false; |
||
481 | } |
||
482 | cmsSetErrorHandler(&cmsErrorHandler); |
||
3745 | craig | 483 | const QCString inputProfilePath(InPo[CMSSettings.DefaultSolidColorProfile].local8Bit()); |
484 | DocInputProf = cmsOpenProfileFromFile(inputProfilePath.data(), "r"); |
||
485 | const QCString monitorProfilePath(MoPo[CMSSettings.DefaultMonitorProfile].local8Bit()); |
||
486 | DocOutputProf = cmsOpenProfileFromFile(monitorProfilePath.data(), "r"); |
||
487 | const QCString printerProfilePath(PrPo[CMSSettings.DefaultPrinterProfile].local8Bit()); |
||
488 | DocPrinterProf = cmsOpenProfileFromFile(printerProfilePath, "r"); |
||
1330 | fschmid | 489 | if ((DocInputProf == NULL) || (DocOutputProf == NULL) || (DocPrinterProf == NULL)) |
490 | { |
||
491 | CMSSettings.CMSinUse = false; |
||
5178 | mrdocs | 492 | return false; |
1330 | fschmid | 493 | } |
494 | int dcmsFlags = 0; |
||
3046 | fschmid | 495 | int dcmsFlags2 = 0; |
496 | dcmsFlags |= cmsFLAGS_LOWRESPRECALC; |
||
497 | dcmsFlags2 |= cmsFLAGS_LOWRESPRECALC; |
||
498 | // int dcmsFlags2 = cmsFLAGS_NOTPRECALC; |
||
1488 | fschmid | 499 | if (CMSSettings.GamutCheck) |
1330 | fschmid | 500 | dcmsFlags |= cmsFLAGS_GAMUTCHECK; |
501 | if (CMSSettings.BlackPoint) |
||
502 | { |
||
503 | dcmsFlags2 |= cmsFLAGS_BLACKPOINTCOMPENSATION; |
||
504 | dcmsFlags |= cmsFLAGS_BLACKPOINTCOMPENSATION; |
||
505 | } |
||
1525 | cbradney | 506 | // set Gamut alarm color to #00ff00 |
1488 | fschmid | 507 | cmsSetAlarmCodes(0, 255, 0); |
1330 | fschmid | 508 | stdProof = cmsCreateProofingTransform(DocInputProf, TYPE_RGB_16, |
509 | DocOutputProf, TYPE_RGB_16, |
||
510 | DocPrinterProf, |
||
511 | IntentPrinter, |
||
3046 | fschmid | 512 | IntentMonitor, dcmsFlags | cmsFLAGS_SOFTPROOFING); |
513 | stdProofGC = cmsCreateProofingTransform(DocInputProf, TYPE_RGB_16, |
||
514 | DocOutputProf, TYPE_RGB_16, |
||
515 | DocPrinterProf, |
||
516 | IntentPrinter, |
||
517 | IntentMonitor, dcmsFlags | cmsFLAGS_SOFTPROOFING | cmsFLAGS_GAMUTCHECK); |
||
1330 | fschmid | 518 | stdTrans = cmsCreateTransform(DocInputProf, TYPE_RGB_16, |
519 | DocOutputProf, TYPE_RGB_16, |
||
520 | IntentMonitor, |
||
521 | dcmsFlags2); |
||
522 | stdProofImg = cmsCreateProofingTransform(DocInputProf, TYPE_RGBA_8, |
||
523 | DocOutputProf, TYPE_RGBA_8, |
||
524 | DocPrinterProf, |
||
525 | IntentPrinter, |
||
3046 | fschmid | 526 | IntentMonitor, dcmsFlags | cmsFLAGS_SOFTPROOFING); |
1330 | fschmid | 527 | stdTransImg = cmsCreateTransform(DocInputProf, TYPE_RGBA_8, |
528 | DocOutputProf, TYPE_RGBA_8, |
||
529 | IntentMonitor, |
||
530 | dcmsFlags2); |
||
1491 | fschmid | 531 | if (static_cast<int>(cmsGetColorSpace(DocPrinterProf)) == icSigCmykData) |
532 | { |
||
533 | stdProofCMYK = cmsCreateProofingTransform(DocPrinterProf, TYPE_CMYK_16, |
||
534 | DocOutputProf, TYPE_RGB_16, |
||
535 | DocPrinterProf, |
||
536 | IntentPrinter, |
||
3046 | fschmid | 537 | IntentMonitor, dcmsFlags | cmsFLAGS_SOFTPROOFING); |
538 | stdProofCMYKGC = cmsCreateProofingTransform(DocPrinterProf, TYPE_CMYK_16, |
||
539 | DocOutputProf, TYPE_RGB_16, |
||
540 | DocPrinterProf, |
||
541 | IntentPrinter, |
||
542 | IntentMonitor, dcmsFlags | cmsFLAGS_SOFTPROOFING | cmsFLAGS_GAMUTCHECK); |
||
1491 | fschmid | 543 | stdTransCMYK = cmsCreateTransform(DocInputProf, TYPE_RGB_16, |
544 | DocPrinterProf, TYPE_CMYK_16, |
||
545 | IntentPrinter, |
||
546 | dcmsFlags2); |
||
547 | stdTransRGB = cmsCreateTransform(DocPrinterProf, TYPE_CMYK_16, |
||
548 | DocInputProf, TYPE_RGB_16, |
||
549 | IntentMonitor, |
||
550 | dcmsFlags2); |
||
551 | } |
||
552 | else |
||
553 | { |
||
554 | stdProofCMYK = cmsCreateProofingTransform(DocPrinterProf, TYPE_RGB_16, |
||
555 | DocOutputProf, TYPE_RGB_16, |
||
556 | DocPrinterProf, |
||
557 | IntentPrinter, |
||
3046 | fschmid | 558 | IntentMonitor, dcmsFlags | cmsFLAGS_SOFTPROOFING); |
559 | stdProofCMYKGC = cmsCreateProofingTransform(DocPrinterProf, TYPE_RGB_16, |
||
560 | DocOutputProf, TYPE_RGB_16, |
||
561 | DocPrinterProf, |
||
562 | IntentPrinter, |
||
563 | IntentMonitor, dcmsFlags | cmsFLAGS_SOFTPROOFING | cmsFLAGS_GAMUTCHECK); |
||
1491 | fschmid | 564 | stdTransCMYK = cmsCreateTransform(DocInputProf, TYPE_RGB_16, |
565 | DocPrinterProf, TYPE_RGB_16, |
||
566 | IntentPrinter, |
||
567 | dcmsFlags2); |
||
568 | stdTransRGB = cmsCreateTransform(DocPrinterProf, TYPE_RGB_16, |
||
569 | DocInputProf, TYPE_RGB_16, |
||
570 | IntentMonitor, |
||
571 | dcmsFlags2); |
||
572 | } |
||
5210 | mrdocs | 573 | cmsSetErrorHandler(NULL); |
5178 | mrdocs | 574 | return true; |
1330 | fschmid | 575 | #endif |
576 | } |
||
577 | |||
456 | fschmid | 578 | /* |
579 | * Split out from loadStyles in editFormats.cpp so it's callable from anywhere, |
||
580 | * including plugins. |
||
581 | * - 2004-09-14 Craig Ringer |
||
582 | */ |
||
1065 | cbradney | 583 | void ScribusDoc::loadStylesFromFile(QString fileName, QValueList<ParagraphStyle> *tempStyles) |
456 | fschmid | 584 | { |
1065 | cbradney | 585 | // This won't create the QValueList<ParagraphStyle> will it? |
586 | QValueList<ParagraphStyle> *wrkStyles = NULL; |
||
456 | fschmid | 587 | /* |
588 | * Use the working styles struct if passed, or work directly |
||
589 | * on the document styles otherwise. Note that tempStyles, |
||
590 | * if passed, MUST have the first five styles initialised already |
||
591 | * or this function will segfault. |
||
592 | */ |
||
593 | if (tempStyles != NULL) |
||
594 | wrkStyles = tempStyles; |
||
595 | else |
||
1065 | cbradney | 596 | wrkStyles = &docParagraphStyles; |
456 | fschmid | 597 | if (!fileName.isEmpty()) |
598 | { |
||
599 | ScriXmlDoc *ss = new ScriXmlDoc(); |
||
1065 | cbradney | 600 | ss->docParagraphStyles.clear(); |
456 | fschmid | 601 | for (uint x = 5; x < wrkStyles->count(); ++x) |
1065 | cbradney | 602 | ss->docParagraphStyles.append((*wrkStyles)[x]); |
456 | fschmid | 603 | uint old = wrkStyles->count()-5; |
2834 | cbradney | 604 | if (ss->ReadStyles(fileName, this)) |
456 | fschmid | 605 | { |
1065 | cbradney | 606 | if (ss->docParagraphStyles.count() > old) |
456 | fschmid | 607 | { |
1065 | cbradney | 608 | for (uint xx=old; xx<ss->docParagraphStyles.count(); ++xx) |
456 | fschmid | 609 | { |
5184 | avox | 610 | ParagraphStyle sty; |
611 | sty.setName(ss->docParagraphStyles[xx].name()); |
||
612 | sty.setLineSpacingMode(static_cast<ParagraphStyle::LineSpacingMode>(ss->docParagraphStyles[xx].lineSpacingMode())); |
||
613 | sty.setLineSpacing(ss->docParagraphStyles[xx].lineSpacing()); |
||
614 | sty.setAlignment(ss->docParagraphStyles[xx].alignment()); |
||
615 | sty.setLeftMargin(ss->docParagraphStyles[xx].leftMargin()); |
||
616 | sty.setFirstIndent(ss->docParagraphStyles[xx].firstIndent()); |
||
617 | sty.setGapBefore(ss->docParagraphStyles[xx].gapBefore()); |
||
618 | sty.setGapAfter(ss->docParagraphStyles[xx].gapAfter()); |
||
619 | sty.charStyle().cfont = ss->docParagraphStyles[xx].charStyle().font(); |
||
620 | sty.charStyle().csize = ss->docParagraphStyles[xx].charStyle().fontSize(); |
||
621 | sty.tabValues() = ss->docParagraphStyles[xx].tabValues(); |
||
622 | sty.setHasDropCap(ss->docParagraphStyles[xx].hasDropCap()); |
||
623 | sty.setDropCapLines(ss->docParagraphStyles[xx].dropCapLines()); |
||
624 | sty.setDropCapOffset(ss->docParagraphStyles[xx].dropCapOffset()); |
||
625 | sty.charStyle().cstyle = ss->docParagraphStyles[xx].charStyle().cstyle; |
||
626 | sty.charStyle().ccolor = ss->docParagraphStyles[xx].charStyle().ccolor; |
||
627 | sty.charStyle().cshade = ss->docParagraphStyles[xx].charStyle().cshade; |
||
628 | sty.charStyle().cstroke = ss->docParagraphStyles[xx].charStyle().cstroke; |
||
629 | sty.charStyle().cshade2 = ss->docParagraphStyles[xx].charStyle().cshade; |
||
630 | sty.setUseBaselineGrid(ss->docParagraphStyles[xx].useBaselineGrid()); |
||
631 | sty.charStyle().cshadowx = ss->docParagraphStyles[xx].charStyle().cshadowx; |
||
632 | sty.charStyle().cshadowy = ss->docParagraphStyles[xx].charStyle().cshadowy; |
||
633 | sty.charStyle().coutline = ss->docParagraphStyles[xx].charStyle().coutline; |
||
634 | sty.charStyle().cunderpos = ss->docParagraphStyles[xx].charStyle().cunderpos; |
||
635 | sty.charStyle().cunderwidth = ss->docParagraphStyles[xx].charStyle().cunderwidth; |
||
636 | sty.charStyle().cstrikepos = ss->docParagraphStyles[xx].charStyle().cstrikepos; |
||
637 | sty.charStyle().cstrikewidth = ss->docParagraphStyles[xx].charStyle().cstrikewidth; |
||
638 | sty.charStyle().cscale = ss->docParagraphStyles[xx].charStyle().cscale; |
||
639 | sty.charStyle().cscalev = ss->docParagraphStyles[xx].charStyle().cscalev; |
||
640 | sty.charStyle().cbase = ss->docParagraphStyles[xx].charStyle().cbase; |
||
641 | sty.charStyle().cextra = ss->docParagraphStyles[xx].charStyle().cextra; |
||
456 | fschmid | 642 | wrkStyles->append(sty); |
643 | } |
||
644 | } |
||
645 | } |
||
646 | delete ss; |
||
647 | } |
||
648 | } |
||
649 | |||
1179 | tsoots | 650 | void ScribusDoc::lockGuides(bool isLocked) |
651 | { |
||
1180 | tsoots | 652 | if (GuideLock == isLocked) |
653 | return; |
||
1179 | tsoots | 654 | GuideLock = isLocked; |
655 | if (UndoManager::undoEnabled()) |
||
656 | { |
||
657 | QString name; |
||
658 | if (isLocked) |
||
1190 | tsoots | 659 | name = Um::LockGuides; |
1179 | tsoots | 660 | else |
1190 | tsoots | 661 | name = Um::UnlockGuides; |
662 | SimpleState *ss = new SimpleState(name, "", Um::ILockGuides); |
||
1179 | tsoots | 663 | ss->set("GUIDE_LOCK", isLocked); |
664 | undoManager->action(this, ss); |
||
665 | } |
||
666 | } |
||
667 | |||
668 | void ScribusDoc::restore(UndoState* state, bool isUndo) |
||
669 | { |
||
670 | SimpleState *ss = dynamic_cast<SimpleState*>(state); |
||
671 | if (ss) |
||
672 | { |
||
2941 | cbradney | 673 | bool layersUndo=false; |
1179 | tsoots | 674 | if (ss->contains("GUIDE_LOCK")) |
675 | { |
||
676 | if (isUndo) |
||
677 | GuideLock = !ss->getBool("GUIDE_LOCK"); |
||
678 | else |
||
3201 | subik | 679 | GuideLock = ss->getBool("GUIDE_LOCK"); |
1179 | tsoots | 680 | } |
2937 | cbradney | 681 | else if (ss->contains("UP_LAYER")) |
682 | { |
||
683 | if (isUndo) |
||
684 | lowerLayer(ss->getInt("ACTIVE")); |
||
685 | else |
||
686 | raiseLayer(ss->getInt("ACTIVE")); |
||
2941 | cbradney | 687 | layersUndo=true; |
2937 | cbradney | 688 | } |
689 | else if (ss->contains("DOWN_LAYER")) |
||
690 | { |
||
691 | if (isUndo) |
||
692 | raiseLayer(ss->getInt("ACTIVE")); |
||
693 | else |
||
694 | lowerLayer(ss->getInt("ACTIVE")); |
||
2941 | cbradney | 695 | layersUndo=true; |
2937 | cbradney | 696 | } |
697 | else if (ss->contains("PRINT_LAYER")) |
||
698 | { |
||
699 | bool print = ss->getBool("PRINT"); |
||
700 | setLayerPrintable(ss->getInt("ACTIVE"), isUndo ? !print : print); |
||
2941 | cbradney | 701 | layersUndo=true; |
2937 | cbradney | 702 | } |
703 | else if (ss->contains("ADD_LAYER")) |
||
704 | { |
||
705 | if (isUndo) |
||
2944 | cbradney | 706 | deleteLayer(ss->getInt("LAYER_NR"), false); |
2937 | cbradney | 707 | else |
708 | { |
||
2944 | cbradney | 709 | int layerNumber=addLayer( ss->get("NAME"), false ); |
710 | int newLayerNumber=ss->getInt("LAYER_NR"); |
||
711 | bool renumberedOk=renumberLayer(layerNumber, newLayerNumber); |
||
712 | Q_ASSERT(renumberedOk); |
||
2937 | cbradney | 713 | } |
2944 | cbradney | 714 | layersUndo=true; |
2937 | cbradney | 715 | } |
716 | else if (ss->contains("REMOVE_LAYER")) |
||
717 | { |
||
718 | if (isUndo) |
||
719 | { |
||
2944 | cbradney | 720 | int layerNumber=addLayer( ss->get("NAME"), false ); |
721 | int newLayerNumber=ss->getInt("LAYER_NR"); |
||
722 | bool renumberedOk=renumberLayer(layerNumber, newLayerNumber); |
||
723 | Q_ASSERT(renumberedOk); |
||
724 | layerNumber=newLayerNumber; |
||
725 | //Layer is at the top now, lower it until it reaches the old level |
||
2937 | cbradney | 726 | int level = ss->getInt("LEVEL"); |
2944 | cbradney | 727 | while (layerLevelFromNumber(layerNumber)!=level) |
728 | lowerLayer(layerNumber); |
||
2937 | cbradney | 729 | } |
730 | else |
||
2944 | cbradney | 731 | deleteLayer(ss->getInt("LAYER_NR"), ss->getBool("DELETE")); |
732 | layersUndo=true; |
||
2937 | cbradney | 733 | } |
734 | else if (ss->contains("CHANGE_NAME")) |
||
735 | { |
||
736 | QString name = ss->get("OLD_NAME"); |
||
737 | if (!isUndo) |
||
738 | name = ss->get("NEW_NAME"); |
||
2938 | cbradney | 739 | changeLayerName(ss->getInt("ACTIVE"), name); |
2941 | cbradney | 740 | layersUndo=true; |
741 | } |
||
3004 | cbradney | 742 | else if (ss->contains("OLD_MASTERPAGE")) |
743 | restoreMasterPageApplying(ss, isUndo); |
||
3201 | subik | 744 | |
2941 | cbradney | 745 | if (layersUndo) |
746 | { |
||
2952 | cbradney | 747 | if (ScQApp->usingGUI()) |
748 | { |
||
4026 | craig | 749 | ScMW->changeLayer(ss->getInt("ACTIVE")); |
750 | ScMW->layerPalette->rebuildList(); |
||
2952 | cbradney | 751 | } |
2937 | cbradney | 752 | } |
1179 | tsoots | 753 | } |
754 | } |
||
755 | |||
756 | void ScribusDoc::setName(const QString& name) |
||
757 | { |
||
758 | DocName = name; |
||
759 | QString uname = name; |
||
760 | if (name.find("/") > -1) |
||
761 | uname = name.right(name.length() - name.findRev("/") - 1); |
||
1190 | tsoots | 762 | if (uname.find(".sl") > -1) |
763 | uname = uname.left(uname.findRev(".sl")); |
||
1179 | tsoots | 764 | setUName(uname); // set the name for the undo object |
765 | } |
||
766 | |||
2891 | cbradney | 767 | void ScribusDoc::setModified(const bool isModified) |
3 | paul | 768 | { |
2891 | cbradney | 769 | modified = isModified; |
3 | paul | 770 | } |
771 | |||
772 | bool ScribusDoc::isModified() const |
||
773 | { |
||
774 | return modified; |
||
775 | } |
||
776 | /** Setzt die Seitenattribute */ |
||
2894 | fschmid | 777 | 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 | 778 | { |
2142 | cbradney | 779 | pageWidth = b; |
780 | pageHeight = h; |
||
781 | pageMargins.Top = t; |
||
782 | pageMargins.Left = l; |
||
783 | pageMargins.Right = r; |
||
784 | pageMargins.Bottom = bo; |
||
3 | paul | 785 | PageSp = sp; |
786 | PageSpa = ab; |
||
3032 | fschmid | 787 | currentPageLayout = fp; |
3648 | cbradney | 788 | automaticTextFrames = atf; |
4546 | subik | 789 | |
3695 | cbradney | 790 | //CB Moved from scribus.cpp. Overrides the defaults... |
791 | PDF_Options.BleedTop = pageMargins.Top; |
||
792 | PDF_Options.BleedLeft = pageMargins.Left; |
||
793 | PDF_Options.BleedRight = pageMargins.Right; |
||
794 | PDF_Options.BleedBottom = pageMargins.Bottom; |
||
3 | paul | 795 | } |
796 | |||
2894 | fschmid | 797 | void ScribusDoc::resetPage(double t, double l, double r, double bo, int fp) |
3 | paul | 798 | { |
2142 | cbradney | 799 | pageMargins.Top = t; |
800 | pageMargins.Left = l; |
||
801 | pageMargins.Right = r; |
||
802 | pageMargins.Bottom = bo; |
||
3032 | fschmid | 803 | currentPageLayout = fp; |
3 | paul | 804 | } |
805 | |||
3544 | avox | 806 | bool ScribusDoc::AddFont(QString name, int fsize) |
3 | paul | 807 | { |
220 | Franz | 808 | bool ret = false; |
809 | bool error; |
||
3 | paul | 810 | FT_Face face; |
2295 | cbradney | 811 | |
3201 | subik | 812 | if (UsedFonts.contains(name)) |
813 | return true; |
||
2295 | cbradney | 814 | |
3572 | avox | 815 | if (! ((*AllFonts)[name]) ) |
816 | return ret; |
||
817 | |||
3544 | avox | 818 | error = FT_New_Face( library, (*AllFonts)[name]->fontFilePath(), (*AllFonts)[name]->faceIndex(), &face ); |
220 | Franz | 819 | if (error) |
820 | return ret; |
||
2295 | cbradney | 821 | |
220 | Franz | 822 | if ((*AllFonts)[name]->ReadMetrics()) |
167 | Franz | 823 | { |
220 | Franz | 824 | (*AllFonts)[name]->CharWidth[13] = 0; |
249 | Franz | 825 | (*AllFonts)[name]->CharWidth[28] = 0; |
2384 | fschmid | 826 | (*AllFonts)[name]->CharWidth[26] = 0; |
220 | Franz | 827 | (*AllFonts)[name]->CharWidth[9] = 1; |
3500 | avox | 828 | QString afnm = (*AllFonts)[name]->fontFilePath().left((*AllFonts)[name]->fontFilePath().length()-3); |
220 | Franz | 829 | QFile afm(afnm+"afm"); |
3 | paul | 830 | if(!(afm.exists())) |
220 | Franz | 831 | { |
832 | afm.setName(afnm+"Afm"); |
||
833 | if(!(afm.exists())) |
||
834 | afm.setName(afnm+"AFM"); |
||
835 | } |
||
836 | if (afm.exists()) |
||
837 | FT_Attach_File(face, afm.name()); |
||
838 | FFonts[name] = face; |
||
3544 | avox | 839 | UsedFonts[name] = fsize; |
220 | Franz | 840 | ret = true; |
167 | Franz | 841 | } |
220 | Franz | 842 | else |
843 | FT_Done_Face( face ); |
||
844 | return ret; |
||
3 | paul | 845 | } |
1694 | cbradney | 846 | |
847 | QStringList ScribusDoc::getItemAttributeNames() |
||
848 | { |
||
849 | QStringList nameList; |
||
3201 | subik | 850 | |
1694 | cbradney | 851 | for(ObjAttrVector::Iterator it = docItemAttributes.begin(); it!= docItemAttributes.end(); ++it) |
852 | nameList.append((*it).name); |
||
853 | return nameList; |
||
1749 | craig | 854 | } |
855 | |||
2891 | cbradney | 856 | void ScribusDoc::addSymbols() |
857 | { |
||
858 | symReturn.resize(0); |
||
859 | symReturn.addQuadPoint(1.98438, 9.14062, 1.98438, 9.14062, 1.98438, 4.03125, 1.98438, 4.03125); |
||
860 | symReturn.addQuadPoint(1.98438, 4.03125, 1.98438, 4.03125, 0.546875, 3.45312, 1.09375, 4); |
||
861 | symReturn.addQuadPoint(0.546875, 3.45312, 0.546875, 3.45312, 0, 2.0625, 0, 2.92188); |
||
862 | symReturn.addQuadPoint(0, 2.0625, 0, 2.0625, 0.65625, 0.5, 0, 1.04688); |
||
863 | symReturn.addQuadPoint(0.65625, 0.5, 0.65625, 0.5, 2.3125, 0, 1.28125, 0); |
||
864 | symReturn.addQuadPoint(2.3125, 0, 2.3125, 0, 5.40625, 0, 5.40625, 0); |
||
865 | symReturn.addQuadPoint(5.40625, 0, 5.40625, 0, 5.40625, 0.84375, 5.40625, 0.84375); |
||
866 | symReturn.addQuadPoint(5.40625, 0.84375, 5.40625, 0.84375, 4.70312, 0.84375, 4.70312, 0.84375); |
||
867 | symReturn.addQuadPoint(4.70312, 0.84375, 4.70312, 0.84375, 4.70312, 9.14062, 4.70312, 9.14062); |
||
868 | symReturn.addQuadPoint(4.70312, 9.14062, 4.70312, 9.14062, 3.875, 9.14062, 3.875, 9.14062); |
||
869 | symReturn.addQuadPoint(3.875, 9.14062, 3.875, 9.14062, 3.875, 0.84375, 3.875, 0.84375); |
||
870 | symReturn.addQuadPoint(3.875, 0.84375, 3.875, 0.84375, 2.78125, 0.84375, 2.78125, 0.84375); |
||
871 | symReturn.addQuadPoint(2.78125, 0.84375, 2.78125, 0.84375, 2.78125, 9.14062, 2.78125, 9.14062); |
||
872 | symReturn.addQuadPoint(2.78125, 9.14062, 2.78125, 9.14062, 1.98438, 9.14062, 1.98438, 9.14062); |
||
873 | symNewLine.resize(0); |
||
874 | symNewLine.addQuadPoint(6.51562, 2.625, 6.51562, 2.625, 0.90625, 2.64062, 0.90625, 2.64062); |
||
875 | symNewLine.addQuadPoint(0.90625, 2.64062, 0.90625, 2.64062, 1.4375, 1.92188, 1.26562, 2.1875); |
||
876 | symNewLine.addQuadPoint(1.4375, 1.92188, 1.4375, 1.92188, 1.76562, 1.14062, 1.75, 1.42188); |
||
877 | symNewLine.addQuadPoint(1.76562, 1.14062, 1.76562, 1.14062, 1.60938, 1.03125, 1.60938, 1.03125); |
||
878 | symNewLine.addQuadPoint(1.60938, 1.03125, 1.60938, 1.03125, 0.90625, 1.92188, 0.90625, 1.92188); |
||
879 | symNewLine.addQuadPoint(0.90625, 1.92188, 0.90625, 1.92188, 0, 2.90625, 0.578125, 2.23438); |
||
880 | symNewLine.addQuadPoint(0, 2.90625, 0, 2.90625, 0.75, 3.875, 0.75, 3.875); |
||
881 | symNewLine.addQuadPoint(0.75, 3.875, 0.75, 3.875, 1.57812, 4.78125, 1.1875, 4.40625); |
||
882 | symNewLine.addQuadPoint(1.57812, 4.78125, 1.57812, 4.78125, 1.65625, 4.79688, 1.65625, 4.79688); |
||
883 | symNewLine.addQuadPoint(1.65625, 4.79688, 1.65625, 4.79688, 1.76562, 4.65625, 1.76562, 4.65625); |
||
884 | symNewLine.addQuadPoint(1.76562, 4.65625, 1.76562, 4.65625, 0.90625, 3.17188, 1.73438, 4.34375); |
||
885 | symNewLine.addQuadPoint(0.90625, 3.17188, 0.90625, 3.17188, 0.96875, 3.125, 0.96875, 3.125); |
||
886 | symNewLine.addQuadPoint(0.96875, 3.125, 0.96875, 3.125, 6.75, 3.125, 6.75, 3.125); |
||
887 | symNewLine.addQuadPoint(6.75, 3.125, 6.75, 3.125, 6.51562, 2.625, 6.51562, 2.625); |
||
888 | symNewLine.addQuadPoint(6.51562, 2.625, 6.51562, 2.625, 6.51562, 2.625, 6.51562, 2.625); |
||
889 | symNewLine.addQuadPoint(999999, 999999, 999999, 999999, 999999, 999999, 999999, 999999); |
||
890 | symNewLine.addQuadPoint(6.875, 0, 6.875, 0, 6.51562, 0, 6.51562, 0); |
||
891 | symNewLine.addQuadPoint(6.51562, 0, 6.51562, 0, 6.51562, 2.84375, 6.51562, 2.84375); |
||
892 | symNewLine.addQuadPoint(6.51562, 2.84375, 6.51562, 2.84375, 6.75, 3.125, 6.51562, 3.125); |
||
893 | symNewLine.addQuadPoint(6.75, 3.125, 6.75, 3.125, 6.85938, 3.0625, 6.85938, 3.0625); |
||
894 | symNewLine.addQuadPoint(6.85938, 3.0625, 6.85938, 3.0625, 6.875, 0, 6.875, 0); |
||
895 | symTab.resize(0); |
||
896 | symTab.addQuadPoint(4.82812, 3.96875, 4.82812, 3.96875, 4.5625, 3.73438, 4.5625, 3.96875); |
||
897 | symTab.addQuadPoint(4.5625, 3.73438, 4.5625, 3.73438, 5.07812, 3.10938, 4.5625, 3.57812); |
||
898 | symTab.addQuadPoint(5.07812, 3.10938, 5.07812, 3.10938, 0, 3.10938, 0, 3.10938); |
||
899 | symTab.addQuadPoint(0, 3.10938, 0, 3.10938, 0, 2.625, 0, 2.625); |
||
900 | symTab.addQuadPoint(0, 2.625, 0, 2.625, 5.53125, 2.625, 5.53125, 2.625); |
||
901 | symTab.addQuadPoint(5.53125, 2.625, 5.53125, 2.625, 6.3125, 1.8125, 6.3125, 1.8125); |
||
902 | symTab.addQuadPoint(6.3125, 1.8125, 6.3125, 1.8125, 5.64062, 1.29688, 5.64062, 1.29688); |
||
903 | symTab.addQuadPoint(5.64062, 1.29688, 5.64062, 1.29688, 0, 1.29688, 0, 1.29688); |
||
904 | symTab.addQuadPoint(0, 1.29688, 0, 1.29688, 0, 0.8125, 0, 0.8125); |
||
905 | symTab.addQuadPoint(0, 0.8125, 0, 0.8125, 5.01562, 0.8125, 5.01562, 0.8125); |
||
906 | symTab.addQuadPoint(5.01562, 0.8125, 5.01562, 0.8125, 4.45312, 0.265625, 4.45312, 0.453125); |
||
907 | symTab.addQuadPoint(4.45312, 0.265625, 4.45312, 0.265625, 4.6875, 0, 4.45312, 0); |
||
908 | symTab.addQuadPoint(4.6875, 0, 4.6875, 0, 5.90625, 0.828125, 4.875, 0); |
||
909 | symTab.addQuadPoint(5.90625, 0.828125, 5.90625, 0.828125, 6.9375, 1.79688, 6.9375, 1.64062); |
||
910 | symTab.addQuadPoint(6.9375, 1.79688, 6.9375, 1.79688, 5.95312, 2.96875, 6.9375, 1.95312); |
||
911 | symTab.addQuadPoint(5.95312, 2.96875, 5.95312, 2.96875, 4.82812, 3.96875, 4.98438, 3.96875); |
||
912 | symNonBreak.resize(0); |
||
913 | symNonBreak.addQuadPoint(1.32812, 2.59375, 1.32812, 2.59375, 0.390625, 2.21875, 0.796875, 2.59375); |
||
914 | symNonBreak.addQuadPoint(0.390625, 2.21875, 0.390625, 2.21875, 0, 1.3125, 0, 1.84375); |
||
915 | symNonBreak.addQuadPoint(0, 1.3125, 0, 1.3125, 0.390625, 0.390625, 0, 0.765625); |
||
916 | symNonBreak.addQuadPoint(0.390625, 0.390625, 0.390625, 0.390625, 1.32812, 0, 0.796875, 0); |
||
917 | symNonBreak.addQuadPoint(1.32812, 0, 1.32812, 0, 2.23438, 0.390625, 1.85938, 0); |
||
918 | symNonBreak.addQuadPoint(2.23438, 0.390625, 2.23438, 0.390625, 2.60938, 1.29688, 2.60938, 0.765625); |
||
919 | symNonBreak.addQuadPoint(2.60938, 1.29688, 2.60938, 1.29688, 2.23438, 2.21875, 2.60938, 1.84375); |
||
920 | symNonBreak.addQuadPoint(2.23438, 2.21875, 2.23438, 2.21875, 1.32812, 2.59375, 1.875, 2.59375); |
||
921 | symNewCol.resize(0); |
||
922 | symNewCol.addQuadPoint(1.73438, 0, 1.73438, 0, 2.67188, 0.109375, 2.03125, 0); |
||
923 | symNewCol.addQuadPoint(2.67188, 0.109375, 2.67188, 0.109375, 3.59375, 0.203125, 3.26562, 0.21875); |
||
924 | symNewCol.addQuadPoint(3.59375, 0.203125, 3.59375, 0.203125, 3.79688, 0.1875, 3.64062, 0.203125); |
||
925 | symNewCol.addQuadPoint(3.79688, 0.1875, 3.79688, 0.1875, 4, 0.171875, 3.92188, 0.171875); |
||
926 | symNewCol.addQuadPoint(4, 0.171875, 4, 0.171875, 4.20312, 0.1875, 4.20312, 0.1875); |
||
927 | symNewCol.addQuadPoint(4.20312, 0.1875, 4.20312, 0.1875, 4.3125, 1.39062, 4.20312, 0.5625); |
||
928 | symNewCol.addQuadPoint(4.3125, 1.39062, 4.3125, 1.39062, 4.42188, 2.64062, 4.42188, 2.21875); |
||
929 | symNewCol.addQuadPoint(4.42188, 2.64062, 4.42188, 2.64062, 4.28125, 2.73438, 4.28125, 2.73438); |
||
930 | symNewCol.addQuadPoint(4.28125, 2.73438, 4.28125, 2.73438, 3.75, 1.03125, 4.01562, 2.64062); |
||
931 | symNewCol.addQuadPoint(3.75, 1.03125, 3.75, 1.03125, 3.67188, 1.03125, 3.67188, 1.03125); |
||
932 | symNewCol.addQuadPoint(3.67188, 1.03125, 3.67188, 1.03125, 0.28125, 6.20312, 0.28125, 6.20312); |
||
933 | symNewCol.addQuadPoint(0.28125, 6.20312, 0.28125, 6.20312, 0, 5.95312, 0.03125, 6.17188); |
||
934 | symNewCol.addQuadPoint(0, 5.95312, 0, 5.95312, 3.35938, 0.71875, 3.35938, 0.71875); |
||
935 | symNewCol.addQuadPoint(3.35938, 0.71875, 3.35938, 0.71875, 3.375, 0.640625, 3.375, 0.640625); |
||
936 | symNewCol.addQuadPoint(3.375, 0.640625, 3.375, 0.640625, 2.4375, 0.484375, 2.79688, 0.5625); |
||
937 | symNewCol.addQuadPoint(2.4375, 0.484375, 2.4375, 0.484375, 1.67188, 0.140625, 1.71875, 0.328125); |
||
938 | symNewCol.addQuadPoint(1.67188, 0.140625, 1.67188, 0.140625, 1.73438, 0, 1.73438, 0); |
||
939 | symNewFrame.resize(0); |
||
940 | symNewFrame.addQuadPoint(1.75, 6.20312, 1.75, 6.20312, 2.67188, 6.09375, 2.0625, 6.20312); |
||
941 | symNewFrame.addQuadPoint(2.67188, 6.09375, 2.67188, 6.09375, 3.60938, 5.98438, 3.28125, 5.98438); |
||
942 | symNewFrame.addQuadPoint(3.60938, 5.98438, 3.60938, 5.98438, 3.84375, 6.01562, 3.6875, 5.98438); |
||
943 | symNewFrame.addQuadPoint(3.84375, 6.01562, 3.84375, 6.01562, 4.07812, 6.03125, 4, 6.03125); |
||
944 | symNewFrame.addQuadPoint(4.07812, 6.03125, 4.07812, 6.03125, 4.20312, 6.01562, 4.20312, 6.01562); |
||
945 | symNewFrame.addQuadPoint(4.20312, 6.01562, 4.20312, 6.01562, 4.32812, 4.79688, 4.21875, 5.625); |
||
946 | symNewFrame.addQuadPoint( 4.32812, 4.79688, 4.32812, 4.79688, 4.42188, 3.5625, 4.42188, 3.98438); |
||
947 | symNewFrame.addQuadPoint(4.42188, 3.5625, 4.42188, 3.5625, 4.29688, 3.45312, 4.29688, 3.45312); |
||
948 | symNewFrame.addQuadPoint(4.29688, 3.45312, 4.29688, 3.45312, 3.75, 5.17188, 4.03125, 3.54688); |
||
949 | symNewFrame.addQuadPoint(3.75, 5.17188, 3.75, 5.17188, 3.67188, 5.17188, 3.67188, 5.17188); |
||
950 | symNewFrame.addQuadPoint(3.67188, 5.17188, 3.67188, 5.17188, 0.28125, 0, 0.28125, 0); |
||
951 | symNewFrame.addQuadPoint(0.28125, 0, 0.28125, 0, 0, 0.25, 0.03125, 0.015625); |
||
952 | symNewFrame.addQuadPoint(0, 0.25, 0, 0.25, 3.375, 5.46875, 3.375, 5.46875); |
||
953 | symNewFrame.addQuadPoint(3.375, 5.46875, 3.375, 5.46875, 3.39062, 5.54688, 3.39062, 5.54688); |
||
954 | symNewFrame.addQuadPoint(3.39062, 5.54688, 3.39062, 5.54688, 2.4375, 5.70312, 2.8125, 5.625); |
||
955 | symNewFrame.addQuadPoint(2.4375, 5.70312, 2.4375, 5.70312, 1.67188, 6.0625, 1.71875, 5.875); |
||
956 | symNewFrame.addQuadPoint(1.67188, 6.0625, 1.67188, 6.0625, 1.75, 6.20312, 1.75, 6.20312); |
||
957 | } |
||
2893 | cbradney | 958 | |
3852 | cbradney | 959 | Page* ScribusDoc::addPage(const int pageIndex, const QString& masterPageName, const bool addAutoFrame) |
2893 | cbradney | 960 | { |
3787 | cbradney | 961 | Q_ASSERT(masterPageMode()==false); |
4069 | craig | 962 | Page* addedPage = new Page(ScratchLeft, DocPages.count()*(pageHeight+ScratchBottom+ScratchTop)+ScratchTop, pageWidth, pageHeight); |
2893 | cbradney | 963 | Q_ASSERT(addedPage!=NULL); |
4738 | cbradney | 964 | addedPage->setDocument(this); |
2893 | cbradney | 965 | addedPage->Margins.Top = pageMargins.Top; |
966 | addedPage->Margins.Bottom = pageMargins.Bottom; |
||
967 | addedPage->initialMargins.Top = pageMargins.Top; |
||
968 | addedPage->initialMargins.Bottom = pageMargins.Bottom; |
||
969 | addedPage->initialMargins.Left = pageMargins.Left; |
||
970 | addedPage->initialMargins.Right = pageMargins.Right; |
||
3852 | cbradney | 971 | addedPage->setPageNr(pageIndex); |
2893 | cbradney | 972 | addedPage->PageSize = PageSize; |
973 | addedPage->PageOri = PageOri; |
||
3852 | cbradney | 974 | bool insertsuccess=DocPages.insert(pageIndex, addedPage); |
975 | Q_ASSERT(insertsuccess==true && DocPages.at(pageIndex)!=NULL); |
||
5087 | subik | 976 | setCurrentPage(addedPage); |
3787 | cbradney | 977 | //if (!masterPageMode()) |
3985 | cbradney | 978 | if (!masterPageName.isEmpty()) |
3911 | cbradney | 979 | applyMasterPage(masterPageName, pageIndex); |
3852 | cbradney | 980 | setLocationBasedPageLRMargins(pageIndex); |
981 | if (addAutoFrame && automaticTextFrames) |
||
982 | addAutomaticTextFrame(pageIndex); |
||
2893 | cbradney | 983 | return addedPage; |
984 | } |
||
2895 | cbradney | 985 | |
3695 | cbradney | 986 | Page* ScribusDoc::addMasterPage(const int pageNumber, const QString& pageName) |
987 | { |
||
988 | //CB We dont create master pages (yet) with a pageCount based location |
||
4069 | craig | 989 | //Page* addedPage = new Page(ScratchLeft, MasterPages.count()*(pageHeight+ScratchBottom+ScratchTop)+ScratchTop, pageWidth, pageHeight); |
3695 | cbradney | 990 | Page* addedPage = new Page(ScratchLeft, ScratchTop, pageWidth, pageHeight); |
991 | Q_ASSERT(addedPage!=NULL); |
||
4738 | cbradney | 992 | addedPage->setDocument(this); |
3695 | cbradney | 993 | addedPage->Margins.Top = pageMargins.Top; |
994 | addedPage->Margins.Bottom = pageMargins.Bottom; |
||
3912 | cbradney | 995 | addedPage->Margins.Left = pageMargins.Left;//todo fix for layouts |
3911 | cbradney | 996 | addedPage->Margins.Right = pageMargins.Right; |
3695 | cbradney | 997 | addedPage->initialMargins.Top = pageMargins.Top; |
998 | addedPage->initialMargins.Bottom = pageMargins.Bottom; |
||
999 | addedPage->initialMargins.Left = pageMargins.Left; |
||
1000 | addedPage->initialMargins.Right = pageMargins.Right; |
||
1001 | addedPage->PageSize = PageSize; |
||
1002 | addedPage->PageOri = PageOri; |
||
3787 | cbradney | 1003 | addedPage->MPageNam = ""; |
3695 | cbradney | 1004 | addedPage->setPageName(pageName); |
4715 | fschmid | 1005 | addedPage->setPageNr(pageNumber); |
3695 | cbradney | 1006 | MasterNames.insert(pageName, pageNumber); |
1007 | bool insertsuccess=MasterPages.insert(pageNumber, addedPage); |
||
1008 | Q_ASSERT(insertsuccess==true && MasterPages.at(pageNumber)!=NULL); |
||
1009 | return addedPage; |
||
1010 | } |
||
1011 | |||
4069 | craig | 1012 | void ScribusDoc::deleteMasterPage(const int pageNumber) |
2895 | cbradney | 1013 | { |
4166 | fschmid | 1014 | Q_ASSERT( Pages->count() > 1 && Pages->count() > static_cast<uint>(pageNumber) ); |
4069 | craig | 1015 | Page* page = Pages->at(pageNumber); |
4615 | cbradney | 1016 | QString oldPageName=page->PageNam; |
4069 | craig | 1017 | Pages->remove(pageNumber); |
1018 | delete page; |
||
1019 | // remove the master page from the master page name list |
||
4615 | cbradney | 1020 | //MasterNames.remove(page->PageNam); |
1021 | /*CB TODO moved back to muster.cpp for now as this must happen after reformPages |
||
1022 | MasterNames.clear(); |
||
1023 | for (uint a = 0; a < Pages->count(); ++a) |
||
1024 | MasterNames[Pages->at(a)->PageNam] = Pages->at(a)->pageNr(); |
||
4069 | craig | 1025 | // and fix up any pages that refer to the deleted master page |
1026 | for (Page* docPage = DocPages.first(); docPage; docPage = DocPages.next() ) |
||
2895 | cbradney | 1027 | { |
4615 | cbradney | 1028 | if (docPage->MPageNam == oldPageName) |
4069 | craig | 1029 | docPage->MPageNam = "Normal"; |
2895 | cbradney | 1030 | } |
4615 | cbradney | 1031 | */ |
4730 | subik | 1032 | //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. |
5087 | subik | 1033 | setCurrentPage(Pages->at(0)); |
4069 | craig | 1034 | } |
1035 | |||
1036 | void ScribusDoc::deletePage(const int pageNumber) |
||
1037 | { |
||
4166 | fschmid | 1038 | Q_ASSERT( Pages->count() > 1 && Pages->count() > static_cast<uint>(pageNumber) ); |
4069 | craig | 1039 | Page* page = Pages->at(pageNumber); |
3724 | cbradney | 1040 | Pages->remove(pageNumber); |
4069 | craig | 1041 | delete page; |
5087 | subik | 1042 | setCurrentPage(Pages->at(0)); |
2895 | cbradney | 1043 | } |
1044 | |||
1045 | void ScribusDoc::movePage(const int from, const int to, const int ziel, const int art) |
||
1046 | { |
||
1047 | QPtrList<Page> Buf; |
||
1048 | int zz = ziel; |
||
1049 | Buf.clear(); |
||
3778 | cbradney | 1050 | for (int a = from; a < to; ++a) |
2895 | cbradney | 1051 | { |
3724 | cbradney | 1052 | Buf.append(Pages->at(from)); |
1053 | Pages->remove(from); |
||
2895 | cbradney | 1054 | if (a <= zz) |
3778 | cbradney | 1055 | --zz; |
2895 | cbradney | 1056 | } |
3778 | cbradney | 1057 | uint bufCount=Buf.count(); |
2895 | cbradney | 1058 | switch (art) |
1059 | { |
||
1060 | case 0: |
||
3778 | cbradney | 1061 | for (uint b = 0; b < bufCount; ++b) |
3724 | cbradney | 1062 | Pages->insert(zz++, Buf.at(b)); |
2895 | cbradney | 1063 | break; |
1064 | case 1: |
||
3778 | cbradney | 1065 | for (uint b = 0; b < bufCount; ++b) |
3724 | cbradney | 1066 | Pages->insert(++zz, Buf.at(b)); |
2895 | cbradney | 1067 | break; |
1068 | case 2: |
||
3778 | cbradney | 1069 | for (uint b = 0; b < bufCount; ++b) |
3724 | cbradney | 1070 | Pages->append(Buf.at(b)); |
2895 | cbradney | 1071 | break; |
1072 | } |
||
5226 | cbradney | 1073 | changed(); |
2895 | cbradney | 1074 | } |
2937 | cbradney | 1075 | |
3985 | cbradney | 1076 | int ScribusDoc::addAutomaticTextFrame(const int pageNumber) |
3778 | cbradney | 1077 | { |
3852 | cbradney | 1078 | if (!automaticTextFrames) |
1079 | return -1; |
||
3778 | cbradney | 1080 | Page *addToPage=DocPages.at(pageNumber); |
3843 | cbradney | 1081 | if ((!masterPageMode()) && (usesAutomaticTextFrames()))// && (!isLoading())) |
3778 | cbradney | 1082 | { |
4546 | subik | 1083 | int z = itemAdd(PageItem::TextFrame, PageItem::Unspecified, |
3778 | cbradney | 1084 | addToPage->Margins.Left+addToPage->xOffset(), |
1085 | addToPage->Margins.Top+addToPage->yOffset(), pageWidth-addToPage->Margins.Right-addToPage->Margins.Left, |
||
1086 | pageHeight-addToPage->Margins.Bottom-addToPage->Margins.Top, |
||
4546 | subik | 1087 | 1, CommonStrings::None, toolSettings.dPen, true); |
3778 | cbradney | 1088 | Items->at(z)->isAutoText = true; |
1089 | Items->at(z)->BackBox = LastAuto; |
||
1090 | Items->at(z)->Cols = qRound(PageSp); |
||
1091 | Items->at(z)->ColGap = PageSpa; |
||
1092 | if (LastAuto != 0) |
||
1093 | LastAuto->NextBox = Items->at(z); |
||
1094 | else |
||
1095 | FirstAuto = Items->at(z); |
||
1096 | LastAuto = Items->at(z); |
||
1097 | Items->at(z)->setRedrawBounding(); |
||
3781 | cbradney | 1098 | return z; |
3778 | cbradney | 1099 | } |
3781 | cbradney | 1100 | return -1; |
3778 | cbradney | 1101 | } |
1102 | |||
4645 | subik | 1103 | int ScribusDoc::addLayer(const QString& layerName, const bool activate) |
2937 | cbradney | 1104 | { |
1105 | struct Layer ll; |
||
1106 | ll.LNr = Layers.last().LNr + 1; |
||
1107 | ll.Level = Layers.count(); |
||
1108 | if (layerName.isNull() || layerName.isEmpty()) |
||
1109 | { |
||
1110 | QString tmp; |
||
1111 | ll.Name = tr("New Layer")+" "+tmp.setNum(ll.LNr); |
||
1112 | } |
||
1113 | else |
||
1114 | ll.Name = layerName; |
||
1115 | ll.isViewable = true; |
||
1116 | ll.isPrintable = true; |
||
4832 | fschmid | 1117 | ll.isEditable = true; |
2937 | cbradney | 1118 | Layers.append(ll); |
1119 | if (activate) |
||
1120 | setActiveLayer(ll.LNr); |
||
3201 | subik | 1121 | |
2937 | cbradney | 1122 | if (UndoManager::undoEnabled()) |
1123 | { |
||
1124 | SimpleState *ss = new SimpleState(Um::AddLayer, "", Um::ICreate); |
||
1125 | ss->set("ADD_LAYER", "add_layer"); |
||
1126 | ss->set("ACTIVE", ActiveLayer); |
||
2944 | cbradney | 1127 | ss->set("NAME", ll.Name); |
2937 | cbradney | 1128 | ss->set("LAYER_NR", ll.LNr); |
1129 | undoManager->action(this, ss, DocName, Um::ILayer); |
||
1130 | } |
||
2944 | cbradney | 1131 | return ll.LNr; |
2937 | cbradney | 1132 | } |
1133 | |||
3985 | cbradney | 1134 | bool ScribusDoc::deleteLayer(const int layerNumber, const bool deleteItems) |
2937 | cbradney | 1135 | { |
1136 | if (Layers.count() < 2) |
||
1137 | return false; |
||
1138 | QValueList<Layer>::iterator it2; |
||
1139 | QValueList<Layer>::iterator it2end=Layers.end(); |
||
1140 | bool found=false; |
||
1141 | int layerLevel; |
||
1142 | for (it2 = Layers.begin(); it2 != it2end; ++it2) |
||
1143 | { |
||
1144 | if ((*it2).LNr == layerNumber) |
||
1145 | { |
||
1146 | layerLevel=(*it2).Level; |
||
1147 | found=true; |
||
1148 | break; |
||
1149 | } |
||
1150 | } |
||
1151 | if (!found) |
||
1152 | return false; |
||
2944 | cbradney | 1153 | if (UndoManager::undoEnabled()) |
1154 | undoManager->beginTransaction("Layer", Um::IDocument, Um::DeleteLayer, "", Um::IDelete); |
||
1155 | |||
2952 | cbradney | 1156 | if (ScQApp->usingGUI()) |
4713 | cbradney | 1157 | removeLayer(layerNumber, deleteItems); |
2937 | cbradney | 1158 | /* |
1159 | //Layer found, do we want to delete its items too? |
||
1160 | if (masterPageMode) |
||
1161 | MasterPages = Pages; |
||
1162 | else |
||
1163 | DocPages = Pages; |
||
1164 | for (uint b = 0; b < MasterItems.count(); ++b) |
||
1165 | { |
||
1166 | if (MasterItems.at(b)->LayerNr == layerNumber) |
||
1167 | { |
||
1168 | if (deleteItems) |
||
1169 | { |
||
1170 | MasterItems.at(b)->setTagged(true); |
||
1171 | DocItems.at(b)->setLocked(false); |
||
1172 | } |
||
1173 | else |
||
1174 | MasterItems.at(b)->setTagged(false); |
||
1175 | } |
||
1176 | } |
||
1177 | // if (view->SelItem.count() != 0) |
||
1178 | // view->DeleteItem(); |
||
1179 | // view->SelItem.clear(); |
||
1180 | for (uint b = 0; b < DocItems.count(); ++b) |
||
1181 | { |
||
1182 | if (DocItems.at(b)->LayerNr == l) |
||
1183 | { |
||
1184 | if (deleteItems) |
||
1185 | { |
||
1186 | DocItems.at(b)->setTagged(true); |
||
1187 | DocItems.at(b)->setLocked(false); |
||
1188 | } |
||
1189 | else |
||
1190 | DocItems.at(b)->setLayer(0); |
||
1191 | } |
||
1192 | } |
||
1193 | // if (view->SelItem.count() != 0) |
||
1194 | // view->DeleteItem(); |
||
1195 | |||
1196 | bool deletedOk=deleteTaggedItems(); |
||
1197 | Q_ASSERT(deletedOk); |
||
3201 | subik | 1198 | |
2937 | cbradney | 1199 | */ |
1200 | //Now delete the layer |
||
3201 | subik | 1201 | |
2937 | cbradney | 1202 | QString name = (*it2).Name; |
1203 | Layers.remove(it2); |
||
1204 | QValueList<Layer>::iterator it; |
||
1205 | QValueList<Layer>::iterator itend=Layers.end(); |
||
1206 | for (it = Layers.begin(); it != itend; ++it) |
||
1207 | { |
||
1208 | if ((*it).Level > layerLevel) |
||
1209 | (*it).Level -= 1; |
||
1210 | } |
||
1211 | if (UndoManager::undoEnabled()) |
||
1212 | { |
||
1213 | SimpleState *ss = new SimpleState(Um::DeleteLayer, "", Um::IDelete); |
||
1214 | ss->set("REMOVE_LAYER", "remove_layer"); |
||
1215 | ss->set("ACTIVE", layerNumber); |
||
1216 | ss->set("LEVEL", layerLevel); |
||
1217 | ss->set("NAME", name); |
||
1218 | ss->set("LAYER_NR", layerNumber); |
||
1219 | ss->set("DELETE", deleteItems); |
||
1220 | undoManager->action(this, ss, DocName, Um::ILayer); |
||
1221 | undoManager->commit(); |
||
1222 | } |
||
2944 | cbradney | 1223 | setActiveLayer(layerNumberFromLevel(0)); |
2947 | cbradney | 1224 | return true; |
2937 | cbradney | 1225 | } |
1226 | |||
3985 | cbradney | 1227 | int ScribusDoc::activeLayer() |
2937 | cbradney | 1228 | { |
1229 | return ActiveLayer; |
||
1230 | } |
||
1231 | |||
1232 | const QString& ScribusDoc::activeLayerName() |
||
1233 | { |
||
1234 | QValueList<Layer>::iterator itend=Layers.end(); |
||
1235 | QValueList<Layer>::iterator it; |
||
1236 | bool found=false; |
||
1237 | for (it = Layers.begin(); it != itend; ++it) |
||
1238 | { |
||
1239 | if ((*it).LNr == ActiveLayer) |
||
1240 | { |
||
1241 | found=true; |
||
1242 | break; |
||
1243 | } |
||
1244 | } |
||
1245 | Q_ASSERT(found); |
||
1246 | return (*it).Name; |
||
1247 | } |
||
1248 | |||
3985 | cbradney | 1249 | bool ScribusDoc::setActiveLayer(const int layerToActivate) |
2937 | cbradney | 1250 | { |
1251 | bool found=false; |
||
2948 | cbradney | 1252 | uint layerCount=Layers.count(); |
4546 | subik | 1253 | |
2937 | cbradney | 1254 | for (uint i=0; i < layerCount; ++i) |
1255 | { |
||
1256 | if (Layers[i].LNr == layerToActivate) |
||
1257 | { |
||
1258 | found = true; |
||
1259 | break; |
||
1260 | } |
||
1261 | } |
||
3855 | cbradney | 1262 | Q_ASSERT(found); |
2937 | cbradney | 1263 | if (found) |
1264 | ActiveLayer=layerToActivate; |
||
1265 | return found; |
||
1266 | } |
||
1267 | |||
3985 | cbradney | 1268 | bool ScribusDoc::setActiveLayer(const QString& layerNameToActivate) |
2937 | cbradney | 1269 | { |
1270 | bool found=false; |
||
2948 | cbradney | 1271 | uint layerCount=Layers.count(); |
2937 | cbradney | 1272 | uint i; |
1273 | for (i=0; i < layerCount; ++i) |
||
1274 | { |
||
1275 | if (Layers[i].Name == layerNameToActivate) |
||
1276 | { |
||
1277 | found = true; |
||
1278 | break; |
||
1279 | } |
||
1280 | } |
||
1281 | if (found) |
||
1282 | ActiveLayer=Layers[i].LNr; |
||
1283 | return found; |
||
1284 | } |
||
1285 | |||
3985 | cbradney | 1286 | bool ScribusDoc::setLayerPrintable(const int layerNumber, const bool isPrintable) |
2937 | cbradney | 1287 | { |
1288 | QValueList<Layer>::iterator itend=Layers.end(); |
||
1289 | QValueList<Layer>::iterator it; |
||
1290 | bool found=false; |
||
1291 | for (it = Layers.begin(); it != itend; ++it) |
||
1292 | { |
||
1293 | if ((*it).LNr == layerNumber) |
||
1294 | { |
||
1295 | bool oldPrintable = (*it).isPrintable; |
||
1296 | (*it).isPrintable = isPrintable; |
||
3201 | subik | 1297 | |
2937 | cbradney | 1298 | if (oldPrintable!=isPrintable && UndoManager::undoEnabled()) |
1299 | { |
||
1300 | SimpleState *ss = new SimpleState(isPrintable ? Um::PrintLayer : Um::DoNotPrintLayer, |
||
1301 | "", Um::IPrint); |
||
1302 | ss->set("PRINT_LAYER", "print_layer"); |
||
1303 | ss->set("ACTIVE", (*it).LNr); |
||
1304 | ss->set("PRINT", isPrintable); |
||
1305 | undoManager->action(this, ss, DocName, Um::IDocument); |
||
1306 | } |
||
1307 | found=true; |
||
1308 | break; |
||
1309 | } |
||
1310 | } |
||
1311 | return found; |
||
1312 | } |
||
1313 | |||
3985 | cbradney | 1314 | bool ScribusDoc::layerPrintable(const int layerNumber) |
2937 | cbradney | 1315 | { |
1316 | QValueList<Layer>::iterator itend=Layers.end(); |
||
1317 | QValueList<Layer>::iterator it; |
||
1318 | for (it = Layers.begin(); it != itend; ++it) |
||
1319 | { |
||
1320 | if ((*it).LNr == layerNumber) |
||
1321 | return (*it).isPrintable; |
||
1322 | } |
||
1323 | return false; |
||
1324 | } |
||
1325 | |||
3985 | cbradney | 1326 | bool ScribusDoc::setLayerVisible(const int layerNumber, const bool isViewable) |
2937 | cbradney | 1327 | { |
1328 | QValueList<Layer>::iterator itend=Layers.end(); |
||
1329 | QValueList<Layer>::iterator it; |
||
1330 | bool found=false; |
||
1331 | for (it = Layers.begin(); it != itend; ++it) |
||
1332 | { |
||
1333 | if ((*it).LNr == layerNumber) |
||
1334 | { |
||
1335 | (*it).isViewable = isViewable; |
||
1336 | found=true; |
||
1337 | break; |
||
1338 | } |
||
1339 | } |
||
1340 | return found; |
||
1341 | } |
||
1342 | |||
3985 | cbradney | 1343 | bool ScribusDoc::layerVisible(const int layerNumber) |
2937 | cbradney | 1344 | { |
1345 | QValueList<Layer>::iterator itend=Layers.end(); |
||
1346 | QValueList<Layer>::iterator it; |
||
1347 | for (it = Layers.begin(); it != itend; ++it) |
||
1348 | { |
||
1349 | if ((*it).LNr == layerNumber) |
||
1350 | return (*it).isViewable; |
||
1351 | } |
||
1352 | return false; |
||
1353 | } |
||
1354 | |||
4832 | fschmid | 1355 | bool ScribusDoc::setLayerLocked(const int layerNumber, const bool isLocked) |
1356 | { |
||
1357 | QValueList<Layer>::iterator itend=Layers.end(); |
||
1358 | QValueList<Layer>::iterator it; |
||
1359 | bool found=false; |
||
1360 | for (it = Layers.begin(); it != itend; ++it) |
||
1361 | { |
||
1362 | if ((*it).LNr == layerNumber) |
||
1363 | { |
||
1364 | (*it).isEditable = !isLocked; |
||
1365 | found=true; |
||
1366 | break; |
||
1367 | } |
||
1368 | } |
||
1369 | return found; |
||
1370 | } |
||
1371 | |||
1372 | bool ScribusDoc::layerLocked(const int layerNumber) |
||
1373 | { |
||
1374 | QValueList<Layer>::iterator itend=Layers.end(); |
||
1375 | QValueList<Layer>::iterator it; |
||
1376 | for (it = Layers.begin(); it != itend; ++it) |
||
1377 | { |
||
1378 | if ((*it).LNr == layerNumber) |
||
1379 | return !(*it).isEditable; |
||
1380 | } |
||
1381 | return false; |
||
1382 | } |
||
1383 | |||
3985 | cbradney | 1384 | int ScribusDoc::layerLevelFromNumber(const int layerNumber) |
2937 | cbradney | 1385 | { |
2948 | cbradney | 1386 | uint layerCount=Layers.count(); |
2937 | cbradney | 1387 | for (uint i=0; i < layerCount; ++i) |
1388 | { |
||
1389 | if (Layers[i].LNr == layerNumber) |
||
1390 | return Layers[i].Level; |
||
1391 | } |
||
1392 | return -1; |
||
1393 | } |
||
1394 | |||
3985 | cbradney | 1395 | int ScribusDoc::layerCount() const |
2937 | cbradney | 1396 | { |
1397 | return Layers.count(); |
||
1398 | } |
||
1399 | |||
3985 | cbradney | 1400 | int ScribusDoc::layerNumberFromLevel(const int layerLevel) |
2937 | cbradney | 1401 | { |
2948 | cbradney | 1402 | uint layerCount=Layers.count(); |
2937 | cbradney | 1403 | for (uint i=0; i < layerCount; ++i) |
1404 | { |
||
1405 | if (Layers[i].Level == layerLevel) |
||
1406 | return Layers[i].LNr; |
||
1407 | } |
||
1408 | return -1; |
||
1409 | } |
||
1410 | |||
3985 | cbradney | 1411 | bool ScribusDoc::lowerLayer(const int layerNumber) |
2937 | cbradney | 1412 | { |
2942 | mrdocs | 1413 | return lowerLayerByLevel(layerLevelFromNumber(layerNumber)); |
2941 | cbradney | 1414 | } |
1415 | |||
3985 | cbradney | 1416 | bool ScribusDoc::lowerLayerByLevel(const int layerLevel) |
2941 | cbradney | 1417 | { |
2937 | cbradney | 1418 | if (Layers.count() < 2) |
1419 | return false; |
||
1420 | if (UndoManager::undoEnabled()) |
||
1421 | { |
||
1422 | SimpleState *ss = new SimpleState(Um::LowerLayer, "", Um::IDown); |
||
1423 | ss->set("DOWN_LAYER", "down_layer"); |
||
2941 | cbradney | 1424 | ss->set("ACTIVE", layerLevel-1); |
2937 | cbradney | 1425 | undoManager->action(this, ss, DocName, Um::ILayer); |
1426 | } |
||
3201 | subik | 1427 | |
2937 | cbradney | 1428 | QValueList<Layer>::iterator it; |
1429 | QValueList<Layer>::iterator itend=Layers.end(); |
||
1430 | for (it = Layers.begin(); it != itend; ++it) |
||
1431 | { |
||
2941 | cbradney | 1432 | if ((*it).Level == layerLevel-1) |
2937 | cbradney | 1433 | break; |
1434 | } |
||
1435 | QValueList<Layer>::iterator it2; |
||
1436 | QValueList<Layer>::iterator it2end=Layers.end(); |
||
1437 | for (it2 = Layers.begin(); it2 != it2end; ++it2) |
||
1438 | { |
||
2941 | cbradney | 1439 | if ((*it2).Level == layerLevel) |
2937 | cbradney | 1440 | break; |
1441 | } |
||
1442 | (*it2).Level -= 1; |
||
1443 | (*it).Level += 1; |
||
1444 | return true; |
||
1445 | } |
||
1446 | |||
3985 | cbradney | 1447 | bool ScribusDoc::raiseLayer(const int layerNumber) |
2937 | cbradney | 1448 | { |
2942 | mrdocs | 1449 | return raiseLayerByLevel(layerLevelFromNumber(layerNumber)); |
2941 | cbradney | 1450 | } |
1451 | |||
3985 | cbradney | 1452 | bool ScribusDoc::raiseLayerByLevel(const int layerLevel) |
2941 | cbradney | 1453 | { |
2937 | cbradney | 1454 | if (Layers.count() < 2) |
1455 | return false; |
||
1456 | if (UndoManager::undoEnabled()) |
||
1457 | { |
||
1458 | SimpleState *ss = new SimpleState(Um::RaiseLayer, "", Um::IUp); |
||
1459 | ss->set("UP_LAYER", "up_layer"); |
||
2941 | cbradney | 1460 | ss->set("ACTIVE", layerLevel+1); |
2937 | cbradney | 1461 | undoManager->action(this, ss, DocName, Um::ILayer); |
1462 | } |
||
3201 | subik | 1463 | |
2937 | cbradney | 1464 | QValueList<Layer>::iterator it; |
1465 | QValueList<Layer>::iterator itend=Layers.end(); |
||
1466 | for (it = Layers.begin(); it != itend; ++it) |
||
1467 | { |
||
2941 | cbradney | 1468 | if ((*it).Level == layerLevel+1) |
2937 | cbradney | 1469 | break; |
1470 | } |
||
1471 | QValueList<Layer>::iterator it2; |
||
1472 | QValueList<Layer>::iterator it2end=Layers.end(); |
||
1473 | for (it2 = Layers.begin(); it2 != it2end; ++it2) |
||
1474 | { |
||
2941 | cbradney | 1475 | if ((*it2).Level == layerLevel) |
2937 | cbradney | 1476 | break; |
1477 | } |
||
1478 | (*it2).Level += 1; |
||
1479 | (*it).Level -= 1; |
||
1480 | return true; |
||
1481 | } |
||
1482 | |||
3985 | cbradney | 1483 | const QString& ScribusDoc::layerName(const int layerNumber) const |
2937 | cbradney | 1484 | { |
2948 | cbradney | 1485 | uint layerCount=Layers.count(); |
2937 | cbradney | 1486 | for (uint i=0; i < layerCount; ++i) |
1487 | { |
||
1488 | if (Layers[i].LNr == layerNumber) |
||
1489 | return Layers[i].Name; |
||
1490 | } |
||
1491 | return QString::null; |
||
1492 | } |
||
1493 | |||
3985 | cbradney | 1494 | bool ScribusDoc::changeLayerName(const int layerNumber, const QString& newName) |
2937 | cbradney | 1495 | { |
2948 | cbradney | 1496 | uint layerCount=Layers.count(); |
2947 | cbradney | 1497 | bool found=false; |
2937 | cbradney | 1498 | for (uint i=0; i < layerCount; ++i) |
1499 | { |
||
1500 | if (Layers[i].LNr == layerNumber) |
||
1501 | { |
||
1502 | if (UndoManager::undoEnabled()) |
||
1503 | { |
||
1504 | SimpleState *ss = new SimpleState(Um::SetLayerName, |
||
1505 | QString(Um::FromTo).arg(Layers[i].Name).arg(newName), |
||
1506 | Um::IDown); |
||
1507 | ss->set("CHANGE_NAME", "change_name"); |
||
2938 | cbradney | 1508 | ss->set("ACTIVE", ActiveLayer); |
2937 | cbradney | 1509 | ss->set("NEW_NAME", newName); |
1510 | ss->set("OLD_NAME", Layers[i].Name); |
||
1511 | undoManager->action(this, ss, DocName, Um::ILayer); |
||
1512 | } |
||
1513 | Layers[i].Name = newName; |
||
2947 | cbradney | 1514 | found=true; |
1515 | break; |
||
2937 | cbradney | 1516 | } |
1517 | } |
||
2947 | cbradney | 1518 | return found; |
2937 | cbradney | 1519 | } |
1520 | |||
3985 | cbradney | 1521 | bool ScribusDoc::layerContainsItems(const int layerNumber) |
2937 | cbradney | 1522 | { |
2948 | cbradney | 1523 | uint masterItemsCount=MasterItems.count(); |
2937 | cbradney | 1524 | for (uint i = 0; i < masterItemsCount; ++i) |
1525 | { |
||
1526 | if (MasterItems.at(i)->LayerNr == layerNumber) |
||
1527 | return true; |
||
1528 | } |
||
2948 | cbradney | 1529 | uint docItemsCount=DocItems.count(); |
2937 | cbradney | 1530 | for (uint i = 0; i < docItemsCount; ++i) |
1531 | { |
||
1532 | if (DocItems.at(i)->LayerNr == layerNumber) |
||
1533 | return true; |
||
1534 | } |
||
1535 | return false; |
||
1536 | } |
||
1537 | |||
1538 | void ScribusDoc::orderedLayerList(QStringList* list) |
||
1539 | { |
||
1540 | Q_ASSERT(list!=NULL); |
||
2948 | cbradney | 1541 | uint layerCount=Layers.count(); |
1542 | if (layerCount != 0) |
||
2937 | cbradney | 1543 | { |
2948 | cbradney | 1544 | for (uint i=0; i < layerCount; ++i) |
2937 | cbradney | 1545 | { |
2948 | cbradney | 1546 | QValueList<Layer>::iterator itend=Layers.end(); |
1547 | for (QValueList<Layer>::iterator it = Layers.begin(); it != itend; ++it) |
||
2937 | cbradney | 1548 | { |
2948 | cbradney | 1549 | if (layerCount-(*it).Level-1 == i) |
2937 | cbradney | 1550 | list->append((*it).Name); |
1551 | } |
||
1552 | } |
||
1553 | } |
||
1554 | } |
||
1555 | |||
3985 | cbradney | 1556 | bool ScribusDoc::renumberLayer(const int layerNumber, const int newLayerNumber) |
2944 | cbradney | 1557 | { |
2948 | cbradney | 1558 | uint layerCount=Layers.count(); |
1559 | uint foundIndex; |
||
1560 | bool found=false; |
||
2944 | cbradney | 1561 | //Find layer to renumber, if found the new number, return as it exists already. |
1562 | for (uint i=0; i < layerCount; ++i) |
||
1563 | { |
||
1564 | if (Layers[i].LNr == layerNumber) |
||
2948 | cbradney | 1565 | { |
2944 | cbradney | 1566 | foundIndex=i; |
2948 | cbradney | 1567 | found=true; |
1568 | } |
||
2944 | cbradney | 1569 | else |
1570 | if (Layers[i].LNr == newLayerNumber) |
||
1571 | return false; |
||
1572 | } |
||
2948 | cbradney | 1573 | if (!found) |
2944 | cbradney | 1574 | return false; |
1575 | Layers[foundIndex].LNr=newLayerNumber; |
||
1576 | return true; |
||
1577 | } |
||
1578 | |||
2937 | cbradney | 1579 | //Make the doc delete the items, not the view. TODO: Currently does nada, zilch, zero |
3985 | cbradney | 1580 | bool ScribusDoc::deleteTaggedItems() |
2937 | cbradney | 1581 | { |
1582 | QString tooltip = Um::ItemsInvolved + "\n"; |
||
1583 | //Master Items |
||
1584 | for (uint b = 0; b < MasterItems.count(); ++b) |
||
1585 | { |
||
1586 | if (MasterItems.at(b)->isTagged()) |
||
1587 | { |
||
1588 | } |
||
1589 | } |
||
1590 | //Doc Items |
||
1591 | for (uint b = 0; b < DocItems.count(); ++b) |
||
1592 | { |
||
1593 | if (DocItems.at(b)->isTagged()) |
||
1594 | { |
||
1595 | } |
||
1596 | } |
||
1597 | return true; |
||
2944 | cbradney | 1598 | } |
1599 | |||
3068 | fschmid | 1600 | void ScribusDoc::getUsedColors(ColorList &colorsToUse, bool spot) |
3057 | fschmid | 1601 | { |
1602 | PageItem* ite; |
||
1603 | bool found; |
||
1604 | colorsToUse.clear(); |
||
1605 | ColorList::Iterator it; |
||
1606 | for (it = PageColors.begin(); it != PageColors.end(); ++it) |
||
1607 | { |
||
1608 | found = false; |
||
1609 | if ((it.key() == toolSettings.dBrush) || (it.key() == toolSettings.dPen) || (it.key() == toolSettings.dBrushPict) |
||
1610 | || (it.key() == toolSettings.dPenLine) || (it.key() == toolSettings.dPenText)) |
||
1611 | { |
||
3068 | fschmid | 1612 | if (spot) |
1613 | { |
||
1614 | if (it.data().isSpotColor()) |
||
1615 | colorsToUse.insert(it.key(), it.data()); |
||
1616 | } |
||
1617 | else |
||
1618 | colorsToUse.insert(it.key(), it.data()); |
||
3057 | fschmid | 1619 | continue; |
1620 | } |
||
1621 | for (uint c = 0; c < MasterItems.count(); ++c) |
||
1622 | { |
||
1623 | ite = MasterItems.at(c); |
||
1624 | QPtrVector<VColorStop> cstops = ite->fill_gradient.colorStops(); |
||
1625 | for (uint cst = 0; cst < ite->fill_gradient.Stops(); ++cst) |
||
1626 | { |
||
1627 | if (it.key() == cstops.at(cst)->name) |
||
1628 | found = true; |
||
1629 | if (found) |
||
1630 | break; |
||
1631 | } |
||
1632 | if ((ite->itemType() == PageItem::TextFrame) || (ite->itemType() == PageItem::PathText)) |
||
1633 | { |
||
4749 | avox | 1634 | for (int d=0; d<ite->itemText.length(); ++d) |
3057 | fschmid | 1635 | { |
4749 | avox | 1636 | if (it.key() == ite->itemText.charStyle(d).ccolor) |
3057 | fschmid | 1637 | found = true; |
4749 | avox | 1638 | if (it.key() == ite->itemText.charStyle(d).cstroke) |
3057 | fschmid | 1639 | found = true; |
1640 | if (found) |
||
1641 | break; |
||
1642 | } |
||
1643 | } |
||
1644 | /* PFJ - 29.02.04 - merged if's to one line */ |
||
1645 | if ((it.key() == ite->fillColor()) || (it.key() == ite->lineColor())) |
||
1646 | found = true; |
||
1647 | if (found) |
||
1648 | break; |
||
1649 | } |
||
1650 | if (found) |
||
1651 | { |
||
3068 | fschmid | 1652 | if (spot) |
1653 | { |
||
1654 | if (it.data().isSpotColor()) |
||
1655 | colorsToUse.insert(it.key(), it.data()); |
||
1656 | } |
||
1657 | else |
||
1658 | colorsToUse.insert(it.key(), it.data()); |
||
3057 | fschmid | 1659 | continue; |
1660 | } |
||
1661 | for (uint c = 0; c < DocItems.count(); ++c) |
||
1662 | { |
||
1663 | ite = DocItems.at(c); |
||
1664 | QPtrVector<VColorStop> cstops = ite->fill_gradient.colorStops(); |
||
1665 | for (uint cst = 0; cst < ite->fill_gradient.Stops(); ++cst) |
||
1666 | { |
||
1667 | if (it.key() == cstops.at(cst)->name) |
||
1668 | found = true; |
||
1669 | if (found) |
||
1670 | break; |
||
1671 | } |
||
1672 | if ((ite->itemType() == PageItem::TextFrame) || (ite->itemType() == PageItem::PathText)) |
||
1673 | { |
||
4749 | avox | 1674 | for (int d=0; d<ite->itemText.length(); ++d) |
3057 | fschmid | 1675 | { |
1676 | /* PFJ - 29.02.04 - Merged if's */ |
||
4749 | avox | 1677 | if ((it.key() == ite->itemText.charStyle(d).ccolor) || (it.key() == ite->itemText.charStyle(d).cstroke)) |
3057 | fschmid | 1678 | found = true; |
1679 | if (found) |
||
1680 | break; |
||
1681 | } |
||
1682 | } |
||
1683 | /* PFJ - 29.02.04 - Merged if's */ |
||
1684 | if ((it.key() == ite->fillColor()) || (it.key() == ite->lineColor())) |
||
1685 | found = true; |
||
1686 | if (found) |
||
1687 | break; |
||
1688 | } |
||
1689 | if (found) |
||
1690 | { |
||
3068 | fschmid | 1691 | if (spot) |
1692 | { |
||
1693 | if (it.data().isSpotColor()) |
||
1694 | colorsToUse.insert(it.key(), it.data()); |
||
1695 | } |
||
1696 | else |
||
1697 | colorsToUse.insert(it.key(), it.data()); |
||
3057 | fschmid | 1698 | continue; |
1699 | } |
||
1700 | for (uint c = 0; c < FrameItems.count(); ++c) |
||
1701 | { |
||
1702 | ite = FrameItems.at(c); |
||
1703 | QPtrVector<VColorStop> cstops = ite->fill_gradient.colorStops(); |
||
1704 | for (uint cst = 0; cst < ite->fill_gradient.Stops(); ++cst) |
||
1705 | { |
||
1706 | if (it.key() == cstops.at(cst)->name) |
||
1707 | found = true; |
||
1708 | if (found) |
||
1709 | break; |
||
1710 | } |
||
1711 | if ((ite->itemType() == PageItem::TextFrame) || (ite->itemType() == PageItem::PathText)) |
||
1712 | { |
||
4749 | avox | 1713 | for (int d=0; d<ite->itemText.length(); ++d) |
3057 | fschmid | 1714 | { |
1715 | /* PFJ - 29.02.04 - Merged if's */ |
||
4749 | avox | 1716 | if ((it.key() == ite->itemText.charStyle(d).ccolor) || (it.key() == ite->itemText.charStyle(d).cstroke)) |
3057 | fschmid | 1717 | found = true; |
1718 | if (found) |
||
1719 | break; |
||
1720 | } |
||
1721 | } |
||
1722 | /* PFJ - 29.02.04 - Merged if's */ |
||
1723 | if ((it.key() == ite->fillColor()) || (it.key() == ite->lineColor())) |
||
1724 | found = true; |
||
1725 | if (found) |
||
1726 | break; |
||
1727 | } |
||
1728 | if (found) |
||
1729 | { |
||
3068 | fschmid | 1730 | if (spot) |
1731 | { |
||
1732 | if (it.data().isSpotColor()) |
||
1733 | colorsToUse.insert(it.key(), it.data()); |
||
1734 | } |
||
1735 | else |
||
1736 | colorsToUse.insert(it.key(), it.data()); |
||
3057 | fschmid | 1737 | continue; |
1738 | } |
||
1739 | } |
||
1740 | } |
||
1741 | |||
3544 | avox | 1742 | void ScribusDoc::getUsedFonts(QMap<QString,int> *Really) |
2960 | cbradney | 1743 | { |
1744 | PageItem* it; |
||
1745 | FPointArray gly; |
||
1746 | QString chx; |
||
1747 | uint counter = 0; |
||
1748 | for (uint lc = 0; lc < 3; ++lc) |
||
1749 | { |
||
1750 | switch (lc) |
||
1751 | { |
||
1752 | case 0: |
||
1753 | counter = MasterItems.count(); |
||
1754 | break; |
||
1755 | case 1: |
||
1756 | counter = DocItems.count(); |
||
1757 | break; |
||
1758 | case 2: |
||
1759 | counter = FrameItems.count(); |
||
1760 | break; |
||
1761 | } |
||
1762 | for (uint d = 0; d < counter; ++d) |
||
1763 | { |
||
1764 | switch (lc) |
||
1765 | { |
||
1766 | case 0: |
||
1767 | it = MasterItems.at(d); |
||
1768 | break; |
||
1769 | case 1: |
||
1770 | it = DocItems.at(d); |
||
1771 | break; |
||
1772 | case 2: |
||
1773 | it = FrameItems.at(d); |
||
1774 | break; |
||
1775 | } |
||
1776 | if ((it->itemType() == PageItem::TextFrame) || (it->itemType() == PageItem::PathText)) |
||
1777 | { |
||
4749 | avox | 1778 | for (int e = 0; e < it->itemText.length(); ++e) |
2960 | cbradney | 1779 | { |
4749 | avox | 1780 | Really->insert(it->itemText.charStyle(e).cfont->scName(), UsedFonts[it->itemText.charStyle(e).cfont->scName()]); |
1781 | uint chr = it->itemText.text(e).unicode(); |
||
2960 | cbradney | 1782 | if ((chr == 13) || (chr == 32) || (chr == 29)) |
1783 | continue; |
||
5184 | avox | 1784 | #ifndef NLS_PROTO |
2960 | cbradney | 1785 | if (chr == 9) |
1786 | { |
||
5184 | avox | 1787 | for (uint t1 = 0; t1 < docParagraphStyles[it->itemText.at(e)->cab].tabValues().count(); t1++) |
2960 | cbradney | 1788 | { |
5184 | avox | 1789 | if (docParagraphStyles[it->itemText.at(e)->cab].tabValues()[t1].tabFillChar.isNull()) |
2960 | cbradney | 1790 | continue; |
5184 | avox | 1791 | chx = QString(docParagraphStyles[it->itemText.at(e)->cab].tabValues()[t1].tabFillChar); |
4749 | avox | 1792 | if ((it->itemText.charStyle(e).cstyle & ScStyle_SmallCaps) || (it->itemText.charStyle(e).cstyle & ScStyle_AllCaps)) |
2960 | cbradney | 1793 | { |
5184 | avox | 1794 | if (chx.upper() != QString(docParagraphStyles[it->itemText.at(e)->cab].tabValues()[t1].tabFillChar)) |
2960 | cbradney | 1795 | chx = chx.upper(); |
1796 | } |
||
1797 | chr = chx[0].unicode(); |
||
4749 | avox | 1798 | gly = it->itemText.charStyle(e).cfont->GlyphArray[chr].Outlines.copy(); |
1799 | it->itemText.charStyle(e).cfont->RealGlyphs.insert(chr, gly); |
||
2960 | cbradney | 1800 | } |
1801 | for (uint t1 = 0; t1 < it->TabValues.count(); t1++) |
||
1802 | { |
||
1803 | if (it->TabValues[t1].tabFillChar.isNull()) |
||
1804 | continue; |
||
1805 | chx = QString(it->TabValues[t1].tabFillChar); |
||
4749 | avox | 1806 | if ((it->itemText.charStyle(e).cstyle & ScStyle_SmallCaps) || (it->itemText.charStyle(e).cstyle & ScStyle_AllCaps)) |
2960 | cbradney | 1807 | { |
1808 | if (chx.upper() != QString(it->TabValues[t1].tabFillChar)) |
||
1809 | chx = chx.upper(); |
||
1810 | } |
||
1811 | chr = chx[0].unicode(); |
||
4749 | avox | 1812 | gly = it->itemText.charStyle(e).cfont->GlyphArray[chr].Outlines.copy(); |
1813 | it->itemText.charStyle(e).cfont->RealGlyphs.insert(chr, gly); |
||
2960 | cbradney | 1814 | } |
1815 | continue; |
||
1816 | } |
||
5184 | avox | 1817 | #endif |
2960 | cbradney | 1818 | if (chr == 30) |
1819 | { |
||
3761 | cbradney | 1820 | /* CB Removed forced loading of 0-9 for section based numbering |
2960 | cbradney | 1821 | for (uint numco = 0x30; numco < 0x3A; ++numco) |
1822 | { |
||
4749 | avox | 1823 | if (it->itemText.charStyle(e)->cfont->CharWidth.contains(numco)) |
2960 | cbradney | 1824 | { |
4749 | avox | 1825 | gly = it->itemText.charStyle(e)->cfont->GlyphArray[numco].Outlines.copy(); |
1826 | it->itemText.charStyle(e)->cfont->RealGlyphs.insert(numco, gly); |
||
2960 | cbradney | 1827 | } |
3761 | cbradney | 1828 | }*/ |
1829 | //Our page number collection string |
||
1830 | QString pageNumberText(QString::null); |
||
1831 | //If not on a master page just get the page number for the page and the text |
||
1832 | if (lc!=0) |
||
1833 | pageNumberText=getSectionPageNumberForPageIndex(it->OwnPage); |
||
1834 | else |
||
1835 | { |
||
1836 | //Else, for a page number in a text frame on a master page we must scan |
||
1837 | //all pages to see which ones use this page and get their page numbers. |
||
1838 | //We only add each character of the pages' page number text if its nothing |
||
1839 | //already in the pageNumberText variable. No need to add glyphs twice. |
||
1840 | QString newText; |
||
1841 | uint docPageCount=DocPages.count(); |
||
1842 | for (uint a = 0; a < docPageCount; ++a) |
||
1843 | { |
||
4784 | fschmid | 1844 | if (DocPages.at(a)->MPageNam == it->OnMasterPage) |
3761 | cbradney | 1845 | { |
1846 | newText=getSectionPageNumberForPageIndex(a); |
||
1847 | for (uint nti=0;nti<newText.length();++nti) |
||
1848 | if (pageNumberText.find(newText[nti])==-1) |
||
1849 | pageNumberText+=newText[nti]; |
||
1850 | } |
||
1851 | } |
||
2960 | cbradney | 1852 | } |
3761 | cbradney | 1853 | //Now scan and add any glyphs used in page numbers |
1854 | for (uint pnti=0;pnti<pageNumberText.length(); ++pnti) |
||
1855 | { |
||
1856 | uint chr = pageNumberText[pnti].unicode(); |
||
4749 | avox | 1857 | if (it->itemText.charStyle(e).cfont->CharWidth.contains(chr)) |
3761 | cbradney | 1858 | { |
4749 | avox | 1859 | FPointArray gly(it->itemText.charStyle(e).cfont->GlyphArray[chr].Outlines.copy()); |
1860 | it->itemText.charStyle(e).cfont->RealGlyphs.insert(chr, gly); |
||
3761 | cbradney | 1861 | } |
1862 | } |
||
2960 | cbradney | 1863 | continue; |
1864 | } |
||
4749 | avox | 1865 | if ((it->itemText.charStyle(e).cstyle & ScStyle_SmallCaps) || (it->itemText.charStyle(e).cstyle & ScStyle_AllCaps)) |
2960 | cbradney | 1866 | { |
4749 | avox | 1867 | chx = it->itemText.text(e, 1); |
1868 | if (chx.upper() != it->itemText.text(e, 1)) |
||
2960 | cbradney | 1869 | chx = chx.upper(); |
1870 | chr = chx[0].unicode(); |
||
1871 | } |
||
4749 | avox | 1872 | if (it->itemText.charStyle(e).cfont->CharWidth.contains(chr)) |
2960 | cbradney | 1873 | { |
4749 | avox | 1874 | gly = it->itemText.charStyle(e).cfont->GlyphArray[chr].Outlines.copy(); |
1875 | it->itemText.charStyle(e).cfont->RealGlyphs.insert(chr, gly); |
||
2960 | cbradney | 1876 | } |
1877 | } |
||
1878 | } |
||
1879 | } |
||
1880 | } |
||
1881 | } |
||
1882 | |||
1883 | void ScribusDoc::reorganiseFonts() |
||
1884 | { |
||
3544 | avox | 1885 | QMap<QString,int> Really; |
2960 | cbradney | 1886 | //QMap<QString,QFont> DocF; |
1887 | //DocF = UsedFonts; |
||
1888 | uint counter = 0; |
||
1889 | for (uint lc = 0; lc < 3; ++lc) |
||
1890 | { |
||
1891 | switch (lc) |
||
1892 | { |
||
1893 | case 0: |
||
1894 | counter = MasterItems.count(); |
||
1895 | break; |
||
1896 | case 1: |
||
1897 | counter = DocItems.count(); |
||
1898 | break; |
||
1899 | case 2: |
||
1900 | counter = FrameItems.count(); |
||
1901 | break; |
||
1902 | } |
||
1903 | PageItem* it; |
||
1904 | for (uint d = 0; d < counter; ++d) |
||
1905 | { |
||
1906 | switch (lc) |
||
1907 | { |
||
1908 | case 0: |
||
1909 | it = MasterItems.at(d); |
||
1910 | break; |
||
1911 | case 1: |
||
1912 | it = DocItems.at(d); |
||
1913 | break; |
||
1914 | case 2: |
||
1915 | it = FrameItems.at(d); |
||
1916 | break; |
||
1917 | } |
||
4073 | cbradney | 1918 | Really.insert(it->font(), UsedFonts[it->font()]); |
2960 | cbradney | 1919 | if ((it->itemType() == PageItem::TextFrame) || (it->itemType() == PageItem::PathText)) |
1920 | { |
||
4749 | avox | 1921 | uint itemTextCount=it->itemText.length(); |
2960 | cbradney | 1922 | for (uint e = 0; e < itemTextCount; ++e) |
1923 | { |
||
4749 | avox | 1924 | Really.insert(it->itemText.charStyle(e).cfont->scName(), UsedFonts[it->itemText.charStyle(e).cfont->scName()]); |
2960 | cbradney | 1925 | } |
1926 | } |
||
1927 | } |
||
1928 | } |
||
3544 | avox | 1929 | QMap<QString,int>::Iterator itfo, itnext; |
2960 | cbradney | 1930 | for (itfo = UsedFonts.begin(); itfo != UsedFonts.end(); itfo = itnext) |
1931 | { |
||
1932 | itnext = itfo; |
||
1933 | ++itnext; |
||
1934 | if (!Really.contains(itfo.key())) |
||
1935 | { |
||
1936 | FT_Done_Face(FFonts[itfo.key()]); |
||
1937 | FFonts.remove(itfo.key()); |
||
1938 | UsedFonts.remove(itfo); |
||
1939 | } |
||
1940 | } |
||
1941 | PrefsManager* prefsManager=PrefsManager::instance(); |
||
3544 | avox | 1942 | AddFont(prefsManager->appPrefs.toolSettings.defFont);//, prefsManager->appPrefs.AvailFonts[prefsManager->appPrefs.toolSettings.defFont]->Font); |
1943 | AddFont(toolSettings.defFont);//, prefsManager->appPrefs.AvailFonts[toolSettings.defFont]->Font); |
||
2960 | cbradney | 1944 | } |
2965 | cbradney | 1945 | |
1946 | void ScribusDoc::setUnitIndex(const int newIndex) |
||
1947 | { |
||
1948 | docUnitIndex=newIndex; |
||
1949 | docUnitRatio = unitGetRatioFromIndex( docUnitIndex ); |
||
1950 | } |
||
1951 | |||
3985 | cbradney | 1952 | int ScribusDoc::unitIndex() const |
2965 | cbradney | 1953 | { |
1954 | return docUnitIndex; |
||
1955 | } |
||
1956 | |||
3985 | cbradney | 1957 | double ScribusDoc::unitRatio() const |
2965 | cbradney | 1958 | { |
1959 | return docUnitRatio; |
||
1960 | } |
||
3004 | cbradney | 1961 | |
3985 | cbradney | 1962 | bool ScribusDoc::applyMasterPage(const QString& in, const int pageNumber) |
3004 | cbradney | 1963 | { |
1964 | if (UndoManager::undoEnabled()) |
||
1965 | { |
||
3817 | cbradney | 1966 | if (DocPages.at(pageNumber)->MPageNam != in) |
3004 | cbradney | 1967 | { |
3817 | cbradney | 1968 | SimpleState *ss = new SimpleState(Um::ApplyMasterPage, QString(Um::FromTo).arg(DocPages.at(pageNumber)->MPageNam).arg(in)); |
3004 | cbradney | 1969 | ss->set("PAGE_NUMBER", pageNumber); |
3817 | cbradney | 1970 | ss->set("OLD_MASTERPAGE", DocPages.at(pageNumber)->MPageNam); |
3004 | cbradney | 1971 | ss->set("NEW_MASTERPAGE", in); |
1972 | undoManager->action(this, ss); |
||
1973 | } |
||
1974 | } |
||
3174 | fschmid | 1975 | |
3004 | cbradney | 1976 | QString mna = in; |
1977 | if (mna == tr("Normal")) |
||
1978 | mna = "Normal"; |
||
1979 | if (!MasterNames.contains(mna)) |
||
1980 | mna = "Normal"; |
||
3817 | cbradney | 1981 | Page* Ap = DocPages.at(pageNumber); |
3004 | cbradney | 1982 | Ap->MPageNam = mna; |
1983 | int MpNr = MasterNames[mna]; |
||
1984 | Page* Mp = MasterPages.at(MpNr); |
||
1985 | PageItem *currItem; |
||
1986 | for (currItem = Ap->FromMaster.first(); currItem; currItem = Ap->FromMaster.next()) |
||
1987 | { |
||
1988 | if (currItem->ChangedMasterItem) |
||
1989 | { |
||
1990 | Ap->FromMaster.remove(currItem); |
||
1991 | delete currItem; |
||
1992 | } |
||
1993 | } |
||
1994 | Ap->FromMaster.clear(); |
||
1995 | for (currItem = MasterItems.first(); currItem; currItem = MasterItems.next()) |
||
1996 | { |
||
1997 | if (currItem->OwnPage == MpNr) |
||
1998 | Ap->FromMaster.append(currItem); |
||
1999 | } |
||
5087 | subik | 2000 | /* PV - guides refactoring |
3004 | cbradney | 2001 | if (Mp->YGuides.count() != 0) |
2002 | { |
||
2003 | for (uint y = 0; y < Mp->YGuides.count(); ++y) |
||
2004 | { |
||
2005 | if (Ap->YGuides.contains(Mp->YGuides[y]) == 0) |
||
2006 | Ap->YGuides.append(Mp->YGuides[y]); |
||
2007 | } |
||
2008 | qHeapSort(Ap->YGuides); |
||
2009 | } |
||
2010 | if (Mp->XGuides.count() != 0) |
||
2011 | { |
||
2012 | for (uint x = 0; x < Mp->XGuides.count(); ++x) |
||
2013 | { |
||
2014 | if (Ap->XGuides.contains(Mp->XGuides[x]) == 0) |
||
2015 | Ap->XGuides.append(Mp->XGuides[x]); |
||
2016 | } |
||
2017 | qHeapSort(Ap->XGuides); |
||
2018 | } |
||
5087 | subik | 2019 | */ |
2020 | Mp->guides.copy(&Ap->guides); |
||
4612 | fschmid | 2021 | Ap->initialMargins.Top = Mp->Margins.Top; |
2022 | Ap->initialMargins.Bottom = Mp->Margins.Bottom; |
||
2023 | Ap->initialMargins.Left = Mp->Margins.Left; |
||
2024 | Ap->initialMargins.Right = Mp->Margins.Right; |
||
3004 | cbradney | 2025 | //TODO make a return false if not possible to apply the master page |
5226 | cbradney | 2026 | changed(); |
3004 | cbradney | 2027 | return true; |
2028 | } |
||
2029 | |||
2030 | void ScribusDoc::restoreMasterPageApplying(SimpleState *state, bool isUndo) |
||
2031 | { |
||
2032 | int pageNumber = state->getInt("PAGE_NUMBER"); |
||
2033 | QString oldName = state->get("OLD_MASTERPAGE"); |
||
2034 | QString newName = state->get("NEW_MASTERPAGE"); |
||
2035 | if (isUndo) |
||
2036 | applyMasterPage(oldName, pageNumber); |
||
2037 | else |
||
2038 | applyMasterPage(newName, pageNumber); |
||
2039 | } |
||
3020 | cbradney | 2040 | |
3025 | cbradney | 2041 | //TODO: Handle saving to versions of SLA, and other formats |
3985 | cbradney | 2042 | bool ScribusDoc::save(const QString& fileName) |
3020 | cbradney | 2043 | { |
2044 | QFileInfo fi(fileName); |
||
2045 | QDir::setCurrent(fi.dirPath(true)); |
||
2046 | QProgressBar* mainWindowProgressBar=NULL; |
||
2047 | if (ScQApp->usingGUI()) |
||
2048 | { |
||
4026 | craig | 2049 | mainWindowProgressBar=ScMW->mainWindowProgressBar; |
3020 | cbradney | 2050 | mainWindowProgressBar->reset(); |
2051 | } |
||
2052 | ScriXmlDoc *ss = new ScriXmlDoc(); |
||
2053 | bool ret = ss->WriteDoc(fileName, this, mainWindowProgressBar); |
||
2054 | delete ss; |
||
2055 | if (ret) |
||
2056 | { |
||
2057 | setModified(false); |
||
2058 | setName(fileName); |
||
2059 | hasName = true; |
||
2060 | } |
||
2061 | return ret; |
||
2062 | } |
||
3025 | cbradney | 2063 | |
3985 | cbradney | 2064 | bool ScribusDoc::changePageMargins(const double initialTop, const double initialBottom, const double initialLeft, const double initialRight, const double initialHeight, const double initialWidth, const double height, const double width, const int orientation, const QString& pageSize, const int pageNumber, const int pageType) |
3025 | cbradney | 2065 | { |
2066 | bool retVal=true; |
||
2067 | if (pageNumber==-1) |
||
2068 | { |
||
2069 | //find page and set values |
||
2070 | return false; |
||
2071 | } |
||
2072 | else |
||
2073 | { |
||
5087 | subik | 2074 | if (currentPage()==NULL) |
3025 | cbradney | 2075 | retVal=false; |
2076 | else |
||
2077 | { |
||
2078 | //set the current page's values |
||
5087 | subik | 2079 | currentPage()->initialMargins.Top = initialTop; |
2080 | currentPage()->initialMargins.Bottom = initialBottom; |
||
2081 | currentPage()->initialMargins.Left = initialLeft; |
||
2082 | currentPage()->initialMargins.Right = initialRight; |
||
2083 | currentPage()->setInitialHeight(initialHeight); |
||
2084 | currentPage()->setInitialWidth(initialWidth); |
||
2085 | currentPage()->setHeight(height); |
||
2086 | currentPage()->setWidth(width); |
||
2087 | currentPage()->PageOri = orientation; |
||
2088 | currentPage()->PageSize = pageSize; |
||
2089 | currentPage()->LeftPg = pageType; |
||
4847 | cbradney | 2090 | changed(); |
3025 | cbradney | 2091 | } |
2092 | } |
||
2093 | return retVal; |
||
2094 | } |
||
3123 | cbradney | 2095 | |
2096 | void ScribusDoc::recalculateColors() |
||
2097 | { |
||
2098 | //Recalculate the RGB or CMYK calues to new CMS settings |
||
2099 | ColorList::Iterator it; |
||
2100 | ColorList::Iterator itend=PageColors.end(); |
||
2101 | for (it = PageColors.begin(); it != itend; ++it) |
||
2102 | PageColors[it.key()].RecalcRGB(); |
||
2103 | //Adjust Items of the 3 types to the colors |
||
3727 | cbradney | 2104 | uint itemsCount=Items->count(); |
3894 | cbradney | 2105 | updateAllItemQColors(); |
3123 | cbradney | 2106 | for (uint c=0; c<itemsCount; ++c) |
2107 | { |
||
3727 | cbradney | 2108 | PageItem *ite = Items->at(c); |
3123 | cbradney | 2109 | QPtrVector<VColorStop> cstops = ite->fill_gradient.colorStops(); |
2110 | for (uint cst = 0; cst < ite->fill_gradient.Stops(); ++cst) |
||
2111 | { |
||
2112 | QColor tmpc = PageColors[cstops.at(cst)->name].getRGBColor(); |
||
2113 | ite->SetFarbe(&tmpc, cstops.at(cst)->name, cstops.at(cst)->shade); |
||
2114 | cstops.at(cst)->color = tmpc; |
||
2115 | } |
||
2116 | } |
||
2117 | uint masterItemsCount=MasterItems.count(); |
||
2118 | for (uint c=0; c<masterItemsCount; ++c) |
||
2119 | { |
||
2120 | PageItem *ite = MasterItems.at(c); |
||
2121 | QPtrVector<VColorStop> cstops = ite->fill_gradient.colorStops(); |
||
2122 | for (uint cst = 0; cst < ite->fill_gradient.Stops(); ++cst) |
||
2123 | { |
||
2124 | QColor tmpc = PageColors[cstops.at(cst)->name].getRGBColor(); |
||
2125 | ite->SetFarbe(&tmpc, cstops.at(cst)->name, cstops.at(cst)->shade); |
||
2126 | cstops.at(cst)->color = tmpc; |
||
2127 | } |
||
2128 | } |
||
2129 | uint frameItemsCount=FrameItems.count(); |
||
2130 | for (uint c=0; c<frameItemsCount; ++c) |
||
2131 | { |
||
2132 | PageItem *ite = FrameItems.at(c); |
||
2133 | QPtrVector<VColorStop> cstops = ite->fill_gradient.colorStops(); |
||