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 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_forms.hxx" 30 #include "richtextunowrapper.hxx" 31 32 /** === begin UNO includes === **/ 33 #include <com/sun/star/container/XNameContainer.hpp> 34 /** === end UNO includes === **/ 35 #include <editeng/unofored.hxx> 36 #include <editeng/editview.hxx> 37 #include <editeng/unoipset.hxx> 38 #include <svx/svdpool.hxx> 39 #include <svx/svdobj.hxx> 40 #include <editeng/unoprnms.hxx> 41 42 //........................................................................ 43 namespace frm 44 { 45 //........................................................................ 46 47 using namespace ::com::sun::star::uno; 48 using namespace ::com::sun::star::lang; 49 using namespace ::com::sun::star::beans; 50 using namespace ::com::sun::star::container; 51 52 //==================================================================== 53 namespace 54 { 55 const SvxItemPropertySet* getTextEnginePropertySet() 56 { 57 // Propertymap fuer einen Outliner Text 58 static const SfxItemPropertyMapEntry aTextEnginePropertyMap[] = 59 { 60 SVX_UNOEDIT_CHAR_PROPERTIES, 61 SVX_UNOEDIT_FONT_PROPERTIES, 62 SVX_UNOEDIT_PARA_PROPERTIES, 63 { MAP_CHAR_LEN("TextUserDefinedAttributes"), EE_CHAR_XMLATTRIBS, &::getCppuType( static_cast< const Reference< XNameContainer >* >( NULL ) ), 0, 0 }, 64 { MAP_CHAR_LEN("ParaUserDefinedAttributes"), EE_PARA_XMLATTRIBS, &::getCppuType( static_cast< const Reference< XNameContainer >* >( NULL ) ), 0, 0 }, 65 { NULL, 0, 0, NULL, 0, 0 } 66 }; 67 static SvxItemPropertySet aTextEnginePropertySet( aTextEnginePropertyMap, SdrObject::GetGlobalDrawObjectItemPool() ); 68 return &aTextEnginePropertySet; 69 } 70 } 71 72 //==================================================================== 73 //= ORichTextUnoWrapper 74 //==================================================================== 75 //-------------------------------------------------------------------- 76 ORichTextUnoWrapper::ORichTextUnoWrapper( EditEngine& _rEngine, IEngineTextChangeListener* _pTextChangeListener ) 77 :SvxUnoText( getTextEnginePropertySet() ) 78 { 79 SetEditSource( new RichTextEditSource( _rEngine, _pTextChangeListener ) ); 80 } 81 82 //-------------------------------------------------------------------- 83 ORichTextUnoWrapper::~ORichTextUnoWrapper() throw() 84 { 85 } 86 87 //==================================================================== 88 //= RichTextEditSource 89 //==================================================================== 90 //-------------------------------------------------------------------- 91 RichTextEditSource::RichTextEditSource( EditEngine& _rEngine, IEngineTextChangeListener* _pTextChangeListener ) 92 :m_rEngine ( _rEngine ) 93 ,m_pTextForwarder ( new SvxEditEngineForwarder( _rEngine ) ) 94 ,m_pTextChangeListener ( _pTextChangeListener ) 95 { 96 } 97 98 //-------------------------------------------------------------------- 99 RichTextEditSource::~RichTextEditSource() 100 { 101 delete m_pTextForwarder; 102 } 103 104 //-------------------------------------------------------------------- 105 SvxEditSource* RichTextEditSource::Clone() const 106 { 107 return new RichTextEditSource( m_rEngine, m_pTextChangeListener ); 108 } 109 110 //-------------------------------------------------------------------- 111 SvxTextForwarder* RichTextEditSource::GetTextForwarder() 112 { 113 return m_pTextForwarder; 114 } 115 116 //-------------------------------------------------------------------- 117 void RichTextEditSource::UpdateData() 118 { 119 // this means that the content of the EditEngine changed via the UNO API 120 // to reflect this in the views, we need to update them 121 sal_uInt16 viewCount = m_rEngine.GetViewCount(); 122 for ( sal_uInt16 view = 0; view < viewCount; ++view ) 123 { 124 EditView* pView = m_rEngine.GetView( view ); 125 if ( pView ) 126 pView->ForceUpdate(); 127 } 128 129 if ( m_pTextChangeListener ) 130 m_pTextChangeListener->potentialTextChange(); 131 } 132 133 //........................................................................ 134 } // namespace frm 135 //........................................................................ 136 137