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 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sdext.hxx"
26 
27 #include "treevisitorfactory.hxx"
28 #include "writertreevisiting.hxx"
29 #include "drawtreevisiting.hxx"
30 
31 namespace pdfi
32 {
33     struct WriterTreeVisitorFactory : public TreeVisitorFactory
34     {
WriterTreeVisitorFactorypdfi::WriterTreeVisitorFactory35         WriterTreeVisitorFactory() {}
36 
createOptimizingVisitorpdfi::WriterTreeVisitorFactory37         virtual boost::shared_ptr<ElementTreeVisitor> createOptimizingVisitor(PDFIProcessor& rProc) const
38         {
39             return boost::shared_ptr<ElementTreeVisitor>(new WriterXmlOptimizer(rProc));
40         }
41 
createStyleCollectingVisitorpdfi::WriterTreeVisitorFactory42         virtual boost::shared_ptr<ElementTreeVisitor> createStyleCollectingVisitor(
43             StyleContainer& rStyles,
44             PDFIProcessor&  rProc ) const
45         {
46             return boost::shared_ptr<ElementTreeVisitor>(new WriterXmlFinalizer(rStyles,rProc));
47         }
48 
createEmittingVisitorpdfi::WriterTreeVisitorFactory49         virtual boost::shared_ptr<ElementTreeVisitor> createEmittingVisitor(EmitContext& rEmitContext, PDFIProcessor&) const
50         {
51             return boost::shared_ptr<ElementTreeVisitor>(new WriterXmlEmitter(rEmitContext));
52         }
53     };
54 
55     struct ImpressTreeVisitorFactory : public TreeVisitorFactory
56     {
ImpressTreeVisitorFactorypdfi::ImpressTreeVisitorFactory57         ImpressTreeVisitorFactory() {}
58 
createOptimizingVisitorpdfi::ImpressTreeVisitorFactory59         virtual boost::shared_ptr<ElementTreeVisitor> createOptimizingVisitor(PDFIProcessor& rProc) const
60         {
61             return boost::shared_ptr<ElementTreeVisitor>(new DrawXmlOptimizer(rProc));
62         }
63 
createStyleCollectingVisitorpdfi::ImpressTreeVisitorFactory64         virtual boost::shared_ptr<ElementTreeVisitor> createStyleCollectingVisitor(
65             StyleContainer& rStyles,
66             PDFIProcessor&  rProc ) const
67         {
68             return boost::shared_ptr<ElementTreeVisitor>(new DrawXmlFinalizer(rStyles,rProc));
69         }
70 
createEmittingVisitorpdfi::ImpressTreeVisitorFactory71         virtual boost::shared_ptr<ElementTreeVisitor> createEmittingVisitor(EmitContext& rEmitContext, PDFIProcessor& rProc) const
72         {
73             return boost::shared_ptr<ElementTreeVisitor>(new DrawXmlEmitter(rEmitContext,
74                                                                             DrawXmlEmitter::IMPRESS_DOC,
75                                                                             rProc
76                                                                             ));
77         }
78     };
79 
80     struct DrawTreeVisitorFactory : public TreeVisitorFactory
81     {
DrawTreeVisitorFactorypdfi::DrawTreeVisitorFactory82         DrawTreeVisitorFactory() {}
83 
createOptimizingVisitorpdfi::DrawTreeVisitorFactory84         virtual boost::shared_ptr<ElementTreeVisitor> createOptimizingVisitor(PDFIProcessor& rProc) const
85         {
86             return boost::shared_ptr<ElementTreeVisitor>(new DrawXmlOptimizer(rProc));
87         }
88 
createStyleCollectingVisitorpdfi::DrawTreeVisitorFactory89         virtual boost::shared_ptr<ElementTreeVisitor> createStyleCollectingVisitor(
90             StyleContainer& rStyles,
91             PDFIProcessor&  rProc ) const
92         {
93             return boost::shared_ptr<ElementTreeVisitor>(new DrawXmlFinalizer(rStyles,rProc));
94         }
95 
createEmittingVisitorpdfi::DrawTreeVisitorFactory96         virtual boost::shared_ptr<ElementTreeVisitor> createEmittingVisitor(EmitContext& rEmitContext, PDFIProcessor& rProc) const
97         {
98             return boost::shared_ptr<ElementTreeVisitor>(new DrawXmlEmitter(rEmitContext,
99                                                                             DrawXmlEmitter::DRAW_DOC,
100                                                                             rProc
101                                                                             ));
102         }
103     };
104 
createWriterTreeVisitorFactory()105     TreeVisitorFactorySharedPtr createWriterTreeVisitorFactory()
106     {
107         return TreeVisitorFactorySharedPtr(new WriterTreeVisitorFactory());
108     }
createImpressTreeVisitorFactory()109     TreeVisitorFactorySharedPtr createImpressTreeVisitorFactory()
110     {
111         return TreeVisitorFactorySharedPtr(new ImpressTreeVisitorFactory());
112     }
createDrawTreeVisitorFactory()113     TreeVisitorFactorySharedPtr createDrawTreeVisitorFactory()
114     {
115         return TreeVisitorFactorySharedPtr(new DrawTreeVisitorFactory());
116     }
117 }
118 
119