r23042 by jghali - Preparatory work for more complete fix of #15718
scribus-commit
scribus-commit at lists.scribus.net
Fri Jun 21 23:08:25 UTC 2019
Author: jghali
Date: Fri Jun 21 23:08:25 2019
New Revision: 23042
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=23042
Log:
Preparatory work for more complete fix of #15718
Modified:
trunk/Scribus/scribus/pageitem.cpp
trunk/Scribus/scribus/pageitem.h
trunk/Scribus/scribus/pageitem_textframe.cpp
Modified: trunk/Scribus/scribus/pageitem.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23042&path=/trunk/Scribus/scribus/pageitem.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem.cpp (original)
+++ trunk/Scribus/scribus/pageitem.cpp Fri Jun 21 23:08:25 2019
@@ -9462,6 +9462,99 @@
return arrowRect;
}
+QRegion PageItem::textInteractionRegion(double xOffset, double yOffset) const
+{
+ QRegion res;
+
+ QTransform pp;
+ if (this->isGroupChild())
+ pp.translate(gXpos, gYpos);
+ else
+ pp.translate(m_xPos - xOffset, m_yPos - yOffset);
+ pp.rotate(m_rotation);
+
+ if (textFlowUsesBoundingBox())
+ {
+ QRectF bb = getVisualBoundingRect();
+ if (isGroupChild())
+ {
+ bb.translate(-m_xPos, -m_yPos);
+ bb.translate(gXpos, gYpos);
+ }
+ res = QRegion(bb.toRect());
+ }
+ else if ((textFlowUsesImageClipping()) && (!imageClip.empty()))
+ {
+ QList<uint> Segs;
+ QPolygon Clip2 = flattenPath(imageClip, Segs);
+ res = QRegion(pp.map(Clip2)).intersected(QRegion(pp.map(Clip)));
+ }
+ else if ((textFlowUsesContourLine()) && (!ContourLine.empty()))
+ {
+ QList<uint> Segs;
+ QPolygon Clip2 = flattenPath(ContourLine, Segs);
+ res = QRegion(pp.map(Clip2));
+ }
+ else
+ {
+ if (isSymbol() || isGroup())
+ {
+ if (imageFlippedH())
+ {
+ pp.translate(m_width, 0);
+ pp.scale(-1, 1);
+ }
+ if (imageFlippedV())
+ {
+ pp.translate(0, m_height);
+ pp.scale(1, -1);
+ }
+ }
+ if ((((lineColorVal != CommonStrings::None) || (!patternStrokeVal.isEmpty()) || (GrTypeStroke > 0)) && (m_lineWidth > 1)) || (!NamedLStyle.isEmpty()))
+ {
+// QVector<double> m_array;
+ QPainterPath ppa;
+ QPainterPath result;
+ if (itemType() == PageItem::PolyLine)
+ ppa = PoLine.toQPainterPath(false);
+ else
+ ppa = PoLine.toQPainterPath(true);
+ if (NamedLStyle.isEmpty())
+ {
+ QPainterPathStroker stroke;
+ stroke.setCapStyle(PLineEnd);
+ stroke.setJoinStyle(PLineJoin);
+ stroke.setDashPattern(Qt::SolidLine);
+ stroke.setWidth(m_lineWidth);
+ result = stroke.createStroke(ppa);
+ }
+ else
+ {
+ multiLine ml = doc()->MLineStyles[NamedLStyle];
+ int ind = ml.size()-1;
+ if ((ml[ind].Color != CommonStrings::None) && (ml[ind].Width != 0))
+ {
+ QPainterPathStroker stroke;
+ stroke.setCapStyle(static_cast<Qt::PenCapStyle>(ml[ind].LineEnd));
+ stroke.setJoinStyle(static_cast<Qt::PenJoinStyle>(ml[ind].LineJoin));
+ stroke.setDashPattern(Qt::SolidLine);
+ stroke.setWidth(ml[ind].Width);
+ result = stroke.createStroke(ppa);
+ }
+ }
+ res = QRegion(pp.map(Clip));
+ QList<QPolygonF> pl = result.toSubpathPolygons();
+ for (int b = 0; b < pl.count(); b++)
+ {
+ res = res.united(QRegion(pp.map(pl[b].toPolygon())));
+ }
+ }
+ else
+ res = QRegion(pp.map(Clip));
+ }
+ return res;
+}
+
bool PageItem::pointWithinItem(int x, const int y) const
{
const_cast<PageItem*>(this)-> setRedrawBounding();
Modified: trunk/Scribus/scribus/pageitem.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23042&path=/trunk/Scribus/scribus/pageitem.h
==============================================================================
--- trunk/Scribus/scribus/pageitem.h (original)
+++ trunk/Scribus/scribus/pageitem.h Fri Jun 21 23:08:25 2019
@@ -58,6 +58,7 @@
class QFrame;
class QGridLayout;
+class QRegion;
class ResourceCollection;
class ScPainter;
class ScribusDoc;
@@ -315,6 +316,7 @@
virtual QRectF getEndArrowBoundingRect() const;
virtual QRectF getEndArrowOldBoundingRect() const;
+ virtual QRegion textInteractionRegion(double xOffset, double yOffset) const;
//>> ********* Functions related to drawing the item *********
Modified: trunk/Scribus/scribus/pageitem_textframe.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23042&path=/trunk/Scribus/scribus/pageitem_textframe.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem_textframe.cpp (original)
+++ trunk/Scribus/scribus/pageitem_textframe.cpp Fri Jun 21 23:08:25 2019
@@ -98,97 +98,6 @@
connect(&itemText,SIGNAL(changed(int,int)), this, SLOT(slotInvalidateLayout(int,int)));
}
-static QRegion itemShape(PageItem* docItem, double xOffset, double yOffset)
-{
- QRegion res;
- QTransform pp;
- if (docItem->isGroupChild())
- pp.translate(docItem->gXpos, docItem->gYpos);
- else
- pp.translate(docItem->xPos() - xOffset, docItem->yPos() - yOffset);
- pp.rotate(docItem->rotation());
- if (docItem->textFlowUsesBoundingBox())
- {
- QRectF bb = docItem->getVisualBoundingRect();
- if (docItem->isGroupChild())
- {
- bb.translate(-docItem->xPos(), -docItem->yPos());
- bb.translate(docItem->gXpos, docItem->gYpos);
- }
- res = QRegion(bb.toRect());
- }
- else if ((docItem->textFlowUsesImageClipping()) && (!docItem->imageClip.empty()))
- {
- QList<uint> Segs;
- QPolygon Clip2 = flattenPath(docItem->imageClip, Segs);
- res = QRegion(pp.map(Clip2)).intersected(QRegion(pp.map(docItem->Clip)));
- }
- else if ((docItem->textFlowUsesContourLine()) && (!docItem->ContourLine.empty()))
- {
- QList<uint> Segs;
- QPolygon Clip2 = flattenPath(docItem->ContourLine, Segs);
- res = QRegion(pp.map(Clip2));
- }
- else
- {
- if (docItem->isSymbol() || docItem->isGroup())
- {
- if (docItem->imageFlippedH())
- {
- pp.translate(docItem->width(), 0);
- pp.scale(-1, 1);
- }
- if (docItem->imageFlippedV())
- {
- pp.translate(0, docItem->height());
- pp.scale(1, -1);
- }
- }
- if ((((docItem->lineColor() != CommonStrings::None) || (!docItem->patternStrokeVal.isEmpty()) || (docItem->GrTypeStroke > 0)) && (docItem->lineWidth() > 1)) || (!docItem->NamedLStyle.isEmpty()))
- {
-// QVector<double> m_array;
- QPainterPath ppa;
- QPainterPath result;
- if (docItem->itemType() == PageItem::PolyLine)
- ppa = docItem->PoLine.toQPainterPath(false);
- else
- ppa = docItem->PoLine.toQPainterPath(true);
- if (docItem->NamedLStyle.isEmpty())
- {
- QPainterPathStroker stroke;
- stroke.setCapStyle(docItem->lineEnd());
- stroke.setJoinStyle(docItem->lineJoin());
- stroke.setDashPattern(Qt::SolidLine);
- stroke.setWidth(docItem->lineWidth());
- result = stroke.createStroke(ppa);
- }
- else
- {
- multiLine ml = docItem->doc()->MLineStyles[docItem->NamedLStyle];
- int ind = ml.size()-1;
- if ((ml[ind].Color != CommonStrings::None) && (ml[ind].Width != 0))
- {
- QPainterPathStroker stroke;
- stroke.setCapStyle(static_cast<Qt::PenCapStyle>(ml[ind].LineEnd));
- stroke.setJoinStyle(static_cast<Qt::PenJoinStyle>(ml[ind].LineJoin));
- stroke.setDashPattern(Qt::SolidLine);
- stroke.setWidth(ml[ind].Width);
- result = stroke.createStroke(ppa);
- }
- }
- res = QRegion(pp.map(docItem->Clip));
- QList<QPolygonF> pl = result.toSubpathPolygons();
- for (int b = 0; b < pl.count(); b++)
- {
- res = res.united(QRegion(pp.map(pl[b].toPolygon())));
- }
- }
- else
- res = QRegion(pp.map(docItem->Clip));
- }
- return res;
-}
-
QRegion PageItem_TextFrame::calcAvailableRegion()
{
QRegion result(this->Clip);
@@ -207,9 +116,9 @@
int LayerLev = m_Doc->layerLevelFromID(m_layerID);
int docItemsCount = m_Doc->Items->count();
- ScPage* Mp=nullptr;
- ScPage* Dp=nullptr;
- PageItem* docItem=nullptr;
+ ScPage* Mp = nullptr;
+ ScPage* Dp = nullptr;
+ PageItem* docItem = nullptr;
int LayerLevItem;
QList<PageItem*> thisList;
if (!OnMasterPage.isEmpty())
@@ -234,7 +143,7 @@
{
if (docItem->textFlowAroundObject())
{
- QRegion itemRgn = itemShape(docItem, Mp->xOffset() - Dp->xOffset(), Mp->yOffset() - Dp->yOffset());
+ QRegion itemRgn = docItem->textInteractionRegion(Mp->xOffset() - Dp->xOffset(), Mp->yOffset() - Dp->yOffset());
result = result.subtracted( canvasToLocalMat.map(itemRgn) );
}
}
@@ -267,7 +176,7 @@
docItem = Parent->asGroupFrame()->groupItemList.at(a);
if (docItem->textFlowAroundObject())
{
- QRegion itemRgn = itemShape(docItem, 0, 0);
+ QRegion itemRgn = docItem->textInteractionRegion(0, 0);
result = result.subtracted( canvasToLocalMat.map(itemRgn) );
}
}
@@ -283,7 +192,7 @@
{
if (docItem->textFlowAroundObject())
{
- QRegion itemRgn = itemShape(docItem, 0, 0);
+ QRegion itemRgn = docItem->textInteractionRegion(0, 0);
result = result.subtracted( canvasToLocalMat.map(itemRgn) );
}
}
More information about the scribus-commit
mailing list