r22892 by jghali - #15594: Copy-pasting image may change image offset
scribus-commit
scribus-commit at lists.scribus.net
Wed Mar 13 11:20:34 UTC 2019
Author: jghali
Date: Wed Mar 13 11:20:34 2019
New Revision: 22892
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=22892
Log:
#15594: Copy-pasting image may change image offset
Modified:
trunk/Scribus/scribus/pageitem.cpp
trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
trunk/Scribus/scribus/ui/propertiespalette_image.cpp
Modified: trunk/Scribus/scribus/pageitem.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22892&path=/trunk/Scribus/scribus/pageitem.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem.cpp (original)
+++ trunk/Scribus/scribus/pageitem.cpp Wed Mar 13 11:20:34 2019
@@ -9739,28 +9739,42 @@
br = m.mapRect(br);
xs = m_width / br.width();
ys = m_height / br.height();
+ double xs2 = AspectRatio ? qMin(xs, ys) : xs;
+ double ys2 = AspectRatio ? qMin(xs, ys) : ys;
QLineF wL = QLineF(0, 0, OrigW, 0);
- wL.setAngle(-m_imageRotation);
QLineF hL = QLineF(0, 0, 0, OrigH);
- hL.setAngle(-m_imageRotation-90);
QTransform mm;
- mm.scale(xs, ys);
+ mm.scale(xs2, ys2);
+ mm.rotate(-m_imageRotation);
hL = mm.map(hL);
wL = mm.map(wL);
xs = wL.length() / static_cast<double>(OrigW);
ys = hL.length() / static_cast<double>(OrigH);
+ }
+ if (AspectRatio)
+ {
+ m_imageXScale = qMin(xs, ys);
+ m_imageYScale = qMin(xs, ys);
+ }
+ else
+ {
+ m_imageXScale = xs;
+ m_imageYScale = ys;
+ }
+ if (imageRot != 0.0)
+ {
+ QRectF br = QRectF(0, 0, OrigW * xs, OrigH * ys);
+ QTransform m;
+ m.scale(1.0 / xs, 1.0 / ys);
+ m.rotate(m_imageRotation);
+ br = m.mapRect(br);
m_imageXOffset = -br.x();
m_imageYOffset = -br.y();
}
- if (AspectRatio)
- {
- m_imageXScale = qMin(xs, ys);
- m_imageYScale = qMin(xs, ys);
- }
- else
- {
- m_imageXScale = xs;
- m_imageYScale = ys;
+ else
+ {
+ m_imageXOffset = 0.0;
+ m_imageYOffset = 0.0;
}
// Disable broken code. Code must be independent from doc in that function
/*switch (m_Doc->RotMode)
Modified: trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22892&path=/trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp (original)
+++ trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp Wed Mar 13 11:20:34 2019
@@ -4197,7 +4197,10 @@
{
if (!newItem->Pfile.isEmpty())
{
+ double imageXOffset = newItem->imageXOffset();
+ double imageYOffset = newItem->imageYOffset();
doc->loadPict(newItem->Pfile, newItem, false);
+ newItem->setImageXYOffset(imageXOffset, imageYOffset);
if (newItem->pixm.imgInfo.PDSpathData.contains(clipPath))
{
newItem->imageClip = newItem->pixm.imgInfo.PDSpathData[clipPath].copy();
@@ -4211,6 +4214,7 @@
{
newItem->pixm.imgInfo.isRequest = true;
doc->loadPict(newItem->Pfile, newItem, true);
+ newItem->setImageXYOffset(imageXOffset, imageYOffset);
}
}
}
@@ -4806,8 +4810,10 @@
double w = attrs.valueAsDouble("WIDTH");
double h = attrs.valueAsDouble("HEIGHT");
double pw = attrs.valueAsDouble("PWIDTH");
- double scx = attrs.valueAsDouble("LOCALSCX");
- double scy = attrs.valueAsDouble("LOCALSCY");
+ double imageXOffset = attrs.valueAsDouble("LOCALX");
+ double imageYOffset = attrs.valueAsDouble("LOCALY");
+ double imageXScale = attrs.valueAsDouble("LOCALSCX");
+ double imageYScale = attrs.valueAsDouble("LOCALSCY");
QString Pcolor = attrs.valueAsString("PCOLOR");
if (Pcolor.isEmpty())
Pcolor = CommonStrings::None;
@@ -4837,8 +4843,8 @@
UndoManager::instance()->setUndoEnabled(false);
currItem->ScaleType = attrs.valueAsInt("SCALETYPE", 1);
currItem->AspectRatio = attrs.valueAsInt("RATIO", 0);
- currItem->setImageXYScale(scx, scy);
- currItem->setImageXYOffset(attrs.valueAsDouble("LOCALX"), attrs.valueAsDouble("LOCALY"));
+ currItem->setImageXYScale(imageXScale, imageYScale);
+ currItem->setImageXYOffset(imageXOffset, imageYOffset);
currItem->setImageRotation(attrs.valueAsDouble("LOCALROT"));
// if (!currItem->asLatexFrame())
#ifdef HAVE_OSG
@@ -4896,7 +4902,7 @@
currItem->CompressionMethodIndex = attrs.valueAsInt("COMPRESSIONMETHOD", 0);
if ((currItem->OverrideCompressionQuality = attrs.hasAttribute("COMPRESSIONQUALITY")))
currItem->CompressionQualityIndex = attrs.valueAsInt("COMPRESSIONQUALITY");
- currItem->setImageXYScale(scx, scy);
+ currItem->setImageXYScale(imageXScale, imageYScale);
currItem->setImageRotation(attrs.valueAsDouble("LOCALROT"));
clPath = attrs.valueAsString("ImageClip", "");
if (!clPath.isEmpty())
@@ -5213,8 +5219,8 @@
UndoManager::instance()->setUndoEnabled(false);
if (currItem->isAnnotation() && currItem->annotation().UseIcons())
{
- currItem->setImageXYScale(scx, scy);
- currItem->setImageXYOffset(attrs.valueAsDouble("LOCALX"), attrs.valueAsDouble("LOCALY"));
+ currItem->setImageXYScale(imageXScale, imageYScale);
+ currItem->setImageXYOffset(imageXOffset, imageYOffset);
currItem->setImageRotation(attrs.valueAsDouble("LOCALROT"));
currItem->Pfile = Relative2Path(attrs.valueAsString("PFILE" , ""), baseDir);
currItem->Pfile2 = Relative2Path(attrs.valueAsString("PFILE2", ""), baseDir);
@@ -5224,7 +5230,7 @@
currItem->IRender = (eRenderIntent) attrs.valueAsInt("IRENDER" , 1);
currItem->UseEmbedded = attrs.valueAsInt("EMBEDDED", 1);
doc->loadPict(currItem->Pfile, currItem);
- currItem->setImageXYScale(scx, scy);
+ currItem->setImageXYScale(imageXScale, imageYScale);
currItem->setImageVisible( attrs.valueAsInt("PICART"));
/* currItem->BBoxX = ScCLocale::toDoubleC( obj->attribute("BBOXX"));
currItem->BBoxH = ScCLocale::toDoubleC( obj->attribute("BBOXH")); */
Modified: trunk/Scribus/scribus/ui/propertiespalette_image.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22892&path=/trunk/Scribus/scribus/ui/propertiespalette_image.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/propertiespalette_image.cpp (original)
+++ trunk/Scribus/scribus/ui/propertiespalette_image.cpp Wed Mar 13 11:20:34 2019
@@ -587,7 +587,10 @@
{
m_doc->itemSelection_SetImageRotation(360 - imageRotation->value());
if (frameScale->isChecked())
+ {
m_item->adjustPictScale();
+ m_item->update();
+ }
}
}
More information about the scribus-commit
mailing list