1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef INCLUDED_PDFI_WRITERTREEVISITING_HXX
25 #define INCLUDED_PDFI_WRITERTREEVISITING_HXX
26 
27 #include "treevisiting.hxx"
28 
29 namespace pdfi
30 {
31     struct DrawElement;
32 
33     class WriterXmlOptimizer : public ElementTreeVisitor
34     {
35     private:
36         PDFIProcessor& m_rProcessor;
37         void optimizeTextElements(Element& rParent);
38         void checkHeaderAndFooter( PageElement& rElem );
39 
40     public:
WriterXmlOptimizer(PDFIProcessor & rProcessor)41         explicit WriterXmlOptimizer(PDFIProcessor& rProcessor) :
42             m_rProcessor(rProcessor)
43         {}
~WriterXmlOptimizer()44         virtual ~WriterXmlOptimizer()
45         {}
46 
47         virtual void visit( HyperlinkElement&, const std::list< Element* >::const_iterator& );
48         virtual void visit( TextElement&, const std::list< Element* >::const_iterator&  );
49         virtual void visit( ParagraphElement&, const std::list< Element* >::const_iterator&  );
50         virtual void visit( FrameElement&, const std::list< Element* >::const_iterator&  );
51         virtual void visit( PolyPolyElement&, const std::list< Element* >::const_iterator&  );
52         virtual void visit( ImageElement&, const std::list< Element* >::const_iterator&  );
53         virtual void visit( PageElement&, const std::list< Element* >::const_iterator&  );
54         virtual void visit( DocumentElement&, const std::list< Element* >::const_iterator&  );
55     };
56 
57     class WriterXmlFinalizer : public ElementTreeVisitor
58     {
59     private:
60         StyleContainer& m_rStyleContainer;
61         PDFIProcessor&  m_rProcessor;
62 
63         void setFirstOnPage( ParagraphElement&    rElem,
64                              StyleContainer&      rStyles,
65                              const rtl::OUString& rMasterPageName );
66 
67     public:
WriterXmlFinalizer(StyleContainer & rStyleContainer,PDFIProcessor & rProcessor)68         explicit WriterXmlFinalizer(StyleContainer& rStyleContainer,
69                                     PDFIProcessor&  rProcessor) :
70             m_rStyleContainer(rStyleContainer),
71             m_rProcessor(rProcessor)
72         {}
~WriterXmlFinalizer()73         virtual ~WriterXmlFinalizer()
74         {}
75 
76         virtual void visit( HyperlinkElement&, const std::list< Element* >::const_iterator& );
77         virtual void visit( TextElement&, const std::list< Element* >::const_iterator&  );
78         virtual void visit( ParagraphElement&, const std::list< Element* >::const_iterator&  );
79         virtual void visit( FrameElement&, const std::list< Element* >::const_iterator&  );
80         virtual void visit( PolyPolyElement&, const std::list< Element* >::const_iterator&  );
81         virtual void visit( ImageElement&, const std::list< Element* >::const_iterator&  );
82         virtual void visit( PageElement&, const std::list< Element* >::const_iterator&  );
83         virtual void visit( DocumentElement&, const std::list< Element* >::const_iterator&  );
84     };
85 
86     class WriterXmlEmitter : public ElementTreeVisitor
87     {
88     private:
89         EmitContext& m_rEmitContext ;
90         void fillFrameProps( DrawElement&       rElem,
91                              PropertyMap&       rProps,
92                              const EmitContext& rEmitContext );
93 
94     public:
WriterXmlEmitter(EmitContext & rEmitContext)95         explicit WriterXmlEmitter(EmitContext& rEmitContext) :
96             m_rEmitContext(rEmitContext)
97         {}
~WriterXmlEmitter()98         virtual ~WriterXmlEmitter()
99         {}
100 
101         virtual void visit( HyperlinkElement&, const std::list< Element* >::const_iterator& );
102         virtual void visit( TextElement&, const std::list< Element* >::const_iterator&  );
103         virtual void visit( ParagraphElement&, const std::list< Element* >::const_iterator&  );
104         virtual void visit( FrameElement&, const std::list< Element* >::const_iterator&  );
105         virtual void visit( PolyPolyElement&, const std::list< Element* >::const_iterator&  );
106         virtual void visit( ImageElement&, const std::list< Element* >::const_iterator&  );
107         virtual void visit( PageElement&, const std::list< Element* >::const_iterator&  );
108         virtual void visit( DocumentElement&, const std::list< Element* >::const_iterator&  );
109     };
110 }
111 
112 #endif
113