diff options
Diffstat (limited to 'vcl/source/gdi')
-rw-r--r-- | vcl/source/gdi/pdffontcache.cxx | 6 | ||||
-rw-r--r-- | vcl/source/gdi/pdffontcache.hxx | 14 | ||||
-rw-r--r-- | vcl/source/gdi/pdfwriter_impl.cxx | 28 | ||||
-rw-r--r-- | vcl/source/gdi/pdfwriter_impl.hxx | 19 |
4 files changed, 34 insertions, 33 deletions
diff --git a/vcl/source/gdi/pdffontcache.cxx b/vcl/source/gdi/pdffontcache.cxx index ccb131dd7cc9..68ede0bd676e 100644 --- a/vcl/source/gdi/pdffontcache.cxx +++ b/vcl/source/gdi/pdffontcache.cxx @@ -17,6 +17,8 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <typeinfo> + #include <sal/types.h> #include "outfont.hxx" @@ -30,8 +32,8 @@ using namespace vcl; PDFFontCache::FontIdentifier::FontIdentifier( const PhysicalFontFace* pFont, bool bVertical ) : m_nFontId( pFont->GetFontId() ), - m_nMagic( pFont->GetFontMagic() ), - m_bVertical( bVertical ) + m_bVertical( bVertical ), + m_typeFontFace( const_cast<std::type_info*>(&typeid(pFont)) ) { } diff --git a/vcl/source/gdi/pdffontcache.hxx b/vcl/source/gdi/pdffontcache.hxx index 88229e293379..8192bf1dbc80 100644 --- a/vcl/source/gdi/pdffontcache.hxx +++ b/vcl/source/gdi/pdffontcache.hxx @@ -20,6 +20,8 @@ #ifndef INCLUDED_VCL_SOURCE_GDI_PDFFONTCACHE_HXX #define INCLUDED_VCL_SOURCE_GDI_PDFFONTCACHE_HXX +#include <typeinfo> + #include <sal/types.h> #include <sallayout.hxx> @@ -32,22 +34,26 @@ namespace vcl struct FontIdentifier { sal_IntPtr m_nFontId; - int m_nMagic; bool m_bVertical; + std::type_info* m_typeFontFace; FontIdentifier( const PhysicalFontFace*, bool bVertical ); - FontIdentifier() : m_nFontId(0), m_nMagic(0), m_bVertical( false ) {} + FontIdentifier() : m_nFontId(0), m_bVertical( false ) {} bool operator==( const FontIdentifier& rRight ) const { return m_nFontId == rRight.m_nFontId && - m_nMagic == rRight.m_nMagic && + m_typeFontFace == rRight.m_typeFontFace && m_bVertical == rRight.m_bVertical; } + + // Less than needed for std::set and std::map bool operator<( const FontIdentifier& rRight ) const { + std::type_info *pType = rRight.m_typeFontFace; + return m_nFontId < rRight.m_nFontId || - m_nMagic < rRight.m_nMagic || + m_typeFontFace->before( *pType ) || m_bVertical < rRight.m_bVertical; } }; diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index 9e8428f372a9..9ccdbd091125 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -2239,29 +2239,6 @@ OutputDevice* PDFWriterImpl::getReferenceDevice() return m_pReferenceDevice; } -class ImplPdfBuiltinFontData : public PhysicalFontFace -{ -private: - const PDFWriterImpl::BuiltinFont& mrBuiltin; - -public: - static int const PDF_FONT_MAGIC = int(0xBDFF0A1C); - explicit ImplPdfBuiltinFontData( const PDFWriterImpl::BuiltinFont& ); - const PDFWriterImpl::BuiltinFont& GetBuiltinFont() const { return mrBuiltin; } - - virtual PhysicalFontFace* Clone() const override { return new ImplPdfBuiltinFontData(*this); } - virtual ImplFontEntry* CreateFontInstance( FontSelectPattern& ) const override; - virtual sal_IntPtr GetFontId() const override { return reinterpret_cast<sal_IntPtr>(&mrBuiltin); } -}; - -inline const ImplPdfBuiltinFontData* GetPdfFontData( const PhysicalFontFace* pFontData ) -{ - const ImplPdfBuiltinFontData* pFD = nullptr; - if( pFontData && pFontData->CheckMagic( ImplPdfBuiltinFontData::PDF_FONT_MAGIC ) ) - pFD = static_cast<const ImplPdfBuiltinFontData*>( pFontData ); - return pFD; -} - static ImplFontAttributes GetDevFontAttributes( const PDFWriterImpl::BuiltinFont& rBuiltin ) { ImplFontAttributes aDFA; @@ -2283,7 +2260,7 @@ static ImplFontAttributes GetDevFontAttributes( const PDFWriterImpl::BuiltinFont } ImplPdfBuiltinFontData::ImplPdfBuiltinFontData( const PDFWriterImpl::BuiltinFont& rBuiltin ) -: PhysicalFontFace( GetDevFontAttributes(rBuiltin), PDF_FONT_MAGIC ), +: PhysicalFontFace( GetDevFontAttributes(rBuiltin) ), mrBuiltin( rBuiltin ) {} @@ -2938,9 +2915,8 @@ bool PDFWriterImpl::emitTilings() return true; } -sal_Int32 PDFWriterImpl::emitBuiltinFont( const PhysicalFontFace* pFont, sal_Int32 nFontObject ) +sal_Int32 PDFWriterImpl::emitBuiltinFont( const ImplPdfBuiltinFontData* pFD, sal_Int32 nFontObject ) { - const ImplPdfBuiltinFontData* pFD = GetPdfFontData( pFont ); if( !pFD ) return 0; const BuiltinFont& rBuiltinFont = pFD->GetBuiltinFont(); diff --git a/vcl/source/gdi/pdfwriter_impl.hxx b/vcl/source/gdi/pdfwriter_impl.hxx index 542b2b512629..7d81df8b4311 100644 --- a/vcl/source/gdi/pdfwriter_impl.hxx +++ b/vcl/source/gdi/pdfwriter_impl.hxx @@ -43,6 +43,7 @@ #include "sallayout.hxx" #include "outdata.hxx" #include "pdffontcache.hxx" +#include "PhysicalFontFace.hxx" class StyleSettings; class FontSelectPattern; @@ -70,6 +71,7 @@ namespace vcl class PDFStreamIf; class Matrix3; +class ImplPdfBuiltinFontData; class PDFWriterImpl { @@ -833,7 +835,7 @@ i12626 /* writes all gradient patterns */ bool emitGradients(); /* writes a builtin font object and returns its objectid (or 0 in case of failure ) */ - sal_Int32 emitBuiltinFont( const PhysicalFontFace*, sal_Int32 nObject = -1 ); + sal_Int32 emitBuiltinFont( const ImplPdfBuiltinFontData*, sal_Int32 nObject = -1 ); /* writes a type1 embedded font object and returns its mapping from font ids to object ids (or 0 in case of failure ) */ std::map< sal_Int32, sal_Int32 > emitEmbeddedFont( const PhysicalFontFace*, EmbedFont& ); /* writes a type1 system font object and returns its mapping from font ids to object ids (or 0 in case of failure ) */ @@ -1254,6 +1256,21 @@ public: } }; +class ImplPdfBuiltinFontData : public PhysicalFontFace +{ +private: + const PDFWriterImpl::BuiltinFont& mrBuiltin; + +public: + explicit ImplPdfBuiltinFontData( const PDFWriterImpl::BuiltinFont& ); + const PDFWriterImpl::BuiltinFont& GetBuiltinFont() const { return mrBuiltin; } + + virtual PhysicalFontFace* Clone() const override { return new ImplPdfBuiltinFontData(*this); } + virtual ImplFontEntry* CreateFontInstance( FontSelectPattern& ) const override; + virtual sal_IntPtr GetFontId() const override { return reinterpret_cast<sal_IntPtr>(&mrBuiltin); } +}; + + } #endif //_VCL_PDFEXPORT_HXX |