Skip to content

Commit 1117038

Browse files
committed
0.2023.08.10: page_layout: fix bad page width for margin
1 parent 29f9194 commit 1117038

File tree

4 files changed

+15
-7
lines changed

4 files changed

+15
-7
lines changed

src/filters/page_layout/ImageView.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,10 @@ ImageView::forceNonNegativeHardMargins(QRectF& middle_rect) const
691691
RelativeMargins
692692
ImageView::calcHardMargins() const
693693
{
694-
qreal const scale = 1.0 / m_innerRect.width();
694+
qreal pagewidth = m_innerRect.width();
695+
qreal pagewidthheight = m_innerRect.height() * 0.7071067811865475244;
696+
pagewidth = (pagewidth < pagewidthheight) ? pagewidthheight : pagewidth;
697+
qreal const scale = 1.0 / pagewidth;
695698
return RelativeMargins(
696699
(m_innerRect.left() - m_middleRect.left()) * scale,
697700
(m_innerRect.top() - m_middleRect.top()) * scale,

src/filters/page_layout/PageLayout.cpp

+9-3
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,13 @@ PageLayout::PageLayout(
5050
// aggregate_size = content_size * scale + margins * width * scale
5151
// Solving for scale:
5252
// scale = aggregate_size / (content_size + margins * width)
53+
qreal pagewidth = m_innerRect.width();
54+
qreal pagewidthheight = m_innerRect.height() * 0.7071067811865475244;
55+
pagewidth = (pagewidth < pagewidthheight) ? pagewidthheight : pagewidth;
5356
qreal const x_scale = aggregate_hard_size.width() /
54-
(m_innerRect.width() + (margins.left() + margins.right()) * m_innerRect.width());
57+
(m_innerRect.width() + (margins.left() + margins.right()) * pagewidth);
5558
qreal const y_scale = aggregate_hard_size.height() /
56-
(m_innerRect.height() + (margins.top() + margins.bottom()) * m_innerRect.width());
59+
(m_innerRect.height() + (margins.top() + margins.bottom()) * pagewidth);
5760

5861
if (x_scale > 1.0 && y_scale > 1.0)
5962
{
@@ -73,9 +76,12 @@ PageLayout::PageLayout(
7376
);
7477
}
7578

79+
qreal pagewidth = m_innerRect.width();
80+
qreal pagewidthheight = m_innerRect.height() * 0.7071067811865475244;
81+
pagewidth = (pagewidth < pagewidthheight) ? pagewidthheight : pagewidth;
7682
if (have_content_box)
7783
{
78-
m_middleRect = margins.extendContentRect(m_innerRect);
84+
m_middleRect = margins.extendContentRect(m_innerRect, pagewidth);
7985
}
8086
else
8187
{

src/foundation/RelativeMargins.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,8 @@ class FOUNDATION_EXPORT RelativeMargins
3737
RelativeMargins(double left, double top, double right, double bottom)
3838
: m_top(top), m_bottom(bottom), m_left(left), m_right(right) {}
3939

40-
QRectF extendContentRect(QRectF const& rect) const
40+
QRectF extendContentRect(QRectF const& rect, double const scale) const
4141
{
42-
double const scale = rect.width();
4342
return rect.adjusted(-m_left * scale, -m_top * scale, m_right * scale, m_bottom * scale);
4443
}
4544

src/version.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@
2020
#define SCANTAILOR_VERSION_H_
2121

2222
#define VERSION "experimental"
23-
#define VERSION_QUAD "0.2023.08.09" // Must be "x.x.x.x" or an empty string.
23+
#define VERSION_QUAD "0.2023.08.10" // Must be "x.x.x.x" or an empty string.
2424

2525
#endif

0 commit comments

Comments
 (0)