diff options
author | Kurt Zenker <kz@openoffice.org> | 2008-08-14 16:01:52 +0000 |
---|---|---|
committer | Kurt Zenker <kz@openoffice.org> | 2008-08-14 16:01:52 +0000 |
commit | 4e2287e64ece9e95db702ac6b67a6dd109490db2 (patch) | |
tree | d05c43747b63129b92d03a11b1b9c4fb25086a2e /sdext | |
parent | INTEGRATION: CWS pdf25 (1.1.2); FILE ADDED (diff) | |
download | core-4e2287e64ece9e95db702ac6b67a6dd109490db2.tar.gz core-4e2287e64ece9e95db702ac6b67a6dd109490db2.zip |
INTEGRATION: CWS pdf25 (1.1.2); FILE ADDED
2008/07/24 11:34:10 akhva 1.1.2.1: #90061
Diffstat (limited to 'sdext')
-rwxr-xr-x | sdext/source/pdfimport/inc/contentsink.hxx | 182 | ||||
-rw-r--r-- | sdext/source/pdfimport/inc/odfemitter.hxx | 49 | ||||
-rwxr-xr-x | sdext/source/pdfimport/inc/pdfihelper.hxx | 197 | ||||
-rw-r--r-- | sdext/source/pdfimport/inc/pdfparse.hxx | 313 | ||||
-rw-r--r-- | sdext/source/pdfimport/inc/saxemitter.hxx | 50 | ||||
-rw-r--r-- | sdext/source/pdfimport/inc/treevisitorfactory.hxx | 71 | ||||
-rwxr-xr-x | sdext/source/pdfimport/inc/wrapper.hxx | 61 | ||||
-rw-r--r-- | sdext/source/pdfimport/inc/xmlemitter.hxx | 64 |
8 files changed, 987 insertions, 0 deletions
diff --git a/sdext/source/pdfimport/inc/contentsink.hxx b/sdext/source/pdfimport/inc/contentsink.hxx new file mode 100755 index 000000000000..e570e3ad4b5f --- /dev/null +++ b/sdext/source/pdfimport/inc/contentsink.hxx @@ -0,0 +1,182 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: contentsink.hxx,v $ + * + * $Revision: 1.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef INCLUDED_PDFI_CONTENTSINK_HXX +#define INCLUDED_PDFI_CONTENTSINK_HXX + +#include <com/sun/star/uno/Reference.hxx> +#include <com/sun/star/uno/Sequence.hxx> +#include <com/sun/star/rendering/ARGBColor.hpp> +#include <boost/shared_ptr.hpp> + +namespace rtl { class OUString; } +namespace com { namespace sun { namespace star { +namespace rendering +{ + class XPolyPolygon2D; +} +namespace geometry +{ + struct Matrix2D; + struct AffineMatrix2D; + struct RealRectangle2D; + struct RealPoint2D; + struct RealSize2D; +} +namespace beans +{ + struct PropertyValue; +} } } } + +namespace pdfi +{ + struct FontAttributes + { + FontAttributes( const rtl::OUString& familyName_, + bool isBold_, + bool isItalic_, + bool isUnderline_, + double size_ ) : + familyName(familyName_), + isBold(isBold_), + isItalic(isItalic_), + isUnderline(isUnderline_), + size(size_) + {} + + FontAttributes() : + familyName(), + isBold(false), + isItalic(false), + isUnderline(false), + size(0.0) + {} + + ::rtl::OUString familyName; + bool isBold; + bool isItalic; + bool isUnderline; + double size; // device pixel + + bool operator==(const FontAttributes& rFont) const + { + return familyName == rFont.familyName && + !isBold == !rFont.isBold && + !isItalic == !rFont.isItalic && + !isUnderline == !rFont.isUnderline && + size == rFont.size; + } + }; + + /** (preliminary) API wrapper around xpdf + + Wraps the functionality currently used from xpdf's OutputDev + interface. Subject to change. + */ + struct ContentSink + { + virtual ~ContentSink() {} + + /// Total number of pages for upcoming document + virtual void setPageNum( sal_Int32 nNumPages ) = 0; + virtual void startPage( const ::com::sun::star::geometry::RealSize2D& rSize ) = 0; + virtual void endPage() = 0; + + virtual void hyperLink( const ::com::sun::star::geometry::RealRectangle2D& rBounds, + const ::rtl::OUString& rURI ) = 0; + + virtual void pushState() = 0; + virtual void popState() = 0; + + virtual void setFlatness( double ) = 0; + virtual void setTransformation( const ::com::sun::star::geometry::AffineMatrix2D& rMatrix ) = 0; + virtual void setLineDash( const ::com::sun::star::uno::Sequence<double>& dashes, + double start ) = 0; + virtual void setLineJoin( sal_Int8 lineJoin ) = 0; + virtual void setLineCap( sal_Int8 lineCap ) = 0; + virtual void setMiterLimit(double) = 0; + virtual void setLineWidth(double) = 0; + virtual void setFillColor( const ::com::sun::star::rendering::ARGBColor& rColor ) = 0; + virtual void setStrokeColor( const ::com::sun::star::rendering::ARGBColor& rColor ) = 0; + virtual void setBlendMode( sal_Int8 blendMode ) = 0; + virtual void setFont( const FontAttributes& rFont ) = 0; + + + virtual void strokePath( const ::com::sun::star::uno::Reference< + ::com::sun::star::rendering::XPolyPolygon2D >& rPath ) = 0; + virtual void fillPath( const ::com::sun::star::uno::Reference< + ::com::sun::star::rendering::XPolyPolygon2D >& rPath ) = 0; + virtual void eoFillPath( const ::com::sun::star::uno::Reference< + ::com::sun::star::rendering::XPolyPolygon2D >& rPath ) = 0; + + virtual void intersectClip(const ::com::sun::star::uno::Reference< + ::com::sun::star::rendering::XPolyPolygon2D >& rPath) = 0; + virtual void intersectEoClip(const ::com::sun::star::uno::Reference< + ::com::sun::star::rendering::XPolyPolygon2D >& rPath) = 0; + + virtual void drawGlyphs( const rtl::OUString& rGlyphs, + const ::com::sun::star::geometry::RealRectangle2D& rRect, + const ::com::sun::star::geometry::Matrix2D& rFontMatrix ) = 0; + + /// issued when a sequence of associated glyphs is drawn + virtual void endText() = 0; + + /// draws given bitmap as a mask (using current fill color) + virtual void drawMask(const ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue>& xBitmap, + bool bInvert ) = 0; + /// Given image must already be color-mapped and normalized to sRGB. + virtual void drawImage(const ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue>& xBitmap ) = 0; + /** Given image must already be color-mapped and normalized to sRGB. + + maskColors must contain two sequences of color components + */ + virtual void drawColorMaskedImage(const ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue>& xBitmap, + const ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Any>& xMaskColors ) = 0; + virtual void drawMaskedImage(const ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue>& xBitmap, + const ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue>& xMask, + bool bInvertMask) = 0; + virtual void drawAlphaMaskedImage(const ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue>& xImage, + const ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue>& xMask) = 0; + }; + + typedef boost::shared_ptr<ContentSink> ContentSinkSharedPtr; +} + +#endif /* INCLUDED_PDFI_CONTENTSINK_HXX */ + diff --git a/sdext/source/pdfimport/inc/odfemitter.hxx b/sdext/source/pdfimport/inc/odfemitter.hxx new file mode 100644 index 000000000000..e36a4dc91ce9 --- /dev/null +++ b/sdext/source/pdfimport/inc/odfemitter.hxx @@ -0,0 +1,49 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: odfemitter.hxx,v $ + * + * $Revision: 1.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef INCLUDED_PDFI_ODFEMITTER_HXX +#define INCLUDED_PDFI_ODFEMITTER_HXX + +#include "xmlemitter.hxx" +#include <com/sun/star/uno/Reference.hxx> + +namespace com { namespace sun { namespace star { namespace io +{ + class XOutputStream; +} } } } + +namespace pdfi +{ + XmlEmitterSharedPtr createOdfEmitter( const com::sun::star::uno::Reference< + com::sun::star::io::XOutputStream>& xOut ); +} + +#endif /* INCLUDED_PDFI_ODFEMITTER_HXX */ diff --git a/sdext/source/pdfimport/inc/pdfihelper.hxx b/sdext/source/pdfimport/inc/pdfihelper.hxx new file mode 100755 index 000000000000..cc1bce96f6b3 --- /dev/null +++ b/sdext/source/pdfimport/inc/pdfihelper.hxx @@ -0,0 +1,197 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: pdfihelper.hxx,v $ + * + * $Revision: 1.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef INCLUDED_PDFI_HELPER_HXX +#define INCLUDED_PDFI_HELPER_HXX + +#include "contentsink.hxx" + +#include <rtl/ustring.hxx> +#include <rtl/math.h> +#include <basegfx/matrix/b2dhommatrix.hxx> +#include <basegfx/polygon/b2dpolypolygon.hxx> +#include <basegfx/polygon/b2dpolygon.hxx> +#include <com/sun/star/rendering/XColorSpace.hpp> + +#include <vector> +#include <hash_map> + +// virtual resolution of the PDF OutputDev in dpi +#define PDFI_OUTDEV_RESOLUTION 7200 + +namespace com { namespace sun { namespace star { namespace task +{ class XInteractionHandler; }}}} + +namespace pdfi +{ + typedef std::hash_map< rtl::OUString, rtl::OUString, rtl::OUStringHash > PropertyMap; + typedef sal_Int32 ImageId; + + /// What to do with a polygon. values can be ORed together + enum PolygonAction { PATH_STROKE=1, PATH_FILL=2, PATH_EOFILL=4 }; + + rtl::OUString unitMMString( double fMM ); + rtl::OUString convertPixelToUnitString( double fPix ); + + inline double convPx2mm( double fPix ) + { + const double px2mm = 25.4/PDFI_OUTDEV_RESOLUTION; + fPix *= px2mm; + return fPix; + } + + inline double convmm2Px( double fMM ) + { + const double mm2px = PDFI_OUTDEV_RESOLUTION/25.4; + fMM *= mm2px; + return fMM; + } + + inline double convPx2mmPrec2( double fPix ) + { + return rtl_math_round( convPx2mm( fPix ), 2, rtl_math_RoundingMode_Floor ); + } + + /// Convert color to "#FEFEFE" color notation + rtl::OUString getColorString( const ::com::sun::star::rendering::ARGBColor& ); + + struct FontAttrHash + { + size_t operator()(const FontAttributes& rFont ) const + { + return (size_t)rFont.familyName.hashCode() + ^ size_t(rFont.isBold ? 0xd47be593 : 0) + ^ size_t(rFont.isItalic ? 0x1efd51a1 : 0) + ^ size_t(rFont.isUnderline ? 0xf6bd325a : 0) + ^ size_t(rFont.size) + ; + } + }; + + struct GraphicsContext + { + ::com::sun::star::rendering::ARGBColor LineColor; + ::com::sun::star::rendering::ARGBColor FillColor; + sal_Int8 LineJoin; + sal_Int8 LineCap; + sal_Int8 BlendMode; + double Flatness; + double LineWidth; + double MiterLimit; + std::vector<double> DashArray; + sal_Int32 FontId; + basegfx::B2DHomMatrix Transformation; + basegfx::B2DPolyPolygon Clip; + + GraphicsContext() : + LineColor(), + FillColor(), + LineJoin(0), + LineCap(0), + BlendMode(0), + Flatness(0.0), + LineWidth(1.0), + MiterLimit(10.0), + DashArray(), + FontId(0), + Transformation(), + Clip() + {} + + bool operator==(const GraphicsContext& rRight ) const + { + return LineColor.Red == rRight.LineColor.Red && + LineColor.Green == rRight.LineColor.Green && + LineColor.Blue == rRight.LineColor.Blue && + LineColor.Alpha == rRight.LineColor.Alpha && + FillColor.Red == rRight.FillColor.Red && + FillColor.Green == rRight.FillColor.Green && + FillColor.Blue == rRight.FillColor.Blue && + FillColor.Alpha == rRight.FillColor.Alpha && + LineJoin == rRight.LineJoin && + LineCap == rRight.LineCap && + BlendMode == rRight.BlendMode && + LineWidth == rRight.LineWidth && + Flatness == rRight.Flatness && + MiterLimit == rRight.MiterLimit && + DashArray == rRight.DashArray && + FontId == rRight.FontId && + Transformation == rRight.Transformation && + Clip == rRight.Clip; + } + + bool isRotatedOrSkewed() const + { return Transformation.get( 0, 1 ) != 0.0 || + Transformation.get( 1, 0 ) != 0.0; } + }; + + struct GraphicsContextHash + { + size_t operator()(const GraphicsContext& rGC ) const + { + return size_t(rGC.LineColor.Red) + ^ size_t(rGC.LineColor.Green) + ^ size_t(rGC.LineColor.Blue) + ^ size_t(rGC.LineColor.Alpha) + ^ size_t(rGC.FillColor.Red) + ^ size_t(rGC.FillColor.Green) + ^ size_t(rGC.FillColor.Blue) + ^ size_t(rGC.FillColor.Alpha) + ^ size_t(rGC.LineJoin) + ^ size_t(rGC.LineCap) + ^ size_t(rGC.BlendMode) + ^ size_t(rGC.LineWidth) + ^ size_t(rGC.Flatness) + ^ size_t(rGC.MiterLimit) + ^ rGC.DashArray.size() + ^ size_t(rGC.FontId) + ^ size_t(rGC.Transformation.get( 0, 0 )) + ^ size_t(rGC.Transformation.get( 1, 0 )) + ^ size_t(rGC.Transformation.get( 0, 1 )) + ^ size_t(rGC.Transformation.get( 1, 1 )) + ^ size_t(rGC.Transformation.get( 0, 2 )) + ^ size_t(rGC.Transformation.get( 1, 2 )) + ^ size_t(rGC.Clip.count() ? rGC.Clip.getB2DPolygon(0).count() : 0) + ; + } + }; + + /** retrieve password from user + */ + bool getPassword( const ::com::sun::star::uno::Reference< + ::com::sun::star::task::XInteractionHandler >& xHandler, + rtl::OUString& rOutPwd, + bool bFirstTry ); +} + +#define USTR(x) rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( x ) ) + +#endif diff --git a/sdext/source/pdfimport/inc/pdfparse.hxx b/sdext/source/pdfimport/inc/pdfparse.hxx new file mode 100644 index 000000000000..d7d1ea1a4dbd --- /dev/null +++ b/sdext/source/pdfimport/inc/pdfparse.hxx @@ -0,0 +1,313 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: pdfparse.hxx,v $ + * + * $Revision: 1.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef INCLUDED_PDFI_PDFPARSE_HXX +#define INCLUDED_PDFI_PDFPARSE_HXX + +#include <sal/types.h> +#include <rtl/ustring.hxx> +#include <rtl/string.hxx> + +#include <vector> +#include <hash_map> + +namespace pdfparse +{ + +struct EmitImplData; +struct PDFContainer; +class EmitContext +{ + public: + virtual bool write( const void* pBuf, unsigned int nLen ) = 0; + virtual unsigned int getCurPos() = 0; + virtual bool copyOrigBytes( unsigned int nOrigOffset, unsigned int nLen ) = 0; + virtual unsigned int readOrigBytes( unsigned int nOrigOffset, unsigned int nLen, void* pBuf ) = 0; + + EmitContext( const PDFContainer* pTop = NULL ); + virtual ~EmitContext(); + + // set this to deflate contained streams + bool m_bDeflate; + // set this to decrypt the PDF file + bool m_bDecrypt; + + private: + friend struct PDFEntry; + EmitImplData* m_pImplData; +}; + +struct PDFEntry +{ + PDFEntry() {} + virtual ~PDFEntry(); + + virtual bool emit( EmitContext& rWriteContext ) const = 0; + virtual PDFEntry* clone() const = 0; + + protected: + EmitImplData* getEmitData( EmitContext& rContext ) const; + void setEmitData( EmitContext& rContext, EmitImplData* pNewEmitData ) const; +}; + +struct PDFComment : public PDFEntry +{ + rtl::OString m_aComment; + + PDFComment( const rtl::OString& rComment ) + : PDFEntry(), m_aComment( rComment ) {} + virtual ~PDFComment(); + virtual bool emit( EmitContext& rWriteContext ) const; + virtual PDFEntry* clone() const; +}; + +struct PDFValue : public PDFEntry +{ + // abstract base class for simple values + PDFValue() : PDFEntry() {} + virtual ~PDFValue(); +}; + +struct PDFName : public PDFValue +{ + rtl::OString m_aName; + + PDFName( const rtl::OString& rName ) + : PDFValue(), m_aName( rName ) {} + virtual ~PDFName(); + virtual bool emit( EmitContext& rWriteContext ) const; + virtual PDFEntry* clone() const; + + rtl::OUString getFilteredName() const; +}; + +struct PDFString : public PDFValue +{ + rtl::OString m_aString; + + PDFString( const rtl::OString& rString ) + : PDFValue(), m_aString( rString ) {} + virtual ~PDFString(); + virtual bool emit( EmitContext& rWriteContext ) const; + virtual PDFEntry* clone() const; + + rtl::OString getFilteredString() const; +}; + +struct PDFNumber : public PDFValue +{ + double m_fValue; + + PDFNumber( double fVal ) + : PDFValue(), m_fValue( fVal ) {} + virtual ~PDFNumber(); + virtual bool emit( EmitContext& rWriteContext ) const; + virtual PDFEntry* clone() const; +}; + +struct PDFBool : public PDFValue +{ + bool m_bValue; + + PDFBool( bool bVal ) + : PDFValue(), m_bValue( bVal ) {} + virtual ~PDFBool(); + virtual bool emit( EmitContext& rWriteContext ) const; + virtual PDFEntry* clone() const; +}; + +struct PDFObjectRef : public PDFValue +{ + unsigned int m_nNumber; + unsigned int m_nGeneration; + + PDFObjectRef( unsigned int nNr, unsigned int nGen ) + : PDFValue(), m_nNumber( nNr ), m_nGeneration( nGen ) {} + virtual ~PDFObjectRef(); + virtual bool emit( EmitContext& rWriteContext ) const; + virtual PDFEntry* clone() const; +}; + +struct PDFNull : public PDFValue +{ + PDFNull() {} + virtual ~PDFNull(); + virtual bool emit( EmitContext& rWriteContext ) const; + virtual PDFEntry* clone() const; +}; + +struct PDFObject; +struct PDFContainer : public PDFEntry +{ + sal_Int32 m_nOffset; + std::vector<PDFEntry*> m_aSubElements; + + // this is an abstract base class for identifying + // entries that can contain sub elements besides comments + PDFContainer() : PDFEntry(), m_nOffset( 0 ) {} + virtual ~PDFContainer(); + virtual bool emitSubElements( EmitContext& rWriteContext ) const; + virtual void cloneSubElements( std::vector<PDFEntry*>& rNewSubElements ) const; + + PDFObject* findObject( unsigned int nNumber, unsigned int nGeneration ) const; + PDFObject* findObject( PDFObjectRef* pRef ) const + { return findObject( pRef->m_nNumber, pRef->m_nGeneration ); } +}; + +struct PDFArray : public PDFContainer +{ + PDFArray() {} + virtual ~PDFArray(); + virtual bool emit( EmitContext& rWriteContext ) const; + virtual PDFEntry* clone() const; +}; + +struct PDFDict : public PDFContainer +{ + typedef std::hash_map<rtl::OString,PDFEntry*,rtl::OStringHash> Map; + Map m_aMap; + + PDFDict() {} + virtual ~PDFDict(); + virtual bool emit( EmitContext& rWriteContext ) const; + virtual PDFEntry* clone() const; + + // inserting a value of NULL will remove rName and the previous value + // from the dictionary + void insertValue( const rtl::OString& rName, PDFEntry* pValue ); + // removes a name/value pair from the dict + void eraseValue( const rtl::OString& rName ); + // builds new map as of sub elements + // returns NULL if successfull, else the first offending element + PDFEntry* buildMap(); +}; + +struct PDFStream : public PDFEntry +{ + unsigned int m_nBeginOffset; + unsigned int m_nEndOffset; // offset of the byte after the stream + PDFDict* m_pDict; + + PDFStream( unsigned int nBegin, unsigned int nEnd, PDFDict* pStreamDict ) + : PDFEntry(), m_nBeginOffset( nBegin ), m_nEndOffset( nEnd ), m_pDict( pStreamDict ) {} + virtual ~PDFStream(); + virtual bool emit( EmitContext& rWriteContext ) const; + virtual PDFEntry* clone() const; + + unsigned int getDictLength( const PDFContainer* pObjectContainer = NULL ) const; // get contents of the "Length" entry of the dict +}; + +struct PDFTrailer : public PDFContainer +{ + PDFDict* m_pDict; + + PDFTrailer() : PDFContainer(), m_pDict( NULL ) {} + virtual ~PDFTrailer(); + virtual bool emit( EmitContext& rWriteContext ) const; + virtual PDFEntry* clone() const; +}; + +struct PDFFileImplData; +struct PDFFile : public PDFContainer +{ + private: + mutable PDFFileImplData* m_pData; + PDFFileImplData* impl_getData() const; + public: + unsigned int m_nMajor; // PDF major + unsigned int m_nMinor; // PDF minor + + PDFFile() + : PDFContainer(), + m_pData( NULL ), + m_nMajor( 0 ), m_nMinor( 0 ) + {} + virtual ~PDFFile(); + + virtual bool emit( EmitContext& rWriteContext ) const; + virtual PDFEntry* clone() const; + + bool isEncrypted() const; + // this method checks whether rPwd is compatible with + // either user or owner password and sets up decrypt data in that case + // returns true if decryption can be done + bool setupDecryptionData( const rtl::OString& rPwd ) const; + + bool decrypt( const sal_uInt8* pInBuffer, sal_uInt32 nLen, + sal_uInt8* pOutBuffer, + unsigned int nObject, unsigned int nGeneration ) const; +}; + +struct PDFObject : public PDFContainer +{ + PDFEntry* m_pObject; + PDFStream* m_pStream; + unsigned int m_nNumber; + unsigned int m_nGeneration; + + PDFObject( unsigned int nNr, unsigned int nGen ) + : m_pObject( NULL ), m_pStream( NULL ), m_nNumber( nNr ), m_nGeneration( nGen ) {} + virtual ~PDFObject(); + virtual bool emit( EmitContext& rWriteContext ) const; + virtual PDFEntry* clone() const; + + // writes only the contained stream, deflated if necessary + bool writeStream( EmitContext& rContext, const PDFFile* pPDFFile ) const; + + private: + // returns true if stream is deflated + // fills *ppStream and *pBytes with start of stream and count of bytes + // memory returned in *ppStream must be freed with rtl_freeMemory afterwards + // fills in NULL and 0 in case of error + bool getDeflatedStream( char** ppStream, unsigned int* pBytes, const PDFContainer* pObjectContainer, EmitContext& rContext ) const; +}; + +struct PDFPart : public PDFContainer +{ + PDFPart() : PDFContainer() {} + virtual ~PDFPart(); + virtual bool emit( EmitContext& rWriteContext ) const; + virtual PDFEntry* clone() const; +}; + +class PDFReader +{ + public: + PDFReader() {} + ~PDFReader() {} + + PDFEntry* read( const char* pFileName ); + PDFEntry* read( const char* pBuffer, unsigned int nLen ); +}; + +} // namespace + +#endif diff --git a/sdext/source/pdfimport/inc/saxemitter.hxx b/sdext/source/pdfimport/inc/saxemitter.hxx new file mode 100644 index 000000000000..ef892b47c973 --- /dev/null +++ b/sdext/source/pdfimport/inc/saxemitter.hxx @@ -0,0 +1,50 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: saxemitter.hxx,v $ + * + * $Revision: 1.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef INCLUDED_PDFI_SAXEMITTER_HXX +#define INCLUDED_PDFI_SAXEMITTER_HXX + +#include "xmlemitter.hxx" +#include <com/sun/star/uno/Reference.hxx> + +namespace com { namespace sun { namespace star { namespace xml { +namespace sax +{ + class XDocumentHandler; +} } } } } + +namespace pdfi +{ + XmlEmitterSharedPtr createSaxEmitter( const com::sun::star::uno::Reference< + com::sun::star::xml::sax::XDocumentHandler >& xDocHdl ); +} + +#endif /* INCLUDED_PDFI_SAXEMITTER_HXX */ diff --git a/sdext/source/pdfimport/inc/treevisitorfactory.hxx b/sdext/source/pdfimport/inc/treevisitorfactory.hxx new file mode 100644 index 000000000000..28566027b6f2 --- /dev/null +++ b/sdext/source/pdfimport/inc/treevisitorfactory.hxx @@ -0,0 +1,71 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: treevisitorfactory.hxx,v $ + * + * $Revision: 1.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef INCLUDED_PDFI_TREEVISITORFACTORY_HXX +#define INCLUDED_PDFI_TREEVISITORFACTORY_HXX + +#include "pdfihelper.hxx" +#include <boost/shared_ptr.hpp> + +namespace pdfi +{ + struct ElementTreeVisitor; + struct EmitContext; + class PDFIProcessor; + class StyleContainer; + + /** Tree manipulation factory + + Creates visitor objects performing various operations on the + pdf parse tree + */ + struct TreeVisitorFactory + { + virtual ~TreeVisitorFactory() {} + + /// Create visitor that combines tree nodes + virtual boost::shared_ptr<ElementTreeVisitor> createOptimizingVisitor(PDFIProcessor&) const = 0; + /// Create visitor that prepares style info + virtual boost::shared_ptr<ElementTreeVisitor> createStyleCollectingVisitor( + StyleContainer&, PDFIProcessor&) const = 0; + /// Create visitor that emits tree to an output target + virtual boost::shared_ptr<ElementTreeVisitor> createEmittingVisitor(EmitContext&) const = 0; + }; + + typedef boost::shared_ptr<TreeVisitorFactory> TreeVisitorFactorySharedPtr; + + TreeVisitorFactorySharedPtr createWriterTreeVisitorFactory(); + TreeVisitorFactorySharedPtr createImpressTreeVisitorFactory(); + TreeVisitorFactorySharedPtr createDrawTreeVisitorFactory(); +} + +#endif + diff --git a/sdext/source/pdfimport/inc/wrapper.hxx b/sdext/source/pdfimport/inc/wrapper.hxx new file mode 100755 index 000000000000..4ef1574b36ee --- /dev/null +++ b/sdext/source/pdfimport/inc/wrapper.hxx @@ -0,0 +1,61 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: wrapper.hxx,v $ + * + * $Revision: 1.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef INCLUDED_PDFI_WRAPPER_HXX +#define INCLUDED_PDFI_WRAPPER_HXX + +#include "contentsink.hxx" +#include <com/sun/star/uno/Reference.hxx> + +namespace rtl { class OUString; } +namespace com { namespace sun { namespace star { + namespace uno { + class XComponentContext; + } + namespace io { + class XInputStream; + } +} } } + +namespace pdfi +{ + bool xpdf_ImportFromFile( const ::rtl::OUString& rURL, + const ContentSinkSharedPtr& rSink, + const com::sun::star::uno::Reference< + com::sun::star::uno::XComponentContext >& xContext ); + bool xpdf_ImportFromStream( const com::sun::star::uno::Reference< + com::sun::star::io::XInputStream >& xInput, + const ContentSinkSharedPtr& rSink, + const com::sun::star::uno::Reference< + com::sun::star::uno::XComponentContext >& xContext ); +} + +#endif /* INCLUDED_PDFI_WRAPPER_HXX */ diff --git a/sdext/source/pdfimport/inc/xmlemitter.hxx b/sdext/source/pdfimport/inc/xmlemitter.hxx new file mode 100644 index 000000000000..94e73212640c --- /dev/null +++ b/sdext/source/pdfimport/inc/xmlemitter.hxx @@ -0,0 +1,64 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: xmlemitter.hxx,v $ + * + * $Revision: 1.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef INCLUDED_PDFI_XMLEMITTER_HXX +#define INCLUDED_PDFI_XMLEMITTER_HXX + +#include "pdfihelper.hxx" +#include <boost/shared_ptr.hpp> + +namespace pdfi +{ + /** Output interface to ODF + + Should be easy to implement using either SAX events or plain ODF + */ + class XmlEmitter + { + public: + virtual ~XmlEmitter() {} + + /** Open up a tag with the given properties + */ + virtual void beginTag( const char* pTag, const PropertyMap& rProperties ) = 0; + /** Write PCTEXT as-is to output + */ + virtual void write( const rtl::OUString& rString ) = 0; + /** Close previously opened tag + */ + virtual void endTag( const char* pTag ) = 0; + }; + + typedef boost::shared_ptr<XmlEmitter> XmlEmitterSharedPtr; +} + +#endif + |