Merge lp:~marcelstimberg/ubuntu/precise/scribus/merge-1.4-from-debian into lp:ubuntu/precise/scribus
- Precise (12.04)
- merge-1.4-from-debian
- Merge into precise
Proposed by
Marcel Stimberg
Status: | Merged |
---|---|
Merged at revision: | 30 |
Proposed branch: | lp:~marcelstimberg/ubuntu/precise/scribus/merge-1.4-from-debian |
Merge into: | lp:ubuntu/precise/scribus |
Diff against target: | 525900 lines |
To merge this branch: | bzr merge lp:~marcelstimberg/ubuntu/precise/scribus/merge-1.4-from-debian |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Felix Geyer (community) | Disapprove | ||
Ubuntu branches | Pending | ||
Review via email: mp+92623@code.launchpad.net |
Commit message
Description of the change
This merges the updated debian version that now ships the final 1.4 release instead of the release candidate.
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === removed directory '.pc/0001-qreal-double-fixes.patch' |
2 | === removed directory '.pc/0001-qreal-double-fixes.patch/scribus' |
3 | === removed directory '.pc/0001-qreal-double-fixes.patch/scribus/fonts' |
4 | === removed file '.pc/0001-qreal-double-fixes.patch/scribus/fonts/scfontmetrics.cpp' |
5 | --- .pc/0001-qreal-double-fixes.patch/scribus/fonts/scfontmetrics.cpp 2011-09-11 22:10:03 +0000 |
6 | +++ .pc/0001-qreal-double-fixes.patch/scribus/fonts/scfontmetrics.cpp 1970-01-01 00:00:00 +0000 |
7 | @@ -1,623 +0,0 @@ |
8 | -/* |
9 | -For general Scribus (>=1.3.2) copyright and licensing information please refer |
10 | -to the COPYING file provided with the program. Following this notice may exist |
11 | -a copyright and/or license notice that predates the release of Scribus 1.3.2 |
12 | -for which a new license (GPL+exception) is in place. |
13 | -*/ |
14 | -#include <QColor> |
15 | -#include <QDebug> |
16 | -#include <QMap> |
17 | -#include <QMatrix> |
18 | -#include <QPainter> |
19 | -#include <QPixmap> |
20 | -#include <QRegExp> |
21 | -#include <QStringList> |
22 | - |
23 | -#include "fpoint.h" |
24 | -#include "fpointarray.h" |
25 | -#include "page.h" |
26 | -#include "scfontmetrics.h" |
27 | -#include "scfonts.h" |
28 | -#include "scpainter.h" |
29 | -#include "scribusdoc.h" |
30 | -#include "style.h" |
31 | -#include "util_math.h" |
32 | - |
33 | - |
34 | -// this code contains a set of font related functions |
35 | -// that don't really fit within ScFonts. |
36 | - |
37 | -static FPoint firstP; |
38 | -static bool FirstM; |
39 | -static QMap<FT_ULong, QString> adobeGlyphNames; |
40 | -static const char* table[] = { |
41 | -//#include "glyphnames.txt.q" |
42 | - NULL}; |
43 | - |
44 | -// private functions |
45 | -static void readAdobeGlyphNames(); |
46 | -static QString adobeGlyphName(FT_ULong charcode); |
47 | -static int traceMoveto( FT_Vector *to, FPointArray *composite ); |
48 | -static int traceLineto( FT_Vector *to, FPointArray *composite ); |
49 | -static int traceQuadraticBezier( FT_Vector *control, FT_Vector *to, FPointArray *composite ); |
50 | -static int traceCubicBezier( FT_Vector *p, FT_Vector *q, FT_Vector *to, FPointArray *composite ); |
51 | - |
52 | -FT_Outline_Funcs OutlineMethods = |
53 | - { |
54 | - (FT_Outline_MoveTo_Func) traceMoveto, |
55 | - (FT_Outline_LineTo_Func) traceLineto, |
56 | - (FT_Outline_ConicTo_Func) traceQuadraticBezier, |
57 | - (FT_Outline_CubicTo_Func) traceCubicBezier, |
58 | - 0, |
59 | - 0 |
60 | - }; |
61 | - |
62 | - |
63 | -const qreal FTSCALE = 64.0; |
64 | - |
65 | - |
66 | -int setBestEncoding(FT_Face face) |
67 | -{ |
68 | - FT_ULong charcode; |
69 | - FT_UInt gindex; |
70 | - bool foundEncoding = false; |
71 | - int countUniCode = 0; |
72 | - int chmapUniCode = -1; |
73 | - int chmapCustom = -1; |
74 | - int retVal = 0; |
75 | - //FT_CharMap defaultEncoding = face->charmap; |
76 | -// int defaultchmap=face->charmap ? FT_Get_Charmap_Index(face->charmap) : 0; |
77 | -// Since the above function is only available in FreeType 2.1.10 its replaced by |
78 | -// the following line, assuming that the default charmap has the index 0 |
79 | - int defaultchmap = 0; |
80 | - for(int u = 0; u < face->num_charmaps; u++) |
81 | - { |
82 | - if (face->charmaps[u]->encoding == FT_ENCODING_UNICODE ) |
83 | - { |
84 | - FT_Set_Charmap(face, face->charmaps[u]); |
85 | - chmapUniCode = u; |
86 | - gindex = 0; |
87 | - charcode = FT_Get_First_Char( face, &gindex ); |
88 | - while ( gindex != 0 ) |
89 | - { |
90 | - countUniCode++; |
91 | - charcode = FT_Get_Next_Char( face, charcode, &gindex ); |
92 | - } |
93 | -// qDebug() << "found Unicode enc for" << face->family_name << face->style_name << "as map" << chmapUniCode << "with" << countUniCode << "glyphs"; |
94 | - |
95 | - } |
96 | - if (face->charmaps[u]->encoding == FT_ENCODING_ADOBE_CUSTOM) |
97 | - { |
98 | - chmapCustom = u; |
99 | - foundEncoding = true; |
100 | - retVal = 1; |
101 | -// qDebug() << "found Custom enc for" << face->family_name << face->style_name; |
102 | - break; |
103 | - } |
104 | - else if (face->charmaps[u]->encoding == FT_ENCODING_MS_SYMBOL) |
105 | - { |
106 | -// qDebug() << "found Symbol enc for" << face->family_name << face->style_name; |
107 | - |
108 | - chmapCustom = u; |
109 | - foundEncoding = true; |
110 | - retVal = 2; |
111 | - break; |
112 | - } |
113 | - } |
114 | - int mapToSet=defaultchmap; |
115 | - if (chmapUniCode >= 0 && countUniCode >= face->num_glyphs-1) |
116 | - { |
117 | -// qDebug() << "using Unicode enc for" << face->family_name << face->style_name; |
118 | - |
119 | - mapToSet=chmapUniCode; |
120 | - //FT_Set_Charmap(face, face->charmaps[chmapUniCode]); |
121 | - retVal = 0; |
122 | - } |
123 | - else |
124 | - if (foundEncoding) |
125 | - { |
126 | -// qDebug() << "using special enc for" << face->family_name << face->style_name; |
127 | - mapToSet=chmapCustom; |
128 | - //FT_Set_Charmap(face, face->charmaps[chmapCustom]); |
129 | - } |
130 | - else |
131 | - { |
132 | -// qDebug() << "using default enc for" << face->family_name << face->style_name; |
133 | - mapToSet=defaultchmap; |
134 | - //FT_Set_Charmap(face, defaultEncoding); |
135 | - retVal = 0; |
136 | - } |
137 | - |
138 | - //Fixes #2199, missing glyphs from 1.2.1->1.2.2 |
139 | - //If the currently wanted character map is not already Unicode... |
140 | - //if (FT_Get_Charmap_Index(face->charmap)!=chmapUniCode) |
141 | - if (mapToSet!=chmapUniCode) |
142 | - { |
143 | - //Change map so we can count the chars in it |
144 | - FT_Set_Charmap(face, face->charmaps[mapToSet]); |
145 | - //Count the characters in the current map |
146 | - gindex = 0; |
147 | - int countCurrMap=0; |
148 | - charcode = FT_Get_First_Char( face, &gindex ); |
149 | - while ( gindex != 0 ) |
150 | - { |
151 | - countCurrMap++; |
152 | - charcode = FT_Get_Next_Char( face, charcode, &gindex ); |
153 | - } |
154 | - //If the last Unicode map we found before has more characters, |
155 | - //then set it to be the current map. |
156 | - |
157 | - if (countUniCode>countCurrMap) |
158 | - { |
159 | -// qDebug() << "override with Unicode enc for" << face->family_name << face->style_name << "map" << mapToSet << "has only" << countCurrMap << "glyphs"; |
160 | - mapToSet=chmapUniCode; |
161 | - //FT_Set_Charmap(face, face->charmaps[chmapUniCode]); |
162 | - retVal = 0; |
163 | - } |
164 | - } |
165 | -// if (face->charmap == NULL || mapToSet!=FT_Get_Charmap_Index(face->charmap)) |
166 | - FT_Set_Charmap(face, face->charmaps[mapToSet]); |
167 | -// qDebug() << "set map" << mapToSet << "for" << face->family_name << face->style_name; |
168 | -// qDebug() << "glyphsForNumbers 0-9:" << FT_Get_Char_Index(face, QChar('0').unicode()) |
169 | -// << FT_Get_Char_Index(face, QChar('1').unicode()) << FT_Get_Char_Index(face, QChar('2').unicode()) << FT_Get_Char_Index(face, QChar('3').unicode()) |
170 | -// << FT_Get_Char_Index(face, QChar('4').unicode()) << FT_Get_Char_Index(face, QChar('5').unicode()) << FT_Get_Char_Index(face, QChar('6').unicode()) |
171 | -// << FT_Get_Char_Index(face, QChar('7').unicode()) << FT_Get_Char_Index(face, QChar('8').unicode()) << FT_Get_Char_Index(face, QChar('9').unicode()); |
172 | - return retVal; |
173 | -} |
174 | - |
175 | -FPointArray traceGlyph(FT_Face face, FT_UInt glyphIndex, int chs, qreal *x, qreal *y, bool *err) |
176 | -{ |
177 | - bool error = false; |
178 | - //AV: not threadsave, but tracechar is only used in ReadMetrics() and fontSample() |
179 | - static FPointArray pts; |
180 | - FPointArray pts2; |
181 | - pts.resize(0); |
182 | - pts2.resize(0); |
183 | - firstP = FPoint(0,0); |
184 | - FirstM = true; |
185 | - error = FT_Set_Char_Size( face, 0, chs*6400, 72, 72 ); |
186 | - if (error) |
187 | - { |
188 | - *err = error; |
189 | - return pts2; |
190 | - } |
191 | - if (glyphIndex == 0) |
192 | - { |
193 | - *err = true; |
194 | - return pts2; |
195 | - } |
196 | - error = FT_Load_Glyph( face, glyphIndex, FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP ); |
197 | - if (error) |
198 | - { |
199 | - *err = error; |
200 | - return pts2; |
201 | - } |
202 | - error = FT_Outline_Decompose(&face->glyph->outline, &OutlineMethods, reinterpret_cast<void*>(&pts)); |
203 | - if (error) |
204 | - { |
205 | - *err = error; |
206 | - return pts2; |
207 | - } |
208 | - *x = face->glyph->metrics.horiBearingX / 6400.0; |
209 | - *y = face->glyph->metrics.horiBearingY / 6400.0; |
210 | - QMatrix ma; |
211 | - ma.scale(0.01, -0.01); |
212 | - pts.map(ma); |
213 | - pts.translate(0, chs); |
214 | - pts2.putPoints(0, pts.size()-2, pts, 0); |
215 | - |
216 | - return pts2; |
217 | -} |
218 | - |
219 | - |
220 | -FPointArray traceChar(FT_Face face, uint chr, int chs, qreal *x, qreal *y, bool *err) |
221 | -{ |
222 | - bool error = false; |
223 | - FT_UInt glyphIndex; |
224 | - error = FT_Set_Char_Size( face, 0, chs*64, 72, 72 ); |
225 | - if (error) |
226 | - { |
227 | - *err = error; |
228 | - return FPointArray(); |
229 | - } |
230 | - glyphIndex = FT_Get_Char_Index(face, chr); |
231 | - return traceGlyph(face, glyphIndex, chs, x, y, err); |
232 | -} |
233 | - |
234 | - |
235 | -QPixmap FontSample(const ScFace& fnt, int s, QString ts, QColor back, bool force) |
236 | -{ |
237 | - FT_Face face; |
238 | - FT_Library library; |
239 | - qreal x, y, ymax; |
240 | - bool error; |
241 | - int pen_x; |
242 | - FPoint gp; |
243 | - error = FT_Init_FreeType( &library ); |
244 | - error = FT_New_Face( library, QFile::encodeName(fnt.fontFilePath()), fnt.faceIndex(), &face ); |
245 | - int encode = setBestEncoding(face); |
246 | - qreal uniEM = static_cast<qreal>(face->units_per_EM); |
247 | - |
248 | - qreal m_descent = face->descender / uniEM; |
249 | - qreal m_height = face->height / uniEM; |
250 | - if (m_height == 0) |
251 | - m_height = (face->bbox.yMax - face->bbox.yMin) / uniEM; |
252 | - |
253 | - int h = qRound(m_height * s) + 1; |
254 | - qreal a = m_descent * s + 1; |
255 | - int w = qRound((face->bbox.xMax - face->bbox.xMin) / uniEM) * s * (ts.length()+1); |
256 | - if (w < 1) |
257 | - w = s * (ts.length()+1); |
258 | - if (h < 1) |
259 | - h = s; |
260 | - QImage pm(w, h, QImage::Format_ARGB32); |
261 | - pen_x = 0; |
262 | - ymax = 0.0; |
263 | - ScPainter *p = new ScPainter(&pm, pm.width(), pm.height()); |
264 | - p->clear(back); |
265 | - p->setFillMode(1); |
266 | - p->setLineWidth(0.0); |
267 | -// p->setBrush(back); |
268 | -// p->drawRect(0.0, 0.0, static_cast<qreal>(w), static_cast<qreal>(h)); |
269 | - p->setBrush(Qt::black); |
270 | - FPointArray gly; |
271 | - uint dv; |
272 | - dv = ts[0].unicode(); |
273 | - error = false; |
274 | - gly = traceChar(face, dv, s, &x, &y, &error); |
275 | - if (((encode != 0) || (error)) && (!force)) |
276 | - { |
277 | - error = false; |
278 | - FT_ULong charcode; |
279 | - FT_UInt gindex; |
280 | - gindex = 0; |
281 | - charcode = FT_Get_First_Char(face, &gindex ); |
282 | - for (int n = 0; n < ts.length(); ++n) |
283 | - { |
284 | - gly = traceChar(face, charcode, s, &x, &y, &error); |
285 | - if (error) |
286 | - break; |
287 | - if (gly.size() > 3) |
288 | - { |
289 | - gly.translate(static_cast<qreal>(pen_x) / 6400.0, a); |
290 | - gp = getMaxClipF(&gly); |
291 | - ymax = qMax(ymax, gp.y()); |
292 | - p->setupPolygon(&gly); |
293 | - p->fillPath(); |
294 | - } |
295 | - pen_x += face->glyph->advance.x; |
296 | - charcode = FT_Get_Next_Char(face, charcode, &gindex ); |
297 | - if (gindex == 0) |
298 | - break; |
299 | - } |
300 | - } |
301 | - else |
302 | - { |
303 | - for (int n = 0; n < ts.length(); ++n) |
304 | - { |
305 | - dv = ts[n].unicode(); |
306 | - error = false; |
307 | - gly = traceChar(face, dv, s, &x, &y, &error); |
308 | - if (gly.size() > 3) |
309 | - { |
310 | - gly.translate(static_cast<qreal>(pen_x) / 6400.0, a); |
311 | - gp = getMaxClipF(&gly); |
312 | - ymax = qMax(ymax, gp.y()); |
313 | - p->setupPolygon(&gly); |
314 | - p->fillPath(); |
315 | - } |
316 | - pen_x += face->glyph->advance.x; |
317 | - } |
318 | - } |
319 | - p->end(); |
320 | - QPixmap pmr; |
321 | - pmr=QPixmap::fromImage(pm.copy(0, 0, qMin(qRound(gp.x()), w), qMin(qRound(ymax), h))); |
322 | -// this one below gives some funny results |
323 | -// pmr.convertFromImage(pm.scaled(qMin(qRound(gp.x()), w), qMin(qRound(ymax), h), Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); |
324 | -// pmr.resize(qMin(qRound(gp.x()), w), qMin(qRound(ymax), h)); |
325 | - delete p; |
326 | - FT_Done_FreeType( library ); |
327 | - return pmr; |
328 | -} |
329 | - |
330 | -/** Same as FontSample() with \n strings support added. |
331 | -09/26/2004 petr vanek |
332 | - |
333 | -QPixmap fontSamples(ScFace * fnt, int s, QString ts, QColor back) |
334 | -{ |
335 | - QStringList lines = QStringList::split("\n", ts); |
336 | - QPixmap ret(640, 480); |
337 | - QPixmap sample; |
338 | - QPainter *painter = new QPainter(&ret); |
339 | - int y = 0; |
340 | - int x = 0; |
341 | - ret.fill(back); |
342 | - for ( QStringList::Iterator it = lines.begin(); it != lines.end(); ++it ) |
343 | - { |
344 | - sample = FontSample(fnt, s, *it, back); |
345 | - if (!sample.isNull()) |
346 | - painter->drawPixmap(0, y, sample, 0, 0); |
347 | - y = y + sample.height(); |
348 | - if (x < sample.width()) |
349 | - x = sample.width(); |
350 | - } // for |
351 | - delete(painter); |
352 | - QPixmap final(x, y); |
353 | - if ((x != 0) && (y != 0)) |
354 | - { |
355 | - QPainter *fpainter = new QPainter(&final); |
356 | - fpainter->drawPixmap(0, 0, ret, 0, 0, x, y); |
357 | - delete(fpainter); |
358 | - } |
359 | - return final; |
360 | -} |
361 | -*/ |
362 | - |
363 | -bool GlyNames(FT_Face face, QMap<uint, std::pair<QChar, QString> >& GList) |
364 | -{ |
365 | - char buf[50]; |
366 | - FT_ULong charcode; |
367 | - FT_UInt gindex; |
368 | - setBestEncoding(face); |
369 | - gindex = 0; |
370 | - charcode = FT_Get_First_Char(face, &gindex ); |
371 | - const bool hasPSNames = FT_HAS_GLYPH_NAMES(face); |
372 | - if (adobeGlyphNames.empty()) |
373 | - readAdobeGlyphNames(); |
374 | -// qDebug() << "reading metrics for" << face->family_name << face->style_name; |
375 | - while (gindex != 0) |
376 | - { |
377 | - bool notfound = true; |
378 | - if (hasPSNames) |
379 | - notfound = FT_Get_Glyph_Name(face, gindex, &buf, 50); |
380 | - |
381 | - // just in case FT gives empty string or ".notdef" |
382 | - // no valid glyphname except ".notdef" starts with '.' |
383 | -// qDebug() << "\t" << gindex << " '" << charcode << "' --> '" << (notfound? "notfound" : buf) << "'"; |
384 | - if (notfound || buf[0] == '\0' || buf[0] == '.') |
385 | - GList.insert(gindex, std::make_pair(QChar(static_cast<uint>(charcode)),adobeGlyphName(charcode))); |
386 | - else |
387 | - GList.insert(gindex, std::make_pair(QChar(static_cast<uint>(charcode)),QString(reinterpret_cast<char*>(buf)))); |
388 | - |
389 | - charcode = FT_Get_Next_Char(face, charcode, &gindex ); |
390 | - } |
391 | - // Let's see if we can find some more... |
392 | - int maxSlot1 = face->num_glyphs; |
393 | - if (hasPSNames) |
394 | - for (int gindex = 1; gindex < maxSlot1; ++gindex) |
395 | - { |
396 | - if (!GList.contains(gindex)) |
397 | - { |
398 | - bool found = ! FT_Get_Glyph_Name(face, gindex, &buf, 50); |
399 | - if (found) |
400 | - { |
401 | - QString glyphname(reinterpret_cast<char*>(buf)); |
402 | - charcode = 0; |
403 | - QMap<uint,std::pair<QChar,QString> >::Iterator gli; |
404 | - for (gli = GList.begin(); gli != GList.end(); ++gli) |
405 | - { |
406 | - if (glyphname == gli.value().second) |
407 | - { |
408 | - charcode = gli.value().first.unicode(); |
409 | - break; |
410 | - } |
411 | - } |
412 | -// qDebug() << "\tmore: " << gindex << " '" << charcode << "' --> '" << buf << "'"; |
413 | - GList.insert(gindex, std::make_pair(QChar(static_cast<uint>(charcode)), glyphname)); |
414 | - } |
415 | - } |
416 | - } |
417 | - |
418 | - return true; |
419 | -} |
420 | - |
421 | - |
422 | -static int traceMoveto( FT_Vector *to, FPointArray *composite ) |
423 | -{ |
424 | - qreal tox = ( to->x / FTSCALE ); |
425 | - qreal toy = ( to->y / FTSCALE ); |
426 | - if (!FirstM) |
427 | - { |
428 | - composite->addPoint(firstP); |
429 | - composite->addPoint(firstP); |
430 | - composite->setMarker(); |
431 | - } |
432 | - else |
433 | - FirstM = false; |
434 | - composite->addPoint(tox, toy); |
435 | - composite->addPoint(tox, toy); |
436 | - firstP.setXY(tox, toy); |
437 | - return 0; |
438 | -} |
439 | - |
440 | -static int traceLineto( FT_Vector *to, FPointArray *composite ) |
441 | -{ |
442 | - qreal tox = ( to->x / FTSCALE ); |
443 | - qreal toy = ( to->y / FTSCALE ); |
444 | - if ( !composite->hasLastQuadPoint(tox, toy, tox, toy, tox, toy, tox, toy)) |
445 | - composite->addQuadPoint(tox, toy, tox, toy, tox, toy, tox, toy); |
446 | - return 0; |
447 | -} |
448 | - |
449 | -static int traceQuadraticBezier( FT_Vector *control, FT_Vector *to, FPointArray *composite ) |
450 | -{ |
451 | - qreal x1 = ( control->x / FTSCALE ); |
452 | - qreal y1 = ( control->y / FTSCALE ); |
453 | - qreal x2 = ( to->x / FTSCALE ); |
454 | - qreal y2 = ( to->y / FTSCALE ); |
455 | - if ( !composite->hasLastQuadPoint(x2, y2, x1, y1, x2, y2, x2, y2)) |
456 | - composite->addQuadPoint(x2, y2, x1, y1, x2, y2, x2, y2); |
457 | - return 0; |
458 | -} |
459 | - |
460 | -static int traceCubicBezier( FT_Vector *p, FT_Vector *q, FT_Vector *to, FPointArray *composite ) |
461 | -{ |
462 | - qreal x1 = ( p->x / FTSCALE ); |
463 | - qreal y1 = ( p->y / FTSCALE ); |
464 | - qreal x2 = ( q->x / FTSCALE ); |
465 | - qreal y2 = ( q->y / FTSCALE ); |
466 | - qreal x3 = ( to->x / FTSCALE ); |
467 | - qreal y3 = ( to->y / FTSCALE ); |
468 | - if ( !composite->hasLastQuadPoint(x3, y3, x2, y2, x3, y3, x3, y3) ) |
469 | - { |
470 | - composite->setPoint(composite->size()-1, FPoint(x1, y1)); |
471 | - composite->addQuadPoint(x3, y3, x2, y2, x3, y3, x3, y3); |
472 | - } |
473 | - return 0; |
474 | -} |
475 | - |
476 | -/// init the Adobe Glyph List |
477 | -void readAdobeGlyphNames() |
478 | -{ |
479 | - adobeGlyphNames.clear(); |
480 | - QRegExp pattern("(\\w*);([0-9A-Fa-f]{4})"); |
481 | - for (uint i=0; table[i]; ++i) { |
482 | - if (pattern.indexIn(table[i]) >= 0) { |
483 | - FT_ULong unicode = pattern.cap(2).toULong(0, 16); |
484 | - qDebug() << QString("reading glyph name %1 for unicode %2(%3)").arg(pattern.cap(1)).arg(unicode).arg(pattern.cap(2)); |
485 | - adobeGlyphNames.insert(unicode, pattern.cap(1)); |
486 | - } |
487 | - } |
488 | -} |
489 | - |
490 | - |
491 | -/// if in AGL, use that name, else use "uni1234" or "u12345" |
492 | -QString adobeGlyphName(FT_ULong charcode) |
493 | -{ |
494 | - static const char HEX[] = "0123456789ABCDEF"; |
495 | - QString result; |
496 | - if (adobeGlyphNames.contains(charcode)) |
497 | - return adobeGlyphNames[charcode]; |
498 | - else if (charcode < 0x10000) { |
499 | - result = QString("uni") + HEX[charcode>>12 & 0xF] |
500 | - + HEX[charcode>> 8 & 0xF] |
501 | - + HEX[charcode>> 4 & 0xF] |
502 | - + HEX[charcode & 0xF]; |
503 | - } |
504 | - else { |
505 | - result = QString("u"); |
506 | - for (int i= 28; i >= 0; i-=4) { |
507 | - if (charcode & (0xF << i)) |
508 | - result += HEX[charcode >> i & 0xF]; |
509 | - } |
510 | - } |
511 | - return result; |
512 | -} |
513 | - |
514 | -/* |
515 | -qreal Cwidth(ScribusDoc *, ScFace* scFace, QString ch, int Size, QString ch2) |
516 | -{ |
517 | - qreal width; |
518 | - FT_Vector delta; |
519 | - FT_Face face; |
520 | - uint c1 = ch.at(0).unicode(); |
521 | - uint c2 = ch2.at(0).unicode(); |
522 | - qreal size10=Size/10.0; |
523 | - if (scFace->canRender(ch[0])) |
524 | - { |
525 | - width = scFace->charWidth(ch[0])*size10; |
526 | - face = scFace->ftFace(); |
527 | - /\**** |
528 | - Ok, this looks like a regression between Freetype 2.1.9 -> 2.1.10. |
529 | - Ignoring the value of FT_HAS_KERNING for now -- AV |
530 | - ****\/ |
531 | - if (true || FT_HAS_KERNING(face) ) |
532 | - { |
533 | - uint cl = FT_Get_Char_Index(face, c1); |
534 | - uint cr = FT_Get_Char_Index(face, c2); |
535 | - FT_Error error = FT_Get_Kerning(face, cl, cr, FT_KERNING_UNSCALED, &delta); |
536 | - if (error) { |
537 | - qDebug() << QString("Error %2 when accessing kerning pair for font %1").arg(scFace->scName()).arg(error); |
538 | - } |
539 | - else { |
540 | - qreal uniEM = static_cast<qreal>(face->units_per_EM); |
541 | - width += delta.x / uniEM * size10; |
542 | - } |
543 | - } |
544 | - else { |
545 | - qDebug() << QString("Font %1 has no kerning pairs (according to Freetype)").arg(scFace->scName()); |
546 | - } |
547 | - return width; |
548 | - } |
549 | - else |
550 | - return size10; |
551 | -} |
552 | - |
553 | -qreal RealCWidth(ScribusDoc *, ScFace* scFace, QString ch, int Size) |
554 | -{ |
555 | - qreal w, ww; |
556 | - uint c1 = ch.at(0).unicode(); |
557 | - FT_Face face; |
558 | - if (scFace->canRender(ch.at(0))) |
559 | - { |
560 | - face = scFace->ftFace(); |
561 | - uint cl = FT_Get_Char_Index(face, c1); |
562 | - int error = FT_Load_Glyph(face, cl, FT_LOAD_NO_SCALE | FT_LOAD_NO_BITMAP ); |
563 | - if (!error) { |
564 | - qreal uniEM = static_cast<qreal>(face->units_per_EM); |
565 | - w = (face->glyph->metrics.width + fabs((qreal)face->glyph->metrics.horiBearingX)) / uniEM * (Size / 10.0); |
566 | - ww = face->glyph->metrics.horiAdvance / uniEM * (Size / 10.0); |
567 | - return qMax(ww, w); |
568 | - } |
569 | - else |
570 | - sDebug(QString("internal error: missing glyph: %1 (char %2) error=%3").arg(c1).arg(ch).arg(error)); |
571 | - |
572 | - } |
573 | - return static_cast<qreal>(Size / 10.0); |
574 | -} |
575 | - |
576 | -qreal RealCHeight(ScribusDoc *, ScFace* scFace, QString ch, int Size) |
577 | -{ |
578 | - qreal w; |
579 | - uint c1 = ch.at(0).unicode(); |
580 | - FT_Face face; |
581 | - if (scFace->canRender(ch.at(0))) |
582 | - { |
583 | - face = scFace->ftFace(); |
584 | - uint cl = FT_Get_Char_Index(face, c1); |
585 | - int error = FT_Load_Glyph(face, cl, FT_LOAD_NO_SCALE | FT_LOAD_NO_BITMAP ); |
586 | - if (!error) { |
587 | - qreal uniEM = static_cast<qreal>(face->units_per_EM); |
588 | - w = face->glyph->metrics.height / uniEM * (Size / 10.0); |
589 | - } |
590 | - else { |
591 | - sDebug(QString("internal error: missing glyph: %1 (char %2) error=%3").arg(c1).arg(ch).arg(error)); |
592 | - w = Size / 10.0; |
593 | - } |
594 | - return w; |
595 | - } |
596 | - else |
597 | - return static_cast<qreal>(Size / 10.0); |
598 | -} |
599 | - |
600 | -qreal RealCAscent(ScribusDoc *, ScFace* scFace, QString ch, int Size) |
601 | -{ |
602 | - qreal w; |
603 | - uint c1 = ch.at(0).unicode(); |
604 | - FT_Face face; |
605 | - if (scFace->canRender(ch.at(0))) |
606 | - { |
607 | - face = scFace->ftFace(); |
608 | - uint cl = FT_Get_Char_Index(face, c1); |
609 | - int error = FT_Load_Glyph(face, cl, FT_LOAD_NO_SCALE | FT_LOAD_NO_BITMAP ); |
610 | - if (! error) { |
611 | - qreal uniEM = static_cast<qreal>(face->units_per_EM); |
612 | - w = face->glyph->metrics.horiBearingY / uniEM * (Size / 10.0); |
613 | - } |
614 | - else { |
615 | - sDebug(QString("internal error: missing glyph: %1 (char %2) error=%3").arg(c1).arg(ch).arg(error)); |
616 | - w = Size / 10.0; |
617 | - } |
618 | - return w; |
619 | - } |
620 | - else |
621 | - return static_cast<qreal>(Size / 10.0); |
622 | -} |
623 | - |
624 | -qreal RealFHeight(ScribusDoc *, ScFace* scFace, int Size) |
625 | -{ |
626 | - FT_Face face = scFace->ftFace(); |
627 | - qreal uniEM = static_cast<qreal>(face->units_per_EM); |
628 | - return face->height / uniEM * (Size / 10.0); |
629 | -} |
630 | -*/ |
631 | |
632 | === removed file '.pc/0001-qreal-double-fixes.patch/scribus/pageitem.cpp' |
633 | --- .pc/0001-qreal-double-fixes.patch/scribus/pageitem.cpp 2011-09-11 22:10:03 +0000 |
634 | +++ .pc/0001-qreal-double-fixes.patch/scribus/pageitem.cpp 1970-01-01 00:00:00 +0000 |
635 | @@ -1,5999 +0,0 @@ |
636 | -/* |
637 | -For general Scribus (>=1.3.2) copyright and licensing information please refer |
638 | -to the COPYING file provided with the program. Following this notice may exist |
639 | -a copyright and/or license notice that predates the release of Scribus 1.3.2 |
640 | -for which a new license (GPL+exception) is in place. |
641 | -*/ |
642 | -/*************************************************************************** |
643 | - pageitem.cpp - description |
644 | - ------------------- |
645 | - begin : Sat Apr 7 2001 |
646 | - copyright : (C) 2001 by Franz Schmid |
647 | - email : Franz.Schmid@altmuehlnet.de |
648 | - ***************************************************************************/ |
649 | - |
650 | -/*************************************************************************** |
651 | - * * |
652 | - * This program is free software; you can redistribute it and/or modify * |
653 | - * it under the terms of the GNU General Public License as published by * |
654 | - * the Free Software Foundation; either version 2 of the License, or * |
655 | - * (at your option) any later version. * |
656 | - * * |
657 | - ***************************************************************************/ |
658 | - |
659 | -#include "pageitem.h" |
660 | -#include <QPainter> |
661 | -#include <QPen> |
662 | -#include <QFont> |
663 | -#include <QRegion> |
664 | -#include <QPoint> |
665 | -#include <QFileInfo> |
666 | -#include <qdrawutil.h> |
667 | -#include <QRegExp> |
668 | -#include <QMessageBox> |
669 | -#include <QPolygon> |
670 | -#include <cassert> |
671 | -#include <QDebug> |
672 | -#include <iostream> |
673 | -#include <sstream> |
674 | -#include <string> |
675 | - |
676 | -#include "canvas.h" |
677 | -#include "cmsettings.h" |
678 | -#include "colorblind.h" |
679 | -#include "commonstrings.h" |
680 | -#include "cpalette.h" |
681 | -#include "guidemanager.h" |
682 | -#include "page.h" |
683 | -#include "pageitem_latexframe.h" |
684 | -#include "pageitem_textframe.h" |
685 | -#include "prefsmanager.h" |
686 | -#include "propertiespalette.h" |
687 | -#include "resourcecollection.h" |
688 | -#include "scclocale.h" |
689 | -#include "sccolorengine.h" |
690 | -#include "scconfig.h" |
691 | -#include "scpainter.h" |
692 | -#include "scpaths.h" |
693 | -#include "scpattern.h" |
694 | -#include "scribus.h" |
695 | -#include "scribusapp.h" |
696 | -#include "scribuscore.h" |
697 | -#include "scribusdoc.h" |
698 | -#include "scribusstructs.h" |
699 | -#include "scribuswin.h" |
700 | -#include "sctextstream.h" |
701 | -#include "serializer.h" |
702 | -#include "selection.h" |
703 | -#include "sclimits.h" |
704 | -#include "text/nlsconfig.h" |
705 | -#include "desaxe/saxXML.h" |
706 | -#include "undomanager.h" |
707 | -#include "undostate.h" |
708 | -#include "util.h" |
709 | -#include "util_formats.h" |
710 | -#include "util_math.h" |
711 | -#include "util_text.h" |
712 | -#include "util_file.h" |
713 | -#ifdef HAVE_CAIRO |
714 | - #include <cairo.h> |
715 | -#endif |
716 | - |
717 | -using namespace std; |
718 | - |
719 | -PageItem::PageItem(const PageItem & other) |
720 | - : QObject(other.parent()), |
721 | - UndoObject(other), SingleObservable<PageItem>(other.m_Doc->itemsChanged()), |
722 | - |
723 | -// 200 attributes! That is madness, or to quote some famous people from Kriquet: |
724 | -// "THAT ALL HAS TO GO!" |
725 | - gXpos(other.gXpos), |
726 | - gYpos(other.gYpos), |
727 | - gWidth(other.gWidth), |
728 | - gHeight(other.gHeight), |
729 | - GrType(other.GrType), |
730 | - GrStartX(other.GrStartX), |
731 | - GrStartY(other.GrStartY), |
732 | - GrEndX(other.GrEndX), |
733 | - GrEndY(other.GrEndY), |
734 | - Cols(other.Cols), |
735 | - ColGap(other.ColGap), |
736 | - PLineArt(other.PLineArt), |
737 | - PLineEnd(other.PLineEnd), |
738 | - PLineJoin(other.PLineJoin), |
739 | - NamedLStyle(other.NamedLStyle), |
740 | - Clip(other.Clip), |
741 | - PoLine(other.PoLine), |
742 | - ContourLine(other.ContourLine), |
743 | - imageClip(other.imageClip), |
744 | - Segments(other.Segments), |
745 | - effectsInUse(other.effectsInUse), |
746 | - PoShow(other.PoShow), |
747 | - BaseOffs(other.BaseOffs), |
748 | - textPathType(other.textPathType), |
749 | - textPathFlipped(other.textPathFlipped), |
750 | - ClipEdited(other.ClipEdited), |
751 | - FrameType(other.FrameType), |
752 | - ItemNr(other.ItemNr), |
753 | - Frame(other.Frame), |
754 | - OwnPage(other.OwnPage), |
755 | - oldOwnPage(other.oldOwnPage), |
756 | - pixm(other.pixm), |
757 | - Pfile(other.Pfile), |
758 | - Pfile2(other.Pfile2), |
759 | - Pfile3(other.Pfile3), |
760 | - IProfile(other.IProfile), |
761 | - UseEmbedded(other.UseEmbedded), |
762 | - EmProfile(other.EmProfile), |
763 | - IRender(other.IRender), |
764 | - |
765 | - PictureIsAvailable(other.PictureIsAvailable), |
766 | - OrigW(other.OrigW), |
767 | - OrigH(other.OrigH), |
768 | - BBoxX(other.BBoxX), |
769 | - BBoxH(other.BBoxH), |
770 | - CurX(other.CurX), |
771 | - CurY(other.CurY), |
772 | - CPos(other.CPos), |
773 | - itemText(other.itemText), |
774 | - isBookmark(other.isBookmark), |
775 | - HasSel(other.HasSel), |
776 | -// Tinput(other.Tinput), |
777 | - isAutoText(other.isAutoText), |
778 | - BackBox(NULL), // otherwise other.BackBox->NextBox would be inconsistent |
779 | - NextBox(NULL), // otherwise other.NextBox->BackBox would be inconsistent |
780 | - firstChar(0), // since this box is unlinked now |
781 | - MaxChars(0), // since the layout is invalid now |
782 | - inPdfArticle(other.inPdfArticle), |
783 | - isRaster(other.isRaster), |
784 | - OldB(other.OldB), |
785 | - OldH(other.OldH), |
786 | - OldB2(other.OldB2), |
787 | - OldH2(other.OldH2), |
788 | - Sizing(other.Sizing), |
789 | - toPixmap(other.toPixmap), |
790 | - LayerNr(other.LayerNr), |
791 | - ScaleType(other.ScaleType), |
792 | - AspectRatio(other.AspectRatio), |
793 | - Groups(other.Groups), |
794 | - DashValues(other.DashValues), |
795 | - DashOffset(other.DashOffset), |
796 | - fill_gradient(other.fill_gradient), |
797 | - fillRule(other.fillRule), |
798 | - doOverprint(other.doOverprint), |
799 | - LeftLink(other.LeftLink), |
800 | - RightLink(other.RightLink), |
801 | - TopLink(other.TopLink), |
802 | - BottomLink(other.BottomLink), |
803 | - LeftLinkID(other.LeftLinkID), |
804 | - RightLinkID(other.RightLinkID), |
805 | - TopLinkID(other.TopLinkID), |
806 | - BottomLinkID(other.BottomLinkID), |
807 | - LeftLine(other.LeftLine), |
808 | - RightLine(other.RightLine), |
809 | - TopLine(other.TopLine), |
810 | - BottomLine(other.BottomLine), |
811 | - isTableItem(other.isTableItem), |
812 | - isSingleSel(other.isSingleSel), |
813 | - isGroupControl(other.isGroupControl), |
814 | - groupsLastItem(other.groupsLastItem), |
815 | - BoundingX(other.BoundingX), |
816 | - BoundingY(other.BoundingY), |
817 | - BoundingW(other.BoundingW), |
818 | - BoundingH(other.BoundingH), |
819 | - ChangedMasterItem(other.ChangedMasterItem), |
820 | - OnMasterPage(other.OnMasterPage), |
821 | - isEmbedded(other.isEmbedded), |
822 | - |
823 | - // protected |
824 | - undoManager(other.undoManager), |
825 | - m_ItemType(other.m_ItemType), |
826 | - AnName(other.AnName), |
827 | - patternVal(other.patternVal), |
828 | - patternScaleX(other.patternScaleX), |
829 | - patternScaleY(other.patternScaleY), |
830 | - patternOffsetX(other.patternOffsetX), |
831 | - patternOffsetY(other.patternOffsetY), |
832 | - patternRotation(other.patternRotation), |
833 | - fillColorVal(other.fillColorVal), |
834 | - lineColorVal(other.lineColorVal), |
835 | - lineShadeVal(other.lineShadeVal), |
836 | - fillShadeVal(other.fillShadeVal), |
837 | - fillTransparencyVal(other.fillTransparencyVal), |
838 | - lineTransparencyVal(other.lineTransparencyVal), |
839 | - fillBlendmodeVal(other.fillBlendmodeVal), |
840 | - lineBlendmodeVal(other.lineBlendmodeVal), |
841 | - m_ImageIsFlippedH(other.m_ImageIsFlippedH), |
842 | - m_ImageIsFlippedV(other.m_ImageIsFlippedV), |
843 | - m_Locked(other.m_Locked), |
844 | - m_SizeLocked(other.m_SizeLocked), |
845 | - textFlowModeVal(other.textFlowModeVal), |
846 | - pageItemAttributes(other.pageItemAttributes), |
847 | - m_PrintEnabled(other.m_PrintEnabled), |
848 | - tagged(other.tagged), |
849 | - fillQColor(other.fillQColor), |
850 | - strokeQColor(other.strokeQColor), |
851 | - Xpos(other.Xpos), |
852 | - Ypos(other.Ypos), |
853 | - Width(other.Width), |
854 | - Height(other.Height), |
855 | - Rot(other.Rot), |
856 | - Select(other.Select), |
857 | - LocalScX(other.LocalScX), |
858 | - LocalScY(other.LocalScY), |
859 | - LocalX(other.LocalX), |
860 | - LocalY(other.LocalY), |
861 | - Reverse(other.Reverse), |
862 | - m_startArrowIndex(other.m_startArrowIndex), |
863 | - m_endArrowIndex(other.m_endArrowIndex), |
864 | - Extra(other.Extra), |
865 | - TExtra(other.TExtra), |
866 | - BExtra(other.BExtra), |
867 | - RExtra(other.RExtra), |
868 | - firstLineOffsetP(other.firstLineOffsetP), |
869 | - RadRect(other.RadRect), |
870 | - oldXpos(other.oldXpos), |
871 | - oldYpos(other.oldYpos), |
872 | - oldWidth(other.oldWidth), |
873 | - oldHeight(other.oldHeight), |
874 | - oldRot(other.oldRot), |
875 | - oldLocalScX(other.oldLocalScX), |
876 | - oldLocalScY(other.oldLocalScY), |
877 | - oldLocalX(other.oldLocalX), |
878 | - oldLocalY(other.oldLocalY), |
879 | - m_Doc(other.m_Doc), |
880 | - m_isAnnotation(other.m_isAnnotation), |
881 | - m_annotation(other.m_annotation), |
882 | - PicArt(other.PicArt), |
883 | - m_lineWidth(other.m_lineWidth), |
884 | - Oldm_lineWidth(other.Oldm_lineWidth) |
885 | -{ |
886 | - QString tmp; |
887 | - m_Doc->TotalItems++; |
888 | - AnName += tmp.setNum(m_Doc->TotalItems); |
889 | - uniqueNr = m_Doc->TotalItems; |
890 | - invalid = true; |
891 | - if (other.isInlineImage) |
892 | - { |
893 | - QFileInfo inlFi(Pfile); |
894 | - QString ext = inlFi.suffix(); |
895 | - tempImageFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_XXXXXX." + ext); |
896 | - tempImageFile->open(); |
897 | - QString fileName = getLongPathName(tempImageFile->fileName()); |
898 | - tempImageFile->close(); |
899 | - copyFile(Pfile, fileName); |
900 | - Pfile = fileName; |
901 | - isInlineImage = true; |
902 | - } |
903 | - else |
904 | - { |
905 | - tempImageFile = NULL; |
906 | - isInlineImage = false; |
907 | - } |
908 | -} |
909 | - |
910 | - |
911 | -PageItem::PageItem(ScribusDoc *pa, ItemType newType, double x, double y, double w, double h, double w2, QString fill, QString outline) |
912 | - // Initialize superclass(es) |
913 | - : QObject(pa), SingleObservable<PageItem>(pa->itemsChanged()), |
914 | - // Initialize member variables |
915 | - itemText(pa), |
916 | - undoManager(UndoManager::instance()), |
917 | - lineShadeVal(100), |
918 | - fillShadeVal(100), |
919 | - fillTransparencyVal(0.0), |
920 | - lineTransparencyVal(0.0), |
921 | - fillBlendmodeVal(0), |
922 | - lineBlendmodeVal(0), |
923 | - m_ImageIsFlippedH(0), |
924 | - m_ImageIsFlippedV(0), |
925 | - m_Locked(false), |
926 | - m_SizeLocked(false), |
927 | - textFlowModeVal(TextFlowDisabled) |
928 | -{ |
929 | - m_Doc = pa; |
930 | - QString tmp; |
931 | - BackBox = 0; |
932 | - NextBox = 0; |
933 | - oldXpos = Xpos = x; |
934 | - oldYpos = Ypos = y; |
935 | - //CB Surely we can remove some of these? |
936 | - OldB2 = OldB = oldWidth = Width = w; |
937 | - OldH2 = OldH = oldHeight = Height = h; |
938 | - BoundingX = x; |
939 | - BoundingY = y; |
940 | - BoundingW = w; |
941 | - BoundingH = h; |
942 | - m_ItemType = newType; |
943 | - oldRot = Rot = 0; |
944 | - fillColorVal = fill; |
945 | - lineColorVal = m_ItemType == PageItem::TextFrame ? fill : outline; |
946 | - gXpos = gYpos = 0; |
947 | - gWidth = gHeight = 0; |
948 | - GrType = 0; |
949 | - GrStartX = 0; |
950 | - GrStartY = 0; |
951 | - GrEndX = w; |
952 | - GrEndY = 0; |
953 | - patternVal = ""; |
954 | - patternScaleX = 100; |
955 | - patternScaleY = 100; |
956 | - patternOffsetX = 0; |
957 | - patternOffsetY = 0; |
958 | - patternRotation = 0; |
959 | - m_lineWidth = w2; |
960 | - Oldm_lineWidth = w2; |
961 | - PLineArt = Qt::PenStyle(m_Doc->toolSettings.dLineArt); |
962 | - PLineEnd = Qt::FlatCap; |
963 | - PLineJoin = Qt::MiterJoin; |
964 | - Select = false; |
965 | - ClipEdited = false; |
966 | - FrameType = 0; |
967 | - CurX = 0; |
968 | - CurY = 0; |
969 | - CPos = 0; |
970 | - oldCPos = 0; |
971 | - Extra = 0; |
972 | - TExtra = 0; |
973 | - BExtra = 0; |
974 | - RExtra = 0; |
975 | - firstChar = 0; |
976 | - MaxChars = 0; |
977 | - Pfile = ""; |
978 | - pixm = ScImage(); |
979 | - pixm.imgInfo.lowResType = m_Doc->toolSettings.lowResType; |
980 | - Pfile2 = ""; |
981 | - Pfile3 = ""; |
982 | - oldLocalScX = LocalScX = 1; |
983 | - oldLocalScY = LocalScY = 1; |
984 | - OrigW = 0; |
985 | - OrigH = 0; |
986 | - oldLocalX = LocalX = 0; |
987 | - oldLocalY = LocalY = 0; |
988 | - BBoxX = 0; |
989 | - BBoxH = 0; |
990 | - RadRect = 0; |
991 | - if ((m_ItemType == TextFrame) || (m_ItemType == ImageFrame) || (m_ItemType == PathText)) |
992 | - // TODO: Frame should become a read-only calculated property |
993 | - Frame = true; |
994 | - else |
995 | - Frame = false; |
996 | - switch (m_ItemType) |
997 | - { |
998 | - case Polygon: |
999 | - Clip.setPoints(4, static_cast<int>(w/2), 0, static_cast<int>(w), static_cast<int>(h/2), |
1000 | - static_cast<int>(w/2), static_cast<int>(h), 0,static_cast<int>(h/2)); |
1001 | - break; |
1002 | - default: |
1003 | - Clip.setPoints(4, 0,0, static_cast<int>(w),0, static_cast<int>(w), static_cast<int>(h), 0,static_cast<int>(h)); |
1004 | - break; |
1005 | - } |
1006 | - PoLine.resize(0); |
1007 | - ContourLine.resize(0); |
1008 | - imageClip.resize(0); |
1009 | - Segments.clear(); |
1010 | - PoShow = false; |
1011 | - BaseOffs = 0; |
1012 | - textPathType = 0; |
1013 | - textPathFlipped = false; |
1014 | - OwnPage = m_Doc->currentPage()->pageNr(); |
1015 | - oldOwnPage = OwnPage; |
1016 | - savedOwnPage = OwnPage; |
1017 | - PicArt = true; |
1018 | - PictureIsAvailable = false; |
1019 | - m_PrintEnabled = true; |
1020 | - isBookmark = false; |
1021 | - m_isAnnotation = false; |
1022 | - |
1023 | - switch (m_ItemType) |
1024 | - { |
1025 | - case ImageFrame: |
1026 | - case LatexFrame: |
1027 | - //We can't determine if this is a latex frame here |
1028 | - // because c++'s typeinfos are still saying it's |
1029 | - // a plain pageitem |
1030 | - // This is fixed in the PageItem_LatexFrame constructor |
1031 | - AnName = tr("Image"); |
1032 | - setUPixmap(Um::IImageFrame); |
1033 | - break; |
1034 | - case TextFrame: |
1035 | - AnName = tr("Text"); |
1036 | - setUPixmap(Um::ITextFrame); |
1037 | - break; |
1038 | - case Line: |
1039 | - AnName = tr("Line"); |
1040 | - setUPixmap(Um::ILine); |
1041 | - break; |
1042 | - case Polygon: |
1043 | - AnName = tr("Polygon"); |
1044 | - setUPixmap(Um::IPolygon); |
1045 | - break; |
1046 | - case PolyLine: |
1047 | - AnName = tr("Polyline"); |
1048 | - setUPixmap(Um::IPolyline); |
1049 | - break; |
1050 | - case PathText: |
1051 | - AnName = tr("PathText"); |
1052 | - setUPixmap(Um::IPathText); |
1053 | - break; |
1054 | - default: |
1055 | - AnName = "Item"; |
1056 | - break; |
1057 | - } |
1058 | - m_Doc->TotalItems++; |
1059 | - AnName += tmp.setNum(m_Doc->TotalItems); // +" "+QDateTime::currentDateTime().toString(); |
1060 | - uniqueNr = m_Doc->TotalItems; |
1061 | - AutoName = true; |
1062 | - setUName(AnName); |
1063 | - m_annotation.setBorderColor(outline); |
1064 | - HasSel = false; |
1065 | -// Tinput = false; |
1066 | - isAutoText = false; |
1067 | - inPdfArticle = false; |
1068 | - isRaster = false; |
1069 | - Sizing = false; |
1070 | - toPixmap = false; |
1071 | - UseEmbedded = true; |
1072 | - IRender = Intent_Relative_Colorimetric; |
1073 | - EmProfile = ""; |
1074 | - Groups.clear(); |
1075 | - LayerNr = m_Doc->activeLayer(); |
1076 | - ScaleType = true; |
1077 | - AspectRatio = true; |
1078 | - Reverse = false; |
1079 | - NamedLStyle = ""; |
1080 | - DashValues.clear(); |
1081 | - DashOffset = 0; |
1082 | - fillRule = true; |
1083 | - doOverprint = false; |
1084 | - fill_gradient = VGradient(VGradient::linear); |
1085 | - fill_gradient.clearStops(); |
1086 | - if (fillColorVal != CommonStrings::None) |
1087 | - { |
1088 | - const ScColor& col = m_Doc->PageColors[fillColorVal]; |
1089 | - QColor qcol = ScColorEngine::getRGBColor(col, m_Doc); |
1090 | - fill_gradient.addStop(qcol, 0.0, 0.5, 1.0, fillColorVal, 100); |
1091 | - fill_gradient.addStop(qcol, 1.0, 0.5, 1.0, fillColorVal, 100); |
1092 | - } |
1093 | - else |
1094 | - { |
1095 | - if (m_Doc->toolSettings.dBrush != CommonStrings::None) |
1096 | - { |
1097 | - const ScColor& col = m_Doc->PageColors[m_Doc->toolSettings.dBrush]; |
1098 | - QColor qcol = ScColorEngine::getRGBColor(col, m_Doc); |
1099 | - fill_gradient.addStop(qcol, 0.0, 0.5, 1.0, m_Doc->toolSettings.dBrush, 100); |
1100 | - fill_gradient.addStop(qcol, 1.0, 0.5, 1.0, m_Doc->toolSettings.dBrush, 100); |
1101 | - } |
1102 | - else |
1103 | - { |
1104 | - if (lineColorVal != CommonStrings::None) |
1105 | - { |
1106 | - const ScColor& col = m_Doc->PageColors[lineColorVal]; |
1107 | - QColor qcol = ScColorEngine::getRGBColor(col, m_Doc); |
1108 | - fill_gradient.addStop(qcol, 0.0, 0.5, 1.0, lineColorVal, 100); |
1109 | - fill_gradient.addStop(qcol, 1.0, 0.5, 1.0, lineColorVal, 100); |
1110 | - } |
1111 | - else |
1112 | - { |
1113 | - if (m_Doc->toolSettings.dPen != CommonStrings::None) |
1114 | - { |
1115 | - const ScColor& col = m_Doc->PageColors[m_Doc->toolSettings.dPen]; |
1116 | - QColor qcol = ScColorEngine::getRGBColor(col, m_Doc); |
1117 | - fill_gradient.addStop(qcol, 0.0, 0.5, 1.0, m_Doc->toolSettings.dPen, 100); |
1118 | - fill_gradient.addStop(qcol, 1.0, 0.5, 1.0, m_Doc->toolSettings.dPen, 100); |
1119 | - } |
1120 | - else if (m_Doc->PageColors.contains("Black")) |
1121 | - { |
1122 | - const ScColor& col = m_Doc->PageColors["Black"]; |
1123 | - QColor qcol = ScColorEngine::getRGBColor(col, m_Doc); |
1124 | - fill_gradient.addStop(qcol, 0.0, 0.5, 1.0, "Black", 100); |
1125 | - fill_gradient.addStop(qcol, 1.0, 0.5, 1.0, "Black", 100); |
1126 | - } |
1127 | - } |
1128 | - } |
1129 | - } |
1130 | - firstLineOffsetP = FLOPRealGlyphHeight; |
1131 | - Cols = m_Doc->toolSettings.dCols; |
1132 | - ColGap = m_Doc->toolSettings.dGap; |
1133 | - LeftLink = 0; |
1134 | - RightLink = 0; |
1135 | - TopLink = 0; |
1136 | - BottomLink = 0; |
1137 | - LeftLinkID = 0; |
1138 | - RightLinkID = 0; |
1139 | - TopLinkID = 0; |
1140 | - BottomLinkID = 0; |
1141 | - LeftLine = 0; |
1142 | - RightLine = false; |
1143 | - TopLine = false; |
1144 | - BottomLine = false; |
1145 | - isTableItem = false; |
1146 | - isSingleSel = false; |
1147 | - Dirty = false; |
1148 | - invalid = true; |
1149 | - isGroupControl = false; |
1150 | - groupsLastItem = 0; |
1151 | - ChangedMasterItem = false; |
1152 | - isEmbedded = false; |
1153 | - OnMasterPage = m_Doc->currentPage()->pageName(); |
1154 | - m_startArrowIndex = m_Doc->toolSettings.dStartArrow; |
1155 | - m_endArrowIndex = m_Doc->toolSettings.dEndArrow; |
1156 | - effectsInUse.clear(); |
1157 | - //Page Item Attributes |
1158 | - pageItemAttributes.clear(); |
1159 | - for(ObjAttrVector::Iterator objAttrIt = m_Doc->docItemAttributes.begin() ; objAttrIt != m_Doc->docItemAttributes.end(); ++objAttrIt ) |
1160 | - { |
1161 | - if (((*objAttrIt).autoaddto=="textframes" && m_ItemType==TextFrame) || |
1162 | - ((*objAttrIt).autoaddto=="imageframes" && m_ItemType==ImageFrame) |
1163 | - ) |
1164 | - pageItemAttributes.append(*objAttrIt); |
1165 | - } |
1166 | - tempImageFile = NULL; |
1167 | - isInlineImage = false; |
1168 | -} |
1169 | - |
1170 | -void PageItem::setXPos(const double newXPos, bool drawingOnly) |
1171 | -{ |
1172 | - Xpos = newXPos; |
1173 | - if (drawingOnly || m_Doc->isLoading()) |
1174 | - return; |
1175 | - checkChanges(); |
1176 | - emit position(Xpos, Ypos); |
1177 | -} |
1178 | - |
1179 | -void PageItem::setYPos(const double newYPos, bool drawingOnly) |
1180 | -{ |
1181 | - Ypos = newYPos; |
1182 | - if (drawingOnly || m_Doc->isLoading()) |
1183 | - return; |
1184 | - checkChanges(); |
1185 | - emit position(Xpos, Ypos); |
1186 | -} |
1187 | - |
1188 | -void PageItem::setXYPos(const double newXPos, const double newYPos, bool drawingOnly) |
1189 | -{ |
1190 | - Xpos = newXPos; |
1191 | - Ypos = newYPos; |
1192 | - if (drawingOnly || m_Doc->isLoading()) |
1193 | - return; |
1194 | - checkChanges(); |
1195 | - emit position(Xpos, Ypos); |
1196 | -} |
1197 | - |
1198 | -void PageItem::moveBy(const double dX, const double dY, bool drawingOnly) |
1199 | -{ |
1200 | - if (dX==0.0 && dY==0.0) |
1201 | - return; |
1202 | - invalid = true; |
1203 | - if (dX!=0.0) |
1204 | - Xpos+=dX; |
1205 | - if (dY!=0.0) |
1206 | - Ypos+=dY; |
1207 | - if (drawingOnly || m_Doc->isLoading()) |
1208 | - return; |
1209 | - checkChanges(); |
1210 | - emit position(Xpos, Ypos); |
1211 | -} |
1212 | - |
1213 | -void PageItem::setWidth(const double newWidth) |
1214 | -{ |
1215 | - Width = newWidth; |
1216 | - updateConstants(); |
1217 | - checkChanges(); |
1218 | - emit widthAndHeight(Width, Height); |
1219 | -} |
1220 | - |
1221 | -void PageItem::setHeight(const double newHeight) |
1222 | -{ |
1223 | - Height = newHeight; |
1224 | - updateConstants(); |
1225 | - checkChanges(); |
1226 | - emit widthAndHeight(Width, Height); |
1227 | -} |
1228 | - |
1229 | -void PageItem::setWidthHeight(const double newWidth, const double newHeight, bool drawingOnly) |
1230 | -{ |
1231 | - Width = newWidth; |
1232 | - Height = newHeight; |
1233 | - updateConstants(); |
1234 | - if (drawingOnly) |
1235 | - return; |
1236 | - checkChanges(); |
1237 | - emit widthAndHeight(Width, Height); |
1238 | -} |
1239 | - |
1240 | -void PageItem::setWidthHeight(const double newWidth, const double newHeight) |
1241 | -{ |
1242 | - Width = newWidth; |
1243 | - Height = newHeight; |
1244 | - updateConstants(); |
1245 | - checkChanges(); |
1246 | - emit widthAndHeight(Width, Height); |
1247 | -} |
1248 | - |
1249 | -void PageItem::resizeBy(const double dH, const double dW) |
1250 | -{ |
1251 | - if (dH==0.0 && dW==0.0) |
1252 | - return; |
1253 | - if (dH!=0.0) |
1254 | - Width+=dH; |
1255 | - if (dW!=0.0) |
1256 | - Height+=dW; |
1257 | - updateConstants(); |
1258 | - checkChanges(); |
1259 | - emit widthAndHeight(Width, Height); |
1260 | -} |
1261 | - |
1262 | -void PageItem::setRotation(const double newRotation, bool drawingOnly) |
1263 | -{ |
1264 | - Rot=newRotation; |
1265 | - checkChanges(); |
1266 | - if (drawingOnly || m_Doc->isLoading()) |
1267 | - return; |
1268 | - emit rotation(Rot); |
1269 | -} |
1270 | - |
1271 | -void PageItem::rotateBy(const double dR) |
1272 | -{ |
1273 | - if (dR==0.0) |
1274 | - return; |
1275 | - Rot+=dR; |
1276 | - checkChanges(); |
1277 | - emit rotation(Rot); |
1278 | -} |
1279 | - |
1280 | -void PageItem::setSelected(const bool toSelect) |
1281 | -{ |
1282 | - Select=toSelect; |
1283 | -} |
1284 | - |
1285 | -void PageItem::setImageXScale(const double newImageXScale) |
1286 | -{ |
1287 | - LocalScX=newImageXScale; |
1288 | - checkChanges(); |
1289 | - emit imageOffsetScale(LocalScX, LocalScY, LocalX, LocalY); |
1290 | -} |
1291 | - |
1292 | -void PageItem::setImageYScale(const double newImageYScale) |
1293 | -{ |
1294 | - LocalScY=newImageYScale; |
1295 | - checkChanges(); |
1296 | - emit imageOffsetScale(LocalScX, LocalScY, LocalX, LocalY); |
1297 | -} |
1298 | - |
1299 | -void PageItem::setImageXYScale(const double newImageXScale, const double newImageYScale) |
1300 | -{ |
1301 | - LocalScX=newImageXScale; |
1302 | - LocalScY=newImageYScale; |
1303 | - checkChanges(); |
1304 | - emit imageOffsetScale(LocalScX, LocalScY, LocalX, LocalY); |
1305 | -} |
1306 | - |
1307 | -void PageItem::setImageXOffset(const double newImageXOffset) |
1308 | -{ |
1309 | - LocalX=newImageXOffset; |
1310 | - checkChanges(); |
1311 | - emit imageOffsetScale(LocalScX, LocalScY, LocalX, LocalY); |
1312 | -} |
1313 | - |
1314 | -void PageItem::setImageYOffset(const double newImageYOffset) |
1315 | -{ |
1316 | - LocalY=newImageYOffset; |
1317 | - checkChanges(); |
1318 | - emit imageOffsetScale(LocalScX, LocalScY, LocalX, LocalY); |
1319 | -} |
1320 | - |
1321 | -void PageItem::setImageXYOffset(const double newImageXOffset, const double newImageYOffset) |
1322 | -{ |
1323 | - LocalX=newImageXOffset; |
1324 | - LocalY=newImageYOffset; |
1325 | - checkChanges(); |
1326 | - emit imageOffsetScale(LocalScX, LocalScY, LocalX, LocalY); |
1327 | -} |
1328 | - |
1329 | -void PageItem::moveImageXYOffsetBy(const double dX, const double dY) |
1330 | -{ |
1331 | - if (dX==0.0 && dY==0.0) |
1332 | - return; |
1333 | - if (dX!=0.0) |
1334 | - LocalX+=dX; |
1335 | - if (dY!=0.0) |
1336 | - LocalY+=dY; |
1337 | - checkChanges(); |
1338 | - emit imageOffsetScale(LocalScX, LocalScY, LocalX, LocalY); |
1339 | -} |
1340 | - |
1341 | -void PageItem::setReversed(bool newReversed) |
1342 | -{ |
1343 | - Reverse=newReversed; |
1344 | -} |
1345 | - |
1346 | - |
1347 | -/// returns true if text overflows |
1348 | -bool PageItem::frameOverflows() const |
1349 | -{ |
1350 | -#ifndef NLS_PROTO |
1351 | - // Fix #6991 : "Text overflow" warning when there is a text underflow in fact |
1352 | - /*return NextBox == NULL && itemText.length() > static_cast<int>(MaxChars);*/ |
1353 | - return ( NextBox == NULL ) |
1354 | - && ( static_cast<int> ( firstChar ) < itemText.length() ) |
1355 | - // Fix #7766 : scribus.textOverflows() returns 0 if there is no place for the overflow mark |
1356 | - /*&& ( firstChar < MaxChars )*/ |
1357 | - && ( firstChar <= MaxChars ) |
1358 | - && ( itemText.length() > static_cast<int> ( MaxChars ) ); |
1359 | -#else |
1360 | - return false; // FIXME:NLS |
1361 | -#endif |
1362 | -} |
1363 | - |
1364 | -int PageItem::firstInFrame() const |
1365 | -{ |
1366 | - return firstChar; |
1367 | -} |
1368 | -int PageItem::lastInFrame() const |
1369 | -{ |
1370 | -#ifndef NLS_PROTO |
1371 | - return qMin(signed(MaxChars), itemText.length()) - 1; |
1372 | -#else |
1373 | - return itemText.length() - 1; |
1374 | -#endif |
1375 | -} |
1376 | - |
1377 | - |
1378 | -void PageItem::link(PageItem* nxt) |
1379 | -{ |
1380 | - assert( !nextInChain() ); |
1381 | - assert( !nxt->prevInChain() ); |
1382 | - for (PageItem* ff=nxt; ff; ff=ff->nextInChain()) |
1383 | - { |
1384 | - assert (ff != this); |
1385 | - } |
1386 | - // Append only if necessary to avoid the |
1387 | - // charstyle: access at end of text warning |
1388 | - if (nxt->itemText.length() > 0) |
1389 | - itemText.append(nxt->itemText); |
1390 | - NextBox = nxt; |
1391 | - nxt->BackBox = this; |
1392 | - // update AutoText |
1393 | - if (isAutoText) |
1394 | - { |
1395 | - PageItem* after = nxt; |
1396 | - while (after) |
1397 | - { |
1398 | - after->isAutoText = true; |
1399 | - m_Doc->LastAuto = after; |
1400 | - after = after->NextBox; |
1401 | - } |
1402 | - } |
1403 | - else if (nxt->isAutoText) |
1404 | - { |
1405 | - PageItem* before = this; |
1406 | - while (before) |
1407 | - { |
1408 | - before->isAutoText = true; |
1409 | - m_Doc->FirstAuto = before; |
1410 | - before = before->BackBox; |
1411 | - } |
1412 | - } |
1413 | - invalid = true; |
1414 | - while (nxt) |
1415 | - { |
1416 | - nxt->itemText = itemText; |
1417 | - nxt->invalid = true; |
1418 | - nxt->firstChar = 0; |
1419 | - nxt = nxt->NextBox; |
1420 | - } |
1421 | - if (UndoManager::undoEnabled()) |
1422 | - { |
1423 | - ItemState<std::pair<PageItem*, PageItem*> > *is = new ItemState<std::pair<PageItem*, PageItem*> >(UndoManager::LinkTextFrame); |
1424 | - is->set("LINK_TEXT_FRAME", "linkTextFrame"); |
1425 | - is->setItem(std::pair<PageItem*, PageItem*>(this, NextBox)); |
1426 | - undoManager->action(this, is); |
1427 | - } |
1428 | -} |
1429 | - |
1430 | -void PageItem::unlink() |
1431 | -{ |
1432 | - if( NextBox ) |
1433 | - { |
1434 | - PageItem *undoNextBox=NextBox; |
1435 | - // make sure lastInFrame is valid |
1436 | - layout(); |
1437 | - /* |
1438 | - //<< CB #6332: Stop the StoryText cut and break and act like other publishing apps |
1439 | - // move following text to new StoryText |
1440 | - itemText.select(lastInFrame()+1, itemText.length()-lastInFrame()-1); |
1441 | - */ |
1442 | - StoryText follow(m_Doc); |
1443 | - /* |
1444 | - follow.setDefaultStyle(itemText.defaultStyle()); |
1445 | - follow.insert(0, itemText, true); |
1446 | - // remove following text from this chain |
1447 | - itemText.removeSelection(); |
1448 | - //>> |
1449 | - */ |
1450 | - // update auto pointers |
1451 | - if (isAutoText) |
1452 | - { |
1453 | - PageItem* before = this; |
1454 | - while (before) |
1455 | - { |
1456 | - before->isAutoText = false; |
1457 | - before = before->BackBox; |
1458 | - } |
1459 | - m_Doc->FirstAuto = NextBox; |
1460 | - } |
1461 | - // link following frames to new text |
1462 | - NextBox->firstChar = 0; |
1463 | - NextBox->BackBox = NULL; |
1464 | - while (NextBox) { |
1465 | - NextBox->itemText = follow; |
1466 | - NextBox->invalid = true; |
1467 | - NextBox->firstChar = 0; |
1468 | - NextBox = NextBox->NextBox; |
1469 | - } |
1470 | - // NextBox == NULL now |
1471 | - NextBox = NULL; |
1472 | - if (UndoManager::undoEnabled()) |
1473 | - { |
1474 | - ItemState<std::pair<PageItem*, PageItem*> > *is = new ItemState<std::pair<PageItem*, PageItem*> >(UndoManager::UnlinkTextFrame); |
1475 | - is->set("UNLINK_TEXT_FRAME", "unlinkTextFrame"); |
1476 | - is->setItem(std::pair<PageItem*, PageItem*>(this, undoNextBox)); |
1477 | - undoManager->action(this, is); |
1478 | - } |
1479 | - } |
1480 | -} |
1481 | - |
1482 | - |
1483 | -void PageItem::dropLinks() |
1484 | -{ |
1485 | - // update auto pointers |
1486 | - if (isAutoText && NextBox == 0) |
1487 | - { |
1488 | - m_Doc->LastAuto = BackBox; |
1489 | - } |
1490 | - if (isAutoText && BackBox == 0) |
1491 | - { |
1492 | - m_Doc->FirstAuto = NextBox; |
1493 | - } |
1494 | - isAutoText = false; |
1495 | - |
1496 | - // leave text in remaining chain |
1497 | - PageItem* before = BackBox; |
1498 | - PageItem* after = NextBox; |
1499 | - if (after != 0 || before != 0) |
1500 | - { |
1501 | - itemText = StoryText(m_Doc); |
1502 | - if (before) |
1503 | - before->NextBox = after; |
1504 | - if (after) |
1505 | - { |
1506 | - after->BackBox = before; |
1507 | - while (after) |
1508 | - { |
1509 | - after->invalid = true; |
1510 | - after->firstChar = 0; |
1511 | - after = after->NextBox; |
1512 | - } |
1513 | - } |
1514 | - // JG we should set BackBox and NextBox to NULL at a point |
1515 | - BackBox = NextBox = NULL; |
1516 | - } |
1517 | -} |
1518 | - |
1519 | -/// tests if a character is displayed by this frame |
1520 | -bool PageItem::frameDisplays(int textpos) const |
1521 | -{ |
1522 | -#ifndef NLS_PROTO |
1523 | - return 0 <= textpos && textpos < signed(MaxChars) && textpos < itemText.length(); |
1524 | -#else |
1525 | - return true; // FIXME:NLS |
1526 | -#endif |
1527 | -} |
1528 | - |
1529 | - |
1530 | -/// returns the style at the current charpos |
1531 | -const ParagraphStyle& PageItem::currentStyle() const |
1532 | -{ |
1533 | - if (frameDisplays(CPos)) |
1534 | - return itemText.paragraphStyle(CPos); |
1535 | - else |
1536 | - return itemText.defaultStyle(); |
1537 | -} |
1538 | - |
1539 | -/// returns the style at the current charpos for changing |
1540 | -ParagraphStyle& PageItem::changeCurrentStyle() |
1541 | -{ |
1542 | - if (frameDisplays(CPos)) |
1543 | - return const_cast<ParagraphStyle&>(itemText.paragraphStyle(CPos)); |
1544 | - else |
1545 | - return const_cast<ParagraphStyle&>(itemText.defaultStyle()); |
1546 | -} |
1547 | - |
1548 | -/// returns the style at the current charpos |
1549 | -const CharStyle& PageItem::currentCharStyle() const |
1550 | -{ |
1551 | - if (frameDisplays(CPos)) |
1552 | - return itemText.charStyle(CPos); |
1553 | - else |
1554 | - return itemText.defaultStyle().charStyle(); |
1555 | -} |
1556 | - |
1557 | -void PageItem::setTextToFrameDistLeft(double newLeft) |
1558 | -{ |
1559 | - Extra=newLeft; |
1560 | - emit textToFrameDistances(Extra, TExtra, BExtra, RExtra); |
1561 | -} |
1562 | - |
1563 | -void PageItem::setTextToFrameDistRight(double newRight) |
1564 | -{ |
1565 | - RExtra=newRight; |
1566 | - emit textToFrameDistances(Extra, TExtra, BExtra, RExtra); |
1567 | -} |
1568 | - |
1569 | -void PageItem::setTextToFrameDistTop(double newTop) |
1570 | -{ |
1571 | - TExtra=newTop; |
1572 | - emit textToFrameDistances(Extra, TExtra, BExtra, RExtra); |
1573 | -} |
1574 | - |
1575 | -void PageItem::setTextToFrameDistBottom(double newBottom) |
1576 | -{ |
1577 | - BExtra=newBottom; |
1578 | - emit textToFrameDistances(Extra, TExtra, BExtra, RExtra); |
1579 | -} |
1580 | - |
1581 | -void PageItem::setTextToFrameDist(double newLeft, double newRight, double newTop, double newBottom) |
1582 | -{ |
1583 | - Extra=newLeft; |
1584 | - RExtra=newRight; |
1585 | - TExtra=newTop; |
1586 | - BExtra=newBottom; |
1587 | - emit textToFrameDistances(Extra, TExtra, BExtra, RExtra); |
1588 | -} |
1589 | - |
1590 | -double PageItem::gridOffset() const { return m_Doc->typographicSettings.offsetBaseGrid; } |
1591 | -double PageItem::gridDistance() const { return m_Doc->typographicSettings.valueBaseGrid; } |
1592 | - |
1593 | -void PageItem::setGridOffset(double) { } // FIXME |
1594 | -void PageItem::setGridDistance(double) { } // FIXME |
1595 | -void PageItem::setColumns(int n) |
1596 | -{ |
1597 | - Cols = qMax(1, n); //FIXME: undo |
1598 | -} |
1599 | -void PageItem::setColumnGap(double gap) |
1600 | -{ |
1601 | - ColGap = gap; //FIXME: undo |
1602 | -} |
1603 | - |
1604 | -void PageItem::setCornerRadius(double newRadius) |
1605 | -{ |
1606 | - RadRect=newRadius; |
1607 | - emit cornerRadius(RadRect); |
1608 | -} |
1609 | - |
1610 | - |
1611 | - |
1612 | - |
1613 | - |
1614 | - |
1615 | - |
1616 | - |
1617 | - |
1618 | -/** Paints the item. |
1619 | - CHANGE: cullingArea is in doc coordinates! |
1620 | - */ |
1621 | -void PageItem::DrawObj(ScPainter *p, QRectF cullingArea) |
1622 | -{ |
1623 | -// qDebug << "PageItem::DrawObj"; |
1624 | - double sc; |
1625 | - if (!m_Doc->DoDrawing) |
1626 | - { |
1627 | -// Tinput = false; |
1628 | - return; |
1629 | - } |
1630 | - if (cullingArea.isNull()) |
1631 | - { |
1632 | - cullingArea = QRectF(QPointF(m_Doc->minCanvasCoordinate.x(), m_Doc->minCanvasCoordinate.y()), |
1633 | - QPointF(m_Doc->maxCanvasCoordinate.x(), m_Doc->maxCanvasCoordinate.y())).toAlignedRect(); |
1634 | - } |
1635 | - |
1636 | - DrawObj_Pre(p, sc); |
1637 | - if (m_Doc->layerOutline(LayerNr)) |
1638 | - { |
1639 | - if ((itemType()==TextFrame || itemType()==ImageFrame || itemType()==PathText || itemType()==Line || itemType()==PolyLine) && (!isGroupControl)) |
1640 | - DrawObj_Item(p, cullingArea, sc); |
1641 | - } |
1642 | - else |
1643 | - { |
1644 | - if (!isGroupControl) |
1645 | - DrawObj_Item(p, cullingArea, sc); |
1646 | - } |
1647 | - DrawObj_Post(p); |
1648 | -} |
1649 | - |
1650 | -void PageItem::DrawObj_Pre(ScPainter *p, double &sc) |
1651 | -{ |
1652 | - ScribusView* view = m_Doc->view(); |
1653 | - sc = view->scale(); |
1654 | - p->save(); |
1655 | - if (!isEmbedded) |
1656 | - p->translate(Xpos, Ypos); |
1657 | - p->rotate(Rot); |
1658 | - if (m_Doc->layerOutline(LayerNr)) |
1659 | - { |
1660 | - p->setPen(m_Doc->layerMarker(LayerNr), 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
1661 | - p->setFillMode(ScPainter::None); |
1662 | - p->setBrushOpacity(1.0); |
1663 | - p->setPenOpacity(1.0); |
1664 | - } |
1665 | - else |
1666 | - { |
1667 | - if (!isGroupControl) |
1668 | - { |
1669 | - if (fillBlendmode() != 0) |
1670 | - p->beginLayer(1.0 - fillTransparency(), fillBlendmode()); |
1671 | - |
1672 | - p->setLineWidth(m_lineWidth); |
1673 | - if (GrType != 0) |
1674 | - { |
1675 | - if (GrType == 8) |
1676 | - { |
1677 | - if ((patternVal.isEmpty()) || (!m_Doc->docPatterns.contains(patternVal))) |
1678 | - { |
1679 | - p->fill_gradient = VGradient(VGradient::linear); |
1680 | - if (fillColor() != CommonStrings::None) |
1681 | - { |
1682 | - p->setBrush(fillQColor); |
1683 | - p->setFillMode(ScPainter::Solid); |
1684 | - } |
1685 | - else |
1686 | - p->setFillMode(ScPainter::None); |
1687 | - if ((!patternVal.isEmpty()) && (!m_Doc->docPatterns.contains(patternVal))) |
1688 | - { |
1689 | - GrType = 0; |
1690 | - patternVal = ""; |
1691 | - } |
1692 | - } |
1693 | - else |
1694 | - { |
1695 | - p->setPattern(&m_Doc->docPatterns[patternVal], patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation); |
1696 | - p->setFillMode(ScPainter::Pattern); |
1697 | - } |
1698 | - } |
1699 | - else |
1700 | - { |
1701 | - if (fill_gradient.Stops() < 2) // fall back to solid filling if there are not enough colorstops in the gradient. |
1702 | - { |
1703 | - if (fillColor() != CommonStrings::None) |
1704 | - { |
1705 | - p->setBrush(fillQColor); |
1706 | - p->setFillMode(ScPainter::Solid); |
1707 | - } |
1708 | - else |
1709 | - p->setFillMode(ScPainter::None); |
1710 | - } |
1711 | - else |
1712 | - { |
1713 | - p->setFillMode(ScPainter::Gradient); |
1714 | - p->fill_gradient = fill_gradient; |
1715 | - QMatrix grm; |
1716 | - grm.rotate(Rot); |
1717 | - FPointArray gra; |
1718 | - switch (GrType) |
1719 | - { |
1720 | - case 1: |
1721 | - case 2: |
1722 | - case 3: |
1723 | - case 4: |
1724 | - case 6: |
1725 | - p->setGradient(VGradient::linear, FPoint(GrStartX, GrStartY), FPoint(GrEndX, GrEndY)); |
1726 | - break; |
1727 | - case 5: |
1728 | - case 7: |
1729 | - gra.setPoints(2, GrStartX, GrStartY, GrEndX, GrEndY); |
1730 | - p->setGradient(VGradient::radial, gra.point(0), gra.point(1), gra.point(0)); |
1731 | - break; |
1732 | - } |
1733 | - } |
1734 | - } |
1735 | - } |
1736 | - else |
1737 | - { |
1738 | - p->fill_gradient = VGradient(VGradient::linear); |
1739 | - if (fillColor() != CommonStrings::None) |
1740 | - { |
1741 | - p->setBrush(fillQColor); |
1742 | - p->setFillMode(ScPainter::Solid); |
1743 | - } |
1744 | - else |
1745 | - p->setFillMode(ScPainter::None); |
1746 | - } |
1747 | - if (lineColor() != CommonStrings::None) |
1748 | - { |
1749 | -// if ((m_lineWidth == 0) && ! asLine()) |
1750 | -// p->setLineWidth(0); |
1751 | -// else |
1752 | -// { |
1753 | - p->setPen(strokeQColor, m_lineWidth, PLineArt, PLineEnd, PLineJoin); |
1754 | - if (DashValues.count() != 0) |
1755 | - p->setDash(DashValues, DashOffset); |
1756 | -// } |
1757 | - } |
1758 | - else |
1759 | - p->setLineWidth(0); |
1760 | - if (fillBlendmode() == 0) |
1761 | - p->setBrushOpacity(1.0 - fillTransparency()); |
1762 | - if (lineBlendmode() == 0) |
1763 | - p->setPenOpacity(1.0 - lineTransparency()); |
1764 | - p->setFillRule(fillRule); |
1765 | - } |
1766 | - } |
1767 | -} |
1768 | - |
1769 | -void PageItem::DrawObj_Post(ScPainter *p) |
1770 | -{ |
1771 | - bool doStroke=true; |
1772 | - ScribusView* view = m_Doc->view(); |
1773 | - if (!isGroupControl) |
1774 | - { |
1775 | - if (m_Doc->layerOutline(LayerNr)) |
1776 | - { |
1777 | - if (itemType()!=Line) |
1778 | - { |
1779 | - p->setPen(m_Doc->layerMarker(LayerNr), 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
1780 | - p->setFillMode(ScPainter::None); |
1781 | - p->setBrushOpacity(1.0); |
1782 | - p->setPenOpacity(1.0); |
1783 | - if (itemType()==PolyLine) |
1784 | - p->setupPolygon(&PoLine, false); |
1785 | - else if (itemType() == PathText) |
1786 | - { |
1787 | - if (PoShow) |
1788 | - p->setupPolygon(&PoLine, false); |
1789 | - else |
1790 | - doStroke = false; |
1791 | - } |
1792 | - else |
1793 | - p->setupPolygon(&PoLine); |
1794 | - if (doStroke) |
1795 | - p->strokePath(); |
1796 | - if (itemType()==ImageFrame) |
1797 | - { |
1798 | - if (imageClip.size() != 0) |
1799 | - { |
1800 | - p->setupPolygon(&imageClip); |
1801 | - p->strokePath(); |
1802 | - } |
1803 | - } |
1804 | - } |
1805 | - } |
1806 | - else |
1807 | - { |
1808 | - if (fillBlendmode() != 0) |
1809 | - p->endLayer(); |
1810 | - if (itemType()==PathText || itemType()==PolyLine || itemType()==Line) |
1811 | - doStroke=false; |
1812 | - if ((doStroke) && (!m_Doc->RePos)) |
1813 | - { |
1814 | - if (lineBlendmode() != 0) |
1815 | - p->beginLayer(1.0 - lineTransparency(), lineBlendmode()); |
1816 | -// if (lineColor() != CommonStrings::None) |
1817 | -// { |
1818 | -// p->setPen(strokeQColor, m_lineWidth, PLineArt, PLineEnd, PLineJoin); |
1819 | -// if (DashValues.count() != 0) |
1820 | -// p->setDash(DashValues, DashOffset); |
1821 | -// } |
1822 | -// else |
1823 | -// p->setLineWidth(0); |
1824 | - if (!isTableItem) |
1825 | - { |
1826 | - if ((itemType() == LatexFrame) || (itemType() == ImageFrame)) |
1827 | - p->setupPolygon(&PoLine); |
1828 | - if (NamedLStyle.isEmpty()) |
1829 | - { |
1830 | - if (lineColor() != CommonStrings::None) |
1831 | - { |
1832 | - p->setPen(strokeQColor, m_lineWidth, PLineArt, PLineEnd, PLineJoin); |
1833 | - if (DashValues.count() != 0) |
1834 | - p->setDash(DashValues, DashOffset); |
1835 | - p->strokePath(); |
1836 | - } |
1837 | - } |
1838 | - else |
1839 | - { |
1840 | - multiLine ml = m_Doc->MLineStyles[NamedLStyle]; |
1841 | - QColor tmp; |
1842 | - for (int it = ml.size()-1; it > -1; it--) |
1843 | - { |
1844 | - struct SingleLine& sl = ml[it]; |
1845 | - // Qt4 if ((!sl.Color != CommonStrings::None) && (sl.Width != 0)) |
1846 | - if (sl.Color != CommonStrings::None) // && (sl.Width != 0)) |
1847 | - { |
1848 | - SetQColor(&tmp, sl.Color, sl.Shade); |
1849 | - p->setPen(tmp, sl.Width, static_cast<Qt::PenStyle>(sl.Dash), static_cast<Qt::PenCapStyle>(sl.LineEnd), static_cast<Qt::PenJoinStyle>(sl.LineJoin)); |
1850 | - p->strokePath(); |
1851 | - } |
1852 | - } |
1853 | - } |
1854 | - } |
1855 | - if (lineBlendmode() != 0) |
1856 | - p->endLayer(); |
1857 | - } |
1858 | - } |
1859 | - } |
1860 | - if ((!isEmbedded) && (!m_Doc->RePos)) |
1861 | - { |
1862 | - double aestheticFactor(5.0); |
1863 | - double scpInv = 1.0 / (qMax(view->scale(), 1.0) * aestheticFactor); |
1864 | - if (!isGroupControl) |
1865 | - { |
1866 | - if ((Frame) && (m_Doc->guidesSettings.framesShown) && ((itemType() == ImageFrame) || (itemType() == LatexFrame) || (itemType() == PathText))) |
1867 | - { |
1868 | - p->setPen(PrefsManager::instance()->appPrefs.DFrameNormColor, scpInv, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
1869 | - if ((isBookmark) || (m_isAnnotation)) |
1870 | - p->setPen(PrefsManager::instance()->appPrefs.DFrameAnnotationColor, scpInv, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
1871 | - if ((BackBox != 0) || (NextBox != 0)) |
1872 | - p->setPen(PrefsManager::instance()->appPrefs.DFrameLinkColor, scpInv, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
1873 | - if (m_Locked) |
1874 | - p->setPen(PrefsManager::instance()->appPrefs.DFrameLockColor, scpInv, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
1875 | - p->setFillMode(0); |
1876 | - if (itemType()==PathText) |
1877 | - { |
1878 | - if (Clip.count() != 0) |
1879 | - { |
1880 | - FPointArray tclip; |
1881 | - FPoint np = FPoint(Clip.point(0)); |
1882 | - tclip.resize(2); |
1883 | - tclip.setPoint(0, np); |
1884 | - tclip.setPoint(1, np); |
1885 | - for (int a = 1; a < Clip.size(); ++a) |
1886 | - { |
1887 | - np = FPoint(Clip.point(a)); |
1888 | - tclip.putPoints(tclip.size(), 4, np.x(), np.y(), np.x(), np.y(), np.x(), np.y(), np.x(), np.y()); |
1889 | - } |
1890 | - np = FPoint(Clip.point(0)); |
1891 | - tclip.putPoints(tclip.size(), 2, np.x(), np.y(), np.x(), np.y()); |
1892 | - p->setupPolygon(&tclip); |
1893 | - } |
1894 | - } |
1895 | - else |
1896 | -// Ugly Hack to fix rendering problems with cairo >=1.5.10 && <1.8.0 follows |
1897 | -#ifdef HAVE_CAIRO |
1898 | - #if ((CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 5, 10)) && (CAIRO_VERSION < CAIRO_VERSION_ENCODE(1, 8, 0))) |
1899 | - p->setupPolygon(&PoLine, false); |
1900 | - #else |
1901 | - p->setupPolygon(&PoLine); |
1902 | - #endif |
1903 | -#else |
1904 | - p->setupPolygon(&PoLine); |
1905 | -#endif |
1906 | - p->strokePath(); |
1907 | - } |
1908 | - } |
1909 | - if ((m_Doc->guidesSettings.framesShown) && textFlowUsesContourLine() && (ContourLine.size() != 0)) |
1910 | - { |
1911 | - p->setPen(Qt::darkGray, 1.0 / qMax(view->scale(), 1.0), Qt::DotLine, Qt::FlatCap, Qt::MiterJoin); |
1912 | -// Ugly Hack to fix rendering problems with cairo >=1.5.10 && <1.8.0 follows |
1913 | -#ifdef HAVE_CAIRO |
1914 | - #if ((CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 5, 10)) && (CAIRO_VERSION < CAIRO_VERSION_ENCODE(1, 8, 0))) |
1915 | - p->setupPolygon(&ContourLine, false); |
1916 | - #else |
1917 | - p->setupPolygon(&ContourLine); |
1918 | - #endif |
1919 | -#else |
1920 | - p->setupPolygon(&ContourLine); |
1921 | -#endif |
1922 | - p->strokePath(); |
1923 | - } |
1924 | - if ((m_Doc->guidesSettings.layerMarkersShown) && (m_Doc->layerCount() > 1) && (!m_Doc->layerOutline(LayerNr)) && ((isGroupControl) || (Groups.count() == 0)) && (!view->m_canvas->isPreviewMode())) |
1925 | - { |
1926 | - p->setPen(Qt::black, 0.5/ m_Doc->view()->scale(), Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
1927 | - p->setPenOpacity(1.0); |
1928 | - p->setBrush(m_Doc->layerMarker(LayerNr)); |
1929 | - p->setBrushOpacity(1.0); |
1930 | - p->setFillMode(ScPainter::Solid); |
1931 | - double ofwh = 10; |
1932 | - double ofx = Width - ofwh/2; |
1933 | - double ofy = Height - ofwh*3; |
1934 | - p->drawRect(ofx, ofy, ofwh, ofwh); |
1935 | - } |
1936 | - //CB disabled for now |
1937 | - //if (m_Doc->m_Selection->findItem(this)!=-1) |
1938 | - // drawLockedMarker(p); |
1939 | - } |
1940 | -// Tinput = false; |
1941 | - FrameOnly = false; |
1942 | - p->restore(); |
1943 | -} |
1944 | - |
1945 | -void PageItem::DrawObj_Embedded(ScPainter *p, QRectF cullingArea, const CharStyle& style, PageItem* cembedded) |
1946 | -{ |
1947 | - if (!cembedded) |
1948 | - return; |
1949 | - if (!m_Doc->DoDrawing) |
1950 | - return; |
1951 | - QList<PageItem*> emG; |
1952 | - QStack<PageItem*> groupStack; |
1953 | - groupStack.clear(); |
1954 | - emG.clear(); |
1955 | - emG.append(cembedded); |
1956 | - if (cembedded->Groups.count() != 0) |
1957 | - { |
1958 | - for (int ga=0; ga<m_Doc->FrameItems.count(); ++ga) |
1959 | - { |
1960 | - if (m_Doc->FrameItems.at(ga)->Groups.count() != 0) |
1961 | - { |
1962 | - if (m_Doc->FrameItems.at(ga)->Groups.top() == cembedded->Groups.top()) |
1963 | - { |
1964 | - if (m_Doc->FrameItems.at(ga)->ItemNr != cembedded->ItemNr) |
1965 | - { |
1966 | - if (!emG.contains(m_Doc->FrameItems.at(ga))) |
1967 | - emG.append(m_Doc->FrameItems.at(ga)); |
1968 | - } |
1969 | - } |
1970 | - } |
1971 | - } |
1972 | - } |
1973 | - for (int em = 0; em < emG.count(); ++em) |
1974 | - { |
1975 | - PageItem* embedded = emG.at(em); |
1976 | - if (embedded->isGroupControl) |
1977 | - { |
1978 | - p->save(); |
1979 | - FPointArray cl = embedded->PoLine.copy(); |
1980 | - QMatrix mm; |
1981 | - mm.translate((embedded->gXpos * (style.scaleH() / 1000.0)), ( - (embedded->gHeight * (style.scaleV() / 1000.0)) + embedded->gYpos * (style.scaleV() / 1000.0))); |
1982 | - if (style.baselineOffset() != 0) |
1983 | - mm.translate(0, -embedded->gHeight * (style.baselineOffset() / 1000.0)); |
1984 | - mm.scale(style.scaleH() / 1000.0, style.scaleV() / 1000.0); |
1985 | - mm.rotate(embedded->rotation()); |
1986 | - cl.map( mm ); |
1987 | - p->beginLayer(1.0 - embedded->fillTransparency(), embedded->fillBlendmode(), &cl); |
1988 | - groupStack.push(embedded->groupsLastItem); |
1989 | - continue; |
1990 | - } |
1991 | - p->save(); |
1992 | - double x = embedded->xPos(); |
1993 | - double y = embedded->yPos(); |
1994 | - embedded->Xpos = embedded->gXpos; |
1995 | - embedded->Ypos = (embedded->gHeight * (style.scaleV() / 1000.0)) + embedded->gYpos; |
1996 | - p->translate((embedded->gXpos * (style.scaleH() / 1000.0)), ( - (embedded->gHeight * (style.scaleV() / 1000.0)) + embedded->gYpos * (style.scaleV() / 1000.0))); |
1997 | - if (style.baselineOffset() != 0) |
1998 | - { |
1999 | - p->translate(0, -embedded->gHeight * (style.baselineOffset() / 1000.0)); |
2000 | - embedded->Ypos -= embedded->gHeight * (style.baselineOffset() / 1000.0); |
2001 | - } |
2002 | - p->scale(style.scaleH() / 1000.0, style.scaleV() / 1000.0); |
2003 | - embedded->Dirty = Dirty; |
2004 | - embedded->invalid = true; |
2005 | - double sc; |
2006 | - double pws = embedded->m_lineWidth; |
2007 | - embedded->DrawObj_Pre(p, sc); |
2008 | - switch(embedded->itemType()) |
2009 | - { |
2010 | - case ImageFrame: |
2011 | - case TextFrame: |
2012 | - case LatexFrame: |
2013 | - case Polygon: |
2014 | - case PathText: |
2015 | - embedded->DrawObj_Item(p, cullingArea, sc); |
2016 | - break; |
2017 | - case Line: |
2018 | - case PolyLine: |
2019 | - embedded->m_lineWidth = pws * qMin(style.scaleH() / 1000.0, style.scaleV() / 1000.0); |
2020 | - embedded->DrawObj_Item(p, cullingArea, sc); |
2021 | - break; |
2022 | - default: |
2023 | - break; |
2024 | - } |
2025 | - embedded->m_lineWidth = pws * qMin(style.scaleH() / 1000.0, style.scaleV() / 1000.0); |
2026 | - embedded->DrawObj_Post(p); |
2027 | - embedded->Xpos = x; |
2028 | - embedded->Ypos = y; |
2029 | - p->restore(); |
2030 | - if (groupStack.count() != 0) |
2031 | - { |
2032 | - while (embedded == groupStack.top()) |
2033 | - { |
2034 | - p->endLayer(); |
2035 | - p->restore(); |
2036 | - groupStack.pop(); |
2037 | - if (groupStack.count() == 0) |
2038 | - break; |
2039 | - } |
2040 | - } |
2041 | - embedded->m_lineWidth = pws; |
2042 | - } |
2043 | - for (int em = 0; em < emG.count(); ++em) |
2044 | - { |
2045 | - PageItem* embedded = emG.at(em); |
2046 | - if (!embedded->isTableItem) |
2047 | - continue; |
2048 | - p->save(); |
2049 | - double x = embedded->xPos(); |
2050 | - double y = embedded->yPos(); |
2051 | - embedded->Xpos = embedded->gXpos; |
2052 | - embedded->Ypos = (embedded->gHeight * (style.scaleV() / 1000.0)) + embedded->gYpos; |
2053 | - p->translate((embedded->gXpos * (style.scaleH() / 1000.0)), ( - (embedded->gHeight * (style.scaleV() / 1000.0)) + embedded->gYpos * (style.scaleV() / 1000.0))); |
2054 | - if (style.baselineOffset() != 0) |
2055 | - { |
2056 | - p->translate(0, -embedded->gHeight * (style.baselineOffset() / 1000.0)); |
2057 | - embedded->Ypos -= embedded->gHeight * (style.baselineOffset() / 1000.0); |
2058 | - } |
2059 | - p->scale(style.scaleH() / 1000.0, style.scaleV() / 1000.0); |
2060 | - p->rotate(embedded->rotation()); |
2061 | - double pws = embedded->m_lineWidth; |
2062 | - embedded->m_lineWidth = pws * qMin(style.scaleH() / 1000.0, style.scaleV() / 1000.0); |
2063 | - if ((embedded->lineColor() != CommonStrings::None) && (embedded->lineWidth() != 0.0)) |
2064 | - { |
2065 | - QColor tmp; |
2066 | - embedded->SetQColor(&tmp, embedded->lineColor(), embedded->lineShade()); |
2067 | - if ((embedded->TopLine) || (embedded->RightLine) || (embedded->BottomLine) || (embedded->LeftLine)) |
2068 | - { |
2069 | - p->setPen(tmp, embedded->lineWidth(), embedded->PLineArt, Qt::SquareCap, embedded->PLineJoin); |
2070 | - if (embedded->TopLine) |
2071 | - p->drawLine(FPoint(0.0, 0.0), FPoint(embedded->width(), 0.0)); |
2072 | - if (embedded->RightLine) |
2073 | - p->drawLine(FPoint(embedded->width(), 0.0), FPoint(embedded->width(), embedded->height())); |
2074 | - if (embedded->BottomLine) |
2075 | - p->drawLine(FPoint(embedded->width(), embedded->height()), FPoint(0.0, embedded->height())); |
2076 | - if (embedded->LeftLine) |
2077 | - p->drawLine(FPoint(0.0, embedded->height()), FPoint(0.0, 0.0)); |
2078 | - } |
2079 | - } |
2080 | - embedded->m_lineWidth = pws; |
2081 | - embedded->Xpos = x; |
2082 | - embedded->Ypos = y; |
2083 | - p->restore(); |
2084 | - } |
2085 | -} |
2086 | - |
2087 | - |
2088 | -void PageItem::paintObj(QPainter *p) |
2089 | -{ |
2090 | - if ((!m_Doc->DoDrawing) || (m_Doc->RePos)) |
2091 | - { |
2092 | - FrameOnly = false; |
2093 | - return; |
2094 | - } |
2095 | - double sc = m_Doc->view()->scale(); |
2096 | - double handleSize = 6.0 / sc; |
2097 | - double halfSize = 3.0 / sc; |
2098 | - if ((!FrameOnly) && (!m_Doc->RePos)) |
2099 | - { |
2100 | - if (!m_Doc->m_Selection->isEmpty()) |
2101 | - { |
2102 | -// qDebug() << "Item: " << ItemNr << "W: " << Width << "H: " << Height; |
2103 | - if (Groups.count() == 0) |
2104 | - { |
2105 | - //Locked line colour selection |
2106 | - if (m_Locked) |
2107 | - p->setPen(QPen(PrefsManager::instance()->appPrefs.DFrameLockColor, 1.0 / sc, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin)); |
2108 | - else |
2109 | - p->setPen(QPen(PrefsManager::instance()->appPrefs.DFrameColor, 1.0 / sc, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin)); |
2110 | - p->setBrush(Qt::NoBrush); |
2111 | - double lw2 = 1.0 / sc; |
2112 | - double lw = 1.0 / sc; |
2113 | - Qt::PenCapStyle le = Qt::FlatCap; |
2114 | - if (NamedLStyle.isEmpty()) |
2115 | - { |
2116 | - lw2 = (m_lineWidth / 2.0) / sc; |
2117 | - lw = qMax(m_lineWidth, 1.0) / sc; |
2118 | - le = PLineEnd; |
2119 | - } |
2120 | - else |
2121 | - { |
2122 | - multiLine ml = m_Doc->MLineStyles[NamedLStyle]; |
2123 | - lw2 = (ml[ml.size()-1].Width / 2.0) / sc; |
2124 | - lw = qMax(ml[ml.size()-1].Width, 1.0) / sc; |
2125 | - le = static_cast<Qt::PenCapStyle>(ml[ml.size()-1].LineEnd); |
2126 | - } |
2127 | - //Draw our frame outline |
2128 | - if (asLine()) |
2129 | - { |
2130 | - if (le != Qt::FlatCap) |
2131 | - p->drawRect(QRectF(-lw2, -lw2, Width+lw, lw)); |
2132 | - else |
2133 | - p->drawRect(QRectF(-1 / sc, -lw2, Width, lw)); |
2134 | - } |
2135 | - else |
2136 | - p->drawRect(QRectF(0, 0, Width, Height)); |
2137 | -// p->setPen(QPen(PrefsManager::instance()->appPrefs.DFrameColor, 1.0 / sc, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin)); |
2138 | - p->setBrush(PrefsManager::instance()->appPrefs.DFrameColor); |
2139 | - p->setPen(Qt::NoPen); |
2140 | - if ((!m_Locked) && (!m_SizeLocked)) |
2141 | - { |
2142 | - if (! asLine()) |
2143 | - { |
2144 | - p->drawRect(QRectF(0.0, 0.0, handleSize, handleSize)); |
2145 | - p->drawRect(QRectF(Width - handleSize, Height - handleSize, handleSize, handleSize)); |
2146 | - p->drawRect(QRectF(Width - handleSize, 0.0, handleSize, handleSize)); |
2147 | - p->drawRect(QRectF(0.0, Height - handleSize, handleSize, handleSize)); |
2148 | - if (Width > 6) |
2149 | - { |
2150 | - p->drawRect(QRectF(Width / 2.0 - halfSize, Height - handleSize, handleSize, handleSize)); |
2151 | - p->drawRect(QRectF(Width / 2.0 - halfSize, 0.0, handleSize, handleSize)); |
2152 | - } |
2153 | - if (Height > 6) |
2154 | - { |
2155 | - p->drawRect(QRectF(Width - handleSize, Height / 2.0 - halfSize, handleSize, handleSize)); |
2156 | - p->drawRect(QRectF(0.0, Height / 2.0 - halfSize, handleSize, handleSize)); |
2157 | - } |
2158 | - } |
2159 | - else |
2160 | - { |
2161 | - p->drawRect(QRectF(-halfSize, -halfSize, handleSize, handleSize)); |
2162 | - p->drawRect(QRectF(Width + halfSize, -halfSize, -handleSize, handleSize)); |
2163 | - } |
2164 | - } |
2165 | - } |
2166 | - else |
2167 | - { |
2168 | - p->setPen(QPen(PrefsManager::instance()->appPrefs.DFrameGroupColor, 1.0 / sc, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin)); |
2169 | - p->setBrush(Qt::NoBrush); |
2170 | - p->drawRect(QRectF(0.0, 0.0, Width, Height)); |
2171 | - if (m_Doc->m_Selection->count() == 1) |
2172 | - { |
2173 | - p->setPen(Qt::NoPen); |
2174 | -// p->setPen(QPen(PrefsManager::instance()->appPrefs.DFrameGroupColor, 1.0 / sc, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin)); |
2175 | - p->setBrush(PrefsManager::instance()->appPrefs.DFrameGroupColor); |
2176 | - p->drawRect(QRectF(0.0, 0.0, handleSize, handleSize)); |
2177 | - p->drawRect(QRectF(Width - handleSize, Height - handleSize, handleSize, handleSize)); |
2178 | - p->drawRect(QRectF(Width - handleSize, 0.0, handleSize, handleSize)); |
2179 | - p->drawRect(QRectF(0.0, Height - handleSize, handleSize, handleSize)); |
2180 | - if (Width > 6) |
2181 | - { |
2182 | - p->drawRect(QRectF(Width / 2.0 - halfSize, Height - handleSize, handleSize, handleSize)); |
2183 | - p->drawRect(QRectF(Width / 2.0 - halfSize, 0.0, handleSize, handleSize)); |
2184 | - } |
2185 | - if (Height > 6) |
2186 | - { |
2187 | - p->drawRect(QRectF(Width - handleSize, Height / 2.0 - halfSize, handleSize, handleSize)); |
2188 | - p->drawRect(QRectF(0.0, Height / 2.0 - halfSize, handleSize, handleSize)); |
2189 | - } |
2190 | - } |
2191 | - } |
2192 | - } |
2193 | - } |
2194 | - FrameOnly = false; |
2195 | -} |
2196 | - |
2197 | -QImage PageItem::DrawObj_toImage() |
2198 | -{ |
2199 | - QList<PageItem*> emG; |
2200 | - emG.clear(); |
2201 | - double minx = std::numeric_limits<double>::max(); |
2202 | - double miny = std::numeric_limits<double>::max(); |
2203 | - double maxx = -std::numeric_limits<double>::max(); |
2204 | - double maxy = -std::numeric_limits<double>::max(); |
2205 | - if (Groups.count() != 0) |
2206 | - { |
2207 | - for (int ga=0; ga<m_Doc->Items->count(); ++ga) |
2208 | - { |
2209 | - if (m_Doc->Items->at(ga)->Groups.count() != 0) |
2210 | - { |
2211 | - if (m_Doc->Items->at(ga)->Groups.top() == Groups.top()) |
2212 | - { |
2213 | - if (!emG.contains(m_Doc->Items->at(ga))) |
2214 | - { |
2215 | - emG.append(m_Doc->Items->at(ga)); |
2216 | - PageItem *currItem = m_Doc->Items->at(ga); |
2217 | - double x1, x2, y1, y2; |
2218 | - currItem->getVisualBoundingRect(&x1, &y1, &x2, &y2); |
2219 | - minx = qMin(minx, x1); |
2220 | - miny = qMin(miny, y1); |
2221 | - maxx = qMax(maxx, x2); |
2222 | - maxy = qMax(maxy, y2); |
2223 | - } |
2224 | - } |
2225 | - } |
2226 | - } |
2227 | - for (int em = 0; em < emG.count(); ++em) |
2228 | - { |
2229 | - PageItem* currItem = emG.at(em); |
2230 | - currItem->gXpos = currItem->xPos() - minx; |
2231 | - currItem->gYpos = currItem->yPos() - miny; |
2232 | - currItem->gWidth = maxx - minx; |
2233 | - currItem->gHeight = maxy - miny; |
2234 | - } |
2235 | - } |
2236 | - else |
2237 | - { |
2238 | - double x1, x2, y1, y2; |
2239 | - getVisualBoundingRect(&x1, &y1, &x2, &y2); |
2240 | - minx = qMin(minx, x1); |
2241 | - miny = qMin(miny, y1); |
2242 | - maxx = qMax(maxx, x2); |
2243 | - maxy = qMax(maxy, y2); |
2244 | - gXpos = xPos() - minx; |
2245 | - gYpos = yPos() - miny; |
2246 | - gWidth = maxx - minx; |
2247 | - gHeight = maxy - miny; |
2248 | - emG.append(this); |
2249 | - } |
2250 | - return DrawObj_toImage(emG); |
2251 | -} |
2252 | - |
2253 | -QImage PageItem::DrawObj_toImage(QList<PageItem*> &emG) |
2254 | -{ |
2255 | - QImage retImg = QImage(qRound(gWidth), qRound(gHeight), QImage::Format_ARGB32); |
2256 | -// retImg.fill( qRgba(255, 255, 255, 0) ); |
2257 | - retImg.fill( qRgba(0, 0, 0, 0) ); |
2258 | - ScPainter *painter = new ScPainter(&retImg, retImg.width(), retImg.height(), 1, 0); |
2259 | -// painter->setZoomFactor(1.0); |
2260 | - painter->setZoomFactor(qMax(qRound(gWidth) / gWidth, qRound(gHeight) / gHeight)); |
2261 | - QStack<PageItem*> groupStack; |
2262 | - for (int em = 0; em < emG.count(); ++em) |
2263 | - { |
2264 | - PageItem* embedded = emG.at(em); |
2265 | - if (embedded->isGroupControl) |
2266 | - { |
2267 | - painter->save(); |
2268 | - FPointArray cl = embedded->PoLine.copy(); |
2269 | - QMatrix mm; |
2270 | - mm.translate(embedded->gXpos, embedded->gYpos); |
2271 | - mm.rotate(embedded->rotation()); |
2272 | - cl.map( mm ); |
2273 | - painter->beginLayer(1.0 - embedded->fillTransparency(), embedded->fillBlendmode(), &cl); |
2274 | - groupStack.push(embedded->groupsLastItem); |
2275 | - continue; |
2276 | - } |
2277 | - painter->save(); |
2278 | -// qDebug()<<embedded<<embedded->xPos()<<embedded->yPos()<<embedded->gXpos<<embedded->gYpos; |
2279 | -// double x = embedded->xPos(); |
2280 | -// double y = embedded->yPos(); |
2281 | -// embedded->Xpos = embedded->gXpos; |
2282 | -// embedded->Ypos = embedded->gYpos; |
2283 | - // Seems to work without all this coordinates mess. To monitor tho |
2284 | - painter->translate(embedded->gXpos, embedded->gYpos); |
2285 | - embedded->isEmbedded = true; |
2286 | - embedded->invalid = true; |
2287 | - embedded->DrawObj(painter, QRectF()); |
2288 | -// embedded->Xpos = x; |
2289 | -// embedded->Ypos = y; |
2290 | - embedded->isEmbedded = false; |
2291 | - painter->restore(); |
2292 | - if (groupStack.count() != 0) |
2293 | - { |
2294 | - while (embedded == groupStack.top()) |
2295 | - { |
2296 | - painter->endLayer(); |
2297 | - painter->restore(); |
2298 | - groupStack.pop(); |
2299 | - if (groupStack.count() == 0) |
2300 | - break; |
2301 | - } |
2302 | - } |
2303 | - } |
2304 | - for (int em = 0; em < emG.count(); ++em) |
2305 | - { |
2306 | - PageItem* embedded = emG.at(em); |
2307 | - if (!embedded->isTableItem) |
2308 | - continue; |
2309 | - painter->save(); |
2310 | -// double x = embedded->xPos(); |
2311 | -// double y = embedded->yPos(); |
2312 | -// embedded->Xpos = embedded->gXpos; |
2313 | -// embedded->Ypos = embedded->gYpos; |
2314 | - painter->translate(embedded->gXpos, embedded->gYpos); |
2315 | - painter->rotate(embedded->rotation()); |
2316 | - embedded->isEmbedded = true; |
2317 | - embedded->invalid = true; |
2318 | - if ((embedded->lineColor() != CommonStrings::None) && (embedded->lineWidth() != 0.0)) |
2319 | - { |
2320 | - QColor tmp; |
2321 | - embedded->SetQColor(&tmp, embedded->lineColor(), embedded->lineShade()); |
2322 | - if ((embedded->TopLine) || (embedded->RightLine) || (embedded->BottomLine) || (embedded->LeftLine)) |
2323 | - { |
2324 | - painter->setPen(tmp, embedded->lineWidth(), embedded->PLineArt, Qt::SquareCap, embedded->PLineJoin); |
2325 | - if (embedded->TopLine) |
2326 | - painter->drawLine(FPoint(0.0, 0.0), FPoint(embedded->width(), 0.0)); |
2327 | - if (embedded->RightLine) |
2328 | - painter->drawLine(FPoint(embedded->width(), 0.0), FPoint(embedded->width(), embedded->height())); |
2329 | - if (embedded->BottomLine) |
2330 | - painter->drawLine(FPoint(embedded->width(), embedded->height()), FPoint(0.0, embedded->height())); |
2331 | - if (embedded->LeftLine) |
2332 | - painter->drawLine(FPoint(0.0, embedded->height()), FPoint(0.0, 0.0)); |
2333 | - } |
2334 | - } |
2335 | - embedded->isEmbedded = false; |
2336 | -// embedded->Xpos = x; |
2337 | -// embedded->Ypos = y; |
2338 | - painter->restore(); |
2339 | - } |
2340 | - painter->end(); |
2341 | - delete painter; |
2342 | - return retImg; |
2343 | -} |
2344 | - |
2345 | -QString PageItem::ExpandToken(uint base) |
2346 | -{ |
2347 | - uint zae = 0; |
2348 | - QChar ch = itemText.text(base); |
2349 | - QString chstr = ch; |
2350 | - if (ch == SpecialChars::PAGENUMBER) |
2351 | - { |
2352 | - // compatibility mode: ignore subsequent pagenumber chars |
2353 | - if (base > 0 && itemText.text(base-1) == SpecialChars::PAGENUMBER) |
2354 | - return ""; |
2355 | - if ((!m_Doc->masterPageMode()) && (OwnPage != -1)) |
2356 | - { |
2357 | - QString out("%1"); |
2358 | - //CB Section numbering |
2359 | - chstr = out.arg(m_Doc->getSectionPageNumberForPageIndex(OwnPage), -(int)zae); |
2360 | - } |
2361 | - else |
2362 | - return "#"; |
2363 | - } |
2364 | - else if (ch == SpecialChars::PAGECOUNT) |
2365 | - { |
2366 | - if (!m_Doc->masterPageMode()) |
2367 | - { |
2368 | - QString out("%1"); |
2369 | - int key = m_Doc->getSectionKeyForPageIndex(OwnPage); |
2370 | - if (key == -1) |
2371 | - return "%"; |
2372 | - chstr = out.arg(getStringFromSequence(m_Doc->sections[key].type, m_Doc->sections[key].toindex - m_Doc->sections[key].fromindex + 1)); |
2373 | - } |
2374 | - else |
2375 | - return "%"; |
2376 | - } |
2377 | - return chstr; |
2378 | -} |
2379 | - |
2380 | -void PageItem::SetQColor(QColor *tmp, QString farbe, double shad) |
2381 | -{ |
2382 | - const ScColor& col = m_Doc->PageColors[farbe]; |
2383 | - *tmp = ScColorEngine::getShadeColorProof(col, m_Doc, shad); |
2384 | - if ((m_Doc->view()) && (m_Doc->view()->m_canvas->usePreviewVisual())) |
2385 | - { |
2386 | - VisionDefectColor defect; |
2387 | - *tmp = defect.convertDefect(*tmp, m_Doc->view()->m_canvas->previewVisual()); |
2388 | - } |
2389 | -} |
2390 | - |
2391 | -/** |
2392 | - layout glyphs translates the chars into a number of glyphs, applying the Charstyle |
2393 | - 'style'. The following fields are set in layout: glyph, more, scaleH, scaleV, xoffset, yoffset, xadvance. |
2394 | - If the DropCap-bit in style.effects is set and yadvance is > 0, scaleH/V, x/yoffset and xadvance |
2395 | - are modified to scale the glyphs to this height. |
2396 | - Otherwise yadvance is set to the max ascender of all generated glyphs. |
2397 | - It scales according to smallcaps and |
2398 | - sets xadvance to the advance width without kerning. If more than one glyph |
2399 | - is generated, kerning is included in all but the last xadvance. |
2400 | -*/ |
2401 | -double PageItem::layoutGlyphs(const CharStyle& style, const QString& chars, GlyphLayout& layout) |
2402 | -{ |
2403 | - double retval = 0.0; |
2404 | - double asce = style.font().ascent(style.fontSize() / 10.0); |
2405 | - int chst = style.effects() & 1919; |
2406 | -/* if (chars[0] == SpecialChars::ZWSPACE || |
2407 | - chars[0] == SpecialChars::ZWNBSPACE || |
2408 | - chars[0] == SpecialChars::NBSPACE || |
2409 | - chars[0] == SpecialChars::NBHYPHEN || |
2410 | - chars[0] == SpecialChars::SHYPHEN || |
2411 | - chars[0] == SpecialChars::PARSEP || |
2412 | - chars[0] == SpecialChars::COLBREAK || |
2413 | - chars[0] == SpecialChars::LINEBREAK || |
2414 | - chars[0] == SpecialChars::FRAMEBREAK || |
2415 | - chars[0] == SpecialChars::TAB) |
2416 | - { |
2417 | - layout.glyph = ScFace::CONTROL_GLYPHS + chars[0].unicode(); |
2418 | - } |
2419 | - else */ |
2420 | - { |
2421 | - layout.glyph = style.font().char2CMap(chars[0].unicode()); |
2422 | - } |
2423 | - |
2424 | - double tracking = 0.0; |
2425 | - if ( (style.effects() & ScStyle_StartOfLine) == 0) |
2426 | - tracking = style.fontSize() * style.tracking() / 10000.0; |
2427 | - |
2428 | - layout.xoffset = tracking; |
2429 | - layout.yoffset = 0; |
2430 | - if (chst != ScStyle_Default) |
2431 | - { |
2432 | - if (chst & ScStyle_Superscript) |
2433 | - { |
2434 | - retval -= asce * m_Doc->typographicSettings.valueSuperScript / 100.0; |
2435 | - layout.yoffset -= asce * m_Doc->typographicSettings.valueSuperScript / 100.0; |
2436 | - layout.scaleV = layout.scaleH = qMax(m_Doc->typographicSettings.scalingSuperScript / 100.0, 10.0 / style.fontSize()); |
2437 | - } |
2438 | - else if (chst & ScStyle_Subscript) |
2439 | - { |
2440 | - retval += asce * m_Doc->typographicSettings.valueSubScript / 100.0; |
2441 | - layout.yoffset += asce * m_Doc->typographicSettings.valueSubScript / 100.0; |
2442 | - layout.scaleV = layout.scaleH = qMax(m_Doc->typographicSettings.scalingSubScript / 100.0, 10.0 / style.fontSize()); |
2443 | - } |
2444 | - else { |
2445 | - layout.scaleV = layout.scaleH = 1.0; |
2446 | - } |
2447 | - layout.scaleH *= style.scaleH() / 1000.0; |
2448 | - layout.scaleV *= style.scaleV() / 1000.0; |
2449 | - if (chst & ScStyle_AllCaps) |
2450 | - { |
2451 | - layout.glyph = style.font().char2CMap(chars[0].toUpper().unicode()); |
2452 | - } |
2453 | - if (chst & ScStyle_SmallCaps) |
2454 | - { |
2455 | - double smallcapsScale = m_Doc->typographicSettings.valueSmallCaps / 100.0; |
2456 | - QChar uc = chars[0].toUpper(); |
2457 | - if (uc != chars[0]) |
2458 | - { |
2459 | - layout.glyph = style.font().char2CMap(chars[0].toUpper().unicode()); |
2460 | - layout.scaleV *= smallcapsScale; |
2461 | - layout.scaleH *= smallcapsScale; |
2462 | - } |
2463 | - } |
2464 | - } |
2465 | - else { |
2466 | - layout.scaleH = style.scaleH() / 1000.0; |
2467 | - layout.scaleV = style.scaleV() / 1000.0; |
2468 | - } |
2469 | - |
2470 | -/* if (layout.glyph == (ScFace::CONTROL_GLYPHS + SpecialChars::NBSPACE.unicode())) { |
2471 | - uint replGlyph = style.font().char2CMap(QChar(' ')); |
2472 | - layout.xadvance = style.font().glyphWidth(replGlyph, style.fontSize() / 10) * layout.scaleH; |
2473 | - layout.yadvance = style.font().glyphBBox(replGlyph, style.fontSize() / 10).ascent * layout.scaleV; |
2474 | - } |
2475 | - else if (layout.glyph == (ScFace::CONTROL_GLYPHS + SpecialChars::NBHYPHEN.unicode())) { |
2476 | - uint replGlyph = style.font().char2CMap(QChar('-')); |
2477 | - layout.xadvance = style.font().glyphWidth(replGlyph, style.fontSize() / 10) * layout.scaleH; |
2478 | - layout.yadvance = style.font().glyphBBox(replGlyph, style.fontSize() / 10).ascent * layout.scaleV; |
2479 | - } |
2480 | - else if (layout.glyph >= ScFace::CONTROL_GLYPHS) { |
2481 | - layout.xadvance = 0; |
2482 | - layout.yadvance = 0; |
2483 | - } |
2484 | - else */ |
2485 | - { |
2486 | - layout.xadvance = style.font().glyphWidth(layout.glyph, style.fontSize() / 10) * layout.scaleH; |
2487 | - layout.yadvance = style.font().glyphBBox(layout.glyph, style.fontSize() / 10).ascent * layout.scaleV; |
2488 | - } |
2489 | - if (layout.xadvance > 0) |
2490 | - layout.xadvance += tracking; |
2491 | - |
2492 | - if (chars.length() > 1) { |
2493 | - layout.grow(); |
2494 | - layoutGlyphs(style, chars.mid(1), *layout.more); |
2495 | - layout.xadvance += style.font().glyphKerning(layout.glyph, layout.more->glyph, style.fontSize() / 10) * layout.scaleH; |
2496 | - if (layout.more->yadvance > layout.yadvance) |
2497 | - layout.yadvance = layout.more->yadvance; |
2498 | - } |
2499 | - else { |
2500 | - layout.shrink(); |
2501 | - } |
2502 | - return retval; |
2503 | -} |
2504 | - |
2505 | -void PageItem::drawGlyphs(ScPainter *p, const CharStyle& style, GlyphLayout& glyphs) |
2506 | -{ |
2507 | - uint glyph = glyphs.glyph; |
2508 | - if ((m_Doc->guidesSettings.showControls) && |
2509 | - (glyph == style.font().char2CMap(QChar(' ')) || glyph >= ScFace::CONTROL_GLYPHS)) |
2510 | - { |
2511 | - bool stroke = false; |
2512 | - if (glyph >= ScFace::CONTROL_GLYPHS) |
2513 | - glyph -= ScFace::CONTROL_GLYPHS; |
2514 | - else |
2515 | - glyph = 32; |
2516 | - QMatrix chma, chma4, chma5; |
2517 | - FPointArray points; |
2518 | - if (glyph == SpecialChars::TAB.unicode()) |
2519 | - { |
2520 | - points = m_Doc->symTab.copy(); |
2521 | - chma4.translate(glyphs.xoffset + glyphs.xadvance - ((style.fontSize() / 10.0) * glyphs.scaleH * 0.7), glyphs.yoffset - ((style.fontSize() / 10.0) * glyphs.scaleV * 0.5)); |
2522 | - } |
2523 | - else if (glyph == SpecialChars::COLBREAK.unicode()) |
2524 | - { |
2525 | - points = m_Doc->symNewCol.copy(); |
2526 | - chma4.translate(glyphs.xoffset, glyphs.yoffset-((style.fontSize() / 10.0) * glyphs.scaleV * 0.6)); |
2527 | - } |
2528 | - else if (glyph == SpecialChars::FRAMEBREAK.unicode()) |
2529 | - { |
2530 | - points = m_Doc->symNewFrame.copy(); |
2531 | - chma4.translate(glyphs.xoffset, glyphs.yoffset-((style.fontSize() / 10.0) * glyphs.scaleV * 0.6)); |
2532 | - } |
2533 | - else if (glyph == SpecialChars::PARSEP.unicode()) |
2534 | - { |
2535 | - points = m_Doc->symReturn.copy(); |
2536 | - chma4.translate(glyphs.xoffset, glyphs.yoffset-((style.fontSize() / 10.0) * glyphs.scaleV * 0.8)); |
2537 | - } |
2538 | - else if (glyph == SpecialChars::LINEBREAK.unicode()) |
2539 | - { |
2540 | - points = m_Doc->symNewLine.copy(); |
2541 | - chma4.translate(glyphs.xoffset, glyphs.yoffset-((style.fontSize() / 10.0) * glyphs.scaleV * 0.4)); |
2542 | - } |
2543 | - else if (glyph == SpecialChars::NBSPACE.unicode() || |
2544 | - glyph == 32) |
2545 | - { |
2546 | - stroke = (glyph == 32); |
2547 | - points = m_Doc->symNonBreak.copy(); |
2548 | - chma4.translate(glyphs.xoffset, glyphs.yoffset-((style.fontSize() / 10.0) * glyphs.scaleV * 0.4)); |
2549 | - } |
2550 | - else if (glyph == SpecialChars::NBHYPHEN.unicode()) |
2551 | - { |
2552 | - points = style.font().glyphOutline(style.font().char2CMap(QChar('-')), style.fontSize() / 100); |
2553 | - chma4.translate(glyphs.xoffset, glyphs.yoffset-((style.fontSize() / 10.0) * glyphs.scaleV)); |
2554 | - } |
2555 | - else if (glyph == SpecialChars::SHYPHEN.unicode()) |
2556 | - { |
2557 | - points.resize(0); |
2558 | - points.addQuadPoint(0, -10, 0, -10, 0, -6, 0, -6); |
2559 | - stroke = true; |
2560 | - } |
2561 | - else // ??? |
2562 | - { |
2563 | - points.resize(0); |
2564 | - points.addQuadPoint(0, -10, 0, -10, 0, -9, 0, -9); |
2565 | - points.addQuadPoint(0, -9, 0, -9, 1, -9, 1, -9); |
2566 | - points.addQuadPoint(1, -9, 1, -9, 1, -10, 1, -10); |
2567 | - points.addQuadPoint(1, -10, 1, -10, 0, -10, 0, -10); |
2568 | - } |
2569 | - chma.scale(glyphs.scaleH * style.fontSize() / 100.0, glyphs.scaleV * style.fontSize() / 100.0); |
2570 | - points.map(chma * chma4); |
2571 | - p->setupPolygon(&points, true); |
2572 | - QColor oldBrush = p->brush(); |
2573 | - p->setBrush( (style.effects() & ScStyle_SuppressSpace) ? Qt::green |
2574 | - : PrefsManager::instance()->appPrefs.DControlCharColor); |
2575 | - if (stroke) |
2576 | - { |
2577 | - QColor tmp = p->pen(); |
2578 | - p->setPen(p->brush(), 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
2579 | - p->setLineWidth(style.fontSize() * glyphs.scaleV / 200.0); |
2580 | - p->strokePath(); |
2581 | - p->setPen(tmp, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
2582 | - } |
2583 | - else |
2584 | - { |
2585 | - p->setFillMode(1); |
2586 | - p->fillPath(); |
2587 | - } |
2588 | - p->setBrush(oldBrush); |
2589 | - if (glyphs.more) |
2590 | - { |
2591 | - p->translate(glyphs.xadvance, 0); |
2592 | - drawGlyphs(p, style, *glyphs.more); |
2593 | - } |
2594 | - return; |
2595 | - } |
2596 | - else if (glyph == (ScFace::CONTROL_GLYPHS + SpecialChars::NBSPACE.unicode()) || |
2597 | - glyph == (ScFace::CONTROL_GLYPHS + 32)) |
2598 | - glyph = style.font().char2CMap(QChar(' ')); |
2599 | - else if (glyph == (ScFace::CONTROL_GLYPHS + SpecialChars::NBHYPHEN.unicode())) |
2600 | - glyph = style.font().char2CMap(QChar('-')); |
2601 | - |
2602 | - if (glyph >= ScFace::CONTROL_GLYPHS || (style.effects() & ScStyle_SuppressSpace)) { |
2603 | -// qDebug("drawGlyphs: skipping %d", glyph); |
2604 | - // all those are empty |
2605 | - if (glyphs.more) |
2606 | - { |
2607 | - p->translate(glyphs.xadvance, 0); |
2608 | - drawGlyphs(p, style, *glyphs.more); |
2609 | - } |
2610 | - return; |
2611 | - } |
2612 | -// if (style.font().canRender(QChar(glyph))) |
2613 | - { |
2614 | - FPointArray gly = style.font().glyphOutline(glyph); |
2615 | - // Do underlining first so you can get typographically correct |
2616 | - // underlines when drawing a white outline |
2617 | - if (((style.effects() & ScStyle_Underline) || ((style.effects() & ScStyle_UnderlineWords) && glyph != style.font().char2CMap(QChar(' ')))) && (style.strokeColor() != CommonStrings::None)) |
2618 | - { |
2619 | - double st, lw; |
2620 | - if ((style.underlineOffset() != -1) || (style.underlineWidth() != -1)) |
2621 | - { |
2622 | - if (style.underlineOffset() != -1) |
2623 | - st = (style.underlineOffset() / 1000.0) * (style.font().descent(style.fontSize() / 10.0)); |
2624 | - else |
2625 | - st = style.font().underlinePos(style.fontSize() / 10.0); |
2626 | - if (style.underlineWidth() != -1) |
2627 | - lw = (style.underlineWidth() / 1000.0) * (style.fontSize() / 10.0); |
2628 | - else |
2629 | - lw = qMax(style.font().strokeWidth(style.fontSize() / 10.0), 1.0); |
2630 | - } |
2631 | - else |
2632 | - { |
2633 | - st = style.font().underlinePos(style.fontSize() / 10.0); |
2634 | - lw = qMax(style.font().strokeWidth(style.fontSize() / 10.0), 1.0); |
2635 | - } |
2636 | - if (style.baselineOffset() != 0) |
2637 | - st += (style.fontSize() / 10.0) * glyphs.scaleV * (style.baselineOffset() / 1000.0); |
2638 | - QColor tmpC = p->pen(); |
2639 | - p->setPen(p->brush()); |
2640 | - p->setLineWidth(lw); |
2641 | - if (style.effects() & ScStyle_Subscript) |
2642 | - p->drawLine(FPoint(glyphs.xoffset, glyphs.yoffset - st), FPoint(glyphs.xoffset + glyphs.xadvance, glyphs.yoffset - st)); |
2643 | - else |
2644 | - p->drawLine(FPoint(glyphs.xoffset, -st), FPoint(glyphs.xoffset + glyphs.xadvance, -st)); |
2645 | - p->setPen(tmpC); |
2646 | - } |
2647 | - if (gly.size() > 3) |
2648 | - { |
2649 | - if (glyph == 0) |
2650 | - { |
2651 | -// qDebug() << QString("glyph 0: (%1,%2) * %3 %4 + %5").arg(glyphs.xoffset).arg(glyphs.yoffset).arg(glyphs.scaleH).arg(glyphs.scaleV).arg(glyphs.xadvance)); |
2652 | - } |
2653 | - p->save(); |
2654 | - p->translate(glyphs.xoffset, glyphs.yoffset - ((style.fontSize() / 10.0) * glyphs.scaleV)); |
2655 | - if (Reverse) |
2656 | - { |
2657 | - p->scale(-1, 1); |
2658 | - p->translate(-glyphs.xadvance, 0); |
2659 | - } |
2660 | - if (style.baselineOffset() != 0) |
2661 | - p->translate(0, -(style.fontSize() / 10.0) * (style.baselineOffset() / 1000.0)); |
2662 | - double glxSc = glyphs.scaleH * style.fontSize() / 100.00; |
2663 | - double glySc = glyphs.scaleV * style.fontSize() / 100.0; |
2664 | - p->scale(glxSc, glySc); |
2665 | -// p->setFillMode(1); |
2666 | - bool fr = p->fillRule(); |
2667 | - p->setFillRule(false); |
2668 | -// double a = gly.point(0).x(); |
2669 | -// double b = gly.point(0).y(); |
2670 | -// double c = gly.point(3).x(); |
2671 | -// double d = gly.point(3).y(); |
2672 | -// qDebug() << QString("drawglyphs: %1 (%2,%3) (%4,%5) scaled %6,%7 trans %8,%9") |
2673 | -// .arg(gly.size()).arg(a).arg(b).arg(c).arg(d) |
2674 | -// .arg(p->worldMatrix().m11()).arg(p->worldMatrix().m22()).arg(p->worldMatrix().dx()).arg(p->worldMatrix().dy()); |
2675 | - p->setupPolygon(&gly, true); |
2676 | - if (m_Doc->layerOutline(LayerNr)) |
2677 | - { |
2678 | - p->save(); |
2679 | - p->setPen(m_Doc->layerMarker(LayerNr), 0.5, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
2680 | - p->setFillMode(ScPainter::None); |
2681 | - p->setBrushOpacity(1.0); |
2682 | - p->setPenOpacity(1.0); |
2683 | - p->strokePath(); |
2684 | - p->restore(); |
2685 | - p->setFillRule(fr); |
2686 | - p->restore(); |
2687 | - if (glyphs.more) |
2688 | - { |
2689 | - p->translate(glyphs.xadvance, 0); |
2690 | - drawGlyphs(p, style, *glyphs.more); |
2691 | - } |
2692 | - return; |
2693 | - } |
2694 | - if (glyph == 0) |
2695 | - { |
2696 | - p->setPen(PrefsManager::instance()->appPrefs.DControlCharColor, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
2697 | - p->setLineWidth(style.fontSize() * glyphs.scaleV * style.outlineWidth() * 2 / 10000.0); |
2698 | - p->strokePath(); |
2699 | - } |
2700 | - else if ((style.font().isStroked()) && (style.strokeColor() != CommonStrings::None) && ((style.fontSize() * glyphs.scaleV * style.outlineWidth() / 10000.0) != 0)) |
2701 | - { |
2702 | - QColor tmp = p->brush(); |
2703 | - p->setPen(tmp, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
2704 | - p->setLineWidth(style.fontSize() * glyphs.scaleV * style.outlineWidth() / 10000.0); |
2705 | - p->strokePath(); |
2706 | - } |
2707 | - else |
2708 | - { |
2709 | - if ((style.effects() & ScStyle_Shadowed) && (style.strokeColor() != CommonStrings::None)) |
2710 | - { |
2711 | - p->save(); |
2712 | - p->translate((style.fontSize() * glyphs.scaleH * style.shadowXOffset() / 10000.0) / glxSc, -(style.fontSize() * glyphs.scaleV * style.shadowYOffset() / 10000.0) / glySc); |
2713 | - QColor tmp = p->brush(); |
2714 | - p->setBrush(p->pen()); |
2715 | - p->setupPolygon(&gly, true); |
2716 | - p->fillPath(); |
2717 | - p->setBrush(tmp); |
2718 | - p->restore(); |
2719 | - p->setupPolygon(&gly, true); |
2720 | - } |
2721 | - if (style.fillColor() != CommonStrings::None) |
2722 | - p->fillPath(); |
2723 | - if ((style.effects() & ScStyle_Outline) && (style.strokeColor() != CommonStrings::None) && ((style.fontSize() * glyphs.scaleV * style.outlineWidth() / 10000.0) != 0)) |
2724 | - { |
2725 | - p->setLineWidth((style.fontSize() * glyphs.scaleV * style.outlineWidth() / 10000.0) / glySc); |
2726 | - p->strokePath(); |
2727 | - } |
2728 | - } |
2729 | - p->setFillRule(fr); |
2730 | - p->restore(); |
2731 | - } |
2732 | - else { |
2733 | -// qDebug() << "drawGlyphs: empty glyph" << glyph; |
2734 | - } |
2735 | - if ((style.effects() & ScStyle_Strikethrough) && (style.strokeColor() != CommonStrings::None)) |
2736 | - { |
2737 | - double st, lw; |
2738 | - if ((style.strikethruOffset() != -1) || (style.strikethruWidth() != -1)) |
2739 | - { |
2740 | - if (style.strikethruOffset() != -1) |
2741 | - st = (style.strikethruOffset() / 1000.0) * (style.font().ascent(style.fontSize() / 10.0)); |
2742 | - else |
2743 | - st = style.font().strikeoutPos(style.fontSize() / 10.0); |
2744 | - if (style.strikethruWidth() != -1) |
2745 | - lw = (style.strikethruWidth() / 1000.0) * (style.fontSize() / 10.0); |
2746 | - else |
2747 | - lw = qMax(style.font().strokeWidth(style.fontSize() / 10.0), 1.0); |
2748 | - } |
2749 | - else |
2750 | - { |
2751 | - st = style.font().strikeoutPos(style.fontSize() / 10.0); |
2752 | - lw = qMax(style.font().strokeWidth(style.fontSize() / 10.0), 1.0); |
2753 | - } |
2754 | - if (style.baselineOffset() != 0) |
2755 | - st += (style.fontSize() / 10.0) * glyphs.scaleV * (style.baselineOffset() / 1000.0); |
2756 | - p->setPen(p->brush()); |
2757 | - p->setLineWidth(lw); |
2758 | - p->drawLine(FPoint(glyphs.xoffset, glyphs.yoffset - st), FPoint(glyphs.xoffset + glyphs.xadvance, glyphs.yoffset - st)); |
2759 | - } |
2760 | - } |
2761 | -/* else |
2762 | - { |
2763 | - p->setLineWidth(1); |
2764 | - p->setPen(red); |
2765 | - p->setBrush(red); |
2766 | - p->setFillMode(1); |
2767 | - p->drawRect(glyphs.xoffset, glyphs.yoffset - (style.fontSize() / 10.0) * glyphs.scaleV , (style.fontSize() / 10.0) * glyphs.scaleH, (style.fontSize() / 10.0) * glyphs.scaleV); |
2768 | - } |
2769 | - */ |
2770 | - if (glyphs.more) |
2771 | - { |
2772 | - p->translate(glyphs.xadvance, 0); |
2773 | - drawGlyphs(p, style, *glyphs.more); |
2774 | - } |
2775 | -} |
2776 | - |
2777 | -void PageItem::DrawPolyL(QPainter *p, QPolygon pts) |
2778 | -{ |
2779 | - if (Segments.count() != 0) |
2780 | - { |
2781 | - QList<uint>::Iterator it2end=Segments.end(); |
2782 | - uint FirstVal = 0; |
2783 | - for (QList<uint>::Iterator it2 = Segments.begin(); it2 != it2end; ++it2) |
2784 | - { |
2785 | - p->drawPolygon(pts.constData() + FirstVal, (*it2)-FirstVal); |
2786 | - FirstVal = (*it2); |
2787 | - } |
2788 | - p->drawPolygon(pts.constData() + FirstVal, pts.size() - FirstVal); |
2789 | - } |
2790 | - else |
2791 | - p->drawPolygon(pts); |
2792 | -/* |
2793 | - QColor tmp; |
2794 | - if (Segments.count() != 0) |
2795 | - { |
2796 | - QList<uint>::Iterator it2end=Segments.end(); |
2797 | - uint FirstVal = 0; |
2798 | - for (QList<uint>::Iterator it2 = Segments.begin(); it2 != it2end; ++it2) |
2799 | - { |
2800 | - if (NamedLStyle.isEmpty()) |
2801 | - { |
2802 | - if (lineColor() != CommonStrings::None) |
2803 | - p->setPen(QPen(strokeQColor, m_lineWidth, PLineArt, PLineEnd, PLineJoin)); |
2804 | - p->drawPolygon(pts.constData() + FirstVal, (*it2)-FirstVal); |
2805 | - } |
2806 | - else |
2807 | - { |
2808 | - multiLine ml = m_Doc->MLineStyles[NamedLStyle]; |
2809 | - for (int it = ml.size()-1; it > -1; it--) |
2810 | - { |
2811 | - SetQColor(&tmp, ml[it].Color, ml[it].Shade); |
2812 | - p->setPen(QPen(tmp, |
2813 | - qMax(static_cast<int>(ml[it].Width), 1), |
2814 | - static_cast<Qt::PenStyle>(ml[it].Dash), |
2815 | - static_cast<Qt::PenCapStyle>(ml[it].LineEnd), |
2816 | - static_cast<Qt::PenJoinStyle>(ml[it].LineJoin))); |
2817 | - p->drawPolygon(pts.constData() + FirstVal, (*it2)-FirstVal); |
2818 | - } |
2819 | - } |
2820 | - FirstVal = (*it2); |
2821 | - } |
2822 | - if (NamedLStyle.isEmpty()) |
2823 | - { |
2824 | - if (lineColor() != CommonStrings::None) |
2825 | - p->setPen(QPen(strokeQColor, m_lineWidth, PLineArt, PLineEnd, PLineJoin)); |
2826 | - p->drawPolygon(pts.constData() + FirstVal, pts.size() - FirstVal); |
2827 | - } |
2828 | - else |
2829 | - { |
2830 | - multiLine ml = m_Doc->MLineStyles[NamedLStyle]; |
2831 | - for (int it = ml.size()-1; it > -1; it--) |
2832 | - { |
2833 | - SetQColor(&tmp, ml[it].Color, ml[it].Shade); |
2834 | - p->setPen(QPen(tmp, |
2835 | - qMax(static_cast<int>(ml[it].Width), 1), |
2836 | - static_cast<Qt::PenStyle>(ml[it].Dash), |
2837 | - static_cast<Qt::PenCapStyle>(ml[it].LineEnd), |
2838 | - static_cast<Qt::PenJoinStyle>(ml[it].LineJoin))); |
2839 | - p->drawPolygon(pts.constData() + FirstVal, pts.size() - FirstVal); |
2840 | - } |
2841 | - } |
2842 | - } |
2843 | - else |
2844 | - { |
2845 | - if (NamedLStyle.isEmpty()) |
2846 | - { |
2847 | - if (lineColor() != CommonStrings::None) |
2848 | - p->setPen(QPen(strokeQColor, m_lineWidth, PLineArt, PLineEnd, PLineJoin)); |
2849 | - p->drawPolygon(pts); |
2850 | - } |
2851 | - else |
2852 | - { |
2853 | - multiLine ml = m_Doc->MLineStyles[NamedLStyle]; |
2854 | - for (int it = ml.size()-1; it > -1; it--) |
2855 | - { |
2856 | - SetQColor(&tmp, ml[it].Color, ml[it].Shade); |
2857 | - p->setPen(QPen(tmp, |
2858 | - qMax(static_cast<int>(ml[it].Width), 1), |
2859 | - static_cast<Qt::PenStyle>(ml[it].Dash), |
2860 | - static_cast<Qt::PenCapStyle>(ml[it].LineEnd), |
2861 | - static_cast<Qt::PenJoinStyle>(ml[it].LineJoin))); |
2862 | - p->drawPolygon(pts); |
2863 | - } |
2864 | - } |
2865 | - } */ |
2866 | -} |
2867 | - |
2868 | -void PageItem::setItemName(const QString& newName) |
2869 | -{ |
2870 | - if (AnName == newName) |
2871 | - return; // nothing to do -> return |
2872 | - if (newName.isEmpty()) |
2873 | - return; |
2874 | - QString oldName = AnName; |
2875 | - AnName = generateUniqueCopyName(newName); |
2876 | - AutoName = false; |
2877 | - if (UndoManager::undoEnabled()) |
2878 | - { |
2879 | - SimpleState *ss = new SimpleState(Um::Rename, QString(Um::FromTo).arg(AnName).arg(newName)); |
2880 | - ss->set("OLD_NAME", oldName); |
2881 | - ss->set("NEW_NAME", newName); |
2882 | - undoManager->action(this, ss); |
2883 | - } |
2884 | - setUName(AnName); // set the name for the UndoObject too |
2885 | -} |
2886 | - |
2887 | -void PageItem::setPattern(const QString &newPattern) |
2888 | -{ |
2889 | - if (patternVal != newPattern) |
2890 | - patternVal = newPattern; |
2891 | -} |
2892 | - |
2893 | -void PageItem::gradientVector(double& startX, double& startY, double& endX, double& endY) const |
2894 | -{ |
2895 | - startX = GrStartX; |
2896 | - startY = GrStartY; |
2897 | - endX = GrEndX; |
2898 | - endY = GrEndY; |
2899 | -} |
2900 | - |
2901 | -void PageItem::setGradientVector(double startX, double startY, double endX, double endY) |
2902 | -{ |
2903 | - GrStartX = startX; |
2904 | - GrStartY = startY; |
2905 | - GrEndX = endX; |
2906 | - GrEndY = endY; |
2907 | -} |
2908 | - |
2909 | -void PageItem::setPatternTransform(double scaleX, double scaleY, double offsetX, double offsetY, double rotation) |
2910 | -{ |
2911 | - patternScaleX = scaleX; |
2912 | - patternScaleY = scaleY; |
2913 | - patternOffsetX = offsetX; |
2914 | - patternOffsetY = offsetY; |
2915 | - patternRotation = rotation; |
2916 | -} |
2917 | - |
2918 | -void PageItem::patternTransform(double &scaleX, double &scaleY, double &offsetX, double &offsetY, double &rotation) const |
2919 | -{ |
2920 | - scaleX = patternScaleX; |
2921 | - scaleY = patternScaleY; |
2922 | - offsetX = patternOffsetX; |
2923 | - offsetY = patternOffsetY; |
2924 | - rotation = patternRotation; |
2925 | -} |
2926 | - |
2927 | -void PageItem::setFillColor(const QString &newColor) |
2928 | -{ |
2929 | - QString tmp = newColor; |
2930 | - if (tmp != CommonStrings::None) |
2931 | - { |
2932 | - if (!m_Doc->PageColors.contains(newColor)) |
2933 | - { |
2934 | - switch(itemType()) |
2935 | - { |
2936 | - case ImageFrame: |
2937 | - case LatexFrame: |
2938 | - tmp = m_Doc->toolSettings.dBrushPict; |
2939 | - case TextFrame: |
2940 | - case PathText: |
2941 | - tmp = m_Doc->toolSettings.dTextBackGround; |
2942 | - break; |
2943 | - case Line: |
2944 | - case PolyLine: |
2945 | - case Polygon: |
2946 | - tmp = m_Doc->toolSettings.dBrush; |
2947 | - break; |
2948 | - default: |
2949 | - break; |
2950 | - } |
2951 | - } |
2952 | - } |
2953 | - if (fillColorVal == tmp) |
2954 | - { |
2955 | - setFillQColor(); |
2956 | - return; |
2957 | - } |
2958 | - if (UndoManager::undoEnabled()) |
2959 | - { |
2960 | - SimpleState *ss = new SimpleState(Um::SetFill, |
2961 | - QString(Um::ColorFromTo).arg(fillColorVal).arg(tmp), |
2962 | - Um::IFill); |
2963 | - ss->set("FILL", "fill"); |
2964 | - ss->set("OLD_FILL", fillColorVal); |
2965 | - ss->set("NEW_FILL", tmp); |
2966 | - undoManager->action(this, ss); |
2967 | - } |
2968 | - fillColorVal = tmp; |
2969 | - if (GrType == 0) |
2970 | - { |
2971 | - fill_gradient = VGradient(VGradient::linear); |
2972 | - fill_gradient.clearStops(); |
2973 | - if (fillColorVal != CommonStrings::None) |
2974 | - { |
2975 | - const ScColor& col = m_Doc->PageColors[fillColorVal]; |
2976 | - fill_gradient.addStop(ScColorEngine::getRGBColor(col, m_Doc), 0.0, 0.5, 1.0, fillColorVal, 100); |
2977 | - fill_gradient.addStop(ScColorEngine::getRGBColor(col, m_Doc), 1.0, 0.5, 1.0, fillColorVal, 100); |
2978 | - } |
2979 | - } |
2980 | - setFillQColor(); |
2981 | -//CB unused in 135 emit colors(lineColorVal, fillColorVal, lineShadeVal, fillShadeVal); |
2982 | -} |
2983 | - |
2984 | -void PageItem::setFillShade(double newShade) |
2985 | -{ |
2986 | - if (fillShadeVal == newShade) |
2987 | - { |
2988 | - setFillQColor(); |
2989 | - return; |
2990 | - } |
2991 | - if (UndoManager::undoEnabled()) |
2992 | - { |
2993 | - SimpleState *ss = new SimpleState(Um::SetShade, |
2994 | - QString(Um::FromTo).arg(fillShadeVal).arg(newShade), |
2995 | - Um::IShade); |
2996 | - ss->set("SHADE", "shade"); |
2997 | - ss->set("OLD_SHADE", fillShadeVal); |
2998 | - ss->set("NEW_SHADE", newShade); |
2999 | - undoManager->action(this, ss); |
3000 | - } |
3001 | - fillShadeVal = newShade; |
3002 | - setFillQColor(); |
3003 | -//CB unused in 135 emit colors(lineColorVal, fillColorVal, lineShadeVal, fillShadeVal); |
3004 | -} |
3005 | - |
3006 | -void PageItem::setFillTransparency(double newTransparency) |
3007 | -{ |
3008 | - if (fillTransparencyVal == newTransparency) |
3009 | - return; // nothing to do -> return |
3010 | - if (UndoManager::undoEnabled()) |
3011 | - { |
3012 | - SimpleState *ss = new SimpleState(Um::Transparency, |
3013 | - QString(Um::FromTo).arg(fillTransparencyVal).arg(newTransparency), |
3014 | - Um::ITransparency); |
3015 | - ss->set("TRANSPARENCY", "transparency"); |
3016 | - ss->set("OLD_TP", fillTransparencyVal); |
3017 | - ss->set("NEW_TP", newTransparency); |
3018 | - undoManager->action(this, ss); |
3019 | - } |
3020 | - fillTransparencyVal = newTransparency; |
3021 | -} |
3022 | - |
3023 | -void PageItem::setFillBlendmode(int newBlendmode) |
3024 | -{ |
3025 | - if (fillBlendmodeVal == newBlendmode) |
3026 | - return; // nothing to do -> return |
3027 | - fillBlendmodeVal = newBlendmode; |
3028 | -} |
3029 | - |
3030 | -void PageItem::setLineColor(const QString &newColor) |
3031 | -{ |
3032 | - QString tmp = newColor; |
3033 | - if (tmp != CommonStrings::None) |
3034 | - { |
3035 | - if (!m_Doc->PageColors.contains(newColor)) |
3036 | - { |
3037 | - switch(itemType()) |
3038 | - { |
3039 | - case TextFrame: |
3040 | - case PathText: |
3041 | - tmp = m_Doc->toolSettings.dTextLineColor; |
3042 | - break; |
3043 | - case Line: |
3044 | - tmp = m_Doc->toolSettings.dPenLine; |
3045 | - break; |
3046 | - case PolyLine: |
3047 | - case Polygon: |
3048 | - case ImageFrame: |
3049 | - case LatexFrame: |
3050 | - tmp = m_Doc->toolSettings.dPen; |
3051 | - break; |
3052 | - default: |
3053 | - break; |
3054 | - } |
3055 | - } |
3056 | - } |
3057 | - if (lineColorVal == tmp) |
3058 | - { |
3059 | - setLineQColor(); |
3060 | - return; |
3061 | - } |
3062 | - if (UndoManager::undoEnabled()) |
3063 | - { |
3064 | - SimpleState *ss = new SimpleState(Um::SetLineColor, |
3065 | - QString(Um::ColorFromTo).arg(lineColorVal).arg(tmp), |
3066 | - Um::IFill); |
3067 | - ss->set("LINE_COLOR", "line_color"); |
3068 | - ss->set("OLD_COLOR", lineColorVal); |
3069 | - ss->set("NEW_COLOR", tmp); |
3070 | - undoManager->action(this, ss); |
3071 | - } |
3072 | - lineColorVal = tmp; |
3073 | - setLineQColor(); |
3074 | -//CB unused in 135 emit colors(lineColorVal, fillColorVal, lineShadeVal, fillShadeVal); |
3075 | -} |
3076 | - |
3077 | -void PageItem::setLineShade(double newShade) |
3078 | -{ |
3079 | - if (lineShadeVal == newShade) |
3080 | - { |
3081 | - setLineQColor(); |
3082 | - return; |
3083 | - } |
3084 | - if (UndoManager::undoEnabled()) |
3085 | - { |
3086 | - SimpleState *ss = new SimpleState(Um::SetLineShade, |
3087 | - QString(Um::FromTo).arg(lineShadeVal).arg(newShade), |
3088 | - Um::IShade); |
3089 | - ss->set("LINE_SHADE", "line_shade"); |
3090 | - ss->set("OLD_SHADE", lineShadeVal); |
3091 | - ss->set("NEW_SHADE", newShade); |
3092 | - undoManager->action(this, ss); |
3093 | - } |
3094 | - lineShadeVal = newShade; |
3095 | - setLineQColor(); |
3096 | -//CB unused in 135 emit colors(lineColorVal, fillColorVal, lineShadeVal, fillShadeVal); |
3097 | -} |
3098 | - |
3099 | -void PageItem::setLineQColor() |
3100 | -{ |
3101 | - if (lineColorVal != CommonStrings::None) |
3102 | - { |
3103 | - if (!m_Doc->PageColors.contains(lineColorVal)) |
3104 | - { |
3105 | - switch(itemType()) |
3106 | - { |
3107 | - case TextFrame: |
3108 | - case PathText: |
3109 | - lineColorVal = m_Doc->toolSettings.dTextLineColor; |
3110 | - break; |
3111 | - case Line: |
3112 | - lineColorVal = m_Doc->toolSettings.dPenLine; |
3113 | - break; |
3114 | - case PolyLine: |
3115 | - case Polygon: |
3116 | - case ImageFrame: |
3117 | - case LatexFrame: |
3118 | - lineColorVal = m_Doc->toolSettings.dPen; |
3119 | - break; |
3120 | - default: |
3121 | - break; |
3122 | - } |
3123 | - } |
3124 | - if (!m_Doc->PageColors.contains(lineColorVal)) |
3125 | - lineColorVal = m_Doc->toolSettings.dPen; |
3126 | - const ScColor& col = m_Doc->PageColors[lineColorVal]; |
3127 | - strokeQColor = ScColorEngine::getShadeColorProof(col, m_Doc, lineShadeVal); |
3128 | - } |
3129 | - if ((m_Doc->view()) && (m_Doc->view()->m_canvas->usePreviewVisual())) |
3130 | - { |
3131 | - VisionDefectColor defect; |
3132 | - strokeQColor = defect.convertDefect(strokeQColor, m_Doc->view()->m_canvas->previewVisual()); |
3133 | - } |
3134 | -} |
3135 | - |
3136 | -void PageItem::setFillQColor() |
3137 | -{ |
3138 | - if (fillColorVal != CommonStrings::None) |
3139 | - { |
3140 | - if (!m_Doc->PageColors.contains(fillColorVal)) |
3141 | - { |
3142 | - switch(itemType()) |
3143 | - { |
3144 | - case ImageFrame: |
3145 | - case LatexFrame: |
3146 | - fillColorVal = m_Doc->toolSettings.dBrushPict; |
3147 | - case TextFrame: |
3148 | - case PathText: |
3149 | - fillColorVal = m_Doc->toolSettings.dTextBackGround; |
3150 | - break; |
3151 | - case Line: |
3152 | - case PolyLine: |
3153 | - case Polygon: |
3154 | - fillColorVal = m_Doc->toolSettings.dBrush; |
3155 | - break; |
3156 | - default: |
3157 | - break; |
3158 | - } |
3159 | - } |
3160 | - const ScColor& col = m_Doc->PageColors[fillColorVal]; |
3161 | - fillQColor = ScColorEngine::getShadeColorProof(col, m_Doc, fillShadeVal); |
3162 | - } |
3163 | - if ((m_Doc->view()) && (m_Doc->view()->m_canvas->usePreviewVisual())) |
3164 | - { |
3165 | - VisionDefectColor defect; |
3166 | - fillQColor = defect.convertDefect(fillQColor, m_Doc->view()->m_canvas->previewVisual()); |
3167 | - } |
3168 | -} |
3169 | - |
3170 | -void PageItem::setLineTransparency(double newTransparency) |
3171 | -{ |
3172 | - if (lineTransparencyVal == newTransparency) |
3173 | - return; // nothing to do -> return |
3174 | - if (UndoManager::undoEnabled()) |
3175 | - { |
3176 | - SimpleState *ss = new SimpleState(Um::LineTransparency, |
3177 | - QString(Um::FromTo).arg(lineTransparencyVal).arg(newTransparency), |
3178 | - Um::ITransparency); |
3179 | - ss->set("LINE_TRANSPARENCY", "transparency"); |
3180 | - ss->set("OLD_TP", lineTransparencyVal); |
3181 | - ss->set("NEW_TP", newTransparency); |
3182 | - undoManager->action(this, ss); |
3183 | - } |
3184 | - lineTransparencyVal = newTransparency; |
3185 | -} |
3186 | - |
3187 | -void PageItem::setLineBlendmode(int newBlendmode) |
3188 | -{ |
3189 | - if (lineBlendmodeVal == newBlendmode) |
3190 | - return; // nothing to do -> return |
3191 | - lineBlendmodeVal = newBlendmode; |
3192 | -} |
3193 | - |
3194 | -void PageItem::setLineStyle(Qt::PenStyle newStyle) |
3195 | -{ |
3196 | - if (PLineArt == newStyle) |
3197 | - return; // nothing to do -> return |
3198 | - if (UndoManager::undoEnabled()) |
3199 | - { |
3200 | - SimpleState *ss = new SimpleState(Um::LineStyle,"",Um::ILineStyle); |
3201 | - ss->set("LINE_STYLE", "line_style"); |
3202 | - ss->set("OLD_STYLE", static_cast<int>(PLineArt)); |
3203 | - ss->set("NEW_STYLE", static_cast<int>(newStyle)); |
3204 | - undoManager->action(this, ss); |
3205 | - } |
3206 | - PLineArt = newStyle; |
3207 | -} |
3208 | - |
3209 | -void PageItem::setLineWidth(double newWidth) |
3210 | -{ |
3211 | - if (m_lineWidth == newWidth) |
3212 | - return; // nothing to do -> return |
3213 | - if (UndoManager::undoEnabled()) |
3214 | - { |
3215 | - SimpleState *ss = new SimpleState(Um::LineWidth, |
3216 | - QString(Um::FromTo).arg(m_lineWidth).arg(newWidth),Um::ILineStyle); |
3217 | - ss->set("LINE_WIDTH", "line_width"); |
3218 | - ss->set("OLD_WIDTH", m_lineWidth); |
3219 | - ss->set("NEW_WIDTH", newWidth); |
3220 | - undoManager->action(this, ss); |
3221 | - } |
3222 | - Oldm_lineWidth=m_lineWidth; |
3223 | - m_lineWidth = newWidth; |
3224 | -} |
3225 | - |
3226 | -void PageItem::setLineEnd(Qt::PenCapStyle newStyle) |
3227 | -{ |
3228 | - if (PLineEnd == newStyle) |
3229 | - return; // nothing to do -> return |
3230 | - if (UndoManager::undoEnabled()) |
3231 | - { |
3232 | - SimpleState *ss = new SimpleState(Um::LineEnd,"",Um::ILineStyle); |
3233 | - ss->set("LINE_END", "line_end"); |
3234 | - ss->set("OLD_STYLE", static_cast<int>(PLineEnd)); |
3235 | - ss->set("NEW_STYLE", static_cast<int>(newStyle)); |
3236 | - undoManager->action(this, ss); |
3237 | - } |
3238 | - PLineEnd = newStyle; |
3239 | -} |
3240 | - |
3241 | -void PageItem::setLineJoin(Qt::PenJoinStyle newStyle) |
3242 | -{ |
3243 | - if (PLineJoin == newStyle) |
3244 | - return; // nothing to do -> return |
3245 | - if (UndoManager::undoEnabled()) |
3246 | - { |
3247 | - SimpleState *ss = new SimpleState(Um::LineJoin,"",Um::ILineStyle); |
3248 | - ss->set("LINE_JOIN", "line_join"); |
3249 | - ss->set("OLD_STYLE", static_cast<int>(PLineJoin)); |
3250 | - ss->set("NEW_STYLE", static_cast<int>(newStyle)); |
3251 | - undoManager->action(this, ss); |
3252 | - } |
3253 | - PLineJoin = newStyle; |
3254 | -} |
3255 | - |
3256 | -void PageItem::setCustomLineStyle(const QString& newStyle) |
3257 | -{ |
3258 | - if (NamedLStyle == newStyle) |
3259 | - return; // nothing to do -> return |
3260 | - if (UndoManager::undoEnabled()) |
3261 | - { |
3262 | - QString oldStyle = NamedLStyle.isEmpty() ? Um::NoStyle : NamedLStyle; |
3263 | - QString nStyle = newStyle.isEmpty() ? Um::NoStyle : newStyle; |
3264 | - QString action = newStyle.isEmpty() ? Um::NoLineStyle : Um::CustomLineStyle; |
3265 | - SimpleState *ss = new SimpleState(action, |
3266 | - QString(Um::FromTo).arg(oldStyle).arg(nStyle),Um::ILineStyle); |
3267 | - ss->set("CUSTOM_LINE_STYLE", "customlinestyle"); |
3268 | - ss->set("OLD_STYLE", NamedLStyle); |
3269 | - ss->set("NEW_STYLE", newStyle); |
3270 | - undoManager->action(this, ss); |
3271 | - } |
3272 | - NamedLStyle = newStyle; |
3273 | -} |
3274 | - |
3275 | -void PageItem::setStartArrowIndex(int newIndex) |
3276 | -{ |
3277 | - if (m_startArrowIndex == newIndex) |
3278 | - return; // nothing to do -> return |
3279 | - if (UndoManager::undoEnabled()) |
3280 | - { |
3281 | - SimpleState *ss = new SimpleState(Um::StartArrow,"",Um::IArrow); |
3282 | - ss->set("START_ARROW", "startarrow"); |
3283 | - ss->set("OLD_INDEX", m_startArrowIndex); |
3284 | - ss->set("NEW_INDEX", newIndex); |
3285 | - undoManager->action(this, ss); |
3286 | - } |
3287 | - m_startArrowIndex = newIndex; |
3288 | -} |
3289 | - |
3290 | -void PageItem::setEndArrowIndex(int newIndex) |
3291 | -{ |
3292 | - if (m_endArrowIndex == newIndex) |
3293 | - return; // nothing to do -> return |
3294 | - if (UndoManager::undoEnabled()) |
3295 | - { |
3296 | - SimpleState *ss = new SimpleState(Um::EndArrow,"",Um::IArrow); |
3297 | - ss->set("END_ARROW", "endarrow"); |
3298 | - ss->set("OLD_INDEX", m_endArrowIndex); |
3299 | - ss->set("NEW_INDEX", newIndex); |
3300 | - undoManager->action(this, ss); |
3301 | - } |
3302 | - m_endArrowIndex = newIndex; |
3303 | -} |
3304 | - |
3305 | -void PageItem::setImageFlippedH(bool flipped) |
3306 | -{ |
3307 | - if (flipped != m_ImageIsFlippedH) |
3308 | - flipImageH(); |
3309 | -} |
3310 | - |
3311 | -void PageItem::flipImageH() |
3312 | -{ |
3313 | - if (UndoManager::undoEnabled()) |
3314 | - { |
3315 | - SimpleState *ss = new SimpleState(Um::FlipH, 0, Um::IFlipH); |
3316 | - ss->set("IMAGEFLIPH", "imagefliph"); |
3317 | - undoManager->action(this, ss); |
3318 | - } |
3319 | - m_ImageIsFlippedH = !m_ImageIsFlippedH; |
3320 | - emit frameFlippedH(m_ImageIsFlippedH); |
3321 | -} |
3322 | - |
3323 | -void PageItem::setImageFlippedV(bool flipped) |
3324 | -{ |
3325 | - if (flipped != m_ImageIsFlippedV) |
3326 | - flipImageV(); |
3327 | -} |
3328 | - |
3329 | -void PageItem::flipImageV() |
3330 | -{ |
3331 | - if (UndoManager::undoEnabled()) |
3332 | - { |
3333 | - SimpleState *ss = new SimpleState(Um::FlipV, 0, Um::IFlipV); |
3334 | - ss->set("IMAGEFLIPV", "imageflipv"); |
3335 | - undoManager->action(this, ss); |
3336 | - } |
3337 | - m_ImageIsFlippedV = !m_ImageIsFlippedV; |
3338 | - emit frameFlippedV(m_ImageIsFlippedV); |
3339 | -} |
3340 | - |
3341 | -void PageItem::setImageScalingMode(bool freeScale, bool keepRatio) |
3342 | -{ |
3343 | - if (ScaleType == freeScale && AspectRatio == keepRatio) |
3344 | - return; |
3345 | - if (UndoManager::undoEnabled()) |
3346 | - { |
3347 | - QString from = ScaleType ? Um::FreeScaling : Um::FrameSize; |
3348 | - from += ", "; |
3349 | - from += AspectRatio ? Um::KeepRatio : Um::BreakRatio; |
3350 | - QString to = freeScale ? Um::FreeScaling : Um::FrameSize; |
3351 | - to += ", "; |
3352 | - to += keepRatio ? Um::KeepRatio : Um::BreakRatio; |
3353 | - SimpleState *ss = new SimpleState(Um::ImageScaling, QString(Um::FromTo).arg(from).arg(to), Um::IImageScaling); |
3354 | - ss->set("SCALE_MODE", "scaling_mode"); |
3355 | - if (freeScale != ScaleType) |
3356 | - { |
3357 | - ss->set("SCALE_TYPE", freeScale); |
3358 | - if (!freeScale) |
3359 | - { |
3360 | - //if switching from free scaling to frame size |
3361 | - //in undo must be offset and scale saved |
3362 | - ss->set("OLD_IMAGEXOFFSET", LocalX); |
3363 | - ss->set("OLD_IMAGEYOFFSET", LocalY); |
3364 | - ss->set("OLD_IMAGEXSCALE", LocalScX); |
3365 | - ss->set("OLD_IMAGEYSCALE", LocalScY); |
3366 | - } |
3367 | - } |
3368 | - if (keepRatio != AspectRatio) |
3369 | - ss->set("ASPECT_RATIO", keepRatio); |
3370 | - undoManager->action(this, ss); |
3371 | - } |
3372 | - ScaleType = freeScale; |
3373 | - AspectRatio = keepRatio; |
3374 | - AdjustPictScale(); |
3375 | - update(); |
3376 | -} |
3377 | - |
3378 | -void PageItem::toggleLock() |
3379 | -{ |
3380 | - if (UndoManager::undoEnabled()) |
3381 | - { |
3382 | - SimpleState *ss; |
3383 | - if (m_Locked) |
3384 | - ss = new SimpleState(Um::UnLock, 0, Um::IUnLock); |
3385 | - else |
3386 | - ss = new SimpleState(Um::Lock, 0, Um::ILock); |
3387 | - ss->set("LOCK", "lock"); |
3388 | - undoManager->action(this, ss); |
3389 | - } |
3390 | - m_Locked = !m_Locked; |
3391 | - emit frameLocked(m_Locked); |
3392 | -} |
3393 | - |
3394 | -void PageItem::setLocked(bool isLocked) |
3395 | -{ |
3396 | - if (isLocked != m_Locked) |
3397 | - toggleLock(); |
3398 | -} |
3399 | - |
3400 | -void PageItem::setGroupsLastItem(PageItem* item) |
3401 | -{ |
3402 | - if (UndoManager::undoEnabled()) |
3403 | - { |
3404 | - ItemState<std::pair<PageItem*, PageItem*> > *is = new ItemState<std::pair<PageItem*, PageItem*> >("GroupsLastItem"); |
3405 | - is->set("GROUPS_LASTITEM", "groups_lastitem"); |
3406 | - is->setItem(std::pair<PageItem*, PageItem*>(this->groupsLastItem, item)); |
3407 | - undoManager->action(this, is); |
3408 | - } |
3409 | - groupsLastItem = item; |
3410 | -} |
3411 | - |
3412 | -void PageItem::toggleSizeLock() |
3413 | -{ |
3414 | - if (UndoManager::undoEnabled()) |
3415 | - { |
3416 | - SimpleState *ss; |
3417 | - if (m_SizeLocked) |
3418 | - ss = new SimpleState(Um::SizeUnLock, 0, Um::IUnLock); |
3419 | - else |
3420 | - ss = new SimpleState(Um::SizeLock, 0, Um::ILock); |
3421 | - ss->set("SIZE_LOCK", "size_lock"); |
3422 | - undoManager->action(this, ss); |
3423 | - } |
3424 | - m_SizeLocked = !m_SizeLocked; |
3425 | - emit frameSizeLocked(m_SizeLocked); |
3426 | -} |
3427 | - |
3428 | -void PageItem::setSizeLocked(bool isLocked) |
3429 | -{ |
3430 | - if (isLocked != m_SizeLocked) |
3431 | - toggleSizeLock(); |
3432 | -} |
3433 | - |
3434 | - |
3435 | -void PageItem::setPrintEnabled(bool toPrint) |
3436 | -{ |
3437 | - if (toPrint != m_PrintEnabled) |
3438 | - togglePrintEnabled(); |
3439 | -} |
3440 | - |
3441 | -void PageItem::togglePrintEnabled() |
3442 | -{ |
3443 | - if (UndoManager::undoEnabled()) |
3444 | - { |
3445 | - SimpleState *ss; |
3446 | - if (m_PrintEnabled) |
3447 | - ss = new SimpleState(Um::DisablePrint, 0, Um::IDisablePrint); |
3448 | - else |
3449 | - ss = new SimpleState(Um::EnablePrint, 0, Um::IEnablePrint); |
3450 | - ss->set("PRINT_ENABLED", "print_enabled"); |
3451 | - undoManager->action(this, ss); |
3452 | - } |
3453 | - m_PrintEnabled=!m_PrintEnabled; |
3454 | - emit printEnabled(m_PrintEnabled); |
3455 | -} |
3456 | - |
3457 | -void PageItem::setTextFlowMode(TextFlowMode mode) |
3458 | -{ |
3459 | - if (textFlowModeVal == mode) |
3460 | - return; |
3461 | - if (UndoManager::undoEnabled()) |
3462 | - { |
3463 | - QString stateMessage; |
3464 | - if( mode == TextFlowUsesFrameShape ) |
3465 | - stateMessage = Um::ObjectFrame; |
3466 | - else if( mode == TextFlowUsesBoundingBox ) |
3467 | - stateMessage = Um::BoundingBox; |
3468 | - else if( mode == TextFlowUsesContourLine ) |
3469 | - stateMessage = Um::ContourLine; |
3470 | - else if( mode == TextFlowUsesImageClipping ) |
3471 | - stateMessage = Um::ImageClip; |
3472 | - else |
3473 | - stateMessage = Um::NoTextFlow; |
3474 | - SimpleState *ss = new SimpleState(stateMessage, "", Um::IFont); |
3475 | - ss->set("TEXTFLOW_OLDMODE", (int) textFlowModeVal); |
3476 | - ss->set("TEXTFLOW_NEWMODE", (int) mode); |
3477 | - undoManager->action(this, ss); |
3478 | - } |
3479 | - textFlowModeVal = mode; |
3480 | - |
3481 | - checkTextFlowInteractions(); |
3482 | -} |
3483 | - |
3484 | -void PageItem::checkTextFlowInteractions(bool allItems) |
3485 | -{ |
3486 | - if(!m_Doc->isLoading()) |
3487 | - { |
3488 | - QRectF baseRect(getBoundingRect()); |
3489 | - QList<PageItem*>* items = OnMasterPage.isEmpty() ? &m_Doc->DocItems : &m_Doc->MasterItems; |
3490 | - for(int idx = (allItems ? items->count()-1 : ItemNr-1); idx >= 0 ; --idx) |
3491 | - { |
3492 | - if(idx != static_cast<int>(ItemNr)) // avoids itself |
3493 | - { |
3494 | - if(items->at(idx)->asTextFrame()) // do not bother with no text frames |
3495 | - { |
3496 | - QRectF uRect(items->at(idx)->getBoundingRect()); |
3497 | - if(baseRect.intersects(uRect)) |
3498 | - { |
3499 | - items->at(idx)->update(); |
3500 | - } |
3501 | - } |
3502 | - } |
3503 | - } |
3504 | - } |
3505 | -} |
3506 | - |
3507 | -void PageItem::convertTo(ItemType newType) |
3508 | -{ |
3509 | - if (m_ItemType == newType) |
3510 | - return; // nothing to do -> return |
3511 | - assert(newType != 1); //DEBUG CR 2005-02-06 |
3512 | - assert(newType != 3); //DEBUG CR 2005-02-06 |
3513 | - QString fromType = "", toType = ""; |
3514 | - switch (m_ItemType) |
3515 | - { |
3516 | - case ImageFrame: |
3517 | - if (asLatexFrame()) { |
3518 | - fromType = Um::LatexFrame; |
3519 | - } else { |
3520 | - fromType = Um::ImageFrame; |
3521 | - } |
3522 | - break; |
3523 | - case TextFrame: |
3524 | - fromType = Um::TextFrame; |
3525 | - break; |
3526 | - case Polygon: |
3527 | - fromType = Um::Polygon; |
3528 | - break; |
3529 | - default: |
3530 | - fromType = ""; |
3531 | - break; |
3532 | - } |
3533 | - switch (newType) |
3534 | - { |
3535 | - case ImageFrame: |
3536 | - toType = Um::ImageFrame; |
3537 | - setUPixmap(Um::IImageFrame); |
3538 | - break; |
3539 | - case LatexFrame: |
3540 | - toType = Um::LatexFrame; |
3541 | - setUPixmap(Um::ILatexFrame); |
3542 | - break; |
3543 | - case TextFrame: |
3544 | - toType = Um::TextFrame; |
3545 | - setUPixmap(Um::ITextFrame); |
3546 | - break; |
3547 | - case Polygon: |
3548 | - toType = Um::Polygon; |
3549 | - setUPixmap(Um::IPolygon); |
3550 | - break; |
3551 | - case PolyLine: |
3552 | - toType = Um::Polyline; |
3553 | - setUPixmap(Um::IPolyline); |
3554 | - break; |
3555 | - default: |
3556 | - toType = ""; |
3557 | - setUPixmap(NULL); |
3558 | - break; |
3559 | - } |
3560 | - /* |
3561 | - if (UndoManager::undoEnabled()) |
3562 | - { |
3563 | - SimpleState *ss = new SimpleState(Um::ConvertTo + " " + toType, |
3564 | - QString(Um::FromTo).arg(fromType).arg(toType)); |
3565 | - ss->set("CONVERT", "convert"); |
3566 | - ss->set("PAGEITEM", reinterpret_cast<int>(this)); |
3567 | - ss->set("OLD_TYPE", m_ItemType); |
3568 | - ss->set("NEW_TYPE", newType); |
3569 | - undoManager->action(this, ss); |
3570 | - } |
3571 | - */ |
3572 | - m_ItemType = newType; |
3573 | - emit frameType(m_ItemType); |
3574 | -} |
3575 | - |
3576 | -void PageItem::setLayer(int layerId) |
3577 | -{ |
3578 | - if (LayerNr == layerId) |
3579 | - return; |
3580 | - if (UndoManager::undoEnabled()) |
3581 | - { |
3582 | - SimpleState *ss = new SimpleState(Um::SendToLayer, |
3583 | - QString(Um::FromTo).arg(LayerNr).arg(layerId), |
3584 | - Um::ILayerAction); |
3585 | - ss->set("SEND_TO_LAYER", "send_to_layer"); |
3586 | - ss->set("OLD_LAYER", LayerNr); |
3587 | - ss->set("NEW_LAYER", layerId); |
3588 | - undoManager->action(this, ss); |
3589 | - } |
3590 | - LayerNr = layerId; |
3591 | -} |
3592 | - |
3593 | -void PageItem::checkChanges(bool force) |
3594 | -{ |
3595 | - bool spreadChanges(false); |
3596 | - // has the item been resized |
3597 | - if (force || ((oldWidth != Width || oldHeight != Height) && shouldCheck())) |
3598 | - { |
3599 | - resizeUndoAction(); |
3600 | - spreadChanges = (textFlowMode() != TextFlowDisabled ); |
3601 | - } |
3602 | - // has the item been rotated |
3603 | - if (force || ((oldRot != Rot) && (shouldCheck()))) |
3604 | - { |
3605 | - rotateUndoAction(); |
3606 | - spreadChanges = (textFlowMode() != TextFlowDisabled ); |
3607 | - } |
3608 | - // has the item been moved |
3609 | - if (force || ((oldXpos != Xpos || oldYpos != Ypos) && shouldCheck())) |
3610 | - { |
3611 | - moveUndoAction(); |
3612 | - spreadChanges = (textFlowMode() != TextFlowDisabled ); |
3613 | - } |
3614 | - // has the item's image been moved |
3615 | - if (force || ((oldLocalX != LocalX || oldLocalY != LocalY) && shouldCheck())) |
3616 | - changeImageOffsetUndoAction(); |
3617 | - // has the item's image been scaled |
3618 | - if (force || ((oldLocalScX != LocalScX || oldLocalScY != LocalScY) && shouldCheck())) |
3619 | - changeImageScaleUndoAction(); |
3620 | - |
3621 | - if(spreadChanges) |
3622 | - { |
3623 | - checkTextFlowInteractions(); |
3624 | - } |
3625 | -} |
3626 | - |
3627 | -bool PageItem::shouldCheck() |
3628 | -{ |
3629 | - return ((!m_Doc->view()->mousePressed()) && |
3630 | - (!ScCore->primaryMainWindow()->arrowKeyDown()) && |
3631 | - (!ScCore->primaryMainWindow()->propertiesPalette->userActionOn())); |
3632 | -} |
3633 | - |
3634 | -void PageItem::moveUndoAction() |
3635 | -{ |
3636 | - if (oldXpos == Xpos && oldYpos == Ypos) |
3637 | - return; |
3638 | - if (UndoManager::undoEnabled()) |
3639 | - { |
3640 | - QString oldp; |
3641 | - QString newp; |
3642 | - if (oldOwnPage == -1) |
3643 | - oldp = Um::ScratchSpace; |
3644 | - else |
3645 | - oldp = QString(Um::PageNmbr).arg(m_Doc->FirstPnum + oldOwnPage); |
3646 | - if (OwnPage == -1) |
3647 | - newp = Um::ScratchSpace; |
3648 | - else |
3649 | - newp = QString(Um::PageNmbr).arg(m_Doc->FirstPnum + OwnPage); |
3650 | - SimpleState *ss = new SimpleState(Um::Move, |
3651 | - QString(Um::MoveFromTo).arg(oldXpos).arg(oldYpos).arg(oldp). |
3652 | - arg(Xpos).arg(Ypos).arg(newp), Um::IMove); |
3653 | - ss->set("OLD_XPOS", oldXpos); |
3654 | - ss->set("OLD_YPOS", oldYpos); |
3655 | - ss->set("NEW_XPOS", Xpos); |
3656 | - ss->set("NEW_YPOS", Ypos); |
3657 | - undoManager->action(this, ss); |
3658 | - } |
3659 | - oldXpos = Xpos; |
3660 | - oldYpos = Ypos; |
3661 | - oldOwnPage = OwnPage; |
3662 | -} |
3663 | - |
3664 | -void PageItem::resizeUndoAction() |
3665 | -{ |
3666 | - if (oldHeight == Height && oldWidth == Width) |
3667 | - return; |
3668 | - if (UndoManager::undoEnabled()) |
3669 | - { |
3670 | - SimpleState *ss = new SimpleState(Um::Resize, |
3671 | - QString(Um::ResizeFromTo).arg(oldWidth).arg(oldHeight).arg(Width).arg(Height), |
3672 | - Um::IResize); |
3673 | - ss->set("OLD_WIDTH", oldWidth); |
3674 | - ss->set("OLD_HEIGHT", oldHeight); |
3675 | - ss->set("NEW_WIDTH", Width); |
3676 | - ss->set("NEW_HEIGHT", Height); |
3677 | - ss->set("OLD_RXPOS", oldXpos); |
3678 | - ss->set("OLD_RYPOS", oldYpos); |
3679 | - ss->set("NEW_RXPOS", Xpos); |
3680 | - ss->set("NEW_RYPOS", Ypos); |
3681 | - ss->set("OLD_RROT", oldRot); |
3682 | - ss->set("NEW_RROT", Rot); |
3683 | - undoManager->action(this, ss); |
3684 | - } |
3685 | - oldXpos = Xpos; |
3686 | - oldYpos = Ypos; |
3687 | - oldHeight = Height; |
3688 | - oldWidth = Width; |
3689 | - oldOwnPage = OwnPage; |
3690 | - oldRot = Rot; |
3691 | -} |
3692 | - |
3693 | -void PageItem::rotateUndoAction() |
3694 | -{ |
3695 | - if (oldRot == Rot) |
3696 | - return; |
3697 | - if (UndoManager::undoEnabled()) |
3698 | - { |
3699 | - SimpleState *ss = new SimpleState(Um::Rotate, |
3700 | - QString(Um::FromTo).arg(oldRot).arg(Rot), |
3701 | - Um::IRotate); |
3702 | - ss->set("OLD_ROT", oldRot); |
3703 | - ss->set("NEW_ROT", Rot); |
3704 | - ss->set("OLD_RXPOS", oldXpos); |
3705 | - ss->set("OLD_RYPOS", oldYpos); |
3706 | - ss->set("NEW_RXPOS", Xpos); |
3707 | - ss->set("NEW_RYPOS", Ypos); |
3708 | - ss->set("OLD_RWIDTH", oldWidth); |
3709 | - ss->set("OLD_RHEIGHT", oldHeight); |
3710 | - ss->set("NEW_RWIDTH", Width); |
3711 | - ss->set("NEW_RHEIGHT", Height); |
3712 | - undoManager->action(this, ss); |
3713 | - } |
3714 | - oldRot = Rot; |
3715 | - oldXpos = Xpos; |
3716 | - oldYpos = Ypos; |
3717 | - oldOwnPage = OwnPage; |
3718 | - oldWidth = Width; |
3719 | - oldHeight = Height; |
3720 | -} |
3721 | - |
3722 | -void PageItem::changeImageOffsetUndoAction() |
3723 | -{ |
3724 | - if (oldLocalX == LocalX && oldLocalY == LocalY) |
3725 | - return; |
3726 | - if (UndoManager::undoEnabled()) |
3727 | - { |
3728 | - SimpleState *ss = new SimpleState(Um::ImageOffset, |
3729 | - QString(Um::ImageOffsetFromTo).arg(oldLocalX).arg(oldLocalY).arg(LocalX).arg(LocalY), Um::IMove); |
3730 | - ss->set("IMAGE_OFFSET", "image_offset"); |
3731 | - ss->set("OLD_IMAGEXOFFSET", oldLocalX); |
3732 | - ss->set("OLD_IMAGEYOFFSET", oldLocalY); |
3733 | - ss->set("NEW_IMAGEXOFFSET", LocalX); |
3734 | - ss->set("NEW_IMAGEYOFFSET", LocalY); |
3735 | - undoManager->action(this, ss); |
3736 | - } |
3737 | - oldLocalX = LocalX; |
3738 | - oldLocalY = LocalY; |
3739 | -} |
3740 | - |
3741 | -void PageItem::changeImageScaleUndoAction() |
3742 | -{ |
3743 | - //#9817: Hack for this rounding issue caused by conversion to text values. Undo needs fixing. |
3744 | - if ((ScCLocale::toDoubleC(ScCLocale::toQStringC(oldLocalScX)) == |
3745 | - ScCLocale::toDoubleC(ScCLocale::toQStringC(LocalScX))) |
3746 | - && (ScCLocale::toDoubleC(ScCLocale::toQStringC(oldLocalScY)) == |
3747 | - ScCLocale::toDoubleC(ScCLocale::toQStringC(LocalScY)))) |
3748 | - return; |
3749 | - if (UndoManager::undoEnabled()) |
3750 | - { |
3751 | - SimpleState *ss = new SimpleState(Um::ImageScale, |
3752 | - QString(Um::ImageScaleFromTo).arg(oldLocalScX).arg(oldLocalScY).arg(LocalScX).arg(LocalScY), Um::IMove); |
3753 | - ss->set("IMAGE_SCALE", "image_scale"); |
3754 | - ss->set("OLD_IMAGEXSCALE", oldLocalScX); |
3755 | - ss->set("OLD_IMAGEYSCALE", oldLocalScY); |
3756 | - ss->set("NEW_IMAGEXSCALE", LocalScX); |
3757 | - ss->set("NEW_IMAGEYSCALE", LocalScY); |
3758 | - undoManager->action(this, ss); |
3759 | - } |
3760 | - oldLocalScX = LocalScX; |
3761 | - oldLocalScY = LocalScY; |
3762 | -} |
3763 | - |
3764 | -void PageItem::restore(UndoState *state, bool isUndo) |
3765 | -{ |
3766 | - bool useRasterBackup = m_Doc->useRaster; |
3767 | - bool SnapGuidesBackup = m_Doc->SnapGuides; |
3768 | - m_Doc->useRaster = false; |
3769 | - m_Doc->SnapGuides = false; |
3770 | - SimpleState *ss = dynamic_cast<SimpleState*>(state); |
3771 | - bool oldMPMode=m_Doc->masterPageMode(); |
3772 | - m_Doc->setMasterPageMode(!OnMasterPage.isEmpty()); |
3773 | - Page *oldCurrentPage = m_Doc->currentPage(); |
3774 | - if (!OnMasterPage.isEmpty()) |
3775 | - { |
3776 | - oldCurrentPage = m_Doc->currentPage(); |
3777 | - m_Doc->setCurrentPage(m_Doc->MasterPages.at(m_Doc->MasterNames[OnMasterPage])); |
3778 | - } |
3779 | - if (ss) |
3780 | - { |
3781 | - if (ss->contains("OLD_XPOS")) |
3782 | - restoreMove(ss, isUndo); |
3783 | - else if (ss->contains("OLD_HEIGHT")) |
3784 | - restoreResize(ss, isUndo); |
3785 | - else if (ss->contains("OLD_ROT")) |
3786 | - restoreRotate(ss, isUndo); |
3787 | - else if (ss->contains("FILL")) |
3788 | - restoreFill(ss, isUndo); |
3789 | - else if (ss->contains("SHADE")) |
3790 | - restoreShade(ss, isUndo); |
3791 | - else if (ss->contains("LINE_COLOR")) |
3792 | - restoreLineColor(ss, isUndo); |
3793 | - else if (ss->contains("LINE_SHADE")) |
3794 | - restoreLineShade(ss, isUndo); |
3795 | - else if (ss->contains("IMAGEFLIPH")) |
3796 | - { |
3797 | - select(); |
3798 | - m_Doc->itemSelection_FlipH(); |
3799 | - } |
3800 | - else if (ss->contains("IMAGEFLIPV")) |
3801 | - { |
3802 | - select(); |
3803 | - m_Doc->itemSelection_FlipV(); |
3804 | - } |
3805 | - else if (ss->contains("LOCK")) |
3806 | - { |
3807 | - select(); |
3808 | - m_Doc->itemSelection_ToggleLock(); |
3809 | - } |
3810 | - else if (ss->contains("SIZE_LOCK")) |
3811 | - { |
3812 | - select(); |
3813 | - m_Doc->itemSelection_ToggleSizeLock(); |
3814 | - } |
3815 | - else if (ss->contains("PRINT_ENABLED")) |
3816 | - { |
3817 | - select(); |
3818 | - m_Doc->itemSelection_TogglePrintEnabled(); |
3819 | - } |
3820 | - else if (ss->contains("NEW_NAME")) |
3821 | - restoreName(ss, isUndo); |
3822 | - else if (ss->contains("TRANSPARENCY")) |
3823 | - restoreFillTP(ss, isUndo); |
3824 | - else if (ss->contains("LINE_TRANSPARENCY")) |
3825 | - restoreLineTP(ss, isUndo); |
3826 | - else if (ss->contains("LINE_STYLE")) |
3827 | - restoreLineStyle(ss, isUndo); |
3828 | - else if (ss->contains("LINE_END")) |
3829 | - restoreLineEnd(ss, isUndo); |
3830 | - else if (ss->contains("LINE_JOIN")) |
3831 | - restoreLineJoin(ss, isUndo); |
3832 | - else if (ss->contains("LINE_WIDTH")) |
3833 | - restoreLineWidth(ss, isUndo); |
3834 | - else if (ss->contains("CUSTOM_LINE_STYLE")) |
3835 | - restoreCustomLineStyle(ss, isUndo); |
3836 | - else if (ss->contains("START_ARROW")) |
3837 | - restoreArrow(ss, isUndo, true); |
3838 | - else if (ss->contains("END_ARROW")) |
3839 | - restoreArrow(ss, isUndo, false); |
3840 | - else if (ss->contains("PSTYLE")) |
3841 | - restorePStyle(ss, isUndo); |
3842 | - else if (ss->contains("CONVERT")) |
3843 | - restoreType(ss, isUndo); |
3844 | - else if (ss->contains("TEXTFLOW_OLDMODE")) |
3845 | - restoreTextFlowing(ss, isUndo); |
3846 | - else if (ss->contains("SCALE_MODE")) |
3847 | - restoreImageScaleMode(ss, isUndo); |
3848 | - else if (ss->contains("IMAGE_SCALE")) |
3849 | - restoreImageScaleChange(ss, isUndo); |
3850 | - else if (ss->contains("IMAGE_OFFSET")) |
3851 | - restoreImageOffsetChange(ss, isUndo); |
3852 | - else if (ss->contains("EDIT_CONTOUR")) |
3853 | - restorePoly(ss, isUndo, true); |
3854 | - else if (ss->contains("EDIT_SHAPE")) |
3855 | - restorePoly(ss, isUndo, false); |
3856 | - else if (ss->contains("RESET_CONTOUR")) |
3857 | - restoreContourLine(ss, isUndo); |
3858 | - else if (ss->contains("CHANGE_SHAPE_TYPE")) |
3859 | - restoreShapeType(ss, isUndo); |
3860 | - else if (ss->contains("MIRROR_PATH_H")) |
3861 | - { |
3862 | - bool editContour = m_Doc->nodeEdit.isContourLine; |
3863 | - m_Doc->nodeEdit.isContourLine = ss->getBool("IS_CONTOUR"); |
3864 | - select(); |
3865 | - m_Doc->MirrorPolyH(m_Doc->m_Selection->itemAt(0)); |
3866 | - m_Doc->nodeEdit.isContourLine = editContour; |
3867 | - } |
3868 | - else if (ss->contains("MIRROR_PATH_V")) |
3869 | - { |
3870 | - bool editContour = m_Doc->nodeEdit.isContourLine; |
3871 | - m_Doc->nodeEdit.isContourLine = ss->getBool("IS_CONTOUR"); |
3872 | - select(); |
3873 | - m_Doc->MirrorPolyV(m_Doc->m_Selection->itemAt(0)); |
3874 | - m_Doc->nodeEdit.isContourLine = editContour; |
3875 | - } |
3876 | - else if (ss->contains("SEND_TO_LAYER")) |
3877 | - restoreLayer(ss, isUndo); |
3878 | - else if (ss->contains("GET_IMAGE")) |
3879 | - restoreGetImage(ss, isUndo); |
3880 | - else if (ss->contains("GROUPS_LASTITEM")) |
3881 | - restoreGroupsLastItem(ss, isUndo); |
3882 | - else if (ss->contains("EDIT_SHAPE_OR_CONTOUR")) |
3883 | - restoreShapeContour(ss, isUndo); |
3884 | - else if (ss->contains("APPLY_IMAGE_EFFECTS")) |
3885 | - restoreImageEffects(ss, isUndo); |
3886 | - else if (ss->contains("STEXT")) |
3887 | - restoreEditText(ss, isUndo); |
3888 | - else if (ss->contains("CLEAR_IMAGE")) |
3889 | - restoreClearImage(ss,isUndo); |
3890 | - else if (ss->contains("LINK_TEXT_FRAME")) |
3891 | - restoreLinkTextFrame(ss,isUndo); |
3892 | - else if (ss->contains("UNLINK_TEXT_FRAME")) |
3893 | - restoreUnlinkTextFrame(ss,isUndo); |
3894 | - } |
3895 | - if (!OnMasterPage.isEmpty()) |
3896 | - m_Doc->setCurrentPage(oldCurrentPage); |
3897 | - m_Doc->setMasterPageMode(oldMPMode); |
3898 | - m_Doc->useRaster = useRasterBackup; |
3899 | - m_Doc->SnapGuides = SnapGuidesBackup; |
3900 | -} |
3901 | - |
3902 | -void PageItem::restoreMove(SimpleState *state, bool isUndo) |
3903 | -{ |
3904 | - double ox = state->getDouble("OLD_XPOS"); |
3905 | - double oy = state->getDouble("OLD_YPOS"); |
3906 | - double x = state->getDouble("NEW_XPOS"); |
3907 | - double y = state->getDouble("NEW_YPOS"); |
3908 | - double mx = ox - x; |
3909 | - double my = oy - y; |
3910 | - if (!isUndo) |
3911 | - { |
3912 | - mx = -mx; |
3913 | - my = -my; |
3914 | - } |
3915 | - m_Doc->MoveItem(mx, my, this, false); |
3916 | - oldXpos = Xpos; |
3917 | - oldYpos = Ypos; |
3918 | - oldOwnPage = OwnPage; |
3919 | -} |
3920 | - |
3921 | -void PageItem::restoreResize(SimpleState *state, bool isUndo) |
3922 | -{ |
3923 | - double ow = state->getDouble("OLD_WIDTH"); |
3924 | - double oh = state->getDouble("OLD_HEIGHT"); |
3925 | - double w = state->getDouble("NEW_WIDTH"); |
3926 | - double h = state->getDouble("NEW_HEIGHT"); |
3927 | - double ox = state->getDouble("OLD_RXPOS"); |
3928 | - double oy = state->getDouble("OLD_RYPOS"); |
3929 | - double x = state->getDouble("NEW_RXPOS"); |
3930 | - double y = state->getDouble("NEW_RYPOS"); |
3931 | - double ort = state->getDouble("OLD_RROT"); |
3932 | - double rt = state->getDouble("NEW_RROT"); |
3933 | - double mx = ox - x; |
3934 | - double my = oy - y; |
3935 | - int stateCode = state->transactionCode; |
3936 | - bool redraw = ((stateCode != 1) && (stateCode != 3)); |
3937 | - if (isUndo) |
3938 | - { |
3939 | - m_Doc->SizeItem(ow, oh, this, false, true, redraw); |
3940 | - m_Doc->MoveItem(mx, my, this, false); |
3941 | - m_Doc->RotateItem(ort, this); |
3942 | - } |
3943 | - else |
3944 | - { |
3945 | - mx = -mx; |
3946 | - my = -my; |
3947 | - m_Doc->SizeItem(w, h, this, false, true, redraw); |
3948 | - m_Doc->MoveItem(mx, my, this, false); |
3949 | - m_Doc->RotateItem(rt, this); |
3950 | - } |
3951 | - oldWidth = Width; |
3952 | - oldHeight = Height; |
3953 | - oldXpos = Xpos; |
3954 | - oldYpos = Ypos; |
3955 | - oldOwnPage = OwnPage; |
3956 | - oldRot = Rot; |
3957 | -} |
3958 | - |
3959 | -void PageItem::restoreRotate(SimpleState *state, bool isUndo) |
3960 | -{ |
3961 | - double ort = state->getDouble("OLD_ROT"); |
3962 | - double rt = state->getDouble("NEW_ROT"); |
3963 | - double ox = state->getDouble("OLD_RXPOS"); |
3964 | - double oy = state->getDouble("OLD_RYPOS"); |
3965 | - double x = state->getDouble("NEW_RXPOS"); |
3966 | - double y = state->getDouble("NEW_RYPOS"); |
3967 | - double ow = state->getDouble("OLD_RWIDTH"); |
3968 | - double oh = state->getDouble("OLD_RHEIGHT"); |
3969 | - double w = state->getDouble("NEW_RWIDTH"); |
3970 | - double h = state->getDouble("NEW_RHEIGHT"); |
3971 | - int stateCode = state->transactionCode; |
3972 | - bool redraw = ((stateCode != 1) && (stateCode != 3));; |
3973 | - //CB Commented out test code |
3974 | - //QRect oldR(getRedrawBounding(view->scale())); |
3975 | - //double mx = ox - x; |
3976 | - //double my = oy - y; |
3977 | - if (isUndo) |
3978 | - { |
3979 | - /*Rot=ort; |
3980 | - Xpos+=mx; |
3981 | - Ypos+=my; |
3982 | - Width=ow; |
3983 | - Height=oh;*/ |
3984 | - m_Doc->RotateItem(ort, this); |
3985 | - m_Doc->MoveItem(ox - Xpos, oy - Ypos, this, false); |
3986 | - m_Doc->SizeItem(ow, oh, this, false, true, redraw); |
3987 | - } |
3988 | - else |
3989 | - { |
3990 | - /*mx = -mx; |
3991 | - my = -my; |
3992 | - Rot=rt; |
3993 | - Xpos-=mx; |
3994 | - Ypos-=my; |
3995 | - Width=w; |
3996 | - Height=h; |
3997 | - */ |
3998 | - m_Doc->RotateItem(rt, this); |
3999 | - m_Doc->MoveItem(x - Xpos, y - Ypos, this, false); |
4000 | - m_Doc->SizeItem(w, h, this, false, true, redraw); |
4001 | - } |
4002 | - /* |
4003 | - m_Doc->setRedrawBounding(this); |
4004 | - QRect newR(getRedrawBounding(view->scale())); |
4005 | - view->updateContents(newR.unite(oldR)); |
4006 | - OwnPage = m_Doc->OnPage(this); |
4007 | - */ |
4008 | - oldRot = Rot; |
4009 | - oldXpos = Xpos; |
4010 | - oldYpos = Ypos; |
4011 | - oldOwnPage = OwnPage; |
4012 | - oldWidth = Width; |
4013 | - oldHeight = Height; |
4014 | -} |
4015 | - |
4016 | -void PageItem::restoreFill(SimpleState *state, bool isUndo) |
4017 | -{ |
4018 | - QString fill = state->get("OLD_FILL"); |
4019 | - if (!isUndo) |
4020 | - fill = state->get("NEW_FILL"); |
4021 | - select(); |
4022 | - m_Doc->itemSelection_SetItemBrush(fill); |
4023 | -} |
4024 | - |
4025 | -void PageItem::restoreShade(SimpleState *state, bool isUndo) |
4026 | -{ |
4027 | - int shade = state->getInt("OLD_SHADE"); |
4028 | - if (!isUndo) |
4029 | - shade = state->getInt("NEW_SHADE"); |
4030 | - select(); |
4031 | - m_Doc->itemSelection_SetItemBrushShade(shade); |
4032 | -} |
4033 | - |
4034 | -void PageItem::restoreLineColor(SimpleState *state, bool isUndo) |
4035 | -{ |
4036 | - QString fill = state->get("OLD_COLOR"); |
4037 | - if (!isUndo) |
4038 | - fill = state->get("NEW_COLOR"); |
4039 | - select(); |
4040 | - m_Doc->itemSelection_SetItemPen(fill); |
4041 | -} |
4042 | - |
4043 | -void PageItem::restoreLineShade(SimpleState *state, bool isUndo) |
4044 | -{ |
4045 | - int shade = state->getInt("OLD_SHADE"); |
4046 | - if (!isUndo) |
4047 | - shade = state->getInt("NEW_SHADE"); |
4048 | - select(); |
4049 | - m_Doc->itemSelection_SetItemPenShade(shade); |
4050 | -} |
4051 | - |
4052 | -void PageItem::restoreFillTP(SimpleState *state, bool isUndo) |
4053 | -{ |
4054 | - double tp = state->getDouble("OLD_TP"); |
4055 | - if (!isUndo) |
4056 | - tp = state->getDouble("NEW_TP"); |
4057 | - select(); |
4058 | - m_Doc->itemSelection_SetItemFillTransparency(tp); |
4059 | -} |
4060 | - |
4061 | -void PageItem::restoreLineTP(SimpleState *state, bool isUndo) |
4062 | -{ |
4063 | - double tp = state->getDouble("OLD_TP"); |
4064 | - if (!isUndo) |
4065 | - tp = state->getDouble("NEW_TP"); |
4066 | - select(); |
4067 | - m_Doc->itemSelection_SetItemLineTransparency(tp); |
4068 | -} |
4069 | - |
4070 | - |
4071 | -void PageItem::restoreLineStyle(SimpleState *state, bool isUndo) |
4072 | -{ |
4073 | - Qt::PenStyle ps = static_cast<Qt::PenStyle>(state->getInt("OLD_STYLE")); |
4074 | - if (!isUndo) |
4075 | - ps = static_cast<Qt::PenStyle>(state->getInt("NEW_STYLE")); |
4076 | - select(); |
4077 | - m_Doc->itemSelection_SetLineArt(ps); |
4078 | -} |
4079 | - |
4080 | -void PageItem::restoreLineEnd(SimpleState *state, bool isUndo) |
4081 | -{ |
4082 | - Qt::PenCapStyle pcs = static_cast<Qt::PenCapStyle>(state->getInt("OLD_STYLE")); |
4083 | - if (!isUndo) |
4084 | - pcs = static_cast<Qt::PenCapStyle>(state->getInt("NEW_STYLE")); |
4085 | - select(); |
4086 | - m_Doc->itemSelection_SetLineEnd(pcs); |
4087 | -} |
4088 | - |
4089 | -void PageItem::restoreLineJoin(SimpleState *state, bool isUndo) |
4090 | -{ |
4091 | - Qt::PenJoinStyle pjs = static_cast<Qt::PenJoinStyle>(state->getInt("OLD_STYLE")); |
4092 | - if (!isUndo) |
4093 | - pjs = static_cast<Qt::PenJoinStyle>(state->getInt("NEW_STYLE")); |
4094 | - select(); |
4095 | - m_Doc->itemSelection_SetLineJoin(pjs); |
4096 | -} |
4097 | - |
4098 | -void PageItem::restoreLineWidth(SimpleState *state, bool isUndo) |
4099 | -{ |
4100 | - double w = state->getDouble("OLD_WIDTH"); |
4101 | - if (!isUndo) |
4102 | - w = state->getDouble("NEW_WIDTH"); |
4103 | - select(); |
4104 | - m_Doc->itemSelection_SetLineWidth(w); |
4105 | -} |
4106 | - |
4107 | -void PageItem::restoreCustomLineStyle(SimpleState *state, bool isUndo) |
4108 | -{ |
4109 | - QString style = state->get("OLD_STYLE"); |
4110 | - if (!isUndo) |
4111 | - style = state->get("NEW_STYLE"); |
4112 | - setCustomLineStyle(style); |
4113 | -} |
4114 | - |
4115 | -void PageItem::restoreName(SimpleState *state, bool isUndo) |
4116 | -{ |
4117 | - QString name = state->get("OLD_NAME"); |
4118 | - if (!isUndo) |
4119 | - name = state->get("NEW_NAME"); |
4120 | - setItemName(name); |
4121 | -} |
4122 | - |
4123 | -void PageItem::restoreArrow(SimpleState *state, bool isUndo, bool isStart) |
4124 | -{ |
4125 | - int i = state->getInt("OLD_INDEX"); |
4126 | - if (!isUndo) |
4127 | - i = state->getInt("NEW_INDEX"); |
4128 | - if (isStart) |
4129 | - setStartArrowIndex(i); |
4130 | - else |
4131 | - setEndArrowIndex(i); |
4132 | -} |
4133 | - |
4134 | - |
4135 | -void PageItem::restorePStyle(SimpleState *state, bool isUndo) |
4136 | -{ |
4137 | - int styleid = state->getInt("OLD_STYLE"); |
4138 | - if (!isUndo) |
4139 | - styleid = state->getInt("NEW_STYLE"); |
4140 | - //will be done later with other text-undo: |
4141 | - // m_Doc->chAbStyle(this, styleid); |
4142 | -} |
4143 | - |
4144 | - |
4145 | -// FIXME: This must go into class ScribusDoc! |
4146 | -// For now we'll just make it independent of 'this' -- AV |
4147 | -void PageItem::restoreType(SimpleState *state, bool isUndo) |
4148 | -{ |
4149 | - // well, probably not the best way to handle pointers... |
4150 | - PageItem * item = reinterpret_cast<PageItem *>(state->getInt("PAGEITEM")); |
4151 | - int type = state->getInt("OLD_TYPE"); |
4152 | - if (!isUndo) |
4153 | - type = state->getInt("NEW_TYPE"); |
4154 | - ScribusView* view = m_Doc->view(); |
4155 | - view->Deselect(false); |
4156 | - view->SelectItem(item, false); |
4157 | - switch (type) { |
4158 | - case ImageFrame: view->ToPicFrame(); break; |
4159 | - case TextFrame: view->ToTextFrame(); break; |
4160 | - case Polygon: view->ToPolyFrame(); break; |
4161 | - case PolyLine: view->ToBezierFrame(); break; |
4162 | - } |
4163 | - view->requestMode(modeNormal); |
4164 | -} |
4165 | - |
4166 | -void PageItem::restoreTextFlowing(SimpleState *state, bool isUndo) |
4167 | -{ |
4168 | - TextFlowMode oldMode = (TextFlowMode) state->getInt("TEXTFLOW_OLDMODE"); |
4169 | - TextFlowMode newMode = (TextFlowMode) state->getInt("TEXTFLOW_NEWMODE"); |
4170 | - if (isUndo) |
4171 | - textFlowModeVal = oldMode; |
4172 | - else |
4173 | - textFlowModeVal = newMode; |
4174 | - |
4175 | - QList<PageItem*> pList; |
4176 | - for(int idx = ItemNr-1; idx >= 0 ; --idx) |
4177 | - { |
4178 | - pList << m_Doc->Items->at(idx); |
4179 | - } |
4180 | - |
4181 | - QRectF baseRect(getBoundingRect()); |
4182 | - for(int idx(0); idx < pList.count(); ++idx) |
4183 | - { |
4184 | - QRectF uRect(pList.at(idx)->getBoundingRect()); |
4185 | - if(baseRect.intersects(uRect)) |
4186 | - pList.at(idx)->update(); |
4187 | - } |
4188 | -} |
4189 | - |
4190 | -void PageItem::restoreImageScaleMode(SimpleState *state, bool isUndo) |
4191 | -{ |
4192 | - bool type=ScaleType; |
4193 | - if (state->contains("SCALE_TYPE")) |
4194 | - { |
4195 | - if (isUndo) |
4196 | - type = !state->getBool("SCALE_TYPE"); |
4197 | - else |
4198 | - type = state->getBool("SCALE_TYPE"); |
4199 | - //if restoring free scaling |
4200 | - //old offset and scale ratio must be restored |
4201 | - if (type) |
4202 | - { |
4203 | - double oscx = state->getDouble("OLD_IMAGEXSCALE"); |
4204 | - double oscy = state->getDouble("OLD_IMAGEYSCALE"); |
4205 | - double ox = state->getDouble("OLD_IMAGEXOFFSET"); |
4206 | - double oy = state->getDouble("OLD_IMAGEYOFFSET"); |
4207 | - Selection tempSelection(this, false); |
4208 | - tempSelection.addItem(this, true); |
4209 | - m_Doc->itemSelection_SetImageScale(oscx, oscy, &tempSelection); |
4210 | - m_Doc->itemSelection_SetImageOffset(ox, oy, &tempSelection); |
4211 | - } |
4212 | - |
4213 | - } |
4214 | - |
4215 | - bool ratio=AspectRatio; |
4216 | - if (state->contains("ASPECT_RATIO")) |
4217 | - { |
4218 | - if (isUndo) |
4219 | - ratio = !state->getBool("ASPECT_RATIO"); |
4220 | - else |
4221 | - ratio = state->getBool("ASPECT_RATIO"); |
4222 | - } |
4223 | - |
4224 | - setImageScalingMode(type, ratio); |
4225 | -} |
4226 | - |
4227 | -void PageItem::restoreImageScaleChange(SimpleState *state, bool isUndo) |
4228 | -{ |
4229 | - double oscx = state->getDouble("OLD_IMAGEXSCALE"); |
4230 | - double oscy = state->getDouble("OLD_IMAGEYSCALE"); |
4231 | - double scx = state->getDouble("NEW_IMAGEXSCALE"); |
4232 | - double scy = state->getDouble("NEW_IMAGEYSCALE"); |
4233 | - Selection tempSelection(this, false); |
4234 | - tempSelection.addItem(this, true); |
4235 | - if (!isUndo) |
4236 | - m_Doc->itemSelection_SetImageScale(scx, scy, &tempSelection); |
4237 | - else |
4238 | - m_Doc->itemSelection_SetImageScale(oscx, oscy, &tempSelection); |
4239 | -} |
4240 | - |
4241 | -void PageItem::restoreImageOffsetChange(SimpleState *state, bool isUndo) |
4242 | -{ |
4243 | - double ox = state->getDouble("OLD_IMAGEXOFFSET"); |
4244 | - double oy = state->getDouble("OLD_IMAGEYOFFSET"); |
4245 | - double x = state->getDouble("NEW_IMAGEXOFFSET"); |
4246 | - double y = state->getDouble("NEW_IMAGEYOFFSET"); |
4247 | - Selection tempSelection(this, false); |
4248 | - tempSelection.addItem(this, true); |
4249 | - if (!isUndo) |
4250 | - m_Doc->itemSelection_SetImageOffset(x, y, &tempSelection); |
4251 | - else |
4252 | - m_Doc->itemSelection_SetImageOffset(ox, oy, &tempSelection); |
4253 | -} |
4254 | - |
4255 | -void PageItem::restoreClearImage(UndoState *state, bool isUndo) |
4256 | -{ |
4257 | - if (!isImageFrame()) |
4258 | - return; |
4259 | - if (isUndo) |
4260 | - { |
4261 | - ItemState<ScImageEffectList> *is = dynamic_cast<ItemState<ScImageEffectList>*>(state); |
4262 | - Pfile = is->get("CI_PFILE"); |
4263 | - loadImage(Pfile, false); |
4264 | - effectsInUse = is->getItem(); |
4265 | - setImageFlippedH(is->getBool("CI_FLIPPH")); |
4266 | - setImageFlippedV(is->getBool("CI_FLIPPV")); |
4267 | - setImageScalingMode(is->getBool("CI_SCALING"),is->getBool("CI_ASPECT")); |
4268 | - setImageXYOffset(is->getDouble("CI_XOFF"), is->getDouble("CI_YOFF")); |
4269 | - setImageXYScale(is->getDouble("CI_XSCALE"), is->getDouble("CI_YSCALE")); |
4270 | - setFillTransparency(is->getDouble("CI_FILLT")); |
4271 | - setLineTransparency(is->getDouble("CI_LINET")); |
4272 | - select(); |
4273 | - m_Doc->updatePic(); |
4274 | - } |
4275 | - else |
4276 | - asImageFrame()->clearContents(); |
4277 | -} |
4278 | - |
4279 | -void PageItem::restoreLinkTextFrame(UndoState *state, bool isUndo) |
4280 | -{ |
4281 | - if (!isTextFrame()) |
4282 | - return; |
4283 | - if (isUndo) |
4284 | - { |
4285 | - unlink(); |
4286 | - } |
4287 | - else |
4288 | - { |
4289 | - ItemState<std::pair<PageItem*, PageItem*> > *is = dynamic_cast<ItemState<std::pair<PageItem*, PageItem*> >*>(state); |
4290 | - asTextFrame()->link(is->getItem().second->asTextFrame()); |
4291 | - } |
4292 | -} |
4293 | - |
4294 | -void PageItem::restoreUnlinkTextFrame(UndoState *state, bool isUndo) |
4295 | -{ |
4296 | - if (!isTextFrame()) |
4297 | - return; |
4298 | - if (isUndo) |
4299 | - { |
4300 | - ItemState<std::pair<PageItem*, PageItem*> > *is = dynamic_cast<ItemState<std::pair<PageItem*, PageItem*> >*>(state); |
4301 | - asTextFrame()->link(is->getItem().second->asTextFrame()); |
4302 | - } |
4303 | - else |
4304 | - { |
4305 | - unlink(); |
4306 | - } |
4307 | -} |
4308 | - |
4309 | - |
4310 | -void PageItem::restorePoly(SimpleState *state, bool isUndo, bool isContour) |
4311 | -{ |
4312 | - int mode = state->getInt("MODE"); |
4313 | - int rot = state->getInt("ROT"); |
4314 | - ScribusView* view = m_Doc->view(); |
4315 | - double scaling = state->getDouble("SCALING"); |
4316 | - bool editContour = m_Doc->nodeEdit.isContourLine; |
4317 | - m_Doc->nodeEdit.isContourLine = isContour; |
4318 | - select(); |
4319 | - if (isUndo) |
4320 | - { |
4321 | - if (mode % 2 != 0 && mode != 0) |
4322 | - --mode; |
4323 | - else |
4324 | - ++mode; |
4325 | - if (mode == 2) |
4326 | - scaling = (1.0 - (100.0 / (100.0 + scaling))) * 100.0; |
4327 | - else if (mode == 3) |
4328 | - scaling = ((100.0 / (100.0 - scaling)) - 1.0) * 100.0; |
4329 | - } |
4330 | - view->TransformPoly(mode, rot, scaling); |
4331 | - m_Doc->nodeEdit.isContourLine = editContour; |
4332 | -} |
4333 | - |
4334 | -void PageItem::restoreContourLine(SimpleState *state, bool isUndo) |
4335 | -{ |
4336 | - ItemState<FPointArray> *is = dynamic_cast<ItemState<FPointArray>*>(state); |
4337 | - if (is) |
4338 | - { |
4339 | - if (isUndo) |
4340 | - ContourLine = is->getItem(); |
4341 | - else |
4342 | - ContourLine = PoLine.copy(); |
4343 | - ClipEdited = true; |
4344 | - } |
4345 | -} |
4346 | - |
4347 | -void PageItem::restoreShapeType(SimpleState *state, bool isUndo) |
4348 | -{ |
4349 | - // Store shape info in this form: |
4350 | - // CHANGE_SHAPE_TYPE - ID of the undo operation |
4351 | - // OLD_FRAME_TYPE - original frame type |
4352 | - // NEW_FRAME_TYPE - change of frame type |
4353 | - // binary QPair<FPointArray, FPointArray> - .first original shape, .second new shape |
4354 | - ItemState<QPair<FPointArray,FPointArray> > *is = dynamic_cast<ItemState<QPair<FPointArray,FPointArray> >*>(state); |
4355 | - if (is) |
4356 | - { |
4357 | - if (isUndo) |
4358 | - { |
4359 | - this->FrameType = is->getInt("OLD_FRAME_TYPE"); |
4360 | - this->PoLine = is->getItem().first; |
4361 | - } |
4362 | - else |
4363 | - { |
4364 | - this->FrameType = is->getInt("NEW_FRAME_TYPE"); |
4365 | - this->PoLine = is->getItem().second; |
4366 | - } |
4367 | - ClipEdited = true; |
4368 | - } |
4369 | -} |
4370 | - |
4371 | -void PageItem::restoreLayer(SimpleState *state, bool isUndo) |
4372 | -{ |
4373 | - ScribusView* view = m_Doc->view(); |
4374 | - setLayer(isUndo ? state->getInt("OLD_LAYER") : state->getInt("NEW_LAYER")); |
4375 | - view->Deselect(true); |
4376 | - m_Doc->regionsChanged()->update(QRectF()); |
4377 | -} |
4378 | - |
4379 | -void PageItem::restoreGetImage(UndoState *state, bool isUndo) |
4380 | -{ |
4381 | - ItemState<ScImageEffectList> *is = dynamic_cast<ItemState<ScImageEffectList>*>(state); |
4382 | - QString fn = is->get("OLD_IMAGE_PATH"); |
4383 | - if (!isUndo) |
4384 | - fn = is->get("NEW_IMAGE_PATH"); |
4385 | - if (fn.isEmpty()) |
4386 | - { |
4387 | - Selection tempSelection(this, false); |
4388 | - tempSelection.addItem(this, true); |
4389 | - m_Doc->itemSelection_ClearItem(&tempSelection); |
4390 | - } |
4391 | - else |
4392 | - { |
4393 | - loadImage(fn, false); |
4394 | - if (isUndo) |
4395 | - { |
4396 | - //restore old image settings |
4397 | - effectsInUse = is->getItem(); |
4398 | - setImageFlippedH(is->getBool("FLIPPH")); |
4399 | - setImageFlippedV(is->getBool("FLIPPV")); |
4400 | - setImageScalingMode(is->getBool("SCALING"), is->getBool("ASPECT")); |
4401 | - setImageXYOffset(is->getDouble("XOFF"), is->getDouble("YOFF")); |
4402 | - setImageXYScale(is->getDouble("XSCALE"), is->getDouble("YSCALE")); |
4403 | - setFillTransparency(is->getDouble("FILLT")); |
4404 | - setLineTransparency(is->getDouble("LINET")); |
4405 | - } |
4406 | - select(); |
4407 | - m_Doc->updatePic(); |
4408 | - } |
4409 | -} |
4410 | - |
4411 | -void PageItem::restoreGroupsLastItem(SimpleState *state, bool isUndo) |
4412 | -{ |
4413 | - ItemState<std::pair<PageItem*, PageItem*> > *is = dynamic_cast<ItemState<std::pair<PageItem*, PageItem*> > *>(state); |
4414 | - if (is) |
4415 | - { |
4416 | - if (isUndo) |
4417 | - this->groupsLastItem = is->getItem().first; |
4418 | - else |
4419 | - this->groupsLastItem = is->getItem().second; |
4420 | - } |
4421 | -} |
4422 | - |
4423 | -void PageItem::restoreShapeContour(UndoState *state, bool isUndo) |
4424 | -{ |
4425 | - ItemState<QPair<FPointArray,FPointArray> > *istate = |
4426 | - dynamic_cast<ItemState<QPair<FPointArray,FPointArray> >*>(state); |
4427 | - if (istate) |
4428 | - { |
4429 | - FPointArray oldClip = istate->getItem().first; |
4430 | - FPointArray newClip = istate->getItem().second; |
4431 | - bool isContour = istate->getBool("IS_CONTOUR"); |
4432 | - double oldX = istate->getDouble("OLD_X"); |
4433 | - double oldY = istate->getDouble("OLD_Y"); |
4434 | - double newX = istate->getDouble("NEW_X"); |
4435 | - double newY = istate->getDouble("NEW_Y"); |
4436 | - double mx = oldX - newX; |
4437 | - double my = oldY - newY; |
4438 | - |
4439 | - if (isUndo) |
4440 | - { |
4441 | - if (isContour) |
4442 | - ContourLine = oldClip; |
4443 | - else |
4444 | - PoLine = oldClip; |
4445 | - } |
4446 | - else |
4447 | - { |
4448 | - mx = -mx; |
4449 | - my = -my; |
4450 | - if (isContour) |
4451 | - ContourLine = newClip; |
4452 | - else |
4453 | - PoLine = newClip; |
4454 | - } |
4455 | - m_Doc->AdjustItemSize(this); |
4456 | - m_Doc->MoveItem(mx, my, this, false); |
4457 | - m_Doc->regionsChanged()->update(QRectF()); |
4458 | - } |
4459 | - |
4460 | -} |
4461 | - |
4462 | -void PageItem::restoreImageEffects(UndoState *state, bool isUndo) |
4463 | -{ |
4464 | - ItemState<QPair<ScImageEffectList, ScImageEffectList> > *istate = |
4465 | - dynamic_cast<ItemState<QPair<ScImageEffectList,ScImageEffectList> >*>(state); |
4466 | - if (istate) |
4467 | - { |
4468 | - if (isUndo) |
4469 | - effectsInUse = istate->getItem().first; |
4470 | - else |
4471 | - effectsInUse = istate->getItem().second; |
4472 | - |
4473 | - select(); |
4474 | - m_Doc->updatePic(); |
4475 | - } |
4476 | -} |
4477 | - |
4478 | -void PageItem::restoreEditText(SimpleState *state, bool isUndo) |
4479 | -{ |
4480 | - if (!isTextFrame()) |
4481 | - return; |
4482 | - itemText.deselectAll(); |
4483 | - HasSel = false; |
4484 | - EditAct action = (EditAct) state->getInt("STEXT"); |
4485 | - if (action == PARAMFULL || action == PARAMSEL) |
4486 | - { |
4487 | - QString buffer; |
4488 | - if (isUndo) |
4489 | - buffer.append(state->get("STEXT_OLD")); |
4490 | - else |
4491 | - buffer.append(state->get("STEXT_NEW")); |
4492 | - if (!buffer.isEmpty()) |
4493 | - { |
4494 | - Serializer dig(*m_Doc); |
4495 | - dig.store<ScribusDoc>("<scribusdoc>", m_Doc); |
4496 | - StoryText::desaxeRules("/", dig, "SCRIBUSTEXT"); |
4497 | - dig.addRule("/SCRIBUSTEXT", desaxe::Result<StoryText>()); |
4498 | - dig.parseMemory(buffer.toStdString().c_str(), buffer.length()); |
4499 | - StoryText* story = dig.result<StoryText>(); |
4500 | - if (action == PARAMFULL) |
4501 | - { |
4502 | - itemText.selectAll(); |
4503 | - itemText.clear(); |
4504 | - itemText.append(*story); |
4505 | - } |
4506 | - else if (action == PARAMSEL) |
4507 | - { |
4508 | - itemText.deselectAll(); |
4509 | - int SelStart = state->getInt("STEXT_SELSTART"); |
4510 | - itemText.select(SelStart,state->getInt("STEXT_SELLEN")); |
4511 | - asTextFrame()->deleteSelectedTextFromFrame(); |
4512 | - int ItemLength = itemText.length(); |
4513 | - itemText.insert(SelStart, *story); |
4514 | - // If we have inserted at end of text we have to restore trailing style |
4515 | - if (ItemLength == SelStart && story->length() > 0 && story->text(-1) != SpecialChars::PARSEP) |
4516 | - { |
4517 | - itemText.setStyle(-1, story->paragraphStyle(story->length())); |
4518 | - } |
4519 | - itemText.select(SelStart, story->length()); |
4520 | - HasSel = true; |
4521 | - } |
4522 | - CPos = itemText.endOfSelection(); |
4523 | - delete story; |
4524 | - } |
4525 | - else { qDebug() << "UNDO buffer EMPTY";} |
4526 | - } |
4527 | - else if (action == REPSAX) |
4528 | - { |
4529 | - QString buffout, buffin; //buffout is deleted, buffin is inserted |
4530 | - int pos = state->getInt("STEXT_CPOS"); |
4531 | - if (isUndo) |
4532 | - { |
4533 | - buffin.append(state->get("STEXT_OLD")); |
4534 | - buffout.append(state->get("STEXT_NEW")); |
4535 | - } |
4536 | - else |
4537 | - { |
4538 | - buffin.append(state->get("STEXT_NEW")); |
4539 | - buffout.append(state->get("STEXT_OLD")); |
4540 | - } |
4541 | - |
4542 | - Serializer dig(*m_Doc); |
4543 | - dig.store<ScribusDoc>("<scribusdoc>", m_Doc); |
4544 | - StoryText::desaxeRules("/", dig, "SCRIBUSTEXT"); |
4545 | - dig.addRule("/SCRIBUSTEXT", desaxe::Result<StoryText>()); |
4546 | - dig.parseMemory(buffout.toStdString().c_str(), buffout.length()); |
4547 | - StoryText* story = dig.result<StoryText>(); |
4548 | - itemText.select(pos,story->length()); |
4549 | - asTextFrame()->deleteSelectedTextFromFrame(); |
4550 | - |
4551 | - Serializer dig2(*m_Doc); |
4552 | - dig2.store<ScribusDoc>("<scribusdoc>", m_Doc); |
4553 | - StoryText::desaxeRules("/", dig2, "SCRIBUSTEXT"); |
4554 | - dig2.addRule("/SCRIBUSTEXT", desaxe::Result<StoryText>()); |
4555 | - dig2.parseMemory(buffin.toStdString().c_str(), buffin.length()); |
4556 | - story = dig2.result<StoryText>(); |
4557 | - itemText.insert(pos,*story); |
4558 | - itemText.select(pos, story->length()); |
4559 | - HasSel = true; |
4560 | - CPos = pos + story->length(); |
4561 | - delete story; |
4562 | - } |
4563 | - else if (action == INSSAX || action == DELSAX) |
4564 | - { |
4565 | - QString str = state->get("STEXT_STR"); |
4566 | - if (str.isEmpty()) |
4567 | - str = itemTextSaxed; |
4568 | - int pos = state->getInt("STEXT_CPOS"); |
4569 | - Serializer dig(*m_Doc); |
4570 | - dig.store<ScribusDoc>("<scribusdoc>", m_Doc); |
4571 | - StoryText::desaxeRules("/", dig, "SCRIBUSTEXT"); |
4572 | - dig.addRule("/SCRIBUSTEXT", desaxe::Result<StoryText>()); |
4573 | - dig.parseMemory(str.toStdString().c_str(), str.length()); |
4574 | - StoryText* story = dig.result<StoryText>(); |
4575 | - if ((action == INSSAX && isUndo) || (action == DELSAX && !isUndo)) |
4576 | - { |
4577 | - //undo for INSSAX, redo for DELSAX |
4578 | - itemText.select(pos, story->length()); |
4579 | - asTextFrame()->deleteSelectedTextFromFrame(); |
4580 | - } |
4581 | - else |
4582 | - { |
4583 | - //undo for DELSAX, redo for INSSAX |
4584 | - itemText.insert(pos, *story); |
4585 | - CPos = pos + story->length(); |
4586 | - } |
4587 | - delete story; |
4588 | - } |
4589 | - else if (action == INS) |
4590 | - { |
4591 | - QString str = state->get("STEXT_STR"); |
4592 | - int pos = state->getInt("STEXT_CPOS"); |
4593 | - if (isUndo) |
4594 | - { |
4595 | - itemText.select(pos, str.length()); |
4596 | - asTextFrame()->deleteSelectedTextFromFrame(); |
4597 | - } |
4598 | - else |
4599 | - { |
4600 | - itemText.insertChars(pos, str, true); |
4601 | - CPos = pos + str.length(); |
4602 | - } |
4603 | - } |
4604 | - // after Undo or Redo new actions should create new undoStates |
4605 | - asTextFrame()->lastUndoAction = NOACTION; |
4606 | - |
4607 | - m_Doc->scMW()->setTBvals(this); |
4608 | - update(); |
4609 | -} |
4610 | - |
4611 | -QString PageItem::getItemTextSaxed(EditActPlace undoItem) |
4612 | -{ |
4613 | - if (!isTextFrame()) return ""; |
4614 | - StoryText iT(m_Doc); |
4615 | - iT.setDefaultStyle(itemText.defaultStyle()); |
4616 | - if (undoItem == FRAME) |
4617 | - iT.insert(0, itemText); |
4618 | - else |
4619 | - { |
4620 | - int StartOldSel = -1, LenOldSel = -1; |
4621 | - if (undoItem == PARAGRAPH) |
4622 | - { |
4623 | - LenOldSel = 0; |
4624 | - if (HasSel) |
4625 | - { |
4626 | - StartOldSel = itemText.startOfSelection(); |
4627 | - LenOldSel = itemText.lengthOfSelection(); |
4628 | - } |
4629 | - asTextFrame()->expandParaSelection(true); |
4630 | - } |
4631 | - else if (undoItem == CHAR || (undoItem == SELECTION && !HasSel)) |
4632 | - { |
4633 | - LenOldSel = itemText.lengthOfSelection(); |
4634 | - if (LenOldSel > 0) |
4635 | - StartOldSel = itemText.startOfSelection(); |
4636 | - if (CPos >= itemText.length()) |
4637 | - return ""; |
4638 | - itemText.select(CPos,1); |
4639 | - HasSel = true; |
4640 | - } |
4641 | - //is SELECTION |
4642 | - iT.insert(0, itemText, HasSel); |
4643 | - if (LenOldSel > 0) //restoring old selection if undoItem was PARAPGRAPH |
4644 | - { |
4645 | - itemText.select(StartOldSel, LenOldSel); |
4646 | - HasSel = true; |
4647 | - } |
4648 | - else if (LenOldSel == 0) |
4649 | - { |
4650 | - itemText.deselectAll(); |
4651 | - HasSel = false; |
4652 | - } |
4653 | - } |
4654 | - //saxing text |
4655 | - std::ostringstream xmlString; |
4656 | - SaxXML xmlStream(xmlString); |
4657 | - xmlStream.beginDoc(); |
4658 | - iT.saxx(xmlStream, "SCRIBUSTEXT"); |
4659 | - xmlStream.endDoc(); |
4660 | - std::string xml(xmlString.str()); |
4661 | - return QString(xml.c_str()); |
4662 | -} |
4663 | - |
4664 | -QString PageItem::getItemTextSaxed(int selStart, int selLength) |
4665 | -{ |
4666 | - if (selStart < 0 || selLength < 0) |
4667 | - return QString(); |
4668 | - |
4669 | - StoryText it(m_Doc); |
4670 | - it.setDefaultStyle(itemText.defaultStyle()); |
4671 | - |
4672 | - int oldSelStart = -1, oldSelLength = -1; |
4673 | - oldSelStart = itemText.startOfSelection(); |
4674 | - oldSelLength = itemText.lengthOfSelection(); |
4675 | - |
4676 | - itemText.select(selStart, selLength); |
4677 | - it.insert(0, itemText, (selLength > 0)); |
4678 | - |
4679 | - if (oldSelLength > 0) //restoring old selection if undoItem was PARAPGRAPH |
4680 | - { |
4681 | - itemText.select(oldSelStart, oldSelLength); |
4682 | - HasSel = true; |
4683 | - } |
4684 | - else if (oldSelLength == 0) |
4685 | - { |
4686 | - itemText.deselectAll(); |
4687 | - HasSel = false; |
4688 | - } |
4689 | - |
4690 | - //saxing text |
4691 | - std::ostringstream xmlString; |
4692 | - SaxXML xmlStream(xmlString); |
4693 | - xmlStream.beginDoc(); |
4694 | - it.saxx(xmlStream, "SCRIBUSTEXT"); |
4695 | - xmlStream.endDoc(); |
4696 | - std::string xml(xmlString.str()); |
4697 | - return QString(xml.c_str()); |
4698 | -} |
4699 | - |
4700 | -QString PageItem::getTextSaxed(QString str) |
4701 | -{ |
4702 | - StoryText iT(m_Doc); |
4703 | - iT.setDefaultStyle(itemText.defaultStyle()); |
4704 | - iT.insertChars(0,str,true); |
4705 | - std::ostringstream xmlString; |
4706 | - SaxXML xmlStream(xmlString); |
4707 | - xmlStream.beginDoc(); |
4708 | - iT.saxx(xmlStream, "SCRIBUSTEXT"); |
4709 | - xmlStream.endDoc(); |
4710 | - std::string xml(xmlString.str()); |
4711 | - return QString(xml.c_str()); |
4712 | -} |
4713 | - |
4714 | -void PageItem::select() |
4715 | -{ |
4716 | - if (m_Doc->m_Selection->count() == 1 && m_Doc->m_Selection->itemAt()->isTextFrame()) |
4717 | - m_Doc->m_Selection->itemAt()->asTextFrame()->lastUndoAction = PageItem::NOACTION; |
4718 | - m_Doc->view()->Deselect(false); |
4719 | - //CB #2969 add this true parm to addItem so we dont connectToGUI, the rest of view->SelectItem isnt needed anyway |
4720 | - m_Doc->m_Selection->addItem(this, true); |
4721 | -} |
4722 | - |
4723 | -ObjAttrVector* PageItem::getObjectAttributes() |
4724 | -{ |
4725 | - return &pageItemAttributes; |
4726 | -} |
4727 | - |
4728 | -ObjectAttribute PageItem::getObjectAttribute(QString attributeName) const |
4729 | -{ |
4730 | - int countFound=0; |
4731 | - ObjAttrVector::const_iterator foundIt = pageItemAttributes.begin(); |
4732 | - for(ObjAttrVector::const_iterator objAttrIt = pageItemAttributes.begin() ; objAttrIt != pageItemAttributes.end(); ++objAttrIt ) |
4733 | - { |
4734 | - if ((*objAttrIt).name==attributeName) |
4735 | - { |
4736 | - ++countFound; |
4737 | - foundIt=objAttrIt; |
4738 | - } |
4739 | - } |
4740 | - ObjectAttribute returnAttribute; |
4741 | - if(countFound==1) |
4742 | - returnAttribute=(*foundIt); |
4743 | - else |
4744 | - returnAttribute.name=QString::null; |
4745 | - return returnAttribute; |
4746 | -} |
4747 | - |
4748 | - |
4749 | -void PageItem::setObjectAttributes(ObjAttrVector* map) |
4750 | -{ |
4751 | - pageItemAttributes=*map; |
4752 | -} |
4753 | - |
4754 | -QString PageItem::generateUniqueCopyName(const QString originalName) const |
4755 | -{ |
4756 | - if (!m_Doc->itemNameExists(originalName)) |
4757 | - return originalName; |
4758 | - |
4759 | - // Start embellishing the name until we get an acceptable unique name |
4760 | - // first we prefix `Copy of' if it's not already there |
4761 | - QString newname(originalName); |
4762 | - if (!originalName.startsWith( tr("Copy of"))) |
4763 | - newname.prepend( tr("Copy of")+" "); |
4764 | - |
4765 | - // See if the name prefixed by "Copy of " is free |
4766 | - if (m_Doc->itemNameExists(newname)) |
4767 | - { |
4768 | - // Search the string for (number) at the end and capture |
4769 | - // both the number and the text leading up to it sans brackets. |
4770 | - // Copy of fred (5) |
4771 | - // ^^^^^^^^^^^^ ^ (where ^ means captured) |
4772 | - static QRegExp rx("^(.*)\\s+\\((\\d+)\\)$"); |
4773 | - int numMatches = rx.lastIndexIn(newname); |
4774 | - // Add a (number) suffix to the end of the name. We start at the |
4775 | - // old suffix's value if there was one, or at 2 if there was not. |
4776 | - int suffixnum = 2; |
4777 | - QString prefix(newname); |
4778 | - if (numMatches != -1) |
4779 | - { |
4780 | - // Already had a suffix; use the name w/o suffix for prefix and |
4781 | - // grab the old suffix value as a starting point. |
4782 | - QStringList matches = rx.capturedTexts(); |
4783 | - prefix = matches[1]; |
4784 | - suffixnum = matches[2].toInt(); |
4785 | - } |
4786 | - // Keep on incrementing the suffix 'till we find a free name |
4787 | - do |
4788 | - { |
4789 | - newname = prefix + " (" + QString::number(suffixnum) + ")"; |
4790 | - suffixnum ++; |
4791 | - } |
4792 | - while (m_Doc->itemNameExists(newname)); |
4793 | - } |
4794 | - // Unnecessary assert, previous code ensure condition is always true - JG |
4795 | - // assert(!m_Doc->itemNameExists(newname)); |
4796 | - return newname; |
4797 | -} |
4798 | - |
4799 | -void PageItem::setTagged(bool tag) |
4800 | -{ |
4801 | - tagged=tag; |
4802 | -} |
4803 | - |
4804 | -void PageItem::replaceNamedResources(ResourceCollection& newNames) |
4805 | -{ |
4806 | - QMap<QString,QString>::ConstIterator it; |
4807 | - |
4808 | - it = newNames.colors().find(fillColor()); |
4809 | - if (it != newNames.colors().end()) |
4810 | - setFillColor(*it); |
4811 | - |
4812 | - it = newNames.colors().find(lineColor()); |
4813 | - if (it != newNames.colors().end()) |
4814 | - setLineColor(*it); |
4815 | - |
4816 | - QList<VColorStop*> cstops = fill_gradient.colorStops(); |
4817 | - for (uint cst = 0; cst < fill_gradient.Stops(); ++cst) |
4818 | - { |
4819 | - it = newNames.colors().find(cstops.at(cst)->name); |
4820 | - if (it != newNames.colors().end()) |
4821 | - { |
4822 | - if (*it != CommonStrings::None) |
4823 | - cstops.at(cst)->name = *it; |
4824 | - } |
4825 | - } |
4826 | - if (effectsInUse.count() != 0) |
4827 | - { |
4828 | - QString col1 = CommonStrings::None; |
4829 | - QString col2 = CommonStrings::None; |
4830 | - QString col3 = CommonStrings::None; |
4831 | - QString col4 = CommonStrings::None; |
4832 | - for (int a = 0; a < effectsInUse.count(); ++a) |
4833 | - { |
4834 | - QString tmpstr = effectsInUse.at(a).effectParameters; |
4835 | - QString tmpstr2 = ""; |
4836 | - ScTextStream fp(&tmpstr, QIODevice::ReadOnly); |
4837 | - switch (effectsInUse.at(a).effectCode) |
4838 | - { |
4839 | - case ScImage::EF_QUADTONE: |
4840 | - col1 = fp.readLine(); |
4841 | - col2 = fp.readLine(); |
4842 | - col3 = fp.readLine(); |
4843 | - col4 = fp.readLine(); |
4844 | - it = newNames.colors().find(col1); |
4845 | - if (it != newNames.colors().end()) |
4846 | - { |
4847 | - if (*it != CommonStrings::None) |
4848 | - tmpstr2 += *it + "\n"; |
4849 | - else |
4850 | - tmpstr2 += col1 + "\n"; |
4851 | - } |
4852 | - else |
4853 | - tmpstr2 += col1 + "\n"; |
4854 | - it = newNames.colors().find(col2); |
4855 | - if (it != newNames.colors().end()) |
4856 | - { |
4857 | - if (*it != CommonStrings::None) |
4858 | - tmpstr2 += *it + "\n"; |
4859 | - else |
4860 | - tmpstr2 += col2 + "\n"; |
4861 | - } |
4862 | - else |
4863 | - tmpstr2 += col2 + "\n"; |
4864 | - it = newNames.colors().find(col3); |
4865 | - if (it != newNames.colors().end()) |
4866 | - { |
4867 | - if (*it != CommonStrings::None) |
4868 | - tmpstr2 += *it + "\n"; |
4869 | - else |
4870 | - tmpstr2 += col3 + "\n"; |
4871 | - } |
4872 | - else |
4873 | - tmpstr2 += col3 + "\n"; |
4874 | - it = newNames.colors().find(col4); |
4875 | - if (it != newNames.colors().end()) |
4876 | - { |
4877 | - if (*it != CommonStrings::None) |
4878 | - tmpstr2 += *it + "\n"; |
4879 | - else |
4880 | - tmpstr2 += col4 + "\n"; |
4881 | - } |
4882 | - else |
4883 | - tmpstr2 += col4 + "\n"; |
4884 | - tmpstr2 += fp.readAll(); |
4885 | - break; |
4886 | - case ScImage::EF_TRITONE: |
4887 | - col1 = fp.readLine(); |
4888 | - col2 = fp.readLine(); |
4889 | - col3 = fp.readLine(); |
4890 | - it = newNames.colors().find(col1); |
4891 | - if (it != newNames.colors().end()) |
4892 | - { |
4893 | - if (*it != CommonStrings::None) |
4894 | - tmpstr2 += *it + "\n"; |
4895 | - else |
4896 | - tmpstr2 += col1 + "\n"; |
4897 | - } |
4898 | - else |
4899 | - tmpstr2 += col1 + "\n"; |
4900 | - it = newNames.colors().find(col2); |
4901 | - if (it != newNames.colors().end()) |
4902 | - { |
4903 | - if (*it != CommonStrings::None) |
4904 | - tmpstr2 += *it + "\n"; |
4905 | - else |
4906 | - tmpstr2 += col2 + "\n"; |
4907 | - } |
4908 | - else |
4909 | - tmpstr2 += col2 + "\n"; |
4910 | - it = newNames.colors().find(col3); |
4911 | - if (it != newNames.colors().end()) |
4912 | - { |
4913 | - if (*it != CommonStrings::None) |
4914 | - tmpstr2 += *it + "\n"; |
4915 | - else |
4916 | - tmpstr2 += col3 + "\n"; |
4917 | - } |
4918 | - else |
4919 | - tmpstr2 += col3 + "\n"; |
4920 | - tmpstr2 += fp.readAll(); |
4921 | - break; |
4922 | - case ScImage::EF_DUOTONE: |
4923 | - col1 = fp.readLine(); |
4924 | - col2 = fp.readLine(); |
4925 | - it = newNames.colors().find(col1); |
4926 | - if (it != newNames.colors().end()) |
4927 | - { |
4928 | - if (*it != CommonStrings::None) |
4929 | - tmpstr2 += *it + "\n"; |
4930 | - else |
4931 | - tmpstr2 += col1 + "\n"; |
4932 | - } |
4933 | - else |
4934 | - tmpstr2 += col1 + "\n"; |
4935 | - it = newNames.colors().find(col2); |
4936 | - if (it != newNames.colors().end()) |
4937 | - { |
4938 | - if (*it != CommonStrings::None) |
4939 | - tmpstr2 += *it + "\n"; |
4940 | - else |
4941 | - tmpstr2 += col2 + "\n"; |
4942 | - } |
4943 | - else |
4944 | - tmpstr2 += col2 + "\n"; |
4945 | - tmpstr2 += fp.readAll(); |
4946 | - break; |
4947 | - case ScImage::EF_COLORIZE: |
4948 | - col1 = fp.readLine(); |
4949 | - it = newNames.colors().find(col1); |
4950 | - if (it != newNames.colors().end()) |
4951 | - { |
4952 | - if (*it != CommonStrings::None) |
4953 | - tmpstr2 += *it + "\n" + fp.readAll(); |
4954 | - else |
4955 | - tmpstr2 += col1 + "\n" + fp.readAll(); |
4956 | - } |
4957 | - else |
4958 | - tmpstr2 += col1 + "\n" + fp.readAll(); |
4959 | - break; |
4960 | - default: |
4961 | - tmpstr2 = tmpstr; |
4962 | - break; |
4963 | - } |
4964 | - effectsInUse[a].effectParameters = tmpstr2; |
4965 | - } |
4966 | - } |
4967 | - |
4968 | - it = newNames.patterns().find(pattern()); |
4969 | - if (it != newNames.patterns().end()) |
4970 | - setPattern(*it); |
4971 | - |
4972 | - it = newNames.lineStyles().find(customLineStyle()); |
4973 | - if (it != newNames.lineStyles().end()) |
4974 | - setCustomLineStyle(*it); |
4975 | - |
4976 | - if (prevInChain() == NULL) |
4977 | - itemText.replaceNamedResources(newNames); |
4978 | -} |
4979 | - |
4980 | - |
4981 | -void PageItem::getNamedResources(ResourceCollection& lists) const |
4982 | -{ |
4983 | - lists.collectColor(lineColor()); |
4984 | - if (GrType == 0) |
4985 | - lists.collectColor(fillColor()); |
4986 | - else if (GrType < 8) |
4987 | - { |
4988 | - QList<VColorStop*> cstops = fill_gradient.colorStops(); |
4989 | - for (uint cst = 0; cst < fill_gradient.Stops(); ++cst) |
4990 | - { |
4991 | - lists.collectColor(cstops.at(cst)->name); |
4992 | - } |
4993 | - } |
4994 | - if (effectsInUse.count() != 0) |
4995 | - { |
4996 | - for (int a = 0; a < effectsInUse.count(); ++a) |
4997 | - { |
4998 | - QString tmpstr = effectsInUse.at(a).effectParameters; |
4999 | - ScTextStream fp(&tmpstr, QIODevice::ReadOnly); |
5000 | - switch (effectsInUse.at(a).effectCode) |
The diff has been truncated for viewing.
1.4.0.dfsg+r17300-1 has been merged already.