24#include <property.hxx>
27#include <com/sun/star/awt/LineEndFormat.hpp>
28#include <com/sun/star/beans/PropertyAttribute.hpp>
29#include <com/sun/star/form/FormComponentType.hpp>
30#include <com/sun/star/text/WritingMode2.hpp>
31#include <com/sun/star/style/VerticalAlignment.hpp>
55 namespace WritingMode2 = ::com::sun::star::text::WritingMode2;
58 :OControlModel ( _rxFactory, OUString() )
59 ,FontControlModel ( true )
60 ,m_pEngine ( RichTextEngine::
Create() )
61 ,m_bSettingEngineText( false )
64 m_nClassId = FormComponentType::TEXTFIELD;
91 ORichTextModel::ORichTextModel(
const ORichTextModel* _pOriginal,
const Reference< XComponentContext >& _rxFactory )
92 :OControlModel ( _pOriginal, _rxFactory, false )
93 ,FontControlModel ( _pOriginal )
94 ,m_bSettingEngineText( false )
98 m_aTabStop = _pOriginal->m_aTabStop;
99 m_aBackgroundColor = _pOriginal->m_aBackgroundColor;
100 m_aBorderColor = _pOriginal->m_aBorderColor;
101 m_aVerticalAlignment = _pOriginal->m_aVerticalAlignment;
102 m_sDefaultControl = _pOriginal->m_sDefaultControl;
103 m_sHelpText = _pOriginal->m_sHelpText;
104 m_sHelpURL = _pOriginal->m_sHelpURL;
105 m_nBorder = _pOriginal->m_nBorder;
106 m_bEnabled = _pOriginal->m_bEnabled;
107 m_bEnableVisible = _pOriginal->m_bEnableVisible;
108 m_bHardLineBreaks = _pOriginal->m_bHardLineBreaks;
109 m_bHScroll = _pOriginal->m_bHScroll;
110 m_bVScroll = _pOriginal->m_bVScroll;
111 m_bReadonly = _pOriginal->m_bReadonly;
112 m_bPrintable = _pOriginal->m_bPrintable;
113 m_bReallyActAsRichText = _pOriginal->m_bReallyActAsRichText;
114 m_bHideInactiveSelection = _pOriginal->m_bHideInactiveSelection;
115 m_nLineEndFormat = _pOriginal->m_nLineEndFormat;
116 m_nTextWritingMode = _pOriginal->m_nTextWritingMode;
117 m_nContextWritingMode = _pOriginal->m_nContextWritingMode;
119 m_aAlign = _pOriginal->m_aAlign;
120 m_nEchoChar = _pOriginal->m_nEchoChar;
121 m_nMaxTextLength = _pOriginal->m_nMaxTextLength;
122 m_bMultiLine = _pOriginal->m_bMultiLine;
124 m_pEngine.reset(_pOriginal->m_pEngine->Clone());
125 m_sLastKnownEngineText = m_pEngine->GetText();
131 void ORichTextModel::implInit()
133 OSL_ENSURE(m_pEngine,
"ORichTextModel::implInit: where's the engine?");
138 EEControlBits nEngineControlWord = m_pEngine->GetControlWord();
139 nEngineControlWord = nEngineControlWord &
~EEControlBits::AUTOPAGESIZE;
140 m_pEngine->SetControlWord( nEngineControlWord );
145 pUnoRefDevice->SetOutputDevice( m_pEngine->GetRefDevice() );
147 m_xReferenceDevice = pUnoRefDevice;
151 implRegisterProperties();
155 void ORichTextModel::implDoAggregation()
161 setAggregation( m_xAggregate );
169 void ORichTextModel::implRegisterProperties()
172 &m_sDefaultControl,
cppu::UnoType<
decltype(m_sDefaultControl)>::get() );
180 &m_bEnableVisible,
cppu::UnoType<
decltype(m_bEnableVisible)>::get() );
184 &m_bHardLineBreaks,
cppu::UnoType<
decltype(m_bHardLineBreaks)>::get() );
192 &m_bPrintable,
cppu::UnoType<
decltype(m_bPrintable)>::get() );
194 &m_xReferenceDevice,
cppu::UnoType<
decltype(m_xReferenceDevice)>::get() );
196 &m_bReallyActAsRichText,
cppu::UnoType<
decltype(m_bReallyActAsRichText)>::get() );
198 &m_bHideInactiveSelection,
cppu::UnoType<
decltype(m_bHideInactiveSelection)>::get() );
214 &m_nMaxTextLength,
cppu::UnoType<
decltype(m_nMaxTextLength)>::get() );
216 &m_bMultiLine,
cppu::UnoType<
decltype(m_bMultiLine)>::get() );
218 &m_sLastKnownEngineText,
cppu::UnoType<
decltype(m_sLastKnownEngineText)>::get() );
220 &m_nLineEndFormat,
cppu::UnoType<
decltype(m_nLineEndFormat)>::get() );
222 &m_nTextWritingMode,
cppu::UnoType<
decltype(m_nTextWritingMode)>::get() );
225 PropertyAttribute::TRANSIENT, &m_nContextWritingMode,
cppu::UnoType<
decltype(m_nContextWritingMode)>::get() );
227 registerMayBeVoidProperty(
PROPERTY_ALIGN,
PROPERTY_ID_ALIGN, PropertyAttribute::MAYBEVOID | PropertyAttribute::BOUND | PropertyAttribute::MAYBEDEFAULT,
232 ORichTextModel::~ORichTextModel( )
234 if ( !OComponentHelper::rBHelper.bDisposed )
247 Any SAL_CALL ORichTextModel::queryAggregation(
const Type& _rType )
249 Any aReturn = ORichTextModel_BASE::queryInterface( _rType );
251 if ( !aReturn.hasValue() )
252 aReturn = OControlModel::queryAggregation( _rType );
262 return "com.sun.star.comp.forms.ORichTextModel";
265 Sequence< OUString > SAL_CALL ORichTextModel::getSupportedServiceNames()
267 Sequence< OUString > aOwnNames {
269 "com.sun.star.text.TextRange",
270 "com.sun.star.style.CharacterProperties",
271 "com.sun.star.style.ParagraphProperties",
272 "com.sun.star.style.CharacterPropertiesAsian",
273 "com.sun.star.style.CharacterPropertiesComplex",
274 "com.sun.star.style.ParagraphPropertiesAsian",
275 "com.sun.star.style.ParagraphPropertiesComplex" };
277 return ::comphelper::combineSequences(
278 getAggregateServiceNames(),
279 ::comphelper::concatSequences(
280 OControlModel::getSupportedServiceNames_Static(),
285 css::uno::Reference< css::util::XCloneable > SAL_CALL ORichTextModel::createClone()
288 pClone->clonedFrom(
this);
293 void SAL_CALL ORichTextModel::disposing()
295 m_aModifyListeners.disposeAndClear( EventObject( *
this ) );
296 OControlModel::disposing();
302 void lcl_removeProperty( Sequence< Property >& _rSeq, std::u16string_view _rPropertyName )
305 Property* pEnd = _rSeq.getArray() + _rSeq.getLength();
306 while ( pLoop != pEnd )
308 if ( pLoop->Name == _rPropertyName )
311 _rSeq.realloc( _rSeq.getLength() - 1 );
319 void ORichTextModel::describeFixedProperties( Sequence< Property >& _rProps )
const
321 OControlModel::describeFixedProperties( _rProps );
322 sal_Int32 nOldCount = _rProps.getLength();
323 _rProps.realloc( nOldCount + 1);
324 css::beans::Property* pProperties = _rProps.getArray() + nOldCount;
326 DBG_ASSERT( pProperties == _rProps.getArray() + _rProps.getLength(),
"<...>::describeFixedProperties/getInfoHelper: forgot to adjust the count ?");
329 Sequence< Property > aContainedProperties;
330 describeProperties( aContainedProperties );
333 Sequence< Property > aFontProperties;
334 describeFontRelatedProperties( aFontProperties );
336 _rProps =
concatSequences( aContainedProperties, aFontProperties, _rProps );
340 void ORichTextModel::describeAggregateProperties( Sequence< Property >& _rAggregateProps )
const
342 OControlModel::describeAggregateProperties( _rAggregateProps );
355 void SAL_CALL ORichTextModel::getFastPropertyValue( Any& _rValue, sal_Int32 _nHandle )
const
357 if ( isRegisteredProperty( _nHandle ) )
359 OPropertyContainerHelper::getFastPropertyValue( _rValue, _nHandle );
361 else if ( isFontRelatedProperty( _nHandle ) )
363 FontControlModel::getFastPropertyValue( _rValue, _nHandle );
367 OControlModel::getFastPropertyValue( _rValue, _nHandle );
372 sal_Bool SAL_CALL ORichTextModel::convertFastPropertyValue( Any& _rConvertedValue, Any& _rOldValue, sal_Int32 _nHandle,
const Any& _rValue )
374 bool bModified =
false;
376 if ( isRegisteredProperty( _nHandle ) )
378 bModified = OPropertyContainerHelper::convertFastPropertyValue( _rConvertedValue, _rOldValue, _nHandle, _rValue );
380 else if ( isFontRelatedProperty( _nHandle ) )
382 bModified = FontControlModel::convertFastPropertyValue( _rConvertedValue, _rOldValue, _nHandle, _rValue );
386 bModified = OControlModel::convertFastPropertyValue( _rConvertedValue, _rOldValue, _nHandle, _rValue );
393 void SAL_CALL ORichTextModel::setFastPropertyValue_NoBroadcast( sal_Int32 _nHandle,
const Any& _rValue )
395 if ( isRegisteredProperty( _nHandle ) )
397 OPropertyContainerHelper::setFastPropertyValue( _nHandle, _rValue );
403 #if OSL_DEBUG_LEVEL > 0
404 MapMode aOldMapMode = m_pEngine->GetRefDevice()->GetMapMode();
408 OSL_ENSURE( pRefDevice,
"ORichTextModel::setFastPropertyValue_NoBroadcast: empty reference device?" );
409 m_pEngine->SetRefDevice( pRefDevice );
411 #if OSL_DEBUG_LEVEL > 0
412 MapMode aNewMapMode = m_pEngine->GetRefDevice()->GetMapMode();
414 "ORichTextModel::setFastPropertyValue_NoBroadcast: You should not tamper with the MapUnit of the ref device!" );
425 impl_smlock_setEngineText( m_sLastKnownEngineText );
430 else if ( isFontRelatedProperty( _nHandle ) )
432 FontControlModel::setFastPropertyValue_NoBroadcast_impl(
433 *
this, &ORichTextModel::setDependentFastPropertyValue,
443 if ( m_xAggregateSet.is() )
444 m_xAggregateSet->setPropertyValue(
"WritingMode", _rValue );
449 OControlModel::setFastPropertyValue_NoBroadcast( _nHandle, _rValue );
458 Any ORichTextModel::getPropertyDefaultByHandle( sal_Int32 _nHandle )
const
466 aDefault <<= WritingMode2::CONTEXT;
470 aDefault <<= sal_Int16(LineEndFormat::LINE_FEED);
476 aDefault <<= sal_Int16(0);
509 aDefault <<= OUString();
513 aDefault <<= sal_Int16(1);
517 if ( isFontRelatedProperty( _nHandle ) )
518 aDefault = FontControlModel::getPropertyDefaultByHandle( _nHandle );
520 aDefault = OControlModel::getPropertyDefaultByHandle( _nHandle );
527 void ORichTextModel::impl_smlock_setEngineText(
const OUString& _rText )
532 m_bSettingEngineText =
true;
533 m_pEngine->SetText( _rText );
534 m_bSettingEngineText =
false;
539 OUString SAL_CALL ORichTextModel::getServiceName()
545 RichTextEngine* ORichTextModel::getEditEngine(
const Reference< XControlModel >& _rxModel )
549 Reference< XUnoTunnel > xTunnel( _rxModel, UNO_QUERY );
550 OSL_ENSURE( xTunnel.is(),
"ORichTextModel::getEditEngine: invalid model!" );
555 pEngine = comphelper::getSomething_cast<RichTextEngine>(xTunnel->getSomething(getUnoTunnelId()));
566 const Sequence<sal_Int8> & ORichTextModel::getUnoTunnelId()
575 if ( !m_bSettingEngineText )
577 m_aModifyListeners.notifyEach( &XModifyListener::modified, EventObject( *
this ) );
579 potentialTextChange();
590 if (comphelper::isUnoTunnelId<ORichTextModel>(_rId))
593 Reference< XUnoTunnel > xAggTunnel;
595 return xAggTunnel->getSomething( _rId );
601 void SAL_CALL ORichTextModel::addModifyListener(
const Reference< XModifyListener >& _rxListener )
603 m_aModifyListeners.addInterface( _rxListener );
607 void SAL_CALL ORichTextModel::removeModifyListener(
const Reference< XModifyListener >& _rxListener )
609 m_aModifyListeners.removeInterface( _rxListener );
613 void ORichTextModel::potentialTextChange( )
615 OUString sCurrentEngineText;
617 sCurrentEngineText = m_pEngine->GetText();
619 if ( sCurrentEngineText != m_sLastKnownEngineText )
622 Any aOldValue; aOldValue <<= m_sLastKnownEngineText;
623 Any aNewValue; aNewValue <<= sCurrentEngineText;
624 fire( &
nHandle, &aNewValue, &aOldValue, 1,
false );
626 m_sLastKnownEngineText = sCurrentEngineText;
634extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
636 css::uno::Sequence<css::uno::Any>
const &)
MapUnit GetMapUnit() const
static OutputDevice * GetOutputDevice(const css::uno::Reference< css::awt::XDevice > &rxDevice)
const css::uno::Sequence< sal_Int8 > & getSeq() const
ORichTextModel(const css::uno::Reference< css::uno::XComponentContext > &_rxFactory)
#define DBG_ASSERT(sCon, aError)
#define TOOLS_WARN_EXCEPTION(area, stream)
constexpr OUStringLiteral PROPERTY_TABINDEX
constexpr OUStringLiteral PROPERTY_DEFAULTCONTROL
constexpr OUStringLiteral PROPERTY_REFERENCE_DEVICE
constexpr OUStringLiteral PROPERTY_READONLY
constexpr OUStringLiteral PROPERTY_TEXT
constexpr OUStringLiteral PROPERTY_BACKGROUNDCOLOR
constexpr OUStringLiteral PROPERTY_VERTICAL_ALIGN
constexpr OUStringLiteral PROPERTY_LINEEND_FORMAT
constexpr OUStringLiteral PROPERTY_ALIGN
constexpr OUStringLiteral PROPERTY_HELPURL
constexpr OUStringLiteral PROPERTY_VSCROLL
constexpr OUStringLiteral PROPERTY_MAXTEXTLEN
constexpr OUStringLiteral PROPERTY_HELPTEXT
constexpr OUStringLiteral PROPERTY_PRINTABLE
constexpr OUStringLiteral PROPERTY_HSCROLL
constexpr OUStringLiteral PROPERTY_FONT
constexpr OUStringLiteral PROPERTY_ECHO_CHAR
constexpr OUStringLiteral PROPERTY_HARDLINEBREAKS
constexpr OUStringLiteral PROPERTY_ENABLEVISIBLE
constexpr OUStringLiteral PROPERTY_WRITING_MODE
constexpr OUStringLiteral PROPERTY_BORDERCOLOR
constexpr OUStringLiteral PROPERTY_TABSTOP
constexpr OUStringLiteral PROPERTY_HIDEINACTIVESELECTION
constexpr OUStringLiteral PROPERTY_RICH_TEXT
constexpr OUStringLiteral PROPERTY_BORDER
constexpr OUStringLiteral PROPERTY_MULTILINE
constexpr OUStringLiteral PROPERTY_ENABLED
constexpr OUStringLiteral PROPERTY_CONTEXT_WRITING_MODE
#define LINK(Instance, Class, Member)
css::uno::Sequence< T > concatSequences(const css::uno::Sequence< T > &rS1, const Ss &... rSn)
bool query_aggregation(const css::uno::Reference< css::uno::XAggregation > &_rxAggregate, css::uno::Reference< iface > &_rxOut)
sal_Int64 getSomething_cast(void *p)
ListBox is a bit confusing / different from other form components, so here are a few notes:
IMPL_LINK_NOARG(ORichTextModel, OnEngineContentModified, LinkParamNone *, void)
IMPLEMENT_FORWARD_XTYPEPROVIDER2(ChildWindowPane, ChildWindowPaneInterfaceBase, Pane)
#define PROPERTY_ID_LINEEND_FORMAT
#define PROPERTY_ID_READONLY
#define PROPERTY_ID_PRINTABLE
#define PROPERTY_ID_WRITING_MODE
#define PROPERTY_ID_MAXTEXTLEN
#define PROPERTY_ID_VSCROLL
#define PROPERTY_ID_ENABLEVISIBLE
#define PROPERTY_ID_BACKGROUNDCOLOR
#define PROPERTY_ID_HSCROLL
#define PROPERTY_ID_ECHO_CHAR
#define PROPERTY_ID_ENABLED
#define PROPERTY_ID_HELPTEXT
#define PROPERTY_ID_BORDERCOLOR
#define PROPERTY_ID_HARDLINEBREAKS
#define PROPERTY_ID_HIDEINACTIVESELECTION
#define PROPERTY_ID_ALIGN
#define PROPERTY_ID_VERTICAL_ALIGN
#define PROPERTY_ID_RICH_TEXT
#define PROPERTY_ID_TABSTOP
#define PROPERTY_ID_DEFAULTCONTROL
#define PROPERTY_ID_REFERENCE_DEVICE
#define PROPERTY_ID_MULTILINE
#define PROPERTY_ID_CONTEXT_WRITING_MODE
#define PROPERTY_ID_HELPURL
#define PROPERTY_ID_TABINDEX
#define PROPERTY_ID_BORDER
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_forms_ORichTextModel_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
constexpr OUStringLiteral FRM_SUN_CONTROL_RICHTEXTCONTROL
constexpr OUStringLiteral FRM_SUN_COMPONENT_RICHTEXTCONTROL