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