Rev 3918 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4430 | cbradney | 1 | /* |
2 | For general Scribus (>=1.3.2) copyright and licensing information please refer |
||
3 | to the COPYING file provided with the program. Following this notice may exist |
||
4 | a copyright and/or license notice that predates the release of Scribus 1.3.2 |
||
5 | for which a new license (GPL+exception) is in place. |
||
6 | */ |
||
3 | paul | 7 | /*************************************************************************** |
8 | pageitem.cpp - description |
||
9 | ------------------- |
||
10 | begin : Sat Apr 7 2001 |
||
11 | copyright : (C) 2001 by Franz Schmid |
||
12 | email : Franz.Schmid@altmuehlnet.de |
||
13 | ***************************************************************************/ |
||
14 | |||
15 | /*************************************************************************** |
||
16 | * * |
||
17 | * This program is free software; you can redistribute it and/or modify * |
||
18 | * it under the terms of the GNU General Public License as published by * |
||
19 | * the Free Software Foundation; either version 2 of the License, or * |
||
20 | * (at your option) any later version. * |
||
21 | * * |
||
22 | ***************************************************************************/ |
||
136 | Franz | 23 | |
3 | paul | 24 | #include "pageitem.h" |
270 | Franz | 25 | #include "pageitem.moc" |
3 | paul | 26 | #include <qpainter.h> |
27 | #include <qpen.h> |
||
68 | Franz | 28 | #include <qfont.h> |
3 | paul | 29 | #include <qregion.h> |
30 | #include <qpoint.h> |
||
31 | #include <qfileinfo.h> |
||
32 | #include <qdrawutil.h> |
||
33 | #include <qbitmap.h> |
||
3056 | avox | 34 | #include <qregexp.h> |
1818 | cbradney | 35 | #include <qmessagebox.h> |
3 | paul | 36 | #include <cmath> |
2104 | cbradney | 37 | #include <cassert> |
4772 | cbradney | 38 | |
2004 | fschmid | 39 | #include "scpaths.h" |
3 | paul | 40 | #include "page.h" |
4772 | cbradney | 41 | #include "scpainter.h" |
243 | Franz | 42 | #include "scribus.h" |
3903 | cbradney | 43 | #include "scribusapp.h" |
3030 | cbradney | 44 | #include "scribusstructs.h" |
838 | cbradney | 45 | #include "scribusdoc.h" |
4320 | cbradney | 46 | #include "scribuswin.h" |
3934 | cbradney | 47 | #include "selection.h" |
3302 | cbradney | 48 | #include "prefsmanager.h" |
1204 | tsoots | 49 | #include "undomanager.h" |
50 | #include "undostate.h" |
||
1263 | tsoots | 51 | #include "mpalette.h" |
3903 | cbradney | 52 | #include "cpalette.h" |
4546 | subik | 53 | #include "commonstrings.h" |
2688 | craig | 54 | #include "scconfig.h" |
5087 | subik | 55 | #include "guidemanager.h" |
128 | Franz | 56 | |
68 | Franz | 57 | #include <ft2build.h> |
58 | #include FT_GLYPH_H |
||
504 | cbradney | 59 | |
2534 | craig | 60 | #include "scfontmetrics.h" |
2533 | craig | 61 | #include "util.h" |
62 | |||
5184 | avox | 63 | #include "text/nlsconfig.h" |
64 | |||
504 | cbradney | 65 | using namespace std; |
66 | |||
3625 | avox | 67 | PageItem::PageItem(const PageItem & other) |
68 | : QObject(other.parent()), |
||
3903 | cbradney | 69 | UndoObject(other), |
3625 | avox | 70 | |
71 | // 200 attributes! That is madness, or to quote some famous people from Kriquet: |
||
72 | // "THAT ALL HAS TO GO!" |
||
73 | gXpos(other.gXpos), |
||
74 | gYpos(other.gYpos), |
||
75 | gWidth(other.gWidth), |
||
76 | gHeight(other.gHeight), |
||
77 | GrType(other.GrType), |
||
78 | GrStartX(other.GrStartX), |
||
79 | GrStartY(other.GrStartY), |
||
80 | GrEndX(other.GrEndX), |
||
81 | GrEndY(other.GrEndY), |
||
82 | TxtStroke(other.TxtStroke), |
||
83 | TxtFill(other.TxtFill), |
||
84 | ShTxtStroke(other.ShTxtStroke), |
||
85 | ShTxtFill(other.ShTxtFill), |
||
86 | TxtScale(other.TxtScale), |
||
87 | TxtScaleV(other.TxtScaleV), |
||
88 | TxTStyle(other.TxTStyle), |
||
89 | TxtBase(other.TxtBase), |
||
90 | TxtShadowX(other.TxtShadowX), |
||
91 | TxtShadowY(other.TxtShadowY), |
||
92 | TxtOutline(other.TxtOutline), |
||
93 | TxtUnderPos(other.TxtUnderPos), |
||
94 | TxtUnderWidth(other.TxtUnderWidth), |
||
95 | TxtStrikePos(other.TxtStrikePos), |
||
96 | TxtStrikeWidth(other.TxtStrikeWidth), |
||
97 | Cols(other.Cols), |
||
98 | ColGap(other.ColGap), |
||
3903 | cbradney | 99 | PLineArt(other.PLineArt), |
3625 | avox | 100 | PLineEnd(other.PLineEnd), |
101 | PLineJoin(other.PLineJoin), |
||
102 | NamedLStyle(other.NamedLStyle), |
||
103 | Clip(other.Clip), |
||
104 | PoLine(other.PoLine), |
||
105 | ContourLine(other.ContourLine), |
||
106 | imageClip(other.imageClip), |
||
107 | Segments(other.Segments), |
||
108 | effectsInUse(other.effectsInUse), |
||
109 | PoShow(other.PoShow), |
||
110 | BaseOffs(other.BaseOffs), |
||
111 | ClipEdited(other.ClipEdited), |
||
112 | FrameType(other.FrameType), |
||
113 | ItemNr(other.ItemNr), |
||
114 | Frame(other.Frame), |
||
115 | OwnPage(other.OwnPage), |
||
116 | oldOwnPage(other.oldOwnPage), |
||
3903 | cbradney | 117 | pixm(other.pixm), |
118 | Pfile(other.Pfile), |
||
3625 | avox | 119 | Pfile2(other.Pfile2), |
120 | Pfile3(other.Pfile3), |
||
121 | IProfile(other.IProfile), |
||
122 | UseEmbedded(other.UseEmbedded), |
||
123 | EmProfile(other.EmProfile), |
||
124 | IRender(other.IRender), |
||
4621 | cbradney | 125 | |
3903 | cbradney | 126 | PicAvail(other.PicAvail), |
3625 | avox | 127 | OrigW(other.OrigW), |
128 | OrigH(other.OrigH), |
||
3903 | cbradney | 129 | BBoxX(other.BBoxX), |
130 | BBoxH(other.BBoxH), |
||
3625 | avox | 131 | CurX(other.CurX), |
132 | CurY(other.CurY), |
||
133 | CPos(other.CPos), |
||
134 | itemText(other.itemText), |
||
3903 | cbradney | 135 | isBookmark(other.isBookmark), |
136 | HasSel(other.HasSel), |
||
137 | FrameOnly(other.FrameOnly), |
||
3625 | avox | 138 | BackBox(other.BackBox), |
139 | NextBox(other.NextBox), |
||
140 | NextIt(other.NextIt), |
||
141 | NextPg(other.NextPg), |
||
142 | Tinput(other.Tinput), |
||
143 | isAutoText(other.isAutoText), |
||
144 | textAlignment(other.textAlignment), |
||
5184 | avox | 145 | #ifndef NLS_PROTO |
3625 | avox | 146 | MaxChars(other.MaxChars), |
5184 | avox | 147 | #endif |
3625 | avox | 148 | Redrawn(other.Redrawn), |
149 | ExtraV(other.ExtraV), |
||
150 | isRaster(other.isRaster), |
||
151 | OldB(other.OldB), |
||
152 | OldH(other.OldH), |
||
153 | OldB2(other.OldB2), |
||
154 | OldH2(other.OldH2), |
||
155 | Sizing(other.Sizing), |
||
156 | toPixmap(other.toPixmap), |
||
157 | LayerNr(other.LayerNr), |
||
158 | ScaleType(other.ScaleType), |
||
159 | AspectRatio(other.AspectRatio), |
||
160 | Groups(other.Groups), |
||
161 | DashValues(other.DashValues), |
||
162 | TabValues(other.TabValues), |
||
163 | DashOffset(other.DashOffset), |
||
164 | fill_gradient(other.fill_gradient), |
||
165 | fillRule(other.fillRule), |
||
166 | Language(other.Language), |
||
167 | LeftLink(other.LeftLink), |
||
168 | RightLink(other.RightLink), |
||
169 | TopLink(other.TopLink), |
||
170 | BottomLink(other.BottomLink), |
||
171 | LeftLinkID(other.LeftLinkID), |
||
172 | RightLinkID(other.RightLinkID), |
||
173 | TopLinkID(other.TopLinkID), |
||
174 | BottomLinkID(other.BottomLinkID), |
||
175 | LeftLine(other.LeftLine), |
||
176 | RightLine(other.RightLine), |
||
177 | TopLine(other.TopLine), |
||
178 | BottomLine(other.BottomLine), |
||
179 | isTableItem(other.isTableItem), |
||
180 | isSingleSel(other.isSingleSel), |
||
181 | BoundingX(other.BoundingX), |
||
182 | BoundingY(other.BoundingY), |
||
183 | BoundingW(other.BoundingW), |
||
184 | BoundingH(other.BoundingH), |
||
185 | ChangedMasterItem(other.ChangedMasterItem), |
||
186 | OnMasterPage(other.OnMasterPage), |
||
187 | isEmbedded(other.isEmbedded), |
||
188 | |||
189 | // protected |
||
4061 | craig | 190 | undoManager(other.undoManager), |
3625 | avox | 191 | AnName(other.AnName), |
192 | fillColorVal(other.fillColorVal), |
||
193 | lineColorVal(other.lineColorVal), |
||
194 | lineShadeVal(other.lineShadeVal), |
||
195 | fillShadeVal(other.fillShadeVal), |
||
196 | fillTransparencyVal(other.fillTransparencyVal), |
||
197 | lineTransparencyVal(other.fillTransparencyVal), |
||
4699 | cbradney | 198 | m_ImageIsFlippedH(other.m_ImageIsFlippedH), |
199 | m_ImageIsFlippedV(other.m_ImageIsFlippedV), |
||
4695 | cbradney | 200 | m_Locked(other.m_Locked), |
201 | m_SizeLocked(other.m_SizeLocked), |
||
3625 | avox | 202 | textFlowsAroundFrameVal(other.textFlowsAroundFrameVal), |
203 | textFlowUsesBoundingBoxVal(other.textFlowUsesBoundingBoxVal), |
||
204 | textFlowUsesContourLineVal(other.textFlowUsesContourLineVal), |
||
205 | pageItemAttributes(other.pageItemAttributes), |
||
4698 | cbradney | 206 | m_PrintEnabled(other.m_PrintEnabled), |
3903 | cbradney | 207 | tagged(other.tagged), |
208 | fillQColor(other.fillQColor), |
||
3934 | cbradney | 209 | strokeQColor(other.strokeQColor), |
210 | Xpos(other.Xpos), |
||
211 | Ypos(other.Ypos), |
||
212 | Width(other.Width), |
||
213 | Height(other.Height), |
||
3939 | cbradney | 214 | Rot(other.Rot), |
3988 | cbradney | 215 | Select(other.Select), |
4010 | cbradney | 216 | LocalScX(other.LocalScX), |
217 | LocalScY(other.LocalScY), |
||
218 | LocalX(other.LocalX), |
||
219 | LocalY(other.LocalY), |
||
4061 | craig | 220 | Reverse(other.Reverse), |
221 | m_startArrowIndex(other.m_startArrowIndex), |
||
222 | m_endArrowIndex(other.m_endArrowIndex), |
||
4010 | cbradney | 223 | Extra(other.Extra), |
224 | TExtra(other.TExtra), |
||
225 | BExtra(other.BExtra), |
||
226 | RExtra(other.RExtra), |
||
227 | RadRect(other.RadRect), |
||
3988 | cbradney | 228 | oldXpos(other.oldXpos), |
229 | oldYpos(other.oldYpos), |
||
230 | oldWidth(other.oldWidth), |
||
4010 | cbradney | 231 | oldHeight(other.oldHeight), |
4073 | cbradney | 232 | oldRot(other.oldRot), |
4821 | cbradney | 233 | oldLocalScX(other.oldLocalScX), |
234 | oldLocalScY(other.oldLocalScY), |
||
235 | oldLocalX(other.oldLocalX), |
||
236 | oldLocalY(other.oldLocalY), |
||
4073 | cbradney | 237 | m_Font(other.m_Font), |
4084 | cbradney | 238 | m_FontSize(other.m_FontSize), |
239 | m_Doc(other.m_Doc), |
||
240 | m_isAnnotation(other.m_isAnnotation), |
||
4621 | cbradney | 241 | m_annotation(other.m_annotation), |
242 | PicArt(other.PicArt), |
||
243 | m_lineWidth(other.m_lineWidth), |
||
244 | Oldm_lineWidth(other.Oldm_lineWidth), |
||
245 | LineSp(other.LineSp), |
||
246 | LineSpMode(other.LineSpMode) |
||
3625 | avox | 247 | { |
248 | } |
||
249 | |||
250 | |||
2707 | subik | 251 | PageItem::PageItem(ScribusDoc *pa, ItemType newType, double x, double y, double w, double h, double w2, QString fill, QString outline) |
4061 | craig | 252 | // Initialize superclass(es) |
1656 | craig | 253 | : QObject(pa), |
4061 | craig | 254 | // Initialize member variables |
4688 | cbradney | 255 | itemText(pa), |
4061 | craig | 256 | undoManager(UndoManager::instance()), |
1749 | craig | 257 | lineShadeVal(100), |
1657 | craig | 258 | fillShadeVal(100), |
259 | fillTransparencyVal(0.0), |
||
260 | lineTransparencyVal(0.0), |
||
4699 | cbradney | 261 | m_ImageIsFlippedH(0), |
262 | m_ImageIsFlippedV(0), |
||
4695 | cbradney | 263 | m_Locked(false), |
264 | m_SizeLocked(false), |
||
1656 | craig | 265 | textFlowsAroundFrameVal(false), |
266 | textFlowUsesBoundingBoxVal(false), |
||
4688 | cbradney | 267 | textFlowUsesContourLineVal(false) |
3 | paul | 268 | { |
269 | QString tmp; |
||
270 | BackBox = 0; |
||
271 | NextBox = 0; |
||
4821 | cbradney | 272 | oldXpos = Xpos = x; |
273 | oldYpos = Ypos = y; |
||
274 | //CB Surely we can remove some of these? |
||
275 | OldB2 = OldB = oldWidth = Width = w; |
||
276 | OldH2 = OldH = oldHeight = Height = h; |
||
456 | fschmid | 277 | BoundingX = x; |
278 | BoundingY = y; |
||
279 | BoundingW = w; |
||
280 | BoundingH = h; |
||
4593 | cbradney | 281 | m_ItemType = newType; |
4821 | cbradney | 282 | oldRot = Rot = 0; |
4084 | cbradney | 283 | m_Doc = pa; |
1394 | cbradney | 284 | fillColorVal = fill; |
4593 | cbradney | 285 | lineColorVal = m_ItemType == PageItem::TextFrame ? fill : outline; |
4084 | cbradney | 286 | TxtFill = m_Doc->toolSettings.dPenText; |
287 | TxtStroke = m_Doc->toolSettings.dStrokeText; |
||
68 | Franz | 288 | ShTxtStroke = 100; |
289 | ShTxtFill = 100; |
||
2242 | fschmid | 290 | TxtScale = 1000; |
291 | TxtScaleV = 1000; |
||
2247 | fschmid | 292 | TxtShadowX = 50; |
293 | TxtShadowY = -50; |
||
2257 | fschmid | 294 | TxtOutline = 10; |
68 | Franz | 295 | TxTStyle = 0; |
2234 | fschmid | 296 | TxtBase = 0; |
4084 | cbradney | 297 | TxtUnderWidth = m_Doc->typographicSettings.valueUnderlineWidth; |
298 | TxtUnderPos = m_Doc->typographicSettings.valueUnderlinePos; |
||
299 | TxtStrikePos = m_Doc->typographicSettings.valueStrikeThruPos; |
||
300 | TxtStrikeWidth = m_Doc->typographicSettings.valueStrikeThruWidth; |
||
3 | paul | 301 | GrType = 0; |
292 | Franz | 302 | GrStartX = 0; |
303 | GrStartY = 0; |
||
294 | Franz | 304 | GrEndX = w; |
292 | Franz | 305 | GrEndY = 0; |
4580 | cbradney | 306 | m_lineWidth = w2; |
307 | Oldm_lineWidth = w2; |
||
4084 | cbradney | 308 | PLineArt = PenStyle(m_Doc->toolSettings.dLineArt); |
3 | paul | 309 | PLineEnd = FlatCap; |
310 | PLineJoin = MiterJoin; |
||
311 | Select = false; |
||
312 | FrameOnly = false; |
||
313 | ClipEdited = false; |
||
314 | FrameType = 0; |
||
4084 | cbradney | 315 | setFont(m_Doc->toolSettings.defFont); |
316 | setFontSize(m_Doc->toolSettings.defSize); |
||
2309 | fschmid | 317 | LineSpMode = 0; |
4084 | cbradney | 318 | LineSp = ((m_Doc->toolSettings.defSize / 10.0) * static_cast<double>(m_Doc->typographicSettings.autoLineSpacing) / 100) + (m_Doc->toolSettings.defSize / 10.0); |
5184 | avox | 319 | m_Doc->docParagraphStyles[0].setLineSpacing(LineSp); |
3 | paul | 320 | CurX = 0; |
321 | CurY = 0; |
||
322 | CPos = 0; |
||
323 | Extra = 1; |
||
324 | TExtra = 1; |
||
325 | BExtra = 1; |
||
326 | RExtra = 1; |
||
327 | ExtraV = 0; |
||
1065 | cbradney | 328 | itemText.clear(); |
5184 | avox | 329 | #ifndef NLS_PROTO |
1065 | cbradney | 330 | itemText.setAutoDelete(true); |
387 | Franz | 331 | MaxChars = 0; |
5184 | avox | 332 | #endif |
3 | paul | 333 | Pfile = ""; |
2004 | fschmid | 334 | pixm = ScImage(); |
4084 | cbradney | 335 | pixm.imgInfo.lowResType = m_Doc->toolSettings.lowResType; |
3 | paul | 336 | Pfile2 = ""; |
337 | Pfile3 = ""; |
||
4821 | cbradney | 338 | oldLocalScX = LocalScX = 1; |
339 | oldLocalScY = LocalScY = 1; |
||
3 | paul | 340 | OrigW = 0; |
341 | OrigH = 0; |
||
4821 | cbradney | 342 | oldLocalX = LocalX = 0; |
343 | oldLocalY = LocalY = 0; |
||
3 | paul | 344 | BBoxX = 0; |
345 | BBoxH = 0; |
||
346 | RadRect = 0; |
||
4593 | cbradney | 347 | if ((m_ItemType == TextFrame) || (m_ItemType == ImageFrame) || (m_ItemType == PathText)) |
1460 | cbradney | 348 | // TODO: Frame should become a read-only calculated property |
3 | paul | 349 | Frame = true; |
350 | else |
||
351 | Frame = false; |
||
4593 | cbradney | 352 | switch (m_ItemType) |
167 | Franz | 353 | { |
1460 | cbradney | 354 | case Polygon: |
340 | Franz | 355 | Clip.setPoints(4, static_cast<int>(w/2), 0, static_cast<int>(w), static_cast<int>(h/2), |
356 | static_cast<int>(w/2), static_cast<int>(h), 0,static_cast<int>(h/2)); |
||
3 | paul | 357 | break; |
358 | default: |
||
340 | Franz | 359 | Clip.setPoints(4, 0,0, static_cast<int>(w),0, static_cast<int>(w), static_cast<int>(h), 0,static_cast<int>(h)); |
3 | paul | 360 | break; |
167 | Franz | 361 | } |
3 | paul | 362 | PoLine.resize(0); |
340 | Franz | 363 | ContourLine.resize(0); |
2040 | fschmid | 364 | imageClip.resize(0); |
3 | paul | 365 | Segments.clear(); |
366 | PoShow = false; |
||
367 | BaseOffs = 0; |
||
5087 | subik | 368 | OwnPage = m_Doc->currentPage()->pageNr(); |
1211 | tsoots | 369 | oldOwnPage = OwnPage; |
4401 | fschmid | 370 | savedOwnPage = OwnPage; |
3 | paul | 371 | PicArt = true; |
372 | PicAvail = false; |
||
4698 | cbradney | 373 | m_PrintEnabled = true; |
3 | paul | 374 | isBookmark = false; |
4102 | cbradney | 375 | m_isAnnotation = false; |
4593 | cbradney | 376 | switch (m_ItemType) |
268 | Franz | 377 | { |
1460 | cbradney | 378 | case ImageFrame: |
268 | Franz | 379 | AnName = tr("Image"); |
1250 | tsoots | 380 | setUPixmap(Um::IImageFrame); |
268 | Franz | 381 | break; |
1460 | cbradney | 382 | case TextFrame: |
268 | Franz | 383 | AnName = tr("Text"); |
1250 | tsoots | 384 | setUPixmap(Um::ITextFrame); |
268 | Franz | 385 | break; |
1460 | cbradney | 386 | case Line: |
268 | Franz | 387 | AnName = tr("Line"); |
1250 | tsoots | 388 | setUPixmap(Um::ILine); |
268 | Franz | 389 | break; |
1460 | cbradney | 390 | case Polygon: |
268 | Franz | 391 | AnName = tr("Polygon"); |
1250 | tsoots | 392 | setUPixmap(Um::IPolygon); |
268 | Franz | 393 | break; |
1460 | cbradney | 394 | case PolyLine: |
268 | Franz | 395 | AnName = tr("Polyline"); |
1250 | tsoots | 396 | setUPixmap(Um::IPolyline); |
268 | Franz | 397 | break; |
1460 | cbradney | 398 | case PathText: |
268 | Franz | 399 | AnName = tr("PathText"); |
1250 | tsoots | 400 | setUPixmap(Um::IPathText); |
268 | Franz | 401 | break; |
402 | default: |
||
403 | AnName = "Item"; |
||
404 | break; |
||
405 | } |
||
4939 | fschmid | 406 | m_Doc->TotalItems++; |
4084 | cbradney | 407 | AnName += tmp.setNum(m_Doc->TotalItems); // +" "+QDateTime::currentDateTime().toString(); |
87 | Franz | 408 | AutoName = true; |
1204 | tsoots | 409 | setUName(AnName); |
4084 | cbradney | 410 | m_annotation.setBorderColor(outline); |
3 | paul | 411 | HasSel = false; |
412 | Tinput = false; |
||
413 | isAutoText = false; |
||
1065 | cbradney | 414 | textAlignment = 0; |
3 | paul | 415 | Redrawn = false; |
416 | isRaster = false; |
||
417 | Sizing = false; |
||
418 | toPixmap = false; |
||
419 | UseEmbedded = true; |
||
420 | EmProfile = ""; |
||
421 | Groups.clear(); |
||
4084 | cbradney | 422 | LayerNr = m_Doc->activeLayer(); |
3 | paul | 423 | ScaleType = true; |
424 | AspectRatio = true; |
||
425 | Reverse = false; |
||
27 | Franz | 426 | NamedLStyle = ""; |
68 | Franz | 427 | DashValues.clear(); |
139 | Franz | 428 | TabValues.clear(); |
68 | Franz | 429 | DashOffset = 0; |
1905 | fschmid | 430 | fillRule = true; |
68 | Franz | 431 | fill_gradient = VGradient(VGradient::linear); |
295 | Franz | 432 | fill_gradient.clearStops(); |
4546 | subik | 433 | if (fillColor() == CommonStrings::None) |
4084 | cbradney | 434 | fill_gradient.addStop(m_Doc->PageColors[m_Doc->toolSettings.dBrush].getRGBColor(), 0.0, 0.5, 1.0, m_Doc->toolSettings.dBrush, 100); |
304 | Franz | 435 | else |
4084 | cbradney | 436 | fill_gradient.addStop(m_Doc->PageColors[fillColor()].getRGBColor(), 0.0, 0.5, 1.0, fillColor(), 100); |
4546 | subik | 437 | if (lineColor() == CommonStrings::None) |
4084 | cbradney | 438 | fill_gradient.addStop(m_Doc->PageColors[m_Doc->toolSettings.dPen].getRGBColor(), 1.0, 0.5, 1.0, m_Doc->toolSettings.dPen, 100); |
304 | Franz | 439 | else |
4084 | cbradney | 440 | fill_gradient.addStop(m_Doc->PageColors[lineColor()].getRGBColor(), 1.0, 0.5, 1.0, lineColor(), 100); |
441 | Language = m_Doc->Language; |
||
442 | Cols = m_Doc->toolSettings.dCols; |
||
443 | ColGap = m_Doc->toolSettings.dGap; |
||
232 | Franz | 444 | LeftLink = 0; |
445 | RightLink = 0; |
||
446 | TopLink = 0; |
||
447 | BottomLink = 0; |
||
234 | Franz | 448 | LeftLinkID = 0; |
449 | RightLinkID = 0; |
||
450 | TopLinkID = 0; |
||
451 | BottomLinkID = 0; |
||
232 | Franz | 452 | LeftLine = 0; |
453 | RightLine = false; |
||
454 | TopLine = false; |
||
455 | BottomLine = false; |
||
456 | isTableItem = false; |
||
457 | isSingleSel = false; |
||
383 | Franz | 458 | Dirty = false; |
456 | fschmid | 459 | ChangedMasterItem = false; |
2434 | fschmid | 460 | isEmbedded = false; |
5087 | subik | 461 | OnMasterPage = m_Doc->currentPage()->PageNam; |
4084 | cbradney | 462 | m_startArrowIndex = m_Doc->toolSettings.dStartArrow; |
463 | m_endArrowIndex = m_Doc->toolSettings.dEndArrow; |
||
2056 | fschmid | 464 | effectsInUse.clear(); |
1659 | cbradney | 465 | //Page Item Attributes |
466 | pageItemAttributes.clear(); |
||
4084 | cbradney | 467 | for(ObjAttrVector::Iterator objAttrIt = m_Doc->docItemAttributes.begin() ; objAttrIt != m_Doc->docItemAttributes.end(); ++objAttrIt ) |
1659 | cbradney | 468 | { |
4593 | cbradney | 469 | if (((*objAttrIt).autoaddto=="textframes" && m_ItemType==TextFrame) || |
470 | ((*objAttrIt).autoaddto=="imageframes" && m_ItemType==ImageFrame) |
||
1659 | cbradney | 471 | ) |
472 | pageItemAttributes.append(*objAttrIt); |
||
473 | } |
||
3 | paul | 474 | } |
475 | |||
4644 | cbradney | 476 | void PageItem::setXPos(const double newXPos, bool drawingOnly) |
3903 | cbradney | 477 | { |
3934 | cbradney | 478 | Xpos = newXPos; |
4644 | cbradney | 479 | if (drawingOnly || m_Doc->isLoading()) |
480 | return; |
||
4621 | cbradney | 481 | checkChanges(); |
3934 | cbradney | 482 | emit position(Xpos, Ypos); |
3903 | cbradney | 483 | } |
484 | |||
4644 | cbradney | 485 | void PageItem::setYPos(const double newYPos, bool drawingOnly) |
3903 | cbradney | 486 | { |
3934 | cbradney | 487 | Ypos = newYPos; |
4644 | cbradney | 488 | if (drawingOnly || m_Doc->isLoading()) |
489 | return; |
||
4621 | cbradney | 490 | checkChanges(); |
3934 | cbradney | 491 | emit position(Xpos, Ypos); |
3903 | cbradney | 492 | } |
493 | |||
4644 | cbradney | 494 | void PageItem::setXYPos(const double newXPos, const double newYPos, bool drawingOnly) |
3903 | cbradney | 495 | { |
3934 | cbradney | 496 | Xpos = newXPos; |
497 | Ypos = newYPos; |
||
4644 | cbradney | 498 | if (drawingOnly || m_Doc->isLoading()) |
499 | return; |
||
4621 | cbradney | 500 | checkChanges(); |
3934 | cbradney | 501 | emit position(Xpos, Ypos); |
502 | } |
||
503 | |||
4644 | cbradney | 504 | void PageItem::moveBy(const double dX, const double dY, bool drawingOnly) |
3934 | cbradney | 505 | { |
506 | if (dX==0.0 && dY==0.0) |
||
507 | return; |
||
3903 | cbradney | 508 | if (dX!=0.0) |
509 | Xpos+=dX; |
||
510 | if (dY!=0.0) |
||
511 | Ypos+=dY; |
||
4644 | cbradney | 512 | if (drawingOnly || m_Doc->isLoading()) |
513 | return; |
||
4621 | cbradney | 514 | checkChanges(); |
3934 | cbradney | 515 | emit position(Xpos, Ypos); |
3903 | cbradney | 516 | } |
517 | |||
3934 | cbradney | 518 | void PageItem::setWidth(const double newWidth) |
519 | { |
||
520 | Width = newWidth; |
||
4621 | cbradney | 521 | checkChanges(); |
3934 | cbradney | 522 | emit widthAndHeight(Width, Height); |
523 | } |
||
524 | |||
525 | void PageItem::setHeight(const double newHeight) |
||
526 | { |
||
527 | Height = newHeight; |
||
4621 | cbradney | 528 | checkChanges(); |
3934 | cbradney | 529 | emit widthAndHeight(Width, Height); |
530 | } |
||
531 | |||
532 | void PageItem::setWidthHeight(const double newWidth, const double newHeight) |
||
533 | { |
||
534 | Width = newWidth; |
||
535 | Height = newHeight; |
||
4621 | cbradney | 536 | checkChanges(); |
3934 | cbradney | 537 | emit widthAndHeight(Width, Height); |
538 | } |
||
539 | |||
540 | void PageItem::resizeBy(const double dH, const double dW) |
||
541 | { |
||
542 | if (dH==0.0 && dW==0.0) |
||
543 | return; |
||
544 | if (dH!=0.0) |
||
545 | Width+=dH; |
||
546 | if (dW!=0.0) |
||
547 | Height+=dW; |
||
4621 | cbradney | 548 | checkChanges(); |
3934 | cbradney | 549 | emit widthAndHeight(Width, Height); |
550 | } |
||
551 | |||
4663 | cbradney | 552 | void PageItem::setRotation(const double newRotation, bool drawingOnly) |
3934 | cbradney | 553 | { |
554 | Rot=newRotation; |
||
4621 | cbradney | 555 | checkChanges(); |
4663 | cbradney | 556 | if (drawingOnly || m_Doc->isLoading()) |
557 | return; |
||
3946 | cbradney | 558 | emit rotation(Rot); |
3934 | cbradney | 559 | } |
560 | |||
561 | void PageItem::rotateBy(const double dR) |
||
562 | { |
||
563 | if (dR==0.0) |
||
564 | return; |
||
565 | Rot+=dR; |
||
4621 | cbradney | 566 | checkChanges(); |
3934 | cbradney | 567 | emit rotation(Rot); |
568 | } |
||
569 | |||
570 | void PageItem::setSelected(const bool toSelect) |
||
571 | { |
||
572 | Select=toSelect; |
||
573 | } |
||
574 | |||
3988 | cbradney | 575 | void PageItem::setImageXScale(const double newImageXScale) |
3985 | cbradney | 576 | { |
3988 | cbradney | 577 | LocalScX=newImageXScale; |
4821 | cbradney | 578 | checkChanges(); |
4960 | cbradney | 579 | emit imageOffsetScale(LocalScX, LocalScY, LocalX, LocalY); |
3985 | cbradney | 580 | } |
581 | |||
582 | void PageItem::setImageYScale(const double newImageYScale) |
||
583 | { |
||
584 | LocalScY=newImageYScale; |
||
4821 | cbradney | 585 | checkChanges(); |
4960 | cbradney | 586 | emit imageOffsetScale(LocalScX, LocalScY, LocalX, LocalY); |
3985 | cbradney | 587 | } |
588 | |||
589 | void PageItem::setImageXYScale(const double newImageXScale, const double newImageYScale) |
||
590 | { |
||
591 | LocalScX=newImageXScale; |
||
592 | LocalScY=newImageYScale; |
||
4821 | cbradney | 593 | checkChanges(); |
4960 | cbradney | 594 | emit imageOffsetScale(LocalScX, LocalScY, LocalX, LocalY); |
3985 | cbradney | 595 | } |
596 | |||
3988 | cbradney | 597 | void PageItem::setImageXOffset(const double newImageXOffset) |
3985 | cbradney | 598 | { |
3988 | cbradney | 599 | LocalX=newImageXOffset; |
4821 | cbradney | 600 | checkChanges(); |
3991 | cbradney | 601 | emit imageOffsetScale(LocalScX, LocalScY, LocalX, LocalY); |
3985 | cbradney | 602 | } |
603 | |||
604 | void PageItem::setImageYOffset(const double newImageYOffset) |
||
605 | { |
||
606 | LocalY=newImageYOffset; |
||
4821 | cbradney | 607 | checkChanges(); |
3991 | cbradney | 608 | emit imageOffsetScale(LocalScX, LocalScY, LocalX, LocalY); |
3985 | cbradney | 609 | } |
610 | |||
611 | void PageItem::setImageXYOffset(const double newImageXOffset, const double newImageYOffset) |
||
612 | { |
||
613 | LocalX=newImageXOffset; |
||
614 | LocalY=newImageYOffset; |
||
4821 | cbradney | 615 | checkChanges(); |
3991 | cbradney | 616 | emit imageOffsetScale(LocalScX, LocalScY, LocalX, LocalY); |
3985 | cbradney | 617 | } |
618 | |||
619 | void PageItem::moveImageXYOffsetBy(const double dX, const double dY) |
||
620 | { |
||
621 | if (dX==0.0 && dY==0.0) |
||
622 | return; |
||
623 | if (dX!=0.0) |
||
624 | LocalX+=dX; |
||
625 | if (dY!=0.0) |
||
626 | LocalY+=dY; |
||
4821 | cbradney | 627 | checkChanges(); |
3991 | cbradney | 628 | emit imageOffsetScale(LocalScX, LocalScY, LocalX, LocalY); |
3985 | cbradney | 629 | } |
630 | |||
3988 | cbradney | 631 | void PageItem::setReversed(bool newReversed) |
632 | { |
||
633 | Reverse=newReversed; |
||
634 | } |
||
3985 | cbradney | 635 | |
3988 | cbradney | 636 | void PageItem::setTextToFrameDistLeft(double newLeft) |
637 | { |
||
638 | Extra=newLeft; |
||
3991 | cbradney | 639 | emit textToFrameDistances(Extra, TExtra, BExtra, RExtra); |
3988 | cbradney | 640 | } |
3985 | cbradney | 641 | |
3988 | cbradney | 642 | void PageItem::setTextToFrameDistRight(double newRight) |
643 | { |
||
644 | RExtra=newRight; |
||
3991 | cbradney | 645 | emit textToFrameDistances(Extra, TExtra, BExtra, RExtra); |
3988 | cbradney | 646 | } |
3985 | cbradney | 647 | |
3988 | cbradney | 648 | void PageItem::setTextToFrameDistTop(double newTop) |
649 | { |
||
650 | TExtra=newTop; |
||
3991 | cbradney | 651 | emit textToFrameDistances(Extra, TExtra, BExtra, RExtra); |
3988 | cbradney | 652 | } |
3985 | cbradney | 653 | |
3988 | cbradney | 654 | void PageItem::setTextToFrameDistBottom(double newBottom) |
655 | { |
||
656 | BExtra=newBottom; |
||
3991 | cbradney | 657 | emit textToFrameDistances(Extra, TExtra, BExtra, RExtra); |
3988 | cbradney | 658 | } |
3985 | cbradney | 659 | |
3988 | cbradney | 660 | void PageItem::setTextToFrameDist(double newLeft, double newRight, double newTop, double newBottom) |
661 | { |
||
662 | Extra=newLeft; |
||
663 | RExtra=newRight; |
||
664 | TExtra=newTop; |
||
665 | BExtra=newBottom; |
||
3991 | cbradney | 666 | emit textToFrameDistances(Extra, TExtra, BExtra, RExtra); |
3988 | cbradney | 667 | } |
3985 | cbradney | 668 | |
3989 | cbradney | 669 | void PageItem::setCornerRadius(double newRadius) |
670 | { |
||
671 | RadRect=newRadius; |
||
672 | emit cornerRadius(RadRect); |
||
673 | } |
||
3985 | cbradney | 674 | |
3988 | cbradney | 675 | |
676 | |||
677 | |||
678 | |||
679 | |||
680 | |||
681 | |||
682 | |||
3 | paul | 683 | /** Zeichnet das Item */ |
68 | Franz | 684 | void PageItem::DrawObj(ScPainter *p, QRect e) |
3 | paul | 685 | { |
2434 | fschmid | 686 | double sc; |
4084 | cbradney | 687 | if (!m_Doc->DoDrawing) |
1740 | cbradney | 688 | { |
689 | Redrawn = true; |
||
690 | Tinput = false; |
||
691 | FrameOnly = false; |
||
692 | return; |
||
693 | } |
||
2434 | fschmid | 694 | DrawObj_Pre(p, sc); |
1736 | cbradney | 695 | switch(itemType()) |
696 | { |
||
697 | case TextFrame: |
||
3617 | cbradney | 698 | DrawObj_Item(p, e, sc); |
1736 | cbradney | 699 | break; |
3617 | cbradney | 700 | case ImageFrame: |
1736 | cbradney | 701 | case PathText: |
3617 | cbradney | 702 | DrawObj_Item(p, sc); |
1736 | cbradney | 703 | break; |
704 | default: |
||
3617 | cbradney | 705 | DrawObj_Item(p); |
1736 | cbradney | 706 | break; |
707 | } |
||
2434 | fschmid | 708 | DrawObj_Post(p); |
1736 | cbradney | 709 | } |
710 | |||
2434 | fschmid | 711 | void PageItem::DrawObj_Pre(ScPainter *p, double &sc) |
1740 | cbradney | 712 | { |
4320 | cbradney | 713 | ScribusView* view = m_Doc->view(); |
4593 | cbradney | 714 | sc = view->scale(); |
1741 | cbradney | 715 | p->save(); |
2434 | fschmid | 716 | if (!isEmbedded) |
717 | { |
||
718 | p->setZoomFactor(sc); |
||
719 | p->translate(Xpos*sc, Ypos*sc); |
||
2955 | fschmid | 720 | // p->rotate(Rot); |
721 | } |
||
2434 | fschmid | 722 | p->rotate(Rot); |
4580 | cbradney | 723 | p->setLineWidth(m_lineWidth); |
1741 | cbradney | 724 | if (GrType != 0) |
725 | { |
||
726 | p->setFillMode(ScPainter::Gradient); |
||
727 | p->fill_gradient = fill_gradient; |
||
728 | QWMatrix grm; |
||
729 | grm.rotate(Rot); |
||
730 | FPointArray gra; |
||
731 | switch (GrType) |
||
732 | { |
||
733 | case 1: |
||
734 | case 2: |
||
735 | case 3: |
||
736 | case 4: |
||
737 | case 6: |
||
738 | gra.setPoints(2, GrStartX, GrStartY, GrEndX, GrEndY); |
||
739 | gra.map(grm); |
||
740 | p->setGradient(VGradient::linear, gra.point(0), gra.point(1)); |
||
741 | break; |
||
742 | case 5: |
||
743 | case 7: |
||
744 | gra.setPoints(2, GrStartX, GrStartY, GrEndX, GrEndY); |
||
745 | p->setGradient(VGradient::radial, gra.point(0), gra.point(1), gra.point(0)); |
||
746 | break; |
||
747 | } |
||
748 | } |
||
749 | else |
||
750 | { |
||
751 | p->fill_gradient = VGradient(VGradient::linear); |
||
4546 | subik | 752 | if (fillColor() != CommonStrings::None) |
1741 | cbradney | 753 | { |
2984 | fschmid | 754 | p->setBrush(fillQColor); |
1741 | cbradney | 755 | p->setFillMode(ScPainter::Solid); |
756 | } |
||
757 | else |
||
758 | p->setFillMode(ScPainter::None); |
||
759 | } |
||
4546 | subik | 760 | if (lineColor() != CommonStrings::None) |
1741 | cbradney | 761 | { |
4580 | cbradney | 762 | if ((m_lineWidth == 0) && ! asLine()) |
1741 | cbradney | 763 | p->setLineWidth(0); |
764 | else |
||
765 | { |
||
4580 | cbradney | 766 | p->setPen(strokeQColor, m_lineWidth, PLineArt, PLineEnd, PLineJoin); |
1741 | cbradney | 767 | if (DashValues.count() != 0) |
768 | p->setDash(DashValues, DashOffset); |
||
769 | } |
||
770 | } |
||
771 | else |
||
772 | p->setLineWidth(0); |
||
773 | p->setBrushOpacity(1.0 - fillTransparency()); |
||
774 | p->setPenOpacity(1.0 - lineTransparency()); |
||
4477 | fschmid | 775 | p->setFillRule(fillRule); |
1740 | cbradney | 776 | } |
777 | |||
2434 | fschmid | 778 | void PageItem::DrawObj_Post(ScPainter *p) |
1740 | cbradney | 779 | { |
780 | bool doStroke=true; |
||
4320 | cbradney | 781 | ScribusView* view = m_Doc->view(); |
3113 | fschmid | 782 | if (itemType()==PathText || itemType()==PolyLine || itemType()==Line) |
1740 | cbradney | 783 | doStroke=false; |
4084 | cbradney | 784 | if ((doStroke) && (!m_Doc->RePos)) |
1740 | cbradney | 785 | { |
4546 | subik | 786 | if (lineColor() != CommonStrings::None) |
1740 | cbradney | 787 | { |
4580 | cbradney | 788 | p->setPen(strokeQColor, m_lineWidth, PLineArt, PLineEnd, PLineJoin); |
1740 | cbradney | 789 | if (DashValues.count() != 0) |
790 | p->setDash(DashValues, DashOffset); |
||
791 | } |
||
792 | else |
||
793 | p->setLineWidth(0); |
||
794 | if (!isTableItem) |
||
795 | { |
||
796 | p->setupPolygon(&PoLine); |
||
2877 | cbradney | 797 | if (NamedLStyle.isEmpty()) |
1740 | cbradney | 798 | p->strokePath(); |
799 | else |
||
800 | { |
||
4084 | cbradney | 801 | multiLine ml = m_Doc->MLineStyles[NamedLStyle]; |
1740 | cbradney | 802 | QColor tmp; |
803 | for (int it = ml.size()-1; it > -1; it--) |
||
804 | { |
||
805 | SetFarbe(&tmp, ml[it].Color, ml[it].Shade); |
||
806 | p->setPen(tmp, ml[it].Width, |
||
807 | static_cast<PenStyle>(ml[it].Dash), |
||
808 | static_cast<PenCapStyle>(ml[it].LineEnd), |
||
809 | static_cast<PenJoinStyle>(ml[it].LineJoin)); |
||
810 | p->strokePath(); |
||
811 | } |
||
812 | } |
||
813 | } |
||
814 | } |
||
4084 | cbradney | 815 | if ((!isEmbedded) && (!m_Doc->RePos)) |
2434 | fschmid | 816 | { |
4593 | cbradney | 817 | double scpInv = 1.0 / (QMAX(view->scale(), 1)); |
4084 | cbradney | 818 | if ((Frame) && (m_Doc->guidesSettings.framesShown) && ((itemType() == ImageFrame) || (itemType() == TextFrame) || (itemType() == PathText))) |
1740 | cbradney | 819 | { |
1742 | cbradney | 820 | p->setPen(black, scpInv, DotLine, FlatCap, MiterJoin); |
4084 | cbradney | 821 | if ((isBookmark) || (m_isAnnotation)) |
1740 | cbradney | 822 | p->setPen(blue, scpInv, DotLine, FlatCap, MiterJoin); |
823 | if ((BackBox != 0) || (NextBox != 0)) |
||
824 | p->setPen(red, scpInv, SolidLine, FlatCap, MiterJoin); |
||
4695 | cbradney | 825 | if (m_Locked) |
1740 | cbradney | 826 | p->setPen(darkRed, scpInv, SolidLine, FlatCap, MiterJoin); |
2707 | subik | 827 | |
1740 | cbradney | 828 | p->setFillMode(0); |
3919 | fschmid | 829 | if (itemType()==PathText) |
830 | { |
||
831 | if (Clip.count() != 0) |
||
832 | { |
||
833 | FPointArray tclip; |
||
834 | FPoint np = FPoint(Clip.point(0)); |
||
835 | tclip.resize(2); |
||
836 | tclip.setPoint(0, np); |
||
837 | tclip.setPoint(1, np); |
||
838 | for (uint a = 1; a < Clip.size(); ++a) |
||
839 | { |
||
840 | np = FPoint(Clip.point(a)); |
||
841 | tclip.putPoints(tclip.size(), 4, np.x(), np.y(), np.x(), np.y(), np.x(), np.y(), np.x(), np.y()); |
||
842 | } |
||
843 | np = FPoint(Clip.point(0)); |
||
844 | tclip.putPoints(tclip.size(), 2, np.x(), np.y(), np.x(), np.y()); |
||
845 | p->setupPolygon(&tclip); |
||
846 | } |
||
847 | } |
||
848 | else |
||
849 | p->setupPolygon(&PoLine); |
||
1740 | cbradney | 850 | p->strokePath(); |
851 | } |
||
4084 | cbradney | 852 | if ((m_Doc->guidesSettings.framesShown) && textFlowUsesContourLine() && (ContourLine.size() != 0)) |
1740 | cbradney | 853 | { |
854 | p->setPen(lightGray, scpInv, DotLine, FlatCap, MiterJoin); |
||
855 | p->setupPolygon(&ContourLine); |
||
856 | p->strokePath(); |
||
857 | } |
||
4145 | cbradney | 858 | //CB disabled for now |
4847 | cbradney | 859 | //if (m_Doc->m_Selection->findItem(this)!=-1) |
4145 | cbradney | 860 | // drawLockedMarker(p); |
2434 | fschmid | 861 | } |
862 | Tinput = false; |
||
863 | FrameOnly = false; |
||
864 | p->restore(); |
||
1740 | cbradney | 865 | } |
866 | |||
2434 | fschmid | 867 | void PageItem::DrawObj_Embedded(ScPainter *p, QRect e, struct ZZ *hl) |
868 | { |
||
2955 | fschmid | 869 | QPtrList<PageItem> emG; |
870 | emG.clear(); |
||
2434 | fschmid | 871 | if (hl->embedded != 0) |
872 | { |
||
4084 | cbradney | 873 | if (!m_Doc->DoDrawing) |
2453 | fschmid | 874 | { |
875 | hl->embedded->Redrawn = true; |
||
876 | hl->embedded->Tinput = false; |
||
877 | hl->embedded->FrameOnly = false; |
||
878 | return; |
||
879 | } |
||
2955 | fschmid | 880 | emG.append(hl->embedded); |
881 | if (hl->embedded->Groups.count() != 0) |
||
2443 | fschmid | 882 | { |
4084 | cbradney | 883 | for (uint ga=0; ga<m_Doc->FrameItems.count(); ++ga) |
2955 | fschmid | 884 | { |
4084 | cbradney | 885 | if (m_Doc->FrameItems.at(ga)->Groups.count() != 0) |
2955 | fschmid | 886 | { |
4084 | cbradney | 887 | if (m_Doc->FrameItems.at(ga)->Groups.top() == hl->embedded->Groups.top()) |
2955 | fschmid | 888 | { |
4084 | cbradney | 889 | if (m_Doc->FrameItems.at(ga)->ItemNr != hl->embedded->ItemNr) |
2955 | fschmid | 890 | { |
4084 | cbradney | 891 | if (emG.find(m_Doc->FrameItems.at(ga)) == -1) |
892 | emG.append(m_Doc->FrameItems.at(ga)); |
||
2955 | fschmid | 893 | } |
894 | } |
||
895 | } |
||
896 | } |
||
2443 | fschmid | 897 | } |
2955 | fschmid | 898 | for (uint em = 0; em < emG.count(); ++em) |
2451 | fschmid | 899 | { |
2955 | fschmid | 900 | PageItem* embedded = emG.at(em); |
901 | struct ParagraphStyle vg; |
||
902 | QValueList<ParagraphStyle> savedParagraphStyles; |
||
903 | for (int xxx=0; xxx<5; ++xxx) |
||
904 | { |
||
5184 | avox | 905 | vg.setLineSpacingMode(static_cast<ParagraphStyle::LineSpacingMode>(m_Doc->docParagraphStyles[xxx].lineSpacingMode())); |
906 | vg.setUseBaselineGrid(m_Doc->docParagraphStyles[xxx].useBaselineGrid()); |
||
907 | vg.setLineSpacing(m_Doc->docParagraphStyles[xxx].lineSpacing()); |
||
908 | vg.charStyle().csize = m_Doc->docParagraphStyles[xxx].charStyle().fontSize(); |
||
909 | vg.setLeftMargin(m_Doc->docParagraphStyles[xxx].leftMargin()); |
||
910 | vg.setFirstIndent(m_Doc->docParagraphStyles[xxx].firstIndent()); |
||
911 | vg.setGapBefore(m_Doc->docParagraphStyles[xxx].gapBefore()); |
||
912 | vg.setGapAfter(m_Doc->docParagraphStyles[xxx].gapAfter()); |
||
2955 | fschmid | 913 | savedParagraphStyles.append(vg); |
914 | } |
||
915 | p->save(); |
||
916 | embedded->Xpos = Xpos + hl->xco + embedded->gXpos; |
||
917 | embedded->Ypos = Ypos + (hl->yco - (embedded->gHeight * (hl->scalev / 1000.0))) + embedded->gYpos; |
||
918 | p->translate((hl->xco + embedded->gXpos * (hl->scale / 1000.0)) * p->zoomFactor(), (hl->yco - (embedded->gHeight * (hl->scalev / 1000.0)) + embedded->gYpos * (hl->scalev / 1000.0)) * p->zoomFactor()); |
||
919 | if (hl->base != 0) |
||
920 | { |
||
921 | p->translate(0, -embedded->gHeight * (hl->base / 1000.0) * p->zoomFactor()); |
||
922 | embedded->Ypos -= embedded->gHeight * (hl->base / 1000.0); |
||
923 | } |
||
924 | p->scale(hl->scale / 1000.0, hl->scalev / 1000.0); |
||
925 | embedded->Dirty = Dirty; |
||
926 | double sc; |
||
4580 | cbradney | 927 | double pws = embedded->m_lineWidth; |
2955 | fschmid | 928 | embedded->DrawObj_Pre(p, sc); |
929 | switch(embedded->itemType()) |
||
930 | { |
||
931 | case ImageFrame: |
||
3617 | cbradney | 932 | embedded->DrawObj_Item(p, sc); |
2955 | fschmid | 933 | break; |
934 | case TextFrame: |
||
3617 | cbradney | 935 | embedded->DrawObj_Item(p, e, sc); |
2955 | fschmid | 936 | break; |
937 | case Line: |
||
4580 | cbradney | 938 | embedded->m_lineWidth = pws * QMIN(hl->scale / 1000.0, hl->scalev / 1000.0); |
3617 | cbradney | 939 | embedded->DrawObj_Item(p); |
2955 | fschmid | 940 | break; |
941 | case Polygon: |
||
3617 | cbradney | 942 | embedded->DrawObj_Item(p); |
2955 | fschmid | 943 | break; |
944 | case PolyLine: |
||
4580 | cbradney | 945 | embedded->m_lineWidth = pws * QMIN(hl->scale / 1000.0, hl->scalev / 1000.0); |
3617 | cbradney | 946 | embedded->DrawObj_Item(p); |
2955 | fschmid | 947 | break; |
948 | case PathText: |
||
3617 | cbradney | 949 | embedded->DrawObj_Item(p, sc); |
2955 | fschmid | 950 | break; |
951 | default: |
||
952 | break; |
||
953 | } |
||
4580 | cbradney | 954 | embedded->m_lineWidth = pws * QMIN(hl->scale / 1000.0, hl->scalev / 1000.0); |
2955 | fschmid | 955 | embedded->DrawObj_Post(p); |
956 | p->restore(); |
||
4580 | cbradney | 957 | embedded->m_lineWidth = pws; |
2955 | fschmid | 958 | for (int xxx=0; xxx<5; ++xxx) |
959 | { |
||
5184 | avox | 960 | m_Doc->docParagraphStyles[xxx].setLineSpacingMode(static_cast<ParagraphStyle::LineSpacingMode>(savedParagraphStyles[xxx].lineSpacingMode())); |
961 | m_Doc->docParagraphStyles[xxx].setUseBaselineGrid(savedParagraphStyles[xxx].useBaselineGrid()); |
||
962 | m_Doc->docParagraphStyles[xxx].setLineSpacing(savedParagraphStyles[xxx].lineSpacing()); |
||
963 | m_Doc->docParagraphStyles[xxx].charStyle().csize = savedParagraphStyles[xxx].charStyle().fontSize(); |
||
964 | m_Doc->docParagraphStyles[xxx].setLeftMargin(savedParagraphStyles[xxx].leftMargin()); |
||
965 | m_Doc->docParagraphStyles[xxx].setFirstIndent(savedParagraphStyles[xxx].firstIndent()); |
||
966 | m_Doc->docParagraphStyles[xxx].setGapBefore(savedParagraphStyles[xxx].gapBefore()); |
||
967 | m_Doc->docParagraphStyles[xxx].setGapAfter(savedParagraphStyles[xxx].gapAfter()); |
||
2955 | fschmid | 968 | } |
969 | savedParagraphStyles.clear(); |
||
2451 | fschmid | 970 | } |
2434 | fschmid | 971 | } |
972 | } |
||
973 | |||
68 | Franz | 974 | void PageItem::paintObj(QRect e, QPixmap *ppX) |
975 | { |
||
4084 | cbradney | 976 | if (!m_Doc->DoDrawing) |
167 | Franz | 977 | { |
68 | Franz | 978 | Redrawn = true; |
979 | Tinput = false; |
||
980 | FrameOnly = false; |
||
981 | return; |
||
167 | Franz | 982 | } |
1795 | cbradney | 983 | //qDebug("paintObj(QRect e, QPixmap *ppX)"); |
1740 | cbradney | 984 | QPainter p; |
4320 | cbradney | 985 | ScribusView* view = m_Doc->view(); |
4593 | cbradney | 986 | double sc = view->scale(); |
68 | Franz | 987 | if (toPixmap) |
988 | p.begin(ppX); |
||
989 | else |
||
4320 | cbradney | 990 | p.begin(view->viewport()); |
4084 | cbradney | 991 | if ((!toPixmap) && (!m_Doc->RePos)) |
167 | Franz | 992 | { |
68 | Franz | 993 | if (!e.isEmpty()) |
994 | p.setClipRect(e); |
||
995 | else |
||
456 | fschmid | 996 | { |
4320 | cbradney | 997 | int x = view->contentsX(); |
998 | int y = view->contentsY(); |
||
999 | QPoint out = view->contentsToViewport(QPoint(x,y)); |
||
1000 | p.setClipRect(QRect(out.x(), out.y(), view->visibleWidth(), view->visibleWidth())); |
||
456 | fschmid | 1001 | } |
167 | Franz | 1002 | } |
4084 | cbradney | 1003 | QPoint in = QPoint(qRound((Xpos-m_Doc->minCanvasCoordinate.x())*sc), qRound((Ypos-m_Doc->minCanvasCoordinate.y())*sc)); |
4320 | cbradney | 1004 | QPoint out = view->contentsToViewport(in); |
456 | fschmid | 1005 | p.translate(out.x(), out.y()); |
1006 | p.scale(sc, sc); |
||
1007 | p.rotate(Rot); |
||
3 | paul | 1008 | if (Sizing) |
167 | Franz | 1009 | { |
3 | paul | 1010 | p.setRasterOp(XorROP); |
1011 | p.setBrush(NoBrush); |
||
1012 | p.setPen(QPen(white, 1, DotLine, FlatCap, MiterJoin)); |
||
1013 | p.drawRect(0, 0, static_cast<int>(OldB), static_cast<int>(OldH)); |
||
1014 | p.drawRect(0, 0, static_cast<int>(Width), static_cast<int>(Height)); |
||
1015 | OldB = Width; |
||
1016 | OldH = Height; |
||
167 | Franz | 1017 | } |
4084 | cbradney | 1018 | if ((!Tinput) && (!m_Doc->RePos)) |
167 | Franz | 1019 | { |
3 | paul | 1020 | if (Select) // && (!Doc->EditClip)) |
167 | Franz | 1021 | { |
4847 | cbradney | 1022 | if (!m_Doc->m_Selection->isEmpty()) |
3 | paul | 1023 | { |
167 | Franz | 1024 | if (Groups.count() == 0) |
3 | paul | 1025 | { |
1026 | QPainter pr; |
||
4320 | cbradney | 1027 | pr.begin(view->viewport()); |
456 | fschmid | 1028 | pr.translate(out.x(), out.y()); |
1029 | pr.rotate(Rot); |
||
4695 | cbradney | 1030 | if (m_Locked) |
3 | paul | 1031 | pr.setPen(QPen(darkRed, 1, SolidLine, FlatCap, MiterJoin)); |
1032 | else |
||
1033 | pr.setPen(QPen(red, 1, DotLine, FlatCap, MiterJoin)); |
||
1034 | pr.setBrush(NoBrush); |
||
4806 | fschmid | 1035 | int lw2 = 1; |
1036 | int lw = 1; |
||
1037 | PenCapStyle le = FlatCap; |
||
1038 | if (NamedLStyle.isEmpty()) |
||
1039 | { |
||
1040 | lw2 = qRound(m_lineWidth * sc / 2.0); |
||
1041 | lw = qRound(QMAX(m_lineWidth * sc, 1.0)); |
||
1042 | le = PLineEnd; |
||
1043 | } |
||
1044 | else |
||
1045 | { |
||
1046 | multiLine ml = m_Doc->MLineStyles[NamedLStyle]; |
||
1047 | lw2 = qRound(ml[ml.size()-1].Width * sc / 2.0); |
||
1048 | lw = qRound(QMAX(ml[ml.size()-1].Width * sc, 1.0)); |
||
1049 | le = static_cast<PenCapStyle>(ml[ml.size()-1].LineEnd); |
||
1050 | } |
||
1051 | if (asLine()) |
||
1052 | { |
||
1053 | if (le != FlatCap) |
||
1054 | pr.drawRect(-lw2, -lw2, qRound(Width*sc)+lw, lw); |
||
1055 | else |
||
1056 | pr.drawRect(-1, -lw2, qRound(Width*sc), lw); |
||
1057 | } |
||
1058 | else |
||
1059 | pr.drawRect(-1, -1, qRound(Width*sc)+2, qRound(Height*sc)+2); |
||
266 | Franz | 1060 | pr.setPen(QPen(red, 1, SolidLine, FlatCap, MiterJoin)); |
1061 | pr.setBrush(red); |
||
4695 | cbradney | 1062 | if ((!m_Locked) && (!m_SizeLocked)) |
167 | Franz | 1063 | { |
3625 | avox | 1064 | if (! asLine()) |
167 | Franz | 1065 | { |
266 | Franz | 1066 | pr.drawRect(-1, -1, 6, 6); |
4806 | fschmid | 1067 | pr.drawRect(qRound(Width*sc), qRound(Height*sc), -6, -6); |
1068 | pr.drawRect(qRound(Width*sc), -1, -6, 6); |
||
1069 | pr.drawRect(-1, qRound(Height*sc), 6, -6); |
||
266 | Franz | 1070 | if (Width > 6) |
1071 | { |
||
4806 | fschmid | 1072 | pr.drawRect(qRound(Width/2*sc - 3), qRound(Height*sc), 6, -6); |
1073 | pr.drawRect(qRound(Width/2*sc - 3), -1, 6, 6); |
||
266 | Franz | 1074 | } |
1075 | if (Height > 6) |
||
1076 | { |
||
4806 | fschmid | 1077 | pr.drawRect(qRound(Width*sc), qRound(Height/2*sc - 3), -6, 6); |
1078 | pr.drawRect(-1, qRound(Height/2*sc - 3), 6, 6); |
||
266 | Franz | 1079 | } |
167 | Franz | 1080 | } |
266 | Franz | 1081 | else |
167 | Franz | 1082 | { |
266 | Franz | 1083 | pr.drawRect(-3, -3, 6, 6); |
4806 | fschmid | 1084 | pr.drawRect(qRound(Width*sc)+3, -3, -6, 6); |
3 | paul | 1085 | } |
167 | Franz | 1086 | } |
3 | paul | 1087 | pr.end(); |
167 | Franz | 1088 | } |
3 | paul | 1089 | else |
167 | Franz | 1090 | { |
3 | paul | 1091 | p.setPen(QPen(darkCyan, 1, DotLine, FlatCap, MiterJoin)); |
1092 | p.setBrush(NoBrush); |
||
24 | Franz | 1093 | p.drawRect(-1, -1, static_cast<int>(Width+2), static_cast<int>(Height+2)); |
4847 | cbradney | 1094 | if (m_Doc->m_Selection->count() == 1) |
227 | Franz | 1095 | { |
1096 | QPainter pr; |
||
4320 | cbradney | 1097 | pr.begin(view->viewport()); |
456 | fschmid | 1098 | pr.translate(out.x(), out.y()); |
1099 | pr.rotate(Rot); |
||
227 | Franz | 1100 | pr.setPen(QPen(darkCyan, 1, SolidLine, FlatCap, MiterJoin)); |
1101 | pr.setBrush(darkCyan); |
||
1102 | pr.drawRect(-1, -1, 6, 6); |
||
456 | fschmid | 1103 | pr.drawRect(static_cast<int>(Width*sc), static_cast<int>(Height*sc), -6, -6); |
1104 | pr.drawRect(static_cast<int>(Width*sc), -1, -6, 6); |
||
1105 | pr.drawRect(-1, static_cast<int>(Height*sc), 6, -6); |
||
227 | Franz | 1106 | if (Width > 6) |
1107 | { |
||
456 | fschmid | 1108 | pr.drawRect(static_cast<int>(Width/2*sc - 3), static_cast<int>(Height*sc), 6, -6); |
1109 | pr.drawRect(static_cast<int>(Width/2*sc - 3), -1, 6, 6); |
||
227 | Franz | 1110 | } |
1111 | if (Height > 6) |
||
1112 | { |
||
456 | fschmid | 1113 | pr.drawRect(static_cast<int>(Width*sc), static_cast<int>(Height/2*sc - 3), -6, 6); |
1114 | pr.drawRect(-1, static_cast<int>(Height/2*sc - 3), 6, 6); |
||
227 | Franz | 1115 | } |
1116 | pr.end(); |
||
1117 | } |
||
3 | paul | 1118 | } |
1119 | } |
||
1120 | } |
||
4847 | cbradney | 1121 | //if (m_Doc->m_Selection->findItem(this)!=-1) |
4145 | cbradney | 1122 | // drawLockedMarker(p); |
167 | Franz | 1123 | } |
3 | paul | 1124 | Tinput = false; |
1125 | FrameOnly = false; |
||
1126 | p.end(); |
||
1286 | tsoots | 1127 | // checkChanges(); // Check changes for undo actions |
3 | paul | 1128 | } |
1129 | |||
1130 | QString PageItem::ExpandToken(uint base) |
||
1131 | { |
||
1132 | uint zae = 0; |
||
362 | Franz | 1133 | uint za2 = base; |
3617 | cbradney | 1134 | QString chx("#"); |
4084 | cbradney | 1135 | if ((!m_Doc->masterPageMode()) && (OwnPage != -1)) |
167 | Franz | 1136 | { |
362 | Franz | 1137 | do |
3 | paul | 1138 | { |
362 | Franz | 1139 | if (za2 == 0) |
1140 | break; |
||
1141 | za2--; |
||
1142 | } |
||
5184 | avox | 1143 | while (itemText.text(za2) == QChar(30)); |
1144 | if (itemText.text(za2) != QChar(30)) |
||
362 | Franz | 1145 | za2++; |
5184 | avox | 1146 | while (itemText.text(za2+zae) == QChar(30)) |
362 | Franz | 1147 | { |
3 | paul | 1148 | zae++; |
5184 | avox | 1149 | if (za2+zae == itemText.length()) |
3 | paul | 1150 | break; |
167 | Franz | 1151 | } |
3617 | cbradney | 1152 | QString out("%1"); |
362 | Franz | 1153 | QString out2; |
3757 | cbradney | 1154 | //CB Section numbering |
1155 | //out2 = out.arg(OwnPage+Doc->FirstPnum, -zae); |
||
4084 | cbradney | 1156 | out2=out.arg(m_Doc->getSectionPageNumberForPageIndex(OwnPage), -zae); |
3761 | cbradney | 1157 | //out2=out.arg(out2, -zae); |
362 | Franz | 1158 | chx = out2.mid(base-za2, 1); |
167 | Franz | 1159 | } |
3 | paul | 1160 | return chx; |
1161 | } |
||
1162 | |||
1163 | void PageItem::SetFarbe(QColor *tmp, QString farbe, int shad) |
||
1164 | { |
||
4084 | cbradney | 1165 | *tmp = m_Doc->PageColors[farbe].getShadeColorProof(shad); |
3 | paul | 1166 | } |
1167 | |||
4689 | mrdocs | 1168 | double PageItem::SetZeichAttr(ScText *hl, int *chs, QString *chx) |
3 | paul | 1169 | { |
157 | Franz | 1170 | double retval = 0.0; |
1789 | fschmid | 1171 | double asce = hl->cfont->numAscent * (hl->csize / 10.0); |
2185 | fschmid | 1172 | int chst = hl->cstyle & 1919; |
3 | paul | 1173 | if (chst != 0) |
167 | Franz | 1174 | { |
1175 | if (chst & 1) |
||
3 | paul | 1176 | { |
4084 | cbradney | 1177 | retval -= asce * m_Doc->typographicSettings.valueSuperScript / 100; |
1178 | *chs = QMAX(static_cast<int>(hl->csize * m_Doc->typographicSettings.scalingSuperScript / 100), 1); |
||
167 | Franz | 1179 | } |
3 | paul | 1180 | if (chst & 2) |
167 | Franz | 1181 | { |
4084 | cbradney | 1182 | retval += asce * m_Doc->typographicSettings.valueSubScript / 100; |
1183 | *chs = QMAX(static_cast<int>(hl->csize * m_Doc->typographicSettings.scalingSubScript / 100), 1); |
||
167 | Franz | 1184 | } |
2185 | fschmid | 1185 | if (chst & 32) |
1186 | { |
||
1187 | if (chx->upper() != *chx) |
||
1188 | *chx = chx->upper(); |
||
1189 | } |
||
3 | paul | 1190 | if (chst & 64) |
167 | Franz | 1191 | { |
1192 | if (chx->upper() != *chx) |
||
3 | paul | 1193 | { |
4084 | cbradney | 1194 | *chs = QMAX(static_cast<int>(hl->csize * m_Doc->typographicSettings.valueSmallCaps / 100), 1); |
3 | paul | 1195 | *chx = chx->upper(); |
1196 | } |
||
1197 | } |
||
167 | Franz | 1198 | } |
157 | Franz | 1199 | return retval; |
3 | paul | 1200 | } |
1201 | |||
68 | Franz | 1202 | void PageItem::DrawZeichenS(ScPainter *p, struct ZZ *hl) |
3 | paul | 1203 | { |
2353 | fschmid | 1204 | double csi = static_cast<double>(hl->Siz) / 100.0; |
55 | Franz | 1205 | QString ccx = hl->Zeich; |
4084 | cbradney | 1206 | if ((m_Doc->guidesSettings.showControls) && ((ccx == QChar(9)) || (ccx == QChar(29)) || ((ccx == QChar(26)) && (Cols > 1))|| (ccx == QChar(27)) || (ccx == QChar(32)))) |
2353 | fschmid | 1207 | { |
2389 | fschmid | 1208 | QWMatrix chma, chma2, chma4, chma5; |
2353 | fschmid | 1209 | FPointArray points; |
1210 | if (ccx == QChar(9)) |
||
2389 | fschmid | 1211 | { |
4084 | cbradney | 1212 | points = m_Doc->symTab.copy(); |
2389 | fschmid | 1213 | chma4.translate(hl->xco-((hl->Siz / 100.0) * 7.0), hl->yco-((hl->Siz / 10.0) * 0.5)); |
1214 | } |
||
1215 | else if (ccx == QChar(26)) |
||
1216 | { |
||
4084 | cbradney | 1217 | points = m_Doc->symNewCol.copy(); |
2389 | fschmid | 1218 | chma4.translate(hl->xco, hl->yco-((hl->Siz / 10.0) * 0.6)); |
1219 | } |
||
1220 | else if (ccx == QChar(27)) |
||
1221 | { |
||
4084 | cbradney | 1222 | points = m_Doc->symNewFrame.copy(); |
2389 | fschmid | 1223 | chma4.translate(hl->xco, hl->yco-((hl->Siz / 10.0) * 0.6)); |
1224 | } |
||
2353 | fschmid | 1225 | else |
2389 | fschmid | 1226 | { |
4084 | cbradney | 1227 | points = m_Doc->symNonBreak.copy(); |
2389 | fschmid | 1228 | chma4.translate(hl->xco, hl->yco-((hl->Siz / 10.0) * 0.4)); |
1229 | } |
||
2353 | fschmid | 1230 | chma.scale(csi, csi); |
1231 | chma2.scale(hl->scale / 1000.0, hl->scalev / 1000.0); |
||
1232 | chma5.scale(p->zoomFactor(), p->zoomFactor()); |
||
2359 | fschmid | 1233 | points.map(chma * chma2 * chma4 * chma5); |
2353 | fschmid | 1234 | p->setupTextPolygon(&points); |
2359 | fschmid | 1235 | if (ccx == QChar(32)) |
1236 | { |
||
1237 | QColor tmp = p->pen(); |
||
1238 | p->setPen(p->brush(), 1, SolidLine, FlatCap, MiterJoin); |
||
1239 | p->setLineWidth(hl->Siz / 200.0); |
||
1240 | p->strokePath(); |
||
1241 | p->setPen(tmp, 1, SolidLine, FlatCap, MiterJoin); |
||
1242 | } |
||
1243 | else |
||
1244 | { |
||
1245 | p->setFillMode(1); |
||
1246 | p->fillPath(); |
||
1247 | } |
||
2353 | fschmid | 1248 | } |
2384 | fschmid | 1249 | if ((ccx == QChar(13)) || (ccx == QChar(9)) || (ccx == QChar(28)) || (ccx == QChar(27)) || (ccx == QChar(26))) |
167 | Franz | 1250 | return; |
55 | Franz | 1251 | if (ccx == QChar(29)) |
1252 | ccx = " "; |
||
2407 | fschmid | 1253 | if (ccx == QChar(24)) |
1254 | ccx = "-"; |
||
55 | Franz | 1255 | uint chr = ccx[0].unicode(); |
1789 | fschmid | 1256 | if (hl->ZFo->CharWidth.contains(chr)) |
167 | Franz | 1257 | { |
1998 | fschmid | 1258 | QWMatrix chma, chma2, chma3, chma4, chma5, chma6; |
68 | Franz | 1259 | chma.scale(csi, csi); |
638 | fschmid | 1260 | chma5.scale(p->zoomFactor(), p->zoomFactor()); |
1789 | fschmid | 1261 | FPointArray gly = hl->ZFo->GlyphArray[chr].Outlines.copy(); |
87 | Franz | 1262 | if (gly.size() > 3) |
167 | Franz | 1263 | { |
2242 | fschmid | 1264 | chma2.scale(hl->scale / 1000.0, hl->scalev / 1000.0); |
68 | Franz | 1265 | if (Reverse) |
167 | Franz | 1266 | { |
638 | fschmid | 1267 | chma3.scale(-1, 1); |
1268 | chma3.translate(-hl->wide, 0); |
||
2242 | fschmid | 1269 | chma4.translate(hl->xco, hl->yco-((hl->Siz / 10.0) * (hl->scalev / 1000.0))); |
167 | Franz | 1270 | } |
68 | Franz | 1271 | else |
2242 | fschmid | 1272 | chma4.translate(hl->xco, hl->yco-((hl->Siz / 10.0) * (hl->scalev / 1000.0))); |
2234 | fschmid | 1273 | if (hl->base != 0) |
2242 | fschmid | 1274 | chma6.translate(0, -(hl->Siz / 10.0) * (hl->base / 1000.0) * p->zoomFactor()); |
2234 | fschmid | 1275 | gly.map(chma * chma2 * chma3 * chma4 * chma5 * chma6); |
87 | Franz | 1276 | p->setFillMode(1); |
1888 | fschmid | 1277 | bool fr = p->fillRule(); |
1278 | p->setFillRule(false); |
||
638 | fschmid | 1279 | p->setupTextPolygon(&gly); |
2257 | fschmid | 1280 | if ((hl->ZFo->isStroked) && ((hl->Siz * hl->outline / 10000.0) != 0)) |
167 | Franz | 1281 | { |
220 | Franz | 1282 | QColor tmp = p->brush(); |
1283 | p->setPen(tmp, 1, SolidLine, FlatCap, MiterJoin); |
||
2257 | fschmid | 1284 | p->setLineWidth(hl->Siz * hl->outline / 10000.0); |
68 | Franz | 1285 | p->strokePath(); |
3 | paul | 1286 | } |
220 | Franz | 1287 | else |
1288 | { |
||
4546 | subik | 1289 | if ((hl->Style & 256) && (hl->Farb2 != CommonStrings::None)) |
2229 | fschmid | 1290 | { |
2261 | fschmid | 1291 | p->save(); |
1292 | p->translate((hl->Siz * hl->shadowX / 10000.0) * p->zoomFactor(), -(hl->Siz * hl->shadowY / 10000.0) * p->zoomFactor()); |
||
1293 | QColor tmp = p->brush(); |
||
1294 | p->setBrush(p->pen()); |
||
3674 | fschmid | 1295 | #ifdef HAVE_CAIRO |
1296 | p->setupTextPolygon(&gly); |
||
1297 | #endif |
||
220 | Franz | 1298 | p->fillPath(); |
2261 | fschmid | 1299 | p->setBrush(tmp); |
1300 | p->restore(); |
||
3674 | fschmid | 1301 | #ifdef HAVE_CAIRO |
1302 | p->setupTextPolygon(&gly); |
||
1303 | #endif |
||
2229 | fschmid | 1304 | } |
4546 | subik | 1305 | if (hl->Farb != CommonStrings::None) |
2261 | fschmid | 1306 | p->fillPath(); |
4546 | subik | 1307 | if ((hl->Style & 4) && (hl->Farb2 != CommonStrings::None) && ((hl->Siz * hl->outline / 10000.0) != 0)) |
220 | Franz | 1308 | { |
2257 | fschmid | 1309 | p->setLineWidth(hl->Siz * hl->outline / 10000.0); |
220 | Franz | 1310 | p->strokePath(); |
1311 | } |
||
1312 | } |
||
1888 | fschmid | 1313 | p->setFillRule(fr); |
167 | Franz | 1314 | } |
68 | Franz | 1315 | if (hl->Style & 16) |
167 | Franz | 1316 | { |
2176 | fschmid | 1317 | double st, lw; |
2272 | fschmid | 1318 | if ((hl->strikepos != -1) || (hl->strikewidth != -1)) |
2176 | fschmid | 1319 | { |
2272 | fschmid | 1320 | if (hl->strikepos != -1) |
1321 | st = (hl->strikepos / 1000.0) * (hl->ZFo->numAscent * (hl->realSiz / 10.0)); |
||
2176 | fschmid | 1322 | else |
2185 | fschmid | 1323 | st = hl->ZFo->strikeout_pos * (hl->realSiz / 10.0); |
2272 | fschmid | 1324 | if (hl->strikewidth != -1) |
1325 | lw = (hl->strikewidth / 1000.0) * (hl->realSiz / 10.0); |
||
2176 | fschmid | 1326 | else |
2185 | fschmid | 1327 | lw = QMAX(hl->ZFo->strokeWidth * (hl->realSiz / 10.0), 1); |
2176 | fschmid | 1328 | } |
1329 | else |
||
1330 | { |
||
2185 | fschmid | 1331 | st = hl->ZFo->strikeout_pos * (hl->realSiz / 10.0); |
1332 | lw = QMAX(hl->ZFo->strokeWidth * (hl->realSiz / 10.0), 1); |
||
2176 | fschmid | 1333 | } |
2234 | fschmid | 1334 | if (hl->base != 0) |
2242 | fschmid | 1335 | st += (hl->Siz / 10.0) * (hl->base / 1000.0); |
68 | Franz | 1336 | p->setPen(p->brush()); |
2176 | fschmid | 1337 | p->setLineWidth(lw); |
68 | Franz | 1338 | p->drawLine(FPoint(hl->xco-hl->kern, hl->yco-st), FPoint(hl->xco+hl->wide, hl->yco-st)); |
167 | Franz | 1339 | } |
2188 | fschmid | 1340 | if ((hl->Style & 8) || ((hl->Style & 512) && (!ccx[0].isSpace()))) |
167 | Franz | 1341 | { |
2174 | fschmid | 1342 | double st, lw; |
2262 | fschmid | 1343 | if ((hl->underpos != -1) || (hl->underwidth != -1)) |
2174 | fschmid | 1344 | { |
2262 | fschmid | 1345 | if (hl->underpos != -1) |
1346 | st = (hl->underpos / 1000.0) * (hl->ZFo->numDescender * (hl->realSiz / 10.0)); |
||
2174 | fschmid | 1347 | else |
2185 | fschmid | 1348 | st = hl->ZFo->underline_pos * (hl->realSiz / 10.0); |
2262 | fschmid | 1349 | if (hl->underwidth != -1) |
1350 | lw = (hl->underwidth / 1000.0) * (hl->realSiz / 10.0); |
||
2174 | fschmid | 1351 | else |
2185 | fschmid | 1352 | lw = QMAX(hl->ZFo->strokeWidth * (hl->realSiz / 10.0), 1); |
2174 | fschmid | 1353 | } |
1354 | else |
||
1355 | { |
||
2185 | fschmid | 1356 | st = hl->ZFo->underline_pos * (hl->realSiz / 10.0); |
1357 | lw = QMAX(hl->ZFo->strokeWidth * (hl->realSiz / 10.0), 1); |
||
2174 | fschmid | 1358 | } |
2234 | fschmid | 1359 | if (hl->base != 0) |
2242 | fschmid | 1360 | st += (hl->Siz / 10.0) * (hl->base / 1000.0); |
68 | Franz | 1361 | p->setPen(p->brush()); |
2174 | fschmid | 1362 | p->setLineWidth(lw); |
265 | Franz | 1363 | p->drawLine(FPoint(hl->xco-hl->kern, hl->yco-st), FPoint(hl->xco+hl->wide, hl->yco-st)); |
3 | paul | 1364 | } |
167 | Franz | 1365 | } |
68 | Franz | 1366 | else |
167 | Franz | 1367 | { |
68 | Franz | 1368 | p->setLineWidth(1); |
1198 | fschmid | 1369 | p->setPen(red); |
1370 | p->setBrush(red); |
||
1371 | p->setFillMode(1); |
||
2242 | fschmid | 1372 | p->drawRect(hl->xco, hl->yco-(hl->Siz / 10.0), (hl->Siz / 10.0)*(hl->scale / 1000.0), (hl->Siz / 10.0)); |
167 | Franz | 1373 | } |
3 | paul | 1374 | } |
1375 | |||
27 | Franz | 1376 | void PageItem::DrawPolyL(QPainter *p, QPointArray pts) |
1377 | { |
||
1378 | QColor tmp; |
||
4320 | cbradney | 1379 | ScribusView* view = m_Doc->view(); |
3 | paul | 1380 | if (Segments.count() != 0) |
167 | Franz | 1381 | { |
3634 | cbradney | 1382 | QValueList<uint>::Iterator it2end=Segments.end(); |
3 | paul | 1383 | uint FirstVal = 0; |
3634 | cbradney | 1384 | for (QValueList<uint>::Iterator it2 = Segments.begin(); it2 != it2end; ++it2) |
167 | Franz | 1385 | { |
2877 | cbradney | 1386 | if (NamedLStyle.isEmpty()) |
27 | Franz | 1387 | p->drawPolyline(pts, FirstVal, (*it2)-FirstVal); |
1388 | else |
||
167 | Franz | 1389 | { |
4084 | cbradney | 1390 | multiLine ml = m_Doc->MLineStyles[NamedLStyle]; |
31 | Franz | 1391 | for (int it = ml.size()-1; it > -1; it--) |
167 | Franz | 1392 | { |
27 | Franz | 1393 | SetFarbe(&tmp, ml[it].Color, ml[it].Shade); |
1394 | p->setPen(QPen(tmp, |
||
4593 | cbradney | 1395 | QMAX(static_cast<int>(ml[it].Width* view->scale()), 1), |
27 | Franz | 1396 | static_cast<PenStyle>(ml[it].Dash), |
1397 | static_cast<PenCapStyle>(ml[it].LineEnd), |
||
1398 | static_cast<PenJoinStyle>(ml[it].LineJoin))); |
||
1399 | p->drawPolyline(pts, FirstVal, (*it2)-FirstVal); |
||
1400 | } |
||
167 | Franz | 1401 | } |
3 | paul | 1402 | FirstVal = (*it2); |
167 | Franz | 1403 | } |
2877 | cbradney | 1404 | if (NamedLStyle.isEmpty()) |
27 | Franz | 1405 | p->drawPolyline(pts, FirstVal); |
1406 | else |
||
167 | Franz | 1407 | { |
4084 | cbradney | 1408 | multiLine ml = m_Doc->MLineStyles[NamedLStyle]; |
31 | Franz | 1409 | for (int it = ml.size()-1; it > -1; it--) |
167 | Franz | 1410 | { |
27 | Franz | 1411 | SetFarbe(&tmp, ml[it].Color, ml[it].Shade); |
1412 | p->setPen(QPen(tmp, |
||
4593 | cbradney | 1413 | QMAX(static_cast<int>(ml[it].Width* view->scale()), 1), |
27 | Franz | 1414 | static_cast<PenStyle>(ml[it].Dash), |
1415 | static_cast<PenCapStyle>(ml[it].LineEnd), |
||
1416 | static_cast<PenJoinStyle>(ml[it].LineJoin))); |
||
1417 | p->drawPolyline(pts, FirstVal); |
||
1418 | } |
||
3 | paul | 1419 | } |
167 | Franz | 1420 | } |
3 | paul | 1421 | else |
167 | Franz | 1422 | { |
2877 | cbradney | 1423 | if (NamedLStyle.isEmpty()) |
27 | Franz | 1424 | p->drawPolyline(pts); |
1425 | else |
||
167 | Franz | 1426 | { |
4084 | cbradney | 1427 | multiLine ml = m_Doc->MLineStyles[NamedLStyle]; |
31 | Franz | 1428 | for (int it = ml.size()-1; it > -1; it--) |
167 | Franz | 1429 | { |
27 | Franz | 1430 | SetFarbe(&tmp, ml[it].Color, ml[it].Shade); |
1431 | p->setPen(QPen(tmp, |
||
4593 | cbradney | 1432 | QMAX(static_cast<int>(ml[it].Width*view->scale()), 1), |
27 | Franz | 1433 | static_cast<PenStyle>(ml[it].Dash), |
1434 | static_cast<PenCapStyle>(ml[it].LineEnd), |
||
1435 | static_cast<PenJoinStyle>(ml[it].LineJoin))); |
||
1436 | p->drawPolyline(pts); |
||
3 | paul | 1437 | } |
1438 | } |
||
167 | Franz | 1439 | } |
3 | paul | 1440 | } |
1204 | tsoots | 1441 | |
1361 | tsoots | 1442 | void PageItem::setItemName(const QString& newName) |
1443 | { |
||
1432 | tsoots | 1444 | if (AnName == newName) |
1445 | return; // nothing to do -> return |
||
1357 | tsoots | 1446 | if (UndoManager::undoEnabled()) |
1447 | { |
||
1448 | SimpleState *ss = new SimpleState(Um::Rename, QString(Um::FromTo).arg(AnName).arg(newName)); |
||
1449 | ss->set("OLD_NAME", AnName); |
||
1450 | ss->set("NEW_NAME", newName); |
||
1451 | undoManager->action(this, ss); |
||
1452 | } |
||
1204 | tsoots | 1453 | AnName = newName; |
1238 | tsoots | 1454 | setUName(newName); // set the name for the UndoObject too |
1204 | tsoots | 1455 | } |
1456 | |||
1286 | tsoots | 1457 | void PageItem::setFillColor(const QString &newColor) |
1458 | { |
||
1432 | tsoots | 1459 | if (fillColorVal == newColor) |
3894 | cbradney | 1460 | { |
1461 | setFillQColor(); |
||
1462 | return; |
||
1463 | } |
||
1286 | tsoots | 1464 | if (UndoManager::undoEnabled()) |
1465 | { |
||
1466 | SimpleState *ss = new SimpleState(Um::SetFill, |
||
1394 | cbradney | 1467 | QString(Um::ColorFromTo).arg(fillColorVal).arg(newColor), |
1286 | tsoots | 1468 | Um::IFill); |
1469 | ss->set("FILL", "fill"); |
||
1394 | cbradney | 1470 | ss->set("OLD_FILL", fillColorVal); |
1286 | tsoots | 1471 | ss->set("NEW_FILL", newColor); |
1472 | undoManager->action(this, ss); |
||
1473 | } |
||
1394 | cbradney | 1474 | fillColorVal = newColor; |
3894 | cbradney | 1475 | setFillQColor(); |
4010 | cbradney | 1476 | emit colors(lineColorVal, fillColorVal, lineShadeVal, fillShadeVal); |
1286 | tsoots | 1477 | } |
1478 | |||
1479 | void PageItem::setFillShade(int newShade) |
||
1480 | { |
||
1432 | tsoots | 1481 | if (fillShadeVal == newShade) |
3894 | cbradney | 1482 | { |
1483 | setFillQColor(); |
||
1484 | return; |
||
1485 | } |
||
1286 | tsoots | 1486 | if (UndoManager::undoEnabled()) |
1487 | { |
||
1488 | SimpleState *ss = new SimpleState(Um::SetShade, |
||
1402 | tsoots | 1489 | QString(Um::FromTo).arg(fillShadeVal).arg(newShade), |
1286 | tsoots | 1490 | Um::IShade); |
1491 | ss->set("SHADE", "shade"); |
||
1394 | cbradney | 1492 | ss->set("OLD_SHADE", fillShadeVal); |
1286 | tsoots | 1493 | ss->set("NEW_SHADE", newShade); |
1494 | undoManager->action(this, ss); |
||
1495 | } |
||
1394 | cbradney | 1496 | fillShadeVal = newShade; |
3894 | cbradney | 1497 | setFillQColor(); |
4010 | cbradney | 1498 | emit colors(lineColorVal, fillColorVal, lineShadeVal, fillShadeVal); |
1286 | tsoots | 1499 | } |
1500 | |||
1371 | tsoots | 1501 | void PageItem::setFillTransparency(double newTransparency) |
1502 | { |
||
1432 | tsoots | 1503 | if (fillTransparencyVal == newTransparency) |
1504 | return; // nothing to do -> return |
||
1371 | tsoots | 1505 | if (UndoManager::undoEnabled()) |
1506 | { |
||
1507 | SimpleState *ss = new SimpleState(Um::Transparency, |
||
1394 | cbradney | 1508 | QString(Um::FromTo).arg(fillTransparencyVal).arg(newTransparency), |
1371 | tsoots | 1509 | Um::ITransparency); |
1510 | ss->set("TRANSPARENCY", "transparency"); |
||
1394 | cbradney | 1511 | ss->set("OLD_TP", fillTransparencyVal); |
1371 | tsoots | 1512 | ss->set("NEW_TP", newTransparency); |
1513 | undoManager->action(this, ss); |
||
1514 | } |
||
1394 | cbradney | 1515 | fillTransparencyVal = newTransparency; |
1371 | tsoots | 1516 | } |
1517 | |||
1286 | tsoots | 1518 | void PageItem::setLineColor(const QString &newColor) |
1519 | { |
||
1432 | tsoots | 1520 | if (lineColorVal == newColor) |
3894 | cbradney | 1521 | { |
1522 | setLineQColor(); |
||
1523 | return; |
||
1524 | } |
||
1286 | tsoots | 1525 | if (UndoManager::undoEnabled()) |
1526 | { |
||
1527 | SimpleState *ss = new SimpleState(Um::SetLineColor, |
||
1394 | cbradney | 1528 | QString(Um::ColorFromTo).arg(lineColorVal).arg(newColor), |
1286 | tsoots | 1529 | Um::IFill); |
1530 | ss->set("LINE_COLOR", "line_color"); |
||
1394 | cbradney | 1531 | ss->set("OLD_COLOR", lineColorVal); |
1286 | tsoots | 1532 | ss->set("NEW_COLOR", newColor); |
1533 | undoManager->action(this, ss); |
||
1534 | } |
||
1394 | cbradney | 1535 | lineColorVal = newColor; |
3894 | cbradney | 1536 | setLineQColor(); |
4010 | cbradney | 1537 | emit colors(lineColorVal, fillColorVal, lineShadeVal, fillShadeVal); |
1286 | tsoots | 1538 | } |
1539 | |||
1540 | void PageItem::setLineShade(int newShade) |
||
1541 | { |
||
1432 | tsoots | 1542 | if (lineShadeVal == newShade) |
3894 | cbradney | 1543 | { |
1544 | setLineQColor(); |
||
1545 | return; |
||
1546 | } |
||
1286 | tsoots | 1547 | if (UndoManager::undoEnabled()) |
1548 | { |
||
1549 | SimpleState *ss = new SimpleState(Um::SetLineShade, |
||
1402 | tsoots | 1550 | QString(Um::FromTo).arg(lineShadeVal).arg(newShade), |
1286 | tsoots | 1551 | Um::IShade); |
1552 | ss->set("LINE_SHADE", "line_shade"); |
||
1394 | cbradney | 1553 | ss->set("OLD_SHADE", lineShadeVal); |
1286 | tsoots | 1554 | ss->set("NEW_SHADE", newShade); |
1555 | undoManager->action(this, ss); |
||
1556 | } |
||
1394 | cbradney | 1557 | lineShadeVal = newShade; |
3894 | cbradney | 1558 | setLineQColor(); |
4010 | cbradney | 1559 | emit colors(lineColorVal, fillColorVal, lineShadeVal, fillShadeVal); |
1286 | tsoots | 1560 | } |
1561 | |||
3894 | cbradney | 1562 | void PageItem::setLineQColor() |
1563 | { |
||
4546 | subik | 1564 | if (lineColorVal != CommonStrings::None) |
4084 | cbradney | 1565 | strokeQColor = m_Doc->PageColors[lineColorVal].getShadeColorProof(lineShadeVal); |
3894 | cbradney | 1566 | } |
1381 | cbradney | 1567 | |
3894 | cbradney | 1568 | void PageItem::setFillQColor() |
1569 | { |
||
4546 | subik | 1570 | if (fillColorVal != CommonStrings::None) |
4084 | cbradney | 1571 | fillQColor = m_Doc->PageColors[fillColorVal].getShadeColorProof(fillShadeVal); |
3894 | cbradney | 1572 | } |
1573 | |||
1371 | tsoots | 1574 | void PageItem::setLineTransparency(double newTransparency) |
1575 | { |
||
1432 | tsoots | 1576 | if (lineTransparencyVal == newTransparency) |
1577 | return; // nothing to do -> return |
||
1371 | tsoots | 1578 | if (UndoManager::undoEnabled()) |
1579 | { |
||
1580 | SimpleState *ss = new SimpleState(Um::LineTransparency, |
||
1394 | cbradney | 1581 | QString(Um::FromTo).arg(lineTransparencyVal).arg(newTransparency), |
1371 | tsoots | 1582 | Um::ITransparency); |
1583 | ss->set("LINE_TRANSPARENCY", "transparency"); |
||
1394 | cbradney | 1584 | ss->set("OLD_TP", lineTransparencyVal); |
1371 | tsoots | 1585 | ss->set("NEW_TP", newTransparency); |
1586 | undoManager->action(this, ss); |
||
1587 | } |
||
1394 | cbradney | 1588 | lineTransparencyVal = newTransparency; |
1371 | tsoots | 1589 | } |
1590 | |||
1383 | tsoots | 1591 | void PageItem::setLineStyle(PenStyle newStyle) |
1592 | { |
||
1432 | tsoots | 1593 | if (PLineArt == newStyle) |
1594 | return; // nothing to do -> return |
||
1383 | tsoots | 1595 | if (UndoManager::undoEnabled()) |
1596 | { |
||
1597 | SimpleState *ss = new SimpleState(Um::LineStyle,"",Um::ILineStyle); |
||
1598 | ss->set("LINE_STYLE", "line_style"); |
||
1599 | ss->set("OLD_STYLE", static_cast<int>(PLineArt)); |
||
1600 | ss->set("NEW_STYLE", static_cast<int>(newStyle)); |
||
1601 | undoManager->action(this, ss); |
||
1602 | } |
||
1603 | PLineArt = newStyle; |
||
1604 | } |
||
1605 | |||
1385 | tsoots | 1606 | void PageItem::setLineWidth(double newWidth) |
1607 | { |
||
4580 | cbradney | 1608 | if (m_lineWidth == newWidth) |
1432 | tsoots | 1609 | return; // nothing to do -> return |
1385 | tsoots | 1610 | if (UndoManager::undoEnabled()) |
1611 | { |
||
1612 | SimpleState *ss = new SimpleState(Um::LineWidth, |
||
4580 | cbradney | 1613 | QString(Um::FromTo).arg(m_lineWidth).arg(newWidth),Um::ILineStyle); |
1385 | tsoots | 1614 | ss->set("LINE_WIDTH", "line_width"); |
4580 | cbradney | 1615 | ss->set("OLD_WIDTH", m_lineWidth); |
1385 | tsoots | 1616 | ss->set("NEW_WIDTH", newWidth); |
1617 | undoManager->action(this, ss); |
||
1618 | } |
||
4580 | cbradney | 1619 | Oldm_lineWidth=m_lineWidth; |
1620 | m_lineWidth = newWidth; |
||
1385 | tsoots | 1621 | } |
1622 | |||
1623 | void PageItem::setLineEnd(PenCapStyle newStyle) |
||
1624 | { |
||
1432 | tsoots | 1625 | if (PLineEnd == newStyle) |
1626 | return; // nothing to do -> return |
||
1385 | tsoots | 1627 | if (UndoManager::undoEnabled()) |
1628 | { |
||
1629 | SimpleState *ss = new SimpleState(Um::LineEnd,"",Um::ILineStyle); |
||
1630 | ss->set("LINE_END", "line_end"); |
||
1631 | ss->set("OLD_STYLE", static_cast<int>(PLineEnd)); |
||
1632 | ss->set("NEW_STYLE", static_cast<int>(newStyle)); |
||
1633 | undoManager->action(this, ss); |
||
1634 | } |
||
1635 | PLineEnd = newStyle; |
||
1636 | } |
||
1637 | |||
1638 | void PageItem::setLineJoin(PenJoinStyle newStyle) |
||
1639 | { |
||
1432 | tsoots | 1640 | if (PLineJoin == newStyle) |
1641 | return; // nothing to do -> return |
||
1385 | tsoots | 1642 | if (UndoManager::undoEnabled()) |
1643 | { |
||
1644 | SimpleState *ss = new SimpleState(Um::LineJoin,"",Um::ILineStyle); |
||
1645 | ss->set("LINE_JOIN", "line_join"); |
||
1646 | ss->set("OLD_STYLE", static_cast<int>(PLineJoin)); |
||
1647 | ss->set("NEW_STYLE", static_cast<int>(newStyle)); |
||
1648 | undoManager->action(this, ss); |
||
1649 | } |
||
1650 | PLineJoin = newStyle; |
||
1651 | } |
||
1392 | cbradney | 1652 | |
1386 | tsoots | 1653 | void PageItem::setCustomLineStyle(const QString& newStyle) |
1654 | { |
||
1432 | tsoots | 1655 | if (NamedLStyle == newStyle) |
1656 | return; // nothing to do -> return |
||
1386 | tsoots | 1657 | if (UndoManager::undoEnabled()) |
1658 | { |
||
2877 | cbradney | 1659 | QString oldStyle = NamedLStyle.isEmpty() ? Um::NoStyle : NamedLStyle; |
1660 | QString nStyle = newStyle.isEmpty() ? Um::NoStyle : newStyle; |
||
1661 | QString action = newStyle.isEmpty() ? Um::NoLineStyle : Um::CustomLineStyle; |
||
1386 | tsoots | 1662 | SimpleState *ss = new SimpleState(action, |
1663 | QString(Um::FromTo).arg(oldStyle).arg(nStyle),Um::ILineStyle); |
||
1664 | ss->set("CUSTOM_LINE_STYLE", "customlinestyle"); |
||
1665 | ss->set("OLD_STYLE", NamedLStyle); |
||
1666 | ss->set("NEW_STYLE", newStyle); |
||
1667 | undoManager->action(this, ss); |
||
1668 | } |
||
1669 | NamedLStyle = newStyle; |
||
1670 | } |
||
1671 | |||
1391 | tsoots | 1672 | void PageItem::setStartArrowIndex(int newIndex) |
1673 | { |
||
4061 | craig | 1674 | if (m_startArrowIndex == newIndex) |
1432 | tsoots | 1675 | return; // nothing to do -> return |
1391 | tsoots | 1676 | if (UndoManager::undoEnabled()) |
1677 | { |
||
1678 | SimpleState *ss = new SimpleState(Um::StartArrow,"",Um::IArrow); |
||
1679 | ss->set("START_ARROW", "startarrow"); |
||
4061 | craig | 1680 | ss->set("OLD_INDEX", m_startArrowIndex); |
1391 | tsoots | 1681 | ss->set("NEW_INDEX", newIndex); |
1682 | undoManager->action(this, ss); |
||
1683 | } |
||
4061 | craig | 1684 | m_startArrowIndex = newIndex; |
1391 | tsoots | 1685 | } |
1686 | |||
1687 | void PageItem::setEndArrowIndex(int newIndex) |
||
1688 | { |
||
4061 | craig | 1689 | if (m_endArrowIndex == newIndex) |
1432 | tsoots | 1690 | return; // nothing to do -> return |
1391 | tsoots | 1691 | if (UndoManager::undoEnabled()) |
1692 | { |
||
1693 | SimpleState *ss = new SimpleState(Um::EndArrow,"",Um::IArrow); |
||
1694 | ss->set("END_ARROW", "endarrow"); |
||
4061 | craig | 1695 | ss->set("OLD_INDEX", m_endArrowIndex); |
1391 | tsoots | 1696 | ss->set("NEW_INDEX", newIndex); |
1697 | undoManager->action(this, ss); |
||
1698 | } |
||
4061 | craig | 1699 | m_endArrowIndex = newIndex; |
1391 | tsoots | 1700 | } |
1701 | |||
1394 | cbradney | 1702 | void PageItem::setImageFlippedH(bool flipped) |
1703 | { |
||
4699 | cbradney | 1704 | if (flipped != m_ImageIsFlippedH) |
1394 | cbradney | 1705 | flipImageH(); |
1706 | } |
||
1707 | |||
1287 | tsoots | 1708 | void PageItem::flipImageH() |
1709 | { |
||
1710 | if (UndoManager::undoEnabled()) |
||
1711 | { |
||
1712 | SimpleState *ss = new SimpleState(Um::FlipH, 0, Um::IFlipH); |
||
1713 | ss->set("IMAGEFLIPH", "imagefliph"); |
||
1714 | undoManager->action(this, ss); |
||
1715 | } |
||
4699 | cbradney | 1716 | m_ImageIsFlippedH = !m_ImageIsFlippedH; |
1717 | emit frameFlippedH(m_ImageIsFlippedH); |
||
1287 | tsoots | 1718 | } |
1719 | |||
1392 | cbradney | 1720 | void PageItem::setImageFlippedV(bool flipped) |
1721 | { |
||
4699 | cbradney | 1722 | if (flipped != m_ImageIsFlippedV) |
1392 | cbradney | 1723 | flipImageV(); |
1724 | } |
||
1725 | |||
1287 | tsoots | 1726 | void PageItem::flipImageV() |
1727 | { |
||
1728 | if (UndoManager::undoEnabled()) |
||
1729 | { |
||
1730 | SimpleState *ss = new SimpleState(Um::FlipV, 0, Um::IFlipV); |
||
1731 | ss->set("IMAGEFLIPV", "imageflipv"); |
||
1732 | undoManager->action(this, ss); |
||
1733 | } |
||
4699 | cbradney | 1734 | m_ImageIsFlippedV = !m_ImageIsFlippedV; |
1735 | emit frameFlippedV(m_ImageIsFlippedV); |
||
1287 | tsoots | 1736 | } |
1737 | |||
1495 | tsoots | 1738 | void PageItem::setImageScalingMode(bool freeScale, bool keepRatio) |
1739 | { |
||
1740 | if (ScaleType == freeScale && AspectRatio == keepRatio) |
||
1741 | return; |
||
1742 | if (UndoManager::undoEnabled()) |
||
1743 | { |
||
1744 | QString from = ScaleType ? Um::FreeScaling : Um::FrameSize; |
||
1745 | from += ", "; |
||
1746 | from += AspectRatio ? Um::KeepRatio : Um::BreakRatio; |
||
1747 | QString to = freeScale ? Um::FreeScaling : Um::FrameSize; |
||
1748 | to += ", "; |
||
1749 | to += keepRatio ? Um::KeepRatio : Um::BreakRatio; |
||
1998 | fschmid | 1750 | SimpleState *ss = new SimpleState(Um::ImageScaling, QString(Um::FromTo).arg(from).arg(to), Um::IImageScaling); |
1495 | tsoots | 1751 | if (freeScale != ScaleType) |
1752 | ss->set("SCALE_TYPE", freeScale); |
||
1753 | if (keepRatio != AspectRatio) |
||
1754 | ss->set("ASPECT_RATIO", keepRatio); |
||
1755 | undoManager->action(this, ss); |
||
1756 | } |
||
1757 | ScaleType = freeScale; |
||
1758 | AspectRatio = keepRatio; |
||
3650 | cbradney | 1759 | AdjustPictScale(); |
4320 | cbradney | 1760 | m_Doc->view()->RefreshItem(this); |
1495 | tsoots | 1761 | } |
1762 | |||
1290 | tsoots | 1763 | void PageItem::toggleLock() |
1764 | { |
||
1765 | if (UndoManager::undoEnabled()) |
||
1766 | { |
||
1767 | SimpleState *ss; |
||
4695 | cbradney | 1768 | if (m_Locked) |
1290 | tsoots | 1769 | ss = new SimpleState(Um::UnLock, 0, Um::IUnLock); |
1770 | else |
||
1771 | ss = new SimpleState(Um::Lock, 0, Um::ILock); |
||
1772 | ss->set("LOCK", "lock"); |
||
1773 | undoManager->action(this, ss); |
||
1774 | } |
||
4695 | cbradney | 1775 | m_Locked = !m_Locked; |
1776 | emit frameLocked(m_Locked); |
||
1290 | tsoots | 1777 | } |
1778 | |||
1293 | tsoots | 1779 | void PageItem::setLocked(bool isLocked) |
1780 | { |
||
4695 | cbradney | 1781 | if (isLocked != m_Locked) |
1293 | tsoots | 1782 | toggleLock(); |
1783 | } |
||
1784 | |||
1290 | tsoots | 1785 | void PageItem::toggleSizeLock() |
1786 | { |
||
1787 | if (UndoManager::undoEnabled()) |
||
1788 | { |
||
1789 | SimpleState *ss; |
||
4695 | cbradney | 1790 | if (m_Locked) |
1290 | tsoots | 1791 | ss = new SimpleState(Um::SizeUnLock, 0, Um::IUnLock); |
1792 | else |
||
1793 | ss = new SimpleState(Um::SizeLock, 0, Um::ILock); |
||
1794 | ss->set("SIZE_LOCK", "size_lock"); |
||
1795 | undoManager->action(this, ss); |
||
1796 | } |
||
4695 | cbradney | 1797 | m_SizeLocked = !m_SizeLocked; |
1798 | emit frameSizeLocked(m_SizeLocked); |
||
1290 | tsoots | 1799 | } |
1800 | |||
1298 | fschmid | 1801 | void PageItem::setSizeLocked(bool isLocked) |
1802 | { |
||
4695 | cbradney | 1803 | if (isLocked != m_SizeLocked) |
1298 | fschmid | 1804 | toggleSizeLock(); |
1805 | } |
||
1806 | |||
4698 | cbradney | 1807 | |
1808 | void PageItem::setPrintEnabled(bool toPrint) |
||
1809 | { |
||
1810 | if (toPrint != m_PrintEnabled) |
||
1811 | togglePrintEnabled(); |
||
1812 | } |
||
1813 | |||
1814 | void PageItem::togglePrintEnabled() |
||
1815 | { |
||
1816 | if (UndoManager::undoEnabled()) |
||
1817 | { |
||
1818 | SimpleState *ss; |
||
1819 | if (m_PrintEnabled) |
||
1820 | ss = new SimpleState(Um::DisablePrint, 0, Um::IDisablePrint); |
||
1821 | else |
||
1822 | ss = new SimpleState(Um::EnablePrint, 0, Um::IEnablePrint); |
||
1823 | ss->set("PRINT_ENABLED", "print_enabled"); |
||
1824 | undoManager->action(this, ss); |
||
1825 | } |
||
1826 | m_PrintEnabled=!m_PrintEnabled; |
||
1827 | emit printEnabled(m_PrintEnabled); |
||
1828 | } |
||
1829 | |||
1399 | tsoots | 1830 | void PageItem::setFont(const QString& newFont) |
1831 | { |
||
4073 | cbradney | 1832 | if (m_Font == newFont) |
1432 | tsoots | 1833 | return; // nothing to do -> return |
1399 | tsoots | 1834 | if (UndoManager::undoEnabled()) |
1835 | { |
||
1836 | SimpleState *ss = new SimpleState(Um::SetFont, |
||
4073 | cbradney | 1837 | QString(Um::FromTo).arg(m_Font).arg(newFont), Um::IFont); |
1399 | tsoots | 1838 | ss->set("SET_FONT", "setfont"); |
4073 | cbradney | 1839 | ss->set("OLD_FONT", m_Font); |
1399 | tsoots | 1840 | ss->set("NEW_FONT", newFont); |
1841 | undoManager->action(this, ss); |
||
1842 | } |
||
4073 | cbradney | 1843 | m_Font = newFont; |
1844 | emit textFont(m_Font); |
||
1399 | tsoots | 1845 | } |
1846 | |||
1400 | tsoots | 1847 | void PageItem::setFontSize(int newSize) |
1848 | { |
||
4073 | cbradney | 1849 | if (m_FontSize == newSize) |
1432 | tsoots | 1850 | return; // nothing to do -> return |
1400 | tsoots | 1851 | if (UndoManager::undoEnabled()) |
1852 | { |
||
1853 | SimpleState *ss = new SimpleState(Um::SetFontSize, |
||
4073 | cbradney | 1854 | QString(Um::FromTo).arg(m_FontSize/10.0).arg(newSize/10.0), Um::IFont); |
1400 | tsoots | 1855 | ss->set("SET_FONT_SIZE", "setfontsize"); |
4073 | cbradney | 1856 | ss->set("OLD_SIZE", m_FontSize); |
1400 | tsoots | 1857 | ss->set("NEW_SIZE", newSize); |
1858 | undoManager->action(this, ss); |
||
1859 | } |
||
4073 | cbradney | 1860 | m_FontSize = newSize; |
1861 | emit textSize(m_FontSize); |
||
1400 | tsoots | 1862 | } |
1863 | |||
2230 | fschmid | 1864 | void PageItem::setFontHeight(int newHeight) |
1865 | { |
||
1866 | if (TxtScaleV == newHeight) |
||
1867 | return; // nothing to do -> return |
||
1868 | if (UndoManager::undoEnabled()) |
||
1869 | { |
||
1870 | SimpleState *ss = new SimpleState(Um::SetFontHeight, |
||
1871 | QString(Um::FromTo).arg(TxtScaleV).arg(newHeight), Um::IFont); |
||
1872 | ss->set("SET_FONT_HEIGHT", "setfontheight"); |
||
1873 | ss->set("OLD_HEIGHT", TxtScaleV); |
||
1874 | ss->set("NEW_HEIGHT", newHeight); |
||
1875 | undoManager->action(this, ss); |
||
1876 | } |
||
1877 | TxtScaleV = newHeight; |
||
1878 | } |
||
1879 | |||
1400 | tsoots | 1880 | void PageItem::setFontWidth(int newWidth) |
1881 | { |
||
1432 | tsoots | 1882 | if (TxtScale == newWidth) |
1883 | return; // nothing to do -> return |
||
1400 | tsoots | 1884 | if (UndoManager::undoEnabled()) |
1885 | { |
||
1886 | SimpleState *ss = new SimpleState(Um::SetFontWidth, |
||
1887 | QString(Um::FromTo).arg(TxtScale).arg(newWidth), Um::IFont); |
||
1888 | ss->set("SET_FONT_WIDTH", "setfontwidth"); |
||
1889 | ss->set("OLD_WIDTH", TxtScale); |
||
1890 | ss->set("NEW_WIDTH", newWidth); |
||
1891 | undoManager->action(this, ss); |
||
1892 | } |
||
1893 | TxtScale = newWidth; |
||
1894 | } |
||
1895 | |||
1401 | tsoots | 1896 | void PageItem::setFontFillColor(const QString& newColor) |
1897 | { |
||
1432 | tsoots | 1898 | if (TxtFill == newColor) |
1899 | return; // nothing to do -> return |
||
1401 | tsoots | 1900 | if (UndoManager::undoEnabled()) |
1901 | { |
||
1902 | SimpleState *ss = new SimpleState(Um::SetFontFill, |
||
1903 | QString(Um::FromTo).arg(TxtFill).arg(newColor), Um::IFont); |
||
1904 | ss->set("SET_FONT_FILL", "setfontfill"); |
||
1905 | ss->set("OLD_FILL", TxtFill); |
||
1906 | ss->set("NEW_FILL", newColor); |
||
1907 | undoManager->action(this, ss); |
||
1908 | } |
||
1909 | TxtFill = newColor; |
||
4893 | cbradney | 1910 | emit textColor(TxtStroke, TxtFill, ShTxtStroke, ShTxtFill); |
1401 | tsoots | 1911 | } |
1912 | |||
1913 | void PageItem::setFontStrokeColor(const QString& newColor) |
||
1914 | { |
||
1432 | tsoots | 1915 | if (TxtStroke == newColor) |
1916 | return; // nothing to do -> return |
||
1401 | tsoots | 1917 | if (UndoManager::undoEnabled()) |
1918 | { |
||
1919 | SimpleState *ss = new SimpleState(Um::SetFontStroke, |
||
1920 | QString(Um::FromTo).arg(TxtStroke).arg(newColor), Um::IFont); |
||
1921 | ss->set("SET_FONT_STROKE", "setfontstroke"); |
||
1922 | ss->set("OLD_STROKE", TxtStroke); |
||
1923 | ss->set("NEW_STROKE", newColor); |
||
1924 | undoManager->action(this, ss); |
||
1925 | } |
||
1926 | TxtStroke = newColor; |
||
4893 | cbradney | 1927 | emit textColor(TxtStroke, TxtFill, ShTxtStroke, ShTxtFill); |
1401 | tsoots | 1928 | } |
1929 | |||
1402 | tsoots | 1930 | void PageItem::setFontFillShade(int newShade) |
1931 | { |
||
1432 | tsoots | 1932 | if (ShTxtFill == newShade) |
1933 | return; // nothing to do -> return |
||
1402 | tsoots | 1934 | if (UndoManager::undoEnabled()) |
1935 | { |
||
1936 | SimpleState *ss = new SimpleState(Um::SetFontFillShade, |
||
1937 | QString(Um::FromTo).arg(ShTxtFill).arg(newShade), |
||
1938 | Um::IFont); |
||
1939 | ss->set("FONT_FILL_SHADE", "line_shade"); |
||
1940 | ss->set("OLD_SHADE", ShTxtFill); |
||
1941 | ss->set("NEW_SHADE", newShade); |
||
1942 | undoManager->action(this, ss); |
||
1943 | } |
||
1944 | ShTxtFill = newShade; |
||
4893 | cbradney | 1945 | emit textColor(TxtStroke, TxtFill, ShTxtStroke, ShTxtFill); |
1402 | tsoots | 1946 | } |
1947 | |||
1948 | void PageItem::setFontStrokeShade(int newShade) |
||
1949 | { |
||
1432 | tsoots | 1950 | if (ShTxtStroke == newShade) |
1951 | return; // nothing to do -> return |
||
1402 | tsoots | 1952 | if (UndoManager::undoEnabled()) |
1953 | { |
||
1954 | SimpleState *ss = new SimpleState(Um::SetFontStrokeShade, |
||
1955 | QString(Um::FromTo).arg(ShTxtStroke).arg(newShade), |
||
1956 | Um::IFont); |
||
1957 | ss->set("FONT_STROKE_SHADE", "line_shade"); |
||
1958 | ss->set("OLD_SHADE", ShTxtStroke); |
||
1959 | ss->set("NEW_SHADE", newShade); |
||
1960 | undoManager->action(this, ss); |
||
1961 | } |
||
1962 | ShTxtStroke = newShade; |
||
4893 | cbradney | 1963 | emit textColor(TxtStroke, TxtFill, ShTxtStroke, ShTxtFill); |
1402 | tsoots | 1964 | } |
1965 | |||
1415 | tsoots | 1966 | void PageItem::setFontEffects(int newEffects) |
1967 | { |
||
1968 | if (UndoManager::undoEnabled()) |
||
1969 | { |
||
1970 | SimpleState *ss = new SimpleState(Um::SetFontEffect, "", Um::IFont); |
||
1971 | ss->set("FONT_EFFECTS", "fonteffects"); |
||
1972 | ss->set("OLD_EFFECT", TxTStyle); |
||
1973 | ss->set("NEW_EFFECT", newEffects); |
||
1974 | undoManager->action(this, ss); |
||
1975 | } |
||
2185 | fschmid | 1976 | TxTStyle &= ~1919; |
1415 | tsoots | 1977 | TxTStyle |= newEffects; |
1978 | } |
||
1979 | |||
2382 | fschmid | 1980 | void PageItem::setKerning(int newKerning) |
1403 | tsoots | 1981 | { |
1432 | tsoots | 1982 | if (ExtraV == newKerning) |
1983 | return; // nothing to do -> return |
||
1403 | tsoots | 1984 | if (UndoManager::undoEnabled()) |
1985 | { |
||
1986 | SimpleState *ss = new SimpleState(Um::SetKerning, |
||
1987 | QString(Um::FromTo).arg(ExtraV).arg(newKerning), |
||
1988 | Um::IFont); |
||
1989 | ss->set("KERNING", "kerning"); |
||
1990 | ss->set("OLD_KERNING", ExtraV); |
||
1991 | ss->set("NEW_KERNING", newKerning); |
||
1992 | undoManager->action(this, ss); |
||
1993 | } |
||
1994 | ExtraV = newKerning; |
||
1995 | } |
||
1996 | |||
1997 | void PageItem::setLineSpacing(double newSpacing) |
||
1998 | { |
||
1432 | tsoots | 1999 | if (LineSp == newSpacing) |
2000 | return; // nothing to do -> return |
||
1403 | tsoots | 2001 | if (UndoManager::undoEnabled()) |
2002 | { |
||
2003 | SimpleState *ss = new SimpleState(Um::SetLineSpacing, |
||
2004 | QString(Um::FromTo).arg(LineSp).arg(newSpacing), |
||
2005 | Um::IFont); |
||
2006 | ss->set("SPACING", "spacing"); |
||
2007 | ss->set("OLD_SPACING", LineSp); |
||
2008 | ss->set("NEW_SPACING", newSpacing); |
||
2009 | undoManager->action(this, ss); |
||
2010 | } |
||
2011 | LineSp = newSpacing; |
||
4584 | cbradney | 2012 | emit lineSpacing(LineSp); |
1403 | tsoots | 2013 | } |
2014 | |||
4584 | cbradney | 2015 | void PageItem::setLineSpacingMode(int newLineSpacingMode) |
2016 | { |
||
2017 | if (LineSpMode == newLineSpacingMode) |
||
2018 | return; // nothing to do -> return |
||
2019 | //TODO Add in undo |
||
2020 | LineSpMode = newLineSpacingMode; |
||
2021 | } |
||
2022 | |||
1403 | tsoots | 2023 | void PageItem::setLanguage(const QString& newLanguage) |
2024 | { |
||
1432 | tsoots | 2025 | if (Language == newLanguage) |
2026 | return; // nothing to do -> return |
||
1403 | tsoots | 2027 | if (UndoManager::undoEnabled()) |
2028 | { |
||
2029 | SimpleState *ss = new SimpleState(Um::SetLanguage, |
||
2030 | QString(Um::FromTo).arg(Language).arg(newLanguage), |
||
2031 | Um::IFont); |
||
2032 | ss->set("LANGUAGE", "lang"); |
||
2033 | ss->set("OLD_LANG", Language); |
||
2034 | ss->set("NEW_LANG", newLanguage); |
||
2035 | undoManager->action(this, ss); |
||
2036 | } |
||
2037 | Language = newLanguage; |
||
2038 | } |
||
2039 | |||
1651 | craig | 2040 | void PageItem::setTextFlowsAroundFrame(bool isFlowing) |
2041 | { |
||
1653 | craig | 2042 | if (textFlowsAroundFrameVal == isFlowing) |
1489 | tsoots | 2043 | return; |
2044 | if (UndoManager::undoEnabled()) |
||
2045 | { |
||
2046 | SimpleState *ss = new SimpleState(isFlowing ? Um::TextFlow : Um::NoTextFlow, "", Um::IFont); |
||
2047 | ss->set("TEXT_FLOW", isFlowing); |
||
2048 | undoManager->action(this, ss); |
||
2049 | } |
||
1653 | craig | 2050 | textFlowsAroundFrameVal = isFlowing; |
1489 | tsoots | 2051 | } |
2052 | |||
1653 | craig | 2053 | void PageItem::setTextFlowUsesBoundingBox(bool useBounding) |
2054 | { |
||
2055 | if (textFlowUsesBoundingBoxVal == useBounding) |
||
1489 | tsoots | 2056 | return; |
2057 | if (UndoManager::undoEnabled()) |
||
2058 | { |
||
2059 | SimpleState *ss = new SimpleState(useBounding ? Um::BoundingBox : Um::NoBoundingBox, "", Um::IFont); |
||
1653 | craig | 2060 | ss->set("TEXT_FLOW", textFlowsAroundFrame()); |
1489 | tsoots | 2061 | ss->set("BOUNDING_BOX", useBounding); |
2062 | undoManager->action(this, ss); |
||
2063 | } |
||
1656 | craig | 2064 | if (useBounding && textFlowUsesContourLineVal) |
2065 | textFlowUsesContourLineVal = false; |
||
1653 | craig | 2066 | textFlowUsesBoundingBoxVal = useBounding; |
1489 | tsoots | 2067 | } |
2068 | |||
1656 | craig | 2069 | void PageItem::setTextFlowUsesContourLine(bool useContour) |
2070 | { |
||
2071 | if (textFlowUsesContourLineVal == useContour) |
||
1489 | tsoots | 2072 | return; |
2073 | if (UndoManager::undoEnabled()) |
||
2074 | { |
||
2075 | SimpleState *ss = new SimpleState(useContour |