Rev 2040 | Rev 2142 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
3 | paul | 1 | /*************************************************************************** |
2 | scribusdoc.cpp - description |
||
3 | ------------------- |
||
4 | begin : Fre Apr 6 21:47:55 CEST 2001 |
||
5 | copyright : (C) 2001 by Franz Schmid |
||
6 | email : Franz.Schmid@altmuehlnet.de |
||
7 | ***************************************************************************/ |
||
8 | |||
9 | /*************************************************************************** |
||
10 | * * |
||
11 | * This program is free software; you can redistribute it and/or modify * |
||
12 | * it under the terms of the GNU General Public License as published by * |
||
13 | * the Free Software Foundation; either version 2 of the License, or * |
||
14 | * (at your option) any later version. * |
||
15 | * * |
||
16 | ***************************************************************************/ |
||
17 | |||
18 | #include "scribusdoc.h" |
||
410 | Franz | 19 | #include "scribusXml.h" |
20 | #include "scribus.h" |
||
2016 | cbradney | 21 | |
22 | #include <qfile.h> |
||
23 | |||
456 | fschmid | 24 | #include "page.h" |
25 | #include "pageitem.h" |
||
1179 | tsoots | 26 | #include "undomanager.h" |
27 | #include "undostate.h" |
||
410 | Franz | 28 | |
2016 | cbradney | 29 | |
1179 | tsoots | 30 | extern QPixmap loadIcon(QString nam); |
31 | |||
1065 | cbradney | 32 | ScribusDoc::ScribusDoc(struct ApplicationPrefs *prefsData) |
1179 | tsoots | 33 | : UndoObject(QObject::tr("Document")) |
3 | paul | 34 | { |
823 | fschmid | 35 | prefsValues = prefsData; |
167 | Franz | 36 | modified = false; |
37 | MasterP = false; |
||
1330 | fschmid | 38 | NrItems = 0; |
39 | First = 1; |
||
40 | Last = 0; |
||
41 | viewCount = 0; |
||
42 | viewID = 0; |
||
823 | fschmid | 43 | UsedFonts.clear(); |
44 | FT_Init_FreeType( &library ); |
||
45 | AllFonts = &prefsData->AvailFonts; |
||
1194 | fschmid | 46 | AddFont(prefsData->toolSettings.defFont, prefsData->AvailFonts[prefsData->toolSettings.defFont]->Font); |
47 | toolSettings.defFont = prefsData->toolSettings.defFont; |
||
48 | toolSettings.defSize = prefsData->toolSettings.defSize; |
||
879 | fschmid | 49 | guidesSettings.marginsShown = prefsData->guidesSettings.marginsShown; |
50 | guidesSettings.framesShown = prefsData->guidesSettings.framesShown; |
||
51 | guidesSettings.gridShown = prefsData->guidesSettings.gridShown; |
||
52 | guidesSettings.guidesShown = prefsData->guidesSettings.guidesShown; |
||
53 | guidesSettings.baseShown = prefsData->guidesSettings.baseShown; |
||
54 | guidesSettings.linkShown = prefsData->guidesSettings.linkShown; |
||
55 | guidesSettings.showPic = prefsData->guidesSettings.showPic; |
||
56 | guidesSettings.grabRad = prefsData->guidesSettings.grabRad; |
||
57 | guidesSettings.guideRad = prefsData->guidesSettings.guideRad; |
||
58 | guidesSettings.minorGrid = prefsData->guidesSettings.minorGrid; |
||
59 | guidesSettings.majorGrid = prefsData->guidesSettings.majorGrid; |
||
60 | guidesSettings.minorColor = prefsData->guidesSettings.minorColor; |
||
61 | guidesSettings.majorColor = prefsData->guidesSettings.majorColor; |
||
823 | fschmid | 62 | papColor = prefsData->DpapColor; |
879 | fschmid | 63 | guidesSettings.margColor = prefsData->guidesSettings.margColor; |
64 | guidesSettings.guideColor = prefsData->guidesSettings.guideColor; |
||
65 | guidesSettings.baseColor = prefsData->guidesSettings.baseColor; |
||
1187 | fschmid | 66 | guidesSettings.before = prefsData->guidesSettings.before; |
823 | fschmid | 67 | PageColors.clear(); |
68 | PageColors.insert("Black", CMYKColor(0, 0, 0, 255)); |
||
69 | PageColors.insert("White", CMYKColor(0, 0, 0, 0)); |
||
1194 | fschmid | 70 | if (prefsData->toolSettings.dPen != "None") |
71 | PageColors.insert(prefsData->toolSettings.dPen, prefsData->DColors[prefsData->toolSettings.dPen]); |
||
72 | toolSettings.dPen = prefsData->toolSettings.dPen; |
||
73 | if (prefsData->toolSettings.dPenLine != "None") |
||
74 | PageColors.insert(prefsData->toolSettings.dPenLine, prefsData->DColors[prefsData->toolSettings.dPenLine]); |
||
75 | toolSettings.dPenLine = prefsData->toolSettings.dPenLine; |
||
76 | if (prefsData->toolSettings.dPenText != "None") |
||
77 | PageColors.insert(prefsData->toolSettings.dPenText, prefsData->DColors[prefsData->toolSettings.dPenText]); |
||
78 | toolSettings.dPenText = prefsData->toolSettings.dPenText; |
||
79 | if (prefsData->toolSettings.dStrokeText != "None") |
||
80 | PageColors.insert(prefsData->toolSettings.dStrokeText, prefsData->DColors[prefsData->toolSettings.dStrokeText]); |
||
81 | toolSettings.dStrokeText = prefsData->toolSettings.dStrokeText; |
||
82 | if (prefsData->toolSettings.dBrush != "None") |
||
83 | PageColors.insert(prefsData->toolSettings.dBrush, prefsData->DColors[prefsData->toolSettings.dBrush]); |
||
84 | toolSettings.dBrush = prefsData->toolSettings.dBrush; |
||
85 | if (prefsData->toolSettings.dBrushPict != "None") |
||
86 | PageColors.insert(prefsData->toolSettings.dBrushPict, prefsData->DColors[prefsData->toolSettings.dBrushPict]); |
||
87 | toolSettings.dBrushPict = prefsData->toolSettings.dBrushPict; |
||
823 | fschmid | 88 | typographicSetttings.valueSuperScript = prefsData->typographicSetttings.valueSuperScript; |
89 | typographicSetttings.scalingSuperScript = prefsData->typographicSetttings.scalingSuperScript; |
||
90 | typographicSetttings.valueSubScript = prefsData->typographicSetttings.valueSubScript; |
||
91 | typographicSetttings.scalingSubScript = prefsData->typographicSetttings.scalingSubScript; |
||
92 | typographicSetttings.valueSmallCaps = prefsData->typographicSetttings.valueSmallCaps; |
||
93 | typographicSetttings.autoLineSpacing = prefsData->typographicSetttings.autoLineSpacing; |
||
94 | typographicSetttings.valueBaseGrid = prefsData->typographicSetttings.valueBaseGrid; |
||
95 | typographicSetttings.offsetBaseGrid = prefsData->typographicSetttings.offsetBaseGrid; |
||
1194 | fschmid | 96 | toolSettings.dShade = prefsData->toolSettings.dShade; |
97 | toolSettings.dShade2 = prefsData->toolSettings.dShade2; |
||
98 | toolSettings.shadePict = prefsData->toolSettings.shadePict; |
||
99 | toolSettings.scaleX = prefsData->toolSettings.scaleX; |
||
100 | toolSettings.scaleY = prefsData->toolSettings.scaleY; |
||
101 | toolSettings.scaleType = prefsData->toolSettings.scaleType; |
||
102 | toolSettings.aspectRatio = prefsData->toolSettings.aspectRatio; |
||
2040 | fschmid | 103 | toolSettings.useEmbeddedPath = prefsData->toolSettings.useEmbeddedPath; |
2025 | fschmid | 104 | toolSettings.lowResType = prefsData->toolSettings.lowResType; |
1194 | fschmid | 105 | toolSettings.dCols = prefsData->toolSettings.dCols; |
106 | toolSettings.dGap = prefsData->toolSettings.dGap; |
||
107 | toolSettings.dLineArt = PenStyle(prefsData->toolSettings.dLineArt); |
||
108 | toolSettings.dWidth = prefsData->toolSettings.dWidth; |
||
109 | toolSettings.dShadeLine = prefsData->toolSettings.dShadeLine; |
||
110 | toolSettings.dLstyleLine = PenStyle(prefsData->toolSettings.dLstyleLine); |
||
111 | toolSettings.dWidthLine = prefsData->toolSettings.dWidthLine; |
||
112 | toolSettings.dStartArrow = prefsData->toolSettings.dStartArrow; |
||
113 | toolSettings.dEndArrow = prefsData->toolSettings.dEndArrow; |
||
114 | toolSettings.polyC = prefsData->toolSettings.polyC; |
||
115 | toolSettings.polyF = prefsData->toolSettings.polyF; |
||
116 | toolSettings.polyS = prefsData->toolSettings.polyS; |
||
117 | toolSettings.polyFd = prefsData->toolSettings.polyFd; |
||
118 | toolSettings.polyR = prefsData->toolSettings.polyR; |
||
119 | toolSettings.magMin = prefsData->toolSettings.magMin; |
||
120 | toolSettings.magMax = prefsData->toolSettings.magMax; |
||
121 | toolSettings.magStep = prefsData->toolSettings.magStep; |
||
1261 | fschmid | 122 | checkerProfiles = prefsData->checkerProfiles; |
123 | curCheckProfile = prefsData->curCheckProfile; |
||
1065 | cbradney | 124 | docUnitIndex = prefsData->docUnitIndex; |
125 | marginColored = prefsData->marginColored; |
||
823 | fschmid | 126 | Language = prefsData->Language; |
127 | MinWordLen = prefsData->MinWordLen; |
||
128 | HyCount = prefsData->HyCount; |
||
129 | Automatic = prefsData->Automatic; |
||
130 | AutoCheck = prefsData->AutoCheck; |
||
3 | paul | 131 | GuideLock = false; |
132 | SnapGuides = false; |
||
167 | Franz | 133 | useRaster = false; |
134 | EditClip = false; |
||
135 | EditClipMode = 0; |
||
136 | loading = false; |
||
178 | Franz | 137 | DocName = QObject::tr("Document")+"-"; |
3 | paul | 138 | CurrentSel = -1; |
139 | PageC = 0; |
||
140 | LastAuto = 0; |
||
141 | FirstAuto = 0; |
||
142 | DraggedElem = 0; |
||
143 | GroupCounter = 1; |
||
1065 | cbradney | 144 | docParagraphStyles.clear(); |
145 | struct ParagraphStyle vg; |
||
3 | paul | 146 | vg.Vname = "Normal Internal"; |
147 | vg.LineSpa = 15; |
||
1065 | cbradney | 148 | vg.textAlignment = 0; |
3 | paul | 149 | vg.Indent = 0; |
150 | vg.First = 0; |
||
1065 | cbradney | 151 | vg.gapBefore = 0; |
152 | vg.gapAfter = 0; |
||
3 | paul | 153 | vg.Font = ""; |
1194 | fschmid | 154 | vg.FontSize = toolSettings.defSize; |
140 | Franz | 155 | vg.TabValues.clear(); |
153 | Franz | 156 | vg.Drop = false; |
157 | vg.DropLin = 2; |
||
173 | Franz | 158 | vg.FontEffect = 0; |
1194 | fschmid | 159 | vg.FColor = toolSettings.dBrush; |
160 | vg.FShade = toolSettings.dShade; |
||
161 | vg.SColor = toolSettings.dPen; |
||
162 | vg.SShade = toolSettings.dShade2; |
||
241 | Franz | 163 | vg.BaseAdj = false; |
1065 | cbradney | 164 | docParagraphStyles.append(vg); |
3 | paul | 165 | vg.Vname = "Center Internal"; |
1065 | cbradney | 166 | vg.textAlignment = 1; |
167 | docParagraphStyles.append(vg); |
||
3 | paul | 168 | vg.Vname = "Rechts Internal"; |
1065 | cbradney | 169 | vg.textAlignment = 2; |
170 | docParagraphStyles.append(vg); |
||
3 | paul | 171 | vg.Vname = "Block Internal"; |
1065 | cbradney | 172 | vg.textAlignment = 3; |
173 | docParagraphStyles.append(vg); |
||
3 | paul | 174 | vg.Vname = "EBlock Internal"; |
1065 | cbradney | 175 | vg.textAlignment = 4; |
176 | docParagraphStyles.append(vg); |
||
3 | paul | 177 | Layers.clear(); |
178 | struct Layer ll; |
||
179 | ll.LNr = 0; |
||
180 | ll.Level = 0; |
||
178 | Franz | 181 | ll.Name = QObject::tr("Background"); |
1065 | cbradney | 182 | ll.isViewable = true; |
183 | ll.isPrintable = true; |
||
3 | paul | 184 | Layers.append(ll); |
185 | ActiveLayer = 0; |
||
186 | JavaScripts.clear(); |
||
167 | Franz | 187 | CurrentStyle = 0; |
1065 | cbradney | 188 | currentParaStyle = 0; |
3 | paul | 189 | TotalItems = 0; |
2093 | cbradney | 190 | masterPageMode = false; |
1545 | cbradney | 191 | PDF_Options.Thumbnails = prefsData->PDF_Options.Thumbnails; |
192 | PDF_Options.Articles = prefsData->PDF_Options.Articles; |
||
193 | PDF_Options.Compress = prefsData->PDF_Options.Compress; |
||
194 | PDF_Options.CompressMethod = prefsData->PDF_Options.CompressMethod; |
||
195 | PDF_Options.Quality = prefsData->PDF_Options.Quality; |
||
196 | PDF_Options.RecalcPic = prefsData->PDF_Options.RecalcPic; |
||
197 | PDF_Options.Bookmarks = prefsData->PDF_Options.Bookmarks; |
||
198 | PDF_Options.PicRes = prefsData->PDF_Options.PicRes; |
||
1973 | craig | 199 | // Fixme: Check PDF version input |
200 | PDF_Options.Version = (PDFOptions::PDFVersion)prefsData->PDF_Options.Version; |
||
1545 | cbradney | 201 | PDF_Options.Resolution = prefsData->PDF_Options.Resolution; |
202 | PDF_Options.Binding = prefsData->PDF_Options.Binding; |
||
203 | PDF_Options.EmbedList = prefsData->PDF_Options.EmbedList; |
||
204 | PDF_Options.SubsetList = prefsData->PDF_Options.SubsetList; |
||
205 | PDF_Options.MirrorH = prefsData->PDF_Options.MirrorH; |
||
206 | PDF_Options.MirrorV = prefsData->PDF_Options.MirrorV; |
||
207 | PDF_Options.RotateDeg = prefsData->PDF_Options.RotateDeg; |
||
208 | PDF_Options.PresentMode = prefsData->PDF_Options.PresentMode; |
||
209 | PDF_Options.Datei = prefsData->PDF_Options.Datei; |
||
210 | PDF_Options.PresentVals = prefsData->PDF_Options.PresentVals; |
||
211 | PDF_Options.isGrayscale = prefsData->PDF_Options.isGrayscale; |
||
212 | PDF_Options.UseRGB = prefsData->PDF_Options.UseRGB; |
||
213 | PDF_Options.UseProfiles = prefsData->PDF_Options.UseProfiles; |
||
214 | PDF_Options.UseProfiles2 = prefsData->PDF_Options.UseProfiles2; |
||
215 | PDF_Options.SolidProf = prefsData->PDF_Options.SolidProf; |
||
216 | PDF_Options.SComp = prefsData->PDF_Options.SComp; |
||
217 | PDF_Options.ImageProf = prefsData->PDF_Options.ImageProf; |
||
218 | PDF_Options.PrintProf = prefsData->PDF_Options.PrintProf; |
||
219 | PDF_Options.Info = prefsData->PDF_Options.Info; |
||
220 | PDF_Options.Intent = prefsData->PDF_Options.Intent; |
||
221 | PDF_Options.Intent2 = prefsData->PDF_Options.Intent2; |
||
222 | PDF_Options.BleedTop = prefsData->PDF_Options.BleedTop; |
||
223 | PDF_Options.BleedLeft = prefsData->PDF_Options.BleedLeft; |
||
224 | PDF_Options.BleedRight = prefsData->PDF_Options.BleedRight; |
||
225 | PDF_Options.BleedBottom = prefsData->PDF_Options.BleedBottom; |
||
226 | PDF_Options.EmbeddedI = prefsData->PDF_Options.EmbeddedI; |
||
227 | PDF_Options.Encrypt = prefsData->PDF_Options.Encrypt; |
||
228 | PDF_Options.PassOwner = prefsData->PDF_Options.PassOwner; |
||
229 | PDF_Options.PassUser = prefsData->PDF_Options.PassUser; |
||
230 | PDF_Options.Permissions = prefsData->PDF_Options.Permissions; |
||
231 | PDF_Options.UseLPI = prefsData->PDF_Options.UseLPI; |
||
232 | PDF_Options.LPISettings = prefsData->PDF_Options.LPISettings; |
||
1738 | fschmid | 233 | PDF_Options.useLayers = prefsData->PDF_Options.useLayers; |
1641 | cbradney | 234 | |
235 | docItemAttributes = prefsData->defaultItemAttributes; |
||
1701 | cbradney | 236 | docToCSetups = prefsData->defaultToCSetups; |
1641 | cbradney | 237 | |
3 | paul | 238 | RePos = false; |
239 | BookMarks.clear(); |
||
240 | OldBM = false; |
||
241 | hasName = false; |
||
63 | Franz | 242 | DoDrawing = true; |
3 | paul | 243 | RotMode = 0; |
123 | Franz | 244 | SubMode = -1; |
3 | paul | 245 | ASaveTimer = new QTimer(this); |
27 | Franz | 246 | MLineStyles.clear(); |
456 | fschmid | 247 | Pages.clear(); |
248 | MasterPages.clear(); |
||
249 | DocPages.clear(); |
||
250 | Items.clear(); |
||
251 | MasterItems.clear(); |
||
252 | DocItems.clear(); |
||
823 | fschmid | 253 | ScratchLeft = prefsData->ScratchLeft; |
254 | ScratchRight = prefsData->ScratchRight; |
||
255 | ScratchTop = prefsData->ScratchTop; |
||
256 | ScratchBottom = prefsData->ScratchBottom; |
||
257 | arrowStyles = prefsData->arrowStyles; |
||
1179 | tsoots | 258 | undoManager = UndoManager::instance(); |
1235 | fschmid | 259 | docItemErrors.clear(); |
260 | masterItemErrors.clear(); |
||
3 | paul | 261 | } |
262 | |||
263 | ScribusDoc::~ScribusDoc() |
||
264 | { |
||
456 | fschmid | 265 | MasterItems.setAutoDelete(true); |
266 | DocItems.setAutoDelete(true); |
||
267 | MasterItems.clear(); |
||
268 | DocItems.clear(); |
||
269 | MasterPages.setAutoDelete(true); |
||
270 | DocPages.setAutoDelete(true); |
||
271 | MasterPages.clear(); |
||
272 | DocPages.clear(); |
||
494 | fschmid | 273 | QMap<QString,QFont>::Iterator it3; |
274 | for (it3 = UsedFonts.begin(); it3 != UsedFonts.end(); ++it3) |
||
275 | { |
||
276 | if ((*AllFonts)[it3.key()]->PrivateFont != "") |
||
277 | (*AllFonts).removeFont(it3.key()); |
||
278 | } |
||
3 | paul | 279 | FT_Done_FreeType( library ); |
280 | } |
||
281 | |||
1330 | fschmid | 282 | void ScribusDoc::CloseCMSProfiles() |
283 | { |
||
284 | #ifdef HAVE_CMS |
||
285 | cmsCloseProfile(DocInputProf); |
||
286 | cmsCloseProfile(DocOutputProf); |
||
287 | cmsCloseProfile(DocPrinterProf); |
||
288 | cmsDeleteTransform(stdTrans); |
||
289 | cmsDeleteTransform(stdProof); |
||
290 | cmsDeleteTransform(stdTransImg); |
||
291 | cmsDeleteTransform(stdProofImg); |
||
1488 | fschmid | 292 | cmsDeleteTransform(stdTransCMYK); |
293 | cmsDeleteTransform(stdProofCMYK); |
||
294 | cmsDeleteTransform(stdTransRGB); |
||
1330 | fschmid | 295 | #endif |
296 | } |
||
297 | |||
298 | void ScribusDoc::OpenCMSProfiles(ProfilesL InPo, ProfilesL MoPo, ProfilesL PrPo) |
||
299 | { |
||
300 | #ifdef HAVE_CMS |
||
301 | DocInputProf = cmsOpenProfileFromFile(InPo[CMSSettings.DefaultInputProfile2], "r"); |
||
302 | DocOutputProf = cmsOpenProfileFromFile(MoPo[CMSSettings.DefaultMonitorProfile], "r"); |
||
303 | DocPrinterProf = cmsOpenProfileFromFile(PrPo[CMSSettings.DefaultPrinterProfile], "r"); |
||
304 | if ((DocInputProf == NULL) || (DocOutputProf == NULL) || (DocPrinterProf == NULL)) |
||
305 | { |
||
306 | CMSSettings.CMSinUse = false; |
||
307 | return; |
||
308 | } |
||
309 | int dcmsFlags = 0; |
||
310 | int dcmsFlags2 = cmsFLAGS_NOTPRECALC; |
||
1488 | fschmid | 311 | if (CMSSettings.GamutCheck) |
1330 | fschmid | 312 | dcmsFlags |= cmsFLAGS_GAMUTCHECK; |
1488 | fschmid | 313 | if (CMSSettings.SoftProofOn) |
1330 | fschmid | 314 | dcmsFlags |= cmsFLAGS_SOFTPROOFING; |
315 | #ifdef cmsFLAGS_BLACKPOINTCOMPENSATION |
||
316 | if (CMSSettings.BlackPoint) |
||
317 | { |
||
318 | dcmsFlags2 |= cmsFLAGS_BLACKPOINTCOMPENSATION; |
||
319 | dcmsFlags |= cmsFLAGS_BLACKPOINTCOMPENSATION; |
||
320 | } |
||
321 | #endif |
||
1525 | cbradney | 322 | // set Gamut alarm color to #00ff00 |
1488 | fschmid | 323 | cmsSetAlarmCodes(0, 255, 0); |
1330 | fschmid | 324 | stdProof = cmsCreateProofingTransform(DocInputProf, TYPE_RGB_16, |
325 | DocOutputProf, TYPE_RGB_16, |
||
326 | DocPrinterProf, |
||
327 | IntentPrinter, |
||
328 | IntentMonitor, dcmsFlags); |
||
329 | stdTrans = cmsCreateTransform(DocInputProf, TYPE_RGB_16, |
||
330 | DocOutputProf, TYPE_RGB_16, |
||
331 | IntentMonitor, |
||
332 | dcmsFlags2); |
||
333 | stdProofImg = cmsCreateProofingTransform(DocInputProf, TYPE_RGBA_8, |
||
334 | DocOutputProf, TYPE_RGBA_8, |
||
335 | DocPrinterProf, |
||
336 | IntentPrinter, |
||
337 | IntentMonitor, dcmsFlags); |
||
338 | stdTransImg = cmsCreateTransform(DocInputProf, TYPE_RGBA_8, |
||
339 | DocOutputProf, TYPE_RGBA_8, |
||
340 | IntentMonitor, |
||
341 | dcmsFlags2); |
||
1491 | fschmid | 342 | if (static_cast<int>(cmsGetColorSpace(DocPrinterProf)) == icSigCmykData) |
343 | { |
||
344 | stdProofCMYK = cmsCreateProofingTransform(DocPrinterProf, TYPE_CMYK_16, |
||
345 | DocOutputProf, TYPE_RGB_16, |
||
346 | DocPrinterProf, |
||
347 | IntentPrinter, |
||
348 | IntentMonitor, dcmsFlags); |
||
349 | stdTransCMYK = cmsCreateTransform(DocInputProf, TYPE_RGB_16, |
||
350 | DocPrinterProf, TYPE_CMYK_16, |
||
351 | IntentPrinter, |
||
352 | dcmsFlags2); |
||
353 | stdTransRGB = cmsCreateTransform(DocPrinterProf, TYPE_CMYK_16, |
||
354 | DocInputProf, TYPE_RGB_16, |
||
355 | IntentMonitor, |
||
356 | dcmsFlags2); |
||
357 | } |
||
358 | else |
||
359 | { |
||
360 | stdProofCMYK = cmsCreateProofingTransform(DocPrinterProf, TYPE_RGB_16, |
||
361 | DocOutputProf, TYPE_RGB_16, |
||
362 | DocPrinterProf, |
||
363 | IntentPrinter, |
||
364 | IntentMonitor, dcmsFlags); |
||
365 | stdTransCMYK = cmsCreateTransform(DocInputProf, TYPE_RGB_16, |
||
366 | DocPrinterProf, TYPE_RGB_16, |
||
367 | IntentPrinter, |
||
368 | dcmsFlags2); |
||
369 | stdTransRGB = cmsCreateTransform(DocPrinterProf, TYPE_RGB_16, |
||
370 | DocInputProf, TYPE_RGB_16, |
||
371 | IntentMonitor, |
||
372 | dcmsFlags2); |
||
373 | } |
||
1330 | fschmid | 374 | #endif |
375 | } |
||
376 | |||
456 | fschmid | 377 | /* |
378 | * Split out from loadStyles in editFormats.cpp so it's callable from anywhere, |
||
379 | * including plugins. |
||
380 | * - 2004-09-14 Craig Ringer |
||
381 | */ |
||
1065 | cbradney | 382 | void ScribusDoc::loadStylesFromFile(QString fileName, QValueList<ParagraphStyle> *tempStyles) |
456 | fschmid | 383 | { |
1065 | cbradney | 384 | // This won't create the QValueList<ParagraphStyle> will it? |
385 | QValueList<ParagraphStyle> *wrkStyles = NULL; |
||
456 | fschmid | 386 | /* |
387 | * Use the working styles struct if passed, or work directly |
||
388 | * on the document styles otherwise. Note that tempStyles, |
||
389 | * if passed, MUST have the first five styles initialised already |
||
390 | * or this function will segfault. |
||
391 | */ |
||
392 | if (tempStyles != NULL) |
||
393 | wrkStyles = tempStyles; |
||
394 | else |
||
1065 | cbradney | 395 | wrkStyles = &docParagraphStyles; |
456 | fschmid | 396 | if (!fileName.isEmpty()) |
397 | { |
||
398 | ScriXmlDoc *ss = new ScriXmlDoc(); |
||
1065 | cbradney | 399 | ss->docParagraphStyles.clear(); |
456 | fschmid | 400 | for (uint x = 5; x < wrkStyles->count(); ++x) |
1065 | cbradney | 401 | ss->docParagraphStyles.append((*wrkStyles)[x]); |
456 | fschmid | 402 | uint old = wrkStyles->count()-5; |
823 | fschmid | 403 | if (ss->ReadStyles(fileName, this, prefsValues)) |
456 | fschmid | 404 | { |
1065 | cbradney | 405 | if (ss->docParagraphStyles.count() > old) |
456 | fschmid | 406 | { |
1065 | cbradney | 407 | for (uint xx=old; xx<ss->docParagraphStyles.count(); ++xx) |
456 | fschmid | 408 | { |
1065 | cbradney | 409 | struct ParagraphStyle sty; |
410 | sty.Vname = ss->docParagraphStyles[xx].Vname; |
||
411 | sty.LineSpa = ss->docParagraphStyles[xx].LineSpa; |
||
412 | sty.textAlignment = ss->docParagraphStyles[xx].textAlignment; |
||
413 | sty.Indent = ss->docParagraphStyles[xx].Indent; |
||
414 | sty.First = ss->docParagraphStyles[xx].First; |
||
415 | sty.gapBefore = ss->docParagraphStyles[xx].gapBefore; |
||
416 | sty.gapAfter = ss->docParagraphStyles[xx].gapAfter; |
||
417 | sty.Font = ss->docParagraphStyles[xx].Font; |
||
418 | sty.FontSize = ss->docParagraphStyles[xx].FontSize; |
||
419 | sty.TabValues = ss->docParagraphStyles[xx].TabValues; |
||
420 | sty.Drop = ss->docParagraphStyles[xx].Drop; |
||
421 | sty.DropLin = ss->docParagraphStyles[xx].DropLin; |
||
422 | sty.FontEffect = ss->docParagraphStyles[xx].FontEffect; |
||
423 | sty.FColor = ss->docParagraphStyles[xx].FColor; |
||
424 | sty.FShade = ss->docParagraphStyles[xx].FShade; |
||
425 | sty.SColor = ss->docParagraphStyles[xx].SColor; |
||
426 | sty.SShade = ss->docParagraphStyles[xx].SShade; |
||
427 | sty.BaseAdj = ss->docParagraphStyles[xx].BaseAdj; |
||
456 | fschmid | 428 | wrkStyles->append(sty); |
429 | } |
||
430 | } |
||
431 | } |
||
432 | delete ss; |
||
433 | } |
||
434 | } |
||
435 | |||
1179 | tsoots | 436 | void ScribusDoc::lockGuides(bool isLocked) |
437 | { |
||
1180 | tsoots | 438 | if (GuideLock == isLocked) |
439 | return; |
||
1179 | tsoots | 440 | GuideLock = isLocked; |
441 | if (UndoManager::undoEnabled()) |
||
442 | { |
||
443 | QString name; |
||
444 | if (isLocked) |
||
1190 | tsoots | 445 | name = Um::LockGuides; |
1179 | tsoots | 446 | else |
1190 | tsoots | 447 | name = Um::UnlockGuides; |
448 | SimpleState *ss = new SimpleState(name, "", Um::ILockGuides); |
||
1179 | tsoots | 449 | ss->set("GUIDE_LOCK", isLocked); |
450 | undoManager->action(this, ss); |
||
451 | } |
||
452 | } |
||
453 | |||
454 | void ScribusDoc::restore(UndoState* state, bool isUndo) |
||
455 | { |
||
456 | SimpleState *ss = dynamic_cast<SimpleState*>(state); |
||
457 | if (ss) |
||
458 | { |
||
459 | if (ss->contains("GUIDE_LOCK")) |
||
460 | { |
||
461 | if (isUndo) |
||
462 | GuideLock = !ss->getBool("GUIDE_LOCK"); |
||
463 | else |
||
464 | GuideLock = ss->getBool("GUIDE_LOCK"); |
||
465 | } |
||
466 | } |
||
467 | } |
||
468 | |||
469 | void ScribusDoc::setName(const QString& name) |
||
470 | { |
||
471 | DocName = name; |
||
472 | QString uname = name; |
||
473 | if (name.find("/") > -1) |
||
474 | uname = name.right(name.length() - name.findRev("/") - 1); |
||
1190 | tsoots | 475 | if (uname.find(".sl") > -1) |
476 | uname = uname.left(uname.findRev(".sl")); |
||
1179 | tsoots | 477 | setUName(uname); // set the name for the undo object |
478 | } |
||
479 | |||
3 | paul | 480 | void ScribusDoc::setModified() |
481 | { |
||
482 | modified = true; |
||
483 | } |
||
484 | |||
485 | void ScribusDoc::setUnModified() |
||
486 | { |
||
487 | modified = false; |
||
488 | } |
||
489 | |||
490 | bool ScribusDoc::isModified() const |
||
491 | { |
||
492 | return modified; |
||
493 | } |
||
494 | /** Setzt die Seitenattribute */ |
||
80 | Franz | 495 | void ScribusDoc::setPage(double b, double h, double t, double l, double r, double bo, double sp, double ab, bool atf, bool fp) |
3 | paul | 496 | { |
497 | PageB = b; |
||
498 | PageH = h; |
||
499 | PageM.Top = t; |
||
500 | PageM.Left = l; |
||
501 | PageM.Right = r; |
||
502 | PageM.Bottom = bo; |
||
503 | PageSp = sp; |
||
504 | PageSpa = ab; |
||
505 | PageFP = fp; |
||
506 | PageAT = atf; |
||
507 | } |
||
508 | |||
80 | Franz | 509 | void ScribusDoc::resetPage(double t, double l, double r, double bo, bool fp) |
3 | paul | 510 | { |
511 | PageM.Top = t; |
||
512 | PageM.Left = l; |
||
513 | PageM.Right = r; |
||
514 | PageM.Bottom = bo; |
||
515 | PageFP = fp; |
||
516 | } |
||
517 | |||
220 | Franz | 518 | bool ScribusDoc::AddFont(QString name, QFont fo) |
3 | paul | 519 | { |
220 | Franz | 520 | bool ret = false; |
521 | bool error; |
||
3 | paul | 522 | FT_Face face; |
1788 | fschmid | 523 | if (UsedFonts.contains(name)) |
524 | return true; |
||
220 | Franz | 525 | error = FT_New_Face( library, (*AllFonts)[name]->Datei, 0, &face ); |
526 | if (error) |
||
527 | return ret; |
||
528 | if ((*AllFonts)[name]->ReadMetrics()) |
||
167 | Franz | 529 | { |
220 | Franz | 530 | (*AllFonts)[name]->CharWidth[13] = 0; |
249 | Franz | 531 | (*AllFonts)[name]->CharWidth[28] = 0; |
220 | Franz | 532 | (*AllFonts)[name]->CharWidth[9] = 1; |
533 | QString afnm = (*AllFonts)[name]->Datei.left((*AllFonts)[name]->Datei.length()-3); |
||
534 | QFile afm(afnm+"afm"); |
||
3 | paul | 535 | if(!(afm.exists())) |
220 | Franz | 536 | { |
537 | afm.setName(afnm+"Afm"); |
||
538 | if(!(afm.exists())) |
||
539 | afm.setName(afnm+"AFM"); |
||
540 | } |
||
541 | if (afm.exists()) |
||
542 | FT_Attach_File(face, afm.name()); |
||
543 | FFonts[name] = face; |
||
544 | UsedFonts[name] = fo; |
||
545 | ret = true; |
||
167 | Franz | 546 | } |
220 | Franz | 547 | else |
548 | FT_Done_Face( face ); |
||
549 | return ret; |
||
3 | paul | 550 | } |
1694 | cbradney | 551 | |
552 | QStringList ScribusDoc::getItemAttributeNames() |
||
553 | { |
||
554 | QStringList nameList; |
||
555 | |||
556 | for(ObjAttrVector::Iterator it = docItemAttributes.begin(); it!= docItemAttributes.end(); ++it) |
||
557 | nameList.append((*it).name); |
||
558 | return nameList; |
||
1749 | craig | 559 | } |
560 |