/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * 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 .
*/
// a lot of initial settings from our component infos
setPosSize( maComponentInfos.nX, maComponentInfos.nY, maComponentInfos.nWidth, maComponentInfos.nHeight, PosSize::POSSIZE );
// the EditEngine of the model
RichTextEngine* pEngine = ORichTextModel::getEditEngine( _rxModel );
OSL_ENSURE( pEngine, "ORichTextPeer::Create: could not obtain the edit engine from the model!" ); if ( !pEngine ) return nullptr;
// the peer itself
rtl::Reference<ORichTextPeer> pPeer(new ORichTextPeer);
// the VCL control for the peer
VclPtrInstance<RichTextControl> pRichTextControl( pEngine, _pParentWindow, _nStyle, nullptr, pPeer.get() );
// some knittings
pRichTextControl->SetComponentInterface( pPeer );
namespace
{
SfxSlotId lcl_translateConflictingSlot( SfxSlotId _nIDFromPool )
{ // HACK HACK HACK // unfortunately, some of our applications have some conflicting slots, // i.e. slots which have the same UNO name as an existing other (common) // slot. // For instance, both the slots SID_SET_SUPER_SCRIPT (from SVX) and FN_SET_SUPER_SCRIPT // (from SW) have the UNO name "SuperScript". // Now, if the controls lives in a text document, and asks the SfxSlotPool for // the id belonging to "SuperScript", it gets the FN_SET_SUPER_SCRIPT - which // is completely unknown to the EditEngine. // So, we need to translate such conflicting ids.
// Note that the real solution would be to fix the applications to // *not* define conflicting slots. Alternatively, if SFX would provide a slot pool // which is *static* (i.e. independent on the active application), then we // would also never encounter such a conflict.
SfxSlotId nReturn( _nIDFromPool ); switch ( _nIDFromPool )
{ case 20411: /* FM_SET_SUPER_SCRIPT, originating in SW */
nReturn = SID_SET_SUPER_SCRIPT; break; case 20412: /* FN_SET_SUB_SCRIPT, originating in SW */
nReturn = SID_SET_SUB_SCRIPT; break;
} return nReturn;
}
}
rtl::Reference<ORichTextFeatureDispatcher> pDispatcher;
rtl::Reference<OAttributeDispatcher> pAttributeDispatcher; switch ( _nSlotId )
{ case SID_CUT:
pDispatcher = new OClipboardDispatcher( pRichTextControl->getView(), OClipboardDispatcher::eCut ); break;
case SID_COPY:
pDispatcher = new OClipboardDispatcher( pRichTextControl->getView(), OClipboardDispatcher::eCopy ); break;
case SID_PASTE:
pDispatcher = new OPasteClipboardDispatcher( pRichTextControl->getView() ); break;
case SID_SELECTALL:
pDispatcher = new OSelectAllDispatcher( pRichTextControl->getView(), _rURL ); break;
case SID_ATTR_PARA_LEFT_TO_RIGHT: case SID_ATTR_PARA_RIGHT_TO_LEFT:
pAttributeDispatcher = new OParagraphDirectionDispatcher( pRichTextControl->getView(), _nSlotId, _rURL, pRichTextControl ); break;
case SID_TEXTDIRECTION_TOP_TO_BOTTOM: case SID_TEXTDIRECTION_LEFT_TO_RIGHT:
pDispatcher = new OTextDirectionDispatcher( pRichTextControl->getView(), _rURL ); break;
case SID_ATTR_PARA_HANGPUNCTUATION: case SID_ATTR_PARA_FORBIDDEN_RULES: case SID_ATTR_PARA_SCRIPTSPACE:
pAttributeDispatcher = new OAsianFontLayoutDispatcher( pRichTextControl->getView(), _nSlotId, _rURL, pRichTextControl ); break;
namespace
{
SfxSlotId lcl_getSlotFromUnoName( SfxSlotPool const & _rSlotPool, const OUString& _rUnoSlotName )
{ const SfxSlot* pSlot = _rSlotPool.GetUnoSlot( _rUnoSlotName ); if ( pSlot )
{ // okay, there's a slot with the given UNO name return lcl_translateConflictingSlot( pSlot->GetSlotId() );
}
// some hard-coded slots, which do not have a UNO name at SFX level, but which // we nevertheless need to transport via UNO mechanisms, so we need a name if ( _rUnoSlotName == "AllowHangingPunctuation" ) return SID_ATTR_PARA_HANGPUNCTUATION; if ( _rUnoSlotName == "ApplyForbiddenCharacterRules" ) return SID_ATTR_PARA_FORBIDDEN_RULES; if ( _rUnoSlotName == "UseScriptSpacing" ) return SID_ATTR_PARA_SCRIPTSPACE;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.