Rev 25004 | 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); |
24730 | jghali | 527 | |
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 | } |
24730 | jghali | 539 | else if (m_Doc->itemToolPrefs().shapeLineColor != CommonStrings::None) |
14168 | fschmid | 540 | { |
24730 | jghali | 541 | const ScColor& col = m_Doc->PageColors[m_Doc->itemToolPrefs().shapeLineColor]; |
542 | QColor qcol = ScColorEngine::getRGBColor(col, m_Doc); |
||
543 | stroke_gradient.addStop(qcol, 0.0, 0.5, 1.0, m_Doc->itemToolPrefs().shapeLineColor, 100); |
||
544 | stroke_gradient.addStop(qcol, 1.0, 0.5, 1.0, m_Doc->itemToolPrefs().shapeLineColor, 100); |
||
14168 | fschmid | 545 | } |
24730 | jghali | 546 | else if (m_fillColor != CommonStrings::None) |
547 | { |
||
548 | const ScColor& col = m_Doc->PageColors[m_fillColor]; |
||
549 | QColor qcol = ScColorEngine::getRGBColor(col, m_Doc); |
||
550 | stroke_gradient.addStop(qcol, 0.0, 0.5, 1.0, m_fillColor, 100); |
||
551 | stroke_gradient.addStop(qcol, 1.0, 0.5, 1.0, m_fillColor, 100); |
||
552 | } |
||
553 | else if (m_Doc->itemToolPrefs().shapeFillColor != CommonStrings::None) |
||
554 | { |
||
555 | const ScColor& col = m_Doc->PageColors[m_Doc->itemToolPrefs().shapeFillColor]; |
||
556 | QColor qcol = ScColorEngine::getRGBColor(col, m_Doc); |
||
557 | stroke_gradient.addStop(qcol, 0.0, 0.5, 1.0, m_Doc->itemToolPrefs().shapeFillColor, 100); |
||
558 | stroke_gradient.addStop(qcol, 1.0, 0.5, 1.0, m_Doc->itemToolPrefs().shapeFillColor, 100); |
||
559 | } |
||
560 | else if (m_Doc->PageColors.contains("Black")) |
||
561 | { |
||
562 | const ScColor& col = m_Doc->PageColors["Black"]; |
||
563 | QColor qcol = ScColorEngine::getRGBColor(col, m_Doc); |
||
564 | stroke_gradient.addStop(qcol, 0.0, 0.5, 1.0, "Black", 100); |
||
565 | stroke_gradient.addStop(qcol, 1.0, 0.5, 1.0, "Black", 100); |
||
566 | } |
||
68 | Franz | 567 | fill_gradient = VGradient(VGradient::linear); |
295 | Franz | 568 | fill_gradient.clearStops(); |
23044 | jghali | 569 | if (m_fillColor != CommonStrings::None) |
7478 | jghali | 570 | { |
23044 | jghali | 571 | const ScColor& col = m_Doc->PageColors[m_fillColor]; |
12642 | jghali | 572 | QColor qcol = ScColorEngine::getRGBColor(col, m_Doc); |
23044 | jghali | 573 | fill_gradient.addStop(qcol, 0.0, 0.5, 1.0, m_fillColor, 100); |
574 | fill_gradient.addStop(qcol, 1.0, 0.5, 1.0, m_fillColor, 100); |
||
575 | GrColorP1 = m_fillColor; |
||
576 | GrColorP2 = m_fillColor; |
||
577 | GrColorP3 = m_fillColor; |
||
578 | GrColorP4 = m_fillColor; |
||
7478 | jghali | 579 | } |
304 | Franz | 580 | else |
7478 | jghali | 581 | { |
14932 | cbradney | 582 | if (m_Doc->itemToolPrefs().shapeFillColor != CommonStrings::None) |
7656 | fschmid | 583 | { |
14932 | cbradney | 584 | const ScColor& col = m_Doc->PageColors[m_Doc->itemToolPrefs().shapeFillColor]; |
12642 | jghali | 585 | QColor qcol = ScColorEngine::getRGBColor(col, m_Doc); |
14932 | cbradney | 586 | fill_gradient.addStop(qcol, 0.0, 0.5, 1.0, m_Doc->itemToolPrefs().shapeFillColor, 100); |
587 | fill_gradient.addStop(qcol, 1.0, 0.5, 1.0, m_Doc->itemToolPrefs().shapeFillColor, 100); |
||
14952 | fschmid | 588 | GrColorP1 = m_Doc->itemToolPrefs().shapeFillColor; |
589 | GrColorP2 = m_Doc->itemToolPrefs().shapeFillColor; |
||
590 | GrColorP3 = m_Doc->itemToolPrefs().shapeFillColor; |
||
591 | GrColorP4 = m_Doc->itemToolPrefs().shapeFillColor; |
||
7656 | fschmid | 592 | } |
593 | else |
||
594 | { |
||
23044 | jghali | 595 | if (m_lineColor != CommonStrings::None) |
7656 | fschmid | 596 | { |
23044 | jghali | 597 | const ScColor& col = m_Doc->PageColors[m_lineColor]; |
12642 | jghali | 598 | QColor qcol = ScColorEngine::getRGBColor(col, m_Doc); |
23044 | jghali | 599 | fill_gradient.addStop(qcol, 0.0, 0.5, 1.0, m_lineColor, 100); |
600 | fill_gradient.addStop(qcol, 1.0, 0.5, 1.0, m_lineColor, 100); |
||
601 | GrColorP1 = m_lineColor; |
||
602 | GrColorP2 = m_lineColor; |
||
603 | GrColorP3 = m_lineColor; |
||
604 | GrColorP4 = m_lineColor; |
||
7656 | fschmid | 605 | } |
606 | else |
||
607 | { |
||
14932 | cbradney | 608 | if (m_Doc->itemToolPrefs().shapeLineColor != CommonStrings::None) |
7656 | fschmid | 609 | { |
14932 | cbradney | 610 | const ScColor& col = m_Doc->PageColors[m_Doc->itemToolPrefs().shapeLineColor]; |
12642 | jghali | 611 | QColor qcol = ScColorEngine::getRGBColor(col, m_Doc); |
14932 | cbradney | 612 | fill_gradient.addStop(qcol, 0.0, 0.5, 1.0, m_Doc->itemToolPrefs().shapeLineColor, 100); |
613 | fill_gradient.addStop(qcol, 1.0, 0.5, 1.0, m_Doc->itemToolPrefs().shapeLineColor, 100); |
||
14952 | fschmid | 614 | GrColorP1 = m_Doc->itemToolPrefs().shapeLineColor; |
615 | GrColorP2 = m_Doc->itemToolPrefs().shapeLineColor; |
||
616 | GrColorP3 = m_Doc->itemToolPrefs().shapeLineColor; |
||
617 | GrColorP4 = m_Doc->itemToolPrefs().shapeLineColor; |
||
7656 | fschmid | 618 | } |
12642 | jghali | 619 | else if (m_Doc->PageColors.contains("Black")) |
620 | { |
||
621 | const ScColor& col = m_Doc->PageColors["Black"]; |
||
622 | QColor qcol = ScColorEngine::getRGBColor(col, m_Doc); |
||
623 | fill_gradient.addStop(qcol, 0.0, 0.5, 1.0, "Black", 100); |
||
624 | fill_gradient.addStop(qcol, 1.0, 0.5, 1.0, "Black", 100); |
||
14952 | fschmid | 625 | GrColorP1 = "Black"; |
626 | GrColorP2 = "Black"; |
||
627 | GrColorP3 = "Black"; |
||
628 | GrColorP4 = "Black"; |
||
12642 | jghali | 629 | } |
7656 | fschmid | 630 | } |
631 | } |
||
7478 | jghali | 632 | } |
14297 | fschmid | 633 | GrMaskEndX = w; |
634 | mask_gradient = VGradient(VGradient::linear); |
||
24174 | jghali | 635 | mask_gradient.clearStops(); |
14297 | fschmid | 636 | const ScColor& col = m_Doc->PageColors["Black"]; |
637 | QColor qcol = ScColorEngine::getRGBColor(col, m_Doc); |
||
638 | mask_gradient.addStop(qcol, 0.0, 0.5, 1.0, "Black", 100); |
||
639 | mask_gradient.addStop(qcol, 1.0, 0.5, 1.0, "Black", 100); |
||
15024 | fschmid | 640 | |
22296 | craig | 641 | QList<MeshPoint> mgList; |
642 | MeshPoint mgP; |
||
16869 | fschmid | 643 | meshGradientPatch patch; |
644 | mgP.resetTo(FPoint(0.0, 0.0)); |
||
15024 | fschmid | 645 | mgP.transparency = 1.0; |
646 | mgP.shade = 100; |
||
647 | mgP.colorName = "Black"; |
||
648 | mgP.color = qcol; |
||
649 | mgList.append(mgP); |
||
16869 | fschmid | 650 | patch.TL = mgP; |
18095 | craig | 651 | mgP.resetTo(FPoint(m_width / 2.0, 0.0)); |
15024 | fschmid | 652 | mgList.append(mgP); |
18095 | craig | 653 | mgP.resetTo(FPoint(m_width, 0.0)); |
15024 | fschmid | 654 | mgList.append(mgP); |
16869 | fschmid | 655 | patch.TR = mgP; |
15024 | fschmid | 656 | meshGradientArray.append(mgList); |
657 | mgList.clear(); |
||
18095 | craig | 658 | mgP.resetTo(FPoint(0.0, m_height / 2.0)); |
15024 | fschmid | 659 | mgList.append(mgP); |
18095 | craig | 660 | mgP.resetTo(FPoint(m_width / 2.0, m_height / 2.0)); |
15024 | fschmid | 661 | mgList.append(mgP); |
18095 | craig | 662 | mgP.resetTo(FPoint(m_width, m_height / 2.0)); |
15024 | fschmid | 663 | mgList.append(mgP); |
664 | meshGradientArray.append(mgList); |
||
665 | mgList.clear(); |
||
18095 | craig | 666 | mgP.resetTo(FPoint(0.0, m_height)); |
15024 | fschmid | 667 | mgList.append(mgP); |
16869 | fschmid | 668 | patch.BL = mgP; |
18095 | craig | 669 | mgP.resetTo(FPoint(m_width / 2.0, m_height)); |
15024 | fschmid | 670 | mgList.append(mgP); |
18095 | craig | 671 | mgP.resetTo(FPoint(m_width, m_height)); |
15024 | fschmid | 672 | mgList.append(mgP); |
16869 | fschmid | 673 | patch.BR = mgP; |
15024 | fschmid | 674 | meshGradientArray.append(mgList); |
16869 | fschmid | 675 | meshGradientPatches.append(patch); |
15024 | fschmid | 676 | |
24217 | jghali | 677 | m_firstLineOffset = m_Doc->itemToolPrefs().firstLineOffset; |
22832 | craig | 678 | m_columns = m_Doc->itemToolPrefs().textColumns; |
679 | m_columnGap = m_Doc->itemToolPrefs().textColumnGap; |
||
23912 | craig | 680 | |
13888 | jghali | 681 | OnMasterPage = m_Doc->currentPage() ? m_Doc->currentPage()->pageName() : QString(); |
14932 | cbradney | 682 | m_startArrowIndex = m_Doc->itemToolPrefs().lineStartArrow; |
683 | m_endArrowIndex = m_Doc->itemToolPrefs().lineEndArrow; |
||
2056 | fschmid | 684 | effectsInUse.clear(); |
24217 | jghali | 685 | |
1659 | cbradney | 686 | //Page Item Attributes |
687 | pageItemAttributes.clear(); |
||
24217 | jghali | 688 | for (const ObjectAttribute& objAttr : qAsConst(m_Doc->itemAttributes())) |
1659 | cbradney | 689 | { |
24217 | jghali | 690 | if ((objAttr.autoaddto == "textframes" && m_itemType == TextFrame) || |
691 | (objAttr.autoaddto == "imageframes" && m_itemType == ImageFrame)) |
||
692 | { |
||
693 | pageItemAttributes.append(objAttr); |
||
694 | } |
||
1659 | cbradney | 695 | } |
24217 | jghali | 696 | |
18935 | fschmid | 697 | hatchBackground = CommonStrings::None; |
698 | hatchBackgroundQ = QColor(); |
||
699 | hatchForeground = "Black"; |
||
700 | hatchForegroundQ = qcol; |
||
3 | paul | 701 | } |
702 | |||
17826 | craig | 703 | PageItem::~PageItem() |
704 | { |
||
18203 | fschmid | 705 | if ((isTempFile) && (!Pfile.isEmpty())) |
706 | QFile::remove(Pfile); |
||
17826 | craig | 707 | //remove marks |
708 | |||
709 | if (isTextFrame()) |
||
710 | { |
||
24518 | jghali | 711 | if (!asTextFrame()->isInChain() && itemText.length() > 0) |
17826 | craig | 712 | { |
24518 | jghali | 713 | for (int pos = 0; pos < itemText.length(); ++pos) |
17826 | craig | 714 | { |
19641 | craig | 715 | if (itemText.hasMark(pos)) |
17826 | craig | 716 | { |
19641 | craig | 717 | Mark* mrk = itemText.mark(pos); |
18047 | craig | 718 | if (!mrk->isType(MARKBullNumType)) |
719 | m_Doc->eraseMark(mrk); |
||
17826 | craig | 720 | } |
721 | } |
||
722 | } |
||
723 | } |
||
724 | // if (isWeld()) |
||
725 | // unWeldFromMaster(true); |
||
726 | // if (isWelded()) |
||
727 | // unWeldChild(); |
||
728 | } |
||
729 | |||
24417 | jghali | 730 | bool PageItem::isMasterItem() const |
731 | { |
||
732 | if (Parent == nullptr) |
||
733 | return !OnMasterPage.isEmpty(); |
||
734 | |||
735 | PageItem* parentItem = Parent; |
||
736 | while (parentItem && parentItem->Parent) |
||
737 | parentItem = parentItem->Parent; |
||
738 | return !parentItem->OnMasterPage.isEmpty(); |
||
739 | } |
||
740 | |||
18794 | jghali | 741 | bool PageItem::isGroupChild() const |
742 | { |
||
22516 | craig | 743 | return (dynamic_cast<PageItem_Group*>(Parent) != nullptr); |
18794 | jghali | 744 | } |
745 | |||
746 | bool PageItem::isTableCell() const |
||
747 | { |
||
22516 | craig | 748 | return (dynamic_cast<PageItem_Table*>(Parent) != nullptr); |
18794 | jghali | 749 | } |
750 | |||
4644 | cbradney | 751 | void PageItem::setXPos(const double newXPos, bool drawingOnly) |
3903 | cbradney | 752 | { |
18032 | craig | 753 | m_xPos = newXPos; |
4644 | cbradney | 754 | if (drawingOnly || m_Doc->isLoading()) |
755 | return; |
||
4621 | cbradney | 756 | checkChanges(); |
3903 | cbradney | 757 | } |
758 | |||
4644 | cbradney | 759 | void PageItem::setYPos(const double newYPos, bool drawingOnly) |
3903 | cbradney | 760 | { |
18032 | craig | 761 | m_yPos = newYPos; |
4644 | cbradney | 762 | if (drawingOnly || m_Doc->isLoading()) |
763 | return; |
||
4621 | cbradney | 764 | checkChanges(); |
3903 | cbradney | 765 | } |
766 | |||
4644 | cbradney | 767 | void PageItem::setXYPos(const double newXPos, const double newYPos, bool drawingOnly) |
3903 | cbradney | 768 | { |
18032 | craig | 769 | m_xPos = newXPos; |
770 | m_yPos = newYPos; |
||
4644 | cbradney | 771 | if (drawingOnly || m_Doc->isLoading()) |
772 | return; |
||
4621 | cbradney | 773 | checkChanges(); |
3934 | cbradney | 774 | } |
775 | |||
18357 | jghali | 776 | int PageItem::level() const |
17092 | jghali | 777 | { |
18357 | jghali | 778 | PageItem* thisItem = const_cast<PageItem*>(this); |
22832 | craig | 779 | if (isGroupChild()) |
780 | return (Parent->asGroupFrame()->groupItemList.indexOf(thisItem) + 1); |
||
781 | if (!m_Doc) |
||
17092 | jghali | 782 | return 0; |
24730 | jghali | 783 | const auto* items = OnMasterPage.isEmpty() ? &m_Doc->DocItems : &m_Doc->MasterItems; |
22832 | craig | 784 | return (items->indexOf(thisItem) + 1); |
17092 | jghali | 785 | } |
786 | |||
4644 | cbradney | 787 | void PageItem::moveBy(const double dX, const double dY, bool drawingOnly) |
3934 | cbradney | 788 | { |
24467 | jghali | 789 | //qDebug() << "pageitem::moveby" << dX << dY; |
24730 | jghali | 790 | if (dX == 0.0 && dY == 0.0) |
3934 | cbradney | 791 | return; |
12820 | pierre | 792 | invalid = true; |
24587 | jghali | 793 | if (dX != 0.0) |
16115 | fschmid | 794 | { |
19220 | jghali | 795 | m_xPos += dX; |
796 | gXpos += dX; |
||
797 | BoundingX += dX; |
||
16115 | fschmid | 798 | } |
24587 | jghali | 799 | if (dY != 0.0) |
16115 | fschmid | 800 | { |
19220 | jghali | 801 | m_yPos += dY; |
802 | gYpos += dY; |
||
803 | BoundingY += dY; |
||
16115 | fschmid | 804 | } |
4644 | cbradney | 805 | if (drawingOnly || m_Doc->isLoading()) |
806 | return; |
||
17826 | craig | 807 | moveWelded(dX, dY); |
4621 | cbradney | 808 | checkChanges(); |
3903 | cbradney | 809 | } |
810 | |||
23025 | craig | 811 | void PageItem::setWidth(double newWidth) |
3934 | cbradney | 812 | { |
18095 | craig | 813 | m_width = newWidth; |
13013 | fschmid | 814 | updateConstants(); |
14681 | fschmid | 815 | if (m_Doc->isLoading()) |
816 | return; |
||
4621 | cbradney | 817 | checkChanges(); |
3934 | cbradney | 818 | } |
819 | |||
23025 | craig | 820 | void PageItem::setHeight(double newHeight) |
3934 | cbradney | 821 | { |
18095 | craig | 822 | m_height = newHeight; |
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::setWidthHeight(double newWidth, double newHeight, bool drawingOnly) |
8418 | fschmid | 830 | { |
18095 | craig | 831 | m_width = newWidth; |
832 | m_height = newHeight; |
||
13013 | fschmid | 833 | updateConstants(); |
8418 | fschmid | 834 | if (drawingOnly) |
835 | return; |
||
836 | checkChanges(); |
||
837 | } |
||
838 | |||
3934 | cbradney | 839 | void PageItem::setWidthHeight(const double newWidth, const double newHeight) |
840 | { |
||
18095 | craig | 841 | m_width = newWidth; |
842 | m_height = newHeight; |
||
13013 | fschmid | 843 | updateConstants(); |
14681 | fschmid | 844 | if (m_Doc->isLoading()) |
845 | return; |
||
4621 | cbradney | 846 | checkChanges(); |
3934 | cbradney | 847 | } |
848 | |||
849 | void PageItem::resizeBy(const double dH, const double dW) |
||
850 | { |
||
23257 | jghali | 851 | if (dH == 0.0 && dW == 0.0) |
3934 | cbradney | 852 | return; |
23257 | jghali | 853 | if (dH != 0.0) |
854 | m_width += dH; |
||
855 | if (dW != 0.0) |
||
856 | m_height += dW; |
||
13013 | fschmid | 857 | updateConstants(); |
14681 | fschmid | 858 | if (m_Doc->isLoading()) |
859 | return; |
||
4621 | cbradney | 860 | checkChanges(); |
3934 | cbradney | 861 | } |
862 | |||
4663 | cbradney | 863 | void PageItem::setRotation(const double newRotation, bool drawingOnly) |
3934 | cbradney | 864 | { |
18022 | craig | 865 | double dR = newRotation - m_rotation; |
866 | double oldRot = m_rotation; |
||
867 | m_rotation = newRotation; |
||
21386 | jghali | 868 | while (m_rotation < 0.0) |
869 | m_rotation += 360.0; |
||
870 | while (m_rotation > 360.0) |
||
871 | m_rotation -= 360.0; |
||
4663 | cbradney | 872 | if (drawingOnly || m_Doc->isLoading()) |
873 | return; |
||
17826 | craig | 874 | rotateWelded(dR, oldRot); |
14681 | fschmid | 875 | checkChanges(); |
3934 | cbradney | 876 | } |
877 | |||
878 | void PageItem::rotateBy(const double dR) |
||
879 | { |
||
880 | if (dR==0.0) |
||
881 | return; |
||
21386 | jghali | 882 | m_rotation += dR; |
883 | while (m_rotation < 0.0) |
||
884 | m_rotation += 360.0; |
||
885 | while (m_rotation > 360.0) |
||
886 | m_rotation -= 360.0; |
||
14681 | fschmid | 887 | if (m_Doc->isLoading()) |
888 | return; |
||
4621 | cbradney | 889 | checkChanges(); |
3934 | cbradney | 890 | } |
891 | |||
892 | void PageItem::setSelected(const bool toSelect) |
||
893 | { |
||
18022 | craig | 894 | m_isSelected=toSelect; |
3934 | cbradney | 895 | } |
896 | |||
3988 | cbradney | 897 | void PageItem::setImageXScale(const double newImageXScale) |
3985 | cbradney | 898 | { |
19263 | jghali | 899 | m_imageXScale = newImageXScale; |
14681 | fschmid | 900 | if (m_Doc->isLoading()) |
19263 | jghali | 901 | { |
902 | oldLocalScX = m_imageXScale; |
||
14681 | fschmid | 903 | return; |
19263 | jghali | 904 | } |
4821 | cbradney | 905 | checkChanges(); |
3985 | cbradney | 906 | } |
907 | |||
908 | void PageItem::setImageYScale(const double newImageYScale) |
||
909 | { |
||
19263 | jghali | 910 | m_imageYScale = newImageYScale; |
14681 | fschmid | 911 | if (m_Doc->isLoading()) |
19263 | jghali | 912 | { |
913 | oldLocalScY = m_imageYScale; |
||
14681 | fschmid | 914 | return; |
19263 | jghali | 915 | } |
4821 | cbradney | 916 | checkChanges(); |
3985 | cbradney | 917 | } |
918 | |||
919 | void PageItem::setImageXYScale(const double newImageXScale, const double newImageYScale) |
||
920 | { |
||
19263 | jghali | 921 | m_imageXScale = newImageXScale; |
922 | m_imageYScale = newImageYScale; |
||
14681 | fschmid | 923 | if (m_Doc->isLoading()) |
19263 | jghali | 924 | { |
925 | oldLocalScX = m_imageXScale; |
||
926 | oldLocalScY = m_imageYScale; |
||
14681 | fschmid | 927 | return; |
19263 | jghali | 928 | } |
4821 | cbradney | 929 | checkChanges(); |
3985 | cbradney | 930 | } |
931 | |||
3988 | cbradney | 932 | void PageItem::setImageXOffset(const double newImageXOffset) |
3985 | cbradney | 933 | { |
19263 | jghali | 934 | m_imageXOffset = newImageXOffset; |
14681 | fschmid | 935 | if (m_Doc->isLoading()) |
19263 | jghali | 936 | { |
937 | oldLocalX = m_imageXOffset; |
||
14681 | fschmid | 938 | return; |
19263 | jghali | 939 | } |
4821 | cbradney | 940 | checkChanges(); |
3985 | cbradney | 941 | } |
942 | |||
943 | void PageItem::setImageYOffset(const double newImageYOffset) |
||
944 | { |
||
19263 | jghali | 945 | m_imageYOffset = newImageYOffset; |
14681 | fschmid | 946 | if (m_Doc->isLoading()) |
19263 | jghali | 947 | { |
948 | oldLocalY = m_imageYOffset; |
||
14681 | fschmid | 949 | return; |
19263 | jghali | 950 | } |
4821 | cbradney | 951 | checkChanges(); |
3985 | cbradney | 952 | } |
953 | |||
954 | void PageItem::setImageXYOffset(const double newImageXOffset, const double newImageYOffset) |
||
955 | { |
||
19263 | jghali | 956 | m_imageXOffset = newImageXOffset; |
957 | m_imageYOffset = newImageYOffset; |
||
14681 | fschmid | 958 | if (m_Doc->isLoading()) |
19263 | jghali | 959 | { |
960 | oldLocalX = m_imageXOffset; |
||
961 | oldLocalY = m_imageYOffset; |
||
14681 | fschmid | 962 | return; |
19263 | jghali | 963 | } |
4821 | cbradney | 964 | checkChanges(); |
3985 | cbradney | 965 | } |
966 | |||
967 | void PageItem::moveImageXYOffsetBy(const double dX, const double dY) |
||
968 | { |
||
969 | if (dX==0.0 && dY==0.0) |
||
970 | return; |
||
16703 | jghali | 971 | if (dX != 0.0) |
18032 | craig | 972 | m_imageXOffset += dX; |
16703 | jghali | 973 | if (dY != 0.0) |
18032 | craig | 974 | m_imageYOffset += dY; |
14681 | fschmid | 975 | if (m_Doc->isLoading()) |
976 | return; |
||
4821 | cbradney | 977 | checkChanges(); |
3985 | cbradney | 978 | } |
979 | |||
14861 | fschmid | 980 | void PageItem::setImageRotation(const double newRotation) |
981 | { |
||
19263 | jghali | 982 | if (m_imageRotation == newRotation) |
17709 | craig | 983 | return; |
19263 | jghali | 984 | if (UndoManager::undoEnabled()) |
17744 | craig | 985 | { |
24730 | jghali | 986 | auto *ss = new SimpleState(Um::Rotate, QString(), Um::IRotate); |
20793 | jghali | 987 | ss->set("IMAGE_ROTATION"); |
19263 | jghali | 988 | ss->set("OLD_ROT", m_imageRotation); |
989 | ss->set("NEW_ROT", newRotation); |
||
23108 | jghali | 990 | undoManager->action(this, ss); |
17744 | craig | 991 | } |
18022 | craig | 992 | m_imageRotation = newRotation; |
14861 | fschmid | 993 | if (m_Doc->isLoading()) |
994 | return; |
||
995 | checkChanges(); |
||
996 | } |
||
997 | |||
23396 | jghali | 998 | |
999 | /// tests if a character is displayed by this frame |
||
1000 | bool PageItem::frameDisplays(int textpos) const |
||
1001 | { |
||
1002 | return 0 <= textpos && textpos < signed(m_maxChars) && textpos < itemText.length(); |
||
1003 | } |
||
1004 | |||
1005 | PageItem* PageItem::frameOfChar(int textPos) |
||
1006 | { |
||
1007 | PageItem* firstFrame = this->firstInChain(); |
||
1008 | PageItem* nextFrame = firstFrame; |
||
1009 | |||
1010 | while (nextFrame) |
||
1011 | { |
||
1012 | if (nextFrame->invalid) |
||
1013 | nextFrame->layout(); |
||
1014 | if (nextFrame->frameDisplays(textPos)) |
||
1015 | return nextFrame; |
||
1016 | nextFrame = nextFrame->nextInChain(); |
||
1017 | } |
||
1018 | |||
1019 | return nullptr; |
||
1020 | } |
||
1021 | |||
16621 | craig | 1022 | //return frame where is text end |
1023 | PageItem * PageItem::frameTextEnd() |
||
1024 | { |
||
1025 | PageItem * LastBox = this; |
||
23912 | craig | 1026 | if (frameOverflows() && m_nextBox) |
16621 | craig | 1027 | { // text ending in some next frame |
23912 | craig | 1028 | LastBox = m_nextBox; |
22600 | craig | 1029 | while (LastBox != nullptr && !LastBox->frameDisplays(itemText.length()-1)) |
16621 | craig | 1030 | LastBox = LastBox->nextInChain(); |
1031 | } |
||
23912 | craig | 1032 | else if (frameUnderflows() && m_backBox) |
16621 | craig | 1033 | { //text ending in some previous frame |
23912 | craig | 1034 | LastBox = m_backBox; |
22600 | craig | 1035 | while (LastBox != nullptr && !LastBox->frameDisplays(itemText.length()-1)) |
16621 | craig | 1036 | LastBox = LastBox->prevInChain(); |
1037 | } |
||
1038 | return LastBox; |
||
1039 | } |
||
5559 | avox | 1040 | |
1041 | /// returns true if text overflows |
||
1042 | bool PageItem::frameOverflows() const |
||
1043 | { |
||
12414 | jghali | 1044 | // Fix #6991 : "Text overflow" warning when there is a text underflow in fact |
22516 | craig | 1045 | /*return NextBox == nullptr && itemText.length() > static_cast<int>(MaxChars);*/ |
23912 | craig | 1046 | return ( m_nextBox == nullptr ) |
23196 | jghali | 1047 | && ( firstChar < itemText.length() ) |
13131 | jghali | 1048 | // Fix #7766 : scribus.textOverflows() returns 0 if there is no place for the overflow mark |
22832 | craig | 1049 | /*&& ( firstChar < MaxChars )*/ |
1050 | && ( firstChar <= m_maxChars ) |
||
23196 | jghali | 1051 | && ( itemText.length() > m_maxChars ); |
5559 | avox | 1052 | } |
1053 | |||
16845 | craig | 1054 | int PageItem::frameOverflowCount() const |
1055 | { |
||
1056 | if (frameOverflows()) |
||
22832 | craig | 1057 | return itemText.length()-m_maxChars; |
16845 | craig | 1058 | return 0; |
1059 | } |
||
1060 | |||
19188 | craig | 1061 | int PageItem::frameOverflowBlankCount() const |
1062 | { |
||
1063 | if (frameOverflows()) |
||
22832 | craig | 1064 | return itemText.plainText().right(itemText.length() - m_maxChars).count(QRegularExpression("\\s+")); |
19188 | craig | 1065 | return 0; |
1066 | } |
||
1067 | |||
24730 | jghali | 1068 | int PageItem::maxCharsInFrame() const |
17100 | fschmid | 1069 | { |
22832 | craig | 1070 | return m_maxChars; |
17100 | fschmid | 1071 | } |
1072 | |||
16621 | craig | 1073 | /// returns true if text is ending before that frame |
1074 | bool PageItem::frameUnderflows() const |
||
1075 | { |
||
23912 | craig | 1076 | if (m_backBox == nullptr) |
23071 | craig | 1077 | return false; |
16621 | craig | 1078 | //FIX ME - I have found that condition if frame is empty |
1079 | //and has been linked with previous frame |
||
1080 | //if you will find any better solution - fix that function |
||
1081 | return (firstInFrame() > lastInFrame()); |
||
1082 | } |
||
1083 | |||
16856 | craig | 1084 | void PageItem::drawOverflowMarker(ScPainter *p) |
1085 | { |
||
1086 | qreal sideLength = 10 / qMax(p->zoomFactor(), 1.0); |
||
1087 | qreal offset = 1 / qMax(p->zoomFactor(), 1.0); |
||
18095 | craig | 1088 | qreal left = m_width - sideLength-offset;// / 2; |
16856 | craig | 1089 | qreal right = left + sideLength; |
18095 | craig | 1090 | qreal top = m_height - sideLength-offset;// * 1.5; |
16856 | craig | 1091 | qreal bottom = top + sideLength; |
1092 | |||
23060 | craig | 1093 | QColor color(PrefsManager::instance().appPrefs.displayPrefs.frameNormColor); |
24730 | jghali | 1094 | if (isBookmark || m_isAnnotation) |
23060 | craig | 1095 | color = PrefsManager::instance().appPrefs.displayPrefs.frameAnnotationColor; |
23912 | craig | 1096 | if ((m_backBox != nullptr) || (m_nextBox != nullptr)) |
23060 | craig | 1097 | color = PrefsManager::instance().appPrefs.displayPrefs.frameLinkColor; |
16856 | craig | 1098 | if (m_Locked) |
23060 | craig | 1099 | color = PrefsManager::instance().appPrefs.displayPrefs.frameLockColor; |
16856 | craig | 1100 | if (m_Doc->m_Selection->containsItem(this)) |
1101 | color = Qt::red; |
||
1102 | |||
1103 | p->save(); |
||
1104 | |||
17790 | fschmid | 1105 | p->setPen(color, 0, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
16856 | craig | 1106 | p->setPenOpacity(1.0); |
1107 | p->setBrush(Qt::white); |
||
1108 | p->setBrushOpacity(1.0); |
||
1109 | p->setFillMode(ScPainter::Solid); |
||
17790 | fschmid | 1110 | p->drawSharpRect(left, top, sideLength, sideLength); |
1111 | p->drawSharpLine(QPointF(left, top), QPointF(right, bottom)); |
||
1112 | p->drawSharpLine(QPointF(left, bottom), QPointF(right, top)); |
||
16856 | craig | 1113 | |
1114 | p->restore(); |
||
1115 | } |
||
1116 | |||
5559 | avox | 1117 | int PageItem::firstInFrame() const |
1118 | { |
||
5721 | avox | 1119 | return firstChar; |
5559 | avox | 1120 | } |
23398 | craig | 1121 | |
5559 | avox | 1122 | int PageItem::lastInFrame() const |
1123 | { |
||
22832 | craig | 1124 | return qMin(signed(m_maxChars), itemText.length()) - 1; |
5559 | avox | 1125 | } |
1126 | |||
22713 | jghali | 1127 | bool PageItem::canBeLinkedTo(const PageItem* nxt) const |
16589 | jghali | 1128 | { |
1129 | if (this->nextInChain() ) |
||
1130 | return false; |
||
18338 | jghali | 1131 | if (!nxt || nxt->prevInChain() ) |
16589 | jghali | 1132 | return false; |
22713 | jghali | 1133 | for (const PageItem* ff = nxt; ff; ff = ff->nextInChain()) |
16589 | jghali | 1134 | { |
22713 | jghali | 1135 | if (ff == this) |
1136 | return false; |
||
16589 | jghali | 1137 | } |
23365 | jghali | 1138 | // If object is placed on a master page, it can be linked only to objects placed on same master page |
1139 | // Same for objects placed on standard pages : they can only be linked to objects placed on standard pages |
||
23881 | craig | 1140 | return OnMasterPage == nxt->OnMasterPage; |
16589 | jghali | 1141 | } |
7994 | avox | 1142 | |
17708 | craig | 1143 | void PageItem::link(PageItem* nxt, bool addPARSEP) |
7994 | avox | 1144 | { |
1145 | assert( !nextInChain() ); |
||
1146 | assert( !nxt->prevInChain() ); |
||
8075 | avox | 1147 | for (PageItem* ff=nxt; ff; ff=ff->nextInChain()) |
1148 | { |
||
1149 | assert (ff != this); |
||
1150 | } |
||
13655 | jghali | 1151 | // Append only if necessary to avoid the |
1152 | // charstyle: access at end of text warning |
||
17708 | craig | 1153 | bool first = false; |
1154 | bool createUndo = addPARSEP; |
||
1155 | |||
22516 | craig | 1156 | if (nxt->prevInChain() == nullptr) |
17708 | craig | 1157 | first = true; |
1158 | int textLen = itemText.length(); |
||
13655 | jghali | 1159 | if (nxt->itemText.length() > 0) |
17708 | craig | 1160 | { //case when text will be joined with next frame text |
1161 | //do not add PARSEP if first frame has no text or text ends already with PARSEP |
||
1162 | if (addPARSEP && (textLen > 0) && (itemText.text(textLen-1) != SpecialChars::PARSEP)) |
||
1163 | itemText.insertChars(textLen, SpecialChars::PARSEP); |
||
1164 | else |
||
1165 | addPARSEP = false; |
||
13655 | jghali | 1166 | itemText.append(nxt->itemText); |
17708 | craig | 1167 | } |
22279 | jghali | 1168 | else |
1169 | addPARSEP = false; |
||
23912 | craig | 1170 | m_nextBox = nxt; |
1171 | nxt->m_backBox = this; |
||
8325 | avox | 1172 | // update AutoText |
1173 | if (isAutoText) |
||
1174 | { |
||
1175 | PageItem* after = nxt; |
||
1176 | while (after) |
||
1177 | { |
||
1178 | after->isAutoText = true; |
||
1179 | m_Doc->LastAuto = after; |
||
23912 | craig | 1180 | after = after->m_nextBox; |
8325 | avox | 1181 | } |
1182 | } |
||
1183 | else if (nxt->isAutoText) |
||
1184 | { |
||
1185 | PageItem* before = this; |
||
1186 | while (before) |
||
1187 | { |
||
1188 | before->isAutoText = true; |
||
1189 | m_Doc->FirstAuto = before; |
||
23912 | craig | 1190 | before = before->m_backBox; |
8325 | avox | 1191 | } |
1192 | } |
||
7994 | avox | 1193 | invalid = true; |
21495 | jghali | 1194 | PageItem* prev = this; |
23912 | craig | 1195 | while (prev->m_backBox && !prev->m_backBox->frameOverflows()) |
21495 | jghali | 1196 | { |
23912 | craig | 1197 | prev->m_backBox->invalid = true; |
1198 | prev = prev->m_backBox; |
||
21495 | jghali | 1199 | } |
8325 | avox | 1200 | while (nxt) |
1201 | { |
||
9490 | avox | 1202 | nxt->itemText = itemText; |
8325 | avox | 1203 | nxt->invalid = true; |
1204 | nxt->firstChar = 0; |
||
23912 | craig | 1205 | nxt = nxt->m_nextBox; |
8325 | avox | 1206 | } |
17708 | craig | 1207 | if (UndoManager::undoEnabled() && createUndo) //addPARESEP is false only if linking is invoked from undo action for unlinkWithText |
16490 | craig | 1208 | { |
17744 | craig | 1209 | ScItemState<QPair<PageItem*, PageItem*> > *is = new ScItemState<QPair<PageItem*, PageItem*> >(Um::LinkTextFrame); |
20793 | jghali | 1210 | is->set("LINK_TEXT_FRAME"); |
17708 | craig | 1211 | is->set("FIRST", first); |
1212 | is->set("JOIN_POS", textLen); |
||
1213 | is->set("ADDPARSEP", addPARSEP); |
||
23912 | craig | 1214 | is->setItem(qMakePair(this, m_nextBox)); |
16490 | craig | 1215 | undoManager->action(this, is); |
1216 | } |
||
7994 | avox | 1217 | } |
1218 | |||
17708 | craig | 1219 | void PageItem::unlink(bool createUndo) |
7994 | avox | 1220 | { |
23912 | craig | 1221 | if (m_nextBox) |
7994 | avox | 1222 | { |
23912 | craig | 1223 | PageItem *undoNextBox=m_nextBox; |
7994 | avox | 1224 | // make sure lastInFrame is valid |
1225 | layout(); |
||
12246 | cbradney | 1226 | /* |
1227 | //<< CB #6332: Stop the StoryText cut and break and act like other publishing apps |
||
7994 | avox | 1228 | // move following text to new StoryText |
1229 | itemText.select(lastInFrame()+1, itemText.length()-lastInFrame()-1); |
||
12246 | cbradney | 1230 | */ |
7994 | avox | 1231 | StoryText follow(m_Doc); |
12246 | cbradney | 1232 | /* |
7994 | avox | 1233 | follow.setDefaultStyle(itemText.defaultStyle()); |
1234 | follow.insert(0, itemText, true); |
||
1235 | // remove following text from this chain |
||
1236 | itemText.removeSelection(); |
||
12246 | cbradney | 1237 | //>> |
1238 | */ |
||
8325 | avox | 1239 | // update auto pointers |
1240 | if (isAutoText) |
||
1241 | { |
||
1242 | PageItem* before = this; |
||
1243 | while (before) |
||
1244 | { |
||
1245 | before->isAutoText = false; |
||
23912 | craig | 1246 | before = before->m_backBox; |
8325 | avox | 1247 | } |
23912 | craig | 1248 | m_Doc->FirstAuto = m_nextBox; |
8325 | avox | 1249 | } |
7994 | avox | 1250 | // link following frames to new text |
23912 | craig | 1251 | m_nextBox->firstChar = 0; |
1252 | m_nextBox->m_backBox = nullptr; |
||
1253 | while (m_nextBox) |
||
22832 | craig | 1254 | { |
23912 | craig | 1255 | m_nextBox->itemText = follow; |
1256 | m_nextBox->invalid = true; |
||
1257 | m_nextBox->firstChar = 0; |
||
1258 | m_nextBox = m_nextBox->m_nextBox; |
||
7994 | avox | 1259 | } |
22516 | craig | 1260 | // NextBox == nullptr now |
23912 | craig | 1261 | m_nextBox = nullptr; |
17708 | craig | 1262 | if (UndoManager::undoEnabled() && createUndo) |
16490 | craig | 1263 | { |
17744 | craig | 1264 | ScItemState<QPair<PageItem*, PageItem*> > *is = new ScItemState<QPair<PageItem*, PageItem*> >(Um::UnlinkTextFrame); |
20793 | jghali | 1265 | is->set("UNLINK_TEXT_FRAME"); |
17744 | craig | 1266 | is->setItem(qMakePair(this, undoNextBox)); |
16490 | craig | 1267 | undoManager->action(this, is); |
1268 | } |
||
7994 | avox | 1269 | } |
1270 | } |
||
1271 | |||
8325 | avox | 1272 | void PageItem::dropLinks() |
1273 | { |
||
1274 | // update auto pointers |
||
23912 | craig | 1275 | if (isAutoText && m_nextBox == nullptr) |
1276 | m_Doc->LastAuto = m_backBox; |
||
1277 | if (isAutoText && m_backBox == nullptr) |
||
1278 | m_Doc->FirstAuto = m_nextBox; |
||
8325 | avox | 1279 | isAutoText = false; |
1280 | |||
1281 | // leave text in remaining chain |
||
23912 | craig | 1282 | PageItem* before = m_backBox; |
1283 | PageItem* after = m_nextBox; |
||
22563 | craig | 1284 | if (after == nullptr && before == nullptr) |
19549 | jghali | 1285 | return; |
1286 | |||
1287 | itemText = StoryText(m_Doc); |
||
19905 | jghali | 1288 | |
1289 | int afterChar = 0; |
||
19549 | jghali | 1290 | if (before) |
19905 | jghali | 1291 | { |
23912 | craig | 1292 | before->m_nextBox = after; |
22832 | craig | 1293 | afterChar = qMin((int) before->m_maxChars, before->itemText.length()); |
19905 | jghali | 1294 | } |
19549 | jghali | 1295 | if (after) |
8325 | avox | 1296 | { |
23912 | craig | 1297 | after->m_backBox = before; |
19549 | jghali | 1298 | while (after) |
1299 | { |
||
1300 | after->invalid = true; |
||
19905 | jghali | 1301 | after->firstChar = afterChar; |
23912 | craig | 1302 | after = after->m_nextBox; |
8325 | avox | 1303 | } |
1304 | } |
||
19549 | jghali | 1305 | |
1306 | if (UndoManager::undoEnabled()) |
||
1307 | { |
||
1308 | ScItemState<QPair<PageItem*, PageItem*> > *is = new ScItemState<QPair<PageItem*, PageItem*> >(Um::UnlinkTextFrame); |
||
20793 | jghali | 1309 | is->set("DROP_LINKS"); |
23912 | craig | 1310 | is->setItem(qMakePair(m_backBox, m_nextBox)); |
19549 | jghali | 1311 | undoManager->action(this, is); |
1312 | } |
||
1313 | |||
22516 | craig | 1314 | // JG we should set BackBox and NextBox to nullptr at a point |
23912 | craig | 1315 | m_backBox = m_nextBox = nullptr; |
8325 | avox | 1316 | } |
1317 | |||
17565 | craig | 1318 | //unlink selected frame from text chain |
1319 | //but copy or cut its content from itemText |
||
22713 | jghali | 1320 | void PageItem::unlinkWithText() |
17565 | craig | 1321 | { |
24617 | jghali | 1322 | PageItem* next = m_nextBox; |
1323 | PageItem* prev = m_backBox; |
||
17708 | craig | 1324 | int length = itemText.length(); |
1325 | |||
22110 | jghali | 1326 | if (this->invalid) |
1327 | layout(); |
||
1328 | |||
17708 | craig | 1329 | //unlink first frame in chain |
24617 | jghali | 1330 | if (prev == nullptr) |
17708 | craig | 1331 | { |
24617 | jghali | 1332 | if (next->invalid) |
1333 | next->layout(); |
||
17708 | craig | 1334 | if (lastInFrame() < length -1) |
1335 | { |
||
1336 | StoryText content(m_Doc); |
||
23914 | jghali | 1337 | itemText.select(lastInFrame() + 1, length - (lastInFrame() + 1)); |
22713 | jghali | 1338 | content.insert(0, itemText, true); |
17708 | craig | 1339 | itemText.removeSelection(); |
1340 | unlink(false); |
||
24617 | jghali | 1341 | next->itemText.insert(0, content); |
1342 | next->update(); |
||
17708 | craig | 1343 | } |
1344 | else |
||
1345 | { |
||
1346 | unlink(false); |
||
1347 | } |
||
1348 | } |
||
1349 | else |
||
1350 | { |
||
24617 | jghali | 1351 | if (prev->invalid) |
1352 | prev->layout(); |
||
17708 | craig | 1353 | itemText.select(firstInFrame(), length - firstInFrame()); |
1354 | StoryText content(m_Doc); |
||
1355 | content.insert(0, itemText, true); |
||
22713 | jghali | 1356 | itemText.removeSelection(); |
24617 | jghali | 1357 | prev->unlink(false); |
17708 | craig | 1358 | itemText.insert(0, content); |
1359 | update(); |
||
1360 | } |
||
1361 | if (UndoManager::undoEnabled()) |
||
1362 | { |
||
17744 | craig | 1363 | ScItemState<QPair<PageItem*, PageItem*> > *is = new ScItemState<QPair<PageItem*, PageItem*> >(Um::UnlinkTextFrame); |
20793 | jghali | 1364 | is->set("UNLINK_TEXT_FRAME"); |
24617 | jghali | 1365 | is->set("CUT_TEXT", true); |
1366 | is->setItem(qMakePair(prev, next)); |
||
17708 | craig | 1367 | undoManager->action(this, is); |
1368 | } |
||
17565 | craig | 1369 | } |
1370 | |||
5559 | avox | 1371 | /// returns the style at the current charpos |
1372 | const ParagraphStyle& PageItem::currentStyle() const |
||
1373 | { |
||
21355 | jghali | 1374 | int cursorPosition = itemText.cursorPosition(); |
23940 | jghali | 1375 | if (itemText.hasSelection()) |
21355 | jghali | 1376 | { |
1377 | int firstSelected = itemText.startOfSelection(); |
||
1378 | int lastSelected = qMax(itemText.endOfSelection() - 1, 0); |
||
1379 | cursorPosition = qMax(firstSelected, qMin(cursorPosition, lastSelected)); |
||
1380 | } |
||
22011 | jghali | 1381 | // Note: cursor position can be past last characters, don't use frameDisplays() here |
1382 | if (cursorPosition >= 0 && cursorPosition <= itemText.length()) |
||
21355 | jghali | 1383 | return itemText.paragraphStyle(cursorPosition); |
1384 | return itemText.defaultStyle(); |
||
5559 | avox | 1385 | } |
1386 | |||
5569 | avox | 1387 | /// returns the style at the current charpos for changing |
1388 | ParagraphStyle& PageItem::changeCurrentStyle() |
||
1389 | { |
||
21355 | jghali | 1390 | int cursorPosition = itemText.cursorPosition(); |
23940 | jghali | 1391 | if (itemText.hasSelection()) |
21355 | jghali | 1392 | { |
1393 | int firstSelected = itemText.startOfSelection(); |
||
1394 | int lastSelected = qMax(itemText.endOfSelection() - 1, 0); |
||
1395 | cursorPosition = qMax(firstSelected, qMin(cursorPosition, lastSelected)); |
||
1396 | } |
||
22011 | jghali | 1397 | // Note: cursor position can be past last characters, don't use frameDisplays() here |
1398 | if (cursorPosition >= 0 && cursorPosition <= itemText.length()) |
||
21355 | jghali | 1399 | return const_cast<ParagraphStyle&>(itemText.paragraphStyle(cursorPosition)); |
22600 | craig | 1400 | return const_cast<ParagraphStyle&>(itemText.defaultStyle()); |
5569 | avox | 1401 | } |
1402 | |||
5559 | avox | 1403 | /// returns the style at the current charpos |
1404 | const CharStyle& PageItem::currentCharStyle() const |
||
1405 | { |
||
21355 | jghali | 1406 | int cursorPosition = itemText.cursorPosition(); |
23940 | jghali | 1407 | if (itemText.hasSelection()) |
21355 | jghali | 1408 | { |
1409 | int firstSelected = itemText.startOfSelection(); |
||
1410 | int lastSelected = qMax(itemText.endOfSelection() - 1, 0); |
||
1411 | cursorPosition = qMax(firstSelected, qMin(cursorPosition, lastSelected)); |
||
1412 | } |
||
22011 | jghali | 1413 | // Note: cursor position can be past last characters, don't use frameDisplays() here |
1414 | if (cursorPosition >= 0 && cursorPosition <= itemText.length()) |
||
21355 | jghali | 1415 | return itemText.charStyle(cursorPosition); |
22600 | craig | 1416 | return itemText.defaultStyle().charStyle(); |
5559 | avox | 1417 | } |
1418 | |||
16838 | jghali | 1419 | void PageItem::currentTextProps(ParagraphStyle& parStyle) const |
1420 | { |
||
21500 | jghali | 1421 | const ParagraphStyle& curStyle = this->currentStyle(); |
1422 | parStyle.setContext(curStyle.context()); |
||
1423 | parStyle = curStyle; |
||
1424 | |||
16838 | jghali | 1425 | int position = itemText.cursorPosition(); |
23940 | jghali | 1426 | if (itemText.hasSelection()) |
16838 | jghali | 1427 | position = qMin(qMax(itemText.endOfSelection() - 1, 0), qMax(position, itemText.startOfSelection())); |
1428 | |||
22011 | jghali | 1429 | // Note: cursor position can be past last characters, don't use frameDisplays() here |
1430 | if (position >= 0 && position <= itemText.length()) |
||
21129 | jghali | 1431 | { |
1432 | // Do not use setStyle here otherwise char style properties explicitly |
||
1433 | // set at paragraph level without using styles might get lost |
||
1434 | parStyle.charStyle().applyCharStyle( itemText.charStyle(position) ); |
||
1435 | } |
||
16838 | jghali | 1436 | else |
1437 | parStyle.charStyle().setStyle( itemText.defaultStyle().charStyle() ); |
||
1438 | } |
||
1439 | |||
3988 | cbradney | 1440 | void PageItem::setTextToFrameDistLeft(double newLeft) |
1441 | { |
||
23244 | jghali | 1442 | if (m_textDistanceMargins.left() == newLeft) |
17641 | craig | 1443 | return; |
1444 | if (UndoManager::undoEnabled()) |
||
1445 | { |
||
24730 | jghali | 1446 | auto *ss = new SimpleState(Um::TextFrameDist, QString(), Um::ITextFrame); |
20793 | jghali | 1447 | ss->set("LEFT_TEXTFRAMEDIST"); |
23244 | jghali | 1448 | ss->set("OLD_DIST", m_textDistanceMargins.left()); |
1449 | ss->set("NEW_DIST", newLeft); |
||
17641 | craig | 1450 | undoManager->action(this, ss); |
1451 | } |
||
19831 | craig | 1452 | m_textDistanceMargins.setLeft(newLeft); |
16546 | jghali | 1453 | //emit textToFrameDistances(Extra, TExtra, BExtra, RExtra); |
3988 | cbradney | 1454 | } |
3985 | cbradney | 1455 | |
3988 | cbradney | 1456 | void PageItem::setTextToFrameDistRight(double newRight) |
1457 | { |
||
23244 | jghali | 1458 | if (m_textDistanceMargins.right() == newRight) |
17641 | craig | 1459 | return; |
1460 | if (UndoManager::undoEnabled()) |
||
1461 | { |
||
24730 | jghali | 1462 | auto *ss = new SimpleState(Um::TextFrameDist, QString(), Um::ITextFrame); |
20793 | jghali | 1463 | ss->set("RIGHT_TEXTFRAMEDIST"); |
23244 | jghali | 1464 | ss->set("OLD_DIST", m_textDistanceMargins.right()); |
1465 | ss->set("NEW_DIST", newRight); |
||
17641 | craig | 1466 | undoManager->action(this, ss); |
1467 | } |
||
19831 | craig | 1468 | m_textDistanceMargins.setRight(newRight); |
16546 | jghali | 1469 | //emit textToFrameDistances(Extra, TExtra, BExtra, RExtra); |
3988 | cbradney | 1470 | } |
3985 | cbradney | 1471 | |
3988 | cbradney | 1472 | void PageItem::setTextToFrameDistTop(double newTop) |
1473 | { |
||
23244 | jghali | 1474 | if (m_textDistanceMargins.top() == newTop) |
17641 | craig | 1475 | return; |
1476 | if (UndoManager::undoEnabled()) |
||
1477 | { |
||
24730 | jghali | 1478 | auto *ss = new SimpleState(Um::TextFrameDist, QString(), Um::ITextFrame); |
20793 | jghali | 1479 | ss->set("TOP_TEXTFRAMEDIST"); |
23244 | jghali | 1480 | ss->set("OLD_DIST", m_textDistanceMargins.top()); |
1481 | ss->set("NEW_DIST", newTop); |
||
17641 | craig | 1482 | undoManager->action(this, ss); |
1483 | } |
||
19831 | craig | 1484 | m_textDistanceMargins.setTop(newTop); |
16546 | jghali | 1485 | //emit textToFrameDistances(Extra, TExtra, BExtra, RExtra); |
3988 | cbradney | 1486 | } |
3985 | cbradney | 1487 | |
3988 | cbradney | 1488 | void PageItem::setTextToFrameDistBottom(double newBottom) |
1489 | { |
||
23244 | jghali | 1490 | if (m_textDistanceMargins.bottom() == newBottom) |
17641 | craig | 1491 | return; |
1492 | if (UndoManager::undoEnabled()) |
||
1493 | { |
||
24730 | jghali | 1494 | auto *ss = new SimpleState(Um::TextFrameDist, QString(), Um::ITextFrame); |
20793 | jghali | 1495 | ss->set("BOTTOM_TEXTFRAMEDIST"); |
23244 | jghali | 1496 | ss->set("OLD_DIST", m_textDistanceMargins.bottom()); |
1497 | ss->set("NEW_DIST", newBottom); |
||
17641 | craig | 1498 | undoManager->action(this, ss); |
1499 | } |
||
19831 | craig | 1500 | m_textDistanceMargins.setBottom(newBottom); |
16546 | jghali | 1501 | //emit textToFrameDistances(Extra, TExtra, BExtra, RExtra); |
3988 | cbradney | 1502 | } |
3985 | cbradney | 1503 | |
3988 | cbradney | 1504 | void PageItem::setTextToFrameDist(double newLeft, double newRight, double newTop, double newBottom) |
1505 | { |
||
19421 | jghali | 1506 | UndoTransaction activeTransaction; |
17641 | craig | 1507 | if (UndoManager::undoEnabled()) |
23942 | jghali | 1508 | activeTransaction = undoManager->beginTransaction(Um::TextFrame, Um::IDocument, Um::TextFrameDist, QString(), Um::ITextFrame); |
17641 | craig | 1509 | setTextToFrameDistLeft(newLeft); |
1510 | setTextToFrameDistRight(newRight); |
||
1511 | setTextToFrameDistTop(newTop); |
||
1512 | setTextToFrameDistBottom(newBottom); |
||
1513 | if (activeTransaction) |
||
19421 | jghali | 1514 | activeTransaction.commit(); |
16546 | jghali | 1515 | //emit textToFrameDistances(Extra, TExtra, BExtra, RExtra); |
3988 | cbradney | 1516 | } |
3985 | cbradney | 1517 | |
22832 | craig | 1518 | double PageItem::gridOffset() const |
1519 | { |
||
1520 | return m_Doc->guidesPrefs().offsetBaselineGrid; |
||
1521 | } |
||
1522 | double PageItem::gridDistance() const |
||
1523 | { |
||
1524 | return m_Doc->guidesPrefs().valueBaselineGrid; |
||
1525 | } |
||
5559 | avox | 1526 | |
1527 | void PageItem::setGridOffset(double) { } // FIXME |
||
1528 | void PageItem::setGridDistance(double) { } // FIXME |
||
22832 | craig | 1529 | |
1530 | void PageItem::setColumns(int newColumnCount) |
||
5559 | avox | 1531 | { |
24730 | jghali | 1532 | if (m_columns == newColumnCount) |
17641 | craig | 1533 | return; |
19415 | jghali | 1534 | if (UndoManager::undoEnabled()) |
17744 | craig | 1535 | { |
24730 | jghali | 1536 | auto *ss = new SimpleState(Um::Columns, QString(), Um::IBorder); |
20793 | jghali | 1537 | ss->set("COLUMNS"); |
22832 | craig | 1538 | ss->set("OLD_COLUMNS", m_columns); |
1539 | ss->set("NEW_COLUMNS", newColumnCount); |
||
17641 | craig | 1540 | undoManager->action(this, ss); |
1541 | } |
||
22832 | craig | 1542 | m_columns = qMax(1, newColumnCount); |
5559 | avox | 1543 | } |
22832 | craig | 1544 | |
1545 | void PageItem::setColumnGap(double newColumnGap) |
||
5559 | avox | 1546 | { |
24730 | jghali | 1547 | if (m_columnGap == newColumnGap) |
17641 | craig | 1548 | return; |
22832 | craig | 1549 | if (UndoManager::undoEnabled()) |
1550 | { |
||
24730 | jghali | 1551 | auto *ss = new SimpleState(Um::Columns, QString(), Um::IBorder); |
20793 | jghali | 1552 | ss->set("COLUMNSGAP"); |
22832 | craig | 1553 | ss->set("OLD_COLUMNS", m_columnGap); |
1554 | ss->set("NEW_COLUMNS", newColumnGap); |
||
17641 | craig | 1555 | undoManager->action(this, ss); |
1556 | } |
||
22832 | craig | 1557 | m_columnGap = newColumnGap; |
5559 | avox | 1558 | } |
1559 | |||
18889 | fschmid | 1560 | int PageItem::verticalAlignment() |
1561 | { |
||
1562 | return verticalAlign; |
||
1563 | } |
||
1564 | |||
1565 | void PageItem::setVerticalAlignment(int val) |
||
1566 | { |
||
1567 | if (val == verticalAlign) |
||
1568 | return; |
||
19415 | jghali | 1569 | if (UndoManager::undoEnabled()) |
19132 | craig | 1570 | { |
24730 | jghali | 1571 | auto *ss = new SimpleState(Um::AlignText, QString(), Um::ITextFrame); |
20793 | jghali | 1572 | ss->set("VERTICAL_ALIGN"); |
19132 | craig | 1573 | ss->set("OLD_VERTALIGN", verticalAlign); |
1574 | ss->set("NEW_VERTALIGN", val); |
||
1575 | undoManager->action(this, ss); |
||
1576 | } |
||
18889 | fschmid | 1577 | verticalAlign = val; |
1578 | } |
||
1579 | |||
3989 | cbradney | 1580 | void PageItem::setCornerRadius(double newRadius) |
1581 | { |
||
23370 | jghali | 1582 | if (m_roundedCornerRadius == newRadius) |
17644 | craig | 1583 | return; |
19415 | jghali | 1584 | if (UndoManager::undoEnabled()) |
17744 | craig | 1585 | { |
24730 | jghali | 1586 | auto *state = new SimpleState(Um::RoundCorner, QString(), Um::IBorder); |
20793 | jghali | 1587 | state->set("CORNER_RADIUS"); |
23370 | jghali | 1588 | state->set("OLD_RADIUS", m_roundedCornerRadius); |
23244 | jghali | 1589 | state->set("NEW_RADIUS", newRadius); |
17744 | craig | 1590 | undoManager->action(this,state); |
1591 | } |
||
23370 | jghali | 1592 | m_roundedCornerRadius=newRadius; |
16546 | jghali | 1593 | //emit cornerRadius(RadRect); |
3989 | cbradney | 1594 | } |
3985 | cbradney | 1595 | |
3988 | cbradney | 1596 | |
1597 | |||
10840 | avox | 1598 | /** Paints the item. |
1599 | CHANGE: cullingArea is in doc coordinates! |
||
1600 | */ |
||
11052 | avox | 1601 | void PageItem::DrawObj(ScPainter *p, QRectF cullingArea) |
3 | paul | 1602 | { |
19515 | jghali | 1603 | // #12698: Prevent drawing of line items |
1604 | /*if (PoLine.isEmpty()) |
||
1605 | return;*/ |
||
10945 | jghali | 1606 | if (cullingArea.isNull()) |
10840 | avox | 1607 | { |
23007 | craig | 1608 | cullingArea = QRectF(QPointF(m_Doc->minCanvasCoordinate.x(), m_Doc->minCanvasCoordinate.y()), |
10840 | avox | 1609 | QPointF(m_Doc->maxCanvasCoordinate.x(), m_Doc->maxCanvasCoordinate.y())).toAlignedRect(); |
1610 | } |
||
17394 | fschmid | 1611 | |
1612 | no_fill = false; |
||
1613 | no_stroke = false; |
||
14681 | fschmid | 1614 | DrawObj_Pre(p); |
22832 | craig | 1615 | if (m_Doc->layerOutline(m_layerID)) |
5572 | fschmid | 1616 | { |
24730 | jghali | 1617 | if (itemType() == TextFrame || itemType() == ImageFrame || itemType() == PathText || itemType() == Line || itemType() == PolyLine || itemType() == Group || itemType() == Symbol) |
14681 | fschmid | 1618 | DrawObj_Item(p, cullingArea); |
5572 | fschmid | 1619 | } |
1620 | else |
||
7549 | fschmid | 1621 | { |
16105 | fschmid | 1622 | DrawObj_Item(p, cullingArea); |
7549 | fschmid | 1623 | } |
2434 | fschmid | 1624 | DrawObj_Post(p); |
1736 | cbradney | 1625 | } |
1626 | |||
14681 | fschmid | 1627 | void PageItem::DrawObj_Pre(ScPainter *p) |
1740 | cbradney | 1628 | { |
1741 | cbradney | 1629 | p->save(); |
18729 | fschmid | 1630 | double lwCorr = m_lineWidth; |
1631 | double sc = p->zoomFactor(); |
||
1632 | if ((m_lineWidth * sc) < 1) |
||
1633 | lwCorr = 0; |
||
2434 | fschmid | 1634 | if (!isEmbedded) |
18032 | craig | 1635 | p->translate(m_xPos, m_yPos); |
18022 | craig | 1636 | p->rotate(m_rotation); |
19514 | jghali | 1637 | |
22832 | craig | 1638 | if (m_Doc->layerOutline(m_layerID)) |
1741 | cbradney | 1639 | { |
22832 | craig | 1640 | p->setPen(m_Doc->layerMarker(m_layerID), 0, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
5572 | fschmid | 1641 | p->setFillMode(ScPainter::None); |
1642 | p->setBrushOpacity(1.0); |
||
1643 | p->setPenOpacity(1.0); |
||
19514 | jghali | 1644 | return; |
1741 | cbradney | 1645 | } |
19514 | jghali | 1646 | |
20047 | fschmid | 1647 | if ((hasSoftShadow()) && (m_Doc->appMode != modeEdit)) |
19514 | jghali | 1648 | DrawSoftShadow(p); |
20111 | fschmid | 1649 | if (isGroup()) |
1650 | return; |
||
19514 | jghali | 1651 | p->setBlendModeFill(fillBlendmode()); |
1652 | p->setLineWidth(lwCorr); |
||
1653 | if (GrType != 0) |
||
1741 | cbradney | 1654 | { |
23904 | jghali | 1655 | if (GrType == Gradient_Pattern) |
1741 | cbradney | 1656 | { |
23046 | jghali | 1657 | ScPattern *pattern = m_Doc->checkedPattern(m_patternName); |
19514 | jghali | 1658 | if (!pattern) |
5572 | fschmid | 1659 | { |
14297 | fschmid | 1660 | p->fill_gradient = VGradient(VGradient::linear); |
19514 | jghali | 1661 | p->fill_gradient.setRepeatMethod(GrExtend); |
14297 | fschmid | 1662 | if (fillColor() != CommonStrings::None) |
6368 | fschmid | 1663 | { |
23046 | jghali | 1664 | p->setBrush(m_fillQColor); |
14297 | fschmid | 1665 | p->setFillMode(ScPainter::Solid); |
7684 | fschmid | 1666 | } |
1667 | else |
||
17394 | fschmid | 1668 | { |
1669 | no_fill = true; |
||
14297 | fschmid | 1670 | p->setFillMode(ScPainter::None); |
17394 | fschmid | 1671 | } |
23046 | jghali | 1672 | if ((!m_patternName.isEmpty()) && (!m_Doc->docPatterns.contains(m_patternName))) |
19514 | jghali | 1673 | { |
1674 | GrType = 0; |
||
23046 | jghali | 1675 | m_patternName = ""; |
19514 | jghali | 1676 | } |
6368 | fschmid | 1677 | } |
19514 | jghali | 1678 | else |
5572 | fschmid | 1679 | { |
19514 | jghali | 1680 | p->setPattern(pattern, patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation, patternSkewX, patternSkewY, patternMirrorX, patternMirrorY); |
1681 | p->setFillMode(ScPainter::Pattern); |
||
5572 | fschmid | 1682 | } |
19514 | jghali | 1683 | } |
1684 | else |
||
1685 | { |
||
23904 | jghali | 1686 | if (GrType == Gradient_4Colors) |
14297 | fschmid | 1687 | { |
19514 | jghali | 1688 | p->setFillMode(ScPainter::Gradient); |
24730 | jghali | 1689 | FPoint pG1(0, 0); |
1690 | FPoint pG2(width(), 0); |
||
1691 | FPoint pG3(width(), height()); |
||
1692 | FPoint pG4(0, height()); |
||
19514 | jghali | 1693 | p->set4ColorGeometry(pG1, pG2, pG3, pG4, GrControl1, GrControl2, GrControl3, GrControl4); |
23046 | jghali | 1694 | p->set4ColorColors(m_grQColorP1, m_grQColorP2, m_grQColorP3, m_grQColorP4); |
14297 | fschmid | 1695 | } |
23904 | jghali | 1696 | else if (GrType == Gradient_Hatch) |
14308 | fschmid | 1697 | { |
19514 | jghali | 1698 | if (fillColor() != CommonStrings::None) |
23046 | jghali | 1699 | p->setBrush(m_fillQColor); |
19514 | jghali | 1700 | p->setFillMode(ScPainter::Hatch); |
1701 | p->setHatchParameters(hatchType, hatchDistance, hatchAngle, hatchUseBackground, hatchBackgroundQ, hatchForegroundQ, width(), height()); |
||
1702 | } |
||
1703 | else |
||
1704 | { |
||
23046 | jghali | 1705 | if ((!m_gradientName.isEmpty()) && (!m_Doc->docGradients.contains(m_gradientName))) |
1706 | m_gradientName = ""; |
||
1707 | if (!(m_gradientName.isEmpty()) && (m_Doc->docGradients.contains(m_gradientName))) |
||
1708 | fill_gradient = m_Doc->docGradients[m_gradientName]; |
||
23904 | jghali | 1709 | if ((fill_gradient.stops() < 2) && (GrType < Gradient_4Colors)) // fall back to solid filling if there are not enough colorstops in the gradient. |
14308 | fschmid | 1710 | { |
19514 | jghali | 1711 | if (fillColor() != CommonStrings::None) |
1712 | { |
||
23046 | jghali | 1713 | p->setBrush(m_fillQColor); |
19514 | jghali | 1714 | p->setFillMode(ScPainter::Solid); |
1715 | } |
||
14318 | fschmid | 1716 | else |
19514 | jghali | 1717 | { |
1718 | no_fill = true; |
||
1719 | p->setFillMode(ScPainter::None); |
||
1720 | } |
||
14308 | fschmid | 1721 | } |
19513 | jghali | 1722 | else |
1723 | { |
||
19514 | jghali | 1724 | p->setFillMode(ScPainter::Gradient); |
1725 | p->fill_gradient = fill_gradient; |
||
1726 | p->fill_gradient.setRepeatMethod(GrExtend); |
||
1727 | switch (GrType) |
||
1728 | { |
||
23904 | jghali | 1729 | case Gradient_LinearLegacy1: |
1730 | case Gradient_LinearLegacy2: |
||
1731 | case Gradient_LinearLegacy3: |
||
1732 | case Gradient_LinearLegacy4: |
||
1733 | case Gradient_Linear: |
||
19514 | jghali | 1734 | p->setGradient(VGradient::linear, FPoint(GrStartX, GrStartY), FPoint(GrEndX, GrEndY), FPoint(GrStartX, GrStartY), GrScale, GrSkew); |
1735 | break; |
||
23904 | jghali | 1736 | case Gradient_RadialLegacy5: |
1737 | case Gradient_Radial: |
||
19514 | jghali | 1738 | p->setGradient(VGradient::radial, FPoint(GrStartX, GrStartY), FPoint(GrEndX, GrEndY), FPoint(GrFocalX, GrFocalY), GrScale, GrSkew); |
1739 | break; |
||
23904 | jghali | 1740 | case Gradient_Diamond: |
19514 | jghali | 1741 | p->setFillMode(ScPainter::Gradient); |
1742 | p->setDiamondGeometry(FPoint(0, 0), FPoint(width(), 0), FPoint(width(), height()), FPoint(0, height()), GrControl1, GrControl2, GrControl3, GrControl4, GrControl5); |
||
1743 | break; |
||
23904 | jghali | 1744 | case Gradient_Mesh: |
1745 | case Gradient_Conical: |
||
19514 | jghali | 1746 | p->setFillMode(ScPainter::Gradient); |
1747 | p->setMeshGradient(FPoint(0, 0), FPoint(width(), 0), FPoint(width(), height()), FPoint(0, height()), meshGradientArray); |
||
1748 | break; |
||
23904 | jghali | 1749 | case Gradient_PatchMesh: |
19514 | jghali | 1750 | p->setFillMode(ScPainter::Gradient); |
1751 | p->setMeshGradient(FPoint(0, 0), FPoint(width(), 0), FPoint(width(), height()), FPoint(0, height()), meshGradientPatches); |
||
1752 | break; |
||
1753 | } |
||
19513 | jghali | 1754 | } |
14308 | fschmid | 1755 | } |
19514 | jghali | 1756 | } |
1757 | } |
||
1758 | else |
||
1759 | { |
||
1760 | p->fill_gradient = VGradient(VGradient::linear); |
||
1761 | if (fillColor() != CommonStrings::None) |
||
1762 | { |
||
23046 | jghali | 1763 | p->setBrush(m_fillQColor); |
19514 | jghali | 1764 | p->setFillMode(ScPainter::Solid); |
1765 | } |
||
1766 | else |
||
1767 | { |
||
1768 | no_fill = true; |
||
1769 | p->setFillMode(ScPainter::None); |
||
1770 | } |
||
1771 | } |
||
1772 | if ((lineColor() != CommonStrings::None) || (!patternStrokeVal.isEmpty()) || (GrTypeStroke > 0)) |
||
1773 | { |
||
23046 | jghali | 1774 | p->setPen(m_strokeQColor, lwCorr, PLineArt, PLineEnd, PLineJoin); |
19514 | jghali | 1775 | if (DashValues.count() != 0) |
1776 | p->setDash(DashValues, DashOffset); |
||
1777 | } |
||
1778 | else |
||
1779 | p->setLineWidth(0); |
||
1780 | p->setBrushOpacity(1.0 - fillTransparency()); |
||
1781 | p->setPenOpacity(1.0 - lineTransparency()); |
||
1782 | p->setFillRule(fillRule); |
||
23907 | jghali | 1783 | if ((GrMask == GradMask_Linear) || (GrMask == GradMask_Radial) || (GrMask == GradMask_LinearLumAlpha) || (GrMask == GradMask_RadialLumAlpha)) |
19514 | jghali | 1784 | { |
23907 | jghali | 1785 | if ((GrMask == GradMask_Linear) || (GrMask == GradMask_Radial)) |
19514 | jghali | 1786 | p->setMaskMode(1); |
1787 | else |
||
1788 | p->setMaskMode(3); |
||
1789 | if ((!gradientMaskVal.isEmpty()) && (!m_Doc->docGradients.contains(gradientMaskVal))) |
||
1790 | gradientMaskVal = ""; |
||
1791 | if (!(gradientMaskVal.isEmpty()) && (m_Doc->docGradients.contains(gradientMaskVal))) |
||
1792 | mask_gradient = m_Doc->docGradients[gradientMaskVal]; |
||
1793 | p->mask_gradient = mask_gradient; |
||
23907 | jghali | 1794 | if ((GrMask == GradMask_Linear) || (GrMask == GradMask_LinearLumAlpha)) |
19514 | jghali | 1795 | p->setGradientMask(VGradient::linear, FPoint(GrMaskStartX, GrMaskStartY), FPoint(GrMaskEndX, GrMaskEndY), FPoint(GrMaskStartX, GrMaskStartY), GrMaskScale, GrMaskSkew); |
1796 | else |
||
1797 | p->setGradientMask(VGradient::radial, FPoint(GrMaskStartX, GrMaskStartY), FPoint(GrMaskEndX, GrMaskEndY), FPoint(GrMaskFocalX, GrMaskFocalY), GrMaskScale, GrMaskSkew); |
||
1798 | } |
||
23907 | jghali | 1799 | else if ((GrMask == GradMask_Pattern) || (GrMask == GradMask_PatternLumAlpha) || (GrMask == GradMask_PatternLumAlphaInverted) || (GrMask == GradMask_PatternInverted)) |
19514 | jghali | 1800 | { |
1801 | ScPattern *patternMask = m_Doc->checkedPattern(patternMaskVal); |
||
1802 | if (patternMask) |
||
1803 | { |
||
1804 | p->setPatternMask(patternMask, patternMaskScaleX, patternMaskScaleY, patternMaskOffsetX, patternMaskOffsetY, patternMaskRotation, patternMaskSkewX, patternMaskSkewY, patternMaskMirrorX, patternMaskMirrorY); |
||
23907 | jghali | 1805 | if (GrMask == GradMask_Pattern) |
19514 | jghali | 1806 | p->setMaskMode(2); |
23907 | jghali | 1807 | else if (GrMask == GradMask_PatternLumAlpha) |
19514 | jghali | 1808 | p->setMaskMode(4); |
23907 | jghali | 1809 | else if (GrMask == GradMask_PatternLumAlphaInverted) |
19514 | jghali | 1810 | p->setMaskMode(5); |
14297 | fschmid | 1811 | else |
19514 | jghali | 1812 | p->setMaskMode(6); |
1741 | cbradney | 1813 | } |
19514 | jghali | 1814 | else |
1815 | { |
||
1816 | p->setMaskMode(0); |
||
1817 | } |
||
7549 | fschmid | 1818 | } |
19514 | jghali | 1819 | else |
1820 | p->setMaskMode(0); |
||
1740 | cbradney | 1821 | } |
1822 | |||
2434 | fschmid | 1823 | void PageItem::DrawObj_Post(ScPainter *p) |
1740 | cbradney | 1824 | { |
1825 | bool doStroke=true; |
||
18729 | fschmid | 1826 | double lwCorr = m_lineWidth; |
22832 | craig | 1827 | if ((m_lineWidth * p->zoomFactor()) < 1) |
18729 | fschmid | 1828 | lwCorr = 0; |
22832 | craig | 1829 | if (m_Doc->layerOutline(m_layerID)) |
1740 | cbradney | 1830 | { |
16899 | fschmid | 1831 | if (itemType()!=Line) |
1740 | cbradney | 1832 | { |
22832 | craig | 1833 | p->setPen(m_Doc->layerMarker(m_layerID), 0, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
16899 | fschmid | 1834 | p->setFillMode(ScPainter::None); |
1835 | p->setBrushOpacity(1.0); |
||
1836 | p->setPenOpacity(1.0); |
||
23244 | jghali | 1837 | if (itemType() == PolyLine) |
16899 | fschmid | 1838 | p->setupPolygon(&PoLine, false); |
1839 | else if (itemType() == PathText) |
||
5582 | fschmid | 1840 | { |
16899 | fschmid | 1841 | if (PoShow) |
5582 | fschmid | 1842 | p->setupPolygon(&PoLine, false); |
16899 | fschmid | 1843 | else |
1844 | doStroke = false; |
||
1845 | } |
||
1846 | else |
||
1847 | p->setupPolygon(&PoLine); |
||
1848 | if (doStroke) |
||
1849 | p->strokePath(); |
||
23244 | jghali | 1850 | if (itemType() == ImageFrame) |
16899 | fschmid | 1851 | { |
22638 | craig | 1852 | if (!imageClip.empty()) |
7549 | fschmid | 1853 | { |
16899 | fschmid | 1854 | p->setupPolygon(&imageClip); |
7549 | fschmid | 1855 | p->strokePath(); |
5584 | fschmid | 1856 | } |
1857 | } |
||
1740 | cbradney | 1858 | } |
16899 | fschmid | 1859 | } |
1860 | else |
||
1861 | { |
||
1862 | if (!isGroup()) |
||
7549 | fschmid | 1863 | { |
14308 | fschmid | 1864 | p->setBlendModeFill(0); |
14298 | fschmid | 1865 | p->setMaskMode(0); |
23244 | jghali | 1866 | // TODO: Investigate whether itemType() == Table should really be here. I got artifacts without it so keeping it here for now. /estan |
1867 | if (itemType() == PathText || itemType() == PolyLine || itemType() == Spiral || itemType() == Line || itemType() == Symbol || itemType() == Group || itemType() == Table) |
||
7549 | fschmid | 1868 | doStroke=false; |
1869 | if ((doStroke) && (!m_Doc->RePos)) |
||
1870 | { |
||
14306 | fschmid | 1871 | p->setBlendModeStroke(lineBlendmode()); |
1872 | p->setPenOpacity(1.0 - lineTransparency()); |
||
14197 | fschmid | 1873 | if ((lineColor() != CommonStrings::None) || (!patternStrokeVal.isEmpty()) || (GrTypeStroke > 0)) |
14168 | fschmid | 1874 | { |
23046 | jghali | 1875 | p->setPen(m_strokeQColor, lwCorr, PLineArt, PLineEnd, PLineJoin); |
14168 | fschmid | 1876 | if (DashValues.count() != 0) |
1877 | p->setDash(DashValues, DashOffset); |
||
1878 | } |
||
1879 | else |
||
1880 | p->setLineWidth(0); |
||
17418 | fschmid | 1881 | if ((itemType() == LatexFrame) || (itemType() == ImageFrame) || (itemType() == OSGFrame)) |
1882 | p->setupPolygon(&PoLine); |
||
1883 | if (NamedLStyle.isEmpty()) |
||
1740 | cbradney | 1884 | { |
19513 | jghali | 1885 | ScPattern *strokePattern = m_Doc->checkedPattern(patternStrokeVal); |
1886 | if (strokePattern) |
||
13013 | fschmid | 1887 | { |
17418 | fschmid | 1888 | if (patternStrokePath) |
13013 | fschmid | 1889 | { |
17418 | fschmid | 1890 | QPainterPath guidePath = PoLine.toQPainterPath(false); |
1891 | DrawStrokePattern(p, guidePath); |
||
14168 | fschmid | 1892 | } |
17418 | fschmid | 1893 | else |
14197 | fschmid | 1894 | { |
19513 | jghali | 1895 | p->setPattern(strokePattern, patternStrokeScaleX, patternStrokeScaleY, patternStrokeOffsetX, patternStrokeOffsetY, patternStrokeRotation, patternStrokeSkewX, patternStrokeSkewY, patternStrokeMirrorX, patternStrokeMirrorY); |
17418 | fschmid | 1896 | p->setStrokeMode(ScPainter::Pattern); |
1897 | p->strokePath(); |
||
1898 | } |
||
1899 | } |
||
1900 | else if (GrTypeStroke > 0) |
||
1901 | { |
||
1902 | if ((!gradientStrokeVal.isEmpty()) && (!m_Doc->docGradients.contains(gradientStrokeVal))) |
||
23653 | craig | 1903 | gradientStrokeVal.clear(); |
17418 | fschmid | 1904 | if (!(gradientStrokeVal.isEmpty()) && (m_Doc->docGradients.contains(gradientStrokeVal))) |
1905 | stroke_gradient = m_Doc->docGradients[gradientStrokeVal]; |
||
22725 | jghali | 1906 | if (stroke_gradient.stops() < 2) // fall back to solid stroking if there are not enough colorstops in the gradient. |
17418 | fschmid | 1907 | { |
1908 | if (lineColor() != CommonStrings::None) |
||
14197 | fschmid | 1909 | { |
23046 | jghali | 1910 | p->setBrush(m_strokeQColor); |
17418 | fschmid | 1911 | p->setStrokeMode(ScPainter::Solid); |
14197 | fschmid | 1912 | } |
1913 | else |
||
1914 | { |
||
17418 | fschmid | 1915 | no_stroke = true; |
1916 | p->setStrokeMode(ScPainter::None); |
||
14197 | fschmid | 1917 | } |
1918 | } |
||
17418 | fschmid | 1919 | else |
14168 | fschmid | 1920 | { |
17418 | fschmid | 1921 | p->setStrokeMode(ScPainter::Gradient); |
1922 | p->stroke_gradient = stroke_gradient; |
||
19163 | fschmid | 1923 | p->stroke_gradient.setRepeatMethod(GrStrokeExtend); |
23904 | jghali | 1924 | if (GrTypeStroke == Gradient_Linear) |
17418 | fschmid | 1925 | p->setGradient(VGradient::linear, FPoint(GrStrokeStartX, GrStrokeStartY), FPoint(GrStrokeEndX, GrStrokeEndY), FPoint(GrStrokeStartX, GrStrokeStartY), GrStrokeScale, GrStrokeSkew); |
1926 | else |
||
1927 | p->setGradient(VGradient::radial, FPoint(GrStrokeStartX, GrStrokeStartY), FPoint(GrStrokeEndX, GrStrokeEndY), FPoint(GrStrokeFocalX, GrStrokeFocalY), GrStrokeScale, GrStrokeSkew); |
||
13013 | fschmid | 1928 | } |
17418 | fschmid | 1929 | p->strokePath(); |
13013 | fschmid | 1930 | } |
17418 | fschmid | 1931 | else if (lineColor() != CommonStrings::None) |
1932 | { |
||
1933 | p->setStrokeMode(ScPainter::Solid); |
||
23046 | jghali | 1934 | p->setPen(m_strokeQColor, lwCorr, PLineArt, PLineEnd, PLineJoin); |
17418 | fschmid | 1935 | if (DashValues.count() != 0) |
1936 | p->setDash(DashValues, DashOffset); |
||
1937 | p->strokePath(); |
||
1938 | } |
||
7549 | fschmid | 1939 | else |
17418 | fschmid | 1940 | no_stroke = true; |
18732 | fschmid | 1941 | if (lineTransparency() > 0.9) |
1942 | no_stroke = true; |
||
17418 | fschmid | 1943 | } |
1944 | else |
||
1945 | { |
||
1946 | p->setStrokeMode(ScPainter::Solid); |
||
23707 | jghali | 1947 | multiLine ml = m_Doc->docLineStyles[NamedLStyle]; |
17418 | fschmid | 1948 | QColor tmp; |
1949 | for (int it = ml.size()-1; it > -1; it--) |
||
5572 | fschmid | 1950 | { |
17418 | fschmid | 1951 | struct SingleLine& sl = ml[it]; |
1952 | // Qt4 if ((!sl.Color != CommonStrings::None) && (sl.Width != 0)) |
||
1953 | if (sl.Color != CommonStrings::None) // && (sl.Width != 0)) |
||
6568 | fschmid | 1954 | { |
17418 | fschmid | 1955 | SetQColor(&tmp, sl.Color, sl.Shade); |
1956 | p->setPen(tmp, sl.Width, static_cast<Qt::PenStyle>(sl.Dash), static_cast<Qt::PenCapStyle>(sl.LineEnd), static_cast<Qt::PenJoinStyle>(sl.LineJoin)); |
||
1957 | p->strokePath(); |
||
6568 | fschmid | 1958 | } |
5572 | fschmid | 1959 | } |
1740 | cbradney | 1960 | } |
14308 | fschmid | 1961 | p->setBlendModeStroke(0); |
7549 | fschmid | 1962 | } |
5746 | fschmid | 1963 | } |
1740 | cbradney | 1964 | } |
14208 | fschmid | 1965 | p->setFillMode(ScPainter::Solid); |
14469 | fschmid | 1966 | p->setBlendModeFill(0); |
14208 | fschmid | 1967 | p->setStrokeMode(ScPainter::Solid); |
14469 | fschmid | 1968 | p->setBlendModeStroke(0); |
14681 | fschmid | 1969 | p->restore(); |
1970 | } |
||
1971 | |||
1972 | void PageItem::DrawObj_Decoration(ScPainter *p) |
||
1973 | { |
||
1974 | p->save(); |
||
21106 | fschmid | 1975 | // p->setAntialiasing(false); |
14681 | fschmid | 1976 | if (!isEmbedded) |
18032 | craig | 1977 | p->translate(m_xPos, m_yPos); |
18022 | craig | 1978 | p->rotate(m_rotation); |
4084 | cbradney | 1979 | if ((!isEmbedded) && (!m_Doc->RePos)) |
2434 | fschmid | 1980 | { |
17790 | fschmid | 1981 | double scpInv = 0; |
16105 | fschmid | 1982 | if (!isGroup()) |
1740 | cbradney | 1983 | { |
18007 | craig | 1984 | if ((drawFrame()) && (m_Doc->guidesPrefs().framesShown) && ((itemType() == ImageFrame) || (itemType() == LatexFrame) || (itemType() == OSGFrame) || (itemType() == PathText)) && (no_stroke)) |
3919 | fschmid | 1985 | { |
23060 | craig | 1986 | p->setPen(PrefsManager::instance().appPrefs.displayPrefs.frameNormColor, scpInv, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
24730 | jghali | 1987 | if (isBookmark || m_isAnnotation) |
23060 | craig | 1988 | p->setPen(PrefsManager::instance().appPrefs.displayPrefs.frameAnnotationColor, scpInv, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
23912 | craig | 1989 | if ((m_backBox != nullptr) || (m_nextBox != nullptr)) |
23060 | craig | 1990 | p->setPen(PrefsManager::instance().appPrefs.displayPrefs.frameLinkColor, scpInv, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
7549 | fschmid | 1991 | if (m_Locked) |
23060 | craig | 1992 | p->setPen(PrefsManager::instance().appPrefs.displayPrefs.frameLockColor, scpInv, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
24527 | jghali | 1993 | p->setFillMode(ScPainter::None); |
23244 | jghali | 1994 | if (itemType() == PathText) |
3919 | fschmid | 1995 | { |
7549 | fschmid | 1996 | if (Clip.count() != 0) |
3919 | fschmid | 1997 | { |
7549 | fschmid | 1998 | FPointArray tclip; |
1999 | FPoint np = FPoint(Clip.point(0)); |
||
2000 | tclip.resize(2); |
||
2001 | tclip.setPoint(0, np); |
||
2002 | tclip.setPoint(1, np); |
||
8557 | subik | 2003 | for (int a = 1; a < Clip.size(); ++a) |
7549 | fschmid | 2004 | { |
2005 | np = FPoint(Clip.point(a)); |
||
2006 | tclip.putPoints(tclip.size(), 4, np.x(), np.y(), np.x(), np.y(), np.x(), np.y(), np.x(), np.y()); |
||
2007 | } |
||
2008 | np = FPoint(Clip.point(0)); |
||
2009 | tclip.putPoints(tclip.size(), 2, np.x(), np.y(), np.x(), np.y()); |
||
2010 | p->setupPolygon(&tclip); |
||
3919 | fschmid | 2011 | } |
2012 | } |
||
12004 | fschmid | 2013 | else |
17790 | fschmid | 2014 | p->setupSharpPolygon(&PoLine); |
7549 | fschmid | 2015 | p->strokePath(); |
3919 | fschmid | 2016 | } |
1740 | cbradney | 2017 | } |
22600 | craig | 2018 | if ((m_Doc->guidesPrefs().framesShown) && textFlowUsesContourLine() && (!ContourLine.empty())) |
8494 | fschmid | 2019 | { |
17790 | fschmid | 2020 | p->setPen(Qt::darkGray, 0, Qt::DotLine, Qt::FlatCap, Qt::MiterJoin); |
2021 | p->setupSharpPolygon(&ContourLine); |
||
8494 | fschmid | 2022 | p->strokePath(); |
2023 | } |
||
23244 | jghali | 2024 | if (itemType() == ImageFrame) |
14808 | fschmid | 2025 | { |
14971 | cbradney | 2026 | double minres = m_Doc->checkerProfiles()[m_Doc->curCheckProfile()].minResolution; |
2027 | double maxres = m_Doc->checkerProfiles()[m_Doc->curCheckProfile()].maxResolution; |
||
2028 | bool checkres = m_Doc->checkerProfiles()[m_Doc->curCheckProfile()].checkResolution; |
||
17224 | craig | 2029 | if ((((72.0 / imageXScale()) < minres) |
14808 | fschmid | 2030 | || ((72.0 / imageYScale()) < minres) |
2031 | || ((72.0 / imageXScale()) > maxres) |
||
2032 | || ((72.0 / imageYScale()) > maxres)) |
||
23060 | craig | 2033 | && (isRaster) && (checkres) && (!m_Doc->drawAsPreview) && (PrefsManager::instance().appPrefs.displayPrefs.showVerifierWarningsOnCanvas)) |
14808 | fschmid | 2034 | { |
18095 | craig | 2035 | double ofx = m_width - 22.0; |
2036 | double ofy = m_height - 22.0; |
||
18983 | fschmid | 2037 | if ((m_width > 40) && (m_height > 40)) |
2038 | { |
||
2039 | p->save(); |
||
2040 | p->translate(ofx, ofy); |
||
23054 | craig | 2041 | QImage ico = IconManager::instance().loadPixmap("22/dialog-warning.png").toImage(); |
18983 | fschmid | 2042 | p->drawImage(&ico); |
2043 | p->restore(); |
||
2044 | } |
||
14808 | fschmid | 2045 | } |
2046 | } |
||
19261 | craig | 2047 | if ((m_Doc->guidesPrefs().layerMarkersShown) && |
2048 | (m_Doc->layerCount() > 1) && |
||
22832 | craig | 2049 | (!m_Doc->layerOutline(m_layerID)) && |
19354 | craig | 2050 | (!isGroupChild()) && |
19261 | craig | 2051 | (!m_Doc->drawAsPreview)) |
1740 | cbradney | 2052 | { |
17790 | fschmid | 2053 | p->setPen(Qt::black, 0, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
5619 | fschmid | 2054 | p->setPenOpacity(1.0); |
22832 | craig | 2055 | p->setBrush(m_Doc->layerMarker(m_layerID)); |
5619 | fschmid | 2056 | p->setBrushOpacity(1.0); |
5572 | fschmid | 2057 | p->setFillMode(ScPainter::Solid); |
5584 | fschmid | 2058 | double ofwh = 10; |
18095 | craig | 2059 | double ofx = m_width - ofwh/2; |
2060 | double ofy = m_height - ofwh*3; |
||
17790 | fschmid | 2061 | p->drawSharpRect(ofx, ofy, ofwh, ofwh); |
5572 | fschmid | 2062 | } |
17394 | fschmid | 2063 | if (no_fill && no_stroke && m_Doc->guidesPrefs().framesShown) |
2064 | { |
||
23060 | craig | 2065 | p->setPen(PrefsManager::instance().appPrefs.displayPrefs.frameNormColor, scpInv, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
17394 | fschmid | 2066 | if (m_Locked) |
23060 | craig | 2067 | p->setPen(PrefsManager::instance().appPrefs.displayPrefs.frameLockColor, scpInv, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
17394 | fschmid | 2068 | p->setFillMode(ScPainter::None); |
18095 | craig | 2069 | p->drawSharpRect(0, 0, m_width, m_height); |
17394 | fschmid | 2070 | no_fill = false; |
2071 | no_stroke = false; |
||
2072 | } |
||
4145 | cbradney | 2073 | //CB disabled for now |
4847 | cbradney | 2074 | //if (m_Doc->m_Selection->findItem(this)!=-1) |
4145 | cbradney | 2075 | // drawLockedMarker(p); |
2434 | fschmid | 2076 | } |
8180 | fschmid | 2077 | FrameOnly = false; |
21106 | fschmid | 2078 | // p->setAntialiasing(true); |
2434 | fschmid | 2079 | p->restore(); |
1740 | cbradney | 2080 | } |
2081 | |||
11052 | avox | 2082 | void PageItem::DrawObj_Embedded(ScPainter *p, QRectF cullingArea, const CharStyle& style, PageItem* cembedded) |
2434 | fschmid | 2083 | { |
8174 | avox | 2084 | if (!cembedded) |
2085 | return; |
||
9856 | fschmid | 2086 | QList<PageItem*> emG; |
2955 | fschmid | 2087 | emG.clear(); |
8174 | avox | 2088 | emG.append(cembedded); |
9856 | fschmid | 2089 | for (int em = 0; em < emG.count(); ++em) |
8174 | avox | 2090 | { |
2091 | PageItem* embedded = emG.at(em); |
||
12299 | fschmid | 2092 | p->save(); |
2093 | double x = embedded->xPos(); |
||
2094 | double y = embedded- |