Kaydet (Commit) b85ff983 authored tarafından Jan-Marek Glogowski's avatar Jan-Marek Glogowski

Change PDFWriterImpl into an OutputDevice

It actually changes it into a VirtualDevice and should just be a
refactoring. We get rid of the crude stuff in a follow up patch,

While at it unfriend PDFWriterImpl from OutputDevice.

Change-Id: Id43731ad076690292c30f9f3e05ff0dd58edc5e5
Reviewed-on: https://gerrit.libreoffice.org/62201
Tested-by: Jenkins
Reviewed-by: 's avatarJan-Marek Glogowski <glogow@fbihome.de>
üst 4b46826e
......@@ -328,7 +328,6 @@ class VCL_DLLPUBLIC OutputDevice : public virtual VclReferenceBase
friend class VirtualDevice;
friend class vcl::Window;
friend class WorkWindow;
friend class vcl::PDFWriterImpl;
friend void ImplHandleResize( vcl::Window* pWindow, long nNewWidth, long nNewHeight );
private:
......@@ -347,7 +346,7 @@ private:
std::unique_ptr<OutDevStateStack> mpOutDevStateStack;
std::unique_ptr<ImplOutDevData> mpOutDevData;
std::vector< VCLXGraphics* >* mpUnoGraphicsList;
vcl::PDFWriterImpl* mpPDFWriter;
VclPtr<OutputDevice> mpPDFWriter;
vcl::ExtOutDevData* mpExtOutDevData;
// TEMP TEMP TEMP
......@@ -550,7 +549,7 @@ public:
*/
bool SupportsOperation( OutDevSupportType ) const;
vcl::PDFWriterImpl* GetPDFWriter() const { return mpPDFWriter; }
vcl::PDFWriterImpl* GetPDFWriter() const;
void SetExtOutDevData( vcl::ExtOutDevData* pExtOutDevData ) { mpExtOutDevData = pExtOutDevData; }
vcl::ExtOutDevData* GetExtOutDevData() const { return mpExtOutDevData; }
......@@ -1181,12 +1180,13 @@ public:
vcl::TextLayoutCache const* = nullptr) const;
std::shared_ptr<vcl::TextLayoutCache> CreateTextLayoutCache(OUString const&) const;
private:
SAL_DLLPRIVATE void ImplInitTextColor();
protected:
SAL_DLLPRIVATE void ImplInitTextLineSize();
SAL_DLLPRIVATE void ImplInitAboveTextLineSize();
static
SAL_DLLPRIVATE long ImplGetTextLines( ImplMultiTextLineInfo& rLineInfo, long nWidth, const OUString& rStr, DrawTextFlags nStyle, const vcl::ITextLayout& _rLayout );
private:
SAL_DLLPRIVATE void ImplInitTextColor();
SAL_DLLPRIVATE void ImplDrawTextDirect( SalLayout&, bool bTextLines);
SAL_DLLPRIVATE void ImplDrawSpecialText( SalLayout& );
......@@ -1202,8 +1202,6 @@ private:
SAL_DLLPRIVATE void ImplDrawMnemonicLine( long nX, long nY, long nWidth );
static
SAL_DLLPRIVATE long ImplGetTextLines( ImplMultiTextLineInfo& rLineInfo, long nWidth, const OUString& rStr, DrawTextFlags nStyle, const vcl::ITextLayout& _rLayout );
///@}
......@@ -1289,12 +1287,15 @@ public:
SAL_DLLPRIVATE static void ImplUpdateAllFontData( bool bNewFontLists );
protected:
SAL_DLLPRIVATE const LogicalFontInstance* GetFontInstance() const;
SAL_DLLPRIVATE long GetEmphasisAscent() const { return mnEmphasisAscent; }
SAL_DLLPRIVATE long GetEmphasisDescent() const { return mnEmphasisDescent; }
SAL_DLLPRIVATE void SetPDFWriter(vcl::PDFWriterImpl* pPDFWriter);
virtual void InitFont() const;
virtual void SetFontOrientation( LogicalFontInstance* const pFontInstance ) const;
virtual long GetFontExtLeading() const;
private:
typedef void ( OutputDevice::* FontUpdateHandler_t )( bool );
......@@ -1809,8 +1810,6 @@ public:
SAL_DLLPRIVATE DeviceCoordinate LogicWidthToDeviceCoordinate( long nWidth ) const;
private:
/** Convert a logical X coordinate to a device pixel's X coordinate.
To get the device's X coordinate, it must calculate the mapping offset
......
......@@ -78,7 +78,11 @@ class VCL_DLLPUBLIC PDFOutputStream
class VCL_DLLPUBLIC PDFWriter
{
std::unique_ptr<PDFWriterImpl> xImplementation;
VclPtr<PDFWriterImpl> xImplementation;
PDFWriter(const PDFWriter&) = delete;
PDFWriter& operator=(const PDFWriter&) = delete;
public:
// extended line info
enum CapType { capButt, capRound, capSquare };
......
......@@ -29,7 +29,7 @@ PDFWriter::AnyWidget::~AnyWidget()
PDFWriter::PDFWriter( const PDFWriter::PDFWriterContext& rContext, const css::uno::Reference< css::beans::XMaterialHolder >& xEnc )
:
xImplementation( new PDFWriterImpl( rContext, xEnc, *this ) )
xImplementation( VclPtr<PDFWriterImpl>::Create(rContext, xEnc, *this) )
{
}
......@@ -39,7 +39,7 @@ PDFWriter::~PDFWriter()
OutputDevice* PDFWriter::GetReferenceDevice()
{
return xImplementation->getReferenceDevice();
return xImplementation.get();
}
void PDFWriter::NewPage( double nPageWidth, double nPageHeight, Orientation eOrientation )
......
......@@ -36,7 +36,7 @@
#include <vcl/bitmapex.hxx>
#include <vcl/gradient.hxx>
#include <vcl/hatch.hxx>
#include <vcl/outdev.hxx>
#include <vcl/virdev.hxx>
#include <vcl/pdfwriter.hxx>
#include <vcl/wall.hxx>
#include <o3tl/typed_flags_set.hxx>
......@@ -96,9 +96,10 @@ namespace filter
class PDFObjectElement;
}
class PDFWriterImpl
class PDFWriterImpl : public VirtualDevice
{
friend class PDFStreamIf;
public:
// definition of structs
struct BuiltinFont
......@@ -134,7 +135,7 @@ public:
struct PDFPage
{
PDFWriterImpl* m_pWriter;
VclPtr<PDFWriterImpl> m_pWriter;
double const m_nPageWidth; // in inch/72
double const m_nPageHeight; // in inch/72
PDFWriter::Orientation const m_eOrientation;
......@@ -611,11 +612,10 @@ public:
static bool compressStream( SvMemoryStream* );
static void convertLineInfoToExtLineInfo( const LineInfo& rIn, PDFWriter::ExtLineInfo& rOut );
private:
static const BuiltinFont m_aBuiltinFonts[14];
VclPtr<OutputDevice> m_pReferenceDevice;
MapMode m_aMapMode; // PDFWriterImpl scaled units
std::vector< PDFPage > m_aPages;
/* maps object numbers to file offsets (needed for xref) */
......@@ -1049,16 +1049,13 @@ i12626
void appendNonStrokingColor( const Color& rColor, OStringBuffer& rBuffer );
public:
PDFWriterImpl( const PDFWriter::PDFWriterContext& rContext, const css::uno::Reference< css::beans::XMaterialHolder >&, PDFWriter& );
~PDFWriterImpl();
~PDFWriterImpl() override;
void dispose() override;
static css::uno::Reference< css::beans::XMaterialHolder >
initEncryption( const OUString& i_rOwnerPassword,
const OUString& i_rUserPassword );
/* for documentation of public functions please see pdfwriter.hxx */
OutputDevice* getReferenceDevice();
/* document structure */
void newPage( double nPageWidth , double nPageHeight, PDFWriter::Orientation eOrientation );
bool emit();
......
......@@ -1096,13 +1096,13 @@ bool OutputDevice::RemoveTransparenciesFromMetaFile( const GDIMetaFile& rInMtf,
Point aPageOffset;
Size aTmpSize( GetOutputSizePixel() );
if( mpPDFWriter )
if( GetPDFWriter() )
{
aTmpSize = mpPDFWriter->getCurPageSize();
aTmpSize = GetPDFWriter()->getCurPageSize();
aTmpSize = LogicToPixel( aTmpSize, MapMode( MapUnit::MapPoint ) );
// also add error code to PDFWriter
mpPDFWriter->insertError( vcl::PDFWriter::Warning_Transparency_Converted );
GetPDFWriter()->insertError( vcl::PDFWriter::Warning_Transparency_Converted );
}
else if( meOutDevType == OUTDEV_PRINTER )
{
......
......@@ -542,7 +542,7 @@ void OutputDevice::ImplClearFontData( const bool bNewFontLists )
if (mxFontCollection && mxFontCollection != pSVData->maGDIData.mxScreenFontList)
mxFontCollection->Clear();
if( mpPDFWriter )
if( GetPDFWriter() )
{
mxFontCollection.reset();
mxFontCache.reset();
......@@ -579,7 +579,7 @@ void OutputDevice::ImplRefreshFontData( const bool bNewFontLists )
// we need a graphics
if ( AcquireGraphics() )
{
if( mpPDFWriter )
if( GetPDFWriter() )
{
mxFontCollection = pSVData->maGDIData.mxScreenFontList->Clone();
mxFontCache.reset(new ImplFontCache);
......@@ -1005,12 +1005,19 @@ void OutputDevice::InitFont() const
mbInitFont = false;
}
const LogicalFontInstance* OutputDevice::GetFontInstance() const
{
if (ImplNewFont())
InitFont();
return mpFontInstance.get();
}
bool OutputDevice::ImplNewFont() const
{
DBG_TESTSOLARMUTEX();
// get correct font list on the PDF writer if necessary
if( mpPDFWriter )
if( GetPDFWriter() )
{
const ImplSVData* pSVData = ImplGetSVData();
if( mxFontCollection == pSVData->maGDIData.mxScreenFontList
......
......@@ -401,9 +401,9 @@ void OutputDevice::DrawHatchLine( const tools::Line& rLine, const tools::PolyPol
{
for( long i = 0; i < nPCounter; i += 2 )
{
if( mpPDFWriter )
if( GetPDFWriter() )
{
mpPDFWriter->drawLine( pPtBuffer[ i ], pPtBuffer[ i+1 ] );
GetPDFWriter()->drawLine( pPtBuffer[ i ], pPtBuffer[ i+1 ] );
}
else
{
......
......@@ -34,6 +34,8 @@
#include <outdevstatestack.hxx>
#include <PhysicalFontCollection.hxx>
#include "../gdi/pdfwriter_impl.hxx"
#ifdef DISABLE_DYNLOADING
// Linking all needed LO code into one .so/executable, these already
// exist in the tools library, so put them in the anonymous namespace
......@@ -142,6 +144,8 @@ OutputDevice::~OutputDevice()
void OutputDevice::dispose()
{
mpPDFWriter.disposeAndClear();
if ( GetUnoGraphicsList() )
{
UnoWrapperBase* pWrapper = UnoWrapperBase::GetUnoWrapper( false );
......@@ -758,4 +762,15 @@ bool OutputDevice::DrawEPS( const Point& rPoint, const Size& rSize,
return bDrawn;
}
vcl::PDFWriterImpl* OutputDevice::GetPDFWriter() const
{
return static_cast<vcl::PDFWriterImpl*>(mpPDFWriter.get());
}
void OutputDevice::SetPDFWriter(vcl::PDFWriterImpl* pPDFWriter)
{
mpPDFWriter = pPDFWriter;
ImplUpdateFontData();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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