r17093 by jghali - merge trunk revisions up to r17092

scribus-commit scribus-commit at lists.scribus.net
Sat Dec 17 12:46:02 UTC 2011


Author: jghali
Date: Sat Dec 17 12:46:02 2011
New Revision: 17093

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=17093
Log:
merge trunk revisions up to r17092

Modified:
    branches/ScribusOIF/scribus/canvasgesture_resize.cpp
    branches/ScribusOIF/scribus/canvasmode.cpp
    branches/ScribusOIF/scribus/loadsaveplugin.cpp
    branches/ScribusOIF/scribus/loadsaveplugin.h
    branches/ScribusOIF/scribus/pageitem.cpp
    branches/ScribusOIF/scribus/pageitem.h
    branches/ScribusOIF/scribus/plugins/import/pdf/slaoutput.h
    branches/ScribusOIF/scribus/selection.cpp
    branches/ScribusOIF/scribus/selection.h
    branches/ScribusOIF/scribus/ui/propertiespalette_xyz.cpp
    branches/ScribusOIF/scribus/ui/propertywidget_pos.cpp

Modified: branches/ScribusOIF/scribus/canvasgesture_resize.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17093&path=/branches/ScribusOIF/scribus/canvasgesture_resize.cpp
==============================================================================
--- branches/ScribusOIF/scribus/canvasgesture_resize.cpp (original)
+++ branches/ScribusOIF/scribus/canvasgesture_resize.cpp Sat Dec 17 12:46:02 2011
@@ -64,10 +64,16 @@
 	else // we keep m_bounds non-rotated
 	{
 		PageItem* currItem = m_doc->m_Selection->itemAt(0);
-		m_bounds = QRectF(currItem->visualXPos(), currItem->visualYPos(), currItem->visualWidth(), currItem->visualHeight());
-		m_rotation = currItem->rotation();
-//		currItem->OldB2 = currItem->visualWidth();
-//		currItem->OldH2 = currItem->visualHeight();
+		m_bounds = QRectF(-currItem->visualLineWidth() / 2.0, -currItem->visualLineWidth() / 2.0, currItem->visualWidth(), currItem->visualHeight());
+		QTransform mm = currItem->getTransform();
+		QPointF itPos = mm.map(QPointF(0, 0));
+		double m_scaleX, m_scaleY;
+		getScaleFromMatrix(mm, m_scaleX, m_scaleY);
+		QTransform m;
+		m.scale(m_scaleX, m_scaleY);
+		m_bounds = m.mapRect(m_bounds);
+		m_bounds.moveTopLeft(itPos);
+		m_rotation = -getRotationDFromMatrix(mm);
 		currItem->OldB2 = currItem->width();
 		currItem->OldH2 = currItem->height();
 		m_extraWidth = currItem->visualWidth() - currItem->width();
@@ -76,7 +82,6 @@
 	}
 	m_origRatio = m_bounds.width() / m_bounds.height();
 	m_origBounds = m_bounds;
-// 	qDebug()<<"P"<<m_bounds<< "E"<< m_extraX<< m_extraY<<m_extraWidth<<m_extraHeight;
 }
 
 
