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.
7
/***************************************************************************
8
pageitem.cpp - description
10
begin : Sat Apr 7 2001
11
copyright : (C) 2001 by Franz Schmid
12
email : Franz.Schmid@altmuehlnet.de
13
***************************************************************************/
15
/***************************************************************************
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. *
22
***************************************************************************/
31
#include <qdrawutil.h>
33
#include <QMessageBox>
42
#include "cmsettings.h"
43
#include "colorblind.h"
44
#include "commonstrings.h"
46
#include "guidemanager.h"
48
#include "pageitem_latexframe.h"
49
#include "pageitem_textframe.h"
50
#include "prefsmanager.h"
51
#include "propertiespalette.h"
52
#include "resourcecollection.h"
53
#include "scclocale.h"
54
#include "sccolorengine.h"
56
#include "scpainter.h"
58
#include "scpattern.h"
60
#include "scribusapp.h"
61
#include "scribuscore.h"
62
#include "scribusdoc.h"
63
#include "scribusstructs.h"
64
#include "scribuswin.h"
65
#include "sctextstream.h"
66
#include "serializer.h"
67
#include "selection.h"
69
#include "text/nlsconfig.h"
70
#include "desaxe/saxXML.h"
71
#include "undomanager.h"
72
#include "undostate.h"
74
#include "util_formats.h"
75
#include "util_math.h"
76
#include "util_text.h"
77
#include "util_file.h"
84
PageItem::PageItem(const PageItem & other)
85
: QObject(other.parent()),
86
UndoObject(other), SingleObservable<PageItem>(other.m_Doc->itemsChanged()),
88
// 200 attributes! That is madness, or to quote some famous people from Kriquet:
89
// "THAT ALL HAS TO GO!"
93
gHeight(other.gHeight),
95
GrStartX(other.GrStartX),
96
GrStartY(other.GrStartY),
100
ColGap(other.ColGap),
101
PLineArt(other.PLineArt),
102
PLineEnd(other.PLineEnd),
103
PLineJoin(other.PLineJoin),
104
NamedLStyle(other.NamedLStyle),
106
PoLine(other.PoLine),
107
ContourLine(other.ContourLine),
108
imageClip(other.imageClip),
109
Segments(other.Segments),
110
effectsInUse(other.effectsInUse),
111
PoShow(other.PoShow),
112
BaseOffs(other.BaseOffs),
113
textPathType(other.textPathType),
114
textPathFlipped(other.textPathFlipped),
115
ClipEdited(other.ClipEdited),
116
FrameType(other.FrameType),
117
ItemNr(other.ItemNr),
119
OwnPage(other.OwnPage),
120
oldOwnPage(other.oldOwnPage),
123
Pfile2(other.Pfile2),
124
Pfile3(other.Pfile3),
125
IProfile(other.IProfile),
126
UseEmbedded(other.UseEmbedded),
127
EmProfile(other.EmProfile),
128
IRender(other.IRender),
130
PictureIsAvailable(other.PictureIsAvailable),
138
itemText(other.itemText),
139
isBookmark(other.isBookmark),
140
HasSel(other.HasSel),
141
// Tinput(other.Tinput),
142
isAutoText(other.isAutoText),
143
BackBox(NULL), // otherwise other.BackBox->NextBox would be inconsistent
144
NextBox(NULL), // otherwise other.NextBox->BackBox would be inconsistent
145
firstChar(0), // since this box is unlinked now
146
MaxChars(0), // since the layout is invalid now
147
inPdfArticle(other.inPdfArticle),
148
isRaster(other.isRaster),
153
Sizing(other.Sizing),
154
toPixmap(other.toPixmap),
155
LayerNr(other.LayerNr),
156
ScaleType(other.ScaleType),
157
AspectRatio(other.AspectRatio),
158
Groups(other.Groups),
159
DashValues(other.DashValues),
160
DashOffset(other.DashOffset),
161
fill_gradient(other.fill_gradient),
162
fillRule(other.fillRule),
163
doOverprint(other.doOverprint),
164
LeftLink(other.LeftLink),
165
RightLink(other.RightLink),
166
TopLink(other.TopLink),
167
BottomLink(other.BottomLink),
168
LeftLinkID(other.LeftLinkID),
169
RightLinkID(other.RightLinkID),
170
TopLinkID(other.TopLinkID),
171
BottomLinkID(other.BottomLinkID),
172
LeftLine(other.LeftLine),
173
RightLine(other.RightLine),
174
TopLine(other.TopLine),
175
BottomLine(other.BottomLine),
176
isTableItem(other.isTableItem),
177
isSingleSel(other.isSingleSel),
178
isGroupControl(other.isGroupControl),
179
groupsLastItem(other.groupsLastItem),
180
BoundingX(other.BoundingX),
181
BoundingY(other.BoundingY),
182
BoundingW(other.BoundingW),
183
BoundingH(other.BoundingH),
184
ChangedMasterItem(other.ChangedMasterItem),
185
OnMasterPage(other.OnMasterPage),
186
isEmbedded(other.isEmbedded),
189
undoManager(other.undoManager),
190
m_ItemType(other.m_ItemType),
191
AnName(other.AnName),
192
patternVal(other.patternVal),
193
patternScaleX(other.patternScaleX),
194
patternScaleY(other.patternScaleY),
195
patternOffsetX(other.patternOffsetX),
196
patternOffsetY(other.patternOffsetY),
197
patternRotation(other.patternRotation),
198
fillColorVal(other.fillColorVal),
199
lineColorVal(other.lineColorVal),
200
lineShadeVal(other.lineShadeVal),
201
fillShadeVal(other.fillShadeVal),
202
fillTransparencyVal(other.fillTransparencyVal),
203
lineTransparencyVal(other.lineTransparencyVal),
204
fillBlendmodeVal(other.fillBlendmodeVal),
205
lineBlendmodeVal(other.lineBlendmodeVal),
206
m_ImageIsFlippedH(other.m_ImageIsFlippedH),
207
m_ImageIsFlippedV(other.m_ImageIsFlippedV),
208
m_Locked(other.m_Locked),
209
m_SizeLocked(other.m_SizeLocked),
210
textFlowModeVal(other.textFlowModeVal),
211
pageItemAttributes(other.pageItemAttributes),
212
m_PrintEnabled(other.m_PrintEnabled),
213
tagged(other.tagged),
214
fillQColor(other.fillQColor),
215
strokeQColor(other.strokeQColor),
219
Height(other.Height),
221
Select(other.Select),
222
LocalScX(other.LocalScX),
223
LocalScY(other.LocalScY),
224
LocalX(other.LocalX),
225
LocalY(other.LocalY),
226
Reverse(other.Reverse),
227
m_startArrowIndex(other.m_startArrowIndex),
228
m_endArrowIndex(other.m_endArrowIndex),
230
TExtra(other.TExtra),
231
BExtra(other.BExtra),
232
RExtra(other.RExtra),
233
firstLineOffsetP(other.firstLineOffsetP),
234
RadRect(other.RadRect),
235
oldXpos(other.oldXpos),
236
oldYpos(other.oldYpos),
237
oldWidth(other.oldWidth),
238
oldHeight(other.oldHeight),
239
oldRot(other.oldRot),
240
oldLocalScX(other.oldLocalScX),
241
oldLocalScY(other.oldLocalScY),
242
oldLocalX(other.oldLocalX),
243
oldLocalY(other.oldLocalY),
245
m_isAnnotation(other.m_isAnnotation),
246
m_annotation(other.m_annotation),
247
PicArt(other.PicArt),
248
m_lineWidth(other.m_lineWidth),
249
Oldm_lineWidth(other.Oldm_lineWidth)
253
AnName += tmp.setNum(m_Doc->TotalItems);
254
uniqueNr = m_Doc->TotalItems;
256
if (other.isInlineImage)
258
QFileInfo inlFi(Pfile);
259
QString ext = inlFi.suffix();
260
tempImageFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_XXXXXX." + ext);
261
tempImageFile->open();
262
QString fileName = getLongPathName(tempImageFile->fileName());
263
tempImageFile->close();
264
copyFile(Pfile, fileName);
266
isInlineImage = true;
270
tempImageFile = NULL;
271
isInlineImage = false;
276
PageItem::PageItem(ScribusDoc *pa, ItemType newType, double x, double y, double w, double h, double w2, QString fill, QString outline)
277
// Initialize superclass(es)
278
: QObject(pa), SingleObservable<PageItem>(pa->itemsChanged()),
279
// Initialize member variables
281
undoManager(UndoManager::instance()),
284
fillTransparencyVal(0.0),
285
lineTransparencyVal(0.0),
288
m_ImageIsFlippedH(0),
289
m_ImageIsFlippedV(0),
292
textFlowModeVal(TextFlowDisabled)
300
//CB Surely we can remove some of these?
301
OldB2 = OldB = oldWidth = Width = w;
302
OldH2 = OldH = oldHeight = Height = h;
307
m_ItemType = newType;
310
lineColorVal = m_ItemType == PageItem::TextFrame ? fill : outline;
312
gWidth = gHeight = 0;
326
PLineArt = Qt::PenStyle(m_Doc->toolSettings.dLineArt);
327
PLineEnd = Qt::FlatCap;
328
PLineJoin = Qt::MiterJoin;
344
pixm.imgInfo.lowResType = m_Doc->toolSettings.lowResType;
347
oldLocalScX = LocalScX = 1;
348
oldLocalScY = LocalScY = 1;
351
oldLocalX = LocalX = 0;
352
oldLocalY = LocalY = 0;
356
if ((m_ItemType == TextFrame) || (m_ItemType == ImageFrame) || (m_ItemType == PathText))
357
// TODO: Frame should become a read-only calculated property
364
Clip.setPoints(4, static_cast<int>(w/2), 0, static_cast<int>(w), static_cast<int>(h/2),
365
static_cast<int>(w/2), static_cast<int>(h), 0,static_cast<int>(h/2));
368
Clip.setPoints(4, 0,0, static_cast<int>(w),0, static_cast<int>(w), static_cast<int>(h), 0,static_cast<int>(h));
372
ContourLine.resize(0);
378
textPathFlipped = false;
379
OwnPage = m_Doc->currentPage()->pageNr();
380
oldOwnPage = OwnPage;
381
savedOwnPage = OwnPage;
383
PictureIsAvailable = false;
384
m_PrintEnabled = true;
386
m_isAnnotation = false;
392
//We can't determine if this is a latex frame here
393
// because c++'s typeinfos are still saying it's
395
// This is fixed in the PageItem_LatexFrame constructor
396
AnName = tr("Image");
397
setUPixmap(Um::IImageFrame);
401
setUPixmap(Um::ITextFrame);
405
setUPixmap(Um::ILine);
408
AnName = tr("Polygon");
409
setUPixmap(Um::IPolygon);
412
AnName = tr("Polyline");
413
setUPixmap(Um::IPolyline);
416
AnName = tr("PathText");
417
setUPixmap(Um::IPathText);
424
AnName += tmp.setNum(m_Doc->TotalItems); // +" "+QDateTime::currentDateTime().toString();
425
uniqueNr = m_Doc->TotalItems;
428
m_annotation.setBorderColor(outline);
432
inPdfArticle = false;
437
IRender = Intent_Relative_Colorimetric;
440
LayerNr = m_Doc->activeLayer();
449
fill_gradient = VGradient(VGradient::linear);
450
fill_gradient.clearStops();
451
if (fillColorVal != CommonStrings::None)
453
const ScColor& col = m_Doc->PageColors[fillColorVal];
454
QColor qcol = ScColorEngine::getRGBColor(col, m_Doc);
455
fill_gradient.addStop(qcol, 0.0, 0.5, 1.0, fillColorVal, 100);
456
fill_gradient.addStop(qcol, 1.0, 0.5, 1.0, fillColorVal, 100);
460
if (m_Doc->toolSettings.dBrush != CommonStrings::None)
462
const ScColor& col = m_Doc->PageColors[m_Doc->toolSettings.dBrush];
463
QColor qcol = ScColorEngine::getRGBColor(col, m_Doc);
464
fill_gradient.addStop(qcol, 0.0, 0.5, 1.0, m_Doc->toolSettings.dBrush, 100);
465
fill_gradient.addStop(qcol, 1.0, 0.5, 1.0, m_Doc->toolSettings.dBrush, 100);
469
if (lineColorVal != CommonStrings::None)
471
const ScColor& col = m_Doc->PageColors[lineColorVal];
472
QColor qcol = ScColorEngine::getRGBColor(col, m_Doc);
473
fill_gradient.addStop(qcol, 0.0, 0.5, 1.0, lineColorVal, 100);
474
fill_gradient.addStop(qcol, 1.0, 0.5, 1.0, lineColorVal, 100);
478
if (m_Doc->toolSettings.dPen != CommonStrings::None)
480
const ScColor& col = m_Doc->PageColors[m_Doc->toolSettings.dPen];
481
QColor qcol = ScColorEngine::getRGBColor(col, m_Doc);
482
fill_gradient.addStop(qcol, 0.0, 0.5, 1.0, m_Doc->toolSettings.dPen, 100);
483
fill_gradient.addStop(qcol, 1.0, 0.5, 1.0, m_Doc->toolSettings.dPen, 100);
485
else if (m_Doc->PageColors.contains("Black"))
487
const ScColor& col = m_Doc->PageColors["Black"];
488
QColor qcol = ScColorEngine::getRGBColor(col, m_Doc);
489
fill_gradient.addStop(qcol, 0.0, 0.5, 1.0, "Black", 100);
490
fill_gradient.addStop(qcol, 1.0, 0.5, 1.0, "Black", 100);
495
firstLineOffsetP = FLOPRealGlyphHeight;
496
Cols = m_Doc->toolSettings.dCols;
497
ColGap = m_Doc->toolSettings.dGap;
514
isGroupControl = false;
516
ChangedMasterItem = false;
518
OnMasterPage = m_Doc->currentPage()->pageName();
519
m_startArrowIndex = m_Doc->toolSettings.dStartArrow;
520
m_endArrowIndex = m_Doc->toolSettings.dEndArrow;
521
effectsInUse.clear();
522
//Page Item Attributes
523
pageItemAttributes.clear();
524
for(ObjAttrVector::Iterator objAttrIt = m_Doc->docItemAttributes.begin() ; objAttrIt != m_Doc->docItemAttributes.end(); ++objAttrIt )
526
if (((*objAttrIt).autoaddto=="textframes" && m_ItemType==TextFrame) ||
527
((*objAttrIt).autoaddto=="imageframes" && m_ItemType==ImageFrame)
529
pageItemAttributes.append(*objAttrIt);
531
tempImageFile = NULL;
532
isInlineImage = false;
535
void PageItem::setXPos(const double newXPos, bool drawingOnly)
538
if (drawingOnly || m_Doc->isLoading())
541
emit position(Xpos, Ypos);
544
void PageItem::setYPos(const double newYPos, bool drawingOnly)
547
if (drawingOnly || m_Doc->isLoading())
550
emit position(Xpos, Ypos);
553
void PageItem::setXYPos(const double newXPos, const double newYPos, bool drawingOnly)
557
if (drawingOnly || m_Doc->isLoading())
560
emit position(Xpos, Ypos);
563
void PageItem::moveBy(const double dX, const double dY, bool drawingOnly)
565
if (dX==0.0 && dY==0.0)
572
if (drawingOnly || m_Doc->isLoading())
575
emit position(Xpos, Ypos);
578
void PageItem::setWidth(const double newWidth)
583
emit widthAndHeight(Width, Height);
586
void PageItem::setHeight(const double newHeight)
591
emit widthAndHeight(Width, Height);
594
void PageItem::setWidthHeight(const double newWidth, const double newHeight, bool drawingOnly)
602
emit widthAndHeight(Width, Height);
605
void PageItem::setWidthHeight(const double newWidth, const double newHeight)
611
emit widthAndHeight(Width, Height);
614
void PageItem::resizeBy(const double dH, const double dW)
616
if (dH==0.0 && dW==0.0)
624
emit widthAndHeight(Width, Height);
627
void PageItem::setRotation(const double newRotation, bool drawingOnly)
631
if (drawingOnly || m_Doc->isLoading())
636
void PageItem::rotateBy(const double dR)
645
void PageItem::setSelected(const bool toSelect)
650
void PageItem::setImageXScale(const double newImageXScale)
652
LocalScX=newImageXScale;
654
emit imageOffsetScale(LocalScX, LocalScY, LocalX, LocalY);
657
void PageItem::setImageYScale(const double newImageYScale)
659
LocalScY=newImageYScale;
661
emit imageOffsetScale(LocalScX, LocalScY, LocalX, LocalY);
664
void PageItem::setImageXYScale(const double newImageXScale, const double newImageYScale)
666
LocalScX=newImageXScale;
667
LocalScY=newImageYScale;
669
emit imageOffsetScale(LocalScX, LocalScY, LocalX, LocalY);
672
void PageItem::setImageXOffset(const double newImageXOffset)
674
LocalX=newImageXOffset;
676
emit imageOffsetScale(LocalScX, LocalScY, LocalX, LocalY);
679
void PageItem::setImageYOffset(const double newImageYOffset)
681
LocalY=newImageYOffset;
683
emit imageOffsetScale(LocalScX, LocalScY, LocalX, LocalY);
686
void PageItem::setImageXYOffset(const double newImageXOffset, const double newImageYOffset)
688
LocalX=newImageXOffset;
689
LocalY=newImageYOffset;
691
emit imageOffsetScale(LocalScX, LocalScY, LocalX, LocalY);
694
void PageItem::moveImageXYOffsetBy(const double dX, const double dY)
696
if (dX==0.0 && dY==0.0)
703
emit imageOffsetScale(LocalScX, LocalScY, LocalX, LocalY);
706
void PageItem::setReversed(bool newReversed)
712
/// returns true if text overflows
713
bool PageItem::frameOverflows() const
716
// Fix #6991 : "Text overflow" warning when there is a text underflow in fact
717
/*return NextBox == NULL && itemText.length() > static_cast<int>(MaxChars);*/
718
return ( NextBox == NULL )
719
&& ( static_cast<int> ( firstChar ) < itemText.length() )
720
// Fix #7766 : scribus.textOverflows() returns 0 if there is no place for the overflow mark
721
/*&& ( firstChar < MaxChars )*/
722
&& ( firstChar <= MaxChars )
723
&& ( itemText.length() > static_cast<int> ( MaxChars ) );
725
return false; // FIXME:NLS
729
int PageItem::firstInFrame() const
733
int PageItem::lastInFrame() const
736
return qMin(signed(MaxChars), itemText.length()) - 1;
738
return itemText.length() - 1;
743
void PageItem::link(PageItem* nxt)
745
assert( !nextInChain() );
746
assert( !nxt->prevInChain() );
747
for (PageItem* ff=nxt; ff; ff=ff->nextInChain())
751
// Append only if necessary to avoid the
752
// charstyle: access at end of text warning
753
if (nxt->itemText.length() > 0)
754
itemText.append(nxt->itemText);
760
PageItem* after = nxt;
763
after->isAutoText = true;
764
m_Doc->LastAuto = after;
765
after = after->NextBox;
768
else if (nxt->isAutoText)
770
PageItem* before = this;
773
before->isAutoText = true;
774
m_Doc->FirstAuto = before;
775
before = before->BackBox;
781
nxt->itemText = itemText;
786
if (UndoManager::undoEnabled())
788
ItemState<std::pair<PageItem*, PageItem*> > *is = new ItemState<std::pair<PageItem*, PageItem*> >(UndoManager::LinkTextFrame);
789
is->set("LINK_TEXT_FRAME", "linkTextFrame");
790
is->setItem(std::pair<PageItem*, PageItem*>(this, NextBox));
791
undoManager->action(this, is);
795
void PageItem::unlink()
799
PageItem *undoNextBox=NextBox;
800
// make sure lastInFrame is valid
803
//<< CB #6332: Stop the StoryText cut and break and act like other publishing apps
804
// move following text to new StoryText
805
itemText.select(lastInFrame()+1, itemText.length()-lastInFrame()-1);
807
StoryText follow(m_Doc);
809
follow.setDefaultStyle(itemText.defaultStyle());
810
follow.insert(0, itemText, true);
811
// remove following text from this chain
812
itemText.removeSelection();
815
// update auto pointers
818
PageItem* before = this;
821
before->isAutoText = false;
822
before = before->BackBox;
824
m_Doc->FirstAuto = NextBox;
826
// link following frames to new text
827
NextBox->firstChar = 0;
828
NextBox->BackBox = NULL;
830
NextBox->itemText = follow;
831
NextBox->invalid = true;
832
NextBox->firstChar = 0;
833
NextBox = NextBox->NextBox;
835
// NextBox == NULL now
837
if (UndoManager::undoEnabled())
839
ItemState<std::pair<PageItem*, PageItem*> > *is = new ItemState<std::pair<PageItem*, PageItem*> >(UndoManager::UnlinkTextFrame);
840
is->set("UNLINK_TEXT_FRAME", "unlinkTextFrame");
841
is->setItem(std::pair<PageItem*, PageItem*>(this, undoNextBox));
842
undoManager->action(this, is);
848
void PageItem::dropLinks()
850
// update auto pointers
851
if (isAutoText && NextBox == 0)
853
m_Doc->LastAuto = BackBox;
855
if (isAutoText && BackBox == 0)
857
m_Doc->FirstAuto = NextBox;
861
// leave text in remaining chain
862
PageItem* before = BackBox;
863
PageItem* after = NextBox;
864
if (after != 0 || before != 0)
866
itemText = StoryText(m_Doc);
868
before->NextBox = after;
871
after->BackBox = before;
874
after->invalid = true;
875
after->firstChar = 0;
876
after = after->NextBox;
879
// JG we should set BackBox and NextBox to NULL at a point
880
BackBox = NextBox = NULL;
884
/// tests if a character is displayed by this frame
885
bool PageItem::frameDisplays(int textpos) const
888
return 0 <= textpos && textpos < signed(MaxChars) && textpos < itemText.length();
890
return true; // FIXME:NLS
895
/// returns the style at the current charpos
896
const ParagraphStyle& PageItem::currentStyle() const
898
if (frameDisplays(CPos))
899
return itemText.paragraphStyle(CPos);
901
return itemText.defaultStyle();
904
/// returns the style at the current charpos for changing
905
ParagraphStyle& PageItem::changeCurrentStyle()
907
if (frameDisplays(CPos))
908
return const_cast<ParagraphStyle&>(itemText.paragraphStyle(CPos));
910
return const_cast<ParagraphStyle&>(itemText.defaultStyle());
913
/// returns the style at the current charpos
914
const CharStyle& PageItem::currentCharStyle() const
916
if (frameDisplays(CPos))
917
return itemText.charStyle(CPos);
919
return itemText.defaultStyle().charStyle();
922
void PageItem::setTextToFrameDistLeft(double newLeft)
925
emit textToFrameDistances(Extra, TExtra, BExtra, RExtra);
928
void PageItem::setTextToFrameDistRight(double newRight)
931
emit textToFrameDistances(Extra, TExtra, BExtra, RExtra);
934
void PageItem::setTextToFrameDistTop(double newTop)
937
emit textToFrameDistances(Extra, TExtra, BExtra, RExtra);
940
void PageItem::setTextToFrameDistBottom(double newBottom)
943
emit textToFrameDistances(Extra, TExtra, BExtra, RExtra);
946
void PageItem::setTextToFrameDist(double newLeft, double newRight, double newTop, double newBottom)
952
emit textToFrameDistances(Extra, TExtra, BExtra, RExtra);
955
double PageItem::gridOffset() const { return m_Doc->typographicSettings.offsetBaseGrid; }
956
double PageItem::gridDistance() const { return m_Doc->typographicSettings.valueBaseGrid; }
958
void PageItem::setGridOffset(double) { } // FIXME
959
void PageItem::setGridDistance(double) { } // FIXME
960
void PageItem::setColumns(int n)
962
Cols = qMax(1, n); //FIXME: undo
964
void PageItem::setColumnGap(double gap)
966
ColGap = gap; //FIXME: undo
969
void PageItem::setCornerRadius(double newRadius)
972
emit cornerRadius(RadRect);
984
CHANGE: cullingArea is in doc coordinates!
986
void PageItem::DrawObj(ScPainter *p, QRectF cullingArea)
988
// qDebug << "PageItem::DrawObj";
990
if (!m_Doc->DoDrawing)
995
if (cullingArea.isNull())
997
cullingArea = QRectF(QPointF(m_Doc->minCanvasCoordinate.x(), m_Doc->minCanvasCoordinate.y()),
998
QPointF(m_Doc->maxCanvasCoordinate.x(), m_Doc->maxCanvasCoordinate.y())).toAlignedRect();
1002
if (m_Doc->layerOutline(LayerNr))
1004
if ((itemType()==TextFrame || itemType()==ImageFrame || itemType()==PathText || itemType()==Line || itemType()==PolyLine) && (!isGroupControl))
1005
DrawObj_Item(p, cullingArea, sc);
1009
if (!isGroupControl)
1010
DrawObj_Item(p, cullingArea, sc);
1015
void PageItem::DrawObj_Pre(ScPainter *p, double &sc)
1017
ScribusView* view = m_Doc->view();
1021
p->translate(Xpos, Ypos);
1023
if (m_Doc->layerOutline(LayerNr))
1025
p->setPen(m_Doc->layerMarker(LayerNr), 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
1026
p->setFillMode(ScPainter::None);
1027
p->setBrushOpacity(1.0);
1028
p->setPenOpacity(1.0);
1032
if (!isGroupControl)
1034
if (fillBlendmode() != 0)
1035
p->beginLayer(1.0 - fillTransparency(), fillBlendmode());
1037
p->setLineWidth(m_lineWidth);
1042
if ((patternVal.isEmpty()) || (!m_Doc->docPatterns.contains(patternVal)))
1044
p->fill_gradient = VGradient(VGradient::linear);
1045
if (fillColor() != CommonStrings::None)
1047
p->setBrush(fillQColor);
1048
p->setFillMode(ScPainter::Solid);
1051
p->setFillMode(ScPainter::None);
1052
if ((!patternVal.isEmpty()) && (!m_Doc->docPatterns.contains(patternVal)))
1060
p->setPattern(&m_Doc->docPatterns[patternVal], patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation);
1061
p->setFillMode(ScPainter::Pattern);
1066
if (fill_gradient.Stops() < 2) // fall back to solid filling if there are not enough colorstops in the gradient.
1068
if (fillColor() != CommonStrings::None)
1070
p->setBrush(fillQColor);
1071
p->setFillMode(ScPainter::Solid);
1074
p->setFillMode(ScPainter::None);
1078
p->setFillMode(ScPainter::Gradient);
1079
p->fill_gradient = fill_gradient;
1090
p->setGradient(VGradient::linear, FPoint(GrStartX, GrStartY), FPoint(GrEndX, GrEndY));
1094
gra.setPoints(2, GrStartX, GrStartY, GrEndX, GrEndY);
1095
p->setGradient(VGradient::radial, gra.point(0), gra.point(1), gra.point(0));
1103
p->fill_gradient = VGradient(VGradient::linear);
1104
if (fillColor() != CommonStrings::None)
1106
p->setBrush(fillQColor);
1107
p->setFillMode(ScPainter::Solid);
1110
p->setFillMode(ScPainter::None);
1112
if (lineColor() != CommonStrings::None)
1114
// if ((m_lineWidth == 0) && ! asLine())
1115
// p->setLineWidth(0);
1118
p->setPen(strokeQColor, m_lineWidth, PLineArt, PLineEnd, PLineJoin);
1119
if (DashValues.count() != 0)
1120
p->setDash(DashValues, DashOffset);
1125
if (fillBlendmode() == 0)
1126
p->setBrushOpacity(1.0 - fillTransparency());
1127
if (lineBlendmode() == 0)
1128
p->setPenOpacity(1.0 - lineTransparency());
1129
p->setFillRule(fillRule);
1134
void PageItem::DrawObj_Post(ScPainter *p)
1137
ScribusView* view = m_Doc->view();
1138
if (!isGroupControl)
1140
if (m_Doc->layerOutline(LayerNr))
1142
if (itemType()!=Line)
1144
p->setPen(m_Doc->layerMarker(LayerNr), 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
1145
p->setFillMode(ScPainter::None);
1146
p->setBrushOpacity(1.0);
1147
p->setPenOpacity(1.0);
1148
if (itemType()==PolyLine)
1149
p->setupPolygon(&PoLine, false);
1150
else if (itemType() == PathText)
1153
p->setupPolygon(&PoLine, false);
1158
p->setupPolygon(&PoLine);
1161
if (itemType()==ImageFrame)
1163
if (imageClip.size() != 0)
1165
p->setupPolygon(&imageClip);
1173
if (fillBlendmode() != 0)
1175
if (itemType()==PathText || itemType()==PolyLine || itemType()==Line)
1177
if ((doStroke) && (!m_Doc->RePos))
1179
if (lineBlendmode() != 0)
1180
p->beginLayer(1.0 - lineTransparency(), lineBlendmode());
1181
// if (lineColor() != CommonStrings::None)
1183
// p->setPen(strokeQColor, m_lineWidth, PLineArt, PLineEnd, PLineJoin);
1184
// if (DashValues.count() != 0)
1185
// p->setDash(DashValues, DashOffset);
1188
// p->setLineWidth(0);
1191
if ((itemType() == LatexFrame) || (itemType() == ImageFrame))
1192
p->setupPolygon(&PoLine);
1193
if (NamedLStyle.isEmpty())
1195
if (lineColor() != CommonStrings::None)
1197
p->setPen(strokeQColor, m_lineWidth, PLineArt, PLineEnd, PLineJoin);
1198
if (DashValues.count() != 0)
1199
p->setDash(DashValues, DashOffset);
1205
multiLine ml = m_Doc->MLineStyles[NamedLStyle];
1207
for (int it = ml.size()-1; it > -1; it--)
1209
struct SingleLine& sl = ml[it];
1210
// Qt4 if ((!sl.Color != CommonStrings::None) && (sl.Width != 0))
1211
if (sl.Color != CommonStrings::None) // && (sl.Width != 0))
1213
SetQColor(&tmp, sl.Color, sl.Shade);
1214
p->setPen(tmp, sl.Width, static_cast<Qt::PenStyle>(sl.Dash), static_cast<Qt::PenCapStyle>(sl.LineEnd), static_cast<Qt::PenJoinStyle>(sl.LineJoin));
1220
if (lineBlendmode() != 0)
1225
if ((!isEmbedded) && (!m_Doc->RePos))
1227
double aestheticFactor(5.0);
1228
double scpInv = 1.0 / (qMax(view->scale(), 1.0) * aestheticFactor);
1229
if (!isGroupControl)
1231
if ((Frame) && (m_Doc->guidesSettings.framesShown) && ((itemType() == ImageFrame) || (itemType() == LatexFrame) || (itemType() == PathText)))
1233
p->setPen(PrefsManager::instance()->appPrefs.DFrameNormColor, scpInv, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
1234
if ((isBookmark) || (m_isAnnotation))
1235
p->setPen(PrefsManager::instance()->appPrefs.DFrameAnnotationColor, scpInv, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
1236
if ((BackBox != 0) || (NextBox != 0))
1237
p->setPen(PrefsManager::instance()->appPrefs.DFrameLinkColor, scpInv, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
1239
p->setPen(PrefsManager::instance()->appPrefs.DFrameLockColor, scpInv, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
1241
if (itemType()==PathText)
1243
if (Clip.count() != 0)
1246
FPoint np = FPoint(Clip.point(0));
1248
tclip.setPoint(0, np);
1249
tclip.setPoint(1, np);
1250
for (int a = 1; a < Clip.size(); ++a)
1252
np = FPoint(Clip.point(a));
1253
tclip.putPoints(tclip.size(), 4, np.x(), np.y(), np.x(), np.y(), np.x(), np.y(), np.x(), np.y());
1255
np = FPoint(Clip.point(0));
1256
tclip.putPoints(tclip.size(), 2, np.x(), np.y(), np.x(), np.y());
1257
p->setupPolygon(&tclip);
1261
// Ugly Hack to fix rendering problems with cairo >=1.5.10 && <1.8.0 follows
1263
#if ((CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 5, 10)) && (CAIRO_VERSION < CAIRO_VERSION_ENCODE(1, 8, 0)))
1264
p->setupPolygon(&PoLine, false);
1266
p->setupPolygon(&PoLine);
1269
p->setupPolygon(&PoLine);
1274
if ((m_Doc->guidesSettings.framesShown) && textFlowUsesContourLine() && (ContourLine.size() != 0))
1276
p->setPen(Qt::darkGray, 1.0 / qMax(view->scale(), 1.0), Qt::DotLine, Qt::FlatCap, Qt::MiterJoin);
1277
// Ugly Hack to fix rendering problems with cairo >=1.5.10 && <1.8.0 follows
1279
#if ((CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 5, 10)) && (CAIRO_VERSION < CAIRO_VERSION_ENCODE(1, 8, 0)))
1280
p->setupPolygon(&ContourLine, false);
1282
p->setupPolygon(&ContourLine);
1285
p->setupPolygon(&ContourLine);
1289
if ((m_Doc->guidesSettings.layerMarkersShown) && (m_Doc->layerCount() > 1) && (!m_Doc->layerOutline(LayerNr)) && ((isGroupControl) || (Groups.count() == 0)) && (!view->m_canvas->isPreviewMode()))
1291
p->setPen(Qt::black, 0.5/ m_Doc->view()->scale(), Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
1292
p->setPenOpacity(1.0);
1293
p->setBrush(m_Doc->layerMarker(LayerNr));
1294
p->setBrushOpacity(1.0);
1295
p->setFillMode(ScPainter::Solid);
1297
double ofx = Width - ofwh/2;
1298
double ofy = Height - ofwh*3;
1299
p->drawRect(ofx, ofy, ofwh, ofwh);
1301
//CB disabled for now
1302
//if (m_Doc->m_Selection->findItem(this)!=-1)
1303
// drawLockedMarker(p);
1310
void PageItem::DrawObj_Embedded(ScPainter *p, QRectF cullingArea, const CharStyle& style, PageItem* cembedded)
1314
if (!m_Doc->DoDrawing)
1316
QList<PageItem*> emG;
1317
QStack<PageItem*> groupStack;
1320
emG.append(cembedded);
1321
if (cembedded->Groups.count() != 0)
1323
for (int ga=0; ga<m_Doc->FrameItems.count(); ++ga)
1325
if (m_Doc->FrameItems.at(ga)->Groups.count() != 0)
1327
if (m_Doc->FrameItems.at(ga)->Groups.top() == cembedded->Groups.top())
1329
if (m_Doc->FrameItems.at(ga)->ItemNr != cembedded->ItemNr)
1331
if (!emG.contains(m_Doc->FrameItems.at(ga)))
1332
emG.append(m_Doc->FrameItems.at(ga));
1338
for (int em = 0; em < emG.count(); ++em)
1340
PageItem* embedded = emG.at(em);
1341
if (embedded->isGroupControl)
1344
FPointArray cl = embedded->PoLine.copy();
1346
mm.translate((embedded->gXpos * (style.scaleH() / 1000.0)), ( - (embedded->gHeight * (style.scaleV() / 1000.0)) + embedded->gYpos * (style.scaleV() / 1000.0)));
1347
if (style.baselineOffset() != 0)
1348
mm.translate(0, -embedded->gHeight * (style.baselineOffset() / 1000.0));
1349
mm.scale(style.scaleH() / 1000.0, style.scaleV() / 1000.0);
1350
mm.rotate(embedded->rotation());
1352
p->beginLayer(1.0 - embedded->fillTransparency(), embedded->fillBlendmode(), &cl);
1353
groupStack.push(embedded->groupsLastItem);
1357
double x = embedded->xPos();
1358
double y = embedded->yPos();
1359
embedded->Xpos = embedded->gXpos;
1360
embedded->Ypos = (embedded->gHeight * (style.scaleV() / 1000.0)) + embedded->gYpos;
1361
p->translate((embedded->gXpos * (style.scaleH() / 1000.0)), ( - (embedded->gHeight * (style.scaleV() / 1000.0)) + embedded->gYpos * (style.scaleV() / 1000.0)));
1362
if (style.baselineOffset() != 0)
1364
p->translate(0, -embedded->gHeight * (style.baselineOffset() / 1000.0));
1365
embedded->Ypos -= embedded->gHeight * (style.baselineOffset() / 1000.0);
1367
p->scale(style.scaleH() / 1000.0, style.scaleV() / 1000.0);
1368
embedded->Dirty = Dirty;
1369
embedded->invalid = true;
1371
double pws = embedded->m_lineWidth;
1372
embedded->DrawObj_Pre(p, sc);
1373
switch(embedded->itemType())
1380
embedded->DrawObj_Item(p, cullingArea, sc);
1384
embedded->m_lineWidth = pws * qMin(style.scaleH() / 1000.0, style.scaleV() / 1000.0);
1385
embedded->DrawObj_Item(p, cullingArea, sc);
1390
embedded->m_lineWidth = pws * qMin(style.scaleH() / 1000.0, style.scaleV() / 1000.0);
1391
embedded->DrawObj_Post(p);
1395
if (groupStack.count() != 0)
1397
while (embedded == groupStack.top())
1402
if (groupStack.count() == 0)
1406
embedded->m_lineWidth = pws;
1408
for (int em = 0; em < emG.count(); ++em)
1410
PageItem* embedded = emG.at(em);
1411
if (!embedded->isTableItem)
1414
double x = embedded->xPos();
1415
double y = embedded->yPos();
1416
embedded->Xpos = embedded->gXpos;
1417
embedded->Ypos = (embedded->gHeight * (style.scaleV() / 1000.0)) + embedded->gYpos;
1418
p->translate((embedded->gXpos * (style.scaleH() / 1000.0)), ( - (embedded->gHeight * (style.scaleV() / 1000.0)) + embedded->gYpos * (style.scaleV() / 1000.0)));
1419
if (style.baselineOffset() != 0)
1421
p->translate(0, -embedded->gHeight * (style.baselineOffset() / 1000.0));
1422
embedded->Ypos -= embedded->gHeight * (style.baselineOffset() / 1000.0);
1424
p->scale(style.scaleH() / 1000.0, style.scaleV() / 1000.0);
1425
p->rotate(embedded->rotation());
1426
double pws = embedded->m_lineWidth;
1427
embedded->m_lineWidth = pws * qMin(style.scaleH() / 1000.0, style.scaleV() / 1000.0);
1428
if ((embedded->lineColor() != CommonStrings::None) && (embedded->lineWidth() != 0.0))
1431
embedded->SetQColor(&tmp, embedded->lineColor(), embedded->lineShade());
1432
if ((embedded->TopLine) || (embedded->RightLine) || (embedded->BottomLine) || (embedded->LeftLine))
1434
p->setPen(tmp, embedded->lineWidth(), embedded->PLineArt, Qt::SquareCap, embedded->PLineJoin);
1435
if (embedded->TopLine)
1436
p->drawLine(FPoint(0.0, 0.0), FPoint(embedded->width(), 0.0));
1437
if (embedded->RightLine)
1438
p->drawLine(FPoint(embedded->width(), 0.0), FPoint(embedded->width(), embedded->height()));
1439
if (embedded->BottomLine)
1440
p->drawLine(FPoint(embedded->width(), embedded->height()), FPoint(0.0, embedded->height()));
1441
if (embedded->LeftLine)
1442
p->drawLine(FPoint(0.0, embedded->height()), FPoint(0.0, 0.0));
1445
embedded->m_lineWidth = pws;
1453
void PageItem::paintObj(QPainter *p)
1455
if ((!m_Doc->DoDrawing) || (m_Doc->RePos))
1460
double sc = m_Doc->view()->scale();
1461
double handleSize = 6.0 / sc;
1462
double halfSize = 3.0 / sc;
1463
if ((!FrameOnly) && (!m_Doc->RePos))
1465
if (!m_Doc->m_Selection->isEmpty())
1467
// qDebug() << "Item: " << ItemNr << "W: " << Width << "H: " << Height;
1468
if (Groups.count() == 0)
1470
//Locked line colour selection
1472
p->setPen(QPen(PrefsManager::instance()->appPrefs.DFrameLockColor, 1.0 / sc, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
1474
p->setPen(QPen(PrefsManager::instance()->appPrefs.DFrameColor, 1.0 / sc, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
1475
p->setBrush(Qt::NoBrush);
1476
double lw2 = 1.0 / sc;
1477
double lw = 1.0 / sc;
1478
Qt::PenCapStyle le = Qt::FlatCap;
1479
if (NamedLStyle.isEmpty())
1481
lw2 = (m_lineWidth / 2.0) / sc;
1482
lw = qMax(m_lineWidth, 1.0) / sc;
1487
multiLine ml = m_Doc->MLineStyles[NamedLStyle];
1488
lw2 = (ml[ml.size()-1].Width / 2.0) / sc;
1489
lw = qMax(ml[ml.size()-1].Width, 1.0) / sc;
1490
le = static_cast<Qt::PenCapStyle>(ml[ml.size()-1].LineEnd);
1492
//Draw our frame outline
1495
if (le != Qt::FlatCap)
1496
p->drawRect(QRectF(-lw2, -lw2, Width+lw, lw));
1498
p->drawRect(QRectF(-1 / sc, -lw2, Width, lw));
1501
p->drawRect(QRectF(0, 0, Width, Height));
1502
// p->setPen(QPen(PrefsManager::instance()->appPrefs.DFrameColor, 1.0 / sc, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
1503
p->setBrush(PrefsManager::instance()->appPrefs.DFrameColor);
1504
p->setPen(Qt::NoPen);
1505
if ((!m_Locked) && (!m_SizeLocked))
1509
p->drawRect(QRectF(0.0, 0.0, handleSize, handleSize));
1510
p->drawRect(QRectF(Width - handleSize, Height - handleSize, handleSize, handleSize));
1511
p->drawRect(QRectF(Width - handleSize, 0.0, handleSize, handleSize));
1512
p->drawRect(QRectF(0.0, Height - handleSize, handleSize, handleSize));
1515
p->drawRect(QRectF(Width / 2.0 - halfSize, Height - handleSize, handleSize, handleSize));
1516
p->drawRect(QRectF(Width / 2.0 - halfSize, 0.0, handleSize, handleSize));
1520
p->drawRect(QRectF(Width - handleSize, Height / 2.0 - halfSize, handleSize, handleSize));
1521
p->drawRect(QRectF(0.0, Height / 2.0 - halfSize, handleSize, handleSize));
1526
p->drawRect(QRectF(-halfSize, -halfSize, handleSize, handleSize));
1527
p->drawRect(QRectF(Width + halfSize, -halfSize, -handleSize, handleSize));
1533
p->setPen(QPen(PrefsManager::instance()->appPrefs.DFrameGroupColor, 1.0 / sc, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
1534
p->setBrush(Qt::NoBrush);
1535
p->drawRect(QRectF(0.0, 0.0, Width, Height));
1536
if (m_Doc->m_Selection->count() == 1)
1538
p->setPen(Qt::NoPen);
1539
// p->setPen(QPen(PrefsManager::instance()->appPrefs.DFrameGroupColor, 1.0 / sc, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
1540
p->setBrush(PrefsManager::instance()->appPrefs.DFrameGroupColor);
1541
p->drawRect(QRectF(0.0, 0.0, handleSize, handleSize));
1542
p->drawRect(QRectF(Width - handleSize, Height - handleSize, handleSize, handleSize));
1543
p->drawRect(QRectF(Width - handleSize, 0.0, handleSize, handleSize));
1544
p->drawRect(QRectF(0.0, Height - handleSize, handleSize, handleSize));
1547
p->drawRect(QRectF(Width / 2.0 - halfSize, Height - handleSize, handleSize, handleSize));
1548
p->drawRect(QRectF(Width / 2.0 - halfSize, 0.0, handleSize, handleSize));
1552
p->drawRect(QRectF(Width - handleSize, Height / 2.0 - halfSize, handleSize, handleSize));
1553
p->drawRect(QRectF(0.0, Height / 2.0 - halfSize, handleSize, handleSize));
1562
QImage PageItem::DrawObj_toImage()
1564
QList<PageItem*> emG;
1566
double minx = std::numeric_limits<double>::max();
1567
double miny = std::numeric_limits<double>::max();
1568
double maxx = -std::numeric_limits<double>::max();
1569
double maxy = -std::numeric_limits<double>::max();
1570
if (Groups.count() != 0)
1572
for (int ga=0; ga<m_Doc->Items->count(); ++ga)
1574
if (m_Doc->Items->at(ga)->Groups.count() != 0)
1576
if (m_Doc->Items->at(ga)->Groups.top() == Groups.top())
1578
if (!emG.contains(m_Doc->Items->at(ga)))
1580
emG.append(m_Doc->Items->at(ga));
1581
PageItem *currItem = m_Doc->Items->at(ga);
1582
double x1, x2, y1, y2;
1583
currItem->getVisualBoundingRect(&x1, &y1, &x2, &y2);
1584
minx = qMin(minx, x1);
1585
miny = qMin(miny, y1);
1586
maxx = qMax(maxx, x2);
1587
maxy = qMax(maxy, y2);
1592
for (int em = 0; em < emG.count(); ++em)
1594
PageItem* currItem = emG.at(em);
1595
currItem->gXpos = currItem->xPos() - minx;
1596
currItem->gYpos = currItem->yPos() - miny;
1597
currItem->gWidth = maxx - minx;
1598
currItem->gHeight = maxy - miny;
1603
double x1, x2, y1, y2;
1604
getVisualBoundingRect(&x1, &y1, &x2, &y2);
1605
minx = qMin(minx, x1);
1606
miny = qMin(miny, y1);
1607
maxx = qMax(maxx, x2);
1608
maxy = qMax(maxy, y2);
1609
gXpos = xPos() - minx;
1610
gYpos = yPos() - miny;
1611
gWidth = maxx - minx;
1612
gHeight = maxy - miny;
1615
return DrawObj_toImage(emG);
1618
QImage PageItem::DrawObj_toImage(QList<PageItem*> &emG)
1620
QImage retImg = QImage(qRound(gWidth), qRound(gHeight), QImage::Format_ARGB32);
1621
// retImg.fill( qRgba(255, 255, 255, 0) );
1622
retImg.fill( qRgba(0, 0, 0, 0) );
1623
ScPainter *painter = new ScPainter(&retImg, retImg.width(), retImg.height(), 1, 0);
1624
// painter->setZoomFactor(1.0);
1625
painter->setZoomFactor(qMax(qRound(gWidth) / gWidth, qRound(gHeight) / gHeight));
1626
QStack<PageItem*> groupStack;
1627
for (int em = 0; em < emG.count(); ++em)
1629
PageItem* embedded = emG.at(em);
1630
if (embedded->isGroupControl)
1633
FPointArray cl = embedded->PoLine.copy();
1635
mm.translate(embedded->gXpos, embedded->gYpos);
1636
mm.rotate(embedded->rotation());
1638
painter->beginLayer(1.0 - embedded->fillTransparency(), embedded->fillBlendmode(), &cl);
1639
groupStack.push(embedded->groupsLastItem);
1643
// qDebug()<<embedded<<embedded->xPos()<<embedded->yPos()<<embedded->gXpos<<embedded->gYpos;
1644
// double x = embedded->xPos();
1645
// double y = embedded->yPos();
1646
// embedded->Xpos = embedded->gXpos;
1647
// embedded->Ypos = embedded->gYpos;
1648
// Seems to work without all this coordinates mess. To monitor tho
1649
painter->translate(embedded->gXpos, embedded->gYpos);
1650
embedded->isEmbedded = true;
1651
embedded->invalid = true;
1652
embedded->DrawObj(painter, QRectF());
1653
// embedded->Xpos = x;
1654
// embedded->Ypos = y;
1655
embedded->isEmbedded = false;
1657
if (groupStack.count() != 0)
1659
while (embedded == groupStack.top())
1661
painter->endLayer();
1664
if (groupStack.count() == 0)
1669
for (int em = 0; em < emG.count(); ++em)
1671
PageItem* embedded = emG.at(em);
1672
if (!embedded->isTableItem)
1675
// double x = embedded->xPos();
1676
// double y = embedded->yPos();
1677
// embedded->Xpos = embedded->gXpos;
1678
// embedded->Ypos = embedded->gYpos;
1679
painter->translate(embedded->gXpos, embedded->gYpos);
1680
painter->rotate(embedded->rotation());
1681
embedded->isEmbedded = true;
1682
embedded->invalid = true;
1683
if ((embedded->lineColor() != CommonStrings::None) && (embedded->lineWidth() != 0.0))
1686
embedded->SetQColor(&tmp, embedded->lineColor(), embedded->lineShade());
1687
if ((embedded->TopLine) || (embedded->RightLine) || (embedded->BottomLine) || (embedded->LeftLine))
1689
painter->setPen(tmp, embedded->lineWidth(), embedded->PLineArt, Qt::SquareCap, embedded->PLineJoin);
1690
if (embedded->TopLine)
1691
painter->drawLine(FPoint(0.0, 0.0), FPoint(embedded->width(), 0.0));
1692
if (embedded->RightLine)
1693
painter->drawLine(FPoint(embedded->width(), 0.0), FPoint(embedded->width(), embedded->height()));
1694
if (embedded->BottomLine)
1695
painter->drawLine(FPoint(embedded->width(), embedded->height()), FPoint(0.0, embedded->height()));
1696
if (embedded->LeftLine)
1697
painter->drawLine(FPoint(0.0, embedded->height()), FPoint(0.0, 0.0));
1700
embedded->isEmbedded = false;
1701
// embedded->Xpos = x;
1702
// embedded->Ypos = y;
1710
QString PageItem::ExpandToken(uint base)
1713
QChar ch = itemText.text(base);
1715
if (ch == SpecialChars::PAGENUMBER)
1717
// compatibility mode: ignore subsequent pagenumber chars
1718
if (base > 0 && itemText.text(base-1) == SpecialChars::PAGENUMBER)
1720
if ((!m_Doc->masterPageMode()) && (OwnPage != -1))
1723
//CB Section numbering
1724
chstr = out.arg(m_Doc->getSectionPageNumberForPageIndex(OwnPage), -(int)zae);
1729
else if (ch == SpecialChars::PAGECOUNT)
1731
if (!m_Doc->masterPageMode())
1734
int key = m_Doc->getSectionKeyForPageIndex(OwnPage);
1737
chstr = out.arg(getStringFromSequence(m_Doc->sections[key].type, m_Doc->sections[key].toindex - m_Doc->sections[key].fromindex + 1));
1745
void PageItem::SetQColor(QColor *tmp, QString farbe, double shad)
1747
const ScColor& col = m_Doc->PageColors[farbe];
1748
*tmp = ScColorEngine::getShadeColorProof(col, m_Doc, shad);
1749
if ((m_Doc->view()) && (m_Doc->view()->m_canvas->usePreviewVisual()))
1751
VisionDefectColor defect;
1752
*tmp = defect.convertDefect(*tmp, m_Doc->view()->m_canvas->previewVisual());
1757
layout glyphs translates the chars into a number of glyphs, applying the Charstyle
1758
'style'. The following fields are set in layout: glyph, more, scaleH, scaleV, xoffset, yoffset, xadvance.
1759
If the DropCap-bit in style.effects is set and yadvance is > 0, scaleH/V, x/yoffset and xadvance
1760
are modified to scale the glyphs to this height.
1761
Otherwise yadvance is set to the max ascender of all generated glyphs.
1762
It scales according to smallcaps and
1763
sets xadvance to the advance width without kerning. If more than one glyph
1764
is generated, kerning is included in all but the last xadvance.
1766
double PageItem::layoutGlyphs(const CharStyle& style, const QString& chars, GlyphLayout& layout)
1768
double retval = 0.0;
1769
double asce = style.font().ascent(style.fontSize() / 10.0);
1770
int chst = style.effects() & 1919;
1771
/* if (chars[0] == SpecialChars::ZWSPACE ||
1772
chars[0] == SpecialChars::ZWNBSPACE ||
1773
chars[0] == SpecialChars::NBSPACE ||
1774
chars[0] == SpecialChars::NBHYPHEN ||
1775
chars[0] == SpecialChars::SHYPHEN ||
1776
chars[0] == SpecialChars::PARSEP ||
1777
chars[0] == SpecialChars::COLBREAK ||
1778
chars[0] == SpecialChars::LINEBREAK ||
1779
chars[0] == SpecialChars::FRAMEBREAK ||
1780
chars[0] == SpecialChars::TAB)
1782
layout.glyph = ScFace::CONTROL_GLYPHS + chars[0].unicode();
1786
layout.glyph = style.font().char2CMap(chars[0].unicode());
1789
double tracking = 0.0;
1790
if ( (style.effects() & ScStyle_StartOfLine) == 0)
1791
tracking = style.fontSize() * style.tracking() / 10000.0;
1793
layout.xoffset = tracking;
1795
if (chst != ScStyle_Default)
1797
if (chst & ScStyle_Superscript)
1799
retval -= asce * m_Doc->typographicSettings.valueSuperScript / 100.0;
1800
layout.yoffset -= asce * m_Doc->typographicSettings.valueSuperScript / 100.0;
1801
layout.scaleV = layout.scaleH = qMax(m_Doc->typographicSettings.scalingSuperScript / 100.0, 10.0 / style.fontSize());
1803
else if (chst & ScStyle_Subscript)
1805
retval += asce * m_Doc->typographicSettings.valueSubScript / 100.0;
1806
layout.yoffset += asce * m_Doc->typographicSettings.valueSubScript / 100.0;
1807
layout.scaleV = layout.scaleH = qMax(m_Doc->typographicSettings.scalingSubScript / 100.0, 10.0 / style.fontSize());
1810
layout.scaleV = layout.scaleH = 1.0;
1812
layout.scaleH *= style.scaleH() / 1000.0;
1813
layout.scaleV *= style.scaleV() / 1000.0;
1814
if (chst & ScStyle_AllCaps)
1816
layout.glyph = style.font().char2CMap(chars[0].toUpper().unicode());
1818
if (chst & ScStyle_SmallCaps)
1820
double smallcapsScale = m_Doc->typographicSettings.valueSmallCaps / 100.0;
1821
QChar uc = chars[0].toUpper();
1824
layout.glyph = style.font().char2CMap(chars[0].toUpper().unicode());
1825
layout.scaleV *= smallcapsScale;
1826
layout.scaleH *= smallcapsScale;
1831
layout.scaleH = style.scaleH() / 1000.0;
1832
layout.scaleV = style.scaleV() / 1000.0;
1835
/* if (layout.glyph == (ScFace::CONTROL_GLYPHS + SpecialChars::NBSPACE.unicode())) {
1836
uint replGlyph = style.font().char2CMap(QChar(' '));
1837
layout.xadvance = style.font().glyphWidth(replGlyph, style.fontSize() / 10) * layout.scaleH;
1838
layout.yadvance = style.font().glyphBBox(replGlyph, style.fontSize() / 10).ascent * layout.scaleV;
1840
else if (layout.glyph == (ScFace::CONTROL_GLYPHS + SpecialChars::NBHYPHEN.unicode())) {
1841
uint replGlyph = style.font().char2CMap(QChar('-'));
1842
layout.xadvance = style.font().glyphWidth(replGlyph, style.fontSize() / 10) * layout.scaleH;
1843
layout.yadvance = style.font().glyphBBox(replGlyph, style.fontSize() / 10).ascent * layout.scaleV;
1845
else if (layout.glyph >= ScFace::CONTROL_GLYPHS) {
1846
layout.xadvance = 0;
1847
layout.yadvance = 0;
1851
layout.xadvance = style.font().glyphWidth(layout.glyph, style.fontSize() / 10) * layout.scaleH;
1852
layout.yadvance = style.font().glyphBBox(layout.glyph, style.fontSize() / 10).ascent * layout.scaleV;
1854
if (layout.xadvance > 0)
1855
layout.xadvance += tracking;
1857
if (chars.length() > 1) {
1859
layoutGlyphs(style, chars.mid(1), *layout.more);
1860
layout.xadvance += style.font().glyphKerning(layout.glyph, layout.more->glyph, style.fontSize() / 10) * layout.scaleH;
1861
if (layout.more->yadvance > layout.yadvance)
1862
layout.yadvance = layout.more->yadvance;
1870
void PageItem::drawGlyphs(ScPainter *p, const CharStyle& style, GlyphLayout& glyphs)
1872
uint glyph = glyphs.glyph;
1873
if ((m_Doc->guidesSettings.showControls) &&
1874
(glyph == style.font().char2CMap(QChar(' ')) || glyph >= ScFace::CONTROL_GLYPHS))
1876
bool stroke = false;
1877
if (glyph >= ScFace::CONTROL_GLYPHS)
1878
glyph -= ScFace::CONTROL_GLYPHS;
1881
QMatrix chma, chma4, chma5;
1883
if (glyph == SpecialChars::TAB.unicode())
1885
points = m_Doc->symTab.copy();
1886
chma4.translate(glyphs.xoffset + glyphs.xadvance - ((style.fontSize() / 10.0) * glyphs.scaleH * 0.7), glyphs.yoffset - ((style.fontSize() / 10.0) * glyphs.scaleV * 0.5));
1888
else if (glyph == SpecialChars::COLBREAK.unicode())
1890
points = m_Doc->symNewCol.copy();
1891
chma4.translate(glyphs.xoffset, glyphs.yoffset-((style.fontSize() / 10.0) * glyphs.scaleV * 0.6));
1893
else if (glyph == SpecialChars::FRAMEBREAK.unicode())
1895
points = m_Doc->symNewFrame.copy();
1896
chma4.translate(glyphs.xoffset, glyphs.yoffset-((style.fontSize() / 10.0) * glyphs.scaleV * 0.6));
1898
else if (glyph == SpecialChars::PARSEP.unicode())
1900
points = m_Doc->symReturn.copy();
1901
chma4.translate(glyphs.xoffset, glyphs.yoffset-((style.fontSize() / 10.0) * glyphs.scaleV * 0.8));
1903
else if (glyph == SpecialChars::LINEBREAK.unicode())
1905
points = m_Doc->symNewLine.copy();
1906
chma4.translate(glyphs.xoffset, glyphs.yoffset-((style.fontSize() / 10.0) * glyphs.scaleV * 0.4));
1908
else if (glyph == SpecialChars::NBSPACE.unicode() ||
1911
stroke = (glyph == 32);
1912
points = m_Doc->symNonBreak.copy();
1913
chma4.translate(glyphs.xoffset, glyphs.yoffset-((style.fontSize() / 10.0) * glyphs.scaleV * 0.4));
1915
else if (glyph == SpecialChars::NBHYPHEN.unicode())
1917
points = style.font().glyphOutline(style.font().char2CMap(QChar('-')), style.fontSize() / 100);
1918
chma4.translate(glyphs.xoffset, glyphs.yoffset-((style.fontSize() / 10.0) * glyphs.scaleV));
1920
else if (glyph == SpecialChars::SHYPHEN.unicode())
1923
points.addQuadPoint(0, -10, 0, -10, 0, -6, 0, -6);
1929
points.addQuadPoint(0, -10, 0, -10, 0, -9, 0, -9);
1930
points.addQuadPoint(0, -9, 0, -9, 1, -9, 1, -9);
1931
points.addQuadPoint(1, -9, 1, -9, 1, -10, 1, -10);
1932
points.addQuadPoint(1, -10, 1, -10, 0, -10, 0, -10);
1934
chma.scale(glyphs.scaleH * style.fontSize() / 100.0, glyphs.scaleV * style.fontSize() / 100.0);
1935
points.map(chma * chma4);
1936
p->setupPolygon(&points, true);
1937
QColor oldBrush = p->brush();
1938
p->setBrush( (style.effects() & ScStyle_SuppressSpace) ? Qt::green
1939
: PrefsManager::instance()->appPrefs.DControlCharColor);
1942
QColor tmp = p->pen();
1943
p->setPen(p->brush(), 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
1944
p->setLineWidth(style.fontSize() * glyphs.scaleV / 200.0);
1946
p->setPen(tmp, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
1953
p->setBrush(oldBrush);
1956
p->translate(glyphs.xadvance, 0);
1957
drawGlyphs(p, style, *glyphs.more);
1961
else if (glyph == (ScFace::CONTROL_GLYPHS + SpecialChars::NBSPACE.unicode()) ||
1962
glyph == (ScFace::CONTROL_GLYPHS + 32))
1963
glyph = style.font().char2CMap(QChar(' '));
1964
else if (glyph == (ScFace::CONTROL_GLYPHS + SpecialChars::NBHYPHEN.unicode()))
1965
glyph = style.font().char2CMap(QChar('-'));
1967
if (glyph >= ScFace::CONTROL_GLYPHS || (style.effects() & ScStyle_SuppressSpace)) {
1968
// qDebug("drawGlyphs: skipping %d", glyph);
1969
// all those are empty
1972
p->translate(glyphs.xadvance, 0);
1973
drawGlyphs(p, style, *glyphs.more);
1977
// if (style.font().canRender(QChar(glyph)))
1979
FPointArray gly = style.font().glyphOutline(glyph);
1980
// Do underlining first so you can get typographically correct
1981
// underlines when drawing a white outline
1982
if (((style.effects() & ScStyle_Underline) || ((style.effects() & ScStyle_UnderlineWords) && glyph != style.font().char2CMap(QChar(' ')))) && (style.strokeColor() != CommonStrings::None))
1985
if ((style.underlineOffset() != -1) || (style.underlineWidth() != -1))
1987
if (style.underlineOffset() != -1)
1988
st = (style.underlineOffset() / 1000.0) * (style.font().descent(style.fontSize() / 10.0));
1990
st = style.font().underlinePos(style.fontSize() / 10.0);
1991
if (style.underlineWidth() != -1)
1992
lw = (style.underlineWidth() / 1000.0) * (style.fontSize() / 10.0);
1994
lw = qMax(style.font().strokeWidth(style.fontSize() / 10.0), 1.0);
1998
st = style.font().underlinePos(style.fontSize() / 10.0);
1999
lw = qMax(style.font().strokeWidth(style.fontSize() / 10.0), 1.0);
2001
if (style.baselineOffset() != 0)
2002
st += (style.fontSize() / 10.0) * glyphs.scaleV * (style.baselineOffset() / 1000.0);
2003
QColor tmpC = p->pen();
2004
p->setPen(p->brush());
2005
p->setLineWidth(lw);
2006
if (style.effects() & ScStyle_Subscript)
2007
p->drawLine(FPoint(glyphs.xoffset, glyphs.yoffset - st), FPoint(glyphs.xoffset + glyphs.xadvance, glyphs.yoffset - st));
2009
p->drawLine(FPoint(glyphs.xoffset, -st), FPoint(glyphs.xoffset + glyphs.xadvance, -st));
2016
// qDebug() << QString("glyph 0: (%1,%2) * %3 %4 + %5").arg(glyphs.xoffset).arg(glyphs.yoffset).arg(glyphs.scaleH).arg(glyphs.scaleV).arg(glyphs.xadvance));
2019
p->translate(glyphs.xoffset, glyphs.yoffset - ((style.fontSize() / 10.0) * glyphs.scaleV));
2023
p->translate(-glyphs.xadvance, 0);
2025
if (style.baselineOffset() != 0)
2026
p->translate(0, -(style.fontSize() / 10.0) * (style.baselineOffset() / 1000.0));
2027
double glxSc = glyphs.scaleH * style.fontSize() / 100.00;
2028
double glySc = glyphs.scaleV * style.fontSize() / 100.0;
2029
p->scale(glxSc, glySc);
2030
// p->setFillMode(1);
2031
bool fr = p->fillRule();
2032
p->setFillRule(false);
2033
// double a = gly.point(0).x();
2034
// double b = gly.point(0).y();
2035
// double c = gly.point(3).x();
2036
// double d = gly.point(3).y();
2037
// qDebug() << QString("drawglyphs: %1 (%2,%3) (%4,%5) scaled %6,%7 trans %8,%9")
2038
// .arg(gly.size()).arg(a).arg(b).arg(c).arg(d)
2039
// .arg(p->worldMatrix().m11()).arg(p->worldMatrix().m22()).arg(p->worldMatrix().dx()).arg(p->worldMatrix().dy());
2040
p->setupPolygon(&gly, true);
2041
if (m_Doc->layerOutline(LayerNr))
2044
p->setPen(m_Doc->layerMarker(LayerNr), 0.5, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
2045
p->setFillMode(ScPainter::None);
2046
p->setBrushOpacity(1.0);
2047
p->setPenOpacity(1.0);
2054
p->translate(glyphs.xadvance, 0);
2055
drawGlyphs(p, style, *glyphs.more);
2061
p->setPen(PrefsManager::instance()->appPrefs.DControlCharColor, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
2062
p->setLineWidth(style.fontSize() * glyphs.scaleV * style.outlineWidth() * 2 / 10000.0);
2065
else if ((style.font().isStroked()) && (style.strokeColor() != CommonStrings::None) && ((style.fontSize() * glyphs.scaleV * style.outlineWidth() / 10000.0) != 0))
2067
QColor tmp = p->brush();
2068
p->setPen(tmp, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
2069
p->setLineWidth(style.fontSize() * glyphs.scaleV * style.outlineWidth() / 10000.0);
2074
if ((style.effects() & ScStyle_Shadowed) && (style.strokeColor() != CommonStrings::None))
2077
p->translate((style.fontSize() * glyphs.scaleH * style.shadowXOffset() / 10000.0) / glxSc, -(style.fontSize() * glyphs.scaleV * style.shadowYOffset() / 10000.0) / glySc);
2078
QColor tmp = p->brush();
2079
p->setBrush(p->pen());
2080
p->setupPolygon(&gly, true);
2084
p->setupPolygon(&gly, true);
2086
if (style.fillColor() != CommonStrings::None)
2088
if ((style.effects() & ScStyle_Outline) && (style.strokeColor() != CommonStrings::None) && ((style.fontSize() * glyphs.scaleV * style.outlineWidth() / 10000.0) != 0))
2090
p->setLineWidth((style.fontSize() * glyphs.scaleV * style.outlineWidth() / 10000.0) / glySc);
2098
// qDebug() << "drawGlyphs: empty glyph" << glyph;
2100
if ((style.effects() & ScStyle_Strikethrough) && (style.strokeColor() != CommonStrings::None))
2103
if ((style.strikethruOffset() != -1) || (style.strikethruWidth() != -1))
2105
if (style.strikethruOffset() != -1)
2106
st = (style.strikethruOffset() / 1000.0) * (style.font().ascent(style.fontSize() / 10.0));
2108
st = style.font().strikeoutPos(style.fontSize() / 10.0);
2109
if (style.strikethruWidth() != -1)
2110
lw = (style.strikethruWidth() / 1000.0) * (style.fontSize() / 10.0);
2112
lw = qMax(style.font().strokeWidth(style.fontSize() / 10.0), 1.0);
2116
st = style.font().strikeoutPos(style.fontSize() / 10.0);
2117
lw = qMax(style.font().strokeWidth(style.fontSize() / 10.0), 1.0);
2119
if (style.baselineOffset() != 0)
2120
st += (style.fontSize() / 10.0) * glyphs.scaleV * (style.baselineOffset() / 1000.0);
2121
p->setPen(p->brush());
2122
p->setLineWidth(lw);
2123
p->drawLine(FPoint(glyphs.xoffset, glyphs.yoffset - st), FPoint(glyphs.xoffset + glyphs.xadvance, glyphs.yoffset - st));
2132
p->drawRect(glyphs.xoffset, glyphs.yoffset - (style.fontSize() / 10.0) * glyphs.scaleV , (style.fontSize() / 10.0) * glyphs.scaleH, (style.fontSize() / 10.0) * glyphs.scaleV);
2137
p->translate(glyphs.xadvance, 0);
2138
drawGlyphs(p, style, *glyphs.more);
2142
void PageItem::DrawPolyL(QPainter *p, QPolygon pts)
2144
if (Segments.count() != 0)
2146
QList<uint>::Iterator it2end=Segments.end();
2148
for (QList<uint>::Iterator it2 = Segments.begin(); it2 != it2end; ++it2)
2150
p->drawPolygon(pts.constData() + FirstVal, (*it2)-FirstVal);
2153
p->drawPolygon(pts.constData() + FirstVal, pts.size() - FirstVal);
2156
p->drawPolygon(pts);
2159
if (Segments.count() != 0)
2161
QList<uint>::Iterator it2end=Segments.end();
2163
for (QList<uint>::Iterator it2 = Segments.begin(); it2 != it2end; ++it2)
2165
if (NamedLStyle.isEmpty())
2167
if (lineColor() != CommonStrings::None)
2168
p->setPen(QPen(strokeQColor, m_lineWidth, PLineArt, PLineEnd, PLineJoin));
2169
p->drawPolygon(pts.constData() + FirstVal, (*it2)-FirstVal);
2173
multiLine ml = m_Doc->MLineStyles[NamedLStyle];
2174
for (int it = ml.size()-1; it > -1; it--)
2176
SetQColor(&tmp, ml[it].Color, ml[it].Shade);
2178
qMax(static_cast<int>(ml[it].Width), 1),
2179
static_cast<Qt::PenStyle>(ml[it].Dash),
2180
static_cast<Qt::PenCapStyle>(ml[it].LineEnd),
2181
static_cast<Qt::PenJoinStyle>(ml[it].LineJoin)));
2182
p->drawPolygon(pts.constData() + FirstVal, (*it2)-FirstVal);
2187
if (NamedLStyle.isEmpty())
2189
if (lineColor() != CommonStrings::None)
2190
p->setPen(QPen(strokeQColor, m_lineWidth, PLineArt, PLineEnd, PLineJoin));
2191
p->drawPolygon(pts.constData() + FirstVal, pts.size() - FirstVal);
2195
multiLine ml = m_Doc->MLineStyles[NamedLStyle];
2196
for (int it = ml.size()-1; it > -1; it--)
2198
SetQColor(&tmp, ml[it].Color, ml[it].Shade);
2200
qMax(static_cast<int>(ml[it].Width), 1),
2201
static_cast<Qt::PenStyle>(ml[it].Dash),
2202
static_cast<Qt::PenCapStyle>(ml[it].LineEnd),
2203
static_cast<Qt::PenJoinStyle>(ml[it].LineJoin)));
2204
p->drawPolygon(pts.constData() + FirstVal, pts.size() - FirstVal);
2210
if (NamedLStyle.isEmpty())
2212
if (lineColor() != CommonStrings::None)
2213
p->setPen(QPen(strokeQColor, m_lineWidth, PLineArt, PLineEnd, PLineJoin));
2214
p->drawPolygon(pts);
2218
multiLine ml = m_Doc->MLineStyles[NamedLStyle];
2219
for (int it = ml.size()-1; it > -1; it--)
2221
SetQColor(&tmp, ml[it].Color, ml[it].Shade);
2223
qMax(static_cast<int>(ml[it].Width), 1),
2224
static_cast<Qt::PenStyle>(ml[it].Dash),
2225
static_cast<Qt::PenCapStyle>(ml[it].LineEnd),
2226
static_cast<Qt::PenJoinStyle>(ml[it].LineJoin)));
2227
p->drawPolygon(pts);
2233
void PageItem::setItemName(const QString& newName)
2235
if (AnName == newName)
2236
return; // nothing to do -> return
2237
if (newName.isEmpty())
2239
QString oldName = AnName;
2240
AnName = generateUniqueCopyName(newName);
2242
if (UndoManager::undoEnabled())
2244
SimpleState *ss = new SimpleState(Um::Rename, QString(Um::FromTo).arg(AnName).arg(newName));
2245
ss->set("OLD_NAME", oldName);
2246
ss->set("NEW_NAME", newName);
2247
undoManager->action(this, ss);
2249
setUName(AnName); // set the name for the UndoObject too
2252
void PageItem::setPattern(const QString &newPattern)
2254
if (patternVal != newPattern)
2255
patternVal = newPattern;
2258
void PageItem::gradientVector(double& startX, double& startY, double& endX, double& endY) const
2266
void PageItem::setGradientVector(double startX, double startY, double endX, double endY)
2274
void PageItem::setPatternTransform(double scaleX, double scaleY, double offsetX, double offsetY, double rotation)
2276
patternScaleX = scaleX;
2277
patternScaleY = scaleY;
2278
patternOffsetX = offsetX;
2279
patternOffsetY = offsetY;
2280
patternRotation = rotation;
2283
void PageItem::patternTransform(double &scaleX, double &scaleY, double &offsetX, double &offsetY, double &rotation) const
2285
scaleX = patternScaleX;
2286
scaleY = patternScaleY;
2287
offsetX = patternOffsetX;
2288
offsetY = patternOffsetY;
2289
rotation = patternRotation;
2292
void PageItem::setFillColor(const QString &newColor)
2294
QString tmp = newColor;
2295
if (tmp != CommonStrings::None)
2297
if (!m_Doc->PageColors.contains(newColor))
2303
tmp = m_Doc->toolSettings.dBrushPict;
2306
tmp = m_Doc->toolSettings.dTextBackGround;
2311
tmp = m_Doc->toolSettings.dBrush;
2318
if (fillColorVal == tmp)
2323
if (UndoManager::undoEnabled())
2325
SimpleState *ss = new SimpleState(Um::SetFill,
2326
QString(Um::ColorFromTo).arg(fillColorVal).arg(tmp),
2328
ss->set("FILL", "fill");
2329
ss->set("OLD_FILL", fillColorVal);
2330
ss->set("NEW_FILL", tmp);
2331
undoManager->action(this, ss);
2336
fill_gradient = VGradient(VGradient::linear);
2337
fill_gradient.clearStops();
2338
if (fillColorVal != CommonStrings::None)
2340
const ScColor& col = m_Doc->PageColors[fillColorVal];
2341
fill_gradient.addStop(ScColorEngine::getRGBColor(col, m_Doc), 0.0, 0.5, 1.0, fillColorVal, 100);
2342
fill_gradient.addStop(ScColorEngine::getRGBColor(col, m_Doc), 1.0, 0.5, 1.0, fillColorVal, 100);
2346
//CB unused in 135 emit colors(lineColorVal, fillColorVal, lineShadeVal, fillShadeVal);
2349
void PageItem::setFillShade(double newShade)
2351
if (fillShadeVal == newShade)
2356
if (UndoManager::undoEnabled())
2358
SimpleState *ss = new SimpleState(Um::SetShade,
2359
QString(Um::FromTo).arg(fillShadeVal).arg(newShade),
2361
ss->set("SHADE", "shade");
2362
ss->set("OLD_SHADE", fillShadeVal);
2363
ss->set("NEW_SHADE", newShade);
2364
undoManager->action(this, ss);
2366
fillShadeVal = newShade;
2368
//CB unused in 135 emit colors(lineColorVal, fillColorVal, lineShadeVal, fillShadeVal);
2371
void PageItem::setFillTransparency(double newTransparency)
2373
if (fillTransparencyVal == newTransparency)
2374
return; // nothing to do -> return
2375
if (UndoManager::undoEnabled())
2377
SimpleState *ss = new SimpleState(Um::Transparency,
2378
QString(Um::FromTo).arg(fillTransparencyVal).arg(newTransparency),
2380
ss->set("TRANSPARENCY", "transparency");
2381
ss->set("OLD_TP", fillTransparencyVal);
2382
ss->set("NEW_TP", newTransparency);
2383
undoManager->action(this, ss);
2385
fillTransparencyVal = newTransparency;
2388
void PageItem::setFillBlendmode(int newBlendmode)
2390
if (fillBlendmodeVal == newBlendmode)
2391
return; // nothing to do -> return
2392
fillBlendmodeVal = newBlendmode;
2395
void PageItem::setLineColor(const QString &newColor)
2397
QString tmp = newColor;
2398
if (tmp != CommonStrings::None)
2400
if (!m_Doc->PageColors.contains(newColor))
2406
tmp = m_Doc->toolSettings.dTextLineColor;
2409
tmp = m_Doc->toolSettings.dPenLine;
2415
tmp = m_Doc->toolSettings.dPen;
2422
if (lineColorVal == tmp)
2427
if (UndoManager::undoEnabled())
2429
SimpleState *ss = new SimpleState(Um::SetLineColor,
2430
QString(Um::ColorFromTo).arg(lineColorVal).arg(tmp),
2432
ss->set("LINE_COLOR", "line_color");
2433
ss->set("OLD_COLOR", lineColorVal);
2434
ss->set("NEW_COLOR", tmp);
2435
undoManager->action(this, ss);
2439
//CB unused in 135 emit colors(lineColorVal, fillColorVal, lineShadeVal, fillShadeVal);
2442
void PageItem::setLineShade(double newShade)
2444
if (lineShadeVal == newShade)
2449
if (UndoManager::undoEnabled())
2451
SimpleState *ss = new SimpleState(Um::SetLineShade,
2452
QString(Um::FromTo).arg(lineShadeVal).arg(newShade),
2454
ss->set("LINE_SHADE", "line_shade");
2455
ss->set("OLD_SHADE", lineShadeVal);
2456
ss->set("NEW_SHADE", newShade);
2457
undoManager->action(this, ss);
2459
lineShadeVal = newShade;
2461
//CB unused in 135 emit colors(lineColorVal, fillColorVal, lineShadeVal, fillShadeVal);
2464
void PageItem::setLineQColor()
2466
if (lineColorVal != CommonStrings::None)
2468
if (!m_Doc->PageColors.contains(lineColorVal))
2474
lineColorVal = m_Doc->toolSettings.dTextLineColor;
2477
lineColorVal = m_Doc->toolSettings.dPenLine;
2483
lineColorVal = m_Doc->toolSettings.dPen;
2489
if (!m_Doc->PageColors.contains(lineColorVal))
2490
lineColorVal = m_Doc->toolSettings.dPen;
2491
const ScColor& col = m_Doc->PageColors[lineColorVal];
2492
strokeQColor = ScColorEngine::getShadeColorProof(col, m_Doc, lineShadeVal);
2494
if ((m_Doc->view()) && (m_Doc->view()->m_canvas->usePreviewVisual()))
2496
VisionDefectColor defect;
2497
strokeQColor = defect.convertDefect(strokeQColor, m_Doc->view()->m_canvas->previewVisual());
2501
void PageItem::setFillQColor()
2503
if (fillColorVal != CommonStrings::None)
2505
if (!m_Doc->PageColors.contains(fillColorVal))
2511
fillColorVal = m_Doc->toolSettings.dBrushPict;
2514
fillColorVal = m_Doc->toolSettings.dTextBackGround;
2519
fillColorVal = m_Doc->toolSettings.dBrush;
2525
const ScColor& col = m_Doc->PageColors[fillColorVal];
2526
fillQColor = ScColorEngine::getShadeColorProof(col, m_Doc, fillShadeVal);
2528
if ((m_Doc->view()) && (m_Doc->view()->m_canvas->usePreviewVisual()))
2530
VisionDefectColor defect;
2531
fillQColor = defect.convertDefect(fillQColor, m_Doc->view()->m_canvas->previewVisual());
2535
void PageItem::setLineTransparency(double newTransparency)
2537
if (lineTransparencyVal == newTransparency)
2538
return; // nothing to do -> return
2539
if (UndoManager::undoEnabled())
2541
SimpleState *ss = new SimpleState(Um::LineTransparency,
2542
QString(Um::FromTo).arg(lineTransparencyVal).arg(newTransparency),
2544
ss->set("LINE_TRANSPARENCY", "transparency");
2545
ss->set("OLD_TP", lineTransparencyVal);
2546
ss->set("NEW_TP", newTransparency);
2547
undoManager->action(this, ss);
2549
lineTransparencyVal = newTransparency;
2552
void PageItem::setLineBlendmode(int newBlendmode)
2554
if (lineBlendmodeVal == newBlendmode)
2555
return; // nothing to do -> return
2556
lineBlendmodeVal = newBlendmode;
2559
void PageItem::setLineStyle(Qt::PenStyle newStyle)
2561
if (PLineArt == newStyle)
2562
return; // nothing to do -> return
2563
if (UndoManager::undoEnabled())
2565
SimpleState *ss = new SimpleState(Um::LineStyle,"",Um::ILineStyle);
2566
ss->set("LINE_STYLE", "line_style");
2567
ss->set("OLD_STYLE", static_cast<int>(PLineArt));
2568
ss->set("NEW_STYLE", static_cast<int>(newStyle));
2569
undoManager->action(this, ss);
2571
PLineArt = newStyle;
2574
void PageItem::setLineWidth(double newWidth)
2576
if (m_lineWidth == newWidth)
2577
return; // nothing to do -> return
2578
if (UndoManager::undoEnabled())
2580
SimpleState *ss = new SimpleState(Um::LineWidth,
2581
QString(Um::FromTo).arg(m_lineWidth).arg(newWidth),Um::ILineStyle);
2582
ss->set("LINE_WIDTH", "line_width");
2583
ss->set("OLD_WIDTH", m_lineWidth);
2584
ss->set("NEW_WIDTH", newWidth);
2585
undoManager->action(this, ss);
2587
Oldm_lineWidth=m_lineWidth;
2588
m_lineWidth = newWidth;
2591
void PageItem::setLineEnd(Qt::PenCapStyle newStyle)
2593
if (PLineEnd == newStyle)
2594
return; // nothing to do -> return
2595
if (UndoManager::undoEnabled())
2597
SimpleState *ss = new SimpleState(Um::LineEnd,"",Um::ILineStyle);
2598
ss->set("LINE_END", "line_end");
2599
ss->set("OLD_STYLE", static_cast<int>(PLineEnd));
2600
ss->set("NEW_STYLE", static_cast<int>(newStyle));
2601
undoManager->action(this, ss);
2603
PLineEnd = newStyle;
2606
void PageItem::setLineJoin(Qt::PenJoinStyle newStyle)
2608
if (PLineJoin == newStyle)
2609
return; // nothing to do -> return
2610
if (UndoManager::undoEnabled())
2612
SimpleState *ss = new SimpleState(Um::LineJoin,"",Um::ILineStyle);
2613
ss->set("LINE_JOIN", "line_join");
2614
ss->set("OLD_STYLE", static_cast<int>(PLineJoin));
2615
ss->set("NEW_STYLE", static_cast<int>(newStyle));
2616
undoManager->action(this, ss);
2618
PLineJoin = newStyle;
2621
void PageItem::setCustomLineStyle(const QString& newStyle)
2623
if (NamedLStyle == newStyle)
2624
return; // nothing to do -> return
2625
if (UndoManager::undoEnabled())
2627
QString oldStyle = NamedLStyle.isEmpty() ? Um::NoStyle : NamedLStyle;
2628
QString nStyle = newStyle.isEmpty() ? Um::NoStyle : newStyle;
2629
QString action = newStyle.isEmpty() ? Um::NoLineStyle : Um::CustomLineStyle;
2630
SimpleState *ss = new SimpleState(action,
2631
QString(Um::FromTo).arg(oldStyle).arg(nStyle),Um::ILineStyle);
2632
ss->set("CUSTOM_LINE_STYLE", "customlinestyle");
2633
ss->set("OLD_STYLE", NamedLStyle);
2634
ss->set("NEW_STYLE", newStyle);
2635
undoManager->action(this, ss);
2637
NamedLStyle = newStyle;
2640
void PageItem::setStartArrowIndex(int newIndex)
2642
if (m_startArrowIndex == newIndex)
2643
return; // nothing to do -> return
2644
if (UndoManager::undoEnabled())
2646
SimpleState *ss = new SimpleState(Um::StartArrow,"",Um::IArrow);
2647
ss->set("START_ARROW", "startarrow");
2648
ss->set("OLD_INDEX", m_startArrowIndex);
2649
ss->set("NEW_INDEX", newIndex);
2650
undoManager->action(this, ss);
2652
m_startArrowIndex = newIndex;
2655
void PageItem::setEndArrowIndex(int newIndex)
2657
if (m_endArrowIndex == newIndex)
2658
return; // nothing to do -> return
2659
if (UndoManager::undoEnabled())
2661
SimpleState *ss = new SimpleState(Um::EndArrow,"",Um::IArrow);
2662
ss->set("END_ARROW", "endarrow");
2663
ss->set("OLD_INDEX", m_endArrowIndex);
2664
ss->set("NEW_INDEX", newIndex);
2665
undoManager->action(this, ss);
2667
m_endArrowIndex = newIndex;
2670
void PageItem::setImageFlippedH(bool flipped)
2672
if (flipped != m_ImageIsFlippedH)
2676
void PageItem::flipImageH()
2678
if (UndoManager::undoEnabled())
2680
SimpleState *ss = new SimpleState(Um::FlipH, 0, Um::IFlipH);
2681
ss->set("IMAGEFLIPH", "imagefliph");
2682
undoManager->action(this, ss);
2684
m_ImageIsFlippedH = !m_ImageIsFlippedH;
2685
emit frameFlippedH(m_ImageIsFlippedH);
2688
void PageItem::setImageFlippedV(bool flipped)
2690
if (flipped != m_ImageIsFlippedV)
2694
void PageItem::flipImageV()
2696
if (UndoManager::undoEnabled())
2698
SimpleState *ss = new SimpleState(Um::FlipV, 0, Um::IFlipV);
2699
ss->set("IMAGEFLIPV", "imageflipv");
2700
undoManager->action(this, ss);
2702
m_ImageIsFlippedV = !m_ImageIsFlippedV;
2703
emit frameFlippedV(m_ImageIsFlippedV);
2706
void PageItem::setImageScalingMode(bool freeScale, bool keepRatio)
2708
if (ScaleType == freeScale && AspectRatio == keepRatio)
2710
if (UndoManager::undoEnabled())
2712
QString from = ScaleType ? Um::FreeScaling : Um::FrameSize;
2714
from += AspectRatio ? Um::KeepRatio : Um::BreakRatio;
2715
QString to = freeScale ? Um::FreeScaling : Um::FrameSize;
2717
to += keepRatio ? Um::KeepRatio : Um::BreakRatio;
2718
SimpleState *ss = new SimpleState(Um::ImageScaling, QString(Um::FromTo).arg(from).arg(to), Um::IImageScaling);
2719
ss->set("SCALE_MODE", "scaling_mode");
2720
if (freeScale != ScaleType)
2722
ss->set("SCALE_TYPE", freeScale);
2725
//if switching from free scaling to frame size
2726
//in undo must be offset and scale saved
2727
ss->set("OLD_IMAGEXOFFSET", LocalX);
2728
ss->set("OLD_IMAGEYOFFSET", LocalY);
2729
ss->set("OLD_IMAGEXSCALE", LocalScX);
2730
ss->set("OLD_IMAGEYSCALE", LocalScY);
2733
if (keepRatio != AspectRatio)
2734
ss->set("ASPECT_RATIO", keepRatio);
2735
undoManager->action(this, ss);
2737
ScaleType = freeScale;
2738
AspectRatio = keepRatio;
2743
void PageItem::toggleLock()
2745
if (UndoManager::undoEnabled())
2749
ss = new SimpleState(Um::UnLock, 0, Um::IUnLock);
2751
ss = new SimpleState(Um::Lock, 0, Um::ILock);
2752
ss->set("LOCK", "lock");
2753
undoManager->action(this, ss);
2755
m_Locked = !m_Locked;
2756
emit frameLocked(m_Locked);
2759
void PageItem::setLocked(bool isLocked)
2761
if (isLocked != m_Locked)
2765
void PageItem::setGroupsLastItem(PageItem* item)
2767
if (UndoManager::undoEnabled())
2769
ItemState<std::pair<PageItem*, PageItem*> > *is = new ItemState<std::pair<PageItem*, PageItem*> >("GroupsLastItem");
2770
is->set("GROUPS_LASTITEM", "groups_lastitem");
2771
is->setItem(std::pair<PageItem*, PageItem*>(this->groupsLastItem, item));
2772
undoManager->action(this, is);
2774
groupsLastItem = item;
2777
void PageItem::toggleSizeLock()
2779
if (UndoManager::undoEnabled())
2783
ss = new SimpleState(Um::SizeUnLock, 0, Um::IUnLock);
2785
ss = new SimpleState(Um::SizeLock, 0, Um::ILock);
2786
ss->set("SIZE_LOCK", "size_lock");
2787
undoManager->action(this, ss);
2789
m_SizeLocked = !m_SizeLocked;
2790
emit frameSizeLocked(m_SizeLocked);
2793
void PageItem::setSizeLocked(bool isLocked)
2795
if (isLocked != m_SizeLocked)
2800
void PageItem::setPrintEnabled(bool toPrint)
2802
if (toPrint != m_PrintEnabled)
2803
togglePrintEnabled();
2806
void PageItem::togglePrintEnabled()
2808
if (UndoManager::undoEnabled())
2812
ss = new SimpleState(Um::DisablePrint, 0, Um::IDisablePrint);
2814
ss = new SimpleState(Um::EnablePrint, 0, Um::IEnablePrint);
2815
ss->set("PRINT_ENABLED", "print_enabled");
2816
undoManager->action(this, ss);
2818
m_PrintEnabled=!m_PrintEnabled;
2819
emit printEnabled(m_PrintEnabled);
2822
void PageItem::setTextFlowMode(TextFlowMode mode)
2824
if (textFlowModeVal == mode)
2826
if (UndoManager::undoEnabled())
2828
QString stateMessage;
2829
if( mode == TextFlowUsesFrameShape )
2830
stateMessage = Um::ObjectFrame;
2831
else if( mode == TextFlowUsesBoundingBox )
2832
stateMessage = Um::BoundingBox;
2833
else if( mode == TextFlowUsesContourLine )
2834
stateMessage = Um::ContourLine;
2835
else if( mode == TextFlowUsesImageClipping )
2836
stateMessage = Um::ImageClip;
2838
stateMessage = Um::NoTextFlow;
2839
SimpleState *ss = new SimpleState(stateMessage, "", Um::IFont);
2840
ss->set("TEXTFLOW_OLDMODE", (int) textFlowModeVal);
2841
ss->set("TEXTFLOW_NEWMODE", (int) mode);
2842
undoManager->action(this, ss);
2844
textFlowModeVal = mode;
2846
checkTextFlowInteractions();
2849
void PageItem::checkTextFlowInteractions(bool allItems)
2851
if(!m_Doc->isLoading())
2853
QRectF baseRect(getBoundingRect());
2854
QList<PageItem*>* items = OnMasterPage.isEmpty() ? &m_Doc->DocItems : &m_Doc->MasterItems;
2855
for(int idx = (allItems ? items->count()-1 : ItemNr-1); idx >= 0 ; --idx)
2857
if(idx != static_cast<int>(ItemNr)) // avoids itself
2859
if(items->at(idx)->asTextFrame()) // do not bother with no text frames
2861
QRectF uRect(items->at(idx)->getBoundingRect());
2862
if(baseRect.intersects(uRect))
2864
items->at(idx)->update();
2872
void PageItem::convertTo(ItemType newType)
2874
if (m_ItemType == newType)
2875
return; // nothing to do -> return
2876
assert(newType != 1); //DEBUG CR 2005-02-06
2877
assert(newType != 3); //DEBUG CR 2005-02-06
2878
QString fromType = "", toType = "";
2882
if (asLatexFrame()) {
2883
fromType = Um::LatexFrame;
2885
fromType = Um::ImageFrame;
2889
fromType = Um::TextFrame;
2892
fromType = Um::Polygon;
2901
toType = Um::ImageFrame;
2902
setUPixmap(Um::IImageFrame);
2905
toType = Um::LatexFrame;
2906
setUPixmap(Um::ILatexFrame);
2909
toType = Um::TextFrame;
2910
setUPixmap(Um::ITextFrame);
2913
toType = Um::Polygon;
2914
setUPixmap(Um::IPolygon);
2917
toType = Um::Polyline;
2918
setUPixmap(Um::IPolyline);
2926
if (UndoManager::undoEnabled())
2928
SimpleState *ss = new SimpleState(Um::ConvertTo + " " + toType,
2929
QString(Um::FromTo).arg(fromType).arg(toType));
2930
ss->set("CONVERT", "convert");
2931
ss->set("PAGEITEM", reinterpret_cast<int>(this));
2932
ss->set("OLD_TYPE", m_ItemType);
2933
ss->set("NEW_TYPE", newType);
2934
undoManager->action(this, ss);
2937
m_ItemType = newType;
2938
emit frameType(m_ItemType);
2941
void PageItem::setLayer(int layerId)
2943
if (LayerNr == layerId)
2945
if (UndoManager::undoEnabled())
2947
SimpleState *ss = new SimpleState(Um::SendToLayer,
2948
QString(Um::FromTo).arg(LayerNr).arg(layerId),
2950
ss->set("SEND_TO_LAYER", "send_to_layer");
2951
ss->set("OLD_LAYER", LayerNr);
2952
ss->set("NEW_LAYER", layerId);
2953
undoManager->action(this, ss);
2958
void PageItem::checkChanges(bool force)
2960
bool spreadChanges(false);
2961
// has the item been resized
2962
if (force || ((oldWidth != Width || oldHeight != Height) && shouldCheck()))
2965
spreadChanges = (textFlowMode() != TextFlowDisabled );
2967
// has the item been rotated
2968
if (force || ((oldRot != Rot) && (shouldCheck())))
2971
spreadChanges = (textFlowMode() != TextFlowDisabled );
2973
// has the item been moved
2974
if (force || ((oldXpos != Xpos || oldYpos != Ypos) && shouldCheck()))
2977
spreadChanges = (textFlowMode() != TextFlowDisabled );
2979
// has the item's image been moved
2980
if (force || ((oldLocalX != LocalX || oldLocalY != LocalY) && shouldCheck()))
2981
changeImageOffsetUndoAction();
2982
// has the item's image been scaled
2983
if (force || ((oldLocalScX != LocalScX || oldLocalScY != LocalScY) && shouldCheck()))
2984
changeImageScaleUndoAction();
2988
checkTextFlowInteractions();
2992
bool PageItem::shouldCheck()
2994
return ((!m_Doc->view()->mousePressed()) &&
2995
(!ScCore->primaryMainWindow()->arrowKeyDown()) &&
2996
(!ScCore->primaryMainWindow()->propertiesPalette->userActionOn()));
2999
void PageItem::moveUndoAction()
3001
if (oldXpos == Xpos && oldYpos == Ypos)
3003
if (UndoManager::undoEnabled())
3007
if (oldOwnPage == -1)
3008
oldp = Um::ScratchSpace;
3010
oldp = QString(Um::PageNmbr).arg(m_Doc->FirstPnum + oldOwnPage);
3012
newp = Um::ScratchSpace;
3014
newp = QString(Um::PageNmbr).arg(m_Doc->FirstPnum + OwnPage);
3015
SimpleState *ss = new SimpleState(Um::Move,
3016
QString(Um::MoveFromTo).arg(oldXpos).arg(oldYpos).arg(oldp).
3017
arg(Xpos).arg(Ypos).arg(newp), Um::IMove);
3018
ss->set("OLD_XPOS", oldXpos);
3019
ss->set("OLD_YPOS", oldYpos);
3020
ss->set("NEW_XPOS", Xpos);
3021
ss->set("NEW_YPOS", Ypos);
3022
undoManager->action(this, ss);
3026
oldOwnPage = OwnPage;
3029
void PageItem::resizeUndoAction()
3031
if (oldHeight == Height && oldWidth == Width)
3033
if (UndoManager::undoEnabled())
3035
SimpleState *ss = new SimpleState(Um::Resize,
3036
QString(Um::ResizeFromTo).arg(oldWidth).arg(oldHeight).arg(Width).arg(Height),
3038
ss->set("OLD_WIDTH", oldWidth);
3039
ss->set("OLD_HEIGHT", oldHeight);
3040
ss->set("NEW_WIDTH", Width);
3041
ss->set("NEW_HEIGHT", Height);
3042
ss->set("OLD_RXPOS", oldXpos);
3043
ss->set("OLD_RYPOS", oldYpos);
3044
ss->set("NEW_RXPOS", Xpos);
3045
ss->set("NEW_RYPOS", Ypos);
3046
ss->set("OLD_RROT", oldRot);
3047
ss->set("NEW_RROT", Rot);
3048
undoManager->action(this, ss);
3054
oldOwnPage = OwnPage;
3058
void PageItem::rotateUndoAction()
3062
if (UndoManager::undoEnabled())
3064
SimpleState *ss = new SimpleState(Um::Rotate,
3065
QString(Um::FromTo).arg(oldRot).arg(Rot),
3067
ss->set("OLD_ROT", oldRot);
3068
ss->set("NEW_ROT", Rot);
3069
ss->set("OLD_RXPOS", oldXpos);
3070
ss->set("OLD_RYPOS", oldYpos);
3071
ss->set("NEW_RXPOS", Xpos);
3072
ss->set("NEW_RYPOS", Ypos);
3073
ss->set("OLD_RWIDTH", oldWidth);
3074
ss->set("OLD_RHEIGHT", oldHeight);
3075
ss->set("NEW_RWIDTH", Width);
3076
ss->set("NEW_RHEIGHT", Height);
3077
undoManager->action(this, ss);
3082
oldOwnPage = OwnPage;
3087
void PageItem::changeImageOffsetUndoAction()
3089
if (oldLocalX == LocalX && oldLocalY == LocalY)
3091
if (UndoManager::undoEnabled())
3093
SimpleState *ss = new SimpleState(Um::ImageOffset,
3094
QString(Um::ImageOffsetFromTo).arg(oldLocalX).arg(oldLocalY).arg(LocalX).arg(LocalY), Um::IMove);
3095
ss->set("IMAGE_OFFSET", "image_offset");
3096
ss->set("OLD_IMAGEXOFFSET", oldLocalX);
3097
ss->set("OLD_IMAGEYOFFSET", oldLocalY);
3098
ss->set("NEW_IMAGEXOFFSET", LocalX);
3099
ss->set("NEW_IMAGEYOFFSET", LocalY);
3100
undoManager->action(this, ss);
3106
void PageItem::changeImageScaleUndoAction()
3108
//#9817: Hack for this rounding issue caused by conversion to text values. Undo needs fixing.
3109
if ((ScCLocale::toDoubleC(ScCLocale::toQStringC(oldLocalScX)) ==
3110
ScCLocale::toDoubleC(ScCLocale::toQStringC(LocalScX)))
3111
&& (ScCLocale::toDoubleC(ScCLocale::toQStringC(oldLocalScY)) ==
3112
ScCLocale::toDoubleC(ScCLocale::toQStringC(LocalScY))))
3114
if (UndoManager::undoEnabled())
3116
SimpleState *ss = new SimpleState(Um::ImageScale,
3117
QString(Um::ImageScaleFromTo).arg(oldLocalScX).arg(oldLocalScY).arg(LocalScX).arg(LocalScY), Um::IMove);
3118
ss->set("IMAGE_SCALE", "image_scale");
3119
ss->set("OLD_IMAGEXSCALE", oldLocalScX);
3120
ss->set("OLD_IMAGEYSCALE", oldLocalScY);
3121
ss->set("NEW_IMAGEXSCALE", LocalScX);
3122
ss->set("NEW_IMAGEYSCALE", LocalScY);
3123
undoManager->action(this, ss);
3125
oldLocalScX = LocalScX;
3126
oldLocalScY = LocalScY;
3129
void PageItem::restore(UndoState *state, bool isUndo)
3131
bool useRasterBackup = m_Doc->useRaster;
3132
bool SnapGuidesBackup = m_Doc->SnapGuides;
3133
m_Doc->useRaster = false;
3134
m_Doc->SnapGuides = false;
3135
SimpleState *ss = dynamic_cast<SimpleState*>(state);
3136
bool oldMPMode=m_Doc->masterPageMode();
3137
m_Doc->setMasterPageMode(!OnMasterPage.isEmpty());
3138
Page *oldCurrentPage = m_Doc->currentPage();
3139
if (!OnMasterPage.isEmpty())
3141
oldCurrentPage = m_Doc->currentPage();
3142
m_Doc->setCurrentPage(m_Doc->MasterPages.at(m_Doc->MasterNames[OnMasterPage]));
3146
if (ss->contains("OLD_XPOS"))
3147
restoreMove(ss, isUndo);
3148
else if (ss->contains("OLD_HEIGHT"))
3149
restoreResize(ss, isUndo);
3150
else if (ss->contains("OLD_ROT"))
3151
restoreRotate(ss, isUndo);
3152
else if (ss->contains("FILL"))
3153
restoreFill(ss, isUndo);
3154
else if (ss->contains("SHADE"))
3155
restoreShade(ss, isUndo);
3156
else if (ss->contains("LINE_COLOR"))
3157
restoreLineColor(ss, isUndo);
3158
else if (ss->contains("LINE_SHADE"))
3159
restoreLineShade(ss, isUndo);
3160
else if (ss->contains("IMAGEFLIPH"))
3163
m_Doc->itemSelection_FlipH();
3165
else if (ss->contains("IMAGEFLIPV"))
3168
m_Doc->itemSelection_FlipV();
3170
else if (ss->contains("LOCK"))
3173
m_Doc->itemSelection_ToggleLock();
3175
else if (ss->contains("SIZE_LOCK"))
3178
m_Doc->itemSelection_ToggleSizeLock();
3180
else if (ss->contains("PRINT_ENABLED"))
3183
m_Doc->itemSelection_TogglePrintEnabled();
3185
else if (ss->contains("NEW_NAME"))
3186
restoreName(ss, isUndo);
3187
else if (ss->contains("TRANSPARENCY"))
3188
restoreFillTP(ss, isUndo);
3189
else if (ss->contains("LINE_TRANSPARENCY"))
3190
restoreLineTP(ss, isUndo);
3191
else if (ss->contains("LINE_STYLE"))
3192
restoreLineStyle(ss, isUndo);
3193
else if (ss->contains("LINE_END"))
3194
restoreLineEnd(ss, isUndo);
3195
else if (ss->contains("LINE_JOIN"))
3196
restoreLineJoin(ss, isUndo);
3197
else if (ss->contains("LINE_WIDTH"))
3198
restoreLineWidth(ss, isUndo);
3199
else if (ss->contains("CUSTOM_LINE_STYLE"))
3200
restoreCustomLineStyle(ss, isUndo);
3201
else if (ss->contains("START_ARROW"))
3202
restoreArrow(ss, isUndo, true);
3203
else if (ss->contains("END_ARROW"))
3204
restoreArrow(ss, isUndo, false);
3205
else if (ss->contains("PSTYLE"))
3206
restorePStyle(ss, isUndo);
3207
else if (ss->contains("CONVERT"))
3208
restoreType(ss, isUndo);
3209
else if (ss->contains("TEXTFLOW_OLDMODE"))
3210
restoreTextFlowing(ss, isUndo);
3211
else if (ss->contains("SCALE_MODE"))
3212
restoreImageScaleMode(ss, isUndo);
3213
else if (ss->contains("IMAGE_SCALE"))
3214
restoreImageScaleChange(ss, isUndo);
3215
else if (ss->contains("IMAGE_OFFSET"))
3216
restoreImageOffsetChange(ss, isUndo);
3217
else if (ss->contains("EDIT_CONTOUR"))
3218
restorePoly(ss, isUndo, true);
3219
else if (ss->contains("EDIT_SHAPE"))
3220
restorePoly(ss, isUndo, false);
3221
else if (ss->contains("RESET_CONTOUR"))
3222
restoreContourLine(ss, isUndo);
3223
else if (ss->contains("CHANGE_SHAPE_TYPE"))
3224
restoreShapeType(ss, isUndo);
3225
else if (ss->contains("MIRROR_PATH_H"))
3227
bool editContour = m_Doc->nodeEdit.isContourLine;
3228
m_Doc->nodeEdit.isContourLine = ss->getBool("IS_CONTOUR");
3230
m_Doc->MirrorPolyH(m_Doc->m_Selection->itemAt(0));
3231
m_Doc->nodeEdit.isContourLine = editContour;
3233
else if (ss->contains("MIRROR_PATH_V"))
3235
bool editContour = m_Doc->nodeEdit.isContourLine;
3236
m_Doc->nodeEdit.isContourLine = ss->getBool("IS_CONTOUR");
3238
m_Doc->MirrorPolyV(m_Doc->m_Selection->itemAt(0));
3239
m_Doc->nodeEdit.isContourLine = editContour;
3241
else if (ss->contains("SEND_TO_LAYER"))
3242
restoreLayer(ss, isUndo);
3243
else if (ss->contains("GET_IMAGE"))
3244
restoreGetImage(ss, isUndo);
3245
else if (ss->contains("GROUPS_LASTITEM"))
3246
restoreGroupsLastItem(ss, isUndo);
3247
else if (ss->contains("EDIT_SHAPE_OR_CONTOUR"))
3248
restoreShapeContour(ss, isUndo);
3249
else if (ss->contains("APPLY_IMAGE_EFFECTS"))
3250
restoreImageEffects(ss, isUndo);
3251
else if (ss->contains("STEXT"))
3252
restoreEditText(ss, isUndo);
3253
else if (ss->contains("CLEAR_IMAGE"))
3254
restoreClearImage(ss,isUndo);
3255
else if (ss->contains("LINK_TEXT_FRAME"))
3256
restoreLinkTextFrame(ss,isUndo);
3257
else if (ss->contains("UNLINK_TEXT_FRAME"))
3258
restoreUnlinkTextFrame(ss,isUndo);
3260
if (!OnMasterPage.isEmpty())
3261
m_Doc->setCurrentPage(oldCurrentPage);
3262
m_Doc->setMasterPageMode(oldMPMode);
3263
m_Doc->useRaster = useRasterBackup;
3264
m_Doc->SnapGuides = SnapGuidesBackup;
3267
void PageItem::restoreMove(SimpleState *state, bool isUndo)
3269
double ox = state->getDouble("OLD_XPOS");
3270
double oy = state->getDouble("OLD_YPOS");
3271
double x = state->getDouble("NEW_XPOS");
3272
double y = state->getDouble("NEW_YPOS");
3280
m_Doc->MoveItem(mx, my, this, false);
3283
oldOwnPage = OwnPage;
3286
void PageItem::restoreResize(SimpleState *state, bool isUndo)
3288
double ow = state->getDouble("OLD_WIDTH");
3289
double oh = state->getDouble("OLD_HEIGHT");
3290
double w = state->getDouble("NEW_WIDTH");
3291
double h = state->getDouble("NEW_HEIGHT");
3292
double ox = state->getDouble("OLD_RXPOS");
3293
double oy = state->getDouble("OLD_RYPOS");
3294
double x = state->getDouble("NEW_RXPOS");
3295
double y = state->getDouble("NEW_RYPOS");
3296
double ort = state->getDouble("OLD_RROT");
3297
double rt = state->getDouble("NEW_RROT");
3300
int stateCode = state->transactionCode;
3301
bool redraw = ((stateCode != 1) && (stateCode != 3));
3304
m_Doc->SizeItem(ow, oh, this, false, true, redraw);
3305
m_Doc->MoveItem(mx, my, this, false);
3306
m_Doc->RotateItem(ort, this);
3312
m_Doc->SizeItem(w, h, this, false, true, redraw);
3313
m_Doc->MoveItem(mx, my, this, false);
3314
m_Doc->RotateItem(rt, this);
3320
oldOwnPage = OwnPage;
3324
void PageItem::restoreRotate(SimpleState *state, bool isUndo)
3326
double ort = state->getDouble("OLD_ROT");
3327
double rt = state->getDouble("NEW_ROT");
3328
double ox = state->getDouble("OLD_RXPOS");
3329
double oy = state->getDouble("OLD_RYPOS");
3330
double x = state->getDouble("NEW_RXPOS");
3331
double y = state->getDouble("NEW_RYPOS");
3332
double ow = state->getDouble("OLD_RWIDTH");
3333
double oh = state->getDouble("OLD_RHEIGHT");
3334
double w = state->getDouble("NEW_RWIDTH");
3335
double h = state->getDouble("NEW_RHEIGHT");
3336
int stateCode = state->transactionCode;
3337
bool redraw = ((stateCode != 1) && (stateCode != 3));;
3338
//CB Commented out test code
3339
//QRect oldR(getRedrawBounding(view->scale()));
3340
//double mx = ox - x;
3341
//double my = oy - y;
3349
m_Doc->RotateItem(ort, this);
3350
m_Doc->MoveItem(ox - Xpos, oy - Ypos, this, false);
3351
m_Doc->SizeItem(ow, oh, this, false, true, redraw);
3363
m_Doc->RotateItem(rt, this);
3364
m_Doc->MoveItem(x - Xpos, y - Ypos, this, false);
3365
m_Doc->SizeItem(w, h, this, false, true, redraw);
3368
m_Doc->setRedrawBounding(this);
3369
QRect newR(getRedrawBounding(view->scale()));
3370
view->updateContents(newR.unite(oldR));
3371
OwnPage = m_Doc->OnPage(this);
3376
oldOwnPage = OwnPage;
3381
void PageItem::restoreFill(SimpleState *state, bool isUndo)
3383
QString fill = state->get("OLD_FILL");
3385
fill = state->get("NEW_FILL");
3387
m_Doc->itemSelection_SetItemBrush(fill);
3390
void PageItem::restoreShade(SimpleState *state, bool isUndo)
3392
int shade = state->getInt("OLD_SHADE");
3394
shade = state->getInt("NEW_SHADE");
3396
m_Doc->itemSelection_SetItemBrushShade(shade);
3399
void PageItem::restoreLineColor(SimpleState *state, bool isUndo)
3401
QString fill = state->get("OLD_COLOR");
3403
fill = state->get("NEW_COLOR");
3405
m_Doc->itemSelection_SetItemPen(fill);
3408
void PageItem::restoreLineShade(SimpleState *state, bool isUndo)
3410
int shade = state->getInt("OLD_SHADE");
3412
shade = state->getInt("NEW_SHADE");
3414
m_Doc->itemSelection_SetItemPenShade(shade);
3417
void PageItem::restoreFillTP(SimpleState *state, bool isUndo)
3419
double tp = state->getDouble("OLD_TP");
3421
tp = state->getDouble("NEW_TP");
3423
m_Doc->itemSelection_SetItemFillTransparency(tp);
3426
void PageItem::restoreLineTP(SimpleState *state, bool isUndo)
3428
double tp = state->getDouble("OLD_TP");
3430
tp = state->getDouble("NEW_TP");
3432
m_Doc->itemSelection_SetItemLineTransparency(tp);
3436
void PageItem::restoreLineStyle(SimpleState *state, bool isUndo)
3438
Qt::PenStyle ps = static_cast<Qt::PenStyle>(state->getInt("OLD_STYLE"));
3440
ps = static_cast<Qt::PenStyle>(state->getInt("NEW_STYLE"));
3442
m_Doc->itemSelection_SetLineArt(ps);
3445
void PageItem::restoreLineEnd(SimpleState *state, bool isUndo)
3447
Qt::PenCapStyle pcs = static_cast<Qt::PenCapStyle>(state->getInt("OLD_STYLE"));
3449
pcs = static_cast<Qt::PenCapStyle>(state->getInt("NEW_STYLE"));
3451
m_Doc->itemSelection_SetLineEnd(pcs);
3454
void PageItem::restoreLineJoin(SimpleState *state, bool isUndo)
3456
Qt::PenJoinStyle pjs = static_cast<Qt::PenJoinStyle>(state->getInt("OLD_STYLE"));
3458
pjs = static_cast<Qt::PenJoinStyle>(state->getInt("NEW_STYLE"));
3460
m_Doc->itemSelection_SetLineJoin(pjs);
3463
void PageItem::restoreLineWidth(SimpleState *state, bool isUndo)
3465
double w = state->getDouble("OLD_WIDTH");
3467
w = state->getDouble("NEW_WIDTH");
3469
m_Doc->itemSelection_SetLineWidth(w);
3472
void PageItem::restoreCustomLineStyle(SimpleState *state, bool isUndo)
3474
QString style = state->get("OLD_STYLE");
3476
style = state->get("NEW_STYLE");
3477
setCustomLineStyle(style);
3480
void PageItem::restoreName(SimpleState *state, bool isUndo)
3482
QString name = state->get("OLD_NAME");
3484
name = state->get("NEW_NAME");
3488
void PageItem::restoreArrow(SimpleState *state, bool isUndo, bool isStart)
3490
int i = state->getInt("OLD_INDEX");
3492
i = state->getInt("NEW_INDEX");
3494
setStartArrowIndex(i);
3496
setEndArrowIndex(i);
3500
void PageItem::restorePStyle(SimpleState *state, bool isUndo)
3502
int styleid = state->getInt("OLD_STYLE");
3504
styleid = state->getInt("NEW_STYLE");
3505
//will be done later with other text-undo:
3506
// m_Doc->chAbStyle(this, styleid);
3510
// FIXME: This must go into class ScribusDoc!
3511
// For now we'll just make it independent of 'this' -- AV
3512
void PageItem::restoreType(SimpleState *state, bool isUndo)
3514
// well, probably not the best way to handle pointers...
3515
PageItem * item = reinterpret_cast<PageItem *>(state->getInt("PAGEITEM"));
3516
int type = state->getInt("OLD_TYPE");
3518
type = state->getInt("NEW_TYPE");
3519
ScribusView* view = m_Doc->view();
3520
view->Deselect(false);
3521
view->SelectItem(item, false);
3523
case ImageFrame: view->ToPicFrame(); break;
3524
case TextFrame: view->ToTextFrame(); break;
3525
case Polygon: view->ToPolyFrame(); break;
3526
case PolyLine: view->ToBezierFrame(); break;
3528
view->requestMode(modeNormal);
3531
void PageItem::restoreTextFlowing(SimpleState *state, bool isUndo)
3533
TextFlowMode oldMode = (TextFlowMode) state->getInt("TEXTFLOW_OLDMODE");
3534
TextFlowMode newMode = (TextFlowMode) state->getInt("TEXTFLOW_NEWMODE");
3536
textFlowModeVal = oldMode;
3538
textFlowModeVal = newMode;
3540
QList<PageItem*> pList;
3541
for(int idx = ItemNr-1; idx >= 0 ; --idx)
3543
pList << m_Doc->Items->at(idx);
3546
QRectF baseRect(getBoundingRect());
3547
for(int idx(0); idx < pList.count(); ++idx)
3549
QRectF uRect(pList.at(idx)->getBoundingRect());
3550
if(baseRect.intersects(uRect))
3551
pList.at(idx)->update();
3555
void PageItem::restoreImageScaleMode(SimpleState *state, bool isUndo)
3557
bool type=ScaleType;
3558
if (state->contains("SCALE_TYPE"))
3561
type = !state->getBool("SCALE_TYPE");
3563
type = state->getBool("SCALE_TYPE");
3564
//if restoring free scaling
3565
//old offset and scale ratio must be restored
3568
double oscx = state->getDouble("OLD_IMAGEXSCALE");
3569
double oscy = state->getDouble("OLD_IMAGEYSCALE");
3570
double ox = state->getDouble("OLD_IMAGEXOFFSET");
3571
double oy = state->getDouble("OLD_IMAGEYOFFSET");
3572
Selection tempSelection(this, false);
3573
tempSelection.addItem(this, true);
3574
m_Doc->itemSelection_SetImageScale(oscx, oscy, &tempSelection);
3575
m_Doc->itemSelection_SetImageOffset(ox, oy, &tempSelection);
3580
bool ratio=AspectRatio;
3581
if (state->contains("ASPECT_RATIO"))
3584
ratio = !state->getBool("ASPECT_RATIO");
3586
ratio = state->getBool("ASPECT_RATIO");
3589
setImageScalingMode(type, ratio);
3592
void PageItem::restoreImageScaleChange(SimpleState *state, bool isUndo)
3594
double oscx = state->getDouble("OLD_IMAGEXSCALE");
3595
double oscy = state->getDouble("OLD_IMAGEYSCALE");
3596
double scx = state->getDouble("NEW_IMAGEXSCALE");
3597
double scy = state->getDouble("NEW_IMAGEYSCALE");
3598
Selection tempSelection(this, false);
3599
tempSelection.addItem(this, true);
3601
m_Doc->itemSelection_SetImageScale(scx, scy, &tempSelection);
3603
m_Doc->itemSelection_SetImageScale(oscx, oscy, &tempSelection);
3606
void PageItem::restoreImageOffsetChange(SimpleState *state, bool isUndo)
3608
double ox = state->getDouble("OLD_IMAGEXOFFSET");
3609
double oy = state->getDouble("OLD_IMAGEYOFFSET");
3610
double x = state->getDouble("NEW_IMAGEXOFFSET");
3611
double y = state->getDouble("NEW_IMAGEYOFFSET");
3612
Selection tempSelection(this, false);
3613
tempSelection.addItem(this, true);
3615
m_Doc->itemSelection_SetImageOffset(x, y, &tempSelection);
3617
m_Doc->itemSelection_SetImageOffset(ox, oy, &tempSelection);
3620
void PageItem::restoreClearImage(UndoState *state, bool isUndo)
3622
if (!isImageFrame())
3626
ItemState<ScImageEffectList> *is = dynamic_cast<ItemState<ScImageEffectList>*>(state);
3627
Pfile = is->get("CI_PFILE");
3628
loadImage(Pfile, false);
3629
effectsInUse = is->getItem();
3630
setImageFlippedH(is->getBool("CI_FLIPPH"));
3631
setImageFlippedV(is->getBool("CI_FLIPPV"));
3632
setImageScalingMode(is->getBool("CI_SCALING"),is->getBool("CI_ASPECT"));
3633
setImageXYOffset(is->getDouble("CI_XOFF"), is->getDouble("CI_YOFF"));
3634
setImageXYScale(is->getDouble("CI_XSCALE"), is->getDouble("CI_YSCALE"));
3635
setFillTransparency(is->getDouble("CI_FILLT"));
3636
setLineTransparency(is->getDouble("CI_LINET"));
3641
asImageFrame()->clearContents();
3644
void PageItem::restoreLinkTextFrame(UndoState *state, bool isUndo)
3654
ItemState<std::pair<PageItem*, PageItem*> > *is = dynamic_cast<ItemState<std::pair<PageItem*, PageItem*> >*>(state);
3655
asTextFrame()->link(is->getItem().second->asTextFrame());
3659
void PageItem::restoreUnlinkTextFrame(UndoState *state, bool isUndo)
3665
ItemState<std::pair<PageItem*, PageItem*> > *is = dynamic_cast<ItemState<std::pair<PageItem*, PageItem*> >*>(state);
3666
asTextFrame()->link(is->getItem().second->asTextFrame());
3675
void PageItem::restorePoly(SimpleState *state, bool isUndo, bool isContour)
3677
int mode = state->getInt("MODE");
3678
int rot = state->getInt("ROT");
3679
ScribusView* view = m_Doc->view();
3680
double scaling = state->getDouble("SCALING");
3681
bool editContour = m_Doc->nodeEdit.isContourLine;
3682
m_Doc->nodeEdit.isContourLine = isContour;
3686
if (mode % 2 != 0 && mode != 0)
3691
scaling = (1.0 - (100.0 / (100.0 + scaling))) * 100.0;
3693
scaling = ((100.0 / (100.0 - scaling)) - 1.0) * 100.0;
3695
view->TransformPoly(mode, rot, scaling);
3696
m_Doc->nodeEdit.isContourLine = editContour;
3699
void PageItem::restoreContourLine(SimpleState *state, bool isUndo)
3701
ItemState<FPointArray> *is = dynamic_cast<ItemState<FPointArray>*>(state);
3705
ContourLine = is->getItem();
3707
ContourLine = PoLine.copy();
3712
void PageItem::restoreShapeType(SimpleState *state, bool isUndo)
3714
// Store shape info in this form:
3715
// CHANGE_SHAPE_TYPE - ID of the undo operation
3716
// OLD_FRAME_TYPE - original frame type
3717
// NEW_FRAME_TYPE - change of frame type
3718
// binary QPair<FPointArray, FPointArray> - .first original shape, .second new shape
3719
ItemState<QPair<FPointArray,FPointArray> > *is = dynamic_cast<ItemState<QPair<FPointArray,FPointArray> >*>(state);
3724
this->FrameType = is->getInt("OLD_FRAME_TYPE");
3725
this->PoLine = is->getItem().first;
3729
this->FrameType = is->getInt("NEW_FRAME_TYPE");
3730
this->PoLine = is->getItem().second;
3736
void PageItem::restoreLayer(SimpleState *state, bool isUndo)
3738
ScribusView* view = m_Doc->view();
3739
setLayer(isUndo ? state->getInt("OLD_LAYER") : state->getInt("NEW_LAYER"));
3740
view->Deselect(true);
3741
m_Doc->regionsChanged()->update(QRectF());
3744
void PageItem::restoreGetImage(UndoState *state, bool isUndo)
3746
ItemState<ScImageEffectList> *is = dynamic_cast<ItemState<ScImageEffectList>*>(state);
3747
QString fn = is->get("OLD_IMAGE_PATH");
3749
fn = is->get("NEW_IMAGE_PATH");
3752
Selection tempSelection(this, false);
3753
tempSelection.addItem(this, true);
3754
m_Doc->itemSelection_ClearItem(&tempSelection);
3758
loadImage(fn, false);
3761
//restore old image settings
3762
effectsInUse = is->getItem();
3763
setImageFlippedH(is->getBool("FLIPPH"));
3764
setImageFlippedV(is->getBool("FLIPPV"));
3765
setImageScalingMode(is->getBool("SCALING"), is->getBool("ASPECT"));
3766
setImageXYOffset(is->getDouble("XOFF"), is->getDouble("YOFF"));
3767
setImageXYScale(is->getDouble("XSCALE"), is->getDouble("YSCALE"));
3768
setFillTransparency(is->getDouble("FILLT"));
3769
setLineTransparency(is->getDouble("LINET"));
3776
void PageItem::restoreGroupsLastItem(SimpleState *state, bool isUndo)
3778
ItemState<std::pair<PageItem*, PageItem*> > *is = dynamic_cast<ItemState<std::pair<PageItem*, PageItem*> > *>(state);
3782
this->groupsLastItem = is->getItem().first;
3784
this->groupsLastItem = is->getItem().second;
3788
void PageItem::restoreShapeContour(UndoState *state, bool isUndo)
3790
ItemState<QPair<FPointArray,FPointArray> > *istate =
3791
dynamic_cast<ItemState<QPair<FPointArray,FPointArray> >*>(state);
3794
FPointArray oldClip = istate->getItem().first;
3795
FPointArray newClip = istate->getItem().second;
3796
bool isContour = istate->getBool("IS_CONTOUR");
3797
double oldX = istate->getDouble("OLD_X");
3798
double oldY = istate->getDouble("OLD_Y");
3799
double newX = istate->getDouble("NEW_X");
3800
double newY = istate->getDouble("NEW_Y");
3801
double mx = oldX - newX;
3802
double my = oldY - newY;
3807
ContourLine = oldClip;
3816
ContourLine = newClip;
3820
m_Doc->AdjustItemSize(this);
3821
m_Doc->MoveItem(mx, my, this, false);
3822
m_Doc->regionsChanged()->update(QRectF());
3827
void PageItem::restoreImageEffects(UndoState *state, bool isUndo)
3829
ItemState<QPair<ScImageEffectList, ScImageEffectList> > *istate =
3830
dynamic_cast<ItemState<QPair<ScImageEffectList,ScImageEffectList> >*>(state);
3834
effectsInUse = istate->getItem().first;
3836
effectsInUse = istate->getItem().second;
3843
void PageItem::restoreEditText(SimpleState *state, bool isUndo)
3847
itemText.deselectAll();
3849
EditAct action = (EditAct) state->getInt("STEXT");
3850
if (action == PARAMFULL || action == PARAMSEL)
3854
buffer.append(state->get("STEXT_OLD"));
3856
buffer.append(state->get("STEXT_NEW"));
3857
if (!buffer.isEmpty())
3859
Serializer dig(*m_Doc);
3860
dig.store<ScribusDoc>("<scribusdoc>", m_Doc);
3861
StoryText::desaxeRules("/", dig, "SCRIBUSTEXT");
3862
dig.addRule("/SCRIBUSTEXT", desaxe::Result<StoryText>());
3863
dig.parseMemory(buffer.toStdString().c_str(), buffer.length());
3864
StoryText* story = dig.result<StoryText>();
3865
if (action == PARAMFULL)
3867
itemText.selectAll();
3869
itemText.append(*story);
3871
else if (action == PARAMSEL)
3873
itemText.deselectAll();
3874
int SelStart = state->getInt("STEXT_SELSTART");
3875
itemText.select(SelStart,state->getInt("STEXT_SELLEN"));
3876
asTextFrame()->deleteSelectedTextFromFrame();
3877
int ItemLength = itemText.length();
3878
itemText.insert(SelStart, *story);
3879
// If we have inserted at end of text we have to restore trailing style
3880
if (ItemLength == SelStart && story->length() > 0 && story->text(-1) != SpecialChars::PARSEP)
3882
itemText.setStyle(-1, story->paragraphStyle(story->length()));
3884
itemText.select(SelStart, story->length());
3887
CPos = itemText.endOfSelection();
3890
else { qDebug() << "UNDO buffer EMPTY";}
3892
else if (action == REPSAX)
3894
QString buffout, buffin; //buffout is deleted, buffin is inserted
3895
int pos = state->getInt("STEXT_CPOS");
3898
buffin.append(state->get("STEXT_OLD"));
3899
buffout.append(state->get("STEXT_NEW"));
3903
buffin.append(state->get("STEXT_NEW"));
3904
buffout.append(state->get("STEXT_OLD"));
3907
Serializer dig(*m_Doc);
3908
dig.store<ScribusDoc>("<scribusdoc>", m_Doc);
3909
StoryText::desaxeRules("/", dig, "SCRIBUSTEXT");
3910
dig.addRule("/SCRIBUSTEXT", desaxe::Result<StoryText>());
3911
dig.parseMemory(buffout.toStdString().c_str(), buffout.length());
3912
StoryText* story = dig.result<StoryText>();
3913
itemText.select(pos,story->length());
3914
asTextFrame()->deleteSelectedTextFromFrame();
3916
Serializer dig2(*m_Doc);
3917
dig2.store<ScribusDoc>("<scribusdoc>", m_Doc);
3918
StoryText::desaxeRules("/", dig2, "SCRIBUSTEXT");
3919
dig2.addRule("/SCRIBUSTEXT", desaxe::Result<StoryText>());
3920
dig2.parseMemory(buffin.toStdString().c_str(), buffin.length());
3921
story = dig2.result<StoryText>();
3922
itemText.insert(pos,*story);
3923
itemText.select(pos, story->length());
3925
CPos = pos + story->length();
3928
else if (action == INSSAX || action == DELSAX)
3930
QString str = state->get("STEXT_STR");
3932
str = itemTextSaxed;
3933
int pos = state->getInt("STEXT_CPOS");
3934
Serializer dig(*m_Doc);
3935
dig.store<ScribusDoc>("<scribusdoc>", m_Doc);
3936
StoryText::desaxeRules("/", dig, "SCRIBUSTEXT");
3937
dig.addRule("/SCRIBUSTEXT", desaxe::Result<StoryText>());
3938
dig.parseMemory(str.toStdString().c_str(), str.length());
3939
StoryText* story = dig.result<StoryText>();
3940
if ((action == INSSAX && isUndo) || (action == DELSAX && !isUndo))
3942
//undo for INSSAX, redo for DELSAX
3943
itemText.select(pos, story->length());
3944
asTextFrame()->deleteSelectedTextFromFrame();
3948
//undo for DELSAX, redo for INSSAX
3949
itemText.insert(pos, *story);
3950
CPos = pos + story->length();
3954
else if (action == INS)
3956
QString str = state->get("STEXT_STR");
3957
int pos = state->getInt("STEXT_CPOS");
3960
itemText.select(pos, str.length());
3961
asTextFrame()->deleteSelectedTextFromFrame();
3965
itemText.insertChars(pos, str, true);
3966
CPos = pos + str.length();
3969
// after Undo or Redo new actions should create new undoStates
3970
asTextFrame()->lastUndoAction = NOACTION;
3972
m_Doc->scMW()->setTBvals(this);
3976
QString PageItem::getItemTextSaxed(EditActPlace undoItem)
3978
if (!isTextFrame()) return "";
3979
StoryText iT(m_Doc);
3980
iT.setDefaultStyle(itemText.defaultStyle());
3981
if (undoItem == FRAME)
3982
iT.insert(0, itemText);
3985
int StartOldSel = -1, LenOldSel = -1;
3986
if (undoItem == PARAGRAPH)
3991
StartOldSel = itemText.startOfSelection();
3992
LenOldSel = itemText.lengthOfSelection();
3994
asTextFrame()->expandParaSelection(true);
3996
else if (undoItem == CHAR || (undoItem == SELECTION && !HasSel))
3998
LenOldSel = itemText.lengthOfSelection();
4000
StartOldSel = itemText.startOfSelection();
4001
if (CPos >= itemText.length())
4003
itemText.select(CPos,1);
4007
iT.insert(0, itemText, HasSel);
4008
if (LenOldSel > 0) //restoring old selection if undoItem was PARAPGRAPH
4010
itemText.select(StartOldSel, LenOldSel);
4013
else if (LenOldSel == 0)
4015
itemText.deselectAll();
4020
std::ostringstream xmlString;
4021
SaxXML xmlStream(xmlString);
4022
xmlStream.beginDoc();
4023
iT.saxx(xmlStream, "SCRIBUSTEXT");
4025
std::string xml(xmlString.str());
4026
return QString(xml.c_str());
4029
QString PageItem::getItemTextSaxed(int selStart, int selLength)
4031
if (selStart < 0 || selLength < 0)
4034
StoryText it(m_Doc);
4035
it.setDefaultStyle(itemText.defaultStyle());
4037
int oldSelStart = -1, oldSelLength = -1;
4038
oldSelStart = itemText.startOfSelection();
4039
oldSelLength = itemText.lengthOfSelection();
4041
itemText.select(selStart, selLength);
4042
it.insert(0, itemText, (selLength > 0));
4044
if (oldSelLength > 0) //restoring old selection if undoItem was PARAPGRAPH
4046
itemText.select(oldSelStart, oldSelLength);
4049
else if (oldSelLength == 0)
4051
itemText.deselectAll();
4056
std::ostringstream xmlString;
4057
SaxXML xmlStream(xmlString);
4058
xmlStream.beginDoc();
4059
it.saxx(xmlStream, "SCRIBUSTEXT");
4061
std::string xml(xmlString.str());
4062
return QString(xml.c_str());
4065
QString PageItem::getTextSaxed(QString str)
4067
StoryText iT(m_Doc);
4068
iT.setDefaultStyle(itemText.defaultStyle());
4069
iT.insertChars(0,str,true);
4070
std::ostringstream xmlString;
4071
SaxXML xmlStream(xmlString);
4072
xmlStream.beginDoc();
4073
iT.saxx(xmlStream, "SCRIBUSTEXT");
4075
std::string xml(xmlString.str());
4076
return QString(xml.c_str());
4079
void PageItem::select()
4081
if (m_Doc->m_Selection->count() == 1 && m_Doc->m_Selection->itemAt()->isTextFrame())
4082
m_Doc->m_Selection->itemAt()->asTextFrame()->lastUndoAction = PageItem::NOACTION;
4083
m_Doc->view()->Deselect(false);
4084
//CB #2969 add this true parm to addItem so we dont connectToGUI, the rest of view->SelectItem isnt needed anyway
4085
m_Doc->m_Selection->addItem(this, true);
4088
ObjAttrVector* PageItem::getObjectAttributes()
4090
return &pageItemAttributes;
4093
ObjectAttribute PageItem::getObjectAttribute(QString attributeName) const
4096
ObjAttrVector::const_iterator foundIt = pageItemAttributes.begin();
4097
for(ObjAttrVector::const_iterator objAttrIt = pageItemAttributes.begin() ; objAttrIt != pageItemAttributes.end(); ++objAttrIt )
4099
if ((*objAttrIt).name==attributeName)
4105
ObjectAttribute returnAttribute;
4107
returnAttribute=(*foundIt);
4109
returnAttribute.name=QString::null;
4110
return returnAttribute;
4114
void PageItem::setObjectAttributes(ObjAttrVector* map)
4116
pageItemAttributes=*map;
4119
QString PageItem::generateUniqueCopyName(const QString originalName) const
4121
if (!m_Doc->itemNameExists(originalName))
4122
return originalName;
4124
// Start embellishing the name until we get an acceptable unique name
4125
// first we prefix `Copy of' if it's not already there
4126
QString newname(originalName);
4127
if (!originalName.startsWith( tr("Copy of")))
4128
newname.prepend( tr("Copy of")+" ");
4130
// See if the name prefixed by "Copy of " is free
4131
if (m_Doc->itemNameExists(newname))
4133
// Search the string for (number) at the end and capture
4134
// both the number and the text leading up to it sans brackets.
4136
// ^^^^^^^^^^^^ ^ (where ^ means captured)
4137
static QRegExp rx("^(.*)\\s+\\((\\d+)\\)$");
4138
int numMatches = rx.lastIndexIn(newname);
4139
// Add a (number) suffix to the end of the name. We start at the
4140
// old suffix's value if there was one, or at 2 if there was not.
4142
QString prefix(newname);
4143
if (numMatches != -1)
4145
// Already had a suffix; use the name w/o suffix for prefix and
4146
// grab the old suffix value as a starting point.
4147
QStringList matches = rx.capturedTexts();
4148
prefix = matches[1];
4149
suffixnum = matches[2].toInt();
4151
// Keep on incrementing the suffix 'till we find a free name
4154
newname = prefix + " (" + QString::number(suffixnum) + ")";
4157
while (m_Doc->itemNameExists(newname));
4159
// Unnecessary assert, previous code ensure condition is always true - JG
4160
// assert(!m_Doc->itemNameExists(newname));
4164
void PageItem::setTagged(bool tag)
4169
void PageItem::replaceNamedResources(ResourceCollection& newNames)
4171
QMap<QString,QString>::ConstIterator it;
4173
it = newNames.colors().find(fillColor());
4174
if (it != newNames.colors().end())
4177
it = newNames.colors().find(lineColor());
4178
if (it != newNames.colors().end())
4181
QList<VColorStop*> cstops = fill_gradient.colorStops();
4182
for (uint cst = 0; cst < fill_gradient.Stops(); ++cst)
4184
it = newNames.colors().find(cstops.at(cst)->name);
4185
if (it != newNames.colors().end())
4187
if (*it != CommonStrings::None)
4188
cstops.at(cst)->name = *it;
4191
if (effectsInUse.count() != 0)
4193
QString col1 = CommonStrings::None;
4194
QString col2 = CommonStrings::None;
4195
QString col3 = CommonStrings::None;
4196
QString col4 = CommonStrings::None;
4197
for (int a = 0; a < effectsInUse.count(); ++a)
4199
QString tmpstr = effectsInUse.at(a).effectParameters;
4200
QString tmpstr2 = "";
4201
ScTextStream fp(&tmpstr, QIODevice::ReadOnly);
4202
switch (effectsInUse.at(a).effectCode)
4204
case ScImage::EF_QUADTONE:
4205
col1 = fp.readLine();
4206
col2 = fp.readLine();
4207
col3 = fp.readLine();
4208
col4 = fp.readLine();
4209
it = newNames.colors().find(col1);
4210
if (it != newNames.colors().end())
4212
if (*it != CommonStrings::None)
4213
tmpstr2 += *it + "\n";
4215
tmpstr2 += col1 + "\n";
4218
tmpstr2 += col1 + "\n";
4219
it = newNames.colors().find(col2);
4220
if (it != newNames.colors().end())
4222
if (*it != CommonStrings::None)
4223
tmpstr2 += *it + "\n";
4225
tmpstr2 += col2 + "\n";
4228
tmpstr2 += col2 + "\n";
4229
it = newNames.colors().find(col3);
4230
if (it != newNames.colors().end())
4232
if (*it != CommonStrings::None)
4233
tmpstr2 += *it + "\n";
4235
tmpstr2 += col3 + "\n";
4238
tmpstr2 += col3 + "\n";
4239
it = newNames.colors().find(col4);
4240
if (it != newNames.colors().end())
4242
if (*it != CommonStrings::None)
4243
tmpstr2 += *it + "\n";
4245
tmpstr2 += col4 + "\n";
4248
tmpstr2 += col4 + "\n";
4249
tmpstr2 += fp.readAll();
4251
case ScImage::EF_TRITONE:
4252
col1 = fp.readLine();
4253
col2 = fp.readLine();
4254
col3 = fp.readLine();
4255
it = newNames.colors().find(col1);
4256
if (it != newNames.colors().end())
4258
if (*it != CommonStrings::None)
4259
tmpstr2 += *it + "\n";
4261
tmpstr2 += col1 + "\n";
4264
tmpstr2 += col1 + "\n";
4265
it = newNames.colors().find(col2);
4266
if (it != newNames.colors().end())
4268
if (*it != CommonStrings::None)
4269
tmpstr2 += *it + "\n";
4271
tmpstr2 += col2 + "\n";
4274
tmpstr2 += col2 + "\n";
4275
it = newNames.colors().find(col3);
4276
if (it != newNames.colors().end())
4278
if (*it != CommonStrings::None)
4279
tmpstr2 += *it + "\n";
4281
tmpstr2 += col3 + "\n";
4284
tmpstr2 += col3 + "\n";
4285
tmpstr2 += fp.readAll();
4287
case ScImage::EF_DUOTONE:
4288
col1 = fp.readLine();
4289
col2 = fp.readLine();
4290
it = newNames.colors().find(col1);
4291
if (it != newNames.colors().end())
4293
if (*it != CommonStrings::None)
4294
tmpstr2 += *it + "\n";
4296
tmpstr2 += col1 + "\n";
4299
tmpstr2 += col1 + "\n";
4300
it = newNames.colors().find(col2);
4301
if (it != newNames.colors().end())
4303
if (*it != CommonStrings::None)
4304
tmpstr2 += *it + "\n";
4306
tmpstr2 += col2 + "\n";
4309
tmpstr2 += col2 + "\n";
4310
tmpstr2 += fp.readAll();
4312
case ScImage::EF_COLORIZE:
4313
col1 = fp.readLine();
4314
it = newNames.colors().find(col1);
4315
if (it != newNames.colors().end())
4317
if (*it != CommonStrings::None)
4318
tmpstr2 += *it + "\n" + fp.readAll();
4320
tmpstr2 += col1 + "\n" + fp.readAll();
4323
tmpstr2 += col1 + "\n" + fp.readAll();
4329
effectsInUse[a].effectParameters = tmpstr2;
4333
it = newNames.patterns().find(pattern());
4334
if (it != newNames.patterns().end())
4337
it = newNames.lineStyles().find(customLineStyle());
4338
if (it != newNames.lineStyles().end())
4339
setCustomLineStyle(*it);
4341
if (prevInChain() == NULL)
4342
itemText.replaceNamedResources(newNames);
4346
void PageItem::getNamedResources(ResourceCollection& lists) const
4348
lists.collectColor(lineColor());
4350
lists.collectColor(fillColor());
4351
else if (GrType < 8)
4353
QList<VColorStop*> cstops = fill_gradient.colorStops();
4354
for (uint cst = 0; cst < fill_gradient.Stops(); ++cst)
4356
lists.collectColor(cstops.at(cst)->name);
4359
if (effectsInUse.count() != 0)
4361
for (int a = 0; a < effectsInUse.count(); ++a)
4363
QString tmpstr = effectsInUse.at(a).effectParameters;
4364
ScTextStream fp(&tmpstr, QIODevice::ReadOnly);
4365
switch (effectsInUse.at(a).effectCode)
4367
case ScImage::EF_QUADTONE:
4368
lists.collectColor(fp.readLine());
4369
case ScImage::EF_TRITONE:
4370
lists.collectColor(fp.readLine());
4371
case ScImage::EF_DUOTONE:
4372
lists.collectColor(fp.readLine());
4373
case ScImage::EF_COLORIZE:
4374
lists.collectColor(fp.readLine());
4381
lists.collectPattern(pattern());
4382
lists.collectLineStyle(customLineStyle());
4383
if (prevInChain() == NULL)
4384
itemText.getNamedResources(lists);
4387
void PageItem::copyToCopyPasteBuffer(struct CopyPasteBuffer *Buffer)
4389
Buffer->PType = realItemType();
4390
Buffer->Xpos = Xpos;
4391
Buffer->Ypos = Ypos;
4392
Buffer->Width = Width;
4393
Buffer->Height = Height;
4394
Buffer->RadRect = RadRect;
4395
Buffer->FrameType = FrameType;
4396
Buffer->ClipEdited = ClipEdited;
4397
Buffer->Pwidth = m_lineWidth;
4398
Buffer->Pcolor = fillColor();
4399
Buffer->Pcolor2 = lineColor();
4400
Buffer->Shade = fillShade();
4401
Buffer->Shade2 = lineShade();
4402
Buffer->FillRule = fillRule;
4403
Buffer->GrColor = "";
4404
Buffer->GrColor2 = "";
4405
Buffer->GrShade = 100;
4406
Buffer->GrShade2 = 100;
4407
Buffer->fill_gradient = fill_gradient;
4408
Buffer->GrType = GrType;
4409
Buffer->GrStartX = GrStartX;
4410
Buffer->GrStartY = GrStartY;
4411
Buffer->GrEndX = GrEndX;
4412
Buffer->GrEndY = GrEndY;
4414
Buffer->PLineArt = PLineArt;
4415
Buffer->PLineEnd = PLineEnd;
4416
Buffer->PLineJoin = PLineJoin;
4417
Buffer->LocalScX = LocalScX;
4418
Buffer->LocalScY = LocalScY;
4419
Buffer->LocalX = LocalX;
4420
Buffer->LocalY = LocalY;
4421
Buffer->PicArt = PicArt;
4422
Buffer->flippedH = imageFlippedH();
4423
Buffer->flippedV = imageFlippedV();
4424
/* Buffer->BBoxX = BBoxX;
4425
Buffer->BBoxH = BBoxH; */
4426
Buffer->isPrintable = printEnabled();
4427
Buffer->isBookmark = isBookmark;
4428
// Buffer->BMnr = BMnr;
4429
Buffer->m_isAnnotation = m_isAnnotation;
4430
Buffer->m_annotation = m_annotation;
4431
Buffer->Extra = Extra;
4432
Buffer->TExtra = TExtra;
4433
Buffer->BExtra = BExtra;
4434
Buffer->RExtra = RExtra;
4435
Buffer->firstLineOffsetP = firstLineOffsetP;
4436
Buffer->Pfile = Pfile;
4437
Buffer->Pfile2 = Pfile2;
4438
Buffer->Pfile3 = Pfile3;
4440
uint itemTextCount=itemText.length();
4441
if (itemTextCount != 0)
4443
for (uint a=0; a<itemTextCount; ++a)
4445
if( (itemText.text(a) == '\n') || (itemText.text(a) == '\r'))
4446
Text += QString(QChar(5))+"\t";
4447
else if(itemText.text(a) == '\t')
4448
Text += QString(QChar(4))+"\t";
4450
Text += itemText.text(a,1)+"\t";
4451
Text += itemText.charStyle(a).font().scName()+"\t";
4452
Text += QString::number(itemText.charStyle(a).fontSize() / 10.0)+"\t";
4453
Text += itemText.charStyle(a).fillColor()+"\t";
4454
Text += QString::number(itemText.charStyle(a).tracking())+"\t";
4455
Text += QString::number(itemText.charStyle(a).fillShade())+'\t';
4456
Text += QString::number(itemText.charStyle(a).effects())+'\t';
4457
Text += QString::number(findParagraphStyle(m_Doc, itemText.paragraphStyle(a)))+'\t';
4458
Text += itemText.charStyle(a).strokeColor()+"\t";
4459
Text += QString::number(itemText.charStyle(a).strokeShade())+'\t';
4460
Text += QString::number(itemText.charStyle(a).scaleH())+'\t';
4461
Text += QString::number(itemText.charStyle(a).scaleV())+'\t';
4462
Text += QString::number(itemText.charStyle(a).baselineOffset())+'\t';
4463
Text += QString::number(itemText.charStyle(a).shadowXOffset())+'\t';
4464
Text += QString::number(itemText.charStyle(a).shadowYOffset())+'\t';
4465
Text += QString::number(itemText.charStyle(a).outlineWidth())+'\t';
4466
Text += QString::number(itemText.charStyle(a).underlineOffset())+'\t';
4467
Text += QString::number(itemText.charStyle(a).underlineWidth())+'\t';
4468
Text += QString::number(itemText.charStyle(a).strikethruOffset())+'\t';
4469
Text += QString::number(itemText.charStyle(a).strikethruWidth())+'\n';
4472
if (asLatexFrame()) {
4473
Buffer->itemText = asLatexFrame()->formula();
4475
Buffer->itemText = Text;
4477
Buffer->Clip = Clip;
4478
Buffer->PoLine = PoLine.copy();
4479
Buffer->ContourLine = ContourLine.copy();
4480
//Buffer->UseContour = textFlowUsesContourLine();
4481
Buffer->DashValues = DashValues;
4482
Buffer->DashOffset = DashOffset;
4483
Buffer->PoShow = PoShow;
4484
Buffer->BaseOffs = BaseOffs;
4485
Buffer->textPathFlipped = textPathFlipped;
4486
Buffer->textPathType = textPathType;
4487
Buffer->TextflowMode = textFlowMode();
4488
Buffer->Groups = Groups;
4489
Buffer->IProfile = IProfile;
4490
Buffer->IRender = IRender;
4491
Buffer->UseEmbedded = UseEmbedded;
4492
Buffer->EmProfile = EmProfile;
4493
Buffer->LayerNr = LayerNr;
4494
Buffer->ScaleType = ScaleType;
4495
Buffer->AspectRatio = AspectRatio;
4496
Buffer->Locked = locked();
4497
Buffer->LockRes = sizeLocked();
4498
Buffer->Transparency = fillTransparency();
4499
Buffer->TranspStroke = lineTransparency();
4500
Buffer->TransBlend = fillBlendmode();
4501
Buffer->TransBlendS = lineBlendmode();
4502
Buffer->Reverse = Reverse;
4503
Buffer->NamedLStyle = NamedLStyle;
4504
Buffer->Cols = Cols;
4505
Buffer->ColGap = ColGap;
4506
Buffer->isTableItem = isTableItem;
4507
Buffer->TopLine = TopLine;
4508
Buffer->LeftLine = LeftLine;
4509
Buffer->RightLine = RightLine;
4510
Buffer->BottomLine = BottomLine;
4514
Buffer->TopLinkID = TopLink->ItemNr;
4516
Buffer->TopLinkID = -1;
4518
Buffer->LeftLinkID = LeftLink->ItemNr;
4520
Buffer->LeftLinkID = -1;
4522
Buffer->RightLinkID = RightLink->ItemNr;
4524
Buffer->RightLinkID = -1;
4525
if (BottomLink != 0)
4526
Buffer->BottomLinkID = BottomLink->ItemNr;
4528
Buffer->BottomLinkID = -1;
4530
Buffer->startArrowIndex = m_startArrowIndex;
4531
Buffer->endArrowIndex = m_endArrowIndex;
4536
void PageItem::SetFrameShape(int count, double *vals)
4539
for (int a = 0; a < count-3; a += 4)
4546
double x1 = Width * vals[a] / 100.0;
4547
double y1 = Height * vals[a+1] / 100.0;
4548
double x2 = Width * vals[a+2] / 100.0;
4549
double y2 = Height * vals[a+3] / 100.0;
4550
PoLine.addPoint(x1, y1);
4551
PoLine.addPoint(x2, y2);
4553
Clip = FlattenPath(PoLine, Segments);
4557
void PageItem::SetRectFrame()
4559
static double rect[] = { 0.0, 0.0, 0.0, 0.0,
4560
100.0, 0.0, 100.0, 0.0,
4561
100.0, 0.0, 100.0, 0.0,
4562
100.0, 100.0, 100.0, 100.0,
4563
100.0, 100.0, 100.0, 100.0,
4564
0.0, 100.0, 0.0, 100.0,
4565
0.0, 100.0, 0.0, 100.0,
4566
0.0, 0.0, 0.0, 0.0};
4567
SetFrameShape(32, rect);
4572
void PageItem::SetOvalFrame()
4574
static double rect[] = { 100.0, 50.0, 100.0, 77.615235,
4575
50.0, 100.0, 77.615235, 100.0,
4576
50.0, 100.0, 22.385765, 100.0,
4577
0.0, 50.0, 0.0, 77.615235,
4578
0.0, 50.0, 0.0, 22.385765,
4579
50.0, 0.0, 22.385765, 0.0,
4580
50.0, 0.0, 77.615235, 0.0,
4581
100.0, 50.0, 100.0, 22.385765};
4582
SetFrameShape(32, rect);
4587
void PageItem::SetFrameRound()
4589
setCornerRadius(qMin(RadRect, qMin(Width,Height)/2));
4591
double rr = fabs(RadRect);
4592
double bezierFactor=0.552284749; //Bezier Control Point Factor: 8/3*(sin(45)-0.5)
4593
double rrxBezierFactor=rr*bezierFactor;
4594
double Width_rr=Width-rr;
4595
double Height_rr=Height-rr;
4598
PoLine.addQuadPoint(rr, 0, rr, 0, Width_rr, 0, Width_rr, 0);
4599
PoLine.addQuadPoint(Width_rr, 0, Width_rr+rrxBezierFactor, 0, Width, rr, Width, rr-rrxBezierFactor);
4600
PoLine.addQuadPoint(Width, rr, Width, rr, Width, Height_rr, Width, Height_rr);
4601
PoLine.addQuadPoint(Width, Height_rr, Width, Height_rr+rrxBezierFactor, Width_rr, Height, Width_rr+rrxBezierFactor, Height);
4602
PoLine.addQuadPoint(Width_rr, Height, Width_rr, Height, rr, Height, rr, Height);
4603
PoLine.addQuadPoint(rr, Height, rr-rrxBezierFactor, Height, 0, Height_rr, 0, Height_rr+rrxBezierFactor);
4604
PoLine.addQuadPoint(0, Height_rr, 0, Height_rr, 0, rr, 0, rr);
4605
PoLine.addQuadPoint(0, rr, 0, rr-rrxBezierFactor, rr, 0, rr-rrxBezierFactor, 0);
4609
PoLine.addQuadPoint(rr, 0, rr, 0, Width_rr, 0, Width_rr, 0);
4610
PoLine.addQuadPoint(Width_rr, 0, Width_rr, rrxBezierFactor, Width, rr, Width-rrxBezierFactor, rr);
4611
PoLine.addQuadPoint(Width, rr, Width, rr, Width, Height_rr, Width, Height_rr);
4612
PoLine.addQuadPoint(Width, Height_rr, Width-rrxBezierFactor, Height_rr, Width_rr, Height, Width_rr, Height-rrxBezierFactor);
4613
PoLine.addQuadPoint(Width_rr, Height, Width_rr, Height, rr, Height, rr, Height);
4614
PoLine.addQuadPoint(rr, Height, rr, Height-rrxBezierFactor, 0, Height_rr, rrxBezierFactor, Height_rr);
4615
PoLine.addQuadPoint(0, Height_rr, 0, Height_rr, 0, rr, 0, rr);
4616
PoLine.addQuadPoint(0, rr, rrxBezierFactor, rr, rr, 0, rr, rr*bezierFactor);
4618
Clip = FlattenPath(PoLine, Segments);
4625
void PageItem::getTransform(QMatrix& mat) const
4627
mat.translate(Xpos, Ypos);
4631
QMatrix PageItem::getTransform() const
4634
getTransform(result);
4638
QRectF PageItem::getBoundingRect() const
4641
getBoundingRect(&x, &y, &x2, &y2);
4642
return QRectF(x,y,x2-x,y2-y);
4645
QRectF PageItem::getCurrentBoundingRect(double moreSpace) const
4647
double x = BoundingX - moreSpace / 2.0;
4648
double y = BoundingY - moreSpace / 2.0;
4649
double w = BoundingW + moreSpace;
4650
double h = BoundingH + moreSpace;
4651
QRectF ret = QRectF(x, y, w, h);
4655
QRectF PageItem::getVisualBoundingRect() const
4658
getVisualBoundingRect(&x, &y, &x2, &y2);
4659
return QRectF(x,y,x2-x,y2-y);
4662
void PageItem::getBoundingRect(double *x1, double *y1, double *x2, double *y2) const
4664
double minx = std::numeric_limits<double>::max();
4665
double miny = std::numeric_limits<double>::max();
4666
double maxx = -std::numeric_limits<double>::max();
4667
double maxy = -std::numeric_limits<double>::max();
4672
pb.addPoint(FPoint(Xpos, Ypos));
4673
pb.addPoint(FPoint(Width, 0.0, Xpos, Ypos, Rot, 1.0, 1.0));
4674
pb.addPoint(FPoint(Width, Height, Xpos, Ypos, Rot, 1.0, 1.0));
4675
pb.addPoint(FPoint( 0.0, Height, Xpos, Ypos, Rot, 1.0, 1.0));
4676
for (uint pc = 0; pc < 4; ++pc)
4678
minx = qMin(minx, pb.point(pc).x());
4679
miny = qMin(miny, pb.point(pc).y());
4680
maxx = qMax(maxx, pb.point(pc).x());
4681
maxy = qMax(maxy, pb.point(pc).y());
4692
*x2 = Xpos + qMax(Width, m_lineWidth);
4693
*y2 = Ypos + qMax(Height, m_lineWidth);
4695
QRectF totalRect = QRectF(QPointF(*x1, *y1), QPointF(*x2, *y2));
4696
if (m_startArrowIndex != 0)
4699
FPointArray arrow = m_Doc->arrowStyles.at(m_startArrowIndex-1).points.copy();
4700
arrowTrans.translate(Xpos, Ypos);
4701
arrowTrans.rotate(Rot);
4702
if (itemType() == Line)
4704
arrowTrans.translate(0, 0);
4705
if (NamedLStyle.isEmpty())
4707
if (m_lineWidth != 0.0)
4708
arrowTrans.scale(m_lineWidth, m_lineWidth);
4712
multiLine ml = m_Doc->MLineStyles[NamedLStyle];
4713
if (ml[ml.size()-1].Width != 0.0)
4714
arrowTrans.scale(ml[ml.size()-1].Width, ml[ml.size()-1].Width);
4716
arrowTrans.scale(-1,1);
4717
arrow.map(arrowTrans);
4721
FPoint Start = PoLine.point(0);
4722
for (uint xx = 1; xx < PoLine.size(); xx += 2)
4724
FPoint Vector = PoLine.point(xx);
4725
if ((Start.x() != Vector.x()) || (Start.y() != Vector.y()))
4727
arrowTrans.translate(Start.x(), Start.y());
4728
arrowTrans.rotate(atan2(Start.y()-Vector.y(),Start.x()-Vector.x())*(180.0/M_PI));
4729
if (NamedLStyle.isEmpty())
4731
if (m_lineWidth != 0.0)
4732
arrowTrans.scale(m_lineWidth, m_lineWidth);
4736
multiLine ml = m_Doc->MLineStyles[NamedLStyle];
4737
if (ml[ml.size()-1].Width != 0.0)
4738
arrowTrans.scale(ml[ml.size()-1].Width, ml[ml.size()-1].Width);
4740
arrow.map(arrowTrans);
4745
FPoint minAr = getMinClipF(&arrow);
4746
FPoint maxAr = getMaxClipF(&arrow);
4747
totalRect = totalRect.united(QRectF(QPointF(minAr.x(), minAr.y()), QPointF(maxAr.x(), maxAr.y())));
4749
if (m_endArrowIndex != 0)
4752
FPointArray arrow = m_Doc->arrowStyles.at(m_endArrowIndex-1).points.copy();
4753
arrowTrans.translate(Xpos, Ypos);
4754
arrowTrans.rotate(Rot);
4755
if (itemType() == Line)
4757
arrowTrans.translate(Width, 0);
4758
if (NamedLStyle.isEmpty())
4760
if (m_lineWidth != 0.0)
4761
arrowTrans.scale(m_lineWidth, m_lineWidth);
4765
multiLine ml = m_Doc->MLineStyles[NamedLStyle];
4766
if (ml[ml.size()-1].Width != 0.0)
4767
arrowTrans.scale(ml[ml.size()-1].Width, ml[ml.size()-1].Width);
4769
arrow.map(arrowTrans);
4773
FPoint End = PoLine.point(PoLine.size()-2);
4774
for (uint xx = PoLine.size()-1; xx > 0; xx -= 2)
4776
FPoint Vector = PoLine.point(xx);
4777
if ((End.x() != Vector.x()) || (End.y() != Vector.y()))
4779
arrowTrans.translate(End.x(), End.y());
4780
arrowTrans.rotate(atan2(End.y()-Vector.y(),End.x()-Vector.x())*(180.0/M_PI));
4781
if (NamedLStyle.isEmpty())
4783
if (m_lineWidth != 0.0)
4784
arrowTrans.scale(m_lineWidth, m_lineWidth);
4788
multiLine ml = m_Doc->MLineStyles[NamedLStyle];
4789
if (ml[ml.size()-1].Width != 0.0)
4790
arrowTrans.scale(ml[ml.size()-1].Width, ml[ml.size()-1].Width);
4792
arrow.map(arrowTrans);
4797
FPoint minAr = getMinClipF(&arrow);
4798
FPoint maxAr = getMaxClipF(&arrow);
4799
totalRect = totalRect.united(QRectF(QPointF(minAr.x(), minAr.y()), QPointF(maxAr.x(), maxAr.y())));
4801
totalRect.getCoords(x1, y1, x2, y2);
4804
void PageItem::getVisualBoundingRect(double * x1, double * y1, double * x2, double * y2) const
4806
double minx = std::numeric_limits<double>::max();
4807
double miny = std::numeric_limits<double>::max();
4808
double maxx = -std::numeric_limits<double>::max();
4809
double maxy = -std::numeric_limits<double>::max();
4810
double extraSpace = 0.0;
4811
if (NamedLStyle.isEmpty())
4813
if (lineColor() != CommonStrings::None)
4814
extraSpace = m_lineWidth / 2.0;
4818
multiLine ml = m_Doc->MLineStyles[NamedLStyle];
4819
struct SingleLine& sl = ml[ml.size()-1];
4820
if ((sl.Color != CommonStrings::None) && (sl.Width != 0))
4821
extraSpace = sl.Width / 2.0;
4827
pb.addPoint(FPoint(-extraSpace, -extraSpace, xPos(), yPos(), Rot, 1.0, 1.0));
4828
pb.addPoint(FPoint(visualWidth()-extraSpace, -extraSpace, xPos(), yPos(), Rot, 1.0, 1.0));
4829
pb.addPoint(FPoint(visualWidth()-extraSpace, visualHeight()-extraSpace, xPos(), yPos(), Rot, 1.0, 1.0));
4830
pb.addPoint(FPoint(-extraSpace, visualHeight()-extraSpace, xPos(), yPos(), Rot, 1.0, 1.0));
4831
for (uint pc = 0; pc < 4; ++pc)
4833
minx = qMin(minx, pb.point(pc).x());
4834
miny = qMin(miny, pb.point(pc).y());
4835
maxx = qMax(maxx, pb.point(pc).x());
4836
maxy = qMax(maxy, pb.point(pc).y());
4847
*x2 = *x1 + qMax(visualWidth(), extraSpace);
4848
*y2 = *y1 + qMax(visualHeight(), extraSpace);
4850
QRectF totalRect = QRectF(QPointF(*x1, *y1), QPointF(*x2, *y2));
4851
if (m_startArrowIndex != 0)
4854
FPointArray arrow = m_Doc->arrowStyles.at(m_startArrowIndex-1).points.copy();
4855
arrowTrans.translate(Xpos, Ypos);
4856
arrowTrans.rotate(Rot);
4857
if (itemType() == Line)
4859
arrowTrans.translate(0, 0);
4860
if (NamedLStyle.isEmpty())
4862
if (m_lineWidth != 0.0)
4863
arrowTrans.scale(m_lineWidth, m_lineWidth);
4867
multiLine ml = m_Doc->MLineStyles[NamedLStyle];
4868
if (ml[ml.size()-1].Width != 0.0)
4869
arrowTrans.scale(ml[ml.size()-1].Width, ml[ml.size()-1].Width);
4871
arrowTrans.scale(-1,1);
4872
arrow.map(arrowTrans);
4876
FPoint Start = PoLine.point(0);
4877
for (uint xx = 1; xx < PoLine.size(); xx += 2)
4879
FPoint Vector = PoLine.point(xx);
4880
if ((Start.x() != Vector.x()) || (Start.y() != Vector.y()))
4882
arrowTrans.translate(Start.x(), Start.y());
4883
arrowTrans.rotate(atan2(Start.y()-Vector.y(),Start.x()-Vector.x())*(180.0/M_PI));
4884
if (NamedLStyle.isEmpty())
4886
if (m_lineWidth != 0.0)
4887
arrowTrans.scale(m_lineWidth, m_lineWidth);
4891
multiLine ml = m_Doc->MLineStyles[NamedLStyle];
4892
if (ml[ml.size()-1].Width != 0.0)
4893
arrowTrans.scale(ml[ml.size()-1].Width, ml[ml.size()-1].Width);
4895
arrow.map(arrowTrans);
4900
FPoint minAr = getMinClipF(&arrow);
4901
FPoint maxAr = getMaxClipF(&arrow);
4902
totalRect = totalRect.united(QRectF(QPointF(minAr.x(), minAr.y()), QPointF(maxAr.x(), maxAr.y())));
4904
if (m_endArrowIndex != 0)
4907
FPointArray arrow = m_Doc->arrowStyles.at(m_endArrowIndex-1).points.copy();
4908
arrowTrans.translate(Xpos, Ypos);
4909
arrowTrans.rotate(Rot);
4910
if (itemType() == Line)
4912
arrowTrans.translate(Width, 0);
4913
if (NamedLStyle.isEmpty())
4915
if (m_lineWidth != 0.0)
4916
arrowTrans.scale(m_lineWidth, m_lineWidth);
4920
multiLine ml = m_Doc->MLineStyles[NamedLStyle];
4921
if (ml[ml.size()-1].Width != 0.0)
4922
arrowTrans.scale(ml[ml.size()-1].Width, ml[ml.size()-1].Width);
4924
arrow.map(arrowTrans);
4928
FPoint End = PoLine.point(PoLine.size()-2);
4929
for (uint xx = PoLine.size()-1; xx > 0; xx -= 2)
4931
FPoint Vector = PoLine.point(xx);
4932
if ((End.x() != Vector.x()) || (End.y() != Vector.y()))
4934
arrowTrans.translate(End.x(), End.y());
4935
arrowTrans.rotate(atan2(End.y()-Vector.y(),End.x()-Vector.x())*(180.0/M_PI));
4936
if (NamedLStyle.isEmpty())
4938
if (m_lineWidth != 0.0)
4939
arrowTrans.scale(m_lineWidth, m_lineWidth);
4943
multiLine ml = m_Doc->MLineStyles[NamedLStyle];
4944
if (ml[ml.size()-1].Width != 0.0)
4945
arrowTrans.scale(ml[ml.size()-1].Width, ml[ml.size()-1].Width);
4947
arrow.map(arrowTrans);
4952
FPoint minAr = getMinClipF(&arrow);
4953
FPoint maxAr = getMaxClipF(&arrow);
4954
totalRect = totalRect.united(QRectF(QPointF(minAr.x(), minAr.y()), QPointF(maxAr.x(), maxAr.y())));
4956
totalRect.getCoords(x1, y1, x2, y2);
4959
double PageItem::visualXPos() const
4961
double extraSpace = 0.0;
4964
if (NamedLStyle.isEmpty())
4966
if (lineColor() != CommonStrings::None)
4967
extraSpace = m_lineWidth / 2.0;
4971
multiLine ml = m_Doc->MLineStyles[NamedLStyle];
4972
struct SingleLine& sl = ml[ml.size()-1];
4973
if ((sl.Color != CommonStrings::None) && (sl.Width != 0))
4974
extraSpace = sl.Width / 2.0;
4977
return Xpos - extraSpace;
4980
double PageItem::visualYPos() const
4982
double extraSpace = 0.0;
4983
if (NamedLStyle.isEmpty())
4985
if (lineColor() != CommonStrings::None)
4986
extraSpace = m_lineWidth / 2.0;
4990
multiLine ml = m_Doc->MLineStyles[NamedLStyle];
4991
struct SingleLine& sl = ml[ml.size()-1];
4992
if ((sl.Color != CommonStrings::None) && (sl.Width != 0))
4993
extraSpace = sl.Width / 2.0;
4995
return Ypos - extraSpace;
4998
double PageItem::visualWidth() const
5000
double extraSpace = 0.0;
5003
if (NamedLStyle.isEmpty())
5005
if (lineColor() != CommonStrings::None)
5006
extraSpace = m_lineWidth;
5010
multiLine ml = m_Doc->MLineStyles[NamedLStyle];
5011
struct SingleLine& sl = ml[ml.size()-1];
5012
if ((sl.Color != CommonStrings::None) && (sl.Width != 0))
5013
extraSpace = sl.Width;
5016
return Width + extraSpace;
5019
double PageItem::visualHeight() const
5021
double extraSpace = 0.0;
5022
if (NamedLStyle.isEmpty())
5024
if (lineColor() != CommonStrings::None)
5025
extraSpace = m_lineWidth;
5029
multiLine ml = m_Doc->MLineStyles[NamedLStyle];
5030
struct SingleLine& sl = ml[ml.size()-1];
5031
if ((sl.Color != CommonStrings::None) && (sl.Width != 0))
5032
extraSpace = sl.Width;
5034
return isLine() ? extraSpace : Height + extraSpace;
5037
bool PageItem::pointWithinItem(const int x, const int y) const
5039
const_cast<PageItem*>(this)-> setRedrawBounding();
5040
// FIXME: We should be rounding or truncating here, not letting the compiler do it.
5041
// Should we be rounding, truncating up, or truncating down?
5042
//CB is this now correct?
5043
QRect itemRect( static_cast<int>(floor(BoundingX)), static_cast<int>(floor(BoundingY)), static_cast<int>(ceil(BoundingW)), static_cast<int>(ceil(BoundingH)) );
5044
return itemRect.contains(x, y);
5047
bool PageItem::mouseWithinItem(const int x, const int y, double scale) const
5051
p.translate(Xpos * scale, Ypos*scale);
5052
p.scale(scale, scale);
5053
p.rotate(rotation());
5054
transRect = p.mapRect(QRectF(0.0, 0.0, width(), height()));
5055
return transRect.contains(x, y);
5058
bool PageItem::loadImage(const QString& filename, const bool reload, const int gsResolution, bool showMsg)
5060
bool useImage = (asImageFrame() != NULL);
5061
useImage |= (isAnnotation() && annotation().UseIcons());
5064
QFileInfo fi(filename);
5065
QString clPath(pixm.imgInfo.usedPath);
5066
pixm.imgInfo.valid = false;
5067
pixm.imgInfo.clipPath="";
5068
pixm.imgInfo.PDSpathData.clear();
5069
pixm.imgInfo.layerInfo.clear();
5070
pixm.imgInfo.usedPath="";
5071
imageClip.resize(0);
5072
int lowResTypeBack = pixm.imgInfo.lowResType;
5073
int gsRes=gsResolution;
5074
if (gsResolution==-1) //If it wasn't supplied, get it from PrefsManager.
5075
gsRes=PrefsManager::instance()->gsResolution();
5077
CMSettings cms(m_Doc, IProfile, IRender);
5078
if (!pixm.LoadPicture(filename, pixm.imgInfo.actualPageNumber, cms, UseEmbedded, true, ScImage::RGBProof, gsRes, &dummy, showMsg))
5080
Pfile = fi.absoluteFilePath();
5081
PictureIsAvailable = false;
5087
QString ext = fi.suffix().toLower();
5088
if (UndoManager::undoEnabled() && !reload)
5090
ItemState<ScImageEffectList> *is = new ItemState<ScImageEffectList>(Um::GetImage, filename, Um::IGetImage);
5091
is->set("GET_IMAGE", "get_image");
5092
is->set("OLD_IMAGE_PATH", Pfile);
5093
is->set("NEW_IMAGE_PATH", filename);
5094
is->set("FLIPPH",imageFlippedH());
5095
is->set("FLIPPV",imageFlippedV());
5096
is->set("SCALING",ScaleType);
5097
is->set("ASPECT",AspectRatio);
5098
is->set("XOFF",imageXOffset());
5099
is->set("XSCALE",imageXScale());
5100
is->set("YOFF",imageYOffset());
5101
is->set("YSCALE",imageYScale());
5102
is->set("FILLT", fillTransparency());
5103
is->set("LINET", lineTransparency());
5104
is->setItem(effectsInUse);
5105
undoManager->action(this, is);
5107
double xres = pixm.imgInfo.xres;
5108
double yres = pixm.imgInfo.yres;
5109
PictureIsAvailable = true;
5112
if (Pfile != filename)
5114
oldLocalScX = LocalScX = 72.0 / xres;
5115
oldLocalScY = LocalScY = 72.0 / yres;
5116
oldLocalX = LocalX = 0;
5117
oldLocalY = LocalY = 0;
5119
if ((m_Doc->toolSettings.useEmbeddedPath) && (!pixm.imgInfo.clipPath.isEmpty()))
5121
pixm.imgInfo.usedPath = pixm.imgInfo.clipPath;
5122
clPath = pixm.imgInfo.clipPath;
5123
if (pixm.imgInfo.PDSpathData.contains(clPath))
5125
imageClip = pixm.imgInfo.PDSpathData[clPath].copy();
5126
pixm.imgInfo.usedPath = clPath;
5128
cl.translate(LocalX*LocalScX, LocalY*LocalScY);
5129
cl.scale(LocalScX, LocalScY);
5135
Pfile = fi.absoluteFilePath();
5136
if (reload && pixm.imgInfo.PDSpathData.contains(clPath))
5138
imageClip = pixm.imgInfo.PDSpathData[clPath].copy();
5139
pixm.imgInfo.usedPath = clPath;
5141
cl.translate(LocalX*LocalScX, LocalY*LocalScY);
5142
cl.scale(LocalScX, LocalScY);
5145
BBoxX = pixm.imgInfo.BBoxX;
5146
BBoxH = pixm.imgInfo.BBoxH;
5147
OrigW = pixm.width();
5148
OrigH = pixm.height();
5149
isRaster = !(extensionIndicatesPDF(ext) || extensionIndicatesEPSorPS(ext));
5151
effectsInUse.clear();
5152
UseEmbedded=pixm.imgInfo.isEmbedded;
5153
if (pixm.imgInfo.isEmbedded)
5155
IProfile = "Embedded " + pixm.imgInfo.profileName;
5156
EmProfile = "Embedded " + pixm.imgInfo.profileName;
5159
IProfile = pixm.imgInfo.profileName;
5162
if (PictureIsAvailable)
5164
if ((pixm.imgInfo.colorspace == ColorSpaceDuotone) && (pixm.imgInfo.duotoneColors.count() != 0) && (!reload))
5167
for (int cc = 0; cc < pixm.imgInfo.duotoneColors.count(); cc++)
5169
if (!m_Doc->PageColors.contains(pixm.imgInfo.duotoneColors[cc].Name))
5170
m_Doc->PageColors.insert(pixm.imgInfo.duotoneColors[cc].Name, pixm.imgInfo.duotoneColors[cc].Color);
5171
efVal += pixm.imgInfo.duotoneColors[cc].Name+"\n";
5173
m_Doc->scMW()->propertiesPalette->updateColorList();
5174
struct ImageEffect ef;
5175
if (pixm.imgInfo.duotoneColors.count() == 1)
5178
ef.effectCode = ScImage::EF_COLORIZE;
5179
ef.effectParameters = efVal;
5181
else if (pixm.imgInfo.duotoneColors.count() == 2)
5185
FPointArray Vals = pixm.imgInfo.duotoneColors[0].Curve;
5186
tmp.setNum(Vals.size());
5188
for (uint p = 0; p < Vals.size(); p++)
5190
FPoint pv = Vals.point(p);
5191
efVal += QString(" %1 %2").arg(pv.x()).arg(pv.y());
5194
Vals = pixm.imgInfo.duotoneColors[1].Curve;
5195
tmp.setNum(Vals.size());
5197
for (uint p = 0; p < Vals.size(); p++)
5199
FPoint pv = Vals.point(p);
5200
efVal += QString(" %1 %2").arg(pv.x()).arg(pv.y());
5203
ef.effectCode = ScImage::EF_DUOTONE;
5204
ef.effectParameters = efVal;
5206
else if (pixm.imgInfo.duotoneColors.count() == 3)
5208
efVal += "100 100 100";
5210
FPointArray Vals = pixm.imgInfo.duotoneColors[0].Curve;
5211
tmp.setNum(Vals.size());
5213
for (uint p = 0; p < Vals.size(); p++)
5215
FPoint pv = Vals.point(p);
5216
efVal += QString(" %1 %2").arg(pv.x()).arg(pv.y());
5219
Vals = pixm.imgInfo.duotoneColors[1].Curve;
5220
tmp.setNum(Vals.size());
5222
for (uint p = 0; p < Vals.size(); p++)
5224
FPoint pv = Vals.point(p);
5225
efVal += QString(" %1 %2").arg(pv.x()).arg(pv.y());
5228
Vals = pixm.imgInfo.duotoneColors[2].Curve;
5229
tmp.setNum(Vals.size());
5231
for (uint p = 0; p < Vals.size(); p++)
5233
FPoint pv = Vals.point(p);
5234
efVal += QString(" %1 %2").arg(pv.x()).arg(pv.y());
5237
ef.effectCode = ScImage::EF_TRITONE;
5238
ef.effectParameters = efVal;
5240
else if (pixm.imgInfo.duotoneColors.count() == 4)
5242
efVal += "100 100 100 100";
5244
FPointArray Vals = pixm.imgInfo.duotoneColors[0].Curve;
5245
tmp.setNum(Vals.size());
5247
for (uint p = 0; p < Vals.size(); p++)
5249
FPoint pv = Vals.point(p);
5250
efVal += QString(" %1 %2").arg(pv.x()).arg(pv.y());
5253
Vals = pixm.imgInfo.duotoneColors[1].Curve;
5254
tmp.setNum(Vals.size());
5256
for (uint p = 0; p < Vals.size(); p++)
5258
FPoint pv = Vals.point(p);
5259
efVal += QString(" %1 %2").arg(pv.x()).arg(pv.y());
5262
Vals = pixm.imgInfo.duotoneColors[2].Curve;
5263
tmp.setNum(Vals.size());
5265
for (uint p = 0; p < Vals.size(); p++)
5267
FPoint pv = Vals.point(p);
5268
efVal += QString(" %1 %2").arg(pv.x()).arg(pv.y());
5271
Vals = pixm.imgInfo.duotoneColors[3].Curve;
5272
tmp.setNum(Vals.size());
5274
for (uint p = 0; p < Vals.size(); p++)
5276
FPoint pv = Vals.point(p);
5277
efVal += QString(" %1 %2").arg(pv.x()).arg(pv.y());
5280
ef.effectCode = ScImage::EF_QUADTONE;
5281
ef.effectParameters = efVal;
5283
effectsInUse.append(ef);
5285
pixm.applyEffect(effectsInUse, m_Doc->PageColors, false);
5287
pixm.imgInfo.lowResType = lowResTypeBack;
5288
if (pixm.imgInfo.lowResType != 0)
5290
double scaling = pixm.imgInfo.xres / 36.0;
5291
if (pixm.imgInfo.lowResType == 1)
5292
scaling = pixm.imgInfo.xres / 72.0;
5293
// Prevent exagerately large images when using low res preview modes
5294
uint pixels = qRound(pixm.width() * pixm.height() / (scaling * scaling));
5295
if (pixels > 3000000)
5297
double ratio = pixels / 3000000.0;
5298
scaling *= sqrt(ratio);
5300
pixm.createLowRes(scaling);
5301
pixm.imgInfo.lowResScale = scaling;
5303
if ((m_Doc->view()->m_canvas->usePreviewVisual()))
5305
VisionDefectColor defect;
5307
int h = pixm.qImagePtr()->height();
5308
int w = pixm.qImagePtr()->width();
5312
for( int yi=0; yi < h; ++yi )
5314
s = (QRgb*)(pixm.qImagePtr()->scanLine( yi ));
5315
for( int xi = 0; xi < w; ++xi )
5319
tmpC = defect.convertDefect(tmpC, m_Doc->view()->m_canvas->previewVisual());
5321
tmpC.getRgb(&r, &g, &b);
5322
*s = qRgba(r, g, b, a);
5332
void PageItem::drawLockedMarker(ScPainter *p)
5335
double scp1 = 1 ;// / ScMW->view->scale();
5336
double ofwh = 6 * scp1;
5337
double ofx = Width - ofwh/2;
5338
double ofy = Height - ofwh*1.5;
5339
double bx1= ofx+ scp1;
5340
double by1= ofy+3 * scp1;
5343
ScribusView* view = m_Doc->view();
5344
p->setPen(Qt::black, 0.5 / view->scale(), Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
5345
p->setPenOpacity(1.0);
5346
p->setBrush(Qt::white);
5347
p->setBrushOpacity(1.0);
5348
p->setFillMode(ScPainter::Solid);
5349
p->drawRect(ofx, ofy, ofwh, ofwh);
5350
p->setBrush(Qt::black);
5351
p->drawRect(bx1, by1, bw, bh);
5352
p->setPen(Qt::black, 1.5 / view->scale(), Qt::SolidLine, Qt::FlatCap, Qt::RoundJoin);
5354
p->drawLine(FPoint(bx1+scp1/2, ofy+scp1), FPoint(bx1+scp1/2, by1));
5355
p->drawLine(FPoint(bx1+scp1*3.5, ofy+scp1), FPoint(bx1+scp1*3.5, by1));
5356
p->drawLine(FPoint(bx1+scp1/2, ofy+scp1), FPoint(bx1+scp1*3.5, ofy+scp1));
5359
void PageItem::drawArrow(ScPainter *p, QMatrix &arrowTrans, int arrowIndex)
5361
FPointArray arrow = m_Doc->arrowStyles.at(arrowIndex-1).points.copy();
5362
if (NamedLStyle.isEmpty())
5364
if (m_lineWidth != 0.0)
5365
arrowTrans.scale(m_lineWidth, m_lineWidth);
5369
multiLine ml = m_Doc->MLineStyles[NamedLStyle];
5370
if (ml[ml.size()-1].Width != 0.0)
5371
arrowTrans.scale(ml[ml.size()-1].Width, ml[ml.size()-1].Width);
5373
arrow.map(arrowTrans);
5374
p->setupPolygon(&arrow);
5375
if (m_Doc->layerOutline(LayerNr))
5379
if (NamedLStyle.isEmpty())
5381
if (lineColor() != CommonStrings::None)
5383
p->setBrush(strokeQColor);
5384
p->setBrushOpacity(1.0 - lineTransparency());
5386
p->setFillMode(ScPainter::Solid);
5392
multiLine ml = m_Doc->MLineStyles[NamedLStyle];
5394
if (ml[0].Color != CommonStrings::None)
5396
SetQColor(&tmp, ml[0].Color, ml[0].Shade);
5399
p->setFillMode(ScPainter::Solid);
5402
for (int it = ml.size()-1; it > 0; it--)
5404
if (ml[it].Color != CommonStrings::None)
5406
SetQColor(&tmp, ml[it].Color, ml[it].Shade);
5407
p->setPen(tmp, ml[it].Width, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
5415
void PageItem::AdjustPictScale()
5417
if (itemType()!=PageItem::ImageFrame)
5421
if (OrigW == 0 || OrigH == 0)
5425
double xs = Width / static_cast<double>(OrigW);
5426
double ys = Height / static_cast<double>(OrigH);
5429
LocalScX = qMin(xs, ys);
5430
LocalScY = qMin(xs, ys);
5437
// Disable broken code. Code must be independent from doc in that function
5438
/*switch (m_Doc->RotMode)
5445
LocalX = (Width - static_cast<double>(OrigW) * LocalScX) / LocalScX;
5449
LocalX = ((Width - static_cast<double>(OrigW) * LocalScX) / LocalScX) / 2.0;
5450
LocalY = ((Height - static_cast<double>(OrigH) * LocalScY) / LocalScY) / 2.0;
5454
LocalY = (Height - static_cast<double>(OrigH) * LocalScY) / LocalScY;
5457
LocalX = (Width - static_cast<double>(OrigW) * LocalScX) / LocalScX;
5458
LocalY = (Height - static_cast<double>(OrigH) * LocalScY) / LocalScY;
5461
if (imageClip.size() != 0)
5463
imageClip = pixm.imgInfo.PDSpathData[pixm.imgInfo.usedPath].copy();
5465
cl.translate(LocalX*LocalScX, LocalY*LocalScY);
5466
cl.scale(LocalScX, LocalScY);
5469
emit imageOffsetScale(LocalScX, LocalScY, LocalX, LocalY );
5472
void PageItem::setExternalFile(QString val)
5475
if (!Pfile.isEmpty())
5477
QString test = Pfile;
5478
if (QDir::isRelativePath(test))
5479
test = QDir::homePath()+"/"+Pfile;
5480
test = QDir::cleanPath(QDir::convertSeparators(test));
5481
QFileInfo pfi2(test);
5482
Pfile = pfi2.absoluteFilePath();
5486
void PageItem::setFileIconPressed(QString val)
5489
if (!Pfile2.isEmpty())
5491
QString test = QDir::cleanPath(QDir::convertSeparators(QDir::homePath()+"/"+Pfile2));
5492
QFileInfo pfi2(test);
5493
Pfile2 = pfi2.absoluteFilePath();
5497
void PageItem::setFileIconRollover(QString val)
5500
if (!Pfile3.isEmpty())
5502
QString test = QDir::cleanPath(QDir::convertSeparators(QDir::homePath()+"/"+Pfile3));
5503
QFileInfo pfi2(test);
5504
Pfile3 = pfi2.absoluteFilePath();
5508
QRect PageItem::getRedrawBounding(const double viewScale)
5510
int x = qRound(floor(BoundingX - Oldm_lineWidth / 2.0 - 5) * viewScale);
5511
int y = qRound(floor(BoundingY - Oldm_lineWidth / 2.0 - 5) * viewScale);
5512
int w = qRound(ceil(BoundingW + Oldm_lineWidth + 10) * viewScale);
5513
int h = qRound(ceil(BoundingH + Oldm_lineWidth + 10) * viewScale);
5514
QRect ret = QRect(x, y, w, h);
5515
ret.translate(qRound(-m_Doc->minCanvasCoordinate.x() * viewScale), qRound(-m_Doc->minCanvasCoordinate.y() * viewScale));
5520
void PageItem::setRedrawBounding()
5523
getBoundingRect(&BoundingX, &BoundingY, &bw, &bh);
5524
BoundingW = bw - BoundingX;
5525
BoundingH = bh - BoundingY;
5527
BoundingH = qMax(BoundingH, 1.0);
5530
void PageItem::updateGradientVectors()
5537
GrStartY = Height / 2.0;
5539
GrEndY = Height / 2.0;
5542
GrStartX = Width / 2.0;
5544
GrEndX = Width / 2.0;
5560
GrStartX = Width / 2.0;
5561
GrStartY = Height / 2.0;
5562
if (Width >= Height)
5565
GrEndY = Height / 2.0;
5569
GrEndX = Width / 2.0;
5576
//if (ScMW->view->SelItem.count()!=0 && this==ScMW->view->SelItem.at(0))
5577
//if (m_Doc->m_Selection->count()!=0 && m_Doc->m_Selection->primarySelectionIsMyself(this))
5578
// ScMW->propertiesPalette->updateColorSpecialGradient();
5579
//CB Will only emit if connected, ie is first in GUI selection
5580
double dur=m_Doc->unitRatio();
5581
emit gradientColorUpdate(GrStartX*dur, GrStartY*dur, GrEndX*dur, GrEndY*dur, Width*dur, Height*dur);
5584
void PageItem::setPolyClip(int up, int down)
5586
if (PoLine.size() < 4)
5593
if (textPathFlipped)
5599
QPolygon cl, cl1, cl2;
5600
cl = FlattenPath(PoLine, Segments);
5604
for (int a = 0; a < cl.size()-1; ++a)
5606
rot = xy2Deg(cl.point(a+1).x()-cl.point(a).x(),cl.point(a+1).y()-cl.point(a).y());
5609
np = QPoint(0, -upval) * ma;
5610
np2 = QPoint(0, -downval) * ma;
5611
cl1.resize(cl1.size()+1);
5612
cl1.setPoint(cl1.size()-1, np+cl.point(a));
5613
cl1.resize(cl1.size()+1);
5614
cl1.setPoint(cl1.size()-1, np+cl.point(a+1));
5615
cl2.resize(cl2.size()+1);
5616
cl2.setPoint(cl2.size()-1, np2+cl.point(a));
5617
cl2.resize(cl2.size()+1);
5618
cl2.setPoint(cl2.size()-1, np2+cl.point(a+1));
5620
cl1.resize(cl1.size()+1);
5621
cl1.setPoint(cl1.size()-1, np+cl.point(cl.size()-1));
5622
cl2.resize(cl2.size()+1);
5623
cl2.setPoint(cl2.size()-1, np2+cl.point(cl.size()-1));
5624
Clip.putPoints(Clip.size(), cl1.size(), cl1);
5625
for (int a2 = cl2.size()-1; a2 > -1; a2--)
5627
Clip.resize(Clip.size()+1);
5628
Clip.setPoint(Clip.size()-1, cl2.point(a2));
5633
void PageItem::updatePolyClip()
5637
uint itemTextCount=itemText.length();
5638
for (uint a = 0; a < itemTextCount; ++a)
5640
const CharStyle& hl (itemText.charStyle(a));
5641
int des = static_cast<int>(hl.font().descent(hl.fontSize() / 10.0));
5642
int asc = static_cast<int>(hl.font().ascent(hl.fontSize() / 10.0));
5643
asce = qMax(asce, asc);
5644
desc = qMax(desc, des);
5646
setPolyClip(static_cast<int>(asce-BaseOffs), static_cast<int>(desc-BaseOffs));
5649
void PageItem::handleModeEditKey(QKeyEvent * /* k */, bool & /* keyRepeat */)
5653
bool PageItem::connectToGUI()
5655
if (!ScCore->usingGUI())
5657
if (!m_Doc->m_Selection->primarySelectionIs(this))
5659
PropertiesPalette* pp=m_Doc->scMW()->propertiesPalette;
5660
connect(this, SIGNAL(myself(PageItem *)), pp, SLOT(SetCurItem(PageItem *)));
5661
connect(this, SIGNAL(frameType(int)), m_Doc->scMW(), SLOT(HaveNewSel(int)));
5662
connect(this, SIGNAL(frameType(int)), m_Doc->view(), SLOT(selectionChanged()));
5663
connect(this, SIGNAL(frameType(int)), pp, SLOT(NewSel(int)));
5664
connect(this, SIGNAL(frameLocked(bool)), pp, SLOT(setLocked(bool)));
5665
connect(this, SIGNAL(frameSizeLocked(bool)), pp, SLOT(setSizeLocked(bool)));
5666
connect(this, SIGNAL(frameFlippedH(bool)), pp, SLOT(setFlippedH(bool)));
5667
connect(this, SIGNAL(frameFlippedV(bool)), pp, SLOT(setFlippedV(bool)));
5668
connect(this, SIGNAL(printEnabled(bool)), pp, SLOT(setPrintingEnabled(bool)));
5669
connect(this, SIGNAL(position(double, double)), pp, SLOT(setXY(double, double)));
5670
connect(this, SIGNAL(widthAndHeight(double, double)), pp, SLOT(setBH(double, double)));
5671
//CB unused in 135 connect(this, SIGNAL(colors(QString, QString, double, double)), m_Doc->scMW(), SLOT(setCSMenu()));
5672
// connect(this, SIGNAL(colors(QString, QString, double, double)), pp->Cpal, SLOT(setActFarben(QString, QString, int, int)));
5673
// connect(this, SIGNAL(gradientType(int)), pp->Cpal, SLOT(setActGradient(int)));
5674
connect(this, SIGNAL(patternFill(QString, double, double, double, double, double)), pp->Cpal, SLOT(setActPattern(QString, double, double, double, double, double)));
5675
// connect(this, SIGNAL(gradientColorUpdate(double, double, double, double, double, double)), pp->Cpal, SLOT(setSpecialGradient(double, double, double, double, double, double)));
5676
connect(this, SIGNAL(rotation(double)), pp, SLOT(setR(double)));
5677
// connect(this, SIGNAL(transparency(double, double)), pp->Cpal, SLOT(setActTrans(double, double)));
5678
// connect(this, SIGNAL(blendmode(int, int)), pp->Cpal, SLOT(setActBlend(int, int)));
5680
//Not connected when transferring code: void columns(int, double); //Number, gap
5681
connect(this, SIGNAL(cornerRadius(double)), pp, SLOT(setRR(double)));
5682
// connect(view, SIGNAL(ItemTextCols(int, double)), propertiesPalette, SLOT(setCols(int, double)));
5684
connect(this, SIGNAL(lineWidth(double)), pp, SLOT(setLineWidth(double)));
5685
connect(this, SIGNAL(imageOffsetScale(double, double, double, double)), pp, SLOT(setScaleAndOffset(double, double, double, double)));
5686
connect(this, SIGNAL(lineStyleCapJoin(Qt::PenStyle, Qt::PenCapStyle, Qt::PenJoinStyle)), pp, SLOT( setLIvalue(Qt::PenStyle, Qt::PenCapStyle, Qt::PenJoinStyle)));
5687
//Frame text signals
5688
connect(this, SIGNAL(lineSpacing(double)), pp, SLOT(setLsp(double)));
5689
connect(this, SIGNAL(textToFrameDistances(double, double, double, double)), pp, SLOT(setTextToFrameDistances(double, double, double, double)));
5690
connect(this, SIGNAL(textKerning(double)), pp, SLOT(setExtra(double)));
5691
connect(this, SIGNAL(textStyle(int)), pp, SLOT(setStil(int)));
5692
connect(this, SIGNAL(textStyle(int)), m_Doc->scMW(), SLOT(setStilvalue(int)));
5693
connect(this, SIGNAL(textFont(const QString&)), pp, SLOT(setFontFace(const QString&)));
5694
connect(this, SIGNAL(textSize(double)), pp, SLOT(setSize(double)));
5695
connect(this, SIGNAL(textWidthScale(double)), pp, SLOT(setTScale(double)));
5696
connect(this, SIGNAL(textHeightScale(double)), pp, SLOT(setTScaleV(double)));
5697
connect(this, SIGNAL(textBaseLineOffset(double)), pp, SLOT(setTBase(double)));
5698
connect(this, SIGNAL(textOutline(double)), pp, SLOT(setOutlineW(double)));
5699
connect(this, SIGNAL(textShadow(double, double )), pp, SLOT(setShadowOffs(double, double )));
5700
connect(this, SIGNAL(textUnderline(double, double)), pp, SLOT(setUnderline(double, double)));
5701
connect(this, SIGNAL(textStrike(double, double)), pp, SLOT(setStrike(double, double)));
5702
connect(this, SIGNAL(textColor(QString, QString, double, double)), pp, SLOT(setActFarben(QString, QString, double, double)));
5703
// connect(this, SIGNAL(textFormatting(int)), pp, SLOT(setAli(int)));
5704
// connect(this, SIGNAL(textFormatting(int)), ScMW, SLOT(setAbsValue(int)));
5709
bool PageItem::disconnectFromGUI()
5711
if (!ScCore->usingGUI())
5713
// Disconnecting only signals from PP will leave some remaining connections
5714
// and cause progressive slowdowns
5715
// PropertiesPalette* pp=m_Doc->scMW()->propertiesPalette;
5716
// disconnect(this, 0, pp, 0);
5717
disconnect(this, 0, 0, 0);
5721
void PageItem::emitAllToGUI()
5726
emit frameType(m_ItemType);
5727
/*CB using the emit myself* instead of all of these
5728
emit position(Xpos, Ypos);
5729
emit widthAndHeight(Width, Height);
5731
emit frameLocked(m_Locked);
5732
emit frameSizeLocked(m_SizeLocked);
5733
emit frameFlippedH(m_ImageIsFlippedH);
5734
emit frameFlippedV(m_ImageIsFlippedV);
5735
emit printEnabled(m_PrintEnabled);
5736
emit lineWidth(m_lineWidth);
5737
emit lineStyleCapJoin(PLineArt, PLineEnd, PLineJoin);
5738
emit imageOffsetScale(LocalScX, LocalScY, LocalX, LocalY);
5740
//CB unused in 135 emit colors(lineColorVal, fillColorVal, lineShadeVal, fillShadeVal);
5741
// emit gradientType(GrType);
5742
// double dur=m_Doc->unitRatio();
5743
// emit gradientColorUpdate(GrStartX*dur, GrStartY*dur, GrEndX*dur, GrEndY*dur, Width*dur, Height*dur);
5744
// emit transparency(fillTransparencyVal, lineTransparencyVal);
5745
// emit blendmode(fillBlendmodeVal, lineBlendmodeVal);
5746
/*CB using the emit myself* instead of all of these
5747
emit patternFill(patternVal, patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation);
5748
emit textToFrameDistances(Extra, TExtra, BExtra, RExtra);
5749
emit columns(Cols, ColGap);
5751
if (m_Doc->appMode == modeEdit)
5753
/* maybe already done elsewhere? -- av
5754
emit lineSpacing(currentStyle().lineSpacing());
5755
emit textKerning(currentCharStyle().tracking());
5756
emit textStyle(currentCharStyle().effects());
5757
emit textFont(currentCharStyle().font()->scName());
5758
emit textSize(currentCharStyle().fontSize());
5760
// emit textFormatting(currentStyle().alignment());
5764
//TODO remove and use the emit myself
5765
emit lineSpacing(itemText.defaultStyle().lineSpacing());
5766
emit textKerning(itemText.defaultStyle().charStyle().tracking());
5767
emit textStyle(itemText.defaultStyle().charStyle().effects());
5768
emit textFont(itemText.defaultStyle().charStyle().font().scName());
5769
emit textSize(itemText.defaultStyle().charStyle().fontSize());
5770
// emit textFormatting(itemText.defaultStyle().alignment());
5774
void PageItem::setIsAnnotation(bool isAnnot)
5776
m_isAnnotation=isAnnot;
5779
void PageItem::setAnnotation(const Annotation& ad)
5784
void PageItem::setImageShown(bool isShown)
5789
void PageItem::updateConstants()
5793
m_Doc->constants().insert("pagewidth", m_Doc->Pages->at(OwnPage)->width());
5794
m_Doc->constants().insert("pageheight", m_Doc->Pages->at(OwnPage)->height());
5796
m_Doc->constants().insert("width", Width);
5797
m_Doc->constants().insert("height", Height);
5800
//CB Old ScribusView MoveItemI
5801
void PageItem::moveImageInFrame(double newX, double newY)
5803
if (m_ItemType!=PageItem::ImageFrame)
5805
if ((locked()) || (!ScaleType))
5807
double dX=0.0, dY=0.0;
5808
if (imageFlippedH())
5812
if (imageFlippedV())
5816
moveImageXYOffsetBy(dX, dY);
5817
if (imageClip.size() != 0)
5819
imageClip = pixm.imgInfo.PDSpathData[pixm.imgInfo.usedPath].copy();
5821
cl.translate(imageXOffset()*imageXScale(), imageYOffset()*imageYScale());
5822
cl.scale(imageXScale(), imageYScale());
5829
void PageItem::convertClip()
5831
if (Clip.count() != 0)
5833
FPoint np(Clip.point(0));
5835
PoLine.setPoint(0, np);
5836
PoLine.setPoint(1, np);
5837
for (int a = 1; a < Clip.size(); ++a)
5839
np = FPoint(Clip.point(a));
5840
PoLine.putPoints(PoLine.size(), 4, np.x(), np.y(), np.x(), np.y(), np.x(), np.y(), np.x(), np.y());
5842
np = FPoint(Clip.point(0));
5843
PoLine.putPoints(PoLine.size(), 2, np.x(), np.y(), np.x(), np.y());
5844
Clip = FlattenPath(PoLine, Segments);
5849
m_Doc->setRedrawBounding(this);
5853
void PageItem::updateClip()
5855
if (m_Doc->appMode == modeDrawBezierLine)
5857
if (ContourLine.size() == 0)
5858
ContourLine = PoLine.copy();
5859
int ph = static_cast<int>(qMax(1.0, lineWidth() / 2.0));
5860
bool clipBackup = ClipEdited;
5863
case PageItem::Line:
5864
Clip.setPoints(4, -ph,-ph, static_cast<int>(width()+ph),-ph,
5865
static_cast<int>(width()+ph),static_cast<int>(height()+ph),
5866
-ph,static_cast<int>(height()+ph));
5869
if (((!ClipEdited) || (FrameType < 3)) && !(asPathText()))
5875
m_Doc->setRedrawBounding(this);
5879
m_Doc->setRedrawBounding(this);
5882
//CB FIXME: stop using nodeEdit.clre or move out of here
5883
m_Doc->nodeEdit.deselect();
5885
m_Doc->setRedrawBounding(this);
5890
ClipEdited = clipBackup;
5891
if ((OldB2 != 0) && (OldH2 != 0) && (width() != 0) && (height() != 0))
5893
double scx = width() / OldB2;
5894
double scy = height() / OldH2;
5898
gr.addPoint(GrStartX, GrStartY);
5899
gr.addPoint(GrEndX, GrEndY);
5901
GrStartX = gr.point(0).x();
5902
GrStartY = gr.point(0).y();
5903
GrEndX = gr.point(1).x();
5904
GrEndY = gr.point(1).y();
5905
ContourLine.map(ma);
5912
Clip = FlattenPath(PoLine, Segments);
5917
if ((FrameType < 3) && (!ClipEdited))
5918
ContourLine = PoLine.copy();
5922
if (m_Doc->SubMode != -1)
5924
switch (m_Doc->SubMode)
5928
m_Doc->setRedrawBounding(this);
5932
m_Doc->setRedrawBounding(this);
5935
SetFrameShape(m_Doc->ValCount, m_Doc->ShapeValues);
5936
m_Doc->setRedrawBounding(this);
5941
ContourLine = PoLine.copy();
5943
if ((OldB2 == 0) || (OldH2 == 0) || (width() == 0) || (height() == 0))
5945
double scx = width() / OldB2;
5946
double scy = height() / OldH2;
5950
gr.addPoint(GrStartX, GrStartY);
5951
gr.addPoint(GrEndX, GrEndY);
5953
GrStartX = gr.point(0).x();
5954
GrStartY = gr.point(0).y();
5955
GrEndX = gr.point(1).x();
5956
GrEndY = gr.point(1).y();
5958
ContourLine.map(ma);
5962
Clip = FlattenPath(PoLine, Segments);
5968
updateGradientVectors();
5971
QString PageItem::infoDescription()
5974
htmlText.append(ScribusView::tr("Print: "));
5976
htmlText.append(ScribusView::tr("Enabled"));
5978
htmlText.append(ScribusView::tr("Disabled"));
5979
htmlText.append("<br/>");
5983
FirstLineOffsetPolicy PageItem::firstLineOffset() const
5985
return firstLineOffsetP;
5988
void PageItem::setFirstLineOffset(FirstLineOffsetPolicy flop)
5990
if(firstLineOffsetP != flop)
5992
firstLineOffsetP = flop;