Subversion Repositories Scribus

Compare Revisions

Ignore whitespace Rev 24718 → Rev 24719

/trunk/Scribus/scribus/canvasmode_normal.cpp
757,7 → 757,7
QTransform p;
m_canvas->Transform(currItem, p);
QRect mpo = QRect(m->x() - m_doc->guidesPrefs().grabRadius, m->y() - m_doc->guidesPrefs().grabRadius, m_doc->guidesPrefs().grabRadius * 2, m_doc->guidesPrefs().grabRadius * 2);
if ((QRegion(p.map(QPolygon(QRect(-3, -3, static_cast<int>(currItem->width() + 6), static_cast<int>(currItem->height() + 6))))).contains(mpo)))
if (QRegion(p.map(QPolygon(QRect(-3, -3, static_cast<int>(currItem->width() + 6), static_cast<int>(currItem->height() + 6))))).contains(mpo))
{
QRect tx = p.mapRect(QRect(0, 0, static_cast<int>(currItem->width()), static_cast<int>(currItem->height())));
if ((tx.intersects(mpo)) && (!currItem->locked()))
/trunk/Scribus/scribus/cmsettings.h
27,13 → 27,14
#ifndef CMSETTINGS_H
#define CMSETTINGS_H
 
#include <QString>
 
#include "scconfig.h"
#include "scribusapi.h"
#include <QString>
#include "colormgmt/sccolormgmtengine.h"
 
class ScribusDoc;
 
#include "colormgmt/sccolormgmtengine.h"
 
class SCRIBUS_API CMSettings
{
public:
90,7 → 91,7
ScColorTransform cmykGamutCheckTransform() const; //stdProofCMYKGCG
 
private:
ScribusDoc* m_Doc;
ScribusDoc* m_Doc {nullptr};
bool m_colorManagementAllowed {true};
bool m_softProofingAllowed {false};
bool m_useEmbeddedProfile {false};
/trunk/Scribus/scribus/documentchecker.cpp
61,7 → 61,7
drawGlyph(gc);
}
void drawLine(QPointF, QPointF) override { }
void drawRect(QRectF) override { }
void drawRect(const QRectF&) override { }
void drawObject(PageItem*) override { }
};
 
106,7 → 106,7
return (currDoc->hasPreflightErrors());
}
 
void DocumentChecker::checkPages(ScribusDoc *currDoc, struct CheckerPrefs checkerSettings)
void DocumentChecker::checkPages(ScribusDoc *currDoc, const CheckerPrefs& checkerSettings)
{
errorCodes pageError;
for (int i=0; i < currDoc->DocPages.count(); ++i )
144,7 → 144,7
}
}
 
void DocumentChecker::checkLayers(ScribusDoc *currDoc, struct CheckerPrefs checkerSettings)
void DocumentChecker::checkLayers(ScribusDoc *currDoc, const CheckerPrefs& checkerSettings)
{
errorCodes layerError;
int Lnr;
172,7 → 172,7
}
}
 