@@ -85,7 +90,6 @@
 	m_handle = Canvas::OUTSIDE;
 	if (m_transactionStarted)
 	{
-//		qDebug() << "ResizeGesture::clear: cancel transaction" << m_transactionStarted;
 		m_transactionStarted->cancel();
 		delete m_transactionStarted;
 		m_transactionStarted = NULL;
@@ -94,14 +98,12 @@
 
 void ResizeGesture::activate(bool flag)
 {
-//	qDebug() << "ResizeGesture::activate" << flag;	
 }
 
 
 
 void ResizeGesture::deactivate(bool forgesture)
 {
-//	qDebug() << "ResizeGesture::deactivate" << forgesture;
 	if (!forgesture)
 		clear();
 }
@@ -113,8 +115,6 @@
 	QColor drawColor = qApp->palette().color(QPalette::Active, QPalette::Highlight);
 	QRect localRect = m_canvas->canvasToLocal(m_bounds.normalized());
 	p->save();
-	//	p->setPen(QPen(Qt::black, 1, Qt::DashLine, Qt::FlatCap, Qt::MiterJoin));
-	//	p->drawRect(localRect);
 	if (m_rotation != 0)
 	{
 		p->setRenderHint(QPainter::Antialiasing);
@@ -126,8 +126,6 @@
 	drawColor.setAlpha(64);
 	p->setBrush(drawColor);
 	p->drawRect(localRect);
-	//	p->setPen(Qt::darkMagenta);
-	//	p->drawLine(localRect.topLeft(), localRect.bottomRight());
 	p->restore();
 
 	if (m_origBounds != m_bounds)
@@ -135,7 +133,6 @@
 		QRectF n_bounds = m_bounds.normalized();
 		QRectF n_origBounds = m_origBounds.normalized();
 		p->save();
-//		p->translate(m_bounds.topLeft() - m_origBounds.topLeft());
 		drawOutline(p, qAbs(n_bounds.width()) / qMax(qAbs(n_origBounds.width()), static_cast<qreal>(1.0)), 
 					qAbs(n_bounds.height()) / qMax(qAbs(n_origBounds.height()), static_cast<qreal>(1.0)),
 					n_bounds.left() - n_origBounds.left(),
@@ -152,7 +149,6 @@
 	if (m_doc->m_Selection->count() != 0)
 	{
 		PageItem* currItem = m_doc->m_Selection->itemAt(0);
-//		qDebug() << "ResizeGesture::release: new bounds" << m_bounds;
 		if (m_bounds != m_mousePressBounds)
 		{
 			doResize(m->modifiers() & Qt::AltModifier);
@@ -172,7 +168,6 @@
 			m_doc->changed();
 		}
 	}
-//	qDebug() << "ResizeGesture::release: transaction" << m_transactionStarted;
 	if (m_transactionStarted)
 	{
 		m_transactionStarted->commit();
@@ -196,11 +191,7 @@
 		targetIcon = currItem->getUPixmap();
 	}
 	if (!m_transactionStarted)
-	{
-		m_transactionStarted = new UndoTransaction(Um::instance()->beginTransaction(targetName, targetIcon,
-																					Um::Resize, "", Um::IResize));
-//		qDebug() << "ResizeGesture::doResize: begin transaction" << m_transactionStarted;
-	}
+		m_transactionStarted = new UndoTransaction(Um::instance()->beginTransaction(targetName, targetIcon, Um::Resize, "", Um::IResize));
 	QRectF newBounds = m_bounds.normalized();
 	double dw = (newBounds.width() - m_extraWidth) - currItem->width();
 	double dh = (newBounds.height() - m_extraHeight) - currItem->height();
@@ -313,14 +304,21 @@
 		}
 		double oldX = currItem->xPos();
 		double oldY = currItem->yPos();
-		currItem->setXYPos(newBounds.x() + m_extraX, newBounds.y() + m_extraY);
-		if (currItem->Parent != 0)	// part of a group
-		{
-			currItem->gXpos += currItem->xPos() - oldX;
-			currItem->gYpos += currItem->yPos() - oldY;
-		}
-		currItem->setWidth(newBounds.width() - m_extraWidth);
-		currItem->setHeight(newBounds.height() - m_extraHeight);
+		QTransform mm = currItem->getTransform();
+		QPointF itPos = mm.map(QPointF(0, 0));
+		oldX = itPos.x();
+		oldY = itPos.y();
+		double m_scaleX, m_scaleY;
+		getScaleFromMatrix(mm, m_scaleX, m_scaleY);
+		double dx = (itPos.x() - newBounds.x()) / m_scaleX;
+		double dy = (itPos.y() - newBounds.y()) / m_scaleY;
+		if (mm.m11() < 0)
+			dx *= -1;
+		if (mm.m22() < 0)
+			dy *= -1;
+		currItem->moveBy(-dx, -dy, true);
+		currItem->setWidth(newBounds.width() / m_scaleX - m_extraWidth);
+		currItem->setHeight(newBounds.height() / m_scaleY - m_extraHeight);
 		currItem->updateClip();
 		if (currItem->isArc())
 		{

Modified: branches/ScribusOIF/scribus/canvasmode.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17093&path=/branches/ScribusOIF/scribus/canvasmode.cpp
==============================================================================
--- branches/ScribusOIF/scribus/canvasmode.cpp (original)
+++ branches/ScribusOIF/scribus/canvasmode.cpp Sat Dec 17 12:46:02 2011
@@ -449,14 +449,20 @@
 		{
 			p->setBrush(m_brush["outline"]);
 			p->setPen(m_pen["outline"]);
-			p->translate(currItem->xPos(), currItem->yPos());
+
+			QTransform itemTrans = currItem->getTransform();
+			QPointF itPos = itemTrans.map(QPointF(0, 0));
+			double gRot = getRotationDFromMatrix(itemTrans);
+			double m_scaleX, m_scaleY;
+			getScaleFromMatrix(itemTrans, m_scaleX, m_scaleY);
+			p->translate(itPos);
 			p->translate(deltax, deltay);
-			if (currItem->rotation() != 0)
+			if (gRot != 0)
 			{
 				p->setRenderHint(QPainter::Antialiasing);
-				p->rotate(currItem->rotation());
-			}
-			p->scale(scalex, scaley);
+				p->rotate(-gRot);
+			}
+			p->scale(scalex * m_scaleX, scaley * m_scaleY);
 			currItem->DrawPolyL(p, currItem->Clip);
 		}
 		else // moving page item

Modified: branches/ScribusOIF/scribus/loadsaveplugin.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17093&path=/branches/ScribusOIF/scribus/loadsaveplugin.cpp
==============================================================================
--- branches/ScribusOIF/scribus/loadsaveplugin.cpp (original)
+++ branches/ScribusOIF/scribus/loadsaveplugin.cpp Sat Dec 17 12:46:02 2011
@@ -7,6 +7,7 @@
 #include "loadsaveplugin.h"
 #include "commonstrings.h"
 #include "scribuscore.h"
+#include "scribusview.h"
 #include "plugins/formatidlist.h"
 
 #include <QList>

Modified: branches/ScribusOIF/scribus/loadsaveplugin.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17093&path=/branches/ScribusOIF/scribus/loadsaveplugin.h
==============================================================================
--- branches/ScribusOIF/scribus/loadsaveplugin.h (original)
+++ branches/ScribusOIF/scribus/loadsaveplugin.h Sat Dec 17 12:46:02 2011
@@ -19,10 +19,9 @@
 class FileFormat;
 //TODO REmove includes one day
 //class ScribusDoc;
-//class ScribusView;
+class ScribusView;
 #include "scfonts.h"
 #include "scribusdoc.h"
-#include "scribusview.h"
 
 /*!
  * @brief Superclass for all file import/export/load/save plugins

Modified: branches/ScribusOIF/scribus/pageitem.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17093&path=/branches/ScribusOIF/scribus/pageitem.cpp
==============================================================================
--- branches/ScribusOIF/scribus/pageitem.cpp (original)
+++ branches/ScribusOIF/scribus/pageitem.cpp Sat Dec 17 12:46:02 2011
@@ -42,6 +42,7 @@
 #include "colorblind.h"
 #include "commonstrings.h"
 
+#include "pageitem_group.h"
 #include "pageitem_textframe.h"
 #include "pageitem_latexframe.h"
 #include "prefsmanager.h"
@@ -849,6 +850,20 @@
 	if (drawingOnly || m_Doc->isLoading())
 		return;
 	checkChanges();
+}
+
+int PageItem::level()
+{
+	if (Parent == NULL)
+	{
+		if (m_Doc)
+		{
+			QList<PageItem*>* items = OnMasterPage.isEmpty() ? &m_Doc->DocItems : &m_Doc->MasterItems;
+			return (items->indexOf(this) + 1);
+		}
+		return 0;
+	}
+	return (Parent->asGroupFrame()->groupItemList.indexOf(this) + 1);
 }
 
 void PageItem::moveBy(const double dX, const double dY, bool drawingOnly)

Modified: branches/ScribusOIF/scribus/pageitem.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17093&path=/branches/ScribusOIF/scribus/pageitem.h
==============================================================================
--- branches/ScribusOIF/scribus/pageitem.h (original)
+++ branches/ScribusOIF/scribus/pageitem.h Sat Dec 17 12:46:02 2011
@@ -251,6 +251,9 @@
 //		if (isWelded())
 //			unWeldChild();
 	}
+
+	// Get item level relative to its parent doc or group
+	int level();
 
 	void saxx(SaxHandler& handler, const Xml_string& elemtag) const {}
 	void saxx(SaxHandler& handler) const {};

Modified: branches/ScribusOIF/scribus/plugins/import/pdf/slaoutput.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17093&path=/branches/ScribusOIF/scribus/plugins/import/pdf/slaoutput.h
==============================================================================
--- branches/ScribusOIF/scribus/plugins/import/pdf/slaoutput.h (original)
+++ branches/ScribusOIF/scribus/plugins/import/pdf/slaoutput.h Sat Dec 17 12:46:02 2011
@@ -22,6 +22,7 @@
 #include "fpointarray.h"
 #include "pageitem.h"
 #include "scribusdoc.h"
+#include "scribusview.h"
 #include "selection.h"
 #include "vgradient.h"
 

Modified: branches/ScribusOIF/scribus/selection.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17093&path=/branches/ScribusOIF/scribus/selection.cpp
==============================================================================
--- branches/ScribusOIF/scribus/selection.cpp (original)
+++ branches/ScribusOIF/scribus/selection.cpp Sat Dec 17 12:46:02 2011
@@ -503,6 +503,25 @@
 	return layerID;
 }
 
+bool Selection::objectsHaveSameParent(void) const
+{
+	int selectedItemCount = m_SelList.count();
+	if (selectedItemCount <= 1)
+		return true;
+
+	bool haveSameParent = true;
+	const PageItem *firstItem = itemAt(0);
+	for (int a = 1; a < selectedItemCount; ++a)
+	{
+		if (itemAt(a)->Parent != firstItem->Parent)
+		{
+			haveSameParent = false;
+			break;
+		}
+	}
+	return haveSameParent;
+}
+
 bool Selection::signalsDelayed(void)
 {
 	return (m_isGUISelection && (m_delaySignals > 0));

Modified: branches/ScribusOIF/scribus/selection.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17093&path=/branches/ScribusOIF/scribus/selection.h
==============================================================================
--- branches/ScribusOIF/scribus/selection.h (original)
+++ branches/ScribusOIF/scribus/selection.h Sat Dec 17 12:46:02 2011
@@ -158,6 +158,12 @@
 		 */
 		int objectsLayer(void) const;
 
+		/**
+		 * \brief detect if selected object have all same parent (doc or group)
+		 * @return true if objects share same parent, false otherwise
+		 */
+		bool objectsHaveSameParent(void) const;
+
 		bool signalsDelayed(void);
 		void delaySignalsOn(void);
 		void delaySignalsOff(void);

Modified: branches/ScribusOIF/scribus/ui/propertiespalette_xyz.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17093&path=/branches/ScribusOIF/scribus/ui/propertiespalette_xyz.cpp
==============================================================================
--- branches/ScribusOIF/scribus/ui/propertiespalette_xyz.cpp (original)
+++ branches/ScribusOIF/scribus/ui/propertiespalette_xyz.cpp Sat Dec 17 12:46:02 2011
@@ -294,11 +294,7 @@
 	m_item = i;
 
 	nameEdit->setText(m_item->itemName());
-	QString tm;
-	if (m_item->Parent == NULL)
-		levelLabel->setText(tm.setNum(m_doc->Items->indexOf(m_item) + 1));
-	else
-		levelLabel->setText(tm.setNum(m_item->Parent->asGroupFrame()->groupItemList.indexOf(m_item) + 1));
+	levelLabel->setText( QString::number(m_item->level()) );
 
 	connect(nameEdit, SIGNAL(Leaved()), this, SLOT(handleNewName()));
 
@@ -356,20 +352,7 @@
 	}
 	xposSpin->setEnabled(!setter);
 	yposSpin->setEnabled(!setter);
-	bool haveSameParent = true;
-	int selectedItemCount = m_doc->m_Selection->count();
-	if (selectedItemCount > 1)
-	{
-		PageItem *firstItem = m_doc->m_Selection->itemAt(0);
-		for (int a = 1; a < selectedItemCount; ++a)
-		{
-			if (m_doc->m_Selection->itemAt(a)->Parent != firstItem->Parent)
-			{
-				haveSameParent = false;
-				break;
-			}
-		}
-	}
+	bool haveSameParent = m_doc->m_Selection->objectsHaveSameParent();
 	levelGroup->setEnabled(haveSameParent && !i->locked());
 	if ((m_item->isGroup()) && (!m_item->isSingleSel))
 	{
@@ -1131,11 +1114,7 @@
 	if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning())
 		return;
 	m_doc->itemSelection_LowerItem();
-	QString tm;
-	if (m_item->Parent == NULL)
-		levelLabel->setText(tm.setNum(m_doc->Items->indexOf(m_item) + 1));
-	else
-		levelLabel->setText(tm.setNum(m_item->Parent->asGroupFrame()->groupItemList.indexOf(m_item) + 1));
+	levelLabel->setText( QString::number(m_item->level()) );
 }
 
 void PropertiesPalette_XYZ::handleRaise()
