Kaydet (Commit) 061ce55a authored tarafından Kurt Zenker's avatar Kurt Zenker

INTEGRATION: CWS pdf25 (1.1.2); FILE ADDED

2008/07/24 12:32:59 akhva 1.1.2.1: #90061
üst 2bc9cff1
/*************************************************************************
*
* 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: drawtreevisiting.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_DRAWTREEVISITING_HXX
#define INCLUDED_PDFI_DRAWTREEVISITING_HXX
#include "treevisiting.hxx"
namespace pdfi
{
struct DrawElement;
class DrawXmlOptimizer : public ElementTreeVisitor
{
private:
PDFIProcessor& m_rProcessor;
void optimizeTextElements(Element& rParent);
public:
explicit DrawXmlOptimizer(PDFIProcessor& rProcessor) :
m_rProcessor(rProcessor)
{}
virtual void visit( HyperlinkElement&, const std::list< Element* >::const_iterator& );
virtual void visit( TextElement&, const std::list< Element* >::const_iterator& );
virtual void visit( ParagraphElement&, const std::list< Element* >::const_iterator& );
virtual void visit( FrameElement&, const std::list< Element* >::const_iterator& );
virtual void visit( PolyPolyElement&, const std::list< Element* >::const_iterator& );
virtual void visit( ImageElement&, const std::list< Element* >::const_iterator& );
virtual void visit( PageElement&, const std::list< Element* >::const_iterator& );
virtual void visit( DocumentElement&, const std::list< Element* >::const_iterator& );
};
class DrawXmlFinalizer : public ElementTreeVisitor
{
private:
StyleContainer& m_rStyleContainer;
PDFIProcessor& m_rProcessor;
public:
explicit DrawXmlFinalizer(StyleContainer& rStyleContainer,
PDFIProcessor& rProcessor) :
m_rStyleContainer(rStyleContainer),
m_rProcessor(rProcessor)
{}
virtual void visit( HyperlinkElement&, const std::list< Element* >::const_iterator& );
virtual void visit( TextElement&, const std::list< Element* >::const_iterator& );
virtual void visit( ParagraphElement&, const std::list< Element* >::const_iterator& );
virtual void visit( FrameElement&, const std::list< Element* >::const_iterator& );
virtual void visit( PolyPolyElement&, const std::list< Element* >::const_iterator& );
virtual void visit( ImageElement&, const std::list< Element* >::const_iterator& );
virtual void visit( PageElement&, const std::list< Element* >::const_iterator& );
virtual void visit( DocumentElement&, const std::list< Element* >::const_iterator& );
};
class DrawXmlEmitter : public ElementTreeVisitor
{
private:
EmitContext& m_rEmitContext ;
/// writes Impress doc when false
const bool m_bWriteDrawDocument;
void fillFrameProps( DrawElement& rElem,
PropertyMap& rProps,
const EmitContext& rEmitContext );
public:
enum DocType{ DRAW_DOC, IMPRESS_DOC };
explicit DrawXmlEmitter(EmitContext& rEmitContext, DocType eDocType) :
m_rEmitContext(rEmitContext),
m_bWriteDrawDocument(eDocType==DRAW_DOC)
{}
virtual void visit( HyperlinkElement&, const std::list< Element* >::const_iterator& );
virtual void visit( TextElement&, const std::list< Element* >::const_iterator& );
virtual void visit( ParagraphElement&, const std::list< Element* >::const_iterator& );
virtual void visit( FrameElement&, const std::list< Element* >::const_iterator& );
virtual void visit( PolyPolyElement&, const std::list< Element* >::const_iterator& );
virtual void visit( ImageElement&, const std::list< Element* >::const_iterator& );
virtual void visit( PageElement&, const std::list< Element* >::const_iterator& );
virtual void visit( DocumentElement&, const std::list< Element* >::const_iterator& );
};
}
#endif
This diff is collapsed.
/*************************************************************************
*
* 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: imagecontainer.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_IMAGECONTAINER_HXX
#define INCLUDED_PDFI_IMAGECONTAINER_HXX
#include "pdfihelper.hxx"
#include <rtl/ustring.hxx>
#include <com/sun/star/uno/Reference.hxx>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/awt/XBitmap.hpp>
#include <vector>
#include <hash_map>
namespace pdfi
{
struct EmitContext;
class ImageContainer
{
private:
std::vector< ::com::sun::star::uno::Sequence<
::com::sun::star::beans::PropertyValue> > m_aImages;
public:
ImageContainer();
ImageId addImage( const ::com::sun::star::uno::Sequence<
::com::sun::star::beans::PropertyValue>& xBitmap );
void writeBase64EncodedStream( ImageId nImageId, EmitContext& rContext );
};
}
#endif
This diff is collapsed.
/*************************************************************************
*
* 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: style.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_STYLE_HXX
#define INCLUDED_PDFI_STYLE_HXX
#include "pdfihelper.hxx"
#include <hash_map>
#include <vector>
#include <rtl/ustring.hxx>
#include <rtl/string.hxx>
#include "treevisiting.hxx"
namespace pdfi
{
struct Element;
struct EmitContext;
struct ElementTreeVisitable;
class StyleContainer
{
public:
struct Style
{
rtl::OString Name;
PropertyMap Properties;
rtl::OUString Contents;
Element* ContainedElement;
std::vector< Style* > SubStyles;
Style() : ContainedElement( NULL ) {}
Style( const rtl::OString& rName, const PropertyMap& rProps ) :
Name( rName ),
Properties( rProps ),
ContainedElement( NULL )
{}
};
private:
struct HashedStyle
{
rtl::OString Name;
PropertyMap Properties;
rtl::OUString Contents;
Element* ContainedElement;
std::vector<sal_Int32> SubStyles;
bool IsSubStyle;
sal_Int32 RefCount;
HashedStyle() : ContainedElement( NULL ), IsSubStyle( true ), RefCount( 0 ) {}
HashedStyle( const HashedStyle& rRight ) :
Name( rRight.Name ),
Properties( rRight.Properties ),
Contents( rRight.Contents ),
ContainedElement( rRight.ContainedElement ),
SubStyles( rRight.SubStyles ),
IsSubStyle( rRight.IsSubStyle ),
RefCount( 0 )
{}
size_t hashCode() const
{
size_t nRet = size_t(Name.hashCode());
for( PropertyMap::const_iterator it = Properties.begin();
it != Properties.end(); ++it )
{
nRet ^= size_t(it->first.hashCode());
nRet ^= size_t(it->second.hashCode());
}
nRet = size_t(Contents.hashCode());
nRet ^= size_t(ContainedElement);
for( unsigned int n = 0; n < SubStyles.size(); ++n )
nRet ^= size_t(SubStyles[n]);
return nRet;
}
bool operator==(const HashedStyle& rRight) const
{
if( Name != rRight.Name ||
Properties != rRight.Properties ||
Contents != rRight.Contents ||
ContainedElement != rRight.ContainedElement ||
SubStyles.size() != rRight.SubStyles.size()
)
return false;
for( unsigned int n = 0; n < SubStyles.size(); ++n )
{
if( SubStyles[n] != rRight.SubStyles[n] )
return false;
}
return true;
}
};
struct StyleHash;
friend struct StyleHash;
struct StyleHash
{
size_t operator()( const StyleContainer::HashedStyle& rStyle ) const
{
return rStyle.hashCode();
}
};
struct StyleIdNameSort;
friend struct StyleIdNameSort;
struct StyleIdNameSort
{
const std::hash_map< sal_Int32, HashedStyle >* m_pMap;
StyleIdNameSort( const std::hash_map< sal_Int32, HashedStyle >* pMap ) :
m_pMap(pMap)
{}
bool operator()( sal_Int32 nLeft, sal_Int32 nRight )
{
const std::hash_map< sal_Int32, HashedStyle >::const_iterator left_it =
m_pMap->find( nLeft );
const std::hash_map< sal_Int32, HashedStyle >::const_iterator right_it =
m_pMap->find( nRight );
if( left_it == m_pMap->end() )
return false;
else if( right_it == m_pMap->end() )
return true;
else
return left_it->second.Name < right_it->second.Name;
}
};
sal_Int32 m_nNextId;
std::hash_map< sal_Int32, HashedStyle > m_aIdToStyle;
std::hash_map< HashedStyle, sal_Int32, StyleHash > m_aStyleToId;
void impl_emitStyle( sal_Int32 nStyleId,
EmitContext& rContext,
ElementTreeVisitor& rContainedElemVisitor );
public:
StyleContainer();
void emit( EmitContext& rContext,
ElementTreeVisitor& rContainedElemVisitor );
sal_Int32 impl_getStyleId( const Style& rStyle, bool bSubStyle );
sal_Int32 getStyleId( const Style& rStyle )
{ return impl_getStyleId( rStyle, false ); }
// returns NULL for an invalid style id
const PropertyMap* getProperties( sal_Int32 nStyleId ) const;
sal_Int32 setProperties( sal_Int32 nStyleId, const PropertyMap &rNewProps );
rtl::OUString getStyleName( sal_Int32 nStyle ) const;
};
}
#endif
/*************************************************************************
*
* 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: treevisiting.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_TREEVISITING_HXX
#define INCLUDED_PDFI_TREEVISITING_HXX
#include <sal/config.h>
#include <list>
namespace pdfi
{
class PDFIProcessor;
class StyleContainer;
struct HyperlinkElement;
struct TextElement;
struct ParagraphElement;
struct FrameElement;
struct PolyPolyElement;
struct ImageElement;
struct PageElement;
struct DocumentElement;
struct EmitContext;
struct Element;
/** To be visited by all tree element types
Visitor interface from the "visitor pattern". Implementor gets
called with actual tree node instances.
*/
struct ElementTreeVisitor
{
virtual void visit( HyperlinkElement&, const std::list< Element* >::const_iterator& ) = 0;
virtual void visit( TextElement&, const std::list< Element* >::const_iterator& ) = 0;
virtual void visit( ParagraphElement&, const std::list< Element* >::const_iterator& ) = 0;
virtual void visit( FrameElement&, const std::list< Element* >::const_iterator& ) = 0;
virtual void visit( PolyPolyElement&, const std::list< Element* >::const_iterator& ) = 0;
virtual void visit( ImageElement&, const std::list< Element* >::const_iterator& ) = 0;
virtual void visit( PageElement&, const std::list< Element* >::const_iterator& ) = 0;
virtual void visit( DocumentElement&, const std::list< Element* >::const_iterator& ) = 0;
};
typedef boost::shared_ptr<ElementTreeVisitor> ElementTreeVisitorSharedPtr;
/** Visitee interface
To be implemented by every tree node that needs to be
visitable.
*/
struct ElementTreeVisitable
{
virtual void visitedBy( ElementTreeVisitor&, const std::list< Element* >::const_iterator& rParentIt ) = 0;
};
typedef boost::shared_ptr<ElementTreeVisitable> ElementTreeVisitableSharedPtr;
}
#endif
/*************************************************************************
*
* 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: writertreevisiting.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_WRITERTREEVISITING_HXX
#define INCLUDED_PDFI_WRITERTREEVISITING_HXX
#include "treevisiting.hxx"
namespace pdfi
{
struct DrawElement;
class WriterXmlOptimizer : public ElementTreeVisitor
{
private:
PDFIProcessor& m_rProcessor;
void optimizeTextElements(Element& rParent);
void checkHeaderAndFooter( PageElement& rElem );
public:
explicit WriterXmlOptimizer(PDFIProcessor& rProcessor) :
m_rProcessor(rProcessor)
{}
virtual ~WriterXmlOptimizer()
{}
virtual void visit( HyperlinkElement&, const std::list< Element* >::const_iterator& );
virtual void visit( TextElement&, const std::list< Element* >::const_iterator& );
virtual void visit( ParagraphElement&, const std::list< Element* >::const_iterator& );
virtual void visit( FrameElement&, const std::list< Element* >::const_iterator& );
virtual void visit( PolyPolyElement&, const std::list< Element* >::const_iterator& );
virtual void visit( ImageElement&, const std::list< Element* >::const_iterator& );
virtual void visit( PageElement&, const std::list< Element* >::const_iterator& );
virtual void visit( DocumentElement&, const std::list< Element* >::const_iterator& );
};
class WriterXmlFinalizer : public ElementTreeVisitor
{
private:
StyleContainer& m_rStyleContainer;
PDFIProcessor& m_rProcessor;
void setFirstOnPage( ParagraphElement& rElem,
StyleContainer& rStyles,
const rtl::OUString& rMasterPageName );
public:
explicit WriterXmlFinalizer(StyleContainer& rStyleContainer,
PDFIProcessor& rProcessor) :
m_rStyleContainer(rStyleContainer),
m_rProcessor(rProcessor)
{}
virtual ~WriterXmlFinalizer()
{}
virtual void visit( HyperlinkElement&, const std::list< Element* >::const_iterator& );
virtual void visit( TextElement&, const std::list< Element* >::const_iterator& );
virtual void visit( ParagraphElement&, const std::list< Element* >::const_iterator& );
virtual void visit( FrameElement&, const std::list< Element* >::const_iterator& );
virtual void visit( PolyPolyElement&, const std::list< Element* >::const_iterator& );
virtual void visit( ImageElement&, const std::list< Element* >::const_iterator& );
virtual void visit( PageElement&, const std::list< Element* >::const_iterator& );
virtual void visit( DocumentElement&, const std::list< Element* >::const_iterator& );
};
class WriterXmlEmitter : public ElementTreeVisitor
{
private:
EmitContext& m_rEmitContext ;
void fillFrameProps( DrawElement& rElem,
PropertyMap& rProps,
const EmitContext& rEmitContext );
public:
explicit WriterXmlEmitter(EmitContext& rEmitContext) :
m_rEmitContext(rEmitContext)
{}
virtual ~WriterXmlEmitter()
{}
virtual void visit( HyperlinkElement&, const std::list< Element* >::const_iterator& );
virtual void visit( TextElement&, const std::list< Element* >::const_iterator& );
virtual void visit( ParagraphElement&, const std::list< Element* >::const_iterator& );
virtual void visit( FrameElement&, const std::list< Element* >::const_iterator& );
virtual void visit( PolyPolyElement&, const std::list< Element* >::const_iterator& );
virtual void visit( ImageElement&, const std::list< Element* >::const_iterator& );
virtual void visit( PageElement&, const std::list< Element* >::const_iterator& );
virtual void visit( DocumentElement&, const std::list< Element* >::const_iterator& );
};
}
#endif
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