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