@@ -1143,11 +1122,7 @@
 	if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning())
 		return;
 	m_doc->itemSelection_RaiseItem();
-	QString tm;
-	if (m_item->Parent == NULL)
-		levelLabel->setText(tm.setNum(m_doc->Items->indexOf(m_item) + 1));
-	else
-		levelLabel->setText(tm.setNum(m_item->Parent->asGroupFrame()->groupItemList.indexOf(m_item) + 1));
+	levelLabel->setText( QString::number(m_item->level()) );
 }
 
 void PropertiesPalette_XYZ::handleFront()
@@ -1155,11 +1130,7 @@
 	if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning())
 		return;
 	m_doc->bringItemSelectionToFront();
-	QString tm;
-	if (m_item->Parent == NULL)
-		levelLabel->setText(tm.setNum(m_doc->Items->indexOf(m_item) + 1));
-	else
-		levelLabel->setText(tm.setNum(m_item->Parent->asGroupFrame()->groupItemList.indexOf(m_item) + 1));
+	levelLabel->setText( QString::number(m_item->level()) );
 }
 
 void PropertiesPalette_XYZ::handleBack()
@@ -1167,11 +1138,7 @@
 	if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning())
 		return;
 	m_doc->sendItemSelectionToBack();
-	QString tm;
-	if (m_item->Parent == NULL)
-		levelLabel->setText(tm.setNum(m_doc->Items->indexOf(m_item) + 1));
-	else
-		levelLabel->setText(tm.setNum(m_item->Parent->asGroupFrame()->groupItemList.indexOf(m_item) + 1));
+	levelLabel->setText( QString::number(m_item->level()) );
 }
 
 void PropertiesPalette_XYZ::handleBasePoint(int m)