void DocumentChecker::checkItems(ScribusDoc *currDoc, struct CheckerPrefs checkerSettings)
void DocumentChecker::checkItems(ScribusDoc *currDoc, const CheckerPrefs& checkerSettings)
{
errorCodes itemError;
 
283,7 → 283,6
itemError.insert(ObjectNotOnPage, 0);
if (currItem->isImageFrame() && !currItem->isOSGFrame())
{
 
// check image vs. frame sizes
if (checkerSettings.checkPartFilledImageFrames && isPartFilledImageFrame(currItem))
{
/trunk/Scribus/scribus/documentchecker.h
40,9 → 40,9
//! Check the passed document for errors, return true on error found
static bool checkDocument(ScribusDoc *currDoc);
static bool checkDocument(ScribusDoc *currDoc, const QString& checkerProfile);
static void checkPages(ScribusDoc *currDoc, struct CheckerPrefs checkerSettings);
static void checkLayers(ScribusDoc *currDoc, struct CheckerPrefs checkerSettings);
static void checkItems(ScribusDoc *currDoc, struct CheckerPrefs checkerSettings);
static void checkPages(ScribusDoc *currDoc, const CheckerPrefs& checkerSettings);
static void checkLayers(ScribusDoc *currDoc, const CheckerPrefs& checkerSettings);
static void checkItems(ScribusDoc *currDoc, const CheckerPrefs& checkerSettings);
};
 
#endif
/trunk/Scribus/scribus/pdflib_core.cpp
477,7 → 477,7
return m_backBuffer + "BT\n" + m_glyphBuffer + "ET\n" + m_pathBuffer;
}
 
void drawRect(QRectF rect) override
void drawRect(const QRectF& rect) override
{
QTransform transform = matrix();
// transform.translate(x(), y());
/trunk/Scribus/scribus/plugins/export/svgexplugin/svgexplugin.cpp
1233,7 → 1233,7
m_elem.appendChild(path);
}
 
void drawRect(QRectF rect) override
void drawRect(const QRectF& rect) override
{
QTransform transform = matrix();
transform.translate(x(), y());
/trunk/Scribus/scribus/plugins/export/xpsexport/xpsexplugin.cpp
974,7 → 974,7
m_restart = true;
}
 
void drawRect(QRectF rect) override
void drawRect(const QRectF& rect) override
{
QTransform transform = matrix();
double rx = (x() + rect.x()) * m_xps->conversionFactor;
/trunk/Scribus/scribus/pslib.cpp
79,7 → 79,7
void drawGlyph(const GlyphCluster& gc) override;
void drawGlyphOutline(const GlyphCluster& gc, bool fill) override;
void drawLine(QPointF start, QPointF end) override;
void drawRect(QRectF rect) override;
void drawRect(const QRectF& rect) override;
void drawObject(PageItem* item) override;
 
private:
190,7 → 190,7
m_ps->PS_restore();
}
 
void PSPainter::drawRect(QRectF rect)
void PSPainter::drawRect(const QRectF& rect)
{
double h {0.0}, s {0.0}, v {0.0}, k {0.0};
m_ps->PS_save();
/trunk/Scribus/scribus/scpageoutput.cpp
37,30 → 37,14
#include "util_math.h"
#include "text/boxes.h"
 
 
MarksOptions::MarksOptions()
MarksOptions::MarksOptions(const PrintOptions& opt)
{
markLength = 20.0;
markOffset = 0.0;
BleedTop = 0.0;
BleedLeft = 0.0;
BleedRight = 0.0;
BleedBottom = 0.0;
cropMarks = false;
bleedMarks = false;
registrationMarks = false;
colorMarks = false;
docInfoMarks = false;
}
 
MarksOptions::MarksOptions(struct PrintOptions& opt)
{
markLength = opt.markLength;
markOffset = opt.markOffset;
BleedTop = opt.bleeds.top();
BleedLeft = opt.bleeds.left();
BleedRight = opt.bleeds.right();
BleedBottom = opt.bleeds.bottom();
bleedTop = opt.bleeds.top();
bleedLeft = opt.bleeds.left();
bleedRight = opt.bleeds.right();
bleedBottom = opt.bleeds.bottom();
cropMarks = opt.cropMarks;
bleedMarks = opt.bleedMarks;
registrationMarks = opt.registrationMarks;
77,7 → 61,7
m_useProfiles = useProfiles;
}
 
ScImage::RequestType ScPageOutput::translateImageModeToRequest(ScPainterExBase::ImageMode mode)
ScImage::RequestType ScPageOutput::translateImageModeToRequest(ScPainterExBase::ImageMode mode) const
{
ScImage::RequestType value = ScImage::RGBData;
if (mode == ScPainterExBase::cmykImages)
159,7 → 143,7
return;
if (!layer.isViewable || !layer.isPrintable)
return;
int docCurrPageNo = static_cast<int>(page->pageNr());
int currentPageNr = page->pageNr();
for (int it = 0; it < m_doc->Items->count(); ++it)
{
currItem = m_doc->Items->at(it);
167,7 → 151,7
continue;
if (!currItem->printEnabled())
continue;
if ((m_doc->masterPageMode()) && ((currItem->OwnPage != -1) && (currItem->OwnPage != docCurrPageNo)))
if ((m_doc->masterPageMode()) && ((currItem->OwnPage != -1) && (currItem->OwnPage != currentPageNr)))
continue;
if (!m_doc->masterPageMode() && !currItem->OnMasterPage.isEmpty())
{
254,10 → 238,10
else if (item->GrType == Gradient_4Colors)
{
painter->setFillMode(ScPainterExBase::Gradient);
FPoint pG1 = FPoint(0, 0);
FPoint pG2 = FPoint(item->width(), 0);
FPoint pG3 = FPoint(item->width(), item->height());
FPoint pG4 = FPoint(0, item->height());
FPoint pG1(0, 0);
FPoint pG2(item->width(), 0);
FPoint pG3(item->width(), item->height());
FPoint pG4(0, item->height());
ScColorShade col1(m_doc->PageColors[item->GrColorP1], item->GrCol1Shade);
ScColorShade col2(m_doc->PageColors[item->GrColorP2], item->GrCol2Shade);
ScColorShade col3(m_doc->PageColors[item->GrColorP3], item->GrCol3Shade);
921,9 → 905,9
class ScPageOutputPainter: public TextLayoutPainter
{
private:
PageItem* m_item;
ScPainterExBase* m_painter;
ScPageOutput* m_scpage;
PageItem* m_item { nullptr };
ScPainterExBase* m_painter { nullptr };
ScPageOutput* m_scpage { nullptr };
 
void setupState()
{
1053,7 → 1037,7
m_painter->restore();
}
 
void drawRect(QRectF rect) override
void drawRect(const QRectF& rect) override
{
m_painter->save();
setupState();
1575,24 → 1559,24
double markLength = options.markLength;
double markOffs = options.markOffset;
double bleedLeft = 0.0, bleedRight = 0.0;
double bleedBottom = options.BleedBottom;
double bleedTop = options.BleedTop;
double bleedBottom = options.bleedBottom;
double bleedTop = options.bleedTop;
if (!options.cropMarks && !options.bleedMarks && !options.registrationMarks && !options.colorMarks)
return;
if (m_doc->locationOfPage(page->pageNr()) == LeftPage)
{
bleedRight = options.BleedRight;
bleedLeft = options.BleedLeft;
bleedRight = options.bleedRight;
bleedLeft = options.bleedLeft;
}
else if (m_doc->locationOfPage(page->pageNr()) == RightPage)
{
bleedRight = options.BleedLeft;
bleedLeft = options.BleedRight;
bleedRight = options.bleedLeft;
bleedLeft = options.bleedRight;
}
else
{
bleedRight = options.BleedLeft;
bleedLeft = options.BleedLeft;
bleedRight = options.bleedLeft;
bleedLeft = options.bleedLeft;
}
double width = page->width();
double height = page->height();
1701,10 → 1685,14
void ScPageOutput::drawBoxMarks(ScPainterExBase* painter, const QRectF& box, const QRectF& bleedBox, double offset , double markSize)
{
FPoint start, end;
double left = box.left(), right = box.right();
double bottom = box.bottom(), top = box.top();
double bleedLeft = bleedBox.left(), bleedRight = bleedBox.right();
double bleedBottom = bleedBox.bottom(), bleedTop = bleedBox.top();
double left = box.left();
double right = box.right();
double bottom = box.bottom();
double top = box.top();
double bleedLeft = bleedBox.left();
double bleedRight = bleedBox.right();
double bleedBottom = bleedBox.bottom();
double bleedTop = bleedBox.top();
// Top Left
start.setXY(bleedLeft - offset, top);
end.setXY (bleedLeft - offset - markSize, top);
/trunk/Scribus/scribus/scpageoutput.h
36,19 → 36,20
class SCRIBUS_API MarksOptions
{
public:
MarksOptions(void);
MarksOptions(struct PrintOptions& opt);
double markLength;
double markOffset;
double BleedTop;
double BleedLeft;
double BleedRight;
double BleedBottom;
bool cropMarks;
bool bleedMarks;
bool registrationMarks;
bool colorMarks;
bool docInfoMarks;
MarksOptions(void) = default;
MarksOptions(const PrintOptions& opt);
 
double markLength { 20.0 };
double markOffset { 0.0 };
double bleedTop { 0.0 };
double bleedLeft { 0.0 };
double bleedRight { 0.0 };
double bleedBottom { 0.0 };
bool cropMarks { false };
bool bleedMarks { false };
bool registrationMarks { false };
bool colorMarks { false };
bool docInfoMarks { false };
};
 
class SCRIBUS_API ScPageOutput
67,11 → 68,11
void setMarksOptions(const MarksOptions& opt) { m_marksOptions = opt; }
 
protected:
ScribusDoc* m_doc;
ScribusDoc* m_doc { nullptr };
 
bool m_reloadImages;
int m_imageRes;
bool m_useProfiles;
bool m_reloadImages { true };
int m_imageRes { 72 };
bool m_useProfiles { false };
MarksOptions m_marksOptions;
 
virtual void fillPath( PageItem* item, ScPainterExBase* painter, QRect clip );
104,7 → 105,7
virtual void drawBoxMarks( ScPainterExBase* painter, const QRectF& box, const QRectF& bleedBox, double offset , double markSize);
virtual void drawRegistrationCross( ScPainterExBase* painter );
 
ScImage::RequestType translateImageModeToRequest( ScPainterExBase::ImageMode mode);
ScImage::RequestType translateImageModeToRequest( ScPainterExBase::ImageMode mode) const;
 
friend class CollapsedTablePainterEx;
};
/trunk/Scribus/scribus/scprintengine_gdi.cpp
17,7 → 17,6
#include <windows.h>
#include <QByteArray>
#include <QScopedPointer>
using namespace ::std;
 
#include "scconfig.h"
 
25,7 → 24,6
#include <icm.h>
#endif
 
 
#include "commonstrings.h"
#include "prefscontext.h"
#include "prefsfile.h"
48,6 → 46,8
#include <cairo.h>
#include <cairo-win32.h>
 
using namespace ::std;
 
// Calculates fixed point from floating point.
#define __FXPTMANTISSA(d, f) ( (DWORD)d << f )
#define __FXPTFRACTION(d, f) ( (DWORD)ldexp((d - (DWORD)d), f) )
56,11 → 56,11
#define __FXPT16DOT16(d) __FXPT32(d, 16)
 
// Convenient structure for performing postscript passthrough
typedef struct
struct sPSPassthrough
{
WORD numBytes;
BYTE data[32768];
} sPSPassthrough;
WORD numBytes { 0 };
BYTE data[32768] { 0 };
};
 
ScPrintEngine_GDI::ScPrintEngine_GDI(ScribusDoc& doc) : ScPrintEngine(doc)
{
140,7 → 140,7
return success;
}
 
bool ScPrintEngine_GDI::gdiPrintPreview(ScPage* page, QImage* image, PrintOptions& options, double scale)
bool ScPrintEngine_GDI::gdiPrintPreview(ScPage* page, QImage* image, const PrintOptions& options, double scale)
{
bool success = true;
HCOLORSPACE hColorSpace = nullptr;
203,7 → 203,7
return success;
}
 
bool ScPrintEngine_GDI::printPages(PrintOptions& options, HDC printerDC, DEVMODEW* devMode, QString& fileName)
bool ScPrintEngine_GDI::printPages(const PrintOptions& options, HDC printerDC, DEVMODEW* devMode, QString& fileName)
{
int jobId;
QScopedPointer<MultiProgressDialog> progress;
217,7 → 217,7
// choose appropriate page printing function
bool psPrint = isPostscriptPrinter(printerDC);
bool useGDI = (!psPrint || m_forceGDI || (options.prnLanguage == PrintLanguage::WindowsGDI));
printPageFunc = (useGDI) ? &ScPrintEngine_GDI::printPage_GDI : &ScPrintEngine_GDI::printPage_PS;
printPageFunc = useGDI ? &ScPrintEngine_GDI::printPage_GDI : &ScPrintEngine_GDI::printPage_PS;
 
// Setup document infos structure
wcsncpy (docName, (const WCHAR*) m_doc.documentFileName().utf16(), 511);
288,21 → 288,12
return success;
}
 
bool ScPrintEngine_GDI::printPage_GDI(ScPage* page, PrintOptions& options, HDC printerDC, cairo_t* context)
bool ScPrintEngine_GDI::printPage_GDI(ScPage* page, const PrintOptions& options, HDC printerDC, cairo_t* context)
{
int logPixelsX;
int logPixelsY;
int physicalWidth;
int physicalHeight;
int physicalWidthP;
int physicalHeightP;
int physicalOffsetX;
int physicalOffsetY;
bool success = true;
QString inputProfile;
QString printerProfile;
HCOLORSPACE hColorSpace = nullptr;
double scalex = 1, scaley = 1;
bool rotate = false;
 
StartPage(printerDC);
375,26 → 366,28
int cliph = qRound(page->height());
 
// Get horizontal and vertical resolution of printer
logPixelsX = GetDeviceCaps(printerDC, LOGPIXELSX);
logPixelsY = GetDeviceCaps(printerDC, LOGPIXELSY);
int logPixelsX = GetDeviceCaps(printerDC, LOGPIXELSX);
int logPixelsY = GetDeviceCaps(printerDC, LOGPIXELSY);
 
// Get paper dimensions (in pixels and points)
physicalWidth = GetDeviceCaps(printerDC, PHYSICALWIDTH);
physicalHeight = GetDeviceCaps(printerDC, PHYSICALHEIGHT);
physicalWidthP = physicalWidth / (double) logPixelsX * 72.0;
physicalHeightP = physicalHeight / (double) logPixelsY * 72.0;
int physicalWidth = GetDeviceCaps(printerDC, PHYSICALWIDTH);
int physicalHeight = GetDeviceCaps(printerDC, PHYSICALHEIGHT);
int physicalWidthP = physicalWidth / (double) logPixelsX * 72.0;
int physicalHeightP = physicalHeight / (double) logPixelsY * 72.0;
 
// Get margins dimensions
physicalOffsetX = GetDeviceCaps(printerDC, PHYSICALOFFSETX);
physicalOffsetY = GetDeviceCaps(printerDC, PHYSICALOFFSETY);
int physicalOffsetX = GetDeviceCaps(printerDC, PHYSICALOFFSETX);
int physicalOffsetY = GetDeviceCaps(printerDC, PHYSICALOFFSETY);
 
// Calculate scaling factors and offsets
scalex = options.mirrorH ? -1.0 : 1.0;
scaley = options.mirrorV ? -1.0 : 1.0;
double scalex = options.mirrorH ? -1.0 : 1.0;
double scaley = options.mirrorV ? -1.0 : 1.0;
double dx = (physicalWidthP - clipw) / 2.0 - clipx * scalex;
double dy = (physicalHeightP - cliph) / 2.0 - clipy * scaley;
if (options.mirrorH) dx += clipw;
if (options.mirrorV) dy += cliph;
if (options.mirrorH)
dx += clipw;
if (options.mirrorV)
dy += cliph;
dx -= (physicalOffsetX / (double) logPixelsX * 72.0);
dy -= (physicalOffsetY / (double) logPixelsY * 72.0);
425,7 → 418,7
return success;
}
 
bool ScPrintEngine_GDI::printPage_PS(ScPage* page, PrintOptions& options, HDC printerDC, cairo_t* /*context*/)
bool ScPrintEngine_GDI::printPage_PS(ScPage* page, const PrintOptions& options, HDC printerDC, cairo_t* /*context*/)
{
bool succeed = false;
PrintOptions options2 = options;
437,10 → 430,11
options2.includePDFMarks = false;
 
tempFilePath = ScPaths::tempFileDir() + "/tmp.ps";
PSLib *dd = new PSLib(&m_doc, options2, PSLib::OutputEPS);
ret = dd->createPS(tempFilePath);
delete dd;
if (ret != 0) return false;
std::unique_ptr<PSLib> psLib(new PSLib(&m_doc, options2, PSLib::OutputEPS));
ret = psLib->createPS(tempFilePath);
if (ret != 0)
return false;
psLib.reset();
 
if (options.prnLanguage == PrintLanguage::PostScript1 || options.prnLanguage == PrintLanguage::PostScript2)
{
476,7 → 470,7
return succeed;
}
 
bool ScPrintEngine_GDI::printPage_PS_Sep(ScPage* page, PrintOptions& options, HDC printerDC, cairo_t* context)
bool ScPrintEngine_GDI::printPage_PS_Sep(ScPage* page, const PrintOptions& options, HDC printerDC, cairo_t* context)
{
bool succeed = true;
QStringList separations;
496,39 → 490,32
 
bool ScPrintEngine_GDI::sendPSFile(QString filePath, HDC printerDC, int pageWidth, int pageHeight, bool landscape)
{
int escape;
int logPixelsX;
int logPixelsY;
int physicalWidth;
int physicalHeight;
bool done = true;
sPSPassthrough sps;
double transx, transy;
double scalex, scaley;
QFile file(filePath);
int fileSize = 0;
int br, bw;
 
if (!printerDC)
return false;
escape = getPSPassthroughSupport(printerDC);
 
int escape = getPSPassthroughSupport(printerDC);
if (!escape)
return false;
 
QFile file(filePath);
 
// Get printer resolution
logPixelsX = GetDeviceCaps(printerDC, LOGPIXELSX);
logPixelsY = GetDeviceCaps(printerDC, LOGPIXELSY);
int logPixelsX = GetDeviceCaps(printerDC, LOGPIXELSX);
int logPixelsY = GetDeviceCaps(printerDC, LOGPIXELSY);
 
// Get paper dimensions (in point units)
physicalWidth = GetDeviceCaps(printerDC, PHYSICALWIDTH) / (double) logPixelsX * 72.0;
physicalHeight = GetDeviceCaps(printerDC, PHYSICALHEIGHT) / (double) logPixelsY * 72.0;
int physicalWidth = GetDeviceCaps(printerDC, PHYSICALWIDTH) / (double) logPixelsX * 72.0;
int physicalHeight = GetDeviceCaps(printerDC, PHYSICALHEIGHT) / (double) logPixelsY * 72.0;
 
// Calculate and set scaling factor
scalex = logPixelsX / 72.0;
scaley = -logPixelsY / 72.0;
sprintf((char*) sps.data, "%0.3f %0.3f scale\n", scalex, scaley);
sps.numBytes = strlen((char*) sps.data);
if (ExtEscape(printerDC, escape, sizeof(sps), (LPCSTR) &sps, 0, nullptr) <= 0)
double scalex = logPixelsX / 72.0;
double scaley = -logPixelsY / 72.0;
 
std::unique_ptr<sPSPassthrough> sps(new sPSPassthrough());
 
sprintf((char*) sps->data, "%0.3f %0.3f scale\n", scalex, scaley);
sps->numBytes = strlen((char*) sps->data);
if (ExtEscape(printerDC, escape, sizeof(sPSPassthrough), (LPCSTR) sps.get(), 0, nullptr) <= 0)
return false;
 
// Set some necessary stuff for embedding ps into ps
545,24 → 532,26
eBegin += "1 ne\n";
eBegin += "{false setstrokeadjust false setoverprint\n";
eBegin += "} if } if\n";
sprintf((char*) sps.data, "%s", eBegin.toLatin1().data());
sps.numBytes = strlen((char*) sps.data);
if (ExtEscape(printerDC, escape, sizeof(sps), (LPCSTR) &sps, 0, nullptr) <= 0)
sprintf((char*) sps->data, "%s", eBegin.toLatin1().data());
sps->numBytes = strlen((char*) sps->data);
if (ExtEscape(printerDC, escape, sizeof(sPSPassthrough), (LPCSTR) sps.get(), 0, nullptr) <= 0)
return false;
 
// Match Postscript and GDI coordinate system
sprintf((char*) sps.data, "0 %0.3f neg translate\n", (double) physicalHeight);
sps.numBytes = strlen((char*) sps.data);
if (ExtEscape(printerDC, escape, sizeof(sps), (LPCSTR) &sps, 0, nullptr) <= 0)
sprintf((char*) sps->data, "0 %0.3f neg translate\n", (double) physicalHeight);
sps->numBytes = strlen((char*) sps->data);
if (ExtEscape(printerDC, escape, sizeof(sPSPassthrough), (LPCSTR) sps.get(), 0, nullptr) <= 0)
return false;
 
// In case of landscape printing, pslib will rotate the page
// we must take that into account
double transx;
double transy;
/*if (landscape)
{
sprintf((char*) sps.data, "-90 rotate %0.3f %0.3f translate\n", (double) -pageHeight, 0.0);
sps.numBytes = strlen((char*) sps.data);
if (ExtEscape(printerDC, escape, sizeof(sps), (LPCSTR) &sps, 0, nullptr) <= 0)
sprintf((char*) sps->data, "-90 rotate %0.3f %0.3f translate\n", (double) -pageHeight, 0.0);
sps->numBytes = strlen((char*) sps.data);
if (ExtEscape(printerDC, escape, sizeof(sPSPassthrough), (LPCSTR) sps.get(), 0, nullptr) <= 0)
return false;
transx = (physicalHeight - pageHeight) / -2.0;
transy = (physicalWidth - pageWidth) / 2.0;
574,34 → 563,34
}
 
// Center the printed page in paper zone
sprintf((char*) sps.data, "%0.3f %0.3f translate\n", transx, transy);
sps.numBytes = strlen((char*) sps.data);
if (ExtEscape(printerDC, escape, sizeof(sps), (LPCSTR) &sps, 0, nullptr) <= 0)
sprintf((char*) sps->data, "%0.3f %0.3f translate\n", transx, transy);
sps->numBytes = strlen((char*) sps->data);
if (ExtEscape(printerDC, escape, sizeof(sPSPassthrough), (LPCSTR) sps.get(), 0, nullptr) <= 0)
return false;
 
sprintf((char*) sps.data, "%s: %s\n", "%%BeginDocument", file.fileName().toLocal8Bit().data());
sps.numBytes = strlen((char*) sps.data);
if (ExtEscape(printerDC, escape, sizeof(sps), (LPCSTR) &sps, 0, nullptr) <= 0)
sprintf((char*) sps->data, "%s: %s\n", "%%BeginDocument", file.fileName().toLocal8Bit().data());
sps->numBytes = strlen((char*) sps->data);
if (ExtEscape(printerDC, escape, sizeof(sPSPassthrough), (LPCSTR) sps.get(), 0, nullptr) <= 0)
return false;
 
if (!file.open(QIODevice::ReadOnly))
return false;
fileSize = file.size();
bw = 0; // bytes written
br = file.read((char*) sps.data, sizeof(sps.data));
 
qint64 fileSize = file.size();
qint64 bw = 0; // bytes written
qint64 br = file.read((char*) sps->data, sizeof(sps->data));
while (br > 0)
{
sps.numBytes = br;
if (ExtEscape(printerDC, escape, sizeof(sps), (LPCSTR) &sps, 0, nullptr) <= 0)
sps->numBytes = br;
if (ExtEscape(printerDC, escape, sizeof(sPSPassthrough), (LPCSTR) sps.get(), 0, nullptr) <= 0)
break;
bw += br;
br = file.read((char*) sps.data, sizeof(sps.data));
br = file.read((char*) sps->data, sizeof(sps->data));
}
file.close();
 
sprintf((char*) sps.data, "%s", "\n%%EndDocument\n");
sps.numBytes = strlen((char*) sps.data);
if (ExtEscape(printerDC, escape, sizeof(sps), (LPCSTR) &sps, 0, nullptr) <= 0)
sprintf((char*) sps->data, "%s", "\n%%EndDocument\n");
sps->numBytes = strlen((char*) sps->data);
if (ExtEscape(printerDC, escape, sizeof(sPSPassthrough), (LPCSTR) sps.get(), 0, nullptr) <= 0)
return false;
 
// Set some necessary stuff for embedding ps into ps
608,15 → 597,15
QString eEnd = "count op_count sub {pop} repeat\n";
eEnd += "countdictstack dict_count sub {end} repeat\n";
eEnd += "b4_Inc_state restore\n";
sprintf((char*) sps.data, "%s", eEnd.toLatin1().data());
sps.numBytes = strlen((char*) sps.data);
if (ExtEscape(printerDC, escape, sizeof(sps), (LPCSTR) &sps, 0, nullptr) <= 0)
sprintf((char*) sps->data, "%s", eEnd.toLatin1().data());
sps->numBytes = strlen((char*) sps->data);
if (ExtEscape(printerDC, escape, sizeof(sPSPassthrough), (LPCSTR) sps.get(), 0, nullptr) <= 0)
return false;
 
return ((fileSize == bw) && (br >= 0));
}
 
void ScPrintEngine_GDI::setDeviceParams(PrintOptions& options, DEVMODEW* devMode)
void ScPrintEngine_GDI::setDeviceParams(const PrintOptions& options, DEVMODEW* devMode)
{
HANDLE handle;
QString printer = options.printer;
648,7 → 637,7
return defPrinter;
}
 
bool ScPrintEngine_GDI::isPostscriptPrinter(HDC dc)
bool ScPrintEngine_GDI::isPostscriptPrinter(HDC dc) const
{
int escapeCode;
char technology[MAX_PATH] = {0};
680,14 → 669,13
return false;
}
 
int ScPrintEngine_GDI::getPSPassthroughSupport(HDC printerDC)
int ScPrintEngine_GDI::getPSPassthroughSupport(HDC printerDC) const
{
int escapeCode;
char technology[MAX_PATH] = {0};
if (!printerDC)
return 0;
 
// Test printer support for the POSTSCRIPT_PASSTHROUGH escape (available since win2k)
escapeCode = POSTSCRIPT_PASSTHROUGH;
int escapeCode = POSTSCRIPT_PASSTHROUGH;
if (ExtEscape(printerDC, QUERYESCSUPPORT, sizeof(int), (LPCSTR) &escapeCode, 0, nullptr) > 0)
return POSTSCRIPT_PASSTHROUGH;
// Test printer support for the POSTSCRIPT_DATA escape (available since win95)
701,14 → 689,13
return 0;
}
 
bool ScPrintEngine_GDI::printerUseFilePort(QString& printerName)
bool ScPrintEngine_GDI::printerUseFilePort(const QString& printerName) const
{
bool done;
bool toFile = false;
HANDLE prnHandle;
DWORD size = 0;
bool toFile = false;
HANDLE prnHandle;
DWORD size = 0;
 
done = OpenPrinterW((LPWSTR) printerName.utf16(), &prnHandle, nullptr);
bool done = OpenPrinterW((LPWSTR) printerName.utf16(), &prnHandle, nullptr);
if (!done)
return false;
/trunk/Scribus/scribus/scprintengine_gdi.h
47,7 → 47,7
\retval bool true on success
\author Jean Ghali
*/
bool gdiPrintPreview(ScPage* page, QImage* image, PrintOptions& options, double scale = 1.0);
bool gdiPrintPreview(ScPage* page, QImage* image, const PrintOptions& options, double scale = 1.0);
 
/*! \brief Get the default printer name
\retval QString the default printer name on success or an empty string
61,7 → 61,7
 
void resetData(void);
 
typedef bool (ScPrintEngine_GDI::*PrintPageFunc) (ScPage* page, PrintOptions& options, HDC printerDC, cairo_t* context);
typedef bool (ScPrintEngine_GDI::*PrintPageFunc) (ScPage* page, const PrintOptions& options, HDC printerDC, cairo_t* context);
 
/*! \brief Print selected pages to a printer or a file
\param doc the document whose pages are to be printer
72,7 → 72,7
\retval bool true on success
\author Jean Ghali
*/
bool printPages(PrintOptions& options, HDC printerDC, DEVMODEW* devMode, QString& fileName);
bool printPages(const PrintOptions& options, HDC printerDC, DEVMODEW* devMode, QString& fileName);
 
/*! \brief Print a page to a gdi printer
Print a page using GDI drawing code ( works on all printers : PS, PCL, GDI... )
84,7 → 84,7
\retval bool true on success
\author Jean Ghali
*/
bool printPage_GDI(ScPage* page, PrintOptions& options, HDC printerDC, cairo_t* context);
bool printPage_GDI(ScPage* page, const PrintOptions& options, HDC printerDC, cairo_t* context);
 
/*! \brief Print a page to a PostScript printer using passthroughs
Print a page using PS drawing code and PS passthroughs ( works on PS printers only )
96,7 → 96,7
\retval bool true on success
\author Jean Ghali
*/
bool printPage_PS (ScPage* page, PrintOptions& options, HDC printerDC, cairo_t* context);
bool printPage_PS (ScPage* page, const PrintOptions& options, HDC printerDC, cairo_t* context);
 
/*! \brief Print a page separations to a PostScript printer using passthroughs
Print a page using PS drawing code and PS passthroughs ( works on PS printers only )
108,7 → 108,7
\retval bool true on success
\author Jean Ghali
*/
bool printPage_PS_Sep(ScPage* page, PrintOptions& options, HDC printerDC, cairo_t* context);
bool printPage_PS_Sep(ScPage* page, const PrintOptions& options, HDC printerDC, cairo_t* context);
 
/*! \brief Send a file to printer using PostScript Passthrough
Send a postscript file to a printer using ps passthrough ( works on PS printers only )
128,7 → 128,7
\param devMode pointer to a DEVMODE structure
\author Jean Ghali
*/
void setDeviceParams(PrintOptions& options, DEVMODEW* devMode);
void setDeviceParams(const PrintOptions& options, DEVMODEW* devMode);
 
/*! \brief Get support for PostScript Passthrough
Get ps passthrough support and escape code
136,7 → 136,7
\retval int the postscript passthrough escape code if success, 0 if the function fails
\author Jean Ghali
*/
int getPSPassthroughSupport(HDC printerDC);
int getPSPassthroughSupport(HDC printerDC) const;
 
/*! \brief Check if a specified printer use the FILE: port
\param printerName the printer name
143,7 → 143,7
\retval bool return true if the specified printer print to the FILE: port
\author Jean Ghali
*/
bool printerUseFilePort (QString& printerName);
bool printerUseFilePort (const QString& printerName) const;
 
/*! \brief Check if PostScript is supported by a printer device context
\param dc the printer device context
150,7 → 150,7
\retval bool return true if PostScript is supported
\author Jean Ghali
*/
bool isPostscriptPrinter(HDC dc);
bool isPostscriptPrinter(HDC dc) const;
};
 
#endif
/trunk/Scribus/scribus/scprintengine_ps.cpp
5,6 → 5,8
for which a new license (GPL+exception) is in place.
*/
 
#include <memory>
 
#include "scpaths.h"
#include "scprintengine_ps.h"
#include "scribusstructs.h"
23,8 → 25,9
bool ScPrintEngine_PS::print(PrintOptions& options)
{
QString filename(options.filename);
PSLib *dd = new PSLib(&m_doc, options, PSLib::OutputPS);
if (dd == nullptr)
 
std::unique_ptr<PSLib> psLib(new PSLib(&m_doc, options, PSLib::OutputPS));
if (!psLib)
return false;
 
if (!options.toFile)
33,13 → 36,13
// Write the PS to a file
filename = QDir::toNativeSeparators(filename);
 
int psCreationRetVal = dd->createPS(filename);
int psCreationRetVal = psLib->createPS(filename);
if (psCreationRetVal != 0)
{
QFile::remove(filename);
if (psCreationRetVal == 2)
return true;
m_errorMessage = dd->errorMessage();
m_errorMessage = psLib->errorMessage();
return false;
}
if (options.prnLanguage != PrintLanguage::PostScript3 && ScCore->haveGS())
/trunk/Scribus/scribus/scribusdoc.cpp
650,7 → 650,7
appMode == modeEditWeldPoint;
}
 
QList<PageItem*> ScribusDoc::getAllItems(QList<PageItem*> &items)
QList<PageItem*> ScribusDoc::getAllItems(QList<PageItem*> &items) const
{
QList<PageItem*> ret;
for (int em = 0; em < items.count(); ++em)
1062,7 → 1062,7
return m_docCharStyles.contains(styleName);
}
 
QList<int> ScribusDoc::getSortedStyleList()
QList<int> ScribusDoc::getSortedStyleList() const
{
QList<int> retList;
for (int i = 0; i < m_docParagraphStyles.count(); ++i)
1094,7 → 1094,7
return retList;
}
 
QList<int> ScribusDoc::getSortedCharStyleList()
QList<int> ScribusDoc::getSortedCharStyleList() const
{
QList<int> retList;
for (int i = 0; i < m_docCharStyles.count(); ++i)
1126,7 → 1126,7
return retList;
}
 
QList<int> ScribusDoc::getSortedTableStyleList()
QList<int> ScribusDoc::getSortedTableStyleList() const
{
QList<int> retList;
for (int i = 0; i < m_docTableStyles.count(); ++i)
1158,7 → 1158,7
return retList;
}
 
QList<int> ScribusDoc::getSortedCellStyleList()
QList<int> ScribusDoc::getSortedCellStyleList() const
{
QList<int> retList;
for (int i = 0; i < m_docCellStyles.count(); ++i)
1577,7 → 1577,7
name = Um::LockGuides;
else
name = Um::UnlockGuides;
SimpleState *ss = new SimpleState(name, "", Um::ILockGuides);
auto* ss = new SimpleState(name, "", Um::ILockGuides);
ss->set("GUIDE_LOCK", isLocked);
m_undoManager->action(this, ss);
}
1599,7 → 1599,7
 
void ScribusDoc::restore(UndoState* state, bool isUndo)
{
SimpleState *ss = dynamic_cast<SimpleState*>(state);
auto *ss = dynamic_cast<SimpleState*>(state);
if (!ss)
return;
 
1813,7 → 1813,7
setMasterPageMode(true);
if (isUndo)
{
DummyUndoObject *duo = new DummyUndoObject();
auto *duo = new DummyUndoObject();
uint did = static_cast<uint>(duo->getUId());
m_undoManager->replaceObject(Pages->at(MasterNames[pageName])->getUId(), duo);
ss->set("DUMMY_ID", did);
1867,7 → 1867,7
 
void ScribusDoc::restoreGrouping(SimpleState* ss, bool isUndo)
{
ScItemState<QList<QPointer<PageItem> > >* is = dynamic_cast<ScItemState<QList<QPointer<PageItem> > >*>(ss);
auto* is = dynamic_cast<ScItemState<QList<QPointer<PageItem> > >*>(ss);
if (!is)
qFatal("ScribusDoc::restoreGrouping: dynamic cast failed");
 
1901,7 → 1901,7
 
void ScribusDoc::restoreMarks(UndoState* state, bool isUndo)
{
ScItemsState *is = dynamic_cast<ScItemsState*>(state);
auto *is = dynamic_cast<ScItemsState*>(state);
if (!is)
return;
 
2260,7 → 2260,7
 
void ScribusDoc::restoreDeleteNote(UndoState* state, bool isUndo)
{
ScItemsState *is = dynamic_cast<ScItemsState*>(state);
auto *is = dynamic_cast<ScItemsState*>(state);
if (!is)
return;
 
2350,11 → 2350,12
}
 
 
QStringList ScribusDoc::getItemAttributeNames()
QStringList ScribusDoc::getItemAttributeNames() const
{
QStringList nameList;
 
for (ObjAttrVector::Iterator it = itemAttributes().begin(); it!= itemAttributes().end(); ++it)
auto itemAttrs = itemAttributes();
for (ObjAttrVector::Iterator it = itemAttrs.begin(); it!= itemAttrs.end(); ++it)
nameList.append((*it).name);
return nameList;
}
2512,7 → 2513,7
changed();
if (UndoManager::undoEnabled())
{
SimpleState *ss = new SimpleState(Um::NewMasterPage, "", Um::IDocument);
auto *ss = new SimpleState(Um::NewMasterPage, "", Um::IDocument);
ss->set("MASTERPAGE_ADD");
ss->set("MASTERPAGE_NAME", pageName);
ss->set("MASTERPAGE_NBR", pgN);
2552,7 → 2553,7
changed();
if (UndoManager::undoEnabled())
{
SimpleState *ss = new SimpleState(Um::RenameMasterPage, "", Um::IDocument);
auto*ss = new SimpleState(Um::RenameMasterPage, "", Um::IDocument);
ss->set("MASTERPAGE_RENAME");
ss->set("OLD_MASTERPAGE", oldPageName);
ss->set("NEW_MASTERPAGE", newPageName);
2650,7 → 2651,7
{
if (UndoManager::undoEnabled())
{
SimpleState *ss = new SimpleState(Um::SwapPage, "", Um::IDocument);
auto *ss = new SimpleState(Um::SwapPage, "", Um::IDocument);
ss->set("PAGE_SWAP");
ss->set("PAGE_SWAP_FROM", a);
ss->set("PAGE_SWAP_TO", b);
2702,7 → 2703,7
 
if (UndoManager::undoEnabled())
{
SimpleState *ss = new SimpleState(Um::MovePage, "", Um::IDocument);
auto *ss = new SimpleState(Um::MovePage, "", Um::IDocument);
ss->set("PAGE_MOVE");
ss->set("PAGE_MOVE_FROM", fromPage);
ss->set("PAGE_MOVE_TO", toPage);
2797,7 → 2798,7
else
if (UndoManager::undoEnabled())
{
SimpleState *ss = new SimpleState(Um::AddLayer, "", Um::ICreate);
auto *ss = new SimpleState(Um::AddLayer, "", Um::ICreate);
ss->set("ADD_LAYER");
ss->set("ACTIVE", m_ActiveLayer);
ss->set("NAME", ll->Name);
2856,7 → 2857,7
 
if (activeTransaction)
{
SimpleState *ss = new SimpleState(Um::DeleteLayer, "", Um::IDelete);
auto *ss = new SimpleState(Um::DeleteLayer, "", Um::IDelete);
ss->set("REMOVE_LAYER");
ss->set("ACTIVE", layerID);
ss->set("LEVEL", layerLevel);
2916,7 → 2917,7
{
if (it->isPrintable!=isPrintable && UndoManager::undoEnabled())
{
SimpleState *ss = new SimpleState(isPrintable ? Um::PrintLayer : Um::DoNotPrintLayer, "", Um::IPrint);
auto *ss = new SimpleState(isPrintable ? Um::PrintLayer : Um::DoNotPrintLayer, "", Um::IPrint);
ss->set("PRINT_LAYER");
ss->set("ACTIVE", it->ID);
ss->set("PRINT", isPrintable);
3017,7 → 3018,7
// == because isEditable vs isLocked...
if (it->isEditable==isLocked && UndoManager::undoEnabled())
{
SimpleState *ss = new SimpleState(isLocked ? Um::SetLayerLocked : Um::SetLayerUnlocked, "", Um::ILayer);
auto *ss = new SimpleState(isLocked ? Um::SetLayerLocked : Um::SetLayerUnlocked, "", Um::ILayer);
ss->set("LAYER_LOCK");
ss->set("ACTIVE", it->ID);
ss->set("LOCK", isLocked);
3056,7 → 3057,7
{
if (it->flowControl!=flow && UndoManager::undoEnabled())
{
SimpleState *ss = new SimpleState(flow ? Um::FlowLayer : Um::DisableFlowLayer, "", Um::ITextFrame);
auto *ss = new SimpleState(flow ? Um::FlowLayer : Um::DisableFlowLayer, "", Um::ITextFrame);
ss->set("LAYER_FLOW");
ss->set("ACTIVE", it->ID);
ss->set("FLOW", flow);
3104,7 → 3105,7
{
if (it->transparency!=trans && UndoManager::undoEnabled())
{
SimpleState *ss = new SimpleState(Um::SetLayerTransparency, "", Um::ILayer);
auto *ss = new SimpleState(Um::SetLayerTransparency, "", Um::ILayer);
ss->set("LAYER_TRANSPARENCY");
ss->set("ACTIVE", it->ID);
ss->set("OLD_TRANS", it->transparency);
3142,9 → 3143,9
{
if (it->ID == layerID)
{
if (it->blendMode!=blend && UndoManager::undoEnabled())
if (it->blendMode != blend && UndoManager::undoEnabled())
{
SimpleState *ss = new SimpleState(Um::SetLayerBlendMode, "", Um::ILayer);
auto *ss = new SimpleState(Um::SetLayerBlendMode, "", Um::ILayer);
ss->set("LAYER_BLENDMODE");
ss->set("ACTIVE", it->ID);
ss->set("OLD_BLENDMODE", it->blendMode);
3292,7 → 3293,7
return false;
if (UndoManager::undoEnabled())
{
SimpleState *ss = new SimpleState(Um::LowerLayer, "", Um::IDown);
auto *ss = new SimpleState(Um::LowerLayer, "", Um::IDown);
ss->set("DOWN_LAYER");
ss->set("ACTIVE", layerIDFromLevel(layerLevel));
m_undoManager->action(this, ss, m_documentFileName, Um::ILayer);
3341,7 → 3342,7
return false;
if (UndoManager::undoEnabled())
{
SimpleState *ss = new SimpleState(Um::RaiseLayer, "", Um::IUp);
auto *ss = new SimpleState(Um::RaiseLayer, "", Um::IUp);
ss->set("UP_LAYER");
ss->set("ACTIVE", layerIDFromLevel(layerLevel));
m_undoManager->action(this, ss, m_documentFileName, Um::ILayer);
3348,10 → 3349,10
}
 
ScLayers::iterator it;
ScLayers::iterator itend=Layers.end();
ScLayers::iterator itend = Layers.end();
for (it = Layers.begin(); it != itend; ++it)
{
if (it->Level == layerLevel+1)
if (it->Level == layerLevel + 1)
break;
}
ScLayers::iterator it2;
3401,7 → 3402,7
{
if (UndoManager::undoEnabled())
{
SimpleState *ss = new SimpleState(Um::SetLayerName, QString(Um::FromTo).arg(Layers[i].Name, newName), Um::IDown);
auto *ss = new SimpleState(Um::SetLayerName, QString(Um::FromTo).arg(Layers[i].Name, newName), Um::IDown);
ss->set("CHANGE_NAME");
ss->set("ACTIVE", m_ActiveLayer);
ss->set("NEW_NAME", newName);
4131,7 → 4132,7
while (allItems.count() > 0)
{
PageItem *ite = allItems.takeFirst();
if (it->isGroup() || it->isTable())
if (ite->isGroup() || ite->isTable())
{
allItems = it->getChildren() + allItems;
continue;
4198,7 → 4199,7
 
// we don't need this one
void drawLine(QPointF, QPointF) override {}
void drawRect(QRectF) override {}
void drawRect(const QRectF&) override {}
void drawObject(PageItem*) override {}
 
private:
4585,7 → 4586,7
{
if (DocPages.at(pageNumber)->masterPageName() != pageName)
{
SimpleState *ss = new SimpleState(Um::ApplyMasterPage, QString(Um::FromTo).arg(DocPages.at(pageNumber)->masterPageName(), pageName));
auto *ss = new SimpleState(Um::ApplyMasterPage, QString(Um::FromTo).arg(DocPages.at(pageNumber)->masterPageName(), pageName));
ss->set("PAGE_NUMBER", pageNumber);
ss->set("OLD_MASTERPAGE", DocPages.at(pageNumber)->masterPageName());
ss->set("NEW_MASTERPAGE", pageName);
6170,7 → 6171,7
}
}
 
double ScribusDoc::getXOffsetForPage(int pageNumber)
double ScribusDoc::getXOffsetForPage(int pageNumber) const
{
if (Pages->at(pageNumber) != nullptr)
return Pages->at(pageNumber)->xOffset();
6177,7 → 6178,7
return -1.0;
}
 
double ScribusDoc::getYOffsetForPage(int pageNumber)
double ScribusDoc::getYOffsetForPage(int pageNumber) const
{
if (Pages->at(pageNumber) != nullptr)
return Pages->at(pageNumber)->yOffset();
6184,7 → 6185,7
return -1.0;
}
 
void ScribusDoc::getBleeds(int pageNumber, MarginStruct &bleedData)
void ScribusDoc::getBleeds(int pageNumber, MarginStruct &bleedData) const
{
if (pageNumber >= 0 && pageNumber < Pages->size())
getBleeds(Pages->at(pageNumber), bleedData);
6192,12 → 6193,12
qCritical() << "Attempting to get bleeds for non-existent page";
}
 
void ScribusDoc::getBleeds(const ScPage* page, MarginStruct& bleedData)
void ScribusDoc::getBleeds(const ScPage* page, MarginStruct& bleedData) const
{
getBleeds(page, m_docPrefsData.docSetupPrefs.bleeds, bleedData);
}
 
void ScribusDoc::getBleeds(const ScPage* page, const MarginStruct& baseValues, MarginStruct& bleedData)
void ScribusDoc::getBleeds(const ScPage* page, const MarginStruct& baseValues, MarginStruct& bleedData) const
{
bleedData.setBottom(baseValues.bottom());
bleedData.setTop(baseValues.top());
7035,7 → 7036,7
if (UndoManager::undoEnabled())
{
copyTransaction = m_undoManager->beginTransaction(getUName(), Um::IDocument, Um::CopyPage, "", Um::ICreate);
SimpleState *ss = new SimpleState(Um::Copy, "", Um::ICreate);
auto *ss = new SimpleState(Um::Copy, "", Um::ICreate);
ss->set("PAGE_COPY");
ss->set("PAGE_NUM", pageNumberToCopy);
ss->set("EXISTING_PAGE", existingPage);
9569,7 → 9570,7
{
if (UndoManager::undoEnabled())
{
SimpleState *ss = new SimpleState(Um::FlipH, "", Um::IFlipH);
auto *ss = new SimpleState(Um::FlipH, "", Um::IFlipH);
ss->set("MIRROR_PATH_H");
ss->set("IS_CONTOUR", true);
m_undoManager->action(currItem, ss, Um::IBorder);
9594,7 → 9595,7
currItem->update();
if (UndoManager::undoEnabled())
{
SimpleState *ss = new SimpleState(Um::FlipH, "", Um::IFlipH);
auto *ss = new SimpleState(Um::FlipH, "", Um::IFlipH);
ss->set("MIRROR_PATH_H");
ss->set("IS_CONTOUR", false);
m_undoManager->action(currItem, ss, Um::IBorder);
9613,7 → 9614,7
{
if (UndoManager::undoEnabled())
{
SimpleState *ss = new SimpleState(Um::FlipV, "", Um::IFlipV);
auto *ss = new SimpleState(Um::FlipV, "", Um::IFlipV);
ss->set("MIRROR_PATH_V");
ss->set("IS_CONTOUR", true);
m_undoManager->action(currItem, ss, Um::IBorder);
9637,7 → 9638,7
currItem->update();
if (UndoManager::undoEnabled())
{
SimpleState *ss = new SimpleState(Um::FlipV, "", Um::IFlipV);
auto *ss = new SimpleState(Um::FlipV, "", Um::IFlipV);
ss->set("MIRROR_PATH_V");
ss->set("IS_CONTOUR", false);
m_undoManager->action(currItem, ss, Um::IBorder);
9649,9 → 9650,9
{
int n=nr;
if (n == -1)
n=0;
*(currItem) = m_Selection->itemAt(n);
return (*(currItem) != nullptr);
n = 0;
*currItem = m_Selection->itemAt(n);
return (*currItem != nullptr);
}
 
void ScribusDoc::setFrameRect()
10443,13 → 10444,13
PageItem *currItem = m_Selection->itemAt(a);
double deltaX = currItem->xPos() - gx;
double deltaY = currItem->yPos() - gy;
QTransform matrixPre = QTransform();
QTransform matrixAft = QTransform();
QTransform matrixPre;
QTransform matrixAft;
switch (basepoint)
{
case 2:
matrixPre.translate(-gw/2.0, -gh/2.0);
matrixAft.translate(gw/2.0, gh/2.0);
matrixPre.translate(-gw / 2.0, -gh / 2.0);
matrixAft.translate(gw / 2.0, gh / 2.0);
break;
case 4:
matrixPre.translate(-gw, -gh);
10516,7 → 10517,7
int rotBack = rotationMode();
setRotationMode ( 0 );
ScriXmlDoc xmlDoc;
QString copyBuffer = xmlDoc.writeElem(this, m_Selection);
QString copyBuffer = ScriXmlDoc::writeElem(this, m_Selection);
view()->deselectItems(true);
for (int b = 0; b < nrOfCopies; b++)
{
10543,13 → 10544,13
currItem = m_Selection->itemAt(a);
double deltaX = currItem->xPos() - gx;
double deltaY = currItem->yPos() - gy;
QTransform matrixPre = QTransform();
QTransform matrixAft = QTransform();
QTransform matrixPre;
QTransform matrixAft;
switch (basepoint)
{
case 2:
matrixPre.translate(-gw/2.0, -gh/2.0);
matrixAft.translate(gw/2.0, gh/2.0);
matrixPre.translate(-gw / 2.0, -gh / 2.0);
matrixAft.translate(gw / 2.0, gh / 2.0);
break;
case 4:
matrixPre.translate(-gw, -gh);
10567,7 → 10568,7
 
if (UndoManager::undoEnabled())
{
ScItemState<QList<QTransform> > *state = new ScItemState<QList<QTransform> >(Um::Transform);
auto *state = new ScItemState<QList<QTransform> >(Um::Transform);
state->set("TRANSFORM");
state->set("DX",deltaX);
state->set("DY",deltaY);
11813,8 → 11814,8
 
void ScribusDoc::itemSelection_AlignItemRight(int i, double newX, AlignMethod how)
{
double diff=newX-AObjects[i].x2;
double width=AObjects[i].x2-AObjects[i].x1;
double diff = newX - AObjects[i].x2;
double width = AObjects[i].x2 - AObjects[i].x1;
bool resize = (how == alignByResizing && diff > -width);
if (!AObjects[i].Object->locked())
{
11830,8 → 11831,8
 
void ScribusDoc::itemSelection_AlignItemLeft(int i, double newX, AlignMethod how)
{
double diff=newX-AObjects[i].x1;
double width=AObjects[i].x2-AObjects[i].x1;
double diff = newX - AObjects[i].x1;
double width = AObjects[i].x2 - AObjects[i].x1;
bool resize = (how == alignByResizing && -diff > -width);
if (!AObjects[i].Object->locked())
{
11846,8 → 11847,8
 
void ScribusDoc::itemSelection_AlignItemBottom(int i, double newY, AlignMethod how)
{
double diff=newY-AObjects[i].y2;
double height=AObjects[i].y2-AObjects[i].y1;
double diff = newY - AObjects[i].y2;
double height = AObjects[i].y2 - AObjects[i].y1;
bool resize = (how == alignByResizing && diff > -height);
if (!AObjects[i].Object->locked())
{
11862,8 → 11863,8
 
void ScribusDoc::itemSelection_AlignItemTop(int i, double newY, AlignMethod how)
{
double diff=newY-AObjects[i].y1;
double height=AObjects[i].y2-AObjects[i].y1;
double diff = newY - AObjects[i].y1;
double height = AObjects[i].y2 - AObjects[i].y1;
bool resize = (how == alignByResizing && -diff > -height);
if (!AObjects[i].Object->locked())
{
11929,7 → 11930,7
break;
case alignLast:
newX = AObjects[alignObjectsCount-1].x1;
loopEnd = alignObjectsCount-2;
loopEnd = alignObjectsCount - 2;
break;
case alignPage:
newX = m_currentPage->xOffset();
11962,19 → 11963,19
switch (currAlignTo)
{
case alignFirst:
newX = AObjects[0].x1 + (AObjects[0].width)/2;
newX = AObjects[0].x1 + (AObjects[0].width) /2 ;
loopStart=1;
break;
case alignLast:
{
int objindex=alignObjectsCount-1;
int objindex = alignObjectsCount - 1;
newX = AObjects[objindex].x1 + (AObjects[objindex].width)/2;
loopEnd=alignObjectsCount-2;
loopEnd=alignObjectsCount - 2;
}
break;
case alignPage:
newX = m_currentPage->xOffset();
newX += m_currentPage->width()/2;
newX += m_currentPage->width() / 2;
break;
case alignMargins:
newX = m_currentPage->xOffset();
12308,22 → 12309,22
}
QMap<double,uint>::Iterator it = Xsorted.begin();
QMap<double,uint>::Iterator itend = Xsorted.end();
double minX=it.key();
double maxX=it.key();
double minX = it.key();
double maxX = it.key();
while ( it != itend)
{
if (minX>it.key())
minX=it.key();
if (maxX<it.key())
maxX=it.key();
if (minX > it.key())
minX = it.key();
if (maxX < it.key())
maxX = it.key();
++it;
}
double separation=(maxX-minX)/static_cast<double>(alignObjectsCount-1);
int i=0;
double separation = (maxX - minX) / static_cast<double>(alignObjectsCount - 1);
int i = 0;
for (QMap<double,uint>::Iterator it = Xsorted.begin(); it != Xsorted.end(); ++it)
{
double diff=minX + i*separation-AObjects[it.value()].x1;
double diff = minX + i * separation - AObjects[it.value()].x1;
if (!AObjects[it.value()].Object->locked())
AObjects[it.value()].Object->moveBy(diff, 0.0);
i++;
12340,27 → 12341,27
QMap<double,uint> Xsorted;
for (int i = 0; i < alignObjectsCount; ++i)
{
if (!Xsorted.contains(AObjects[i].x1+(AObjects[i].width)/2))
Xsorted.insert(AObjects[i].x1+(AObjects[i].width)/2, i);
if (!Xsorted.contains(AObjects[i].x1 + (AObjects[i].width) / 2))
Xsorted.insert(AObjects[i].x1 + (AObjects[i].width) / 2, i);
}
QMap<double,uint>::Iterator it = Xsorted.begin();
QMap<double,uint>::Iterator itend = Xsorted.end();
double minX=it.key();
double maxX=it.key();
double minX = it.key();
double maxX = it.key();
while ( it != itend)
{
if (minX>it.key())
minX=it.key();
if (maxX<it.key())
maxX=it.key();
if (minX > it.key())
minX = it.key();
if (maxX < it.key())
maxX = it.key();
++it;
}
double separation=(maxX-minX)/static_cast<double>(alignObjectsCount-1);
int i=0;
double separation = (maxX - minX) / static_cast<double>(alignObjectsCount - 1);
int i = 0;
for (QMap<double,uint>::Iterator it = Xsorted.begin(); it != Xsorted.end(); ++it)
{
double diff=minX + i*separation-AObjects[it.value()].x1-(AObjects[it.value()].width)/2;
double diff = minX + i * separation - AObjects[it.value()].x1 - (AObjects[it.value()].width) / 2;
if (!AObjects[it.value()].Object->locked())
AObjects[it.value()].Object->moveBy(diff, 0.0);
i++;
12382,14 → 12383,14
}
QMap<double,uint>::Iterator it = Xsorted.begin();
QMap<double,uint>::Iterator itend = Xsorted.end();
double minX=it.key();
double maxX=it.key();
double minX = it.key();
double maxX = it.key();
while ( it != itend)
{
if (minX>it.key())
minX=it.key();
if (maxX<it.key())
maxX=it.key();
if (minX > it.key())
minX = it.key();
if (maxX < it.key())
maxX = it.key();
++it;
}
12397,7 → 12398,7
int i=0;
for (QMap<double,uint>::Iterator it = Xsorted.begin(); it != Xsorted.end(); ++it)
{
double diff=minX + i*separation-AObjects[it.value()].x2;
double diff = minX + i * separation - AObjects[it.value()].x2;
if (!AObjects[it.value()].Object->locked())
AObjects[it.value()].Object->moveBy(diff, 0.0);
i++;
12423,7 → 12424,7
int right = x2Sorted[x2Sorted.keys().back()];
double minX = AObjects[left].x2;
double maxX = AObjects[right].x2;
double separation=0.0;
double separation = 0.0;
if (!usingDistance)
{
double maxX = AObjects[right].x1;
12500,22 → 12501,22
}
QMap<double,uint>::Iterator it = Ysorted.begin();
QMap<double,uint>::Iterator itend = Ysorted.end();
double minY=it.key();
double maxY=it.key();
double minY = it.key();
double maxY = it.key();
while ( it != itend)
{
if (minY>it.key())
minY=it.key();
if (maxY<it.key())
maxY=it.key();
if (minY > it.key())
minY = it.key();
if (maxY < it.key())
maxY = it.key();
++it;
}
double separation=(maxY-minY)/static_cast<double>(alignObjectsCount-1);
int i=0;
double separation = (maxY - minY) / static_cast<double>(alignObjectsCount - 1);
int i = 0;
for (QMap<double,uint>::Iterator it = Ysorted.begin(); it != Ysorted.end(); ++it)
{
double diff=minY + i*separation-AObjects[it.value()].y2;
double diff = minY + i * separation - AObjects[it.value()].y2;
if (!AObjects[it.value()].Object->locked())
AObjects[it.value()].Object->moveBy(0.0, diff);
i++;
12532,27 → 12533,27
QMap<double,uint> Ysorted;
for (int i = 0; i < alignObjectsCount; ++i)
{
if (!Ysorted.contains(AObjects[i].y1+(AObjects[i].height)/2))
Ysorted.insert(AObjects[i].y1+(AObjects[i].height)/2, i);
if (!Ysorted.contains(AObjects[i].y1 + (AObjects[i].height) / 2))
Ysorted.insert(AObjects[i].y1 + (AObjects[i].height) / 2, i);
}
QMap<double,uint>::Iterator it = Ysorted.begin();
QMap<double,uint>::Iterator itend = Ysorted.end();
double minY=it.key();
double maxY=it.key();
double minY = it.key();
double maxY = it.key();
while ( it != itend)
{
if (minY>it.key())
minY=it.key();
if (maxY<it.key())
maxY=it.key();
if (minY > it.key())
minY = it.key();
if (maxY < it.key())
maxY = it.key();
++it;
}
double separation=(maxY-minY)/static_cast<double>(alignObjectsCount-1);
int i=0;
double separation = (maxY - minY) / static_cast<double>(alignObjectsCount - 1);
int i = 0;
for (QMap<double,uint>::Iterator it = Ysorted.begin(); it != Ysorted.end(); ++it)
{
double diff=minY + i*separation-AObjects[it.value()].y1-(AObjects[it.value()].height)/2;
double diff = minY + i * separation - AObjects[it.value()].y1 - AObjects[it.value()].height / 2;
if (!AObjects[it.value()].Object->locked())
AObjects[it.value()].Object->moveBy(0.0, diff);
i++;
12574,22 → 12575,22
}
QMap<double,uint>::Iterator it = Ysorted.begin();
QMap<double,uint>::Iterator itend = Ysorted.end();
double minY=it.key();
double maxY=it.key();
double minY = it.key();
double maxY = it.key();
while ( it != itend)
{
if (minY>it.key())
minY=it.key();
if (maxY<it.key())
maxY=it.key();
if (minY > it.key())
minY = it.key();
if (maxY < it.key())
maxY = it.key();
++it;
}
double separation=(maxY-minY)/static_cast<double>(alignObjectsCount-1);
int i=0;
double separation = (maxY - minY) / static_cast<double>(alignObjectsCount - 1);
int i = 0;
for (QMap<double,uint>::Iterator it = Ysorted.begin(); it != Ysorted.end(); ++it)
{
double diff=minY + i*separation-AObjects[it.value()].y1;
double diff = minY + i * separation - AObjects[it.value()].y1;
if (!AObjects[it.value()].Object->locked())
AObjects[it.value()].Object->moveBy(0.0,diff);
i++;
13365,7 → 13366,7
dV2 += selection.height();
}
ScriXmlDoc ss;
QString BufferS = ss.writeElem(this, &selection);
QString BufferS = ScriXmlDoc::writeElem(this, &selection);
//FIXME: stop using m_View
Selection tempSelection(nullptr, false);
m_View->deselectItems(true);
13418,7 → 13419,7
double dX = mdData.gridGapH / m_docUnitRatio + selection.width();
double dY = mdData.gridGapV / m_docUnitRatio + selection.height();
ScriXmlDoc ss;
QString BufferS = ss.writeElem(this, &selection);
QString BufferS = ScriXmlDoc::writeElem(this, &selection);
for (int i = 0; i < mdData.gridRows; ++i) //skip 0, the item is the one we are copying
{
for (int j = 0; j < mdData.gridCols; ++j) //skip 0, the item is the one we are copying
13532,7 → 13533,7
 
ScPage* oldCurrentPage = currentPage();
ScriXmlDoc xmlStream;
QString buffer = xmlStream.writeElem(this, &selection);
QString buffer = ScriXmlDoc::writeElem(this, &selection);
for (const auto page: pages)
{
if (currPageNumber == page - 1)
14277,7 → 14278,7
QRectF newR(currItem->getBoundingRect());
invalidateRegion(newR.united(oldR));
}
if ((redraw) && (!m_loading))
if (redraw && !m_loading)
{
QRectF newR(currItem->getBoundingRect());
QRectF updateRect = newR.united(oldR);
14307,7 → 14308,7
return true;
}
 
bool ScribusDoc::moveSizeItem(const FPoint& newX, const FPoint& newY, PageItem* currItem, bool fromMP, bool constrainRotation)
bool ScribusDoc::moveSizeItem(const FPoint& newX, const FPoint& newY, PageItem* currItem, bool fromMP)
{
QRectF oldR(currItem->getBoundingRect());
if (currItem->isLine())
14318,9 → 14319,9
double mx = ma.m11() * currItem->width() + ma.dx();
double my = ma.m12() * currItem->width() + ma.dy();
moveItem(newX.x(), newX.y(), currItem);
double newRot=xy2Deg(mx - currItem->xPos(), my - currItem->yPos());
double newRot = xy2Deg(mx - currItem->xPos(), my - currItem->yPos());
currItem->setRotation(newRot);
currItem->setWidthHeight(sqrt(pow(mx - currItem->xPos(),2)+pow(my - currItem->yPos(),2)), 1.0);
currItem->setWidthHeight(sqrt(pow(mx - currItem->xPos(), 2) + pow(my - currItem->yPos(), 2)), 1.0);
currItem->updateClip();
setRedrawBounding(currItem);
QRectF newR(currItem->getBoundingRect());
14515,7 → 14516,7
ma.translate(RCenter.x(), RCenter.y());
ma.scale(1, 1);
ma.rotate(angle);
QRect oldR = QRect(static_cast<int>(gxS*sc-5), static_cast<int>(gyS*sc-5), static_cast<int>(gwS*sc+10), static_cast<int>(ghS*sc+10));
QRect oldR(static_cast<int>(gxS * sc - 5), static_cast<int>(gyS * sc - 5), static_cast<int>(gwS * sc + 10), static_cast<int>(ghS * sc + 10));
FPoint n;
for (int a = 0; a < itemSelection->count(); ++a)
{
14545,7 → 14546,7
int drm = m_rotMode;
m_rotMode = 0;
itemSelection->getGroupRect(&gx, &gy, &gw, &gh);
QRect oldR(static_cast<int>(gx*sc-5), static_cast<int>(gy*sc-5), static_cast<int>(gw*sc+10), static_cast<int>(gh*sc+10));
QRect oldR(static_cast<int>(gx * sc - 5), static_cast<int>(gy * sc - 5), static_cast<int>(gw * sc + 10), static_cast<int>(gh * sc + 10));
itemSelection->getGroupRect(&gx, &gy, &gw, &gh);
double origGW = gw;
double origGH = gh;
15057,7 → 15058,7
itemSelection->addItem(groupItem);
 
GroupCounter++;
QRectF regionToUpdate = QRectF(gx - 5, gy - 5, gw + 10, gh + 10);
QRectF regionToUpdate(gx - 5, gy - 5, gw + 10, gh + 10);
if (needTextInteractionCheck)
invalidateRegion(regionToUpdate);
regionsChanged()->update(needTextInteractionCheck ? QRectF() : regionToUpdate);
15165,7 → 15166,7
if (itemSelection->count() > 0)
m_ScMW->HaveNewSel();
 
QRectF regionToUpdate = QRectF(x - 5, y - 5, w + 10, h + 10);
QRectF regionToUpdate(x - 5, y - 5, w + 10, h + 10);
if (needTextInteractionCheck)
invalidateRegion(regionToUpdate);
regionsChanged()->update(needTextInteractionCheck ? QRectF() : regionToUpdate);
15185,7 → 15186,7
QTransform mm;
mm.rotate(gRot);
mm.scale(1.0 / grScXi, 1.0 / grScYi);
QLineF d = QLineF(0.0, 0.0, itPos.x() - grPos.x(), itPos.y() - grPos.y());
QLineF d(0.0, 0.0, itPos.x() - grPos.x(), itPos.y() - grPos.y());
d = mm.map(d);
item->gXpos = d.p2().x();
item->gYpos = d.p2().y();
15671,7 → 15672,7
m_ScMW->patternsDependingOnThis.prepend(getEditedSymbol());
allItems.clear();
 
ScPattern pat = ScPattern();
ScPattern pat;
pat.setDoc(this);
double minx = std::numeric_limits<double>::max();
double miny = std::numeric_limits<double>::max();
16177,7 → 16178,7
QMap<QString,int>::Iterator it3;
UsedFonts.clear();
QStringList::Iterator it3a;
QStringList::Iterator it3aend=uf.end();
QStringList::Iterator it3aend = uf.end();
for (it3a = uf.begin(); it3a != it3aend; ++it3a)
AddFont(*it3a);
 
17032,7 → 17033,7
//used by MarksManager
if (UndoManager::undoEnabled())
{
ScItemsState* ims = new ScItemsState(Um::DeleteMark, "", Um::IDelete);
auto* ims = new ScItemsState(Um::DeleteMark, "", Um::IDelete);
if (mrk->isUnique())
{
ims->set("MARK", QString("delete"));
17255,9 → 17256,9
getUniqueName(nsName, nsNames, "_");
newNS->setName(nsName);
m_docNotesStylesList.append(newNS);
if (m_undoManager->undoEnabled())
if (UndoManager::undoEnabled())
{
SimpleState* ss = new SimpleState(UndoManager::NewNotesStyle);
auto* ss = new SimpleState(UndoManager::NewNotesStyle);
ss->set("NSTYLE", QString("new"));
undoSetNotesStyle(ss, newNS);
m_undoManager->action(this, ss);
17307,7 → 17308,7
if (activeTransaction)
{
//undo is enabled
SimpleState* ss = new SimpleState(UndoManager::DeleteNotesStyle);
auto* ss = new SimpleState(UndoManager::DeleteNotesStyle);
ss->set("NSTYLE", QString("delete"));
undoSetNotesStyle(ss, noteStyle);
m_undoManager->action(this, ss);
17391,7 → 17392,7
{
if (UndoManager::undoEnabled())
{
ScItemsState* ims = new ScItemsState(Um::DeleteNote,"",Um::IDelete);
auto* ims = new ScItemsState(Um::DeleteNote,"",Um::IDelete);
ims->set("DELETE_NOTE");
PageItem* master = note->masterMark()->getItemPtr();
int pos = findMarkCPos(note->masterMark(), master);
/trunk/Scribus/scribus/scribusdoc.h
100,7 → 100,7
void init();
bool inAnEditMode() const;
bool inASpecialEditMode() const;
QList<PageItem*> getAllItems(QList<PageItem*> &items);
QList<PageItem*> getAllItems(QList<PageItem*> &items) const;
QList<PageItem*> *parentGroup(PageItem* item, QList<PageItem*> *list);
void setup(int, int, int, int, int, const QString&, const QString&);
void setLoading(bool);
171,6 → 171,8
PDFOptions& pdfOptions() { return m_docPrefsData.pdfPrefs; }
 
ObjAttrVector& itemAttributes() { return m_docPrefsData.itemAttrPrefs.defaultItemAttributes; }
const ObjAttrVector& itemAttributes() const { return m_docPrefsData.itemAttrPrefs.defaultItemAttributes; }
 
void setItemAttributes(ObjAttrVector& oav) { m_docPrefsData.itemAttrPrefs.defaultItemAttributes=oav;}
void clearItemAttributes() { m_docPrefsData.itemAttrPrefs.defaultItemAttributes.clear(); }
void appendToItemAttributes(const ObjectAttribute& oa) { m_docPrefsData.itemAttrPrefs.defaultItemAttributes.append(oa); }
617,10 → 619,10
bool styleExists(const QString& styleName) const;
bool charStyleExists(const QString& styleName) const;
QList<int> getSortedStyleList();
QList<int> getSortedCharStyleList();
QList<int> getSortedTableStyleList();
QList<int> getSortedCellStyleList();
QList<int> getSortedStyleList() const;
QList<int> getSortedCharStyleList() const;
QList<int> getSortedTableStyleList() const;
QList<int> getSortedCellStyleList() const;
void redefineStyles(const StyleSet<ParagraphStyle>& newStyles, bool removeUnused=false);
/**
675,7 → 677,7
/*!
* @brief Returns a stringlist of the item attributes within the document
*/
QStringList getItemAttributeNames();
QStringList getItemAttributeNames() const;
 
bool AddFont(const QString& name, int fsize = 10);
/*!
942,11 → 944,11
* @retval double containing the offset. Returns -1.0 if page not in Pages list (as -ve is not possible).
* Mostly saves bringing in extra includes into files that already have scribusdoc.h
*/
double getXOffsetForPage(int);
double getYOffsetForPage(int);
void getBleeds(int pageNumber, MarginStruct& bleedData);
void getBleeds(const ScPage* page, MarginStruct& bleedData);
void getBleeds(const ScPage* page, const MarginStruct& baseValues, MarginStruct& bleedData);
double getXOffsetForPage(int) const;
double getYOffsetForPage(int) const;
void getBleeds(int pageNumber, MarginStruct& bleedData) const;
void getBleeds(const ScPage* page, MarginStruct& bleedData) const;
void getBleeds(const ScPage* page, const MarginStruct& baseValues, MarginStruct& bleedData) const;
/**
* @brief Item type conversion functions
1247,7 → 1249,7
void rotateItem(double win, PageItem *currItem);
void moveRotated(PageItem *currItem, const FPoint& npv);
bool sizeItem(double newX, double newY, PageItem *pi, bool fromMP = false, bool DoUpdateClip = true, bool redraw = true);
bool moveSizeItem(const FPoint& newX, const FPoint& newY, PageItem* currItem, bool fromMP = false, bool constrainRotation = false);
bool moveSizeItem(const FPoint& newX, const FPoint& newY, PageItem* currItem, bool fromMP = false);
void adjustItemSize(PageItem *currItem, bool includeGroup = false);
void moveGroup(double x, double y, Selection* customSelection = nullptr);
void rotateGroup(double angle, Selection* customSelection = nullptr);
/trunk/Scribus/scribus/scribusview.cpp
129,9 → 129,7
m_canvas(new Canvas(doc, this)),
Prefs(&(PrefsManager::instance().appPrefs)),
undoManager(UndoManager::instance()),
m_ScMW(mw),
RCenter(-1,-1),
m_vhRulerHW(17)
m_ScMW(mw)
{
setObjectName("s");
QPalette p=palette();
513,113 → 511,8
}
if (updateNecessary)
updateCanvas();
//setCursorBasedOnAppMode(appMode);
}
 
/*
void ScribusView::setCursorBasedOnAppMode(int appMode)
{
IconManager* im=IconManager::instance();
int docSelectionCount = Doc->m_Selection->count();
switch (appMode)
{
case modeDrawShapes:
case modeDrawArc:
case modeDrawSpiral:
if (docSelectionCount!=0)
Deselect(true);
setCursor(im->loadCursor("drawframe.png"));
break;
case modeDrawImage:
if (docSelectionCount!=0)
Deselect(true);
setCursor(im->loadCursor("drawimageframe.png"));
break;
case modeDrawLatex:
if (docSelectionCount!=0)
Deselect(true);
setCursor(im->loadCursor("drawlatexframe.png"));
break;
case modeDrawText:
if (docSelectionCount!=0)
Deselect(true);
setCursor(im->loadCursor("drawtextframe.png"));
break;
case modeDrawTable2:
if (docSelectionCount!=0)
Deselect(true);
setCursor(im->loadCursor("drawtable.png"));
break;
case modeDrawRegularPolygon:
if (docSelectionCount!=0)
Deselect(true);
setCursor(im->loadCursor("drawpolyline.png"));
break;
case modeMagnifier:
if (docSelectionCount!=0)
Deselect(true);
Magnify = true;
setCursor(im->loadCursor("lupez.png"));
break;
case modePanning:
setCursor(im->loadCursor("handc.png"));
break;
case modeDrawLine:
case modeDrawBezierLine:
setCursor(QCursor(Qt::CrossCursor));
break;
case modeDrawCalligraphicLine:
case modeDrawFreehandLine:
setCursor(im->loadCursor("DrawFreeLine.png", 0, 32));
break;
case modeEyeDropper:
setCursor(im->loadCursor("colorpickercursor.png", 0, 32));
break;
case modeInsertPDFButton:
case modeInsertPDFRadioButton:
case modeInsertPDFTextfield:
case modeInsertPDFCheckbox:
case modeInsertPDFCombobox:
case modeInsertPDFListbox:
case modeInsertPDFTextAnnotation:
case modeInsertPDFLinkAnnotation:
case modeInsertPDF3DAnnotation:
if (docSelectionCount!=0)
Deselect(true);
setCursor(QCursor(Qt::CrossCursor));
break;
case modeLinkFrames:
setCursor(im->loadCursor("LinkTextFrame.png", 0, 31));
break;
case modeMeasurementTool:
case modeEditGradientVectors:
case modeEditMeshGradient:
case modeEditArc:
case modeEditPolygon:
case modeEditSpiral:
setCursor(QCursor(Qt::CrossCursor));
break;
default:
setCursor(QCursor(Qt::ArrowCursor));
break;
}
}
*/
 
 
/*
void ScribusView::paintEvent ( QPaintEvent * p )
{
#ifndef _WIN32
if (p->spontaneous())
evSpon = true;
#endif
QScrollArea::paintEvent(p);
// QPainter qp(viewport());
// drawContents(&qp, p->rect().x(), p->rect().y(), p->rect().width(), p->rect().height());
}
*/
 
void ScribusView::enterEvent(QEvent * e)
{
m_canvasMode->enterEvent(e);
673,8 → 566,8
if (ss.readElemHeader(text, fromFile, &gx, &gy, &gw, &gh))
{
FPoint dragPosDoc = m_canvas->globalToCanvas(widget()->mapToGlobal(e->pos()));
dragX = dragPosDoc.x(); //e->pos().x() / m_canvas->scale();
dragY = dragPosDoc.y(); //e->pos().y() / m_canvas->scale();
dragX = dragPosDoc.x();
dragY = dragPosDoc.y();
dragW = gw;
dragH = gh;
DraggedGroup = true;
998,7 → 891,7
// qDebug() << "drop - img:" << img << "file:" << fi.exists() << "suffix:" << fi.suffix() << "select by drag:" << selectedItemByDrag;
//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 && !vectorFile)// && (!SeleItemPos(e->pos())))
if ((fi.exists()) && img && !selectedItemByDrag && !vectorFile)// && (!SeleItemPos(e->pos())))
{
int z = m_doc->itemAdd(PageItem::ImageFrame, PageItem::Unspecified, dropPosDoc.x(), dropPosDoc.y(), 1, 1, m_doc->itemToolPrefs().shapeLineWidth, m_doc->itemToolPrefs().imageFillColor, m_doc->itemToolPrefs().imageStrokeColor);
PageItem *item = m_doc->Items->at(z);
1037,17 → 930,17
update();
return;
}
if (selectedItemByDrag && (m_canvas->frameHitTest(dropPosDocQ, m_doc->m_Selection->itemAt(0)) >= Canvas::INSIDE) && ((!vectorFile) || (img)))
if (selectedItemByDrag && (m_canvas->frameHitTest(dropPosDocQ, m_doc->m_Selection->itemAt(0)) >= Canvas::INSIDE) && (!vectorFile || img))
{
PageItem *item = m_doc->m_Selection->itemAt(0);
if (item->itemType() == PageItem::ImageFrame)
{
if ((fi.exists()) && (img))
if (fi.exists() && img)
m_doc->loadPict(url.toLocalFile(), item);
}
else if (item->itemType() == PageItem::TextFrame)
{
if ((fi.exists()) && (!img))
if (fi.exists() && !img)
{
gtGetText* gt = new gtGetText(m_doc);
QStringList exts = gt->getSupportedTypes();
1547,7 → 1440,7
undoManager->setUndoEnabled(false);
currItem->checkChanges(true);
undoManager->setUndoEnabled(true);
SimpleState *ss = new SimpleState(Um::EditContourLine, "", Um::IBorder);
auto *ss = new SimpleState(Um::EditContourLine, "", Um::IBorder);
ss->set("EDIT_CONTOUR");
ss->set("MODE", mode);
ss->set("ROT", rot);
1652,7 → 1545,7
undoManager->setUndoEnabled(false);
currItem->checkChanges(true);
undoManager->setUndoEnabled(true);
SimpleState *ss = new SimpleState(Um::EditShape, "", Um::IBorder);
auto *ss = new SimpleState(Um::EditShape, "", Um::IBorder);
ss->set("EDIT_SHAPE");
ss->set("MODE", mode);
ss->set("ROT", rot);
2105,13 → 1998,12
vertRuler->shiftRel(0*m_doc->minCanvasCoordinate.y() - m_doc->rulerYoffset);
horizRuler->update();
vertRuler->update();
// evSpon = true;
QString newStatusBarText(" ");
if ((verticalScrollBar()->isSliderDown()) || (horizontalScrollBar()->isSliderDown()))
{
QList<int> pag;
pag.clear();
int docPageCount=m_doc->Pages->count();
int docPageCount = m_doc->Pages->count();
for (int i = 0; i < docPageCount; ++i)
{
int xs = static_cast<int>(m_doc->Pages->at(i)->xOffset() * m_canvas->scale());
2118,7 → 2010,7
int ys = static_cast<int>(m_doc->Pages->at(i)->yOffset() * m_canvas->scale());
int ws = static_cast<int>(m_doc->Pages->at(i)->width() * m_canvas->scale());
int hs = static_cast<int>(m_doc->Pages->at(i)->height() * m_canvas->scale());
QRect drawRect = QRect(x, y, visibleWidth(), visibleHeight());
QRect drawRect(x, y, visibleWidth(), visibleHeight());
// drawRect.moveBy(qRound(-Doc->minCanvasCoordinate.x() * m_canvas->scale()), qRound(-Doc->minCanvasCoordinate.y() * m_canvas->scale()));
if (drawRect.intersects(QRect(xs, ys, ws, hs)))
pag.append(i+1);
2239,7 → 2131,7
{
double scale = m_canvas->scale();
horizontalScrollBar()->setValue(qRound(horizontalScrollBar()->value() + deltaX * scale));
verticalScrollBar()->setValue(qRound(verticalScrollBar()->value() + deltaX * scale));
verticalScrollBar()->setValue(qRound(verticalScrollBar()->value() + deltaY * scale));
}
 
 
2344,7 → 2236,8
void ScribusView::slotZoomOut(int mx, int my, bool preservePoint)
{
// FIXME : mx and my should really be ScribusView local coordinates or global coordinates
int oldZoomX(mx), oldZoomY(my);
int oldZoomX(mx);
int oldZoomY(my);
if ((mx == 0) && (my == 0))
{
double x = qMax(contentsX() / m_canvas->scale(), m_doc->minCanvasCoordinate.x());
2386,9 → 2279,6
updateContents();
setRulerPos(contentsX(), contentsY());
m_ScMW->slotSetCurrentPage(m_doc->currentPage()->pageNr());
// disconnect(m_ScMW->zoomSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setZoom()));
// m_ScMW->zoomSpinBox->setValue(m_canvas->scale()/Prefs->displayPrefs.displayScale*100);
// connect(m_ScMW->zoomSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setZoom()));
}
 
void ScribusView::setCanvasCenterPos(double x, double y)
2582,7 → 2472,7
setScale(1.0);
m_canvas->setPreviewMode(true);
m_canvas->setForcedRedraw(true);
QImage pm = QImage(clipw, cliph, QImage::Format_ARGB32_Premultiplied);
QImage pm(clipw, cliph, QImage::Format_ARGB32_Premultiplied);
ScPainter *painter = new ScPainter(&pm, pm.width(), pm.height(), 1.0, 0);
painter->clear(m_doc->paperColor());
painter->translate(-clipx, -clipy);
2717,7 → 2607,7
if ((m_doc->Items->count() != 0) && !flags.testFlag(Pixmap_DontReloadImages))
{
FPoint orig = m_canvas->localToCanvas(QPoint(clipx, clipy));
QRectF cullingArea = QRectF(orig.x(), orig.y(), qRound(clipw / sc + 0.5), qRound(cliph / sc + 0.5));
QRectF cullingArea(orig.x(), orig.y(), qRound(clipw / sc + 0.5), qRound(cliph / sc + 0.5));
QList<PageItem*> itemList = *(m_doc->Items);
while (itemList.count() > 0)
{
2956,7 → 2846,7
ScribusView* m_view;
PageItem* m_item;
QList<PageItem*> &m_group;
int m_counter;
int m_counter { 0 };
 
public:
TextToPathPainter(ScribusView* view, PageItem* item, QList<PageItem*> &group)
2963,7 → 2853,6
: m_view(view)
, m_item(item)
, m_group(group)
, m_counter(0)
{}
 
void drawGlyph(const GlyphCluster& gc) override
3114,7 → 3003,7
m_group.append(m_view->m_doc->Items->takeAt(z));
}
 
void drawRect(QRectF rect) override {}
void drawRect(const QRectF& rect) override {}
void drawObject(PageItem* item) override {}
};
 
/trunk/Scribus/scribus/scribusview.h
119,7 → 119,6
};
void requestMode(int appMode);
// void setCursorBasedOnAppMode(int appMode);
void startGesture(CanvasGesture*);
void stopGesture();
157,7 → 156,7
bool m_EditModeWasOn;
bool m_ChangedState;
SelectionRubberBand *redrawMarker;
FPoint RCenter;
FPoint RCenter { -1.0, -1.0 };
FPoint m_mousePointDoc;
void updatesOn(bool on);
//CB This MUST now be called AFTER a call to doc->addPage or doc->addMasterPage as it
351,7 → 350,7
virtual void setVBarGeometry(QScrollBar &bar, int x, int y, int w, int h);
//The width of vertical ruler/height of horizontal ruler, set to 17 in scribusview.cpp
int m_vhRulerHW;
int m_vhRulerHW { 17 };
 
signals:
void unitChanged(int);
/trunk/Scribus/scribus/text/screenpainter.cpp
289,7 → 289,7
m_painter->restore();
}
 
void ScreenPainter::drawRect(QRectF rect)
void ScreenPainter::drawRect(const QRectF& rect)
{
m_painter->save();
setupState(true);
/trunk/Scribus/scribus/text/screenpainter.h
24,7 → 24,7
void drawGlyph(const GlyphCluster& gc) override;
void drawGlyphOutline(const GlyphCluster& gc, bool fill) override;
void drawLine(QPointF start, QPointF end) override;
void drawRect(QRectF rect) override;
void drawRect(const QRectF& rect) override;
void drawObject(PageItem* embedded) override;
 
void clip(QRectF rect);
/trunk/Scribus/scribus/text/textlayoutpainter.h
121,7 → 121,7
/// Draws a rectangle at current x and y positions, using current stoke
/// color and width for its border, and filled with the current fill
/// color.
virtual void drawRect(QRectF rect) = 0;
virtual void drawRect(const QRectF& rect) = 0;
/// Draws and embedded page item at the current x and y positions.
virtual void drawObject(PageItem* item) = 0;