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