Modified: branches/ScribusOIF/scribus/ui/propertywidget_pos.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17093&path=/branches/ScribusOIF/scribus/ui/propertywidget_pos.cpp
==============================================================================
--- branches/ScribusOIF/scribus/ui/propertywidget_pos.cpp (original)
+++ branches/ScribusOIF/scribus/ui/propertywidget_pos.cpp Sat Dec 17 12:46:02 2011
@@ -264,20 +264,7 @@
 	xposSpin->setEnabled(!setter);
 	yposSpin->setEnabled(!setter);
 
-	bool haveSameParent = true;
-	int selectedItemCount = m_doc->m_Selection->count();
-	if (selectedItemCount > 1)
-	{
-		PageItem *firstItem = m_doc->m_Selection->itemAt(0);
-		for (int a = 1; a < selectedItemCount; ++a)
-		{
-			if (m_doc->m_Selection->itemAt(a)->Parent != firstItem->Parent)
-			{
-				haveSameParent = false;
-				break;
-			}
-		}
-	}
+	bool haveSameParent = m_doc->m_Selection->objectsHaveSameParent();
 	levelSpin->setEnabled(haveSameParent && !m_item->locked());
 
 	if (m_item->asLine())
@@ -1100,10 +1087,7 @@
 	if (!m_doc || !m_item || !m_ScMW || m_ScMW->scriptIsRunning())
 		return;
 	m_doc->itemSelection_LowerItem();
