2010-10-12 15:57:08 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-06-21 14:30:25 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2004-05-07 15:12:42 +00:00
|
|
|
|
|
|
|
#include "richtextengine.hxx"
|
2009-10-16 00:05:16 +02:00
|
|
|
#include <svl/itempool.hxx>
|
2010-01-08 18:32:51 +01:00
|
|
|
#include <editeng/eeitem.hxx>
|
|
|
|
#include <editeng/editobj.hxx>
|
|
|
|
#include <editeng/fhgtitem.hxx>
|
|
|
|
#include <editeng/fontitem.hxx>
|
|
|
|
#include <editeng/langitem.hxx>
|
2004-05-07 15:12:42 +00:00
|
|
|
#include <vcl/svapp.hxx>
|
2010-11-23 18:41:04 +01:00
|
|
|
#include <tools/mapunit.hxx>
|
2004-05-07 15:12:42 +00:00
|
|
|
#include <vcl/mapmod.hxx>
|
|
|
|
#include <vcl/outdev.hxx>
|
2009-10-06 07:38:24 +02:00
|
|
|
#include <unotools/lingucfg.hxx>
|
2009-10-16 00:05:16 +02:00
|
|
|
#include <svl/undo.hxx>
|
2010-10-16 03:15:49 -05:00
|
|
|
#include <osl/mutex.hxx>
|
2004-05-07 15:12:42 +00:00
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
#include <functional>
|
|
|
|
|
|
|
|
//........................................................................
|
|
|
|
namespace frm
|
|
|
|
{
|
|
|
|
//........................................................................
|
|
|
|
|
|
|
|
//====================================================================
|
|
|
|
//= RichTextEngine
|
|
|
|
//====================================================================
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
RichTextEngine* RichTextEngine::Create()
|
|
|
|
{
|
Lock SolarMutex in RichtTextEngine::Create
...as always, the question is where exactly to place the mutex guard, but
without it querying for XServiceInfo of a freshly instantiated
"stardiv.one.form.component.Edit" (i.e., OFormattedFieldWrapper) would lead to
failing
> DbgTestSolarMutex () at include/tools/debug.hxx:295
> OutputDevice::ImplGetGraphics (this=0x2b81dc11e680) at vcl/source/gdi/outdev.cxx:560
> OutputDevice::DrawRect (this=0x2b81dc11e680, rRect=Rectangle = {...}) at vcl/source/gdi/outdev.cxx:1649
> OutputDevice::ImplDrawColorWallpaper (this=0x2b81dc11e680, nX=0, nY=0, nWidth=1, nHeight=1, rWallpaper=...) at vcl/source/gdi/outdev6.cxx:778
> OutputDevice::ImplDrawWallpaper (this=0x2b81dc11e680, nX=0, nY=0, nWidth=1, nHeight=1, rWallpaper=...) at vcl/source/gdi/outdev6.cxx:1083
> OutputDevice::Erase (this=0x2b81dc11e680) at vcl/source/gdi/outdev6.cxx:1144
> VirtualDevice::ImplInitVirDev (this=0x2b81dc11e680, pOutDev=0x28dc0a0, nDX=1, nDY=1, nBitCount=0, pData=0x0) at vcl/source/gdi/virdev.cxx:114
> VirtualDevice::VirtualDevice (this=0x2b81dc11e680, nBitCount=0) at vcl/source/gdi/virdev.cxx:136
> ImpEditEngine::SetRefDevice (this=0x2b81dc045f10, pRef=0x0) at editeng/source/editeng/impedit2.cxx:195
> ImpEditEngine::ImpEditEngine (this=0x2b81dc045f10, pEE=0x2b81dc0c8a00, pItemPool=0x2b81dc0a0960) at editeng/source/editeng/impedit2.cxx:156
> EditEngine::EditEngine (this=0x2b81dc0c8a00, pItemPool=0x2b81dc0a0960) at editeng/source/editeng/editeng.cxx:104
> frm::RichTextEngine::RichTextEngine (this=0x2b81dc0c8a00, _pPool=0x2b81dc0a0960) at forms/source/richtext/richtextengine.cxx:103
> frm::RichTextEngine::Create () at forms/source/richtext/richtextengine.cxx:52
> frm::ORichTextModel::ORichTextModel (this=0x2b81d866ff30, _rxFactory=uno::Reference to (cppu::ComponentContext *) 0x2b813a244dd8) at forms/source/richtext/richtextmodel.cxx:66
> frm::ORichTextModel::Create (_rxFactory=uno::Reference to (cppuhelper::ServiceManager *) 0x2b813a25a260) at forms/source/richtext/richtextmodel.cxx:243
> cppu::OSingleFactoryHelper::createInstanceEveryTime (this=0x2b819d66a6a0, xContext=uno::Reference to (cppu::ComponentContext *) 0x2b813a244dd8) at cppuhelper/source/factory.cxx:171
> cppu::OSingleFactoryHelper::createInstanceWithContext (this=0x2b819d66a6a0, xContext=uno::Reference to (cppu::ComponentContext *) 0x2b813a244dd8) at cppuhelper/source/factory.cxx:203
> cppu::OFactoryComponentHelper::createInstanceWithContext (this=0x2b819d66a638, xContext=uno::Reference to (cppu::ComponentContext *) 0x2b813a244dd8) at cppuhelper/source/factory.cxx:432
> non-virtual thunk to cppu::OFactoryComponentHelper::createInstanceWithContext(com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const&) () at cppuhelper/source/factory.cxx:433
> cppuhelper::ServiceManager::createInstanceWithContext (this=0x2b813a25a208, aServiceSpecifier="com.sun.star.form.component.RichTextControl", Context=uno::Reference to (cppu::ComponentContext *) 0x2b813a244dd8) at cppuhelper/source/servicemanager.cxx:979
> non-virtual thunk to cppuhelper::ServiceManager::createInstanceWithContext(rtl::OUString const&, com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const&) () at cppuhelper/source/servicemanager.cxx:987
> frm::OControlModel::OControlModel (this=0x2b81d8679408, _rxContext=uno::Reference to (cppu::ComponentContext *) 0x2b813a244dd8, _rUnoControlModelTypeName="com.sun.star.form.component.RichTextControl", rDefault="com.sun.star.form.control.TextField", _bSetDelegator=0 '\000') at forms/source/component/FormComponent.cxx:593
> frm::OBoundControlModel::OBoundControlModel (this=0x2b81d8679408, _rxFactory=uno::Reference to (cppu::ComponentContext *) 0x2b813a244dd8, _rUnoControlModelTypeName="com.sun.star.form.component.RichTextControl", _rDefault="com.sun.star.form.control.TextField", _bCommitable=1 '\001', _bSupportExternalBinding=1 '\001', _bSupportsValidation=1 '\001') at forms/source/component/FormComponent.cxx:1273
> frm::OEditBaseModel::OEditBaseModel (this=0x2b81d8679408, _rxFactory=uno::Reference to (cppu::ComponentContext *) 0x2b813a244dd8, rUnoControlModelName="com.sun.star.form.component.RichTextControl", rDefault="com.sun.star.form.control.TextField", _bSupportExternalBinding=1 '\001', _bSupportsValidation=1 '\001') at forms/source/component/EditBase.cxx:57
> frm::OEditModel::OEditModel (this=0x2b81d8679408, _rxFactory=uno::Reference to (cppu::ComponentContext *) 0x2b813a244dd8) at forms/source/component/Edit.cxx:296
> frm::OEditModel_CreateInstance (_rxFactory=uno::Reference to (cppuhelper::ServiceManager *) 0x2b813a25a260) at forms/source/component/Edit.cxx:280
> cppu::OSingleFactoryHelper::createInstanceEveryTime (this=0x2b819d66a5c0, xContext=uno::Reference to (cppu::ComponentContext *) 0x2b813a244dd8) at cppuhelper/source/factory.cxx:171
> cppu::OSingleFactoryHelper::createInstanceWithContext (this=0x2b819d66a5c0, xContext=uno::Reference to (cppu::ComponentContext *) 0x2b813a244dd8) at cppuhelper/source/factory.cxx:203
> cppu::OFactoryComponentHelper::createInstanceWithContext (this=0x2b819d66a558, xContext=uno::Reference to (cppu::ComponentContext *) 0x2b813a244dd8) at cppuhelper/source/factory.cxx:432
> non-virtual thunk to cppu::OFactoryComponentHelper::createInstanceWithContext(com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const&) () at cppuhelper/source/factory.cxx:433
> cppuhelper::ServiceManager::createInstanceWithContext (this=0x2b813a25a208, aServiceSpecifier="com.sun.star.form.component.TextField", Context=uno::Reference to (cppu::ComponentContext *) 0x2b813a244dd8) at cppuhelper/source/servicemanager.cxx:979
> non-virtual thunk to cppuhelper::ServiceManager::createInstanceWithContext(rtl::OUString const&, com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const&) () at cppuhelper/source/servicemanager.cxx:987
> frm::OFormattedFieldWrapper::ensureAggregate (this=0x2b81d8879818) at forms/source/component/FormattedFieldWrapper.cxx:342
> frm::OFormattedFieldWrapper::queryAggregation (this=0x2b81d8879818, _rType=invalid uno::Type) at forms/source/component/FormattedFieldWrapper.cxx:164
> cppu::OWeakAggObject::queryInterface (this=0x2b81d8879818, rType=invalid uno::Type) at cppuhelper/source/weak.cxx:281
> frm::OFormattedFieldWrapper::queryInterface (this=0x2b81d8879818, _rType=invalid uno::Type) at forms/source/component/FormattedFieldWrapper.hxx:68
> com::sun::star::uno::BaseReference::iquery (pInterface=0x2b81d8879818, rType=invalid uno::Type) at include/com/sun/star/uno/Reference.hxx:43
> com::sun::star::uno::Reference<com::sun::star::lang::XServiceInfo>::iquery (pInterface=0x2b81d8879818) at include/com/sun/star/uno/Reference.hxx:58
> com::sun::star::uno::Reference<com::sun::star::lang::XServiceInfo>::Reference (this=0x2b81d8663a98, rRef=...) at include/com/sun/star/uno/Reference.hxx:158
Change-Id: I16ebbb2caf4f0fe943c9e43bddde03b5a2627e35
2014-01-08 14:09:15 +01:00
|
|
|
SolarMutexGuard g;
|
|
|
|
|
2004-05-07 15:12:42 +00:00
|
|
|
SfxItemPool* pPool = EditEngine::CreatePool();
|
|
|
|
pPool->FreezeIdRanges();
|
|
|
|
|
|
|
|
RichTextEngine* pReturn = new RichTextEngine( pPool );
|
|
|
|
OutputDevice* pOutputDevice = pReturn->GetRefDevice();
|
|
|
|
MapMode aDeviceMapMode( pOutputDevice->GetMapMode() );
|
|
|
|
|
|
|
|
pReturn->SetStatusEventHdl( LINK( pReturn, RichTextEngine, EditEngineStatusChanged ) );
|
|
|
|
|
2004-05-12 14:44:51 +00:00
|
|
|
pPool->SetDefaultMetric( (SfxMapUnit)( aDeviceMapMode.GetMapUnit() ) );
|
2004-05-07 15:12:42 +00:00
|
|
|
|
|
|
|
// defaults
|
|
|
|
Font aFont = Application::GetSettings().GetStyleSettings().GetAppFont();
|
2013-09-25 14:30:51 +02:00
|
|
|
aFont.SetName( "Times New Roman" );
|
|
|
|
pPool->SetPoolDefaultItem( SvxFontItem( aFont.GetFamily(), aFont.GetName(), OUString(), aFont.GetPitch(), aFont.GetCharSet(), EE_CHAR_FONTINFO ) );
|
2004-05-07 15:12:42 +00:00
|
|
|
|
|
|
|
// 12 pt font size
|
|
|
|
MapMode aPointMapMode( MAP_POINT );
|
|
|
|
Size a12PointSize( OutputDevice::LogicToLogic( Size( 12, 0 ), aPointMapMode, aDeviceMapMode ) );
|
|
|
|
pPool->SetPoolDefaultItem( SvxFontHeightItem( a12PointSize.Width(), 100, EE_CHAR_FONTHEIGHT ) );
|
|
|
|
|
|
|
|
// font languages
|
|
|
|
SvtLinguOptions aLinguOpt;
|
|
|
|
pPool->SetPoolDefaultItem( SvxLanguageItem( aLinguOpt.nDefaultLanguage, EE_CHAR_LANGUAGE ) );
|
|
|
|
pPool->SetPoolDefaultItem( SvxLanguageItem( aLinguOpt.nDefaultLanguage_CJK, EE_CHAR_LANGUAGE_CJK ) );
|
|
|
|
pPool->SetPoolDefaultItem( SvxLanguageItem( aLinguOpt.nDefaultLanguage_CTL, EE_CHAR_LANGUAGE_CTL ) );
|
|
|
|
|
|
|
|
return pReturn;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
RichTextEngine* RichTextEngine::Clone()
|
|
|
|
{
|
2007-11-21 15:35:42 +00:00
|
|
|
RichTextEngine* pClone( NULL );
|
|
|
|
{
|
2010-10-13 04:35:41 -05:00
|
|
|
SolarMutexGuard aGuard;
|
2007-11-21 15:35:42 +00:00
|
|
|
EditTextObject* pMyText = CreateTextObject();
|
|
|
|
OSL_ENSURE( pMyText, "RichTextEngine::Clone: CreateTextObject returned nonsense!" );
|
|
|
|
|
|
|
|
pClone = Create();
|
|
|
|
|
|
|
|
if ( pMyText )
|
|
|
|
pClone->SetText( *pMyText );
|
|
|
|
delete pMyText;
|
|
|
|
}
|
2004-05-07 15:12:42 +00:00
|
|
|
|
|
|
|
return pClone;
|
|
|
|
}
|
|
|
|
|
2007-07-06 08:56:09 +00:00
|
|
|
DBG_NAME(RichTextEngine)
|
2004-05-07 15:12:42 +00:00
|
|
|
//--------------------------------------------------------------------
|
|
|
|
RichTextEngine::RichTextEngine( SfxItemPool* _pPool )
|
|
|
|
:EditEngine( _pPool )
|
|
|
|
,m_pEnginePool( _pPool )
|
|
|
|
{
|
2007-07-06 08:56:09 +00:00
|
|
|
DBG_CTOR(RichTextEngine,NULL);
|
2004-05-07 15:12:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
RichTextEngine::~RichTextEngine( )
|
|
|
|
{
|
2007-07-06 08:56:09 +00:00
|
|
|
DBG_DTOR(RichTextEngine,NULL);
|
2004-05-07 15:12:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
void RichTextEngine::registerEngineStatusListener( IEngineStatusListener* _pListener )
|
|
|
|
{
|
|
|
|
OSL_ENSURE( _pListener, "RichTextEngine::registerEngineStatusListener: invalid listener!" );
|
|
|
|
if ( _pListener )
|
|
|
|
m_aStatusListeners.push_back( _pListener );
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
void RichTextEngine::revokeEngineStatusListener( IEngineStatusListener* _pListener )
|
|
|
|
{
|
|
|
|
::std::vector< IEngineStatusListener* >::iterator aPos = ::std::find_if(
|
|
|
|
m_aStatusListeners.begin(),
|
|
|
|
m_aStatusListeners.end(),
|
|
|
|
::std::bind2nd( ::std::equal_to< IEngineStatusListener* >( ), _pListener )
|
|
|
|
);
|
|
|
|
OSL_ENSURE( aPos != m_aStatusListeners.end(), "RichTextEngine::revokeEngineStatusListener: listener not registered!" );
|
|
|
|
if ( aPos != m_aStatusListeners.end() )
|
|
|
|
m_aStatusListeners.erase( aPos );
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
IMPL_LINK( RichTextEngine, EditEngineStatusChanged, EditStatus*, _pStatus )
|
|
|
|
{
|
|
|
|
for ( ::std::vector< IEngineStatusListener* >::const_iterator aLoop = m_aStatusListeners.begin();
|
|
|
|
aLoop != m_aStatusListeners.end();
|
|
|
|
++aLoop
|
|
|
|
)
|
|
|
|
(*aLoop)->EditEngineStatusChanged( *_pStatus );
|
|
|
|
return 0L;
|
|
|
|
}
|
|
|
|
|
|
|
|
//........................................................................
|
|
|
|
} // namespace frm
|
|
|
|
//........................................................................
|
|
|
|
|
2010-10-12 15:57:08 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|