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),
137
itemText(other.itemText),
138
isBookmark(other.isBookmark),
139
HasSel(other.HasSel),
140
// Tinput(other.Tinput),
141
isAutoText(other.isAutoText),
142
BackBox(NULL), // otherwise other.BackBox->NextBox would be inconsistent
143
NextBox(NULL), // otherwise other.NextBox->BackBox would be inconsistent
144
firstChar(0), // since this box is unlinked now
145
MaxChars(0), // since the layout is invalid now
146
inPdfArticle(other.inPdfArticle),
147
isRaster(other.isRaster),
152
Sizing(other.Sizing),
153
toPixmap(other.toPixmap),
154
LayerNr(other.LayerNr),
155
ScaleType(other.ScaleType),
156
AspectRatio(other.AspectRatio),
157
Groups(other.Groups),
158
DashValues(other.DashValues),
159
DashOffset(other.DashOffset),
160
fill_gradient(other.fill_gradient),
161
fillRule(other.fillRule),
162
doOverprint(other.doOverprint),
163
LeftLink(other.LeftLink),
164
RightLink(other.RightLink),
165
TopLink(other.TopLink),
166
BottomLink(other.BottomLink),
167
LeftLinkID(other.LeftLinkID),
168
RightLinkID(other.RightLinkID),
169
TopLinkID(other.TopLinkID),
170
BottomLinkID(other.BottomLinkID),
171
LeftLine(other.LeftLine),
172
RightLine(other.RightLine),
173
TopLine(other.TopLine),
174
BottomLine(other.BottomLine),
175
isTableItem(other.isTableItem),
176
isSingleSel(other.isSingleSel),
177
isGroupControl(other.isGroupControl),
178
groupsLastItem(other.groupsLastItem),
179
BoundingX(other.BoundingX),
180
BoundingY(other.BoundingY),
181
BoundingW(other.BoundingW),
182
BoundingH(other.BoundingH),
183
ChangedMasterItem(other.ChangedMasterItem),
184
OnMasterPage(other.OnMasterPage),
185
isEmbedded(other.isEmbedded),
188
undoManager(other.undoManager),
189
m_ItemType(other.m_ItemType),
190
AnName(other.AnName),
191
patternVal(other.patternVal),
192
patternScaleX(other.patternScaleX),
193
patternScaleY(other.patternScaleY),
194
patternOffsetX(other.patternOffsetX),
195
patternOffsetY(other.patternOffsetY),
196
patternRotation(other.patternRotation),
197
fillColorVal(other.fillColorVal),
198
lineColorVal(other.lineColorVal),
199
lineShadeVal(other.lineShadeVal),
200
fillShadeVal(other.fillShadeVal),
201
fillTransparencyVal(other.fillTransparencyVal),
202
lineTransparencyVal(other.lineTransparencyVal),
203
fillBlendmodeVal(other.fillBlendmodeVal),
204
lineBlendmodeVal(other.lineBlendmodeVal),
205
m_ImageIsFlippedH(other.m_ImageIsFlippedH),
206
m_ImageIsFlippedV(other.m_ImageIsFlippedV),
207
m_Locked(other.m_Locked),
208
m_SizeLocked(other.m_SizeLocked),
209
textFlowModeVal(other.textFlowModeVal),
210
pageItemAttributes(other.pageItemAttributes),
211
m_PrintEnabled(other.m_PrintEnabled),
212
tagged(other.tagged),
213
fillQColor(other.fillQColor),
214
strokeQColor(other.strokeQColor),
218
Height(other.Height),
220
Select(other.Select),
221
LocalScX(other.LocalScX),
222
LocalScY(other.LocalScY),
223
LocalX(other.LocalX),
224
LocalY(other.LocalY),
225
Reverse(other.Reverse),
226
m_startArrowIndex(other.m_startArrowIndex),
227
m_endArrowIndex(other.m_endArrowIndex),
229
TExtra(other.TExtra),
230
BExtra(other.BExtra),
231
RExtra(other.RExtra),
232
firstLineOffsetP(other.firstLineOffsetP),
233
RadRect(other.RadRect),
234
oldXpos(other.oldXpos),
235
oldYpos(other.oldYpos),
236
oldWidth(other.oldWidth),
237
oldHeight(other.oldHeight),
238
oldRot(other.oldRot),
239
oldLocalScX(other.oldLocalScX),
240
oldLocalScY(other.oldLocalScY),
241
oldLocalX(other.oldLocalX),
242
oldLocalY(other.oldLocalY),
244
m_isAnnotation(other.m_isAnnotation),
245
m_annotation(other.m_annotation),
246
PicArt(other.PicArt),
247
m_lineWidth(other.m_lineWidth),
248
Oldm_lineWidth(other.Oldm_lineWidth)
252
AnName += tmp.setNum(m_Doc->TotalItems);
253
uniqueNr = m_Doc->TotalItems;
255
if (other.isInlineImage)
257
QFileInfo inlFi(Pfile);
258
QString ext = inlFi.suffix();
259
tempImageFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_XXXXXX." + ext);
260
tempImageFile->open();
261
QString fileName = getLongPathName(tempImageFile->fileName());
262
tempImageFile->close();
263
copyFile(Pfile, fileName);
265
isInlineImage = true;
269
tempImageFile = NULL;
270
isInlineImage = false;
275
PageItem::PageItem(ScribusDoc *pa, ItemType newType, double x, double y, double w, double h, double w2, QString fill, QString outline)
276
// Initialize superclass(es)
277
: QObject(pa), SingleObservable<PageItem>(pa->itemsChanged()),
278
// Initialize member variables
280
undoManager(UndoManager::instance()),
283
fillTransparencyVal(0.0),
284
lineTransparencyVal(0.0),
287
m_ImageIsFlippedH(0),
288
m_ImageIsFlippedV(0),
291
textFlowModeVal(TextFlowDisabled)
299
//CB Surely we can remove some of these?
300
OldB2 = OldB = oldWidth = Width = w;
301
OldH2 = OldH = oldHeight = Height = h;
306
m_ItemType = newType;
309
lineColorVal = m_ItemType == PageItem::TextFrame ? fill : outline;
311
gWidth = gHeight = 0;
325
PLineArt = Qt::PenStyle(m_Doc->toolSettings.dLineArt);
326
PLineEnd = Qt::FlatCap;
327
PLineJoin = Qt::MiterJoin;
342
pixm.imgInfo.lowResType = m_Doc->toolSettings.lowResType;
345
oldLocalScX = LocalScX = 1;
346
oldLocalScY = LocalScY = 1;
349
oldLocalX = LocalX = 0;
350
oldLocalY = LocalY = 0;
354
if ((m_ItemType == TextFrame) || (m_ItemType == ImageFrame) || (m_ItemType == PathText))
355
// TODO: Frame should become a read-only calculated property
362
Clip.setPoints(4, static_cast<int>(w/2), 0, static_cast<int>(w), static_cast<int>(h/2),
363
static_cast<int>(w/2), static_cast<int>(h), 0,static_cast<int>(h/2));
366
Clip.setPoints(4, 0,0, static_cast<int>(w),0, static_cast<int>(w), static_cast<int>(h), 0,static_cast<int>(h));
370
ContourLine.resize(0);
376
textPathFlipped = false;
377
OwnPage = m_Doc->currentPage()->pageNr();
378
oldOwnPage = OwnPage;
379
savedOwnPage = OwnPage;
381
PictureIsAvailable = false;
382
m_PrintEnabled = true;
384
m_isAnnotation = false;
390
//We can't determine if this is a latex frame here
391
// because c++'s typeinfos are still saying it's
393
// This is fixed in the PageItem_LatexFrame constructor
394
AnName = tr("Image");
395
setUPixmap(Um::IImageFrame);
399
setUPixmap(Um::ITextFrame);
403
setUPixmap(Um::ILine);
406
AnName = tr("Polygon");
407
setUPixmap(Um::IPolygon);
410
AnName = tr("Polyline");
411
setUPixmap(Um::IPolyline);
414
AnName = tr("PathText");
415
setUPixmap(Um::IPathText);
422
AnName += tmp.setNum(m_Doc->TotalItems); // +" "+QDateTime::currentDateTime().toString();
423
uniqueNr = m_Doc->TotalItems;
426
m_annotation.setBorderColor(outline);
430
inPdfArticle = false;
435
IRender = Intent_Relative_Colorimetric;
438
LayerNr = m_Doc->activeLayer();
447
fill_gradient = VGradient(VGradient::linear);
448
fill_gradient.clearStops();
449
if (fillColorVal != CommonStrings::None)
451
const ScColor& col = m_Doc->PageColors[fillColorVal];
452
QColor qcol = ScColorEngine::getRGBColor(col, m_Doc);
453
fill_gradient.addStop(qcol, 0.0, 0.5, 1.0, fillColorVal, 100);
454
fill_gradient.addStop(qcol, 1.0, 0.5, 1.0, fillColorVal, 100);
458
if (m_Doc->toolSettings.dBrush != CommonStrings::None)
460
const ScColor& col = m_Doc->PageColors[m_Doc->toolSettings.dBrush];
461
QColor qcol = ScColorEngine::getRGBColor(col, m_Doc);
462
fill_gradient.addStop(qcol, 0.0, 0.5, 1.0, m_Doc->toolSettings.dBrush, 100);
463
fill_gradient.addStop(qcol, 1.0, 0.5, 1.0, m_Doc->toolSettings.dBrush, 100);
467
if (lineColorVal != CommonStrings::None)
469
const ScColor& col = m_Doc->PageColors[lineColorVal];
470
QColor qcol = ScColorEngine::getRGBColor(col, m_Doc);
471
fill_gradient.addStop(qcol, 0.0, 0.5, 1.0, lineColorVal, 100);
472
fill_gradient.addStop(qcol, 1.0, 0.5, 1.0, lineColorVal, 100);
476
if (m_Doc->toolSettings.dPen != CommonStrings::None)
478
const ScColor& col = m_Doc->PageColors[m_Doc->toolSettings.dPen];
479
QColor qcol = ScColorEngine::getRGBColor(col, m_Doc);
480
fill_gradient.addStop(qcol, 0.0, 0.5, 1.0, m_Doc->toolSettings.dPen, 100);
481
fill_gradient.addStop(qcol, 1.0, 0.5, 1.0, m_Doc->toolSettings.dPen, 100);
483
else if (m_Doc->PageColors.contains("Black"))
485
const ScColor& col = m_Doc->PageColors["Black"];
486
QColor qcol = ScColorEngine::getRGBColor(col, m_Doc);
487
fill_gradient.addStop(qcol, 0.0, 0.5, 1.0, "Black", 100);
488
fill_gradient.addStop(qcol, 1.0, 0.5, 1.0, "Black", 100);
493
firstLineOffsetP = FLOPRealGlyphHeight;
494
Cols = m_Doc->toolSettings.dCols;
495
ColGap = m_Doc->toolSettings.dGap;
512
isGroupControl = false;
514
ChangedMasterItem = false;
516
OnMasterPage = m_Doc->currentPage()->pageName();
517
m_startArrowIndex = m_Doc->toolSettings.dStartArrow;
518
m_endArrowIndex = m_Doc->toolSettings.dEndArrow;
519
effectsInUse.clear();
520
//Page Item Attributes
521
pageItemAttributes.clear();
522
for(ObjAttrVector::Iterator objAttrIt = m_Doc->docItemAttributes.begin() ; objAttrIt != m_Doc->docItemAttributes.end(); ++objAttrIt )
524
if (((*objAttrIt).autoaddto=="textframes" && m_ItemType==TextFrame) ||
525
((*objAttrIt).autoaddto=="imageframes" && m_ItemType==ImageFrame)
527
pageItemAttributes.append(*objAttrIt);
529
tempImageFile = NULL;
530
isInlineImage = false;
533
void PageItem::setXPos(const double newXPos, bool drawingOnly)
536
if (drawingOnly || m_Doc->isLoading())
539
emit position(Xpos, Ypos);
542
void PageItem::setYPos(const double newYPos, bool drawingOnly)
545
if (drawingOnly || m_Doc->isLoading())
548
emit position(Xpos, Ypos);
551
void PageItem::setXYPos(const double newXPos, const double newYPos, bool drawingOnly)
555
if (drawingOnly || m_Doc->isLoading())
558
emit position(Xpos, Ypos);
561
void PageItem::moveBy(const double dX, const double dY, bool drawingOnly)
563
if (dX==0.0 && dY==0.0)
570
if (drawingOnly || m_Doc->isLoading())
573
emit position(Xpos, Ypos);
576
void PageItem::setWidth(const double newWidth)
581
emit widthAndHeight(Width, Height);
584
void PageItem::setHeight(const double newHeight)
589
emit widthAndHeight(Width, Height);
592
void PageItem::setWidthHeight(const double newWidth, const double newHeight, bool drawingOnly)
600
emit widthAndHeight(Width, Height);
603
void PageItem::setWidthHeight(const double newWidth, const double newHeight)
609
emit widthAndHeight(Width, Height);
612
void PageItem::resizeBy(const double dH, const double dW)
614
if (dH==0.0 && dW==0.0)
622
emit widthAndHeight(Width, Height);
625
void PageItem::setRotation(const double newRotation, bool drawingOnly)
629
if (drawingOnly || m_Doc->isLoading())
634
void PageItem::rotateBy(const double dR)
643
void PageItem::setSelected(const bool toSelect)
648
void PageItem::setImageXScale(const double newImageXScale)
650
LocalScX=newImageXScale;
652
emit imageOffsetScale(LocalScX, LocalScY, LocalX, LocalY);
655
void PageItem::setImageYScale(const double newImageYScale)
657
LocalScY=newImageYScale;
659
emit imageOffsetScale(LocalScX, LocalScY, LocalX, LocalY);
662
void PageItem::setImageXYScale(const double newImageXScale, const double newImageYScale)
664
LocalScX=newImageXScale;
665
LocalScY=newImageYScale;
667
emit imageOffsetScale(LocalScX, LocalScY, LocalX, LocalY);
670
void PageItem::setImageXOffset(const double newImageXOffset)
672
LocalX=newImageXOffset;
674
emit imageOffsetScale(LocalScX, LocalScY, LocalX, LocalY);
677
void PageItem::setImageYOffset(const double newImageYOffset)
679
LocalY=newImageYOffset;
681
emit imageOffsetScale(LocalScX, LocalScY, LocalX, LocalY);
684
void PageItem::setImageXYOffset(const double newImageXOffset, const double newImageYOffset)
686
LocalX=newImageXOffset;
687
LocalY=newImageYOffset;
689
emit imageOffsetScale(LocalScX, LocalScY, LocalX, LocalY);
692
void PageItem::moveImageXYOffsetBy(const double dX, const double dY)
694
if (dX==0.0 && dY==0.0)
701
emit imageOffsetScale(LocalScX, LocalScY, LocalX, LocalY);
704
void PageItem::setReversed(bool newReversed)
706
if (Reverse == newReversed)
708
if (UndoManager::undoEnabled())
710
SimpleState *ss = new SimpleState(Um::FlipH, 0, Um::IFlipH);
711
ss->set("REVERSE_TEXT", newReversed);
712
undoManager->action(this, ss);
714
Reverse = newReversed;
717
//return frame where is text end
718
PageItem * PageItem::frameTextEnd()
720
PageItem * LastBox = this;
721
if (frameOverflows() && NextBox)
722
{ // text ending in some next frame
724
while (LastBox != 0 && !LastBox->frameDisplays(itemText.length()-1))
725
LastBox = LastBox->nextInChain();
727
else if (frameUnderflows() && BackBox)
728
{ //text ending in some previous frame
730
while (LastBox != 0 && !LastBox->frameDisplays(itemText.length()-1))
731
LastBox = LastBox->prevInChain();
736
/// returns true if text overflows
737
bool PageItem::frameOverflows() const
740
// Fix #6991 : "Text overflow" warning when there is a text underflow in fact
741
/*return NextBox == NULL && itemText.length() > static_cast<int>(MaxChars);*/
742
return ( NextBox == NULL )
743
&& ( static_cast<int> ( firstChar ) < itemText.length() )
744
// Fix #7766 : scribus.textOverflows() returns 0 if there is no place for the overflow mark
745
/*&& ( firstChar < MaxChars )*/
746
&& ( firstChar <= MaxChars )
747
&& ( itemText.length() > static_cast<int> ( MaxChars ) );
749
return false; // FIXME:NLS
753
/// returns true if text is ending before that frame
754
bool PageItem::frameUnderflows() const
758
//FIX ME - I have found that condition if frame is empty
759
//and has been linked with previous frame
760
//if you will find any better solution - fix that function
761
return (firstInFrame() > lastInFrame());
764
int PageItem::firstInFrame() const
768
int PageItem::lastInFrame() const
771
return qMin(signed(MaxChars), itemText.length()) - 1;
773
return itemText.length() - 1;
777
bool PageItem::testLinkCandidate(PageItem* nxt)
779
if (this->nextInChain() )
781
if (nxt->prevInChain() )
783
for (PageItem* ff=nxt; ff; ff=ff->nextInChain())
785
if (ff == this) return false;
790
void PageItem::link(PageItem* nxt)
792
assert( !nextInChain() );
793
assert( !nxt->prevInChain() );
794
for (PageItem* ff=nxt; ff; ff=ff->nextInChain())
798
// Append only if necessary to avoid the
799
// charstyle: access at end of text warning
800
if (nxt->itemText.length() > 0)
801
itemText.append(nxt->itemText);
807
PageItem* after = nxt;
810
after->isAutoText = true;
811
m_Doc->LastAuto = after;
812
after = after->NextBox;
815
else if (nxt->isAutoText)
817
PageItem* before = this;
820
before->isAutoText = true;
821
m_Doc->FirstAuto = before;
822
before = before->BackBox;
828
nxt->itemText = itemText;
833
if (UndoManager::undoEnabled())
835
ItemState<std::pair<PageItem*, PageItem*> > *is = new ItemState<std::pair<PageItem*, PageItem*> >(UndoManager::LinkTextFrame);
836
is->set("LINK_TEXT_FRAME", "linkTextFrame");
837
is->setItem(std::pair<PageItem*, PageItem*>(this, NextBox));
838
undoManager->action(this, is);
842
void PageItem::unlink()
846
PageItem *undoNextBox=NextBox;
847
// make sure lastInFrame is valid
850
//<< CB #6332: Stop the StoryText cut and break and act like other publishing apps
851
// move following text to new StoryText
852
itemText.select(lastInFrame()+1, itemText.length()-lastInFrame()-1);
854
StoryText follow(m_Doc);
856
follow.setDefaultStyle(itemText.defaultStyle());
857
follow.insert(0, itemText, true);
858
// remove following text from this chain
859
itemText.removeSelection();
862
// update auto pointers
865
PageItem* before = this;
868
before->isAutoText = false;
869
before = before->BackBox;
871
m_Doc->FirstAuto = NextBox;
873
// link following frames to new text
874
NextBox->firstChar = 0;
875
NextBox->BackBox = NULL;
877
NextBox->itemText = follow;
878
NextBox->invalid = true;
879
NextBox->firstChar = 0;
880
NextBox = NextBox->NextBox;
882
// NextBox == NULL now
884
if (UndoManager::undoEnabled())
886
ItemState<std::pair<PageItem*, PageItem*> > *is = new ItemState<std::pair<PageItem*, PageItem*> >(UndoManager::UnlinkTextFrame);
887
is->set("UNLINK_TEXT_FRAME", "unlinkTextFrame");
888
is->setItem(std::pair<PageItem*, PageItem*>(this, undoNextBox));
889
undoManager->action(this, is);
895
void PageItem::dropLinks()
897
// update auto pointers
898
if (isAutoText && NextBox == 0)
900
m_Doc->LastAuto = BackBox;
902
if (isAutoText && BackBox == 0)
904
m_Doc->FirstAuto = NextBox;
908
// leave text in remaining chain
909
PageItem* before = BackBox;
910
PageItem* after = NextBox;
911
if (after != 0 || before != 0)
913
itemText = StoryText(m_Doc);
915
before->NextBox = after;
918
after->BackBox = before;
921
after->invalid = true;
922
after->firstChar = 0;
923
after = after->NextBox;
926
// JG we should set BackBox and NextBox to NULL at a point
927
BackBox = NextBox = NULL;
931
/// tests if a character is displayed by this frame
932
bool PageItem::frameDisplays(int textpos) const
935
return 0 <= textpos && textpos < signed(MaxChars) && textpos < itemText.length();
937
return true; // FIXME:NLS
942
/// returns the style at the current charpos
943
const ParagraphStyle& PageItem::currentStyle() const
945
if (frameDisplays(itemText.cursorPosition()))
946
return itemText.paragraphStyle();
948
return itemText.defaultStyle();
951
/// returns the style at the current charpos for changing
952
ParagraphStyle& PageItem::changeCurrentStyle()
954
if (frameDisplays(itemText.cursorPosition()))
955
return const_cast<ParagraphStyle&>(itemText.paragraphStyle());
957
return const_cast<ParagraphStyle&>(itemText.defaultStyle());
960
/// returns the style at the current charpos
961
const CharStyle& PageItem::currentCharStyle() const
963
if (frameDisplays(itemText.cursorPosition()))
964
return itemText.charStyle();
966
return itemText.defaultStyle().charStyle();
969
void PageItem::setTextToFrameDistLeft(double newLeft)
972
emit textToFrameDistances(Extra, TExtra, BExtra, RExtra);
975
void PageItem::setTextToFrameDistRight(double newRight)
978
emit textToFrameDistances(Extra, TExtra, BExtra, RExtra);
981
void PageItem::setTextToFrameDistTop(double newTop)
984
emit textToFrameDistances(Extra, TExtra, BExtra, RExtra);
987
void PageItem::setTextToFrameDistBottom(double newBottom)
990
emit textToFrameDistances(Extra, TExtra, BExtra, RExtra);
993
void PageItem::setTextToFrameDist(double newLeft, double newRight, double newTop, double newBottom)
999
emit textToFrameDistances(Extra, TExtra, BExtra, RExtra);
1002
double PageItem::gridOffset() const { return m_Doc->typographicSettings.offsetBaseGrid; }
1003
double PageItem::gridDistance() const { return m_Doc->typographicSettings.valueBaseGrid; }
1005
void PageItem::setGridOffset(double) { } // FIXME
1006
void PageItem::setGridDistance(double) { } // FIXME
1007
void PageItem::setColumns(int n)
1009
Cols = qMax(1, n); //FIXME: undo
1011
void PageItem::setColumnGap(double gap)
1013
ColGap = gap; //FIXME: undo
1016
void PageItem::setCornerRadius(double newRadius)
1019
emit cornerRadius(RadRect);
1030
/** Paints the item.
1031
CHANGE: cullingArea is in doc coordinates!
1033
void PageItem::DrawObj(ScPainter *p, QRectF cullingArea)
1035
// qDebug << "PageItem::DrawObj";
1037
if (!m_Doc->DoDrawing)
1042
if (cullingArea.isNull())
1044
cullingArea = QRectF(QPointF(m_Doc->minCanvasCoordinate.x(), m_Doc->minCanvasCoordinate.y()),
1045
QPointF(m_Doc->maxCanvasCoordinate.x(), m_Doc->maxCanvasCoordinate.y())).toAlignedRect();
1049
if (m_Doc->layerOutline(LayerNr))
1051
if ((itemType()==TextFrame || itemType()==ImageFrame || itemType()==PathText || itemType()==Line || itemType()==PolyLine) && (!isGroupControl))
1052
DrawObj_Item(p, cullingArea, sc);
1056
if (!isGroupControl)
1057
DrawObj_Item(p, cullingArea, sc);
1062
void PageItem::DrawObj_Pre(ScPainter *p, double &sc)
1064
ScribusView* view = m_Doc->view();
1068
p->translate(Xpos, Ypos);
1070
if (m_Doc->layerOutline(LayerNr))
1072
p->setPen(m_Doc->layerMarker(LayerNr), 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
1073
p->setFillMode(ScPainter::None);
1074
p->setBrushOpacity(1.0);
1075
p->setPenOpacity(1.0);
1079
if (!isGroupControl)
1081
if (fillBlendmode() != 0)
1082
p->beginLayer(1.0 - fillTransparency(), fillBlendmode());
1084
p->setLineWidth(m_lineWidth);
1089
if ((patternVal.isEmpty()) || (!m_Doc->docPatterns.contains(patternVal)))
1091
p->fill_gradient = VGradient(VGradient::linear);
1092
if (fillColor() != CommonStrings::None)
1094
p->setBrush(fillQColor);
1095
p->setFillMode(ScPainter::Solid);
1098
p->setFillMode(ScPainter::None);
1099
if ((!patternVal.isEmpty()) && (!m_Doc->docPatterns.contains(patternVal)))
1107
p->setPattern(&m_Doc->docPatterns[patternVal], patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation);
1108
p->setFillMode(ScPainter::Pattern);
1113
if (fill_gradient.Stops() < 2) // fall back to solid filling if there are not enough colorstops in the gradient.
1115
if (fillColor() != CommonStrings::None)
1117
p->setBrush(fillQColor);
1118
p->setFillMode(ScPainter::Solid);
1121
p->setFillMode(ScPainter::None);
1125
p->setFillMode(ScPainter::Gradient);
1126
p->fill_gradient = fill_gradient;
1137
p->setGradient(VGradient::linear, FPoint(GrStartX, GrStartY), FPoint(GrEndX, GrEndY));
1141
gra.setPoints(2, GrStartX, GrStartY, GrEndX, GrEndY);
1142
p->setGradient(VGradient::radial, gra.point(0), gra.point(1), gra.point(0));
1150
p->fill_gradient = VGradient(VGradient::linear);
1151
if (fillColor() != CommonStrings::None)
1153
p->setBrush(fillQColor);
1154
p->setFillMode(ScPainter::Solid);
1157
p->setFillMode(ScPainter::None);
1159
if (lineColor() != CommonStrings::None)
1161
// if ((m_lineWidth == 0) && ! asLine())
1162
// p->setLineWidth(0);
1165
p->setPen(strokeQColor, m_lineWidth, PLineArt, PLineEnd, PLineJoin);
1166
if (DashValues.count() != 0)
1167
p->setDash(DashValues, DashOffset);
1172
if (fillBlendmode() == 0)
1173
p->setBrushOpacity(1.0 - fillTransparency());
1174
if (lineBlendmode() == 0)
1175
p->setPenOpacity(1.0 - lineTransparency());
1176
p->setFillRule(fillRule);
1181
void PageItem::DrawObj_Post(ScPainter *p)
1184
ScribusView* view = m_Doc->view();
1185
if (!isGroupControl)
1187
if (m_Doc->layerOutline(LayerNr))
1189
if (itemType()!=Line)
1191
p->setPen(m_Doc->layerMarker(LayerNr), 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
1192
p->setFillMode(ScPainter::None);
1193
p->setBrushOpacity(1.0);
1194
p->setPenOpacity(1.0);
1195
if (itemType()==PolyLine)
1196
p->setupPolygon(&PoLine, false);
1197
else if (itemType() == PathText)
1200
p->setupPolygon(&PoLine, false);
1205
p->setupPolygon(&PoLine);
1208
if (itemType()==ImageFrame)
1210
if (imageClip.size() != 0)
1212
p->setupPolygon(&imageClip);
1220
if (fillBlendmode() != 0)
1222
if (itemType()==PathText || itemType()==PolyLine || itemType()==Line)
1224
if ((doStroke) && (!m_Doc->RePos))
1226
if (lineBlendmode() != 0)
1227
p->beginLayer(1.0 - lineTransparency(), lineBlendmode());
1228
// if (lineColor() != CommonStrings::None)
1230
// p->setPen(strokeQColor, m_lineWidth, PLineArt, PLineEnd, PLineJoin);
1231
// if (DashValues.count() != 0)
1232
// p->setDash(DashValues, DashOffset);
1235
// p->setLineWidth(0);
1238
if ((itemType() == LatexFrame) || (itemType() == ImageFrame))
1239
p->setupPolygon(&PoLine);
1240
if (NamedLStyle.isEmpty())
1242
if (lineColor() != CommonStrings::None)
1244
p->setPen(strokeQColor, m_lineWidth, PLineArt, PLineEnd, PLineJoin);
1245
if (DashValues.count() != 0)
1246
p->setDash(DashValues, DashOffset);
1252
multiLine ml = m_Doc->MLineStyles[NamedLStyle];
1254
for (int it = ml.size()-1; it > -1; it--)
1256
struct SingleLine& sl = ml[it];
1257
// Qt4 if ((!sl.Color != CommonStrings::None) && (sl.Width != 0))
1258
if (sl.Color != CommonStrings::None) // && (sl.Width != 0))
1260
SetQColor(&tmp, sl.Color, sl.Shade);
1261
p->setPen(tmp, sl.Width, static_cast<Qt::PenStyle>(sl.Dash), static_cast<Qt::PenCapStyle>(sl.LineEnd), static_cast<Qt::PenJoinStyle>(sl.LineJoin));
1267
if (lineBlendmode() != 0)
1272
if ((!isEmbedded) && (!m_Doc->RePos))
1274
double aestheticFactor(3.33);
1275
double scpInv = 1.0 / (view->scale() * aestheticFactor);
1276
if (!isGroupControl)
1278
if ((Frame) && (m_Doc->guidesSettings.framesShown) && ((itemType() == ImageFrame) || (itemType() == LatexFrame) || (itemType() == PathText)))
1280
p->setPen(PrefsManager::instance()->appPrefs.DFrameNormColor, scpInv, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
1281
if ((isBookmark) || (m_isAnnotation))
1282
p->setPen(PrefsManager::instance()->appPrefs.DFrameAnnotationColor, scpInv, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
1283
if ((BackBox != 0) || (NextBox != 0))
1284
p->setPen(PrefsManager::instance()->appPrefs.DFrameLinkColor, scpInv, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
1286
p->setPen(PrefsManager::instance()->appPrefs.DFrameLockColor, scpInv, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
1288
if (itemType()==PathText)
1290
if (Clip.count() != 0)
1293
FPoint np = FPoint(Clip.point(0));
1295
tclip.setPoint(0, np);
1296
tclip.setPoint(1, np);
1297
for (int a = 1; a < Clip.size(); ++a)
1299
np = FPoint(Clip.point(a));
1300
tclip.putPoints(tclip.size(), 4, np.x(), np.y(), np.x(), np.y(), np.x(), np.y(), np.x(), np.y());
1302
np = FPoint(Clip.point(0));
1303
tclip.putPoints(tclip.size(), 2, np.x(), np.y(), np.x(), np.y());
1304
p->setupPolygon(&tclip);
1308
// Ugly Hack to fix rendering problems with cairo >=1.5.10 && <1.8.0 follows
1310
#if ((CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 5, 10)) && (CAIRO_VERSION < CAIRO_VERSION_ENCODE(1, 8, 0)))
1311
p->setupPolygon(&PoLine, false);
1313
p->setupPolygon(&PoLine);
1316
p->setupPolygon(&PoLine);
1321
if ((m_Doc->guidesSettings.framesShown) && textFlowUsesContourLine() && (ContourLine.size() != 0))
1323
p->setPen(Qt::darkGray, scpInv, Qt::DotLine, Qt::FlatCap, Qt::MiterJoin);
1324
// Ugly Hack to fix rendering problems with cairo >=1.5.10 && <1.8.0 follows
1326
#if ((CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 5, 10)) && (CAIRO_VERSION < CAIRO_VERSION_ENCODE(1, 8, 0)))
1327
p->setupPolygon(&ContourLine, false);
1329
p->setupPolygon(&ContourLine);
1332
p->setupPolygon(&ContourLine);
1336
if ((m_Doc->guidesSettings.layerMarkersShown) && (m_Doc->layerCount() > 1) && (!m_Doc->layerOutline(LayerNr)) && ((isGroupControl) || (Groups.count() == 0)) && (!view->m_canvas->isPreviewMode()))
1338
p->setPen(Qt::black, 0.5 / m_Doc->view()->scale(), Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
1339
p->setPenOpacity(1.0);
1340
p->setBrush(m_Doc->layerMarker(LayerNr));
1341
p->setBrushOpacity(1.0);
1342
p->setFillMode(ScPainter::Solid);
1344
double ofx = Width - ofwh/2;
1345
double ofy = Height - ofwh*3;
1346
p->drawRect(ofx, ofy, ofwh, ofwh);
1348
//CB disabled for now
1349
//if (m_Doc->m_Selection->findItem(this)!=-1)
1350
// drawLockedMarker(p);
1357
void PageItem::DrawObj_Embedded(ScPainter *p, QRectF cullingArea, const CharStyle& style, PageItem* cembedded)
1361
if (!m_Doc->DoDrawing)
1363
QList<PageItem*> emG;
1364
QStack<PageItem*> groupStack;
1367
emG.append(cembedded);
1368
if (cembedded->Groups.count() != 0)
1370
for (int ga=0; ga<m_Doc->FrameItems.count(); ++ga)
1372
if (m_Doc->FrameItems.at(ga)->Groups.count() != 0)
1374
if (m_Doc->FrameItems.at(ga)->Groups.top() == cembedded->Groups.top())
1376
if (m_Doc->FrameItems.at(ga)->ItemNr != cembedded->ItemNr)
1378
if (!emG.contains(m_Doc->FrameItems.at(ga)))
1379
emG.append(m_Doc->FrameItems.at(ga));
1385
for (int em = 0; em < emG.count(); ++em)
1387
PageItem* embedded = emG.at(em);
1388
if (embedded->isGroupControl)
1391
FPointArray cl = embedded->PoLine.copy();
1393
mm.translate((embedded->gXpos * (style.scaleH() / 1000.0)), ( - (embedded->gHeight * (style.scaleV() / 1000.0)) + embedded->gYpos * (style.scaleV() / 1000.0)));
1394
if (style.baselineOffset() != 0)
1395
mm.translate(0, -embedded->gHeight * (style.baselineOffset() / 1000.0));
1396
mm.scale(style.scaleH() / 1000.0, style.scaleV() / 1000.0);
1397
mm.rotate(embedded->rotation());
1399
p->beginLayer(1.0 - embedded->fillTransparency(), embedded->fillBlendmode(), &cl);
1400
groupStack.push(embedded->groupsLastItem);
1404
double x = embedded->xPos();
1405
double y = embedded->yPos();
1406
embedded->Xpos = embedded->gXpos;
1407
embedded->Ypos = (embedded->gHeight * (style.scaleV() / 1000.0)) + embedded->gYpos;
1408
p->translate((embedded->gXpos * (style.scaleH() / 1000.0)), ( - (embedded->gHeight * (style.scaleV() / 1000.0)) + embedded->gYpos * (style.scaleV() / 1000.0)));
1409
if (style.baselineOffset() != 0)
1411
p->translate(0, -embedded->gHeight * (style.baselineOffset() / 1000.0));
1412
embedded->Ypos -= embedded->gHeight * (style.baselineOffset() / 1000.0);
1414
p->scale(style.scaleH() / 1000.0, style.scaleV() / 1000.0);
1415
embedded->Dirty = Dirty;
1416
embedded->invalid = true;
1418
double pws = embedded->m_lineWidth;
1419
embedded->DrawObj_Pre(p, sc);
1420
switch(embedded->itemType())
1427
embedded->DrawObj_Item(p, cullingArea, sc);
1431
embedded->m_lineWidth = pws * qMin(style.scaleH() / 1000.0, style.scaleV() / 1000.0);
1432
embedded->DrawObj_Item(p, cullingArea, sc);
1437
embedded->m_lineWidth = pws * qMin(style.scaleH() / 1000.0, style.scaleV() / 1000.0);
1438
embedded->DrawObj_Post(p);
1442
if (groupStack.count() != 0)
1444
while (embedded == groupStack.top())
1449
if (groupStack.count() == 0)
1453
embedded->m_lineWidth = pws;
1455
for (int em = 0; em < emG.count(); ++em)
1457
PageItem* embedded = emG.at(em);
1458
if (!embedded->isTableItem)
1461
double x = embedded->xPos();
1462
double y = embedded->yPos();
1463
embedded->Xpos = embedded->gXpos;
1464
embedded->Ypos = (embedded->gHeight * (style.scaleV() / 1000.0)) + embedded->gYpos;
1465
p->translate((embedded->gXpos * (style.scaleH() / 1000.0)), ( - (embedded->gHeight * (style.scaleV() / 1000.0)) + embedded->gYpos * (style.scaleV() / 1000.0)));
1466
if (style.baselineOffset() != 0)
1468
p->translate(0, -embedded->gHeight * (style.baselineOffset() / 1000.0));
1469
embedded->Ypos -= embedded->gHeight * (style.baselineOffset() / 1000.0);
1471
p->scale(style.scaleH() / 1000.0, style.scaleV() / 1000.0);
1472
p->rotate(embedded->rotation());
1473
double pws = embedded->m_lineWidth;
1474
embedded->m_lineWidth = pws * qMin(style.scaleH() / 1000.0, style.scaleV() / 1000.0);
1475
if ((embedded->lineColor() != CommonStrings::None) && (embedded->lineWidth() != 0.0))
1478
embedded->SetQColor(&tmp, embedded->lineColor(), embedded->lineShade());
1479
if ((embedded->TopLine) || (embedded->RightLine) || (embedded->BottomLine) || (embedded->LeftLine))
1481
p->setPen(tmp, embedded->lineWidth(), embedded->PLineArt, Qt::SquareCap, embedded->PLineJoin);
1482
if (embedded->TopLine)
1483
p->drawLine(FPoint(0.0, 0.0), FPoint(embedded->width(), 0.0));
1484
if (embedded->RightLine)
1485
p->drawLine(FPoint(embedded->width(), 0.0), FPoint(embedded->width(), embedded->height()));
1486
if (embedded->BottomLine)
1487
p->drawLine(FPoint(embedded->width(), embedded->height()), FPoint(0.0, embedded->height()));
1488
if (embedded->LeftLine)
1489
p->drawLine(FPoint(0.0, embedded->height()), FPoint(0.0, 0.0));
1492
embedded->m_lineWidth = pws;
1500
void PageItem::paintObj(QPainter *p)
1502
if ((!m_Doc->DoDrawing) || (m_Doc->RePos))
1507
double sc = m_Doc->view()->scale();
1508
double handleSize = 6.0 / sc;
1509
double halfSize = 3.0 / sc;
1510
if ((!FrameOnly) && (!m_Doc->RePos))
1512
if (!m_Doc->m_Selection->isEmpty())
1514
// qDebug() << "Item: " << ItemNr << "W: " << Width << "H: " << Height;
1515
if (Groups.count() == 0)
1517
//Locked line colour selection
1519
p->setPen(QPen(PrefsManager::instance()->appPrefs.DFrameLockColor, 1.0 / sc, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
1521
p->setPen(QPen(PrefsManager::instance()->appPrefs.DFrameColor, 1.0 / sc, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
1522
p->setBrush(Qt::NoBrush);
1523
double lw2 = 1.0 / sc;
1524
double lw = 1.0 / sc;
1525
Qt::PenCapStyle le = Qt::FlatCap;
1526
if (NamedLStyle.isEmpty())
1528
lw2 = (m_lineWidth / 2.0) / sc;
1529
lw = qMax(m_lineWidth, 1.0) / sc;
1534
multiLine ml = m_Doc->MLineStyles[NamedLStyle];
1535
lw2 = (ml[ml.size()-1].Width / 2.0) / sc;
1536
lw = qMax(ml[ml.size()-1].Width, 1.0) / sc;
1537
le = static_cast<Qt::PenCapStyle>(ml[ml.size()-1].LineEnd);
1539
//Draw our frame outline
1542
if (le != Qt::FlatCap)
1543
p->drawRect(QRectF(-lw2, -lw2, Width+lw, lw));
1545
p->drawRect(QRectF(-1 / sc, -lw2, Width, lw));
1548
p->drawRect(QRectF(0, 0, Width, Height));
1549
// p->setPen(QPen(PrefsManager::instance()->appPrefs.DFrameColor, 1.0 / sc, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
1550
p->setBrush(PrefsManager::instance()->appPrefs.DFrameColor);
1551
p->setPen(Qt::NoPen);
1552
if ((!m_Locked) && (!m_SizeLocked))
1556
p->drawRect(QRectF(0.0, 0.0, handleSize, handleSize));
1557
p->drawRect(QRectF(Width - handleSize, Height - handleSize, handleSize, handleSize));
1558
p->drawRect(QRectF(Width - handleSize, 0.0, handleSize, handleSize));
1559
p->drawRect(QRectF(0.0, Height - handleSize, handleSize, handleSize));
1562
p->drawRect(QRectF(Width / 2.0 - halfSize, Height - handleSize, handleSize, handleSize));
1563
p->drawRect(QRectF(Width / 2.0 - halfSize, 0.0, handleSize, handleSize));
1567
p->drawRect(QRectF(Width - handleSize, Height / 2.0 - halfSize, handleSize, handleSize));
1568
p->drawRect(QRectF(0.0, Height / 2.0 - halfSize, handleSize, handleSize));
1573
p->drawRect(QRectF(-halfSize, -halfSize, handleSize, handleSize));
1574
p->drawRect(QRectF(Width + halfSize, -halfSize, -handleSize, handleSize));
1580
p->setPen(QPen(PrefsManager::instance()->appPrefs.DFrameGroupColor, 1.0 / sc, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
1581
p->setBrush(Qt::NoBrush);
1582
p->drawRect(QRectF(0.0, 0.0, Width, Height));
1583
if (m_Doc->m_Selection->count() == 1)
1585
p->setPen(Qt::NoPen);
1586
// p->setPen(QPen(PrefsManager::instance()->appPrefs.DFrameGroupColor, 1.0 / sc, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
1587
p->setBrush(PrefsManager::instance()->appPrefs.DFrameGroupColor);
1588
p->drawRect(QRectF(0.0, 0.0, handleSize, handleSize));
1589
p->drawRect(QRectF(Width - handleSize, Height - handleSize, handleSize, handleSize));
1590
p->drawRect(QRectF(Width - handleSize, 0.0, handleSize, handleSize));
1591
p->drawRect(QRectF(0.0, Height - handleSize, handleSize, handleSize));
1594
p->drawRect(QRectF(Width / 2.0 - halfSize, Height - handleSize, handleSize, handleSize));
1595
p->drawRect(QRectF(Width / 2.0 - halfSize, 0.0, handleSize, handleSize));
1599
p->drawRect(QRectF(Width - handleSize, Height / 2.0 - halfSize, handleSize, handleSize));
1600
p->drawRect(QRectF(0.0, Height / 2.0 - halfSize, handleSize, handleSize));
1609
QImage PageItem::DrawObj_toImage()
1611
QList<PageItem*> emG;
1613
double minx = std::numeric_limits<double>::max();
1614
double miny = std::numeric_limits<double>::max();
1615
double maxx = -std::numeric_limits<double>::max();
1616
double maxy = -std::numeric_limits<double>::max();
1617
if (Groups.count() != 0)
1619
for (int ga=0; ga<m_Doc->Items->count(); ++ga)
1621
if (m_Doc->Items->at(ga)->Groups.count() != 0)
1623
if (m_Doc->Items->at(ga)->Groups.top() == Groups.top())
1625
if (!emG.contains(m_Doc->Items->at(ga)))
1627
emG.append(m_Doc->Items->at(ga));
1628
PageItem *currItem = m_Doc->Items->at(ga);
1629
double x1, x2, y1, y2;
1630
currItem->getVisualBoundingRect(&x1, &y1, &x2, &y2);
1631
minx = qMin(minx, x1);
1632
miny = qMin(miny, y1);
1633
maxx = qMax(maxx, x2);
1634
maxy = qMax(maxy, y2);
1639
for (int em = 0; em < emG.count(); ++em)
1641
PageItem* currItem = emG.at(em);
1642
currItem->gXpos = currItem->xPos() - minx;
1643
currItem->gYpos = currItem->yPos() - miny;
1644
currItem->gWidth = maxx - minx;
1645
currItem->gHeight = maxy - miny;
1650
double x1, x2, y1, y2;
1651
getVisualBoundingRect(&x1, &y1, &x2, &y2);
1652
minx = qMin(minx, x1);
1653
miny = qMin(miny, y1);
1654
maxx = qMax(maxx, x2);
1655
maxy = qMax(maxy, y2);
1656
gXpos = xPos() - minx;
1657
gYpos = yPos() - miny;
1658
gWidth = maxx - minx;
1659
gHeight = maxy - miny;
1662
return DrawObj_toImage(emG);
1665
QImage PageItem::DrawObj_toImage(QList<PageItem*> &emG)
1667
QImage retImg = QImage(qRound(gWidth), qRound(gHeight), QImage::Format_ARGB32);
1668
// retImg.fill( qRgba(255, 255, 255, 0) );
1669
retImg.fill( qRgba(0, 0, 0, 0) );
1670
ScPainter *painter = new ScPainter(&retImg, retImg.width(), retImg.height(), 1, 0);
1671
// painter->setZoomFactor(1.0);
1672
painter->setZoomFactor(qMax(qRound(gWidth) / gWidth, qRound(gHeight) / gHeight));
1673
QStack<PageItem*> groupStack;
1674
for (int em = 0; em < emG.count(); ++em)
1676
PageItem* embedded = emG.at(em);
1677
if (embedded->isGroupControl)
1680
FPointArray cl = embedded->PoLine.copy();
1682
mm.translate(embedded->gXpos, embedded->gYpos);
1683
mm.rotate(embedded->rotation());
1685
painter->beginLayer(1.0 - embedded->fillTransparency(), embedded->fillBlendmode(), &cl);
1686
groupStack.push(embedded->groupsLastItem);
1690
// qDebug()<<embedded<<embedded->xPos()<<embedded->yPos()<<embedded->gXpos<<embedded->gYpos;
1691
// double x = embedded->xPos();
1692
// double y = embedded->yPos();
1693
// embedded->Xpos = embedded->gXpos;
1694
// embedded->Ypos = embedded->gYpos;
1695
// Seems to work without all this coordinates mess. To monitor tho
1696
painter->translate(embedded->gXpos, embedded->gYpos);
1697
embedded->isEmbedded = true;
1698
embedded->invalid = true;
1699
embedded->DrawObj(painter, QRectF());
1700
// embedded->Xpos = x;
1701
// embedded->Ypos = y;
1702
embedded->isEmbedded = false;
1704
if (groupStack.count() != 0)
1706
while (embedded == groupStack.top())
1708
painter->endLayer();
1711
if (groupStack.count() == 0)
1716
for (int em = 0; em < emG.count(); ++em)
1718
PageItem* embedded = emG.at(em);
1719
if (!embedded->isTableItem)
1722
// double x = embedded->xPos();
1723
// double y = embedded->yPos();
1724
// embedded->Xpos = embedded->gXpos;
1725
// embedded->Ypos = embedded->gYpos;
1726
painter->translate(embedded->gXpos, embedded->gYpos);
1727
painter->rotate(embedded->rotation());
1728
embedded->isEmbedded = true;
1729
embedded->invalid = true;
1730
if ((embedded->lineColor() != CommonStrings::None) && (embedded->lineWidth() != 0.0))
1733
embedded->SetQColor(&tmp, embedded->lineColor(), embedded->lineShade());
1734
if ((embedded->TopLine) || (embedded->RightLine) || (embedded->BottomLine) || (embedded->LeftLine))
1736
painter->setPen(tmp, embedded->lineWidth(), embedded->PLineArt, Qt::SquareCap, embedded->PLineJoin);
1737
if (embedded->TopLine)
1738
painter->drawLine(FPoint(0.0, 0.0), FPoint(embedded->width(), 0.0));
1739
if (embedded->RightLine)
1740
painter->drawLine(FPoint(embedded->width(), 0.0), FPoint(embedded->width(), embedded->height()));
1741
if (embedded->BottomLine)
1742
painter->drawLine(FPoint(embedded->width(), embedded->height()), FPoint(0.0, embedded->height()));
1743
if (embedded->LeftLine)
1744
painter->drawLine(FPoint(0.0, embedded->height()), FPoint(0.0, 0.0));
1747
embedded->isEmbedded = false;
1748
// embedded->Xpos = x;
1749
// embedded->Ypos = y;
1757
QString PageItem::ExpandToken(uint base)
1760
QChar ch = itemText.text(base);
1762
if (ch == SpecialChars::PAGENUMBER)
1764
// compatibility mode: ignore subsequent pagenumber chars
1765
if (base > 0 && itemText.text(base-1) == SpecialChars::PAGENUMBER)
1767
if ((!m_Doc->masterPageMode()) && (OwnPage != -1))
1770
//CB Section numbering
1771
chstr = out.arg(m_Doc->getSectionPageNumberForPageIndex(OwnPage), -(int)zae);
1776
else if (ch == SpecialChars::PAGECOUNT)
1778
if (!m_Doc->masterPageMode())
1781
int key = m_Doc->getSectionKeyForPageIndex(OwnPage);
1784
chstr = out.arg(getStringFromSequence(m_Doc->sections[key].type, m_Doc->sections[key].toindex - m_Doc->sections[key].fromindex + 1));
1792
void PageItem::SetQColor(QColor *tmp, QString farbe, double shad)
1794
const ScColor& col = m_Doc->PageColors[farbe];
1795
*tmp = ScColorEngine::getShadeColorProof(col, m_Doc, shad);
1796
if ((m_Doc->view()) && (m_Doc->view()->m_canvas->usePreviewVisual()))
1798
VisionDefectColor defect;
1799
*tmp = defect.convertDefect(*tmp, m_Doc->view()->m_canvas->previewVisual());
1804
layout glyphs translates the chars into a number of glyphs, applying the Charstyle
1805
'style'. The following fields are set in layout: glyph, more, scaleH, scaleV, xoffset, yoffset, xadvance.
1806
If the DropCap-bit in style.effects is set and yadvance is > 0, scaleH/V, x/yoffset and xadvance
1807
are modified to scale the glyphs to this height.
1808
Otherwise yadvance is set to the max ascender of all generated glyphs.
1809
It scales according to smallcaps and
1810
sets xadvance to the advance width without kerning. If more than one glyph
1811
is generated, kerning is included in all but the last xadvance.
1813
double PageItem::layoutGlyphs(const CharStyle& style, const QString& chars, GlyphLayout& layout)
1815
double retval = 0.0;
1816
double asce = style.font().ascent(style.fontSize() / 10.0);
1817
int chst = style.effects() & 1919;
1818
/* if (chars[0] == SpecialChars::ZWSPACE ||
1819
chars[0] == SpecialChars::ZWNBSPACE ||
1820
chars[0] == SpecialChars::NBSPACE ||
1821
chars[0] == SpecialChars::NBHYPHEN ||
1822
chars[0] == SpecialChars::SHYPHEN ||
1823
chars[0] == SpecialChars::PARSEP ||
1824
chars[0] == SpecialChars::COLBREAK ||
1825
chars[0] == SpecialChars::LINEBREAK ||
1826
chars[0] == SpecialChars::FRAMEBREAK ||
1827
chars[0] == SpecialChars::TAB)
1829
layout.glyph = ScFace::CONTROL_GLYPHS + chars[0].unicode();
1833
layout.glyph = style.font().char2CMap(chars[0].unicode());
1836
double tracking = 0.0;
1837
if ( (style.effects() & ScStyle_StartOfLine) == 0)
1838
tracking = style.fontSize() * style.tracking() / 10000.0;
1840
layout.xoffset = tracking;
1842
if (chst != ScStyle_Default)
1844
if (chst & ScStyle_Superscript)
1846
retval -= asce * m_Doc->typographicSettings.valueSuperScript / 100.0;
1847
layout.yoffset -= asce * m_Doc->typographicSettings.valueSuperScript / 100.0;
1848
layout.scaleV = layout.scaleH = qMax(m_Doc->typographicSettings.scalingSuperScript / 100.0, 10.0 / style.fontSize());
1850
else if (chst & ScStyle_Subscript)
1852
retval += asce * m_Doc->typographicSettings.valueSubScript / 100.0;
1853
layout.yoffset += asce * m_Doc->typographicSettings.valueSubScript / 100.0;
1854
layout.scaleV = layout.scaleH = qMax(m_Doc->typographicSettings.scalingSubScript / 100.0, 10.0 / style.fontSize());
1857
layout.scaleV = layout.scaleH = 1.0;
1859
layout.scaleH *= style.scaleH() / 1000.0;
1860
layout.scaleV *= style.scaleV() / 1000.0;
1861
if (chst & ScStyle_AllCaps)
1863
layout.glyph = style.font().char2CMap(chars[0].toUpper().unicode());
1865
if (chst & ScStyle_SmallCaps)
1867
double smallcapsScale = m_Doc->typographicSettings.valueSmallCaps / 100.0;
1868
QChar uc = chars[0].toUpper();
1871
layout.glyph = style.font().char2CMap(chars[0].toUpper().unicode());
1872
layout.scaleV *= smallcapsScale;
1873
layout.scaleH *= smallcapsScale;
1878
layout.scaleH = style.scaleH() / 1000.0;
1879
layout.scaleV = style.scaleV() / 1000.0;
1882
/* if (layout.glyph == (ScFace::CONTROL_GLYPHS + SpecialChars::NBSPACE.unicode())) {
1883
uint replGlyph = style.font().char2CMap(QChar(' '));
1884
layout.xadvance = style.font().glyphWidth(replGlyph, style.fontSize() / 10) * layout.scaleH;
1885
layout.yadvance = style.font().glyphBBox(replGlyph, style.fontSize() / 10).ascent * layout.scaleV;
1887
else if (layout.glyph == (ScFace::CONTROL_GLYPHS + SpecialChars::NBHYPHEN.unicode())) {
1888
uint replGlyph = style.font().char2CMap(QChar('-'));
1889
layout.xadvance = style.font().glyphWidth(replGlyph, style.fontSize() / 10) * layout.scaleH;
1890
layout.yadvance = style.font().glyphBBox(replGlyph, style.fontSize() / 10).ascent * layout.scaleV;
1892
else if (layout.glyph >= ScFace::CONTROL_GLYPHS) {
1893
layout.xadvance = 0;
1894
layout.yadvance = 0;
1898
layout.xadvance = style.font().glyphWidth(layout.glyph, style.fontSize() / 10) * layout.scaleH;
1899
layout.yadvance = style.font().glyphBBox(layout.glyph, style.fontSize() / 10).ascent * layout.scaleV;
1901
if (layout.xadvance > 0)
1902
layout.xadvance += tracking;
1904
if (chars.length() > 1) {
1906
layoutGlyphs(style, chars.mid(1), *layout.more);
1907
layout.xadvance += style.font().glyphKerning(layout.glyph, layout.more->glyph, style.fontSize() / 10) * layout.scaleH;
1908
if (layout.more->yadvance > layout.yadvance)
1909
layout.yadvance = layout.more->yadvance;
1917
void PageItem::drawGlyphs(ScPainter *p, const CharStyle& style, GlyphLayout& glyphs)
1919
uint glyph = glyphs.glyph;
1920
if ((m_Doc->guidesSettings.showControls) &&
1921
(glyph == style.font().char2CMap(QChar(' ')) || glyph >= ScFace::CONTROL_GLYPHS))
1923
bool stroke = false;
1924
if (glyph >= ScFace::CONTROL_GLYPHS)
1925
glyph -= ScFace::CONTROL_GLYPHS;
1928
QMatrix chma, chma4, chma5;
1930
if (glyph == SpecialChars::TAB.unicode())
1932
points = m_Doc->symTab.copy();
1933
chma4.translate(glyphs.xoffset + glyphs.xadvance - ((style.fontSize() / 10.0) * glyphs.scaleH * 0.7), glyphs.yoffset - ((style.fontSize() / 10.0) * glyphs.scaleV * 0.5));
1935
else if (glyph == SpecialChars::COLBREAK.unicode())
1937
points = m_Doc->symNewCol.copy();
1938
chma4.translate(glyphs.xoffset, glyphs.yoffset-((style.fontSize() / 10.0) * glyphs.scaleV * 0.6));
1940
else if (glyph == SpecialChars::FRAMEBREAK.unicode())
1942
points = m_Doc->symNewFrame.copy();
1943
chma4.translate(glyphs.xoffset, glyphs.yoffset-((style.fontSize() / 10.0) * glyphs.scaleV * 0.6));
1945
else if (glyph == SpecialChars::PARSEP.unicode())
1947
points = m_Doc->symReturn.copy();
1948
chma4.translate(glyphs.xoffset, glyphs.yoffset-((style.fontSize() / 10.0) * glyphs.scaleV * 0.8));
1950
else if (glyph == SpecialChars::LINEBREAK.unicode())
1952
points = m_Doc->symNewLine.copy();
1953
chma4.translate(glyphs.xoffset, glyphs.yoffset-((style.fontSize() / 10.0) * glyphs.scaleV * 0.4));
1955
else if (glyph == SpecialChars::NBSPACE.unicode() ||
1958
stroke = (glyph == 32);
1959
points = m_Doc->symNonBreak.copy();
1960
chma4.translate(glyphs.xoffset, glyphs.yoffset-((style.fontSize() / 10.0) * glyphs.scaleV * 0.4));
1962
else if (glyph == SpecialChars::NBHYPHEN.unicode())
1964
points = style.font().glyphOutline(style.font().char2CMap(QChar('-')), style.fontSize() / 100);
1965
chma4.translate(glyphs.xoffset, glyphs.yoffset-((style.fontSize() / 10.0) * glyphs.scaleV));
1967
else if (glyph == SpecialChars::SHYPHEN.unicode())
1970
points.addQuadPoint(0, -10, 0, -10, 0, -6, 0, -6);
1976
points.addQuadPoint(0, -10, 0, -10, 0, -9, 0, -9);
1977
points.addQuadPoint(0, -9, 0, -9, 1, -9, 1, -9);
1978
points.addQuadPoint(1, -9, 1, -9, 1, -10, 1, -10);
1979
points.addQuadPoint(1, -10, 1, -10, 0, -10, 0, -10);
1981
chma.scale(glyphs.scaleH * style.fontSize() / 100.0, glyphs.scaleV * style.fontSize() / 100.0);
1982
points.map(chma * chma4);
1983
p->setupPolygon(&points, true);
1984
QColor oldBrush = p->brush();
1985
p->setBrush( (style.effects() & ScStyle_SuppressSpace) ? Qt::green
1986
: PrefsManager::instance()->appPrefs.DControlCharColor);
1989
QColor tmp = p->pen();
1990
p->setPen(p->brush(), 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
1991
p->setLineWidth(style.fontSize() * glyphs.scaleV / 200.0);
1993
p->setPen(tmp, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
2000
p->setBrush(oldBrush);
2003
p->translate(glyphs.xadvance, 0);
2004
drawGlyphs(p, style, *glyphs.more);
2008
else if (glyph == (ScFace::CONTROL_GLYPHS + SpecialChars::NBSPACE.unicode()) ||
2009
glyph == (ScFace::CONTROL_GLYPHS + 32))
2010
glyph = style.font().char2CMap(QChar(' '));
2011
else if (glyph == (ScFace::CONTROL_GLYPHS + SpecialChars::NBHYPHEN.unicode()))
2012
glyph = style.font().char2CMap(QChar('-'));
2014
if (glyph >= ScFace::CONTROL_GLYPHS || (style.effects() & ScStyle_SuppressSpace)) {
2015
// qDebug("drawGlyphs: skipping %d", glyph);
2016
// all those are empty
2019
p->translate(glyphs.xadvance, 0);
2020
drawGlyphs(p, style, *glyphs.more);
2024
// if (style.font().canRender(QChar(glyph)))
2026
FPointArray gly = style.font().glyphOutline(glyph);
2027
// Do underlining first so you can get typographically correct
2028
// underlines when drawing a white outline
2029
if (((style.effects() & ScStyle_Underline) || ((style.effects() & ScStyle_UnderlineWords) && glyph != style.font().char2CMap(QChar(' ')))) && (style.strokeColor() != CommonStrings::None))
2032
if ((style.underlineOffset() != -1) || (style.underlineWidth() != -1))
2034
if (style.underlineOffset() != -1)
2035
st = (style.underlineOffset() / 1000.0) * (style.font().descent(style.fontSize() / 10.0));
2037
st = style.font().underlinePos(style.fontSize() / 10.0);
2038
if (style.underlineWidth() != -1)
2039
lw = (style.underlineWidth() / 1000.0) * (style.fontSize() / 10.0);
2041
lw = qMax(style.font().strokeWidth(style.fontSize() / 10.0), qreal(1.0));
2045
st = style.font().underlinePos(style.fontSize() / 10.0);
2046
lw = qMax(style.font().strokeWidth(style.fontSize() / 10.0), qreal(1.0));
2048
if (style.baselineOffset() != 0)
2049
st += (style.fontSize() / 10.0) * glyphs.scaleV * (style.baselineOffset() / 1000.0);
2050
QColor tmpC = p->pen();
2051
p->setPen(p->brush());
2052
p->setLineWidth(lw);
2053
if (style.effects() & ScStyle_Subscript)
2054
p->drawLine(FPoint(glyphs.xoffset, glyphs.yoffset - st), FPoint(glyphs.xoffset + glyphs.xadvance, glyphs.yoffset - st));
2056
p->drawLine(FPoint(glyphs.xoffset, -st), FPoint(glyphs.xoffset + glyphs.xadvance, -st));
2063
// qDebug() << QString("glyph 0: (%1,%2) * %3 %4 + %5").arg(glyphs.xoffset).arg(glyphs.yoffset).arg(glyphs.scaleH).arg(glyphs.scaleV).arg(glyphs.xadvance));
2066
p->translate(glyphs.xoffset, glyphs.yoffset - ((style.fontSize() / 10.0) * glyphs.scaleV));
2070
p->translate(-glyphs.xadvance, 0);
2072
if (style.baselineOffset() != 0)
2073
p->translate(0, -(style.fontSize() / 10.0) * (style.baselineOffset() / 1000.0));
2074
double glxSc = glyphs.scaleH * style.fontSize() / 100.00;
2075
double glySc = glyphs.scaleV * style.fontSize() / 100.0;
2076
p->scale(glxSc, glySc);
2077
// p->setFillMode(1);
2078
bool fr = p->fillRule();
2079
p->setFillRule(false);
2080
// double a = gly.point(0).x();
2081
// double b = gly.point(0).y();
2082
// double c = gly.point(3).x();
2083
// double d = gly.point(3).y();
2084
// qDebug() << QString("drawglyphs: %1 (%2,%3) (%4,%5) scaled %6,%7 trans %8,%9")
2085
// .arg(gly.size()).arg(a).arg(b).arg(c).arg(d)
2086
// .arg(p->worldMatrix().m11()).arg(p->worldMatrix().m22()).arg(p->worldMatrix().dx()).arg(p->worldMatrix().dy());
2087
p->setupPolygon(&gly, true);
2088
if (m_Doc->layerOutline(LayerNr))
2091
p->setPen(m_Doc->layerMarker(LayerNr), 0.5, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
2092
p->setFillMode(ScPainter::None);
2093
p->setBrushOpacity(1.0);
2094
p->setPenOpacity(1.0);
2101
p->translate(glyphs.xadvance, 0);
2102
drawGlyphs(p, style, *glyphs.more);
2108
p->setPen(PrefsManager::instance()->appPrefs.DControlCharColor, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
2109
p->setLineWidth(style.fontSize() * glyphs.scaleV * style.outlineWidth() * 2 / 10000.0);
2112
else if ((style.font().isStroked()) && (style.strokeColor() != CommonStrings::None) && ((style.fontSize() * glyphs.scaleV * style.outlineWidth() / 10000.0) != 0))
2114
QColor tmp = p->brush();
2115
p->setPen(tmp, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
2116
p->setLineWidth(style.fontSize() * glyphs.scaleV * style.outlineWidth() / 10000.0);
2121
if ((style.effects() & ScStyle_Shadowed) && (style.strokeColor() != CommonStrings::None))
2124
p->translate((style.fontSize() * glyphs.scaleH * style.shadowXOffset() / 10000.0) / glxSc, -(style.fontSize() * glyphs.scaleV * style.shadowYOffset() / 10000.0) / glySc);
2125
QColor tmp = p->brush();
2126
p->setBrush(p->pen());
2127
p->setupPolygon(&gly, true);
2131
p->setupPolygon(&gly, true);
2133
if (style.fillColor() != CommonStrings::None)
2135
if ((style.effects() & ScStyle_Outline) && (style.strokeColor() != CommonStrings::None) && ((style.fontSize() * glyphs.scaleV * style.outlineWidth() / 10000.0) != 0))
2137
p->setLineWidth((style.fontSize() * glyphs.scaleV * style.outlineWidth() / 10000.0) / glySc);
2145
// qDebug() << "drawGlyphs: empty glyph" << glyph;
2147
if ((style.effects() & ScStyle_Strikethrough) && (style.strokeColor() != CommonStrings::None))
2150
if ((style.strikethruOffset() != -1) || (style.strikethruWidth() != -1))
2152
if (style.strikethruOffset() != -1)
2153
st = (style.strikethruOffset() / 1000.0) * (style.font().ascent(style.fontSize() / 10.0));
2155
st = style.font().strikeoutPos(style.fontSize() / 10.0);
2156
if (style.strikethruWidth() != -1)
2157
lw = (style.strikethruWidth() / 1000.0) * (style.fontSize() / 10.0);
2159
lw = qMax(style.font().strokeWidth(style.fontSize() / 10.0), qreal(1.0));
2163
st = style.font().strikeoutPos(style.fontSize() / 10.0);
2164
lw = qMax(style.font().strokeWidth(style.fontSize() / 10.0), qreal(1.0));
2166
if (style.baselineOffset() != 0)
2167
st += (style.fontSize() / 10.0) * glyphs.scaleV * (style.baselineOffset() / 1000.0);
2168
p->setPen(p->brush());
2169
p->setLineWidth(lw);
2170
p->drawLine(FPoint(glyphs.xoffset, glyphs.yoffset - st), FPoint(glyphs.xoffset + glyphs.xadvance, glyphs.yoffset - st));
2179
p->drawRect(glyphs.xoffset, glyphs.yoffset - (style.fontSize() / 10.0) * glyphs.scaleV , (style.fontSize() / 10.0) * glyphs.scaleH, (style.fontSize() / 10.0) * glyphs.scaleV);
2184
p->translate(glyphs.xadvance, 0);
2185
drawGlyphs(p, style, *glyphs.more);
2189
void PageItem::DrawPolyL(QPainter *p, QPolygon pts)
2191
if (Segments.count() != 0)
2193
QList<uint>::Iterator it2end=Segments.end();
2195
for (QList<uint>::Iterator it2 = Segments.begin(); it2 != it2end; ++it2)
2197
p->drawPolygon(pts.constData() + FirstVal, (*it2)-FirstVal);
2200
p->drawPolygon(pts.constData() + FirstVal, pts.size() - FirstVal);
2203
p->drawPolygon(pts);
2206
if (Segments.count() != 0)
2208
QList<uint>::Iterator it2end=Segments.end();
2210
for (QList<uint>::Iterator it2 = Segments.begin(); it2 != it2end; ++it2)
2212
if (NamedLStyle.isEmpty())
2214
if (lineColor() != CommonStrings::None)
2215
p->setPen(QPen(strokeQColor, m_lineWidth, PLineArt, PLineEnd, PLineJoin));
2216
p->drawPolygon(pts.constData() + FirstVal, (*it2)-FirstVal);
2220
multiLine ml = m_Doc->MLineStyles[NamedLStyle];
2221
for (int it = ml.size()-1; it > -1; it--)
2223
SetQColor(&tmp, ml[it].Color, ml[it].Shade);
2225
qMax(static_cast<int>(ml[it].Width), 1),
2226
static_cast<Qt::PenStyle>(ml[it].Dash),
2227
static_cast<Qt::PenCapStyle>(ml[it].LineEnd),
2228
static_cast<Qt::PenJoinStyle>(ml[it].LineJoin)));
2229
p->drawPolygon(pts.constData() + FirstVal, (*it2)-FirstVal);
2234
if (NamedLStyle.isEmpty())
2236
if (lineColor() != CommonStrings::None)
2237
p->setPen(QPen(strokeQColor, m_lineWidth, PLineArt, PLineEnd, PLineJoin));
2238
p->drawPolygon(pts.constData() + FirstVal, pts.size() - FirstVal);
2242
multiLine ml = m_Doc->MLineStyles[NamedLStyle];
2243
for (int it = ml.size()-1; it > -1; it--)
2245
SetQColor(&tmp, ml[it].Color, ml[it].Shade);
2247
qMax(static_cast<int>(ml[it].Width), 1),
2248
static_cast<Qt::PenStyle>(ml[it].Dash),
2249
static_cast<Qt::PenCapStyle>(ml[it].LineEnd),
2250
static_cast<Qt::PenJoinStyle>(ml[it].LineJoin)));
2251
p->drawPolygon(pts.constData() + FirstVal, pts.size() - FirstVal);
2257
if (NamedLStyle.isEmpty())
2259
if (lineColor() != CommonStrings::None)
2260
p->setPen(QPen(strokeQColor, m_lineWidth, PLineArt, PLineEnd, PLineJoin));
2261
p->drawPolygon(pts);
2265
multiLine ml = m_Doc->MLineStyles[NamedLStyle];
2266
for (int it = ml.size()-1; it > -1; it--)
2268
SetQColor(&tmp, ml[it].Color, ml[it].Shade);
2270
qMax(static_cast<int>(ml[it].Width), 1),
2271
static_cast<Qt::PenStyle>(ml[it].Dash),
2272
static_cast<Qt::PenCapStyle>(ml[it].LineEnd),
2273
static_cast<Qt::PenJoinStyle>(ml[it].LineJoin)));
2274
p->drawPolygon(pts);
2280
void PageItem::setItemName(const QString& newName)
2282
if (AnName == newName)
2283
return; // nothing to do -> return
2284
if (newName.isEmpty())
2286
QString oldName = AnName;
2287
AnName = generateUniqueCopyName(newName);
2289
if (UndoManager::undoEnabled())
2291
SimpleState *ss = new SimpleState(Um::Rename, QString(Um::FromTo).arg(AnName).arg(newName));
2292
ss->set("OLD_NAME", oldName);
2293
ss->set("NEW_NAME", newName);
2294
undoManager->action(this, ss);
2296
setUName(AnName); // set the name for the UndoObject too
2299
void PageItem::setPattern(const QString &newPattern)
2301
if (patternVal != newPattern)
2302
patternVal = newPattern;
2305
void PageItem::gradientVector(double& startX, double& startY, double& endX, double& endY) const
2313
void PageItem::setGradientVector(double startX, double startY, double endX, double endY)
2321
void PageItem::setPatternTransform(double scaleX, double scaleY, double offsetX, double offsetY, double rotation)
2323
patternScaleX = scaleX;
2324
patternScaleY = scaleY;
2325
patternOffsetX = offsetX;
2326
patternOffsetY = offsetY;
2327
patternRotation = rotation;
2330
void PageItem::patternTransform(double &scaleX, double &scaleY, double &offsetX, double &offsetY, double &rotation) const
2332
scaleX = patternScaleX;
2333
scaleY = patternScaleY;
2334
offsetX = patternOffsetX;
2335
offsetY = patternOffsetY;
2336
rotation = patternRotation;
2339
void PageItem::setFillColor(const QString &newColor)
2341
QString tmp = newColor;
2342
if (tmp != CommonStrings::None)
2344
if (!m_Doc->PageColors.contains(newColor))
2350
tmp = m_Doc->toolSettings.dBrushPict;
2353
tmp = m_Doc->toolSettings.dTextBackGround;
2358
tmp = m_Doc->toolSettings.dBrush;
2365
if (fillColorVal == tmp)
2370
if (UndoManager::undoEnabled())
2372
SimpleState *ss = new SimpleState(Um::SetFill,
2373
QString(Um::ColorFromTo).arg(fillColorVal).arg(tmp),
2375
ss->set("FILL", "fill");
2376
ss->set("OLD_FILL", fillColorVal);
2377
ss->set("NEW_FILL", tmp);
2378
undoManager->action(this, ss);
2383
fill_gradient = VGradient(VGradient::linear);
2384
fill_gradient.clearStops();
2385
if (fillColorVal != CommonStrings::None)
2387
const ScColor& col = m_Doc->PageColors[fillColorVal];
2388
fill_gradient.addStop(ScColorEngine::getRGBColor(col, m_Doc), 0.0, 0.5, 1.0, fillColorVal, 100);
2389
fill_gradient.addStop(ScColorEngine::getRGBColor(col, m_Doc), 1.0, 0.5, 1.0, fillColorVal, 100);
2393
//CB unused in 135 emit colors(lineColorVal, fillColorVal, lineShadeVal, fillShadeVal);
2396
void PageItem::setFillShade(double newShade)
2398
if (fillShadeVal == newShade)
2403
if (UndoManager::undoEnabled())
2405
SimpleState *ss = new SimpleState(Um::SetShade,
2406
QString(Um::FromTo).arg(fillShadeVal).arg(newShade),
2408
ss->set("SHADE", "shade");
2409
ss->set("OLD_SHADE", fillShadeVal);
2410
ss->set("NEW_SHADE", newShade);
2411
undoManager->action(this, ss);
2413
fillShadeVal = newShade;
2415
//CB unused in 135 emit colors(lineColorVal, fillColorVal, lineShadeVal, fillShadeVal);
2418
void PageItem::setFillTransparency(double newTransparency)
2420
if (fillTransparencyVal == newTransparency)
2421
return; // nothing to do -> return
2422
if (UndoManager::undoEnabled())
2424
SimpleState *ss = new SimpleState(Um::Transparency,
2425
QString(Um::FromTo).arg(fillTransparencyVal).arg(newTransparency),
2427
ss->set("TRANSPARENCY", "transparency");
2428
ss->set("OLD_TP", fillTransparencyVal);
2429
ss->set("NEW_TP", newTransparency);
2430
undoManager->action(this, ss);
2432
fillTransparencyVal = newTransparency;
2435
void PageItem::setFillBlendmode(int newBlendmode)
2437
if (fillBlendmodeVal == newBlendmode)
2438
return; // nothing to do -> return
2439
fillBlendmodeVal = newBlendmode;
2442
void PageItem::setLineColor(const QString &newColor)
2444
QString tmp = newColor;
2445
if (tmp != CommonStrings::None)
2447
if (!m_Doc->PageColors.contains(newColor))
2453
tmp = m_Doc->toolSettings.dTextLineColor;
2456
tmp = m_Doc->toolSettings.dPenLine;
2462
tmp = m_Doc->toolSettings.dPen;
2469
if (lineColorVal == tmp)
2474
if (UndoManager::undoEnabled())
2476
SimpleState *ss = new SimpleState(Um::SetLineColor,
2477
QString(Um::ColorFromTo).arg(lineColorVal).arg(tmp),
2479
ss->set("LINE_COLOR", "line_color");
2480
ss->set("OLD_COLOR", lineColorVal);
2481
ss->set("NEW_COLOR", tmp);
2482
undoManager->action(this, ss);
2486
//CB unused in 135 emit colors(lineColorVal, fillColorVal, lineShadeVal, fillShadeVal);
2489
void PageItem::setLineShade(double newShade)
2491
if (lineShadeVal == newShade)
2496
if (UndoManager::undoEnabled())
2498
SimpleState *ss = new SimpleState(Um::SetLineShade,
2499
QString(Um::FromTo).arg(lineShadeVal).arg(newShade),
2501
ss->set("LINE_SHADE", "line_shade");
2502
ss->set("OLD_SHADE", lineShadeVal);
2503
ss->set("NEW_SHADE", newShade);
2504
undoManager->action(this, ss);
2506
lineShadeVal = newShade;
2508
//CB unused in 135 emit colors(lineColorVal, fillColorVal, lineShadeVal, fillShadeVal);
2511
void PageItem::setLineQColor()
2513
if (lineColorVal != CommonStrings::None)
2515
if (!m_Doc->PageColors.contains(lineColorVal))
2521
lineColorVal = m_Doc->toolSettings.dTextLineColor;
2524
lineColorVal = m_Doc->toolSettings.dPenLine;
2530
lineColorVal = m_Doc->toolSettings.dPen;
2536
if (!m_Doc->PageColors.contains(lineColorVal))
2537
lineColorVal = m_Doc->toolSettings.dPen;
2538
const ScColor& col = m_Doc->PageColors[lineColorVal];
2539
strokeQColor = ScColorEngine::getShadeColorProof(col, m_Doc, lineShadeVal);
2541
if ((m_Doc->view()) && (m_Doc->view()->m_canvas->usePreviewVisual()))
2543
VisionDefectColor defect;
2544
strokeQColor = defect.convertDefect(strokeQColor, m_Doc->view()->m_canvas->previewVisual());
2548
void PageItem::setFillQColor()
2550
if (fillColorVal != CommonStrings::None)
2552
if (!m_Doc->PageColors.contains(fillColorVal))
2558
fillColorVal = m_Doc->toolSettings.dBrushPict;
2561
fillColorVal = m_Doc->toolSettings.dTextBackGround;
2566
fillColorVal = m_Doc->toolSettings.dBrush;
2572
const ScColor& col = m_Doc->PageColors[fillColorVal];
2573
fillQColor = ScColorEngine::getShadeColorProof(col, m_Doc, fillShadeVal);
2575
if ((m_Doc->view()) && (m_Doc->view()->m_canvas->usePreviewVisual()))
2577
VisionDefectColor defect;
2578
fillQColor = defect.convertDefect(fillQColor, m_Doc->view()->m_canvas->previewVisual());
2582
void PageItem::setLineTransparency(double newTransparency)
2584
if (lineTransparencyVal == newTransparency)
2585
return; // nothing to do -> return
2586
if (UndoManager::undoEnabled())
2588
SimpleState *ss = new SimpleState(Um::LineTransparency,
2589
QString(Um::FromTo).arg(lineTransparencyVal).arg(newTransparency),
2591
ss->set("LINE_TRANSPARENCY", "transparency");
2592
ss->set("OLD_TP", lineTransparencyVal);
2593
ss->set("NEW_TP", newTransparency);
2594
undoManager->action(this, ss);
2596
lineTransparencyVal = newTransparency;
2599
void PageItem::setLineBlendmode(int newBlendmode)
2601
if (lineBlendmodeVal == newBlendmode)
2602
return; // nothing to do -> return
2603
lineBlendmodeVal = newBlendmode;
2606
void PageItem::setLineStyle(Qt::PenStyle newStyle)
2608
if (PLineArt == newStyle)
2609
return; // nothing to do -> return
2610
if (UndoManager::undoEnabled())
2612
SimpleState *ss = new SimpleState(Um::LineStyle,"",Um::ILineStyle);
2613
ss->set("LINE_STYLE", "line_style");
2614
ss->set("OLD_STYLE", static_cast<int>(PLineArt));
2615
ss->set("NEW_STYLE", static_cast<int>(newStyle));
2616
undoManager->action(this, ss);
2618
PLineArt = newStyle;
2621
void PageItem::setLineWidth(double newWidth)
2623
if (m_lineWidth == newWidth)
2624
return; // nothing to do -> return
2625
if (UndoManager::undoEnabled())
2627
SimpleState *ss = new SimpleState(Um::LineWidth,
2628
QString(Um::FromTo).arg(m_lineWidth).arg(newWidth),Um::ILineStyle);
2629
ss->set("LINE_WIDTH", "line_width");
2630
ss->set("OLD_WIDTH", m_lineWidth);
2631
ss->set("NEW_WIDTH", newWidth);
2632
undoManager->action(this, ss);
2634
Oldm_lineWidth=m_lineWidth;
2635
m_lineWidth = newWidth;
2638
void PageItem::setLineEnd(Qt::PenCapStyle newStyle)
2640
if (PLineEnd == newStyle)
2641
return; // nothing to do -> return
2642
if (UndoManager::undoEnabled())
2644
SimpleState *ss = new SimpleState(Um::LineEnd,"",Um::ILineStyle);
2645
ss->set("LINE_END", "line_end");
2646
ss->set("OLD_STYLE", static_cast<int>(PLineEnd));
2647
ss->set("NEW_STYLE", static_cast<int>(newStyle));
2648
undoManager->action(this, ss);
2650
PLineEnd = newStyle;
2653
void PageItem::setLineJoin(Qt::PenJoinStyle newStyle)
2655
if (PLineJoin == newStyle)
2656
return; // nothing to do -> return
2657
if (UndoManager::undoEnabled())
2659
SimpleState *ss = new SimpleState(Um::LineJoin,"",Um::ILineStyle);
2660
ss->set("LINE_JOIN", "line_join");
2661
ss->set("OLD_STYLE", static_cast<int>(PLineJoin));
2662
ss->set("NEW_STYLE", static_cast<int>(newStyle));
2663
undoManager->action(this, ss);
2665
PLineJoin = newStyle;
2668
void PageItem::setCustomLineStyle(const QString& newStyle)
2670
if (NamedLStyle == newStyle)
2671
return; // nothing to do -> return
2672
if (UndoManager::undoEnabled())
2674
QString oldStyle = NamedLStyle.isEmpty() ? Um::NoStyle : NamedLStyle;
2675
QString nStyle = newStyle.isEmpty() ? Um::NoStyle : newStyle;
2676
QString action = newStyle.isEmpty() ? Um::NoLineStyle : Um::CustomLineStyle;
2677
SimpleState *ss = new SimpleState(action,
2678
QString(Um::FromTo).arg(oldStyle).arg(nStyle),Um::ILineStyle);
2679
ss->set("CUSTOM_LINE_STYLE", "customlinestyle");
2680
ss->set("OLD_STYLE", NamedLStyle);
2681
ss->set("NEW_STYLE", newStyle);
2682
undoManager->action(this, ss);
2684
NamedLStyle = newStyle;
2687
void PageItem::setStartArrowIndex(int newIndex)
2689
if (m_startArrowIndex == newIndex)
2690
return; // nothing to do -> return
2691
if (UndoManager::undoEnabled())
2693
SimpleState *ss = new SimpleState(Um::StartArrow,"",Um::IArrow);
2694
ss->set("START_ARROW", "startarrow");
2695
ss->set("OLD_INDEX", m_startArrowIndex);
2696
ss->set("NEW_INDEX", newIndex);
2697
undoManager->action(this, ss);
2699
m_startArrowIndex = newIndex;
2702
void PageItem::setEndArrowIndex(int newIndex)
2704
if (m_endArrowIndex == newIndex)
2705
return; // nothing to do -> return
2706
if (UndoManager::undoEnabled())
2708
SimpleState *ss = new SimpleState(Um::EndArrow,"",Um::IArrow);
2709
ss->set("END_ARROW", "endarrow");
2710
ss->set("OLD_INDEX", m_endArrowIndex);
2711
ss->set("NEW_INDEX", newIndex);
2712
undoManager->action(this, ss);
2714
m_endArrowIndex = newIndex;
2717
void PageItem::setImageFlippedH(bool flipped)
2719
if (flipped != m_ImageIsFlippedH)
2723
void PageItem::flipImageH()
2725
if (UndoManager::undoEnabled())
2727
SimpleState *ss = new SimpleState(Um::FlipH, 0, Um::IFlipH);
2728
ss->set("IMAGEFLIPH", "imagefliph");
2729
undoManager->action(this, ss);
2731
m_ImageIsFlippedH = !m_ImageIsFlippedH;
2732
emit frameFlippedH(m_ImageIsFlippedH);
2735
void PageItem::setImageFlippedV(bool flipped)
2737
if (flipped != m_ImageIsFlippedV)
2741
void PageItem::flipImageV()
2743
if (UndoManager::undoEnabled())
2745
SimpleState *ss = new SimpleState(Um::FlipV, 0, Um::IFlipV);
2746
ss->set("IMAGEFLIPV", "imageflipv");
2747
undoManager->action(this, ss);
2749
m_ImageIsFlippedV = !m_ImageIsFlippedV;
2750
emit frameFlippedV(m_ImageIsFlippedV);
2753
void PageItem::setImageScalingMode(bool freeScale, bool keepRatio)
2755
if (ScaleType == freeScale && AspectRatio == keepRatio)
2757
if (UndoManager::undoEnabled())
2759
QString from = ScaleType ? Um::FreeScaling : Um::FrameSize;
2761
from += AspectRatio ? Um::KeepRatio : Um::BreakRatio;
2762
QString to = freeScale ? Um::FreeScaling : Um::FrameSize;
2764
to += keepRatio ? Um::KeepRatio : Um::BreakRatio;
2765
SimpleState *ss = new SimpleState(Um::ImageScaling, QString(Um::FromTo).arg(from).arg(to), Um::IImageScaling);
2766
ss->set("SCALE_MODE", "scaling_mode");
2767
if (freeScale != ScaleType)
2769
ss->set("SCALE_TYPE", freeScale);
2770
ss->set("OLD_IMAGEXOFFSET", LocalX);
2771
ss->set("OLD_IMAGEYOFFSET", LocalY);
2772
ss->set("OLD_IMAGEXSCALE", LocalScX);
2773
ss->set("OLD_IMAGEYSCALE", LocalScY);
2775
if (keepRatio != AspectRatio)
2776
ss->set("ASPECT_RATIO", keepRatio);
2777
undoManager->action(this, ss);
2779
ScaleType = freeScale;
2780
AspectRatio = keepRatio;
2785
void PageItem::toggleLock()
2787
if (UndoManager::undoEnabled())
2791
ss = new SimpleState(Um::UnLock, 0, Um::IUnLock);
2793
ss = new SimpleState(Um::Lock, 0, Um::ILock);
2794
ss->set("LOCK", "lock");
2795
undoManager->action(this, ss);
2797
m_Locked = !m_Locked;
2798
emit frameLocked(m_Locked);
2801
void PageItem::setLocked(bool isLocked)
2803
if (isLocked != m_Locked)
2807
void PageItem::setGroupsLastItem(PageItem* item)
2809
if (UndoManager::undoEnabled())
2811
ItemState<std::pair<PageItem*, PageItem*> > *is = new ItemState<std::pair<PageItem*, PageItem*> >("GroupsLastItem");
2812
is->set("GROUPS_LASTITEM", "groups_lastitem");
2813
is->setItem(std::pair<PageItem*, PageItem*>(this->groupsLastItem, item));
2814
undoManager->action(this, is);
2816
groupsLastItem = item;
2819
void PageItem::toggleSizeLock()
2821
if (UndoManager::undoEnabled())
2825
ss = new SimpleState(Um::SizeUnLock, 0, Um::IUnLock);
2827
ss = new SimpleState(Um::SizeLock, 0, Um::ILock);
2828
ss->set("SIZE_LOCK", "size_lock");
2829
undoManager->action(this, ss);
2831
m_SizeLocked = !m_SizeLocked;
2832
emit frameSizeLocked(m_SizeLocked);
2835
void PageItem::setSizeLocked(bool isLocked)
2837
if (isLocked != m_SizeLocked)
2842
void PageItem::setPrintEnabled(bool toPrint)
2844
if (toPrint != m_PrintEnabled)
2845
togglePrintEnabled();
2848
void PageItem::togglePrintEnabled()
2850
if (UndoManager::undoEnabled())
2854
ss = new SimpleState(Um::DisablePrint, 0, Um::IDisablePrint);
2856
ss = new SimpleState(Um::EnablePrint, 0, Um::IEnablePrint);
2857
ss->set("PRINT_ENABLED", "print_enabled");
2858
undoManager->action(this, ss);
2860
m_PrintEnabled=!m_PrintEnabled;
2861
emit printEnabled(m_PrintEnabled);
2864
void PageItem::setTextFlowMode(TextFlowMode mode)
2866
if (textFlowModeVal == mode)
2868
if (UndoManager::undoEnabled())
2870
QString stateMessage;
2871
if( mode == TextFlowUsesFrameShape )
2872
stateMessage = Um::ObjectFrame;
2873
else if( mode == TextFlowUsesBoundingBox )
2874
stateMessage = Um::BoundingBox;
2875
else if( mode == TextFlowUsesContourLine )
2876
stateMessage = Um::ContourLine;
2877
else if( mode == TextFlowUsesImageClipping )
2878
stateMessage = Um::ImageClip;
2880
stateMessage = Um::NoTextFlow;
2881
SimpleState *ss = new SimpleState(stateMessage, "", Um::IFont);
2882
ss->set("TEXTFLOW_OLDMODE", (int) textFlowModeVal);
2883
ss->set("TEXTFLOW_NEWMODE", (int) mode);
2884
undoManager->action(this, ss);
2886
textFlowModeVal = mode;
2888
checkTextFlowInteractions();
2891
void PageItem::checkTextFlowInteractions(bool allItems)
2893
if(!m_Doc->isLoading())
2895
QRectF baseRect(getBoundingRect());
2896
QList<PageItem*>* items = OnMasterPage.isEmpty() ? &m_Doc->DocItems : &m_Doc->MasterItems;
2897
for(int idx = (allItems ? items->count()-1 : ItemNr-1); idx >= 0 ; --idx)
2899
if(idx != static_cast<int>(ItemNr)) // avoids itself
2901
if(items->at(idx)->asTextFrame()) // do not bother with no text frames
2903
QRectF uRect(items->at(idx)->getBoundingRect());
2904
if(baseRect.intersects(uRect))
2906
items->at(idx)->update();
2914
void PageItem::convertTo(ItemType newType)
2916
if (m_ItemType == newType)
2917
return; // nothing to do -> return
2918
assert(newType != 1); //DEBUG CR 2005-02-06
2919
assert(newType != 3); //DEBUG CR 2005-02-06
2920
QString fromType = "", toType = "";
2924
if (asLatexFrame()) {
2925
fromType = Um::LatexFrame;
2927
fromType = Um::ImageFrame;
2931
fromType = Um::TextFrame;
2934
fromType = Um::Polygon;
2943
toType = Um::ImageFrame;
2944
setUPixmap(Um::IImageFrame);
2947
toType = Um::LatexFrame;
2948
setUPixmap(Um::ILatexFrame);
2951
toType = Um::TextFrame;
2952
setUPixmap(Um::ITextFrame);
2955
toType = Um::Polygon;
2956
setUPixmap(Um::IPolygon);
2959
toType = Um::Polyline;
2960
setUPixmap(Um::IPolyline);
2968
if (UndoManager::undoEnabled())
2970
SimpleState *ss = new SimpleState(Um::ConvertTo + " " + toType,
2971
QString(Um::FromTo).arg(fromType).arg(toType));
2972
ss->set("CONVERT", "convert");
2973
ss->set("PAGEITEM", reinterpret_cast<int>(this));
2974
ss->set("OLD_TYPE", m_ItemType);
2975
ss->set("NEW_TYPE", newType);
2976
undoManager->action(this, ss);
2979
m_ItemType = newType;
2980
emit frameType(m_ItemType);
2983
void PageItem::setLayer(int layerId)
2985
if (LayerNr == layerId)
2987
if (UndoManager::undoEnabled())
2989
SimpleState *ss = new SimpleState(Um::SendToLayer,
2990
QString(Um::FromTo).arg(LayerNr).arg(layerId),
2992
ss->set("SEND_TO_LAYER", "send_to_layer");
2993
ss->set("OLD_LAYER", LayerNr);
2994
ss->set("NEW_LAYER", layerId);
2995
undoManager->action(this, ss);
3000
void PageItem::checkChanges(bool force)
3002
bool spreadChanges(false);
3003
// has the item been resized
3004
if (force || ((oldWidth != Width || oldHeight != Height) && shouldCheck()))
3007
spreadChanges = (textFlowMode() != TextFlowDisabled );
3009
// has the item been rotated
3010
if (force || ((oldRot != Rot) && (shouldCheck())))
3013
spreadChanges = (textFlowMode() != TextFlowDisabled );
3015
// has the item been moved
3016
if (force || ((oldXpos != Xpos || oldYpos != Ypos) && shouldCheck()))
3019
spreadChanges = (textFlowMode() != TextFlowDisabled );
3021
// has the item's image been moved
3022
if (force || ((oldLocalX != LocalX || oldLocalY != LocalY) && shouldCheck()))
3023
changeImageOffsetUndoAction();
3024
// has the item's image been scaled
3025
if (force || ((oldLocalScX != LocalScX || oldLocalScY != LocalScY) && shouldCheck()))
3026
changeImageScaleUndoAction();
3030
checkTextFlowInteractions();
3034
bool PageItem::shouldCheck()
3036
return ((!m_Doc->view()->mousePressed()) &&
3037
(!ScCore->primaryMainWindow()->arrowKeyDown()) &&
3038
(!ScCore->primaryMainWindow()->propertiesPalette->userActionOn()));
3041
void PageItem::moveUndoAction()
3043
if (oldXpos == Xpos && oldYpos == Ypos)
3045
if (UndoManager::undoEnabled())
3049
if (oldOwnPage == -1)
3050
oldp = Um::ScratchSpace;
3052
oldp = QString(Um::PageNmbr).arg(m_Doc->FirstPnum + oldOwnPage);
3054
newp = Um::ScratchSpace;
3056
newp = QString(Um::PageNmbr).arg(m_Doc->FirstPnum + OwnPage);
3057
SimpleState *ss = new SimpleState(Um::Move,
3058
QString(Um::MoveFromTo).arg(oldXpos).arg(oldYpos).arg(oldp).
3059
arg(Xpos).arg(Ypos).arg(newp), Um::IMove);
3060
ss->set("OLD_XPOS", oldXpos);
3061
ss->set("OLD_YPOS", oldYpos);
3062
ss->set("NEW_XPOS", Xpos);
3063
ss->set("NEW_YPOS", Ypos);
3064
undoManager->action(this, ss);
3068
oldOwnPage = OwnPage;
3071
void PageItem::resizeUndoAction()
3073
if (oldHeight == Height && oldWidth == Width)
3075
if (UndoManager::undoEnabled())
3077
SimpleState *ss = new SimpleState(Um::Resize,
3078
QString(Um::ResizeFromTo).arg(oldWidth).arg(oldHeight).arg(Width).arg(Height),
3080
ss->set("OLD_WIDTH", oldWidth);
3081
ss->set("OLD_HEIGHT", oldHeight);
3082
ss->set("NEW_WIDTH", Width);
3083
ss->set("NEW_HEIGHT", Height);
3084
ss->set("OLD_RXPOS", oldXpos);
3085
ss->set("OLD_RYPOS", oldYpos);
3086
ss->set("NEW_RXPOS", Xpos);
3087
ss->set("NEW_RYPOS", Ypos);
3088
ss->set("OLD_RROT", oldRot);
3089
ss->set("NEW_RROT", Rot);
3090
undoManager->action(this, ss);
3096
oldOwnPage = OwnPage;
3100
void PageItem::rotateUndoAction()
3104
if (UndoManager::undoEnabled())
3106
SimpleState *ss = new SimpleState(Um::Rotate,
3107
QString(Um::FromTo).arg(oldRot).arg(Rot),
3109
ss->set("OLD_ROT", oldRot);
3110
ss->set("NEW_ROT", Rot);
3111
ss->set("OLD_RXPOS", oldXpos);
3112
ss->set("OLD_RYPOS", oldYpos);
3113
ss->set("NEW_RXPOS", Xpos);
3114
ss->set("NEW_RYPOS", Ypos);
3115
ss->set("OLD_RWIDTH", oldWidth);
3116
ss->set("OLD_RHEIGHT", oldHeight);
3117
ss->set("NEW_RWIDTH", Width);
3118
ss->set("NEW_RHEIGHT", Height);
3119
undoManager->action(this, ss);
3124
oldOwnPage = OwnPage;
3129
void PageItem::changeImageOffsetUndoAction()
3131
if (oldLocalX == LocalX && oldLocalY == LocalY)
3133
if (UndoManager::undoEnabled())
3135
SimpleState *ss = new SimpleState(Um::ImageOffset,
3136
QString(Um::ImageOffsetFromTo).arg(oldLocalX).arg(oldLocalY).arg(LocalX).arg(LocalY), Um::IMove);
3137
ss->set("IMAGE_OFFSET", "image_offset");
3138
ss->set("OLD_IMAGEXOFFSET", oldLocalX);
3139
ss->set("OLD_IMAGEYOFFSET", oldLocalY);
3140
ss->set("NEW_IMAGEXOFFSET", LocalX);
3141
ss->set("NEW_IMAGEYOFFSET", LocalY);
3142
undoManager->action(this, ss);
3148
void PageItem::changeImageScaleUndoAction()
3150
//#9817: Hack for this rounding issue caused by conversion to text values. Undo needs fixing.
3151
if ((ScCLocale::toDoubleC(ScCLocale::toQStringC(oldLocalScX)) ==
3152
ScCLocale::toDoubleC(ScCLocale::toQStringC(LocalScX)))
3153
&& (ScCLocale::toDoubleC(ScCLocale::toQStringC(oldLocalScY)) ==
3154
ScCLocale::toDoubleC(ScCLocale::toQStringC(LocalScY))))
3156
if (UndoManager::undoEnabled())
3158
SimpleState *ss = new SimpleState(Um::ImageScale,
3159
QString(Um::ImageScaleFromTo).arg(oldLocalScX).arg(oldLocalScY).arg(LocalScX).arg(LocalScY), Um::IMove);
3160
ss->set("IMAGE_SCALE", "image_scale");
3161
ss->set("OLD_IMAGEXSCALE", oldLocalScX);
3162
ss->set("OLD_IMAGEYSCALE", oldLocalScY);
3163
ss->set("NEW_IMAGEXSCALE", LocalScX);
3164
ss->set("NEW_IMAGEYSCALE", LocalScY);
3165
undoManager->action(this, ss);
3167
oldLocalScX = LocalScX;
3168
oldLocalScY = LocalScY;
3171
void PageItem::restore(UndoState *state, bool isUndo)
3173
bool useRasterBackup = m_Doc->useRaster;
3174
bool SnapGuidesBackup = m_Doc->SnapGuides;
3175
m_Doc->useRaster = false;
3176
m_Doc->SnapGuides = false;
3177
SimpleState *ss = dynamic_cast<SimpleState*>(state);
3178
bool oldMPMode=m_Doc->masterPageMode();
3179
m_Doc->setMasterPageMode(!OnMasterPage.isEmpty());
3180
Page *oldCurrentPage = m_Doc->currentPage();
3181
if (!OnMasterPage.isEmpty())
3183
oldCurrentPage = m_Doc->currentPage();
3184
m_Doc->setCurrentPage(m_Doc->MasterPages.at(m_Doc->MasterNames[OnMasterPage]));
3188
if (ss->contains("OLD_XPOS"))
3189
restoreMove(ss, isUndo);
3190
else if (ss->contains("OLD_HEIGHT"))
3191
restoreResize(ss, isUndo);
3192
else if (ss->contains("OLD_ROT"))
3193
restoreRotate(ss, isUndo);
3194
else if (ss->contains("FILL"))
3195
restoreFill(ss, isUndo);
3196
else if (ss->contains("SHADE"))
3197
restoreShade(ss, isUndo);
3198
else if (ss->contains("LINE_COLOR"))
3199
restoreLineColor(ss, isUndo);
3200
else if (ss->contains("LINE_SHADE"))
3201
restoreLineShade(ss, isUndo);
3202
else if (ss->contains("IMAGEFLIPH"))
3205
m_Doc->itemSelection_FlipH();
3207
else if (ss->contains("IMAGEFLIPV"))
3210
m_Doc->itemSelection_FlipV();
3212
else if (ss->contains("LOCK"))
3215
m_Doc->itemSelection_ToggleLock();
3217
else if (ss->contains("SIZE_LOCK"))
3220
m_Doc->itemSelection_ToggleSizeLock();
3222
else if (ss->contains("PRINT_ENABLED"))
3225
m_Doc->itemSelection_TogglePrintEnabled();
3227
else if (ss->contains("NEW_NAME"))
3228
restoreName(ss, isUndo);
3229
else if (ss->contains("TRANSPARENCY"))
3230
restoreFillTP(ss, isUndo);
3231
else if (ss->contains("LINE_TRANSPARENCY"))
3232
restoreLineTP(ss, isUndo);
3233
else if (ss->contains("LINE_STYLE"))
3234
restoreLineStyle(ss, isUndo);
3235
else if (ss->contains("LINE_END"))
3236
restoreLineEnd(ss, isUndo);
3237
else if (ss->contains("LINE_JOIN"))
3238
restoreLineJoin(ss, isUndo);
3239
else if (ss->contains("LINE_WIDTH"))
3240
restoreLineWidth(ss, isUndo);
3241
else if (ss->contains("CUSTOM_LINE_STYLE"))
3242
restoreCustomLineStyle(ss, isUndo);
3243
else if (ss->contains("START_ARROW"))
3244
restoreArrow(ss, isUndo, true);
3245
else if (ss->contains("END_ARROW"))
3246
restoreArrow(ss, isUndo, false);
3247
else if (ss->contains("PSTYLE"))
3248
restorePStyle(ss, isUndo);
3249
else if (ss->contains("CONVERT"))
3250
restoreType(ss, isUndo);
3251
else if (ss->contains("TEXTFLOW_OLDMODE"))
3252
restoreTextFlowing(ss, isUndo);
3253
else if (ss->contains("SCALE_MODE"))
3254
restoreImageScaleMode(ss, isUndo);
3255
else if (ss->contains("IMAGE_SCALE"))
3256
restoreImageScaleChange(ss, isUndo);
3257
else if (ss->contains("IMAGE_OFFSET"))
3258
restoreImageOffsetChange(ss, isUndo);
3259
else if (ss->contains("EDIT_CONTOUR"))
3260
restorePoly(ss, isUndo, true);
3261
else if (ss->contains("EDIT_SHAPE"))
3262
restorePoly(ss, isUndo, false);
3263
else if (ss->contains("RESET_CONTOUR"))
3264
restoreContourLine(ss, isUndo);
3265
else if (ss->contains("CHANGE_SHAPE_TYPE"))
3266
restoreShapeType(ss, isUndo);
3267
else if (ss->contains("MIRROR_PATH_H"))
3269
bool editContour = m_Doc->nodeEdit.isContourLine;
3270
m_Doc->nodeEdit.isContourLine = ss->getBool("IS_CONTOUR");
3272
m_Doc->MirrorPolyH(m_Doc->m_Selection->itemAt(0));
3273
m_Doc->nodeEdit.isContourLine = editContour;
3275
else if (ss->contains("MIRROR_PATH_V"))
3277
bool editContour = m_Doc->nodeEdit.isContourLine;
3278
m_Doc->nodeEdit.isContourLine = ss->getBool("IS_CONTOUR");
3280
m_Doc->MirrorPolyV(m_Doc->m_Selection->itemAt(0));
3281
m_Doc->nodeEdit.isContourLine = editContour;
3283
else if (ss->contains("SEND_TO_LAYER"))
3284
restoreLayer(ss, isUndo);
3285
else if (ss->contains("GET_IMAGE"))
3286
restoreGetImage(ss, isUndo);
3287
else if (ss->contains("GROUPS_LASTITEM"))
3288
restoreGroupsLastItem(ss, isUndo);
3289
else if (ss->contains("EDIT_SHAPE_OR_CONTOUR"))
3290
restoreShapeContour(ss, isUndo);
3291
else if (ss->contains("APPLY_IMAGE_EFFECTS"))
3292
restoreImageEffects(ss, isUndo);
3293
else if (ss->contains("STEXT"))
3294
restoreEditText(ss, isUndo);
3295
else if (ss->contains("CLEAR_IMAGE"))
3296
restoreClearImage(ss,isUndo);
3297
else if (ss->contains("LINK_TEXT_FRAME"))
3298
restoreLinkTextFrame(ss,isUndo);
3299
else if (ss->contains("UNLINK_TEXT_FRAME"))
3300
restoreUnlinkTextFrame(ss, isUndo);
3301
else if (ss->contains("REVERSE_TEXT"))
3302
restoreReverseText(ss, isUndo);
3303
else if (ss->contains("PATH_OPERATION"))
3304
restorePathOperation(ss, isUndo);
3306
if (!OnMasterPage.isEmpty())
3307
m_Doc->setCurrentPage(oldCurrentPage);
3308
m_Doc->setMasterPageMode(oldMPMode);
3309
m_Doc->useRaster = useRasterBackup;
3310
m_Doc->SnapGuides = SnapGuidesBackup;
3313
void PageItem::restoreMove(SimpleState *state, bool isUndo)
3315
double ox = state->getDouble("OLD_XPOS");
3316
double oy = state->getDouble("OLD_YPOS");
3317
double x = state->getDouble("NEW_XPOS");
3318
double y = state->getDouble("NEW_YPOS");
3326
m_Doc->MoveItem(mx, my, this, false);
3329
oldOwnPage = OwnPage;
3332
void PageItem::restoreResize(SimpleState *state, bool isUndo)
3334
double ow = state->getDouble("OLD_WIDTH");
3335
double oh = state->getDouble("OLD_HEIGHT");
3336
double w = state->getDouble("NEW_WIDTH");
3337
double h = state->getDouble("NEW_HEIGHT");
3338
double ox = state->getDouble("OLD_RXPOS");
3339
double oy = state->getDouble("OLD_RYPOS");
3340
double x = state->getDouble("NEW_RXPOS");
3341
double y = state->getDouble("NEW_RYPOS");
3342
double ort = state->getDouble("OLD_RROT");
3343
double rt = state->getDouble("NEW_RROT");
3346
int stateCode = state->transactionCode;
3347
bool redraw = ((stateCode != 1) && (stateCode != 3));
3350
m_Doc->SizeItem(ow, oh, this, false, true, redraw);
3351
m_Doc->MoveItem(mx, my, this, false);
3352
m_Doc->RotateItem(ort, this);
3358
m_Doc->SizeItem(w, h, this, false, true, redraw);
3359
m_Doc->MoveItem(mx, my, this, false);
3360
m_Doc->RotateItem(rt, this);
3366
oldOwnPage = OwnPage;
3370
void PageItem::restoreRotate(SimpleState *state, bool isUndo)
3372
double ort = state->getDouble("OLD_ROT");
3373
double rt = state->getDouble("NEW_ROT");
3374
double ox = state->getDouble("OLD_RXPOS");
3375
double oy = state->getDouble("OLD_RYPOS");
3376
double x = state->getDouble("NEW_RXPOS");
3377
double y = state->getDouble("NEW_RYPOS");
3378
double ow = state->getDouble("OLD_RWIDTH");
3379
double oh = state->getDouble("OLD_RHEIGHT");
3380
double w = state->getDouble("NEW_RWIDTH");
3381
double h = state->getDouble("NEW_RHEIGHT");
3382
int stateCode = state->transactionCode;
3383
bool redraw = ((stateCode != 1) && (stateCode != 3));;
3384
//CB Commented out test code
3385
//QRect oldR(getRedrawBounding(view->scale()));
3386
//double mx = ox - x;
3387
//double my = oy - y;
3395
m_Doc->RotateItem(ort, this);
3396
m_Doc->MoveItem(ox - Xpos, oy - Ypos, this, false);
3397
m_Doc->SizeItem(ow, oh, this, false, true, redraw);
3409
m_Doc->RotateItem(rt, this);
3410
m_Doc->MoveItem(x - Xpos, y - Ypos, this, false);
3411
m_Doc->SizeItem(w, h, this, false, true, redraw);
3414
m_Doc->setRedrawBounding(this);
3415
QRect newR(getRedrawBounding(view->scale()));
3416
view->updateContents(newR.unite(oldR));
3417
OwnPage = m_Doc->OnPage(this);
3422
oldOwnPage = OwnPage;
3427
void PageItem::restoreFill(SimpleState *state, bool isUndo)
3429
QString fill = state->get("OLD_FILL");
3431
fill = state->get("NEW_FILL");
3433
m_Doc->itemSelection_SetItemBrush(fill);
3436
void PageItem::restoreShade(SimpleState *state, bool isUndo)
3438
int shade = state->getInt("OLD_SHADE");
3440
shade = state->getInt("NEW_SHADE");
3442
m_Doc->itemSelection_SetItemBrushShade(shade);
3445
void PageItem::restoreLineColor(SimpleState *state, bool isUndo)
3447
QString fill = state->get("OLD_COLOR");
3449
fill = state->get("NEW_COLOR");
3451
m_Doc->itemSelection_SetItemPen(fill);
3454
void PageItem::restoreLineShade(SimpleState *state, bool isUndo)
3456
int shade = state->getInt("OLD_SHADE");
3458
shade = state->getInt("NEW_SHADE");
3460
m_Doc->itemSelection_SetItemPenShade(shade);
3463
void PageItem::restoreFillTP(SimpleState *state, bool isUndo)
3465
double tp = state->getDouble("OLD_TP");
3467
tp = state->getDouble("NEW_TP");
3469
m_Doc->itemSelection_SetItemFillTransparency(tp);
3472
void PageItem::restoreLineTP(SimpleState *state, bool isUndo)
3474
double tp = state->getDouble("OLD_TP");
3476
tp = state->getDouble("NEW_TP");
3478
m_Doc->itemSelection_SetItemLineTransparency(tp);
3482
void PageItem::restoreLineStyle(SimpleState *state, bool isUndo)
3484
Qt::PenStyle ps = static_cast<Qt::PenStyle>(state->getInt("OLD_STYLE"));
3486
ps = static_cast<Qt::PenStyle>(state->getInt("NEW_STYLE"));
3488
m_Doc->itemSelection_SetLineArt(ps);
3491
void PageItem::restoreLineEnd(SimpleState *state, bool isUndo)
3493
Qt::PenCapStyle pcs = static_cast<Qt::PenCapStyle>(state->getInt("OLD_STYLE"));
3495
pcs = static_cast<Qt::PenCapStyle>(state->getInt("NEW_STYLE"));
3497
m_Doc->itemSelection_SetLineEnd(pcs);
3500
void PageItem::restoreLineJoin(SimpleState *state, bool isUndo)
3502
Qt::PenJoinStyle pjs = static_cast<Qt::PenJoinStyle>(state->getInt("OLD_STYLE"));
3504
pjs = static_cast<Qt::PenJoinStyle>(state->getInt("NEW_STYLE"));
3506
m_Doc->itemSelection_SetLineJoin(pjs);
3509
void PageItem::restoreLineWidth(SimpleState *state, bool isUndo)
3511
double w = state->getDouble("OLD_WIDTH");
3513
w = state->getDouble("NEW_WIDTH");
3515
m_Doc->itemSelection_SetLineWidth(w);
3518
void PageItem::restoreCustomLineStyle(SimpleState *state, bool isUndo)
3520
QString style = state->get("OLD_STYLE");
3522
style = state->get("NEW_STYLE");
3523
setCustomLineStyle(style);
3526
void PageItem::restoreName(SimpleState *state, bool isUndo)
3528
QString name = state->get("OLD_NAME");
3530
name = state->get("NEW_NAME");
3534
void PageItem::restoreArrow(SimpleState *state, bool isUndo, bool isStart)
3536
int i = state->getInt("OLD_INDEX");
3538
i = state->getInt("NEW_INDEX");
3540
setStartArrowIndex(i);
3542
setEndArrowIndex(i);
3546
void PageItem::restorePStyle(SimpleState *state, bool isUndo)
3548
int styleid = state->getInt("OLD_STYLE");
3550
styleid = state->getInt("NEW_STYLE");
3551
//will be done later with other text-undo:
3552
// m_Doc->chAbStyle(this, styleid);
3556
// FIXME: This must go into class ScribusDoc!
3557
// For now we'll just make it independent of 'this' -- AV
3558
void PageItem::restoreType(SimpleState *state, bool isUndo)
3560
// well, probably not the best way to handle pointers...
3561
PageItem * item = reinterpret_cast<PageItem *>(state->getInt("PAGEITEM"));
3562
int type = state->getInt("OLD_TYPE");
3564
type = state->getInt("NEW_TYPE");
3565
ScribusView* view = m_Doc->view();
3566
view->Deselect(false);
3567
view->SelectItem(item, false);
3569
case ImageFrame: view->ToPicFrame(); break;
3570
case TextFrame: view->ToTextFrame(); break;
3571
case Polygon: view->ToPolyFrame(); break;
3572
case PolyLine: view->ToBezierFrame(); break;
3574
view->requestMode(modeNormal);
3577
void PageItem::restoreTextFlowing(SimpleState *state, bool isUndo)
3579
TextFlowMode oldMode = (TextFlowMode) state->getInt("TEXTFLOW_OLDMODE");
3580
TextFlowMode newMode = (TextFlowMode) state->getInt("TEXTFLOW_NEWMODE");
3582
textFlowModeVal = oldMode;
3584
textFlowModeVal = newMode;
3586
QList<PageItem*> pList;
3587
for(int idx = ItemNr-1; idx >= 0 ; --idx)
3589
pList << m_Doc->Items->at(idx);
3592
QRectF baseRect(getBoundingRect());
3593
for(int idx(0); idx < pList.count(); ++idx)
3595
QRectF uRect(pList.at(idx)->getBoundingRect());
3596
if(baseRect.intersects(uRect))
3597
pList.at(idx)->update();
3601
void PageItem::restoreImageScaleMode(SimpleState *state, bool isUndo)
3603
bool type=ScaleType;
3604
if (state->contains("SCALE_TYPE"))
3607
type = !state->getBool("SCALE_TYPE");
3609
type = state->getBool("SCALE_TYPE");
3610
//if restoring free scaling
3611
//old offset and scale ratio must be restored
3614
double oscx = state->getDouble("OLD_IMAGEXSCALE");
3615
double oscy = state->getDouble("OLD_IMAGEYSCALE");
3616
double ox = state->getDouble("OLD_IMAGEXOFFSET");
3617
double oy = state->getDouble("OLD_IMAGEYOFFSET");
3618
Selection tempSelection(this, false);
3619
tempSelection.addItem(this, true);
3620
m_Doc->itemSelection_SetImageScale(oscx, oscy, &tempSelection);
3621
m_Doc->itemSelection_SetImageOffset(ox, oy, &tempSelection);
3626
bool ratio=AspectRatio;
3627
if (state->contains("ASPECT_RATIO"))
3630
ratio = !state->getBool("ASPECT_RATIO");
3632
ratio = state->getBool("ASPECT_RATIO");
3635
setImageScalingMode(type, ratio);
3638
void PageItem::restoreImageScaleChange(SimpleState *state, bool isUndo)
3640
double oscx = state->getDouble("OLD_IMAGEXSCALE");
3641
double oscy = state->getDouble("OLD_IMAGEYSCALE");
3642
double scx = state->getDouble("NEW_IMAGEXSCALE");
3643
double scy = state->getDouble("NEW_IMAGEYSCALE");
3644
Selection tempSelection(this, false);
3645
tempSelection.addItem(this, true);
3647
m_Doc->itemSelection_SetImageScale(scx, scy, &tempSelection);
3649
m_Doc->itemSelection_SetImageScale(oscx, oscy, &tempSelection);
3652
void PageItem::restoreImageOffsetChange(SimpleState *state, bool isUndo)
3654
double ox = state->getDouble("OLD_IMAGEXOFFSET");
3655
double oy = state->getDouble("OLD_IMAGEYOFFSET");
3656
double x = state->getDouble("NEW_IMAGEXOFFSET");
3657
double y = state->getDouble("NEW_IMAGEYOFFSET");
3658
Selection tempSelection(this, false);
3659
tempSelection.addItem(this, true);
3661
m_Doc->itemSelection_SetImageOffset(x, y, &tempSelection);
3663
m_Doc->itemSelection_SetImageOffset(ox, oy, &tempSelection);
3666
void PageItem::restoreClearImage(UndoState *state, bool isUndo)
3668
if (!isImageFrame())
3672
ItemState<ScImageEffectList> *is = dynamic_cast<ItemState<ScImageEffectList>*>(state);
3673
Pfile = is->get("CI_PFILE");
3674
loadImage(Pfile, false);
3675
effectsInUse = is->getItem();
3676
setImageFlippedH(is->getBool("CI_FLIPPH"));
3677
setImageFlippedV(is->getBool("CI_FLIPPV"));
3678
setImageScalingMode(is->getBool("CI_SCALING"),is->getBool("CI_ASPECT"));
3679
setImageXYOffset(is->getDouble("CI_XOFF"), is->getDouble("CI_YOFF"));
3680
setImageXYScale(is->getDouble("CI_XSCALE"), is->getDouble("CI_YSCALE"));
3681
setFillTransparency(is->getDouble("CI_FILLT"));
3682
setLineTransparency(is->getDouble("CI_LINET"));
3687
asImageFrame()->clearContents();
3690
void PageItem::restoreLinkTextFrame(UndoState *state, bool isUndo)
3700
ItemState<std::pair<PageItem*, PageItem*> > *is = dynamic_cast<ItemState<std::pair<PageItem*, PageItem*> >*>(state);
3701
asTextFrame()->link(is->getItem().second->asTextFrame());
3705
void PageItem::restoreUnlinkTextFrame(UndoState *state, bool isUndo)
3711
ItemState<std::pair<PageItem*, PageItem*> > *is = dynamic_cast<ItemState<std::pair<PageItem*, PageItem*> >*>(state);
3712
asTextFrame()->link(is->getItem().second->asTextFrame());
3720
void PageItem::restoreReverseText(UndoState *state, bool /*isUndo*/)
3727
void PageItem::restorePathOperation(UndoState *state, bool isUndo)
3729
ItemState<QPair<QPair<FPointArray, FPointArray>, QPair<FPointArray, FPointArray> > >*is = dynamic_cast<ItemState<QPair<QPair<FPointArray, FPointArray>, QPair<FPointArray, FPointArray> > >*>(state);
3734
this->ClipEdited=is->getBool("PATH_OP_OLD_CLIPEDITED");
3735
this->Frame=is->getBool("PATH_OP_OLD_FRAME");
3736
this->FrameType=is->getInt("PATH_OP_OLD_FRAMETYPE");
3737
this->OldB2=is->getDouble("PATH_OP_OLD_OLDB2");
3738
this->OldH2=is->getDouble("PATH_OP_OLD_OLDH2");
3739
QPair<FPointArray, FPointArray> oldLines=is->getItem().first;
3740
this->PoLine = oldLines.first;
3741
this->ContourLine = oldLines.second;
3745
this->ClipEdited=is->getBool("PATH_OP_NEW_CLIPEDITED");
3746
this->Frame=is->getBool("PATH_OP_NEW_FRAME");
3747
this->FrameType=is->getInt("PATH_OP_NEW_FRAMETYPE");
3748
this->OldB2=is->getDouble("PATH_OP_NEW_OLDB2");
3749
this->OldH2=is->getDouble("PATH_OP_NEW_OLDH2");
3750
QPair<FPointArray, FPointArray> newLines=is->getItem().second;
3751
this->PoLine = newLines.first;
3752
this->ContourLine = newLines.second;
3758
void PageItem::restorePoly(SimpleState *state, bool isUndo, bool isContour)
3760
int mode = state->getInt("MODE");
3761
int rot = state->getInt("ROT");
3762
ScribusView* view = m_Doc->view();
3763
double scaling = state->getDouble("SCALING");
3764
bool editContour = m_Doc->nodeEdit.isContourLine;
3765
m_Doc->nodeEdit.isContourLine = isContour;
3769
if (mode % 2 != 0 && mode != 0)
3774
scaling = (1.0 - (100.0 / (100.0 + scaling))) * 100.0;
3776
scaling = ((100.0 / (100.0 - scaling)) - 1.0) * 100.0;
3778
view->TransformPoly(mode, rot, scaling);
3779
m_Doc->nodeEdit.isContourLine = editContour;
3782
void PageItem::restoreContourLine(SimpleState *state, bool isUndo)
3784
ItemState<FPointArray> *is = dynamic_cast<ItemState<FPointArray>*>(state);
3788
ContourLine = is->getItem();
3790
ContourLine = PoLine.copy();
3795
void PageItem::restoreShapeType(SimpleState *state, bool isUndo)
3797
// Store shape info in this form:
3798
// CHANGE_SHAPE_TYPE - ID of the undo operation
3799
// OLD_FRAME_TYPE - original frame type
3800
// NEW_FRAME_TYPE - change of frame type
3801
// binary QPair<FPointArray, FPointArray> - .first original shape, .second new shape
3802
ItemState<QPair<FPointArray,FPointArray> > *is = dynamic_cast<ItemState<QPair<FPointArray,FPointArray> >*>(state);
3807
this->FrameType = is->getInt("OLD_FRAME_TYPE");
3808
this->PoLine = is->getItem().first;
3812
this->FrameType = is->getInt("NEW_FRAME_TYPE");
3813
this->PoLine = is->getItem().second;
3819
void PageItem::restoreLayer(SimpleState *state, bool isUndo)
3821
ScribusView* view = m_Doc->view();
3822
setLayer(isUndo ? state->getInt("OLD_LAYER") : state->getInt("NEW_LAYER"));
3823
view->Deselect(true);
3824
m_Doc->regionsChanged()->update(QRectF());
3827
void PageItem::restoreGetImage(UndoState *state, bool isUndo)
3829
ItemState<ScImageEffectList> *is = dynamic_cast<ItemState<ScImageEffectList>*>(state);
3830
QString fn = is->get("OLD_IMAGE_PATH");
3832
fn = is->get("NEW_IMAGE_PATH");
3835
Selection tempSelection(this, false);
3836
tempSelection.addItem(this, true);
3837
m_Doc->itemSelection_ClearItem(&tempSelection);
3841
loadImage(fn, false);
3844
//restore old image settings
3845
effectsInUse = is->getItem();
3846
setImageFlippedH(is->getBool("FLIPPH"));
3847
setImageFlippedV(is->getBool("FLIPPV"));
3848
setImageScalingMode(is->getBool("SCALING"), is->getBool("ASPECT"));
3849
setImageXYOffset(is->getDouble("XOFF"), is->getDouble("YOFF"));
3850
setImageXYScale(is->getDouble("XSCALE"), is->getDouble("YSCALE"));
3851
setFillTransparency(is->getDouble("FILLT"));
3852
setLineTransparency(is->getDouble("LINET"));
3859
void PageItem::restoreGroupsLastItem(SimpleState *state, bool isUndo)
3861
ItemState<std::pair<PageItem*, PageItem*> > *is = dynamic_cast<ItemState<std::pair<PageItem*, PageItem*> > *>(state);
3865
this->groupsLastItem = is->getItem().first;
3867
this->groupsLastItem = is->getItem().second;
3871
void PageItem::restoreShapeContour(UndoState *state, bool isUndo)
3873
ItemState<QPair<FPointArray,FPointArray> > *istate =
3874
dynamic_cast<ItemState<QPair<FPointArray,FPointArray> >*>(state);
3877
FPointArray oldClip = istate->getItem().first;
3878
FPointArray newClip = istate->getItem().second;
3879
bool isContour = istate->getBool("IS_CONTOUR");
3880
double oldX = istate->getDouble("OLD_X");
3881
double oldY = istate->getDouble("OLD_Y");
3882
double newX = istate->getDouble("NEW_X");
3883
double newY = istate->getDouble("NEW_Y");
3884
double mx = oldX - newX;
3885
double my = oldY - newY;
3890
ContourLine = oldClip;
3899
ContourLine = newClip;
3903
m_Doc->AdjustItemSize(this);
3904
m_Doc->MoveItem(mx, my, this, false);
3905
m_Doc->regionsChanged()->update(QRectF());
3910
void PageItem::restoreImageEffects(UndoState *state, bool isUndo)
3912
ItemState<QPair<ScImageEffectList, ScImageEffectList> > *istate =
3913
dynamic_cast<ItemState<QPair<ScImageEffectList,ScImageEffectList> >*>(state);
3917
effectsInUse = istate->getItem().first;
3919
effectsInUse = istate->getItem().second;
3926
void PageItem::restoreEditText(SimpleState *state, bool isUndo)
3930
itemText.deselectAll();
3932
EditAct action = (EditAct) state->getInt("STEXT");
3933
if (action == PARAMFULL || action == PARAMSEL)
3937
buffer.append(state->get("STEXT_OLD"));
3939
buffer.append(state->get("STEXT_NEW"));
3940
if (!buffer.isEmpty())
3942
Serializer dig(*m_Doc);
3943
dig.store<ScribusDoc>("<scribusdoc>", m_Doc);
3944
StoryText::desaxeRules("/", dig, "SCRIBUSTEXT");
3945
dig.addRule("/SCRIBUSTEXT", desaxe::Result<StoryText>());
3946
dig.parseMemory(buffer.toStdString().c_str(), buffer.length());
3947
StoryText* story = dig.result<StoryText>();
3948
if (action == PARAMFULL)
3950
itemText.selectAll();
3952
itemText.append(*story);
3954
else if (action == PARAMSEL)
3956
itemText.deselectAll();
3957
int SelStart = state->getInt("STEXT_SELSTART");
3958
itemText.select(SelStart,state->getInt("STEXT_SELLEN"));
3959
asTextFrame()->deleteSelectedTextFromFrame();
3960
int ItemLength = itemText.length();
3961
itemText.insert(SelStart, *story);
3962
// If we have inserted at end of text we have to restore trailing style
3963
if (ItemLength == SelStart && story->length() > 0 && story->text(-1) != SpecialChars::PARSEP)
3965
itemText.setStyle(-1, story->paragraphStyle(story->length()));
3967
itemText.select(SelStart, story->length());
3970
itemText.setCursorPosition( itemText.endOfSelection() );
3973
else { qDebug() << "UNDO buffer EMPTY";}
3975
else if (action == REPSAX)
3977
QString buffout, buffin; //buffout is deleted, buffin is inserted
3978
int pos = state->getInt("STEXT_CPOS");
3981
buffin.append(state->get("STEXT_OLD"));
3982
buffout.append(state->get("STEXT_NEW"));
3986
buffin.append(state->get("STEXT_NEW"));
3987
buffout.append(state->get("STEXT_OLD"));
3990
Serializer dig(*m_Doc);
3991
dig.store<ScribusDoc>("<scribusdoc>", m_Doc);
3992
StoryText::desaxeRules("/", dig, "SCRIBUSTEXT");
3993
dig.addRule("/SCRIBUSTEXT", desaxe::Result<StoryText>());
3994
dig.parseMemory(buffout.toStdString().c_str(), buffout.length());
3995
StoryText* story = dig.result<StoryText>();
3996
itemText.select(pos,story->length());
3997
asTextFrame()->deleteSelectedTextFromFrame();
3999
Serializer dig2(*m_Doc);
4000
dig2.store<ScribusDoc>("<scribusdoc>", m_Doc);
4001
StoryText::desaxeRules("/", dig2, "SCRIBUSTEXT");
4002
dig2.addRule("/SCRIBUSTEXT", desaxe::Result<StoryText>());
4003
dig2.parseMemory(buffin.toStdString().c_str(), buffin.length());
4004
story = dig2.result<StoryText>();
4005
itemText.insert(pos,*story);
4006
itemText.select(pos, story->length());
4010
else if (action == INSSAX || action == DELSAX)
4012
QString str = state->get("STEXT_STR");
4014
str = itemTextSaxed;
4015
int pos = state->getInt("STEXT_CPOS");
4016
Serializer dig(*m_Doc);
4017
dig.store<ScribusDoc>("<scribusdoc>", m_Doc);
4018
StoryText::desaxeRules("/", dig, "SCRIBUSTEXT");
4019
dig.addRule("/SCRIBUSTEXT", desaxe::Result<StoryText>());
4020
dig.parseMemory(str.toStdString().c_str(), str.length());
4021
StoryText* story = dig.result<StoryText>();
4022
if ((action == INSSAX && isUndo) || (action == DELSAX && !isUndo))
4024
//undo for INSSAX, redo for DELSAX
4025
itemText.select(pos, story->length());
4026
asTextFrame()->deleteSelectedTextFromFrame();
4030
//undo for DELSAX, redo for INSSAX
4031
itemText.insert(pos, *story);
4035
else if (action == INS)
4037
QString str = state->get("STEXT_STR");
4038
int pos = state->getInt("STEXT_CPOS");
4041
itemText.select(pos, str.length());
4042
asTextFrame()->deleteSelectedTextFromFrame();
4046
itemText.insertChars(pos, str, true);
4049
// after Undo or Redo new actions should create new undoStates
4050
asTextFrame()->lastUndoAction = NOACTION;
4052
m_Doc->scMW()->setTBvals(this);
4056
QString PageItem::getItemTextSaxed(EditActPlace undoItem)
4058
if (!isTextFrame()) return "";
4059
StoryText iT(m_Doc);
4060
iT.setDefaultStyle(itemText.defaultStyle());
4061
if (undoItem == FRAME)
4062
iT.insert(0, itemText);
4065
int StartOldSel = 0, LenOldSel = 0;
4068
StartOldSel = itemText.startOfSelection();
4069
LenOldSel = itemText.lengthOfSelection();
4071
if (undoItem == PARAGRAPH)
4072
asTextFrame()->expandParaSelection(true);
4073
else if (undoItem == CHAR || !HasSel)
4075
if (itemText.cursorPosition() >= itemText.length())
4077
itemText.select(itemText.cursorPosition(), 1);
4080
iT.insert(0, itemText, true);
4081
itemText.deselectAll();
4082
if (LenOldSel > 0) //restoring old selection if undoItem was PARAPGRAPH
4083
itemText.select(StartOldSel, LenOldSel);
4086
std::ostringstream xmlString;
4087
SaxXML xmlStream(xmlString);
4088
xmlStream.beginDoc();
4089
iT.saxx(xmlStream, "SCRIBUSTEXT");
4091
std::string xml(xmlString.str());
4092
return QString(xml.c_str());
4095
QString PageItem::getItemTextSaxed(int selStart, int selLength)
4097
if (selStart < 0 || selLength < 0)
4100
StoryText it(m_Doc);
4101
it.setDefaultStyle(itemText.defaultStyle());
4103
itemText.select(selStart, selLength);
4104
it.insert(0, itemText, (selLength > 0));
4107
std::ostringstream xmlString;
4108
SaxXML xmlStream(xmlString);
4109
xmlStream.beginDoc();
4110
it.saxx(xmlStream, "SCRIBUSTEXT");
4112
std::string xml(xmlString.str());
4113
return QString(xml.c_str());
4116
QString PageItem::getTextSaxed(QString str)
4118
StoryText iT(m_Doc);
4119
iT.setDefaultStyle(itemText.defaultStyle());
4120
iT.insertChars(0,str,true);
4121
std::ostringstream xmlString;
4122
SaxXML xmlStream(xmlString);
4123
xmlStream.beginDoc();
4124
iT.saxx(xmlStream, "SCRIBUSTEXT");
4126
std::string xml(xmlString.str());
4127
return QString(xml.c_str());
4130
void PageItem::select()
4132
if (m_Doc->m_Selection->count() == 1 && m_Doc->m_Selection->itemAt()->isTextFrame())
4133
m_Doc->m_Selection->itemAt()->asTextFrame()->lastUndoAction = PageItem::NOACTION;
4134
m_Doc->view()->Deselect(false);
4135
//CB #2969 add this true parm to addItem so we dont connectToGUI, the rest of view->SelectItem isnt needed anyway
4136
m_Doc->m_Selection->addItem(this, true);
4139
ObjAttrVector* PageItem::getObjectAttributes()
4141
return &pageItemAttributes;
4144
QList<ObjectAttribute> PageItem::getObjectAttributes(QString attributeName) const
4146
QList<ObjectAttribute> attributes;
4147
for(ObjAttrVector::const_iterator objAttrIt = pageItemAttributes.begin() ; objAttrIt != pageItemAttributes.end(); ++objAttrIt )
4149
if (objAttrIt->name == attributeName)
4151
attributes.append(*objAttrIt);
4157
ObjectAttribute PageItem::getObjectAttribute(QString attributeName) const
4160
ObjAttrVector::const_iterator foundIt = pageItemAttributes.begin();
4161
for(ObjAttrVector::const_iterator objAttrIt = pageItemAttributes.begin(); objAttrIt != pageItemAttributes.end(); ++objAttrIt )
4163
if (objAttrIt->name == attributeName)
4166
foundIt = objAttrIt;
4169
ObjectAttribute returnAttribute;
4171
returnAttribute = (*foundIt);
4173
returnAttribute.name = QString::null;
4174
return returnAttribute;
4178
void PageItem::setObjectAttributes(ObjAttrVector* map)
4180
pageItemAttributes=*map;
4183
QString PageItem::generateUniqueCopyName(const QString originalName) const
4185
if (!m_Doc->itemNameExists(originalName))
4186
return originalName;
4188
// Start embellishing the name until we get an acceptable unique name
4189
// first we prefix `Copy of' if it's not already there
4190
QString newname(originalName);
4191
if (!originalName.startsWith( tr("Copy of")))
4192
newname.prepend( tr("Copy of")+" ");
4194
// See if the name prefixed by "Copy of " is free
4195
if (m_Doc->itemNameExists(newname))
4197
// Search the string for (number) at the end and capture
4198
// both the number and the text leading up to it sans brackets.
4200
// ^^^^^^^^^^^^ ^ (where ^ means captured)
4201
static QRegExp rx("^(.*)\\s+\\((\\d+)\\)$");
4202
int numMatches = rx.lastIndexIn(newname);
4203
// Add a (number) suffix to the end of the name. We start at the
4204
// old suffix's value if there was one, or at 2 if there was not.
4206
QString prefix(newname);
4207
if (numMatches != -1)
4209
// Already had a suffix; use the name w/o suffix for prefix and
4210
// grab the old suffix value as a starting point.
4211
QStringList matches = rx.capturedTexts();
4212
prefix = matches[1];
4213
suffixnum = matches[2].toInt();
4215
// Keep on incrementing the suffix 'till we find a free name
4218
newname = prefix + " (" + QString::number(suffixnum) + ")";
4221
while (m_Doc->itemNameExists(newname));
4223
// Unnecessary assert, previous code ensure condition is always true - JG
4224
// assert(!m_Doc->itemNameExists(newname));
4228
void PageItem::setTagged(bool tag)
4233
void PageItem::replaceNamedResources(ResourceCollection& newNames)
4235
QMap<QString,QString>::ConstIterator it;
4237
it = newNames.colors().find(fillColor());
4238
if (it != newNames.colors().end())
4241
it = newNames.colors().find(lineColor());
4242
if (it != newNames.colors().end())
4245
QList<VColorStop*> cstops = fill_gradient.colorStops();
4246
for (uint cst = 0; cst < fill_gradient.Stops(); ++cst)
4248
it = newNames.colors().find(cstops.at(cst)->name);
4249
if (it != newNames.colors().end())
4251
if (*it != CommonStrings::None)
4252
cstops.at(cst)->name = *it;
4255
if (effectsInUse.count() != 0)
4257
QString col1 = CommonStrings::None;
4258
QString col2 = CommonStrings::None;
4259
QString col3 = CommonStrings::None;
4260
QString col4 = CommonStrings::None;
4261
for (int a = 0; a < effectsInUse.count(); ++a)
4263
QString tmpstr = effectsInUse.at(a).effectParameters;
4264
QString tmpstr2 = "";
4265
ScTextStream fp(&tmpstr, QIODevice::ReadOnly);
4266
switch (effectsInUse.at(a).effectCode)
4268
case ScImage::EF_QUADTONE:
4269
col1 = fp.readLine();
4270
col2 = fp.readLine();
4271
col3 = fp.readLine();
4272
col4 = fp.readLine();
4273
it = newNames.colors().find(col1);
4274
if (it != newNames.colors().end())
4276
if (*it != CommonStrings::None)
4277
tmpstr2 += *it + "\n";
4279
tmpstr2 += col1 + "\n";
4282
tmpstr2 += col1 + "\n";
4283
it = newNames.colors().find(col2);
4284
if (it != newNames.colors().end())
4286
if (*it != CommonStrings::None)
4287
tmpstr2 += *it + "\n";
4289
tmpstr2 += col2 + "\n";
4292
tmpstr2 += col2 + "\n";
4293
it = newNames.colors().find(col3);
4294
if (it != newNames.colors().end())
4296
if (*it != CommonStrings::None)
4297
tmpstr2 += *it + "\n";
4299
tmpstr2 += col3 + "\n";
4302
tmpstr2 += col3 + "\n";
4303
it = newNames.colors().find(col4);
4304
if (it != newNames.colors().end())
4306
if (*it != CommonStrings::None)
4307
tmpstr2 += *it + "\n";
4309
tmpstr2 += col4 + "\n";
4312
tmpstr2 += col4 + "\n";
4313
tmpstr2 += fp.readAll();
4315
case ScImage::EF_TRITONE:
4316
col1 = fp.readLine();
4317
col2 = fp.readLine();
4318
col3 = fp.readLine();
4319
it = newNames.colors().find(col1);
4320
if (it != newNames.colors().end())
4322
if (*it != CommonStrings::None)
4323
tmpstr2 += *it + "\n";
4325
tmpstr2 += col1 + "\n";
4328
tmpstr2 += col1 + "\n";
4329
it = newNames.colors().find(col2);
4330
if (it != newNames.colors().end())
4332
if (*it != CommonStrings::None)
4333
tmpstr2 += *it + "\n";
4335
tmpstr2 += col2 + "\n";
4338
tmpstr2 += col2 + "\n";
4339
it = newNames.colors().find(col3);
4340
if (it != newNames.colors().end())
4342
if (*it != CommonStrings::None)
4343
tmpstr2 += *it + "\n";
4345
tmpstr2 += col3 + "\n";
4348
tmpstr2 += col3 + "\n";
4349
tmpstr2 += fp.readAll();
4351
case ScImage::EF_DUOTONE:
4352
col1 = fp.readLine();
4353
col2 = fp.readLine();
4354
it = newNames.colors().find(col1);
4355
if (it != newNames.colors().end())
4357
if (*it != CommonStrings::None)
4358
tmpstr2 += *it + "\n";
4360
tmpstr2 += col1 + "\n";
4363
tmpstr2 += col1 + "\n";
4364
it = newNames.colors().find(col2);
4365
if (it != newNames.colors().end())
4367
if (*it != CommonStrings::None)
4368
tmpstr2 += *it + "\n";
4370
tmpstr2 += col2 + "\n";
4373
tmpstr2 += col2 + "\n";
4374
tmpstr2 += fp.readAll();
4376
case ScImage::EF_COLORIZE:
4377
col1 = fp.readLine();
4378
it = newNames.colors().find(col1);
4379
if (it != newNames.colors().end())
4381
if (*it != CommonStrings::None)
4382
tmpstr2 += *it + "\n" + fp.readAll();
4384
tmpstr2 += col1 + "\n" + fp.readAll();
4387
tmpstr2 += col1 + "\n" + fp.readAll();
4393
effectsInUse[a].effectParameters = tmpstr2;
4397
it = newNames.patterns().find(pattern());
4398
if (it != newNames.patterns().end())
4401
it = newNames.lineStyles().find(customLineStyle());
4402
if (it != newNames.lineStyles().end())
4403
setCustomLineStyle(*it);
4405
if (prevInChain() == NULL)
4406
itemText.replaceNamedResources(newNames);
4410
void PageItem::getNamedResources(ResourceCollection& lists) const
4412
lists.collectColor(lineColor());
4414
lists.collectColor(fillColor());
4415
else if (GrType < 8)
4417
QList<VColorStop*> cstops = fill_gradient.colorStops();
4418
for (uint cst = 0; cst < fill_gradient.Stops(); ++cst)
4420
lists.collectColor(cstops.at(cst)->name);
4423
if (effectsInUse.count() != 0)
4425
for (int a = 0; a < effectsInUse.count(); ++a)
4427
QString tmpstr = effectsInUse.at(a).effectParameters;
4428
ScTextStream fp(&tmpstr, QIODevice::ReadOnly);
4429
switch (effectsInUse.at(a).effectCode)
4431
case ScImage::EF_QUADTONE:
4432
lists.collectColor(fp.readLine());
4433
case ScImage::EF_TRITONE:
4434
lists.collectColor(fp.readLine());
4435
case ScImage::EF_DUOTONE:
4436
lists.collectColor(fp.readLine());
4437
case ScImage::EF_COLORIZE:
4438
lists.collectColor(fp.readLine());
4445
lists.collectPattern(pattern());
4446
lists.collectLineStyle(customLineStyle());
4447
if (prevInChain() == NULL)
4448
itemText.getNamedResources(lists);
4451
void PageItem::copyToCopyPasteBuffer(struct CopyPasteBuffer *Buffer)
4453
Buffer->PType = realItemType();
4454
Buffer->Xpos = Xpos;
4455
Buffer->Ypos = Ypos;
4456
Buffer->Width = Width;
4457
Buffer->Height = Height;
4458
Buffer->RadRect = RadRect;
4459
Buffer->FrameType = FrameType;
4460
Buffer->ClipEdited = ClipEdited;
4461
Buffer->Pwidth = m_lineWidth;
4462
Buffer->Pcolor = fillColor();
4463
Buffer->Pcolor2 = lineColor();
4464
Buffer->Shade = fillShade();
4465
Buffer->Shade2 = lineShade();
4466
Buffer->FillRule = fillRule;
4467
Buffer->GrColor = "";
4468
Buffer->GrColor2 = "";
4469
Buffer->GrShade = 100;
4470
Buffer->GrShade2 = 100;
4471
Buffer->fill_gradient = fill_gradient;
4472
Buffer->GrType = GrType;
4473
Buffer->GrStartX = GrStartX;
4474
Buffer->GrStartY = GrStartY;
4475
Buffer->GrEndX = GrEndX;
4476
Buffer->GrEndY = GrEndY;
4478
Buffer->PLineArt = PLineArt;
4479
Buffer->PLineEnd = PLineEnd;
4480
Buffer->PLineJoin = PLineJoin;
4481
Buffer->LocalScX = LocalScX;
4482
Buffer->LocalScY = LocalScY;
4483
Buffer->LocalX = LocalX;
4484
Buffer->LocalY = LocalY;
4485
Buffer->PicArt = PicArt;
4486
Buffer->flippedH = imageFlippedH();
4487
Buffer->flippedV = imageFlippedV();
4488
/* Buffer->BBoxX = BBoxX;
4489
Buffer->BBoxH = BBoxH; */
4490
Buffer->isPrintable = printEnabled();
4491
Buffer->isBookmark = isBookmark;
4492
// Buffer->BMnr = BMnr;
4493
Buffer->m_isAnnotation = m_isAnnotation;
4494
Buffer->m_annotation = m_annotation;
4495
Buffer->Extra = Extra;
4496
Buffer->TExtra = TExtra;
4497
Buffer->BExtra = BExtra;
4498
Buffer->RExtra = RExtra;
4499
Buffer->firstLineOffsetP = firstLineOffsetP;
4500
Buffer->Pfile = Pfile;
4501
Buffer->Pfile2 = Pfile2;
4502
Buffer->Pfile3 = Pfile3;
4504
uint itemTextCount=itemText.length();
4505
if (itemTextCount != 0)
4507
for (uint a=0; a<itemTextCount; ++a)
4509
if( (itemText.text(a) == '\n') || (itemText.text(a) == '\r'))
4510
Text += QString(QChar(5))+"\t";
4511
else if(itemText.text(a) == '\t')
4512
Text += QString(QChar(4))+"\t";
4514
Text += itemText.text(a,1)+"\t";
4515
Text += itemText.charStyle(a).font().scName()+"\t";
4516
Text += QString::number(itemText.charStyle(a).fontSize() / 10.0)+"\t";
4517
Text += itemText.charStyle(a).fillColor()+"\t";
4518
Text += QString::number(itemText.charStyle(a).tracking())+"\t";
4519
Text += QString::number(itemText.charStyle(a).fillShade())+'\t';
4520
Text += QString::number(itemText.charStyle(a).effects())+'\t';
4521
Text += QString::number(findParagraphStyle(m_Doc, itemText.paragraphStyle(a)))+'\t';
4522
Text += itemText.charStyle(a).strokeColor()+"\t";
4523
Text += QString::number(itemText.charStyle(a).strokeShade())+'\t';
4524
Text += QString::number(itemText.charStyle(a).scaleH())+'\t';
4525
Text += QString::number(itemText.charStyle(a).scaleV())+'\t';
4526
Text += QString::number(itemText.charStyle(a).baselineOffset())+'\t';
4527
Text += QString::number(itemText.charStyle(a).shadowXOffset())+'\t';
4528
Text += QString::number(itemText.charStyle(a).shadowYOffset())+'\t';
4529
Text += QString::number(itemText.charStyle(a).outlineWidth())+'\t';
4530
Text += QString::number(itemText.charStyle(a).underlineOffset())+'\t';
4531
Text += QString::number(itemText.charStyle(a).underlineWidth())+'\t';
4532
Text += QString::number(itemText.charStyle(a).strikethruOffset())+'\t';
4533
Text += QString::number(itemText.charStyle(a).strikethruWidth())+'\n';
4536
if (asLatexFrame()) {
4537
Buffer->itemText = asLatexFrame()->formula();
4539
Buffer->itemText = Text;
4541
Buffer->Clip = Clip;
4542
Buffer->PoLine = PoLine.copy();
4543
Buffer->ContourLine = ContourLine.copy();
4544
//Buffer->UseContour = textFlowUsesContourLine();
4545
Buffer->DashValues = DashValues;
4546
Buffer->DashOffset = DashOffset;
4547
Buffer->PoShow = PoShow;
4548
Buffer->BaseOffs = BaseOffs;
4549
Buffer->textPathFlipped = textPathFlipped;
4550
Buffer->textPathType = textPathType;
4551
Buffer->TextflowMode = textFlowMode();
4552
Buffer->Groups = Groups;
4553
Buffer->IProfile = IProfile;
4554
Buffer->IRender = IRender;
4555
Buffer->UseEmbedded = UseEmbedded;
4556
Buffer->EmProfile = EmProfile;
4557
Buffer->LayerNr = LayerNr;
4558
Buffer->ScaleType = ScaleType;
4559
Buffer->AspectRatio = AspectRatio;
4560
Buffer->Locked = locked();
4561
Buffer->LockRes = sizeLocked();
4562
Buffer->Transparency = fillTransparency();
4563
Buffer->TranspStroke = lineTransparency();
4564
Buffer->TransBlend = fillBlendmode();
4565
Buffer->TransBlendS = lineBlendmode();
4566
Buffer->Reverse = Reverse;
4567
Buffer->NamedLStyle = NamedLStyle;
4568
Buffer->Cols = Cols;
4569
Buffer->ColGap = ColGap;
4570
Buffer->isTableItem = isTableItem;
4571
Buffer->TopLine = TopLine;
4572
Buffer->LeftLine = LeftLine;
4573
Buffer->RightLine = RightLine;
4574
Buffer->BottomLine = BottomLine;
4578
Buffer->TopLinkID = TopLink->ItemNr;
4580
Buffer->TopLinkID = -1;
4582
Buffer->LeftLinkID = LeftLink->ItemNr;
4584
Buffer->LeftLinkID = -1;
4586
Buffer->RightLinkID = RightLink->ItemNr;
4588
Buffer->RightLinkID = -1;
4589
if (BottomLink != 0)
4590
Buffer->BottomLinkID = BottomLink->ItemNr;
4592
Buffer->BottomLinkID = -1;
4594
Buffer->startArrowIndex = m_startArrowIndex;
4595
Buffer->endArrowIndex = m_endArrowIndex;
4600
void PageItem::SetFrameShape(int count, double *vals)
4603
for (int a = 0; a < count-3; a += 4)
4610
double x1 = Width * vals[a] / 100.0;
4611
double y1 = Height * vals[a+1] / 100.0;
4612
double x2 = Width * vals[a+2] / 100.0;
4613
double y2 = Height * vals[a+3] / 100.0;
4614
PoLine.addPoint(x1, y1);
4615
PoLine.addPoint(x2, y2);
4617
Clip = FlattenPath(PoLine, Segments);
4621
void PageItem::SetRectFrame()
4623
static double rect[] = { 0.0, 0.0, 0.0, 0.0,
4624
100.0, 0.0, 100.0, 0.0,
4625
100.0, 0.0, 100.0, 0.0,
4626
100.0, 100.0, 100.0, 100.0,
4627
100.0, 100.0, 100.0, 100.0,
4628
0.0, 100.0, 0.0, 100.0,
4629
0.0, 100.0, 0.0, 100.0,
4630
0.0, 0.0, 0.0, 0.0};
4631
SetFrameShape(32, rect);
4636
void PageItem::SetOvalFrame()
4638
static double rect[] = { 100.0, 50.0, 100.0, 77.615235,
4639
50.0, 100.0, 77.615235, 100.0,
4640
50.0, 100.0, 22.385765, 100.0,
4641
0.0, 50.0, 0.0, 77.615235,
4642
0.0, 50.0, 0.0, 22.385765,
4643
50.0, 0.0, 22.385765, 0.0,
4644
50.0, 0.0, 77.615235, 0.0,
4645
100.0, 50.0, 100.0, 22.385765};
4646
SetFrameShape(32, rect);
4651
void PageItem::SetFrameRound()
4653
setCornerRadius(qMin(RadRect, qMin(Width,Height)/2));
4655
double rr = fabs(RadRect);
4656
double bezierFactor=0.552284749; //Bezier Control Point Factor: 8/3*(sin(45)-0.5)
4657
double rrxBezierFactor=rr*bezierFactor;
4658
double Width_rr=Width-rr;
4659
double Height_rr=Height-rr;
4662
PoLine.addQuadPoint(rr, 0, rr, 0, Width_rr, 0, Width_rr, 0);
4663
PoLine.addQuadPoint(Width_rr, 0, Width_rr+rrxBezierFactor, 0, Width, rr, Width, rr-rrxBezierFactor);
4664
PoLine.addQuadPoint(Width, rr, Width, rr, Width, Height_rr, Width, Height_rr);
4665
PoLine.addQuadPoint(Width, Height_rr, Width, Height_rr+rrxBezierFactor, Width_rr, Height, Width_rr+rrxBezierFactor, Height);
4666
PoLine.addQuadPoint(Width_rr, Height, Width_rr, Height, rr, Height, rr, Height);
4667
PoLine.addQuadPoint(rr, Height, rr-rrxBezierFactor, Height, 0, Height_rr, 0, Height_rr+rrxBezierFactor);
4668
PoLine.addQuadPoint(0, Height_rr, 0, Height_rr, 0, rr, 0, rr);
4669
PoLine.addQuadPoint(0, rr, 0, rr-rrxBezierFactor, rr, 0, rr-rrxBezierFactor, 0);
4673
PoLine.addQuadPoint(rr, 0, rr, 0, Width_rr, 0, Width_rr, 0);
4674
PoLine.addQuadPoint(Width_rr, 0, Width_rr, rrxBezierFactor, Width, rr, Width-rrxBezierFactor, rr);
4675
PoLine.addQuadPoint(Width, rr, Width, rr, Width, Height_rr, Width, Height_rr);
4676
PoLine.addQuadPoint(Width, Height_rr, Width-rrxBezierFactor, Height_rr, Width_rr, Height, Width_rr, Height-rrxBezierFactor);
4677
PoLine.addQuadPoint(Width_rr, Height, Width_rr, Height, rr, Height, rr, Height);
4678
PoLine.addQuadPoint(rr, Height, rr, Height-rrxBezierFactor, 0, Height_rr, rrxBezierFactor, Height_rr);
4679
PoLine.addQuadPoint(0, Height_rr, 0, Height_rr, 0, rr, 0, rr);
4680
PoLine.addQuadPoint(0, rr, rrxBezierFactor, rr, rr, 0, rr, rr*bezierFactor);
4682
Clip = FlattenPath(PoLine, Segments);
4689
void PageItem::getTransform(QMatrix& mat) const
4691
mat.translate(Xpos, Ypos);
4695
QMatrix PageItem::getTransform() const
4698
getTransform(result);
4702
QRectF PageItem::getBoundingRect() const
4705
getBoundingRect(&x, &y, &x2, &y2);
4706
return QRectF(x,y,x2-x,y2-y);
4709
QRectF PageItem::getCurrentBoundingRect(double moreSpace) const
4711
double x = BoundingX - moreSpace / 2.0;
4712
double y = BoundingY - moreSpace / 2.0;
4713
double w = BoundingW + moreSpace;
4714
double h = BoundingH + moreSpace;
4715
QRectF ret = QRectF(x, y, w, h);
4719
QRectF PageItem::getVisualBoundingRect() const
4722
getVisualBoundingRect(&x, &y, &x2, &y2);
4723
return QRectF(x,y,x2-x,y2-y);
4726
void PageItem::getBoundingRect(double *x1, double *y1, double *x2, double *y2) const
4728
double minx = std::numeric_limits<double>::max();
4729
double miny = std::numeric_limits<double>::max();
4730
double maxx = -std::numeric_limits<double>::max();
4731
double maxy = -std::numeric_limits<double>::max();
4736
pb.addPoint(FPoint(Xpos, Ypos));
4737
pb.addPoint(FPoint(Width, 0.0, Xpos, Ypos, Rot, 1.0, 1.0));
4738
pb.addPoint(FPoint(Width, Height, Xpos, Ypos, Rot, 1.0, 1.0));
4739
pb.addPoint(FPoint( 0.0, Height, Xpos, Ypos, Rot, 1.0, 1.0));
4740
for (uint pc = 0; pc < 4; ++pc)
4742
minx = qMin(minx, pb.point(pc).x());
4743
miny = qMin(miny, pb.point(pc).y());
4744
maxx = qMax(maxx, pb.point(pc).x());
4745
maxy = qMax(maxy, pb.point(pc).y());
4756
*x2 = Xpos + qMax(Width, m_lineWidth);
4757
*y2 = Ypos + qMax(Height, m_lineWidth);
4759
QRectF totalRect = QRectF(QPointF(*x1, *y1), QPointF(*x2, *y2));
4760
if (m_startArrowIndex != 0)
4763
FPointArray arrow = m_Doc->arrowStyles.at(m_startArrowIndex-1).points.copy();
4764
arrowTrans.translate(Xpos, Ypos);
4765
arrowTrans.rotate(Rot);
4766
if (itemType() == Line)
4768
arrowTrans.translate(0, 0);
4769
if (NamedLStyle.isEmpty())
4771
if (m_lineWidth != 0.0)
4772
arrowTrans.scale(m_lineWidth, m_lineWidth);
4776
multiLine ml = m_Doc->MLineStyles[NamedLStyle];
4777
if (ml[ml.size()-1].Width != 0.0)
4778
arrowTrans.scale(ml[ml.size()-1].Width, ml[ml.size()-1].Width);
4780
arrowTrans.scale(-1,1);
4781
arrow.map(arrowTrans);
4785
FPoint Start = PoLine.point(0);
4786
for (uint xx = 1; xx < PoLine.size(); xx += 2)
4788
FPoint Vector = PoLine.point(xx);
4789
if ((Start.x() != Vector.x()) || (Start.y() != Vector.y()))
4791
arrowTrans.translate(Start.x(), Start.y());
4792
arrowTrans.rotate(atan2(Start.y()-Vector.y(),Start.x()-Vector.x())*(180.0/M_PI));
4793
if (NamedLStyle.isEmpty())
4795
if (m_lineWidth != 0.0)
4796
arrowTrans.scale(m_lineWidth, m_lineWidth);
4800
multiLine ml = m_Doc->MLineStyles[NamedLStyle];
4801
if (ml[ml.size()-1].Width != 0.0)
4802
arrowTrans.scale(ml[ml.size()-1].Width, ml[ml.size()-1].Width);
4804
arrow.map(arrowTrans);
4809
FPoint minAr = getMinClipF(&arrow);
4810
FPoint maxAr = getMaxClipF(&arrow);
4811
totalRect = totalRect.united(QRectF(QPointF(minAr.x(), minAr.y()), QPointF(maxAr.x(), maxAr.y())));
4813
if (m_endArrowIndex != 0)
4816
FPointArray arrow = m_Doc->arrowStyles.at(m_endArrowIndex-1).points.copy();
4817
arrowTrans.translate(Xpos, Ypos);
4818
arrowTrans.rotate(Rot);
4819
if (itemType() == Line)
4821
arrowTrans.translate(Width, 0);
4822
if (NamedLStyle.isEmpty())
4824
if (m_lineWidth != 0.0)
4825
arrowTrans.scale(m_lineWidth, m_lineWidth);
4829
multiLine ml = m_Doc->MLineStyles[NamedLStyle];
4830
if (ml[ml.size()-1].Width != 0.0)
4831
arrowTrans.scale(ml[ml.size()-1].Width, ml[ml.size()-1].Width);
4833
arrow.map(arrowTrans);
4837
FPoint End = PoLine.point(PoLine.size()-2);
4838
for (uint xx = PoLine.size()-1; xx > 0; xx -= 2)
4840
FPoint Vector = PoLine.point(xx);
4841
if ((End.x() != Vector.x()) || (End.y() != Vector.y()))
4843
arrowTrans.translate(End.x(), End.y());
4844
arrowTrans.rotate(atan2(End.y()-Vector.y(),End.x()-Vector.x())*(180.0/M_PI));
4845
if (NamedLStyle.isEmpty())
4847
if (m_lineWidth != 0.0)
4848
arrowTrans.scale(m_lineWidth, m_lineWidth);
4852
multiLine ml = m_Doc->MLineStyles[NamedLStyle];
4853
if (ml[ml.size()-1].Width != 0.0)
4854
arrowTrans.scale(ml[ml.size()-1].Width, ml[ml.size()-1].Width);
4856
arrow.map(arrowTrans);
4861
FPoint minAr = getMinClipF(&arrow);
4862
FPoint maxAr = getMaxClipF(&arrow);
4863
totalRect = totalRect.united(QRectF(QPointF(minAr.x(), minAr.y()), QPointF(maxAr.x(), maxAr.y())));
4866
qreal rx1, ry1, rx2, ry2;
4867
totalRect.getCoords(&rx1, &ry1, &rx2, &ry2);
4868
*x1 = rx1; *y1 = ry1;
4869
*x2 = rx2; *y2 = ry2;
4872
void PageItem::getVisualBoundingRect(double * x1, double * y1, double * x2, double * y2) const
4874
double minx = std::numeric_limits<double>::max();
4875
double miny = std::numeric_limits<double>::max();
4876
double maxx = -std::numeric_limits<double>::max();
4877
double maxy = -std::numeric_limits<double>::max();
4878
double extraSpace = 0.0;
4879
if (NamedLStyle.isEmpty())
4881
if (lineColor() != CommonStrings::None)
4883
if ((itemType() == Line) && (PLineEnd == Qt::FlatCap))
4886
extraSpace = m_lineWidth / 2.0;
4891
multiLine ml = m_Doc->MLineStyles[NamedLStyle];
4892
struct SingleLine& sl = ml[ml.size()-1];
4893
if ((sl.Color != CommonStrings::None) && (sl.Width != 0))
4894
extraSpace = sl.Width / 2.0;
4900
pb.addPoint(FPoint(-extraSpace, -extraSpace, xPos(), yPos(), Rot, 1.0, 1.0));
4901
pb.addPoint(FPoint(visualWidth()-extraSpace, -extraSpace, xPos(), yPos(), Rot, 1.0, 1.0));
4902
pb.addPoint(FPoint(visualWidth()-extraSpace, visualHeight()-extraSpace, xPos(), yPos(), Rot, 1.0, 1.0));
4903
pb.addPoint(FPoint(-extraSpace, visualHeight()-extraSpace, xPos(), yPos(), Rot, 1.0, 1.0));
4904
for (uint pc = 0; pc < 4; ++pc)
4906
minx = qMin(minx, pb.point(pc).x());
4907
miny = qMin(miny, pb.point(pc).y());
4908
maxx = qMax(maxx, pb.point(pc).x());
4909
maxy = qMax(maxy, pb.point(pc).y());
4920
*x2 = *x1 + qMax(visualWidth(), extraSpace);
4921
*y2 = *y1 + qMax(visualHeight(), extraSpace);
4923
QRectF totalRect = QRectF(QPointF(*x1, *y1), QPointF(*x2, *y2));
4924
if (m_startArrowIndex != 0)
4927
FPointArray arrow = m_Doc->arrowStyles.at(m_startArrowIndex-1).points.copy();
4928
arrowTrans.translate(Xpos, Ypos);
4929
arrowTrans.rotate(Rot);
4930
if (itemType() == Line)
4932
arrowTrans.translate(0, 0);
4933
if (NamedLStyle.isEmpty())
4935
if (m_lineWidth != 0.0)
4936
arrowTrans.scale(m_lineWidth, m_lineWidth);
4940
multiLine ml = m_Doc->MLineStyles[NamedLStyle];
4941
if (ml[ml.size()-1].Width != 0.0)
4942
arrowTrans.scale(ml[ml.size()-1].Width, ml[ml.size()-1].Width);
4944
arrowTrans.scale(-1,1);
4945
arrow.map(arrowTrans);
4949
FPoint Start = PoLine.point(0);
4950
for (uint xx = 1; xx < PoLine.size(); xx += 2)
4952
FPoint Vector = PoLine.point(xx);
4953
if ((Start.x() != Vector.x()) || (Start.y() != Vector.y()))
4955
arrowTrans.translate(Start.x(), Start.y());
4956
arrowTrans.rotate(atan2(Start.y()-Vector.y(),Start.x()-Vector.x())*(180.0/M_PI));
4957
if (NamedLStyle.isEmpty())
4959
if (m_lineWidth != 0.0)
4960
arrowTrans.scale(m_lineWidth, m_lineWidth);
4964
multiLine ml = m_Doc->MLineStyles[NamedLStyle];
4965
if (ml[ml.size()-1].Width != 0.0)
4966
arrowTrans.scale(ml[ml.size()-1].Width, ml[ml.size()-1].Width);
4968
arrow.map(arrowTrans);
4973
FPoint minAr = getMinClipF(&arrow);
4974
FPoint maxAr = getMaxClipF(&arrow);
4975
totalRect = totalRect.united(QRectF(QPointF(minAr.x(), minAr.y()), QPointF(maxAr.x(), maxAr.y())));
4977
if (m_endArrowIndex != 0)
4980
FPointArray arrow = m_Doc->arrowStyles.at(m_endArrowIndex-1).points.copy();
4981
arrowTrans.translate(Xpos, Ypos);
4982
arrowTrans.rotate(Rot);
4983
if (itemType() == Line)
4985
arrowTrans.translate(Width, 0);
4986
if (NamedLStyle.isEmpty())
4988
if (m_lineWidth != 0.0)
4989
arrowTrans.scale(m_lineWidth, m_lineWidth);
4993
multiLine ml = m_Doc->MLineStyles[NamedLStyle];
4994
if (ml[ml.size()-1].Width != 0.0)
4995
arrowTrans.scale(ml[ml.size()-1].Width, ml[ml.size()-1].Width);
4997
arrow.map(arrowTrans);
5001
FPoint End = PoLine.point(PoLine.size()-2);
5002
for (uint xx = PoLine.size()-1; xx > 0; xx -= 2)
5004
FPoint Vector = PoLine.point(xx);
5005
if ((End.x() != Vector.x()) || (End.y() != Vector.y()))
5007
arrowTrans.translate(End.x(), End.y());
5008
arrowTrans.rotate(atan2(End.y()-Vector.y(),End.x()-Vector.x())*(180.0/M_PI));
5009
if (NamedLStyle.isEmpty())
5011
if (m_lineWidth != 0.0)
5012
arrowTrans.scale(m_lineWidth, m_lineWidth);
5016
multiLine ml = m_Doc->MLineStyles[NamedLStyle];
5017
if (ml[ml.size()-1].Width != 0.0)
5018
arrowTrans.scale(ml[ml.size()-1].Width, ml[ml.size()-1].Width);
5020
arrow.map(arrowTrans);
5025
FPoint minAr = getMinClipF(&arrow);
5026
FPoint maxAr = getMaxClipF(&arrow);
5027
totalRect = totalRect.united(QRectF(QPointF(minAr.x(), minAr.y()), QPointF(maxAr.x(), maxAr.y())));
5030
qreal rx1, ry1, rx2, ry2;
5031
totalRect.getCoords(&rx1, &ry1, &rx2, &ry2);
5032
*x1 = rx1; *y1 = ry1;
5033
*x2 = rx2; *y2 = ry2;
5036
double PageItem::visualXPos() const
5038
double extraSpace = 0.0;
5041
if (NamedLStyle.isEmpty())
5043
if (lineColor() != CommonStrings::None)
5044
extraSpace = m_lineWidth / 2.0;
5048
multiLine ml = m_Doc->MLineStyles[NamedLStyle];
5049
struct SingleLine& sl = ml[ml.size()-1];
5050
if ((sl.Color != CommonStrings::None) && (sl.Width != 0))
5051
extraSpace = sl.Width / 2.0;
5054
return Xpos - extraSpace;
5057
double PageItem::visualYPos() const
5059
double extraSpace = 0.0;
5060
if (NamedLStyle.isEmpty())
5062
if (lineColor() != CommonStrings::None)
5063
extraSpace = m_lineWidth / 2.0;
5067
multiLine ml = m_Doc->MLineStyles[NamedLStyle];
5068
struct SingleLine& sl = ml[ml.size()-1];
5069
if ((sl.Color != CommonStrings::None) && (sl.Width != 0))
5070
extraSpace = sl.Width / 2.0;
5072
return Ypos - extraSpace;
5075
double PageItem::visualWidth() const
5077
double extraSpace = 0.0;
5080
if (NamedLStyle.isEmpty())
5082
if (lineColor() != CommonStrings::None)
5083
extraSpace = m_lineWidth;
5087
multiLine ml = m_Doc->MLineStyles[NamedLStyle];
5088
struct SingleLine& sl = ml[ml.size()-1];
5089
if ((sl.Color != CommonStrings::None) && (sl.Width != 0))
5090
extraSpace = sl.Width;
5093
return Width + extraSpace;
5096
double PageItem::visualHeight() const
5098
double extraSpace = 0.0;
5099
if (NamedLStyle.isEmpty())
5101
if (lineColor() != CommonStrings::None)
5102
extraSpace = m_lineWidth;
5106
multiLine ml = m_Doc->MLineStyles[NamedLStyle];
5107
struct SingleLine& sl = ml[ml.size()-1];
5108
if ((sl.Color != CommonStrings::None) && (sl.Width != 0))
5109
extraSpace = sl.Width;
5111
return isLine() ? extraSpace : Height + extraSpace;
5114
bool PageItem::pointWithinItem(const int x, const int y) const
5116
const_cast<PageItem*>(this)-> setRedrawBounding();
5117
// FIXME: We should be rounding or truncating here, not letting the compiler do it.
5118
// Should we be rounding, truncating up, or truncating down?
5119
//CB is this now correct?
5120
QRect itemRect( static_cast<int>(floor(BoundingX)), static_cast<int>(floor(BoundingY)), static_cast<int>(ceil(BoundingW)), static_cast<int>(ceil(BoundingH)) );
5121
return itemRect.contains(x, y);
5124
bool PageItem::mouseWithinItem(const int x, const int y, double scale) const
5128
p.translate(Xpos * scale, Ypos*scale);
5129
p.scale(scale, scale);
5130
p.rotate(rotation());
5131
transRect = p.mapRect(QRectF(0.0, 0.0, width(), height()));
5132
return transRect.contains(x, y);
5135
bool PageItem::loadImage(const QString& filename, const bool reload, const int gsResolution, bool showMsg)
5137
bool useImage = (asImageFrame() != NULL);
5138
useImage |= (isAnnotation() && annotation().UseIcons());
5141
QFileInfo fi(filename);
5142
QString clPath(pixm.imgInfo.usedPath);
5143
pixm.imgInfo.valid = false;
5144
pixm.imgInfo.clipPath="";
5145
pixm.imgInfo.PDSpathData.clear();
5146
pixm.imgInfo.layerInfo.clear();
5147
pixm.imgInfo.usedPath="";
5148
imageClip.resize(0);
5149
int lowResTypeBack = pixm.imgInfo.lowResType;
5150
int gsRes=gsResolution;
5151
if (gsResolution==-1) //If it wasn't supplied, get it from PrefsManager.
5152
gsRes=PrefsManager::instance()->gsResolution();
5154
CMSettings cms(m_Doc, IProfile, IRender);
5155
if (!pixm.LoadPicture(filename, pixm.imgInfo.actualPageNumber, cms, UseEmbedded, true, ScImage::RGBProof, gsRes, &dummy, showMsg))
5157
Pfile = fi.absoluteFilePath();
5158
PictureIsAvailable = false;
5164
QString ext = fi.suffix().toLower();
5165
if (UndoManager::undoEnabled() && !reload)
5167
ItemState<ScImageEffectList> *is = new ItemState<ScImageEffectList>(Um::GetImage, filename, Um::IGetImage);
5168
is->set("GET_IMAGE", "get_image");
5169
is->set("OLD_IMAGE_PATH", Pfile);
5170
is->set("NEW_IMAGE_PATH", filename);
5171
is->set("FLIPPH",imageFlippedH());
5172
is->set("FLIPPV",imageFlippedV());
5173
is->set("SCALING",ScaleType);
5174
is->set("ASPECT",AspectRatio);
5175
is->set("XOFF",imageXOffset());
5176
is->set("XSCALE",imageXScale());
5177
is->set("YOFF",imageYOffset());
5178
is->set("YSCALE",imageYScale());
5179
is->set("FILLT", fillTransparency());
5180
is->set("LINET", lineTransparency());
5181
is->setItem(effectsInUse);
5182
undoManager->action(this, is);
5184
double xres = pixm.imgInfo.xres;
5185
double yres = pixm.imgInfo.yres;
5186
PictureIsAvailable = true;
5189
if (Pfile != filename)
5191
oldLocalScX = LocalScX = 72.0 / xres;
5192
oldLocalScY = LocalScY = 72.0 / yres;
5193
oldLocalX = LocalX = 0;
5194
oldLocalY = LocalY = 0;
5196
if ((m_Doc->toolSettings.useEmbeddedPath) && (!pixm.imgInfo.clipPath.isEmpty()))
5198
pixm.imgInfo.usedPath = pixm.imgInfo.clipPath;
5199
clPath = pixm.imgInfo.clipPath;
5200
if (pixm.imgInfo.PDSpathData.contains(clPath))
5202
imageClip = pixm.imgInfo.PDSpathData[clPath].copy();
5203
pixm.imgInfo.usedPath = clPath;
5205
cl.translate(LocalX*LocalScX, LocalY*LocalScY);
5206
cl.scale(LocalScX, LocalScY);
5212
Pfile = fi.absoluteFilePath();
5213
if (reload && pixm.imgInfo.PDSpathData.contains(clPath))
5215
imageClip = pixm.imgInfo.PDSpathData[clPath].copy();
5216
pixm.imgInfo.usedPath = clPath;
5218
cl.translate(LocalX*LocalScX, LocalY*LocalScY);
5219
cl.scale(LocalScX, LocalScY);
5222
BBoxX = pixm.imgInfo.BBoxX;
5223
BBoxH = pixm.imgInfo.BBoxH;
5224
OrigW = pixm.width();
5225
OrigH = pixm.height();
5226
isRaster = !(extensionIndicatesPDF(ext) || extensionIndicatesEPSorPS(ext));
5228
effectsInUse.clear();
5229
UseEmbedded=pixm.imgInfo.isEmbedded;
5230
if (pixm.imgInfo.isEmbedded)
5232
IProfile = "Embedded " + pixm.imgInfo.profileName;
5233
EmProfile = "Embedded " + pixm.imgInfo.profileName;
5236
IProfile = pixm.imgInfo.profileName;
5239
if (PictureIsAvailable)
5241
if ((pixm.imgInfo.colorspace == ColorSpaceDuotone) && (pixm.imgInfo.duotoneColors.count() != 0) && (!reload))
5244
for (int cc = 0; cc < pixm.imgInfo.duotoneColors.count(); cc++)
5246
if (!m_Doc->PageColors.contains(pixm.imgInfo.duotoneColors[cc].Name))
5247
m_Doc->PageColors.insert(pixm.imgInfo.duotoneColors[cc].Name, pixm.imgInfo.duotoneColors[cc].Color);
5248
efVal += pixm.imgInfo.duotoneColors[cc].Name+"\n";
5250
m_Doc->scMW()->propertiesPalette->updateColorList();
5251
struct ImageEffect ef;
5252
if (pixm.imgInfo.duotoneColors.count() == 1)
5255
ef.effectCode = ScImage::EF_COLORIZE;
5256
ef.effectParameters = efVal;
5258
else if (pixm.imgInfo.duotoneColors.count() == 2)
5262
FPointArray Vals = pixm.imgInfo.duotoneColors[0].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[1].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_DUOTONE;
5281
ef.effectParameters = efVal;
5283
else if (pixm.imgInfo.duotoneColors.count() == 3)
5285
efVal += "100 100 100";
5287
FPointArray Vals = pixm.imgInfo.duotoneColors[0].Curve;
5288
tmp.setNum(Vals.size());
5290
for (uint p = 0; p < Vals.size(); p++)
5292
FPoint pv = Vals.point(p);
5293
efVal += QString(" %1 %2").arg(pv.x()).arg(pv.y());
5296
Vals = pixm.imgInfo.duotoneColors[1].Curve;
5297
tmp.setNum(Vals.size());
5299
for (uint p = 0; p < Vals.size(); p++)
5301
FPoint pv = Vals.point(p);
5302
efVal += QString(" %1 %2").arg(pv.x()).arg(pv.y());
5305
Vals = pixm.imgInfo.duotoneColors[2].Curve;
5306
tmp.setNum(Vals.size());
5308
for (uint p = 0; p < Vals.size(); p++)
5310
FPoint pv = Vals.point(p);
5311
efVal += QString(" %1 %2").arg(pv.x()).arg(pv.y());
5314
ef.effectCode = ScImage::EF_TRITONE;
5315
ef.effectParameters = efVal;
5317
else if (pixm.imgInfo.duotoneColors.count() == 4)
5319
efVal += "100 100 100 100";
5321
FPointArray Vals = pixm.imgInfo.duotoneColors[0].Curve;
5322
tmp.setNum(Vals.size());
5324
for (uint p = 0; p < Vals.size(); p++)
5326
FPoint pv = Vals.point(p);
5327
efVal += QString(" %1 %2").arg(pv.x()).arg(pv.y());
5330
Vals = pixm.imgInfo.duotoneColors[1].Curve;
5331
tmp.setNum(Vals.size());
5333
for (uint p = 0; p < Vals.size(); p++)
5335
FPoint pv = Vals.point(p);
5336
efVal += QString(" %1 %2").arg(pv.x()).arg(pv.y());
5339
Vals = pixm.imgInfo.duotoneColors[2].Curve;
5340
tmp.setNum(Vals.size());
5342
for (uint p = 0; p < Vals.size(); p++)
5344
FPoint pv = Vals.point(p);
5345
efVal += QString(" %1 %2").arg(pv.x()).arg(pv.y());
5348
Vals = pixm.imgInfo.duotoneColors[3].Curve;
5349
tmp.setNum(Vals.size());
5351
for (uint p = 0; p < Vals.size(); p++)
5353
FPoint pv = Vals.point(p);
5354
efVal += QString(" %1 %2").arg(pv.x()).arg(pv.y());
5357
ef.effectCode = ScImage::EF_QUADTONE;
5358
ef.effectParameters = efVal;
5360
effectsInUse.append(ef);
5362
pixm.applyEffect(effectsInUse, m_Doc->PageColors, false);
5364
pixm.imgInfo.lowResType = lowResTypeBack;
5365
if (pixm.imgInfo.lowResType != 0)
5367
double scaling = pixm.imgInfo.xres / 36.0;
5368
if (pixm.imgInfo.lowResType == 1)
5369
scaling = pixm.imgInfo.xres / 72.0;
5370
// Prevent exagerately large images when using low res preview modes
5371
uint pixels = qRound(pixm.width() * pixm.height() / (scaling * scaling));
5372
if (pixels > 3000000)
5374
double ratio = pixels / 3000000.0;
5375
scaling *= sqrt(ratio);
5377
pixm.createLowRes(scaling);
5378
pixm.imgInfo.lowResScale = scaling;
5380
if ((m_Doc->view()->m_canvas->usePreviewVisual()))
5382
VisionDefectColor defect;
5384
int h = pixm.qImagePtr()->height();
5385
int w = pixm.qImagePtr()->width();
5389
for( int yi=0; yi < h; ++yi )
5391
s = (QRgb*)(pixm.qImagePtr()->scanLine( yi ));
5392
for( int xi = 0; xi < w; ++xi )
5396
tmpC = defect.convertDefect(tmpC, m_Doc->view()->m_canvas->previewVisual());
5398
tmpC.getRgb(&r, &g, &b);
5399
*s = qRgba(r, g, b, a);
5409
void PageItem::drawLockedMarker(ScPainter *p)
5412
double scp1 = 1 ;// / ScMW->view->scale();
5413
double ofwh = 6 * scp1;
5414
double ofx = Width - ofwh/2;
5415
double ofy = Height - ofwh*1.5;
5416
double bx1= ofx+ scp1;
5417
double by1= ofy+3 * scp1;
5420
ScribusView* view = m_Doc->view();
5421
p->setPen(Qt::black, 0.5 / view->scale(), Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
5422
p->setPenOpacity(1.0);
5423
p->setBrush(Qt::white);
5424
p->setBrushOpacity(1.0);
5425
p->setFillMode(ScPainter::Solid);
5426
p->drawRect(ofx, ofy, ofwh, ofwh);
5427
p->setBrush(Qt::black);
5428
p->drawRect(bx1, by1, bw, bh);
5429
p->setPen(Qt::black, 1.5 / view->scale(), Qt::SolidLine, Qt::FlatCap, Qt::RoundJoin);
5431
p->drawLine(FPoint(bx1+scp1/2, ofy+scp1), FPoint(bx1+scp1/2, by1));
5432
p->drawLine(FPoint(bx1+scp1*3.5, ofy+scp1), FPoint(bx1+scp1*3.5, by1));
5433
p->drawLine(FPoint(bx1+scp1/2, ofy+scp1), FPoint(bx1+scp1*3.5, ofy+scp1));
5436
void PageItem::drawArrow(ScPainter *p, QMatrix &arrowTrans, int arrowIndex)
5438
FPointArray arrow = m_Doc->arrowStyles.at(arrowIndex-1).points.copy();
5439
if (NamedLStyle.isEmpty())
5441
if (m_lineWidth != 0.0)
5442
arrowTrans.scale(m_lineWidth, m_lineWidth);
5446
multiLine ml = m_Doc->MLineStyles[NamedLStyle];
5447
if (ml[ml.size()-1].Width != 0.0)
5448
arrowTrans.scale(ml[ml.size()-1].Width, ml[ml.size()-1].Width);
5450
arrow.map(arrowTrans);
5451
p->setupPolygon(&arrow);
5452
if (m_Doc->layerOutline(LayerNr))
5456
if (NamedLStyle.isEmpty())
5458
if (lineColor() != CommonStrings::None)
5460
p->setBrush(strokeQColor);
5461
p->setBrushOpacity(1.0 - lineTransparency());
5463
p->setFillMode(ScPainter::Solid);
5469
multiLine ml = m_Doc->MLineStyles[NamedLStyle];
5471
if (ml[0].Color != CommonStrings::None)
5473
SetQColor(&tmp, ml[0].Color, ml[0].Shade);
5476
p->setFillMode(ScPainter::Solid);
5479
for (int it = ml.size()-1; it > 0; it--)
5481
if (ml[it].Color != CommonStrings::None)
5483
SetQColor(&tmp, ml[it].Color, ml[it].Shade);
5484
p->setPen(tmp, ml[it].Width, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
5492
void PageItem::AdjustPictScale()
5494
if (itemType()!=PageItem::ImageFrame)
5498
if (OrigW == 0 || OrigH == 0)
5502
double xs = Width / static_cast<double>(OrigW);
5503
double ys = Height / static_cast<double>(OrigH);
5506
LocalScX = qMin(xs, ys);
5507
LocalScY = qMin(xs, ys);
5514
// Disable broken code. Code must be independent from doc in that function
5515
/*switch (m_Doc->RotMode)
5522
LocalX = (Width - static_cast<double>(OrigW) * LocalScX) / LocalScX;
5526
LocalX = ((Width - static_cast<double>(OrigW) * LocalScX) / LocalScX) / 2.0;
5527
LocalY = ((Height - static_cast<double>(OrigH) * LocalScY) / LocalScY) / 2.0;
5531
LocalY = (Height - static_cast<double>(OrigH) * LocalScY) / LocalScY;
5534
LocalX = (Width - static_cast<double>(OrigW) * LocalScX) / LocalScX;
5535
LocalY = (Height - static_cast<double>(OrigH) * LocalScY) / LocalScY;
5538
if (imageClip.size() != 0)
5540
imageClip = pixm.imgInfo.PDSpathData[pixm.imgInfo.usedPath].copy();
5542
cl.translate(LocalX*LocalScX, LocalY*LocalScY);
5543
cl.scale(LocalScX, LocalScY);
5546
emit imageOffsetScale(LocalScX, LocalScY, LocalX, LocalY );
5549
void PageItem::setExternalFile(QString val)
5552
if (!Pfile.isEmpty())
5554
QString test = Pfile;
5555
if (QDir::isRelativePath(test))
5556
test = QDir::homePath()+"/"+Pfile;
5557
test = QDir::cleanPath(QDir::toNativeSeparators(test));
5558
QFileInfo pfi2(test);
5559
Pfile = pfi2.absoluteFilePath();
5563
void PageItem::setFileIconPressed(QString val)
5566
if (!Pfile2.isEmpty())
5568
QString test = QDir::cleanPath(QDir::toNativeSeparators(QDir::homePath()+"/"+Pfile2));
5569
QFileInfo pfi2(test);
5570
Pfile2 = pfi2.absoluteFilePath();
5574
void PageItem::setFileIconRollover(QString val)
5577
if (!Pfile3.isEmpty())
5579
QString test = QDir::cleanPath(QDir::toNativeSeparators(QDir::homePath()+"/"+Pfile3));
5580
QFileInfo pfi2(test);
5581
Pfile3 = pfi2.absoluteFilePath();
5585
QRect PageItem::getRedrawBounding(const double viewScale)
5587
int x = qRound(floor(BoundingX - Oldm_lineWidth / 2.0 - 5) * viewScale);
5588
int y = qRound(floor(BoundingY - Oldm_lineWidth / 2.0 - 5) * viewScale);
5589
int w = qRound(ceil(BoundingW + Oldm_lineWidth + 10) * viewScale);
5590
int h = qRound(ceil(BoundingH + Oldm_lineWidth + 10) * viewScale);
5591
QRect ret = QRect(x, y, w, h);
5592
ret.translate(qRound(-m_Doc->minCanvasCoordinate.x() * viewScale), qRound(-m_Doc->minCanvasCoordinate.y() * viewScale));
5597
void PageItem::setRedrawBounding()
5600
getBoundingRect(&BoundingX, &BoundingY, &bw, &bh);
5601
BoundingW = bw - BoundingX;
5602
BoundingH = bh - BoundingY;
5604
BoundingH = qMax(BoundingH, 1.0);
5607
void PageItem::updateGradientVectors()
5614
GrStartY = Height / 2.0;
5616
GrEndY = Height / 2.0;
5619
GrStartX = Width / 2.0;
5621
GrEndX = Width / 2.0;
5637
GrStartX = Width / 2.0;
5638
GrStartY = Height / 2.0;
5639
if (Width >= Height)
5642
GrEndY = Height / 2.0;
5646
GrEndX = Width / 2.0;
5653
//if (ScMW->view->SelItem.count()!=0 && this==ScMW->view->SelItem.at(0))
5654
//if (m_Doc->m_Selection->count()!=0 && m_Doc->m_Selection->primarySelectionIsMyself(this))
5655
// ScMW->propertiesPalette->updateColorSpecialGradient();
5656
//CB Will only emit if connected, ie is first in GUI selection
5657
double dur=m_Doc->unitRatio();
5658
emit gradientColorUpdate(GrStartX*dur, GrStartY*dur, GrEndX*dur, GrEndY*dur, Width*dur, Height*dur);
5661
void PageItem::setPolyClip(int up, int down)
5663
if (PoLine.size() < 4)
5670
if (textPathFlipped)
5676
QPolygon cl, cl1, cl2;
5677
cl = FlattenPath(PoLine, Segments);
5681
for (int a = 0; a < cl.size()-1; ++a)
5683
rot = xy2Deg(cl.point(a+1).x()-cl.point(a).x(),cl.point(a+1).y()-cl.point(a).y());
5686
np = QPoint(0, -upval) * ma;
5687
np2 = QPoint(0, -downval) * ma;
5688
cl1.resize(cl1.size()+1);
5689
cl1.setPoint(cl1.size()-1, np+cl.point(a));
5690
cl1.resize(cl1.size()+1);
5691
cl1.setPoint(cl1.size()-1, np+cl.point(a+1));
5692
cl2.resize(cl2.size()+1);
5693
cl2.setPoint(cl2.size()-1, np2+cl.point(a));
5694
cl2.resize(cl2.size()+1);
5695
cl2.setPoint(cl2.size()-1, np2+cl.point(a+1));
5697
cl1.resize(cl1.size()+1);
5698
cl1.setPoint(cl1.size()-1, np+cl.point(cl.size()-1));
5699
cl2.resize(cl2.size()+1);
5700
cl2.setPoint(cl2.size()-1, np2+cl.point(cl.size()-1));
5701
Clip.putPoints(Clip.size(), cl1.size(), cl1);
5702
for (int a2 = cl2.size()-1; a2 > -1; a2--)
5704
Clip.resize(Clip.size()+1);
5705
Clip.setPoint(Clip.size()-1, cl2.point(a2));
5710
void PageItem::updatePolyClip()
5714
uint itemTextCount=itemText.length();
5715
for (uint a = 0; a < itemTextCount; ++a)
5717
const CharStyle& hl (itemText.charStyle(a));
5718
int des = static_cast<int>(hl.font().descent(hl.fontSize() / 10.0));
5719
int asc = static_cast<int>(hl.font().ascent(hl.fontSize() / 10.0));
5720
asce = qMax(asce, asc);
5721
desc = qMax(desc, des);
5723
setPolyClip(static_cast<int>(asce-BaseOffs), static_cast<int>(desc-BaseOffs));
5726
void PageItem::handleModeEditKey(QKeyEvent * /* k */, bool & /* keyRepeat */)
5730
bool PageItem::connectToGUI()
5732
if (!ScCore->usingGUI())
5734
if (!m_Doc->m_Selection->primarySelectionIs(this))
5736
PropertiesPalette* pp=m_Doc->scMW()->propertiesPalette;
5737
connect(this, SIGNAL(myself(PageItem *)), pp, SLOT(SetCurItem(PageItem *)));
5738
connect(this, SIGNAL(frameType(int)), m_Doc->scMW(), SLOT(HaveNewSel(int)));
5739
connect(this, SIGNAL(frameType(int)), m_Doc->view(), SLOT(selectionChanged()));
5740
connect(this, SIGNAL(frameType(int)), pp, SLOT(NewSel(int)));
5741
connect(this, SIGNAL(frameLocked(bool)), pp, SLOT(setLocked(bool)));
5742
connect(this, SIGNAL(frameSizeLocked(bool)), pp, SLOT(setSizeLocked(bool)));
5743
connect(this, SIGNAL(frameFlippedH(bool)), pp, SLOT(setFlippedH(bool)));
5744
connect(this, SIGNAL(frameFlippedV(bool)), pp, SLOT(setFlippedV(bool)));
5745
connect(this, SIGNAL(printEnabled(bool)), pp, SLOT(setPrintingEnabled(bool)));
5746
connect(this, SIGNAL(position(double, double)), pp, SLOT(setXY(double, double)));
5747
connect(this, SIGNAL(widthAndHeight(double, double)), pp, SLOT(setBH(double, double)));
5748
//CB unused in 135 connect(this, SIGNAL(colors(QString, QString, double, double)), m_Doc->scMW(), SLOT(setCSMenu()));
5749
// connect(this, SIGNAL(colors(QString, QString, double, double)), pp->Cpal, SLOT(setActFarben(QString, QString, int, int)));
5750
// connect(this, SIGNAL(gradientType(int)), pp->Cpal, SLOT(setActGradient(int)));
5751
connect(this, SIGNAL(patternFill(QString, double, double, double, double, double)), pp->Cpal, SLOT(setActPattern(QString, double, double, double, double, double)));
5752
// connect(this, SIGNAL(gradientColorUpdate(double, double, double, double, double, double)), pp->Cpal, SLOT(setSpecialGradient(double, double, double, double, double, double)));
5753
connect(this, SIGNAL(rotation(double)), pp, SLOT(setR(double)));
5754
// connect(this, SIGNAL(transparency(double, double)), pp->Cpal, SLOT(setActTrans(double, double)));
5755
// connect(this, SIGNAL(blendmode(int, int)), pp->Cpal, SLOT(setActBlend(int, int)));
5757
//Not connected when transferring code: void columns(int, double); //Number, gap
5758
connect(this, SIGNAL(cornerRadius(double)), pp, SLOT(setRR(double)));
5759
// connect(view, SIGNAL(ItemTextCols(int, double)), propertiesPalette, SLOT(setCols(int, double)));
5761
connect(this, SIGNAL(lineWidth(double)), pp, SLOT(setLineWidth(double)));
5762
connect(this, SIGNAL(imageOffsetScale(double, double, double, double)), pp, SLOT(setScaleAndOffset(double, double, double, double)));
5763
connect(this, SIGNAL(lineStyleCapJoin(Qt::PenStyle, Qt::PenCapStyle, Qt::PenJoinStyle)), pp, SLOT( setLIvalue(Qt::PenStyle, Qt::PenCapStyle, Qt::PenJoinStyle)));
5764
//Frame text signals
5765
connect(this, SIGNAL(lineSpacing(double)), pp, SLOT(setLsp(double)));
5766
connect(this, SIGNAL(textToFrameDistances(double, double, double, double)), pp, SLOT(setTextToFrameDistances(double, double, double, double)));
5767
connect(this, SIGNAL(textKerning(double)), pp, SLOT(setExtra(double)));
5768
connect(this, SIGNAL(textStyle(int)), pp, SLOT(setStil(int)));
5769
connect(this, SIGNAL(textStyle(int)), m_Doc->scMW(), SLOT(setStilvalue(int)));
5770
connect(this, SIGNAL(textFont(const QString&)), pp, SLOT(setFontFace(const QString&)));
5771
connect(this, SIGNAL(textSize(double)), pp, SLOT(setSize(double)));
5772
connect(this, SIGNAL(textWidthScale(double)), pp, SLOT(setTScale(double)));
5773
connect(this, SIGNAL(textHeightScale(double)), pp, SLOT(setTScaleV(double)));
5774
connect(this, SIGNAL(textBaseLineOffset(double)), pp, SLOT(setTBase(double)));
5775
connect(this, SIGNAL(textOutline(double)), pp, SLOT(setOutlineW(double)));
5776
connect(this, SIGNAL(textShadow(double, double )), pp, SLOT(setShadowOffs(double, double )));
5777
connect(this, SIGNAL(textUnderline(double, double)), pp, SLOT(setUnderline(double, double)));
5778
connect(this, SIGNAL(textStrike(double, double)), pp, SLOT(setStrike(double, double)));
5779
connect(this, SIGNAL(textColor(QString, QString, double, double)), pp, SLOT(setActFarben(QString, QString, double, double)));
5780
// connect(this, SIGNAL(textFormatting(int)), pp, SLOT(setAli(int)));
5781
// connect(this, SIGNAL(textFormatting(int)), ScMW, SLOT(setAbsValue(int)));
5786
bool PageItem::disconnectFromGUI()
5788
if (!ScCore->usingGUI())
5790
// Disconnecting only signals from PP will leave some remaining connections
5791
// and cause progressive slowdowns
5792
// PropertiesPalette* pp=m_Doc->scMW()->propertiesPalette;
5793
// disconnect(this, 0, pp, 0);
5794
disconnect(this, 0, 0, 0);
5798
void PageItem::emitAllToGUI()
5803
emit frameType(m_ItemType);
5804
/*CB using the emit myself* instead of all of these
5805
emit position(Xpos, Ypos);
5806
emit widthAndHeight(Width, Height);
5808
emit frameLocked(m_Locked);
5809
emit frameSizeLocked(m_SizeLocked);
5810
emit frameFlippedH(m_ImageIsFlippedH);
5811
emit frameFlippedV(m_ImageIsFlippedV);
5812
emit printEnabled(m_PrintEnabled);
5813
emit lineWidth(m_lineWidth);
5814
emit lineStyleCapJoin(PLineArt, PLineEnd, PLineJoin);
5815
emit imageOffsetScale(LocalScX, LocalScY, LocalX, LocalY);
5817
//CB unused in 135 emit colors(lineColorVal, fillColorVal, lineShadeVal, fillShadeVal);
5818
// emit gradientType(GrType);
5819
// double dur=m_Doc->unitRatio();
5820
// emit gradientColorUpdate(GrStartX*dur, GrStartY*dur, GrEndX*dur, GrEndY*dur, Width*dur, Height*dur);
5821
// emit transparency(fillTransparencyVal, lineTransparencyVal);
5822
// emit blendmode(fillBlendmodeVal, lineBlendmodeVal);
5823
/*CB using the emit myself* instead of all of these
5824
emit patternFill(patternVal, patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation);
5825
emit textToFrameDistances(Extra, TExtra, BExtra, RExtra);
5826
emit columns(Cols, ColGap);
5828
if (m_Doc->appMode == modeEdit)
5830
/* maybe already done elsewhere? -- av
5831
emit lineSpacing(currentStyle().lineSpacing());
5832
emit textKerning(currentCharStyle().tracking());
5833
emit textStyle(currentCharStyle().effects());
5834
emit textFont(currentCharStyle().font()->scName());
5835
emit textSize(currentCharStyle().fontSize());
5837
// emit textFormatting(currentStyle().alignment());
5841
//TODO remove and use the emit myself
5842
emit lineSpacing(itemText.defaultStyle().lineSpacing());
5843
emit textKerning(itemText.defaultStyle().charStyle().tracking());
5844
emit textStyle(itemText.defaultStyle().charStyle().effects());
5845
emit textFont(itemText.defaultStyle().charStyle().font().scName());
5846
emit textSize(itemText.defaultStyle().charStyle().fontSize());
5847
// emit textFormatting(itemText.defaultStyle().alignment());
5851
void PageItem::setIsAnnotation(bool isAnnot)
5853
m_isAnnotation=isAnnot;
5856
void PageItem::setAnnotation(const Annotation& ad)
5861
void PageItem::setImageShown(bool isShown)
5866
void PageItem::updateConstants()
5870
m_Doc->constants().insert("pagewidth", m_Doc->Pages->at(OwnPage)->width());
5871
m_Doc->constants().insert("pageheight", m_Doc->Pages->at(OwnPage)->height());
5872
m_Doc->constants().insert("marginleft", m_Doc->Pages->at(OwnPage)->Margins.Left);
5873
m_Doc->constants().insert("marginright", m_Doc->Pages->at(OwnPage)->width() - m_Doc->Pages->at(OwnPage)->Margins.Right);
5874
m_Doc->constants().insert("margintop", m_Doc->Pages->at(OwnPage)->Margins.Top);
5875
m_Doc->constants().insert("marginbottom", m_Doc->Pages->at(OwnPage)->height() - m_Doc->Pages->at(OwnPage)->Margins.Bottom);
5877
m_Doc->constants().insert("width", Width);
5878
m_Doc->constants().insert("height", Height);
5881
//CB Old ScribusView MoveItemI
5882
void PageItem::moveImageInFrame(double newX, double newY)
5884
if (m_ItemType!=PageItem::ImageFrame)
5886
if ((locked()) || (!ScaleType))
5888
double dX=0.0, dY=0.0;
5889
if (imageFlippedH())
5893
if (imageFlippedV())
5897
moveImageXYOffsetBy(dX, dY);
5898
if (imageClip.size() != 0)
5900
imageClip = pixm.imgInfo.PDSpathData[pixm.imgInfo.usedPath].copy();
5902
cl.translate(imageXOffset()*imageXScale(), imageYOffset()*imageYScale());
5903
cl.scale(imageXScale(), imageYScale());
5910
void PageItem::convertClip()
5912
if (Clip.count() != 0)
5914
FPoint np(Clip.point(0));
5916
PoLine.setPoint(0, np);
5917
PoLine.setPoint(1, np);
5918
for (int a = 1; a < Clip.size(); ++a)
5920
np = FPoint(Clip.point(a));
5921
PoLine.putPoints(PoLine.size(), 4, np.x(), np.y(), np.x(), np.y(), np.x(), np.y(), np.x(), np.y());
5923
np = FPoint(Clip.point(0));
5924
PoLine.putPoints(PoLine.size(), 2, np.x(), np.y(), np.x(), np.y());
5925
Clip = FlattenPath(PoLine, Segments);
5930
m_Doc->setRedrawBounding(this);
5934
void PageItem::updateClip()
5936
if (m_Doc->appMode == modeDrawBezierLine)
5938
if (ContourLine.size() == 0)
5939
ContourLine = PoLine.copy();
5940
int ph = static_cast<int>(qMax(1.0, lineWidth() / 2.0));
5941
bool clipBackup = ClipEdited;
5944
case PageItem::Line:
5945
Clip.setPoints(4, -ph,-ph, static_cast<int>(width()+ph),-ph,
5946
static_cast<int>(width()+ph),static_cast<int>(height()+ph),
5947
-ph,static_cast<int>(height()+ph));
5950
if (((!ClipEdited) || (FrameType < 3)) && !(asPathText()))
5956
m_Doc->setRedrawBounding(this);
5960
m_Doc->setRedrawBounding(this);
5963
//CB FIXME: stop using nodeEdit.clre or move out of here
5964
m_Doc->nodeEdit.deselect();
5966
m_Doc->setRedrawBounding(this);
5971
ClipEdited = clipBackup;
5972
if ((OldB2 != 0) && (OldH2 != 0) && (width() != 0) && (height() != 0))
5974
double scx = width() / OldB2;
5975
double scy = height() / OldH2;
5979
gr.addPoint(GrStartX, GrStartY);
5980
gr.addPoint(GrEndX, GrEndY);
5982
GrStartX = gr.point(0).x();
5983
GrStartY = gr.point(0).y();
5984
GrEndX = gr.point(1).x();
5985
GrEndY = gr.point(1).y();
5986
ContourLine.map(ma);
5993
Clip = FlattenPath(PoLine, Segments);
5998
if ((FrameType < 3) && (!ClipEdited))
5999
ContourLine = PoLine.copy();
6003
if (m_Doc->SubMode != -1)
6005
switch (m_Doc->SubMode)
6009
m_Doc->setRedrawBounding(this);
6013
m_Doc->setRedrawBounding(this);
6016
SetFrameShape(m_Doc->ValCount, m_Doc->ShapeValues);
6017
m_Doc->setRedrawBounding(this);
6022
ContourLine = PoLine.copy();
6024
if ((OldB2 == 0) || (OldH2 == 0) || (width() == 0) || (height() == 0))
6026
double scx = width() / OldB2;
6027
double scy = height() / OldH2;
6031
gr.addPoint(GrStartX, GrStartY);
6032
gr.addPoint(GrEndX, GrEndY);
6034
GrStartX = gr.point(0).x();
6035
GrStartY = gr.point(0).y();
6036
GrEndX = gr.point(1).x();
6037
GrEndY = gr.point(1).y();
6039
ContourLine.map(ma);
6043
Clip = FlattenPath(PoLine, Segments);
6049
updateGradientVectors();
6052
QString PageItem::infoDescription()
6055
htmlText.append(ScribusView::tr("Print: "));
6057
htmlText.append(ScribusView::tr("Enabled"));
6059
htmlText.append(ScribusView::tr("Disabled"));
6060
htmlText.append("<br/>");
6064
FirstLineOffsetPolicy PageItem::firstLineOffset() const
6066
return firstLineOffsetP;
6069
void PageItem::setFirstLineOffset(FirstLineOffsetPolicy flop)
6071
if(firstLineOffsetP != flop)
6073
firstLineOffsetP = flop;