1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "richtextmodel.hxx"
21 #include "richtextengine.hxx"
22 #include "richtextunowrapper.hxx"
24 #include <com/sun/star/awt/LineEndFormat.hpp>
25 #include <com/sun/star/text/WritingMode2.hpp>
26 #include <com/sun/star/style/VerticalAlignment.hpp>
28 #include <cppuhelper/typeprovider.hxx>
29 #include <comphelper/guarding.hxx>
30 #include <toolkit/awt/vclxdevice.hxx>
31 #include <toolkit/helper/vclunohelper.hxx>
32 #include <editeng/editstat.hxx>
33 #include <vcl/outdev.hxx>
34 #include <vcl/svapp.hxx>
36 //--------------------------------------------------------------------------
37 extern "C" void SAL_CALL
createRegistryInfo_ORichTextModel()
39 static ::frm::OMultiInstanceAutoRegistration
< ::frm::ORichTextModel
> aRegisterModel
;
42 //........................................................................
45 //........................................................................
47 using namespace ::com::sun::star::uno
;
48 using namespace ::com::sun::star::awt
;
49 using namespace ::com::sun::star::lang
;
50 using namespace ::com::sun::star::io
;
51 using namespace ::com::sun::star::beans
;
52 using namespace ::com::sun::star::form
;
53 using namespace ::com::sun::star::util
;
54 using namespace ::com::sun::star::style
;
56 namespace WritingMode2
= ::com::sun::star::text::WritingMode2
;
58 //====================================================================
60 //====================================================================
61 DBG_NAME( ORichTextModel
)
62 //--------------------------------------------------------------------
63 ORichTextModel::ORichTextModel( const Reference
< XMultiServiceFactory
>& _rxFactory
)
64 :OControlModel ( _rxFactory
, OUString() )
65 ,FontControlModel ( true )
66 ,m_pEngine ( RichTextEngine::Create() )
67 ,m_bSettingEngineText( false )
68 ,m_aModifyListeners ( m_aMutex
)
70 DBG_CTOR( ORichTextModel
, NULL
);
71 m_nClassId
= FormComponentType::TEXTFIELD
;
73 getPropertyDefaultByHandle( PROPERTY_ID_DEFAULTCONTROL
) >>= m_sDefaultControl
;
74 getPropertyDefaultByHandle( PROPERTY_ID_BORDER
) >>= m_nBorder
;
75 getPropertyDefaultByHandle( PROPERTY_ID_ENABLED
) >>= m_bEnabled
;
76 getPropertyDefaultByHandle( PROPERTY_ID_ENABLEVISIBLE
) >>= m_bEnableVisible
;
77 getPropertyDefaultByHandle( PROPERTY_ID_HARDLINEBREAKS
) >>= m_bHardLineBreaks
;
78 getPropertyDefaultByHandle( PROPERTY_ID_HSCROLL
) >>= m_bHScroll
;
79 getPropertyDefaultByHandle( PROPERTY_ID_VSCROLL
) >>= m_bVScroll
;
80 getPropertyDefaultByHandle( PROPERTY_ID_READONLY
) >>= m_bReadonly
;
81 getPropertyDefaultByHandle( PROPERTY_ID_PRINTABLE
) >>= m_bPrintable
;
82 getPropertyDefaultByHandle( PROPERTY_ID_ALIGN
) >>= m_aAlign
;
83 getPropertyDefaultByHandle( PROPERTY_ID_ECHO_CHAR
) >>= m_nEchoChar
;
84 getPropertyDefaultByHandle( PROPERTY_ID_MAXTEXTLEN
) >>= m_nMaxTextLength
;
85 getPropertyDefaultByHandle( PROPERTY_ID_MULTILINE
) >>= m_bMultiLine
;
86 getPropertyDefaultByHandle( PROPERTY_ID_RICH_TEXT
) >>= m_bReallyActAsRichText
;
87 getPropertyDefaultByHandle( PROPERTY_ID_HIDEINACTIVESELECTION
) >>= m_bHideInactiveSelection
;
88 getPropertyDefaultByHandle( PROPERTY_ID_LINEEND_FORMAT
) >>= m_nLineEndFormat
;
89 getPropertyDefaultByHandle( PROPERTY_ID_WRITING_MODE
) >>= m_nTextWritingMode
;
90 getPropertyDefaultByHandle( PROPERTY_ID_CONTEXT_WRITING_MODE
) >>= m_nContextWritingMode
;
95 //------------------------------------------------------------------
96 ORichTextModel::ORichTextModel( const ORichTextModel
* _pOriginal
, const Reference
< XMultiServiceFactory
>& _rxFactory
)
97 :OControlModel ( _pOriginal
, _rxFactory
, sal_False
)
98 ,FontControlModel ( _pOriginal
)
100 ,m_bSettingEngineText( false )
101 ,m_aModifyListeners ( m_aMutex
)
103 DBG_CTOR( ORichTextModel
, NULL
);
105 m_aTabStop
= _pOriginal
->m_aTabStop
;
106 m_aBackgroundColor
= _pOriginal
->m_aBackgroundColor
;
107 m_aBorderColor
= _pOriginal
->m_aBorderColor
;
108 m_aVerticalAlignment
= _pOriginal
->m_aVerticalAlignment
;
109 m_sDefaultControl
= _pOriginal
->m_sDefaultControl
;
110 m_sHelpText
= _pOriginal
->m_sHelpText
;
111 m_sHelpURL
= _pOriginal
->m_sHelpURL
;
112 m_nBorder
= _pOriginal
->m_nBorder
;
113 m_bEnabled
= _pOriginal
->m_bEnabled
;
114 m_bEnableVisible
= _pOriginal
->m_bEnableVisible
;
115 m_bHardLineBreaks
= _pOriginal
->m_bHardLineBreaks
;
116 m_bHScroll
= _pOriginal
->m_bHScroll
;
117 m_bVScroll
= _pOriginal
->m_bVScroll
;
118 m_bReadonly
= _pOriginal
->m_bReadonly
;
119 m_bPrintable
= _pOriginal
->m_bPrintable
;
120 m_bReallyActAsRichText
= _pOriginal
->m_bReallyActAsRichText
;
121 m_bHideInactiveSelection
= _pOriginal
->m_bHideInactiveSelection
;
122 m_nLineEndFormat
= _pOriginal
->m_nLineEndFormat
;
123 m_nTextWritingMode
= _pOriginal
->m_nTextWritingMode
;
124 m_nContextWritingMode
= _pOriginal
->m_nContextWritingMode
;
126 m_aAlign
= _pOriginal
->m_aAlign
;
127 m_nEchoChar
= _pOriginal
->m_nEchoChar
;
128 m_nMaxTextLength
= _pOriginal
->m_nMaxTextLength
;
129 m_bMultiLine
= _pOriginal
->m_bMultiLine
;
131 m_pEngine
.reset(_pOriginal
->m_pEngine
->Clone());
132 m_sLastKnownEngineText
= m_pEngine
->GetText();
137 //------------------------------------------------------------------
138 void ORichTextModel::implInit()
140 OSL_ENSURE( m_pEngine
.get(), "ORichTextModel::implInit: where's the engine?" );
141 if ( m_pEngine
.get() )
143 m_pEngine
->SetModifyHdl( LINK( this, ORichTextModel
, OnEngineContentModified
) );
145 sal_uLong nEngineControlWord
= m_pEngine
->GetControlWord();
146 nEngineControlWord
= nEngineControlWord
& ~EE_CNTRL_AUTOPAGESIZE
;
147 m_pEngine
->SetControlWord( nEngineControlWord
);
149 VCLXDevice
* pUnoRefDevice
= new VCLXDevice
;
150 pUnoRefDevice
->SetOutputDevice( m_pEngine
->GetRefDevice() );
151 m_xReferenceDevice
= pUnoRefDevice
;
155 implRegisterProperties();
158 //------------------------------------------------------------------
159 void ORichTextModel::implDoAggregation()
161 increment( m_refCount
);
164 m_xAggregate
= new ORichTextUnoWrapper( *m_pEngine
, this );
165 setAggregation( m_xAggregate
);
169 decrement( m_refCount
);
172 //------------------------------------------------------------------
173 void ORichTextModel::implRegisterProperties()
175 REGISTER_PROP_2( DEFAULTCONTROL
, m_sDefaultControl
, BOUND
, MAYBEDEFAULT
);
176 REGISTER_PROP_2( HELPTEXT
, m_sHelpText
, BOUND
, MAYBEDEFAULT
);
177 REGISTER_PROP_2( HELPURL
, m_sHelpURL
, BOUND
, MAYBEDEFAULT
);
178 REGISTER_PROP_2( ENABLED
, m_bEnabled
, BOUND
, MAYBEDEFAULT
);
179 REGISTER_PROP_2( ENABLEVISIBLE
, m_bEnableVisible
, BOUND
, MAYBEDEFAULT
);
180 REGISTER_PROP_2( BORDER
, m_nBorder
, BOUND
, MAYBEDEFAULT
);
181 REGISTER_PROP_2( HARDLINEBREAKS
, m_bHardLineBreaks
, BOUND
, MAYBEDEFAULT
);
182 REGISTER_PROP_2( HSCROLL
, m_bHScroll
, BOUND
, MAYBEDEFAULT
);
183 REGISTER_PROP_2( VSCROLL
, m_bVScroll
, BOUND
, MAYBEDEFAULT
);
184 REGISTER_PROP_2( READONLY
, m_bReadonly
, BOUND
, MAYBEDEFAULT
);
185 REGISTER_PROP_2( PRINTABLE
, m_bPrintable
, BOUND
, MAYBEDEFAULT
);
186 REGISTER_PROP_2( REFERENCE_DEVICE
, m_xReferenceDevice
, BOUND
, TRANSIENT
);
187 REGISTER_PROP_2( RICH_TEXT
, m_bReallyActAsRichText
, BOUND
, MAYBEDEFAULT
);
188 REGISTER_PROP_2( HIDEINACTIVESELECTION
, m_bHideInactiveSelection
, BOUND
, MAYBEDEFAULT
);
190 REGISTER_VOID_PROP_2( TABSTOP
, m_aTabStop
, sal_Bool
, BOUND
, MAYBEDEFAULT
);
191 REGISTER_VOID_PROP_2( BACKGROUNDCOLOR
, m_aBackgroundColor
, sal_Int32
, BOUND
, MAYBEDEFAULT
);
192 REGISTER_VOID_PROP_2( BORDERCOLOR
, m_aBorderColor
, sal_Int32
, BOUND
, MAYBEDEFAULT
);
193 REGISTER_VOID_PROP_2( VERTICAL_ALIGN
, m_aVerticalAlignment
, VerticalAlignment
, BOUND
, MAYBEDEFAULT
);
195 // properties which exist only for compatibility with the css.swt.UnoControlEditModel,
196 // since we replace the default implementation for this service
197 REGISTER_PROP_2( ECHO_CHAR
, m_nEchoChar
, BOUND
, MAYBEDEFAULT
);
198 REGISTER_PROP_2( MAXTEXTLEN
, m_nMaxTextLength
, BOUND
, MAYBEDEFAULT
);
199 REGISTER_PROP_2( MULTILINE
, m_bMultiLine
, BOUND
, MAYBEDEFAULT
);
200 REGISTER_PROP_2( TEXT
, m_sLastKnownEngineText
, BOUND
, MAYBEDEFAULT
);
201 REGISTER_PROP_2( LINEEND_FORMAT
, m_nLineEndFormat
, BOUND
, MAYBEDEFAULT
);
202 REGISTER_PROP_2( WRITING_MODE
, m_nTextWritingMode
, BOUND
, MAYBEDEFAULT
);
203 REGISTER_PROP_3( CONTEXT_WRITING_MODE
, m_nContextWritingMode
, BOUND
, MAYBEDEFAULT
, TRANSIENT
);
205 REGISTER_VOID_PROP_2( ALIGN
, m_aAlign
, sal_Int16
, BOUND
, MAYBEDEFAULT
);
208 //--------------------------------------------------------------------
209 ORichTextModel::~ORichTextModel( )
211 if ( !OComponentHelper::rBHelper
.bDisposed
)
216 if ( m_pEngine
.get() )
219 SfxItemPool
* pPool
= m_pEngine
->getPool();
221 SfxItemPool::Free(pPool
);
225 DBG_DTOR( ORichTextModel
, NULL
);
228 //------------------------------------------------------------------
229 Any SAL_CALL
ORichTextModel::queryAggregation( const Type
& _rType
) throw ( RuntimeException
)
231 Any aReturn
= ORichTextModel_BASE::queryInterface( _rType
);
233 if ( !aReturn
.hasValue() )
234 aReturn
= OControlModel::queryAggregation( _rType
);
239 //------------------------------------------------------------------
240 IMPLEMENT_FORWARD_XTYPEPROVIDER2( ORichTextModel
, OControlModel
, ORichTextModel_BASE
)
242 //--------------------------------------------------------------------
243 IMPLEMENT_SERVICE_REGISTRATION_8( ORichTextModel
, OControlModel
,
244 FRM_SUN_COMPONENT_RICHTEXTCONTROL
,
245 OUString( "com.sun.star.text.TextRange" ),
246 OUString( "com.sun.star.style.CharacterProperties" ),
247 OUString( "com.sun.star.style.ParagraphProperties" ),
248 OUString( "com.sun.star.style.CharacterPropertiesAsian" ),
249 OUString( "com.sun.star.style.CharacterPropertiesComplex" ),
250 OUString( "com.sun.star.style.ParagraphPropertiesAsian" ),
251 OUString( "com.sun.star.style.ParagraphPropertiesComplex" )
254 //------------------------------------------------------------------------------
255 IMPLEMENT_DEFAULT_CLONING( ORichTextModel
)
257 //------------------------------------------------------------------------------
258 void SAL_CALL
ORichTextModel::disposing()
260 m_aModifyListeners
.disposeAndClear( EventObject( *this ) );
261 OControlModel::disposing();
264 //------------------------------------------------------------------------------
267 void lcl_removeProperty( Sequence
< Property
>& _rSeq
, const OUString
& _rPropertyName
)
269 Property
* pLoop
= _rSeq
.getArray();
270 Property
* pEnd
= _rSeq
.getArray() + _rSeq
.getLength();
271 while ( pLoop
!= pEnd
)
273 if ( pLoop
->Name
== _rPropertyName
)
275 ::std::copy( pLoop
+ 1, pEnd
, pLoop
);
276 _rSeq
.realloc( _rSeq
.getLength() - 1 );
283 //------------------------------------------------------------------------------
284 void ORichTextModel::describeFixedProperties( Sequence
< Property
>& _rProps
) const
286 BEGIN_DESCRIBE_PROPERTIES( 1, OControlModel
)
287 DECL_PROP2( TABINDEX
, sal_Int16
, BOUND
, MAYBEDEFAULT
);
288 END_DESCRIBE_PROPERTIES();
290 // properties which the OPropertyContainerHelper is responsible for
291 Sequence
< Property
> aContainedProperties
;
292 describeProperties( aContainedProperties
);
294 // properties which the FontControlModel is responsible for
295 Sequence
< Property
> aFontProperties
;
296 describeFontRelatedProperties( aFontProperties
);
298 _rProps
= concatSequences( aContainedProperties
, aFontProperties
, _rProps
);
301 //------------------------------------------------------------------------------
302 void ORichTextModel::describeAggregateProperties( Sequence
< Property
>& _rAggregateProps
) const
304 OControlModel::describeAggregateProperties( _rAggregateProps
);
306 // our aggregate (the SvxUnoText) declares a FontDescriptor property, as does
307 // our FormControlFont base class. We remove it from the base class' sequence
308 // here, and later on care for both instances being in sync
309 lcl_removeProperty( _rAggregateProps
, PROPERTY_FONT
);
311 // similar, the WritingMode property is declared in our aggregate, too, but we override
312 // it, since the aggregate does no proper PropertyState handling.
313 lcl_removeProperty( _rAggregateProps
, PROPERTY_WRITING_MODE
);
316 //--------------------------------------------------------------------
317 void SAL_CALL
ORichTextModel::getFastPropertyValue( Any
& _rValue
, sal_Int32 _nHandle
) const
319 if ( isRegisteredProperty( _nHandle
) )
321 OPropertyContainerHelper::getFastPropertyValue( _rValue
, _nHandle
);
323 else if ( isFontRelatedProperty( _nHandle
) )
325 FontControlModel::getFastPropertyValue( _rValue
, _nHandle
);
329 OControlModel::getFastPropertyValue( _rValue
, _nHandle
);
333 //--------------------------------------------------------------------
334 sal_Bool SAL_CALL
ORichTextModel::convertFastPropertyValue( Any
& _rConvertedValue
, Any
& _rOldValue
, sal_Int32 _nHandle
, const Any
& _rValue
) throw( IllegalArgumentException
)
336 sal_Bool bModified
= sal_False
;
338 if ( isRegisteredProperty( _nHandle
) )
340 bModified
= OPropertyContainerHelper::convertFastPropertyValue( _rConvertedValue
, _rOldValue
, _nHandle
, _rValue
);
342 else if ( isFontRelatedProperty( _nHandle
) )
344 bModified
= FontControlModel::convertFastPropertyValue( _rConvertedValue
, _rOldValue
, _nHandle
, _rValue
);
348 bModified
= OControlModel::convertFastPropertyValue( _rConvertedValue
, _rOldValue
, _nHandle
, _rValue
);
354 //--------------------------------------------------------------------
355 void SAL_CALL
ORichTextModel::setFastPropertyValue_NoBroadcast( sal_Int32 _nHandle
, const Any
& _rValue
) throw ( Exception
)
357 if ( isRegisteredProperty( _nHandle
) )
359 OPropertyContainerHelper::setFastPropertyValue( _nHandle
, _rValue
);
363 case PROPERTY_ID_REFERENCE_DEVICE
:
365 #if OSL_DEBUG_LEVEL > 0
366 MapMode aOldMapMode
= m_pEngine
->GetRefDevice()->GetMapMode();
369 OutputDevice
* pRefDevice
= VCLUnoHelper::GetOutputDevice( m_xReferenceDevice
);
370 OSL_ENSURE( pRefDevice
, "ORichTextModel::setFastPropertyValue_NoBroadcast: empty reference device?" );
371 m_pEngine
->SetRefDevice( pRefDevice
);
373 #if OSL_DEBUG_LEVEL > 0
374 MapMode aNewMapMode
= m_pEngine
->GetRefDevice()->GetMapMode();
375 OSL_ENSURE( aNewMapMode
.GetMapUnit() == aOldMapMode
.GetMapUnit(),
376 "ORichTextModel::setFastPropertyValue_NoBroadcast: You should not tamper with the MapUnit of the ref device!" );
377 // if this assertion here is triggered, then we would need to adjust all
378 // items in all text portions in all paragraphs in the attributes of the EditEngine,
379 // as long as they are MapUnit-dependent. This holds at least for the FontSize.
384 case PROPERTY_ID_TEXT
:
386 MutexRelease
aReleaseMutex( m_aMutex
);
387 impl_smlock_setEngineText( m_sLastKnownEngineText
);
390 } // switch ( _nHandle )
392 else if ( isFontRelatedProperty( _nHandle
) )
394 FontDescriptor
aOldFont( getFont() );
396 FontControlModel::setFastPropertyValue_NoBroadcast( _nHandle
, _rValue
);
398 if ( isFontAggregateProperty( _nHandle
) )
399 firePropertyChange( PROPERTY_ID_FONT
, makeAny( getFont() ), makeAny( aOldFont
) );
405 case PROPERTY_ID_WRITING_MODE
:
407 // forward to our aggregate, so the EditEngine knows about it
408 if ( m_xAggregateSet
.is() )
409 m_xAggregateSet
->setPropertyValue(
410 OUString( "WritingMode" ), _rValue
);
415 OControlModel::setFastPropertyValue_NoBroadcast( _nHandle
, _rValue
);
421 //--------------------------------------------------------------------
422 Any
ORichTextModel::getPropertyDefaultByHandle( sal_Int32 _nHandle
) const
428 case PROPERTY_ID_WRITING_MODE
:
429 case PROPERTY_ID_CONTEXT_WRITING_MODE
:
430 aDefault
<<= WritingMode2::CONTEXT
;
433 case PROPERTY_ID_LINEEND_FORMAT
:
434 aDefault
<<= (sal_Int16
)LineEndFormat::LINE_FEED
;
437 case PROPERTY_ID_ECHO_CHAR
:
438 case PROPERTY_ID_ALIGN
:
439 case PROPERTY_ID_MAXTEXTLEN
:
440 aDefault
<<= (sal_Int16
)0;
443 case PROPERTY_ID_TABSTOP
:
444 case PROPERTY_ID_BACKGROUNDCOLOR
:
445 case PROPERTY_ID_BORDERCOLOR
:
446 case PROPERTY_ID_VERTICAL_ALIGN
:
450 case PROPERTY_ID_ENABLED
:
451 case PROPERTY_ID_ENABLEVISIBLE
:
452 case PROPERTY_ID_PRINTABLE
:
453 case PROPERTY_ID_HIDEINACTIVESELECTION
:
454 aDefault
<<= (sal_Bool
)sal_True
;
457 case PROPERTY_ID_HARDLINEBREAKS
:
458 case PROPERTY_ID_HSCROLL
:
459 case PROPERTY_ID_VSCROLL
:
460 case PROPERTY_ID_READONLY
:
461 case PROPERTY_ID_MULTILINE
:
462 case PROPERTY_ID_RICH_TEXT
:
463 aDefault
<<= (sal_Bool
)sal_False
;
466 case PROPERTY_ID_DEFAULTCONTROL
:
467 aDefault
<<= (OUString
)FRM_SUN_CONTROL_RICHTEXTCONTROL
;
470 case PROPERTY_ID_HELPTEXT
:
471 case PROPERTY_ID_HELPURL
:
472 case PROPERTY_ID_TEXT
:
473 aDefault
<<= OUString();
476 case PROPERTY_ID_BORDER
:
477 aDefault
<<= (sal_Int16
)1;
481 if ( isFontRelatedProperty( _nHandle
) )
482 aDefault
= FontControlModel::getPropertyDefaultByHandle( _nHandle
);
484 aDefault
= OControlModel::getPropertyDefaultByHandle( _nHandle
);
490 //--------------------------------------------------------------------
491 void ORichTextModel::impl_smlock_setEngineText( const OUString
& _rText
)
493 if ( m_pEngine
.get() )
495 SolarMutexGuard aSolarGuard
;
496 m_bSettingEngineText
= true;
497 m_pEngine
->SetText( _rText
);
498 m_bSettingEngineText
= false;
502 //--------------------------------------------------------------------
503 OUString SAL_CALL
ORichTextModel::getServiceName() throw ( RuntimeException
)
505 return OUString(FRM_SUN_COMPONENT_RICHTEXTCONTROL
);
508 //--------------------------------------------------------------------
509 void SAL_CALL
ORichTextModel::write(const Reference
< XObjectOutputStream
>& _rxOutStream
) throw ( IOException
, RuntimeException
)
511 OControlModel::write( _rxOutStream
);
512 // TODO: place your code here
515 //--------------------------------------------------------------------
516 void SAL_CALL
ORichTextModel::read(const Reference
< XObjectInputStream
>& _rxInStream
) throw ( IOException
, RuntimeException
)
518 OControlModel::read( _rxInStream
);
519 // TODO: place your code here
522 //--------------------------------------------------------------------
523 RichTextEngine
* ORichTextModel::getEditEngine( const Reference
< XControlModel
>& _rxModel
)
525 RichTextEngine
* pEngine
= NULL
;
527 Reference
< XUnoTunnel
> xTunnel( _rxModel
, UNO_QUERY
);
528 OSL_ENSURE( xTunnel
.is(), "ORichTextModel::getEditEngine: invalid model!" );
533 pEngine
= reinterpret_cast< RichTextEngine
* >( xTunnel
->getSomething( getEditEngineTunnelId() ) );
535 catch( const Exception
& )
537 OSL_FAIL( "ORichTextModel::getEditEngine: caught an exception!" );
543 //--------------------------------------------------------------------
544 Sequence
< sal_Int8
> ORichTextModel::getEditEngineTunnelId()
546 static ::cppu::OImplementationId
* pId
= 0;
549 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
552 static ::cppu::OImplementationId aId
;
556 return pId
->getImplementationId();
559 //--------------------------------------------------------------------
560 IMPL_LINK( ORichTextModel
, OnEngineContentModified
, void*, /*_pNotInterestedIn*/ )
562 if ( !m_bSettingEngineText
)
564 m_aModifyListeners
.notifyEach( &XModifyListener::modified
, EventObject( *this ) );
566 potentialTextChange();
567 // is this a good idea? It may become expensive in case of larger texts,
568 // and this method here is called for every single changed character ...
569 // On the other hand, the API *requires* us to notify changes in the "Text"
570 // property immediately ...
576 //--------------------------------------------------------------------
577 sal_Int64 SAL_CALL
ORichTextModel::getSomething( const Sequence
< sal_Int8
>& _rId
) throw (RuntimeException
)
579 Sequence
< sal_Int8
> aEditEngineAccessId( getEditEngineTunnelId() );
580 if ( ( _rId
.getLength() == aEditEngineAccessId
.getLength() )
581 && ( 0 == memcmp( aEditEngineAccessId
.getConstArray(), _rId
.getConstArray(), _rId
.getLength() ) )
583 return reinterpret_cast< sal_Int64
>( m_pEngine
.get() );
585 Reference
< XUnoTunnel
> xAggTunnel
;
586 if ( query_aggregation( m_xAggregate
, xAggTunnel
) )
587 return xAggTunnel
->getSomething( _rId
);
592 //--------------------------------------------------------------------
593 void SAL_CALL
ORichTextModel::addModifyListener( const Reference
< XModifyListener
>& _rxListener
) throw (RuntimeException
)
595 m_aModifyListeners
.addInterface( _rxListener
);
598 //--------------------------------------------------------------------
599 void SAL_CALL
ORichTextModel::removeModifyListener( const Reference
< XModifyListener
>& _rxListener
) throw (RuntimeException
)
601 m_aModifyListeners
.removeInterface( _rxListener
);
604 //--------------------------------------------------------------------
605 void ORichTextModel::potentialTextChange( )
607 OUString sCurrentEngineText
;
608 if ( m_pEngine
.get() )
609 sCurrentEngineText
= m_pEngine
->GetText();
611 if ( sCurrentEngineText
!= m_sLastKnownEngineText
)
613 sal_Int32 nHandle
= PROPERTY_ID_TEXT
;
614 Any aOldValue
; aOldValue
<<= m_sLastKnownEngineText
;
615 Any aNewValue
; aNewValue
<<= sCurrentEngineText
;
616 fire( &nHandle
, &aNewValue
, &aOldValue
, 1, sal_False
);
618 m_sLastKnownEngineText
= sCurrentEngineText
;
622 //........................................................................
624 //........................................................................
626 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */