Kaydet (Commit) 3a2ccb41 authored tarafından Miklos Vajna's avatar Miklos Vajna

tdf#108056 PDF export: work with double page size

Our coordinate system has the origo in the top left corner, PDF's one is
at the bottom left corner. So the page height affects the coordinate of
all widths and y positions. That page width is 870.25 in the case of the
bugdoc, but it was handled as 870 due to the integer rounding. The
coordinates and heights are now closer to the expected ones.

(cherry picked from commit a05dc747)

Change-Id: I9c7d77298df3850bbc170c9ace18120900d7e3fa
Reviewed-on: https://gerrit.libreoffice.org/38035Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
üst f80c3e37
......@@ -1009,12 +1009,14 @@ void PDFExport::showErrors( const std::set< vcl::PDFWriter::ErrorCode >& rErrors
bool PDFExport::ImplExportPage( vcl::PDFWriter& rWriter, vcl::PDFExtOutDevData& rPDFExtOutDevData, const GDIMetaFile& rMtf )
{
const Size aSizePDF( OutputDevice::LogicToLogic( rMtf.GetPrefSize(), rMtf.GetPrefMapMode(), MapUnit::MapPoint ) );
basegfx::B2DPolygon aSize(tools::Polygon(tools::Rectangle(Point(0, 0), rMtf.GetPrefSize())).getB2DPolygon());
basegfx::B2DPolygon aSizePDF(OutputDevice::LogicToLogic(aSize, rMtf.GetPrefMapMode(), MapUnit::MapPoint));
basegfx::B2DRange aRangePDF(aSizePDF.getB2DRange());
Point aOrigin;
tools::Rectangle aPageRect( aOrigin, rMtf.GetPrefSize() );
bool bRet = true;
rWriter.NewPage( aSizePDF.Width(), aSizePDF.Height() );
rWriter.NewPage( aRangePDF.getWidth(), aRangePDF.getHeight() );
rWriter.SetMapMode( rMtf.GetPrefMapMode() );
vcl::PDFWriter::PlayMetafileContext aCtx;
......@@ -1042,7 +1044,7 @@ bool PDFExport::ImplExportPage( vcl::PDFWriter& rWriter, vcl::PDFExtOutDevData&
rPDFExtOutDevData.ResetSyncData();
if (!msWatermark.isEmpty())
ImplWriteWatermark( rWriter, aSizePDF );
ImplWriteWatermark( rWriter, Size(aRangePDF.getWidth(), aRangePDF.getHeight()) );
return bRet;
}
......
......@@ -689,7 +689,7 @@ The following structure describes the permissions used in PDF security
Colors and other state information MUST
be set again or are undefined.
*/
void NewPage( sal_Int32 nPageWidth, sal_Int32 nPageHeight, Orientation eOrientation = Orientation::Inherit );
void NewPage( double nPageWidth, double nPageHeight, Orientation eOrientation = Orientation::Inherit );
/** Play a metafile like an outputdevice would do
*/
struct PlayMetafileContext
......
......@@ -53,7 +53,7 @@ OutputDevice* PDFWriter::GetReferenceDevice()
return xImplementation->getReferenceDevice();
}
void PDFWriter::NewPage( sal_Int32 nPageWidth, sal_Int32 nPageHeight, Orientation eOrientation )
void PDFWriter::NewPage( double nPageWidth, double nPageHeight, Orientation eOrientation )
{
xImplementation->newPage( nPageWidth, nPageHeight, eOrientation );
}
......
......@@ -1126,7 +1126,7 @@ void PDFWriterImpl::ResourceDict::append( OStringBuffer& rBuf, sal_Int32 nFontDi
rBuf.append( "]\n>>\n" );
};
PDFWriterImpl::PDFPage::PDFPage( PDFWriterImpl* pWriter, sal_Int32 nPageWidth, sal_Int32 nPageHeight, PDFWriter::Orientation eOrientation )
PDFWriterImpl::PDFPage::PDFPage( PDFWriterImpl* pWriter, double nPageWidth, double nPageHeight, PDFWriter::Orientation eOrientation )
:
m_pWriter( pWriter ),
m_nPageWidth( nPageWidth ),
......@@ -2258,7 +2258,7 @@ LogicalFontInstance* PdfBuiltinFontFace::CreateFontInstance( FontSelectPattern&
}
void PDFWriterImpl::newPage( sal_Int32 nPageWidth, sal_Int32 nPageHeight, PDFWriter::Orientation eOrientation )
void PDFWriterImpl::newPage( double nPageWidth, double nPageHeight, PDFWriter::Orientation eOrientation )
{
endPage();
m_nCurrentPage = m_aPages.size();
......
......@@ -135,8 +135,8 @@ public:
struct PDFPage
{
PDFWriterImpl* m_pWriter;
sal_Int32 m_nPageWidth; // in inch/72
sal_Int32 m_nPageHeight; // in inch/72
double m_nPageWidth; // in inch/72
double m_nPageHeight; // in inch/72
PDFWriter::Orientation m_eOrientation;
sal_Int32 m_nPageObject;
sal_Int32 m_nPageIndex;
......@@ -150,7 +150,7 @@ public:
sal_uInt32 m_nDuration;
bool m_bHasWidgets;
PDFPage( PDFWriterImpl* pWriter, sal_Int32 nPageWidth, sal_Int32 nPageHeight, PDFWriter::Orientation eOrientation );
PDFPage( PDFWriterImpl* pWriter, double nPageWidth, double nPageHeight, PDFWriter::Orientation eOrientation );
~PDFPage();
void beginStream();
......@@ -191,7 +191,7 @@ public:
// appends a horizontal waveline with vertical offset (helper for drawWaveLine)
void appendWaveLine( sal_Int32 nLength, sal_Int32 nYOffset, sal_Int32 nDelta, OStringBuffer& rBuffer ) const;
sal_Int32 getHeight() const { return m_nPageHeight ? m_nPageHeight : m_pWriter->m_nInheritedPageHeight; }
double getHeight() const { return m_nPageHeight ? m_nPageHeight : m_pWriter->m_nInheritedPageHeight; }
};
friend struct PDFPage;
......@@ -1079,7 +1079,7 @@ public:
OutputDevice* getReferenceDevice();
/* document structure */
void newPage( sal_Int32 nPageWidth , sal_Int32 nPageHeight, PDFWriter::Orientation eOrientation );
void newPage( double nPageWidth , double nPageHeight, PDFWriter::Orientation eOrientation );
bool emit();
const std::set< PDFWriter::ErrorCode > & getErrors() const { return m_aErrors;}
void insertError( PDFWriter::ErrorCode eErr ) { m_aErrors.insert( eErr ); }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment