1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef INCLUDED_PDFI_WRITERTREEVISITING_HXX
29 #define INCLUDED_PDFI_WRITERTREEVISITING_HXX
30 
31 #include "treevisiting.hxx"
32 
33 namespace pdfi
34 {
35     struct DrawElement;
36 
37     class WriterXmlOptimizer : public ElementTreeVisitor
38     {
39     private:
40         PDFIProcessor& m_rProcessor;
41         void optimizeTextElements(Element& rParent);
42         void checkHeaderAndFooter( PageElement& rElem );
43 
44     public:
45         explicit WriterXmlOptimizer(PDFIProcessor& rProcessor) :
46             m_rProcessor(rProcessor)
47         {}
48         virtual ~WriterXmlOptimizer()
49         {}
50 
51         virtual void visit( HyperlinkElement&, const std::list< Element* >::const_iterator& );
52         virtual void visit( TextElement&, const std::list< Element* >::const_iterator&  );
53         virtual void visit( ParagraphElement&, const std::list< Element* >::const_iterator&  );
54         virtual void visit( FrameElement&, const std::list< Element* >::const_iterator&  );
55         virtual void visit( PolyPolyElement&, const std::list< Element* >::const_iterator&  );
56         virtual void visit( ImageElement&, const std::list< Element* >::const_iterator&  );
57         virtual void visit( PageElement&, const std::list< Element* >::const_iterator&  );
58         virtual void visit( DocumentElement&, const std::list< Element* >::const_iterator&  );
59     };
60 
61     class WriterXmlFinalizer : public ElementTreeVisitor
62     {
63     private:
64         StyleContainer& m_rStyleContainer;
65         PDFIProcessor&  m_rProcessor;
66 
67         void setFirstOnPage( ParagraphElement&    rElem,
68                              StyleContainer&      rStyles,
69                              const rtl::OUString& rMasterPageName );
70 
71     public:
72         explicit WriterXmlFinalizer(StyleContainer& rStyleContainer,
73                                     PDFIProcessor&  rProcessor) :
74             m_rStyleContainer(rStyleContainer),
75             m_rProcessor(rProcessor)
76         {}
77         virtual ~WriterXmlFinalizer()
78         {}
79 
80         virtual void visit( HyperlinkElement&, const std::list< Element* >::const_iterator& );
81         virtual void visit( TextElement&, const std::list< Element* >::const_iterator&  );
82         virtual void visit( ParagraphElement&, const std::list< Element* >::const_iterator&  );
83         virtual void visit( FrameElement&, const std::list< Element* >::const_iterator&  );
84         virtual void visit( PolyPolyElement&, const std::list< Element* >::const_iterator&  );
85         virtual void visit( ImageElement&, const std::list< Element* >::const_iterator&  );
86         virtual void visit( PageElement&, const std::list< Element* >::const_iterator&  );
87         virtual void visit( DocumentElement&, const std::list< Element* >::const_iterator&  );
88     };
89 
90     class WriterXmlEmitter : public ElementTreeVisitor
91     {
92     private:
93         EmitContext& m_rEmitContext ;
94         void fillFrameProps( DrawElement&       rElem,
95                              PropertyMap&       rProps,
96                              const EmitContext& rEmitContext );
97 
98     public:
99         explicit WriterXmlEmitter(EmitContext& rEmitContext) :
100             m_rEmitContext(rEmitContext)
101         {}
102         virtual ~WriterXmlEmitter()
103         {}
104 
105         virtual void visit( HyperlinkElement&, const std::list< Element* >::const_iterator& );
106         virtual void visit( TextElement&, const std::list< Element* >::const_iterator&  );
107         virtual void visit( ParagraphElement&, const std::list< Element* >::const_iterator&  );
108         virtual void visit( FrameElement&, const std::list< Element* >::const_iterator&  );
109         virtual void visit( PolyPolyElement&, const std::list< Element* >::const_iterator&  );
110         virtual void visit( ImageElement&, const std::list< Element* >::const_iterator&  );
111         virtual void visit( PageElement&, const std::list< Element* >::const_iterator&  );
112         virtual void visit( DocumentElement&, const std::list< Element* >::const_iterator&  );
113     };
114 }
115 
116 #endif
117