Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef INCLUDED_SDEXT_SOURCE_PDFIMPORT_TREE_DRAWTREEVISITING_HXX
21 : #define INCLUDED_SDEXT_SOURCE_PDFIMPORT_TREE_DRAWTREEVISITING_HXX
22 :
23 : #include "treevisiting.hxx"
24 :
25 : #include "com/sun/star/i18n/XBreakIterator.hpp"
26 : #include "com/sun/star/i18n/XCharacterClassification.hpp"
27 : #include "com/sun/star/lang/XMultiServiceFactory.hpp"
28 : #include "com/sun/star/uno/XComponentContext.hpp"
29 :
30 : namespace pdfi
31 : {
32 : struct DrawElement;
33 :
34 6 : class DrawXmlOptimizer : public ElementTreeVisitor
35 : {
36 : private:
37 : PDFIProcessor& m_rProcessor;
38 : void optimizeTextElements(Element& rParent);
39 :
40 : public:
41 : css::uno::Reference< css::i18n::XBreakIterator > mxBreakIter;
42 : const css::uno::Reference< css::i18n::XBreakIterator >& GetBreakIterator();
43 3 : explicit DrawXmlOptimizer(PDFIProcessor& rProcessor) :
44 3 : m_rProcessor(rProcessor)
45 3 : {}
46 :
47 : virtual void visit( HyperlinkElement&, const std::list< Element* >::const_iterator& ) SAL_OVERRIDE;
48 : virtual void visit( TextElement&, const std::list< Element* >::const_iterator& ) SAL_OVERRIDE;
49 : virtual void visit( ParagraphElement&, const std::list< Element* >::const_iterator& ) SAL_OVERRIDE;
50 : virtual void visit( FrameElement&, const std::list< Element* >::const_iterator& ) SAL_OVERRIDE;
51 : virtual void visit( PolyPolyElement&, const std::list< Element* >::const_iterator& ) SAL_OVERRIDE;
52 : virtual void visit( ImageElement&, const std::list< Element* >::const_iterator& ) SAL_OVERRIDE;
53 : virtual void visit( PageElement&, const std::list< Element* >::const_iterator& ) SAL_OVERRIDE;
54 : virtual void visit( DocumentElement&, const std::list< Element* >::const_iterator& ) SAL_OVERRIDE;
55 : };
56 :
57 6 : class DrawXmlFinalizer : public ElementTreeVisitor
58 : {
59 : private:
60 : StyleContainer& m_rStyleContainer;
61 : PDFIProcessor& m_rProcessor;
62 :
63 : public:
64 3 : explicit DrawXmlFinalizer(StyleContainer& rStyleContainer,
65 : PDFIProcessor& rProcessor) :
66 : m_rStyleContainer(rStyleContainer),
67 3 : m_rProcessor(rProcessor)
68 3 : {}
69 :
70 : virtual void visit( HyperlinkElement&, const std::list< Element* >::const_iterator& ) SAL_OVERRIDE;
71 : virtual void visit( TextElement&, const std::list< Element* >::const_iterator& ) SAL_OVERRIDE;
72 : virtual void visit( ParagraphElement&, const std::list< Element* >::const_iterator& ) SAL_OVERRIDE;
73 : virtual void visit( FrameElement&, const std::list< Element* >::const_iterator& ) SAL_OVERRIDE;
74 : virtual void visit( PolyPolyElement&, const std::list< Element* >::const_iterator& ) SAL_OVERRIDE;
75 : virtual void visit( ImageElement&, const std::list< Element* >::const_iterator& ) SAL_OVERRIDE;
76 : virtual void visit( PageElement&, const std::list< Element* >::const_iterator& ) SAL_OVERRIDE;
77 : virtual void visit( DocumentElement&, const std::list< Element* >::const_iterator& ) SAL_OVERRIDE;
78 : };
79 :
80 6 : class DrawXmlEmitter : public ElementTreeVisitor
81 : {
82 : private:
83 : css::uno::Reference< css::lang::XMultiServiceFactory > xFactory;
84 : css::uno::Reference< css::uno::XComponentContext > xCtx;
85 : css::uno::Reference< css::i18n::XBreakIterator > mxBreakIter;
86 : css::uno::Reference< css::i18n::XCharacterClassification > mxCharClass;
87 :
88 : EmitContext& m_rEmitContext ;
89 : /// writes Impress doc when false
90 : const bool m_bWriteDrawDocument;
91 :
92 : static void fillFrameProps( DrawElement& rElem,
93 : PropertyMap& rProps,
94 : const EmitContext& rEmitContext,
95 : bool bWasTransformed = false
96 : );
97 :
98 : public:
99 : const css::uno::Reference< css::i18n::XCharacterClassification >& GetCharacterClassification();
100 : enum DocType{ DRAW_DOC, IMPRESS_DOC };
101 3 : explicit DrawXmlEmitter(EmitContext& rEmitContext, DocType eDocType) :
102 : m_rEmitContext(rEmitContext),
103 3 : m_bWriteDrawDocument(eDocType==DRAW_DOC)
104 3 : {}
105 :
106 : virtual void visit( HyperlinkElement&, const std::list< Element* >::const_iterator& ) SAL_OVERRIDE;
107 : virtual void visit( TextElement&, const std::list< Element* >::const_iterator& ) SAL_OVERRIDE;
108 : virtual void visit( ParagraphElement&, const std::list< Element* >::const_iterator& ) SAL_OVERRIDE;
109 : virtual void visit( FrameElement&, const std::list< Element* >::const_iterator& ) SAL_OVERRIDE;
110 : virtual void visit( PolyPolyElement&, const std::list< Element* >::const_iterator& ) SAL_OVERRIDE;
111 : virtual void visit( ImageElement&, const std::list< Element* >::const_iterator& ) SAL_OVERRIDE;
112 : virtual void visit( PageElement&, const std::list< Element* >::const_iterator& ) SAL_OVERRIDE;
113 : virtual void visit( DocumentElement&, const std::list< Element* >::const_iterator& ) SAL_OVERRIDE;
114 : };
115 : }
116 :
117 : #endif
118 :
119 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|