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 #ifndef INCLUDED_DOMAINMAPPER_HXX 28 #define INCLUDED_DOMAINMAPPER_HXX 29 30 #include <WriterFilterDllApi.hxx> 31 #include <resourcemodel/LoggedResources.hxx> 32 #include <com/sun/star/lang/XComponent.hpp> 33 #include <com/sun/star/text/FontEmphasis.hpp> 34 #include <com/sun/star/style/TabAlign.hpp> 35 36 #include <map> 37 #include <vector> 38 39 namespace com{ namespace sun {namespace star{ 40 namespace beans{ 41 struct PropertyValue; 42 } 43 namespace io{ 44 class XInputStream; 45 } 46 namespace uno{ 47 class XComponentContext; 48 } 49 namespace lang{ 50 class XMultiServiceFactory; 51 } 52 namespace text{ 53 class XTextRange; 54 } 55 }}} 56 57 typedef std::vector< com::sun::star::beans::PropertyValue > PropertyValueVector_t; 58 59 namespace writerfilter { 60 namespace dmapper 61 { 62 63 class PropertyMap; 64 class DomainMapper_Impl; 65 class ListsManager; 66 class StyleSheetTable; 67 68 // different context types require different sprm handling (e.g. names) 69 enum SprmType 70 { 71 SPRM_DEFAULT, 72 SPRM_LIST 73 }; 74 enum SourceDocumentType 75 { 76 DOCUMENT_DOC, 77 DOCUMENT_OOXML, 78 DOCUMENT_RTF 79 }; 80 class WRITERFILTER_DLLPUBLIC DomainMapper : public LoggedProperties, public LoggedTable, 81 public BinaryObj, public LoggedStream 82 { 83 DomainMapper_Impl *m_pImpl; 84 85 public: 86 DomainMapper(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext, 87 ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > xInputStream, 88 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > xModel, 89 SourceDocumentType eDocumentType ); 90 virtual ~DomainMapper(); 91 92 // Stream 93 virtual void markLastParagraphInSection(); 94 95 // BinaryObj 96 virtual void data(const sal_uInt8* buf, size_t len, 97 writerfilter::Reference<Properties>::Pointer_t ref); 98 99 void sprmWithProps( Sprm& sprm, ::boost::shared_ptr<PropertyMap> pContext, SprmType = SPRM_DEFAULT ); 100 101 void PushStyleSheetProperties( ::boost::shared_ptr<PropertyMap> pStyleProperties, bool bAffectTableMngr = false ); 102 void PopStyleSheetProperties( bool bAffectTableMngr = false ); 103 104 void PushListProperties( ::boost::shared_ptr<PropertyMap> pListProperties ); 105 void PopListProperties(); 106 107 bool IsOOXMLImport() const; 108 ::com::sun::star::uno::Reference < ::com::sun::star::lang::XMultiServiceFactory > GetTextFactory() const; 109 void AddListIDToLFOTable( sal_Int32 nAbstractNumId ); 110 ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > GetCurrentTextRange(); 111 112 ::rtl::OUString getOrCreateCharStyle( PropertyValueVector_t& rCharProperties ); 113 boost::shared_ptr< ListsManager > GetListTable( ); 114 boost::shared_ptr< StyleSheetTable > GetStyleSheetTable( ); 115 116 private: 117 // Stream 118 virtual void lcl_startSectionGroup(); 119 virtual void lcl_endSectionGroup(); 120 virtual void lcl_startParagraphGroup(); 121 virtual void lcl_endParagraphGroup(); 122 virtual void lcl_startCharacterGroup(); 123 virtual void lcl_endCharacterGroup(); 124 virtual void lcl_startShape( ::com::sun::star::uno::Reference< com::sun::star::drawing::XShape > xShape ); 125 virtual void lcl_endShape( ); 126 127 virtual void lcl_text(const sal_uInt8 * data, size_t len); 128 virtual void lcl_utext(const sal_uInt8 * data, size_t len); 129 virtual void lcl_props(writerfilter::Reference<Properties>::Pointer_t ref); 130 virtual void lcl_table(Id name, 131 writerfilter::Reference<Table>::Pointer_t ref); 132 virtual void lcl_substream(Id name, 133 ::writerfilter::Reference<Stream>::Pointer_t ref); 134 virtual void lcl_info(const string & info); 135 136 // Properties 137 virtual void lcl_attribute(Id Name, Value & val); 138 virtual void lcl_sprm(Sprm & sprm); 139 140 // Table 141 virtual void lcl_entry(int pos, writerfilter::Reference<Properties>::Pointer_t ref); 142 143 void handleUnderlineType(const sal_Int32 nIntValue, const ::boost::shared_ptr<PropertyMap> pContext); 144 void handleParaJustification(const sal_Int32 nIntValue, const ::boost::shared_ptr<PropertyMap> pContext, const bool bExchangeLeftRight); 145 bool getColorFromIndex(const sal_Int32 nIndex, sal_Int32 &nColor); 146 sal_Int16 getEmphasisValue(const sal_Int32 nIntValue); 147 rtl::OUString getBracketStringFromEnum(const sal_Int32 nIntValue, const bool bIsPrefix = true); 148 com::sun::star::style::TabAlign getTabAlignFromValue(const sal_Int32 nIntValue); 149 sal_Unicode getFillCharFromValue(const sal_Int32 nIntValue); 150 sal_Int32 mnBackgroundColor; 151 bool mbIsHighlightSet; 152 }; 153 154 } // namespace dmapper 155 } // namespace writerfilter 156 #endif // 157