Rev 24587 | Rev 24665 | 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" |
16503 | craig | 25 | |
21587 | craig | 26 | #include <QDebug> |
27 | #include <QFileInfo> |
||
28 | #include <QFont> |
||
29 | #include <QMessageBox> |
||
10220 | cbradney | 30 | #include <QPainter> |
31 | #include <QPen> |
||
32 | #include <QPoint> |
||
16856 | craig | 33 | #include <QPointF> |
21587 | craig | 34 | #include <QPolygon> |
10220 | cbradney | 35 | #include <QRegExp> |
21587 | craig | 36 | #include <QRegion> |
19266 | jghali | 37 | #include <QRegularExpression> |
21587 | craig | 38 | #include <cairo.h> |
2104 | cbradney | 39 | #include <cassert> |
21587 | craig | 40 | #include <qdrawutil.h> |
17826 | craig | 41 | #include <sstream> |
4772 | cbradney | 42 | |
19067 | craig | 43 | #include "appmodes.h" |
10532 | avox | 44 | #include "canvas.h" |
24003 | jghali | 45 | #include "canvasmode.h" |
10601 | mrdocs | 46 | #include "cmsettings.h" |
10212 | cbradney | 47 | #include "colorblind.h" |
17826 | craig | 48 | #include "desaxe/saxXML.h" |
20185 | craig | 49 | #include "iconmanager.h" |
17826 | craig | 50 | #include "marks.h" |
18794 | jghali | 51 | #include "pageitem_arc.h" |
17092 | jghali | 52 | #include "pageitem_group.h" |
19067 | craig | 53 | #include "pageitem_latexframe.h" |
23413 | jghali | 54 | #include "pageitem_line.h" |
18794 | jghali | 55 | #include "pageitem_noteframe.h" |
17709 | craig | 56 | #include "pageitem_regularpolygon.h" |
17735 | craig | 57 | #include "pageitem_spiral.h" |
18794 | jghali | 58 | #include "pageitem_table.h" |
19067 | craig | 59 | #include "pageitem_textframe.h" |
10212 | cbradney | 60 | #include "prefsmanager.h" |
61 | #include "resourcecollection.h" |
||
13497 | jghali | 62 | #include "scclocale.h" |
10212 | cbradney | 63 | #include "sccolorengine.h" |
14539 | jghali | 64 | #include "scimagecacheproxy.h" |
16736 | jghali | 65 | #include "sclimits.h" |
66 | #include "scpage.h" |
||
4772 | cbradney | 67 | #include "scpainter.h" |
10212 | cbradney | 68 | #include "scpaths.h" |
69 | #include "scpattern.h" |
||
70 | #include "scribusapp.h" |
||
5243 | cbradney | 71 | #include "scribuscore.h" |
10212 | cbradney | 72 | #include "scribusdoc.h" |
19093 | craig | 73 | #include "scribusview.h" |
4320 | cbradney | 74 | #include "scribuswin.h" |
13503 | cbradney | 75 | #include "sctextstream.h" |
3934 | cbradney | 76 | #include "selection.h" |
16159 | fschmid | 77 | #include "text/storytext.h" |
23284 | jghali | 78 | #include "ui/contentpalette.h" |
19093 | craig | 79 | #include "ui/guidemanager.h" |
80 | #include "ui/propertiespalette.h" |
||
1204 | tsoots | 81 | #include "undomanager.h" |
82 | #include "undostate.h" |
||
19297 | jghali | 83 | #include "units.h" |
2533 | craig | 84 | #include "util.h" |
16736 | jghali | 85 | #include "util_file.h" |
10212 | cbradney | 86 | #include "util_formats.h" |
10203 | cbradney | 87 | #include "util_math.h" |
12277 | cbradney | 88 | #include "util_text.h" |
2533 | craig | 89 | |
16281 | jghali | 90 | |
21587 | craig | 91 | |
92 | |||
504 | cbradney | 93 | using namespace std; |
94 | |||
3625 | avox | 95 | PageItem::PageItem(const PageItem & other) |
96 | : QObject(other.parent()), |
||
22563 | craig | 97 | UndoObject(other), |
98 | SingleObservable<PageItem>(other.m_Doc->itemsChanged()), |
||
99 | TextContext(this), |
||
3625 | avox | 100 | |
101 | // 200 attributes! That is madness, or to quote some famous people from Kriquet: |
||
102 | // "THAT ALL HAS TO GO!" |
||
103 | gXpos(other.gXpos), |
||
104 | gYpos(other.gYpos), |
||
105 | gWidth(other.gWidth), |
||
106 | gHeight(other.gHeight), |
||
107 | GrType(other.GrType), |
||
108 | GrStartX(other.GrStartX), |
||
109 | GrStartY(other.GrStartY), |
||
110 | GrEndX(other.GrEndX), |
||
111 | GrEndY(other.GrEndY), |
||
14278 | fschmid | 112 | GrFocalX(other.GrFocalX), |
113 | GrFocalY(other.GrFocalY), |
||
114 | GrScale(other.GrScale), |
||
14284 | fschmid | 115 | GrSkew(other.GrSkew), |
19401 | fschmid | 116 | GrExtend(other.GrExtend), |
14952 | fschmid | 117 | GrControl1(other.GrControl1), |
118 | GrControl2(other.GrControl2), |
||
119 | GrControl3(other.GrControl3), |
||
120 | GrControl4(other.GrControl4), |
||
14981 | fschmid | 121 | GrControl5(other.GrControl5), |
14952 | fschmid | 122 | GrColorP1(other.GrColorP1), |
123 | GrColorP2(other.GrColorP2), |
||
124 | GrColorP3(other.GrColorP3), |
||
125 | GrColorP4(other.GrColorP4), |
||
126 | GrCol1transp(other.GrCol1transp), |
||
127 | GrCol2transp(other.GrCol2transp), |
||
128 | GrCol3transp(other.GrCol3transp), |
||
129 | GrCol4transp(other.GrCol4transp), |
||
130 | GrCol1Shade(other.GrCol1Shade), |
||
131 | GrCol2Shade(other.GrCol2Shade), |
||
132 | GrCol3Shade(other.GrCol3Shade), |
||
133 | GrCol4Shade(other.GrCol4Shade), |
||
16729 | fschmid | 134 | meshGradientPatches(other.meshGradientPatches), |
15024 | fschmid | 135 | meshGradientArray(other.meshGradientArray), |
15517 | fschmid | 136 | selectedMeshPointX(other.selectedMeshPointX), |
137 | selectedMeshPointY(other.selectedMeshPointY), |
||
138 | selectedMeshControlPoint(other.selectedMeshControlPoint), |
||
16891 | fschmid | 139 | snapToPatchGrid(other.snapToPatchGrid), |
22832 | craig | 140 | m_columns(other.m_columns), |
141 | m_columnGap(other.m_columnGap), |
||
3903 | cbradney | 142 | PLineArt(other.PLineArt), |
3625 | avox | 143 | PLineEnd(other.PLineEnd), |
144 | PLineJoin(other.PLineJoin), |
||
145 | NamedLStyle(other.NamedLStyle), |
||
146 | Clip(other.Clip), |
||
147 | PoLine(other.PoLine), |
||
148 | ContourLine(other.ContourLine), |
||
149 | imageClip(other.imageClip), |
||
150 | Segments(other.Segments), |
||
151 | effectsInUse(other.effectsInUse), |
||
152 | PoShow(other.PoShow), |
||
153 | BaseOffs(other.BaseOffs), |
||
7926 | fschmid | 154 | textPathType(other.textPathType), |
155 | textPathFlipped(other.textPathFlipped), |
||
3625 | avox | 156 | ClipEdited(other.ClipEdited), |
157 | FrameType(other.FrameType), |
||
158 | OwnPage(other.OwnPage), |
||
159 | oldOwnPage(other.oldOwnPage), |
||
3903 | cbradney | 160 | pixm(other.pixm), |
161 | Pfile(other.Pfile), |
||
3625 | avox | 162 | Pfile2(other.Pfile2), |
163 | Pfile3(other.Pfile3), |
||
23488 | jghali | 164 | ImageProfile(other.ImageProfile), |
3625 | avox | 165 | UseEmbedded(other.UseEmbedded), |
23488 | jghali | 166 | EmbeddedProfile(other.EmbeddedProfile), |
167 | ImageIntent(other.ImageIntent), |
||
14444 | fschmid | 168 | OverrideCompressionMethod(other.OverrideCompressionMethod), |
169 | CompressionMethodIndex(other.CompressionMethodIndex), |
||
170 | OverrideCompressionQuality(other.OverrideCompressionQuality), |
||
171 | CompressionQualityIndex(other.CompressionQualityIndex), |
||
4621 | cbradney | 172 | |
19834 | craig | 173 | imageIsAvailable(other.imageIsAvailable), |
3625 | avox | 174 | OrigW(other.OrigW), |
175 | OrigH(other.OrigH), |
||
3903 | cbradney | 176 | BBoxX(other.BBoxX), |
177 | BBoxH(other.BBoxH), |
||
3625 | avox | 178 | CurX(other.CurX), |
179 | CurY(other.CurY), |
||
180 | itemText(other.itemText), |
||
18987 | avox | 181 | textLayout(&itemText, this), |
3903 | cbradney | 182 | isBookmark(other.isBookmark), |
183 | HasSel(other.HasSel), |
||
3625 | avox | 184 | isAutoText(other.isAutoText), |
5362 | avox | 185 | inPdfArticle(other.inPdfArticle), |
3625 | avox | 186 | isRaster(other.isRaster), |
187 | OldB(other.OldB), |
||
188 | OldH(other.OldH), |
||
189 | OldB2(other.OldB2), |
||
190 | OldH2(other.OldH2), |
||
191 | Sizing(other.Sizing), |
||
22832 | craig | 192 | m_layerID(other.m_layerID), |
3625 | avox | 193 | ScaleType(other.ScaleType), |
194 | AspectRatio(other.AspectRatio), |
||
195 | DashValues(other.DashValues), |
||
196 | DashOffset(other.DashOffset), |
||
197 | fill_gradient(other.fill_gradient), |
||
198 | fillRule(other.fillRule), |
||
5320 | fschmid | 199 | doOverprint(other.doOverprint), |
23049 | craig | 200 | m_leftLink(other.m_leftLink), |
201 | m_rightLink(other.m_rightLink), |
||
202 | m_topLink(other.m_topLink), |
||
203 | m_bottomLink(other.m_bottomLink), |
||
3625 | avox | 204 | LeftLinkID(other.LeftLinkID), |
205 | RightLinkID(other.RightLinkID), |
||
206 | TopLinkID(other.TopLinkID), |
||
207 | BottomLinkID(other.BottomLinkID), |
||
208 | LeftLine(other.LeftLine), |
||
209 | RightLine(other.RightLine), |
||
210 | TopLine(other.TopLine), |
||
211 | BottomLine(other.BottomLine), |
||
212 | isTableItem(other.isTableItem), |
||
213 | isSingleSel(other.isSingleSel), |
||
16105 | fschmid | 214 | groupItemList(other.groupItemList), |
215 | groupWidth(other.groupWidth), |
||
216 | groupHeight(other.groupHeight), |
||
3625 | avox | 217 | BoundingX(other.BoundingX), |
218 | BoundingY(other.BoundingY), |
||
219 | BoundingW(other.BoundingW), |
||
220 | BoundingH(other.BoundingH), |
||
221 | ChangedMasterItem(other.ChangedMasterItem), |
||
222 | OnMasterPage(other.OnMasterPage), |
||
223 | isEmbedded(other.isEmbedded), |
||
23370 | jghali | 224 | m_roundedCornerRadius(other.m_roundedCornerRadius), |
3988 | cbradney | 225 | oldXpos(other.oldXpos), |
226 | oldYpos(other.oldYpos), |
||
227 | oldWidth(other.oldWidth), |
||
4010 | cbradney | 228 | oldHeight(other.oldHeight), |
4073 | cbradney | 229 | oldRot(other.oldRot), |
4821 | cbradney | 230 | oldLocalScX(other.oldLocalScX), |
231 | oldLocalScY(other.oldLocalScY), |
||
232 | oldLocalX(other.oldLocalX), |
||
233 | oldLocalY(other.oldLocalY), |
||
4084 | cbradney | 234 | m_Doc(other.m_Doc), |
4621 | cbradney | 235 | m_lineWidth(other.m_lineWidth), |
23031 | jghali | 236 | m_oldLineWidth(other.m_oldLineWidth), |
14168 | fschmid | 237 | patternStrokeVal(other.patternStrokeVal), |
238 | patternStrokeScaleX(other.patternStrokeScaleX), |
||
239 | patternStrokeScaleY(other.patternStrokeScaleY), |
||
240 | patternStrokeOffsetX(other.patternStrokeOffsetX), |
||
241 | patternStrokeOffsetY(other.patternStrokeOffsetY), |
||
242 | patternStrokeRotation(other.patternStrokeRotation), |
||
14260 | fschmid | 243 | patternStrokeSkewX(other.patternStrokeSkewX), |
244 | patternStrokeSkewY(other.patternStrokeSkewY), |
||
14403 | fschmid | 245 | patternStrokeSpace(other.patternStrokeSpace), |
14276 | fschmid | 246 | patternStrokeMirrorX(other.patternStrokeMirrorX), |
247 | patternStrokeMirrorY(other.patternStrokeMirrorY), |
||
14398 | fschmid | 248 | patternStrokePath(other.patternStrokePath), |
14168 | fschmid | 249 | gradientStrokeVal(other.gradientStrokeVal), |
14213 | fschmid | 250 | stroke_gradient(other.stroke_gradient), |
14168 | fschmid | 251 | GrTypeStroke(other.GrTypeStroke), |
252 | GrStrokeStartX(other.GrStrokeStartX), |
||
253 | GrStrokeStartY(other.GrStrokeStartY), |
||
254 | GrStrokeEndX(other.GrStrokeEndX), |
||
14278 | fschmid | 255 | GrStrokeEndY(other.GrStrokeEndY), |
256 | GrStrokeFocalX(other.GrStrokeFocalX), |
||
257 | GrStrokeFocalY(other.GrStrokeFocalY), |
||
14284 | fschmid | 258 | GrStrokeScale(other.GrStrokeScale), |
14297 | fschmid | 259 | GrStrokeSkew(other.GrStrokeSkew), |
260 | GrMask(other.GrMask), |
||
261 | GrMaskStartX(other.GrMaskStartX), |
||
262 | GrMaskStartY(other.GrMaskStartY), |
||
263 | GrMaskEndX(other.GrMaskEndX), |
||
264 | GrMaskEndY(other.GrMaskEndY), |
||
265 | GrMaskFocalX(other.GrMaskFocalX), |
||
266 | GrMaskFocalY(other.GrMaskFocalY), |
||
267 | GrMaskScale(other.GrMaskScale), |
||
268 | GrMaskSkew(other.GrMaskSkew), |
||
269 | patternMaskScaleX(other.patternMaskScaleX), |
||
270 | patternMaskScaleY(other.patternMaskScaleY), |
||
271 | patternMaskOffsetX(other.patternMaskOffsetX), |
||
272 | patternMaskOffsetY(other.patternMaskOffsetY), |
||
273 | patternMaskRotation(other.patternMaskRotation), |
||
274 | patternMaskSkewX(other.patternMaskSkewX), |
||
275 | patternMaskSkewY(other.patternMaskSkewY), |
||
276 | patternMaskMirrorX(other.patternMaskMirrorX), |
||
277 | patternMaskMirrorY(other.patternMaskMirrorY), |
||
278 | patternMaskVal(other.patternMaskVal), |
||
18204 | fschmid | 279 | mask_gradient(other.mask_gradient), |
18935 | fschmid | 280 | hatchAngle(other.hatchAngle), |
281 | hatchDistance(other.hatchDistance), |
||
282 | hatchType(other.hatchType), |
||
283 | hatchUseBackground(other.hatchUseBackground), |
||
284 | hatchBackground(other.hatchBackground), |
||
285 | hatchForeground(other.hatchForeground), |
||
23618 | jghali | 286 | hatchBackgroundQ(other.hatchBackgroundQ), |
287 | hatchForegroundQ(other.hatchForegroundQ), |
||
18204 | fschmid | 288 | // protected |
289 | undoManager(other.undoManager), |
||
290 | firstChar(0), // since this box is unlinked now |
||
22832 | craig | 291 | m_maxChars(0), // since the layout is invalid now |
18204 | fschmid | 292 | m_sampleItem(false), |
293 | m_textDistanceMargins(other.m_textDistanceMargins), |
||
18889 | fschmid | 294 | verticalAlign(other.verticalAlign), |
23046 | jghali | 295 | m_itemType(other.m_itemType), |
22832 | craig | 296 | m_itemName(other.m_itemName), |
23866 | jghali | 297 | m_isAnnotation(other.m_isAnnotation), |
298 | m_annotation(other.m_annotation), |
||
23046 | jghali | 299 | m_gradientName(other.m_gradientName), |
300 | m_patternName(other.m_patternName), |
||
18204 | fschmid | 301 | patternScaleX(other.patternScaleX), |
302 | patternScaleY(other.patternScaleY), |
||
303 | patternOffsetX(other.patternOffsetX), |
||
304 | patternOffsetY(other.patternOffsetY), |
||
305 | patternRotation(other.patternRotation), |
||
306 | patternSkewX(other.patternSkewX), |
||
307 | patternSkewY(other.patternSkewY), |
||
308 | patternMirrorX(other.patternMirrorX), |
||
309 | patternMirrorY(other.patternMirrorY), |
||
23044 | jghali | 310 | m_fillColor(other.m_fillColor), |
311 | m_lineColor(other.m_lineColor), |
||
312 | m_lineShade(other.m_lineShade), |
||
313 | m_fillShade(other.m_fillShade), |
||
314 | m_fillTransparency(other.m_fillTransparency), |
||
315 | m_lineTransparency(other.m_lineTransparency), |
||
316 | m_fillBlendMode(other.m_fillBlendMode), |
||
317 | m_lineBlendMode(other.m_lineBlendMode), |
||
18204 | fschmid | 318 | m_ImageIsFlippedH(other.m_ImageIsFlippedH), |
319 | m_ImageIsFlippedV(other.m_ImageIsFlippedV), |
||
320 | m_Locked(other.m_Locked), |
||
321 | m_SizeLocked(other.m_SizeLocked), |
||
322 | m_SizeHLocked(other.m_SizeHLocked), |
||
323 | m_SizeVLocked(other.m_SizeVLocked), |
||
23044 | jghali | 324 | m_textFlowMode(other.m_textFlowMode), |
18204 | fschmid | 325 | pageItemAttributes(other.pageItemAttributes), |
326 | m_PrintEnabled(other.m_PrintEnabled), |
||
23046 | jghali | 327 | m_fillQColor(other.m_fillQColor), |
328 | m_strokeQColor(other.m_strokeQColor), |
||
329 | m_grQColorP1(other.m_grQColorP1), |
||
330 | m_grQColorP2(other.m_grQColorP2), |
||
331 | m_grQColorP3(other.m_grQColorP3), |
||
332 | m_grQColorP4(other.m_grQColorP4), |
||
18204 | fschmid | 333 | m_xPos(other.m_xPos), |
334 | m_yPos(other.m_yPos), |
||
335 | m_width(other.m_width), |
||
336 | m_height(other.m_height), |
||
337 | m_rotation(other.m_rotation), |
||
338 | m_isSelected(other.m_isSelected), |
||
23861 | jghali | 339 | m_imageVisible(other.m_imageVisible), |
18204 | fschmid | 340 | m_imageXScale(other.m_imageXScale), |
341 | m_imageYScale(other.m_imageYScale), |
||
342 | m_imageXOffset(other.m_imageXOffset), |
||
343 | m_imageYOffset(other.m_imageYOffset), |
||
344 | m_imageRotation(other.m_imageRotation), |
||
22799 | jghali | 345 | m_firstLineOffset(other.m_firstLineOffset), |
18935 | fschmid | 346 | m_groupClips(other.m_groupClips), |
23618 | jghali | 347 | m_startArrowIndex(other.m_startArrowIndex), |
348 | m_endArrowIndex(other.m_endArrowIndex), |
||
349 | m_startArrowScale(other.m_startArrowScale), |
||
350 | m_endArrowScale(other.m_endArrowScale), |
||
351 | m_hasSoftShadow(other.m_hasSoftShadow), |
||
352 | m_softShadowColor(other.m_softShadowColor), |
||
353 | m_softShadowShade(other.m_softShadowShade), |
||
354 | m_softShadowBlurRadius(other.m_softShadowBlurRadius), |
||
355 | m_softShadowXOffset(other.m_softShadowXOffset), |
||
356 | m_softShadowYOffset(other.m_softShadowYOffset), |
||
357 | m_softShadowOpacity(other.m_softShadowOpacity), |
||
358 | m_softShadowBlendMode(other.m_softShadowBlendMode), |
||
359 | m_softShadowErasedByObject(other.m_softShadowErasedByObject), |
||
360 | m_softShadowHasObjectTransparency(other.m_softShadowHasObjectTransparency) |
||
3625 | avox | 361 | { |
7068 | fschmid | 362 | QString tmp; |
22385 | jghali | 363 | m_imageVisible = m_Doc->guidesPrefs().showPic; |
7068 | fschmid | 364 | m_Doc->TotalItems++; |
22385 | jghali | 365 | |
22832 | craig | 366 | QString oldName(m_itemName); |
22385 | jghali | 367 | int nameNum = m_Doc->TotalItems; |
22832 | craig | 368 | m_itemName += tmp.setNum(m_Doc->TotalItems); |
369 | while (m_Doc->itemNameExists(m_itemName)) |
||
22385 | jghali | 370 | { |
371 | ++nameNum; |
||
22832 | craig | 372 | m_itemName = oldName + tmp.setNum(nameNum); |
22385 | jghali | 373 | } |
374 | |||
7068 | fschmid | 375 | uniqueNr = m_Doc->TotalItems; |
8047 | avox | 376 | invalid = true; |
12795 | fschmid | 377 | if (other.isInlineImage) |
378 | { |
||
379 | QFileInfo inlFi(Pfile); |
||
380 | QString ext = inlFi.suffix(); |
||
18203 | fschmid | 381 | QTemporaryFile *tempFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_XXXXXX." + ext); |
382 | tempFile->setAutoRemove(false); |
||
383 | tempFile->open(); |
||
384 | QString fileName = getLongPathName(tempFile->fileName()); |
||
385 | tempFile->close(); |
||
12795 | fschmid | 386 | copyFile(Pfile, fileName); |
387 | Pfile = fileName; |
||
18203 | fschmid | 388 | delete tempFile; |
12795 | fschmid | 389 | isInlineImage = true; |
18203 | fschmid | 390 | isTempFile = true; |
12795 | fschmid | 391 | } |
392 | else |
||
393 | { |
||
394 | isInlineImage = false; |
||
18203 | fschmid | 395 | isTempFile = false; |
12795 | fschmid | 396 | } |
22516 | craig | 397 | Parent = nullptr; |
16926 | fschmid | 398 | unWeld(); |
3625 | avox | 399 | } |
400 | |||
401 | |||
23912 | craig | 402 | PageItem::PageItem(ScribusDoc *doc, ItemType newType, double x, double y, double w, double h, double w2, const QString& fill, const QString& outline) |
4061 | craig | 403 | // Initialize superclass(es) |
23912 | craig | 404 | : QObject(doc), SingleObservable<PageItem>(doc->itemsChanged()), TextContext(this), |
4061 | craig | 405 | // Initialize member variables |
23912 | craig | 406 | itemText(doc), |
18987 | avox | 407 | textLayout(&itemText, this), |
23912 | craig | 408 | undoManager(UndoManager::instance()) |
3 | paul | 409 | { |
23912 | craig | 410 | m_Doc = doc; |
3 | paul | 411 | QString tmp; |
18032 | craig | 412 | gXpos = oldXpos = m_xPos = x; |
413 | gYpos = oldYpos = m_yPos = y; |
||
4821 | cbradney | 414 | //CB Surely we can remove some of these? |
18095 | craig | 415 | OldB2 = OldB = oldWidth = m_width = w; |
416 | OldH2 = OldH = oldHeight = m_height = h; |
||
456 | fschmid | 417 | BoundingX = x; |
418 | BoundingY = y; |
||
419 | BoundingW = w; |
||
420 | BoundingH = h; |
||
23046 | jghali | 421 | m_itemType = newType; |
23044 | jghali | 422 | m_fillColor = fill; |
23046 | jghali | 423 | m_lineColor = m_itemType == PageItem::TextFrame ? fill : outline; |
294 | Franz | 424 | GrEndX = w; |
23912 | craig | 425 | |
14952 | fschmid | 426 | GrControl2 = FPoint(w, 0); |
427 | GrControl3 = FPoint(w, h); |
||
428 | GrControl4 = FPoint(0, h); |
||
14981 | fschmid | 429 | GrControl5 = FPoint(w / 2.0, h / 2.0); |
14168 | fschmid | 430 | GrStrokeEndX = w; |
4580 | cbradney | 431 | m_lineWidth = w2; |
23031 | jghali | 432 | m_oldLineWidth = w2; |
14932 | cbradney | 433 | PLineArt = Qt::PenStyle(m_Doc->itemToolPrefs().shapeLineStyle); |
8522 | cbradney | 434 | PLineEnd = Qt::FlatCap; |
435 | PLineJoin = Qt::MiterJoin; |
||
24217 | jghali | 436 | m_textDistanceMargins = m_Doc->itemToolPrefs().textDistances; |
14932 | cbradney | 437 | pixm.imgInfo.lowResType = m_Doc->itemToolPrefs().imageLowResType; |
23046 | jghali | 438 | switch (m_itemType) |
167 | Franz | 439 | { |
1460 | cbradney | 440 | case Polygon: |
23413 | jghali | 441 | Clip.setPoints(4, static_cast<int>(w / 2), 0, static_cast<int>(w), static_cast<int>(h / 2), |
442 | static_cast<int>(w / 2), static_cast<int>(h), 0, static_cast<int>(h / 2)); |
||
3 | paul | 443 | break; |
444 | default: |
||
23413 | jghali | 445 | 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 | 446 | break; |
167 | Franz | 447 | } |
13888 | jghali | 448 | OwnPage = m_Doc->currentPage() ? m_Doc->currentPage()->pageNr() : -1; |
1211 | tsoots | 449 | oldOwnPage = OwnPage; |
4401 | fschmid | 450 | savedOwnPage = OwnPage; |
19834 | craig | 451 | m_imageVisible = m_Doc->guidesPrefs().showPic; |
10321 | mrdocs | 452 | |
23046 | jghali | 453 | switch (m_itemType) |
268 | Franz | 454 | { |
23912 | craig | 455 | case ImageFrame: |
456 | case OSGFrame: |
||
457 | case LatexFrame: |
||
458 | //We can't determine if this is a latex frame here |
||
459 | // because c++'s typeinfos are still saying it's |
||
460 | // a plain pageitem |
||
461 | // This is fixed in the PageItem_LatexFrame constructor |
||
462 | m_itemName = tr("Image"); |
||
463 | setUPixmap(Um::IImageFrame); |
||
464 | break; |
||
465 | case TextFrame: |
||
466 | m_itemName = tr("Text"); |
||
467 | setUPixmap(Um::ITextFrame); |
||
468 | break; |
||
469 | case Line: |
||
470 | m_itemName = tr("Line"); |
||
471 | setUPixmap(Um::ILine); |
||
472 | break; |
||
473 | case Polygon: |
||
474 | m_itemName = tr("Polygon"); |
||
475 | setUPixmap(Um::IPolygon); |
||
476 | break; |
||
477 | case PolyLine: |
||
478 | m_itemName = tr("Polyline"); |
||
479 | setUPixmap(Um::IPolyline); |
||
480 | break; |
||
481 | case PathText: |
||
482 | m_itemName = tr("PathText"); |
||
483 | setUPixmap(Um::IPathText); |
||
484 | break; |
||
485 | case Symbol: |
||
486 | m_itemName = tr("Symbol"); |
||
487 | setUPixmap(Um::IPolygon); |
||
488 | break; |
||
489 | case Group: |
||
490 | m_itemName = tr("Group"); |
||
491 | setUPixmap(Um::IPolygon); |
||
492 | break; |
||
493 | case RegularPolygon: |
||
494 | m_itemName = tr("RegularPolygon"); |
||
495 | setUPixmap(Um::IPolygon); |
||
496 | break; |
||
497 | case Arc: |
||
498 | m_itemName = tr("Arc"); |
||
499 | setUPixmap(Um::IPolygon); |
||
500 | break; |
||
501 | case Spiral: |
||
502 | m_itemName = tr("Spiral"); |
||
503 | setUPixmap(Um::IPolygon); |
||
504 | break; |
||
505 | case Table: |
||
506 | m_itemName = tr("Table"); |
||
507 | //setUPixmap(Um::IPolygon); // TODO: Fix this. |
||
508 | break; |
||
509 | default: |
||
510 | m_itemName = "Item"; |
||
511 | break; |
||
268 | Franz | 512 | } |
4939 | fschmid | 513 | m_Doc->TotalItems++; |
22385 | jghali | 514 | |
22832 | craig | 515 | QString oldName(m_itemName); |
22385 | jghali | 516 | int nameNum = m_Doc->TotalItems; |
22832 | craig | 517 | m_itemName += tmp.setNum(m_Doc->TotalItems); |
518 | while (m_Doc->itemNameExists(m_itemName)) |
||
22385 | jghali | 519 | { |
520 | ++nameNum; |
||
22832 | craig | 521 | m_itemName = oldName + tmp.setNum(nameNum); |
22385 | jghali | 522 | } |
523 | |||
7068 | fschmid | 524 | uniqueNr = m_Doc->TotalItems; |
22832 | craig | 525 | setUName(m_itemName); |
4084 | cbradney | 526 | m_annotation.setBorderColor(outline); |
16961 | fschmid | 527 | // toPixmap = false; |
23488 | jghali | 528 | ImageIntent = Intent_Relative_Colorimetric; |
22832 | craig | 529 | m_layerID = m_Doc->activeLayer(); |
14168 | fschmid | 530 | stroke_gradient = VGradient(VGradient::linear); |
531 | stroke_gradient.clearStops(); |
||
23044 | jghali | 532 | if (m_lineColor != CommonStrings::None) |
14168 | fschmid | 533 | { |
23044 | jghali | 534 | const ScColor& col = m_Doc->PageColors[m_lineColor]; |
14168 | fschmid | 535 | QColor qcol = ScColorEngine::getRGBColor(col, m_Doc); |
23044 | jghali | 536 | stroke_gradient.addStop(qcol, 0.0, 0.5, 1.0, m_lineColor, 100); |
537 | stroke_gradient.addStop(qcol, 1.0, 0.5, 1.0, m_lineColor, 100); |
||
14168 | fschmid | 538 | } |
539 | else |
||
540 | { |
||
14932 | cbradney | 541 | if (m_Doc->itemToolPrefs().shapeLineColor != CommonStrings::None) |
14168 | fschmid | 542 | { |
14932 | cbradney | 543 | const ScColor& col = m_Doc->PageColors[m_Doc->itemToolPrefs().shapeLineColor]; |
14168 | fschmid | 544 | QColor qcol = ScColorEngine::getRGBColor(col, m_Doc); |
14932 | cbradney | 545 | stroke_gradient.addStop(qcol, 0.0, 0.5, 1.0, m_Doc->itemToolPrefs().shapeLineColor, 100); |
546 | stroke_gradient.addStop(qcol, 1.0, 0.5, 1.0, m_Doc->itemToolPrefs().shapeLineColor, 100); |
||
14168 | fschmid | 547 | } |
548 | else |
||
549 | { |
||
23044 | jghali | 550 | if (m_fillColor != CommonStrings::None) |
14168 | fschmid | 551 | { |
23044 | jghali | 552 | const ScColor& col = m_Doc->PageColors[m_fillColor]; |
14168 | fschmid | 553 | QColor qcol = ScColorEngine::getRGBColor(col, m_Doc); |
23044 | jghali | 554 | stroke_gradient.addStop(qcol, 0.0, 0.5, 1.0, m_fillColor, 100); |
555 | stroke_gradient.addStop(qcol, 1.0, 0.5, 1.0, m_fillColor, 100); |
||
14168 | fschmid | 556 | } |
557 | else |
||
558 | { |
||
19630 | jghali | 559 | if (m_Doc->itemToolPrefs().shapeFillColor != CommonStrings::None) |
14168 | fschmid | 560 | { |
14932 | cbradney | 561 | const ScColor& col = m_Doc->PageColors[m_Doc->itemToolPrefs().shapeFillColor]; |
14168 | fschmid | 562 | QColor qcol = ScColorEngine::getRGBColor(col, m_Doc); |
14932 | cbradney | 563 | stroke_gradient.addStop(qcol, 0.0, 0.5, 1.0, m_Doc->itemToolPrefs().shapeFillColor, 100); |
564 | stroke_gradient.addStop(qcol, 1.0, 0.5, 1.0, m_Doc->itemToolPrefs().shapeFillColor, 100); |
||
14168 | fschmid | 565 | } |
566 | else if (m_Doc->PageColors.contains("Black")) |
||
567 | { |
||
568 | const ScColor& col = m_Doc->PageColors["Black"]; |
||
569 | QColor qcol = ScColorEngine::getRGBColor(col, m_Doc); |
||
570 | stroke_gradient.addStop(qcol, 0.0, 0.5, 1.0, "Black", 100); |
||
571 | stroke_gradient.addStop(qcol, 1.0, 0.5, 1.0, "Black", 100); |
||
572 | } |
||
573 | } |
||
574 | } |
||
575 | } |
||
68 | Franz | 576 | fill_gradient = VGradient(VGradient::linear); |
295 | Franz | 577 | fill_gradient.clearStops(); |
23044 | jghali | 578 | if (m_fillColor != CommonStrings::None) |
7478 | jghali | 579 | { |
23044 | jghali | 580 | const ScColor& col = m_Doc->PageColors[m_fillColor]; |
12642 | jghali | 581 | QColor qcol = ScColorEngine::getRGBColor(col, m_Doc); |
23044 | jghali | 582 | fill_gradient.addStop(qcol, 0.0, 0.5, 1.0, m_fillColor, 100); |
583 | fill_gradient.addStop(qcol, 1.0, 0.5, 1.0, m_fillColor, 100); |
||
584 | GrColorP1 = m_fillColor; |
||
585 | GrColorP2 = m_fillColor; |
||
586 | GrColorP3 = m_fillColor; |
||
587 | GrColorP4 = m_fillColor; |
||
7478 | jghali | 588 | } |
304 | Franz | 589 | else |
7478 | jghali | 590 | { |
14932 | cbradney | 591 | if (m_Doc->itemToolPrefs().shapeFillColor != CommonStrings::None) |
7656 | fschmid | 592 | { |
14932 | cbradney | 593 | const ScColor& col = m_Doc->PageColors[m_Doc->itemToolPrefs().shapeFillColor]; |
12642 | jghali | 594 | QColor qcol = ScColorEngine::getRGBColor(col, m_Doc); |
14932 | cbradney | 595 | fill_gradient.addStop(qcol, 0.0, 0.5, 1.0, m_Doc->itemToolPrefs().shapeFillColor, 100); |
596 | fill_gradient.addStop(qcol, 1.0, 0.5, 1.0, m_Doc->itemToolPrefs().shapeFillColor, 100); |
||
14952 | fschmid | 597 | GrColorP1 = m_Doc->itemToolPrefs().shapeFillColor; |
598 | GrColorP2 = m_Doc->itemToolPrefs().shapeFillColor; |
||
599 | GrColorP3 = m_Doc->itemToolPrefs().shapeFillColor; |
||
600 | GrColorP4 = m_Doc->itemToolPrefs().shapeFillColor; |
||
7656 | fschmid | 601 | } |
602 | else |
||
603 | { |
||
23044 | jghali | 604 | if (m_lineColor != CommonStrings::None) |
7656 | fschmid | 605 | { |
23044 | jghali | 606 | const ScColor& col = m_Doc->PageColors[m_lineColor]; |
12642 | jghali | 607 | QColor qcol = ScColorEngine::getRGBColor(col, m_Doc); |
23044 | jghali | 608 | fill_gradient.addStop(qcol, 0.0, 0.5, 1.0, m_lineColor, 100); |
609 | fill_gradient.addStop(qcol, 1.0, 0.5, 1.0, m_lineColor, 100); |
||
610 | GrColorP1 = m_lineColor; |
||
611 | GrColorP2 = m_lineColor; |
||
612 | GrColorP3 = m_lineColor; |
||
613 | GrColorP4 = m_lineColor; |
||
7656 | fschmid | 614 | } |
615 | else |
||
616 | { |
||
14932 | cbradney | 617 | if (m_Doc->itemToolPrefs().shapeLineColor != CommonStrings::None) |
7656 | fschmid | 618 | { |
14932 | cbradney | 619 | const ScColor& col = m_Doc->PageColors[m_Doc->itemToolPrefs().shapeLineColor]; |
12642 | jghali | 620 | QColor qcol = ScColorEngine::getRGBColor(col, m_Doc); |
14932 | cbradney | 621 | fill_gradient.addStop(qcol, 0.0, 0.5, 1.0, m_Doc->itemToolPrefs().shapeLineColor, 100); |
622 | fill_gradient.addStop(qcol, 1.0, 0.5, 1.0, m_Doc->itemToolPrefs().shapeLineColor, 100); |
||
14952 | fschmid | 623 | GrColorP1 = m_Doc->itemToolPrefs().shapeLineColor; |
624 | GrColorP2 = m_Doc->itemToolPrefs().shapeLineColor; |
||
625 | GrColorP3 = m_Doc->itemToolPrefs().shapeLineColor; |
||
626 | GrColorP4 = m_Doc->itemToolPrefs().shapeLineColor; |
||
7656 | fschmid | 627 | } |
12642 | jghali | 628 | else if (m_Doc->PageColors.contains("Black")) |
629 | { |
||
630 | const ScColor& col = m_Doc->PageColors["Black"]; |
||
631 | QColor qcol = ScColorEngine::getRGBColor(col, m_Doc); |
||
632 | fill_gradient.addStop(qcol, 0.0, 0.5, 1.0, "Black", 100); |
||
633 | fill_gradient.addStop(qcol, 1.0, 0.5, 1.0, "Black", 100); |
||
14952 | fschmid | 634 | GrColorP1 = "Black"; |
635 | GrColorP2 = "Black"; |
||
636 | GrColorP3 = "Black"; |
||
637 | GrColorP4 = "Black"; |
||
12642 | jghali | 638 | } |
7656 | fschmid | 639 | } |
640 | } |
||
7478 | jghali | 641 | } |
14297 | fschmid | 642 | GrMaskEndX = w; |
643 | mask_gradient = VGradient(VGradient::linear); |
||
24174 | jghali | 644 | mask_gradient.clearStops(); |
14297 | fschmid | 645 | const ScColor& col = m_Doc->PageColors["Black"]; |
646 | QColor qcol = ScColorEngine::getRGBColor(col, m_Doc); |
||
647 | mask_gradient.addStop(qcol, 0.0, 0.5, 1.0, "Black", 100); |
||
648 | mask_gradient.addStop(qcol, 1.0, 0.5, 1.0, "Black", 100); |
||
15024 | fschmid | 649 | |
22296 | craig | 650 | QList<MeshPoint> mgList; |
651 | MeshPoint mgP; |
||
16869 | fschmid | 652 | meshGradientPatch patch; |
653 | mgP.resetTo(FPoint(0.0, 0.0)); |
||
15024 | fschmid | 654 | mgP.transparency = 1.0; |
655 | mgP.shade = 100; |
||
656 | mgP.colorName = "Black"; |
||
657 | mgP.color = qcol; |
||
658 | mgList.append(mgP); |
||
16869 | fschmid | 659 | patch.TL = mgP; |
18095 | craig | 660 | mgP.resetTo(FPoint(m_width / 2.0, 0.0)); |
15024 | fschmid | 661 | mgList.append(mgP); |
18095 | craig | 662 | mgP.resetTo(FPoint(m_width, 0.0)); |
15024 | fschmid | 663 | mgList.append(mgP); |
16869 | fschmid | 664 | patch.TR = mgP; |
15024 | fschmid | 665 | meshGradientArray.append(mgList); |
666 | mgList.clear(); |
||
18095 | craig | 667 | mgP.resetTo(FPoint(0.0, m_height / 2.0)); |
15024 | fschmid | 668 | mgList.append(mgP); |
18095 | craig | 669 | mgP.resetTo(FPoint(m_width / 2.0, m_height / 2.0)); |
15024 | fschmid | 670 | mgList.append(mgP); |
18095 | craig | 671 | mgP.resetTo(FPoint(m_width, m_height / 2.0)); |
15024 | fschmid | 672 | mgList.append(mgP); |
673 | meshGradientArray.append(mgList); |
||
674 | mgList.clear(); |
||
18095 | craig | 675 | mgP.resetTo(FPoint(0.0, m_height)); |
15024 | fschmid | 676 | mgList.append(mgP); |
16869 | fschmid | 677 | patch.BL = mgP; |
18095 | craig | 678 | mgP.resetTo(FPoint(m_width / 2.0, m_height)); |
15024 | fschmid | 679 | mgList.append(mgP); |
18095 | craig | 680 | mgP.resetTo(FPoint(m_width, m_height)); |
15024 | fschmid | 681 | mgList.append(mgP); |
16869 | fschmid | 682 | patch.BR = mgP; |
15024 | fschmid | 683 | meshGradientArray.append(mgList); |
16869 | fschmid | 684 | meshGradientPatches.append(patch); |
15024 | fschmid | 685 | |
24217 | jghali | 686 | m_firstLineOffset = m_Doc->itemToolPrefs().firstLineOffset; |
22832 | craig | 687 | m_columns = m_Doc->itemToolPrefs().textColumns; |
688 | m_columnGap = m_Doc->itemToolPrefs().textColumnGap; |
||
23912 | craig | 689 | |
13888 | jghali | 690 | OnMasterPage = m_Doc->currentPage() ? m_Doc->currentPage()->pageName() : QString(); |
14932 | cbradney | 691 | m_startArrowIndex = m_Doc->itemToolPrefs().lineStartArrow; |
692 | m_endArrowIndex = m_Doc->itemToolPrefs().lineEndArrow; |
||
2056 | fschmid | 693 | effectsInUse.clear(); |
24217 | jghali | 694 | |
1659 | cbradney | 695 | //Page Item Attributes |
696 | pageItemAttributes.clear(); |
||
24217 | jghali | 697 | for (const ObjectAttribute& objAttr : qAsConst(m_Doc->itemAttributes())) |
1659 | cbradney | 698 | { |
24217 | jghali | 699 | if ((objAttr.autoaddto == "textframes" && m_itemType == TextFrame) || |
700 | (objAttr.autoaddto == "imageframes" && m_itemType == ImageFrame)) |
||
701 | { |
||
702 | pageItemAttributes.append(objAttr); |
||
703 | } |
||
1659 | cbradney | 704 | } |
24217 | jghali | 705 | |
18935 | fschmid | 706 | hatchBackground = CommonStrings::None; |
707 | hatchBackgroundQ = QColor(); |
||
708 | hatchForeground = "Black"; |
||
709 | hatchForegroundQ = qcol; |
||
3 | paul | 710 | } |
711 | |||
17826 | craig | 712 | PageItem::~PageItem() |
713 | { |
||
18203 | fschmid | 714 | if ((isTempFile) && (!Pfile.isEmpty())) |
715 | QFile::remove(Pfile); |
||
17826 | craig | 716 | //remove marks |
717 | |||
718 | if (isTextFrame()) |
||
719 | { |
||
24518 | jghali | 720 | if (!asTextFrame()->isInChain() && itemText.length() > 0) |
17826 | craig | 721 | { |
24518 | jghali | 722 | for (int pos = 0; pos < itemText.length(); ++pos) |
17826 | craig | 723 | { |
19641 | craig | 724 | if (itemText.hasMark(pos)) |
17826 | craig | 725 | { |
19641 | craig | 726 | Mark* mrk = itemText.mark(pos); |
18047 | craig | 727 | if (!mrk->isType(MARKBullNumType)) |
728 | m_Doc->eraseMark(mrk); |
||
17826 | craig | 729 | } |
730 | } |
||
731 | } |
||
732 | } |
||
733 | // if (isWeld()) |
||
734 | // unWeldFromMaster(true); |
||
735 | // if (isWelded()) |
||
736 | // unWeldChild(); |
||
737 | } |
||
738 | |||
24417 | jghali | 739 | bool PageItem::isMasterItem() const |
740 | { |
||
741 | if (Parent == nullptr) |
||
742 | return !OnMasterPage.isEmpty(); |
||
743 | |||
744 | PageItem* parentItem = Parent; |
||
745 | while (parentItem && parentItem->Parent) |
||
746 | parentItem = parentItem->Parent; |
||
747 | return !parentItem->OnMasterPage.isEmpty(); |
||
748 | } |
||
749 | |||
18794 | jghali | 750 | bool PageItem::isGroupChild() const |
751 | { |
||
22516 | craig | 752 | return (dynamic_cast<PageItem_Group*>(Parent) != nullptr); |
18794 | jghali | 753 | } |
754 | |||
755 | bool PageItem::isTableCell() const |
||
756 | { |
||
22516 | craig | 757 | return (dynamic_cast<PageItem_Table*>(Parent) != nullptr); |
18794 | jghali | 758 | } |
759 | |||
4644 | cbradney | 760 | void PageItem::setXPos(const double newXPos, bool drawingOnly) |
3903 | cbradney | 761 | { |
18032 | craig | 762 | m_xPos = newXPos; |
4644 | cbradney | 763 | if (drawingOnly || m_Doc->isLoading()) |
764 | return; |
||
4621 | cbradney | 765 | checkChanges(); |
3903 | cbradney | 766 | } |
767 | |||
4644 | cbradney | 768 | void PageItem::setYPos(const double newYPos, bool drawingOnly) |
3903 | cbradney | 769 | { |
18032 | craig | 770 | m_yPos = newYPos; |
4644 | cbradney | 771 | if (drawingOnly || m_Doc->isLoading()) |
772 | return; |
||
4621 | cbradney | 773 | checkChanges(); |
3903 | cbradney | 774 | } |
775 | |||
4644 | cbradney | 776 | void PageItem::setXYPos(const double newXPos, const double newYPos, bool drawingOnly) |
3903 | cbradney | 777 | { |
18032 | craig | 778 | m_xPos = newXPos; |
779 | m_yPos = newYPos; |
||
4644 | cbradney | 780 | if (drawingOnly || m_Doc->isLoading()) |
781 | return; |
||
4621 | cbradney | 782 | checkChanges(); |
3934 | cbradney | 783 | } |
784 | |||
18357 | jghali | 785 | int PageItem::level() const |
17092 | jghali | 786 | { |
18357 | jghali | 787 | PageItem* thisItem = const_cast<PageItem*>(this); |
22832 | craig | 788 | if (isGroupChild()) |
789 | return (Parent->asGroupFrame()->groupItemList.indexOf(thisItem) + 1); |
||
790 | if (!m_Doc) |
||
17092 | jghali | 791 | return 0; |
22832 | craig | 792 | QList<PageItem*>* items = OnMasterPage.isEmpty() ? &m_Doc->DocItems : &m_Doc->MasterItems; |
793 | return (items->indexOf(thisItem) + 1); |
||
17092 | jghali | 794 | } |
795 | |||
4644 | cbradney | 796 | void PageItem::moveBy(const double dX, const double dY, bool drawingOnly) |
3934 | cbradney | 797 | { |
24467 | jghali | 798 | //qDebug() << "pageitem::moveby" << dX << dY; |
3934 | cbradney | 799 | if (dX==0.0 && dY==0.0) |
800 | return; |
||
12820 | pierre | 801 | invalid = true; |
24587 | jghali | 802 | if (dX != 0.0) |
16115 | fschmid | 803 | { |
19220 | jghali | 804 | m_xPos += dX; |
805 | gXpos += dX; |
||
806 | BoundingX += dX; |
||
16115 | fschmid | 807 | } |
24587 | jghali | 808 | if (dY != 0.0) |
16115 | fschmid | 809 | { |
19220 | jghali | 810 | m_yPos += dY; |
811 | gYpos += dY; |
||
812 | BoundingY += dY; |
||
16115 | fschmid | 813 | } |
4644 | cbradney | 814 | if (drawingOnly || m_Doc->isLoading()) |
815 | return; |
||
17826 | craig | 816 | moveWelded(dX, dY); |
4621 | cbradney | 817 | checkChanges(); |
3903 | cbradney | 818 | } |
819 | |||
23025 | craig | 820 | void PageItem::setWidth(double newWidth) |
3934 | cbradney | 821 | { |
18095 | craig | 822 | m_width = newWidth; |
13013 | fschmid | 823 | updateConstants(); |
14681 | fschmid | 824 | if (m_Doc->isLoading()) |
825 | return; |
||
4621 | cbradney | 826 | checkChanges(); |
3934 | cbradney | 827 | } |
828 | |||
23025 | craig | 829 | void PageItem::setHeight(double newHeight) |
3934 | cbradney | 830 | { |
18095 | craig | 831 | m_height = newHeight; |
13013 | fschmid | 832 | updateConstants(); |
14681 | fschmid | 833 | if (m_Doc->isLoading()) |
834 | return; |
||
4621 | cbradney | 835 | checkChanges(); |
3934 | cbradney | 836 | } |
837 | |||
23025 | craig | 838 | void PageItem::setWidthHeight(double newWidth, double newHeight, bool drawingOnly) |
8418 | fschmid | 839 | { |
18095 | craig | 840 | m_width = newWidth; |
841 | m_height = newHeight; |
||
13013 | fschmid | 842 | updateConstants(); |
8418 | fschmid | 843 | if (drawingOnly) |
844 | return; |
||
845 | checkChanges(); |
||
846 | } |
||
847 | |||
3934 | cbradney | 848 | void PageItem::setWidthHeight(const double newWidth, const double newHeight) |
849 | { |
||
18095 | craig | 850 | m_width = newWidth; |
851 | m_height = newHeight; |
||
13013 | fschmid | 852 | updateConstants(); |
14681 | fschmid | 853 | if (m_Doc->isLoading()) |
854 | return; |
||
4621 | cbradney | 855 | checkChanges(); |
3934 | cbradney | 856 | } |
857 | |||
858 | void PageItem::resizeBy(const double dH, const double dW) |
||
859 | { |
||
23257 | jghali | 860 | if (dH == 0.0 && dW == 0.0) |
3934 | cbradney | 861 | return; |
23257 | jghali | 862 | if (dH != 0.0) |
863 | m_width += dH; |
||
864 | if (dW != 0.0) |
||
865 | m_height += dW; |
||
13013 | fschmid | 866 | updateConstants(); |
14681 | fschmid | 867 | if (m_Doc->isLoading()) |
868 | return; |
||
4621 | cbradney | 869 | checkChanges(); |
3934 | cbradney | 870 | } |
871 | |||
4663 | cbradney | 872 | void PageItem::setRotation(const double newRotation, bool drawingOnly) |
3934 | cbradney | 873 | { |
18022 | craig | 874 | double dR = newRotation - m_rotation; |
875 | double oldRot = m_rotation; |
||
876 | m_rotation = newRotation; |
||
21386 | jghali | 877 | while (m_rotation < 0.0) |
878 | m_rotation += 360.0; |
||
879 | while (m_rotation > 360.0) |
||
880 | m_rotation -= 360.0; |
||
4663 | cbradney | 881 | if (drawingOnly || m_Doc->isLoading()) |
882 | return; |
||
17826 | craig | 883 | rotateWelded(dR, oldRot); |
14681 | fschmid | 884 | checkChanges(); |
3934 | cbradney | 885 | } |
886 | |||
887 | void PageItem::rotateBy(const double dR) |
||
888 | { |
||
889 | if (dR==0.0) |
||
890 | return; |
||
21386 | jghali | 891 | m_rotation += dR; |
892 | while (m_rotation < 0.0) |
||
893 | m_rotation += 360.0; |
||
894 | while (m_rotation > 360.0) |
||
895 | m_rotation -= 360.0; |
||
14681 | fschmid | 896 | if (m_Doc->isLoading()) |
897 | return; |
||
4621 | cbradney | 898 | checkChanges(); |
3934 | cbradney | 899 | } |
900 | |||
901 | void PageItem::setSelected(const bool toSelect) |
||
902 | { |
||
18022 | craig | 903 | m_isSelected=toSelect; |
3934 | cbradney | 904 | } |
905 | |||
3988 | cbradney | 906 | void PageItem::setImageXScale(const double newImageXScale) |
3985 | cbradney | 907 | { |
19263 | jghali | 908 | m_imageXScale = newImageXScale; |
14681 | fschmid | 909 | if (m_Doc->isLoading()) |
19263 | jghali | 910 | { |
911 | oldLocalScX = m_imageXScale; |
||
14681 | fschmid | 912 | return; |
19263 | jghali | 913 | } |
4821 | cbradney | 914 | checkChanges(); |
3985 | cbradney | 915 | } |
916 | |||
917 | void PageItem::setImageYScale(const double newImageYScale) |
||
918 | { |
||
19263 | jghali | 919 | m_imageYScale = newImageYScale; |
14681 | fschmid | 920 | if (m_Doc->isLoading()) |
19263 | jghali | 921 | { |
922 | oldLocalScY = m_imageYScale; |
||
14681 | fschmid | 923 | return; |
19263 | jghali | 924 | } |
4821 | cbradney | 925 | checkChanges(); |
3985 | cbradney | 926 | } |
927 | |||
928 | void PageItem::setImageXYScale(const double newImageXScale, const double newImageYScale) |
||
929 | { |
||
19263 | jghali | 930 | m_imageXScale = newImageXScale; |
931 | m_imageYScale = newImageYScale; |
||
14681 | fschmid | 932 | if (m_Doc->isLoading()) |
19263 | jghali | 933 | { |
934 | oldLocalScX = m_imageXScale; |
||
935 | oldLocalScY = m_imageYScale; |
||
14681 | fschmid | 936 | return; |
19263 | jghali | 937 | } |
4821 | cbradney | 938 | checkChanges(); |
3985 | cbradney | 939 | } |
940 | |||
3988 | cbradney | 941 | void PageItem::setImageXOffset(const double newImageXOffset) |
3985 | cbradney | 942 | { |
19263 | jghali | 943 | m_imageXOffset = newImageXOffset; |
14681 | fschmid | 944 | if (m_Doc->isLoading()) |
19263 | jghali | 945 | { |
946 | oldLocalX = m_imageXOffset; |
||
14681 | fschmid | 947 | return; |
19263 | jghali | 948 | } |
4821 | cbradney | 949 | checkChanges(); |
3985 | cbradney | 950 | } |
951 | |||
952 | void PageItem::setImageYOffset(const double newImageYOffset) |
||
953 | { |
||
19263 | jghali | 954 | m_imageYOffset = newImageYOffset; |
14681 | fschmid | 955 | if (m_Doc->isLoading()) |
19263 | jghali | 956 | { |
957 | oldLocalY = m_imageYOffset; |
||
14681 | fschmid | 958 | return; |
19263 | jghali | 959 | } |
4821 | cbradney | 960 | checkChanges(); |
3985 | cbradney | 961 | } |
962 | |||
963 | void PageItem::setImageXYOffset(const double newImageXOffset, const double newImageYOffset) |
||
964 | { |
||
19263 | jghali | 965 | m_imageXOffset = newImageXOffset; |
966 | m_imageYOffset = newImageYOffset; |
||
14681 | fschmid | 967 | if (m_Doc->isLoading()) |
19263 | jghali | 968 | { |
969 | oldLocalX = m_imageXOffset; |
||
970 | oldLocalY = m_imageYOffset; |
||
14681 | fschmid | 971 | return; |
19263 | jghali | 972 | } |
4821 | cbradney | 973 | checkChanges(); |
3985 | cbradney | 974 | } |
975 | |||
976 | void PageItem::moveImageXYOffsetBy(const double dX, const double dY) |
||
977 | { |
||
978 | if (dX==0.0 && dY==0.0) |
||
979 | return; |
||
16703 | jghali | 980 | if (dX != 0.0) |
18032 | craig | 981 | m_imageXOffset += dX; |
16703 | jghali | 982 | if (dY != 0.0) |
18032 | craig | 983 | m_imageYOffset += dY; |
14681 | fschmid | 984 | if (m_Doc->isLoading()) |
985 | return; |
||
4821 | cbradney | 986 | checkChanges(); |
3985 | cbradney | 987 | } |
988 | |||
14861 | fschmid | 989 | void PageItem::setImageRotation(const double newRotation) |
990 | { |
||
19263 | jghali | 991 | if (m_imageRotation == newRotation) |
17709 | craig | 992 | return; |
19263 | jghali | 993 | if (UndoManager::undoEnabled()) |
17744 | craig | 994 | { |
23942 | jghali | 995 | SimpleState *ss = new SimpleState(Um::Rotate, QString(), Um::IRotate); |
20793 | jghali | 996 | ss->set("IMAGE_ROTATION"); |
19263 | jghali | 997 | ss->set("OLD_ROT", m_imageRotation); |
998 | ss->set("NEW_ROT", newRotation); |
||
23108 | jghali | 999 | undoManager->action(this, ss); |
17744 | craig | 1000 | } |
18022 | craig | 1001 | m_imageRotation = newRotation; |
14861 | fschmid | 1002 | if (m_Doc->isLoading()) |
1003 | return; |
||
1004 | checkChanges(); |
||
1005 | } |
||
1006 | |||
23396 | jghali | 1007 | |
1008 | /// tests if a character is displayed by this frame |
||
1009 | bool PageItem::frameDisplays(int textpos) const |
||
1010 | { |
||
1011 | return 0 <= textpos && textpos < signed(m_maxChars) && textpos < itemText.length(); |
||
1012 | } |
||
1013 | |||
1014 | PageItem* PageItem::frameOfChar(int textPos) |
||
1015 | { |
||
1016 | PageItem* firstFrame = this->firstInChain(); |
||
1017 | PageItem* nextFrame = firstFrame; |
||
1018 | |||
1019 | while (nextFrame) |
||
1020 | { |
||
1021 | if (nextFrame->invalid) |
||
1022 | nextFrame->layout(); |
||
1023 | if (nextFrame->frameDisplays(textPos)) |
||
1024 | return nextFrame; |
||
1025 | nextFrame = nextFrame->nextInChain(); |
||
1026 | } |
||
1027 | |||
1028 | return nullptr; |
||
1029 | } |
||
1030 | |||
16621 | craig | 1031 | //return frame where is text end |
1032 | PageItem * PageItem::frameTextEnd() |
||
1033 | { |
||
1034 | PageItem * LastBox = this; |
||
23912 | craig | 1035 | if (frameOverflows() && m_nextBox) |
16621 | craig | 1036 | { // text ending in some next frame |
23912 | craig | 1037 | LastBox = m_nextBox; |
22600 | craig | 1038 | while (LastBox != nullptr && !LastBox->frameDisplays(itemText.length()-1)) |
16621 | craig | 1039 | LastBox = LastBox->nextInChain(); |
1040 | } |
||
23912 | craig | 1041 | else if (frameUnderflows() && m_backBox) |
16621 | craig | 1042 | { //text ending in some previous frame |
23912 | craig | 1043 | LastBox = m_backBox; |
22600 | craig | 1044 | while (LastBox != nullptr && !LastBox->frameDisplays(itemText.length()-1)) |
16621 | craig | 1045 | LastBox = LastBox->prevInChain(); |
1046 | } |
||
1047 | return LastBox; |
||
1048 | } |
||
5559 | avox | 1049 | |
1050 | /// returns true if text overflows |
||
1051 | bool PageItem::frameOverflows() const |
||
1052 | { |
||
12414 | jghali | 1053 | // Fix #6991 : "Text overflow" warning when there is a text underflow in fact |
22516 | craig | 1054 | /*return NextBox == nullptr && itemText.length() > static_cast<int>(MaxChars);*/ |
23912 | craig | 1055 | return ( m_nextBox == nullptr ) |
23196 | jghali | 1056 | && ( firstChar < itemText.length() ) |
13131 | jghali | 1057 | // Fix #7766 : scribus.textOverflows() returns 0 if there is no place for the overflow mark |
22832 | craig | 1058 | /*&& ( firstChar < MaxChars )*/ |
1059 | && ( firstChar <= m_maxChars ) |
||
23196 | jghali | 1060 | && ( itemText.length() > m_maxChars ); |
5559 | avox | 1061 | } |
1062 | |||
16845 | craig | 1063 | int PageItem::frameOverflowCount() const |
1064 | { |
||
1065 | if (frameOverflows()) |
||
22832 | craig | 1066 | return itemText.length()-m_maxChars; |
16845 | craig | 1067 | return 0; |
1068 | } |
||
1069 | |||
19188 | craig | 1070 | int PageItem::frameOverflowBlankCount() const |
1071 | { |
||
1072 | if (frameOverflows()) |
||
22832 | craig | 1073 | return itemText.plainText().right(itemText.length() - m_maxChars).count(QRegularExpression("\\s+")); |
19188 | craig | 1074 | return 0; |
1075 | } |
||
1076 | |||
17100 | fschmid | 1077 | int PageItem::maxCharsInFrame() |
1078 | { |
||
22832 | craig | 1079 | return m_maxChars; |
17100 | fschmid | 1080 | } |
1081 | |||
16621 | craig | 1082 | /// returns true if text is ending before that frame |
1083 | bool PageItem::frameUnderflows() const |
||
1084 | { |
||
23912 | craig | 1085 | if (m_backBox == nullptr) |
23071 | craig | 1086 | return false; |
16621 | craig | 1087 | //FIX ME - I have found that condition if frame is empty |
1088 | //and has been linked with previous frame |
||
1089 | //if you will find any better solution - fix that function |
||
1090 | return (firstInFrame() > lastInFrame()); |
||
1091 | } |
||
1092 | |||
16856 | craig | 1093 | void PageItem::drawOverflowMarker(ScPainter *p) |
1094 | { |
||
1095 | qreal sideLength = 10 / qMax(p->zoomFactor(), 1.0); |
||
1096 | qreal offset = 1 / qMax(p->zoomFactor(), 1.0); |
||
18095 | craig | 1097 | qreal left = m_width - sideLength-offset;// / 2; |
16856 | craig | 1098 | qreal right = left + sideLength; |
18095 | craig | 1099 | qreal top = m_height - sideLength-offset;// * 1.5; |
16856 | craig | 1100 | qreal bottom = top + sideLength; |
1101 | |||
23060 | craig | 1102 | QColor color(PrefsManager::instance().appPrefs.displayPrefs.frameNormColor); |
16856 | craig | 1103 | if ((isBookmark) || (m_isAnnotation)) |
23060 | craig | 1104 | color = PrefsManager::instance().appPrefs.displayPrefs.frameAnnotationColor; |
23912 | craig | 1105 | if ((m_backBox != nullptr) || (m_nextBox != nullptr)) |
23060 | craig | 1106 | color = PrefsManager::instance().appPrefs.displayPrefs.frameLinkColor; |
16856 | craig | 1107 | if (m_Locked) |
23060 | craig | 1108 | color = PrefsManager::instance().appPrefs.displayPrefs.frameLockColor; |
16856 | craig | 1109 | if (m_Doc->m_Selection->containsItem(this)) |
1110 | color = Qt::red; |
||
1111 | |||
1112 | p->save(); |
||
1113 | |||
17790 | fschmid | 1114 | p->setPen(color, 0, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
16856 | craig | 1115 | p->setPenOpacity(1.0); |
1116 | p->setBrush(Qt::white); |
||
1117 | p->setBrushOpacity(1.0); |
||
1118 | p->setFillMode(ScPainter::Solid); |
||
17790 | fschmid | 1119 | p->drawSharpRect(left, top, sideLength, sideLength); |
1120 | p->drawSharpLine(QPointF(left, top), QPointF(right, bottom)); |
||
1121 | p->drawSharpLine(QPointF(left, bottom), QPointF(right, top)); |
||
16856 | craig | 1122 | |
1123 | p->restore(); |
||
1124 | } |
||
1125 | |||
5559 | avox | 1126 | int PageItem::firstInFrame() const |
1127 | { |
||
5721 | avox | 1128 | return firstChar; |
5559 | avox | 1129 | } |
23398 | craig | 1130 | |
5559 | avox | 1131 | int PageItem::lastInFrame() const |
1132 | { |
||
22832 | craig | 1133 | return qMin(signed(m_maxChars), itemText.length()) - 1; |
5559 | avox | 1134 | } |
1135 | |||
22713 | jghali | 1136 | bool PageItem::canBeLinkedTo(const PageItem* nxt) const |
16589 | jghali | 1137 | { |
1138 | if (this->nextInChain() ) |
||
1139 | return false; |
||
18338 | jghali | 1140 | if (!nxt || nxt->prevInChain() ) |
16589 | jghali | 1141 | return false; |
22713 | jghali | 1142 | for (const PageItem* ff = nxt; ff; ff = ff->nextInChain()) |
16589 | jghali | 1143 | { |
22713 | jghali | 1144 | if (ff == this) |
1145 | return false; |
||
16589 | jghali | 1146 | } |
23365 | jghali | 1147 | // If object is placed on a master page, it can be linked only to objects placed on same master page |
1148 | // Same for objects placed on standard pages : they can only be linked to objects placed on standard pages |
||
23881 | craig | 1149 | return OnMasterPage == nxt->OnMasterPage; |
16589 | jghali | 1150 | } |
7994 | avox | 1151 | |
17708 | craig | 1152 | void PageItem::link(PageItem* nxt, bool addPARSEP) |
7994 | avox | 1153 | { |
1154 | assert( !nextInChain() ); |
||
1155 | assert( !nxt->prevInChain() ); |
||
8075 | avox | 1156 | for (PageItem* ff=nxt; ff; ff=ff->nextInChain()) |
1157 | { |
||
1158 | assert (ff != this); |
||
1159 | } |
||
13655 | jghali | 1160 | // Append only if necessary to avoid the |
1161 | // charstyle: access at end of text warning |
||
17708 | craig | 1162 | bool first = false; |
1163 | bool createUndo = addPARSEP; |
||
1164 | |||
22516 | craig | 1165 | if (nxt->prevInChain() == nullptr) |
17708 | craig | 1166 | first = true; |
1167 | int textLen = itemText.length(); |
||
13655 | jghali | 1168 | if (nxt->itemText.length() > 0) |
17708 | craig | 1169 | { //case when text will be joined with next frame text |
1170 | //do not add PARSEP if first frame has no text or text ends already with PARSEP |
||
1171 | if (addPARSEP && (textLen > 0) && (itemText.text(textLen-1) != SpecialChars::PARSEP)) |
||
1172 | itemText.insertChars(textLen, SpecialChars::PARSEP); |
||
1173 | else |
||
1174 | addPARSEP = false; |
||
13655 | jghali | 1175 | itemText.append(nxt->itemText); |
17708 | craig | 1176 | } |
22279 | jghali | 1177 | else |
1178 | addPARSEP = false; |
||
23912 | craig | 1179 | m_nextBox = nxt; |
1180 | nxt->m_backBox = this; |
||
8325 | avox | 1181 | // update AutoText |
1182 | if (isAutoText) |
||
1183 | { |
||
1184 | PageItem* after = nxt; |
||
1185 | while (after) |
||
1186 | { |
||
1187 | after->isAutoText = true; |
||
1188 | m_Doc->LastAuto = after; |
||
23912 | craig | 1189 | after = after->m_nextBox; |
8325 | avox | 1190 | } |
1191 | } |
||
1192 | else if (nxt->isAutoText) |
||
1193 | { |
||
1194 | PageItem* before = this; |
||
1195 | while (before) |
||
1196 | { |
||
1197 | before->isAutoText = true; |
||
1198 | m_Doc->FirstAuto = before; |
||
23912 | craig | 1199 | before = before->m_backBox; |
8325 | avox | 1200 | } |
1201 | } |
||
7994 | avox | 1202 | invalid = true; |
21495 | jghali | 1203 | PageItem* prev = this; |
23912 | craig | 1204 | while (prev->m_backBox && !prev->m_backBox->frameOverflows()) |
21495 | jghali | 1205 | { |
23912 | craig | 1206 | prev->m_backBox->invalid = true; |
1207 | prev = prev->m_backBox; |
||
21495 | jghali | 1208 | } |
8325 | avox | 1209 | while (nxt) |
1210 | { |
||
9490 | avox | 1211 | nxt->itemText = itemText; |
8325 | avox | 1212 | nxt->invalid = true; |
1213 | nxt->firstChar = 0; |
||
23912 | craig | 1214 | nxt = nxt->m_nextBox; |
8325 | avox | 1215 | } |
17708 | craig | 1216 | if (UndoManager::undoEnabled() && createUndo) //addPARESEP is false only if linking is invoked from undo action for unlinkWithText |
16490 | craig | 1217 | { |
17744 | craig | 1218 | ScItemState<QPair<PageItem*, PageItem*> > *is = new ScItemState<QPair<PageItem*, PageItem*> >(Um::LinkTextFrame); |
20793 | jghali | 1219 | is->set("LINK_TEXT_FRAME"); |
17708 | craig | 1220 | is->set("FIRST", first); |
1221 | is->set("JOIN_POS", textLen); |
||
1222 | is->set("ADDPARSEP", addPARSEP); |
||
23912 | craig | 1223 | is->setItem(qMakePair(this, m_nextBox)); |
16490 | craig | 1224 | undoManager->action(this, is); |
1225 | } |
||
7994 | avox | 1226 | } |
1227 | |||
17708 | craig | 1228 | void PageItem::unlink(bool createUndo) |
7994 | avox | 1229 | { |
23912 | craig | 1230 | if (m_nextBox) |
7994 | avox | 1231 | { |
23912 | craig | 1232 | PageItem *undoNextBox=m_nextBox; |
7994 | avox | 1233 | // make sure lastInFrame is valid |
1234 | layout(); |
||
12246 | cbradney | 1235 | /* |
1236 | //<< CB #6332: Stop the StoryText cut and break and act like other publishing apps |
||
7994 | avox | 1237 | // move following text to new StoryText |
1238 | itemText.select(lastInFrame()+1, itemText.length()-lastInFrame()-1); |
||
12246 | cbradney | 1239 | */ |
7994 | avox | 1240 | StoryText follow(m_Doc); |
12246 | cbradney | 1241 | /* |
7994 | avox | 1242 | follow.setDefaultStyle(itemText.defaultStyle()); |
1243 | follow.insert(0, itemText, true); |
||
1244 | // remove following text from this chain |
||
1245 | itemText.removeSelection(); |
||
12246 | cbradney | 1246 | //>> |
1247 | */ |
||
8325 | avox | 1248 | // update auto pointers |
1249 | if (isAutoText) |
||
1250 | { |
||
1251 | PageItem* before = this; |
||
1252 | while (before) |
||
1253 | { |
||
1254 | before->isAutoText = false; |
||
23912 | craig | 1255 | before = before->m_backBox; |
8325 | avox | 1256 | } |
23912 | craig | 1257 | m_Doc->FirstAuto = m_nextBox; |
8325 | avox | 1258 | } |
7994 | avox | 1259 | // link following frames to new text |
23912 | craig | 1260 | m_nextBox->firstChar = 0; |
1261 | m_nextBox->m_backBox = nullptr; |
||
1262 | while (m_nextBox) |
||
22832 | craig | 1263 | { |
23912 | craig | 1264 | m_nextBox->itemText = follow; |
1265 | m_nextBox->invalid = true; |
||
1266 | m_nextBox->firstChar = 0; |
||
1267 | m_nextBox = m_nextBox->m_nextBox; |
||
7994 | avox | 1268 | } |
22516 | craig | 1269 | // NextBox == nullptr now |
23912 | craig | 1270 | m_nextBox = nullptr; |
17708 | craig | 1271 | if (UndoManager::undoEnabled() && createUndo) |
16490 | craig | 1272 | { |
17744 | craig | 1273 | ScItemState<QPair<PageItem*, PageItem*> > *is = new ScItemState<QPair<PageItem*, PageItem*> >(Um::UnlinkTextFrame); |
20793 | jghali | 1274 | is->set("UNLINK_TEXT_FRAME"); |
17744 | craig | 1275 | is->setItem(qMakePair(this, undoNextBox)); |
16490 | craig | 1276 | undoManager->action(this, is); |
1277 | } |
||
7994 | avox | 1278 | } |
1279 | } |
||
1280 | |||
8325 | avox | 1281 | void PageItem::dropLinks() |
1282 | { |
||
1283 | // update auto pointers |
||
23912 | craig | 1284 | if (isAutoText && m_nextBox == nullptr) |
1285 | m_Doc->LastAuto = m_backBox; |
||
1286 | if (isAutoText && m_backBox == nullptr) |
||
1287 | m_Doc->FirstAuto = m_nextBox; |
||
8325 | avox | 1288 | isAutoText = false; |
1289 | |||
1290 | // leave text in remaining chain |
||
23912 | craig | 1291 | PageItem* before = m_backBox; |
1292 | PageItem* after = m_nextBox; |
||
22563 | craig | 1293 | if (after == nullptr && before == nullptr) |
19549 | jghali | 1294 | return; |
1295 | |||
1296 | itemText = StoryText(m_Doc); |
||
19905 | jghali | 1297 | |
1298 | int afterChar = 0; |
||
19549 | jghali | 1299 | if (before) |
19905 | jghali | 1300 | { |
23912 | craig | 1301 | before->m_nextBox = after; |
22832 | craig | 1302 | afterChar = qMin((int) before->m_maxChars, before->itemText.length()); |
19905 | jghali | 1303 | } |
19549 | jghali | 1304 | if (after) |
8325 | avox | 1305 | { |
23912 | craig | 1306 | after->m_backBox = before; |
19549 | jghali | 1307 | while (after) |
1308 | { |
||
1309 | after->invalid = true; |
||
19905 | jghali | 1310 | after->firstChar = afterChar; |
23912 | craig | 1311 | after = after->m_nextBox; |
8325 | avox | 1312 | } |
1313 | } |
||
19549 | jghali | 1314 | |
1315 | if (UndoManager::undoEnabled()) |
||
1316 | { |
||
1317 | ScItemState<QPair<PageItem*, PageItem*> > *is = new ScItemState<QPair<PageItem*, PageItem*> >(Um::UnlinkTextFrame); |
||
20793 | jghali | 1318 | is->set("DROP_LINKS"); |
23912 | craig | 1319 | is->setItem(qMakePair(m_backBox, m_nextBox)); |
19549 | jghali | 1320 | undoManager->action(this, is); |
1321 | } |
||
1322 | |||
22516 | craig | 1323 | // JG we should set BackBox and NextBox to nullptr at a point |
23912 | craig | 1324 | m_backBox = m_nextBox = nullptr; |
8325 | avox | 1325 | } |
1326 | |||
17565 | craig | 1327 | //unlink selected frame from text chain |
1328 | //but copy or cut its content from itemText |
||
22713 | jghali | 1329 | void PageItem::unlinkWithText() |
17565 | craig | 1330 | { |
24617 | jghali | 1331 | PageItem* next = m_nextBox; |
1332 | PageItem* prev = m_backBox; |
||
17708 | craig | 1333 | int length = itemText.length(); |
1334 | |||
22110 | jghali | 1335 | if (this->invalid) |
1336 | layout(); |
||
1337 | |||
17708 | craig | 1338 | //unlink first frame in chain |
24617 | jghali | 1339 | if (prev == nullptr) |
17708 | craig | 1340 | { |
24617 | jghali | 1341 | if (next->invalid) |
1342 | next->layout(); |
||
17708 | craig | 1343 | if (lastInFrame() < length -1) |
1344 | { |
||
1345 | StoryText content(m_Doc); |
||
23914 | jghali | 1346 | itemText.select(lastInFrame() + 1, length - (lastInFrame() + 1)); |
22713 | jghali | 1347 | content.insert(0, itemText, true); |
17708 | craig | 1348 | itemText.removeSelection(); |
1349 | unlink(false); |
||
24617 | jghali | 1350 | next->itemText.insert(0, content); |
1351 | next->update(); |
||
17708 | craig | 1352 | } |
1353 | else |
||
1354 | { |
||
1355 | unlink(false); |
||
1356 | } |
||
1357 | } |
||
1358 | else |
||
1359 | { |
||
24617 | jghali | 1360 | if (prev->invalid) |
1361 | prev->layout(); |
||
17708 | craig | 1362 | itemText.select(firstInFrame(), length - firstInFrame()); |
1363 | StoryText content(m_Doc); |
||
1364 | content.insert(0, itemText, true); |
||
22713 | jghali | 1365 | itemText.removeSelection(); |
24617 | jghali | 1366 | prev->unlink(false); |
17708 | craig | 1367 | itemText.insert(0, content); |
1368 | update(); |
||
1369 | } |
||
1370 | if (UndoManager::undoEnabled()) |
||
1371 | { |
||
17744 | craig | 1372 | ScItemState<QPair<PageItem*, PageItem*> > *is = new ScItemState<QPair<PageItem*, PageItem*> >(Um::UnlinkTextFrame); |
20793 | jghali | 1373 | is->set("UNLINK_TEXT_FRAME"); |
24617 | jghali | 1374 | is->set("CUT_TEXT", true); |
1375 | is->setItem(qMakePair(prev, next)); |
||
17708 | craig | 1376 | undoManager->action(this, is); |
1377 | } |
||
17565 | craig | 1378 | } |
1379 | |||
5559 | avox | 1380 | /// returns the style at the current charpos |
1381 | const ParagraphStyle& PageItem::currentStyle() const |
||
1382 | { |
||
21355 | jghali | 1383 | int cursorPosition = itemText.cursorPosition(); |
23940 | jghali | 1384 | if (itemText.hasSelection()) |
21355 | jghali | 1385 | { |
1386 | int firstSelected = itemText.startOfSelection(); |
||
1387 | int lastSelected = qMax(itemText.endOfSelection() - 1, 0); |
||
1388 | cursorPosition = qMax(firstSelected, qMin(cursorPosition, lastSelected)); |
||
1389 | } |
||
22011 | jghali | 1390 | // Note: cursor position can be past last characters, don't use frameDisplays() here |
1391 | if (cursorPosition >= 0 && cursorPosition <= itemText.length()) |
||
21355 | jghali | 1392 | return itemText.paragraphStyle(cursorPosition); |
1393 | return itemText.defaultStyle(); |
||
5559 | avox | 1394 | } |
1395 | |||
5569 | avox | 1396 | /// returns the style at the current charpos for changing |
1397 | ParagraphStyle& PageItem::changeCurrentStyle() |
||
1398 | { |
||
21355 | jghali | 1399 | int cursorPosition = itemText.cursorPosition(); |
23940 | jghali | 1400 | if (itemText.hasSelection()) |
21355 | jghali | 1401 | { |
1402 | int firstSelected = itemText.startOfSelection(); |
||
1403 | int lastSelected = qMax(itemText.endOfSelection() - 1, 0); |
||
1404 | cursorPosition = qMax(firstSelected, qMin(cursorPosition, lastSelected)); |
||
1405 | } |
||
22011 | jghali | 1406 | // Note: cursor position can be past last characters, don't use frameDisplays() here |
1407 | if (cursorPosition >= 0 && cursorPosition <= itemText.length()) |
||
21355 | jghali | 1408 | return const_cast<ParagraphStyle&>(itemText.paragraphStyle(cursorPosition)); |
22600 | craig | 1409 | return const_cast<ParagraphStyle&>(itemText.defaultStyle()); |
5569 | avox | 1410 | } |
1411 | |||
5559 | avox | 1412 | /// returns the style at the current charpos |
1413 | const CharStyle& PageItem::currentCharStyle() const |
||
1414 | { |
||
21355 | jghali | 1415 | int cursorPosition = itemText.cursorPosition(); |
23940 | jghali | 1416 | if (itemText.hasSelection()) |
21355 | jghali | 1417 | { |
1418 | int firstSelected = itemText.startOfSelection(); |
||
1419 | int lastSelected = qMax(itemText.endOfSelection() - 1, 0); |
||
1420 | cursorPosition = qMax(firstSelected, qMin(cursorPosition, lastSelected)); |
||
1421 | } |
||
22011 | jghali | 1422 | // Note: cursor position can be past last characters, don't use frameDisplays() here |
1423 | if (cursorPosition >= 0 && cursorPosition <= itemText.length()) |
||
21355 | jghali | 1424 | return itemText.charStyle(cursorPosition); |
22600 | craig | 1425 | return itemText.defaultStyle().charStyle(); |
5559 | avox | 1426 | } |
1427 | |||
16838 | jghali | 1428 | void PageItem::currentTextProps(ParagraphStyle& parStyle) const |
1429 | { |
||
21500 | jghali | 1430 | const ParagraphStyle& curStyle = this->currentStyle(); |
1431 | parStyle.setContext(curStyle.context()); |
||
1432 | parStyle = curStyle; |
||
1433 | |||
16838 | jghali | 1434 | int position = itemText.cursorPosition(); |
23940 | jghali | 1435 | if (itemText.hasSelection()) |
16838 | jghali | 1436 | position = qMin(qMax(itemText.endOfSelection() - 1, 0), qMax(position, itemText.startOfSelection())); |
1437 | |||
22011 | jghali | 1438 | // Note: cursor position can be past last characters, don't use frameDisplays() here |
1439 | if (position >= 0 && position <= itemText.length()) |
||
21129 | jghali | 1440 | { |
1441 | // Do not use setStyle here otherwise char style properties explicitly |
||
1442 | // set at paragraph level without using styles might get lost |
||
1443 | parStyle.charStyle().applyCharStyle( itemText.charStyle(position) ); |
||
1444 | } |
||
16838 | jghali | 1445 | else |
1446 | parStyle.charStyle().setStyle( itemText.defaultStyle().charStyle() ); |
||
1447 | } |
||
1448 | |||
3988 | cbradney | 1449 | void PageItem::setTextToFrameDistLeft(double newLeft) |
1450 | { |
||
23244 | jghali | 1451 | if (m_textDistanceMargins.left() == newLeft) |
17641 | craig | 1452 | return; |
1453 | if (UndoManager::undoEnabled()) |
||
1454 | { |
||
23942 | jghali | 1455 | SimpleState *ss = new SimpleState(Um::TextFrameDist, QString(), Um::ITextFrame); |
20793 | jghali | 1456 | ss->set("LEFT_TEXTFRAMEDIST"); |
23244 | jghali | 1457 | ss->set("OLD_DIST", m_textDistanceMargins.left()); |
1458 | ss->set("NEW_DIST", newLeft); |
||
17641 | craig | 1459 | undoManager->action(this, ss); |
1460 | } |
||
19831 | craig | 1461 | m_textDistanceMargins.setLeft(newLeft); |
16546 | jghali | 1462 | //emit textToFrameDistances(Extra, TExtra, BExtra, RExtra); |
3988 | cbradney | 1463 | } |
3985 | cbradney | 1464 | |
3988 | cbradney | 1465 | void PageItem::setTextToFrameDistRight(double newRight) |
1466 | { |
||
23244 | jghali | 1467 | if (m_textDistanceMargins.right() == newRight) |
17641 | craig | 1468 | return; |
1469 | if (UndoManager::undoEnabled()) |
||
1470 | { |
||
23942 | jghali | 1471 | SimpleState *ss = new SimpleState(Um::TextFrameDist, QString(), Um::ITextFrame); |
20793 | jghali | 1472 | ss->set("RIGHT_TEXTFRAMEDIST"); |
23244 | jghali | 1473 | ss->set("OLD_DIST", m_textDistanceMargins.right()); |
1474 | ss->set("NEW_DIST", newRight); |
||
17641 | craig | 1475 | undoManager->action(this, ss); |
1476 | } |
||
19831 | craig | 1477 | m_textDistanceMargins.setRight(newRight); |
16546 | jghali | 1478 | //emit textToFrameDistances(Extra, TExtra, BExtra, RExtra); |
3988 | cbradney | 1479 | } |
3985 | cbradney | 1480 | |
3988 | cbradney | 1481 | void PageItem::setTextToFrameDistTop(double newTop) |
1482 | { |
||
23244 | jghali | 1483 | if (m_textDistanceMargins.top() == newTop) |
17641 | craig | 1484 | return; |
1485 | if (UndoManager::undoEnabled()) |
||
1486 | { |
||
23942 | jghali | 1487 | SimpleState *ss = new SimpleState(Um::TextFrameDist, QString(), Um::ITextFrame); |
20793 | jghali | 1488 | ss->set("TOP_TEXTFRAMEDIST"); |
23244 | jghali | 1489 | ss->set("OLD_DIST", m_textDistanceMargins.top()); |
1490 | ss->set("NEW_DIST", newTop); |
||
17641 | craig | 1491 | undoManager->action(this, ss); |
1492 | } |
||
19831 | craig | 1493 | m_textDistanceMargins.setTop(newTop); |
16546 | jghali | 1494 | //emit textToFrameDistances(Extra, TExtra, BExtra, RExtra); |
3988 | cbradney | 1495 | } |
3985 | cbradney | 1496 | |
3988 | cbradney | 1497 | void PageItem::setTextToFrameDistBottom(double newBottom) |
1498 | { |
||
23244 | jghali | 1499 | if (m_textDistanceMargins.bottom() == newBottom) |
17641 | craig | 1500 | return; |
1501 | if (UndoManager::undoEnabled()) |
||
1502 | { |
||
23942 | jghali | 1503 | SimpleState *ss = new SimpleState(Um::TextFrameDist, QString(), Um::ITextFrame); |
20793 | jghali | 1504 | ss->set("BOTTOM_TEXTFRAMEDIST"); |
23244 | jghali | 1505 | ss->set("OLD_DIST", m_textDistanceMargins.bottom()); |
1506 | ss->set("NEW_DIST", newBottom); |
||
17641 | craig | 1507 | undoManager->action(this, ss); |
1508 | } |
||
19831 | craig | 1509 | m_textDistanceMargins.setBottom(newBottom); |
16546 | jghali | 1510 | //emit textToFrameDistances(Extra, TExtra, BExtra, RExtra); |
3988 | cbradney | 1511 | } |
3985 | cbradney | 1512 | |
3988 | cbradney | 1513 | void PageItem::setTextToFrameDist(double newLeft, double newRight, double newTop, double newBottom) |
1514 | { |
||
19421 | jghali | 1515 | UndoTransaction activeTransaction; |
17641 | craig | 1516 | if (UndoManager::undoEnabled()) |
23942 | jghali | 1517 | activeTransaction = undoManager->beginTransaction(Um::TextFrame, Um::IDocument, Um::TextFrameDist, QString(), Um::ITextFrame); |
17641 | craig | 1518 | setTextToFrameDistLeft(newLeft); |
1519 | setTextToFrameDistRight(newRight); |
||
1520 | setTextToFrameDistTop(newTop); |
||
1521 | setTextToFrameDistBottom(newBottom); |
||
1522 | if (activeTransaction) |
||
19421 | jghali | 1523 | activeTransaction.commit(); |
16546 | jghali | 1524 | //emit textToFrameDistances(Extra, TExtra, BExtra, RExtra); |
3988 | cbradney | 1525 | } |
3985 | cbradney | 1526 | |
22832 | craig | 1527 | double PageItem::gridOffset() const |
1528 | { |
||
1529 | return m_Doc->guidesPrefs().offsetBaselineGrid; |
||
1530 | } |
||
1531 | double PageItem::gridDistance() const |
||
1532 | { |
||
1533 | return m_Doc->guidesPrefs().valueBaselineGrid; |
||
1534 | } |
||
5559 | avox | 1535 | |
1536 | void PageItem::setGridOffset(double) { } // FIXME |
||
1537 | void PageItem::setGridDistance(double) { } // FIXME |
||
22832 | craig | 1538 | |
1539 | void PageItem::setColumns(int newColumnCount) |
||
5559 | avox | 1540 | { |
22832 | craig | 1541 | if (m_columns==newColumnCount) |
17641 | craig | 1542 | return; |
19415 | jghali | 1543 | if (UndoManager::undoEnabled()) |
17744 | craig | 1544 | { |
23942 | jghali | 1545 | SimpleState *ss = new SimpleState(Um::Columns, QString(), Um::IBorder); |
20793 | jghali | 1546 | ss->set("COLUMNS"); |
22832 | craig | 1547 | ss->set("OLD_COLUMNS", m_columns); |
1548 | ss->set("NEW_COLUMNS", newColumnCount); |
||
17641 | craig | 1549 | undoManager->action(this, ss); |
1550 | } |
||
22832 | craig | 1551 | m_columns = qMax(1, newColumnCount); |
5559 | avox | 1552 | } |
22832 | craig | 1553 | |
1554 | void PageItem::setColumnGap(double newColumnGap) |
||
5559 | avox | 1555 | { |
22832 | craig | 1556 | if (m_columnGap==newColumnGap) |
17641 | craig | 1557 | return; |
22832 | craig | 1558 | if (UndoManager::undoEnabled()) |
1559 | { |
||
23942 | jghali | 1560 | SimpleState *ss = new SimpleState(Um::Columns, QString(), Um::IBorder); |
20793 | jghali | 1561 | ss->set("COLUMNSGAP"); |
22832 | craig | 1562 | ss->set("OLD_COLUMNS", m_columnGap); |
1563 | ss->set("NEW_COLUMNS", newColumnGap); |
||
17641 | craig | 1564 | undoManager->action(this, ss); |
1565 | } |
||
22832 | craig | 1566 | m_columnGap = newColumnGap; |
5559 | avox | 1567 | } |
1568 | |||
18889 | fschmid | 1569 | int PageItem::verticalAlignment() |
1570 | { |
||
1571 | return verticalAlign; |
||
1572 | } |
||
1573 | |||
1574 | void PageItem::setVerticalAlignment(int val) |
||
1575 | { |
||
1576 | if (val == verticalAlign) |
||
1577 | return; |
||
19415 | jghali | 1578 | if (UndoManager::undoEnabled()) |
19132 | craig | 1579 | { |
23942 | jghali | 1580 | SimpleState *ss = new SimpleState(Um::AlignText, QString(), Um::ITextFrame); |
20793 | jghali | 1581 | ss->set("VERTICAL_ALIGN"); |
19132 | craig | 1582 | ss->set("OLD_VERTALIGN", verticalAlign); |
1583 | ss->set("NEW_VERTALIGN", val); |
||
1584 | undoManager->action(this, ss); |
||
1585 | } |
||
18889 | fschmid | 1586 | verticalAlign = val; |
1587 | } |
||
1588 | |||
3989 | cbradney | 1589 | void PageItem::setCornerRadius(double newRadius) |
1590 | { |
||
23370 | jghali | 1591 | if (m_roundedCornerRadius == newRadius) |
17644 | craig | 1592 | return; |
19415 | jghali | 1593 | if (UndoManager::undoEnabled()) |
17744 | craig | 1594 | { |
23942 | jghali | 1595 | SimpleState *state = new SimpleState(Um::RoundCorner, QString(), Um::IBorder); |
20793 | jghali | 1596 | state->set("CORNER_RADIUS"); |
23370 | jghali | 1597 | state->set("OLD_RADIUS", m_roundedCornerRadius); |
23244 | jghali | 1598 | state->set("NEW_RADIUS", newRadius); |
17744 | craig | 1599 | undoManager->action(this,state); |
1600 | } |
||
23370 | jghali | 1601 | m_roundedCornerRadius=newRadius; |
16546 | jghali | 1602 | //emit cornerRadius(RadRect); |
3989 | cbradney | 1603 | } |
3985 | cbradney | 1604 | |
3988 | cbradney | 1605 | |
1606 | |||
10840 | avox | 1607 | /** Paints the item. |
1608 | CHANGE: cullingArea is in doc coordinates! |
||
1609 | */ |
||
11052 | avox | 1610 | void PageItem::DrawObj(ScPainter *p, QRectF cullingArea) |
3 | paul | 1611 | { |
19515 | jghali | 1612 | // #12698: Prevent drawing of line items |
1613 | /*if (PoLine.isEmpty()) |
||
1614 | return;*/ |
||
10945 | jghali | 1615 | if (cullingArea.isNull()) |
10840 | avox | 1616 | { |
23007 | craig | 1617 | cullingArea = QRectF(QPointF(m_Doc->minCanvasCoordinate.x(), m_Doc->minCanvasCoordinate.y()), |
10840 | avox | 1618 | QPointF(m_Doc->maxCanvasCoordinate.x(), m_Doc->maxCanvasCoordinate.y())).toAlignedRect(); |
1619 | } |
||
17394 | fschmid | 1620 | |
1621 | no_fill = false; |
||
1622 | no_stroke = false; |
||
14681 | fschmid | 1623 | DrawObj_Pre(p); |
22832 | craig | 1624 | if (m_Doc->layerOutline(m_layerID)) |
5572 | fschmid | 1625 | { |
23244 | jghali | 1626 | if ((itemType() == TextFrame || itemType() == ImageFrame || itemType() == PathText || itemType() == Line || itemType() == PolyLine || itemType() == Group || itemType() == Symbol)) |
14681 | fschmid | 1627 | DrawObj_Item(p, cullingArea); |
5572 | fschmid | 1628 | } |
1629 | else |
||
7549 | fschmid | 1630 | { |
16105 | fschmid | 1631 | DrawObj_Item(p, cullingArea); |
7549 | fschmid | 1632 | } |
2434 | fschmid | 1633 | DrawObj_Post(p); |
1736 | cbradney | 1634 | } |
1635 | |||
14681 | fschmid | 1636 | void PageItem::DrawObj_Pre(ScPainter *p) |
1740 | cbradney | 1637 | { |
1741 | cbradney | 1638 | p->save(); |
18729 | fschmid | 1639 | double lwCorr = m_lineWidth; |
1640 | double sc = p->zoomFactor(); |
||
1641 | if ((m_lineWidth * sc) < 1) |
||
1642 | lwCorr = 0; |
||
2434 | fschmid | 1643 | if (!isEmbedded) |
18032 | craig | 1644 | p->translate(m_xPos, m_yPos); |
18022 | craig | 1645 | p->rotate(m_rotation); |
19514 | jghali | 1646 | |
22832 | craig | 1647 | if (m_Doc->layerOutline(m_layerID)) |
1741 | cbradney | 1648 | { |
22832 | craig | 1649 | p->setPen(m_Doc->layerMarker(m_layerID), 0, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
5572 | fschmid | 1650 | p->setFillMode(ScPainter::None); |
1651 | p->setBrushOpacity(1.0); |
||
1652 | p->setPenOpacity(1.0); |
||
19514 | jghali | 1653 | return; |
1741 | cbradney | 1654 | } |
19514 | jghali | 1655 | |
20047 | fschmid | 1656 | if ((hasSoftShadow()) && (m_Doc->appMode != modeEdit)) |
19514 | jghali | 1657 | DrawSoftShadow(p); |
20111 | fschmid | 1658 | if (isGroup()) |
1659 | return; |
||
19514 | jghali | 1660 | p->setBlendModeFill(fillBlendmode()); |
1661 | p->setLineWidth(lwCorr); |
||
1662 | if (GrType != 0) |
||
1741 | cbradney | 1663 | { |
23904 | jghali | 1664 | if (GrType == Gradient_Pattern) |
1741 | cbradney | 1665 | { |
23046 | jghali | 1666 | ScPattern *pattern = m_Doc->checkedPattern(m_patternName); |
19514 | jghali | 1667 | if (!pattern) |
5572 | fschmid | 1668 | { |
14297 | fschmid | 1669 | p->fill_gradient = VGradient(VGradient::linear); |
19514 | jghali | 1670 | p->fill_gradient.setRepeatMethod(GrExtend); |
14297 | fschmid | 1671 | if (fillColor() != CommonStrings::None) |
6368 | fschmid | 1672 | { |
23046 | jghali | 1673 | p->setBrush(m_fillQColor); |
14297 | fschmid | 1674 | p->setFillMode(ScPainter::Solid); |
7684 | fschmid | 1675 | } |
1676 | else |
||
17394 | fschmid | 1677 | { |
1678 | no_fill = true; |
||
14297 | fschmid | 1679 | p->setFillMode(ScPainter::None); |
17394 | fschmid | 1680 | } |
23046 | jghali | 1681 | if ((!m_patternName.isEmpty()) && (!m_Doc->docPatterns.contains(m_patternName))) |
19514 | jghali | 1682 | { |
1683 | GrType = 0; |
||
23046 | jghali | 1684 | m_patternName = ""; |
19514 | jghali | 1685 | } |
6368 | fschmid | 1686 | } |
19514 | jghali | 1687 | else |
5572 | fschmid | 1688 | { |
19514 | jghali | 1689 | p->setPattern(pattern, patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation, patternSkewX, patternSkewY, patternMirrorX, patternMirrorY); |
1690 | p->setFillMode(ScPainter::Pattern); |
||
5572 | fschmid | 1691 | } |
19514 | jghali | 1692 | } |
1693 | else |
||
1694 | { |
||
23904 | jghali | 1695 | if (GrType == Gradient_4Colors) |
14297 | fschmid | 1696 | { |
19514 | jghali | 1697 | p->setFillMode(ScPainter::Gradient); |
1698 | FPoint pG1 = FPoint(0, 0); |
||
1699 | FPoint pG2 = FPoint(width(), 0); |
||
1700 | FPoint pG3 = FPoint(width(), height()); |
||
1701 | FPoint pG4 = FPoint(0, height()); |
||
1702 | p->set4ColorGeometry(pG1, pG2, pG3, pG4, GrControl1, GrControl2, GrControl3, GrControl4); |
||
23046 | jghali | 1703 | p->set4ColorColors(m_grQColorP1, m_grQColorP2, m_grQColorP3, m_grQColorP4); |
14297 | fschmid | 1704 | } |
23904 | jghali | 1705 | else if (GrType == Gradient_Hatch) |
14308 | fschmid | 1706 | { |
19514 | jghali | 1707 | if (fillColor() != CommonStrings::None) |
23046 | jghali | 1708 | p->setBrush(m_fillQColor); |
19514 | jghali | 1709 | p->setFillMode(ScPainter::Hatch); |
1710 | p->setHatchParameters(hatchType, hatchDistance, hatchAngle, hatchUseBackground, hatchBackgroundQ, hatchForegroundQ, width(), height()); |
||
1711 | } |
||
1712 | else |
||
1713 | { |
||
23046 | jghali | 1714 | if ((!m_gradientName.isEmpty()) && (!m_Doc->docGradients.contains(m_gradientName))) |
1715 | m_gradientName = ""; |
||
1716 | if (!(m_gradientName.isEmpty()) && (m_Doc->docGradients.contains(m_gradientName))) |
||
1717 | fill_gradient = m_Doc->docGradients[m_gradientName]; |
||
23904 | jghali | 1718 | if ((fill_gradient.stops() < 2) && (GrType < Gradient_4Colors)) // fall back to solid filling if there are not enough colorstops in the gradient. |
14308 | fschmid | 1719 | { |
19514 | jghali | 1720 | if (fillColor() != CommonStrings::None) |
1721 | { |
||
23046 | jghali | 1722 | p->setBrush(m_fillQColor); |
19514 | jghali | 1723 | p->setFillMode(ScPainter::Solid); |
1724 | } |
||
14318 | fschmid | 1725 | else |
19514 | jghali | 1726 | { |
1727 | no_fill = true; |
||
1728 | p->setFillMode(ScPainter::None); |
||
1729 | } |
||
14308 | fschmid | 1730 | } |
19513 | jghali | 1731 | else |
1732 | { |
||
19514 | jghali | 1733 | p->setFillMode(ScPainter::Gradient); |
1734 | p->fill_gradient = fill_gradient; |
||
1735 | p->fill_gradient.setRepeatMethod(GrExtend); |
||
1736 | switch (GrType) |
||
1737 | { |
||
23904 | jghali | 1738 | case Gradient_LinearLegacy1: |
1739 | case Gradient_LinearLegacy2: |
||
1740 | case Gradient_LinearLegacy3: |
||
1741 | case Gradient_LinearLegacy4: |
||
1742 | case Gradient_Linear: |
||
19514 | jghali | 1743 | p->setGradient(VGradient::linear, FPoint(GrStartX, GrStartY), FPoint(GrEndX, GrEndY), FPoint(GrStartX, GrStartY), GrScale, GrSkew); |
1744 | break; |
||
23904 | jghali | 1745 | case Gradient_RadialLegacy5: |
1746 | case Gradient_Radial: |
||
19514 | jghali | 1747 | p->setGradient(VGradient::radial, FPoint(GrStartX, GrStartY), FPoint(GrEndX, GrEndY), FPoint(GrFocalX, GrFocalY), GrScale, GrSkew); |
1748 | break; |
||
23904 | jghali | 1749 | case Gradient_Diamond: |
19514 | jghali | 1750 | p->setFillMode(ScPainter::Gradient); |
1751 | p->setDiamondGeometry(FPoint(0, 0), FPoint(width(), 0), FPoint(width(), height()), FPoint(0, height()), GrControl1, GrControl2, GrControl3, GrControl4, GrControl5); |
||
1752 | break; |
||
23904 | jghali | 1753 | case Gradient_Mesh: |
1754 | case Gradient_Conical: |
||
19514 | jghali | 1755 | p->setFillMode(ScPainter::Gradient); |
1756 | p->setMeshGradient(FPoint(0, 0), FPoint(width(), 0), FPoint(width(), height()), FPoint(0, height()), meshGradientArray); |
||
1757 | break; |
||
23904 | jghali | 1758 | case Gradient_PatchMesh: |
19514 | jghali | 1759 | p->setFillMode(ScPainter::Gradient); |
1760 | p->setMeshGradient(FPoint(0, 0), FPoint(width(), 0), FPoint(width(), height()), FPoint(0, height()), meshGradientPatches); |
||
1761 | break; |
||
1762 | } |
||
19513 | jghali | 1763 | } |
14308 | fschmid | 1764 | } |
19514 | jghali | 1765 | } |
1766 | } |
||
1767 | else |
||
1768 | { |
||
1769 | p->fill_gradient = VGradient(VGradient::linear); |
||
1770 | if (fillColor() != CommonStrings::None) |
||
1771 | { |
||
23046 | jghali | 1772 | p->setBrush(m_fillQColor); |
19514 | jghali | 1773 | p->setFillMode(ScPainter::Solid); |
1774 | } |
||
1775 | else |
||
1776 | { |
||
1777 | no_fill = true; |
||
1778 | p->setFillMode(ScPainter::None); |
||
1779 | } |
||
1780 | } |
||
1781 | if ((lineColor() != CommonStrings::None) || (!patternStrokeVal.isEmpty()) || (GrTypeStroke > 0)) |
||
1782 | { |
||
23046 | jghali | 1783 | p->setPen(m_strokeQColor, lwCorr, PLineArt, PLineEnd, PLineJoin); |
19514 | jghali | 1784 | if (DashValues.count() != 0) |
1785 | p->setDash(DashValues, DashOffset); |
||
1786 | } |
||
1787 | else |
||
1788 | p->setLineWidth(0); |
||
1789 | p->setBrushOpacity(1.0 - fillTransparency()); |
||
1790 | p->setPenOpacity(1.0 - lineTransparency()); |
||
1791 | p->setFillRule(fillRule); |
||
23907 | jghali | 1792 | if ((GrMask == GradMask_Linear) || (GrMask == GradMask_Radial) || (GrMask == GradMask_LinearLumAlpha) || (GrMask == GradMask_RadialLumAlpha)) |
19514 | jghali | 1793 | { |
23907 | jghali | 1794 | if ((GrMask == GradMask_Linear) || (GrMask == GradMask_Radial)) |
19514 | jghali | 1795 | p->setMaskMode(1); |
1796 | else |
||
1797 | p->setMaskMode(3); |
||
1798 | if ((!gradientMaskVal.isEmpty()) && (!m_Doc->docGradients.contains(gradientMaskVal))) |
||
1799 | gradientMaskVal = ""; |
||
1800 | if (!(gradientMaskVal.isEmpty()) && (m_Doc->docGradients.contains(gradientMaskVal))) |
||
1801 | mask_gradient = m_Doc->docGradients[gradientMaskVal]; |
||
1802 | p->mask_gradient = mask_gradient; |
||
23907 | jghali | 1803 | if ((GrMask == GradMask_Linear) || (GrMask == GradMask_LinearLumAlpha)) |
19514 | jghali | 1804 | p->setGradientMask(VGradient::linear, FPoint(GrMaskStartX, GrMaskStartY), FPoint(GrMaskEndX, GrMaskEndY), FPoint(GrMaskStartX, GrMaskStartY), GrMaskScale, GrMaskSkew); |
1805 | else |
||
1806 | p->setGradientMask(VGradient::radial, FPoint(GrMaskStartX, GrMaskStartY), FPoint(GrMaskEndX, GrMaskEndY), FPoint(GrMaskFocalX, GrMaskFocalY), GrMaskScale, GrMaskSkew); |
||
1807 | } |
||
23907 | jghali | 1808 | else if ((GrMask == GradMask_Pattern) || (GrMask == GradMask_PatternLumAlpha) || (GrMask == GradMask_PatternLumAlphaInverted) || (GrMask == GradMask_PatternInverted)) |
19514 | jghali | 1809 | { |
1810 | ScPattern *patternMask = m_Doc->checkedPattern(patternMaskVal); |
||
1811 | if (patternMask) |
||
1812 | { |
||
1813 | p->setPatternMask(patternMask, patternMaskScaleX, patternMaskScaleY, patternMaskOffsetX, patternMaskOffsetY, patternMaskRotation, patternMaskSkewX, patternMaskSkewY, patternMaskMirrorX, patternMaskMirrorY); |
||
23907 | jghali | 1814 | if (GrMask == GradMask_Pattern) |
19514 | jghali | 1815 | p->setMaskMode(2); |
23907 | jghali | 1816 | else if (GrMask == GradMask_PatternLumAlpha) |
19514 | jghali | 1817 | p->setMaskMode(4); |
23907 | jghali | 1818 | else if (GrMask == GradMask_PatternLumAlphaInverted) |
19514 | jghali | 1819 | p->setMaskMode(5); |
14297 | fschmid | 1820 | else |
19514 | jghali | 1821 | p->setMaskMode(6); |
1741 | cbradney | 1822 | } |
19514 | jghali | 1823 | else |
1824 | { |
||
1825 | p->setMaskMode(0); |
||
1826 | } |
||
7549 | fschmid | 1827 | } |
19514 | jghali | 1828 | else |
1829 | p->setMaskMode(0); |
||
1740 | cbradney | 1830 | } |
1831 | |||
2434 | fschmid | 1832 | void PageItem::DrawObj_Post(ScPainter *p) |
1740 | cbradney | 1833 | { |
1834 | bool doStroke=true; |
||
18729 | fschmid | 1835 | double lwCorr = m_lineWidth; |
22832 | craig | 1836 | if ((m_lineWidth * p->zoomFactor()) < 1) |
18729 | fschmid | 1837 | lwCorr = 0; |
22832 | craig | 1838 | if (m_Doc->layerOutline(m_layerID)) |
1740 | cbradney | 1839 | { |
16899 | fschmid | 1840 | if (itemType()!=Line) |
1740 | cbradney | 1841 | { |
22832 | craig | 1842 | p->setPen(m_Doc->layerMarker(m_layerID), 0, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
16899 | fschmid | 1843 | p->setFillMode(ScPainter::None); |
1844 | p->setBrushOpacity(1.0); |
||
1845 | p->setPenOpacity(1.0); |
||
23244 | jghali | 1846 | if (itemType() == PolyLine) |
16899 | fschmid | 1847 | p->setupPolygon(&PoLine, false); |
1848 | else if (itemType() == PathText) |
||
5582 | fschmid | 1849 | { |
16899 | fschmid | 1850 | if (PoShow) |
5582 | fschmid | 1851 | p->setupPolygon(&PoLine, false); |
16899 | fschmid | 1852 | else |
1853 | doStroke = false; |
||
1854 | } |
||
1855 | else |
||
1856 | p->setupPolygon(&PoLine); |
||
1857 | if (doStroke) |
||
1858 | p->strokePath(); |
||
23244 | jghali | 1859 | if (itemType() == ImageFrame) |
16899 | fschmid | 1860 | { |
22638 | craig | 1861 | if (!imageClip.empty()) |
7549 | fschmid | 1862 | { |
16899 | fschmid | 1863 | p->setupPolygon(&imageClip); |
7549 | fschmid | 1864 | p->strokePath(); |
5584 | fschmid | 1865 | } |
1866 | } |
||
1740 | cbradney | 1867 | } |
16899 | fschmid | 1868 | } |
1869 | else |
||
1870 | { |
||
1871 | if (!isGroup()) |
||
7549 | fschmid | 1872 | { |
14308 | fschmid | 1873 | p->setBlendModeFill(0); |
14298 | fschmid | 1874 | p->setMaskMode(0); |
23244 | jghali | 1875 | // TODO: Investigate whether itemType() == Table should really be here. I got artifacts without it so keeping it here for now. /estan |
1876 | if (itemType() == PathText || itemType() == PolyLine || itemType() == Spiral || itemType() == Line || itemType() == Symbol || itemType() == Group || itemType() == Table) |
||
7549 | fschmid | 1877 | doStroke=false; |
1878 | if ((doStroke) && (!m_Doc->RePos)) |
||
1879 | { |
||
14306 | fschmid | 1880 | p->setBlendModeStroke(lineBlendmode()); |
1881 | p->setPenOpacity(1.0 - lineTransparency()); |
||
14197 | fschmid | 1882 | if ((lineColor() != CommonStrings::None) || (!patternStrokeVal.isEmpty()) || (GrTypeStroke > 0)) |
14168 | fschmid | 1883 | { |
23046 | jghali | 1884 | p->setPen(m_strokeQColor, lwCorr, PLineArt, PLineEnd, PLineJoin); |
14168 | fschmid | 1885 | if (DashValues.count() != 0) |
1886 | p->setDash(DashValues, DashOffset); |
||
1887 | } |
||
1888 | else |
||
1889 | p->setLineWidth(0); |
||
17418 | fschmid | 1890 | if ((itemType() == LatexFrame) || (itemType() == ImageFrame) || (itemType() == OSGFrame)) |
1891 | p->setupPolygon(&PoLine); |
||
1892 | if (NamedLStyle.isEmpty()) |
||
1740 | cbradney | 1893 | { |
19513 | jghali | 1894 | ScPattern *strokePattern = m_Doc->checkedPattern(patternStrokeVal); |
1895 | if (strokePattern) |
||
13013 | fschmid | 1896 | { |
17418 | fschmid | 1897 | if (patternStrokePath) |
13013 | fschmid | 1898 | { |
17418 | fschmid | 1899 | QPainterPath guidePath = PoLine.toQPainterPath(false); |
1900 | DrawStrokePattern(p, guidePath); |
||
14168 | fschmid | 1901 | } |
17418 | fschmid | 1902 | else |
14197 | fschmid | 1903 | { |
19513 | jghali | 1904 | p->setPattern(strokePattern, patternStrokeScaleX, patternStrokeScaleY, patternStrokeOffsetX, patternStrokeOffsetY, patternStrokeRotation, patternStrokeSkewX, patternStrokeSkewY, patternStrokeMirrorX, patternStrokeMirrorY); |
17418 | fschmid | 1905 | p->setStrokeMode(ScPainter::Pattern); |
1906 | p->strokePath(); |
||
1907 | } |
||
1908 | } |
||
1909 | else if (GrTypeStroke > 0) |
||
1910 | { |
||
1911 | if ((!gradientStrokeVal.isEmpty()) && (!m_Doc->docGradients.contains(gradientStrokeVal))) |
||
23653 | craig | 1912 | gradientStrokeVal.clear(); |
17418 | fschmid | 1913 | if (!(gradientStrokeVal.isEmpty()) && (m_Doc->docGradients.contains(gradientStrokeVal))) |
1914 | stroke_gradient = m_Doc->docGradients[gradientStrokeVal]; |
||
22725 | jghali | 1915 | if (stroke_gradient.stops() < 2) // fall back to solid stroking if there are not enough colorstops in the gradient. |
17418 | fschmid | 1916 | { |
1917 | if (lineColor() != CommonStrings::None) |
||
14197 | fschmid | 1918 | { |
23046 | jghali | 1919 | p->setBrush(m_strokeQColor); |
17418 | fschmid | 1920 | p->setStrokeMode(ScPainter::Solid); |
14197 | fschmid | 1921 | } |
1922 | else |
||
1923 | { |
||
17418 | fschmid | 1924 | no_stroke = true; |
1925 | p->setStrokeMode(ScPainter::None); |
||
14197 | fschmid | 1926 | } |
1927 | } |
||
17418 | fschmid | 1928 | else |
14168 | fschmid | 1929 | { |
17418 | fschmid | 1930 | p->setStrokeMode(ScPainter::Gradient); |
1931 | p->stroke_gradient = stroke_gradient; |
||
19163 | fschmid | 1932 | p->stroke_gradient.setRepeatMethod(GrStrokeExtend); |
23904 | jghali | 1933 | if (GrTypeStroke == Gradient_Linear) |
17418 | fschmid | 1934 | p->setGradient(VGradient::linear, FPoint(GrStrokeStartX, GrStrokeStartY), FPoint(GrStrokeEndX, GrStrokeEndY), FPoint(GrStrokeStartX, GrStrokeStartY), GrStrokeScale, GrStrokeSkew); |
1935 | else |
||
1936 | p->setGradient(VGradient::radial, FPoint(GrStrokeStartX, GrStrokeStartY), FPoint(GrStrokeEndX, GrStrokeEndY), FPoint(GrStrokeFocalX, GrStrokeFocalY), GrStrokeScale, GrStrokeSkew); |
||
13013 | fschmid | 1937 | } |
17418 | fschmid | 1938 | p->strokePath(); |
13013 | fschmid | 1939 | } |
17418 | fschmid | 1940 | else if (lineColor() != CommonStrings::None) |
1941 | { |
||
1942 | p->setStrokeMode(ScPainter::Solid); |
||
23046 | jghali | 1943 | p->setPen(m_strokeQColor, lwCorr, PLineArt, PLineEnd, PLineJoin); |
17418 | fschmid | 1944 | if (DashValues.count() != 0) |
1945 | p->setDash(DashValues, DashOffset); |
||
1946 | p->strokePath(); |
||
1947 | } |
||
7549 | fschmid | 1948 | else |
17418 | fschmid | 1949 | no_stroke = true; |
18732 | fschmid | 1950 | if (lineTransparency() > 0.9) |
1951 | no_stroke = true; |
||
17418 | fschmid | 1952 | } |
1953 | else |
||
1954 | { |
||
1955 | p->setStrokeMode(ScPainter::Solid); |
||
23707 | jghali | 1956 | multiLine ml = m_Doc->docLineStyles[NamedLStyle]; |
17418 | fschmid | 1957 | QColor tmp; |
1958 | for (int it = ml.size()-1; it > -1; it--) |
||
5572 | fschmid | 1959 | { |
17418 | fschmid | 1960 | struct SingleLine& sl = ml[it]; |
1961 | // Qt4 if ((!sl.Color != CommonStrings::None) && (sl.Width != 0)) |
||
1962 | if (sl.Color != CommonStrings::None) // && (sl.Width != 0)) |
||
6568 | fschmid | 1963 | { |
17418 | fschmid | 1964 | SetQColor(&tmp, sl.Color, sl.Shade); |
1965 | p->setPen(tmp, sl.Width, static_cast<Qt::PenStyle>(sl.Dash), static_cast<Qt::PenCapStyle>(sl.LineEnd), static_cast<Qt::PenJoinStyle>(sl.LineJoin)); |
||
1966 | p->strokePath(); |
||
6568 | fschmid | 1967 | } |
5572 | fschmid | 1968 | } |
1740 | cbradney | 1969 | } |
14308 | fschmid | 1970 | p->setBlendModeStroke(0); |
7549 | fschmid | 1971 | } |
5746 | fschmid | 1972 | } |
1740 | cbradney | 1973 | } |
14208 | fschmid | 1974 | p->setFillMode(ScPainter::Solid); |
14469 | fschmid | 1975 | p->setBlendModeFill(0); |
14208 | fschmid | 1976 | p->setStrokeMode(ScPainter::Solid); |
14469 | fschmid | 1977 | p->setBlendModeStroke(0); |
14681 | fschmid | 1978 | p->restore(); |
1979 | } |
||
1980 | |||
1981 | void PageItem::DrawObj_Decoration(ScPainter *p) |
||
1982 | { |
||
1983 | p->save(); |
||
21106 | fschmid | 1984 | // p->setAntialiasing(false); |
14681 | fschmid | 1985 | if (!isEmbedded) |
18032 | craig | 1986 | p->translate(m_xPos, m_yPos); |
18022 | craig | 1987 | p->rotate(m_rotation); |
4084 | cbradney | 1988 | if ((!isEmbedded) && (!m_Doc->RePos)) |
2434 | fschmid | 1989 | { |
17790 | fschmid | 1990 | double scpInv = 0; |
16105 | fschmid | 1991 | if (!isGroup()) |
1740 | cbradney | 1992 | { |
18007 | craig | 1993 | if ((drawFrame()) && (m_Doc->guidesPrefs().framesShown) && ((itemType() == ImageFrame) || (itemType() == LatexFrame) || (itemType() == OSGFrame) || (itemType() == PathText)) && (no_stroke)) |
3919 | fschmid | 1994 | { |
23060 | craig | 1995 | p->setPen(PrefsManager::instance().appPrefs.displayPrefs.frameNormColor, scpInv, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
7549 | fschmid | 1996 | if ((isBookmark) || (m_isAnnotation)) |
23060 | craig | 1997 | p->setPen(PrefsManager::instance().appPrefs.displayPrefs.frameAnnotationColor, scpInv, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
23912 | craig | 1998 | if ((m_backBox != nullptr) || (m_nextBox != nullptr)) |
23060 | craig | 1999 | p->setPen(PrefsManager::instance().appPrefs.displayPrefs.frameLinkColor, scpInv, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
7549 | fschmid | 2000 | if (m_Locked) |
23060 | craig | 2001 | p->setPen(PrefsManager::instance().appPrefs.displayPrefs.frameLockColor, scpInv, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
24527 | jghali | 2002 | p->setFillMode(ScPainter::None); |
23244 | jghali | 2003 | if (itemType() == PathText) |
3919 | fschmid | 2004 | { |
7549 | fschmid | 2005 | if (Clip.count() != 0) |
3919 | fschmid | 2006 | { |
7549 | fschmid | 2007 | FPointArray tclip; |
2008 | FPoint np = FPoint(Clip.point(0)); |
||
2009 | tclip.resize(2); |
||
2010 | tclip.setPoint(0, np); |
||
2011 | tclip.setPoint(1, np); |
||
8557 | subik | 2012 | for (int a = 1; a < Clip.size(); ++a) |
7549 | fschmid | 2013 | { |
2014 | np = FPoint(Clip.point(a)); |
||
2015 | tclip.putPoints(tclip.size(), 4, np.x(), np.y(), np.x(), np.y(), np.x(), np.y(), np.x(), np.y()); |
||
2016 | } |
||
2017 | np = FPoint(Clip.point(0)); |
||
2018 | tclip.putPoints(tclip.size(), 2, np.x(), np.y(), np.x(), np.y()); |
||
2019 | p->setupPolygon(&tclip); |
||
3919 | fschmid | 2020 | } |
2021 | } |
||
12004 | fschmid | 2022 | else |
17790 | fschmid | 2023 | p->setupSharpPolygon(&PoLine); |
7549 | fschmid | 2024 | p->strokePath(); |
3919 | fschmid | 2025 | } |
1740 | cbradney | 2026 | } |
22600 | craig | 2027 | if ((m_Doc->guidesPrefs().framesShown) && textFlowUsesContourLine() && (!ContourLine.empty())) |
8494 | fschmid | 2028 | { |
17790 | fschmid | 2029 | p->setPen(Qt::darkGray, 0, Qt::DotLine, Qt::FlatCap, Qt::MiterJoin); |
2030 | p->setupSharpPolygon(&ContourLine); |
||
8494 | fschmid | 2031 | p->strokePath(); |
2032 | } |
||
23244 | jghali | 2033 | if (itemType() == ImageFrame) |
14808 | fschmid | 2034 | { |
14971 | cbradney | 2035 | double minres = m_Doc->checkerProfiles()[m_Doc->curCheckProfile()].minResolution; |
2036 | double maxres = m_Doc->checkerProfiles()[m_Doc->curCheckProfile()].maxResolution; |
||
2037 | bool checkres = m_Doc->checkerProfiles()[m_Doc->curCheckProfile()].checkResolution; |
||
17224 | craig | 2038 | if ((((72.0 / imageXScale()) < minres) |
14808 | fschmid | 2039 | || ((72.0 / imageYScale()) < minres) |
2040 | || ((72.0 / imageXScale()) > maxres) |
||
2041 | || ((72.0 / imageYScale()) > maxres)) |
||
23060 | craig | 2042 | && (isRaster) && (checkres) && (!m_Doc->drawAsPreview) && (PrefsManager::instance().appPrefs.displayPrefs.showVerifierWarningsOnCanvas)) |
14808 | fschmid | 2043 | { |
18095 | craig | 2044 | double ofx = m_width - 22.0; |
2045 | double ofy = m_height - 22.0; |
||
18983 | fschmid | 2046 | if ((m_width > 40) && (m_height > 40)) |
2047 | { |
||
2048 | p->save(); |
||
2049 | p->translate(ofx, ofy); |
||
23054 | craig | 2050 | QImage ico = IconManager::instance().loadPixmap("22/dialog-warning.png").toImage(); |
18983 | fschmid | 2051 | p->drawImage(&ico); |
2052 | p->restore(); |
||
2053 | } |
||
14808 | fschmid | 2054 | } |
2055 | } |
||
19261 | craig | 2056 | if ((m_Doc->guidesPrefs().layerMarkersShown) && |
2057 | (m_Doc->layerCount() > 1) && |
||
22832 | craig | 2058 | (!m_Doc->layerOutline(m_layerID)) && |
19354 | craig | 2059 | (!isGroupChild()) && |
19261 | craig | 2060 | (!m_Doc->drawAsPreview)) |
1740 | cbradney | 2061 | { |
17790 | fschmid | 2062 | p->setPen(Qt::black, 0, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
5619 | fschmid | 2063 | p->setPenOpacity(1.0); |
22832 | craig | 2064 | p->setBrush(m_Doc->layerMarker(m_layerID)); |
5619 | fschmid | 2065 | p->setBrushOpacity(1.0); |
5572 | fschmid | 2066 | p->setFillMode(ScPainter::Solid); |
5584 | fschmid | 2067 | double ofwh = 10; |
18095 | craig | 2068 | double ofx = m_width - ofwh/2; |
2069 | double ofy = m_height - ofwh*3; |
||
17790 | fschmid | 2070 | p->drawSharpRect(ofx, ofy, ofwh, ofwh); |
5572 | fschmid | 2071 | } |
17394 | fschmid | 2072 | if (no_fill && no_stroke && m_Doc->guidesPrefs().framesShown) |
2073 | { |
||
23060 | craig | 2074 | p->setPen(PrefsManager::instance().appPrefs.displayPrefs.frameNormColor, scpInv, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
17394 | fschmid | 2075 | if (m_Locked) |
23060 | craig | 2076 | p->setPen(PrefsManager::instance().appPrefs.displayPrefs.frameLockColor, scpInv, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
17394 | fschmid | 2077 | p->setFillMode(ScPainter::None); |
18095 | craig | 2078 | p->drawSharpRect(0, 0, m_width, m_height); |
17394 | fschmid | 2079 | no_fill = false; |
2080 | no_stroke = false; |
||
2081 | } |
||
4145 | cbradney | 2082 | //CB disabled for now |
4847 | cbradney | 2083 | //if (m_Doc->m_Selection->findItem(this)!=-1) |
4145 | cbradney | 2084 | // drawLockedMarker(p); |
2434 | fschmid | 2085 | } |
8180 | fschmid | 2086 | FrameOnly = false; |
21106 | fschmid | 2087 | // p->setAntialiasing(true); |
2434 | fschmid | 2088 | p->restore(); |
1740 | cbradney | 2089 | } |
2090 | |||
11052 | avox | 2091 |