From ae9da263ab725567602a87a7d57228f78c31b63d Mon Sep 17 00:00:00 2001 From: Ronan Le Tiec Date: Sun, 23 Oct 2016 11:11:00 +0200 Subject: [PATCH 1/2] issue #570 tiled pdf case when margin smaller than min --HG-- branch : feature --- src/app/valentina/core/vcmdexport.cpp | 1 + .../valentina/core/vformulapropertyeditor.cpp | 2 ++ .../core/vtooloptionspropertybrowser.cpp | 2 ++ src/app/valentina/dialogs/dialoghistory.cpp | 1 + .../valentina/dialogs/dialogsavelayout.cpp | 1 + src/app/valentina/mainwindowsnogui.cpp | 22 ++++++++++++++++- src/app/valentina/xml/vpattern.cpp | 2 ++ src/libs/ifc/xml/vdomdocument.h | 1 + src/libs/vlayout/vposter.cpp | 24 +++++++++++++++++-- .../vtools/undocommands/savedetailoptions.cpp | 1 + 10 files changed, 54 insertions(+), 3 deletions(-) diff --git a/src/app/valentina/core/vcmdexport.cpp b/src/app/valentina/core/vcmdexport.cpp index f6d1c7d9a..f938970f3 100644 --- a/src/app/valentina/core/vcmdexport.cpp +++ b/src/app/valentina/core/vcmdexport.cpp @@ -33,6 +33,7 @@ #include "../vformat/vmeasurements.h" #include "../vmisc/commandoptions.h" #include "../vmisc/vsettings.h" +#include VCommandLinePtr VCommandLine::instance = nullptr; diff --git a/src/app/valentina/core/vformulapropertyeditor.cpp b/src/app/valentina/core/vformulapropertyeditor.cpp index ca671c9c2..0100c8741 100644 --- a/src/app/valentina/core/vformulapropertyeditor.cpp +++ b/src/app/valentina/core/vformulapropertyeditor.cpp @@ -33,6 +33,8 @@ #include #include #include +#include +#include #include "../vpropertyexplorer/vproperty.h" #include "../vtools/dialogs/support/dialogeditwrongformula.h" diff --git a/src/app/valentina/core/vtooloptionspropertybrowser.cpp b/src/app/valentina/core/vtooloptionspropertybrowser.cpp index 864e44aae..40183cc34 100644 --- a/src/app/valentina/core/vtooloptionspropertybrowser.cpp +++ b/src/app/valentina/core/vtooloptionspropertybrowser.cpp @@ -40,6 +40,8 @@ #include #include +#include +#include using namespace VPE; diff --git a/src/app/valentina/dialogs/dialoghistory.cpp b/src/app/valentina/dialogs/dialoghistory.cpp index 3fd144b6b..bd177bdea 100644 --- a/src/app/valentina/dialogs/dialoghistory.cpp +++ b/src/app/valentina/dialogs/dialoghistory.cpp @@ -39,6 +39,7 @@ #include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.h" #include "../xml/vpattern.h" #include "../vmisc/diagnostic.h" +#include //--------------------------------------------------------------------------------------------------------------------- /** diff --git a/src/app/valentina/dialogs/dialogsavelayout.cpp b/src/app/valentina/dialogs/dialogsavelayout.cpp index f4cb267cd..6faed5795 100644 --- a/src/app/valentina/dialogs/dialogsavelayout.cpp +++ b/src/app/valentina/dialogs/dialogsavelayout.cpp @@ -38,6 +38,7 @@ #include #include #include +#include const QString baseFilenameRegExp = QStringLiteral("^[\\w\\-. ]+$"); diff --git a/src/app/valentina/mainwindowsnogui.cpp b/src/app/valentina/mainwindowsnogui.cpp index 8dd23ae17..d5a0eab35 100644 --- a/src/app/valentina/mainwindowsnogui.cpp +++ b/src/app/valentina/mainwindowsnogui.cpp @@ -383,7 +383,27 @@ void MainWindowsNoGUI::PrintPages(QPrinter *printer) // Render QRectF source; isTiled ? source = poster->at(index).rect : source = paper->rect(); - QRectF target(0, 0, source.width() * scale, source.height() * scale); + + qreal x,y; + if(printer->fullPage()) + { + #if QT_VERSION >= QT_VERSION_CHECK(5, 3, 0) + QMarginsF printerMargins = printer->pageLayout().margins(); + x = qFloor(ToPixel(printerMargins.left(),Unit::Mm)); + y = qFloor(ToPixel(printerMargins.top(),Unit::Mm)); + #else + qreal left = 0, top = 0, right = 0, bottom = 0; + printer->getPageMargins(&left, &top, &right, &bottom, QPrinter::Millimeter); + x = qFloor(ToPixel(left,Unit::Mm)); + y = qFloor(ToPixel(top,Unit::Mm)); + #endif + } + else + { + x = 0; y = 0; + } + + QRectF target(x * scale, y * scale, source.width() * scale, source.height() * scale); scenes.at(paperIndex)->render(&painter, target, source, Qt::IgnoreAspectRatio); diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index ce88bb98b..e2d6fe44f 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -55,6 +55,8 @@ #include #include #include +#include +#include const QString VPattern::AttrReadOnly = QStringLiteral("readOnly"); diff --git a/src/libs/ifc/xml/vdomdocument.h b/src/libs/ifc/xml/vdomdocument.h index 3bb8875cd..1d1ed589b 100644 --- a/src/libs/ifc/xml/vdomdocument.h +++ b/src/libs/ifc/xml/vdomdocument.h @@ -40,6 +40,7 @@ #include #include #include +#include #include "../ifc/ifcdef.h" #include "../vmisc/def.h" diff --git a/src/libs/vlayout/vposter.cpp b/src/libs/vlayout/vposter.cpp index d413ab148..34d05b03f 100644 --- a/src/libs/vlayout/vposter.cpp +++ b/src/libs/vlayout/vposter.cpp @@ -267,8 +267,28 @@ QRect VPoster::PageRect() const // we can't use method pageRect(QPrinter::Point). Our dpi value can be different. // We convert value yourself to pixels. const QRectF rect = printer->pageRect(QPrinter::Millimeter); - const QRect pageRect(0, 0, qFloor(ToPixel(rect.width())), qFloor(ToPixel(rect.height()))); - return pageRect; + + if(printer->fullPage()) + { + #if QT_VERSION >= QT_VERSION_CHECK(5, 3, 0) + QMarginsF pMargins = printer->pageLayout().margins(); + QRectF newRect = rect.marginsRemoved(pMargins); + const QRect pageRectFP(0, 0, qFloor(ToPixel(newRect.width())), qFloor(ToPixel(newRect.height()))); + return pageRectFP; + #else + qreal left = 0 , top = 0, right = 0, bottom = 0; + printer->getPageMargins(&left, &top, &right, &bottom, QPrinter::Millimeter); + qreal newWidth = rect.width()-left-right; + qreal newHeight = rect.height()-top-bottom; + const QRect pageRectFP(0, 0, qFloor(ToPixel(newWidth)), qFloor(ToPixel(newHeight))); + return pageRectFP; + #endif + } + else + { + const QRect pageRect(0, 0, qFloor(ToPixel(rect.width())), qFloor(ToPixel(rect.height()))); + return pageRect; + } } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/undocommands/savedetailoptions.cpp b/src/libs/vtools/undocommands/savedetailoptions.cpp index 7da804348..31458d809 100644 --- a/src/libs/vtools/undocommands/savedetailoptions.cpp +++ b/src/libs/vtools/undocommands/savedetailoptions.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include "../ifc/xml/vabstractpattern.h" #include "../ifc/ifcdef.h" From cabb3957e4c4dd42abedc2de7f03f9c7b6ccfbe4 Mon Sep 17 00:00:00 2001 From: Ronan Le Tiec Date: Sun, 23 Oct 2016 09:18:05 +0000 Subject: [PATCH 2/2] ChangeLog.txt edited for #570 --HG-- branch : feature --- ChangeLog.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog.txt b/ChangeLog.txt index 60b3df9cd..3a86be3b1 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -42,6 +42,7 @@ - [#138] New tool: 'Mirror Point' or 'Symmetric Point'. - [#573] New tool: 'Move Point'. - [#577] 10 new colors added for the lines +- [#570] Tiled PDF : Margin values correctly taken into account # Version 0.4.5 October 15, 2016 - [#435] Valentina doesn't change the cursor.