-	if (m_item->Parent == NULL)
-		displayLevel(m_doc->Items->indexOf(m_item) + 1);
-	else
-		displayLevel(m_item->Parent->asGroupFrame()->groupItemList.indexOf(m_item) + 1);
+	displayLevel(m_item->level());
 }
 
 void PropertyWidget_Position::handleRaise()
@@ -1111,10 +1095,7 @@
 	if (!m_doc || !m_item || !m_ScMW || m_ScMW->scriptIsRunning())
 		return;
 	m_doc->itemSelection_RaiseItem();
-	if (m_item->Parent == NULL)
-		displayLevel(m_doc->Items->indexOf(m_item) + 1);
-	else
-		displayLevel(m_item->Parent->asGroupFrame()->groupItemList.indexOf(m_item) + 1);
+	displayLevel(m_item->level());
 }
 
 void PropertyWidget_Position::handleFront()
@@ -1122,10 +1103,7 @@
 	if (!m_doc || !m_item || !m_ScMW || m_ScMW->scriptIsRunning())
 		return;
 	m_doc->bringItemSelectionToFront();
-	if (m_item->Parent == NULL)
-		displayLevel(m_doc->Items->indexOf(m_item) + 1);
-	else
-		displayLevel(m_item->Parent->asGroupFrame()->groupItemList.indexOf(m_item) + 1);
+	displayLevel(m_item->level());
 }
 
 void PropertyWidget_Position::handleBack()
@@ -1133,10 +1111,7 @@
 	if (!m_doc || !m_item || !m_ScMW || m_ScMW->scriptIsRunning())
 		return;
 	m_doc->sendItemSelectionToBack();
-	if (m_item->Parent == NULL)
-		displayLevel(m_doc->Items->indexOf(m_item) + 1);
-	else
-		displayLevel(m_item->Parent->asGroupFrame()->groupItemList.indexOf(m_item) + 1);
+	displayLevel(m_item->level());
 }
 
 void PropertyWidget_Position::handleBasePoint(int m)




More information about the scribus-commit mailing list