xref: /AOO41X/main/sdext/source/pdfimport/tree/drawtreevisiting.hxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
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_DRAWTREEVISITING_HXX
29 #define INCLUDED_PDFI_DRAWTREEVISITING_HXX
30 
31 #include "treevisiting.hxx"
32 
33 #include "com/sun/star/i18n/XBreakIterator.hpp"
34 #include "com/sun/star/i18n/XCharacterClassification.hpp"
35 #include "com/sun/star/lang/XMultiServiceFactory.hpp"
36 #include "com/sun/star/uno/XComponentContext.hpp"
37 
38 namespace pdfi
39 {
40     struct DrawElement;
41 
42     class DrawXmlOptimizer : public ElementTreeVisitor
43     {
44     private:
45         PDFIProcessor& m_rProcessor;
46         void optimizeTextElements(Element& rParent);
47 
48     public:
49 	::com::sun::star::uno::Reference< ::com::sun::star::i18n::XBreakIterator > mxBreakIter;
50 	const ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XBreakIterator >& GetBreakIterator();
51         explicit DrawXmlOptimizer(PDFIProcessor& rProcessor) :
52             m_rProcessor(rProcessor)
53         {}
54 
55         virtual void visit( HyperlinkElement&, const std::list< Element* >::const_iterator& );
56         virtual void visit( TextElement&, const std::list< Element* >::const_iterator&  );
57         virtual void visit( ParagraphElement&, const std::list< Element* >::const_iterator&  );
58         virtual void visit( FrameElement&, const std::list< Element* >::const_iterator&  );
59         virtual void visit( PolyPolyElement&, const std::list< Element* >::const_iterator&  );
60         virtual void visit( ImageElement&, const std::list< Element* >::const_iterator&  );
61         virtual void visit( PageElement&, const std::list< Element* >::const_iterator&  );
62         virtual void visit( DocumentElement&, const std::list< Element* >::const_iterator&  );
63     };
64 
65     class DrawXmlFinalizer : public ElementTreeVisitor
66     {
67     private:
68         StyleContainer& m_rStyleContainer;
69         PDFIProcessor&  m_rProcessor;
70 
71     public:
72         explicit DrawXmlFinalizer(StyleContainer& rStyleContainer,
73                                   PDFIProcessor&  rProcessor) :
74             m_rStyleContainer(rStyleContainer),
75             m_rProcessor(rProcessor)
76         {}
77 
78         virtual void visit( HyperlinkElement&, const std::list< Element* >::const_iterator& );
79         virtual void visit( TextElement&, const std::list< Element* >::const_iterator&  );
80         virtual void visit( ParagraphElement&, const std::list< Element* >::const_iterator&  );
81         virtual void visit( FrameElement&, const std::list< Element* >::const_iterator&  );
82         virtual void visit( PolyPolyElement&, const std::list< Element* >::const_iterator&  );
83         virtual void visit( ImageElement&, const std::list< Element* >::const_iterator&  );
84         virtual void visit( PageElement&, const std::list< Element* >::const_iterator&  );
85         virtual void visit( DocumentElement&, const std::list< Element* >::const_iterator&  );
86     };
87 
88     class DrawXmlEmitter : public ElementTreeVisitor
89     {
90     private:
91 	::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xFactory;
92 	::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > xCtx;
93 	::com::sun::star::uno::Reference< ::com::sun::star::i18n::XBreakIterator > mxBreakIter;
94 	::com::sun::star::uno::Reference< ::com::sun::star::i18n::XCharacterClassification > mxCharClass;
95 
96 	    PDFIProcessor&  m_rProcessor;
97 
98         EmitContext& m_rEmitContext ;
99         /// writes Impress doc when false
100         const bool   m_bWriteDrawDocument;
101 
102         void fillFrameProps( DrawElement&       rElem,
103                              PropertyMap&       rProps,
104                              const EmitContext& rEmitContext,
105                              bool               bWasTransformed = false
106                              );
107 
108     public:
109 	const ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XBreakIterator >& GetBreakIterator();
110 	const ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XCharacterClassification >& GetCharacterClassification();
111         enum DocType{ DRAW_DOC, IMPRESS_DOC };
112         explicit DrawXmlEmitter(EmitContext& rEmitContext, DocType eDocType, PDFIProcessor& rProc ) :
113             m_rProcessor( rProc ),
114             m_rEmitContext(rEmitContext),
115             m_bWriteDrawDocument(eDocType==DRAW_DOC)
116         {}
117 
118         virtual void visit( HyperlinkElement&, const std::list< Element* >::const_iterator& );
119         virtual void visit( TextElement&, const std::list< Element* >::const_iterator&  );
120         virtual void visit( ParagraphElement&, const std::list< Element* >::const_iterator&  );
121         virtual void visit( FrameElement&, const std::list< Element* >::const_iterator&  );
122         virtual void visit( PolyPolyElement&, const std::list< Element* >::const_iterator&  );
123         virtual void visit( ImageElement&, const std::list< Element* >::const_iterator&  );
124         virtual void visit( PageElement&, const std::list< Element* >::const_iterator&  );
125         virtual void visit( DocumentElement&, const std::list< Element* >::const_iterator&  );
126     };
127 }
128 
129 #endif
130