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