Rev 12348 |
Rev 13304 |
Go to most recent revision |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
/*
For general Scribus (>=1.3.2) copyright and licensing information please refer
to the COPYING file provided with the program. Following this notice may exist
a copyright and/or license notice that predates the release of Scribus 1.3.2
for which a new license (GPL+exception) is in place.
*/
/***************************************************************************
scribusview.cpp - description
-------------------
begin : Fre Apr 6 21:47:55 CEST 2001
copyright : (C) 2001 by Franz Schmid
email : Franz.Schmid@altmuehlnet.de
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "scribusview.h"
#include "scribusview.moc"
#include "scconfig.h"
#include <qcolor.h>
#include <qfont.h>
#include <qfontmetrics.h>
#include <qpixmap.h>
#include <qpointarray.h>
#include <qstringlist.h>
#include <qdragobject.h>
#include <qimage.h>
#include <qcstring.h>
#include <qfileinfo.h>
#include <qfile.h>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <qcursor.h>
#include <qurl.h>
#include <qdir.h>
#include <qevent.h>
#include <qsizegrip.h>
#if QT_VERSION > 0x030102
#define SPLITVC SplitHCursor
#define SPLITHC SplitVCursor
#else
#define SPLITVC SplitVCursor
#define SPLITHC SplitHCursor
#endif
#include "scribus.h"
#include "tree.h"
#include "mpalette.h"
#include "scribusXml.h"
#include "selection.h"
#include "serializer.h"
#include "insertTable.h"
#include "hruler.h"
#include "vruler.h"
#include "filewatcher.h"
#include "undomanager.h"
#include "units.h"
#include "extimageprops.h"
#include "page.h"
#include "pageitemattributes.h"
#include "pageitem_imageframe.h"
#include "pageitem_line.h"
#include "pageitem_pathtext.h"
#include "pageitem_polygon.h"
#include "pageitem_polyline.h"
#include "pageitem_textframe.h"
#include "pageselector.h"
#include "scpaths.h"
#include "actionmanager.h"
#ifdef HAVE_TIFF
#include <tiffio.h>
#endif
#ifdef HAVE_CMS
#include CMS_INC
#endif
#include "scfontmetrics.h"
#include "scmessagebox.h"
#include "util.h"
#include "story.h"
#include "prefsmanager.h"
#include "rulermover.h"
#include "hyphenator.h"
#include "commonstrings.h"
using namespace std;
ScribusView::ScribusView(QWidget *parent, ScribusDoc *doc) :
QScrollView(parent, "s", WRepaintNoErase | WNorthWestGravity),
Doc(doc),
Prefs(&(PrefsManager::instance()->appPrefs)),
undoManager(UndoManager::instance()),
OldScale(0),
GroupX(0), GroupY(0), GroupW(0), GroupH(0),
oldW(-1), oldCp(-1),
Mxp(-1), Myp(-1), Dxp(-1), Dyp(-1),
frameResizeHandle(-1),
SeRx(-1), SeRy(-1), GyM(-1), GxM(-1),
ClRe(-1), ClRe2(-1),
SegP1(-1), SegP2(-1),
RotMode(0),
DrHY(-1), DrVX(-1),
EdPoints(true),
m_MouseButtonPressed(false),
operItemMoving(false),
MoveGY(false), MoveGX(false),
HaveSelRect(false),
operItemResizing(false),
EditContour(false),
//GroupSel(false),
DraggedGroup(false),
DraggedGroupFirst(false),
operItemResizeInEditMode(false),
MidButt(false),
updateOn(true),
FirstPoly(true),
Magnify(false),
MoveSym(false),
previewMode(false),
RCenter(-1,-1),
RecordP(),
Ready(false),
oldX(0), oldY(0),
_groupTransactionStarted(false),
_isGlobalMode(true),
evSpon(false),
forceRedraw(false),
Scale(Prefs->DisScale),
oldClip(0),
m_vhRulerHW(17),
m_cursorVisible(false)
{
setHScrollBarMode(QScrollView::AlwaysOn);
setVScrollBarMode(QScrollView::AlwaysOn);
setMargins(m_vhRulerHW, m_vhRulerHW, 0, 0);
setResizePolicy(Manual);
viewport()->setBackgroundMode(PaletteBackground);
QFont fo = QFont(font());
int posi = fo.pointSize()-2;
fo.setPointSize(posi);
unitSwitcher = new QComboBox( false, this, "unitSwitcher" );
unitSwitcher->setFocusPolicy(QWidget::NoFocus);
unitSwitcher->setFont(fo);
for (int i=0;i<=unitGetMaxIndex();++i)
unitSwitcher->insertItem(unitGetStrFromIndex(i));
zoomSpinBox = new MSpinBox( 10, 3200, this, 2 );
zoomSpinBox ->setTabAdvance(false);
zoomSpinBox->setFont(fo);
zoomSpinBox->setValue( 100 );
zoomSpinBox->setFocusPolicy(QWidget::ClickFocus);
zoomSpinBox->setSuffix( tr( " %" ) );
#if OPTION_USE_QTOOLBUTTON
zoomOutToolbarButton = new QToolButton(this);
zoomDefaultToolbarButton = new QToolButton(this);
zoomInToolbarButton = new QToolButton(this);
zoomDefaultToolbarButton->setAutoRaise(OPTION_FLAT_BUTTON);
zoomOutToolbarButton->setAutoRaise(OPTION_FLAT_BUTTON);
zoomInToolbarButton->setAutoRaise(OPTION_FLAT_BUTTON);
#else
zoomDefaultToolbarButton = new QPushButton(this);
zoomDefaultToolbarButton->setFocusPolicy(QWidget::NoFocus);
zoomDefaultToolbarButton->setDefault( false );
zoomDefaultToolbarButton->setAutoDefault( false );
zoomDefaultToolbarButton->setFlat(OPTION_FLAT_BUTTON);
zoomOutToolbarButton = new QPushButton(this);
zoomOutToolbarButton->setFocusPolicy(QWidget::NoFocus);
zoomOutToolbarButton->setDefault( false );
zoomOutToolbarButton->setAutoDefault( false );
zoomOutToolbarButton->setFlat(OPTION_FLAT_BUTTON);
zoomInToolbarButton = new QPushButton(this);
zoomInToolbarButton->setFocusPolicy(QWidget::NoFocus);
zoomInToolbarButton->setDefault( false );
zoomInToolbarButton->setAutoDefault( false );
zoomInToolbarButton->setFlat(OPTION_FLAT_BUTTON);
#endif
zoomDefaultToolbarButton->setText("1:1");
// zoomDefaultToolbarButton->setPixmap(loadIcon("viewmag1.png"));
zoomOutToolbarButton->setPixmap(loadIcon("viewmagout.png"));
zoomInToolbarButton->setPixmap(loadIcon("viewmagin.png"));
pageSelector = new PageSelector(this, Doc->Pages->count());
pageSelector->setFont(fo);
pageSelector->setFocusPolicy(QWidget::ClickFocus);
layerMenu = new QComboBox( true, this, "LY" );
layerMenu->setEditable(false);
layerMenu->setFont(fo);
layerMenu->setFocusPolicy(QWidget::NoFocus);
horizRuler = new Hruler(this, Doc);
vertRuler = new Vruler(this, Doc);
rulerMover = new RulerMover(this);
rulerMover->setFocusPolicy(QWidget::NoFocus);
Ready = true;
viewport()->setMouseTracking(true);
setAcceptDrops(true);
viewport()->setAcceptDrops(true);
setDragAutoScroll(false);
//languageChange();
Doc->DragP = false;
Doc->leaveDrag = false;
Doc->SubMode = -1;
connect(zoomOutToolbarButton, SIGNAL(clicked()), this, SLOT(slotZoomOut()));
connect(zoomInToolbarButton, SIGNAL(clicked()), this, SLOT(slotZoomIn()));
connect(zoomDefaultToolbarButton, SIGNAL(clicked()), this, SLOT(slotZoom100()));
connect(zoomSpinBox, SIGNAL(valueChanged(int)), this, SLOT(setZoom()));
connect(pageSelector, SIGNAL(GotoPage(int)), this, SLOT(GotoPa(int)));
connect(layerMenu, SIGNAL(activated(int)), this, SLOT(GotoLa(int)));
connect(unitSwitcher, SIGNAL(activated(int)), this, SLOT(ChgUnit(int)));
connect(this, SIGNAL(contentsMoving(int, int)), this, SLOT(setRulerPos(int, int)));
connect(this, SIGNAL(HaveSel(int)), this, SLOT(selectionChanged()));
}
void ScribusView::languageChange()
{
disconnect(layerMenu, SIGNAL(activated(int)), this, SLOT(GotoLa(int)));
disconnect(unitSwitcher, SIGNAL(activated(int)), this, SLOT(ChgUnit(int)));
zoomSpinBox->setSuffix( tr( " %" ) );
layerMenu->setCurrentText( tr("Layer")+" 0");
//CB TODO Convert to actions later
unitSwitcher->clear();
for (int i=0;i<=unitGetMaxIndex();++i)
unitSwitcher->insertItem(unitGetStrFromIndex(i));
unitSwitcher->setCurrentText(unitGetStrFromIndex(Doc->unitIndex()));
connect(layerMenu, SIGNAL(activated(int)), this, SLOT(GotoLa(int)));
connect(unitSwitcher, SIGNAL(activated(int)), this, SLOT(ChgUnit(int)));
}
void ScribusView::viewportPaintEvent ( QPaintEvent * p )
{
#ifndef _WIN32
if (p->spontaneous())
evSpon = true;
#endif
QScrollView::viewportPaintEvent(p);
}
void ScribusView::drawContents(QPainter *, int clipx, int clipy, int clipw, int cliph)
{
if (Doc->isLoading())
return;
if (!updateOn)
return;
// QTime tim;
// tim.start();
if ((clipw > 0) && (cliph > 0))
{
QPoint vr = contentsToViewport(QPoint(clipx, clipy));
ScPainter *painter = new ScPainter(viewport(), clipw, cliph, vr.x(), vr.y());
painter->clear(paletteBackgroundColor());
painter->translate(-Doc->minCanvasCoordinate.x()*Scale, -Doc->minCanvasCoordinate.y()*Scale);
painter->translate(-clipx, -clipy);
painter->setLineWidth(1);
painter->setFillMode(ScPainter::Solid);
// painter->translate(0.5, 0.5);
painter->setZoomFactor(1.0);
/* Draw Page Outlines */
if (!Doc->masterPageMode())
{
uint docPagesCount=Doc->Pages->count();
for (int a = 0; a < static_cast<int>(docPagesCount); ++a)
{
int x = qRound(Doc->Pages->at(a)->xOffset() * Scale);
int y = qRound(Doc->Pages->at(a)->yOffset() * Scale);
int w = qRound(Doc->Pages->at(a)->width() * Scale);
int h = qRound(Doc->Pages->at(a)->height() * Scale);
QRect drawRect = QRect(x, y, w+5, h+5);
drawRect.moveBy(qRound(-Doc->minCanvasCoordinate.x() * Scale), qRound(-Doc->minCanvasCoordinate.y() * Scale));
if (drawRect.intersects(QRect(clipx, clipy, clipw, cliph)))
{
painter->setFillMode(ScPainter::Solid);
painter->setPen(black, 1, SolidLine, FlatCap, MiterJoin);
painter->setBrush(QColor(128,128,128));
painter->drawRect(x+5, y+5, w, h);
if (a == Doc->currentPageNumber())
painter->setPen(red, 2, SolidLine, FlatCap, MiterJoin);
else
painter->setPen(black, 1, SolidLine, FlatCap, MiterJoin);
painter->setBrush(Doc->papColor);
painter->drawRect(x, y, w, h);
if (Doc->guidesSettings.before)
DrawPageMarks(painter, Doc->Pages->at(a), QRect(clipx, clipy, clipw, cliph));
}
DrawMasterItems(painter, Doc->Pages->at(a), QRect(clipx, clipy, clipw, cliph));
}
DrawPageItems(painter, QRect(clipx, clipy, clipw, cliph));
if (!Doc->guidesSettings.before)
{
for (uint a = 0; a < docPagesCount; ++a)
{
int x = static_cast<int>(Doc->Pages->at(a)->xOffset() * Scale);
int y = static_cast<int>(Doc->Pages->at(a)->yOffset() * Scale);
int w = static_cast<int>(Doc->Pages->at(a)->width() * Scale);
int h = static_cast<int>(Doc->Pages->at(a)->height() * Scale);
QRect drawRect = QRect(x, y, w+5, h+5);
drawRect.moveBy(qRound(-Doc->minCanvasCoordinate.x() * Scale), qRound(-Doc->minCanvasCoordinate.y() * Scale));
if (drawRect.intersects(QRect(clipx, clipy, clipw, cliph)))
DrawPageMarks(painter, Doc->Pages->at(a), QRect(clipx, clipy, clipw, cliph));
}
}
}
else
{
int x = static_cast<int>(Doc->ScratchLeft * Scale);
int y = static_cast<int>(Doc->ScratchTop * Scale);
int w = static_cast<int>(Doc->currentPage->width() * Scale);
int h = static_cast<int>(Doc->currentPage->height() * Scale);
QRect drawRect = QRect(x, y, w+5, h+5);
drawRect.moveBy(qRound(-Doc->minCanvasCoordinate.x() * Scale), qRound(-Doc->minCanvasCoordinate.y() * Scale));
if (drawRect.intersects(QRect(clipx, clipy, clipw, cliph)))
{
painter->setFillMode(ScPainter::Solid);
painter->setPen(black, 1, SolidLine, FlatCap, MiterJoin);
painter->setBrush(QColor(128,128,128));
painter->drawRect(x+5, y+5, w, h);
painter->setBrush(Doc->papColor);
painter->drawRect(x, y, w, h);
if (Doc->guidesSettings.before)
DrawPageMarks(painter, Doc->currentPage, QRect(clipx, clipy, clipw, cliph));
}
DrawPageItems(painter, QRect(clipx, clipy, clipw, cliph));
if ((!Doc->guidesSettings.before) && (drawRect.intersects(QRect(clipx, clipy, clipw, cliph))))
DrawPageMarks(painter, Doc->currentPage, QRect(clipx, clipy, clipw, cliph));
}
if ((Doc->m_Selection->count() != 0) || (linkedFramesToShow.count() != 0))
{
double z = painter->zoomFactor();
painter->setZoomFactor(Scale);
painter->save();
PageItem *currItem;
if ((Doc->guidesSettings.linkShown) && (linkedFramesToShow.count() != 0))
currItem = linkedFramesToShow.at(0);
else
{
if (linkedFramesToShow.count() != 0)
currItem = linkedFramesToShow.at(0);
else
currItem = Doc->m_Selection->itemAt(0);
}
//Draw the frame links
if ((((Doc->appMode == modeLinkFrames) || (Doc->appMode == modeUnlinkFrames))
&& (currItem->itemType() == PageItem::TextFrame)) || (Doc->guidesSettings.linkShown))
{
PageItem *nextItem = currItem;
if (Doc->guidesSettings.linkShown)
{
for (uint lks = 0; lks < linkedFramesToShow.count(); ++lks)
{
nextItem = linkedFramesToShow.at(lks);
while (nextItem != 0)
{
//Calculate the link points of the frames
double x11 = nextItem->xPos();
double y11 = nextItem->yPos();
double x12 = x11+nextItem->width();
double y12 = y11+nextItem->height();
double x1mid = x11+(x12-x11)/2;
double y1mid = y11+(y12-y11)/2;
if (nextItem->rotation()!=0.000)
{
FPoint tempPoint(0,0, x11, y11, nextItem->rotation(), 1, 1);
x11=tempPoint.x();
y11=tempPoint.y();
FPoint tempPoint2(0,0, x12, y12, nextItem->rotation(), 1, 1);
x12=tempPoint2.x();
y12=tempPoint2.y();
FPoint tempPoint3(0,0, x1mid, y1mid, nextItem->rotation(), 1, 1);
x1mid=tempPoint3.x();
y1mid=tempPoint3.y();
}
double a1, b1, a2, b2;
a1 = a2 = b1 = b2 = 0;
if (nextItem->NextBox!=NULL)
{
double x21 = nextItem->NextBox->xPos();
double y21 = nextItem->NextBox->yPos();
double x22 = x21+nextItem->NextBox->width();
double y22 = y21+nextItem->NextBox->height();
double x2mid = x21 + nextItem->NextBox->width()/2;
double y2mid = y21 + nextItem->NextBox->height()/2;
//x2mid = x21+(x22-x21)/2;
//y2mid = y21+(y22-y21)/2;
if (nextItem->NextBox->rotation()!=0.000)
{
FPoint tempPoint(0,0, x21, y21, nextItem->NextBox->rotation(), 1, 1);
x21=tempPoint.x();
y21=tempPoint.y();
FPoint tempPoint2(0,0, x22, y22, nextItem->NextBox->rotation(), 1, 1);
x22=tempPoint2.x();
y22=tempPoint2.y();
FPoint tempPoint3(0,0, x2mid, y2mid, nextItem->NextBox->rotation(), 1, 1);
x2mid=tempPoint3.x();
y2mid=tempPoint3.y();
}
if (x22<x11) { a1 = x11; a2 = x22; }
if (x21>x12) { a1 = x12; a2 = x21; }
if (y22<y11) { b1 = y11; b2 = y22; }
if (y21>y12) { b1 = y12; b2 = y21; }
if (x21<x12 && x21>x11) { a1 = x1mid; a2 = x2mid; }
if (x21<x11 && x22>x11) { a1 = x1mid; a2 = x2mid; }
if (y21<y12 && y21>y11) { b1 = y1mid; b2 = y2mid; }
if (y21<y11 && y22>y11) { b1 = y1mid; b2 = y2mid; }
//When our points (in pt) are exactly the same, cover this too. #3634
if (x11==x21) { a1 = x1mid; a2 = x2mid; }
if (y11==y21) { b1 = y1mid; b2 = y2mid; }
}
//Draw the link frame lines
FPoint Start(a1-nextItem->xPos(), b1-nextItem->yPos(), nextItem->xPos(), nextItem->yPos(), nextItem->rotation(), 1, 1);
//FPoint Start = transformPoint(FPoint(nextItem->Width/2, nextItem->Height), nextItem->xPos(), nextItem->yPos(), nextItem->Rot, 1, 1);
nextItem = nextItem->NextBox;
if (nextItem != NULL)
{
FPoint End(a2-nextItem->xPos(), b2-nextItem->yPos(), nextItem->xPos(), nextItem->yPos(), nextItem->rotation(), 1, 1);
drawLinkFrameLine(painter, Start, End);
}
}
}
}
else
{
while (nextItem != 0)
{
if (nextItem->BackBox != 0)
nextItem = nextItem->BackBox;
else
break;
}
while (nextItem != 0)
{
FPoint Start(nextItem->width()/2, nextItem->height(), nextItem->xPos(), nextItem->yPos(), nextItem->rotation(), 1, 1);
nextItem = nextItem->NextBox;
//Draw the link frame indicator for a new link
//CB unsure if we need to do this
if (nextItem != 0)
{
FPoint End(nextItem->width()/2, 0, nextItem->xPos(), nextItem->yPos(), nextItem->rotation(), 1, 1);
drawLinkFrameLine(painter, Start, End);
}
}
}
}
painter->setLineWidth(1);
painter->setPenOpacity(1.0);
painter->restore();
painter->setZoomFactor(z);
}
painter->end();
delete painter;
painter=NULL;
}
if (Doc->m_Selection->count() != 0)
{
PageItem *currItem = Doc->m_Selection->itemAt(0);
currItem->paintObj();
if ((Doc->EditClip) && (currItem->isSelected()))
{
if (EditContour)
MarkClip(currItem, currItem->ContourLine, true);
else
MarkClip(currItem, currItem->PoLine, true);
}
if (Doc->m_Selection->isMultipleSelection())
{
setGroupRect();
paintGroupRect();
}
}
if (Doc->appMode == modeEdit)
slotDoCurs(true);
if (Doc->appMode == modeEditGradientVectors)
{
PageItem *currItem = Doc->m_Selection->itemAt(0);
QPainter p;
p.begin(viewport());
ToView(&p);
Transform(currItem, &p);
p.setPen(QPen(blue, 1, SolidLine, FlatCap, MiterJoin));
p.setBrush(NoBrush);
p.drawLine(QPoint(qRound(currItem->GrStartX), qRound(currItem->GrStartY)), QPoint(qRound(currItem->GrEndX), qRound(currItem->GrEndY)));
p.setPen(QPen(magenta, 8, SolidLine, RoundCap, MiterJoin));
p.drawLine(QPoint(qRound(currItem->GrStartX), qRound(currItem->GrStartY)), QPoint(qRound(currItem->GrStartX), qRound(currItem->GrStartY)));
p.drawLine(QPoint(qRound(currItem->GrEndX), qRound(currItem->GrEndY)), QPoint(qRound(currItem->GrEndX), qRound(currItem->GrEndY)));
p.end();
}
evSpon = false;
forceRedraw = false;
// qDebug( "Time elapsed: %d ms", tim.elapsed() );
}
void ScribusView::DrawMasterItems(ScPainter *painter, Page *page, QRect clip)
{
double z = painter->zoomFactor();
if (!page->MPageNam.isEmpty())
{
Page* Mp = Doc->MasterPages.at(Doc->MasterNames[page->MPageNam]);
if (page->FromMaster.count() != 0)
{
//QPainter p;
int Lnr;
struct Layer ll;
PageItem *currItem;
ll.isViewable = false;
ll.LNr = 0;
Lnr = 0;
uint layerCount=Doc->layerCount();
for (uint la = 0; la < layerCount; ++la)
{
Level2Layer(Doc, &ll, Lnr);
bool pr = true;
if ((previewMode) && (!ll.isPrintable))
pr = false;
if ((ll.isViewable) && (pr))
{
uint pageFromMasterCount=page->FromMaster.count();
for (uint a = 0; a < pageFromMasterCount; ++a)
{
currItem = page->FromMaster.at(a);
if (currItem->LayerNr != ll.LNr)
continue;
if ((currItem->OwnPage != -1) && (currItem->OwnPage != static_cast<int>(Mp->pageNr())))
continue;
if ((previewMode) && (!currItem->printEnabled()))
continue;
currItem->savedOwnPage = currItem->OwnPage;
// int savedOwnPage = currItem->OwnPage;
double OldX = currItem->xPos();
double OldY = currItem->yPos();
double OldBX = currItem->BoundingX;
double OldBY = currItem->BoundingY;
currItem->OwnPage = page->pageNr();
if (!currItem->ChangedMasterItem)
{
//Hack to not check for undo changes, indicate drawing only
currItem->moveBy(-Mp->xOffset() + page->xOffset(), -Mp->yOffset() + page->yOffset(), true);
currItem->BoundingX = OldBX - Mp->xOffset() + page->xOffset();
currItem->BoundingY = OldBY - Mp->yOffset() + page->yOffset();
}
if (evSpon)
currItem->Dirty = true;
QRect oldR(currItem->getRedrawBounding(Scale));
if (clip.intersects(oldR))
currItem->DrawObj(painter, clip);
currItem->OwnPage = currItem->savedOwnPage;
// currItem->OwnPage = savedOwnPage;
if (!currItem->ChangedMasterItem)
{
//Hack to not check for undo changes, indicate drawing only
currItem->setXYPos(OldX, OldY, true);
currItem->BoundingX = OldBX;
currItem->BoundingY = OldBY;
}
}
for (uint a = 0; a < pageFromMasterCount; ++a)
{
currItem = page->FromMaster.at(a);
if (currItem->LayerNr != ll.LNr)
continue;
if (!currItem->isTableItem)
continue;
if ((currItem->OwnPage != -1) && (currItem->OwnPage != static_cast<int>(Mp->pageNr())))
continue;
double OldX = currItem->xPos();
double OldY = currItem->yPos();
double OldBX = currItem->BoundingX;
double OldBY = currItem->BoundingY;
if (!currItem->ChangedMasterItem)
{
//Hack to not check for undo changes, indicate drawing only
currItem->setXYPos(OldX - Mp->xOffset() + page->xOffset(), OldY - Mp->yOffset() + page->yOffset(), true);
currItem->BoundingX = OldBX - Mp->xOffset() + page->xOffset();
currItem->BoundingY = OldBY - Mp->yOffset() + page->yOffset();
}
QRect oldR(currItem->getRedrawBounding(Scale));
if (clip.intersects(oldR))
{
painter->setZoomFactor(Scale);
painter->save();
painter->translate(currItem->xPos()*Scale, currItem->yPos()*Scale);
painter->rotate(currItem->rotation());
if ((currItem->lineColor() != CommonStrings::None) && (currItem->lineWidth() != 0.0))
{
QColor tmp;
currItem->SetFarbe(&tmp, currItem->lineColor(), currItem->lineShade());
if ((currItem->TopLine) || (currItem->RightLine) || (currItem->BottomLine) || (currItem->LeftLine))
{
painter->setPen(tmp, currItem->lineWidth(), currItem->PLineArt, Qt::SquareCap, currItem->PLineJoin);
if (currItem->TopLine)
painter->drawLine(FPoint(0.0, 0.0), FPoint(currItem->width(), 0.0));
if (currItem->RightLine)
painter->drawLine(FPoint(currItem->width(), 0.0), FPoint(currItem->width(), currItem->height()));
if (currItem->BottomLine)
painter->drawLine(FPoint(currItem->width(), currItem->height()), FPoint(0.0, currItem->height()));
if (currItem->LeftLine)
painter->drawLine(FPoint(0.0, currItem->height()), FPoint(0.0, 0.0));
}
}
painter->restore();
}
if (!currItem->ChangedMasterItem)
{
//Hack to not check for undo changes, indicate drawing only
currItem->setXYPos(OldX, OldY, true);
currItem->BoundingX = OldBX;
currItem->BoundingY = OldBY;
}
}
}
Lnr++;
}
}
}
painter->setZoomFactor(z);
}
/*backport the #3586 fix from 1.3.4cvs */
void ScribusView::DrawPageItems(ScPainter *painter, QRect clip)
{
linkedFramesToShow.clear();
double z = painter->zoomFactor();
if (Doc->Items->count() != 0)
{
int Lnr=0;
struct Layer ll;
PageItem *currItem;
ll.isViewable = false;
ll.LNr = 0;
uint layerCount=Doc->layerCount();
int docCurrPageNo=static_cast<int>(Doc->currentPageNumber());
for (uint la2 = 0; la2 < layerCount; ++la2)
{
Level2Layer(Doc, &ll, Lnr);
bool pr = true;
if ((previewMode) && (!ll.isPrintable))
pr = false;
if ((ll.isViewable) && (pr))
{
QPtrListIterator<PageItem> docItem(*Doc->Items);
while ( (currItem = docItem.current()) != 0)
{
++docItem;
if (currItem->LayerNr != ll.LNr)
continue;
if ((previewMode) && (!currItem->printEnabled()))
continue;
if ((Doc->masterPageMode()) && ((currItem->OwnPage != -1) && (currItem->OwnPage != docCurrPageNo)))
continue;
if (!Doc->masterPageMode() && !currItem->OnMasterPage.isEmpty())
{
if (currItem->OnMasterPage != Doc->currentPage->PageNam)
continue;
}
QRect oldR(currItem->getRedrawBounding(Scale));
if (clip.intersects(oldR))
{
if (evSpon)
currItem->Dirty = true;
if (forceRedraw)
currItem->Dirty = false;
// if ((!m_MouseButtonPressed) || (Doc->EditClip))
currItem->DrawObj(painter, clip);
currItem->Redrawn = true;
if ((currItem->asTextFrame()) && ((currItem->NextBox != 0) || (currItem->BackBox != 0)))
{
PageItem *nextItem = currItem;
while (nextItem != 0)
{
if (nextItem->BackBox != 0)
nextItem = nextItem->BackBox;
else
break;
}
if (linkedFramesToShow.find(nextItem) == -1)
linkedFramesToShow.append(nextItem);
}
if ((Doc->appMode == modeEdit) && (currItem->isSelected()) && (currItem->itemType() == PageItem::TextFrame))
{
//CB 230305 Stop redrawing the horizontal ruler if it hasnt changed when typing text!!!
if ((qRound(horizRuler->ItemPos*10000) != qRound((currItem->xPos())*10000)) || (qRound(horizRuler->ItemEndPos*10000) != qRound(((currItem->xPos()+currItem->width()) )*10000)))
{
horizRuler->setItemPosition(currItem->xPos(), currItem->width());
if (currItem->lineColor() != CommonStrings::None)
horizRuler->lineCorr = currItem->lineWidth() / 2.0;
else
horizRuler->lineCorr = 0;
horizRuler->ColGap = currItem->ColGap;
horizRuler->Cols = currItem->Cols;
horizRuler->Extra = currItem->textToFrameDistLeft();
horizRuler->RExtra = currItem->textToFrameDistRight();
horizRuler->First = Doc->docParagraphStyles[Doc->currentParaStyle].First;
horizRuler->Indent = Doc->docParagraphStyles[Doc->currentParaStyle].Indent;
if (currItem->imageFlippedH() || (currItem->reversed()))
horizRuler->Revers = true;
else
horizRuler->Revers = false;
horizRuler->ItemPosValid = true;
if (Doc->currentParaStyle < 5)
horizRuler->TabValues = currItem->TabValues;
else
horizRuler->TabValues = Doc->docParagraphStyles[Doc->currentParaStyle].TabValues;
horizRuler->repaint();
}
}
}
}
QPtrListIterator<PageItem> docItem2(*Doc->Items);
while ( (currItem = docItem2.current()) != 0 )
{
++docItem2;
if (currItem->LayerNr != ll.LNr)
continue;
if (!currItem->isTableItem)
continue;
QRect oldR(currItem->getRedrawBounding(Scale));
if (clip.intersects(oldR))
{
painter->setZoomFactor(Scale);
painter->save();
painter->translate(currItem->xPos()*Scale, currItem->yPos()*Scale);
painter->rotate(currItem->rotation());
if ((currItem->lineColor() != CommonStrings::None) && (currItem->lineWidth() != 0.0))
{
QColor tmp;
currItem->SetFarbe(&tmp, currItem->lineColor(), currItem->lineShade());
if ((currItem->TopLine) || (currItem->RightLine) || (currItem->BottomLine) || (currItem->LeftLine))
{
painter->setPen(tmp, currItem->lineWidth(), currItem->PLineArt, Qt::SquareCap, currItem->PLineJoin);
if (currItem->TopLine)
painter->drawLine(FPoint(0.0, 0.0), FPoint(currItem->width(), 0.0));
if (currItem->RightLine)
painter->drawLine(FPoint(currItem->width(), 0.0), FPoint(currItem->width(), currItem->height()));
if (currItem->BottomLine)
painter->drawLine(FPoint(currItem->width(), currItem->height()), FPoint(0.0, currItem->height()));
if (currItem->LeftLine)
painter->drawLine(FPoint(0.0, currItem->height()), FPoint(0.0, 0.0));
}
}
painter->restore();
}
}
}
Lnr++;
}
}
painter->setZoomFactor(z);
}
void ScribusView::DrawPageMarks(ScPainter *p, Page *page, QRect clip)
{
double z = p->zoomFactor();
p->save();
p->setZoomFactor(Scale);
p->translate(page->xOffset() * Scale, page->yOffset() * Scale);
double lineWidth = 0.5 / Scale;
p->setLineWidth(lineWidth);
double pageHeight=page->height();
double pageWidth=page->width();
//Draw the margins
if (Doc->guidesSettings.marginsShown)
{
p->setPen(Doc->guidesSettings.margColor);
if (Doc->marginColored)
{
p->setBrush(Doc->guidesSettings.margColor);
p->drawRect(0, 0, pageWidth, page->Margins.Top);
p->drawRect(0, page->Margins.Top, page->Margins.Left, pageHeight - page->Margins.Top);
p->drawRect(page->Margins.Left, pageHeight - page->Margins.Bottom, pageWidth - page->Margins.Right - page->Margins.Left, page->Margins.Bottom);
p->drawRect(pageWidth - page->Margins.Right, page->Margins.Top, page->Margins.Right, pageHeight-page->Margins.Top);
}
p->setPen(Doc->guidesSettings.margColor);
p->drawLine(FPoint(0, page->Margins.Top), FPoint(pageWidth, page->Margins.Top));
p->drawLine(FPoint(0, pageHeight - page->Margins.Bottom), FPoint(pageWidth, pageHeight - page->Margins.Bottom));
p->drawLine(FPoint(page->Margins.Left, 0), FPoint(page->Margins.Left, pageHeight));
p->drawLine(FPoint(pageWidth - page->Margins.Right, 0), FPoint(pageWidth - page->Margins.Right, pageHeight));
}
//Draw the baseline grid
if (Doc->guidesSettings.baseShown)
{
p->setPen(Doc->guidesSettings.baseColor, lineWidth, SolidLine, FlatCap, MiterJoin);
for (double yg = Doc->typographicSettings.offsetBaseGrid; yg < pageHeight; yg += Doc->typographicSettings.valueBaseGrid)
p->drawLine(FPoint(0, yg), FPoint(pageWidth, yg));
}
//Draw the grid lines
if (Doc->guidesSettings.gridShown)
{
double stx = 0;
double endx = pageWidth;
double sty = 0;
double endy = pageHeight;
double lowerBx = clip.x() / Scale + Doc->minCanvasCoordinate.x() - page->xOffset();
double lowerBy = clip.y() / Scale + Doc->minCanvasCoordinate.y() - page->yOffset();
double highBx = lowerBx + clip.width() / Scale;
double highBy = lowerBy + clip.height() / Scale;
/* double stx = QMAX((clip.x() - page->Xoffset) / Scale, 0);
double endx = QMIN(stx + clip.width() / Scale, page->width());
double sty = QMAX((clip.y() - page->Yoffset) / Scale, 0);
double endy = QMIN(sty + clip.height() / Scale, page->height()); */
if (Scale > 0.49)
{
double i,start;
i = Doc->guidesSettings.majorGrid;
p->setPen(Doc->guidesSettings.majorColor, lineWidth, SolidLine, FlatCap, MiterJoin);
start=floor(sty/i);
start*=i;
for (double b = start; b <= endy; b+=i)
{
if ((b >= lowerBy) && (b <= highBy))
p->drawLine(FPoint(QMAX(lowerBx, 0), b), FPoint(QMIN(pageWidth, highBx), b));
}
start=floor(stx/i);
start*=i;
for (double b = start; b <= endx; b+=i)
{
if ((b >= lowerBx) && (b <= highBx))
p->drawLine(FPoint(b, QMAX(lowerBy, 0)), FPoint(b, QMIN(pageHeight, highBy)));
}
i = Doc->guidesSettings.minorGrid;
p->setPen(Doc->guidesSettings.minorColor, lineWidth, DotLine, FlatCap, MiterJoin);
start=floor(sty/i);
start*=i;
for (double b = start; b <= endy; b+=i)
{
if ((b >= lowerBy) && (b <= highBy))
p->drawLine(FPoint(QMAX(lowerBx, 0), b), FPoint(QMIN(pageWidth, highBx), b));
}
start=floor(stx/i);
start*=i;
for (double b = start; b <= endx; b+=i)
{
if ((b >= lowerBx) && (b <= highBx))
p->drawLine(FPoint(b, QMAX(lowerBy, 0)), FPoint(b, QMIN(pageHeight, highBy)));
}
}
}
//Draw the guides
if (Doc->guidesSettings.guidesShown)
{
p->setPen(Doc->guidesSettings.guideColor, lineWidth, DotLine, FlatCap, MiterJoin);
if (page->XGuides.count() != 0)
{
for (uint xg = 0; xg < page->XGuides.count(); ++xg)
{
if ((page->XGuides[xg] >= 0) && (page->XGuides[xg] <= page->width()))
p->drawLine(FPoint(page->XGuides[xg], 0), FPoint(page->XGuides[xg], pageHeight));
}
}
if (page->YGuides.count() != 0)
{
for (uint yg = 0; yg < page->YGuides.count(); ++yg)
{
if ((page->YGuides[yg] >= 0) && (page->YGuides[yg] <= pageHeight))
p->drawLine(FPoint(0, page->YGuides[yg]), FPoint(page->width(), page->YGuides[yg]));
}
}
}
p->restore();
p->setZoomFactor(z);
}
void ScribusView::enterEvent(QEvent *)
{
if (Doc->appMode == modePanning)
qApp->setOverrideCursor(QCursor(loadIcon("HandC.xpm")), true);
}
void ScribusView::leaveEvent(QEvent *)
{
/* if (BlockLeave)
return; */
if (!m_MouseButtonPressed)
qApp->setOverrideCursor(QCursor(ArrowCursor), true);
/* else
{
if ((SelItem.count() != 0) && (m_MouseButtonPressed) && (!doku->DragP) && (doku->appMode == 1))
{
PageItem *currItem = SelItem.at(0);
if ((b->Locked) || (b->Sizing))
return;
doku->DragP = true;
doku->leaveDrag = true;
doku->DraggedElem = b;
doku->DragElements.clear();
for (uint dre=0; dre<SelItem.count(); ++dre)
doku->DragElements.append(SelItem.at(dre)->ItemNr);
ScriXmlDoc *ss = new ScriXmlDoc();
QDragObject *dr = new QTextDrag(ss->WriteElem(&SelItem, doku), this);
dr->setPixmap(loadIcon("DragPix.xpm"));
dr->drag();
delete ss;
ss=NULL;
doku->DragP = false;
doku->leaveDrag = false;
m_MouseButtonPressed = false;
doku->DraggedElem = 0;
doku->DragElements.clear();
}
} */
}
void ScribusView::contentsDragEnterEvent(QDragEnterEvent *e)
{
QString text;
e->accept(QTextDrag::canDecode(e));
if (QTextDrag::decode(e, text))
{
double gx, gy, gw, gh;
/*<< #3524
setActiveWindow();
raise();
ScMW->newActWin(Doc->WinHan);
updateContents();
>>*/
// SeleItemPos(e->pos());
QUrl ur(text);
QFileInfo fi = QFileInfo(ur.path());
ScriXmlDoc *ss = new ScriXmlDoc();
if (fi.exists())
text = ur.path();
if(ss->ReadElemHeader(text,fi.exists(), &gx, &gy, &gw, &gh))
{
GroupX = e->pos().x() / Scale;
GroupY = e->pos().y() / Scale;
GroupW = gw;
GroupH = gh;
DraggedGroup = true;
DraggedGroupFirst = true;
//GroupSel = false;
QPainter p;
p.begin(viewport());
PaintSizeRect(&p, QRect());
emit ItemGeom(gw, gh);
// QPoint pv = QPoint(qRound(gx), qRound(gy));
// PaintSizeRect(&p, QRect(pv, QPoint(pv.x()+qRound(gw), pv.y()+qRound(gh))));
p.end();
}
delete ss;
ss=NULL;
}
}
void ScribusView::contentsDragMoveEvent(QDragMoveEvent *e)
{
QString text;
// PageItem *currItem;
// bool img;
e->accept(QTextDrag::canDecode(e));
if (QTextDrag::decode(e, text))
{
if (DraggedGroup)
{
double gx, gy, gw, gh;
GroupX = e->pos().x() / Scale;
GroupY = e->pos().y() / Scale;
getGroupRectScreen(&gx, &gy, &gw, &gh);
QPainter p;
p.begin(viewport());
gx += Doc->minCanvasCoordinate.x();
gy += Doc->minCanvasCoordinate.y();
QPoint pv = QPoint(qRound(gx), qRound(gy));
if (!DraggedGroupFirst)
PaintSizeRect(&p, QRect(pv, QPoint(pv.x()+qRound(gw), pv.y()+qRound(gh))));
DraggedGroupFirst = false;
p.end();
emit MousePos(GroupX+Doc->minCanvasCoordinate.x(), GroupY+Doc->minCanvasCoordinate.y());
horizRuler->Draw(e->pos().x());
vertRuler->Draw(e->pos().y());
return;
}
/* QUrl ur(text);
QFileInfo fi = QFileInfo(ur.path());
QString ext = fi.extension(false).upper();
QStrList imfo = QImageIO::inputFormats();
if (ext == "JPG")
ext = "JPEG";
img = ((imfo.contains(ext))||(ext=="PS")||(ext=="EPS")||(ext=="TIF"));
if (!SeleItemPos(e->pos()))
{
if (SelItem.count() != 0)
Deselect(true);
}
else
{
b = SelItem.at(0);
if (img)
{
if (b->PType != 2)
Deselect(true);
}
else
{
if (b->PType != 4)
Deselect(true);
}
} */
}
}
void ScribusView::contentsDragLeaveEvent(QDragLeaveEvent *)
{
if (DraggedGroup)
{
updateContents();
DraggedGroup = false;
DraggedGroupFirst = false;
}
}
void ScribusView::contentsDropEvent(QDropEvent *e)
{
QString text;
PageItem *currItem;
bool img = false;
// struct ScText *hg;
// uint a;
int re = 0;
e->accept(QTextDrag::canDecode(e));
DraggedGroupFirst = false;
int ex = qRound(e->pos().x()/Scale + Doc->minCanvasCoordinate.x());
int ey = qRound(e->pos().y()/Scale + Doc->minCanvasCoordinate.y());
if (QTextDrag::decode(e, text))
{
//<<#3524
setActiveWindow();
raise();
ScMW->newActWin(Doc->WinHan);
updateContents();
//>>
QUrl ur(text);
QFileInfo fi = QFileInfo(ur.path());
QString ext = fi.extension(false).upper();
QStrList imfo = QImageIO::inputFormats();
if (ext == "JPG")
ext = "JPEG";
//CB Need to handle this ugly file extension list elsewhere... some capabilities class perhaps
img = ((imfo.contains(ext))||(ext=="PS")||(ext=="EPS")||(ext=="PDF")||(ext=="TIF")||(ext=="TIFF")||(ext=="PSD"));
bool selectedItemByDrag=false;
int pscx=qRound(e->pos().x()/Scale), pscy=qRound(e->pos().y()/Scale);
//Loop through all items and see which one(s) were under the drop point on the current layer
//Should make a nice function for this.
for (uint i=0; i<Doc->Items->count(); ++i)
{
if (Doc->Items->at(i)->LayerNr==Doc->activeLayer())
{
if (Doc->Items->at(i)->pointWithinItem(pscx, pscy))
{
Deselect(false);
SelectItem(Doc->Items->at(i));
selectedItemByDrag=true;
break;
}
}
}
//CB When we drag an image to a page from outside
//SeleItemPos is from 1.2.x. Needs reenabling for dragging *TO* a frame
if ((fi.exists()) && (img) && !selectedItemByDrag)// && (!SeleItemPos(e->pos())))
{
//int z = PaintPict(qRound(e->pos().x()/doku->Scale), qRound(e->pos().y()/doku->Scale), 1, 1);
int z = Doc->itemAdd(PageItem::ImageFrame, PageItem::Unspecified, ex, ey, 1, 1, 1, Doc->toolSettings.dBrushPict, CommonStrings::None, true);
PageItem *b = Doc->Items->at(z);
Doc->LoadPict(ur.path(), b->ItemNr);
b->setWidth(static_cast<double>(b->pixm.width()));
b->setHeight(static_cast<double>(b->pixm.height()));
b->OldB2 = b->width();
b->OldH2 = b->height();
b->updateClip();
emit DocChanged();
update();
return;
}
//if ((SeleItemPos(e->pos())) && (!text.startsWith("<SCRIBUSELEM")))
if (Doc->m_Selection->count()>0 && Doc->m_Selection->itemAt(0)->pointWithinItem(pscx, pscy) && (!text.startsWith("<SCRIBUSELEM")))
{
PageItem *b = Doc->m_Selection->itemAt(0);
if (b->itemType() == PageItem::ImageFrame)
{
if ((fi.exists()) && (img))
{
Doc->LoadPict(ur.path(), b->ItemNr);
update();
}
}
/* CB leaving this out for now...
if (b->PType == 4)
{
if ((b->BackBox != 0) && (b->itemText.count() == 0))
return;
if ((fi.exists()) && (!img) && (fi.size() < 500000))
{
Serializer *ss = new Serializer(ur.path());
if (ss->Read())
{
int st = doku->currentParaStyle;
ss->GetText(b, st, doku->docParagraphStyles[st].Font, doku->docParagraphStyles[st].FontSize, true);
emit DocChanged();
}
delete ss;
ss=NULL;
update();
}
else
{
slotDoCurs(false);
slotSetCurs(e->pos().x(), e->pos().y());
if (text.startsWith("<SCRIBUSELEM"))
return;
for (a=0; a<text.length(); ++a)
{
hg = new ScText;
hg->ch = text.at(a);
if (hg->ch == QChar(10))
hg->ch = QChar(13);
if (hg->ch == QChar(4))
hg->ch = QChar(9);
if (hg->ch == QChar(5))
hg->ch = QChar(13);
hg->cfont = b->IFont;
hg->csize = b->ISize;
hg->ccolor = b->TxtFill;
hg->cshade = b->ShTxtFill;
hg->cstroke = b->TxtStroke;
hg->cshade2 = b->ShTxtStroke;
hg->cselect = false;
hg->cscale = b->TxtScale;
hg->cextra = 0;
hg->cstyle = 0;
hg->cab = 0;
hg->xp = 0;
hg->yp = 0;
hg->PRot = 0;
hg->PtransX = 0;
hg->PtransY = 0;
b->itemText.insert(b->CPos, hg);
b->CPos += 1;
}
emit DocChanged();
update();
}
}*/
}
else
{
for (uint as = 0; as < Doc->Items->count(); ++as)
{
Doc->Items->at(as)->setSelected(false);
}
uint oldDocItemCount = Doc->Items->count();
if ((!img) && (Doc->DraggedElem == 0))
{
undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::Create,"",Um::ICreate);
if ((fi.exists()) && (!img))
emit LoadElem(ur.path(), ex, ey, true, false, Doc, this);
else
emit LoadElem(QString(text), ex, ey, false, false, Doc, this);
Doc->m_Selection->clear();
for (uint as = oldDocItemCount; as < Doc->Items->count(); ++as)
{
currItem = Doc->Items->at(as);
Doc->m_Selection->addItem(currItem);
if (currItem->isBookmark)
emit AddBM(currItem);
}
undoManager->commit();
}
else
{
if (Doc->DraggedElem != 0)
{
if (!Doc->leaveDrag)
{
QPopupMenu *pmen = new QPopupMenu();
qApp->setOverrideCursor(QCursor(ArrowCursor), true);
pmen->insertItem( tr("Copy Here"));
int mov = pmen->insertItem( tr("Move Here"));
pmen->insertItem( tr("Cancel"));
for (uint dre=0; dre<Doc->DragElements.count(); ++dre)
{
if (Doc->Items->at(Doc->DragElements[dre])->locked())
{
pmen->setItemEnabled(mov, false);
break;
}
}
re = pmen->indexOf(pmen->exec(QCursor::pos()));
delete pmen;
pmen=NULL;
}
else
re = 1;
if ((re == 2) || (re == -1))
{
updateContents();
return;
}
if ((re == 1) || (Doc->leaveDrag))
{
QPtrList<PageItem> pasted;
emit LoadElem(QString(text), ex, ey, false, false, Doc, this);
for (uint as = oldDocItemCount; as < Doc->Items->count(); ++as)
{
pasted.append(Doc->Items->at(as));
}
Doc->m_Selection->clear();
for (uint dre=0; dre<Doc->DragElements.count(); ++dre)
{
Doc->m_Selection->addItem(Doc->Items->at(Doc->DragElements[dre]));
}
PageItem* bb;
int fin;
for (uint dre=0; dre<Doc->DragElements.count(); ++dre)
{
bb = pasted.at(dre);
currItem = Doc->m_Selection->itemAt(dre);
if ((currItem->asTextFrame()) && ((currItem->NextBox != 0) || (currItem->BackBox != 0)))
{
if (currItem->BackBox != 0)
{
bb->BackBox = currItem->BackBox;
fin = Doc->m_Selection->findItem(currItem->BackBox);
if (fin != -1)
bb->BackBox = pasted.at(fin);
bb->BackBox->NextBox = bb;
}
if (currItem->NextBox != 0)
{
bb->NextBox = currItem->NextBox;
fin = Doc->m_Selection->findItem(currItem->NextBox);
if (fin != -1)
bb->NextBox = pasted.at(fin);
bb->NextBox->BackBox = bb;
}
}
}
for (uint dre=0; dre<Doc->DragElements.count(); ++dre)
{
currItem = Doc->m_Selection->itemAt(dre);
currItem->NextBox = 0;
currItem->BackBox = 0;
}
pasted.clear();
Doc->itemSelection_DeleteItem();
}
}
if ((!img) && ((re == 0)))
emit LoadElem(QString(text), ex, ey, false, false, Doc, this);
Doc->DraggedElem = 0;
Doc->DragElements.clear();
Doc->m_Selection->clear();
for (uint as = oldDocItemCount; as < Doc->Items->count(); ++as)
{
currItem = Doc->Items->at(as);
Doc->m_Selection->addItem(currItem);
if (currItem->isBookmark)
emit AddBM(currItem);
}
}
if (Doc->m_Selection->count() > 1)
{
setGroupRect();
paintGroupRect();
double x, y, w, h;
getGroupRect(&x, &y, &w, &h);
emit ItemPos(x, y);
emit ItemGeom(w, h);
}
updateContents();
}
if (!Doc->masterPageMode())
{
uint docPagesCount=Doc->Pages->count();
uint docCurrPageNo=Doc->currentPageNumber();
for (uint i = 0; i < docPagesCount; ++i)
{
int x = static_cast<int>(Doc->Pages->at(i)->xOffset());
int y = static_cast<int>(Doc->Pages->at(i)->yOffset());
int w = static_cast<int>(Doc->Pages->at(i)->width());
int h = static_cast<int>(Doc->Pages->at(i)->height());
if (QRect(x, y, w, h).contains(ex, ey))
{
if (docCurrPageNo != i)
{
Doc->currentPage = Doc->Pages->at(i);
setMenTxt(i);
DrawNew();
}
break;
}
}
setRulerPos(contentsX(), contentsY());
}
}
}
void ScribusView::contentsMouseDoubleClickEvent(QMouseEvent *m)
{
m->accept();
m_MouseButtonPressed = false;
PageItem *currItem = 0;
if (Doc->EditClip)
{
emit EndNodeEdit();
return;
}
if ((Doc->m_Selection->isMultipleSelection()) || (Doc->appMode != modeNormal))
{
if ((Doc->m_Selection->isMultipleSelection()) && (Doc->appMode == modeNormal))
{
if (GetItem(&currItem))
{
if (currItem->isTableItem)
{
Deselect(false);
Doc->m_Selection->addItem(currItem);
currItem->isSingleSel = true;
//CB FIXME dont call this if the added item is item 0
if (!Doc->m_Selection->primarySelectionIs(currItem))
currItem->emitAllToGUI();
currItem->paintObj();
}
}
return;
}
else
{
if (!(GetItem(&currItem) && (Doc->appMode == modeEdit) && currItem->asTextFrame()))
{
contentsMousePressEvent(m);
return;
}
}
}
if (GetItem(&currItem))
{
if ((currItem->itemType() == PageItem::Polygon) || (currItem->itemType() == PageItem::PolyLine) || (currItem->itemType() == PageItem::ImageFrame) || (currItem->itemType() == PageItem::PathText))
{
if ((currItem->locked()) || (!currItem->ScaleType))
{
contentsMousePressEvent(m);
return;
}
//If we double click on an image frame and theres no image assigned, open the
//load picture dialog, else put it into edit mode if the frame is set to show the image
if (currItem->itemType() == PageItem::ImageFrame)
{
if (currItem->Pfile.isEmpty())
emit LoadPic();
else if (currItem->imageShown())
emit Amode(modeEdit);
}
else
emit Amode(modeEdit);
}
else
if (currItem->itemType() == PageItem::TextFrame)
{
//CB old code
//emit currItem->isAnnotation() ? AnnotProps() : Amode(modeEdit);
//contentsMousePressEvent(m);
//CB if annotation, open the annotation dialog
if (currItem->isAnnotation())
{
emit AnnotProps();
contentsMousePressEvent(m);
}
//else if not in mode edit, set mode edit
else if (Doc->appMode != modeEdit)
{
emit Amode(modeEdit);
//CB ignore the double click and go with a single one
//if we werent in mode edit before.
//unsure if this is correct, but its ok given we had no
//double click select until now.
contentsMousePressEvent(m);
}
//otherwise, select between the whitespace
else
{ //Double click in a frame to select a word
PageItem_TextFrame *cItem=currItem->asTextFrame();
bool inText = slotSetCurs(m->x(), m->y());
if (!inText)
{
Deselect(true);
slotDoCurs(true);
emit Amode(modeNormal);
return;
}
int a=cItem->CPos;
while(a>0)
{
if (cItem->itemText.at(a-1)->ch.at(0).isLetterOrNumber())
--a;
else
break;
}
uint b=cItem->CPos;
while(b<cItem->itemText.count())
{
if (cItem->itemText.at(b)->ch.at(0).isLetterOrNumber())
++b;
else
break;
}
oldCp = a;
cItem->CPos=b;
cItem->ExpandSel(1, oldCp);
slotDoCurs(true);
}
}
}
}
void ScribusView::contentsMouseReleaseEvent(QMouseEvent *m)
{
PageItem *currItem;
m_MouseButtonPressed = false;
if (Doc->guidesSettings.guidesShown && Doc->appMode == modeNormal)
{
bool foundGuide = false;
double nx = m->x()/Scale + Doc->minCanvasCoordinate.x();
double ny = m->y()/Scale + Doc->minCanvasCoordinate.y();
if (Doc->currentPage->YGuides.count() != 0)
{
for (uint yg = 0; yg < Doc->currentPage->YGuides.count(); ++yg)
{
if ((Doc->currentPage->YGuides[yg]+Doc->currentPage->yOffset()< (ny+Doc->guidesSettings.grabRad)) &&
(Doc->currentPage->YGuides[yg]+Doc->currentPage->yOffset()> (ny-Doc->guidesSettings.grabRad)))
{
foundGuide = true;
break;
}
}
}
if (Doc->currentPage->XGuides.count() != 0)
{
for (uint xg = 0; xg < Doc->currentPage->XGuides.count(); ++xg)
{
if ((Doc->currentPage->XGuides[xg]+Doc->currentPage->xOffset()< (nx+Doc->guidesSettings.grabRad)) &&
(Doc->currentPage->XGuides[xg]+Doc->currentPage->xOffset()> (nx-Doc->guidesSettings.grabRad)))
{
foundGuide = true;
break;
}
}
}
if ((foundGuide) && (m->button() == RightButton) && (!GetItem(&currItem)))
{
qApp->setOverrideCursor(QCursor(ArrowCursor), true);
MoveGY = false;
MoveGX = false;
emit EditGuides();
return;
}
if (MoveGY)
{
SetYGuide(m, GyM);
MoveGY = false;
qApp->setOverrideCursor(QCursor(ArrowCursor), true);
updateContents();
GyM = -1;
return;
}
if (MoveGX)
{
SetXGuide(m, GxM);
MoveGX = false;
qApp->setOverrideCursor(QCursor(ArrowCursor), true);
updateContents();
GxM = -1;
return;
}
}
if (Doc->appMode == modeEditGradientVectors)
return;
if (Doc->appMode == modeCopyProperties)
return;
if (Doc->appMode == modeMeasurementTool)
{
QPainter p;
p.begin(viewport());
QPoint out = contentsToViewport(QPoint(0, 0));
p.translate(out.x(), out.y());
p.setRasterOp(XorROP);
p.setPen(QPen(white, 1, DotLine, FlatCap, MiterJoin));
p.drawLine(Dxp, Dyp, Mxp, Myp);
p.end();
qApp->setOverrideCursor(QCursor(ArrowCursor), true);
//emit PaintingDone();
return;
}
if (Doc->appMode == modePanning)
{
if ((m->state() & Qt::RightButton) && (m->state() & Qt::ControlButton))
{
ScMW->setAppMode(modeNormal);
}
return;
}
if (Doc->appMode == modeDrawTable)
{
if ((Doc->m_Selection->count() == 0) && (HaveSelRect) && (!MidButt))
{
QRect AreaR = QRect(static_cast<int>(Mxp), static_cast<int>(Myp), static_cast<int>(SeRx-Mxp), static_cast<int>(SeRy-Myp));
QPainter p;
p.begin(viewport());
ToView(&p);
p.scale(Scale, Scale);
p.setRasterOp(XorROP);
p.setPen(QPen(white, 1, DotLine, FlatCap, MiterJoin));
if(Mxp > SeRx)
{
double tmp=SeRx;
SeRx=static_cast<int>(Mxp);
Mxp=static_cast<int>(tmp);
}
if(Myp > SeRy)
{
double tmp=SeRy;
SeRy=static_cast<int>(Myp);
Myp=static_cast<int>(tmp);
}
HaveSelRect = false;
double Tx, Ty, Tw, Th;
Tx = Mxp;
Ty = Myp;
Tw = SeRx-Mxp;
Th = SeRy-Myp;
int z;
int Cols, Rows;
double deltaX, deltaY, offX, offY;
if ((Th < 6) || (Tw < 6))
{
p.drawRect(AreaR);
p.end();
Doc->appMode = modeNormal;
emit PaintingDone();
return;
}
InsertTable *dia = new InsertTable(this, static_cast<int>(Th / 6), static_cast<int>(Tw / 6));
if (!dia->exec())
{
p.drawRect(AreaR);
p.end();
Doc->appMode = modeNormal;
emit PaintingDone();
delete dia;
dia=NULL;
return;
}
p.end();
Cols = dia->Cols->value();
Rows = dia->Rows->value();
delete dia;
dia=NULL;
deltaX = Tw / Cols;
deltaY = Th / Rows;
offX = 0.0;
offY = 0.0;
Doc->m_Selection->clear();
if (UndoManager::undoEnabled())
undoManager->beginTransaction(Doc->currentPage->getUName(), Um::ITable, Um::CreateTable,
QString(Um::RowsCols).arg(Rows).arg(Cols), Um::ICreate);
for (int rc = 0; rc < Rows; ++rc)
{
for (int cc = 0; cc < Cols; ++cc)
{
//z = PaintText(Tx + offX, Ty + offY, deltaX, deltaY, Doc->toolSettings.dWidth, Doc->toolSettings.dPenText);
z = Doc->itemAdd(PageItem::TextFrame, PageItem::Unspecified, Tx + offX, Ty + offY, deltaX, deltaY, Doc->toolSettings.dWidth, CommonStrings::None, Doc->toolSettings.dPenText, !m_MouseButtonPressed);
currItem = Doc->Items->at(z);
currItem->isTableItem = true;
currItem->setTextFlowsAroundFrame(true);
currItem->setTextFlowUsesBoundingBox(true);
Doc->m_Selection->addItem(currItem);
offX += deltaX;
}
offY += deltaY;
offX = 0.0;
}
for (int rc = 0; rc < Rows; ++rc)
{
for (int cc = 0; cc < Cols; ++cc)
{
currItem = Doc->m_Selection->itemAt((rc * Cols) + cc);
if (rc == 0)
currItem->TopLink = 0;
else
currItem->TopLink = Doc->m_Selection->itemAt(((rc-1)*Cols)+cc);
if (rc == Rows-1)
currItem->BottomLink = 0;
else
currItem->BottomLink = Doc->m_Selection->itemAt(((rc+1)*Cols)+cc);
if (cc == 0)
currItem->LeftLink = 0;
else
currItem->LeftLink = Doc->m_Selection->itemAt((rc*Cols)+cc-1);
if (cc == Cols-1)
currItem->RightLink = 0;
else
currItem->RightLink = Doc->m_Selection->itemAt((rc*Cols)+cc+1);
}
}
emit DoGroup();
if (UndoManager::undoEnabled())
undoManager->commit();
}
Doc->appMode = modeNormal;
emit PaintingDone();
emit DocChanged();
updateContents();
return;
}
if (Doc->appMode == modeDrawFreehandLine)
{
if (RecordP.size() > 1)
{
uint z = Doc->itemAdd(PageItem::PolyLine, PageItem::Unspecified, 0, 0, 1, 1, Doc->toolSettings.dWidth, CommonStrings::None, Doc->toolSettings.dPenLine, !m_MouseButtonPressed);
currItem = Doc->Items->at(z);
currItem->PoLine.resize(0);
currItem->PoLine.addPoint(RecordP.point(0));
currItem->PoLine.addPoint(RecordP.point(0));
for (uint px = 1; px < RecordP.size()-1; ++px)
{
currItem->PoLine.addPoint(RecordP.point(px));
currItem->PoLine.addPoint(RecordP.point(px));
currItem->PoLine.addPoint(RecordP.point(px));
currItem->PoLine.addPoint(RecordP.point(px));
}
currItem->PoLine.addPoint(RecordP.point(RecordP.size()-1));
currItem->PoLine.addPoint(RecordP.point(RecordP.size()-1));
AdjustItemSize(currItem);
Doc->m_Selection->clear();
Doc->m_Selection->addItem(currItem);
currItem->ClipEdited = true;
//currItem->Select = true;
currItem->FrameType = 3;
currItem->OwnPage = Doc->OnPage(currItem);
//qDebug("emit ItemPos(currItem->xPos(), currItem->yPos());");
/*CB Done with addItem
emit SetSizeValue(currItem->Pwidth);
emit SetLineArt(currItem->PLineArt, currItem->PLineEnd, currItem->PLineJoin);
emit ItemFarben(currItem->lineColor(), currItem->fillColor(), currItem->lineShade(), currItem->fillShade());
emit ItemGradient(currItem->GrType);
emit ItemTrans(currItem->fillTransparency(), currItem->lineTransparency());
*/
//emit HaveSel(PageItem::PolyLine);
}
Doc->appMode = modeNormal;
updateContents();
emit PaintingDone();
emit DocChanged();
return;
}
if ((Doc->EditClip) && (ClRe == -1) && (HaveSelRect))
{
double sc = Scale;
QPainter p;
p.begin(viewport());
ToView(&p);
p.scale(Scale, Scale);
p.setRasterOp(XorROP);
p.setPen(QPen(white, 1, DotLine, FlatCap, MiterJoin));
p.drawRect(Mxp, Myp, SeRx-Mxp, SeRy-Myp);
p.end();
if(Mxp > SeRx)
{
double tmp=SeRx;
SeRx=static_cast<int>(Mxp);
Mxp=static_cast<int>(tmp);
}
if(Myp > SeRy)
{
double tmp=SeRy;
SeRy=static_cast<int>(Myp);
Myp=static_cast<int>(tmp);
}
currItem = Doc->m_Selection->itemAt(0);
SelNode.clear();
QRect Sele = QRect(static_cast<int>(Mxp*sc), static_cast<int>(Myp*sc), static_cast<int>((SeRx-Mxp)*sc), static_cast<int>((SeRy-Myp)*sc));
FPointArray Clip;
if (EditContour)
Clip = currItem->ContourLine;
else
Clip = currItem->PoLine;
for (uint a = 0; a < Clip.size(); ++a)
{
if (Clip.point(a).x() > 900000)
continue;
p.begin(viewport());
Transform(currItem, &p);
QPoint npf = p.xForm(Clip.pointQ(a));
p.end();
if ((Sele.contains(npf)) && ((a == 0) || (((a-2) % 4) == 0)))
{
ClRe = a;
SelNode.append(a);
emit ClipPo(Clip.point(a).x(), Clip.point(a).y());
}
}
HaveSelRect = false;
if (EditContour)
MarkClip(currItem, currItem->ContourLine, true);
else
MarkClip(currItem, currItem->PoLine, true);
if (oldClip) // is there the old clip stored for the undo action
{
FPointArray newClip(isContourLine ? currItem->ContourLine : currItem->PoLine);
if (*oldClip != newClip)
{
QString name = isContourLine ? Um::EditContour : Um::EditShape;
ItemState<QPair<FPointArray, FPointArray> > *state =
new ItemState<QPair<FPointArray, FPointArray> >(name);
state->set("EDIT_SHAPE_OR_CONTOUR", "edit_shape_or_contour");
state->set("IS_CONTOUR", isContourLine);
state->setItem(QPair<FPointArray, FPointArray>(*oldClip, newClip));
state->set("OLD_X", oldItemX);
state->set("OLD_Y", oldItemY);
state->set("NEW_X", currItem->xPos());
state->set("NEW_Y", currItem->yPos());
undoManager->action(currItem, state);
undoManager->commit();
}
else
undoManager->cancelTransaction();
delete oldClip;
oldClip = 0;
}
return;
}
/* if (moveTimerElapsed() && (Doc->EditClip) && (SegP1 == -1) && (SegP2 == -1))
{
currItem = Doc->m_Selection->itemAt(0);
if (operItemMoving)
{
currItem->OldB2 = currItem->width();
currItem->OldH2 = currItem->height();
double nx = m->x()/Scale + Doc->minCanvasCoordinate.x();
double ny = m->y()/Scale + Doc->minCanvasCoordinate.y();
if (!ApplyGuides(&nx, &ny))
{
FPoint npg(ApplyGridF(FPoint(nx, ny)));
nx = npg.x();
ny = npg.y();
}
FPoint np(nx, ny, currItem->xPos(), currItem->yPos(), currItem->rotation(), 1, 1, true);
MoveClipPoint(currItem, np);
}
AdjustItemSize(currItem);
emit DocChanged();
updateContents();
operItemMoving = false;
return;
}
if (moveTimerElapsed() && (Doc->EditClip) && (SegP1 != -1) && (SegP2 != -1)) */
if (moveTimerElapsed() && (Doc->EditClip))
{
SegP1 = -1;
SegP2 = -1;
currItem = Doc->m_Selection->itemAt(0);
operItemMoving = false;
double xposOrig = currItem->xPos();
double yposOrig = currItem->yPos();
ItemState<QPair<FPointArray, FPointArray> > *state;
if (oldClip) // is there the old clip stored for the undo action
{
FPointArray newClip(isContourLine ? currItem->ContourLine : currItem->PoLine);
if (*oldClip != newClip)
{
QString name = isContourLine ? Um::EditContour : Um::EditShape;
state = new ItemState<QPair<FPointArray, FPointArray> >(name);
state->set("EDIT_SHAPE_OR_CONTOUR", "edit_shape_or_contour");
state->set("IS_CONTOUR", isContourLine);
state->setItem(QPair<FPointArray, FPointArray>(*oldClip, newClip));
undoManager->setUndoEnabled(false);
}
else
{
delete oldClip;
oldClip = 0;
undoManager->cancelTransaction();
}
}
AdjustItemSize(currItem);
if (!EditContour)
currItem->ContourLine.translate(xposOrig - currItem->xPos(), yposOrig - currItem->yPos());
emit DocChanged();
updateContents();
if (oldClip)
{
state->set("OLD_X", oldItemX);
state->set("OLD_Y", oldItemY);
state->set("NEW_X", currItem->xPos());
state->set("NEW_Y", currItem->yPos());
undoManager->setUndoEnabled(true);
undoManager->action(currItem, state);
undoManager->commit();
delete oldClip;
oldClip = 0;
}
return;
}
if ((!GetItem(&currItem)) && (m->button() == RightButton) && (!Doc->DragP) && (Doc->appMode == modeNormal))
{
QPopupMenu *pmen = new QPopupMenu();
if (ScMW->Buffer2.startsWith("<SCRIBUSELEM"))
{
Mxp = m->x();
Myp = m->y();
pmen->insertItem( tr("&Paste") , this, SLOT(PasteToPage()));
pmen->insertSeparator();
}
setObjectUndoMode();
ScMW->scrActions["editUndoAction"]->addTo(pmen);
ScMW->scrActions["editRedoAction"]->addTo(pmen);
pmen->insertSeparator();
ScMW->scrActions["viewShowMargins"]->addTo(pmen);
ScMW->scrActions["viewShowFrames"]->addTo(pmen);
ScMW->scrActions["viewShowImages"]->addTo(pmen);
ScMW->scrActions["viewShowGrid"]->addTo(pmen);
ScMW->scrActions["viewShowGuides"]->addTo(pmen);
ScMW->scrActions["viewShowBaseline"]->addTo(pmen);
ScMW->scrActions["viewShowTextChain"]->addTo(pmen);
ScMW->scrActions["viewRulerMode"]->addTo(pmen);
pmen->insertSeparator();
// pmen->insertItem( tr("Unit"), unitSwitcher);
// pmen->insertSeparator();
ScMW->scrActions["viewSnapToGrid"]->addTo(pmen);
ScMW->scrActions["viewSnapToGuides"]->addTo(pmen);
pmen->insertSeparator();
ScMW->scrActions["pageApplyMasterPage"]->addTo(pmen);
ScMW->scrActions["pageManageGuides"]->addTo(pmen);
ScMW->scrActions["pageManageMargins"]->addTo(pmen);
pmen->exec(QCursor::pos());
setGlobalUndoMode();
delete pmen;
pmen=NULL;
return;
}
if ((Doc->appMode != modeMagnifier) && (!Doc->EditClip) && (Doc->appMode != modeDrawBezierLine))
{
if ((GetItem(&currItem)) && (m->button() == RightButton) && (!Doc->DragP))
{
QPopupMenu *pmen = new QPopupMenu();
QPopupMenu *pmen2 = new QPopupMenu();
pmen3 = new QPopupMenu();
qApp->setOverrideCursor(QCursor(ArrowCursor), true);
QPopupMenu *pmen4 = new QPopupMenu();
QPopupMenu *pmenEditContents = new QPopupMenu();
QPopupMenu *pmenLevel = new QPopupMenu();
QPopupMenu *pmenPDF = new QPopupMenu();
pmenResolution = new QPopupMenu();
Q_CHECK_PTR(pmen);
Q_CHECK_PTR(pmen2);
Q_CHECK_PTR(pmen3);
Q_CHECK_PTR(pmen4);
Q_CHECK_PTR(pmenEditContents);
Q_CHECK_PTR(pmenLevel);
Q_CHECK_PTR(pmenPDF);
setObjectUndoMode();
if ((currItem->itemType() == PageItem::TextFrame) || (currItem->itemType() == PageItem::ImageFrame) || (currItem->itemType() == PageItem::PathText))
{
QButtonGroup *InfoGroup = new QButtonGroup( this, "InfoGroup" );
InfoGroup->setFrameShape( QButtonGroup::NoFrame );
InfoGroup->setFrameShadow( QButtonGroup::Plain );
InfoGroup->setTitle("");
InfoGroup->setExclusive( true );
InfoGroup->setColumnLayout(0, Qt::Vertical );
InfoGroup->layout()->setSpacing( 0 );
InfoGroup->layout()->setMargin( 0 );
QGridLayout *InfoGroupLayout = new QGridLayout( InfoGroup->layout() );
InfoGroupLayout->setAlignment( Qt::AlignTop );
InfoGroupLayout->setSpacing( 2 );
InfoGroupLayout->setMargin( 0 );
QString txtC, txtC2;
QLabel *InfoT = new QLabel(InfoGroup, "ct");
QLabel *ParCT = new QLabel(InfoGroup, "pt");
QLabel *ParC = new QLabel(InfoGroup, "pc");
QLabel *WordCT = new QLabel(InfoGroup, "wt");
QLabel *WordC = new QLabel(InfoGroup, "wc");
QLabel *CharCT = new QLabel(InfoGroup, "ct");
QLabel *CharC = new QLabel(InfoGroup, "cc");
QLabel *ColCT = new QLabel(InfoGroup, "ct");
QLabel *ColC = new QLabel(InfoGroup, "cc");
QLabel *PrintCT = new QLabel(InfoGroup, "nt"); // <a.l.e>
QLabel *PrintC = new QLabel(InfoGroup, "nc"); // </a.l.e>
if (currItem->itemType() == PageItem::ImageFrame)
{
QFileInfo fi = QFileInfo(currItem->Pfile);
InfoT->setText( tr("Image"));
InfoGroupLayout->addMultiCellWidget( InfoT, 0, 0, 0, 1, Qt::AlignCenter );
ParCT->setText( tr("File: "));
InfoGroupLayout->addWidget( ParCT, 1, 0, Qt::AlignRight );
ParC->setText(fi.fileName());
InfoGroupLayout->addWidget( ParC, 1, 1 );
WordCT->setText( tr("Original PPI: "));
InfoGroupLayout->addWidget( WordCT, 2, 0, Qt::AlignRight );
WordC->setText(txtC.setNum(qRound(currItem->pixm.imgInfo.xres))+" x "+txtC2.setNum(qRound(currItem->pixm.imgInfo.yres)));
InfoGroupLayout->addWidget( WordC, 2, 1 );
CharCT->setText( tr("Actual PPI: "));
InfoGroupLayout->addWidget( CharCT, 3, 0, Qt::AlignRight );
CharC->setText(txtC.setNum(qRound(72.0 / currItem->imageXScale()))+" x "+
txtC2.setNum(qRound(72.0 / currItem->imageYScale())));
InfoGroupLayout->addWidget( CharC, 3, 1 );
ColCT->setText( tr("Colorspace: "));
ColCT->show();
InfoGroupLayout->addWidget( ColCT, 4, 0, Qt::AlignRight );
QString cSpace;
QString ext = fi.extension(false).lower();
if ((ext == "pdf") || (ext == "eps") || (ext == "ps"))
cSpace = tr("Unknown");
else
{
switch (currItem->pixm.imgInfo.colorspace)
{
case 0:
cSpace = tr("RGB");
break;
case 1:
cSpace = tr("CMYK");
break;
case 2:
cSpace = tr("Grayscale");
break;
}
}
ColC->setText(cSpace);
ColC->show();
InfoGroupLayout->addWidget( ColC, 4, 1 );
}
if ((currItem->itemType() == PageItem::TextFrame) || (currItem->itemType() == PageItem::PathText))
{
int Parag = 0;
int Words = 0;
int Chara = 0;
int ParagN = 0;
int WordsN = 0;
int CharaN = 0;
ColC->hide();
ColCT->hide();
if (currItem->itemType() == PageItem::TextFrame)
{
if ((currItem->NextBox != 0) || (currItem->BackBox != 0))
InfoT->setText( tr("Linked Text"));
else
InfoT->setText( tr("Text Frame"));
}
else
InfoT->setText( tr("Text on a Path"));
InfoGroupLayout->addMultiCellWidget( InfoT, 0, 0, 0, 1, Qt::AlignCenter );
WordAndPara(currItem, &Words, &Parag, &Chara, &WordsN, &ParagN, &CharaN);
ParCT->setText( tr("Paragraphs: "));
InfoGroupLayout->addWidget( ParCT, 1, 0, Qt::AlignRight );
if (ParagN != 0)
ParC->setText(txtC.setNum(Parag+ParagN)+" ("+txtC2.setNum(ParagN)+")");
else
ParC->setText(txtC.setNum(Parag));
InfoGroupLayout->addWidget( ParC, 1, 1 );
WordCT->setText( tr("Words: "));
InfoGroupLayout->addWidget( WordCT, 2, 0, Qt::AlignRight );
if (WordsN != 0)
WordC->setText(txtC.setNum(Words+WordsN)+" ("+txtC2.setNum(WordsN)+")");
else
WordC->setText(txtC.setNum(Words));
InfoGroupLayout->addWidget( WordC, 2, 1 );
CharCT->setText( tr("Chars: "));
InfoGroupLayout->addWidget( CharCT, 3, 0, Qt::AlignRight );
if (CharaN != 0)
CharC->setText(txtC.setNum(Chara+CharaN)+" ("+txtC2.setNum(CharaN)+")");
else
CharC->setText(txtC.setNum(Chara));
InfoGroupLayout->addWidget( CharC, 3, 1 );
}
int row = InfoGroupLayout->numRows(); // <a.l.e>
PrintCT->setText( tr("Export: "));
InfoGroupLayout->addWidget( PrintCT, row, 0, Qt::AlignRight );
if (currItem->printEnabled())
PrintC->setText( tr("Enabled"));
else
PrintC->setText( tr("Disabled"));
InfoGroupLayout->addWidget( PrintC, row, 1 ); // </a.l.e>
pmen4->insertItem(InfoGroup);
if ((currItem->itemType() == PageItem::ImageFrame) && (currItem->pixm.imgInfo.exifDataValid))
ScMW->scrActions["itemImageInfo"]->addTo(pmen4);
pmen->insertItem( tr("In&fo"), pmen4);
}
pmen->insertSeparator();
ScMW->scrActions["editUndoAction"]->addTo(pmen);
ScMW->scrActions["editRedoAction"]->addTo(pmen);
if (currItem->itemType() == PageItem::ImageFrame ||
currItem->itemType() == PageItem::TextFrame ||
currItem->itemType() == PageItem::PathText)
{
pmen->insertSeparator();
if (currItem->itemType() == PageItem::ImageFrame)
{
ScMW->scrActions["fileImportImage"]->addTo(pmen);
ScMW->scrActions["itemImageIsVisible"]->addTo(pmen);
pmen->insertItem( tr("Preview Settings"), pmenResolution);
ScMW->scrActions["itemPreviewLow"]->addTo(pmenResolution);
ScMW->scrActions["itemPreviewNormal"]->addTo(pmenResolution);
ScMW->scrActions["itemPreviewFull"]->addTo(pmenResolution);
if ((currItem->PicAvail) && (currItem->pixm.imgInfo.valid))
ScMW->scrActions["itemExtendedImageProperties"]->addTo(pmen);
if (currItem->PicAvail && currItem->isRaster)
{
ScMW->scrActions["styleImageEffects"]->addTo(pmen);
ScMW->scrActions["editEditWithImageEditor"]->addTo(pmen);
}
if (currItem->PicAvail)
ScMW->scrActions["itemUpdateImage"]->addTo(pmen);
if ((currItem->PicAvail) && (!currItem->isTableItem))
ScMW->scrActions["itemAdjustFrameToImage"]->addTo(pmen);
}
if (currItem->itemType() == PageItem::TextFrame)
{
ScMW->scrActions["fileImportText"]->addTo(pmen);
ScMW->scrActions["fileImportAppendText"]->addTo(pmen);
ScMW->scrActions["toolsEditWithStoryEditor"]->addTo(pmen);
ScMW->scrActions["insertSampleText"]->addTo(pmen);
}
if (currItem->itemType() == PageItem::PathText)
ScMW->scrActions["toolsEditWithStoryEditor"]->addTo(pmen);
}
pmen->insertSeparator();
ScMW->scrActions["itemAttributes"]->addTo(pmen);
if (currItem->itemType() == PageItem::TextFrame)
{
if (Doc->currentPage->PageNam.isEmpty())
{
ScMW->scrActions["itemPDFIsAnnotation"]->addTo(pmenPDF);
ScMW->scrActions["itemPDFIsBookmark"]->addTo(pmenPDF);
if (currItem->isAnnotation())
{
if ((currItem->annotation().Type() == 0) || (currItem->annotation().Type() == 1) || (currItem->annotation().Type() > 9))
ScMW->scrActions["itemPDFAnnotationProps"]->addTo(pmenPDF);
else
ScMW->scrActions["itemPDFFieldProps"]->addTo(pmenPDF);
}
}
pmen->insertItem( tr("&PDF Options"), pmenPDF);
}
pmen->insertSeparator();
ScMW->scrActions["itemLock"]->addTo(pmen);
ScMW->scrActions["itemLockSize"]->addTo(pmen);
if (!currItem->isSingleSel)
{
ScMW->scrActions["itemSendToScrapbook"]->addTo(pmen);
if (Doc->layerCount() > 1)
{
QMap<int,int> layerMap;
for (QValueList<Layer>::iterator it = Doc->Layers.begin(); it != Doc->Layers.end(); ++it)
layerMap.insert((*it).Level, (*it).LNr);
int i=layerMap.count()-1;
while (i>=0)
{
if (Doc->layerLocked(layerMap[i]))
ScMW->scrLayersActions[QString::number(layerMap[i])]->setEnabled(false);
else
ScMW->scrLayersActions[QString::number(layerMap[i])]->setEnabled(true);
ScMW->scrLayersActions[QString::number(layerMap[i--])]->addTo(pmen3);
}
pmen->insertItem( tr("Send to La&yer"), pmen3);
}
}
if (Doc->m_Selection->count() > 1)
{
bool isGroup = true;
int firstElem = -1;
if (currItem->Groups.count() != 0)
firstElem = currItem->Groups.top();
for (uint bx = 0; bx < Doc->m_Selection->count(); ++bx)
{
if (Doc->m_Selection->itemAt(bx)->Groups.count() != 0)
{
if (Doc->m_Selection->itemAt(bx)->Groups.top() != firstElem)
isGroup = false;
}
else
isGroup = false;
}
if (!isGroup)
ScMW->scrActions["itemGroup"]->addTo(pmen);
}
if (currItem->Groups.count() != 0)
ScMW->scrActions["itemUngroup"]->addTo(pmen);
if (!currItem->locked())
{
if ((!currItem->isTableItem) && (!currItem->isSingleSel))
{
pmen->insertItem( tr("Le&vel"), pmenLevel);
ScMW->scrActions["itemRaiseToTop"]->addTo(pmenLevel);
ScMW->scrActions["itemRaise"]->addTo(pmenLevel);
ScMW->scrActions["itemLower"]->addTo(pmenLevel);
ScMW->scrActions["itemLowerToBottom"]->addTo(pmenLevel);
}
}
if (Doc->appMode != modeEdit) //Create convertTo Menu
{
ScMW->scrActions["itemConvertToBezierCurve"]->addTo(pmen2);
ScMW->scrActions["itemConvertToImageFrame"]->addTo(pmen2);
ScMW->scrActions["itemConvertToOutlines"]->addTo(pmen2);
ScMW->scrActions["itemConvertToPolygon"]->addTo(pmen2);
ScMW->scrActions["itemConvertToTextFrame"]->addTo(pmen2);
ScMW->scrActions["itemConvertToBezierCurve"]->setEnabled(false);
ScMW->scrActions["itemConvertToImageFrame"]->setEnabled(false);
ScMW->scrActions["itemConvertToOutlines"]->setEnabled(false);
ScMW->scrActions["itemConvertToPolygon"]->setEnabled(false);
ScMW->scrActions["itemConvertToTextFrame"]->setEnabled(false);
if ((currItem->itemType() == PageItem::TextFrame) || (currItem->itemType() == PageItem::PathText))
{
if (currItem->itemType() == PageItem::PathText)
ScMW->scrActions["itemConvertToOutlines"]->setEnabled(true);
else
{
if (currItem->isTableItem)
ScMW->scrActions["itemConvertToImageFrame"]->setEnabled(true);
if ((!currItem->isTableItem) && (currItem->BackBox == 0) && (currItem->NextBox == 0))
{
ScMW->scrActions["itemConvertToImageFrame"]->setEnabled(true);
ScMW->scrActions["itemConvertToOutlines"]->setEnabled(true);
ScMW->scrActions["itemConvertToPolygon"]->setEnabled(true);
}
}
}
if (currItem->itemType() == PageItem::ImageFrame)
{
ScMW->scrActions["itemConvertToTextFrame"]->setEnabled(true);
if (!currItem->isTableItem)
ScMW->scrActions["itemConvertToPolygon"]->setEnabled(true);
}
if (currItem->itemType() == PageItem::Polygon)
{
ScMW->scrActions["itemConvertToBezierCurve"]->setEnabled(true);
ScMW->scrActions["itemConvertToImageFrame"]->setEnabled(true);
ScMW->scrActions["itemConvertToTextFrame"]->setEnabled(true);
}
pmen->insertItem( tr("Conve&rt to"), pmen2);
}
pmen->insertSeparator();
if (!currItem->locked() && !(currItem->isTableItem && currItem->isSingleSel))
ScMW->scrActions["editCut"]->addTo(pmen);
if (!(currItem->isTableItem && currItem->isSingleSel))
ScMW->scrActions["editCopy"]->addTo(pmen);
if ((Doc->appMode == modeEdit) && (ScMW->Buffer2.startsWith("<SCRIBUSTEXT")) && (currItem->itemType() == PageItem::TextFrame))
ScMW->scrActions["editPaste"]->addTo(pmen);
if (!currItem->locked() && (Doc->appMode != modeEdit) && (!(currItem->isTableItem && currItem->isSingleSel)))
pmen->insertItem( tr("&Delete"), Doc, SLOT(itemSelection_DeleteItem()));
if ((currItem->itemType() == PageItem::ImageFrame) || (currItem->itemType() == PageItem::TextFrame))
{
pmen->insertItem( tr("Contents"), pmenEditContents);
if (currItem->itemType() == PageItem::ImageFrame)
{
ScMW->scrActions["editCopyContents"]->addTo(pmenEditContents);
ScMW->scrActions["editPasteContents"]->addTo(pmenEditContents);
ScMW->scrActions["editPasteContentsAbs"]->addTo(pmenEditContents);
}
ScMW->scrActions["editClearContents"]->addTo(pmenEditContents);
}
pmen->insertSeparator();
ScMW->scrActions["toolsProperties"]->addTo(pmen);
pmen->exec(QCursor::pos());
setGlobalUndoMode();
delete pmen;
delete pmen2;
delete pmen3;
delete pmen4;
delete pmenEditContents;
delete pmenLevel;
delete pmenPDF;
delete pmenResolution;
pmen=NULL;
pmen2=NULL;
pmen3=NULL;
pmen4=NULL;
pmenLevel=NULL;
pmenPDF=NULL;
pmenResolution=NULL;
}
if ((Doc->appMode == modeLinkFrames) || (Doc->appMode == modeUnlinkFrames))
{
updateContents();
if (Doc->ElemToLink != 0)
return;
else
{
Doc->appMode = modeNormal;
qApp->setOverrideCursor(QCursor(ArrowCursor), true);
emit PaintingDone();
return;
}
}
if (Doc->appMode == modeDrawRegularPolygon)
{
currItem = Doc->m_Selection->itemAt(0);
FPoint np1(m->x() / Scale + Doc->minCanvasCoordinate.x(), m->y() / Scale + Doc->minCanvasCoordinate.y());
np1 = ApplyGridF(np1);
double w = np1.x() - currItem->xPos();
double h = np1.y()- currItem->yPos();
currItem->setWidthHeight(fabs(w), fabs(h));
if (w < 0.0)
currItem->setXPos(currItem->xPos() - fabs(w), true);
if (h < 0.0)
currItem->setYPos(currItem->yPos() - fabs(h), true);
// currItem->setWidthHeight(np1.x() - currItem->xPos(), np1.y()- currItem->yPos());
FPointArray cli = RegularPolygonF(currItem->width(), currItem->height(), Doc->toolSettings.polyC, Doc->toolSettings.polyS, Doc->toolSettings.polyF, Doc->toolSettings.polyR);
FPoint np(cli.point(0));
currItem->PoLine.resize(2);
currItem->PoLine.setPoint(0, np);
currItem->PoLine.setPoint(1, np);
for (uint ax = 1; ax < cli.size(); ++ax)
{
np = FPoint(cli.point(ax));
currItem->PoLine.putPoints(currItem->PoLine.size(), 4, np.x(), np.y(), np.x(), np.y(), np.x(), np.y(), np.x(), np.y());
}
np = FPoint(cli.point(0));
currItem->PoLine.putPoints(currItem->PoLine.size(), 2, np.x(), np.y(), np.x(), np.y());
FPoint tp2(getMinClipF(&currItem->PoLine));
if ((tp2.x() > -1) || (tp2.y() > -1))
{
SizeItem(currItem->width() - tp2.x(), currItem->height() - tp2.y(), currItem->ItemNr, false, false, false);
}
FPoint tp(getMaxClipF(&currItem->PoLine));
SizeItem(tp.x(), tp.y(), currItem->ItemNr, false, false, false);
currItem->Clip = FlattenPath(currItem->PoLine, currItem->Segments);
AdjustItemSize(currItem);
currItem->ContourLine = currItem->PoLine.copy();
Doc->setRedrawBounding(currItem);
currItem->OwnPage = Doc->OnPage(currItem);
currItem->OldB2 = currItem->width();
currItem->OldH2 = currItem->height();
updateContents();
}
if (Doc->appMode == modeDrawLine)
{
currItem = Doc->m_Selection->itemAt(0);
QPainter p;
p.begin(viewport());
Transform(currItem, &p);
QPoint np = p.xFormDev(m->pos());
p.end();
np += QPoint(qRound(Doc->minCanvasCoordinate.x()), qRound(Doc->minCanvasCoordinate.y()));
np = ApplyGrid(np);
double newRot=xy2Deg(np.x(), np.y());
//Constrain rotation angle, when the mouse is released from drawing a line
if (m->state() & ControlButton)
newRot=constrainAngle(newRot);
currItem->setRotation(newRot);
currItem->setWidthHeight(sqrt(pow(np.x(),2.0)+pow(np.y(),2.0)), 1.0);
currItem->Sizing = false;
currItem->updateClip();
Doc->setRedrawBounding(currItem);
currItem->OwnPage = Doc->OnPage(currItem);
updateContents();
}
if (moveTimerElapsed() && (GetItem(&currItem)))
{
if (Doc->m_Selection->isMultipleSelection())
{
if (operItemResizing)
{
double gx, gy, gh, gw, nx, ny, scx, scy;
getGroupRect(&gx, &gy, &gw, &gh);
double sc = Scale;
scx = sc;
scy = sc;
QPoint np2;
double newXF = m->x()/sc + Doc->minCanvasCoordinate.x();
double newYF = m->y()/sc + Doc->minCanvasCoordinate.y();
if (m->state() & ControlButton)
np2 = QPoint(qRound(newXF), qRound(gy+(gh * ((newXF-gx) / gw))));
else
np2 = QPoint(qRound(newXF), qRound(newYF));
nx = np2.x();
ny = np2.y();
if (!ApplyGuides(&nx, &ny))
{
np2 = ApplyGrid(np2);
nx = np2.x();
ny = np2.y();
}
switch (frameResizeHandle)
{
case 1:
scy = fabs(ny-gy) / gh;
scx = fabs(nx-gx) / gw;
break;
case 2:
scx = fabs(nx-(gx+gw)) / gw;
scy = fabs(ny-(gy+gh)) / gh;
break;
case 3:
scx = fabs(nx-gx) / gw;
scy = fabs(ny-(gy+gh)) / gh;
break;
case 4:
scx = fabs(nx-(gx+gw)) / gw;
scy = fabs(ny-gy) / gh;
break;
case 5:
scx = 1.0;
scy = fabs(ny-gy) / gh;
break;
case 6:
scx = fabs(nx-gx) / gw;
scy = 1.0;
break;
case 7:
scx = fabs(nx-(gx+gw)) / gw;
scy = 1.0;
break;
case 8:
scx = 1.0;
scy = fabs(ny-(gy+gh)) / gh;
break;
}
RotMode = Doc->RotMode;
Doc->RotMode = 0;
//CB #3012 only scale text in a group if alt is pressed
if ((currItem->itemType() == PageItem::TextFrame) && (m->state() & AltButton))
scaleGroup(scx, scy, true);
else
scaleGroup(scx, scy, false);
if ((frameResizeHandle == 3) || (frameResizeHandle == 8))
moveGroup(0, ny-gy);
if (frameResizeHandle == 2)
moveGroup(nx-gx, ny-gy);
if ((frameResizeHandle == 7) || (frameResizeHandle == 4))
moveGroup(nx-gx, 0);
Doc->RotMode = RotMode;
evSpon = false;
updateContents();
emit DocChanged();
}
}
else
{
//Where a single frame resize stops when the mouse buttno is released
//FIXME: reduce code!
if (currItem->Sizing)
{
FPoint npx;
double nx = m->pos().x()/Scale + Doc->minCanvasCoordinate.x();
double ny = m->pos().y()/Scale + Doc->minCanvasCoordinate.y();
if (Doc->SnapGuides)
{
ApplyGuides(&nx, &ny);
npx = FPoint(nx, ny, currItem->xPos(), currItem->yPos(), currItem->rotation(), 1, 1, true);
}
else {
FPoint npg(ApplyGridF(FPoint(nx, ny)));
nx = npg.x();
ny = npg.y();
npx = FPoint(nx, ny, currItem->xPos(), currItem->yPos(), currItem->rotation(), 1, 1, true);
}
if ((frameResizeHandle == 1) && !(currItem->asLine()) && (Doc->SnapGuides))
SizeItem(npx.x(), npx.y(), currItem->ItemNr);
bool sav = Doc->SnapGuides;
Doc->SnapGuides = false;
if (UndoManager::undoEnabled())
{
undoManager->beginTransaction(currItem->getUName(), currItem->getUPixmap(),
Um::Resize, QString(Um::ResizeFromTo).arg(currItem->width()).arg(currItem->height()).arg(currItem->width() - npx.x()).arg(currItem->height() - npx.y()), Um::IResize);
}
switch (frameResizeHandle)
{
case 1:
if (!currItem->asLine())
{
if (currItem->isTableItem)
{
double dist;
if (currItem->LeftLink != 0)
dist = npx.y() - currItem->LeftLink->height();
else if (currItem->RightLink != 0)
dist = npx.y() - currItem->RightLink->height();
else
dist = npx.y() - currItem->height();
PageItem* bb2;
PageItem* bb = currItem;
while (bb->LeftLink != 0)
{
bb = bb->LeftLink;
}
while (bb->RightLink != 0)
{
bb2 = bb;
while (bb2->BottomLink != 0)
{
MoveRotated(bb2->BottomLink, FPoint(0, dist));
bb2 = bb2->BottomLink;
}
if (bb != currItem)
MoveSizeItem(FPoint(0, 0), FPoint(0, -dist), bb->ItemNr);
bb = bb->RightLink;
}
bb2 = bb;
while (bb2->BottomLink != 0)
{
MoveRotated(bb2->BottomLink, FPoint(0, dist));
bb2 = bb2->BottomLink;
}
if (bb != currItem)
MoveSizeItem(FPoint(0, 0), FPoint(0, -dist), bb->ItemNr);
bb = currItem;
if (currItem->TopLink != 0)
dist = npx.x() - currItem->TopLink->width();
else if (currItem->BottomLink != 0)
dist = npx.x() - currItem->BottomLink->width();
else
dist = npx.x() - currItem->width();
while (bb->TopLink != 0)
{
bb = bb->TopLink;
}
while (bb->BottomLink != 0)
{
bb2 = bb;
while (bb2->RightLink != 0)
{
MoveRotated(bb2->RightLink, FPoint(dist, 0));
bb2 = bb2->RightLink;
}
if (bb != currItem)
MoveSizeItem(FPoint(0, 0), FPoint(-dist, 0), bb->ItemNr);
bb = bb->BottomLink;
}
bb2 = bb;
while (bb2->RightLink != 0)
{
MoveRotated(bb2->RightLink, FPoint(dist, 0));
bb2 = bb2->RightLink;
}
if (bb != currItem)
MoveSizeItem(FPoint(0, 0), FPoint(-dist, 0), bb->ItemNr);
}
//<<Swap location if width/height is <0
if (currItem->width()<0)
{
currItem->setWidth(-currItem->width());
currItem->setXPos(currItem->xPos()-currItem->width());
}
if (currItem->height()<0)
{
currItem->setHeight(-currItem->height());
currItem->setYPos(currItem->yPos()-currItem->height());
}
//>>
if (currItem->imageFlippedH())
currItem->moveImageInFrame(-(currItem->width() - currItem->OldB2)/currItem->imageXScale(), 0);
if (currItem->imageFlippedV())
currItem->moveImageInFrame(0, -(currItem->height() - currItem->OldH2)/currItem->imageYScale());
}
else
{
if (sav)
{
double nx = m->pos().x()/Scale + Doc->minCanvasCoordinate.x();
double ny = m->pos().y()/Scale + Doc->minCanvasCoordinate.y();
if (Doc->useRaster)
{
FPoint ra(ApplyGridF(FPoint(nx, ny)));
nx = ra.x();
ny = ra.y();
}
Doc->SnapGuides = sav;
ApplyGuides(&nx, &ny);
Doc->SnapGuides = false;
double r = atan2(ny - currItem->yPos(), nx - currItem->xPos())*(180.0/M_PI);
RotateItem(r, currItem->ItemNr);
double w = sqrt(pow(nx - currItem->xPos(), 2) + pow(ny - currItem->yPos(),2));
SizeItem(w, currItem->height(), currItem->ItemNr, true);
}
}
currItem->Sizing = false;
break;
case 2:
if (!currItem->asLine())
{
if (currItem->isTableItem)
{
PageItem* bb2;
PageItem* bb = currItem;
while (bb->TopLink != 0)
{
bb = bb->TopLink;
}
while (bb->BottomLink != 0)
{
bb2 = bb;
while (bb2->LeftLink != 0)
{
MoveRotated(bb2->LeftLink, FPoint(npx.x(), 0));
bb2 = bb2->LeftLink;
}
MoveSizeItem(FPoint(npx.x(), 0), FPoint(npx.x(), 0), bb->ItemNr);
bb = bb->BottomLink;
}
bb2 = bb;
while (bb2->LeftLink != 0)
{
MoveRotated(bb2->LeftLink, FPoint(npx.x(), 0));
bb2 = bb2->LeftLink;
}
MoveSizeItem(FPoint(npx.x(), 0), FPoint(npx.x(), 0), bb->ItemNr);
bb = currItem;
while (bb->LeftLink != 0)
{
bb = bb->LeftLink;
}
while (bb->RightLink != 0)
{
bb2 = bb;
while (bb2->TopLink != 0)
{
MoveRotated(bb2->TopLink, FPoint(0, npx.y()));
bb2 = bb2->TopLink;
}
MoveSizeItem(FPoint(0, npx.y()), FPoint(0, npx.y()), bb->ItemNr);
bb = bb->RightLink;
}
bb2 = bb;
while (bb2->TopLink != 0)
{
MoveRotated(bb2->TopLink, FPoint(0, npx.y()));
bb2 = bb2->TopLink;
}
MoveSizeItem(FPoint(0, npx.y()), FPoint(0, npx.y()), bb->ItemNr);
}
else
MoveSizeItem(npx, npx, currItem->ItemNr);
//<<Swap location if width/height is <0
if (currItem->width()<0)
{
currItem->setWidth(-currItem->width());
currItem->setXPos(currItem->xPos()-currItem->width());
}
if (currItem->height()<0)
{
currItem->setHeight(-currItem->height());
currItem->setYPos(currItem->yPos()-currItem->height());
}
//>>
currItem->Sizing = false;
if (!currItem->imageFlippedH())
{
currItem->moveImageInFrame((currItem->width() - currItem->OldB2)/currItem->imageXScale(), 0);
updateContents(currItem->getRedrawBounding(Scale));
}
if (!currItem->imageFlippedV())
{
currItem->moveImageInFrame(0, (currItem->height() - currItem->OldH2)/currItem->imageYScale());
updateContents(currItem->getRedrawBounding(Scale));
}
}
else
{
if (sav)
{
double nx = m->pos().x()/Scale + Doc->minCanvasCoordinate.x();
double ny = m->pos().y()/Scale + Doc->minCanvasCoordinate.y();
if (Doc->useRaster)
{
FPoint ra(ApplyGridF(FPoint(nx, ny)));
nx = ra.x();
ny = ra.y();
}
Doc->SnapGuides = sav;
ApplyGuides(&nx, &ny);
Doc->SnapGuides = false;
QWMatrix ma;
ma.translate(currItem->xPos(), currItem->yPos());
ma.rotate(currItem->rotation());
double mx = ma.m11() * currItem->width() + ma.m21() * currItem->height() + ma.dx();
double my = ma.m22() * currItem->height() + ma.m12() * currItem->width() + ma.dy();
double r = atan2(my-ny,mx-nx)*(180.0/M_PI);
double w = sqrt(pow(mx-nx,2)+pow(my-ny,2));
MoveItem(nx - currItem->xPos(), ny - currItem->yPos(), currItem, true);
SizeItem(w, currItem->height(), currItem->ItemNr, true);
RotateItem(r, currItem->ItemNr);
currItem->Sizing = false;
}
}
break;
case 3:
if (currItem->isTableItem)
{
double dist = npx.x() - currItem->width();
PageItem* bb2;
PageItem* bb = currItem;
while (bb->TopLink != 0)
{
bb = bb->TopLink;
}
while (bb->BottomLink != 0)
{
bb2 = bb;
while (bb2->RightLink != 0)
{
MoveRotated(bb2->RightLink, FPoint(dist, 0));
bb2 = bb2->RightLink;
}
MoveSizeItem(FPoint(0, 0), FPoint(-dist, 0), bb->ItemNr);
bb = bb->BottomLink;
}
bb2 = bb;
while (bb2->RightLink != 0)
{
MoveRotated(bb2->RightLink, FPoint(dist, 0));
bb2 = bb2->RightLink;
}
MoveSizeItem(FPoint(0, 0), FPoint(-dist, 0), bb->ItemNr);
bb = currItem;
while (bb->LeftLink != 0)
{
bb = bb->LeftLink;
}
while (bb->RightLink != 0)
{
bb2 = bb;
while (bb2->TopLink != 0)
{
MoveRotated(bb2->TopLink, FPoint(0, npx.y()));
bb2 = bb2->TopLink;
}
MoveSizeItem(FPoint(0, npx.y()), FPoint(0, npx.y()), bb->ItemNr);
bb = bb->RightLink;
}
bb2 = bb;
while (bb2->TopLink != 0)
{
MoveRotated(bb2->TopLink, FPoint(0, npx.y()));
bb2 = bb2->TopLink;
}
MoveSizeItem(FPoint(0, npx.y()), FPoint(0, npx.y()), bb->ItemNr);
}
else
MoveSizeItem(FPoint(0, npx.y()), FPoint(currItem->width() - npx.x(), npx.y()), currItem->ItemNr);
//<<Swap location if width/height is <0
if (currItem->width()<0)
{
currItem->setWidth(-currItem->width());
currItem->setXPos(currItem->xPos()-currItem->width());
}
if (currItem->height()<0)
{
currItem->setHeight(-currItem->height());
currItem->setYPos(currItem->yPos()-currItem->height());
}
//>>
currItem->Sizing = false;
if (currItem->imageFlippedH())
currItem->moveImageInFrame(-(currItem->width() - currItem->OldB2)/currItem->imageXScale(), 0);
if (!currItem->imageFlippedV())
currItem->moveImageInFrame(0, (currItem->height() - currItem->OldH2)/currItem->imageYScale());
break;
case 4:
if (currItem->isTableItem)
{
double dist = npx.y() - currItem->height();
PageItem* bb2;
PageItem* bb = currItem;
while (bb->LeftLink != 0)
{
bb = bb->LeftLink;
}
while (bb->RightLink != 0)
{
bb2 = bb;
while (bb2->BottomLink != 0)
{
MoveRotated(bb2->BottomLink, FPoint(0, dist));
bb2 = bb2->BottomLink;
}
MoveSizeItem(FPoint(0, 0), FPoint(0, -dist), bb->ItemNr);
bb = bb->RightLink;
}
bb2 = bb;
while (bb2->BottomLink != 0)
{
MoveRotated(bb2->BottomLink, FPoint(0, dist));
bb2 = bb2->BottomLink;
}
MoveSizeItem(FPoint(0, 0), FPoint(0, -dist), bb->ItemNr);
bb = currItem;
while (bb->TopLink != 0)
{
bb = bb->TopLink;
}
while (bb->BottomLink != 0)
{
bb2 = bb;
while (bb2->LeftLink != 0)
{
MoveRotated(bb2->LeftLink, FPoint(npx.x(), 0));
bb2 = bb2->LeftLink;
}
MoveSizeItem(FPoint(npx.x(), 0), FPoint(npx.x(), 0), bb->ItemNr);
bb = bb->BottomLink;
}
bb2 = bb;
while (bb2->LeftLink != 0)
{
MoveRotated(bb2->LeftLink, FPoint(npx.x(), 0));
bb2 = bb2->LeftLink;
}
MoveSizeItem(FPoint(npx.x(), 0), FPoint(npx.x(), 0), bb->ItemNr);
}
else
MoveSizeItem(FPoint(npx.x(), 0), FPoint(npx.x(), currItem->height() - npx.y()), currItem->ItemNr);
//<<Swap location if width/height is <0
if (currItem->width()<0)
{
currItem->setWidth(-currItem->width());
currItem->setXPos(currItem->xPos()-currItem->width());
}
if (currItem->height()<0)
{
currItem->setHeight(-currItem->height());
currItem->setYPos(currItem->yPos()-currItem->height());
}
//>>
currItem->Sizing = false;
if (!currItem->imageFlippedH())
currItem->moveImageInFrame((currItem->width() - currItem->OldB2)/currItem->imageXScale(), 0);
if (currItem->imageFlippedV())
currItem->moveImageInFrame(0, -(currItem->height() - currItem->OldH2)/currItem->imageYScale());
break;
case 5:
if (currItem->isTableItem)
{
double dist = npx.y() - currItem->height();
PageItem* bb2;
PageItem* bb = currItem;
while (bb->LeftLink != 0)
{
bb = bb->LeftLink;
}
while (bb->RightLink != 0)
{
bb2 = bb;
while (bb2->BottomLink != 0)
{
MoveRotated(bb2->BottomLink, FPoint(0, dist));
bb2 = bb2->BottomLink;
}
MoveSizeItem(FPoint(0, 0), FPoint(0, -dist), bb->ItemNr);
bb = bb->RightLink;
}
bb2 = bb;
while (bb2->BottomLink != 0)
{
MoveRotated(bb2->BottomLink, FPoint(0, dist));
bb2 = bb2->BottomLink;
}
MoveSizeItem(FPoint(0, 0), FPoint(0, -dist), bb->ItemNr);
}
else
MoveSizeItem(FPoint(0, 0), FPoint(0, currItem->height() - npx.y()), currItem->ItemNr);
if (currItem->imageFlippedV())
currItem->moveImageInFrame(0, -(currItem->height() - currItem->OldH2)/currItem->imageYScale());
//<<Swap location if width/height is <0
if (currItem->width()<0)
{
currItem->setWidth(-currItem->width());
currItem->setXPos(currItem->xPos()-currItem->width());
}
if (currItem->height()<0)
{
currItem->setHeight(-currItem->height());
currItem->setYPos(currItem->yPos()-currItem->height());
}
//>>
currItem->Sizing = false;
break;
case 6:
if (currItem->isTableItem)
{
double dist = npx.x() - currItem->width();
PageItem* bb2;
PageItem* bb = currItem;
while (bb->TopLink != 0)
{
bb = bb->TopLink;
}
while (bb->BottomLink != 0)
{
bb2 = bb;
while (bb2->RightLink != 0)
{
MoveRotated(bb2->RightLink, FPoint(dist, 0));
bb2 = bb2->RightLink;
}
MoveSizeItem(FPoint(0, 0), FPoint(-dist, 0), bb->ItemNr);
bb = bb->BottomLink;
}
bb2 = bb;
while (bb2->RightLink != 0)
{
MoveRotated(bb2->RightLink, FPoint(dist, 0));
bb2 = bb2->RightLink;
}
MoveSizeItem(FPoint(0, 0), FPoint(-dist, 0), bb->ItemNr);
}
else
MoveSizeItem(FPoint(0, 0), FPoint(currItem->width() - npx.x(), 0), currItem->ItemNr);
if (currItem->imageFlippedH())
currItem->moveImageInFrame(-(currItem->width() - currItem->OldB2)/currItem->imageXScale(), 0);
//<<Swap location if width/height is <0
if (currItem->width()<0)
{
currItem->setWidth(-currItem->width());
&